@sema-agent/core 7.58.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 (519) hide show
  1. package/CHANGELOG.md +1340 -0
  2. package/README.md +6 -4
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  6. package/dist/agents/agent-transcript-tool.js +3 -1
  7. package/dist/agents/cc-peer-directory.js +8 -8
  8. package/dist/agents/child-model-seat.d.ts +4 -2
  9. package/dist/agents/child-model-seat.js +9 -4
  10. package/dist/agents/cumulative-stats.js +0 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  12. package/dist/agents/inherited-tool-pool.js +22 -0
  13. package/dist/agents/peer-directory.d.ts +9 -0
  14. package/dist/agents/peer-directory.js +6 -2
  15. package/dist/agents/retain-ledger.d.ts +11 -1
  16. package/dist/agents/retain-ledger.js +13 -2
  17. package/dist/agents/roster-store.d.ts +1 -1
  18. package/dist/agents/roster-store.js +3 -1
  19. package/dist/agents/send-message-tool.d.ts +8 -19
  20. package/dist/agents/send-message-tool.js +32 -50
  21. package/dist/agents/subagent.d.ts +51 -17
  22. package/dist/agents/subagent.js +150 -112
  23. package/dist/agents/tool-filter.d.ts +1 -3
  24. package/dist/agents/tool-filter.js +4 -12
  25. package/dist/bench/metrics.d.ts +3 -5
  26. package/dist/bench/metrics.js +0 -1
  27. package/dist/brain/anthropic.js +161 -45
  28. package/dist/brain/degrading.js +3 -1
  29. package/dist/brain/errors.d.ts +9 -3
  30. package/dist/brain/errors.js +7 -1
  31. package/dist/brain/failover.js +2 -1
  32. package/dist/brain/open-responses.js +3 -3
  33. package/dist/brain/openai.js +103 -53
  34. package/dist/brain/provider-dialect.d.ts +11 -0
  35. package/dist/brain/provider-dialect.js +5 -2
  36. package/dist/brain/reasoning-request.js +5 -4
  37. package/dist/brain/reasoning.d.ts +19 -0
  38. package/dist/brain/reasoning.js +17 -2
  39. package/dist/brain/request-route.d.ts +4 -1
  40. package/dist/brain/request-route.js +4 -1
  41. package/dist/brain/route-adjudicator.d.ts +84 -18
  42. package/dist/brain/route-adjudicator.js +90 -22
  43. package/dist/brain/route-conformance.js +1 -1
  44. package/dist/brain/status-sink.d.ts +7 -1
  45. package/dist/brain/status-sink.js +6 -0
  46. package/dist/brain/stream-engine.js +84 -49
  47. package/dist/brain/stream-shared.d.ts +30 -0
  48. package/dist/brain/stream-shared.js +34 -1
  49. package/dist/brain/timeout.d.ts +65 -6
  50. package/dist/brain/timeout.js +111 -11
  51. package/dist/core/a2a.d.ts +15 -5
  52. package/dist/core/a2a.js +34 -19
  53. package/dist/core/account-row.d.ts +61 -0
  54. package/dist/core/account-row.js +51 -0
  55. package/dist/core/advisor-verdict.d.ts +2 -1
  56. package/dist/core/advisor-verdict.js +1 -1
  57. package/dist/core/agent-definition.d.ts +20 -0
  58. package/dist/core/allow-entry.d.ts +20 -6
  59. package/dist/core/allow-entry.js +17 -7
  60. package/dist/core/approval-object.d.ts +29 -15
  61. package/dist/core/approval-object.js +47 -19
  62. package/dist/core/artifact-host.d.ts +0 -2
  63. package/dist/core/artifact-host.js +0 -1
  64. package/dist/core/auto-compaction.js +1 -1
  65. package/dist/core/auto-mode-defaults.d.ts +8 -0
  66. package/dist/core/auto-mode-defaults.js +1 -0
  67. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  68. package/dist/core/auto-mode.d.ts +39 -4
  69. package/dist/core/auto-mode.js +63 -12
  70. package/dist/core/background-agent-store.d.ts +26 -4
  71. package/dist/core/background-agent-store.js +3 -2
  72. package/dist/core/background-shell.d.ts +12 -1
  73. package/dist/core/background-shell.js +12 -0
  74. package/dist/core/checkpoint-requirements.d.ts +13 -1
  75. package/dist/core/checkpoint-requirements.js +3 -1
  76. package/dist/core/checkpoint-store.d.ts +66 -25
  77. package/dist/core/checkpoint-store.js +22 -9
  78. package/dist/core/child-clamp-seats.d.ts +29 -0
  79. package/dist/core/child-clamp-seats.js +56 -1
  80. package/dist/core/compliance.d.ts +3 -3
  81. package/dist/core/compliance.js +1 -1
  82. package/dist/core/credential-echo.d.ts +52 -0
  83. package/dist/core/credential-echo.js +65 -0
  84. package/dist/core/credential-vocabulary.d.ts +13 -3
  85. package/dist/core/credential-vocabulary.js +12 -4
  86. package/dist/core/cross-boundary-taint.d.ts +4 -5
  87. package/dist/core/effective-path-target.d.ts +8 -2
  88. package/dist/core/effective-path-target.js +8 -3
  89. package/dist/core/engine-notice.d.ts +156 -23
  90. package/dist/core/engine-notice.js +19 -5
  91. package/dist/core/frame-settlement.d.ts +5 -0
  92. package/dist/core/frame-settlement.js +4 -0
  93. package/dist/core/gate-fold.js +8 -6
  94. package/dist/core/gate-lanes.js +47 -12
  95. package/dist/core/gate-outcome.d.ts +32 -3
  96. package/dist/core/gate-outcome.js +19 -1
  97. package/dist/core/governance-codes.d.ts +17 -1
  98. package/dist/core/governance-codes.js +25 -0
  99. package/dist/core/hands-band-screen.js +0 -1
  100. package/dist/core/hands-band.d.ts +0 -3
  101. package/dist/core/hooks.d.ts +70 -59
  102. package/dist/core/hooks.js +125 -80
  103. package/dist/core/image-admission.d.ts +106 -52
  104. package/dist/core/image-admission.js +184 -56
  105. package/dist/core/image-downsample.d.ts +36 -69
  106. package/dist/core/image-downsample.js +111 -73
  107. package/dist/core/integer-option.d.ts +21 -0
  108. package/dist/core/integer-option.js +13 -0
  109. package/dist/core/locked-config.d.ts +59 -5
  110. package/dist/core/locked-config.js +82 -50
  111. package/dist/core/mailbox-store.d.ts +45 -1
  112. package/dist/core/mailbox-store.js +53 -9
  113. package/dist/core/mcp-call-meta.d.ts +2 -2
  114. package/dist/core/mcp-call-meta.js +9 -10
  115. package/dist/core/mcp-failure.d.ts +122 -20
  116. package/dist/core/mcp-failure.js +73 -5
  117. package/dist/core/mcp-host-seat.d.ts +92 -0
  118. package/dist/core/mcp-host-seat.js +131 -0
  119. package/dist/core/mcp-probe.d.ts +7 -2
  120. package/dist/core/mcp-probe.js +7 -2
  121. package/dist/core/mcp-server-link.d.ts +22 -1
  122. package/dist/core/mcp-server-link.js +25 -1
  123. package/dist/core/mcp-server-spec.d.ts +38 -9
  124. package/dist/core/mcp-server-spec.js +55 -21
  125. package/dist/core/mcp.d.ts +27 -12
  126. package/dist/core/mcp.js +105 -76
  127. package/dist/core/memory-admission.d.ts +23 -6
  128. package/dist/core/memory-admission.js +19 -9
  129. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  130. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  131. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  132. package/dist/core/memory-engine/consolidation.js +1 -0
  133. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  134. package/dist/core/memory-engine/content-origin.js +21 -3
  135. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  136. package/dist/core/memory-engine/distiller.js +2 -2
  137. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  138. package/dist/core/memory-engine/dual-root.js +44 -1
  139. package/dist/core/memory-engine/engine.d.ts +67 -14
  140. package/dist/core/memory-engine/engine.js +384 -212
  141. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  142. package/dist/core/memory-engine/export-bundle.js +23 -4
  143. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  144. package/dist/core/memory-engine/file-backend.js +290 -117
  145. package/dist/core/memory-engine/index.d.ts +3 -2
  146. package/dist/core/memory-engine/index.js +2 -1
  147. package/dist/core/memory-engine/layout.d.ts +59 -11
  148. package/dist/core/memory-engine/layout.js +190 -40
  149. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  150. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  151. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  152. package/dist/core/memory-engine/scope-contract.js +2 -2
  153. package/dist/core/memory-engine/sync-client.d.ts +51 -9
  154. package/dist/core/memory-engine/sync-client.js +107 -13
  155. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  156. package/dist/core/memory-engine/sync-report.js +119 -0
  157. package/dist/core/memory-engine/sync.d.ts +8 -1
  158. package/dist/core/memory-engine/types.d.ts +6 -0
  159. package/dist/core/mode-policy.d.ts +9 -1
  160. package/dist/core/mode-policy.js +11 -1
  161. package/dist/core/model-receipt.d.ts +39 -0
  162. package/dist/core/model-receipt.js +139 -0
  163. package/dist/core/mods/agent-stations.d.ts +65 -0
  164. package/dist/core/mods/agent-stations.js +105 -0
  165. package/dist/core/mods/classic-events.d.ts +5 -1
  166. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  167. package/dist/core/mods/kernel/dispatch.js +6 -5
  168. package/dist/core/mods/kernel/events.d.ts +11 -4
  169. package/dist/core/mods/kernel/events.js +11 -7
  170. package/dist/core/mods/kernel/receive.d.ts +5 -0
  171. package/dist/core/mods/kernel/receive.js +10 -0
  172. package/dist/core/mods/kernel/registration.d.ts +4 -0
  173. package/dist/core/mods/kernel/registration.js +3 -0
  174. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  175. package/dist/core/mods/lifecycle-stations.js +35 -0
  176. package/dist/core/mods/stations.d.ts +73 -60
  177. package/dist/core/mods/stations.js +64 -40
  178. package/dist/core/mods/tool-call.d.ts +10 -4
  179. package/dist/core/mods/tool-call.js +28 -12
  180. package/dist/core/mounted-mcp.d.ts +5 -0
  181. package/dist/core/mounted-mcp.js +2 -2
  182. package/dist/core/namespaced-rule-name.d.ts +7 -1
  183. package/dist/core/namespaced-rule-name.js +13 -2
  184. package/dist/core/oracle-isolation.js +1 -1
  185. package/dist/core/own-property-receipt.d.ts +3 -0
  186. package/dist/core/own-property-receipt.js +3 -0
  187. package/dist/core/parent-spec-seat.d.ts +8 -3
  188. package/dist/core/parent-spec-seat.js +2 -0
  189. package/dist/core/park-selfcheck.js +14 -8
  190. package/dist/core/peer-seat.d.ts +133 -16
  191. package/dist/core/peer-seat.js +319 -42
  192. package/dist/core/permission-rule-consent.d.ts +0 -21
  193. package/dist/core/permission-rule-consent.js +11 -6
  194. package/dist/core/permission-rule-model.d.ts +20 -2
  195. package/dist/core/permission-rule-model.js +8 -7
  196. package/dist/core/present-plan-tool.d.ts +11 -3
  197. package/dist/core/present-plan-tool.js +2 -2
  198. package/dist/core/protocol-http-auth.d.ts +14 -2
  199. package/dist/core/protocol-http-auth.js +16 -7
  200. package/dist/core/read-face-seats.d.ts +7 -5
  201. package/dist/core/read-face-seats.js +4 -1
  202. package/dist/core/redaction-marks.d.ts +4 -3
  203. package/dist/core/redaction-marks.js +2 -2
  204. package/dist/core/remote-env.d.ts +146 -98
  205. package/dist/core/remote-env.js +113 -14
  206. package/dist/core/resume-startup-cause.js +1 -0
  207. package/dist/core/retention.js +37 -12
  208. package/dist/core/retired-keys.d.ts +6 -1
  209. package/dist/core/retired-keys.js +4 -1
  210. package/dist/core/rewrite-rejudge.d.ts +13 -5
  211. package/dist/core/rewrite-rejudge.js +9 -5
  212. package/dist/core/roles.d.ts +69 -3
  213. package/dist/core/roles.js +167 -80
  214. package/dist/core/rule-owner.d.ts +3 -0
  215. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  216. package/dist/core/runner/announce-once-ledger.js +4 -2
  217. package/dist/core/runner/assemble-result.d.ts +0 -5
  218. package/dist/core/runner/assemble-result.js +0 -1
  219. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  220. package/dist/core/runner/call-hook-stations.js +23 -12
  221. package/dist/core/runner/child-tree.d.ts +7 -8
  222. package/dist/core/runner/child-tree.js +6 -6
  223. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  224. package/dist/core/runner/classifier-ladder.js +39 -8
  225. package/dist/core/runner/construction-doors.js +5 -0
  226. package/dist/core/runner/contracts.d.ts +82 -57
  227. package/dist/core/runner/credential-origin-seat.js +4 -3
  228. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  229. package/dist/core/runner/cross-boundary-lane.js +11 -2
  230. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  231. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  232. package/dist/core/runner/decide-continuation.d.ts +2 -2
  233. package/dist/core/runner/env-capability-census.d.ts +15 -20
  234. package/dist/core/runner/env-capability-census.js +25 -34
  235. package/dist/core/runner/file-history-request.d.ts +2 -2
  236. package/dist/core/runner/file-history-request.js +0 -8
  237. package/dist/core/runner/gate-exit.d.ts +87 -11
  238. package/dist/core/runner/gate-exit.js +30 -8
  239. package/dist/core/runner/git-status-frame.d.ts +5 -2
  240. package/dist/core/runner/git-status-frame.js +3 -4
  241. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  242. package/dist/core/runner/image-removed-seat.js +19 -0
  243. package/dist/core/runner/image.d.ts +7 -2
  244. package/dist/core/runner/image.js +14 -8
  245. package/dist/core/runner/inline-image.d.ts +10 -8
  246. package/dist/core/runner/inline-image.js +11 -9
  247. package/dist/core/runner/memory-consolidation-driver.js +5 -5
  248. package/dist/core/runner/park-commit.d.ts +1 -1
  249. package/dist/core/runner/park-commit.js +3 -0
  250. package/dist/core/runner/permission-rule-lanes.js +1 -1
  251. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  252. package/dist/core/runner/prepare-ask-lane.js +2 -1
  253. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  254. package/dist/core/runner/prepare-boundary-parks.js +5 -5
  255. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
  256. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  257. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  258. package/dist/core/runner/prepare-config-doors.js +16 -9
  259. package/dist/core/runner/prepare-context-lane.js +2 -0
  260. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
  261. package/dist/core/runner/prepare-delegation-surface.js +5 -4
  262. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  263. package/dist/core/runner/prepare-file-history.js +3 -12
  264. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  265. package/dist/core/runner/prepare-gate-stations.js +4 -3
  266. package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
  267. package/dist/core/runner/prepare-hands-readface.js +19 -6
  268. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
  269. package/dist/core/runner/prepare-inherited-gate.js +22 -31
  270. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  271. package/dist/core/runner/prepare-memory.d.ts +2 -2
  272. package/dist/core/runner/prepare-memory.js +12 -19
  273. package/dist/core/runner/prepare-park-ask.d.ts +4 -6
  274. package/dist/core/runner/prepare-park-ask.js +5 -9
  275. package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
  276. package/dist/core/runner/prepare-policy-chain.js +136 -121
  277. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  278. package/dist/core/runner/prepare-project-context.js +10 -7
  279. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
  280. package/dist/core/runner/prepare-prompt-inputs.js +10 -20
  281. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  282. package/dist/core/runner/prepare-protocol-tools.js +17 -2
  283. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  284. package/dist/core/runner/prepare-run-refs.js +4 -1
  285. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  286. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  287. package/dist/core/runner/prepare-task.js +44 -28
  288. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  289. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  290. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
  291. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  292. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  293. package/dist/core/runner/reply-pricing.d.ts +30 -0
  294. package/dist/core/runner/reply-pricing.js +19 -0
  295. package/dist/core/runner/resume-admission.js +4 -2
  296. package/dist/core/runner/resume-apply.js +6 -1
  297. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  298. package/dist/core/runner/resume-policy-outcome.js +5 -5
  299. package/dist/core/runner/retired-runner-deps.js +4 -1
  300. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  301. package/dist/core/runner/role-seat-defaulted.js +40 -0
  302. package/dist/core/runner/run-attachment-seats.js +3 -3
  303. package/dist/core/runner/run-brain-sinks.js +3 -0
  304. package/dist/core/runner/run-git-lane.d.ts +3 -1
  305. package/dist/core/runner/run-git-lane.js +1 -1
  306. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  307. package/dist/core/runner/run-harness-handlers.js +3 -1
  308. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  309. package/dist/core/runner/run-identity-wiring.js +6 -5
  310. package/dist/core/runner/run-leg.d.ts +2 -0
  311. package/dist/core/runner/run-leg.js +63 -56
  312. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  313. package/dist/core/runner/run-notification-lane.js +16 -10
  314. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  315. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  316. package/dist/core/runner/run-stop-and-final-verify.js +14 -6
  317. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  318. package/dist/core/runner/run-terminal-adoption.js +9 -3
  319. package/dist/core/runner/run-turn-boundary.js +89 -77
  320. package/dist/core/runner/runtask.d.ts +8 -5
  321. package/dist/core/runner/runtask.js +21 -13
  322. package/dist/core/runner/side-call-account.d.ts +1 -1
  323. package/dist/core/runner/side-call-account.js +3 -18
  324. package/dist/core/runner/skills-seat.js +2 -2
  325. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  326. package/dist/core/runner/sub-agent-deny-lists.js +20 -7
  327. package/dist/core/runner/synthetic-tools.js +2 -2
  328. package/dist/core/runner/tool-disclosure.js +0 -2
  329. package/dist/core/runner/tool-end-body.js +2 -2
  330. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  331. package/dist/core/runner/tool-face-overlay.js +26 -19
  332. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  333. package/dist/core/runner/tool-occurrence.js +2 -2
  334. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  335. package/dist/core/runner/tool-result-media-seat.js +17 -1
  336. package/dist/core/runner/turn-attachments.d.ts +29 -27
  337. package/dist/core/runner/turn-attachments.js +27 -42
  338. package/dist/core/runner-deps.d.ts +32 -19
  339. package/dist/core/secret-env.d.ts +35 -4
  340. package/dist/core/secret-env.js +65 -3
  341. package/dist/core/sensitive-path-policy.js +3 -3
  342. package/dist/core/session-policy-store.d.ts +12 -3
  343. package/dist/core/session-policy-store.js +29 -10
  344. package/dist/core/session-store.d.ts +5 -7
  345. package/dist/core/session-store.js +50 -11
  346. package/dist/core/side-query.d.ts +11 -1
  347. package/dist/core/side-query.js +9 -0
  348. package/dist/core/skill-grant-binding.d.ts +31 -2
  349. package/dist/core/skill-grant-binding.js +31 -1
  350. package/dist/core/skill-grant.d.ts +17 -5
  351. package/dist/core/skill-grant.js +24 -6
  352. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  353. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  354. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  355. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  356. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  357. package/dist/core/stub-env.d.ts +5 -5
  358. package/dist/core/stub-env.js +11 -1
  359. package/dist/core/swappable-deps.d.ts +17 -43
  360. package/dist/core/swappable-deps.js +15 -5
  361. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  362. package/dist/core/synthetic-read-verdict.js +2 -1
  363. package/dist/core/task-event.d.ts +50 -10
  364. package/dist/core/task-notification.d.ts +88 -5
  365. package/dist/core/task-notification.js +146 -17
  366. package/dist/core/task-registry-agent.d.ts +18 -12
  367. package/dist/core/task-registry-agent.js +19 -6
  368. package/dist/core/task-registry-monitor.d.ts +7 -0
  369. package/dist/core/task-registry-monitor.js +28 -1
  370. package/dist/core/task-registry-shared.d.ts +43 -3
  371. package/dist/core/task-registry-shared.js +21 -7
  372. package/dist/core/task-registry-workflow.js +1 -1
  373. package/dist/core/task-registry.d.ts +50 -35
  374. package/dist/core/task-registry.js +64 -23
  375. package/dist/core/task-result.d.ts +3 -12
  376. package/dist/core/task-spec.d.ts +15 -7
  377. package/dist/core/task-stream.d.ts +1 -1
  378. package/dist/core/terminal-cause.d.ts +10 -0
  379. package/dist/core/tool-catalog-entries.js +1 -1
  380. package/dist/core/tool-check-reading.d.ts +1 -0
  381. package/dist/core/tool-check-reading.js +3 -3
  382. package/dist/core/tool-face-reader.d.ts +7 -6
  383. package/dist/core/tool-face-reader.js +4 -3
  384. package/dist/core/tool-name-aliases.d.ts +19 -0
  385. package/dist/core/tool-name-aliases.js +54 -2
  386. package/dist/core/tool-policy.d.ts +21 -4
  387. package/dist/core/tool-policy.js +1 -1
  388. package/dist/core/tool-registry.d.ts +5 -5
  389. package/dist/core/tool-registry.js +2 -2
  390. package/dist/core/tool-result-store.d.ts +88 -5
  391. package/dist/core/tool-result-store.js +51 -12
  392. package/dist/core/tool-roster.d.ts +112 -5
  393. package/dist/core/tool-roster.js +42 -1
  394. package/dist/core/tool-spec.d.ts +23 -5
  395. package/dist/core/trace.d.ts +0 -1
  396. package/dist/core/types.d.ts +5 -5
  397. package/dist/core/types.js +2 -2
  398. package/dist/core/untrusted-text.js +1 -1
  399. package/dist/core/user-attachment.d.ts +10 -5
  400. package/dist/core/user-attachment.js +15 -7
  401. package/dist/core/wiring-manifest.d.ts +6 -3
  402. package/dist/engine/compaction/compaction.js +29 -3
  403. package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
  404. package/dist/engine/execution-env/node-execution-env.js +21 -13
  405. package/dist/engine/harness/agent-harness.d.ts +26 -3
  406. package/dist/engine/harness/agent-harness.js +49 -16
  407. package/dist/engine/harness/messages.d.ts +3 -1
  408. package/dist/engine/harness/messages.js +3 -2
  409. package/dist/engine/harness/types.d.ts +119 -28
  410. package/dist/engine/llm/rejected-images.d.ts +46 -0
  411. package/dist/engine/llm/rejected-images.js +54 -0
  412. package/dist/engine/llm/tool-turns.d.ts +2 -1
  413. package/dist/engine/llm/types.d.ts +18 -7
  414. package/dist/engine/loop/agent-loop.d.ts +20 -12
  415. package/dist/engine/loop/agent-loop.js +205 -36
  416. package/dist/engine/loop/types.d.ts +12 -3
  417. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  418. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  419. package/dist/engine/session/path-to-root.d.ts +38 -0
  420. package/dist/engine/session/path-to-root.js +39 -0
  421. package/dist/engine/session/storage-base.js +4 -21
  422. package/dist/index.d.ts +35 -21
  423. package/dist/index.js +26 -17
  424. package/dist/internal/harness-types.d.ts +1 -1
  425. package/dist/internal/harness.d.ts +1 -0
  426. package/dist/internal/llm.d.ts +1 -0
  427. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  428. package/dist/orchestration/run-workflow-tool.js +59 -29
  429. package/dist/orchestration/workflow-governance.d.ts +1 -1
  430. package/dist/orchestration/workflow-governance.js +2 -1
  431. package/dist/orchestration/workflow-observe.d.ts +17 -1
  432. package/dist/orchestration/workflow-observe.js +20 -0
  433. package/dist/orchestration/workflow-types.d.ts +32 -7
  434. package/dist/orchestration/workflow.d.ts +4 -0
  435. package/dist/orchestration/workflow.js +762 -491
  436. package/dist/prompts/default.d.ts +1 -10
  437. package/dist/prompts/default.js +0 -2
  438. package/dist/shell/counting-pass.d.ts +50 -0
  439. package/dist/shell/counting-pass.js +502 -0
  440. package/dist/shell/lex.d.ts +4 -2
  441. package/dist/shell/lex.js +93 -34
  442. package/dist/shell/shell-words.d.ts +1 -1
  443. package/dist/shell/shell-words.js +7 -6
  444. package/dist/stores/file/background-agent-store.d.ts +1 -1
  445. package/dist/stores/file/background-agent-store.js +3 -1
  446. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  447. package/dist/stores/file/checkpoint-store.js +19 -14
  448. package/dist/stores/file/file-history-store.d.ts +1 -1
  449. package/dist/stores/file/file-history-store.js +3 -1
  450. package/dist/stores/file/index.d.ts +4 -3
  451. package/dist/stores/file/index.js +17 -8
  452. package/dist/stores/file/mailbox-store.d.ts +1 -1
  453. package/dist/stores/file/mailbox-store.js +9 -11
  454. package/dist/stores/file/memory-store.d.ts +1 -1
  455. package/dist/stores/file/memory-store.js +3 -1
  456. package/dist/stores/file/session-policy-store.d.ts +1 -1
  457. package/dist/stores/file/session-policy-store.js +3 -1
  458. package/dist/stores/file/session-store.d.ts +1 -1
  459. package/dist/stores/file/session-store.js +3 -1
  460. package/dist/stores/file/shared-ledger.d.ts +26 -0
  461. package/dist/stores/file/shared-ledger.js +38 -9
  462. package/dist/stores/file/tool-result-store.d.ts +20 -2
  463. package/dist/stores/file/tool-result-store.js +74 -6
  464. package/dist/stores/file/usage-window-store.d.ts +1 -1
  465. package/dist/stores/file/usage-window-store.js +3 -1
  466. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  467. package/dist/stores/file/workflow-journal-store.js +3 -2
  468. package/dist/tools/fs/containment-face.d.ts +5 -0
  469. package/dist/tools/fs/encoding.d.ts +13 -4
  470. package/dist/tools/fs/encoding.js +17 -2
  471. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  472. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  473. package/dist/tools/fs/fs-bash.d.ts +14 -4
  474. package/dist/tools/fs/fs-bash.js +29 -35
  475. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  476. package/dist/tools/fs/fs-pdf.js +26 -21
  477. package/dist/tools/fs/fs-read.d.ts +5 -4
  478. package/dist/tools/fs/fs-read.js +35 -18
  479. package/dist/tools/fs/fs-search-tools.js +4 -1
  480. package/dist/tools/fs/fs-shared.d.ts +11 -13
  481. package/dist/tools/fs/fs-shared.js +11 -7
  482. package/dist/tools/fs/fs-write.js +5 -5
  483. package/dist/tools/fs/index.d.ts +14 -8
  484. package/dist/tools/fs/index.js +13 -5
  485. package/dist/tools/fs/program-read-model.d.ts +13 -0
  486. package/dist/tools/fs/program-read-model.js +15 -0
  487. package/dist/tools/fs/program-read-model.rows.js +1 -1
  488. package/dist/tools/fs/read-deny.d.ts +13 -10
  489. package/dist/tools/fs/read-deny.js +25 -5
  490. package/dist/tools/fs/read-floor.d.ts +62 -0
  491. package/dist/tools/fs/read-floor.js +58 -0
  492. package/dist/tools/fs/removal-targets.d.ts +9 -4
  493. package/dist/tools/fs/removal-targets.js +17 -9
  494. package/dist/tools/fs/search.d.ts +3 -3
  495. package/dist/tools/fs/search.js +4 -4
  496. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  497. package/dist/tools/fs/shell-read-check.js +2 -1
  498. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  499. package/dist/tools/fs/shell-read-judge.js +10 -6
  500. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  501. package/dist/tools/fs/shell-read-plan.js +22 -15
  502. package/dist/tools/fs/shell-read-start.js +1 -0
  503. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  504. package/dist/tools/fs/shell-reentry-text.js +25 -3
  505. package/dist/tools/monitor.d.ts +9 -4
  506. package/dist/tools/monitor.js +17 -8
  507. package/dist/tools/scheduler-tools.js +42 -4
  508. package/dist/tools/web.d.ts +0 -10
  509. package/dist/tools/web.js +1 -4
  510. package/package.json +5 -2
  511. package/test/export-surface.snapshot.json +161 -21
  512. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  513. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  514. package/wire-changes/core@7.59.0.json +2459 -0
  515. package/wire-changes/core@7.60.0.json +3274 -0
  516. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  517. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  518. package/wire-changes/primitives@7.59.0.json +29 -0
  519. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -158,6 +158,22 @@ export interface ToolCallRequest {
158
158
  * Read-only.
159
159
  */
160
160
  approvalReach?: import("./wiring-manifest.js").ApprovalReach;
161
+ /**
162
+ * What answering this call grants beyond the call — the binding words every card of the call carries ({@link AskRequest.boundGrantDigest} /
163
+ * {@link AskRequest.boundGrants} / {@link AskRequest.boundGrantAbsence}), minted by the same factory over THIS request's `args`: a call to the
164
+ * engine's `Skill` tool on a leg that loads skills carries the digest and the value it hashes, every other call `not_bindable`. Exactly one
165
+ * arm on every request a Runner hands a policy (the gate's adjudication, the resume belt, the park's stored-shape re-check, the pre-claim
166
+ * edit re-check, the synthetic probes, and every copy a policy fold makes over moved args — the copy carries the answer for ITS args);
167
+ * absent on a bare request (a host driving a policy outside a Runner), which a reader takes as a binding it cannot read. `unreadable` on a
168
+ * request = it binds a grant and what it binds over these args cannot be read here (a copy over moved args whose digest the engine did
169
+ * not mint for this call — `withArgsBinding`). A policy that keeps an answer by tool name reads these words, never the tool name.
170
+ * Read-only metadata: no engine judgment reads them (a parked approval is judged by its row's digest).
171
+ */
172
+ boundGrantDigest?: string;
173
+ /** The value {@link boundGrantDigest} hashes; same presence (see there). Deployment text — render with contextual escaping. */
174
+ boundGrants?: import("./skill-grant-binding.js").BoundSkillGrants;
175
+ /** Why this request carries no {@link boundGrantDigest} — the closed set `BOUND_GRANT_ABSENCES` (see there). */
176
+ boundGrantAbsence?: import("./skill-grant-binding.js").BoundGrantAbsence;
161
177
  /**
162
178
  * design/80 D-E-core: read-only per-run budget snapshot so a STATELESS policy can self-limit against
163
179
  * state that survives suspend/resume (a fresh in-memory counter would reset every leg — the supervisor
@@ -782,9 +798,9 @@ export type ConstraintChainEntry = ConstraintChainEntryMeta & ({
782
798
  components: readonly ToolPolicyProjectionComponent[];
783
799
  requiresLiveRemainder: boolean;
784
800
  });
785
- /** Project one policy into its chain entry (opaque placeholder when it exports no projection),
786
- * carrying the layer's decision-chain metadata posture for the digest (round 12). */
787
- export declare function constraintChainEntryOf(policy: ToolPolicy, meta?: ConstraintChainEntryMeta): ConstraintChainEntry;
801
+ /** Project one chain entry's policy into its chain entry (opaque placeholder when it exports no projection, and for a
802
+ * screening installation, which has no policy), carrying the layer's decision-chain metadata posture for the digest (round 12). */
803
+ export declare function constraintChainEntryOf(policy: ToolPolicy | undefined, meta?: ConstraintChainEntryMeta): ConstraintChainEntry;
788
804
  /**
789
805
  * One inherited-chain LAYER as both chain-entry mint sites see it — structurally an
790
806
  * `InheritedGate.parentConstraints[]` element, typed here structurally so this module (which owns the
@@ -792,7 +808,8 @@ export declare function constraintChainEntryOf(policy: ToolPolicy, meta?: Constr
792
808
  * state between rounds, so nothing about its health enters a chain entry.
793
809
  */
794
810
  export interface ConstraintChainLayerView {
795
- policy: ToolPolicy;
811
+ /** Absent on a screening installation (projected opaque, as its judgments live on its own bus). */
812
+ policy?: ToolPolicy | undefined;
796
813
  autoMode?: {
797
814
  arming?: unknown;
798
815
  };
@@ -187,7 +187,7 @@ export function constraintChainEntryOf(policy, meta) {
187
187
  ...(meta?.durableMandate ? { durableMandate: true } : {}),
188
188
  ...(meta?.contentMandate ? { contentMandate: true } : {}),
189
189
  };
190
- const p = policy.projection;
190
+ const p = policy?.projection;
191
191
  if (p === undefined)
192
192
  return { opaque: true, ...m };
193
193
  return { components: p.components, requiresLiveRemainder: p.requiresLiveRemainder, ...m };
@@ -43,14 +43,14 @@ export interface PersistenceFacts {
43
43
  readonly exclude?: readonly string[];
44
44
  /** The leg's by-name effect map: the fallback for a tool that declares no `effect` of its own (silent ⇒ `"write"`). */
45
45
  readonly effects?: ReadonlyMap<string, import("./tool-spec.js").ToolEffect>;
46
- /** The hand band is mounted on a REMOTE env: its file tools write the sandbox filesystem, not the host-side memory
47
- * root, so their presence proves nothing about persistence there. */
48
- readonly remoteHands: boolean;
46
+ /** The hand band is mounted on an env whose paths are not the host's (`pathsAreHostLocal` is false): its file tools
47
+ * write that filesystem, not the host-side memory root, so their presence proves nothing about persistence there. */
48
+ readonly handsOffHost: boolean;
49
49
  }
50
50
  /**
51
51
  * The names, among a run's MOUNTED tools (instances, whose face members sit on the object itself), the persistence
52
52
  * judgment passes. The judgment's inputs beyond the tools (the exclude snapshot, the by-name effect map, whether the
53
- * hand band is remote) are leg facts only the run holds; {@link rosterCanPersistMemory} is the verdict built on it.
53
+ * hand band is off the host's disk) are leg facts only the run holds; {@link rosterCanPersistMemory} is the verdict built on it.
54
54
  */
55
55
  export declare function persistenceCapableToolNames(tools: ReadonlyArray<PersistenceProbeTool>, facts: PersistenceFacts): string[];
56
56
  /**
@@ -61,7 +61,7 @@ export declare function persistenceCapableToolNames(tools: ReadonlyArray<Persist
61
61
  export declare function rosterCanPersistMemory(tools: ReadonlyArray<PersistenceProbeTool>, facts: PersistenceFacts, declared?: boolean): boolean;
62
62
  /**
63
63
  * The CANDIDATE set, from the static catalog alone: the names whose definition passes the same judgment on no leg
64
- * facts at all (nothing excluded, no by-name effect map, hands not remote) — the tools that COULD persist on a leg
64
+ * facts at all (nothing excluded, no by-name effect map, hands on the host's disk) — the tools that COULD persist on a leg
65
65
  * that mounts them. A prediction, not a verdict: whether a given run's roster persists is
66
66
  * {@link rosterCanPersistMemory}, which the runner calls with the facts the run holds.
67
67
  */
@@ -36,7 +36,7 @@ function toolCanPersist(t, facts) {
36
36
  const family = t.family ?? catalogEntriesNamed(t.name)[0]?.face.family;
37
37
  if (!((pathTarget !== undefined && pathTarget.access !== "read") || family === "shell"))
38
38
  return false;
39
- return !facts.remoteHands;
39
+ return !facts.handsOffHost;
40
40
  }
41
41
  export function persistenceCapableToolNames(tools, facts) {
42
42
  const out = new Set();
@@ -50,7 +50,7 @@ export function rosterCanPersistMemory(tools, facts, declared) {
50
50
  }
51
51
  export function persistenceCandidateToolNames() {
52
52
  const rows = TOOL_CATALOG_ENTRIES.map((e) => ({ name: e.name, effect: e.face.effect, pathTarget: e.face.pathTarget, family: e.face.family }));
53
- return persistenceCapableToolNames(rows, { remoteHands: false });
53
+ return persistenceCapableToolNames(rows, { handsOffHost: false });
54
54
  }
55
55
  export function pathTargetingToolNames() {
56
56
  return names((e) => e.face.pathTarget !== undefined);
@@ -118,6 +118,52 @@ export interface ToolResultStore {
118
118
  * audit receipts, scheduled execution), of which this is one caller-driven erase.
119
119
  */
120
120
  deleteBySession?(sessionId: string): Promise<ToolResultDeletionReport> | ToolResultDeletionReport;
121
+ /**
122
+ * The READ half of the same ownership coordinate {@link deleteBySession} erases by: every entry this store recorded as belonging to
123
+ * `sessionId`, as the ref and the owner recorded at its winning write. Without it the offloaded results a session's transcript
124
+ * points at have no way out of a store, so a session moved to another store reads references it cannot dereference.
125
+ *
126
+ * The listing is the whole of the export: the bytes are read with {@link get} (bounded slices; `totalChars` says how much) and
127
+ * land in the other store with `put(ref, content, entry.provenance)` — that store's write-once election makes a repeated move an
128
+ * idempotent no-op and a ref that already belongs to a different owner a typed refusal ({@link ToolResultRefConflictError}).
129
+ * There is no second path for content.
130
+ *
131
+ * Rules every implementation follows, the same selection as {@link deleteBySession}:
132
+ * - **selection is by RECORDED PROVENANCE, never by parsing the ref**; `taskId` is ignored in the match (the entry's
133
+ * `provenance` still carries the one that was recorded — it is the very owner the importing `put` states);
134
+ * - **an UNOWNED entry is never listed**: it belongs to no session this call can name. It is counted in
135
+ * {@link ToolResultSessionListing.unattributable} (store-wide, the same figure a sweep reports), so a caller learns the
136
+ * listing cannot speak for such rows rather than being told a clean "that is all";
137
+ * - an entry the session owns but whose ref the store cannot name — only an entry written before the store recorded the ref beside
138
+ * it — is counted in {@link ToolResultSessionListing.unaddressable}, never listed under a guessed ref;
139
+ * - the listing is a snapshot with no order promised; an entry that disappears before the caller reads it is honest absence
140
+ * (`get` answers `undefined`), and a listing of a session with no entries is empty, not an error.
141
+ *
142
+ * Typed OPTIONAL, and an OPTIONAL leg of the published contract kit (`toolResultStoreContract`): a store that cannot enumerate
143
+ * by owner is still a usable offload store, so absence is a checkable fact reported through `onOptionalMember`, never a
144
+ * contract breach. Implementing it does NOT make a store `retention: "managed"`.
145
+ */
146
+ listBySession?(sessionId: string): Promise<ToolResultSessionListing> | ToolResultSessionListing;
147
+ }
148
+ /** One entry a {@link ToolResultStore.listBySession} listing names: the ref and the owner recorded at its winning write — the two
149
+ * arguments an importing store's `put` takes beside the content `get` returns. */
150
+ export interface ToolResultListedEntry {
151
+ readonly ref: string;
152
+ readonly provenance: ToolResultProvenance;
153
+ }
154
+ /** What a {@link ToolResultStore.listBySession} call answers. */
155
+ export interface ToolResultSessionListing {
156
+ /** The session's entries, in no particular order. */
157
+ readonly entries: readonly ToolResultListedEntry[];
158
+ /** Entries the store could not attribute to ANY session (stored without provenance, or with an unreadable owner record) and so did
159
+ * not list: store-wide, the same figure {@link ToolResultDeletionReport.unattributable} reports. */
160
+ readonly unattributable: number;
161
+ /** Entries the session owns whose ref this store cannot name, so they are not listed. It counts ONE thing only — entries written
162
+ * before the store recorded the ref beside the entry (a file backend's folded file name is a digest of the ref, and the owner record
163
+ * it writes now carries the ref; records written by earlier versions do not). It is not a second kind of entry: a store whose
164
+ * entries were all written by a version that records the ref reports `0`, always. Such an entry is still removed by
165
+ * {@link ToolResultStore.deleteBySession}, so `entries.length + unaddressable` is the number a sweep of the session then deletes. */
166
+ readonly unaddressable: number;
121
167
  }
122
168
  /**
123
169
  * What a {@link ToolResultStore.deleteBySession} sweep actually did. A count, not a `void`, because the
@@ -275,6 +321,11 @@ export declare function assertSafeToolResultRef(ref: string): void;
275
321
  * matches.
276
322
  */
277
323
  export declare function buildToolResultRef(sessionId: string, toolCallId: string, ...extraSegments: string[]): string;
324
+ /** The task whose result `ref` holds, read off the segment {@link buildTaskArtifactRef} put it in — `undefined` for every other
325
+ * ref, which by construction is not a task's result (only that mint carries {@link TASK_ARTIFACT_SEGMENT}). An origin, never an
326
+ * owner: who may read the bytes is still {@link ToolResultStore.ownerOf}'s answer. A task id the mint had to fold comes back as
327
+ * its folded segment, which names no task — the reading of a task that is gone. */
328
+ export declare function taskArtifactOriginOf(ref: string): string | undefined;
278
329
  /**
279
330
  * Backlog #119 — the ceiling on a ref this module can mint, so a durable backend can size its key
280
331
  * column from a stated invariant instead of a guess (TiDB's was `VARCHAR(191)`, which a long
@@ -320,7 +371,6 @@ export interface ToolResultSlice {
320
371
  * on the existing honest "may have expired" text). Durability across restarts still requires a real
321
372
  * store (e.g. FileToolResultStore) via `RunnerDeps.toolResultStore`. */
322
373
  export declare class InMemoryToolResultStore implements ToolResultStore {
323
- private readonly opts?;
324
374
  /** Managed-retention declaration (retention.ts): whether this store's rows are deleted on schedule by the deployment — given by
325
375
  * the party that runs the sweep (the `retention` option), `"none"` when none is given; the store itself is put/get only. */
326
376
  readonly retention: RetentionDeclaration;
@@ -330,10 +380,12 @@ export declare class InMemoryToolResultStore implements ToolResultStore {
330
380
  private totalChars;
331
381
  /** @param opts.retention the store's managed-retention declaration, default `"none"`; a word other than the two is refused
332
382
  * (`config.retention_capability`). */
333
- constructor(opts?: {
383
+ /** The bound, read once at construction by the integer reading (`undefined` = unbounded): the one value the eviction enforces. */
384
+ private readonly maxTotalChars;
385
+ constructor(options?: {
334
386
  maxTotalChars?: number;
335
387
  retention?: RetentionDeclaration;
336
- } | undefined);
388
+ });
337
389
  put(ref: string, content: string, provenance?: ToolResultProvenance): void;
338
390
  /** The owner recorded at the winning write; `undefined` for unknown AND for unowned entries,
339
391
  * which a read face treats identically (fail-closed). */
@@ -344,6 +396,9 @@ export declare class InMemoryToolResultStore implements ToolResultStore {
344
396
  * same provenance match applies with none of the file backend's two-object bookkeeping. Deleting
345
397
  * from a Map while iterating it is defined (a removed key is simply not revisited). */
346
398
  deleteBySession(sessionId: string): ToolResultDeletionReport;
399
+ /** This session's entries, selected on the owner recorded at the winning write — the very match {@link deleteBySession} runs (the
400
+ * interface states the rules). The ref is the map key, so every owned entry is nameable. */
401
+ listBySession(sessionId: string): ToolResultSessionListing;
347
402
  /** design/80 D-2: true when NOTHING has been offloaded — a durable suspend can then proceed safely even on
348
403
  * this in-memory store, because a cross-replica resume has no offloaded result to deref to null. */
349
404
  isEmpty(): boolean;
@@ -431,6 +486,30 @@ onNotice?: (notice: import("./types.js").EngineNotice) => void): (toolCallId: st
431
486
  * already has in hand. `taskId` is omitted (not `undefined`-valued) when the run declares none, so the
432
487
  * stored shape compares equal across a durable round-trip. */
433
488
  export declare function toolResultProvenanceOf(sessionId: string, taskId?: string): ToolResultProvenance;
489
+ /** Where a background task's result is written when its completion notification carries less than the whole of it: the
490
+ * offload store the receiving run's {@link OFFLOAD_TOOL_NAME} reads, and the session that run's refs are minted under. */
491
+ export interface TaskArtifactSeat {
492
+ readonly store: ToolResultStore;
493
+ readonly sessionId: string;
494
+ }
495
+ /** What {@link persistTaskArtifact} answers: the ref the text is stored under, a write that failed or went unconfirmed
496
+ * (no ref — a ref nobody can read back is a false promise), or no store to write to. */
497
+ export type TaskArtifact = {
498
+ readonly kind: "stored";
499
+ readonly ref: string;
500
+ } | {
501
+ readonly kind: "unconfirmed";
502
+ } | {
503
+ readonly kind: "no_store";
504
+ };
505
+ /**
506
+ * THE one write of a background task's result artifact. The ref is CONTENT-ADDRESSED (task id + a digest of the text):
507
+ * two cycles of one task with different answers get different refs, and the same answer written twice lands on the same
508
+ * write-once row — no cycle number is read, so a row reseeded after a restart (whose cycle counter restarts) cannot
509
+ * land a new answer on an old ref. The put is awaited before the answer is returned, so a caller that announces the ref
510
+ * announces a write that already landed.
511
+ */
512
+ export declare function persistTaskArtifact(seat: TaskArtifactSeat | undefined, taskId: string, text: string): Promise<TaskArtifact>;
434
513
  /**
435
514
  * RB-374① — the ONE source of the "page the offloaded text back" suggestion sentence, shared by
436
515
  * {@link buildPreview} (offload preview tail) and context-edit's cleared-marker refNote. The two
@@ -495,5 +574,9 @@ export declare const OFFLOADED_DETAIL_NOTICE_PREFIX = "\u2026[offloaded \u2014 "
495
574
  /** True when `s` carries an offloaded-detail replacement notice (the newline-anchored prefix form the
496
575
  * walk emits). A semantic consumer treats such a string as NOT the member's real bytes. */
497
576
  export declare function isOffloadedDetailReplacement(s: string): boolean;
498
- /** The injected `read_tool_result` tool: pages through an offloaded result. `effect:"read"` (verifier/reconcile-safe). */
499
- export declare function createReadToolResultTool(store: ToolResultStore): AgentTool;
577
+ /** The injected `read_tool_result` tool: pages through an offloaded result. `effect:"read"` (verifier/reconcile-safe).
578
+ * `legsOfRef` = the legs a page-back of one ref travels: a ref holding a background task's result (`persistTaskArtifact`, its
579
+ * origin in the ref — {@link taskArtifactOriginOf}) travels the legs a poll of that task travels — content from another tree is
580
+ * an off-target read however it is read back — and the registry's reading answers it; absent, or for any other ref (offloaded
581
+ * tool output), none. */
582
+ export declare function createReadToolResultTool(store: ToolResultStore, legsOfRef?: (ref: string, tree: import("./cross-boundary-taint.js").CrossBoundaryTreeToken) => import("./cross-boundary-taint.js").BoundaryLegsGiven): AgentTool;
@@ -8,6 +8,8 @@ import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
8
8
  import { thrownText } from "./thrown-value.js";
9
9
  import { readRetentionDeclaration } from "./retention.js";
10
10
  import { carryNotStartedReceipt } from "./delegation-not-started.js";
11
+ import { receiveOptions } from "./own-property-receipt.js";
12
+ import { NON_NEGATIVE_SAFE_INTEGER, readIntegerOption } from "./integer-option.js";
11
13
  export const TOOL_RESULT_REF_CONFLICT_CODE = "tool_result.ref_conflict";
12
14
  export class ToolResultRefConflictError extends Error {
13
15
  ref;
@@ -51,7 +53,18 @@ const MAX_REF_SEGMENT_CHARS = 128;
51
53
  const REF_SEGMENT_SEPARATOR = "~";
52
54
  const FOLDED_SEGMENT_PREFIX = "fold.";
53
55
  export function buildToolResultRef(sessionId, toolCallId, ...extraSegments) {
54
- return [`tr_${refSegment(sessionId)}`, refSegment(toolCallId), ...extraSegments.map(refSegment)].join(REF_SEGMENT_SEPARATOR);
56
+ return composeToolResultRef(sessionId, [toolCallId, ...extraSegments].map(refSegment));
57
+ }
58
+ function composeToolResultRef(sessionId, segments) {
59
+ return [`tr_${refSegment(sessionId)}`, ...segments].join(REF_SEGMENT_SEPARATOR);
60
+ }
61
+ const TASK_ARTIFACT_SEGMENT = `${FOLDED_SEGMENT_PREFIX}task`;
62
+ function buildTaskArtifactRef(sessionId, taskId, text) {
63
+ return composeToolResultRef(sessionId, [TASK_ARTIFACT_SEGMENT, ...[taskId, toolResultContentSegment(text)].map(refSegment)]);
64
+ }
65
+ export function taskArtifactOriginOf(ref) {
66
+ const segments = ref.split(REF_SEGMENT_SEPARATOR);
67
+ return segments[1] === TASK_ARTIFACT_SEGMENT ? segments[2] : undefined;
55
68
  }
56
69
  function refSegment(raw) {
57
70
  if (raw.length <= MAX_REF_SEGMENT_CHARS && NATIVE_REF_CHARSET.test(raw) && !raw.startsWith(FOLDED_SEGMENT_PREFIX))
@@ -67,17 +80,14 @@ function digestOfString(s) {
67
80
  return createHash("sha256").update(Buffer.from(s, "utf16le")).digest("hex");
68
81
  }
69
82
  export class InMemoryToolResultStore {
70
- opts;
71
83
  retention;
72
84
  map = new Map();
73
85
  totalChars = 0;
74
- constructor(opts) {
75
- this.opts = opts;
76
- this.retention = readRetentionDeclaration("InMemoryToolResultStore.retention", opts?.retention);
77
- const cap = opts?.maxTotalChars;
78
- if (cap !== undefined && Number.isNaN(cap)) {
79
- throw new Error("InMemoryToolResultStore: maxTotalChars must be a number (got NaN) — omit it for an unbounded store");
80
- }
86
+ maxTotalChars;
87
+ constructor(options) {
88
+ const opts = receiveOptions(options, "InMemoryToolResultStore");
89
+ this.retention = readRetentionDeclaration("InMemoryToolResultStore.retention", opts.retention);
90
+ this.maxTotalChars = readIntegerOption("InMemoryToolResultStore.maxTotalChars", opts.maxTotalChars, NON_NEGATIVE_SAFE_INTEGER, "characters", "an unbounded store");
81
91
  }
82
92
  put(ref, content, provenance) {
83
93
  assertSafeToolResultRef(ref);
@@ -88,8 +98,8 @@ export class InMemoryToolResultStore {
88
98
  }
89
99
  this.map.set(ref, provenance === undefined ? { content } : { content, provenance: normalizeToolResultProvenance(provenance) });
90
100
  this.totalChars += content.length;
91
- const cap = this.opts?.maxTotalChars;
92
- if (cap !== undefined && Number.isFinite(cap)) {
101
+ const cap = this.maxTotalChars;
102
+ if (cap !== undefined) {
93
103
  for (const [oldRef, oldEntry] of this.map) {
94
104
  if (this.totalChars <= cap || oldRef === ref)
95
105
  break;
@@ -117,6 +127,19 @@ export class InMemoryToolResultStore {
117
127
  }
118
128
  return { deleted, unattributable };
119
129
  }
130
+ listBySession(sessionId) {
131
+ const entries = [];
132
+ let unattributable = 0;
133
+ for (const [ref, entry] of this.map) {
134
+ if (entry.provenance === undefined) {
135
+ unattributable++;
136
+ continue;
137
+ }
138
+ if (entry.provenance.sessionId === sessionId)
139
+ entries.push({ ref, provenance: { ...entry.provenance } });
140
+ }
141
+ return { entries, unattributable, unaddressable: 0 };
142
+ }
120
143
  isEmpty() {
121
144
  return this.map.size === 0;
122
145
  }
@@ -198,6 +221,18 @@ export function createOffloadPersist(store, sessionId, onNotice) {
198
221
  export function toolResultProvenanceOf(sessionId, taskId) {
199
222
  return taskId === undefined ? { sessionId } : { sessionId, taskId };
200
223
  }
224
+ export async function persistTaskArtifact(seat, taskId, text) {
225
+ if (seat === undefined)
226
+ return { kind: "no_store" };
227
+ const ref = buildTaskArtifactRef(seat.sessionId, taskId, text);
228
+ try {
229
+ await seat.store.put(ref, text, toolResultProvenanceOf(seat.sessionId));
230
+ }
231
+ catch {
232
+ return { kind: "unconfirmed" };
233
+ }
234
+ return { kind: "stored", ref };
235
+ }
201
236
  export function offloadPagebackHint(ref, form, reachableTools) {
202
237
  const activate = reachableTools !== undefined && !reachableTools.has(OFFLOAD_TOOL_NAME)
203
238
  ? `${OFFLOAD_TOOL_NAME} is not active yet — call ${TOOL_SEARCH_NAME} with {"query":"select:${OFFLOAD_TOOL_NAME}"} to activate it, then `
@@ -386,11 +421,15 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
386
421
  };
387
422
  return { value: finalize(value) };
388
423
  }
389
- export function createReadToolResultTool(store) {
424
+ export function createReadToolResultTool(store, legsOfRef) {
390
425
  return defineTool({
391
426
  name: OFFLOAD_TOOL_NAME,
392
427
  ...toolFace("read-tool-result"),
393
428
  ruleFace: mountRuleFace("read-tool-result"),
429
+ boundaryLegsFor: (rawArgs, at) => {
430
+ const ref = rawArgs?.ref;
431
+ return typeof ref === "string" && legsOfRef !== undefined ? legsOfRef(ref, at.tree) : { legs: [] };
432
+ },
394
433
  description: `Read the full content of a tool result that was too large and persisted (you saw it as ` +
395
434
  `<persisted-output ref="..."> with a preview). Pass the ref; use offset/limit to page through it.`,
396
435
  parameters: Type.Object({
@@ -316,7 +316,7 @@ export declare function approvalCardMemberOf(call: {
316
316
  export declare function toolCallFaceOf(roster: ToolRoster | undefined, toolName: string): import("./tool-policy.js").ToolCallFace | undefined;
317
317
  /** design/388 B18 — the identity members a park row carries (the tool member of its approval object,
318
318
  * `approval-object.ts`), read off a roster snapshot by name; an empty object when the name is not on the snapshot
319
- * (the row then reads pre-identity and the resume binds the name alone). */
319
+ * (the row then carries no tool member, and the claim refuses its approval: no tool is bound by a name alone). */
320
320
  export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolName: string): Partial<ToolIdentity>;
321
321
  /** design/388 B6 × B18 — the FACE members a park row carries beside its identity: the display family, the declared
322
322
  * path target or URL slot, and the names the parked call was judged under. `names` is copied from the face the gate stamped on the
@@ -325,8 +325,8 @@ export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolN
325
325
  * beside it are: a fact of the tool, not of the call, and never read off the request's face, which the policy that judges the call
326
326
  * can write. A recheck that runs before the leg's roster exists (the pre-CAS resume-edit
327
327
  * re-adjudication) rebuilds the call face from the row through {@link parkedCallFaceOf}, so it judges the members the row
328
- * recorded (identity, family, targets, names, mount site) — not the live face's rule name values or approval card. An empty object when the name is not on the snapshot (the row then reads pre-face and the
329
- * recheck falls to the catalog for the name). */
328
+ * recorded (identity, family, targets, names, mount site) — not the live face's rule name values or approval card. An empty object
329
+ * when the name is not on the snapshot (no tool member: the claim refuses the row's approval before any recheck). */
330
330
  export declare function parkedToolFace(roster: ToolRoster | undefined, req: {
331
331
  readonly toolName: string;
332
332
  readonly face?: {
@@ -337,6 +337,7 @@ export declare function parkedToolFace(roster: ToolRoster | undefined, req: {
337
337
  pathTarget?: ToolRosterEntry["pathTarget"];
338
338
  hostTarget?: ToolHostTarget;
339
339
  names?: readonly string[];
340
+ declarationDigest?: string;
340
341
  engineMounted?: true;
341
342
  };
342
343
  /** The live face a resumed park row is re-judged under: minted under the row's recorded spelling (`names[0]`) when that
@@ -347,8 +348,8 @@ export declare function parkedRowLiveFace(roster: ToolRoster | undefined, row: {
347
348
  readonly names?: readonly string[];
348
349
  }): import("./tool-policy.js").ToolCallFace | undefined;
349
350
  /** The call face a park row carries — present iff the row was minted with BOTH its face members and its four
350
- * identity members (one mint writes all of them; a row missing any is pre-388 and yields undefined, never a
351
- * partial face). This is the face every recheck of the row judges under, roster or no roster. */
351
+ * identity members (one mint writes all of them; a row missing any yields undefined, never a partial face, and its
352
+ * approval is refused at the claim before any recheck reads it). This is the face every recheck of the row judges under, roster or no roster. */
352
353
  export declare function parkedCallFaceOf(pending: {
353
354
  family?: ToolFamily;
354
355
  pathTarget?: ToolRosterPathTarget;
@@ -372,6 +373,112 @@ export interface ToolIdentity {
372
373
  implementationRevision: string;
373
374
  }
374
375
  export declare function toolIdentityOf(entry: ToolRosterEntry): ToolIdentity;
376
+ /** How a parked approval binds one member of the roster row it was asked under: `identity` (the row member that carries it —
377
+ * a live row that differs is another tool, the row reopens), `face` (carried by value — a face that differs vetoes the call),
378
+ * `declaration` (hashed into the row's `declarationDigest` — a declaration that differs vetoes the call), or `unbound` (why the
379
+ * approval does not cover it). */
380
+ export type RosterApprovalBinding = {
381
+ readonly identity: readonly (keyof ToolIdentity | "engineMounted")[];
382
+ } | "face" | "declaration" | {
383
+ readonly unbound: string;
384
+ };
385
+ /** THE classification of every roster member for the approval of a parked call (#639 / #2345): typed over every key of the row,
386
+ * so a member added to the row is a compile error here until it is classified, and two fences hold the approval object's judge
387
+ * to it (`approval-object.ts`: the identity carriers and the face members it compares are exactly the table's). */
388
+ export declare const ROSTER_APPROVAL_BINDING: Readonly<{
389
+ readonly name: {
390
+ readonly identity: readonly ["capabilityId"];
391
+ };
392
+ readonly aliases: {
393
+ readonly unbound: "the names a call answers to are the call's own (the row's `names`); a resumed belt judges under the live names";
394
+ };
395
+ readonly source: {
396
+ readonly identity: readonly ["capabilityId"];
397
+ };
398
+ readonly origin: {
399
+ readonly unbound: "the peer is the identity's (capabilityId); who declared the server is provenance no decision reads";
400
+ };
401
+ readonly contract: {
402
+ readonly identity: readonly ["contractId", "implementationRevision"];
403
+ };
404
+ readonly shapeDigest: {
405
+ readonly identity: readonly ["shapeDigest"];
406
+ };
407
+ readonly wireSchemaDigest: {
408
+ readonly unbound: "the schema with its description prose for the model; the shape a call is validated against is the identity's (shapeDigest)";
409
+ };
410
+ readonly cardId: {
411
+ readonly unbound: "derived from the source, peer, name and contract, all identity";
412
+ };
413
+ readonly capabilityId: {
414
+ readonly identity: readonly ["capabilityId"];
415
+ };
416
+ readonly inputKeys: {
417
+ readonly unbound: "derived from the schema, whose shape is the identity's (shapeDigest)";
418
+ };
419
+ readonly effect: "declaration";
420
+ readonly effectProvenance: "declaration";
421
+ readonly offload: {
422
+ readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
423
+ };
424
+ readonly offloadThresholdChars: {
425
+ readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
426
+ };
427
+ readonly compactable: {
428
+ readonly unbound: "how the transcript keeps the result, not what the call does";
429
+ };
430
+ readonly budgetExempt: {
431
+ readonly unbound: "how the result counts against the context budget, not what the call does";
432
+ };
433
+ readonly egress: "declaration";
434
+ readonly egressProvenance: {
435
+ readonly unbound: "where the egress value came from; the value is the declaration's (egress), no decision reads its provenance";
436
+ };
437
+ readonly irreversibility: "declaration";
438
+ readonly reversibilityProbe: "declaration";
439
+ readonly contentOrigin: "declaration";
440
+ readonly contentOriginProvenance: {
441
+ readonly unbound: "where the content-origin value came from; the value is the declaration's, no decision reads its provenance";
442
+ };
443
+ readonly family: "face";
444
+ readonly boundaryLegs: "declaration";
445
+ readonly pathTarget: "face";
446
+ readonly hostTarget: "face";
447
+ readonly ruleFace: "declaration";
448
+ readonly approvalPreview: {
449
+ readonly unbound: "whether the card had a preview, shown when it was asked";
450
+ };
451
+ readonly validateInput: {
452
+ readonly unbound: "the live tool validates the bytes it runs, whatever the row says";
453
+ };
454
+ readonly deferred: {
455
+ readonly unbound: "when the schema is loaded into the model's context, not what the call does";
456
+ };
457
+ readonly alwaysLoad: {
458
+ readonly unbound: "when the schema is loaded into the model's context, not what the call does";
459
+ };
460
+ readonly modelGate: "declaration";
461
+ readonly renderHints: {
462
+ readonly unbound: "display, shown when the card was asked";
463
+ };
464
+ readonly mountedBy: {
465
+ readonly identity: readonly ["engineMounted"];
466
+ };
467
+ }>;
468
+ type ApprovalTable = typeof ROSTER_APPROVAL_BINDING;
469
+ /** The roster members the table binds as the tool's FACE. */
470
+ export type RosterFaceMember = {
471
+ [K in keyof ApprovalTable]: ApprovalTable[K] extends "face" ? K : never;
472
+ }[keyof ApprovalTable];
473
+ /** The row members that carry the roster's IDENTITY members. */
474
+ export type RosterIdentityCarrier = {
475
+ [K in keyof ApprovalTable]: ApprovalTable[K] extends {
476
+ readonly identity: readonly (infer I)[];
477
+ } ? I : never;
478
+ }[keyof ApprovalTable];
479
+ /** The declaration a parked approval binds: the digest of the row's `declaration` members ({@link ROSTER_APPROVAL_BINDING}), each as
480
+ * the row carries it — one mint for the park row and for the live row it is compared with. */
481
+ export declare function toolDeclarationDigestOf(entry: ToolRosterEntry): string;
375
482
  /** The engine-minted capability identity: a STRUCTURED tuple (never a joined string — `a:b`+`c` and `a`+`b:c`
376
483
  * must not collide). Stable across legs for the same source/peer/name/contract. */
377
484
  export declare function mintCapabilityId(t: {
@@ -11,6 +11,7 @@ import { PRESENT_PLAN_TOOL_NAME } from "./present-plan-tool.js";
11
11
  import { wireOf } from "./tool-name-readings.js";
12
12
  import { BOUNDARY_LEGS, rosterBoundaryLegs } from "./cross-boundary-taint.js";
13
13
  import { isPlainRecord, receive } from "./mods/kernel/receive.js";
14
+ import { boundInputHashOf } from "./canonical-json.js";
14
15
  function lit(values) {
15
16
  return Type.Union(values.map((v) => Type.Literal(v)));
16
17
  }
@@ -140,7 +141,7 @@ export function parkedToolFace(roster, req) {
140
141
  if (e === undefined)
141
142
  return {};
142
143
  const judged = req.face?.names;
143
- return { family: e.family, ...(e.pathTarget !== undefined ? { pathTarget: e.pathTarget } : {}), ...(e.hostTarget !== undefined ? { hostTarget: e.hostTarget } : {}), names: judged !== undefined && judged.includes(req.toolName) ? [...judged] : namesResolvingTo(roster, e), ...(engineMountedRow(e) ? { engineMounted: true } : {}) };
144
+ return { family: e.family, ...(e.pathTarget !== undefined ? { pathTarget: e.pathTarget } : {}), ...(e.hostTarget !== undefined ? { hostTarget: e.hostTarget } : {}), names: judged !== undefined && judged.includes(req.toolName) ? [...judged] : namesResolvingTo(roster, e), declarationDigest: toolDeclarationDigestOf(e), ...(engineMountedRow(e) ? { engineMounted: true } : {}) };
144
145
  }
145
146
  export function parkedRowLiveFace(roster, row) {
146
147
  const spelled = row.names?.[0];
@@ -168,6 +169,46 @@ export function callFaceSeat(face) {
168
169
  export function toolIdentityOf(entry) {
169
170
  return { capabilityId: entry.capabilityId, contractId: entry.contract.contractId, shapeDigest: entry.shapeDigest, implementationRevision: entry.contract.implementationRevision };
170
171
  }
172
+ export const ROSTER_APPROVAL_BINDING = Object.freeze({
173
+ name: { identity: ["capabilityId"] },
174
+ aliases: { unbound: "the names a call answers to are the call's own (the row's `names`); a resumed belt judges under the live names" },
175
+ source: { identity: ["capabilityId"] },
176
+ origin: { unbound: "the peer is the identity's (capabilityId); who declared the server is provenance no decision reads" },
177
+ contract: { identity: ["contractId", "implementationRevision"] },
178
+ shapeDigest: { identity: ["shapeDigest"] },
179
+ wireSchemaDigest: { unbound: "the schema with its description prose for the model; the shape a call is validated against is the identity's (shapeDigest)" },
180
+ cardId: { unbound: "derived from the source, peer, name and contract, all identity" },
181
+ capabilityId: { identity: ["capabilityId"] },
182
+ inputKeys: { unbound: "derived from the schema, whose shape is the identity's (shapeDigest)" },
183
+ effect: "declaration",
184
+ effectProvenance: "declaration",
185
+ offload: { unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches" },
186
+ offloadThresholdChars: { unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches" },
187
+ compactable: { unbound: "how the transcript keeps the result, not what the call does" },
188
+ budgetExempt: { unbound: "how the result counts against the context budget, not what the call does" },
189
+ egress: "declaration",
190
+ egressProvenance: { unbound: "where the egress value came from; the value is the declaration's (egress), no decision reads its provenance" },
191
+ irreversibility: "declaration",
192
+ reversibilityProbe: "declaration",
193
+ contentOrigin: "declaration",
194
+ contentOriginProvenance: { unbound: "where the content-origin value came from; the value is the declaration's, no decision reads its provenance" },
195
+ family: "face",
196
+ boundaryLegs: "declaration",
197
+ pathTarget: "face",
198
+ hostTarget: "face",
199
+ ruleFace: "declaration",
200
+ approvalPreview: { unbound: "whether the card had a preview, shown when it was asked" },
201
+ validateInput: { unbound: "the live tool validates the bytes it runs, whatever the row says" },
202
+ deferred: { unbound: "when the schema is loaded into the model's context, not what the call does" },
203
+ alwaysLoad: { unbound: "when the schema is loaded into the model's context, not what the call does" },
204
+ modelGate: "declaration",
205
+ renderHints: { unbound: "display, shown when the card was asked" },
206
+ mountedBy: { identity: ["engineMounted"] },
207
+ });
208
+ const DECLARATION_MEMBERS = Object.keys(ROSTER_APPROVAL_BINDING).filter((k) => ROSTER_APPROVAL_BINDING[k] === "declaration");
209
+ export function toolDeclarationDigestOf(entry) {
210
+ return boundInputHashOf(Object.fromEntries(DECLARATION_MEMBERS.flatMap((k) => (entry[k] === undefined ? [] : [[k, entry[k]]]))));
211
+ }
171
212
  function canonical(node) {
172
213
  if (Array.isArray(node))
173
214
  return `[${node.map(canonical).join(",")}]`;