@wjarka/cezarion 0.17.0-pr2123.3265 → 0.17.0-pr2124.3266
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.
- package/dist/ci-wait/controller.d.ts +26 -26
- package/dist/delegation/routes.d.ts +15 -15
- package/dist/delegation/transport.d.ts +11 -11
- package/dist/workflows/run.d.ts +4 -2
- package/dist/workflows/run.js +81 -19
- package/dist/workflows/run.js.map +1 -1
- package/package.json +3 -3
- package/dist/workflows/run/inbox-claims.d.ts +0 -38
- package/dist/workflows/run/inbox-claims.js +0 -107
- package/dist/workflows/run/inbox-claims.js.map +0 -1
|
@@ -477,11 +477,13 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
477
477
|
"/api/v1/tools/preview-stop": {
|
|
478
478
|
$post: {
|
|
479
479
|
output: {
|
|
480
|
-
|
|
480
|
+
ok: boolean;
|
|
481
|
+
code: "adopted" | "approval_required" | "headless" | "invalid_input" | "not_registered" | "port_held" | "port_in_use" | "preview_disabled" | "restarted" | "stopped" | "unavailable" | "worktree_missing";
|
|
481
482
|
message: string;
|
|
483
|
+
hint: string;
|
|
482
484
|
};
|
|
483
485
|
outputFormat: "json";
|
|
484
|
-
status:
|
|
486
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
485
487
|
input: {
|
|
486
488
|
json: {
|
|
487
489
|
port: number;
|
|
@@ -490,13 +492,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
490
492
|
};
|
|
491
493
|
} | {
|
|
492
494
|
output: {
|
|
493
|
-
|
|
494
|
-
code: "adopted" | "approval_required" | "headless" | "invalid_input" | "not_registered" | "port_held" | "port_in_use" | "preview_disabled" | "restarted" | "stopped" | "unavailable" | "worktree_missing";
|
|
495
|
+
code: 'capability_revoked';
|
|
495
496
|
message: string;
|
|
496
|
-
hint: string;
|
|
497
497
|
};
|
|
498
498
|
outputFormat: "json";
|
|
499
|
-
status:
|
|
499
|
+
status: 401;
|
|
500
500
|
input: {
|
|
501
501
|
json: {
|
|
502
502
|
port: number;
|
|
@@ -509,11 +509,13 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
509
509
|
"/api/v1/tools/preview-serve": {
|
|
510
510
|
$post: {
|
|
511
511
|
output: {
|
|
512
|
-
|
|
512
|
+
ok: boolean;
|
|
513
|
+
code: "cezar_port" | "cwd_outside_worktree" | "headless" | "invalid_input" | "port_held" | "preview_disabled" | "registered" | "replaced" | "too_many" | "unavailable" | "worktree_missing";
|
|
513
514
|
message: string;
|
|
515
|
+
hint: string;
|
|
514
516
|
};
|
|
515
517
|
outputFormat: "json";
|
|
516
|
-
status:
|
|
518
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
517
519
|
input: {
|
|
518
520
|
json: {
|
|
519
521
|
command: string;
|
|
@@ -525,13 +527,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
525
527
|
};
|
|
526
528
|
} | {
|
|
527
529
|
output: {
|
|
528
|
-
|
|
529
|
-
code: "cezar_port" | "cwd_outside_worktree" | "headless" | "invalid_input" | "port_held" | "preview_disabled" | "registered" | "replaced" | "too_many" | "unavailable" | "worktree_missing";
|
|
530
|
+
code: 'capability_revoked';
|
|
530
531
|
message: string;
|
|
531
|
-
hint: string;
|
|
532
532
|
};
|
|
533
533
|
outputFormat: "json";
|
|
534
|
-
status:
|
|
534
|
+
status: 401;
|
|
535
535
|
input: {
|
|
536
536
|
json: {
|
|
537
537
|
command: string;
|
|
@@ -547,11 +547,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
547
547
|
"/api/v1/tools/schedule-task": {
|
|
548
548
|
$post: {
|
|
549
549
|
output: {
|
|
550
|
-
|
|
550
|
+
ok: false;
|
|
551
|
+
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
551
552
|
message: string;
|
|
552
553
|
};
|
|
553
554
|
outputFormat: "json";
|
|
554
|
-
status:
|
|
555
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
555
556
|
input: {
|
|
556
557
|
json: {
|
|
557
558
|
at?: string | undefined;
|
|
@@ -569,12 +570,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
569
570
|
};
|
|
570
571
|
} | {
|
|
571
572
|
output: {
|
|
572
|
-
|
|
573
|
-
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
573
|
+
code: 'capability_revoked';
|
|
574
574
|
message: string;
|
|
575
575
|
};
|
|
576
576
|
outputFormat: "json";
|
|
577
|
-
status:
|
|
577
|
+
status: 401;
|
|
578
578
|
input: {
|
|
579
579
|
json: {
|
|
580
580
|
at?: string | undefined;
|
|
@@ -592,6 +592,10 @@ 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
|
+
} | {
|
|
595
599
|
ok: true;
|
|
596
600
|
task: {
|
|
597
601
|
id: string;
|
|
@@ -605,10 +609,6 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
605
609
|
url?: string | undefined;
|
|
606
610
|
};
|
|
607
611
|
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;
|
|
@@ -633,11 +633,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
633
633
|
"/api/v1/tools/scheduled-tasks": {
|
|
634
634
|
$post: {
|
|
635
635
|
output: {
|
|
636
|
-
|
|
636
|
+
ok: false;
|
|
637
|
+
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
637
638
|
message: string;
|
|
638
639
|
};
|
|
639
640
|
outputFormat: "json";
|
|
640
|
-
status:
|
|
641
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
641
642
|
input: {
|
|
642
643
|
json: {
|
|
643
644
|
at?: string | undefined;
|
|
@@ -671,12 +672,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
671
672
|
};
|
|
672
673
|
} | {
|
|
673
674
|
output: {
|
|
674
|
-
|
|
675
|
-
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
675
|
+
code: 'capability_revoked';
|
|
676
676
|
message: string;
|
|
677
677
|
};
|
|
678
678
|
outputFormat: "json";
|
|
679
|
-
status:
|
|
679
|
+
status: 401;
|
|
680
680
|
input: {
|
|
681
681
|
json: {
|
|
682
682
|
at?: string | undefined;
|
|
@@ -82,17 +82,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
82
82
|
"/discover": {
|
|
83
83
|
$post: {
|
|
84
84
|
output: {
|
|
85
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
86
|
-
models: {
|
|
87
|
-
id: string;
|
|
88
|
-
label: string;
|
|
89
|
-
description: string;
|
|
90
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
91
|
-
}[];
|
|
92
|
-
source: "cache" | "live" | "unavailable";
|
|
93
|
-
stale: boolean;
|
|
94
|
-
reason?: string | undefined;
|
|
95
|
-
} | {
|
|
96
85
|
scope: "host-default-account";
|
|
97
86
|
runners: {
|
|
98
87
|
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
@@ -113,6 +102,17 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
113
102
|
reason?: string | undefined;
|
|
114
103
|
}[];
|
|
115
104
|
nextOffset?: number | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
107
|
+
models: {
|
|
108
|
+
id: string;
|
|
109
|
+
label: string;
|
|
110
|
+
description: string;
|
|
111
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
112
|
+
}[];
|
|
113
|
+
source: "cache" | "live" | "unavailable";
|
|
114
|
+
stale: boolean;
|
|
115
|
+
reason?: string | undefined;
|
|
116
116
|
};
|
|
117
117
|
outputFormat: "json";
|
|
118
118
|
status: 200;
|
|
@@ -221,13 +221,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
221
221
|
status: 200;
|
|
222
222
|
input: {
|
|
223
223
|
json: {
|
|
224
|
-
workerIds: string[];
|
|
225
|
-
timeoutSeconds?: number | undefined;
|
|
226
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
227
|
-
} | {
|
|
228
224
|
requestIds: string[];
|
|
229
225
|
mode?: "all" | "any" | "one" | undefined;
|
|
230
226
|
timeoutSeconds?: number | undefined;
|
|
227
|
+
} | {
|
|
228
|
+
workerIds: string[];
|
|
229
|
+
timeoutSeconds?: number | undefined;
|
|
230
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
231
231
|
} | {
|
|
232
232
|
peerIds: string[];
|
|
233
233
|
timeoutSeconds?: number | undefined;
|
|
@@ -57,6 +57,17 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
57
57
|
"/discover": {
|
|
58
58
|
$post: {
|
|
59
59
|
output: {
|
|
60
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
61
|
+
models: {
|
|
62
|
+
id: string;
|
|
63
|
+
label: string;
|
|
64
|
+
description: string;
|
|
65
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
66
|
+
}[];
|
|
67
|
+
source: "cache" | "live" | "unavailable";
|
|
68
|
+
stale: boolean;
|
|
69
|
+
reason?: string | undefined;
|
|
70
|
+
} | {
|
|
60
71
|
scope: "host-default-account";
|
|
61
72
|
runners: {
|
|
62
73
|
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
@@ -77,17 +88,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
77
88
|
reason?: string | undefined;
|
|
78
89
|
}[];
|
|
79
90
|
nextOffset?: number | undefined;
|
|
80
|
-
} | {
|
|
81
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
82
|
-
models: {
|
|
83
|
-
id: string;
|
|
84
|
-
label: string;
|
|
85
|
-
description: string;
|
|
86
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
87
|
-
}[];
|
|
88
|
-
source: "cache" | "live" | "unavailable";
|
|
89
|
-
stale: boolean;
|
|
90
|
-
reason?: string | undefined;
|
|
91
91
|
};
|
|
92
92
|
outputFormat: "json";
|
|
93
93
|
status: 200;
|
package/dist/workflows/run.d.ts
CHANGED
|
@@ -204,8 +204,7 @@ export declare class RunManager {
|
|
|
204
204
|
/** Each family's conversation request deadlines. Every worker wait, Cezar's completion wait
|
|
205
205
|
* included, parks, wakes and times out through the wait list (hearsay-tools/cezarion#1301). */
|
|
206
206
|
private readonly requestDeadlineTimers;
|
|
207
|
-
private readonly
|
|
208
|
-
private get inboxClaimTimers();
|
|
207
|
+
private readonly inboxClaimTimers;
|
|
209
208
|
private reconcilingWorkers;
|
|
210
209
|
private reconcilingFamily;
|
|
211
210
|
private readonly pendingReconciliations;
|
|
@@ -995,8 +994,10 @@ export declare class RunManager {
|
|
|
995
994
|
/** Like a timer, the wake is the agent's own arrangement: a stopping or finishing run takes none,
|
|
996
995
|
* and the wait stays for that transition to cancel. True when the wait is no longer open. */
|
|
997
996
|
private resolvePeerWait;
|
|
997
|
+
/** A wait wake is only a pointer. Only provider submission/opening prompts own delivery. */
|
|
998
998
|
private providerOwnsInboxInput;
|
|
999
999
|
canClaimInboxInput(runId: string, id: string): boolean;
|
|
1000
|
+
/** The service supplies authorized, bounded IDs; claim and flight reservations are synchronous. */
|
|
1000
1001
|
reserveInboxInputs(runId: string, generation: string, ids: readonly string[]): {
|
|
1001
1002
|
receiptId: string;
|
|
1002
1003
|
expiresAt: string;
|
|
@@ -1004,6 +1005,7 @@ export declare class RunManager {
|
|
|
1004
1005
|
} | undefined;
|
|
1005
1006
|
acknowledgeInbox(runId: string, generation: string, receiptId: string): 'acknowledged' | 'already-acknowledged';
|
|
1006
1007
|
releaseInbox(runId: string, generation: string, receiptId: string): 'released';
|
|
1008
|
+
/** Expiry is an independent wake source, including after the provider's last turn. */
|
|
1007
1009
|
private armInboxClaimExpiry;
|
|
1008
1010
|
/** Accepted conversation input uses the existing scheduler admission for idle recipients. */
|
|
1009
1011
|
deliverConversationInput(runId: string): void;
|
package/dist/workflows/run.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { InboxClaims } from './run/inbox-claims.js';
|
|
2
1
|
import { WorkerExecutions } from './run/worker-executions.js';
|
|
3
2
|
import { TurnBookkeeper } from './run/turn-bookkeeping.js';
|
|
4
3
|
import { AutomationToolsSlot, cezarToolHandlers, toolSessionRefusal } from './run/cezar-tools.js';
|
|
@@ -363,8 +362,7 @@ export class RunManager {
|
|
|
363
362
|
/** Each family's conversation request deadlines. Every worker wait, Cezar's completion wait
|
|
364
363
|
* included, parks, wakes and times out through the wait list (hearsay-tools/cezarion#1301). */
|
|
365
364
|
requestDeadlineTimers = new Map();
|
|
366
|
-
|
|
367
|
-
get inboxClaimTimers() { return this.inboxClaims.inboxClaimTimers; }
|
|
365
|
+
inboxClaimTimers = new Map();
|
|
368
366
|
reconcilingWorkers = false;
|
|
369
367
|
reconcilingFamily;
|
|
370
368
|
pendingReconciliations = new Set();
|
|
@@ -512,15 +510,6 @@ export class RunManager {
|
|
|
512
510
|
persistPastedAttachments: (id, content) => this.persistPastedAttachments(id, content),
|
|
513
511
|
toQueuedMessage: (id, content) => this.toQueuedMessage(id, content),
|
|
514
512
|
sendMessage: (id, content, messageId) => this.sendMessage(id, content, messageId) });
|
|
515
|
-
this.inboxClaims = new InboxClaims({ store, repoRoot, dataDir: this.dataDir, semaphore: this.semaphore, disposed: () => this.disposed }, { activeGet: id => this.active.get(id),
|
|
516
|
-
executionBlockedByRootFinish: run => this.executionBlockedByRootFinish(run),
|
|
517
|
-
workerExecutionStopped: id => this.workerExecutionStopped(id),
|
|
518
|
-
reconcileWorkerWaits: () => this.reconcileWorkerWaits(), retireEmptyWake: id => this.retireEmptyWake(id),
|
|
519
|
-
deliverConversationInput: id => this.deliverConversationInput(id),
|
|
520
|
-
settleIdleBoundary: (id, state, session) => this.settleIdleBoundary(id, state, session),
|
|
521
|
-
releaseSlot: () => this.releaseSlot(), providerOwnsInboxInput: (id, inputId) => this.providerOwnsInboxInput(id, inputId),
|
|
522
|
-
canClaimInboxInput: (id, inputId) => this.canClaimInboxInput(id, inputId),
|
|
523
|
-
armInboxClaimExpiry: id => this.armInboxClaimExpiry(id) });
|
|
524
513
|
this.repoRootLease = new RepoRootLease({ store, repoRoot, dataDir: this.dataDir, semaphore: this.semaphore, disposed: () => this.disposed }, { park: id => { this.waiting.add(id); }, unpark: id => { this.waiting.delete(id); },
|
|
525
514
|
releaseSlot: () => this.releaseSlot() });
|
|
526
515
|
this.turnBookkeeper = new TurnBookkeeper({ store, repoRoot, dataDir: this.dataDir, semaphore: this.semaphore, disposed: () => this.disposed }, { isDisposedDelegatedRun: id => this.isDisposedDelegatedRun(id), discoverSkills: () => this.discoverSkills(),
|
|
@@ -584,7 +573,9 @@ export class RunManager {
|
|
|
584
573
|
for (const timer of this.requestDeadlineTimers.values())
|
|
585
574
|
clearTimeout(timer);
|
|
586
575
|
this.requestDeadlineTimers.clear();
|
|
587
|
-
this.
|
|
576
|
+
for (const timer of this.inboxClaimTimers.values())
|
|
577
|
+
clearTimeout(timer);
|
|
578
|
+
this.inboxClaimTimers.clear();
|
|
588
579
|
this.offUsage();
|
|
589
580
|
this.offSemaphore();
|
|
590
581
|
clearInterval(this.queueWatchdog);
|
|
@@ -3688,23 +3679,94 @@ export class RunManager {
|
|
|
3688
3679
|
this.settleWait(runId, wait.id, result);
|
|
3689
3680
|
return !!result && this.store.getRun(runId)?.waits?.find(entry => entry.id === wait.id)?.phase !== 'open';
|
|
3690
3681
|
}
|
|
3682
|
+
/** A wait wake is only a pointer. Only provider submission/opening prompts own delivery. */
|
|
3691
3683
|
providerOwnsInboxInput(runId, id) {
|
|
3692
|
-
|
|
3684
|
+
const state = this.active.get(runId);
|
|
3685
|
+
return !!state?.agentInputFlight?.inputIds.includes(id) || state?.openingAgentInputId === id ||
|
|
3686
|
+
this.store.getRun(runId)?.continuationMessage?.agentInputId === id;
|
|
3693
3687
|
}
|
|
3694
3688
|
canClaimInboxInput(runId, id) {
|
|
3695
|
-
|
|
3689
|
+
const run = this.store.getRun(runId);
|
|
3690
|
+
const input = run?.agentInputs?.find(entry => entry.id === id);
|
|
3691
|
+
return !this.disposed && !!run && ['queued', 'running', 'waiting'].includes(run.status) &&
|
|
3692
|
+
!this.historyDeletionPending(runId) && !this.executionBlockedByRootFinish(run) && !this.workerExecutionStopped(runId) &&
|
|
3693
|
+
!!input && input.source === 'agent' && !!input.conversation && !input.deliveredAt &&
|
|
3694
|
+
!hasLiveInboxClaim(input) && !this.providerOwnsInboxInput(runId, id);
|
|
3696
3695
|
}
|
|
3696
|
+
/** The service supplies authorized, bounded IDs; claim and flight reservations are synchronous. */
|
|
3697
3697
|
reserveInboxInputs(runId, generation, ids) {
|
|
3698
|
-
|
|
3698
|
+
if (!ids.length || ids.some(id => !this.canClaimInboxInput(runId, id)) ||
|
|
3699
|
+
this.store.getRun(runId)?.agentInputs?.some(input => !input.deliveredAt && hasLiveInboxClaim(input)))
|
|
3700
|
+
return undefined;
|
|
3701
|
+
const claim = { receiptId: randomUUID(), generation, expiresAt: new Date(Date.now() + 120_000).toISOString() };
|
|
3702
|
+
this.store.claimInboxInputs(runId, ids, claim);
|
|
3703
|
+
this.armInboxClaimExpiry(runId);
|
|
3704
|
+
return { receiptId: claim.receiptId, expiresAt: claim.expiresAt, inputIds: [...ids] };
|
|
3699
3705
|
}
|
|
3700
3706
|
acknowledgeInbox(runId, generation, receiptId) {
|
|
3701
|
-
|
|
3707
|
+
if (this.disposed || this.store.getRun(runId)?.agentInputs?.some(input => input.inboxClaim?.receiptId === receiptId &&
|
|
3708
|
+
!input.deliveredAt && this.providerOwnsInboxInput(runId, input.id)))
|
|
3709
|
+
throw new Error('inbox receipt displaced');
|
|
3710
|
+
const result = this.store.ackInboxInputs(runId, receiptId, generation, new Date().toISOString());
|
|
3711
|
+
this.armInboxClaimExpiry(runId);
|
|
3712
|
+
this.reconcileWorkerWaits();
|
|
3713
|
+
this.retireEmptyWake(runId);
|
|
3714
|
+
this.deliverConversationInput(runId);
|
|
3715
|
+
// A done the turn end kept behind this claim settles now that the input is read: the inbox
|
|
3716
|
+
// acknowledgement is the boundary's last owed input (hearsay-tools/cezarion#1620).
|
|
3717
|
+
const state = this.active.get(runId);
|
|
3718
|
+
if (state?.session?.open)
|
|
3719
|
+
this.settleIdleBoundary(runId, state, state.session);
|
|
3720
|
+
this.releaseSlot();
|
|
3721
|
+
return result;
|
|
3702
3722
|
}
|
|
3703
3723
|
releaseInbox(runId, generation, receiptId) {
|
|
3704
|
-
|
|
3724
|
+
if (this.disposed)
|
|
3725
|
+
throw new Error('inbox manager disposed');
|
|
3726
|
+
const result = this.store.releaseInboxInputs(runId, receiptId, generation);
|
|
3727
|
+
this.armInboxClaimExpiry(runId);
|
|
3728
|
+
this.reconcileWorkerWaits();
|
|
3729
|
+
this.deliverConversationInput(runId);
|
|
3730
|
+
this.releaseSlot();
|
|
3731
|
+
return result;
|
|
3705
3732
|
}
|
|
3733
|
+
/** Expiry is an independent wake source, including after the provider's last turn. */
|
|
3706
3734
|
armInboxClaimExpiry(runId) {
|
|
3707
|
-
this.
|
|
3735
|
+
const previous = this.inboxClaimTimers.get(runId);
|
|
3736
|
+
if (previous)
|
|
3737
|
+
clearTimeout(previous);
|
|
3738
|
+
this.inboxClaimTimers.delete(runId);
|
|
3739
|
+
if (this.disposed)
|
|
3740
|
+
return;
|
|
3741
|
+
const deadlines = (this.store.getRun(runId)?.agentInputs ?? []).flatMap(input => input.inboxClaim && !input.inboxClaim.acknowledgedAt ? [Date.parse(input.inboxClaim.expiresAt)] : []);
|
|
3742
|
+
if (!deadlines.length)
|
|
3743
|
+
return;
|
|
3744
|
+
let warned = false;
|
|
3745
|
+
const expire = () => {
|
|
3746
|
+
this.inboxClaimTimers.delete(runId);
|
|
3747
|
+
if (this.disposed || !this.store.getRun(runId))
|
|
3748
|
+
return;
|
|
3749
|
+
try {
|
|
3750
|
+
this.store.clearExpiredInboxClaims(runId, new Date().toISOString());
|
|
3751
|
+
this.reconcileWorkerWaits();
|
|
3752
|
+
this.deliverConversationInput(runId);
|
|
3753
|
+
this.armInboxClaimExpiry(runId);
|
|
3754
|
+
this.releaseSlot();
|
|
3755
|
+
}
|
|
3756
|
+
catch {
|
|
3757
|
+
if (!warned)
|
|
3758
|
+
console.warn('[cez] inbox expiry checkpoint failed; retrying in 1 second');
|
|
3759
|
+
warned = true;
|
|
3760
|
+
if (!this.disposed)
|
|
3761
|
+
arm(1_000);
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
const arm = (delay) => {
|
|
3765
|
+
const timer = setTimeout(expire, delay);
|
|
3766
|
+
timer.unref?.();
|
|
3767
|
+
this.inboxClaimTimers.set(runId, timer);
|
|
3768
|
+
};
|
|
3769
|
+
arm(Math.max(0, Math.min(...deadlines) - Date.now()));
|
|
3708
3770
|
}
|
|
3709
3771
|
/** Accepted conversation input uses the existing scheduler admission for idle recipients. */
|
|
3710
3772
|
deliverConversationInput(runId) {
|