@wjarka/cezarion 0.14.8-pr540.823 → 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.
- package/README.md +56 -3
- package/dist/automations/scheduler.d.ts +6 -0
- package/dist/automations/scheduler.js +45 -17
- package/dist/automations/scheduler.js.map +1 -1
- package/dist/automations/store.d.ts +12 -4
- package/dist/automations/store.js +199 -22
- package/dist/automations/store.js.map +1 -1
- package/dist/automations/types.d.ts +2 -0
- package/dist/automations/types.js +1 -0
- package/dist/automations/types.js.map +1 -1
- package/dist/contract/automations.d.ts +6 -0
- package/dist/contract/delegation.d.ts +29 -0
- package/dist/contract/discovery.d.ts +134 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +1520 -1447
- package/dist/contract/projects.d.ts +40 -0
- package/dist/contract/runs.d.ts +43 -0
- package/dist/contract/skills.d.ts +5 -0
- package/dist/core/claude-cli-runner.js +1 -1
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/cursor-acp-runner.d.ts +2 -0
- package/dist/core/cursor-acp-runner.js +159 -26
- package/dist/core/cursor-acp-runner.js.map +1 -1
- package/dist/core/cursor-provider-error.d.ts +3 -0
- package/dist/core/cursor-provider-error.js +14 -1
- package/dist/core/cursor-provider-error.js.map +1 -1
- package/dist/core/opencode-server-runner.js +12 -5
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-runner.js +17 -4
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/core/provider-auth.d.ts +99 -1
- package/dist/core/provider-auth.js +203 -2
- package/dist/core/provider-auth.js.map +1 -1
- package/dist/delegation/cli.d.ts +1 -0
- package/dist/delegation/cli.js +1 -1
- package/dist/delegation/cli.js.map +1 -1
- package/dist/delegation/policy.d.ts +3 -2
- package/dist/delegation/policy.js +3 -1
- package/dist/delegation/policy.js.map +1 -1
- package/dist/delegation/process-liveness.d.ts +66 -0
- package/dist/delegation/process-liveness.js +215 -0
- package/dist/delegation/process-liveness.js.map +1 -0
- package/dist/delegation/provision.d.ts +1 -1
- package/dist/delegation/provision.js +5 -2
- package/dist/delegation/provision.js.map +1 -1
- package/dist/delegation/results.js +10 -6
- package/dist/delegation/results.js.map +1 -1
- package/dist/delegation/routes.d.ts +101 -54
- package/dist/delegation/routes.js +3 -2
- package/dist/delegation/routes.js.map +1 -1
- package/dist/delegation/service.d.ts +8 -1
- package/dist/delegation/service.js +56 -7
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +40 -4
- package/dist/discovery/catalog.d.ts +14 -0
- package/dist/discovery/catalog.js +31 -0
- package/dist/discovery/catalog.js.map +1 -0
- package/dist/discovery/cli.d.ts +8 -0
- package/dist/discovery/cli.js +104 -0
- package/dist/discovery/cli.js.map +1 -0
- package/dist/git-worktree.d.ts +3 -1
- package/dist/git-worktree.js +26 -4
- package/dist/git-worktree.js.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/runs/agent-tmpdir.d.ts +2 -0
- package/dist/runs/agent-tmpdir.js +5 -2
- package/dist/runs/agent-tmpdir.js.map +1 -1
- package/dist/runs/retention.d.ts +7 -2
- package/dist/runs/retention.js +39 -7
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/store.d.ts +22 -0
- package/dist/runs/store.js +82 -1
- package/dist/runs/store.js.map +1 -1
- package/dist/runs/webhook.d.ts +125 -0
- package/dist/runs/webhook.js +256 -0
- package/dist/runs/webhook.js.map +1 -0
- package/dist/server/provider-auth-runtime.d.ts +30 -4
- package/dist/server/provider-auth-runtime.js +71 -6
- package/dist/server/provider-auth-runtime.js.map +1 -1
- package/dist/server/server.d.ts +3673 -2420
- package/dist/server/server.js +139 -11
- package/dist/server/server.js.map +1 -1
- package/dist/server-install/platforms/ubuntu-vps.d.ts +5 -1
- package/dist/server-install/platforms/ubuntu-vps.js +160 -18
- package/dist/server-install/platforms/ubuntu-vps.js.map +1 -1
- package/dist/server-install/steps.d.ts +4 -2
- package/dist/server-install/steps.js +5 -4
- package/dist/server-install/steps.js.map +1 -1
- package/dist/skills-remote.d.ts +30 -5
- package/dist/skills-remote.js +122 -32
- package/dist/skills-remote.js.map +1 -1
- package/dist/skills.js +15 -6
- package/dist/skills.js.map +1 -1
- package/dist/task-cli/cli.js +124 -7
- package/dist/task-cli/cli.js.map +1 -1
- package/dist/task-cli/discovery.js +6 -5
- package/dist/task-cli/discovery.js.map +1 -1
- package/dist/task-cli/http.d.ts +3 -0
- package/dist/task-cli/http.js.map +1 -1
- package/dist/task-cli/watch.d.ts +19 -0
- package/dist/task-cli/watch.js +35 -2
- package/dist/task-cli/watch.js.map +1 -1
- package/dist/workflows/run.d.ts +67 -2
- package/dist/workflows/run.js +325 -27
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/agent-profiles.d.ts +22 -0
- package/dist/workspace/agent-profiles.js +15 -0
- package/dist/workspace/agent-profiles.js.map +1 -1
- package/dist/workspace/config.d.ts +9 -0
- package/dist/workspace/config.js +13 -1
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/projects.d.ts +24 -1
- package/dist/workspace/projects.js +14 -1
- package/dist/workspace/projects.js.map +1 -1
- package/package.json +5 -5
- package/scripts/mock-claude.mjs +26 -0
- package/scripts/mock-codex-app-server.mjs +26 -0
- package/scripts/mock-cursor-acp.mjs +51 -3
- package/scripts/mock-cursor-hang-stdin-late.mjs +35 -0
- package/scripts/mock-cursor-hang-stdin.mjs +30 -0
- package/scripts/mock-opencode-serve.mjs +33 -0
- package/scripts/mock-pi-rpc.mjs +22 -4
- package/web/dist/assets/agent-accounts-CerclGiO.js +1 -0
- package/web/dist/assets/centered-state-DH8qtCz-.js +43 -0
- package/web/dist/assets/{collapsible-Bb2y0asn.js → collapsible-De2G0xqQ.js} +1 -1
- package/web/dist/assets/{commit-list-DpxX-bA4.js → commit-list-CQubP1iS.js} +1 -1
- package/web/dist/assets/compare-variants-C_NijJvg.js +1 -0
- package/web/dist/assets/{diff-rDeblLVZ2.js → diff-8M5HlDxq2.js} +2 -2
- package/web/dist/assets/{diff-controls-frbAqBK1.js → diff-controls-B6ok0TtQ.js} +1 -1
- package/web/dist/assets/{diff-stat-Cn7rzy1H.js → diff-stat-D1AODN2a.js} +1 -1
- package/web/dist/assets/{diff-view-D6N_QzSq.js → diff-view-Bs5Gh7UF.js} +2 -2
- package/web/dist/assets/{dropdown-menu-Bwvi4Ono.js → dropdown-menu-7KGQMoFj.js} +1 -1
- package/web/dist/assets/{git-toolbar-5TyOh819.js → git-toolbar-DqbapMXr.js} +1 -1
- package/web/dist/assets/github-lMHiuYSx.js +1 -0
- package/web/dist/assets/{image-preview-B618kDBH.js → image-preview-jzHoEyLM.js} +1 -1
- package/web/dist/assets/index-D4OJTArJ.js +7 -0
- package/web/dist/assets/index-D5NkwqY7.css +1 -0
- package/web/dist/assets/{markdown-BnjmXdz2.js → markdown-DvbymqXz.js} +1 -1
- package/web/dist/assets/pill-BL6ugwXo.js +1 -0
- package/web/dist/assets/{project-router-BSpCQc8A.js → project-router-ChC5Rb-Y.js} +1 -1
- package/web/dist/assets/{prompt-templates-BsHnTixc.js → prompt-templates-j8qlK7c-.js} +3 -3
- package/web/dist/assets/repo-git-BbPAgkqb.js +1 -0
- package/web/dist/assets/{run-diff-CFeYdPGE.js → run-diff-BuATgZpx.js} +2 -2
- package/web/dist/assets/run-header-DuAWswYM.js +1 -0
- package/web/dist/assets/skills-DiC2XrU1.js +1 -0
- package/web/dist/assets/{tab-link-BXDesc8g.js → tab-link-BmGKj9Rt.js} +1 -1
- package/web/dist/assets/{task-changes-DfF08cUG.js → task-changes-CP9kPnsy.js} +1 -1
- package/web/dist/assets/{task-commits-BMmpYP5e.js → task-commits-D6NfTw5r.js} +1 -1
- package/web/dist/assets/{task-files-D_dKDdRK.js → task-files-W-b_gtcb.js} +2 -2
- package/web/dist/assets/task-thread-Bw_nQuTx.css +1 -0
- package/web/dist/assets/task-thread-Q7Nj33DH.js +9 -0
- package/web/dist/assets/{textarea-COQtp9cB.js → textarea-ByZ-txS7.js} +1 -1
- package/web/dist/assets/thread-loading-DHT9p5o5.js +1 -0
- package/web/dist/assets/{token-metrics-CFWQYcgY.js → token-metrics-k4XoovDS.js} +1 -1
- package/web/dist/assets/{utils-DKheTxGD.js → utils-BTFBhZ55.js} +1 -1
- package/web/dist/assets/workflows-DqQszPHJ.js +11 -0
- package/web/dist/assets/{zoomable-image-YW3Qdrr_.js → zoomable-image-Ba6y6Wyl.js} +1 -1
- package/web/dist/index.html +14 -14
- package/web/dist/assets/agent-accounts-B7aDlJ4I.js +0 -1
- package/web/dist/assets/centered-state-wm14n-hB.js +0 -43
- package/web/dist/assets/compare-variants-DbPcvMtU.js +0 -1
- package/web/dist/assets/github-Dyo38xkh.js +0 -1
- package/web/dist/assets/ibm-plex-mono-regular-BF3vfe7_.ttf +0 -0
- package/web/dist/assets/index-dgQfUHKO.css +0 -1
- package/web/dist/assets/index-yCn9jZqm.js +0 -7
- package/web/dist/assets/pill-DqEXer06.js +0 -1
- package/web/dist/assets/repo-git-Cw1UOtWI.js +0 -1
- package/web/dist/assets/run-header-G5PQQyme.js +0 -1
- package/web/dist/assets/skills-DMvpMI_E.js +0 -1
- package/web/dist/assets/task-thread-BL7keYuU.js +0 -9
- package/web/dist/assets/task-thread-BQFdz1dJ.css +0 -1
- package/web/dist/assets/thread-loading-B7mgkPaL.js +0 -1
- package/web/dist/assets/workflows-DLCH6MDH.js +0 -11
|
@@ -9,11 +9,58 @@ export declare function delegationFailure(error: unknown): {
|
|
|
9
9
|
readonly body: {
|
|
10
10
|
readonly code: "capacity_limit" | "denied_scope" | "incompatible_state" | "incomplete_cleanup" | "invalid_baseline" | "invalid_input" | "unauthenticated" | "unavailable_diff" | "unavailable_transport";
|
|
11
11
|
readonly error: string;
|
|
12
|
+
readonly modelChoices?: {
|
|
13
|
+
runner: "claude" | "codex" | "cursor" | "opencode" | "pi";
|
|
14
|
+
requestedModel: string;
|
|
15
|
+
availableModels: {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
description: string;
|
|
19
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
otherRunners: ("claude" | "codex" | "cursor" | "opencode" | "pi")[];
|
|
22
|
+
} | undefined;
|
|
12
23
|
};
|
|
13
24
|
readonly status: 400 | 401 | 403 | 409 | 503;
|
|
14
25
|
};
|
|
15
26
|
/** Only this family runs on the private listener. It never inherits hosted cockpit exposure. */
|
|
16
27
|
export declare function createDelegationRoutes(service: DelegationService, credentials: CredentialRegistry): import("hono/hono-base").HonoBase<Env, {
|
|
28
|
+
"/discover": {
|
|
29
|
+
$post: {
|
|
30
|
+
output: {
|
|
31
|
+
scope: "host-default-account";
|
|
32
|
+
runners: {
|
|
33
|
+
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
34
|
+
enabled?: boolean | undefined;
|
|
35
|
+
hint?: string | undefined;
|
|
36
|
+
authFailureId?: string | undefined;
|
|
37
|
+
runner: "claude" | "codex" | "cursor" | "opencode" | "pi";
|
|
38
|
+
}[];
|
|
39
|
+
} | {
|
|
40
|
+
runner: "claude" | "codex" | "cursor" | "opencode" | "pi";
|
|
41
|
+
models: {
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
description: string;
|
|
45
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
46
|
+
}[];
|
|
47
|
+
source: "cache" | "live" | "unavailable";
|
|
48
|
+
stale: boolean;
|
|
49
|
+
reason?: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
outputFormat: "json";
|
|
52
|
+
status: 200;
|
|
53
|
+
input: {
|
|
54
|
+
json: {
|
|
55
|
+
kind: "runners";
|
|
56
|
+
} | {
|
|
57
|
+
kind: "models";
|
|
58
|
+
runner: "claude" | "codex" | "cursor" | "opencode" | "pi";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
} & {
|
|
17
64
|
"/spawn": {
|
|
18
65
|
$post: {
|
|
19
66
|
output: {
|
|
@@ -82,13 +129,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
82
129
|
status: 200;
|
|
83
130
|
input: {
|
|
84
131
|
json: {
|
|
85
|
-
requestIds: string[];
|
|
86
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
87
|
-
timeoutSeconds?: number | undefined;
|
|
88
|
-
} | {
|
|
89
132
|
workerIds: string[];
|
|
90
133
|
timeoutSeconds?: number | undefined;
|
|
91
134
|
mode?: "all" | "any" | "one" | undefined;
|
|
135
|
+
} | {
|
|
136
|
+
requestIds: string[];
|
|
137
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
138
|
+
timeoutSeconds?: number | undefined;
|
|
92
139
|
};
|
|
93
140
|
};
|
|
94
141
|
};
|
|
@@ -439,6 +486,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
439
486
|
} & {
|
|
440
487
|
"/:workerId": {
|
|
441
488
|
$get: {
|
|
489
|
+
output: {
|
|
490
|
+
error: string;
|
|
491
|
+
code?: "invalid_input" | undefined;
|
|
492
|
+
};
|
|
493
|
+
outputFormat: "json";
|
|
494
|
+
status: 400;
|
|
495
|
+
input: {
|
|
496
|
+
param: {
|
|
497
|
+
workerId: string;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
} | {
|
|
442
501
|
output: {
|
|
443
502
|
workerId: string;
|
|
444
503
|
parentRunId: string;
|
|
@@ -515,7 +574,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
515
574
|
workerId: string;
|
|
516
575
|
};
|
|
517
576
|
};
|
|
518
|
-
}
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
} & {
|
|
580
|
+
"/:workerId/collect": {
|
|
581
|
+
$post: {
|
|
519
582
|
output: {
|
|
520
583
|
error: string;
|
|
521
584
|
code?: "invalid_input" | undefined;
|
|
@@ -526,12 +589,10 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
526
589
|
param: {
|
|
527
590
|
workerId: string;
|
|
528
591
|
};
|
|
592
|
+
} & {
|
|
593
|
+
json: Record<string, never>;
|
|
529
594
|
};
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
} & {
|
|
533
|
-
"/:workerId/collect": {
|
|
534
|
-
$post: {
|
|
595
|
+
} | {
|
|
535
596
|
output: {
|
|
536
597
|
workerId: string;
|
|
537
598
|
parentRunId: string;
|
|
@@ -633,7 +694,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
633
694
|
} & {
|
|
634
695
|
json: Record<string, never>;
|
|
635
696
|
};
|
|
636
|
-
}
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
} & {
|
|
700
|
+
"/:workerId/steer": {
|
|
701
|
+
$post: {
|
|
637
702
|
output: {
|
|
638
703
|
error: string;
|
|
639
704
|
code?: "invalid_input" | undefined;
|
|
@@ -645,13 +710,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
645
710
|
workerId: string;
|
|
646
711
|
};
|
|
647
712
|
} & {
|
|
648
|
-
json:
|
|
713
|
+
json: {
|
|
714
|
+
text: string;
|
|
715
|
+
};
|
|
649
716
|
};
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
} & {
|
|
653
|
-
"/:workerId/steer": {
|
|
654
|
-
$post: {
|
|
717
|
+
} | {
|
|
655
718
|
output: {
|
|
656
719
|
workerId: string;
|
|
657
720
|
state: "delivered" | "queued";
|
|
@@ -667,7 +730,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
667
730
|
text: string;
|
|
668
731
|
};
|
|
669
732
|
};
|
|
670
|
-
}
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
} & {
|
|
736
|
+
"/:workerId/stop": {
|
|
737
|
+
$post: {
|
|
671
738
|
output: {
|
|
672
739
|
error: string;
|
|
673
740
|
code?: "invalid_input" | undefined;
|
|
@@ -679,15 +746,9 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
679
746
|
workerId: string;
|
|
680
747
|
};
|
|
681
748
|
} & {
|
|
682
|
-
json:
|
|
683
|
-
text: string;
|
|
684
|
-
};
|
|
749
|
+
json: Record<string, never>;
|
|
685
750
|
};
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
} & {
|
|
689
|
-
"/:workerId/stop": {
|
|
690
|
-
$post: {
|
|
751
|
+
} | {
|
|
691
752
|
output: {
|
|
692
753
|
workerId: string;
|
|
693
754
|
state: "stopping" | "terminated";
|
|
@@ -701,7 +762,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
701
762
|
} & {
|
|
702
763
|
json: Record<string, never>;
|
|
703
764
|
};
|
|
704
|
-
}
|
|
765
|
+
};
|
|
766
|
+
};
|
|
767
|
+
} & {
|
|
768
|
+
"/:workerId/destroy": {
|
|
769
|
+
$post: {
|
|
705
770
|
output: {
|
|
706
771
|
error: string;
|
|
707
772
|
code?: "invalid_input" | undefined;
|
|
@@ -715,11 +780,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
715
780
|
} & {
|
|
716
781
|
json: Record<string, never>;
|
|
717
782
|
};
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
} & {
|
|
721
|
-
"/:workerId/destroy": {
|
|
722
|
-
$post: {
|
|
783
|
+
} | {
|
|
723
784
|
output: {
|
|
724
785
|
workerId: string;
|
|
725
786
|
state: "complete" | "incomplete";
|
|
@@ -742,20 +803,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
742
803
|
} & {
|
|
743
804
|
json: Record<string, never>;
|
|
744
805
|
};
|
|
745
|
-
} | {
|
|
746
|
-
output: {
|
|
747
|
-
error: string;
|
|
748
|
-
code?: "invalid_input" | undefined;
|
|
749
|
-
};
|
|
750
|
-
outputFormat: "json";
|
|
751
|
-
status: 400;
|
|
752
|
-
input: {
|
|
753
|
-
param: {
|
|
754
|
-
workerId: string;
|
|
755
|
-
};
|
|
756
|
-
} & {
|
|
757
|
-
json: Record<string, never>;
|
|
758
|
-
};
|
|
759
806
|
} | {
|
|
760
807
|
output: {
|
|
761
808
|
workerId: string;
|
|
@@ -785,13 +832,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
785
832
|
"/:workerId/diff": {
|
|
786
833
|
$get: {
|
|
787
834
|
output: {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
diff: string;
|
|
791
|
-
truncated: boolean;
|
|
835
|
+
error: string;
|
|
836
|
+
code?: "invalid_input" | undefined;
|
|
792
837
|
};
|
|
793
838
|
outputFormat: "json";
|
|
794
|
-
status:
|
|
839
|
+
status: 400;
|
|
795
840
|
input: {
|
|
796
841
|
param: {
|
|
797
842
|
workerId: string;
|
|
@@ -799,11 +844,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
799
844
|
};
|
|
800
845
|
} | {
|
|
801
846
|
output: {
|
|
802
|
-
|
|
803
|
-
|
|
847
|
+
workerId: string;
|
|
848
|
+
baselineSha: string;
|
|
849
|
+
diff: string;
|
|
850
|
+
truncated: boolean;
|
|
804
851
|
};
|
|
805
852
|
outputFormat: "json";
|
|
806
|
-
status:
|
|
853
|
+
status: 200;
|
|
807
854
|
input: {
|
|
808
855
|
param: {
|
|
809
856
|
workerId: string;
|
|
@@ -2,7 +2,7 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { bodyLimit } from 'hono/body-limit';
|
|
3
3
|
import { ZodError } from 'zod';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { conversationSendRequestSchema, conversationInspectRequestSchema, conversationCancelRequestSchema, inboxReceiptRequestSchema, requestWaitRequestSchema, workerCancelWaitRequestSchema, workerSpawnRequestSchema, workerSteerRequestSchema, workerWaitRequestSchema, workerParamsSchema, workerEmptyRequestSchema } from '../contract/index.js';
|
|
5
|
+
import { discoveryRequestSchema, conversationSendRequestSchema, conversationInspectRequestSchema, conversationCancelRequestSchema, inboxReceiptRequestSchema, requestWaitRequestSchema, workerCancelWaitRequestSchema, workerSpawnRequestSchema, workerSteerRequestSchema, workerWaitRequestSchema, workerParamsSchema, workerEmptyRequestSchema } from '../contract/index.js';
|
|
6
6
|
import { jsonZodValidator, paramZodValidator, queryZodValidator } from '../server/validators.js';
|
|
7
7
|
import { isLoopbackHostHeader } from '../server/capabilities.js';
|
|
8
8
|
import { delegationEnabled } from './service.js';
|
|
@@ -14,7 +14,7 @@ export function delegationFailure(error) {
|
|
|
14
14
|
const status = known.code === 'unauthenticated' ? 401 : known.code === 'denied_scope' ? 403
|
|
15
15
|
: known.code === 'invalid_input' || known.code === 'invalid_baseline' ? 400
|
|
16
16
|
: known.code === 'unavailable_transport' ? 503 : 409;
|
|
17
|
-
return { body: { code: known.code, error: known.message.slice(0, 2_000) }, status };
|
|
17
|
+
return { body: { code: known.code, error: known.message.slice(0, 2_000), ...(known.modelChoices ? { modelChoices: known.modelChoices } : {}) }, status };
|
|
18
18
|
}
|
|
19
19
|
/** Only this family runs on the private listener. It never inherits hosted cockpit exposure. */
|
|
20
20
|
export function createDelegationRoutes(service, credentials) {
|
|
@@ -46,6 +46,7 @@ export function createDelegationRoutes(service, credentials) {
|
|
|
46
46
|
.use('*', authenticateDelegation)
|
|
47
47
|
.use('*', bodyLimit({ maxSize: 1_048_576, onError: c => c.json({ code: 'invalid_input', error: 'Delegation request too large' }, 400) }))
|
|
48
48
|
.use('*', queryZodValidator(workerEmptyRequestSchema, invalid))
|
|
49
|
+
.post('/discover', jsonZodValidator(discoveryRequestSchema, invalid), async (c) => c.json(await service.discover(c.get('caller'), c.req.valid('json')), 200))
|
|
49
50
|
.post('/spawn', jsonZodValidator(workerSpawnRequestSchema, invalid), async (c) => c.json(await service.spawn(c.get('caller'), c.req.valid('json')), 201))
|
|
50
51
|
.post('/wait', jsonZodValidator(z.union([workerWaitRequestSchema, requestWaitRequestSchema]), invalid), async (c) => { const value = c.req.valid('json'); return c.json(await ('requestIds' in value ? service.waitRequests(c.get('caller'), value) : service.wait(c.get('caller'), value)), 200); })
|
|
51
52
|
.post('/cancel-wait', jsonZodValidator(workerCancelWaitRequestSchema, invalid), async (c) => c.json(await service.cancelWait(c.get('caller'), c.req.valid('json')), 200))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/delegation/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,gCAAgC,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/delegation/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0B,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,gCAAgC,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACvX,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,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AAC;SACnP,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE;QAC7K,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnF,CAAC,CAAC;SACD,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAE,KAAK,EAAC,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/J,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HostDiscovery } from '../discovery/catalog.ts';
|
|
2
|
+
import { type DiscoveryRequest, type DiscoveryResponse, type ConversationSendRequest, type ConversationSendResult, type ConversationInspectRequest, type ConversationInspectResult, type ConversationCancelRequest, type InboxReserveResult, type InboxReceiptRequest, type InboxReceiptResult, type RequestWaitRequest, type RequestOutcome, type WorkerCancelWaitRequest, type WorkerCollectedResult, type WorkerInspection, type WorkerParams, type WorkerSpawnRequest, type WorkerSteerRequest, type WorkerWaitRequest } from '../contract/index.js';
|
|
2
3
|
import type { RunStore } from '../runs/store.ts';
|
|
3
4
|
import type { RunManager } from '../workflows/run.ts';
|
|
4
5
|
import type { Caller } from './credentials.ts';
|
|
@@ -11,8 +12,14 @@ export type DelegationProject = {
|
|
|
11
12
|
export declare const delegationEnabled: () => boolean;
|
|
12
13
|
/** A single controller's shared policy adapter; managers retain scheduling and lifecycle ownership. */
|
|
13
14
|
export declare class DelegationService {
|
|
15
|
+
private discovery?;
|
|
16
|
+
setDiscovery(discovery: HostDiscovery): void;
|
|
17
|
+
discover(caller: Caller, value: DiscoveryRequest): Promise<DiscoveryResponse>;
|
|
18
|
+
private validateModels;
|
|
14
19
|
private projects;
|
|
15
20
|
private serial;
|
|
21
|
+
/** How long destroy waits for proven termination; private and overridable so tests need not wait it out. */
|
|
22
|
+
private terminationTimeoutMs;
|
|
16
23
|
registerProject(project: DelegationProject): () => void;
|
|
17
24
|
private context;
|
|
18
25
|
private serialized;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { discoveredRunners, missingModelChoices } from '../discovery/catalog.js';
|
|
1
2
|
import { reconcileConversationState, projectConversationEvents } from './conversations.js';
|
|
2
3
|
import { openQuestions } from './questions.js';
|
|
3
4
|
import { collectWorkerEvidence, revalidateRetainedWorkerResult, workerRevision } from './results.js';
|
|
@@ -5,7 +6,7 @@ import { join } from 'node:path';
|
|
|
5
6
|
import { prepareWorkerContext, workerContextTask } from './context.js';
|
|
6
7
|
import { acceptedWorkerIdentitySchema, workerContextHash, workerWorkflowHash } from './execution-identity.js';
|
|
7
8
|
import { createHash, randomUUID } from 'node:crypto';
|
|
8
|
-
import { conversationSendRequestSchema, conversationInspectRequestSchema, conversationCancelRequestSchema, inboxReceiptRequestSchema, requestWaitRequestSchema, workerSpawnRequestSchema, workerSteerRequestSchema, workerWaitRequestSchema, workerParamsSchema, workerCancelWaitRequestSchema, } from '../contract/index.js';
|
|
9
|
+
import { discoveryRequestSchema, conversationSendRequestSchema, conversationInspectRequestSchema, conversationCancelRequestSchema, inboxReceiptRequestSchema, requestWaitRequestSchema, workerSpawnRequestSchema, workerSteerRequestSchema, workerWaitRequestSchema, workerParamsSchema, workerCancelWaitRequestSchema, } from '../contract/index.js';
|
|
9
10
|
import { workerOutcome } from '../runs/delegation-state.js';
|
|
10
11
|
import { QUICK_TASK_WORKFLOW, allowedToolsForStep, stepKind } from '../workflows/types.js';
|
|
11
12
|
import { findWorkflow } from '../workflows/load.js';
|
|
@@ -48,7 +49,7 @@ function narrowGrants(parent, step, runner) {
|
|
|
48
49
|
* only what a step leaves unset; a step's own runner, model, effort and account win. Equal
|
|
49
50
|
* selections share one resolution so a ten-step single-runner chain reads the registry once.
|
|
50
51
|
*/
|
|
51
|
-
async function resolveSpawnSteps(manager, parentId, request, workflow) {
|
|
52
|
+
async function resolveSpawnSteps(manager, parentId, request, workflow, validateModel) {
|
|
52
53
|
const cache = new Map();
|
|
53
54
|
const resolved = [];
|
|
54
55
|
for (const step of workflow.steps) {
|
|
@@ -63,7 +64,7 @@ async function resolveSpawnSteps(manager, parentId, request, workflow) {
|
|
|
63
64
|
const key = JSON.stringify(selection);
|
|
64
65
|
let pending = cache.get(key);
|
|
65
66
|
if (!pending) {
|
|
66
|
-
pending = manager.selectDelegationExecutionSettings(parentId, selection);
|
|
67
|
+
pending = manager.selectDelegationExecutionSettings(parentId, selection, settings => validateModel(step, settings));
|
|
67
68
|
cache.set(key, pending);
|
|
68
69
|
}
|
|
69
70
|
const settings = await pending;
|
|
@@ -78,8 +79,46 @@ function stepIdentityFields({ settings, grants }) {
|
|
|
78
79
|
export const delegationEnabled = () => process.env.CEZ_DELEGATION === '1';
|
|
79
80
|
/** A single controller's shared policy adapter; managers retain scheduling and lifecycle ownership. */
|
|
80
81
|
export class DelegationService {
|
|
82
|
+
discovery;
|
|
83
|
+
setDiscovery(discovery) { this.discovery = discovery; }
|
|
84
|
+
async discover(caller, value) {
|
|
85
|
+
const project = this.context(caller);
|
|
86
|
+
// Discovery accompanies spawn authority, including roots persisted before this command existed.
|
|
87
|
+
authorizeSpawnReplay(caller, project.store.getRun(caller.runId), project.id);
|
|
88
|
+
const request = discoveryRequestSchema.parse(value);
|
|
89
|
+
if (!this.discovery)
|
|
90
|
+
throw new DelegationPolicyError('unavailable_transport', 'Host discovery is unavailable');
|
|
91
|
+
return request.kind === 'models' ? this.discovery.models.get(request.runner) : discoveredRunners(await this.discovery.providers());
|
|
92
|
+
}
|
|
93
|
+
async validateModels(request, resolved) {
|
|
94
|
+
if (!this.discovery)
|
|
95
|
+
return;
|
|
96
|
+
const checked = new Set();
|
|
97
|
+
for (const { step, settings } of resolved) {
|
|
98
|
+
// The host catalog says nothing authoritative about a different named account.
|
|
99
|
+
if (settings.accountBinding?.profileId !== 'default')
|
|
100
|
+
continue;
|
|
101
|
+
const model = (step.model ?? request.model)?.trim();
|
|
102
|
+
if (!model)
|
|
103
|
+
continue; // Inherited/default models keep their existing resolution path.
|
|
104
|
+
const runner = settings.runner;
|
|
105
|
+
const key = JSON.stringify([runner, model]);
|
|
106
|
+
if (checked.has(key))
|
|
107
|
+
continue;
|
|
108
|
+
checked.add(key);
|
|
109
|
+
const choices = await missingModelChoices(this.discovery, runner, model, settings.model, settings.modelIdentity);
|
|
110
|
+
if (!choices)
|
|
111
|
+
continue;
|
|
112
|
+
const alternatives = choices.otherRunners.join(', ') || 'none';
|
|
113
|
+
const available = choices.availableModels.map(row => `${row.id}${row.effortLevels ? ` (effort: ${row.effortLevels.join(', ') || 'none advertised'})` : ''}`).join('; ');
|
|
114
|
+
// Full choices remain structured even when the human-readable error reaches its bound.
|
|
115
|
+
throw new DelegationPolicyError('invalid_input', `Model "${model}" is not in the ${runner} catalog. Available models: ${available.slice(0, 1200)}. Other runners listing "${model}": ${alternatives}. Use cez discover models --runner=${runner}.`, choices);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
81
118
|
projects = new Map();
|
|
82
119
|
serial = new Map();
|
|
120
|
+
/** How long destroy waits for proven termination; private and overridable so tests need not wait it out. */
|
|
121
|
+
terminationTimeoutMs = 30_000;
|
|
83
122
|
registerProject(project) {
|
|
84
123
|
const existing = this.projects.get(project.id);
|
|
85
124
|
if (existing?.store === project.store && existing.manager === project.manager)
|
|
@@ -395,7 +434,7 @@ export class DelegationService {
|
|
|
395
434
|
}
|
|
396
435
|
authorizeSpawn(caller, parent, project.id);
|
|
397
436
|
const catalog = await resolveSpawnWorkflow(project.root, request);
|
|
398
|
-
const resolvedSteps = await resolveSpawnSteps(project.manager, parent.id, request, catalog);
|
|
437
|
+
const resolvedSteps = await resolveSpawnSteps(project.manager, parent.id, request, catalog, (step, settings) => this.validateModels(request, [{ step, settings }]));
|
|
399
438
|
// Run-level fields hold the first agent step (cockpit columns, pre-#452 evidence readers);
|
|
400
439
|
// the per-step list is what each launch binds.
|
|
401
440
|
const first = resolvedSteps[0];
|
|
@@ -452,9 +491,10 @@ export class DelegationService {
|
|
|
452
491
|
});
|
|
453
492
|
}
|
|
454
493
|
async inspect(caller, params) {
|
|
455
|
-
const { worker, parent } = this.target(caller, params, 'inspect');
|
|
494
|
+
const { project, worker, parent } = this.target(caller, params, 'inspect');
|
|
456
495
|
if (worker.delegation?.role !== 'worker')
|
|
457
496
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
497
|
+
project.manager.settleOrphanedWorkerExecution(worker.id); // #469: an orphan that died after recovery settles
|
|
458
498
|
const outcome = workerOutcome(worker, new Date().toISOString());
|
|
459
499
|
const wait = parent.delegation?.role === 'root' ? parent.delegation.wait : undefined;
|
|
460
500
|
return { workerId: worker.id, parentRunId: parent.id, status: worker.status, workspace: worker.delegation.workspace,
|
|
@@ -477,6 +517,7 @@ export class DelegationService {
|
|
|
477
517
|
return project.store.commitWorkerResult(caller.runId, evidence, project.store.readWorkerResultDiff(caller.runId, workerId));
|
|
478
518
|
}
|
|
479
519
|
authorizeWorker(caller, worker, 'inspect', parent, project.id);
|
|
520
|
+
project.manager.settleOrphanedWorkerExecution(workerId); // #469: before `settled` is computed
|
|
480
521
|
if (parent?.delegation?.role === 'root' && parent.delegation.receipts.some(receipt => receipt.workerId === workerId && receipt.deletion?.phase === 'pending')) {
|
|
481
522
|
const retained = project.store.readWorkerResult(parent.id, workerId);
|
|
482
523
|
if (!retained || !project.store.canDeleteRun(workerId))
|
|
@@ -576,8 +617,16 @@ export class DelegationService {
|
|
|
576
617
|
persist('terminating', ['process', ...resources]);
|
|
577
618
|
project.manager.requestWorkerStop(workerId);
|
|
578
619
|
let result;
|
|
579
|
-
if (!await project.manager.awaitRunTermination(workerId,
|
|
580
|
-
|
|
620
|
+
if (!await project.manager.awaitRunTermination(workerId, this.terminationTimeoutMs, { reapOrphans: true })) {
|
|
621
|
+
// #469: name what blocks a crashed generation; other causes keep the generic message.
|
|
622
|
+
const taken = project.manager.takeWorkerTerminationBlocker(workerId);
|
|
623
|
+
const reason = taken && (taken.blocker.kind === 'unreadable' ? 'worker process record is unreadable; termination cannot be proven'
|
|
624
|
+
: taken.blocker.kind === 'controller' ? `the worker is still controlled by a live cezar (pid ${taken.blocker.pid})`
|
|
625
|
+
: `${taken.blocker.pids.length === 1 ? 'process' : 'processes'} ${taken.blocker.pids.join(', ')} still ${taken.blocker.pids.length === 1 ? 'holds' : 'hold'} the worker's worktree or scratch`);
|
|
626
|
+
if (taken?.changed)
|
|
627
|
+
project.store.appendEvent(workerId, { type: 'lifecycle', message: `destroy blocked: ${reason}` });
|
|
628
|
+
result = { workerId, state: 'incomplete', remaining: ['process', ...resources], error: !taken ? 'Worker termination is not proven; retry cleanup later'
|
|
629
|
+
: taken.blocker.kind === 'unreadable' ? reason : `Worker termination is not proven: ${reason}; retry cleanup later` };
|
|
581
630
|
}
|
|
582
631
|
else {
|
|
583
632
|
persist('cleaning', resources);
|