@open-mercato/cezar 0.1.5-pr506.357

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 (264) hide show
  1. package/README.md +573 -0
  2. package/dist/config.d.ts +144 -0
  3. package/dist/config.js +106 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/core/agent-runner.d.ts +169 -0
  6. package/dist/core/agent-runner.js +23 -0
  7. package/dist/core/agent-runner.js.map +1 -0
  8. package/dist/core/backend-detect.d.ts +16 -0
  9. package/dist/core/backend-detect.js +118 -0
  10. package/dist/core/backend-detect.js.map +1 -0
  11. package/dist/core/claude-cli-runner.d.ts +56 -0
  12. package/dist/core/claude-cli-runner.js +416 -0
  13. package/dist/core/claude-cli-runner.js.map +1 -0
  14. package/dist/core/claude-ui-mapper.d.ts +71 -0
  15. package/dist/core/claude-ui-mapper.js +567 -0
  16. package/dist/core/claude-ui-mapper.js.map +1 -0
  17. package/dist/core/codex-app-server-runner.d.ts +29 -0
  18. package/dist/core/codex-app-server-runner.js +489 -0
  19. package/dist/core/codex-app-server-runner.js.map +1 -0
  20. package/dist/core/codex-ui-mapper.d.ts +63 -0
  21. package/dist/core/codex-ui-mapper.js +491 -0
  22. package/dist/core/codex-ui-mapper.js.map +1 -0
  23. package/dist/core/ndjson.d.ts +6 -0
  24. package/dist/core/ndjson.js +23 -0
  25. package/dist/core/ndjson.js.map +1 -0
  26. package/dist/core/opencode-server-runner.d.ts +30 -0
  27. package/dist/core/opencode-server-runner.js +488 -0
  28. package/dist/core/opencode-server-runner.js.map +1 -0
  29. package/dist/core/opencode-ui-mapper.d.ts +105 -0
  30. package/dist/core/opencode-ui-mapper.js +588 -0
  31. package/dist/core/opencode-ui-mapper.js.map +1 -0
  32. package/dist/core/process-usage.d.ts +63 -0
  33. package/dist/core/process-usage.js +181 -0
  34. package/dist/core/process-usage.js.map +1 -0
  35. package/dist/core/runner-factory.d.ts +8 -0
  36. package/dist/core/runner-factory.js +22 -0
  37. package/dist/core/runner-factory.js.map +1 -0
  38. package/dist/core/tool-display.d.ts +30 -0
  39. package/dist/core/tool-display.js +156 -0
  40. package/dist/core/tool-display.js.map +1 -0
  41. package/dist/core/ui-events.d.ts +308 -0
  42. package/dist/core/ui-events.js +25 -0
  43. package/dist/core/ui-events.js.map +1 -0
  44. package/dist/core/usage.d.ts +11 -0
  45. package/dist/core/usage.js +15 -0
  46. package/dist/core/usage.js.map +1 -0
  47. package/dist/git-worktree.d.ts +88 -0
  48. package/dist/git-worktree.js +297 -0
  49. package/dist/git-worktree.js.map +1 -0
  50. package/dist/handoff.d.ts +62 -0
  51. package/dist/handoff.js +147 -0
  52. package/dist/handoff.js.map +1 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +466 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/install-as-command.d.ts +39 -0
  57. package/dist/install-as-command.js +51 -0
  58. package/dist/install-as-command.js.map +1 -0
  59. package/dist/pack-check.d.ts +17 -0
  60. package/dist/pack-check.js +27 -0
  61. package/dist/pack-check.js.map +1 -0
  62. package/dist/paths.d.ts +23 -0
  63. package/dist/paths.js +34 -0
  64. package/dist/paths.js.map +1 -0
  65. package/dist/planner.d.ts +17 -0
  66. package/dist/planner.js +248 -0
  67. package/dist/planner.js.map +1 -0
  68. package/dist/release/snapshot.d.ts +64 -0
  69. package/dist/release/snapshot.js +75 -0
  70. package/dist/release/snapshot.js.map +1 -0
  71. package/dist/release/stable.d.ts +46 -0
  72. package/dist/release/stable.js +57 -0
  73. package/dist/release/stable.js.map +1 -0
  74. package/dist/runs/auto-name.d.ts +75 -0
  75. package/dist/runs/auto-name.js +168 -0
  76. package/dist/runs/auto-name.js.map +1 -0
  77. package/dist/runs/retention.d.ts +60 -0
  78. package/dist/runs/retention.js +86 -0
  79. package/dist/runs/retention.js.map +1 -0
  80. package/dist/runs/review-gate.d.ts +18 -0
  81. package/dist/runs/review-gate.js +21 -0
  82. package/dist/runs/review-gate.js.map +1 -0
  83. package/dist/runs/store.d.ts +408 -0
  84. package/dist/runs/store.js +526 -0
  85. package/dist/runs/store.js.map +1 -0
  86. package/dist/runs/task-refs.d.ts +24 -0
  87. package/dist/runs/task-refs.js +74 -0
  88. package/dist/runs/task-refs.js.map +1 -0
  89. package/dist/runs/ui-event-sink.d.ts +81 -0
  90. package/dist/runs/ui-event-sink.js +210 -0
  91. package/dist/runs/ui-event-sink.js.map +1 -0
  92. package/dist/server/capabilities.d.ts +33 -0
  93. package/dist/server/capabilities.js +43 -0
  94. package/dist/server/capabilities.js.map +1 -0
  95. package/dist/server/forge/github.d.ts +70 -0
  96. package/dist/server/forge/github.js +375 -0
  97. package/dist/server/forge/github.js.map +1 -0
  98. package/dist/server/forge/index.d.ts +24 -0
  99. package/dist/server/forge/index.js +45 -0
  100. package/dist/server/forge/index.js.map +1 -0
  101. package/dist/server/forge/types.d.ts +80 -0
  102. package/dist/server/forge/types.js +2 -0
  103. package/dist/server/forge/types.js.map +1 -0
  104. package/dist/server/git-changes.d.ts +195 -0
  105. package/dist/server/git-changes.js +497 -0
  106. package/dist/server/git-changes.js.map +1 -0
  107. package/dist/server/git.d.ts +26 -0
  108. package/dist/server/git.js +103 -0
  109. package/dist/server/git.js.map +1 -0
  110. package/dist/server/github.d.ts +8 -0
  111. package/dist/server/github.js +8 -0
  112. package/dist/server/github.js.map +1 -0
  113. package/dist/server/launch-key.d.ts +7 -0
  114. package/dist/server/launch-key.js +33 -0
  115. package/dist/server/launch-key.js.map +1 -0
  116. package/dist/server/open-in-app.d.ts +51 -0
  117. package/dist/server/open-in-app.js +189 -0
  118. package/dist/server/open-in-app.js.map +1 -0
  119. package/dist/server/open-in-terminal.d.ts +25 -0
  120. package/dist/server/open-in-terminal.js +120 -0
  121. package/dist/server/open-in-terminal.js.map +1 -0
  122. package/dist/server/pr.d.ts +7 -0
  123. package/dist/server/pr.js +7 -0
  124. package/dist/server/pr.js.map +1 -0
  125. package/dist/server/server.d.ts +41 -0
  126. package/dist/server/server.js +1390 -0
  127. package/dist/server/server.js.map +1 -0
  128. package/dist/server/static-ui.d.ts +49 -0
  129. package/dist/server/static-ui.js +92 -0
  130. package/dist/server/static-ui.js.map +1 -0
  131. package/dist/server/wsl.d.ts +25 -0
  132. package/dist/server/wsl.js +92 -0
  133. package/dist/server/wsl.js.map +1 -0
  134. package/dist/server-install/engine.d.ts +33 -0
  135. package/dist/server-install/engine.js +314 -0
  136. package/dist/server-install/engine.js.map +1 -0
  137. package/dist/server-install/platforms/macosx-ngrok.d.ts +6 -0
  138. package/dist/server-install/platforms/macosx-ngrok.js +345 -0
  139. package/dist/server-install/platforms/macosx-ngrok.js.map +1 -0
  140. package/dist/server-install/platforms/ubuntu-vps.d.ts +39 -0
  141. package/dist/server-install/platforms/ubuntu-vps.js +746 -0
  142. package/dist/server-install/platforms/ubuntu-vps.js.map +1 -0
  143. package/dist/server-install/state.d.ts +26 -0
  144. package/dist/server-install/state.js +125 -0
  145. package/dist/server-install/state.js.map +1 -0
  146. package/dist/server-install/steps.d.ts +109 -0
  147. package/dist/server-install/steps.js +330 -0
  148. package/dist/server-install/steps.js.map +1 -0
  149. package/dist/server-install/strategies.d.ts +4 -0
  150. package/dist/server-install/strategies.js +20 -0
  151. package/dist/server-install/strategies.js.map +1 -0
  152. package/dist/server-install/types.d.ts +597 -0
  153. package/dist/server-install/types.js +98 -0
  154. package/dist/server-install/types.js.map +1 -0
  155. package/dist/server-install/ui.d.ts +42 -0
  156. package/dist/server-install/ui.js +130 -0
  157. package/dist/server-install/ui.js.map +1 -0
  158. package/dist/skills-banner.d.ts +21 -0
  159. package/dist/skills-banner.js +40 -0
  160. package/dist/skills-banner.js.map +1 -0
  161. package/dist/skills-remote.d.ts +35 -0
  162. package/dist/skills-remote.js +266 -0
  163. package/dist/skills-remote.js.map +1 -0
  164. package/dist/skills.d.ts +45 -0
  165. package/dist/skills.js +182 -0
  166. package/dist/skills.js.map +1 -0
  167. package/dist/todos.d.ts +63 -0
  168. package/dist/todos.js +168 -0
  169. package/dist/todos.js.map +1 -0
  170. package/dist/ui-state.d.ts +12 -0
  171. package/dist/ui-state.js +25 -0
  172. package/dist/ui-state.js.map +1 -0
  173. package/dist/update-check.d.ts +12 -0
  174. package/dist/update-check.js +41 -0
  175. package/dist/update-check.js.map +1 -0
  176. package/dist/workflows/load.d.ts +15 -0
  177. package/dist/workflows/load.js +56 -0
  178. package/dist/workflows/load.js.map +1 -0
  179. package/dist/workflows/run.d.ts +281 -0
  180. package/dist/workflows/run.js +1511 -0
  181. package/dist/workflows/run.js.map +1 -0
  182. package/dist/workflows/types.d.ts +307 -0
  183. package/dist/workflows/types.js +171 -0
  184. package/dist/workflows/types.js.map +1 -0
  185. package/package.json +90 -0
  186. package/scripts/check-pack.mjs +46 -0
  187. package/scripts/dev.mjs +74 -0
  188. package/scripts/install-as-command.mjs +120 -0
  189. package/scripts/mock-claude.mjs +310 -0
  190. package/scripts/release-snapshot.mjs +130 -0
  191. package/scripts/release.mjs +119 -0
  192. package/scripts/test-process-usage.mjs +47 -0
  193. package/web/dist/assets/arrow-left-BE957rJs.js +1 -0
  194. package/web/dist/assets/bundle-mjs-DLPpRFyl.js +1 -0
  195. package/web/dist/assets/centered-state-BddhEEtO.js +43 -0
  196. package/web/dist/assets/chunk-BO2N2NFS-f5igTtpB.js +131 -0
  197. package/web/dist/assets/command-CjhFbABo.js +1 -0
  198. package/web/dist/assets/compare-variants-Cs52IAEG.js +1 -0
  199. package/web/dist/assets/core-BuMqAF_1.js +12 -0
  200. package/web/dist/assets/css-BsVw1vtW.js +1 -0
  201. package/web/dist/assets/dialog-DFvXTkFv.js +1 -0
  202. package/web/dist/assets/diff-view-C9b8AITq.js +4 -0
  203. package/web/dist/assets/diff-woXpYk--.js +1 -0
  204. package/web/dist/assets/dist-FBs4wmIY.js +1 -0
  205. package/web/dist/assets/dist-o_kVMXjg.js +1 -0
  206. package/web/dist/assets/engine-javascript-FQvzRocB.js +141 -0
  207. package/web/dist/assets/file-BVuztAOd.js +1 -0
  208. package/web/dist/assets/folder-0pJ1NZ_S.js +1 -0
  209. package/web/dist/assets/git-pull-request-DJkAMT0f.js +1 -0
  210. package/web/dist/assets/git-toolbar-CwhQdx3J.js +1 -0
  211. package/web/dist/assets/github-D0rAX4-r.js +1 -0
  212. package/web/dist/assets/go-rLFTqkRN.js +1 -0
  213. package/web/dist/assets/highlighted-body-OFNGDK62-DGHHie_q.js +1 -0
  214. package/web/dist/assets/highlighter-BKVEsACy.js +3 -0
  215. package/web/dist/assets/html-BY76lXLH.js +1 -0
  216. package/web/dist/assets/index-CEkI7QxN.css +2 -0
  217. package/web/dist/assets/index-CO2lH2et.js +11 -0
  218. package/web/dist/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  219. package/web/dist/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  220. package/web/dist/assets/javascript-BgS3c2Ky.js +1 -0
  221. package/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  222. package/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  223. package/web/dist/assets/json-qhed-kSA.js +1 -0
  224. package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
  225. package/web/dist/assets/jsx-Bz0zcwM4.js +1 -0
  226. package/web/dist/assets/lib-CNGa3Dig.js +1 -0
  227. package/web/dist/assets/loader-circle-BV3DO9mE.js +1 -0
  228. package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
  229. package/web/dist/assets/markdown-D4-ADgH9.js +1 -0
  230. package/web/dist/assets/mermaid-GHXKKRXX-DM2VsGBG.js +1 -0
  231. package/web/dist/assets/open-mercato-toBr6SOa.svg +11 -0
  232. package/web/dist/assets/prompt-templates-C7ptKvDd.js +15 -0
  233. package/web/dist/assets/python-gzcpVVnB.js +1 -0
  234. package/web/dist/assets/react-dom-Ddtik4qM.js +1 -0
  235. package/web/dist/assets/refresh-cw-DCa-Rlwz.js +1 -0
  236. package/web/dist/assets/repo-git-DIhryGDx.js +1 -0
  237. package/web/dist/assets/run-diff-Dyow8B1q.js +3 -0
  238. package/web/dist/assets/run-header-jx9-18b8.js +1 -0
  239. package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
  240. package/web/dist/assets/search-x-CoCyl7zT.js +1 -0
  241. package/web/dist/assets/shellscript-CLZ0U2zV.js +1 -0
  242. package/web/dist/assets/skill-detail-DB7x_FQp.js +1 -0
  243. package/web/dist/assets/skills-98vCroU8.js +1 -0
  244. package/web/dist/assets/skills-BKIoqD6K.js +1 -0
  245. package/web/dist/assets/sql-BsFa4tDR.js +1 -0
  246. package/web/dist/assets/square-terminal-B6PZX4Qp.js +1 -0
  247. package/web/dist/assets/tab-link-C5--YMQd.js +1 -0
  248. package/web/dist/assets/task-changes-ejxPGVJw.js +1 -0
  249. package/web/dist/assets/task-commits-C6GO5qT-.js +1 -0
  250. package/web/dist/assets/task-files-CatpCBXa.js +2 -0
  251. package/web/dist/assets/task-thread-BMbXDM3d.js +5 -0
  252. package/web/dist/assets/tasks-table-dgezlCcg.js +1 -0
  253. package/web/dist/assets/trash-2-CDtxmmc8.js +1 -0
  254. package/web/dist/assets/triangle-alert-6su4Js5O.js +1 -0
  255. package/web/dist/assets/tsx-udAQXfEw.js +1 -0
  256. package/web/dist/assets/typescript-bsJCZSQ-.js +1 -0
  257. package/web/dist/assets/upload-Bp7hQxll.js +1 -0
  258. package/web/dist/assets/use-desktop-CvTwojOJ.js +3 -0
  259. package/web/dist/assets/utils-rQGbOrwc.js +1 -0
  260. package/web/dist/assets/workflows-Dy2c6790.js +11 -0
  261. package/web/dist/assets/x-Br_jIDBw.js +1 -0
  262. package/web/dist/assets/yaml-rwi0_p6S.js +1 -0
  263. package/web/dist/index.html +70 -0
  264. package/web/open-mercato.svg +11 -0
@@ -0,0 +1,308 @@
1
+ /**
2
+ * Normalized agent-event protocol v2 — the shared vocabulary every runner
3
+ * emits ALONGSIDE the v1 `AgentEvent` stream (never replacing it; mixed
4
+ * NDJSON files stay valid — old recordings must keep replaying).
5
+ *
6
+ * Contract sources (authoritative, in this order):
7
+ * - `.ai/analysis/cockpit-ui-redesign/agent-event-protocols.md` §7 (schema)
8
+ * and §7.1 (per-backend mapping tables);
9
+ * - the spec `.ai/specs/2026-07-14-cockpit-ui-redesign.md`
10
+ * §"Normalized agent-event protocol v2".
11
+ *
12
+ * Design rules baked in:
13
+ * 1. Item-lifecycle model (Codex/ACP style): one stable `id` per item with
14
+ * started/delta/updated/completed phases — two of the three backends are
15
+ * natively item-shaped and claude maps trivially.
16
+ * 2. ACP vocabulary wherever a choice is arbitrary (tool status/kind, plan
17
+ * entries, diff shape, stop reasons) for ecosystem alignment.
18
+ * 3. Every v1 `AgentEvent` stays derivable from this stream, so consumers
19
+ * can migrate one panel at a time.
20
+ *
21
+ * This module is pure vocabulary: no runtime imports, no runner coupling.
22
+ * Step 2.4 mirrors it into `web/app/src/protocol/`.
23
+ */
24
+ /** The backend that produced a session — mirrors `RunnerId` in
25
+ * `agent-runner.ts` (kept structurally identical; a type-level test
26
+ * guards against drift so this module stays dependency-free). */
27
+ export type UiBackend = 'claude' | 'codex' | 'opencode';
28
+ /**
29
+ * Tool lifecycle status (ACP: pending/in_progress/completed/failed).
30
+ * `running` ≡ ACP `in_progress` (opencode's word — reads better in code);
31
+ * `declined` covers codex approval declines and claude `permission_denials`.
32
+ *
33
+ * Per backend: claude has no pending phase (`tool_use` arrives already
34
+ * running); codex maps `inProgress→running`, `completed/failed/declined`
35
+ * verbatim; opencode maps `pending/running` verbatim and `error→failed`.
36
+ */
37
+ export type ToolStatus = 'pending' | 'running' | 'completed' | 'failed' | 'declined';
38
+ /**
39
+ * Icon/verb hint for a tool item — a superset of ACP's ToolKind.
40
+ * `task` = subagent spawn (claude Task / opencode subtask / codex review).
41
+ */
42
+ export type ToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'task' | 'plan' | 'other';
43
+ /**
44
+ * Why a turn (or the session) stopped.
45
+ *
46
+ * Per backend: claude `result` subtype success→`end_turn`,
47
+ * error_max_turns→`max_tokens`, error_during_execution→`error`; codex
48
+ * turn/completed→`end_turn`, turn/failed→`error`, interrupt→`cancelled`;
49
+ * opencode `session.idle`→`end_turn` (or `error` when a session.error
50
+ * preceded it).
51
+ */
52
+ export type StopReason = 'end_turn' | 'max_tokens' | 'refusal' | 'cancelled' | 'timeout' | 'error';
53
+ /**
54
+ * Status of one plan/todo entry. claude TodoWrite/TaskUpdate use the first
55
+ * three words verbatim; codex `turn/plan/updated` sends camelCase
56
+ * (`inProgress`) and is normalized here; opencode `todowrite` adds
57
+ * `cancelled` ("no longer needed") — its status field is a free-form string
58
+ * whose documented vocabulary is pending|in_progress|completed|cancelled.
59
+ *
60
+ * `cancelled` is opencode-only today. It is a first-class status rather than a
61
+ * dropped row: an abandoned todo must stay visible (struck through) instead of
62
+ * silently vanishing from the dock mid-run.
63
+ */
64
+ export type PlanStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
65
+ /** One entry of the session plan — full-replacement semantics (ACP style). */
66
+ export interface PlanEntry {
67
+ content: string;
68
+ status: PlanStatus;
69
+ priority?: 'high' | 'medium' | 'low';
70
+ /** Present-continuous label shown while the entry is in progress
71
+ * (claude TodoWrite's `activeForm`). */
72
+ activeForm?: string;
73
+ }
74
+ /**
75
+ * Raw token counts — never pre-weighted (cost weighting is a presentation
76
+ * concern, not a wire concern).
77
+ *
78
+ * Per backend: claude `result.usage` (+ `total_cost_usd` as `costUsd` on the
79
+ * carrying event); codex `thread/tokenUsage/updated` (no USD); opencode
80
+ * `message.updated` info.tokens/cost and `step-finish` parts.
81
+ */
82
+ export interface TokenUsage {
83
+ input: number;
84
+ output: number;
85
+ cacheRead?: number;
86
+ cacheWrite?: number;
87
+ reasoning?: number;
88
+ /** The backend's own total when given, else the sum of the parts. */
89
+ total: number;
90
+ /** Model context-window size when known — feeds the fill gauge. */
91
+ contextWindow?: number;
92
+ }
93
+ /**
94
+ * One file change carried by an edit-tool item.
95
+ * claude `Edit`/`Write` input → `oldText`/`newText`; codex
96
+ * `fileChange.changes[]` → `unified`; opencode `patch` parts → `unified`.
97
+ * `oldText: null` means the file is newly created.
98
+ */
99
+ export interface FileDiff {
100
+ path: string;
101
+ oldText: string | null;
102
+ newText?: string;
103
+ unified?: string;
104
+ }
105
+ /** A file location a tool touched (feeds "jump to file" affordances). */
106
+ export interface ToolLocation {
107
+ path: string;
108
+ line?: number;
109
+ }
110
+ /** A choice offered by a permission request (ACP option kinds). */
111
+ export type PermissionOptionKind = 'allow_once' | 'allow_always' | 'reject_once' | 'reject_always';
112
+ export interface PermissionOption {
113
+ id: string;
114
+ label: string;
115
+ kind: PermissionOptionKind;
116
+ }
117
+ /**
118
+ * A chat message.
119
+ * claude: `assistant` `text` blocks (whole-block, or true deltas via
120
+ * `--include-partial-messages`); codex: `agentMessage` items (`phase` from
121
+ * the item's own phase field); opencode: text parts of a message.
122
+ */
123
+ export interface UiMessageItem {
124
+ kind: 'message';
125
+ id: string;
126
+ role: 'assistant' | 'user';
127
+ text: string;
128
+ phase?: 'commentary' | 'final';
129
+ parentItemId?: string;
130
+ }
131
+ /**
132
+ * Extended thinking / reasoning summary.
133
+ * claude: `thinking` blocks; codex: `reasoning` items (+ textDelta);
134
+ * opencode: `reasoning` parts.
135
+ */
136
+ export interface UiReasoningItem {
137
+ kind: 'reasoning';
138
+ id: string;
139
+ text: string;
140
+ parentItemId?: string;
141
+ }
142
+ /**
143
+ * One tool invocation with its full lifecycle.
144
+ * claude: `tool_use` (started, status `running`) + `tool_result`
145
+ * (completed/failed; `permission_denials` → `declined`); codex: typed items
146
+ * (`commandExecution`→execute with `exitCode`, `fileChange`→edit with
147
+ * `diffs`, `mcpToolCall`→other, `webSearch`→fetch); opencode: tool parts
148
+ * (state pending/running/completed/error, `patch` parts → `diffs`).
149
+ *
150
+ * `parentItemId` nests subagent work under its spawning task item —
151
+ * claude `parent_tool_use_id`, opencode `subtask` parts, codex review items.
152
+ */
153
+ export interface UiToolItem {
154
+ kind: 'tool';
155
+ id: string;
156
+ /** The backend's tool name / item type (e.g. `Bash`, `commandExecution`). */
157
+ name: string;
158
+ /** ACP-style icon/verb hint — see `toolDisplay()` in `tool-display.ts`. */
159
+ toolKind: ToolKind;
160
+ /** Human line, computed once in the protocol layer: "Ran npm test". */
161
+ title: string;
162
+ status: ToolStatus;
163
+ /** Raw input — may arrive incrementally. */
164
+ input?: unknown;
165
+ output?: string;
166
+ error?: string;
167
+ diffs?: FileDiff[];
168
+ locations?: ToolLocation[];
169
+ /** commandExecution / bash exit code, when the backend reports one. */
170
+ exitCode?: number;
171
+ parentItemId?: string;
172
+ }
173
+ export type UiItem = UiMessageItem | UiReasoningItem | UiToolItem;
174
+ /**
175
+ * Session opened.
176
+ * claude: `system/init` (model, tools, cwd); codex: `thread/started` or the
177
+ * `thread/start` result; opencode: `POST /session` response.
178
+ */
179
+ export interface UiSessionStartedEvent {
180
+ type: 'session.started';
181
+ sessionId: string;
182
+ backend: UiBackend;
183
+ model?: string;
184
+ cwd?: string;
185
+ tools?: string[];
186
+ }
187
+ /** Session over (replaces v1 `done` / fatal `error`). */
188
+ export interface UiSessionEndedEvent {
189
+ type: 'session.ended';
190
+ reason: StopReason;
191
+ message?: string;
192
+ }
193
+ /** v1 `note` + `error` unified — severity explicit instead of implied. */
194
+ export interface UiSessionErrorEvent {
195
+ type: 'session.error';
196
+ message: string;
197
+ fatal: boolean;
198
+ }
199
+ /**
200
+ * A turn began.
201
+ * claude: on each stdin user message; codex: `turn/started`;
202
+ * opencode: on each prompt POST.
203
+ */
204
+ export interface UiTurnStartedEvent {
205
+ type: 'turn.started';
206
+ turnId: string;
207
+ }
208
+ /**
209
+ * A turn finished.
210
+ * claude: `result` (usage + `total_cost_usd`); codex: `turn/completed` /
211
+ * `turn/failed`; opencode: `session.idle`.
212
+ */
213
+ export interface UiTurnCompletedEvent {
214
+ type: 'turn.completed';
215
+ turnId: string;
216
+ stopReason: StopReason;
217
+ usage?: TokenUsage;
218
+ costUsd?: number;
219
+ }
220
+ /** An item entered the stream (tools usually with status pending/running). */
221
+ export interface UiItemStartedEvent {
222
+ type: 'item.started';
223
+ item: UiItem;
224
+ }
225
+ /**
226
+ * Streaming append to one field of a live item.
227
+ * claude: partial-message text deltas; codex: `item/agentMessage/delta`
228
+ * (`text`), `item/reasoning/textDelta` (`reasoning`),
229
+ * `item/commandExecution/outputDelta` (`output` — live terminal); opencode:
230
+ * text/reasoning part cursor deltas, running-state metadata for `output`.
231
+ * claude has no live command output — the tool card fills on completion
232
+ * (per-capability degradation, never per-backend).
233
+ */
234
+ export interface UiItemDeltaEvent {
235
+ type: 'item.delta';
236
+ itemId: string;
237
+ field: 'text' | 'reasoning' | 'output';
238
+ delta: string;
239
+ }
240
+ /** Status flips and streamed-content snapshots (codex `item/updated`,
241
+ * opencode part-state flips such as pending→running). */
242
+ export interface UiItemUpdatedEvent {
243
+ type: 'item.updated';
244
+ item: UiItem;
245
+ }
246
+ /** Final snapshot of an item — safe to persist (snapshots, not deltas). */
247
+ export interface UiItemCompletedEvent {
248
+ type: 'item.completed';
249
+ item: UiItem;
250
+ }
251
+ /**
252
+ * Full-replacement plan snapshot (ACP semantics).
253
+ * claude: `TodoWrite` tool input, or a snapshot folded from the incremental
254
+ * `TaskCreate`/`TaskUpdate`/`TaskList` calls (keyed by the task id the harness
255
+ * reports in each tool's RESULT — see `claude-ui-mapper`); codex: the
256
+ * `turn/plan/updated` notification carrying the whole `update_plan` list (it is
257
+ * a turn-level notification, NOT an item — the app-server `ThreadItem` union has
258
+ * no todo variant); opencode: `todowrite` tool input — identical
259
+ * full-replacement semantics across all three.
260
+ */
261
+ export interface UiPlanUpdatedEvent {
262
+ type: 'plan.updated';
263
+ entries: PlanEntry[];
264
+ }
265
+ /**
266
+ * RESERVED — wired when auto-approve becomes optional. Types only for now.
267
+ * claude: `control_request can_use_tool`; codex: the per-item
268
+ * `requestApproval` JSON-RPC requests; opencode: `permission.updated`.
269
+ */
270
+ export interface UiPermissionRequestedEvent {
271
+ type: 'permission.requested';
272
+ requestId: string;
273
+ itemId?: string;
274
+ title: string;
275
+ options: PermissionOption[];
276
+ }
277
+ /** RESERVED — the counterpart resolution (see `permission.requested`). */
278
+ export interface UiPermissionResolvedEvent {
279
+ type: 'permission.resolved';
280
+ requestId: string;
281
+ optionId: string;
282
+ }
283
+ /**
284
+ * Cumulative-for-session raw telemetry.
285
+ * claude: `result.usage` + `total_cost_usd`; codex:
286
+ * `thread/tokenUsage/updated` (cost stays absent); opencode:
287
+ * `message.updated` tokens/cost + `step-finish` increments.
288
+ */
289
+ export interface UiUsageUpdatedEvent {
290
+ type: 'usage.updated';
291
+ usage: TokenUsage;
292
+ costUsd?: number;
293
+ }
294
+ /**
295
+ * An image emitted mid-stream (kept from v1) — raw base64 on the wire here;
296
+ * the run manager persists it and re-emits a URL. claude: image blocks in
297
+ * `tool_result` (with `itemId` linking back to the tool item).
298
+ */
299
+ export interface UiImageEvent {
300
+ type: 'image';
301
+ itemId?: string;
302
+ mediaType: string;
303
+ data: string;
304
+ }
305
+ export type UiEvent = UiSessionStartedEvent | UiSessionEndedEvent | UiSessionErrorEvent | UiTurnStartedEvent | UiTurnCompletedEvent | UiItemStartedEvent | UiItemDeltaEvent | UiItemUpdatedEvent | UiItemCompletedEvent | UiPlanUpdatedEvent | UiPermissionRequestedEvent | UiPermissionResolvedEvent | UiUsageUpdatedEvent | UiImageEvent;
306
+ /** Every v2 event discriminator — `satisfies Record<UiEventType, …>` maps
307
+ * downstream keep new event types honest at compile time. */
308
+ export type UiEventType = UiEvent['type'];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Normalized agent-event protocol v2 — the shared vocabulary every runner
3
+ * emits ALONGSIDE the v1 `AgentEvent` stream (never replacing it; mixed
4
+ * NDJSON files stay valid — old recordings must keep replaying).
5
+ *
6
+ * Contract sources (authoritative, in this order):
7
+ * - `.ai/analysis/cockpit-ui-redesign/agent-event-protocols.md` §7 (schema)
8
+ * and §7.1 (per-backend mapping tables);
9
+ * - the spec `.ai/specs/2026-07-14-cockpit-ui-redesign.md`
10
+ * §"Normalized agent-event protocol v2".
11
+ *
12
+ * Design rules baked in:
13
+ * 1. Item-lifecycle model (Codex/ACP style): one stable `id` per item with
14
+ * started/delta/updated/completed phases — two of the three backends are
15
+ * natively item-shaped and claude maps trivially.
16
+ * 2. ACP vocabulary wherever a choice is arbitrary (tool status/kind, plan
17
+ * entries, diff shape, stop reasons) for ecosystem alignment.
18
+ * 3. Every v1 `AgentEvent` stays derivable from this stream, so consumers
19
+ * can migrate one panel at a time.
20
+ *
21
+ * This module is pure vocabulary: no runtime imports, no runner coupling.
22
+ * Step 2.4 mirrors it into `web/app/src/protocol/`.
23
+ */
24
+ export {};
25
+ //# sourceMappingURL=ui-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-events.js","sourceRoot":"","sources":["../../src/core/ui-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -0,0 +1,11 @@
1
+ export declare const CACHE_READ_WEIGHT = 0.1;
2
+ export declare const CACHE_CREATION_WEIGHT = 1.25;
3
+ /** A loosely-typed usage record as emitted by the claude CLI stream. */
4
+ export interface RawUsage {
5
+ input_tokens?: number;
6
+ output_tokens?: number;
7
+ cache_creation_input_tokens?: number;
8
+ cache_read_input_tokens?: number;
9
+ }
10
+ /** Collapse a raw usage record into a single cost-weighted token count. */
11
+ export declare function costWeightedTokens(usage: RawUsage | undefined | null): number;
@@ -0,0 +1,15 @@
1
+ // Anthropic bills cache-read input at ~10% of standard input cost and cache
2
+ // creation at ~125%. Weighting raw counts by these keeps the token number
3
+ // shown in the cockpit roughly proportional to dollar cost.
4
+ export const CACHE_READ_WEIGHT = 0.1;
5
+ export const CACHE_CREATION_WEIGHT = 1.25;
6
+ /** Collapse a raw usage record into a single cost-weighted token count. */
7
+ export function costWeightedTokens(usage) {
8
+ if (!usage)
9
+ return 0;
10
+ return Math.round((usage.input_tokens ?? 0) +
11
+ (usage.output_tokens ?? 0) +
12
+ (usage.cache_creation_input_tokens ?? 0) * CACHE_CREATION_WEIGHT +
13
+ (usage.cache_read_input_tokens ?? 0) * CACHE_READ_WEIGHT);
14
+ }
15
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/core/usage.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAU1C,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB,CAAC,KAAkC;IACnE,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,KAAK,CACf,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC;QACvB,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC;QAC1B,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,CAAC,GAAG,qBAAqB;QAChE,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAC3D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Git worktree per task (spec 006). Each run gets its own branch
3
+ * `cez/<id8>` checked out into `.ai/cezar/worktrees/<runId>` so agents never
4
+ * touch the user's working tree. Pattern ported from github-janitor's
5
+ * `git.ts` (createWorktree / autosaveCommit), minus the bare clone — we're
6
+ * already inside a working copy. Everything degrades: helpers never throw
7
+ * except `createWorktree`, whose failure the caller turns into a note.
8
+ */
9
+ /** Repo-relative home of all task worktrees (gitignored via .ai/cezar/.gitignore). */
10
+ export declare const WORKTREES_DIR = ".ai/cezar/worktrees";
11
+ export declare function branchFor(runId: string): string;
12
+ /**
13
+ * Resolve the configured base branch to something `git worktree add` can
14
+ * fork from: the branch itself, else its remote-tracking ref (base exists
15
+ * only on origin), else null — the caller falls back to the current branch
16
+ * with a note. Never throws.
17
+ */
18
+ export declare function resolveBaseRef(repoRoot: string, base: string): Promise<string | null>;
19
+ export declare function worktreePathFor(repoRoot: string, runId: string): string;
20
+ export interface WorktreeInfo {
21
+ path: string;
22
+ branch: string;
23
+ /** Branch name the worktree was forked from (commit sha when HEAD was detached). */
24
+ baseBranch: string;
25
+ }
26
+ /**
27
+ * Establish the task worktree idempotently. Besides the fresh
28
+ * `git worktree add -b` path, recover the two normal restart/deletion cases:
29
+ * reuse an already-registered task worktree, or reattach a surviving task
30
+ * branch after its directory/registration was removed. Existing non-empty
31
+ * unregistered paths are never deleted because they may hold recoverable
32
+ * uncommitted work.
33
+ */
34
+ export declare function createWorktree(repoRoot: string, runId: string, baseBranch: string): Promise<WorktreeInfo>;
35
+ /**
36
+ * Best-effort on-disk size of a worktree directory in bytes, via POSIX
37
+ * `du -sk` (kibibytes → bytes). Returns `null` when `du` is unavailable —
38
+ * including all of Windows, where `du` is not a command — or on any error.
39
+ * Never throws and never blocks: worktree retention is count-based, so a null
40
+ * size only blanks the panel's size column, it does not affect reclamation.
41
+ */
42
+ export declare function worktreeSizeBytes(path: string): Promise<number | null>;
43
+ /** Remove a task worktree and its branch. Best effort — never throws. */
44
+ export declare function removeWorktree(repoRoot: string, worktreePath: string, branch?: string): Promise<void>;
45
+ /**
46
+ * Stage and commit everything in the worktree as a "cezar autosave" commit
47
+ * (janitor pattern) — the agent's progress is always recoverable from the
48
+ * `cez/<id8>` branch history. Quietly a no-op when nothing changed.
49
+ */
50
+ export declare function autosaveCommit(dir: string): Promise<boolean>;
51
+ /**
52
+ * "What did this task change": diff of the worktree (committed + uncommitted
53
+ * + untracked, via `add -N`) against the merge-base with its base branch —
54
+ * so the diff stays *this task's* changes even after the base moves on.
55
+ */
56
+ export declare function worktreeDiff(worktreePath: string, baseBranch: string, cap?: number): Promise<string>;
57
+ /**
58
+ * `git diff --stat` version of `worktreeDiff` (spec 010 — the variant
59
+ * comparison columns). Same merge-base anchoring; returns '' on any failure.
60
+ */
61
+ export declare function worktreeDiffStat(worktreePath: string, baseBranch: string): Promise<string>;
62
+ /** Aggregate diff numbers (#389) — the shape stored on `RunRecord.diffStat`. */
63
+ export interface DiffStat {
64
+ adds: number;
65
+ dels: number;
66
+ files: number;
67
+ }
68
+ /**
69
+ * Parse `git diff --shortstat` output — " 3 files changed, 10 insertions(+),
70
+ * 2 deletions(-)". Every part is optional: insertions-only and deletions-only
71
+ * diffs omit the other counter, and an empty diff prints nothing at all
72
+ * (→ all zeros). The wording is stable porcelain English — git does not
73
+ * localize `--shortstat` — so matching the words is safe.
74
+ */
75
+ export declare function parseShortstat(s: string): DiffStat;
76
+ /**
77
+ * `git diff --shortstat` of the worktree vs its base (#389) — same
78
+ * merge-base anchoring and intent-to-add as `worktreeDiff`, parsed into
79
+ * numbers. Null on git failure (the caller notes it, never fails the run);
80
+ * an empty diff is a valid all-zero stat.
81
+ */
82
+ export declare function worktreeShortstat(worktreePath: string, baseBranch: string): Promise<DiffStat | null>;
83
+ /**
84
+ * Startup reconcile: `git worktree prune` + remove every directory under
85
+ * `.ai/cezar/worktrees/` whose run id is no longer in the store (and its
86
+ * branch). Returns the removed run ids for the boot log. Never throws.
87
+ */
88
+ export declare function pruneOrphans(repoRoot: string, validIds: ReadonlySet<string>): Promise<string[]>;