@sema-agent/core 7.58.0 → 7.59.0

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 (284) hide show
  1. package/CHANGELOG.md +776 -0
  2. package/README.md +6 -4
  3. package/dist/agents/cc-peer-directory.js +8 -8
  4. package/dist/agents/child-model-seat.d.ts +4 -2
  5. package/dist/agents/child-model-seat.js +5 -3
  6. package/dist/agents/peer-directory.d.ts +9 -0
  7. package/dist/agents/peer-directory.js +6 -2
  8. package/dist/agents/send-message-tool.js +21 -12
  9. package/dist/agents/subagent.js +33 -34
  10. package/dist/brain/anthropic.js +161 -45
  11. package/dist/brain/errors.d.ts +9 -3
  12. package/dist/brain/errors.js +7 -1
  13. package/dist/brain/failover.js +2 -1
  14. package/dist/brain/open-responses.js +3 -3
  15. package/dist/brain/openai.js +103 -53
  16. package/dist/brain/provider-dialect.d.ts +11 -0
  17. package/dist/brain/provider-dialect.js +5 -2
  18. package/dist/brain/reasoning-request.js +5 -4
  19. package/dist/brain/reasoning.d.ts +19 -0
  20. package/dist/brain/reasoning.js +17 -2
  21. package/dist/brain/request-route.d.ts +4 -1
  22. package/dist/brain/request-route.js +4 -1
  23. package/dist/brain/route-adjudicator.d.ts +84 -18
  24. package/dist/brain/route-adjudicator.js +87 -21
  25. package/dist/brain/route-conformance.js +1 -1
  26. package/dist/brain/stream-engine.js +84 -49
  27. package/dist/brain/stream-shared.d.ts +30 -0
  28. package/dist/brain/stream-shared.js +34 -1
  29. package/dist/brain/timeout.d.ts +62 -5
  30. package/dist/brain/timeout.js +93 -6
  31. package/dist/core/account-row.d.ts +61 -0
  32. package/dist/core/account-row.js +51 -0
  33. package/dist/core/advisor-verdict.d.ts +2 -1
  34. package/dist/core/advisor-verdict.js +1 -1
  35. package/dist/core/allow-entry.d.ts +18 -6
  36. package/dist/core/allow-entry.js +16 -8
  37. package/dist/core/approval-object.d.ts +29 -15
  38. package/dist/core/approval-object.js +47 -19
  39. package/dist/core/auto-compaction.js +1 -1
  40. package/dist/core/background-agent-store.d.ts +16 -3
  41. package/dist/core/checkpoint-requirements.d.ts +13 -1
  42. package/dist/core/checkpoint-requirements.js +3 -1
  43. package/dist/core/checkpoint-store.d.ts +58 -12
  44. package/dist/core/checkpoint-store.js +18 -6
  45. package/dist/core/child-clamp-seats.d.ts +29 -0
  46. package/dist/core/child-clamp-seats.js +56 -1
  47. package/dist/core/compliance.d.ts +2 -2
  48. package/dist/core/compliance.js +1 -1
  49. package/dist/core/effective-path-target.d.ts +8 -2
  50. package/dist/core/effective-path-target.js +8 -3
  51. package/dist/core/engine-notice.d.ts +98 -8
  52. package/dist/core/engine-notice.js +19 -5
  53. package/dist/core/gate-fold.js +1 -1
  54. package/dist/core/gate-lanes.js +8 -4
  55. package/dist/core/gate-outcome.d.ts +32 -3
  56. package/dist/core/gate-outcome.js +19 -1
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +13 -0
  59. package/dist/core/hooks.d.ts +31 -3
  60. package/dist/core/hooks.js +5 -6
  61. package/dist/core/image-admission.d.ts +6 -5
  62. package/dist/core/image-admission.js +18 -14
  63. package/dist/core/locked-config.d.ts +5 -2
  64. package/dist/core/locked-config.js +2 -1
  65. package/dist/core/mailbox-store.d.ts +45 -1
  66. package/dist/core/mailbox-store.js +53 -9
  67. package/dist/core/mcp-failure.d.ts +114 -18
  68. package/dist/core/mcp-failure.js +63 -5
  69. package/dist/core/mcp-server-link.d.ts +22 -1
  70. package/dist/core/mcp-server-link.js +25 -1
  71. package/dist/core/mcp.d.ts +12 -8
  72. package/dist/core/mcp.js +42 -25
  73. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  74. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  75. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  76. package/dist/core/memory-engine/consolidation.js +1 -0
  77. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  78. package/dist/core/memory-engine/distiller.js +2 -2
  79. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  80. package/dist/core/memory-engine/dual-root.js +44 -1
  81. package/dist/core/memory-engine/engine.d.ts +67 -14
  82. package/dist/core/memory-engine/engine.js +384 -212
  83. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  84. package/dist/core/memory-engine/export-bundle.js +23 -4
  85. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  86. package/dist/core/memory-engine/file-backend.js +290 -117
  87. package/dist/core/memory-engine/index.d.ts +1 -1
  88. package/dist/core/memory-engine/layout.d.ts +59 -11
  89. package/dist/core/memory-engine/layout.js +190 -40
  90. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  91. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  92. package/dist/core/memory-engine/sync-client.d.ts +9 -1
  93. package/dist/core/memory-engine/sync-client.js +31 -8
  94. package/dist/core/memory-engine/sync.d.ts +5 -0
  95. package/dist/core/memory-engine/types.d.ts +6 -0
  96. package/dist/core/mods/classic-events.d.ts +5 -1
  97. package/dist/core/mods/kernel/dispatch.js +2 -1
  98. package/dist/core/mods/kernel/events.d.ts +2 -1
  99. package/dist/core/mods/kernel/events.js +2 -2
  100. package/dist/core/mods/kernel/registration.d.ts +4 -0
  101. package/dist/core/mods/kernel/registration.js +3 -0
  102. package/dist/core/mods/stations.d.ts +31 -10
  103. package/dist/core/mods/stations.js +44 -10
  104. package/dist/core/mods/tool-call.js +1 -1
  105. package/dist/core/parent-spec-seat.d.ts +8 -3
  106. package/dist/core/parent-spec-seat.js +2 -0
  107. package/dist/core/park-selfcheck.js +6 -0
  108. package/dist/core/peer-seat.d.ts +70 -8
  109. package/dist/core/peer-seat.js +143 -11
  110. package/dist/core/permission-rule-consent.js +10 -4
  111. package/dist/core/permission-rule-model.d.ts +16 -0
  112. package/dist/core/permission-rule-model.js +1 -1
  113. package/dist/core/present-plan-tool.d.ts +11 -3
  114. package/dist/core/present-plan-tool.js +2 -2
  115. package/dist/core/resume-startup-cause.js +1 -0
  116. package/dist/core/rewrite-rejudge.d.ts +1 -0
  117. package/dist/core/rewrite-rejudge.js +2 -2
  118. package/dist/core/roles.d.ts +34 -2
  119. package/dist/core/roles.js +43 -4
  120. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  121. package/dist/core/runner/announce-once-ledger.js +4 -2
  122. package/dist/core/runner/call-hook-stations.js +2 -2
  123. package/dist/core/runner/contracts.d.ts +20 -16
  124. package/dist/core/runner/credential-origin-seat.js +4 -3
  125. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  126. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  127. package/dist/core/runner/decide-continuation.d.ts +2 -2
  128. package/dist/core/runner/gate-exit.d.ts +12 -4
  129. package/dist/core/runner/gate-exit.js +10 -7
  130. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  131. package/dist/core/runner/image-removed-seat.js +19 -0
  132. package/dist/core/runner/inline-image.js +1 -1
  133. package/dist/core/runner/memory-consolidation-driver.js +3 -3
  134. package/dist/core/runner/park-commit.d.ts +1 -1
  135. package/dist/core/runner/park-commit.js +3 -0
  136. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  137. package/dist/core/runner/prepare-ask-lane.js +2 -1
  138. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  139. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
  140. package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
  141. package/dist/core/runner/prepare-config-doors.js +2 -0
  142. package/dist/core/runner/prepare-context-lane.js +2 -0
  143. package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
  144. package/dist/core/runner/prepare-delegation-surface.js +1 -0
  145. package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
  146. package/dist/core/runner/prepare-hands-readface.js +5 -0
  147. package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
  148. package/dist/core/runner/prepare-inherited-gate.js +14 -27
  149. package/dist/core/runner/prepare-memory.js +10 -17
  150. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  151. package/dist/core/runner/prepare-park-ask.js +2 -1
  152. package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
  153. package/dist/core/runner/prepare-policy-chain.js +16 -13
  154. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  155. package/dist/core/runner/prepare-project-context.js +2 -2
  156. package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
  157. package/dist/core/runner/prepare-prompt-inputs.js +8 -19
  158. package/dist/core/runner/prepare-protocol-tools.js +9 -1
  159. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  160. package/dist/core/runner/prepare-run-refs.js +4 -1
  161. package/dist/core/runner/prepare-task.js +4 -2
  162. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
  163. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  164. package/dist/core/runner/reply-pricing.d.ts +30 -0
  165. package/dist/core/runner/reply-pricing.js +19 -0
  166. package/dist/core/runner/resume-admission.js +4 -2
  167. package/dist/core/runner/resume-apply.js +6 -1
  168. package/dist/core/runner/resume-policy-outcome.js +5 -5
  169. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  170. package/dist/core/runner/role-seat-defaulted.js +40 -0
  171. package/dist/core/runner/run-brain-sinks.js +2 -0
  172. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  173. package/dist/core/runner/run-identity-wiring.js +5 -4
  174. package/dist/core/runner/run-leg.d.ts +2 -0
  175. package/dist/core/runner/run-leg.js +37 -28
  176. package/dist/core/runner/run-stop-and-final-verify.js +2 -2
  177. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  178. package/dist/core/runner/run-terminal-adoption.js +9 -3
  179. package/dist/core/runner/run-turn-boundary.js +77 -70
  180. package/dist/core/runner/runtask.d.ts +1 -1
  181. package/dist/core/runner/runtask.js +2 -2
  182. package/dist/core/runner/side-call-account.d.ts +1 -1
  183. package/dist/core/runner/side-call-account.js +3 -18
  184. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  185. package/dist/core/runner/sub-agent-deny-lists.js +10 -0
  186. package/dist/core/runner/tool-end-body.js +2 -2
  187. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  188. package/dist/core/runner/tool-occurrence.js +2 -2
  189. package/dist/core/runner/turn-attachments.d.ts +26 -22
  190. package/dist/core/runner/turn-attachments.js +24 -26
  191. package/dist/core/runner-deps.d.ts +1 -1
  192. package/dist/core/secret-env.d.ts +32 -2
  193. package/dist/core/secret-env.js +65 -3
  194. package/dist/core/sensitive-path-policy.js +3 -3
  195. package/dist/core/session-policy-store.d.ts +3 -1
  196. package/dist/core/session-policy-store.js +13 -9
  197. package/dist/core/session-store.d.ts +2 -5
  198. package/dist/core/side-query.d.ts +11 -1
  199. package/dist/core/side-query.js +9 -0
  200. package/dist/core/skill-grant-binding.d.ts +31 -2
  201. package/dist/core/skill-grant-binding.js +31 -1
  202. package/dist/core/skill-grant.d.ts +8 -5
  203. package/dist/core/skill-grant.js +6 -6
  204. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  205. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  206. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  207. package/dist/core/synthetic-read-verdict.js +2 -1
  208. package/dist/core/task-event.d.ts +32 -8
  209. package/dist/core/task-notification.js +16 -10
  210. package/dist/core/task-registry-agent.js +1 -0
  211. package/dist/core/task-registry-shared.d.ts +5 -0
  212. package/dist/core/task-spec.d.ts +12 -1
  213. package/dist/core/terminal-cause.d.ts +10 -0
  214. package/dist/core/tool-check-reading.d.ts +1 -0
  215. package/dist/core/tool-check-reading.js +3 -3
  216. package/dist/core/tool-policy.d.ts +16 -0
  217. package/dist/core/tool-roster.d.ts +112 -5
  218. package/dist/core/tool-roster.js +42 -1
  219. package/dist/core/tool-spec.d.ts +3 -1
  220. package/dist/core/types.d.ts +2 -2
  221. package/dist/core/types.js +1 -1
  222. package/dist/core/user-attachment.js +1 -1
  223. package/dist/core/wiring-manifest.d.ts +6 -3
  224. package/dist/engine/compaction/compaction.js +29 -3
  225. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  226. package/dist/engine/execution-env/node-execution-env.js +9 -12
  227. package/dist/engine/harness/agent-harness.d.ts +25 -2
  228. package/dist/engine/harness/agent-harness.js +41 -12
  229. package/dist/engine/harness/messages.d.ts +3 -1
  230. package/dist/engine/harness/messages.js +3 -2
  231. package/dist/engine/harness/types.d.ts +8 -0
  232. package/dist/engine/llm/rejected-images.d.ts +46 -0
  233. package/dist/engine/llm/rejected-images.js +54 -0
  234. package/dist/engine/llm/tool-turns.d.ts +2 -1
  235. package/dist/engine/llm/types.d.ts +18 -7
  236. package/dist/engine/loop/agent-loop.d.ts +8 -0
  237. package/dist/engine/loop/agent-loop.js +52 -15
  238. package/dist/engine/loop/types.d.ts +3 -1
  239. package/dist/engine/session/path-to-root.d.ts +38 -0
  240. package/dist/engine/session/path-to-root.js +39 -0
  241. package/dist/engine/session/storage-base.js +4 -21
  242. package/dist/index.d.ts +16 -10
  243. package/dist/index.js +11 -7
  244. package/dist/internal/harness-types.d.ts +1 -1
  245. package/dist/internal/harness.d.ts +1 -0
  246. package/dist/internal/llm.d.ts +1 -0
  247. package/dist/orchestration/workflow-observe.d.ts +17 -1
  248. package/dist/orchestration/workflow-observe.js +20 -0
  249. package/dist/orchestration/workflow-types.d.ts +32 -7
  250. package/dist/orchestration/workflow.js +739 -489
  251. package/dist/shell/counting-pass.d.ts +50 -0
  252. package/dist/shell/counting-pass.js +502 -0
  253. package/dist/shell/lex.d.ts +4 -2
  254. package/dist/shell/lex.js +93 -34
  255. package/dist/shell/shell-words.d.ts +1 -1
  256. package/dist/shell/shell-words.js +7 -6
  257. package/dist/stores/file/mailbox-store.js +6 -10
  258. package/dist/tools/fs/fs-bash.d.ts +6 -0
  259. package/dist/tools/fs/fs-bash.js +6 -3
  260. package/dist/tools/fs/index.js +6 -2
  261. package/dist/tools/fs/program-read-model.d.ts +13 -0
  262. package/dist/tools/fs/program-read-model.js +15 -0
  263. package/dist/tools/fs/program-read-model.rows.js +1 -1
  264. package/dist/tools/fs/read-deny.d.ts +13 -10
  265. package/dist/tools/fs/read-deny.js +25 -5
  266. package/dist/tools/fs/read-floor.d.ts +19 -0
  267. package/dist/tools/fs/read-floor.js +23 -0
  268. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  269. package/dist/tools/fs/shell-read-check.js +2 -1
  270. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  271. package/dist/tools/fs/shell-read-judge.js +10 -6
  272. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  273. package/dist/tools/fs/shell-read-plan.js +22 -15
  274. package/dist/tools/fs/shell-read-start.js +1 -0
  275. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  276. package/dist/tools/fs/shell-reentry-text.js +25 -3
  277. package/dist/tools/monitor.d.ts +4 -0
  278. package/dist/tools/monitor.js +2 -0
  279. package/package.json +3 -2
  280. package/test/export-surface.snapshot.json +87 -1
  281. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  282. package/wire-changes/core@7.59.0.json +2459 -0
  283. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  284. package/wire-changes/primitives@7.59.0.json +29 -0
@@ -1,4 +1,4 @@
1
- import { CheckpointError, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
1
+ import { CheckpointError, judgeParkedSteerRepeat, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
2
2
  import { assertResumeConfigRecord, checkpointStoreSeat, refuseResumeDoors } from "./prepare-config-doors.js";
3
3
  import { asResumeConfigRefusal } from "../mode-policy.js";
4
4
  import { describeSuppliedValue } from "./decide-continuation.js";
@@ -15,7 +15,7 @@ export async function resumeAdmission(input) {
15
15
  const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry } = input;
16
16
  let internals = input.internals;
17
17
  if (outcome === null || typeof outcome !== "object") {
18
- throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`);
18
+ throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`, { field: "outcome" });
19
19
  }
20
20
  asResumeConfigRefusal("taskConfig", () => assertResumeConfigRecord(taskConfig));
21
21
  let config = { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) };
@@ -80,6 +80,8 @@ export async function resumeAdmission(input) {
80
80
  }
81
81
  if (suppliedMessage !== undefined) {
82
82
  wakeMessage = validatePendingSteer(suppliedMessage);
83
+ if (judgeParkedSteerRepeat(parkedSteers, wakeMessage) !== undefined)
84
+ wakeMessage = undefined;
83
85
  }
84
86
  else if (parkedSteers.length === 0) {
85
87
  throw new CheckpointError("wake.nothing_to_deliver", "cannot wake: no message was supplied and the checkpoint holds no parked pendingSteer — an empty " +
@@ -4,6 +4,8 @@ import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
4
4
  import { mintHookInvocationIdentity } from "../hooks.js";
5
5
  import { admitLegMods, classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
6
6
  import { checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
7
+ import { requestGrantBinding } from "../skill-grant-binding.js";
8
+ import { skillGrantBindingMembers } from "../skill-grant.js";
7
9
  import { callFaceSeat, parkedCallFaceOf } from "../tool-roster.js";
8
10
  import { readCallTarget } from "../effective-path-target.js";
9
11
  import { inlineUntrusted } from "../untrusted-text.js";
@@ -74,9 +76,11 @@ export async function resumeApply(input) {
74
76
  p.then((v) => { editSignal.removeEventListener("abort", onAbort); resolve(v); }, (e) => { editSignal.removeEventListener("abort", onAbort); reject(e); });
75
77
  });
76
78
  };
79
+ const servedSkills = plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval" ? skillsThatLoad(normalizeSkills(config.skills)) : [];
77
80
  if (plainPolicyOutcome?.decision === "allow" && cp.pendingAction.kind === "tool_approval") {
78
- const servedSkills = skillsThatLoad(normalizeSkills(config.skills));
79
81
  const claimed = judgeApprovalObject(cp.pendingAction, { args: plainPolicyOutcome.updatedInput ?? cp.pendingAction.args, skills: servedSkills, skillToolName: SKILL_TOOL_NAME }, "claim");
82
+ if (claimed !== "match" && claimed.member === "tool")
83
+ throw new CheckpointError("checkpoint.unsupported_version", claimed.message, { reason: "tool_identity_missing" });
80
84
  if (claimed !== "match")
81
85
  throw new CheckpointError("checkpoint.invalid_outcome", claimed.message, { field: "boundGrantDigest" });
82
86
  }
@@ -94,6 +98,7 @@ export async function resumeApply(input) {
94
98
  toolName: cp.pendingAction.toolName,
95
99
  args: editedArgs,
96
100
  toolCallId: cp.pendingAction.toolCallId,
101
+ ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, servedSkills, SKILL_TOOL_NAME), cp.pendingAction, editedArgs),
97
102
  budget: editBudget,
98
103
  ...callFaceSeat(parkedCallFaceOf(cp.pendingAction)),
99
104
  ...(cp.state.handsCwd !== undefined ? { cwd: cp.state.handsCwd } : {}),
@@ -33,17 +33,17 @@ export function resumePolicyOutcome(input) {
33
33
  if (updatedInputRaw !== undefined) {
34
34
  const captured = capturedJsonOf(updatedInputRaw);
35
35
  if (!captured.ok)
36
- throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault));
36
+ throw new CheckpointError("checkpoint.invalid_outcome", bindingRefusalOf(cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "the parked call", updatedInputRaw, captured.fault), { field: "updatedInput" });
37
37
  updatedInput = captured.value;
38
38
  }
39
39
  const decision = decide.decision;
40
40
  if (decision !== "allow" && decision !== "deny") {
41
- throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending`);
41
+ throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the policy_ask domain — a decide is exactly "allow" or "deny"; refusing pre-CAS, the checkpoint stays pending`, { field: "decision" });
42
42
  }
43
43
  refuseSuppliedKeys(decide, REFUSED_DECIDE_KEYS);
44
44
  const hostDecision = captureHostDecision(cp, decide.hostDecision, "policy_ask", { word: decision, allows: decision === "allow" });
45
45
  const reason = decide.reason;
46
- assertOutcomeText(reason, "reason");
46
+ assertOutcomeText(reason, "reason", { field: "reason" });
47
47
  const feedback = decide.feedback;
48
48
  assertOutcomeText(feedback, "feedback", { field: "feedback" });
49
49
  plainPolicyOutcome = {
@@ -59,7 +59,7 @@ export function resumePolicyOutcome(input) {
59
59
  };
60
60
  refuseUnfitFeedback(plainPolicyOutcome);
61
61
  if (plainPolicyOutcome.decision === "deny" && plainPolicyOutcome.reason && sanitizeUntrustedText(plainPolicyOutcome.reason) !== plainPolicyOutcome.reason) {
62
- throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"));
62
+ throw new CheckpointError("checkpoint.invalid_outcome", sentinelTagRefusal("resume deny/reject reason"), { field: "reason" });
63
63
  }
64
64
  }
65
65
  if (plainPolicyOutcome !== undefined) {
@@ -74,7 +74,7 @@ export function resumePolicyOutcome(input) {
74
74
  }
75
75
  }
76
76
  else if (checkpointVersionOf(cp) >= CHECKPOINT_FEATURES.binding.version) {
77
- throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)`);
77
+ throw new CheckpointError("checkpoint.invalid_outcome", `resume of a binding-version (v${checkpointVersionOf(cp)}) checkpoint whose pending tool call has no persisted boundInputHash — refusing to resume an unbound binding-version checkpoint (corruption / downgrade guard)`, { reason: "bound_input_hash_missing" });
78
78
  }
79
79
  if (cp.reopenReason === "env_failed") {
80
80
  if (cp.resolvedOutcome === undefined) {
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The person's account of a role seat the engine stands in for (`model.role_defaulted`).
3
+ *
4
+ * A role seat that names a model word the deployment's catalog does not hold supplies no model: the roles family reads it as an unset
5
+ * seat (`seatRead`, `src/core/roles.ts` — the tier default and the fallback chain follow; a subagent seat falls to the parent's model),
6
+ * so the run goes on instead of refusing at every prepare. That is only honest when it is said: this prepare-time phase names each such
7
+ * seat once per conversation, from the SAME role maps (the merged deployment-and-task map, and the deployment's own map that a delegated child's
8
+ * seat reads) and the SAME catalog the reads use (`unheldRoleSeats`), whether or not a
9
+ * later read of this leg reaches the seat. `default` (the main model's seat) and `classifier` (its own stand-in and line,
10
+ * `classifier.role_defaulted`) are never named here.
11
+ *
12
+ * Root legs only: a delegated child inherits the deployment's maps and would repeat the parent's line once per spawn.
13
+ */
14
+ import { type EngineNotice } from "../engine-notice.js";
15
+ import { type ModelRoles, type UnheldRoleSeat } from "../roles.js";
16
+ import type { Model } from "../types.js";
17
+ import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
18
+ export declare const ROLE_DEFAULTED = "model.role_defaulted";
19
+ /** The notice for one unheld seat. `word` is bounded and quoted as every refusal of this family quotes it. */
20
+ export declare function roleDefaultedNotice(u: UnheldRoleSeat, ids: {
21
+ sessionId: string;
22
+ runId?: string;
23
+ }): EngineNotice;
24
+ export interface AnnounceRoleSeatsInput {
25
+ /** borrowed-readonly — the rebound spec's role map (the task's own seats). */
26
+ spec: {
27
+ roles?: ModelRoles;
28
+ };
29
+ /** borrowed-readonly — the deployment's maps and the catalog the reads ask, and the notice sink. */
30
+ deps: {
31
+ models?: Record<string, Model>;
32
+ roles?: ModelRoles;
33
+ onNotice?: (notice: EngineNotice) => void;
34
+ };
35
+ /** borrowed-readonly — the once-per-session ledger the notice's dedupe rides. */
36
+ onceLedger: Pick<AnnounceOnceLedger, "oncePerSession">;
37
+ /** borrowed-readonly — true for the root leg of a conversation; a delegated child names nothing (its parent already did). */
38
+ rootLeg: boolean;
39
+ sessionId: string;
40
+ runId: string | undefined;
41
+ }
42
+ /** The phase: one line per unheld seat per conversation (the dedupe key is the seat and the word, so a seat re-pointed at another
43
+ * unknown word is said again). */
44
+ export declare function announceRoleSeatsDefaulted(input: AnnounceRoleSeatsInput): void;
@@ -0,0 +1,40 @@
1
+ import { deliverEngineNotice } from "../engine-notice.js";
2
+ import { bindingShown, roleFallbackChain, unheldRoleSeats } from "../roles.js";
3
+ import { announceDigest } from "./announce-once-ledger.js";
4
+ export const ROLE_DEFAULTED = "model.role_defaulted";
5
+ const STANDS_IN = {
6
+ summarize: "the compaction summary runs on the conversation's own model (or the tier default for that role, when tiers are declared)",
7
+ subagent: "child runs go on the parent run's model",
8
+ verifier: "the verification gate runs on the main model",
9
+ consolidate: "memory consolidation runs on the summarize role's model, and is refused when that supplies none",
10
+ };
11
+ export function roleDefaultedNotice(u, ids) {
12
+ const shown = bindingShown(u.word);
13
+ return {
14
+ code: ROLE_DEFAULTED,
15
+ message: `${u.seat} names the model ${shown}, which this deployment's model catalog does not hold, so the seat is read as an unset one: ${STANDS_IN[u.role] ?? "its fallback chain decides"}. ` +
16
+ `Declare ${shown} in the catalog (RunnerDeps.models) or correct the seat. Said once per conversation for this seat.`,
17
+ detail: {
18
+ seat: u.seat,
19
+ role: u.role,
20
+ model: u.word.length > 80 ? `${u.word.slice(0, 80)}…` : u.word,
21
+ reason: "unknown_model_ref",
22
+ fallback: [...roleFallbackChain(u.role)],
23
+ sessionId: ids.sessionId,
24
+ ...(ids.runId !== undefined ? { runId: ids.runId } : {}),
25
+ },
26
+ sessionId: ids.sessionId,
27
+ };
28
+ }
29
+ export function announceRoleSeatsDefaulted(input) {
30
+ if (!input.rootLeg)
31
+ return;
32
+ const seen = new Set();
33
+ for (const u of [...unheldRoleSeats({}, input.deps), ...unheldRoleSeats(input.spec, input.deps)]) {
34
+ const key = `${u.seat}\n${u.word}`;
35
+ if (seen.has(key))
36
+ continue;
37
+ seen.add(key);
38
+ input.onceLedger.oncePerSession(announceDigest(ROLE_DEFAULTED, key), () => deliverEngineNotice(input.deps.onNotice, roleDefaultedNotice(u, { sessionId: input.sessionId, ...(input.runId !== undefined ? { runId: input.runId } : {}) })));
39
+ }
40
+ }
@@ -19,6 +19,8 @@ export function runBrainSinks(input) {
19
19
  ...(s.retryAtMs !== undefined ? { retryAtMs: s.retryAtMs } : {}),
20
20
  ...(s.elapsedMs !== undefined ? { elapsedMs: s.elapsedMs } : {}),
21
21
  ...(s.timeoutMs !== undefined ? { timeoutMs: s.timeoutMs } : {}),
22
+ ...(s.waitSegment !== undefined ? { waitSegment: s.waitSegment } : {}),
23
+ ...(s.sleptMs !== undefined ? { sleptMs: s.sleptMs } : {}),
22
24
  ...(s.attempt !== undefined ? { attempt: s.attempt } : {}),
23
25
  ...(s.maxRetries !== undefined ? { maxRetries: s.maxRetries } : {}),
24
26
  ...(s.errClass !== undefined ? { errClass: s.errClass } : {}),
@@ -2,7 +2,7 @@ import type { PeerInboundChainRef } from "../../agents/peer-admission.js";
2
2
  import { type SafeNotifier } from "../safe-notify.js";
3
3
  import { type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
4
4
  import type { PushQueue } from "../push-queue.js";
5
- import type { TaskEvent, TaskSpec } from "../types.js";
5
+ import type { HeldUserInputs, TaskEvent, TaskSpec } from "../types.js";
6
6
  import type { Stats } from "./assemble-result.js";
7
7
  import { type CallerStopGate } from "./caller-stop-gate.js";
8
8
  import type { CaptureOptOutRef, LiveHandle, ManualCompactRef, McpRedialRef, NotificationLaneBindings, NotifyRef, Prepared, RunInternals, RunnerDepsSeat, TaskIdRef } from "./contracts.js";
@@ -73,10 +73,7 @@ export interface RunIdentityWiringResult {
73
73
  /** The held agent_end account, a READ FACE over this lane's own `let` (the undrained-inputs sink writes it
74
74
  * when the run committed a durable park); the terminal-adoption lane settles it minus what the park carried. */
75
75
  undrainedUserAtEnd: {
76
- readonly current: {
77
- steer: number;
78
- followUp: number;
79
- } | undefined;
76
+ readonly current: HeldUserInputs | undefined;
80
77
  };
81
78
  /** The run's ONE isolation scope for the {@link RunInternals} observation sinks: minted here because
82
79
  * the manifest sink below is the run's first call into one, and handed on to the harness-handlers lane
@@ -6,7 +6,7 @@ import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js
6
6
  import { discloseDroppedPending, renderTaskNotificationXml, taskNotificationDedupKey } from "../task-notification.js";
7
7
  import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
8
8
  import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
9
- import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, undrainedUserInputNotices } from "../types.js";
9
+ import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
10
10
  import { mintCallerStopGate } from "./caller-stop-gate.js";
11
11
  export function runIdentityWiring(input) {
12
12
  const { spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, notificationLane, pendingSessionNotifications, runner } = input;
@@ -64,13 +64,14 @@ export function runIdentityWiring(input) {
64
64
  prepared.harness.engineInjectionsHeld = () => prepared.batchHaltRef.current !== undefined;
65
65
  let undrainedUserAtEnd;
66
66
  let userInputLostAtEnd = false;
67
- prepared.harness.onUndrainedUserInputs = (counts) => {
67
+ prepared.harness.onUndrainedUserInputs = (counts, parkRecords) => {
68
68
  userInputLostAtEnd = counts.steer + counts.followUp > 0;
69
+ const inputIds = parkRecords !== undefined ? parkedInputIdsOf(parkRecords) : undefined;
69
70
  if (prepared.pausedRef.current !== undefined || prepared.undeliveredContinuationRef.current.parkedSteers.length > 0) {
70
- undrainedUserAtEnd = counts;
71
+ undrainedUserAtEnd = { steer: counts.steer, followUp: counts.followUp, ...(inputIds !== undefined ? { inputIds } : {}) };
71
72
  return;
72
73
  }
73
- for (const notice of undrainedUserInputNotices(counts, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
74
+ for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) }, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
74
75
  deliverEngineNotice(runner.deps.onNotice, notice);
75
76
  }
76
77
  };
@@ -40,6 +40,8 @@ export interface RunLegInput<R> {
40
40
  rs: RunState;
41
41
  /** borrowed-readonly — the API-boundary attribution snapshot of the objective's actor (the objective leg's speaker envelope). */
42
42
  entryActor: ActorAssertion | undefined;
43
+ /** borrowed-readonly — `RunInternals.operatorObjective`: this delegated leg's objective carries a person's words. */
44
+ operatorObjective: boolean;
43
45
  /** borrowed-readonly — the effective walltime window (undefined = unbounded): `<= 0` refuses the first turn. */
44
46
  effectiveTimeoutMs: number | undefined;
45
47
  /** borrowed-mutable — the hard walltime timer: claimed (`fired`) and cleared by the exhausted arms and the finally. */
@@ -5,14 +5,15 @@ import { CheckpointError, readPendingSteerQueue, realApprovalOrgFact, remainingB
5
5
  import { normalizePersistedRuleHit } from "../rule-lane-reads.js";
6
6
  import { decidersNote, SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
7
7
  import { formatHookFeedback } from "../hooks.js";
8
- import { classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
8
+ import { classicEventBase, failedHandlerClause, legEventsOf, openSubagent, screenUserPrompt } from "../mods/stations.js";
9
9
  import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
10
10
  import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
11
11
  import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
12
12
  import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
13
13
  import { applyPersistedTightening, disclosedRuleSet } from "../persisted-rule-arms.js";
14
14
  import { argsReadBy, stampArgsReading } from "../effective-path-target.js";
15
- import { skillRowRefusal } from "../skill-grant.js";
15
+ import { skillGrantBindingMembers, skillRowRefusal } from "../skill-grant.js";
16
+ import { requestGrantBinding } from "../skill-grant-binding.js";
16
17
  import { judgeApprovalObject } from "../approval-object.js";
17
18
  import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
18
19
  import { computeCostMicroUsd } from "../pricing.js";
@@ -53,7 +54,7 @@ import { thrownMarksOf } from "../thrown-value.js";
53
54
  import { egressThrownText, egressValue } from "../untrusted-egress.js";
54
55
  import { ruleSourcePhrase } from "../rule-denial-sentence.js";
55
56
  export async function runLeg(input) {
56
- const { spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
57
+ const { spec, queue, prepared, resume, rs, entryActor, operatorObjective, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
57
58
  let final;
58
59
  let threw;
59
60
  let abortedLive = false;
@@ -305,28 +306,36 @@ export async function runLeg(input) {
305
306
  const projectedObjective = projectHumanInput({ text: spec.objective, actor: objectiveActor, source: "objective" });
306
307
  let effectiveObjective = projectedObjective;
307
308
  let promptBlocked = false;
308
- const screen = await screenUserPrompt(prepared.modBus, {
309
- ...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
310
- prompt: spec.objective,
311
- source: "objective",
312
- ...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
313
- ...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
314
- }, prepared.abortController.signal);
315
- if (screen?.kind === "aborted") {
316
- holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
317
- `the prompt was NOT submitted (fail-closed)`);
318
- promptBlocked = true;
319
- }
320
- else if (screen?.kind === "failed") {
321
- holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
322
- promptBlocked = true;
323
- }
324
- else if (screen?.block) {
325
- holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
326
- promptBlocked = true;
309
+ const objectiveEvents = legEventsOf(prepared.hookIdentity, operatorObjective);
310
+ if (objectiveEvents.screen !== undefined) {
311
+ const screen = await screenUserPrompt(prepared.modBus, {
312
+ ...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
313
+ prompt: spec.objective,
314
+ source: "objective",
315
+ ...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
316
+ ...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
317
+ }, prepared.abortController.signal);
318
+ if (screen?.kind === "aborted") {
319
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
320
+ `the prompt was NOT submitted (fail-closed)`);
321
+ promptBlocked = true;
322
+ }
323
+ else if (screen?.kind === "failed") {
324
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
325
+ promptBlocked = true;
326
+ }
327
+ else if (screen?.block) {
328
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
329
+ promptBlocked = true;
330
+ }
331
+ else if (screen?.additionalContext) {
332
+ effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
333
+ }
327
334
  }
328
- else if (screen?.additionalContext) {
329
- effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
335
+ if (objectiveEvents.start !== undefined && !promptBlocked) {
336
+ const start = await openSubagent(prepared.modBus, prepared.hookIdentity, prepared.permissionMode.observed, prepared.abortController.signal);
337
+ if (start?.additionalContext)
338
+ effectiveObjective = `${formatHookFeedback(start.additionalContext, prepared.reminderMark)}\n\n${effectiveObjective}`;
330
339
  }
331
340
  const objectiveInputId = uuidv7();
332
341
  const { frames: attachmentFrames, chars: attachmentChars } = await readObjectiveAttachments(prepared, objectiveInputId, promptBlocked, { overlay: () => legContextOverlayOption(prepared, runner).contextOverlay, objectiveChars: effectiveObjective.length });
@@ -600,9 +609,9 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
600
609
  occurrences.gateRound(pendingAction.toolCallId, decidedGate, frozenInputSnapshot(resolvedArgs));
601
610
  let notExecuted = false;
602
611
  const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
603
- const settleEnd = async (isError, result, refusedBy, neverRan) => {
612
+ const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
604
613
  if (refusedBy !== undefined)
605
- occurrences.refuse(pendingAction.toolCallId, refusedBy);
614
+ occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
606
615
  const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaByteCapBytes: runner.deps.mediaByteCapBytes });
607
616
  notExecuted = settled.notExecuted === true;
608
617
  const gate = settled.gate ?? decidedGate;
@@ -648,7 +657,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
648
657
  const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), decidedBy: outcome.hostDecision.decidedBy });
649
658
  if (screened !== undefined && "refused" in screened) {
650
659
  const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
651
- await settleEnd(true, { content: hookDenial }, "hook");
660
+ await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
652
661
  emitCommitted(await prepared.session.appendMessage(resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
653
662
  return;
654
663
  }
@@ -663,7 +672,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
663
672
  const executedArgs = rescreened !== undefined ? rescreened.args : resolvedArgs;
664
673
  const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
665
674
  let beltReading;
666
- const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}) });
675
+ const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
667
676
  const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
668
677
  if (unjudgeable !== undefined) {
669
678
  const chainDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: its input changed after the approval and the inherited ancestor chain cannot judge the changed input (${unjudgeable}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
@@ -1,11 +1,11 @@
1
1
  import { openSystemReminder } from "../reminder-mint.js";
2
2
  import { formatHookFeedback } from "../hooks.js";
3
- import { classicEventBase, dispatchClassic, stopEventOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
3
+ import { classicEventBase, dispatchClassic, legEventsOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
4
4
  import { asThrownError } from "../thrown-value.js";
5
5
  const STOP_HOOK_BLOCK_CAP = 8;
6
6
  export function runStopAndFinalVerify(input) {
7
7
  const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, runner } = input;
8
- const stopEvent = stopEventOf(prepared.hookIdentity);
8
+ const stopEvent = legEventsOf(prepared.hookIdentity).stop;
9
9
  const stopArmed = prepared.modBus.hasHandlers(stopEvent);
10
10
  const finalVerificationOn = spec.finalVerification === true;
11
11
  const finalVerifyBudgetFill = () => {
@@ -19,7 +19,7 @@ import type { Model } from "../../internal/llm.js";
19
19
  import { type MaybeCompactOptions } from "../auto-compaction.js";
20
20
  import type { SessionStore } from "../session.js";
21
21
  import type { PushQueue } from "../push-queue.js";
22
- import type { Brain, OwedUserInputAccount, TaskEvent, TaskSpec } from "../types.js";
22
+ import { type Brain, type HeldUserInputs, type OwedUserInputAccount, type TaskEvent, type TaskSpec } from "../types.js";
23
23
  import { type Stats } from "./assemble-result.js";
24
24
  import type { EndOfTaskCompaction, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
25
25
  import type { CallerStopGate } from "./caller-stop-gate.js";
@@ -61,10 +61,7 @@ export interface RunTerminalAdoptionInput<R> {
61
61
  windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
62
62
  /** borrowed-readonly — the held agent_end account, as the read face on the identity lane's Result. */
63
63
  undrainedUserAtEnd: {
64
- readonly current: {
65
- steer: number;
66
- followUp: number;
67
- } | undefined;
64
+ readonly current: HeldUserInputs | undefined;
68
65
  };
69
66
  /** borrowed-readonly — did the run end with a person's steer / follow-up still pending (the identity lane's read face)? Folded
70
67
  * into the answer-settled verdict this lane evaluates once. */
@@ -2,6 +2,7 @@ import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTR
2
2
  import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
3
3
  import { appendInterruptionMarker, reconcileInterruptedSession } from "../session-reconcile.js";
4
4
  import { emitTrace } from "../trace.js";
5
+ import { parkedInputIdsOf } from "../types.js";
5
6
  import { answerSettled } from "./assemble-result.js";
6
7
  import { errorCodeOf } from "./terminal-account.js";
7
8
  import { awaitChargeWithSlowDisclosure, discloseUnevaluableWindow } from "./clock-and-limits.js";
@@ -79,6 +80,7 @@ export async function runTerminalAdoption(input) {
79
80
  }
80
81
  let migratedParked = { steer: 0, followUp: 0 };
81
82
  let carriedContinuation = 0;
83
+ const carriedContinuationInputIds = [];
82
84
  let carriedApproval = 0;
83
85
  let approvalRefusal;
84
86
  if (committedPause !== undefined && runner.deps.checkpointStore !== undefined) {
@@ -101,8 +103,11 @@ export async function runTerminalAdoption(input) {
101
103
  carried.push(live);
102
104
  else if (approval)
103
105
  carriedApproval += 1;
104
- else
106
+ else {
105
107
  carriedContinuation += 1;
108
+ if (typeof input.inputId === "string")
109
+ carriedContinuationInputIds.push(input.inputId);
110
+ }
106
111
  }
107
112
  catch (parkErr) {
108
113
  runner.deps.onError?.(asThrownError(parkErr), {
@@ -118,9 +123,10 @@ export async function runTerminalAdoption(input) {
118
123
  break;
119
124
  }
120
125
  }
121
- migratedParked = prepared.harness.dropParkedUserInputs(carried);
126
+ const dropped = prepared.harness.dropParkedUserInputs(carried);
127
+ migratedParked = { steer: dropped.steer, followUp: dropped.followUp, inputIds: parkedInputIdsOf(dropped.records) };
122
128
  }
123
- const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
129
+ const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, carriedInputIds: carriedContinuationInputIds, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
124
130
  if (rs.attach.attachState?.postCompactPending === true && (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true) {
125
131
  emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.announce_dropped", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
126
132
  }