@wjarka/cezarion 0.14.8 → 0.14.9-dev.1004

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 (274) hide show
  1. package/README.md +129 -2
  2. package/dist/application-update/bin-recovery.d.ts +5 -0
  3. package/dist/application-update/bin-recovery.js +96 -0
  4. package/dist/application-update/bin-recovery.js.map +1 -0
  5. package/dist/application-update/discovery.d.ts +22 -0
  6. package/dist/application-update/discovery.js +91 -0
  7. package/dist/application-update/discovery.js.map +1 -0
  8. package/dist/application-update/helper.d.ts +57 -0
  9. package/dist/application-update/helper.js +374 -0
  10. package/dist/application-update/helper.js.map +1 -0
  11. package/dist/application-update/launcher.d.ts +8 -0
  12. package/dist/application-update/launcher.js +53 -0
  13. package/dist/application-update/launcher.js.map +1 -0
  14. package/dist/application-update/lock.d.ts +4 -0
  15. package/dist/application-update/lock.js +70 -0
  16. package/dist/application-update/lock.js.map +1 -0
  17. package/dist/application-update/npm-process.d.ts +17 -0
  18. package/dist/application-update/npm-process.js +133 -0
  19. package/dist/application-update/npm-process.js.map +1 -0
  20. package/dist/application-update/service.d.ts +69 -0
  21. package/dist/application-update/service.js +456 -0
  22. package/dist/application-update/service.js.map +1 -0
  23. package/dist/artifacts/cli.d.ts +1 -0
  24. package/dist/artifacts/cli.js +32 -0
  25. package/dist/artifacts/cli.js.map +1 -0
  26. package/dist/artifacts/lifecycle.d.ts +4 -0
  27. package/dist/artifacts/lifecycle.js +42 -0
  28. package/dist/artifacts/lifecycle.js.map +1 -0
  29. package/dist/artifacts/resolve.d.ts +18 -0
  30. package/dist/artifacts/resolve.js +102 -0
  31. package/dist/artifacts/resolve.js.map +1 -0
  32. package/dist/artifacts/store.d.ts +8 -0
  33. package/dist/artifacts/store.js +323 -0
  34. package/dist/artifacts/store.js.map +1 -0
  35. package/dist/automations/scheduler.d.ts +6 -0
  36. package/dist/automations/scheduler.js +45 -17
  37. package/dist/automations/scheduler.js.map +1 -1
  38. package/dist/automations/store.d.ts +12 -4
  39. package/dist/automations/store.js +199 -22
  40. package/dist/automations/store.js.map +1 -1
  41. package/dist/automations/types.d.ts +2 -0
  42. package/dist/automations/types.js +1 -0
  43. package/dist/automations/types.js.map +1 -1
  44. package/dist/ci-wait/mcp.d.ts +3 -0
  45. package/dist/ci-wait/mcp.js +14 -3
  46. package/dist/ci-wait/mcp.js.map +1 -1
  47. package/dist/contract/application-update.d.ts +32 -0
  48. package/dist/contract/artifacts.d.ts +83 -0
  49. package/dist/contract/ask-schema.d.ts +32 -0
  50. package/dist/contract/ask.d.ts +2 -32
  51. package/dist/contract/automations.d.ts +6 -0
  52. package/dist/contract/conversations.d.ts +165 -0
  53. package/dist/contract/delegation.d.ts +68 -0
  54. package/dist/contract/discovery.d.ts +134 -0
  55. package/dist/contract/events.d.ts +49 -0
  56. package/dist/contract/health.d.ts +12 -0
  57. package/dist/contract/index.d.ts +3 -0
  58. package/dist/contract/index.js +1654 -1454
  59. package/dist/contract/projects.d.ts +40 -0
  60. package/dist/contract/runs.d.ts +186 -0
  61. package/dist/contract/skills.d.ts +33 -0
  62. package/dist/core/agent-runner.d.ts +33 -4
  63. package/dist/core/agent-runner.js +5 -0
  64. package/dist/core/agent-runner.js.map +1 -1
  65. package/dist/core/claude-cli-runner.d.ts +6 -12
  66. package/dist/core/claude-cli-runner.js +90 -20
  67. package/dist/core/claude-cli-runner.js.map +1 -1
  68. package/dist/core/codex-app-server-runner.d.ts +2 -1
  69. package/dist/core/codex-app-server-runner.js +327 -92
  70. package/dist/core/codex-app-server-runner.js.map +1 -1
  71. package/dist/core/codex-app-server-transport.d.ts +13 -1
  72. package/dist/core/codex-app-server-transport.js +58 -17
  73. package/dist/core/codex-app-server-transport.js.map +1 -1
  74. package/dist/core/cursor-acp-runner.d.ts +6 -1
  75. package/dist/core/cursor-acp-runner.js +162 -26
  76. package/dist/core/cursor-acp-runner.js.map +1 -1
  77. package/dist/core/cursor-provider-error.d.ts +3 -0
  78. package/dist/core/cursor-provider-error.js +16 -1
  79. package/dist/core/cursor-provider-error.js.map +1 -1
  80. package/dist/core/input-submissions.d.ts +14 -0
  81. package/dist/core/input-submissions.js +26 -0
  82. package/dist/core/input-submissions.js.map +1 -0
  83. package/dist/core/opencode-server-runner.d.ts +4 -1
  84. package/dist/core/opencode-server-runner.js +156 -26
  85. package/dist/core/opencode-server-runner.js.map +1 -1
  86. package/dist/core/pi-runner.d.ts +2 -1
  87. package/dist/core/pi-runner.js +88 -10
  88. package/dist/core/pi-runner.js.map +1 -1
  89. package/dist/core/provider-auth.d.ts +99 -1
  90. package/dist/core/provider-auth.js +203 -2
  91. package/dist/core/provider-auth.js.map +1 -1
  92. package/dist/delegation/cli.d.ts +1 -0
  93. package/dist/delegation/cli.js +103 -7
  94. package/dist/delegation/cli.js.map +1 -1
  95. package/dist/delegation/conversations.js +13 -5
  96. package/dist/delegation/conversations.js.map +1 -1
  97. package/dist/delegation/input.d.ts +2 -1
  98. package/dist/delegation/input.js +6 -1
  99. package/dist/delegation/input.js.map +1 -1
  100. package/dist/delegation/policy.d.ts +3 -2
  101. package/dist/delegation/policy.js +3 -1
  102. package/dist/delegation/policy.js.map +1 -1
  103. package/dist/delegation/process-liveness.d.ts +66 -0
  104. package/dist/delegation/process-liveness.js +215 -0
  105. package/dist/delegation/process-liveness.js.map +1 -0
  106. package/dist/delegation/provision.d.ts +1 -1
  107. package/dist/delegation/provision.js +10 -5
  108. package/dist/delegation/provision.js.map +1 -1
  109. package/dist/delegation/questions.d.ts +19 -0
  110. package/dist/delegation/questions.js +45 -0
  111. package/dist/delegation/questions.js.map +1 -0
  112. package/dist/delegation/results.d.ts +1 -1
  113. package/dist/delegation/results.js +33 -19
  114. package/dist/delegation/results.js.map +1 -1
  115. package/dist/delegation/routes.d.ts +185 -11
  116. package/dist/delegation/routes.js +6 -2
  117. package/dist/delegation/routes.js.map +1 -1
  118. package/dist/delegation/service.d.ts +16 -5
  119. package/dist/delegation/service.js +161 -13
  120. package/dist/delegation/service.js.map +1 -1
  121. package/dist/delegation/transport.d.ts +228 -65
  122. package/dist/discovery/catalog.d.ts +14 -0
  123. package/dist/discovery/catalog.js +31 -0
  124. package/dist/discovery/catalog.js.map +1 -0
  125. package/dist/discovery/cli.d.ts +8 -0
  126. package/dist/discovery/cli.js +104 -0
  127. package/dist/discovery/cli.js.map +1 -0
  128. package/dist/git-worktree.d.ts +3 -1
  129. package/dist/git-worktree.js +26 -4
  130. package/dist/git-worktree.js.map +1 -1
  131. package/dist/index.js +92 -26
  132. package/dist/index.js.map +1 -1
  133. package/dist/open-url.d.ts +2 -0
  134. package/dist/open-url.js +20 -0
  135. package/dist/open-url.js.map +1 -0
  136. package/dist/release/snapshot.d.ts +3 -3
  137. package/dist/release/snapshot.js +6 -6
  138. package/dist/release/snapshot.js.map +1 -1
  139. package/dist/runs/agent-tmpdir.d.ts +2 -0
  140. package/dist/runs/agent-tmpdir.js +5 -2
  141. package/dist/runs/agent-tmpdir.js.map +1 -1
  142. package/dist/runs/client-request.d.ts +11 -0
  143. package/dist/runs/client-request.js +26 -0
  144. package/dist/runs/client-request.js.map +1 -0
  145. package/dist/runs/delegation-state.d.ts +17 -0
  146. package/dist/runs/event-history.js +6 -0
  147. package/dist/runs/event-history.js.map +1 -1
  148. package/dist/runs/retention.d.ts +7 -2
  149. package/dist/runs/retention.js +39 -7
  150. package/dist/runs/retention.js.map +1 -1
  151. package/dist/runs/store.d.ts +100 -6
  152. package/dist/runs/store.js +245 -2
  153. package/dist/runs/store.js.map +1 -1
  154. package/dist/runs/webhook.d.ts +125 -0
  155. package/dist/runs/webhook.js +256 -0
  156. package/dist/runs/webhook.js.map +1 -0
  157. package/dist/server/provider-auth-runtime.d.ts +30 -4
  158. package/dist/server/provider-auth-runtime.js +71 -6
  159. package/dist/server/provider-auth-runtime.js.map +1 -1
  160. package/dist/server/server.d.ts +8226 -4860
  161. package/dist/server/server.js +309 -15
  162. package/dist/server/server.js.map +1 -1
  163. package/dist/server-install/platforms/ubuntu-vps.d.ts +5 -1
  164. package/dist/server-install/platforms/ubuntu-vps.js +160 -18
  165. package/dist/server-install/platforms/ubuntu-vps.js.map +1 -1
  166. package/dist/server-install/steps.d.ts +4 -2
  167. package/dist/server-install/steps.js +5 -4
  168. package/dist/server-install/steps.js.map +1 -1
  169. package/dist/skills-remote.d.ts +30 -5
  170. package/dist/skills-remote.js +122 -32
  171. package/dist/skills-remote.js.map +1 -1
  172. package/dist/skills.js +15 -6
  173. package/dist/skills.js.map +1 -1
  174. package/dist/task-cli/cli.d.ts +38 -0
  175. package/dist/task-cli/cli.js +580 -0
  176. package/dist/task-cli/cli.js.map +1 -0
  177. package/dist/task-cli/discovery.d.ts +22 -0
  178. package/dist/task-cli/discovery.js +96 -0
  179. package/dist/task-cli/discovery.js.map +1 -0
  180. package/dist/task-cli/http.d.ts +46 -0
  181. package/dist/task-cli/http.js +101 -0
  182. package/dist/task-cli/http.js.map +1 -0
  183. package/dist/task-cli/projections.d.ts +40 -0
  184. package/dist/task-cli/projections.js +45 -0
  185. package/dist/task-cli/projections.js.map +1 -0
  186. package/dist/task-cli/watch.d.ts +78 -0
  187. package/dist/task-cli/watch.js +336 -0
  188. package/dist/task-cli/watch.js.map +1 -0
  189. package/dist/workflows/run.d.ts +160 -2
  190. package/dist/workflows/run.js +1141 -108
  191. package/dist/workflows/run.js.map +1 -1
  192. package/dist/workspace/agent-profiles.d.ts +22 -0
  193. package/dist/workspace/agent-profiles.js +15 -0
  194. package/dist/workspace/agent-profiles.js.map +1 -1
  195. package/dist/workspace/config.d.ts +9 -0
  196. package/dist/workspace/config.js +13 -1
  197. package/dist/workspace/config.js.map +1 -1
  198. package/dist/workspace/projects-cli.js +1 -1
  199. package/dist/workspace/projects.d.ts +24 -1
  200. package/dist/workspace/projects.js +14 -1
  201. package/dist/workspace/projects.js.map +1 -1
  202. package/package.json +5 -5
  203. package/scripts/mock-claude.mjs +64 -2
  204. package/scripts/mock-codex-app-server.mjs +124 -1
  205. package/scripts/mock-cursor-acp.mjs +54 -3
  206. package/scripts/mock-cursor-hang-stdin-late.mjs +35 -0
  207. package/scripts/mock-cursor-hang-stdin.mjs +30 -0
  208. package/scripts/mock-opencode-serve.mjs +102 -2
  209. package/scripts/mock-pi-rpc.mjs +82 -3
  210. package/web/dist/assets/agent-accounts-CerclGiO.js +1 -0
  211. package/web/dist/assets/centered-state-DH8qtCz-.js +43 -0
  212. package/web/dist/assets/collapsible-De2G0xqQ.js +1 -0
  213. package/web/dist/assets/commit-list-CQubP1iS.js +1 -0
  214. package/web/dist/assets/compare-variants-C_NijJvg.js +1 -0
  215. package/web/dist/assets/{diff-tRE59UNb2.js → diff-8M5HlDxq2.js} +2 -2
  216. package/web/dist/assets/diff-controls-B6ok0TtQ.js +1 -0
  217. package/web/dist/assets/{diff-stat-Cgnl_hYF.js → diff-stat-D1AODN2a.js} +1 -1
  218. package/web/dist/assets/{diff-view-DN1ort7Q.js → diff-view-Bs5Gh7UF.js} +2 -2
  219. package/web/dist/assets/dropdown-menu-7KGQMoFj.js +1 -0
  220. package/web/dist/assets/git-toolbar-DqbapMXr.js +1 -0
  221. package/web/dist/assets/github-lMHiuYSx.js +1 -0
  222. package/web/dist/assets/{image-preview-C2JGcBlC.js → image-preview-jzHoEyLM.js} +1 -1
  223. package/web/dist/assets/index-D4OJTArJ.js +7 -0
  224. package/web/dist/assets/index-D5NkwqY7.css +1 -0
  225. package/web/dist/assets/markdown-DvbymqXz.js +2 -0
  226. package/web/dist/assets/pill-BL6ugwXo.js +1 -0
  227. package/web/dist/assets/project-router-ChC5Rb-Y.js +1 -0
  228. package/web/dist/assets/prompt-templates-j8qlK7c-.js +15 -0
  229. package/web/dist/assets/repo-git-BbPAgkqb.js +1 -0
  230. package/web/dist/assets/{run-diff-CyG0Nciv.js → run-diff-BuATgZpx.js} +2 -2
  231. package/web/dist/assets/run-header-DuAWswYM.js +1 -0
  232. package/web/dist/assets/skills-DiC2XrU1.js +1 -0
  233. package/web/dist/assets/{tab-link-BWNp3mLY.js → tab-link-BmGKj9Rt.js} +1 -1
  234. package/web/dist/assets/task-changes-CP9kPnsy.js +1 -0
  235. package/web/dist/assets/task-commits-D6NfTw5r.js +1 -0
  236. package/web/dist/assets/task-files-W-b_gtcb.js +2 -0
  237. package/web/dist/assets/task-thread-Bw_nQuTx.css +1 -0
  238. package/web/dist/assets/task-thread-Q7Nj33DH.js +9 -0
  239. package/web/dist/assets/textarea-ByZ-txS7.js +1 -0
  240. package/web/dist/assets/thread-loading-DHT9p5o5.js +1 -0
  241. package/web/dist/assets/token-metrics-k4XoovDS.js +1 -0
  242. package/web/dist/assets/utils-BTFBhZ55.js +64 -0
  243. package/web/dist/assets/workflows-DqQszPHJ.js +11 -0
  244. package/web/dist/assets/{zoomable-image-Z3JDnm0b.js → zoomable-image-Ba6y6Wyl.js} +1 -1
  245. package/web/dist/index.html +14 -14
  246. package/web/dist/assets/agent-accounts-BZm_2WAv.js +0 -1
  247. package/web/dist/assets/alert-dialog-B422RI-k.js +0 -43
  248. package/web/dist/assets/collapsible-Cy_Fmkrd.js +0 -1
  249. package/web/dist/assets/commit-list-Dcnk7TnI.js +0 -1
  250. package/web/dist/assets/compare-variants-Ciqwvd_f.js +0 -1
  251. package/web/dist/assets/diff-controls-BGrXGi7O.js +0 -1
  252. package/web/dist/assets/dropdown-menu-dwDGT8MM.js +0 -1
  253. package/web/dist/assets/git-toolbar-UiHnGvE0.js +0 -1
  254. package/web/dist/assets/github-D-MrkbJ7.js +0 -1
  255. package/web/dist/assets/ibm-plex-mono-regular-BF3vfe7_.ttf +0 -0
  256. package/web/dist/assets/index-BszfYvBq.js +0 -7
  257. package/web/dist/assets/index-CWh4pKP3.css +0 -1
  258. package/web/dist/assets/markdown-C_IcKVQd.js +0 -2
  259. package/web/dist/assets/pill-BsbO6G7y.js +0 -1
  260. package/web/dist/assets/project-router-DbLkll25.js +0 -1
  261. package/web/dist/assets/prompt-templates-BlTGJB5W.js +0 -15
  262. package/web/dist/assets/repo-git-Bm3s6Why.js +0 -1
  263. package/web/dist/assets/run-header-IFyIGCey.js +0 -1
  264. package/web/dist/assets/skills-C-C4DVFY.js +0 -1
  265. package/web/dist/assets/task-changes-D2PHtWUW.js +0 -1
  266. package/web/dist/assets/task-commits-N5u9U0_R.js +0 -1
  267. package/web/dist/assets/task-files-BS7c7CFm.js +0 -2
  268. package/web/dist/assets/task-thread-BQFdz1dJ.css +0 -1
  269. package/web/dist/assets/task-thread-DGM2dZV-.js +0 -9
  270. package/web/dist/assets/textarea-FjaU370i.js +0 -1
  271. package/web/dist/assets/thread-loading-77sJ8Yu_.js +0 -1
  272. package/web/dist/assets/token-metrics-Clxh03bE.js +0 -1
  273. package/web/dist/assets/utils-PYYcpCFZ.js +0 -64
  274. package/web/dist/assets/workflows-Czl0ZfXH.js +0 -11
@@ -1,58 +1,103 @@
1
1
  // ../contract/src/events.ts
2
- import { z as z4 } from "zod";
2
+ import { z as z9 } from "zod";
3
3
 
4
4
  // ../contract/src/conversations.ts
5
+ import { z as z2 } from "zod";
6
+
7
+ // ../contract/src/ask-schema.ts
5
8
  import { z } from "zod";
6
- var conversationAttributionSchema = z.object({
7
- senderRunId: z.uuid(),
8
- recipientRunId: z.uuid(),
9
- kind: z.enum(["request", "progress", "follow-up", "reply"]),
10
- requestId: z.uuid().optional()
9
+ var askOptionSchema = z.object({
10
+ label: z.string().min(1).max(60),
11
+ description: z.string().max(280).optional()
12
+ }).strict();
13
+ var askQuestionSchema = z.object({
14
+ /** Stable key for the answer; defaults to the array index when omitted. */
15
+ id: z.string().min(1).max(64).optional(),
16
+ /** ≤12-char chip label (matches AskUserQuestion's `header`). */
17
+ header: z.string().min(1).max(12),
18
+ question: z.string().min(1).max(400),
19
+ options: z.array(askOptionSchema).min(2).max(4).refine((opts) => new Set(opts.map((o) => o.label)).size === opts.length, {
20
+ message: "option labels must be unique within a question"
21
+ }),
22
+ multiSelect: z.boolean().optional()
23
+ }).strict();
24
+ var askRequestSchema = z.object({
25
+ questions: z.array(askQuestionSchema).min(1).max(4).refine((qs) => new Set(qs.map((q) => q.question)).size === qs.length, {
26
+ message: "question texts must be unique"
27
+ })
28
+ }).strict();
29
+
30
+ // ../contract/src/conversations.ts
31
+ var conversationAttributionSchema = z2.object({
32
+ senderRunId: z2.uuid(),
33
+ recipientRunId: z2.uuid(),
34
+ kind: z2.enum(["request", "progress", "follow-up", "reply"]),
35
+ requestId: z2.uuid().optional()
11
36
  }).strict();
12
37
  var conversationMessageSchema = conversationAttributionSchema.extend({
13
- id: z.uuid(),
14
- text: z.string().min(1).max(1e5),
15
- createdAt: z.iso.datetime(),
16
- deadline: z.iso.datetime().optional(),
17
- requestHash: z.string().regex(/^[0-9a-f]{64}$/),
18
- state: z.enum(["accepted", "continuation-required", "destroyed", "late"]),
38
+ id: z2.uuid(),
39
+ text: z2.string().min(1).max(1e5),
40
+ createdAt: z2.iso.datetime(),
41
+ deadline: z2.iso.datetime().optional(),
42
+ requestHash: z2.string().regex(/^[0-9a-f]{64}$/),
43
+ state: z2.enum(["accepted", "continuation-required", "destroyed", "late"]),
19
44
  /** A parent-authorized new execution; retained on exact message retries. */
20
- resumed: z.literal(true).optional(),
21
- instruction: z.string().max(2048).optional()
22
- });
23
- var requestOutcomeSchema = z.object({
24
- requestId: z.uuid(),
25
- status: z.enum(["replied", "completed-without-reply", "failed", "cancelled", "destroyed", "timed-out", "sender-closed"]),
26
- observedAt: z.iso.datetime(),
27
- replyId: z.uuid().optional()
45
+ resumed: z2.literal(true).optional(),
46
+ instruction: z2.string().max(2048).optional(),
47
+ /** A worker's question routed to its parent (#505): answered only by a reply naming it. */
48
+ question: askRequestSchema.optional()
49
+ });
50
+ var requestOutcomeSchema = z2.object({
51
+ requestId: z2.uuid(),
52
+ status: z2.enum(["replied", "completed-without-reply", "failed", "cancelled", "destroyed", "timed-out", "sender-closed", "human-fallback"]),
53
+ observedAt: z2.iso.datetime(),
54
+ replyId: z2.uuid().optional()
28
55
  }).strict();
29
- var conversationStateSchema = z.object({ messages: z.array(conversationMessageSchema).max(1024), outcomes: z.array(requestOutcomeSchema).max(1024) }).strict();
30
- var conversationSendRequestSchema = z.object({
31
- id: z.uuid(),
32
- recipientRunId: z.uuid(),
56
+ var conversationStateSchema = z2.object({ messages: z2.array(conversationMessageSchema).max(1024), outcomes: z2.array(requestOutcomeSchema).max(1024) }).strict();
57
+ var conversationInspectResultSchema = conversationStateSchema.extend({ hint: z2.string().optional() });
58
+ var inboxReserveResultSchema = z2.object({
59
+ messages: z2.array(conversationMessageSchema).max(32),
60
+ outcomes: z2.array(requestOutcomeSchema).max(32),
61
+ receiptId: z2.uuid().optional(),
62
+ expiresAt: z2.iso.datetime().optional()
63
+ }).strict().refine(
64
+ (value) => value.messages.length > 0 ? value.receiptId !== void 0 && value.expiresAt !== void 0 : value.receiptId === void 0 && value.expiresAt === void 0,
65
+ { message: "A nonempty inbox batch requires a receipt and expiry" }
66
+ );
67
+ var inboxReceiptRequestSchema = z2.object({ receiptId: z2.uuid() }).strict();
68
+ var inboxReceiptResultSchema = z2.object({
69
+ receiptId: z2.uuid(),
70
+ status: z2.enum(["acknowledged", "already-acknowledged", "released"])
71
+ }).strict();
72
+ var conversationSendRequestSchema = z2.object({
73
+ id: z2.uuid(),
74
+ recipientRunId: z2.uuid(),
33
75
  kind: conversationAttributionSchema.shape.kind,
34
- requestId: z.uuid().optional(),
35
- text: z.string().min(1).max(1e5).refine((text) => text.trim().length > 0),
36
- timeoutSeconds: z.number().int().min(1).max(1800).default(600),
37
- resume: z.boolean().optional()
76
+ requestId: z2.uuid().optional(),
77
+ text: z2.string().min(1).max(1e5).refine((text) => text.trim().length > 0),
78
+ timeoutSeconds: z2.number().int().min(1).max(1800).default(600),
79
+ resume: z2.boolean().optional()
38
80
  }).strict().refine((value) => (value.kind === "reply" || value.kind === "follow-up") === (value.requestId !== void 0), { message: "Replies and follow-ups require a request ID; new messages must omit it" }).refine((value) => !value.resume || value.kind === "request" || value.kind === "progress", { message: "--resume requires a new request or progress instruction" });
39
- var conversationSendResultSchema = z.object({ message: conversationMessageSchema, delivery: z.enum(["queued", "delivered", "not-delivered"]), outcome: requestOutcomeSchema.optional() }).strict();
40
- var conversationInspectRequestSchema = z.object({ recipientRunId: z.uuid() }).strict();
41
- var conversationCancelRequestSchema = z.object({ requestId: z.uuid() }).strict();
42
- var requestWaitRequestSchema = z.object({
43
- requestIds: z.array(z.uuid()).min(1).max(32).refine((ids) => new Set(ids).size === ids.length),
44
- mode: z.enum(["one", "any", "all"]).optional(),
45
- timeoutSeconds: z.number().int().min(1).max(1800).default(600)
81
+ var conversationSendResultSchema = z2.object({ message: conversationMessageSchema, delivery: z2.enum(["queued", "delivered", "consumed", "not-delivered"]), outcome: requestOutcomeSchema.optional() }).strict();
82
+ var conversationInspectRequestSchema = z2.object({ recipientRunId: z2.uuid() }).strict();
83
+ var conversationCancelRequestSchema = z2.object({ requestId: z2.uuid() }).strict();
84
+ var requestWaitRequestSchema = z2.object({
85
+ requestIds: z2.array(z2.uuid()).min(1).max(32).refine((ids) => new Set(ids).size === ids.length),
86
+ mode: z2.enum(["one", "any", "all"]).optional(),
87
+ timeoutSeconds: z2.number().int().min(1).max(1800).default(600)
46
88
  }).strict().refine((value) => value.mode !== "one" || value.requestIds.length === 1, { message: "one requires exactly one request" });
47
89
 
48
- // ../contract/src/delegation.ts
49
- import { z as z3 } from "zod";
90
+ // ../contract/src/discovery.ts
91
+ import { z as z7 } from "zod";
92
+
93
+ // ../contract/src/workspace.ts
94
+ import { z as z6 } from "zod";
50
95
 
51
96
  // ../contract/src/effort.ts
52
- import { z as z2 } from "zod";
97
+ import { z as z3 } from "zod";
53
98
  var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
54
- var effortLevelSchema = z2.enum(EFFORT_LEVELS);
55
- var effortFieldSchema = z2.string().max(32).optional();
99
+ var effortLevelSchema = z3.enum(EFFORT_LEVELS);
100
+ var effortFieldSchema = z3.string().max(32).optional();
56
101
  function parseEffort(value) {
57
102
  const trimmed = value?.trim().toLowerCase();
58
103
  if (!trimmed || trimmed === "auto") return void 0;
@@ -60,163 +105,599 @@ function parseEffort(value) {
60
105
  return parsed.success ? parsed.data : void 0;
61
106
  }
62
107
 
108
+ // ../contract/src/health.ts
109
+ import { z as z5 } from "zod";
110
+
111
+ // ../contract/src/application-update.ts
112
+ import { z as z4 } from "zod";
113
+ var applicationUpdateStateSchema = z4.object({
114
+ status: z4.enum(["idle", "preparing", "ready", "restarting", "error"]),
115
+ supported: z4.boolean(),
116
+ targetVersion: z4.string().optional(),
117
+ message: z4.string().optional()
118
+ });
119
+ var applicationUpdateInputSchema = z4.record(z4.string(), z4.never());
120
+ var applicationUpdateResponseSchema = z4.object({ state: applicationUpdateStateSchema });
121
+
122
+ // ../contract/src/health.ts
123
+ var runnerSchema = z5.enum(["claude", "codex", "opencode", "pi", "cursor"]);
124
+ var repoInfoSchema = z5.object({
125
+ root: z5.string(),
126
+ branch: z5.string(),
127
+ remote: z5.string().optional()
128
+ });
129
+ var backendCheckSchema = z5.object({
130
+ name: z5.enum(["claude", "codex", "opencode", "pi", "cursor", "gh", "git"]),
131
+ available: z5.boolean(),
132
+ version: z5.string().optional(),
133
+ hint: z5.string().optional()
134
+ });
135
+ var forgeInfoSchema = z5.object({
136
+ kind: z5.literal("github"),
137
+ /**
138
+ * Whether the forge is reachable — **absent until the availability probe has warmed**.
139
+ *
140
+ * Health must never pay a `gh` shell-out, so it serves whatever the cache holds. Absent means
141
+ * "not determined yet", which is not the same as `false`, and the cockpit renders the two
142
+ * differently. Declaring it required is what made an earlier hand-written mirror wrong.
143
+ */
144
+ available: z5.boolean().optional(),
145
+ reason: z5.string().optional()
146
+ });
147
+ var capabilitiesSchema = z5.object({
148
+ localHandoff: z5.boolean(),
149
+ followups: z5.boolean(),
150
+ singleProject: z5.boolean(),
151
+ /**
152
+ * `true` means `CEZ_AUTOMATIONS=1` opted this server into GitHub automations (#801). Off — the
153
+ * default — the whole feature is absent: no `Automations` nav item anywhere it is rendered, the
154
+ * `/api/v1/…/automations*` family answers `409`, and the workspace scheduler never polls GitHub.
155
+ *
156
+ * REQUIRED for the same reason as `tokenMetrics` below: this server always sends it.
157
+ */
158
+ automations: z5.boolean(),
159
+ /**
160
+ * `false` means `CEZ_HIDE_TOKEN_METRICS=1` asks the browser to omit token counts and monetary
161
+ * cost (#481). The telemetry itself still rides in run/event payloads — this is presentation
162
+ * only.
163
+ *
164
+ * REQUIRED, because this server always sends it (`capabilities.ts` computes it from the env on
165
+ * every read) and this contract describes THIS server's wire. The DTO it replaces declared it
166
+ * optional so a newer cockpit could read an OLDER server, which is version skew a contract
167
+ * versioned in lockstep with the server cannot model. That tolerance lives where it belongs, in
168
+ * `web/src/lib/token-metrics.ts`, whose `!== false` read still treats an absent field as
169
+ * visible.
170
+ */
171
+ tokenMetrics: z5.boolean(),
172
+ /** Current token-count presentation policy. Required on current servers;
173
+ * older payload tolerance belongs in the browser resolver. */
174
+ tokenUsageMetrics: z5.boolean(),
175
+ /** Current backend-reported-cost presentation policy. */
176
+ costMetrics: z5.boolean()
177
+ });
178
+ var healthResponseSchema = z5.object({
179
+ version: z5.string(),
180
+ latestVersion: z5.string().optional(),
181
+ repoRoot: z5.string(),
182
+ repo: repoInfoSchema.nullable(),
183
+ checks: z5.array(backendCheckSchema),
184
+ defaultRunner: runnerSchema,
185
+ forge: forgeInfoSchema.nullable(),
186
+ capabilities: capabilitiesSchema,
187
+ // Always sent: `workspaceSummary()` returns both unconditionally, and an unreadable workspace
188
+ // degrades to `projects: []` rather than to an absent key. The hand-written DTO declared them
189
+ // optional, which was wider than the server has ever been.
190
+ projects: z5.array(z5.object({ id: z5.string(), name: z5.string() })),
191
+ bootProject: z5.string(),
192
+ applicationUpdate: applicationUpdateStateSchema.optional()
193
+ });
194
+
195
+ // ../contract/src/workspace.ts
196
+ var workspaceConfigResponseSchema = z6.object({
197
+ /** Root exposed by the Add-project directory browser — stored as written (`~` kept). */
198
+ browseRoot: z6.string(),
199
+ /** Checkout root for GUI-cloned projects — stored as written (`~` kept). */
200
+ projectsDir: z6.string(),
201
+ /** Stored override; `null` means inherit `CEZ_SKILLS_AUTO_UPDATE`, then true. */
202
+ skillsAutoUpdate: z6.boolean().nullable(),
203
+ effectiveSkillsAutoUpdate: z6.boolean(),
204
+ composerDefaults: z6.object({
205
+ autonomous: z6.boolean().nullable(),
206
+ worktree: z6.boolean().nullable(),
207
+ /** `'source-dependent'` when no `CEZ_AUTONOMOUS_DEFAULT` pins it either way. */
208
+ inheritedAutonomous: z6.union([z6.boolean(), z6.literal("source-dependent")]),
209
+ inheritedWorktree: z6.boolean()
210
+ }),
211
+ resources: z6.object({
212
+ maxParallel: z6.number(),
213
+ maxMonitoringSessions: z6.number(),
214
+ monitoringWakeIntervalMinutes: z6.number().nullable(),
215
+ /** Resume a run a provider usage limit stopped, once the limit resets. Default `true`. */
216
+ autoResumeOnUsageLimit: z6.boolean(),
217
+ memoryLimitMb: z6.number().nullable(),
218
+ worktreeRetentionDefault: z6.number()
219
+ }),
220
+ /**
221
+ * What a repo that has set none of its own runs (spec 2026-07-29-agent-profiles).
222
+ *
223
+ * Both keys are OPTIONAL on the wire, and that is load-bearing rather than lax: absent means
224
+ * "this machine has no opinion, the built-in default applies", and it has to stay distinguishable
225
+ * from a value someone chose or the fallback collapses into "always claude". Consulted only where
226
+ * the repo's own `.ai/cezar/config.json` is silent — a repo that chose is never overruled.
227
+ */
228
+ agentDefaults: z6.object({
229
+ runner: runnerSchema.optional(),
230
+ models: z6.object({
231
+ claude: z6.string().optional(),
232
+ codex: z6.string().optional(),
233
+ opencode: z6.string().optional(),
234
+ pi: z6.string().optional(),
235
+ cursor: z6.string().optional()
236
+ }).optional()
237
+ })
238
+ });
239
+ var setWorkspaceConfigInputSchema = z6.object({
240
+ browseRoot: z6.string().trim().min(1).max(4096).optional(),
241
+ projectsDir: z6.string().trim().min(1).max(4096).optional(),
242
+ skillsAutoUpdate: z6.boolean().nullable().optional(),
243
+ composerDefaults: z6.object({
244
+ autonomous: z6.boolean().nullable().optional(),
245
+ worktree: z6.boolean().nullable().optional()
246
+ }).optional(),
247
+ /** Machine-wide agent defaults. `null` on a key CLEARS it back to "no opinion", which a bare
248
+ * absent key cannot say in a partial patch. */
249
+ agentDefaults: z6.object({
250
+ runner: runnerSchema.nullable().optional(),
251
+ models: z6.object({
252
+ claude: z6.string().trim().min(1).max(200).nullable().optional(),
253
+ codex: z6.string().trim().min(1).max(200).nullable().optional(),
254
+ opencode: z6.string().trim().min(1).max(200).nullable().optional(),
255
+ pi: z6.string().trim().min(1).max(200).nullable().optional(),
256
+ cursor: z6.string().trim().min(1).max(200).nullable().optional()
257
+ }).optional()
258
+ }).optional(),
259
+ resources: z6.object({
260
+ maxParallel: z6.number().int().min(1).max(16).optional(),
261
+ maxMonitoringSessions: z6.number().int().min(0).max(16).optional(),
262
+ monitoringWakeIntervalMinutes: z6.number().int().min(1).max(60).nullable().optional(),
263
+ autoResumeOnUsageLimit: z6.boolean().optional(),
264
+ memoryLimitMb: z6.number().int().min(0).max(1048576).nullable().optional(),
265
+ worktreeRetentionDefault: z6.number().int().min(0).max(1e3).optional()
266
+ }).optional()
267
+ });
268
+ var appearanceSchema = z6.object({
269
+ accent: z6.enum(["cezarion", "lime", "violet"]).optional(),
270
+ density: z6.enum(["comfortable", "compact", "ultra"]).optional(),
271
+ width: z6.enum(["narrow", "wide"]).optional()
272
+ });
273
+ var taskTableUiStateSchema = z6.looseObject({
274
+ /** Explicit user choices only. Missing ids keep the registry-owned default. */
275
+ expandedColumns: z6.record(z6.string(), z6.boolean()).optional()
276
+ });
277
+ var uiStateSchema = z6.looseObject({
278
+ /** What the last started run used. `null` is a VALUE, not an absence: it records a run that
279
+ * chose neither a skill nor a workflow (the plain built-in `quick-task`), which the composer
280
+ * can now express since the source picker grew an empty state. Absent still means "no
281
+ * run has been recorded here" — a cockpit reading either one selects nothing. */
282
+ lastTask: z6.object({ source: z6.enum(["workflow", "skill"]), ref: z6.string() }).nullable().optional(),
283
+ /** Most-recently-run sources, newest first (deduped, capped). Feeds the composer picker's
284
+ * recency sort. */
285
+ recentSources: z6.array(z6.object({ source: z6.enum(["workflow", "skill"]), ref: z6.string() })).optional(),
286
+ /** The last worktree choice for a single-skill run. Absent → the default (isolated worktree). */
287
+ lastWorktree: z6.boolean().optional(),
288
+ /** The last autonomous choice — remembered like `lastWorktree`. Absent → off. */
289
+ lastAutonomous: z6.boolean().optional(),
290
+ /** Whether new runs should ask agents to append follow-up work. Absent → on. */
291
+ lastGenerateFollowups: z6.boolean().optional(),
292
+ /** Skill selection frequency (#408): name → times chosen, across BOTH composers. */
293
+ skillUsage: z6.record(z6.string(), z6.number()).optional(),
294
+ runsView: z6.enum(["list", "table"]).optional(),
295
+ /** The GitHub tab's last-selected sub-tab (#417). Absent → issues. */
296
+ githubView: z6.enum(["issues", "prs"]).optional(),
297
+ /** Settings → Appearance. The theme itself stays in localStorage (`cez-theme`) — it must
298
+ * pre-paint, and it is per-browser by design. */
299
+ appearance: appearanceSchema.optional(),
300
+ /** Follow-up prompt templates (#413). Absent → the built-in defaults; present (even `[]`) is
301
+ * the user's own edited list. `skills` are the skill names the template auto-applies for. */
302
+ promptTemplates: z6.array(
303
+ z6.object({
304
+ id: z6.string(),
305
+ label: z6.string(),
306
+ text: z6.string(),
307
+ skills: z6.array(z6.string()).optional()
308
+ })
309
+ ).optional(),
310
+ /** The open-mercato/skills promo banner (#391), dismissed for good. Legacy — the banner is
311
+ * gone, replaced by `WorkspaceUiState.importedSkills`; retained so old files round-trip. */
312
+ dismissedSkillsBanner: z6.boolean().optional()
313
+ });
314
+ var workspaceLastLocationSchema = z6.strictObject({
315
+ projectId: z6.string().min(1).max(64),
316
+ pathname: z6.string().min(1).max(2048).startsWith("/p/"),
317
+ search: z6.string().max(4096).startsWith("?").optional(),
318
+ hash: z6.string().max(2048).startsWith("#").optional()
319
+ });
320
+ var workspaceUiStateSchema = z6.looseObject({
321
+ /** LEGACY — the sidebar's per-project collapse map (step 3.3). Still accepted and still
322
+ * round-tripped so an older cockpit sharing this home keeps working, but the current cockpit
323
+ * neither reads nor writes it: which groups are shut describes the WINDOW, not the workspace,
324
+ * so it lives in that browser's localStorage (`packages/web/src/lib/sidebar-collapse.ts`).
325
+ * One shared answer meant a phone collapsing a group collapsed it on the desktop too. */
326
+ sidebar: z6.looseObject({ collapsed: z6.record(z6.string(), z6.boolean()).optional() }).optional(),
327
+ /** Dismissed runtime-auth incident IDs, keyed by provider. An ID is only dismissed until the
328
+ * provider reports a different incident, so this stays workspace-global with the browser
329
+ * rather than one project checkout. */
330
+ dismissedProviderAuthFailures: z6.object({
331
+ claude: z6.string().optional(),
332
+ codex: z6.string().optional(),
333
+ opencode: z6.string().optional(),
334
+ pi: z6.string().optional(),
335
+ cursor: z6.string().optional()
336
+ }).optional(),
337
+ /** Settings → Appearance, GLOBAL since step 3.5: accent + density describe the person at the
338
+ * keyboard, not a repo. */
339
+ appearance: appearanceSchema.optional(),
340
+ /** Settings → Notifications, GLOBAL since step 3.5 — one answer for the whole workspace, since
341
+ * the delivering browser is one browser whichever project you are looking at. */
342
+ notifications: z6.looseObject({ enabled: z6.boolean().optional() }).optional(),
343
+ /** Desktop Tasks-table density, shared across every project in this workspace. */
344
+ taskTable: taskTableUiStateSchema.optional(),
345
+ /** LEGACY, exactly like `sidebar` above — the last settled project-scoped page, restored when
346
+ * entering at the exact bare root. The shape is unchanged and still accepted, but the current
347
+ * cockpit keeps it in localStorage (`packages/web/src/lib/last-location.ts`): stored here, the
348
+ * last client to navigate decided where every OTHER client's next launch landed. */
349
+ lastLocation: workspaceLastLocationSchema.optional(),
350
+ /** The user's curated selection of default (vendor) skills. Tri-state: ABSENT means "not
351
+ * curated", so every default skill shows; a PRESENT array (even `[]`) means only those names
352
+ * show from that repo. */
353
+ importedSkills: z6.array(z6.string()).optional()
354
+ });
355
+ var WORKSPACE_UI_STATE_MAX_KEYS = 200;
356
+ var TASK_TABLE_MAX_COLUMNS = 50;
357
+ var setWorkspaceUiStateInputSchema = z6.looseObject({
358
+ ...workspaceUiStateSchema.shape,
359
+ sidebar: z6.looseObject({
360
+ collapsed: z6.record(z6.string().min(1).max(64), z6.boolean()).refine((map) => Object.keys(map).length <= WORKSPACE_UI_STATE_MAX_KEYS, {
361
+ message: `sidebar.collapsed must have at most ${WORKSPACE_UI_STATE_MAX_KEYS} entries`
362
+ }).optional()
363
+ }).optional(),
364
+ dismissedProviderAuthFailures: z6.strictObject({
365
+ claude: z6.string().min(1).max(128).optional(),
366
+ codex: z6.string().min(1).max(128).optional(),
367
+ opencode: z6.string().min(1).max(128).optional(),
368
+ pi: z6.string().min(1).max(128).optional(),
369
+ cursor: z6.string().min(1).max(128).optional()
370
+ }).optional(),
371
+ importedSkills: z6.array(z6.string().min(1).max(200)).max(WORKSPACE_UI_STATE_MAX_KEYS).optional(),
372
+ taskTable: taskTableUiStateSchema.extend({
373
+ expandedColumns: z6.record(z6.string().min(1).max(64), z6.boolean()).refine((map) => Object.keys(map).length <= TASK_TABLE_MAX_COLUMNS, {
374
+ message: `taskTable.expandedColumns must have at most ${TASK_TABLE_MAX_COLUMNS} entries`
375
+ }).optional()
376
+ }).optional()
377
+ }).superRefine((data, ctx) => {
378
+ if (Object.keys(data).length > WORKSPACE_UI_STATE_MAX_KEYS) {
379
+ ctx.addIssue({
380
+ code: "custom",
381
+ message: `ui-state has too many keys (max ${WORKSPACE_UI_STATE_MAX_KEYS})`
382
+ });
383
+ }
384
+ });
385
+ var runnerModelsSchema = z6.object({
386
+ claude: z6.string().optional(),
387
+ codex: z6.string().optional(),
388
+ opencode: z6.string().optional(),
389
+ pi: z6.string().optional(),
390
+ cursor: z6.string().optional()
391
+ });
392
+ var configResponseSchema = z6.object({
393
+ baseBranch: z6.string().nullable(),
394
+ defaultRunner: runnerSchema,
395
+ systemPrompt: z6.string().nullable(),
396
+ defaultModels: runnerModelsSchema,
397
+ /** True when native coding-agent settings are authoritative and model picks are read-only. */
398
+ modelsLocked: z6.boolean(),
399
+ /** How many tasks run at once (1–16). */
400
+ maxParallel: z6.number(),
401
+ /** Per-task memory ceiling in MiB (whole process tree); null = no limit. */
402
+ memoryLimitMb: z6.number().nullable(),
403
+ /** Keep the last N finished worktrees on disk (#483); 0 = unlimited. Older ones are reclaimed
404
+ * (directory only — branch kept, so work is recoverable). */
405
+ worktreeRetention: z6.number(),
406
+ /** Live title updates: null = no config key, the `CEZ_TITLE_UPDATES` env default (ON) decides. */
407
+ liveTitleUpdates: z6.boolean().nullable(),
408
+ /** Optional review gate (#489): null = no config key, the `CEZ_REVIEW_GATE` env default (OFF)
409
+ * decides. */
410
+ reviewGate: z6.boolean().nullable()
411
+ });
412
+ var setConfigResponseSchema = configResponseSchema;
413
+ var setConfigInputSchema = z6.object({
414
+ baseBranch: z6.string().trim().min(1).max(200).nullable().optional(),
415
+ defaultRunner: runnerSchema.optional(),
416
+ systemPrompt: z6.string().trim().max(2e4).nullable().optional(),
417
+ defaultModels: z6.object({
418
+ claude: z6.string().trim().max(200).nullable().optional(),
419
+ codex: z6.string().trim().max(200).nullable().optional(),
420
+ opencode: z6.string().trim().max(200).nullable().optional(),
421
+ pi: z6.string().trim().max(200).nullable().optional(),
422
+ cursor: z6.string().trim().max(200).nullable().optional()
423
+ }).optional(),
424
+ maxParallel: z6.number().int().min(1).max(16).optional(),
425
+ /** null or 0 clears the ceiling back to "no limit". */
426
+ memoryLimitMb: z6.number().int().min(0).max(1048576).nullable().optional(),
427
+ /** Keep last N finished worktrees (#483); 0 = unlimited, null clears back to the default (10). */
428
+ worktreeRetention: z6.number().int().min(0).max(1e3).nullable().optional(),
429
+ /** null clears the key back to the env-default behavior. */
430
+ liveTitleUpdates: z6.boolean().nullable().optional(),
431
+ /** null clears the key back to the env-default behavior (OFF). */
432
+ reviewGate: z6.boolean().nullable().optional()
433
+ });
434
+ var skillsUpdateStatusSchema = z6.enum([
435
+ "idle",
436
+ "checking",
437
+ "available",
438
+ "updating",
439
+ "current",
440
+ "unavailable",
441
+ "error"
442
+ ]);
443
+ var skillsUpdateScopeStateSchema = z6.object({
444
+ scope: z6.enum(["project", "global"]),
445
+ status: skillsUpdateStatusSchema,
446
+ available: z6.boolean(),
447
+ skills: z6.array(z6.string()),
448
+ checkedAt: z6.string().nullable(),
449
+ updatedAt: z6.string().nullable(),
450
+ reason: z6.string().optional()
451
+ });
452
+ var skillsUpdateStateSchema = z6.object({
453
+ status: skillsUpdateStatusSchema,
454
+ available: z6.boolean(),
455
+ autoUpdateEnabled: z6.boolean(),
456
+ inherited: z6.boolean(),
457
+ checkedAt: z6.string().nullable(),
458
+ updatedAt: z6.string().nullable(),
459
+ scopes: z6.array(skillsUpdateScopeStateSchema),
460
+ needsUpgradeNotes: z6.boolean()
461
+ });
462
+ var providerIdSchema = runnerSchema;
463
+ var providerConnectionStateSchema = z6.enum([
464
+ "connected",
465
+ "disconnected",
466
+ "not-installed",
467
+ "unknown"
468
+ ]);
469
+ var providerStatusSchema = z6.object({
470
+ provider: providerIdSchema,
471
+ status: providerConnectionStateSchema,
472
+ enabled: z6.boolean().optional(),
473
+ hint: z6.string().optional(),
474
+ authFailureId: z6.string().optional(),
475
+ /** Which agent account this row describes (spec 2026-07-29-agent-profiles). ABSENT on
476
+ * `GET /api/v1/providers/status`, which deliberately keeps answering exactly one row per
477
+ * provider — the discovered default — so an older client sees no change at all. Per-account
478
+ * rows are carried by `GET /api/v1/workspace/agent-profiles` instead. */
479
+ profileId: z6.string().optional()
480
+ });
481
+ var providerStatusResponseSchema = z6.object({
482
+ providers: z6.array(providerStatusSchema)
483
+ });
484
+ var providerConnectResponseSchema = z6.discriminatedUnion("opened", [
485
+ z6.object({ opened: z6.literal(true), command: z6.string() }),
486
+ z6.object({ opened: z6.literal(false), connected: z6.literal(true), command: z6.string() })
487
+ ]);
488
+ var modelDiscoveryRunnerSchema = z6.enum(["claude", "codex", "opencode", "pi", "cursor"]);
489
+ var MODEL_DISCOVERY_RUNNERS = modelDiscoveryRunnerSchema.options;
490
+ function runnerDiscoversModels(runner) {
491
+ return MODEL_DISCOVERY_RUNNERS.includes(runner);
492
+ }
493
+ var runnerModelOptionSchema = z6.object({
494
+ id: z6.string(),
495
+ label: z6.string(),
496
+ description: z6.string(),
497
+ effortLevels: z6.array(effortLevelSchema).optional()
498
+ });
499
+ var runnerModelCatalogResponseSchema = z6.object({
500
+ runner: runnerSchema,
501
+ models: z6.array(runnerModelOptionSchema),
502
+ source: z6.enum(["live", "cache", "unavailable"]),
503
+ stale: z6.boolean(),
504
+ reason: z6.string().optional()
505
+ });
506
+ var openTargetSchema = z6.object({
507
+ id: z6.string(),
508
+ label: z6.string(),
509
+ /** A stable icon key (#361) the UI maps to a concrete icon. Optional: an older server omitting
510
+ * it just renders the generic fallback icon. */
511
+ icon: z6.string().optional()
512
+ });
513
+ var openTargetsResponseSchema = z6.object({
514
+ targets: z6.array(openTargetSchema)
515
+ });
516
+ var openProjectInSchema = z6.object({
517
+ // A short bound (#429): matched against a downstream allowlist, so an app id is never long.
518
+ target: z6.string().trim().min(1, "target required").max(200)
519
+ });
520
+ var openProjectInResponseSchema = z6.object({
521
+ opened: z6.literal(true),
522
+ path: z6.string()
523
+ });
524
+
525
+ // ../contract/src/discovery.ts
526
+ var discoveryRequestSchema = z7.discriminatedUnion("kind", [
527
+ z7.object({ kind: z7.literal("runners") }).strict(),
528
+ z7.object({ kind: z7.literal("models"), runner: modelDiscoveryRunnerSchema }).strict()
529
+ ]);
530
+ var discoveredRunnerSchema = providerStatusSchema.omit({ provider: true, profileId: true }).extend({ runner: modelDiscoveryRunnerSchema });
531
+ var discoveredRunnersSchema = z7.object({
532
+ scope: z7.literal("host-default-account"),
533
+ runners: z7.array(discoveredRunnerSchema)
534
+ });
535
+ var discoveryResponseSchema = z7.union([discoveredRunnersSchema, runnerModelCatalogResponseSchema]);
536
+ var modelChoicesSchema = z7.object({
537
+ runner: modelDiscoveryRunnerSchema,
538
+ requestedModel: z7.string(),
539
+ availableModels: z7.array(runnerModelOptionSchema),
540
+ otherRunners: z7.array(modelDiscoveryRunnerSchema)
541
+ });
542
+
63
543
  // ../contract/src/delegation.ts
64
- var workerOperationSchema = z3.enum(["spawn", "inspect", "steer", "stop", "destroy", "diff", "wait"]);
65
- var commitShaSchema = z3.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/);
66
- var requestHashSchema = z3.string().regex(/^[0-9a-f]{64}$/);
67
- var workerIdsSchema = z3.array(z3.uuid()).min(1).max(32).refine((ids) => new Set(ids).size === ids.length);
68
- var permissionsSchema = z3.array(workerOperationSchema).max(7).refine((operations) => new Set(operations).size === operations.length);
69
- var remainingSchema = z3.array(z3.enum(["process", "worktree", "branch"])).max(3).refine((resources) => new Set(resources).size === resources.length);
70
- var errorSchema = z3.string().max(2e3);
71
- var workerWorkspaceSchema = z3.object({
72
- ownerRunId: z3.uuid(),
73
- resourceId: z3.uuid(),
74
- kind: z3.literal("owned-isolated"),
544
+ import { z as z8 } from "zod";
545
+ var workerOperationSchema = z8.enum(["spawn", "inspect", "steer", "stop", "destroy", "diff", "wait"]);
546
+ var commitShaSchema = z8.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/);
547
+ var requestHashSchema = z8.string().regex(/^[0-9a-f]{64}$/);
548
+ var workerIdsSchema = z8.array(z8.uuid()).min(1).max(32).refine((ids) => new Set(ids).size === ids.length);
549
+ var permissionsSchema = z8.array(workerOperationSchema).max(7).refine((operations) => new Set(operations).size === operations.length);
550
+ var remainingSchema = z8.array(z8.enum(["process", "worktree", "branch"])).max(3).refine((resources) => new Set(resources).size === resources.length);
551
+ var errorSchema = z8.string().max(2e3);
552
+ var workerWorkspaceSchema = z8.object({
553
+ ownerRunId: z8.uuid(),
554
+ resourceId: z8.uuid(),
555
+ kind: z8.literal("owned-isolated"),
75
556
  /** Canonical creation path and original branch, never inferred from execution cwd. */
76
- path: z3.string().min(1),
77
- branch: z3.string().min(1),
557
+ path: z8.string().min(1),
558
+ branch: z8.string().min(1),
78
559
  baselineSha: commitShaSchema
79
560
  }).strict();
80
- var workerOutcomeSchema = z3.object({
81
- workerId: z3.uuid(),
82
- status: z3.enum(["review", "done", "failed", "cancelled"]),
83
- observedAt: z3.iso.datetime(),
84
- summary: z3.string().max(4e3).optional(),
85
- revision: z3.number().int().nonnegative().optional()
561
+ var workerOutcomeSchema = z8.object({
562
+ workerId: z8.uuid(),
563
+ status: z8.enum(["review", "done", "failed", "cancelled"]),
564
+ observedAt: z8.iso.datetime(),
565
+ summary: z8.string().max(4e3).optional(),
566
+ revision: z8.number().int().nonnegative().optional()
86
567
  }).strict();
87
- var workerWaitModeSchema = z3.enum(["one", "any", "all"]);
88
- var workerWaitSchema = z3.object({
89
- id: z3.uuid(),
90
- workerIds: z3.array(z3.uuid()).max(32).refine((ids) => new Set(ids).size === ids.length),
91
- requestIds: z3.array(z3.uuid()).min(1).max(32).optional(),
92
- requestOutcomes: z3.array(requestOutcomeSchema).max(32).optional(),
93
- deadline: z3.iso.datetime(),
568
+ var workerWaitModeSchema = z8.enum(["one", "any", "all"]);
569
+ var workerWaitSchema = z8.object({
570
+ id: z8.uuid(),
571
+ workerIds: z8.array(z8.uuid()).max(32).refine((ids) => new Set(ids).size === ids.length),
572
+ requestIds: z8.array(z8.uuid()).min(1).max(32).optional(),
573
+ requestOutcomes: z8.array(requestOutcomeSchema).max(32).optional(),
574
+ deadline: z8.iso.datetime(),
94
575
  mode: workerWaitModeSchema.optional(),
95
- revisions: z3.array(z3.object({ workerId: z3.uuid(), revision: z3.number().int().nonnegative() }).strict()).max(32).optional(),
96
- reason: z3.enum(["outcome", "timeout", "cancelled", "message"]).optional(),
97
- phase: z3.enum(["registered", "parked", "wake-pending"]),
98
- outcomes: z3.array(workerOutcomeSchema).max(32),
99
- wakeId: z3.uuid().optional()
576
+ revisions: z8.array(z8.object({ workerId: z8.uuid(), revision: z8.number().int().nonnegative() }).strict()).max(32).optional(),
577
+ reason: z8.enum(["outcome", "timeout", "cancelled", "message"]).optional(),
578
+ phase: z8.enum(["registered", "parked", "wake-pending"]),
579
+ outcomes: z8.array(workerOutcomeSchema).max(32),
580
+ wakeId: z8.uuid().optional()
100
581
  }).strict();
101
- var workerDestroySchema = z3.object({
102
- requestedAt: z3.iso.datetime(),
103
- phase: z3.enum(["requested", "terminating", "cleaning", "complete", "incomplete"]),
582
+ var workerDestroySchema = z8.object({
583
+ requestedAt: z8.iso.datetime(),
584
+ phase: z8.enum(["requested", "terminating", "cleaning", "complete", "incomplete"]),
104
585
  remaining: remainingSchema,
105
586
  error: errorSchema.optional()
106
587
  }).strict();
107
- var workerCreationReceiptSchema = z3.object({
108
- requestId: z3.uuid(),
109
- workerId: z3.uuid(),
588
+ var workerCreationReceiptSchema = z8.object({
589
+ requestId: z8.uuid(),
590
+ workerId: z8.uuid(),
110
591
  /** Hash of the original normalized spawn request, NOT the resolved commit or inherited settings. */
111
592
  requestHash: requestHashSchema,
112
- deletion: z3.object({ phase: z3.enum(["pending", "complete"]), revision: z3.number().int().nonnegative(), resourceId: z3.uuid(), generation: z3.uuid() }).strict().optional()
593
+ deletion: z8.object({ phase: z8.enum(["pending", "complete"]), revision: z8.number().int().nonnegative(), resourceId: z8.uuid(), generation: z8.uuid() }).strict().optional()
113
594
  }).strict();
114
- var workerBackendSchema = z3.enum(["claude", "codex", "opencode", "pi", "cursor"]);
115
- var relativeInputPath = z3.string().min(1).max(4096).refine((path) => !/[\\\u0000-\u001f\u007f:]/.test(path) && !path.startsWith("/") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".."));
116
- var workerContextReferenceSchema = z3.discriminatedUnion("kind", [
117
- z3.object({ kind: z3.literal("baseline-file"), path: relativeInputPath }).strict(),
118
- z3.object({ kind: z3.literal("parent-attachment"), id: z3.string().min(1).max(255).regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine((id) => !id.includes("..")) }).strict()
595
+ var workerBackendSchema = z8.enum(["claude", "codex", "opencode", "pi", "cursor"]);
596
+ var relativeInputPath = z8.string().min(1).max(4096).refine((path) => !/[\\\u0000-\u001f\u007f:]/.test(path) && !path.startsWith("/") && path.split("/").every((part) => part !== "" && part !== "." && part !== ".."));
597
+ var workerContextReferenceSchema = z8.discriminatedUnion("kind", [
598
+ z8.object({ kind: z8.literal("baseline-file"), path: relativeInputPath }).strict(),
599
+ z8.object({ kind: z8.literal("parent-attachment"), id: z8.string().min(1).max(255).regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine((id) => !id.includes("..")) }).strict()
119
600
  ]);
120
- var workerContextSchema = z3.object({
121
- text: z3.string().max(1e5).optional(),
122
- artifacts: z3.array(workerContextReferenceSchema).max(32).optional()
601
+ var workerContextSchema = z8.object({
602
+ text: z8.string().max(1e5).optional(),
603
+ artifacts: z8.array(workerContextReferenceSchema).max(32).optional()
123
604
  }).strict();
124
- var workerInputSchema = z3.object({
605
+ var workerInputSchema = z8.object({
125
606
  source: workerContextReferenceSchema,
126
- path: z3.string().min(1).max(8192),
607
+ path: z8.string().min(1).max(8192),
127
608
  /** Parent attachment: SHA-256 of copied bytes. Baseline file: SHA-256 of the pinned Git blob ID
128
609
  * (the lowercase hexadecimal ID as UTF-8 text), not of file contents. Interpret by source.kind. */
129
610
  sha256: requestHashSchema,
130
- bytes: z3.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
611
+ bytes: z8.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
131
612
  }).strict();
132
- var workerInputRecipeSchema = z3.object({
133
- text: z3.string().max(1e5).optional(),
134
- inputs: z3.array(workerInputSchema).max(32)
613
+ var workerInputRecipeSchema = z8.object({
614
+ text: z8.string().max(1e5).optional(),
615
+ inputs: z8.array(workerInputSchema).max(32)
135
616
  }).strict();
136
- var unavailableEvidenceSchema = z3.object({ state: z3.literal("unavailable"), reason: z3.enum(["no-assistant-output", "missing", "unreadable", "unverified"]), detail: errorSchema.optional() }).strict();
137
- var deletedEvidenceSchema = z3.object({ state: z3.literal("deleted"), reason: z3.literal("missing") }).strict();
138
- var executionOutcomeSchema = z3.enum(["running", "review-ready", "completed", "failed", "cancelled"]);
139
- var workerArtifactSchema = z3.discriminatedUnion("state", [
140
- z3.object({ state: z3.literal("available"), id: z3.string().max(255), path: z3.string().max(8192) }).strict(),
141
- unavailableEvidenceSchema.extend({ id: z3.string().max(255), path: z3.string().max(8192) }),
142
- deletedEvidenceSchema.extend({ id: z3.string().max(255), path: z3.string().max(8192) })
617
+ var unavailableEvidenceSchema = z8.object({ state: z8.literal("unavailable"), reason: z8.enum(["no-assistant-output", "missing", "unreadable", "unverified"]), detail: errorSchema.optional() }).strict();
618
+ var deletedEvidenceSchema = z8.object({ state: z8.literal("deleted"), reason: z8.literal("missing") }).strict();
619
+ var executionOutcomeSchema = z8.enum(["running", "review-ready", "completed", "failed", "cancelled"]);
620
+ var workerArtifactSchema = z8.discriminatedUnion("state", [
621
+ z8.object({ state: z8.literal("available"), id: z8.string().max(255), path: z8.string().max(8192) }).strict(),
622
+ unavailableEvidenceSchema.extend({ id: z8.string().max(255), path: z8.string().max(8192) }),
623
+ deletedEvidenceSchema.extend({ id: z8.string().max(255), path: z8.string().max(8192) })
143
624
  ]);
144
- var workerCollectedResultSchema = z3.object({
145
- workerId: z3.uuid(),
146
- parentRunId: z3.uuid(),
147
- revision: z3.number().int().nonnegative(),
148
- observedAt: z3.iso.datetime(),
149
- status: z3.enum(["queued", "running", "waiting", "review", "done", "failed", "cancelled"]),
150
- outcome: z3.enum(["running", "review-ready", "completed", "failed", "cancelled", "destroyed"]),
625
+ var workerCollectedResultSchema = z8.object({
626
+ workerId: z8.uuid(),
627
+ parentRunId: z8.uuid(),
628
+ revision: z8.number().int().nonnegative(),
629
+ observedAt: z8.iso.datetime(),
630
+ status: z8.enum(["queued", "running", "waiting", "review", "done", "failed", "cancelled"]),
631
+ outcome: z8.enum(["running", "review-ready", "completed", "failed", "cancelled", "destroyed"]),
151
632
  lastExecutionOutcome: executionOutcomeSchema,
152
- partial: z3.boolean(),
153
- settled: z3.boolean(),
633
+ partial: z8.boolean(),
634
+ settled: z8.boolean(),
154
635
  error: errorSchema.optional(),
155
636
  backend: workerBackendSchema.optional(),
156
- model: z3.string().max(512).optional(),
637
+ model: z8.string().max(512).optional(),
157
638
  baselineSha: commitShaSchema,
158
- workspace: workerWorkspaceSchema.extend({ state: z3.enum(["available", "unavailable", "deleted"]).optional() }),
159
- cleanup: z3.enum(["retained", "requested", "terminating", "cleaning", "complete", "incomplete"]),
160
- summary: z3.discriminatedUnion("state", [
161
- z3.object({ state: z3.literal("available"), text: z3.string().min(1).max(4e3), source: z3.literal("assistant"), seq: z3.number().int().nonnegative(), truncated: z3.boolean() }).strict(),
639
+ workspace: workerWorkspaceSchema.extend({ state: z8.enum(["available", "unavailable", "deleted"]).optional() }),
640
+ cleanup: z8.enum(["retained", "requested", "terminating", "cleaning", "complete", "incomplete"]),
641
+ summary: z8.discriminatedUnion("state", [
642
+ z8.object({ state: z8.literal("available"), text: z8.string().min(1).max(4e3), source: z8.literal("assistant"), seq: z8.number().int().nonnegative(), truncated: z8.boolean() }).strict(),
162
643
  unavailableEvidenceSchema,
163
644
  deletedEvidenceSchema
164
645
  ]),
165
- head: z3.discriminatedUnion("state", [
166
- z3.object({ state: z3.literal("available"), sha: commitShaSchema }).strict(),
646
+ head: z8.discriminatedUnion("state", [
647
+ z8.object({ state: z8.literal("available"), sha: commitShaSchema }).strict(),
167
648
  unavailableEvidenceSchema.extend({ sha: commitShaSchema.optional() }),
168
649
  deletedEvidenceSchema.extend({ sha: commitShaSchema.optional() })
169
650
  ]),
170
- diff: z3.discriminatedUnion("state", [
651
+ diff: z8.discriminatedUnion("state", [
171
652
  // path addresses a workerResultFileSchema JSON document; its diffSnapshot field contains the patch.
172
- z3.object({ state: z3.literal("available"), snapshotId: z3.uuid(), path: z3.string().min(1).max(8192), truncated: z3.boolean() }).strict(),
653
+ z8.object({ state: z8.literal("available"), snapshotId: z8.uuid(), path: z8.string().min(1).max(8192), truncated: z8.boolean() }).strict(),
173
654
  unavailableEvidenceSchema,
174
655
  deletedEvidenceSchema
175
656
  ]),
176
- artifacts: z3.discriminatedUnion("state", [
177
- z3.object({ state: z3.literal("available"), items: z3.array(workerArtifactSchema).max(32), truncated: z3.boolean() }).strict(),
657
+ artifacts: z8.discriminatedUnion("state", [
658
+ z8.object({ state: z8.literal("available"), items: z8.array(workerArtifactSchema).max(32), truncated: z8.boolean() }).strict(),
178
659
  unavailableEvidenceSchema,
179
660
  deletedEvidenceSchema
180
661
  ])
181
662
  }).strict();
182
- var workerResultFileSchema = z3.object({ result: workerCollectedResultSchema, diffSnapshot: z3.string().max(4e5).optional() }).strict();
183
- var workerResultReferenceSchema = z3.object({
184
- workerId: z3.uuid(),
185
- revision: z3.number().int().nonnegative(),
186
- snapshotId: z3.uuid(),
187
- observedAt: z3.iso.datetime(),
663
+ var workerResultFileSchema = z8.object({ result: workerCollectedResultSchema, diffSnapshot: z8.string().max(4e5).optional() }).strict();
664
+ var workerResultReferenceSchema = z8.object({
665
+ workerId: z8.uuid(),
666
+ revision: z8.number().int().nonnegative(),
667
+ snapshotId: z8.uuid(),
668
+ observedAt: z8.iso.datetime(),
188
669
  lastExecutionOutcome: executionOutcomeSchema,
189
- previous: z3.object({ revision: z3.number().int().nonnegative(), observedAt: z3.iso.datetime(), lastExecutionOutcome: executionOutcomeSchema }).strict().optional()
670
+ previous: z8.object({ revision: z8.number().int().nonnegative(), observedAt: z8.iso.datetime(), lastExecutionOutcome: executionOutcomeSchema }).strict().optional()
190
671
  }).strict();
191
- var delegationStateSchema = z3.discriminatedUnion("role", [
192
- z3.object({
193
- role: z3.literal("root"),
672
+ var delegationStateSchema = z8.discriminatedUnion("role", [
673
+ z8.object({
674
+ role: z8.literal("root"),
194
675
  conversation: conversationStateSchema.optional(),
195
676
  permissions: permissionsSchema,
196
- receipts: z3.array(workerCreationReceiptSchema).max(32).refine((receipts) => new Set(receipts.map((receipt) => receipt.requestId)).size === receipts.length && new Set(receipts.map((receipt) => receipt.workerId)).size === receipts.length),
677
+ receipts: z8.array(workerCreationReceiptSchema).max(32).refine((receipts) => new Set(receipts.map((receipt) => receipt.requestId)).size === receipts.length && new Set(receipts.map((receipt) => receipt.workerId)).size === receipts.length),
197
678
  wait: workerWaitSchema.optional(),
198
679
  lastWait: workerWaitSchema.optional(),
199
- results: z3.array(workerResultReferenceSchema).max(32).refine((results) => new Set(results.map((result) => result.workerId)).size === results.length).optional(),
200
- finishRequestedAt: z3.iso.datetime().optional(),
201
- historyDeletion: z3.literal("pending").optional(),
202
- completion: z3.object({ phase: z3.enum(["waiting", "attention"]), waitId: z3.uuid().optional() }).strict().optional()
680
+ results: z8.array(workerResultReferenceSchema).max(32).refine((results) => new Set(results.map((result) => result.workerId)).size === results.length).optional(),
681
+ finishRequestedAt: z8.iso.datetime().optional(),
682
+ historyDeletion: z8.literal("pending").optional(),
683
+ completion: z8.object({ phase: z8.enum(["waiting", "attention"]), waitId: z8.uuid().optional() }).strict().optional()
203
684
  }).strict(),
204
- z3.object({
205
- role: z3.literal("worker"),
685
+ z8.object({
686
+ role: z8.literal("worker"),
206
687
  wait: workerWaitSchema.optional(),
207
688
  lastWait: workerWaitSchema.optional(),
208
689
  permissions: permissionsSchema,
209
- parentRunId: z3.uuid(),
690
+ parentRunId: z8.uuid(),
210
691
  workspace: workerWorkspaceSchema,
211
692
  destroy: workerDestroySchema.optional(),
212
693
  context: workerInputRecipeSchema.optional(),
213
- executionRevision: z3.number().int().nonnegative().optional(),
214
- executionStartSeq: z3.number().int().nonnegative().optional()
694
+ executionRevision: z8.number().int().nonnegative().optional(),
695
+ executionStartSeq: z8.number().int().nonnegative().optional()
215
696
  }).strict(),
216
697
  // A persisted quarantine is distinct from absent legacy metadata and grants no authority.
217
- z3.object({ role: z3.literal("invalid") }).strict()
698
+ z8.object({ role: z8.literal("invalid") }).strict()
218
699
  ]);
219
- var runDelegationSummarySchema = z3.discriminatedUnion("role", [
700
+ var runDelegationSummarySchema = z8.discriminatedUnion("role", [
220
701
  delegationStateSchema.options[0].pick({ role: true }).strip().extend({
221
702
  wait: workerWaitSchema.pick({ phase: true, requestIds: true }).strip().optional()
222
703
  }),
@@ -225,74 +706,89 @@ var runDelegationSummarySchema = z3.discriminatedUnion("role", [
225
706
  }),
226
707
  delegationStateSchema.options[2].strip()
227
708
  ]);
228
- var workerSpawnRequestSchema = z3.object({
229
- task: z3.string().min(1).max(1e5),
230
- baseline: z3.string().min(1).max(1024),
231
- requestId: z3.uuid(),
709
+ var workerSpawnRequestSchema = z8.object({
710
+ task: z8.string().min(1).max(1e5),
711
+ baseline: z8.string().min(1).max(1024),
712
+ requestId: z8.uuid(),
232
713
  context: workerContextSchema.optional(),
233
714
  backend: workerBackendSchema.optional(),
234
- model: z3.string().trim().min(1).max(512).optional(),
715
+ model: z8.string().trim().min(1).max(512).optional(),
235
716
  effort: effortFieldSchema,
236
717
  /** Catalog workflow name (built-in quick-task or `.ai/cezar/workflows/*.yaml`, #451). Absent means quick-task. */
237
- workflow: z3.string().trim().min(1).max(200).optional()
718
+ workflow: z8.string().trim().min(1).max(200).optional()
238
719
  }).strict().refine((request) => request.task.length + (request.context?.text?.length ?? 0) <= 1e5, { message: "Combined task and context exceed 100000 characters" });
239
- var workerSteerRequestSchema = z3.object({
240
- text: z3.string().max(1e5).refine((text) => text.trim().length > 0)
720
+ var workerSteerRequestSchema = z8.object({
721
+ text: z8.string().max(1e5).refine((text) => text.trim().length > 0)
241
722
  }).strict();
242
- var workerWaitRequestSchema = z3.object({
723
+ var workerWaitRequestSchema = z8.object({
243
724
  workerIds: workerIdsSchema,
244
- timeoutSeconds: z3.number().int().min(1).max(1800).default(600),
725
+ timeoutSeconds: z8.number().int().min(1).max(1800).default(600),
245
726
  mode: workerWaitModeSchema.optional()
246
727
  }).strict().refine((request) => request.mode !== "one" || request.workerIds.length === 1, { message: "one mode requires exactly one worker" });
247
- var agentInputSchema = z3.object({
728
+ var inboxClaimSchema = z8.object({
729
+ receiptId: z8.uuid(),
730
+ generation: z8.uuid(),
731
+ expiresAt: z8.iso.datetime(),
732
+ acknowledgedAt: z8.iso.datetime().optional(),
733
+ /** Optional on read for receipts persisted before member manifests existed. */
734
+ memberIds: z8.array(z8.uuid()).min(1).max(32).refine((ids) => new Set(ids).size === ids.length).optional()
735
+ }).strict();
736
+ var agentInputSchema = z8.object({
248
737
  conversation: conversationAttributionSchema.optional(),
249
- id: z3.uuid(),
250
- source: z3.enum(["agent", "lifecycle"]),
251
- parentRunId: z3.uuid(),
252
- text: z3.string().min(1).max(1e5),
253
- createdAt: z3.iso.datetime(),
254
- deliveredAt: z3.iso.datetime().optional()
738
+ id: z8.uuid(),
739
+ source: z8.enum(["agent", "lifecycle"]),
740
+ parentRunId: z8.uuid(),
741
+ text: z8.string().min(1).max(1e5),
742
+ createdAt: z8.iso.datetime(),
743
+ deliveredAt: z8.iso.datetime().optional(),
744
+ /** The model received it, when the harness can show that (#505). Absent on
745
+ * unobservable backends and on records written before #505. */
746
+ consumedAt: z8.iso.datetime().optional(),
747
+ /** Accepted by a harness that reports reading, and not read yet. A restart replays
748
+ * such input; records written before #505 never carry it, so nothing historical replays. */
749
+ awaitingRead: z8.literal(true).optional(),
750
+ inboxClaim: inboxClaimSchema.optional()
255
751
  }).strict();
256
- var workerInspectionSchema = z3.object({
257
- workerId: z3.uuid(),
258
- parentRunId: z3.uuid(),
259
- status: z3.enum(["queued", "running", "waiting", ...workerOutcomeSchema.shape.status.options]),
260
- currentStepId: z3.string().optional(),
261
- activity: z3.enum(["monitoring"]).optional(),
752
+ var workerInspectionSchema = z8.object({
753
+ workerId: z8.uuid(),
754
+ parentRunId: z8.uuid(),
755
+ status: z8.enum(["queued", "running", "waiting", ...workerOutcomeSchema.shape.status.options]),
756
+ currentStepId: z8.string().optional(),
757
+ activity: z8.enum(["monitoring"]).optional(),
262
758
  workspace: workerWorkspaceSchema,
263
759
  backend: workerBackendSchema.optional(),
264
- model: z3.string().max(512).optional(),
265
- inputs: z3.array(workerInputSchema).max(32).optional(),
760
+ model: z8.string().max(512).optional(),
761
+ inputs: z8.array(workerInputSchema).max(32).optional(),
266
762
  wait: workerWaitSchema.optional(),
267
763
  destroy: workerDestroySchema.optional(),
268
764
  outcome: workerOutcomeSchema.optional()
269
765
  });
270
- var workerDiffSchema = z3.object({
271
- workerId: z3.uuid(),
766
+ var workerDiffSchema = z8.object({
767
+ workerId: z8.uuid(),
272
768
  baselineSha: commitShaSchema,
273
- diff: z3.string().max(4e5),
274
- truncated: z3.boolean()
275
- });
276
- var workerStopResultSchema = z3.object({
277
- workerId: z3.uuid(),
278
- state: z3.enum(["stopping", "terminated"])
279
- });
280
- var workerDestroyResultSchema = z3.object({
281
- workerId: z3.uuid(),
282
- state: z3.enum(["complete", "incomplete"]),
283
- deleted: z3.array(z3.discriminatedUnion("kind", [
284
- z3.object({ kind: z3.literal("worktree"), path: z3.string().max(8192) }).strict(),
285
- z3.object({ kind: z3.literal("branch"), ref: z3.string().max(1024) }).strict()
769
+ diff: z8.string().max(4e5),
770
+ truncated: z8.boolean()
771
+ });
772
+ var workerStopResultSchema = z8.object({
773
+ workerId: z8.uuid(),
774
+ state: z8.enum(["stopping", "terminated"])
775
+ });
776
+ var workerDestroyResultSchema = z8.object({
777
+ workerId: z8.uuid(),
778
+ state: z8.enum(["complete", "incomplete"]),
779
+ deleted: z8.array(z8.discriminatedUnion("kind", [
780
+ z8.object({ kind: z8.literal("worktree"), path: z8.string().max(8192) }).strict(),
781
+ z8.object({ kind: z8.literal("branch"), ref: z8.string().max(1024) }).strict()
286
782
  ])).max(2).optional(),
287
783
  remaining: remainingSchema,
288
784
  error: errorSchema.optional()
289
785
  });
290
- var runRelationshipsSchema = z3.object({
291
- parentRunId: z3.uuid().optional(),
292
- workers: z3.array(workerInspectionSchema).max(32)
786
+ var runRelationshipsSchema = z8.object({
787
+ parentRunId: z8.uuid().optional(),
788
+ workers: z8.array(workerInspectionSchema).max(32)
293
789
  });
294
- var delegationErrorResponseSchema = z3.object({
295
- code: z3.enum([
790
+ var delegationErrorResponseSchema = z8.object({
791
+ code: z8.enum([
296
792
  "unavailable_transport",
297
793
  "unauthenticated",
298
794
  "denied_scope",
@@ -303,98 +799,92 @@ var delegationErrorResponseSchema = z3.object({
303
799
  "unavailable_diff",
304
800
  "incomplete_cleanup"
305
801
  ]),
306
- error: errorSchema
307
- });
308
- var workerParamsSchema = z3.object({ workerId: z3.uuid() }).strict();
309
- var workerSpawnResultSchema = z3.object({ workerId: z3.uuid(), baselineSha: commitShaSchema }).strict();
310
- var workerSteerResultSchema = z3.object({ workerId: z3.uuid(), state: z3.enum(["queued", "delivered"]) }).strict();
311
- var workerWaitResultSchema = z3.object({ wait: workerWaitSchema, instruction: z3.string().min(1).max(1e3) }).strict();
312
- var workerEmptyRequestSchema = z3.object({}).strict();
313
- var workerCancelWaitRequestSchema = z3.object({ waitId: z3.uuid() }).strict();
314
- var workerCancelWaitResultSchema = z3.object({ wait: workerWaitSchema }).strict();
802
+ error: errorSchema,
803
+ modelChoices: modelChoicesSchema.optional()
804
+ });
805
+ var workerParamsSchema = z8.object({ workerId: z8.uuid() }).strict();
806
+ var workerSpawnResultSchema = z8.object({ workerId: z8.uuid(), baselineSha: commitShaSchema }).strict();
807
+ var workerSteerResultSchema = z8.object({ workerId: z8.uuid(), state: z8.enum(["queued", "delivered"]) }).strict();
808
+ var workerWaitResultSchema = z8.object({ wait: workerWaitSchema, instruction: z8.string().min(1).max(1e3) }).strict();
809
+ var workerEmptyRequestSchema = z8.object({}).strict();
810
+ var workerCancelWaitRequestSchema = z8.object({ waitId: z8.uuid() }).strict();
811
+ var workerCancelWaitResultSchema = z8.object({ wait: workerWaitSchema }).strict();
315
812
 
316
813
  // ../contract/src/events.ts
317
- var runEventSchema = z4.looseObject({
318
- seq: z4.number(),
319
- ts: z4.string(),
320
- stepId: z4.string().optional(),
321
- type: z4.string()
322
- });
323
- var conversationMessageEventSchema = runEventSchema.extend({ type: z4.literal("conversation-message"), message: conversationMessageSchema, delivery: z4.enum(["queued", "delivered", "not-delivered"]), deliveredAt: z4.iso.datetime().optional() });
324
- var requestOutcomeEventSchema = runEventSchema.extend({ type: z4.literal("request-outcome"), outcome: requestOutcomeSchema });
814
+ var runEventSchema = z9.looseObject({
815
+ seq: z9.number(),
816
+ ts: z9.string(),
817
+ stepId: z9.string().optional(),
818
+ type: z9.string()
819
+ });
820
+ var conversationMessageEventSchema = runEventSchema.extend({ type: z9.literal("conversation-message"), message: conversationMessageSchema, delivery: z9.enum(["queued", "delivered", "consumed", "not-delivered"]), deliveredAt: z9.iso.datetime().optional(), consumedAt: z9.iso.datetime().optional() });
821
+ var requestOutcomeEventSchema = runEventSchema.extend({ type: z9.literal("request-outcome"), outcome: requestOutcomeSchema });
325
822
  var agentInputEventSchema = runEventSchema.extend({
326
- type: z4.literal("agent-input"),
823
+ type: z9.literal("agent-input"),
327
824
  input: agentInputSchema
328
825
  });
329
826
  var humanInputDeliveredEventSchema = runEventSchema.extend({
330
- type: z4.literal("human-input-delivered"),
331
- askSeq: z4.number().int().nonnegative()
827
+ type: z9.literal("human-input-delivered"),
828
+ askSeq: z9.number().int().nonnegative(),
829
+ /** Who answered: absent (records before #505) or `human` is a person; `parent` is the
830
+ * owning parent's reply to a routed worker question. */
831
+ source: z9.enum(["human", "parent"]).optional()
832
+ });
833
+ var workerQuestionRoutedEventSchema = runEventSchema.extend({
834
+ type: z9.literal("worker-question-routed"),
835
+ askSeq: z9.number().int().nonnegative(),
836
+ messageId: z9.uuid(),
837
+ parentRunId: z9.uuid()
838
+ });
839
+ var workerQuestionFallbackEventSchema = runEventSchema.extend({
840
+ type: z9.literal("worker-question-fallback"),
841
+ askSeq: z9.number().int().nonnegative(),
842
+ reason: z9.string().min(1).max(200)
332
843
  });
333
844
  var workerOutcomeEventSchema = runEventSchema.extend({
334
- type: z4.literal("worker-outcome"),
845
+ type: z9.literal("worker-outcome"),
335
846
  outcome: workerOutcomeSchema
336
847
  });
337
848
  var RUN_HISTORY_PAGE_ITEMS = 100;
338
- var runIdParamSchema = z4.object({
339
- id: z4.string().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/)
849
+ var runIdParamSchema = z9.object({
850
+ id: z9.string().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/)
340
851
  });
341
- var runHistoryCursorSchema = z4.string().min(1).max(2048);
342
- var runHistoryQuerySchema = z4.object({
852
+ var runHistoryCursorSchema = z9.string().min(1).max(2048);
853
+ var runHistoryQuerySchema = z9.object({
343
854
  cursor: runHistoryCursorSchema.optional()
344
855
  });
345
- var runEventsQuerySchema = z4.object({
856
+ var runEventsQuerySchema = z9.object({
346
857
  cursor: runHistoryCursorSchema.optional(),
347
- afterSeq: z4.coerce.number().int().nonnegative().optional()
348
- });
349
- var runHistoryEventSchema = z4.object({
350
- seq: z4.number(),
351
- ts: z4.string(),
352
- stepId: z4.string().optional(),
353
- type: z4.string()
354
- }).catchall(z4.any());
355
- var runHistoryPageSchema = z4.object({
356
- events: z4.array(runHistoryEventSchema),
357
- itemCount: z4.number().int().min(0).max(RUN_HISTORY_PAGE_ITEMS),
858
+ afterSeq: z9.coerce.number().int().nonnegative().optional()
859
+ });
860
+ var runHistoryEventSchema = z9.object({
861
+ seq: z9.number(),
862
+ ts: z9.string(),
863
+ stepId: z9.string().optional(),
864
+ type: z9.string()
865
+ }).catchall(z9.any());
866
+ var runHistoryPageSchema = z9.object({
867
+ events: z9.array(runHistoryEventSchema),
868
+ itemCount: z9.number().int().min(0).max(RUN_HISTORY_PAGE_ITEMS),
358
869
  olderCursor: runHistoryCursorSchema.optional(),
359
870
  newerCursor: runHistoryCursorSchema.optional(),
360
871
  liveCursor: runHistoryCursorSchema,
361
- asOfSeq: z4.number().int().nonnegative(),
362
- hasOlder: z4.boolean()
872
+ asOfSeq: z9.number().int().nonnegative(),
873
+ hasOlder: z9.boolean()
363
874
  });
364
- var runHistoryContextSchema = z4.object({
365
- contextEvents: z4.array(runHistoryEventSchema),
366
- asOfSeq: z4.number().int().nonnegative()
875
+ var runHistoryContextSchema = z9.object({
876
+ contextEvents: z9.array(runHistoryEventSchema),
877
+ asOfSeq: z9.number().int().nonnegative()
367
878
  });
368
- var checkoutProgressEventSchema = z4.object({
369
- checkoutId: z4.string().optional(),
370
- name: z4.string(),
371
- phase: z4.enum(["cloning", "done", "error"]),
372
- line: z4.string().optional(),
373
- error: z4.string().optional()
879
+ var checkoutProgressEventSchema = z9.object({
880
+ checkoutId: z9.string().optional(),
881
+ name: z9.string(),
882
+ phase: z9.enum(["cloning", "done", "error"]),
883
+ line: z9.string().optional(),
884
+ error: z9.string().optional()
374
885
  });
375
886
 
376
887
  // ../contract/src/ask.ts
377
- import { z as z5 } from "zod";
378
- var askOptionSchema = z5.object({
379
- label: z5.string().min(1).max(60),
380
- description: z5.string().max(280).optional()
381
- }).strict();
382
- var askQuestionSchema = z5.object({
383
- /** Stable key for the answer; defaults to the array index when omitted. */
384
- id: z5.string().min(1).max(64).optional(),
385
- /** ≤12-char chip label (matches AskUserQuestion's `header`). */
386
- header: z5.string().min(1).max(12),
387
- question: z5.string().min(1).max(400),
388
- options: z5.array(askOptionSchema).min(2).max(4).refine((opts) => new Set(opts.map((o) => o.label)).size === opts.length, {
389
- message: "option labels must be unique within a question"
390
- }),
391
- multiSelect: z5.boolean().optional()
392
- }).strict();
393
- var askRequestSchema = z5.object({
394
- questions: z5.array(askQuestionSchema).min(1).max(4).refine((qs) => new Set(qs.map((q) => q.question)).size === qs.length, {
395
- message: "question texts must be unique"
396
- })
397
- }).strict();
398
888
  function advancePendingHumanAsk(pending, event) {
399
889
  if (event.type === "ask.requested" && typeof event.requestId === "string" && askRequestSchema.safeParse({ questions: event.questions }).success) return event;
400
890
  if (event.type === "human-input-delivered") {
@@ -409,102 +899,29 @@ function pendingHumanAsk(events) {
409
899
  return pending;
410
900
  }
411
901
 
412
- // ../contract/src/health.ts
413
- import { z as z6 } from "zod";
414
- var runnerSchema = z6.enum(["claude", "codex", "opencode", "pi", "cursor"]);
415
- var repoInfoSchema = z6.object({
416
- root: z6.string(),
417
- branch: z6.string(),
418
- remote: z6.string().optional()
419
- });
420
- var backendCheckSchema = z6.object({
421
- name: z6.enum(["claude", "codex", "opencode", "pi", "cursor", "gh", "git"]),
422
- available: z6.boolean(),
423
- version: z6.string().optional(),
424
- hint: z6.string().optional()
425
- });
426
- var forgeInfoSchema = z6.object({
427
- kind: z6.literal("github"),
428
- /**
429
- * Whether the forge is reachable — **absent until the availability probe has warmed**.
430
- *
431
- * Health must never pay a `gh` shell-out, so it serves whatever the cache holds. Absent means
432
- * "not determined yet", which is not the same as `false`, and the cockpit renders the two
433
- * differently. Declaring it required is what made an earlier hand-written mirror wrong.
434
- */
435
- available: z6.boolean().optional(),
436
- reason: z6.string().optional()
437
- });
438
- var capabilitiesSchema = z6.object({
439
- localHandoff: z6.boolean(),
440
- followups: z6.boolean(),
441
- singleProject: z6.boolean(),
442
- /**
443
- * `true` means `CEZ_AUTOMATIONS=1` opted this server into GitHub automations (#801). Off — the
444
- * default — the whole feature is absent: no `Automations` nav item anywhere it is rendered, the
445
- * `/api/v1/…/automations*` family answers `409`, and the workspace scheduler never polls GitHub.
446
- *
447
- * REQUIRED for the same reason as `tokenMetrics` below: this server always sends it.
448
- */
449
- automations: z6.boolean(),
450
- /**
451
- * `false` means `CEZ_HIDE_TOKEN_METRICS=1` asks the browser to omit token counts and monetary
452
- * cost (#481). The telemetry itself still rides in run/event payloads — this is presentation
453
- * only.
454
- *
455
- * REQUIRED, because this server always sends it (`capabilities.ts` computes it from the env on
456
- * every read) and this contract describes THIS server's wire. The DTO it replaces declared it
457
- * optional so a newer cockpit could read an OLDER server, which is version skew a contract
458
- * versioned in lockstep with the server cannot model. That tolerance lives where it belongs, in
459
- * `web/src/lib/token-metrics.ts`, whose `!== false` read still treats an absent field as
460
- * visible.
461
- */
462
- tokenMetrics: z6.boolean(),
463
- /** Current token-count presentation policy. Required on current servers;
464
- * older payload tolerance belongs in the browser resolver. */
465
- tokenUsageMetrics: z6.boolean(),
466
- /** Current backend-reported-cost presentation policy. */
467
- costMetrics: z6.boolean()
468
- });
469
- var healthResponseSchema = z6.object({
470
- version: z6.string(),
471
- latestVersion: z6.string().optional(),
472
- repoRoot: z6.string(),
473
- repo: repoInfoSchema.nullable(),
474
- checks: z6.array(backendCheckSchema),
475
- defaultRunner: runnerSchema,
476
- forge: forgeInfoSchema.nullable(),
477
- capabilities: capabilitiesSchema,
478
- // Always sent: `workspaceSummary()` returns both unconditionally, and an unreadable workspace
479
- // degrades to `projects: []` rather than to an absent key. The hand-written DTO declared them
480
- // optional, which was wider than the server has ever been.
481
- projects: z6.array(z6.object({ id: z6.string(), name: z6.string() })),
482
- bootProject: z6.string()
483
- });
484
-
485
902
  // ../contract/src/ci-wait.ts
486
- import { z as z7 } from "zod";
903
+ import { z as z10 } from "zod";
487
904
  var CI_WAIT_LIMITATION = "Passing reported checks does not prove that every expected workflow has appeared or that the PR is merge-ready. This observation is not merge approval.";
488
905
  var CI_WAIT_RECEIPT_INSTRUCTION = "End your turn to wait for CI; no marker is needed. " + CI_WAIT_LIMITATION;
489
906
  var prPattern = /^https:\/\/([a-zA-Z0-9](?:[a-zA-Z0-9.-]*[a-zA-Z0-9])?)\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)\/pull\/([1-9][0-9]*)$/;
490
- var ciPrUrlSchema = z7.string().max(2048).regex(prPattern).refine((value) => {
907
+ var ciPrUrlSchema = z10.string().max(2048).regex(prPattern).refine((value) => {
491
908
  const match = prPattern.exec(value);
492
909
  return !!match && Number.isSafeInteger(Number(match[4])) && match[3] !== "." && match[3] !== "..";
493
910
  }, "Expected an HTTPS GitHub PR URL with a positive integer PR number");
494
- var ciWaitRequestSchema = z7.object({
911
+ var ciWaitRequestSchema = z10.object({
495
912
  pr: ciPrUrlSchema,
496
- timeout_seconds: z7.number().int().min(1).max(7200).default(1800)
913
+ timeout_seconds: z10.number().int().min(1).max(7200).default(1800)
497
914
  }).strict();
498
- var sha = z7.string().regex(/^[0-9a-f]{40}$/i);
499
- var ciPrIdentitySchema = z7.object({
915
+ var sha = z10.string().regex(/^[0-9a-f]{40}$/i);
916
+ var ciPrIdentitySchema = z10.object({
500
917
  prUrl: ciPrUrlSchema,
501
- repository: z7.string().max(2048).regex(/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/),
502
- prNumber: z7.number().int().positive().max(Number.MAX_SAFE_INTEGER),
918
+ repository: z10.string().max(2048).regex(/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/),
919
+ prNumber: z10.number().int().positive().max(Number.MAX_SAFE_INTEGER),
503
920
  headSha: sha
504
921
  }).strict();
505
- var ciWaitOutcomeSchema = z7.enum(["passed", "failed", "cancelled", "skipped", "no_checks", "head_changed", "deadline", "error"]);
506
- var ciWaitErrorCodeSchema = z7.enum(["invalid_request", "unsupported_host", "gh_missing", "authentication", "inaccessible_pr", "malformed_data", "output_limit", "query_timeout", "command_failed", "wait_conflict", "capacity", "unavailable", "unauthorized", "persistence"]);
507
- var ciWaitErrorSchema = z7.object({ code: ciWaitErrorCodeSchema, message: z7.string().max(4096) }).strict();
922
+ var ciWaitOutcomeSchema = z10.enum(["passed", "failed", "cancelled", "skipped", "no_checks", "head_changed", "deadline", "error"]);
923
+ var ciWaitErrorCodeSchema = z10.enum(["invalid_request", "unsupported_host", "gh_missing", "authentication", "inaccessible_pr", "malformed_data", "output_limit", "query_timeout", "command_failed", "wait_conflict", "capacity", "unavailable", "unauthorized", "persistence"]);
924
+ var ciWaitErrorSchema = z10.object({ code: ciWaitErrorCodeSchema, message: z10.string().max(4096) }).strict();
508
925
  function utf8Bytes(value) {
509
926
  let bytes = 0;
510
927
  for (const char of value) {
@@ -513,113 +930,113 @@ function utf8Bytes(value) {
513
930
  }
514
931
  return bytes;
515
932
  }
516
- var ciWaitResultSchema = z7.object({
933
+ var ciWaitResultSchema = z10.object({
517
934
  outcome: ciWaitOutcomeSchema,
518
935
  headSha: sha,
519
936
  observedHeadSha: sha.optional(),
520
- observedAt: z7.iso.datetime(),
521
- checks: z7.array(z7.object({ name: z7.string().max(256), state: z7.string().max(256), link: z7.string().max(2048) }).strict()).max(100),
522
- totalChecks: z7.number().int().nonnegative(),
523
- truncated: z7.boolean(),
524
- diagnostic: z7.string().max(4096).refine((value) => utf8Bytes(value) <= 4096).optional()
937
+ observedAt: z10.iso.datetime(),
938
+ checks: z10.array(z10.object({ name: z10.string().max(256), state: z10.string().max(256), link: z10.string().max(2048) }).strict()).max(100),
939
+ totalChecks: z10.number().int().nonnegative(),
940
+ truncated: z10.boolean(),
941
+ diagnostic: z10.string().max(4096).refine((value) => utf8Bytes(value) <= 4096).optional()
525
942
  }).strict().refine((value) => utf8Bytes(JSON.stringify(value)) <= 32 * 1024, "CI result exceeds 32 KiB");
526
943
  var ciWaitSchema = ciPrIdentitySchema.extend({
527
- id: z7.uuid(),
528
- generation: z7.string().min(1).max(256),
529
- turnId: z7.string().min(1).max(256),
530
- timeoutSeconds: z7.number().int().min(1).max(7200),
531
- registeredAt: z7.iso.datetime(),
532
- deadline: z7.iso.datetime(),
533
- phase: z7.enum(["registered", "parked", "wake-pending", "delivered", "withdrawn"]),
944
+ id: z10.uuid(),
945
+ generation: z10.string().min(1).max(256),
946
+ turnId: z10.string().min(1).max(256),
947
+ timeoutSeconds: z10.number().int().min(1).max(7200),
948
+ registeredAt: z10.iso.datetime(),
949
+ deadline: z10.iso.datetime(),
950
+ phase: z10.enum(["registered", "parked", "wake-pending", "delivered", "withdrawn"]),
534
951
  result: ciWaitResultSchema.optional(),
535
- wakeId: z7.string().min(1).max(256).optional(),
536
- deliveredAt: z7.iso.datetime().optional()
952
+ wakeId: z10.string().min(1).max(256).optional(),
953
+ deliveredAt: z10.iso.datetime().optional()
537
954
  }).strict();
538
955
  var ciWaitReceiptSchema = ciPrIdentitySchema.extend({
539
- waitId: z7.uuid(),
540
- registeredAt: z7.iso.datetime(),
541
- deadline: z7.iso.datetime(),
956
+ waitId: z10.uuid(),
957
+ registeredAt: z10.iso.datetime(),
958
+ deadline: z10.iso.datetime(),
542
959
  phase: ciWaitSchema.shape.phase
543
960
  }).strict();
544
961
 
545
962
  // ../contract/src/runs.ts
546
- import { z as z10 } from "zod";
963
+ import { z as z13 } from "zod";
547
964
 
548
965
  // ../contract/src/github.ts
549
- import { z as z8 } from "zod";
550
- var checksGlyphSchema = z8.enum(["passing", "failing", "pending"]).nullable();
551
- var githubItemSchema = z8.object({
552
- kind: z8.enum(["issue", "pr"]),
553
- number: z8.number(),
554
- title: z8.string(),
555
- author: z8.string(),
556
- createdAt: z8.string(),
557
- labels: z8.array(z8.string()),
558
- body: z8.string(),
559
- url: z8.string(),
560
- comments: z8.number(),
966
+ import { z as z11 } from "zod";
967
+ var checksGlyphSchema = z11.enum(["passing", "failing", "pending"]).nullable();
968
+ var githubItemSchema = z11.object({
969
+ kind: z11.enum(["issue", "pr"]),
970
+ number: z11.number(),
971
+ title: z11.string(),
972
+ author: z11.string(),
973
+ createdAt: z11.string(),
974
+ labels: z11.array(z11.string()),
975
+ body: z11.string(),
976
+ url: z11.string(),
977
+ comments: z11.number(),
561
978
  /** Issues only; absent on older servers. */
562
- assignees: z8.array(z8.string()).optional(),
563
- projectIds: z8.array(z8.string()).optional(),
979
+ assignees: z11.array(z11.string()).optional(),
980
+ projectIds: z11.array(z11.string()).optional(),
564
981
  /** PRs only. */
565
- isDraft: z8.boolean().optional(),
566
- additions: z8.number().optional(),
567
- deletions: z8.number().optional(),
982
+ isDraft: z11.boolean().optional(),
983
+ additions: z11.number().optional(),
984
+ deletions: z11.number().optional(),
568
985
  checks: checksGlyphSchema.optional()
569
986
  });
570
- var githubProjectSchema = z8.object({
571
- id: z8.string(),
572
- title: z8.string(),
573
- url: z8.string()
987
+ var githubProjectSchema = z11.object({
988
+ id: z11.string(),
989
+ title: z11.string(),
990
+ url: z11.string()
574
991
  });
575
- var githubDataSchema = z8.object({
576
- available: z8.boolean(),
992
+ var githubDataSchema = z11.object({
993
+ available: z11.boolean(),
577
994
  /** Why it is unavailable (`gh` missing, no remote, offline…). Never an error — a hint. */
578
- reason: z8.string().optional(),
995
+ reason: z11.string().optional(),
579
996
  /** owner/name, when known. */
580
- repo: z8.string().optional(),
581
- syncedAt: z8.string().optional(),
582
- issues: z8.array(githubItemSchema),
583
- prs: z8.array(githubItemSchema),
997
+ repo: z11.string().optional(),
998
+ syncedAt: z11.string().optional(),
999
+ issues: z11.array(githubItemSchema),
1000
+ prs: z11.array(githubItemSchema),
584
1001
  /** Repo-wide label name → 6-hex color (no `#`); lets chips tint like GitHub. Additive. */
585
- labelColors: z8.record(z8.string(), z8.string()).optional(),
586
- viewerLogin: z8.string().optional(),
1002
+ labelColors: z11.record(z11.string(), z11.string()).optional(),
1003
+ viewerLogin: z11.string().optional(),
587
1004
  /** Repository-linked Projects v2. Absent when lookup is unavailable; [] means none. */
588
- projects: z8.array(githubProjectSchema).optional(),
589
- projectsReason: z8.string().optional()
1005
+ projects: z11.array(githubProjectSchema).optional(),
1006
+ projectsReason: z11.string().optional()
590
1007
  });
591
- var githubChecksDataSchema = z8.discriminatedUnion("available", [
592
- z8.object({
593
- available: z8.literal(true),
594
- checks: z8.record(z8.number(), checksGlyphSchema)
1008
+ var githubChecksDataSchema = z11.discriminatedUnion("available", [
1009
+ z11.object({
1010
+ available: z11.literal(true),
1011
+ checks: z11.record(z11.number(), checksGlyphSchema)
595
1012
  }),
596
- z8.object({
597
- available: z8.literal(false),
598
- reason: z8.string()
1013
+ z11.object({
1014
+ available: z11.literal(false),
1015
+ reason: z11.string()
599
1016
  })
600
1017
  ]);
601
1018
  var GITHUB_SEARCH_MAX = 50;
602
- var githubSearchQuerySchema = z8.object({
603
- kind: z8.enum(["issue", "pr"]),
604
- q: z8.string().trim().min(1).max(256),
605
- limit: z8.coerce.number().int().positive().max(GITHUB_SEARCH_MAX).optional()
1019
+ var githubSearchQuerySchema = z11.object({
1020
+ kind: z11.enum(["issue", "pr"]),
1021
+ q: z11.string().trim().min(1).max(256),
1022
+ limit: z11.coerce.number().int().positive().max(GITHUB_SEARCH_MAX).optional()
606
1023
  });
607
- var githubSearchDataSchema = z8.object({
608
- available: z8.boolean(),
1024
+ var githubSearchDataSchema = z11.object({
1025
+ available: z11.boolean(),
609
1026
  /** Membership is unknown when lookup fails; never substitute empty projectIds. */
610
- projectsReason: z8.string().optional(),
1027
+ projectsReason: z11.string().optional(),
611
1028
  /** Why it could not search (`gh` missing, no remote, rate-limited…). A hint, never an error. */
612
- reason: z8.string().optional(),
1029
+ reason: z11.string().optional(),
613
1030
  /** The same rows the list ships. `checks` is always `null` here — hydrated lazily through
614
1031
  * `/github/checks`, exactly as list rows have been since #664. */
615
- items: z8.array(githubItemSchema),
1032
+ items: z11.array(githubItemSchema),
616
1033
  /** The hit list filled the server's cap; there may be more matches on the forge. */
617
- truncated: z8.boolean().optional(),
1034
+ truncated: z11.boolean().optional(),
618
1035
  /** Label name → 6-hex color for the labels these hits carry. A closed item often wears labels
619
1036
  * no open one does, which the repo-wide map from the list call would not cover. Additive. */
620
- labelColors: z8.record(z8.string(), z8.string()).optional()
1037
+ labelColors: z11.record(z11.string(), z11.string()).optional()
621
1038
  });
622
- var referenceStatusSchema = z8.enum([
1039
+ var referenceStatusSchema = z11.enum([
623
1040
  "draft",
624
1041
  "review-required",
625
1042
  "changes-requested",
@@ -632,13 +1049,13 @@ var referenceStatusSchema = z8.enum([
632
1049
  "completed",
633
1050
  "not-planned"
634
1051
  ]);
635
- var recheckAfterMsSchema = z8.number().nullable();
1052
+ var recheckAfterMsSchema = z11.number().nullable();
636
1053
  var REFERENCE_STATUS_MAX = 100;
637
- var githubRefStatusDataSchema = z8.discriminatedUnion("available", [
638
- z8.object({
639
- available: z8.literal(true),
640
- prs: z8.record(z8.number(), referenceStatusSchema),
641
- issues: z8.record(z8.number(), referenceStatusSchema),
1054
+ var githubRefStatusDataSchema = z11.discriminatedUnion("available", [
1055
+ z11.object({
1056
+ available: z11.literal(true),
1057
+ prs: z11.record(z11.number(), referenceStatusSchema),
1058
+ issues: z11.record(z11.number(), referenceStatusSchema),
642
1059
  /**
643
1060
  * The pull request numbers that do NOT merge cleanly into their base right now.
644
1061
  *
@@ -658,28 +1075,28 @@ var githubRefStatusDataSchema = z8.discriminatedUnion("available", [
658
1075
  * ever named — GitHub reports `UNKNOWN` for merged and closed ones, and `UNKNOWN` (which is
659
1076
  * also what it answers while it is still computing) is never listed.
660
1077
  */
661
- conflicts: z8.array(z8.number()).optional(),
1078
+ conflicts: z11.array(z11.number()).optional(),
662
1079
  recheckAfterMs: recheckAfterMsSchema
663
1080
  }),
664
- z8.object({
665
- available: z8.literal(false),
666
- reason: z8.string(),
1081
+ z11.object({
1082
+ available: z11.literal(false),
1083
+ reason: z11.string(),
667
1084
  recheckAfterMs: recheckAfterMsSchema
668
1085
  })
669
1086
  ]);
670
- var githubCommentSchema = z8.object({
671
- id: z8.number(),
1087
+ var githubCommentSchema = z11.object({
1088
+ id: z11.number(),
672
1089
  /** Author login, `'?'` fallback when gh omits the user. */
673
- author: z8.string(),
674
- avatarUrl: z8.string().optional(),
675
- createdAt: z8.string(),
676
- body: z8.string(),
677
- kind: z8.enum(["comment", "review"]),
1090
+ author: z11.string(),
1091
+ avatarUrl: z11.string().optional(),
1092
+ createdAt: z11.string(),
1093
+ body: z11.string(),
1094
+ kind: z11.enum(["comment", "review"]),
678
1095
  /** Reviews only — drives the state chip. */
679
- reviewState: z8.enum(["approved", "changes_requested", "commented", "dismissed"]).optional(),
680
- url: z8.string()
1096
+ reviewState: z11.enum(["approved", "changes_requested", "commented", "dismissed"]).optional(),
1097
+ url: z11.string()
681
1098
  });
682
- var githubTimelineEventKindSchema = z8.enum([
1099
+ var githubTimelineEventKindSchema = z11.enum([
683
1100
  "committed",
684
1101
  "labeled",
685
1102
  "unlabeled",
@@ -692,134 +1109,134 @@ var githubTimelineEventKindSchema = z8.enum([
692
1109
  "cross-referenced",
693
1110
  "renamed"
694
1111
  ]);
695
- var githubTimelineEventSchema = z8.object({
696
- id: z8.string(),
1112
+ var githubTimelineEventSchema = z11.object({
1113
+ id: z11.string(),
697
1114
  kind: githubTimelineEventKindSchema,
698
1115
  /** Login — or the git author name for `committed`, which carries no GitHub actor. */
699
- actor: z8.string(),
1116
+ actor: z11.string(),
700
1117
  /** Absent for `committed`. */
701
- avatarUrl: z8.string().optional(),
702
- createdAt: z8.string(),
703
- url: z8.string().optional(),
1118
+ avatarUrl: z11.string().optional(),
1119
+ createdAt: z11.string(),
1120
+ url: z11.string().optional(),
704
1121
  /** `committed` — full 40-char SHA. */
705
- sha: z8.string().optional(),
1122
+ sha: z11.string().optional(),
706
1123
  /** `committed` — first line, capped at 120 chars. */
707
- message: z8.string().optional(),
1124
+ message: z11.string().optional(),
708
1125
  /** `committed` — **absent** (lookup failed/skipped) and **`null`** (no CI configured) both
709
1126
  * render no glyph, but stay distinct values. */
710
1127
  checks: checksGlyphSchema.optional(),
711
- label: z8.object({ name: z8.string(), color: z8.string().optional() }).optional(),
1128
+ label: z11.object({ name: z11.string(), color: z11.string().optional() }).optional(),
712
1129
  /** `assigned`/`unassigned` login, or the new title for `renamed`. */
713
- subject: z8.string().optional(),
714
- refNumber: z8.number().optional(),
715
- refTitle: z8.string().optional(),
716
- refIsPr: z8.boolean().optional()
717
- });
718
- var githubCommentsDataSchema = z8.object({
719
- available: z8.boolean(),
720
- reason: z8.string().optional(),
1130
+ subject: z11.string().optional(),
1131
+ refNumber: z11.number().optional(),
1132
+ refTitle: z11.string().optional(),
1133
+ refIsPr: z11.boolean().optional()
1134
+ });
1135
+ var githubCommentsDataSchema = z11.object({
1136
+ available: z11.boolean(),
1137
+ reason: z11.string().optional(),
721
1138
  /** Chronological, oldest first. */
722
- comments: z8.array(githubCommentSchema),
1139
+ comments: z11.array(githubCommentSchema),
723
1140
  /** True when either stream hit its cap, or the timeline fetch stopped short. */
724
- truncated: z8.boolean().optional(),
1141
+ truncated: z11.boolean().optional(),
725
1142
  /** Timeline events (#525) — additive; absent when the server degraded to the legacy
726
1143
  * comments-only fetch. Capped independently of `comments`. */
727
- events: z8.array(githubTimelineEventSchema).optional()
728
- });
729
- var githubMergeMethodSchema = z8.enum(["merge", "squash", "rebase"]);
730
- var githubPrCheckSchema = z8.object({
731
- name: z8.string(),
732
- state: z8.enum(["passing", "failing", "pending", "unknown"]),
733
- required: z8.boolean().nullable(),
734
- url: z8.string().optional()
735
- });
736
- var githubPrMergeStateSchema = z8.object({
737
- number: z8.number(),
738
- title: z8.string(),
739
- url: z8.string(),
740
- state: z8.enum(["open", "closed", "merged"]),
741
- isDraft: z8.boolean(),
742
- headRef: z8.string(),
743
- baseRef: z8.string(),
744
- headSha: z8.string(),
745
- mergeable: z8.enum(["mergeable", "conflicting", "unknown"]),
746
- reviewDecision: z8.enum(["approved", "changes-requested", "review-required", "unknown"]),
747
- checks: z8.array(githubPrCheckSchema),
748
- methods: z8.array(githubMergeMethodSchema),
1144
+ events: z11.array(githubTimelineEventSchema).optional()
1145
+ });
1146
+ var githubMergeMethodSchema = z11.enum(["merge", "squash", "rebase"]);
1147
+ var githubPrCheckSchema = z11.object({
1148
+ name: z11.string(),
1149
+ state: z11.enum(["passing", "failing", "pending", "unknown"]),
1150
+ required: z11.boolean().nullable(),
1151
+ url: z11.string().optional()
1152
+ });
1153
+ var githubPrMergeStateSchema = z11.object({
1154
+ number: z11.number(),
1155
+ title: z11.string(),
1156
+ url: z11.string(),
1157
+ state: z11.enum(["open", "closed", "merged"]),
1158
+ isDraft: z11.boolean(),
1159
+ headRef: z11.string(),
1160
+ baseRef: z11.string(),
1161
+ headSha: z11.string(),
1162
+ mergeable: z11.enum(["mergeable", "conflicting", "unknown"]),
1163
+ reviewDecision: z11.enum(["approved", "changes-requested", "review-required", "unknown"]),
1164
+ checks: z11.array(githubPrCheckSchema),
1165
+ methods: z11.array(githubMergeMethodSchema),
749
1166
  defaultMethod: githubMergeMethodSchema.nullable(),
750
- eligibility: z8.enum(["ready", "blocked", "pending", "unauthorized", "terminal", "unknown"]),
751
- blockers: z8.array(z8.object({ code: z8.string(), message: z8.string() })),
752
- canMerge: z8.boolean(),
753
- canOverride: z8.boolean()
754
- });
755
- var githubPrMergeStateResponseSchema = z8.discriminatedUnion("available", [
756
- z8.object({ available: z8.literal(true), mergeState: githubPrMergeStateSchema }),
757
- z8.object({ available: z8.literal(false), reason: z8.string() })
1167
+ eligibility: z11.enum(["ready", "blocked", "pending", "unauthorized", "terminal", "unknown"]),
1168
+ blockers: z11.array(z11.object({ code: z11.string(), message: z11.string() })),
1169
+ canMerge: z11.boolean(),
1170
+ canOverride: z11.boolean()
1171
+ });
1172
+ var githubPrMergeStateResponseSchema = z11.discriminatedUnion("available", [
1173
+ z11.object({ available: z11.literal(true), mergeState: githubPrMergeStateSchema }),
1174
+ z11.object({ available: z11.literal(false), reason: z11.string() })
758
1175
  ]);
759
- var githubMergeResponseSchema = z8.object({
760
- merged: z8.literal(true),
761
- number: z8.number(),
762
- url: z8.string(),
1176
+ var githubMergeResponseSchema = z11.object({
1177
+ merged: z11.literal(true),
1178
+ number: z11.number(),
1179
+ url: z11.string(),
763
1180
  method: githubMergeMethodSchema,
764
- mergeCommitSha: z8.string().optional()
765
- });
766
- var githubPrChangeSchema = z8.object({
767
- path: z8.string(),
768
- previousPath: z8.string().optional(),
769
- status: z8.enum(["added", "modified", "removed", "renamed", "copied", "changed"]),
770
- additions: z8.number(),
771
- deletions: z8.number(),
772
- patch: z8.string().optional(),
773
- patchUnavailableReason: z8.enum(["binary", "too-large", "not-provided"]).optional(),
774
- truncated: z8.boolean().optional()
775
- });
776
- var githubPrChangesDataSchema = z8.discriminatedUnion("available", [
777
- z8.object({
778
- available: z8.literal(true),
779
- number: z8.number(),
780
- headSha: z8.string(),
781
- files: z8.array(githubPrChangeSchema),
782
- additions: z8.number(),
783
- deletions: z8.number(),
784
- truncated: z8.boolean(),
1181
+ mergeCommitSha: z11.string().optional()
1182
+ });
1183
+ var githubPrChangeSchema = z11.object({
1184
+ path: z11.string(),
1185
+ previousPath: z11.string().optional(),
1186
+ status: z11.enum(["added", "modified", "removed", "renamed", "copied", "changed"]),
1187
+ additions: z11.number(),
1188
+ deletions: z11.number(),
1189
+ patch: z11.string().optional(),
1190
+ patchUnavailableReason: z11.enum(["binary", "too-large", "not-provided"]).optional(),
1191
+ truncated: z11.boolean().optional()
1192
+ });
1193
+ var githubPrChangesDataSchema = z11.discriminatedUnion("available", [
1194
+ z11.object({
1195
+ available: z11.literal(true),
1196
+ number: z11.number(),
1197
+ headSha: z11.string(),
1198
+ files: z11.array(githubPrChangeSchema),
1199
+ additions: z11.number(),
1200
+ deletions: z11.number(),
1201
+ truncated: z11.boolean(),
785
1202
  /** Present when the payload is complete but partial in some other way (a capped patch). */
786
- reason: z8.string().optional()
1203
+ reason: z11.string().optional()
787
1204
  }),
788
- z8.object({ available: z8.literal(false), reason: z8.string() })
1205
+ z11.object({ available: z11.literal(false), reason: z11.string() })
789
1206
  ]);
790
1207
 
791
1208
  // ../contract/src/workflows.ts
792
- import { z as z9 } from "zod";
793
- var workflowStepDefSchema = z9.object({
794
- id: z9.string().min(1),
795
- name: z9.string().optional(),
1209
+ import { z as z12 } from "zod";
1210
+ var workflowStepDefSchema = z12.object({
1211
+ id: z12.string().min(1),
1212
+ name: z12.string().optional(),
796
1213
  // agent step
797
- prompt: z9.string().optional(),
798
- skill: z9.string().optional(),
799
- model: z9.string().optional(),
800
- effort: z9.string().max(32).optional(),
1214
+ prompt: z12.string().optional(),
1215
+ skill: z12.string().optional(),
1216
+ model: z12.string().optional(),
1217
+ effort: z12.string().max(32).optional(),
801
1218
  /** Per-step agent backend override (falls back to the task / config default). */
802
1219
  runner: runnerSchema.optional(),
803
1220
  /** Agent account id for this step (spec 2026-07-29-agent-profiles); resolved per step for owned workers (#452). */
804
- agentProfile: z9.string().min(1).max(64).optional(),
805
- allowedTools: z9.array(z9.string()).optional(),
806
- bashAllowlist: z9.array(z9.string()).optional(),
1221
+ agentProfile: z12.string().min(1).max(64).optional(),
1222
+ allowedTools: z12.array(z12.string()).optional(),
1223
+ bashAllowlist: z12.array(z12.string()).optional(),
807
1224
  // check step
808
- command: z9.string().optional(),
809
- onFail: z9.object({
810
- retry: z9.string().min(1),
811
- max: z9.number().int().positive().default(2)
1225
+ command: z12.string().optional(),
1226
+ onFail: z12.object({
1227
+ retry: z12.string().min(1),
1228
+ max: z12.number().int().positive().default(2)
812
1229
  }).optional()
813
1230
  }).refine((s) => Boolean(s.command) !== Boolean(s.prompt ?? s.skill), {
814
1231
  message: "a step is either an agent step (prompt/skill) or a check step (command), not both"
815
1232
  });
816
- var workflowDefSchema = z9.object({
817
- name: z9.string(),
818
- description: z9.string().optional(),
819
- steps: z9.array(workflowStepDefSchema),
820
- source: z9.enum(["built-in", "file"]),
1233
+ var workflowDefSchema = z12.object({
1234
+ name: z12.string(),
1235
+ description: z12.string().optional(),
1236
+ steps: z12.array(workflowStepDefSchema),
1237
+ source: z12.enum(["built-in", "file"]),
821
1238
  /** Absent on built-ins — which is exactly what makes them undeletable. */
822
- path: z9.string().optional()
1239
+ path: z12.string().optional()
823
1240
  });
824
1241
  function providersRequiredByWorkflow(workflow, fallback) {
825
1242
  const required = /* @__PURE__ */ new Set();
@@ -828,46 +1245,46 @@ function providersRequiredByWorkflow(workflow, fallback) {
828
1245
  }
829
1246
  return runnerSchema.options.filter((provider) => required.has(provider));
830
1247
  }
831
- var workflowLoadIssueSchema = z9.object({
832
- path: z9.string(),
833
- message: z9.string()
834
- });
835
- var workflowsResponseSchema = z9.object({
836
- workflows: z9.array(workflowDefSchema),
837
- issues: z9.array(workflowLoadIssueSchema)
838
- });
839
- var saveWorkflowInputSchema = z9.object({
840
- name: z9.string().trim().min(1).max(80),
841
- description: z9.string().max(2e3, "must be at most 2000 characters").optional(),
842
- steps: z9.array(workflowStepDefSchema).min(1).max(8).optional(),
843
- skills: z9.array(z9.string().trim().min(1)).min(1).max(8).optional(),
844
- overwrite: z9.boolean().optional()
1248
+ var workflowLoadIssueSchema = z12.object({
1249
+ path: z12.string(),
1250
+ message: z12.string()
1251
+ });
1252
+ var workflowsResponseSchema = z12.object({
1253
+ workflows: z12.array(workflowDefSchema),
1254
+ issues: z12.array(workflowLoadIssueSchema)
1255
+ });
1256
+ var saveWorkflowInputSchema = z12.object({
1257
+ name: z12.string().trim().min(1).max(80),
1258
+ description: z12.string().max(2e3, "must be at most 2000 characters").optional(),
1259
+ steps: z12.array(workflowStepDefSchema).min(1).max(8).optional(),
1260
+ skills: z12.array(z12.string().trim().min(1)).min(1).max(8).optional(),
1261
+ overwrite: z12.boolean().optional()
845
1262
  }).refine((b) => Boolean(b.steps) !== Boolean(b.skills), {
846
1263
  message: 'provide either "steps" or "skills", not both'
847
1264
  });
848
- var saveWorkflowResponseSchema = z9.object({
849
- path: z9.string(),
850
- name: z9.string()
1265
+ var saveWorkflowResponseSchema = z12.object({
1266
+ path: z12.string(),
1267
+ name: z12.string()
851
1268
  });
852
- var parsedWorkflowSchema = z9.object({
853
- name: z9.string(),
854
- description: z9.string().optional(),
855
- steps: z9.array(workflowStepDefSchema)
1269
+ var parsedWorkflowSchema = z12.object({
1270
+ name: z12.string(),
1271
+ description: z12.string().optional(),
1272
+ steps: z12.array(workflowStepDefSchema)
856
1273
  });
857
- var deleteWorkflowResponseSchema = z9.object({
858
- ok: z9.literal(true),
859
- path: z9.string()
1274
+ var deleteWorkflowResponseSchema = z12.object({
1275
+ ok: z12.literal(true),
1276
+ path: z12.string()
860
1277
  });
861
- var planResponseSchema = z9.object({
1278
+ var planResponseSchema = z12.object({
862
1279
  /** The kebab-case workflow title the planner proposed. Absent on the degraded fallback. */
863
- name: z9.string().optional(),
864
- steps: z9.array(workflowStepDefSchema),
865
- rationale: z9.string(),
866
- fallback: z9.boolean()
1280
+ name: z12.string().optional(),
1281
+ steps: z12.array(workflowStepDefSchema),
1282
+ rationale: z12.string(),
1283
+ fallback: z12.boolean()
867
1284
  });
868
1285
 
869
1286
  // ../contract/src/runs.ts
870
- var runStatusSchema = z10.enum([
1287
+ var runStatusSchema = z13.enum([
871
1288
  "queued",
872
1289
  "running",
873
1290
  "waiting",
@@ -876,8 +1293,8 @@ var runStatusSchema = z10.enum([
876
1293
  "failed",
877
1294
  "cancelled"
878
1295
  ]);
879
- var runActivitySchema = z10.enum(["monitoring"]);
880
- var stepStatusSchema = z10.enum([
1296
+ var runActivitySchema = z13.enum(["monitoring"]);
1297
+ var stepStatusSchema = z13.enum([
881
1298
  "pending",
882
1299
  "running",
883
1300
  "waiting",
@@ -887,16 +1304,16 @@ var stepStatusSchema = z10.enum([
887
1304
  "cancelled",
888
1305
  "skipped"
889
1306
  ]);
890
- var usageCounterSchema = z10.number().finite().nonnegative();
891
- var stepStateSchema = z10.object({
892
- id: z10.string(),
893
- name: z10.string(),
894
- kind: z10.enum(["agent", "check"]),
1307
+ var usageCounterSchema = z13.number().finite().nonnegative();
1308
+ var stepStateSchema = z13.object({
1309
+ id: z13.string(),
1310
+ name: z13.string(),
1311
+ kind: z13.enum(["agent", "check"]),
895
1312
  status: stepStatusSchema,
896
- iterations: z10.number(),
1313
+ iterations: z13.number(),
897
1314
  /** Durable count of onFail retry loops consumed by this check. */
898
- retriesUsed: z10.number().int().nonnegative().optional(),
899
- tokensUsed: z10.number(),
1315
+ retriesUsed: z13.number().int().nonnegative().optional(),
1316
+ tokensUsed: z13.number(),
900
1317
  inputTokens: usageCounterSchema.optional(),
901
1318
  outputTokens: usageCounterSchema.optional(),
902
1319
  usageInvocationsStarted: usageCounterSchema.optional(),
@@ -904,99 +1321,103 @@ var stepStateSchema = z10.object({
904
1321
  usageTurnsStarted: usageCounterSchema.optional(),
905
1322
  usageTurnsRecorded: usageCounterSchema.optional(),
906
1323
  usageInvocationEpoch: usageCounterSchema.optional(),
907
- startedAt: z10.string().optional(),
908
- finishedAt: z10.string().optional(),
909
- error: z10.string().optional(),
1324
+ startedAt: z13.string().optional(),
1325
+ finishedAt: z13.string().optional(),
1326
+ error: z13.string().optional(),
910
1327
  /** Latest agent session id — `claude --resume <id>` and friends. */
911
- sessionId: z10.string().optional(),
1328
+ sessionId: z13.string().optional(),
912
1329
  /** Backend that owns `sessionId`; absent on records written before backend affinity. */
913
1330
  backend: runnerSchema.optional(),
914
1331
  /** Agent account (spec 2026-07-29-agent-profiles) that owns `sessionId` — `default`, or a
915
1332
  * stored profile id. The two are a PAIR: a session id only resolves inside the config dir
916
1333
  * that created it, so resume and Continue read this rather than the project's current
917
1334
  * selection. Absent on records written before accounts existed. */
918
- profileId: z10.string().optional(),
919
- costUsd: z10.number().optional(),
1335
+ profileId: z13.string().optional(),
1336
+ costUsd: z13.number().optional(),
920
1337
  /** Explicit provenance for engine-generated continuation steps. */
921
- synthetic: z10.literal("continuation").optional()
1338
+ synthetic: z13.literal("continuation").optional()
922
1339
  });
923
- var diffStatSchema = z10.object({
924
- adds: z10.number(),
925
- dels: z10.number(),
926
- files: z10.number(),
1340
+ var diffStatSchema = z13.object({
1341
+ adds: z13.number(),
1342
+ dels: z13.number(),
1343
+ files: z13.number(),
927
1344
  /** Additive since #751, and present ONLY when true: the numbers were measured against a
928
1345
  * branch the agent checked out into the task's worktree, as the run found it, because the
929
1346
  * worktree's HEAD had been repointed off the task's own branch (every review/QA run does
930
1347
  * this) and the merge-base anchor would otherwise have reported that branch's entire diff
931
1348
  * as this task's. Absent on every normal run and on every record written before #751 — a
932
1349
  * consumer that ignores it sees exactly the old shape. */
933
- repointed: z10.boolean().optional()
1350
+ repointed: z13.boolean().optional()
934
1351
  });
935
- var queuedMessageSchema = z10.object({
936
- id: z10.string(),
937
- text: z10.string(),
1352
+ var queuedMessageSchema = z13.object({
1353
+ id: z13.string(),
1354
+ text: z13.string(),
938
1355
  /** `/api/v1/runs/:id/images/…` URLs — attachments are persisted, never inlined. Images and
939
1356
  * files share this one list; read `isImageAttachmentName` on the file name to tell them apart. */
940
- images: z10.array(z10.string()).optional(),
941
- createdAt: z10.string()
1357
+ images: z13.array(z13.string()).optional(),
1358
+ createdAt: z13.string()
942
1359
  });
943
1360
  var continuationMessageSchema = queuedMessageSchema.extend({
944
- origin: z10.enum(["human", "lifecycle"]).optional(),
1361
+ origin: z13.enum(["human", "lifecycle"]).optional(),
945
1362
  /** An attributed parent message used as the opening prompt, never a human answer. */
946
- agentInputId: z10.uuid().optional()
1363
+ agentInputId: z13.uuid().optional()
947
1364
  });
948
- var processUsageSchema = z10.object({
1365
+ var processUsageSchema = z13.object({
949
1366
  /** Sum of `%cpu` across the tree — can exceed 100 on multi-core work. */
950
- cpuPct: z10.number(),
951
- rssBytes: z10.number(),
952
- procCount: z10.number()
1367
+ cpuPct: z13.number(),
1368
+ rssBytes: z13.number(),
1369
+ procCount: z13.number()
953
1370
  });
954
- var runRecordSchema = z10.object({
955
- id: z10.string(),
956
- title: z10.string(),
1371
+ var runWebhookOutcomeSchema = z13.object({
1372
+ lastDeliveredAt: z13.string().optional(),
1373
+ lastError: z13.string().max(512).optional()
1374
+ });
1375
+ var runRecordSchema = z13.object({
1376
+ id: z13.string(),
1377
+ title: z13.string(),
957
1378
  /** Display title (#389): auto-derived from the first agent turn, or the user's inline edit
958
1379
  * (`PATCH /runs/:id` sets it together with `title`). Show `titleSummary ?? title`. */
959
- titleSummary: z10.string().optional(),
1380
+ titleSummary: z13.string().optional(),
960
1381
  /** Refreshed on every turn-end; absent until the first turn ends (and on worktree-less runs). */
961
1382
  diffStat: diffStatSchema.optional(),
962
- workflow: z10.string(),
963
- task: z10.string(),
1383
+ workflow: z13.string(),
1384
+ task: z13.string(),
964
1385
  /** Prompt messages stacked onto the run while it waited for a free agent slot (#472). Folded
965
1386
  * into the prompt at dequeue — never delivered as their own turns. Absent on pre-#472 runs. */
966
- queuedMessages: z10.array(queuedMessageSchema).optional(),
1387
+ queuedMessages: z13.array(queuedMessageSchema).optional(),
967
1388
  /** Stop was accepted; execution termination is still pending. */
968
- stopping: z10.boolean().optional(),
1389
+ stopping: z13.boolean().optional(),
969
1390
  /** Opening Continue message, retained until its first completed turn for crash recovery. */
970
1391
  continuationMessage: continuationMessageSchema.optional(),
971
1392
  /** The last turn carried a malformed explicit structured question. */
972
- invalidAsk: z10.boolean().optional(),
1393
+ invalidAsk: z13.boolean().optional(),
973
1394
  /** Owned-run authority; absence is legacy, invalid is explicitly quarantined. */
974
1395
  delegation: delegationStateSchema.optional(),
975
1396
  /** Durable non-human input, kept separate from human prompt/answer queues. */
976
- agentInputs: z10.array(agentInputSchema).optional(),
1397
+ agentInputs: z13.array(agentInputSchema).optional(),
977
1398
  ciWait: ciWaitSchema.optional(),
978
1399
  lastCiWait: ciWaitSchema.optional(),
979
1400
  /** Retained recovery observation when previous CI metadata cannot be trusted. */
980
- lastCiWaitError: z10.string().max(256).optional(),
1401
+ lastCiWaitError: z13.string().max(256).optional(),
981
1402
  /** URLs of images and document attachments on the initial task prompt; branch on isImageAttachmentName. */
982
- taskImages: z10.array(z10.string()).optional(),
983
- model: z10.string().optional(),
1403
+ taskImages: z13.array(z13.string()).optional(),
1404
+ model: z13.string().optional(),
984
1405
  /** Reasoning-effort pin (#45). Canonical `low`/`medium`/`high`/`xhigh`/`max`.
985
1406
  * Absent = harness default. Additive: pre-#45 records omit it and still parse. */
986
- effort: z10.string().max(32).optional(),
1407
+ effort: z13.string().max(32).optional(),
987
1408
  /** Normalized provider/model identity used for attribution and reproducible replay. */
988
- modelIdentity: z10.string().optional(),
1409
+ modelIdentity: z13.string().optional(),
989
1410
  runner: runnerSchema.optional(),
990
1411
  /** The composer's per-task agent account (spec 2026-07-29-agent-profiles), applying to steps
991
1412
  * on `runner`. Absent = the run follows the project's own selection. */
992
- agentProfile: z10.string().optional(),
1413
+ agentProfile: z13.string().optional(),
993
1414
  /** Echo of the extra system prompt the run used (POST override or config default). */
994
- systemPrompt: z10.string().optional(),
1415
+ systemPrompt: z13.string().optional(),
995
1416
  /** false when the run deliberately disabled follow-up todo generation. Absent means enabled. */
996
- generateFollowups: z10.boolean().optional(),
1417
+ generateFollowups: z13.boolean().optional(),
997
1418
  /** Autonomous mode (#autonomous): the run never parks at `waiting` or the terminal `review`
998
1419
  * gate. Absent = falsy = not autonomous. */
999
- autonomous: z10.boolean().optional(),
1420
+ autonomous: z13.boolean().optional(),
1000
1421
  /**
1001
1422
  * Provenance for a task a project GitHub automation launched (#694). Absent on every ordinary
1002
1423
  * run, which is what makes it additive — the cockpit shows the "from automation" link only when
@@ -1006,97 +1427,107 @@ var runRecordSchema = z10.object({
1006
1427
  * launching definition matched, recorded on the run for the audit trail, and `src/runs/store.ts`
1007
1428
  * persists it as free text so an older cezar can still read a record written by a newer one.
1008
1429
  */
1009
- automation: z10.object({
1010
- automationId: z10.string(),
1011
- automationRevision: z10.number(),
1012
- receiptId: z10.string(),
1013
- event: z10.string(),
1014
- githubUrl: z10.string()
1430
+ automation: z13.object({
1431
+ automationId: z13.string(),
1432
+ automationRevision: z13.number(),
1433
+ receiptId: z13.string(),
1434
+ event: z13.string(),
1435
+ githubUrl: z13.string()
1015
1436
  }).optional(),
1437
+ /** Task webhook opt-in (#589): the project's webhook receives this run's status changes.
1438
+ * Absent = off. Changes after start through `POST /runs/:id/notify`, which is why it is not
1439
+ * part of the idempotent-start hash. */
1440
+ notify: z13.boolean().optional(),
1441
+ /** The last webhook delivery's outcome (#589). Absent until a delivery was attempted. */
1442
+ webhook: runWebhookOutcomeSchema.optional(),
1016
1443
  status: runStatusSchema,
1017
1444
  /** `monitoring` while `status === 'running'` and the agent is working on downstream work.
1018
1445
  * Absent on old runs; cleared on resume/end. */
1019
1446
  activity: runActivitySchema.optional(),
1020
1447
  /** Derived from valid human questions and matching delivery receipts in durable history.
1021
1448
  * List attention only; never authorization to deliver an answer or wake a worker. */
1022
- hasPendingHumanAsk: z10.boolean().optional(),
1449
+ hasPendingHumanAsk: z13.boolean().optional(),
1023
1450
  /** Exact ISO-8601 deadline for the next automatic monitoring check. */
1024
- monitoringWakeAt: z10.string().optional(),
1451
+ monitoringWakeAt: z13.string().optional(),
1025
1452
  /** The current live monitoring epoch exhausted its 40 automatic checks. */
1026
- monitoringWakeCapReached: z10.boolean().optional(),
1453
+ monitoringWakeCapReached: z13.boolean().optional(),
1027
1454
  /** Exact ISO-8601 instant this run resumes itself after a provider usage limit stopped it
1028
1455
  * (spec 2026-08-03-auto-resume-after-usage-limit). Present only on a `failed` run with a
1029
1456
  * pending automatic resume — its absence is what "no resume is scheduled" looks like. */
1030
- autoResumeAt: z10.string().optional(),
1457
+ autoResumeAt: z13.string().optional(),
1031
1458
  /** Consecutive automatic resumes since the last human turn, against the safety cap. */
1032
- autoResumeAttempts: z10.number().optional(),
1033
- createdAt: z10.string(),
1034
- startedAt: z10.string().optional(),
1035
- finishedAt: z10.string().optional(),
1036
- tokensUsed: z10.number(),
1459
+ autoResumeAttempts: z13.number().optional(),
1460
+ createdAt: z13.string(),
1461
+ startedAt: z13.string().optional(),
1462
+ finishedAt: z13.string().optional(),
1463
+ tokensUsed: z13.number(),
1037
1464
  inputTokens: usageCounterSchema.optional(),
1038
1465
  outputTokens: usageCounterSchema.optional(),
1039
- costUsd: z10.number().optional(),
1040
- pullRequestUrl: z10.string().optional(),
1466
+ costUsd: z13.number().optional(),
1467
+ pullRequestUrl: z13.string().optional(),
1041
1468
  /** The PR this task is ABOUT (#407) — auto-discovered from conversation references. Display
1042
1469
  * tier only: `pullRequestUrl` (the PR this task CREATED) wins, and the action gates ignore it. */
1043
- referencedPullRequestUrl: z10.string().optional(),
1470
+ referencedPullRequestUrl: z13.string().optional(),
1044
1471
  /** The PR/issue number this task is ABOUT (task auto-naming spec) — display tier only. */
1045
- prNumber: z10.number().optional(),
1046
- issueNumber: z10.number().optional(),
1472
+ prNumber: z13.number().optional(),
1473
+ issueNumber: z13.number().optional(),
1047
1474
  /** Server-side provenance: referenced-issue discovery currently owns `issueNumber`. */
1048
- referencedIssueNumberSeeded: z10.boolean().optional(),
1475
+ referencedIssueNumberSeeded: z13.boolean().optional(),
1049
1476
  /** 'user' = renamed via PATCH, never auto-overwritten; 'marker' = agent-declared via
1050
1477
  * CEZ:TITLE (spec 2026-07-18-task-ref-markers); 'auto' = namer-owned. */
1051
- titleOrigin: z10.enum(["user", "auto", "marker"]).optional(),
1478
+ titleOrigin: z13.enum(["user", "auto", "marker"]).optional(),
1052
1479
  /** References the agent declared via CEZ:PR/CEZ:ISSUE markers — authoritative over the namer
1053
1480
  * for the matching kind. */
1054
- markerRefs: z10.object({ pr: z10.number().optional(), issue: z10.number().optional() }).optional(),
1481
+ markerRefs: z13.object({ pr: z13.number().optional(), issue: z13.number().optional() }).optional(),
1055
1482
  /** The referenced tier's working set (distinct PR URLs spotted, capped server-side). */
1056
- referencedPrCandidates: z10.array(z10.string()).optional(),
1483
+ referencedPrCandidates: z13.array(z13.string()).optional(),
1057
1484
  /** The issue this task is ABOUT (spec 2026-07-21-report-ref-discovery). Display-only. */
1058
- referencedIssueUrl: z10.string().optional(),
1485
+ referencedIssueUrl: z13.string().optional(),
1059
1486
  /** The referenced-issue working set, persisted like `referencedPrCandidates`. Capped. */
1060
- referencedIssueCandidates: z10.array(z10.string()).optional(),
1487
+ referencedIssueCandidates: z13.array(z13.string()).optional(),
1061
1488
  /** Explicit execution policy. `false` means the run intentionally uses the repo root;
1062
1489
  * absent on older runs and for the default isolated-worktree mode. */
1063
- worktree: z10.literal(false).optional(),
1490
+ worktree: z13.literal(false).optional(),
1064
1491
  /** Absent for in-place runs and after an isolated worktree is removed. */
1065
- worktreePath: z10.string().optional(),
1066
- branch: z10.string().optional(),
1492
+ worktreePath: z13.string().optional(),
1493
+ branch: z13.string().optional(),
1067
1494
  /** Stable baseline for session git views: a worktree's fork ref, or an in-place run's starting commit. */
1068
- baseBranch: z10.string().optional(),
1495
+ baseBranch: z13.string().optional(),
1069
1496
  /** Set when count-based retention (#483) reclaimed the worktree DIRECTORY (the branch is
1070
1497
  * kept): the dir is gone but recoverable. */
1071
- worktreeReclaimedAt: z10.string().optional(),
1498
+ worktreeReclaimedAt: z13.string().optional(),
1072
1499
  /** Parallel variants (spec 010): runs sharing a groupId are one group. */
1073
- groupId: z10.string().optional(),
1500
+ groupId: z13.string().optional(),
1074
1501
  /** Variant letter within the group — 'A' | 'B' | 'C'. */
1075
- variant: z10.string().optional(),
1076
- peakRssBytes: z10.number().optional(),
1077
- peakProcCount: z10.number().optional(),
1078
- archived: z10.boolean(),
1079
- archivedAt: z10.string().optional(),
1502
+ variant: z13.string().optional(),
1503
+ /** Idempotent start (#504): the caller's request id and the hash of the start payload it
1504
+ * named (`src/runs/client-request.ts`). Absent on every run started without one. */
1505
+ clientRequestId: z13.string().optional(),
1506
+ clientRequestHash: z13.string().optional(),
1507
+ peakRssBytes: z13.number().optional(),
1508
+ peakProcCount: z13.number().optional(),
1509
+ archived: z13.boolean(),
1510
+ archivedAt: z13.string().optional(),
1080
1511
  /** Pinned to the top of this project's task list (#935) — the `Pinned` group above
1081
1512
  * `Needs you`. Optional, unlike `archived`: absent IS "not pinned", which is what every
1082
1513
  * record written before this carries, and the store never writes `false`. Archiving
1083
1514
  * clears it, because archiving is how a user resigns from a task. */
1084
- pinned: z10.boolean().optional(),
1515
+ pinned: z13.boolean().optional(),
1085
1516
  /** When the pin was set. Deliberately WRITE-ONLY today, like the `archivedAt` above it:
1086
1517
  * ordering inside `Pinned` uses the ordinary status/recency rules, so nothing reads this
1087
1518
  * yet. It is here because a field on a protected surface is far cheaper to add now than to
1088
1519
  * add later — "pinned oldest first" and "unpin what you pinned a month ago" both need it,
1089
1520
  * and neither can be reconstructed after the fact. */
1090
- pinnedAt: z10.string().optional(),
1521
+ pinnedAt: z13.string().optional(),
1091
1522
  /** Read receipt (#unread-done-items): ISO time the cockpit last opened this run's
1092
1523
  * thread. A finished (`done`/`failed`) run reads as *unread* until seen since it
1093
1524
  * finished — see `isUnread()` in the cockpit's `lib/read-state.ts`. Absent on old
1094
1525
  * runs, on any run not yet opened, and on one deliberately put back to unread via
1095
1526
  * `POST /runs/:id/unread` (#775) — all three count as unread. */
1096
- seenAt: z10.string().optional(),
1097
- currentStepId: z10.string().optional(),
1098
- error: z10.string().optional(),
1099
- steps: z10.array(stepStateSchema),
1527
+ seenAt: z13.string().optional(),
1528
+ currentStepId: z13.string().optional(),
1529
+ error: z13.string().optional(),
1530
+ steps: z13.array(stepStateSchema),
1100
1531
  /**
1101
1532
  * The persisted workflow definition, so a `queued` run survives a restart — including the ad-hoc
1102
1533
  * "(planned)" chains that exist nowhere else.
@@ -1114,48 +1545,48 @@ var runRecordSchema = z10.object({
1114
1545
  var apiRunSchema = runRecordSchema.extend({
1115
1546
  /** Read-only GET /runs/:id verdict: null permits Finish, a string explains refusal.
1116
1547
  * Absent on lists, stored records and mutation responses; absence is not permission. */
1117
- finishBlocked: z10.string().nullable().optional(),
1548
+ finishBlocked: z13.string().nullable().optional(),
1118
1549
  /** Server-resolved Cursor CLI command, including the configured executable. Never persisted. */
1119
- cliResumeCommand: z10.string().optional(),
1550
+ cliResumeCommand: z13.string().optional(),
1120
1551
  usage: processUsageSchema.optional()
1121
1552
  });
1122
- var runIndexEntrySchema = z10.object({
1553
+ var runIndexEntrySchema = z13.object({
1123
1554
  /** The registered project this run belongs to. Joins against `GET /projects`. */
1124
- projectId: z10.string(),
1125
- id: z10.string(),
1126
- title: z10.string(),
1127
- titleSummary: z10.string().optional(),
1128
- titleOrigin: z10.enum(["user", "auto", "marker"]).optional(),
1555
+ projectId: z13.string(),
1556
+ id: z13.string(),
1557
+ title: z13.string(),
1558
+ titleSummary: z13.string().optional(),
1559
+ titleOrigin: z13.enum(["user", "auto", "marker"]).optional(),
1129
1560
  status: runStatusSchema,
1130
1561
  activity: runActivitySchema.optional(),
1131
1562
  hasPendingHumanAsk: runRecordSchema.shape.hasPendingHumanAsk,
1132
1563
  /** Only the relationship role and wait phase used by list attention. */
1133
1564
  delegation: runDelegationSummarySchema.optional(),
1134
- createdAt: z10.string(),
1135
- finishedAt: z10.string().optional(),
1565
+ createdAt: z13.string(),
1566
+ finishedAt: z13.string().optional(),
1136
1567
  /** With `status`/`finishedAt`/`archived`, the four inputs `isUnread` reads — what lets the
1137
1568
  * palette lead with "finished while you weren't looking" across every project, not just the
1138
1569
  * one you happen to be standing in. */
1139
- seenAt: z10.string().optional(),
1570
+ seenAt: z13.string().optional(),
1140
1571
  /** Always present, like `RunRecord.archived`: absent would read as "not archived", and the
1141
1572
  * unread rule treats archiving as a stronger "done with this" than reading. */
1142
- archived: z10.boolean(),
1573
+ archived: z13.boolean(),
1143
1574
  /** A run parked by a provider usage limit is `failed` on the record with a resume booked
1144
1575
  * (spec 2026-08-03-auto-resume-after-usage-limit). Both `deriveAttention` and `isUnread` read
1145
1576
  * it, so without it here a cross-project row would show a red "failed" dot and land in
1146
1577
  * Recently finished for work that is simply waiting for its appointment. */
1147
- autoResumeAt: z10.string().optional(),
1578
+ autoResumeAt: z13.string().optional(),
1148
1579
  /** The workflow the run executes — the global Tasks page shows it in a column and groups by
1149
1580
  * it. Always present on the record (`RunRecord.workflow`), so required here; the display
1150
1581
  * refinement `workflowLabel` applies needs `steps[]`, which this row deliberately omits, so
1151
1582
  * a `(planned)` chain reads as itself here rather than as its first agent's name. */
1152
- workflow: z10.string(),
1583
+ workflow: z13.string(),
1153
1584
  /** The task's branch, when it has one — a column on the global page, and the one field that
1154
1585
  * makes a cross-project row identifiable at a glance without opening it. */
1155
- branch: z10.string().optional(),
1586
+ branch: z13.string().optional(),
1156
1587
  /** When the agent actually started, as opposed to when the task was created. The global page's
1157
1588
  * age column prefers it and falls back to `createdAt`, exactly as the per-project table does. */
1158
- startedAt: z10.string().optional(),
1589
+ startedAt: z13.string().optional(),
1159
1590
  /**
1160
1591
  * The six fields `taskReference()` (`web/src/lib/tasks-table.ts`) reads to decide a task's PR
1161
1592
  * or issue chip. Carried verbatim rather than pre-resolved into a `{kind, number, url}` on the
@@ -1167,20 +1598,20 @@ var runIndexEntrySchema = z10.object({
1167
1598
  * Six scalars is still the slim row this schema exists to keep: `steps[]` and `workflowDef`,
1168
1599
  * the expensive half, stay off it.
1169
1600
  */
1170
- pullRequestUrl: z10.string().optional(),
1171
- referencedPullRequestUrl: z10.string().optional(),
1172
- prNumber: z10.number().optional(),
1173
- issueNumber: z10.number().optional(),
1174
- referencedIssueUrl: z10.string().optional(),
1175
- markerRefs: z10.object({ pr: z10.number().optional(), issue: z10.number().optional() }).optional(),
1601
+ pullRequestUrl: z13.string().optional(),
1602
+ referencedPullRequestUrl: z13.string().optional(),
1603
+ prNumber: z13.number().optional(),
1604
+ issueNumber: z13.number().optional(),
1605
+ referencedIssueUrl: z13.string().optional(),
1606
+ markerRefs: z13.object({ pr: z13.number().optional(), issue: z13.number().optional() }).optional(),
1176
1607
  /** What the run has cost so far. Absent means nothing was recorded, which is NOT `$0` — the
1177
1608
  * cockpit prints an em dash rather than claiming a measurement that never happened. */
1178
- costUsd: z10.number().optional(),
1609
+ costUsd: z13.number().optional(),
1179
1610
  /** The persisted high-water marks a FINISHED run leaves behind. `usage` below stops existing
1180
1611
  * the moment the process tree does, so without these a finished row could say nothing at all
1181
1612
  * about what it took to run. */
1182
- peakRssBytes: z10.number().optional(),
1183
- peakProcCount: z10.number().optional(),
1613
+ peakRssBytes: z13.number().optional(),
1614
+ peakProcCount: z13.number().optional(),
1184
1615
  /**
1185
1616
  * The live CPU/RSS sample of this run's process tree, attached on the way out exactly as
1186
1617
  * `GET /runs` attaches it (`withUsage`) — never persisted.
@@ -1192,90 +1623,90 @@ var runIndexEntrySchema = z10.object({
1192
1623
  */
1193
1624
  usage: processUsageSchema.optional()
1194
1625
  });
1195
- var referenceStatusesByProjectSchema = z10.record(
1196
- z10.string(),
1197
- z10.object({
1198
- prs: z10.record(z10.number(), referenceStatusSchema),
1199
- issues: z10.record(z10.number(), referenceStatusSchema)
1626
+ var referenceStatusesByProjectSchema = z13.record(
1627
+ z13.string(),
1628
+ z13.object({
1629
+ prs: z13.record(z13.number(), referenceStatusSchema),
1630
+ issues: z13.record(z13.number(), referenceStatusSchema)
1200
1631
  })
1201
1632
  );
1202
- var runsIndexResponseSchema = z10.object({
1633
+ var runsIndexResponseSchema = z13.object({
1203
1634
  /** Newest first, across every registered project. Archived runs are included — `GET /runs`
1204
1635
  * carries them for the project you are standing in, and a finder that dropped them elsewhere
1205
1636
  * would make a task vanish the moment you left its project. */
1206
- runs: z10.array(runIndexEntrySchema),
1637
+ runs: z13.array(runIndexEntrySchema),
1207
1638
  /** Additive: absent statuses mean "nothing warm", never "nothing to show". */
1208
1639
  referenceStatuses: referenceStatusesByProjectSchema,
1209
1640
  /** The per-project cap that produced this list. */
1210
- perProjectLimit: z10.number(),
1641
+ perProjectLimit: z13.number(),
1211
1642
  /** Ids of the projects that had more runs than the cap allowed. */
1212
- truncated: z10.array(z10.string())
1643
+ truncated: z13.array(z13.string())
1213
1644
  });
1214
- var createRunResponseSchema = z10.union([
1645
+ var createRunResponseSchema = z13.union([
1215
1646
  runRecordSchema,
1216
- z10.object({ runs: z10.array(runRecordSchema) })
1647
+ z13.object({ runs: z13.array(runRecordSchema) })
1217
1648
  ]);
1218
- var cancelResponseSchema = z10.object({ cancelled: z10.boolean() });
1219
- var cancelAutoResumeResponseSchema = z10.object({ cancelled: z10.literal(true) });
1220
- var archiveFinishedResponseSchema = z10.object({ archived: z10.number() });
1221
- var markAllReadResponseSchema = z10.object({ read: z10.number() });
1222
- var deleteRunResponseSchema = z10.object({ deleted: z10.literal(true) });
1223
- var finishResponseSchema = z10.object({ finished: z10.literal(true) });
1224
- var continueResponseSchema = z10.object({ continued: z10.literal(true) });
1225
- var createPrResponseSchema = z10.object({
1226
- url: z10.string(),
1227
- dryRun: z10.boolean()
1228
- });
1229
- var messageResponseSchema = z10.union([
1230
- z10.object({ delivered: z10.literal(true) }),
1231
- z10.object({ queued: z10.literal(true), message: queuedMessageSchema }),
1232
- z10.object({ deferred: z10.literal(true) })
1649
+ var cancelResponseSchema = z13.object({ cancelled: z13.boolean() });
1650
+ var cancelAutoResumeResponseSchema = z13.object({ cancelled: z13.literal(true) });
1651
+ var archiveFinishedResponseSchema = z13.object({ archived: z13.number() });
1652
+ var markAllReadResponseSchema = z13.object({ read: z13.number() });
1653
+ var deleteRunResponseSchema = z13.object({ deleted: z13.literal(true) });
1654
+ var finishResponseSchema = z13.object({ finished: z13.literal(true) });
1655
+ var continueResponseSchema = z13.object({ continued: z13.literal(true) });
1656
+ var createPrResponseSchema = z13.object({
1657
+ url: z13.string(),
1658
+ dryRun: z13.boolean()
1659
+ });
1660
+ var messageResponseSchema = z13.union([
1661
+ z13.object({ delivered: z13.literal(true) }),
1662
+ z13.object({ queued: z13.literal(true), message: queuedMessageSchema }),
1663
+ z13.object({ deferred: z13.literal(true) })
1233
1664
  ]);
1234
- var editQueuedMessageResponseSchema = z10.object({ message: queuedMessageSchema });
1235
- var removeQueuedMessageResponseSchema = z10.object({ removed: z10.literal(true) });
1236
- var openInCliResponseSchema = z10.object({
1237
- opened: z10.literal(true),
1238
- command: z10.string()
1239
- });
1240
- var removeWorktreeResponseSchema = z10.object({ removed: z10.literal(true) });
1241
- var gitCommitResponseSchema = z10.object({
1242
- committed: z10.literal(true),
1243
- sha: z10.string()
1244
- });
1245
- var gitPushResponseSchema = z10.object({
1246
- pushed: z10.literal(true),
1247
- branch: z10.string(),
1248
- remote: z10.string(),
1249
- upstreamSet: z10.boolean()
1250
- });
1251
- var runCommitSchema = z10.object({
1252
- sha: z10.string(),
1253
- subject: z10.string(),
1254
- author: z10.string(),
1665
+ var editQueuedMessageResponseSchema = z13.object({ message: queuedMessageSchema });
1666
+ var removeQueuedMessageResponseSchema = z13.object({ removed: z13.literal(true) });
1667
+ var openInCliResponseSchema = z13.object({
1668
+ opened: z13.literal(true),
1669
+ command: z13.string()
1670
+ });
1671
+ var removeWorktreeResponseSchema = z13.object({ removed: z13.literal(true) });
1672
+ var gitCommitResponseSchema = z13.object({
1673
+ committed: z13.literal(true),
1674
+ sha: z13.string()
1675
+ });
1676
+ var gitPushResponseSchema = z13.object({
1677
+ pushed: z13.literal(true),
1678
+ branch: z13.string(),
1679
+ remote: z13.string(),
1680
+ upstreamSet: z13.boolean()
1681
+ });
1682
+ var runCommitSchema = z13.object({
1683
+ sha: z13.string(),
1684
+ subject: z13.string(),
1685
+ author: z13.string(),
1255
1686
  /** Relative time ("3 hours ago") — git's `%cr`. */
1256
- when: z10.string()
1687
+ when: z13.string()
1257
1688
  });
1258
- var runCommitsResponseSchema = z10.object({ commits: z10.array(runCommitSchema) });
1259
- var groupVariantSchema = z10.object({
1260
- id: z10.string(),
1689
+ var runCommitsResponseSchema = z13.object({ commits: z13.array(runCommitSchema) });
1690
+ var groupVariantSchema = z13.object({
1691
+ id: z13.string(),
1261
1692
  /** 'A' | 'B' | 'C' in practice; `'?'` for a record that lost its letter. */
1262
- variant: z10.string(),
1263
- title: z10.string(),
1693
+ variant: z13.string(),
1694
+ title: z13.string(),
1264
1695
  status: runStatusSchema,
1265
- archived: z10.boolean(),
1266
- tokensUsed: z10.number(),
1696
+ archived: z13.boolean(),
1697
+ tokensUsed: z13.number(),
1267
1698
  inputTokens: usageCounterSchema.optional(),
1268
1699
  outputTokens: usageCounterSchema.optional(),
1269
- costUsd: z10.number().optional(),
1270
- diffStat: z10.string(),
1700
+ costUsd: z13.number().optional(),
1701
+ diffStat: z13.string(),
1271
1702
  /** First lines of the handoff journal's "## Progress log" section, as markdown. */
1272
- handoffExcerpt: z10.string()
1703
+ handoffExcerpt: z13.string()
1273
1704
  });
1274
- var groupResponseSchema = z10.object({
1275
- groupId: z10.string(),
1276
- runs: z10.array(groupVariantSchema)
1705
+ var groupResponseSchema = z13.object({
1706
+ groupId: z13.string(),
1707
+ runs: z13.array(groupVariantSchema)
1277
1708
  });
1278
- var pickVariantResponseSchema = z10.object({
1709
+ var pickVariantResponseSchema = z13.object({
1279
1710
  winner: runRecordSchema.optional()
1280
1711
  });
1281
1712
  var FILE_ATTACHMENT_MEDIA_TYPES = [
@@ -1298,174 +1729,189 @@ function isImageAttachmentName(name) {
1298
1729
  const ext = name.split(".").pop()?.toLowerCase();
1299
1730
  return ext !== void 0 && IMAGE_ATTACHMENT_EXTENSIONS.has(ext);
1300
1731
  }
1301
- var attachmentFileParamSchema = z10.object({
1302
- id: z10.string().min(1),
1303
- file: z10.string().regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine((name) => !name.includes(".."))
1732
+ var attachmentFileParamSchema = z13.object({
1733
+ id: z13.string().min(1),
1734
+ file: z13.string().regex(/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/).refine((name) => !name.includes(".."))
1304
1735
  });
1305
- var attachmentInputSchema = z10.object({
1306
- mediaType: z10.string().refine(isAttachmentMediaType, {
1736
+ var attachmentInputSchema = z13.object({
1737
+ mediaType: z13.string().refine(isAttachmentMediaType, {
1307
1738
  message: "unsupported attachment type \u2014 images, plain text, markdown and PDF only"
1308
1739
  }),
1309
- data: z10.string().min(1).max(7e6)
1740
+ data: z13.string().min(1).max(7e6)
1310
1741
  });
1311
1742
  var imageInputSchema = attachmentInputSchema;
1312
- var createRunInputBaseSchema = z10.object({
1313
- workflow: z10.string().min(1).optional(),
1743
+ var CLIENT_REQUEST_VARIANTS_ERROR = "clientRequestId names one run; it cannot be combined with variants > 1";
1744
+ var createRunInputBaseSchema = z13.object({
1745
+ workflow: z13.string().min(1).optional(),
1314
1746
  /** An inline chain (spec 008 — an approved plan runs as an ad-hoc workflow, never written to
1315
1747
  * a file). The catalog's own step shape, not a copy of it. */
1316
- steps: z10.array(workflowStepDefSchema).min(1).max(8).optional(),
1317
- task: z10.string().min(1).max(1e5, "must be at most 100000 characters"),
1318
- model: z10.string().optional(),
1748
+ steps: z13.array(workflowStepDefSchema).min(1).max(8).optional(),
1749
+ task: z13.string().min(1).max(1e5, "must be at most 100000 characters"),
1750
+ model: z13.string().optional(),
1319
1751
  /** Reasoning-effort pin (#45). Omit for the harness default; empty/`auto` stay implicit. */
1320
- effort: z10.string().max(32).optional(),
1752
+ effort: z13.string().max(32).optional(),
1321
1753
  runner: runnerSchema.optional(),
1322
1754
  /** Agent account for this task (spec 2026-07-29-agent-profiles). Omit to follow the
1323
1755
  * project's own selection; an id that no longer exists is a 400, not a silent default. */
1324
- agentProfile: z10.string().max(64).optional(),
1756
+ agentProfile: z13.string().max(64).optional(),
1325
1757
  /** 1–3. Above 1 the response is `{ runs }` rather than a single record. */
1326
- variants: z10.number().int().min(1).max(3).optional(),
1758
+ variants: z13.number().int().min(1).max(3).optional(),
1327
1759
  /** false → run in the repo working tree instead of an isolated worktree (read-only skills).
1328
1760
  * Omit for the default. Ignored server-side when variants > 1. */
1329
- worktree: z10.boolean().optional(),
1761
+ worktree: z13.boolean().optional(),
1330
1762
  /** true → autonomous run: never parks at "waiting"; auto-continues until done. */
1331
- autonomous: z10.boolean().optional(),
1763
+ autonomous: z13.boolean().optional(),
1332
1764
  /** false → keep the handoff journal but do not expose or request a follow-up todos file.
1333
1765
  * Omit for the default (enabled); a server with the capability off pins it to false. */
1334
- generateFollowups: z10.boolean().optional(),
1766
+ generateFollowups: z13.boolean().optional(),
1335
1767
  /** Per-run system-prompt override (R2 2.3) — programmatic callers only. Wins over the
1336
1768
  * config.json default; whitespace-only degrades to absent. */
1337
- systemPrompt: z10.string().trim().max(2e4, "must be at most 20000 characters").optional().transform((s) => s ? s : void 0),
1769
+ systemPrompt: z13.string().trim().max(2e4, "must be at most 20000 characters").optional().transform((s) => s ? s : void 0),
1338
1770
  /** Attachments pasted into the new-task form — screenshots, and since #950 PDF/TXT/MD files
1339
1771
  * too; delivered with the first agent step. The key keeps its name: the wire contract widened
1340
1772
  * in place rather than growing a second list. */
1341
- images: z10.array(attachmentInputSchema).max(4).optional(),
1773
+ images: z13.array(attachmentInputSchema).max(4).optional(),
1342
1774
  /** The inbox entry this task came from (#374). Best-effort bookkeeping: an unknown or
1343
1775
  * already-started id never fails the run. For ×2/×3 the FIRST variant is recorded. */
1344
- todoId: z10.string().min(1).max(200, "must be at most 200 characters").optional()
1345
- });
1346
- var createRunInputSchema = createRunInputBaseSchema.refine(
1776
+ todoId: z13.string().min(1).max(200, "must be at most 200 characters").optional()
1777
+ });
1778
+ var createRunInputSchema = createRunInputBaseSchema.extend({
1779
+ /** Idempotent start (#504): a retry with the same id and payload answers `200` with the run
1780
+ * the first request created; a different payload answers `409`. Scoped to the project. Not
1781
+ * on the base schema, so an automation's task definition cannot carry one. */
1782
+ clientRequestId: z13.string().uuid().optional(),
1783
+ /** Task webhook opt-in (#589). Absent = off. `true` on a project with no webhook is a 400.
1784
+ * Not on the base schema, and not part of the idempotent-start hash: it can change later. */
1785
+ notify: z13.boolean().optional()
1786
+ }).refine(
1347
1787
  (b) => Boolean(b.workflow) !== Boolean(b.steps),
1348
1788
  { message: 'provide either "workflow" or "steps", not both' }
1349
- );
1350
- var messageInputSchema = z10.object({
1351
- text: z10.string().max(1e5).default(""),
1352
- images: z10.array(attachmentInputSchema).max(4).default([])
1789
+ ).refine((b) => !(b.clientRequestId && (b.variants ?? 1) > 1), {
1790
+ message: CLIENT_REQUEST_VARIANTS_ERROR
1791
+ });
1792
+ var messageInputSchema = z13.object({
1793
+ text: z13.string().max(1e5).default(""),
1794
+ images: z13.array(attachmentInputSchema).max(4).default([])
1353
1795
  }).refine((m) => m.text.trim().length > 0 || m.images.length > 0, {
1354
1796
  message: "message needs text or at least one attachment"
1355
1797
  });
1356
- var patchRunInputSchema = z10.object({
1357
- title: z10.string().trim().min(1).max(300).optional(),
1358
- task: z10.string().trim().min(1).max(1e5).optional()
1798
+ var patchRunInputSchema = z13.object({
1799
+ title: z13.string().trim().min(1).max(300).optional(),
1800
+ task: z13.string().trim().min(1).max(1e5).optional()
1801
+ });
1802
+ var pinRunInputSchema = z13.object({ pinned: z13.boolean().optional() });
1803
+ var notifyRunInputSchema = z13.object({
1804
+ notify: z13.boolean(),
1805
+ message: z13.string().trim().max(1e5).optional().transform((text) => text ? text : void 0)
1359
1806
  });
1360
- var pinRunInputSchema = z10.object({ pinned: z10.boolean().optional() });
1361
1807
 
1362
1808
  // ../contract/src/repo.ts
1363
- import { z as z11 } from "zod";
1364
- var statusEntrySchema = z11.object({
1365
- status: z11.string(),
1366
- path: z11.string()
1367
- });
1368
- var logEntrySchema = z11.object({
1369
- hash: z11.string(),
1370
- subject: z11.string(),
1371
- author: z11.string(),
1372
- when: z11.string()
1373
- });
1374
- var repoResponseSchema = z11.union([
1375
- z11.object({
1376
- info: z11.null(),
1377
- status: z11.array(z11.never()),
1378
- log: z11.array(z11.never()),
1379
- branches: z11.array(z11.never()),
1380
- baseBranch: z11.null()
1809
+ import { z as z14 } from "zod";
1810
+ var statusEntrySchema = z14.object({
1811
+ status: z14.string(),
1812
+ path: z14.string()
1813
+ });
1814
+ var logEntrySchema = z14.object({
1815
+ hash: z14.string(),
1816
+ subject: z14.string(),
1817
+ author: z14.string(),
1818
+ when: z14.string()
1819
+ });
1820
+ var repoResponseSchema = z14.union([
1821
+ z14.object({
1822
+ info: z14.null(),
1823
+ status: z14.array(z14.never()),
1824
+ log: z14.array(z14.never()),
1825
+ branches: z14.array(z14.never()),
1826
+ baseBranch: z14.null()
1381
1827
  }),
1382
- z11.object({
1828
+ z14.object({
1383
1829
  info: repoInfoSchema,
1384
- status: z11.array(statusEntrySchema),
1385
- log: z11.array(logEntrySchema),
1386
- branches: z11.array(z11.string()),
1387
- baseBranch: z11.string().nullable()
1830
+ status: z14.array(statusEntrySchema),
1831
+ log: z14.array(logEntrySchema),
1832
+ branches: z14.array(z14.string()),
1833
+ baseBranch: z14.string().nullable()
1388
1834
  })
1389
1835
  ]);
1390
- var repoBranchResponseSchema = z11.object({
1391
- branch: z11.string(),
1392
- created: z11.boolean()
1393
- });
1394
- var repoPullBranchesResponseSchema = z11.object({ branches: z11.array(z11.string()) });
1395
- var repoPullInputSchema = z11.object({
1396
- branch: z11.string().trim().min(1).max(200).optional(),
1397
- confirm: z11.boolean().optional()
1398
- });
1399
- var repoPullResponseSchema = z11.object({
1400
- branch: z11.string(),
1401
- pulled: z11.literal(true),
1402
- summary: z11.string()
1403
- });
1404
- var repoPullConfirmationSchema = z11.object({
1405
- error: z11.string(),
1406
- branch: z11.string(),
1407
- risks: z11.array(z11.enum(["active_runs", "dirty_tree"]))
1408
- });
1409
- var repoPullErrorSchema = z11.union([
1836
+ var repoBranchResponseSchema = z14.object({
1837
+ branch: z14.string(),
1838
+ created: z14.boolean()
1839
+ });
1840
+ var repoPullBranchesResponseSchema = z14.object({ branches: z14.array(z14.string()) });
1841
+ var repoPullInputSchema = z14.object({
1842
+ branch: z14.string().trim().min(1).max(200).optional(),
1843
+ confirm: z14.boolean().optional()
1844
+ });
1845
+ var repoPullResponseSchema = z14.object({
1846
+ branch: z14.string(),
1847
+ pulled: z14.literal(true),
1848
+ summary: z14.string()
1849
+ });
1850
+ var repoPullConfirmationSchema = z14.object({
1851
+ error: z14.string(),
1852
+ branch: z14.string(),
1853
+ risks: z14.array(z14.enum(["active_runs", "dirty_tree"]))
1854
+ });
1855
+ var repoPullErrorSchema = z14.union([
1410
1856
  repoPullConfirmationSchema,
1411
- z11.object({ error: z11.string() })
1857
+ z14.object({ error: z14.string() })
1412
1858
  ]);
1413
- var diffStatSchema2 = z11.object({
1414
- adds: z11.number(),
1415
- dels: z11.number(),
1416
- files: z11.number()
1859
+ var diffStatSchema2 = z14.object({
1860
+ adds: z14.number(),
1861
+ dels: z14.number(),
1862
+ files: z14.number()
1417
1863
  });
1418
- var changedFileSchema = z11.object({
1419
- path: z11.string(),
1864
+ var changedFileSchema = z14.object({
1865
+ path: z14.string(),
1420
1866
  /** Rename/copy source — present only when `status` is renamed/copied. */
1421
- oldPath: z11.string().optional(),
1422
- status: z11.enum(["added", "modified", "deleted", "renamed", "copied"]),
1423
- adds: z11.number(),
1424
- dels: z11.number(),
1867
+ oldPath: z14.string().optional(),
1868
+ status: z14.enum(["added", "modified", "deleted", "renamed", "copied"]),
1869
+ adds: z14.number(),
1870
+ dels: z14.number(),
1425
1871
  /** Binary per numstat — there is no text patch to render. */
1426
- binary: z11.boolean(),
1872
+ binary: z14.boolean(),
1427
1873
  /** True when the path is one the raw-bytes route serves as an `<img>` (#365) — present only
1428
1874
  * when true, so old clients that never read it stay correct. */
1429
- image: z11.boolean().optional(),
1875
+ image: z14.boolean().optional(),
1430
1876
  /** This file's unified-diff section; possibly `… (patch truncated)`, possibly empty. */
1431
- patch: z11.string()
1877
+ patch: z14.string()
1432
1878
  });
1433
- var changesPayloadSchema = z11.object({
1434
- files: z11.array(changedFileSchema),
1879
+ var changesPayloadSchema = z14.object({
1880
+ files: z14.array(changedFileSchema),
1435
1881
  stat: diffStatSchema2,
1436
1882
  /** Additive context for review tasks whose worktree HEAD no longer matches their own branch. */
1437
- repointedHead: z11.object({ headBranch: z11.string(), taskBranch: z11.string() }).optional()
1883
+ repointedHead: z14.object({ headBranch: z14.string(), taskBranch: z14.string() }).optional()
1438
1884
  });
1439
- var repoCommitPayloadSchema = z11.object({
1440
- sha: z11.string(),
1441
- subject: z11.string(),
1442
- author: z11.string(),
1885
+ var repoCommitPayloadSchema = z14.object({
1886
+ sha: z14.string(),
1887
+ subject: z14.string(),
1888
+ author: z14.string(),
1443
1889
  /** Relative time ("3 hours ago") — same `%cr` format as the /api/v1/repo log. */
1444
- when: z11.string(),
1445
- files: z11.array(changedFileSchema),
1890
+ when: z14.string(),
1891
+ files: z14.array(changedFileSchema),
1446
1892
  stat: diffStatSchema2
1447
1893
  });
1448
- var worktreeDirEntrySchema = z11.object({
1449
- name: z11.string(),
1450
- type: z11.enum(["dir", "file"]),
1451
- size: z11.number().optional()
1894
+ var worktreeDirEntrySchema = z14.object({
1895
+ name: z14.string(),
1896
+ type: z14.enum(["dir", "file"]),
1897
+ size: z14.number().optional()
1452
1898
  });
1453
- var worktreeEntrySchema = z11.discriminatedUnion("type", [
1454
- z11.object({
1455
- type: z11.literal("dir"),
1456
- path: z11.string(),
1457
- entries: z11.array(worktreeDirEntrySchema)
1899
+ var worktreeEntrySchema = z14.discriminatedUnion("type", [
1900
+ z14.object({
1901
+ type: z14.literal("dir"),
1902
+ path: z14.string(),
1903
+ entries: z14.array(worktreeDirEntrySchema)
1458
1904
  }),
1459
- z11.object({
1460
- type: z11.literal("file"),
1461
- path: z11.string(),
1462
- size: z11.number(),
1463
- binary: z11.boolean(),
1464
- tooLarge: z11.boolean(),
1465
- content: z11.string().optional()
1905
+ z14.object({
1906
+ type: z14.literal("file"),
1907
+ path: z14.string(),
1908
+ size: z14.number(),
1909
+ binary: z14.boolean(),
1910
+ tooLarge: z14.boolean(),
1911
+ content: z14.string().optional()
1466
1912
  })
1467
1913
  ]);
1468
- var worktreeRunStatusSchema = z11.enum([
1914
+ var worktreeRunStatusSchema = z14.enum([
1469
1915
  "queued",
1470
1916
  "running",
1471
1917
  "waiting",
@@ -1474,41 +1920,41 @@ var worktreeRunStatusSchema = z11.enum([
1474
1920
  "failed",
1475
1921
  "cancelled"
1476
1922
  ]);
1477
- var worktreeInfoSchema = z11.object({
1478
- runId: z11.string(),
1479
- title: z11.string(),
1923
+ var worktreeInfoSchema = z14.object({
1924
+ runId: z14.string(),
1925
+ title: z14.string(),
1480
1926
  status: worktreeRunStatusSchema,
1481
- branch: z11.string().nullable(),
1482
- sizeBytes: z11.number().nullable(),
1483
- finishedAt: z11.string().nullable(),
1484
- reclaimable: z11.boolean()
1927
+ branch: z14.string().nullable(),
1928
+ sizeBytes: z14.number().nullable(),
1929
+ finishedAt: z14.string().nullable(),
1930
+ reclaimable: z14.boolean()
1485
1931
  });
1486
- var worktreesResponseSchema = z11.object({
1487
- worktrees: z11.array(worktreeInfoSchema),
1488
- totalBytes: z11.number().nullable(),
1489
- keep: z11.number()
1932
+ var worktreesResponseSchema = z14.object({
1933
+ worktrees: z14.array(worktreeInfoSchema),
1934
+ totalBytes: z14.number().nullable(),
1935
+ keep: z14.number()
1490
1936
  });
1491
- var reclaimWorktreesResponseSchema = z11.object({
1492
- reclaimed: z11.array(z11.string())
1937
+ var reclaimWorktreesResponseSchema = z14.object({
1938
+ reclaimed: z14.array(z14.string())
1493
1939
  });
1494
1940
 
1495
1941
  // ../contract/src/projects.ts
1496
- import { z as z12 } from "zod";
1497
- var projectListEntrySchema = z12.object({
1498
- id: z12.string(),
1499
- name: z12.string(),
1942
+ import { z as z15 } from "zod";
1943
+ var projectListEntrySchema = z15.object({
1944
+ id: z15.string(),
1945
+ name: z15.string(),
1500
1946
  /** Absolute, realpath-normalized repo root. */
1501
- root: z12.string(),
1502
- addedAt: z12.string(),
1503
- lastOpenedAt: z12.string(),
1504
- source: z12.enum(["local", "checkout"]),
1947
+ root: z15.string(),
1948
+ addedAt: z15.string(),
1949
+ lastOpenedAt: z15.string(),
1950
+ source: z15.enum(["local", "checkout"]),
1505
1951
  /** `not-git` is fully usable (degraded single-queue mode); only `missing` blocks. */
1506
- status: z12.enum(["ok", "missing", "not-git"]),
1952
+ status: z15.enum(["ok", "missing", "not-git"]),
1507
1953
  /** Current branch when cheaply available (omitted e.g. on an unborn HEAD). */
1508
- branch: z12.string().optional(),
1954
+ branch: z15.string().optional(),
1509
1955
  /** Which forge this project's remote belongs to (#698) — classified server-side from the
1510
1956
  * remote URL alone. Gates the project group's GitHub nav item; omitted = no forge remote. */
1511
- forge: z12.literal("github").optional(),
1957
+ forge: z15.literal("github").optional(),
1512
1958
  /**
1513
1959
  * The remote's web root, `https://github.com/owner/repo`. Rebuilt server-side from the parsed
1514
1960
  * remote rather than passed through, so a remote carrying credentials cannot leak into the
@@ -1518,10 +1964,10 @@ var projectListEntrySchema = z12.object({
1518
1964
  * the global Tasks page has one row per project, so it cannot use any single repo's base the
1519
1965
  * way a project-scoped view can. With this, every reference it shows is a link.
1520
1966
  */
1521
- repoUrl: z12.string().optional(),
1967
+ repoUrl: z15.string().optional(),
1522
1968
  /** Per-project cap on concurrently running tasks (spec 2026-07-22). Omitted = inherit the
1523
1969
  * workspace `resources.maxParallel`; a number pins this project. */
1524
- maxParallel: z12.number().optional(),
1970
+ maxParallel: z15.number().optional(),
1525
1971
  /**
1526
1972
  * Free-form labels grouping CONNECTED repositories — a `storefront` tag on the API, the web
1527
1973
  * app and the design system says those three are one piece of work spread over three repos.
@@ -1533,528 +1979,218 @@ var projectListEntrySchema = z12.object({
1533
1979
  * server-side (trimmed, deduped case-insensitively, sorted), so a consumer may compare them
1534
1980
  * directly.
1535
1981
  */
1536
- tags: z12.array(z12.string()).optional()
1982
+ tags: z15.array(z15.string()).optional(),
1983
+ /** The task webhook (#589). The token is write-only: the wire says only whether one is set. */
1984
+ webhook: z15.object({ url: z15.string(), tokenSet: z15.boolean() }).optional()
1537
1985
  });
1538
- var projectsResponseSchema = z12.object({
1539
- projects: z12.array(projectListEntrySchema),
1540
- bootProject: z12.string(),
1541
- projectsDir: z12.string()
1986
+ var projectsResponseSchema = z15.object({
1987
+ projects: z15.array(projectListEntrySchema),
1988
+ bootProject: z15.string(),
1989
+ projectsDir: z15.string()
1542
1990
  });
1543
- var registerProjectResponseSchema = z12.object({
1991
+ var registerProjectResponseSchema = z15.object({
1544
1992
  project: projectListEntrySchema,
1545
- error: z12.string().optional()
1993
+ error: z15.string().optional()
1546
1994
  });
1547
- var removeProjectResponseSchema = z12.object({
1548
- removed: z12.literal(true),
1549
- id: z12.string()
1995
+ var removeProjectResponseSchema = z15.object({
1996
+ removed: z15.literal(true),
1997
+ id: z15.string()
1550
1998
  });
1551
- var updateProjectResponseSchema = z12.object({
1999
+ var updateProjectResponseSchema = z15.object({
1552
2000
  project: projectListEntrySchema
1553
2001
  });
1554
2002
  var PROJECT_TAG_MAX_LENGTH = 32;
1555
2003
  var PROJECT_TAGS_MAX = 20;
1556
- var updateProjectInputSchema = z12.object({
1557
- maxParallel: z12.number().int().min(1).max(16).nullable().optional(),
1558
- tags: z12.array(z12.string().trim().min(1).max(PROJECT_TAG_MAX_LENGTH)).max(PROJECT_TAGS_MAX).nullable().optional()
2004
+ var PROJECT_WEBHOOK_URL_MAX_LENGTH = 2048;
2005
+ var PROJECT_WEBHOOK_TOKEN_MAX_LENGTH = 1024;
2006
+ var projectWebhookUrlSchema = z15.string().trim().max(PROJECT_WEBHOOK_URL_MAX_LENGTH).pipe(z15.url({ protocol: /^https?$/, error: "webhook url must be an http(s) URL" })).refine((value) => !/^https?:\/\/[^/?#]*@/i.test(value), "webhook url must not contain credentials; put the secret in the token");
2007
+ var projectWebhookInputSchema = z15.object({
2008
+ url: projectWebhookUrlSchema,
2009
+ token: z15.string().trim().max(PROJECT_WEBHOOK_TOKEN_MAX_LENGTH).optional()
2010
+ });
2011
+ var testProjectWebhookResponseSchema = z15.object({
2012
+ ok: z15.boolean(),
2013
+ status: z15.number().optional(),
2014
+ error: z15.string().optional(),
2015
+ dryRun: z15.boolean().optional()
2016
+ });
2017
+ var updateProjectInputSchema = z15.object({
2018
+ maxParallel: z15.number().int().min(1).max(16).nullable().optional(),
2019
+ tags: z15.array(z15.string().trim().min(1).max(PROJECT_TAG_MAX_LENGTH)).max(PROJECT_TAGS_MAX).nullable().optional(),
2020
+ /**
2021
+ * The task webhook (#589). `null` removes it. An omitted `token` keeps the stored one, so the
2022
+ * settings form can change the URL without asking for a secret it never shows again; `''`
2023
+ * clears the token.
2024
+ */
2025
+ webhook: projectWebhookInputSchema.nullable().optional()
1559
2026
  }).refine(
1560
- (body) => body.maxParallel !== void 0 || body.tags !== void 0,
1561
- "specify maxParallel or tags"
2027
+ (body) => body.maxParallel !== void 0 || body.tags !== void 0 || body.webhook !== void 0,
2028
+ "specify maxParallel, tags or webhook"
1562
2029
  );
1563
- var checkoutProjectInputSchema = z12.object({
1564
- url: z12.string().trim().min(1).max(512),
1565
- name: z12.string().trim().max(128).optional(),
1566
- checkoutId: z12.string().trim().max(128).optional()
2030
+ var checkoutProjectInputSchema = z15.object({
2031
+ url: z15.string().trim().min(1).max(512),
2032
+ name: z15.string().trim().max(128).optional(),
2033
+ checkoutId: z15.string().trim().max(128).optional()
1567
2034
  });
1568
- var fsBrowseDirSchema = z12.object({
1569
- name: z12.string(),
1570
- path: z12.string(),
2035
+ var fsBrowseDirSchema = z15.object({
2036
+ name: z15.string(),
2037
+ path: z15.string(),
1571
2038
  /** Has a `.git` entry — drives the "git" badge. A non-repo folder is still selectable. */
1572
- isRepo: z12.boolean()
2039
+ isRepo: z15.boolean()
1573
2040
  });
1574
- var fsBrowseResponseSchema = z12.object({
2041
+ var fsBrowseResponseSchema = z15.object({
1575
2042
  /** The realpath'd directory actually listed — never the spelling asked for, so the breadcrumb
1576
2043
  * shows where the picker really is. */
1577
- path: z12.string(),
2044
+ path: z15.string(),
1578
2045
  /** `null` AT the browse root: there is no "up" out of it, and the dialog must render no parent
1579
2046
  * row rather than one that 400s. */
1580
- parent: z12.string().nullable(),
1581
- dirs: z12.array(fsBrowseDirSchema),
2047
+ parent: z15.string().nullable(),
2048
+ dirs: z15.array(fsBrowseDirSchema),
1582
2049
  /** True when the listing was capped server-side — surfaced honestly instead of showing a
1583
2050
  * silently short list. */
1584
- truncated: z12.boolean()
1585
- });
1586
- var launchKeyResponseSchema = z12.object({
1587
- key: z12.string()
1588
- });
1589
-
1590
- // ../contract/src/workspace.ts
1591
- import { z as z13 } from "zod";
1592
- var workspaceConfigResponseSchema = z13.object({
1593
- /** Root exposed by the Add-project directory browser — stored as written (`~` kept). */
1594
- browseRoot: z13.string(),
1595
- /** Checkout root for GUI-cloned projects — stored as written (`~` kept). */
1596
- projectsDir: z13.string(),
1597
- /** Stored override; `null` means inherit `CEZ_SKILLS_AUTO_UPDATE`, then true. */
1598
- skillsAutoUpdate: z13.boolean().nullable(),
1599
- effectiveSkillsAutoUpdate: z13.boolean(),
1600
- composerDefaults: z13.object({
1601
- autonomous: z13.boolean().nullable(),
1602
- worktree: z13.boolean().nullable(),
1603
- /** `'source-dependent'` when no `CEZ_AUTONOMOUS_DEFAULT` pins it either way. */
1604
- inheritedAutonomous: z13.union([z13.boolean(), z13.literal("source-dependent")]),
1605
- inheritedWorktree: z13.boolean()
1606
- }),
1607
- resources: z13.object({
1608
- maxParallel: z13.number(),
1609
- maxMonitoringSessions: z13.number(),
1610
- monitoringWakeIntervalMinutes: z13.number().nullable(),
1611
- /** Resume a run a provider usage limit stopped, once the limit resets. Default `true`. */
1612
- autoResumeOnUsageLimit: z13.boolean(),
1613
- memoryLimitMb: z13.number().nullable(),
1614
- worktreeRetentionDefault: z13.number()
1615
- }),
1616
- /**
1617
- * What a repo that has set none of its own runs (spec 2026-07-29-agent-profiles).
1618
- *
1619
- * Both keys are OPTIONAL on the wire, and that is load-bearing rather than lax: absent means
1620
- * "this machine has no opinion, the built-in default applies", and it has to stay distinguishable
1621
- * from a value someone chose or the fallback collapses into "always claude". Consulted only where
1622
- * the repo's own `.ai/cezar/config.json` is silent — a repo that chose is never overruled.
1623
- */
1624
- agentDefaults: z13.object({
1625
- runner: runnerSchema.optional(),
1626
- models: z13.object({
1627
- claude: z13.string().optional(),
1628
- codex: z13.string().optional(),
1629
- opencode: z13.string().optional(),
1630
- pi: z13.string().optional(),
1631
- cursor: z13.string().optional()
1632
- }).optional()
1633
- })
1634
- });
1635
- var setWorkspaceConfigInputSchema = z13.object({
1636
- browseRoot: z13.string().trim().min(1).max(4096).optional(),
1637
- projectsDir: z13.string().trim().min(1).max(4096).optional(),
1638
- skillsAutoUpdate: z13.boolean().nullable().optional(),
1639
- composerDefaults: z13.object({
1640
- autonomous: z13.boolean().nullable().optional(),
1641
- worktree: z13.boolean().nullable().optional()
1642
- }).optional(),
1643
- /** Machine-wide agent defaults. `null` on a key CLEARS it back to "no opinion", which a bare
1644
- * absent key cannot say in a partial patch. */
1645
- agentDefaults: z13.object({
1646
- runner: runnerSchema.nullable().optional(),
1647
- models: z13.object({
1648
- claude: z13.string().trim().min(1).max(200).nullable().optional(),
1649
- codex: z13.string().trim().min(1).max(200).nullable().optional(),
1650
- opencode: z13.string().trim().min(1).max(200).nullable().optional(),
1651
- pi: z13.string().trim().min(1).max(200).nullable().optional(),
1652
- cursor: z13.string().trim().min(1).max(200).nullable().optional()
1653
- }).optional()
1654
- }).optional(),
1655
- resources: z13.object({
1656
- maxParallel: z13.number().int().min(1).max(16).optional(),
1657
- maxMonitoringSessions: z13.number().int().min(0).max(16).optional(),
1658
- monitoringWakeIntervalMinutes: z13.number().int().min(1).max(60).nullable().optional(),
1659
- autoResumeOnUsageLimit: z13.boolean().optional(),
1660
- memoryLimitMb: z13.number().int().min(0).max(1048576).nullable().optional(),
1661
- worktreeRetentionDefault: z13.number().int().min(0).max(1e3).optional()
1662
- }).optional()
1663
- });
1664
- var appearanceSchema = z13.object({
1665
- accent: z13.enum(["cezarion", "lime", "violet"]).optional(),
1666
- density: z13.enum(["comfortable", "compact", "ultra"]).optional(),
1667
- width: z13.enum(["narrow", "wide"]).optional()
1668
- });
1669
- var taskTableUiStateSchema = z13.looseObject({
1670
- /** Explicit user choices only. Missing ids keep the registry-owned default. */
1671
- expandedColumns: z13.record(z13.string(), z13.boolean()).optional()
1672
- });
1673
- var uiStateSchema = z13.looseObject({
1674
- /** What the last started run used. `null` is a VALUE, not an absence: it records a run that
1675
- * chose neither a skill nor a workflow (the plain built-in `quick-task`), which the composer
1676
- * can now express since the source picker grew an empty state. Absent still means "no
1677
- * run has been recorded here" — a cockpit reading either one selects nothing. */
1678
- lastTask: z13.object({ source: z13.enum(["workflow", "skill"]), ref: z13.string() }).nullable().optional(),
1679
- /** Most-recently-run sources, newest first (deduped, capped). Feeds the composer picker's
1680
- * recency sort. */
1681
- recentSources: z13.array(z13.object({ source: z13.enum(["workflow", "skill"]), ref: z13.string() })).optional(),
1682
- /** The last worktree choice for a single-skill run. Absent → the default (isolated worktree). */
1683
- lastWorktree: z13.boolean().optional(),
1684
- /** The last autonomous choice — remembered like `lastWorktree`. Absent → off. */
1685
- lastAutonomous: z13.boolean().optional(),
1686
- /** Whether new runs should ask agents to append follow-up work. Absent → on. */
1687
- lastGenerateFollowups: z13.boolean().optional(),
1688
- /** Skill selection frequency (#408): name → times chosen, across BOTH composers. */
1689
- skillUsage: z13.record(z13.string(), z13.number()).optional(),
1690
- runsView: z13.enum(["list", "table"]).optional(),
1691
- /** The GitHub tab's last-selected sub-tab (#417). Absent → issues. */
1692
- githubView: z13.enum(["issues", "prs"]).optional(),
1693
- /** Settings → Appearance. The theme itself stays in localStorage (`cez-theme`) — it must
1694
- * pre-paint, and it is per-browser by design. */
1695
- appearance: appearanceSchema.optional(),
1696
- /** Follow-up prompt templates (#413). Absent → the built-in defaults; present (even `[]`) is
1697
- * the user's own edited list. `skills` are the skill names the template auto-applies for. */
1698
- promptTemplates: z13.array(
1699
- z13.object({
1700
- id: z13.string(),
1701
- label: z13.string(),
1702
- text: z13.string(),
1703
- skills: z13.array(z13.string()).optional()
1704
- })
1705
- ).optional(),
1706
- /** The open-mercato/skills promo banner (#391), dismissed for good. Legacy — the banner is
1707
- * gone, replaced by `WorkspaceUiState.importedSkills`; retained so old files round-trip. */
1708
- dismissedSkillsBanner: z13.boolean().optional()
1709
- });
1710
- var workspaceLastLocationSchema = z13.strictObject({
1711
- projectId: z13.string().min(1).max(64),
1712
- pathname: z13.string().min(1).max(2048).startsWith("/p/"),
1713
- search: z13.string().max(4096).startsWith("?").optional(),
1714
- hash: z13.string().max(2048).startsWith("#").optional()
1715
- });
1716
- var workspaceUiStateSchema = z13.looseObject({
1717
- /** LEGACY — the sidebar's per-project collapse map (step 3.3). Still accepted and still
1718
- * round-tripped so an older cockpit sharing this home keeps working, but the current cockpit
1719
- * neither reads nor writes it: which groups are shut describes the WINDOW, not the workspace,
1720
- * so it lives in that browser's localStorage (`packages/web/src/lib/sidebar-collapse.ts`).
1721
- * One shared answer meant a phone collapsing a group collapsed it on the desktop too. */
1722
- sidebar: z13.looseObject({ collapsed: z13.record(z13.string(), z13.boolean()).optional() }).optional(),
1723
- /** Dismissed runtime-auth incident IDs, keyed by provider. An ID is only dismissed until the
1724
- * provider reports a different incident, so this stays workspace-global with the browser
1725
- * rather than one project checkout. */
1726
- dismissedProviderAuthFailures: z13.object({
1727
- claude: z13.string().optional(),
1728
- codex: z13.string().optional(),
1729
- opencode: z13.string().optional(),
1730
- pi: z13.string().optional(),
1731
- cursor: z13.string().optional()
1732
- }).optional(),
1733
- /** Settings → Appearance, GLOBAL since step 3.5: accent + density describe the person at the
1734
- * keyboard, not a repo. */
1735
- appearance: appearanceSchema.optional(),
1736
- /** Settings → Notifications, GLOBAL since step 3.5 — one answer for the whole workspace, since
1737
- * the delivering browser is one browser whichever project you are looking at. */
1738
- notifications: z13.looseObject({ enabled: z13.boolean().optional() }).optional(),
1739
- /** Desktop Tasks-table density, shared across every project in this workspace. */
1740
- taskTable: taskTableUiStateSchema.optional(),
1741
- /** LEGACY, exactly like `sidebar` above — the last settled project-scoped page, restored when
1742
- * entering at the exact bare root. The shape is unchanged and still accepted, but the current
1743
- * cockpit keeps it in localStorage (`packages/web/src/lib/last-location.ts`): stored here, the
1744
- * last client to navigate decided where every OTHER client's next launch landed. */
1745
- lastLocation: workspaceLastLocationSchema.optional(),
1746
- /** The user's curated selection of default (vendor) skills. Tri-state: ABSENT means "not
1747
- * curated", so every default skill shows; a PRESENT array (even `[]`) means only those names
1748
- * show from that repo. */
1749
- importedSkills: z13.array(z13.string()).optional()
1750
- });
1751
- var WORKSPACE_UI_STATE_MAX_KEYS = 200;
1752
- var TASK_TABLE_MAX_COLUMNS = 50;
1753
- var setWorkspaceUiStateInputSchema = z13.looseObject({
1754
- ...workspaceUiStateSchema.shape,
1755
- sidebar: z13.looseObject({
1756
- collapsed: z13.record(z13.string().min(1).max(64), z13.boolean()).refine((map) => Object.keys(map).length <= WORKSPACE_UI_STATE_MAX_KEYS, {
1757
- message: `sidebar.collapsed must have at most ${WORKSPACE_UI_STATE_MAX_KEYS} entries`
1758
- }).optional()
1759
- }).optional(),
1760
- dismissedProviderAuthFailures: z13.strictObject({
1761
- claude: z13.string().min(1).max(128).optional(),
1762
- codex: z13.string().min(1).max(128).optional(),
1763
- opencode: z13.string().min(1).max(128).optional(),
1764
- pi: z13.string().min(1).max(128).optional(),
1765
- cursor: z13.string().min(1).max(128).optional()
1766
- }).optional(),
1767
- importedSkills: z13.array(z13.string().min(1).max(200)).max(WORKSPACE_UI_STATE_MAX_KEYS).optional(),
1768
- taskTable: taskTableUiStateSchema.extend({
1769
- expandedColumns: z13.record(z13.string().min(1).max(64), z13.boolean()).refine((map) => Object.keys(map).length <= TASK_TABLE_MAX_COLUMNS, {
1770
- message: `taskTable.expandedColumns must have at most ${TASK_TABLE_MAX_COLUMNS} entries`
1771
- }).optional()
1772
- }).optional()
1773
- }).superRefine((data, ctx) => {
1774
- if (Object.keys(data).length > WORKSPACE_UI_STATE_MAX_KEYS) {
1775
- ctx.addIssue({
1776
- code: "custom",
1777
- message: `ui-state has too many keys (max ${WORKSPACE_UI_STATE_MAX_KEYS})`
1778
- });
1779
- }
1780
- });
1781
- var runnerModelsSchema = z13.object({
1782
- claude: z13.string().optional(),
1783
- codex: z13.string().optional(),
1784
- opencode: z13.string().optional(),
1785
- pi: z13.string().optional(),
1786
- cursor: z13.string().optional()
1787
- });
1788
- var configResponseSchema = z13.object({
1789
- baseBranch: z13.string().nullable(),
1790
- defaultRunner: runnerSchema,
1791
- systemPrompt: z13.string().nullable(),
1792
- defaultModels: runnerModelsSchema,
1793
- /** True when native coding-agent settings are authoritative and model picks are read-only. */
1794
- modelsLocked: z13.boolean(),
1795
- /** How many tasks run at once (1–16). */
1796
- maxParallel: z13.number(),
1797
- /** Per-task memory ceiling in MiB (whole process tree); null = no limit. */
1798
- memoryLimitMb: z13.number().nullable(),
1799
- /** Keep the last N finished worktrees on disk (#483); 0 = unlimited. Older ones are reclaimed
1800
- * (directory only — branch kept, so work is recoverable). */
1801
- worktreeRetention: z13.number(),
1802
- /** Live title updates: null = no config key, the `CEZ_TITLE_UPDATES` env default (ON) decides. */
1803
- liveTitleUpdates: z13.boolean().nullable(),
1804
- /** Optional review gate (#489): null = no config key, the `CEZ_REVIEW_GATE` env default (OFF)
1805
- * decides. */
1806
- reviewGate: z13.boolean().nullable()
1807
- });
1808
- var setConfigResponseSchema = configResponseSchema;
1809
- var setConfigInputSchema = z13.object({
1810
- baseBranch: z13.string().trim().min(1).max(200).nullable().optional(),
1811
- defaultRunner: runnerSchema.optional(),
1812
- systemPrompt: z13.string().trim().max(2e4).nullable().optional(),
1813
- defaultModels: z13.object({
1814
- claude: z13.string().trim().max(200).nullable().optional(),
1815
- codex: z13.string().trim().max(200).nullable().optional(),
1816
- opencode: z13.string().trim().max(200).nullable().optional(),
1817
- pi: z13.string().trim().max(200).nullable().optional(),
1818
- cursor: z13.string().trim().max(200).nullable().optional()
1819
- }).optional(),
1820
- maxParallel: z13.number().int().min(1).max(16).optional(),
1821
- /** null or 0 clears the ceiling back to "no limit". */
1822
- memoryLimitMb: z13.number().int().min(0).max(1048576).nullable().optional(),
1823
- /** Keep last N finished worktrees (#483); 0 = unlimited, null clears back to the default (10). */
1824
- worktreeRetention: z13.number().int().min(0).max(1e3).nullable().optional(),
1825
- /** null clears the key back to the env-default behavior. */
1826
- liveTitleUpdates: z13.boolean().nullable().optional(),
1827
- /** null clears the key back to the env-default behavior (OFF). */
1828
- reviewGate: z13.boolean().nullable().optional()
1829
- });
1830
- var skillsUpdateStatusSchema = z13.enum([
1831
- "idle",
1832
- "checking",
1833
- "available",
1834
- "updating",
1835
- "current",
1836
- "unavailable",
1837
- "error"
1838
- ]);
1839
- var skillsUpdateScopeStateSchema = z13.object({
1840
- scope: z13.enum(["project", "global"]),
1841
- status: skillsUpdateStatusSchema,
1842
- available: z13.boolean(),
1843
- skills: z13.array(z13.string()),
1844
- checkedAt: z13.string().nullable(),
1845
- updatedAt: z13.string().nullable(),
1846
- reason: z13.string().optional()
2051
+ truncated: z15.boolean()
1847
2052
  });
1848
- var skillsUpdateStateSchema = z13.object({
1849
- status: skillsUpdateStatusSchema,
1850
- available: z13.boolean(),
1851
- autoUpdateEnabled: z13.boolean(),
1852
- inherited: z13.boolean(),
1853
- checkedAt: z13.string().nullable(),
1854
- updatedAt: z13.string().nullable(),
1855
- scopes: z13.array(skillsUpdateScopeStateSchema),
1856
- needsUpgradeNotes: z13.boolean()
1857
- });
1858
- var providerIdSchema = runnerSchema;
1859
- var providerConnectionStateSchema = z13.enum([
1860
- "connected",
1861
- "disconnected",
1862
- "not-installed",
1863
- "unknown"
1864
- ]);
1865
- var providerStatusSchema = z13.object({
1866
- provider: providerIdSchema,
1867
- status: providerConnectionStateSchema,
1868
- enabled: z13.boolean().optional(),
1869
- hint: z13.string().optional(),
1870
- authFailureId: z13.string().optional(),
1871
- /** Which agent account this row describes (spec 2026-07-29-agent-profiles). ABSENT on
1872
- * `GET /api/v1/providers/status`, which deliberately keeps answering exactly one row per
1873
- * provider — the discovered default — so an older client sees no change at all. Per-account
1874
- * rows are carried by `GET /api/v1/workspace/agent-profiles` instead. */
1875
- profileId: z13.string().optional()
1876
- });
1877
- var providerStatusResponseSchema = z13.object({
1878
- providers: z13.array(providerStatusSchema)
1879
- });
1880
- var providerConnectResponseSchema = z13.discriminatedUnion("opened", [
1881
- z13.object({ opened: z13.literal(true), command: z13.string() }),
1882
- z13.object({ opened: z13.literal(false), connected: z13.literal(true), command: z13.string() })
1883
- ]);
1884
- var modelDiscoveryRunnerSchema = z13.enum(["claude", "codex", "opencode", "pi", "cursor"]);
1885
- var MODEL_DISCOVERY_RUNNERS = modelDiscoveryRunnerSchema.options;
1886
- function runnerDiscoversModels(runner) {
1887
- return MODEL_DISCOVERY_RUNNERS.includes(runner);
1888
- }
1889
- var runnerModelOptionSchema = z13.object({
1890
- id: z13.string(),
1891
- label: z13.string(),
1892
- description: z13.string(),
1893
- effortLevels: z13.array(effortLevelSchema).optional()
1894
- });
1895
- var runnerModelCatalogResponseSchema = z13.object({
1896
- runner: runnerSchema,
1897
- models: z13.array(runnerModelOptionSchema),
1898
- source: z13.enum(["live", "cache", "unavailable"]),
1899
- stale: z13.boolean(),
1900
- reason: z13.string().optional()
1901
- });
1902
- var openTargetSchema = z13.object({
1903
- id: z13.string(),
1904
- label: z13.string(),
1905
- /** A stable icon key (#361) the UI maps to a concrete icon. Optional: an older server omitting
1906
- * it just renders the generic fallback icon. */
1907
- icon: z13.string().optional()
1908
- });
1909
- var openTargetsResponseSchema = z13.object({
1910
- targets: z13.array(openTargetSchema)
1911
- });
1912
- var openProjectInSchema = z13.object({
1913
- // A short bound (#429): matched against a downstream allowlist, so an app id is never long.
1914
- target: z13.string().trim().min(1, "target required").max(200)
1915
- });
1916
- var openProjectInResponseSchema = z13.object({
1917
- opened: z13.literal(true),
1918
- path: z13.string()
2053
+ var launchKeyResponseSchema = z15.object({
2054
+ key: z15.string()
1919
2055
  });
1920
2056
 
1921
2057
  // ../contract/src/skills.ts
1922
- import { z as z14 } from "zod";
1923
- var skillSchema = z14.object({
1924
- name: z14.string(),
1925
- description: z14.string().optional(),
2058
+ import { z as z16 } from "zod";
2059
+ var skillSchema = z16.object({
2060
+ name: z16.string(),
2061
+ description: z16.string().optional(),
1926
2062
  /** Advisory hint for untouched composer run-mode choices. */
1927
- interactive: z14.literal(true).optional(),
1928
- body: z14.string(),
1929
- path: z14.string(),
1930
- source: z14.enum(["ai", "cezar", "agents", "global", "team"]),
2063
+ interactive: z16.literal(true).optional(),
2064
+ body: z16.string(),
2065
+ path: z16.string(),
2066
+ source: z16.enum(["ai", "cezar", "agents", "global", "team"]),
1931
2067
  /** Team skills only: where the definition lives in its skills repo. */
1932
- team: z14.object({
1933
- repo: z14.string(),
1934
- ref: z14.string(),
1935
- path: z14.string(),
2068
+ team: z16.object({
2069
+ repo: z16.string(),
2070
+ ref: z16.string(),
2071
+ path: z16.string(),
1936
2072
  /** True for the `SKILL.md` convention — a whole directory (references/…). */
1937
- dir: z14.boolean(),
2073
+ dir: z16.boolean(),
1938
2074
  /**
1939
2075
  * The exact commit `ref` resolved to when the skill was read (#428).
1940
2076
  *
1941
2077
  * The hand-written DTO omitted this field entirely — it was NARROWER than the route,
1942
2078
  * which has served it since #428.
1943
2079
  */
1944
- commit: z14.string().optional()
2080
+ commit: z16.string().optional()
1945
2081
  }).optional()
1946
2082
  });
1947
- var importableSkillSchema = z14.object({
1948
- name: z14.string(),
1949
- description: z14.string().optional()
1950
- });
1951
- var todoItemSchema = z14.object({
1952
- id: z14.string(),
1953
- ts: z14.string().optional(),
1954
- taskId: z14.string().optional(),
1955
- summary: z14.string().min(1),
1956
- action: z14.string().optional(),
1957
- prUrl: z14.string().optional(),
1958
- suggestedSkill: z14.string().optional(),
1959
- suggestedArgs: z14.string().optional(),
1960
- suggestedPrompt: z14.string().optional(),
2083
+ var importableSkillSchema = z16.object({
2084
+ name: z16.string(),
2085
+ description: z16.string().optional()
2086
+ });
2087
+ var todoItemSchema = z16.object({
2088
+ id: z16.string(),
2089
+ ts: z16.string().optional(),
2090
+ taskId: z16.string().optional(),
2091
+ summary: z16.string().min(1),
2092
+ action: z16.string().optional(),
2093
+ prUrl: z16.string().optional(),
2094
+ suggestedSkill: z16.string().optional(),
2095
+ suggestedArgs: z16.string().optional(),
2096
+ suggestedPrompt: z16.string().optional(),
1961
2097
  /** Explicit intent; missing infers from suggestedSkill/suggestedPrompt for old files. */
1962
- runnable: z14.boolean().optional(),
2098
+ runnable: z16.boolean().optional(),
1963
2099
  /** Set once a task was started from this entry — it then leaves the inbox and stays as
1964
2100
  * the audit trail. A later launch never overwrites the first. */
1965
- startedTaskId: z14.string().optional()
2101
+ startedTaskId: z16.string().optional()
1966
2102
  });
1967
- var removeTodoResponseSchema = z14.object({
1968
- removed: z14.literal(true)
2103
+ var removeTodoResponseSchema = z16.object({
2104
+ removed: z16.literal(true)
1969
2105
  });
1970
- var startTodoResponseSchema = z14.object({
2106
+ var startTodoResponseSchema = z16.object({
1971
2107
  run: runRecordSchema
1972
2108
  });
1973
2109
 
1974
2110
  // ../contract/src/agent-config.ts
1975
- import { z as z15 } from "zod";
1976
- var agentConfigFormatSchema = z15.enum(["json", "jsonc", "toml", "markdown"]);
1977
- var agentConfigScopeSchema = z15.enum(["user", "project", "local"]);
1978
- var agentConfigKindSchema = z15.enum(["settings", "memory", "mcp"]);
1979
- var agentConfigTrackedSchema = z15.enum(["tracked", "gitignored", "outside-repo"]);
1980
- var agentConfigFileSchema = z15.object({
2111
+ import { z as z17 } from "zod";
2112
+ var agentConfigFormatSchema = z17.enum(["json", "jsonc", "toml", "markdown"]);
2113
+ var agentConfigScopeSchema = z17.enum(["user", "project", "local"]);
2114
+ var agentConfigKindSchema = z17.enum(["settings", "memory", "mcp"]);
2115
+ var agentConfigTrackedSchema = z17.enum(["tracked", "gitignored", "outside-repo"]);
2116
+ var agentConfigFileSchema = z17.object({
1981
2117
  /** Stable, opaque, URL-safe — the ONLY thing a client may name (traversal-proof). */
1982
- id: z15.string(),
2118
+ id: z17.string(),
1983
2119
  /** Every runner that reads this file: `<repo>/AGENTS.md` is one file, two readers. */
1984
- runners: z15.array(runnerSchema),
2120
+ runners: z17.array(runnerSchema),
1985
2121
  kind: agentConfigKindSchema,
1986
2122
  scope: agentConfigScopeSchema,
1987
- label: z15.string(),
1988
- path: z15.string(),
2123
+ label: z17.string(),
2124
+ path: z17.string(),
1989
2125
  format: agentConfigFormatSchema,
1990
2126
  tracked: agentConfigTrackedSchema,
1991
- seeded: z15.boolean(),
1992
- holdsMcp: z15.boolean(),
2127
+ seeded: z17.boolean(),
2128
+ holdsMcp: z17.boolean(),
1993
2129
  /** VERBATIM from the vendor docs. Never computed, never generic. */
1994
- precedence: z15.string(),
2130
+ precedence: z17.string(),
1995
2131
  /** Documented mid-run reload behaviour, or absent when the vendor is silent. */
1996
- hotReload: z15.string().optional(),
1997
- docsUrl: z15.string(),
1998
- exists: z15.boolean(),
1999
- size: z15.number(),
2132
+ hotReload: z17.string().optional(),
2133
+ docsUrl: z17.string(),
2134
+ exists: z17.boolean(),
2135
+ size: z17.number(),
2000
2136
  /** sha256 of the bytes, or null when absent. */
2001
- version: z15.string().nullable(),
2137
+ version: z17.string().nullable(),
2002
2138
  /** False in hosted mode (whole feature) — the client renders read-only up front. */
2003
- writable: z15.boolean(),
2004
- readOnlyReason: z15.string().optional()
2139
+ writable: z17.boolean(),
2140
+ readOnlyReason: z17.string().optional()
2005
2141
  });
2006
- var userMcpListingSchema = z15.object({
2007
- path: z15.string(),
2008
- servers: z15.array(z15.string()),
2009
- readable: z15.boolean()
2142
+ var userMcpListingSchema = z17.object({
2143
+ path: z17.string(),
2144
+ servers: z17.array(z17.string()),
2145
+ readable: z17.boolean()
2010
2146
  });
2011
- var agentConfigListingSchema = z15.object({
2012
- editable: z15.boolean(),
2013
- files: z15.array(agentConfigFileSchema),
2147
+ var agentConfigListingSchema = z17.object({
2148
+ editable: z17.boolean(),
2149
+ files: z17.array(agentConfigFileSchema),
2014
2150
  /** null in hosted mode (host-state disclosure guard). */
2015
2151
  userMcp: userMcpListingSchema.nullable()
2016
2152
  });
2017
- var agentConfigFileContentSchema = z15.object({
2018
- id: z15.string(),
2019
- path: z15.string(),
2020
- exists: z15.boolean(),
2021
- content: z15.string(),
2153
+ var agentConfigFileContentSchema = z17.object({
2154
+ id: z17.string(),
2155
+ path: z17.string(),
2156
+ exists: z17.boolean(),
2157
+ content: z17.string(),
2022
2158
  /** sha256 of the bytes, or null when the file does not exist yet. */
2023
- version: z15.string().nullable()
2159
+ version: z17.string().nullable()
2024
2160
  });
2025
- var setAgentConfigInputSchema = z15.object({
2026
- content: z15.string().max(2e6),
2027
- version: z15.string().nullable()
2161
+ var setAgentConfigInputSchema = z17.object({
2162
+ content: z17.string().max(2e6),
2163
+ version: z17.string().nullable()
2028
2164
  });
2029
2165
 
2030
2166
  // ../contract/src/agent-profiles.ts
2031
- import { z as z16 } from "zod";
2167
+ import { z as z18 } from "zod";
2032
2168
  var DEFAULT_AGENT_ACCOUNT_ID = "default";
2033
- var agentAccountFileSchema = z16.object({
2034
- id: z16.string(),
2169
+ var agentAccountFileSchema = z18.object({
2170
+ id: z18.string(),
2035
2171
  /** e.g. `settings.json` — the file's own name, since the folder is shown once on the account. */
2036
- label: z16.string(),
2172
+ label: z18.string(),
2037
2173
  /** Absolute, resolved inside this account's config folder. */
2038
- path: z16.string(),
2039
- exists: z16.boolean()
2174
+ path: z18.string(),
2175
+ exists: z18.boolean()
2040
2176
  });
2041
- var agentProfileSchema = z16.object({
2177
+ var agentProfileSchema = z18.object({
2042
2178
  /** `default` for the discovered profile, else the stored slug. */
2043
- id: z16.string(),
2179
+ id: z18.string(),
2044
2180
  provider: providerIdSchema,
2045
- label: z16.string(),
2181
+ label: z18.string(),
2046
2182
  /** As the user wrote it — a literal `~` is preserved, matching `browseRoot`/`projectsDir`. */
2047
- configDir: z16.string(),
2183
+ configDir: z18.string(),
2048
2184
  /** Expanded absolute path. Same-origin route, like `ProjectListEntry.root`. */
2049
- path: z16.string(),
2185
+ path: z18.string(),
2050
2186
  /** False for a dir the CLI has not created yet — legitimate, and NOT a reason to fall back
2051
2187
  * to another account at run time (that would silently bill the wrong subscription). */
2052
- exists: z16.boolean(),
2188
+ exists: z18.boolean(),
2053
2189
  /** Whether the dir carries this agent's own marker files. ADVISORY: an unrecognised dir is
2054
2190
  * still accepted, because "add profile → Connect → the CLI creates it" is the real flow. */
2055
- looksValid: z16.boolean(),
2191
+ looksValid: z18.boolean(),
2056
2192
  /** True for the profile cezar discovers from the environment. Never stored, never deletable. */
2057
- isDefault: z16.boolean(),
2193
+ isDefault: z18.boolean(),
2058
2194
  /** This account's own authentication state — two Claude logins answer independently.
2059
2195
  *
2060
2196
  * **Absent until the probe has warmed.** Every probe shells out to an agent CLI, and this
@@ -2065,36 +2201,36 @@ var agentProfileSchema = z16.object({
2065
2201
  status: providerStatusSchema.optional(),
2066
2202
  /** This agent's own user-scope config files, resolved inside THIS account's folder — so a
2067
2203
  * second login's `settings.json` is the one you open, not the default account's. */
2068
- files: z16.array(agentAccountFileSchema)
2204
+ files: z18.array(agentAccountFileSchema)
2069
2205
  });
2070
2206
  function agentAccountRouteId(profile) {
2071
2207
  return profile.isDefault ? `default:${profile.provider}` : profile.id;
2072
2208
  }
2073
- var agentAccountSelectionSchema = z16.object({
2074
- claude: z16.string().optional(),
2075
- codex: z16.string().optional(),
2076
- opencode: z16.string().optional(),
2077
- pi: z16.string().optional(),
2078
- cursor: z16.string().optional()
2079
- });
2080
- var agentProfilesResponseSchema = z16.object({
2081
- editable: z16.boolean(),
2082
- profiles: z16.array(agentProfileSchema),
2209
+ var agentAccountSelectionSchema = z18.object({
2210
+ claude: z18.string().optional(),
2211
+ codex: z18.string().optional(),
2212
+ opencode: z18.string().optional(),
2213
+ pi: z18.string().optional(),
2214
+ cursor: z18.string().optional()
2215
+ });
2216
+ var agentProfilesResponseSchema = z18.object({
2217
+ editable: z18.boolean(),
2218
+ profiles: z18.array(agentProfileSchema),
2083
2219
  /** Providers that can carry more than one account at all — what "Add account" is offered for.
2084
2220
  * OpenCode is absent: its credentials live in a SQLite DB behind a separate `OPENCODE_DB`, so
2085
2221
  * a config-dir profile would swap settings while still billing the other account. */
2086
- profileCapableProviders: z16.array(providerIdSchema),
2222
+ profileCapableProviders: z18.array(providerIdSchema),
2087
2223
  /** Which account each project uses, keyed by the project's realpath'd ROOT.
2088
2224
  *
2089
2225
  * Served here rather than on `GET /api/v1/projects` because it is stored beside the accounts it
2090
2226
  * names (`~/.cezar/agent-accounts.json`) — one file, so deleting an account and scrubbing every
2091
2227
  * reference to it is one atomic write, and neither can be dropped by a cezar version that never
2092
2228
  * heard of accounts. Empty in hosted mode, where the whole family is withheld. */
2093
- selections: z16.record(z16.string(), agentAccountSelectionSchema),
2229
+ selections: z18.record(z18.string(), agentAccountSelectionSchema),
2094
2230
  /** The machine-wide fallback account per provider, used by any repo that has chosen none. */
2095
2231
  defaults: agentAccountSelectionSchema
2096
2232
  });
2097
- var selectAgentProfileInputSchema = z16.object({
2233
+ var selectAgentProfileInputSchema = z18.object({
2098
2234
  /**
2099
2235
  * Registry slug, or the reserved `default` boot alias. Resolved to a root server-side.
2100
2236
  *
@@ -2102,192 +2238,228 @@ var selectAgentProfileInputSchema = z16.object({
2102
2238
  * chosen nothing uses, so a second login is set up once rather than per checkout. A repo's own
2103
2239
  * choice always wins over it, which is what keeps this a default and not an override.
2104
2240
  */
2105
- projectId: z16.string().min(1).max(64).nullable(),
2241
+ projectId: z18.string().min(1).max(64).nullable(),
2106
2242
  provider: providerIdSchema,
2107
- profileId: z16.string().max(64).nullable()
2243
+ profileId: z18.string().max(64).nullable()
2108
2244
  });
2109
- var agentProfileSelectionsResponseSchema = z16.object({
2110
- selections: z16.record(z16.string(), agentAccountSelectionSchema),
2245
+ var agentProfileSelectionsResponseSchema = z18.object({
2246
+ selections: z18.record(z18.string(), agentAccountSelectionSchema),
2111
2247
  /** The machine-wide fallback, for repos with no selection of their own. */
2112
2248
  defaults: agentAccountSelectionSchema
2113
2249
  });
2114
- var agentAccountStatusResponseSchema = z16.object({ status: providerStatusSchema });
2115
- var agentAccountDetailsResponseSchema = z16.object({
2116
- available: z16.boolean(),
2117
- reason: z16.string().optional(),
2118
- fields: z16.array(z16.object({ label: z16.string(), value: z16.string() }))
2250
+ var agentAccountStatusResponseSchema = z18.object({ status: providerStatusSchema });
2251
+ var agentAccountDetailsResponseSchema = z18.object({
2252
+ available: z18.boolean(),
2253
+ reason: z18.string().optional(),
2254
+ fields: z18.array(z18.object({ label: z18.string(), value: z18.string() }))
2119
2255
  });
2120
- var openAgentAccountFileInputSchema = z16.object({
2121
- file: z16.string().min(1).max(200),
2122
- target: z16.string().min(1).max(64).optional()
2256
+ var openAgentAccountFileInputSchema = z18.object({
2257
+ file: z18.string().min(1).max(200),
2258
+ target: z18.string().min(1).max(64).optional()
2123
2259
  });
2124
- var openAgentAccountFileResponseSchema = z16.object({
2125
- opened: z16.literal(true),
2126
- path: z16.string()
2260
+ var openAgentAccountFileResponseSchema = z18.object({
2261
+ opened: z18.literal(true),
2262
+ path: z18.string()
2127
2263
  });
2128
- var createAgentProfileInputSchema = z16.object({
2264
+ var createAgentProfileInputSchema = z18.object({
2129
2265
  provider: providerIdSchema,
2130
- label: z16.string().trim().max(200).optional(),
2266
+ label: z18.string().trim().max(200).optional(),
2131
2267
  /** Stored as written; validated absolute after `~` expansion, server-side. */
2132
- configDir: z16.string().trim().min(1).max(4096)
2268
+ configDir: z18.string().trim().min(1).max(4096)
2133
2269
  });
2134
- var agentProfileResponseSchema = z16.object({ profile: agentProfileSchema });
2135
- var updateAgentProfileInputSchema = z16.object({
2136
- label: z16.string().trim().max(200).optional(),
2137
- configDir: z16.string().trim().min(1).max(4096).optional()
2270
+ var agentProfileResponseSchema = z18.object({ profile: agentProfileSchema });
2271
+ var updateAgentProfileInputSchema = z18.object({
2272
+ label: z18.string().trim().max(200).optional(),
2273
+ configDir: z18.string().trim().min(1).max(4096).optional()
2138
2274
  });
2139
- var removeAgentProfileResponseSchema = z16.object({
2140
- removed: z16.literal(true),
2141
- id: z16.string()
2275
+ var removeAgentProfileResponseSchema = z18.object({
2276
+ removed: z18.literal(true),
2277
+ id: z18.string()
2142
2278
  });
2143
2279
 
2144
2280
  // ../contract/src/automations.ts
2145
- import { z as z17 } from "zod";
2146
- var automationEventSchema = z17.enum([
2281
+ import { z as z19 } from "zod";
2282
+ var automationEventSchema = z19.enum([
2147
2283
  "pull_request.opened",
2148
2284
  "issue.opened",
2149
2285
  "issue.labeled",
2150
2286
  "issue.unlabeled"
2151
2287
  ]);
2152
- var automationFiltersSchema = z17.object({
2153
- authors: z17.array(z17.string()).optional(),
2154
- assignees: z17.array(z17.string()).optional(),
2155
- allLabels: z17.array(z17.string()).optional(),
2156
- anyLabels: z17.array(z17.string()).optional(),
2157
- excludeLabels: z17.array(z17.string()).optional(),
2288
+ var automationFiltersSchema = z19.object({
2289
+ authors: z19.array(z19.string()).optional(),
2290
+ assignees: z19.array(z19.string()).optional(),
2291
+ allLabels: z19.array(z19.string()).optional(),
2292
+ anyLabels: z19.array(z19.string()).optional(),
2293
+ excludeLabels: z19.array(z19.string()).optional(),
2158
2294
  /** Required for the two label events — the server rejects a definition without it. */
2159
- changedLabels: z17.array(z17.string()).optional(),
2160
- lookbackDays: z17.number(),
2161
- maxRecords: z17.number()
2295
+ changedLabels: z19.array(z19.string()).optional(),
2296
+ lookbackDays: z19.number(),
2297
+ maxRecords: z19.number()
2162
2298
  });
2163
2299
  var automationTaskSchema = createRunInputBaseSchema.omit({ task: true, images: true, todoId: true, systemPrompt: true }).extend({
2164
2300
  /** The prompt template. `{{github.number}}`, `{{github.title}}`, `{{github.url}}` and
2165
2301
  * `{{github.labels}}` are substituted per match; GitHub content is appended as untrusted
2166
2302
  * context, never interpolated into instructions. */
2167
- prompt: z17.string(),
2168
- variants: z17.union([z17.literal(1), z17.literal(2), z17.literal(3)]).optional(),
2169
- systemPrompt: z17.string().optional()
2303
+ prompt: z19.string(),
2304
+ variants: z19.union([z19.literal(1), z19.literal(2), z19.literal(3)]).optional(),
2305
+ systemPrompt: z19.string().optional()
2170
2306
  });
2171
- var automationDefinitionSchema = z17.object({
2172
- id: z17.string(),
2307
+ var automationDefinitionSchema = z19.object({
2308
+ id: z19.string(),
2173
2309
  /** Bumped on every edit; a PUT must echo the revision it read (optimistic concurrency). */
2174
- revision: z17.number(),
2175
- name: z17.string(),
2176
- description: z17.string().optional(),
2310
+ revision: z19.number(),
2311
+ name: z19.string(),
2312
+ description: z19.string().optional(),
2177
2313
  /** Always present: the storage schema defaults it to `false`, so a definition is created
2178
2314
  * PAUSED and enabling it is a separate, baseline-establishing act. */
2179
- enabled: z17.boolean(),
2180
- events: z17.array(automationEventSchema),
2181
- intervalSeconds: z17.number(),
2315
+ enabled: z19.boolean(),
2316
+ events: z19.array(automationEventSchema),
2317
+ intervalSeconds: z19.number(),
2182
2318
  filters: automationFiltersSchema,
2183
2319
  task: automationTaskSchema,
2184
- createdAt: z17.string(),
2185
- updatedAt: z17.string()
2320
+ createdAt: z19.string(),
2321
+ updatedAt: z19.string()
2186
2322
  });
2187
- var automationCursorSchema = z17.object({
2188
- timestamp: z17.string(),
2189
- tieBreaker: z17.string().optional()
2323
+ var automationCursorSchema = z19.object({
2324
+ timestamp: z19.string(),
2325
+ tieBreaker: z19.string().optional()
2190
2326
  });
2191
- var automationRuntimeStateSchema = z17.object({
2327
+ var automationRuntimeStateSchema = z19.object({
2192
2328
  /** The definition revision this state belongs to; a bumped revision re-baselines. */
2193
- revision: z17.number().optional(),
2329
+ revision: z19.number().optional(),
2194
2330
  /** Enabling establishes a CURRENT-TIME baseline: records older than this never launch. */
2195
- baselineAt: z17.string().optional(),
2331
+ baselineAt: z19.string().optional(),
2196
2332
  cursor: automationCursorSchema.optional(),
2197
- frozenHighWatermark: automationCursorSchema.extend({ tieBreaker: z17.string() }).optional(),
2198
- backlogAfter: automationCursorSchema.extend({ tieBreaker: z17.string() }).optional(),
2199
- nextCheckAt: z17.string().optional(),
2200
- lastSuccessAt: z17.string().optional(),
2333
+ frozenHighWatermark: automationCursorSchema.extend({ tieBreaker: z19.string() }).optional(),
2334
+ backlogAfter: automationCursorSchema.extend({ tieBreaker: z19.string() }).optional(),
2335
+ nextCheckAt: z19.string().optional(),
2336
+ lastSuccessAt: z19.string().optional(),
2201
2337
  /** Per-query GitHub ETags, so an unchanged page costs no rate-limit budget. */
2202
- etags: z17.record(z17.string(), z17.string()).optional(),
2203
- backoffUntil: z17.string().optional(),
2204
- consecutiveFailures: z17.number().optional()
2338
+ etags: z19.record(z19.string(), z19.string()).optional(),
2339
+ backoffUntil: z19.string().optional(),
2340
+ consecutiveFailures: z19.number().optional()
2205
2341
  });
2206
- var automationLogResultSchema = z17.enum([
2342
+ var automationLogResultSchema = z19.enum([
2207
2343
  "launched",
2208
2344
  "no-match",
2209
2345
  "duplicate",
2210
2346
  "rate-limited",
2211
2347
  "error",
2212
2348
  "baseline",
2213
- "preview"
2349
+ "preview",
2350
+ "skipped"
2214
2351
  ]);
2215
- var automationLogRecordSchema = z17.object({
2216
- seq: z17.number(),
2217
- ts: z17.string(),
2218
- automationId: z17.string(),
2219
- revision: z17.number(),
2352
+ var automationLogRecordSchema = z19.object({
2353
+ seq: z19.number(),
2354
+ ts: z19.string(),
2355
+ automationId: z19.string(),
2356
+ revision: z19.number(),
2220
2357
  event: automationEventSchema.optional(),
2221
2358
  result: automationLogResultSchema,
2222
- reason: z17.string().optional(),
2223
- durationMs: z17.number().optional(),
2224
- receiptId: z17.string().optional(),
2225
- runId: z17.string().optional(),
2226
- githubNumber: z17.number().optional(),
2227
- githubTitle: z17.string().optional(),
2228
- githubUrl: z17.string().optional(),
2229
- rateLimit: z17.object({
2230
- bucket: z17.enum(["core", "search"]),
2231
- remaining: z17.number().optional(),
2232
- resetAt: z17.string().optional()
2359
+ reason: z19.string().optional(),
2360
+ durationMs: z19.number().optional(),
2361
+ receiptId: z19.string().optional(),
2362
+ runId: z19.string().optional(),
2363
+ githubNumber: z19.number().optional(),
2364
+ githubTitle: z19.string().optional(),
2365
+ githubUrl: z19.string().optional(),
2366
+ rateLimit: z19.object({
2367
+ bucket: z19.enum(["core", "search"]),
2368
+ remaining: z19.number().optional(),
2369
+ resetAt: z19.string().optional()
2233
2370
  }).optional()
2234
2371
  });
2235
- var automationCountsSchema = z17.object({
2236
- matches: z17.number(),
2237
- launched: z17.number(),
2238
- duplicates: z17.number(),
2239
- errors: z17.number()
2372
+ var automationCountsSchema = z19.object({
2373
+ matches: z19.number(),
2374
+ launched: z19.number(),
2375
+ duplicates: z19.number(),
2376
+ errors: z19.number()
2240
2377
  });
2241
2378
  var automationListEntrySchema = automationDefinitionSchema.extend({
2242
2379
  state: automationRuntimeStateSchema.optional(),
2243
2380
  latestLog: automationLogRecordSchema.optional(),
2244
2381
  counts: automationCountsSchema
2245
2382
  });
2246
- var automationsResponseSchema = z17.object({
2247
- available: z17.boolean(),
2248
- reason: z17.string().optional(),
2249
- scheduler: z17.object({
2250
- state: z17.enum(["scheduled", "idle"]),
2251
- nextDue: z17.string().optional()
2383
+ var automationsResponseSchema = z19.object({
2384
+ available: z19.boolean(),
2385
+ reason: z19.string().optional(),
2386
+ scheduler: z19.object({
2387
+ state: z19.enum(["scheduled", "idle"]),
2388
+ nextDue: z19.string().optional()
2252
2389
  }),
2253
- automations: z17.array(automationListEntrySchema)
2390
+ automations: z19.array(automationListEntrySchema)
2254
2391
  });
2255
- var automationResponseSchema = z17.object({ automation: automationDefinitionSchema });
2256
- var automationDetailResponseSchema = z17.object({
2392
+ var automationResponseSchema = z19.object({ automation: automationDefinitionSchema });
2393
+ var automationDetailResponseSchema = z19.object({
2257
2394
  automation: automationDefinitionSchema,
2258
2395
  state: automationRuntimeStateSchema.optional(),
2259
2396
  latestLog: automationLogRecordSchema.optional()
2260
2397
  });
2261
- var automationCheckSchema = z17.object({
2262
- id: z17.string(),
2263
- automationId: z17.string(),
2264
- mode: z17.enum(["preview", "execute"]),
2265
- status: z17.enum(["queued", "running", "complete", "error"]),
2266
- createdAt: z17.string(),
2267
- completedAt: z17.string().optional(),
2268
- matches: z17.number().optional(),
2269
- truncated: z17.boolean().optional(),
2270
- error: z17.string().optional()
2271
- });
2272
- var automationCheckQueuedResponseSchema = z17.object({ checkId: z17.string() });
2273
- var automationLogResponseSchema = z17.object({
2274
- records: z17.array(automationLogRecordSchema)
2275
- });
2276
- var automationRetryResponseSchema = z17.object({
2277
- receiptId: z17.string(),
2278
- runId: z17.string()
2279
- });
2280
- var createAutomationInputSchema = automationDefinitionSchema.omit({ id: true, revision: true, createdAt: true, updatedAt: true, enabled: true }).extend({ enable: z17.boolean().optional() });
2398
+ var automationCheckSchema = z19.object({
2399
+ id: z19.string(),
2400
+ automationId: z19.string(),
2401
+ mode: z19.enum(["preview", "execute"]),
2402
+ status: z19.enum(["queued", "running", "complete", "error"]),
2403
+ createdAt: z19.string(),
2404
+ completedAt: z19.string().optional(),
2405
+ matches: z19.number().optional(),
2406
+ truncated: z19.boolean().optional(),
2407
+ error: z19.string().optional()
2408
+ });
2409
+ var automationCheckQueuedResponseSchema = z19.object({ checkId: z19.string() });
2410
+ var automationLogResponseSchema = z19.object({
2411
+ records: z19.array(automationLogRecordSchema)
2412
+ });
2413
+ var automationRetryResponseSchema = z19.object({
2414
+ receiptId: z19.string(),
2415
+ runId: z19.string()
2416
+ });
2417
+ var createAutomationInputSchema = automationDefinitionSchema.omit({ id: true, revision: true, createdAt: true, updatedAt: true, enabled: true }).extend({ enable: z19.boolean().optional() });
2281
2418
  var updateAutomationInputSchema = createAutomationInputSchema.omit({ enable: true }).extend({
2282
- enabled: z17.boolean().optional(),
2283
- expectedRevision: z17.number()
2419
+ enabled: z19.boolean().optional(),
2420
+ expectedRevision: z19.number()
2284
2421
  });
2285
- var automationCheckInputSchema = z17.object({
2286
- mode: z17.enum(["preview", "execute"])
2422
+ var automationCheckInputSchema = z19.object({
2423
+ mode: z19.enum(["preview", "execute"])
2287
2424
  });
2425
+
2426
+ // ../contract/src/artifacts.ts
2427
+ import { z as z20 } from "zod";
2428
+ var pathSchema = z20.string().min(1).max(8192).refine((value) => !value.includes("\0"), "Path contains NUL");
2429
+ var publishedArtifactSchema = z20.object({
2430
+ id: z20.uuid(),
2431
+ runId: z20.uuid(),
2432
+ name: z20.string().min(1).max(255),
2433
+ sourcePath: pathSchema.refine((value) => /^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(value), "Expected an absolute source path"),
2434
+ createdAt: z20.iso.datetime(),
2435
+ size: z20.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
2436
+ sha256: z20.string().regex(/^[a-f0-9]{64}$/)
2437
+ }).strict();
2438
+ var filePreviewDataSchema = z20.object({
2439
+ type: z20.literal("file"),
2440
+ path: pathSchema,
2441
+ size: z20.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
2442
+ binary: z20.boolean(),
2443
+ tooLarge: z20.boolean(),
2444
+ content: z20.string().optional(),
2445
+ source: z20.enum(["worktree", "project", "artifact"]),
2446
+ artifact: publishedArtifactSchema.optional()
2447
+ }).strict();
2448
+ var fileLinkResultSchema = z20.union([
2449
+ filePreviewDataSchema,
2450
+ z20.object({
2451
+ type: z20.enum(["unavailable", "unpublished"]),
2452
+ path: pathSchema,
2453
+ reason: z20.string().min(1).max(4096)
2454
+ }).strict()
2455
+ ]);
2456
+ var artifactListSchema = z20.object({ artifacts: z20.array(publishedArtifactSchema).max(64) }).strict();
2457
+ var fileLinkQuerySchema = z20.object({ path: pathSchema, raw: z20.literal("1").optional() }).strict();
2458
+ var artifactParamsSchema = z20.object({ id: z20.uuid(), artifactId: z20.uuid() });
2288
2459
  export {
2289
2460
  CI_WAIT_LIMITATION,
2290
2461
  CI_WAIT_RECEIPT_INSTRUCTION,
2462
+ CLIENT_REQUEST_VARIANTS_ERROR,
2291
2463
  DEFAULT_AGENT_ACCOUNT_ID,
2292
2464
  EFFORT_LEVELS,
2293
2465
  FILE_ATTACHMENT_MEDIA_TYPES,
@@ -2295,6 +2467,8 @@ export {
2295
2467
  MODEL_DISCOVERY_RUNNERS,
2296
2468
  PROJECT_TAGS_MAX,
2297
2469
  PROJECT_TAG_MAX_LENGTH,
2470
+ PROJECT_WEBHOOK_TOKEN_MAX_LENGTH,
2471
+ PROJECT_WEBHOOK_URL_MAX_LENGTH,
2298
2472
  REFERENCE_STATUS_MAX,
2299
2473
  RUN_HISTORY_PAGE_ITEMS,
2300
2474
  advancePendingHumanAsk,
@@ -2317,7 +2491,12 @@ export {
2317
2491
  agentProfileSelectionsResponseSchema,
2318
2492
  agentProfilesResponseSchema,
2319
2493
  apiRunSchema,
2494
+ applicationUpdateInputSchema,
2495
+ applicationUpdateResponseSchema,
2496
+ applicationUpdateStateSchema,
2320
2497
  archiveFinishedResponseSchema,
2498
+ artifactListSchema,
2499
+ artifactParamsSchema,
2321
2500
  askOptionSchema,
2322
2501
  askQuestionSchema,
2323
2502
  askRequestSchema,
@@ -2365,6 +2544,7 @@ export {
2365
2544
  conversationAttributionSchema,
2366
2545
  conversationCancelRequestSchema,
2367
2546
  conversationInspectRequestSchema,
2547
+ conversationInspectResultSchema,
2368
2548
  conversationMessageEventSchema,
2369
2549
  conversationMessageSchema,
2370
2550
  conversationSendRequestSchema,
@@ -2381,9 +2561,16 @@ export {
2381
2561
  deleteRunResponseSchema,
2382
2562
  deleteWorkflowResponseSchema,
2383
2563
  diffStatSchema,
2564
+ discoveredRunnerSchema,
2565
+ discoveredRunnersSchema,
2566
+ discoveryRequestSchema,
2567
+ discoveryResponseSchema,
2384
2568
  editQueuedMessageResponseSchema,
2385
2569
  effortFieldSchema,
2386
2570
  effortLevelSchema,
2571
+ fileLinkQuerySchema,
2572
+ fileLinkResultSchema,
2573
+ filePreviewDataSchema,
2387
2574
  finishResponseSchema,
2388
2575
  forgeInfoSchema,
2389
2576
  fsBrowseDirSchema,
@@ -2414,6 +2601,10 @@ export {
2414
2601
  humanInputDeliveredEventSchema,
2415
2602
  imageInputSchema,
2416
2603
  importableSkillSchema,
2604
+ inboxClaimSchema,
2605
+ inboxReceiptRequestSchema,
2606
+ inboxReceiptResultSchema,
2607
+ inboxReserveResultSchema,
2417
2608
  isAttachmentMediaType,
2418
2609
  isImageAttachmentName,
2419
2610
  isImageMediaType,
@@ -2422,7 +2613,9 @@ export {
2422
2613
  markAllReadResponseSchema,
2423
2614
  messageInputSchema,
2424
2615
  messageResponseSchema,
2616
+ modelChoicesSchema,
2425
2617
  modelDiscoveryRunnerSchema,
2618
+ notifyRunInputSchema,
2426
2619
  openAgentAccountFileInputSchema,
2427
2620
  openAgentAccountFileResponseSchema,
2428
2621
  openInCliResponseSchema,
@@ -2439,6 +2632,8 @@ export {
2439
2632
  planResponseSchema,
2440
2633
  processUsageSchema,
2441
2634
  projectListEntrySchema,
2635
+ projectWebhookInputSchema,
2636
+ projectWebhookUrlSchema,
2442
2637
  projectsResponseSchema,
2443
2638
  providerConnectResponseSchema,
2444
2639
  providerConnectionStateSchema,
@@ -2446,6 +2641,7 @@ export {
2446
2641
  providerStatusResponseSchema,
2447
2642
  providerStatusSchema,
2448
2643
  providersRequiredByWorkflow,
2644
+ publishedArtifactSchema,
2449
2645
  queuedMessageSchema,
2450
2646
  reclaimWorktreesResponseSchema,
2451
2647
  referenceStatusSchema,
@@ -2484,6 +2680,7 @@ export {
2484
2680
  runRecordSchema,
2485
2681
  runRelationshipsSchema,
2486
2682
  runStatusSchema,
2683
+ runWebhookOutcomeSchema,
2487
2684
  runnerDiscoversModels,
2488
2685
  runnerModelCatalogResponseSchema,
2489
2686
  runnerModelOptionSchema,
@@ -2506,6 +2703,7 @@ export {
2506
2703
  statusEntrySchema,
2507
2704
  stepStateSchema,
2508
2705
  stepStatusSchema,
2706
+ testProjectWebhookResponseSchema,
2509
2707
  todoItemSchema,
2510
2708
  uiStateSchema,
2511
2709
  updateAgentProfileInputSchema,
@@ -2531,6 +2729,8 @@ export {
2531
2729
  workerOutcomeEventSchema,
2532
2730
  workerOutcomeSchema,
2533
2731
  workerParamsSchema,
2732
+ workerQuestionFallbackEventSchema,
2733
+ workerQuestionRoutedEventSchema,
2534
2734
  workerResultFileSchema,
2535
2735
  workerResultReferenceSchema,
2536
2736
  workerSpawnRequestSchema,