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,309 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: discussion threads — create, followup, resolve, delete, list.
|
|
3
|
-
*
|
|
4
|
-
* Tests the REST CRUD endpoints and verifies DB state + WS broadcasts.
|
|
5
|
-
* Uses the real codex-provider (mocked AppServerClient) for startTurn calls.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
-
import { resolve } from 'node:path';
|
|
11
|
-
import type Database from 'better-sqlite3';
|
|
12
|
-
import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
|
|
13
|
-
import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
14
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
15
|
-
|
|
16
|
-
const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/simple-turn.json'), 'utf-8')) as Fixture;
|
|
17
|
-
|
|
18
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
19
|
-
AppServerClient: createAppServerMock(fixture),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
23
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
24
|
-
return {
|
|
25
|
-
...actual,
|
|
26
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
27
|
-
capturedBroadcasts.push({ event, data });
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const { getDb } = await import('../db/index.ts');
|
|
33
|
-
const { createTestApp, insertTestSession } = await import('./helpers/test-app.ts');
|
|
34
|
-
|
|
35
|
-
describe('Integration: discussion threads', () => {
|
|
36
|
-
let testApp: TestApp;
|
|
37
|
-
|
|
38
|
-
beforeEach(async () => {
|
|
39
|
-
vi.clearAllMocks();
|
|
40
|
-
clearBroadcasts();
|
|
41
|
-
testApp = await createTestApp();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
afterEach(async () => {
|
|
45
|
-
await testApp.cleanup();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('creates a thread + first AI turn', async () => {
|
|
49
|
-
const db: Database.Database = getDb();
|
|
50
|
-
insertTestSession(db, 's1', { runtime_type: 'codex' });
|
|
51
|
-
|
|
52
|
-
// Insert an anchor turn + item (the agent_message being annotated)
|
|
53
|
-
const now = '2025-01-01T00:00:00Z';
|
|
54
|
-
db.prepare(
|
|
55
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
56
|
-
VALUES (?, ?, 'prompt', 'response', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
57
|
-
).run('t1', 's1', now, now);
|
|
58
|
-
db.prepare(
|
|
59
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
60
|
-
VALUES (?, ?, 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
61
|
-
).run('i1', 't1', JSON.stringify({ text: 'Some text to discuss' }), now, now);
|
|
62
|
-
|
|
63
|
-
const res = await testApp.app.inject({
|
|
64
|
-
method: 'POST',
|
|
65
|
-
url: '/api/sessions/s1/threads',
|
|
66
|
-
payload: {
|
|
67
|
-
itemId: 'i1',
|
|
68
|
-
turnId: 't1',
|
|
69
|
-
startOffset: 0,
|
|
70
|
-
endOffset: 10,
|
|
71
|
-
selectedText: 'Some text ',
|
|
72
|
-
message: 'What does this mean?',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(res.statusCode).toBe(200);
|
|
77
|
-
const body = res.json();
|
|
78
|
-
expect(body.thread).toBeDefined();
|
|
79
|
-
expect(body.thread.id).toBeDefined();
|
|
80
|
-
expect(body.thread.status).toBe('open');
|
|
81
|
-
expect(body.thread.selected_text).toBe('Some text ');
|
|
82
|
-
expect(body.turn).toBeDefined();
|
|
83
|
-
expect(body.turn.thread_id).toBe(body.thread.id);
|
|
84
|
-
|
|
85
|
-
// Verify DB state
|
|
86
|
-
const threadRow = db.prepare('SELECT * FROM discussion_threads WHERE id = ?').get(body.thread.id);
|
|
87
|
-
expect(threadRow).toBeDefined();
|
|
88
|
-
expect((threadRow as { status: string }).status).toBe('open');
|
|
89
|
-
|
|
90
|
-
const turnRow = db.prepare('SELECT * FROM turns WHERE id = ?').get(body.turn.id) as { thread_id: string | null; user_prompt: string };
|
|
91
|
-
expect(turnRow.thread_id).toBe(body.thread.id);
|
|
92
|
-
expect(turnRow.user_prompt).toContain('[Quoting from your previous response]');
|
|
93
|
-
expect(turnRow.user_prompt).toContain('Some text ');
|
|
94
|
-
expect(turnRow.user_prompt).toContain('What does this mean?');
|
|
95
|
-
|
|
96
|
-
// Verify broadcast
|
|
97
|
-
const createdEvent = capturedBroadcasts.find((b) => b.event === 'thread:created');
|
|
98
|
-
expect(createdEvent).toBeDefined();
|
|
99
|
-
expect((createdEvent!.data as { sessionId: string }).sessionId).toBe('s1');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('returns 409 when a turn is already running', async () => {
|
|
103
|
-
const db: Database.Database = getDb();
|
|
104
|
-
insertTestSession(db, 's1', { is_running: 1 });
|
|
105
|
-
|
|
106
|
-
const res = await testApp.app.inject({
|
|
107
|
-
method: 'POST',
|
|
108
|
-
url: '/api/sessions/s1/threads',
|
|
109
|
-
payload: {
|
|
110
|
-
itemId: 'i1',
|
|
111
|
-
turnId: 't1',
|
|
112
|
-
startOffset: 0,
|
|
113
|
-
endOffset: 5,
|
|
114
|
-
selectedText: 'text',
|
|
115
|
-
message: 'test',
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
expect(res.statusCode).toBe(409);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('resolves and reopens a thread', async () => {
|
|
123
|
-
const db: Database.Database = getDb();
|
|
124
|
-
insertTestSession(db, 's1', { runtime_type: 'codex' });
|
|
125
|
-
|
|
126
|
-
const now = '2025-01-01T00:00:00Z';
|
|
127
|
-
db.prepare(
|
|
128
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
129
|
-
VALUES (?, ?, 'prompt', 'response', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
130
|
-
).run('t1', 's1', now, now);
|
|
131
|
-
db.prepare(
|
|
132
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
133
|
-
VALUES (?, ?, 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
134
|
-
).run('i1', 't1', JSON.stringify({ text: 'text' }), now, now);
|
|
135
|
-
|
|
136
|
-
// Manually insert a thread
|
|
137
|
-
db.prepare(
|
|
138
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
139
|
-
VALUES (?, ?, ?, ?, 0, 4, 'text', 'open', ?, ?)`,
|
|
140
|
-
).run('th1', 's1', 'i1', 't1', now, now);
|
|
141
|
-
|
|
142
|
-
// Resolve
|
|
143
|
-
const resolveRes = await testApp.app.inject({
|
|
144
|
-
method: 'PATCH',
|
|
145
|
-
url: '/api/sessions/s1/threads/th1',
|
|
146
|
-
payload: { status: 'resolved' },
|
|
147
|
-
});
|
|
148
|
-
expect(resolveRes.statusCode).toBe(200);
|
|
149
|
-
expect(resolveRes.json().status).toBe('resolved');
|
|
150
|
-
|
|
151
|
-
const thread = db.prepare('SELECT status, resolved_at FROM discussion_threads WHERE id = ?').get('th1') as { status: string; resolved_at: string | null };
|
|
152
|
-
expect(thread.status).toBe('resolved');
|
|
153
|
-
expect(thread.resolved_at).not.toBeNull();
|
|
154
|
-
|
|
155
|
-
const resolvedEvent = capturedBroadcasts.find((b) => b.event === 'thread:resolved');
|
|
156
|
-
expect(resolvedEvent).toBeDefined();
|
|
157
|
-
|
|
158
|
-
// Reopen
|
|
159
|
-
clearBroadcasts();
|
|
160
|
-
const reopenRes = await testApp.app.inject({
|
|
161
|
-
method: 'PATCH',
|
|
162
|
-
url: '/api/sessions/s1/threads/th1',
|
|
163
|
-
payload: { status: 'open' },
|
|
164
|
-
});
|
|
165
|
-
expect(reopenRes.statusCode).toBe(200);
|
|
166
|
-
expect(reopenRes.json().status).toBe('open');
|
|
167
|
-
|
|
168
|
-
const reopened = db.prepare('SELECT status FROM discussion_threads WHERE id = ?').get('th1') as { status: string };
|
|
169
|
-
expect(reopened.status).toBe('open');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('deletes a thread and its turns + items', async () => {
|
|
173
|
-
const db: Database.Database = getDb();
|
|
174
|
-
insertTestSession(db, 's1', { runtime_type: 'codex' });
|
|
175
|
-
|
|
176
|
-
const now = '2025-01-01T00:00:00Z';
|
|
177
|
-
// Insert anchor turn + item
|
|
178
|
-
db.prepare(
|
|
179
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
180
|
-
VALUES (?, ?, 'prompt', 'response', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
181
|
-
).run('t1', 's1', now, now);
|
|
182
|
-
db.prepare(
|
|
183
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
184
|
-
VALUES (?, ?, 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
185
|
-
).run('i1', 't1', JSON.stringify({ text: 'text' }), now, now);
|
|
186
|
-
|
|
187
|
-
// Insert thread + thread turn + thread item
|
|
188
|
-
db.prepare(
|
|
189
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
190
|
-
VALUES (?, ?, ?, ?, 0, 4, 'text', 'open', ?, ?)`,
|
|
191
|
-
).run('th1', 's1', 'i1', 't1', now, now);
|
|
192
|
-
db.prepare(
|
|
193
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
|
|
194
|
-
VALUES (?, ?, 'thread msg', 'thread resp', NULL, NULL, NULL, 'completed', NULL, ?, ?, ?)`,
|
|
195
|
-
).run('tt1', 's1', 'th1', now, now);
|
|
196
|
-
db.prepare(
|
|
197
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
198
|
-
VALUES (?, ?, 'ext2', 'agent_message', ?, 'completed', ?, ?)`,
|
|
199
|
-
).run('ti1', 'tt1', JSON.stringify({ text: 'thread response' }), now, now);
|
|
200
|
-
|
|
201
|
-
const res = await testApp.app.inject({
|
|
202
|
-
method: 'DELETE',
|
|
203
|
-
url: '/api/sessions/s1/threads/th1',
|
|
204
|
-
});
|
|
205
|
-
expect(res.statusCode).toBe(200);
|
|
206
|
-
expect(res.json().success).toBe(true);
|
|
207
|
-
|
|
208
|
-
// Thread row deleted
|
|
209
|
-
const thread = db.prepare('SELECT id FROM discussion_threads WHERE id = ?').get('th1');
|
|
210
|
-
expect(thread).toBeUndefined();
|
|
211
|
-
|
|
212
|
-
// Thread turn deleted
|
|
213
|
-
const turn = db.prepare('SELECT id FROM turns WHERE id = ?').get('tt1');
|
|
214
|
-
expect(turn).toBeUndefined();
|
|
215
|
-
|
|
216
|
-
// Thread item deleted
|
|
217
|
-
const item = db.prepare('SELECT id FROM items WHERE id = ?').get('ti1');
|
|
218
|
-
expect(item).toBeUndefined();
|
|
219
|
-
|
|
220
|
-
// Anchor turn + item still exist
|
|
221
|
-
const anchorTurn = db.prepare('SELECT id FROM turns WHERE id = ?').get('t1');
|
|
222
|
-
expect(anchorTurn).toBeDefined();
|
|
223
|
-
const anchorItem = db.prepare('SELECT id FROM items WHERE id = ?').get('i1');
|
|
224
|
-
expect(anchorItem).toBeDefined();
|
|
225
|
-
|
|
226
|
-
const deletedEvent = capturedBroadcasts.find((b) => b.event === 'thread:deleted');
|
|
227
|
-
expect(deletedEvent).toBeDefined();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('lists threads with nested turns', async () => {
|
|
231
|
-
const db: Database.Database = getDb();
|
|
232
|
-
insertTestSession(db, 's1', { runtime_type: 'codex' });
|
|
233
|
-
|
|
234
|
-
const now = '2025-01-01T00:00:00Z';
|
|
235
|
-
// Anchor turn + item
|
|
236
|
-
db.prepare(
|
|
237
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
238
|
-
VALUES (?, ?, 'prompt', 'response', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
239
|
-
).run('t1', 's1', now, now);
|
|
240
|
-
db.prepare(
|
|
241
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
242
|
-
VALUES (?, ?, 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
243
|
-
).run('i1', 't1', JSON.stringify({ text: 'text' }), now, now);
|
|
244
|
-
|
|
245
|
-
// Thread + thread turn + thread item
|
|
246
|
-
db.prepare(
|
|
247
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
248
|
-
VALUES (?, ?, ?, ?, 0, 4, 'text', 'open', ?, ?)`,
|
|
249
|
-
).run('th1', 's1', 'i1', 't1', now, now);
|
|
250
|
-
db.prepare(
|
|
251
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
|
|
252
|
-
VALUES (?, ?, 'msg', 'resp', NULL, NULL, NULL, 'completed', NULL, ?, ?, ?)`,
|
|
253
|
-
).run('tt1', 's1', 'th1', now, now);
|
|
254
|
-
db.prepare(
|
|
255
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
256
|
-
VALUES (?, ?, 'ext2', 'agent_message', ?, 'completed', ?, ?)`,
|
|
257
|
-
).run('ti1', 'tt1', JSON.stringify({ text: 'response' }), now, now);
|
|
258
|
-
|
|
259
|
-
const res = await testApp.app.inject({
|
|
260
|
-
method: 'GET',
|
|
261
|
-
url: '/api/sessions/s1/threads',
|
|
262
|
-
});
|
|
263
|
-
expect(res.statusCode).toBe(200);
|
|
264
|
-
const threads = res.json();
|
|
265
|
-
expect(threads).toHaveLength(1);
|
|
266
|
-
expect(threads[0].id).toBe('th1');
|
|
267
|
-
expect(threads[0].turns).toHaveLength(1);
|
|
268
|
-
expect(threads[0].turns[0].id).toBe('tt1');
|
|
269
|
-
expect(threads[0].turns[0].items).toHaveLength(1);
|
|
270
|
-
expect(threads[0].turns[0].items[0].id).toBe('ti1');
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it('GET /api/sessions/:id includes threads', async () => {
|
|
274
|
-
const db: Database.Database = getDb();
|
|
275
|
-
insertTestSession(db, 's1', { runtime_type: 'codex' });
|
|
276
|
-
|
|
277
|
-
const now = '2025-01-01T00:00:00Z';
|
|
278
|
-
db.prepare(
|
|
279
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
280
|
-
VALUES (?, ?, 'prompt', 'response', NULL, NULL, NULL, 'completed', NULL, ?, ?)`,
|
|
281
|
-
).run('t1', 's1', now, now);
|
|
282
|
-
db.prepare(
|
|
283
|
-
`INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
|
|
284
|
-
VALUES (?, ?, 'ext1', 'agent_message', ?, 'completed', ?, ?)`,
|
|
285
|
-
).run('i1', 't1', JSON.stringify({ text: 'text' }), now, now);
|
|
286
|
-
|
|
287
|
-
db.prepare(
|
|
288
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
289
|
-
VALUES (?, ?, ?, ?, 0, 4, 'text', 'open', ?, ?)`,
|
|
290
|
-
).run('th1', 's1', 'i1', 't1', now, now);
|
|
291
|
-
db.prepare(
|
|
292
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, thread_id, created_at, updated_at)
|
|
293
|
-
VALUES (?, ?, 'msg', 'resp', NULL, NULL, NULL, 'completed', NULL, ?, ?, ?)`,
|
|
294
|
-
).run('tt1', 's1', 'th1', now, now);
|
|
295
|
-
|
|
296
|
-
const res = await testApp.app.inject({ method: 'GET', url: '/api/sessions/s1' });
|
|
297
|
-
expect(res.statusCode).toBe(200);
|
|
298
|
-
const detail = res.json();
|
|
299
|
-
expect(detail.threads).toBeDefined();
|
|
300
|
-
expect(detail.threads).toHaveLength(1);
|
|
301
|
-
expect(detail.threads[0].id).toBe('th1');
|
|
302
|
-
expect(detail.threads[0].turns).toHaveLength(1);
|
|
303
|
-
|
|
304
|
-
// Thread turns should also be in the main turns array
|
|
305
|
-
expect(detail.turns).toHaveLength(2);
|
|
306
|
-
const threadTurn = detail.turns.find((t: { thread_id: string | null }) => t.thread_id === 'th1');
|
|
307
|
-
expect(threadTurn).toBeDefined();
|
|
308
|
-
});
|
|
309
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: title auto-generation.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that after a turn completes, a throwaway Codex thread is
|
|
5
|
-
* used to generate a title, which is saved to the DB and broadcast
|
|
6
|
-
* via session:title.
|
|
7
|
-
*
|
|
8
|
-
* Uses HTTP POST to trigger the 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, findBroadcast, 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__/simple-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, insertTestSession } = await import('./helpers/test-app.ts');
|
|
37
|
-
|
|
38
|
-
describe('Integration: title generation', () => {
|
|
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('generates title after first turn via throwaway thread', async () => {
|
|
52
|
-
const db: Database.Database = getDb();
|
|
53
|
-
|
|
54
|
-
insertTestSession(db, 's1');
|
|
55
|
-
|
|
56
|
-
// Submit turn via HTTP
|
|
57
|
-
const turnRes = await testApp.app.inject({
|
|
58
|
-
method: 'POST',
|
|
59
|
-
url: '/api/sessions/s1/turns',
|
|
60
|
-
payload: { user_prompt: 'Hello, how are you?' },
|
|
61
|
-
});
|
|
62
|
-
const turn = turnRes.json();
|
|
63
|
-
|
|
64
|
-
await waitForTurn(db, turn.id);
|
|
65
|
-
|
|
66
|
-
// Wait for fire-and-forget title generation
|
|
67
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
68
|
-
|
|
69
|
-
// Title in DB
|
|
70
|
-
const dbSession = db.prepare('SELECT title FROM sessions WHERE id = ?').get('s1') as {
|
|
71
|
-
title: string | null;
|
|
72
|
-
};
|
|
73
|
-
expect(dbSession.title).toBe('Simple Hello Chat');
|
|
74
|
-
|
|
75
|
-
// session:title broadcast
|
|
76
|
-
const titleData = findBroadcast('session:title') as { sessionId: string; title: string };
|
|
77
|
-
expect(titleData.sessionId).toBe('s1');
|
|
78
|
-
expect(titleData.title).toBe('Simple Hello Chat');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('does not regenerate title when session already has one', async () => {
|
|
82
|
-
const db: Database.Database = getDb();
|
|
83
|
-
|
|
84
|
-
insertTestSession(db, 's1', { title: 'Existing Title' });
|
|
85
|
-
|
|
86
|
-
// Submit turn via HTTP
|
|
87
|
-
const turnRes = await testApp.app.inject({
|
|
88
|
-
method: 'POST',
|
|
89
|
-
url: '/api/sessions/s1/turns',
|
|
90
|
-
payload: { user_prompt: 'Hello, how are you?' },
|
|
91
|
-
});
|
|
92
|
-
const turn = turnRes.json();
|
|
93
|
-
|
|
94
|
-
await waitForTurn(db, turn.id);
|
|
95
|
-
|
|
96
|
-
// Wait for any potential title generation
|
|
97
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
98
|
-
|
|
99
|
-
// Title should NOT have changed
|
|
100
|
-
const dbSession = db.prepare('SELECT title FROM sessions WHERE id = ?').get('s1') as {
|
|
101
|
-
title: string | null;
|
|
102
|
-
};
|
|
103
|
-
expect(dbSession.title).toBe('Existing Title');
|
|
104
|
-
|
|
105
|
-
// No session:title broadcast
|
|
106
|
-
const titleBroadcasts = capturedBroadcasts.filter((b) => b.event === 'session:title');
|
|
107
|
-
expect(titleBroadcasts).toHaveLength(0);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: turn cancellation.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that aborting a running turn sets the correct DB state
|
|
5
|
-
* and broadcasts turn:cancelled.
|
|
6
|
-
*
|
|
7
|
-
* Uses manual turn insertion + direct startTurn call to control cancel timing.
|
|
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, findBroadcast, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
16
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
17
|
-
|
|
18
|
-
const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/cancel-turn.json'), 'utf-8')) as Fixture;
|
|
19
|
-
|
|
20
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
21
|
-
AppServerClient: createAppServerMock(fixture),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
25
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
26
|
-
return {
|
|
27
|
-
...actual,
|
|
28
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
29
|
-
capturedBroadcasts.push({ event, data });
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const { startTurn, interruptTurn } = await import('../codex/codex-provider.ts');
|
|
35
|
-
const { getDb } = await import('../db/index.ts');
|
|
36
|
-
const { createTestApp, waitForTurn, insertTestSession } = await import('./helpers/test-app.ts');
|
|
37
|
-
|
|
38
|
-
describe('Integration: turn cancellation', () => {
|
|
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('aborts a running turn and sets correct DB + WS state', async () => {
|
|
52
|
-
const db: Database.Database = getDb();
|
|
53
|
-
|
|
54
|
-
// Create session via HTTP
|
|
55
|
-
insertTestSession(db, 's1');
|
|
56
|
-
|
|
57
|
-
// Insert turn manually (not via HTTP — avoids fire-and-forget startTurn)
|
|
58
|
-
const now = new Date().toISOString();
|
|
59
|
-
db.prepare(
|
|
60
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, created_at, updated_at)
|
|
61
|
-
VALUES (?, ?, ?, NULL, NULL, NULL, NULL, 'pending', NULL, ?, ?)`,
|
|
62
|
-
).run('t1', 's1', 'Write a long essay about history', now, now);
|
|
63
|
-
|
|
64
|
-
const session = db.prepare('SELECT * FROM sessions WHERE id = ?').get('s1') as Record<string, unknown>;
|
|
65
|
-
const turn = db.prepare('SELECT * FROM turns WHERE id = ?').get('t1') as Record<string, unknown>;
|
|
66
|
-
|
|
67
|
-
// Start turn directly — do NOT await (need to cancel while running)
|
|
68
|
-
const turnPromise = startTurn(session as never, turn as never);
|
|
69
|
-
|
|
70
|
-
// Give it a moment to start streaming and set up abortController
|
|
71
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
72
|
-
|
|
73
|
-
// Check that abortController is registered
|
|
74
|
-
const isRunning = db.prepare('SELECT is_running FROM sessions WHERE id = ?').get('s1') as { is_running: number };
|
|
75
|
-
expect(isRunning.is_running).toBe(1);
|
|
76
|
-
|
|
77
|
-
// Cancel the turn
|
|
78
|
-
const cancelled = await interruptTurn('s1');
|
|
79
|
-
expect(cancelled).toBe(true);
|
|
80
|
-
|
|
81
|
-
// Wait for the turn promise to resolve
|
|
82
|
-
await turnPromise;
|
|
83
|
-
await waitForTurn(db, 't1');
|
|
84
|
-
|
|
85
|
-
// Assert DB state
|
|
86
|
-
const dbTurn = db.prepare('SELECT status FROM turns WHERE id = ?').get('t1') as {
|
|
87
|
-
status: string;
|
|
88
|
-
};
|
|
89
|
-
expect(dbTurn.status).toBe('aborted');
|
|
90
|
-
|
|
91
|
-
const dbSession = db.prepare('SELECT is_running, status FROM sessions WHERE id = ?').get('s1') as {
|
|
92
|
-
is_running: number;
|
|
93
|
-
status: string;
|
|
94
|
-
};
|
|
95
|
-
expect(dbSession.is_running).toBe(0);
|
|
96
|
-
expect(dbSession.status).toBe('active');
|
|
97
|
-
|
|
98
|
-
// Assert WS broadcast
|
|
99
|
-
const cancelledData = findBroadcast('turn:cancelled') as {
|
|
100
|
-
sessionId: string;
|
|
101
|
-
turnId: string;
|
|
102
|
-
};
|
|
103
|
-
expect(cancelledData.sessionId).toBe('s1');
|
|
104
|
-
expect(cancelledData.turnId).toBe('t1');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('returns false when interrupting a non-running session', async () => {
|
|
108
|
-
const result = await interruptTurn('nonexistent-session');
|
|
109
|
-
expect(result).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integration test: turn failure handling.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that error events from the SDK set the correct DB state
|
|
5
|
-
* (turn=failed, session=failed) and broadcast turn:failed.
|
|
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, findBroadcast, capturedBroadcasts } from './helpers/ws-capture.ts';
|
|
16
|
-
import type { TestApp } from './helpers/test-app.ts';
|
|
17
|
-
|
|
18
|
-
const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/failed-turn.json'), 'utf-8')) as Fixture;
|
|
19
|
-
|
|
20
|
-
vi.mock('../codex/app-server-client.ts', () => ({
|
|
21
|
-
AppServerClient: createAppServerMock(fixture),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
25
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
26
|
-
return {
|
|
27
|
-
...actual,
|
|
28
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
29
|
-
capturedBroadcasts.push({ event, data });
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const { getDb } = await import('../db/index.ts');
|
|
35
|
-
const { createTestApp, waitForTurn } = await import('./helpers/test-app.ts');
|
|
36
|
-
|
|
37
|
-
describe('Integration: turn failure', () => {
|
|
38
|
-
let testApp: TestApp;
|
|
39
|
-
|
|
40
|
-
beforeEach(async () => {
|
|
41
|
-
vi.clearAllMocks();
|
|
42
|
-
clearBroadcasts();
|
|
43
|
-
testApp = await createTestApp();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterEach(async () => {
|
|
47
|
-
await testApp.cleanup();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('handles error event → turn=failed, session=failed, WS turn:failed', async () => {
|
|
51
|
-
const db: Database.Database = getDb();
|
|
52
|
-
|
|
53
|
-
// Create session
|
|
54
|
-
const createRes = await testApp.app.inject({
|
|
55
|
-
method: 'POST',
|
|
56
|
-
url: '/api/sessions',
|
|
57
|
-
payload: {},
|
|
58
|
-
});
|
|
59
|
-
const session = createRes.json();
|
|
60
|
-
|
|
61
|
-
// Submit turn via HTTP — triggers fire-and-forget startTurn
|
|
62
|
-
const turnRes = await testApp.app.inject({
|
|
63
|
-
method: 'POST',
|
|
64
|
-
url: `/api/sessions/${session.id}/turns`,
|
|
65
|
-
payload: { user_prompt: 'Do something that fails' },
|
|
66
|
-
});
|
|
67
|
-
const turn = turnRes.json();
|
|
68
|
-
|
|
69
|
-
await waitForTurn(db, turn.id);
|
|
70
|
-
|
|
71
|
-
// Assert DB — turn
|
|
72
|
-
const dbTurn = db.prepare('SELECT status, error FROM turns WHERE id = ?').get(turn.id) as {
|
|
73
|
-
status: string;
|
|
74
|
-
error: string | null;
|
|
75
|
-
};
|
|
76
|
-
expect(dbTurn.status).toBe('failed');
|
|
77
|
-
expect(dbTurn.error).toBe('Rate limit exceeded. Please try again later.');
|
|
78
|
-
|
|
79
|
-
// Assert DB — session
|
|
80
|
-
const dbSession = db.prepare('SELECT is_running, status FROM sessions WHERE id = ?').get(session.id) as {
|
|
81
|
-
is_running: number;
|
|
82
|
-
status: string;
|
|
83
|
-
};
|
|
84
|
-
expect(dbSession.is_running).toBe(0);
|
|
85
|
-
expect(dbSession.status).toBe('failed');
|
|
86
|
-
|
|
87
|
-
// Assert WS broadcast
|
|
88
|
-
const failedData = findBroadcast('turn:failed') as {
|
|
89
|
-
sessionId: string;
|
|
90
|
-
turnId: string;
|
|
91
|
-
error: string;
|
|
92
|
-
};
|
|
93
|
-
expect(failedData.sessionId).toBe(session.id);
|
|
94
|
-
expect(failedData.turnId).toBe(turn.id);
|
|
95
|
-
expect(failedData.error).toBe('Rate limit exceeded. Please try again later.');
|
|
96
|
-
});
|
|
97
|
-
});
|