Commit Graph
235 Commits
Author SHA1 Message Date
Cursor AgentandJulius Marminge 7c19979050 feat(claude): update ClaudeCodeAdapter to emit V2 canonical runtime events
- Replace old event types with V2 content.delta, item.started/completed, request.opened/resolved
- Use RuntimeSessionId, ThreadId, TurnId, RuntimeItemId, RuntimeRequestId branded IDs
- Add payload objects for all event types
- Use CanonicalItemType and CanonicalRequestType for item/request classification
- Include providerRefs on all emitted events

Co-authored-by: Julius Marminge <[email protected]>
2026-03-01 11:44:08 +00:00
Cursor AgentandJulius Marminge 214d6cd867 feat(codex): rewrite CodexAdapter event mapping for V2 canonical runtime events
- Replace old event types (message.delta, tool.started, etc.) with V2 types
- Emit content.delta, item.started/completed, request.opened/resolved
- Add reasoning, plan, command output, and file change delta mappings
- Add turn.plan.updated support
- Use RuntimeSessionId, ThreadId, TurnId, RuntimeItemId branded IDs
- Include providerRefs and raw envelope on all events

Co-authored-by: Julius Marminge <[email protected]>
2026-03-01 11:44:01 +00:00
Cursor AgentandJulius Marminge 46f9391bf3 fix: migrate CheckpointReactor to V2 ProviderRuntimeEvent types
- Import RuntimeSessionId; use string casts for ProviderSessionId vs
  RuntimeSessionId comparisons and 'as unknown as ProviderSessionId'
  for assignments
- Replace event.status with event.payload.state for turn.completed
- Remove checkpoint.captured handler (event removed from V2 union);
  turn.completed already triggers captureCheckpointFromTurnCompletion
- Remove checkpoint.captured from stream event filter
- Update test file: use RuntimeSessionId, ThreadId, TurnId for runtime
  events; replace status with payload.state; add payload field to
  turn.started events; convert checkpoint.captured tests to
  turn.completed equivalents

Co-authored-by: Julius Marminge <[email protected]>
2026-03-01 11:26:16 +00:00
Cursor AgentandJulius Marminge a719a1e68c fix: resolve TypeScript errors in provider adapter test files
- CodexAdapter.test.ts: update 'message.completed' to 'item.completed' (V2),
  fix payload access for session.exited (payload.reason instead of message)
- ClaudeCodeAdapter.test.ts: update old event types to V2 equivalents
  (content.delta, item.started, item.completed, request.opened, request.resolved),
  fix branded ID mismatches using TurnId.makeUnsafe(), fix property access
  patterns (payload.delta, payload.state, payload.itemType, payload.decision)
- ProviderAdapterRegistry.test.ts: add CursorAdapter stub to layer context
- ProviderService.test.ts: remove resumeThreadId from expected assertions
  (not in ProviderSessionStartInput schema), replace sessionSequence assertion
  with event type ordering check
- ProviderService.ts: remove resumeThreadId spread from recoverSessionForThread
  to match schema contract

Co-authored-by: Julius Marminge <[email protected]>
2026-03-01 10:57:19 +00:00
Cursor AgentandJulius Marminge 9304b22b51 Fix test files for V2 ProviderRuntimeEvent migration
- ProviderService.test.ts: Update event construction to use V2 types
  (content.delta, item.started, item.completed, turn.completed with
  payload), V2 branded IDs (RuntimeSessionId, ThreadId, TurnId,
  RuntimeItemId)
- CursorAdapter.test.ts: Replace removed CursorCliStreamEvent tests
  with ACP schema decode tests (AcpInitializeResult,
  AcpSessionNewResult, AcpPermissionRequestParams)
- wsServer.test.ts: Update runtime event emission to V2 content.delta
  shape with payload and V2 branded IDs

Co-authored-by: Julius Marminge <[email protected]>
2026-03-01 10:40:49 +00:00
Julius Marminge 719c7dc28e Introduce v2 provider runtime event schema and validation tests
- Restructure runtime events around a shared base plus typed payloads
- Add runtime-branded IDs and new event types (plan, item, request, user-input)
- Remove legacy canonical event names from docs and add schema decode/rejection tests
2026-03-01 01:29:59 -08:00
Julius Marminge 87c797b16b Add Cursor provider support across backend, contracts, and UI
- Accept `cursor` as a first-class provider in orchestration, persistence, and session directory flows
- Update model/provider inference and normalization to handle Cursor model aliases
- Revamp chat provider/model picker with Cursor-specific trait controls and add coverage in tests
2026-02-28 20:21:37 -08:00
Julius Marmingeandcodex f265f56cb5 Add Cursor CLI stream event schemas and decoding tests
- define `CursorAdapter` service contract and Cursor stream-json schema types
- add `CursorCliStreamEvent` decoding tests for system/thinking/tool/result/retry events
- add implementation plan for Cursor provider integration

Co-authored-by: codex <[email protected]>
2026-02-28 20:21:37 -08:00
Julius Marminge 2c631e8725 Track runtime event sequence and order thread activities by sequence
- add per-session `sessionSequence` on provider runtime events and persist activity `sequence`
- migrate `projection_thread_activities` with nullable `sequence` column + index
- sort server/web activity projections by sequence fallback to timestamp/id
- allow provider sessions/turns to start before a real threadId is emitted
2026-02-28 12:27:45 -08:00
Julius Marminge d75ca11981 Align Claude permissions and provider-specific reasoning effort
- Default Claude sessions to bypass permissions when approval policy is `never`, while preserving explicit `permissionMode`
- Hide/send reasoning effort only for providers that support it in ChatView
- Add coverage for Claude permission-mode derivation and precedence, and update runtime event model docs
2026-02-28 11:28:54 -08:00
Julius Marminge 02c89a5af6 Stabilize Claude turn event ordering and native event logging
- Preserve active turn state when `session.started`/`thread.started` arrive mid-turn
- Emit `message.delta` from assistant text when stream deltas are missing, then complete the message
- Add Claude native SDK NDJSON observability logging and wire its log path in server layers
- Expand ingestion/adapter tests to cover mid-turn lifecycle and delta fallback behavior
2026-02-27 23:53:47 -08:00
Julius Marmingeandcodex 870096b8a3 Fix ProviderService sendTurn recovery expectation after rebase
Co-authored-by: codex <[email protected]>
2026-02-27 21:38:23 -08:00
Julius Marminge 8d23276aff Ignore stale resume cursors and Claude placeholder thread IDs
- Do not pass `resumeCursor` when restarting a session after changing providers
- Treat synthetic Claude thread IDs (`claude-thread-*`) as unscoped during runtime ingestion
- Add tests covering provider-switch restart behavior and Claude turn lifecycle acceptance
2026-02-27 21:35:57 -08:00
Julius Marminge 3e6ac44156 Fix Claude resume cursor to only persist valid session UUIDs
- Stop synthesizing `resume` from generated thread IDs
- Persist resume session ID from query messages when available
- Validate resume/sessionId values as UUIDs before reuse
- Add tests for valid UUID resume passthrough and no synthesized resume
2026-02-27 21:35:57 -08:00
Julius Marminge 6ff39f9097 Refactor ClaudeCodeAdapter session flow and stream handling
- Replace manual prompt async iterator with `Stream.fromQueue(...).toAsyncIterable`
- Use `Ref` for shared session context in tool approval callbacks
- Simplify timestamp/ID generation and close sessions via queue shutdown
2026-02-27 21:35:57 -08:00
Julius Marminge e5f12e6507 Integrate Claude agent SDK into server provider adapter
- add `@anthropic-ai/claude-agent-sdk` dependency for `apps/server`
- replace placeholder Claude adapter with live session/query/event handling
- add comprehensive adapter tests for runtime events, approvals, resume, rollback, and model overrides
2026-02-27 21:35:57 -08:00
Julius Marmingeandcodex e45cd8fec1 Inline Claude adapter behavior into live layer
Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marminge fb1e7c18b2 unnecessary catch 2026-02-27 21:35:28 -08:00
Julius Marmingeandcodex b03287ebea Use typed errors for unavailable Claude runtime path
Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marmingeandcodex 344d9b46f0 Make Claude runtime boundary Effect-native
Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marmingeandcodex fb62d21c05 Add Claude checkpoint and revert reactor coverage
Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marmingeandcodex 1fb357419e Support provider-aware session selection in reactor
Add restart semantics when requested provider changes and cover with tests.

Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marmingeandcodex b8e3b4623d Wire Claude adapter into registry and server provider layer
Add provider-service routing coverage for explicit claudeCode sessions.

Co-authored-by: codex <[email protected]>
2026-02-27 21:35:28 -08:00
Julius Marminge f2e087cba4 Add Claude Code adapter live layer with error mapping tests
- introduce `ClaudeCodeAdapter` service and live layer wiring
- map runtime/session/request failures into provider adapter error types
- add coverage for validation, session-not-found mapping, lifecycle forwarding, and event passthrough
2026-02-27 21:35:28 -08:00
Julius Marminge 2ed16e5e2f redo contracts a bit 2026-02-27 21:35:28 -08:00
Julius Marminge d48b42c017 fix type 2026-02-27 21:32:15 -08:00
Julius Marminge fb45896588 simplify layers 2026-02-27 21:30:46 -08:00
Julius Marminge b52518f85f Flatten attachment paths with message-prefixed filenames
- Write projected attachments under the thread directory using `messageSegment-fileName`
- Avoid nested per-message folders while preserving unique, deterministic file paths
- Update projection pipeline tests to match new attachment URLs and on-disk paths
2026-02-27 21:30:46 -08:00
Julius Marminge 3e99019af8 Serve attachments using URL-encoded relative paths
- Read attachment route paths without URI decoding before normalization
- Align test fixture paths with encoded thread/message/file names
2026-02-27 21:30:46 -08:00
Julius Marminge 7d4b02689e Overwrite attachment bytes for repeated message attachment index
- Make projection attachment writes use last-write-wins per file path
- Always write attachment files so updated message attachments replace stale bytes
- Add regression test covering same message/attachment index update behavior
2026-02-27 21:30:46 -08:00
Julius Marminge 9962f57ad0 Preserve empty attachment updates in projection pipeline
- Treat `attachments: []` as an explicit update instead of dropping the field
- Add regression test covering attachment clearing for an existing thread message
2026-02-27 21:30:46 -08:00
Julius Marminge 8b538e2802 dedupe 2026-02-27 21:30:46 -08:00
Julius Marminge a6c57e169a nit 2026-02-27 21:30:46 -08:00
Julius Marminge 6f92f0a668 kewl 2026-02-27 21:30:46 -08:00
Julius Marminge 35817601ff fixxx 2026-02-27 21:30:46 -08:00
Julius Marminge b9ff7aa5cd Make attachment writes transactional and decode attachment URLs
- Stage attachment file writes until projector transactions commit, then apply write/prune/delete side effects
- Remove orphaned attachment files on thread revert and delete thread attachment dirs on thread deletion
- Serve URL-encoded attachment paths in `wsServer` and stream file responses
- Add regression tests for rollback safety, revert/delete cleanup, and encoded attachment URLs
2026-02-27 21:30:46 -08:00
Julius Marminge b5188e8cea Harden attachment materialization and static file path handling
- Materialize only valid image data URLs and restrict inferred file extensions to a safe whitelist
- Preserve existing message attachments on upsert unless explicitly replaced or cleared
- Serve static `/` via `index.html` and block traversal attempts in static file requests
2026-02-27 21:30:46 -08:00
Julius Marminge 992db16586 Persist and serve projected message image attachments
- Store message attachments in `projection_thread_messages.attachments_json`
- Materialize base64 image attachments to `stateDir/attachments` during projection
- Serve `/attachments/*` from the server and resolve preview URLs from WebSocket origin
- Add migration and tests for projection materialization and attachment serving
2026-02-27 21:30:46 -08:00
Julius Marminge 2aad749e24 Reuse persisted cwd when recovering stale provider sessions
- Read and validate `cwd` from persisted runtime payload when restarting sessions
- Apply persisted `cwd` during stale-session recovery paths, including `sendTurn`
- Add tests to verify resumed sessions preserve the original working directory
2026-02-27 20:58:21 -08:00
Julius Marminge 80498f1709 Handle terminal exit writes and auto-close exited terminal view
- Ignore late write calls after a terminal session has already exited
- Add regression test for trailing writes after exit
- Close terminal drawer session once an exit event is handled
2026-02-27 18:08:18 -08:00
Julius Marminge e6c5a4a4bb Handle favicon links when href precedes rel
- Update favicon regex parsing to support rel/href in either order
- Add route tests for HTML link tags and object-style metadata with href-first ordering
2026-02-27 15:21:31 -08:00
Julius Marminge 732b3abf99 match assets/{icon,logo} as well 2026-02-27 15:21:31 -08:00
Julius Marminge ffbf541ff8 Extract project favicon route and tighten turn-settled logic
- move `/api/project-favicon` handling into a dedicated server route with coverage for root and source-linked icons
- wire `wsServer` to use the new route helper
- treat any running session as unsettled in `isLatestTurnSettled` to prevent stale latest-turn banners, with test coverage
2026-02-27 15:21:31 -08:00
Theo Browne c7ae6b9471 Favicons + custom port during dev 2026-02-27 15:21:31 -08:00
Julius Marminge 3f81f9dcb4 Replace thread latestTurnId with structured latestTurn metadata
- add `OrchestrationLatestTurn` schema and store full turn state/timestamps/message linkage
- update server projector/snapshot queries to populate `latestTurn` from session + projection_turns
- migrate web store/components to consume `latestTurn` and adjust related tests
2026-02-27 14:10:34 -08:00
Julius Marminge b073fea5fb Handle provider turn IDs correctly in runtime ingestion
- Use `ProviderTurnId` in `CheckpointReactor` tests instead of `TurnId`
- Guard `event.turnId` access in provider runtime ingestion when the field is absent
2026-02-27 14:10:34 -08:00
Julius Marminge 872b907372 Guard provider lifecycle updates to primary thread and active turn
- Ignore auxiliary/non-active turn completions for session lifecycle and checkpoints
- Restrict runtime thread/turn IDs to provider IDs in contracts
- Add regression tests and ADR for lifecycle ownership rules
2026-02-27 14:10:34 -08:00
Julius Marminge 041acf158a fix nullability 2026-02-26 21:36:44 -08:00
Julius Marminge f9752d7c08 migr 2026-02-26 21:26:35 -08:00
Julius Marminge 766592b83b tone down defautls 2026-02-26 21:26:35 -08:00