@wjarka/cezarion 0.15.1 → 0.16.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 (462) hide show
  1. package/README.md +167 -46
  2. package/dist/agent-config/catalog.d.ts +6 -2
  3. package/dist/agent-config/catalog.js +78 -3
  4. package/dist/agent-config/catalog.js.map +1 -1
  5. package/dist/agent-config/model-settings/shared.js +6 -3
  6. package/dist/agent-config/model-settings/shared.js.map +1 -1
  7. package/dist/agent-config/models.js +4 -0
  8. package/dist/agent-config/models.js.map +1 -1
  9. package/dist/agent-config/validate.js +6 -0
  10. package/dist/agent-config/validate.js.map +1 -1
  11. package/dist/artifacts/cli.js +10 -2
  12. package/dist/artifacts/cli.js.map +1 -1
  13. package/dist/automations/coordinator.d.ts +7 -0
  14. package/dist/automations/coordinator.js +22 -2
  15. package/dist/automations/coordinator.js.map +1 -1
  16. package/dist/automations/github-poller.d.ts +4 -4
  17. package/dist/automations/github-poller.js.map +1 -1
  18. package/dist/automations/schedule-runner.d.ts +130 -0
  19. package/dist/automations/schedule-runner.js +326 -0
  20. package/dist/automations/schedule-runner.js.map +1 -0
  21. package/dist/automations/scheduler.d.ts +38 -7
  22. package/dist/automations/scheduler.js +90 -22
  23. package/dist/automations/scheduler.js.map +1 -1
  24. package/dist/automations/store.d.ts +80 -3
  25. package/dist/automations/store.js +208 -16
  26. package/dist/automations/store.js.map +1 -1
  27. package/dist/automations/task-template.d.ts +42 -6
  28. package/dist/automations/task-template.js +152 -24
  29. package/dist/automations/task-template.js.map +1 -1
  30. package/dist/automations/types.d.ts +142 -6
  31. package/dist/automations/types.js +64 -6
  32. package/dist/automations/types.js.map +1 -1
  33. package/dist/autosave-holders.js +8 -12
  34. package/dist/autosave-holders.js.map +1 -1
  35. package/dist/ci-wait/client.d.ts +8 -1
  36. package/dist/ci-wait/client.js +43 -1
  37. package/dist/ci-wait/client.js.map +1 -1
  38. package/dist/ci-wait/controller.d.ts +83 -4
  39. package/dist/ci-wait/controller.js +76 -11
  40. package/dist/ci-wait/controller.js.map +1 -1
  41. package/dist/ci-wait/errors.d.ts +7 -1
  42. package/dist/ci-wait/errors.js +36 -0
  43. package/dist/ci-wait/errors.js.map +1 -1
  44. package/dist/ci-wait/github.d.ts +2 -0
  45. package/dist/ci-wait/github.js +3 -1
  46. package/dist/ci-wait/github.js.map +1 -1
  47. package/dist/ci-wait/mcp.d.ts +2 -98
  48. package/dist/ci-wait/mcp.js +11 -25
  49. package/dist/ci-wait/mcp.js.map +1 -1
  50. package/dist/ci-wait/supervisor.d.ts +2 -1
  51. package/dist/ci-wait/supervisor.js +2 -1
  52. package/dist/ci-wait/supervisor.js.map +1 -1
  53. package/dist/ci-wait/tools.d.ts +307 -0
  54. package/dist/ci-wait/tools.js +63 -0
  55. package/dist/ci-wait/tools.js.map +1 -0
  56. package/dist/config.d.ts +3 -0
  57. package/dist/config.js +7 -0
  58. package/dist/config.js.map +1 -1
  59. package/dist/contract/agent-config.d.ts +5 -0
  60. package/dist/contract/agent-profiles.d.ts +15 -0
  61. package/dist/contract/automation-schedule.d.ts +60 -0
  62. package/dist/contract/automations.d.ts +208 -36
  63. package/dist/contract/delegation.d.ts +96 -0
  64. package/dist/contract/discovery.d.ts +7 -0
  65. package/dist/contract/github.d.ts +1 -0
  66. package/dist/contract/health.d.ts +6 -0
  67. package/dist/contract/index.d.ts +3 -0
  68. package/dist/contract/index.js +1445 -745
  69. package/dist/contract/preview.d.ts +508 -0
  70. package/dist/contract/runs.d.ts +716 -15
  71. package/dist/contract/skills.d.ts +39 -0
  72. package/dist/contract/workflows.d.ts +6 -0
  73. package/dist/contract/workspace.d.ts +65 -0
  74. package/dist/contract/zoned-time.d.ts +35 -0
  75. package/dist/core/agent-env.d.ts +11 -0
  76. package/dist/core/agent-env.js +27 -5
  77. package/dist/core/agent-env.js.map +1 -1
  78. package/dist/core/agent-profiles.js +7 -0
  79. package/dist/core/agent-profiles.js.map +1 -1
  80. package/dist/core/agent-runner.d.ts +49 -1
  81. package/dist/core/agent-runner.js +2 -1
  82. package/dist/core/agent-runner.js.map +1 -1
  83. package/dist/core/backend-detect.d.ts +3 -2
  84. package/dist/core/backend-detect.js +27 -1
  85. package/dist/core/backend-detect.js.map +1 -1
  86. package/dist/core/claude-cli-runner.d.ts +1 -0
  87. package/dist/core/claude-cli-runner.js +69 -19
  88. package/dist/core/claude-cli-runner.js.map +1 -1
  89. package/dist/core/codex-app-server-runner.d.ts +1 -0
  90. package/dist/core/codex-app-server-runner.js +200 -25
  91. package/dist/core/codex-app-server-runner.js.map +1 -1
  92. package/dist/core/codex-app-server-transport.d.ts +7 -3
  93. package/dist/core/codex-app-server-transport.js +11 -9
  94. package/dist/core/codex-app-server-transport.js.map +1 -1
  95. package/dist/core/cursor-acp-runner.d.ts +1 -0
  96. package/dist/core/cursor-acp-runner.js +24 -9
  97. package/dist/core/cursor-acp-runner.js.map +1 -1
  98. package/dist/core/host-model-catalog.js +2 -0
  99. package/dist/core/host-model-catalog.js.map +1 -1
  100. package/dist/core/managed-session.js +2 -0
  101. package/dist/core/managed-session.js.map +1 -1
  102. package/dist/core/model-identity.js +2 -0
  103. package/dist/core/model-identity.js.map +1 -1
  104. package/dist/core/model-presets.js +3 -0
  105. package/dist/core/model-presets.js.map +1 -1
  106. package/dist/core/omp-model-catalog.d.ts +43 -0
  107. package/dist/core/omp-model-catalog.js +205 -0
  108. package/dist/core/omp-model-catalog.js.map +1 -0
  109. package/dist/core/omp-runner.d.ts +73 -0
  110. package/dist/core/omp-runner.js +990 -0
  111. package/dist/core/omp-runner.js.map +1 -0
  112. package/dist/core/omp-ui-mapper.d.ts +106 -0
  113. package/dist/core/omp-ui-mapper.js +882 -0
  114. package/dist/core/omp-ui-mapper.js.map +1 -0
  115. package/dist/core/opencode-server-runner.d.ts +18 -4
  116. package/dist/core/opencode-server-runner.js +337 -96
  117. package/dist/core/opencode-server-runner.js.map +1 -1
  118. package/dist/core/opencode-session-error.d.ts +11 -0
  119. package/dist/core/opencode-session-error.js +26 -0
  120. package/dist/core/opencode-session-error.js.map +1 -0
  121. package/dist/core/opencode-ui-mapper.js +4 -36
  122. package/dist/core/opencode-ui-mapper.js.map +1 -1
  123. package/dist/core/pi-runner.d.ts +1 -0
  124. package/dist/core/pi-runner.js +75 -12
  125. package/dist/core/pi-runner.js.map +1 -1
  126. package/dist/core/provider-auth.d.ts +9 -2
  127. package/dist/core/provider-auth.js +43 -6
  128. package/dist/core/provider-auth.js.map +1 -1
  129. package/dist/core/runner-factory.js +3 -0
  130. package/dist/core/runner-factory.js.map +1 -1
  131. package/dist/core/runner-model-catalog.js +1 -0
  132. package/dist/core/runner-model-catalog.js.map +1 -1
  133. package/dist/core/runner-stderr.d.ts +2 -0
  134. package/dist/core/runner-stderr.js +20 -0
  135. package/dist/core/runner-stderr.js.map +1 -0
  136. package/dist/core/session-process.d.ts +22 -0
  137. package/dist/core/session-process.js +202 -0
  138. package/dist/core/session-process.js.map +1 -0
  139. package/dist/core/ui-events.d.ts +1 -1
  140. package/dist/core/usage-limit.js +3 -60
  141. package/dist/core/usage-limit.js.map +1 -1
  142. package/dist/data-gitignore.d.ts +6 -0
  143. package/dist/data-gitignore.js +57 -0
  144. package/dist/data-gitignore.js.map +1 -0
  145. package/dist/delegation/capacity.d.ts +19 -0
  146. package/dist/delegation/capacity.js +34 -0
  147. package/dist/delegation/capacity.js.map +1 -0
  148. package/dist/delegation/cli.js +13 -4
  149. package/dist/delegation/cli.js.map +1 -1
  150. package/dist/delegation/conversations.d.ts +4 -2
  151. package/dist/delegation/conversations.js +8 -12
  152. package/dist/delegation/conversations.js.map +1 -1
  153. package/dist/delegation/credentials.d.ts +2 -0
  154. package/dist/delegation/credentials.js +10 -0
  155. package/dist/delegation/credentials.js.map +1 -1
  156. package/dist/delegation/destroy-observation.d.ts +42 -0
  157. package/dist/delegation/destroy-observation.js +115 -0
  158. package/dist/delegation/destroy-observation.js.map +1 -0
  159. package/dist/delegation/execution-identity.d.ts +6 -0
  160. package/dist/delegation/execution-identity.js +1 -1
  161. package/dist/delegation/execution-identity.js.map +1 -1
  162. package/dist/delegation/policy.d.ts +3 -2
  163. package/dist/delegation/policy.js +7 -5
  164. package/dist/delegation/policy.js.map +1 -1
  165. package/dist/delegation/process-liveness.d.ts +57 -20
  166. package/dist/delegation/process-liveness.js +114 -92
  167. package/dist/delegation/process-liveness.js.map +1 -1
  168. package/dist/delegation/provision.js +6 -6
  169. package/dist/delegation/provision.js.map +1 -1
  170. package/dist/delegation/results.js +4 -2
  171. package/dist/delegation/results.js.map +1 -1
  172. package/dist/delegation/retry-backoff.d.ts +23 -0
  173. package/dist/delegation/retry-backoff.js +18 -0
  174. package/dist/delegation/retry-backoff.js.map +1 -0
  175. package/dist/delegation/routes.d.ts +64 -58
  176. package/dist/delegation/scratch-cleanup.d.ts +29 -0
  177. package/dist/delegation/scratch-cleanup.js +143 -0
  178. package/dist/delegation/scratch-cleanup.js.map +1 -0
  179. package/dist/delegation/service.d.ts +20 -1
  180. package/dist/delegation/service.js +233 -70
  181. package/dist/delegation/service.js.map +1 -1
  182. package/dist/delegation/transport.d.ts +12 -6
  183. package/dist/delegation/workspace.d.ts +23 -4
  184. package/dist/delegation/workspace.js +147 -31
  185. package/dist/delegation/workspace.js.map +1 -1
  186. package/dist/git-worktree-lock-helper.js +8 -3
  187. package/dist/git-worktree-lock-helper.js.map +1 -1
  188. package/dist/git-worktree-lock.d.ts +6 -1
  189. package/dist/git-worktree-lock.js +10 -4
  190. package/dist/git-worktree-lock.js.map +1 -1
  191. package/dist/git-worktree-release.d.ts +20 -0
  192. package/dist/git-worktree-release.js +27 -0
  193. package/dist/git-worktree-release.js.map +1 -0
  194. package/dist/git-worktree.d.ts +8 -2
  195. package/dist/git-worktree.js +19 -2
  196. package/dist/git-worktree.js.map +1 -1
  197. package/dist/handoff.d.ts +2 -2
  198. package/dist/handoff.js +1 -1
  199. package/dist/index.js +109 -76
  200. package/dist/index.js.map +1 -1
  201. package/dist/paths.d.ts +1 -1
  202. package/dist/paths.js +5 -1
  203. package/dist/paths.js.map +1 -1
  204. package/dist/preview/cdp.d.ts +13 -0
  205. package/dist/preview/cdp.js +69 -0
  206. package/dist/preview/cdp.js.map +1 -0
  207. package/dist/preview/chromium.d.ts +75 -0
  208. package/dist/preview/chromium.js +394 -0
  209. package/dist/preview/chromium.js.map +1 -0
  210. package/dist/preview/dev-server.d.ts +68 -0
  211. package/dist/preview/dev-server.js +341 -0
  212. package/dist/preview/dev-server.js.map +1 -0
  213. package/dist/preview/host.d.ts +154 -0
  214. package/dist/preview/host.js +681 -0
  215. package/dist/preview/host.js.map +1 -0
  216. package/dist/preview/registration.d.ts +63 -0
  217. package/dist/preview/registration.js +109 -0
  218. package/dist/preview/registration.js.map +1 -0
  219. package/dist/preview/session.d.ts +73 -0
  220. package/dist/preview/session.js +347 -0
  221. package/dist/preview/session.js.map +1 -0
  222. package/dist/preview/url.d.ts +6 -0
  223. package/dist/preview/url.js +17 -0
  224. package/dist/preview/url.js.map +1 -0
  225. package/dist/runs/agent-tmpdir-removal.d.ts +15 -0
  226. package/dist/runs/agent-tmpdir-removal.js +60 -0
  227. package/dist/runs/agent-tmpdir-removal.js.map +1 -0
  228. package/dist/runs/agent-tmpdir.d.ts +12 -1
  229. package/dist/runs/agent-tmpdir.js +123 -34
  230. package/dist/runs/agent-tmpdir.js.map +1 -1
  231. package/dist/runs/delegation-state.d.ts +5 -1
  232. package/dist/runs/delegation-state.js +9 -0
  233. package/dist/runs/delegation-state.js.map +1 -1
  234. package/dist/runs/event-history.d.ts +4 -4
  235. package/dist/runs/event-history.js +97 -117
  236. package/dist/runs/event-history.js.map +1 -1
  237. package/dist/runs/history-compressor.d.ts +29 -0
  238. package/dist/runs/history-compressor.js +116 -0
  239. package/dist/runs/history-compressor.js.map +1 -0
  240. package/dist/runs/history-file.d.ts +36 -0
  241. package/dist/runs/history-file.js +463 -0
  242. package/dist/runs/history-file.js.map +1 -0
  243. package/dist/runs/human-ask-summary.js +18 -13
  244. package/dist/runs/human-ask-summary.js.map +1 -1
  245. package/dist/runs/legacy-index.d.ts +62 -0
  246. package/dist/runs/legacy-index.js +168 -0
  247. package/dist/runs/legacy-index.js.map +1 -0
  248. package/dist/runs/raw-record.d.ts +52 -0
  249. package/dist/runs/raw-record.js +145 -0
  250. package/dist/runs/raw-record.js.map +1 -0
  251. package/dist/runs/retention.d.ts +13 -6
  252. package/dist/runs/retention.js +42 -13
  253. package/dist/runs/retention.js.map +1 -1
  254. package/dist/runs/run-claims.d.ts +23 -0
  255. package/dist/runs/run-claims.js +24 -0
  256. package/dist/runs/run-claims.js.map +1 -0
  257. package/dist/runs/run-database.d.ts +385 -0
  258. package/dist/runs/run-database.js +930 -0
  259. package/dist/runs/run-database.js.map +1 -0
  260. package/dist/runs/run-index.d.ts +35 -9
  261. package/dist/runs/run-index.js +200 -25
  262. package/dist/runs/run-index.js.map +1 -1
  263. package/dist/runs/run-row.d.ts +44 -0
  264. package/dist/runs/run-row.js +84 -0
  265. package/dist/runs/run-row.js.map +1 -0
  266. package/dist/runs/run-search.d.ts +29 -0
  267. package/dist/runs/run-search.js +63 -0
  268. package/dist/runs/run-search.js.map +1 -0
  269. package/dist/runs/store-open-error.d.ts +24 -0
  270. package/dist/runs/store-open-error.js +61 -0
  271. package/dist/runs/store-open-error.js.map +1 -0
  272. package/dist/runs/store.d.ts +667 -32
  273. package/dist/runs/store.js +2153 -324
  274. package/dist/runs/store.js.map +1 -1
  275. package/dist/runs/transcript-facts.d.ts +77 -0
  276. package/dist/runs/transcript-facts.js +302 -0
  277. package/dist/runs/transcript-facts.js.map +1 -0
  278. package/dist/runs/webhook.js +5 -4
  279. package/dist/runs/webhook.js.map +1 -1
  280. package/dist/runs/worker-execution.d.ts +22 -0
  281. package/dist/runs/worker-execution.js +30 -0
  282. package/dist/runs/worker-execution.js.map +1 -0
  283. package/dist/server/capabilities.d.ts +1 -0
  284. package/dist/server/capabilities.js +2 -0
  285. package/dist/server/capabilities.js.map +1 -1
  286. package/dist/server/cockpit-ownership.d.ts +8 -0
  287. package/dist/server/cockpit-ownership.js +19 -0
  288. package/dist/server/cockpit-ownership.js.map +1 -1
  289. package/dist/server/forge/github.d.ts +1 -4
  290. package/dist/server/forge/github.js +47 -23
  291. package/dist/server/forge/github.js.map +1 -1
  292. package/dist/server/git.js +1 -1
  293. package/dist/server/git.js.map +1 -1
  294. package/dist/server/open-in-app.js +1 -0
  295. package/dist/server/open-in-app.js.map +1 -1
  296. package/dist/server/preview-socket.d.ts +36 -0
  297. package/dist/server/preview-socket.js +126 -0
  298. package/dist/server/preview-socket.js.map +1 -0
  299. package/dist/server/project-context.d.ts +31 -4
  300. package/dist/server/project-context.js +73 -9
  301. package/dist/server/project-context.js.map +1 -1
  302. package/dist/server/provider-action-gate.js +1 -0
  303. package/dist/server/provider-action-gate.js.map +1 -1
  304. package/dist/server/repo-branches.d.ts +4 -3
  305. package/dist/server/repo-branches.js +5 -4
  306. package/dist/server/repo-branches.js.map +1 -1
  307. package/dist/server/server.d.ts +4500 -2727
  308. package/dist/server/server.js +651 -202
  309. package/dist/server/server.js.map +1 -1
  310. package/dist/server/upgrade-router.d.ts +23 -0
  311. package/dist/server/upgrade-router.js +53 -0
  312. package/dist/server/upgrade-router.js.map +1 -0
  313. package/dist/server/validators.d.ts +6 -1
  314. package/dist/server/validators.js +4 -4
  315. package/dist/server/validators.js.map +1 -1
  316. package/dist/server/ws.d.ts +16 -16
  317. package/dist/server/ws.js +56 -54
  318. package/dist/server/ws.js.map +1 -1
  319. package/dist/skills-remote.d.ts +14 -0
  320. package/dist/skills-remote.js +91 -15
  321. package/dist/skills-remote.js.map +1 -1
  322. package/dist/task-cli/cli.js +40 -16
  323. package/dist/task-cli/cli.js.map +1 -1
  324. package/dist/task-cli/discovery.d.ts +4 -3
  325. package/dist/task-cli/discovery.js +4 -3
  326. package/dist/task-cli/discovery.js.map +1 -1
  327. package/dist/task-cli/http.d.ts +2 -0
  328. package/dist/task-cli/http.js +10 -4
  329. package/dist/task-cli/http.js.map +1 -1
  330. package/dist/task-cli/projections.d.ts +5 -2
  331. package/dist/task-cli/projections.js +13 -0
  332. package/dist/task-cli/projections.js.map +1 -1
  333. package/dist/task-cli/watch.d.ts +15 -2
  334. package/dist/task-cli/watch.js +31 -9
  335. package/dist/task-cli/watch.js.map +1 -1
  336. package/dist/ui-state.d.ts +4 -3
  337. package/dist/ui-state.js +8 -3
  338. package/dist/ui-state.js.map +1 -1
  339. package/dist/workflows/grouped-command.d.ts +31 -0
  340. package/dist/workflows/grouped-command.js +143 -0
  341. package/dist/workflows/grouped-command.js.map +1 -0
  342. package/dist/workflows/run.d.ts +223 -42
  343. package/dist/workflows/run.js +1316 -398
  344. package/dist/workflows/run.js.map +1 -1
  345. package/dist/workflows/types.d.ts +12 -0
  346. package/dist/workflows/types.js +20 -0
  347. package/dist/workflows/types.js.map +1 -1
  348. package/dist/workspace/agent-accounts.d.ts +5 -1
  349. package/dist/workspace/agent-accounts.js +1 -0
  350. package/dist/workspace/agent-accounts.js.map +1 -1
  351. package/dist/workspace/agent-profiles.js +1 -1
  352. package/dist/workspace/agent-profiles.js.map +1 -1
  353. package/dist/workspace/config.d.ts +3 -1
  354. package/dist/workspace/config.js +1 -0
  355. package/dist/workspace/config.js.map +1 -1
  356. package/dist/worktree-setup.d.ts +85 -0
  357. package/dist/worktree-setup.js +164 -0
  358. package/dist/worktree-setup.js.map +1 -0
  359. package/package.json +7 -5
  360. package/scripts/benchmark-run-store-fixture.ts +428 -0
  361. package/scripts/benchmark-run-store.ts +743 -0
  362. package/scripts/benchmark-stuck-destroys.ts +143 -0
  363. package/scripts/mock-autonomous.mjs +11 -0
  364. package/scripts/mock-ci-tool.mjs +20 -5
  365. package/scripts/mock-claude.mjs +110 -1
  366. package/scripts/mock-codex-app-server.mjs +117 -2
  367. package/scripts/mock-codex-coalesce-steer.mjs +59 -0
  368. package/scripts/mock-codex-reverse-steer.mjs +130 -0
  369. package/scripts/mock-cursor-acp.mjs +75 -1
  370. package/scripts/mock-omp-rpc.mjs +605 -0
  371. package/scripts/mock-opencode-serve.mjs +312 -22
  372. package/scripts/mock-pi-rpc.mjs +109 -3
  373. package/scripts/mock-runner-crash.mjs +42 -0
  374. package/scripts/mock-silent-tail.mjs +78 -0
  375. package/scripts/mock-turn-messages.mjs +5 -0
  376. package/scripts/omp-ci-wait.mjs +29 -0
  377. package/scripts/omp-restrict-delegation.yml +4 -0
  378. package/scripts/pi-ci-wait.mjs +12 -9
  379. package/scripts/seed-archive-profile.ts +3 -3
  380. package/web/dist/assets/agent-accounts-CFOBMVHc.js +1 -0
  381. package/web/dist/assets/alert-dialog-BrpNUwMt.js +1 -0
  382. package/web/dist/assets/app-window-CSHwDX9N.js +1 -0
  383. package/web/dist/assets/button-C_rd7CPp.js +43 -0
  384. package/web/dist/assets/compare-variants-D6WXhvXA.js +1 -0
  385. package/web/dist/assets/diff-DrEARXTV.js +3 -0
  386. package/web/dist/assets/diff-controls-B1-j7nFg.js +1 -0
  387. package/web/dist/assets/{diff-view-DPn6bQ5W.js → diff-view-DvGLjdTk.js} +3 -3
  388. package/web/dist/assets/dropdown-menu-BegOZFrj.js +1 -0
  389. package/web/dist/assets/format-DpNe3S0A.js +1 -0
  390. package/web/dist/assets/git-toolbar-Cw4ljmhB.js +1 -0
  391. package/web/dist/assets/github-CfV5sqL0.js +1 -0
  392. package/web/dist/assets/{image-preview-DJ8cgb1Z.js → image-preview-FOEfqpZP.js} +1 -1
  393. package/web/dist/assets/index-DgWWlOLy.js +13 -0
  394. package/web/dist/assets/index-fBFnuvxu.css +1 -0
  395. package/web/dist/assets/{nav-row-styles-3j64kH5s.js → nav-row-styles-vp2JbhuJ.js} +1 -1
  396. package/web/dist/assets/play-CmVAj_fu.js +1 -0
  397. package/web/dist/assets/popover-BohP6WTx.js +1 -0
  398. package/web/dist/assets/preview-pane-connected-qTA5KNoJ.js +3 -0
  399. package/web/dist/assets/preview-state-vuMviq6q.js +1 -0
  400. package/web/dist/assets/prompt-templates-Cubdut_C.js +15 -0
  401. package/web/dist/assets/repo-git-Cf4t5PD0.js +1 -0
  402. package/web/dist/assets/{run-diff-5-RRdcVz.js → run-diff-BpkUW37Z.js} +3 -3
  403. package/web/dist/assets/run-header-68WHf9wV.js +1 -0
  404. package/web/dist/assets/skills-DiVIgKeU.js +1 -0
  405. package/web/dist/assets/square-terminal-B6RYYieR.js +1 -0
  406. package/web/dist/assets/status-dot-CqTJHSP9.js +1 -0
  407. package/web/dist/assets/{tab-link-K0hjzEXR.js → tab-link-B07Hu4QX.js} +1 -1
  408. package/web/dist/assets/task-changes--lQF6EYf.js +1 -0
  409. package/web/dist/assets/task-commits-Cx0qy4DN.js +1 -0
  410. package/web/dist/assets/task-files-D50s-gKW.js +2 -0
  411. package/web/dist/assets/task-github-item-DaqmSwYT.js +1 -0
  412. package/web/dist/assets/task-thread-BPQ64lui.js +7 -0
  413. package/web/dist/assets/{task-thread-Bw_nQuTx.css → task-thread-zNE2Q9E-.css} +1 -1
  414. package/web/dist/assets/textarea-D20O4Pw0.js +1 -0
  415. package/web/dist/assets/thread-state-DWcFMrvb.js +4 -0
  416. package/web/dist/assets/use-hand-to-agent-state-BLIGmwbd.css +1 -0
  417. package/web/dist/assets/use-hand-to-agent-state-Cy9eyyfL.js +1 -0
  418. package/web/dist/assets/{utils-fzNfbPzA.js → utils-JsL3ZsJf.js} +1 -1
  419. package/web/dist/assets/workflows-jwG7uxqi.js +11 -0
  420. package/web/dist/assets/{zoomable-image-CDmZ_Rtl.js → zoomable-image-BJJ64KGc.js} +1 -1
  421. package/web/dist/cezarion-lockup-dark.svg +1 -13
  422. package/web/dist/cezarion-lockup-light.svg +1 -13
  423. package/web/dist/cezarion-mark-dark.svg +1 -12
  424. package/web/dist/cezarion-mark-light.svg +1 -12
  425. package/web/dist/index.html +16 -21
  426. package/web/dist/assets/agent-accounts-CU2ZDv24.js +0 -1
  427. package/web/dist/assets/alert-dialog-C-xYE_dg.js +0 -43
  428. package/web/dist/assets/chevron-right-BENZ-1ZN.js +0 -1
  429. package/web/dist/assets/collapsible-DD9J91Iv.js +0 -1
  430. package/web/dist/assets/compare-variants-5FmqpFSN.js +0 -1
  431. package/web/dist/assets/diff-controls-Bj0YrioE.js +0 -1
  432. package/web/dist/assets/diff-rE8rm75J2.js +0 -3
  433. package/web/dist/assets/diff-stat-BKDCSVfJ.js +0 -1
  434. package/web/dist/assets/dropdown-menu-Ch5BYQh_.js +0 -1
  435. package/web/dist/assets/format-dBiNDNVe.js +0 -1
  436. package/web/dist/assets/git-toolbar-ClVvf5iF.js +0 -1
  437. package/web/dist/assets/github-BkNOyour.css +0 -1
  438. package/web/dist/assets/github-DeZMeMwJ.js +0 -1
  439. package/web/dist/assets/github-item-detail-W5F6GVjF.js +0 -1
  440. package/web/dist/assets/github-sidebar-model-DcMu-IK2.js +0 -1
  441. package/web/dist/assets/highlighter-CdHqIwFr.js +0 -3
  442. package/web/dist/assets/index-CatemBEL.js +0 -8
  443. package/web/dist/assets/index-MvfD8bZJ.css +0 -1
  444. package/web/dist/assets/markdown-zdKeLIYA.js +0 -2
  445. package/web/dist/assets/mobile-run-bar-BCfmFi8V.js +0 -1
  446. package/web/dist/assets/prompt-templates-CBPp39IU.js +0 -15
  447. package/web/dist/assets/reference-chip-D6owncJT.js +0 -1
  448. package/web/dist/assets/repo-git-CtdkZFey.js +0 -1
  449. package/web/dist/assets/run-header-BcjoDi0W.js +0 -1
  450. package/web/dist/assets/sheet-ChnYVrp1.js +0 -1
  451. package/web/dist/assets/skills-C8YKp2vr.js +0 -1
  452. package/web/dist/assets/task-changes-BW8YdWG8.js +0 -1
  453. package/web/dist/assets/task-commits-q2kB2y6L.js +0 -1
  454. package/web/dist/assets/task-files-pPL6_3Cr.js +0 -2
  455. package/web/dist/assets/task-github-item-BXF5R52U.js +0 -1
  456. package/web/dist/assets/task-thread-DtkFL3EC.js +0 -10
  457. package/web/dist/assets/textarea-DxlkE-Yd.js +0 -1
  458. package/web/dist/assets/token-metrics-DIAjrPlM.js +0 -1
  459. package/web/dist/assets/use-desktop-CrDny2uG.js +0 -1
  460. package/web/dist/assets/use-submit-shortcut-KWJsC906.js +0 -1
  461. package/web/dist/assets/workflows-TmcPEj2K.js +0 -11
  462. /package/web/dist/assets/{lib-BQXq3kEf2.js → lib-BQXq3kEf.js} +0 -0
@@ -0,0 +1,882 @@
1
+ import { toolDisplay } from './tool-display.js';
2
+ /** Early `subagent_event` buffer bounds (spec § Sub-agents and the Agents drawer). */
3
+ const PENDING_SUBAGENT_EVENTS_PER_ID = 200;
4
+ const PENDING_SUBAGENT_IDS = 8;
5
+ const SUBAGENT_DROP_MESSAGE = 'omp: sub-agent events dropped before lifecycle';
6
+ /** A failure before admission never gets a `prompt_result`, so its id is never released: bound it. */
7
+ const FAILED_PROMPTS_KEPT = 32;
8
+ const EMPTY_LANE = {
9
+ textBlock: 0,
10
+ startedItems: new Set(),
11
+ endedItems: new Set(),
12
+ textByItem: new Map(),
13
+ };
14
+ export function createOmpUiState() {
15
+ return {
16
+ sessionStarted: false,
17
+ sessionId: null,
18
+ turnSeq: 0,
19
+ turnId: null,
20
+ turnPromptId: null,
21
+ turnPromptAdmitted: false,
22
+ stopReason: 'end_turn',
23
+ turnUsage: null,
24
+ turnCostUsd: null,
25
+ sessionUsage: null,
26
+ sessionCostUsd: null,
27
+ latchedProviderError: null,
28
+ ...EMPTY_LANE,
29
+ tools: new Map(),
30
+ subagents: new Map(),
31
+ pendingSubagentEvents: new Map(),
32
+ batchCalls: new Set(),
33
+ childLanes: new Map(),
34
+ subagentDropReported: false,
35
+ failedPrompts: new Set(),
36
+ };
37
+ }
38
+ /**
39
+ * Same as `pi-ui-mapper.ts` `piTurnStarted`, plus the id of the `prompt` that opens the turn
40
+ * (the runner's; omitted when OMP's own activity opened it).
41
+ */
42
+ export function ompTurnStarted(state, promptId) {
43
+ const turnSeq = state.turnSeq + 1;
44
+ const turnId = `turn_${turnSeq}`;
45
+ return {
46
+ events: [{ type: 'turn.started', turnId }],
47
+ state: {
48
+ ...state,
49
+ turnSeq,
50
+ turnId,
51
+ turnPromptId: promptId ?? null,
52
+ turnPromptAdmitted: false,
53
+ stopReason: 'end_turn',
54
+ textBlock: 0,
55
+ },
56
+ };
57
+ }
58
+ /** The frame answers the `prompt` that opened the turn in flight (ids are the runner's). */
59
+ function opensTurn(value, state) {
60
+ const id = string(value.id);
61
+ return state.turnId !== null && id !== undefined && id === state.turnPromptId;
62
+ }
63
+ /**
64
+ * Which frame can end a turn (rpc.md § Yield vs settled): `session_settled` when the session
65
+ * went quiet, or a prompt OMP finished without invoking the agent — a `prompt_result` with
66
+ * `agentInvoked: false`, or the prompt's own success response carrying `data.agentInvoked:
67
+ * false` (no `prompt_result` follows that one). `agent_end` is never a boundary. A `local`
68
+ * boundary ends the turn only for the prompt that opened it: a steer answered locally, or
69
+ * failing after admission (`RpcPromptResults.fail`), leaves the running turn alone.
70
+ */
71
+ export function ompTurnBoundary(value) {
72
+ if (!isRecord(value))
73
+ return null;
74
+ if (value.type === 'session_settled')
75
+ return 'settled';
76
+ if (value.type === 'prompt_result' && value.agentInvoked === false)
77
+ return 'local';
78
+ if (value.type === 'response' &&
79
+ value.command === 'prompt' &&
80
+ value.success === true &&
81
+ isRecord(value.data) &&
82
+ value.data.agentInvoked === false) {
83
+ return 'local';
84
+ }
85
+ return null;
86
+ }
87
+ /** Same rule as `pi-ui-mapper.ts` `mapActivity`: activity after the turn ended re-opens one. */
88
+ function mapActivity(value, state, map) {
89
+ if (state.turnId)
90
+ return map(value, state);
91
+ const started = ompTurnStarted(state);
92
+ const mapped = map(value, started.state);
93
+ if (mapped.events.length === 0)
94
+ return { events: [], state };
95
+ return { events: [...started.events, ...mapped.events], state: mapped.state };
96
+ }
97
+ function isMessageUpdateActivity(value) {
98
+ const update = isRecord(value.assistantMessageEvent) ? value.assistantMessageEvent : undefined;
99
+ const type = update ? string(update.type) : undefined;
100
+ return type?.startsWith('text_') === true || type?.startsWith('thinking_') === true;
101
+ }
102
+ function isAssistantMessageEnd(value) {
103
+ return isRecord(value.message) && string(value.message.role) === 'assistant';
104
+ }
105
+ function isToolStart(value) {
106
+ return Boolean(string(value.toolCallId) && string(value.toolName));
107
+ }
108
+ export function mapOmpRpcMessage(value, state) {
109
+ if (!isRecord(value) || typeof value.type !== 'string')
110
+ return { events: [], state };
111
+ if (value.type === 'response')
112
+ return mapResponse(value, state);
113
+ switch (value.type) {
114
+ case 'message_update':
115
+ return isMessageUpdateActivity(value)
116
+ ? mapActivity(value, state, mapMessageUpdate)
117
+ : mapMessageUpdate(value, state);
118
+ case 'message_end':
119
+ return isAssistantMessageEnd(value)
120
+ ? mapActivity(value, state, mapMessageEnd)
121
+ : mapMessageEnd(value, state);
122
+ case 'tool_execution_start':
123
+ return isToolStart(value) ? mapActivity(value, state, mapToolStart) : mapToolStart(value, state);
124
+ case 'tool_execution_update':
125
+ return mapActivity(value, state, mapToolUpdate);
126
+ case 'tool_execution_end':
127
+ return mapActivity(value, state, mapToolEnd);
128
+ case 'session_settled':
129
+ return completeTurn(state.stopReason, state);
130
+ case 'prompt_result':
131
+ return mapPromptResult(value, state);
132
+ case 'subagent_lifecycle':
133
+ return isRecord(value.payload) ? mapSubagentLifecycle(value.payload, state) : { events: [], state };
134
+ case 'subagent_event':
135
+ return isRecord(value.payload) ? mapSubagentEvent(value.payload, state) : { events: [], state };
136
+ case 'extension_error': {
137
+ const message = string(value.error) ?? string(value.message) ?? 'omp extension error';
138
+ return { events: [{ type: 'session.error', message, fatal: false }], state };
139
+ }
140
+ case 'notice': {
141
+ if (value.level !== 'error')
142
+ return { events: [], state };
143
+ const message = string(value.message) ?? 'omp error notice';
144
+ return { events: [{ type: 'session.error', message, fatal: false }], state };
145
+ }
146
+ // `agent_end` (any `yielded`), `ready`, `queue_update`, `auto_*`, `cache_warming_*`, and the
147
+ // unsolicited startup frames `extension_ui_request`, `advisor_cost_changed`,
148
+ // `available_commands_update` (recorded from the real v18.4.11 binary) carry nothing here.
149
+ default:
150
+ return { events: [], state };
151
+ }
152
+ }
153
+ function mapResponse(value, state) {
154
+ const command = string(value.command);
155
+ if (command === 'get_state' && value.success === true && isRecord(value.data)) {
156
+ const sessionId = string(value.data.sessionId);
157
+ if (sessionId && !state.sessionStarted) {
158
+ const model = isRecord(value.data.model) ? string(value.data.model.id) : undefined;
159
+ return {
160
+ events: [{ type: 'session.started', sessionId, backend: 'omp', ...(model ? { model } : {}) }],
161
+ state: { ...state, sessionStarted: true, sessionId },
162
+ };
163
+ }
164
+ return { events: [], state };
165
+ }
166
+ if (command === 'prompt') {
167
+ if (value.success === false) {
168
+ // rpc.md § Request/Response Correlation: a prompt that fails before admission gets only
169
+ // this error response — no `prompt_result` follows — so it is reported here. A failure
170
+ // after admission sends this response after the success ack, AND a `prompt_result`,
171
+ // whose error is then skipped. The opening prompt failing before its ack ends the turn
172
+ // (Ruling 10); a steer failing leaves it running.
173
+ const id = string(value.id);
174
+ let failedPrompts = state.failedPrompts;
175
+ if (id) {
176
+ const kept = [...failedPrompts, id].slice(-FAILED_PROMPTS_KEPT);
177
+ failedPrompts = new Set(kept);
178
+ }
179
+ const error = { type: 'session.error', message: `omp: prompt failed: ${rpcError(value)}`, fatal: false };
180
+ if (opensTurn(value, state) && !state.turnPromptAdmitted) {
181
+ const completed = completeTurn('error', state);
182
+ return { events: [error, ...completed.events], state: { ...completed.state, failedPrompts } };
183
+ }
184
+ return { events: [error], state: { ...state, failedPrompts } };
185
+ }
186
+ if (value.success !== true || !opensTurn(value, state))
187
+ return { events: [], state };
188
+ const admitted = { ...state, turnPromptAdmitted: true };
189
+ return ompTurnBoundary(value) === 'local' ? completeTurn(state.stopReason, admitted) : { events: [], state: admitted };
190
+ }
191
+ // `set_*` failures are configuration notes for the runner (v1), not session errors.
192
+ if (value.success === false && !command?.startsWith('set_')) {
193
+ return { events: [{ type: 'session.error', message: rpcError(value), fatal: false }], state };
194
+ }
195
+ return { events: [], state };
196
+ }
197
+ function mapPromptResult(value, state) {
198
+ // An agent-invoked prompt yields here, but the turn runs on until `session_settled`.
199
+ if (ompTurnBoundary(value) !== 'local')
200
+ return { events: [], state };
201
+ const status = string(value.status);
202
+ const id = string(value.id);
203
+ // Only the prompt that opened the turn ends it; a steer's local completion does not.
204
+ const ends = opensTurn(value, state);
205
+ const end = (reason, next) => ends ? completeTurn(reason, next) : { events: [], state: next };
206
+ if (status === 'error' && id && state.failedPrompts.has(id)) {
207
+ // Its failure response already reported the error; this frame only ends the turn.
208
+ const failedPrompts = new Set(state.failedPrompts);
209
+ failedPrompts.delete(id);
210
+ return end('error', { ...state, failedPrompts });
211
+ }
212
+ if (status === 'error') {
213
+ const error = isRecord(value.error) ? value.error : {};
214
+ const message = ompProviderErrorMessage({
215
+ provider: error.provider,
216
+ model: error.model,
217
+ errorMessage: error.message,
218
+ });
219
+ const completed = end('error', state);
220
+ return { events: [{ type: 'session.error', message, fatal: false }, ...completed.events], state: completed.state };
221
+ }
222
+ return end(status === 'aborted' ? 'cancelled' : state.stopReason, state);
223
+ }
224
+ /* ------------------------------------------------------------------ */
225
+ /* Text and reasoning — same wire as pi-ui-mapper.ts (rpc.md, v18.4.11) */
226
+ /* ------------------------------------------------------------------ */
227
+ /** Parent ids are `<turnId>_text_…`, child ids `<rowId>/text_…` (see `ItemScope`). */
228
+ const LANE_ITEM = /[_/](text|reasoning)_\d+_\d+$/;
229
+ function laneOf(state) {
230
+ return {
231
+ textBlock: state.textBlock,
232
+ startedItems: state.startedItems,
233
+ endedItems: state.endedItems,
234
+ textByItem: state.textByItem,
235
+ };
236
+ }
237
+ function withChildLane(state, rowId, lane) {
238
+ const childLanes = new Map(state.childLanes);
239
+ childLanes.set(rowId, lane);
240
+ return { ...state, childLanes };
241
+ }
242
+ /** Same wire as pi-ui-mapper.ts `mapMessageUpdate` (rpc.md, v18.4.11), for one lane. */
243
+ function laneTextUpdate(update, lane, scope) {
244
+ const updateType = string(update.type);
245
+ const contentIndex = number(update.contentIndex) ?? 0;
246
+ const field = updateType?.startsWith('thinking_') ? 'reasoning' : updateType?.startsWith('text_') ? 'text' : null;
247
+ if (!updateType || !field)
248
+ return { events: [], lane };
249
+ const itemId = `${scope.textPrefix}${field}_${contentIndex}_${lane.textBlock}`;
250
+ const events = [];
251
+ let { startedItems, textByItem, endedItems } = lane;
252
+ const makeItem = (text) => withParent(field === 'text' ? { kind: 'message', id: itemId, role: 'assistant', text } : { kind: 'reasoning', id: itemId, text }, scope);
253
+ const delta = string(update.delta);
254
+ if (!startedItems.has(itemId)) {
255
+ if (delta === undefined && !updateType.endsWith('_end'))
256
+ return { events: [], lane };
257
+ events.push({ type: 'item.started', item: makeItem('') });
258
+ startedItems = new Set(startedItems).add(itemId);
259
+ }
260
+ if (delta !== undefined) {
261
+ events.push({ type: 'item.delta', itemId, field, delta });
262
+ const next = new Map(textByItem);
263
+ next.set(itemId, `${next.get(itemId) ?? ''}${delta}`);
264
+ textByItem = next;
265
+ }
266
+ if (updateType.endsWith('_end')) {
267
+ const text = string(update.content) ?? textByItem.get(itemId) ?? '';
268
+ events.push({ type: 'item.completed', item: makeItem(text) });
269
+ endedItems = new Set(endedItems).add(itemId);
270
+ }
271
+ return { events, lane: { ...lane, startedItems, textByItem, endedItems } };
272
+ }
273
+ /** Same as pi-ui-mapper.ts `closeOpenPiText`, for one lane. */
274
+ function closeLaneText(lane, scope) {
275
+ const events = [];
276
+ let endedItems = lane.endedItems;
277
+ for (const id of lane.startedItems) {
278
+ if (endedItems.has(id))
279
+ continue;
280
+ const kind = LANE_ITEM.exec(id)?.[1];
281
+ if (!kind)
282
+ continue;
283
+ const text = lane.textByItem.get(id) ?? '';
284
+ events.push({
285
+ type: 'item.completed',
286
+ item: withParent(kind === 'text' ? { kind: 'message', id, role: 'assistant', text } : { kind: 'reasoning', id, text }, scope),
287
+ });
288
+ endedItems = new Set(endedItems).add(id);
289
+ }
290
+ return { events, lane: { ...lane, endedItems, textBlock: lane.textBlock + 1 } };
291
+ }
292
+ function parentScope(state) {
293
+ return { textPrefix: `${state.turnId ?? 'turn_0'}_`, toolPrefix: '' };
294
+ }
295
+ function childScope(rowId) {
296
+ return { textPrefix: `${rowId}/`, toolPrefix: `${rowId}/`, parentItemId: rowId };
297
+ }
298
+ function withParent(item, scope) {
299
+ return scope.parentItemId === undefined ? item : { ...item, parentItemId: scope.parentItemId };
300
+ }
301
+ function closeParentText(state) {
302
+ const closed = closeLaneText(laneOf(state), parentScope(state));
303
+ return { events: closed.events, state: { ...state, ...closed.lane } };
304
+ }
305
+ /** Same wire as pi-ui-mapper.ts `mapMessageUpdate` (rpc.md, v18.4.11). */
306
+ function mapMessageUpdate(value, state) {
307
+ const update = isRecord(value.assistantMessageEvent) ? value.assistantMessageEvent : undefined;
308
+ const updateType = update ? string(update.type) : undefined;
309
+ if (!update || !updateType || !state.turnId)
310
+ return { events: [], state };
311
+ if (updateType === 'done') {
312
+ return { events: [], state: { ...state, stopReason: mapOmpMessageStopReason(string(update.reason)) } };
313
+ }
314
+ if (updateType === 'error') {
315
+ const reason = string(update.reason) === 'aborted' ? 'cancelled' : 'error';
316
+ const error = isRecord(update.error) ? string(update.error.errorMessage) : undefined;
317
+ return {
318
+ events: [],
319
+ state: { ...state, stopReason: reason, latchedProviderError: error ?? `omp model ${reason}` },
320
+ };
321
+ }
322
+ const mapped = laneTextUpdate(update, laneOf(state), parentScope(state));
323
+ return { events: mapped.events, state: { ...state, ...mapped.lane } };
324
+ }
325
+ /** Same wire as pi-ui-mapper.ts `mapMessageEnd` (rpc.md, v18.4.11). */
326
+ function mapMessageEnd(value, state) {
327
+ const message = isRecord(value.message) ? value.message : undefined;
328
+ if (!message || string(message.role) !== 'assistant')
329
+ return { events: [], state };
330
+ const closed = closeParentText(state);
331
+ state = closed.state;
332
+ const events = [...closed.events];
333
+ const accounted = accountUsage(ompMessageUsage(value), state);
334
+ events.push(...accounted.events);
335
+ state = accounted.state;
336
+ // Latch the failed attempt, clear on a successful one (#316): `agent_end {yielded:false}`
337
+ // follows a failed attempt OMP is about to retry, and a recovered retry must stay silent.
338
+ if (string(message.stopReason) === 'error') {
339
+ state = { ...state, latchedProviderError: ompProviderErrorMessage(message) };
340
+ }
341
+ else {
342
+ state = { ...state, latchedProviderError: null };
343
+ }
344
+ state = { ...state, stopReason: mapOmpMessageStopReason(string(message.stopReason)) };
345
+ return { events, state };
346
+ }
347
+ /** Same as pi-ui-mapper.ts `mapPiMessageStopReason`. */
348
+ function mapOmpMessageStopReason(reason) {
349
+ if (reason === 'error')
350
+ return 'error';
351
+ if (reason === 'aborted')
352
+ return 'cancelled';
353
+ if (reason === 'length')
354
+ return 'max_tokens';
355
+ return 'end_turn';
356
+ }
357
+ /* ------------------------------------------------------------------ */
358
+ /* Tools */
359
+ /* ------------------------------------------------------------------ */
360
+ /** `toolDisplay` plus the OMP-only shapes: `todo` is the plan tool and a batch `task` is a plain card. */
361
+ function ompToolDisplay(name, args) {
362
+ if (name === 'todo')
363
+ return { toolKind: 'plan', title: 'Update plan' };
364
+ if (name === 'task' && isRecord(args) && Array.isArray(args.tasks)) {
365
+ // The drawer lists one synthetic row per sub-agent; the card itself must not be a row too.
366
+ return { toolKind: 'other', title: `Task batch · ${args.tasks.length} agent${args.tasks.length === 1 ? '' : 's'}` };
367
+ }
368
+ // The single form has no `description`; its `task` text is the row's label.
369
+ const display = name === 'task' && isRecord(args) && args.description === undefined
370
+ ? toolDisplay(name, { description: args.task })
371
+ : toolDisplay(name, args);
372
+ return { toolKind: display.toolKind, title: display.title };
373
+ }
374
+ function mapToolStart(value, state) {
375
+ const callId = string(value.toolCallId);
376
+ const name = string(value.toolName);
377
+ if (!callId || !name)
378
+ return { events: [], state };
379
+ const closed = closeParentText(state);
380
+ state = closed.state;
381
+ const started = toolStarted(callId, name, value.args, parentScope(state), state);
382
+ let batchCalls = state.batchCalls;
383
+ if (name === 'task' && isRecord(value.args) && Array.isArray(value.args.tasks)) {
384
+ batchCalls = new Set(batchCalls).add(callId);
385
+ }
386
+ return { events: [...closed.events, ...started.events], state: { ...started.state, batchCalls } };
387
+ }
388
+ function toolStarted(callId, name, args, scope, state) {
389
+ const display = ompToolDisplay(name, args);
390
+ const item = withParent({
391
+ kind: 'tool',
392
+ id: `${scope.toolPrefix}${callId}`,
393
+ name,
394
+ toolKind: display.toolKind,
395
+ title: display.title,
396
+ status: 'running',
397
+ input: args,
398
+ }, scope);
399
+ const tools = new Map(state.tools);
400
+ tools.set(item.id, item);
401
+ return { events: [{ type: 'item.started', item }], state: { ...state, tools } };
402
+ }
403
+ function mapToolUpdate(value, state) {
404
+ return toolUpdated(value, '', state);
405
+ }
406
+ function toolUpdated(value, toolPrefix, state) {
407
+ const callId = string(value.toolCallId);
408
+ const id = callId ? `${toolPrefix}${callId}` : undefined;
409
+ const previous = id ? state.tools.get(id) : undefined;
410
+ if (!id || !previous)
411
+ return { events: [], state };
412
+ const output = contentText(isRecord(value.partialResult) ? value.partialResult.content : undefined);
413
+ if (output === undefined)
414
+ return { events: [], state };
415
+ const item = { ...previous, output };
416
+ const tools = new Map(state.tools);
417
+ tools.set(id, item);
418
+ return { events: [{ type: 'item.updated', item }], state: { ...state, tools } };
419
+ }
420
+ function mapToolEnd(value, state) {
421
+ return toolEnded(value, parentScope(state), state, true);
422
+ }
423
+ function toolEnded(value, scope, state, publishPlan) {
424
+ const callId = string(value.toolCallId);
425
+ const id = callId ? `${scope.toolPrefix}${callId}` : undefined;
426
+ const previous = id ? state.tools.get(id) : undefined;
427
+ if (!id || !previous)
428
+ return { events: [], state };
429
+ const result = isRecord(value.result) ? value.result : {};
430
+ const output = contentText(result.content);
431
+ const isError = value.isError === true || result.isError === true;
432
+ // A single-form `task` row is its sub-agent's: in RPC OMP runs `task` asynchronously by
433
+ // default, so the result can arrive while the agent still runs, and an aborted agent's result
434
+ // can still read as success. Its lifecycle status wins over a successful result.
435
+ const agent = scope.toolPrefix === '' ? singleFormSubagent(state, id) : undefined;
436
+ if (agent)
437
+ state = withSubagent(state, agent[0], { ...agent[1], ended: true });
438
+ const status = isError ? 'failed' : agent ? agent[1].status : 'completed';
439
+ const item = {
440
+ ...previous,
441
+ status,
442
+ ...(isError ? { error: output ?? 'omp tool failed' } : output !== undefined ? { output } : {}),
443
+ };
444
+ const diffs = isError ? undefined : ompToolDiffs(previous.name, previous.input, result);
445
+ if (diffs) {
446
+ item.diffs = diffs;
447
+ // Hashline edits carry the path only in `{input}` text; the result names it.
448
+ if (previous.name.toLowerCase() === 'edit' && !argsPath(previous.input)) {
449
+ item.title = diffs.length === 1 ? `Edit ${diffs[0].path}` : `Edit ${diffs.length} files`;
450
+ }
451
+ }
452
+ const tools = new Map(state.tools);
453
+ tools.set(id, item);
454
+ const events = [{ type: status === 'running' ? 'item.updated' : 'item.completed', item }];
455
+ // A sub-agent's todo list is its own; it never replaces the session's plan dock.
456
+ const plan = publishPlan && !isError ? ompToolPlan(previous.name, result) : undefined;
457
+ if (plan)
458
+ events.push({ type: 'plan.updated', entries: plan });
459
+ return { events, state: { ...state, tools } };
460
+ }
461
+ /**
462
+ * Diffs for an `edit`/`write` call. OMP's default `edit.mode` is `hashline` (args `{input}`), so
463
+ * the change lives in the result `details` (`path`/`oldText`/`newText`, or `perFileResults[]` for
464
+ * several files — `src/edit/index.ts` `aggregateDetails`, v18.4.11). Falls back to replace-mode
465
+ * args and `write` content, the same reading as pi-ui-mapper.ts `toolDiffs`.
466
+ */
467
+ function ompToolDiffs(name, args, result) {
468
+ const key = name.toLowerCase();
469
+ if (key !== 'edit' && key !== 'write')
470
+ return undefined;
471
+ const details = isRecord(result.details) ? result.details : undefined;
472
+ if (details) {
473
+ const files = Array.isArray(details.perFileResults) ? details.perFileResults : [details];
474
+ const diffs = files.flatMap((file) => {
475
+ const diff = isRecord(file) ? detailDiff(file) : undefined;
476
+ return diff ? [diff] : [];
477
+ });
478
+ if (diffs.length > 0)
479
+ return diffs;
480
+ }
481
+ return argsDiffs(key, args);
482
+ }
483
+ function detailDiff(file) {
484
+ const path = string(file.path);
485
+ const oldText = string(file.oldText);
486
+ const newText = string(file.newText);
487
+ if (!path || (oldText === undefined && newText === undefined))
488
+ return undefined;
489
+ return { path, oldText: oldText ?? null, ...(newText !== undefined ? { newText } : {}) };
490
+ }
491
+ /** The path keys `toolDisplay` titles an edit from. */
492
+ function argsPath(input) {
493
+ if (!isRecord(input))
494
+ return undefined;
495
+ return string(input.path) ?? string(input.file_path) ?? string(input.filePath);
496
+ }
497
+ /** Same reading as pi-ui-mapper.ts `toolDiffs`. */
498
+ function argsDiffs(key, input) {
499
+ if (!isRecord(input))
500
+ return undefined;
501
+ const path = argsPath(input);
502
+ if (!path)
503
+ return undefined;
504
+ const oldText = string(input.oldText) ?? string(input.old_string) ?? (key === 'write' ? null : undefined);
505
+ const newText = string(input.newText) ?? string(input.new_string) ?? string(input.content);
506
+ if (oldText === undefined && newText === undefined)
507
+ return undefined;
508
+ return [{ path, oldText: oldText ?? null, ...(newText !== undefined ? { newText } : {}) }];
509
+ }
510
+ const TODO_STATUS = {
511
+ pending: 'pending',
512
+ in_progress: 'in_progress',
513
+ completed: 'completed',
514
+ abandoned: 'cancelled',
515
+ // A blocked task is still to do; the plan vocabulary has no "blocked".
516
+ blocked: 'pending',
517
+ };
518
+ /**
519
+ * The whole plan from a state-changing `todo` result: `details.phases[].tasks[]` holds the full
520
+ * list after the op (`src/tools/todo.ts` `committedTodoPhases`, v18.4.11). `view` is a read.
521
+ */
522
+ function ompToolPlan(name, result) {
523
+ if (name !== 'todo' || !isRecord(result.details))
524
+ return undefined;
525
+ const { op, phases } = result.details;
526
+ if (op === 'view' || !Array.isArray(phases))
527
+ return undefined;
528
+ const entries = [];
529
+ for (const phase of phases) {
530
+ if (!isRecord(phase) || !Array.isArray(phase.tasks))
531
+ continue;
532
+ for (const task of phase.tasks) {
533
+ if (!isRecord(task))
534
+ continue;
535
+ const content = string(task.content);
536
+ const status = TODO_STATUS[string(task.status) ?? ''];
537
+ if (content && status)
538
+ entries.push({ content, status });
539
+ }
540
+ }
541
+ return entries;
542
+ }
543
+ /* ------------------------------------------------------------------ */
544
+ /* Sub-agents */
545
+ /* ------------------------------------------------------------------ */
546
+ function lifecycleStatus(status) {
547
+ if (status === 'completed')
548
+ return 'completed';
549
+ if (status === 'failed' || status === 'aborted')
550
+ return 'failed';
551
+ return 'running';
552
+ }
553
+ /** The batch entry this sub-agent runs: by `name` (OMP derives the id from it), else by index. */
554
+ function batchTask(parent, id, index) {
555
+ const tasks = isRecord(parent?.input) && Array.isArray(parent.input.tasks) ? parent.input.tasks : [];
556
+ const byName = tasks.find((task) => isRecord(task) && string(task.name) === id);
557
+ if (isRecord(byName))
558
+ return byName;
559
+ const byIndex = index !== undefined ? tasks[index] : undefined;
560
+ return isRecord(byIndex) ? byIndex : undefined;
561
+ }
562
+ function mapSubagentLifecycle(payload, state) {
563
+ const id = string(payload.id);
564
+ if (!id)
565
+ return { events: [], state };
566
+ const status = lifecycleStatus(string(payload.status));
567
+ const events = [];
568
+ const parentToolCallId = string(payload.parentToolCallId) ?? '';
569
+ let entry = state.subagents.get(id);
570
+ // v18.4.11 `AgentOutputManager.allocate` keeps ids unique within one session, but a
571
+ // `new_session` in the same process starts a fresh allocator. A `started` frame naming
572
+ // another parent call is a new agent: rebind the id so its events cannot reach the old row.
573
+ if (entry && string(payload.status) === 'started' && parentToolCallId && entry.parentToolCallId !== parentToolCallId) {
574
+ entry = undefined;
575
+ }
576
+ if (!entry) {
577
+ const parent = parentToolCallId ? state.tools.get(parentToolCallId) : undefined;
578
+ // A single-form call IS the sub-agent's row; a batch call (or an unknown parent) gets one
579
+ // synthetic `task` row per sub-agent so the drawer counts agents, not calls.
580
+ const single = parent !== undefined && !state.batchCalls.has(parentToolCallId);
581
+ const rowId = single ? parentToolCallId : `${parentToolCallId || 'omp-subagent'}#${id}`;
582
+ entry = { rowId, parentToolCallId, status, ended: false };
583
+ state = withSubagent(state, id, entry);
584
+ if (!single) {
585
+ const agent = string(payload.agent);
586
+ const task = batchTask(parent, id, number(payload.index));
587
+ const taskText = task ? string(task.task) : undefined;
588
+ const label = string(payload.description) ?? taskText ?? agent ?? id;
589
+ const item = {
590
+ kind: 'tool',
591
+ id: rowId,
592
+ name: 'task',
593
+ toolKind: 'task',
594
+ title: toolDisplay('task', { description: label }).title,
595
+ status: 'running',
596
+ input: { ...(agent ? { agent } : {}), ...(taskText ? { task: taskText } : {}) },
597
+ };
598
+ const tools = new Map(state.tools);
599
+ tools.set(rowId, item);
600
+ state = { ...state, tools };
601
+ events.push({ type: 'item.started', item });
602
+ }
603
+ }
604
+ // Replay what arrived before this frame named the parent, ahead of any terminal close.
605
+ const buffered = state.pendingSubagentEvents.get(id);
606
+ if (buffered) {
607
+ const pendingSubagentEvents = new Map(state.pendingSubagentEvents);
608
+ pendingSubagentEvents.delete(id);
609
+ state = { ...state, pendingSubagentEvents };
610
+ for (const event of buffered) {
611
+ const mapped = mapChildEvent(event, entry.rowId, state);
612
+ state = mapped.state;
613
+ events.push(...mapped.events);
614
+ }
615
+ }
616
+ if (status !== 'running') {
617
+ // An aborted agent leaves its last block open; it ends with the agent, not the turn.
618
+ const lane = state.childLanes.get(entry.rowId);
619
+ if (lane) {
620
+ const closed = closeLaneText(lane, childScope(entry.rowId));
621
+ events.push(...closed.events);
622
+ state = withChildLane(state, entry.rowId, closed.lane);
623
+ }
624
+ }
625
+ if (entry.status !== status) {
626
+ entry = { ...entry, status };
627
+ state = withSubagent(state, id, entry);
628
+ }
629
+ // A batch row is the agent's own; a single-form row is the `task` call, which follows the
630
+ // lifecycle only once its result has arrived (`toolEnded` reads `status` up to then).
631
+ const single = entry.rowId === entry.parentToolCallId;
632
+ const row = !single || (entry.ended && status !== 'running') ? state.tools.get(entry.rowId) : undefined;
633
+ if (row && row.status !== status && (!single || row.status === 'running')) {
634
+ const item = { ...row, status };
635
+ const tools = new Map(state.tools);
636
+ tools.set(row.id, item);
637
+ state = { ...state, tools };
638
+ events.push({ type: status === 'running' ? 'item.updated' : 'item.completed', item });
639
+ }
640
+ return { events, state };
641
+ }
642
+ /** The sub-agent whose single-form `task` call is row `rowId`, with its id. */
643
+ function singleFormSubagent(state, rowId) {
644
+ for (const [id, entry] of state.subagents) {
645
+ if (entry.rowId === rowId && entry.parentToolCallId === rowId)
646
+ return [id, entry];
647
+ }
648
+ return undefined;
649
+ }
650
+ function withSubagent(state, id, entry) {
651
+ const subagents = new Map(state.subagents);
652
+ subagents.set(id, entry);
653
+ return { ...state, subagents };
654
+ }
655
+ function mapSubagentEvent(payload, state) {
656
+ const id = string(payload.id);
657
+ if (!id || !isRecord(payload.event))
658
+ return { events: [], state };
659
+ // Account on receipt, before the presentation buffer. Replaying or dropping visual
660
+ // frames must neither duplicate nor discard spend (hearsay-tools/cezarion#833).
661
+ const accounted = accountUsage(ompMessageUsage({ type: 'subagent_event', payload }), state);
662
+ const mapped = mapSubagentVisualEvent(id, payload.event, accounted.state);
663
+ return { events: [...accounted.events, ...mapped.events], state: mapped.state };
664
+ }
665
+ function mapSubagentVisualEvent(id, event, state) {
666
+ const entry = state.subagents.get(id);
667
+ if (entry)
668
+ return mapChildEvent(event, entry.rowId, state);
669
+ // Only the lifecycle frame names the parent call: hold the event until it arrives.
670
+ const buffered = state.pendingSubagentEvents.get(id);
671
+ const full = buffered
672
+ ? buffered.length >= PENDING_SUBAGENT_EVENTS_PER_ID
673
+ : state.pendingSubagentEvents.size >= PENDING_SUBAGENT_IDS;
674
+ if (full) {
675
+ if (state.subagentDropReported)
676
+ return { events: [], state };
677
+ return {
678
+ events: [{ type: 'session.error', message: SUBAGENT_DROP_MESSAGE, fatal: false }],
679
+ state: { ...state, subagentDropReported: true },
680
+ };
681
+ }
682
+ const pendingSubagentEvents = new Map(state.pendingSubagentEvents);
683
+ pendingSubagentEvents.set(id, [...(buffered ?? []), event]);
684
+ return { events: [], state: { ...state, pendingSubagentEvents } };
685
+ }
686
+ /**
687
+ * One sub-agent's `AgentSessionEvent`, nested under its row. It never ends the parent turn,
688
+ * never writes parent text or plan: a child `agent_end` only closes the child's own open
689
+ * text. Usage is accounted on receipt, outside this replayable presentation path.
690
+ */
691
+ function mapChildEvent(event, rowId, state) {
692
+ if (!isRecord(event) || typeof event.type !== 'string')
693
+ return { events: [], state };
694
+ const scope = childScope(rowId);
695
+ const lane = state.childLanes.get(rowId) ?? EMPTY_LANE;
696
+ switch (event.type) {
697
+ case 'message_update': {
698
+ if (!isRecord(event.assistantMessageEvent))
699
+ return { events: [], state };
700
+ const mapped = laneTextUpdate(event.assistantMessageEvent, lane, scope);
701
+ return { events: mapped.events, state: withChildLane(state, rowId, mapped.lane) };
702
+ }
703
+ case 'message_end':
704
+ case 'agent_end': {
705
+ if (event.type === 'message_end' && !isAssistantMessageEnd(event))
706
+ return { events: [], state };
707
+ const closed = closeLaneText(lane, scope);
708
+ return { events: closed.events, state: withChildLane(state, rowId, closed.lane) };
709
+ }
710
+ case 'tool_execution_start': {
711
+ const callId = string(event.toolCallId);
712
+ const name = string(event.toolName);
713
+ if (!callId || !name)
714
+ return { events: [], state };
715
+ const closed = closeLaneText(lane, scope);
716
+ const started = toolStarted(callId, name, event.args, scope, withChildLane(state, rowId, closed.lane));
717
+ return { events: [...closed.events, ...started.events], state: started.state };
718
+ }
719
+ case 'tool_execution_update':
720
+ return toolUpdated(event, scope.toolPrefix, state);
721
+ case 'tool_execution_end':
722
+ return toolEnded(event, scope, state, false);
723
+ default:
724
+ return { events: [], state };
725
+ }
726
+ }
727
+ /* ------------------------------------------------------------------ */
728
+ /* Turn end, usage and errors */
729
+ /* ------------------------------------------------------------------ */
730
+ /** Same as pi-ui-mapper.ts `completeTurn`, also closing every sub-agent's open text. */
731
+ function completeTurn(reason, state) {
732
+ if (!state.turnId)
733
+ return { events: [], state };
734
+ const turnId = state.turnId;
735
+ const closed = closeParentText(state);
736
+ state = closed.state;
737
+ const events = [...closed.events];
738
+ for (const [rowId, lane] of state.childLanes) {
739
+ const child = closeLaneText(lane, childScope(rowId));
740
+ events.push(...child.events);
741
+ state = withChildLane(state, rowId, child.lane);
742
+ }
743
+ const flushed = ompFlushProviderError(state);
744
+ state = flushed.state;
745
+ const event = { type: 'turn.completed', turnId, stopReason: reason };
746
+ if (state.turnUsage)
747
+ event.usage = state.turnUsage;
748
+ if (state.turnCostUsd !== null)
749
+ event.costUsd = state.turnCostUsd;
750
+ return {
751
+ events: [...events, ...flushed.events, event],
752
+ state: { ...state, turnId: null, turnPromptId: null, turnPromptAdmitted: false, turnUsage: null, turnCostUsd: null },
753
+ };
754
+ }
755
+ /** Same as pi-ui-mapper.ts `piFlushProviderError`: release the latch as `session.error` (#256). */
756
+ export function ompFlushProviderError(state) {
757
+ if (!state.latchedProviderError)
758
+ return { events: [], state };
759
+ return {
760
+ events: [{ type: 'session.error', message: state.latchedProviderError, fatal: false }],
761
+ state: { ...state, latchedProviderError: null },
762
+ };
763
+ }
764
+ /** Same as pi-ui-mapper.ts `piProviderErrorMessage`, prefixed `omp:`. */
765
+ export function ompProviderErrorMessage(message) {
766
+ const detail = ompProviderErrorDetail(message);
767
+ const provider = string(message.provider);
768
+ const model = string(message.model);
769
+ const who = provider && model ? `${provider}/${model}` : (provider ?? model);
770
+ if (who && detail)
771
+ return `omp: ${who} request failed: ${detail}`;
772
+ if (who)
773
+ return `omp: ${who} request failed`;
774
+ if (detail)
775
+ return `omp: provider request failed: ${detail}`;
776
+ return 'omp: provider request failed';
777
+ }
778
+ /** Same as pi-ui-mapper.ts `piProviderErrorDetail`. */
779
+ function ompProviderErrorDetail(message) {
780
+ if (Array.isArray(message.diagnostics)) {
781
+ for (const diagnostic of message.diagnostics) {
782
+ if (!isRecord(diagnostic) || string(diagnostic.type) !== 'provider_transport_failure')
783
+ continue;
784
+ const error = isRecord(diagnostic.error) ? string(diagnostic.error.message) : undefined;
785
+ if (error)
786
+ return error;
787
+ }
788
+ }
789
+ return string(message.errorMessage);
790
+ }
791
+ /** Read the same native per-message report for both v1 and v2, including child envelopes. */
792
+ export function ompMessageUsage(value) {
793
+ if (!isRecord(value))
794
+ return undefined;
795
+ if (value.type === 'subagent_event') {
796
+ if (!isRecord(value.payload) || !string(value.payload.id) || !isRecord(value.payload.event))
797
+ return undefined;
798
+ value = value.payload.event;
799
+ }
800
+ if (!isRecord(value) || value.type !== 'message_end' || !isRecord(value.message) || value.message.role !== 'assistant')
801
+ return undefined;
802
+ return usageEvent(value.message.usage);
803
+ }
804
+ function sumUsage(previous, next) {
805
+ return {
806
+ input: (previous?.input ?? 0) + next.input,
807
+ output: (previous?.output ?? 0) + next.output,
808
+ total: (previous?.total ?? 0) + (next.total ?? 0),
809
+ ...(previous?.cacheRead !== undefined || next.cacheRead !== undefined
810
+ ? { cacheRead: (previous?.cacheRead ?? 0) + (next.cacheRead ?? 0) } : {}),
811
+ ...(previous?.cacheWrite !== undefined || next.cacheWrite !== undefined
812
+ ? { cacheWrite: (previous?.cacheWrite ?? 0) + (next.cacheWrite ?? 0) } : {}),
813
+ };
814
+ }
815
+ function accountUsage(report, state) {
816
+ if (!report)
817
+ return { events: [], state };
818
+ const sessionUsage = sumUsage(state.sessionUsage, report.usage);
819
+ const sessionCostUsd = report.costUsd === undefined ? state.sessionCostUsd : (state.sessionCostUsd ?? 0) + report.costUsd;
820
+ return {
821
+ events: [{ type: 'usage.updated', usage: sessionUsage, ...(sessionCostUsd !== null ? { costUsd: sessionCostUsd } : {}) }],
822
+ state: {
823
+ ...state, sessionUsage, sessionCostUsd,
824
+ ...(state.turnId ? {
825
+ turnUsage: sumUsage(state.turnUsage, report.usage),
826
+ turnCostUsd: report.costUsd === undefined ? state.turnCostUsd : (state.turnCostUsd ?? 0) + report.costUsd,
827
+ } : {}),
828
+ },
829
+ };
830
+ }
831
+ /** Native OMP message usage is an increment; the public usage.updated event is cumulative. */
832
+ function usageEvent(value) {
833
+ if (!isRecord(value))
834
+ return undefined;
835
+ const input = number(value.input) ?? 0;
836
+ const output = number(value.output) ?? 0;
837
+ const cacheRead = number(value.cacheRead);
838
+ const cacheWrite = number(value.cacheWrite);
839
+ const total = number(value.totalTokens) ?? input + output + (cacheRead ?? 0) + (cacheWrite ?? 0);
840
+ const cost = isRecord(value.cost) ? number(value.cost.total) : undefined;
841
+ if (total <= 0 && !(cost !== undefined && cost > 0))
842
+ return undefined;
843
+ return {
844
+ type: 'usage.updated',
845
+ usage: {
846
+ input,
847
+ output,
848
+ total,
849
+ ...(cacheRead !== undefined ? { cacheRead } : {}),
850
+ ...(cacheWrite !== undefined ? { cacheWrite } : {}),
851
+ },
852
+ ...(cost !== undefined && cost >= 0 ? { costUsd: cost } : {}),
853
+ };
854
+ }
855
+ /** OMP's failure response carries `error` as a string (rpc.md § Responses). */
856
+ function rpcError(value) {
857
+ if (typeof value.error === 'string')
858
+ return value.error;
859
+ const error = isRecord(value.error) ? value.error : undefined;
860
+ return string(error?.message) ?? string(value.message) ?? `omp RPC command ${string(value.command) ?? 'unknown'} failed`;
861
+ }
862
+ /** Same as pi-ui-mapper.ts `contentText`. */
863
+ function contentText(value) {
864
+ if (typeof value === 'string')
865
+ return value;
866
+ if (!Array.isArray(value))
867
+ return undefined;
868
+ const parts = value
869
+ .map((part) => (isRecord(part) && part.type === 'text' ? string(part.text) : undefined))
870
+ .filter((part) => part !== undefined);
871
+ return parts.length > 0 ? parts.join('\n') : undefined;
872
+ }
873
+ function isRecord(value) {
874
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
875
+ }
876
+ function string(value) {
877
+ return typeof value === 'string' ? value : undefined;
878
+ }
879
+ function number(value) {
880
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
881
+ }
882
+ //# sourceMappingURL=omp-ui-mapper.js.map