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.
Files changed (325) hide show
  1. package/agent-pane/backend/dist/index.js +2714 -32395
  2. package/agent-pane/backend/dist/server.js +45304 -0
  3. package/askuser-after-step5-postgres-selected.png +0 -0
  4. package/askuser-after-step7-answer-sent.png +0 -0
  5. package/askuser-card-visible.png +0 -0
  6. package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.d.ts +16 -0
  7. package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js +87 -0
  8. package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js.map +1 -1
  9. package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +16 -1
  10. package/backend/dist/src/app.controller.d.ts +1 -0
  11. package/backend/dist/src/app.service.d.ts +1 -0
  12. package/backend/dist/src/app.service.js +4 -1
  13. package/backend/dist/src/app.service.js.map +1 -1
  14. package/backend/dist/src/interactive-chat/chat.service.d.ts +4 -0
  15. package/backend/dist/src/interactive-chat/chat.service.js +21 -1
  16. package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
  17. package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js +12 -1
  18. package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js.map +1 -1
  19. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -0
  20. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js +1 -0
  21. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -1
  22. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +2 -0
  23. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
  24. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  25. package/daemon/dist/agentPane.js +128 -0
  26. package/daemon/dist/agentPane.spec.js +183 -0
  27. package/daemon/dist/api/services.js +4 -0
  28. package/daemon/dist/index.js +28 -8
  29. package/daemon/dist/serviceManager.js +30 -11
  30. package/daemon/dist/serviceManager.spec.js +26 -0
  31. package/daemon/dist/workspace-validation.js +63 -0
  32. package/daemon/dist/workspace-validation.spec.js +63 -0
  33. package/daemon/package.json +1 -1
  34. package/package.json +15 -2
  35. package/r2-step4-apple-banana.png +0 -0
  36. package/r2-step5-after-rewind-apple-last.png +0 -0
  37. package/r2-step7-apple-cherry.png +0 -0
  38. package/r2-step8-cherry-menu-no-restore.png +0 -0
  39. package/r3-step3-live-task-card-running.png +0 -0
  40. package/r3-step4-after-completion.png +0 -0
  41. package/r3-step5-persistence-after-reload.png +0 -0
  42. package/r3-step6-tasks-tab-card.png +0 -0
  43. package/reverify-answered-state-answer-sent.png +0 -0
  44. package/reverify-card-visible-after-completion.png +0 -0
  45. package/rewind-step3-apple-banana-turns.png +0 -0
  46. package/rewind-step5-ui-unchanged-after-confirmed-rewind.png +0 -0
  47. package/rewind-step6-apple-menu-no-restore.png +0 -0
  48. package/rewind-step7-final-turnlist-unchanged.png +0 -0
  49. package/rewind-step7-negative-error-toast.png +0 -0
  50. package/rewind-step7-negative-error-toast2.png +0 -0
  51. package/subagent-r2-step5-turn-after-reload-no-card.png +0 -0
  52. package/subagent-r2-step6-tasks-panel-card.png +0 -0
  53. package/subagent-step3-tasks-tab-done-card.png +0 -0
  54. package/subagent-step4-turn-stuck-no-cards.png +0 -0
  55. package/agent-pane/.prettierignore +0 -5
  56. package/agent-pane/.prettierrc +0 -8
  57. package/agent-pane/backend/coverage/base.css +0 -224
  58. package/agent-pane/backend/coverage/block-navigation.js +0 -87
  59. package/agent-pane/backend/coverage/clover.xml +0 -887
  60. package/agent-pane/backend/coverage/coverage-final.json +0 -10
  61. package/agent-pane/backend/coverage/favicon.png +0 -0
  62. package/agent-pane/backend/coverage/index.html +0 -176
  63. package/agent-pane/backend/coverage/prettify.css +0 -1
  64. package/agent-pane/backend/coverage/prettify.js +0 -2
  65. package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
  66. package/agent-pane/backend/coverage/sorter.js +0 -210
  67. package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +0 -1402
  68. package/agent-pane/backend/coverage/src/codex/index.html +0 -131
  69. package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +0 -331
  70. package/agent-pane/backend/coverage/src/db/index.html +0 -131
  71. package/agent-pane/backend/coverage/src/db/index.ts.html +0 -436
  72. package/agent-pane/backend/coverage/src/db/schema.ts.html +0 -175
  73. package/agent-pane/backend/coverage/src/index.html +0 -116
  74. package/agent-pane/backend/coverage/src/index.ts.html +0 -262
  75. package/agent-pane/backend/coverage/src/routes/index.html +0 -146
  76. package/agent-pane/backend/coverage/src/routes/sessions.ts.html +0 -991
  77. package/agent-pane/backend/coverage/src/routes/turns.ts.html +0 -256
  78. package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +0 -406
  79. package/agent-pane/backend/coverage/src/ws/index.html +0 -116
  80. package/agent-pane/backend/coverage/src/ws/index.ts.html +0 -238
  81. package/agent-pane/backend/data.db +0 -0
  82. package/agent-pane/backend/data.db-shm +0 -0
  83. package/agent-pane/backend/data.db-wal +0 -0
  84. package/agent-pane/backend/package-lock.json +0 -5945
  85. package/agent-pane/backend/package.json +0 -33
  86. package/agent-pane/backend/scripts/backfill-from-jsonl.ts +0 -206
  87. package/agent-pane/backend/scripts/import-session-from-jsonl.ts +0 -264
  88. package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +0 -271
  89. package/agent-pane/backend/src/claude/claude-message-mapper.ts +0 -259
  90. package/agent-pane/backend/src/claude/claude-provider.test.ts +0 -455
  91. package/agent-pane/backend/src/claude/claude-provider.ts +0 -1319
  92. package/agent-pane/backend/src/claude/claude-types.ts +0 -45
  93. package/agent-pane/backend/src/codex/app-server-client.test.ts +0 -183
  94. package/agent-pane/backend/src/codex/app-server-client.ts +0 -247
  95. package/agent-pane/backend/src/codex/app-server-types.ts +0 -259
  96. package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +0 -56
  97. package/agent-pane/backend/src/codex/codex-provider.test.ts +0 -60
  98. package/agent-pane/backend/src/codex/codex-provider.ts +0 -619
  99. package/agent-pane/backend/src/codex/item-mapper.test.ts +0 -221
  100. package/agent-pane/backend/src/codex/item-mapper.ts +0 -86
  101. package/agent-pane/backend/src/codex/shared-app-server.ts +0 -25
  102. package/agent-pane/backend/src/db/index.test.ts +0 -125
  103. package/agent-pane/backend/src/db/index.ts +0 -230
  104. package/agent-pane/backend/src/db/schema.ts +0 -34
  105. package/agent-pane/backend/src/index.ts +0 -89
  106. package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +0 -29
  107. package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +0 -40
  108. package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +0 -16
  109. package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +0 -60
  110. package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +0 -34
  111. package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +0 -85
  112. package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +0 -48
  113. package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +0 -35
  114. package/agent-pane/backend/src/integration/delta-streaming.test.ts +0 -130
  115. package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +0 -272
  116. package/agent-pane/backend/src/integration/helpers/test-app.ts +0 -110
  117. package/agent-pane/backend/src/integration/helpers/ws-capture.ts +0 -64
  118. package/agent-pane/backend/src/integration/item-lifecycle.test.ts +0 -133
  119. package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +0 -102
  120. package/agent-pane/backend/src/integration/missing-item-started.test.ts +0 -91
  121. package/agent-pane/backend/src/integration/multi-turn.test.ts +0 -121
  122. package/agent-pane/backend/src/integration/session-operations.test.ts +0 -175
  123. package/agent-pane/backend/src/integration/threads-claude-fork.test.ts +0 -241
  124. package/agent-pane/backend/src/integration/threads.test.ts +0 -309
  125. package/agent-pane/backend/src/integration/title-generation.test.ts +0 -109
  126. package/agent-pane/backend/src/integration/turn-cancel.test.ts +0 -111
  127. package/agent-pane/backend/src/integration/turn-failure.test.ts +0 -97
  128. package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +0 -141
  129. package/agent-pane/backend/src/providers/index.ts +0 -16
  130. package/agent-pane/backend/src/providers/registry.test.ts +0 -92
  131. package/agent-pane/backend/src/providers/registry.ts +0 -43
  132. package/agent-pane/backend/src/providers/runtime-provider.ts +0 -43
  133. package/agent-pane/backend/src/repoburg/action-mapping.ts +0 -216
  134. package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +0 -271
  135. package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +0 -262
  136. package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +0 -271
  137. package/agent-pane/backend/src/repoburg/backend-resolver.ts +0 -246
  138. package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +0 -159
  139. package/agent-pane/backend/src/repoburg/repoburg-client.ts +0 -181
  140. package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +0 -723
  141. package/agent-pane/backend/src/repoburg/repoburg-provider.ts +0 -422
  142. package/agent-pane/backend/src/repoburg/turn-projector.test.ts +0 -475
  143. package/agent-pane/backend/src/repoburg/turn-projector.ts +0 -537
  144. package/agent-pane/backend/src/routes/files.ts +0 -31
  145. package/agent-pane/backend/src/routes/mcp.ts +0 -33
  146. package/agent-pane/backend/src/routes/models.test.ts +0 -92
  147. package/agent-pane/backend/src/routes/models.ts +0 -16
  148. package/agent-pane/backend/src/routes/plugins.ts +0 -40
  149. package/agent-pane/backend/src/routes/providers.test.ts +0 -86
  150. package/agent-pane/backend/src/routes/providers.ts +0 -86
  151. package/agent-pane/backend/src/routes/sessions.test.ts +0 -558
  152. package/agent-pane/backend/src/routes/sessions.ts +0 -504
  153. package/agent-pane/backend/src/routes/skills.test.ts +0 -114
  154. package/agent-pane/backend/src/routes/skills.ts +0 -70
  155. package/agent-pane/backend/src/routes/threads.ts +0 -323
  156. package/agent-pane/backend/src/routes/turns.test.ts +0 -196
  157. package/agent-pane/backend/src/routes/turns.ts +0 -103
  158. package/agent-pane/backend/src/routes/workspaces.test.ts +0 -197
  159. package/agent-pane/backend/src/routes/workspaces.ts +0 -128
  160. package/agent-pane/backend/src/ws/index.test.ts +0 -107
  161. package/agent-pane/backend/src/ws/index.ts +0 -51
  162. package/agent-pane/backend/tsconfig.json +0 -25
  163. package/agent-pane/backend/vitest.config.ts +0 -20
  164. package/agent-pane/eslint.config.js +0 -33
  165. package/agent-pane/frontend/coverage/base.css +0 -224
  166. package/agent-pane/frontend/coverage/block-navigation.js +0 -87
  167. package/agent-pane/frontend/coverage/clover.xml +0 -2962
  168. package/agent-pane/frontend/coverage/coverage-final.json +0 -37
  169. package/agent-pane/frontend/coverage/favicon.png +0 -0
  170. package/agent-pane/frontend/coverage/index.html +0 -251
  171. package/agent-pane/frontend/coverage/prettify.css +0 -1
  172. package/agent-pane/frontend/coverage/prettify.js +0 -2
  173. package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
  174. package/agent-pane/frontend/coverage/sorter.js +0 -210
  175. package/agent-pane/frontend/coverage/src/App.tsx.html +0 -217
  176. package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +0 -223
  177. package/agent-pane/frontend/coverage/src/api/client.ts.html +0 -187
  178. package/agent-pane/frontend/coverage/src/api/index.html +0 -161
  179. package/agent-pane/frontend/coverage/src/api/sessions.ts.html +0 -316
  180. package/agent-pane/frontend/coverage/src/api/websocket.ts.html +0 -544
  181. package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +0 -199
  182. package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +0 -226
  183. package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +0 -382
  184. package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +0 -715
  185. package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +0 -160
  186. package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +0 -478
  187. package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +0 -472
  188. package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +0 -574
  189. package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +0 -205
  190. package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +0 -133
  191. package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +0 -217
  192. package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +0 -271
  193. package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +0 -109
  194. package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +0 -313
  195. package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +0 -1216
  196. package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +0 -1138
  197. package/agent-pane/frontend/coverage/src/components/index.html +0 -326
  198. package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +0 -247
  199. package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +0 -160
  200. package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +0 -427
  201. package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +0 -397
  202. package/agent-pane/frontend/coverage/src/components/panels/index.html +0 -161
  203. package/agent-pane/frontend/coverage/src/constants/index.html +0 -116
  204. package/agent-pane/frontend/coverage/src/constants/models.ts.html +0 -406
  205. package/agent-pane/frontend/coverage/src/hooks/index.html +0 -146
  206. package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +0 -124
  207. package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +0 -142
  208. package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +0 -187
  209. package/agent-pane/frontend/coverage/src/index.html +0 -146
  210. package/agent-pane/frontend/coverage/src/main.tsx.html +0 -115
  211. package/agent-pane/frontend/coverage/src/store/index.html +0 -116
  212. package/agent-pane/frontend/coverage/src/store/store.ts.html +0 -2404
  213. package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +0 -190
  214. package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +0 -367
  215. package/agent-pane/frontend/coverage/src/test/index.html +0 -131
  216. package/agent-pane/frontend/coverage/src/types/index.html +0 -116
  217. package/agent-pane/frontend/coverage/src/types/index.ts.html +0 -466
  218. package/agent-pane/frontend/coverage/src/utils/changes.ts.html +0 -202
  219. package/agent-pane/frontend/coverage/src/utils/duration.ts.html +0 -127
  220. package/agent-pane/frontend/coverage/src/utils/index.html +0 -131
  221. package/agent-pane/frontend/dist/assets/index-34WaZYsW.css +0 -1
  222. package/agent-pane/frontend/dist/assets/index-y7xlT86e.js +0 -362
  223. package/agent-pane/frontend/dist/index.html +0 -19
  224. package/agent-pane/frontend/index.html +0 -18
  225. package/agent-pane/frontend/package-lock.json +0 -4211
  226. package/agent-pane/frontend/package.json +0 -35
  227. package/agent-pane/frontend/src/App.test.tsx +0 -74
  228. package/agent-pane/frontend/src/App.tsx +0 -44
  229. package/agent-pane/frontend/src/AppInitializer.test.tsx +0 -142
  230. package/agent-pane/frontend/src/AppInitializer.tsx +0 -46
  231. package/agent-pane/frontend/src/__tests__/ThreadsPanel.test.tsx +0 -192
  232. package/agent-pane/frontend/src/api/client.test.ts +0 -126
  233. package/agent-pane/frontend/src/api/client.ts +0 -34
  234. package/agent-pane/frontend/src/api/models.ts +0 -7
  235. package/agent-pane/frontend/src/api/providers.ts +0 -17
  236. package/agent-pane/frontend/src/api/sessions.test.ts +0 -245
  237. package/agent-pane/frontend/src/api/sessions.ts +0 -97
  238. package/agent-pane/frontend/src/api/skills.ts +0 -12
  239. package/agent-pane/frontend/src/api/websocket.test.ts +0 -288
  240. package/agent-pane/frontend/src/api/websocket.ts +0 -238
  241. package/agent-pane/frontend/src/api/workspaces.test.ts +0 -112
  242. package/agent-pane/frontend/src/api/workspaces.ts +0 -38
  243. package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +0 -49
  244. package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +0 -56
  245. package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +0 -133
  246. package/agent-pane/frontend/src/components/CommandInputBar.tsx +0 -584
  247. package/agent-pane/frontend/src/components/CommandPalette.test.tsx +0 -226
  248. package/agent-pane/frontend/src/components/CommandPalette.tsx +0 -194
  249. package/agent-pane/frontend/src/components/CommentableText.test.tsx +0 -196
  250. package/agent-pane/frontend/src/components/CommentableText.tsx +0 -379
  251. package/agent-pane/frontend/src/components/IdeWorkspace.test.tsx +0 -39
  252. package/agent-pane/frontend/src/components/IdeWorkspace.tsx +0 -51
  253. package/agent-pane/frontend/src/components/ModelSelector.test.tsx +0 -129
  254. package/agent-pane/frontend/src/components/ModelSelector.tsx +0 -191
  255. package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +0 -95
  256. package/agent-pane/frontend/src/components/NewSessionDialog.tsx +0 -129
  257. package/agent-pane/frontend/src/components/RenderArea.test.tsx +0 -160
  258. package/agent-pane/frontend/src/components/RenderArea.tsx +0 -170
  259. package/agent-pane/frontend/src/components/ResizeHandle.tsx +0 -29
  260. package/agent-pane/frontend/src/components/RightPanel.test.tsx +0 -43
  261. package/agent-pane/frontend/src/components/RightPanel.tsx +0 -46
  262. package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +0 -32
  263. package/agent-pane/frontend/src/components/RuntimeIcon.tsx +0 -16
  264. package/agent-pane/frontend/src/components/SessionTabs.test.tsx +0 -72
  265. package/agent-pane/frontend/src/components/SessionTabs.tsx +0 -49
  266. package/agent-pane/frontend/src/components/StatusBar.test.tsx +0 -56
  267. package/agent-pane/frontend/src/components/StatusBar.tsx +0 -129
  268. package/agent-pane/frontend/src/components/StatusDot.test.tsx +0 -25
  269. package/agent-pane/frontend/src/components/StatusDot.tsx +0 -8
  270. package/agent-pane/frontend/src/components/Toast.test.tsx +0 -79
  271. package/agent-pane/frontend/src/components/Toast.tsx +0 -76
  272. package/agent-pane/frontend/src/components/TurnContent.test.tsx +0 -298
  273. package/agent-pane/frontend/src/components/TurnContent.tsx +0 -548
  274. package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +0 -297
  275. package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +0 -351
  276. package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +0 -32
  277. package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +0 -63
  278. package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +0 -78
  279. package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +0 -96
  280. package/agent-pane/frontend/src/components/input/SlashPopup.tsx +0 -82
  281. package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +0 -61
  282. package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +0 -54
  283. package/agent-pane/frontend/src/components/panels/TasksPanel.test.tsx +0 -97
  284. package/agent-pane/frontend/src/components/panels/TasksPanel.tsx +0 -208
  285. package/agent-pane/frontend/src/components/panels/ThreadsPanel.tsx +0 -382
  286. package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +0 -83
  287. package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +0 -126
  288. package/agent-pane/frontend/src/constants/models.test.ts +0 -97
  289. package/agent-pane/frontend/src/constants/models.ts +0 -166
  290. package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +0 -42
  291. package/agent-pane/frontend/src/hooks/useEscapeKey.ts +0 -13
  292. package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +0 -92
  293. package/agent-pane/frontend/src/hooks/useOutsideClick.ts +0 -19
  294. package/agent-pane/frontend/src/hooks/useProvider.ts +0 -44
  295. package/agent-pane/frontend/src/hooks/useResizable.test.ts +0 -97
  296. package/agent-pane/frontend/src/hooks/useResizable.ts +0 -75
  297. package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +0 -116
  298. package/agent-pane/frontend/src/hooks/useSessionStatus.ts +0 -34
  299. package/agent-pane/frontend/src/main.test.tsx +0 -37
  300. package/agent-pane/frontend/src/main.tsx +0 -10
  301. package/agent-pane/frontend/src/store/sessionSlice.ts +0 -440
  302. package/agent-pane/frontend/src/store/store.test.ts +0 -1319
  303. package/agent-pane/frontend/src/store/store.ts +0 -37
  304. package/agent-pane/frontend/src/store/threadSlice.ts +0 -136
  305. package/agent-pane/frontend/src/store/uiSlice.ts +0 -133
  306. package/agent-pane/frontend/src/store/workspaceSlice.ts +0 -77
  307. package/agent-pane/frontend/src/store/wsSlice.ts +0 -361
  308. package/agent-pane/frontend/src/styles/app.css +0 -611
  309. package/agent-pane/frontend/src/styles/tokens.css +0 -62
  310. package/agent-pane/frontend/src/test/component-helpers.ts +0 -38
  311. package/agent-pane/frontend/src/test/fixtures.ts +0 -100
  312. package/agent-pane/frontend/src/test-setup.ts +0 -5
  313. package/agent-pane/frontend/src/types/index.test.ts +0 -128
  314. package/agent-pane/frontend/src/types/index.ts +0 -132
  315. package/agent-pane/frontend/src/utils/changes.test.ts +0 -81
  316. package/agent-pane/frontend/src/utils/changes.ts +0 -39
  317. package/agent-pane/frontend/src/utils/duration.test.ts +0 -75
  318. package/agent-pane/frontend/src/utils/duration.ts +0 -14
  319. package/agent-pane/frontend/tsconfig.json +0 -25
  320. package/agent-pane/frontend/vite.config.ts +0 -22
  321. package/agent-pane/frontend/vitest.config.ts +0 -29
  322. package/agent-pane/package-lock.json +0 -1527
  323. package/agent-pane/package.json +0 -19
  324. package/agent-pane/shared/provider-types.ts +0 -67
  325. package/agent-pane/shared/types.ts +0 -167
@@ -1,272 +0,0 @@
1
- /**
2
- * App-server replay mock for integration tests.
3
- *
4
- * Replaces the old `@openai/codex-sdk` replay mock. The mock AppServerClient
5
- * replays fixture events as JSON-RPC notifications (item/started, item/completed,
6
- * turn/completed, turn/failed) instead of SDK async generators.
7
- *
8
- * The fixture format is unchanged — events use SDK-style names (thread.started,
9
- * item.started, etc.) which are translated to app-server notification names
10
- * (thread/started, item/started, etc.) by the mock.
11
- */
12
-
13
- import { EventEmitter } from 'node:events';
14
-
15
- /** A single event captured from the real SDK (or app-server). */
16
- type FixtureEvent = Record<string, unknown>;
17
-
18
- /** A captured interaction (events for one turn). */
19
- interface ReplayCall {
20
- prompt: string;
21
- events: FixtureEvent[];
22
- eventDelay?: number;
23
- }
24
-
25
- /** A captured title generation interaction. */
26
- interface TitleCall {
27
- prompt: string;
28
- result: { finalResponse: string };
29
- }
30
-
31
- /** A complete fixture — all interactions for one test scenario. */
32
- export interface Fixture {
33
- name: string;
34
- description: string;
35
- threadId: string;
36
- runStreamedCalls: ReplayCall[];
37
- runCalls: TitleCall[];
38
- }
39
-
40
- /** Read a fixture from a JSON string. */
41
- export function parseFixture(json: string): Fixture {
42
- return JSON.parse(json) as Fixture;
43
- }
44
-
45
- /** Map SDK event type to app-server notification method. */
46
- function sdkEventToNotification(eventType: string): string {
47
- switch (eventType) {
48
- case 'thread.started':
49
- return 'thread/started';
50
- case 'item.started':
51
- return 'item/started';
52
- case 'item.updated':
53
- return 'item/updated';
54
- case 'item.completed':
55
- return 'item/completed';
56
- case 'item.agentMessage.delta':
57
- return 'item/agentMessage/delta';
58
- case 'turn.completed':
59
- return 'turn/completed';
60
- case 'thread.tokenUsage.updated':
61
- return 'thread/tokenUsage/updated';
62
- case 'error':
63
- return 'turn/failed';
64
- default:
65
- return eventType;
66
- }
67
- }
68
-
69
- /** Map an SDK event to app-server notification params. */
70
- function sdkEventToParams(event: FixtureEvent, threadId: string, turnId: string): Record<string, unknown> {
71
- const type = event.type as string;
72
-
73
- if (type === 'turn.completed') {
74
- // Real app-server sends { threadId, turn: { id, status } } — no usage.
75
- // Token usage arrives via separate thread/tokenUsage/updated notification.
76
- return {
77
- threadId,
78
- turnId,
79
- };
80
- }
81
-
82
- if (type === 'error') {
83
- return {
84
- threadId,
85
- turnId,
86
- error: { message: event.message as string },
87
- };
88
- }
89
-
90
- if (type === 'item.agentMessage.delta') {
91
- return {
92
- threadId,
93
- turnId,
94
- itemId: event.itemId as string,
95
- delta: event.delta as string,
96
- };
97
- }
98
-
99
- if (type === 'thread.tokenUsage.updated') {
100
- const usage = event.tokenUsage as {
101
- inputTokens: number;
102
- cachedInputTokens: number;
103
- cacheWriteInputTokens: number;
104
- outputTokens: number;
105
- reasoningOutputTokens: number;
106
- totalTokens: number;
107
- };
108
- return {
109
- threadId,
110
- turnId,
111
- tokenUsage: {
112
- total: usage,
113
- last: usage,
114
- modelContextWindow: event.modelContextWindow ?? 258400,
115
- },
116
- };
117
- }
118
-
119
- // item.* events
120
- return {
121
- threadId,
122
- turnId,
123
- item: event.item as Record<string, unknown>,
124
- };
125
- }
126
-
127
- /**
128
- * Create a mock AppServerClient class that replays fixture events.
129
- *
130
- * @param fixture — The fixture to replay.
131
- * @returns A class that can be used to mock the AppServerClient module.
132
- */
133
- export function createAppServerMock(fixture: Fixture) {
134
- return class MockAppServerClient {
135
- readonly events = new EventEmitter();
136
- private notificationHandlers = new Map<string, Array<(params: unknown) => void>>();
137
- private closed = false;
138
- private interrupted = false;
139
- private turnStartIndex = 0;
140
- private titleCallIndex = 0;
141
-
142
- async initialize(): Promise<{ userAgent: string }> {
143
- return { userAgent: 'mock/0.147.0' };
144
- }
145
-
146
- async request<T>(method: string, params?: unknown): Promise<T> {
147
- if (this.closed) throw new Error('MockAppServerClient is closed');
148
-
149
- switch (method) {
150
- case 'thread/start':
151
- case 'thread/resume':
152
- return { thread: { id: fixture.threadId } } as T;
153
-
154
- case 'turn/start': {
155
- // Detect title generation by checking input prompt prefix
156
- const inputText = (params as { input?: Array<{ text?: string }> })?.input?.[0]?.text ?? '';
157
- const isTitleGen = inputText.startsWith('Generate a concise 3-5 word title');
158
-
159
- if (isTitleGen) {
160
- // Title generation — use runCalls
161
- if (this.titleCallIndex < fixture.runCalls.length) {
162
- const call = fixture.runCalls[this.titleCallIndex];
163
- this.titleCallIndex++;
164
-
165
- const turnId = `title_${this.titleCallIndex}`;
166
- this.replayTitleCall(call, fixture.threadId, turnId);
167
-
168
- return { turn: { id: turnId } } as T;
169
- }
170
- // No more title calls — return empty turn
171
- return { turn: { id: 'empty_title' } } as T;
172
- }
173
-
174
- // Main turns use runStreamedCalls
175
- if (this.turnStartIndex < fixture.runStreamedCalls.length) {
176
- const call = fixture.runStreamedCalls[this.turnStartIndex];
177
- this.turnStartIndex++;
178
-
179
- const turnId = `turn_${this.turnStartIndex}`;
180
- this.replayEvents(call, fixture.threadId, turnId);
181
-
182
- return { turn: { id: turnId } } as T;
183
- }
184
-
185
- // No more fixture calls — return empty turn (no events)
186
- return { turn: { id: 'empty' } } as T;
187
- }
188
-
189
- case 'turn/interrupt':
190
- this.interrupted = true;
191
- return {} as T;
192
-
193
- default:
194
- return {} as T;
195
- }
196
- }
197
-
198
- notify(): void {
199
- // No-op
200
- }
201
-
202
- onNotification(method: string, handler: (params: unknown) => void): void {
203
- const handlers = this.notificationHandlers.get(method) ?? [];
204
- handlers.push(handler);
205
- this.notificationHandlers.set(method, handlers);
206
- }
207
-
208
- onRequest(): void {
209
- // No-op
210
- }
211
-
212
- isClosed(): boolean {
213
- return this.closed;
214
- }
215
-
216
- async close(): Promise<void> {
217
- this.closed = true;
218
- }
219
-
220
- /** Replay fixture events as notifications with optional delay. */
221
- private async replayEvents(call: ReplayCall, threadId: string, turnId: string): Promise<void> {
222
- for (const event of call.events) {
223
- if (this.interrupted) {
224
- // On interrupt, stop replaying — codex-provider handles DB update + broadcast
225
- return;
226
- }
227
-
228
- if (call.eventDelay) {
229
- await new Promise((r) => setTimeout(r, call.eventDelay));
230
- }
231
-
232
- const type = event.type as string;
233
- const method = sdkEventToNotification(type);
234
- const params = sdkEventToParams(event, threadId, turnId);
235
-
236
- this.emitNotification(method, params);
237
- }
238
- }
239
-
240
- /** Replay a title generation call as notifications (item/completed + turn/completed). */
241
- private async replayTitleCall(call: TitleCall, threadId: string, turnId: string): Promise<void> {
242
- // Simulate: agent_message item started → completed → turn completed
243
- this.emitNotification('item/started', {
244
- threadId,
245
- turnId,
246
- item: { id: 'title_item', type: 'agent_message', text: '' },
247
- });
248
-
249
- this.emitNotification('item/completed', {
250
- threadId,
251
- turnId,
252
- item: { id: 'title_item', type: 'agent_message', text: call.result.finalResponse },
253
- });
254
-
255
- this.emitNotification('turn/completed', {
256
- threadId,
257
- turnId,
258
- });
259
- }
260
-
261
- /** Emit a notification to all registered handlers for the method. */
262
- private emitNotification(method: string, params: unknown): void {
263
- const handlers = this.notificationHandlers.get(method);
264
- if (handlers) {
265
- for (const handler of handlers) {
266
- handler(params);
267
- }
268
- }
269
- this.events.emit('notification', method, params);
270
- }
271
- };
272
- }
@@ -1,110 +0,0 @@
1
- /**
2
- * Test app factory for integration tests.
3
- *
4
- * Sets up a Fastify instance with all route handlers registered, using
5
- * an in-memory SQLite database. The `app-server-client.ts` module is mocked
6
- * by the test file (not here) using `createAppServerMock(fixture)`.
7
- *
8
- * Usage in a test file:
9
- * ```ts
10
- * vi.mock('../codex/app-server-client.ts', () => ({ AppServerClient: createAppServerMock(fixture) }));
11
- * vi.mock('../../ws/index.ts', () => ({ ...realWs, broadcast: mockBroadcast }));
12
- * const { app, db } = await createTestApp();
13
- * ```
14
- */
15
-
16
- import Fastify, { type FastifyInstance } from 'fastify';
17
- import type Database from 'better-sqlite3';
18
- import { initDb } from '../../db/index.ts';
19
- import { initWs } from '../../ws/index.ts';
20
- import { registerSessionRoutes } from '../../routes/sessions.ts';
21
- import { registerTurnRoutes } from '../../routes/turns.ts';
22
- import { registerThreadRoutes } from '../../routes/threads.ts';
23
- import { registerWorkspaceRoutes } from '../../routes/workspaces.ts';
24
- import { clearAllProviders } from '../../providers/registry.ts';
25
- import '../../providers/index.ts'; // register providers for integration tests
26
-
27
- export interface TestApp {
28
- app: FastifyInstance;
29
- db: Database.Database;
30
- /** Close the Fastify instance and close the DB. */
31
- cleanup: () => Promise<void>;
32
- }
33
-
34
- /**
35
- * Create a test Fastify app with all routes and an in-memory DB.
36
- *
37
- * @returns `{ app, db, cleanup }`. Call `cleanup()` in `afterEach`.
38
- */
39
- export async function createTestApp(): Promise<TestApp> {
40
- const db = initDb(':memory:');
41
-
42
- const app = Fastify();
43
-
44
- await registerSessionRoutes(app);
45
- await registerTurnRoutes(app);
46
- await registerThreadRoutes(app);
47
- await registerWorkspaceRoutes(app);
48
-
49
- initWs();
50
-
51
- return {
52
- app,
53
- db,
54
- cleanup: async () => {
55
- clearAllProviders();
56
- await app.close();
57
- db.close();
58
- },
59
- };
60
- }
61
-
62
- /**
63
- * Wait for a turn to reach a terminal status by polling the DB.
64
- *
65
- * `startTurn()` is fire-and-forget — the HTTP POST returns immediately.
66
- * Integration tests must wait for the async turn to finish before
67
- * asserting on DB state or WS broadcasts.
68
- *
69
- * @param db — The in-memory DB instance.
70
- * @param turnId — The turn ID to poll.
71
- * @param timeoutMs — Max wait time (default 5000ms).
72
- * @throws If the turn does not reach a terminal status within the timeout.
73
- */
74
- export async function waitForTurn(db: Database.Database, turnId: string, timeoutMs = 5000): Promise<void> {
75
- const start = Date.now();
76
- while (Date.now() - start < timeoutMs) {
77
- const row = db.prepare('SELECT status FROM turns WHERE id = ?').get(turnId) as { status: string } | undefined;
78
- if (!row) {
79
- throw new Error(`Turn ${turnId} not found in DB`);
80
- }
81
- if (row.status === 'completed' || row.status === 'failed' || row.status === 'aborted') {
82
- return;
83
- }
84
- await new Promise((r) => setTimeout(r, 50));
85
- }
86
- throw new Error(`Turn ${turnId} did not complete within ${timeoutMs}ms`);
87
- }
88
-
89
- /** Insert a session row with sensible defaults for integration tests. */
90
- export function insertTestSession(db: Database.Database, id: string, overrides: Record<string, unknown> = {}): void {
91
- const now = new Date().toISOString();
92
- db.prepare(
93
- `INSERT INTO sessions (id, title, runtime_type, model, model_reasoning_effort, cwd, external_thread_id, status, is_running, lifecycle, has_unreviewed, created_at, updated_at)
94
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
95
- ).run(
96
- id,
97
- (overrides['title'] as string | null) ?? null,
98
- (overrides['runtime_type'] as string) ?? 'codex',
99
- (overrides['model'] as string | null) ?? null,
100
- (overrides['model_reasoning_effort'] as string | null) ?? null,
101
- (overrides['cwd'] as string | null) ?? null,
102
- (overrides['external_thread_id'] as string | null) ?? null,
103
- (overrides['status'] as string) ?? 'active',
104
- (overrides['is_running'] as number) ?? 0,
105
- (overrides['lifecycle'] as string) ?? 'working',
106
- (overrides['has_unreviewed'] as number) ?? 0,
107
- (overrides['created_at'] as string) ?? now,
108
- (overrides['updated_at'] as string) ?? now,
109
- );
110
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Broadcast capture helper for integration tests.
3
- *
4
- * Replaces the real `broadcast()` function in `ws/index.ts` with a spy
5
- * that records every call. This lets integration tests assert on the
6
- * exact sequence of WS events without connecting a real WebSocket client.
7
- */
8
-
9
- export interface CapturedBroadcast {
10
- event: string;
11
- data: unknown;
12
- }
13
-
14
- /** A list of captured broadcast calls, populated by the mock. */
15
- export const capturedBroadcasts: CapturedBroadcast[] = [];
16
-
17
- /** Clear all captured broadcasts. Call in `beforeEach`. */
18
- export function clearBroadcasts(): void {
19
- capturedBroadcasts.length = 0;
20
- }
21
-
22
- /**
23
- * Mock broadcast function — records the call into `capturedBroadcasts`.
24
- * Drop-in replacement for the real `broadcast()` in `ws/index.ts`.
25
- */
26
- export function mockBroadcast(event: string, data: unknown): void {
27
- capturedBroadcasts.push({ event, data });
28
- }
29
-
30
- /**
31
- * Assert that broadcasts contain a specific event type.
32
- * @param event — The event name to find (e.g. 'turn:started').
33
- * @returns The first matching broadcast's data.
34
- * @throws If no matching broadcast is found.
35
- */
36
- export function findBroadcast(event: string): unknown {
37
- const found = capturedBroadcasts.find((b) => b.event === event);
38
- if (!found) {
39
- const events = capturedBroadcasts.map((b) => b.event).join(', ');
40
- throw new Error(`Expected broadcast "${event}" not found. Actual broadcasts: [${events}]`);
41
- }
42
- return found.data;
43
- }
44
-
45
- /**
46
- * Assert the ordered sequence of broadcast event names.
47
- * @param expected — Array of event names in expected order.
48
- */
49
- export function expectBroadcastSequence(expected: string[]): void {
50
- const actual = capturedBroadcasts.map((b) => b.event);
51
- if (actual.length < expected.length) {
52
- throw new Error(
53
- `Expected ${expected.length} broadcasts but got ${actual.length}. ` +
54
- `Expected: [${expected.join(', ')}]. Actual: [${actual.join(', ')}]`,
55
- );
56
- }
57
- for (let i = 0; i < expected.length; i++) {
58
- if (actual[i] !== expected[i]) {
59
- throw new Error(
60
- `Broadcast ${i}: expected "${expected[i]}" but got "${actual[i]}". ` + `Full actual: [${actual.join(', ')}]`,
61
- );
62
- }
63
- }
64
- }
@@ -1,133 +0,0 @@
1
- /**
2
- * Integration test: item lifecycle across multiple item types.
3
- *
4
- * Verifies that handleEvent correctly processes all item types through
5
- * item-mapper, including status transitions, thoughts accumulation,
6
- * and WS broadcasts for each item event.
7
- *
8
- * Uses HTTP POST to trigger the turn (fire-and-forget startTurn).
9
- */
10
-
11
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
12
- import { readFileSync } from 'node:fs';
13
- import { resolve } from 'node:path';
14
- import type Database from 'better-sqlite3';
15
- import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
16
- import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
17
- import type { TestApp } from './helpers/test-app.ts';
18
-
19
- const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/multi-item-turn.json'), 'utf-8')) as Fixture;
20
-
21
- vi.mock('../codex/app-server-client.ts', () => ({
22
- AppServerClient: createAppServerMock(fixture),
23
- }));
24
-
25
- vi.mock('../ws/index.ts', async (importOriginal) => {
26
- const actual = (await importOriginal()) as Record<string, unknown>;
27
- return {
28
- ...actual,
29
- broadcast: vi.fn((event: string, data: unknown) => {
30
- capturedBroadcasts.push({ event, data });
31
- }),
32
- };
33
- });
34
-
35
- const { getDb } = await import('../db/index.ts');
36
- const { createTestApp, waitForTurn } = await import('./helpers/test-app.ts');
37
-
38
- describe('Integration: item lifecycle', () => {
39
- let testApp: TestApp;
40
-
41
- beforeEach(async () => {
42
- vi.clearAllMocks();
43
- clearBroadcasts();
44
- testApp = await createTestApp();
45
- });
46
-
47
- afterEach(async () => {
48
- await testApp.cleanup();
49
- });
50
-
51
- it('processes reasoning, command, file_change, agent_message items correctly', async () => {
52
- const db: Database.Database = getDb();
53
-
54
- // Create session
55
- const createRes = await testApp.app.inject({
56
- method: 'POST',
57
- url: '/api/sessions',
58
- payload: {},
59
- });
60
- const session = createRes.json();
61
-
62
- // Submit turn via HTTP
63
- const turnRes = await testApp.app.inject({
64
- method: 'POST',
65
- url: `/api/sessions/${session.id}/turns`,
66
- payload: { user_prompt: 'List files and create a test file' },
67
- });
68
- const turn = turnRes.json();
69
-
70
- await waitForTurn(db, turn.id);
71
-
72
- // Assert items in DB — all 4 types mapped correctly
73
- const items = db.prepare('SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC').all(turn.id) as {
74
- type: string;
75
- data: string;
76
- status: string;
77
- }[];
78
-
79
- expect(items).toHaveLength(4);
80
-
81
- // Reasoning
82
- expect(items[0].type).toBe('reasoning');
83
- expect(items[0].status).toBe('completed');
84
- expect(JSON.parse(items[0].data)).toEqual({
85
- text: 'I need to list files first, then create a test file.',
86
- });
87
-
88
- // Command execution
89
- expect(items[1].type).toBe('command_execution');
90
- expect(items[1].status).toBe('completed');
91
- expect(JSON.parse(items[1].data)).toEqual({
92
- command: 'ls -la',
93
- aggregated_output: 'total 0\ndrwxr-xr-x 2 user staff 64 Jan 1 00:00 .',
94
- exit_code: 0,
95
- status: 'completed',
96
- });
97
-
98
- // File change
99
- expect(items[2].type).toBe('file_change');
100
- expect(items[2].status).toBe('completed');
101
- expect(JSON.parse(items[2].data)).toEqual({
102
- changes: [{ path: 'test.txt', change_type: 'added' }],
103
- status: 'completed',
104
- });
105
-
106
- // Agent message
107
- expect(items[3].type).toBe('agent_message');
108
- expect(items[3].status).toBe('completed');
109
- expect(JSON.parse(items[3].data)).toEqual({
110
- text: 'I listed the files and created test.txt for you.',
111
- });
112
-
113
- // Assert turn-level fields updated from items
114
- const dbTurn = db.prepare('SELECT thoughts, agent_response FROM turns WHERE id = ?').get(turn.id) as {
115
- thoughts: string | null;
116
- agent_response: string | null;
117
- };
118
- expect(dbTurn.thoughts).toBe('I need to list files first, then create a test file.');
119
- expect(dbTurn.agent_response).toBe('I listed the files and created test.txt for you.');
120
-
121
- // Assert WS broadcasts — 4 item:started + 4 item:completed
122
- const startedCount = capturedBroadcasts.filter((b) => b.event === 'item:started').length;
123
- const completedCount = capturedBroadcasts.filter((b) => b.event === 'item:completed').length;
124
- expect(startedCount).toBe(4);
125
- expect(completedCount).toBe(4);
126
-
127
- // Verify item:completed broadcasts contain correct item types
128
- const completedTypes = capturedBroadcasts
129
- .filter((b) => b.event === 'item:completed')
130
- .map((b) => (b.data as { item: { type: string } }).item.type);
131
- expect(completedTypes).toEqual(['reasoning', 'command_execution', 'file_change', 'agent_message']);
132
- });
133
- });
@@ -1,102 +0,0 @@
1
- /**
2
- * Integration test: MCP tool call item type.
3
- *
4
- * Verifies that mcp_tool_call items are correctly mapped via item-mapper
5
- * and stored in DB with the right data shape.
6
- *
7
- * Uses HTTP POST to trigger the turn (fire-and-forget startTurn).
8
- */
9
-
10
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
11
- import { readFileSync } from 'node:fs';
12
- import { resolve } from 'node:path';
13
- import type Database from 'better-sqlite3';
14
- import { createAppServerMock, type Fixture } from './helpers/app-server-mock.ts';
15
- import { clearBroadcasts, capturedBroadcasts } from './helpers/ws-capture.ts';
16
- import type { TestApp } from './helpers/test-app.ts';
17
-
18
- const fixture = JSON.parse(readFileSync(resolve(__dirname, '__fixtures__/mcp-tool-call.json'), 'utf-8')) as Fixture;
19
-
20
- vi.mock('../codex/app-server-client.ts', () => ({
21
- AppServerClient: createAppServerMock(fixture),
22
- }));
23
-
24
- vi.mock('../ws/index.ts', async (importOriginal) => {
25
- const actual = (await importOriginal()) as Record<string, unknown>;
26
- return {
27
- ...actual,
28
- broadcast: vi.fn((event: string, data: unknown) => {
29
- capturedBroadcasts.push({ event, data });
30
- }),
31
- };
32
- });
33
-
34
- const { getDb } = await import('../db/index.ts');
35
- const { createTestApp, waitForTurn } = await import('./helpers/test-app.ts');
36
-
37
- describe('Integration: MCP tool call', () => {
38
- let testApp: TestApp;
39
-
40
- beforeEach(async () => {
41
- vi.clearAllMocks();
42
- clearBroadcasts();
43
- testApp = await createTestApp();
44
- });
45
-
46
- afterEach(async () => {
47
- await testApp.cleanup();
48
- });
49
-
50
- it('maps mcp_tool_call item with server, tool, arguments, result', async () => {
51
- const db: Database.Database = getDb();
52
-
53
- // Create session
54
- const createRes = await testApp.app.inject({
55
- method: 'POST',
56
- url: '/api/sessions',
57
- payload: {},
58
- });
59
- const session = createRes.json();
60
-
61
- // Submit turn via HTTP
62
- const turnRes = await testApp.app.inject({
63
- method: 'POST',
64
- url: `/api/sessions/${session.id}/turns`,
65
- payload: { user_prompt: 'Search the web for cats' },
66
- });
67
- const turn = turnRes.json();
68
-
69
- await waitForTurn(db, turn.id);
70
-
71
- const items = db.prepare('SELECT * FROM items WHERE turn_id = ? ORDER BY created_at ASC').all(turn.id) as {
72
- type: string;
73
- data: string;
74
- status: string;
75
- }[];
76
- expect(items).toHaveLength(2);
77
-
78
- // MCP tool call
79
- expect(items[0].type).toBe('mcp_tool_call');
80
- expect(items[0].status).toBe('completed');
81
- expect(JSON.parse(items[0].data)).toEqual({
82
- server: 'web-search',
83
- tool: 'search',
84
- arguments: { query: 'cats' },
85
- result: { urls: ['https://example.com/cats'] },
86
- error: null,
87
- status: 'completed',
88
- });
89
-
90
- // Agent message
91
- expect(items[1].type).toBe('agent_message');
92
- expect(items[1].status).toBe('completed');
93
-
94
- // Verify WS: mcp item:started has in_progress status
95
- const mcpStarted = capturedBroadcasts.find(
96
- (b) => b.event === 'item:started' && (b.data as { item: { type: string } }).item.type === 'mcp_tool_call',
97
- );
98
- expect(mcpStarted).toBeDefined();
99
- const mcpStartedData = mcpStarted!.data as { item: { status: string } };
100
- expect(mcpStartedData.item.status).toBe('in_progress');
101
- });
102
- });