@sema-agent/core 7.60.0 → 7.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (560) hide show
  1. package/CHANGELOG.md +917 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-transcript-tool.d.ts +2 -2
  4. package/dist/agents/agent-transcript-tool.js +1 -1
  5. package/dist/agents/cascade.d.ts +71 -12
  6. package/dist/agents/cascade.js +61 -21
  7. package/dist/agents/composition-allowance.d.ts +53 -0
  8. package/dist/agents/composition-allowance.js +49 -0
  9. package/dist/agents/composition-placement.d.ts +29 -0
  10. package/dist/agents/composition-placement.js +24 -0
  11. package/dist/agents/cumulative-stats.d.ts +4 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/inherited-tool-pool.d.ts +5 -3
  14. package/dist/agents/inherited-tool-pool.js +2 -2
  15. package/dist/agents/list-agents-tool.d.ts +1 -1
  16. package/dist/agents/peer-held-queue.d.ts +27 -4
  17. package/dist/agents/peer-held-queue.js +81 -36
  18. package/dist/agents/peer-notice-route.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.js +4 -3
  20. package/dist/agents/peer-notices.d.ts +4 -4
  21. package/dist/agents/peer-notices.js +8 -4
  22. package/dist/agents/peer-session-drain.d.ts +8 -1
  23. package/dist/agents/peer-session-drain.js +49 -10
  24. package/dist/agents/repair-loop.js +16 -6
  25. package/dist/agents/retain-ledger.js +3 -1
  26. package/dist/agents/roster-store.d.ts +1 -1
  27. package/dist/agents/roster-store.js +7 -4
  28. package/dist/agents/send-message-tool.d.ts +8 -10
  29. package/dist/agents/send-message-tool.js +43 -23
  30. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  31. package/dist/agents/subagent-completion-gate.js +62 -0
  32. package/dist/agents/subagent-steps.d.ts +7 -6
  33. package/dist/agents/subagent.d.ts +36 -41
  34. package/dist/agents/subagent.js +245 -200
  35. package/dist/agents/suspend-guard.d.ts +47 -16
  36. package/dist/agents/suspend-guard.js +13 -4
  37. package/dist/agents/verify.d.ts +41 -14
  38. package/dist/agents/verify.js +41 -30
  39. package/dist/brain/anthropic.js +1 -0
  40. package/dist/brain/errors.d.ts +7 -1
  41. package/dist/brain/errors.js +6 -0
  42. package/dist/brain/failover.js +2 -1
  43. package/dist/brain/open-responses.js +1 -0
  44. package/dist/brain/openai.js +1 -0
  45. package/dist/brain/provider-dialect.d.ts +10 -0
  46. package/dist/brain/provider-dialect.js +13 -2
  47. package/dist/brain/stream-engine.d.ts +3 -0
  48. package/dist/brain/stream-engine.js +4 -0
  49. package/dist/core/agent-state.d.ts +1 -1
  50. package/dist/core/allow-entry.d.ts +59 -23
  51. package/dist/core/allow-entry.js +131 -38
  52. package/dist/core/ask-origin.d.ts +79 -0
  53. package/dist/core/ask-origin.js +76 -0
  54. package/dist/core/ask-question.d.ts +19 -13
  55. package/dist/core/ask-question.js +8 -2
  56. package/dist/core/auto-compaction.d.ts +2 -0
  57. package/dist/core/auto-compaction.js +2 -1
  58. package/dist/core/auto-mode.js +3 -5
  59. package/dist/core/background-agent-store.d.ts +7 -5
  60. package/dist/core/background-agent-store.js +12 -11
  61. package/dist/core/checkpoint-features.d.ts +722 -0
  62. package/dist/core/checkpoint-features.js +98 -0
  63. package/dist/core/checkpoint-requirements.d.ts +33 -5
  64. package/dist/core/checkpoint-requirements.js +18 -5
  65. package/dist/core/checkpoint-row-verdict.d.ts +99 -0
  66. package/dist/core/checkpoint-row-verdict.js +225 -0
  67. package/dist/core/checkpoint-store.d.ts +107 -738
  68. package/dist/core/checkpoint-store.js +45 -143
  69. package/dist/core/child-clamp-seats.d.ts +3 -2
  70. package/dist/core/child-clamp-seats.js +4 -3
  71. package/dist/core/closest-name.d.ts +13 -0
  72. package/dist/core/closest-name.js +35 -0
  73. package/dist/core/context-settings.js +3 -5
  74. package/dist/core/cross-boundary-taint.d.ts +1 -1
  75. package/dist/core/decision-receipt.d.ts +14 -1
  76. package/dist/core/decision-receipt.js +6 -3
  77. package/dist/core/delegation-frames.d.ts +13 -9
  78. package/dist/core/effective-path-target.js +2 -3
  79. package/dist/core/engine-attestation.d.ts +11 -1
  80. package/dist/core/engine-attestation.js +2 -0
  81. package/dist/core/engine-notice.d.ts +68 -21
  82. package/dist/core/engine-notice.js +9 -2
  83. package/dist/core/file-history-retention.d.ts +8 -0
  84. package/dist/core/file-history-retention.js +14 -11
  85. package/dist/core/file-history-store.d.ts +31 -1
  86. package/dist/core/file-history-store.js +31 -2
  87. package/dist/core/frame-settlement.d.ts +10 -0
  88. package/dist/core/frame-settlement.js +6 -1
  89. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  90. package/dist/core/fs-write-gate-policy.js +8 -7
  91. package/dist/core/gate-fold.js +4 -3
  92. package/dist/core/gate-lanes.js +7 -4
  93. package/dist/core/gate-outcome.d.ts +40 -1
  94. package/dist/core/gate-outcome.js +10 -0
  95. package/dist/core/git-worktree-env.d.ts +7 -3
  96. package/dist/core/git-worktree-env.js +16 -13
  97. package/dist/core/governance-codes.d.ts +14 -4
  98. package/dist/core/governance-codes.js +19 -4
  99. package/dist/core/hooks.d.ts +25 -4
  100. package/dist/core/hooks.js +11 -4
  101. package/dist/core/host-floor.js +3 -5
  102. package/dist/core/human-input-projection.d.ts +1 -0
  103. package/dist/core/human-input-projection.js +3 -0
  104. package/dist/core/image-admission.d.ts +47 -7
  105. package/dist/core/image-admission.js +35 -4
  106. package/dist/core/input-author.d.ts +36 -0
  107. package/dist/core/input-author.js +39 -0
  108. package/dist/core/leg-identity.d.ts +62 -0
  109. package/dist/core/leg-identity.js +18 -0
  110. package/dist/core/locked-config.d.ts +4 -3
  111. package/dist/core/locked-config.js +5 -3
  112. package/dist/core/lsp.d.ts +5 -3
  113. package/dist/core/lsp.js +3 -2
  114. package/dist/core/mailbox-store.d.ts +85 -10
  115. package/dist/core/mailbox-store.js +31 -10
  116. package/dist/core/mcp-connection-pool.d.ts +6 -20
  117. package/dist/core/mcp-connection-pool.js +10 -28
  118. package/dist/core/mcp-failure.d.ts +76 -15
  119. package/dist/core/mcp-failure.js +60 -33
  120. package/dist/core/mcp-host-seat.d.ts +92 -53
  121. package/dist/core/mcp-host-seat.js +225 -46
  122. package/dist/core/mcp-probe.js +2 -2
  123. package/dist/core/mcp-server-link.d.ts +18 -6
  124. package/dist/core/mcp-server-link.js +19 -4
  125. package/dist/core/mcp-server-spec.d.ts +2 -1
  126. package/dist/core/mcp-session-end.d.ts +1 -2
  127. package/dist/core/mcp-session-end.js +1 -1
  128. package/dist/core/mcp.d.ts +6 -49
  129. package/dist/core/mcp.js +115 -111
  130. package/dist/core/media-byte-cap.d.ts +21 -46
  131. package/dist/core/media-byte-cap.js +55 -55
  132. package/dist/core/member-group.d.ts +7 -0
  133. package/dist/core/member-group.js +35 -0
  134. package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
  135. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  136. package/dist/core/memory-engine/consolidation.js +7 -1
  137. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  138. package/dist/core/memory-engine/dual-root.js +59 -11
  139. package/dist/core/memory-engine/engine.js +27 -24
  140. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  141. package/dist/core/memory-engine/file-backend.js +35 -15
  142. package/dist/core/memory-engine/layout.d.ts +3 -0
  143. package/dist/core/memory-engine/layout.js +13 -3
  144. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  145. package/dist/core/memory-engine/memory-deployment.js +182 -0
  146. package/dist/core/memory-engine/sync-client.d.ts +39 -18
  147. package/dist/core/memory-engine/sync-client.js +72 -14
  148. package/dist/core/memory-engine/sync-report.d.ts +7 -4
  149. package/dist/core/memory-engine/sync.d.ts +9 -1
  150. package/dist/core/memory-vector.d.ts +1 -1
  151. package/dist/core/memory.d.ts +10 -10
  152. package/dist/core/mode-policy.d.ts +8 -8
  153. package/dist/core/mode-policy.js +8 -6
  154. package/dist/core/mods/agent-stations.d.ts +39 -4
  155. package/dist/core/mods/agent-stations.js +59 -10
  156. package/dist/core/mods/classic-events.d.ts +9 -1
  157. package/dist/core/mods/dollar.d.ts +94 -1
  158. package/dist/core/mods/dollar.js +13 -1
  159. package/dist/core/mods/extension-call.d.ts +15 -1
  160. package/dist/core/mods/extension-call.js +7 -2
  161. package/dist/core/mods/kernel/dispatch.d.ts +4 -3
  162. package/dist/core/mods/kernel/dispatch.js +4 -4
  163. package/dist/core/mods/kernel/events.d.ts +14 -3
  164. package/dist/core/mods/kernel/events.js +18 -15
  165. package/dist/core/mods/kernel/registration.d.ts +3 -0
  166. package/dist/core/mods/kernel/registration.js +5 -0
  167. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  168. package/dist/core/mods/kernel/site-rules.js +10 -2
  169. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  170. package/dist/core/mods/lifecycle-stations.js +44 -9
  171. package/dist/core/mods/session-append.d.ts +118 -0
  172. package/dist/core/mods/session-append.js +318 -0
  173. package/dist/core/mods/session-compact.d.ts +48 -0
  174. package/dist/core/mods/session-compact.js +194 -0
  175. package/dist/core/mods/session-receive.d.ts +93 -0
  176. package/dist/core/mods/session-receive.js +138 -0
  177. package/dist/core/mods/session-send.d.ts +72 -0
  178. package/dist/core/mods/session-send.js +88 -0
  179. package/dist/core/mods/stations.d.ts +88 -21
  180. package/dist/core/mods/stations.js +149 -11
  181. package/dist/core/mods/tool-call.d.ts +2 -0
  182. package/dist/core/mods/tool-call.js +4 -4
  183. package/dist/core/output-style.js +3 -4
  184. package/dist/core/own-property-receipt.d.ts +68 -2
  185. package/dist/core/own-property-receipt.js +45 -2
  186. package/dist/core/park-selfcheck.js +4 -2
  187. package/dist/core/path-identity.d.ts +11 -0
  188. package/dist/core/path-identity.js +4 -0
  189. package/dist/core/path-rule-binding.d.ts +3 -1
  190. package/dist/core/path-rule-binding.js +3 -1
  191. package/dist/core/peer-seat.d.ts +3 -3
  192. package/dist/core/peer-seat.js +20 -8
  193. package/dist/core/permission-rule-consent.d.ts +21 -5
  194. package/dist/core/permission-rule-consent.js +21 -1
  195. package/dist/core/permission-rule-model.d.ts +34 -11
  196. package/dist/core/permission-rule-model.js +47 -10
  197. package/dist/core/permission-rule-org.d.ts +1 -1
  198. package/dist/core/permission-rule-provider.js +4 -1
  199. package/dist/core/permission-rules.d.ts +4 -0
  200. package/dist/core/permission-rules.js +11 -16
  201. package/dist/core/read-root-candidate.js +1 -1
  202. package/dist/core/remote-env.d.ts +74 -26
  203. package/dist/core/remote-env.js +20 -0
  204. package/dist/core/resume-startup-cause.d.ts +5 -4
  205. package/dist/core/retention-policy.d.ts +24 -23
  206. package/dist/core/retention-policy.js +36 -2
  207. package/dist/core/retention.d.ts +4 -1
  208. package/dist/core/retired-keys.d.ts +4 -4
  209. package/dist/core/row-admission.d.ts +10 -0
  210. package/dist/core/row-admission.js +5 -0
  211. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  212. package/dist/core/runner/advisor-instructions.js +2 -1
  213. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  214. package/dist/core/runner/assemble-result.d.ts +13 -3
  215. package/dist/core/runner/assemble-result.js +12 -7
  216. package/dist/core/runner/caller-roster.d.ts +12 -9
  217. package/dist/core/runner/caller-roster.js +5 -2
  218. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  219. package/dist/core/runner/checkpoint-scope.js +21 -0
  220. package/dist/core/runner/compact-session.js +18 -3
  221. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  222. package/dist/core/runner/compaction-restate.d.ts +2 -2
  223. package/dist/core/runner/compaction-restate.js +4 -3
  224. package/dist/core/runner/construction-doors.d.ts +2 -2
  225. package/dist/core/runner/construction-doors.js +2 -2
  226. package/dist/core/runner/contracts.d.ts +116 -34
  227. package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
  228. package/dist/core/runner/decide-continuation.d.ts +4 -2
  229. package/dist/core/runner/decide-continuation.js +7 -4
  230. package/dist/core/runner/delegation-owner.d.ts +43 -0
  231. package/dist/core/runner/delegation-owner.js +59 -0
  232. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  233. package/dist/core/runner/denial-limit-arms.js +17 -10
  234. package/dist/core/runner/expire-settle.d.ts +44 -0
  235. package/dist/core/runner/expire-settle.js +55 -0
  236. package/dist/core/runner/git-status-frame.d.ts +3 -3
  237. package/dist/core/runner/git-status-frame.js +2 -1
  238. package/dist/core/runner/halt-attribution.d.ts +2 -1
  239. package/dist/core/runner/halt-attribution.js +2 -1
  240. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  241. package/dist/core/runner/lineage-reroot-view.js +108 -0
  242. package/dist/core/runner/local-claims.d.ts +17 -0
  243. package/dist/core/runner/local-claims.js +18 -0
  244. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  245. package/dist/core/runner/media-removed-seat.js +88 -0
  246. package/dist/core/runner/park-commit.d.ts +2 -2
  247. package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
  248. package/dist/core/runner/permission-rule-lanes.js +28 -9
  249. package/dist/core/runner/person-path-rows.d.ts +15 -0
  250. package/dist/core/runner/person-path-rows.js +27 -4
  251. package/dist/core/runner/placement-fence.d.ts +26 -0
  252. package/dist/core/runner/placement-fence.js +38 -0
  253. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  254. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  255. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  256. package/dist/core/runner/prepare-ask-lane.js +4 -4
  257. package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
  258. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  259. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
  260. package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
  261. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  262. package/dist/core/runner/prepare-config-doors.js +19 -21
  263. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  264. package/dist/core/runner/prepare-context-lane.js +13 -13
  265. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
  266. package/dist/core/runner/prepare-delegation-surface.js +4 -5
  267. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  268. package/dist/core/runner/prepare-execution-env.js +7 -4
  269. package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
  270. package/dist/core/runner/prepare-gate-stations.js +6 -4
  271. package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
  272. package/dist/core/runner/prepare-hands-readface.js +32 -11
  273. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
  274. package/dist/core/runner/prepare-inherited-gate.js +10 -3
  275. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  276. package/dist/core/runner/prepare-lsp.js +2 -2
  277. package/dist/core/runner/prepare-park-ask.d.ts +5 -2
  278. package/dist/core/runner/prepare-park-ask.js +4 -5
  279. package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
  280. package/dist/core/runner/prepare-policy-chain.js +16 -25
  281. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  282. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
  283. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  284. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  285. package/dist/core/runner/prepare-question-face.js +2 -2
  286. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  287. package/dist/core/runner/prepare-run-refs.js +2 -2
  288. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
  289. package/dist/core/runner/prepare-suspend-saga.js +17 -7
  290. package/dist/core/runner/prepare-task.d.ts +1 -1
  291. package/dist/core/runner/prepare-task.js +61 -30
  292. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  293. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  294. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
  295. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  296. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  297. package/dist/core/runner/prepare-workspace-restore.js +10 -6
  298. package/dist/core/runner/read-root-grant.d.ts +1 -1
  299. package/dist/core/runner/read-root-grant.js +2 -1
  300. package/dist/core/runner/resume-admission.d.ts +8 -6
  301. package/dist/core/runner/resume-admission.js +23 -6
  302. package/dist/core/runner/resume-apply.d.ts +4 -0
  303. package/dist/core/runner/resume-apply.js +14 -5
  304. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  305. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  306. package/dist/core/runner/resume-claim.d.ts +8 -3
  307. package/dist/core/runner/resume-claim.js +28 -12
  308. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  309. package/dist/core/runner/resume-internals-and-config.js +10 -1
  310. package/dist/core/runner/resume-preflight.d.ts +3 -2
  311. package/dist/core/runner/resume-preflight.js +13 -26
  312. package/dist/core/runner/retired-runner-deps.js +2 -0
  313. package/dist/core/runner/run-git-lane.d.ts +2 -0
  314. package/dist/core/runner/run-git-lane.js +6 -2
  315. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  316. package/dist/core/runner/run-harness-handlers.js +5 -4
  317. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  318. package/dist/core/runner/run-identity-wiring.js +14 -5
  319. package/dist/core/runner/run-leg.d.ts +3 -3
  320. package/dist/core/runner/run-leg.js +64 -36
  321. package/dist/core/runner/run-notification-lane.js +20 -2
  322. package/dist/core/runner/run-recovery-lanes.js +3 -2
  323. package/dist/core/runner/run-settle-and-teardown.js +12 -9
  324. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  325. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  326. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  327. package/dist/core/runner/run-terminal-adoption.js +26 -17
  328. package/dist/core/runner/run-turn-boundary.js +34 -18
  329. package/dist/core/runner/runtask.d.ts +18 -3
  330. package/dist/core/runner/runtask.js +33 -17
  331. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  332. package/dist/core/runner/session-rule-policy.js +6 -1
  333. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  334. package/dist/core/runner/steering-preview.d.ts +9 -0
  335. package/dist/core/runner/steering-preview.js +5 -0
  336. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  337. package/dist/core/runner/stream-halt-verbs.js +4 -3
  338. package/dist/core/runner/stream-reap.d.ts +7 -6
  339. package/dist/core/runner/stream-reap.js +13 -16
  340. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  341. package/dist/core/runner/stream-settle-backstop.js +5 -3
  342. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  343. package/dist/core/runner/stream-steer-verb.js +16 -7
  344. package/dist/core/runner/terminal-account.d.ts +11 -1
  345. package/dist/core/runner/terminal-account.js +20 -0
  346. package/dist/core/runner/terminal-projection.d.ts +8 -2
  347. package/dist/core/runner/terminal-projection.js +2 -2
  348. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  349. package/dist/core/runner/tool-disclosure.js +5 -2
  350. package/dist/core/runner/tool-end-body.d.ts +3 -3
  351. package/dist/core/runner/tool-end-body.js +1 -1
  352. package/dist/core/runner/tool-face-overlay.js +2 -0
  353. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  354. package/dist/core/runner/tool-output-projection.js +7 -6
  355. package/dist/core/runner/tool-table-view.d.ts +56 -0
  356. package/dist/core/runner/tool-table-view.js +51 -0
  357. package/dist/core/runner/turn-attachments.d.ts +8 -2
  358. package/dist/core/runner/turn-attachments.js +2 -2
  359. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  360. package/dist/core/runner/void-verifier-pause.js +41 -0
  361. package/dist/core/runner-deps.d.ts +26 -27
  362. package/dist/core/secret-env.d.ts +19 -16
  363. package/dist/core/secret-env.js +45 -27
  364. package/dist/core/session-log-transfer.js +9 -10
  365. package/dist/core/session-policy-store.d.ts +1 -1
  366. package/dist/core/session-policy-store.js +5 -2
  367. package/dist/core/session-reconcile.d.ts +3 -2
  368. package/dist/core/session-reconcile.js +7 -4
  369. package/dist/core/session-store.d.ts +3 -1
  370. package/dist/core/session-store.js +10 -8
  371. package/dist/core/session.d.ts +16 -5
  372. package/dist/core/shell-confinement.d.ts +37 -0
  373. package/dist/core/shell-confinement.js +56 -0
  374. package/dist/core/skill-grant.js +1 -1
  375. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
  376. package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
  377. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  378. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  379. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  380. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  381. package/dist/core/store-contracts/session-store-contract.js +22 -8
  382. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  383. package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
  384. package/dist/core/task-event.d.ts +24 -9
  385. package/dist/core/task-limits.d.ts +5 -0
  386. package/dist/core/task-notification.d.ts +89 -12
  387. package/dist/core/task-notification.js +89 -14
  388. package/dist/core/task-registry-agent.d.ts +32 -50
  389. package/dist/core/task-registry-agent.js +36 -56
  390. package/dist/core/task-registry-monitor.d.ts +1 -1
  391. package/dist/core/task-registry-monitor.js +15 -60
  392. package/dist/core/task-registry-shared.d.ts +22 -112
  393. package/dist/core/task-registry-shared.js +3 -41
  394. package/dist/core/task-registry-workflow.js +5 -21
  395. package/dist/core/task-registry.d.ts +32 -62
  396. package/dist/core/task-registry.js +30 -110
  397. package/dist/core/task-result.d.ts +29 -12
  398. package/dist/core/task-spec-members.d.ts +39 -0
  399. package/dist/core/task-spec-members.js +92 -0
  400. package/dist/core/task-spec.d.ts +11 -11
  401. package/dist/core/task-tool-shape.d.ts +7 -57
  402. package/dist/core/task-tool-shape.js +7 -66
  403. package/dist/core/terminal-cause.d.ts +36 -6
  404. package/dist/core/terminal-cause.js +1 -0
  405. package/dist/core/tool-catalog-entries.js +2 -5
  406. package/dist/core/tool-check-reading.js +16 -10
  407. package/dist/core/tool-conformance.js +1 -2
  408. package/dist/core/tool-errors.d.ts +6 -3
  409. package/dist/core/tool-errors.js +2 -0
  410. package/dist/core/tool-face-reader.js +3 -2
  411. package/dist/core/tool-face.d.ts +8 -5
  412. package/dist/core/tool-face.js +1 -1
  413. package/dist/core/tool-name-aliases.d.ts +5 -29
  414. package/dist/core/tool-name-aliases.js +9 -5
  415. package/dist/core/tool-name-readings.d.ts +14 -3
  416. package/dist/core/tool-name-readings.js +2 -0
  417. package/dist/core/tool-policy.d.ts +109 -18
  418. package/dist/core/tool-policy.js +84 -14
  419. package/dist/core/tool-result-store.d.ts +23 -0
  420. package/dist/core/tool-result-store.js +3 -2
  421. package/dist/core/tool-roster.d.ts +4 -4
  422. package/dist/core/tool-spec.d.ts +23 -6
  423. package/dist/core/trace.d.ts +18 -1
  424. package/dist/core/types.d.ts +1 -1
  425. package/dist/core/types.js +1 -1
  426. package/dist/core/user-attachment.js +26 -21
  427. package/dist/core/workflow-journal-store.d.ts +1 -1
  428. package/dist/core/workflow-run-store.d.ts +2 -0
  429. package/dist/core/workflow-run-store.js +6 -5
  430. package/dist/core/workflow-settled-run.d.ts +5 -0
  431. package/dist/core/workflow-settled-run.js +7 -0
  432. package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
  433. package/dist/engine/execution-env/node-execution-env.js +221 -22
  434. package/dist/engine/harness/agent-harness.d.ts +65 -18
  435. package/dist/engine/harness/agent-harness.js +90 -23
  436. package/dist/engine/harness/messages.d.ts +4 -3
  437. package/dist/engine/harness/messages.js +2 -2
  438. package/dist/engine/harness/types.d.ts +52 -7
  439. package/dist/engine/llm/media-removed.d.ts +14 -0
  440. package/dist/engine/llm/media-removed.js +9 -0
  441. package/dist/engine/llm/rejected-images.d.ts +35 -25
  442. package/dist/engine/llm/rejected-images.js +59 -10
  443. package/dist/engine/llm/types.d.ts +24 -3
  444. package/dist/engine/llm/types.js +7 -3
  445. package/dist/engine/loop/agent-loop.d.ts +6 -1
  446. package/dist/engine/loop/agent-loop.js +20 -11
  447. package/dist/engine/loop/types.d.ts +12 -3
  448. package/dist/engine/session/import-validate.js +7 -0
  449. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  450. package/dist/engine/session/parent-chain-guard.js +1 -1
  451. package/dist/engine/session/path-to-root.d.ts +18 -3
  452. package/dist/engine/session/path-to-root.js +15 -1
  453. package/dist/engine/session/repo-utils.d.ts +12 -1
  454. package/dist/engine/session/repo-utils.js +41 -0
  455. package/dist/engine/session/session.js +1 -1
  456. package/dist/engine/session/storage-base.d.ts +20 -0
  457. package/dist/engine/session/storage-base.js +28 -9
  458. package/dist/fixtures/index.d.ts +7 -5
  459. package/dist/fixtures/index.js +5 -3
  460. package/dist/index.d.ts +29 -18
  461. package/dist/index.js +19 -11
  462. package/dist/internal/harness-types.d.ts +2 -0
  463. package/dist/internal/harness.d.ts +4 -3
  464. package/dist/internal/harness.js +3 -2
  465. package/dist/internal/llm.d.ts +2 -1
  466. package/dist/internal/llm.js +1 -0
  467. package/dist/orchestration/goal.d.ts +6 -2
  468. package/dist/orchestration/goal.js +6 -3
  469. package/dist/orchestration/run-workflow-tool.d.ts +14 -17
  470. package/dist/orchestration/run-workflow-tool.js +43 -50
  471. package/dist/orchestration/workflow-types.d.ts +2 -2
  472. package/dist/orchestration/workflow.d.ts +7 -0
  473. package/dist/orchestration/workflow.js +10 -12
  474. package/dist/stores/file/background-agent-store.js +18 -15
  475. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  476. package/dist/stores/file/checkpoint-store.js +13 -9
  477. package/dist/stores/file/file-history-store.js +3 -2
  478. package/dist/stores/file/fs-atomic.d.ts +0 -22
  479. package/dist/stores/file/fs-atomic.js +0 -17
  480. package/dist/stores/file/index.d.ts +7 -12
  481. package/dist/stores/file/index.js +25 -12
  482. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  483. package/dist/stores/file/ledger-tuning.js +21 -0
  484. package/dist/stores/file/mailbox-store.js +42 -22
  485. package/dist/stores/file/memory-store.js +3 -2
  486. package/dist/stores/file/permission-rule-adopt.js +24 -21
  487. package/dist/stores/file/permission-rule-store.js +6 -3
  488. package/dist/stores/file/session-policy-store.js +3 -2
  489. package/dist/stores/file/session-store.d.ts +26 -7
  490. package/dist/stores/file/session-store.js +59 -35
  491. package/dist/stores/file/tool-result-store.d.ts +11 -0
  492. package/dist/stores/file/tool-result-store.js +57 -3
  493. package/dist/stores/file/usage-window-store.js +3 -2
  494. package/dist/stores/file/workflow-journal-store.d.ts +0 -2
  495. package/dist/stores/file/workflow-journal-store.js +3 -18
  496. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  497. package/dist/stores/file/workflow-run-store.js +15 -10
  498. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  499. package/dist/tools/fs/bash-program-position.js +7 -7
  500. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  501. package/dist/tools/fs/dead-cwd.js +4 -11
  502. package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
  503. package/dist/tools/fs/fs-bash-background-text.js +6 -0
  504. package/dist/tools/fs/fs-bash.d.ts +3 -18
  505. package/dist/tools/fs/fs-bash.js +37 -124
  506. package/dist/tools/fs/fs-pdf.js +8 -6
  507. package/dist/tools/fs/fs-read.js +2 -2
  508. package/dist/tools/fs/fs-shared.d.ts +28 -3
  509. package/dist/tools/fs/fs-shared.js +15 -0
  510. package/dist/tools/fs/index.d.ts +1 -1
  511. package/dist/tools/fs/index.js +4 -14
  512. package/dist/tools/fs/pdf.d.ts +4 -4
  513. package/dist/tools/fs/pdf.js +6 -6
  514. package/dist/tools/fs/read-deny-home.js +8 -1
  515. package/dist/tools/fs/read-deny.d.ts +26 -2
  516. package/dist/tools/fs/read-deny.js +9 -2
  517. package/dist/tools/fs/read-floor.d.ts +13 -5
  518. package/dist/tools/fs/read-floor.js +206 -2
  519. package/dist/tools/fs/removal-targets.js +2 -2
  520. package/dist/tools/fs/search.d.ts +3 -2
  521. package/dist/tools/fs/search.js +6 -6
  522. package/dist/tools/fs/shell-read-argv.d.ts +4 -2
  523. package/dist/tools/fs/shell-read-argv.js +14 -3
  524. package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
  525. package/dist/tools/fs/shell-read-bindings.js +148 -68
  526. package/dist/tools/fs/shell-read-check.js +20 -4
  527. package/dist/tools/fs/shell-read-establish.js +25 -9
  528. package/dist/tools/fs/shell-read-functions.js +2 -2
  529. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  530. package/dist/tools/fs/shell-read-identity.js +4 -2
  531. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  532. package/dist/tools/fs/shell-read-judge.js +1 -1
  533. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  534. package/dist/tools/fs/shell-read-object-path.js +119 -0
  535. package/dist/tools/fs/shell-read-plan.d.ts +8 -0
  536. package/dist/tools/fs/shell-read-plan.js +47 -30
  537. package/dist/tools/fs/shell-read-start.d.ts +66 -13
  538. package/dist/tools/fs/shell-read-start.js +89 -17
  539. package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
  540. package/dist/tools/fs/shell-read-workdir.js +31 -8
  541. package/dist/tools/monitor.d.ts +8 -7
  542. package/dist/tools/monitor.js +12 -10
  543. package/dist/tools/worktree.d.ts +5 -1
  544. package/dist/tools/worktree.js +20 -17
  545. package/package.json +6 -3
  546. package/test/export-surface.snapshot.json +112 -42
  547. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  548. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  549. package/wire-changes/core@7.61.0.json +4405 -0
  550. package/wire-changes/core@7.62.0.json +2181 -0
  551. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  552. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  553. package/wire-changes/primitives@7.61.0.json +30 -0
  554. package/wire-changes/primitives@7.62.0.json +30 -0
  555. package/dist/core/consolidate-scope.d.ts +0 -93
  556. package/dist/core/consolidate-scope.js +0 -98
  557. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  558. package/dist/core/runner/image-removed-seat.js +0 -19
  559. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  560. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -14,11 +14,13 @@ export type SystemInjectionPriority = "now" | "next" | "later";
14
14
  * session's next run in this process (a process restart loses it);
15
15
  * · `parked_durably` — no live lane; appended to the session's DURABLE box
16
16
  * ({@link PendingSessionNotifications.bindSessionBox}) — the next run drains it, in any process;
17
- * · `dropped_duplicate` — the session already delivered this exact frame.
17
+ * · `dropped_duplicate` — the session already delivered this exact frame;
18
+ * · `refused` — a live lane took it and the session's receiving station did not hand it over: an extension consumed it,
19
+ * or a handler there failed ({@link FrameReceiver}). The model never saw it, and it is not owed again.
18
20
  * The park backend is the seat's choice ({@link routeOrParkNotification}), never the producer's.
19
21
  */
20
- export type NotificationInjectionOutcome = "queued" | "parked" | "parked_durably" | "dropped_duplicate";
21
- export declare const NOTIFICATION_INJECTION_OUTCOMES: readonly ["queued", "parked", "parked_durably", "dropped_duplicate"];
22
+ export type NotificationInjectionOutcome = "queued" | "parked" | "parked_durably" | "dropped_duplicate" | "refused";
23
+ export declare const NOTIFICATION_INJECTION_OUTCOMES: readonly ["queued", "parked", "parked_durably", "dropped_duplicate", "refused"];
22
24
  /** Is `value` one of the injector's outcome words? A host-wired uplink may answer anything (a bare
23
25
  * `void`, an array's `push` count) — such an answer reads as "outcome not reported", never as a word. */
24
26
  export declare function isNotificationInjectionOutcome(value: unknown): value is NotificationInjectionOutcome;
@@ -207,7 +209,7 @@ export interface TaskNotificationPayload {
207
209
  resumable?: boolean;
208
210
  /** A cross-channel correlation key for ONE completion event — the same task's completion fans out
209
211
  * across several independent read faces (this live notification frame, a durable inbox entry, and the
210
- * `TaskOutput` poll projection). Minted ONCE per completion, fill-once (first writer wins), on the
212
+ * host task poll projection). Minted ONCE per completion, fill-once (first writer wins), on the
211
213
  * same task-registry handle/record every read face serves from — see
212
214
  * {@link "./task-registry.js".UnifiedTaskOutput.completionId} for the shared contract (open-shape
213
215
  * `string`, absent until terminal settle, absent on a pre-P1-3 core build). Deliberately ABSENT on
@@ -285,7 +287,38 @@ export interface TaskNotificationPayload {
285
287
  * and the record's typed peer metadata rides in `peerMeta` (on a notice frame its `notice` is THE typed notice).
286
288
  */
287
289
  _sema_provenance?: SemaProvenance;
290
+ /**
291
+ * The text a receiving extension handed the model in place of this frame's rendering (the `session.receive` station,
292
+ * {@link FrameReceiver}), and who changed it. Set only on the copy a delivery carries — never on the frame a producer,
293
+ * a park or a box holds — and {@link renderTaskNotificationXml} returns it verbatim: every face that renders the frame
294
+ * (the live lane, the turn-open redelivery, a `ReadInbox` result, its receipt ask) reads the one rendering.
295
+ */
296
+ received?: {
297
+ readonly text: string;
298
+ readonly rewrittenBy: readonly string[];
299
+ };
288
300
  }
301
+ /**
302
+ * The session's one receiving station (`session.receive`): every face a frame reaches the model by — the live lane (a
303
+ * producer's injection, a frame routed in from another run of the session, a peer letter the box drain pushes), the
304
+ * turn-open redelivery of what was parked, and the box's `ReadInbox` pull — hands the frame to it before the hand-over, and
305
+ * hands over what it answers. Awaited; with no handler listening, nothing is raised and a caller keeps its own path.
306
+ */
307
+ export interface FrameReceiver {
308
+ /** Does a handler listen? `false` ⇒ the frame passes as made, and nothing is raised. */
309
+ listens(): boolean;
310
+ /** What becomes of `payload`: handed over (the frame, or a copy carrying {@link TaskNotificationPayload.received}), or
311
+ * consumed — not handed over, by the extension `by` (or the engine, when the station could not judge), for `reason`. */
312
+ receive(payload: TaskNotificationPayload): Promise<ReceivedFrame>;
313
+ }
314
+ export type ReceivedFrame = {
315
+ readonly kind: "arrived";
316
+ readonly payload: TaskNotificationPayload;
317
+ } | {
318
+ readonly kind: "consumed";
319
+ readonly by: string;
320
+ readonly reason: string;
321
+ };
289
322
  /** design/385 §1.4 d1 / §4.1 — see {@link TaskNotificationPayload._sema_provenance}. `kind` is a
290
323
  * closed set of the engine carriers that mint the record; a future carrier adds a member, never a
291
324
  * second key. */
@@ -515,16 +548,22 @@ export declare function terminalFrameFacets(facts: {
515
548
  warning?: string | undefined;
516
549
  compaction?: TaskNotificationPayload["compaction"] | undefined;
517
550
  }): Pick<TaskNotificationPayload, "spawnName" | "handback" | "compaction">;
551
+ /** What the deployment hears when a report the frame carried whole could not be stored: the task row keeps no read handle. */
552
+ export declare const SHORT_REPORT_UNSTORED = "a background task's report could not be stored (the write failed or went unconfirmed): its completion frame carried the whole report, but its task row keeps no read handle for a later list";
518
553
  /**
519
554
  * A delegated child's report as its completion frame carries it — the one value the parent's notification and the fleet
520
555
  * terminal projected from that frame both read: redacted BEFORE the cut, with the pass the task row's copy uses (a token
521
- * across the cut is never half-shown), then cut with an honest total. A report longer than the frame carries is the task's
522
- * result artifact: `persist` stores the whole redacted report and the cut line names what it answered — awaited first, so
523
- * the frame never names a ref whose write has not landed. `ref` = the stored ref, for the task row. Absent in ⇒ absent out.
556
+ * across the cut is never half-shown), then cut with an honest total. The report is the task's result artifact whatever its
557
+ * length: `persist` stores the whole redacted report and `record` hands the stored ref to the task row as its read handle
558
+ * (a list of tasks names it when the frame itself is lost) — only after the write landed. A report longer than the frame
559
+ * carries is cut, and its cut line names that ref, so the frame waits for the write; a report the frame carries whole does
560
+ * not wait (its write lands on its own and records the ref then — a stalled store never holds a complete answer back).
561
+ * That unawaited write still has a failure path: a write that went unconfirmed, or anything thrown on the way, reaches the
562
+ * caller's `notifier` (its first failure per site is disclosed on the deployment's channel), never the floor. `record`
563
+ * names the settle the result belongs to, so a write landing after the row moved on records nothing. Absent in ⇒ absent out.
524
564
  */
525
- export declare function completionResultField(result: string | undefined, persist: (report: string) => Promise<import("./tool-result-store.js").TaskArtifact>): Promise<{
565
+ export declare function completionResultField(result: string | undefined, persist: (report: string) => Promise<import("./tool-result-store.js").TaskArtifact>, record: (ref: string) => void, notifier: Pick<import("./safe-notify.js").SafeNotifier, "notifyAsync">): Promise<{
526
566
  readonly text: string;
527
- readonly ref?: string;
528
567
  } | undefined>;
529
568
  /** The codec version this engine writes into an `engine_frame` record and the highest it reads. */
530
569
  export declare const ENGINE_FRAME_CODEC_VERSION = 1;
@@ -593,6 +632,18 @@ export declare function isTerminalTaskNotification(n: Pick<TaskNotificationPaylo
593
632
  * another for the delivery.
594
633
  */
595
634
  export declare function resolveCompletionSink<C, M>(callSink: C | undefined, mountSink: M | undefined): C | M | undefined;
635
+ /**
636
+ * THE background admission every producer applies at launch — a background command, a Monitor watch, a background
637
+ * agent, a workflow run, a continued agent: the launch is made only when its completion will come back — the one
638
+ * resolved completion sink ({@link resolveCompletionSink}) is there, or the deployment wired a channel of its own for
639
+ * this producer outside the engine (a workflow's durable notifier; a host that announces a continued agent itself).
640
+ * No channel ⇒ no background launch: an agent runs synchronously instead, every other producer refuses before any
641
+ * side effect. Judged at the call, never at the mount — a mount cannot know the run lane a call will carry (a
642
+ * caller-mounted tool gets its run's lane on the call's context only) — so a mount offers its background option on its
643
+ * own capability, and every "you will be notified" a face says holds for any launch this admits.
644
+ */
645
+ export declare function admitsBackgroundLaunch<S>(sink: S | undefined): sink is S;
646
+ export declare function admitsBackgroundLaunch(sink: unknown, deploymentChannel: boolean): boolean;
596
647
  /**
597
648
  * The terminal frames a run's notification lane is still OWED — the one book a one-shot submission's ending waits on.
598
649
  * A loop-type background task (a background agent, a continued agent, a workflow run) whose completion sink is a run's
@@ -668,7 +719,7 @@ export interface DrainedPendingNotifications {
668
719
  * key, which put a session-level fact into a per-task ledger and broke twice for it: the key could
669
720
  * collide with a real, free-form external `task_id` (merging two unrelated counts and mislabelling the
670
721
  * lane — design/144 X1 already ruled that the external lane needs its own key space), and the
671
- * survivors-none renderer told the model to call `TaskOutput("(evicted-session)")`, an instruction with
722
+ * survivors-none renderer told the model to poll a task id `"(evicted-session)"`, an instruction with
672
723
  * nothing behind it. The count is a session fact; it now has a session field.
673
724
  */
674
725
  droppedWholeSession?: number;
@@ -767,6 +818,16 @@ export declare class SessionLiveNotificationLanes {
767
818
  /** Sessions holding at least one live lane (observability + the tests' rollback detector). */
768
819
  get size(): number;
769
820
  }
821
+ /**
822
+ * What a double fault at the park seat leaves beside its in-process copy: the box the record was meant for (the binding
823
+ * the seat asked, as it was then — the store object, scope and handle) and the record it asked with. The copy is a debt
824
+ * owed to THAT box, settled by asking it again ({@link PendingSessionNotifications.settleBoxDebts}) — never by comparing
825
+ * it with whatever box the session binds later.
826
+ */
827
+ export interface SessionBoxDebt {
828
+ readonly box: SessionBoxBinding;
829
+ readonly record: MailboxAppendMessage;
830
+ }
770
831
  export declare class PendingSessionNotifications {
771
832
  private readonly sessions;
772
833
  /**
@@ -800,8 +861,24 @@ export declare class PendingSessionNotifications {
800
861
  bindSessionBox(sessionId: string, box: SessionBoxBinding | undefined): void;
801
862
  /** The session's durable box, when a leg of it mounted the drain in this process. */
802
863
  sessionBoxFor(sessionId: string): SessionBoxBinding | undefined;
803
- pend(sessionId: string, n: TaskNotificationPayload, priority?: SystemInjectionPriority): void;
804
- /** Remove and return the session's pendings (one-shot — the next run consumes them exactly once).
864
+ /**
865
+ * Settle what the session's pending copies owe their boxes ({@link SessionBoxDebt}): each is asked of its own box once
866
+ * more, under its record, in pend order. A box that answers took the record — it holds it, or received it already —
867
+ * so the delivery is the box's and the copy is dropped (the box then owns the key, as after a durable park). A box
868
+ * that refuses, whatever the refusal, is disclosed once on that binding and the copy stays an ordinary pending
869
+ * notification. Never rejects. `undefined` when nothing is owed: a leg with no debt takes no store round trip. ONE
870
+ * pass over what is owed when it starts, stopped by `signal`: a debt that arrives meanwhile, or one an abort left
871
+ * unasked, stays owed — and a copy that owes its box is never drained ({@link drain} keeps it back) — until a later
872
+ * leg's settlement asks.
873
+ */
874
+ settleBoxDebts(sessionId: string, signal?: AbortSignal): Promise<void> | undefined;
875
+ /** What a drain hands out of a parked record: everything but the copies that still owe their box — those go back
876
+ * into the store as the session's record (with their keys, tiers and debts) for the leg that settles them. */
877
+ private keepBackOwing;
878
+ private settleBoxDebt;
879
+ pend(sessionId: string, n: TaskNotificationPayload, priority?: SystemInjectionPriority, debt?: SessionBoxDebt): void;
880
+ /** Remove and return the session's pendings (one-shot — the next run consumes them exactly once); a copy that
881
+ * still owes its box stays parked for the leg that settles it ({@link settleBoxDebts}).
805
882
  * design/373 §3.5: the batch comes out PRIORITY-MAJOR (stable sort — pend order within a class;
806
883
  * a no-priority record ranks as later), the idle-dequeue min-value-first form. */
807
884
  drain(sessionId: string): DrainedPendingNotifications | undefined;
@@ -1,10 +1,11 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { escapeEnvelopeTag, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
3
3
  import { egressText } from "./untrusted-egress.js";
4
+ import { redactThenCut } from "../agents/subagent-steps.js";
4
5
  import { PEER_MESSAGE_NOTICE } from "../agents/peer-admission.js";
5
6
  import { buildCrossSessionEnvelope, CROSS_PRINCIPAL_MESSAGE_NOTICE, CROSS_SESSION_MESSAGE_NOTICE, neutralizePeerBody } from "../agents/cross-session-envelope.js";
6
7
  export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(["completed", "failed", "killed", "cancelled"]);
7
- export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate"]);
8
+ export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate", "refused"]);
8
9
  export function isNotificationInjectionOutcome(value) {
9
10
  return typeof value === "string" && NOTIFICATION_INJECTION_OUTCOMES.includes(value);
10
11
  }
@@ -95,6 +96,8 @@ export function renderCrossSessionNoticeLine(notice) {
95
96
  }
96
97
  export const RESUPPLIED_FRAME_PREAMBLE = "[Re-supplied] You were shown this message once before; the compaction that replaced older context with a summary did not keep it, so the engine is handing it over again. It is the SAME message, not a new one \u2014 act on it once.";
97
98
  export function renderTaskNotificationXml(n) {
99
+ if (n.received !== undefined)
100
+ return n.received.text;
98
101
  const body = renderTaskNotificationCarrier(n);
99
102
  return n.resupplied === true ? `${RESUPPLIED_FRAME_PREAMBLE}\n\n${body}` : body;
100
103
  }
@@ -183,22 +186,30 @@ function cutReportReading(artifact) {
183
186
  case "stored":
184
187
  return `read the full text with ReadToolResult (ref "${artifact.ref}")`;
185
188
  case "unconfirmed":
186
- return "the full text could not be stored (the write failed or went unconfirmed), so no ref can read it back — ask the agent for it via SendMessage, or read it with TaskOutput where mounted";
189
+ return "the full text could not be stored (the write failed or went unconfirmed), so no ref can read it back and it is not readable in this session — ask the agent for it via SendMessage";
187
190
  case "no_store":
188
- return "the full text is not stored behind a ref (no offload store) — ask the agent for it via SendMessage, or read it with TaskOutput where mounted";
191
+ return "the full text is not stored behind a ref (no offload store), so it is not readable in this session — ask the agent for it via SendMessage";
189
192
  }
190
193
  }
191
- export async function completionResultField(result, persist) {
194
+ export const SHORT_REPORT_UNSTORED = "a background task's report could not be stored (the write failed or went unconfirmed): its completion frame carried the whole report, but its task row keeps no read handle for a later list";
195
+ export async function completionResultField(result, persist, record, notifier) {
192
196
  if (!result)
193
197
  return undefined;
194
198
  const report = egressText("same-principal", result);
195
- if (report.length <= COMPLETION_REPORT_MAX)
199
+ if (report.length <= COMPLETION_REPORT_MAX) {
200
+ void notifier.notifyAsync(async () => {
201
+ const artifact = await persist(report);
202
+ if (artifact.kind === "unconfirmed")
203
+ throw new Error(SHORT_REPORT_UNSTORED);
204
+ if (artifact.kind === "stored")
205
+ record(artifact.ref);
206
+ }, "completionResultField.shortReportWrite");
196
207
  return { text: report };
208
+ }
197
209
  const artifact = await persist(report);
198
- return {
199
- text: `${report.slice(0, COMPLETION_REPORT_MAX)}\n[result truncated: ${report.length} chars total — ${cutReportReading(artifact)}]`,
200
- ...(artifact.kind === "stored" ? { ref: artifact.ref } : {}),
201
- };
210
+ if (artifact.kind === "stored")
211
+ record(artifact.ref);
212
+ return { text: `${report.slice(0, COMPLETION_REPORT_MAX)}\n[result truncated: ${report.length} chars total — ${cutReportReading(artifact)}]` };
202
213
  }
203
214
  export const ENGINE_FRAME_CODEC_VERSION = 1;
204
215
  export const ENGINE_FRAME_TASK_TYPES = Object.freeze(["background_agent", "monitor", "workflow"]);
@@ -293,6 +304,9 @@ export function isTerminalTaskNotification(n) {
293
304
  export function resolveCompletionSink(callSink, mountSink) {
294
305
  return callSink ?? mountSink;
295
306
  }
307
+ export function admitsBackgroundLaunch(sink, deploymentChannel = false) {
308
+ return sink !== undefined || deploymentChannel;
309
+ }
296
310
  export class DeliveryObligations {
297
311
  owed = new Map();
298
312
  counted = new Set();
@@ -460,7 +474,63 @@ export class PendingSessionNotifications {
460
474
  sessionBoxFor(sessionId) {
461
475
  return this.sessionBoxes.get(sessionId);
462
476
  }
463
- pend(sessionId, n, priority) {
477
+ settleBoxDebts(sessionId, signal) {
478
+ const owed = this.sessions.get(sessionId)?.boxDebts;
479
+ if (owed === undefined || owed.size === 0)
480
+ return undefined;
481
+ const debts = [...owed];
482
+ return (async () => {
483
+ for (const [copy, debt] of debts) {
484
+ if (signal?.aborted === true)
485
+ return;
486
+ await this.settleBoxDebt(sessionId, copy, debt);
487
+ }
488
+ })();
489
+ }
490
+ keepBackOwing(sessionId, s) {
491
+ const debts = s.boxDebts;
492
+ const owing = debts === undefined ? [] : s.items.filter((n) => debts.has(n));
493
+ if (owing.length === 0)
494
+ return s;
495
+ const tiers = new Map();
496
+ for (const n of owing) {
497
+ const p = s.priorities?.get(n);
498
+ if (p !== undefined)
499
+ tiers.set(n, p);
500
+ }
501
+ this.sessions.set(sessionId, { items: owing, dropped: new Map(), keys: new Set(owing.map((n) => taskNotificationDedupKey(n))), priorities: tiers, boxDebts: debts });
502
+ const rest = s.items.filter((n) => !debts.has(n));
503
+ return rest.length === 0 && s.dropped.size === 0 ? undefined : { ...s, items: rest };
504
+ }
505
+ async settleBoxDebt(sessionId, copy, debt) {
506
+ let answered = false;
507
+ try {
508
+ await debt.box.mailbox.append(debt.box.scope, debt.box.handle, debt.record);
509
+ answered = true;
510
+ }
511
+ catch (e) {
512
+ try {
513
+ debt.box.onError?.(e);
514
+ }
515
+ catch {
516
+ }
517
+ }
518
+ const s = this.sessions.get(sessionId);
519
+ if (s?.boxDebts?.get(copy) !== debt)
520
+ return;
521
+ s.boxDebts.delete(copy);
522
+ const at = s.items.indexOf(copy);
523
+ if (!answered || at === -1)
524
+ return;
525
+ s.items.splice(at, 1);
526
+ const key = taskNotificationDedupKey(copy);
527
+ s.keys.delete(key);
528
+ s.priorities?.delete(copy);
529
+ this.noteDurablePark(sessionId, key);
530
+ if (s.items.length === 0 && s.dropped.size === 0)
531
+ this.sessions.delete(sessionId);
532
+ }
533
+ pend(sessionId, n, priority, debt) {
464
534
  let s = this.sessions.get(sessionId);
465
535
  if (s === undefined) {
466
536
  if (this.sessions.size >= MAX_PENDING_SESSIONS) {
@@ -492,6 +562,8 @@ export class PendingSessionNotifications {
492
562
  s.items.push(n);
493
563
  if (priority !== undefined)
494
564
  s.priorities?.set(n, priority);
565
+ if (debt !== undefined)
566
+ (s.boxDebts ??= new Map()).set(n, debt);
495
567
  const lane = taskNotificationLaneKey(n);
496
568
  let mine = 0;
497
569
  for (const i of s.items)
@@ -504,9 +576,11 @@ export class PendingSessionNotifications {
504
576
  }
505
577
  drain(sessionId) {
506
578
  this.routed.delete(sessionId);
507
- const s = this.sessions.get(sessionId);
508
- if (s !== undefined) {
579
+ const parked = this.sessions.get(sessionId);
580
+ if (parked !== undefined)
509
581
  this.sessions.delete(sessionId);
582
+ const s = parked !== undefined ? this.keepBackOwing(sessionId, parked) : undefined;
583
+ if (s !== undefined) {
510
584
  const rank = (n) => {
511
585
  const p = s.priorities?.get(n);
512
586
  return p === "now" ? 0 : p === "next" ? 1 : 2;
@@ -630,7 +704,7 @@ export function routeOrParkNotification(store, sessionId, payload, priority, onD
630
704
  });
631
705
  const settled = appended.then(() => onDisposition?.("parked_durably"), () => {
632
706
  store.forgetDurablePark(sessionId, dedupKey);
633
- store.pend(sessionId, payload, priority);
707
+ store.pend(sessionId, payload, priority, { box, record });
634
708
  onDisposition?.("parked");
635
709
  });
636
710
  DurableAppendObligations.current()?.track(settled);
@@ -668,6 +742,7 @@ function evictOldest(s, match) {
668
742
  const victim = s.items.splice(idx, 1)[0];
669
743
  s.keys.delete(taskNotificationDedupKey(victim));
670
744
  s.priorities?.delete(victim);
745
+ s.boxDebts?.delete(victim);
671
746
  const laneKey = taskNotificationLaneKey(victim);
672
747
  const prior = s.dropped.get(laneKey);
673
748
  s.dropped.set(laneKey, { count: (prior?.count ?? 0) + 1, taskType: victim.task_type, taskId: victim.task_id });
@@ -746,7 +821,7 @@ export function renderBackgroundTaskTable(tasks) {
746
821
  : t.status === "parked"
747
822
  ? "parked awaiting an out-of-band approval — do NOT re-issue the gated call"
748
823
  : t.status;
749
- return `- [${t.id}] Task "${(t.description ?? "background task").slice(0, BACKGROUND_TASK_TABLE_DESCRIPTION_MAX)}" ${phrase}${t.read !== undefined ? ` — ${t.read}` : ""}`;
824
+ return `- [${t.id}] Task "${redactThenCut(t.description ?? "background task", BACKGROUND_TASK_TABLE_DESCRIPTION_MAX)}" ${phrase}${t.read !== undefined ? ` — ${t.read}` : ""}`;
750
825
  });
751
826
  return lines.join("\n") + (unlisted > 0 ? `\n(+${unlisted} more background tasks, not listed here)` : "");
752
827
  }
@@ -1,6 +1,5 @@
1
1
  import { type BackgroundAgentRecord, type BackgroundAgentStore } from "./background-agent-store.js";
2
- import { type StopSource, type TaskAccess, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type RegisteredTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput } from "./task-registry-shared.js";
3
- import { type ToolResultStore } from "./tool-result-store.js";
2
+ import { type StopSource, type TaskAccess, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type ChildSessionStore, type RegisteredTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput } from "./task-registry-shared.js";
4
3
  import { type AgentState } from "./agent-state.js";
5
4
  import type { CheckpointSeat } from "./checkpoint-seat.js";
6
5
  /**
@@ -14,6 +13,17 @@ import type { CheckpointSeat } from "./checkpoint-seat.js";
14
13
  * segment, which is what makes the reservation race-free in-process.
15
14
  */
16
15
  export declare function activeDelegationHandlesLane(core: DurableAgentCore, scope: string, rootSessionId: string): string[];
16
+ /** One running or pending row of a delegation tree, as its occupant is told of it: the task id every addressing tool takes, the row's
17
+ * addressing name, and whether the caller asked for can address it (the registry's access predicate — a nested agent does not reach
18
+ * its siblings' rows, so their ids and names are not its to be told). */
19
+ export interface DelegationOccupant {
20
+ readonly id: string;
21
+ readonly name: string;
22
+ readonly reachable: boolean;
23
+ }
24
+ /** The rows {@link activeDelegationHandlesLane} counts, with the name each is addressed by — the one selection, read in the same
25
+ * synchronous segment. `caller` is the access the asking leg's own tools hold (`scope` is the pool's); without one no row is reachable. */
26
+ export declare function activeDelegationOccupantsLane(core: DurableAgentCore, scope: string, rootSessionId: string, caller?: TaskAccess): DelegationOccupant[];
17
27
  export declare function ensureDurableHeartbeatLane(core: DurableAgentCore): void;
18
28
  /** design/151 S1a — enqueue one durable-row write (see {@link DurableAgentLane} for the lane
19
29
  * contract). `patch` is captured at CALL time (the settle-site values), applied in chain order.
@@ -117,11 +127,18 @@ export declare function reapDurableAgentsLane(core: DurableAgentCore, scope: str
117
127
  skippedNoSessions: number;
118
128
  orphanPlacedReleased: number;
119
129
  }>;
130
+ /** A background-agent row's child session: its id and the store the child's run holds it through (`undefined` when a
131
+ * caller outside the bind's types bound the id without one). */
132
+ export interface ChildSessionAnchor {
133
+ readonly sessionId: string;
134
+ readonly store: ChildSessionStore | undefined;
135
+ }
120
136
  /** The child session a background-agent row is anchored to right now — the session its child runs on
121
- * or keeps (transcript / resume anchor) — or `undefined` before the bind, after the anchor's release,
122
- * and on every other task type. The ONE reading of the anchor: the list row's `sessionId` and the
123
- * release match below both read it here. */
124
- export declare function childSessionAnchorOf(handle: RegisteredTaskHandle): string | undefined;
137
+ * or keeps (transcript / resume anchor), with the store that holds it — or `undefined` before the bind,
138
+ * after the anchor's release, and on every other task type. The ONE reading of the anchor: the list
139
+ * row's `sessionId`, the transcript read ({@link TaskRegistry.anchoredSession}) and the release and bind
140
+ * matches below all read it here. */
141
+ export declare function childSessionAnchorOf(handle: RegisteredTaskHandle): ChildSessionAnchor | undefined;
125
142
  /** A successful release of the child session `sessionId` ends the row's claim on it: both copies of
126
143
  * the anchor go — the handle's (the list row reads it) and the durable record's (the heartbeat's F-1
127
144
  * arm keeps re-driving a flush-failed lane, so a later successful flush would otherwise persist a row
@@ -134,8 +151,10 @@ export declare function releaseDurableTranscriptAnchorLane(core: DurableAgentCor
134
151
  * A row already anchored to that session is left as it is (one fact, no second durable write). A row anchored to ANOTHER session
135
152
  * is refused: an anchor changes only by its release ({@link releaseDurableTranscriptAnchorLane}) and a fresh bind, never by being
136
153
  * written over, so the earlier session is never silently left unowned. An id that is no non-empty string is no anchor and is
137
- * refused whatever the row holds. */
138
- export declare function bindBackgroundAgentSessionLane(core: DurableAgentCore, id: string, sessionId: string): void;
154
+ * refused whatever the row holds. `store` is the store the child's run holds that session through, bound with the id (the
155
+ * store is process-local; the durable record keeps the id alone). The store is judged where it is read: the transcript read
156
+ * (`$.session.messages`) refuses, naming why, one it cannot read through. */
157
+ export declare function bindBackgroundAgentSessionLane(core: DurableAgentCore, id: string, sessionId: string, store: ChildSessionStore): void;
139
158
  /**
140
159
  * #22 — record the org-memory admission verdict THIS leg adjudicated onto the durable row, so the
141
160
  * next CROSS-PROCESS revival (which rebuilds the spec from the reviving caller's mount and cannot
@@ -447,7 +466,7 @@ export declare function deliverToRunningAgentLane(core: DurableAgentCore, id: st
447
466
  disposition: "queued" | "parked" | "pending";
448
467
  } | {
449
468
  ok: false;
450
- reason: "not_found" | "not_running" | "no_channel" | "queue_full";
469
+ reason: "not_found" | "not_running" | "no_channel" | "queue_full" | "refused";
451
470
  }>;
452
471
  /** CC `ugo`/`rxo` (206:575227-575243 = 220:467937-467951): `id (label)` rows for a not-found footer —
453
472
  * running bg agents the CALLER can address (canAccess scopes; CC's self/observer exclusions have no
@@ -469,8 +488,8 @@ export declare function runningBackgroundAgentLabelsLane(core: DurableAgentCore,
469
488
  * rows. CC filters `!n.has(i.id)` — a NAMED agent is deliberately NOT repeated here, because
470
489
  * its addressable form is the name, not the id. The pre-RB-332 sema code merged both legs
471
490
  * into one list and justified it with "named has no counterpart", a claim [c209-D] retired
472
- * when the explicit `name` field landed. The id stays in these rows because TaskOutput
473
- * resolves exact ids only: an agent nobody named is the one a retry can reach by its id alone.
491
+ * when the explicit `name` field landed. The id stays in these rows because the task faces
492
+ * resolve exact ids: an agent nobody named is the one a retry can reach by its id alone.
474
493
  * CC's `YEd` "Running teammates:" leg has no sema counterpart (no teammate registry on this face) and is
475
494
  * honestly absent rather than faked.
476
495
  */
@@ -478,8 +497,8 @@ export declare function runningAgentFooterLane(core: DurableAgentCore, access: T
478
497
  named: string[];
479
498
  background: string[];
480
499
  };
481
- /** The not-found TAIL both task faces share (CC `rxo`, appended by `uMs` for TaskStop
482
- * and by `xwd` 220:472095-472097 for TaskOutput). Empty string when the caller has nothing running. */
500
+ /** The not-found TAIL both task faces share (CC `rxo`, appended by `uMs` for TaskStop;
501
+ * the host poll's not-found carries the same tail). Empty string when the caller has nothing running. */
483
502
  export declare function notFoundRunningAgentsTail(footer: {
484
503
  named: string[];
485
504
  background: string[];
@@ -535,44 +554,7 @@ export declare function serveDurableAgentRowLane(row: BackgroundAgentRecord,
535
554
  * {@link import("./agent-state.js").agentStateSourceOfRecord}(row)): rendered as the `state:` line and
536
555
  * carried as `details.agentState`. Absent ⇒ neither appears (a serving layer that does not read it). */
537
556
  agentState?: AgentState): UnifiedTaskResult;
538
- /**
539
- * design/158 S1 (RB-205-B 半) — spill the FULL text behind a CLIPPED background_agent result to the
540
- * offload store, and append a ref-disclosure so the middle `clipTaskOutput` drops is not gone for good.
541
- * `RegisterBackgroundAgentInput` deliberately carries no `outputFile` (ref-not-path is the design/158
542
- * §2.4 divergence — TOC/TOB compatible, unlike a local path), so this is the only pageback this lane
543
- * gets; it reuses the SAME vocabulary as the offload face (design/108: {@link OFFLOAD_TOOL_NAME},
544
- * {@link buildToolResultRef} — RB-273's single mint point) instead of inventing a parallel one.
545
- *
546
- * Lazy: only writes on the FIRST poll whose clip actually cut something (`clipped !== full`) — a short
547
- * result never touches the store, matching design/158 §2.1 ("spill is a fidelity layer, not a new
548
- * source of truth"). Idempotent PER REVIVE CYCLE: the ref folds in `handle.reviveCycle` (a revive clears
549
- * `handle.spillRef` — see {@link reviveBackgroundAgentLane} — but `handle.id` itself does NOT change
550
- * across a revive, so without the cycle in the ref, cycle 2's spill would mint the SAME ref string as
551
- * cycle 1's and the store's write-once contract would silently keep cycle 1's STALE text under a ref
552
- * now disclosed as cycle 2's current result). Caching the minted ref on the handle (rather than just
553
- * re-deriving+re-`put`ting every poll and trusting the store's own write-once no-op) keeps the disclosed
554
- * ref byte-stable across polls and avoids a redundant round-trip to a durable backend on every poll.
555
- *
556
- * No store configured (a deployment that never wired a `toolResultStore`) ⇒ returns `clipped` UNCHANGED
557
- * — the legal degrade design/158 §2.2 calls for, byte-identical to pre-S1 behavior.
558
- *
559
- * Backlog #169 — a FAILING `put` (throwing or rejecting; the store contract admits both dialects) is
560
- * NOT fatal to the poll: the clipped text is still served, with {@link AGENT_SPILL_FAILED_NOTE} in
561
- * place of the ref disclosure (advertising a ref nobody can read back would be a false promise), and
562
- * `handle.spillFailed` latches so later polls of the same cycle repeat the honest note instead of
563
- * retrying the write — see the catch below for why latch-not-retry. Same "store failure is never
564
- * fatal" posture as the monitor/offload/budget/compaction write sites. A put that settles AFTER a
565
- * revive (stale cycle) is generation-guarded: it answers its own caller honestly but never writes
566
- * spill state onto the new cycle (see `mintCycle` below).
567
- */
568
- export declare function spillClippedAgentResult(handle: BackgroundAgentTaskHandle, full: string, clipped: string, store: ToolResultStore | undefined, sessionId: string | undefined): Promise<string>;
569
557
  export declare function pollBackgroundAgentLane(handle: BackgroundAgentTaskHandle, deadline?: number, signal?: AbortSignal,
570
- /** design/158 S1 — the offload store a clipped result's full text spills to (see
571
- * {@link spillClippedAgentResult}). Absent ⇒ legal degrade, byte-identical to pre-S1 output. */
572
- store?: ToolResultStore,
573
- /** design/158 S1 — the caller's session id, folded into the minted ref for global uniqueness (same
574
- * role `sessionId` plays at every other {@link buildToolResultRef} call site). */
575
- sessionId?: string,
576
558
  /** The run's checkpoint seat — the store a parked row's approval card is read from
577
559
  * ({@link import("./agent-state.js").readAgentState}). Absent ⇒ a parked row reads `approval unreadable`. */
578
560
  checkpointSeat?: CheckpointSeat): Promise<UnifiedTaskResult>;