@sema-agent/core 7.59.0 → 7.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-definition.js +12 -0
  4. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  5. package/dist/agents/agent-transcript-tool.js +3 -1
  6. package/dist/agents/child-model-seat.js +6 -3
  7. package/dist/agents/cumulative-stats.js +0 -1
  8. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  9. package/dist/agents/inherited-tool-pool.js +22 -0
  10. package/dist/agents/retain-ledger.d.ts +11 -1
  11. package/dist/agents/retain-ledger.js +13 -2
  12. package/dist/agents/roster-store.d.ts +1 -1
  13. package/dist/agents/roster-store.js +3 -1
  14. package/dist/agents/send-message-tool.d.ts +8 -19
  15. package/dist/agents/send-message-tool.js +11 -38
  16. package/dist/agents/subagent.d.ts +51 -17
  17. package/dist/agents/subagent.js +117 -78
  18. package/dist/agents/tool-filter.d.ts +1 -3
  19. package/dist/agents/tool-filter.js +4 -12
  20. package/dist/bench/metrics.d.ts +3 -5
  21. package/dist/bench/metrics.js +0 -1
  22. package/dist/brain/degrading.js +3 -1
  23. package/dist/brain/route-adjudicator.js +3 -1
  24. package/dist/brain/status-sink.d.ts +7 -1
  25. package/dist/brain/status-sink.js +6 -0
  26. package/dist/brain/timeout.d.ts +3 -1
  27. package/dist/brain/timeout.js +18 -5
  28. package/dist/core/a2a.d.ts +15 -5
  29. package/dist/core/a2a.js +34 -19
  30. package/dist/core/agent-definition.d.ts +20 -0
  31. package/dist/core/allow-entry.d.ts +2 -0
  32. package/dist/core/allow-entry.js +3 -1
  33. package/dist/core/artifact-host.d.ts +0 -2
  34. package/dist/core/artifact-host.js +0 -1
  35. package/dist/core/auto-mode-defaults.d.ts +8 -0
  36. package/dist/core/auto-mode-defaults.js +1 -0
  37. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  38. package/dist/core/auto-mode.d.ts +39 -4
  39. package/dist/core/auto-mode.js +63 -12
  40. package/dist/core/background-agent-store.d.ts +10 -1
  41. package/dist/core/background-agent-store.js +3 -2
  42. package/dist/core/background-shell.d.ts +12 -1
  43. package/dist/core/background-shell.js +12 -0
  44. package/dist/core/checkpoint-store.d.ts +8 -13
  45. package/dist/core/checkpoint-store.js +4 -3
  46. package/dist/core/compliance.d.ts +1 -1
  47. package/dist/core/credential-echo.d.ts +52 -0
  48. package/dist/core/credential-echo.js +65 -0
  49. package/dist/core/credential-vocabulary.d.ts +13 -3
  50. package/dist/core/credential-vocabulary.js +12 -4
  51. package/dist/core/cross-boundary-taint.d.ts +4 -5
  52. package/dist/core/engine-notice.d.ts +58 -15
  53. package/dist/core/frame-settlement.d.ts +5 -0
  54. package/dist/core/frame-settlement.js +4 -0
  55. package/dist/core/gate-fold.js +7 -5
  56. package/dist/core/gate-lanes.js +39 -8
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +12 -0
  59. package/dist/core/hands-band-screen.js +0 -1
  60. package/dist/core/hands-band.d.ts +0 -3
  61. package/dist/core/hooks.d.ts +39 -56
  62. package/dist/core/hooks.js +123 -77
  63. package/dist/core/image-admission.d.ts +104 -51
  64. package/dist/core/image-admission.js +170 -46
  65. package/dist/core/image-downsample.d.ts +36 -69
  66. package/dist/core/image-downsample.js +111 -73
  67. package/dist/core/integer-option.d.ts +21 -0
  68. package/dist/core/integer-option.js +13 -0
  69. package/dist/core/locked-config.d.ts +54 -3
  70. package/dist/core/locked-config.js +81 -50
  71. package/dist/core/mcp-call-meta.d.ts +2 -2
  72. package/dist/core/mcp-call-meta.js +9 -10
  73. package/dist/core/mcp-failure.d.ts +9 -3
  74. package/dist/core/mcp-failure.js +10 -0
  75. package/dist/core/mcp-host-seat.d.ts +92 -0
  76. package/dist/core/mcp-host-seat.js +131 -0
  77. package/dist/core/mcp-probe.d.ts +7 -2
  78. package/dist/core/mcp-probe.js +7 -2
  79. package/dist/core/mcp-server-spec.d.ts +38 -9
  80. package/dist/core/mcp-server-spec.js +55 -21
  81. package/dist/core/mcp.d.ts +17 -6
  82. package/dist/core/mcp.js +67 -55
  83. package/dist/core/memory-admission.d.ts +23 -6
  84. package/dist/core/memory-admission.js +19 -9
  85. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  86. package/dist/core/memory-engine/content-origin.js +21 -3
  87. package/dist/core/memory-engine/index.d.ts +2 -1
  88. package/dist/core/memory-engine/index.js +2 -1
  89. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  90. package/dist/core/memory-engine/scope-contract.js +2 -2
  91. package/dist/core/memory-engine/sync-client.d.ts +45 -11
  92. package/dist/core/memory-engine/sync-client.js +82 -11
  93. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  94. package/dist/core/memory-engine/sync-report.js +119 -0
  95. package/dist/core/memory-engine/sync.d.ts +4 -2
  96. package/dist/core/mode-policy.d.ts +9 -1
  97. package/dist/core/mode-policy.js +11 -1
  98. package/dist/core/model-receipt.d.ts +39 -0
  99. package/dist/core/model-receipt.js +139 -0
  100. package/dist/core/mods/agent-stations.d.ts +65 -0
  101. package/dist/core/mods/agent-stations.js +105 -0
  102. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  103. package/dist/core/mods/kernel/dispatch.js +4 -4
  104. package/dist/core/mods/kernel/events.d.ts +10 -4
  105. package/dist/core/mods/kernel/events.js +10 -6
  106. package/dist/core/mods/kernel/receive.d.ts +5 -0
  107. package/dist/core/mods/kernel/receive.js +10 -0
  108. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  109. package/dist/core/mods/lifecycle-stations.js +35 -0
  110. package/dist/core/mods/stations.d.ts +51 -59
  111. package/dist/core/mods/stations.js +32 -42
  112. package/dist/core/mods/tool-call.d.ts +10 -4
  113. package/dist/core/mods/tool-call.js +28 -12
  114. package/dist/core/mounted-mcp.d.ts +5 -0
  115. package/dist/core/mounted-mcp.js +2 -2
  116. package/dist/core/namespaced-rule-name.d.ts +7 -1
  117. package/dist/core/namespaced-rule-name.js +13 -2
  118. package/dist/core/oracle-isolation.js +1 -1
  119. package/dist/core/own-property-receipt.d.ts +3 -0
  120. package/dist/core/own-property-receipt.js +3 -0
  121. package/dist/core/park-selfcheck.js +8 -8
  122. package/dist/core/peer-seat.d.ts +63 -8
  123. package/dist/core/peer-seat.js +179 -34
  124. package/dist/core/permission-rule-consent.d.ts +0 -21
  125. package/dist/core/permission-rule-consent.js +1 -2
  126. package/dist/core/permission-rule-model.d.ts +4 -2
  127. package/dist/core/permission-rule-model.js +7 -6
  128. package/dist/core/protocol-http-auth.d.ts +14 -2
  129. package/dist/core/protocol-http-auth.js +16 -7
  130. package/dist/core/read-face-seats.d.ts +7 -5
  131. package/dist/core/read-face-seats.js +4 -1
  132. package/dist/core/redaction-marks.d.ts +4 -3
  133. package/dist/core/redaction-marks.js +2 -2
  134. package/dist/core/remote-env.d.ts +146 -98
  135. package/dist/core/remote-env.js +113 -14
  136. package/dist/core/retention.js +37 -12
  137. package/dist/core/retired-keys.d.ts +6 -1
  138. package/dist/core/retired-keys.js +4 -1
  139. package/dist/core/rewrite-rejudge.d.ts +12 -5
  140. package/dist/core/rewrite-rejudge.js +9 -5
  141. package/dist/core/roles.d.ts +37 -3
  142. package/dist/core/roles.js +126 -78
  143. package/dist/core/rule-owner.d.ts +3 -0
  144. package/dist/core/runner/assemble-result.d.ts +0 -5
  145. package/dist/core/runner/assemble-result.js +0 -1
  146. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  147. package/dist/core/runner/call-hook-stations.js +21 -10
  148. package/dist/core/runner/child-tree.d.ts +7 -8
  149. package/dist/core/runner/child-tree.js +6 -6
  150. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  151. package/dist/core/runner/classifier-ladder.js +39 -8
  152. package/dist/core/runner/construction-doors.js +5 -0
  153. package/dist/core/runner/contracts.d.ts +62 -41
  154. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  155. package/dist/core/runner/cross-boundary-lane.js +11 -2
  156. package/dist/core/runner/env-capability-census.d.ts +15 -20
  157. package/dist/core/runner/env-capability-census.js +25 -34
  158. package/dist/core/runner/file-history-request.d.ts +2 -2
  159. package/dist/core/runner/file-history-request.js +0 -8
  160. package/dist/core/runner/gate-exit.d.ts +75 -7
  161. package/dist/core/runner/gate-exit.js +20 -1
  162. package/dist/core/runner/git-status-frame.d.ts +5 -2
  163. package/dist/core/runner/git-status-frame.js +3 -4
  164. package/dist/core/runner/image.d.ts +7 -2
  165. package/dist/core/runner/image.js +14 -8
  166. package/dist/core/runner/inline-image.d.ts +10 -8
  167. package/dist/core/runner/inline-image.js +11 -9
  168. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  169. package/dist/core/runner/permission-rule-lanes.js +1 -1
  170. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  171. package/dist/core/runner/prepare-boundary-parks.js +3 -3
  172. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  173. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  174. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  175. package/dist/core/runner/prepare-config-doors.js +14 -9
  176. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
  177. package/dist/core/runner/prepare-delegation-surface.js +4 -4
  178. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  179. package/dist/core/runner/prepare-file-history.js +3 -12
  180. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  181. package/dist/core/runner/prepare-gate-stations.js +4 -3
  182. package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
  183. package/dist/core/runner/prepare-hands-readface.js +15 -7
  184. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
  185. package/dist/core/runner/prepare-inherited-gate.js +9 -5
  186. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  187. package/dist/core/runner/prepare-memory.d.ts +2 -2
  188. package/dist/core/runner/prepare-memory.js +2 -2
  189. package/dist/core/runner/prepare-park-ask.d.ts +3 -5
  190. package/dist/core/runner/prepare-park-ask.js +3 -8
  191. package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
  192. package/dist/core/runner/prepare-policy-chain.js +120 -108
  193. package/dist/core/runner/prepare-project-context.js +8 -5
  194. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
  195. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  196. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  197. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  199. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  200. package/dist/core/runner/prepare-task.js +41 -27
  201. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  203. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
  204. package/dist/core/runner/prepare-wiring-manifest.js +32 -18
  205. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  206. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  207. package/dist/core/runner/retired-runner-deps.js +4 -1
  208. package/dist/core/runner/run-attachment-seats.js +3 -3
  209. package/dist/core/runner/run-brain-sinks.js +1 -0
  210. package/dist/core/runner/run-git-lane.d.ts +3 -1
  211. package/dist/core/runner/run-git-lane.js +1 -1
  212. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  213. package/dist/core/runner/run-harness-handlers.js +3 -1
  214. package/dist/core/runner/run-identity-wiring.js +1 -1
  215. package/dist/core/runner/run-leg.js +26 -28
  216. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  217. package/dist/core/runner/run-notification-lane.js +16 -10
  218. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  219. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  220. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  221. package/dist/core/runner/run-turn-boundary.js +12 -7
  222. package/dist/core/runner/runtask.d.ts +7 -4
  223. package/dist/core/runner/runtask.js +19 -11
  224. package/dist/core/runner/skills-seat.js +2 -2
  225. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  226. package/dist/core/runner/synthetic-tools.js +2 -2
  227. package/dist/core/runner/tool-disclosure.js +0 -2
  228. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  229. package/dist/core/runner/tool-face-overlay.js +26 -19
  230. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  231. package/dist/core/runner/tool-result-media-seat.js +17 -1
  232. package/dist/core/runner/turn-attachments.d.ts +3 -5
  233. package/dist/core/runner/turn-attachments.js +3 -16
  234. package/dist/core/runner-deps.d.ts +31 -18
  235. package/dist/core/secret-env.d.ts +3 -2
  236. package/dist/core/session-policy-store.d.ts +9 -2
  237. package/dist/core/session-policy-store.js +16 -1
  238. package/dist/core/session-store.d.ts +3 -2
  239. package/dist/core/session-store.js +50 -11
  240. package/dist/core/skill-grant.d.ts +9 -0
  241. package/dist/core/skill-grant.js +18 -0
  242. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  243. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  244. package/dist/core/stub-env.d.ts +5 -5
  245. package/dist/core/stub-env.js +11 -1
  246. package/dist/core/swappable-deps.d.ts +17 -43
  247. package/dist/core/swappable-deps.js +15 -5
  248. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  249. package/dist/core/task-event.d.ts +18 -2
  250. package/dist/core/task-notification.d.ts +88 -5
  251. package/dist/core/task-notification.js +130 -7
  252. package/dist/core/task-registry-agent.d.ts +18 -12
  253. package/dist/core/task-registry-agent.js +18 -6
  254. package/dist/core/task-registry-monitor.d.ts +7 -0
  255. package/dist/core/task-registry-monitor.js +28 -1
  256. package/dist/core/task-registry-shared.d.ts +38 -3
  257. package/dist/core/task-registry-shared.js +21 -7
  258. package/dist/core/task-registry-workflow.js +1 -1
  259. package/dist/core/task-registry.d.ts +50 -35
  260. package/dist/core/task-registry.js +64 -23
  261. package/dist/core/task-result.d.ts +3 -12
  262. package/dist/core/task-spec.d.ts +3 -6
  263. package/dist/core/task-stream.d.ts +1 -1
  264. package/dist/core/tool-catalog-entries.js +1 -1
  265. package/dist/core/tool-face-reader.d.ts +7 -6
  266. package/dist/core/tool-face-reader.js +4 -3
  267. package/dist/core/tool-name-aliases.d.ts +19 -0
  268. package/dist/core/tool-name-aliases.js +54 -2
  269. package/dist/core/tool-policy.d.ts +5 -4
  270. package/dist/core/tool-policy.js +1 -1
  271. package/dist/core/tool-registry.d.ts +5 -5
  272. package/dist/core/tool-registry.js +2 -2
  273. package/dist/core/tool-result-store.d.ts +88 -5
  274. package/dist/core/tool-result-store.js +51 -12
  275. package/dist/core/tool-spec.d.ts +20 -4
  276. package/dist/core/trace.d.ts +0 -1
  277. package/dist/core/types.d.ts +3 -3
  278. package/dist/core/types.js +1 -1
  279. package/dist/core/untrusted-text.js +1 -1
  280. package/dist/core/user-attachment.d.ts +10 -5
  281. package/dist/core/user-attachment.js +14 -6
  282. package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
  283. package/dist/engine/execution-env/node-execution-env.js +12 -1
  284. package/dist/engine/harness/agent-harness.d.ts +1 -1
  285. package/dist/engine/harness/agent-harness.js +8 -4
  286. package/dist/engine/harness/types.d.ts +112 -29
  287. package/dist/engine/loop/agent-loop.d.ts +12 -12
  288. package/dist/engine/loop/agent-loop.js +153 -21
  289. package/dist/engine/loop/types.d.ts +9 -2
  290. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  291. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  292. package/dist/index.d.ts +22 -14
  293. package/dist/index.js +15 -10
  294. package/dist/internal/harness-types.d.ts +1 -1
  295. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  296. package/dist/orchestration/run-workflow-tool.js +59 -29
  297. package/dist/orchestration/workflow-governance.d.ts +1 -1
  298. package/dist/orchestration/workflow-governance.js +2 -1
  299. package/dist/orchestration/workflow.d.ts +4 -0
  300. package/dist/orchestration/workflow.js +25 -4
  301. package/dist/prompts/default.d.ts +1 -10
  302. package/dist/prompts/default.js +0 -2
  303. package/dist/stores/file/background-agent-store.d.ts +1 -1
  304. package/dist/stores/file/background-agent-store.js +3 -1
  305. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  306. package/dist/stores/file/checkpoint-store.js +19 -14
  307. package/dist/stores/file/file-history-store.d.ts +1 -1
  308. package/dist/stores/file/file-history-store.js +3 -1
  309. package/dist/stores/file/index.d.ts +4 -3
  310. package/dist/stores/file/index.js +17 -8
  311. package/dist/stores/file/mailbox-store.d.ts +1 -1
  312. package/dist/stores/file/mailbox-store.js +3 -1
  313. package/dist/stores/file/memory-store.d.ts +1 -1
  314. package/dist/stores/file/memory-store.js +3 -1
  315. package/dist/stores/file/session-policy-store.d.ts +1 -1
  316. package/dist/stores/file/session-policy-store.js +3 -1
  317. package/dist/stores/file/session-store.d.ts +1 -1
  318. package/dist/stores/file/session-store.js +3 -1
  319. package/dist/stores/file/shared-ledger.d.ts +26 -0
  320. package/dist/stores/file/shared-ledger.js +38 -9
  321. package/dist/stores/file/tool-result-store.d.ts +20 -2
  322. package/dist/stores/file/tool-result-store.js +74 -6
  323. package/dist/stores/file/usage-window-store.d.ts +1 -1
  324. package/dist/stores/file/usage-window-store.js +3 -1
  325. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  326. package/dist/stores/file/workflow-journal-store.js +3 -2
  327. package/dist/tools/fs/containment-face.d.ts +5 -0
  328. package/dist/tools/fs/encoding.d.ts +13 -4
  329. package/dist/tools/fs/encoding.js +17 -2
  330. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  331. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  332. package/dist/tools/fs/fs-bash.d.ts +8 -4
  333. package/dist/tools/fs/fs-bash.js +26 -35
  334. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  335. package/dist/tools/fs/fs-pdf.js +26 -21
  336. package/dist/tools/fs/fs-read.d.ts +5 -4
  337. package/dist/tools/fs/fs-read.js +35 -18
  338. package/dist/tools/fs/fs-search-tools.js +4 -1
  339. package/dist/tools/fs/fs-shared.d.ts +11 -13
  340. package/dist/tools/fs/fs-shared.js +11 -7
  341. package/dist/tools/fs/fs-write.js +5 -5
  342. package/dist/tools/fs/index.d.ts +14 -8
  343. package/dist/tools/fs/index.js +8 -4
  344. package/dist/tools/fs/read-floor.d.ts +44 -1
  345. package/dist/tools/fs/read-floor.js +35 -0
  346. package/dist/tools/fs/removal-targets.d.ts +9 -4
  347. package/dist/tools/fs/removal-targets.js +17 -9
  348. package/dist/tools/fs/search.d.ts +3 -3
  349. package/dist/tools/fs/search.js +4 -4
  350. package/dist/tools/monitor.d.ts +5 -4
  351. package/dist/tools/monitor.js +15 -8
  352. package/dist/tools/scheduler-tools.js +42 -4
  353. package/dist/tools/web.d.ts +0 -10
  354. package/dist/tools/web.js +1 -4
  355. package/package.json +4 -2
  356. package/test/export-surface.snapshot.json +75 -21
  357. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  358. package/wire-changes/core@7.60.0.json +3274 -0
  359. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  360. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -5,7 +5,7 @@ import type { BoundaryLegsGiven } from "./cross-boundary-taint.js";
5
5
  import type { WorkflowRunStore } from "./workflow-run-store.js";
6
6
  import { type BackgroundAgentStore } from "./background-agent-store.js";
7
7
  import type { TaskNotificationPayload } from "./task-notification.js";
8
- import type { ToolResultStore } from "./tool-result-store.js";
8
+ import { type TaskArtifactSeat, type ToolResultStore } from "./tool-result-store.js";
9
9
  import { type SemaTaskType, type StopSource, type SemaTaskStatus, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type SemaTaskHandle, type TaskAccess, type BackgroundAgentTaskHandle, type MonitorTimers, type RegisterMonitorInput, type RegisterWorkflowInput, canAccessWorkflowRun, clipTaskOutput, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE } from "./task-registry-shared.js";
10
10
  export { normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName } from "./task-registry-shared.js";
11
11
  export type { ParkedClaimTicket, RegisterBackgroundAgentInput } from "./task-registry-shared.js";
@@ -48,6 +48,8 @@ export interface RegisterBackgroundBashInput extends TaskAccess {
48
48
  * STATES the lane: a later run teardown does not re-judge the row. Absent = the launcher does not know the
49
49
  * lane; the owning run's teardown supplies it. */
50
50
  retainBackgroundProcesses?: boolean;
51
+ /** See {@link BackgroundBashTaskHandle.taskArtifacts}. */
52
+ taskArtifacts?: TaskArtifactSeat;
51
53
  }
52
54
  /** One row's receipt from {@link TaskRegistry.killAllBackgroundShellsNow} (closed `outcome` set; `retained`
53
55
  * present when the row was retained, whatever the outcome). */
@@ -72,10 +74,6 @@ export interface TaskPollOptions {
72
74
  timeoutMs?: number;
73
75
  /** Abort signal — a blocked wait must stop when the tool call is cancelled. */
74
76
  signal?: AbortSignal;
75
- /** Mirrors {@link import("./types.js").TaskSpec.oneShot} (see {@link TaskToolOptions.oneShot}
76
- * for the full contract): forwarded to the background_agent lane's still-running poll body so it
77
- * does not teach "you will be notified" when this run has no later turn to receive one. */
78
- oneShot?: boolean;
79
77
  /** design/158 S1 (RB-205-B 半): the offload store a CLIPPED background_agent result's full text
80
78
  * spills to — the disclosure gains a `ReadToolResult` ref instead of the middle staying gone for
81
79
  * good (see {@link import("./task-registry-agent.js").spillClippedAgentResult}). Absent (a
@@ -110,15 +108,6 @@ export interface TaskToolOptions extends TaskAccess {
110
108
  * `taskNotification` (B17 方案查出的既有假广告). Default true (a direct public-API consumer keeps the
111
109
  * historical wording); prepare-task passes the real wiring state. */
112
110
  notificationWired?: boolean;
113
- /**
114
- * Mirrors {@link import("./types.js").TaskSpec.oneShot}: this run has no later turn for an
115
- * async background notification to land in (a headless `-p` process exits once the turn ends).
116
- * Threaded into the background_agent lane's non-blocking/blocked-timeout "still running" poll body
117
- * (see {@link import("./task-registry-agent.js").pollBackgroundAgentLane}), which otherwise taught
118
- * "you will be notified when it completes" — the same failure form `run_workflow`'s launch note was
119
- * fixed for (RB-215/run-workflow-tool.ts). Default undefined ⇒ byte-compat (pre-RB-220 wording).
120
- */
121
- oneShot?: boolean;
122
111
  /** design/158 S1 (RB-205-B 半): the offload store a CLIPPED background_agent result's full text
123
112
  * spills to — see {@link TaskPollOptions.toolResultStore} (forwarded verbatim into `pollTask`).
124
113
  * Absent ⇒ legal degrade, byte-identical to pre-S1 output. */
@@ -127,6 +116,33 @@ export interface TaskToolOptions extends TaskAccess {
127
116
  * `pollTask`). The first-party mount passes the same seat the Agent tool parks children into. */
128
117
  checkpointSeat?: CheckpointSeat;
129
118
  }
119
+ /** One row of {@link TaskRegistry.list} (and {@link TaskRegistry.liveTasks}): the DISPLAY projection of a task
120
+ * the caller reaches — never the internal handle. One name for the list, the live reading and the walk behind both. */
121
+ export interface TaskListRow {
122
+ task_id: string;
123
+ type: SemaTaskType;
124
+ status: SemaTaskStatus;
125
+ /** design/129 lifetime flag, surfaced for observability — on resume-leg deployments the
126
+ * canonical taskId==sessionId, so task- and session-scoped rows share an owner KEY VALUE and only this
127
+ * explicit flag tells them apart. Bulk attribution should use {@link TaskRegistry.markStopSourceForOwner}, not a
128
+ * list()-driven loop (the 500-row cap). */
129
+ sessionScoped: boolean;
130
+ /** Present on a shell-lane row (`background_bash` / `monitor`) that THE retain predicate keeps alive
131
+ * past the automatic reaps — the "keeps running" half of an exit listing: the controlled-exit reap and
132
+ * the hard face under `includeRetained: false` leave it running; every other running shell row stops. */
133
+ retained?: true;
134
+ description?: string;
135
+ toolUseId?: string;
136
+ /** The child session a `background_agent` row is anchored to — absent in the startup window before the
137
+ * bind (right after registration, once the child's session id is fixed), present from the bind until a
138
+ * successful release of that session (a terminal row keeps it until that release or the terminal GC),
139
+ * absent on every other task type. Present means "the registry has not released the anchor", not "the
140
+ * session store still holds the session" — the session store answers that. Only this process's
141
+ * handles are listed: a row known only to the durable store of another process is not here. */
142
+ sessionId?: string;
143
+ createdAt: number;
144
+ updatedAt: number;
145
+ }
130
146
  /**
131
147
  * RB-49 B-3 (2026-07-25): the row-metadata projection `getAccessibleTask` returns. Was spelled out as a
132
148
  * hand-written literal in THREE places (this signature, the internal cast below, and the SendMessage
@@ -225,7 +241,9 @@ export declare class TaskRegistry {
225
241
  skippedNoSessions: number;
226
242
  orphanPlacedReleased: number;
227
243
  }>;
228
- releaseDurableTranscriptAnchor(id: string): void;
244
+ /** The successful release of child session `sessionId` ends row `id`'s anchor on it — handle and durable
245
+ * record together, and only while the row still names that session (see {@link releaseDurableTranscriptAnchorLane}). */
246
+ releaseDurableTranscriptAnchor(id: string, sessionId: string): void;
229
247
  bindBackgroundAgentSession(id: string, sessionId: string): void;
230
248
  registerBackgroundAgent(input: RegisterBackgroundAgentInput): string;
231
249
  /** #22 — persist this leg's org-memory admission verdict on the durable row (the cross-process
@@ -400,8 +418,10 @@ export declare class TaskRegistry {
400
418
  private durableHeartbeatTimer;
401
419
  mintTaskId(type: SemaTaskType): string;
402
420
  registerBackgroundBash(input: RegisterBackgroundBashInput): string;
421
+ /** {@link commandRecordSink} over this registry's rows, ref book and guarded send. */
422
+ private commandRecordSink;
403
423
  /** Background output-file read exemption: true iff `canonicalPath` is EXACTLY the registered output
404
- * file of a background bash row that (a) the caller can access (same owner/scope/session visibility as
424
+ * file of a background bash or monitor row that (a) the caller can access (same owner/scope/session visibility as
405
425
  * a TaskOutput poll — {@link canAccess}) and (b) was registered on the caller's OWN execution env —
406
426
  * `env` identity is part of the match, same discipline as {@link runningShellIds}. A canonical path only names a file within ONE env's filesystem
407
427
  * namespace: on a shared registry, a row minted on env A must never exempt a same-named outside-root
@@ -471,6 +491,18 @@ export declare class TaskRegistry {
471
491
  * every registered task kind, workflow included, carries it the same way. Undefined until the task's
472
492
  * own settle point has run ({@link mintCompletionId}), or for an id this registry never held. */
473
493
  getCompletionId(id: string): string | undefined;
494
+ /** Record the ref a task's cut result was stored under (`persistTaskArtifact` landed it) — the read handle a
495
+ * later list of tasks names for it. `cycle` = the revive cycle the result belongs to (0 = the spawn cycle; a workflow
496
+ * has only 0): a row revived since (its cycle moved on) or already gone (terminal GC) records nothing. */
497
+ recordArtifactRef(id: string, ref: string, cycle: number): void;
498
+ /** The legs a page-back of `ref` travels (ReadToolResult's per-call reading): a ref holding a background task's result —
499
+ * its origin is part of the ref ({@link taskArtifactOriginOf}), so no row eviction, restart or other store forgets it —
500
+ * travels what a poll of that task travels ({@link boundaryLegsOf}, `"output"` — another tree's agent, a workflow run, a
501
+ * row gone or out of reach are off-target reads); any other ref (offloaded tool output) stays inside the engine. */
502
+ artifactBoundaryLegs(ref: string, access: TaskAccess, tree: object): BoundaryLegsGiven;
503
+ /** The read handle ({@link taskReadHandleText}) of a task `access` reaches — `undefined` for an unknown or unreachable
504
+ * id (the same info-hiding a poll gives) and for a task with nothing to read beyond its notification. */
505
+ readHandleOf(id: string, access: TaskAccess): string | undefined;
474
506
  /** Bulk stop-source attribution for one owner — the registry-side primitive that
475
507
  * replaces the service's `list()+markStopSource` per-row loop, which had TWO holes: ① `list()` didn't
476
508
  * expose `sessionScoped`, so on the resume leg (canonical taskId==sessionId, rebuilt taskConfig without
@@ -662,28 +694,11 @@ export declare class TaskRegistry {
662
694
  */
663
695
  list(access: TaskAccess, opts?: {
664
696
  limit?: number;
665
- }): Array<{
666
- task_id: string;
667
- type: SemaTaskType;
668
- status: SemaTaskStatus;
669
- /** design/129 lifetime flag, surfaced for observability — on resume-leg deployments the
670
- * canonical taskId==sessionId, so task- and session-scoped rows share an owner KEY VALUE and only this
671
- * explicit flag tells them apart. Bulk attribution should use {@link markStopSourceForOwner}, not a
672
- * list()-driven loop (the 500-row cap). */
673
- sessionScoped: boolean;
674
- /** Present on a shell-lane row (`background_bash` / `monitor`) that THE retain predicate keeps alive
675
- * past the automatic reaps — the "keeps running" half of an exit listing: the controlled-exit reap and
676
- * the hard face under `includeRetained: false` leave it running; every other running shell row stops. */
677
- retained?: true;
678
- description?: string;
679
- toolUseId?: string;
680
- createdAt: number;
681
- updatedAt: number;
682
- }>;
697
+ }): TaskListRow[];
683
698
  /** The tasks `access` reaches that have not finished (`pending`, `running` or `parked`), newest first — EVERY one, with no display
684
699
  * cap ({@link list}'s): the one reading of a leg's live background tasks (its end's {@link owedDeliveries}, the post-compaction
685
700
  * listing and the resume's orphan diff, the suspend's snapshot), each consumer projecting its own columns from it. */
686
- liveTasks(access: TaskAccess): ReturnType<TaskRegistry["list"]>;
701
+ liveTasks(access: TaskAccess): TaskListRow[];
687
702
  /** Every row `access` reaches, newest first, in {@link list}'s projection — the one walk both readings take. */
688
703
  private rowsUnder;
689
704
  /** Throttled {@link gc} for hot-path callers (design/115 review B5): prepare-task runs once per task,
@@ -6,12 +6,13 @@ import { canAccessAgentRecord, } from "./background-agent-store.js";
6
6
  import { delimitUntrusted } from "./untrusted-text.js";
7
7
  import { createSafeNotifier } from "./safe-notify.js";
8
8
  import { stripCwdSentinel } from "../tools/fs/fs-shared.js";
9
+ import { persistTaskArtifact, taskArtifactOriginOf } from "./tool-result-store.js";
9
10
  import { registerMonitorLane, pollMonitorLane, stopMonitorLane } from "./task-registry-monitor.js";
10
11
  import { registerWorkflowLane, pollWorkflowLane, stopWorkflowLane } from "./task-registry-workflow.js";
11
- import { mintCompletionId, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, DURABLE_AGENT_HANDLE_RE, } from "./task-registry-shared.js";
12
+ import { mintCompletionId, taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, DURABLE_AGENT_HANDLE_RE, } from "./task-registry-shared.js";
12
13
  export { normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName } from "./task-registry-shared.js";
13
14
  import { TASK_OUTPUT_TOOL_NAME, TASK_STOP_TOOL_NAME, TASK_OUTPUT_MISSING_ID_MESSAGE, TASK_STOP_MISSING_ID_MESSAGE, TASK_STOP_PARAMS, resolveTaskIdArg, REGISTRY_TASK_TOOL_CAPS, composeTaskOutputDescription, composeTaskOutputParams, composeTaskStopDescription, } from "./task-tool-shape.js";
14
- import { durableAgentArmedLane, durableAgentRowProbeLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, serveDurableAgentRowLane, resolveBackgroundAgentByNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
15
+ import { durableAgentArmedLane, durableAgentRowProbeLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, childSessionAnchorOf, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, serveDurableAgentRowLane, resolveBackgroundAgentByNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
15
16
  import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
16
17
  import { thrownText } from "./thrown-value.js";
17
18
  import { agentStateSourceOfHandle, agentStateSourceOfRecord, agentStateSummary, readAgentState } from "./agent-state.js";
@@ -81,10 +82,29 @@ async function drainBashTailBestEffort(handle) {
81
82
  catch {
82
83
  }
83
84
  }
84
- function bashMirrorGapNote(handle) {
85
- return handle.outputFile !== undefined && handle.spool?.mirrorFailed === true
86
- ? " [!] The output file is INCOMPLETE (one or more writes to it failed) — trust the result text / TaskOutput over the file."
87
- : "";
85
+ function commandRecordSink(rowOf, record, guarded, sink) {
86
+ return (n) => {
87
+ const row = rowOf(n.task_id);
88
+ if ((row?.type !== "background_bash" && row?.type !== "monitor") || n.status === "event")
89
+ return sink(n);
90
+ const gap = row.outputFile === undefined ? "missing" : row.spool?.mirrorFailed === true ? "incomplete" : undefined;
91
+ if (gap === undefined)
92
+ return sink(n);
93
+ const retained = row.spool !== undefined && row.spool.stdout.length + row.spool.stderr.length > 0 ? row.spool : undefined;
94
+ if (row.taskArtifacts === undefined || retained === undefined)
95
+ return sink(gap === "incomplete" ? { ...n, summary: n.summary + commandRecordGapNote(row, gap, undefined) } : n);
96
+ const body = renderSpoolBody(retained, { running: false, handleStatus: row.status, shape: (text) => text, rolledExtraClause: "", drainNote: "" });
97
+ void persistTaskArtifact(row.taskArtifacts, row.id, body).then((artifact) => {
98
+ const ref = artifact.kind === "stored" ? artifact.ref : undefined;
99
+ if (ref !== undefined)
100
+ record(row.id, ref);
101
+ guarded(() => sink(ref === undefined && gap === "missing" ? n : { ...n, summary: n.summary + commandRecordGapNote(row, gap, ref) }));
102
+ });
103
+ };
104
+ }
105
+ function commandRecordGapNote(row, gap, ref) {
106
+ const head = gap === "incomplete" ? ` [!] Its output file ${row.outputFile} is incomplete (an append failed) — do not read it as the whole output` : " [!] No output file holds its output (the file could not be created)";
107
+ return ref === undefined ? `${head}.` : `${head}; what the engine retained (its head and tail, any gap stated) is stored: read it with ReadToolResult (ref "${ref}").`;
88
108
  }
89
109
  function explicitStopBashTerminalNote(handle, alreadyGone) {
90
110
  const resultText = handle.spool !== undefined ? bashTerminalResult(handle.spool) : "";
@@ -98,7 +118,7 @@ function explicitStopBashTerminalNote(handle, alreadyGone) {
98
118
  ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
99
119
  status: "killed",
100
120
  ...(handle.stoppedBy !== undefined ? { stoppedBy: handle.stoppedBy } : {}),
101
- summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — ${detail}${bashMirrorGapNote(handle)}${handle.spool !== undefined ? droppedGapNote(handle.spool) : ""}`,
121
+ summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — ${detail}${handle.spool !== undefined ? droppedGapNote(handle.spool) : ""}`,
102
122
  ...(resultText.length > 0 ? { result: resultText, partial: true } : {}),
103
123
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
104
124
  });
@@ -146,8 +166,8 @@ export class TaskRegistry {
146
166
  async reapDurableAgents(scope, deps, policy) {
147
167
  return reapDurableAgentsLane(this.core, scope, deps, policy);
148
168
  }
149
- releaseDurableTranscriptAnchor(id) {
150
- return releaseDurableTranscriptAnchorLane(this.core, id);
169
+ releaseDurableTranscriptAnchor(id, sessionId) {
170
+ return releaseDurableTranscriptAnchorLane(this.core, id, sessionId);
151
171
  }
152
172
  bindBackgroundAgentSession(id, sessionId) {
153
173
  return bindBackgroundAgentSessionLane(this.core, id, sessionId);
@@ -247,8 +267,8 @@ export class TaskRegistry {
247
267
  runningBackgroundAgentLabels(access) {
248
268
  return runningBackgroundAgentLabelsLane(this.core, access);
249
269
  }
250
- async pollBackgroundAgent(handle, deadline, signal, oneShot, toolResultStore, sessionId, checkpointSeat) {
251
- return pollBackgroundAgentLane(handle, deadline, signal, oneShot, toolResultStore, sessionId, checkpointSeat);
270
+ async pollBackgroundAgent(handle, deadline, signal, toolResultStore, sessionId, checkpointSeat) {
271
+ return pollBackgroundAgentLane(handle, deadline, signal, toolResultStore, sessionId, checkpointSeat);
252
272
  }
253
273
  async stopBackgroundAgent(handle) {
254
274
  return stopBackgroundAgentLane(this.core, handle);
@@ -273,6 +293,7 @@ export class TaskRegistry {
273
293
  if (this.handles.has(id))
274
294
  throw new Error(`TaskRegistry: task id already registered: ${id}`);
275
295
  const now = input.now ?? Date.now();
296
+ const onTerminal = input.onTerminal !== undefined ? this.commandRecordSink(input.onTerminal) : undefined;
276
297
  this.handles.set(id, {
277
298
  id,
278
299
  type: "background_bash",
@@ -286,18 +307,22 @@ export class TaskRegistry {
286
307
  updatedAt: now,
287
308
  env: input.env,
288
309
  shellId: input.shellId,
289
- ...(input.onTerminal !== undefined ? { onTerminal: input.onTerminal } : {}),
310
+ ...(onTerminal !== undefined ? { onTerminal } : {}),
290
311
  ...(input.outputFile !== undefined ? { outputFile: input.outputFile } : {}),
312
+ ...(input.taskArtifacts !== undefined ? { taskArtifacts: input.taskArtifacts } : {}),
291
313
  ...(retainsBackgroundProcesses({ env: envDeclaresRetain(input.env), task: input.retainBackgroundProcesses === true }) ? { retained: true } : {}),
292
314
  ...(input.retainBackgroundProcesses !== undefined ? { retainStatedAtLaunch: true } : {}),
293
315
  });
294
- if (input.onTerminal)
295
- this.startBashWatcher(id, input.onTerminal);
316
+ if (onTerminal)
317
+ this.startBashWatcher(id, onTerminal);
296
318
  return id;
297
319
  }
320
+ commandRecordSink(sink) {
321
+ return commandRecordSink((id) => this.handles.get(id), (id, ref) => this.recordArtifactRef(id, ref, 0), (send) => this.notifier.notify(send, "taskRegistry.commandRecordSink"), sink);
322
+ }
298
323
  isBackgroundOutputFile(canonicalPath, access, env) {
299
324
  for (const handle of this.handles.values()) {
300
- if (handle.type !== "background_bash" || handle.outputFile === undefined)
325
+ if ((handle.type !== "background_bash" && handle.type !== "monitor") || handle.outputFile === undefined)
301
326
  continue;
302
327
  if (handle.env !== env)
303
328
  continue;
@@ -399,6 +424,22 @@ export class TaskRegistry {
399
424
  getCompletionId(id) {
400
425
  return this.handles.get(id)?.completionId;
401
426
  }
427
+ recordArtifactRef(id, ref, cycle) {
428
+ const h = this.handles.get(id);
429
+ if (h === undefined)
430
+ return;
431
+ if ((h.type === "background_agent" ? (h.reviveCycle ?? 0) : 0) !== cycle)
432
+ return;
433
+ h.artifactRef = ref;
434
+ }
435
+ artifactBoundaryLegs(ref, access, tree) {
436
+ const id = taskArtifactOriginOf(ref);
437
+ return id === undefined ? { legs: [] } : this.boundaryLegsOf(id, access, "output", tree);
438
+ }
439
+ readHandleOf(id, access) {
440
+ const h = this.handles.get(id);
441
+ return h !== undefined && canAccess(h, access) ? taskReadHandleText(h) : undefined;
442
+ }
402
443
  markStopSourceForOwner(access, source, opts) {
403
444
  let marked = 0;
404
445
  for (const handle of this.handles.values()) {
@@ -470,7 +511,7 @@ export class TaskRegistry {
470
511
  ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
471
512
  status: "killed",
472
513
  stoppedBy: handle.stoppedBy,
473
- summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — killed before completion (${clause(handle.stoppedBy)})${killFailed ? ` — kill attempt reported ${kill.ok ? "" : kill.error.code}: the process may still be terminating; the environment teardown retries` : ""}${bashMirrorGapNote(handle)}`,
514
+ summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "killed")} — killed before completion (${clause(handle.stoppedBy)})${killFailed ? ` — kill attempt reported ${kill.ok ? "" : kill.error.code}: the process may still be terminating; the environment teardown retries` : ""}`,
474
515
  ...(resultText.length > 0 ? { result: resultText, partial: true } : {}),
475
516
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
476
517
  }));
@@ -765,7 +806,7 @@ export class TaskRegistry {
765
806
  ...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
766
807
  ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
767
808
  status: "failed",
768
- summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (${r.error.message}); no further output will arrive.${bashMirrorGapNote(handle)}`,
809
+ summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (${r.error.message}); no further output will arrive.`,
769
810
  ...(lostResult.length > 0 ? { result: lostResult } : {}),
770
811
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
771
812
  }));
@@ -813,7 +854,6 @@ export class TaskRegistry {
813
854
  ? `${terminalTaskSummary("bash", desc, "killed")} — timed out after ${r.value.timeoutSec}s (its own background time budget); the process was killed`
814
855
  : `${terminalTaskSummary("bash", desc, "killed")} — timed out (its own background time budget); the process was killed`
815
856
  : `${terminalTaskSummary("bash", desc, handle.status === "completed" ? "completed" : handle.status === "killed" ? "killed" : "failed")} — ${r.value.status}`) +
816
- bashMirrorGapNote(handle) +
817
857
  droppedGapNote(spool),
818
858
  ...(resultText.length > 0 ? { result: resultText } : {}),
819
859
  ...(handle.status === "killed" && resultText.length > 0 ? { partial: true } : {}),
@@ -837,7 +877,7 @@ export class TaskRegistry {
837
877
  ...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
838
878
  ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
839
879
  status: "failed",
840
- summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (poll failed: ${thrownText(e)}); no further output will arrive.${bashMirrorGapNote(handle)}`,
880
+ summary: `${terminalTaskSummary("bash", (handle.description ?? "background command").slice(0, 200), "failed")} — lost its background process (poll failed: ${thrownText(e)}); no further output will arrive.`,
841
881
  ...(crashedResult.length > 0 ? { result: crashedResult } : {}),
842
882
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
843
883
  }));
@@ -859,7 +899,7 @@ export class TaskRegistry {
859
899
  return out;
860
900
  }
861
901
  registerMonitor(input) {
862
- return registerMonitorLane(this.core, input);
902
+ return registerMonitorLane(this.core, input.onEvent !== undefined ? { ...input, onEvent: this.commandRecordSink(input.onEvent) } : input);
863
903
  }
864
904
  registerWorkflow(input) {
865
905
  return registerWorkflowLane(this.core, input);
@@ -883,7 +923,7 @@ export class TaskRegistry {
883
923
  if (handle.type === "background_bash")
884
924
  return this.pollBackgroundBash(handle, taskId, access, opts.filter, deadline, opts.signal);
885
925
  if (handle.type === "background_agent")
886
- return this.pollBackgroundAgent(handle, deadline, opts.signal, opts.oneShot, opts.toolResultStore, access.sessionId, opts.checkpointSeat);
926
+ return this.pollBackgroundAgent(handle, deadline, opts.signal, opts.toolResultStore, access.sessionId, opts.checkpointSeat);
887
927
  if (handle.type === "monitor")
888
928
  return this.pollMonitor(handle, opts.filter, deadline, opts.signal);
889
929
  return this.pollWorkflow(handle, access, deadline, opts.signal);
@@ -1031,6 +1071,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1031
1071
  for (const h of this.handles.values()) {
1032
1072
  if (!canAccess(h, access))
1033
1073
  continue;
1074
+ const childSession = childSessionAnchorOf(h);
1034
1075
  out.push({
1035
1076
  task_id: h.id,
1036
1077
  type: h.type,
@@ -1039,6 +1080,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1039
1080
  ...((h.type === "background_bash" || h.type === "monitor") && shellRowRetained(h) ? { retained: true } : {}),
1040
1081
  ...(h.description !== undefined ? { description: h.description } : {}),
1041
1082
  ...(h.toolUseId !== undefined ? { toolUseId: h.toolUseId } : {}),
1083
+ ...(childSession !== undefined ? { sessionId: childSession } : {}),
1042
1084
  createdAt: h.createdAt,
1043
1085
  updatedAt: h.updatedAt,
1044
1086
  });
@@ -1277,7 +1319,7 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1277
1319
  const retrieval_status = r.error.code === "timeout" ? "timeout" : "not_ready";
1278
1320
  return {
1279
1321
  content: `Error (TaskStop): ${r.error.message} — the kill did not land; the process may still be running.` +
1280
- (restored ? " Its watcher keeps running: TaskOutput still works and the completion notification will still fire." : " TaskOutput still reflects its live status."),
1322
+ (restored ? " Its watcher keeps running: its output file keeps filling and the completion notification will still fire." : " It has no watcher, so no completion notification will follow."),
1281
1323
  details: { task_id: handle.id, type: "background_bash", status: handle.status, retrieval_status, error: r.error.code },
1282
1324
  isError: true,
1283
1325
  };
@@ -1354,7 +1396,6 @@ export function createTaskOutputTool(opts) {
1354
1396
  block: args.block !== false,
1355
1397
  timeoutMs: effectiveTimeoutMs,
1356
1398
  signal: ctx.signal,
1357
- oneShot: opts.oneShot,
1358
1399
  toolResultStore: opts.toolResultStore,
1359
1400
  checkpointSeat: opts.checkpointSeat,
1360
1401
  });
@@ -419,7 +419,7 @@ export interface TaskResult {
419
419
  * of silence. Present only when at least one applies (absent = nothing to disclose), so a consumer that
420
420
  * ignores the field is unchanged. A rewind that could NOT be delivered as asked is NOT a note — it is a
421
421
  * terminal failure (`rewind_snapshot.unresolvable` / `rewind.store_unconfigured` /
422
- * `rewind.restore_failed` / `rewind.invalid_spec` / `rewind.rewind_files_retired` /
422
+ * `rewind.restore_failed` / `rewind.invalid_spec` /
423
423
  * `rewind.conflicting_targets` / `rewind.child_scope_unsupported` / `rewind.capture_disabled`).
424
424
  *
425
425
  * - `conversation_only` — {@link TaskSpec.resumeAt} branched the transcript WITHOUT
@@ -776,11 +776,8 @@ export interface TaskResult {
776
776
  * mechanism engaged this leg; absent = none did (byte-compatible).
777
777
  */
778
778
  mechanisms?: {
779
- /** design/132: the natural-end final-verification reminder was injected this run. */
780
- finalVerifyInjected?: true;
781
- /** oracle-grounding gate (opus LOW 复审, additive): HOW MANY final-verification injections
782
- * fired this run — 1 = the R9 one-shot only, 2 = R9 + the grounding re-entry (hard cap).
783
- * Present iff `finalVerifyInjected` is (the boolean stays for compatibility, RL-1336-finalverify-bool). */
779
+ /** design/132: HOW MANY natural-end final-verification injections fired this run — 1 = the R9 one-shot
780
+ * only, 2 = R9 + the oracle-grounding re-entry (hard cap). Present iff at least one fired. */
784
781
  finalVerifyInjections?: number;
785
782
  /** design/133: number of attachment blocks injected this run — turn-boundary bundles
786
783
  * (todo/task reminders, changed-files notes, plan-mode re-reminders, listing drift frames;
@@ -874,8 +871,6 @@ export interface TaskResult {
874
871
  * subagent cost (it lands in `nested`, see assemble-result.ts), so `nestedSubagentMicroUsd` sits
875
872
  * OUTSIDE the costMicroUsd identity, not inside it (measured correction: the previous wording
876
873
  * `llmRoot + nested + compaction === costMicroUsd` only held when nested was 0).
877
- * (`memoryConsolidationMicroUsd` is a separate, budget-excluded line, permanently 0 since the
878
- * runner-integrated consolidation pass was retired — design/157 B19 — and NOT part of any identity).
879
874
  * Present whenever stats are assembled, EXCEPT when `costMicroUsd` is absent for unpriced spend
880
875
  * (RB-368) — the taxonomy would partition a fabricated total, so it is omitted together with it.
881
876
  */
@@ -889,10 +884,6 @@ export interface TaskResult {
889
884
  llmRootMicroUsd: number;
890
885
  /** Delegated sub-agent (nested) LLM cost (micro-USD) = `nested?.costMicroUsd ?? 0`. */
891
886
  nestedSubagentMicroUsd: number;
892
- /** Post-task memory-consolidation LLM cost (micro-USD). Permanently 0 since design/157 B19 retired
893
- * the runner-integrated consolidation pass (kept: public stats contract; an engine-plane re-mount —
894
- * design/138 §7 — would fill it). A separate, budget-excluded line. */
895
- memoryConsolidationMicroUsd: number;
896
887
  /** design/100 §E12 — prompt-suggestion pass LLM cost (micro-USD) = `suggestions?.costMicroUsd ?? 0`; filled
897
888
  * asynchronously after the (post-completion) pass (0 until then). A separate, budget-excluded line. */
898
889
  suggestionsMicroUsd?: number;
@@ -441,11 +441,8 @@ export interface TaskSpec {
441
441
  *
442
442
  * There is NO capture request anymore: first-touch tracking is ON whenever a `RunnerDeps.fileHistoryStore`
443
443
  * is wired, `RunnerDeps.fileHistoryCapture` is not `"off"`, and no {@link fileHistory} off switch is set (per-edited-file backups are near-zero cost — no tree walk,
444
- * no size gate), which is what retired the old `rewindFiles` capture request. The retired
445
- * `rewindFiles` spelling is handled at prepare: its capture sense (true, no `resumeAt`) is a
446
- * tolerated no-op with a deprecation disclosure (the intent is structurally satisfied); its restore
447
- * sense (true, with `resumeAt`) is a typed retirement rejection naming THIS field — the restore
448
- * semantics genuinely changed (whole-tree ⇒ tracked set), so that migration must be explicit.
444
+ * no size gate). The retired `rewindFiles` key is refused by name at prepare (`config.spec_retired_key`) in
445
+ * both of its old senses; the restore sense is THIS field.
449
446
  */
450
447
  restoreFiles?: boolean;
451
448
  /**
@@ -820,7 +817,7 @@ export interface TaskSpec {
820
817
  * their own fake self-check; prompt discipline alone (1.242) had a low landing rate. Opt-in
821
818
  * because the evidence is from UNATTENDED long-task legs; consumers default it OFF and expose an
822
819
  * explicit opt-in (ruled 2026-08-04). Interactive deployments choose per scenario. Read-only /
823
- * Q&A runs never trigger it. Telemetry: `stats.mechanisms.finalVerifyInjected`.
820
+ * Q&A runs never trigger it. Telemetry: `stats.mechanisms.finalVerifyInjections`.
824
821
  */
825
822
  finalVerification?: boolean;
826
823
  /**
@@ -270,7 +270,7 @@ export interface TaskStream extends AsyncIterable<TaskEvent> {
270
270
  * `memory.capture_optout_unavailable` (this run mounted no memory session — nothing to opt out
271
271
  * of), `memory.capture_optout_sweep_failed` (the record STANDS but the §2.3 boundary sweep could
272
272
  * not contain named residue paths — a repeat call is the retry lane),
273
- * `config.memory_capture_unsupported` (remote/per-run deployment shape with no
273
+ * `config.memory_capture_unsupported` (an execution env whose paths are not the host's, with no
274
274
  * {@link RunnerDeps.memoryCaptureRecordStore} — the record would not survive to a resume
275
275
  * replica), `steering.invalid_content` (a non-string `options.reason`), plus the steer-family
276
276
  * `steering.not_running` once the task has finished. Resolves `{ outcome }`: `"created"` = this
@@ -134,7 +134,7 @@ export const TOOL_CATALOG_ENTRIES = [
134
134
  { id: "report-findings", name: "ReportFindings", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["always"], cards: ["report-findings"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.report_findings@1"), ruleFace: { params: ["level"] } } },
135
135
  { id: "structured-output", name: OUTPUT_TOOL_NAME, protocol: ["structured"], source: "synthetic", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.structured_output@1") } },
136
136
  { id: "skill", name: "Skill", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.skill@1"), renderHints: { approvalCard: "skill" }, ruleFace: { params: ["skill", "args"] } } },
137
- { id: "read-tool-result", name: "ReadToolResult", source: "builtin", definedIn: "src/core/tool-result-store.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.read_tool_result@1"), budgetExempt: true, ruleFace: { params: ["ref", "offset", "limit"] } } },
137
+ { id: "read-tool-result", name: "ReadToolResult", source: "builtin", definedIn: "src/core/tool-result-store.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", boundaryLegs: "per_call", effect: "read", contract: c("core.read_tool_result@1"), budgetExempt: true, ruleFace: { params: ["ref", "offset", "limit"] } } },
138
138
  { id: "tool-search", name: "ToolSearch", source: "builtin", definedIn: "src/core/runner/tool-disclosure.ts", mountedBy: ["optional"], cards: ["tool-search"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contract: c("core.tool_search@1"), ruleFace: { params: ["query", "max_results"] } } },
139
139
  { id: "advisor", name: "advisor", source: "builtin", definedIn: "src/core/runner/advisor-tool.ts", mountedBy: ["optional"], cards: ["advisor"], face: { family: "scaffold", boundaryLegs: [], effect: "read", contentOrigin: "local", contract: c("core.advisor@1"), offload: false, budgetExempt: true, ruleFace: { params: [] } } },
140
140
  { id: "ask-user-question", name: "AskUserQuestion", source: "builtin", definedIn: "src/core/ask-question.ts", mountedBy: ["optional"], cards: ["ask-question"], face: { family: "other", boundaryLegs: [], effect: "read", contract: c("core.ask_user_question@1"), renderHints: { approvalCard: "question" }, ruleFace: { params: [] } } },
@@ -9,15 +9,16 @@
9
9
  * the prepare path, and the public surface is tiered by where a symbol is declared (`readToolAxes` is `advanced` for the same reason).
10
10
  */
11
11
  import { type McpServerSpec } from "./mcp-server-spec.js";
12
+ /** Every member name a face declaration has, at any depth — the words a `toolFaces` refusal's member path spells (derived from the tables above). */
13
+ export declare const TOOL_FACE_WORDS: ReadonlySet<string>;
12
14
  /**
13
15
  * {@link readToolFaces}'s answer. `ok: true` hands back a copy of the faces that the reader itself built, plain data and none of the caller's own
14
16
  * objects; `faces` is absent when nothing is declared (no key at all, or an empty record). `ok: false` carries one sentence (its detail cut at
15
- * 240 characters) naming the tool and the member that did not fit. What it may quote of the declaration is its structure and nothing of its content:
16
- * a tool or member name (quoted, a tool name cut at 80 characters), the word a closed table refuses, a key or a list entry over its bound (its
17
- * first 40 characters), a key a pattern parameter names, a count and its bound. It never quotes display text (`userFacingName`, `activity`) or
18
- * the entries of a list that fits. These are the mount's judge's own sentences, the ones it announces at the listing, so the reader and the mount
19
- * tell one operator one thing; `readToolAxes` refuses in the same sentence shape and names no word because an axis word is never a name the
20
- * operator needs echoed to find the fault.
17
+ * 240 characters) pointing at the tool and the member that did not fit. It says the face's own member names, the closed words a member takes,
18
+ * kinds, counts and bounds; it never says the declaration's content — a tool name, an unknown member's name, a word a closed table refuses, a
19
+ * parameter name, a list entry, display text: each is shown in the one caller's-text shape (`callerText`: the redaction mark and its length).
20
+ * These are the mount's judge's own sentences, the ones it announces at the listing, so the reader and the mount tell one operator one thing;
21
+ * `readToolAxes` refuses in the same sentence shape.
21
22
  */
22
23
  export type ToolFacesRead = {
23
24
  ok: true;
@@ -1,4 +1,4 @@
1
- import { dataKind, perToolEmptyName, perToolEntryRefusal, quotedName, receivePerToolDeclaration } from "./mcp-server-spec.js";
1
+ import { callerText, dataKind, perToolEmptyName, perToolEntryRefusal, receivePerToolDeclaration } from "./mcp-server-spec.js";
2
2
  import { isPlainRecord } from "./mods/kernel/receive.js";
3
3
  import { faceProblem } from "./runner/tool-face-overlay.js";
4
4
  import { inlineUntrusted } from "./untrusted-text.js";
@@ -9,6 +9,7 @@ const HOST_TARGET_KINDS = { param: "string" };
9
9
  const HOST_TARGET_REQUIRED = ["param"];
10
10
  const RENDER_HINT_KINDS = { userFacingName: "string", activity: "string", summaryParams: "list", resultCards: "list", approvalCard: "string" };
11
11
  const RULE_FACE_KINDS = { primaryParams: "list", params: "list", nameValues: "list" };
12
+ export const TOOL_FACE_WORDS = new Set([TOOL_FACE_MEMBERS, PATH_TARGET_KINDS, HOST_TARGET_KINDS, RENDER_HINT_KINDS, RULE_FACE_KINDS].flatMap((table) => Object.keys(table)));
12
13
  function kindProblem(label, value, kind) {
13
14
  if (value === undefined)
14
15
  return undefined;
@@ -20,7 +21,7 @@ function membersOf(raw, label, names) {
20
21
  if (!isPlainRecord(raw))
21
22
  return `${label} is ${dataKind(raw)}, not an object`;
22
23
  const unknown = Object.keys(raw).find((member) => !names.includes(member));
23
- return unknown === undefined ? raw : `${label} has the unknown member ${quotedName(unknown)} (the members are ${names.join(", ")})`;
24
+ return unknown === undefined ? raw : `${label} has an unknown member ${callerText(unknown)} (the members are ${names.join(", ")})`;
24
25
  }
25
26
  function ownMember(record, name) {
26
27
  return Object.hasOwn(record, name) ? record[name] : undefined;
@@ -74,7 +75,7 @@ function readOneToolFace(raw) {
74
75
  export function readToolFaces(declared) {
75
76
  if (declared === undefined)
76
77
  return { ok: true };
77
- const received = receivePerToolDeclaration(declared, "toolFaces", "tool");
78
+ const received = receivePerToolDeclaration(declared, "toolFaces", "tool", TOOL_FACE_WORDS);
78
79
  if (!received.ok)
79
80
  return { ok: false, problem: received.problem };
80
81
  const entries = [];
@@ -65,6 +65,7 @@ export type RuleToolNameVerdict = {
65
65
  readonly kind: "unmintable_segment";
66
66
  readonly guidance: string;
67
67
  readonly currentName?: string;
68
+ readonly ambiguous?: true;
68
69
  };
69
70
  /**
70
71
  * A name in ANY protocol namespace split into its owning namespace, its peer segment and its optional tool segment —
@@ -80,6 +81,23 @@ export declare function splitNamespacedName(name: string): {
80
81
  readonly peer: string;
81
82
  readonly tool?: string;
82
83
  } | undefined;
84
+ /** One way a rule name can be read as a protocol name: the peer's MINTED segment and, when the reading names a tool, its segment. */
85
+ export interface PeerReading {
86
+ readonly ns: ProtocolNamespace;
87
+ readonly peer: string;
88
+ readonly tool?: string;
89
+ }
90
+ /**
91
+ * Every way an MCP rule name can denote a peer, when it can be read more than one way — the readings the reference's lookup takes
92
+ * of a name whose server segment may itself carry the separator: a cut at EACH `__` of the body (server = what precedes the cut,
93
+ * tool = what follows) and the whole body as a server (`mcp__a__b` is tool `b` of server `a`, and server `a__b`). The reference
94
+ * spells a server `a__b` as is; the mint folds a run of `_` and drops a trailing one ({@link mintNamespacePrefix}), so a server
95
+ * segment is read through the mint — the peer a reading names is the one the mint would spell it as. `[]` for a name with no
96
+ * second reading: no separator in the body (the one reading is {@link splitNamespacedName}'s), a glob, an empty segment on either
97
+ * side of a cut, or a namespace the reference has no spelling for (only MCP's server names reach a rule from another product).
98
+ * The first reading is the first separator's — the one `splitNamespacedName` gives.
99
+ */
100
+ export declare function peerReadingsOf(name: string): readonly PeerReading[];
83
101
  /**
84
102
  * Does a list of this behavior read a `*` in a tool name as a glob over the WHOLE name — anywhere in it, the lone `*` (every tool)
85
103
  * included? A list that RESTRICTS (`deny`, `ask`) does: it reaches every tool any of whose names the glob matches (the reference's
@@ -117,6 +135,7 @@ export type ToolNameFault = {
117
135
  readonly verdict: Exclude<RuleToolNameVerdict["kind"], "current">;
118
136
  readonly guidance?: string;
119
137
  readonly currentName?: string;
138
+ readonly ambiguous?: true;
120
139
  } | {
121
140
  readonly reason: "near_miss";
122
141
  readonly currentName: string;