@wjarka/cezarion 0.17.0-pr2124.3266 → 0.17.0-pr2125.3271

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 (38) hide show
  1. package/dist/ci-wait/controller.d.ts +4 -4
  2. package/dist/delegation/routes.d.ts +4 -4
  3. package/dist/delegation/transport.d.ts +71 -71
  4. package/dist/server/live-routes.d.ts +6 -6
  5. package/dist/server/server.d.ts +6 -6
  6. package/dist/voice/routes.d.ts +19 -19
  7. package/dist/workflows/active-run.d.ts +4 -4
  8. package/dist/workflows/active-run.js +1 -1
  9. package/dist/workflows/run/inbox-claims.d.ts +38 -0
  10. package/dist/workflows/run/inbox-claims.js +107 -0
  11. package/dist/workflows/run/inbox-claims.js.map +1 -0
  12. package/dist/workflows/run/prompts.d.ts +1 -1
  13. package/dist/workflows/run/prompts.js +1 -1
  14. package/dist/workflows/run/run-skills.d.ts +79 -0
  15. package/dist/workflows/run/run-skills.js +174 -0
  16. package/dist/workflows/run/run-skills.js.map +1 -0
  17. package/dist/workflows/run.d.ts +3 -54
  18. package/dist/workflows/run.js +33 -247
  19. package/dist/workflows/run.js.map +1 -1
  20. package/package.json +3 -3
  21. package/web/dist/assets/{diff-Bu5Zcy1K2.js → diff-8pBV9JjH2.js} +2 -2
  22. package/web/dist/assets/{diff-view-Qwy6l5Ff.js → diff-view-MglB-OY3.js} +1 -1
  23. package/web/dist/assets/{git-toolbar-BNeVCcch.js → git-toolbar-B-fyCYU9.js} +1 -1
  24. package/web/dist/assets/{github-Ca9FjltU.js → github-DhHIgTnM.js} +1 -1
  25. package/web/dist/assets/{index-BWWbSsVD.js → index-C9l320b2.js} +3 -3
  26. package/web/dist/assets/{preview-pane-connected-K1fzlGyo.js → preview-pane-connected-Bn8WoRCx.js} +1 -1
  27. package/web/dist/assets/{repo-git-DqKEMfiO.js → repo-git-CqAKwCjg.js} +1 -1
  28. package/web/dist/assets/{run-header-DEQBzSue.js → run-header-DlYKZQ71.js} +1 -1
  29. package/web/dist/assets/{skills-B1vJpfwo.js → skills-BFMFN1Am.js} +1 -1
  30. package/web/dist/assets/{task-changes-BwnZWikA.js → task-changes-DeKR2gp5.js} +1 -1
  31. package/web/dist/assets/{task-commits-Co7Sp-m7.js → task-commits-CX645qDB.js} +1 -1
  32. package/web/dist/assets/{task-files-CNUcKgS-.js → task-files-CV-_fpqJ.js} +1 -1
  33. package/web/dist/assets/{task-github-item-ChOuHe1O.js → task-github-item-BuHoEPtf.js} +1 -1
  34. package/web/dist/assets/{task-thread-pIkyRPD_.js → task-thread-DUgyVVKW.js} +1 -1
  35. package/web/dist/assets/{thread-state-DU2z1ov1.js → thread-state-C4GLVC1w.js} +1 -1
  36. package/web/dist/assets/{use-hand-to-agent-state-DMwn5rSx.js → use-hand-to-agent-state-D7q0Bz0Z.js} +1 -1
  37. package/web/dist/assets/{workflows-BzsK3-Tv.js → workflows-hfnyMYGE.js} +1 -1
  38. package/web/dist/index.html +1 -1
@@ -592,10 +592,6 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
592
592
  };
593
593
  } | {
594
594
  output: {
595
- ok: false;
596
- code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
597
- message: string;
598
- } | {
599
595
  ok: true;
600
596
  task: {
601
597
  id: string;
@@ -609,6 +605,10 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
609
605
  url?: string | undefined;
610
606
  };
611
607
  note: string;
608
+ } | {
609
+ ok: false;
610
+ code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
611
+ message: string;
612
612
  };
613
613
  outputFormat: "json";
614
614
  status: import("hono/utils/http-status").ContentfulStatusCode;
@@ -221,13 +221,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
221
221
  status: 200;
222
222
  input: {
223
223
  json: {
224
- requestIds: string[];
225
- mode?: "all" | "any" | "one" | undefined;
226
- timeoutSeconds?: number | undefined;
227
- } | {
228
224
  workerIds: string[];
229
225
  timeoutSeconds?: number | undefined;
230
226
  mode?: "all" | "any" | "one" | undefined;
227
+ } | {
228
+ requestIds: string[];
229
+ mode?: "all" | "any" | "one" | undefined;
230
+ timeoutSeconds?: number | undefined;
231
231
  } | {
232
232
  peerIds: string[];
233
233
  timeoutSeconds?: number | undefined;
@@ -2,18 +2,6 @@ import type { DelegationRoutes } from './routes.ts';
2
2
  export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
3
3
  "/list": {
4
4
  $get: {
5
- output: {
6
- error: string;
7
- code?: "invalid_input" | undefined;
8
- };
9
- outputFormat: "json";
10
- status: 400;
11
- input: {
12
- query: {
13
- offset?: string | undefined;
14
- };
15
- };
16
- } | {
17
5
  output: {
18
6
  workers: {
19
7
  workerId: string;
@@ -51,12 +39,33 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
51
39
  offset?: string | undefined;
52
40
  };
53
41
  };
42
+ } | {
43
+ output: {
44
+ error: string;
45
+ code?: "invalid_input" | undefined;
46
+ };
47
+ outputFormat: "json";
48
+ status: 400;
49
+ input: {
50
+ query: {
51
+ offset?: string | undefined;
52
+ };
53
+ };
54
54
  };
55
55
  };
56
56
  } & {
57
57
  "/discover": {
58
58
  $post: {
59
59
  output: {
60
+ scope: "host-default-account";
61
+ runners: {
62
+ status: "connected" | "disconnected" | "not-installed" | "unknown";
63
+ enabled?: boolean | undefined;
64
+ hint?: string | undefined;
65
+ authFailureId?: string | undefined;
66
+ runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
67
+ }[];
68
+ } | {
60
69
  runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
61
70
  models: {
62
71
  id: string;
@@ -67,15 +76,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
67
76
  source: "cache" | "live" | "unavailable";
68
77
  stale: boolean;
69
78
  reason?: string | undefined;
70
- } | {
71
- scope: "host-default-account";
72
- runners: {
73
- status: "connected" | "disconnected" | "not-installed" | "unknown";
74
- enabled?: boolean | undefined;
75
- hint?: string | undefined;
76
- authFailureId?: string | undefined;
77
- runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
78
- }[];
79
79
  } | {
80
80
  tasks: {
81
81
  id: string;
@@ -585,18 +585,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
585
585
  } & {
586
586
  "/:workerId": {
587
587
  $get: {
588
- output: {
589
- error: string;
590
- code?: "invalid_input" | undefined;
591
- };
592
- outputFormat: "json";
593
- status: 400;
594
- input: {
595
- param: {
596
- workerId: string;
597
- };
598
- };
599
- } | {
600
588
  output: {
601
589
  workerId: string;
602
590
  parentRunId: string;
@@ -700,11 +688,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
700
688
  workerId: string;
701
689
  };
702
690
  };
703
- };
704
- };
705
- } & {
706
- "/:workerId/collect": {
707
- $post: {
691
+ } | {
708
692
  output: {
709
693
  error: string;
710
694
  code?: "invalid_input" | undefined;
@@ -715,10 +699,12 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
715
699
  param: {
716
700
  workerId: string;
717
701
  };
718
- } & {
719
- json: Record<string, never>;
720
702
  };
721
- } | {
703
+ };
704
+ };
705
+ } & {
706
+ "/:workerId/collect": {
707
+ $post: {
722
708
  output: {
723
709
  workerId: string;
724
710
  parentRunId: string;
@@ -820,11 +806,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
820
806
  } & {
821
807
  json: Record<string, never>;
822
808
  };
823
- };
824
- };
825
- } & {
826
- "/:workerId/steer": {
827
- $post: {
809
+ } | {
828
810
  output: {
829
811
  error: string;
830
812
  code?: "invalid_input" | undefined;
@@ -836,11 +818,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
836
818
  workerId: string;
837
819
  };
838
820
  } & {
839
- json: {
840
- text: string;
841
- };
821
+ json: Record<string, never>;
842
822
  };
843
- } | {
823
+ };
824
+ };
825
+ } & {
826
+ "/:workerId/steer": {
827
+ $post: {
844
828
  output: {
845
829
  workerId: string;
846
830
  state: "delivered" | "queued";
@@ -856,11 +840,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
856
840
  text: string;
857
841
  };
858
842
  };
859
- };
860
- };
861
- } & {
862
- "/:workerId/stop": {
863
- $post: {
843
+ } | {
864
844
  output: {
865
845
  error: string;
866
846
  code?: "invalid_input" | undefined;
@@ -872,9 +852,15 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
872
852
  workerId: string;
873
853
  };
874
854
  } & {
875
- json: Record<string, never>;
855
+ json: {
856
+ text: string;
857
+ };
876
858
  };
877
- } | {
859
+ };
860
+ };
861
+ } & {
862
+ "/:workerId/stop": {
863
+ $post: {
878
864
  output: {
879
865
  workerId: string;
880
866
  state: "stopping" | "terminated";
@@ -888,11 +874,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
888
874
  } & {
889
875
  json: Record<string, never>;
890
876
  };
891
- };
892
- };
893
- } & {
894
- "/:workerId/destroy": {
895
- $post: {
877
+ } | {
896
878
  output: {
897
879
  error: string;
898
880
  code?: "invalid_input" | undefined;
@@ -906,7 +888,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
906
888
  } & {
907
889
  json: Record<string, never>;
908
890
  };
909
- } | {
891
+ };
892
+ };
893
+ } & {
894
+ "/:workerId/destroy": {
895
+ $post: {
910
896
  output: {
911
897
  workerId: string;
912
898
  state: "complete" | "incomplete";
@@ -929,6 +915,20 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
929
915
  } & {
930
916
  json: Record<string, never>;
931
917
  };
918
+ } | {
919
+ output: {
920
+ error: string;
921
+ code?: "invalid_input" | undefined;
922
+ };
923
+ outputFormat: "json";
924
+ status: 400;
925
+ input: {
926
+ param: {
927
+ workerId: string;
928
+ };
929
+ } & {
930
+ json: Record<string, never>;
931
+ };
932
932
  } | {
933
933
  output: {
934
934
  workerId: string;
@@ -958,11 +958,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
958
958
  "/:workerId/diff": {
959
959
  $get: {
960
960
  output: {
961
- error: string;
962
- code?: "invalid_input" | undefined;
961
+ workerId: string;
962
+ baselineSha: string;
963
+ diff: string;
964
+ truncated: boolean;
963
965
  };
964
966
  outputFormat: "json";
965
- status: 400;
967
+ status: 200;
966
968
  input: {
967
969
  param: {
968
970
  workerId: string;
@@ -970,13 +972,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
970
972
  };
971
973
  } | {
972
974
  output: {
973
- workerId: string;
974
- baselineSha: string;
975
- diff: string;
976
- truncated: boolean;
975
+ error: string;
976
+ code?: "invalid_input" | undefined;
977
977
  };
978
978
  outputFormat: "json";
979
- status: 200;
979
+ status: 400;
980
980
  input: {
981
981
  param: {
982
982
  workerId: string;
@@ -11,6 +11,12 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
11
11
  output: {
12
12
  generation: string;
13
13
  results: ({
14
+ projectId: string;
15
+ runId: string;
16
+ type: "error" | "reset";
17
+ status: 400 | 404 | 409 | 413 | 503;
18
+ error: string;
19
+ } | {
14
20
  projectId: string;
15
21
  runId: string;
16
22
  type: "batch";
@@ -24,12 +30,6 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
24
30
  cursor: string;
25
31
  afterSeq: number;
26
32
  hasMore: boolean;
27
- } | {
28
- projectId: string;
29
- runId: string;
30
- type: "error" | "reset";
31
- status: 400 | 404 | 409 | 413 | 503;
32
- error: string;
33
33
  })[];
34
34
  };
35
35
  outputFormat: "json";
@@ -404,6 +404,12 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
404
404
  output: {
405
405
  generation: string;
406
406
  results: ({
407
+ projectId: string;
408
+ runId: string;
409
+ type: "error" | "reset";
410
+ status: 400 | 404 | 409 | 413 | 503;
411
+ error: string;
412
+ } | {
407
413
  projectId: string;
408
414
  runId: string;
409
415
  type: "batch";
@@ -417,12 +423,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
417
423
  cursor: string;
418
424
  afterSeq: number;
419
425
  hasMore: boolean;
420
- } | {
421
- projectId: string;
422
- runId: string;
423
- type: "error" | "reset";
424
- status: 400 | 404 | 409 | 413 | 503;
425
- error: string;
426
426
  })[];
427
427
  };
428
428
  outputFormat: "json";
@@ -18,25 +18,6 @@ export interface VoiceRouteDeps {
18
18
  export declare function createVoiceRoutes(deps: VoiceRouteDeps): import("hono/hono-base").HonoBase<ProjectApiEnv, {
19
19
  "/voice/decide": {
20
20
  $post: {
21
- output: {
22
- error: string;
23
- };
24
- outputFormat: "json";
25
- status: 503;
26
- input: {
27
- json: {
28
- text: string;
29
- sidebarView: "active" | "automations";
30
- openRunId?: string | undefined;
31
- view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
32
- askRequestId?: string | null | undefined;
33
- proposal?: {
34
- decisionId: string;
35
- action: "answer" | "tell";
36
- } | undefined;
37
- };
38
- };
39
- } | {
40
21
  output: {
41
22
  action: "open";
42
23
  decisionId: string;
@@ -94,6 +75,25 @@ export declare function createVoiceRoutes(deps: VoiceRouteDeps): import("hono/ho
94
75
  } | undefined;
95
76
  };
96
77
  };
78
+ } | {
79
+ output: {
80
+ error: string;
81
+ };
82
+ outputFormat: "json";
83
+ status: 503;
84
+ input: {
85
+ json: {
86
+ text: string;
87
+ sidebarView: "active" | "automations";
88
+ openRunId?: string | undefined;
89
+ view?: "automations" | "git" | "github" | "inbox" | "new-task" | "other" | "settings" | "task" | undefined;
90
+ askRequestId?: string | null | undefined;
91
+ proposal?: {
92
+ decisionId: string;
93
+ action: "answer" | "tell";
94
+ } | undefined;
95
+ };
96
+ };
97
97
  };
98
98
  };
99
99
  } & {
@@ -128,10 +128,10 @@ export interface ActiveRun {
128
128
  * blocked done at this turn end takes the second step. Every turn end sets or clears it. */
129
129
  completionNudgeAnswered?: AgentSession | undefined;
130
130
  /** Registry snapshot used to expand `/skill` follow-ups before a backend can
131
- * mistake them for its own slash commands (#676). Only `RunManager.loadRunSkills` writes it,
132
- * and only `RunManager.enabledSkills` reads it. */
131
+ * mistake them for its own slash commands (hearsay-tools/cezarion#676). Only `RunSkills.loadRunSkills` writes it,
132
+ * and only `RunSkills.enabledSkills` reads it. */
133
133
  skills?: Skill[];
134
- /** The install a live `/name` started after its message went out (#1408); tests await it. */
134
+ /** The install a live `/name` started after its message went out (hearsay-tools/cezarion#1408); tests await it. */
135
135
  liveSkillProvisioning?: Promise<void>;
136
136
  /** Release for exclusive execution in the user's repository working tree.
137
137
  * Worktree-backed runs never need it; root runs ordinarily do unless the
@@ -165,6 +165,6 @@ export interface ActiveRunInit {
165
165
  * literals; a second literal is refused by the `active-run-literal` ast-grep rule.
166
166
  *
167
167
  * The skill registry is not built here: it needs I/O after the run is registered, so
168
- * `RunManager.loadRunSkills` loads it, from the same two callers.
168
+ * `RunSkills.loadRunSkills` loads it, from the same two callers.
169
169
  */
170
170
  export declare function createActiveRun(init: ActiveRunInit): ActiveRun;
@@ -7,7 +7,7 @@
7
7
  * literals; a second literal is refused by the `active-run-literal` ast-grep rule.
8
8
  *
9
9
  * The skill registry is not built here: it needs I/O after the run is registered, so
10
- * `RunManager.loadRunSkills` loads it, from the same two callers.
10
+ * `RunSkills.loadRunSkills` loads it, from the same two callers.
11
11
  */
12
12
  export function createActiveRun(init) {
13
13
  return {
@@ -0,0 +1,38 @@
1
+ import type { AgentSession } from '../../core/agent-runner.ts';
2
+ import type { RunRecord } from '../../runs/store.ts';
3
+ import type { ActiveRun } from '../active-run.ts';
4
+ import type { RunModuleContext } from './types.ts';
5
+ interface InboxClaimsHost {
6
+ activeGet(runId: string): ActiveRun | undefined;
7
+ executionBlockedByRootFinish(run: RunRecord): boolean;
8
+ workerExecutionStopped(runId: string): boolean;
9
+ reconcileWorkerWaits(): void;
10
+ retireEmptyWake(runId: string): void;
11
+ deliverConversationInput(runId: string): void;
12
+ settleIdleBoundary(runId: string, state: ActiveRun, session: AgentSession): void;
13
+ releaseSlot(): void;
14
+ providerOwnsInboxInput(runId: string, id: string): boolean;
15
+ canClaimInboxInput(runId: string, id: string): boolean;
16
+ armInboxClaimExpiry(runId: string): void;
17
+ }
18
+ export declare class InboxClaims {
19
+ private readonly context;
20
+ private readonly host;
21
+ readonly inboxClaimTimers: Map<string, NodeJS.Timeout>;
22
+ constructor(context: RunModuleContext, host: InboxClaimsHost);
23
+ dispose(): void;
24
+ /** A wait wake is only a pointer. Only provider submission/opening prompts own delivery. */
25
+ providerOwnsInboxInput(runId: string, id: string): boolean;
26
+ canClaimInboxInput(runId: string, id: string): boolean;
27
+ /** The service supplies authorized, bounded IDs; claim and flight reservations are synchronous. */
28
+ reserveInboxInputs(runId: string, generation: string, ids: readonly string[]): {
29
+ receiptId: string;
30
+ expiresAt: string;
31
+ inputIds: string[];
32
+ } | undefined;
33
+ acknowledgeInbox(runId: string, generation: string, receiptId: string): 'acknowledged' | 'already-acknowledged';
34
+ releaseInbox(runId: string, generation: string, receiptId: string): 'released';
35
+ /** Expiry is an independent wake source, including after the provider's last turn. */
36
+ armInboxClaimExpiry(runId: string): void;
37
+ }
38
+ export {};
@@ -0,0 +1,107 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { hasLiveInboxClaim } from '../../delegation/input.js';
3
+ import { historyDeletionPending } from './run-guards.js';
4
+ export class InboxClaims {
5
+ context;
6
+ host;
7
+ inboxClaimTimers = new Map();
8
+ constructor(context, host) {
9
+ this.context = context;
10
+ this.host = host;
11
+ }
12
+ dispose() {
13
+ for (const timer of this.inboxClaimTimers.values())
14
+ clearTimeout(timer);
15
+ this.inboxClaimTimers.clear();
16
+ }
17
+ /** A wait wake is only a pointer. Only provider submission/opening prompts own delivery. */
18
+ providerOwnsInboxInput(runId, id) {
19
+ const state = this.host.activeGet(runId);
20
+ return !!state?.agentInputFlight?.inputIds.includes(id) || state?.openingAgentInputId === id ||
21
+ this.context.store.getRun(runId)?.continuationMessage?.agentInputId === id;
22
+ }
23
+ canClaimInboxInput(runId, id) {
24
+ const run = this.context.store.getRun(runId);
25
+ const input = run?.agentInputs?.find(entry => entry.id === id);
26
+ return !this.context.disposed() && !!run && ['queued', 'running', 'waiting'].includes(run.status) &&
27
+ !historyDeletionPending(this.context.store, runId) && !this.host.executionBlockedByRootFinish(run) && !this.host.workerExecutionStopped(runId) &&
28
+ !!input && input.source === 'agent' && !!input.conversation && !input.deliveredAt &&
29
+ !hasLiveInboxClaim(input) && !this.host.providerOwnsInboxInput(runId, id);
30
+ }
31
+ /** The service supplies authorized, bounded IDs; claim and flight reservations are synchronous. */
32
+ reserveInboxInputs(runId, generation, ids) {
33
+ if (!ids.length || ids.some(id => !this.host.canClaimInboxInput(runId, id)) ||
34
+ this.context.store.getRun(runId)?.agentInputs?.some(input => !input.deliveredAt && hasLiveInboxClaim(input)))
35
+ return undefined;
36
+ const claim = { receiptId: randomUUID(), generation, expiresAt: new Date(Date.now() + 120_000).toISOString() };
37
+ this.context.store.claimInboxInputs(runId, ids, claim);
38
+ this.host.armInboxClaimExpiry(runId);
39
+ return { receiptId: claim.receiptId, expiresAt: claim.expiresAt, inputIds: [...ids] };
40
+ }
41
+ acknowledgeInbox(runId, generation, receiptId) {
42
+ if (this.context.disposed() || this.context.store.getRun(runId)?.agentInputs?.some(input => input.inboxClaim?.receiptId === receiptId &&
43
+ !input.deliveredAt && this.host.providerOwnsInboxInput(runId, input.id)))
44
+ throw new Error('inbox receipt displaced');
45
+ const result = this.context.store.ackInboxInputs(runId, receiptId, generation, new Date().toISOString());
46
+ this.host.armInboxClaimExpiry(runId);
47
+ this.host.reconcileWorkerWaits();
48
+ this.host.retireEmptyWake(runId);
49
+ this.host.deliverConversationInput(runId);
50
+ // A done the turn end kept behind this claim settles now that the input is read: the inbox
51
+ // acknowledgement is the boundary's last owed input (hearsay-tools/cezarion#1620).
52
+ const state = this.host.activeGet(runId);
53
+ if (state?.session?.open)
54
+ this.host.settleIdleBoundary(runId, state, state.session);
55
+ this.host.releaseSlot();
56
+ return result;
57
+ }
58
+ releaseInbox(runId, generation, receiptId) {
59
+ if (this.context.disposed())
60
+ throw new Error('inbox manager disposed');
61
+ const result = this.context.store.releaseInboxInputs(runId, receiptId, generation);
62
+ this.host.armInboxClaimExpiry(runId);
63
+ this.host.reconcileWorkerWaits();
64
+ this.host.deliverConversationInput(runId);
65
+ this.host.releaseSlot();
66
+ return result;
67
+ }
68
+ /** Expiry is an independent wake source, including after the provider's last turn. */
69
+ armInboxClaimExpiry(runId) {
70
+ const previous = this.inboxClaimTimers.get(runId);
71
+ if (previous)
72
+ clearTimeout(previous);
73
+ this.inboxClaimTimers.delete(runId);
74
+ if (this.context.disposed())
75
+ return;
76
+ const deadlines = (this.context.store.getRun(runId)?.agentInputs ?? []).flatMap(input => input.inboxClaim && !input.inboxClaim.acknowledgedAt ? [Date.parse(input.inboxClaim.expiresAt)] : []);
77
+ if (!deadlines.length)
78
+ return;
79
+ let warned = false;
80
+ const expire = () => {
81
+ this.inboxClaimTimers.delete(runId);
82
+ if (this.context.disposed() || !this.context.store.getRun(runId))
83
+ return;
84
+ try {
85
+ this.context.store.clearExpiredInboxClaims(runId, new Date().toISOString());
86
+ this.host.reconcileWorkerWaits();
87
+ this.host.deliverConversationInput(runId);
88
+ this.host.armInboxClaimExpiry(runId);
89
+ this.host.releaseSlot();
90
+ }
91
+ catch {
92
+ if (!warned)
93
+ console.warn('[cez] inbox expiry checkpoint failed; retrying in 1 second');
94
+ warned = true;
95
+ if (!this.context.disposed())
96
+ arm(1_000);
97
+ }
98
+ };
99
+ const arm = (delay) => {
100
+ const timer = setTimeout(expire, delay);
101
+ timer.unref?.();
102
+ this.inboxClaimTimers.set(runId, timer);
103
+ };
104
+ arm(Math.max(0, Math.min(...deadlines) - Date.now()));
105
+ }
106
+ }
107
+ //# sourceMappingURL=inbox-claims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-claims.js","sourceRoot":"","sources":["../../../src/workflows/run/inbox-claims.ts"],"names":[],"mappings":"AAAA,OAA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C,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;CAEF"}
@@ -41,7 +41,7 @@ export declare function applyTemplate(template: string, task: string): string;
41
41
  * resolves against the MAIN project root (`discoverSkills(repoRoot)`), i.e. the
42
42
  * current `npx skills`-installed copy, so a worktree agent and the main
43
43
  * checkout read the exact same, up-to-date files. A team skill's `path` is not
44
- * on disk: its files are materialized per run (`RunManager.provisionRunSkills`).
44
+ * on disk: its files are materialized per run (`RunSkills.provisionRunSkills`).
45
45
  * Inside the run's task worktree they need no pointer; a run without one, or
46
46
  * whose worktree took no copy, gets a per-commit cache copy, passed here as
47
47
  * `teamFilesDir` (#1024). A worktree that took only some of its copies passes
@@ -65,7 +65,7 @@ export function applyTemplate(template, task) {
65
65
  * resolves against the MAIN project root (`discoverSkills(repoRoot)`), i.e. the
66
66
  * current `npx skills`-installed copy, so a worktree agent and the main
67
67
  * checkout read the exact same, up-to-date files. A team skill's `path` is not
68
- * on disk: its files are materialized per run (`RunManager.provisionRunSkills`).
68
+ * on disk: its files are materialized per run (`RunSkills.provisionRunSkills`).
69
69
  * Inside the run's task worktree they need no pointer; a run without one, or
70
70
  * whose worktree took no copy, gets a per-commit cache copy, passed here as
71
71
  * `teamFilesDir` (#1024). A worktree that took only some of its copies passes