@wjarka/cezarion 0.10.0-pr30.54

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 (478) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +838 -0
  3. package/dist/agent-config/account-identity.d.ts +44 -0
  4. package/dist/agent-config/account-identity.js +128 -0
  5. package/dist/agent-config/account-identity.js.map +1 -0
  6. package/dist/agent-config/catalog.d.ts +72 -0
  7. package/dist/agent-config/catalog.js +223 -0
  8. package/dist/agent-config/catalog.js.map +1 -0
  9. package/dist/agent-config/files.d.ts +46 -0
  10. package/dist/agent-config/files.js +119 -0
  11. package/dist/agent-config/files.js.map +1 -0
  12. package/dist/agent-config/model-settings/claude.d.ts +2 -0
  13. package/dist/agent-config/model-settings/claude.js +11 -0
  14. package/dist/agent-config/model-settings/claude.js.map +1 -0
  15. package/dist/agent-config/model-settings/codex.d.ts +2 -0
  16. package/dist/agent-config/model-settings/codex.js +16 -0
  17. package/dist/agent-config/model-settings/codex.js.map +1 -0
  18. package/dist/agent-config/model-settings/opencode.d.ts +2 -0
  19. package/dist/agent-config/model-settings/opencode.js +8 -0
  20. package/dist/agent-config/model-settings/opencode.js.map +1 -0
  21. package/dist/agent-config/model-settings/pi.d.ts +12 -0
  22. package/dist/agent-config/model-settings/pi.js +18 -0
  23. package/dist/agent-config/model-settings/pi.js.map +1 -0
  24. package/dist/agent-config/model-settings/shared.d.ts +9 -0
  25. package/dist/agent-config/model-settings/shared.js +93 -0
  26. package/dist/agent-config/model-settings/shared.js.map +1 -0
  27. package/dist/agent-config/model-settings/types.d.ts +9 -0
  28. package/dist/agent-config/model-settings/types.js +2 -0
  29. package/dist/agent-config/model-settings/types.js.map +1 -0
  30. package/dist/agent-config/models.d.ts +9 -0
  31. package/dist/agent-config/models.js +32 -0
  32. package/dist/agent-config/models.js.map +1 -0
  33. package/dist/agent-config/seed.d.ts +7 -0
  34. package/dist/agent-config/seed.js +90 -0
  35. package/dist/agent-config/seed.js.map +1 -0
  36. package/dist/agent-config/service.d.ts +44 -0
  37. package/dist/agent-config/service.js +71 -0
  38. package/dist/agent-config/service.js.map +1 -0
  39. package/dist/agent-config/validate.d.ts +21 -0
  40. package/dist/agent-config/validate.js +76 -0
  41. package/dist/agent-config/validate.js.map +1 -0
  42. package/dist/automations/coordinator.d.ts +26 -0
  43. package/dist/automations/coordinator.js +66 -0
  44. package/dist/automations/coordinator.js.map +1 -0
  45. package/dist/automations/github-poller.d.ts +74 -0
  46. package/dist/automations/github-poller.js +234 -0
  47. package/dist/automations/github-poller.js.map +1 -0
  48. package/dist/automations/scheduler.d.ts +42 -0
  49. package/dist/automations/scheduler.js +192 -0
  50. package/dist/automations/scheduler.js.map +1 -0
  51. package/dist/automations/store.d.ts +65 -0
  52. package/dist/automations/store.js +298 -0
  53. package/dist/automations/store.js.map +1 -0
  54. package/dist/automations/task-template.d.ts +18 -0
  55. package/dist/automations/task-template.js +95 -0
  56. package/dist/automations/task-template.js.map +1 -0
  57. package/dist/automations/types.d.ts +255 -0
  58. package/dist/automations/types.js +159 -0
  59. package/dist/automations/types.js.map +1 -0
  60. package/dist/config.d.ts +77 -0
  61. package/dist/config.js +242 -0
  62. package/dist/config.js.map +1 -0
  63. package/dist/contract/agent-config.d.ts +153 -0
  64. package/dist/contract/agent-profiles.d.ts +347 -0
  65. package/dist/contract/automations.d.ts +935 -0
  66. package/dist/contract/events.d.ts +104 -0
  67. package/dist/contract/github.d.ts +556 -0
  68. package/dist/contract/health.d.ts +102 -0
  69. package/dist/contract/index.d.ts +16 -0
  70. package/dist/contract/index.js +1895 -0
  71. package/dist/contract/projects.d.ts +210 -0
  72. package/dist/contract/repo.d.ts +234 -0
  73. package/dist/contract/runs.d.ts +1473 -0
  74. package/dist/contract/skills.d.ts +232 -0
  75. package/dist/contract/workflows.d.ts +218 -0
  76. package/dist/contract/workspace.d.ts +579 -0
  77. package/dist/core/agent-env.d.ts +31 -0
  78. package/dist/core/agent-env.js +371 -0
  79. package/dist/core/agent-env.js.map +1 -0
  80. package/dist/core/agent-model-policy.d.ts +10 -0
  81. package/dist/core/agent-model-policy.js +36 -0
  82. package/dist/core/agent-model-policy.js.map +1 -0
  83. package/dist/core/agent-profiles.d.ts +62 -0
  84. package/dist/core/agent-profiles.js +90 -0
  85. package/dist/core/agent-profiles.js.map +1 -0
  86. package/dist/core/agent-runner.d.ts +211 -0
  87. package/dist/core/agent-runner.js +68 -0
  88. package/dist/core/agent-runner.js.map +1 -0
  89. package/dist/core/ask.d.ts +105 -0
  90. package/dist/core/ask.js +187 -0
  91. package/dist/core/ask.js.map +1 -0
  92. package/dist/core/backend-detect.d.ts +16 -0
  93. package/dist/core/backend-detect.js +155 -0
  94. package/dist/core/backend-detect.js.map +1 -0
  95. package/dist/core/claude-cli-runner.d.ts +59 -0
  96. package/dist/core/claude-cli-runner.js +483 -0
  97. package/dist/core/claude-cli-runner.js.map +1 -0
  98. package/dist/core/claude-ui-mapper.d.ts +80 -0
  99. package/dist/core/claude-ui-mapper.js +598 -0
  100. package/dist/core/claude-ui-mapper.js.map +1 -0
  101. package/dist/core/codex-app-server-runner.d.ts +41 -0
  102. package/dist/core/codex-app-server-runner.js +584 -0
  103. package/dist/core/codex-app-server-runner.js.map +1 -0
  104. package/dist/core/codex-app-server-transport.d.ts +35 -0
  105. package/dist/core/codex-app-server-transport.js +150 -0
  106. package/dist/core/codex-app-server-transport.js.map +1 -0
  107. package/dist/core/codex-model-catalog.d.ts +10 -0
  108. package/dist/core/codex-model-catalog.js +110 -0
  109. package/dist/core/codex-model-catalog.js.map +1 -0
  110. package/dist/core/codex-ui-mapper.d.ts +112 -0
  111. package/dist/core/codex-ui-mapper.js +766 -0
  112. package/dist/core/codex-ui-mapper.js.map +1 -0
  113. package/dist/core/model-identity.d.ts +125 -0
  114. package/dist/core/model-identity.js +132 -0
  115. package/dist/core/model-identity.js.map +1 -0
  116. package/dist/core/model-presets.d.ts +21 -0
  117. package/dist/core/model-presets.js +81 -0
  118. package/dist/core/model-presets.js.map +1 -0
  119. package/dist/core/ndjson.d.ts +6 -0
  120. package/dist/core/ndjson.js +23 -0
  121. package/dist/core/ndjson.js.map +1 -0
  122. package/dist/core/opencode-model-catalog.d.ts +32 -0
  123. package/dist/core/opencode-model-catalog.js +153 -0
  124. package/dist/core/opencode-model-catalog.js.map +1 -0
  125. package/dist/core/opencode-server-runner.d.ts +32 -0
  126. package/dist/core/opencode-server-runner.js +882 -0
  127. package/dist/core/opencode-server-runner.js.map +1 -0
  128. package/dist/core/opencode-ui-mapper.d.ts +137 -0
  129. package/dist/core/opencode-ui-mapper.js +800 -0
  130. package/dist/core/opencode-ui-mapper.js.map +1 -0
  131. package/dist/core/pi-model-catalog.d.ts +31 -0
  132. package/dist/core/pi-model-catalog.js +152 -0
  133. package/dist/core/pi-model-catalog.js.map +1 -0
  134. package/dist/core/pi-runner.d.ts +24 -0
  135. package/dist/core/pi-runner.js +403 -0
  136. package/dist/core/pi-runner.js.map +1 -0
  137. package/dist/core/pi-ui-mapper.d.ts +36 -0
  138. package/dist/core/pi-ui-mapper.js +304 -0
  139. package/dist/core/pi-ui-mapper.js.map +1 -0
  140. package/dist/core/process-usage.d.ts +66 -0
  141. package/dist/core/process-usage.js +193 -0
  142. package/dist/core/process-usage.js.map +1 -0
  143. package/dist/core/provider-auth.d.ts +154 -0
  144. package/dist/core/provider-auth.js +509 -0
  145. package/dist/core/provider-auth.js.map +1 -0
  146. package/dist/core/provider-availability.d.ts +3 -0
  147. package/dist/core/provider-availability.js +14 -0
  148. package/dist/core/provider-availability.js.map +1 -0
  149. package/dist/core/runner-factory.d.ts +8 -0
  150. package/dist/core/runner-factory.js +25 -0
  151. package/dist/core/runner-factory.js.map +1 -0
  152. package/dist/core/runner-model-catalog.d.ts +29 -0
  153. package/dist/core/runner-model-catalog.js +78 -0
  154. package/dist/core/runner-model-catalog.js.map +1 -0
  155. package/dist/core/secret-redaction.d.ts +37 -0
  156. package/dist/core/secret-redaction.js +115 -0
  157. package/dist/core/secret-redaction.js.map +1 -0
  158. package/dist/core/shell-env.d.ts +28 -0
  159. package/dist/core/shell-env.js +56 -0
  160. package/dist/core/shell-env.js.map +1 -0
  161. package/dist/core/tool-display.d.ts +31 -0
  162. package/dist/core/tool-display.js +179 -0
  163. package/dist/core/tool-display.js.map +1 -0
  164. package/dist/core/ui-events.d.ts +335 -0
  165. package/dist/core/ui-events.js +25 -0
  166. package/dist/core/ui-events.js.map +1 -0
  167. package/dist/core/usage-limit.d.ts +42 -0
  168. package/dist/core/usage-limit.js +209 -0
  169. package/dist/core/usage-limit.js.map +1 -0
  170. package/dist/core/usage.d.ts +11 -0
  171. package/dist/core/usage.js +15 -0
  172. package/dist/core/usage.js.map +1 -0
  173. package/dist/core/v1-text-coalescer.d.ts +36 -0
  174. package/dist/core/v1-text-coalescer.js +72 -0
  175. package/dist/core/v1-text-coalescer.js.map +1 -0
  176. package/dist/git-diff-base.d.ts +85 -0
  177. package/dist/git-diff-base.js +180 -0
  178. package/dist/git-diff-base.js.map +1 -0
  179. package/dist/git-refs.d.ts +11 -0
  180. package/dist/git-refs.js +14 -0
  181. package/dist/git-refs.js.map +1 -0
  182. package/dist/git-worktree.d.ts +161 -0
  183. package/dist/git-worktree.js +508 -0
  184. package/dist/git-worktree.js.map +1 -0
  185. package/dist/handoff.d.ts +62 -0
  186. package/dist/handoff.js +154 -0
  187. package/dist/handoff.js.map +1 -0
  188. package/dist/index.d.ts +2 -0
  189. package/dist/index.js +680 -0
  190. package/dist/index.js.map +1 -0
  191. package/dist/install-as-command.d.ts +40 -0
  192. package/dist/install-as-command.js +52 -0
  193. package/dist/install-as-command.js.map +1 -0
  194. package/dist/pack-check.d.ts +17 -0
  195. package/dist/pack-check.js +27 -0
  196. package/dist/pack-check.js.map +1 -0
  197. package/dist/paths.d.ts +140 -0
  198. package/dist/paths.js +192 -0
  199. package/dist/paths.js.map +1 -0
  200. package/dist/planner.d.ts +27 -0
  201. package/dist/planner.js +268 -0
  202. package/dist/planner.js.map +1 -0
  203. package/dist/release/manifests.d.ts +81 -0
  204. package/dist/release/manifests.js +74 -0
  205. package/dist/release/manifests.js.map +1 -0
  206. package/dist/release/snapshot.d.ts +67 -0
  207. package/dist/release/snapshot.js +97 -0
  208. package/dist/release/snapshot.js.map +1 -0
  209. package/dist/release/stable.d.ts +38 -0
  210. package/dist/release/stable.js +55 -0
  211. package/dist/release/stable.js.map +1 -0
  212. package/dist/runs/agent-tmpdir.d.ts +41 -0
  213. package/dist/runs/agent-tmpdir.js +183 -0
  214. package/dist/runs/agent-tmpdir.js.map +1 -0
  215. package/dist/runs/auto-name.d.ts +75 -0
  216. package/dist/runs/auto-name.js +179 -0
  217. package/dist/runs/auto-name.js.map +1 -0
  218. package/dist/runs/event-history.d.ts +50 -0
  219. package/dist/runs/event-history.js +613 -0
  220. package/dist/runs/event-history.js.map +1 -0
  221. package/dist/runs/retention.d.ts +60 -0
  222. package/dist/runs/retention.js +86 -0
  223. package/dist/runs/retention.js.map +1 -0
  224. package/dist/runs/review-gate.d.ts +18 -0
  225. package/dist/runs/review-gate.js +21 -0
  226. package/dist/runs/review-gate.js.map +1 -0
  227. package/dist/runs/run-index.d.ts +19 -0
  228. package/dist/runs/run-index.js +43 -0
  229. package/dist/runs/run-index.js.map +1 -0
  230. package/dist/runs/store.d.ts +446 -0
  231. package/dist/runs/store.js +1118 -0
  232. package/dist/runs/store.js.map +1 -0
  233. package/dist/runs/task-markers.d.ts +28 -0
  234. package/dist/runs/task-markers.js +74 -0
  235. package/dist/runs/task-markers.js.map +1 -0
  236. package/dist/runs/task-refs.d.ts +25 -0
  237. package/dist/runs/task-refs.js +74 -0
  238. package/dist/runs/task-refs.js.map +1 -0
  239. package/dist/runs/ui-event-sink.d.ts +81 -0
  240. package/dist/runs/ui-event-sink.js +210 -0
  241. package/dist/runs/ui-event-sink.js.map +1 -0
  242. package/dist/server/app-type.d.ts +21 -0
  243. package/dist/server/app-type.js +2 -0
  244. package/dist/server/app-type.js.map +1 -0
  245. package/dist/server/capabilities.d.ts +70 -0
  246. package/dist/server/capabilities.js +152 -0
  247. package/dist/server/capabilities.js.map +1 -0
  248. package/dist/server/checkout.d.ts +128 -0
  249. package/dist/server/checkout.js +296 -0
  250. package/dist/server/checkout.js.map +1 -0
  251. package/dist/server/forge/github.d.ts +513 -0
  252. package/dist/server/forge/github.js +2364 -0
  253. package/dist/server/forge/github.js.map +1 -0
  254. package/dist/server/forge/index.d.ts +40 -0
  255. package/dist/server/forge/index.js +72 -0
  256. package/dist/server/forge/index.js.map +1 -0
  257. package/dist/server/forge/types.d.ts +242 -0
  258. package/dist/server/forge/types.js +2 -0
  259. package/dist/server/forge/types.js.map +1 -0
  260. package/dist/server/fs-browse.d.ts +105 -0
  261. package/dist/server/fs-browse.js +182 -0
  262. package/dist/server/fs-browse.js.map +1 -0
  263. package/dist/server/git-changes.d.ts +213 -0
  264. package/dist/server/git-changes.js +555 -0
  265. package/dist/server/git-changes.js.map +1 -0
  266. package/dist/server/git.d.ts +28 -0
  267. package/dist/server/git.js +112 -0
  268. package/dist/server/git.js.map +1 -0
  269. package/dist/server/github.d.ts +9 -0
  270. package/dist/server/github.js +8 -0
  271. package/dist/server/github.js.map +1 -0
  272. package/dist/server/launch-key.d.ts +7 -0
  273. package/dist/server/launch-key.js +33 -0
  274. package/dist/server/launch-key.js.map +1 -0
  275. package/dist/server/open-in-app.d.ts +66 -0
  276. package/dist/server/open-in-app.js +211 -0
  277. package/dist/server/open-in-app.js.map +1 -0
  278. package/dist/server/open-in-terminal.d.ts +70 -0
  279. package/dist/server/open-in-terminal.js +179 -0
  280. package/dist/server/open-in-terminal.js.map +1 -0
  281. package/dist/server/pr.d.ts +7 -0
  282. package/dist/server/pr.js +7 -0
  283. package/dist/server/pr.js.map +1 -0
  284. package/dist/server/project-context.d.ts +120 -0
  285. package/dist/server/project-context.js +182 -0
  286. package/dist/server/project-context.js.map +1 -0
  287. package/dist/server/provider-action-gate.d.ts +8 -0
  288. package/dist/server/provider-action-gate.js +56 -0
  289. package/dist/server/provider-action-gate.js.map +1 -0
  290. package/dist/server/provider-auth-runtime.d.ts +21 -0
  291. package/dist/server/provider-auth-runtime.js +66 -0
  292. package/dist/server/provider-auth-runtime.js.map +1 -0
  293. package/dist/server/server.d.ts +13138 -0
  294. package/dist/server/server.js +5263 -0
  295. package/dist/server/server.js.map +1 -0
  296. package/dist/server/static-ui.d.ts +49 -0
  297. package/dist/server/static-ui.js +92 -0
  298. package/dist/server/static-ui.js.map +1 -0
  299. package/dist/server/validators.d.ts +97 -0
  300. package/dist/server/validators.js +86 -0
  301. package/dist/server/validators.js.map +1 -0
  302. package/dist/server/ws.d.ts +85 -0
  303. package/dist/server/ws.js +218 -0
  304. package/dist/server/ws.js.map +1 -0
  305. package/dist/server/wsl.d.ts +25 -0
  306. package/dist/server/wsl.js +92 -0
  307. package/dist/server/wsl.js.map +1 -0
  308. package/dist/server-install/engine.d.ts +50 -0
  309. package/dist/server-install/engine.js +324 -0
  310. package/dist/server-install/engine.js.map +1 -0
  311. package/dist/server-install/platforms/macosx-ngrok.d.ts +6 -0
  312. package/dist/server-install/platforms/macosx-ngrok.js +345 -0
  313. package/dist/server-install/platforms/macosx-ngrok.js.map +1 -0
  314. package/dist/server-install/platforms/ubuntu-vps.d.ts +78 -0
  315. package/dist/server-install/platforms/ubuntu-vps.js +1016 -0
  316. package/dist/server-install/platforms/ubuntu-vps.js.map +1 -0
  317. package/dist/server-install/state.d.ts +52 -0
  318. package/dist/server-install/state.js +182 -0
  319. package/dist/server-install/state.js.map +1 -0
  320. package/dist/server-install/steps.d.ts +109 -0
  321. package/dist/server-install/steps.js +334 -0
  322. package/dist/server-install/steps.js.map +1 -0
  323. package/dist/server-install/strategies.d.ts +4 -0
  324. package/dist/server-install/strategies.js +20 -0
  325. package/dist/server-install/strategies.js.map +1 -0
  326. package/dist/server-install/types.d.ts +287 -0
  327. package/dist/server-install/types.js +121 -0
  328. package/dist/server-install/types.js.map +1 -0
  329. package/dist/server-install/ui.d.ts +42 -0
  330. package/dist/server-install/ui.js +130 -0
  331. package/dist/server-install/ui.js.map +1 -0
  332. package/dist/skills-banner.d.ts +22 -0
  333. package/dist/skills-banner.js +41 -0
  334. package/dist/skills-banner.js.map +1 -0
  335. package/dist/skills-remote.d.ts +84 -0
  336. package/dist/skills-remote.js +468 -0
  337. package/dist/skills-remote.js.map +1 -0
  338. package/dist/skills-update.d.ts +88 -0
  339. package/dist/skills-update.js +392 -0
  340. package/dist/skills-update.js.map +1 -0
  341. package/dist/skills.d.ts +82 -0
  342. package/dist/skills.js +251 -0
  343. package/dist/skills.js.map +1 -0
  344. package/dist/todos.d.ts +48 -0
  345. package/dist/todos.js +201 -0
  346. package/dist/todos.js.map +1 -0
  347. package/dist/ui-state.d.ts +26 -0
  348. package/dist/ui-state.js +38 -0
  349. package/dist/ui-state.js.map +1 -0
  350. package/dist/update-check.d.ts +12 -0
  351. package/dist/update-check.js +41 -0
  352. package/dist/update-check.js.map +1 -0
  353. package/dist/workflows/load.d.ts +15 -0
  354. package/dist/workflows/load.js +56 -0
  355. package/dist/workflows/load.js.map +1 -0
  356. package/dist/workflows/run.d.ts +758 -0
  357. package/dist/workflows/run.js +3389 -0
  358. package/dist/workflows/run.js.map +1 -0
  359. package/dist/workflows/types.d.ts +153 -0
  360. package/dist/workflows/types.js +212 -0
  361. package/dist/workflows/types.js.map +1 -0
  362. package/dist/workspace/agent-accounts.d.ts +153 -0
  363. package/dist/workspace/agent-accounts.js +304 -0
  364. package/dist/workspace/agent-accounts.js.map +1 -0
  365. package/dist/workspace/agent-profiles.d.ts +78 -0
  366. package/dist/workspace/agent-profiles.js +115 -0
  367. package/dist/workspace/agent-profiles.js.map +1 -0
  368. package/dist/workspace/config.d.ts +169 -0
  369. package/dist/workspace/config.js +379 -0
  370. package/dist/workspace/config.js.map +1 -0
  371. package/dist/workspace/migrations.d.ts +45 -0
  372. package/dist/workspace/migrations.js +147 -0
  373. package/dist/workspace/migrations.js.map +1 -0
  374. package/dist/workspace/projects-cli.d.ts +25 -0
  375. package/dist/workspace/projects-cli.js +172 -0
  376. package/dist/workspace/projects-cli.js.map +1 -0
  377. package/dist/workspace/projects.d.ts +109 -0
  378. package/dist/workspace/projects.js +250 -0
  379. package/dist/workspace/projects.js.map +1 -0
  380. package/dist/workspace/semaphore.d.ts +179 -0
  381. package/dist/workspace/semaphore.js +195 -0
  382. package/dist/workspace/semaphore.js.map +1 -0
  383. package/dist/workspace/ui-state.d.ts +34 -0
  384. package/dist/workspace/ui-state.js +53 -0
  385. package/dist/workspace/ui-state.js.map +1 -0
  386. package/package.json +70 -0
  387. package/scripts/check-pack.mjs +46 -0
  388. package/scripts/inline-contract.mjs +112 -0
  389. package/scripts/install-as-command.mjs +120 -0
  390. package/scripts/mock-claude.mjs +520 -0
  391. package/scripts/mock-pi-rpc.mjs +83 -0
  392. package/scripts/sync-readme.mjs +20 -0
  393. package/scripts/test-process-usage.mjs +47 -0
  394. package/web/dist/assets/alert-dialog-B4Ofsgv7.js +1 -0
  395. package/web/dist/assets/arrow-down-Dy8dup7j.js +1 -0
  396. package/web/dist/assets/arrow-left-BJaucbhn.js +1 -0
  397. package/web/dist/assets/bundle-mjs-BT31bpU6.js +1 -0
  398. package/web/dist/assets/centered-state-duPW0phQ.js +43 -0
  399. package/web/dist/assets/chevron-right-Be4A5TCS.js +1 -0
  400. package/web/dist/assets/chunk-BO2N2NFS-DE6qKn3r.js +131 -0
  401. package/web/dist/assets/collapsible-DdcNBdSk.js +1 -0
  402. package/web/dist/assets/commit-list-CgvN9vec.js +1 -0
  403. package/web/dist/assets/compare-variants-CQA2nd65.js +1 -0
  404. package/web/dist/assets/core-BCsw8oQw.js +12 -0
  405. package/web/dist/assets/css-BsVw1vtW.js +1 -0
  406. package/web/dist/assets/diff-B6Agp5Hl.js +3 -0
  407. package/web/dist/assets/diff-stat-BoXuGkgq.js +1 -0
  408. package/web/dist/assets/diff-view-CD8XI-fj.js +6 -0
  409. package/web/dist/assets/diff-woXpYk--.js +1 -0
  410. package/web/dist/assets/dropdown-menu-B3SYw-k5.js +1 -0
  411. package/web/dist/assets/editable-title-B-hjp5wl.js +1 -0
  412. package/web/dist/assets/ellipsis-vertical-BYwzw0xl.js +1 -0
  413. package/web/dist/assets/engine-javascript-FQvzRocB.js +141 -0
  414. package/web/dist/assets/file-BRj5eISx.js +1 -0
  415. package/web/dist/assets/folder-z4oT5981.js +1 -0
  416. package/web/dist/assets/git-toolbar-owSEkYld.js +1 -0
  417. package/web/dist/assets/github-Bz2VgRX3.js +1 -0
  418. package/web/dist/assets/go-rLFTqkRN.js +1 -0
  419. package/web/dist/assets/highlighted-body-OFNGDK62-BL-MfFgl.js +1 -0
  420. package/web/dist/assets/highlighter-CdHqIwFr.js +3 -0
  421. package/web/dist/assets/html-BY76lXLH.js +1 -0
  422. package/web/dist/assets/image-preview-h3WFluuy.js +1 -0
  423. package/web/dist/assets/index-BbcQNT92.css +2 -0
  424. package/web/dist/assets/index-EtQQQ6Kj.js +7 -0
  425. package/web/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  426. package/web/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  427. package/web/dist/assets/javascript-BgS3c2Ky.js +1 -0
  428. package/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  429. package/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  430. package/web/dist/assets/json-qhed-kSA.js +1 -0
  431. package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
  432. package/web/dist/assets/jsx-Bz0zcwM4.js +1 -0
  433. package/web/dist/assets/lib-BQXq3kEf.js +1 -0
  434. package/web/dist/assets/lib-BxQXEXDF.js +1 -0
  435. package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
  436. package/web/dist/assets/markdown-DqBKYPiB.js +2 -0
  437. package/web/dist/assets/mermaid-GHXKKRXX-C4jxqUUb.js +1 -0
  438. package/web/dist/assets/new-task-form-BdJKRBJX.js +1 -0
  439. package/web/dist/assets/pill-BQfmfpYp.js +1 -0
  440. package/web/dist/assets/project-router-DxgFZY1l.js +1 -0
  441. package/web/dist/assets/prompt-templates-B6m16gq-.js +15 -0
  442. package/web/dist/assets/python-gzcpVVnB.js +1 -0
  443. package/web/dist/assets/react-runtime-CCIEwYL0.js +9 -0
  444. package/web/dist/assets/refresh-cw-mhSpxf2a.js +1 -0
  445. package/web/dist/assets/repo-git-CUNRxR3_.js +1 -0
  446. package/web/dist/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  447. package/web/dist/assets/run-diff-DsmmDVfx.js +3 -0
  448. package/web/dist/assets/run-header-BkhrseLJ.js +1 -0
  449. package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
  450. package/web/dist/assets/search-x-BqDMB2g8.js +1 -0
  451. package/web/dist/assets/shellscript-CLZ0U2zV.js +1 -0
  452. package/web/dist/assets/skill-empty-hint-BWEvTggc.js +1 -0
  453. package/web/dist/assets/skills-9oR_oHse.js +1 -0
  454. package/web/dist/assets/skills-DwIxnnWO.js +1 -0
  455. package/web/dist/assets/sparkles-DIoTQpyx.js +1 -0
  456. package/web/dist/assets/sql-BsFa4tDR.js +1 -0
  457. package/web/dist/assets/square-terminal-Cc7CuQxc.js +1 -0
  458. package/web/dist/assets/tab-link-D1fQgpmO.js +1 -0
  459. package/web/dist/assets/task-changes-BKeLlDpK.js +1 -0
  460. package/web/dist/assets/task-commits-gcEFZIa5.js +1 -0
  461. package/web/dist/assets/task-files-BGAqoXTW.js +2 -0
  462. package/web/dist/assets/task-thread-DT8aUYTS.js +9 -0
  463. package/web/dist/assets/textarea-BOVbfy5C.js +1 -0
  464. package/web/dist/assets/thread-loading-CypW73KD.js +1 -0
  465. package/web/dist/assets/toml-CcmNWLt0.js +1 -0
  466. package/web/dist/assets/trash-2-CJq6LHWn.js +1 -0
  467. package/web/dist/assets/triangle-alert-CjDFvU27.js +1 -0
  468. package/web/dist/assets/tsx-udAQXfEw.js +1 -0
  469. package/web/dist/assets/typescript-bsJCZSQ-.js +1 -0
  470. package/web/dist/assets/upload-CPDZlJeK.js +1 -0
  471. package/web/dist/assets/use-desktop-5JsLmi0a.js +1 -0
  472. package/web/dist/assets/use-submit-shortcut-CHVFevty.js +1 -0
  473. package/web/dist/assets/utils-DiO6zyJd.js +64 -0
  474. package/web/dist/assets/workflows-rQDFzWRt.js +11 -0
  475. package/web/dist/assets/yaml-rwi0_p6S.js +1 -0
  476. package/web/dist/assets/zoomable-image-COWqb11v.js +1 -0
  477. package/web/dist/index.html +80 -0
  478. package/web/dist/open-mercato.svg +11 -0
@@ -0,0 +1,766 @@
1
+ /**
2
+ * Pure codex app-server JSON-RPC → protocol-v2 mapper. `mapCodexNotification`
3
+ * folds one parsed JSONL frame into `UiEvent`s plus the next mapper state;
4
+ * the runner calls it ALONGSIDE the v1 path (v1 events keep flowing
5
+ * unchanged).
6
+ *
7
+ * Contract: `.ai/analysis/cockpit-ui-redesign/agent-event-protocols.md` §3
8
+ * (wire format) and §7.1 "Codex (app-server)" (the mapping). Golden fixtures
9
+ * replaying wire-faithful frame sequences live in `__fixtures__/codex/`.
10
+ *
11
+ * Robustness rule: input is untrusted wire data — the mapper never throws;
12
+ * responses, server→client requests (handled by the session transport) and
13
+ * unknown methods map to zero events.
14
+ *
15
+ * State is explicit and treated as immutable: callers thread the returned
16
+ * `state` into the next call. Ids are deterministic — codex items and turns
17
+ * carry stable wire ids which are reused verbatim (`turn_<n>` is minted only
18
+ * when a turn frame arrives without one) — so replaying a stored transcript
19
+ * reproduces the exact event sequence.
20
+ *
21
+ * Status map (§7.1, kills v1's regex-on-status hack): `inProgress→running`,
22
+ * `completed→completed`, `failed→failed`, `declined→declined`.
23
+ */
24
+ import { toolDisplay } from './tool-display.js';
25
+ export function createCodexUiState() {
26
+ return {
27
+ sessionStarted: false,
28
+ turnSeq: 0,
29
+ currentTurnId: null,
30
+ pendingTurnUsage: null,
31
+ knownItems: new Set(),
32
+ outputs: new Map(),
33
+ reasonings: new Map(),
34
+ planFromNotification: false,
35
+ reviewItemId: null,
36
+ collabTasks: new Map(),
37
+ };
38
+ }
39
+ /**
40
+ * Codex confirms the thread via the `thread/start`/`thread/resume` RESULT
41
+ * (a response frame the mapper cannot attribute), so the runner calls this
42
+ * once the thread id is known. Deduplicated against the `thread/started`
43
+ * notification — whichever arrives first emits `session.started`.
44
+ */
45
+ export function codexSessionStarted(threadId, state) {
46
+ if (state.sessionStarted || threadId === '')
47
+ return { events: [], state };
48
+ return {
49
+ events: [{ type: 'session.started', sessionId: threadId, backend: 'codex' }],
50
+ state: { ...state, sessionStarted: true },
51
+ };
52
+ }
53
+ /** Fold one parsed JSON-RPC frame into v2 events. Never throws. */
54
+ export function mapCodexNotification(frame, state) {
55
+ if (!isRecord(frame) || typeof frame.method !== 'string')
56
+ return { events: [], state };
57
+ // Server requests are answered by CodexSession, not the notification mapper.
58
+ if (frame.id !== undefined)
59
+ return { events: [], state };
60
+ const params = isRecord(frame.params) ? frame.params : {};
61
+ switch (frame.method) {
62
+ case 'thread/started':
63
+ return codexSessionStarted(threadIdOf(params) ?? '', state);
64
+ case 'turn/started':
65
+ return mapTurnStarted(params, state);
66
+ case 'turn/completed':
67
+ return mapTurnEnd(params, state, /* failed */ false);
68
+ case 'turn/failed':
69
+ return mapTurnEnd(params, state, /* failed */ true);
70
+ case 'turn/plan/updated':
71
+ return mapTurnPlanUpdated(params, state);
72
+ case 'item/started':
73
+ return mapItemLifecycle(params, state, 'item.started');
74
+ case 'item/updated':
75
+ return mapItemLifecycle(params, state, 'item.updated');
76
+ case 'item/completed':
77
+ return mapItemLifecycle(params, state, 'item.completed');
78
+ case 'item/agentMessage/delta':
79
+ return mapDelta(params, state, 'text');
80
+ case 'item/reasoning/textDelta':
81
+ return mapDelta(params, state, 'reasoning', 'text');
82
+ case 'item/reasoning/summaryDelta':
83
+ case 'item/reasoning/summaryTextDelta':
84
+ return mapDelta(params, state, 'reasoning', 'summary');
85
+ case 'item/commandExecution/outputDelta':
86
+ return mapDelta(params, state, 'output');
87
+ case 'thread/tokenUsage/updated':
88
+ return mapTokenUsage(params, state);
89
+ default:
90
+ // thread/status/changed, thread/closed, … — nothing to render yet.
91
+ return { events: [], state };
92
+ }
93
+ }
94
+ // ---- turn lifecycle ---------------------------------------------------------
95
+ function mapTurnStarted(params, state) {
96
+ const turnSeq = state.turnSeq + 1;
97
+ const turnId = turnIdOf(params) ?? `turn_${turnSeq}`;
98
+ return {
99
+ events: [{ type: 'turn.started', turnId }],
100
+ // planFromNotification is turn-scoped — a new turn re-opens the item arm.
101
+ // So are the reasoning accumulators: an interrupted item never completes,
102
+ // so its text would otherwise leak into a later turn that reuses the id
103
+ // and pin whole chains of thought in memory for the session (#528).
104
+ state: {
105
+ ...state,
106
+ turnSeq,
107
+ currentTurnId: turnId,
108
+ pendingTurnUsage: null,
109
+ planFromNotification: false,
110
+ reasonings: new Map(),
111
+ },
112
+ };
113
+ }
114
+ function mapTurnEnd(params, state, failed) {
115
+ let turnSeq = state.turnSeq;
116
+ const turnId = turnIdOf(params) ?? state.currentTurnId ?? `turn_${++turnSeq}`;
117
+ const closesActiveTurn = state.currentTurnId === null || turnId === state.currentTurnId;
118
+ // A review span still open when the turn ends never gets its `exitedReviewMode` — an
119
+ // interrupted, cancelled or failed turn simply stops. Close it here, or the item stays
120
+ // `running` forever and the Agents dock reads a finished run as a live fan-out (#474).
121
+ // The status follows the turn: a turn that failed did not complete its review.
122
+ const events = [];
123
+ if (closesActiveTurn && state.reviewItemId !== null) {
124
+ events.push({
125
+ type: 'item.completed',
126
+ item: {
127
+ kind: 'tool',
128
+ id: state.reviewItemId,
129
+ name: 'enteredReviewMode',
130
+ toolKind: 'task',
131
+ title: 'Review',
132
+ status: failed ? 'failed' : 'completed',
133
+ },
134
+ });
135
+ }
136
+ const completed = {
137
+ type: 'turn.completed',
138
+ turnId,
139
+ stopReason: turnStopReason(params, failed),
140
+ };
141
+ if (turnId === state.currentTurnId && state.pendingTurnUsage !== null) {
142
+ completed.usage = state.pendingTurnUsage;
143
+ }
144
+ events.push(completed);
145
+ return {
146
+ events,
147
+ state: closesActiveTurn
148
+ ? { ...state, turnSeq, currentTurnId: null, pendingTurnUsage: null, reviewItemId: null }
149
+ : { ...state, turnSeq },
150
+ };
151
+ }
152
+ /** §7.1: turn/completed→end_turn, turn/failed→error — except an interrupted
153
+ * turn (turn.status `interrupted`, or an interrupt-shaped error message,
154
+ * the only wire signals codex gives us) → cancelled. */
155
+ function turnStopReason(params, failed) {
156
+ const turn = isRecord(params.turn) ? params.turn : {};
157
+ if (turn.status === 'interrupted')
158
+ return 'cancelled';
159
+ if (!failed)
160
+ return 'end_turn';
161
+ return /interrupt/i.test(errorMessage(params.error) ?? '') ? 'cancelled' : 'error';
162
+ }
163
+ // ---- plan -------------------------------------------------------------------
164
+ /**
165
+ * `turn/plan/updated` → the plan dock. This is the ONLY channel codex's
166
+ * `update_plan` tool reaches the client on: the app-server `ThreadItem` union
167
+ * has no todo/`todoList` variant, so the plan is a turn-level notification
168
+ * rather than an item (verified against
169
+ * `app-server-protocol/schema/typescript/v2/TurnPlanUpdatedNotification.ts`).
170
+ *
171
+ * Full replacement: `plan` carries the entire list on every notification and
172
+ * the steps have no wire ids, so the snapshot IS the plan — no accumulation
173
+ * (contrast the claude mapper's id-keyed TaskCreate/TaskUpdate fold).
174
+ *
175
+ * `explanation` (the model's prose rationale) is deliberately dropped: the dock
176
+ * renders entries only, and PlanEntry has nowhere to put it.
177
+ */
178
+ function mapTurnPlanUpdated(params, state) {
179
+ const entries = turnPlanEntries(params.plan);
180
+ if (!entries)
181
+ return { events: [], state };
182
+ return {
183
+ events: [{ type: 'plan.updated', entries }],
184
+ state: state.planFromNotification ? state : { ...state, planFromNotification: true },
185
+ };
186
+ }
187
+ /** `plan: [{step, status}]` → plan entries. An EMPTY array is a legitimate
188
+ * snapshot (the agent cleared its plan) and clears the dock; anything else that
189
+ * yields no entries — a non-array, or rows we could not read a step out of —
190
+ * is malformed and maps to zero events, so a garbled frame cannot wipe a good
191
+ * plan. The distinction matters: "the agent has no steps" and "we failed to
192
+ * parse the steps" look identical downstream once they are both `[]`. */
193
+ function turnPlanEntries(plan) {
194
+ if (!Array.isArray(plan))
195
+ return undefined;
196
+ const entries = [];
197
+ for (const step of plan) {
198
+ if (!isRecord(step))
199
+ continue;
200
+ const content = str(step.step);
201
+ if (content === undefined)
202
+ continue;
203
+ entries.push({ content, status: turnPlanStatus(step.status) });
204
+ }
205
+ if (plan.length > 0 && entries.length === 0)
206
+ return undefined;
207
+ return entries;
208
+ }
209
+ /** `TurnPlanStepStatus` is camelCase ON THE APP-SERVER WIRE (`inProgress`) even
210
+ * though codex's core protocol type is snake_case — the app-server layer
211
+ * re-serializes. Accept both spellings rather than depend on that detail, and
212
+ * treat anything unknown as `pending` (a step the agent has not reached). */
213
+ function turnPlanStatus(status) {
214
+ if (status === 'completed')
215
+ return 'completed';
216
+ if (status === 'inProgress' || status === 'in_progress')
217
+ return 'in_progress';
218
+ return 'pending';
219
+ }
220
+ function mapItemLifecycle(params, state, eventType) {
221
+ const raw = isRecord(params.item) ? params.item : undefined;
222
+ if (!raw || typeof raw.type !== 'string')
223
+ return { events: [], state };
224
+ const type = raw.type;
225
+ // `plan` / `todoList` items never render as items — they ARE the plan
226
+ // (full-replacement semantics on every lifecycle phase, §7.1).
227
+ //
228
+ // `plan` is the plan-MODE item (`{type:'plan', id, text}`, streamed via
229
+ // `item/plan/delta`) — prose, not a checklist, and mutually exclusive with
230
+ // `update_plan` (codex rejects that tool in plan mode). It becomes the single
231
+ // entry the agent is executing.
232
+ //
233
+ // `todoList` is NOT an app-server item type — the v2 `ThreadItem` union has no
234
+ // todo variant, so this arm is dead on the transport cezar spawns. It is kept
235
+ // as cheap tolerance: these types are marked EXPERIMENTAL upstream, codex's
236
+ // exec transport does emit a `todo_list` item, and a stray snapshot is better
237
+ // rendered than dropped. The real plan channel is `turn/plan/updated`.
238
+ //
239
+ // That makes this the SECOND writer of `plan.updated`, so it yields to the
240
+ // first: once the notification has delivered a real checklist, a prose `plan`
241
+ // item must not flatten it back into a single entry. Upstream says the two are
242
+ // mutually exclusive (codex rejects `update_plan` in plan mode) — this does not
243
+ // depend on that holding.
244
+ if (type === 'todoList' || type === 'todo_list' || type === 'plan') {
245
+ if (state.planFromNotification)
246
+ return { events: [], state };
247
+ const entries = planEntriesOf(raw);
248
+ if (!entries)
249
+ return { events: [], state };
250
+ return { events: [{ type: 'plan.updated', entries }], state };
251
+ }
252
+ // The user's own message echoed back — the client already rendered what it
253
+ // sent, so it maps to zero events (matching the claude mapper).
254
+ if (type === 'userMessage')
255
+ return { events: [], state };
256
+ const id = str(raw.id);
257
+ if (id === undefined)
258
+ return { events: [], state };
259
+ // Review mode is a PAIR of frames describing one span of work — folded into a
260
+ // single lifecycle before the generic arm, which knows only one frame at a time.
261
+ if (type === 'enteredReviewMode' || type === 'exitedReviewMode') {
262
+ return mapReviewMode(raw, id, type, eventType, state);
263
+ }
264
+ // Internal collaboration telemetry is not a user tool. Codex emits one
265
+ // `subAgentActivity(kind: started)` when it creates a child thread, followed
266
+ // by `interacted` bookkeeping as control returns between threads.
267
+ if (type === 'subAgentActivity')
268
+ return mapSubAgentActivity(raw, id, state);
269
+ const item = type === 'agentMessage'
270
+ ? messageItem(raw, id)
271
+ : type === 'reasoning'
272
+ ? reasoningItem(raw, id, state)
273
+ : toolItem(raw, id, type, eventType, state);
274
+ if (type === 'collabAgentToolCall' || type === 'collabToolCall') {
275
+ return mapCollabToolCall(raw, id, eventType, state);
276
+ }
277
+ const parentItemId = collabParentItemId(params, state);
278
+ if (parentItemId !== undefined)
279
+ item.parentItemId = parentItemId;
280
+ const events = [{ type: eventType, item }];
281
+ // Track live ids (for delta synthesis) and drop bookkeeping on completion.
282
+ if (eventType === 'item.completed') {
283
+ if (!state.knownItems.has(id) && !state.outputs.has(id) && !state.reasonings.has(id)) {
284
+ return { events, state };
285
+ }
286
+ const knownItems = new Set(state.knownItems);
287
+ knownItems.delete(id);
288
+ const outputs = new Map(state.outputs);
289
+ outputs.delete(id);
290
+ const reasonings = new Map(state.reasonings);
291
+ reasonings.delete(id);
292
+ return { events, state: { ...state, knownItems, outputs, reasonings } };
293
+ }
294
+ if (state.knownItems.has(id))
295
+ return { events, state };
296
+ return { events, state: { ...state, knownItems: new Set(state.knownItems).add(id) } };
297
+ }
298
+ function mapSubAgentActivity(raw, id, state) {
299
+ if (str(raw.kind) !== 'started' || state.knownItems.has(id))
300
+ return { events: [], state };
301
+ const agentPath = str(raw.agentPath);
302
+ const agentName = agentPath?.split('/').filter(Boolean).at(-1)?.replaceAll('_', ' ');
303
+ const agentThreadId = str(raw.agentThreadId);
304
+ const display = toolDisplay('Task', agentName ? { description: agentName } : undefined);
305
+ const task = { itemId: id, ...(agentName ? { prompt: agentName } : {}) };
306
+ const collabTasks = new Map(state.collabTasks);
307
+ if (agentThreadId)
308
+ collabTasks.set(agentThreadId, task);
309
+ return {
310
+ events: [{
311
+ type: 'item.started',
312
+ item: {
313
+ kind: 'tool', id, name: 'spawnAgent', toolKind: 'task', title: display.title, status: 'running',
314
+ input: { ...(agentPath ? { agentPath } : {}), ...(agentThreadId ? { agentThreadId } : {}) },
315
+ },
316
+ }],
317
+ state: { ...state, knownItems: new Set(state.knownItems).add(id), collabTasks },
318
+ };
319
+ }
320
+ /** A spawn creates one task row; later send/wait/resume/close calls update the
321
+ * same row through receiver-thread correlation instead of creating duplicates. */
322
+ function mapCollabToolCall(raw, id, eventType, state) {
323
+ const operation = str(raw.tool) ?? str(raw.operation);
324
+ const receiverIds = stringArray(raw.receiverThreadIds ?? raw.receiver_thread_ids);
325
+ const isSpawn = operation === 'spawnAgent' || operation === 'spawn_agent';
326
+ if (isSpawn) {
327
+ const prompt = str(raw.prompt);
328
+ const model = str(raw.model);
329
+ const task = { itemId: id, ...(prompt ? { prompt } : {}), ...(model ? { model } : {}) };
330
+ let collabTasks = state.collabTasks;
331
+ if (receiverIds.length > 0) {
332
+ const next = new Map(state.collabTasks);
333
+ for (const threadId of receiverIds)
334
+ next.set(threadId, task);
335
+ collabTasks = next;
336
+ }
337
+ const status = collabStatus(raw, receiverIds, eventType);
338
+ const mappedType = eventType === 'item.started'
339
+ ? eventType
340
+ : status === 'running' || status === 'pending' ? 'item.updated' : 'item.completed';
341
+ return {
342
+ events: [{ type: mappedType, item: collabTaskItem(task, status) }],
343
+ state: { ...state, collabTasks },
344
+ };
345
+ }
346
+ const tasks = new Map();
347
+ for (const threadId of receiverIds) {
348
+ const task = state.collabTasks.get(threadId);
349
+ if (task)
350
+ tasks.set(task.itemId, task);
351
+ }
352
+ if (tasks.size === 0)
353
+ return { events: [], state };
354
+ const status = collabStatus(raw, receiverIds, eventType);
355
+ const mappedType = status === 'running' || status === 'pending' ? 'item.updated' : 'item.completed';
356
+ return {
357
+ events: [...tasks.values()].map((task) => ({ type: mappedType, item: collabTaskItem(task, status) })),
358
+ state,
359
+ };
360
+ }
361
+ function collabTaskItem(task, status) {
362
+ const display = toolDisplay('Task', task.prompt ? { description: task.prompt } : undefined);
363
+ const input = {};
364
+ if (task.prompt)
365
+ input.prompt = task.prompt;
366
+ if (task.model)
367
+ input.model = task.model;
368
+ return {
369
+ kind: 'tool', id: task.itemId, name: 'spawnAgent', toolKind: 'task', title: display.title, status,
370
+ ...(Object.keys(input).length > 0 ? { input } : {}),
371
+ };
372
+ }
373
+ function collabStatus(raw, receiverIds, eventType) {
374
+ const states = isRecord(raw.agentsStates) ? raw.agentsStates
375
+ : isRecord(raw.agents_states) ? raw.agents_states : undefined;
376
+ const statuses = receiverIds
377
+ .map((threadId) => (states && isRecord(states[threadId]) ? states[threadId].status : undefined))
378
+ .filter((status) => typeof status === 'string');
379
+ if (statuses.some((status) => status === 'errored' || status === 'notFound' || status === 'not_found'))
380
+ return 'failed';
381
+ if (statuses.some((status) => status === 'interrupted'))
382
+ return 'declined';
383
+ if (statuses.length > 0 && statuses.every((status) => status === 'completed' || status === 'shutdown'))
384
+ return 'completed';
385
+ if (statuses.some((status) => status === 'running' || status === 'pendingInit' || status === 'pending_init'))
386
+ return 'running';
387
+ return toolStatus(raw, eventType);
388
+ }
389
+ function collabParentItemId(params, state) {
390
+ const threadId = threadIdOf(params);
391
+ return threadId ? state.collabTasks.get(threadId)?.itemId : undefined;
392
+ }
393
+ /**
394
+ * §7.1: review-mode items → tool(kind task) — but ONE item for the pair, not two.
395
+ *
396
+ * `enteredReviewMode` opens the item (`running`); `exitedReviewMode` completes
397
+ * **that same id**, so the cockpit sees one "Review" span with a lifecycle instead
398
+ * of two childless task items that would read as two sub-agents (spec
399
+ * `.ai/specs/2026-07-20-grouped-subagent-display.md` §"Codex-mapper fix", #474).
400
+ *
401
+ * The fallback matters: an exit with no open item — a resumed thread, a replay that
402
+ * starts mid-review — still maps to its own completed item, so no frame is dropped.
403
+ */
404
+ function mapReviewMode(raw, id, type, eventType, state) {
405
+ const reviewItem = (itemId, name, status) => ({
406
+ kind: 'tool',
407
+ id: itemId,
408
+ name,
409
+ toolKind: 'task',
410
+ // One stable title across the lifecycle: the row must not rename itself on exit.
411
+ title: 'Review',
412
+ status,
413
+ });
414
+ if (type === 'enteredReviewMode') {
415
+ const status = toolStatus(raw, eventType);
416
+ const events = [];
417
+ // A second entered frame with no intervening exit displaces the open span. Settle the
418
+ // displaced item rather than leaking a permanently `running` row — the same rule the
419
+ // opencode mapper's subtask slot follows.
420
+ if (state.reviewItemId !== null && state.reviewItemId !== id) {
421
+ events.push({
422
+ type: 'item.completed',
423
+ item: reviewItem(state.reviewItemId, 'enteredReviewMode', 'completed'),
424
+ });
425
+ }
426
+ events.push({ type: eventType, item: reviewItem(id, type, status) });
427
+ // Latch on the RESOLVED status, not the event phase: an entered frame that already
428
+ // carries a terminal wire status closes the span whichever lifecycle phase it arrived in,
429
+ // and one that is still in progress stays open even on an `item/completed` frame.
430
+ const settled = status !== 'running' && status !== 'pending';
431
+ return { events, state: { ...state, reviewItemId: settled ? null : id } };
432
+ }
433
+ const openId = state.reviewItemId;
434
+ if (openId === null) {
435
+ // Unpaired exit — today's shape, under the exit frame's own id.
436
+ return {
437
+ events: [{ type: 'item.completed', item: reviewItem(id, type, toolStatus(raw, 'item.completed')) }],
438
+ state,
439
+ };
440
+ }
441
+ return {
442
+ events: [
443
+ {
444
+ type: 'item.completed',
445
+ // The item was introduced by the entered frame, so it keeps that identity.
446
+ item: reviewItem(openId, 'enteredReviewMode', toolStatus(raw, 'item.completed')),
447
+ },
448
+ ],
449
+ state: { ...state, reviewItemId: null },
450
+ };
451
+ }
452
+ /** `agentMessage` → message item; `phase` commentary|final_answer→'commentary'|'final'. */
453
+ function messageItem(raw, id) {
454
+ const item = {
455
+ kind: 'message',
456
+ id,
457
+ role: 'assistant',
458
+ text: typeof raw.text === 'string' ? raw.text : '',
459
+ };
460
+ if (raw.phase === 'commentary')
461
+ item.phase = 'commentary';
462
+ else if (raw.phase === 'final_answer')
463
+ item.phase = 'final';
464
+ return item;
465
+ }
466
+ /** `reasoning` → reasoning item. Precedence, most authoritative first:
467
+ * wire `content` → streamed raw chain of thought → the fuller of the wire
468
+ * `summary` and the streamed summary.
469
+ *
470
+ * The accumulators matter on `item.completed`: deltas never reach disk, so a
471
+ * completed snapshot without `content` would otherwise persist the short
472
+ * summary (or nothing) and the row would read back empty after a reload
473
+ * (#528). They are consulted on `item.started` too — a delta can outrun its
474
+ * `item/started`, and re-emitting an empty snapshot would blank the row the
475
+ * synthesized item already filled.
476
+ *
477
+ * Summary picks the LONGER of the two sources rather than preferring the
478
+ * stream: a mapper attached mid-turn, or any dropped frame, leaves a partial
479
+ * accumulator that must not overwrite a complete `summary` from the wire. */
480
+ function reasoningItem(raw, id, state) {
481
+ const streamed = state.reasonings.get(id);
482
+ // app-server v2 snapshots use arrays for both fields. Deltas remain scalar
483
+ // strings, and older recorded transcripts may still contain scalar snapshots,
484
+ // so accept both without weakening the untrusted-wire boundary.
485
+ const summary = longer(reasoningSnapshotText(raw.summary), str(streamed?.summary));
486
+ return {
487
+ kind: 'reasoning',
488
+ id,
489
+ text: reasoningSnapshotText(raw.content) ?? str(streamed?.text) ?? summary ?? '',
490
+ };
491
+ }
492
+ /** Join app-server reasoning parts without flattening their boundaries. Scalar
493
+ * strings remain accepted for replay compatibility with older transcripts. */
494
+ function reasoningSnapshotText(value) {
495
+ if (typeof value === 'string')
496
+ return str(value);
497
+ if (!Array.isArray(value))
498
+ return undefined;
499
+ const parts = value.filter((part) => typeof part === 'string' && part !== '');
500
+ return parts.length > 0 ? parts.join('\n') : undefined;
501
+ }
502
+ /** The longer of two optional strings — neither present yields undefined. */
503
+ function longer(a, b) {
504
+ if (a === undefined)
505
+ return b;
506
+ if (b === undefined)
507
+ return a;
508
+ return b.length > a.length ? b : a;
509
+ }
510
+ /** The §7.1 status map — the wire word wins; an item without one derives its
511
+ * status from the lifecycle phase it arrived in. */
512
+ const STATUS_MAP = {
513
+ inProgress: 'running',
514
+ in_progress: 'running',
515
+ completed: 'completed',
516
+ failed: 'failed',
517
+ declined: 'declined',
518
+ };
519
+ function toolStatus(raw, eventType) {
520
+ const mapped = typeof raw.status === 'string' ? STATUS_MAP[raw.status] : undefined;
521
+ return mapped ?? (eventType === 'item.completed' ? 'completed' : 'running');
522
+ }
523
+ function toolItem(raw, id, type, eventType, state) {
524
+ const status = toolStatus(raw, eventType);
525
+ let item;
526
+ switch (type) {
527
+ case 'commandExecution': {
528
+ const display = toolDisplay('commandExecution', raw);
529
+ item = { kind: 'tool', id, name: type, toolKind: display.toolKind, title: display.title, status };
530
+ if (raw.command !== undefined)
531
+ item.input = { command: raw.command };
532
+ // Wire output wins; else the final snapshot carries what outputDelta streamed.
533
+ const output = str(raw.aggregatedOutput) ??
534
+ str(raw.output) ??
535
+ (eventType === 'item.completed' ? state.outputs.get(id) : undefined);
536
+ if (output !== undefined)
537
+ item.output = output;
538
+ const exitCode = num(raw.exitCode);
539
+ if (exitCode !== undefined)
540
+ item.exitCode = exitCode;
541
+ break;
542
+ }
543
+ case 'fileChange': {
544
+ const display = toolDisplay('fileChange', raw);
545
+ item = { kind: 'tool', id, name: type, toolKind: display.toolKind, title: display.title, status };
546
+ const artifacts = changeArtifacts(raw.changes);
547
+ if (artifacts) {
548
+ item.diffs = artifacts.diffs;
549
+ item.locations = artifacts.locations;
550
+ }
551
+ break;
552
+ }
553
+ case 'mcpToolCall': {
554
+ const server = str(raw.server);
555
+ const tool = str(raw.tool);
556
+ const display = toolDisplay('mcpToolCall', raw);
557
+ item = {
558
+ kind: 'tool',
559
+ id,
560
+ // §7.1: the item is named after what it called, `server.tool`.
561
+ name: server && tool ? `${server}.${tool}` : type,
562
+ toolKind: display.toolKind,
563
+ title: display.title,
564
+ status,
565
+ };
566
+ if (raw.arguments !== undefined)
567
+ item.input = raw.arguments;
568
+ const result = raw.result;
569
+ if (typeof result === 'string')
570
+ item.output = result;
571
+ else if (result !== undefined)
572
+ item.output = safeStringify(result);
573
+ break;
574
+ }
575
+ case 'webSearch': {
576
+ const display = toolDisplay('webSearch', raw);
577
+ item = { kind: 'tool', id, name: type, toolKind: display.toolKind, title: display.title, status };
578
+ break;
579
+ }
580
+ default: {
581
+ // Unknown item types stay visible as generic tool cards (v1 parity —
582
+ // a future codex tool must not silently vanish from the thread).
583
+ const display = toolDisplay(type, raw);
584
+ item = { kind: 'tool', id, name: type, toolKind: display.toolKind, title: display.title, status, input: raw };
585
+ }
586
+ }
587
+ const error = errorMessage(raw.error);
588
+ if (error !== undefined)
589
+ item.error = error;
590
+ return item;
591
+ }
592
+ /** `fileChange.changes[]` `{path, kind, diff}` → `diffs[]` (unified) + locations. */
593
+ function changeArtifacts(changes) {
594
+ if (!Array.isArray(changes))
595
+ return undefined;
596
+ const diffs = [];
597
+ const locations = [];
598
+ for (const change of changes) {
599
+ if (!isRecord(change) || typeof change.path !== 'string' || change.path === '')
600
+ continue;
601
+ // Codex sends unified diffs only — the old text is unknown, not "empty".
602
+ const diff = { path: change.path, oldText: null };
603
+ const unified = str(change.diff);
604
+ if (unified !== undefined)
605
+ diff.unified = unified;
606
+ diffs.push(diff);
607
+ locations.push({ path: change.path });
608
+ }
609
+ if (diffs.length === 0)
610
+ return undefined;
611
+ return { diffs, locations };
612
+ }
613
+ /** `todoList` items `{text, completed}` (and plan step arrays) → plan entries;
614
+ * a text-only `plan` item becomes the single entry the agent is executing. */
615
+ function planEntriesOf(raw) {
616
+ const list = Array.isArray(raw.items) ? raw.items : Array.isArray(raw.plan) ? raw.plan : undefined;
617
+ if (list) {
618
+ const entries = [];
619
+ for (const entry of list) {
620
+ if (!isRecord(entry))
621
+ continue;
622
+ const content = str(entry.text) ?? str(entry.step) ?? str(entry.content);
623
+ if (content === undefined)
624
+ continue;
625
+ if (typeof entry.completed === 'boolean') {
626
+ entries.push({ content, status: entry.completed ? 'completed' : 'pending' });
627
+ }
628
+ else if (entry.status === 'pending' || entry.status === 'completed') {
629
+ entries.push({ content, status: entry.status });
630
+ }
631
+ else if (entry.status === 'inProgress' || entry.status === 'in_progress') {
632
+ entries.push({ content, status: 'in_progress' });
633
+ }
634
+ else {
635
+ entries.push({ content, status: 'pending' });
636
+ }
637
+ }
638
+ return entries;
639
+ }
640
+ const text = str(raw.text);
641
+ if (text === undefined)
642
+ return undefined;
643
+ return [{ content: text, status: 'in_progress' }];
644
+ }
645
+ // ---- streaming deltas -------------------------------------------------------
646
+ /** Minimal item synthesized when a delta outruns its `item/started` — gives
647
+ * consumers a valid target to upsert; the completed snapshot reconciles. */
648
+ function synthesizedItem(itemId, field) {
649
+ if (field === 'text')
650
+ return { kind: 'message', id: itemId, role: 'assistant', text: '' };
651
+ if (field === 'reasoning')
652
+ return { kind: 'reasoning', id: itemId, text: '' };
653
+ const display = toolDisplay('commandExecution');
654
+ return { kind: 'tool', id: itemId, name: 'commandExecution', toolKind: display.toolKind, title: display.title, status: 'running' };
655
+ }
656
+ function mapDelta(params, state, field,
657
+ /** Which reasoning stream fed this delta — see `ReasoningAccumulator`. */
658
+ reasoningChannel = 'text') {
659
+ const itemId = str(params.itemId);
660
+ const delta = typeof params.delta === 'string' ? params.delta : '';
661
+ if (itemId === undefined || delta === '')
662
+ return { events: [], state };
663
+ const events = [];
664
+ let knownItems = state.knownItems;
665
+ if (!knownItems.has(itemId)) {
666
+ const item = synthesizedItem(itemId, field);
667
+ const parentItemId = collabParentItemId(params, state);
668
+ if (parentItemId !== undefined)
669
+ item.parentItemId = parentItemId;
670
+ events.push({ type: 'item.started', item });
671
+ knownItems = new Set(knownItems).add(itemId);
672
+ }
673
+ events.push({ type: 'item.delta', itemId, field, delta });
674
+ let outputs = state.outputs;
675
+ if (field === 'output') {
676
+ const next = new Map(state.outputs);
677
+ next.set(itemId, (next.get(itemId) ?? '') + delta);
678
+ outputs = next;
679
+ }
680
+ let reasonings = state.reasonings;
681
+ if (field === 'reasoning') {
682
+ const next = new Map(state.reasonings);
683
+ const prev = next.get(itemId) ?? { text: '', summary: '' };
684
+ next.set(itemId, reasoningChannel === 'text'
685
+ ? { ...prev, text: prev.text + delta }
686
+ : { ...prev, summary: prev.summary + delta });
687
+ reasonings = next;
688
+ }
689
+ return { events, state: { ...state, knownItems, outputs, reasonings } };
690
+ }
691
+ // ---- telemetry ---------------------------------------------------------------
692
+ /** `thread/tokenUsage/updated` → usage.updated. Raw CUMULATIVE totals from
693
+ * `tokenUsage.total`; codex reports no USD cost, so none is ever fabricated. */
694
+ function mapTokenUsage(params, state) {
695
+ if (!isRecord(params.tokenUsage))
696
+ return { events: [], state };
697
+ const tokenUsage = params.tokenUsage;
698
+ const total = isRecord(tokenUsage.total) ? tokenUsage.total : undefined;
699
+ if (!total)
700
+ return { events: [], state };
701
+ const usage = codexUsage(total);
702
+ if (usage === undefined)
703
+ return { events: [], state };
704
+ const contextWindow = num(tokenUsage.modelContextWindow);
705
+ if (contextWindow !== undefined)
706
+ usage.contextWindow = contextWindow;
707
+ const last = isRecord(tokenUsage.last) ? codexUsage(tokenUsage.last) : undefined;
708
+ const nextState = state.currentTurnId !== null && last !== undefined ? { ...state, pendingTurnUsage: last } : state;
709
+ return { events: [{ type: 'usage.updated', usage }], state: nextState };
710
+ }
711
+ function codexUsage(raw) {
712
+ const input = nonNegative(raw.inputTokens);
713
+ const output = nonNegative(raw.outputTokens);
714
+ if (input === undefined || output === undefined)
715
+ return undefined;
716
+ const total = nonNegative(raw.totalTokens) ?? input + output;
717
+ const usage = { input, output, total };
718
+ const cacheRead = nonNegative(raw.cachedInputTokens);
719
+ const reasoning = nonNegative(raw.reasoningOutputTokens);
720
+ if (cacheRead !== undefined)
721
+ usage.cacheRead = cacheRead;
722
+ if (reasoning !== undefined)
723
+ usage.reasoning = reasoning;
724
+ return usage;
725
+ }
726
+ // ---- tiny guards --------------------------------------------------------------
727
+ function isRecord(value) {
728
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
729
+ }
730
+ function str(value) {
731
+ return typeof value === 'string' && value !== '' ? value : undefined;
732
+ }
733
+ function num(value) {
734
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
735
+ }
736
+ function nonNegative(value) {
737
+ const parsed = num(value);
738
+ return parsed !== undefined && parsed >= 0 ? parsed : undefined;
739
+ }
740
+ function stringArray(value) {
741
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === 'string' && entry !== '') : [];
742
+ }
743
+ function turnIdOf(params) {
744
+ const turn = isRecord(params.turn) ? params.turn : undefined;
745
+ return (turn && str(turn.id)) ?? str(params.turnId);
746
+ }
747
+ function threadIdOf(params) {
748
+ const thread = isRecord(params.thread) ? params.thread : undefined;
749
+ return (thread && str(thread.id)) ?? str(params.threadId);
750
+ }
751
+ function errorMessage(error) {
752
+ if (typeof error === 'string')
753
+ return str(error);
754
+ if (isRecord(error))
755
+ return str(error.message);
756
+ return undefined;
757
+ }
758
+ function safeStringify(value) {
759
+ try {
760
+ return JSON.stringify(value);
761
+ }
762
+ catch {
763
+ return String(value);
764
+ }
765
+ }
766
+ //# sourceMappingURL=codex-ui-mapper.js.map