repoburg 1.3.188 → 1.3.196
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/.prettierignore +5 -0
- package/agent-pane/.prettierrc +8 -0
- package/agent-pane/backend/coverage/base.css +224 -0
- package/agent-pane/backend/coverage/block-navigation.js +87 -0
- package/agent-pane/backend/coverage/clover.xml +887 -0
- package/agent-pane/backend/coverage/coverage-final.json +10 -0
- package/agent-pane/backend/coverage/favicon.png +0 -0
- package/agent-pane/backend/coverage/index.html +176 -0
- package/agent-pane/backend/coverage/prettify.css +1 -0
- package/agent-pane/backend/coverage/prettify.js +2 -0
- package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/backend/coverage/sorter.js +210 -0
- package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +1402 -0
- package/agent-pane/backend/coverage/src/codex/index.html +131 -0
- package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +331 -0
- package/agent-pane/backend/coverage/src/db/index.html +131 -0
- package/agent-pane/backend/coverage/src/db/index.ts.html +436 -0
- package/agent-pane/backend/coverage/src/db/schema.ts.html +175 -0
- package/agent-pane/backend/coverage/src/index.html +116 -0
- package/agent-pane/backend/coverage/src/index.ts.html +262 -0
- package/agent-pane/backend/coverage/src/routes/index.html +146 -0
- package/agent-pane/backend/coverage/src/routes/sessions.ts.html +991 -0
- package/agent-pane/backend/coverage/src/routes/turns.ts.html +256 -0
- package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +406 -0
- package/agent-pane/backend/coverage/src/ws/index.html +116 -0
- package/agent-pane/backend/coverage/src/ws/index.ts.html +238 -0
- 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/dist/index.js +70869 -0
- package/agent-pane/backend/package-lock.json +4529 -1013
- package/agent-pane/backend/package.json +10 -6
- package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +163 -0
- package/agent-pane/backend/src/claude/claude-message-mapper.ts +154 -0
- package/agent-pane/backend/src/claude/claude-provider.test.ts +65 -0
- package/agent-pane/backend/src/claude/claude-provider.ts +482 -0
- package/agent-pane/backend/src/claude/claude-types.ts +33 -0
- package/agent-pane/backend/src/codex/app-server-client.test.ts +183 -0
- package/agent-pane/backend/src/codex/app-server-client.ts +225 -0
- package/agent-pane/backend/src/codex/app-server-types.ts +259 -0
- package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +56 -0
- package/agent-pane/backend/src/codex/codex-provider.test.ts +60 -0
- package/agent-pane/backend/src/codex/codex-provider.ts +521 -265
- package/agent-pane/backend/src/codex/item-mapper.test.ts +221 -0
- package/agent-pane/backend/src/codex/item-mapper.ts +35 -8
- package/agent-pane/backend/src/codex/shared-app-server.ts +25 -0
- package/agent-pane/backend/src/db/index.test.ts +125 -0
- package/agent-pane/backend/src/db/index.ts +39 -8
- package/agent-pane/backend/src/db/schema.ts +28 -74
- package/agent-pane/backend/src/index.ts +29 -2
- package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +29 -0
- package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +40 -0
- package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +16 -0
- package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +60 -0
- package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +34 -0
- package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +85 -0
- package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +48 -0
- package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +35 -0
- package/agent-pane/backend/src/integration/delta-streaming.test.ts +130 -0
- package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +272 -0
- package/agent-pane/backend/src/integration/helpers/test-app.ts +108 -0
- package/agent-pane/backend/src/integration/helpers/ws-capture.ts +64 -0
- package/agent-pane/backend/src/integration/item-lifecycle.test.ts +133 -0
- package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +102 -0
- package/agent-pane/backend/src/integration/missing-item-started.test.ts +91 -0
- package/agent-pane/backend/src/integration/multi-turn.test.ts +121 -0
- package/agent-pane/backend/src/integration/session-operations.test.ts +168 -0
- package/agent-pane/backend/src/integration/title-generation.test.ts +109 -0
- package/agent-pane/backend/src/integration/turn-cancel.test.ts +111 -0
- package/agent-pane/backend/src/integration/turn-failure.test.ts +97 -0
- package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +141 -0
- package/agent-pane/backend/src/providers/index.ts +14 -0
- package/agent-pane/backend/src/providers/registry.test.ts +92 -0
- package/agent-pane/backend/src/providers/registry.ts +43 -0
- package/agent-pane/backend/src/providers/runtime-provider.ts +25 -0
- package/agent-pane/backend/src/routes/files.ts +31 -0
- package/agent-pane/backend/src/routes/mcp.ts +33 -0
- package/agent-pane/backend/src/routes/models.test.ts +92 -0
- package/agent-pane/backend/src/routes/models.ts +16 -0
- package/agent-pane/backend/src/routes/plugins.ts +40 -0
- package/agent-pane/backend/src/routes/providers.test.ts +69 -0
- package/agent-pane/backend/src/routes/providers.ts +57 -0
- package/agent-pane/backend/src/routes/sessions.test.ts +424 -0
- package/agent-pane/backend/src/routes/sessions.ts +295 -42
- package/agent-pane/backend/src/routes/skills.test.ts +114 -0
- package/agent-pane/backend/src/routes/skills.ts +70 -0
- package/agent-pane/backend/src/routes/turns.test.ts +152 -0
- package/agent-pane/backend/src/routes/turns.ts +36 -16
- package/agent-pane/backend/src/routes/workspaces.test.ts +197 -0
- package/agent-pane/backend/src/routes/workspaces.ts +73 -55
- package/agent-pane/backend/src/ws/index.test.ts +107 -0
- package/agent-pane/backend/src/ws/index.ts +19 -11
- package/agent-pane/backend/tsconfig.json +4 -2
- package/agent-pane/backend/vitest.config.ts +20 -0
- package/agent-pane/eslint.config.js +33 -0
- package/agent-pane/frontend/coverage/base.css +224 -0
- package/agent-pane/frontend/coverage/block-navigation.js +87 -0
- package/agent-pane/frontend/coverage/clover.xml +2962 -0
- package/agent-pane/frontend/coverage/coverage-final.json +37 -0
- package/agent-pane/frontend/coverage/favicon.png +0 -0
- package/agent-pane/frontend/coverage/index.html +251 -0
- package/agent-pane/frontend/coverage/prettify.css +1 -0
- package/agent-pane/frontend/coverage/prettify.js +2 -0
- package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/frontend/coverage/sorter.js +210 -0
- package/agent-pane/frontend/coverage/src/App.tsx.html +217 -0
- package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +223 -0
- package/agent-pane/frontend/coverage/src/api/client.ts.html +187 -0
- package/agent-pane/frontend/coverage/src/api/index.html +161 -0
- package/agent-pane/frontend/coverage/src/api/sessions.ts.html +316 -0
- package/agent-pane/frontend/coverage/src/api/websocket.ts.html +544 -0
- package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +199 -0
- package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +226 -0
- package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +382 -0
- package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +715 -0
- package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +160 -0
- package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +478 -0
- package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +472 -0
- package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +574 -0
- package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +205 -0
- package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +133 -0
- package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +217 -0
- package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +271 -0
- package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +109 -0
- package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +313 -0
- package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +1216 -0
- package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +1138 -0
- package/agent-pane/frontend/coverage/src/components/index.html +326 -0
- package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +247 -0
- package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +160 -0
- package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +427 -0
- package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +397 -0
- package/agent-pane/frontend/coverage/src/components/panels/index.html +161 -0
- package/agent-pane/frontend/coverage/src/constants/index.html +116 -0
- package/agent-pane/frontend/coverage/src/constants/models.ts.html +406 -0
- package/agent-pane/frontend/coverage/src/hooks/index.html +146 -0
- package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +124 -0
- package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +142 -0
- package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +187 -0
- package/agent-pane/frontend/coverage/src/index.html +146 -0
- package/agent-pane/frontend/coverage/src/main.tsx.html +115 -0
- package/agent-pane/frontend/coverage/src/store/index.html +116 -0
- package/agent-pane/frontend/coverage/src/store/store.ts.html +2404 -0
- package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +190 -0
- package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +367 -0
- package/agent-pane/frontend/coverage/src/test/index.html +131 -0
- package/agent-pane/frontend/coverage/src/types/index.html +116 -0
- package/agent-pane/frontend/coverage/src/types/index.ts.html +466 -0
- package/agent-pane/frontend/coverage/src/utils/changes.ts.html +202 -0
- package/agent-pane/frontend/coverage/src/utils/duration.ts.html +127 -0
- package/agent-pane/frontend/coverage/src/utils/index.html +131 -0
- package/agent-pane/frontend/dist/assets/index-Bg0PF2aV.css +1 -0
- package/agent-pane/frontend/dist/assets/index-BlybeX5e.js +281 -0
- package/agent-pane/frontend/dist/index.html +19 -0
- package/agent-pane/frontend/package-lock.json +2434 -213
- package/agent-pane/frontend/package.json +10 -3
- package/agent-pane/frontend/src/App.test.tsx +74 -0
- package/agent-pane/frontend/src/App.tsx +1 -1
- package/agent-pane/frontend/src/AppInitializer.test.tsx +142 -0
- package/agent-pane/frontend/src/AppInitializer.tsx +1 -1
- package/agent-pane/frontend/src/api/client.test.ts +126 -0
- package/agent-pane/frontend/src/api/client.ts +22 -29
- package/agent-pane/frontend/src/api/models.ts +7 -0
- package/agent-pane/frontend/src/api/providers.ts +12 -0
- package/agent-pane/frontend/src/api/sessions.test.ts +241 -0
- package/agent-pane/frontend/src/api/sessions.ts +43 -1
- package/agent-pane/frontend/src/api/skills.ts +12 -0
- package/agent-pane/frontend/src/api/websocket.test.ts +288 -0
- package/agent-pane/frontend/src/api/websocket.ts +27 -2
- package/agent-pane/frontend/src/api/workspaces.test.ts +112 -0
- package/agent-pane/frontend/src/api/workspaces.ts +17 -3
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +49 -0
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +2 -5
- package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +133 -0
- package/agent-pane/frontend/src/components/CommandInputBar.tsx +296 -17
- package/agent-pane/frontend/src/components/CommandPalette.test.tsx +230 -0
- package/agent-pane/frontend/src/components/CommandPalette.tsx +26 -23
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +1 -1
- package/agent-pane/frontend/src/components/ModelSelector.test.tsx +129 -0
- package/agent-pane/frontend/src/components/ModelSelector.tsx +191 -0
- package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +95 -0
- package/agent-pane/frontend/src/components/NewSessionDialog.tsx +58 -13
- package/agent-pane/frontend/src/components/RenderArea.test.tsx +160 -0
- package/agent-pane/frontend/src/components/RenderArea.tsx +18 -25
- package/agent-pane/frontend/src/components/RightPanel.test.tsx +43 -0
- package/agent-pane/frontend/src/components/RightPanel.tsx +1 -1
- package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +32 -0
- package/agent-pane/frontend/src/components/RuntimeIcon.tsx +1 -1
- package/agent-pane/frontend/src/components/SessionTabs.test.tsx +72 -0
- package/agent-pane/frontend/src/components/SessionTabs.tsx +12 -12
- package/agent-pane/frontend/src/components/StatusBar.test.tsx +56 -0
- package/agent-pane/frontend/src/components/StatusBar.tsx +25 -31
- package/agent-pane/frontend/src/components/StatusDot.test.tsx +25 -0
- package/agent-pane/frontend/src/components/StatusDot.tsx +2 -7
- package/agent-pane/frontend/src/components/Toast.test.tsx +79 -0
- package/agent-pane/frontend/src/components/Toast.tsx +2 -6
- package/agent-pane/frontend/src/components/TurnContent.test.tsx +287 -0
- package/agent-pane/frontend/src/components/TurnContent.tsx +107 -24
- package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +297 -0
- package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +33 -32
- package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +32 -0
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +63 -0
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +78 -0
- package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +96 -0
- package/agent-pane/frontend/src/components/input/SlashPopup.tsx +63 -0
- package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +61 -0
- package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +12 -39
- package/agent-pane/frontend/src/components/panels/LogsPanel.test.tsx +58 -0
- package/agent-pane/frontend/src/components/panels/LogsPanel.tsx +1 -1
- package/agent-pane/frontend/src/components/panels/MetricsPanel.test.tsx +71 -0
- package/agent-pane/frontend/src/components/panels/MetricsPanel.tsx +63 -31
- package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +83 -0
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +66 -7
- package/agent-pane/frontend/src/constants/models.test.ts +97 -0
- package/agent-pane/frontend/src/constants/models.ts +129 -0
- package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +42 -0
- package/agent-pane/frontend/src/hooks/useEscapeKey.ts +13 -0
- package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +92 -0
- package/agent-pane/frontend/src/hooks/useOutsideClick.ts +19 -0
- package/agent-pane/frontend/src/hooks/useProvider.ts +44 -0
- package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +114 -0
- package/agent-pane/frontend/src/hooks/useSessionStatus.ts +34 -0
- package/agent-pane/frontend/src/main.test.tsx +37 -0
- package/agent-pane/frontend/src/main.tsx +1 -1
- package/agent-pane/frontend/src/store/sessionSlice.ts +417 -0
- package/agent-pane/frontend/src/store/store.test.ts +1284 -0
- package/agent-pane/frontend/src/store/store.ts +16 -617
- package/agent-pane/frontend/src/store/uiSlice.ts +83 -0
- package/agent-pane/frontend/src/store/workspaceSlice.ts +77 -0
- package/agent-pane/frontend/src/store/wsSlice.ts +292 -0
- package/agent-pane/frontend/src/styles/app.css +113 -7
- package/agent-pane/frontend/src/test/component-helpers.ts +36 -0
- package/agent-pane/frontend/src/test/fixtures.ts +96 -0
- package/agent-pane/frontend/src/test-setup.ts +5 -0
- package/agent-pane/frontend/src/types/index.test.ts +128 -0
- package/agent-pane/frontend/src/types/index.ts +80 -104
- package/agent-pane/frontend/src/utils/changes.test.ts +81 -0
- package/agent-pane/frontend/src/utils/changes.ts +39 -0
- package/agent-pane/frontend/src/utils/duration.test.ts +71 -0
- package/agent-pane/frontend/src/utils/duration.ts +14 -0
- package/agent-pane/frontend/tsconfig.json +4 -1
- package/agent-pane/frontend/vite.config.ts +6 -0
- package/agent-pane/frontend/vitest.config.ts +29 -0
- package/agent-pane/package-lock.json +1527 -0
- package/agent-pane/package.json +19 -0
- package/agent-pane/shared/provider-types.ts +53 -0
- package/agent-pane/shared/types.ts +107 -0
- package/agentpane-branch-session.png +0 -0
- package/agentpane-expanded-all.png +0 -0
- package/agentpane-fixed-rendering.png +0 -0
- package/agentpane-focus-check.png +0 -0
- package/agentpane-initial.png +0 -0
- package/agentpane-mcp-detail.png +0 -0
- package/agentpane-no-focus-ring.png +0 -0
- package/agentpane-soft-focus.png +0 -0
- package/backend/dist/src/llm-provider/ollama-llm.provider.js +1 -0
- package/backend/dist/src/llm-provider/ollama-llm.provider.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/data.db +0 -0
- package/empty-state.png +0 -0
- package/frontend-home.png +0 -0
- package/model-selector-open.png +0 -0
- package/package.json +1 -1
- package/slash-popup-working.png +0 -0
- package/agent-pane/frontend/src/components/DiffViewer.tsx +0 -27
|
@@ -0,0 +1,221 @@
|
|
|
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,14 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AppServerItem } from './app-server-types.ts';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
|
|
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> {
|
|
5
13
|
switch (item.type) {
|
|
14
|
+
case 'agentMessage':
|
|
6
15
|
case 'agent_message':
|
|
7
16
|
return { text: item.text };
|
|
8
17
|
|
|
9
18
|
case 'reasoning':
|
|
10
|
-
|
|
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
|
+
}
|
|
11
24
|
|
|
25
|
+
case 'commandExecution':
|
|
12
26
|
case 'command_execution':
|
|
13
27
|
return {
|
|
14
28
|
command: item.command,
|
|
@@ -17,12 +31,14 @@ export function mapItemData(item: ThreadItem): Record<string, unknown> {
|
|
|
17
31
|
status: item.status,
|
|
18
32
|
};
|
|
19
33
|
|
|
34
|
+
case 'fileChange':
|
|
20
35
|
case 'file_change':
|
|
21
36
|
return {
|
|
22
37
|
changes: item.changes,
|
|
23
38
|
status: item.status,
|
|
24
39
|
};
|
|
25
40
|
|
|
41
|
+
case 'mcpToolCall':
|
|
26
42
|
case 'mcp_tool_call':
|
|
27
43
|
return {
|
|
28
44
|
server: item.server,
|
|
@@ -33,9 +49,11 @@ export function mapItemData(item: ThreadItem): Record<string, unknown> {
|
|
|
33
49
|
status: item.status,
|
|
34
50
|
};
|
|
35
51
|
|
|
52
|
+
case 'webSearch':
|
|
36
53
|
case 'web_search':
|
|
37
54
|
return { query: item.query };
|
|
38
55
|
|
|
56
|
+
case 'todoList':
|
|
39
57
|
case 'todo_list':
|
|
40
58
|
return { items: item.items };
|
|
41
59
|
|
|
@@ -47,10 +65,19 @@ export function mapItemData(item: ThreadItem): Record<string, unknown> {
|
|
|
47
65
|
}
|
|
48
66
|
}
|
|
49
67
|
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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';
|
|
54
81
|
}
|
|
55
82
|
if (item.type === 'error') {
|
|
56
83
|
return 'failed';
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
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,9 +1,17 @@
|
|
|
1
1
|
import Database from 'better-sqlite3';
|
|
2
|
-
import type { Database as DB } from 'better-sqlite3';
|
|
3
2
|
|
|
4
|
-
let db:
|
|
3
|
+
let db: Database.Database;
|
|
5
4
|
|
|
6
|
-
|
|
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 {
|
|
7
15
|
db = new Database(path);
|
|
8
16
|
db.pragma('journal_mode = WAL');
|
|
9
17
|
db.pragma('foreign_keys = ON');
|
|
@@ -12,14 +20,29 @@ export function initDb(path: string = 'data.db'): DB {
|
|
|
12
20
|
return db;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Get the initialised database instance.
|
|
25
|
+
*
|
|
26
|
+
* @throws Error if `initDb()` has not been called yet.
|
|
27
|
+
* @returns The singleton `Database` instance.
|
|
28
|
+
*/
|
|
29
|
+
export function getDb(): Database.Database {
|
|
16
30
|
if (!db) {
|
|
17
31
|
throw new Error('Database not initialized. Call initDb() first.');
|
|
18
32
|
}
|
|
19
33
|
return db;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Create all tables and run inline migrations for new columns.
|
|
38
|
+
*
|
|
39
|
+
* Tables: `sessions`, `turns`, `items`, `workspaces`.
|
|
40
|
+
* Migrations: `deleted` (workspaces), `lifecycle` + `has_unreviewed` +
|
|
41
|
+
* `model_reasoning_effort` (sessions) — each guarded by PRAGMA table_info check.
|
|
42
|
+
*
|
|
43
|
+
* @param database — The DB instance to create tables in.
|
|
44
|
+
*/
|
|
45
|
+
function createTables(database: Database.Database): void {
|
|
23
46
|
database.exec(`
|
|
24
47
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
25
48
|
id TEXT PRIMARY KEY,
|
|
@@ -75,17 +98,25 @@ function createTables(database: DB): void {
|
|
|
75
98
|
`);
|
|
76
99
|
|
|
77
100
|
// Migration: add 'deleted' column to existing workspaces table if missing
|
|
78
|
-
const wsColumns = database.prepare(
|
|
101
|
+
const wsColumns = database.prepare('PRAGMA table_info(workspaces)').all() as { name: string }[];
|
|
79
102
|
if (!wsColumns.some((c) => c.name === 'deleted')) {
|
|
80
103
|
database.exec('ALTER TABLE workspaces ADD COLUMN deleted INTEGER NOT NULL DEFAULT 0');
|
|
81
104
|
}
|
|
82
105
|
|
|
83
106
|
// Migration: add 'lifecycle' + 'has_unreviewed' columns to existing sessions table
|
|
84
|
-
const sessColumns = database.prepare(
|
|
107
|
+
const sessColumns = database.prepare('PRAGMA table_info(sessions)').all() as { name: string }[];
|
|
85
108
|
if (!sessColumns.some((c) => c.name === 'lifecycle')) {
|
|
86
109
|
database.exec("ALTER TABLE sessions ADD COLUMN lifecycle TEXT NOT NULL DEFAULT 'working'");
|
|
87
110
|
}
|
|
88
111
|
if (!sessColumns.some((c) => c.name === 'has_unreviewed')) {
|
|
89
112
|
database.exec('ALTER TABLE sessions ADD COLUMN has_unreviewed INTEGER NOT NULL DEFAULT 0');
|
|
90
113
|
}
|
|
91
|
-
|
|
114
|
+
if (!sessColumns.some((c) => c.name === 'model_reasoning_effort')) {
|
|
115
|
+
database.exec('ALTER TABLE sessions ADD COLUMN model_reasoning_effort TEXT');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Migration: add 'runtime_config' column to existing sessions table
|
|
119
|
+
if (!sessColumns.some((c) => c.name === 'runtime_config')) {
|
|
120
|
+
database.exec('ALTER TABLE sessions ADD COLUMN runtime_config TEXT');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -1,76 +1,30 @@
|
|
|
1
|
-
// Database schema — TypeScript interfaces
|
|
1
|
+
// Database schema — TypeScript interfaces.
|
|
2
|
+
// Core types are imported from @agentpane/shared and re-exported.
|
|
3
|
+
// This file adds DB-specific aliases (TurnBase = Turn without items).
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
import type {
|
|
6
|
+
SessionStatus,
|
|
7
|
+
TurnStatus,
|
|
8
|
+
ItemType,
|
|
9
|
+
ItemStatus,
|
|
10
|
+
Session,
|
|
11
|
+
Turn,
|
|
12
|
+
TokenUsage,
|
|
13
|
+
Item,
|
|
14
|
+
Workspace,
|
|
15
|
+
SessionDetail,
|
|
16
|
+
} from '@agentpane/shared';
|
|
15
17
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface TokenUsage {
|
|
32
|
-
input_tokens: number;
|
|
33
|
-
cached_input_tokens: number;
|
|
34
|
-
cache_write_input_tokens: number;
|
|
35
|
-
output_tokens: number;
|
|
36
|
-
reasoning_output_tokens: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface Turn {
|
|
40
|
-
id: string;
|
|
41
|
-
session_id: string;
|
|
42
|
-
user_prompt: string;
|
|
43
|
-
agent_response: string | null;
|
|
44
|
-
thoughts: string | null;
|
|
45
|
-
token_usage: TokenUsage | null;
|
|
46
|
-
external_turn_id: string | null;
|
|
47
|
-
status: TurnStatus;
|
|
48
|
-
error: string | null;
|
|
49
|
-
created_at: string;
|
|
50
|
-
updated_at: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface Item {
|
|
54
|
-
id: string;
|
|
55
|
-
turn_id: string;
|
|
56
|
-
external_item_id: string | null;
|
|
57
|
-
type: ItemType;
|
|
58
|
-
data: Record<string, unknown> | null;
|
|
59
|
-
status: ItemStatus;
|
|
60
|
-
created_at: string;
|
|
61
|
-
updated_at: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Workspaces — directory paths for grouping sessions in sidebar
|
|
65
|
-
export interface Workspace {
|
|
66
|
-
id: string;
|
|
67
|
-
path: string; // directory path, e.g. "/Users/me/projects/my-app"
|
|
68
|
-
label: string | null; // optional custom label, null = use basename
|
|
69
|
-
deleted: number; // 0 = active, 1 = soft-deleted (hidden from sidebar)
|
|
70
|
-
created_at: string; // ISO
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Nested session detail for GET /api/sessions/:id
|
|
74
|
-
export interface SessionDetail extends Session {
|
|
75
|
-
turns: (Turn & { items: Item[] })[];
|
|
76
|
-
}
|
|
18
|
+
// Re-export shared types for backward compatibility with existing imports.
|
|
19
|
+
export type {
|
|
20
|
+
SessionStatus,
|
|
21
|
+
TurnStatus,
|
|
22
|
+
ItemType,
|
|
23
|
+
ItemStatus,
|
|
24
|
+
Session,
|
|
25
|
+
Turn,
|
|
26
|
+
TokenUsage,
|
|
27
|
+
Item,
|
|
28
|
+
Workspace,
|
|
29
|
+
SessionDetail,
|
|
30
|
+
};
|