repoburg 1.3.202 → 1.3.209
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 +2103 -32003
- package/agent-pane/backend/dist/server.js +45313 -0
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +6 -6
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +1 -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/index.js +28 -8
- package/daemon/package.json +1 -1
- package/model-selector-scroll.png +0 -0
- package/package.json +10 -2
- 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 -236
- 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 -49
- package/agent-pane/backend/src/repoburg/action-mapping.test.ts +0 -122
- package/agent-pane/backend/src/repoburg/action-mapping.ts +0 -294
- package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +0 -285
- package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +0 -356
- package/agent-pane/backend/src/repoburg/backend-resolver.ts +0 -261
- package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +0 -180
- package/agent-pane/backend/src/repoburg/repoburg-client.ts +0 -194
- package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +0 -780
- package/agent-pane/backend/src/repoburg/repoburg-provider.ts +0 -471
- package/agent-pane/backend/src/repoburg/turn-projector.test.ts +0 -621
- package/agent-pane/backend/src/repoburg/turn-projector.ts +0 -637
- 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 -772
- package/agent-pane/backend/src/routes/sessions.ts +0 -565
- 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-CJxD4YmJ.js +0 -370
- package/agent-pane/frontend/dist/assets/index-r-xwfOKQ.css +0 -1
- 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 -246
- 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 -240
- 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/AskUserItem.test.tsx +0 -143
- package/agent-pane/frontend/src/components/AskUserItem.tsx +0 -207
- 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 -377
- package/agent-pane/frontend/src/components/TurnContent.tsx +0 -594
- 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 -131
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +0 -131
- 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 -1338
- 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 -368
- package/agent-pane/frontend/src/styles/app.css +0 -627
- 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 -101
- 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 -134
- 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 -76
- 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 -184
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared mapping helpers for the repoburg provider: repoburg AIAction →
|
|
3
|
-
* agent-pane item shapes, DB item helpers, and usage mapping.
|
|
4
|
-
* Used by both the provider (turn orchestration) and the turn projector
|
|
5
|
-
* (message-stream projection).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
-
import type Database from 'better-sqlite3';
|
|
10
|
-
import { broadcast } from '../ws/index.ts';
|
|
11
|
-
import type { Item, ItemStatus } from '../db/schema.ts';
|
|
12
|
-
import type { AskUserSelectionGroup, AskUserItemData } from '@agentpane/shared';
|
|
13
|
-
import type { RepoburgAction } from './repoburg-client.ts';
|
|
14
|
-
|
|
15
|
-
/** Safely parse a JSON string field from an action row. */
|
|
16
|
-
export function parseJsonArgs(raw: string | null | undefined): Record<string, unknown> | null {
|
|
17
|
-
if (!raw) return null;
|
|
18
|
-
try {
|
|
19
|
-
const parsed = JSON.parse(raw);
|
|
20
|
-
return typeof parsed === 'object' && parsed !== null ? (parsed as Record<string, unknown>) : null;
|
|
21
|
-
} catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Parse a raw selections JSON string into validated groups (platform parity:
|
|
27
|
-
* ActionItemContent.parseSelectionGroups). Never throws; flat-string arrays
|
|
28
|
-
* coerce into single-option groups; invalid entries are dropped. */
|
|
29
|
-
export function parseSelectionGroups(raw: string | null | undefined): AskUserSelectionGroup[] {
|
|
30
|
-
if (!raw) return [];
|
|
31
|
-
let parsed: unknown;
|
|
32
|
-
try {
|
|
33
|
-
parsed = JSON.parse(raw);
|
|
34
|
-
} catch {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
if (!Array.isArray(parsed)) return [];
|
|
38
|
-
return parsed
|
|
39
|
-
.map((item): AskUserSelectionGroup | null => {
|
|
40
|
-
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
41
|
-
const obj = item as Record<string, unknown>;
|
|
42
|
-
if (Array.isArray(obj.selections)) {
|
|
43
|
-
const opts = obj.selections.filter((s): s is string => typeof s === 'string');
|
|
44
|
-
if (opts.length > 0) {
|
|
45
|
-
return {
|
|
46
|
-
question: typeof obj.question === 'string' ? obj.question : '',
|
|
47
|
-
selections: opts,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
// Graceful coercion: flat string → single-option group.
|
|
54
|
-
if (typeof item === 'string') {
|
|
55
|
-
return { question: '', selections: [item] };
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
})
|
|
59
|
-
.filter((g): g is AskUserSelectionGroup => g !== null);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Map a repoburg AIAction (+ its first execution log) to an agent-pane item
|
|
63
|
-
* shape. Returns null for actions that carry no displayable content
|
|
64
|
-
* (final/html_final — their text is part of the LLM response). */
|
|
65
|
-
export function mapActionToItem(
|
|
66
|
-
action: RepoburgAction,
|
|
67
|
-
): { type: Item['type']; data: Record<string, unknown>; status: ItemStatus } | null {
|
|
68
|
-
const failed = action.status === 'EXECUTION_FAILED';
|
|
69
|
-
const status: ItemStatus = failed ? 'failed' : 'completed';
|
|
70
|
-
const log = action.executionLogs?.[0];
|
|
71
|
-
const output = log?.output ?? '';
|
|
72
|
-
const errorMsg = log?.error_message ?? '';
|
|
73
|
-
|
|
74
|
-
switch (action.action_type) {
|
|
75
|
-
case 'create_file':
|
|
76
|
-
case 'overwrite_file':
|
|
77
|
-
case 'patch':
|
|
78
|
-
case 'quick_edit':
|
|
79
|
-
case 'apply_diff':
|
|
80
|
-
case 'write_todo':
|
|
81
|
-
case 'delete_file': {
|
|
82
|
-
const kind =
|
|
83
|
-
action.action_type === 'create_file'
|
|
84
|
-
? 'add'
|
|
85
|
-
: action.action_type === 'delete_file'
|
|
86
|
-
? 'delete'
|
|
87
|
-
: 'modify';
|
|
88
|
-
return {
|
|
89
|
-
type: 'file_change',
|
|
90
|
-
data: { changes: [{ path: action.file_path ?? '', kind }], status },
|
|
91
|
-
status,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case 'run_command':
|
|
96
|
-
case 'execute_code':
|
|
97
|
-
return {
|
|
98
|
-
type: 'command_execution',
|
|
99
|
-
data: {
|
|
100
|
-
command: action.command_string ?? action.action_type,
|
|
101
|
-
aggregated_output: output,
|
|
102
|
-
exit_code: failed ? 1 : 0,
|
|
103
|
-
status,
|
|
104
|
-
},
|
|
105
|
-
status,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
case 'invoke_subagent': {
|
|
109
|
-
// background_task completed form — Claude-provider data shape. Serves
|
|
110
|
-
// snapshot reconcile + reload; the live projector finalizes the same
|
|
111
|
-
// card through the identical external id `<inputId>-action-<actionId>`.
|
|
112
|
-
const args = parseJsonArgs(action.arguments);
|
|
113
|
-
const agentName = (args?.agent_name as string) ?? (args?.agentName as string) ?? 'Sub-agent';
|
|
114
|
-
const prompt = (args?.prompt as string) ?? '';
|
|
115
|
-
return {
|
|
116
|
-
type: 'background_task',
|
|
117
|
-
data: {
|
|
118
|
-
task_id: (args?.childSessionId as string) ?? '',
|
|
119
|
-
description: prompt || agentName,
|
|
120
|
-
task_type: 'subagent',
|
|
121
|
-
subagent_type: agentName,
|
|
122
|
-
prompt: prompt || null,
|
|
123
|
-
status: failed ? 'failed' : 'completed',
|
|
124
|
-
summary: output || (failed ? errorMsg || 'Sub-agent failed' : ''),
|
|
125
|
-
output_file: null,
|
|
126
|
-
output: '',
|
|
127
|
-
token_count: null,
|
|
128
|
-
last_tool_name: null,
|
|
129
|
-
},
|
|
130
|
-
status,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
case 'web_search': {
|
|
135
|
-
const args = parseJsonArgs(action.arguments);
|
|
136
|
-
return { type: 'web_search', data: { query: (args?.query as string) ?? '' }, status };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
case 'ask_user': {
|
|
140
|
-
// Rendered as clickable selection buttons in the frontend.
|
|
141
|
-
// Malformed payload → fallback plain-text question card.
|
|
142
|
-
const groups = parseSelectionGroups(action.selections);
|
|
143
|
-
const data: AskUserItemData = {
|
|
144
|
-
question: groups.length ? '' : (action.selections ?? ''),
|
|
145
|
-
groups,
|
|
146
|
-
};
|
|
147
|
-
return {
|
|
148
|
-
type: 'ask_user',
|
|
149
|
-
data: { question: data.question, groups: data.groups },
|
|
150
|
-
status,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
case 'final':
|
|
155
|
-
case 'html_final':
|
|
156
|
-
// Their text is part of the LLM response — no separate item.
|
|
157
|
-
return null;
|
|
158
|
-
|
|
159
|
-
default: {
|
|
160
|
-
// MCP tools (serverName__toolName) and remaining built-ins → generic tool call.
|
|
161
|
-
const isMcp = !!(action.server_name && action.tool_name);
|
|
162
|
-
return {
|
|
163
|
-
type: 'mcp_tool_call',
|
|
164
|
-
data: {
|
|
165
|
-
server: isMcp ? action.server_name : null,
|
|
166
|
-
tool: isMcp ? action.tool_name : action.action_type,
|
|
167
|
-
arguments: parseJsonArgs(action.arguments),
|
|
168
|
-
result: output ? [{ type: 'text', text: output }] : null,
|
|
169
|
-
error: failed ? errorMsg || 'Action failed' : null,
|
|
170
|
-
status,
|
|
171
|
-
},
|
|
172
|
-
status,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/** Map repoburg token counts to the agent-pane TokenUsage shape. */
|
|
179
|
-
export function mapUsage(u: {
|
|
180
|
-
input: number;
|
|
181
|
-
cached: number;
|
|
182
|
-
output: number;
|
|
183
|
-
}): {
|
|
184
|
-
input_tokens: number;
|
|
185
|
-
cached_input_tokens: number;
|
|
186
|
-
cache_write_input_tokens: number;
|
|
187
|
-
output_tokens: number;
|
|
188
|
-
reasoning_output_tokens: number;
|
|
189
|
-
} {
|
|
190
|
-
return {
|
|
191
|
-
input_tokens: u.input,
|
|
192
|
-
cached_input_tokens: u.cached,
|
|
193
|
-
cache_write_input_tokens: 0,
|
|
194
|
-
output_tokens: u.output,
|
|
195
|
-
reasoning_output_tokens: 0,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Update an item's data + status and broadcast the updated item. */
|
|
200
|
-
export function updateItem(
|
|
201
|
-
db: Database.Database,
|
|
202
|
-
sessionId: string,
|
|
203
|
-
turnId: string,
|
|
204
|
-
item: Item,
|
|
205
|
-
data: Record<string, unknown>,
|
|
206
|
-
status: ItemStatus,
|
|
207
|
-
): void {
|
|
208
|
-
const now = new Date().toISOString();
|
|
209
|
-
db.prepare('UPDATE items SET data = ?, status = ?, updated_at = ? WHERE id = ?').run(
|
|
210
|
-
JSON.stringify(data),
|
|
211
|
-
status,
|
|
212
|
-
now,
|
|
213
|
-
item.id,
|
|
214
|
-
);
|
|
215
|
-
const updated: Item = { ...item, data, status, updated_at: now };
|
|
216
|
-
broadcast('item:updated', { sessionId, turnId, item: updated });
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** Update the running state and status of a session. */
|
|
220
|
-
export function setSessionStatus(
|
|
221
|
-
db: Database.Database,
|
|
222
|
-
sessionId: string,
|
|
223
|
-
isRunning: 0 | 1,
|
|
224
|
-
status: string,
|
|
225
|
-
now: string,
|
|
226
|
-
hasUnreviewed = false,
|
|
227
|
-
): void {
|
|
228
|
-
if (hasUnreviewed) {
|
|
229
|
-
db.prepare('UPDATE sessions SET is_running = ?, status = ?, has_unreviewed = 1, updated_at = ? WHERE id = ?').run(
|
|
230
|
-
isRunning,
|
|
231
|
-
status,
|
|
232
|
-
now,
|
|
233
|
-
sessionId,
|
|
234
|
-
);
|
|
235
|
-
} else {
|
|
236
|
-
db.prepare('UPDATE sessions SET is_running = ?, status = ?, updated_at = ? WHERE id = ?').run(
|
|
237
|
-
isRunning,
|
|
238
|
-
status,
|
|
239
|
-
now,
|
|
240
|
-
sessionId,
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/** Insert an item row and broadcast it. Returns the created item. */
|
|
246
|
-
export function insertItem(
|
|
247
|
-
db: Database.Database,
|
|
248
|
-
sessionId: string,
|
|
249
|
-
turnId: string,
|
|
250
|
-
externalId: string,
|
|
251
|
-
type: Item['type'],
|
|
252
|
-
data: Record<string, unknown>,
|
|
253
|
-
status: ItemStatus,
|
|
254
|
-
broadcastEvent: 'item:started' | 'item:completed',
|
|
255
|
-
): Item {
|
|
256
|
-
const now = new Date().toISOString();
|
|
257
|
-
const itemId = uuidv4();
|
|
258
|
-
db.prepare(
|
|
259
|
-
'INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
|
260
|
-
).run(itemId, turnId, externalId, type, JSON.stringify(data), status, now, now);
|
|
261
|
-
|
|
262
|
-
const item: Item = {
|
|
263
|
-
id: itemId,
|
|
264
|
-
turn_id: turnId,
|
|
265
|
-
external_item_id: externalId,
|
|
266
|
-
type,
|
|
267
|
-
data,
|
|
268
|
-
status,
|
|
269
|
-
created_at: now,
|
|
270
|
-
updated_at: now,
|
|
271
|
-
};
|
|
272
|
-
broadcast(broadcastEvent, { sessionId, turnId, item });
|
|
273
|
-
return item;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/** Update an item's data + status and broadcast the completed item. */
|
|
277
|
-
export function completeItem(
|
|
278
|
-
db: Database.Database,
|
|
279
|
-
sessionId: string,
|
|
280
|
-
turnId: string,
|
|
281
|
-
item: Item,
|
|
282
|
-
data: Record<string, unknown>,
|
|
283
|
-
status: ItemStatus,
|
|
284
|
-
): void {
|
|
285
|
-
const now = new Date().toISOString();
|
|
286
|
-
db.prepare('UPDATE items SET data = ?, status = ?, updated_at = ? WHERE id = ?').run(
|
|
287
|
-
JSON.stringify(data),
|
|
288
|
-
status,
|
|
289
|
-
now,
|
|
290
|
-
item.id,
|
|
291
|
-
);
|
|
292
|
-
const updated: Item = { ...item, data, status, updated_at: now };
|
|
293
|
-
broadcast('item:completed', { sessionId, turnId, item: updated });
|
|
294
|
-
}
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
createSseParser,
|
|
4
|
-
parseSseFrame,
|
|
5
|
-
streamAgentRuntimeMessages,
|
|
6
|
-
} from './agent-runtime-client.ts';
|
|
7
|
-
import type { AgentRuntimeMessage } from './agent-runtime-client.ts';
|
|
8
|
-
|
|
9
|
-
const enc = new TextEncoder();
|
|
10
|
-
|
|
11
|
-
describe('parseSseFrame', () => {
|
|
12
|
-
it('extracts a single data line', () => {
|
|
13
|
-
expect(parseSseFrame('data: {"a":1}')).toBe('{"a":1}');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('strips one optional space after the colon', () => {
|
|
17
|
-
expect(parseSseFrame('data: {"a":1}')).toBe('{"a":1}');
|
|
18
|
-
expect(parseSseFrame('data:{"a":1}')).toBe('{"a":1}');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('ignores comment (heartbeat) lines and returns null when no data', () => {
|
|
22
|
-
expect(parseSseFrame(': ping')).toBeNull();
|
|
23
|
-
expect(parseSseFrame(': ping\ndata: x')).toBe('x');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('joins multiple data lines with newlines', () => {
|
|
27
|
-
expect(parseSseFrame('data: a\ndata: b')).toBe('a\nb');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('createSseParser', () => {
|
|
32
|
-
it('splits complete frames and buffers partial ones across chunks', () => {
|
|
33
|
-
const parse = createSseParser();
|
|
34
|
-
expect(parse('data: {"type":"a"}\n\ndata: {"ty')).toEqual(['{"type":"a"}']);
|
|
35
|
-
expect(parse('pe":"b"}\n\n')).toEqual(['{"type":"b"}']);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('handles CRLF line endings', () => {
|
|
39
|
-
const parse = createSseParser();
|
|
40
|
-
expect(parse('data: {"type":"a"}\r\n\r\n')).toEqual(['{"type":"a"}']);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('ignores heartbeat-only frames', () => {
|
|
44
|
-
const parse = createSseParser();
|
|
45
|
-
expect(parse(': ping\n\n')).toEqual([]);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('streamAgentRuntimeMessages', () => {
|
|
50
|
-
const fetchMock = vi.fn();
|
|
51
|
-
const originalFetch = globalThis.fetch;
|
|
52
|
-
|
|
53
|
-
beforeEach(() => {
|
|
54
|
-
vi.clearAllMocks();
|
|
55
|
-
globalThis.fetch = fetchMock as never;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
globalThis.fetch = originalFetch;
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/** Build an SSE Response body from raw chunks. */
|
|
63
|
-
function sseBody(chunks: string[], onAbort?: (error: () => void) => void): ReadableStream<Uint8Array> {
|
|
64
|
-
return new ReadableStream<Uint8Array>({
|
|
65
|
-
start(controller) {
|
|
66
|
-
for (const c of chunks) controller.enqueue(enc.encode(c));
|
|
67
|
-
if (!onAbort) controller.close();
|
|
68
|
-
else onAbort(() => controller.error(new DOMException('Aborted', 'AbortError')));
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function sseResponse(body: ReadableStream<Uint8Array>): Response {
|
|
74
|
-
return { ok: true, status: 200, body } as never;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const systemFrame = 'data: {"type":"system","subtype":"init","sessionId":"rs-1","modelId":null}\n\n';
|
|
78
|
-
const assistantFrame = 'data: {"type":"assistant","sessionId":"rs-1","inputId":"in-1","content":[]}\n\n';
|
|
79
|
-
const resultFrame =
|
|
80
|
-
'data: {"type":"result","subtype":"success","sessionId":"rs-1","is_error":false,"result":"done","num_rounds":1}\n\n';
|
|
81
|
-
|
|
82
|
-
it('delivers messages in order and stops at the terminal result', async () => {
|
|
83
|
-
fetchMock.mockResolvedValue(
|
|
84
|
-
sseResponse(sseBody([systemFrame, ': ping\n\n', assistantFrame, resultFrame])),
|
|
85
|
-
);
|
|
86
|
-
const messages: AgentRuntimeMessage[] = [];
|
|
87
|
-
const onActivity = vi.fn();
|
|
88
|
-
|
|
89
|
-
const reason = await streamAgentRuntimeMessages(
|
|
90
|
-
'http://repoburg.test',
|
|
91
|
-
'rs-1',
|
|
92
|
-
(m) => messages.push(m),
|
|
93
|
-
{ onActivity, reconnectDelayMs: 1 },
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
expect(reason).toBe('result');
|
|
97
|
-
expect(messages.map((m) => m.type)).toEqual(['system', 'assistant', 'result']);
|
|
98
|
-
// Activity fired for the received bytes (chunk coalescing makes the exact
|
|
99
|
-
// read count implementation-dependent — at least once).
|
|
100
|
-
expect(onActivity.mock.calls.length).toBeGreaterThanOrEqual(1);
|
|
101
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
102
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
103
|
-
'http://repoburg.test/agent-runtime/sessions/rs-1/messages?stream=1',
|
|
104
|
-
expect.objectContaining({ method: 'GET' }),
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('parses frames split across chunk boundaries', async () => {
|
|
109
|
-
fetchMock.mockResolvedValue(
|
|
110
|
-
sseResponse(
|
|
111
|
-
sseBody([
|
|
112
|
-
'data: {"type":"res',
|
|
113
|
-
'ult","subtype":"succ',
|
|
114
|
-
'ess","sessionId":"rs-1","is_error":false,"result":"d","num_rounds":1}\n\n',
|
|
115
|
-
]),
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
const messages: AgentRuntimeMessage[] = [];
|
|
119
|
-
|
|
120
|
-
const reason = await streamAgentRuntimeMessages(
|
|
121
|
-
'http://repoburg.test',
|
|
122
|
-
'rs-1',
|
|
123
|
-
(m) => messages.push(m),
|
|
124
|
-
{ reconnectDelayMs: 1 },
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
expect(reason).toBe('result');
|
|
128
|
-
expect(messages).toHaveLength(1);
|
|
129
|
-
expect(messages[0].type).toBe('result');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('reconnects after the server closes the stream without a result', async () => {
|
|
133
|
-
fetchMock
|
|
134
|
-
.mockResolvedValueOnce(sseResponse(sseBody([assistantFrame]))) // closes early
|
|
135
|
-
.mockResolvedValueOnce(sseResponse(sseBody([resultFrame])));
|
|
136
|
-
const messages: AgentRuntimeMessage[] = [];
|
|
137
|
-
|
|
138
|
-
const reason = await streamAgentRuntimeMessages(
|
|
139
|
-
'http://repoburg.test',
|
|
140
|
-
'rs-1',
|
|
141
|
-
(m) => messages.push(m),
|
|
142
|
-
{ reconnectDelayMs: 1 },
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
expect(reason).toBe('result');
|
|
146
|
-
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
147
|
-
expect(messages.map((m) => m.type)).toEqual(['assistant', 'result']);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('reconnects after a fetch failure', async () => {
|
|
151
|
-
fetchMock
|
|
152
|
-
.mockRejectedValueOnce(new Error('ECONNREFUSED'))
|
|
153
|
-
.mockResolvedValueOnce(sseResponse(sseBody([resultFrame])));
|
|
154
|
-
|
|
155
|
-
const reason = await streamAgentRuntimeMessages(
|
|
156
|
-
'http://repoburg.test',
|
|
157
|
-
'rs-1',
|
|
158
|
-
() => {},
|
|
159
|
-
{ reconnectDelayMs: 1 },
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
expect(reason).toBe('result');
|
|
163
|
-
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('reconnects on non-OK responses other than 404', async () => {
|
|
167
|
-
fetchMock
|
|
168
|
-
.mockResolvedValueOnce({ ok: false, status: 502 } as never)
|
|
169
|
-
.mockResolvedValueOnce(sseResponse(sseBody([resultFrame])));
|
|
170
|
-
|
|
171
|
-
const reason = await streamAgentRuntimeMessages(
|
|
172
|
-
'http://repoburg.test',
|
|
173
|
-
'rs-1',
|
|
174
|
-
() => {},
|
|
175
|
-
{ reconnectDelayMs: 1 },
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
expect(reason).toBe('result');
|
|
179
|
-
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('returns session-not-found on 404 without retrying', async () => {
|
|
183
|
-
fetchMock.mockResolvedValue({ ok: false, status: 404 } as never);
|
|
184
|
-
|
|
185
|
-
const reason = await streamAgentRuntimeMessages(
|
|
186
|
-
'http://repoburg.test',
|
|
187
|
-
'rs-1',
|
|
188
|
-
() => {},
|
|
189
|
-
{ reconnectDelayMs: 1 },
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
expect(reason).toBe('session-not-found');
|
|
193
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('returns aborted when the signal is already aborted', async () => {
|
|
197
|
-
const controller = new AbortController();
|
|
198
|
-
controller.abort();
|
|
199
|
-
|
|
200
|
-
const reason = await streamAgentRuntimeMessages(
|
|
201
|
-
'http://repoburg.test',
|
|
202
|
-
'rs-1',
|
|
203
|
-
() => {},
|
|
204
|
-
{ signal: controller.signal, reconnectDelayMs: 1 },
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
expect(reason).toBe('aborted');
|
|
208
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('returns aborted when the signal aborts mid-stream', async () => {
|
|
212
|
-
const controller = new AbortController();
|
|
213
|
-
// Simulate real fetch semantics: aborting errors the body stream.
|
|
214
|
-
fetchMock.mockResolvedValue(
|
|
215
|
-
sseResponse(
|
|
216
|
-
sseBody([assistantFrame], (error) => {
|
|
217
|
-
controller.signal.addEventListener('abort', () => error());
|
|
218
|
-
}),
|
|
219
|
-
),
|
|
220
|
-
);
|
|
221
|
-
const messages: AgentRuntimeMessage[] = [];
|
|
222
|
-
|
|
223
|
-
const promise = streamAgentRuntimeMessages(
|
|
224
|
-
'http://repoburg.test',
|
|
225
|
-
'rs-1',
|
|
226
|
-
(m) => messages.push(m),
|
|
227
|
-
{ signal: controller.signal, reconnectDelayMs: 1 },
|
|
228
|
-
);
|
|
229
|
-
// Let the first chunk deliver, then abort.
|
|
230
|
-
await new Promise((r) => setTimeout(r, 10));
|
|
231
|
-
controller.abort();
|
|
232
|
-
|
|
233
|
-
const reason = await promise;
|
|
234
|
-
|
|
235
|
-
expect(reason).toBe('aborted');
|
|
236
|
-
expect(messages.map((m) => m.type)).toEqual(['assistant']);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('skips malformed JSON frames without failing the stream', async () => {
|
|
240
|
-
fetchMock.mockResolvedValue(
|
|
241
|
-
sseResponse(sseBody(['data: not-json\n\n', resultFrame])),
|
|
242
|
-
);
|
|
243
|
-
const messages: AgentRuntimeMessage[] = [];
|
|
244
|
-
|
|
245
|
-
const reason = await streamAgentRuntimeMessages(
|
|
246
|
-
'http://repoburg.test',
|
|
247
|
-
'rs-1',
|
|
248
|
-
(m) => messages.push(m),
|
|
249
|
-
{ reconnectDelayMs: 1 },
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
expect(reason).toBe('result');
|
|
253
|
-
expect(messages.map((m) => m.type)).toEqual(['result']);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('requests deltas off (?stream=0) when deltas=false', async () => {
|
|
257
|
-
fetchMock.mockResolvedValue(sseResponse(sseBody([resultFrame])));
|
|
258
|
-
|
|
259
|
-
await streamAgentRuntimeMessages(
|
|
260
|
-
'http://repoburg.test',
|
|
261
|
-
'rs-1',
|
|
262
|
-
() => {},
|
|
263
|
-
{ deltas: false, reconnectDelayMs: 1 },
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
267
|
-
'http://repoburg.test/agent-runtime/sessions/rs-1/messages?stream=0',
|
|
268
|
-
expect.anything(),
|
|
269
|
-
);
|
|
270
|
-
});
|
|
271
|
-
});
|