repoburg 1.3.201 → 1.3.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-pane/backend/dist/index.js +2714 -32395
- package/agent-pane/backend/dist/server.js +45304 -0
- package/askuser-after-step5-postgres-selected.png +0 -0
- package/askuser-after-step7-answer-sent.png +0 -0
- package/askuser-card-visible.png +0 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.d.ts +16 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js +87 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js.map +1 -1
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +16 -1
- package/backend/dist/src/app.controller.d.ts +1 -0
- package/backend/dist/src/app.service.d.ts +1 -0
- package/backend/dist/src/app.service.js +4 -1
- package/backend/dist/src/app.service.js.map +1 -1
- package/backend/dist/src/interactive-chat/chat.service.d.ts +4 -0
- package/backend/dist/src/interactive-chat/chat.service.js +21 -1
- package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js +12 -1
- package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +2 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/daemon/dist/agentPane.js +128 -0
- package/daemon/dist/agentPane.spec.js +183 -0
- package/daemon/dist/api/services.js +4 -0
- package/daemon/dist/index.js +28 -8
- package/daemon/dist/serviceManager.js +30 -11
- package/daemon/dist/serviceManager.spec.js +26 -0
- package/daemon/dist/workspace-validation.js +63 -0
- package/daemon/dist/workspace-validation.spec.js +63 -0
- package/daemon/package.json +1 -1
- package/package.json +15 -2
- package/r2-step4-apple-banana.png +0 -0
- package/r2-step5-after-rewind-apple-last.png +0 -0
- package/r2-step7-apple-cherry.png +0 -0
- package/r2-step8-cherry-menu-no-restore.png +0 -0
- package/r3-step3-live-task-card-running.png +0 -0
- package/r3-step4-after-completion.png +0 -0
- package/r3-step5-persistence-after-reload.png +0 -0
- package/r3-step6-tasks-tab-card.png +0 -0
- package/reverify-answered-state-answer-sent.png +0 -0
- package/reverify-card-visible-after-completion.png +0 -0
- package/rewind-step3-apple-banana-turns.png +0 -0
- package/rewind-step5-ui-unchanged-after-confirmed-rewind.png +0 -0
- package/rewind-step6-apple-menu-no-restore.png +0 -0
- package/rewind-step7-final-turnlist-unchanged.png +0 -0
- package/rewind-step7-negative-error-toast.png +0 -0
- package/rewind-step7-negative-error-toast2.png +0 -0
- package/subagent-r2-step5-turn-after-reload-no-card.png +0 -0
- package/subagent-r2-step6-tasks-panel-card.png +0 -0
- package/subagent-step3-tasks-tab-done-card.png +0 -0
- package/subagent-step4-turn-stuck-no-cards.png +0 -0
- package/agent-pane/.prettierignore +0 -5
- package/agent-pane/.prettierrc +0 -8
- package/agent-pane/backend/coverage/base.css +0 -224
- package/agent-pane/backend/coverage/block-navigation.js +0 -87
- package/agent-pane/backend/coverage/clover.xml +0 -887
- package/agent-pane/backend/coverage/coverage-final.json +0 -10
- package/agent-pane/backend/coverage/favicon.png +0 -0
- package/agent-pane/backend/coverage/index.html +0 -176
- package/agent-pane/backend/coverage/prettify.css +0 -1
- package/agent-pane/backend/coverage/prettify.js +0 -2
- package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/backend/coverage/sorter.js +0 -210
- package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +0 -1402
- package/agent-pane/backend/coverage/src/codex/index.html +0 -131
- package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +0 -331
- package/agent-pane/backend/coverage/src/db/index.html +0 -131
- package/agent-pane/backend/coverage/src/db/index.ts.html +0 -436
- package/agent-pane/backend/coverage/src/db/schema.ts.html +0 -175
- package/agent-pane/backend/coverage/src/index.html +0 -116
- package/agent-pane/backend/coverage/src/index.ts.html +0 -262
- package/agent-pane/backend/coverage/src/routes/index.html +0 -146
- package/agent-pane/backend/coverage/src/routes/sessions.ts.html +0 -991
- package/agent-pane/backend/coverage/src/routes/turns.ts.html +0 -256
- package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +0 -406
- package/agent-pane/backend/coverage/src/ws/index.html +0 -116
- package/agent-pane/backend/coverage/src/ws/index.ts.html +0 -238
- package/agent-pane/backend/data.db +0 -0
- package/agent-pane/backend/data.db-shm +0 -0
- package/agent-pane/backend/data.db-wal +0 -0
- package/agent-pane/backend/package-lock.json +0 -5945
- package/agent-pane/backend/package.json +0 -33
- package/agent-pane/backend/scripts/backfill-from-jsonl.ts +0 -206
- package/agent-pane/backend/scripts/import-session-from-jsonl.ts +0 -264
- package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +0 -271
- package/agent-pane/backend/src/claude/claude-message-mapper.ts +0 -259
- package/agent-pane/backend/src/claude/claude-provider.test.ts +0 -455
- package/agent-pane/backend/src/claude/claude-provider.ts +0 -1319
- package/agent-pane/backend/src/claude/claude-types.ts +0 -45
- package/agent-pane/backend/src/codex/app-server-client.test.ts +0 -183
- package/agent-pane/backend/src/codex/app-server-client.ts +0 -247
- package/agent-pane/backend/src/codex/app-server-types.ts +0 -259
- package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +0 -56
- package/agent-pane/backend/src/codex/codex-provider.test.ts +0 -60
- package/agent-pane/backend/src/codex/codex-provider.ts +0 -619
- package/agent-pane/backend/src/codex/item-mapper.test.ts +0 -221
- package/agent-pane/backend/src/codex/item-mapper.ts +0 -86
- package/agent-pane/backend/src/codex/shared-app-server.ts +0 -25
- package/agent-pane/backend/src/db/index.test.ts +0 -125
- package/agent-pane/backend/src/db/index.ts +0 -230
- package/agent-pane/backend/src/db/schema.ts +0 -34
- package/agent-pane/backend/src/index.ts +0 -89
- package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +0 -29
- package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +0 -40
- package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +0 -16
- package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +0 -60
- package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +0 -34
- package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +0 -85
- package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +0 -48
- package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +0 -35
- package/agent-pane/backend/src/integration/delta-streaming.test.ts +0 -130
- package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +0 -272
- package/agent-pane/backend/src/integration/helpers/test-app.ts +0 -110
- package/agent-pane/backend/src/integration/helpers/ws-capture.ts +0 -64
- package/agent-pane/backend/src/integration/item-lifecycle.test.ts +0 -133
- package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +0 -102
- package/agent-pane/backend/src/integration/missing-item-started.test.ts +0 -91
- package/agent-pane/backend/src/integration/multi-turn.test.ts +0 -121
- package/agent-pane/backend/src/integration/session-operations.test.ts +0 -175
- package/agent-pane/backend/src/integration/threads-claude-fork.test.ts +0 -241
- package/agent-pane/backend/src/integration/threads.test.ts +0 -309
- package/agent-pane/backend/src/integration/title-generation.test.ts +0 -109
- package/agent-pane/backend/src/integration/turn-cancel.test.ts +0 -111
- package/agent-pane/backend/src/integration/turn-failure.test.ts +0 -97
- package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +0 -141
- package/agent-pane/backend/src/providers/index.ts +0 -16
- package/agent-pane/backend/src/providers/registry.test.ts +0 -92
- package/agent-pane/backend/src/providers/registry.ts +0 -43
- package/agent-pane/backend/src/providers/runtime-provider.ts +0 -43
- package/agent-pane/backend/src/repoburg/action-mapping.ts +0 -216
- package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +0 -262
- package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/backend-resolver.ts +0 -246
- package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +0 -159
- package/agent-pane/backend/src/repoburg/repoburg-client.ts +0 -181
- package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +0 -723
- package/agent-pane/backend/src/repoburg/repoburg-provider.ts +0 -422
- package/agent-pane/backend/src/repoburg/turn-projector.test.ts +0 -475
- package/agent-pane/backend/src/repoburg/turn-projector.ts +0 -537
- package/agent-pane/backend/src/routes/files.ts +0 -31
- package/agent-pane/backend/src/routes/mcp.ts +0 -33
- package/agent-pane/backend/src/routes/models.test.ts +0 -92
- package/agent-pane/backend/src/routes/models.ts +0 -16
- package/agent-pane/backend/src/routes/plugins.ts +0 -40
- package/agent-pane/backend/src/routes/providers.test.ts +0 -86
- package/agent-pane/backend/src/routes/providers.ts +0 -86
- package/agent-pane/backend/src/routes/sessions.test.ts +0 -558
- package/agent-pane/backend/src/routes/sessions.ts +0 -504
- package/agent-pane/backend/src/routes/skills.test.ts +0 -114
- package/agent-pane/backend/src/routes/skills.ts +0 -70
- package/agent-pane/backend/src/routes/threads.ts +0 -323
- package/agent-pane/backend/src/routes/turns.test.ts +0 -196
- package/agent-pane/backend/src/routes/turns.ts +0 -103
- package/agent-pane/backend/src/routes/workspaces.test.ts +0 -197
- package/agent-pane/backend/src/routes/workspaces.ts +0 -128
- package/agent-pane/backend/src/ws/index.test.ts +0 -107
- package/agent-pane/backend/src/ws/index.ts +0 -51
- package/agent-pane/backend/tsconfig.json +0 -25
- package/agent-pane/backend/vitest.config.ts +0 -20
- package/agent-pane/eslint.config.js +0 -33
- package/agent-pane/frontend/coverage/base.css +0 -224
- package/agent-pane/frontend/coverage/block-navigation.js +0 -87
- package/agent-pane/frontend/coverage/clover.xml +0 -2962
- package/agent-pane/frontend/coverage/coverage-final.json +0 -37
- package/agent-pane/frontend/coverage/favicon.png +0 -0
- package/agent-pane/frontend/coverage/index.html +0 -251
- package/agent-pane/frontend/coverage/prettify.css +0 -1
- package/agent-pane/frontend/coverage/prettify.js +0 -2
- package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/frontend/coverage/sorter.js +0 -210
- package/agent-pane/frontend/coverage/src/App.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +0 -223
- package/agent-pane/frontend/coverage/src/api/client.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/api/index.html +0 -161
- package/agent-pane/frontend/coverage/src/api/sessions.ts.html +0 -316
- package/agent-pane/frontend/coverage/src/api/websocket.ts.html +0 -544
- package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +0 -199
- package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +0 -226
- package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +0 -382
- package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +0 -715
- package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +0 -478
- package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +0 -472
- package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +0 -574
- package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +0 -205
- package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +0 -133
- package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +0 -271
- package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +0 -109
- package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +0 -313
- package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +0 -1216
- package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +0 -1138
- package/agent-pane/frontend/coverage/src/components/index.html +0 -326
- package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +0 -247
- package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +0 -427
- package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +0 -397
- package/agent-pane/frontend/coverage/src/components/panels/index.html +0 -161
- package/agent-pane/frontend/coverage/src/constants/index.html +0 -116
- package/agent-pane/frontend/coverage/src/constants/models.ts.html +0 -406
- package/agent-pane/frontend/coverage/src/hooks/index.html +0 -146
- package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +0 -124
- package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +0 -142
- package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/index.html +0 -146
- package/agent-pane/frontend/coverage/src/main.tsx.html +0 -115
- package/agent-pane/frontend/coverage/src/store/index.html +0 -116
- package/agent-pane/frontend/coverage/src/store/store.ts.html +0 -2404
- package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +0 -190
- package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +0 -367
- package/agent-pane/frontend/coverage/src/test/index.html +0 -131
- package/agent-pane/frontend/coverage/src/types/index.html +0 -116
- package/agent-pane/frontend/coverage/src/types/index.ts.html +0 -466
- package/agent-pane/frontend/coverage/src/utils/changes.ts.html +0 -202
- package/agent-pane/frontend/coverage/src/utils/duration.ts.html +0 -127
- package/agent-pane/frontend/coverage/src/utils/index.html +0 -131
- package/agent-pane/frontend/dist/assets/index-34WaZYsW.css +0 -1
- package/agent-pane/frontend/dist/assets/index-y7xlT86e.js +0 -362
- package/agent-pane/frontend/dist/index.html +0 -19
- package/agent-pane/frontend/index.html +0 -18
- package/agent-pane/frontend/package-lock.json +0 -4211
- package/agent-pane/frontend/package.json +0 -35
- package/agent-pane/frontend/src/App.test.tsx +0 -74
- package/agent-pane/frontend/src/App.tsx +0 -44
- package/agent-pane/frontend/src/AppInitializer.test.tsx +0 -142
- package/agent-pane/frontend/src/AppInitializer.tsx +0 -46
- package/agent-pane/frontend/src/__tests__/ThreadsPanel.test.tsx +0 -192
- package/agent-pane/frontend/src/api/client.test.ts +0 -126
- package/agent-pane/frontend/src/api/client.ts +0 -34
- package/agent-pane/frontend/src/api/models.ts +0 -7
- package/agent-pane/frontend/src/api/providers.ts +0 -17
- package/agent-pane/frontend/src/api/sessions.test.ts +0 -245
- package/agent-pane/frontend/src/api/sessions.ts +0 -97
- package/agent-pane/frontend/src/api/skills.ts +0 -12
- package/agent-pane/frontend/src/api/websocket.test.ts +0 -288
- package/agent-pane/frontend/src/api/websocket.ts +0 -238
- package/agent-pane/frontend/src/api/workspaces.test.ts +0 -112
- package/agent-pane/frontend/src/api/workspaces.ts +0 -38
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +0 -49
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +0 -56
- package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +0 -133
- package/agent-pane/frontend/src/components/CommandInputBar.tsx +0 -584
- package/agent-pane/frontend/src/components/CommandPalette.test.tsx +0 -226
- package/agent-pane/frontend/src/components/CommandPalette.tsx +0 -194
- package/agent-pane/frontend/src/components/CommentableText.test.tsx +0 -196
- package/agent-pane/frontend/src/components/CommentableText.tsx +0 -379
- package/agent-pane/frontend/src/components/IdeWorkspace.test.tsx +0 -39
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +0 -51
- package/agent-pane/frontend/src/components/ModelSelector.test.tsx +0 -129
- package/agent-pane/frontend/src/components/ModelSelector.tsx +0 -191
- package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +0 -95
- package/agent-pane/frontend/src/components/NewSessionDialog.tsx +0 -129
- package/agent-pane/frontend/src/components/RenderArea.test.tsx +0 -160
- package/agent-pane/frontend/src/components/RenderArea.tsx +0 -170
- package/agent-pane/frontend/src/components/ResizeHandle.tsx +0 -29
- package/agent-pane/frontend/src/components/RightPanel.test.tsx +0 -43
- package/agent-pane/frontend/src/components/RightPanel.tsx +0 -46
- package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +0 -32
- package/agent-pane/frontend/src/components/RuntimeIcon.tsx +0 -16
- package/agent-pane/frontend/src/components/SessionTabs.test.tsx +0 -72
- package/agent-pane/frontend/src/components/SessionTabs.tsx +0 -49
- package/agent-pane/frontend/src/components/StatusBar.test.tsx +0 -56
- package/agent-pane/frontend/src/components/StatusBar.tsx +0 -129
- package/agent-pane/frontend/src/components/StatusDot.test.tsx +0 -25
- package/agent-pane/frontend/src/components/StatusDot.tsx +0 -8
- package/agent-pane/frontend/src/components/Toast.test.tsx +0 -79
- package/agent-pane/frontend/src/components/Toast.tsx +0 -76
- package/agent-pane/frontend/src/components/TurnContent.test.tsx +0 -298
- package/agent-pane/frontend/src/components/TurnContent.tsx +0 -548
- package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +0 -297
- package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +0 -351
- package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +0 -32
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +0 -63
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +0 -78
- package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +0 -96
- package/agent-pane/frontend/src/components/input/SlashPopup.tsx +0 -82
- package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +0 -61
- package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +0 -54
- package/agent-pane/frontend/src/components/panels/TasksPanel.test.tsx +0 -97
- package/agent-pane/frontend/src/components/panels/TasksPanel.tsx +0 -208
- package/agent-pane/frontend/src/components/panels/ThreadsPanel.tsx +0 -382
- package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +0 -83
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +0 -126
- package/agent-pane/frontend/src/constants/models.test.ts +0 -97
- package/agent-pane/frontend/src/constants/models.ts +0 -166
- package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +0 -42
- package/agent-pane/frontend/src/hooks/useEscapeKey.ts +0 -13
- package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +0 -92
- package/agent-pane/frontend/src/hooks/useOutsideClick.ts +0 -19
- package/agent-pane/frontend/src/hooks/useProvider.ts +0 -44
- package/agent-pane/frontend/src/hooks/useResizable.test.ts +0 -97
- package/agent-pane/frontend/src/hooks/useResizable.ts +0 -75
- package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +0 -116
- package/agent-pane/frontend/src/hooks/useSessionStatus.ts +0 -34
- package/agent-pane/frontend/src/main.test.tsx +0 -37
- package/agent-pane/frontend/src/main.tsx +0 -10
- package/agent-pane/frontend/src/store/sessionSlice.ts +0 -440
- package/agent-pane/frontend/src/store/store.test.ts +0 -1319
- package/agent-pane/frontend/src/store/store.ts +0 -37
- package/agent-pane/frontend/src/store/threadSlice.ts +0 -136
- package/agent-pane/frontend/src/store/uiSlice.ts +0 -133
- package/agent-pane/frontend/src/store/workspaceSlice.ts +0 -77
- package/agent-pane/frontend/src/store/wsSlice.ts +0 -361
- package/agent-pane/frontend/src/styles/app.css +0 -611
- package/agent-pane/frontend/src/styles/tokens.css +0 -62
- package/agent-pane/frontend/src/test/component-helpers.ts +0 -38
- package/agent-pane/frontend/src/test/fixtures.ts +0 -100
- package/agent-pane/frontend/src/test-setup.ts +0 -5
- package/agent-pane/frontend/src/types/index.test.ts +0 -128
- package/agent-pane/frontend/src/types/index.ts +0 -132
- package/agent-pane/frontend/src/utils/changes.test.ts +0 -81
- package/agent-pane/frontend/src/utils/changes.ts +0 -39
- package/agent-pane/frontend/src/utils/duration.test.ts +0 -75
- package/agent-pane/frontend/src/utils/duration.ts +0 -14
- package/agent-pane/frontend/tsconfig.json +0 -25
- package/agent-pane/frontend/vite.config.ts +0 -22
- package/agent-pane/frontend/vitest.config.ts +0 -29
- package/agent-pane/package-lock.json +0 -1527
- package/agent-pane/package.json +0 -19
- package/agent-pane/shared/provider-types.ts +0 -67
- package/agent-pane/shared/types.ts +0 -167
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: missing item.started auto-insert fallback.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that when item.updated or item.completed arrives without
|
|
5
|
-
* a prior item.started, the handleEvent auto-inserts the item into DB.
|
|
6
|
-
*
|
|
7
|
-
* Uses HTTP POST to trigger the turn (fire-and-forget startTurn).
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
11
|
-
import { readFileSync } from 'node:fs';
|
|
12
|
-
import { resolve } from 'node:path';
|
|
13
|
-
import type Database from 'better-sqlite3';
|
|
14
|
-
import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
|
|
15
|
-
import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
16
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
17
|
-
|
|
18
|
-
const fixture = JSON.parse(
|
|
19
|
-
readFileSync(resolve(__dirname, '__fixtures__/missing-item-started.json'), 'utf-8'),
|
|
20
|
-
) as Fixture;
|
|
21
|
-
|
|
22
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
23
|
-
AppServerClient: createAppServerMock(fixture),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
27
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
28
|
-
return {
|
|
29
|
-
...actual,
|
|
30
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
31
|
-
capturedBroadcasts.push({ event, data });
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const { getDb } = await import('../db/index.ts');
|
|
37
|
-
const { createTestApp, waitForTurn } = await import('./helpers/test-app.ts');
|
|
38
|
-
|
|
39
|
-
describe('Integration: missing item.started auto-insert', () => {
|
|
40
|
-
let testApp: TestApp;
|
|
41
|
-
|
|
42
|
-
beforeEach(async () => {
|
|
43
|
-
vi.clearAllMocks();
|
|
44
|
-
clearBroadcasts();
|
|
45
|
-
testApp = await createTestApp();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
afterEach(async () => {
|
|
49
|
-
await testApp.cleanup();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('auto-inserts item when item.updated arrives without item.started', async () => {
|
|
53
|
-
const db: Database.Database = getDb();
|
|
54
|
-
|
|
55
|
-
// Create session
|
|
56
|
-
const createRes = await testApp.app.inject({
|
|
57
|
-
method: 'POST',
|
|
58
|
-
url: '/api/sessions',
|
|
59
|
-
payload: {},
|
|
60
|
-
});
|
|
61
|
-
const session = createRes.json();
|
|
62
|
-
|
|
63
|
-
// Submit turn via HTTP
|
|
64
|
-
const turnRes = await testApp.app.inject({
|
|
65
|
-
method: 'POST',
|
|
66
|
-
url: `/api/sessions/${session.id}/turns`,
|
|
67
|
-
payload: { user_prompt: 'Hello' },
|
|
68
|
-
});
|
|
69
|
-
const turn = turnRes.json();
|
|
70
|
-
|
|
71
|
-
await waitForTurn(db, turn.id);
|
|
72
|
-
|
|
73
|
-
// Only 1 item in DB (no duplicate from missing item.started)
|
|
74
|
-
const items = db.prepare('SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC').all(turn.id) as {
|
|
75
|
-
type: string;
|
|
76
|
-
data: string;
|
|
77
|
-
status: string;
|
|
78
|
-
}[];
|
|
79
|
-
expect(items).toHaveLength(1);
|
|
80
|
-
expect(items[0].type).toBe('agent_message');
|
|
81
|
-
expect(items[0].status).toBe('completed');
|
|
82
|
-
expect(JSON.parse(items[0].data)).toEqual({ text: 'Hello! How can I help?' });
|
|
83
|
-
|
|
84
|
-
// Verify WS: item:updated broadcast fired (auto-insert path)
|
|
85
|
-
const updatedBroadcasts = capturedBroadcasts.filter((b) => b.event === 'item:updated');
|
|
86
|
-
expect(updatedBroadcasts).toHaveLength(1);
|
|
87
|
-
|
|
88
|
-
const completedBroadcasts = capturedBroadcasts.filter((b) => b.event === 'item:completed');
|
|
89
|
-
expect(completedBroadcasts).toHaveLength(1);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: multi-turn session — thread reuse and title only once.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that a second turn in the same session reuses the existing
|
|
5
|
-
* thread (external_thread_id set after first turn) and that the title
|
|
6
|
-
* is only generated once (for the first turn).
|
|
7
|
-
*
|
|
8
|
-
* Uses HTTP POST to trigger each turn (fire-and-forget startTurn).
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
12
|
-
import { readFileSync } from 'node:fs';
|
|
13
|
-
import { resolve } from 'node:path';
|
|
14
|
-
import type Database from 'better-sqlite3';
|
|
15
|
-
import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
|
|
16
|
-
import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
17
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
18
|
-
|
|
19
|
-
const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/multi-turn.json'), 'utf-8')) as Fixture;
|
|
20
|
-
|
|
21
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
22
|
-
AppServerClient: createAppServerMock(fixture),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
26
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
27
|
-
return {
|
|
28
|
-
...actual,
|
|
29
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
30
|
-
capturedBroadcasts.push({ event, data });
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const { getDb } = await import('../db/index.ts');
|
|
36
|
-
const { createTestApp, waitForTurn } = await import('./helpers/test-app.ts');
|
|
37
|
-
|
|
38
|
-
describe('Integration: multi-turn', () => {
|
|
39
|
-
let testApp: TestApp;
|
|
40
|
-
|
|
41
|
-
beforeEach(async () => {
|
|
42
|
-
vi.clearAllMocks();
|
|
43
|
-
clearBroadcasts();
|
|
44
|
-
testApp = await createTestApp();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(async () => {
|
|
48
|
-
await testApp.cleanup();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('handles two turns with thread reuse and title only once', async () => {
|
|
52
|
-
const db: Database.Database = getDb();
|
|
53
|
-
|
|
54
|
-
// Create session
|
|
55
|
-
const createRes = await testApp.app.inject({
|
|
56
|
-
method: 'POST',
|
|
57
|
-
url: '/api/sessions',
|
|
58
|
-
payload: {},
|
|
59
|
-
});
|
|
60
|
-
const session = createRes.json();
|
|
61
|
-
|
|
62
|
-
// Turn 1 via HTTP
|
|
63
|
-
const turn1Res = await testApp.app.inject({
|
|
64
|
-
method: 'POST',
|
|
65
|
-
url: `/api/sessions/${session.id}/turns`,
|
|
66
|
-
payload: { user_prompt: 'What is 2+2?' },
|
|
67
|
-
});
|
|
68
|
-
const turn1 = turn1Res.json();
|
|
69
|
-
await waitForTurn(db, turn1.id);
|
|
70
|
-
|
|
71
|
-
// After turn 1: external_thread_id should be set
|
|
72
|
-
const sessionAfterT1 = db
|
|
73
|
-
.prepare('SELECT external_thread_id, title FROM sessions WHERE id = ?')
|
|
74
|
-
.get(session.id) as { external_thread_id: string | null; title: string | null };
|
|
75
|
-
expect(sessionAfterT1.external_thread_id).toBe('thread_fix_005');
|
|
76
|
-
|
|
77
|
-
// Wait for title generation (fire-and-forget)
|
|
78
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
79
|
-
const sessionTitled = db.prepare('SELECT title FROM sessions WHERE id = ?').get(session.id) as {
|
|
80
|
-
title: string | null;
|
|
81
|
-
};
|
|
82
|
-
expect(sessionTitled.title).toBe('Simple Math Questions');
|
|
83
|
-
|
|
84
|
-
// Turn 2 via HTTP
|
|
85
|
-
const turn2Res = await testApp.app.inject({
|
|
86
|
-
method: 'POST',
|
|
87
|
-
url: `/api/sessions/${session.id}/turns`,
|
|
88
|
-
payload: { user_prompt: 'What about 3+3?' },
|
|
89
|
-
});
|
|
90
|
-
const turn2 = turn2Res.json();
|
|
91
|
-
await waitForTurn(db, turn2.id);
|
|
92
|
-
|
|
93
|
-
// Both turns in DB
|
|
94
|
-
const turns = db.prepare('SELECT * FROM turns WHERE session_id = ? ORDER BY created_at ASC').all(session.id) as {
|
|
95
|
-
user_prompt: string;
|
|
96
|
-
agent_response: string | null;
|
|
97
|
-
status: string;
|
|
98
|
-
}[];
|
|
99
|
-
expect(turns).toHaveLength(2);
|
|
100
|
-
expect(turns[0].user_prompt).toBe('What is 2+2?');
|
|
101
|
-
expect(turns[0].agent_response).toBe('2+2 equals 4.');
|
|
102
|
-
expect(turns[0].status).toBe('completed');
|
|
103
|
-
expect(turns[1].user_prompt).toBe('What about 3+3?');
|
|
104
|
-
expect(turns[1].agent_response).toBe('3+3 equals 6.');
|
|
105
|
-
expect(turns[1].status).toBe('completed');
|
|
106
|
-
|
|
107
|
-
// Title should still be from first turn (not regenerated)
|
|
108
|
-
const finalTitle = db.prepare('SELECT title FROM sessions WHERE id = ?').get(session.id) as {
|
|
109
|
-
title: string | null;
|
|
110
|
-
};
|
|
111
|
-
expect(finalTitle.title).toBe('Simple Math Questions');
|
|
112
|
-
|
|
113
|
-
// Only one session:title broadcast (from first turn's title generation)
|
|
114
|
-
const titleBroadcasts = capturedBroadcasts.filter((b) => b.event === 'session:title');
|
|
115
|
-
expect(titleBroadcasts).toHaveLength(1);
|
|
116
|
-
|
|
117
|
-
// Two turn:completed broadcasts
|
|
118
|
-
const completedBroadcasts = capturedBroadcasts.filter((b) => b.event === 'turn:completed');
|
|
119
|
-
expect(completedBroadcasts).toHaveLength(2);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: session operations — rewind, branch, model change.
|
|
3
|
-
*
|
|
4
|
-
* These operations interact with codex-provider's clearThread() function.
|
|
5
|
-
* Uses the real codex-provider.ts (not mocked) with a simple-turn fixture
|
|
6
|
-
* to populate DB state, then tests the operations via HTTP.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
10
|
-
import { readFileSync } from 'node:fs';
|
|
11
|
-
import { resolve } from 'node:path';
|
|
12
|
-
import type Database from 'better-sqlite3';
|
|
13
|
-
import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
|
|
14
|
-
import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
15
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
16
|
-
|
|
17
|
-
const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/simple-turn.json'), 'utf-8')) as Fixture;
|
|
18
|
-
|
|
19
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
20
|
-
AppServerClient: createAppServerMock(fixture),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
24
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
25
|
-
return {
|
|
26
|
-
...actual,
|
|
27
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
28
|
-
capturedBroadcasts.push({ event, data });
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const { getDb } = await import('../db/index.ts');
|
|
34
|
-
const { createTestApp, insertTestSession } = await import('./helpers/test-app.ts');
|
|
35
|
-
|
|
36
|
-
describe('Integration: session operations', () => {
|
|
37
|
-
let testApp: TestApp;
|
|
38
|
-
|
|
39
|
-
beforeEach(async () => {
|
|
40
|
-
vi.clearAllMocks();
|
|
41
|
-
clearBroadcasts();
|
|
42
|
-
testApp = await createTestApp();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
afterEach(async () => {
|
|
46
|
-
await testApp.cleanup();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('rewind marks session as rewound (non-destructive) and saves pre_rewind_thread_id', async () => {
|
|
50
|
-
const db: Database.Database = getDb();
|
|
51
|
-
|
|
52
|
-
insertTestSession(db, 's1', { external_thread_id: 'thread_old' });
|
|
53
|
-
|
|
54
|
-
// Insert two turns manually
|
|
55
|
-
const now1 = '2025-01-01T00:00:00Z';
|
|
56
|
-
const now2 = '2025-01-01T01:00:00Z';
|
|
57
|
-
db.prepare(
|
|
58
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
59
|
-
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
60
|
-
).run('t1', 's1', 'first', now1, now1);
|
|
61
|
-
db.prepare(
|
|
62
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
63
|
-
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
64
|
-
).run('t2', 's1', 'second', now2, now2);
|
|
65
|
-
|
|
66
|
-
// Rewind to t1 — non-destructive: turns are NOT deleted
|
|
67
|
-
const res = await testApp.app.inject({
|
|
68
|
-
method: 'POST',
|
|
69
|
-
url: '/api/sessions/s1/rewind',
|
|
70
|
-
payload: { turn_id: 't1' },
|
|
71
|
-
});
|
|
72
|
-
expect(res.statusCode).toBe(200);
|
|
73
|
-
|
|
74
|
-
// Both turns still exist (not deleted)
|
|
75
|
-
const turns = db.prepare('SELECT id FROM turns WHERE session_id = ?').all('s1') as {
|
|
76
|
-
id: string;
|
|
77
|
-
}[];
|
|
78
|
-
expect(turns).toHaveLength(2);
|
|
79
|
-
|
|
80
|
-
// Session marked as rewound, pre_rewind_thread_id saved
|
|
81
|
-
const session = db.prepare('SELECT rewound_at_turn_id, pre_rewind_thread_id FROM sessions WHERE id = ?').get('s1') as {
|
|
82
|
-
rewound_at_turn_id: string | null;
|
|
83
|
-
pre_rewind_thread_id: string | null;
|
|
84
|
-
};
|
|
85
|
-
expect(session.rewound_at_turn_id).toBe('t1');
|
|
86
|
-
expect(session.pre_rewind_thread_id).toBe('thread_old');
|
|
87
|
-
|
|
88
|
-
// GET session filters turns (only t1 visible)
|
|
89
|
-
const getRes = await testApp.app.inject({ method: 'GET', url: '/api/sessions/s1' });
|
|
90
|
-
expect(getRes.json().turns).toHaveLength(1);
|
|
91
|
-
expect(getRes.json().turns[0].id).toBe('t1');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('branch creates new session with copied turns and items', async () => {
|
|
95
|
-
const db: Database.Database = getDb();
|
|
96
|
-
|
|
97
|
-
insertTestSession(db, 's1', { title: 'Original', model: 'gpt-4' });
|
|
98
|
-
|
|
99
|
-
const now = '2025-01-01T00:00:00Z';
|
|
100
|
-
db.prepare(
|
|
101
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
102
|
-
VALUES (?, ?, ?, 'answer', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
103
|
-
).run('t1', 's1', 'hello', now, now);
|
|
104
|
-
db.prepare(
|
|
105
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
106
|
-
VALUES (?, ?, ?, 'agent_message', ?, 'completed', ?, ?)`,
|
|
107
|
-
).run('i1', 't1', 'ext1', JSON.stringify({ text: 'answer' }), now, now);
|
|
108
|
-
|
|
109
|
-
const res = await testApp.app.inject({
|
|
110
|
-
method: 'POST',
|
|
111
|
-
url: '/api/sessions/s1/branch',
|
|
112
|
-
payload: { turn_id: 't1' },
|
|
113
|
-
});
|
|
114
|
-
expect(res.statusCode).toBe(200);
|
|
115
|
-
const newSession = res.json();
|
|
116
|
-
expect(newSession.id).not.toBe('s1');
|
|
117
|
-
expect(newSession.title).toBe('Branch of Original');
|
|
118
|
-
expect(newSession.model).toBe('gpt-4');
|
|
119
|
-
expect(newSession.external_thread_id).toBeNull();
|
|
120
|
-
|
|
121
|
-
// New session has copied turn + item
|
|
122
|
-
const newTurns = db.prepare('SELECT * FROM turns WHERE session_id = ?').all(newSession.id) as {
|
|
123
|
-
user_prompt: string;
|
|
124
|
-
agent_response: string;
|
|
125
|
-
}[];
|
|
126
|
-
expect(newTurns).toHaveLength(1);
|
|
127
|
-
expect(newTurns[0].user_prompt).toBe('hello');
|
|
128
|
-
expect(newTurns[0].agent_response).toBe('answer');
|
|
129
|
-
|
|
130
|
-
const newItems = db
|
|
131
|
-
.prepare('SELECT * FROM items WHERE turn_id IN (SELECT id FROM turns WHERE session_id = ?)')
|
|
132
|
-
.all(newSession.id) as { type: string }[];
|
|
133
|
-
expect(newItems).toHaveLength(1);
|
|
134
|
-
expect(newItems[0].type).toBe('agent_message');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('model change preserves thread when external_thread_id exists (same provider)', async () => {
|
|
138
|
-
const db: Database.Database = getDb();
|
|
139
|
-
|
|
140
|
-
insertTestSession(db, 's1', { model: 'gpt-4', external_thread_id: 'thread_123' });
|
|
141
|
-
|
|
142
|
-
const res = await testApp.app.inject({
|
|
143
|
-
method: 'PATCH',
|
|
144
|
-
url: '/api/sessions/s1',
|
|
145
|
-
payload: { model: 'o3' },
|
|
146
|
-
});
|
|
147
|
-
expect(res.statusCode).toBe(200);
|
|
148
|
-
|
|
149
|
-
const session = db.prepare('SELECT external_thread_id, model FROM sessions WHERE id = ?').get('s1') as {
|
|
150
|
-
external_thread_id: string | null;
|
|
151
|
-
model: string | null;
|
|
152
|
-
};
|
|
153
|
-
// Thread must survive model change within the same provider
|
|
154
|
-
expect(session.external_thread_id).toBe('thread_123');
|
|
155
|
-
expect(session.model).toBe('o3');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('model change does NOT clear thread when external_thread_id is null', async () => {
|
|
159
|
-
const db: Database.Database = getDb();
|
|
160
|
-
|
|
161
|
-
insertTestSession(db, 's1', { model: 'gpt-4' });
|
|
162
|
-
|
|
163
|
-
const res = await testApp.app.inject({
|
|
164
|
-
method: 'PATCH',
|
|
165
|
-
url: '/api/sessions/s1',
|
|
166
|
-
payload: { model: 'o3' },
|
|
167
|
-
});
|
|
168
|
-
expect(res.statusCode).toBe(200);
|
|
169
|
-
|
|
170
|
-
const session = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as {
|
|
171
|
-
external_thread_id: string | null;
|
|
172
|
-
};
|
|
173
|
-
expect(session.external_thread_id).toBeNull();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: discussion threads — Claude fork isolation (BUG 1 + BUG 2).
|
|
3
|
-
*
|
|
4
|
-
* Exercises the REAL claudeProvider + REAL thread routes with a mocked Claude
|
|
5
|
-
* SDK (`query` + `forkSession`). Verifies that creating a Discuss thread forks
|
|
6
|
-
* the main session, stores the fork id on the thread row, and never corrupts
|
|
7
|
-
* the main session's `external_thread_id`; and that a failed fork starts a
|
|
8
|
-
* fresh isolated session instead of resuming (and contaminating) the main
|
|
9
|
-
* session.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
13
|
-
import type Database from 'better-sqlite3';
|
|
14
|
-
import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
15
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
16
|
-
|
|
17
|
-
// Mock the Claude SDK — both the query factory and forkSession.
|
|
18
|
-
vi.mock('@anthropic-ai/claude-agent-sdk', () => ({
|
|
19
|
-
query: vi.fn(),
|
|
20
|
-
forkSession: vi.fn(),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
24
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
25
|
-
return {
|
|
26
|
-
...actual,
|
|
27
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
28
|
-
capturedBroadcasts.push({ event, data });
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Import after mocks are set up.
|
|
34
|
-
import { query, forkSession } from '@anthropic-ai/claude-agent-sdk';
|
|
35
|
-
import { clearAllThreads } from '../claude/claude-provider.ts';
|
|
36
|
-
const { getDb } = await import('../db/index.ts');
|
|
37
|
-
const { createTestApp, insertTestSession, waitForTurn } = await import('./helpers/test-app.ts');
|
|
38
|
-
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
// Mock helpers
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
|
|
43
|
-
/** Build a mock `Query` whose async iterator yields the given SDK messages in
|
|
44
|
-
* order, then ends. getContextUsage resolves an empty snapshot (0/0) so the
|
|
45
|
-
* result/success handler completes the turn without emitting contextUsage. */
|
|
46
|
-
function createClaudeQueryMock(messages: unknown[]): unknown {
|
|
47
|
-
return {
|
|
48
|
-
getContextUsage: vi.fn().mockResolvedValue({
|
|
49
|
-
totalTokens: 0, maxTokens: 0, rawMaxTokens: 0, percentage: 0,
|
|
50
|
-
categories: [], gridRows: [], model: '', memoryFiles: [], mcpTools: [],
|
|
51
|
-
}),
|
|
52
|
-
interrupt: vi.fn(),
|
|
53
|
-
setModel: vi.fn(),
|
|
54
|
-
close: vi.fn(),
|
|
55
|
-
stopTask: vi.fn(),
|
|
56
|
-
initializationResult: vi.fn(),
|
|
57
|
-
[Symbol.asyncIterator]: async function* () {
|
|
58
|
-
for (const m of messages) yield m;
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** A `system/init` SDK message carrying the given Claude session id. */
|
|
64
|
-
function initMsg(claudeSessionId: string): unknown {
|
|
65
|
-
return { type: 'system', subtype: 'init', session_id: claudeSessionId };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** A `result/success` SDK message that completes a turn. */
|
|
69
|
-
function resultSuccessMsg(claudeSessionId: string): unknown {
|
|
70
|
-
return {
|
|
71
|
-
type: 'result', subtype: 'success',
|
|
72
|
-
usage: { input_tokens: 10, cache_read_input_tokens: 0, cache_creation_input_tokens: 0, output_tokens: 5 },
|
|
73
|
-
modelUsage: {}, result: 'done', is_error: false, num_turns: 1,
|
|
74
|
-
stop_reason: 'end_turn', duration_ms: 1, duration_api_ms: 1, total_cost_usd: 0,
|
|
75
|
-
permission_denials: [], uuid: 'u1', session_id: claudeSessionId,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
describe('Integration: discussion threads — Claude fork isolation', () => {
|
|
80
|
-
let testApp: TestApp;
|
|
81
|
-
|
|
82
|
-
beforeEach(async () => {
|
|
83
|
-
vi.clearAllMocks();
|
|
84
|
-
clearAllThreads();
|
|
85
|
-
clearBroadcasts();
|
|
86
|
-
testApp = await createTestApp();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
afterEach(async () => {
|
|
90
|
-
clearAllThreads();
|
|
91
|
-
await testApp.cleanup();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
/** Seed a Claude session + anchor turn/item, ready for a thread creation. */
|
|
95
|
-
function seedSession(db: Database.Database): void {
|
|
96
|
-
insertTestSession(db, 's1', { runtime_type: 'claude', external_thread_id: 'main-1', title: 'Test' });
|
|
97
|
-
const now = '2025-01-01T00:00:00Z';
|
|
98
|
-
db.prepare(
|
|
99
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, status, external_turn_id, created_at, updated_at)
|
|
100
|
-
VALUES ('t1', 's1', 'prompt', 'response', 'completed', 'msg-uuid-1', ?, ?)`,
|
|
101
|
-
).run(now, now);
|
|
102
|
-
db.prepare(
|
|
103
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
104
|
-
VALUES ('i1', 't1', 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
105
|
-
).run(JSON.stringify({ text: 'Some text to discuss' }), now, now);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** The shared thread-creation POST payload. */
|
|
109
|
-
const threadPayload = {
|
|
110
|
-
itemId: 'i1',
|
|
111
|
-
turnId: 't1',
|
|
112
|
-
startOffset: 0,
|
|
113
|
-
endOffset: 10,
|
|
114
|
-
selectedText: 'Some text ',
|
|
115
|
-
message: 'What does this mean?',
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
it('successful fork: stores fork id, resumes the fork, does NOT corrupt the main session (BUG 1 + BUG 2)', async () => {
|
|
119
|
-
const db: Database.Database = getDb();
|
|
120
|
-
seedSession(db);
|
|
121
|
-
|
|
122
|
-
// forkSession returns a new forked session id.
|
|
123
|
-
vi.mocked(forkSession).mockResolvedValue({ sessionId: 'fork-9' } as never);
|
|
124
|
-
// The forked query emits init with the FORK's id, then completes the turn.
|
|
125
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('fork-9'), resultSuccessMsg('fork-9')]) as never);
|
|
126
|
-
|
|
127
|
-
const res = await testApp.app.inject({
|
|
128
|
-
method: 'POST',
|
|
129
|
-
url: '/api/sessions/s1/threads',
|
|
130
|
-
payload: threadPayload,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(res.statusCode).toBe(200);
|
|
134
|
-
const body = res.json();
|
|
135
|
-
const threadId = body.thread.id as string;
|
|
136
|
-
const turnId = body.turn.id as string;
|
|
137
|
-
|
|
138
|
-
// forkSession was called with the MAIN session id + the anchor turn's message UUID.
|
|
139
|
-
expect(vi.mocked(forkSession).mock.calls[0][0]).toBe('main-1');
|
|
140
|
-
expect((vi.mocked(forkSession).mock.calls[0][1] as { upToMessageId?: string }).upToMessageId).toBe('msg-uuid-1');
|
|
141
|
-
|
|
142
|
-
// The fork id is stored on the THREAD row, not the main session.
|
|
143
|
-
const threadRow = db.prepare('SELECT external_thread_id FROM discussion_threads WHERE id = ?').get(threadId) as
|
|
144
|
-
| { external_thread_id: string | null }
|
|
145
|
-
| undefined;
|
|
146
|
-
expect(threadRow?.external_thread_id).toBe('fork-9');
|
|
147
|
-
|
|
148
|
-
// Wait for the thread turn to complete, then assert the main session is intact.
|
|
149
|
-
await waitForTurn(db, turnId);
|
|
150
|
-
|
|
151
|
-
// BUG 2: the thread turn resumed its OWN fork ('fork-9'), not the main session.
|
|
152
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
153
|
-
expect(opts.resume).toBe('fork-9');
|
|
154
|
-
|
|
155
|
-
// BUG 1: the main session's external_thread_id was NOT overwritten with the fork's id.
|
|
156
|
-
const sessionRow = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
157
|
-
| { external_thread_id: string | null }
|
|
158
|
-
| undefined;
|
|
159
|
-
expect(sessionRow?.external_thread_id).toBe('main-1');
|
|
160
|
-
|
|
161
|
-
// thread:created was broadcast.
|
|
162
|
-
expect(capturedBroadcasts.find((b) => b.event === 'thread:created')).toBeDefined();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('failed fork (null): thread still created, starts a FRESH session (resume undefined), main session untouched (BUG 2)', async () => {
|
|
166
|
-
const db: Database.Database = getDb();
|
|
167
|
-
seedSession(db);
|
|
168
|
-
|
|
169
|
-
// forkSession returns null (e.g. no main session to fork from, or SDK refused).
|
|
170
|
-
vi.mocked(forkSession).mockResolvedValue(null as never);
|
|
171
|
-
// The fresh isolated session emits its own init id, then completes.
|
|
172
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('fresh-1'), resultSuccessMsg('fresh-1')]) as never);
|
|
173
|
-
|
|
174
|
-
const res = await testApp.app.inject({
|
|
175
|
-
method: 'POST',
|
|
176
|
-
url: '/api/sessions/s1/threads',
|
|
177
|
-
payload: threadPayload,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
expect(res.statusCode).toBe(200);
|
|
181
|
-
const body = res.json();
|
|
182
|
-
const threadId = body.thread.id as string;
|
|
183
|
-
const turnId = body.turn.id as string;
|
|
184
|
-
|
|
185
|
-
// The thread row has NO fork id.
|
|
186
|
-
const threadRow = db.prepare('SELECT external_thread_id FROM discussion_threads WHERE id = ?').get(threadId) as
|
|
187
|
-
| { external_thread_id: string | null }
|
|
188
|
-
| undefined;
|
|
189
|
-
expect(threadRow?.external_thread_id).toBeNull();
|
|
190
|
-
|
|
191
|
-
await waitForTurn(db, turnId);
|
|
192
|
-
|
|
193
|
-
// BUG 2: the thread started a FRESH session — no `resume` option — and did
|
|
194
|
-
// NOT fall back to the main session's 'main-1'.
|
|
195
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
196
|
-
expect(opts.resume).toBeUndefined();
|
|
197
|
-
|
|
198
|
-
// The main session is untouched.
|
|
199
|
-
const sessionRow = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
200
|
-
| { external_thread_id: string | null }
|
|
201
|
-
| undefined;
|
|
202
|
-
expect(sessionRow?.external_thread_id).toBe('main-1');
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('failed fork (throws): caught, thread still created, main session untouched (BUG 2)', async () => {
|
|
206
|
-
const db: Database.Database = getDb();
|
|
207
|
-
seedSession(db);
|
|
208
|
-
|
|
209
|
-
// forkSession throws — the route must catch it and still create the thread.
|
|
210
|
-
vi.mocked(forkSession).mockRejectedValue(new Error('boom') as never);
|
|
211
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('fresh-2'), resultSuccessMsg('fresh-2')]) as never);
|
|
212
|
-
|
|
213
|
-
const res = await testApp.app.inject({
|
|
214
|
-
method: 'POST',
|
|
215
|
-
url: '/api/sessions/s1/threads',
|
|
216
|
-
payload: threadPayload,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(res.statusCode).toBe(200);
|
|
220
|
-
const body = res.json();
|
|
221
|
-
const threadId = body.thread.id as string;
|
|
222
|
-
const turnId = body.turn.id as string;
|
|
223
|
-
|
|
224
|
-
// The thread row has NO fork id (fork threw before storing anything).
|
|
225
|
-
const threadRow = db.prepare('SELECT external_thread_id FROM discussion_threads WHERE id = ?').get(threadId) as
|
|
226
|
-
| { external_thread_id: string | null }
|
|
227
|
-
| undefined;
|
|
228
|
-
expect(threadRow?.external_thread_id).toBeNull();
|
|
229
|
-
|
|
230
|
-
await waitForTurn(db, turnId);
|
|
231
|
-
|
|
232
|
-
// The thread started a fresh isolated session (no resume), not the main session.
|
|
233
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
234
|
-
expect(opts.resume).toBeUndefined();
|
|
235
|
-
|
|
236
|
-
const sessionRow = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
237
|
-
| { external_thread_id: string | null }
|
|
238
|
-
| undefined;
|
|
239
|
-
expect(sessionRow?.external_thread_id).toBe('main-1');
|
|
240
|
-
});
|
|
241
|
-
});
|