@sema-agent/core 7.70.0 → 7.71.1

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 (439) hide show
  1. package/CHANGELOG.md +740 -0
  2. package/dist/agents/agent-transcript-tool.js +43 -19
  3. package/dist/agents/inherited-tool-pool.d.ts +5 -1
  4. package/dist/agents/inherited-tool-pool.js +6 -0
  5. package/dist/agents/retain-ledger.js +2 -0
  6. package/dist/agents/send-message-tool.d.ts +12 -1
  7. package/dist/agents/send-message-tool.js +47 -9
  8. package/dist/agents/subagent.js +31 -10
  9. package/dist/agents/tool-filter.js +1 -2
  10. package/dist/agents/verify.js +13 -2
  11. package/dist/agents/yield-adoption.js +11 -1
  12. package/dist/brain/claude-model-id.d.ts +11 -0
  13. package/dist/brain/claude-model-id.js +3 -1
  14. package/dist/config/catalog.js +10 -1
  15. package/dist/config/defaults.d.ts +3 -0
  16. package/dist/config/defaults.js +1 -0
  17. package/dist/core/allow-entry.js +1 -2
  18. package/dist/core/ask-origin.d.ts +55 -21
  19. package/dist/core/ask-origin.js +19 -11
  20. package/dist/core/ask-question.d.ts +4 -7
  21. package/dist/core/ask-question.js +2 -4
  22. package/dist/core/ask-unresolvable-notice.d.ts +17 -3
  23. package/dist/core/ask-unresolvable-notice.js +18 -4
  24. package/dist/core/attachment-source.d.ts +1 -1
  25. package/dist/core/attachment-source.js +2 -0
  26. package/dist/core/auto-compaction.d.ts +14 -4
  27. package/dist/core/auto-compaction.js +3 -2
  28. package/dist/core/auto-strip.js +2 -0
  29. package/dist/core/caller-text.d.ts +2 -33
  30. package/dist/core/caller-text.js +2 -23
  31. package/dist/core/caller-tool-name.js +1 -2
  32. package/dist/core/canonical-json.d.ts +9 -0
  33. package/dist/core/canonical-json.js +6 -0
  34. package/dist/core/checkpoint-features.d.ts +43 -80
  35. package/dist/core/checkpoint-features.js +10 -20
  36. package/dist/core/checkpoint-generation.d.ts +89 -19
  37. package/dist/core/checkpoint-generation.js +89 -14
  38. package/dist/core/checkpoint-queries.d.ts +95 -15
  39. package/dist/core/checkpoint-queries.js +108 -7
  40. package/dist/core/checkpoint-rekey.d.ts +2 -1
  41. package/dist/core/checkpoint-rekey.js +2 -2
  42. package/dist/core/checkpoint-requirements.d.ts +21 -7
  43. package/dist/core/checkpoint-requirements.js +2 -5
  44. package/dist/core/checkpoint-row-verdict.d.ts +3 -4
  45. package/dist/core/checkpoint-row-verdict.js +20 -41
  46. package/dist/core/checkpoint-store.d.ts +69 -41
  47. package/dist/core/checkpoint-store.js +28 -14
  48. package/dist/core/command-sandbox.d.ts +5 -3
  49. package/dist/core/command-sandbox.js +17 -9
  50. package/dist/core/config-refusal-codes.d.ts +1 -1
  51. package/dist/core/config-refusal-codes.js +1 -0
  52. package/dist/core/declaration-words.d.ts +2 -1
  53. package/dist/core/declaration-words.js +13 -2
  54. package/dist/core/effective-path-target.d.ts +23 -0
  55. package/dist/core/effective-path-target.js +15 -1
  56. package/dist/core/engine-attestation.d.ts +5 -1
  57. package/dist/core/engine-attestation.js +1 -0
  58. package/dist/core/engine-capabilities.d.ts +14 -9
  59. package/dist/core/engine-capabilities.js +1 -1
  60. package/dist/core/engine-notice.d.ts +62 -32
  61. package/dist/core/engine-version.js +1 -1
  62. package/dist/core/entries-not-applied.d.ts +1 -1
  63. package/dist/core/entries-not-applied.js +1 -0
  64. package/dist/core/file-history-store.d.ts +95 -11
  65. package/dist/core/file-history-store.js +117 -19
  66. package/dist/core/gate-fold.js +13 -7
  67. package/dist/core/gate-lanes.js +9 -9
  68. package/dist/core/governance-codes.d.ts +56 -7
  69. package/dist/core/governance-codes.js +105 -7
  70. package/dist/core/grant-holder.d.ts +53 -0
  71. package/dist/core/grant-holder.js +80 -0
  72. package/dist/core/hooks.d.ts +7 -3
  73. package/dist/core/hooks.js +2 -2
  74. package/dist/core/locked-config.d.ts +7 -1
  75. package/dist/core/locked-config.js +9 -2
  76. package/dist/core/mcp-call-meta.d.ts +52 -7
  77. package/dist/core/mcp-call-meta.js +21 -2
  78. package/dist/core/mcp-host-read.d.ts +1 -1
  79. package/dist/core/mcp-server-spec.d.ts +18 -0
  80. package/dist/core/mcp-server-spec.js +1 -0
  81. package/dist/core/mcp.js +2 -2
  82. package/dist/core/member-outcome.d.ts +22 -1
  83. package/dist/core/member-outcome.js +18 -6
  84. package/dist/core/memory-engine/delegation-settlement.js +5 -5
  85. package/dist/core/memory-engine/engine.js +19 -19
  86. package/dist/core/memory-engine/file-backend.d.ts +7 -2
  87. package/dist/core/memory-engine/file-backend.js +14 -12
  88. package/dist/core/memory-engine/frontmatter.js +1 -1
  89. package/dist/core/memory-engine/index.d.ts +1 -0
  90. package/dist/core/memory-engine/index.js +1 -0
  91. package/dist/core/memory-engine/layout.d.ts +34 -9
  92. package/dist/core/memory-engine/layout.js +36 -19
  93. package/dist/core/memory-engine/memory-deployment.js +8 -8
  94. package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
  95. package/dist/core/memory-engine/mount-failed-notice.js +5 -2
  96. package/dist/core/mode-policy.d.ts +5 -0
  97. package/dist/core/mode-policy.js +6 -0
  98. package/dist/core/mods/host.d.ts +2 -1
  99. package/dist/core/mods/host.js +7 -6
  100. package/dist/core/mods/kernel/index.d.ts +1 -1
  101. package/dist/core/mods/kernel/index.js +1 -1
  102. package/dist/core/mods/kernel/registration.d.ts +5 -2
  103. package/dist/core/mods/kernel/registration.js +19 -3
  104. package/dist/core/mods/package.d.ts +12 -1
  105. package/dist/core/mods/package.js +36 -9
  106. package/dist/core/mods/stations.d.ts +7 -1
  107. package/dist/core/mods/stations.js +17 -3
  108. package/dist/core/mods/teammate-stations.d.ts +4 -1
  109. package/dist/core/mods/teammate-stations.js +1 -1
  110. package/dist/core/native-signal.d.ts +13 -0
  111. package/dist/core/native-signal.js +18 -0
  112. package/dist/core/park-resumability.d.ts +16 -14
  113. package/dist/core/park-resumability.js +9 -4
  114. package/dist/core/path-rule-binding.js +1 -1
  115. package/dist/core/permission-rule-model.d.ts +11 -5
  116. package/dist/core/permission-rule-model.js +5 -3
  117. package/dist/core/permission-rule-org.js +1 -1
  118. package/dist/core/permission-rule-provider.d.ts +5 -1
  119. package/dist/core/permission-rule-provider.js +6 -1
  120. package/dist/core/permission-rule-session.d.ts +35 -5
  121. package/dist/core/permission-rule-session.js +32 -1
  122. package/dist/core/permission-rule-store.d.ts +5 -1
  123. package/dist/core/permission-rule-store.js +28 -5
  124. package/dist/core/permission-rules.d.ts +2 -2
  125. package/dist/core/permission-rules.js +2 -3
  126. package/dist/core/principal-name.d.ts +12 -0
  127. package/dist/core/principal-name.js +6 -2
  128. package/dist/core/read-root-grant-screen.d.ts +7 -6
  129. package/dist/core/read-root-grant-screen.js +7 -8
  130. package/dist/core/remote-env.d.ts +42 -8
  131. package/dist/core/resume-config-judge.js +1 -1
  132. package/dist/core/resume-startup-cause.d.ts +19 -4
  133. package/dist/core/resume-startup-cause.js +25 -6
  134. package/dist/core/rewind-conversation.d.ts +4 -0
  135. package/dist/core/rewrite-rejudge.d.ts +9 -1
  136. package/dist/core/rewrite-rejudge.js +11 -1
  137. package/dist/core/rule-offer-read.js +3 -2
  138. package/dist/core/runner/assemble-result.d.ts +21 -11
  139. package/dist/core/runner/assemble-result.js +24 -4
  140. package/dist/core/runner/boundary-reminders.d.ts +104 -0
  141. package/dist/core/runner/boundary-reminders.js +108 -0
  142. package/dist/core/runner/branch-writeback.d.ts +21 -7
  143. package/dist/core/runner/branch-writeback.js +44 -6
  144. package/dist/core/runner/command-sandbox-frame.js +2 -1
  145. package/dist/core/runner/compact-session.js +11 -4
  146. package/dist/core/runner/constraint-layers.d.ts +24 -5
  147. package/dist/core/runner/constraint-layers.js +21 -2
  148. package/dist/core/runner/continuation-gate.js +3 -1
  149. package/dist/core/runner/contracts.d.ts +83 -13
  150. package/dist/core/runner/cross-boundary-lane.js +2 -1
  151. package/dist/core/runner/delegation-owner.d.ts +246 -45
  152. package/dist/core/runner/delegation-owner.js +237 -63
  153. package/dist/core/runner/expire-settle.d.ts +17 -0
  154. package/dist/core/runner/expire-settle.js +8 -2
  155. package/dist/core/runner/file-history-request.d.ts +4 -3
  156. package/dist/core/runner/file-history-request.js +4 -1
  157. package/dist/core/runner/file-history-restore.d.ts +11 -3
  158. package/dist/core/runner/file-history-restore.js +11 -3
  159. package/dist/core/runner/gate-exit.d.ts +22 -1
  160. package/dist/core/runner/gate-exit.js +12 -14
  161. package/dist/core/runner/nested-memory-content.js +1 -1
  162. package/dist/core/runner/nested-memory-lane.d.ts +10 -2
  163. package/dist/core/runner/nested-memory-lane.js +29 -8
  164. package/dist/core/runner/own-model-money-door.d.ts +13 -0
  165. package/dist/core/runner/own-model-money-door.js +17 -0
  166. package/dist/core/runner/park-commit.d.ts +4 -2
  167. package/dist/core/runner/park-commit.js +2 -1
  168. package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
  169. package/dist/core/runner/permission-rule-lanes.js +7 -0
  170. package/dist/core/runner/person-path-rows.js +1 -1
  171. package/dist/core/runner/placement-fence.d.ts +8 -2
  172. package/dist/core/runner/placement-fence.js +8 -3
  173. package/dist/core/runner/policy-throw.d.ts +3 -2
  174. package/dist/core/runner/policy-throw.js +2 -2
  175. package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
  176. package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
  177. package/dist/core/runner/prepare-artifact.d.ts +14 -1
  178. package/dist/core/runner/prepare-artifact.js +7 -2
  179. package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
  180. package/dist/core/runner/prepare-ask-lane.js +14 -5
  181. package/dist/core/runner/prepare-boundary-parks.js +5 -4
  182. package/dist/core/runner/prepare-config-doors.d.ts +9 -4
  183. package/dist/core/runner/prepare-config-doors.js +25 -8
  184. package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
  185. package/dist/core/runner/prepare-defer-classify.js +6 -6
  186. package/dist/core/runner/prepare-execution-env.d.ts +4 -1
  187. package/dist/core/runner/prepare-execution-env.js +8 -3
  188. package/dist/core/runner/prepare-file-history.d.ts +26 -0
  189. package/dist/core/runner/prepare-file-history.js +15 -1
  190. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
  191. package/dist/core/runner/prepare-inherited-gate.js +9 -2
  192. package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
  193. package/dist/core/runner/prepare-park-ask.js +8 -5
  194. package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
  195. package/dist/core/runner/prepare-policy-chain.js +18 -7
  196. package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
  197. package/dist/core/runner/prepare-prompt-assembly.js +4 -3
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
  199. package/dist/core/runner/prepare-suspend-saga.js +19 -5
  200. package/dist/core/runner/prepare-task.d.ts +2 -5
  201. package/dist/core/runner/prepare-task.js +71 -26
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -5
  203. package/dist/core/runner/prepare-workspace-restore.js +59 -28
  204. package/dist/core/runner/read-root-grant.d.ts +1 -0
  205. package/dist/core/runner/read-root-grant.js +1 -2
  206. package/dist/core/runner/resume-admission.d.ts +3 -0
  207. package/dist/core/runner/resume-admission.js +6 -4
  208. package/dist/core/runner/resume-apply.js +7 -5
  209. package/dist/core/runner/resume-claim.d.ts +2 -2
  210. package/dist/core/runner/resume-claim.js +4 -4
  211. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  212. package/dist/core/runner/resume-policy-outcome.js +6 -4
  213. package/dist/core/runner/resume-preflight.d.ts +3 -0
  214. package/dist/core/runner/resume-preflight.js +10 -3
  215. package/dist/core/runner/rewind-conversation.js +11 -4
  216. package/dist/core/runner/rewind-files.js +29 -14
  217. package/dist/core/runner/rewind-outcome.d.ts +27 -0
  218. package/dist/core/runner/rewind-outcome.js +14 -0
  219. package/dist/core/runner/run-attachment-seats.js +2 -1
  220. package/dist/core/runner/run-clock-and-content.js +2 -0
  221. package/dist/core/runner/run-identity-wiring.js +2 -0
  222. package/dist/core/runner/run-leg.js +11 -1
  223. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  224. package/dist/core/runner/run-notification-lane.js +2 -2
  225. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
  226. package/dist/core/runner/run-settle-and-teardown.js +52 -40
  227. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  228. package/dist/core/runner/run-stop-and-final-verify.js +5 -4
  229. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  230. package/dist/core/runner/run-terminal-adoption.js +3 -3
  231. package/dist/core/runner/run-turn-boundary.js +7 -0
  232. package/dist/core/runner/runtask.d.ts +7 -4
  233. package/dist/core/runner/runtask.js +18 -9
  234. package/dist/core/runner/session-call-grant-station.d.ts +64 -0
  235. package/dist/core/runner/session-call-grant-station.js +119 -0
  236. package/dist/core/runner/session-file-state-replay.js +2 -2
  237. package/dist/core/runner/session-prompt-seats.d.ts +95 -0
  238. package/dist/core/runner/session-prompt-seats.js +62 -0
  239. package/dist/core/runner/session-rule-policy.js +1 -1
  240. package/dist/core/runner/session-write-ledger.d.ts +8 -0
  241. package/dist/core/runner/session-write-ledger.js +16 -0
  242. package/dist/core/runner/side-call-account.js +5 -1
  243. package/dist/core/runner/stop-tail-notice.d.ts +7 -0
  244. package/dist/core/runner/stop-tail-notice.js +23 -8
  245. package/dist/core/runner/stream-reap.js +4 -2
  246. package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
  247. package/dist/core/runner/stream-settle-backstop.js +17 -18
  248. package/dist/core/runner/terminal-account.js +17 -8
  249. package/dist/core/runner/terminal-projection.d.ts +3 -2
  250. package/dist/core/runner/terminal-projection.js +1 -1
  251. package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
  252. package/dist/core/runner/tool-turn-repair-seat.js +12 -7
  253. package/dist/core/runner/turn-attachments.d.ts +22 -1
  254. package/dist/core/runner/turn-attachments.js +20 -3
  255. package/dist/core/runner-deps.d.ts +6 -2
  256. package/dist/core/secret-env.d.ts +26 -6
  257. package/dist/core/secret-env.js +6 -6
  258. package/dist/core/session-call-grant-screen.d.ts +58 -0
  259. package/dist/core/session-call-grant-screen.js +18 -0
  260. package/dist/core/session-call-grant.d.ts +93 -0
  261. package/dist/core/session-call-grant.js +524 -0
  262. package/dist/core/session-checkout.d.ts +3 -0
  263. package/dist/core/session-checkout.js +8 -3
  264. package/dist/core/session-policy-store.d.ts +14 -0
  265. package/dist/core/session-policy-store.js +16 -2
  266. package/dist/core/session-store.d.ts +18 -1
  267. package/dist/core/session-store.js +20 -4
  268. package/dist/core/session.d.ts +36 -4
  269. package/dist/core/shared-artifact-reads.d.ts +93 -0
  270. package/dist/core/shared-artifact-reads.js +94 -0
  271. package/dist/core/skill-grant.js +1 -1
  272. package/dist/core/skills-directory.d.ts +9 -45
  273. package/dist/core/skills-directory.js +9 -722
  274. package/dist/core/spend-account.js +3 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
  276. package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
  277. package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
  278. package/dist/core/store-contracts/file-history-store-contract.js +62 -2
  279. package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
  280. package/dist/core/store-contracts/grant-fixture.js +84 -0
  281. package/dist/core/store-contracts/session-repo-contract.js +18 -0
  282. package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
  283. package/dist/core/store-contracts/session-store-contract.js +211 -2
  284. package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
  285. package/dist/core/suspend-lane-reasons.d.ts +13 -0
  286. package/dist/core/suspend-lane-reasons.js +5 -0
  287. package/dist/core/synthetic-read-verdict.d.ts +5 -3
  288. package/dist/core/synthetic-read-verdict.js +1 -1
  289. package/dist/core/task-limits.d.ts +15 -0
  290. package/dist/core/task-notification.d.ts +33 -7
  291. package/dist/core/task-notification.js +34 -9
  292. package/dist/core/task-registry-agent.d.ts +1 -1
  293. package/dist/core/task-registry-agent.js +18 -7
  294. package/dist/core/task-registry-shared.d.ts +29 -4
  295. package/dist/core/task-registry-shared.js +7 -0
  296. package/dist/core/task-registry.d.ts +21 -1
  297. package/dist/core/task-registry.js +36 -9
  298. package/dist/core/task-result.d.ts +55 -1
  299. package/dist/core/task-spec.d.ts +17 -3
  300. package/dist/core/terminal-cause.d.ts +68 -5
  301. package/dist/core/tool-catalog-entries.js +1 -1
  302. package/dist/core/tool-check-reading.js +2 -1
  303. package/dist/core/tool-errors.js +1 -0
  304. package/dist/core/tool-list-grammar.d.ts +0 -47
  305. package/dist/core/tool-list-grammar.js +1 -75
  306. package/dist/core/tool-model-gate.d.ts +7 -11
  307. package/dist/core/tool-model-gate.js +5 -8
  308. package/dist/core/tool-name-aliases.js +2 -3
  309. package/dist/core/tool-name-readings.d.ts +4 -0
  310. package/dist/core/tool-name-readings.js +1 -0
  311. package/dist/core/tool-policy.d.ts +46 -4
  312. package/dist/core/tool-policy.js +47 -18
  313. package/dist/core/tool-result-store.d.ts +0 -24
  314. package/dist/core/tool-result-store.js +1 -36
  315. package/dist/core/tool-spec.d.ts +8 -4
  316. package/dist/core/untrusted-egress.js +2 -2
  317. package/dist/core/untrusted-text.d.ts +8 -0
  318. package/dist/core/untrusted-text.js +14 -0
  319. package/dist/core/user-attachment.d.ts +16 -1
  320. package/dist/core/user-attachment.js +42 -18
  321. package/dist/core/wiring-manifest.d.ts +4 -9
  322. package/dist/core/wiring-manifest.js +1 -1
  323. package/dist/core/workflow-journal-store.d.ts +55 -8
  324. package/dist/core/workflow-journal-store.js +34 -10
  325. package/dist/core/workflow-run-store-contract.js +56 -1
  326. package/dist/core/workflow-run-store.d.ts +43 -19
  327. package/dist/core/workflow-run-store.js +17 -2
  328. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  329. package/dist/engine/execution-env/node-execution-env.js +4 -0
  330. package/dist/engine/harness/agent-harness.d.ts +10 -5
  331. package/dist/engine/harness/agent-harness.js +12 -4
  332. package/dist/engine/harness/types.d.ts +18 -0
  333. package/dist/engine/llm/tool-turns.d.ts +1 -1
  334. package/dist/engine/llm/types.d.ts +5 -4
  335. package/dist/engine/session/memory-repo.d.ts +15 -3
  336. package/dist/engine/session/memory-repo.js +21 -3
  337. package/dist/engine/session/memory-storage.d.ts +5 -0
  338. package/dist/engine/session/memory-storage.js +8 -3
  339. package/dist/engine/session/repo-utils.d.ts +9 -0
  340. package/dist/engine/session/repo-utils.js +14 -0
  341. package/dist/engine/session/storage-base.d.ts +20 -7
  342. package/dist/engine/session/storage-base.js +13 -1
  343. package/dist/index.d.ts +39 -21
  344. package/dist/index.js +32 -17
  345. package/dist/internal/harness.d.ts +1 -1
  346. package/dist/internal/harness.js +1 -1
  347. package/dist/orchestration/run-workflow-tool.d.ts +13 -1
  348. package/dist/orchestration/run-workflow-tool.js +101 -32
  349. package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
  350. package/dist/orchestration/workflow-park-adoption.js +588 -323
  351. package/dist/orchestration/workflow-tree-id.d.ts +66 -0
  352. package/dist/orchestration/workflow-tree-id.js +66 -0
  353. package/dist/orchestration/workflow-types.d.ts +90 -11
  354. package/dist/orchestration/workflow-types.js +10 -1
  355. package/dist/orchestration/workflow.d.ts +30 -4
  356. package/dist/orchestration/workflow.js +424 -114
  357. package/dist/prompt-assembly/catalog/constitution.js +5 -1
  358. package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
  359. package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
  360. package/dist/prompt-assembly/catalog/environment.js +2 -2
  361. package/dist/prompt-assembly/catalog/events.d.ts +16 -0
  362. package/dist/prompt-assembly/catalog/events.js +2 -0
  363. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
  364. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
  365. package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
  366. package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
  367. package/dist/prompt-assembly/catalog/schema.js +2 -0
  368. package/dist/prompt-assembly/catalog/sections.js +3 -14
  369. package/dist/prompt-assembly/event-registry.js +2 -0
  370. package/dist/prompt-assembly/select.js +1 -0
  371. package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
  372. package/dist/prompt-assembly/tool-catalog.js +21 -7
  373. package/dist/prompt-assembly/types.d.ts +3 -0
  374. package/dist/prompts/default.d.ts +4 -1
  375. package/dist/prompts/default.js +6 -0
  376. package/dist/stores/file/checkpoint-store.d.ts +11 -10
  377. package/dist/stores/file/checkpoint-store.js +36 -10
  378. package/dist/stores/file/file-history-store.d.ts +6 -0
  379. package/dist/stores/file/file-history-store.js +21 -4
  380. package/dist/stores/file/fs-atomic.d.ts +1 -1
  381. package/dist/stores/file/index.d.ts +14 -4
  382. package/dist/stores/file/index.js +21 -5
  383. package/dist/stores/file/process-anchor.d.ts +9 -1
  384. package/dist/stores/file/session-policy-store.js +2 -17
  385. package/dist/stores/file/session-store.d.ts +27 -0
  386. package/dist/stores/file/session-store.js +81 -9
  387. package/dist/stores/file/workflow-journal-store.d.ts +14 -4
  388. package/dist/stores/file/workflow-journal-store.js +32 -24
  389. package/dist/stores/file/workflow-run-store.d.ts +15 -4
  390. package/dist/stores/file/workflow-run-store.js +76 -0
  391. package/dist/tools/artifact/artifact-tool.d.ts +10 -3
  392. package/dist/tools/artifact/artifact-tool.js +16 -1
  393. package/dist/tools/fs/bash-program-position.d.ts +10 -4
  394. package/dist/tools/fs/bash-program-position.js +11 -8
  395. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
  396. package/dist/tools/fs/bash-readonly-classifier.js +9 -2
  397. package/dist/tools/fs/find-actions.d.ts +30 -16
  398. package/dist/tools/fs/find-actions.js +272 -19
  399. package/dist/tools/fs/fs-bash.js +8 -5
  400. package/dist/tools/fs/fs-shared.d.ts +0 -29
  401. package/dist/tools/fs/fs-shared.js +0 -5
  402. package/dist/tools/fs/fs-write.js +2 -1
  403. package/dist/tools/fs/read-deny.d.ts +6 -1
  404. package/dist/tools/fs/read-deny.js +6 -1
  405. package/dist/tools/fs/read-floor.d.ts +6 -0
  406. package/dist/tools/fs/read-floor.js +5 -1
  407. package/dist/tools/fs/removal-actions.d.ts +43 -0
  408. package/dist/tools/fs/removal-actions.js +25 -0
  409. package/dist/tools/fs/removal-targets.d.ts +2 -21
  410. package/dist/tools/fs/removal-targets.js +2 -3
  411. package/dist/tools/fs/safety.d.ts +37 -1
  412. package/dist/tools/fs/safety.js +52 -0
  413. package/dist/tools/fs/shell-climb.d.ts +46 -0
  414. package/dist/tools/fs/shell-climb.js +79 -0
  415. package/dist/tools/fs/shell-read-check.js +47 -19
  416. package/dist/tools/fs/shell-read-establish.js +36 -22
  417. package/dist/tools/fs/shell-read-judge.d.ts +10 -2
  418. package/dist/tools/fs/shell-read-judge.js +4 -4
  419. package/dist/tools/fs/shell-read-plan.d.ts +3 -0
  420. package/dist/tools/fs/shell-read-plan.js +1 -1
  421. package/dist/tools/fs/shell-read-workdir.js +3 -2
  422. package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
  423. package/dist/tools/fs/shell-read-write-targets.js +3 -0
  424. package/package.json +2 -2
  425. package/test/export-surface.snapshot.json +173 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core-stores-sql@7.71.1.json +40 -0
  428. package/wire-changes/core@7.71.0.json +5827 -0
  429. package/wire-changes/core@7.71.1.json +118 -0
  430. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  431. package/wire-changes/mods-kernel@7.71.1.json +40 -0
  432. package/wire-changes/primitives@7.71.0.json +473 -0
  433. package/wire-changes/primitives@7.71.1.json +40 -0
  434. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  435. package/wire-changes/wiki-gate@7.71.1.json +40 -0
  436. package/dist/core/frontmatter-fence.d.ts +0 -10
  437. package/dist/core/frontmatter-fence.js +0 -6
  438. package/dist/core/permission-rule-syntax.d.ts +0 -46
  439. package/dist/core/permission-rule-syntax.js +0 -52
@@ -67,6 +67,21 @@ export interface TaskLimits {
67
67
  * is this allowed to be", so it is the axis of last resort.
68
68
  */
69
69
  maxWalltimeMs?: number;
70
+ /**
71
+ * How long a ONE-SHOT submission's ending ({@link TaskSpec.oneShot}) waits for the loop-type background tasks it started (agents,
72
+ * continued agents, workflow runs), in MILLISECONDS, counted from the ending's first wait. Absent ⇒ 600 000 (the reference's
73
+ * default for the same wait). `0` ⇒ no ceiling of its own: the ending waits as long as the run's walltime window and its
74
+ * cancel allow (the reference's `0`). It takes effect only on a one-shot run (any other run has no such wait, so a deployment may
75
+ * set it on every task); beside `maxWalltimeMs` the two clocks run side by side and whichever comes first ends the wait.
76
+ *
77
+ * When it is reached the wait stops, the answer stands as the result and the run's end handles each task as it always does (a
78
+ * task-scoped agent stopped with the run, anything else left to its own lifetime) — and says so once, naming each task:
79
+ * `task.wait_ceiling_reached`.
80
+ *
81
+ * Refused (`config.limit_invalid`), never folded to the default: not a finite number; negative; above 2 147 483 647 (a timer
82
+ * cannot hold it).
83
+ */
84
+ oneShotWaitCeilingMs?: number;
70
85
  /**
71
86
  * design/119 #2: per-REQUEST output-token cap (the provider `max_tokens` / `max_completion_tokens`
72
87
  * field). NOT a budget — it bounds each model reply, while {@link maxTokens} bounds the whole slice.
@@ -2,6 +2,8 @@ import type { MailboxAppendMessage, MailboxStore } from "./mailbox-store.js";
2
2
  import { type EngineNotice } from "./engine-notice.js";
3
3
  import type { DelegationUnreviewed } from "./classifier-unavailable-arm.js";
4
4
  import type { TaskEvent } from "./task-event.js";
5
+ import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
6
+ export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
5
7
  /** The TERMINAL words of {@link TaskNotificationStatus}: the one table every "is this frame a completion?"
6
8
  * reading asks, exported as a value so a consumer outside the package reads these words rather than its own list. */
7
9
  export declare const TASK_NOTIFICATION_TERMINAL_STATUSES: readonly ["completed", "failed", "killed", "cancelled"];
@@ -100,6 +102,12 @@ export interface TaskNotificationPayload {
100
102
  * consumers must tolerate unknown values (a future "timeout" etc. is not breaking) and fall back
101
103
  * to default copy. */
102
104
  stoppedBy?: "user" | "parent" | "system" | (string & {});
105
+ /** Present only as `true`, minted by the engine: this frame must not start a turn of an idle session on its own — a host that
106
+ * wakes an idle session for a completion keeps this one for the session's next turn that something else starts (a person's
107
+ * message, a still-open run). For the late result of an EXTERNAL agent-to-agent peer: an outside party must not be able to
108
+ * trigger a model call while nobody is there. The host reads this bit and never infers it from the lane. No lane of this
109
+ * engine version mints it yet (the peer-task lane will); ABSENT = handle the frame as before. */
110
+ noWake?: true;
103
111
  summary: string;
104
112
  /** RB-386① — the failure reason DIGEST on a `status:"failed"` terminal notification
105
113
  * (background_agent lanes): the same bounded text the settle stored as the registry row's `error`
@@ -814,8 +822,11 @@ export declare class DeliveryObligations {
814
822
  /** The terminal frames already counted (their dedup keys): a repeat of one settles nothing more. */
815
823
  private readonly counted;
816
824
  private readonly wakers;
817
- /** When the waiting stops whatever is still owed (monotonic) — set by the first wait, never moved. */
825
+ /** When the waiting stops whatever is still owed (monotonic) — set by the first wait, never moved; `null` once a first wait ran
826
+ * with no ceiling of its own. */
818
827
  private waitDeadline;
828
+ /** The wait ended at its ceiling with something still owed — the one fact `task.wait_ceiling_reached` is minted on. */
829
+ private stoppedAtCeiling;
819
830
  owe(task: Pick<TaskNotificationPayload, "task_id" | "task_type">): void;
820
831
  discharge(frame: TaskNotificationPayload): void;
821
832
  /** A cycle whose terminal frame was voided before it reached the sink (a continuation dropped its deferred frame) owes
@@ -831,13 +842,29 @@ export declare class DeliveryObligations {
831
842
  nextDischarge(signal: AbortSignal, withinMs: number): Promise<void>;
832
843
  /**
833
844
  * Wait out the debt the way a one-shot ending does: wake by wake, while something is owed, `keepWaiting()` holds (no
834
- * input is queued for the run yet, the run is not ending) and `signal` has not aborted — and never past the reference's
835
- * print-mode ceiling, counted from this book's first wait: `mFt` (cli309.js:260064), the default of
836
- * `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS` (cli309.js:263180), taken as a constant. `onInput` subscribes a wake to every
837
- * input that reaches the run's queues meanwhile (a steer, a child's message, any engine note) — the wait re-checks.
845
+ * input is queued for the run yet, the run is not ending) and `signal` has not aborted — and never past `ceilingMs`, counted
846
+ * from this book's first wait (`0` = no ceiling of its own: the walltime and the cancel still end it). The reference's same
847
+ * wait reads `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS` (cli321.js:282495), its default `JQt` (cli321.js:282481) = 600 000, and its
848
+ * `0` is (cli321.js:312481) "wait indefinitely"; the host's knob here is {@link oneShotWaitCeilingOf}. `onInput` subscribes a wake to every
849
+ * input that reaches the run's queues meanwhile (a steer, a child's message, any engine note) — the wait re-checks. A wait that
850
+ * ends at the ceiling with debt still owed is remembered ({@link stoppedWaitingAtCeiling}).
851
+ *
852
+ * Answers what ended THIS wait, read at the check that ended it, in the order the loop asks: nothing was owed (`"nothing_owed"`),
853
+ * the debt was paid (`"discharged"`), `keepWaiting()` turned false (`"input"`), `signal` aborted while debt was still owed
854
+ * (`"signal"`), or the ceiling (`"ceiling"`).
838
855
  */
839
- waitOut(signal: AbortSignal, keepWaiting: () => boolean, onInput: (wake: () => void) => () => void): Promise<void>;
856
+ waitOut(signal: AbortSignal, keepWaiting: () => boolean, onInput: (wake: () => void) => () => void, ceilingMs: number): Promise<OneShotWaitEnd>;
857
+ /** Did this book's last wait stop at its ceiling with something still owed, and was nothing admitted since? (What is still owed
858
+ * is {@link pending}.) */
859
+ get stoppedWaitingAtCeiling(): boolean;
840
860
  }
861
+ /** What ended one {@link DeliveryObligations.waitOut}. */
862
+ export type OneShotWaitEnd = "nothing_owed" | "discharged" | "input" | "signal" | "ceiling";
863
+ /** The ceiling a one-shot ending waits under: the host's `limits.oneShotWaitCeilingMs` (judged at the door; `0` = none of its
864
+ * own), else {@link ONE_SHOT_WAIT_CEILING_DEFAULT_MS}. */
865
+ export declare const oneShotWaitCeilingOf: (limits: {
866
+ readonly oneShotWaitCeilingMs?: number;
867
+ } | undefined) => number;
841
868
  /** The book a run's ending waits on: a one-shot submission's lane book ({@link DeliveryObligations.waitOut}); any other run waits on none. */
842
869
  export declare const oneShotEndingBook: (oneShot: boolean | undefined, book: DeliveryObligations) => DeliveryObligations | undefined;
843
870
  export declare function bindDeliveryObligations(sink: object, book: DeliveryObligations): void;
@@ -1319,4 +1346,3 @@ export declare class SystemInjectionQueue<TPayload = TaskNotificationPayload> {
1319
1346
  subscribe(listener: (item: SystemInjection<TPayload>) => void): () => void;
1320
1347
  get size(): number;
1321
1348
  }
1322
- export {};
@@ -9,6 +9,8 @@ import { deliverEngineNotice } from "./engine-notice.js";
9
9
  import { isAutoModeFallbackCause } from "./auto-mode.js";
10
10
  import { sameOccupant } from "../engine/session/repo-utils.js";
11
11
  import { codedRefusal } from "./thrown-value.js";
12
+ import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
13
+ export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
12
14
  export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(["completed", "failed", "killed", "cancelled"]);
13
15
  export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate", "refused"]);
14
16
  export function isNotificationInjectionOutcome(value) {
@@ -305,6 +307,8 @@ const SPAWN_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
305
307
  function malformedFacet(f) {
306
308
  if (f["spawnName"] !== undefined && (typeof f["spawnName"] !== "string" || !SPAWN_NAME_RE.test(f["spawnName"])))
307
309
  return "spawnName outside the spawn-name grammar";
310
+ if (f["noWake"] !== undefined && f["noWake"] !== true)
311
+ return "noWake is not true";
308
312
  if (f["handback"] !== undefined && !(typeof f["handback"] === "string" && HANDBACK_STATES.includes(f["handback"])))
309
313
  return "handback outside its closed set";
310
314
  const u = f["unreviewed"];
@@ -372,7 +376,9 @@ export class DeliveryObligations {
372
376
  counted = new Set();
373
377
  wakers = new Set();
374
378
  waitDeadline;
379
+ stoppedAtCeiling = false;
375
380
  owe(task) {
381
+ this.stoppedAtCeiling = false;
376
382
  const lane = taskNotificationLaneKey(task);
377
383
  this.owed.set(lane, (this.owed.get(lane) ?? 0) + 1);
378
384
  }
@@ -408,10 +414,11 @@ export class DeliveryObligations {
408
414
  if (this.owed.size === 0 || signal.aborted || withinMs <= 0)
409
415
  return Promise.resolve();
410
416
  return new Promise((resolve) => {
411
- const timer = setTimeout(() => wake(), withinMs);
412
- timer.unref?.();
417
+ const timer = Number.isFinite(withinMs) ? setTimeout(() => wake(), Math.min(withinMs, 2_147_483_647)) : undefined;
418
+ timer?.unref?.();
413
419
  const wake = () => {
414
- clearTimeout(timer);
420
+ if (timer !== undefined)
421
+ clearTimeout(timer);
415
422
  this.wakers.delete(wake);
416
423
  signal.removeEventListener("abort", wake);
417
424
  resolve();
@@ -420,21 +427,39 @@ export class DeliveryObligations {
420
427
  signal.addEventListener("abort", wake, { once: true });
421
428
  });
422
429
  }
423
- async waitOut(signal, keepWaiting, onInput) {
430
+ async waitOut(signal, keepWaiting, onInput, ceilingMs) {
431
+ this.stoppedAtCeiling = false;
424
432
  if (this.owed.size === 0)
425
- return;
426
- this.waitDeadline ??= performance.now() + ONE_SHOT_WAIT_CEILING_MS;
433
+ return "nothing_owed";
434
+ if (this.waitDeadline === undefined)
435
+ this.waitDeadline = ceilingMs > 0 ? performance.now() + ceilingMs : null;
436
+ const deadline = this.waitDeadline;
427
437
  const unsubscribe = onInput(() => this.wake());
428
438
  try {
429
- while (this.owed.size > 0 && keepWaiting() && !signal.aborted && performance.now() < this.waitDeadline)
430
- await this.nextDischarge(signal, this.waitDeadline - performance.now());
439
+ for (;;) {
440
+ if (this.owed.size === 0)
441
+ return "discharged";
442
+ if (!keepWaiting())
443
+ return "input";
444
+ if (signal.aborted)
445
+ return "signal";
446
+ const left = deadline === null ? Infinity : deadline - performance.now();
447
+ if (left <= 0) {
448
+ this.stoppedAtCeiling = true;
449
+ return "ceiling";
450
+ }
451
+ await this.nextDischarge(signal, left);
452
+ }
431
453
  }
432
454
  finally {
433
455
  unsubscribe();
434
456
  }
435
457
  }
458
+ get stoppedWaitingAtCeiling() {
459
+ return this.stoppedAtCeiling;
460
+ }
436
461
  }
437
- const ONE_SHOT_WAIT_CEILING_MS = 600_000;
462
+ export const oneShotWaitCeilingOf = (limits) => limits?.oneShotWaitCeilingMs ?? ONE_SHOT_WAIT_CEILING_DEFAULT_MS;
438
463
  export const oneShotEndingBook = (oneShot, book) => (oneShot === true ? book : undefined);
439
464
  const LANE_OBLIGATIONS = new WeakMap();
440
465
  export function bindDeliveryObligations(sink, book) {
@@ -347,7 +347,7 @@ export declare function ownerSweepTakes(handle: RegisteredTaskHandle, access: Ta
347
347
  export declare function abortBackgroundAgentsForOwnerLane(core: DurableAgentCore, access: TaskAccess, opts?: {
348
348
  skipSessionScoped?: boolean;
349
349
  sessionScopedOnly?: boolean;
350
- }): number;
350
+ }, runEnd?: import("./member-outcome.js").RunEndCause): number;
351
351
  /** Name resolution over the caller-visible background_agent rows
352
352
  * (sema's single-lane subset: no teammate/name-registry branches).
353
353
  *
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
+ import { isCheckpointRowUnreadable } from "./checkpoint-queries.js";
2
3
  import { describeRejectedValue } from "./tool-search-setting.js";
3
4
  import { receiveRetentionPolicy } from "./retention-policy.js";
4
5
  import { commitCompletionIdIfEmpty, completionIdCandidate, mintCompletionId } from "./completion-id.js";
@@ -459,6 +460,7 @@ export function registerBackgroundAgentLane(core, input) {
459
460
  ...(input.parentSessionId !== undefined ? { parentSessionId: input.parentSessionId } : {}),
460
461
  ...(input.rootSessionId !== undefined ? { rootSessionId: input.rootSessionId } : {}),
461
462
  ...(input.crossBoundaryTree !== undefined ? { crossBoundaryTree: input.crossBoundaryTree } : {}),
463
+ ...(input.delegationTree !== undefined ? { delegationTree: input.delegationTree } : {}),
462
464
  ...(input.deliveryChannel !== undefined ? { channelState: input.deliveryChannel } : {}),
463
465
  ...(input.retainedContinuation !== undefined ? { retainedContinuation: input.retainedContinuation } : {}),
464
466
  ...(input.owner !== undefined ? { owner: input.owner } : {}),
@@ -631,8 +633,8 @@ export async function claimParkedAgentLane(stores, handle, access) {
631
633
  try {
632
634
  cp = (await stores.checkpointStore.get(token));
633
635
  }
634
- catch {
635
- return { ok: false, reason: "store_unreachable" };
636
+ catch (e) {
637
+ return { ok: false, reason: isCheckpointRowUnreadable(e) ? "binding_broken" : "store_unreachable" };
636
638
  }
637
639
  if (cp === null || cp.sessionId !== row.sessionId)
638
640
  return { ok: false, reason: "binding_broken" };
@@ -892,7 +894,7 @@ export function settleBackgroundAgentLane(core, id, outcome) {
892
894
  backfilled = true;
893
895
  }
894
896
  if (outcome.leg !== undefined && handle.outcome?.refused === undefined) {
895
- const withLeg = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, outcome.leg);
897
+ const withLeg = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, outcome.leg, runEndOf(handle));
896
898
  if (handle.outcome === undefined || withLeg.refused !== undefined) {
897
899
  handle.outcome = withLeg;
898
900
  backfilled = true;
@@ -927,7 +929,7 @@ export function settleBackgroundAgentLane(core, id, outcome) {
927
929
  }
928
930
  if (outcome.result !== undefined)
929
931
  handle.result = outcome.result;
930
- handle.outcome = backgroundAgentOutcomeOf(outcome.status, outcome.status === "failed" ? outcome.errorCode : undefined, handle.stoppedBy, outcome.leg);
932
+ handle.outcome = backgroundAgentOutcomeOf(outcome.status, outcome.status === "failed" ? outcome.errorCode : undefined, handle.stoppedBy, outcome.leg, outcome.status === "killed" ? runEndOf(handle) : undefined);
931
933
  if (outcome.resultFull !== undefined)
932
934
  handle.resultFull = outcome.resultFull;
933
935
  if (outcome.status === "killed" && outcome.result !== undefined && outcome.result !== "") {
@@ -963,6 +965,9 @@ export function settleBackgroundAgentLane(core, id, outcome) {
963
965
  }, ["parkedCheckpointToken", "parkClaimId", "parkedAt"]);
964
966
  return outcome.status;
965
967
  }
968
+ function runEndOf(handle) {
969
+ return handle.stopRunEnd !== undefined ? { cause: handle.stopRunEnd } : undefined;
970
+ }
966
971
  export function ownerSweepTakes(handle, access, opts) {
967
972
  if (handle.type !== "background_agent" || handle.status !== "running" || !canAccess(handle, access))
968
973
  return false;
@@ -972,8 +977,13 @@ export function ownerSweepTakes(handle, access, opts) {
972
977
  return false;
973
978
  return true;
974
979
  }
975
- export function abortBackgroundAgentsForOwnerLane(core, access, opts) {
980
+ export function abortBackgroundAgentsForOwnerLane(core, access, opts, runEnd) {
976
981
  let aborted = 0;
982
+ if (runEnd !== undefined) {
983
+ for (const handle of [...core.handles.values()])
984
+ if (ownerSweepTakes(handle, access, opts) && !handle.abort.signal.aborted)
985
+ core.markRunEnd(handle.id, runEnd);
986
+ }
977
987
  for (const handle of core.handles.values()) {
978
988
  if (!ownerSweepTakes(handle, access, opts))
979
989
  continue;
@@ -1221,6 +1231,7 @@ export async function reviveBackgroundAgentLane(core, id, access, abort) {
1221
1231
  handle.resultIsPartial = undefined;
1222
1232
  handle.outcome = undefined;
1223
1233
  handle.stopSource = undefined;
1234
+ handle.stopRunEnd = undefined;
1224
1235
  handle.stoppedBy = undefined;
1225
1236
  handle.completionId = undefined;
1226
1237
  handle.terminalNotified = undefined;
@@ -1614,7 +1625,7 @@ export async function stopBackgroundAgentLane(core, handle) {
1614
1625
  core.markStopSource(handle.id, "parent");
1615
1626
  handle.status = "killed";
1616
1627
  handle.stoppedBy = handle.stopSource ?? "parent";
1617
- handle.outcome = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, undefined);
1628
+ handle.outcome = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, undefined, runEndOf(handle));
1618
1629
  stampActivity(handle);
1619
1630
  mintCompletionId(handle);
1620
1631
  handle.parkedCheckpointToken = undefined;
@@ -1685,7 +1696,7 @@ export async function stopBackgroundAgentLane(core, handle) {
1685
1696
  handle.abort.abort();
1686
1697
  handle.status = "killed";
1687
1698
  handle.stoppedBy = handle.stopSource ?? "parent";
1688
- handle.outcome = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, undefined);
1699
+ handle.outcome = backgroundAgentOutcomeOf("killed", undefined, handle.stoppedBy, undefined, runEndOf(handle));
1689
1700
  stampActivity(handle);
1690
1701
  mintCompletionId(handle);
1691
1702
  handle.notify = undefined;
@@ -7,7 +7,21 @@ import type { TaskNotificationPayload } from "./task-notification.js";
7
7
  import type { ExtensionRequester } from "./task-event.js";
8
8
  import type { TaskArtifactSeat } from "./tool-result-store.js";
9
9
  import type { AssertAllKeysHandled } from "./ask-origin.js";
10
- export type SemaTaskType = "background_bash" | "workflow" | "background_agent" | "monitor";
10
+ /** The kinds of background task the registry holds, as ONE list: {@link SemaTaskType} is derived from it, so a consumer that
11
+ * validates a task kind it read off the wire (a stored row, a listing, a frame) iterates the same source the type is. */
12
+ export declare const SEMA_TASK_TYPES: readonly ["background_bash", "workflow", "background_agent", "monitor"];
13
+ export type SemaTaskType = (typeof SEMA_TASK_TYPES)[number];
14
+ /** The handle prefix of each kind: a task id is this one lowercase letter followed by 16 lowercase hex digits (8 random bytes) —
15
+ * the table `TaskRegistry.mintTaskId` mints with, the only one (a reader that tells a kind by its handle reads it here, never a
16
+ * copy). Total over {@link SEMA_TASK_TYPES} ({@link TaskHandlePrefixesCoverEveryType}); no two kinds share a letter. */
17
+ export declare const SEMA_TASK_HANDLE_PREFIXES: Readonly<{
18
+ readonly background_bash: "b";
19
+ readonly workflow: "w";
20
+ readonly background_agent: "a";
21
+ readonly monitor: "m";
22
+ }>;
23
+ /** Compile-time fence: `never` while every task kind has a handle prefix. */
24
+ export type TaskHandlePrefixesCoverEveryType = AssertAllKeysHandled<Exclude<SemaTaskType, keyof typeof SEMA_TASK_HANDLE_PREFIXES>>;
11
25
  /** design/134 §3.3 (R3): WHO initiated a kill — recorded at the initiation site (first-marker-wins),
12
26
  * because the settle-side then/catch context has already lost it. OPEN ENUM on the wire, now in the
13
27
  * TYPE too (`(string & {})` keeps literal completion while admitting future values like "timeout"
@@ -314,13 +328,16 @@ export interface DurableAgentLane {
314
328
  * flush success); past the ceiling the lane is abandoned loudly instead of retrying forever. */
315
329
  redrives?: number;
316
330
  }
317
- /** What a background agent's row keeps of the store its child session lives in: that store's `acquire` (structural, so any
318
- * session store fits — the type-only import is erased, the one-way import rule at the top is untouched). */
319
- export type ChildSessionStore = Pick<import("./session.js").SessionStore, "acquire">;
331
+ /** What a background agent's row keeps of the store its child session lives in: that store's `acquire`, the by-id read a reader of the
332
+ * session judges it by, and the cache drop of a row it was refused (structural, so any session store fits — the type-only import is
333
+ * erased, the one-way import rule at the top is untouched). */
334
+ export type ChildSessionStore = Pick<import("./session.js").SessionStore, "acquire" | "headOf" | "forget">;
320
335
  export interface BackgroundAgentTaskHandle extends SemaTaskHandle {
321
336
  type: "background_agent";
322
337
  /** The spawning tree's cross-boundary token ({@link RegisterBackgroundAgentInput.crossBoundaryTree}), compared by identity. */
323
338
  crossBoundaryTree?: object;
339
+ /** The tree the child runs in ({@link RegisterBackgroundAgentInput.delegationTree}). */
340
+ delegationTree?: import("./runner/delegation-owner.js").DelegationOwnerSeat;
324
341
  /** design/115 P3: aborting this cancels the child run (TaskStop / parent teardown). */
325
342
  abort: AbortController;
326
343
  /** Lineage axes, declared (registration always spread them into the handle; readers used
@@ -480,6 +497,9 @@ export interface BackgroundAgentTaskHandle extends SemaTaskHandle {
480
497
  * at the kill INITIATION site, strictly BEFORE the abort/status flip (once the handle leaves "running"
481
498
  * the marker is refused and attribution falls back to "system"). First-marker-wins. */
482
499
  stopSource?: StopSource;
500
+ /** What ended the run whose run-end sweep wrote {@link stopSource} (written with it, by the same mark; cleared with it): the
501
+ * settle that lands `killed` under that marker puts it on the outcome (`MemberOutcome.runEnd`). */
502
+ stopRunEnd?: import("./member-outcome.js").RunEndCause;
483
503
  /** The LANDED attribution — set exactly when the handle goes `killed`, never rewritten afterwards
484
504
  * (first-writer-wins, same discipline as the terminal status itself). Absent on natural completion/failure. */
485
505
  stoppedBy?: StopSource;
@@ -906,6 +926,8 @@ export interface RegistryCore {
906
926
  handles: Map<string, RegisteredTaskHandle>;
907
927
  mintTaskId(type: SemaTaskType): string;
908
928
  markStopSource(id: string, source: StopSource): void;
929
+ /** What ended the run, on a running background agent its run-end sweep listed ({@link BackgroundAgentTaskHandle.stopRunEnd}). */
930
+ markRunEnd(id: string, cause: import("./member-outcome.js").RunEndCause): void;
909
931
  notifyTerminalOnce(handle: BackgroundBashTaskHandle | MonitorTaskHandle | BackgroundAgentTaskHandle, send: () => void): void;
910
932
  pokeBgQuiescence(owner: string | undefined): void;
911
933
  /** Re-run every pending yield `drained()` check (a transition that is not an agent's — a workflow run's end). */
@@ -1115,6 +1137,9 @@ export interface RegisterBackgroundAgentInput extends TaskAccess {
1115
1137
  /** The spawning tree's cross-boundary token (`RunInternals.crossBoundaryTree`, the tree the child joins): a poll of this handle
1116
1138
  * from a leg of the SAME tree moves nothing across the device boundary — the child's bits are already in that tree. */
1117
1139
  crossBoundaryTree?: object;
1140
+ /** The tree the child runs in (its run's `RunInternals.delegationOwner` seat — a revival's, the tree it was born in): a message to
1141
+ * the running or retained child is delivered only from that tree ({@link TaskRegistry.backgroundAgentTree}). In-process only. */
1142
+ delegationTree?: import("./runner/delegation-owner.js").DelegationOwnerSeat;
1118
1143
  /** design/153 §7.2d (件3c) — parked-resume registration shape: the handle is born PARKED (the
1119
1144
  * pre-consume window keeps the live face's checkpoint arbitration; the consume flip
1120
1145
  * {@link TaskRegistry.adoptParkedResume} is the only path to running). Pass the ticket's token
@@ -6,6 +6,13 @@ import { boundedRedactedSummary } from "./untrusted-egress.js";
6
6
  import { clipWithFilePointer, OUTPUT_BUDGET_MIN_CHARS } from "./tool-errors.js";
7
7
  import { resolveEnvBudget } from "./env-budget.js";
8
8
  import { isOccupantToken, sameOccupant } from "../engine/session/repo-utils.js";
9
+ export const SEMA_TASK_TYPES = Object.freeze(["background_bash", "workflow", "background_agent", "monitor"]);
10
+ export const SEMA_TASK_HANDLE_PREFIXES = Object.freeze({
11
+ background_bash: "b",
12
+ workflow: "w",
13
+ background_agent: "a",
14
+ monitor: "m",
15
+ });
9
16
  export function monotonicNow() {
10
17
  return performance.now();
11
18
  }
@@ -3,15 +3,17 @@ import type { ToolEffect } from "./types.js";
3
3
  import { type BackgroundHardKillOutcome, type BackgroundShellCapability, type BackgroundShellId } from "./background-shell.js";
4
4
  import type { BoundaryLegsGiven } from "./cross-boundary-taint.js";
5
5
  import type { WorkflowRunStore } from "./workflow-run-store.js";
6
+ import type { WorkflowAgentStopReceipt } from "../orchestration/workflow-types.js";
6
7
  import { type BackgroundAgentRecord, type BackgroundAgentSettledStatus, type BackgroundAgentStore } from "./background-agent-store.js";
7
8
  import type { TaskNotificationPayload } from "./task-notification.js";
8
9
  import type { ExtensionRequester } from "./task-event.js";
9
10
  import { type TaskArtifactSeat } from "./tool-result-store.js";
10
11
  import { type SemaTaskType, type StopSource, type SemaTaskStatus, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type SemaTaskHandle, type TaskAccess, type BackgroundAgentTaskHandle, type MonitorTimers, type RegisterMonitorInput, type RegisterWorkflowInput, canAccessWorkflowRun, clipTaskOutput, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, type OccupantMount } from "./task-registry-shared.js";
11
- export { normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
12
+ export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
12
13
  export type { ParkedClaimTicket, ParkedClaimRollback, RegisterBackgroundAgentInput, BackgroundUnyieldableReason, BackgroundYieldLane, BackgroundYieldOptions, BackgroundYieldReport } from "./task-registry-shared.js";
13
14
  import type { RegisterBackgroundAgentInput, ParkedClaimTicket, ParkedClaimRollback, ChildSessionStore, LandedAgentTerminal, BackgroundYieldOptions, BackgroundYieldReport } from "./task-registry-shared.js";
14
15
  import type { ChildSessionAnchor } from "./task-registry-agent.js";
16
+ import type { RunEndCause } from "./member-outcome.js";
15
17
  import { type DelegationOccupant, type DelegationRowAddress } from "./task-registry-agent.js";
16
18
  import { type AgentStateSource } from "./agent-state.js";
17
19
  import type { CheckpointSeat } from "./checkpoint-seat.js";
@@ -180,6 +182,9 @@ export interface AccessibleTaskRow {
180
182
  * revive projection needs it so a revive frame's `startedAt` anchors the ROW, not the wake call. */
181
183
  createdAt?: number;
182
184
  }
185
+ export declare function abortBackgroundAgentsAtRunEnd(registry: TaskRegistry, access: TaskAccess, opts: {
186
+ skipSessionScoped?: boolean;
187
+ }, runEnd: RunEndCause | undefined): number;
183
188
  export declare class TaskRegistry {
184
189
  private handles;
185
190
  /** observers of the design/129 session terminal anchor — `reapSessionBackground`
@@ -756,6 +761,9 @@ export declare class TaskRegistry {
756
761
  * agent of another tree, a workflow run, an id no live handle answers (a durable row read back) — is content from beyond the
757
762
  * boundary on a poll and nothing on a stop. */
758
763
  boundaryLegsOf(id: string, access: TaskAccess, verb: "output" | "stop", tree: object): BoundaryLegsGiven;
764
+ /** The tree a background agent runs in, off the handle `id` resolves to under `access` ({@link RegisterBackgroundAgentInput.delegationTree});
765
+ * `undefined` for an agent registered with none (a call with no seat: an anonymous tree's). */
766
+ backgroundAgentTree(id: string, access: TaskAccess): import("./runner/delegation-owner.js").DelegationOwnerSeat | undefined;
759
767
  /** What a session is still owed when one of its legs ends: each of its {@link liveTasks} delivers into a LATER leg of the session —
760
768
  * another tree — so each is read as that leg's poll of it ({@link boundaryLegsOf}, `"output"`, under a tree no handle recorded). */
761
769
  owedDeliveries(access: TaskAccess): BoundaryLegsGiven[];
@@ -763,6 +771,18 @@ export declare class TaskRegistry {
763
771
  * occupant is the handle's); a handle of the same id over another store is another run. */
764
772
  private heldWorkflow;
765
773
  pollTask(id: string, access: TaskAccess, opts?: TaskPollOptions): Promise<UnifiedTaskResult>;
774
+ /**
775
+ * #4760 — stop ONE member of a workflow run, by the member's call key (`WorkflowAgentRun.callKey`); the run goes on. The run held
776
+ * in this process answers through its own `stopAgent` (`stoppedBy` defaults to `parent`; a service passes `user` for a person). A
777
+ * run not held here, read from `workflowStore`: one it records `running` is another process's (`not_local`); one that has ended
778
+ * answers `already_terminal` (its status); none the caller can see, or a handle that does not answer member stops: `not_found`. A
779
+ * store read that throws rejects (an outage is not "no such run"); a run registered here while the store was read answers live.
780
+ * Stopping a whole run (one that waits on an approval included) is {@link stopTask}'s.
781
+ */
782
+ stopWorkflowAgent(runId: string, callKey: string, access: TaskAccess, opts?: {
783
+ readonly stoppedBy?: StopSource;
784
+ readonly workflowStore?: WorkflowRunStore;
785
+ }): Promise<WorkflowAgentStopReceipt>;
766
786
  stopTask(id: string, access: TaskAccess, opts?: TaskStopOptions): Promise<UnifiedTaskResult>;
767
787
  /** S2b — bounded delivery-confirmation wait (see deliverToRunningAgent). Test-tunable. */
768
788
  deliverConfirmTimeoutMs: number;
@@ -11,8 +11,8 @@ import { readExtensionRequester } from "./extension-requester.js";
11
11
  import { persistTaskArtifact, taskArtifactOriginOf } from "./tool-result-store.js";
12
12
  import { registerMonitorLane, pollMonitorLane, stopMonitorLane } from "./task-registry-monitor.js";
13
13
  import { registerWorkflowLane, pollWorkflowLane, stopWorkflowLane, workflowParkWaitsOf } from "./task-registry-workflow.js";
14
- import { taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, dropFactsOf, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, isLiveSessionResidentAgent, DURABLE_AGENT_HANDLE_RE, activityStamp, stampActivity, occupantStamp, callOccupant, } from "./task-registry-shared.js";
15
- export { normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
14
+ import { taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, dropFactsOf, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, isLiveSessionResidentAgent, DURABLE_AGENT_HANDLE_RE, SEMA_TASK_HANDLE_PREFIXES, activityStamp, stampActivity, occupantStamp, callOccupant, } from "./task-registry-shared.js";
15
+ export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
16
16
  import { attachYieldLegLane, requestYieldLane, yieldCovers, yieldPopulationLane, yieldPopulationLeftRunning, yieldPopulationWrites, yieldRequested } from "./task-registry-yield.js";
17
17
  import { TASK_STOP_TOOL_NAME, TASK_STOP_MISSING_ID_MESSAGE, TASK_STOP_PARAMS, TASK_STOP_DESCRIPTION, resolveTaskIdArg } from "./task-tool-shape.js";
18
18
  import { durableAgentArmedLane, durableAgentRowProbeLane, durableAgentRowFactsLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, announceLandedAgentTerminal, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, childSessionAnchorOf, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, ownerSweepTakes, serveDurableAgentRowLane, agentHandleOutcomeOf, resolveBackgroundAgentByNameLane, claimBackgroundAgentNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, activeDelegationHandlesByRootLane, activeDelegationOccupantsLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, endRetentionHoldLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
@@ -42,12 +42,6 @@ function blockDeadline(timeoutMs, now) {
42
42
  const t = Math.min(BLOCK_MAX_TIMEOUT_MS, Math.max(1, Math.floor(timeoutMs ?? BLOCK_DEFAULT_TIMEOUT_MS)));
43
43
  return now + t;
44
44
  }
45
- const TASK_PREFIX = {
46
- background_bash: "b",
47
- workflow: "w",
48
- background_agent: "a",
49
- monitor: "m",
50
- };
51
45
  const A_LATER_LEG = Object.freeze({});
52
46
  function noTask(taskId, runningAgents) {
53
47
  return {
@@ -158,6 +152,15 @@ function workflowParkedProjection(handle) {
158
152
  return { parkedUnreadable: true };
159
153
  }
160
154
  }
155
+ function markRunEndOn(handles, id, runEnd) {
156
+ const handle = handles.get(id);
157
+ if (handle?.type === "background_agent" && handle.status === "running")
158
+ handle.stopRunEnd ??= runEnd;
159
+ }
160
+ let sweepAtRunEnd;
161
+ export function abortBackgroundAgentsAtRunEnd(registry, access, opts, runEnd) {
162
+ return sweepAtRunEnd(registry, access, opts, runEnd);
163
+ }
161
164
  export class TaskRegistry {
162
165
  handles = new Map();
163
166
  sessionReapHooks = new Set();
@@ -172,6 +175,7 @@ export class TaskRegistry {
172
175
  handles: self.handles,
173
176
  mintTaskId: (type) => self.mintTaskId(type),
174
177
  markStopSource: (id, source) => self.markStopSource(id, source),
178
+ markRunEnd: (id, cause) => markRunEndOn(self.handles, id, cause),
175
179
  notifyTerminalOnce: (handle, send) => self.notifyTerminalOnce(handle, send),
176
180
  pokeBgQuiescence: (owner) => self.pokeBgQuiescence(owner),
177
181
  pokeYieldDrains: () => self.pokeYieldDrains(),
@@ -304,6 +308,9 @@ export class TaskRegistry {
304
308
  abortBackgroundAgentsForOwner(access, opts) {
305
309
  return abortBackgroundAgentsForOwnerLane(this.core, access, opts);
306
310
  }
311
+ static {
312
+ sweepAtRunEnd = (registry, access, opts, runEnd) => abortBackgroundAgentsForOwnerLane(registry.core, access, opts, runEnd);
313
+ }
307
314
  serveDurableAgentRow(row, checkpointSeat) {
308
315
  const read = readAgentState(agentStateSourceOfRecord(row), checkpointSeat, Date.now());
309
316
  return read instanceof Promise ? read.then((agentState) => serveDurableAgentRowLane(row, agentState)) : serveDurableAgentRowLane(row, read);
@@ -390,7 +397,7 @@ export class TaskRegistry {
390
397
  agentNameClaims = new Set();
391
398
  durableHeartbeatTimer;
392
399
  mintTaskId(type) {
393
- const prefix = TASK_PREFIX[type];
400
+ const prefix = SEMA_TASK_HANDLE_PREFIXES[type];
394
401
  for (let i = 0; i < 32; i++) {
395
402
  const id = `${prefix}${randomBytes(8).toString("hex")}`;
396
403
  if (!this.handles.has(id))
@@ -1009,6 +1016,10 @@ export class TaskRegistry {
1009
1016
  return { legs: [] };
1010
1017
  return { legs: verb === "output" ? ["outside_read"] : [] };
1011
1018
  }
1019
+ backgroundAgentTree(id, access) {
1020
+ const handle = this.resolveInternal(id.trim(), access);
1021
+ return handle?.type === "background_agent" ? handle.delegationTree : undefined;
1022
+ }
1012
1023
  owedDeliveries(access) {
1013
1024
  return this.liveTasks(access).map((t) => this.boundaryLegsOf(t.task_id, access, "output", A_LATER_LEG));
1014
1025
  }
@@ -1088,6 +1099,22 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1088
1099
  }
1089
1100
  return noTask(taskId, runningAgentFooterLane(this.core, access));
1090
1101
  }
1102
+ async stopWorkflowAgent(runId, callKey, access, opts = {}) {
1103
+ const id = runId.trim();
1104
+ const handle = this.resolveInternal(id, access);
1105
+ if (handle !== undefined)
1106
+ return handle.type === "workflow" && handle.handle.stopAgent !== undefined ? handle.handle.stopAgent(callKey, { stoppedBy: opts.stoppedBy ?? "parent" }) : { answer: "not_found" };
1107
+ const store = opts.workflowStore;
1108
+ if (store !== undefined) {
1109
+ const run = await store.get(id);
1110
+ const now = this.heldWorkflow(id, store);
1111
+ if (now !== undefined && canAccess(now, access))
1112
+ return now.handle.stopAgent !== undefined ? now.handle.stopAgent(callKey, { stoppedBy: opts.stoppedBy ?? "parent" }) : { answer: "not_found" };
1113
+ if (run && canAccessWorkflowRun(run, access, this.heldWorkflow(id, store)))
1114
+ return run.status === "running" ? { answer: "not_local" } : { answer: "already_terminal", status: run.status };
1115
+ }
1116
+ return { answer: "not_found" };
1117
+ }
1091
1118
  async stopTask(id, access, opts = {}) {
1092
1119
  const taskId = id.trim();
1093
1120
  const handle = this.resolveInternal(taskId, access);
@@ -6,7 +6,7 @@
6
6
  * no consumer's import changes.
7
7
  */
8
8
  import type { DeniedBy, SettlementKind } from "./gate-outcome.js";
9
- import type { FileHistoryLeftAsIsFile } from "./file-history-store.js";
9
+ import type { FileHistoryLeftAsIsFile, RewindFilesResult } from "./file-history-store.js";
10
10
  import type { TerminalCause } from "./terminal-cause.js";
11
11
  import type { NestedUsage } from "./tool-spec.js";
12
12
  /**
@@ -185,6 +185,13 @@ export interface RefusedAsk {
185
185
  * stands alone), and where nobody could answer but the refusal names no way out (an inherited or forced mandate on a leg with no
186
186
  * park lane whose host did not declare it not resumable — {@link remedy} is absent there as well). */
187
187
  readonly modelRemedy?: string;
188
+ /** #5244 — a durable approval park was attempted for the call and could not be minted: its sentence, the one the
189
+ * `delegation.ask_unresolvable` notice carries as `detail.parkFailed` (one reading, {@link import("./ask-unresolvable-notice.js").refusedAskOf}),
190
+ * and {@link remedy} then names the park first. Absent where no park was attempted, or the refusal names no way out. */
191
+ readonly parkFailed?: string;
192
+ /** Beside {@link parkFailed}: the missing piece of durable-suspend infrastructure the failure is, when it is one (the notice's
193
+ * `detail.parkFailedReason`, a word of `SUSPEND_LANE_REASONS`). */
194
+ readonly parkFailedReason?: import("./suspend-lane-reasons.js").SuspendLaneReason;
188
195
  }
189
196
  /**
190
197
  * A leg's verdict that the gate refused ({@link TaskResult.verdictRefused}): at least one call of the leg's verdict tool (its
@@ -730,6 +737,19 @@ export interface TaskResult {
730
737
  * restore's own order. Absent on every other code. A machine reading: branch on `class`, locate by `place`. */
731
738
  leftAsIs?: FileHistoryLeftAsIsFile[];
732
739
  }>;
740
+ /**
741
+ * The file restore this run carried out (`rewindFilesTo`, `resumeAt` + `restoreFiles`), as the restore answered it — the SAME value
742
+ * `Runner.rewindFiles` answers as `restore`, minted by the same restore reading: `outcome` (`complete`, or `partial` where
743
+ * `acceptPartialRestore` accepted it), the counts' lists, every file it wrote, deleted or refused (`files`, each with its
744
+ * `targetPath` and `outsideRoot`) and every file it left as it is (`leftAsIs`). The sentences about the same restore are
745
+ * {@link rewindNotes}; this is the rows a host reads instead. PRESENCE: exactly when the run's restore was accepted, whatever
746
+ * terminal the run then reached (a refusal after the restore landed included); absent on a run that asked no restore, and on one
747
+ * whose restore was refused or failed (`rewind.restore_failed` carries that ledger on its `detail`; `terminal.rewind` says whether
748
+ * the tree moved).
749
+ */
750
+ fileRestore?: Extract<RewindFilesResult, {
751
+ dryRun: false;
752
+ }>["restore"];
733
753
  /**
734
754
  * The files THIS RUN's hands actually mutated, with how many times each — the same
735
755
  * `{path, edits}` shape the delegated-child projection publishes as
@@ -1030,6 +1050,40 @@ export interface TaskResult {
1030
1050
  /** The caller homes a TASK layer declared for this leg ({@link import("./task-spec.js").TaskSpec.agentHomeDirs}, its own and a
1031
1051
  * resumed row's) — {@link effectiveAgentConfigDirs}'s twin for the home-anchored rows, same purpose, same presence. */
1032
1052
  effectiveAgentHomeDirs?: readonly string[];
1053
+ /**
1054
+ * The leg refused reads outside its declared directories — its one resolution of
1055
+ * {@link import("./task-spec.js").TaskSpec.blockReadsOutsideRoots}: the declaration, or the resumed row's record
1056
+ * (`CheckpointState.readBlock`) — as an engine-filled OBSERVATION (never a knob: writing it on a spec does nothing). Same
1057
+ * purpose as {@link effectiveReadFace}: a row parked with the seat on resumes with it whatever the resume-side config sends, so a
1058
+ * POST-COMPLETION follow-on leg (the verify gate's verifier and fix legs) reads the seat HERE (beside the caller's own `true`: whichever restricts).
1059
+ * **In-presence condition:** present (always `true`) iff the leg resolved the seat on; rides any terminal of a leg that ran;
1060
+ * absent when the leg did not refuse such reads, and on prepare failures. The stream layer's failure backstop (a leg that throws
1061
+ * past its result assembly) carries it too, as it does every posture seat, by the one assembly (`resultPostureSeats`) — once the
1062
+ * leg's identity wiring published them; a leg that throws between the end of its prepare and that wiring carries none.
1063
+ */
1064
+ effectiveBlockReadsOutsideRoots?: true;
1065
+ /**
1066
+ * The command sandbox requirement this leg ran its commands under — {@link import("./task-spec.js").TaskSpec.sandbox} as judged,
1067
+ * with a resumed row's recorded requirement as its floor (`CheckpointState.commandSandbox`, the value this leg's own rows record) —
1068
+ * as an engine-filled OBSERVATION (never a knob: writing it on a spec does nothing). Same purpose as
1069
+ * {@link effectiveBlockReadsOutsideRoots}: the verify gate's verifier and fix legs run in the boundary read HERE (the caller's stated keys
1070
+ * laid over it), so a resume whose config does not send `sandbox` again still runs them inside the parked boundary. A copy: the holder's edits reach nothing.
1071
+ * **In-presence condition:** present iff a requirement was stated for the leg (its own or a resumed row's) — `enabled: false`
1072
+ * included, so presence alone does not say the commands were sandboxed; rides any terminal of a leg that ran; absent on prepare
1073
+ * failures.
1074
+ */
1075
+ effectiveSandbox?: import("./command-sandbox.js").TaskSandboxSettings;
1076
+ /**
1077
+ * The leg treated what its execution environment produced as content from outside the deployment's trust boundary — its
1078
+ * external-content-target fold: the environment's declaration (`ExecutionEnvCapabilities.externalContentTarget`, undeclared read
1079
+ * as outside), a resumed row's record (`CheckpointState.externalContentTarget`), or the later-leg seat a composition hands
1080
+ * ({@link import("./runner/contracts.js").RunInternals.externalContentTarget}) — as an engine-filled OBSERVATION. Same purpose as
1081
+ * {@link effectiveBlockReadsOutsideRoots}: the verify gate hands it to its verifier and fix legs from HERE, so a resume onto an
1082
+ * environment that declares no external target keeps the fold on those legs (the memory face, the environment disclosure).
1083
+ * **In-presence condition:** present (always `true`) iff the fold is on; rides any terminal of a leg that ran; absent when it is
1084
+ * off, and on prepare failures.
1085
+ */
1086
+ effectiveExternalContentTarget?: true;
1033
1087
  /**
1034
1088
  * design/178 v2 §2.3 (件①) — the memory VISIBILITY face this leg actually ran under, as an
1035
1089
  * engine-filled OBSERVATION (never a knob: writing it on a spec does nothing). This is the