@open-mercato/cezar 0.9.1 → 0.9.2

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 (300) hide show
  1. package/README.md +19 -11
  2. package/dist/agent-config/catalog.d.ts +1 -1
  3. package/dist/agent-config/files.d.ts +1 -1
  4. package/dist/agent-config/service.d.ts +1 -1
  5. package/dist/agent-config/validate.d.ts +1 -1
  6. package/dist/automations/coordinator.d.ts +26 -0
  7. package/dist/automations/coordinator.js +66 -0
  8. package/dist/automations/coordinator.js.map +1 -0
  9. package/dist/automations/github-poller.d.ts +74 -0
  10. package/dist/automations/github-poller.js +234 -0
  11. package/dist/automations/github-poller.js.map +1 -0
  12. package/dist/automations/scheduler.d.ts +42 -0
  13. package/dist/automations/scheduler.js +192 -0
  14. package/dist/automations/scheduler.js.map +1 -0
  15. package/dist/automations/store.d.ts +65 -0
  16. package/dist/automations/store.js +298 -0
  17. package/dist/automations/store.js.map +1 -0
  18. package/dist/automations/task-template.d.ts +18 -0
  19. package/dist/automations/task-template.js +95 -0
  20. package/dist/automations/task-template.js.map +1 -0
  21. package/dist/automations/types.d.ts +251 -0
  22. package/dist/automations/types.js +158 -0
  23. package/dist/automations/types.js.map +1 -0
  24. package/dist/config.d.ts +9 -111
  25. package/dist/contract/agent-config.d.ts +151 -0
  26. package/dist/contract/automations.d.ts +911 -0
  27. package/dist/contract/events.d.ts +45 -0
  28. package/dist/contract/github.d.ts +467 -0
  29. package/dist/contract/health.d.ts +96 -0
  30. package/dist/contract/index.d.ts +15 -0
  31. package/dist/contract/index.js +1421 -0
  32. package/dist/contract/projects.d.ts +182 -0
  33. package/dist/contract/repo.d.ts +234 -0
  34. package/dist/contract/runs.d.ts +1226 -0
  35. package/dist/contract/skills.d.ts +225 -0
  36. package/dist/contract/workflows.d.ts +212 -0
  37. package/dist/contract/workspace.d.ts +442 -0
  38. package/dist/core/agent-env.d.ts +1 -1
  39. package/dist/core/agent-runner.d.ts +12 -1
  40. package/dist/core/agent-runner.js +13 -0
  41. package/dist/core/agent-runner.js.map +1 -1
  42. package/dist/core/ask.d.ts +45 -124
  43. package/dist/core/ask.js +103 -13
  44. package/dist/core/ask.js.map +1 -1
  45. package/dist/core/claude-cli-runner.d.ts +2 -2
  46. package/dist/core/claude-cli-runner.js +52 -9
  47. package/dist/core/claude-cli-runner.js.map +1 -1
  48. package/dist/core/claude-ui-mapper.d.ts +1 -1
  49. package/dist/core/codex-app-server-runner.d.ts +1 -1
  50. package/dist/core/codex-app-server-runner.js +55 -3
  51. package/dist/core/codex-app-server-runner.js.map +1 -1
  52. package/dist/core/codex-app-server-transport.d.ts +6 -1
  53. package/dist/core/codex-app-server-transport.js +12 -3
  54. package/dist/core/codex-app-server-transport.js.map +1 -1
  55. package/dist/core/codex-model-catalog.d.ts +1 -1
  56. package/dist/core/codex-ui-mapper.d.ts +5 -1
  57. package/dist/core/codex-ui-mapper.js +74 -17
  58. package/dist/core/codex-ui-mapper.js.map +1 -1
  59. package/dist/core/model-identity.d.ts +1 -1
  60. package/dist/core/model-presets.d.ts +2 -2
  61. package/dist/core/model-presets.js +1 -1
  62. package/dist/core/opencode-server-runner.d.ts +2 -2
  63. package/dist/core/opencode-ui-mapper.d.ts +4 -1
  64. package/dist/core/opencode-ui-mapper.js +45 -7
  65. package/dist/core/opencode-ui-mapper.js.map +1 -1
  66. package/dist/core/provider-auth.d.ts +62 -0
  67. package/dist/core/provider-auth.js +290 -0
  68. package/dist/core/provider-auth.js.map +1 -0
  69. package/dist/core/provider-availability.d.ts +3 -0
  70. package/dist/core/provider-availability.js +13 -0
  71. package/dist/core/provider-availability.js.map +1 -0
  72. package/dist/core/runner-factory.d.ts +1 -1
  73. package/dist/core/runner-model-catalog.d.ts +1 -1
  74. package/dist/core/tool-display.d.ts +1 -1
  75. package/dist/core/ui-events.d.ts +1 -1
  76. package/dist/core/ui-events.js +1 -1
  77. package/dist/git-diff-base.d.ts +60 -0
  78. package/dist/git-diff-base.js +54 -0
  79. package/dist/git-diff-base.js.map +1 -0
  80. package/dist/git-worktree.d.ts +37 -6
  81. package/dist/git-worktree.js +39 -9
  82. package/dist/git-worktree.js.map +1 -1
  83. package/dist/handoff.d.ts +2 -2
  84. package/dist/handoff.js +1 -1
  85. package/dist/index.js +65 -8
  86. package/dist/index.js.map +1 -1
  87. package/dist/paths.d.ts +16 -1
  88. package/dist/paths.js +24 -1
  89. package/dist/paths.js.map +1 -1
  90. package/dist/planner.d.ts +2 -2
  91. package/dist/planner.js +1 -1
  92. package/dist/planner.js.map +1 -1
  93. package/dist/release/manifests.d.ts +81 -0
  94. package/dist/release/manifests.js +74 -0
  95. package/dist/release/manifests.js.map +1 -0
  96. package/dist/release/snapshot.d.ts +9 -23
  97. package/dist/release/snapshot.js +9 -22
  98. package/dist/release/snapshot.js.map +1 -1
  99. package/dist/release/stable.d.ts +15 -29
  100. package/dist/release/stable.js +14 -27
  101. package/dist/release/stable.js.map +1 -1
  102. package/dist/runs/auto-name.d.ts +1 -1
  103. package/dist/runs/retention.d.ts +1 -1
  104. package/dist/runs/store.d.ts +142 -336
  105. package/dist/runs/store.js +136 -9
  106. package/dist/runs/store.js.map +1 -1
  107. package/dist/runs/ui-event-sink.d.ts +1 -1
  108. package/dist/server/app-type.d.ts +21 -0
  109. package/dist/server/app-type.js +2 -0
  110. package/dist/server/app-type.js.map +1 -0
  111. package/dist/server/capabilities.d.ts +6 -5
  112. package/dist/server/capabilities.js +11 -0
  113. package/dist/server/capabilities.js.map +1 -1
  114. package/dist/server/forge/github.d.ts +58 -151
  115. package/dist/server/forge/github.js +530 -6
  116. package/dist/server/forge/github.js.map +1 -1
  117. package/dist/server/forge/index.d.ts +10 -3
  118. package/dist/server/forge/index.js +14 -1
  119. package/dist/server/forge/index.js.map +1 -1
  120. package/dist/server/forge/types.d.ts +86 -1
  121. package/dist/server/git-changes.d.ts +8 -8
  122. package/dist/server/git-changes.js +14 -17
  123. package/dist/server/git-changes.js.map +1 -1
  124. package/dist/server/git.d.ts +2 -0
  125. package/dist/server/git.js +9 -0
  126. package/dist/server/git.js.map +1 -1
  127. package/dist/server/github.d.ts +3 -3
  128. package/dist/server/github.js +1 -1
  129. package/dist/server/github.js.map +1 -1
  130. package/dist/server/pr.d.ts +2 -2
  131. package/dist/server/project-context.d.ts +20 -3
  132. package/dist/server/project-context.js +30 -1
  133. package/dist/server/project-context.js.map +1 -1
  134. package/dist/server/provider-action-gate.d.ts +8 -0
  135. package/dist/server/provider-action-gate.js +54 -0
  136. package/dist/server/provider-action-gate.js.map +1 -0
  137. package/dist/server/provider-auth-runtime.d.ts +21 -0
  138. package/dist/server/provider-auth-runtime.js +66 -0
  139. package/dist/server/provider-auth-runtime.js.map +1 -0
  140. package/dist/server/server.d.ts +11142 -47
  141. package/dist/server/server.js +1714 -806
  142. package/dist/server/server.js.map +1 -1
  143. package/dist/server/validators.d.ts +97 -0
  144. package/dist/server/validators.js +86 -0
  145. package/dist/server/validators.js.map +1 -0
  146. package/dist/server/ws.d.ts +2 -2
  147. package/dist/server/ws.js +2 -2
  148. package/dist/server/ws.js.map +1 -1
  149. package/dist/server-install/engine.d.ts +1 -1
  150. package/dist/server-install/platforms/macosx-ngrok.d.ts +1 -1
  151. package/dist/server-install/platforms/ubuntu-vps.d.ts +16 -1
  152. package/dist/server-install/platforms/ubuntu-vps.js +83 -1
  153. package/dist/server-install/platforms/ubuntu-vps.js.map +1 -1
  154. package/dist/server-install/state.d.ts +1 -1
  155. package/dist/server-install/steps.d.ts +2 -2
  156. package/dist/server-install/strategies.d.ts +1 -1
  157. package/dist/server-install/types.d.ts +38 -424
  158. package/dist/server-install/ui.d.ts +1 -1
  159. package/dist/skills-banner.d.ts +7 -6
  160. package/dist/skills-banner.js +7 -6
  161. package/dist/skills-banner.js.map +1 -1
  162. package/dist/skills-remote.d.ts +2 -2
  163. package/dist/skills-update.d.ts +88 -0
  164. package/dist/skills-update.js +392 -0
  165. package/dist/skills-update.js.map +1 -0
  166. package/dist/skills.d.ts +2 -0
  167. package/dist/skills.js +3 -2
  168. package/dist/skills.js.map +1 -1
  169. package/dist/todos.d.ts +2 -28
  170. package/dist/todos.js +1 -1
  171. package/dist/ui-state.d.ts +16 -2
  172. package/dist/ui-state.js +14 -1
  173. package/dist/ui-state.js.map +1 -1
  174. package/dist/workflows/load.d.ts +1 -1
  175. package/dist/workflows/run.d.ts +53 -12
  176. package/dist/workflows/run.js +436 -64
  177. package/dist/workflows/run.js.map +1 -1
  178. package/dist/workflows/types.d.ts +59 -224
  179. package/dist/workflows/types.js +14 -0
  180. package/dist/workflows/types.js.map +1 -1
  181. package/dist/workspace/config.d.ts +68 -206
  182. package/dist/workspace/config.js +145 -14
  183. package/dist/workspace/config.js.map +1 -1
  184. package/dist/workspace/migrations.d.ts +1 -1
  185. package/dist/workspace/migrations.js +19 -4
  186. package/dist/workspace/migrations.js.map +1 -1
  187. package/dist/workspace/projects.d.ts +8 -2
  188. package/dist/workspace/projects.js +9 -3
  189. package/dist/workspace/projects.js.map +1 -1
  190. package/dist/workspace/semaphore.d.ts +6 -0
  191. package/dist/workspace/semaphore.js +14 -1
  192. package/dist/workspace/semaphore.js.map +1 -1
  193. package/dist/workspace/ui-state.d.ts +13 -3
  194. package/dist/workspace/ui-state.js +15 -5
  195. package/dist/workspace/ui-state.js.map +1 -1
  196. package/package.json +17 -39
  197. package/scripts/inline-contract.mjs +112 -0
  198. package/scripts/mock-claude.mjs +39 -1
  199. package/scripts/sync-readme.mjs +20 -0
  200. package/web/dist/assets/alert-dialog-ghffK6g9.js +1 -0
  201. package/web/dist/assets/arrow-down-Cz8qb71e.js +1 -0
  202. package/web/dist/assets/arrow-left-wcYKQXI_.js +1 -0
  203. package/web/dist/assets/bundle-mjs-BT31bpU6.js +1 -0
  204. package/web/dist/assets/centered-state-ZtnFHA-n.js +43 -0
  205. package/web/dist/assets/chevron-right-G4caF2QV.js +1 -0
  206. package/web/dist/assets/{chunk-BO2N2NFS-DtrdTCWa.js → chunk-BO2N2NFS-DE6qKn3r.js} +8 -8
  207. package/web/dist/assets/circle-check--KvBxXWp.js +1 -0
  208. package/web/dist/assets/circle-x-C3EFZ3xf.js +1 -0
  209. package/web/dist/assets/collapsible-B0JVzd0B.js +1 -0
  210. package/web/dist/assets/commit-list-wm6DPHNs.js +1 -0
  211. package/web/dist/assets/compare-variants-DbdP4Y5T.js +1 -0
  212. package/web/dist/assets/{core-DePtBHcl.js → core-BCsw8oQw.js} +1 -1
  213. package/web/dist/assets/diff-Bizc96qe.js +3 -0
  214. package/web/dist/assets/diff-stat-Dyfg3ltF.js +1 -0
  215. package/web/dist/assets/{diff-view-DCeSegKk.js → diff-view-CG8ek6tC.js} +4 -4
  216. package/web/dist/assets/dropdown-menu-C1Dlf35P.js +1 -0
  217. package/web/dist/assets/editable-title-5rC_QRBZ.js +1 -0
  218. package/web/dist/assets/{ellipsis-vertical-CNnSLn5a.js → ellipsis-vertical-DpGTRqC2.js} +1 -1
  219. package/web/dist/assets/{file-D4GBh1ao.js → file-DlUGpUlb.js} +1 -1
  220. package/web/dist/assets/folder-BAY6Vddy.js +1 -0
  221. package/web/dist/assets/{git-pull-request-DnR8Xh4_.js → git-pull-request-agOG0iGM.js} +1 -1
  222. package/web/dist/assets/git-toolbar-DGiNMmtY.js +1 -0
  223. package/web/dist/assets/github-Vp7lxYGQ.js +1 -0
  224. package/web/dist/assets/highlighted-body-OFNGDK62-BL-MfFgl.js +1 -0
  225. package/web/dist/assets/highlighter-CdHqIwFr.js +3 -0
  226. package/web/dist/assets/image-preview-BWGk5fPX.js +1 -0
  227. package/web/dist/assets/index-DSxyJpuK.css +2 -0
  228. package/web/dist/assets/index-DiawI6RX.js +6 -0
  229. package/web/dist/assets/lib-BQXq3kEf.js +1 -0
  230. package/web/dist/assets/lib-BxQXEXDF.js +1 -0
  231. package/web/dist/assets/markdown-BGBOGCA_.js +2 -0
  232. package/web/dist/assets/mermaid-GHXKKRXX-C4jxqUUb.js +1 -0
  233. package/web/dist/assets/new-task-form-BpAw_Dks.js +1 -0
  234. package/web/dist/assets/pill-Dvs-P0xy.js +1 -0
  235. package/web/dist/assets/project-router-Cx8NPoqn.js +1 -0
  236. package/web/dist/assets/prompt-templates-CSBYBR1I.js +15 -0
  237. package/web/dist/assets/react-runtime-CCIEwYL0.js +9 -0
  238. package/web/dist/assets/{refresh-cw-BT8E96Tm.js → refresh-cw-BoGdAykg.js} +1 -1
  239. package/web/dist/assets/repo-git-PmX-BNMo.js +1 -0
  240. package/web/dist/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  241. package/web/dist/assets/run-diff-EcOkf3ti.js +3 -0
  242. package/web/dist/assets/run-header-BGiv6_qX.js +1 -0
  243. package/web/dist/assets/{search-x-BDjaMrzG.js → search-x-X3EpVhgs.js} +1 -1
  244. package/web/dist/assets/skill-empty-hint-CZLALx6l.js +1 -0
  245. package/web/dist/assets/skills-BiWfHmCR.js +1 -0
  246. package/web/dist/assets/skills-CC91ouGH.js +1 -0
  247. package/web/dist/assets/sparkles-Dt4q7pbG.js +1 -0
  248. package/web/dist/assets/{square-terminal-Ckjjn0vb.js → square-terminal-hwBL8XsC.js} +1 -1
  249. package/web/dist/assets/tab-link-DIlR5T07.js +1 -0
  250. package/web/dist/assets/task-changes-XkHDxzQA.js +1 -0
  251. package/web/dist/assets/task-commits-BTTA5k5T.js +1 -0
  252. package/web/dist/assets/task-files-Da8_4C9g.js +2 -0
  253. package/web/dist/assets/task-thread-DoNXUsHr.js +9 -0
  254. package/web/dist/assets/textarea-CUdokhkv.js +1 -0
  255. package/web/dist/assets/thread-loading-B8q8ukXJ.js +1 -0
  256. package/web/dist/assets/{trash-2-DAyZ0VSi.js → trash-2-DhVIdWv8.js} +1 -1
  257. package/web/dist/assets/{triangle-alert-Uy8rokUh.js → triangle-alert-XYT0DGCI.js} +1 -1
  258. package/web/dist/assets/{upload-CDdyPPo_.js → upload-BKjN59-1.js} +1 -1
  259. package/web/dist/assets/use-desktop-Bf5LS_P4.js +1 -0
  260. package/web/dist/assets/use-submit-shortcut-CzVyoAMd.js +1 -0
  261. package/web/dist/assets/utils-DsLuRXwV.js +64 -0
  262. package/web/dist/assets/workflows-o2QU_pvU.js +11 -0
  263. package/web/dist/assets/zoomable-image-7WyUiaVD.js +1 -0
  264. package/web/dist/index.html +32 -13
  265. package/scripts/dev.mjs +0 -74
  266. package/scripts/release-snapshot.mjs +0 -130
  267. package/scripts/release.mjs +0 -119
  268. package/web/dist/assets/arrow-left-CnSdp92h.js +0 -1
  269. package/web/dist/assets/bundle-mjs-BegPhL5c.js +0 -1
  270. package/web/dist/assets/centered-state-DOsTcJZF.js +0 -43
  271. package/web/dist/assets/commit-list-BrxBEzRK.js +0 -1
  272. package/web/dist/assets/compare-variants-Bv2c9ORF.js +0 -1
  273. package/web/dist/assets/dist-B6XQOhgM.js +0 -1
  274. package/web/dist/assets/git-toolbar-pIC1ubPM.js +0 -1
  275. package/web/dist/assets/github-DTTSG0ht.js +0 -1
  276. package/web/dist/assets/highlighted-body-OFNGDK62-BuFJwunK.js +0 -1
  277. package/web/dist/assets/image-preview-DEhW0TFz.js +0 -1
  278. package/web/dist/assets/index-Cijmlz7q.js +0 -30
  279. package/web/dist/assets/index-DzroxqBG.css +0 -2
  280. package/web/dist/assets/lib-DPEZDBUN.js +0 -1
  281. package/web/dist/assets/lib-uHpeUPzK.js +0 -1
  282. package/web/dist/assets/mermaid-GHXKKRXX-CN2zQue0.js +0 -1
  283. package/web/dist/assets/open-mercato-toBr6SOa.svg +0 -11
  284. package/web/dist/assets/project-router-BMx4e8m-.js +0 -1
  285. package/web/dist/assets/repo-git-BusYfa3t.js +0 -1
  286. package/web/dist/assets/run-diff-wOJ3odA-.js +0 -3
  287. package/web/dist/assets/run-header-Cg5incil.js +0 -1
  288. package/web/dist/assets/skill-empty-hint-DTUSp6Vl.js +0 -1
  289. package/web/dist/assets/skills-PpP2owbM.js +0 -1
  290. package/web/dist/assets/tab-link-F3uQrdm2.js +0 -1
  291. package/web/dist/assets/task-changes-iD9kS79I.js +0 -1
  292. package/web/dist/assets/task-commits-COkLaUri.js +0 -1
  293. package/web/dist/assets/task-files-Ckttz7XH.js +0 -2
  294. package/web/dist/assets/task-thread-CQD91VPt.js +0 -9
  295. package/web/dist/assets/textarea-Bj_LCreg.js +0 -1
  296. package/web/dist/assets/use-desktop-DUh0STzq.js +0 -3
  297. package/web/dist/assets/utils-B8s5qIcK.js +0 -1
  298. package/web/dist/assets/workflows-BFk8C0co.js +0 -11
  299. package/web/dist/assets/zoomable-image-PEDOqyLQ.js +0 -1
  300. /package/web/{open-mercato.svg → dist/open-mercato.svg} +0 -0
@@ -0,0 +1,1421 @@
1
+ // ../contract/src/events.ts
2
+ import { z } from "zod";
3
+ var runEventSchema = z.looseObject({
4
+ seq: z.number(),
5
+ ts: z.string(),
6
+ stepId: z.string().optional(),
7
+ type: z.string()
8
+ });
9
+ var checkoutProgressEventSchema = z.object({
10
+ checkoutId: z.string().optional(),
11
+ name: z.string(),
12
+ phase: z.enum(["cloning", "done", "error"]),
13
+ line: z.string().optional(),
14
+ error: z.string().optional()
15
+ });
16
+
17
+ // ../contract/src/health.ts
18
+ import { z as z2 } from "zod";
19
+ var runnerSchema = z2.enum(["claude", "codex", "opencode"]);
20
+ var repoInfoSchema = z2.object({
21
+ root: z2.string(),
22
+ branch: z2.string(),
23
+ remote: z2.string().optional()
24
+ });
25
+ var backendCheckSchema = z2.object({
26
+ name: z2.enum(["claude", "codex", "opencode", "gh", "git"]),
27
+ available: z2.boolean(),
28
+ version: z2.string().optional(),
29
+ hint: z2.string().optional()
30
+ });
31
+ var forgeInfoSchema = z2.object({
32
+ kind: z2.literal("github"),
33
+ /**
34
+ * Whether the forge is reachable — **absent until the availability probe has warmed**.
35
+ *
36
+ * Health must never pay a `gh` shell-out, so it serves whatever the cache holds. Absent means
37
+ * "not determined yet", which is not the same as `false`, and the cockpit renders the two
38
+ * differently. Declaring it required is what made an earlier hand-written mirror wrong.
39
+ */
40
+ available: z2.boolean().optional(),
41
+ reason: z2.string().optional()
42
+ });
43
+ var capabilitiesSchema = z2.object({
44
+ localHandoff: z2.boolean(),
45
+ followups: z2.boolean(),
46
+ singleProject: z2.boolean(),
47
+ /**
48
+ * `false` means `CEZ_HIDE_TOKEN_METRICS=1` asks the browser to omit token counts and monetary
49
+ * cost (#481). The telemetry itself still rides in run/event payloads — this is presentation
50
+ * only.
51
+ *
52
+ * REQUIRED, because this server always sends it (`capabilities.ts` computes it from the env on
53
+ * every read) and this contract describes THIS server's wire. The DTO it replaces declared it
54
+ * optional so a newer cockpit could read an OLDER server, which is version skew a contract
55
+ * versioned in lockstep with the server cannot model. That tolerance lives where it belongs, in
56
+ * `web/src/lib/token-metrics.ts`, whose `!== false` read still treats an absent field as
57
+ * visible.
58
+ */
59
+ tokenMetrics: z2.boolean(),
60
+ /** Current token-count presentation policy. Required on current servers;
61
+ * older payload tolerance belongs in the browser resolver. */
62
+ tokenUsageMetrics: z2.boolean(),
63
+ /** Current backend-reported-cost presentation policy. */
64
+ costMetrics: z2.boolean()
65
+ });
66
+ var healthResponseSchema = z2.object({
67
+ version: z2.string(),
68
+ latestVersion: z2.string().optional(),
69
+ repoRoot: z2.string(),
70
+ repo: repoInfoSchema.nullable(),
71
+ checks: z2.array(backendCheckSchema),
72
+ defaultRunner: runnerSchema,
73
+ forge: forgeInfoSchema.nullable(),
74
+ capabilities: capabilitiesSchema,
75
+ // Always sent: `workspaceSummary()` returns both unconditionally, and an unreadable workspace
76
+ // degrades to `projects: []` rather than to an absent key. The hand-written DTO declared them
77
+ // optional, which was wider than the server has ever been.
78
+ projects: z2.array(z2.object({ id: z2.string(), name: z2.string() })),
79
+ bootProject: z2.string()
80
+ });
81
+
82
+ // ../contract/src/runs.ts
83
+ import { z as z4 } from "zod";
84
+
85
+ // ../contract/src/workflows.ts
86
+ import { z as z3 } from "zod";
87
+ var workflowStepDefSchema = z3.object({
88
+ id: z3.string().min(1),
89
+ name: z3.string().optional(),
90
+ // agent step
91
+ prompt: z3.string().optional(),
92
+ skill: z3.string().optional(),
93
+ model: z3.string().optional(),
94
+ /** Per-step agent backend override (falls back to the task / config default). */
95
+ runner: runnerSchema.optional(),
96
+ allowedTools: z3.array(z3.string()).optional(),
97
+ bashAllowlist: z3.array(z3.string()).optional(),
98
+ // check step
99
+ command: z3.string().optional(),
100
+ onFail: z3.object({
101
+ retry: z3.string().min(1),
102
+ max: z3.number().int().positive().default(2)
103
+ }).optional()
104
+ }).refine((s) => Boolean(s.command) !== Boolean(s.prompt ?? s.skill), {
105
+ message: "a step is either an agent step (prompt/skill) or a check step (command), not both"
106
+ });
107
+ var workflowDefSchema = z3.object({
108
+ name: z3.string(),
109
+ description: z3.string().optional(),
110
+ steps: z3.array(workflowStepDefSchema),
111
+ source: z3.enum(["built-in", "file"]),
112
+ /** Absent on built-ins — which is exactly what makes them undeletable. */
113
+ path: z3.string().optional()
114
+ });
115
+ var workflowLoadIssueSchema = z3.object({
116
+ path: z3.string(),
117
+ message: z3.string()
118
+ });
119
+ var workflowsResponseSchema = z3.object({
120
+ workflows: z3.array(workflowDefSchema),
121
+ issues: z3.array(workflowLoadIssueSchema)
122
+ });
123
+ var saveWorkflowInputSchema = z3.object({
124
+ name: z3.string().trim().min(1).max(80),
125
+ description: z3.string().max(2e3, "must be at most 2000 characters").optional(),
126
+ steps: z3.array(workflowStepDefSchema).min(1).max(8).optional(),
127
+ skills: z3.array(z3.string().trim().min(1)).min(1).max(8).optional(),
128
+ overwrite: z3.boolean().optional()
129
+ }).refine((b) => Boolean(b.steps) !== Boolean(b.skills), {
130
+ message: 'provide either "steps" or "skills", not both'
131
+ });
132
+ var saveWorkflowResponseSchema = z3.object({
133
+ path: z3.string(),
134
+ name: z3.string()
135
+ });
136
+ var parsedWorkflowSchema = z3.object({
137
+ name: z3.string(),
138
+ description: z3.string().optional(),
139
+ steps: z3.array(workflowStepDefSchema)
140
+ });
141
+ var deleteWorkflowResponseSchema = z3.object({
142
+ ok: z3.literal(true),
143
+ path: z3.string()
144
+ });
145
+ var planResponseSchema = z3.object({
146
+ /** The kebab-case workflow title the planner proposed. Absent on the degraded fallback. */
147
+ name: z3.string().optional(),
148
+ steps: z3.array(workflowStepDefSchema),
149
+ rationale: z3.string(),
150
+ fallback: z3.boolean()
151
+ });
152
+
153
+ // ../contract/src/runs.ts
154
+ var runStatusSchema = z4.enum([
155
+ "queued",
156
+ "running",
157
+ "waiting",
158
+ "review",
159
+ "done",
160
+ "failed",
161
+ "cancelled"
162
+ ]);
163
+ var runActivitySchema = z4.enum(["monitoring"]);
164
+ var stepStatusSchema = z4.enum([
165
+ "pending",
166
+ "running",
167
+ "waiting",
168
+ "review",
169
+ "done",
170
+ "failed",
171
+ "cancelled",
172
+ "skipped"
173
+ ]);
174
+ var usageCounterSchema = z4.number().finite().nonnegative();
175
+ var stepStateSchema = z4.object({
176
+ id: z4.string(),
177
+ name: z4.string(),
178
+ kind: z4.enum(["agent", "check"]),
179
+ status: stepStatusSchema,
180
+ iterations: z4.number(),
181
+ tokensUsed: z4.number(),
182
+ inputTokens: usageCounterSchema.optional(),
183
+ outputTokens: usageCounterSchema.optional(),
184
+ usageInvocationsStarted: usageCounterSchema.optional(),
185
+ usageInvocationsObserved: usageCounterSchema.optional(),
186
+ usageTurnsStarted: usageCounterSchema.optional(),
187
+ usageTurnsRecorded: usageCounterSchema.optional(),
188
+ usageInvocationEpoch: usageCounterSchema.optional(),
189
+ startedAt: z4.string().optional(),
190
+ finishedAt: z4.string().optional(),
191
+ error: z4.string().optional(),
192
+ /** Latest agent session id — `claude --resume <id>` and friends. */
193
+ sessionId: z4.string().optional(),
194
+ /** Backend that owns `sessionId`; absent on records written before backend affinity. */
195
+ backend: runnerSchema.optional(),
196
+ costUsd: z4.number().optional()
197
+ });
198
+ var diffStatSchema = z4.object({
199
+ adds: z4.number(),
200
+ dels: z4.number(),
201
+ files: z4.number(),
202
+ /** Additive since #751, and present ONLY when true: the numbers cover uncommitted work
203
+ * alone, because the worktree's HEAD had been repointed off the task's own branch (every
204
+ * review/QA run does this) and the merge-base anchor would otherwise have reported the
205
+ * checked-out branch's entire diff as this task's. Absent on every normal run and on every
206
+ * record written before #751 — a consumer that ignores it sees exactly the old shape. */
207
+ repointed: z4.boolean().optional()
208
+ });
209
+ var queuedMessageSchema = z4.object({
210
+ id: z4.string(),
211
+ text: z4.string(),
212
+ /** `/api/v1/runs/:id/images/…` URLs — attachments are persisted, never inlined. */
213
+ images: z4.array(z4.string()).optional(),
214
+ createdAt: z4.string()
215
+ });
216
+ var processUsageSchema = z4.object({
217
+ /** Sum of `%cpu` across the tree — can exceed 100 on multi-core work. */
218
+ cpuPct: z4.number(),
219
+ rssBytes: z4.number(),
220
+ procCount: z4.number()
221
+ });
222
+ var runRecordSchema = z4.object({
223
+ id: z4.string(),
224
+ title: z4.string(),
225
+ /** Display title (#389): auto-derived from the first agent turn, or the user's inline edit
226
+ * (`PATCH /runs/:id` sets it together with `title`). Show `titleSummary ?? title`. */
227
+ titleSummary: z4.string().optional(),
228
+ /** Refreshed on every turn-end; absent until the first turn ends (and on worktree-less runs). */
229
+ diffStat: diffStatSchema.optional(),
230
+ workflow: z4.string(),
231
+ task: z4.string(),
232
+ /** Prompt messages stacked onto the run while it waited for a free agent slot (#472). Folded
233
+ * into the prompt at dequeue — never delivered as their own turns. Absent on pre-#472 runs. */
234
+ queuedMessages: z4.array(queuedMessageSchema).optional(),
235
+ /** URLs of images attached to the initial task prompt (#image-display). */
236
+ taskImages: z4.array(z4.string()).optional(),
237
+ model: z4.string().optional(),
238
+ /** Normalized provider/model identity used for attribution and reproducible replay. */
239
+ modelIdentity: z4.string().optional(),
240
+ runner: runnerSchema.optional(),
241
+ /** Echo of the extra system prompt the run used (POST override or config default). */
242
+ systemPrompt: z4.string().optional(),
243
+ /** false when the run deliberately disabled follow-up todo generation. Absent means enabled. */
244
+ generateFollowups: z4.boolean().optional(),
245
+ /** Autonomous mode (#autonomous): the run never parks at `waiting` or the terminal `review`
246
+ * gate. Absent = falsy = not autonomous. */
247
+ autonomous: z4.boolean().optional(),
248
+ /**
249
+ * Provenance for a task a project GitHub automation launched (#694). Absent on every ordinary
250
+ * run, which is what makes it additive — the cockpit shows the "from automation" link only when
251
+ * it is there.
252
+ *
253
+ * `event` is a plain string rather than `automationEventSchema`: it is the event NAME the
254
+ * launching definition matched, recorded on the run for the audit trail, and `src/runs/store.ts`
255
+ * persists it as free text so an older cezar can still read a record written by a newer one.
256
+ */
257
+ automation: z4.object({
258
+ automationId: z4.string(),
259
+ automationRevision: z4.number(),
260
+ receiptId: z4.string(),
261
+ event: z4.string(),
262
+ githubUrl: z4.string()
263
+ }).optional(),
264
+ status: runStatusSchema,
265
+ /** `monitoring` while `status === 'running'` and the agent is working on downstream work.
266
+ * Absent on old runs; cleared on resume/end. */
267
+ activity: runActivitySchema.optional(),
268
+ /** Exact ISO-8601 deadline for the next automatic monitoring check. */
269
+ monitoringWakeAt: z4.string().optional(),
270
+ /** The current live monitoring epoch exhausted its 40 automatic checks. */
271
+ monitoringWakeCapReached: z4.boolean().optional(),
272
+ createdAt: z4.string(),
273
+ startedAt: z4.string().optional(),
274
+ finishedAt: z4.string().optional(),
275
+ tokensUsed: z4.number(),
276
+ inputTokens: usageCounterSchema.optional(),
277
+ outputTokens: usageCounterSchema.optional(),
278
+ costUsd: z4.number().optional(),
279
+ pullRequestUrl: z4.string().optional(),
280
+ /** The PR this task is ABOUT (#407) — auto-discovered from conversation references. Display
281
+ * tier only: `pullRequestUrl` (the PR this task CREATED) wins, and the action gates ignore it. */
282
+ referencedPullRequestUrl: z4.string().optional(),
283
+ /** The PR/issue number this task is ABOUT (task auto-naming spec) — display tier only. */
284
+ prNumber: z4.number().optional(),
285
+ issueNumber: z4.number().optional(),
286
+ /** Server-side provenance: referenced-issue discovery currently owns `issueNumber`. */
287
+ referencedIssueNumberSeeded: z4.boolean().optional(),
288
+ /** 'user' = renamed via PATCH, never auto-overwritten; 'marker' = agent-declared via
289
+ * CEZ:TITLE (spec 2026-07-18-task-ref-markers); 'auto' = namer-owned. */
290
+ titleOrigin: z4.enum(["user", "auto", "marker"]).optional(),
291
+ /** References the agent declared via CEZ:PR/CEZ:ISSUE markers — authoritative over the namer
292
+ * for the matching kind. */
293
+ markerRefs: z4.object({ pr: z4.number().optional(), issue: z4.number().optional() }).optional(),
294
+ /** The referenced tier's working set (distinct PR URLs spotted, capped server-side). */
295
+ referencedPrCandidates: z4.array(z4.string()).optional(),
296
+ /** The issue this task is ABOUT (spec 2026-07-21-report-ref-discovery). Display-only. */
297
+ referencedIssueUrl: z4.string().optional(),
298
+ /** The referenced-issue working set, persisted like `referencedPrCandidates`. Capped. */
299
+ referencedIssueCandidates: z4.array(z4.string()).optional(),
300
+ /** Explicit execution policy. `false` means the run intentionally uses the repo root;
301
+ * absent on older runs and for the default isolated-worktree mode. */
302
+ worktree: z4.literal(false).optional(),
303
+ /** Absent for in-place runs and after an isolated worktree is removed. */
304
+ worktreePath: z4.string().optional(),
305
+ branch: z4.string().optional(),
306
+ /** Stable baseline for session git views: a worktree's fork ref, or an in-place run's starting commit. */
307
+ baseBranch: z4.string().optional(),
308
+ /** Set when count-based retention (#483) reclaimed the worktree DIRECTORY (the branch is
309
+ * kept): the dir is gone but recoverable. */
310
+ worktreeReclaimedAt: z4.string().optional(),
311
+ /** Parallel variants (spec 010): runs sharing a groupId are one group. */
312
+ groupId: z4.string().optional(),
313
+ /** Variant letter within the group — 'A' | 'B' | 'C'. */
314
+ variant: z4.string().optional(),
315
+ peakRssBytes: z4.number().optional(),
316
+ peakProcCount: z4.number().optional(),
317
+ archived: z4.boolean(),
318
+ archivedAt: z4.string().optional(),
319
+ /** Read receipt (#unread-done-items): ISO time the cockpit last opened this run's
320
+ * thread. A finished (`done`/`failed`) run reads as *unread* until seen since it
321
+ * finished — see `isUnread()` in the cockpit's `lib/read-state.ts`. Absent on old
322
+ * runs and on any run not yet opened, both of which count as unread. */
323
+ seenAt: z4.string().optional(),
324
+ currentStepId: z4.string().optional(),
325
+ error: z4.string().optional(),
326
+ steps: z4.array(stepStateSchema),
327
+ /**
328
+ * The persisted workflow definition, so a `queued` run survives a restart — including the ad-hoc
329
+ * "(planned)" chains that exist nowhere else.
330
+ *
331
+ * The definition schema and NOT `z.record(z.string(), z.unknown())`: this key comes off the wire,
332
+ * so its values are whatever `JSON.parse` can produce and nothing else. `unknown` was wider than
333
+ * the server can serialize, and it made the route type unrepresentable here — hono maps `unknown`
334
+ * to its own `JSONValue`, whose index signature admits `object | symbol | undefined`. The fix was
335
+ * at the source: `src/runs/store.ts` persists a typed `workflowDefSchema` now, so the route's own
336
+ * type is this shape and the two-way check in `src/server/contract-parity.runs.test.ts` covers it
337
+ * like every other key.
338
+ */
339
+ workflowDef: workflowDefSchema.optional()
340
+ });
341
+ var apiRunSchema = runRecordSchema.extend({
342
+ usage: processUsageSchema.optional()
343
+ });
344
+ var createRunResponseSchema = z4.union([
345
+ runRecordSchema,
346
+ z4.object({ runs: z4.array(runRecordSchema) })
347
+ ]);
348
+ var cancelResponseSchema = z4.object({ cancelled: z4.boolean() });
349
+ var archiveFinishedResponseSchema = z4.object({ archived: z4.number() });
350
+ var markAllReadResponseSchema = z4.object({ read: z4.number() });
351
+ var deleteRunResponseSchema = z4.object({ deleted: z4.literal(true) });
352
+ var finishResponseSchema = z4.object({ finished: z4.literal(true) });
353
+ var continueResponseSchema = z4.object({ continued: z4.literal(true) });
354
+ var createPrResponseSchema = z4.object({
355
+ url: z4.string(),
356
+ dryRun: z4.boolean()
357
+ });
358
+ var messageResponseSchema = z4.union([
359
+ z4.object({ delivered: z4.literal(true) }),
360
+ z4.object({ queued: z4.literal(true), message: queuedMessageSchema }),
361
+ z4.object({ deferred: z4.literal(true) })
362
+ ]);
363
+ var editQueuedMessageResponseSchema = z4.object({ message: queuedMessageSchema });
364
+ var removeQueuedMessageResponseSchema = z4.object({ removed: z4.literal(true) });
365
+ var openInCliResponseSchema = z4.object({
366
+ opened: z4.literal(true),
367
+ command: z4.string()
368
+ });
369
+ var removeWorktreeResponseSchema = z4.object({ removed: z4.literal(true) });
370
+ var gitCommitResponseSchema = z4.object({
371
+ committed: z4.literal(true),
372
+ sha: z4.string()
373
+ });
374
+ var gitPushResponseSchema = z4.object({
375
+ pushed: z4.literal(true),
376
+ branch: z4.string(),
377
+ remote: z4.string(),
378
+ upstreamSet: z4.boolean()
379
+ });
380
+ var runCommitSchema = z4.object({
381
+ sha: z4.string(),
382
+ subject: z4.string(),
383
+ author: z4.string(),
384
+ /** Relative time ("3 hours ago") — git's `%cr`. */
385
+ when: z4.string()
386
+ });
387
+ var runCommitsResponseSchema = z4.object({ commits: z4.array(runCommitSchema) });
388
+ var groupVariantSchema = z4.object({
389
+ id: z4.string(),
390
+ /** 'A' | 'B' | 'C' in practice; `'?'` for a record that lost its letter. */
391
+ variant: z4.string(),
392
+ title: z4.string(),
393
+ status: runStatusSchema,
394
+ archived: z4.boolean(),
395
+ tokensUsed: z4.number(),
396
+ inputTokens: usageCounterSchema.optional(),
397
+ outputTokens: usageCounterSchema.optional(),
398
+ costUsd: z4.number().optional(),
399
+ diffStat: z4.string(),
400
+ /** First lines of the handoff journal's "## Progress log" section, as markdown. */
401
+ handoffExcerpt: z4.string()
402
+ });
403
+ var groupResponseSchema = z4.object({
404
+ groupId: z4.string(),
405
+ runs: z4.array(groupVariantSchema)
406
+ });
407
+ var pickVariantResponseSchema = z4.object({
408
+ winner: runRecordSchema.optional()
409
+ });
410
+ var imageInputSchema = z4.object({
411
+ mediaType: z4.string().regex(/^image\//),
412
+ data: z4.string().min(1).max(7e6)
413
+ });
414
+ var createRunInputBaseSchema = z4.object({
415
+ workflow: z4.string().min(1).optional(),
416
+ /** An inline chain (spec 008 — an approved plan runs as an ad-hoc workflow, never written to
417
+ * a file). The catalog's own step shape, not a copy of it. */
418
+ steps: z4.array(workflowStepDefSchema).min(1).max(8).optional(),
419
+ task: z4.string().min(1).max(1e5, "must be at most 100000 characters"),
420
+ model: z4.string().optional(),
421
+ runner: runnerSchema.optional(),
422
+ /** 1–3. Above 1 the response is `{ runs }` rather than a single record. */
423
+ variants: z4.number().int().min(1).max(3).optional(),
424
+ /** false → run in the repo working tree instead of an isolated worktree (read-only skills).
425
+ * Omit for the default. Ignored server-side when variants > 1. */
426
+ worktree: z4.boolean().optional(),
427
+ /** true → autonomous run: never parks at "waiting"; auto-continues until done. */
428
+ autonomous: z4.boolean().optional(),
429
+ /** false → keep the handoff journal but do not expose or request a follow-up todos file.
430
+ * Omit for the default (enabled); a server with the capability off pins it to false. */
431
+ generateFollowups: z4.boolean().optional(),
432
+ /** Per-run system-prompt override (R2 2.3) — programmatic callers only. Wins over the
433
+ * config.json default; whitespace-only degrades to absent. */
434
+ systemPrompt: z4.string().trim().max(2e4, "must be at most 20000 characters").optional().transform((s) => s ? s : void 0),
435
+ /** Screenshots pasted into the new-task form; delivered with the first agent step. */
436
+ images: z4.array(imageInputSchema).max(4).optional(),
437
+ /** The inbox entry this task came from (#374). Best-effort bookkeeping: an unknown or
438
+ * already-started id never fails the run. For ×2/×3 the FIRST variant is recorded. */
439
+ todoId: z4.string().min(1).max(200, "must be at most 200 characters").optional()
440
+ });
441
+ var createRunInputSchema = createRunInputBaseSchema.refine(
442
+ (b) => Boolean(b.workflow) !== Boolean(b.steps),
443
+ { message: 'provide either "workflow" or "steps", not both' }
444
+ );
445
+ var messageInputSchema = z4.object({
446
+ text: z4.string().max(1e5).default(""),
447
+ images: z4.array(imageInputSchema).max(4).default([])
448
+ }).refine((m) => m.text.trim().length > 0 || m.images.length > 0, {
449
+ message: "message needs text or at least one image"
450
+ });
451
+ var patchRunInputSchema = z4.object({
452
+ title: z4.string().trim().min(1).max(300).optional(),
453
+ task: z4.string().trim().min(1).max(1e5).optional()
454
+ });
455
+
456
+ // ../contract/src/repo.ts
457
+ import { z as z5 } from "zod";
458
+ var statusEntrySchema = z5.object({
459
+ status: z5.string(),
460
+ path: z5.string()
461
+ });
462
+ var logEntrySchema = z5.object({
463
+ hash: z5.string(),
464
+ subject: z5.string(),
465
+ author: z5.string(),
466
+ when: z5.string()
467
+ });
468
+ var repoResponseSchema = z5.union([
469
+ z5.object({
470
+ info: z5.null(),
471
+ status: z5.array(z5.never()),
472
+ log: z5.array(z5.never()),
473
+ branches: z5.array(z5.never()),
474
+ baseBranch: z5.null()
475
+ }),
476
+ z5.object({
477
+ info: repoInfoSchema,
478
+ status: z5.array(statusEntrySchema),
479
+ log: z5.array(logEntrySchema),
480
+ branches: z5.array(z5.string()),
481
+ baseBranch: z5.string().nullable()
482
+ })
483
+ ]);
484
+ var repoBranchResponseSchema = z5.object({
485
+ branch: z5.string(),
486
+ created: z5.boolean()
487
+ });
488
+ var diffStatSchema2 = z5.object({
489
+ adds: z5.number(),
490
+ dels: z5.number(),
491
+ files: z5.number()
492
+ });
493
+ var changedFileSchema = z5.object({
494
+ path: z5.string(),
495
+ /** Rename/copy source — present only when `status` is renamed/copied. */
496
+ oldPath: z5.string().optional(),
497
+ status: z5.enum(["added", "modified", "deleted", "renamed", "copied"]),
498
+ adds: z5.number(),
499
+ dels: z5.number(),
500
+ /** Binary per numstat — there is no text patch to render. */
501
+ binary: z5.boolean(),
502
+ /** True when the path is one the raw-bytes route serves as an `<img>` (#365) — present only
503
+ * when true, so old clients that never read it stay correct. */
504
+ image: z5.boolean().optional(),
505
+ /** This file's unified-diff section; possibly `… (patch truncated)`, possibly empty. */
506
+ patch: z5.string()
507
+ });
508
+ var changesPayloadSchema = z5.object({
509
+ files: z5.array(changedFileSchema),
510
+ stat: diffStatSchema2,
511
+ /** Additive context for review tasks whose worktree HEAD no longer matches their own branch. */
512
+ repointedHead: z5.object({ headBranch: z5.string(), taskBranch: z5.string() }).optional()
513
+ });
514
+ var repoCommitPayloadSchema = z5.object({
515
+ sha: z5.string(),
516
+ subject: z5.string(),
517
+ author: z5.string(),
518
+ /** Relative time ("3 hours ago") — same `%cr` format as the /api/v1/repo log. */
519
+ when: z5.string(),
520
+ files: z5.array(changedFileSchema),
521
+ stat: diffStatSchema2
522
+ });
523
+ var worktreeDirEntrySchema = z5.object({
524
+ name: z5.string(),
525
+ type: z5.enum(["dir", "file"]),
526
+ size: z5.number().optional()
527
+ });
528
+ var worktreeEntrySchema = z5.discriminatedUnion("type", [
529
+ z5.object({
530
+ type: z5.literal("dir"),
531
+ path: z5.string(),
532
+ entries: z5.array(worktreeDirEntrySchema)
533
+ }),
534
+ z5.object({
535
+ type: z5.literal("file"),
536
+ path: z5.string(),
537
+ size: z5.number(),
538
+ binary: z5.boolean(),
539
+ tooLarge: z5.boolean(),
540
+ content: z5.string().optional()
541
+ })
542
+ ]);
543
+ var worktreeRunStatusSchema = z5.enum([
544
+ "queued",
545
+ "running",
546
+ "waiting",
547
+ "review",
548
+ "done",
549
+ "failed",
550
+ "cancelled"
551
+ ]);
552
+ var worktreeInfoSchema = z5.object({
553
+ runId: z5.string(),
554
+ title: z5.string(),
555
+ status: worktreeRunStatusSchema,
556
+ branch: z5.string().nullable(),
557
+ sizeBytes: z5.number().nullable(),
558
+ finishedAt: z5.string().nullable(),
559
+ reclaimable: z5.boolean()
560
+ });
561
+ var worktreesResponseSchema = z5.object({
562
+ worktrees: z5.array(worktreeInfoSchema),
563
+ totalBytes: z5.number().nullable(),
564
+ keep: z5.number()
565
+ });
566
+ var reclaimWorktreesResponseSchema = z5.object({
567
+ reclaimed: z5.array(z5.string())
568
+ });
569
+
570
+ // ../contract/src/github.ts
571
+ import { z as z6 } from "zod";
572
+ var checksGlyphSchema = z6.enum(["passing", "failing", "pending"]).nullable();
573
+ var githubItemSchema = z6.object({
574
+ kind: z6.enum(["issue", "pr"]),
575
+ number: z6.number(),
576
+ title: z6.string(),
577
+ author: z6.string(),
578
+ createdAt: z6.string(),
579
+ labels: z6.array(z6.string()),
580
+ body: z6.string(),
581
+ url: z6.string(),
582
+ comments: z6.number(),
583
+ /** PRs only. */
584
+ isDraft: z6.boolean().optional(),
585
+ additions: z6.number().optional(),
586
+ deletions: z6.number().optional(),
587
+ checks: checksGlyphSchema.optional()
588
+ });
589
+ var githubDataSchema = z6.object({
590
+ available: z6.boolean(),
591
+ /** Why it is unavailable (`gh` missing, no remote, offline…). Never an error — a hint. */
592
+ reason: z6.string().optional(),
593
+ /** owner/name, when known. */
594
+ repo: z6.string().optional(),
595
+ syncedAt: z6.string().optional(),
596
+ issues: z6.array(githubItemSchema),
597
+ prs: z6.array(githubItemSchema),
598
+ /** Repo-wide label name → 6-hex color (no `#`); lets chips tint like GitHub. Additive. */
599
+ labelColors: z6.record(z6.string(), z6.string()).optional()
600
+ });
601
+ var githubChecksDataSchema = z6.discriminatedUnion("available", [
602
+ z6.object({
603
+ available: z6.literal(true),
604
+ checks: z6.record(z6.number(), checksGlyphSchema)
605
+ }),
606
+ z6.object({
607
+ available: z6.literal(false),
608
+ reason: z6.string()
609
+ })
610
+ ]);
611
+ var githubCommentSchema = z6.object({
612
+ id: z6.number(),
613
+ /** Author login, `'?'` fallback when gh omits the user. */
614
+ author: z6.string(),
615
+ avatarUrl: z6.string().optional(),
616
+ createdAt: z6.string(),
617
+ body: z6.string(),
618
+ kind: z6.enum(["comment", "review"]),
619
+ /** Reviews only — drives the state chip. */
620
+ reviewState: z6.enum(["approved", "changes_requested", "commented", "dismissed"]).optional(),
621
+ url: z6.string()
622
+ });
623
+ var githubTimelineEventKindSchema = z6.enum([
624
+ "committed",
625
+ "labeled",
626
+ "unlabeled",
627
+ "assigned",
628
+ "unassigned",
629
+ "merged",
630
+ "closed",
631
+ "reopened",
632
+ "head_ref_force_pushed",
633
+ "cross-referenced",
634
+ "renamed"
635
+ ]);
636
+ var githubTimelineEventSchema = z6.object({
637
+ id: z6.string(),
638
+ kind: githubTimelineEventKindSchema,
639
+ /** Login — or the git author name for `committed`, which carries no GitHub actor. */
640
+ actor: z6.string(),
641
+ /** Absent for `committed`. */
642
+ avatarUrl: z6.string().optional(),
643
+ createdAt: z6.string(),
644
+ url: z6.string().optional(),
645
+ /** `committed` — full 40-char SHA. */
646
+ sha: z6.string().optional(),
647
+ /** `committed` — first line, capped at 120 chars. */
648
+ message: z6.string().optional(),
649
+ /** `committed` — **absent** (lookup failed/skipped) and **`null`** (no CI configured) both
650
+ * render no glyph, but stay distinct values. */
651
+ checks: checksGlyphSchema.optional(),
652
+ label: z6.object({ name: z6.string(), color: z6.string().optional() }).optional(),
653
+ /** `assigned`/`unassigned` login, or the new title for `renamed`. */
654
+ subject: z6.string().optional(),
655
+ refNumber: z6.number().optional(),
656
+ refTitle: z6.string().optional(),
657
+ refIsPr: z6.boolean().optional()
658
+ });
659
+ var githubCommentsDataSchema = z6.object({
660
+ available: z6.boolean(),
661
+ reason: z6.string().optional(),
662
+ /** Chronological, oldest first. */
663
+ comments: z6.array(githubCommentSchema),
664
+ /** True when either stream hit its cap, or the timeline fetch stopped short. */
665
+ truncated: z6.boolean().optional(),
666
+ /** Timeline events (#525) — additive; absent when the server degraded to the legacy
667
+ * comments-only fetch. Capped independently of `comments`. */
668
+ events: z6.array(githubTimelineEventSchema).optional()
669
+ });
670
+ var githubMergeMethodSchema = z6.enum(["merge", "squash", "rebase"]);
671
+ var githubPrCheckSchema = z6.object({
672
+ name: z6.string(),
673
+ state: z6.enum(["passing", "failing", "pending", "unknown"]),
674
+ required: z6.boolean().nullable(),
675
+ url: z6.string().optional()
676
+ });
677
+ var githubPrMergeStateSchema = z6.object({
678
+ number: z6.number(),
679
+ title: z6.string(),
680
+ url: z6.string(),
681
+ state: z6.enum(["open", "closed", "merged"]),
682
+ isDraft: z6.boolean(),
683
+ headRef: z6.string(),
684
+ baseRef: z6.string(),
685
+ headSha: z6.string(),
686
+ mergeable: z6.enum(["mergeable", "conflicting", "unknown"]),
687
+ reviewDecision: z6.enum(["approved", "changes-requested", "review-required", "unknown"]),
688
+ checks: z6.array(githubPrCheckSchema),
689
+ methods: z6.array(githubMergeMethodSchema),
690
+ defaultMethod: githubMergeMethodSchema.nullable(),
691
+ eligibility: z6.enum(["ready", "blocked", "pending", "unauthorized", "terminal", "unknown"]),
692
+ blockers: z6.array(z6.object({ code: z6.string(), message: z6.string() })),
693
+ canMerge: z6.boolean(),
694
+ canOverride: z6.boolean()
695
+ });
696
+ var githubPrMergeStateResponseSchema = z6.discriminatedUnion("available", [
697
+ z6.object({ available: z6.literal(true), mergeState: githubPrMergeStateSchema }),
698
+ z6.object({ available: z6.literal(false), reason: z6.string() })
699
+ ]);
700
+ var githubMergeResponseSchema = z6.object({
701
+ merged: z6.literal(true),
702
+ number: z6.number(),
703
+ url: z6.string(),
704
+ method: githubMergeMethodSchema,
705
+ mergeCommitSha: z6.string().optional()
706
+ });
707
+ var githubPrChangeSchema = z6.object({
708
+ path: z6.string(),
709
+ previousPath: z6.string().optional(),
710
+ status: z6.enum(["added", "modified", "removed", "renamed", "copied", "changed"]),
711
+ additions: z6.number(),
712
+ deletions: z6.number(),
713
+ patch: z6.string().optional(),
714
+ patchUnavailableReason: z6.enum(["binary", "too-large", "not-provided"]).optional(),
715
+ truncated: z6.boolean().optional()
716
+ });
717
+ var githubPrChangesDataSchema = z6.discriminatedUnion("available", [
718
+ z6.object({
719
+ available: z6.literal(true),
720
+ number: z6.number(),
721
+ headSha: z6.string(),
722
+ files: z6.array(githubPrChangeSchema),
723
+ additions: z6.number(),
724
+ deletions: z6.number(),
725
+ truncated: z6.boolean(),
726
+ /** Present when the payload is complete but partial in some other way (a capped patch). */
727
+ reason: z6.string().optional()
728
+ }),
729
+ z6.object({ available: z6.literal(false), reason: z6.string() })
730
+ ]);
731
+
732
+ // ../contract/src/projects.ts
733
+ import { z as z7 } from "zod";
734
+ var projectListEntrySchema = z7.object({
735
+ id: z7.string(),
736
+ name: z7.string(),
737
+ /** Absolute, realpath-normalized repo root. */
738
+ root: z7.string(),
739
+ addedAt: z7.string(),
740
+ lastOpenedAt: z7.string(),
741
+ source: z7.enum(["local", "checkout"]),
742
+ /** `not-git` is fully usable (degraded single-queue mode); only `missing` blocks. */
743
+ status: z7.enum(["ok", "missing", "not-git"]),
744
+ /** Current branch when cheaply available (omitted e.g. on an unborn HEAD). */
745
+ branch: z7.string().optional(),
746
+ /** Which forge this project's remote belongs to (#698) — classified server-side from the
747
+ * remote URL alone. Gates the project group's GitHub nav item; omitted = no forge remote. */
748
+ forge: z7.literal("github").optional(),
749
+ /** Per-project cap on concurrently running tasks (spec 2026-07-22). Omitted = inherit the
750
+ * workspace `resources.maxParallel`; a number pins this project. */
751
+ maxParallel: z7.number().optional()
752
+ });
753
+ var projectsResponseSchema = z7.object({
754
+ projects: z7.array(projectListEntrySchema),
755
+ bootProject: z7.string(),
756
+ projectsDir: z7.string()
757
+ });
758
+ var registerProjectResponseSchema = z7.object({
759
+ project: projectListEntrySchema,
760
+ error: z7.string().optional()
761
+ });
762
+ var removeProjectResponseSchema = z7.object({
763
+ removed: z7.literal(true),
764
+ id: z7.string()
765
+ });
766
+ var updateProjectResponseSchema = z7.object({
767
+ project: projectListEntrySchema
768
+ });
769
+ var updateProjectInputSchema = z7.object({
770
+ maxParallel: z7.number().int().min(1).max(16).nullable()
771
+ });
772
+ var checkoutProjectInputSchema = z7.object({
773
+ url: z7.string().trim().min(1).max(512),
774
+ name: z7.string().trim().max(128).optional(),
775
+ checkoutId: z7.string().trim().max(128).optional()
776
+ });
777
+ var fsBrowseDirSchema = z7.object({
778
+ name: z7.string(),
779
+ path: z7.string(),
780
+ /** Has a `.git` entry — drives the "git" badge. A non-repo folder is still selectable. */
781
+ isRepo: z7.boolean()
782
+ });
783
+ var fsBrowseResponseSchema = z7.object({
784
+ /** The realpath'd directory actually listed — never the spelling asked for, so the breadcrumb
785
+ * shows where the picker really is. */
786
+ path: z7.string(),
787
+ /** `null` AT the browse root: there is no "up" out of it, and the dialog must render no parent
788
+ * row rather than one that 400s. */
789
+ parent: z7.string().nullable(),
790
+ dirs: z7.array(fsBrowseDirSchema),
791
+ /** True when the listing was capped server-side — surfaced honestly instead of showing a
792
+ * silently short list. */
793
+ truncated: z7.boolean()
794
+ });
795
+ var launchKeyResponseSchema = z7.object({
796
+ key: z7.string()
797
+ });
798
+
799
+ // ../contract/src/workspace.ts
800
+ import { z as z8 } from "zod";
801
+ var workspaceConfigResponseSchema = z8.object({
802
+ /** Root exposed by the Add-project directory browser — stored as written (`~` kept). */
803
+ browseRoot: z8.string(),
804
+ /** Checkout root for GUI-cloned projects — stored as written (`~` kept). */
805
+ projectsDir: z8.string(),
806
+ /** Stored override; `null` means inherit `CEZ_SKILLS_AUTO_UPDATE`, then true. */
807
+ skillsAutoUpdate: z8.boolean().nullable(),
808
+ effectiveSkillsAutoUpdate: z8.boolean(),
809
+ composerDefaults: z8.object({
810
+ autonomous: z8.boolean().nullable(),
811
+ worktree: z8.boolean().nullable(),
812
+ /** `'source-dependent'` when no `CEZ_AUTONOMOUS_DEFAULT` pins it either way. */
813
+ inheritedAutonomous: z8.union([z8.boolean(), z8.literal("source-dependent")]),
814
+ inheritedWorktree: z8.boolean()
815
+ }),
816
+ resources: z8.object({
817
+ maxParallel: z8.number(),
818
+ maxMonitoringSessions: z8.number(),
819
+ monitoringWakeIntervalMinutes: z8.number().nullable(),
820
+ memoryLimitMb: z8.number().nullable(),
821
+ worktreeRetentionDefault: z8.number()
822
+ })
823
+ });
824
+ var setWorkspaceConfigInputSchema = z8.object({
825
+ browseRoot: z8.string().trim().min(1).max(4096).optional(),
826
+ projectsDir: z8.string().trim().min(1).max(4096).optional(),
827
+ skillsAutoUpdate: z8.boolean().nullable().optional(),
828
+ composerDefaults: z8.object({
829
+ autonomous: z8.boolean().nullable().optional(),
830
+ worktree: z8.boolean().nullable().optional()
831
+ }).optional(),
832
+ resources: z8.object({
833
+ maxParallel: z8.number().int().min(1).max(16).optional(),
834
+ maxMonitoringSessions: z8.number().int().min(0).max(16).optional(),
835
+ monitoringWakeIntervalMinutes: z8.number().int().min(1).max(60).nullable().optional(),
836
+ memoryLimitMb: z8.number().int().min(0).max(1048576).nullable().optional(),
837
+ worktreeRetentionDefault: z8.number().int().min(0).max(1e3).optional()
838
+ }).optional()
839
+ });
840
+ var appearanceSchema = z8.object({
841
+ accent: z8.enum(["lime", "violet"]).optional(),
842
+ density: z8.enum(["comfortable", "compact", "ultra"]).optional()
843
+ });
844
+ var uiStateSchema = z8.looseObject({
845
+ lastTask: z8.object({ source: z8.enum(["workflow", "skill"]), ref: z8.string() }).optional(),
846
+ /** Most-recently-run sources, newest first (deduped, capped). Feeds the composer picker's
847
+ * recency sort. */
848
+ recentSources: z8.array(z8.object({ source: z8.enum(["workflow", "skill"]), ref: z8.string() })).optional(),
849
+ /** The last worktree choice for a single-skill run. Absent → the default (isolated worktree). */
850
+ lastWorktree: z8.boolean().optional(),
851
+ /** The last autonomous choice — remembered like `lastWorktree`. Absent → off. */
852
+ lastAutonomous: z8.boolean().optional(),
853
+ /** Whether new runs should ask agents to append follow-up work. Absent → on. */
854
+ lastGenerateFollowups: z8.boolean().optional(),
855
+ /** Skill selection frequency (#408): name → times chosen, across BOTH composers. */
856
+ skillUsage: z8.record(z8.string(), z8.number()).optional(),
857
+ runsView: z8.enum(["list", "table"]).optional(),
858
+ /** The GitHub tab's last-selected sub-tab (#417). Absent → issues. */
859
+ githubView: z8.enum(["issues", "prs"]).optional(),
860
+ /** Settings → Appearance. The theme itself stays in localStorage (`cez-theme`) — it must
861
+ * pre-paint, and it is per-browser by design. */
862
+ appearance: appearanceSchema.optional(),
863
+ /** Follow-up prompt templates (#413). Absent → the built-in defaults; present (even `[]`) is
864
+ * the user's own edited list. `skills` are the skill names the template auto-applies for. */
865
+ promptTemplates: z8.array(
866
+ z8.object({
867
+ id: z8.string(),
868
+ label: z8.string(),
869
+ text: z8.string(),
870
+ skills: z8.array(z8.string()).optional()
871
+ })
872
+ ).optional(),
873
+ /** The open-mercato/skills promo banner (#391), dismissed for good. Legacy — the banner is
874
+ * gone, replaced by `WorkspaceUiState.importedSkills`; retained so old files round-trip. */
875
+ dismissedSkillsBanner: z8.boolean().optional()
876
+ });
877
+ var workspaceLastLocationSchema = z8.strictObject({
878
+ projectId: z8.string().min(1).max(64),
879
+ pathname: z8.string().min(1).max(2048).startsWith("/p/"),
880
+ search: z8.string().max(4096).startsWith("?").optional(),
881
+ hash: z8.string().max(2048).startsWith("#").optional()
882
+ });
883
+ var workspaceUiStateSchema = z8.looseObject({
884
+ /** The sidebar's per-project collapse map (step 3.3) — `true` collapses a group, `false` pins
885
+ * it open, absent means the default (the active project expands, the rest collapse). Loose for
886
+ * the same round-trip reason as its parent. */
887
+ sidebar: z8.looseObject({ collapsed: z8.record(z8.string(), z8.boolean()).optional() }).optional(),
888
+ /** Dismissed runtime-auth incident IDs, keyed by provider. An ID is only dismissed until the
889
+ * provider reports a different incident, so this stays workspace-global with the browser
890
+ * rather than one project checkout. */
891
+ dismissedProviderAuthFailures: z8.object({
892
+ claude: z8.string().optional(),
893
+ codex: z8.string().optional(),
894
+ opencode: z8.string().optional()
895
+ }).optional(),
896
+ /** Settings → Appearance, GLOBAL since step 3.5: accent + density describe the person at the
897
+ * keyboard, not a repo. */
898
+ appearance: appearanceSchema.optional(),
899
+ /** Settings → Notifications, GLOBAL since step 3.5 — one answer for the whole workspace, since
900
+ * the delivering browser is one browser whichever project you are looking at. */
901
+ notifications: z8.looseObject({ enabled: z8.boolean().optional() }).optional(),
902
+ /** Last settled project-scoped page. Used only when entering at the exact bare root;
903
+ * explicit deep links always win. */
904
+ lastLocation: workspaceLastLocationSchema.optional(),
905
+ /** The user's curated selection of default (vendor) skills. Tri-state: ABSENT means "not
906
+ * curated", so every default skill shows; a PRESENT array (even `[]`) means only those names
907
+ * show from that repo. */
908
+ importedSkills: z8.array(z8.string()).optional()
909
+ });
910
+ var runnerModelsSchema = z8.object({
911
+ claude: z8.string().optional(),
912
+ codex: z8.string().optional(),
913
+ opencode: z8.string().optional()
914
+ });
915
+ var configResponseSchema = z8.object({
916
+ baseBranch: z8.string().nullable(),
917
+ defaultRunner: runnerSchema,
918
+ systemPrompt: z8.string().nullable(),
919
+ defaultModels: runnerModelsSchema,
920
+ /** How many tasks run at once (1–16). */
921
+ maxParallel: z8.number(),
922
+ /** Per-task memory ceiling in MiB (whole process tree); null = no limit. */
923
+ memoryLimitMb: z8.number().nullable(),
924
+ /** Keep the last N finished worktrees on disk (#483); 0 = unlimited. Older ones are reclaimed
925
+ * (directory only — branch kept, so work is recoverable). */
926
+ worktreeRetention: z8.number(),
927
+ /** Live title updates: null = no config key, the `CEZ_TITLE_UPDATES` env default (ON) decides. */
928
+ liveTitleUpdates: z8.boolean().nullable(),
929
+ /** Optional review gate (#489): null = no config key, the `CEZ_REVIEW_GATE` env default (OFF)
930
+ * decides. */
931
+ reviewGate: z8.boolean().nullable()
932
+ });
933
+ var setConfigResponseSchema = configResponseSchema;
934
+ var setConfigInputSchema = z8.object({
935
+ baseBranch: z8.string().trim().min(1).max(200).nullable().optional(),
936
+ defaultRunner: runnerSchema.optional(),
937
+ systemPrompt: z8.string().trim().max(2e4).nullable().optional(),
938
+ defaultModels: z8.object({
939
+ claude: z8.string().trim().max(200).nullable().optional(),
940
+ codex: z8.string().trim().max(200).nullable().optional(),
941
+ opencode: z8.string().trim().max(200).nullable().optional()
942
+ }).optional(),
943
+ maxParallel: z8.number().int().min(1).max(16).optional(),
944
+ /** null or 0 clears the ceiling back to "no limit". */
945
+ memoryLimitMb: z8.number().int().min(0).max(1048576).nullable().optional(),
946
+ /** Keep last N finished worktrees (#483); 0 = unlimited, null clears back to the default (10). */
947
+ worktreeRetention: z8.number().int().min(0).max(1e3).nullable().optional(),
948
+ /** null clears the key back to the env-default behavior. */
949
+ liveTitleUpdates: z8.boolean().nullable().optional(),
950
+ /** null clears the key back to the env-default behavior (OFF). */
951
+ reviewGate: z8.boolean().nullable().optional()
952
+ });
953
+ var skillsUpdateStatusSchema = z8.enum([
954
+ "idle",
955
+ "checking",
956
+ "available",
957
+ "updating",
958
+ "current",
959
+ "unavailable",
960
+ "error"
961
+ ]);
962
+ var skillsUpdateScopeStateSchema = z8.object({
963
+ scope: z8.enum(["project", "global"]),
964
+ status: skillsUpdateStatusSchema,
965
+ available: z8.boolean(),
966
+ skills: z8.array(z8.string()),
967
+ checkedAt: z8.string().nullable(),
968
+ updatedAt: z8.string().nullable(),
969
+ reason: z8.string().optional()
970
+ });
971
+ var skillsUpdateStateSchema = z8.object({
972
+ status: skillsUpdateStatusSchema,
973
+ available: z8.boolean(),
974
+ autoUpdateEnabled: z8.boolean(),
975
+ inherited: z8.boolean(),
976
+ checkedAt: z8.string().nullable(),
977
+ updatedAt: z8.string().nullable(),
978
+ scopes: z8.array(skillsUpdateScopeStateSchema),
979
+ needsUpgradeNotes: z8.boolean()
980
+ });
981
+ var providerIdSchema = runnerSchema;
982
+ var providerConnectionStateSchema = z8.enum([
983
+ "connected",
984
+ "disconnected",
985
+ "not-installed",
986
+ "unknown"
987
+ ]);
988
+ var providerStatusSchema = z8.object({
989
+ provider: providerIdSchema,
990
+ status: providerConnectionStateSchema,
991
+ enabled: z8.boolean().optional(),
992
+ hint: z8.string().optional(),
993
+ authFailureId: z8.string().optional()
994
+ });
995
+ var providerStatusResponseSchema = z8.object({
996
+ providers: z8.array(providerStatusSchema)
997
+ });
998
+ var providerConnectResponseSchema = z8.discriminatedUnion("opened", [
999
+ z8.object({ opened: z8.literal(true), command: z8.string() }),
1000
+ z8.object({ opened: z8.literal(false), connected: z8.literal(true), command: z8.string() })
1001
+ ]);
1002
+ var runnerModelOptionSchema = z8.object({
1003
+ id: z8.string(),
1004
+ label: z8.string(),
1005
+ description: z8.string()
1006
+ });
1007
+ var runnerModelCatalogResponseSchema = z8.object({
1008
+ runner: runnerSchema,
1009
+ models: z8.array(runnerModelOptionSchema),
1010
+ source: z8.enum(["live", "cache", "unavailable"]),
1011
+ stale: z8.boolean(),
1012
+ reason: z8.string().optional()
1013
+ });
1014
+ var openTargetSchema = z8.object({
1015
+ id: z8.string(),
1016
+ label: z8.string(),
1017
+ /** A stable icon key (#361) the UI maps to a concrete icon. Optional: an older server omitting
1018
+ * it just renders the generic fallback icon. */
1019
+ icon: z8.string().optional()
1020
+ });
1021
+ var openTargetsResponseSchema = z8.object({
1022
+ targets: z8.array(openTargetSchema)
1023
+ });
1024
+
1025
+ // ../contract/src/skills.ts
1026
+ import { z as z9 } from "zod";
1027
+ var skillSchema = z9.object({
1028
+ name: z9.string(),
1029
+ description: z9.string().optional(),
1030
+ /** Advisory hint for untouched composer run-mode choices. */
1031
+ interactive: z9.literal(true).optional(),
1032
+ body: z9.string(),
1033
+ path: z9.string(),
1034
+ source: z9.enum(["ai", "cezar", "agents", "global", "team"]),
1035
+ /** Team skills only: where the definition lives in its skills repo. */
1036
+ team: z9.object({
1037
+ repo: z9.string(),
1038
+ ref: z9.string(),
1039
+ path: z9.string(),
1040
+ /** True for the `SKILL.md` convention — a whole directory (references/…). */
1041
+ dir: z9.boolean(),
1042
+ /**
1043
+ * The exact commit `ref` resolved to when the skill was read (#428).
1044
+ *
1045
+ * The hand-written DTO omitted this field entirely — it was NARROWER than the route,
1046
+ * which has served it since #428.
1047
+ */
1048
+ commit: z9.string().optional()
1049
+ }).optional()
1050
+ });
1051
+ var importableSkillSchema = z9.object({
1052
+ name: z9.string(),
1053
+ description: z9.string().optional()
1054
+ });
1055
+ var todoItemSchema = z9.object({
1056
+ id: z9.string(),
1057
+ ts: z9.string().optional(),
1058
+ taskId: z9.string().optional(),
1059
+ summary: z9.string().min(1),
1060
+ action: z9.string().optional(),
1061
+ prUrl: z9.string().optional(),
1062
+ suggestedSkill: z9.string().optional(),
1063
+ suggestedArgs: z9.string().optional(),
1064
+ suggestedPrompt: z9.string().optional(),
1065
+ /** Explicit intent; missing infers from suggestedSkill/suggestedPrompt for old files. */
1066
+ runnable: z9.boolean().optional(),
1067
+ /** Set once a task was started from this entry — it then leaves the inbox and stays as
1068
+ * the audit trail. A later launch never overwrites the first. */
1069
+ startedTaskId: z9.string().optional()
1070
+ });
1071
+ var removeTodoResponseSchema = z9.object({
1072
+ removed: z9.literal(true)
1073
+ });
1074
+ var startTodoResponseSchema = z9.object({
1075
+ run: runRecordSchema
1076
+ });
1077
+
1078
+ // ../contract/src/agent-config.ts
1079
+ import { z as z10 } from "zod";
1080
+ var agentConfigFormatSchema = z10.enum(["json", "jsonc", "toml", "markdown"]);
1081
+ var agentConfigScopeSchema = z10.enum(["user", "project", "local"]);
1082
+ var agentConfigKindSchema = z10.enum(["settings", "memory", "mcp"]);
1083
+ var agentConfigTrackedSchema = z10.enum(["tracked", "gitignored", "outside-repo"]);
1084
+ var agentConfigFileSchema = z10.object({
1085
+ /** Stable, opaque, URL-safe — the ONLY thing a client may name (traversal-proof). */
1086
+ id: z10.string(),
1087
+ /** Every runner that reads this file: `<repo>/AGENTS.md` is one file, two readers. */
1088
+ runners: z10.array(runnerSchema),
1089
+ kind: agentConfigKindSchema,
1090
+ scope: agentConfigScopeSchema,
1091
+ label: z10.string(),
1092
+ path: z10.string(),
1093
+ format: agentConfigFormatSchema,
1094
+ tracked: agentConfigTrackedSchema,
1095
+ seeded: z10.boolean(),
1096
+ holdsMcp: z10.boolean(),
1097
+ /** VERBATIM from the vendor docs. Never computed, never generic. */
1098
+ precedence: z10.string(),
1099
+ /** Documented mid-run reload behaviour, or absent when the vendor is silent. */
1100
+ hotReload: z10.string().optional(),
1101
+ docsUrl: z10.string(),
1102
+ exists: z10.boolean(),
1103
+ size: z10.number(),
1104
+ /** sha256 of the bytes, or null when absent. */
1105
+ version: z10.string().nullable(),
1106
+ /** False in hosted mode (whole feature) — the client renders read-only up front. */
1107
+ writable: z10.boolean(),
1108
+ readOnlyReason: z10.string().optional()
1109
+ });
1110
+ var userMcpListingSchema = z10.object({
1111
+ path: z10.string(),
1112
+ servers: z10.array(z10.string()),
1113
+ readable: z10.boolean()
1114
+ });
1115
+ var agentConfigListingSchema = z10.object({
1116
+ editable: z10.boolean(),
1117
+ files: z10.array(agentConfigFileSchema),
1118
+ /** null in hosted mode (host-state disclosure guard). */
1119
+ userMcp: userMcpListingSchema.nullable()
1120
+ });
1121
+ var agentConfigFileContentSchema = z10.object({
1122
+ id: z10.string(),
1123
+ path: z10.string(),
1124
+ exists: z10.boolean(),
1125
+ content: z10.string(),
1126
+ /** sha256 of the bytes, or null when the file does not exist yet. */
1127
+ version: z10.string().nullable()
1128
+ });
1129
+ var setAgentConfigInputSchema = z10.object({
1130
+ content: z10.string().max(2e6),
1131
+ version: z10.string().nullable()
1132
+ });
1133
+
1134
+ // ../contract/src/automations.ts
1135
+ import { z as z11 } from "zod";
1136
+ var automationEventSchema = z11.enum([
1137
+ "pull_request.opened",
1138
+ "issue.opened",
1139
+ "issue.labeled",
1140
+ "issue.unlabeled"
1141
+ ]);
1142
+ var automationFiltersSchema = z11.object({
1143
+ authors: z11.array(z11.string()).optional(),
1144
+ assignees: z11.array(z11.string()).optional(),
1145
+ allLabels: z11.array(z11.string()).optional(),
1146
+ anyLabels: z11.array(z11.string()).optional(),
1147
+ excludeLabels: z11.array(z11.string()).optional(),
1148
+ /** Required for the two label events — the server rejects a definition without it. */
1149
+ changedLabels: z11.array(z11.string()).optional(),
1150
+ lookbackDays: z11.number(),
1151
+ maxRecords: z11.number()
1152
+ });
1153
+ var automationTaskSchema = createRunInputBaseSchema.omit({ task: true, images: true, todoId: true, systemPrompt: true }).extend({
1154
+ /** The prompt template. `{{github.number}}`, `{{github.title}}`, `{{github.url}}` and
1155
+ * `{{github.labels}}` are substituted per match; GitHub content is appended as untrusted
1156
+ * context, never interpolated into instructions. */
1157
+ prompt: z11.string(),
1158
+ variants: z11.union([z11.literal(1), z11.literal(2), z11.literal(3)]).optional(),
1159
+ systemPrompt: z11.string().optional()
1160
+ });
1161
+ var automationDefinitionSchema = z11.object({
1162
+ id: z11.string(),
1163
+ /** Bumped on every edit; a PUT must echo the revision it read (optimistic concurrency). */
1164
+ revision: z11.number(),
1165
+ name: z11.string(),
1166
+ description: z11.string().optional(),
1167
+ /** Always present: the storage schema defaults it to `false`, so a definition is created
1168
+ * PAUSED and enabling it is a separate, baseline-establishing act. */
1169
+ enabled: z11.boolean(),
1170
+ events: z11.array(automationEventSchema),
1171
+ intervalSeconds: z11.number(),
1172
+ filters: automationFiltersSchema,
1173
+ task: automationTaskSchema,
1174
+ createdAt: z11.string(),
1175
+ updatedAt: z11.string()
1176
+ });
1177
+ var automationCursorSchema = z11.object({
1178
+ timestamp: z11.string(),
1179
+ tieBreaker: z11.string().optional()
1180
+ });
1181
+ var automationRuntimeStateSchema = z11.object({
1182
+ /** The definition revision this state belongs to; a bumped revision re-baselines. */
1183
+ revision: z11.number().optional(),
1184
+ /** Enabling establishes a CURRENT-TIME baseline: records older than this never launch. */
1185
+ baselineAt: z11.string().optional(),
1186
+ cursor: automationCursorSchema.optional(),
1187
+ frozenHighWatermark: automationCursorSchema.extend({ tieBreaker: z11.string() }).optional(),
1188
+ backlogAfter: automationCursorSchema.extend({ tieBreaker: z11.string() }).optional(),
1189
+ nextCheckAt: z11.string().optional(),
1190
+ lastSuccessAt: z11.string().optional(),
1191
+ /** Per-query GitHub ETags, so an unchanged page costs no rate-limit budget. */
1192
+ etags: z11.record(z11.string(), z11.string()).optional(),
1193
+ backoffUntil: z11.string().optional(),
1194
+ consecutiveFailures: z11.number().optional()
1195
+ });
1196
+ var automationLogResultSchema = z11.enum([
1197
+ "launched",
1198
+ "no-match",
1199
+ "duplicate",
1200
+ "rate-limited",
1201
+ "error",
1202
+ "baseline",
1203
+ "preview"
1204
+ ]);
1205
+ var automationLogRecordSchema = z11.object({
1206
+ seq: z11.number(),
1207
+ ts: z11.string(),
1208
+ automationId: z11.string(),
1209
+ revision: z11.number(),
1210
+ event: automationEventSchema.optional(),
1211
+ result: automationLogResultSchema,
1212
+ reason: z11.string().optional(),
1213
+ durationMs: z11.number().optional(),
1214
+ receiptId: z11.string().optional(),
1215
+ runId: z11.string().optional(),
1216
+ githubNumber: z11.number().optional(),
1217
+ githubTitle: z11.string().optional(),
1218
+ githubUrl: z11.string().optional(),
1219
+ rateLimit: z11.object({
1220
+ bucket: z11.enum(["core", "search"]),
1221
+ remaining: z11.number().optional(),
1222
+ resetAt: z11.string().optional()
1223
+ }).optional()
1224
+ });
1225
+ var automationCountsSchema = z11.object({
1226
+ matches: z11.number(),
1227
+ launched: z11.number(),
1228
+ duplicates: z11.number(),
1229
+ errors: z11.number()
1230
+ });
1231
+ var automationListEntrySchema = automationDefinitionSchema.extend({
1232
+ state: automationRuntimeStateSchema.optional(),
1233
+ latestLog: automationLogRecordSchema.optional(),
1234
+ counts: automationCountsSchema
1235
+ });
1236
+ var automationsResponseSchema = z11.object({
1237
+ available: z11.boolean(),
1238
+ reason: z11.string().optional(),
1239
+ scheduler: z11.object({
1240
+ state: z11.enum(["scheduled", "idle"]),
1241
+ nextDue: z11.string().optional()
1242
+ }),
1243
+ automations: z11.array(automationListEntrySchema)
1244
+ });
1245
+ var automationResponseSchema = z11.object({ automation: automationDefinitionSchema });
1246
+ var automationDetailResponseSchema = z11.object({
1247
+ automation: automationDefinitionSchema,
1248
+ state: automationRuntimeStateSchema.optional(),
1249
+ latestLog: automationLogRecordSchema.optional()
1250
+ });
1251
+ var automationCheckSchema = z11.object({
1252
+ id: z11.string(),
1253
+ automationId: z11.string(),
1254
+ mode: z11.enum(["preview", "execute"]),
1255
+ status: z11.enum(["queued", "running", "complete", "error"]),
1256
+ createdAt: z11.string(),
1257
+ completedAt: z11.string().optional(),
1258
+ matches: z11.number().optional(),
1259
+ truncated: z11.boolean().optional(),
1260
+ error: z11.string().optional()
1261
+ });
1262
+ var automationCheckQueuedResponseSchema = z11.object({ checkId: z11.string() });
1263
+ var automationLogResponseSchema = z11.object({
1264
+ records: z11.array(automationLogRecordSchema)
1265
+ });
1266
+ var automationRetryResponseSchema = z11.object({
1267
+ receiptId: z11.string(),
1268
+ runId: z11.string()
1269
+ });
1270
+ var createAutomationInputSchema = automationDefinitionSchema.omit({ id: true, revision: true, createdAt: true, updatedAt: true, enabled: true }).extend({ enable: z11.boolean().optional() });
1271
+ var updateAutomationInputSchema = createAutomationInputSchema.omit({ enable: true }).extend({
1272
+ enabled: z11.boolean().optional(),
1273
+ expectedRevision: z11.number()
1274
+ });
1275
+ var automationCheckInputSchema = z11.object({
1276
+ mode: z11.enum(["preview", "execute"])
1277
+ });
1278
+ export {
1279
+ agentConfigFileContentSchema,
1280
+ agentConfigFileSchema,
1281
+ agentConfigFormatSchema,
1282
+ agentConfigKindSchema,
1283
+ agentConfigListingSchema,
1284
+ agentConfigScopeSchema,
1285
+ agentConfigTrackedSchema,
1286
+ apiRunSchema,
1287
+ archiveFinishedResponseSchema,
1288
+ automationCheckInputSchema,
1289
+ automationCheckQueuedResponseSchema,
1290
+ automationCheckSchema,
1291
+ automationCountsSchema,
1292
+ automationCursorSchema,
1293
+ automationDefinitionSchema,
1294
+ automationDetailResponseSchema,
1295
+ automationEventSchema,
1296
+ automationFiltersSchema,
1297
+ automationListEntrySchema,
1298
+ automationLogRecordSchema,
1299
+ automationLogResponseSchema,
1300
+ automationLogResultSchema,
1301
+ automationResponseSchema,
1302
+ automationRetryResponseSchema,
1303
+ automationRuntimeStateSchema,
1304
+ automationTaskSchema,
1305
+ automationsResponseSchema,
1306
+ backendCheckSchema,
1307
+ cancelResponseSchema,
1308
+ capabilitiesSchema,
1309
+ changedFileSchema,
1310
+ changesPayloadSchema,
1311
+ checkoutProgressEventSchema,
1312
+ checkoutProjectInputSchema,
1313
+ configResponseSchema,
1314
+ continueResponseSchema,
1315
+ createAutomationInputSchema,
1316
+ createPrResponseSchema,
1317
+ createRunInputBaseSchema,
1318
+ createRunInputSchema,
1319
+ createRunResponseSchema,
1320
+ deleteRunResponseSchema,
1321
+ deleteWorkflowResponseSchema,
1322
+ diffStatSchema,
1323
+ editQueuedMessageResponseSchema,
1324
+ finishResponseSchema,
1325
+ forgeInfoSchema,
1326
+ fsBrowseDirSchema,
1327
+ fsBrowseResponseSchema,
1328
+ gitCommitResponseSchema,
1329
+ gitPushResponseSchema,
1330
+ githubChecksDataSchema,
1331
+ githubCommentSchema,
1332
+ githubCommentsDataSchema,
1333
+ githubDataSchema,
1334
+ githubItemSchema,
1335
+ githubMergeMethodSchema,
1336
+ githubMergeResponseSchema,
1337
+ githubPrChangeSchema,
1338
+ githubPrChangesDataSchema,
1339
+ githubPrCheckSchema,
1340
+ githubPrMergeStateResponseSchema,
1341
+ githubPrMergeStateSchema,
1342
+ githubTimelineEventKindSchema,
1343
+ githubTimelineEventSchema,
1344
+ groupResponseSchema,
1345
+ groupVariantSchema,
1346
+ healthResponseSchema,
1347
+ imageInputSchema,
1348
+ importableSkillSchema,
1349
+ launchKeyResponseSchema,
1350
+ logEntrySchema,
1351
+ markAllReadResponseSchema,
1352
+ messageInputSchema,
1353
+ messageResponseSchema,
1354
+ openInCliResponseSchema,
1355
+ openTargetSchema,
1356
+ openTargetsResponseSchema,
1357
+ parsedWorkflowSchema,
1358
+ patchRunInputSchema,
1359
+ pickVariantResponseSchema,
1360
+ planResponseSchema,
1361
+ processUsageSchema,
1362
+ projectListEntrySchema,
1363
+ projectsResponseSchema,
1364
+ providerConnectResponseSchema,
1365
+ providerConnectionStateSchema,
1366
+ providerIdSchema,
1367
+ providerStatusResponseSchema,
1368
+ providerStatusSchema,
1369
+ queuedMessageSchema,
1370
+ reclaimWorktreesResponseSchema,
1371
+ registerProjectResponseSchema,
1372
+ removeProjectResponseSchema,
1373
+ removeQueuedMessageResponseSchema,
1374
+ removeTodoResponseSchema,
1375
+ removeWorktreeResponseSchema,
1376
+ repoBranchResponseSchema,
1377
+ repoCommitPayloadSchema,
1378
+ repoInfoSchema,
1379
+ repoResponseSchema,
1380
+ runActivitySchema,
1381
+ runCommitSchema,
1382
+ runCommitsResponseSchema,
1383
+ runEventSchema,
1384
+ runRecordSchema,
1385
+ runStatusSchema,
1386
+ runnerModelCatalogResponseSchema,
1387
+ runnerModelOptionSchema,
1388
+ runnerModelsSchema,
1389
+ runnerSchema,
1390
+ saveWorkflowInputSchema,
1391
+ saveWorkflowResponseSchema,
1392
+ setAgentConfigInputSchema,
1393
+ setConfigInputSchema,
1394
+ setConfigResponseSchema,
1395
+ setWorkspaceConfigInputSchema,
1396
+ skillSchema,
1397
+ skillsUpdateScopeStateSchema,
1398
+ skillsUpdateStateSchema,
1399
+ skillsUpdateStatusSchema,
1400
+ startTodoResponseSchema,
1401
+ statusEntrySchema,
1402
+ stepStateSchema,
1403
+ stepStatusSchema,
1404
+ todoItemSchema,
1405
+ uiStateSchema,
1406
+ updateAutomationInputSchema,
1407
+ updateProjectInputSchema,
1408
+ updateProjectResponseSchema,
1409
+ userMcpListingSchema,
1410
+ workflowDefSchema,
1411
+ workflowLoadIssueSchema,
1412
+ workflowStepDefSchema,
1413
+ workflowsResponseSchema,
1414
+ workspaceConfigResponseSchema,
1415
+ workspaceLastLocationSchema,
1416
+ workspaceUiStateSchema,
1417
+ worktreeDirEntrySchema,
1418
+ worktreeEntrySchema,
1419
+ worktreeInfoSchema,
1420
+ worktreesResponseSchema
1421
+ };