@qodeca/xezar 0.10.1

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