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,619 +0,0 @@
|
|
|
1
|
-
import type { SessionRuntimeConfig, ModelInfo } from '@agentpane/shared';
|
|
2
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
-
import type Database from 'better-sqlite3';
|
|
4
|
-
import { getDb } from '../db/index.ts';
|
|
5
|
-
import { broadcast } from '../ws/index.ts';
|
|
6
|
-
import { mapItemData, getItemStatus } from './item-mapper.ts';
|
|
7
|
-
import { AppServerClient } from './app-server-client.ts';
|
|
8
|
-
import type {
|
|
9
|
-
ItemNotification,
|
|
10
|
-
TurnFailedNotification,
|
|
11
|
-
ThreadStartResult,
|
|
12
|
-
TurnStartResult,
|
|
13
|
-
AppServerItem,
|
|
14
|
-
AgentMessageDeltaNotification,
|
|
15
|
-
TokenUsageNotification,
|
|
16
|
-
ModelListResult,
|
|
17
|
-
} from './app-server-types.ts';
|
|
18
|
-
import { mapTokenUsage } from './app-server-types.ts';
|
|
19
|
-
import { getSharedAppServer, closeSharedAppServer } from './shared-app-server.ts';
|
|
20
|
-
import type { Session, Turn, Item, ItemStatus } from '../db/schema.ts';
|
|
21
|
-
import type { RuntimeProvider } from '../providers/runtime-provider.ts';
|
|
22
|
-
|
|
23
|
-
/** Per-session app-server client + thread state. */
|
|
24
|
-
interface SessionEntry {
|
|
25
|
-
client: AppServerClient;
|
|
26
|
-
threadId: string;
|
|
27
|
-
turnId: string | null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const sessionMap = new Map<string, SessionEntry>();
|
|
31
|
-
|
|
32
|
-
/** Update the running state and status of a session. */
|
|
33
|
-
function setSessionStatus(
|
|
34
|
-
db: Database.Database,
|
|
35
|
-
sessionId: string,
|
|
36
|
-
isRunning: 0 | 1,
|
|
37
|
-
status: string,
|
|
38
|
-
now: string,
|
|
39
|
-
hasUnreviewed = false,
|
|
40
|
-
): void {
|
|
41
|
-
if (hasUnreviewed) {
|
|
42
|
-
db.prepare('UPDATE sessions SET is_running = ?, status = ?, has_unreviewed = 1, updated_at = ? WHERE id = ?').run(
|
|
43
|
-
isRunning,
|
|
44
|
-
status,
|
|
45
|
-
now,
|
|
46
|
-
sessionId,
|
|
47
|
-
);
|
|
48
|
-
} else {
|
|
49
|
-
db.prepare('UPDATE sessions SET is_running = ?, status = ?, updated_at = ? WHERE id = ?').run(
|
|
50
|
-
isRunning,
|
|
51
|
-
status,
|
|
52
|
-
now,
|
|
53
|
-
sessionId,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Parse runtime_config JSON from the session row. Returns null on parse failure. */
|
|
59
|
-
function parseRuntimeConfig(session: Session): SessionRuntimeConfig | null {
|
|
60
|
-
if (!session.runtime_config) return null;
|
|
61
|
-
try {
|
|
62
|
-
return JSON.parse(session.runtime_config) as SessionRuntimeConfig;
|
|
63
|
-
} catch {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Map runtime config sandbox mode to app-server sandbox type string (kebab-case). */
|
|
69
|
-
function sandboxType(config: SessionRuntimeConfig | null): 'read-only' | 'workspace-write' | 'danger-full-access' {
|
|
70
|
-
switch (config?.sandboxMode) {
|
|
71
|
-
case 'read-only':
|
|
72
|
-
return 'read-only';
|
|
73
|
-
case 'danger-full-access':
|
|
74
|
-
return 'danger-full-access';
|
|
75
|
-
default:
|
|
76
|
-
return 'workspace-write';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Convert app-server camelCase item type to DB snake_case item type. */
|
|
81
|
-
function normalizeItemType(type: string): string {
|
|
82
|
-
const map: Record<string, string> = {
|
|
83
|
-
agentMessage: 'agent_message',
|
|
84
|
-
userMessage: 'user_message',
|
|
85
|
-
agentReasoning: 'reasoning',
|
|
86
|
-
commandExecution: 'command_execution',
|
|
87
|
-
fileChange: 'file_change',
|
|
88
|
-
mcpToolCall: 'mcp_tool_call',
|
|
89
|
-
webSearch: 'web_search',
|
|
90
|
-
todoList: 'todo_list',
|
|
91
|
-
error: 'error',
|
|
92
|
-
};
|
|
93
|
-
return map[type] ?? type;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Check if an item type should be skipped (not stored in DB). */
|
|
97
|
-
function shouldSkipItem(type: string): boolean {
|
|
98
|
-
return type === 'userMessage' || type === 'user_message';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Check if a reasoning item has empty content (app-server sends summary: [], content: []). */
|
|
102
|
-
function isEmptyReasoning(item: AppServerItem): boolean {
|
|
103
|
-
const summary = Array.isArray(item.summary) ? item.summary : [];
|
|
104
|
-
const content = Array.isArray(item.content) ? item.content : [];
|
|
105
|
-
const text = item.text ?? '';
|
|
106
|
-
return summary.length === 0 && content.length === 0 && text.length === 0;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Create or resume a thread for the session via a per-session app-server client. */
|
|
110
|
-
async function getOrCreateThread(session: Session): Promise<SessionEntry> {
|
|
111
|
-
const existing = sessionMap.get(session.id);
|
|
112
|
-
if (existing) return existing;
|
|
113
|
-
|
|
114
|
-
const cwd = session.cwd ?? process.cwd();
|
|
115
|
-
const client = new AppServerClient({ cwd });
|
|
116
|
-
await client.initialize();
|
|
117
|
-
|
|
118
|
-
const config = parseRuntimeConfig(session);
|
|
119
|
-
const sandbox = sandboxType(config);
|
|
120
|
-
|
|
121
|
-
let threadId: string;
|
|
122
|
-
|
|
123
|
-
if (session.external_thread_id) {
|
|
124
|
-
const result = await client.request<ThreadStartResult>('thread/resume', {
|
|
125
|
-
threadId: session.external_thread_id,
|
|
126
|
-
cwd,
|
|
127
|
-
approvalPolicy: 'never',
|
|
128
|
-
sandbox,
|
|
129
|
-
model: session.model ?? undefined,
|
|
130
|
-
});
|
|
131
|
-
threadId = result.thread.id;
|
|
132
|
-
} else {
|
|
133
|
-
const result = await client.request<ThreadStartResult>('thread/start', {
|
|
134
|
-
cwd,
|
|
135
|
-
approvalPolicy: 'never',
|
|
136
|
-
sandbox,
|
|
137
|
-
model: session.model ?? undefined,
|
|
138
|
-
});
|
|
139
|
-
threadId = result.thread.id;
|
|
140
|
-
|
|
141
|
-
// Save the thread ID to the database
|
|
142
|
-
const db = getDb();
|
|
143
|
-
const now = new Date().toISOString();
|
|
144
|
-
db.prepare('UPDATE sessions SET external_thread_id = ?, updated_at = ? WHERE id = ?').run(
|
|
145
|
-
threadId,
|
|
146
|
-
now,
|
|
147
|
-
session.id,
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const entry: SessionEntry = { client, threadId, turnId: null };
|
|
152
|
-
sessionMap.set(session.id, entry);
|
|
153
|
-
return entry;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** Start a Codex turn. Fire-and-forget — streams events via WS. */
|
|
157
|
-
export async function startTurn(session: Session, turn: Turn): Promise<void> {
|
|
158
|
-
const db = getDb();
|
|
159
|
-
|
|
160
|
-
// Phase 1: create or resume thread
|
|
161
|
-
let entry: SessionEntry;
|
|
162
|
-
try {
|
|
163
|
-
entry = await getOrCreateThread(session);
|
|
164
|
-
} catch (err) {
|
|
165
|
-
const errMsg = `Failed to create app-server thread: ${(err as Error).message}`;
|
|
166
|
-
const now = new Date().toISOString();
|
|
167
|
-
db.prepare('UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?').run(
|
|
168
|
-
'failed',
|
|
169
|
-
errMsg,
|
|
170
|
-
now,
|
|
171
|
-
turn.id,
|
|
172
|
-
);
|
|
173
|
-
setSessionStatus(db, session.id, 0, 'failed', now);
|
|
174
|
-
broadcast('turn:failed', { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Phase 2: update status
|
|
179
|
-
entry.turnId = turn.id;
|
|
180
|
-
const now = new Date().toISOString();
|
|
181
|
-
db.prepare('UPDATE turns SET status = ?, updated_at = ? WHERE id = ?').run('running', now, turn.id);
|
|
182
|
-
setSessionStatus(db, session.id, 1, 'running', now);
|
|
183
|
-
broadcast('turn:started', { sessionId: session.id, turnId: turn.id });
|
|
184
|
-
|
|
185
|
-
// Phase 3: register notification handlers and send turn/start
|
|
186
|
-
const { client, threadId } = entry;
|
|
187
|
-
const config = parseRuntimeConfig(session);
|
|
188
|
-
const sandbox = sandboxType(config);
|
|
189
|
-
|
|
190
|
-
// Flag to prevent duplicate handler execution after turn ends
|
|
191
|
-
let turnDone = false;
|
|
192
|
-
|
|
193
|
-
// Register handlers for this turn (scoped by threadId — one active turn per session)
|
|
194
|
-
const handleItemStarted = (params: unknown) => {
|
|
195
|
-
if (turnDone) return;
|
|
196
|
-
const p = params as ItemNotification;
|
|
197
|
-
if (p.threadId !== threadId) return;
|
|
198
|
-
handleItemEvent(p, session.id, turn.id, 'in_progress', 'item:started');
|
|
199
|
-
};
|
|
200
|
-
const handleItemUpdated = (params: unknown) => {
|
|
201
|
-
if (turnDone) return;
|
|
202
|
-
const p = params as ItemNotification;
|
|
203
|
-
if (p.threadId !== threadId) return;
|
|
204
|
-
handleItemEvent(p, session.id, turn.id, 'in_progress', 'item:updated');
|
|
205
|
-
};
|
|
206
|
-
const handleItemCompleted = (params: unknown) => {
|
|
207
|
-
if (turnDone) return;
|
|
208
|
-
const p = params as ItemNotification;
|
|
209
|
-
if (p.threadId !== threadId) return;
|
|
210
|
-
const status = getItemStatus(p.item);
|
|
211
|
-
handleItemEvent(p, session.id, turn.id, status, 'item:completed');
|
|
212
|
-
};
|
|
213
|
-
const handleTurnCompleted = (params: unknown) => {
|
|
214
|
-
if (turnDone) return;
|
|
215
|
-
const p = params as { threadId: string; turn?: { id: string; status: string }; usage?: unknown };
|
|
216
|
-
if (p.threadId !== threadId) return;
|
|
217
|
-
turnDone = true;
|
|
218
|
-
const db = getDb();
|
|
219
|
-
const now = new Date().toISOString();
|
|
220
|
-
// Token usage may be in params (mock) or already saved via thread/tokenUsage/updated (real app-server).
|
|
221
|
-
// When p.usage is undefined, preserve existing token_usage (set by thread/tokenUsage/updated handler).
|
|
222
|
-
if (p.usage !== undefined) {
|
|
223
|
-
db.prepare('UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?').run(
|
|
224
|
-
'completed',
|
|
225
|
-
JSON.stringify(p.usage),
|
|
226
|
-
now,
|
|
227
|
-
turn.id,
|
|
228
|
-
);
|
|
229
|
-
broadcast('turn:completed', { sessionId: session.id, turnId: turn.id, usage: p.usage, hasUnreviewed: true });
|
|
230
|
-
} else {
|
|
231
|
-
db.prepare('UPDATE turns SET status = ?, updated_at = ? WHERE id = ?').run('completed', now, turn.id);
|
|
232
|
-
broadcast('turn:completed', { sessionId: session.id, turnId: turn.id, hasUnreviewed: true });
|
|
233
|
-
}
|
|
234
|
-
setSessionStatus(db, session.id, 0, 'active', now, true);
|
|
235
|
-
syncThreadTitle(session.id);
|
|
236
|
-
};
|
|
237
|
-
const handleTurnFailed = (params: unknown) => {
|
|
238
|
-
if (turnDone) return;
|
|
239
|
-
const p = params as TurnFailedNotification;
|
|
240
|
-
if (p.threadId !== threadId) return;
|
|
241
|
-
turnDone = true;
|
|
242
|
-
const db = getDb();
|
|
243
|
-
const now = new Date().toISOString();
|
|
244
|
-
db.prepare('UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?').run(
|
|
245
|
-
'failed',
|
|
246
|
-
p.error.message,
|
|
247
|
-
now,
|
|
248
|
-
turn.id,
|
|
249
|
-
);
|
|
250
|
-
setSessionStatus(db, session.id, 0, 'failed', now);
|
|
251
|
-
broadcast('turn:failed', { sessionId: session.id, turnId: turn.id, error: p.error.message });
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// Stream incremental text deltas to frontend — no DB write per delta (performance).
|
|
255
|
-
// The final text is written by handleItemEvent on item/completed.
|
|
256
|
-
const handleAgentMessageDelta = (params: unknown) => {
|
|
257
|
-
if (turnDone) return;
|
|
258
|
-
const p = params as AgentMessageDeltaNotification;
|
|
259
|
-
if (p.threadId !== threadId) return;
|
|
260
|
-
broadcast('item:delta', {
|
|
261
|
-
sessionId: session.id,
|
|
262
|
-
turnId: turn.id,
|
|
263
|
-
itemId: p.itemId,
|
|
264
|
-
delta: p.delta,
|
|
265
|
-
});
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// Save token usage from thread/tokenUsage/updated — no turnDone guard (may arrive before or after turn/completed).
|
|
269
|
-
const handleTokenUsageUpdated = (params: unknown) => {
|
|
270
|
-
const p = params as TokenUsageNotification;
|
|
271
|
-
if (p.threadId !== threadId) return;
|
|
272
|
-
const usage = mapTokenUsage(p.tokenUsage.total);
|
|
273
|
-
const db = getDb();
|
|
274
|
-
const now = new Date().toISOString();
|
|
275
|
-
db.prepare('UPDATE turns SET token_usage = ?, updated_at = ? WHERE id = ?').run(
|
|
276
|
-
JSON.stringify(usage),
|
|
277
|
-
now,
|
|
278
|
-
turn.id,
|
|
279
|
-
);
|
|
280
|
-
broadcast('turn:tokenUsage', { sessionId: session.id, turnId: turn.id, usage });
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// Note: onNotification adds to a list, so we register before sending turn/start
|
|
284
|
-
client.onNotification('item/started', handleItemStarted);
|
|
285
|
-
client.onNotification('item/updated', handleItemUpdated);
|
|
286
|
-
client.onNotification('item/completed', handleItemCompleted);
|
|
287
|
-
client.onNotification('item/agentMessage/delta', handleAgentMessageDelta);
|
|
288
|
-
client.onNotification('turn/completed', handleTurnCompleted);
|
|
289
|
-
client.onNotification('turn/failed', handleTurnFailed);
|
|
290
|
-
client.onNotification('thread/tokenUsage/updated', handleTokenUsageUpdated);
|
|
291
|
-
|
|
292
|
-
// Phase 4: send turn/start
|
|
293
|
-
try {
|
|
294
|
-
await client.request<TurnStartResult>('turn/start', {
|
|
295
|
-
threadId,
|
|
296
|
-
input: [{ type: 'text', text: turn.user_prompt }],
|
|
297
|
-
approvalPolicy: 'never',
|
|
298
|
-
sandbox: { type: sandbox },
|
|
299
|
-
model: session.model ?? undefined,
|
|
300
|
-
effort: session.model_reasoning_effort ?? undefined,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// The turn runs asynchronously — events arrive via notifications
|
|
304
|
-
// If the process closes unexpectedly, handle cleanup
|
|
305
|
-
client.events.once('closed', () => {
|
|
306
|
-
const db = getDb();
|
|
307
|
-
const now = new Date().toISOString();
|
|
308
|
-
const currentTurn = db.prepare('SELECT status FROM turns WHERE id = ?').get(turn.id) as
|
|
309
|
-
| { status: string }
|
|
310
|
-
| undefined;
|
|
311
|
-
if (currentTurn && currentTurn.status === 'running') {
|
|
312
|
-
db.prepare('UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?').run(
|
|
313
|
-
'failed',
|
|
314
|
-
'App-server process closed unexpectedly',
|
|
315
|
-
now,
|
|
316
|
-
turn.id,
|
|
317
|
-
);
|
|
318
|
-
setSessionStatus(db, session.id, 0, 'failed', now);
|
|
319
|
-
broadcast('turn:failed', {
|
|
320
|
-
sessionId: session.id,
|
|
321
|
-
turnId: turn.id,
|
|
322
|
-
error: 'App-server process closed unexpectedly',
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
} catch (err) {
|
|
327
|
-
const errMsg = (err as Error).message;
|
|
328
|
-
const now2 = new Date().toISOString();
|
|
329
|
-
db.prepare('UPDATE turns SET status = ?, error = ?, updated_at = ? WHERE id = ?').run(
|
|
330
|
-
'failed',
|
|
331
|
-
errMsg,
|
|
332
|
-
now2,
|
|
333
|
-
turn.id,
|
|
334
|
-
);
|
|
335
|
-
setSessionStatus(db, session.id, 0, 'failed', now2);
|
|
336
|
-
broadcast('turn:failed', { sessionId: session.id, turnId: turn.id, error: errMsg });
|
|
337
|
-
turnDone = true;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** Handle an item notification — insert or update DB row and broadcast. */
|
|
342
|
-
function handleItemEvent(
|
|
343
|
-
params: ItemNotification,
|
|
344
|
-
sessionId: string,
|
|
345
|
-
turnId: string,
|
|
346
|
-
status: ItemStatus,
|
|
347
|
-
broadcastEvent: string,
|
|
348
|
-
): void {
|
|
349
|
-
const db = getDb();
|
|
350
|
-
const now = new Date().toISOString();
|
|
351
|
-
const item = params.item;
|
|
352
|
-
|
|
353
|
-
// Skip user messages — they are not agent output
|
|
354
|
-
if (shouldSkipItem(item.type)) return;
|
|
355
|
-
|
|
356
|
-
// Skip reasoning items with empty content — app-server sends summary: [], content: []
|
|
357
|
-
// These have no displayable text and would render as empty cards
|
|
358
|
-
if ((item.type === 'reasoning' || item.type === 'agentReasoning') && isEmptyReasoning(item)) return;
|
|
359
|
-
|
|
360
|
-
const data = mapItemData(item);
|
|
361
|
-
const normalizedType = normalizeItemType(item.type);
|
|
362
|
-
|
|
363
|
-
// Try to update existing row
|
|
364
|
-
const result = db
|
|
365
|
-
.prepare('UPDATE items SET data = ?, status = ?, updated_at = ? WHERE external_item_id = ? AND turn_id = ?')
|
|
366
|
-
.run(JSON.stringify(data), status, now, item.id, turnId);
|
|
367
|
-
|
|
368
|
-
let itemId: string;
|
|
369
|
-
let createdAt: string;
|
|
370
|
-
|
|
371
|
-
if (result.changes === 0) {
|
|
372
|
-
// Item not in DB yet — insert
|
|
373
|
-
itemId = uuidv4();
|
|
374
|
-
createdAt = now;
|
|
375
|
-
db.prepare(
|
|
376
|
-
'INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
377
|
-
).run(itemId, turnId, item.id, normalizedType as Item['type'], JSON.stringify(data), status, now, now);
|
|
378
|
-
} else {
|
|
379
|
-
const row = db
|
|
380
|
-
.prepare('SELECT id, created_at FROM items WHERE external_item_id = ? AND turn_id = ?')
|
|
381
|
-
.get(item.id, turnId) as { id: string; created_at: string };
|
|
382
|
-
itemId = row.id;
|
|
383
|
-
createdAt = row.created_at;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Update turn-level fields on item completion
|
|
387
|
-
if (status === 'completed' || status === 'in_progress') {
|
|
388
|
-
if (item.type === 'agentMessage' || item.type === 'agent_message') {
|
|
389
|
-
db.prepare('UPDATE turns SET agent_response = ?, updated_at = ? WHERE id = ?').run(item.text, now, turnId);
|
|
390
|
-
}
|
|
391
|
-
if (item.type === 'reasoning' || item.type === 'agentReasoning') {
|
|
392
|
-
const summary = Array.isArray(item.summary) ? (item.summary as string[]).join('\n') : '';
|
|
393
|
-
const thoughts = summary || item.text || '';
|
|
394
|
-
if (thoughts) {
|
|
395
|
-
db.prepare('UPDATE turns SET thoughts = ?, updated_at = ? WHERE id = ?').run(thoughts, now, turnId);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const wsItem: Item = {
|
|
401
|
-
id: itemId,
|
|
402
|
-
turn_id: turnId,
|
|
403
|
-
external_item_id: item.id,
|
|
404
|
-
type: normalizedType as Item['type'],
|
|
405
|
-
data,
|
|
406
|
-
status,
|
|
407
|
-
created_at: createdAt,
|
|
408
|
-
updated_at: now,
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
broadcast(broadcastEvent, { sessionId, turnId, item: wsItem });
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/** Cancel a running turn by session ID. Returns true if a turn was cancelled. */
|
|
415
|
-
export async function interruptTurn(sessionId: string): Promise<boolean> {
|
|
416
|
-
const entry = sessionMap.get(sessionId);
|
|
417
|
-
if (!entry || !entry.turnId) return false;
|
|
418
|
-
|
|
419
|
-
try {
|
|
420
|
-
await entry.client.request('turn/interrupt', {
|
|
421
|
-
threadId: entry.threadId,
|
|
422
|
-
turnId: entry.turnId,
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// Update DB and broadcast — the app-server may not send a turn/failed notification
|
|
426
|
-
const db = getDb();
|
|
427
|
-
const now = new Date().toISOString();
|
|
428
|
-
db.prepare('UPDATE turns SET status = ?, updated_at = ? WHERE id = ?').run('aborted', now, entry.turnId);
|
|
429
|
-
setSessionStatus(db, sessionId, 0, 'active', now);
|
|
430
|
-
broadcast('turn:cancelled', { sessionId, turnId: entry.turnId });
|
|
431
|
-
|
|
432
|
-
// Clear turn ID so further notifications are ignored
|
|
433
|
-
entry.turnId = null;
|
|
434
|
-
|
|
435
|
-
return true;
|
|
436
|
-
} catch {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/** Remove a session's app-server client from the in-memory map. Used after rewind/branch. */
|
|
442
|
-
export function clearThread(sessionId: string): void {
|
|
443
|
-
const entry = sessionMap.get(sessionId);
|
|
444
|
-
if (entry) {
|
|
445
|
-
entry.client.close().catch(() => {
|
|
446
|
-
// Ignore close errors
|
|
447
|
-
});
|
|
448
|
-
sessionMap.delete(sessionId);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/** Clear all session entries. Used in test cleanup. */
|
|
453
|
-
export function clearAllThreads(): void {
|
|
454
|
-
for (const [, entry] of sessionMap) {
|
|
455
|
-
entry.client.close().catch(() => {});
|
|
456
|
-
}
|
|
457
|
-
sessionMap.clear();
|
|
458
|
-
titleGenerating.clear();
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// --- Title generation ---
|
|
462
|
-
|
|
463
|
-
/** Tracks sessions currently generating titles — prevents duplicate throwaway threads. */
|
|
464
|
-
const titleGenerating = new Set<string>();
|
|
465
|
-
|
|
466
|
-
/** Generate a title for the session using a throwaway app-server thread. */
|
|
467
|
-
function syncThreadTitle(sessionId: string): void {
|
|
468
|
-
const db = getDb();
|
|
469
|
-
const session = db.prepare('SELECT title FROM sessions WHERE id = ?').get(sessionId) as
|
|
470
|
-
| { title: string | null }
|
|
471
|
-
| undefined;
|
|
472
|
-
if (!session || session.title !== null) return;
|
|
473
|
-
if (titleGenerating.has(sessionId)) return;
|
|
474
|
-
|
|
475
|
-
const turn = db
|
|
476
|
-
.prepare('SELECT user_prompt, agent_response FROM turns WHERE session_id = ? ORDER BY created_at ASC LIMIT 1')
|
|
477
|
-
.get(sessionId) as { user_prompt: string; agent_response: string | null } | undefined;
|
|
478
|
-
if (!turn) return;
|
|
479
|
-
|
|
480
|
-
titleGenerating.add(sessionId);
|
|
481
|
-
generateTitleAsync(sessionId, turn.user_prompt, turn.agent_response).finally(() => {
|
|
482
|
-
titleGenerating.delete(sessionId);
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/** Create a throwaway app-server thread, ask for a title, update the session. */
|
|
487
|
-
async function generateTitleAsync(
|
|
488
|
-
sessionId: string,
|
|
489
|
-
userPrompt: string,
|
|
490
|
-
agentResponse: string | null,
|
|
491
|
-
): Promise<void> {
|
|
492
|
-
let client: AppServerClient | null = null;
|
|
493
|
-
try {
|
|
494
|
-
client = new AppServerClient({ cwd: process.cwd() });
|
|
495
|
-
await client.initialize();
|
|
496
|
-
|
|
497
|
-
const initResult = await client.request<ThreadStartResult>('thread/start', {
|
|
498
|
-
cwd: process.cwd(),
|
|
499
|
-
approvalPolicy: 'never',
|
|
500
|
-
sandbox: 'read-only',
|
|
501
|
-
});
|
|
502
|
-
const threadId = initResult.thread.id;
|
|
503
|
-
|
|
504
|
-
const truncatedPrompt = userPrompt.slice(0, 500);
|
|
505
|
-
const truncatedResponse = (agentResponse || '').slice(0, 500);
|
|
506
|
-
const titlePrompt = `Generate a concise 3-5 word title for this conversation. Reply with only the title, nothing else.\n\nUser asked: "${truncatedPrompt}"\n\nAgent responded: "${truncatedResponse}"`;
|
|
507
|
-
|
|
508
|
-
// Set up promise to capture the title response
|
|
509
|
-
let titleResolve!: (value: string) => void;
|
|
510
|
-
let titleReject!: (error: Error) => void;
|
|
511
|
-
const titlePromise = new Promise<string>((resolve, reject) => {
|
|
512
|
-
titleResolve = resolve;
|
|
513
|
-
titleReject = reject;
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
// Capture agent_message text from item/completed
|
|
517
|
-
let titleResponse = '';
|
|
518
|
-
client.onNotification('item/completed', (params: unknown) => {
|
|
519
|
-
const p = params as ItemNotification;
|
|
520
|
-
if (p.threadId !== threadId) return;
|
|
521
|
-
if ((p.item.type === 'agentMessage' || p.item.type === 'agent_message') && p.item.text) {
|
|
522
|
-
titleResponse = p.item.text;
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
// Resolve on turn/completed
|
|
527
|
-
client.onNotification('turn/completed', (params: unknown) => {
|
|
528
|
-
const p = params as { threadId: string };
|
|
529
|
-
if (p.threadId !== threadId) return;
|
|
530
|
-
titleResolve(titleResponse);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
// Reject on turn/failed
|
|
534
|
-
client.onNotification('turn/failed', (params: unknown) => {
|
|
535
|
-
const p = params as TurnFailedNotification;
|
|
536
|
-
if (p.threadId !== threadId) return;
|
|
537
|
-
titleReject(new Error(p.error.message));
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// Set a timeout (30s)
|
|
541
|
-
const timeout = setTimeout(() => {
|
|
542
|
-
titleReject(new Error('Title generation timed out'));
|
|
543
|
-
}, 30_000);
|
|
544
|
-
|
|
545
|
-
// Send turn/start — events arrive via notifications
|
|
546
|
-
await client.request<TurnStartResult>('turn/start', {
|
|
547
|
-
threadId,
|
|
548
|
-
input: [{ type: 'text', text: titlePrompt }],
|
|
549
|
-
approvalPolicy: 'never',
|
|
550
|
-
sandbox: { type: 'read-only' },
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
const title = await titlePromise;
|
|
554
|
-
clearTimeout(timeout);
|
|
555
|
-
|
|
556
|
-
const cleanTitle = title.trim().replace(/^["']|["']$/g, '').slice(0, 100);
|
|
557
|
-
|
|
558
|
-
if (cleanTitle) {
|
|
559
|
-
const db = getDb();
|
|
560
|
-
const now = new Date().toISOString();
|
|
561
|
-
db.prepare('UPDATE sessions SET title = ?, updated_at = ? WHERE id = ?').run(cleanTitle, now, sessionId);
|
|
562
|
-
broadcast('session:title', { sessionId, title: cleanTitle });
|
|
563
|
-
}
|
|
564
|
-
} catch {
|
|
565
|
-
// Silently skip on error — session keeps null title
|
|
566
|
-
} finally {
|
|
567
|
-
if (client) {
|
|
568
|
-
await client.close().catch(() => {});
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// --- Provider interface ---
|
|
574
|
-
|
|
575
|
-
/** Map SDK effort values to UI labels. */
|
|
576
|
-
const EFFORT_LABELS: Record<string, string> = {
|
|
577
|
-
minimal: 'Minimal',
|
|
578
|
-
low: 'Low',
|
|
579
|
-
medium: 'Medium',
|
|
580
|
-
high: 'High',
|
|
581
|
-
xhigh: 'Extra High',
|
|
582
|
-
max: 'Max',
|
|
583
|
-
ultra: 'Ultra',
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
/** Fetch available models from the shared app-server and map to ModelInfo[]. */
|
|
587
|
-
async function getModels(): Promise<ModelInfo[]> {
|
|
588
|
-
try {
|
|
589
|
-
const result = await getSharedAppServer().request<ModelListResult>('model/list', {});
|
|
590
|
-
return (result.data ?? []).map((m) => ({
|
|
591
|
-
slug: m.id,
|
|
592
|
-
displayName: m.displayName,
|
|
593
|
-
description: m.description,
|
|
594
|
-
defaultReasoning: m.defaultReasoningEffort,
|
|
595
|
-
reasoningLevels: (m.supportedReasoningEfforts ?? []).map((r) => ({
|
|
596
|
-
effort: r.reasoningEffort,
|
|
597
|
-
label: EFFORT_LABELS[r.reasoningEffort] ?? r.reasoningEffort,
|
|
598
|
-
})),
|
|
599
|
-
}));
|
|
600
|
-
} catch {
|
|
601
|
-
return [];
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/** Graceful shutdown — close shared metadata process and all per-session clients. */
|
|
606
|
-
async function shutdown(): Promise<void> {
|
|
607
|
-
await closeSharedAppServer();
|
|
608
|
-
clearAllThreads();
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/** Codex provider — implements RuntimeProvider interface. */
|
|
612
|
-
export const codexProvider: RuntimeProvider = {
|
|
613
|
-
startTurn,
|
|
614
|
-
interruptTurn,
|
|
615
|
-
clearThread,
|
|
616
|
-
clearAllThreads,
|
|
617
|
-
getModels,
|
|
618
|
-
shutdown,
|
|
619
|
-
};
|