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,221 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { mapItemData, getItemStatus } from './item-mapper.ts';
|
|
3
|
-
import { mapTokenUsage } from './app-server-types.ts';
|
|
4
|
-
import type { AppServerItem, AppServerTokenUsageData } from './app-server-types.ts';
|
|
5
|
-
|
|
6
|
-
/** Helper to create an AppServerItem with required id field. */
|
|
7
|
-
function makeItem(partial: Partial<AppServerItem> & { type: string }): AppServerItem {
|
|
8
|
-
return { id: 'test-item', ...partial } as AppServerItem;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe('mapItemData', () => {
|
|
12
|
-
it('maps agent_message to { text }', () => {
|
|
13
|
-
const item = makeItem({ type: 'agent_message', text: 'Hello world' });
|
|
14
|
-
expect(mapItemData(item)).toEqual({ text: 'Hello world' });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('maps reasoning to { text }', () => {
|
|
18
|
-
const item = makeItem({ type: 'reasoning', text: 'Thinking...' });
|
|
19
|
-
expect(mapItemData(item)).toEqual({ text: 'Thinking...' });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('maps reasoning with summary array to joined text', () => {
|
|
23
|
-
const item = makeItem({ type: 'reasoning', summary: ['First thought', 'Second thought'] });
|
|
24
|
-
expect(mapItemData(item)).toEqual({ text: 'First thought\nSecond thought' });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('maps reasoning with empty summary and content to empty text', () => {
|
|
28
|
-
const item = makeItem({ type: 'reasoning', summary: [], content: [] });
|
|
29
|
-
expect(mapItemData(item)).toEqual({ text: '' });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('maps command_execution with all fields', () => {
|
|
33
|
-
const item = makeItem({
|
|
34
|
-
type: 'command_execution',
|
|
35
|
-
command: 'ls -la',
|
|
36
|
-
aggregated_output: 'total 0',
|
|
37
|
-
exit_code: 0,
|
|
38
|
-
status: 'completed',
|
|
39
|
-
});
|
|
40
|
-
expect(mapItemData(item)).toEqual({
|
|
41
|
-
command: 'ls -la',
|
|
42
|
-
aggregated_output: 'total 0',
|
|
43
|
-
exit_code: 0,
|
|
44
|
-
status: 'completed',
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('maps command_execution with null exit_code', () => {
|
|
49
|
-
const item = makeItem({
|
|
50
|
-
type: 'command_execution',
|
|
51
|
-
command: 'npm install',
|
|
52
|
-
aggregated_output: 'done',
|
|
53
|
-
status: 'completed',
|
|
54
|
-
});
|
|
55
|
-
expect(mapItemData(item)).toEqual({
|
|
56
|
-
command: 'npm install',
|
|
57
|
-
aggregated_output: 'done',
|
|
58
|
-
exit_code: null,
|
|
59
|
-
status: 'completed',
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('maps file_change with changes and status', () => {
|
|
64
|
-
const changes = [{ path: 'src/index.ts', change_type: 'modify' }];
|
|
65
|
-
const item = makeItem({ type: 'file_change', changes, status: 'completed' });
|
|
66
|
-
expect(mapItemData(item)).toEqual({ changes, status: 'completed' });
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('maps mcp_tool_call with all fields', () => {
|
|
70
|
-
const args = { query: 'test' };
|
|
71
|
-
const result = { data: 'response' };
|
|
72
|
-
const item = makeItem({
|
|
73
|
-
type: 'mcp_tool_call',
|
|
74
|
-
server: 'myserver',
|
|
75
|
-
tool: 'search',
|
|
76
|
-
arguments: args,
|
|
77
|
-
result,
|
|
78
|
-
error: null,
|
|
79
|
-
status: 'completed',
|
|
80
|
-
});
|
|
81
|
-
expect(mapItemData(item)).toEqual({
|
|
82
|
-
server: 'myserver',
|
|
83
|
-
tool: 'search',
|
|
84
|
-
arguments: args,
|
|
85
|
-
result,
|
|
86
|
-
error: null,
|
|
87
|
-
status: 'completed',
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('maps mcp_tool_call with null result and error', () => {
|
|
92
|
-
const item = makeItem({
|
|
93
|
-
type: 'mcp_tool_call',
|
|
94
|
-
server: 'srv',
|
|
95
|
-
tool: 't',
|
|
96
|
-
arguments: {},
|
|
97
|
-
status: 'failed',
|
|
98
|
-
});
|
|
99
|
-
expect(mapItemData(item)).toEqual({
|
|
100
|
-
server: 'srv',
|
|
101
|
-
tool: 't',
|
|
102
|
-
arguments: {},
|
|
103
|
-
result: null,
|
|
104
|
-
error: null,
|
|
105
|
-
status: 'failed',
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('maps web_search to { query }', () => {
|
|
110
|
-
const item = makeItem({ type: 'web_search', query: 'typescript vitest' });
|
|
111
|
-
expect(mapItemData(item)).toEqual({ query: 'typescript vitest' });
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('maps todo_list to { items }', () => {
|
|
115
|
-
const items = [{ content: 'task 1', status: 'completed' }];
|
|
116
|
-
const item = makeItem({ type: 'todo_list', items });
|
|
117
|
-
expect(mapItemData(item)).toEqual({ items });
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('maps error to { message }', () => {
|
|
121
|
-
const item = makeItem({ type: 'error', message: 'Something went wrong' });
|
|
122
|
-
expect(mapItemData(item)).toEqual({ message: 'Something went wrong' });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('returns empty object for unknown type', () => {
|
|
126
|
-
const item = makeItem({ type: 'unknown_type' });
|
|
127
|
-
expect(mapItemData(item)).toEqual({});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe('getItemStatus', () => {
|
|
132
|
-
it('returns item.status for command_execution', () => {
|
|
133
|
-
const item = makeItem({
|
|
134
|
-
type: 'command_execution',
|
|
135
|
-
command: 'ls',
|
|
136
|
-
aggregated_output: '',
|
|
137
|
-
exit_code: 1,
|
|
138
|
-
status: 'failed',
|
|
139
|
-
});
|
|
140
|
-
expect(getItemStatus(item)).toBe('failed');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('returns item.status for file_change', () => {
|
|
144
|
-
const item = makeItem({ type: 'file_change', changes: [], status: 'in_progress' });
|
|
145
|
-
expect(getItemStatus(item)).toBe('in_progress');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('returns item.status for mcp_tool_call', () => {
|
|
149
|
-
const item = makeItem({
|
|
150
|
-
type: 'mcp_tool_call',
|
|
151
|
-
server: 's',
|
|
152
|
-
tool: 't',
|
|
153
|
-
arguments: {},
|
|
154
|
-
status: 'completed',
|
|
155
|
-
});
|
|
156
|
-
expect(getItemStatus(item)).toBe('completed');
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('returns failed for error type', () => {
|
|
160
|
-
const item = makeItem({ type: 'error', message: 'boom' });
|
|
161
|
-
expect(getItemStatus(item)).toBe('failed');
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('returns completed for agent_message', () => {
|
|
165
|
-
const item = makeItem({ type: 'agent_message', text: 'hi' });
|
|
166
|
-
expect(getItemStatus(item)).toBe('completed');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('returns completed for reasoning', () => {
|
|
170
|
-
const item = makeItem({ type: 'reasoning', text: 'thinking' });
|
|
171
|
-
expect(getItemStatus(item)).toBe('completed');
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('returns completed for web_search', () => {
|
|
175
|
-
const item = makeItem({ type: 'web_search', query: 'test' });
|
|
176
|
-
expect(getItemStatus(item)).toBe('completed');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('returns completed for todo_list', () => {
|
|
180
|
-
const item = makeItem({ type: 'todo_list', items: [] });
|
|
181
|
-
expect(getItemStatus(item)).toBe('completed');
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe('mapTokenUsage', () => {
|
|
186
|
-
it('maps camelCase app-server fields to snake_case TokenUsage', () => {
|
|
187
|
-
const data: AppServerTokenUsageData = {
|
|
188
|
-
totalTokens: 15910,
|
|
189
|
-
inputTokens: 15901,
|
|
190
|
-
cachedInputTokens: 11008,
|
|
191
|
-
cacheWriteInputTokens: 0,
|
|
192
|
-
outputTokens: 9,
|
|
193
|
-
reasoningOutputTokens: 0,
|
|
194
|
-
};
|
|
195
|
-
expect(mapTokenUsage(data)).toEqual({
|
|
196
|
-
input_tokens: 15901,
|
|
197
|
-
cached_input_tokens: 11008,
|
|
198
|
-
cache_write_input_tokens: 0,
|
|
199
|
-
output_tokens: 9,
|
|
200
|
-
reasoning_output_tokens: 0,
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('maps zero values correctly', () => {
|
|
205
|
-
const data: AppServerTokenUsageData = {
|
|
206
|
-
totalTokens: 0,
|
|
207
|
-
inputTokens: 0,
|
|
208
|
-
cachedInputTokens: 0,
|
|
209
|
-
cacheWriteInputTokens: 0,
|
|
210
|
-
outputTokens: 0,
|
|
211
|
-
reasoningOutputTokens: 0,
|
|
212
|
-
};
|
|
213
|
-
expect(mapTokenUsage(data)).toEqual({
|
|
214
|
-
input_tokens: 0,
|
|
215
|
-
cached_input_tokens: 0,
|
|
216
|
-
cache_write_input_tokens: 0,
|
|
217
|
-
output_tokens: 0,
|
|
218
|
-
reasoning_output_tokens: 0,
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { AppServerItem } from './app-server-types.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Map an app-server item to a plain object for JSON storage in the items table.
|
|
5
|
-
*
|
|
6
|
-
* App-server uses camelCase type names: `agentMessage`, `userMessage`,
|
|
7
|
-
* `commandExecution`, `fileChange`, `mcpToolCall`, `webSearch`, `todoList`, `error`.
|
|
8
|
-
*
|
|
9
|
-
* @param item — The app-server item to map.
|
|
10
|
-
* @returns A plain object suitable for `JSON.stringify` into the `data` column.
|
|
11
|
-
*/
|
|
12
|
-
export function mapItemData(item: AppServerItem): Record<string, unknown> {
|
|
13
|
-
switch (item.type) {
|
|
14
|
-
case 'agentMessage':
|
|
15
|
-
case 'agent_message':
|
|
16
|
-
return { text: item.text };
|
|
17
|
-
|
|
18
|
-
case 'reasoning':
|
|
19
|
-
case 'agentReasoning': {
|
|
20
|
-
// App-server sends summary: string[] and content: string[] (both may be empty)
|
|
21
|
-
const summary = Array.isArray(item.summary) ? (item.summary as string[]).join('\n') : '';
|
|
22
|
-
return { text: summary || item.text || '' };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
case 'commandExecution':
|
|
26
|
-
case 'command_execution':
|
|
27
|
-
return {
|
|
28
|
-
command: item.command,
|
|
29
|
-
aggregated_output: item.aggregated_output,
|
|
30
|
-
exit_code: item.exit_code ?? null,
|
|
31
|
-
status: item.status,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
case 'fileChange':
|
|
35
|
-
case 'file_change':
|
|
36
|
-
return {
|
|
37
|
-
changes: item.changes,
|
|
38
|
-
status: item.status,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
case 'mcpToolCall':
|
|
42
|
-
case 'mcp_tool_call':
|
|
43
|
-
return {
|
|
44
|
-
server: item.server,
|
|
45
|
-
tool: item.tool,
|
|
46
|
-
arguments: item.arguments,
|
|
47
|
-
result: item.result ?? null,
|
|
48
|
-
error: item.error ?? null,
|
|
49
|
-
status: item.status,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
case 'webSearch':
|
|
53
|
-
case 'web_search':
|
|
54
|
-
return { query: item.query };
|
|
55
|
-
|
|
56
|
-
case 'todoList':
|
|
57
|
-
case 'todo_list':
|
|
58
|
-
return { items: item.items };
|
|
59
|
-
|
|
60
|
-
case 'error':
|
|
61
|
-
return { message: item.message };
|
|
62
|
-
|
|
63
|
-
default:
|
|
64
|
-
return {};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Determine the DB item status from a completed app-server item.
|
|
70
|
-
*
|
|
71
|
-
* @param item — The app-server item that has completed.
|
|
72
|
-
* @returns `'in_progress' | 'completed' | 'failed'`.
|
|
73
|
-
*/
|
|
74
|
-
export function getItemStatus(item: AppServerItem): 'in_progress' | 'completed' | 'failed' {
|
|
75
|
-
if (
|
|
76
|
-
item.type === 'commandExecution' || item.type === 'command_execution' ||
|
|
77
|
-
item.type === 'fileChange' || item.type === 'file_change' ||
|
|
78
|
-
item.type === 'mcpToolCall' || item.type === 'mcp_tool_call'
|
|
79
|
-
) {
|
|
80
|
-
return item.status ?? 'completed';
|
|
81
|
-
}
|
|
82
|
-
if (item.type === 'error') {
|
|
83
|
-
return 'failed';
|
|
84
|
-
}
|
|
85
|
-
return 'completed';
|
|
86
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** Singleton manager for the shared metadata app-server process. */
|
|
2
|
-
|
|
3
|
-
import { AppServerClient } from './app-server-client.ts';
|
|
4
|
-
|
|
5
|
-
let shared: AppServerClient | null = null;
|
|
6
|
-
|
|
7
|
-
/** Get or create the shared app-server client for metadata queries. */
|
|
8
|
-
export function getSharedAppServer(): AppServerClient {
|
|
9
|
-
if (!shared || shared.isClosed()) {
|
|
10
|
-
shared = new AppServerClient({ cwd: process.cwd() });
|
|
11
|
-
// Fire-and-forget initialize — the first request will wait for it
|
|
12
|
-
shared.initialize().catch((err) => {
|
|
13
|
-
console.error('[shared-app-server] Initialize failed:', err);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return shared;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** Close the shared app-server client. Called during graceful shutdown. */
|
|
20
|
-
export async function closeSharedAppServer(): Promise<void> {
|
|
21
|
-
if (shared) {
|
|
22
|
-
await shared.close();
|
|
23
|
-
shared = null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
-
import { initDb, getDb } from './index.ts';
|
|
3
|
-
import type Database from 'better-sqlite3';
|
|
4
|
-
|
|
5
|
-
describe('getDb', () => {
|
|
6
|
-
it('throws if initDb has not been called', async () => {
|
|
7
|
-
vi.resetModules();
|
|
8
|
-
const { getDb: freshGetDb } = await import('./index.ts');
|
|
9
|
-
expect(() => freshGetDb()).toThrow('Database not initialized');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('returns the database instance after initDb', () => {
|
|
13
|
-
const db = initDb(':memory:');
|
|
14
|
-
expect(getDb()).toBe(db);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('initDb', () => {
|
|
19
|
-
let db: Database.Database;
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
db = initDb(':memory:');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('creates sessions table', () => {
|
|
26
|
-
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='sessions'").all() as {
|
|
27
|
-
name: string;
|
|
28
|
-
}[];
|
|
29
|
-
expect(tables).toHaveLength(1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('creates turns table', () => {
|
|
33
|
-
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='turns'").all() as {
|
|
34
|
-
name: string;
|
|
35
|
-
}[];
|
|
36
|
-
expect(tables).toHaveLength(1);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('creates items table', () => {
|
|
40
|
-
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='items'").all() as {
|
|
41
|
-
name: string;
|
|
42
|
-
}[];
|
|
43
|
-
expect(tables).toHaveLength(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('creates workspaces table', () => {
|
|
47
|
-
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='workspaces'").all() as {
|
|
48
|
-
name: string;
|
|
49
|
-
}[];
|
|
50
|
-
expect(tables).toHaveLength(1);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('creates idx_turns_session_id index', () => {
|
|
54
|
-
const indexes = db
|
|
55
|
-
.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='idx_turns_session_id'")
|
|
56
|
-
.all() as { name: string }[];
|
|
57
|
-
expect(indexes).toHaveLength(1);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('creates idx_items_turn_id index', () => {
|
|
61
|
-
const indexes = db
|
|
62
|
-
.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='idx_items_turn_id'")
|
|
63
|
-
.all() as { name: string }[];
|
|
64
|
-
expect(indexes).toHaveLength(1);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('creates idx_workspaces_path index', () => {
|
|
68
|
-
const indexes = db
|
|
69
|
-
.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='idx_workspaces_path'")
|
|
70
|
-
.all() as { name: string }[];
|
|
71
|
-
expect(indexes).toHaveLength(1);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('adds lifecycle column to sessions', () => {
|
|
75
|
-
const cols = db.prepare('PRAGMA table_info(sessions)').all() as { name: string }[];
|
|
76
|
-
expect(cols.some((c) => c.name === 'lifecycle')).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('adds has_unreviewed column to sessions', () => {
|
|
80
|
-
const cols = db.prepare('PRAGMA table_info(sessions)').all() as { name: string }[];
|
|
81
|
-
expect(cols.some((c) => c.name === 'has_unreviewed')).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('adds model_reasoning_effort column to sessions', () => {
|
|
85
|
-
const cols = db.prepare('PRAGMA table_info(sessions)').all() as { name: string }[];
|
|
86
|
-
expect(cols.some((c) => c.name === 'model_reasoning_effort')).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('adds deleted column to workspaces', () => {
|
|
90
|
-
const cols = db.prepare('PRAGMA table_info(workspaces)').all() as { name: string }[];
|
|
91
|
-
expect(cols.some((c) => c.name === 'deleted')).toBe(true);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('enables foreign keys', () => {
|
|
95
|
-
const result = db.pragma('foreign_keys', { simple: true }) as number;
|
|
96
|
-
expect(result).toBe(1);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('enforces foreign key cascade on turn deletion', () => {
|
|
100
|
-
db.prepare(
|
|
101
|
-
'INSERT INTO sessions (id, title, runtime_type, status, is_running, lifecycle, has_unreviewed, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
102
|
-
).run('s1', null, 'codex', 'active', 0, 'working', 0, '2025-01-01T00:00:00Z', '2025-01-01T00:00:00Z');
|
|
103
|
-
|
|
104
|
-
db.prepare(
|
|
105
|
-
'INSERT INTO turns (id, session_id, user_prompt, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)',
|
|
106
|
-
).run('t1', 's1', 'hello', 'pending', '2025-01-01T00:00:00Z', '2025-01-01T00:00:00Z');
|
|
107
|
-
|
|
108
|
-
db.prepare('INSERT INTO items (id, turn_id, type, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)').run(
|
|
109
|
-
'i1',
|
|
110
|
-
't1',
|
|
111
|
-
'agent_message',
|
|
112
|
-
'completed',
|
|
113
|
-
'2025-01-01T00:00:00Z',
|
|
114
|
-
'2025-01-01T00:00:00Z',
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
// Delete session → cascades to turns → cascades to items
|
|
118
|
-
db.prepare('DELETE FROM sessions WHERE id = ?').run('s1');
|
|
119
|
-
|
|
120
|
-
const turns = db.prepare('SELECT COUNT(*) as count FROM turns').get() as { count: number };
|
|
121
|
-
const items = db.prepare('SELECT COUNT(*) as count FROM items').get() as { count: number };
|
|
122
|
-
expect(turns.count).toBe(0);
|
|
123
|
-
expect(items.count).toBe(0);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import Database from 'better-sqlite3';
|
|
2
|
-
|
|
3
|
-
let db: Database.Database;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Initialise the SQLite database at the given path.
|
|
7
|
-
*
|
|
8
|
-
* Enables WAL journal mode and foreign keys, then creates tables and runs
|
|
9
|
-
* any pending column migrations.
|
|
10
|
-
*
|
|
11
|
-
* @param path — Filesystem path to the SQLite database file. Use `':memory:'` for tests.
|
|
12
|
-
* @returns The initialised `Database` instance.
|
|
13
|
-
*/
|
|
14
|
-
export function initDb(path: string = 'data.db'): Database.Database {
|
|
15
|
-
db = new Database(path);
|
|
16
|
-
db.pragma('journal_mode = WAL');
|
|
17
|
-
db.pragma('foreign_keys = ON');
|
|
18
|
-
|
|
19
|
-
createTables(db);
|
|
20
|
-
cleanupStaleState(db);
|
|
21
|
-
return db;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get the initialised database instance.
|
|
26
|
-
*
|
|
27
|
-
* @throws Error if `initDb()` has not been called yet.
|
|
28
|
-
* @returns The singleton `Database` instance.
|
|
29
|
-
*/
|
|
30
|
-
export function getDb(): Database.Database {
|
|
31
|
-
if (!db) {
|
|
32
|
-
throw new Error('Database not initialized. Call initDb() first.');
|
|
33
|
-
}
|
|
34
|
-
return db;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Clean up stale running state from a previous backend process that crashed
|
|
39
|
-
* or was killed while a turn was in progress.
|
|
40
|
-
*
|
|
41
|
-
* Resets all sessions with `is_running = 1` to `is_running = 0, status = 'active'`,
|
|
42
|
-
* and marks all turns with `status = 'running'` as `failed` with an explanatory
|
|
43
|
-
* error message. This prevents a deadlock where the frontend sees stale running
|
|
44
|
-
* state and blocks the input bar after a backend restart.
|
|
45
|
-
*
|
|
46
|
-
* No-op if no stale state exists (0 rows affected). Safe for tests (fresh DB).
|
|
47
|
-
*/
|
|
48
|
-
function cleanupStaleState(database: Database.Database): void {
|
|
49
|
-
const now = new Date().toISOString();
|
|
50
|
-
|
|
51
|
-
// Mark ALL in_progress items as failed — after a backend restart, no background
|
|
52
|
-
// task can still be running (the CLI process is dead). This includes in_progress
|
|
53
|
-
// background_task items inside completed turns (Monitor/Subagent tasks that
|
|
54
|
-
// outlive their turn via streaming-input mode).
|
|
55
|
-
const staleItems = database.prepare(
|
|
56
|
-
"UPDATE items SET status = 'failed', updated_at = ? WHERE status = 'in_progress'",
|
|
57
|
-
).run(now);
|
|
58
|
-
|
|
59
|
-
const staleSessions = database.prepare('UPDATE sessions SET is_running = 0, status = ?, updated_at = ? WHERE is_running = 1').run('active', now);
|
|
60
|
-
const staleTurns = database.prepare("UPDATE turns SET status = 'failed', error = ?, updated_at = ? WHERE status = 'running'").run('Backend restarted while turn was running', now);
|
|
61
|
-
if (staleSessions.changes > 0 || staleTurns.changes > 0 || staleItems.changes > 0) {
|
|
62
|
-
console.log(`[db] Cleaned up stale state: ${staleSessions.changes} sessions, ${staleTurns.changes} turns, ${staleItems.changes} items`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Create all tables and run inline migrations for new columns.
|
|
68
|
-
*
|
|
69
|
-
* Tables: `sessions`, `turns`, `items`, `workspaces`.
|
|
70
|
-
* Migrations: `deleted` (workspaces), `lifecycle` + `has_unreviewed` +
|
|
71
|
-
* `model_reasoning_effort` (sessions) — each guarded by PRAGMA table_info check.
|
|
72
|
-
*
|
|
73
|
-
* @param database — The DB instance to create tables in.
|
|
74
|
-
*/
|
|
75
|
-
function createTables(database: Database.Database): void {
|
|
76
|
-
database.exec(`
|
|
77
|
-
CREATE TABLE IF NOT EXISTS sessions (
|
|
78
|
-
id TEXT PRIMARY KEY,
|
|
79
|
-
title TEXT,
|
|
80
|
-
runtime_type TEXT NOT NULL DEFAULT 'codex',
|
|
81
|
-
model TEXT,
|
|
82
|
-
cwd TEXT,
|
|
83
|
-
external_thread_id TEXT,
|
|
84
|
-
status TEXT NOT NULL DEFAULT 'active',
|
|
85
|
-
is_running INTEGER NOT NULL DEFAULT 0,
|
|
86
|
-
created_at TEXT NOT NULL,
|
|
87
|
-
updated_at TEXT NOT NULL
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
CREATE TABLE IF NOT EXISTS turns (
|
|
91
|
-
id TEXT PRIMARY KEY,
|
|
92
|
-
session_id TEXT NOT NULL,
|
|
93
|
-
user_prompt TEXT NOT NULL,
|
|
94
|
-
agent_response TEXT,
|
|
95
|
-
thoughts TEXT,
|
|
96
|
-
token_usage TEXT,
|
|
97
|
-
external_turn_id TEXT,
|
|
98
|
-
status TEXT NOT NULL DEFAULT 'pending',
|
|
99
|
-
error TEXT,
|
|
100
|
-
created_at TEXT NOT NULL,
|
|
101
|
-
updated_at TEXT NOT NULL,
|
|
102
|
-
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
CREATE TABLE IF NOT EXISTS items (
|
|
106
|
-
id TEXT PRIMARY KEY,
|
|
107
|
-
turn_id TEXT NOT NULL,
|
|
108
|
-
external_item_id TEXT,
|
|
109
|
-
type TEXT NOT NULL,
|
|
110
|
-
data TEXT,
|
|
111
|
-
status TEXT NOT NULL DEFAULT 'in_progress',
|
|
112
|
-
created_at TEXT NOT NULL,
|
|
113
|
-
updated_at TEXT NOT NULL,
|
|
114
|
-
FOREIGN KEY (turn_id) REFERENCES turns(id) ON DELETE CASCADE
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
CREATE TABLE IF NOT EXISTS workspaces (
|
|
118
|
-
id TEXT PRIMARY KEY,
|
|
119
|
-
path TEXT NOT NULL UNIQUE,
|
|
120
|
-
label TEXT,
|
|
121
|
-
deleted INTEGER NOT NULL DEFAULT 0,
|
|
122
|
-
created_at TEXT NOT NULL
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
CREATE TABLE IF NOT EXISTS discussion_threads (
|
|
126
|
-
id TEXT PRIMARY KEY,
|
|
127
|
-
session_id TEXT NOT NULL,
|
|
128
|
-
item_id TEXT NOT NULL,
|
|
129
|
-
turn_id TEXT NOT NULL,
|
|
130
|
-
start_offset INTEGER NOT NULL,
|
|
131
|
-
end_offset INTEGER NOT NULL,
|
|
132
|
-
selected_text TEXT NOT NULL,
|
|
133
|
-
status TEXT NOT NULL DEFAULT 'open',
|
|
134
|
-
resolved_at TEXT,
|
|
135
|
-
created_at TEXT NOT NULL,
|
|
136
|
-
updated_at TEXT NOT NULL,
|
|
137
|
-
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
CREATE INDEX IF NOT EXISTS idx_turns_session_id ON turns(session_id);
|
|
141
|
-
CREATE INDEX IF NOT EXISTS idx_items_turn_id ON items(turn_id);
|
|
142
|
-
CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
|
|
143
|
-
CREATE INDEX IF NOT EXISTS idx_discussion_threads_session_id ON discussion_threads(session_id);
|
|
144
|
-
CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
|
|
145
|
-
`);
|
|
146
|
-
|
|
147
|
-
// Migration: add 'deleted' column to existing workspaces table if missing
|
|
148
|
-
const wsColumns = database.prepare('PRAGMA table_info(workspaces)').all() as { name: string }[];
|
|
149
|
-
if (!wsColumns.some((c) => c.name === 'deleted')) {
|
|
150
|
-
database.exec('ALTER TABLE workspaces ADD COLUMN deleted INTEGER NOT NULL DEFAULT 0');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Migration: add 'lifecycle' + 'has_unreviewed' columns to existing sessions table
|
|
154
|
-
const sessColumns = database.prepare('PRAGMA table_info(sessions)').all() as { name: string }[];
|
|
155
|
-
if (!sessColumns.some((c) => c.name === 'lifecycle')) {
|
|
156
|
-
database.exec("ALTER TABLE sessions ADD COLUMN lifecycle TEXT NOT NULL DEFAULT 'working'");
|
|
157
|
-
}
|
|
158
|
-
if (!sessColumns.some((c) => c.name === 'has_unreviewed')) {
|
|
159
|
-
database.exec('ALTER TABLE sessions ADD COLUMN has_unreviewed INTEGER NOT NULL DEFAULT 0');
|
|
160
|
-
}
|
|
161
|
-
if (!sessColumns.some((c) => c.name === 'model_reasoning_effort')) {
|
|
162
|
-
database.exec('ALTER TABLE sessions ADD COLUMN model_reasoning_effort TEXT');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Migration: add 'runtime_config' column to existing sessions table
|
|
166
|
-
if (!sessColumns.some((c) => c.name === 'runtime_config')) {
|
|
167
|
-
database.exec('ALTER TABLE sessions ADD COLUMN runtime_config TEXT');
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Migration: add 'rewound_at_turn_id' + 'pre_rewind_thread_id' columns for non-destructive rewind
|
|
171
|
-
if (!sessColumns.some((c) => c.name === 'rewound_at_turn_id')) {
|
|
172
|
-
database.exec('ALTER TABLE sessions ADD COLUMN rewound_at_turn_id TEXT');
|
|
173
|
-
}
|
|
174
|
-
if (!sessColumns.some((c) => c.name === 'pre_rewind_thread_id')) {
|
|
175
|
-
database.exec('ALTER TABLE sessions ADD COLUMN pre_rewind_thread_id TEXT');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Migration: add 'context_usage' column — persisted last-known context-window usage
|
|
179
|
-
// (JSON of ContextUsage) so the status-bar counter survives page reload.
|
|
180
|
-
if (!sessColumns.some((c) => c.name === 'context_usage')) {
|
|
181
|
-
database.exec('ALTER TABLE sessions ADD COLUMN context_usage TEXT');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Migration: add 'thread_id' column to turns table (discussion threads feature)
|
|
185
|
-
const turnColumns = database.prepare('PRAGMA table_info(turns)').all() as { name: string }[];
|
|
186
|
-
if (!turnColumns.some((c) => c.name === 'thread_id')) {
|
|
187
|
-
database.exec('ALTER TABLE turns ADD COLUMN thread_id TEXT');
|
|
188
|
-
}
|
|
189
|
-
database.exec('CREATE INDEX IF NOT EXISTS idx_turns_thread_id ON turns(thread_id)');
|
|
190
|
-
|
|
191
|
-
// Migration: add 'attachments' column to turns table (file upload feature)
|
|
192
|
-
if (!turnColumns.some((c) => c.name === 'attachments')) {
|
|
193
|
-
database.exec('ALTER TABLE turns ADD COLUMN attachments TEXT');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Migration: add 'external_thread_id' column to discussion_threads (thread branching)
|
|
197
|
-
const threadColumns = database.prepare('PRAGMA table_info(discussion_threads)').all() as { name: string }[];
|
|
198
|
-
if (!threadColumns.some((c) => c.name === 'external_thread_id')) {
|
|
199
|
-
database.exec('ALTER TABLE discussion_threads ADD COLUMN external_thread_id TEXT');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Migration: drop discussion_threads if it was created with FK constraints on
|
|
203
|
-
// item_id/turn_id (initial version). Those FKs fail when the frontend sends
|
|
204
|
-
// delta-* item IDs from live streaming. Recreate without those FKs.
|
|
205
|
-
const threadTableDef = database
|
|
206
|
-
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='discussion_threads'")
|
|
207
|
-
.get() as { sql: string } | undefined;
|
|
208
|
-
if (threadTableDef && threadTableDef.sql.includes('FOREIGN KEY (item_id)')) {
|
|
209
|
-
database.exec('DROP TABLE discussion_threads');
|
|
210
|
-
// Recreate with the new schema (no FKs on item_id/turn_id)
|
|
211
|
-
database.exec(`
|
|
212
|
-
CREATE TABLE IF NOT EXISTS discussion_threads (
|
|
213
|
-
id TEXT PRIMARY KEY,
|
|
214
|
-
session_id TEXT NOT NULL,
|
|
215
|
-
item_id TEXT NOT NULL,
|
|
216
|
-
turn_id TEXT NOT NULL,
|
|
217
|
-
start_offset INTEGER NOT NULL,
|
|
218
|
-
end_offset INTEGER NOT NULL,
|
|
219
|
-
selected_text TEXT NOT NULL,
|
|
220
|
-
status TEXT NOT NULL DEFAULT 'open',
|
|
221
|
-
resolved_at TEXT,
|
|
222
|
-
created_at TEXT NOT NULL,
|
|
223
|
-
updated_at TEXT NOT NULL,
|
|
224
|
-
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
225
|
-
);
|
|
226
|
-
CREATE INDEX IF NOT EXISTS idx_discussion_threads_session_id ON discussion_threads(session_id);
|
|
227
|
-
CREATE INDEX IF NOT EXISTS idx_discussion_threads_item_id ON discussion_threads(item_id);
|
|
228
|
-
`);
|
|
229
|
-
}
|
|
230
|
-
}
|