@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
@@ -13,7 +13,7 @@ import { getSessionRetainLedger } from "./retain-ledger.js";
13
13
  import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
14
14
  import { thrownText } from "../core/thrown-value.js";
15
15
  import { callScopeOf } from "../core/isolation-scope.js";
16
- import { delegationOwnerOf, revivalRowJudged } from "../core/runner/delegation-owner.js";
16
+ import { judgeRowForSeat, readJudgedRow } from "../core/runner/delegation-owner.js";
17
17
  export const AGENT_TRANSCRIPT_TOOL_NAME = "AgentTranscript";
18
18
  const AGENT_TRANSCRIPT_DEFAULT_N = 20;
19
19
  const AGENT_TRANSCRIPT_MAX_N = 50;
@@ -75,22 +75,29 @@ export function createAgentTranscriptTool(opts) {
75
75
  const recordSource = agentStateSourceOfRecord(durableRow);
76
76
  if (durableRow.sessionId === undefined)
77
77
  return live === undefined ? await transcriptGone(recordSource) : undefined;
78
- if (!(await revivalRowJudged(opts.runner.sessions, durableRow.sessionId, await delegationOwnerOf(ctx.delegationOwner, ctx.signal), ctx.signal))) {
78
+ const unread = async (e) => {
79
+ if (e?.code === "not_found")
80
+ announceTranscriptIntegrityGapOnce(id, access.scope, opts.onTranscriptIntegrityGap, transcriptTier);
81
+ return live === undefined ? await transcriptGone(recordSource) : undefined;
82
+ };
83
+ const notOurs = async () => {
79
84
  announceTranscriptIntegrityGapOnce(id, access.scope, opts.onTranscriptIntegrityGap, transcriptTier);
80
85
  return live === undefined ? await transcriptGone(recordSource) : undefined;
81
- }
86
+ };
87
+ const verdict = await judgeRowForSeat(opts.runner.sessions, { sessionId: durableRow.sessionId }, ctx.delegationOwner, ctx.signal);
88
+ if (!verdict.open && verdict.kind === "store")
89
+ return rowStoreFault(verdict, live?.() ?? recordSource);
90
+ if (!verdict.open)
91
+ return notOurs();
82
92
  let steps;
83
93
  try {
84
- const acquired = await opts.runner.sessions.acquire(durableRow.sessionId, { requireExisting: true });
85
- const branch = await acquired.session.getBranch();
86
- const messages = branch.filter((e) => e.type === "message").map((e) => e.message);
87
- steps = stepsFromMessages(messages, lastN);
94
+ const read = await readJudgedRow(opts.runner.sessions, durableRow.sessionId, verdict, async (held) => (await held.session.getBranch()).filter((e) => e.type === "message").map((e) => e.message), ctx.signal);
95
+ if ("refused" in read)
96
+ return read.refused.kind === "store" ? rowStoreFault(read.refused, live?.() ?? recordSource) : notOurs();
97
+ steps = stepsFromMessages(read.read, lastN);
88
98
  }
89
99
  catch (e) {
90
- if (e?.code === "not_found") {
91
- announceTranscriptIntegrityGapOnce(id, access.scope, opts.onTranscriptIntegrityGap, transcriptTier);
92
- }
93
- return live === undefined ? await transcriptGone(recordSource) : undefined;
100
+ return unread(e);
94
101
  }
95
102
  const state = await stateOf(live?.() ?? recordSource);
96
103
  if (steps.length === 0) {
@@ -105,6 +112,14 @@ export function createAgentTranscriptTool(opts) {
105
112
  const state = await stateOf(source);
106
113
  return { content: `${clipStateHeader(state)}No transcript found for agent ${id}.`, details: { error: "not_found", id, agentState: state }, isError: true };
107
114
  };
115
+ const rowStoreFault = async (verdict, source) => {
116
+ const state = source !== undefined ? await stateOf(source) : undefined;
117
+ return {
118
+ content: `${state !== undefined ? clipStateHeader(state) : ""}No transcript read: agent ${id.slice(0, 120)}'s session cannot be read from here right now — the session store this deployment runs on could not confirm it belongs to this conversation (${verdict.code}). This is a deployment fault, not a lost transcript; tell the operator.`,
119
+ details: { error: verdict.code, code: verdict.code, id, cause: redactThenCut(verdict.why, REPORT_FIELD_MAX), ...(state !== undefined ? { agentState: state } : {}) },
120
+ isError: true,
121
+ };
122
+ };
108
123
  const row = opts.registry.getAccessibleTask(id, access);
109
124
  if (!row || row.type !== "background_agent") {
110
125
  if (/^w[0-9a-f]{16}$/.test(id) || (row !== undefined && row.type === "workflow")) {
@@ -128,16 +143,19 @@ export function createAgentTranscriptTool(opts) {
128
143
  const atLedgerSessionId = ctx.sessionId ?? opts.sessionId;
129
144
  const sessionLedger = atLedgerSessionId !== undefined ? getSessionRetainLedger(atLedgerSessionId) : undefined;
130
145
  const entry = row.toolUseId !== undefined ? (sessionLedger?.get(row.toolUseId) ?? runLedger?.get(row.toolUseId)) : undefined;
131
- if (!entry) {
132
- const durable = await readDurableSteps(live);
133
- if (durable)
134
- return durable;
146
+ const notRetained = async () => {
135
147
  const state = live !== undefined ? await stateOf(live()) : undefined;
136
148
  return {
137
149
  content: `${state !== undefined ? clipStateHeader(state) : ""}No transcript: agent ${id}'s session was not retained (this run did not enable retainSubagentSessions), so its history is unavailable. Its completion notification carried the recent steps.`,
138
150
  details: { error: "not_retained", id, ...(state !== undefined ? { agentState: state } : {}) },
139
151
  isError: true,
140
152
  };
153
+ };
154
+ if (!entry) {
155
+ const durable = await readDurableSteps(live);
156
+ if (durable)
157
+ return durable;
158
+ return await notRetained();
141
159
  }
142
160
  const noStepsYet = async () => {
143
161
  const state = live !== undefined ? await stateOf(live()) : undefined;
@@ -147,10 +165,16 @@ export function createAgentTranscriptTool(opts) {
147
165
  return await noStepsYet();
148
166
  let steps;
149
167
  try {
150
- const acquired = await (entry.runner ?? opts.runner).sessions.acquire(entry.childSessionId, { requireExisting: true });
151
- const branch = await acquired.session.getBranch();
152
- const messages = branch.filter((e) => e.type === "message").map((e) => e.message);
153
- steps = stepsFromMessages(messages, lastN);
168
+ const store = (entry.runner ?? opts.runner).sessions;
169
+ const verdict = await judgeRowForSeat(store, { sessionId: entry.childSessionId }, ctx.delegationOwner, ctx.signal);
170
+ if (!verdict.open && verdict.kind === "store")
171
+ return await rowStoreFault(verdict, live?.());
172
+ if (!verdict.open)
173
+ return await notRetained();
174
+ const read = await readJudgedRow(store, entry.childSessionId, verdict, async (held) => (await held.session.getBranch()).filter((e) => e.type === "message").map((e) => e.message), ctx.signal);
175
+ if ("refused" in read)
176
+ return read.refused.kind === "store" ? await rowStoreFault(read.refused, live?.()) : await notRetained();
177
+ steps = stepsFromMessages(read.read, lastN);
154
178
  }
155
179
  catch (e) {
156
180
  const code = e?.code;
@@ -2,7 +2,7 @@ import type { AgentDefinition, McpServerSpec, ToolSpec } from "../core/types.js"
2
2
  import type { ToolSelector, ToolSelectorLayer } from "../core/tool-face.js";
3
3
  import type { MountedMcp } from "../core/mounted-mcp.js";
4
4
  import type { McpHostSeat } from "../core/mcp-host-seat.js";
5
- import type { RunInternals } from "../core/runner/contracts.js";
5
+ import type { InheritedGate, RunInternals } from "../core/runner/contracts.js";
6
6
  /**
7
7
  * What a delegated child inherits when its delegation tool has no explicit pool (`SubagentToolOptions.inheritedTools`):
8
8
  * the parent surface, narrowed at spawn by two laws, and the parent's MCP declarations. The mint of the parent bound
@@ -44,6 +44,10 @@ export declare function inheritedHostSeats(held: ReadonlyMap<string, McpHostSeat
44
44
  * ({@link inheritedHostSeats} over the waker's mount), its target, so a woken agent is minted where its waker is — the same answer a
45
45
  * tier-3 revival of that agent gets — its author, since every resume states who wrote it, and the activity seat of the row it wakes. */
46
46
  export declare function withoutWakerSeats(internals: RunInternals): RunInternals;
47
+ /** The chain a WAKE hands the leg it wakes — a retained snapshot's ({@link withoutWakerSeats}) and a tier-3 revival's (the waker's own
48
+ * chain): without any reading of the `sharedArtifactReads` setting. One rule: every wake is a run of its own and reads the seat
49
+ * again — neither the spawner's old `allow` nor the waker's outlives a setting changed since. Every other member stays as it is. */
50
+ export declare function wakeGate(gate: InheritedGate): InheritedGate;
47
51
  /**
48
52
  * The MCP servers a leg spawned as an agent definition is declared ({@link AgentDefinition.mcp}): the servers its lane hands it (the
49
53
  * spawning run's it inherits, a workflow child's governed spec's) first, then each of the definition's own whose tool namespace none of
@@ -23,6 +23,12 @@ export function inheritedHostSeats(held, servers) {
23
23
  }
24
24
  export function withoutWakerSeats(internals) {
25
25
  const { mcpHostSeats: _live, placementTarget: _spawnersTarget, objectiveAuthor: _spawnAuthor, onSubtreeActivity: _spawnersActivity, ...kept } = internals;
26
+ return kept.inheritedGate === undefined ? kept : { ...kept, inheritedGate: wakeGate(kept.inheritedGate) };
27
+ }
28
+ export function wakeGate(gate) {
29
+ if (gate.sharedArtifactReads === undefined)
30
+ return gate;
31
+ const { sharedArtifactReads: _reading, ...kept } = gate;
26
32
  return kept;
27
33
  }
28
34
  export function withDefinitionServers(handed, own) {
@@ -152,6 +152,8 @@ export class SubagentRetainLedger {
152
152
  }
153
153
  }
154
154
  register(parentToolCallId, entry) {
155
+ if (typeof entry.rowVerified !== "function")
156
+ throw codedRefusal("config.invalid_argument", "SubagentRetainLedger.register: the entry has no `rowVerified` function — every reader of a retained entry asks it whether the row's owner was verified; give it `rowVerified: () => boolean` (the spawning lane's word for the row)");
155
157
  if (this.isDisposed)
156
158
  return void entry.declarations.release();
157
159
  this.sweepExpired();
@@ -4,6 +4,7 @@ import { type TaskNotificationPayload } from "../core/task-notification.js";
4
4
  import { type ToolCtxEnricher } from "../core/tools.js";
5
5
  import { type TaskAccess } from "../core/task-registry.js";
6
6
  import { type OccupantMount } from "../core/task-registry-shared.js";
7
+ import { type DelegationOwnerSeat } from "../core/runner/delegation-owner.js";
7
8
  import type { PermissionModeClass } from "./cross-session-envelope.js";
8
9
  import { type PeerDirectory } from "./peer-directory.js";
9
10
  import type { PeerChannel } from "../core/peer-channel.js";
@@ -106,7 +107,9 @@ export interface SendMessageToolOptions extends OccupantMount {
106
107
  * tool's execute (object identity via the `agentListing` marker — never wire-name lookup, so a
107
108
  * caller's same-named shadow tool can never receive the trusted claim) with a fresh toolCallId
108
109
  * and `ctx.reviveClaim`. The revival is thereby the FULL spawn chain (observer frames, durable
109
- * lane re-arm, notify, park semantics) — nothing re-implemented here. */
110
+ * lane re-arm, notify, park semantics) — nothing re-implemented here. The tree the cycle runs in (the birth tree this send read once
111
+ * and admitted its caller on) is not part of the request: it rides the request's `row` object itself, which the spawner hands on to the
112
+ * delegation tool as `ctx.reviveClaim.row` as it was given (a copy carries nothing). */
110
113
  reviveSpawn?: (req: {
111
114
  row: import("../core/background-agent-store.js").BackgroundAgentRecord;
112
115
  rev: number;
@@ -290,10 +293,18 @@ export interface AgentContinuationReceipt {
290
293
  * specified one leaves the axes it omits UNDECLARED (default-deny), never backfilled from the mount.
291
294
  * See the identity-strip note in the body for why that has to be spelled at the options seat too.
292
295
  *
296
+ * THE TREE IT ACTS FOR is the host's to state, per call: `o.delegationOwner` (a {@link DelegationOwnerSeat},
297
+ * `delegationOwnerSeat(name | null)` — the seat a host hands a leg it starts) is the call's seat, judged by the
298
+ * tool's own ladder as any leg's is: the agent's row must be one that tree may open, and a revival — which runs in
299
+ * the tree the agent was born in — is started only from that tree. None stated is an anonymous tree's: it
300
+ * continues an agent born in a tree that records no owner, and answers `not_retained` for one born in a named
301
+ * principal's tree, as a call stating another principal does.
302
+ *
293
303
  * Store-conditional like every continuation face: with no durable stores wired the live-gate waiver
294
304
  * still works for same-process handles, and the durable leg refuses honestly.
295
305
  */
296
306
  export declare function createAgentContinuationVerb(opts: SendMessageToolOptions): (handle: string, content: string, access: TaskAccess, o?: {
297
307
  userInitiated?: true;
298
308
  summary?: string;
309
+ delegationOwner?: DelegationOwnerSeat;
299
310
  }) => Promise<AgentContinuationReceipt>;
@@ -5,7 +5,7 @@ import { defineTool } from "../core/tools.js";
5
5
  import { normalizeAgentName, chosenAgentName, DURABLE_AGENT_HANDLE_RE, DURABLE_AGENT_HEARTBEAT_MS } from "../core/task-registry.js";
6
6
  import { callOccupant } from "../core/task-registry-shared.js";
7
7
  import { announceTranscriptIntegrityGapOnce, canAccessAgentRecord, clearRevivedRowTerminalPayload, nextCycleSeq } from "../core/background-agent-store.js";
8
- import { delegationOwnerOf, revivalRowJudged } from "../core/runner/delegation-owner.js";
8
+ import { birthTreeAdmission, delegationOwnerOf, holdCycleTree, treeReaches } from "../core/runner/delegation-owner.js";
9
9
  import { uuidv7 } from "../internal/harness.js";
10
10
  import { MAILBOX_TOMBSTONED_RECIPIENT_CODE, sessionBoxMountVerdict } from "../core/mailbox-store.js";
11
11
  import { peerSendVerdictSeverity } from "./cross-session-judge.js";
@@ -241,6 +241,11 @@ export function createSendMessageTool(opts) {
241
241
  details: { error: "revive.no_background", code: "revive.no_background", to },
242
242
  isError: true,
243
243
  });
244
+ const rowStoreFaultResult = (verdict, whoLabel, toLabel) => ({
245
+ content: `Message not sent: ${whoLabel.slice(0, 200)} cannot be continued from here right now — the session store this deployment runs on could not confirm its session belongs to this conversation (${verdict.code}). This is a deployment fault, not a lost session; tell the operator.`,
246
+ details: { error: verdict.code, code: verdict.code, to: toLabel, cause: redactThenCut(verdict.why, 400) },
247
+ isError: true,
248
+ });
244
249
  const admissionRefusal = (reason, whoLabel) => {
245
250
  const text = reason === "rate_limited"
246
251
  ? `you are sending messages to ${whoLabel} faster than its rate limit — the budget refills on its own; slow down and resend in a moment.`
@@ -531,6 +536,9 @@ export function createSendMessageTool(opts) {
531
536
  const parentAccess = parentTaskId !== undefined
532
537
  ? { ...access, owner: parentTaskId, ...(parentSessionId !== undefined ? { sessionId: parentSessionId } : {}) }
533
538
  : undefined;
539
+ let callerTreeRead;
540
+ const callerTree = () => (callerTreeRead ??= delegationOwnerOf(ctx.delegationOwner, ctx.signal));
541
+ const noTranscriptFound = () => ({ content: `Message not sent: no transcript found for agent ${to} — launch a new agent with the needed context instead.`, details: { error: "not_found", to }, isError: true });
534
542
  const tier3Revive = async (handle, admitted = false) => {
535
543
  if (opts.agentStore === undefined || opts.mailbox === undefined || opts.reviveSpawn === undefined)
536
544
  return undefined;
@@ -593,8 +601,12 @@ export function createSendMessageTool(opts) {
593
601
  }
594
602
  if (!admission.ok && admission.refusal === "no_transcript")
595
603
  return undefined;
596
- if (!(await revivalRowJudged(opts.runner.sessions, admission.transcript, await delegationOwnerOf(ctx.delegationOwner, ctx.signal), ctx.signal)))
604
+ const birthVerdict = await birthTreeAdmission(opts.runner.sessions, row, { sessionId: admission.transcript }, await callerTree(), ctx.signal);
605
+ if (!birthVerdict.open && birthVerdict.kind === "not_ours")
597
606
  return void announceTranscriptIntegrityGapOnce(handle, scope, opts.onTranscriptIntegrityGap, continuationTier);
607
+ if (!birthVerdict.open)
608
+ return rowStoreFaultResult(birthVerdict, whoT3, to);
609
+ const cycleTree = birthVerdict.tree;
598
610
  if (!continuationAdmitted)
599
611
  return noContinuationLane(whoT3);
600
612
  if (!admission.ok) {
@@ -672,6 +684,7 @@ export function createSendMessageTool(opts) {
672
684
  const drainPrompt = `${drainLease.messages.map((m) => frameTeammateMessage({ from: m.from ?? "main", text: m.content })).join("\n")}\n\n${PEER_MESSAGE_NOTICE}`;
673
685
  const drainSeed = drainLease.messages[drainLease.messages.length - 1]?.hopChain ?? [];
674
686
  let drainSpawned;
687
+ holdCycleTree(claimed, cycleTree);
675
688
  try {
676
689
  drainSpawned = await opts.reviveSpawn({ row: claimed, rev: claimedRev, prompt: drainPrompt, peerSeed: { hopChain: [...drainSeed] } });
677
690
  }
@@ -802,6 +815,7 @@ export function createSendMessageTool(opts) {
802
815
  .join("\n")}\n\n${PEER_MESSAGE_NOTICE}`;
803
816
  const reviveSeed = lease.messages[lease.messages.length - 1]?.hopChain ?? [];
804
817
  let spawned;
818
+ holdCycleTree(claimed, cycleTree);
805
819
  try {
806
820
  spawned = await opts.reviveSpawn({ row: claimed, rev: claimedRev, prompt: revivePrompt, peerSeed: { hopChain: [...reviveSeed] } });
807
821
  }
@@ -909,13 +923,8 @@ export function createSendMessageTool(opts) {
909
923
  else if (peerLane.reason !== undefined) {
910
924
  return peerRefusal("peer_send.other", `no agent matches "${inlineUntrusted(to, 120)}", and the cross-session lane that could reach a peer session by that name is unavailable on this mount — ${peerLane.reason}.`);
911
925
  }
912
- if (DURABLE_AGENT_HANDLE_RE.test(to)) {
913
- return {
914
- content: `Message not sent: no transcript found for agent ${to} — launch a new agent with the needed context instead.`,
915
- details: { error: "not_found", to },
916
- isError: true,
917
- };
918
- }
926
+ if (DURABLE_AGENT_HANDLE_RE.test(to))
927
+ return noTranscriptFound();
919
928
  const reachable = [
920
929
  ...(opts.uplink !== undefined ? ['"main" (the conversation that spawned you)'] : []),
921
930
  "background agents you spawned, by name or task_id",
@@ -950,14 +959,32 @@ export function createSendMessageTool(opts) {
950
959
  if (guard !== undefined)
951
960
  return guard;
952
961
  }
962
+ const notReached = () => (DURABLE_AGENT_HANDLE_RE.test(to) ? noTranscriptFound() : { content: `Message not sent: no agent matches "${inlineUntrusted(to, 120)}" (unknown id or name, or not yours). Launch a new agent with the needed context instead.`, details: { error: "not_found", to }, isError: true });
963
+ const inProcessRefusal = (heldTree) => {
964
+ if (heldTree === undefined)
965
+ return undefined;
966
+ return Promise.all([delegationOwnerOf(heldTree, ctx.signal), callerTree()]).then(([held, caller]) => {
967
+ if (!caller.bound)
968
+ return rowStoreFaultResult({ open: false, kind: "store", code: "delegation.owner_unbound", why: `the delegation tree's owner does not bind: ${caller.reason}` }, who, to);
969
+ return treeReaches(held, caller) ? undefined : notReached();
970
+ });
971
+ };
953
972
  if (row.status === "running" || row.status === "pending") {
954
973
  return await withTargetLane(targetLaneKey(access.scope, targetId), async () => {
974
+ const runningTree = () => opts.registry.backgroundAgentTree?.(targetId, resolvedAccess);
975
+ const judgedTree = runningTree();
976
+ const judged = inProcessRefusal(judgedTree);
977
+ const refusal = judged === undefined ? undefined : await judged;
978
+ if (refusal !== undefined)
979
+ return refusal;
955
980
  const liveRecipientKey = peerAxisToken(resolvedAccess.scope, "h", targetId);
956
981
  const liveVerdict = admitFor(liveRecipientKey, [liveRecipientKey]);
957
982
  if (!liveVerdict.ok)
958
983
  return admissionRefusal(liveVerdict.reason, who);
959
984
  const s2Clipped = clipCarrierMessage(message);
960
985
  const teammateXml = `${frameTeammateMessage({ from: senderLabel, summary, text: s2Clipped })}\n\n${PEER_MESSAGE_NOTICE}`;
986
+ if (runningTree() !== judgedTree)
987
+ return notReached();
961
988
  const delivered = await opts.registry.deliverToRunningAgent(targetId, resolvedAccess, {
962
989
  task_id: senderLabel,
963
990
  task_type: "background_agent",
@@ -1063,6 +1090,12 @@ export function createSendMessageTool(opts) {
1063
1090
  return noContinuationLane(who);
1064
1091
  let fastLaneMiss;
1065
1092
  const fastLaneAnswer = await withTargetLane(targetLaneKey(access.scope, targetId), async () => {
1093
+ const judgedEntry = ledger.get(resumeToolUseId);
1094
+ const judgedSeat = judgedEntry?.internalsSnapshot.delegationOwner;
1095
+ const judged = inProcessRefusal(judgedSeat);
1096
+ const refusal = judged === undefined ? undefined : await judged;
1097
+ if (refusal !== undefined)
1098
+ return refusal;
1066
1099
  const l3RecipientKey = peerAxisToken(access.scope, "h", targetId);
1067
1100
  const l3Verdict = admitFor(l3RecipientKey, [
1068
1101
  l3RecipientKey,
@@ -1109,6 +1142,9 @@ export function createSendMessageTool(opts) {
1109
1142
  try {
1110
1143
  const safeSummary = escapeEnvelopeTag(TEAMMATE_MESSAGE_TAG, summary);
1111
1144
  const safeMessage = escapeEnvelopeTag(TEAMMATE_MESSAGE_TAG, message);
1145
+ const entryNow = ledger.get(resumeToolUseId);
1146
+ if (entryNow !== undefined && (entryNow !== judgedEntry || entryNow.internalsSnapshot.delegationOwner !== judgedSeat))
1147
+ return notReached();
1112
1148
  const marker = await resume(`${fromPrefix}[${safeSummary}] ${safeMessage}`);
1113
1149
  return {
1114
1150
  content: continuedReceipt(receiptAgentLabel(to, targetId, row), 0),
@@ -1150,6 +1186,7 @@ export function createAgentContinuationVerb(opts) {
1150
1186
  const { owner: _mo, scope: _ms, sessionId: _msid, parentTaskId: _mpt, parentSessionId: _mps, occupant: _mocc, ...mountWithoutIdentity } = opts;
1151
1187
  const mountLedgerKey = opts.sessionId;
1152
1188
  return async (handle, content, access, o) => {
1189
+ const statedTree = o?.delegationOwner;
1153
1190
  const tool = createSendMessageTool({
1154
1191
  ...mountWithoutIdentity,
1155
1192
  ...(mountLedgerKey !== undefined ? { sessionRetainLedgerKey: mountLedgerKey } : {}),
@@ -1163,6 +1200,7 @@ export function createAgentContinuationVerb(opts) {
1163
1200
  ...(access.scope !== undefined ? { isolationScope: access.scope } : {}),
1164
1201
  ...(access.sessionId !== undefined ? { sessionId: access.sessionId } : {}),
1165
1202
  ...(access.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: access.rootSessionIncarnation } : {}),
1203
+ ...(statedTree !== undefined ? { delegationOwner: statedTree } : {}),
1166
1204
  };
1167
1205
  if (o?.userInitiated === true)
1168
1206
  enriched[OPERATOR_CONTINUATION_CTX] = true;
@@ -5,7 +5,7 @@ import { HANDBACK_REVIEW_SILENT, handbackLeadOf, handbackNoRulingNote, reviewSub
5
5
  import { backgroundChildContinuation, backgroundChildTerminal } from "../core/delegation-frames.js";
6
6
  import { bindDelegationName } from "../core/delegation-name.js";
7
7
  import { authoredSteerOf } from "../core/input-author.js";
8
- import { DELEGATION_OWNER_UNBOUND, delegationOwnerOf, judgedOwnerSeat, namesVerifiedSession, ownerToJudge, rowOwnerReading, verifiedAtBirth } from "../core/runner/delegation-owner.js";
8
+ import { DELEGATION_OWNER_UNBOUND, delegationOwnerOf, judgedOwnerSeat, recordedRootAnchor, revivalTreeSeat, namesVerifiedSession, ownerToJudge, rowOwnerReading, verifiedAtBirth } from "../core/runner/delegation-owner.js";
9
9
  import { resumeRefusalDetailOf, resumeStartupCauseOf } from "../core/resume-startup-cause.js";
10
10
  import { errorCodeOf } from "../core/runner/terminal-account.js";
11
11
  import { applyParentSpecSeat, parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
@@ -104,7 +104,7 @@ import { childOwnerKeys, parkCompletionNotify, runningBackgroundUnder } from "./
104
104
  import { placesSubagentTranscripts, subagentTranscriptPlacement } from "./subagent-transcript-placement.js";
105
105
  import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
106
106
  import { canonicalNameValue } from "../core/permission-rule-model.js";
107
- import { definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, selectorLayerOf, withDefinitionServers, withoutWakerSeats } from "./inherited-tool-pool.js";
107
+ import { definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, selectorLayerOf, wakeGate, withDefinitionServers, withoutWakerSeats } from "./inherited-tool-pool.js";
108
108
  import { codedRefusal, readMember, thrownMarksOf, thrownText } from "../core/thrown-value.js";
109
109
  import { GIT_READ_ONLY } from "../core/git-read-only.js";
110
110
  const BG_AGENT_RESULT_MAX = 4_000;
@@ -2179,9 +2179,10 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2179
2179
  ...(parentGate.shellGate !== undefined ? { shellGate: parentGate.shellGate } : {}),
2180
2180
  ...(parentGate.persistedRuleBuckets !== undefined ? { persistedRuleBuckets: parentGate.persistedRuleBuckets } : {}),
2181
2181
  admittedOrgScopes: parentGate.admittedOrgScopes,
2182
+ ...(parentGate.sharedArtifactReads !== undefined ? { sharedArtifactReads: parentGate.sharedArtifactReads } : {}),
2182
2183
  };
2183
2184
  const observerInternals = { ...(delegationSpendParent !== undefined ? { spendParent: delegationSpendParent } : {}), ...(ctx.interactionPosture !== undefined ? { parentInteractionPosture: ctx.interactionPosture } : {}), ...(pickedRef !== undefined ? { inheritedModelRef: pickedRef } : {}), ...(observerGate !== undefined ? { inheritedGate: observerGate } : {}), toolCeiling: [...childCeiling, childOwnLayer], observerLeg: true, objectiveAuthor: "observer", ...(ctx.delegationOwner !== undefined ? { delegationOwner: ctx.delegationOwner } : {}), sessionIdMintedBySpawner: true, onSessionVerified: (id) => void observerRowsVerified.add(id) };
2184
- if (spec.sessionId !== undefined && judgedOwnerSeat(spec, observerInternals) === undefined)
2185
+ if (spec.sessionId !== undefined && judgedOwnerSeat(observerInternals) === undefined)
2185
2186
  observerRowsVerified.add(spec.sessionId);
2186
2187
  const r = await opts.runner.runTask(spec, observerInternals);
2187
2188
  if (r.terminal.kind !== "completed") {
@@ -2341,7 +2342,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2341
2342
  ...(ctx.delegationOwner !== undefined ? { delegationOwner: ctx.delegationOwner } : {}),
2342
2343
  ...(treeScope !== undefined ? { registryScope: treeScope } : {}),
2343
2344
  ...(ctx.checkpointScopeForChildren !== undefined ? { checkpointScope: ctx.checkpointScopeForChildren } : {}),
2344
- ...(ctx.inheritedGateForChildren ? { inheritedGate: ctx.inheritedGateForChildren() } : {}),
2345
+ ...(ctx.inheritedGateForChildren ? { inheritedGate: reviveClaim !== undefined ? wakeGate(ctx.inheritedGateForChildren()) : ctx.inheritedGateForChildren() } : {}),
2345
2346
  ...(ctx.questionFaceStripped === true ? { questionFaceStripped: true } : {}),
2346
2347
  ownOrgAdmissionRef: { current: reviveClaim !== undefined ? readDurableOrgAdmission(reviveClaim.row) : undefined },
2347
2348
  peerSelfRef: (() => {
@@ -2757,13 +2758,12 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2757
2758
  ...(agentName !== undefined ? { name: agentName } : {}),
2758
2759
  ...(ctx.taskId !== undefined && ctx.taskId !== ctx.sessionId ? { parentTaskId: ctx.taskId } : {}),
2759
2760
  ...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
2760
- ...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
2761
- ...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
2761
+ ...recordedRootAnchor(ctx, forkTree),
2762
2762
  ...(ctx.rootSessionScope !== undefined ? { rootSessionScope: ctx.rootSessionScope } : {}),
2763
2763
  ...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
2764
2764
  deliveryChannel: "attaching",
2765
2765
  toolUseId: ctx.toolCallId,
2766
- ...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
2766
+ ...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}), ...(ctx.delegationOwner !== undefined ? { delegationTree: ctx.delegationOwner } : {}),
2767
2767
  ...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor(), spawnDepth: depth + 1 } : {}),
2768
2768
  abort,
2769
2769
  yieldLane: "fork_child",
@@ -3205,6 +3205,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3205
3205
  const bgScope = treeScope;
3206
3206
  const promotedRowOwner = (signal) => (reviveRow !== undefined ? rowOwnerReading(opts.runner.sessions, reviveRow.sessionId) : delegationOwnerOf(ctx.delegationOwner, signal));
3207
3207
  let spawnTreeOwner;
3208
+ let spawnTree;
3208
3209
  if (reviveRow === undefined) {
3209
3210
  const tree = await promotedRowOwner(ctx.signal).catch(() => "stopped");
3210
3211
  if (tree === "stopped" || !tree.bound) {
@@ -3213,6 +3214,21 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3213
3214
  return tree === "stopped" ? spawnAbortedResult(await finishWorktree(), faultDetails()) : ownerUnboundResult(true, tree);
3214
3215
  }
3215
3216
  spawnTreeOwner = tree.owner;
3217
+ spawnTree = tree;
3218
+ }
3219
+ let revivalSeat;
3220
+ let revivalRefusal;
3221
+ if (reviveRow !== undefined) {
3222
+ const born = bg.agentStore !== undefined ? await revivalTreeSeat(opts.runner.sessions, bg.agentStore, { row: reviveRow, rev: reviveClaim.rev, parked: parkedResume !== undefined }, ctx.signal).catch(() => "stopped") : { refused: "no durable record store holds the agent's record" };
3223
+ if (born !== "stopped" && "refused" in born && parkedResume !== undefined && born.identity !== true)
3224
+ revivalRefusal = born.refused;
3225
+ else if (born === "stopped" || "refused" in born) {
3226
+ dropHostAbortListener();
3227
+ await cancelObserver();
3228
+ return born === "stopped" ? spawnAbortedResult(await finishWorktree(), faultDetails()) : ownerUnboundResult(true, { bound: false, reason: born.refused });
3229
+ }
3230
+ else
3231
+ revivalSeat = born.seat;
3216
3232
  }
3217
3233
  const bgEntryPool = delegationEntryPool(entryPoolSeat);
3218
3234
  const capLedgerKey = bgEntryPool.key;
@@ -3292,6 +3308,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3292
3308
  ...(reviveRow.model !== undefined ? { model: reviveRow.model } : {}),
3293
3309
  deliveryChannel: "attaching",
3294
3310
  toolUseId: ctx.toolCallId,
3311
+ ...(revivalSeat !== undefined ? { delegationTree: revivalSeat } : {}),
3295
3312
  ...(bg.agentStore !== undefined ? { store: bg.agentStore, durableSeed: { record: reviveClaim.row, rev: reviveClaim.rev } } : {}),
3296
3313
  ...(parkedResume !== undefined
3297
3314
  ? {
@@ -3321,13 +3338,13 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3321
3338
  ...(agentName !== undefined ? { name: agentName } : {}),
3322
3339
  ...(ctx.taskId !== undefined && ctx.taskId !== ctx.sessionId ? { parentTaskId: ctx.taskId } : {}),
3323
3340
  ...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
3324
- ...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
3325
- ...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
3341
+ ...recordedRootAnchor(ctx, spawnTree),
3326
3342
  ...(ctx.rootSessionScope !== undefined ? { rootSessionScope: ctx.rootSessionScope } : {}),
3327
3343
  ...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
3328
3344
  deliveryChannel: "attaching",
3329
3345
  toolUseId: ctx.toolCallId,
3330
3346
  ...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
3347
+ ...(ctx.delegationOwner !== undefined ? { delegationTree: ctx.delegationOwner } : {}),
3331
3348
  ...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor(), spawnDepth: depth + 1 } : {}),
3332
3349
  abort,
3333
3350
  yieldLane: parkCapable ? "parkable" : "no_park_lane",
@@ -3505,6 +3522,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3505
3522
  const bgLaneInternals = bgSink
3506
3523
  ? {
3507
3524
  ...childInternals,
3525
+ ...(revivalSeat !== undefined ? { delegationOwner: revivalSeat } : {}),
3508
3526
  ...(bgQuestionStrip !== undefined ? bgQuestionStrip.internalsFlag : {}),
3509
3527
  ...(bgPlacement !== undefined ? { sessionPlacement: bgPlacement } : {}), ...(reviveRow === undefined ? { sessionIdMintedBySpawner: true } : {}),
3510
3528
  onNotifyInjectorReady: s2NotifyReady,
@@ -3541,6 +3559,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3541
3559
  }
3542
3560
  : {
3543
3561
  ...childInternals,
3562
+ ...(revivalSeat !== undefined ? { delegationOwner: revivalSeat } : {}),
3544
3563
  ...(bgQuestionStrip !== undefined ? bgQuestionStrip.internalsFlag : {}),
3545
3564
  ...(bgPlacement !== undefined ? { sessionPlacement: bgPlacement } : {}), ...(reviveRow === undefined ? { sessionIdMintedBySpawner: true } : {}),
3546
3565
  onNotifyInjectorReady: s2NotifyReady,
@@ -3634,6 +3653,8 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3634
3653
  "superseded by a newer claim) — the approval was NOT consumed; re-list pending approvals and claim afresh"));
3635
3654
  }
3636
3655
  }
3656
+ if (revivalRefusal !== undefined)
3657
+ return rollbackAndThrow(Object.assign(new Error(`the delegation tree's owner does not bind — ${revivalRefusal}`), { code: DELEGATION_OWNER_UNBOUND }));
3637
3658
  const afterCheckpointResolve = async () => {
3638
3659
  attemptEnding = "failed";
3639
3660
  const opened = await bgRegistry.consumeParkedFlip(taskId, { agentStore: bg.agentStore }, pr.ticket);
@@ -4063,7 +4084,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4063
4084
  try {
4064
4085
  if (ctx.onSubagentSpawn || observerPairing) {
4065
4086
  if (ctx.onSubagentSpawn)
4066
- syncRowVerified = await verifiedAtBirth(judgedOwnerSeat({}, childInternals), ctx.signal);
4087
+ syncRowVerified = await verifiedAtBirth(judgedOwnerSeat(childInternals), ctx.signal);
4067
4088
  retainEntry = ctx.onSubagentSpawn ? await tryRetainChild(ctx.subagentRetain, () => syncRowVerified) : undefined;
4068
4089
  if (retainEntry)
4069
4090
  stepRecorder.lockTo(retainEntry.childSessionId);
@@ -1,10 +1,9 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { canonicalize, UNCANONICALIZABLE } from "../core/canonical-json.js";
3
3
  import { SPAWNER_SURFACE_LEG_KINDS } from "../core/tool-face.js";
4
- import { ruleSpellingOf } from "../core/permission-rule-syntax.js";
5
4
  import { TOOL_CATALOG_ENTRIES } from "../core/tool-catalog-entries.js";
6
5
  import { isCoveringRuleName, ruleNameCovers, ruleNameReachIntoPeer } from "../core/namespaced-rule-name.js";
7
- import { splitNamespacedName } from "@sema-agent/primitives";
6
+ import { ruleSpellingOf, splitNamespacedName } from "@sema-agent/primitives";
8
7
  import { readToolNameList, valueTypeLabel } from "../core/tool-name-list.js";
9
8
  export function readDeniedEntry(entry) {
10
9
  if (typeof entry !== "string")
@@ -2,6 +2,7 @@ import { Type } from "typebox";
2
2
  import { namesRoleBase } from "../prompt-assembly/role-base.js";
3
3
  import { releaseSession } from "./session-util.js";
4
4
  import { childClampSeats, clampSourceOf, engineHeadlessLegSeats, unionAddOnly } from "../core/child-clamp-seats.js";
5
+ import { mergeChildSandbox } from "../core/command-sandbox.js";
5
6
  import { applyParentSpecSeat, parentSpecSeatOf } from "../core/parent-spec-seat.js";
6
7
  import { mapNestedSuspend, isDurablePause, pauseFamily } from "./suspend-guard.js";
7
8
  import { delimitUntrusted, sanitizeUntrustedText } from "../core/untrusted-text.js";
@@ -130,6 +131,10 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
130
131
  const foldedReadDeny = [...(specBase.readDenyPatterns ?? []), ...(result.effectiveReadDenyPatterns ?? [])];
131
132
  const foldedConfigDirs = unionAddOnly("agentConfigDirs", specBase.agentConfigDirs, result.effectiveAgentConfigDirs);
132
133
  const foldedHomeDirs = unionAddOnly("agentHomeDirs", specBase.agentHomeDirs, result.effectiveAgentHomeDirs);
134
+ const foldedReadBlock = result.effectiveBlockReadsOutsideRoots === true || specBase.blockReadsOutsideRoots === true ? true : undefined;
135
+ const mergedSandbox = mergeChildSandbox(result.effectiveSandbox, specBase.sandbox);
136
+ const laterSandbox = mergedSandbox !== undefined ? structuredClone(mergedSandbox) : undefined;
137
+ const continuedSandbox = () => (laterSandbox !== undefined ? { sandbox: structuredClone(laterSandbox) } : {});
133
138
  const carryFrozenPosture = (r) => {
134
139
  const face = result.effectiveReadFace === "roots" ? "roots" : r.effectiveReadFace;
135
140
  const keyOf = (e) => `${e.caseSensitive ? "s" : "i"} ${e.pattern}`;
@@ -149,7 +154,8 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
149
154
  };
150
155
  const evidenceMode = config.evidence != null && config.evidence.trim() !== "";
151
156
  const verifierPrompt = config.verifierPrompt ?? (evidenceMode ? STATIC_VERIFICATION_PROMPT : VERIFICATION_PROMPT);
152
- const legInternals = () => recipeContinuationLeg(placement.laterLeg(result));
157
+ const laterLegFold = result.effectiveExternalContentTarget === true ? { externalContentTarget: true } : {};
158
+ const legInternals = () => ({ ...recipeContinuationLeg(placement.laterLeg(result)), ...laterLegFold });
153
159
  const runsAs = placement.laterIdentity({});
154
160
  const verifierLegInternals = (round) => {
155
161
  const { compositionLeg: _notThisLeg, ...leg } = legInternals();
@@ -167,10 +173,12 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
167
173
  handsReadOnly: config.verifierHandsReadOnly ?? true,
168
174
  ...engineHeadlessLegSeats(),
169
175
  ...(specBase.checkpointStore !== undefined ? { checkpointStore: specBase.checkpointStore } : {}),
176
+ ...continuedSandbox(),
170
177
  ...childClampSeats({
171
178
  ...clampSourceOf(specBase),
172
179
  readFace: foldedRootsFace ? "roots" : undefined,
173
180
  writeFace: foldedRootsWriteFace ? "roots" : undefined,
181
+ blockReadsOutsideRoots: foldedReadBlock,
174
182
  readDenyPatterns: foldedReadDeny,
175
183
  agentConfigDirs: foldedConfigDirs,
176
184
  agentHomeDirs: foldedHomeDirs,
@@ -296,12 +304,15 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
296
304
  break;
297
305
  }
298
306
  refuseUnhonorableInternals(internals, "before_leg");
307
+ const { blockReadsOutsideRoots: _readBlockOffTheResult, ...withoutReadBlock } = turns.spec ?? specBase;
308
+ const { sandbox: _sandboxOffTheResult, ...continuedConfig } = withoutReadBlock;
299
309
  const fixLegSpec = {
300
- ...placement.laterIdentity(withOpeningObjective(turns.spec ?? specBase, fixObjective(outcome.findings), current.sessionId)),
310
+ ...placement.laterIdentity(withOpeningObjective({ ...continuedConfig, ...continuedSandbox() }, fixObjective(outcome.findings), current.sessionId)),
301
311
  ...childClampSeats({
302
312
  ...clampSourceOf(specBase),
303
313
  readFace: foldedRootsFace ? "roots" : specBase.readFace,
304
314
  writeFace: foldedRootsWriteFace ? "roots" : specBase.writeFace,
315
+ blockReadsOutsideRoots: foldedReadBlock,
305
316
  readDenyPatterns: foldedReadDeny,
306
317
  agentConfigDirs: foldedConfigDirs,
307
318
  agentHomeDirs: foldedHomeDirs,
@@ -1,3 +1,4 @@
1
+ import { isCheckpointRowUnreadable as isUnreadableRowRefusal } from "../core/checkpoint-queries.js";
1
2
  import { isolationScopeOf } from "../core/isolation-scope.js";
2
3
  import { parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
3
4
  import { thrownText } from "../core/thrown-value.js";
@@ -28,7 +29,16 @@ async function adoptYieldedAgents(bag, execute, enrich, leg) {
28
29
  const row = await store.get(summary.handle, scope);
29
30
  if (row === null || row.status !== "parked" || row.parkedCheckpointToken === undefined)
30
31
  continue;
31
- const cp = await parkStore.get(row.parkedCheckpointToken);
32
+ let cp;
33
+ try {
34
+ cp = await parkStore.get(row.parkedCheckpointToken);
35
+ }
36
+ catch (e) {
37
+ if (!isUnreadableRowRefusal(e))
38
+ throw e;
39
+ refused.push({ id: row.handle, why: foreignLine(thrownText(e), 300) });
40
+ continue;
41
+ }
32
42
  if (cp === null || cp.status !== "pending" || cp.gate.kind !== "resource_limit" || cp.gate.reason !== "preempt")
33
43
  continue;
34
44
  const claim = await registry.claimParkedAgent({ agentStore: store, checkpointStore: parkStore }, row.handle, { owner, scope, sessionId, ...callOccupant(ctx, {}) });
@@ -1,3 +1,14 @@
1
+ /**
2
+ * The one reading of a Claude model id — parsing it into its parts and telling whether two ids name the same model. Its
3
+ * readers: the reference preset table's lookup (`referenceModelIdOf`, `reference-model-traits.ts`), and fast mode's rule, which
4
+ * reads the model an endpoint's `speed` refusal names (`fastModeFallbackOf`, `fast-mode.ts`). A module of its own so a reader
5
+ * of the id does not reach the preset table (the prompt-assembly path never does: pinned by
6
+ * test/backlog4297-s1-reference-presets.test.ts).
7
+ */
8
+ /** The boundary-aware LAST path segment of a model id, case-folded (BYOM ids may carry provider prefixes —
9
+ * "openrouter/anthropic/claude-fable-5"): the tail every model-id comparison reads — this module's parse, and the tool
10
+ * model gate's exact-id rows. Prompt text never reads a model id; it selects on the model's declared traits. */
11
+ export declare function modelIdTail(id: string): string;
1
12
  /** A Claude model id read into its parts: `claude-<family>-<major>[-<minor>]`, or the older `claude-<major>[-<minor>]-<family>`. */
2
13
  export interface ParsedClaudeModelId {
3
14
  readonly family: string;
@@ -1,4 +1,6 @@
1
- import { modelIdTail } from "../core/tool-model-gate.js";
1
+ export function modelIdTail(id) {
2
+ return id.toLowerCase().split("/").pop() ?? "";
3
+ }
2
4
  const REGION_PREFIXES = Object.freeze(["us", "eu", "apac", "jp", "au", "us-gov", "global"]);
3
5
  const ACCEPTED_SUFFIX = /^(?:-fast|-latest)?(?:-v\d{1,3}@\d{8}|[-@]\d{8})?(?:-v\d{1,3}(?::\d{1,3})?)?$/;
4
6
  const FAMILY_FIRST = /^claude-([a-z]+)-(\d{1,2})(?!\d)(?:-(\d{1,2})(?!\d))?/;