@hearsay-tools/squawk 0.18.0-pr4178.8069 → 0.18.0-pr4179.8077

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/contract/conversations.d.ts +2 -0
  2. package/dist/contract/delegation.d.ts +57 -0
  3. package/dist/contract/index.js +187 -144
  4. package/dist/contract/run-predicates.d.ts +9 -0
  5. package/dist/contract/usage-limit-hold.d.ts +7 -0
  6. package/dist/contract/waits.d.ts +2 -2
  7. package/dist/delegation/cli.js +8 -4
  8. package/dist/delegation/cli.js.map +1 -1
  9. package/dist/delegation/conversation-send.js +15 -4
  10. package/dist/delegation/conversation-send.js.map +1 -1
  11. package/dist/delegation/conversations.js +6 -0
  12. package/dist/delegation/conversations.js.map +1 -1
  13. package/dist/delegation/execution-identity.d.ts +53 -9
  14. package/dist/delegation/execution-identity.js +165 -9
  15. package/dist/delegation/execution-identity.js.map +1 -1
  16. package/dist/delegation/park-notice.d.ts +29 -3
  17. package/dist/delegation/park-notice.js +32 -4
  18. package/dist/delegation/park-notice.js.map +1 -1
  19. package/dist/delegation/provision.js +3 -3
  20. package/dist/delegation/provision.js.map +1 -1
  21. package/dist/delegation/routes.d.ts +84 -65
  22. package/dist/delegation/service.d.ts +5 -0
  23. package/dist/delegation/service.js +93 -14
  24. package/dist/delegation/service.js.map +1 -1
  25. package/dist/delegation/transport.d.ts +23 -4
  26. package/dist/delegation/worker-executions.d.ts +2 -0
  27. package/dist/delegation/worker-executions.js +5 -1
  28. package/dist/delegation/worker-executions.js.map +1 -1
  29. package/dist/runs/ports.d.ts +2 -0
  30. package/dist/server/provider-action-gate.d.ts +8 -0
  31. package/dist/server/provider-action-gate.js +19 -2
  32. package/dist/server/provider-action-gate.js.map +1 -1
  33. package/dist/server/reports-api.d.ts +2 -2
  34. package/dist/server/run-accounts.d.ts +4 -3
  35. package/dist/server/run-accounts.js +20 -5
  36. package/dist/server/run-accounts.js.map +1 -1
  37. package/dist/server/server.d.ts +14 -0
  38. package/dist/server/server.js +3 -9
  39. package/dist/server/server.js.map +1 -1
  40. package/dist/workflows/continuation-admission.d.ts +7 -0
  41. package/dist/workflows/continuation-admission.js +21 -8
  42. package/dist/workflows/continuation-admission.js.map +1 -1
  43. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  44. package/dist/workflows/run/completion-gate.js +1 -1
  45. package/dist/workflows/run/completion-gate.js.map +1 -1
  46. package/dist/workflows/run/continuation-acceptance.d.ts +5 -1
  47. package/dist/workflows/run/continuation-acceptance.js +94 -29
  48. package/dist/workflows/run/continuation-acceptance.js.map +1 -1
  49. package/dist/workflows/run/family-reconciler.js +2 -2
  50. package/dist/workflows/run/family-reconciler.js.map +1 -1
  51. package/dist/workflows/run/launch-read-resolver.d.ts +6 -0
  52. package/dist/workflows/run/launch-read-resolver.js +13 -2
  53. package/dist/workflows/run/launch-read-resolver.js.map +1 -1
  54. package/dist/workflows/run/run-settlement.js +6 -0
  55. package/dist/workflows/run/run-settlement.js.map +1 -1
  56. package/dist/workflows/run/wait-engine.js +4 -1
  57. package/dist/workflows/run/wait-engine.js.map +1 -1
  58. package/dist/workflows/run/wake-admission.js +1 -1
  59. package/dist/workflows/run/wake-admission.js.map +1 -1
  60. package/dist/workflows/run/worker-questions.d.ts +4 -0
  61. package/dist/workflows/run/worker-questions.js +42 -8
  62. package/dist/workflows/run/worker-questions.js.map +1 -1
  63. package/dist/workflows/wait-scope.js +4 -1
  64. package/dist/workflows/wait-scope.js.map +1 -1
  65. package/package.json +4 -4
  66. package/web/dist/assets/{accounts-section-D3P_Z-Nu.js → accounts-section-BkKQ8sVH.js} +1 -1
  67. package/web/dist/assets/{activity-motion-BW-0k8s7.js → activity-motion-D80Uv4-Z.js} +1 -1
  68. package/web/dist/assets/{activity-route-Bpgblioe.js → activity-route-DVT8IWTR.js} +1 -1
  69. package/web/dist/assets/{agent-config-section-Cj3w7UIn.js → agent-config-section-BbwkJunW.js} +1 -1
  70. package/web/dist/assets/{agent-defaults-section-BJ4poe9c.js → agent-defaults-section-BLNTIZT_.js} +1 -1
  71. package/web/dist/assets/{appearance-BUsUTPF0.js → appearance-B6YBsmTo.js} +1 -1
  72. package/web/dist/assets/{archive-on-merge-field-D_kgBFNv.js → archive-on-merge-field-Bx1bEmI8.js} +1 -1
  73. package/web/dist/assets/attention-otQlgfRj.js +1 -0
  74. package/web/dist/assets/{automation-format-1lHzRTbq.js → automation-format-BsnXeUET.js} +1 -1
  75. package/web/dist/assets/automations-route-BOcGwfd4.js +1 -0
  76. package/web/dist/assets/{cez-idle-BY3rjM_y.js → cez-idle-Crszm9Ts.js} +1 -1
  77. package/web/dist/assets/{commit-diff-panel-xwLW6Ydr.js → commit-diff-panel-DKUnniap.js} +1 -1
  78. package/web/dist/assets/{diff-BB8SoL-s.js → diff-DUbLBjbg.js} +2 -2
  79. package/web/dist/assets/{diff-view-O8lx1ztb.js → diff-view-D_bjQyDl.js} +1 -1
  80. package/web/dist/assets/{file-preview-BS6M2tBo.js → file-preview-glEH09z8.js} +1 -1
  81. package/web/dist/assets/{folder-browser-Dsqz0Z1z.js → folder-browser-G_9ZgDjg.js} +1 -1
  82. package/web/dist/assets/{git-toolbar-DoPFA36c.js → git-toolbar-CTsmGICA.js} +1 -1
  83. package/web/dist/assets/{github-Bjy3WBvf.js → github-BqW9PaQO.js} +1 -1
  84. package/web/dist/assets/{global-activity-route-BXBZKz_9.js → global-activity-route-BP_Z7HNc.js} +1 -1
  85. package/web/dist/assets/index-DXIRYobS.js +21 -0
  86. package/web/dist/assets/{label-CZp8t0zE.js → label-BWld23ke.js} +1 -1
  87. package/web/dist/assets/live-protocol-BXzu6cSE.js +64 -0
  88. package/web/dist/assets/{markdown-KHcncamw.js → markdown-CT65TA_B.js} +1 -1
  89. package/web/dist/assets/{notifications-section-DD21Sd79.js → notifications-section-DuSzYLwP.js} +1 -1
  90. package/web/dist/assets/{open-in-menu-DdKs6X5r.js → open-in-menu-D03osLGE.js} +1 -1
  91. package/web/dist/assets/{preview-pane-connected-BvTZv2SQ.js → preview-pane-connected-DHmgDHId.js} +1 -1
  92. package/web/dist/assets/{project-location-B3LBvkz2.js → project-location-BM-6wMI3.js} +1 -1
  93. package/web/dist/assets/{project-router-CIKODSHW.js → project-router-DtTvMbeA.js} +1 -1
  94. package/web/dist/assets/project-scope-context-Dgq8_2JZ.js +4 -0
  95. package/web/dist/assets/{projects-section-C0k8kyb-.js → projects-section-Dr0xJWTm.js} +1 -1
  96. package/web/dist/assets/{prompt-templates-section-DNkosCni.js → prompt-templates-section-COKMgKMw.js} +1 -1
  97. package/web/dist/assets/queries-yuG-mM6_.js +1 -0
  98. package/web/dist/assets/{reference-chip-BWViAFIN.js → reference-chip-DTKtEtWv.js} +1 -1
  99. package/web/dist/assets/{remote-settings-notice-DPCENbhz.js → remote-settings-notice-BV_sPAXc.js} +1 -1
  100. package/web/dist/assets/{repo-git-jKOnO3ba.js → repo-git-BgXC4opq.js} +1 -1
  101. package/web/dist/assets/{report-reader-DXYiKNcg.js → report-reader-CtHvvSln.js} +1 -1
  102. package/web/dist/assets/{reports-DEE0bHNv.js → reports-CdbDUzkK.js} +1 -1
  103. package/web/dist/assets/{resources-section-lqXgYTrv.js → resources-section-C8KZ4hre.js} +1 -1
  104. package/web/dist/assets/{run-header-CXlUbvDO.js → run-header-RQYKdIMw.js} +1 -1
  105. package/web/dist/assets/runners-CDw7wLfd.js +1 -0
  106. package/web/dist/assets/{settings-agent-picker-BRvZn4kM.js → settings-agent-picker-3uuSf9LK.js} +1 -1
  107. package/web/dist/assets/{settings-shell-DTtd-vIa.js → settings-shell-DnYRfclU.js} +1 -1
  108. package/web/dist/assets/{sidebar-section-BFW4ZfBR.js → sidebar-section-CCg4QGtg.js} +1 -1
  109. package/web/dist/assets/{skills-AImMlT1T.js → skills-L01dfEnP.js} +1 -1
  110. package/web/dist/assets/{tab-link-CM6SDBtV.js → tab-link-Dl5Mmavw.js} +1 -1
  111. package/web/dist/assets/{task-changes-01Z_ppIw.js → task-changes-DWPWp6ZV.js} +1 -1
  112. package/web/dist/assets/{task-commits-DRNIum3J.js → task-commits-D576LERH.js} +1 -1
  113. package/web/dist/assets/{task-files-Crz7Fo3C.js → task-files-1EjplVVb.js} +1 -1
  114. package/web/dist/assets/{task-github-item-psG2V47c.js → task-github-item-BubKlTej.js} +1 -1
  115. package/web/dist/assets/task-groups-D4RYW5I_.js +1 -0
  116. package/web/dist/assets/task-thread-yWACZZAo.js +9 -0
  117. package/web/dist/assets/{tasks-table-DHTEGteC.js → tasks-table-DTNcYbbN.js} +1 -1
  118. package/web/dist/assets/{thread-state-BWJ2YyXo.js → thread-state-BiS8rKQ-.js} +1 -1
  119. package/web/dist/assets/{use-hand-to-agent-state-DNROQerR.js → use-hand-to-agent-state-BFx3SZia.js} +1 -1
  120. package/web/dist/assets/{useInfiniteQuery-qJeCNhM7.js → useInfiniteQuery-BnyaEFle.js} +1 -1
  121. package/web/dist/assets/useQuery-BUslvRIM.js +1 -0
  122. package/web/dist/assets/{workflows-Cx9lgrEo.js → workflows-DbuTPPz7.js} +1 -1
  123. package/web/dist/assets/{workspace-tools-CVitt3kE.js → workspace-tools-DPnEZoDL.js} +1 -1
  124. package/web/dist/assets/{worktrees-section-DxUg4l9n.js → worktrees-section-Vr8s9cio.js} +1 -1
  125. package/web/dist/assets/{ws-BisMp6U5.js → ws-Bal5BUy2.js} +1 -1
  126. package/web/dist/index.html +17 -17
  127. package/web/dist/live-worker.js +1 -1
  128. package/web/dist/assets/attention-lvUYNNvV.js +0 -1
  129. package/web/dist/assets/automations-route-CZaUrmDs.js +0 -1
  130. package/web/dist/assets/index-CmadQXcg.js +0 -21
  131. package/web/dist/assets/live-protocol-D9ji1YCl.js +0 -64
  132. package/web/dist/assets/project-scope-context-D1bpJixc.js +0 -4
  133. package/web/dist/assets/queries-dHXhD3Hc.js +0 -1
  134. package/web/dist/assets/runners-CGQjSsir.js +0 -1
  135. package/web/dist/assets/task-groups-DF0XoB6U.js +0 -1
  136. package/web/dist/assets/task-thread-Bqg91ZVZ.js +0 -9
  137. package/web/dist/assets/useQuery-C3CQhXsT.js +0 -1
@@ -27,18 +27,6 @@ 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
- } | {
42
30
  output: {
43
31
  workers: {
44
32
  workerId: string;
@@ -60,6 +48,12 @@ export declare function createDelegationRoutes(service: DelegationService, crede
60
48
  hostRunId: string;
61
49
  baselineSha: string;
62
50
  };
51
+ hold?: {
52
+ reason: "provider-error" | "usage-limit";
53
+ resumeAt: string;
54
+ attempts?: number | undefined;
55
+ error?: string | undefined;
56
+ } | undefined;
63
57
  destroy?: {
64
58
  requestedAt: string;
65
59
  phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
@@ -85,6 +79,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
85
79
  offset?: string | undefined;
86
80
  };
87
81
  };
82
+ } | {
83
+ output: {
84
+ error: string;
85
+ code?: "invalid_input" | undefined;
86
+ };
87
+ outputFormat: "json";
88
+ status: 400;
89
+ input: {
90
+ query: {
91
+ offset?: string | undefined;
92
+ };
93
+ };
88
94
  };
89
95
  };
90
96
  } & {
@@ -357,6 +363,8 @@ export declare function createDelegationRoutes(service: DelegationService, crede
357
363
  text: string;
358
364
  timeoutSeconds?: number | undefined;
359
365
  resume?: boolean | undefined;
366
+ model?: string | undefined;
367
+ effort?: string | undefined;
360
368
  };
361
369
  };
362
370
  };
@@ -414,6 +422,8 @@ export declare function createDelegationRoutes(service: DelegationService, crede
414
422
  text: string;
415
423
  timeoutSeconds?: number | undefined;
416
424
  resume?: boolean | undefined;
425
+ model?: string | undefined;
426
+ effort?: string | undefined;
417
427
  };
418
428
  };
419
429
  };
@@ -471,6 +481,8 @@ export declare function createDelegationRoutes(service: DelegationService, crede
471
481
  text: string;
472
482
  timeoutSeconds?: number | undefined;
473
483
  resume?: boolean | undefined;
484
+ model?: string | undefined;
485
+ effort?: string | undefined;
474
486
  };
475
487
  };
476
488
  };
@@ -629,18 +641,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
629
641
  } & {
630
642
  "/:workerId": {
631
643
  $get: {
632
- output: {
633
- error: string;
634
- code?: "invalid_input" | undefined;
635
- };
636
- outputFormat: "json";
637
- status: 400;
638
- input: {
639
- param: {
640
- workerId: string;
641
- };
642
- };
643
- } | {
644
644
  output: {
645
645
  workerId: string;
646
646
  settled: boolean;
@@ -665,6 +665,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
665
665
  };
666
666
  backend?: string | undefined;
667
667
  model?: string | undefined;
668
+ effort?: string | undefined;
669
+ hold?: {
670
+ reason: "provider-error" | "usage-limit";
671
+ resumeAt: string;
672
+ attempts?: number | undefined;
673
+ error?: string | undefined;
674
+ } | undefined;
668
675
  inputs?: {
669
676
  source: {
670
677
  kind: "parent-file";
@@ -758,11 +765,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
758
765
  workerId: string;
759
766
  };
760
767
  };
761
- };
762
- };
763
- } & {
764
- "/:workerId/collect": {
765
- $post: {
768
+ } | {
766
769
  output: {
767
770
  error: string;
768
771
  code?: "invalid_input" | undefined;
@@ -773,10 +776,12 @@ export declare function createDelegationRoutes(service: DelegationService, crede
773
776
  param: {
774
777
  workerId: string;
775
778
  };
776
- } & {
777
- json: Record<string, never>;
778
779
  };
779
- } | {
780
+ };
781
+ };
782
+ } & {
783
+ "/:workerId/collect": {
784
+ $post: {
780
785
  output: {
781
786
  workerId: string;
782
787
  parentRunId: string;
@@ -899,11 +904,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
899
904
  } & {
900
905
  json: Record<string, never>;
901
906
  };
902
- };
903
- };
904
- } & {
905
- "/:workerId/steer": {
906
- $post: {
907
+ } | {
907
908
  output: {
908
909
  error: string;
909
910
  code?: "invalid_input" | undefined;
@@ -915,11 +916,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
915
916
  workerId: string;
916
917
  };
917
918
  } & {
918
- json: {
919
- text: string;
920
- };
919
+ json: Record<string, never>;
921
920
  };
922
- } | {
921
+ };
922
+ };
923
+ } & {
924
+ "/:workerId/steer": {
925
+ $post: {
923
926
  output: {
924
927
  workerId: string;
925
928
  state: "delivered" | "queued";
@@ -935,11 +938,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
935
938
  text: string;
936
939
  };
937
940
  };
938
- };
939
- };
940
- } & {
941
- "/:workerId/stop": {
942
- $post: {
941
+ } | {
943
942
  output: {
944
943
  error: string;
945
944
  code?: "invalid_input" | undefined;
@@ -951,9 +950,15 @@ export declare function createDelegationRoutes(service: DelegationService, crede
951
950
  workerId: string;
952
951
  };
953
952
  } & {
954
- json: Record<string, never>;
953
+ json: {
954
+ text: string;
955
+ };
955
956
  };
956
- } | {
957
+ };
958
+ };
959
+ } & {
960
+ "/:workerId/stop": {
961
+ $post: {
957
962
  output: {
958
963
  workerId: string;
959
964
  state: "stopping" | "terminated";
@@ -967,11 +972,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
967
972
  } & {
968
973
  json: Record<string, never>;
969
974
  };
970
- };
971
- };
972
- } & {
973
- "/:workerId/destroy": {
974
- $post: {
975
+ } | {
975
976
  output: {
976
977
  error: string;
977
978
  code?: "invalid_input" | undefined;
@@ -983,11 +984,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
983
984
  workerId: string;
984
985
  };
985
986
  } & {
986
- json: {
987
- discardWork?: true | undefined;
988
- };
987
+ json: Record<string, never>;
989
988
  };
990
- } | {
989
+ };
990
+ };
991
+ } & {
992
+ "/:workerId/destroy": {
993
+ $post: {
991
994
  output: {
992
995
  workerId: string;
993
996
  state: "complete" | "incomplete";
@@ -1016,6 +1019,22 @@ export declare function createDelegationRoutes(service: DelegationService, crede
1016
1019
  discardWork?: true | undefined;
1017
1020
  };
1018
1021
  };
1022
+ } | {
1023
+ output: {
1024
+ error: string;
1025
+ code?: "invalid_input" | undefined;
1026
+ };
1027
+ outputFormat: "json";
1028
+ status: 400;
1029
+ input: {
1030
+ param: {
1031
+ workerId: string;
1032
+ };
1033
+ } & {
1034
+ json: {
1035
+ discardWork?: true | undefined;
1036
+ };
1037
+ };
1019
1038
  } | {
1020
1039
  output: {
1021
1040
  workerId: string;
@@ -1051,11 +1070,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
1051
1070
  "/:workerId/diff": {
1052
1071
  $get: {
1053
1072
  output: {
1054
- error: string;
1055
- code?: "invalid_input" | undefined;
1073
+ workerId: string;
1074
+ baselineSha: string;
1075
+ diff: string;
1076
+ truncated: boolean;
1056
1077
  };
1057
1078
  outputFormat: "json";
1058
- status: 400;
1079
+ status: 200;
1059
1080
  input: {
1060
1081
  param: {
1061
1082
  workerId: string;
@@ -1063,13 +1084,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
1063
1084
  };
1064
1085
  } | {
1065
1086
  output: {
1066
- workerId: string;
1067
- baselineSha: string;
1068
- diff: string;
1069
- truncated: boolean;
1087
+ error: string;
1088
+ code?: "invalid_input" | undefined;
1070
1089
  };
1071
1090
  outputFormat: "json";
1072
- status: 200;
1091
+ status: 400;
1073
1092
  input: {
1074
1093
  param: {
1075
1094
  workerId: string;
@@ -35,6 +35,7 @@ export declare class DelegationService {
35
35
  private discovery?;
36
36
  setDiscovery(discovery: HostDiscovery): void;
37
37
  discover(caller: Caller, value: DiscoveryRequest): Promise<DiscoveryResponse>;
38
+ private assertCatalogModel;
38
39
  private validateModels;
39
40
  private projects;
40
41
  private serial;
@@ -64,6 +65,10 @@ export declare class DelegationService {
64
65
  /** A cancelled or session-less worker restarts from its worktree and branch (hearsay-tools/squawk#3337),
65
66
  * so --resume proves both still exist before anything is accepted. */
66
67
  private assertResumableWorkspace;
68
+ /** Validate and normalize same-runner `--model` / `--effort` overrides on `worker resume`. */
69
+ private resolveResumeOverrides;
70
+ private resumeStepTarget;
71
+ private validateResumeModel;
67
72
  /** Runs entirely under the ledger lock; mutable records are read at the queue head. */
68
73
  private sendLocked;
69
74
  private assertSendScope;
@@ -1,6 +1,7 @@
1
1
  import { spawnCapacityRefusal } from './capacity.js';
2
2
  import { commandText } from '../home/command.js';
3
3
  import { WAIT_KINDS } from '../workflows/run/wait-kinds.js';
4
+ import { isUntouchedCancelledRun } from '../workflows/run/run-guards.js';
4
5
  import { projectPaths } from '../project-paths.js';
5
6
  import { assertReplyDirection, sendRequestContext, sendAdmission, sendMessage, sendInput } from './conversation-send.js';
6
7
  import { discoverTasks } from './task-discovery.js';
@@ -10,7 +11,14 @@ export { rootDelegation } from './conversations.js';
10
11
  import { collectWorkerEvidence, revalidateRetainedWorkerResult, workerRevision } from './results.js';
11
12
  import { workerContextTask } from './context.js';
12
13
  import { workerExecutionsOf } from './worker-executions.js';
13
- import { acceptedWorkerIdentitySchema, workerContextHash, workerWorkflowHash } from './execution-identity.js';
14
+ import { acceptedWorkerIdentitySchema, boundWorkerAccountEnv, continuationDefStep, workerContextHash, workerIdentity, workerStepIdentity, workerWorkflowHash } from './execution-identity.js';
15
+ import { latestSessionStep, workerContinuationStep } from '../contract/index.js';
16
+ import { isUsageLimitHold, usageLimitHoldOf } from '../contract/index.js';
17
+ import { AGENT_MODELS_LOCKED_ERROR, agentModelsLocked } from '../core/agent-model-policy.js';
18
+ import { buildChildEnv } from '../core/agent-env.js';
19
+ import { readAgentModelSettings } from '../agent-config/models.js';
20
+ import { formatModelIdentity, normalizeModelForBackend } from '../core/model-identity.js';
21
+ import { modelConflictsWithRunner } from '../core/model-presets.js';
14
22
  import { createHash, randomUUID } from 'node:crypto';
15
23
  import { discoveryRequestSchema, } from '../contract/index.js';
16
24
  import { CONVERSATION_PAGE_MESSAGES, conversationSendEffectSchema, decodeConversationCursor, encodeConversationCursor, conversationSendRequestSchema, conversationInspectRequestSchema, conversationCancelRequestSchema, inboxReceiptRequestSchema, requestWaitRequestSchema, } from '../contract/index.js';
@@ -192,6 +200,17 @@ export class DelegationService {
192
200
  throw new DelegationPolicyError('unavailable_transport', 'Host discovery is unavailable');
193
201
  return request.kind === 'models' ? this.discovery.models.get(registeredRunnerId(request.runner)) : discoveredRunners(await this.discovery.providers());
194
202
  }
203
+ async assertCatalogModel(runner, model, backendModel, modelIdentity) {
204
+ if (!this.discovery)
205
+ return;
206
+ const choices = await missingModelChoices(this.discovery, runner, model, backendModel, modelIdentity);
207
+ if (!choices)
208
+ return;
209
+ const alternatives = choices.otherRunners.join(', ') || 'none';
210
+ const available = choices.availableModels.map(row => `${row.id}${row.effortLevels ? ` (effort: ${row.effortLevels.join(', ') || 'none advertised'})` : ''}`).join('; ');
211
+ // Full choices remain structured even when the human-readable error reaches its bound.
212
+ throw new DelegationPolicyError('invalid_input', `Model "${model}" is not in the ${runner} catalog. Available models: ${available.slice(0, 1200)}. Other runners listing "${model}": ${alternatives}. ${commandText(`Use cez discover models --runner=${runner}.`)}`, choices);
213
+ }
195
214
  async validateModels(request, resolved) {
196
215
  if (!this.discovery)
197
216
  return;
@@ -208,13 +227,7 @@ export class DelegationService {
208
227
  if (checked.has(key))
209
228
  continue;
210
229
  checked.add(key);
211
- const choices = await missingModelChoices(this.discovery, runner, model, settings.model, settings.modelIdentity);
212
- if (!choices)
213
- continue;
214
- const alternatives = choices.otherRunners.join(', ') || 'none';
215
- const available = choices.availableModels.map(row => `${row.id}${row.effortLevels ? ` (effort: ${row.effortLevels.join(', ') || 'none advertised'})` : ''}`).join('; ');
216
- // Full choices remain structured even when the human-readable error reaches its bound.
217
- throw new DelegationPolicyError('invalid_input', `Model "${model}" is not in the ${runner} catalog. Available models: ${available.slice(0, 1200)}. Other runners listing "${model}": ${alternatives}. ${commandText(`Use cez discover models --runner=${runner}.`)}`, choices);
230
+ await this.assertCatalogModel(runner, model, settings.model, settings.modelIdentity);
218
231
  }
219
232
  }
220
233
  projects = new Map();
@@ -329,7 +342,8 @@ export class DelegationService {
329
342
  return this.serialized(`conversation:${initial.project.id}:${this.ledgerFor(initial, request).id}`, async () => {
330
343
  if (request.resume)
331
344
  await this.assertResumableWorkspace(caller, request);
332
- return this.sendLocked(caller, request);
345
+ const resumeOverrides = request.resume ? await this.resolveResumeOverrides(caller, request) : undefined;
346
+ return this.sendLocked(caller, request, resumeOverrides);
333
347
  });
334
348
  }
335
349
  /** A cancelled or session-less worker restarts from its worktree and branch (hearsay-tools/squawk#3337),
@@ -342,7 +356,7 @@ export class DelegationService {
342
356
  return;
343
357
  if (recipient.delegation?.role !== 'worker' || recipient.delegation.destroy || !freshWorkerSession(recipient) && recipient.status !== 'cancelled')
344
358
  return;
345
- if (['queued', 'running', 'waiting'].includes(recipient.status))
359
+ if (['queued', 'running', 'waiting'].includes(recipient.status) && !isUsageLimitHold(recipient))
346
360
  return;
347
361
  try {
348
362
  await workspaceKindOf(recipient).assertResumable(project.root, recipient);
@@ -351,8 +365,64 @@ export class DelegationService {
351
365
  throw new DelegationPolicyError('incompatible_state', `Worker worktree or branch is gone (${error instanceof Error ? error.message : String(error)}); --resume cannot restart it. Spawn a new worker with the follow-up instruction`);
352
366
  }
353
367
  }
368
+ /** Validate and normalize same-runner `--model` / `--effort` overrides on `worker resume`. */
369
+ async resolveResumeOverrides(caller, request) {
370
+ if (request.model === undefined && request.effort === undefined)
371
+ return undefined;
372
+ const pair = this.conversationPair(caller, request.recipientRunId, true);
373
+ const { project, recipient } = pair;
374
+ const root = this.ledgerFor(pair, request);
375
+ if (this.currentConversation(project, root).messages.some(message => message.id === request.id))
376
+ return undefined;
377
+ this.assertSendScope(pair, request);
378
+ sendAdmission(pair, request);
379
+ const effortPin = parseDelegationEffort(request.effort);
380
+ if (agentModelsLocked(project.root, process.env, project.home) && (request.model !== undefined || effortPin !== undefined)) {
381
+ throw new DelegationPolicyError('invalid_input', AGENT_MODELS_LOCKED_ERROR);
382
+ }
383
+ const model = request.model === undefined ? undefined : await this.validateResumeModel(project, recipient, request.model);
384
+ return { ...(model === undefined ? {} : { model }), ...(request.effort === undefined ? {} : { effort: effortPin ?? '' }) };
385
+ }
386
+ resumeStepTarget(project, recipient) {
387
+ const untouched = isUntouchedCancelledRun(recipient);
388
+ const sessionId = latestSessionStep(recipient.steps)?.sessionId;
389
+ const stepId = continuationDefStep(project.store, recipient, sessionId, untouched)?.id;
390
+ try {
391
+ const identity = workerIdentity(project.store, project.root, recipient.id, stepId, project.home);
392
+ const stepIdentity = identity ? (stepId === undefined ? identity : workerStepIdentity(identity, stepId)) : undefined;
393
+ const runner = stepIdentity?.account.provider ?? recipient.runner;
394
+ if (!runner)
395
+ throw new DelegationPolicyError('incompatible_state', 'Worker runner identity is unavailable');
396
+ const baseEnv = buildChildEnv({ backend: runner });
397
+ const env = stepIdentity ? { ...baseEnv, ...boundWorkerAccountEnv(stepIdentity.account, baseEnv) } : baseEnv;
398
+ return { runner, profileId: stepIdentity?.account.profileId ?? recipient.agentProfile ?? 'default', env };
399
+ }
400
+ catch (error) {
401
+ if (error instanceof DelegationPolicyError)
402
+ throw error;
403
+ throw new DelegationPolicyError('incompatible_state', error instanceof Error ? error.message : 'Worker execution identity is unavailable');
404
+ }
405
+ }
406
+ async validateResumeModel(project, recipient, requested) {
407
+ const { runner, profileId, env } = this.resumeStepTarget(project, recipient);
408
+ const native = await readAgentModelSettings(runner, project.root, env);
409
+ let normalized;
410
+ try {
411
+ normalized = normalizeModelForBackend(runner, requested, { configuredProvider: native.provider });
412
+ }
413
+ catch (error) {
414
+ throw new DelegationPolicyError('invalid_input', error instanceof Error ? error.message : 'Invalid model');
415
+ }
416
+ if (profileId === 'default') {
417
+ await this.assertCatalogModel(runner, requested, normalized?.backendModel, normalized ? formatModelIdentity(normalized.identity) : undefined);
418
+ }
419
+ if (modelConflictsWithRunner(requested, runner)) {
420
+ throw new DelegationPolicyError('invalid_input', `Model "${requested}" is incompatible with ${runner}`);
421
+ }
422
+ return normalized?.backendModel ?? requested;
423
+ }
354
424
  /** Runs entirely under the ledger lock; mutable records are read at the queue head. */
355
- sendLocked(caller, request) {
425
+ sendLocked(caller, request, resumeOverrides) {
356
426
  const pair = this.conversationPair(caller, request.recipientRunId, true);
357
427
  const { project, sender, recipient } = pair;
358
428
  const root = this.ledgerFor(pair, request);
@@ -386,7 +456,7 @@ export class DelegationService {
386
456
  const outcomes = replyOutcomes(state, request, settled, now);
387
457
  const input = sendInput(pair, root, message, requestHash, now);
388
458
  const next = { messages: [...state.messages, message], outcomes };
389
- this.commitSend(pair, root, next, input, resume, enqueue);
459
+ this.commitSend(pair, root, next, input, resume, enqueue, resumeOverrides);
390
460
  try {
391
461
  projectConversationEvents(project.store, project.store.getRun(root.id));
392
462
  project.manager.reconcileWorkerWaits();
@@ -421,7 +491,7 @@ export class DelegationService {
421
491
  }
422
492
  return { ...this.conversationReceipt(project, root.id, existing), effect: conversationSendEffectSchema.enum.unchanged };
423
493
  }
424
- commitSend(pair, root, next, input, resume, enqueue) {
494
+ commitSend(pair, root, next, input, resume, enqueue, resumeOverrides) {
425
495
  const { project, recipient, relationship } = pair;
426
496
  const peer = relationship === 'peer';
427
497
  if (resume) {
@@ -436,6 +506,8 @@ export class DelegationService {
436
506
  const fresh = freshWorkerSession(recipient) ? `${FRESH_SESSION_NOTICE}\n` : '';
437
507
  const result = project.manager.continueRun(recipient.id, {
438
508
  text: `Your parent resumed this worker with a new instruction.\n${fresh}Agent conversation ${JSON.stringify({ id: input.id, ...input.conversation })}\n${input.text}`,
509
+ ...(resumeOverrides?.model === undefined ? {} : { model: resumeOverrides.model }),
510
+ ...(resumeOverrides?.effort === undefined ? {} : { effort: resumeOverrides.effort }),
439
511
  }, true, { rootId: root.id, state: next, input });
440
512
  if (!result.ok)
441
513
  throw new DelegationPolicyError('incompatible_state', `Worker was not resumed: ${result.error}. No message was accepted; ${result.next ?? 'resolve this condition and retry the same command'}`);
@@ -718,6 +790,7 @@ export class DelegationService {
718
790
  workers.push({ workerId: inspection.workerId, parentRunId: inspection.parentRunId,
719
791
  ...(inspection.supervisorRunId === undefined ? {} : { supervisorRunId: inspection.supervisorRunId }),
720
792
  status: inspection.status, workspace: inspection.workspace,
793
+ ...(inspection.hold ? { hold: inspection.hold } : {}),
721
794
  ...(inspection.destroy ? { destroy: inspection.destroy } : {}), revision: workerRevision(worker),
722
795
  settled: inspection.settled,
723
796
  destroyed: worker.delegation.destroy?.phase === 'complete' });
@@ -733,11 +806,17 @@ export class DelegationService {
733
806
  const wait = this.inspectedWait(parent, worker.id);
734
807
  const completion = completionWaitEntry(parent.waits, worker.id);
735
808
  const completionWait = completion ? workerCompletionWaitProjection(completion, parent) : undefined;
809
+ const hold = usageLimitHoldOf(worker);
810
+ const activeStep = workerContinuationStep(worker, isUntouchedCancelledRun(worker));
811
+ const backend = activeStep?.runner ?? worker.runner;
812
+ const model = activeStep ? activeStep.model : worker.model;
813
+ const effort = activeStep ? activeStep.effort : worker.effort;
736
814
  return { workerId: worker.id, parentRunId: worker.delegation.parentRunId,
737
815
  ...(worker.delegation.supervisorRunId === undefined ? {} : { supervisorRunId: worker.delegation.supervisorRunId }),
738
816
  status: worker.status, workspace: worker.delegation.workspace,
739
817
  settled: workerObservation(worker, project.store.workerExecutions.readWorkerExecution(worker.id)).settled,
740
- ...(worker.runner === undefined ? {} : { backend: worker.runner }), ...(worker.model === undefined ? {} : { model: worker.model }),
818
+ ...(backend === undefined ? {} : { backend }), ...(model === undefined ? {} : { model }),
819
+ ...(effort === undefined ? {} : { effort }), ...(hold ? { hold } : {}),
741
820
  ...(worker.delegation.context === undefined ? {} : { inputs: worker.delegation.context.inputs }),
742
821
  ...(worker.currentStepId === undefined ? {} : { currentStepId: worker.currentStepId }),
743
822
  ...(wait ? { wait } : {}), ...(completionWait ? { completionWait } : {}), ...(worker.delegation.destroy ? { destroy: workerDestroyView(worker) } : {}), ...(outcome ? { outcome } : {}),