@sema-agent/core 7.59.0 → 7.60.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 (360) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-definition.js +12 -0
  4. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  5. package/dist/agents/agent-transcript-tool.js +3 -1
  6. package/dist/agents/child-model-seat.js +6 -3
  7. package/dist/agents/cumulative-stats.js +0 -1
  8. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  9. package/dist/agents/inherited-tool-pool.js +22 -0
  10. package/dist/agents/retain-ledger.d.ts +11 -1
  11. package/dist/agents/retain-ledger.js +13 -2
  12. package/dist/agents/roster-store.d.ts +1 -1
  13. package/dist/agents/roster-store.js +3 -1
  14. package/dist/agents/send-message-tool.d.ts +8 -19
  15. package/dist/agents/send-message-tool.js +11 -38
  16. package/dist/agents/subagent.d.ts +51 -17
  17. package/dist/agents/subagent.js +117 -78
  18. package/dist/agents/tool-filter.d.ts +1 -3
  19. package/dist/agents/tool-filter.js +4 -12
  20. package/dist/bench/metrics.d.ts +3 -5
  21. package/dist/bench/metrics.js +0 -1
  22. package/dist/brain/degrading.js +3 -1
  23. package/dist/brain/route-adjudicator.js +3 -1
  24. package/dist/brain/status-sink.d.ts +7 -1
  25. package/dist/brain/status-sink.js +6 -0
  26. package/dist/brain/timeout.d.ts +3 -1
  27. package/dist/brain/timeout.js +18 -5
  28. package/dist/core/a2a.d.ts +15 -5
  29. package/dist/core/a2a.js +34 -19
  30. package/dist/core/agent-definition.d.ts +20 -0
  31. package/dist/core/allow-entry.d.ts +2 -0
  32. package/dist/core/allow-entry.js +3 -1
  33. package/dist/core/artifact-host.d.ts +0 -2
  34. package/dist/core/artifact-host.js +0 -1
  35. package/dist/core/auto-mode-defaults.d.ts +8 -0
  36. package/dist/core/auto-mode-defaults.js +1 -0
  37. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  38. package/dist/core/auto-mode.d.ts +39 -4
  39. package/dist/core/auto-mode.js +63 -12
  40. package/dist/core/background-agent-store.d.ts +10 -1
  41. package/dist/core/background-agent-store.js +3 -2
  42. package/dist/core/background-shell.d.ts +12 -1
  43. package/dist/core/background-shell.js +12 -0
  44. package/dist/core/checkpoint-store.d.ts +8 -13
  45. package/dist/core/checkpoint-store.js +4 -3
  46. package/dist/core/compliance.d.ts +1 -1
  47. package/dist/core/credential-echo.d.ts +52 -0
  48. package/dist/core/credential-echo.js +65 -0
  49. package/dist/core/credential-vocabulary.d.ts +13 -3
  50. package/dist/core/credential-vocabulary.js +12 -4
  51. package/dist/core/cross-boundary-taint.d.ts +4 -5
  52. package/dist/core/engine-notice.d.ts +58 -15
  53. package/dist/core/frame-settlement.d.ts +5 -0
  54. package/dist/core/frame-settlement.js +4 -0
  55. package/dist/core/gate-fold.js +7 -5
  56. package/dist/core/gate-lanes.js +39 -8
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +12 -0
  59. package/dist/core/hands-band-screen.js +0 -1
  60. package/dist/core/hands-band.d.ts +0 -3
  61. package/dist/core/hooks.d.ts +39 -56
  62. package/dist/core/hooks.js +123 -77
  63. package/dist/core/image-admission.d.ts +104 -51
  64. package/dist/core/image-admission.js +170 -46
  65. package/dist/core/image-downsample.d.ts +36 -69
  66. package/dist/core/image-downsample.js +111 -73
  67. package/dist/core/integer-option.d.ts +21 -0
  68. package/dist/core/integer-option.js +13 -0
  69. package/dist/core/locked-config.d.ts +54 -3
  70. package/dist/core/locked-config.js +81 -50
  71. package/dist/core/mcp-call-meta.d.ts +2 -2
  72. package/dist/core/mcp-call-meta.js +9 -10
  73. package/dist/core/mcp-failure.d.ts +9 -3
  74. package/dist/core/mcp-failure.js +10 -0
  75. package/dist/core/mcp-host-seat.d.ts +92 -0
  76. package/dist/core/mcp-host-seat.js +131 -0
  77. package/dist/core/mcp-probe.d.ts +7 -2
  78. package/dist/core/mcp-probe.js +7 -2
  79. package/dist/core/mcp-server-spec.d.ts +38 -9
  80. package/dist/core/mcp-server-spec.js +55 -21
  81. package/dist/core/mcp.d.ts +17 -6
  82. package/dist/core/mcp.js +67 -55
  83. package/dist/core/memory-admission.d.ts +23 -6
  84. package/dist/core/memory-admission.js +19 -9
  85. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  86. package/dist/core/memory-engine/content-origin.js +21 -3
  87. package/dist/core/memory-engine/index.d.ts +2 -1
  88. package/dist/core/memory-engine/index.js +2 -1
  89. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  90. package/dist/core/memory-engine/scope-contract.js +2 -2
  91. package/dist/core/memory-engine/sync-client.d.ts +45 -11
  92. package/dist/core/memory-engine/sync-client.js +82 -11
  93. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  94. package/dist/core/memory-engine/sync-report.js +119 -0
  95. package/dist/core/memory-engine/sync.d.ts +4 -2
  96. package/dist/core/mode-policy.d.ts +9 -1
  97. package/dist/core/mode-policy.js +11 -1
  98. package/dist/core/model-receipt.d.ts +39 -0
  99. package/dist/core/model-receipt.js +139 -0
  100. package/dist/core/mods/agent-stations.d.ts +65 -0
  101. package/dist/core/mods/agent-stations.js +105 -0
  102. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  103. package/dist/core/mods/kernel/dispatch.js +4 -4
  104. package/dist/core/mods/kernel/events.d.ts +10 -4
  105. package/dist/core/mods/kernel/events.js +10 -6
  106. package/dist/core/mods/kernel/receive.d.ts +5 -0
  107. package/dist/core/mods/kernel/receive.js +10 -0
  108. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  109. package/dist/core/mods/lifecycle-stations.js +35 -0
  110. package/dist/core/mods/stations.d.ts +51 -59
  111. package/dist/core/mods/stations.js +32 -42
  112. package/dist/core/mods/tool-call.d.ts +10 -4
  113. package/dist/core/mods/tool-call.js +28 -12
  114. package/dist/core/mounted-mcp.d.ts +5 -0
  115. package/dist/core/mounted-mcp.js +2 -2
  116. package/dist/core/namespaced-rule-name.d.ts +7 -1
  117. package/dist/core/namespaced-rule-name.js +13 -2
  118. package/dist/core/oracle-isolation.js +1 -1
  119. package/dist/core/own-property-receipt.d.ts +3 -0
  120. package/dist/core/own-property-receipt.js +3 -0
  121. package/dist/core/park-selfcheck.js +8 -8
  122. package/dist/core/peer-seat.d.ts +63 -8
  123. package/dist/core/peer-seat.js +179 -34
  124. package/dist/core/permission-rule-consent.d.ts +0 -21
  125. package/dist/core/permission-rule-consent.js +1 -2
  126. package/dist/core/permission-rule-model.d.ts +4 -2
  127. package/dist/core/permission-rule-model.js +7 -6
  128. package/dist/core/protocol-http-auth.d.ts +14 -2
  129. package/dist/core/protocol-http-auth.js +16 -7
  130. package/dist/core/read-face-seats.d.ts +7 -5
  131. package/dist/core/read-face-seats.js +4 -1
  132. package/dist/core/redaction-marks.d.ts +4 -3
  133. package/dist/core/redaction-marks.js +2 -2
  134. package/dist/core/remote-env.d.ts +146 -98
  135. package/dist/core/remote-env.js +113 -14
  136. package/dist/core/retention.js +37 -12
  137. package/dist/core/retired-keys.d.ts +6 -1
  138. package/dist/core/retired-keys.js +4 -1
  139. package/dist/core/rewrite-rejudge.d.ts +12 -5
  140. package/dist/core/rewrite-rejudge.js +9 -5
  141. package/dist/core/roles.d.ts +37 -3
  142. package/dist/core/roles.js +126 -78
  143. package/dist/core/rule-owner.d.ts +3 -0
  144. package/dist/core/runner/assemble-result.d.ts +0 -5
  145. package/dist/core/runner/assemble-result.js +0 -1
  146. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  147. package/dist/core/runner/call-hook-stations.js +21 -10
  148. package/dist/core/runner/child-tree.d.ts +7 -8
  149. package/dist/core/runner/child-tree.js +6 -6
  150. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  151. package/dist/core/runner/classifier-ladder.js +39 -8
  152. package/dist/core/runner/construction-doors.js +5 -0
  153. package/dist/core/runner/contracts.d.ts +62 -41
  154. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  155. package/dist/core/runner/cross-boundary-lane.js +11 -2
  156. package/dist/core/runner/env-capability-census.d.ts +15 -20
  157. package/dist/core/runner/env-capability-census.js +25 -34
  158. package/dist/core/runner/file-history-request.d.ts +2 -2
  159. package/dist/core/runner/file-history-request.js +0 -8
  160. package/dist/core/runner/gate-exit.d.ts +75 -7
  161. package/dist/core/runner/gate-exit.js +20 -1
  162. package/dist/core/runner/git-status-frame.d.ts +5 -2
  163. package/dist/core/runner/git-status-frame.js +3 -4
  164. package/dist/core/runner/image.d.ts +7 -2
  165. package/dist/core/runner/image.js +14 -8
  166. package/dist/core/runner/inline-image.d.ts +10 -8
  167. package/dist/core/runner/inline-image.js +11 -9
  168. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  169. package/dist/core/runner/permission-rule-lanes.js +1 -1
  170. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  171. package/dist/core/runner/prepare-boundary-parks.js +3 -3
  172. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  173. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  174. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  175. package/dist/core/runner/prepare-config-doors.js +14 -9
  176. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
  177. package/dist/core/runner/prepare-delegation-surface.js +4 -4
  178. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  179. package/dist/core/runner/prepare-file-history.js +3 -12
  180. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  181. package/dist/core/runner/prepare-gate-stations.js +4 -3
  182. package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
  183. package/dist/core/runner/prepare-hands-readface.js +15 -7
  184. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
  185. package/dist/core/runner/prepare-inherited-gate.js +9 -5
  186. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  187. package/dist/core/runner/prepare-memory.d.ts +2 -2
  188. package/dist/core/runner/prepare-memory.js +2 -2
  189. package/dist/core/runner/prepare-park-ask.d.ts +3 -5
  190. package/dist/core/runner/prepare-park-ask.js +3 -8
  191. package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
  192. package/dist/core/runner/prepare-policy-chain.js +120 -108
  193. package/dist/core/runner/prepare-project-context.js +8 -5
  194. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
  195. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  196. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  197. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  199. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  200. package/dist/core/runner/prepare-task.js +41 -27
  201. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  203. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
  204. package/dist/core/runner/prepare-wiring-manifest.js +32 -18
  205. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  206. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  207. package/dist/core/runner/retired-runner-deps.js +4 -1
  208. package/dist/core/runner/run-attachment-seats.js +3 -3
  209. package/dist/core/runner/run-brain-sinks.js +1 -0
  210. package/dist/core/runner/run-git-lane.d.ts +3 -1
  211. package/dist/core/runner/run-git-lane.js +1 -1
  212. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  213. package/dist/core/runner/run-harness-handlers.js +3 -1
  214. package/dist/core/runner/run-identity-wiring.js +1 -1
  215. package/dist/core/runner/run-leg.js +26 -28
  216. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  217. package/dist/core/runner/run-notification-lane.js +16 -10
  218. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  219. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  220. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  221. package/dist/core/runner/run-turn-boundary.js +12 -7
  222. package/dist/core/runner/runtask.d.ts +7 -4
  223. package/dist/core/runner/runtask.js +19 -11
  224. package/dist/core/runner/skills-seat.js +2 -2
  225. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  226. package/dist/core/runner/synthetic-tools.js +2 -2
  227. package/dist/core/runner/tool-disclosure.js +0 -2
  228. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  229. package/dist/core/runner/tool-face-overlay.js +26 -19
  230. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  231. package/dist/core/runner/tool-result-media-seat.js +17 -1
  232. package/dist/core/runner/turn-attachments.d.ts +3 -5
  233. package/dist/core/runner/turn-attachments.js +3 -16
  234. package/dist/core/runner-deps.d.ts +31 -18
  235. package/dist/core/secret-env.d.ts +3 -2
  236. package/dist/core/session-policy-store.d.ts +9 -2
  237. package/dist/core/session-policy-store.js +16 -1
  238. package/dist/core/session-store.d.ts +3 -2
  239. package/dist/core/session-store.js +50 -11
  240. package/dist/core/skill-grant.d.ts +9 -0
  241. package/dist/core/skill-grant.js +18 -0
  242. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  243. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  244. package/dist/core/stub-env.d.ts +5 -5
  245. package/dist/core/stub-env.js +11 -1
  246. package/dist/core/swappable-deps.d.ts +17 -43
  247. package/dist/core/swappable-deps.js +15 -5
  248. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  249. package/dist/core/task-event.d.ts +18 -2
  250. package/dist/core/task-notification.d.ts +88 -5
  251. package/dist/core/task-notification.js +130 -7
  252. package/dist/core/task-registry-agent.d.ts +18 -12
  253. package/dist/core/task-registry-agent.js +18 -6
  254. package/dist/core/task-registry-monitor.d.ts +7 -0
  255. package/dist/core/task-registry-monitor.js +28 -1
  256. package/dist/core/task-registry-shared.d.ts +38 -3
  257. package/dist/core/task-registry-shared.js +21 -7
  258. package/dist/core/task-registry-workflow.js +1 -1
  259. package/dist/core/task-registry.d.ts +50 -35
  260. package/dist/core/task-registry.js +64 -23
  261. package/dist/core/task-result.d.ts +3 -12
  262. package/dist/core/task-spec.d.ts +3 -6
  263. package/dist/core/task-stream.d.ts +1 -1
  264. package/dist/core/tool-catalog-entries.js +1 -1
  265. package/dist/core/tool-face-reader.d.ts +7 -6
  266. package/dist/core/tool-face-reader.js +4 -3
  267. package/dist/core/tool-name-aliases.d.ts +19 -0
  268. package/dist/core/tool-name-aliases.js +54 -2
  269. package/dist/core/tool-policy.d.ts +5 -4
  270. package/dist/core/tool-policy.js +1 -1
  271. package/dist/core/tool-registry.d.ts +5 -5
  272. package/dist/core/tool-registry.js +2 -2
  273. package/dist/core/tool-result-store.d.ts +88 -5
  274. package/dist/core/tool-result-store.js +51 -12
  275. package/dist/core/tool-spec.d.ts +20 -4
  276. package/dist/core/trace.d.ts +0 -1
  277. package/dist/core/types.d.ts +3 -3
  278. package/dist/core/types.js +1 -1
  279. package/dist/core/untrusted-text.js +1 -1
  280. package/dist/core/user-attachment.d.ts +10 -5
  281. package/dist/core/user-attachment.js +14 -6
  282. package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
  283. package/dist/engine/execution-env/node-execution-env.js +12 -1
  284. package/dist/engine/harness/agent-harness.d.ts +1 -1
  285. package/dist/engine/harness/agent-harness.js +8 -4
  286. package/dist/engine/harness/types.d.ts +112 -29
  287. package/dist/engine/loop/agent-loop.d.ts +12 -12
  288. package/dist/engine/loop/agent-loop.js +153 -21
  289. package/dist/engine/loop/types.d.ts +9 -2
  290. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  291. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  292. package/dist/index.d.ts +22 -14
  293. package/dist/index.js +15 -10
  294. package/dist/internal/harness-types.d.ts +1 -1
  295. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  296. package/dist/orchestration/run-workflow-tool.js +59 -29
  297. package/dist/orchestration/workflow-governance.d.ts +1 -1
  298. package/dist/orchestration/workflow-governance.js +2 -1
  299. package/dist/orchestration/workflow.d.ts +4 -0
  300. package/dist/orchestration/workflow.js +25 -4
  301. package/dist/prompts/default.d.ts +1 -10
  302. package/dist/prompts/default.js +0 -2
  303. package/dist/stores/file/background-agent-store.d.ts +1 -1
  304. package/dist/stores/file/background-agent-store.js +3 -1
  305. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  306. package/dist/stores/file/checkpoint-store.js +19 -14
  307. package/dist/stores/file/file-history-store.d.ts +1 -1
  308. package/dist/stores/file/file-history-store.js +3 -1
  309. package/dist/stores/file/index.d.ts +4 -3
  310. package/dist/stores/file/index.js +17 -8
  311. package/dist/stores/file/mailbox-store.d.ts +1 -1
  312. package/dist/stores/file/mailbox-store.js +3 -1
  313. package/dist/stores/file/memory-store.d.ts +1 -1
  314. package/dist/stores/file/memory-store.js +3 -1
  315. package/dist/stores/file/session-policy-store.d.ts +1 -1
  316. package/dist/stores/file/session-policy-store.js +3 -1
  317. package/dist/stores/file/session-store.d.ts +1 -1
  318. package/dist/stores/file/session-store.js +3 -1
  319. package/dist/stores/file/shared-ledger.d.ts +26 -0
  320. package/dist/stores/file/shared-ledger.js +38 -9
  321. package/dist/stores/file/tool-result-store.d.ts +20 -2
  322. package/dist/stores/file/tool-result-store.js +74 -6
  323. package/dist/stores/file/usage-window-store.d.ts +1 -1
  324. package/dist/stores/file/usage-window-store.js +3 -1
  325. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  326. package/dist/stores/file/workflow-journal-store.js +3 -2
  327. package/dist/tools/fs/containment-face.d.ts +5 -0
  328. package/dist/tools/fs/encoding.d.ts +13 -4
  329. package/dist/tools/fs/encoding.js +17 -2
  330. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  331. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  332. package/dist/tools/fs/fs-bash.d.ts +8 -4
  333. package/dist/tools/fs/fs-bash.js +26 -35
  334. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  335. package/dist/tools/fs/fs-pdf.js +26 -21
  336. package/dist/tools/fs/fs-read.d.ts +5 -4
  337. package/dist/tools/fs/fs-read.js +35 -18
  338. package/dist/tools/fs/fs-search-tools.js +4 -1
  339. package/dist/tools/fs/fs-shared.d.ts +11 -13
  340. package/dist/tools/fs/fs-shared.js +11 -7
  341. package/dist/tools/fs/fs-write.js +5 -5
  342. package/dist/tools/fs/index.d.ts +14 -8
  343. package/dist/tools/fs/index.js +8 -4
  344. package/dist/tools/fs/read-floor.d.ts +44 -1
  345. package/dist/tools/fs/read-floor.js +35 -0
  346. package/dist/tools/fs/removal-targets.d.ts +9 -4
  347. package/dist/tools/fs/removal-targets.js +17 -9
  348. package/dist/tools/fs/search.d.ts +3 -3
  349. package/dist/tools/fs/search.js +4 -4
  350. package/dist/tools/monitor.d.ts +5 -4
  351. package/dist/tools/monitor.js +15 -8
  352. package/dist/tools/scheduler-tools.js +42 -4
  353. package/dist/tools/web.d.ts +0 -10
  354. package/dist/tools/web.js +1 -4
  355. package/package.json +4 -2
  356. package/test/export-surface.snapshot.json +75 -21
  357. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  358. package/wire-changes/core@7.60.0.json +3274 -0
  359. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  360. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -1,5 +1,7 @@
1
1
  import { describeRejectedValue } from "./tool-search-setting.js";
2
2
  import { thrownText } from "./thrown-value.js";
3
+ import { CONFIG_RECEIPT_MODE, DECLARATION_RECEIPT_MODE, receiptRefusal, receiveOwnProperties } from "./own-property-receipt.js";
4
+ import { describeFault, receive } from "./mods/kernel/receive.js";
3
5
  export function readRetentionDeclaration(name, value) {
4
6
  if (value === undefined || value === "none")
5
7
  return "none";
@@ -20,42 +22,65 @@ const RETENTION_EXECUTOR_MEMBERS = Object.keys({
20
22
  deleteExpiredSessions: true,
21
23
  deleteOrphanToolResults: true,
22
24
  });
25
+ function faceMember(face, member, owner, refusal) {
26
+ try {
27
+ return face[member];
28
+ }
29
+ catch (cause) {
30
+ throw codedError("config.retention_capability", `${owner}'s ${member} could not be read (${thrownText(cause)}) — ${refusal}.`);
31
+ }
32
+ }
23
33
  function assertRetentionExecutor(executor) {
24
34
  if ((typeof executor !== "object" && typeof executor !== "function") || executor === null) {
25
35
  throw codedError("config.retention_capability", `the retention executor must be an object implementing ManagedRetentionCapability, or null when the deployment runs none (got ${describeRejectedValue(executor)}).`);
26
36
  }
27
37
  for (const member of RETENTION_EXECUTOR_MEMBERS) {
28
- let value;
29
- try {
30
- value = executor[member];
31
- }
32
- catch (cause) {
33
- throw codedError("config.retention_capability", `the retention executor's ${member} could not be read (${thrownText(cause)}) — it is not a ManagedRetentionCapability.`);
34
- }
38
+ const value = faceMember(executor, member, "the retention executor", "it is not a ManagedRetentionCapability");
35
39
  if (typeof value !== "function") {
36
40
  throw codedError("config.retention_capability", `the retention executor's ${member} is ${describeRejectedValue(value)}, not a function — it is not a ManagedRetentionCapability.`);
37
41
  }
38
42
  }
39
43
  }
44
+ function receiveRetentionInput(input, owner) {
45
+ const top = receiveOwnProperties(input, { subject: `${owner}'s input`, unit: "member", moment: `at ${owner}` });
46
+ let policy = top["policy"];
47
+ if (typeof policy === "object" && policy !== null) {
48
+ const got = receive(policy, DECLARATION_RECEIPT_MODE);
49
+ if (!got.ok)
50
+ throw codedError("config.retention_policy", `retentionPolicy could not be read as plain data — ${describeFault(got.fault)}.`);
51
+ policy = got.value;
52
+ }
53
+ const list = receive(top["stores"], CONFIG_RECEIPT_MODE);
54
+ if (!list.ok)
55
+ throw receiptRefusal(`${owner}'s stores could not be read — ${describeFault(list.fault)}`);
56
+ if (!Array.isArray(list.value))
57
+ throw receiptRefusal(`${owner}'s stores must be a list of { name, store } (got ${describeRejectedValue(list.value)})`);
58
+ const stores = list.value.map((item, i) => {
59
+ const got = receiveOwnProperties(item, { subject: `${owner}'s stores[${i}]`, unit: "member", moment: `at ${owner}` });
60
+ return { name: got.name, store: got.store };
61
+ });
62
+ return { policy: policy, locked: top["locked"], stores, ...(Object.hasOwn(top, "executor") ? { executor: top["executor"] } : {}) };
63
+ }
40
64
  function readRetentionWords({ policy, stores }) {
41
65
  const declared = policy;
42
66
  if (declared !== undefined && (typeof declared !== "object" || declared === null || Array.isArray(declared))) {
43
67
  throw codedError("config.retention_policy", `retentionPolicy must be an object carrying maxAgeDays (got ${declared === null ? "null" : Array.isArray(declared) ? "an array" : typeof declared}).`);
44
68
  }
45
- if (policy !== undefined && (!Number.isFinite(policy.maxAgeDays) || policy.maxAgeDays < 0)) {
46
- throw codedError("config.retention_policy", `retentionPolicy.maxAgeDays must be a finite non-negative number of days (got ${describeRejectedValue(policy.maxAgeDays)}).`);
69
+ const maxAgeDays = policy?.maxAgeDays;
70
+ if (policy !== undefined && (typeof maxAgeDays !== "number" || !Number.isFinite(maxAgeDays) || maxAgeDays < 0)) {
71
+ throw codedError("config.retention_policy", `retentionPolicy.maxAgeDays must be a finite non-negative number of days (got ${describeRejectedValue(maxAgeDays)}).`);
47
72
  }
48
73
  return stores
49
74
  .filter((s) => s.store !== undefined && s.store !== null)
50
- .map(({ name, store }) => ({ name, retention: readRetentionDeclaration(name, store.retention) }));
75
+ .map(({ name, store }) => ({ name, retention: readRetentionDeclaration(name, faceMember(store, "retention", `store "${name}"`, "its retention declaration is unreadable")) }));
51
76
  }
52
77
  export function assertRetentionWords(input) {
53
- const { policy, locked, stores } = input;
78
+ const { policy, locked, stores } = receiveRetentionInput(input, "assertRetentionWords");
54
79
  const words = { policy, locked, stores };
55
80
  refuseLockedOverNone(words, readRetentionWords(words));
56
81
  }
57
82
  export function assertRetentionCapability(input) {
58
- const { policy, locked, stores, executor } = input;
83
+ const { policy, locked, stores, executor } = receiveRetentionInput(input, "assertRetentionCapability");
59
84
  const words = { policy, locked, stores };
60
85
  if (executor === undefined) {
61
86
  throw codedError("config.retention_capability", `executor is required — the managed-retention executor the deployment runs over these stores' rows (a backend's \`retention\` member), or null when it runs none (got undefined).`);
@@ -35,8 +35,13 @@ export declare const RETIRED_HOOKS_REPLACEMENT = "the callback seats are `mods`
35
35
  /** The RETIRED `TaskSpec` keys, each with the sentence that names its replacement — the table the spec door reads
36
36
  * ({@link assertNoRetiredKeys} with owner `TaskSpec`). A caller still writing one of these is refused by name
37
37
  * (`config.spec_retired_key`), never read as absence: a mode a caller believes it declared must not silently run
38
- * as another. */
38
+ * as another. Each retired row has ONE reader: a row inside a seat that is read once by its own reader lives in that
39
+ * seat's table ({@link RETIRED_SKILLS_SEAT_KEYS}), so the spec door never reads into the seat a second time. */
39
40
  export declare const RETIRED_TASK_SPEC_KEYS: Readonly<Record<string, string>>;
41
+ /** The RETIRED `TaskSpec.skills` rows — the table the skills seat's one reader (`readSkillsSeat`) judges over its one read of
42
+ * the seat, owner `TaskSpec` (same code, same `TaskSpec.skills[].…` sentence). Kept out of {@link RETIRED_TASK_SPEC_KEYS}:
43
+ * the spec door reading these rows would read the caller's `skills` before the seat's reader does. */
44
+ export declare const RETIRED_SKILLS_SEAT_KEYS: Readonly<Record<string, string>>;
40
45
  /** The RETIRED `ToolSpec` members — a spec still carrying one is refused by name (`config.deps_retired_key`) where the
41
46
  * factory reads the spec, never dropped unseen: a description the author wrote for one prompt shape would silently
42
47
  * never be shown. */
@@ -32,9 +32,12 @@ export const RETIRED_TASK_SPEC_KEYS = Object.freeze({
32
32
  autoModeRequested: 'the permission mode is one key now — write `permissionMode: "auto"`',
33
33
  approverPosture: 'a posture never authorized anything; drop the key (the engine renders the posture from the effective mode). Releasing asks is a separate decision: `permissionMode: "bypassPermissions"`',
34
34
  "attachments.planModeReminder": "the read-only planning posture is stated whenever the leg's mode is `plan` (first turn, every 5 turns, and an exit frame when it ends) — drop the key",
35
- "skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
36
35
  promptProvider: "a task changes prompt text through overlays: its role text is `systemPrompt` (it replaces the role base `promptRole` selects), its added block `appendSystemPrompt`, the minimal form `promptForm: \"minimal\"`; anything else is a `prompt.compose` registration on the task's own `mods` answering `{ overlays }` (an already-assembled prompt is refused, never passed through)",
37
36
  promptProfile: 'the prompt\'s shape is the `lean_prompt` trait now — write `promptLean: false` for the long (classic) shape, `promptLean: true` (or nothing, on a model that declares `lean_prompt`) for the lean one',
37
+ rewindFiles: "capture needs no request (first-touch tracking is on whenever `RunnerDeps.fileHistoryStore` is wired and neither `RunnerDeps.fileHistoryCapture` nor `TaskSpec.fileHistory` turns it off); to restore files with the conversation write `resumeAt` + `restoreFiles: true`, for a code-only restore `rewindFilesTo` — drop the key",
38
+ });
39
+ export const RETIRED_SKILLS_SEAT_KEYS = Object.freeze({
40
+ "skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
38
41
  });
39
42
  export const RETIRED_TOOL_SPEC_KEYS = Object.freeze({
40
43
  descriptionClassic: 'a description\'s other forms are `descriptionVariants` now — the long form is `{ id: "classic", traits: { noneOf: ["lean_prompt"] }, text }`, chosen at mount by the run\'s prompt traits',
@@ -1,6 +1,6 @@
1
1
  import type { PreToolUseResult } from "./hooks.js";
2
2
  import type { PermissionResult } from "./tool-policy.js";
3
- import type { PreToolUseScreening } from "./runner/gate-exit.js";
3
+ import type { InheritedScreenRead, PreToolUseScreen, PreToolUseScreening } from "./runner/gate-exit.js";
4
4
  import type { RewriteAuthor, ToolInputRewrite } from "./task-event.js";
5
5
  /** One gate pass's account of its rewrites: the bytes it took at its entry, and one author per adoption that changed the bytes
6
6
  * in hand (written only through {@link noteRewrite}). */
@@ -57,19 +57,26 @@ export declare function readRejudge(req: {
57
57
  readonly updatedInput?: unknown;
58
58
  } | undefined): RejudgeReading;
59
59
  /** What the PreToolUse screening said on its one second look at bytes rewritten after it judged: its verdict on them
60
- * (`stands` — no opinion, an allow, an ask; never a rewrite), or a refusal — the hook's own deny, or the engine's
61
- * (the screening failed, or it handed back yet another form). */
60
+ * (`stands` — no opinion, an allow, an ask; never a rewrite — with the context lines and what the inherited installations
61
+ * said), or a refusal — the hook's own deny, the engine's (the screening failed, or it handed back yet another form), or an
62
+ * inherited installation's question refused where it was settled (`settled`). */
62
63
  export type ScreeningRejudge = {
63
64
  readonly kind: "stands";
64
65
  readonly answer: PreToolUseResult | undefined;
65
66
  readonly answeredBy?: string;
67
+ readonly contexts: readonly string[];
68
+ readonly inherited?: InheritedScreenRead;
66
69
  } | {
67
70
  readonly kind: "refused";
68
71
  readonly reason: string;
69
72
  readonly by: "hook" | "engine";
70
73
  readonly extension?: string;
71
- };
72
- /** The screening's second look at rewritten `bytes` (the gate's fold after a policy rewrite; the approved-edit pass). */
74
+ readonly judged?: unknown;
75
+ } | Extract<PreToolUseScreen, {
76
+ kind: "settled";
77
+ }>;
78
+ /** The screening's second look at rewritten `bytes` (the gate's fold after a policy rewrite; the approved-edit pass). A refusal
79
+ * names the bytes its judge judged (`judged`) when the screen moved them past `bytes`. */
73
80
  export declare function screenRewrite(screening: PreToolUseScreening, req: {
74
81
  readonly face?: object | undefined;
75
82
  readonly toolName: string;
@@ -48,18 +48,22 @@ export function readRejudge(req, given, answer) {
48
48
  return rewrite === undefined || sameBytes(req, given, rewrite) ? { kind: "as_is" } : { kind: "rewritten", form: argsAsTheToolReads(req, rewrite) };
49
49
  }
50
50
  export async function screenRewrite(screening, req, bytes, subject) {
51
- const screened = await screening.screen(bytes, subject);
51
+ const screened = await screening.screen(bytes, subject, req);
52
+ const judged = screened.judged !== undefined ? { judged: screened.judged } : {};
52
53
  if (screened.kind === "refused")
53
- return { kind: "refused", reason: screened.reason, by: "engine", ...(screened.extension !== undefined ? { extension: screened.extension } : {}) };
54
+ return { kind: "refused", reason: screened.reason, by: "engine", ...(screened.extension !== undefined ? { extension: screened.extension } : {}), ...judged };
55
+ if (screened.kind === "settled")
56
+ return screened;
54
57
  const r = screened.answer;
55
58
  if (r?.action === "deny")
56
- return { kind: "refused", reason: screening.deniedReason(r), by: "hook", ...(screened.answeredBy !== undefined ? { extension: screened.answeredBy } : {}) };
59
+ return { kind: "refused", reason: screening.deniedReason(r), by: "hook", ...(screened.answeredBy !== undefined ? { extension: screened.answeredBy } : {}), ...judged };
57
60
  if (readRejudge(req, bytes, r).kind === "rewritten")
58
61
  return { kind: "refused", reason: rewriteChasedSentence(req.toolName), by: "engine" };
62
+ const said = { contexts: screened.contexts, ...(screened.answeredBy !== undefined ? { answeredBy: screened.answeredBy } : {}), ...(screened.inherited !== undefined ? { inherited: screened.inherited } : {}) };
59
63
  if (r === undefined)
60
- return { kind: "stands", answer: undefined, ...(screened.answeredBy !== undefined ? { answeredBy: screened.answeredBy } : {}) };
64
+ return { kind: "stands", answer: undefined, ...said };
61
65
  const { updatedInput: _sameBytes, ...answer } = r;
62
- return { kind: "stands", answer, ...(screened.answeredBy !== undefined ? { answeredBy: screened.answeredBy } : {}) };
66
+ return { kind: "stands", answer, ...said };
63
67
  }
64
68
  export function outletAsk(standing, toolName, form) {
65
69
  const editRewritten = { acceptableForm: form };
@@ -5,8 +5,21 @@ import { type RoleBaseDeclaration } from "../prompt-assembly/role-base.js";
5
5
  import { type ModelRef, type ModelRole, type ModelRoles, type RoleSpec } from "./types.js";
6
6
  export type { ModelRole, RoleSpec, ModelRoles } from "./types.js";
7
7
  export { MODEL_ROLES } from "./types.js";
8
- /** A word in a refusal sentence, bounded and quoted; any other kind of value by its kind (rendering it could itself throw). */
9
- export declare function bindingShown(value: unknown): string;
8
+ export { bindingShown } from "./model-receipt.js";
9
+ /**
10
+ * The catalog's answer for a model word — every read of a catalog's entry: the entry's snapshot from the model door (an entry of a
11
+ * catalog the catalog door received is one already, handed back as itself; an entry of a catalog a caller built is received here, at
12
+ * the read). `seat` names where the word was written; the entry is named as the catalog entry that word resolved to.
13
+ */
14
+ export declare function catalogModel(ref: string, models: Record<string, Model> | undefined, seat: string, what?: string): Model | undefined;
15
+ /**
16
+ * The role receipt — a role map read ONCE per operation (one public entry of this module: a task's resolution, a role's model if set, the
17
+ * preset's role base, the classifier seat, the deployment's subagent tier): the map a plain record whose every member is read once and
18
+ * received ({@link receiveRoleSpec}), the copy frozen. The map stays the caller's between operations (a deployment may change it in place);
19
+ * within one, every reader reads this copy, and an entry that calls back in hands the copy, which is received as itself. `field` names the
20
+ * map (`RunnerDeps.roles` / `TaskSpec.roles`).
21
+ */
22
+ export declare function receiveRoleMap(roles: ModelRoles | undefined, field: string): ModelRoles | undefined;
10
23
  /**
11
24
  * Resolve a ModelRef against the catalog (a Model object passes through). A word the catalog does not hold, and a value that is no model
12
25
  * reference, are refused by `config.unknown_role` with `detail { field: seat, reason }` — `seat` names where the caller wrote the word
@@ -45,6 +58,27 @@ export declare function resolveModelDisplayLabel(ref: string): string;
45
58
  * `resolveModel("best")` refuses like any unknown ref.
46
59
  */
47
60
  export declare function expandTiers(models: Record<string, Model> | undefined, tiers: Record<string, ModelRef> | undefined): Record<string, Model> | undefined;
61
+ /** Whether `models` is a catalog the catalog door made ({@link receiveModelCatalog}). */
62
+ export declare function isReceivedCatalog(models: Record<string, Model> | undefined): boolean;
63
+ /** The catalog a deps bag answers with — the catalog door's generation: a Runner's own (received at its construction) as it is, a bag a
64
+ * caller built received here. The one reading of "the catalog these deps name", wherever deps are read outside a Runner's own seat. */
65
+ export declare function catalogOfDeps(deps: {
66
+ models?: Record<string, Model>;
67
+ tiers?: Record<string, ModelRef>;
68
+ }): Record<string, Model> | undefined;
69
+ /**
70
+ * The CATALOG DOOR — a catalog generation (a model catalog and the tier bindings over it) received whole, where a Runner takes one: at
71
+ * `new Runner` and at `swapDeps`. The catalog is a plain record read once; every entry with a model behind it is received by the model door
72
+ * now (a catalog entry no task names yet is judged as well as one a task names: a catalog is configuration, and a bad entry is a boot error,
73
+ * not a first-use one); the bindings are a plain record read once, every binding a word or a Model object (received), a binding a catalog
74
+ * key shadows included; THEN the bindings are expanded over the received catalog ({@link expandTiers} — its marks are written on its own
75
+ * output, so they are never lost to a copy) and the result frozen. `field` names the door (`RunnerDeps` / `swapDeps`). Throws the first
76
+ * refusal; nothing is written by the caller before it returns.
77
+ */
78
+ export declare function receiveModelCatalog(models: Record<string, Model> | undefined, tiers: Record<string, ModelRef> | undefined, field: string): {
79
+ models?: Record<string, Model>;
80
+ tiers?: Record<string, ModelRef>;
81
+ };
48
82
  /**
49
83
  * The words a catalog word stands in for under the tier layer, nearest first — what {@link expandTiers}
50
84
  * recorded for a key IT wrote: the tier words its resolution passed through and the binding's own catalog
@@ -119,7 +153,7 @@ export declare function roleSpecNamesModel(spec: RoleSpec | undefined): boolean;
119
153
  * Every entry is judged, read or not: a resume's screen calls it before the claim, and the merge below calls it on both
120
154
  * maps, so an entry no task of this leg selects still refuses loudly.
121
155
  */
122
- export declare function screenRoleMap(roles: ModelRoles | undefined, field: "RunnerDeps.roles" | "TaskSpec.roles"): void;
156
+ export declare function screenRoleMap(roles: ModelRoles | undefined, field: "RunnerDeps.roles" | "TaskSpec.roles"): ModelRoles | undefined;
123
157
  /** A role seat whose word the catalog does not hold: the role, the seat as the refusal names it, the word written there. */
124
158
  export interface UnheldRoleSeat {
125
159
  role: ModelRole;
@@ -1,83 +1,98 @@
1
1
  import { selectModel } from "./select-model.js";
2
2
  import { namesRoleBase } from "../prompt-assembly/role-base.js";
3
3
  import { readPromptRole } from "../prompt-assembly/select.js";
4
- import { readMember } from "./thrown-value.js";
4
+ import { bindingShown, isList, isModelSnapshot, modelBindingRefusal, receiveModel } from "./model-receipt.js";
5
+ import { describeFault, receive } from "./mods/kernel/receive.js";
6
+ import { CONFIG_RECEIPT_MODE, DECLARATION_RECEIPT_MODE, receiveOwnProperties } from "./own-property-receipt.js";
5
7
  import { MODEL_ROLES } from "./types.js";
6
8
  export { MODEL_ROLES } from "./types.js";
7
- function catalogModel(ref, models) {
9
+ export { bindingShown } from "./model-receipt.js";
10
+ function catalogEntry(ref, models) {
8
11
  const m = models != null && (typeof models === "object" || typeof models === "function") && Object.hasOwn(models, ref) ? models[ref] : undefined;
9
12
  return m || undefined;
10
13
  }
11
- function modelBindingRefusal(field, reason, message) {
12
- const e = new Error(message);
13
- e.code = "config.unknown_role";
14
- e.detail = { field, reason };
15
- return e;
14
+ export function catalogModel(ref, models, seat, what = `${bindingShown(ref)} (a catalog entry)`) {
15
+ const m = catalogEntry(ref, models);
16
+ return m === undefined ? undefined : receiveModel(m, seat, what);
16
17
  }
17
18
  const ROLE_RECORD_KEYS = new Set(["model", "select", "thinking", "promptRole", "systemPrompt"]);
18
- function isModelShaped(s) {
19
- try {
20
- if (typeof s === "function" || isList(s)) {
21
- Reflect.ownKeys(s);
22
- return false;
23
- }
24
- if (Reflect.ownKeys(s).some((k) => typeof k !== "string" || !ROLE_RECORD_KEYS.has(k)))
25
- return true;
26
- return readMember(s, "id") !== undefined || readMember(s, "api") !== undefined;
27
- }
28
- catch {
29
- return true;
30
- }
31
- }
32
19
  function isBindingObject(value) {
33
20
  return (typeof value === "object" && value !== null) || typeof value === "function";
34
21
  }
35
- export function bindingShown(value) {
36
- if (typeof value === "string")
37
- return JSON.stringify(value.length > 80 ? `${value.slice(0, 80)}…` : value);
38
- return value === null ? "null" : isList(value) ? "a list" : `a ${typeof value}`;
39
- }
40
- function isList(value) {
41
- try {
42
- return Array.isArray(value);
43
- }
44
- catch {
45
- return false;
46
- }
47
- }
48
22
  function unknownModelRefRefusal(ref, seat) {
49
23
  return modelBindingRefusal(seat, "unknown_model_ref", `Unknown model ref ${bindingShown(ref)} in ${seat}. Provide it in RunnerDeps.models or pass a Model object.`);
50
24
  }
51
25
  function modelOfBinding(value, models, seat, binds) {
52
- assertModelBindingShape(value, seat, binds);
53
26
  if (typeof value === "string") {
54
- const held = catalogModel(value, models);
27
+ const held = catalogModel(value, models, seat);
55
28
  if (held === undefined)
56
29
  throw unknownModelRefRefusal(value, seat);
57
- assertModelObject(held, seat, `${bindingShown(value)} (a catalog entry)`);
58
30
  return held;
59
31
  }
60
- return value;
32
+ return modelObjectAt(value, seat, binds);
61
33
  }
62
- function assertModelBindingShape(value, seat, binds) {
63
- if (typeof value === "string")
64
- return;
34
+ function modelObjectAt(value, seat, binds) {
65
35
  if (typeof value !== "object" || value === null || isList(value)) {
66
36
  throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${bindingShown(value)}, not a model reference — ${binds}.`);
67
37
  }
68
- assertModelObject(value, seat, "a Model object", binds === ROLE_BINDS ? " At a role seat an object with a key beyond model / select / thinking / promptRole / systemPrompt is read as a Model, not as a role record." : "");
69
- }
70
- function assertModelObject(value, seat, what, note = "") {
71
- const id = readMember(value, "id");
72
- const api = readMember(value, "api");
73
- const [member, got] = typeof id !== "string" || id === "" ? ["id", id] : typeof api !== "string" ? ["api", api] : [undefined, undefined];
74
- if (member === undefined)
75
- return;
76
- const shown = got === undefined ? "absent" : bindingShown(got);
77
- throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`${member}\` is ${shown} — a Model carries a non-empty string \`id\` and a string \`api\`.${note}`);
38
+ return receiveModel(value, seat, "a Model object", binds === ROLE_BINDS ? " At a role seat an object that is not a plain record of model / select / thinking / promptRole / systemPrompt is read as a Model, not as a role record." : "");
78
39
  }
79
40
  const ROLE_BINDS = "a role binds a catalog model name or a Model object";
41
+ const TIER_BINDS = "a tier binds a catalog model name or a Model object";
80
42
  const roleModelSeat = (named, seat) => (typeof named === "string" ? seat : `${seat}.model`);
43
+ const RECEIVED_ROLES = new WeakSet();
44
+ const EMPTY_ROLE_RECORD = Object.freeze({});
45
+ function receiveRoleSpec(value, seat) {
46
+ if (typeof value === "function")
47
+ return CONFIG_RECEIPT_MODE.isProxy?.(value) === true ? modelObjectAt(value, `${seat}.model`, ROLE_BINDS) : EMPTY_ROLE_RECORD;
48
+ if (typeof value !== "object" || value === null)
49
+ return value;
50
+ if (isModelSnapshot(value) || RECEIVED_ROLES.has(value))
51
+ return value;
52
+ if (isList(value))
53
+ return EMPTY_ROLE_RECORD;
54
+ if (!isRoleRecord(value))
55
+ return modelObjectAt(value, `${seat}.model`, ROLE_BINDS);
56
+ const read = receive(value, CONFIG_RECEIPT_MODE);
57
+ if (!read.ok)
58
+ throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is a role record that could not be read — ${describeFault(read.fault)}.`);
59
+ const given = read.value;
60
+ const out = {};
61
+ for (const key of Object.keys(given)) {
62
+ let member = given[key];
63
+ if (key === "model" && typeof member === "object" && member !== null && !isList(member))
64
+ member = receiveModel(member, `${seat}.model`, "a Model object");
65
+ else if (key !== "model" && typeof member === "object" && member !== null) {
66
+ const data = receive(member, DECLARATION_RECEIPT_MODE);
67
+ if (!data.ok)
68
+ throw modelBindingRefusal(`${seat}.${key}`, "not_a_model_ref", `${seat}.${key} could not be read as plain data — ${describeFault(data.fault)}.`);
69
+ member = data.value;
70
+ }
71
+ Object.defineProperty(out, key, { value: member, enumerable: true, writable: false, configurable: false });
72
+ }
73
+ RECEIVED_ROLES.add(Object.freeze(out));
74
+ return out;
75
+ }
76
+ function isRoleRecord(value) {
77
+ if (CONFIG_RECEIPT_MODE.isProxy?.(value) === true)
78
+ return false;
79
+ const proto = Object.getPrototypeOf(value);
80
+ if (proto !== Object.prototype && proto !== null)
81
+ return false;
82
+ return Reflect.ownKeys(value).every((k) => typeof k === "string" && ROLE_RECORD_KEYS.has(k));
83
+ }
84
+ export function receiveRoleMap(roles, field) {
85
+ if (roles === undefined || roles === null)
86
+ return undefined;
87
+ if (typeof roles === "object" && RECEIVED_ROLES.has(roles))
88
+ return roles;
89
+ const given = receiveOwnProperties(roles, { subject: field, unit: "role", moment: "when its roles are read" });
90
+ const out = {};
91
+ for (const key of Object.keys(given))
92
+ Object.defineProperty(out, key, { value: receiveRoleSpec(given[key], `roles.${key}`), enumerable: true, writable: false, configurable: false });
93
+ RECEIVED_ROLES.add(Object.freeze(out));
94
+ return out;
95
+ }
81
96
  export function resolveModel(ref, models, seat = "model") {
82
97
  return modelOfBinding(ref, models, seat, "a model is named by a catalog model name or a Model object");
83
98
  }
@@ -105,7 +120,7 @@ export function expandTiers(models, tiers) {
105
120
  const b = Object.hasOwn(tiers, name) ? tiers[name] : undefined;
106
121
  if (b === undefined)
107
122
  return undefined;
108
- return modelOfBinding(b, models, `tiers.${name}`, "a tier binds a catalog model name or a Model object");
123
+ return modelOfBinding(b, models, `tiers.${name}`, TIER_BINDS);
109
124
  };
110
125
  const ownKey = (k) => models !== undefined && Object.hasOwn(models, k) && Boolean(models[k]);
111
126
  const landing = (t, self) => {
@@ -160,6 +175,38 @@ export function expandTiers(models, tiers) {
160
175
  }
161
176
  return out;
162
177
  }
178
+ const RECEIVED_CATALOGS = new WeakSet();
179
+ export function isReceivedCatalog(models) {
180
+ return models !== undefined && RECEIVED_CATALOGS.has(models);
181
+ }
182
+ export function catalogOfDeps(deps) {
183
+ return isReceivedCatalog(deps.models) ? deps.models : receiveModelCatalog(deps.models, deps.tiers, "RunnerDeps").models;
184
+ }
185
+ export function receiveModelCatalog(models, tiers, field) {
186
+ let held;
187
+ if (models !== undefined && models !== null) {
188
+ const given = receiveOwnProperties(models, { subject: `${field}.models`, unit: "entry", moment: "when the catalog is received" });
189
+ held = {};
190
+ for (const key of Object.keys(given)) {
191
+ const m = given[key];
192
+ Object.defineProperty(held, key, { value: m ? receiveModel(m, `${field}.models.${key}`, `${bindingShown(key)} (a catalog entry)`) : m, enumerable: true, writable: true, configurable: true });
193
+ }
194
+ }
195
+ let bindings;
196
+ if (tiers !== undefined && tiers !== null) {
197
+ const given = receiveOwnProperties(tiers, { subject: `${field}.tiers`, unit: "binding", moment: "when the catalog is received" });
198
+ bindings = {};
199
+ for (const name of Object.keys(given)) {
200
+ const b = given[name];
201
+ Object.defineProperty(bindings, name, { value: b === undefined || typeof b === "string" ? b : modelObjectAt(b, `tiers.${name}`, TIER_BINDS), enumerable: true, writable: false, configurable: false });
202
+ }
203
+ Object.freeze(bindings);
204
+ }
205
+ const expanded = bindings !== undefined && Object.keys(bindings).length > 0 ? expandTiers(held, bindings) : held;
206
+ if (expanded !== undefined)
207
+ RECEIVED_CATALOGS.add(Object.freeze(expanded));
208
+ return { ...(expanded !== undefined ? { models: expanded } : {}), ...(bindings !== undefined ? { tiers: bindings } : {}) };
209
+ }
163
210
  export function tierAliasVia(word, models) {
164
211
  const via = models?.[TIER_ALIAS_VIA];
165
212
  return via?.get(word) ?? [];
@@ -193,10 +240,7 @@ function roleTierModel(role, models) {
193
240
  if (!models || !models[TIERS_ACTIVE])
194
241
  return undefined;
195
242
  const tier = ROLE_TIER_DEFAULTS[role];
196
- const m = tier !== undefined ? models[tier] : undefined;
197
- if (m)
198
- assertModelObject(m, `tiers.${String(tier)}`, "the catalog entry the tier word names");
199
- return m;
243
+ return tier !== undefined ? catalogModel(tier, models, `tiers.${tier}`, "the catalog entry the tier word names") : undefined;
200
244
  }
201
245
  const FALLBACK = {
202
246
  default: [],
@@ -216,21 +260,21 @@ function specParts(s, seat = "a role seat") {
216
260
  if (!isBindingObject(s)) {
217
261
  throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${bindingShown(s)}, not a model reference — a role binds a catalog model name, a Model object or a { model, select, thinking, systemPrompt } record.`);
218
262
  }
219
- if (isModelShaped(s)) {
263
+ if (isModelSnapshot(s)) {
220
264
  return { model: s };
221
265
  }
222
266
  const cfg = s;
223
267
  return { model: cfg.model, select: cfg.select, thinking: cfg.thinking, promptRole: readPromptRole(`${seat}.promptRole`, cfg.promptRole), systemPrompt: cfg.systemPrompt };
224
268
  }
225
269
  export function roleSpecNamesModel(spec) {
226
- const parts = specParts(spec);
270
+ const parts = specParts(receiveRoleSpec(spec, "a role seat"));
227
271
  return parts.model !== undefined || parts.select !== undefined;
228
272
  }
229
273
  function toConfig(s) {
230
274
  if (s === undefined) {
231
275
  return undefined;
232
276
  }
233
- if (typeof s === "string" || isModelShaped(s)) {
277
+ if (typeof s === "string" || isModelSnapshot(s)) {
234
278
  return { model: s };
235
279
  }
236
280
  return s;
@@ -259,18 +303,20 @@ function assertKnownRole(word, field, ofKey = false) {
259
303
  throw modelBindingRefusal(field, "unknown_role_word", `${ofKey ? `${field} key` : field} names the model role ${shown}, which is not one of ${MODEL_ROLES.join(" / ")} — a word outside the vocabulary binds nothing and resolves nothing; bind the model on one of these roles, or name it on TaskSpec.model`);
260
304
  }
261
305
  export function screenRoleMap(roles, field) {
262
- for (const key of Object.keys(roles ?? {}))
306
+ const received = receiveRoleMap(roles, field);
307
+ for (const key of Object.keys(received ?? {}))
263
308
  assertKnownRole(key, field, true);
264
- for (const [key, value] of Object.entries(roles ?? {})) {
309
+ for (const [key, value] of Object.entries(received ?? {})) {
265
310
  const seat = `roles.${key}`;
266
311
  const named = specParts(value, seat).model;
267
- if (named !== undefined)
268
- assertModelBindingShape(named, roleModelSeat(named, seat), ROLE_BINDS);
312
+ if (named !== undefined && typeof named !== "string")
313
+ modelObjectAt(named, roleModelSeat(named, seat), ROLE_BINDS);
269
314
  }
315
+ return received;
270
316
  }
271
- function mergeRoles(base, over) {
272
- screenRoleMap(base, "RunnerDeps.roles");
273
- screenRoleMap(over, "TaskSpec.roles");
317
+ function mergeRoles(deployment, task) {
318
+ const base = screenRoleMap(deployment, "RunnerDeps.roles");
319
+ const over = screenRoleMap(task, "TaskSpec.roles");
274
320
  const out = { ...base };
275
321
  for (const role of Object.keys(over ?? {})) {
276
322
  out[role] = mergeRoleSpec(base?.[role], over?.[role]);
@@ -286,19 +332,19 @@ function partsModel(parts, models, seat = "a role seat") {
286
332
  if (needs != null && !Array.isArray(needs)) {
287
333
  throw modelBindingRefusal(`${seat}.select`, "not_a_model_ref", `${seat}.select.needs is ${bindingShown(needs)}, not a list of capabilities (vision / reasoning).`);
288
334
  }
289
- const held = models != null && typeof models === "object" ? Object.entries(models).filter(([, m]) => Boolean(m)) : [];
290
- for (const [key, m] of held)
291
- assertModelObject(m, `${seat}.select`, `the catalog entry ${bindingShown(key)} the criteria read`);
292
- const picked = selectModel(held.map(([, m]) => m), parts.select);
293
- if (picked !== undefined)
294
- assertModelObject(picked, `${seat}.select`, "the catalog entry the criteria pick");
295
- return picked;
335
+ const held = [];
336
+ for (const key of models != null && typeof models === "object" ? Object.keys(models) : []) {
337
+ const m = catalogModel(key, models, `${seat}.select`, `the catalog entry ${bindingShown(key)} the criteria read`);
338
+ if (m !== undefined)
339
+ held.push(m);
340
+ }
341
+ return selectModel(held, parts.select);
296
342
  }
297
343
  return undefined;
298
344
  }
299
345
  export function unheldSeatWord(spec, models) {
300
346
  const named = typeof spec === "string" ? spec : isBindingObject(spec) && !("id" in spec && "api" in spec) ? spec.model : undefined;
301
- return typeof named === "string" && catalogModel(named, models) === undefined ? named : undefined;
347
+ return typeof named === "string" && catalogEntry(named, models) === undefined ? named : undefined;
302
348
  }
303
349
  const STRICT_SEATS = new Set(["default", "classifier"]);
304
350
  function seatRead(parts, models, seat, role) {
@@ -342,10 +388,12 @@ export function presetRoleBaseOf(spec, deps) {
342
388
  }
343
389
  export function resolveTaskModel(spec, deps) {
344
390
  const { start, merged, startParts } = chainHead(spec, deps);
345
- if (spec.model !== undefined) {
391
+ const written = spec.model;
392
+ if (written !== undefined) {
393
+ const model = resolveModel(written, deps.models, "TaskSpec.model");
346
394
  return {
347
- model: resolveModel(spec.model, deps.models, "TaskSpec.model"),
348
- modelRef: spec.model,
395
+ model,
396
+ modelRef: typeof written === "string" ? written : model,
349
397
  thinking: spec.thinking ?? startParts.thinking,
350
398
  promptRole: startParts.promptRole,
351
399
  systemPrompt: startParts.systemPrompt,
@@ -366,7 +414,7 @@ export function resolveTaskModel(spec, deps) {
366
414
  }
367
415
  if (firstUnheld !== undefined)
368
416
  throw unheldSeatRefusal(firstUnheld);
369
- throw new Error(`No model for role "${start}": set TaskSpec.model, or configure RunnerDeps.roles / TaskSpec.roles["${start}"] (or a "default" role). A "select" RoleSpec also fails here if no catalog model matches.`);
417
+ throw modelBindingRefusal(`roles.${start}`, "no_model_for_role", `No model for role "${start}": set TaskSpec.model, or configure RunnerDeps.roles / TaskSpec.roles["${start}"] (or a "default" role). A "select" RoleSpec also fails here if no catalog model matches.`);
370
418
  }
371
419
  export function roleModelIfSet(role, spec, deps) {
372
420
  const merged = mergeRoles(deps.roles, spec.roles);
@@ -17,6 +17,9 @@ import type { AssertAllKeysHandled } from "./ask-origin.js";
17
17
  * identity surface is indistinguishable from a real one downstream. Cloud sync and cloud tickets accept
18
18
  * ONLY the `principal` kind: syncing is an authenticated act, and a local-owner bucket has no cloud home
19
19
  * until it is adopted (`adoptFilePermissionRuleStore`).
20
+ *
21
+ * A memory layer's owner is read the same way: the identity-less owner is this `local-owner` arm, and its layer
22
+ * keeps an opaque key, never a `user:` key (`@contract memory.identity_absence.opaque_key`, scope-contract.ts).
20
23
  */
21
24
  export type RuleOwner = {
22
25
  kind: "principal";
@@ -48,7 +48,6 @@ export interface Stats {
48
48
  * only when ≥1 engaged; flows straight through to `TaskResult.stats.mechanisms` via the
49
49
  * public-stats spread. */
50
50
  mechanisms?: {
51
- finalVerifyInjected?: true;
52
51
  finalVerifyInjections?: number;
53
52
  attachmentsInjected?: number;
54
53
  repetitionCuts?: number;
@@ -90,10 +89,6 @@ export interface Stats {
90
89
  llmRootMicroUsd: number;
91
90
  /** Delegated sub-agent (nested) LLM cost (micro-USD) = `stats.nested?.costMicroUsd ?? 0`. */
92
91
  nestedSubagentMicroUsd: number;
93
- /** Post-task memory-consolidation LLM cost (micro-USD) = `stats.memory?.costMicroUsd ?? 0`. Permanently
94
- * 0: the runner-integrated consolidation pass is retired (the public `TaskStats` doc is the one home
95
- * for what would fill it again). */
96
- memoryConsolidationMicroUsd: number;
97
92
  /** Within-task compaction LLM cost (micro-USD) = the running `compactionMicroUsd` accumulator (the
98
93
  * category Framing-4 missed). This IS part of `costMicroUsd`, so it is subtracted from `llmRoot`. */
99
94
  compactionMicroUsd: number;
@@ -159,7 +159,6 @@ export function assembleResult(spec, sessionId, final, stats, flags) {
159
159
  stats.costBreakdown = {
160
160
  llmRootMicroUsd: Math.max(0, stats.costMicroUsd - compactionMicroUsd),
161
161
  nestedSubagentMicroUsd,
162
- memoryConsolidationMicroUsd: 0,
163
162
  compactionMicroUsd,
164
163
  ...(stats.sideCallMicroUsd !== undefined ? { sideCallMicroUsd: stats.sideCallMicroUsd } : {}),
165
164
  };