@sema-agent/core 7.72.0 → 7.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -229,96 +229,106 @@ export async function prepareCapsAndWorkflow(input) {
229
229
  return;
230
230
  if (permissionMode.receipt().effective !== "auto" || autoModeFace === undefined)
231
231
  return;
232
- const am = autoModeFace;
233
- const classifierSeat = classifierSeatModel({ deps, main: model });
234
- let classifierModel = classifierSeat.model;
235
- if ((await derivedRouteFallsBack({ seat: "auto-mode-classifier", derived: classifierModel, primary: model, brain: modelLaneBrainOf(deps), getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId, onBrokenPairing: autoModeClassifierFallbackOf(am.classifierFallback) === "none" ? "refuse" : "fall_back" })).action === "fall_back") {
236
- classifierModel = model;
237
- }
238
- announceClassifierRoleDefaulted({ onNotice: deps.onNotice, seat: { ...classifierSeat, model: classifierModel }, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) });
239
- const classifierLaneRule = peerLaneActive && peerSendMessageBuiltIn;
240
- const table = await readDenyEntries();
241
- const derivedDenyRules = readDenyClassifierRules(table.entries, table.ruleRows);
242
- let classifierSystemPromptMemo;
243
- const classifierSystemPrompt = () => (classifierSystemPromptMemo ??= buildAutoModePrompt({ ...am, derivedDenyRules, ...(classifierLaneRule ? { crossSessionMessagesRule: CROSS_SESSION_CLASSIFIER_RULE } : {}) }));
244
- const classifierRuntime = brainToRuntime(observingBrain(modelLaneBrainOf(deps), observeSideRequest));
245
- const runtimeByAccount = new WeakMap();
246
- const classifierRuntimeFor = (seat) => {
247
- const account = spendAccountOf(seat);
248
- if (account === undefined)
249
- return classifierRuntime;
250
- let rt = runtimeByAccount.get(account);
251
- if (rt === undefined)
252
- runtimeByAccount.set(account, (rt = brainToRuntime(observingBrain(modelLaneBrainOf(meteredDepsOf(deps, account)), observeSideRequest))));
253
- return rt;
254
- };
255
- const classifierRungs = classifierLadderRungs(am.classifierFallback, classifierModel, model);
256
- const denialTracking = createAutoModeDenialTracker(am.denialLimit);
257
- const decider = createAutoModeDecider({
258
- ...(am.timeoutMs !== undefined ? { timeoutMs: am.timeoutMs } : {}), ...(am.rateLimitBreakAfter !== undefined ? { rateLimitBreakAfter: am.rateLimitBreakAfter } : {}),
259
- candidates: classifierRungs.map((m) => m.id),
260
- onClassified: classifierRoundObserver({ tracer: deps.tracer, onNotice: deps.onNotice, taskId: hostTaskId, seatModelId: classifierModel.id, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) }),
261
- assemble: async (input) => {
262
- const ctx = await session.buildContext();
263
- const known = ctx.messages.filter((m) => !isSyntheticApiErrorMessage(m) && (m.role === "user" || m.role === "assistant" || m.role === "toolResult"));
264
- return renderAutoModeWindow(known, am.window, { delegated }) + renderAutoModeAction(input);
265
- },
266
- classify: async (classifyInput, signal, rung, userPrompt) => {
267
- const runtime = classifierRuntimeFor(classifyInput.spendSeat);
268
- const payer = spendAccountOf(classifyInput.spendSeat);
269
- const paidHere = payer === undefined || payer === meterOf(deps)?.account;
270
- const rungModel = rung !== undefined ? classifierRungs[rung.index] : undefined;
271
- if (rung === undefined || rungModel === undefined) {
272
- throw new Error(`the auto-mode classifier was asked at ladder position ${JSON.stringify(rung?.index)}, which this arming did not build`);
273
- }
274
- if (userPrompt === undefined) {
275
- throw new Error("the auto-mode classifier was asked with no assembled question, which this arming builds once per classification");
276
- }
277
- const classifierAuth = await askPerModelAuth(spec.getApiKeyAndHeaders, rungModel, spec);
278
- const request = async (seat, suffix) => {
279
- const book = paidHere ? sideCallBookRef.book : NOT_BOOKED_HERE;
280
- if (book === undefined)
281
- throw new Error("the auto-mode classifier was asked before the run body bound the leg's usage account, which it does before any tool call");
282
- let replied = false;
283
- const cut = () => {
284
- if (!replied)
285
- book("classifier", rungModel, undefined);
286
- };
287
- signal?.addEventListener("abort", cut, { once: true });
288
- let response;
289
- try {
290
- response = await runtime.completeSimple(rungModel, { systemPrompt: classifierSystemPrompt(), messages: [{ role: "user", content: userPrompt + suffix, timestamp: Date.now() }] }, {
291
- signal,
292
- maxRetries: AUTO_MODE_CLASSIFIER_MAX_RETRIES,
293
- ...classifierSeatOptions(rungModel, seat),
294
- ...classifierAuth,
295
- });
232
+ try {
233
+ const am = autoModeFace;
234
+ const classifierSeat = classifierSeatModel({ deps, main: model });
235
+ let classifierModel = classifierSeat.model;
236
+ if ((await derivedRouteFallsBack({ seat: "auto-mode-classifier", derived: classifierModel, primary: model, brain: modelLaneBrainOf(deps), getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId, onBrokenPairing: autoModeClassifierFallbackOf(am.classifierFallback) === "none" ? "refuse" : "fall_back" })).action === "fall_back") {
237
+ classifierModel = model;
238
+ }
239
+ announceClassifierRoleDefaulted({ onNotice: deps.onNotice, seat: { ...classifierSeat, model: classifierModel }, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) });
240
+ const classifierLaneRule = peerLaneActive && peerSendMessageBuiltIn;
241
+ const table = await readDenyEntries();
242
+ const derivedDenyRules = readDenyClassifierRules(table.entries, table.ruleRows);
243
+ let classifierSystemPromptMemo;
244
+ const classifierSystemPrompt = () => (classifierSystemPromptMemo ??= buildAutoModePrompt({ ...am, derivedDenyRules, ...(classifierLaneRule ? { crossSessionMessagesRule: CROSS_SESSION_CLASSIFIER_RULE } : {}) }));
245
+ const classifierRuntime = brainToRuntime(observingBrain(modelLaneBrainOf(deps), observeSideRequest));
246
+ const runtimeByAccount = new WeakMap();
247
+ const classifierRuntimeFor = (seat) => {
248
+ const account = spendAccountOf(seat);
249
+ if (account === undefined)
250
+ return classifierRuntime;
251
+ let rt = runtimeByAccount.get(account);
252
+ if (rt === undefined)
253
+ runtimeByAccount.set(account, (rt = brainToRuntime(observingBrain(modelLaneBrainOf(meteredDepsOf(deps, account)), observeSideRequest))));
254
+ return rt;
255
+ };
256
+ const classifierRungs = classifierLadderRungs(am.classifierFallback, classifierModel, model);
257
+ const denialTracking = createAutoModeDenialTracker(am.denialLimit);
258
+ const decider = createAutoModeDecider({
259
+ ...(am.timeoutMs !== undefined ? { timeoutMs: am.timeoutMs } : {}), ...(am.rateLimitBreakAfter !== undefined ? { rateLimitBreakAfter: am.rateLimitBreakAfter } : {}),
260
+ candidates: classifierRungs.map((m) => m.id),
261
+ onClassified: classifierRoundObserver({ tracer: deps.tracer, onNotice: deps.onNotice, taskId: hostTaskId, seatModelId: classifierModel.id, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) }),
262
+ assemble: async (input) => {
263
+ const ctx = await session.buildContext();
264
+ const known = ctx.messages.filter((m) => !isSyntheticApiErrorMessage(m) && (m.role === "user" || m.role === "assistant" || m.role === "toolResult"));
265
+ return renderAutoModeWindow(known, am.window, { delegated }) + renderAutoModeAction(input);
266
+ },
267
+ classify: async (classifyInput, signal, rung, userPrompt) => {
268
+ const runtime = classifierRuntimeFor(classifyInput.spendSeat);
269
+ const payer = spendAccountOf(classifyInput.spendSeat);
270
+ const paidHere = payer === undefined || payer === meterOf(deps)?.account;
271
+ const rungModel = rung !== undefined ? classifierRungs[rung.index] : undefined;
272
+ if (rung === undefined || rungModel === undefined) {
273
+ throw new Error(`the auto-mode classifier was asked at ladder position ${JSON.stringify(rung?.index)}, which this arming did not build`);
296
274
  }
297
- finally {
298
- replied = true;
299
- signal?.removeEventListener("abort", cut);
275
+ if (userPrompt === undefined) {
276
+ throw new Error("the auto-mode classifier was asked with no assembled question, which this arming builds once per classification");
300
277
  }
301
- book("classifier", rungModel, response);
302
- const refused = spendRefusalOf(response);
303
- if (refused !== undefined)
304
- throw autoModeSpendRefused(refused.stop.reason);
305
- const failure = classifierReplyFailure(response);
306
- if (failure !== undefined)
307
- throw failure;
308
- return response;
309
- };
310
- let response = await request(classifierRungSeat(rungModel), CLASSIFIER_ATTEMPT_SUFFIX.first);
311
- if (classifierReplyAsksAgain(response) && signal?.aborted !== true)
312
- response = await request(CLASSIFIER_THINK_SEAT, CLASSIFIER_ATTEMPT_SUFFIX.reask);
313
- return classifierReplyVerdictText(response);
314
- },
315
- });
316
- const arming = am.persistArming === true ? mintPersistedArming(am, classifierLaneRule, classifierSystemPrompt(), derivedDenyRules, deps.onError, sessionId) : undefined;
317
- if (autoModeDeciderRef.current !== undefined)
318
- return;
319
- autoModeDeciderRef.current = decider;
320
- autoModeDenialTrackingRef.current = denialTracking;
321
- autoModeArmingRef.current = arming;
278
+ const classifierAuth = await askPerModelAuth(spec.getApiKeyAndHeaders, rungModel, spec);
279
+ const request = async (seat, suffix) => {
280
+ const book = paidHere ? sideCallBookRef.book : NOT_BOOKED_HERE;
281
+ if (book === undefined)
282
+ throw new Error("the auto-mode classifier was asked before the run body bound the leg's usage account, which it does before any tool call");
283
+ let replied = false;
284
+ const cut = () => {
285
+ if (!replied)
286
+ book("classifier", rungModel, undefined);
287
+ };
288
+ signal?.addEventListener("abort", cut, { once: true });
289
+ let response;
290
+ try {
291
+ response = await runtime.completeSimple(rungModel, { systemPrompt: classifierSystemPrompt(), messages: [{ role: "user", content: userPrompt + suffix, timestamp: Date.now() }] }, {
292
+ signal,
293
+ maxRetries: AUTO_MODE_CLASSIFIER_MAX_RETRIES,
294
+ ...classifierSeatOptions(rungModel, seat),
295
+ ...classifierAuth,
296
+ });
297
+ }
298
+ finally {
299
+ replied = true;
300
+ signal?.removeEventListener("abort", cut);
301
+ }
302
+ book("classifier", rungModel, response);
303
+ const refused = spendRefusalOf(response);
304
+ if (refused !== undefined)
305
+ throw autoModeSpendRefused(refused.stop.reason);
306
+ const failure = classifierReplyFailure(response);
307
+ if (failure !== undefined)
308
+ throw failure;
309
+ return response;
310
+ };
311
+ let response = await request(classifierRungSeat(rungModel), CLASSIFIER_ATTEMPT_SUFFIX.first);
312
+ if (classifierReplyAsksAgain(response) && signal?.aborted !== true)
313
+ response = await request(CLASSIFIER_THINK_SEAT, CLASSIFIER_ATTEMPT_SUFFIX.reask);
314
+ return classifierReplyVerdictText(response);
315
+ },
316
+ });
317
+ const arming = am.persistArming === true ? mintPersistedArming(am, classifierLaneRule, classifierSystemPrompt(), derivedDenyRules, deps.onError, sessionId) : undefined;
318
+ if (autoModeDeciderRef.current !== undefined)
319
+ return;
320
+ autoModeDeciderRef.current = decider;
321
+ autoModeDenialTrackingRef.current = denialTracking;
322
+ autoModeArmingRef.current = arming;
323
+ }
324
+ catch (e) {
325
+ const err = asThrownError(e);
326
+ const code = err.code;
327
+ const wrapped = new Error(`Auto-mode classifier could not be armed — check RunnerDeps.autoMode and roles.classifier (${err.message}).`, { cause: err });
328
+ if (typeof code === "string")
329
+ wrapped.code = code;
330
+ throw wrapped;
331
+ }
322
332
  };
323
333
  permissionMode.bindArming({ caps: runtimeCaps, autoFacePresent: autoModeFace !== undefined, capsFaulted: runtimeCapsFaulted, armAuto: armAutoMode, onArmFault: (e) => deps.onError?.(asThrownError(e), { phase: "config", sessionId }) });
324
334
  const deploymentWorkflowReady = runnerSelf !== undefined && isSelfOrchestrationActive(spec, deps);
@@ -284,6 +284,7 @@ type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "
284
284
  skills: TaskSpec["skills"];
285
285
  projectMemory: TaskSpec["projectMemory"];
286
286
  deploymentRoles: RunnerDeps["roles"];
287
+ hostInstance: RunnerDeps["host"];
287
288
  taskRoles: TaskSpec["roles"];
288
289
  interactionPostureInput: ConfigRefusalInput;
289
290
  };
@@ -5,6 +5,7 @@ import { MICRO_COMPACT_MACHINES } from "../context-edit.js";
5
5
  import { assertAddOnlySeats } from "../child-clamp-seats.js";
6
6
  import { CROSS_BOUNDARY_POSTURES } from "../cross-boundary-taint.js";
7
7
  import { compileHostFloor } from "../host-floor.js";
8
+ import { receiveHostInstance } from "../host-instance.js";
8
9
  import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
9
10
  import { resolveCheckpointStore } from "../checkpoint-store.js";
10
11
  import { refuseUncountedOwnModel } from "./own-model-money-door.js";
@@ -23,6 +24,7 @@ import { malformedPricingField, priceTableOf } from "../pricing.js";
23
24
  import { ownMoneyCeiling, priceTableInput, unpricedModelRefusal } from "./side-call-account.js";
24
25
  import { fastTierNoticeTo } from "../fast-tier-door.js";
25
26
  import { receiveRoleMapPriced, resolveRunModel } from "./seat-model-doors.js";
27
+ import { keepDeploymentOf } from "./model-lane-seat.js";
26
28
  import { preflightLockedConfig, received } from "../locked-config.js";
27
29
  import { enterConfigDoor, refusalAbout, resolveSeatValue } from "../config-refusal-input.js";
28
30
  import { assertRetentionWords } from "../retention.js";
@@ -110,9 +112,12 @@ export function assertDurableApprovalDeclaresScope(declared) {
110
112
  const reading = readDeclaredCheckpointScope(declared);
111
113
  if (reading.kind === "scope")
112
114
  return;
113
- const e = limitConfigError("config.invalid_argument", `TaskSpec.durableApproval must be an object carrying a non-empty string \`scope\` (got ${typeof declared === "object" && declared !== null ? "an object" : describeRejectedValue(declared)}: ${reading.fault}) — the object is plain data (no accessor, no Proxy) and the scope is a name (visible content; no control, separator or format character), the rule \`isolationScope\` is judged by; it is the isolation key every durable approval is filed under, and the one a parked child's revival reads the opt-in back by; an opt-in that names none is refused, never read as the isolation scope on one path and as no opt-in on another. Set \`scope\`, or omit \`durableApproval\`.`);
114
- e.detail = { field: "durableApproval.scope" };
115
- throw e;
115
+ const message = reading.at === "ttlMs"
116
+ ? `TaskSpec.durableApproval.ttlMs must be a finite number >= 0 when present (got ${reading.fault}) — the opt-in is read as plain data, and its \`ttlMs\` is the lifetime of every approval parked under it; omit \`ttlMs\` for an approval no operator bounds.`
117
+ : reading.at === "undeclared"
118
+ ? `TaskSpec.durableApproval must be plain data (got ${reading.fault} in a member the opt-in does not declare) — an opt-in carries \`scope\` and, optionally, \`ttlMs\`; remove the other member.`
119
+ : `TaskSpec.durableApproval must be an object carrying a non-empty string \`scope\` (got ${typeof declared === "object" && declared !== null ? "an object" : describeRejectedValue(declared)}: ${reading.fault}) — the object is plain data (no accessor, no Proxy) and the scope is a name (visible content; no control, separator or format character), the rule \`isolationScope\` is judged by; it is the isolation key every durable approval is filed under, and the one a parked child's revival reads the opt-in back by; an opt-in that names none is refused, never read as the isolation scope on one path and as no opt-in on another. Set \`scope\`, or omit \`durableApproval\`.`;
120
+ throw Object.assign(limitConfigError("config.invalid_argument", message), { detail: { field: reading.at === "ttlMs" ? "durableApproval.ttlMs" : reading.at === "undeclared" || (reading.at === undefined && reading.fault.startsWith("not plain data — ")) ? "durableApproval" : "durableApproval.scope" } });
116
121
  }
117
122
  export function assertDurableApprovalDeclaration(declared) {
118
123
  assertDurableApprovalDeclaresScope(declared);
@@ -254,6 +259,7 @@ export function configValueDoors(input) {
254
259
  const startedBy = holderSeatStarterOf(input.leg);
255
260
  let deps = input.deps;
256
261
  enterConfigDoor("deps", () => assertNoRetiredRunnerDeps(deps));
262
+ const hostInstance = enterConfigDoor("deps", () => receiveHostInstance(deps.host, "RunnerDeps.host"));
257
263
  enterConfigDoor("taskConfig", () => assertPrincipalValue(spec.principal));
258
264
  enterConfigDoor("taskConfig", () => assertPrincipalIsNotUsageKey(spec.principal));
259
265
  enterConfigDoor("taskConfig", () => assertPrincipalValue(spec.isolationScope, "isolationScope"));
@@ -264,7 +270,7 @@ export function configValueDoors(input) {
264
270
  const promptHost = enterConfigDoor("taskConfig", () => resolveHost(spec));
265
271
  const deploymentRoles = enterConfigDoor("deps", () => receiveRoleMapPriced(deps.roles, "RunnerDeps.roles", deps.pricing, input.tellFastTier));
266
272
  if (deploymentRoles !== undefined)
267
- deps = { ...deps, roles: deploymentRoles };
273
+ deps = keepDeploymentOf(deps, { ...deps, roles: deploymentRoles });
268
274
  const taskRoles = enterConfigDoor("taskConfig", () => receiveRoleMapPriced(spec.roles, "TaskSpec.roles", deps.pricing, input.tellFastTier));
269
275
  const promptBinding = enterConfigDoor("taskConfig", () => resolvePromptBinding(spec));
270
276
  const promptLocale = enterConfigDoor("taskConfig", () => resolvePromptLocale(spec));
@@ -400,7 +406,7 @@ export function configValueDoors(input) {
400
406
  enterConfigDoor("taskConfig", () => assertRetentionWords({ ...retention, stores: [{ name: "checkpointStore", store: taskStore }] }));
401
407
  const { posture: resolvedInteractionPosture, input: interactionPostureInput } = interactionPostureDoor(spec, input.parentInteractionPosture, deps, input.discloseInteractionPosture);
402
408
  enterConfigDoor("taskConfig", () => screenModelRole(spec.modelRole));
403
- return { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, taskRoles, resolvedInteractionPosture, interactionPostureInput };
409
+ return { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, hostInstance, taskRoles, resolvedInteractionPosture, interactionPostureInput };
404
410
  }
405
411
  function holderSeatStarterOf(internals) {
406
412
  return engineLaneLegOf(internals) ? "engine" : "host";
@@ -438,9 +444,9 @@ export function prepareConfigDoors(input) {
438
444
  }
439
445
  };
440
446
  const tellFastTier = input.refusalSink !== undefined ? fastTierNoticeTo(input.refusalSink, callerSpec.sessionId ?? "(pre-session)") : undefined;
441
- const { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, taskRoles, resolvedInteractionPosture, interactionPostureInput } = configValueDoors({ spec: callerSpec, deps: input.deps, resumeLeg: resume !== undefined, sessions, leg: internals, parentInteractionPosture: internals?.parentInteractionPosture, discloseInteractionPosture: discloseInteractionPostureRefusal, ...(tellFastTier !== undefined ? { tellFastTier } : {}), receivedPeers: input.receipt, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
447
+ const { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, hostInstance, taskRoles, resolvedInteractionPosture, interactionPostureInput } = configValueDoors({ spec: callerSpec, deps: input.deps, resumeLeg: resume !== undefined, sessions, leg: internals, parentInteractionPosture: internals?.parentInteractionPosture, discloseInteractionPosture: discloseInteractionPostureRefusal, ...(tellFastTier !== undefined ? { tellFastTier } : {}), receivedPeers: input.receipt, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
442
448
  const doorRead = (value) => ({ value, enumerable: value !== undefined, writable: false, configurable: false });
443
- const deps = deploymentRoles !== undefined ? { ...input.deps, roles: deploymentRoles } : input.deps;
449
+ const deps = deploymentRoles !== undefined || hostInstance !== undefined ? keepDeploymentOf(input.deps, { ...input.deps, ...(deploymentRoles !== undefined ? { roles: deploymentRoles } : {}), ...(hostInstance !== undefined ? { host: hostInstance } : {}) }) : input.deps;
444
450
  const declaredDurableApproval = callerSpec.durableApproval;
445
451
  const hostApprovalParksNotResumable = declaredDurableApproval === false;
446
452
  let spec = Object.create(Object.getPrototypeOf(callerSpec), { ...Object.getOwnPropertyDescriptors(callerSpec), skills: doorRead(skills), projectMemory: doorRead(projectMemory), runOrigin: doorRead(runOrigin), durableApproval: doorRead(hostApprovalParksNotResumable ? undefined : declaredDurableApproval), ...(taskRoles !== undefined ? { roles: doorRead(taskRoles) } : {}) });
@@ -267,6 +267,7 @@ export function prepareContextLane(input) {
267
267
  turnSnapshotRef.current?.declare({ cause: "history_rewrite" });
268
268
  pointedBefore = pointedNow;
269
269
  await clearedResults.record(microCompact.ledger);
270
+ await microCompact.offloadPersist?.flush(signal);
270
271
  return { messages: trimmed, ...(chain.partial ? { trimmedRequestTokens: overheadTokens + sentRows } : {}) };
271
272
  }
272
273
  finally {
@@ -131,6 +131,9 @@ export interface PrepareDelegationSurfaceInput {
131
131
  * reads it through its one reader `currentCheckoutOf`). The worktree mount seeds `current` here and hands THIS object to
132
132
  * the tools — a copy would strand their writes from every write-root reader. */
133
133
  worktreeSeat: WorktreeSessionRef;
134
+ /** borrowed-readonly — the run's member ledger seats (`TaskSpec.runLedger`): the book and the session recorder the report tool
135
+ * delivers through; undefined on a run without a ledger (the report tool's row does not hold there). */
136
+ runLedger?: import("../../agents/send-user-message-tool.js").SendUserMessageSeats | undefined;
134
137
  }
135
138
  export interface PrepareDelegationSurfaceResult {
136
139
  /** owned — whether the delegation door is open (TaskStop / AgentTranscript ride it). */
@@ -1,5 +1,6 @@
1
1
  import { createAgentTranscriptTool } from "../../agents/agent-transcript-tool.js";
2
2
  import { createSendMessageTool, SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
3
+ import { createSendUserMessageTool } from "../../agents/send-user-message-tool.js";
3
4
  import { listAgentsMountable, mountListAgents, peerDrainLanesOf, peerLaneSendMessageSeats, principalInboxSeatRefusal } from "../../agents/peer-session-drain.js";
4
5
  import { resolvePeerLaneConfig } from "../../agents/peer-admission.js";
5
6
  import { createReadInboxTool, READ_INBOX_TOOL_NAME } from "../../agents/read-inbox-tool.js";
@@ -99,6 +100,11 @@ export function prepareDelegationSurface(input) {
99
100
  if (listAgents !== undefined)
100
101
  roster.mount(firstPartyOffload(listAgents), { source: "builtin", mountedBy: "peerLane" });
101
102
  }
103
+ if (roster.mounts.judge("send-user-message")) {
104
+ if (input.runLedger === undefined)
105
+ throw Object.assign(new Error("the report tool's row holds but this leg has no member ledger book"), { code: "internal.tool_mount_plan_mismatch" });
106
+ roster.mount(createSendUserMessageTool(input.runLedger), { source: "builtin", mountedBy: "optional" });
107
+ }
102
108
  if (roster.mounts.judge("monitor")) {
103
109
  roster.mount(firstPartyOffload(createMonitorTool(executionEnv, {
104
110
  registry: defaultTaskRegistry,
@@ -84,9 +84,9 @@ export type FactoryAsk = "ask" | "not_needed" | "not_answered";
84
84
  /**
85
85
  * Whether THIS acquisition asks the deployment's factory — the one judgment of it, read on a deployment that has a factory
86
86
  * (a Runner with none has nothing to ask; the env fold is its answer, whatever the purpose):
87
- * · `"not_answered"` — the purpose is `"read_changes"` and the deployment does not state that its factory answers it
88
- * (`RunnerDeps.executionEnvFactoryHonorsReadChanges` is not `true`): no hands — the no-I/O stub, never the static env (it is
89
- * not where the session's runs work), no cwd door, the factory not called;
87
+ * · `"not_answered"` — the purpose is `"read_changes"` (read-only out-of-run reads: `readSessionChanges`, `previewInstructions`) and the
88
+ * deployment does not state its factory answers it (`RunnerDeps.executionEnvFactoryHonorsReadChanges` is not `true`): no hands — the
89
+ * no-I/O stub, never the static env (it is not where the session's runs work), no cwd door, the factory not called;
90
90
  * · `"not_needed"` — the leg needs no environment (`startsEnv` false): the factory is not asked and the fold stands (a static
91
91
  * env, else the stub);
92
92
  * · `"ask"` — the factory is called.
@@ -182,6 +182,12 @@ export interface PrepareGateStationsInput {
182
182
  shellReadCheck: ShellReadCheck | undefined;
183
183
  /** borrowed-readonly — the leg's cross-boundary seat (`ToolGateInput.crossBoundaryCheck`), or undefined on a leg whose station is not engaged. */
184
184
  crossBoundaryCheck: import("../cross-boundary-taint.js").CrossBoundaryCheck | undefined;
185
+ /** borrowed-readonly — PRESENT ⇔ the Runner declares its shape (`RunnerDeps.deploymentShape`): the legs one call declares, off the
186
+ * leg's cross-boundary lane (`CrossBoundaryLane.legsOf`), and the deny rows one call may meet — the gate's `confined` seat reads them. */
187
+ confinedLeg?: {
188
+ readonly legsOf: (call: import("../cross-boundary-taint.js").CrossBoundaryCall) => readonly import("../cross-boundary-taint.js").BoundaryLeg[];
189
+ readonly denyRows: (toolCallId: string) => import("../shell-read-silence.js").ConfinedDenyRows;
190
+ };
185
191
  /** borrowed-readonly — the leg's resolved read face (`undefined` with no hands), read per call into the class derivation. */
186
192
  readFace: () => ContainmentFace | undefined;
187
193
  /** borrowed-readonly — the read-deny table the call is judged with (`ToolGateInput.readDenyInForce`): the active built-in
@@ -19,6 +19,7 @@ import { callParkRoute, extensionCallOf } from "../mods/extension-call.js";
19
19
  import { extensionCallOverlap } from "../mods/tool-call.js";
20
20
  import { leavesByEscape } from "../command-sandbox.js";
21
21
  import { perTaskEnvParkRefusal } from "../remote-env.js";
22
+ import { destinationOnHands } from "./cross-boundary-lane.js";
22
23
  const PEER_MESSAGE_NAMES = new Set([SEND_MESSAGE_TOOL_NAME]);
23
24
  function screenGateResult(result) {
24
25
  if (result.suspend !== undefined)
@@ -52,7 +53,7 @@ export function maybeHumanRejectionHalt(input) {
52
53
  };
53
54
  }
54
55
  export function prepareGateStations(input) {
55
- const { askLane, parkAsk, tools, refusedAsks, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, readDenyInForce, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, notResumable, permissionMode, toolMarkSources, a2aIsolatePeers, a2aInsidePeerOf, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls, workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
56
+ const { askLane, parkAsk, tools, refusedAsks, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, hookScreens, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, confinedLeg, readFace, readDenyInForce, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, notResumable, permissionMode, toolMarkSources, a2aIsolatePeers, a2aInsidePeerOf, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, durableQuestionFace, suspendTargetGap, continuationCalls, workflowParkGap, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
56
57
  const noticeAddress = legNotice.route.address;
57
58
  const admitsLegNotice = legNotice.admission;
58
59
  const tellAskUnresolvable = askUnresolvableTeller(noticeAddress);
@@ -135,6 +136,7 @@ export function prepareGateStations(input) {
135
136
  ...seatInputsFor(e.toolName, wireOf("gate.skillActivationSeat", call)),
136
137
  ...(mountedToolRequiresUserInteraction(tools, e.toolName) ? { requiresUserInteraction: true } : {}),
137
138
  ...(commandSandboxArmed ? { leavesCommandSandbox: (args) => leavesByEscape(sandboxPlanOf({ toolName: e.toolName, toolCallId: e.toolCallId, args })) } : {}),
139
+ ...(confinedLeg !== undefined ? { confined: { staysOnHands: (args) => destinationOnHands(!sandboxBoundaryCapable(call), confinedLeg.legsOf({ toolName: e.toolName, args, toolCallId: e.toolCallId })), bypassArmed: () => permissionMode.armsAs("bypassPermissions") === "bypassPermissions", denyRows: () => confinedLeg.denyRows(e.toolCallId) } } : {}),
138
140
  ...(a2aIsolatePeers === true ? { a2aIsolatePeers: true } : {}),
139
141
  ...((inside) => (inside !== undefined ? { a2aInsidePeer: inside } : {}))(a2aInsidePeerOf(e.toolName)),
140
142
  ancestorArbitrationOf: (toolCallId) => ancestorArbitrations.get(toolCallId),
@@ -17,7 +17,7 @@ import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
17
17
  import type { DeclaredRoot } from "./nested-memory-lane.js";
18
18
  import { type ArtifactStoreRef, type GrantReadRoot } from "./read-root-grant.js";
19
19
  import type { StoredSession } from "../session.js";
20
- import type { IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js";
20
+ import type { CarriedFaces, IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js";
21
21
  import type { ToolOccurrenceTable } from "./tool-occurrence.js";
22
22
  import { RosterBuilder } from "../tool-roster.js";
23
23
  import type { PermissionMode } from "../ask-origin.js";
@@ -117,7 +117,7 @@ export interface PrepareHandsReadFaceInput {
117
117
  /** borrowed-readonly — the task-spec seats this phase reads, as a Pick over the SAME spec object
118
118
  * (R-4). `tools` feeds only the band shadow check; `envFacts` only the advertised scratchpad; `planFile` only the
119
119
  * advertised session plan file; `retainBackgroundProcesses` only the band's retain lane (Bash's lifetime sentence + row stamp). */
120
- spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "blockReadsOutsideRoots" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">;
120
+ spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "ownHandsReadOnly" | "blockReadsOutsideRoots" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">;
121
121
  /** borrowed-readonly — the deployment seats this phase reads, as a Pick over the SAME deps
122
122
  * object (R-4: `deps.onError?.()` keeps its receiver; a new deps read must widen this Pick).
123
123
  * `readDenyBuiltinTiers`/`readDenyBuiltinExclude` are SNAPSHOTTED before the first await that
@@ -293,6 +293,9 @@ export interface PrepareHandsReadFaceResult {
293
293
  /** write-back — the hands-LESS legs' write face in force (the posture is a property of the RUN, not the mount): the
294
294
  * delegation carriers and the checkpoint mint read it on every leg. */
295
295
  handsLessResolvedWriteFace: WriteFaceSeat | undefined;
296
+ /** write-back — a leg that narrowed only its OWN hands (`TaskSpec.ownHandsReadOnly`): the two faces its children are handed,
297
+ * resolved without that narrowing ({@link carriedFacesOf}); absent on every other leg (its children are handed its own faces). */
298
+ carriedFaces: CarriedFaces | undefined;
296
299
  /** write-back (D-3 hold) — the NORMALIZED deny-set additions in force (deployment ∪ task ∪
297
300
  * resume-seed; zero-builtin compile — the persisted/carrier form, never the judged union's
298
301
  * post-dedup remainder). Driver assigns onto its outer `let`. */
@@ -22,7 +22,7 @@ import { redeemSessionReadRoot } from "../permission-rule-consent.js";
22
22
  import { legReadCarrier, readSeatLeaf, sessionLogWhole } from "./session-read-file-states.js";
23
23
  import { rebaseWorkspacePath } from "./workspace-path.js";
24
24
  import { RosterBuilder, survivorsByName } from "../tool-roster.js";
25
- import { unionAddOnly } from "../child-clamp-seats.js";
25
+ import { handsReadOnlyCarried, unionAddOnly } from "../child-clamp-seats.js";
26
26
  import { assertStringArraySeat, screenReadDenySeat } from "../read-face-seats.js";
27
27
  import { modePolicyOf } from "../mode-policy.js";
28
28
  import { valveLeaves } from "../../agents/tool-filter.js";
@@ -54,6 +54,15 @@ function writeFaceReader(input, onDeploymentClamp) {
54
54
  const faceUnder = (modeFace) => resolveContainmentFace({ ...seats, specFace: folded(spec.writeFace), depsFace: folded(deps.writeFace), ...(modeFace !== undefined ? { modeFace } : {}) });
55
55
  return { inForce: () => faceUnder(modePolicyOf(permissionMode.current).writeFace), fenced: faceUnder("open") === "roots" };
56
56
  }
57
+ function carriedFacesOf(input, readBlock) {
58
+ const { spec, deps, resume, fullShellReachable } = input;
59
+ if (spec.ownHandsReadOnly !== true)
60
+ return undefined;
61
+ const handed = { ...spec, handsReadOnly: handsReadOnlyCarried(spec) };
62
+ const live = resolveContainmentFace({ kind: "read", specFace: spec.readFace, depsFace: deps.readFace, readOnlyMount: handed.handsReadOnly === true, readBlock, orgGoverned: deps.permissionRuleStore?.partitions.org === true, fullShellReachable });
63
+ const seed = resume?.seed.readFace;
64
+ return { read: resume !== undefined && (seed === undefined || seed.face === "roots") ? "roots" : live, write: writeFaceReader({ ...input, spec: handed }) };
65
+ }
57
66
  const FLOOR_NEVER_UNKEPT = Object.freeze({ current: false, judged: false });
58
67
  export function resolveHandsLessReadFace(input) {
59
68
  const { resume, fullShellReachable, spec, deps } = input;
@@ -109,6 +118,7 @@ export function resolveHandsLessReadFace(input) {
109
118
  readFloorUnkept: FLOOR_NEVER_UNKEPT,
110
119
  handsLessResolvedFace,
111
120
  handsLessResolvedWriteFace,
121
+ carriedFaces: carriedFacesOf(input, readBlock),
112
122
  additionalRootsCanonical: [],
113
123
  commandWriteRootsCanonical: [],
114
124
  declaredAdditionalRoots: [],
@@ -242,9 +252,10 @@ export async function prepareHandsMount(input) {
242
252
  backgroundTaskToolsActive = roster.mounts.holds("monitor");
243
253
  const shellFaceHere = roster.mounts.holding((e) => isShellFaceToolName(e.name));
244
254
  const checkpointTracked = resume?.seed.handsCwd !== undefined;
245
- wsSnapshot = checkpointTracked || !(handsIncludeShell && !handsReadOnly) ? undefined : await session.getWorkspaceState().catch(() => undefined);
255
+ const tracksCwd = (handsIncludeShell && !handsReadOnly) || roster.mounts.holds("enter-worktree");
256
+ wsSnapshot = checkpointTracked || !tracksCwd ? undefined : await session.getWorkspaceState().catch(() => undefined);
246
257
  rebaseWsPath = (p) => (wsSnapshot === undefined || wsSnapshot.taskRoot === rootCanonical ? p : rebaseWorkspacePath(p, wsSnapshot.taskRoot, rootCanonical));
247
- if (handsIncludeShell && !handsReadOnly) {
258
+ if (tracksCwd) {
248
259
  handsCwdRef = { current: rootCanonical };
249
260
  if (resume?.seed.handsCwd !== undefined)
250
261
  handsCwdRef.current = rebaseRestoredPath(resume.seed.handsCwd);
@@ -535,6 +546,7 @@ export async function prepareHandsMount(input) {
535
546
  resolvedReadFace,
536
547
  resolvedWriteFace,
537
548
  handsLessResolvedWriteFace,
549
+ carriedFaces: carriedFacesOf(input, readBlock),
538
550
  readDenyAdditionsNormalized,
539
551
  readDenyBuiltinTiersActive,
540
552
  readFloorUnkept,
@@ -52,7 +52,7 @@ import type { PathRuleBases } from "../permission-rule-model.js";
52
52
  import type { PermissionMode, RunnerDeps, RuntimeCaps, ShellGateDoctrine, TaskEvent, TaskSpec, ToolExecuteContext, ToolSpec } from "../types.js";
53
53
  import { PermissionModeController } from "../mode-policy.js";
54
54
  import { type SkillGrantTable } from "../skill-grant.js";
55
- import type { InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
55
+ import type { CarriedFaces, InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
56
56
  import type { RosterSpec } from "./caller-roster.js";
57
57
  import type { DelegationSettlementSeat } from "../tool-spec.js";
58
58
  import type { ToolMountFacts } from "../tool-mount-facts.js";
@@ -62,7 +62,7 @@ export interface PrepareInheritedGateInput {
62
62
  * / `oneShot` / `clientContext` / `principal` / `additionalDirectories` / `additionalReadDirectories` / `envFacts` /
63
63
  * `memoryPersistenceCapable` / `getApiKeyAndHeaders` / `backgroundScope` / `enablePlanMode` (the ctx enrichment's
64
64
  * trusted seats). Never mutated. */
65
- spec: Pick<RosterSpec, "durableApproval"> & Pick<TaskSpec, "shellGate" | "onQuestion" | "handsReadOnly" | "interactiveTools" | "oneShot" | "clientContext" | "principal" | "isolationScope" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "getApiKeyAndHeaders" | "backgroundScope" | "enablePlanMode">;
65
+ spec: Pick<RosterSpec, "durableApproval"> & Pick<TaskSpec, "shellGate" | "onQuestion" | "handsReadOnly" | "ownHandsReadOnly" | "interactiveTools" | "oneShot" | "clientContext" | "principal" | "isolationScope" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "getApiKeyAndHeaders" | "backgroundScope" | "enablePlanMode">;
66
66
  /** borrowed-readonly — the seat this run hands its children (`checkpointSeatOf`, minted once by the driver after the config doors): the ctx's `checkpointStoreForChildren`, absent when the run has no seat. */
67
67
  checkpointSeat: import("../checkpoint-seat.js").CheckpointSeat | undefined;
68
68
  /** borrowed-readonly — the command sandbox requirement this run runs under (a resumed leg's: the parked one as a floor under the
@@ -96,7 +96,7 @@ export interface PrepareInheritedGateInput {
96
96
  /** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
97
97
  * (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
98
98
  * seats the ctx enrichment forwards. Never mutated. */
99
- internals: Pick<RunInternals, "inheritedGate" | "isDelegatedChild" | "observerLeg" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "rootSessionScope" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "onSubtreeActivity" | "insideFork" | "questionFaceStripped"> | undefined;
99
+ internals: Pick<RunInternals, "inheritedGate" | "isDelegatedChild" | "observerLeg" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "rootSessionScope" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "onSubtreeActivity" | "insideFork" | "questionFaceStripped" | "runLedgerBook"> | undefined;
100
100
  /** borrowed-readonly — the resume leg, or undefined on a fresh one: `seed.inheritedGate` is the CHECKPOINT half of the chain
101
101
  * fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
102
102
  resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
@@ -236,6 +236,9 @@ export interface PrepareInheritedGateInput {
236
236
  handsLessResolvedFace: () => ContainmentFace | undefined;
237
237
  /** borrowed-readonly — LATE-BOUND: the hands-less legs' resolved WRITE face (same second source, write seat). */
238
238
  handsLessResolvedWriteFace: () => WriteFaceSeat | undefined;
239
+ /** borrowed-readonly — LATE-BOUND: a leg that narrowed only its own hands (`TaskSpec.ownHandsReadOnly`): the faces its children
240
+ * are handed, resolved without that narrowing; undefined on every other leg (its children take its own faces). */
241
+ carriedFaces: () => CarriedFaces | undefined;
239
242
  /** borrowed-readonly — LATE-BOUND: the leg's resolved `blockReadsOutsideRoots` (the hands phase's one answer, on either
240
243
  * branch: the declaration, or the resumed row's record of it) — what the children's clamp takes, never the spec's word. */
241
244
  readBlock: () => boolean;
@@ -5,7 +5,7 @@ import { parentSpecSeatOf } from "../parent-spec-seat.js";
5
5
  import { legIdentityOf } from "../isolation-scope.js";
6
6
  import { rootAnchorOf } from "../leg-identity.js";
7
7
  import { chainJudges, sameInstallation } from "../mods/stations.js";
8
- import { childClampSeats, clampSourceOf } from "../child-clamp-seats.js";
8
+ import { childClampSeats, clampSourceOf, handsReadOnlyCarried } from "../child-clamp-seats.js";
9
9
  import { inheritedRuleKeyOf } from "../session-policy-store.js";
10
10
  import { rowFollowsFloor } from "./session-rule-policy.js";
11
11
  import { declaresSubagentPlacement } from "../session.js";
@@ -16,7 +16,7 @@ import { chainAnchorRecords } from "./child-tree.js";
16
16
  import { defaultTaskRegistry } from "../task-registry.js";
17
17
  import { joinRuleBuckets, persistedRuleBucketsOf, readRuleBuckets } from "../persisted-rule-buckets.js";
18
18
  import { deliverEngineNotice } from "../types.js";
19
- import { PermissionModeController, autoModeFaceOf, modeRequestAfterResume } from "../mode-policy.js";
19
+ import { PermissionModeController, autoModeFaceOf, modeRequestAfterResume, withheldApprovalMode } from "../mode-policy.js";
20
20
  import { SessionModeSeats } from "./session-mode-seats.js";
21
21
  import { recordedModeSeed } from "../checkpoint-row-verdict.js";
22
22
  import { frozenSkillGrants } from "../skill-grant.js";
@@ -73,8 +73,14 @@ export function prepareInheritedGate(input) {
73
73
  deliverEngineNotice(deps.onNotice, { code: "config.permission_mode_unavailable", message: `${message} (a child leg, ${sessionId})`, detail: { requested: folded, effective: receipt.effective, by: receipt.foldedBy, sessionId: parentSeat.sessionId, childSessionId: sessionId, runId } });
74
74
  }
75
75
  };
76
- const permissionMode = new PermissionModeController(modeRequestAfterResume(permissionModeSeat, modeSeed, resume?.outcome), ceiling, { onFold: announceModeFold, ...(modeSeed.prePlanMode !== undefined ? { prePlanMode: modeSeed.prePlanMode } : {}), ...(wiringLegKindOf(resume !== undefined, internals) === "root" && deps.permissionModeWhenUnset !== undefined ? { whenUnset: deps.permissionModeWhenUnset } : {}) });
76
+ const parentModeUnknown = input.delegated && ceiling === undefined ? true : undefined;
77
+ const withheldMode = withheldApprovalMode(permissionModeSeat, modeSeed, resume?.outcome, parentModeUnknown);
78
+ const permissionMode = new PermissionModeController(modeRequestAfterResume(permissionModeSeat, modeSeed, resume?.outcome, parentModeUnknown), ceiling, { onFold: announceModeFold, ...(modeSeed.prePlanMode !== undefined ? { prePlanMode: modeSeed.prePlanMode } : {}), ...(wiringLegKindOf(resume !== undefined, internals) === "root" && deps.permissionModeWhenUnset !== undefined ? { whenUnset: deps.permissionModeWhenUnset } : {}) });
77
79
  permissionMode.announceStart();
80
+ if (withheldMode !== undefined) {
81
+ const message = `permission mode "${withheldMode}" the approval named is not taken on this leg (its parent's mode was not handed to this resume, so the ceiling a widening is held to is unknown) — it runs under "${permissionMode.current}"`;
82
+ deliverEngineNotice(deps.onNotice, { code: "config.permission_mode_unavailable", message, detail: { requested: withheldMode, effective: permissionMode.current, by: "inherited_ceiling", sessionId, runId } });
83
+ }
78
84
  const { ceiling: legModeCeiling, commit: commitLegModeCeiling, end: endModeCeiling } = (internals?.sessionModeSeats ?? new SessionModeSeats()).legCeiling(sessionId, permissionMode);
79
85
  const commitModeSeats = (legSignal) => {
80
86
  commitLegModeCeiling();
@@ -189,8 +195,9 @@ export function prepareInheritedGate(input) {
189
195
  const carrierWriteFace = () => (input.resolvedWriteFace() ?? input.handsLessResolvedWriteFace())?.inForce();
190
196
  const runClampSource = () => ({
191
197
  ...clampSourceOf(spec, "clamp"),
192
- readFace: carrierReadFace(),
193
- writeFace: carrierWriteFace(),
198
+ handsReadOnly: handsReadOnlyCarried(spec),
199
+ readFace: input.carriedFaces()?.read ?? carrierReadFace(),
200
+ writeFace: input.carriedFaces()?.write.inForce() ?? carrierWriteFace(),
194
201
  blockReadsOutsideRoots: input.readBlock() ? true : undefined,
195
202
  readDenyPatterns: input.readDenyAdditionsNormalized(),
196
203
  agentConfigDirs: input.callerPlaces.configRoots.carried, agentHomeDirs: input.callerPlaces.homes.carried,
@@ -226,6 +233,7 @@ export function prepareInheritedGate(input) {
226
233
  ...(leg.isolationScope !== undefined ? { isolationScope: leg.isolationScope } : {}),
227
234
  ...(frozenOnAsk !== undefined ? { onAsk: frozenOnAsk } : {}),
228
235
  ...childClampSeats(runClampSource()),
236
+ ...(internals?.runLedgerBook !== undefined ? { runLedgerBook: internals.runLedgerBook } : {}),
229
237
  ...(frozenOnQuestion !== undefined ? { onQuestion: frozenOnQuestion } : {}),
230
238
  oneShot: spec.oneShot,
231
239
  mountsCallerTool,
@@ -41,7 +41,7 @@ export function prepareOffloadWrappers(input) {
41
41
  const maybeOffload = (tool, perTool) => {
42
42
  if (!offloadStore || perTool?.offload === false)
43
43
  return tool;
44
- return withToolResultOffload(tool, offloadStore, perTool?.offloadThresholdChars ?? offloadThreshold, sessionId, () => offloadReachableToolsRef.current?.());
44
+ return withToolResultOffload(tool, offloadStore, perTool?.offloadThresholdChars ?? offloadThreshold, sessionId, () => offloadReachableToolsRef.current?.(), deps.onNotice);
45
45
  };
46
46
  const firstPartyOffload = (tool) => {
47
47
  const face = faceOf(tool);
@@ -32,7 +32,7 @@ export interface PrepareRunRefsInput {
32
32
  /** borrowed-readonly — the REBOUND spec. Read: `forwardSubagentEvents` (widens the forwarding filter),
33
33
  * `retainSubagentSessions` (the ledger opt-in and its config), `handsReadOnly` (a read-only run mints no
34
34
  * worktree helper). Never mutated. */
35
- spec: Pick<TaskSpec, "forwardSubagentEvents" | "retainSubagentSessions" | "handsReadOnly">;
35
+ spec: Pick<TaskSpec, "forwardSubagentEvents" | "retainSubagentSessions" | "handsReadOnly" | "ownHandsReadOnly">;
36
36
  /** borrowed-readonly — the trusted spawn-side channel; only `onForwardEvent` (the deployment's display
37
37
  * sink) is read, to decide whether a forwarding wrapper exists at all, and `forwardScope` (the run's
38
38
  * forwarding containment, read by the door). The OBJECT is what the wrapper hands the door rather than