@sema-agent/core 7.60.0 → 7.62.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 (560) hide show
  1. package/CHANGELOG.md +917 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-transcript-tool.d.ts +2 -2
  4. package/dist/agents/agent-transcript-tool.js +1 -1
  5. package/dist/agents/cascade.d.ts +71 -12
  6. package/dist/agents/cascade.js +61 -21
  7. package/dist/agents/composition-allowance.d.ts +53 -0
  8. package/dist/agents/composition-allowance.js +49 -0
  9. package/dist/agents/composition-placement.d.ts +29 -0
  10. package/dist/agents/composition-placement.js +24 -0
  11. package/dist/agents/cumulative-stats.d.ts +4 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/inherited-tool-pool.d.ts +5 -3
  14. package/dist/agents/inherited-tool-pool.js +2 -2
  15. package/dist/agents/list-agents-tool.d.ts +1 -1
  16. package/dist/agents/peer-held-queue.d.ts +27 -4
  17. package/dist/agents/peer-held-queue.js +81 -36
  18. package/dist/agents/peer-notice-route.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.js +4 -3
  20. package/dist/agents/peer-notices.d.ts +4 -4
  21. package/dist/agents/peer-notices.js +8 -4
  22. package/dist/agents/peer-session-drain.d.ts +8 -1
  23. package/dist/agents/peer-session-drain.js +49 -10
  24. package/dist/agents/repair-loop.js +16 -6
  25. package/dist/agents/retain-ledger.js +3 -1
  26. package/dist/agents/roster-store.d.ts +1 -1
  27. package/dist/agents/roster-store.js +7 -4
  28. package/dist/agents/send-message-tool.d.ts +8 -10
  29. package/dist/agents/send-message-tool.js +43 -23
  30. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  31. package/dist/agents/subagent-completion-gate.js +62 -0
  32. package/dist/agents/subagent-steps.d.ts +7 -6
  33. package/dist/agents/subagent.d.ts +36 -41
  34. package/dist/agents/subagent.js +245 -200
  35. package/dist/agents/suspend-guard.d.ts +47 -16
  36. package/dist/agents/suspend-guard.js +13 -4
  37. package/dist/agents/verify.d.ts +41 -14
  38. package/dist/agents/verify.js +41 -30
  39. package/dist/brain/anthropic.js +1 -0
  40. package/dist/brain/errors.d.ts +7 -1
  41. package/dist/brain/errors.js +6 -0
  42. package/dist/brain/failover.js +2 -1
  43. package/dist/brain/open-responses.js +1 -0
  44. package/dist/brain/openai.js +1 -0
  45. package/dist/brain/provider-dialect.d.ts +10 -0
  46. package/dist/brain/provider-dialect.js +13 -2
  47. package/dist/brain/stream-engine.d.ts +3 -0
  48. package/dist/brain/stream-engine.js +4 -0
  49. package/dist/core/agent-state.d.ts +1 -1
  50. package/dist/core/allow-entry.d.ts +59 -23
  51. package/dist/core/allow-entry.js +131 -38
  52. package/dist/core/ask-origin.d.ts +79 -0
  53. package/dist/core/ask-origin.js +76 -0
  54. package/dist/core/ask-question.d.ts +19 -13
  55. package/dist/core/ask-question.js +8 -2
  56. package/dist/core/auto-compaction.d.ts +2 -0
  57. package/dist/core/auto-compaction.js +2 -1
  58. package/dist/core/auto-mode.js +3 -5
  59. package/dist/core/background-agent-store.d.ts +7 -5
  60. package/dist/core/background-agent-store.js +12 -11
  61. package/dist/core/checkpoint-features.d.ts +722 -0
  62. package/dist/core/checkpoint-features.js +98 -0
  63. package/dist/core/checkpoint-requirements.d.ts +33 -5
  64. package/dist/core/checkpoint-requirements.js +18 -5
  65. package/dist/core/checkpoint-row-verdict.d.ts +99 -0
  66. package/dist/core/checkpoint-row-verdict.js +225 -0
  67. package/dist/core/checkpoint-store.d.ts +107 -738
  68. package/dist/core/checkpoint-store.js +45 -143
  69. package/dist/core/child-clamp-seats.d.ts +3 -2
  70. package/dist/core/child-clamp-seats.js +4 -3
  71. package/dist/core/closest-name.d.ts +13 -0
  72. package/dist/core/closest-name.js +35 -0
  73. package/dist/core/context-settings.js +3 -5
  74. package/dist/core/cross-boundary-taint.d.ts +1 -1
  75. package/dist/core/decision-receipt.d.ts +14 -1
  76. package/dist/core/decision-receipt.js +6 -3
  77. package/dist/core/delegation-frames.d.ts +13 -9
  78. package/dist/core/effective-path-target.js +2 -3
  79. package/dist/core/engine-attestation.d.ts +11 -1
  80. package/dist/core/engine-attestation.js +2 -0
  81. package/dist/core/engine-notice.d.ts +68 -21
  82. package/dist/core/engine-notice.js +9 -2
  83. package/dist/core/file-history-retention.d.ts +8 -0
  84. package/dist/core/file-history-retention.js +14 -11
  85. package/dist/core/file-history-store.d.ts +31 -1
  86. package/dist/core/file-history-store.js +31 -2
  87. package/dist/core/frame-settlement.d.ts +10 -0
  88. package/dist/core/frame-settlement.js +6 -1
  89. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  90. package/dist/core/fs-write-gate-policy.js +8 -7
  91. package/dist/core/gate-fold.js +4 -3
  92. package/dist/core/gate-lanes.js +7 -4
  93. package/dist/core/gate-outcome.d.ts +40 -1
  94. package/dist/core/gate-outcome.js +10 -0
  95. package/dist/core/git-worktree-env.d.ts +7 -3
  96. package/dist/core/git-worktree-env.js +16 -13
  97. package/dist/core/governance-codes.d.ts +14 -4
  98. package/dist/core/governance-codes.js +19 -4
  99. package/dist/core/hooks.d.ts +25 -4
  100. package/dist/core/hooks.js +11 -4
  101. package/dist/core/host-floor.js +3 -5
  102. package/dist/core/human-input-projection.d.ts +1 -0
  103. package/dist/core/human-input-projection.js +3 -0
  104. package/dist/core/image-admission.d.ts +47 -7
  105. package/dist/core/image-admission.js +35 -4
  106. package/dist/core/input-author.d.ts +36 -0
  107. package/dist/core/input-author.js +39 -0
  108. package/dist/core/leg-identity.d.ts +62 -0
  109. package/dist/core/leg-identity.js +18 -0
  110. package/dist/core/locked-config.d.ts +4 -3
  111. package/dist/core/locked-config.js +5 -3
  112. package/dist/core/lsp.d.ts +5 -3
  113. package/dist/core/lsp.js +3 -2
  114. package/dist/core/mailbox-store.d.ts +85 -10
  115. package/dist/core/mailbox-store.js +31 -10
  116. package/dist/core/mcp-connection-pool.d.ts +6 -20
  117. package/dist/core/mcp-connection-pool.js +10 -28
  118. package/dist/core/mcp-failure.d.ts +76 -15
  119. package/dist/core/mcp-failure.js +60 -33
  120. package/dist/core/mcp-host-seat.d.ts +92 -53
  121. package/dist/core/mcp-host-seat.js +225 -46
  122. package/dist/core/mcp-probe.js +2 -2
  123. package/dist/core/mcp-server-link.d.ts +18 -6
  124. package/dist/core/mcp-server-link.js +19 -4
  125. package/dist/core/mcp-server-spec.d.ts +2 -1
  126. package/dist/core/mcp-session-end.d.ts +1 -2
  127. package/dist/core/mcp-session-end.js +1 -1
  128. package/dist/core/mcp.d.ts +6 -49
  129. package/dist/core/mcp.js +115 -111
  130. package/dist/core/media-byte-cap.d.ts +21 -46
  131. package/dist/core/media-byte-cap.js +55 -55
  132. package/dist/core/member-group.d.ts +7 -0
  133. package/dist/core/member-group.js +35 -0
  134. package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
  135. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  136. package/dist/core/memory-engine/consolidation.js +7 -1
  137. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  138. package/dist/core/memory-engine/dual-root.js +59 -11
  139. package/dist/core/memory-engine/engine.js +27 -24
  140. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  141. package/dist/core/memory-engine/file-backend.js +35 -15
  142. package/dist/core/memory-engine/layout.d.ts +3 -0
  143. package/dist/core/memory-engine/layout.js +13 -3
  144. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  145. package/dist/core/memory-engine/memory-deployment.js +182 -0
  146. package/dist/core/memory-engine/sync-client.d.ts +39 -18
  147. package/dist/core/memory-engine/sync-client.js +72 -14
  148. package/dist/core/memory-engine/sync-report.d.ts +7 -4
  149. package/dist/core/memory-engine/sync.d.ts +9 -1
  150. package/dist/core/memory-vector.d.ts +1 -1
  151. package/dist/core/memory.d.ts +10 -10
  152. package/dist/core/mode-policy.d.ts +8 -8
  153. package/dist/core/mode-policy.js +8 -6
  154. package/dist/core/mods/agent-stations.d.ts +39 -4
  155. package/dist/core/mods/agent-stations.js +59 -10
  156. package/dist/core/mods/classic-events.d.ts +9 -1
  157. package/dist/core/mods/dollar.d.ts +94 -1
  158. package/dist/core/mods/dollar.js +13 -1
  159. package/dist/core/mods/extension-call.d.ts +15 -1
  160. package/dist/core/mods/extension-call.js +7 -2
  161. package/dist/core/mods/kernel/dispatch.d.ts +4 -3
  162. package/dist/core/mods/kernel/dispatch.js +4 -4
  163. package/dist/core/mods/kernel/events.d.ts +14 -3
  164. package/dist/core/mods/kernel/events.js +18 -15
  165. package/dist/core/mods/kernel/registration.d.ts +3 -0
  166. package/dist/core/mods/kernel/registration.js +5 -0
  167. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  168. package/dist/core/mods/kernel/site-rules.js +10 -2
  169. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  170. package/dist/core/mods/lifecycle-stations.js +44 -9
  171. package/dist/core/mods/session-append.d.ts +118 -0
  172. package/dist/core/mods/session-append.js +318 -0
  173. package/dist/core/mods/session-compact.d.ts +48 -0
  174. package/dist/core/mods/session-compact.js +194 -0
  175. package/dist/core/mods/session-receive.d.ts +93 -0
  176. package/dist/core/mods/session-receive.js +138 -0
  177. package/dist/core/mods/session-send.d.ts +72 -0
  178. package/dist/core/mods/session-send.js +88 -0
  179. package/dist/core/mods/stations.d.ts +88 -21
  180. package/dist/core/mods/stations.js +149 -11
  181. package/dist/core/mods/tool-call.d.ts +2 -0
  182. package/dist/core/mods/tool-call.js +4 -4
  183. package/dist/core/output-style.js +3 -4
  184. package/dist/core/own-property-receipt.d.ts +68 -2
  185. package/dist/core/own-property-receipt.js +45 -2
  186. package/dist/core/park-selfcheck.js +4 -2
  187. package/dist/core/path-identity.d.ts +11 -0
  188. package/dist/core/path-identity.js +4 -0
  189. package/dist/core/path-rule-binding.d.ts +3 -1
  190. package/dist/core/path-rule-binding.js +3 -1
  191. package/dist/core/peer-seat.d.ts +3 -3
  192. package/dist/core/peer-seat.js +20 -8
  193. package/dist/core/permission-rule-consent.d.ts +21 -5
  194. package/dist/core/permission-rule-consent.js +21 -1
  195. package/dist/core/permission-rule-model.d.ts +34 -11
  196. package/dist/core/permission-rule-model.js +47 -10
  197. package/dist/core/permission-rule-org.d.ts +1 -1
  198. package/dist/core/permission-rule-provider.js +4 -1
  199. package/dist/core/permission-rules.d.ts +4 -0
  200. package/dist/core/permission-rules.js +11 -16
  201. package/dist/core/read-root-candidate.js +1 -1
  202. package/dist/core/remote-env.d.ts +74 -26
  203. package/dist/core/remote-env.js +20 -0
  204. package/dist/core/resume-startup-cause.d.ts +5 -4
  205. package/dist/core/retention-policy.d.ts +24 -23
  206. package/dist/core/retention-policy.js +36 -2
  207. package/dist/core/retention.d.ts +4 -1
  208. package/dist/core/retired-keys.d.ts +4 -4
  209. package/dist/core/row-admission.d.ts +10 -0
  210. package/dist/core/row-admission.js +5 -0
  211. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  212. package/dist/core/runner/advisor-instructions.js +2 -1
  213. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  214. package/dist/core/runner/assemble-result.d.ts +13 -3
  215. package/dist/core/runner/assemble-result.js +12 -7
  216. package/dist/core/runner/caller-roster.d.ts +12 -9
  217. package/dist/core/runner/caller-roster.js +5 -2
  218. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  219. package/dist/core/runner/checkpoint-scope.js +21 -0
  220. package/dist/core/runner/compact-session.js +18 -3
  221. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  222. package/dist/core/runner/compaction-restate.d.ts +2 -2
  223. package/dist/core/runner/compaction-restate.js +4 -3
  224. package/dist/core/runner/construction-doors.d.ts +2 -2
  225. package/dist/core/runner/construction-doors.js +2 -2
  226. package/dist/core/runner/contracts.d.ts +116 -34
  227. package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
  228. package/dist/core/runner/decide-continuation.d.ts +4 -2
  229. package/dist/core/runner/decide-continuation.js +7 -4
  230. package/dist/core/runner/delegation-owner.d.ts +43 -0
  231. package/dist/core/runner/delegation-owner.js +59 -0
  232. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  233. package/dist/core/runner/denial-limit-arms.js +17 -10
  234. package/dist/core/runner/expire-settle.d.ts +44 -0
  235. package/dist/core/runner/expire-settle.js +55 -0
  236. package/dist/core/runner/git-status-frame.d.ts +3 -3
  237. package/dist/core/runner/git-status-frame.js +2 -1
  238. package/dist/core/runner/halt-attribution.d.ts +2 -1
  239. package/dist/core/runner/halt-attribution.js +2 -1
  240. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  241. package/dist/core/runner/lineage-reroot-view.js +108 -0
  242. package/dist/core/runner/local-claims.d.ts +17 -0
  243. package/dist/core/runner/local-claims.js +18 -0
  244. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  245. package/dist/core/runner/media-removed-seat.js +88 -0
  246. package/dist/core/runner/park-commit.d.ts +2 -2
  247. package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
  248. package/dist/core/runner/permission-rule-lanes.js +28 -9
  249. package/dist/core/runner/person-path-rows.d.ts +15 -0
  250. package/dist/core/runner/person-path-rows.js +27 -4
  251. package/dist/core/runner/placement-fence.d.ts +26 -0
  252. package/dist/core/runner/placement-fence.js +38 -0
  253. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  254. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  255. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  256. package/dist/core/runner/prepare-ask-lane.js +4 -4
  257. package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
  258. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  259. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
  260. package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
  261. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  262. package/dist/core/runner/prepare-config-doors.js +19 -21
  263. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  264. package/dist/core/runner/prepare-context-lane.js +13 -13
  265. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
  266. package/dist/core/runner/prepare-delegation-surface.js +4 -5
  267. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  268. package/dist/core/runner/prepare-execution-env.js +7 -4
  269. package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
  270. package/dist/core/runner/prepare-gate-stations.js +6 -4
  271. package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
  272. package/dist/core/runner/prepare-hands-readface.js +32 -11
  273. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
  274. package/dist/core/runner/prepare-inherited-gate.js +10 -3
  275. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  276. package/dist/core/runner/prepare-lsp.js +2 -2
  277. package/dist/core/runner/prepare-park-ask.d.ts +5 -2
  278. package/dist/core/runner/prepare-park-ask.js +4 -5
  279. package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
  280. package/dist/core/runner/prepare-policy-chain.js +16 -25
  281. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  282. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
  283. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  284. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  285. package/dist/core/runner/prepare-question-face.js +2 -2
  286. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  287. package/dist/core/runner/prepare-run-refs.js +2 -2
  288. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
  289. package/dist/core/runner/prepare-suspend-saga.js +17 -7
  290. package/dist/core/runner/prepare-task.d.ts +1 -1
  291. package/dist/core/runner/prepare-task.js +61 -30
  292. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  293. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  294. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
  295. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  296. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  297. package/dist/core/runner/prepare-workspace-restore.js +10 -6
  298. package/dist/core/runner/read-root-grant.d.ts +1 -1
  299. package/dist/core/runner/read-root-grant.js +2 -1
  300. package/dist/core/runner/resume-admission.d.ts +8 -6
  301. package/dist/core/runner/resume-admission.js +23 -6
  302. package/dist/core/runner/resume-apply.d.ts +4 -0
  303. package/dist/core/runner/resume-apply.js +14 -5
  304. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  305. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  306. package/dist/core/runner/resume-claim.d.ts +8 -3
  307. package/dist/core/runner/resume-claim.js +28 -12
  308. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  309. package/dist/core/runner/resume-internals-and-config.js +10 -1
  310. package/dist/core/runner/resume-preflight.d.ts +3 -2
  311. package/dist/core/runner/resume-preflight.js +13 -26
  312. package/dist/core/runner/retired-runner-deps.js +2 -0
  313. package/dist/core/runner/run-git-lane.d.ts +2 -0
  314. package/dist/core/runner/run-git-lane.js +6 -2
  315. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  316. package/dist/core/runner/run-harness-handlers.js +5 -4
  317. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  318. package/dist/core/runner/run-identity-wiring.js +14 -5
  319. package/dist/core/runner/run-leg.d.ts +3 -3
  320. package/dist/core/runner/run-leg.js +64 -36
  321. package/dist/core/runner/run-notification-lane.js +20 -2
  322. package/dist/core/runner/run-recovery-lanes.js +3 -2
  323. package/dist/core/runner/run-settle-and-teardown.js +12 -9
  324. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  325. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  326. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  327. package/dist/core/runner/run-terminal-adoption.js +26 -17
  328. package/dist/core/runner/run-turn-boundary.js +34 -18
  329. package/dist/core/runner/runtask.d.ts +18 -3
  330. package/dist/core/runner/runtask.js +33 -17
  331. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  332. package/dist/core/runner/session-rule-policy.js +6 -1
  333. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  334. package/dist/core/runner/steering-preview.d.ts +9 -0
  335. package/dist/core/runner/steering-preview.js +5 -0
  336. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  337. package/dist/core/runner/stream-halt-verbs.js +4 -3
  338. package/dist/core/runner/stream-reap.d.ts +7 -6
  339. package/dist/core/runner/stream-reap.js +13 -16
  340. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  341. package/dist/core/runner/stream-settle-backstop.js +5 -3
  342. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  343. package/dist/core/runner/stream-steer-verb.js +16 -7
  344. package/dist/core/runner/terminal-account.d.ts +11 -1
  345. package/dist/core/runner/terminal-account.js +20 -0
  346. package/dist/core/runner/terminal-projection.d.ts +8 -2
  347. package/dist/core/runner/terminal-projection.js +2 -2
  348. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  349. package/dist/core/runner/tool-disclosure.js +5 -2
  350. package/dist/core/runner/tool-end-body.d.ts +3 -3
  351. package/dist/core/runner/tool-end-body.js +1 -1
  352. package/dist/core/runner/tool-face-overlay.js +2 -0
  353. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  354. package/dist/core/runner/tool-output-projection.js +7 -6
  355. package/dist/core/runner/tool-table-view.d.ts +56 -0
  356. package/dist/core/runner/tool-table-view.js +51 -0
  357. package/dist/core/runner/turn-attachments.d.ts +8 -2
  358. package/dist/core/runner/turn-attachments.js +2 -2
  359. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  360. package/dist/core/runner/void-verifier-pause.js +41 -0
  361. package/dist/core/runner-deps.d.ts +26 -27
  362. package/dist/core/secret-env.d.ts +19 -16
  363. package/dist/core/secret-env.js +45 -27
  364. package/dist/core/session-log-transfer.js +9 -10
  365. package/dist/core/session-policy-store.d.ts +1 -1
  366. package/dist/core/session-policy-store.js +5 -2
  367. package/dist/core/session-reconcile.d.ts +3 -2
  368. package/dist/core/session-reconcile.js +7 -4
  369. package/dist/core/session-store.d.ts +3 -1
  370. package/dist/core/session-store.js +10 -8
  371. package/dist/core/session.d.ts +16 -5
  372. package/dist/core/shell-confinement.d.ts +37 -0
  373. package/dist/core/shell-confinement.js +56 -0
  374. package/dist/core/skill-grant.js +1 -1
  375. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
  376. package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
  377. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  378. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  379. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  380. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  381. package/dist/core/store-contracts/session-store-contract.js +22 -8
  382. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  383. package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
  384. package/dist/core/task-event.d.ts +24 -9
  385. package/dist/core/task-limits.d.ts +5 -0
  386. package/dist/core/task-notification.d.ts +89 -12
  387. package/dist/core/task-notification.js +89 -14
  388. package/dist/core/task-registry-agent.d.ts +32 -50
  389. package/dist/core/task-registry-agent.js +36 -56
  390. package/dist/core/task-registry-monitor.d.ts +1 -1
  391. package/dist/core/task-registry-monitor.js +15 -60
  392. package/dist/core/task-registry-shared.d.ts +22 -112
  393. package/dist/core/task-registry-shared.js +3 -41
  394. package/dist/core/task-registry-workflow.js +5 -21
  395. package/dist/core/task-registry.d.ts +32 -62
  396. package/dist/core/task-registry.js +30 -110
  397. package/dist/core/task-result.d.ts +29 -12
  398. package/dist/core/task-spec-members.d.ts +39 -0
  399. package/dist/core/task-spec-members.js +92 -0
  400. package/dist/core/task-spec.d.ts +11 -11
  401. package/dist/core/task-tool-shape.d.ts +7 -57
  402. package/dist/core/task-tool-shape.js +7 -66
  403. package/dist/core/terminal-cause.d.ts +36 -6
  404. package/dist/core/terminal-cause.js +1 -0
  405. package/dist/core/tool-catalog-entries.js +2 -5
  406. package/dist/core/tool-check-reading.js +16 -10
  407. package/dist/core/tool-conformance.js +1 -2
  408. package/dist/core/tool-errors.d.ts +6 -3
  409. package/dist/core/tool-errors.js +2 -0
  410. package/dist/core/tool-face-reader.js +3 -2
  411. package/dist/core/tool-face.d.ts +8 -5
  412. package/dist/core/tool-face.js +1 -1
  413. package/dist/core/tool-name-aliases.d.ts +5 -29
  414. package/dist/core/tool-name-aliases.js +9 -5
  415. package/dist/core/tool-name-readings.d.ts +14 -3
  416. package/dist/core/tool-name-readings.js +2 -0
  417. package/dist/core/tool-policy.d.ts +109 -18
  418. package/dist/core/tool-policy.js +84 -14
  419. package/dist/core/tool-result-store.d.ts +23 -0
  420. package/dist/core/tool-result-store.js +3 -2
  421. package/dist/core/tool-roster.d.ts +4 -4
  422. package/dist/core/tool-spec.d.ts +23 -6
  423. package/dist/core/trace.d.ts +18 -1
  424. package/dist/core/types.d.ts +1 -1
  425. package/dist/core/types.js +1 -1
  426. package/dist/core/user-attachment.js +26 -21
  427. package/dist/core/workflow-journal-store.d.ts +1 -1
  428. package/dist/core/workflow-run-store.d.ts +2 -0
  429. package/dist/core/workflow-run-store.js +6 -5
  430. package/dist/core/workflow-settled-run.d.ts +5 -0
  431. package/dist/core/workflow-settled-run.js +7 -0
  432. package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
  433. package/dist/engine/execution-env/node-execution-env.js +221 -22
  434. package/dist/engine/harness/agent-harness.d.ts +65 -18
  435. package/dist/engine/harness/agent-harness.js +90 -23
  436. package/dist/engine/harness/messages.d.ts +4 -3
  437. package/dist/engine/harness/messages.js +2 -2
  438. package/dist/engine/harness/types.d.ts +52 -7
  439. package/dist/engine/llm/media-removed.d.ts +14 -0
  440. package/dist/engine/llm/media-removed.js +9 -0
  441. package/dist/engine/llm/rejected-images.d.ts +35 -25
  442. package/dist/engine/llm/rejected-images.js +59 -10
  443. package/dist/engine/llm/types.d.ts +24 -3
  444. package/dist/engine/llm/types.js +7 -3
  445. package/dist/engine/loop/agent-loop.d.ts +6 -1
  446. package/dist/engine/loop/agent-loop.js +20 -11
  447. package/dist/engine/loop/types.d.ts +12 -3
  448. package/dist/engine/session/import-validate.js +7 -0
  449. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  450. package/dist/engine/session/parent-chain-guard.js +1 -1
  451. package/dist/engine/session/path-to-root.d.ts +18 -3
  452. package/dist/engine/session/path-to-root.js +15 -1
  453. package/dist/engine/session/repo-utils.d.ts +12 -1
  454. package/dist/engine/session/repo-utils.js +41 -0
  455. package/dist/engine/session/session.js +1 -1
  456. package/dist/engine/session/storage-base.d.ts +20 -0
  457. package/dist/engine/session/storage-base.js +28 -9
  458. package/dist/fixtures/index.d.ts +7 -5
  459. package/dist/fixtures/index.js +5 -3
  460. package/dist/index.d.ts +29 -18
  461. package/dist/index.js +19 -11
  462. package/dist/internal/harness-types.d.ts +2 -0
  463. package/dist/internal/harness.d.ts +4 -3
  464. package/dist/internal/harness.js +3 -2
  465. package/dist/internal/llm.d.ts +2 -1
  466. package/dist/internal/llm.js +1 -0
  467. package/dist/orchestration/goal.d.ts +6 -2
  468. package/dist/orchestration/goal.js +6 -3
  469. package/dist/orchestration/run-workflow-tool.d.ts +14 -17
  470. package/dist/orchestration/run-workflow-tool.js +43 -50
  471. package/dist/orchestration/workflow-types.d.ts +2 -2
  472. package/dist/orchestration/workflow.d.ts +7 -0
  473. package/dist/orchestration/workflow.js +10 -12
  474. package/dist/stores/file/background-agent-store.js +18 -15
  475. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  476. package/dist/stores/file/checkpoint-store.js +13 -9
  477. package/dist/stores/file/file-history-store.js +3 -2
  478. package/dist/stores/file/fs-atomic.d.ts +0 -22
  479. package/dist/stores/file/fs-atomic.js +0 -17
  480. package/dist/stores/file/index.d.ts +7 -12
  481. package/dist/stores/file/index.js +25 -12
  482. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  483. package/dist/stores/file/ledger-tuning.js +21 -0
  484. package/dist/stores/file/mailbox-store.js +42 -22
  485. package/dist/stores/file/memory-store.js +3 -2
  486. package/dist/stores/file/permission-rule-adopt.js +24 -21
  487. package/dist/stores/file/permission-rule-store.js +6 -3
  488. package/dist/stores/file/session-policy-store.js +3 -2
  489. package/dist/stores/file/session-store.d.ts +26 -7
  490. package/dist/stores/file/session-store.js +59 -35
  491. package/dist/stores/file/tool-result-store.d.ts +11 -0
  492. package/dist/stores/file/tool-result-store.js +57 -3
  493. package/dist/stores/file/usage-window-store.js +3 -2
  494. package/dist/stores/file/workflow-journal-store.d.ts +0 -2
  495. package/dist/stores/file/workflow-journal-store.js +3 -18
  496. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  497. package/dist/stores/file/workflow-run-store.js +15 -10
  498. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  499. package/dist/tools/fs/bash-program-position.js +7 -7
  500. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  501. package/dist/tools/fs/dead-cwd.js +4 -11
  502. package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
  503. package/dist/tools/fs/fs-bash-background-text.js +6 -0
  504. package/dist/tools/fs/fs-bash.d.ts +3 -18
  505. package/dist/tools/fs/fs-bash.js +37 -124
  506. package/dist/tools/fs/fs-pdf.js +8 -6
  507. package/dist/tools/fs/fs-read.js +2 -2
  508. package/dist/tools/fs/fs-shared.d.ts +28 -3
  509. package/dist/tools/fs/fs-shared.js +15 -0
  510. package/dist/tools/fs/index.d.ts +1 -1
  511. package/dist/tools/fs/index.js +4 -14
  512. package/dist/tools/fs/pdf.d.ts +4 -4
  513. package/dist/tools/fs/pdf.js +6 -6
  514. package/dist/tools/fs/read-deny-home.js +8 -1
  515. package/dist/tools/fs/read-deny.d.ts +26 -2
  516. package/dist/tools/fs/read-deny.js +9 -2
  517. package/dist/tools/fs/read-floor.d.ts +13 -5
  518. package/dist/tools/fs/read-floor.js +206 -2
  519. package/dist/tools/fs/removal-targets.js +2 -2
  520. package/dist/tools/fs/search.d.ts +3 -2
  521. package/dist/tools/fs/search.js +6 -6
  522. package/dist/tools/fs/shell-read-argv.d.ts +4 -2
  523. package/dist/tools/fs/shell-read-argv.js +14 -3
  524. package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
  525. package/dist/tools/fs/shell-read-bindings.js +148 -68
  526. package/dist/tools/fs/shell-read-check.js +20 -4
  527. package/dist/tools/fs/shell-read-establish.js +25 -9
  528. package/dist/tools/fs/shell-read-functions.js +2 -2
  529. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  530. package/dist/tools/fs/shell-read-identity.js +4 -2
  531. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  532. package/dist/tools/fs/shell-read-judge.js +1 -1
  533. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  534. package/dist/tools/fs/shell-read-object-path.js +119 -0
  535. package/dist/tools/fs/shell-read-plan.d.ts +8 -0
  536. package/dist/tools/fs/shell-read-plan.js +47 -30
  537. package/dist/tools/fs/shell-read-start.d.ts +66 -13
  538. package/dist/tools/fs/shell-read-start.js +89 -17
  539. package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
  540. package/dist/tools/fs/shell-read-workdir.js +31 -8
  541. package/dist/tools/monitor.d.ts +8 -7
  542. package/dist/tools/monitor.js +12 -10
  543. package/dist/tools/worktree.d.ts +5 -1
  544. package/dist/tools/worktree.js +20 -17
  545. package/package.json +6 -3
  546. package/test/export-surface.snapshot.json +112 -42
  547. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  548. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  549. package/wire-changes/core@7.61.0.json +4405 -0
  550. package/wire-changes/core@7.62.0.json +2181 -0
  551. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  552. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  553. package/wire-changes/primitives@7.61.0.json +30 -0
  554. package/wire-changes/primitives@7.62.0.json +30 -0
  555. package/dist/core/consolidate-scope.d.ts +0 -93
  556. package/dist/core/consolidate-scope.js +0 -98
  557. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  558. package/dist/core/runner/image-removed-seat.js +0 -19
  559. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  560. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -1,4 +1,6 @@
1
- import type { ExecutionEnv } from "../../internal/harness-types.js";
1
+ import type { AgentMessage, ExecutionEnv, ReadFloor } from "../../internal/harness-types.js";
2
+ import type { TaskAccess, TaskRegistry } from "../task-registry.js";
3
+ import type { SessionMeasureSeat } from "./lifecycle-stations.js";
2
4
  import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
3
5
  import type { CwdRef } from "../../tools/fs/fs-shared.js";
4
6
  import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
@@ -7,11 +9,11 @@ import type { ClassicEventMap, ClassicEventName } from "./classic-events.js";
7
9
  import type { PermissionMode } from "../ask-origin.js";
8
10
  import type { RunnerDeps } from "../runner-deps.js";
9
11
  import type { TaskSpec } from "../task-spec.js";
10
- import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
12
+ import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModEventName, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
11
13
  import { type SourcedOverlay } from "../../prompt-assembly/overlay.js";
12
14
  import type { BandId } from "../../prompt-assembly/catalog/schema.js";
13
15
  import type { ModParticipant } from "./kernel/dispatch.js";
14
- import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView } from "./dollar.js";
16
+ import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView, type SessionUsage, type SessionVersion } from "./dollar.js";
15
17
  import type { SkillSpec } from "../agent-definition.js";
16
18
  import { type SkillScopes } from "./spec-seats.js";
17
19
  /**
@@ -24,28 +26,30 @@ export declare const ENGINE_CORE_ANSWER: Readonly<Record<string, never>>;
24
26
  export declare function engineCore(): Readonly<Record<string, never>>;
25
27
  /** The leg's bus seat, as the stations read it. */
26
28
  export type LegModBus = Pick<ModBus, "hasHandlers" | "dispatch">;
27
- /**
28
- * The id a delegated leg's events carry as `agentId` (the leg's task id — the key its `task_progress` frames
29
- * and its parent's fleet row use). A top-level leg carries none.
30
- */
31
- export declare function agentIdOf(identity: HookInvocationIdentity | undefined): string | undefined;
29
+ /** Does a seat raise `event` — bound, and a handler hangs on it? Every station entry reads this first, synchronously. */
30
+ export declare function seatHears<B extends {
31
+ readonly bus: Pick<ModBus, "hasHandlers">;
32
+ }>(binding: B | undefined, event: ModEventName): binding is B;
33
+ /** The `detail` member of a notice a leg raises about itself: the leg's own task id, read from its prepare's one mint ({@link legTaskIdOf}), never from the host's declaration. */
34
+ export declare function legNoticeTaskId(leg: {
35
+ readonly taskId: string;
36
+ }): {
37
+ readonly taskId: string;
38
+ };
32
39
  export interface LegEvents {
33
- /** The person's-prompt screen its objective passes — present when a person wrote the objective. */
34
- readonly screen?: "classic.UserPromptSubmit";
35
40
  /** The event it opens on — present on a delegated leg. */
36
41
  readonly start?: "classic.SubagentStart";
37
42
  /** The event it raises when it would otherwise end. */
38
43
  readonly stop: "classic.Stop" | "classic.SubagentStop";
39
44
  }
40
45
  /**
41
- * Both ends of a leg. The delegation fact alone picks the lifecycle (a child resumed from its checkpoint keeps it): a
42
- * delegated leg opens on `classic.SubagentStart` and ends on `classic.SubagentStop`, any other on nothing and
43
- * `classic.Stop`. Who wrote the objective picks the screen: a top-level leg's objective is a person's prompt, and so is
44
- * a delegated leg's that carries an operator's words (`operatorObjective`, the trusted resume fact) — both pass
45
- * `classic.UserPromptSubmit`; any other delegated objective is its delegator's (a parent model, a workflow script, a
46
- * peer) and is judged at the delegator's gate. Not the leg kind: a resumed leg's kind reads `"resume"` whoever it runs as.
46
+ * Both ends of a leg, from the delegation fact alone (a child resumed from its checkpoint keeps it): a delegated leg opens on
47
+ * `classic.SubagentStart` and ends on `classic.SubagentStop`, any other opens on nothing and ends on `classic.Stop`. Not the leg
48
+ * kind (a resumed leg's kind reads `"resume"` whoever it runs as), and not who wrote the objective: whether an input passes
49
+ * `classic.UserPromptSubmit` is the input's own fact, its author (`countsAsOperator`, input-author.ts) — a delegator's words are
50
+ * judged at the delegator's gate (`classic.PreToolUse` on the delegating call), an operator's resume of a child is screened.
47
51
  */
48
- export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined, operatorObjective?: boolean): LegEvents;
52
+ export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined): LegEvents;
49
53
  /**
50
54
  * The args as a judging handler receives them: the gate pass's own immutable value ({@link ownArgs} — the value itself when
51
55
  * the gate already took it, which is every call the gate raises an event over), so the bytes a handler judges are the bytes
@@ -201,9 +205,13 @@ export declare function observePermissionDenied(input: {
201
205
  readonly signal: AbortSignal | undefined;
202
206
  readonly onHostObserverFailure: (err: Error) => void;
203
207
  }): Promise<void>;
204
- /** What a `classic.UserPromptSubmit` screen came to, as the four entrances read it. */
208
+ /** What a prompt's screen came to, as the four entrances read it: `text` is what the entrance delivers (the prompt as it
209
+ * came, or as `prompt.submit` handed it on — `rewrittenBy` then names who changed it, in the order they did); `block` the
210
+ * refusal (a `prompt.submit` drop, or `classic.UserPromptSubmit`'s block). */
205
211
  export type PromptScreen = {
206
212
  readonly kind: "answered";
213
+ readonly text: string;
214
+ readonly rewrittenBy?: readonly string[];
207
215
  readonly block?: string;
208
216
  readonly additionalContext?: string;
209
217
  } | Extract<ModDispatchOutcome, {
@@ -211,10 +219,31 @@ export type PromptScreen = {
211
219
  }> | {
212
220
  readonly kind: "aborted";
213
221
  };
222
+ /** Who changed a text a chain carried, read off the chain as it runs (a station's `checkHandOn` and `checkAnswer` feed it). */
223
+ export interface TextChanges {
224
+ /** A handler handed `text` on (down): it changed the text when that differs from what the previous hand-on (or the
225
+ * original) carried. */
226
+ handedOn(by: string, text: string): void;
227
+ /** A handler answered `text` (up): it changed the text when that differs from what its `next` answered (`below`) or, when
228
+ * it answered without one, from the text it was handed. */
229
+ answered(by: string, text: string, handed: string, below: string | undefined): void;
230
+ /** The handlers that changed the text, in the order they did (down before up), each named once. */
231
+ rewrittenBy(): readonly string[];
232
+ }
233
+ /** The one reading of who changed a text, for every station whose answer is a rewritten text (`session.receive`,
234
+ * `prompt.submit`): a handler is named for the change it made — handing a different text on, or answering a different text
235
+ * than the one that came up to it — never for carrying another handler's change up. */
236
+ export declare function textChanges(original: string): TextChanges;
237
+ /** The four entrances' one predicate: does the leg hear a prompt's screen — `prompt.submit`, or `classic.UserPromptSubmit`
238
+ * raised in its bottom? */
239
+ export declare function promptScreenHasHandlers(bus: LegModBus): boolean;
214
240
  /**
215
- * Raise `classic.UserPromptSubmit` (undefined when no handler hangs on it). A decision event: a handler that throws,
216
- * runs past its budget or breaks the site's contract ends the screen `failed`, and every entrance fails closed on it;
217
- * a cancelled screen ends `aborted` at once. A dispatch the engine itself could not run is `failed` too.
241
+ * A prompt's screen at one of the four entrances (objective, live steer, a wake's message before its claim, a parked steer
242
+ * redelivered): `prompt.submit` over `e` with the prompt as `text`, its bottom raising `classic.UserPromptSubmit` on the text
243
+ * handed down; `undefined` (nothing raised) when neither is heard ({@link promptScreenHasHandlers}). A decision event: a
244
+ * handler that throws, runs past its budget or breaks the site's contract ends the screen `failed`, and every entrance fails
245
+ * closed on it; a cancelled screen ends `aborted` at once; a dispatch the engine could not run is `failed` too. What the
246
+ * classic screen refused (its block, failure or cancel) is final — a `prompt.submit` handler above it does not undo it.
218
247
  */
219
248
  export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
220
249
  /**
@@ -297,11 +326,24 @@ export interface LegFacadeSeats {
297
326
  root(): string;
298
327
  model(): string;
299
328
  messages(): readonly Message[];
329
+ /** `$.session.messages({ agentId })`'s read ({@link agentRowsOf}). */
330
+ agentMessages(agentId: string): Promise<readonly AgentMessage[]>;
331
+ turns(): Promise<number>;
332
+ usage(): SessionUsage;
333
+ version(): SessionVersion;
300
334
  now(): number;
301
335
  tools(): readonly string[];
302
336
  agents(): readonly string[];
303
337
  /** `$.tool.call`'s host entry (`createToolCallEntry`, `tool-call.ts`). */
304
338
  readonly toolCall: ModCallEntry;
339
+ /** `$.agent.spawn`'s host entry (`createAgentSpawnEntry`, `agent-stations.ts`). */
340
+ readonly agentSpawn: ModCallEntry;
341
+ /** `$.session.append`'s host entry (`createSessionAppendEntry`, `session-append.ts`). */
342
+ readonly sessionAppend: ModCallEntry;
343
+ /** `$.session.send`'s host entry (`createSessionSendEntry`, `session-send.ts`). */
344
+ readonly sessionSend: ModCallEntry;
345
+ /** `$.session.compact`'s host entry (`createSessionCompactEntry`, `session-compact.ts`). */
346
+ readonly sessionCompact: ModCallEntry;
305
347
  }
306
348
  /** The leg's admitted bus, its chain identity (the one its admission recorded, {@link chainOfBus}) and the binding of the
307
349
  * facade its `$` reaches. `bus` is the leg bus every station raises on ({@link legBusOf}: an extension's own call's
@@ -315,6 +357,8 @@ export interface LegMods {
315
357
  readonly chain: readonly ModChainLink[];
316
358
  /** The leg's skill scopes (`SkillSpec.mods`): the grant table opens one on each activation, the park freezes them. */
317
359
  readonly skillScopes: SkillScopes;
360
+ /** The leg's report sink (handler failures; a station's own disclosures). */
361
+ readonly report: (err: Error) => void;
318
362
  /** Bind the engine facade once the leg is prepared. Until then a `$` call throws, naming the method. */
319
363
  bindFacade(seats: LegFacadeSeats): void;
320
364
  }
@@ -340,12 +384,21 @@ export interface LegFacadeInput {
340
384
  readonly sessionId: string;
341
385
  readonly model: Model;
342
386
  readonly executionEnv: Pick<ExecutionEnv, "exec">;
387
+ /** The run's byte-floor seat: a mod's `$.process.run` is the run's own start and carries the run's base table. */
388
+ readonly readFloor: (toolCallId: string | undefined) => ReadFloor | undefined;
343
389
  readonly taskRoot: string;
344
390
  readonly cwdRef: CwdRef | undefined;
345
391
  /** The leg's latest model request as recorded at the provider seam (the session's messages as the model last saw them). */
346
392
  readonly lastBrainContext: () => {
347
393
  readonly messages: readonly Message[];
348
394
  } | undefined;
395
+ /** Where the leg's subagents' transcripts are read ({@link agentRowsOf}); `undefined` ⇒ there is no task list (a
396
+ * session-level pass), and the read refuses saying so. */
397
+ readonly agentSessions: AgentSessionsSeat | undefined;
398
+ /** The session's prompt count, read at the call (`promptCountOf` over its branch, `session-append.ts`). */
399
+ readonly turns: () => Promise<number>;
400
+ /** The leg's measurement seat (`measureSession` writes it at each turn boundary). */
401
+ readonly measure: SessionMeasureSeat;
349
402
  readonly activeTools: ReadonlySet<string>;
350
403
  readonly agentListing: {
351
404
  readonly entries: ReadonlyArray<{
@@ -361,6 +414,20 @@ export interface LegFacadeInput {
361
414
  }) => void;
362
415
  /** `$.tool.call`'s host entry, over the leg's harness and occurrence table. */
363
416
  readonly toolCall: ModCallEntry;
417
+ /** `$.agent.spawn`'s host entry, over the leg's harness and its delegation tool. */
418
+ readonly agentSpawn: ModCallEntry;
419
+ /** `$.session.append`'s host entry, over the leg's admission seat and harness. */
420
+ readonly sessionAppend: ModCallEntry;
421
+ /** `$.session.send`'s host entry, over the leg's `$.tool.call` entry and its SendMessage. */
422
+ readonly sessionSend: ModCallEntry;
423
+ /** `$.session.compact`'s host entry, over the leg's compaction station. */
424
+ readonly sessionCompact: ModCallEntry;
425
+ }
426
+ /** The seat a leg reads its subagents' transcripts through: its task list, only the rows its own access reaches. Each row
427
+ * carries the store its child's session lives in, so no store of the leg's own is read. */
428
+ export interface AgentSessionsSeat {
429
+ readonly registry: Pick<TaskRegistry, "anchoredSession">;
430
+ readonly access: TaskAccess;
364
431
  }
365
432
  /** The engine facade's seats over a prepared leg — each one a seat the leg already has (no new capability). */
366
433
  export declare function legFacadeSeats(input: LegFacadeInput): LegFacadeSeats;
@@ -1,9 +1,11 @@
1
1
  import { types } from "node:util";
2
+ import { engineVersion } from "../version.js";
2
3
  import { resolveModel } from "../roles.js";
3
4
  import { brainToRuntime } from "../runtime.js";
4
5
  import { deliverEngineNotice } from "../engine-notice.js";
5
6
  import { extensionWords } from "../untrusted-egress.js";
6
7
  import { askApproverIdentity, describeThrown, ownArgs } from "../tool-policy.js";
8
+ import { agentIdOf } from "../leg-identity.js";
7
9
  import { admitMods } from "./kernel/index.js";
8
10
  import { legBusOf } from "./extension-call.js";
9
11
  import { validateOverlay } from "../../prompt-assembly/overlay.js";
@@ -16,16 +18,16 @@ export const ENGINE_CORE_ANSWER = Object.freeze({});
16
18
  export function engineCore() {
17
19
  return ENGINE_CORE_ANSWER;
18
20
  }
19
- export function agentIdOf(identity) {
20
- return identity?.isDelegatedChild === true ? identity.taskId : undefined;
21
+ export function seatHears(binding, event) {
22
+ return binding !== undefined && binding.bus.hasHandlers(event);
21
23
  }
22
- const PERSON_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", stop: "classic.Stop" });
24
+ export function legNoticeTaskId(leg) {
25
+ return { taskId: leg.taskId };
26
+ }
27
+ const TOP_LEVEL_LEG = Object.freeze({ stop: "classic.Stop" });
23
28
  const DELEGATED_LEG = Object.freeze({ start: "classic.SubagentStart", stop: "classic.SubagentStop" });
24
- const OPERATOR_RESUMED_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", start: "classic.SubagentStart", stop: "classic.SubagentStop" });
25
- export function legEventsOf(identity, operatorObjective = false) {
26
- if (identity?.isDelegatedChild !== true)
27
- return PERSON_LEG;
28
- return operatorObjective ? OPERATOR_RESUMED_LEG : DELEGATED_LEG;
29
+ export function legEventsOf(identity) {
30
+ return identity?.isDelegatedChild === true ? DELEGATED_LEG : TOP_LEVEL_LEG;
29
31
  }
30
32
  export function judgedInputOf(args) {
31
33
  const owned = ownArgs(args);
@@ -199,7 +201,101 @@ export async function observePermissionDenied(input) {
199
201
  await observeClassic(own, "classic.PermissionDenied", e, input.signal);
200
202
  }
201
203
  const USER_PROMPT_RANKS = Object.freeze({ of: (a) => (stringMembersOf(a, ["block"]).block ? 1 : 0), top: 1 });
204
+ export function textChanges(original) {
205
+ const changers = [];
206
+ const note = (by) => {
207
+ if (!changers.includes(by))
208
+ changers.push(by);
209
+ };
210
+ let before = original;
211
+ return {
212
+ handedOn: (by, text) => {
213
+ if (text !== before)
214
+ note(by);
215
+ before = text;
216
+ },
217
+ answered: (by, text, handed, below) => {
218
+ if (text !== (below ?? handed))
219
+ note(by);
220
+ },
221
+ rewrittenBy: () => Object.freeze([...changers]),
222
+ };
223
+ }
224
+ export function promptScreenHasHandlers(bus) {
225
+ return bus.hasHandlers("prompt.submit") || bus.hasHandlers("classic.UserPromptSubmit");
226
+ }
227
+ const PROMPT_SUBMIT_FORM = "prompt.submit takes { text } (a string) or { drop: <reason> }";
228
+ function readSubmitAnswer(a) {
229
+ if (!isPlainRecord(a))
230
+ return { why: PROMPT_SUBMIT_FORM };
231
+ const keys = Object.keys(a);
232
+ if (keys.length === 1 && keys[0] === "drop") {
233
+ const r = a["drop"];
234
+ return typeof r === "string" && r.trim() !== "" ? { drop: r } : { why: "a drop that is not a reason (a non-empty string)" };
235
+ }
236
+ if (keys.length === 1 && keys[0] === "text") {
237
+ const t = a["text"];
238
+ return typeof t === "string" ? { text: t } : { why: "a text that is not a string" };
239
+ }
240
+ return { why: PROMPT_SUBMIT_FORM };
241
+ }
242
+ const PROMPT_SUBMIT_RANKS = Object.freeze({ of: (a) => (isPlainRecord(a) && Object.hasOwn(a, "drop") ? 1 : 0), top: 1 });
202
243
  export async function screenUserPrompt(bus, e, signal) {
244
+ if (!promptScreenHasHandlers(bus))
245
+ return undefined;
246
+ const { prompt, ...facts } = e;
247
+ const changes = textChanges(prompt);
248
+ const checkHandOn = (handed, by) => {
249
+ const t = handed["text"];
250
+ if (typeof t !== "string")
251
+ return "next() handed on a text that is not a string";
252
+ changes.handedOn(by.plugin, t);
253
+ return undefined;
254
+ };
255
+ const seen = {};
256
+ const bottom = async (handed) => {
257
+ const text = handed["text"];
258
+ const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal);
259
+ if (classic !== undefined)
260
+ seen.classic = classic;
261
+ if (classic === undefined || (classic.kind === "answered" && !classic.block))
262
+ return Object.freeze({ text });
263
+ return Object.freeze({ drop: classic.kind === "answered" ? classic.block : "the classic.UserPromptSubmit screen did not clear the prompt" });
264
+ };
265
+ const checkAnswer = (a, handed, by, below) => {
266
+ const read = readSubmitAnswer(a);
267
+ if ("why" in read)
268
+ return read.why;
269
+ if ("text" in read) {
270
+ const up = below.length > 0 ? readSubmitAnswer(below[below.length - 1]) : undefined;
271
+ changes.answered(by.plugin, read.text, handed["text"], up !== undefined && "text" in up ? up.text : undefined);
272
+ }
273
+ return undefined;
274
+ };
275
+ let outcome;
276
+ try {
277
+ outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}) });
278
+ }
279
+ catch (err) {
280
+ return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screen: ${describeThrown(err)}`, skipped: [] };
281
+ }
282
+ const classic = seen.classic;
283
+ if (classic !== undefined && (classic.kind !== "answered" || classic.block))
284
+ return classic.kind === "answered" ? { ...classic, text: prompt } : classic;
285
+ if (outcome.kind !== "answered")
286
+ return outcome;
287
+ const read = readSubmitAnswer(outcome.answer);
288
+ const by = outcome.answeredBy ?? "engine";
289
+ const context = classic?.kind === "answered" && classic.additionalContext !== undefined ? { additionalContext: classic.additionalContext } : {};
290
+ if ("drop" in read)
291
+ return { kind: "answered", text: prompt, block: read.drop };
292
+ if ("why" in read)
293
+ return { kind: "failed", registration: by, cause: "violation", reason: read.why, skipped: [] };
294
+ if (read.text === prompt)
295
+ return { kind: "answered", text: prompt, ...context };
296
+ return { kind: "answered", text: read.text, rewrittenBy: changes.rewrittenBy(), ...context };
297
+ }
298
+ async function screenClassicPrompt(bus, e, signal) {
203
299
  let outcome;
204
300
  try {
205
301
  outcome = await dispatchClassic(bus, "classic.UserPromptSubmit", e, {
@@ -386,6 +482,10 @@ function lateView() {
386
482
  root: () => need("session.root").root(),
387
483
  model: () => need("session.model").model(),
388
484
  messages: () => need("session.messages").messages(),
485
+ agentMessages: (agentId) => need("session.messages").agentMessages(agentId),
486
+ turns: () => need("session.turns").turns(),
487
+ usage: () => need("session.usage").usage(),
488
+ version: () => need("session.version").version(),
389
489
  },
390
490
  now: () => need("clock.now").now(),
391
491
  tools: () => need("tool.list").tools(),
@@ -393,7 +493,13 @@ function lateView() {
393
493
  };
394
494
  return {
395
495
  view,
396
- entries: { "tool.call": (args, ctx) => need("tool.call").toolCall(args, ctx) },
496
+ entries: {
497
+ "tool.call": (args, ctx) => need("tool.call").toolCall(args, ctx),
498
+ "agent.spawn": (args, ctx) => need("agent.spawn").agentSpawn(args, ctx),
499
+ "session.append": (args, ctx) => need("session.append").sessionAppend(args, ctx),
500
+ "session.send": (args, ctx) => need("session.send").sessionSend(args, ctx),
501
+ "session.compact": (args, ctx) => need("session.compact").sessionCompact(args, ctx),
502
+ },
397
503
  bind: (s) => {
398
504
  seats = s;
399
505
  },
@@ -416,7 +522,28 @@ export async function admitLegMods(input) {
416
522
  const chain = recordAdmittedChain(bus, seats);
417
523
  if (standing !== bus)
418
524
  ADMITTED_CHAINS.set(standing, chain);
419
- return { bus, standing, chain, skillScopes, bindFacade: late.bind };
525
+ return { bus, standing, chain, skillScopes, report, bindFacade: late.bind };
526
+ }
527
+ async function agentRowsOf(seat, agentId) {
528
+ const refused = (why) => new Error(`session.messages: agent ${agentId}: ${why}`);
529
+ if (seat === undefined)
530
+ throw refused("there is no task list here — a session-level pass has no run, so no subagents");
531
+ const anchor = seat.registry.anchoredSession(agentId, seat.access);
532
+ if (anchor === undefined)
533
+ throw refused("not one of this leg's subagents (no task list row this leg reaches has that id)");
534
+ if (anchor === null)
535
+ throw refused("its row names no session — not a subagent's row, or its session is not bound yet or was released");
536
+ const store = anchor.store;
537
+ if (store === undefined)
538
+ throw refused("its session was bound without the store that holds it");
539
+ let branch;
540
+ try {
541
+ branch = await (await store.acquire(anchor.sessionId, { requireExisting: true })).session.getBranch();
542
+ }
543
+ catch (err) {
544
+ throw refused(`its session could not be read (${describeThrown(err)})`);
545
+ }
546
+ return branch.flatMap((e) => (e.type === "message" ? [e.message] : []));
420
547
  }
421
548
  function replyText(reply) {
422
549
  return reply.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("");
@@ -426,7 +553,10 @@ export function legFacadeSeats(input) {
426
553
  const answeredBy = new Map();
427
554
  const byUsage = new WeakMap();
428
555
  return {
429
- exec: (command, options) => input.executionEnv.exec(command, options),
556
+ exec: (command, options) => {
557
+ const readFloor = input.readFloor(undefined);
558
+ return input.executionEnv.exec(command, { ...options, ...(readFloor !== undefined ? { readFloor } : {}) });
559
+ },
430
560
  complete: async (request, signal) => {
431
561
  const model = request.model !== undefined ? resolveModel(request.model, input.deps.models) : input.model;
432
562
  answeredBy.set(model.id, model);
@@ -451,10 +581,18 @@ export function legFacadeSeats(input) {
451
581
  root: () => input.taskRoot,
452
582
  model: () => input.model.id,
453
583
  messages: () => input.lastBrainContext()?.messages ?? [],
584
+ agentMessages: (agentId) => agentRowsOf(input.agentSessions, agentId),
585
+ turns: () => input.turns(),
586
+ usage: () => Object.freeze(input.measure.context !== undefined ? { context: input.measure.context } : {}),
587
+ version: () => Object.freeze({ version: engineVersion() }),
454
588
  now: () => (input.deps.now ?? Date.now)(),
455
589
  tools: () => [...input.activeTools],
456
590
  agents: () => (input.agentListing?.entries ?? []).map((e) => e.name),
457
591
  toolCall: input.toolCall,
592
+ agentSpawn: input.agentSpawn,
593
+ sessionAppend: input.sessionAppend,
594
+ sessionSend: input.sessionSend,
595
+ sessionCompact: input.sessionCompact,
458
596
  };
459
597
  }
460
598
  export async function admitModChain(seats, onError) {
@@ -87,3 +87,5 @@ export declare function extensionCallOverlap(input: {
87
87
  readonly args: unknown;
88
88
  readonly batchSafe: (toolName: string, args: unknown) => boolean;
89
89
  }): string | undefined;
90
+ /** A call result's text, as a host entry answers a refusal with it (`{ deny: <the text> }`). */
91
+ export declare const resultText: (content: unknown) => string;
@@ -143,7 +143,7 @@ export function createToolCallStation(input) {
143
143
  const AGENT_DOOR = "runs the Agent tool: that is $.agent.spawn";
144
144
  const OTHER_DOOR = new Map([
145
145
  [toolFace("ask-user-question").contract.contractId, "runs the AskUserQuestion tool, which puts a question to the person: an extension's call does not ask the person"],
146
- [toolFace("workflow").contract.contractId, "runs the Workflow tool, whose agents run outside the at-once bound on spawns: $.agent.spawn is the door"],
146
+ [toolFace("workflow").contract.contractId, "runs the Workflow tool, whose agents run outside the tree's bound on agents running at once (RunnerDeps.delegationEntryCaps.maxConcurrent): $.agent.spawn is the door"],
147
147
  ]);
148
148
  export function createToolCallEntry(input) {
149
149
  return async (args, ctx) => {
@@ -152,7 +152,7 @@ export function createToolCallEntry(input) {
152
152
  if (typeof tool !== "string" || tool === "")
153
153
  throw new TypeError(`${by}: $.tool.call takes the event's input: { tool, ...args }`);
154
154
  const toolCallId = `ext-${randomUUID()}`;
155
- return runExtensionCall(input.bus, toolCallId, ctx, async (call) => {
155
+ return runExtensionCall(input.bus, toolCallId, "tool.call", ctx, async (call) => {
156
156
  const finalized = await input.harness.callTool({ type: "toolCall", id: toolCallId, name: tool, arguments: { ...callInput } }, ctx.signal, (t) => {
157
157
  const contractId = input.faceOf(t.name)?.contractId;
158
158
  const door = declaredDelegationNameOf(input.specOf(t.name)) !== undefined ? AGENT_DOOR : contractId !== undefined ? OTHER_DOOR.get(contractId) : undefined;
@@ -160,7 +160,7 @@ export function createToolCallEntry(input) {
160
160
  throw new TypeError(`${by}: $.tool.call(${extensionWords(t.name, 80)}) ${door}`);
161
161
  });
162
162
  if (call.denied)
163
- return Object.freeze({ deny: textOf(finalized.result.content) });
163
+ return Object.freeze({ deny: resultText(finalized.result.content) });
164
164
  return viewOf({ ...finalized.result, isError: finalized.isError });
165
165
  });
166
166
  };
@@ -174,4 +174,4 @@ export function extensionCallOverlap(input) {
174
174
  const exclusive = others.find((o) => o.life === "released" && !input.batchSafe(o.wireName ?? o.spelledName, o.finalInput ?? o.args));
175
175
  return exclusive === undefined ? undefined : `${name}: an extension's call cannot run beside "${extensionWords(exclusive.wireName ?? exclusive.spelledName, 80)}", which has the run to itself`;
176
176
  }
177
- const textOf = (content) => (Array.isArray(content) ? content.map((b) => (isPlainRecord(b) && b["type"] === "text" && typeof b["text"] === "string" ? b["text"] : "")).join("") : "");
177
+ export const resultText = (content) => (Array.isArray(content) ? content.map((b) => (isPlainRecord(b) && b["type"] === "text" && typeof b["text"] === "string" ? b["text"] : "")).join("") : "");
@@ -1,5 +1,7 @@
1
1
  import { describeRejectedValue } from "./tool-search-setting.js";
2
2
  import { inlineUntrusted } from "./untrusted-text.js";
3
+ import { optionKeys, receiveMembers } from "./own-property-receipt.js";
4
+ const OUTPUT_STYLE_KEYS = optionKeys()({ name: 0, turnReminder: 0 });
3
5
  export const OUTPUT_STYLE_NAME_MAX = 256;
4
6
  const OUTPUT_STYLE_DEFAULT_TURN_REMINDER = "Remember to follow the specific guidelines for this style.";
5
7
  export function renderOutputStyle(name, turnReminder) {
@@ -15,10 +17,7 @@ export function resolveOutputStyleFrame(seat) {
15
17
  };
16
18
  if (seat === null || typeof seat !== "object" || Array.isArray(seat))
17
19
  return refuse(`must be an object { name, turnReminder? } (got ${describeRejectedValue(seat)})`);
18
- const extra = Object.keys(seat).filter((k) => k !== "name" && k !== "turnReminder");
19
- if (extra.length > 0)
20
- return refuse(`carries ${extra.map((k) => JSON.stringify(k)).join(", ")}, which the seat does not read (members: "name", "turnReminder")`);
21
- const { name, turnReminder } = seat;
20
+ const { name, turnReminder } = receiveMembers(seat, { subject: "TaskSpec.outputStyle", unit: "member", moment: "when the seat is read" }, OUTPUT_STYLE_KEYS, (_, extra) => refuse(`carries ${extra.map((k) => JSON.stringify(String(k))).join(", ")}, which the seat does not read (members: "name", "turnReminder")`));
22
21
  if (typeof name !== "string" || name.trim() === "")
23
22
  return refuse(`.name must be a non-empty string (got ${describeRejectedValue(name)})`);
24
23
  if (name.length > OUTPUT_STYLE_NAME_MAX)
@@ -27,8 +27,74 @@ export declare const CONFIG_RECEIPT_MODE: ReceiptMode;
27
27
  * itself, a container nested deeper — a shared one measured where it sits each time it is met), every copied container frozen.
28
28
  */
29
29
  export declare const DECLARATION_RECEIPT_MODE: ReceiptMode;
30
+ /** Only {@link optionKeys} mints an {@link OptionKeys}: a hand-written list carries no brand. */
31
+ declare const OPTION_KEYS: unique symbol;
32
+ /**
33
+ * A constructor's options table: the keys of the options interface `T`, exactly. The brand is a function over `keyof T`
34
+ * in both positions, so a table for one interface is not a table for another (a narrower one, an `Omit` of it) in either
35
+ * direction, and a plain string list is not one at all.
36
+ */
37
+ export type OptionKeys<T> = readonly string[] & {
38
+ readonly [OPTION_KEYS]: (key: keyof T) => keyof T;
39
+ };
40
+ /** The keys of `K` outside `T`, taken arm by arm when `K` is a union (each arm's own keys, not only the keys all arms share). */
41
+ type SurplusKeys<K, T> = K extends unknown ? Exclude<keyof K, keyof T> : never;
42
+ /** The minter {@link optionKeys} hands back: `never` — not callable — for an interface with an index signature, whose keys no
43
+ * table can name. */
44
+ type OptionKeysMinter<T> = string extends keyof T ? never : number extends keyof T ? never : <K extends Record<keyof T, 0>>(table: K & Record<SurplusKeys<K, T>, never>) => OptionKeys<T>;
45
+ /**
46
+ * Mint the options table of interface `T` from a literal naming each of its keys once (`{ fsync: 0, lockWaitMs: 0 }`).
47
+ * Curried so `T` is written and the literal inferred: a key of `T` the literal leaves out does not compile, and neither
48
+ * does a key `T` lacks — whether the literal is fresh, a variable, a spread, or a union whose arms each carry one — since
49
+ * every key outside `T` must be `never`. An interface with an index signature has no table (the minter is not callable).
50
+ */
51
+ export declare function optionKeys<T extends object>(): OptionKeysMinter<T>;
30
52
  /** The OPTIONS DOOR — a constructor's options bag received by the receipt law, absent ⇒ an empty one: every option the constructor reads
31
- * is read off this copy, once, and the caller's bag is never read again (a store keeps no hold of it). `owner` names the constructor. */
32
- export declare function receiveOptions<T extends object>(given: T | undefined, owner: string): T;
53
+ * is read off this frozen copy, once, and the caller's bag is never read again (a store keeps no hold of it). `owner` names the
54
+ * constructor; `keys` is the table of the options it takes ({@link optionKeys}), and an option outside it is refused by name
55
+ * ({@link receiveMembers}). */
56
+ export declare function receiveOptions<T extends object>(given: T | undefined, owner: string, keys: OptionKeys<T>): Readonly<T>;
33
57
  /** Read `given` by the receipt law (module note): the plain copy, every own member taken once from its captured descriptor. */
34
58
  export declare function receiveOwnProperties<T extends object>(given: T, words: OwnPropertyReceiptWords): T;
59
+ /** How a door whose family has its own code refuses its stray members: the one sentence, and the stray names it names
60
+ * (a symbol as itself), for a refusal that also carries them as data. */
61
+ export type StrayMembersRefusal = (message: string, stray: readonly (string | symbol)[]) => Error;
62
+ /** A record's members outside a door's table: their names (a symbol as itself) and the one sentence that names them. */
63
+ export interface StrayMembers {
64
+ readonly names: readonly (string | symbol)[];
65
+ readonly sentence: string;
66
+ }
67
+ /**
68
+ * THE NAME JUDGMENT of a door (module note): every own member of `given` that `keys` does not name — a string key,
69
+ * enumerable or not, and a symbol key — with the one sentence that names them all (each with its nearest taken name within
70
+ * two edits, then the members taken); `undefined` when there is none. It reads names only: no getter runs and no value is
71
+ * looked at. On an admitted object (a plain record that is no Proxy, or a copy a receipt made) no caller code runs; a
72
+ * reader whose own law reads the caller's live object judges the names that object answers (a Proxy's own-keys answer
73
+ * included). A reader that answers a sentence instead of throwing takes this; a door that throws takes
74
+ * {@link refuseStrayMembers} or {@link receiveMembers}.
75
+ */
76
+ export declare function strayMembersOf(given: object, words: OwnPropertyReceiptWords, keys: readonly string[]): StrayMembers | undefined;
77
+ /**
78
+ * THE MEMBER'S PRESENCE (module note): `name` is a member of `record` exactly when its value there is not `undefined` — an
79
+ * own key holding `undefined` and a missing key are one absence; `null`, `0`, `""` and `false` are values. The engine's one
80
+ * reading of whether a record carries a member; the names a caller handed over are the name judgment's question
81
+ * ({@link strayMembersOf}), not this one's.
82
+ */
83
+ export declare function memberPresent(record: object, name: string): boolean;
84
+ /**
85
+ * THE NAME-ONLY DOOR — the receipt's admission (not a Proxy, a plain record), then {@link strayMembersOf}: every own member
86
+ * `keys` does not name is refused, all of them in one sentence, and no getter runs. For an object the door must judge but
87
+ * not copy (a face whose callbacks are later called with the object itself as `this`); a door that takes a copy takes
88
+ * {@link receiveMembers}, which is this judgment followed by the receipt.
89
+ */
90
+ export declare function refuseStrayMembers(given: object, words: OwnPropertyReceiptWords, keys: readonly string[], refusal?: StrayMembersRefusal): void;
91
+ /**
92
+ * Read `given` by the receipt law and refuse every own member `keys` does not name (module note): the members a door
93
+ * takes, and nothing else, by one reading. The names are judged ({@link refuseStrayMembers}) before the receipt runs any
94
+ * getter, and nothing of the caller's runs between that judgment and the receipt's one capture, so the names judged are
95
+ * the names read. `refusal` codes the stray-member refusal for a door whose family has its own code (the receipt's own
96
+ * refusals keep `config.invalid_argument`). The copy handed back is frozen: what was judged is what is held, and a
97
+ * callback the door's owner later calls on it (its `this`) cannot change a member.
98
+ */
99
+ export declare function receiveMembers<T extends object>(given: T, words: OwnPropertyReceiptWords, keys: readonly string[], refusal?: StrayMembersRefusal): Readonly<T>;
100
+ export {};
@@ -1,4 +1,6 @@
1
1
  import { types } from "node:util";
2
+ import { closestName } from "./closest-name.js";
3
+ import { inlineUntrusted } from "./untrusted-text.js";
2
4
  import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
3
5
  import { MODS_VALUE_DEPTH } from "./mods/kernel/site-rules.js";
4
6
  export function receiptRefusal(message) {
@@ -12,14 +14,40 @@ export function refuseProxy(given, words) {
12
14
  }
13
15
  export const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
14
16
  export const DECLARATION_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: MODS_VALUE_DEPTH + 1, others: "refuse", freeze: true, isProxy: (v) => types.isProxy(v) });
15
- export function receiveOptions(given, owner) {
16
- return given === undefined ? {} : receiveOwnProperties(given, { subject: `${owner} options`, unit: "option", moment: `at new ${owner}` });
17
+ export function optionKeys() {
18
+ return ((table) => Object.freeze(Object.keys(table)));
19
+ }
20
+ export function receiveOptions(given, owner, keys) {
21
+ return given === undefined ? Object.freeze({}) : receiveMembers(given, { subject: `${owner} options`, unit: "option", moment: `at new ${owner}` }, keys);
17
22
  }
18
23
  export function receiveOwnProperties(given, words) {
24
+ admitPlainRecord(given, words);
25
+ return readCaptured(given, words);
26
+ }
27
+ export function strayMembersOf(given, words, keys) {
28
+ const names = Reflect.ownKeys(given).filter((k) => typeof k === "symbol" || !keys.includes(k));
29
+ return names.length === 0 ? undefined : Object.freeze({ names: Object.freeze(names), sentence: strayMembersSentence(words, names, keys) });
30
+ }
31
+ export function memberPresent(record, name) {
32
+ return Reflect.get(record, name) !== undefined;
33
+ }
34
+ export function refuseStrayMembers(given, words, keys, refusal = receiptRefusal) {
35
+ admitPlainRecord(given, words);
36
+ const stray = strayMembersOf(given, words, keys);
37
+ if (stray !== undefined)
38
+ throw refusal(stray.sentence, stray.names);
39
+ }
40
+ export function receiveMembers(given, words, keys, refusal = receiptRefusal) {
41
+ refuseStrayMembers(given, words, keys, refusal);
42
+ return Object.freeze(readCaptured(given, words));
43
+ }
44
+ function admitPlainRecord(given, words) {
19
45
  refuseProxy(given, words);
20
46
  if (!isPlainRecord(given)) {
21
47
  throw receiptRefusal(`${words.subject} must be a plain object (its prototype is neither Object.prototype nor null): every ${words.unit} is read once as an own property, and a ${words.unit} its prototype would supply is not read — refused rather than wired without it`);
22
48
  }
49
+ }
50
+ function readCaptured(given, words) {
23
51
  const received = receive(given, CONFIG_RECEIPT_MODE);
24
52
  if (received.ok)
25
53
  return received.value;
@@ -30,3 +58,18 @@ export function receiveOwnProperties(given, words) {
30
58
  throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
31
59
  throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
32
60
  }
61
+ const STRAY_NAME_MAX = 80;
62
+ function strayMembersSentence(words, stray, keys) {
63
+ const named = stray.map((k) => {
64
+ if (typeof k === "symbol")
65
+ return `${inlineUntrusted(String(k), STRAY_NAME_MAX)} (a symbol-keyed member)`;
66
+ const shown = JSON.stringify(inlineUntrusted(k, STRAY_NAME_MAX));
67
+ const near = closestName(k, keys);
68
+ return near === undefined ? shown : `${shown} (did you mean ${JSON.stringify(near)}?)`;
69
+ });
70
+ const one = stray.length === 1;
71
+ const unit = words.unit;
72
+ const what = one ? `is not ${/^[aeiou]/i.test(unit) ? "an" : "a"} ${unit}` : `are not ${unit}s`;
73
+ const takes = keys.length === 0 ? `it takes no ${unit}s` : `the ${unit}s it takes are ${keys.map((k) => JSON.stringify(k)).join(", ")}`;
74
+ return `${words.subject}: ${named.join(", ")} ${what} it takes — ${takes}; refused ${words.moment} rather than read as absent (a misspelled ${unit} would leave its default in force and nothing would say so)`;
75
+ }