@wjarka/cezarion 0.14.8 → 0.14.9-dev.842

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 (207) hide show
  1. package/README.md +76 -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/ci-wait/mcp.d.ts +3 -0
  36. package/dist/ci-wait/mcp.js +14 -3
  37. package/dist/ci-wait/mcp.js.map +1 -1
  38. package/dist/contract/application-update.d.ts +32 -0
  39. package/dist/contract/artifacts.d.ts +83 -0
  40. package/dist/contract/ask-schema.d.ts +32 -0
  41. package/dist/contract/ask.d.ts +2 -32
  42. package/dist/contract/conversations.d.ts +165 -0
  43. package/dist/contract/delegation.d.ts +39 -0
  44. package/dist/contract/events.d.ts +49 -0
  45. package/dist/contract/health.d.ts +12 -0
  46. package/dist/contract/index.d.ts +2 -0
  47. package/dist/contract/index.js +1374 -1247
  48. package/dist/contract/runs.d.ts +143 -0
  49. package/dist/contract/skills.d.ts +28 -0
  50. package/dist/core/agent-runner.d.ts +33 -4
  51. package/dist/core/agent-runner.js +5 -0
  52. package/dist/core/agent-runner.js.map +1 -1
  53. package/dist/core/claude-cli-runner.d.ts +6 -12
  54. package/dist/core/claude-cli-runner.js +89 -19
  55. package/dist/core/claude-cli-runner.js.map +1 -1
  56. package/dist/core/codex-app-server-runner.d.ts +2 -1
  57. package/dist/core/codex-app-server-runner.js +327 -92
  58. package/dist/core/codex-app-server-runner.js.map +1 -1
  59. package/dist/core/codex-app-server-transport.d.ts +13 -1
  60. package/dist/core/codex-app-server-transport.js +58 -17
  61. package/dist/core/codex-app-server-transport.js.map +1 -1
  62. package/dist/core/cursor-acp-runner.d.ts +4 -1
  63. package/dist/core/cursor-acp-runner.js +3 -0
  64. package/dist/core/cursor-acp-runner.js.map +1 -1
  65. package/dist/core/cursor-provider-error.js +6 -1
  66. package/dist/core/cursor-provider-error.js.map +1 -1
  67. package/dist/core/input-submissions.d.ts +14 -0
  68. package/dist/core/input-submissions.js +26 -0
  69. package/dist/core/input-submissions.js.map +1 -0
  70. package/dist/core/opencode-server-runner.d.ts +4 -1
  71. package/dist/core/opencode-server-runner.js +144 -21
  72. package/dist/core/opencode-server-runner.js.map +1 -1
  73. package/dist/core/pi-runner.d.ts +2 -1
  74. package/dist/core/pi-runner.js +72 -7
  75. package/dist/core/pi-runner.js.map +1 -1
  76. package/dist/delegation/cli.js +102 -6
  77. package/dist/delegation/cli.js.map +1 -1
  78. package/dist/delegation/conversations.js +13 -5
  79. package/dist/delegation/conversations.js.map +1 -1
  80. package/dist/delegation/input.d.ts +2 -1
  81. package/dist/delegation/input.js +6 -1
  82. package/dist/delegation/input.js.map +1 -1
  83. package/dist/delegation/provision.js +5 -3
  84. package/dist/delegation/provision.js.map +1 -1
  85. package/dist/delegation/questions.d.ts +19 -0
  86. package/dist/delegation/questions.js +45 -0
  87. package/dist/delegation/questions.js.map +1 -0
  88. package/dist/delegation/results.d.ts +1 -1
  89. package/dist/delegation/results.js +23 -13
  90. package/dist/delegation/results.js.map +1 -1
  91. package/dist/delegation/routes.d.ts +142 -15
  92. package/dist/delegation/routes.js +4 -1
  93. package/dist/delegation/routes.js.map +1 -1
  94. package/dist/delegation/service.d.ts +9 -5
  95. package/dist/delegation/service.js +106 -7
  96. package/dist/delegation/service.js.map +1 -1
  97. package/dist/delegation/transport.d.ts +188 -61
  98. package/dist/index.js +72 -26
  99. package/dist/index.js.map +1 -1
  100. package/dist/open-url.d.ts +2 -0
  101. package/dist/open-url.js +20 -0
  102. package/dist/open-url.js.map +1 -0
  103. package/dist/release/snapshot.d.ts +3 -3
  104. package/dist/release/snapshot.js +6 -6
  105. package/dist/release/snapshot.js.map +1 -1
  106. package/dist/runs/client-request.d.ts +11 -0
  107. package/dist/runs/client-request.js +26 -0
  108. package/dist/runs/client-request.js.map +1 -0
  109. package/dist/runs/delegation-state.d.ts +17 -0
  110. package/dist/runs/event-history.js +6 -0
  111. package/dist/runs/event-history.js.map +1 -1
  112. package/dist/runs/store.d.ts +78 -6
  113. package/dist/runs/store.js +163 -1
  114. package/dist/runs/store.js.map +1 -1
  115. package/dist/server/server.d.ts +3761 -1648
  116. package/dist/server/server.js +170 -4
  117. package/dist/server/server.js.map +1 -1
  118. package/dist/task-cli/cli.d.ts +38 -0
  119. package/dist/task-cli/cli.js +463 -0
  120. package/dist/task-cli/cli.js.map +1 -0
  121. package/dist/task-cli/discovery.d.ts +22 -0
  122. package/dist/task-cli/discovery.js +95 -0
  123. package/dist/task-cli/discovery.js.map +1 -0
  124. package/dist/task-cli/http.d.ts +43 -0
  125. package/dist/task-cli/http.js +101 -0
  126. package/dist/task-cli/http.js.map +1 -0
  127. package/dist/task-cli/projections.d.ts +40 -0
  128. package/dist/task-cli/projections.js +45 -0
  129. package/dist/task-cli/projections.js.map +1 -0
  130. package/dist/task-cli/watch.d.ts +78 -0
  131. package/dist/task-cli/watch.js +336 -0
  132. package/dist/task-cli/watch.js.map +1 -0
  133. package/dist/workflows/run.d.ts +93 -0
  134. package/dist/workflows/run.js +816 -81
  135. package/dist/workflows/run.js.map +1 -1
  136. package/dist/workspace/projects-cli.js +1 -1
  137. package/package.json +3 -3
  138. package/scripts/mock-claude.mjs +38 -2
  139. package/scripts/mock-codex-app-server.mjs +98 -1
  140. package/scripts/mock-cursor-acp.mjs +8 -0
  141. package/scripts/mock-opencode-serve.mjs +69 -2
  142. package/scripts/mock-pi-rpc.mjs +63 -2
  143. package/web/dist/assets/agent-accounts-JPfZPgKn.js +1 -0
  144. package/web/dist/assets/centered-state-HwCqQkH3.js +43 -0
  145. package/web/dist/assets/collapsible-CTymFdL7.js +1 -0
  146. package/web/dist/assets/commit-list-BZpYGQl2.js +1 -0
  147. package/web/dist/assets/compare-variants-9VkybaQ7.js +1 -0
  148. package/web/dist/assets/{diff-tRE59UNb2.js → diff-CZcD4D1r2.js} +2 -2
  149. package/web/dist/assets/diff-controls-CpcHG3Mm.js +1 -0
  150. package/web/dist/assets/{diff-stat-Cgnl_hYF.js → diff-stat-Cn7rzy1H.js} +1 -1
  151. package/web/dist/assets/{diff-view-DN1ort7Q.js → diff-view-C46nHiP2.js} +2 -2
  152. package/web/dist/assets/dropdown-menu-_YAzCaoQ.js +1 -0
  153. package/web/dist/assets/git-toolbar-BvKDz6uS.js +1 -0
  154. package/web/dist/assets/github-CgjJCGrD.js +1 -0
  155. package/web/dist/assets/{image-preview-C2JGcBlC.js → image-preview-B618kDBH.js} +1 -1
  156. package/web/dist/assets/index-BJtve0Pm.js +7 -0
  157. package/web/dist/assets/index-D0WAgmTQ.css +1 -0
  158. package/web/dist/assets/markdown-CFWZnvMh.js +2 -0
  159. package/web/dist/assets/pill-QfwkuR50.js +1 -0
  160. package/web/dist/assets/project-router-CkAA39N5.js +1 -0
  161. package/web/dist/assets/prompt-templates-Cfna_S0T.js +15 -0
  162. package/web/dist/assets/repo-git-DgzgJ0cP.js +1 -0
  163. package/web/dist/assets/{run-diff-CyG0Nciv.js → run-diff-YbCEQn5I.js} +2 -2
  164. package/web/dist/assets/run-header-DMgIbr1d.js +1 -0
  165. package/web/dist/assets/skills-BW79kUTd.js +1 -0
  166. package/web/dist/assets/{tab-link-BWNp3mLY.js → tab-link-MIHvczEm.js} +1 -1
  167. package/web/dist/assets/task-changes-C96ekt94.js +1 -0
  168. package/web/dist/assets/task-commits-DBfcMZyG.js +1 -0
  169. package/web/dist/assets/task-files-BKpH8dKQ.js +2 -0
  170. package/web/dist/assets/task-thread-Bw_nQuTx.css +1 -0
  171. package/web/dist/assets/task-thread-Dnq7Ek6W.js +9 -0
  172. package/web/dist/assets/textarea-D2vAVgYW.js +1 -0
  173. package/web/dist/assets/thread-loading-NW8Mthco.js +1 -0
  174. package/web/dist/assets/token-metrics-D188e6_0.js +1 -0
  175. package/web/dist/assets/utils-DKheTxGD.js +64 -0
  176. package/web/dist/assets/workflows-BFY1hgp3.js +11 -0
  177. package/web/dist/assets/{zoomable-image-Z3JDnm0b.js → zoomable-image-YW3Qdrr_.js} +1 -1
  178. package/web/dist/index.html +14 -14
  179. package/web/dist/assets/agent-accounts-BZm_2WAv.js +0 -1
  180. package/web/dist/assets/alert-dialog-B422RI-k.js +0 -43
  181. package/web/dist/assets/collapsible-Cy_Fmkrd.js +0 -1
  182. package/web/dist/assets/commit-list-Dcnk7TnI.js +0 -1
  183. package/web/dist/assets/compare-variants-Ciqwvd_f.js +0 -1
  184. package/web/dist/assets/diff-controls-BGrXGi7O.js +0 -1
  185. package/web/dist/assets/dropdown-menu-dwDGT8MM.js +0 -1
  186. package/web/dist/assets/git-toolbar-UiHnGvE0.js +0 -1
  187. package/web/dist/assets/github-D-MrkbJ7.js +0 -1
  188. package/web/dist/assets/ibm-plex-mono-regular-BF3vfe7_.ttf +0 -0
  189. package/web/dist/assets/index-BszfYvBq.js +0 -7
  190. package/web/dist/assets/index-CWh4pKP3.css +0 -1
  191. package/web/dist/assets/markdown-C_IcKVQd.js +0 -2
  192. package/web/dist/assets/pill-BsbO6G7y.js +0 -1
  193. package/web/dist/assets/project-router-DbLkll25.js +0 -1
  194. package/web/dist/assets/prompt-templates-BlTGJB5W.js +0 -15
  195. package/web/dist/assets/repo-git-Bm3s6Why.js +0 -1
  196. package/web/dist/assets/run-header-IFyIGCey.js +0 -1
  197. package/web/dist/assets/skills-C-C4DVFY.js +0 -1
  198. package/web/dist/assets/task-changes-D2PHtWUW.js +0 -1
  199. package/web/dist/assets/task-commits-N5u9U0_R.js +0 -1
  200. package/web/dist/assets/task-files-BS7c7CFm.js +0 -2
  201. package/web/dist/assets/task-thread-BQFdz1dJ.css +0 -1
  202. package/web/dist/assets/task-thread-DGM2dZV-.js +0 -9
  203. package/web/dist/assets/textarea-FjaU370i.js +0 -1
  204. package/web/dist/assets/thread-loading-77sJ8Yu_.js +0 -1
  205. package/web/dist/assets/token-metrics-Clxh03bE.js +0 -1
  206. package/web/dist/assets/utils-PYYcpCFZ.js +0 -64
  207. package/web/dist/assets/workflows-Czl0ZfXH.js +0 -11
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { z } from 'zod';
3
- import type { CiWait, ConversationState, AgentInput, DelegationState, WorkerCollectedResult } from '../contract/index.js';
3
+ import type { CiWait, ConversationState, AgentInput, InboxClaim, DelegationState, WorkerCollectedResult } from '../contract/index.js';
4
4
  import { type WorkerExecutionIdentity } from '../delegation/execution-identity.ts';
5
5
  import { workflowDefSchema } from '../workflows/types.ts';
6
6
  import type { RunnerId } from '../core/agent-runner.ts';
@@ -125,6 +125,18 @@ export declare const runRecordSchema: z.ZodObject<{
125
125
  }>;
126
126
  resumed: z.ZodOptional<z.ZodLiteral<true>>;
127
127
  instruction: z.ZodOptional<z.ZodString>;
128
+ question: z.ZodOptional<z.ZodObject<{
129
+ questions: z.ZodArray<z.ZodObject<{
130
+ id: z.ZodOptional<z.ZodString>;
131
+ header: z.ZodString;
132
+ question: z.ZodString;
133
+ options: z.ZodArray<z.ZodObject<{
134
+ label: z.ZodString;
135
+ description: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strict>>;
137
+ multiSelect: z.ZodOptional<z.ZodBoolean>;
138
+ }, z.core.$strict>>;
139
+ }, z.core.$strict>>;
128
140
  }, z.core.$strict>>;
129
141
  outcomes: z.ZodArray<z.ZodObject<{
130
142
  requestId: z.ZodUUID;
@@ -133,6 +145,7 @@ export declare const runRecordSchema: z.ZodObject<{
133
145
  "completed-without-reply": "completed-without-reply";
134
146
  destroyed: "destroyed";
135
147
  failed: "failed";
148
+ "human-fallback": "human-fallback";
136
149
  replied: "replied";
137
150
  "sender-closed": "sender-closed";
138
151
  "timed-out": "timed-out";
@@ -175,6 +188,7 @@ export declare const runRecordSchema: z.ZodObject<{
175
188
  "completed-without-reply": "completed-without-reply";
176
189
  destroyed: "destroyed";
177
190
  failed: "failed";
191
+ "human-fallback": "human-fallback";
178
192
  replied: "replied";
179
193
  "sender-closed": "sender-closed";
180
194
  "timed-out": "timed-out";
@@ -228,6 +242,7 @@ export declare const runRecordSchema: z.ZodObject<{
228
242
  "completed-without-reply": "completed-without-reply";
229
243
  destroyed: "destroyed";
230
244
  failed: "failed";
245
+ "human-fallback": "human-fallback";
231
246
  replied: "replied";
232
247
  "sender-closed": "sender-closed";
233
248
  "timed-out": "timed-out";
@@ -316,6 +331,7 @@ export declare const runRecordSchema: z.ZodObject<{
316
331
  "completed-without-reply": "completed-without-reply";
317
332
  destroyed: "destroyed";
318
333
  failed: "failed";
334
+ "human-fallback": "human-fallback";
319
335
  replied: "replied";
320
336
  "sender-closed": "sender-closed";
321
337
  "timed-out": "timed-out";
@@ -369,6 +385,7 @@ export declare const runRecordSchema: z.ZodObject<{
369
385
  "completed-without-reply": "completed-without-reply";
370
386
  destroyed: "destroyed";
371
387
  failed: "failed";
388
+ "human-fallback": "human-fallback";
372
389
  replied: "replied";
373
390
  "sender-closed": "sender-closed";
374
391
  "timed-out": "timed-out";
@@ -486,6 +503,15 @@ export declare const runRecordSchema: z.ZodObject<{
486
503
  text: z.ZodString;
487
504
  createdAt: z.ZodISODateTime;
488
505
  deliveredAt: z.ZodOptional<z.ZodISODateTime>;
506
+ consumedAt: z.ZodOptional<z.ZodISODateTime>;
507
+ awaitingRead: z.ZodOptional<z.ZodLiteral<true>>;
508
+ inboxClaim: z.ZodOptional<z.ZodObject<{
509
+ receiptId: z.ZodUUID;
510
+ generation: z.ZodUUID;
511
+ expiresAt: z.ZodISODateTime;
512
+ acknowledgedAt: z.ZodOptional<z.ZodISODateTime>;
513
+ memberIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
514
+ }, z.core.$strict>>;
489
515
  }, z.core.$strict>>>;
490
516
  ciWait: z.ZodOptional<z.ZodObject<{
491
517
  prUrl: z.ZodString;
@@ -648,6 +674,8 @@ export declare const runRecordSchema: z.ZodObject<{
648
674
  worktreeReclaimedAt: z.ZodOptional<z.ZodString>;
649
675
  groupId: z.ZodOptional<z.ZodString>;
650
676
  variant: z.ZodOptional<z.ZodString>;
677
+ clientRequestId: z.ZodOptional<z.ZodString>;
678
+ clientRequestHash: z.ZodOptional<z.ZodString>;
651
679
  peakRssBytes: z.ZodOptional<z.ZodNumber>;
652
680
  peakProcCount: z.ZodOptional<z.ZodNumber>;
653
681
  archived: z.ZodDefault<z.ZodBoolean>;
@@ -777,10 +805,22 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
777
805
  state: "accepted" | "continuation-required" | "destroyed" | "late";
778
806
  resumed?: true | undefined;
779
807
  instruction?: string | undefined;
808
+ question?: {
809
+ questions: {
810
+ id?: string | undefined;
811
+ header: string;
812
+ question: string;
813
+ options: {
814
+ label: string;
815
+ description?: string | undefined;
816
+ }[];
817
+ multiSelect?: boolean | undefined;
818
+ }[];
819
+ } | undefined;
780
820
  }[];
781
821
  outcomes: {
782
822
  requestId: string;
783
- status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "replied" | "sender-closed" | "timed-out";
823
+ status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "human-fallback" | "replied" | "sender-closed" | "timed-out";
784
824
  observedAt: string;
785
825
  replyId?: string | undefined;
786
826
  }[];
@@ -803,7 +843,7 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
803
843
  requestIds?: string[] | undefined;
804
844
  requestOutcomes?: {
805
845
  requestId: string;
806
- status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "replied" | "sender-closed" | "timed-out";
846
+ status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "human-fallback" | "replied" | "sender-closed" | "timed-out";
807
847
  observedAt: string;
808
848
  replyId?: string | undefined;
809
849
  }[] | undefined;
@@ -830,7 +870,7 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
830
870
  requestIds?: string[] | undefined;
831
871
  requestOutcomes?: {
832
872
  requestId: string;
833
- status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "replied" | "sender-closed" | "timed-out";
873
+ status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "human-fallback" | "replied" | "sender-closed" | "timed-out";
834
874
  observedAt: string;
835
875
  replyId?: string | undefined;
836
876
  }[] | undefined;
@@ -877,7 +917,7 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
877
917
  requestIds?: string[] | undefined;
878
918
  requestOutcomes?: {
879
919
  requestId: string;
880
- status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "replied" | "sender-closed" | "timed-out";
920
+ status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "human-fallback" | "replied" | "sender-closed" | "timed-out";
881
921
  observedAt: string;
882
922
  replyId?: string | undefined;
883
923
  }[] | undefined;
@@ -904,7 +944,7 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
904
944
  requestIds?: string[] | undefined;
905
945
  requestOutcomes?: {
906
946
  requestId: string;
907
- status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "replied" | "sender-closed" | "timed-out";
947
+ status: "cancelled" | "completed-without-reply" | "destroyed" | "failed" | "human-fallback" | "replied" | "sender-closed" | "timed-out";
908
948
  observedAt: string;
909
949
  replyId?: string | undefined;
910
950
  }[] | undefined;
@@ -974,6 +1014,15 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
974
1014
  text: string;
975
1015
  createdAt: string;
976
1016
  deliveredAt?: string | undefined;
1017
+ consumedAt?: string | undefined;
1018
+ awaitingRead?: true | undefined;
1019
+ inboxClaim?: {
1020
+ receiptId: string;
1021
+ generation: string;
1022
+ expiresAt: string;
1023
+ acknowledgedAt?: string | undefined;
1024
+ memberIds?: string[] | undefined;
1025
+ } | undefined;
977
1026
  }[] | undefined;
978
1027
  ciWait?: {
979
1028
  prUrl: string;
@@ -1085,6 +1134,8 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
1085
1134
  worktreeReclaimedAt?: string | undefined;
1086
1135
  groupId?: string | undefined;
1087
1136
  variant?: string | undefined;
1137
+ clientRequestId?: string | undefined;
1138
+ clientRequestHash?: string | undefined;
1088
1139
  peakRssBytes?: number | undefined;
1089
1140
  peakProcCount?: number | undefined;
1090
1141
  archived: boolean;
@@ -1220,6 +1271,9 @@ export declare class RunStore extends EventEmitter {
1220
1271
  setRepoHandle(handle: RepoHandle | null): void;
1221
1272
  listRuns(): RunRecord[];
1222
1273
  getRun(id: string): RunRecord | undefined;
1274
+ /** The run an idempotent start already created (#504), archived or not. A deleted run is gone
1275
+ * with its record, so a retry after deletion honestly creates a fresh one. */
1276
+ findRunByClientRequestId(clientRequestId: string): RunRecord | undefined;
1223
1277
  createRun(input: {
1224
1278
  title: string;
1225
1279
  systemPrompt?: string;
@@ -1237,6 +1291,8 @@ export declare class RunStore extends EventEmitter {
1237
1291
  worktree?: false;
1238
1292
  groupId?: string;
1239
1293
  variant?: string;
1294
+ clientRequestId?: string;
1295
+ clientRequestHash?: string;
1240
1296
  steps: Array<Pick<StepState, 'id' | 'name' | 'kind'>>;
1241
1297
  }): RunRecord;
1242
1298
  /** Build without publishing: owned creation must commit its receipt and run together. */
@@ -1247,7 +1303,23 @@ export declare class RunStore extends EventEmitter {
1247
1303
  input: AgentInput;
1248
1304
  }): void;
1249
1305
  /** Observable atomic input checkpoint: a failed write publishes nothing. */
1306
+ /** Accepted input the harness will never read returns to the queue (#505): only its
1307
+ * delivery and consumption receipts are cleared; order and identity are kept. */
1308
+ requeueUnconsumedAgentInputs(id: string, ids: readonly string[]): void;
1309
+ /** Model consumption observed by the current session (#505). Never un-sets deliveredAt. */
1310
+ commitAgentInputsConsumed(id: string, ids: readonly string[], at: string): void;
1311
+ /** Delivered, but the harness never confirmed reading it (#505): stop awaiting a read. */
1312
+ commitAgentInputsUnconfirmed(id: string, ids: readonly string[]): void;
1313
+ /** Crash recovery (#505): input a harness accepted but was never seen reading goes
1314
+ * back to the queue. Returns the requeued IDs. */
1315
+ requeueAwaitingReadInputs(id: string): string[];
1250
1316
  commitAgentInputs(id: string, inputs: readonly AgentInput[], openingContinuationInputId?: string): void;
1317
+ /** Reserve only unread conversation inputs in one durable index replacement. */
1318
+ claimInboxInputs(runId: string, ids: readonly string[], claim: InboxClaim): void;
1319
+ /** A receipt owns every matching input or none; exact ACK retries preserve the first timestamp. */
1320
+ ackInboxInputs(runId: string, receiptId: string, generation: string, at: string): 'acknowledged' | 'already-acknowledged';
1321
+ releaseInboxInputs(runId: string, receiptId: string, generation: string): 'released';
1322
+ clearExpiredInboxClaims(runId: string, now: string): void;
1251
1323
  /** CI intent and its wake entry share one atomic index replacement. */
1252
1324
  commitCiWait(id: string, wait: CiWait, input?: AgentInput): void;
1253
1325
  /** Retire the wait and precisely its pending wake, optionally accepting human input. */
@@ -1,9 +1,11 @@
1
1
  import { EventEmitter } from 'node:events';
2
+ import { removeArtifacts } from '../artifacts/lifecycle.js';
2
3
  import { randomUUID } from 'node:crypto';
4
+ import { isDeepStrictEqual } from 'node:util';
3
5
  import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, realpathSync, readdirSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
4
6
  import { join, resolve } from 'node:path';
5
7
  import { z } from 'zod';
6
- import { ciWaitSchema, agentInputSchema, delegationStateSchema, workerCreationReceiptSchema, workerCollectedResultSchema, workerResultFileSchema, continuationMessageSchema, runRecordSchema as contractRunRecordSchema, } from '../contract/index.js';
8
+ import { ciWaitSchema, agentInputSchema, inboxClaimSchema, delegationStateSchema, workerCreationReceiptSchema, workerCollectedResultSchema, workerResultFileSchema, continuationMessageSchema, runRecordSchema as contractRunRecordSchema, } from '../contract/index.js';
7
9
  import { storedDelegationStateSchema } from './delegation-state.js';
8
10
  import { refreshHumanAskSummary } from './human-ask-summary.js';
9
11
  import { workerExecutionIdentitySchema } from '../delegation/execution-identity.js';
@@ -262,6 +264,10 @@ export const runRecordSchema = z.object({
262
264
  groupId: z.string().optional(),
263
265
  /** Variant letter within the group — 'A' | 'B' | 'C' (kept as a string). */
264
266
  variant: z.string().optional(),
267
+ /** Idempotent start (#504): the caller's request id and the hash of the start payload it
268
+ * named (`src/runs/client-request.ts`). Absent on every run started without one. */
269
+ clientRequestId: z.string().optional(),
270
+ clientRequestHash: z.string().optional(),
265
271
  /** Peak resident memory (bytes) / process count observed across the run's
266
272
  * agent process trees (#348) — written when a session's telemetry ends.
267
273
  * Optional: old runs.json files and `ps`-less platforms have neither. */
@@ -776,6 +782,14 @@ export class RunStore extends EventEmitter {
776
782
  getRun(id) {
777
783
  return this.runs.get(id);
778
784
  }
785
+ /** The run an idempotent start already created (#504), archived or not. A deleted run is gone
786
+ * with its record, so a retry after deletion honestly creates a fresh one. */
787
+ findRunByClientRequestId(clientRequestId) {
788
+ for (const run of this.runs.values())
789
+ if (run.clientRequestId === clientRequestId)
790
+ return run;
791
+ return undefined;
792
+ }
779
793
  createRun(input) {
780
794
  const run = this.buildRun(input, randomUUID());
781
795
  this.runs.set(run.id, run);
@@ -807,6 +821,7 @@ export class RunStore extends EventEmitter {
807
821
  worktree: input.worktree,
808
822
  groupId: input.groupId,
809
823
  variant: input.variant,
824
+ ...(input.clientRequestId === undefined ? {} : { clientRequestId: input.clientRequestId, clientRequestHash: input.clientRequestHash }),
810
825
  status: 'queued',
811
826
  createdAt: new Date().toISOString(),
812
827
  tokensUsed: 0,
@@ -846,11 +861,65 @@ export class RunStore extends EventEmitter {
846
861
  this.commitIndex(proposed, changed);
847
862
  }
848
863
  /** Observable atomic input checkpoint: a failed write publishes nothing. */
864
+ /** Accepted input the harness will never read returns to the queue (#505): only its
865
+ * delivery and consumption receipts are cleared; order and identity are kept. */
866
+ requeueUnconsumedAgentInputs(id, ids) {
867
+ const run = this.runs.get(id);
868
+ if (!run?.agentInputs || !ids.length)
869
+ return;
870
+ this.commitAgentInputs(id, run.agentInputs.map(input => {
871
+ if (!ids.includes(input.id))
872
+ return input;
873
+ const { deliveredAt: _delivered, consumedAt: _consumed, awaitingRead: _awaiting, ...queued } = input;
874
+ return queued;
875
+ }));
876
+ }
877
+ /** Model consumption observed by the current session (#505). Never un-sets deliveredAt. */
878
+ commitAgentInputsConsumed(id, ids, at) {
879
+ const run = this.runs.get(id);
880
+ if (!run?.agentInputs || !ids.length)
881
+ return;
882
+ this.commitAgentInputs(id, run.agentInputs.map(input => {
883
+ if (!ids.includes(input.id) || !input.deliveredAt || input.consumedAt)
884
+ return input;
885
+ const { awaitingRead: _awaiting, ...read } = input;
886
+ return { ...read, consumedAt: at };
887
+ }));
888
+ }
889
+ /** Delivered, but the harness never confirmed reading it (#505): stop awaiting a read. */
890
+ commitAgentInputsUnconfirmed(id, ids) {
891
+ const run = this.runs.get(id);
892
+ if (!run?.agentInputs || !ids.length)
893
+ return;
894
+ this.commitAgentInputs(id, run.agentInputs.map(input => {
895
+ if (!ids.includes(input.id) || !input.awaitingRead)
896
+ return input;
897
+ const { awaitingRead: _awaiting, ...unconfirmed } = input;
898
+ return unconfirmed;
899
+ }));
900
+ }
901
+ /** Crash recovery (#505): input a harness accepted but was never seen reading goes
902
+ * back to the queue. Returns the requeued IDs. */
903
+ requeueAwaitingReadInputs(id) {
904
+ const ids = (this.runs.get(id)?.agentInputs ?? []).filter(input => input.awaitingRead && input.deliveredAt && !input.consumedAt).map(input => input.id);
905
+ this.requeueUnconsumedAgentInputs(id, ids);
906
+ return ids;
907
+ }
849
908
  commitAgentInputs(id, inputs, openingContinuationInputId) {
850
909
  const run = this.runs.get(id);
851
910
  if (!run)
852
911
  throw new Error('missing agent input target');
853
912
  const agentInputs = inputs.map(input => agentInputSchema.parse(input));
913
+ const now = new Date().toISOString();
914
+ for (const input of run.agentInputs ?? []) {
915
+ const claim = input.inboxClaim;
916
+ if (!claim || claim.acknowledgedAt || claim.expiresAt <= now)
917
+ continue;
918
+ const matching = agentInputs.filter(next => next.id === input.id);
919
+ if (matching.length !== 1 || !isDeepStrictEqual(matching[0].inboxClaim, claim)) {
920
+ throw new Error('live inbox receipt changed');
921
+ }
922
+ }
854
923
  if (openingContinuationInputId && (run.continuationMessage?.agentInputId !== openingContinuationInputId ||
855
924
  !agentInputs.some(input => input.id === openingContinuationInputId && input.deliveredAt)))
856
925
  throw new Error('opening agent input checkpoint changed');
@@ -858,6 +927,96 @@ export class RunStore extends EventEmitter {
858
927
  proposed.set(id, { ...run, agentInputs, ...(openingContinuationInputId ? { continuationMessage: undefined } : {}) });
859
928
  this.commitIndex(proposed, new Set([id]));
860
929
  }
930
+ /** Reserve only unread conversation inputs in one durable index replacement. */
931
+ claimInboxInputs(runId, ids, claim) {
932
+ const run = this.runs.get(runId);
933
+ if (!run)
934
+ throw new Error('missing inbox recipient');
935
+ const selected = z.array(z.uuid()).min(1).max(32).refine(values => new Set(values).size === values.length).parse(ids);
936
+ const receipt = inboxClaimSchema.parse({ ...claim, memberIds: selected });
937
+ if (receipt.acknowledgedAt || receipt.expiresAt <= new Date().toISOString())
938
+ throw new Error('inbox claim is not live');
939
+ const inputs = run.agentInputs ?? [];
940
+ if (inputs.some(input => input.inboxClaim?.receiptId === receipt.receiptId))
941
+ throw new Error('inbox receipt already exists');
942
+ for (const id of selected) {
943
+ const matching = inputs.filter(input => input.id === id);
944
+ if (matching.length !== 1 || matching[0]?.source !== 'agent' || !matching[0].conversation ||
945
+ matching[0].deliveredAt || (matching[0].inboxClaim && matching[0].inboxClaim.expiresAt > new Date().toISOString())) {
946
+ throw new Error('inbox input is not available');
947
+ }
948
+ }
949
+ const selectedIds = new Set(selected);
950
+ const proposed = new Map(this.runs);
951
+ proposed.set(runId, { ...run, agentInputs: inputs.map(input => selectedIds.has(input.id)
952
+ ? agentInputSchema.parse({ ...input, inboxClaim: receipt }) : input) });
953
+ this.commitIndex(proposed, new Set([runId]));
954
+ }
955
+ /** A receipt owns every matching input or none; exact ACK retries preserve the first timestamp. */
956
+ ackInboxInputs(runId, receiptId, generation, at) {
957
+ const run = this.runs.get(runId);
958
+ if (!run)
959
+ throw new Error('missing inbox recipient');
960
+ inboxClaimSchema.shape.receiptId.parse(receiptId);
961
+ inboxClaimSchema.shape.generation.parse(generation);
962
+ inboxClaimSchema.shape.expiresAt.parse(at);
963
+ const matching = (run.agentInputs ?? []).filter(input => input.inboxClaim?.receiptId === receiptId);
964
+ const receipt = matching[0]?.inboxClaim;
965
+ const memberIds = receipt?.memberIds;
966
+ if (!memberIds || matching.length !== memberIds.length ||
967
+ !memberIds.every(id => matching.some(input => input.id === id)) ||
968
+ matching.some(input => !isDeepStrictEqual(input.inboxClaim, receipt)) ||
969
+ matching.some(input => input.inboxClaim?.generation !== generation ||
970
+ input.source !== 'agent' || !input.conversation))
971
+ throw new Error('inbox receipt changed');
972
+ if (matching.every(input => input.inboxClaim?.acknowledgedAt && input.deliveredAt === input.inboxClaim.acknowledgedAt)) {
973
+ return 'already-acknowledged';
974
+ }
975
+ if (matching.some(input => input.deliveredAt || input.inboxClaim?.acknowledgedAt || input.inboxClaim.expiresAt <= at)) {
976
+ throw new Error('inbox receipt expired or displaced');
977
+ }
978
+ const proposed = new Map(this.runs);
979
+ proposed.set(runId, { ...run, agentInputs: run.agentInputs.map(input => input.inboxClaim?.receiptId === receiptId
980
+ ? agentInputSchema.parse({ ...input, deliveredAt: at, inboxClaim: { ...input.inboxClaim, acknowledgedAt: at } }) : input) });
981
+ this.commitIndex(proposed, new Set([runId]));
982
+ return 'acknowledged';
983
+ }
984
+ releaseInboxInputs(runId, receiptId, generation) {
985
+ const run = this.runs.get(runId);
986
+ if (!run)
987
+ throw new Error('missing inbox recipient');
988
+ inboxClaimSchema.shape.receiptId.parse(receiptId);
989
+ inboxClaimSchema.shape.generation.parse(generation);
990
+ const matching = (run.agentInputs ?? []).filter(input => input.inboxClaim?.receiptId === receiptId);
991
+ if (!matching.length || matching.some(input => input.inboxClaim?.generation !== generation ||
992
+ input.inboxClaim?.acknowledgedAt || input.deliveredAt))
993
+ throw new Error('inbox receipt changed');
994
+ const proposed = new Map(this.runs);
995
+ proposed.set(runId, { ...run, agentInputs: run.agentInputs.map(input => {
996
+ if (input.inboxClaim?.receiptId !== receiptId)
997
+ return input;
998
+ const { inboxClaim: _claim, ...unclaimed } = input;
999
+ return agentInputSchema.parse(unclaimed);
1000
+ }) });
1001
+ this.commitIndex(proposed, new Set([runId]));
1002
+ return 'released';
1003
+ }
1004
+ clearExpiredInboxClaims(runId, now) {
1005
+ const run = this.runs.get(runId);
1006
+ if (!run)
1007
+ throw new Error('missing inbox recipient');
1008
+ inboxClaimSchema.shape.expiresAt.parse(now);
1009
+ if (!run.agentInputs?.some(input => input.inboxClaim && !input.inboxClaim.acknowledgedAt && input.inboxClaim.expiresAt <= now))
1010
+ return;
1011
+ const proposed = new Map(this.runs);
1012
+ proposed.set(runId, { ...run, agentInputs: run.agentInputs.map(input => {
1013
+ if (!input.inboxClaim || input.inboxClaim.acknowledgedAt || input.inboxClaim.expiresAt > now)
1014
+ return input;
1015
+ const { inboxClaim: _claim, ...unclaimed } = input;
1016
+ return agentInputSchema.parse(unclaimed);
1017
+ }) });
1018
+ this.commitIndex(proposed, new Set([runId]));
1019
+ }
861
1020
  /** CI intent and its wake entry share one atomic index replacement. */
862
1021
  commitCiWait(id, wait, input) {
863
1022
  const run = this.runs.get(id);
@@ -1974,6 +2133,7 @@ export class RunStore extends EventEmitter {
1974
2133
  rmSync(this.eventsPath(id), { force: true });
1975
2134
  rmSync(this.handoffPath(id), { force: true });
1976
2135
  rmSync(this.imagesDir(id), { recursive: true, force: true });
2136
+ removeArtifacts(this.dataDir, id);
1977
2137
  }
1978
2138
  deleteRun(id) {
1979
2139
  if (!this.canDeleteRun(id))
@@ -1987,6 +2147,7 @@ export class RunStore extends EventEmitter {
1987
2147
  rmSync(this.eventsPath(id), { force: true });
1988
2148
  rmSync(this.handoffPath(id), { force: true });
1989
2149
  rmSync(this.imagesDir(id), { recursive: true, force: true });
2150
+ removeArtifacts(this.dataDir, id);
1990
2151
  }
1991
2152
  catch { /* Ordinary run deletion preserves its existing best-effort behavior. */ }
1992
2153
  this.seqs.delete(id);
@@ -2054,6 +2215,7 @@ export class RunStore extends EventEmitter {
2054
2215
  rmSync(this.eventsPath(stale.id), { force: true });
2055
2216
  rmSync(this.handoffPath(stale.id), { force: true });
2056
2217
  rmSync(this.imagesDir(stale.id), { recursive: true, force: true });
2218
+ removeArtifacts(this.dataDir, stale.id);
2057
2219
  }
2058
2220
  catch {
2059
2221
  // best effort