@sema-agent/core 7.52.0 → 7.54.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 (357) hide show
  1. package/CHANGELOG.md +470 -0
  2. package/LICENSE +3 -1
  3. package/README.md +3 -1
  4. package/dist/agents/cross-session-envelope.d.ts +8 -0
  5. package/dist/agents/cross-session-envelope.js +6 -0
  6. package/dist/agents/cross-session-judge.d.ts +21 -1
  7. package/dist/agents/cross-session-judge.js +8 -0
  8. package/dist/agents/cross-session-ref.d.ts +5 -0
  9. package/dist/agents/cross-session-ref.js +1 -0
  10. package/dist/agents/org-delivery-gate.d.ts +122 -0
  11. package/dist/agents/org-delivery-gate.js +69 -0
  12. package/dist/agents/peer-held-queue.d.ts +9 -4
  13. package/dist/agents/peer-held-queue.js +6 -5
  14. package/dist/agents/peer-session-drain.d.ts +35 -6
  15. package/dist/agents/peer-session-drain.js +271 -182
  16. package/dist/agents/read-inbox-tool.d.ts +7 -0
  17. package/dist/agents/read-inbox-tool.js +5 -1
  18. package/dist/agents/send-message-tool.js +3 -4
  19. package/dist/agents/subagent.d.ts +6 -5
  20. package/dist/agents/subagent.js +117 -83
  21. package/dist/agents/tool-filter.d.ts +25 -4
  22. package/dist/agents/tool-filter.js +13 -3
  23. package/dist/brain/anthropic.d.ts +6 -1
  24. package/dist/brain/anthropic.js +4 -4
  25. package/dist/brain/model-presets.js +2 -1
  26. package/dist/brain/route-adjudicator.d.ts +6 -0
  27. package/dist/brain/routing.d.ts +24 -1
  28. package/dist/brain/routing.js +54 -19
  29. package/dist/brain/timeout.js +5 -4
  30. package/dist/core/a2a.d.ts +5 -2
  31. package/dist/core/a2a.js +33 -14
  32. package/dist/core/allow-entry.d.ts +3 -1
  33. package/dist/core/allow-entry.js +3 -2
  34. package/dist/core/approval-object.d.ts +87 -0
  35. package/dist/core/approval-object.js +85 -0
  36. package/dist/core/arg-summary.d.ts +3 -2
  37. package/dist/core/arg-summary.js +17 -11
  38. package/dist/core/ask-origin.d.ts +43 -27
  39. package/dist/core/ask-origin.js +20 -11
  40. package/dist/core/ask-question.d.ts +0 -1
  41. package/dist/core/ask-question.js +4 -67
  42. package/dist/core/ask-unresolvable-notice.d.ts +3 -2
  43. package/dist/core/auto-compaction.d.ts +106 -50
  44. package/dist/core/auto-compaction.js +69 -53
  45. package/dist/core/auto-mode-prompt.d.ts +4 -2
  46. package/dist/core/auto-mode-prompt.js +4 -3
  47. package/dist/core/canonical-json.d.ts +69 -0
  48. package/dist/core/canonical-json.js +130 -8
  49. package/dist/core/checkpoint-requirements.d.ts +13 -7
  50. package/dist/core/checkpoint-requirements.js +4 -1
  51. package/dist/core/checkpoint-store.d.ts +60 -36
  52. package/dist/core/checkpoint-store.js +7 -6
  53. package/dist/core/child-clamp-seats.d.ts +45 -6
  54. package/dist/core/child-clamp-seats.js +56 -4
  55. package/dist/core/compliance.js +3 -1
  56. package/dist/core/consolidate-scope.d.ts +1 -1
  57. package/dist/core/cross-boundary-taint.d.ts +213 -0
  58. package/dist/core/cross-boundary-taint.js +196 -0
  59. package/dist/core/decision-receipt.d.ts +44 -1
  60. package/dist/core/decision-receipt.js +16 -0
  61. package/dist/core/effective-path-target.d.ts +28 -6
  62. package/dist/core/effective-path-target.js +28 -2
  63. package/dist/core/engine-notice.d.ts +47 -4
  64. package/dist/core/engine-notice.js +17 -1
  65. package/dist/core/engine-storage-backend.d.ts +73 -0
  66. package/dist/core/engine-storage-backend.js +1 -0
  67. package/dist/core/file-history-store.d.ts +6 -2
  68. package/dist/core/file-history-store.js +1 -0
  69. package/dist/core/gate-fold.js +13 -4
  70. package/dist/core/gate-lanes.js +41 -34
  71. package/dist/core/gate-outcome.d.ts +18 -9
  72. package/dist/core/governance-codes.d.ts +9 -2
  73. package/dist/core/governance-codes.js +9 -0
  74. package/dist/core/hands-band-screen.d.ts +7 -0
  75. package/dist/core/hands-band-screen.js +32 -0
  76. package/dist/core/hooks.d.ts +21 -19
  77. package/dist/core/hooks.js +6 -5
  78. package/dist/core/locked-config.d.ts +110 -31
  79. package/dist/core/locked-config.js +155 -42
  80. package/dist/core/lsp.d.ts +1 -1
  81. package/dist/core/mcp-probe.js +1 -1
  82. package/dist/core/mcp-server-spec.d.ts +152 -17
  83. package/dist/core/mcp-server-spec.js +223 -40
  84. package/dist/core/mcp.d.ts +21 -14
  85. package/dist/core/mcp.js +59 -54
  86. package/dist/core/memory-engine/engine.d.ts +14 -19
  87. package/dist/core/memory-engine/engine.js +9 -6
  88. package/dist/core/memory-engine/export-bundle.d.ts +1 -1
  89. package/dist/core/memory-engine/export-bundle.js +1 -1
  90. package/dist/core/memory-engine/file-backend.d.ts +2 -6
  91. package/dist/core/memory-engine/file-backend.js +1 -12
  92. package/dist/core/memory.d.ts +3 -3
  93. package/dist/core/mode-policy.d.ts +16 -26
  94. package/dist/core/mode-policy.js +5 -18
  95. package/dist/core/mods/kernel/dispatch.js +13 -15
  96. package/dist/core/mods/kernel/events.d.ts +9 -6
  97. package/dist/core/mods/kernel/events.js +2 -2
  98. package/dist/core/mods/kernel/receive.d.ts +41 -11
  99. package/dist/core/mods/kernel/receive.js +124 -54
  100. package/dist/core/mods/kernel/site-rules.d.ts +80 -15
  101. package/dist/core/mods/kernel/site-rules.js +232 -40
  102. package/dist/core/mods/stations.d.ts +0 -6
  103. package/dist/core/mods/stations.js +0 -7
  104. package/dist/core/mounted-mcp.d.ts +57 -0
  105. package/dist/core/mounted-mcp.js +71 -2
  106. package/dist/core/own-property-receipt.d.ts +13 -0
  107. package/dist/core/own-property-receipt.js +3 -1
  108. package/dist/core/parent-spec-seat.d.ts +12 -15
  109. package/dist/core/parent-spec-seat.js +14 -6
  110. package/dist/core/pause-registry.d.ts +35 -1
  111. package/dist/core/pause-registry.js +10 -0
  112. package/dist/core/permission-rule-consent.d.ts +18 -5
  113. package/dist/core/permission-rule-consent.js +13 -8
  114. package/dist/core/permission-rule-model.d.ts +87 -15
  115. package/dist/core/permission-rule-model.js +87 -8
  116. package/dist/core/permission-rule-org.d.ts +200 -33
  117. package/dist/core/permission-rule-org.js +217 -91
  118. package/dist/core/permission-rule-session.js +2 -2
  119. package/dist/core/permission-rule-store.d.ts +8 -0
  120. package/dist/core/permission-rule-store.js +1 -0
  121. package/dist/core/permission-rule-sync.js +3 -2
  122. package/dist/core/permission-rules.d.ts +7 -1
  123. package/dist/core/permission-rules.js +37 -8
  124. package/dist/core/read-only-shell.d.ts +1 -1
  125. package/dist/core/read-only-shell.js +30 -9
  126. package/dist/core/remote-env.d.ts +41 -1
  127. package/dist/core/remote-env.js +18 -0
  128. package/dist/core/resume-startup-cause.d.ts +18 -0
  129. package/dist/core/resume-startup-cause.js +12 -0
  130. package/dist/core/retention.js +7 -2
  131. package/dist/core/retired-keys.d.ts +8 -2
  132. package/dist/core/retired-keys.js +12 -1
  133. package/dist/core/roles.js +60 -10
  134. package/dist/core/rule-lane-reads.js +1 -1
  135. package/dist/core/runner/approval-feedback.d.ts +46 -0
  136. package/dist/core/runner/approval-feedback.js +41 -0
  137. package/dist/core/runner/compaction-call-options.d.ts +3 -3
  138. package/dist/core/runner/compaction-call-options.js +2 -2
  139. package/dist/core/runner/contracts.d.ts +34 -41
  140. package/dist/core/runner/cross-boundary-lane.d.ts +87 -0
  141. package/dist/core/runner/cross-boundary-lane.js +190 -0
  142. package/dist/core/runner/decide-continuation.d.ts +4 -4
  143. package/dist/core/runner/decide-continuation.js +3 -1
  144. package/dist/core/runner/gate-exit.d.ts +32 -12
  145. package/dist/core/runner/gate-exit.js +77 -34
  146. package/dist/core/runner/inherited-ask-grants.js +2 -2
  147. package/dist/core/runner/mcp-redial.d.ts +52 -10
  148. package/dist/core/runner/mcp-redial.js +38 -9
  149. package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
  150. package/dist/core/runner/permission-rule-lanes.js +22 -10
  151. package/dist/core/runner/person-path-rows.d.ts +5 -3
  152. package/dist/core/runner/person-path-rows.js +2 -2
  153. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -4
  154. package/dist/core/runner/prepare-acquire-reconcile.js +3 -3
  155. package/dist/core/runner/prepare-ask-lane.js +3 -3
  156. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -5
  157. package/dist/core/runner/prepare-caps-and-workflow.js +3 -3
  158. package/dist/core/runner/prepare-config-doors.d.ts +58 -15
  159. package/dist/core/runner/prepare-config-doors.js +167 -146
  160. package/dist/core/runner/prepare-context-lane.js +6 -3
  161. package/dist/core/runner/prepare-defer-classify.js +4 -7
  162. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -4
  163. package/dist/core/runner/prepare-delegation-surface.js +8 -7
  164. package/dist/core/runner/prepare-execution-env.d.ts +1 -2
  165. package/dist/core/runner/prepare-execution-env.js +2 -1
  166. package/dist/core/runner/prepare-gate-stations.d.ts +2 -0
  167. package/dist/core/runner/prepare-gate-stations.js +4 -3
  168. package/dist/core/runner/prepare-hands-readface.d.ts +3 -3
  169. package/dist/core/runner/prepare-hands-readface.js +3 -2
  170. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -0
  171. package/dist/core/runner/prepare-inherited-gate.js +3 -2
  172. package/dist/core/runner/prepare-listings.d.ts +1 -1
  173. package/dist/core/runner/prepare-listings.js +4 -2
  174. package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
  175. package/dist/core/runner/prepare-memory-engine-session.js +19 -6
  176. package/dist/core/runner/prepare-memory.d.ts +3 -2
  177. package/dist/core/runner/prepare-memory.js +6 -2
  178. package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
  179. package/dist/core/runner/prepare-offload-wrappers.js +2 -1
  180. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  181. package/dist/core/runner/prepare-park-ask.js +9 -3
  182. package/dist/core/runner/prepare-policy-chain.d.ts +1 -1
  183. package/dist/core/runner/prepare-policy-chain.js +14 -19
  184. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  185. package/dist/core/runner/prepare-project-context.js +6 -4
  186. package/dist/core/runner/prepare-prompt-assembly.d.ts +1 -1
  187. package/dist/core/runner/prepare-prompt-assembly.js +20 -16
  188. package/dist/core/runner/prepare-prompt-inputs.d.ts +12 -6
  189. package/dist/core/runner/prepare-prompt-inputs.js +6 -3
  190. package/dist/core/runner/prepare-protocol-tools.d.ts +7 -5
  191. package/dist/core/runner/prepare-protocol-tools.js +19 -12
  192. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  193. package/dist/core/runner/prepare-question-face.js +4 -3
  194. package/dist/core/runner/prepare-safety-scan.d.ts +7 -2
  195. package/dist/core/runner/prepare-safety-scan.js +34 -27
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +6 -2
  198. package/dist/core/runner/prepare-task.js +22 -19
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +10 -5
  200. package/dist/core/runner/prepare-turn-wiring.js +14 -49
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +10 -5
  202. package/dist/core/runner/prepare-wiring-manifest.js +9 -6
  203. package/dist/core/runner/prepare-workspace-restore.js +2 -2
  204. package/dist/core/runner/resume-admission.d.ts +4 -1
  205. package/dist/core/runner/resume-admission.js +16 -14
  206. package/dist/core/runner/resume-apply.js +4 -4
  207. package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
  208. package/dist/core/runner/resume-internals-and-config.js +3 -8
  209. package/dist/core/runner/resume-policy-outcome.d.ts +2 -2
  210. package/dist/core/runner/resume-policy-outcome.js +18 -15
  211. package/dist/core/runner/resume-preflight.js +2 -2
  212. package/dist/core/runner/resume-review-outcome.js +3 -3
  213. package/dist/core/runner/retired-runner-deps.d.ts +5 -6
  214. package/dist/core/runner/retired-runner-deps.js +1 -4
  215. package/dist/core/runner/run-leg.js +97 -43
  216. package/dist/core/runner/run-recovery-lanes.js +5 -3
  217. package/dist/core/runner/run-settle-and-teardown.js +2 -0
  218. package/dist/core/runner/run-terminal-adoption.js +21 -9
  219. package/dist/core/runner/run-turn-boundary.js +9 -3
  220. package/dist/core/runner/runtask.js +1 -1
  221. package/dist/core/runner/session-file-state-replay.d.ts +5 -2
  222. package/dist/core/runner/session-file-state-replay.js +3 -2
  223. package/dist/core/runner/skills-seat.d.ts +15 -0
  224. package/dist/core/runner/skills-seat.js +57 -0
  225. package/dist/core/runner/stream-steer-verb.js +2 -2
  226. package/dist/core/runner/sub-agent-deny-lists.d.ts +13 -11
  227. package/dist/core/runner/sub-agent-deny-lists.js +7 -5
  228. package/dist/core/runner/synthetic-tools.d.ts +5 -2
  229. package/dist/core/runner/synthetic-tools.js +2 -12
  230. package/dist/core/runner/tool-face-overlay.d.ts +24 -6
  231. package/dist/core/runner/tool-face-overlay.js +24 -15
  232. package/dist/core/runner-deps.d.ts +37 -22
  233. package/dist/core/session-policy-store.d.ts +19 -0
  234. package/dist/core/session-policy-store.js +22 -2
  235. package/dist/core/session-store.d.ts +35 -16
  236. package/dist/core/session-store.js +20 -12
  237. package/dist/core/{shell-lexer.d.ts → shell-run-candidates.d.ts} +36 -12
  238. package/dist/core/{shell-lexer.js → shell-run-candidates.js} +145 -225
  239. package/dist/core/shell-wrapper-table.d.ts +5 -3
  240. package/dist/core/shell-wrapper-table.js +1 -1
  241. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -2
  242. package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
  243. package/dist/core/store-contracts/session-store-contract.d.ts +49 -0
  244. package/dist/core/store-contracts/session-store-contract.js +639 -0
  245. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +12 -0
  246. package/dist/core/store-contracts/session-store-incarnation-contract.js +5 -2
  247. package/dist/core/task-event.d.ts +44 -6
  248. package/dist/core/task-notification.js +2 -2
  249. package/dist/core/task-registry-agent.js +1 -0
  250. package/dist/core/task-registry-shared.d.ts +5 -0
  251. package/dist/core/task-registry.d.ts +7 -0
  252. package/dist/core/task-registry.js +17 -0
  253. package/dist/core/task-result.d.ts +1 -1
  254. package/dist/core/task-spec.d.ts +7 -7
  255. package/dist/core/tighten-task-spec.d.ts +6 -4
  256. package/dist/core/tighten-task-spec.js +2 -2
  257. package/dist/core/tool-catalog-entries.d.ts +1 -1
  258. package/dist/core/tool-catalog-entries.js +52 -52
  259. package/dist/core/tool-face-reader.d.ts +49 -0
  260. package/dist/core/tool-face-reader.js +94 -0
  261. package/dist/core/tool-face.d.ts +17 -8
  262. package/dist/core/tool-face.js +1 -0
  263. package/dist/core/tool-policy.d.ts +67 -23
  264. package/dist/core/tool-policy.js +72 -60
  265. package/dist/core/tool-roster.d.ts +46 -28
  266. package/dist/core/tool-roster.js +91 -14
  267. package/dist/core/tool-spec-members.js +2 -2
  268. package/dist/core/tool-spec.d.ts +20 -4
  269. package/dist/core/tools.js +2 -0
  270. package/dist/core/trace.d.ts +24 -2
  271. package/dist/core/types.d.ts +3 -3
  272. package/dist/core/types.js +1 -1
  273. package/dist/core/untrusted-text.d.ts +23 -0
  274. package/dist/core/untrusted-text.js +10 -10
  275. package/dist/core/user-attachment.d.ts +56 -2
  276. package/dist/core/user-attachment.js +139 -56
  277. package/dist/core/wiring-manifest.d.ts +4 -2
  278. package/dist/engine/compaction/compaction.d.ts +2 -2
  279. package/dist/engine/compaction/utils.d.ts +2 -2
  280. package/dist/engine/harness/agent-harness.js +2 -1
  281. package/dist/engine/harness/types.d.ts +10 -4
  282. package/dist/engine/llm/types.d.ts +7 -2
  283. package/dist/engine/llm/types.js +2 -1
  284. package/dist/engine/loop/agent-loop.d.ts +12 -1
  285. package/dist/engine/loop/agent-loop.js +17 -5
  286. package/dist/engine/loop/types.d.ts +7 -1
  287. package/dist/engine/session/repo-utils.d.ts +5 -0
  288. package/dist/engine/session/repo-utils.js +9 -0
  289. package/dist/engine/session/storage-base.js +2 -2
  290. package/dist/index.d.ts +37 -17
  291. package/dist/index.js +31 -14
  292. package/dist/internal/harness.d.ts +1 -0
  293. package/dist/internal/harness.js +1 -0
  294. package/dist/internal/llm.d.ts +1 -1
  295. package/dist/internal/llm.js +1 -1
  296. package/dist/orchestration/goal.d.ts +24 -1
  297. package/dist/orchestration/goal.js +3 -2
  298. package/dist/orchestration/run-workflow-tool.d.ts +3 -0
  299. package/dist/orchestration/run-workflow-tool.js +1 -0
  300. package/dist/orchestration/workflow-governance.d.ts +1 -1
  301. package/dist/orchestration/workflow.d.ts +3 -0
  302. package/dist/orchestration/workflow.js +2 -1
  303. package/dist/prompt-assembly/artifact-store.d.ts +44 -9
  304. package/dist/prompt-assembly/artifact-store.js +38 -12
  305. package/dist/prompt-assembly/artifact.d.ts +12 -11
  306. package/dist/prompt-assembly/artifact.js +52 -21
  307. package/dist/prompt-assembly/assemble.d.ts +2 -0
  308. package/dist/prompt-assembly/assemble.js +2 -1
  309. package/dist/prompt-assembly/catalog/index.js +2 -1
  310. package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
  311. package/dist/prompt-assembly/catalog/memory.js +6 -0
  312. package/dist/prompt-assembly/catalog/schema.d.ts +19 -2
  313. package/dist/prompt-assembly/catalog/schema.js +3 -0
  314. package/dist/prompt-assembly/composer.d.ts +2 -0
  315. package/dist/prompt-assembly/composer.js +1 -1
  316. package/dist/prompt-assembly/overlay.d.ts +21 -11
  317. package/dist/prompt-assembly/overlay.js +57 -19
  318. package/dist/prompt-assembly/select.d.ts +21 -6
  319. package/dist/prompt-assembly/select.js +41 -4
  320. package/dist/prompts/default.d.ts +1 -12
  321. package/dist/prompts/default.js +0 -3
  322. package/dist/shell/lex.d.ts +87 -8
  323. package/dist/shell/lex.js +283 -49
  324. package/dist/stores/file/index.d.ts +8 -6
  325. package/dist/stores/file/permission-rule-store.d.ts +1 -1
  326. package/dist/stores/file/permission-rule-store.js +2 -1
  327. package/dist/tools/artifact/artifact-tool.js +14 -3
  328. package/dist/tools/fs/bash-program-position.d.ts +3 -15
  329. package/dist/tools/fs/bash-program-position.js +3 -10
  330. package/dist/tools/fs/bash-readonly-classifier.js +2 -0
  331. package/dist/tools/fs/fs-bash.d.ts +3 -3
  332. package/dist/tools/fs/fs-bash.js +72 -101
  333. package/dist/tools/fs/fs-read.d.ts +12 -0
  334. package/dist/tools/fs/fs-read.js +10 -9
  335. package/dist/tools/fs/fs-shared.d.ts +27 -31
  336. package/dist/tools/fs/fs-shared.js +12 -15
  337. package/dist/tools/fs/fs-write.js +1 -1
  338. package/dist/tools/fs/index.js +2 -2
  339. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  340. package/dist/tools/fs/read-deny-home.js +5 -4
  341. package/dist/tools/fs/read-deny.d.ts +16 -3
  342. package/dist/tools/fs/read-deny.js +12 -9
  343. package/dist/tools/fs/safety.d.ts +7 -6
  344. package/dist/tools/fs/shell-read-bindings.d.ts +5 -3
  345. package/dist/tools/fs/shell-read-bindings.js +15 -16
  346. package/dist/tools/fs/shell-read-device.js +1 -1
  347. package/dist/tools/fs/shell-read-plan.js +36 -47
  348. package/dist/tools/fs/shell-read-word.d.ts +1 -6
  349. package/dist/tools/fs/shell-read-word.js +2 -20
  350. package/dist/tools/fs/shell-reentry-text.js +1 -1
  351. package/dist/tools/web.d.ts +2 -2
  352. package/package.json +4 -1
  353. package/test/export-surface.snapshot.json +5651 -5457
  354. package/wire-changes/core@7.53.0.json +1968 -0
  355. package/wire-changes/core@7.54.0.json +2870 -0
  356. package/dist/core/shell-scan.d.ts +0 -60
  357. package/dist/core/shell-scan.js +0 -183
@@ -36,7 +36,7 @@ import type { AssertAllKeysHandled } from "../ask-origin.js";
36
36
  import { type ChildClampSource } from "../child-clamp-seats.js";
37
37
  import type { InheritedGate, Prepared, RunInternals, RunnerSelfSeat, ToolFaceSnapshot } from "./contracts.js";
38
38
  import { type BlockedRef } from "./synthetic-tools.js";
39
- import { RosterBuilder } from "../tool-roster.js";
39
+ import { RosterBuilder, type RosterAxisTables } from "../tool-roster.js";
40
40
  import type { ParentSpecSeat } from "../parent-spec-seat.js";
41
41
  import { type RosterSpec } from "./caller-roster.js";
42
42
  export interface PrepareCapsAndWorkflowInput {
@@ -48,8 +48,7 @@ export interface PrepareCapsAndWorkflowInput {
48
48
  /** borrowed-readonly — the deployment seats, whole: `runtimeCapsResolver`, `compliancePostureResolver`, `onError`, `onNotice`,
49
49
  * `autoMode`, `brain`, `models`, and the Workflow mount's dozen deps (`workflowScriptRunner`,
50
50
  * `workflowGovernanceBaseline`, `workflowRunStore`, `workflowJournalStore`, `workflowScriptStore`,
51
- * `onWorkflowAgentSpawn`, `workflowCompletionNotifier`, `workflowLimits`, `agents`, `builtinAgents`, `onBackgroundChildEvent`).
52
- * The self-orchestration predicate takes the whole record. */
51
+ * `onWorkflowAgentSpawn`, `workflowCompletionNotifier`, `workflowLimits`, `agents`, `builtinAgents`, `onBackgroundChildEvent`). The self-orchestration predicate takes the whole record. */
53
52
  deps: RunnerDeps;
54
53
  /** borrowed-readonly — the seat this run hands its children (`checkpointSeatOf`, minted once by the driver right after the
55
54
  * config doors): the plan-pair face reads the store it names, the Workflow mount hands the seat itself to its children. */
@@ -58,6 +57,7 @@ export interface PrepareCapsAndWorkflowInput {
58
57
  * `onTaskNotification`, `workflowDepth`, the capture-floor getter reads `memoryCaptureAncestors`, and the arming reads
59
58
  * the chain's auto-mode face (`inheritedGate.autoModeFace`). */
60
59
  internals: Pick<RunInternals, "rootSessionId" | "placementRoot" | "onTaskNotification" | "workflowDepth" | "memoryCaptureAncestors" | "workflowParkedResume" | "questionFaceStripped" | "inheritedGate"> | undefined;
60
+ /** borrowed-readonly — the tree's cross-boundary token (inherited or minted), which the Workflow mount hands to its children. */ crossBoundaryTree: import("../cross-boundary-taint.js").CrossBoundaryTreeToken;
61
61
  /** borrowed-readonly — the acquired session; the classifier leg rebuilds its transcript window from `buildContext`. */
62
62
  session: Pick<StoredSession, "buildContext">;
63
63
  /** borrowed-readonly — the acquired session id (operator-line context, the refusal codes' phase record). */
@@ -76,9 +76,10 @@ export interface PrepareCapsAndWorkflowInput {
76
76
  thinking: ThinkingLevel | undefined;
77
77
  /** borrowed-readonly — the frozen preflight; only `mcp` (the compliance veto's mcp_servers conflict check). */
78
78
  lockedPreflight: Pick<LockedPreflight, "mcp">;
79
- /** borrowed-mutable — the effect collection (`Prepared.toolEffects`). Writer here: ONE set, `Workflow → write`, at its mount.
80
- * Every other writer is the safety scan (the seed) and the later mounts (see the roster table on `Prepared.tools`). */
79
+ /** borrowed-mutable — the effect collection (`Prepared.toolEffects`): the safety scan's caller entries, then the mounts' writes. */
81
80
  toolEffects: Prepared["toolEffects"];
81
+ /** borrowed-mutable — the scan's axis tables, so the builder moves an alias's axes with its member (a phase test may omit them). */
82
+ safetyAxes?: RosterAxisTables;
82
83
  /** borrowed-readonly — the frozen tool-face snapshot the Workflow mount forwards (exclude / defer / alwaysLoad / restoreGated). */
83
84
  toolFaceSnapshot: ToolFaceSnapshot;
84
85
  /** borrowed-readonly — the resolved prompt profile (the Workflow mount's parentPromptProfile). */
@@ -117,8 +117,8 @@ function autoModeArmReasonOf(intent, facePresent, caps, capsFaulted) {
117
117
  return { armed: true, reason: "armed" };
118
118
  }
119
119
  export async function prepareCapsAndWorkflow(input) {
120
- const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, model, thinking, lockedPreflight, toolEffects, toolFaceSnapshot, promptProfile, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, sideCallBookRef } = input;
121
- const roster = new RosterBuilder(toolEffects);
120
+ const { spec, deps, parentSpecSeat, checkpointSeat, internals, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, model, thinking, lockedPreflight, toolEffects, safetyAxes, toolFaceSnapshot, promptProfile, resolvedInteractionPosture, harnessRef, askSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, requestReview, enterPlanMode, permissionMode, readDenyEntries, peerLaneActive, peerSendMessageBuiltIn, runnerSelf, delegated, sideCallBookRef } = input;
121
+ const roster = new RosterBuilder(toolEffects, safetyAxes);
122
122
  for (const t of spec.tools ?? []) {
123
123
  const mounted = mountCallerTool(t);
124
124
  roster.mount(mounted, { source: callerMountSource(mounted), mountedBy: "scenario" });
@@ -329,7 +329,7 @@ export async function prepareCapsAndWorkflow(input) {
329
329
  scope: taskScope,
330
330
  notifier: deps.workflowCompletionNotifier,
331
331
  originatingSessionId: sessionId,
332
- rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}),
332
+ rootSessionId: internals?.rootSessionId ?? sessionId, ...(internals?.placementRoot !== undefined ? { placementRoot: internals.placementRoot } : {}), crossBoundaryTree: input.crossBoundaryTree,
333
333
  taskRegistry: defaultTaskRegistry,
334
334
  taskNotification: internals?.onTaskNotification,
335
335
  taskOwner: hostTaskId,
@@ -10,8 +10,7 @@
10
10
  * the safety scan after it run BEFORE prepareTask's first await (`sessions.acquire`), so a caller
11
11
  * has no microtask window in which to mutate `spec.tools`/the face arrays between the snapshots,
12
12
  * the doors and the scan. An `async` wrapper — even with a zero-await body — would hand the caller
13
- * exactly that window (the driver's `await` yields one microtask). Pinned by the
14
- * `prepare-task-phase-pins` microtask-latch tests.
13
+ * exactly that window (the driver's `await` yields one microtask). Pinned by the `prepare-task-phase-pins` microtask-latch tests.
15
14
  *
16
15
  * Throws pass through unchanged: every `config.*` / `resume_at.*` refusal here is a DELIBERATE
17
16
  * at-the-door rejection (a throw before acquisition needs no cleanup), and the
@@ -23,7 +22,9 @@ import { type BrainCallGuardrailRef } from "../../brain/timeout.js";
23
22
  import type { Model } from "../../internal/llm.js";
24
23
  import type { ThinkingLevel } from "../../internal/harness.js";
25
24
  import { type MicroCompactMachine } from "../context-edit.js";
26
- import { type LockedPreflight } from "../locked-config.js";
25
+ import { type CrossBoundaryPosture } from "../cross-boundary-taint.js";
26
+ import { recordedModeSeed } from "../checkpoint-store.js";
27
+ import { type ConfigDoorEntry, type LockedPreflight } from "../locked-config.js";
27
28
  import { type ResolvedRole } from "../roles.js";
28
29
  import { type ResolvedSkillListingBudget } from "../skill-listing-budget.js";
29
30
  import type { SessionStore } from "../session.js";
@@ -136,8 +137,7 @@ export interface PrepareConfigDoorsInput {
136
137
  export interface PrepareConfigDoorsResult {
137
138
  /** owned (by the caller, from here on) — the REBOUND spec: identical to the input object unless
138
139
  * `spec.agents` was set, in which case it is a shallow copy whose `tools` is the
139
- * withAgents-rebuilt roster. Every later phase (the safety scan above all — T21) must read THIS,
140
- * never the original input. */
140
+ * withAgents-rebuilt roster. Every later phase (the safety scan above all — T21) must read THIS, never the original input. */
141
141
  spec: RosterSpec;
142
142
  /** owned — the frozen task-start copies of the caller's tool-face control arrays; the driver compiles the leg's selector
143
143
  * from them, and the selector (with the disclosure lists) is the ONLY thing later face reads consult. Frozen-immutable. */
@@ -146,7 +146,7 @@ export interface PrepareConfigDoorsResult {
146
146
  promptProfile: "simple" | "classic";
147
147
  /** owned — the host selector values (`TaskSpec.promptRole` / `TaskSpec.promptForm`, validated) the assembly selects on. */
148
148
  promptHost: ReturnType<typeof resolveHost>;
149
- /** owned — the center binding (`TaskSpec.promptBinding`, validated) the center layer's scoped overlays select on. */
149
+ /** owned — the run's binding (`TaskSpec.promptBinding`, validated): the selector value every overlay's `when.binding` reads. */
150
150
  promptBinding: string | undefined;
151
151
  /** owned — the administrator lock snapshot; the rest of prepare reads guarded slots through it. */
152
152
  lockedPreflight: LockedPreflight;
@@ -155,17 +155,15 @@ export interface PrepareConfigDoorsResult {
155
155
  resolvedInteractionPosture: "interactive" | "headless" | undefined;
156
156
  /** owned, frozen — the run's approval seat ({@link resolveAskSeat}), the one read of the seats; later phases read only this. */
157
157
  askSeat: AskSeat;
158
- /** owned — the validated/resolved microCompact knob ({@link resolveMicroCompactKnob}
159
- * for the door + placement reasoning). The per-run state builder consumes exactly these values —
160
- * the deps bag is never re-read after this door. */
158
+ /** owned — the validated/resolved microCompact knob ({@link resolveMicroCompactKnob} for the door + placement reasoning). The per-run
159
+ * state builder consumes exactly these values — the deps bag is never re-read after this door. */
161
160
  microCompactKnob: {
162
161
  machine: MicroCompactMachine;
163
162
  clearOnRejection: boolean;
164
163
  };
165
164
  /** owned — the resolved role; its `systemPrompt` seat is still read at prompt-input time. */
166
165
  resolvedRole: ResolvedRole;
167
- /** owned — the resolved main model (`resolvedRole.model`, re-exposed as the name every later
168
- * phase reads). */
166
+ /** owned — the resolved main model (`resolvedRole.model`, re-exposed as the name every later phase reads). */
169
167
  model: Model;
170
168
  /** owned — caller-explicit > role default > model default; undefined = off. */
171
169
  thinking: ThinkingLevel | undefined;
@@ -190,8 +188,7 @@ export interface PrepareConfigDoorsResult {
190
188
  /** owned — the NORMALIZED per-leg delegation-evidence standard: the deps seat read
191
189
  * ONCE, in this synchronous pre-await stretch, screened, and absent folded to the "static-face"
192
190
  * default. The delegation wrap consumes THIS value, never the live deps object — a deps seat
193
- * mutated (or getter-backed) after the door must not present an unscreened value to the mark
194
- * branch (the read-once posture). */
191
+ * mutated (or getter-backed) after the door must not present an unscreened value to the mark branch (the read-once posture). */
195
192
  memoryDelegationEvidence: "static-face" | "attested-only";
196
193
  /** owned — the lowered skills-listing budget seats (`TaskSpec.skillListingBudgetFraction` /
197
194
  * `skillListingMaxDescChars`): the renderer's two numbers, resolved once against the resolved main
@@ -212,9 +209,10 @@ export interface PrepareConfigDoorsResult {
212
209
  /** owned, out-param cell — created EMPTY here; the brain-call wiring later installs into
213
210
  * `.current`. Returned so driver and harness share one cell identity. */
214
211
  brainCallGuardrailRef: BrainCallGuardrailRef;
215
- /** owned — the resolved outer brain-call guardrail (task > deployment > default; undefined per
216
- * the resolver's off states). */
212
+ /** owned — the resolved outer brain-call guardrail (task > deployment > default; undefined per the resolver's off states). */
217
213
  brainCallGuardrailMs: number | undefined;
214
+ /** owned — the screened cross-boundary posture: the deps seat read ONCE, a bad value refused; absent stays `undefined` (undeclared is its own fact). */
215
+ crossBoundaryPosture: CrossBoundaryPosture | undefined;
218
216
  }
219
217
  /** The microCompact knob door (坏值响亮度默认律, the sibling knob doors' form:
220
218
  * interactionPosture / toolModelGate / staleToolResultOffload). Placement is load-bearing:
@@ -230,4 +228,49 @@ export declare function resolveMicroCompactKnob(bag: RunnerDeps["microCompact"])
230
228
  machine: MicroCompactMachine;
231
229
  clearOnRejection: boolean;
232
230
  };
231
+ /** The seat a checkpoint-store resolution is judged at: the store the task's own config names, else the deployment's. */
232
+ export declare const checkpointStoreSeat: (spec: {
233
+ checkpointStore?: unknown;
234
+ }) => "taskConfig" | "deps";
235
+ /** The first door of a resume: its re-supplied config is a record. A `null`, a primitive or an array where the record is declared is refused by name
236
+ * (`config.invalid_argument`), through the same channel as every door after it, before any of its members is read. */
237
+ export declare function assertResumeConfigRecord(config: unknown): void;
238
+ /** The spec the value doors read: a prepare's (its roster is faces) or a resume's re-supplied config (no objective, no session id). */
239
+ type ValueDoorSpec = Omit<TaskSpec, "tools" | "objective" | "sessionId" | "userAttachments"> & Partial<Pick<TaskSpec, "objective" | "sessionId">>;
240
+ type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "promptHost" | "promptBinding" | "lockedPreflight" | "microCompactKnob" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "usageWindows" | "brainCallGuardrailMs" | "crossBoundaryPosture"> & {
241
+ skillListingSeats: {
242
+ fraction: unknown;
243
+ maxDescChars: unknown;
244
+ };
245
+ skills: TaskSpec["skills"];
246
+ };
247
+ /**
248
+ * The phase's VALUE doors as ONE function with two callers — each judges a declared value against its own vocabulary, reading only the
249
+ * spec, the deployment's deps, the session store the Runner was constructed over and whether the leg resumes: {@link prepareConfigDoors}
250
+ * enters them as they stand, and a resume's screen before the claim (`refuseResumeDoors`) enters them through the resume's refusal
251
+ * channel, so a resume prepare would refuse here is refused before it consumes the row. `enter(seat, door)` names the input that carries
252
+ * each value; what a door resolves is returned. Every door is total over what a plain-JSON caller can hand it: a `null`, a primitive or an
253
+ * array where a record is declared is refused by its own code, never read through.
254
+ */
255
+ export declare function configValueDoors(input: {
256
+ spec: ValueDoorSpec;
257
+ deps: RunnerDeps;
258
+ resumeLeg: boolean;
259
+ sessions: SessionStore;
260
+ }, enter?: ConfigDoorEntry): ConfigValueDoorsResult;
261
+ /**
262
+ * The doors a RESUMED leg's prepare refuses at, run as one screen BEFORE the claim — prepare's own functions, so a refusal carries
263
+ * the very sentence and code prepare throws: the mode doors (`refusePermissionModeDoors`), the output-style seat, the approval
264
+ * reach, the skills invoked by name (the part no roster changes), the attachments (a resume sends no new human message, so any
265
+ * entry is refused), the leg declarations of the tools it re-supplies (this phase's first door), this phase's value doors over the config, the deployment's deps and the session store the Runner holds
266
+ * ({@link configValueDoors}, the retention capability door included) and the mode words the row recorded (`recordedModeSeed`).
267
+ * It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
268
+ * `checkpoint.config_refused`, `detail.code` = prepare's code, `detail.field` = `"taskConfig"`, `"deps"` or `"inheritedGate"`)
269
+ * where prepare would end the leg `failed` after the claim — the row consumed on a store without `reopen`, replayed as a system
270
+ * retry on one with it, which a configuration fix cannot reach. Before the claim the row stays `pending` and byte-identical and the
271
+ * corrected resume redeems the same token. A throw that is none of prepare's codes leaves as it was thrown. Returns the config the
272
+ * leg is handed: the caller's, its MCP servers and A2A peers the frozen entries the lock layer judged (read once, dialed as judged).
273
+ */
274
+ export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C, recordedGate: Parameters<typeof recordedModeSeed>[0], deps: RunnerDeps, sessions: SessionStore): C;
233
275
  export declare function prepareConfigDoors(input: PrepareConfigDoorsInput): PrepareConfigDoorsResult;
276
+ export {};
@@ -2,24 +2,32 @@ import { resolveBrainCallGuardrailMs } from "../../brain/timeout.js";
2
2
  import { assertContainmentFaceValue } from "../../tools/fs/index.js";
3
3
  import { MICRO_COMPACT_MACHINES } from "../context-edit.js";
4
4
  import { assertAddOnlySeats } from "../child-clamp-seats.js";
5
+ import { CROSS_BOUNDARY_POSTURES } from "../cross-boundary-taint.js";
5
6
  import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
6
- import { resolveCheckpointStore } from "../checkpoint-store.js";
7
+ import { recordedModeSeed, resolveCheckpointStore } from "../checkpoint-store.js";
8
+ import { asResumeConfigRefusal, refusePermissionModeDoors } from "../mode-policy.js";
9
+ import { resolveOutputStyleFrame } from "../output-style.js";
10
+ import { screenUserAttachments } from "../user-attachment.js";
11
+ import { screenUserInvokedSkills } from "../skill-grant.js";
12
+ import { readSkillsSeat } from "./skills-seat.js";
13
+ import { screenHandsBandOptions } from "../hands-band-screen.js";
7
14
  import { assertAutoConsolidationWirable } from "./memory-consolidation-driver.js";
8
15
  import { isModelPriced, malformedPricingField, modelCostToPricing } from "../pricing.js";
9
- import { preflightLockedConfig } from "../locked-config.js";
16
+ import { ENTER_AS_IS, preflightLockedConfig } from "../locked-config.js";
10
17
  import { assertRetentionCapability } from "../retention.js";
11
18
  import { resolveModel, resolveTaskModel, roleModelIfSet } from "../roles.js";
12
19
  import { resolveSkillListingBudget } from "../skill-listing-budget.js";
13
20
  import { describeRejectedValue } from "../tool-search-setting.js";
14
21
  import { applyToolModelGate, assertRestoreGatedToolsValue, modelIdTail } from "../tool-model-gate.js";
15
22
  import { resolveUsageWindows } from "../usage-window-store.js";
16
- import { deriveAskEffective, resolveAskSeat, resolveQuestionSeam } from "../wiring-manifest.js";
23
+ import { deriveAskEffective, resolveAskSeat, resolveQuestionSeam, screenApprovalReach } from "../wiring-manifest.js";
17
24
  import { resolveHost } from "../../prompt-assembly/select.js";
18
25
  import { resolvePromptBinding } from "../../prompt-assembly/overlay.js";
19
26
  import { assertPeerPresenceValue } from "../../agents/peer-directory.js";
20
27
  import { snapshotDefinitionLists } from "../../agents/tool-filter.js";
21
28
  import { TOTAL_TOKENS_REMINDER_MODES } from "./turn-attachments.js";
22
29
  import { rosterFaceOf } from "./caller-roster.js";
30
+ import { assertToolBoundaryLegs } from "../tool-roster.js";
23
31
  import { refuseRenamedDelegationMounts } from "./sub-agent-deny-lists.js";
24
32
  const TASK_LIMIT_KEY_DICT = {
25
33
  maxTokens: true,
@@ -48,8 +56,8 @@ export function limitConfigError(code, message) {
48
56
  export function resolveTaskLimits(limits) {
49
57
  if (limits === undefined)
50
58
  return undefined;
51
- if (typeof limits !== "object" || Array.isArray(limits)) {
52
- throw limitConfigError("config.limit_invalid", `TaskSpec.limits must be an object (got ${Array.isArray(limits) ? "an array" : typeof limits})`);
59
+ if (typeof limits !== "object" || limits === null || Array.isArray(limits)) {
60
+ throw limitConfigError("config.limit_invalid", `TaskSpec.limits must be an object (got ${limits === null ? "null" : Array.isArray(limits) ? "an array" : typeof limits})`);
53
61
  }
54
62
  const raw = limits;
55
63
  const legal = TASK_LIMIT_KEYS;
@@ -66,13 +74,13 @@ export function resolveTaskLimits(limits) {
66
74
  if (value === undefined)
67
75
  continue;
68
76
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
69
- throw limitConfigError("config.limit_invalid", `TaskSpec.limits.${key} must be a finite, non-negative number (got ${String(value)}) — an unevaluable ceiling is not a ceiling, and folding it to a default would run the task under a limit nobody chose.`);
77
+ throw limitConfigError("config.limit_invalid", `TaskSpec.limits.${key} must be a finite, non-negative number (got ${describeRejectedValue(value)}) — an unevaluable ceiling is not a ceiling, and folding it to a default would run the task under a limit nobody chose.`);
70
78
  }
71
79
  }
72
80
  const notice = raw.approachNotice;
73
81
  if (notice !== undefined && notice !== false) {
74
82
  if (typeof notice !== "object" || notice === null || Array.isArray(notice)) {
75
- throw limitConfigError("config.limit_invalid", `TaskSpec.limits.approachNotice must be \`false\` or { at?: [first, second] } (got ${String(notice)})`);
83
+ throw limitConfigError("config.limit_invalid", `TaskSpec.limits.approachNotice must be \`false\` or { at?: [first, second] } (got ${describeRejectedValue(notice)})`);
76
84
  }
77
85
  const at = notice.at;
78
86
  if (at !== undefined) {
@@ -147,34 +155,51 @@ function resolveClearOnRejection(bag) {
147
155
  }
148
156
  return declared ?? true;
149
157
  }
150
- export function prepareConfigDoors(input) {
151
- const { deps, sessions, resume, internals } = input;
152
- let spec = input.spec;
153
- assertNoRetiredRunnerDeps(deps);
154
- assertPeerPresenceValue(spec.peerPresence);
155
- assertRestoreGatedToolsValue(spec.restoreGatedTools);
156
- const microCompactKnob = resolveMicroCompactKnob(deps.microCompact);
158
+ function deploymentWord(raw, seat, words, absent, code, why) {
159
+ if (raw === undefined)
160
+ return absent;
161
+ const word = words.find((w) => w === raw);
162
+ if (word !== undefined)
163
+ return word;
164
+ const got = typeof raw === "string" ? JSON.stringify(raw.length > 64 ? `${raw.slice(0, 64)}…` : raw) : raw === null ? "null" : Array.isArray(raw) ? "an array" : typeof raw;
165
+ const spelled = words.map((w) => `"${w}"`);
166
+ throw limitConfigError(code, `RunnerDeps.${seat} must be ${spelled.slice(0, -1).join(", ")} or ${spelled.at(-1)} when present (got ${got}) — ${why}`);
167
+ }
168
+ export const checkpointStoreSeat = (spec) => (spec.checkpointStore !== undefined ? "taskConfig" : "deps");
169
+ export function assertResumeConfigRecord(config) {
170
+ if (config === null || typeof config !== "object" || Array.isArray(config)) {
171
+ throw limitConfigError("config.invalid_argument", `the resume's taskConfig must be an object — the TaskSpec the run suspended with (got ${config === null ? "null" : Array.isArray(config) ? "an array" : typeof config})`);
172
+ }
173
+ }
174
+ export function configValueDoors(input, enter = ENTER_AS_IS) {
175
+ const { spec, deps, resumeLeg, sessions } = input;
176
+ enter("deps", () => assertNoRetiredRunnerDeps(deps));
177
+ enter("taskConfig", () => assertPeerPresenceValue(spec.peerPresence));
178
+ enter("taskConfig", () => assertRestoreGatedToolsValue(spec.restoreGatedTools));
179
+ const microCompactKnob = enter("deps", () => resolveMicroCompactKnob(deps.microCompact));
180
+ const toolFaceListRefusal = (message, reason) => {
181
+ const e = new Error(message);
182
+ e.code = "config.tool_face_control";
183
+ e.detail = { reason };
184
+ return e;
185
+ };
157
186
  const assertToolNameListValue = (value, seat) => {
158
187
  if (value === undefined)
159
188
  return;
160
189
  if (!Array.isArray(value)) {
161
- const e = new Error(`TaskSpec.${seat} must be an array of tool names or absent (got ${value === null ? "null" : typeof value}) — a garbage list must refuse loudly, never be read as "no ${seat}".`);
162
- e.code = "config.tool_face_control";
163
- throw e;
190
+ throw toolFaceListRefusal(`TaskSpec.${seat} must be an array of tool names or absent (got ${value === null ? "null" : typeof value}) — a garbage list must refuse loudly, never be read as "no ${seat}".`, "not_a_list");
164
191
  }
165
192
  const entries = value;
166
193
  for (const entry of entries) {
167
194
  if (typeof entry !== "string") {
168
- const e = new Error(`TaskSpec.${seat} entries must be strings (got ${entry === null ? "null" : typeof entry}).`);
169
- e.code = "config.tool_face_control";
170
- throw e;
195
+ throw toolFaceListRefusal(`TaskSpec.${seat} entries must be strings (got ${entry === null ? "null" : typeof entry}).`, "not_a_string");
171
196
  }
172
197
  }
173
198
  };
174
- assertToolNameListValue(spec.allowTools, "allowTools");
175
- assertToolNameListValue(spec.excludeTools, "excludeTools");
176
- assertToolNameListValue(spec.deferTools, "deferTools");
177
- assertToolNameListValue(spec.alwaysLoadTools, "alwaysLoadTools");
199
+ enter("taskConfig", () => assertToolNameListValue(spec.allowTools, "allowTools"));
200
+ enter("taskConfig", () => assertToolNameListValue(spec.excludeTools, "excludeTools"));
201
+ enter("taskConfig", () => assertToolNameListValue(spec.deferTools, "deferTools"));
202
+ enter("taskConfig", () => assertToolNameListValue(spec.alwaysLoadTools, "alwaysLoadTools"));
178
203
  const toolFaceLists = {
179
204
  allow: spec.allowTools ? Object.freeze([...spec.allowTools]) : undefined,
180
205
  exclude: spec.excludeTools ? Object.freeze([...spec.excludeTools]) : undefined,
@@ -186,116 +211,134 @@ export function prepareConfigDoors(input) {
186
211
  ? Object.freeze([...spec.restoreGatedTools])
187
212
  : undefined,
188
213
  };
189
- const promptProfile = resolveModelPromptTraits({ id: "" }, spec, internals).promptProfile;
190
- const promptHost = resolveHost(spec);
191
- const promptBinding = resolvePromptBinding(spec);
192
- if (spec.resumeAt !== undefined) {
193
- if (resume) {
194
- const e = new Error("resumeAt cannot be combined with a durable resume");
195
- e.code = "resume_at.conflicts_resume";
214
+ const promptHost = enter("taskConfig", () => resolveHost(spec));
215
+ const promptBinding = enter("taskConfig", () => resolvePromptBinding(spec));
216
+ if (spec.resumeAt !== undefined)
217
+ enter("taskConfig", () => {
218
+ if (resumeLeg) {
219
+ const e = new Error("resumeAt cannot be combined with a durable resume");
220
+ e.code = "resume_at.conflicts_resume";
221
+ throw e;
222
+ }
223
+ if (!spec.sessionId) {
224
+ const e = new Error("resumeAt requires a sessionId (the session to branch)");
225
+ e.code = "resume_at.no_session";
226
+ throw e;
227
+ }
228
+ });
229
+ enter("taskConfig", () => assertContainmentFaceValue(spec.readFace, "read", "spec"));
230
+ enter("deps", () => assertContainmentFaceValue(deps.readFace, "read", "deps"));
231
+ enter("taskConfig", () => assertContainmentFaceValue(spec.writeFace, "write", "spec"));
232
+ enter("deps", () => assertContainmentFaceValue(deps.writeFace, "write", "deps"));
233
+ enter("taskConfig", () => assertAddOnlySeats(spec));
234
+ const memoryDelegationEvidence = enter("deps", () => deploymentWord(deps.memoryDelegationEvidence, "memoryDelegationEvidence", ["static-face", "attested-only"], "static-face", "config.memory_delegation_evidence", "an unevaluable evidence standard is refused loudly, never folded to either standard."));
235
+ const memoryProvenance = enter("deps", () => deploymentWord(deps.memoryProvenance, "memoryProvenance", ["off", "carry"], "carry", "config.memory_provenance", "an unevaluable provenance mode is refused loudly, never folded to either mode."));
236
+ const memoryCapturePolicy = enter("deps", () => deploymentWord(deps.memoryCapturePolicy, "memoryCapturePolicy", ["open", "governed", "capture-required"], "open", "config.memory_capture_policy", "an unevaluable capture posture is refused loudly, never folded to any posture (the fault arms differ per posture, so a guess would pick a polarity nobody configured)."));
237
+ const crossBoundaryPosture = enter("deps", () => deploymentWord(deps.crossBoundaryPosture, "crossBoundaryPosture", CROSS_BOUNDARY_POSTURES, undefined, "config.cross_boundary_posture", "an unevaluable posture is refused loudly, never folded to either word (an absent seat is undeclared, which is its own fact)."));
238
+ enter("deps", () => assertAutoConsolidationWirable(deps));
239
+ if (spec.resumeAtMode !== undefined)
240
+ enter("taskConfig", () => {
241
+ if (spec.resumeAt === undefined) {
242
+ const e = new Error(`resumeAtMode ${describeRejectedValue(spec.resumeAtMode)} requires resumeAt (there is no branch target to position against)`);
243
+ e.code = "resume_at.mode_without_target";
244
+ throw e;
245
+ }
246
+ if (spec.resumeAtMode !== "at" && spec.resumeAtMode !== "before") {
247
+ const e = new Error(`resumeAtMode ${describeRejectedValue(spec.resumeAtMode)} is invalid — expected "at" (inclusive branch, the default) or "before" (exclusive branch)`);
248
+ e.code = "resume_at.invalid_mode";
249
+ throw e;
250
+ }
251
+ });
252
+ if (spec.toolMaterializeStrategy !== undefined && spec.toolMaterializeStrategy !== "swap" && spec.toolMaterializeStrategy !== "static")
253
+ enter("taskConfig", () => {
254
+ const e = new Error(`toolMaterializeStrategy must be "swap" or "static" (got ${JSON.stringify(spec.toolMaterializeStrategy)}).`);
255
+ e.code = "config.tool_materialize_invalid";
196
256
  throw e;
197
- }
198
- if (!spec.sessionId) {
199
- const e = new Error("resumeAt requires a sessionId (the session to branch)");
200
- e.code = "resume_at.no_session";
257
+ });
258
+ if (spec.memoryPersistenceCapable !== undefined && typeof spec.memoryPersistenceCapable !== "boolean")
259
+ enter("taskConfig", () => {
260
+ const e = new Error(`memoryPersistenceCapable must be a boolean when present (got ${JSON.stringify(spec.memoryPersistenceCapable)}) — a non-boolean would silently read as capable.`);
261
+ e.code = "config.memory_persistence_invalid";
201
262
  throw e;
202
- }
203
- }
204
- assertContainmentFaceValue(spec.readFace, "read", "spec");
205
- assertContainmentFaceValue(deps.readFace, "read", "deps");
206
- assertContainmentFaceValue(spec.writeFace, "write", "spec");
207
- assertContainmentFaceValue(deps.writeFace, "write", "deps");
208
- assertAddOnlySeats(spec);
209
- const memoryDelegationEvidenceRaw = deps.memoryDelegationEvidence;
210
- if (memoryDelegationEvidenceRaw !== undefined && memoryDelegationEvidenceRaw !== "static-face" && memoryDelegationEvidenceRaw !== "attested-only") {
211
- const evidence = memoryDelegationEvidenceRaw;
212
- const got = typeof evidence === "string"
213
- ? JSON.stringify(evidence.length > 64 ? `${evidence.slice(0, 64)}…` : evidence)
214
- : evidence === null
215
- ? "null"
216
- : Array.isArray(evidence)
217
- ? "an array"
218
- : typeof evidence;
219
- const e = new Error(`RunnerDeps.memoryDelegationEvidence must be "static-face" or "attested-only" when present (got ${got}) — ` +
220
- `an unevaluable evidence standard is refused loudly, never folded to either standard.`);
221
- e.code = "config.memory_delegation_evidence";
222
- throw e;
223
- }
224
- const memoryDelegationEvidence = memoryDelegationEvidenceRaw === "attested-only" ? "attested-only" : "static-face";
225
- const memoryProvenanceRaw = deps.memoryProvenance;
226
- if (memoryProvenanceRaw !== undefined && memoryProvenanceRaw !== "off" && memoryProvenanceRaw !== "carry") {
227
- const got = typeof memoryProvenanceRaw === "string"
228
- ? JSON.stringify(memoryProvenanceRaw.length > 64 ? `${memoryProvenanceRaw.slice(0, 64)}…` : memoryProvenanceRaw)
229
- : memoryProvenanceRaw === null
230
- ? "null"
231
- : Array.isArray(memoryProvenanceRaw)
232
- ? "an array"
233
- : typeof memoryProvenanceRaw;
234
- const e = new Error(`RunnerDeps.memoryProvenance must be "off" or "carry" when present (got ${got}) — ` + `an unevaluable provenance mode is refused loudly, never folded to either mode.`);
235
- e.code = "config.memory_provenance";
236
- throw e;
237
- }
238
- const memoryProvenance = memoryProvenanceRaw === "off" ? "off" : "carry";
239
- const memoryCapturePolicyRaw = deps.memoryCapturePolicy;
240
- if (memoryCapturePolicyRaw !== undefined && memoryCapturePolicyRaw !== "open" && memoryCapturePolicyRaw !== "governed" && memoryCapturePolicyRaw !== "capture-required") {
241
- const got = typeof memoryCapturePolicyRaw === "string"
242
- ? JSON.stringify(memoryCapturePolicyRaw.length > 64 ? `${memoryCapturePolicyRaw.slice(0, 64)}…` : memoryCapturePolicyRaw)
243
- : memoryCapturePolicyRaw === null
244
- ? "null"
245
- : Array.isArray(memoryCapturePolicyRaw)
246
- ? "an array"
247
- : typeof memoryCapturePolicyRaw;
248
- const e = new Error(`RunnerDeps.memoryCapturePolicy must be "open", "governed" or "capture-required" when present (got ${got}) — ` +
249
- `an unevaluable capture posture is refused loudly, never folded to any posture (the fault arms differ per posture, so a guess would pick a polarity nobody configured).`);
250
- e.code = "config.memory_capture_policy";
251
- throw e;
252
- }
253
- const memoryCapturePolicy = memoryCapturePolicyRaw === "governed" ? "governed" : memoryCapturePolicyRaw === "capture-required" ? "capture-required" : "open";
254
- assertAutoConsolidationWirable(deps);
255
- if (spec.resumeAtMode !== undefined) {
256
- if (spec.resumeAt === undefined) {
257
- const e = new Error(`resumeAtMode "${spec.resumeAtMode}" requires resumeAt (there is no branch target to position against)`);
258
- e.code = "resume_at.mode_without_target";
263
+ });
264
+ if (spec.toolMaterializeStrategy === "static" && spec.deferSelfResolve === false)
265
+ enter("taskConfig", () => {
266
+ const e = new Error(`toolMaterializeStrategy "static" cannot be combined with deferSelfResolve: false — with the direct-call ` +
267
+ `lane disabled a placeholder is never swapped and never self-resolves, so no deferred tool could ever be ` +
268
+ `called. Use "swap", or leave deferSelfResolve on.`);
269
+ e.code = "config.tool_materialize_unreachable";
259
270
  throw e;
260
- }
261
- if (spec.resumeAtMode !== "at" && spec.resumeAtMode !== "before") {
262
- const e = new Error(`resumeAtMode "${String(spec.resumeAtMode)}" is invalid — expected "at" (inclusive branch, the default) or "before" (exclusive branch)`);
263
- e.code = "resume_at.invalid_mode";
264
- throw e;
265
- }
266
- }
267
- if (spec.toolMaterializeStrategy !== undefined && spec.toolMaterializeStrategy !== "swap" && spec.toolMaterializeStrategy !== "static") {
268
- const e = new Error(`toolMaterializeStrategy must be "swap" or "static" (got ${JSON.stringify(spec.toolMaterializeStrategy)}).`);
269
- e.code = "config.tool_materialize_invalid";
270
- throw e;
271
- }
272
- if (spec.memoryPersistenceCapable !== undefined && typeof spec.memoryPersistenceCapable !== "boolean") {
273
- const e = new Error(`memoryPersistenceCapable must be a boolean when present (got ${JSON.stringify(spec.memoryPersistenceCapable)}) — a non-boolean would silently read as capable.`);
274
- e.code = "config.memory_persistence_invalid";
275
- throw e;
276
- }
277
- if (spec.toolMaterializeStrategy === "static" && spec.deferSelfResolve === false) {
278
- const e = new Error(`toolMaterializeStrategy "static" cannot be combined with deferSelfResolve: false — with the direct-call ` +
279
- `lane disabled a placeholder is never swapped and never self-resolves, so no deferred tool could ever be ` +
280
- `called. Use "swap", or leave deferSelfResolve on.`);
281
- e.code = "config.tool_materialize_unreachable";
282
- throw e;
283
- }
284
- if (resume === undefined && spec.objective.trim().length === 0) {
271
+ });
272
+ if (!resumeLeg && (spec.objective ?? "").trim().length === 0) {
285
273
  const e = new Error("TaskSpec.objective is empty — a task needs an instruction (an empty user message is rejected by strict model endpoints and would fail every later request of the session).");
286
274
  e.code = "config.empty_objective";
287
275
  throw e;
288
276
  }
289
- const lockedPreflight = preflightLockedConfig(spec, deps);
290
- assertRetentionCapability({
291
- policy: deps.retentionPolicy,
292
- locked: lockedPreflight.lockedKeys.has("retentionPolicy"),
277
+ const lockedPreflight = preflightLockedConfig(spec, deps, enter);
278
+ const declaredSkills = spec.skills;
279
+ const skills = declaredSkills === undefined ? undefined : enter("taskConfig", () => readSkillsSeat(declaredSkills));
280
+ enter("deps", () => screenHandsBandOptions(deps.hands));
281
+ const skillListingSeats = { fraction: spec.skillListingBudgetFraction, maxDescChars: spec.skillListingMaxDescChars };
282
+ enter("taskConfig", () => resolveSkillListingBudget(skillListingSeats));
283
+ enter("taskConfig", () => resolveTaskLimits(spec.limits));
284
+ enter("taskConfig", () => resolveAttachmentsConfig(spec.attachments));
285
+ if (spec.resourceSuspend !== undefined)
286
+ enter("taskConfig", () => {
287
+ const declared = spec.resourceSuspend;
288
+ if (typeof declared !== "object" || declared === null || Array.isArray(declared)) {
289
+ throw limitConfigError("config.limit_invalid", `TaskSpec.resourceSuspend must be an object carrying a non-empty \`scope\` (got ${declared === null ? "null" : Array.isArray(declared) ? "an array" : typeof declared}) — it is the allocation every resource checkpoint is filed under.`);
290
+ }
291
+ const rsus = declared;
292
+ if (typeof rsus.scope !== "string" || rsus.scope === "") {
293
+ throw limitConfigError("config.limit_invalid", `TaskSpec.resourceSuspend.scope must be a non-empty string (got ${describeRejectedValue(rsus.scope)}) — it is the multi-tenant isolation key every resource checkpoint is filed under.`);
294
+ }
295
+ for (const key of ["totalBudgetUsd", "totalTokens", "maxSlices", "ttlMs"]) {
296
+ const value = rsus[key];
297
+ if (value === undefined)
298
+ continue;
299
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
300
+ throw limitConfigError("config.limit_invalid", `TaskSpec.resourceSuspend.${key} must be a finite, non-negative number (got ${describeRejectedValue(value)}) — an unevaluable allocation is not an allocation, and a NaN here blinds even the validated per-slice window.`);
301
+ }
302
+ }
303
+ });
304
+ const usageWindows = enter("deps", () => resolveUsageWindows(deps.usageWindows));
305
+ const taskGuardrail = spec.limits?.brainCallGuardrailMs;
306
+ const brainCallGuardrailMs = enter(taskGuardrail != null ? "taskConfig" : "deps", () => resolveBrainCallGuardrailMs(taskGuardrail ?? deps.brainCallGuardrailMs));
307
+ const checkpointStore = enter(checkpointStoreSeat(spec), () => resolveCheckpointStore(spec, deps));
308
+ const taskStore = checkpointStoreSeat(spec) === "taskConfig" ? checkpointStore : undefined;
309
+ const retention = { policy: deps.retentionPolicy, locked: lockedPreflight.lockedKeys.has("retentionPolicy") };
310
+ enter("deps", () => assertRetentionCapability({
311
+ ...retention,
293
312
  stores: [
294
313
  { name: "sessionStore", store: sessions },
295
- { name: "checkpointStore", store: resolveCheckpointStore(spec, deps) },
314
+ { name: "checkpointStore", store: taskStore === undefined ? checkpointStore : undefined },
296
315
  { name: "toolResultStore", store: deps.toolResultStore },
297
316
  ],
317
+ }));
318
+ if (taskStore !== undefined)
319
+ enter("taskConfig", () => assertRetentionCapability({ ...retention, stores: [{ name: "checkpointStore", store: taskStore }] }));
320
+ return { toolFaceLists, promptHost, promptBinding, lockedPreflight, skillListingSeats, skills, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture };
321
+ }
322
+ export function refuseResumeDoors(config, recordedGate, deps, sessions) {
323
+ asResumeConfigRefusal("taskConfig", () => {
324
+ refusePermissionModeDoors(config);
325
+ resolveOutputStyleFrame(config.outputStyle);
326
+ screenApprovalReach(config.approvalReach);
327
+ screenUserInvokedSkills(config);
328
+ screenUserAttachments(config.userAttachments, { resumeLeg: true });
329
+ assertToolBoundaryLegs(config.tools);
298
330
  });
331
+ const { lockedPreflight, skills } = configValueDoors({ spec: config, deps, resumeLeg: true, sessions }, asResumeConfigRefusal);
332
+ asResumeConfigRefusal("inheritedGate", () => void recordedModeSeed(recordedGate));
333
+ return { ...config, ...(config.mcp !== undefined ? { mcp: lockedPreflight.mcp ?? [] } : {}), ...(config.a2a !== undefined ? { a2a: lockedPreflight.a2a ?? [] } : {}), skills };
334
+ }
335
+ export function prepareConfigDoors(input) {
336
+ const { deps, sessions, resume, internals } = input;
337
+ assertToolBoundaryLegs(input.spec.tools);
338
+ let spec = input.spec;
339
+ const { toolFaceLists, promptHost, promptBinding, lockedPreflight, skillListingSeats, skills, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture } = configValueDoors({ spec, deps, resumeLeg: resume !== undefined, sessions });
340
+ spec = Object.create(Object.getPrototypeOf(spec), { ...Object.getOwnPropertyDescriptors(spec), skills: { value: skills, enumerable: skills !== undefined, writable: false, configurable: false } });
341
+ const promptProfile = resolveModelPromptTraits({ id: "" }, spec, internals).promptProfile;
299
342
  const resolvedInteractionPosture = spec.interactionPosture ?? internals?.parentInteractionPosture ?? deps.interactionPosture;
300
343
  const askSeat = resolveAskSeat(spec, deps);
301
344
  {
@@ -344,25 +387,7 @@ export function prepareConfigDoors(input) {
344
387
  }
345
388
  }
346
389
  }
347
- resolveTaskLimits(spec.limits);
348
- resolveAttachmentsConfig(spec.attachments);
349
- if (spec.resourceSuspend !== undefined) {
350
- const rsus = spec.resourceSuspend;
351
- if (typeof rsus.scope !== "string" || rsus.scope === "") {
352
- throw limitConfigError("config.limit_invalid", `TaskSpec.resourceSuspend.scope must be a non-empty string (got ${String(rsus.scope)}) — it is the multi-tenant isolation key every resource checkpoint is filed under.`);
353
- }
354
- for (const key of ["totalBudgetUsd", "totalTokens", "maxSlices", "ttlMs"]) {
355
- const value = rsus[key];
356
- if (value === undefined)
357
- continue;
358
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
359
- throw limitConfigError("config.limit_invalid", `TaskSpec.resourceSuspend.${key} must be a finite, non-negative number (got ${String(value)}) — an unevaluable allocation is not an allocation, and a NaN here blinds even the validated per-slice window.`);
360
- }
361
- }
362
- }
363
- const usageWindows = resolveUsageWindows(deps.usageWindows);
364
390
  const brainCallGuardrailRef = {};
365
- const brainCallGuardrailMs = resolveBrainCallGuardrailMs(spec.limits?.brainCallGuardrailMs ?? deps.brainCallGuardrailMs);
366
391
  const mountedRoster = spec.tools;
367
392
  if (spec.agents !== undefined && spec.agents.length > 0) {
368
393
  const pool = spec.tools ?? [];
@@ -427,11 +452,7 @@ export function prepareConfigDoors(input) {
427
452
  if (gateDecision.survivors !== undefined) {
428
453
  spec = { ...spec, tools: gateDecision.survivors };
429
454
  }
430
- const skillListingBudget = resolveSkillListingBudget({
431
- fraction: spec.skillListingBudgetFraction,
432
- maxDescChars: spec.skillListingMaxDescChars,
433
- model,
434
- });
455
+ const skillListingBudget = resolveSkillListingBudget({ ...skillListingSeats, model });
435
456
  const modelGate = Object.freeze({
436
457
  removedByClass: gateDecision.removedByClass,
437
458
  unknownClasses: gateDecision.unknownClasses,
@@ -460,7 +481,7 @@ export function prepareConfigDoors(input) {
460
481
  memoryDelegationEvidence,
461
482
  skillListingBudget,
462
483
  memoryProvenance,
463
- memoryCapturePolicy,
484
+ memoryCapturePolicy, crossBoundaryPosture,
464
485
  usageWindows,
465
486
  brainCallGuardrailRef,
466
487
  brainCallGuardrailMs,