@kabmo-labs/kabmo 0.24.0 → 0.26.0

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/dist/client/index.html +1 -1
  2. package/dist/client/index.js +585 -512
  3. package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
  4. package/dist/client/static/js/index-p2yw9ywf.css +1 -0
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/index.tsx +59 -2
  15. package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
  16. package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
  17. package/src/client/components/common/session-branch/index.tsx +169 -0
  18. package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
  19. package/src/client/components/common/session-branch/style.ts +29 -0
  20. package/src/client/components/common/session-row/StatusSlot.tsx +17 -5
  21. package/src/client/components/common/session-row/index.tsx +28 -3
  22. package/src/client/components/common/session-row/session-row.test.tsx +11 -0
  23. package/src/client/components/common/session-state-provider/index.tsx +1 -1
  24. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  25. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
  26. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
  27. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
  28. package/src/client/components/layout/session-sidebar/SessionItem.tsx +35 -7
  29. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
  30. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
  31. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
  32. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  33. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
  34. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
  35. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
  36. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
  37. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
  38. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
  39. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
  40. package/src/client/components/settings/Sidebar.tsx +1 -1
  41. package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
  42. package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
  43. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
  44. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
  45. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
  46. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  47. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  48. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
  49. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  50. package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
  51. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
  52. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
  53. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
  55. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
  56. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
  58. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
  59. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
  60. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  61. package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
  62. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
  63. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
  64. package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
  65. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  66. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  67. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  68. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  69. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  70. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  71. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  72. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  73. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  74. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  75. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  76. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  77. package/src/client/data/settings/omp-schema.json +1 -1
  78. package/src/client/data/theme/terminal.test.ts +25 -0
  79. package/src/client/data/theme/terminal.ts +96 -79
  80. package/src/client/hooks/chat/composer/items.test.ts +31 -26
  81. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  82. package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
  83. package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
  84. package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
  85. package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
  86. package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
  87. package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
  88. package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
  89. package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
  90. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  91. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  92. package/src/client/hooks/chat/omp/run-switch.ts +1 -1
  93. package/src/client/hooks/chat/omp/session-list.tsx +4 -0
  94. package/src/client/hooks/chat/subagents/roster.ts +122 -0
  95. package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
  96. package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
  97. package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
  98. package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
  99. package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
  100. package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
  101. package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
  102. package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
  103. package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
  104. package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
  105. package/src/client/hooks/chat/timeline/modes.ts +42 -29
  106. package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
  107. package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
  108. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  109. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  110. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  111. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  112. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  113. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  114. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  115. package/src/client/hooks/chat/timeline/send.ts +48 -133
  116. package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
  117. package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
  118. package/src/client/hooks/chat/timeline/use-fork-session.ts +58 -0
  119. package/src/client/hooks/models/use-harness-update.test.ts +286 -0
  120. package/src/client/hooks/models/use-harness-update.ts +250 -0
  121. package/src/client/hooks/ui/input-required-alert.ts +12 -5
  122. package/src/client/hooks/ui/notifications.ts +45 -0
  123. package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
  124. package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
  125. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  126. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  127. package/src/client/lib/native/open-session.ts +33 -0
  128. package/src/client/lib/notifications/os.test.ts +125 -0
  129. package/src/client/lib/notifications/os.ts +130 -0
  130. package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
  131. package/src/client/lib/router/open-session.test.ts +75 -0
  132. package/src/client/lib/router/open-session.ts +34 -0
  133. package/src/client/lib/session-tree.test.ts +50 -0
  134. package/src/client/lib/session-tree.ts +59 -0
  135. package/src/client/lib/signals.ts +5 -1
  136. package/src/client/main.tsx +6 -0
  137. package/src/client/tailwind.css +17 -11
  138. package/src/server/index.ts +2 -0
  139. package/src/server/lib/auth/guard.ts +10 -0
  140. package/src/server/lib/btw/session-copy.server.ts +6 -44
  141. package/src/server/lib/btw/session-copy.test.ts +2 -1
  142. package/src/server/lib/db/schema.ts +5 -0
  143. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  144. package/src/server/lib/db/seed.test.ts +1 -1
  145. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  146. package/src/server/lib/harness/acp/background-work.ts +320 -0
  147. package/src/server/lib/harness/acp/calls.ts +15 -1
  148. package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
  149. package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
  150. package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
  151. package/src/server/lib/harness/acp/client-fs.ts +131 -0
  152. package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
  153. package/src/server/lib/harness/acp/client-initialize.ts +84 -0
  154. package/src/server/lib/harness/acp/client.ts +33 -23
  155. package/src/server/lib/harness/acp/commands.test.ts +5 -5
  156. package/src/server/lib/harness/acp/commands.ts +14 -2
  157. package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
  158. package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
  159. package/src/server/lib/harness/acp/frames.ts +71 -158
  160. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  161. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  162. package/src/server/lib/harness/acp/mapper.test.ts +40 -0
  163. package/src/server/lib/harness/acp/mapper.ts +12 -0
  164. package/src/server/lib/harness/acp/permissions.ts +6 -0
  165. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  166. package/src/server/lib/harness/acp/prompt.ts +19 -3
  167. package/src/server/lib/harness/acp/protocol.ts +41 -2
  168. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  169. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  170. package/src/server/lib/harness/acp/session-facts.ts +1 -1
  171. package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
  172. package/src/server/lib/harness/acp/session-handshake.ts +110 -7
  173. package/src/server/lib/harness/acp/session-idle.ts +7 -6
  174. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  175. package/src/server/lib/harness/acp/session-notifications.ts +41 -2
  176. package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
  177. package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
  178. package/src/server/lib/harness/acp/session-permissions.ts +36 -0
  179. package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
  180. package/src/server/lib/harness/acp/session-requests.ts +89 -0
  181. package/src/server/lib/harness/acp/session-turns.ts +28 -8
  182. package/src/server/lib/harness/acp/session-usage.ts +4 -0
  183. package/src/server/lib/harness/acp/session-web-state.ts +30 -2
  184. package/src/server/lib/harness/acp/session.test-util.ts +42 -2
  185. package/src/server/lib/harness/acp/session.ts +115 -115
  186. package/src/server/lib/harness/acp/tool-calls.ts +223 -0
  187. package/src/server/lib/harness/acp/turn.test.ts +183 -0
  188. package/src/server/lib/harness/acp/turn.ts +102 -10
  189. package/src/server/lib/harness/acp/v2.test.ts +144 -0
  190. package/src/server/lib/harness/acp/v2.ts +220 -0
  191. package/src/server/lib/harness/acp/verbs.ts +58 -8
  192. package/src/server/lib/harness/launch.test.ts +25 -0
  193. package/src/server/lib/harness/launch.ts +24 -10
  194. package/src/server/lib/harness/session.ts +3 -0
  195. package/src/server/lib/harness/spawn.server.ts +15 -2
  196. package/src/server/lib/harness/update-job-store.test.ts +151 -0
  197. package/src/server/lib/harness/update-job-store.ts +115 -0
  198. package/src/server/lib/harness/update-job.server.ts +94 -0
  199. package/src/server/lib/harness/update-queue.server.ts +292 -0
  200. package/src/server/lib/harness/update-queue.test.ts +265 -0
  201. package/src/server/lib/harness/update-spawn.server.ts +96 -0
  202. package/src/server/lib/harness/update-worker.test.ts +153 -0
  203. package/src/server/lib/harness/update-worker.ts +202 -0
  204. package/src/server/lib/lifecycle/after-listen.ts +9 -0
  205. package/src/server/lib/lifecycle/paths.ts +28 -0
  206. package/src/server/lib/omp/rpc/manager.ts +5 -5
  207. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  208. package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
  209. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  210. package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
  211. package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
  212. package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
  213. package/src/server/lib/omp/session/delete.server.ts +5 -0
  214. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  215. package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
  216. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  217. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  218. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  219. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  220. package/src/server/lib/sessions/answers.server.ts +37 -0
  221. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  222. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  223. package/src/server/lib/sessions/fork.server.test.ts +277 -0
  224. package/src/server/lib/sessions/fork.server.ts +329 -0
  225. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  226. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  227. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  228. package/src/server/lib/sessions/notify.server.ts +212 -0
  229. package/src/server/lib/sessions/relation-types.ts +76 -0
  230. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  231. package/src/server/lib/sessions/relations.server.ts +337 -0
  232. package/src/server/lib/sessions/resolve.server.ts +106 -0
  233. package/src/server/lib/sessions/schema.server.ts +82 -0
  234. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  235. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  236. package/src/server/lib/sessions/spawn.server.test.ts +237 -0
  237. package/src/server/lib/sessions/spawn.server.ts +335 -0
  238. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  239. package/src/server/lib/terminal/output.test.ts +2 -2
  240. package/src/server/lib/terminal/output.ts +1 -1
  241. package/src/server/lib/terminal/resize.test.ts +99 -0
  242. package/src/server/lib/terminal/runtime.server.ts +26 -6
  243. package/src/server/lib/terminal/send-result.test.ts +18 -1
  244. package/src/server/lib/terminal/send-result.ts +26 -2
  245. package/src/server/lib/terminal/session.server.ts +6 -6
  246. package/src/server/lib/usage/new-api.test.ts +92 -0
  247. package/src/server/lib/usage/new-api.ts +131 -0
  248. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  249. package/src/server/lib/usage/provider-key.ts +33 -0
  250. package/src/server/lib/usage/providers.server.ts +10 -3
  251. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  252. package/src/server/lib/usage/vendor-http.ts +41 -0
  253. package/src/server/lib/usage/window.ts +55 -0
  254. package/src/server/routes/agent/command.ts +14 -1
  255. package/src/server/routes/agent/harness-command.ts +12 -5
  256. package/src/server/routes/agent/new.ts +15 -0
  257. package/src/server/routes/chat/stream.ts +7 -2
  258. package/src/server/routes/harness/add-provider.test.ts +9 -1
  259. package/src/server/routes/harness/import-action.ts +4 -0
  260. package/src/server/routes/harness/import.test.ts +1 -1
  261. package/src/server/routes/harness/index.ts +5 -1
  262. package/src/server/routes/harness/update-status.ts +32 -0
  263. package/src/server/routes/harness/update.test.ts +156 -0
  264. package/src/server/routes/harness/update.ts +64 -147
  265. package/src/server/routes/sessions/answer.ts +24 -0
  266. package/src/server/routes/sessions/batch-delete.ts +11 -5
  267. package/src/server/routes/sessions/body-readers.ts +43 -0
  268. package/src/server/routes/sessions/delete.ts +4 -2
  269. package/src/server/routes/sessions/fork.ts +89 -0
  270. package/src/server/routes/sessions/index.ts +14 -0
  271. package/src/server/routes/sessions/relations.ts +85 -0
  272. package/src/server/routes/sessions/routes.test.ts +1 -2
  273. package/src/server/routes/sessions/session.ts +23 -0
  274. package/src/server/routes/sessions/spawn.ts +137 -0
  275. package/src/server/routes/terminal/ws.ts +3 -3
  276. package/src/shared/lib/chat/composer/client.ts +31 -2
  277. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  278. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  279. package/src/shared/lib/chat/notice-text.ts +1 -1
  280. package/src/shared/lib/chat/omp/agent-events.ts +11 -0
  281. package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
  282. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  283. package/src/shared/lib/code/ansi.ts +1 -1
  284. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  285. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  286. package/src/shared/lib/harness/mode-signal.ts +20 -0
  287. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  288. package/src/shared/lib/harness/providers.ts +35 -1
  289. package/src/shared/lib/harness/session-modes.ts +24 -0
  290. package/src/shared/lib/harness/update-job.ts +80 -0
  291. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  292. package/src/shared/lib/harness/update-plan.ts +12 -4
  293. package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
  294. package/src/shared/lib/notifications/outcomes.test.ts +96 -0
  295. package/src/shared/lib/notifications/outcomes.ts +64 -0
  296. package/src/shared/lib/notifications/settings.test.ts +49 -0
  297. package/src/shared/lib/notifications/settings.ts +34 -0
  298. package/src/shared/lib/omp/session/default-title.ts +5 -4
  299. package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
  300. package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
  301. package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
  302. package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
  303. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  304. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  305. package/src/shared/lib/settings/defaults.ts +3 -0
  306. package/src/shared/lib/theme/catalog.test.ts +13 -9
  307. package/src/shared/lib/theme/color.test.ts +2 -2
  308. package/src/shared/lib/theme/color.ts +4 -4
  309. package/src/shared/lib/theme/theme.test.ts +1 -1
  310. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  311. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  312. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  313. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  314. package/src/shared/types/chat.ts +1 -1
  315. package/src/shared/types/harness-update.ts +89 -0
  316. package/src/shared/types/omp/agent.ts +19 -2
  317. package/src/shared/types/realtime.ts +2 -0
  318. package/src/shared/types/settings/state.ts +10 -0
  319. package/src/shared/types/workspace.ts +8 -0
  320. package/src/test-support/fake-omp-fork.ts +16 -2
  321. package/src/test-support/harness-table.test-util.ts +31 -1
  322. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  323. package/src/client/components/common/subagent-list/index.tsx +0 -165
  324. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  325. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /** The notification preferences are opt-in, and only the boolean `true` opts in. */
7
+
8
+ import { afterEach, describe, expect, test } from 'bun:test';
9
+
10
+ import { primeKabmoSettings } from '@/shared/lib/settings/client';
11
+ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
12
+ import {
13
+ isNotificationEnabled,
14
+ NOTIFICATION_SETTING_KEYS,
15
+ type NotificationEvent,
16
+ } from '@/shared/lib/notifications/settings';
17
+
18
+ const EVENTS: NotificationEvent[] = ['finish', 'ask', 'error'];
19
+
20
+ afterEach(() => {
21
+ primeKabmoSettings({});
22
+ });
23
+
24
+ describe('notification settings', () => {
25
+ test('every event is off on a fresh install', () => {
26
+ primeKabmoSettings({});
27
+ for (const event of EVENTS) expect(isNotificationEnabled(event)).toBe(false);
28
+ });
29
+
30
+ test('the shipped defaults are all false', () => {
31
+ // The defaults object is what the settings modal seeds from, so a `true`
32
+ // here would silently turn notifications on for a new install.
33
+ for (const event of EVENTS) {
34
+ expect(DEFAULT_SETTINGS[NOTIFICATION_SETTING_KEYS[event] as keyof typeof DEFAULT_SETTINGS]).toBe(false);
35
+ }
36
+ });
37
+
38
+ test('each event reads its own key', () => {
39
+ primeKabmoSettings({ notifyOnFinish: true, notifyOnAsk: false, notifyOnError: true });
40
+ expect(isNotificationEnabled('finish')).toBe(true);
41
+ expect(isNotificationEnabled('ask')).toBe(false);
42
+ expect(isNotificationEnabled('error')).toBe(true);
43
+ });
44
+
45
+ test('a truthy non-boolean does not opt in', () => {
46
+ primeKabmoSettings({ notifyOnFinish: 'yes' });
47
+ expect(isNotificationEnabled('finish')).toBe(false);
48
+ });
49
+ });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which system notification each event is allowed to send.
8
+ *
9
+ * All three default to FALSE, and only the literal `true` enables one. That
10
+ * strictness is the feature: an install that predates these keys has no value
11
+ * at all, and a truthy string from a hand-edited settings blob must not opt the
12
+ * user into OS notifications they never chose. It also keeps a fresh install
13
+ * from being prompted for permission by a shell on first launch.
14
+ */
15
+
16
+ import { readKabmoSetting } from '@/shared/lib/settings/client';
17
+
18
+ /** The events a notification setting exists for. */
19
+ export type NotificationEvent = 'finish' | 'ask' | 'error';
20
+
21
+ /** The stored setting key for each event. */
22
+ export const NOTIFICATION_SETTING_KEYS: Readonly<Record<NotificationEvent, string>> = {
23
+ finish: 'notifyOnFinish',
24
+ ask: 'notifyOnAsk',
25
+ error: 'notifyOnError',
26
+ };
27
+
28
+ /** Whether the user asked for a system notification for `event`. */
29
+ export function isNotificationEnabled(
30
+ event: NotificationEvent,
31
+ appSettings?: Record<string, any>,
32
+ ): boolean {
33
+ return readKabmoSetting<boolean>(NOTIFICATION_SETTING_KEYS[event], appSettings) === true;
34
+ }
@@ -24,10 +24,11 @@ function pad2(value: number): string {
24
24
  }
25
25
 
26
26
  /** `New Session - yyyy-mm-ddThh:mm:ss` (local time); plain "New Session" when
27
- * the date is invalid. */
28
- export function formatNewSessionTitle(date: Date = new Date()): string {
29
- if (Number.isNaN(date.getTime())) return 'New Session';
30
- return `New Session - ${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}T${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`;
27
+ * the date is invalid. A child passes its own label (`New Child`), so a
28
+ * pending row says what it is before it has a transcript. */
29
+ export function formatNewSessionTitle(date: Date = new Date(), label = 'New Session'): string {
30
+ if (Number.isNaN(date.getTime())) return label;
31
+ return `${label} - ${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}T${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`;
31
32
  }
32
33
 
33
34
  /** True for client-side pending session ids (`new-<epochMs>`, pre-spawn). */
@@ -79,13 +79,14 @@ describe('contentProfile', () => {
79
79
  });
80
80
 
81
81
  describe('migrateSessionStreamStateColumns', () => {
82
- test('issues the additive owner, provider, and model columns', async () => {
82
+ test('issues the additive owner, provider, model and failure columns', async () => {
83
83
  const statements: string[] = [];
84
84
  await migrateSessionStreamStateColumns({ exec: async (sql: string) => { statements.push(sql); } } as never);
85
85
  expect(statements).toEqual([
86
86
  'ALTER TABLE session_stream_state ADD COLUMN owner_pid INTEGER;',
87
87
  'ALTER TABLE session_stream_state ADD COLUMN model_provider TEXT;',
88
88
  'ALTER TABLE session_stream_state ADD COLUMN model_id TEXT;',
89
+ 'ALTER TABLE session_stream_state ADD COLUMN failure TEXT;',
89
90
  ]);
90
91
  });
91
92
 
@@ -96,7 +97,7 @@ describe('migrateSessionStreamStateColumns', () => {
96
97
  await migrateSessionStreamStateColumns({
97
98
  exec: async () => { attempts += 1; throw new Error('duplicate column name: owner_pid'); },
98
99
  } as never);
99
- expect(attempts).toBe(3);
100
+ expect(attempts).toBe(4);
100
101
  });
101
102
  });
102
103
 
@@ -32,4 +32,8 @@ export async function migrateSessionStreamStateColumns(db: DbClient): Promise<vo
32
32
  // stream status — instead of re-deriving it from the session JSONL.
33
33
  await addColumn(db, 'ALTER TABLE session_stream_state ADD COLUMN model_provider TEXT;');
34
34
  await addColumn(db, 'ALTER TABLE session_stream_state ADD COLUMN model_id TEXT;');
35
+ // Why a terminal `finish` row ended: the notification's own reason, and the
36
+ // only durable place a background tab can learn that a run failed. NULL is a
37
+ // normal stop, so every existing row keeps its meaning.
38
+ await addColumn(db, 'ALTER TABLE session_stream_state ADD COLUMN failure TEXT;');
35
39
  }
@@ -77,6 +77,25 @@ describe('run model on the stream row', () => {
77
77
  expect((await loadStreamStates()).s1?.model).toEqual({ provider: 'openai', modelId: 'gpt-5' });
78
78
  });
79
79
 
80
+ test('a failed finish keeps its reason, and the next run clears it', async () => {
81
+ await markStreamStatus('s1', 'stream');
82
+ await markStreamStatus('s1', 'finish', undefined, ' 401 invalid api key ');
83
+ expect((await loadStreamStates()).s1).toEqual({
84
+ status: 'finish',
85
+ failure: '401 invalid api key',
86
+ });
87
+
88
+ // A new run must not inherit the previous run's failure: otherwise its
89
+ // normal end would be announced as an error.
90
+ await markStreamStatus('s1', 'stream');
91
+ expect((await loadStreamStates()).s1).toEqual({ status: 'stream' });
92
+ });
93
+
94
+ test('a reason is stored only on a finish row', async () => {
95
+ await markStreamStatus('s1', 'abort', undefined, 'not a finish');
96
+ expect((await loadStreamStates()).s1).toEqual({ status: 'abort' });
97
+ });
98
+
80
99
  test('a row written without a model reports none, and the status view is status-only', async () => {
81
100
  await markStreamStatus('s2', 'abort');
82
101
  expect((await loadStreamStates()).s2).toEqual({ status: 'abort' });
@@ -29,6 +29,11 @@
29
29
  * second instance opening its sidebar judged the first instance's live run by
30
30
  * its own empty registry and cleared a spinner that was still working.
31
31
  *
32
+ * A terminal `finish` may also carry `failure` — the agent's own reason when
33
+ * the run failed. It rides this row for the same reason the model does: a tab
34
+ * that never opened the session has no other durable source, and the failure
35
+ * notification is only useful with the reason. A new `stream` write clears it.
36
+ *
32
37
  * Every write raises the realtime `stream-status` signal, which is what the
33
38
  * socket's `sidebar:status` topic publishes from. All writes are
34
39
  * fire-and-forget: a status write must never fail a prompt.
@@ -49,6 +54,13 @@ export interface SessionRunModel {
49
54
  export interface SessionStreamState {
50
55
  status: SessionStreamStatus;
51
56
  model?: SessionRunModel;
57
+ /**
58
+ * Why a terminal `finish` run failed, when the agent said. NULL/absent is a
59
+ * normal stop. It rides this row because a tab that never opened the session
60
+ * has no other durable source for the reason, and the notification that says
61
+ * "this run failed" is only useful with it.
62
+ */
63
+ failure?: string;
52
64
  }
53
65
 
54
66
  /**
@@ -64,6 +76,7 @@ export async function markStreamStatus(
64
76
  sessionId: string,
65
77
  status: SessionStreamStatus,
66
78
  model?: SessionRunModel | null,
79
+ failure?: string | null,
67
80
  ): Promise<void> {
68
81
  try {
69
82
  const db = await getDb();
@@ -71,16 +84,20 @@ export async function markStreamStatus(
71
84
  // belongs to no process, and leaving a pid on it would invite a later read
72
85
  // to judge the badge by the liveness of a process it never concerned.
73
86
  const ownerPid = status === 'stream' ? process.pid : null;
87
+ // A live or aborted row never carries a reason, and a new `stream` write
88
+ // clears the previous run's: the next terminal settle must not inherit it.
89
+ const reason = status === 'finish' && typeof failure === 'string' ? failure.trim() : '';
74
90
  await db.run(
75
- `INSERT INTO session_stream_state (session_id, status, owner_pid, model_provider, model_id, updated_at)
76
- VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
91
+ `INSERT INTO session_stream_state (session_id, status, owner_pid, model_provider, model_id, failure, updated_at)
92
+ VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
77
93
  ON CONFLICT(session_id) DO UPDATE SET
78
94
  status = excluded.status,
79
95
  owner_pid = excluded.owner_pid,
80
96
  model_provider = COALESCE(excluded.model_provider, session_stream_state.model_provider),
81
97
  model_id = COALESCE(excluded.model_id, session_stream_state.model_id),
98
+ failure = excluded.failure,
82
99
  updated_at = excluded.updated_at`,
83
- [sessionId, status, ownerPid, model?.provider ?? null, model?.modelId ?? null],
100
+ [sessionId, status, ownerPid, model?.provider ?? null, model?.modelId ?? null, reason || null],
84
101
  );
85
102
  // The signal bus has no imports of its own, so this edge cannot close a
86
103
  // cycle: the realtime layer subscribes to it, and this module only raises.
@@ -168,20 +185,23 @@ export async function markStreamSeen(sessionId: string): Promise<boolean> {
168
185
  export async function loadStreamStates(): Promise<Record<string, SessionStreamState>> {
169
186
  try {
170
187
  const db = await getDb();
171
- const rows = (await db.all('SELECT session_id, status, model_provider, model_id FROM session_stream_state')) as {
188
+ const rows = (await db.all('SELECT session_id, status, model_provider, model_id, failure FROM session_stream_state')) as {
172
189
  session_id: string;
173
190
  status: string;
174
191
  model_provider: string | null;
175
192
  model_id: string | null;
193
+ failure: string | null;
176
194
  }[];
177
195
  const map: Record<string, SessionStreamState> = {};
178
196
  for (const row of rows) {
179
197
  if (row.status !== 'stream' && row.status !== 'finish' && row.status !== 'abort') continue;
198
+ const failure = typeof row.failure === 'string' ? row.failure.trim() : '';
180
199
  map[row.session_id] = {
181
200
  status: row.status,
182
201
  ...(row.model_provider && row.model_id
183
202
  ? { model: { provider: row.model_provider, modelId: row.model_id } }
184
203
  : {}),
204
+ ...(failure ? { failure } : {}),
185
205
  };
186
206
  }
187
207
  return map;
@@ -25,6 +25,17 @@ describe('the idle ladder', () => {
25
25
  expect(waitIdleOf('No service finished within 30s. Read proc:// for status.')).toEqual({ windowMs: 30_000 });
26
26
  });
27
27
 
28
+ test('reads the 18.18.6 sentence, which names the next rung instead of ending', () => {
29
+ // 18.18.6 appends a back-to-back hint after a semicolon, and words a
30
+ // timeout that watched jobs the same way (`No job finished …`). A regex
31
+ // demanding the period stopped matching, so both cards lost the idle chip.
32
+ expect(waitIdleOf('No reply within 5.0s; a back-to-back wait allows up to 10s.')).toEqual({ windowMs: 5_000 });
33
+ expect(waitIdleOf('No service finished within 10s; a back-to-back wait allows up to 30s. Read proc:// for status.'))
34
+ .toEqual({ windowMs: 10_000 });
35
+ expect(waitIdleOf('1 background job still running.\n\nNo job finished within 30s; a back-to-back wait allows up to 60s.'))
36
+ .toEqual({ windowMs: 30_000 });
37
+ });
38
+
28
39
  test('reads the streak omp names from the second idle wait on', () => {
29
40
  // `WAIT_NOTICE_RUNG` appends the notice whose span is the RUNNING TOTAL:
30
41
  // 5 s + 10 s, then + 30 s, then + 60 s, then + 300 s.
@@ -17,6 +17,12 @@
17
17
  * omp's prose, which is what this module parses. It lives beside `wait.ts`
18
18
  * rather than inside it because the card's parser (jobs, agents, messages) and
19
19
  * the outcomes omp words are separate subjects, and the file ceiling is real.
20
+ *
21
+ * 18.18.6 ends that sentence with the ladder's next rung — `No reply within
22
+ * 5.0s; a back-to-back wait allows up to 10s.` — and words a job-timeout return
23
+ * the same way (`No job finished within …`). The parser accepts both the old
24
+ * period and the new semicolon, because persisted sessions carry the older
25
+ * sentence.
20
26
  */
21
27
 
22
28
  import { formatToolMs } from '@/shared/lib/chat/tool/labels';
@@ -29,8 +35,12 @@ export const WAIT_LADDER_MS = [5_000, 10_000, 30_000, 60_000, 300_000] as const;
29
35
  /** A span in omp's `formatDuration` spelling: `250ms`, `5.0s`, `30s`, `1m45s`, `5m`, `2h5m`. */
30
36
  const OMP_DURATION = String.raw`(?:\d+d)?(?:\d+h)?(?:\d+m)?(?:[\d.]+s)?(?:\d+ms)?`;
31
37
 
32
- /** `No reply within 5.0s.` / `No service finished within 30s. Read proc:// for status.` */
33
- const WAIT_WINDOW_TEXT = new RegExp(`^No (?:reply|service finished) within (${OMP_DURATION})\\.`, 'm');
38
+ /** `No reply within 5.0s.` (≤18.18.3) and the 18.18.6 form
39
+ * `No job finished within 5.0s; a back-to-back wait allows up to 10s.` */
40
+ const WAIT_WINDOW_TEXT = new RegExp(
41
+ `^No (?:reply|job finished|service finished) within (${OMP_DURATION})(?:\\.|;)`,
42
+ 'm',
43
+ );
34
44
 
35
45
  /** `Nothing new after 15.0s of back-to-back waits.` — appended from the SECOND
36
46
  * consecutive idle wait, inside a `<system-notice>` block, and the only place
@@ -36,6 +36,9 @@ export const DEFAULT_SETTINGS = {
36
36
  autoSessionTitle: true,
37
37
  soundAlerts: true,
38
38
  chatCompletionSound: true,
39
+ notifyOnFinish: false,
40
+ notifyOnAsk: false,
41
+ notifyOnError: false,
39
42
  goalAuditEnabled: true,
40
43
  goalAuditModel: '',
41
44
  goalDefaultBudget: null,
@@ -23,7 +23,7 @@ import {
23
23
  } from '@/shared/lib/theme/catalog';
24
24
  import { themeStyleSheet } from '@/shared/lib/theme/css';
25
25
  import { mixHex, parseHexColor } from '@/shared/lib/theme/color';
26
- import { getXtermTheme } from '@/client/data/theme/terminal';
26
+ import { getTerminalTheme } from '@/client/data/theme/terminal';
27
27
 
28
28
  const COLOR_KEYS = ['canvas', 'paper', 'ink', 'error', 'success', 'info', 'warning', 'meta'] as const;
29
29
  const COLOR_VALUE = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|#[0-9a-f]{8})$/i;
@@ -143,24 +143,28 @@ describe('color math', () => {
143
143
 
144
144
  describe('terminal palette', () => {
145
145
  test('follows the active theme rather than a fixed light/dark pair', () => {
146
- const nord = getXtermTheme('nord-dark');
147
- const paper = getXtermTheme('paper');
148
- expect(nord.background).toBe('#1F2430');
146
+ const nord = getTerminalTheme('nord-dark');
147
+ const paper = getTerminalTheme('paper');
148
+ // No surface of its own: the terminal paints nothing behind the cells, so
149
+ // the panel's chrome (and the glass plane under it) shows through.
150
+ expect(nord.background).toBe('transparent');
151
+ expect(paper.background).toBe('transparent');
149
152
  expect(nord.foreground).toBe('#E5E9F0');
150
- expect(paper.background).toBe('#f4f1ea');
151
153
  expect(paper.foreground).toBe('#141310');
152
154
  });
153
155
 
154
- test('emits literal colors — xterm cannot parse color-mix()', () => {
156
+ test('emits literal colors — the canvas cannot parse color-mix()', () => {
155
157
  for (const theme of THEMES) {
156
- for (const value of Object.values(getXtermTheme(theme.id))) {
157
- expect(value).toMatch(COLOR_VALUE);
158
+ for (const value of Object.values(getTerminalTheme(theme.id))) {
159
+ // `transparent` is a CSS keyword `fillStyle` does accept, and it is the
160
+ // only non-hex value the palette is allowed to carry.
161
+ expect(value).toMatch(value === 'transparent' ? /^transparent$/ : COLOR_VALUE);
158
162
  }
159
163
  }
160
164
  });
161
165
 
162
166
  test('takes its signal colors from the palette', () => {
163
- const dracula = getXtermTheme('dracula-dark');
167
+ const dracula = getTerminalTheme('dracula-dark');
164
168
  expect(dracula.red).toBe('#FF5555');
165
169
  expect(dracula.green).toBe('#50FA7B');
166
170
  expect(dracula.yellow).toBe('#FFB86C');
@@ -6,8 +6,8 @@
6
6
  /**
7
7
  * Hex color arithmetic for the terminal palette.
8
8
  *
9
- * xterm cannot parse `color-mix()`, so blends are computed here and handed over
10
- * as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
9
+ * The terminal renderer cannot resolve `color-mix()`, so blends are computed
10
+ * here and handed over as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
11
11
  * fallback (returning a broken string instead of the base color) would blank a
12
12
  * palette entry. The parser must handle all three spellings the ported palettes
13
13
  * use (`#rgb`, `#rrggbb`, and 8-digit `#rrggbbaa`, including OpenChamber's
@@ -6,10 +6,10 @@
6
6
  /**
7
7
  * Hex color arithmetic for the places that cannot use CSS.
8
8
  *
9
- * `color-mix()` covers every blend inside the document, but xterm parses theme
10
- * colors itself (it accepts `#rgb`, `#rrggbb`, `rgb()`, `hsl()` and named
11
- * colors — not `color-mix()`, in either the DOM or the WebGL renderer), so the
12
- * terminal palette has to be computed here and handed over as literal hex.
9
+ * `color-mix()` covers every blend inside the document, but the terminal
10
+ * renderer takes only literal colors (it hands them to `ctx.fillStyle`, which
11
+ * does not resolve `color-mix()`), so the terminal palette has to be computed
12
+ * here and handed over as hex.
13
13
  *
14
14
  * The palette values are ported verbatim from OpenChamber and are therefore not
15
15
  * uniform: `#FFF` (jetbrains-light) and 8-digit alpha (`#dbd7caee`,
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Why each case is risky:
12
12
  *
13
- * - `rgbaToHex` feeds xterm, which rejects anything but literal hex. An
13
+ * - `rgbaToHex` feeds the terminal palette, which takes only literal hex. An
14
14
  * out-of-range or unrounded channel emits `#ff0-10`, a color no consumer can
15
15
  * parse, so clamping/rounding is pinned here.
16
16
  * - `mixHex` composites the blend's own alpha. A palette that carries 8-digit
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { terminalInputFrame } from '@/shared/lib/workspace/terminal/input';
8
+
9
+ describe('terminalInputFrame', () => {
10
+ test('keeps ordinary text on the text channel', () => {
11
+ expect(terminalInputFrame('echo ok\r')).toEqual({ text: 'echo ok\r' });
12
+ expect(terminalInputFrame('ả 漢')).toEqual({ text: 'ả 漢' });
13
+ });
14
+
15
+ test('routes an X10 mouse report as latin-1 bytes, including values above 127', () => {
16
+ // ESC [ M, button 0, column 188 (+32 = 220), row 3 (+32 = 35).
17
+ const frame = terminalInputFrame('\x1b[M\x20\xdc\x23');
18
+ expect(frame.text).toBeUndefined();
19
+ expect([...(frame.bytes ?? [])]).toEqual([27, 91, 77, 32, 220, 35]);
20
+ expect(frame.bytes?.length).toBe(6);
21
+ });
22
+
23
+ test('does not treat a truncated prefix as a mouse report', () => {
24
+ expect(terminalInputFrame('\x1b[M')).toEqual({ text: '\x1b[M' });
25
+ expect(terminalInputFrame('\x1b[M\x20')).toEqual({ text: '\x1b[M\x20' });
26
+ });
27
+ });
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Split one ghostty-web `onData` payload into the channel the PTY needs.
8
+ *
9
+ * ghostty-web has no `onBinary` (xterm's separate channel for non-UTF-8
10
+ * payloads). Its legacy X10 mouse report is built with `String.fromCharCode`
11
+ * from values up to 255, so `TextEncoder` would turn a 6-byte report into 7+
12
+ * bytes and the shell would receive the wrong sequence. SGR mouse reports are
13
+ * printable ASCII and stay on the text path.
14
+ *
15
+ * X10 is exactly `ESC [ M` followed by three bytes; a payload with that prefix
16
+ * is forwarded through the byte channel unchanged otherwise.
17
+ */
18
+
19
+ const X10_MOUSE_PREFIX = '\x1b[M';
20
+ const X10_MOUSE_LENGTH = X10_MOUSE_PREFIX.length + 3;
21
+
22
+ export type TerminalInputFrame = { text: string; bytes?: undefined } | { text?: undefined; bytes: Uint8Array };
23
+
24
+ export function terminalInputFrame(data: string): TerminalInputFrame {
25
+ if (!data.startsWith(X10_MOUSE_PREFIX) || data.length < X10_MOUSE_LENGTH) {
26
+ return { text: data };
27
+ }
28
+ const bytes = new Uint8Array(data.length);
29
+ for (let index = 0; index < data.length; index += 1) {
30
+ bytes[index] = data.charCodeAt(index) & 0xff;
31
+ }
32
+ return { bytes };
33
+ }
@@ -7,7 +7,7 @@
7
7
  * The bytes the terminal key bar sends.
8
8
  *
9
9
  * Every expectation here is copied from xterm's own `evaluateKeyboardEvent`
10
- * (`@xterm/xterm/src/common/input/Keyboard.ts`), because the shell cannot tell a
10
+ * (`Keyboard.ts`), because the shell cannot tell a
11
11
  * bar button from a physical key: a sequence that merely looks plausible works
12
12
  * in bash and breaks in vim. Three of those rules are the ones this file exists
13
13
  * to pin — a modifier is a CSI PARAMETER and not an ESC prefix, application
@@ -9,8 +9,8 @@
9
9
  * A phone's soft keyboard has no Ctrl, no Alt, no arrows, no Esc and no `|`, so
10
10
  * a shell on a phone is unusable without a strip of buttons that emit the raw
11
11
  * bytes those keys would. Every sequence here is what xterm's own
12
- * `evaluateKeyboardEvent` sends for the same physical key
13
- * (`@xterm/xterm/src/common/input/Keyboard.ts`) — the shell on the far end
12
+ * `evaluateKeyboardEvent` sends for the same physical key (xterm.js's
13
+ * `Keyboard.ts`) — the shell on the far end
14
14
  * cannot tell the two apart, so a bar key that invented its own encoding would
15
15
  * work in bash and break in vim.
16
16
  *
@@ -23,11 +23,11 @@
23
23
  * - Ctrl has no literal spelling: it folds a typed character into a control
24
24
  * character (Ctrl+C is `0x03`), so a literal button keeps its own byte.
25
25
  *
26
- * There is deliberately no Cmd key. macOS reports it as `metaKey` and xterm
27
- * discards it — `if (ev.metaKey) break;` in the cursor-key branches — because
28
- * Cmd is the browser's modifier, not the terminal's: in a terminal Cmd+C and
29
- * Cmd+V mean copy and paste, which is why those are actions in `KeyBar.tsx`
30
- * rather than bytes here.
26
+ * There is deliberately no Cmd key. macOS reports it as `metaKey`, and the
27
+ * renderer treats it as the host's modifier rather than the terminal's: a
28
+ * printable Cmd chord sends nothing, and Cmd+C / Cmd+V are its own copy and
29
+ * paste — which is why those are actions in `KeyBar.tsx` rather than bytes
30
+ * here.
31
31
  */
32
32
 
33
33
  export type TerminalModifier = 'ctrl' | 'alt';
@@ -258,7 +258,7 @@ export interface QueuedMessage {
258
258
  /** Trigger group that opened the composer autocomplete: `@` → mention, `/` → command. */
259
259
  export type ComposerPickKind = 'mention' | 'command';
260
260
  /** Origin of a pickable item: an `@` mention is an agent or a workspace file. */
261
- export type ComposerPickSource = 'agent' | 'file' | 'command' | 'skill';
261
+ export type ComposerPickSource = 'agent' | 'harness' | 'file' | 'command' | 'skill';
262
262
 
263
263
  /**
264
264
  * Which part of a slash invocation the popup is completing. oh-my-pi splits
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One harness update, as a BACKGROUND job.
8
+ *
9
+ * The update used to run inside the POST that asked for it: the request held
10
+ * open for minutes, a reload forgot it, and the five-minute child timeout could
11
+ * kill `npm install -g` halfway through writing the package tree — a corrupt
12
+ * install that the dialog still reported as a failure it could retry. The run is
13
+ * now a detached worker (`update-worker.ts`) that owns its steps and writes this
14
+ * record to disk, so the request can answer immediately, the page can close, and
15
+ * the next open reads what actually happened.
16
+ *
17
+ * Stated once, here, because three places read it: the worker writes it, the
18
+ * route answers it, and the About card polls it.
19
+ */
20
+
21
+ import type { HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
22
+
23
+ /** Where one step is in its life. `pending` exists on the record before the
24
+ * worker reaches it, so a reader sees the whole plan from the first poll. */
25
+ export type HarnessUpdateStepState = 'pending' | 'running' | 'ok' | 'failed';
26
+
27
+ /** A planned step plus what running it produced. */
28
+ export interface HarnessUpdateJobStep extends HarnessUpdateStep {
29
+ state: HarnessUpdateStepState;
30
+ /** Exit code, or null while it has not run (or was killed). */
31
+ code: number | null;
32
+ }
33
+
34
+ export interface HarnessUpdateJob {
35
+ harness: string;
36
+ label: string;
37
+ startedAt: number;
38
+ /** Null while running: this is the field that says whether to poll. */
39
+ finishedAt: number | null;
40
+ /**
41
+ * When this run was ACCEPTED while another harness was already installing.
42
+ *
43
+ * Two presses are no longer one press refused: the record carries this stamp
44
+ * and the queue starts the install when the one ahead of it finishes. A record
45
+ * with `pid: null`, `finishedAt: null` and this set is WAITING — not a worker
46
+ * that died — and must never be settled as a failure. The worker clears it
47
+ * when it takes the run over.
48
+ *
49
+ * Optional because a record written before the queue existed has no such
50
+ * field; readers normalize with `jobQueued`.
51
+ */
52
+ queuedAt?: number | null;
53
+ /** The WORKER process, used to tell a run that is still alive from one that
54
+ * died without writing its result (a crash, a kill, a reboot). */
55
+ pid: number | null;
56
+ steps: HarnessUpdateJobStep[];
57
+ /** The tail of everything the commands printed. */
58
+ output: string;
59
+ /** Null while running; true/false once the worker has decided. */
60
+ ok: boolean | null;
61
+ /** The sentence the dialog shows. Null while running. */
62
+ message: string | null;
63
+ /** True once the SERVER applied the post-install side effects (forget the
64
+ * probe and CLI version caches, repoint the launch line). The worker cannot
65
+ * do those: they read the database, which the server owns. */
66
+ applied: boolean;
67
+ /**
68
+ * The post-install PROBE: the freshly installed agent is asked what it is, so
69
+ * the row stops quoting the version that was just replaced.
70
+ *
71
+ * `pending` while that probe runs (it spawns an agent process, so the
72
+ * install's own report is not held up by it), `done` once its answer is in the
73
+ * probe cache, and null when this run has nothing to probe — it failed, or the
74
+ * vendor owns the install. A polling dialog keys its "keep going" on this, and
75
+ * re-reads the version rows when it turns `done`.
76
+ */
77
+ probe?: 'pending' | 'done' | null;
78
+ /** The launch command a successful install left behind, when it moved it. */
79
+ repointed: string | null;
80
+ }
81
+
82
+ /** What a step needs to run: the plan, and where the worker reads and writes. */
83
+ export interface HarnessUpdateJobSpec {
84
+ harness: string;
85
+ label: string;
86
+ steps: HarnessUpdateStep[];
87
+ statusPath: string;
88
+ lockPath: string;
89
+ }
@@ -153,6 +153,23 @@ export interface SpawnedSession {
153
153
  harness?: string | null;
154
154
  }
155
155
 
156
+ /**
157
+ * Outcome of a brand-new session spawn.
158
+ *
159
+ * A refusal travels with the server's own reason. The caller must report it —
160
+ * falling through to the simulated stream told the operator an agent had
161
+ * answered when nothing had started at all.
162
+ */
163
+ export type SpawnPromptResult =
164
+ | { ok: true; session: SpawnedSession }
165
+ /**
166
+ * `code` is the server's own discriminator when there is one. `mock_mode`
167
+ * means there is no agent process to start ON PURPOSE — the caller must take
168
+ * the simulated path instead of reporting a failure the operator cannot act
169
+ * on. Every other failure is reported.
170
+ */
171
+ | { ok: false; error: string; code?: string };
172
+
156
173
  /** Command surface returned by useOmpAgent — the live omp session handle the
157
174
  * chat timeline drives. */
158
175
  export interface OmpAgentHandle extends OmpAgentState {
@@ -162,7 +179,7 @@ export interface OmpAgentHandle extends OmpAgentState {
162
179
  * time and the server reconciles an idle session by respawning it. */
163
180
  sendPrompt: (message: string, images?: AgentImage[], options?: { accessMode?: ApprovalMode }) => Promise<PromptDispatchResult>;
164
181
  /** Spawn a brand-new omp session and send its first prompt; resolves with the
165
- * adopted session id (or null on failure). */
182
+ * adopted session or the server's refusal reason. */
166
183
  sendNewPrompt: (
167
184
  message: string,
168
185
  cwd: string,
@@ -172,7 +189,7 @@ export interface OmpAgentHandle extends OmpAgentState {
172
189
  * armed goal is started, so the prompt IS its first turn. Resolves true
173
190
  * when it consumed the prompt (an interview renders its own). */
174
191
  beforePrompt?: (sessionId: string) => Promise<boolean>,
175
- ) => Promise<SpawnedSession | null>;
192
+ ) => Promise<SpawnPromptResult>;
176
193
  /** Steer the running agent: deliver the message INTO the turn in flight
177
194
  * (omp's `steer` RPC). The run continues; the model sees the message inside
178
195
  * the same turn and answers it there.
@@ -28,6 +28,8 @@ export interface SidebarStatusEntry {
28
28
  streamStatus?: 'stream' | 'finish' | 'abort';
29
29
  awaitingInput?: boolean;
30
30
  runModel?: SessionRunModel;
31
+ /** Present only on a failed terminal run; the notification's own reason. */
32
+ runFailure?: string;
31
33
  }
32
34
 
33
35
  /** `sidebar:status` — keyed by session id. Absent id means "no volatile fields". */