@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
package/README.md CHANGED
@@ -22,7 +22,8 @@ const res = await runner.runTask({ objective: "...", model: "main" });
22
22
  and for the Anthropic Messages API. Routing, failover, and model roles are configuration.
23
23
  - **Stateless by design.** A task carries its full configuration (model, prompt, tools, MCP,
24
24
  skills, limits) and returns a `TaskResult`. Persistence — sessions, checkpoints, long-term
25
- memory, workflow journals — lives behind storage interfaces you can back with files or Postgres.
25
+ memory, workflow journals — lives behind storage interfaces. Core ships in-memory and file-backed
26
+ implementations; a database store is your deployment's to write and prove with the published contract kits.
26
27
 
27
28
  **It is not:**
28
29
 
@@ -39,10 +40,10 @@ const res = await runner.runTask({ objective: "...", model: "main" });
39
40
  behavior of Claude Code's tool contract, continuously verified against live probes.
40
41
  - **Durable checkpoints and human-in-the-loop.** Tasks can suspend on approval gates, budget
41
42
  limits, or explicit checkpoints and resume later — on another process or machine — via a
42
- pluggable `CheckpointStore` (in-memory, file, Postgres). Task statuses are explicit:
43
+ pluggable `CheckpointStore` (in-memory and file-backed here; a database one is yours). Task statuses are explicit:
43
44
  `completed | blocked | failed | timeout | suspended | needs_review`.
44
45
  - **Memory engine.** Scoped long-term memory with a pluggable `MemoryBackend`
45
- (file-backed or Postgres), plus automatic in-context compaction that keeps long runs inside the
46
+ (file-backed here; a database backend is yours), plus automatic in-context compaction that keeps long runs inside the
46
47
  model's context window without losing the thread.
47
48
  - **Multi-agent.** Sub-agent delegation, deterministic `runWorkflow`
48
49
  orchestration with durable journals, and opt-in observer agents that monitor and steer a run.
@@ -50,7 +51,8 @@ const res = await runner.runTask({ objective: "...", model: "main" });
50
51
  tool lifecycle, progress, diagnostics), ready to pipe into SSE via `createTaskServer`.
51
52
  - **Security model built in.** Tool policies with allow/ask/deny semantics, per-principal
52
53
  authorization, shell gating, and durable approval suspension — not bolted on.
53
- - **Small and honest.** Two runtime dependencies (`typebox`, `@modelcontextprotocol/sdk`).
54
+ - **Small and honest.** Four runtime dependencies (`typebox`, `@modelcontextprotocol/sdk`, `undici`, and the sibling package
55
+ `@sema-agent/primitives`, installed with it at the same version).
54
56
  A deterministic vitest suite of 5,400+ tests runs fully offline (`npm test`), including a real
55
57
  stdio MCP server.
56
58
  - **Source-available.** BUSL-1.1: free for personal, educational, research, and non-commercial
@@ -1,4 +1,11 @@
1
1
  import type { AgentDefinition } from "../core/types.js";
2
+ /**
3
+ * A definition as the engine receives it — where it is handed to the delegation tool and where a task carries it: its two tool-name
4
+ * lists replaced by their one copy (the copy every later reader takes instead of the host's container), and its MCP server declarations
5
+ * by the copy the door that judges `TaskSpec.mcp` makes of them ({@link snapshotAndValidateMcpEntries}) — a declaration that door refuses
6
+ * is refused here, by the same code and sentence.
7
+ */
8
+ export declare function snapshotDefinitionLists(def: AgentDefinition): AgentDefinition;
2
9
  /**
3
10
  * Validate + freeze a declarative sub-agent definition (design/38 1B). A thin, fail-fast factory: it
4
11
  * checks the only hard requirement (a non-empty `name`) and returns a shallow-frozen copy so a stored
@@ -1,3 +1,15 @@
1
+ import { snapshotToolNameList } from "../core/tool-name-list.js";
2
+ import { snapshotAndValidateMcpEntries } from "../core/locked-config.js";
3
+ export function snapshotDefinitionLists(def) {
4
+ const copy = { ...def };
5
+ if (copy.allowTools !== undefined)
6
+ copy.allowTools = snapshotToolNameList(copy.allowTools);
7
+ if (copy.denyTools !== undefined)
8
+ copy.denyTools = snapshotToolNameList(copy.denyTools);
9
+ if (copy.mcp !== undefined)
10
+ copy.mcp = snapshotAndValidateMcpEntries(copy.mcp, `AgentDefinition.mcp of ${typeof copy.name === "string" ? JSON.stringify(copy.name.slice(0, 80)) : "an unnamed definition"}`);
11
+ return copy;
12
+ }
1
13
  export function defineAgent(def) {
2
14
  if (!def.name || !def.name.trim()) {
3
15
  const e = new Error("defineAgent: `name` is required and must be a non-empty string.");
@@ -33,7 +33,8 @@ export interface AgentTranscriptToolOptions {
33
33
  enrichCtx?: import("../core/tools.js").ToolCtxEnricher;
34
34
  /** Subagent transcript persistence — the declared-durability integrity-gap disclosure sink (see
35
35
  * the SendMessage twin): a durable row with a bound sessionId whose session store attests
36
- * not_found. Announced once per (handle, process); absent ⇒ the honest per-call degrade alone. */
36
+ * not_found, on a mount whose transcript tier declares transcript durability (`full`). Announced once
37
+ * per (handle, process); absent ⇒ the honest per-call degrade alone. */
37
38
  onTranscriptIntegrityGap?: (handle: string, scope: string | undefined) => void;
38
39
  /** The run's checkpoint seat — where a PARKED agent's approval card is read from for the state line
39
40
  * (the same seat the Agent tool parks children into). Absent ⇒ the ctx seat
@@ -1,6 +1,7 @@
1
1
  import { Type } from "typebox";
2
2
  import { defineTool } from "../core/tools.js";
3
3
  import { announceTranscriptIntegrityGapOnce, canAccessAgentRecord } from "../core/background-agent-store.js";
4
+ import { resolveSubagentTranscriptTier } from "../core/wiring-manifest.js";
4
5
  import { DURABLE_AGENT_HANDLE_RE } from "../core/task-registry.js";
5
6
  import { inlineUntrusted } from "../core/untrusted-text.js";
6
7
  import { stepsFromMessages } from "./subagent-steps.js";
@@ -22,6 +23,7 @@ function renderSteps(steps, readAt) {
22
23
  }
23
24
  const clipStateHeader = (state) => `State: ${agentStateSummary(state).slice(0, REPORT_FIELD_MAX)}\n`;
24
25
  export function createAgentTranscriptTool(opts) {
26
+ const transcriptTier = resolveSubagentTranscriptTier(opts.agentStore !== undefined, opts.runner.sessions);
25
27
  return defineTool({
26
28
  name: AGENT_TRANSCRIPT_TOOL_NAME,
27
29
  ...toolFace("agent-transcript"),
@@ -77,7 +79,7 @@ export function createAgentTranscriptTool(opts) {
77
79
  }
78
80
  catch (e) {
79
81
  if (e?.code === "not_found") {
80
- announceTranscriptIntegrityGapOnce(id, access.scope, opts.onTranscriptIntegrityGap);
82
+ announceTranscriptIntegrityGapOnce(id, access.scope, opts.onTranscriptIntegrityGap, transcriptTier);
81
83
  }
82
84
  return live === undefined ? await transcriptGone(recordSource) : undefined;
83
85
  }
@@ -1,10 +1,9 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { lstat, readdir, readFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { normalizePeerName } from "./cross-session-ref.js";
5
4
  import { inheritedHostEnv } from "../core/secret-env.js";
6
5
  import { CC_PEER_ROW_FILE_RE } from "./cc-peer-wire.js";
7
- import { judgePeerRecordFile, PEER_PRESENCE_MAX_CHARS, PEER_SESSION_RECORD_SCHEMA_VERSION, readPeerSessionRecord, vetPeerRegistryDirectory, } from "./peer-directory.js";
6
+ import { judgePeerRecordFile, PEER_SESSION_RECORD_SCHEMA_VERSION, peerRowFault, readPeerSessionRecord, vetPeerRegistryDirectory, } from "./peer-directory.js";
8
7
  export const CC_UNNAMED_SESSION_NAME = "(unnamed session)";
9
8
  export function ccProcessStartToken(pid) {
10
9
  if (process.platform === "win32" || !Number.isInteger(pid) || pid <= 0)
@@ -32,7 +31,7 @@ export class CcPeerDirectoryError extends Error {
32
31
  code;
33
32
  path;
34
33
  constructor(code, path) {
35
- super(`the reference agent's session registry is not a directory this engine can trust (${code}: ${path}) — nothing was listed`);
34
+ super(`the reference agent's session registry is not a directory this engine can trust (${code}: ${path})`);
36
35
  this.name = "CcPeerDirectoryError";
37
36
  this.code = code;
38
37
  this.path = path;
@@ -87,11 +86,11 @@ export function createCcPeerDirectory(opts) {
87
86
  }
88
87
  const finite = (v) => (typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : undefined);
89
88
  const startedAt = finite(r["startedAt"]) ?? 0;
90
- const name = typeof r["name"] === "string" && normalizePeerName(r["name"]) !== "" ? r["name"] : CC_UNNAMED_SESSION_NAME;
89
+ const name = typeof r["name"] === "string" ? r["name"] : CC_UNNAMED_SESSION_NAME;
91
90
  const features = Array.isArray(r["peerFeatures"]) ? r["peerFeatures"].filter((f) => typeof f === "string" && FEATURE_RE.test(f)).slice(0, MAX_FEATURES) : undefined;
92
91
  const tempo = r["tempo"];
93
- const agent = typeof r["agent"] === "string" && r["agent"].length <= PEER_PRESENCE_MAX_CHARS ? r["agent"] : undefined;
94
- const read = readPeerSessionRecord({
92
+ const agent = typeof r["agent"] === "string" ? r["agent"] : undefined;
93
+ const raw = {
95
94
  schemaVersion: PEER_SESSION_RECORD_SCHEMA_VERSION,
96
95
  sessionId: r["sessionId"],
97
96
  scope,
@@ -108,9 +107,10 @@ export function createCcPeerDirectory(opts) {
108
107
  ...(features !== undefined ? { peerFeatures: features } : {}),
109
108
  sockPath,
110
109
  where: "this_machine",
111
- });
110
+ };
111
+ const read = readPeerSessionRecord(raw);
112
112
  if (!read.ok)
113
- return void skip(file, "invalid_row", read.field !== undefined ? `${read.reason}: ${read.field}` : read.reason);
113
+ throw peerRowFault(raw, read);
114
114
  return read.record;
115
115
  };
116
116
  return {
@@ -7,9 +7,11 @@ export declare function runnerRoleMap(runner: unknown): ModelRoles | undefined;
7
7
  * own: a string ref other than the literal `"default"`, a `Model` object, or a `{ model | select }` config
8
8
  * whose `model` is not that literal. The word `"default"` is how a deployment spells "no subagent tier of my
9
9
  * own — same as the main model" (a catalog key of that name is the boot default), so it reads as NOT stated;
10
- * a role entry carrying only a `thinking` / `systemPrompt` preset states no model either.
10
+ * a role entry carrying only a `thinking` / `systemPrompt` preset states no model either. A word the catalog does not hold states none
11
+ * either — the seat is read as the same seat without that word (`unheldSeatWord`, the roles family's one test): a `select` beside it still
12
+ * states the tier, otherwise the children run on the parent's model; the engine says so once per conversation (`model.role_defaulted`).
11
13
  */
12
- export declare function deploymentStatesSubagentModel(roles: ModelRoles | undefined): boolean;
14
+ export declare function deploymentStatesSubagentModel(roles: ModelRoles | undefined, models: Record<string, Model> | undefined): boolean;
13
15
  /**
14
16
  * Did the deployment STATE a thinking level for its subagents — and which? The `thinking` member of an
15
17
  * object-form `roles.subagent` entry; a string ref, a `Model` object or an entry without the member states
@@ -1,4 +1,4 @@
1
- import { resolveModel, resolveTaskModel } from "../core/roles.js";
1
+ import { receiveRoleMap, resolveModel, resolveTaskModel, unheldSeatWord } from "../core/roles.js";
2
2
  export function runnerRoleMap(runner) {
3
3
  try {
4
4
  return runner?.agentCatalog?.roles;
@@ -7,10 +7,12 @@ export function runnerRoleMap(runner) {
7
7
  return undefined;
8
8
  }
9
9
  }
10
- export function deploymentStatesSubagentModel(roles) {
10
+ export function deploymentStatesSubagentModel(roles, models) {
11
11
  const s = roles?.subagent;
12
12
  if (s == null)
13
13
  return false;
14
+ if (unheldSeatWord(s, models) !== undefined)
15
+ return typeof s !== "string" && s.select !== undefined;
14
16
  if (typeof s === "string")
15
17
  return s !== "default";
16
18
  if ("id" in s && "api" in s)
@@ -36,9 +38,12 @@ export function childThinkingSeat(explicit, deploymentStated, parent) {
36
38
  return level !== undefined ? { thinking: level } : {};
37
39
  }
38
40
  export function deploymentSubagentTierModel(deps) {
39
- if (deps === undefined || !deploymentStatesSubagentModel(deps.roles))
41
+ if (deps === undefined)
40
42
  return undefined;
41
- const resolved = resolveTaskModel({ modelRole: "subagent" }, deps);
43
+ const roles = receiveRoleMap(deps.roles, "RunnerDeps.roles");
44
+ if (!deploymentStatesSubagentModel(roles, deps.models))
45
+ return undefined;
46
+ const resolved = resolveTaskModel({ modelRole: "subagent" }, { models: deps.models, roles });
42
47
  return { model: resolved.model, ...(inheritableRef(resolved.modelRef, resolved.model, deps.models) !== undefined ? { modelRef: resolved.modelRef } : {}) };
43
48
  }
44
49
  export function inheritedParentModel(parent, catalog) {
@@ -19,7 +19,6 @@ export function buildCumulativeStats(base, acc) {
19
19
  : {
20
20
  llmRootMicroUsd: acc.llmRootMicroUsd,
21
21
  nestedSubagentMicroUsd: acc.nested.costMicroUsd,
22
- memoryConsolidationMicroUsd: 0,
23
22
  compactionMicroUsd: acc.compactionMicroUsd,
24
23
  ...(acc.sideCallMicroUsd !== undefined ? { sideCallMicroUsd: acc.sideCallMicroUsd } : {}),
25
24
  },
@@ -1,6 +1,8 @@
1
- import type { McpServerSpec, ToolSpec } from "../core/types.js";
1
+ import type { AgentDefinition, McpServerSpec, ToolSpec } from "../core/types.js";
2
2
  import type { ToolSelector } from "../core/tool-face.js";
3
3
  import type { MountedMcp } from "../core/mounted-mcp.js";
4
+ import type { McpHostSeat } from "../core/mcp-host-seat.js";
5
+ import type { RunInternals } from "../core/runner/contracts.js";
4
6
  /**
5
7
  * What a delegated child inherits when its delegation tool has no explicit pool (`SubagentToolOptions.inheritedTools`):
6
8
  * the parent surface, narrowed at spawn by two laws, and the parent's MCP declarations. The mint of the parent bound
@@ -30,3 +32,26 @@ export declare function inheritedChildPool(surface: readonly ToolSpec[], mountsC
30
32
  * the server's tools mount.
31
33
  */
32
34
  export declare function inheritedMcpDeclarations(mounted: MountedMcp, selector: ToolSelector): McpServerSpec[];
35
+ /** The host seats a child is handed: of `held` (the seats of the run that spawns or wakes it — `MountedMcp.hostSeats`), those of the
36
+ * host-transport servers among the child's declarations (`servers`), as the child's internals carry them — none ⇒ no member, so such a server
37
+ * of the child fails its dial like any declaration without a seat. */
38
+ export declare function inheritedHostSeats(held: ReadonlyMap<string, McpHostSeat> | undefined, servers: ReadonlyArray<McpServerSpec>): Pick<RunInternals, "mcpHostSeats">;
39
+ /** A child's internals as a retained snapshot keeps them: without host seats — they are live objects of the run that held them, and each wake
40
+ * hands the waker's own ({@link inheritedHostSeats} over the waker's mount). */
41
+ export declare function withoutHostSeats(internals: RunInternals): RunInternals;
42
+ /**
43
+ * The MCP servers a leg spawned as an agent definition is declared ({@link AgentDefinition.mcp}): the servers its lane hands it (the
44
+ * spawning run's it inherits, a workflow child's governed spec's) first, then each of the definition's own whose tool namespace none of
45
+ * those holds — a run holds one server per namespace, and a name the lane already declares for the leg names the lane's server. Every
46
+ * entry as declared; two of the definition's own under one namespace both stay, so the leg's mount refuses them as it refuses a task's
47
+ * own pair (`config.mcp_server_name_collision`). Which of their tools mount is the leg's own selector's question at its prepare.
48
+ */
49
+ export declare function withDefinitionServers<S extends {
50
+ readonly name: string;
51
+ }>(handed: readonly S[] | undefined, own: readonly S[] | undefined): S[];
52
+ /**
53
+ * A definition's own allowed-tools list as its leg's selector reads it: the list it wrote, extended by every tool of each MCP server it
54
+ * declares (`mcp__<server>__*`) — the servers an agent brings are its own whatever its list names, and its denied list still wins over them.
55
+ * No list (absent or `null`) stays no list.
56
+ */
57
+ export declare function definitionAllowTools(def: Pick<AgentDefinition, "allowTools" | "mcp">): string[] | undefined;
@@ -1,3 +1,4 @@
1
+ import { transportKindOf } from "../core/mcp-server-spec.js";
1
2
  import { mintNamespacePrefix } from "../core/protocol-naming.js";
2
3
  import { MCP_NAMESPACE } from "../core/protocol-table.js";
3
4
  import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "../core/tool-catalog-entries.js";
@@ -14,3 +15,24 @@ export function inheritedChildPool(surface, mountsCallerTool, anonymousBackgroun
14
15
  export function inheritedMcpDeclarations(mounted, selector) {
15
16
  return mounted.servers.filter((m) => selector.admitsPeer(mintNamespacePrefix(MCP_NAMESPACE, m.server.name))).map((m) => m.server);
16
17
  }
18
+ export function inheritedHostSeats(held, servers) {
19
+ const seats = servers.flatMap((s) => {
20
+ const seat = transportKindOf(s) === "host" ? held?.get(s.name) : undefined;
21
+ return seat !== undefined ? [[s.name, seat]] : [];
22
+ });
23
+ return seats.length > 0 ? { mcpHostSeats: new Map(seats) } : {};
24
+ }
25
+ export function withoutHostSeats(internals) {
26
+ const { mcpHostSeats: _live, ...kept } = internals;
27
+ return kept;
28
+ }
29
+ export function withDefinitionServers(handed, own) {
30
+ const held = new Set((handed ?? []).map((s) => mintNamespacePrefix(MCP_NAMESPACE, s.name)));
31
+ return [...(handed ?? []), ...(own ?? []).filter((s) => !held.has(mintNamespacePrefix(MCP_NAMESPACE, s.name)))];
32
+ }
33
+ export function definitionAllowTools(def) {
34
+ const written = def.allowTools ?? undefined;
35
+ if (!Array.isArray(written) || def.mcp === undefined || def.mcp.length === 0)
36
+ return written;
37
+ return [...written, ...def.mcp.map((s) => `${mintNamespacePrefix(MCP_NAMESPACE, s.name)}*`)];
38
+ }
@@ -185,6 +185,15 @@ export interface PeerDirectory {
185
185
  * faults the WHOLE listing (thrown, so each consumer's fault arm speaks), never a partial set — refs are minted and
186
186
  * names resolved over the full set, and dropping one row would change both. */
187
187
  export declare function listPeerDirectory(dir: PeerDirectory, access: PeerDirectoryAccess): Promise<PeerSessionRecord[]>;
188
+ /**
189
+ * THE fault of a row the reader refuses: what the directory did wrong, in one sentence — the consequence is each reader's own
190
+ * line (the listing says what it lists, a send's refusal frame says it was not sent), so a sentence is not written twice. Raised by
191
+ * {@link listPeerDirectory} for a host's rows and by the reference registry's directory for a row it read the same way.
192
+ */
193
+ export declare function peerRowFault(raw: unknown, read: {
194
+ reason: PeerSessionRecordRefusal;
195
+ field?: string;
196
+ }): Error;
188
197
  export interface PeerSessionCandidate {
189
198
  record: PeerSessionRecord;
190
199
  /** The listing-minted ref (6..12 hex) of this row — stable across the live/dead filter because it is
@@ -177,10 +177,14 @@ export async function listPeerDirectory(dir, access) {
177
177
  const read = readPeerSessionRecord(raw);
178
178
  if (read.ok)
179
179
  return read.record;
180
- const id = typeof raw?.sessionId === "string" ? inlineUntrusted(raw.sessionId, 80) : "(no session id)";
181
- throw new Error(`the directory listed a row this engine cannot read (${id}: ${read.reason}${read.field !== undefined ? `: ${read.field}` : ""}); no peer row is used until its host fixes it`);
180
+ throw peerRowFault(raw, read);
182
181
  });
183
182
  }
183
+ export function peerRowFault(raw, read) {
184
+ const sessionId = raw?.sessionId;
185
+ const id = typeof sessionId === "string" ? inlineUntrusted(sessionId, 80) : "(no session id)";
186
+ return new Error(`the directory listed a row this engine cannot read (${id}: ${read.reason}${read.field !== undefined ? `: ${read.field}` : ""})`);
187
+ }
184
188
  export function mintPeerSessionCandidates(records, self) {
185
189
  const entries = records.map((record) => ({ kind: "session", id: record.sessionId.toLowerCase(), record }));
186
190
  const selfEntry = self !== undefined && !records.some((r) => r.sessionId.toLowerCase() === self.sessionId.toLowerCase()) ? { kind: "session", id: self.sessionId.toLowerCase() } : undefined;
@@ -1,7 +1,12 @@
1
1
  import type { RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
2
2
  import type { TaskSpec } from "../core/types.js";
3
+ import type { PeerDeclarationHold, PeerDeclarations } from "../core/peer-seat.js";
3
4
  /** design/122 D2 — per-child resume cap (default 8): a child can be revived at most this many times. */
4
5
  export declare const SUBAGENT_RESUME_CAP = 8;
6
+ /** The one read of a seat's `holdDeclarations` — both retention registrations take their hold here. The member is required, so a typed host
7
+ * is stopped by the compiler; a seat built by hand without it (untyped, cast) is refused by name, where the bare call was a TypeError
8
+ * from the middle of a delegation. */
9
+ export declare function holdChildDeclarations(runner: RunnerSelfSeat, declared: PeerDeclarations): PeerDeclarationHold;
5
10
  /**
6
11
  * design/122 D1 — one RETAINED child ledger row. `specSnapshot` is a FROZEN plain value-copy of the spawn
7
12
  * childSpec (r1-m5: retaining the live `ctx`/spec-builder closures would pin the parent run's whole prepare
@@ -33,6 +38,10 @@ export interface SubagentRetainEntry {
33
38
  * Expiry (lazy sweep + active timer) uses this when present, the ledger default otherwise. */
34
39
  ttlMs?: number;
35
40
  specSnapshot: Readonly<TaskSpec>;
41
+ /** The entry's hold on the references `specSnapshot`'s declarations name, on the seat the runner that revives it asks
42
+ * (`RunnerSelfSeat.holdDeclarations`): handed to {@link SubagentRetainLedger.register}, which owns it from then on — kept while the
43
+ * row is in the ledger, released the moment the row leaves it (or at once when the row is not taken). */
44
+ declarations: PeerDeclarationHold;
36
45
  internalsSnapshot: RunInternals;
37
46
  /** True while the initial run OR a resume run is in flight (resume re-entry rejects `steering.still_running`). */
38
47
  running: boolean;
@@ -168,7 +177,8 @@ export declare class SubagentRetainLedger {
168
177
  sweepExpired(now?: number): void;
169
178
  /** Register a child at SPAWN (running until `markSettled`). Over `max`: the oldest settled idle entry is
170
179
  * evicted (unpin+release); when every slot is still running, the NEW child is NOT retained (tombstoned →
171
- * its resume rejects `resume.evicted`) and `undefined` is returned — the caller falls back to throwaway. */
180
+ * its resume rejects `resume.evicted`) and `undefined` is returned — the caller falls back to throwaway.
181
+ * The entry's `declarations` hold is the ledger's from this call on: a row not taken releases it here. */
172
182
  register(parentToolCallId: string, entry: Omit<SubagentRetainEntry, "running" | "settled" | "settledAt" | "resumeCount" | "cycleSeq" | "activeAbort" | "deferredNotify">): SubagentRetainEntry | undefined;
173
183
  /** Flip a child to settled (idle, resumable) — called when the initial run's stream drains.
174
184
  * fidelity R4-1: also (re-)arms the entry's own TTL timer, so the retain window expires by TIME,
@@ -4,6 +4,14 @@ import { createSafeNotifier } from "../core/safe-notify.js";
4
4
  import { RETAIN_DEFAULT_TTL_MS, RETAIN_DEFAULT_MAX } from "../config/defaults.js";
5
5
  import { asThrownError } from "../core/thrown-value.js";
6
6
  export const SUBAGENT_RESUME_CAP = 8;
7
+ export function holdChildDeclarations(runner, declared) {
8
+ if (typeof runner.holdDeclarations !== "function") {
9
+ throw Object.assign(new Error("the runner seat this tool runs children on has no `holdDeclarations` function — a seat built by hand forwards `holdDeclarations(declared)` to the Runner it stands for, or the Runner itself is handed in"), {
10
+ code: "config.invalid_argument",
11
+ });
12
+ }
13
+ return runner.holdDeclarations(declared);
14
+ }
7
15
  export class SubagentRetainLedger {
8
16
  ttlMs;
9
17
  max;
@@ -77,7 +85,7 @@ export class SubagentRetainLedger {
77
85
  }
78
86
  register(parentToolCallId, entry) {
79
87
  if (this.isDisposed)
80
- return undefined;
88
+ return void entry.declarations.release();
81
89
  this.sweepExpired();
82
90
  if (this.entries.size >= this.max) {
83
91
  let oldest;
@@ -90,11 +98,12 @@ export class SubagentRetainLedger {
90
98
  }
91
99
  if (oldest === undefined) {
92
100
  this.tombstone(parentToolCallId);
93
- return undefined;
101
+ return void entry.declarations.release();
94
102
  }
95
103
  this.evictDetached(oldest, "lru_overflow");
96
104
  }
97
105
  const full = { ...entry, running: true, settled: false, settledAt: Date.now(), resumeCount: 0, cycleSeq: 1 };
106
+ this.entries.get(parentToolCallId)?.declarations.release();
98
107
  this.entries.set(parentToolCallId, full);
99
108
  return full;
100
109
  }
@@ -151,6 +160,7 @@ export class SubagentRetainLedger {
151
160
  abandon(parentToolCallId) {
152
161
  const e = this.entries.get(parentToolCallId);
153
162
  if (e !== undefined && this.entries.delete(parentToolCallId)) {
163
+ e.declarations.release();
154
164
  this.clearTtlTimer(parentToolCallId);
155
165
  this.flushDeferredNotify(e);
156
166
  this.tombstone(parentToolCallId);
@@ -161,6 +171,7 @@ export class SubagentRetainLedger {
161
171
  if (!e)
162
172
  return;
163
173
  this.entries.delete(parentToolCallId);
174
+ e.declarations.release();
164
175
  this.clearTtlTimer(parentToolCallId);
165
176
  this.flushDeferredNotify(e);
166
177
  this.tombstone(parentToolCallId);
@@ -144,7 +144,7 @@ export declare class FileRosterStore implements RosterStore {
144
144
  private readonly maxAgeMs;
145
145
  private readonly gc;
146
146
  private readonly onCorruptRead;
147
- constructor(path: string, opts?: RosterGcOptions & {
147
+ constructor(path: string, options?: RosterGcOptions & {
148
148
  onCorruptRead?: (info: CorruptReadInfo) => void;
149
149
  });
150
150
  /** RB-482 #25 (baggage class-4 ruling): the LENIENT read grade's swallow stays (a store fault must read as a
@@ -1,5 +1,6 @@
1
1
  import { mkdirSync, readFileSync } from "node:fs";
2
2
  import { assertRetentionPolicy } from "../core/retention-policy.js";
3
+ import { receiveOptions } from "../core/own-property-receipt.js";
3
4
  import { atomicWriteFile } from "../stores/file/fs-atomic.js";
4
5
  import { dirname } from "node:path";
5
6
  import { normalizeAgentName } from "../core/task-registry.js";
@@ -79,7 +80,8 @@ export class FileRosterStore {
79
80
  maxAgeMs;
80
81
  gc;
81
82
  onCorruptRead;
82
- constructor(path, opts) {
83
+ constructor(path, options) {
84
+ const opts = options === undefined ? undefined : receiveOptions(options, "FileRosterStore");
83
85
  assertRetentionPolicy("RosterStore", opts);
84
86
  this.path = path;
85
87
  this.maxAgeMs = opts?.maxAgeMs;
@@ -37,30 +37,17 @@ export interface SendMessageToolOptions {
37
37
  notify?: (n: TaskNotificationPayload, opts?: {
38
38
  priority?: "now" | "next" | "later";
39
39
  }) => void;
40
+ /** The sending run's result store, the pair of {@link notify}: a continued agent's cut completion is stored where that
41
+ * run's `ReadToolResult` reads. Absent ⇒ the cut says the full text is not readable from this session. */
42
+ taskArtifacts?: import("../core/tool-result-store.js").TaskArtifactSeat;
40
43
  /** Whether a completion notification really reaches the sender — drives every "you will be notified"
41
44
  * sentence on this face (description + four receipts), mirroring TaskOutput's `notificationWired`.
42
45
  * Default = `notify !== undefined`, which is the truth on both the first-party mount and a direct
43
46
  * mount that wires its own sink here. Pass `true` only when the deployment announces a finished
44
47
  * agent through a channel of its own (this tool then keeps the wired wording); `false` states the
45
- * degraded truth explicitly. */
48
+ * degraded truth explicitly. A one-shot submission needs no wording of its own: its ending waits for a continued
49
+ * agent's completion, owed to the lane `notify` delivers into (`DeliveryObligations`). */
46
50
  notificationWired?: boolean;
47
- /** RB-220 mirror of {@link import("../core/types.js").TaskSpec.oneShot} (the Runner mount fills it):
48
- * this run's process exits when the turn ends, so no completion notification can ever land — checked
49
- * AHEAD of {@link notificationWired}, since no amount of wiring makes a later turn exist. */
50
- oneShot?: boolean;
51
- /**
52
- * Whether a RETRIEVAL tool (`TaskOutput`) is mounted beside this tool on the same face. Every
53
- * degraded completion promise on this face (the one-shot and silent arms of the description and
54
- * the receipt/refusal texts) tells the model how to collect a continued agent's result; naming
55
- * `TaskOutput(task_id, block: true)` as an imperative is only true where that tool exists. Since
56
- * design/385 §1.5 this tool also mounts on the delegated-child arm WITHOUT the background door
57
- * TaskOutput/TaskStop keep, so the two can no longer be assumed to travel together. Three states:
58
- * `true` — the advice names TaskOutput plainly; `false` — this face has no retrieval tool, and the
59
- * advice says the result cannot be collected by this run instead of naming a tool the model cannot
60
- * call (an unknown-tool error on a one-shot run is the turn where the result is lost); absent — the
61
- * mount did not say, and the advice is hedged ("where that tool is mounted").
62
- */
63
- retrievalToolMounted?: boolean;
64
51
  /** Steer-handle sink: the revived run re-emits a FRESH handle (design/122 risk-table contract). */
65
52
  sink?: (handle: SubagentSteerHandle) => void;
66
53
  /**
@@ -178,7 +165,9 @@ export interface SendMessageToolOptions {
178
165
  /**
179
166
  * Subagent transcript persistence — the "declared durability contradicted by reality" disclosure
180
167
  * sink: called (at most once per (scope, handle) per process, {@link announceTranscriptIntegrityGapOnce})
181
- * when a durable row with a bound sessionId meets a session store that attests `not_found`. The
168
+ * when a durable row with a bound sessionId meets a session store that attests `not_found` AND the
169
+ * mount's transcript tier declares transcript durability (`full`; under `rows` a gone transcript is the
170
+ * declared fate and the sink is not called). The
182
171
  * first-party mount wires an EngineNotice (`delegation.transcript_integrity`); absent ⇒ the
183
172
  * per-call honest refusal is the only loudness (unchanged behavior).
184
173
  */