@hearsay-tools/squawk 0.18.0-dev.7406 → 0.18.0-dev.7413
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/automations/github-poller.d.ts +3 -0
- package/dist/automations/github-poller.js +5 -1
- package/dist/automations/github-poller.js.map +1 -1
- package/dist/automations/github-repository.d.ts +2 -2
- package/dist/automations/github-repository.js +7 -1
- package/dist/automations/github-repository.js.map +1 -1
- package/dist/automations/scheduler.d.ts +2 -0
- package/dist/automations/scheduler.js +26 -2
- package/dist/automations/scheduler.js.map +1 -1
- package/dist/ci-wait/controller.d.ts +42 -42
- package/dist/ci-wait/github.d.ts +8 -12
- package/dist/ci-wait/github.js +14 -49
- package/dist/ci-wait/github.js.map +1 -1
- package/dist/ci-wait/supervisor.js +4 -3
- package/dist/ci-wait/supervisor.js.map +1 -1
- package/dist/contract/delegation.d.ts +30 -0
- package/dist/contract/index.js +10 -0
- package/dist/contract/runs.d.ts +48 -0
- package/dist/delegation/capacity.d.ts +7 -1
- package/dist/delegation/capacity.js +21 -12
- package/dist/delegation/capacity.js.map +1 -1
- package/dist/delegation/conversation-send.d.ts +3 -10
- package/dist/delegation/conversation-send.js +4 -3
- package/dist/delegation/conversation-send.js.map +1 -1
- package/dist/delegation/conversations.d.ts +18 -2175
- package/dist/delegation/conversations.js +47 -62
- package/dist/delegation/conversations.js.map +1 -1
- package/dist/delegation/policy.d.ts +7 -4
- package/dist/delegation/policy.js +29 -27
- package/dist/delegation/policy.js.map +1 -1
- package/dist/delegation/readiness.js +3 -2
- package/dist/delegation/readiness.js.map +1 -1
- package/dist/delegation/routes.d.ts +66 -66
- package/dist/delegation/service.d.ts +4 -9
- package/dist/delegation/service.js +65 -78
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/task-discovery.js +3 -3
- package/dist/delegation/task-discovery.js.map +1 -1
- package/dist/delegation/transport.d.ts +83 -83
- package/dist/runs/delegation-state.d.ts +16 -0
- package/dist/runs/run-exits.d.ts +60 -0
- package/dist/runs/store.d.ts +26 -0
- package/dist/runs/task-rights.d.ts +68 -0
- package/dist/runs/task-rights.js +108 -0
- package/dist/runs/task-rights.js.map +1 -0
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/archive-on-merge.js +6 -1
- package/dist/server/archive-on-merge.js.map +1 -1
- package/dist/server/forge/github-merged-pr-chunk.d.ts +5 -0
- package/dist/server/forge/github-merged-pr-chunk.js +45 -0
- package/dist/server/forge/github-merged-pr-chunk.js.map +1 -0
- package/dist/server/forge/github-repo-handle.d.ts +3 -2
- package/dist/server/forge/github-repo-handle.js +4 -3
- package/dist/server/forge/github-repo-handle.js.map +1 -1
- package/dist/server/forge/github-request-gate.d.ts +64 -0
- package/dist/server/forge/github-request-gate.js +152 -0
- package/dist/server/forge/github-request-gate.js.map +1 -0
- package/dist/server/forge/github.js +4 -44
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/server.d.ts +3082 -2902
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/workflows/continuation-admission.d.ts +10 -0
- package/dist/workflows/input-acknowledgement.d.ts +24 -24
- package/dist/workflows/run/completion-gate.js +9 -10
- package/dist/workflows/run/completion-gate.js.map +1 -1
- package/dist/workflows/run/run-finish.js +4 -3
- package/dist/workflows/run/run-finish.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +82 -72
- package/dist/workflows/run/wait-registry.js +2 -2
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/wait-scope.d.ts +6 -8
- package/dist/workflows/wait-scope.js +13 -14
- package/dist/workflows/wait-scope.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-GWiNidwF.js → activity-motion-CjiZJB7H.js} +1 -1
- package/web/dist/assets/{activity-route-ByFh99Eo.js → activity-route-1W0U2NqM.js} +1 -1
- package/web/dist/assets/{agent-accounts-BDB73Hg9.js → agent-accounts-DJbSC2sB.js} +1 -1
- package/web/dist/assets/attention-BdI3xSwD.js +1 -0
- package/web/dist/assets/{cez-idle-DreV5r0B.js → cez-idle-CKE0WtrH.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-CM6ogknc.js → commit-diff-panel-DkvsBvlr.js} +1 -1
- package/web/dist/assets/{diff-BU25IR0d.js → diff-BCSgE1l6.js} +2 -2
- package/web/dist/assets/{diff-view-CnGdaz-L.js → diff-view-B3eMq9Uw.js} +1 -1
- package/web/dist/assets/{file-preview-COpe5-X0.js → file-preview-BIHQ0YTn.js} +1 -1
- package/web/dist/assets/{git-toolbar-CMH0kDal.js → git-toolbar-BtU7xtmD.js} +1 -1
- package/web/dist/assets/{github-JeDKhIAK.js → github-INQcTy36.js} +1 -1
- package/web/dist/assets/{global-activity-route-x2Xn5g2h.js → global-activity-route-B3-2eIFG.js} +1 -1
- package/web/dist/assets/{index-3JtARe0j.js → index-DUuc-42H.js} +4 -4
- package/web/dist/assets/{live-protocol-kUxhOnN1.js → live-protocol-B5jzpJgG.js} +1 -1
- package/web/dist/assets/{markdown-BDuLh9lK.js → markdown-DcRzCfVU.js} +1 -1
- package/web/dist/assets/{picker-pill-DpZKt_In.js → picker-pill-x0hXGTLP.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-CwYbRQfS.js → preview-pane-connected-CCHDk6rz.js} +1 -1
- package/web/dist/assets/{project-router-DNqfLxdJ.js → project-router-_V9XDi3p.js} +1 -1
- package/web/dist/assets/{project-scope-context-CFEoNQTg.js → project-scope-context-VENshCVj.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-DPEauS3z.js → prompt-template-menu-C60uqznw.js} +1 -1
- package/web/dist/assets/{queries-mk7hUEKT.js → queries-r1Fc1fWN.js} +1 -1
- package/web/dist/assets/{reference-chip-DQtQZJaX.js → reference-chip-GElOouoU.js} +1 -1
- package/web/dist/assets/{repo-git-CcfbTImd.js → repo-git-B09hWAxY.js} +1 -1
- package/web/dist/assets/{report-reader-CWXDg8JE.js → report-reader-y4t2Prir.js} +1 -1
- package/web/dist/assets/{reports-Bau_TxUs.js → reports-BU3a_4kU.js} +1 -1
- package/web/dist/assets/{run-header-C5wDUTls.js → run-header-BZukpHEK.js} +1 -1
- package/web/dist/assets/{skills-CFl4V447.js → skills-C6V0Yo95.js} +1 -1
- package/web/dist/assets/{tab-link-B7SjdDeU.js → tab-link-CuL027Wh.js} +1 -1
- package/web/dist/assets/{task-changes-Dnprgwc1.js → task-changes-Dx9OTRkk.js} +1 -1
- package/web/dist/assets/{task-commits-B0SApZKn.js → task-commits-ClWR4wQR.js} +1 -1
- package/web/dist/assets/{task-files-B_mLju-K.js → task-files-DCkrdsrz.js} +1 -1
- package/web/dist/assets/{task-github-item-BUoUh8t0.js → task-github-item-C3D4vDw7.js} +1 -1
- package/web/dist/assets/{task-thread-BQi3cH3M.js → task-thread-D0sTMg9h.js} +1 -1
- package/web/dist/assets/{thread-state-BOUrIjKm.js → thread-state-BHSYtS79.js} +1 -1
- package/web/dist/assets/{use-desktop-CkqdpZt0.js → use-desktop-BnWAyH1e.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-PCPwKRR0.js → use-hand-to-agent-state-VmvgZIh6.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-BL1dhFBm.js → useInfiniteQuery-DbCUWSLK.js} +1 -1
- package/web/dist/assets/useQuery-CxWGWuW4.js +1 -0
- package/web/dist/assets/{workflows-BRZR4pVb.js → workflows-B_HWC2FT.js} +1 -1
- package/web/dist/assets/{ws-DX0R2MDS.js → ws-jytXIi1s.js} +1 -1
- package/web/dist/index.html +15 -15
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/attention-FrfXSNio.js +0 -1
- package/web/dist/assets/useQuery-B12MHZfS.js +0 -1
|
@@ -27,6 +27,18 @@ export declare function delegationFailure(error: unknown): {
|
|
|
27
27
|
export declare function createDelegationRoutes(service: DelegationService, credentials: CredentialRegistry): import("hono/hono-base").HonoBase<Env, {
|
|
28
28
|
"/list": {
|
|
29
29
|
$get: {
|
|
30
|
+
output: {
|
|
31
|
+
error: string;
|
|
32
|
+
code?: "invalid_input" | undefined;
|
|
33
|
+
};
|
|
34
|
+
outputFormat: "json";
|
|
35
|
+
status: 400;
|
|
36
|
+
input: {
|
|
37
|
+
query: {
|
|
38
|
+
offset?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
30
42
|
output: {
|
|
31
43
|
workers: {
|
|
32
44
|
workerId: string;
|
|
@@ -71,18 +83,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
71
83
|
offset?: string | undefined;
|
|
72
84
|
};
|
|
73
85
|
};
|
|
74
|
-
} | {
|
|
75
|
-
output: {
|
|
76
|
-
error: string;
|
|
77
|
-
code?: "invalid_input" | undefined;
|
|
78
|
-
};
|
|
79
|
-
outputFormat: "json";
|
|
80
|
-
status: 400;
|
|
81
|
-
input: {
|
|
82
|
-
query: {
|
|
83
|
-
offset?: string | undefined;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
} & {
|
|
@@ -229,13 +229,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
229
229
|
status: 200;
|
|
230
230
|
input: {
|
|
231
231
|
json: {
|
|
232
|
-
requestIds: string[];
|
|
233
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
234
|
-
timeoutSeconds?: number | undefined;
|
|
235
|
-
} | {
|
|
236
232
|
workerIds: string[];
|
|
237
233
|
timeoutSeconds?: number | undefined;
|
|
238
234
|
mode?: "all" | "any" | "one" | undefined;
|
|
235
|
+
} | {
|
|
236
|
+
requestIds: string[];
|
|
237
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
238
|
+
timeoutSeconds?: number | undefined;
|
|
239
239
|
} | {
|
|
240
240
|
peerIds: string[];
|
|
241
241
|
timeoutSeconds?: number | undefined;
|
|
@@ -621,6 +621,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
621
621
|
} & {
|
|
622
622
|
"/:workerId": {
|
|
623
623
|
$get: {
|
|
624
|
+
output: {
|
|
625
|
+
error: string;
|
|
626
|
+
code?: "invalid_input" | undefined;
|
|
627
|
+
};
|
|
628
|
+
outputFormat: "json";
|
|
629
|
+
status: 400;
|
|
630
|
+
input: {
|
|
631
|
+
param: {
|
|
632
|
+
workerId: string;
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
} | {
|
|
624
636
|
output: {
|
|
625
637
|
workerId: string;
|
|
626
638
|
settled: boolean;
|
|
@@ -736,7 +748,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
736
748
|
workerId: string;
|
|
737
749
|
};
|
|
738
750
|
};
|
|
739
|
-
}
|
|
751
|
+
};
|
|
752
|
+
};
|
|
753
|
+
} & {
|
|
754
|
+
"/:workerId/collect": {
|
|
755
|
+
$post: {
|
|
740
756
|
output: {
|
|
741
757
|
error: string;
|
|
742
758
|
code?: "invalid_input" | undefined;
|
|
@@ -747,12 +763,10 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
747
763
|
param: {
|
|
748
764
|
workerId: string;
|
|
749
765
|
};
|
|
766
|
+
} & {
|
|
767
|
+
json: Record<string, never>;
|
|
750
768
|
};
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
} & {
|
|
754
|
-
"/:workerId/collect": {
|
|
755
|
-
$post: {
|
|
769
|
+
} | {
|
|
756
770
|
output: {
|
|
757
771
|
workerId: string;
|
|
758
772
|
parentRunId: string;
|
|
@@ -875,7 +889,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
875
889
|
} & {
|
|
876
890
|
json: Record<string, never>;
|
|
877
891
|
};
|
|
878
|
-
}
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
} & {
|
|
895
|
+
"/:workerId/steer": {
|
|
896
|
+
$post: {
|
|
879
897
|
output: {
|
|
880
898
|
error: string;
|
|
881
899
|
code?: "invalid_input" | undefined;
|
|
@@ -887,13 +905,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
887
905
|
workerId: string;
|
|
888
906
|
};
|
|
889
907
|
} & {
|
|
890
|
-
json:
|
|
908
|
+
json: {
|
|
909
|
+
text: string;
|
|
910
|
+
};
|
|
891
911
|
};
|
|
892
|
-
}
|
|
893
|
-
};
|
|
894
|
-
} & {
|
|
895
|
-
"/:workerId/steer": {
|
|
896
|
-
$post: {
|
|
912
|
+
} | {
|
|
897
913
|
output: {
|
|
898
914
|
workerId: string;
|
|
899
915
|
state: "delivered" | "queued";
|
|
@@ -909,7 +925,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
909
925
|
text: string;
|
|
910
926
|
};
|
|
911
927
|
};
|
|
912
|
-
}
|
|
928
|
+
};
|
|
929
|
+
};
|
|
930
|
+
} & {
|
|
931
|
+
"/:workerId/stop": {
|
|
932
|
+
$post: {
|
|
913
933
|
output: {
|
|
914
934
|
error: string;
|
|
915
935
|
code?: "invalid_input" | undefined;
|
|
@@ -921,15 +941,9 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
921
941
|
workerId: string;
|
|
922
942
|
};
|
|
923
943
|
} & {
|
|
924
|
-
json:
|
|
925
|
-
text: string;
|
|
926
|
-
};
|
|
944
|
+
json: Record<string, never>;
|
|
927
945
|
};
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
} & {
|
|
931
|
-
"/:workerId/stop": {
|
|
932
|
-
$post: {
|
|
946
|
+
} | {
|
|
933
947
|
output: {
|
|
934
948
|
workerId: string;
|
|
935
949
|
state: "stopping" | "terminated";
|
|
@@ -943,7 +957,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
943
957
|
} & {
|
|
944
958
|
json: Record<string, never>;
|
|
945
959
|
};
|
|
946
|
-
}
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
} & {
|
|
963
|
+
"/:workerId/destroy": {
|
|
964
|
+
$post: {
|
|
947
965
|
output: {
|
|
948
966
|
error: string;
|
|
949
967
|
code?: "invalid_input" | undefined;
|
|
@@ -957,11 +975,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
957
975
|
} & {
|
|
958
976
|
json: Record<string, never>;
|
|
959
977
|
};
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
} & {
|
|
963
|
-
"/:workerId/destroy": {
|
|
964
|
-
$post: {
|
|
978
|
+
} | {
|
|
965
979
|
output: {
|
|
966
980
|
workerId: string;
|
|
967
981
|
state: "complete" | "incomplete";
|
|
@@ -984,20 +998,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
984
998
|
} & {
|
|
985
999
|
json: Record<string, never>;
|
|
986
1000
|
};
|
|
987
|
-
} | {
|
|
988
|
-
output: {
|
|
989
|
-
error: string;
|
|
990
|
-
code?: "invalid_input" | undefined;
|
|
991
|
-
};
|
|
992
|
-
outputFormat: "json";
|
|
993
|
-
status: 400;
|
|
994
|
-
input: {
|
|
995
|
-
param: {
|
|
996
|
-
workerId: string;
|
|
997
|
-
};
|
|
998
|
-
} & {
|
|
999
|
-
json: Record<string, never>;
|
|
1000
|
-
};
|
|
1001
1001
|
} | {
|
|
1002
1002
|
output: {
|
|
1003
1003
|
workerId: string;
|
|
@@ -1027,13 +1027,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1027
1027
|
"/:workerId/diff": {
|
|
1028
1028
|
$get: {
|
|
1029
1029
|
output: {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
diff: string;
|
|
1033
|
-
truncated: boolean;
|
|
1030
|
+
error: string;
|
|
1031
|
+
code?: "invalid_input" | undefined;
|
|
1034
1032
|
};
|
|
1035
1033
|
outputFormat: "json";
|
|
1036
|
-
status:
|
|
1034
|
+
status: 400;
|
|
1037
1035
|
input: {
|
|
1038
1036
|
param: {
|
|
1039
1037
|
workerId: string;
|
|
@@ -1041,11 +1039,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1041
1039
|
};
|
|
1042
1040
|
} | {
|
|
1043
1041
|
output: {
|
|
1044
|
-
|
|
1045
|
-
|
|
1042
|
+
workerId: string;
|
|
1043
|
+
baselineSha: string;
|
|
1044
|
+
diff: string;
|
|
1045
|
+
truncated: boolean;
|
|
1046
1046
|
};
|
|
1047
1047
|
outputFormat: "json";
|
|
1048
|
-
status:
|
|
1048
|
+
status: 200;
|
|
1049
1049
|
input: {
|
|
1050
1050
|
param: {
|
|
1051
1051
|
workerId: string;
|
|
@@ -44,16 +44,11 @@ export declare class DelegationService {
|
|
|
44
44
|
private context;
|
|
45
45
|
private serialized;
|
|
46
46
|
private target;
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* root and its direct owned worker, `peer` for two root tasks of the caller's project, and
|
|
50
|
-
* `denied_scope` with one text for everything else. `send` asks for the live pair a new message
|
|
51
|
-
* needs; without it the pair is checked for reading. A peer's own durable records (history, its
|
|
52
|
-
* requests, its inbox) are read through `peerRecords` instead, which a deleted peer does not block.
|
|
53
|
-
*/
|
|
47
|
+
/** The resolved pair (`resolvePair`). A peer's own durable records (history, its requests, its
|
|
48
|
+
* inbox) are read through `peerRecords` instead, which a deleted peer does not block. */
|
|
54
49
|
private conversationPair;
|
|
55
|
-
/** The caller's own peer records need only its participation: a
|
|
56
|
-
* not being deleted. The record read names the counterpart; a deleted peer does not block it. */
|
|
50
|
+
/** The caller's own peer records need only its participation: a task that may message peers and
|
|
51
|
+
* whose own history is not being deleted. The record read names the counterpart; a deleted peer does not block it. */
|
|
57
52
|
private peerRecords;
|
|
58
53
|
/** The ledger a new message lands in (spec § 2, Which ledger holds a message): a new request or
|
|
59
54
|
* progress message in the sender's family ledger, a follow-up or reply with the request it names. */
|
|
@@ -4,7 +4,7 @@ import { projectPaths } from '../project-paths.js';
|
|
|
4
4
|
import { assertReplyDirection, sendRequestContext, sendAdmission, sendMessage, sendInput } from './conversation-send.js';
|
|
5
5
|
import { discoverTasks } from './task-discovery.js';
|
|
6
6
|
import { discoveredRunners, missingModelChoices } from '../discovery/choices.js';
|
|
7
|
-
import { assertConversationCapacity,
|
|
7
|
+
import { assertConversationCapacity, byCreatedAtAndId, commitAccepted, inboxEntryIn, orphanedPeerMessage, resolvePair, takesPart, projectConversationEvents, reconcileConversationState, replyOutcomes } from './conversations.js';
|
|
8
8
|
export { rootDelegation } from './conversations.js';
|
|
9
9
|
import { collectWorkerEvidence, revalidateRetainedWorkerResult, workerRevision } from './results.js';
|
|
10
10
|
import { workerContextTask } from './context.js';
|
|
@@ -17,6 +17,7 @@ import { messagingAllowed } from '../contract/index.js';
|
|
|
17
17
|
import { completionWaitEntry, peerWaitView, workerCompletionWaitProjection, workerWaitEntryToLegacy } from '../contract/index.js';
|
|
18
18
|
import { assertConversationIdFree, ConversationIdInUseError } from '../runs/conversation-identity.js';
|
|
19
19
|
import { workerDestroyView, workerOutcome, workerObservation } from '../runs/delegation-state.js';
|
|
20
|
+
import { childSpawnGrant, conversationOf, DEFAULT_GRANTS, familyRecordOf, grantsOf, historyDeleting, isFamilyRecord, receiptsOf, relationOf, supervisorIdOf } from '../runs/task-rights.js';
|
|
20
21
|
import { QUICK_TASK_WORKFLOW, skillTaskSteps, plannedWorkflow, allowedToolsForStep, stepKind } from '../workflows/types.js';
|
|
21
22
|
import { resolveRunnerSkill } from '../core/runner-skill-reference.js';
|
|
22
23
|
import { findWorkflow } from '../workflows/load.js';
|
|
@@ -98,16 +99,14 @@ function spawnRequestHash(request) {
|
|
|
98
99
|
...((request.workspace ?? DEFAULT_WORKSPACE_CHOICE) === DEFAULT_WORKSPACE_CHOICE ? {} : { workspace: request.workspace }),
|
|
99
100
|
})).digest('hex');
|
|
100
101
|
}
|
|
101
|
-
function replayedSpawn(project, parent, requestId, requestHash) {
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
const receipt = parent.delegation.receipts.find(r => r.requestId === requestId);
|
|
102
|
+
function replayedSpawn(project, family, parent, requestId, requestHash) {
|
|
103
|
+
const receipt = receiptsOf(family).find(r => r.requestId === requestId);
|
|
105
104
|
if (!receipt)
|
|
106
105
|
return;
|
|
107
106
|
if (receipt.requestHash !== requestHash)
|
|
108
107
|
throw new DelegationPolicyError('invalid_input', 'Request ID payload conflict');
|
|
109
108
|
const worker = project.store.getRun(receipt.workerId);
|
|
110
|
-
if (worker?.delegation?.role !== 'worker' ||
|
|
109
|
+
if (worker?.delegation?.role !== 'worker' || relationOf(parent, worker) !== 'supervised')
|
|
111
110
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
112
111
|
return { workerId: worker.id, baselineSha: worker.delegation.workspace.baselineSha };
|
|
113
112
|
}
|
|
@@ -128,14 +127,15 @@ function boundSpawnWorkflow(catalog, resolvedSteps) {
|
|
|
128
127
|
}) };
|
|
129
128
|
}
|
|
130
129
|
async function acceptSpawnedWorker(args) {
|
|
131
|
-
const { project, parent, request, catalog, resolvedSteps, settings, identity, workspace, baselineSha, requestHash, prepared, caller } = args;
|
|
130
|
+
const { project, parent, family, request, catalog, resolvedSteps, settings, identity, workspace, baselineSha, requestHash, prepared, caller } = args;
|
|
132
131
|
const context = prepared?.recipe;
|
|
133
132
|
let accepted = false;
|
|
134
133
|
try {
|
|
135
134
|
// Ref resolution yields to Finish, revocation and project disposal; recheck before acceptance.
|
|
136
135
|
if (args.current() !== project)
|
|
137
136
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
138
|
-
authorizeSpawn(caller, project.store.getRun(parent.id), project.id, id => project.store.getRun(id));
|
|
137
|
+
authorizeSpawn(caller, project.store.getRun(parent.id), project.id, id => project.store.getRun(id), workspace.kind);
|
|
138
|
+
const spawnGrant = childSpawnGrant(parent);
|
|
139
139
|
const workflowDef = boundSpawnWorkflow(catalog, resolvedSteps);
|
|
140
140
|
const worker = project.store.createOwnedRun({
|
|
141
141
|
title: request.task.slice(0, 200), task: context ? workerContextTask(request.task, context) : request.task, workflow: workflowDef.name,
|
|
@@ -143,7 +143,8 @@ async function acceptSpawnedWorker(args) {
|
|
|
143
143
|
systemPrompt: settings.systemPrompt, workflowDef,
|
|
144
144
|
autonomous: parent.autonomous,
|
|
145
145
|
steps: workflowDef.steps.map(step => ({ id: step.id, name: step.name ?? step.id, kind: stepKind(step) })),
|
|
146
|
-
},
|
|
146
|
+
}, family.id, request.requestId, { role: 'worker', permissions: [...DEFAULT_GRANTS.worker.operate], ...(spawnGrant ? { spawnGrant } : {}),
|
|
147
|
+
parentRunId: family.id, workspace, ...(context ? { context } : {}) }, requestHash, {
|
|
147
148
|
...identity, ...(context ? { contextHash: workerContextHash(context) } : {}),
|
|
148
149
|
// A named catalog chain or skill is bound like the context recipe; the default quick-task leaves the identity as before.
|
|
149
150
|
...(request.workflow === undefined && request.skill === undefined ? {} : { workflowHash: workerWorkflowHash(workflowDef) }),
|
|
@@ -269,30 +270,18 @@ export class DelegationService {
|
|
|
269
270
|
authorizeWorker(caller, worker, operation, parent, project.id);
|
|
270
271
|
return { project, parent: parent, worker: worker };
|
|
271
272
|
}
|
|
272
|
-
/**
|
|
273
|
-
*
|
|
274
|
-
* root and its direct owned worker, `peer` for two root tasks of the caller's project, and
|
|
275
|
-
* `denied_scope` with one text for everything else. `send` asks for the live pair a new message
|
|
276
|
-
* needs; without it the pair is checked for reading. A peer's own durable records (history, its
|
|
277
|
-
* requests, its inbox) are read through `peerRecords` instead, which a deleted peer does not block.
|
|
278
|
-
*/
|
|
273
|
+
/** The resolved pair (`resolvePair`). A peer's own durable records (history, its requests, its
|
|
274
|
+
* inbox) are read through `peerRecords` instead, which a deleted peer does not block. */
|
|
279
275
|
conversationPair(caller, recipientRunId, send = false) {
|
|
280
276
|
const project = this.context(caller);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return { project, ...peer };
|
|
286
|
-
const { root, worker } = familyPair(sender, recipient);
|
|
287
|
-
assertFamilySender(sender, root, send);
|
|
288
|
-
return { project, relationship: 'family', sender: sender, recipient: recipient, root, worker };
|
|
289
|
-
}
|
|
290
|
-
/** The caller's own peer records need only its participation: a root task whose own history is
|
|
291
|
-
* not being deleted. The record read names the counterpart; a deleted peer does not block it. */
|
|
277
|
+
return { project, ...resolvePair(project.store.getRun(caller.runId), project.store.getRun(recipientRunId), id => project.store.getRun(id), send) };
|
|
278
|
+
}
|
|
279
|
+
/** The caller's own peer records need only its participation: a task that may message peers and
|
|
280
|
+
* whose own history is not being deleted. The record read names the counterpart; a deleted peer does not block it. */
|
|
292
281
|
peerRecords(caller) {
|
|
293
282
|
const project = this.context(caller);
|
|
294
283
|
const self = project.store.getRun(caller.runId);
|
|
295
|
-
if (self
|
|
284
|
+
if (!self || !grantsOf(self).message.includes('peer') || historyDeleting(self))
|
|
296
285
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
297
286
|
return { project, self };
|
|
298
287
|
}
|
|
@@ -303,25 +292,24 @@ export class DelegationService {
|
|
|
303
292
|
return pair.root;
|
|
304
293
|
const ledger = request.kind === 'reply' ? pair.recipient : pair.sender;
|
|
305
294
|
// A peer that never opened a session has no ledger, so it holds no request to reply to.
|
|
306
|
-
if (ledger
|
|
295
|
+
if (!isFamilyRecord(ledger))
|
|
307
296
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
308
297
|
return ledger;
|
|
309
298
|
}
|
|
310
299
|
currentConversation(project, root) {
|
|
311
300
|
// A ledger whose history is being deleted is read as it stands: reconciliation would write to it.
|
|
312
|
-
if (root
|
|
313
|
-
return root
|
|
301
|
+
if (historyDeleting(root))
|
|
302
|
+
return conversationOf(root) ?? { messages: [], outcomes: [] };
|
|
314
303
|
const state = reconcileConversationState(root, (id) => project.store.getRun(id), new Date().toISOString(), run => run.delegation?.role === 'worker'
|
|
315
304
|
? project.store.readWorkerExecution(run.id)?.phase === 'complete' : !project.manager.isActive(run.id), id => project.store.isUnreadable(id));
|
|
316
|
-
if (
|
|
305
|
+
if (state && state !== conversationOf(root))
|
|
317
306
|
project.store.commitConversation(root.id, state);
|
|
318
307
|
return state ?? { messages: [], outcomes: [] };
|
|
319
308
|
}
|
|
320
309
|
conversationReceipt(project, ledgerId, message) {
|
|
321
310
|
const recipient = project.store.getRun(message.recipientRunId);
|
|
322
311
|
const input = recipient?.agentInputs?.find(input => input.id === message.id);
|
|
323
|
-
const
|
|
324
|
-
const state = ledger?.delegation?.role === 'root' ? ledger.delegation.conversation : undefined;
|
|
312
|
+
const state = conversationOf(project.store.getRun(ledgerId));
|
|
325
313
|
const outcome = state?.outcomes.find(outcome => outcome.requestId === (message.requestId ?? message.id));
|
|
326
314
|
return { message, delivery: input?.consumedAt ? 'consumed' : input?.deliveredAt ? 'delivered' : input ? 'queued' : 'not-delivered', ...(outcome ? { outcome } : {}) };
|
|
327
315
|
}
|
|
@@ -358,9 +346,9 @@ export class DelegationService {
|
|
|
358
346
|
const pair = this.conversationPair(caller, request.recipientRunId, true);
|
|
359
347
|
const { project, sender, recipient } = pair;
|
|
360
348
|
const root = this.ledgerFor(pair, request);
|
|
361
|
-
this.assertSendScope(pair,
|
|
362
|
-
if (pair.relationship === 'peer'
|
|
363
|
-
assertReplyDirection(sender
|
|
349
|
+
this.assertSendScope(pair, request);
|
|
350
|
+
if (pair.relationship === 'peer')
|
|
351
|
+
assertReplyDirection(conversationOf(sender) ?? { messages: [], outcomes: [] }, request, sender, recipient);
|
|
364
352
|
const requestHash = createHash('sha256').update(JSON.stringify({ senderRunId: sender.id, ...request })).digest('hex');
|
|
365
353
|
const state = this.currentConversation(project, root);
|
|
366
354
|
const existing = state.messages.find(message => message.id === request.id);
|
|
@@ -369,7 +357,7 @@ export class DelegationService {
|
|
|
369
357
|
assertNewPeerSend(pair, request);
|
|
370
358
|
const { original, settled } = sendRequestContext(state, request, sender, recipient);
|
|
371
359
|
const now = new Date().toISOString();
|
|
372
|
-
const { destroyed, resumable, resume, instruction } = sendAdmission(pair,
|
|
360
|
+
const { destroyed, resumable, resume, instruction } = sendAdmission(pair, request);
|
|
373
361
|
// A new continuation is new worker work: the parent's switch gates it (hearsay-tools/cezarion#2784).
|
|
374
362
|
if (resume)
|
|
375
363
|
requireWorkersAllowed(root);
|
|
@@ -400,10 +388,9 @@ export class DelegationService {
|
|
|
400
388
|
}
|
|
401
389
|
return { ...this.conversationReceipt(project, root.id, message), effect: enqueue ? conversationSendEffectSchema.enum.applied : conversationSendEffectSchema.enum.refused };
|
|
402
390
|
}
|
|
403
|
-
assertSendScope(pair,
|
|
404
|
-
const { project
|
|
405
|
-
|
|
406
|
-
if (request.resume && (peer || sender.id !== root.id || recipient.delegation?.role !== 'worker')) {
|
|
391
|
+
assertSendScope(pair, request) {
|
|
392
|
+
const { project } = pair;
|
|
393
|
+
if (request.resume && !(pair.relationship === 'family' && pair.relation === 'supervised')) {
|
|
407
394
|
throw new DelegationPolicyError('denied_scope', 'Only an active parent may use --resume for its owned worker');
|
|
408
395
|
}
|
|
409
396
|
if (project.store.containsSessionSecret(JSON.stringify(request)))
|
|
@@ -500,12 +487,12 @@ export class DelegationService {
|
|
|
500
487
|
const other = project.store.getRun(otherId);
|
|
501
488
|
if (!pair && !takesPart(self, other, otherId))
|
|
502
489
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
503
|
-
return { project, ledgers: [self, ...(other
|
|
490
|
+
return { project, ledgers: [self, ...(isFamilyRecord(other) ? [other] : [])], self: self.id, other: otherId };
|
|
504
491
|
}
|
|
505
492
|
async inbox(caller) {
|
|
506
493
|
const project = this.context(caller);
|
|
507
494
|
const run = project.store.getRun(caller.runId);
|
|
508
|
-
if (!run || (run.
|
|
495
|
+
if (!run || !grantsOf(run).message.length)
|
|
509
496
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
510
497
|
const selected = [];
|
|
511
498
|
let characters = 0;
|
|
@@ -545,14 +532,14 @@ export class DelegationService {
|
|
|
545
532
|
/** A peer input addressed to the caller: its participation is the whole check (spec § 2, two
|
|
546
533
|
* levels). When the sender's ledger went with its deletion, the input still carries the message. */
|
|
547
534
|
peerInboxEntry(project, run, input, ledgerState) {
|
|
548
|
-
if (run.
|
|
535
|
+
if (!grantsOf(run).message.includes('peer'))
|
|
549
536
|
return undefined;
|
|
550
537
|
const ledger = project.store.getRun(input.parentRunId);
|
|
551
538
|
if (!ledger) {
|
|
552
539
|
const message = orphanedPeerMessage(input);
|
|
553
540
|
return message && { message };
|
|
554
541
|
}
|
|
555
|
-
return ledger
|
|
542
|
+
return isFamilyRecord(ledger) ? inboxEntryIn(ledgerState(ledger), input, run.id) : undefined;
|
|
556
543
|
}
|
|
557
544
|
/** A family input: the pair must still be admitted, as before peers existed. */
|
|
558
545
|
familyInboxEntry(caller, run, input, ledgerState) {
|
|
@@ -607,8 +594,8 @@ export class DelegationService {
|
|
|
607
594
|
ownRequest(caller, requestId) {
|
|
608
595
|
const project = this.context(caller);
|
|
609
596
|
const sender = project.store.getRun(caller.runId);
|
|
610
|
-
const root = sender
|
|
611
|
-
const message = root?.
|
|
597
|
+
const root = familyRecordOf(sender, id => project.store.getRun(id));
|
|
598
|
+
const message = conversationOf(root)?.messages.find(message => message.id === requestId && message.kind === 'request' && message.state === 'accepted' && message.senderRunId === caller.runId);
|
|
612
599
|
if (!message)
|
|
613
600
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
614
601
|
if (message.relationship === 'peer')
|
|
@@ -660,15 +647,17 @@ export class DelegationService {
|
|
|
660
647
|
const project = this.context(caller);
|
|
661
648
|
const parent = project.store.getRun(caller.runId);
|
|
662
649
|
authorizeSpawnReplay(caller, parent, project.id);
|
|
663
|
-
|
|
650
|
+
const family = familyRecordOf(parent, id => project.store.getRun(id));
|
|
651
|
+
if (!family)
|
|
664
652
|
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
665
653
|
if (project.store.containsSessionSecret(JSON.stringify(request)))
|
|
666
654
|
throw new DelegationPolicyError('invalid_input', 'Credentials cannot be included in delegated input');
|
|
667
655
|
const requestHash = spawnRequestHash(request);
|
|
668
|
-
const replayed = replayedSpawn(project, parent, request.requestId, requestHash);
|
|
656
|
+
const replayed = replayedSpawn(project, family, parent, request.requestId, requestHash);
|
|
669
657
|
if (replayed)
|
|
670
658
|
return replayed;
|
|
671
|
-
|
|
659
|
+
const kindId = WORKSPACE_CHOICES[request.workspace ?? DEFAULT_WORKSPACE_CHOICE];
|
|
660
|
+
authorizeSpawn(caller, parent, project.id, id => project.store.getRun(id), kindId);
|
|
672
661
|
const catalog = await resolveSpawnWorkflow(project, request);
|
|
673
662
|
const resolvedSteps = await resolveSpawnSteps(project.manager, parent.id, request, catalog, (step, settings) => this.validateModels(request, [{ step, settings }]));
|
|
674
663
|
if (request.skill !== undefined) {
|
|
@@ -685,14 +674,14 @@ export class DelegationService {
|
|
|
685
674
|
const identity = acceptedWorkerIdentitySchema.parse({ kind: 'accepted', ...stepIdentityFields(first),
|
|
686
675
|
steps: resolvedSteps.map(entry => ({ stepId: entry.step.id, ...stepIdentityFields(entry) })) });
|
|
687
676
|
const baselineSha = await resolveWorkerBaseline(project.root, settings.cwd, request.baseline ?? 'parent-head');
|
|
688
|
-
const kind = workspaceKinds[
|
|
677
|
+
const kind = workspaceKinds[kindId];
|
|
689
678
|
const workspace = await kind.plan({ repoRoot: project.root, workerId: randomUUID(), baselineSha, hostRunId: parent.id, hostDirectory: settings.cwd });
|
|
690
679
|
const prepared = request.context === undefined ? undefined : await kind.prepareContext({
|
|
691
680
|
repoRoot: project.root, dataDir: projectPaths(project.root).write, parentId: parent.id, workspace,
|
|
692
681
|
parentCwd: settings.cwd, context: request.context, containsSecret: text => project.store.containsSessionSecret(text),
|
|
693
682
|
});
|
|
694
683
|
return acceptSpawnedWorker({
|
|
695
|
-
project, parent, request, catalog, resolvedSteps, settings, identity, workspace, baselineSha, requestHash, prepared,
|
|
684
|
+
project, parent, family, request, catalog, resolvedSteps, settings, identity, workspace, baselineSha, requestHash, prepared,
|
|
696
685
|
current: () => this.context(caller), caller,
|
|
697
686
|
});
|
|
698
687
|
});
|
|
@@ -701,16 +690,14 @@ export class DelegationService {
|
|
|
701
690
|
const project = this.context(caller);
|
|
702
691
|
const parent = project.store.getRun(caller.runId);
|
|
703
692
|
authorizeWorkerList(caller, parent, project.id);
|
|
704
|
-
|
|
705
|
-
throw new DelegationPolicyError('denied_scope', 'Worker scope denied');
|
|
693
|
+
const receipts = receiptsOf(familyRecordOf(parent, id => project.store.getRun(id)));
|
|
706
694
|
const workers = [];
|
|
707
695
|
const offset = Number(query.offset ?? 0);
|
|
708
|
-
const end = Math.min(offset + 32,
|
|
709
|
-
for (const receipt of
|
|
696
|
+
const end = Math.min(offset + 32, receipts.length);
|
|
697
|
+
for (const receipt of receipts.slice(offset, end)) {
|
|
710
698
|
const worker = project.store.getRun(receipt.workerId);
|
|
711
699
|
// Deleted histories have no resources to supervise. Never expose an unrelated receipt target.
|
|
712
|
-
if (worker?.delegation?.role !== 'worker' || worker
|
|
713
|
-
worker.delegation.workspace.ownerRunId !== worker.id)
|
|
700
|
+
if (worker?.delegation?.role !== 'worker' || relationOf(parent, worker) !== 'supervised')
|
|
714
701
|
continue;
|
|
715
702
|
const inspection = await this.inspect(caller, { workerId: worker.id });
|
|
716
703
|
workers.push({ workerId: inspection.workerId, parentRunId: inspection.parentRunId,
|
|
@@ -719,7 +706,7 @@ export class DelegationService {
|
|
|
719
706
|
settled: inspection.settled,
|
|
720
707
|
destroyed: worker.delegation.destroy?.phase === 'complete' });
|
|
721
708
|
}
|
|
722
|
-
return { workers, ...(end <
|
|
709
|
+
return { workers, ...(end < receipts.length ? { nextOffset: end } : {}) };
|
|
723
710
|
}
|
|
724
711
|
async inspect(caller, params) {
|
|
725
712
|
const { project, worker, parent } = this.target(caller, params, 'inspect');
|
|
@@ -728,7 +715,7 @@ export class DelegationService {
|
|
|
728
715
|
project.manager.settleOrphanedWorkerExecution(worker.id); // #469: an orphan that died after recovery settles
|
|
729
716
|
const outcome = workerOutcome(worker, new Date().toISOString());
|
|
730
717
|
const wait = this.inspectedWait(parent, worker.id);
|
|
731
|
-
const completion =
|
|
718
|
+
const completion = completionWaitEntry(parent.waits, worker.id);
|
|
732
719
|
const completionWait = completion ? workerCompletionWaitProjection(completion, parent) : undefined;
|
|
733
720
|
return { workerId: worker.id, parentRunId: parent.id, status: worker.status, workspace: worker.delegation.workspace,
|
|
734
721
|
settled: workerObservation(worker, project.store.readWorkerExecution(worker.id)).settled,
|
|
@@ -743,8 +730,6 @@ export class DelegationService {
|
|
|
743
730
|
* deadline, which that shape requires, so inspection shows it as `completionWait`
|
|
744
731
|
* (hearsay-tools/cezarion#1301). */
|
|
745
732
|
inspectedWait(parent, workerId) {
|
|
746
|
-
if (parent.delegation?.role !== 'root')
|
|
747
|
-
return undefined;
|
|
748
733
|
const entry = (parent.waits ?? []).filter((wait) => wait.kind === 'worker' && WAIT_KINDS.worker.hasDeadline(wait) && !!wait.workerIds?.includes(workerId)).at(-1);
|
|
749
734
|
return entry ? workerWaitEntryToLegacy(entry) : undefined;
|
|
750
735
|
}
|
|
@@ -762,7 +747,8 @@ export class DelegationService {
|
|
|
762
747
|
}
|
|
763
748
|
authorizeWorker(caller, worker, 'inspect', parent, project.id);
|
|
764
749
|
project.manager.settleOrphanedWorkerExecution(workerId); // #469: before `settled` is computed
|
|
765
|
-
|
|
750
|
+
const family = familyRecordOf(parent, id => project.store.getRun(id));
|
|
751
|
+
if (parent && receiptsOf(family).some(receipt => receipt.workerId === workerId && receipt.deletion?.phase === 'pending')) {
|
|
766
752
|
const retained = project.store.readWorkerResult(parent.id, workerId);
|
|
767
753
|
if (!retained || !project.store.canDeleteRun(workerId))
|
|
768
754
|
throw new DelegationPolicyError('incompatible_state', 'Worker history deletion evidence is unavailable');
|
|
@@ -811,21 +797,22 @@ export class DelegationService {
|
|
|
811
797
|
const { waitId } = workerCancelWaitRequestSchema.parse(value);
|
|
812
798
|
const project = this.context(caller);
|
|
813
799
|
const sender = project.store.getRun(caller.runId);
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
800
|
+
const entries = [...sender?.waits ?? [], ...sender?.lastWaits ?? []];
|
|
801
|
+
const supervisorId = supervisorIdOf(sender);
|
|
802
|
+
// hearsay-tools/cezarion#1235: a supervised task's request wait is a list entry, open or settled,
|
|
803
|
+
// and is checked through its supervisor pair whatever operate grant the task holds.
|
|
804
|
+
const wait = supervisorId === undefined ? undefined : entries.find(entry => entry.id === waitId && entry.kind === 'worker');
|
|
805
|
+
const requestIds = wait?.kind === 'worker' ? wait.requestIds ?? [] : [];
|
|
806
|
+
if (supervisorId !== undefined)
|
|
807
|
+
this.conversationPair(caller, supervisorId);
|
|
808
|
+
for (const requestId of requestIds)
|
|
809
|
+
this.ownRequest(caller, requestId);
|
|
810
|
+
// Any other wait is on workers or peers: the `wait` grant covers it.
|
|
811
|
+
if (!requestIds.length)
|
|
824
812
|
authorizeCancelWait(caller, sender, project.id);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
}
|
|
813
|
+
// A peer wait is cancelled through the list too (hearsay-tools/cezarion#1995).
|
|
814
|
+
if (entries.some(entry => entry.id === waitId && entry.kind === 'peer')) {
|
|
815
|
+
return { wait: peerWaitView(project.manager.cancelPeerWait(caller.runId, waitId)) };
|
|
829
816
|
}
|
|
830
817
|
return { wait: project.manager.cancelWorkerWait(caller.runId, waitId) };
|
|
831
818
|
}
|