@sema-agent/core 7.66.1 → 7.67.1

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 (904) hide show
  1. package/CHANGELOG.md +3518 -0
  2. package/LICENSE +2 -1
  3. package/dist/agents/agent-definition.js +2 -1
  4. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  5. package/dist/agents/agent-transcript-tool.js +4 -3
  6. package/dist/agents/builtin-agents.d.ts +10 -7
  7. package/dist/agents/builtin-agents.js +1 -0
  8. package/dist/agents/cascade.d.ts +24 -11
  9. package/dist/agents/cascade.js +21 -9
  10. package/dist/agents/child-failure.d.ts +30 -0
  11. package/dist/agents/child-failure.js +25 -1
  12. package/dist/agents/composition-placement.d.ts +6 -2
  13. package/dist/agents/composition-placement.js +7 -3
  14. package/dist/agents/cross-session-envelope.d.ts +10 -1
  15. package/dist/agents/cross-session-envelope.js +6 -2
  16. package/dist/agents/cross-session-judge.d.ts +7 -1
  17. package/dist/agents/cross-session-judge.js +1 -0
  18. package/dist/agents/cumulative-stats.d.ts +36 -2
  19. package/dist/agents/cumulative-stats.js +44 -9
  20. package/dist/agents/delegation-registry-seat.js +2 -3
  21. package/dist/agents/inherited-tool-pool.d.ts +9 -4
  22. package/dist/agents/inherited-tool-pool.js +7 -1
  23. package/dist/agents/leg-label.d.ts +28 -0
  24. package/dist/agents/leg-label.js +9 -0
  25. package/dist/agents/list-agents-tool.d.ts +1 -1
  26. package/dist/agents/list-agents-tool.js +4 -4
  27. package/dist/agents/org-delivery-gate.d.ts +129 -23
  28. package/dist/agents/org-delivery-gate.js +41 -20
  29. package/dist/agents/peer-held-queue.d.ts +15 -10
  30. package/dist/agents/peer-held-queue.js +47 -19
  31. package/dist/agents/peer-notice-route.js +2 -2
  32. package/dist/agents/peer-notices.d.ts +13 -2
  33. package/dist/agents/peer-notices.js +12 -2
  34. package/dist/agents/peer-session-drain.d.ts +65 -15
  35. package/dist/agents/peer-session-drain.js +198 -41
  36. package/dist/agents/read-inbox-tool.d.ts +3 -2
  37. package/dist/agents/read-inbox-tool.js +7 -5
  38. package/dist/agents/repair-loop.js +20 -16
  39. package/dist/agents/retain-ledger.d.ts +1 -1
  40. package/dist/agents/retain-ledger.js +2 -4
  41. package/dist/agents/root-session-lane.d.ts +27 -0
  42. package/dist/agents/root-session-lane.js +57 -0
  43. package/dist/agents/roster-store.js +1 -2
  44. package/dist/agents/send-message-tool.js +6 -4
  45. package/dist/agents/subagent.d.ts +20 -4
  46. package/dist/agents/subagent.js +218 -183
  47. package/dist/agents/tool-filter.d.ts +3 -10
  48. package/dist/agents/tool-filter.js +0 -13
  49. package/dist/agents/verifier-independence.d.ts +31 -0
  50. package/dist/agents/verifier-independence.js +23 -0
  51. package/dist/agents/verify.d.ts +23 -11
  52. package/dist/agents/verify.js +28 -12
  53. package/dist/agents/yield-adoption.d.ts +24 -0
  54. package/dist/agents/yield-adoption.js +84 -0
  55. package/dist/bench/metrics.d.ts +2 -2
  56. package/dist/brain/anthropic.d.ts +4 -2
  57. package/dist/brain/anthropic.js +49 -35
  58. package/dist/brain/brain-faces.d.ts +11 -0
  59. package/dist/brain/brain-faces.js +6 -0
  60. package/dist/brain/cache-retention.d.ts +2 -0
  61. package/dist/brain/cache-retention.js +9 -0
  62. package/dist/brain/circuit-breaker.js +51 -26
  63. package/dist/brain/errors.d.ts +15 -1
  64. package/dist/brain/errors.js +8 -0
  65. package/dist/brain/failover.d.ts +6 -0
  66. package/dist/brain/failover.js +52 -37
  67. package/dist/brain/media-degrade.d.ts +5 -0
  68. package/dist/brain/media-degrade.js +4 -0
  69. package/dist/brain/model-capability.d.ts +2 -1
  70. package/dist/brain/model-lane.d.ts +169 -0
  71. package/dist/brain/model-lane.js +505 -0
  72. package/dist/brain/open-responses.js +19 -22
  73. package/dist/brain/openai.js +23 -22
  74. package/dist/brain/provider-message.d.ts +9 -0
  75. package/dist/brain/provider-message.js +18 -0
  76. package/dist/brain/reasoning-request.d.ts +9 -7
  77. package/dist/brain/reasoning-request.js +9 -10
  78. package/dist/brain/reasoning.d.ts +47 -13
  79. package/dist/brain/reasoning.js +20 -10
  80. package/dist/brain/route-adjudicator.d.ts +8 -2
  81. package/dist/brain/route-adjudicator.js +35 -1
  82. package/dist/brain/route-conformance.js +17 -0
  83. package/dist/brain/routing.d.ts +2 -0
  84. package/dist/brain/routing.js +19 -8
  85. package/dist/brain/status-sink.d.ts +5 -4
  86. package/dist/brain/status-sink.js +2 -2
  87. package/dist/brain/stream-engine.js +8 -2
  88. package/dist/brain/stream-shared.d.ts +12 -0
  89. package/dist/brain/stream-shared.js +18 -0
  90. package/dist/brain/timeout.d.ts +28 -0
  91. package/dist/brain/timeout.js +13 -4
  92. package/dist/brain/tool-schema-projection.d.ts +2 -0
  93. package/dist/brain/tool-schema-projection.js +108 -0
  94. package/dist/brain/usage-reading.d.ts +49 -0
  95. package/dist/brain/usage-reading.js +44 -0
  96. package/dist/brain/usage-reasoning.d.ts +38 -0
  97. package/dist/brain/usage-reasoning.js +9 -0
  98. package/dist/config/catalog.d.ts +3 -0
  99. package/dist/config/catalog.js +18 -9
  100. package/dist/core/a2a.d.ts +22 -4
  101. package/dist/core/a2a.js +191 -50
  102. package/dist/core/agent-definition.d.ts +3 -1
  103. package/dist/core/agent-state.d.ts +29 -16
  104. package/dist/core/agent-state.js +36 -9
  105. package/dist/core/allow-entry.d.ts +12 -3
  106. package/dist/core/allow-entry.js +10 -3
  107. package/dist/core/approval-display.d.ts +18 -0
  108. package/dist/core/approval-display.js +26 -0
  109. package/dist/core/approval-object.js +2 -2
  110. package/dist/core/approval-route.d.ts +16 -0
  111. package/dist/core/approval-route.js +5 -0
  112. package/dist/core/approval-words.d.ts +43 -0
  113. package/dist/core/approval-words.js +37 -0
  114. package/dist/core/ask-origin.d.ts +37 -10
  115. package/dist/core/ask-origin.js +19 -7
  116. package/dist/core/ask-question.d.ts +36 -8
  117. package/dist/core/ask-question.js +24 -9
  118. package/dist/core/ask-unresolvable-notice.d.ts +3 -2
  119. package/dist/core/ask-unresolvable-notice.js +3 -2
  120. package/dist/core/attachment-source.d.ts +50 -0
  121. package/dist/core/attachment-source.js +46 -0
  122. package/dist/core/auto-compaction.d.ts +151 -40
  123. package/dist/core/auto-compaction.js +115 -50
  124. package/dist/core/auto-mode.d.ts +5 -0
  125. package/dist/core/auto-mode.js +11 -4
  126. package/dist/core/background-agent-store.d.ts +151 -23
  127. package/dist/core/background-agent-store.js +201 -61
  128. package/dist/core/background-shell.d.ts +4 -1
  129. package/dist/core/background-shell.js +1 -0
  130. package/dist/core/cache-break-detector.d.ts +49 -25
  131. package/dist/core/cache-break-detector.js +99 -44
  132. package/dist/core/caller-text.d.ts +28 -0
  133. package/dist/core/caller-text.js +12 -0
  134. package/dist/core/canonical-json.d.ts +5 -0
  135. package/dist/core/canonical-json.js +7 -0
  136. package/dist/core/checkpoint-features.d.ts +80 -9
  137. package/dist/core/checkpoint-features.js +1 -1
  138. package/dist/core/checkpoint-generation.d.ts +8 -1
  139. package/dist/core/checkpoint-generation.js +3 -0
  140. package/dist/core/checkpoint-queries.d.ts +47 -14
  141. package/dist/core/checkpoint-queries.js +63 -30
  142. package/dist/core/checkpoint-requirements.d.ts +36 -3
  143. package/dist/core/checkpoint-requirements.js +11 -1
  144. package/dist/core/checkpoint-row-verdict.d.ts +0 -2
  145. package/dist/core/checkpoint-row-verdict.js +5 -8
  146. package/dist/core/checkpoint-store.d.ts +166 -41
  147. package/dist/core/checkpoint-store.js +96 -15
  148. package/dist/core/child-clamp-seats.d.ts +10 -2
  149. package/dist/core/child-clamp-seats.js +2 -2
  150. package/dist/core/classifier-unavailable-arm.d.ts +11 -9
  151. package/dist/core/classifier-unavailable-arm.js +4 -2
  152. package/dist/core/command-sandbox-dispatch.d.ts +13 -0
  153. package/dist/core/command-sandbox-dispatch.js +8 -0
  154. package/dist/core/command-sandbox.d.ts +231 -0
  155. package/dist/core/command-sandbox.js +344 -0
  156. package/dist/core/completion-id.d.ts +21 -0
  157. package/dist/core/completion-id.js +14 -0
  158. package/dist/core/config-refusal-codes.d.ts +22 -0
  159. package/dist/core/config-refusal-codes.js +196 -0
  160. package/dist/core/context-edit.d.ts +26 -0
  161. package/dist/core/context-edit.js +4 -2
  162. package/dist/core/context-guard.d.ts +80 -7
  163. package/dist/core/context-guard.js +126 -25
  164. package/dist/core/context-settings.d.ts +32 -0
  165. package/dist/core/context-settings.js +41 -3
  166. package/dist/core/contract-faces.d.ts +22 -0
  167. package/dist/core/contract-faces.js +1 -0
  168. package/dist/core/credential-echo.d.ts +2 -2
  169. package/dist/core/credential-echo.js +2 -2
  170. package/dist/core/cross-boundary-taint.d.ts +10 -8
  171. package/dist/core/decision-receipt.d.ts +3 -2
  172. package/dist/core/decision-receipt.js +1 -1
  173. package/dist/core/definition-entry-grammar.d.ts +42 -0
  174. package/dist/core/definition-entry-grammar.js +15 -0
  175. package/dist/core/engine-attestation.d.ts +19 -4
  176. package/dist/core/engine-attestation.js +4 -0
  177. package/dist/core/engine-capabilities.d.ts +8 -1
  178. package/dist/core/engine-capabilities.js +1 -1
  179. package/dist/core/engine-contracts/open-face-contract.d.ts +39 -0
  180. package/dist/core/engine-contracts/open-face-contract.js +57 -0
  181. package/dist/core/engine-notice.d.ts +164 -33
  182. package/dist/core/exclusive-temp.d.ts +25 -0
  183. package/dist/core/exclusive-temp.js +19 -0
  184. package/dist/core/existing-target.d.ts +112 -0
  185. package/dist/core/existing-target.js +88 -0
  186. package/dist/core/file-history-store.d.ts +14 -6
  187. package/dist/core/gate-lanes.js +8 -3
  188. package/dist/core/gate-outcome.d.ts +2 -1
  189. package/dist/core/git-worktree-env.d.ts +92 -1
  190. package/dist/core/git-worktree-env.js +87 -6
  191. package/dist/core/governance-codes.d.ts +49 -8
  192. package/dist/core/governance-codes.js +59 -8
  193. package/dist/core/hands-band.d.ts +10 -6
  194. package/dist/core/hooks.d.ts +60 -6
  195. package/dist/core/hooks.js +10 -2
  196. package/dist/core/host-floor.d.ts +24 -8
  197. package/dist/core/host-floor.js +45 -16
  198. package/dist/core/human-input-projection.d.ts +7 -0
  199. package/dist/core/human-input-projection.js +11 -3
  200. package/dist/core/image-admission.d.ts +16 -4
  201. package/dist/core/image-admission.js +29 -17
  202. package/dist/core/input-author.d.ts +43 -1
  203. package/dist/core/input-author.js +19 -0
  204. package/dist/core/isolation-scope.d.ts +41 -0
  205. package/dist/core/isolation-scope.js +10 -0
  206. package/dist/core/json-schema-seats.d.ts +11 -0
  207. package/dist/core/json-schema-seats.js +5 -0
  208. package/dist/core/leg-identity.d.ts +53 -5
  209. package/dist/core/leg-identity.js +32 -1
  210. package/dist/core/locked-config.d.ts +33 -38
  211. package/dist/core/locked-config.js +21 -3
  212. package/dist/core/lsp.js +2 -1
  213. package/dist/core/mailbox-store.d.ts +111 -18
  214. package/dist/core/mailbox-store.js +101 -13
  215. package/dist/core/mcp-call-meta.js +1 -1
  216. package/dist/core/mcp-connection-pool.d.ts +8 -2
  217. package/dist/core/mcp-connection-pool.js +3 -1
  218. package/dist/core/mcp-failure.d.ts +6 -1
  219. package/dist/core/mcp-failure.js +10 -0
  220. package/dist/core/mcp-host-read.d.ts +293 -0
  221. package/dist/core/mcp-host-read.js +428 -0
  222. package/dist/core/mcp-server-link.d.ts +28 -6
  223. package/dist/core/mcp-server-link.js +35 -7
  224. package/dist/core/mcp-server-spec.d.ts +22 -29
  225. package/dist/core/mcp-server-spec.js +7 -14
  226. package/dist/core/mcp-server-unavailable-notice.d.ts +32 -0
  227. package/dist/core/mcp-server-unavailable-notice.js +15 -0
  228. package/dist/core/mcp-session-end.d.ts +5 -2
  229. package/dist/core/mcp-session-end.js +7 -2
  230. package/dist/core/mcp-tool-meta.d.ts +6 -0
  231. package/dist/core/mcp-tool-meta.js +1 -0
  232. package/dist/core/mcp.d.ts +54 -19
  233. package/dist/core/mcp.js +194 -241
  234. package/dist/core/memory-engine/committed-shadow-read.d.ts +16 -0
  235. package/dist/core/memory-engine/committed-shadow-read.js +21 -0
  236. package/dist/core/memory-engine/consolidation-driver.js +2 -1
  237. package/dist/core/memory-engine/consolidation.d.ts +3 -3
  238. package/dist/core/memory-engine/control-objects.d.ts +4 -3
  239. package/dist/core/memory-engine/control-objects.js +6 -4
  240. package/dist/core/memory-engine/delegation-settlement.d.ts +127 -25
  241. package/dist/core/memory-engine/delegation-settlement.js +145 -18
  242. package/dist/core/memory-engine/distiller.d.ts +2 -1
  243. package/dist/core/memory-engine/distiller.js +10 -5
  244. package/dist/core/memory-engine/dual-root.js +2 -2
  245. package/dist/core/memory-engine/engine.d.ts +127 -33
  246. package/dist/core/memory-engine/engine.js +774 -323
  247. package/dist/core/memory-engine/entry-scan.d.ts +3 -0
  248. package/dist/core/memory-engine/entry-scan.js +8 -0
  249. package/dist/core/memory-engine/export-bundle.d.ts +4 -0
  250. package/dist/core/memory-engine/export-bundle.js +2 -0
  251. package/dist/core/memory-engine/file-backend.d.ts +62 -17
  252. package/dist/core/memory-engine/file-backend.js +155 -99
  253. package/dist/core/memory-engine/index.d.ts +1 -1
  254. package/dist/core/memory-engine/index.js +1 -1
  255. package/dist/core/memory-engine/layer-observations.d.ts +7 -1
  256. package/dist/core/memory-engine/layer-observations.js +6 -0
  257. package/dist/core/memory-engine/layout.d.ts +88 -26
  258. package/dist/core/memory-engine/layout.js +105 -29
  259. package/dist/core/memory-engine/memory-deployment.js +4 -4
  260. package/dist/core/memory-engine/mount-failed-notice.d.ts +24 -0
  261. package/dist/core/memory-engine/mount-failed-notice.js +22 -0
  262. package/dist/core/memory-engine/origin-clearance.d.ts +15 -1
  263. package/dist/core/memory-engine/origin-clearance.js +30 -10
  264. package/dist/core/memory-engine/scan.js +1 -1
  265. package/dist/core/memory-engine/scope-contract.js +4 -3
  266. package/dist/core/memory-engine/session-write-home.js +13 -1
  267. package/dist/core/memory-engine/sync-client.d.ts +1 -1
  268. package/dist/core/memory-engine/sync-client.js +3 -1
  269. package/dist/core/memory-engine/tools.d.ts +5 -4
  270. package/dist/core/memory-engine/tools.js +1 -1
  271. package/dist/core/memory-engine/types.d.ts +18 -1
  272. package/dist/core/memory-engine/types.js +1 -0
  273. package/dist/core/memory.d.ts +1 -1
  274. package/dist/core/memory.js +2 -6
  275. package/dist/core/mode-policy.d.ts +8 -1
  276. package/dist/core/mode-policy.js +6 -2
  277. package/dist/core/model-fallbacks.d.ts +105 -0
  278. package/dist/core/model-fallbacks.js +79 -0
  279. package/dist/core/model-receipt.d.ts +15 -3
  280. package/dist/core/model-receipt.js +22 -1
  281. package/dist/core/model-seat.d.ts +1 -1
  282. package/dist/core/mods/classic-events.d.ts +5 -1
  283. package/dist/core/mods/dollar.d.ts +47 -2
  284. package/dist/core/mods/dollar.js +28 -5
  285. package/dist/core/mods/kernel/budget.d.ts +6 -0
  286. package/dist/core/mods/kernel/budget.js +6 -0
  287. package/dist/core/mods/kernel/dispatch.d.ts +23 -2
  288. package/dist/core/mods/kernel/dispatch.js +104 -15
  289. package/dist/core/mods/kernel/events.d.ts +18 -1
  290. package/dist/core/mods/kernel/events.js +7 -6
  291. package/dist/core/mods/kernel/index.d.ts +2 -2
  292. package/dist/core/mods/kernel/index.js +1 -1
  293. package/dist/core/mods/kernel/receive.d.ts +2 -1
  294. package/dist/core/mods/lifecycle-stations.d.ts +13 -4
  295. package/dist/core/mods/lifecycle-stations.js +8 -3
  296. package/dist/core/mods/message-display.d.ts +81 -0
  297. package/dist/core/mods/message-display.js +369 -0
  298. package/dist/core/mods/prompt-submit.d.ts +1 -1
  299. package/dist/core/mods/prompt-submit.js +5 -2
  300. package/dist/core/mods/session-append.d.ts +2 -2
  301. package/dist/core/mods/session-append.js +2 -1
  302. package/dist/core/mods/session-compact.js +2 -2
  303. package/dist/core/mods/stations.d.ts +48 -18
  304. package/dist/core/mods/stations.js +100 -19
  305. package/dist/core/mods/stop-answers.d.ts +23 -0
  306. package/dist/core/mods/stop-answers.js +20 -0
  307. package/dist/core/mounted-mcp.d.ts +48 -8
  308. package/dist/core/mounted-mcp.js +82 -16
  309. package/dist/core/namespaced-rule-name.js +2 -1
  310. package/dist/core/own-property-receipt.js +3 -5
  311. package/dist/core/parent-spec-seat.d.ts +20 -1
  312. package/dist/core/parent-spec-seat.js +13 -3
  313. package/dist/core/park-selfcheck.js +1 -0
  314. package/dist/core/path-identity.js +2 -1
  315. package/dist/core/peer-seat.d.ts +21 -7
  316. package/dist/core/peer-seat.js +25 -16
  317. package/dist/core/permission-rule-consent.js +15 -5
  318. package/dist/core/permission-rule-model.d.ts +4 -2
  319. package/dist/core/permission-rule-model.js +43 -23
  320. package/dist/core/permission-rule-store.d.ts +31 -16
  321. package/dist/core/permission-rule-store.js +27 -18
  322. package/dist/core/present-plan-tool.d.ts +6 -1
  323. package/dist/core/present-plan-tool.js +11 -3
  324. package/dist/core/pricing.d.ts +8 -6
  325. package/dist/core/pricing.js +1 -1
  326. package/dist/core/principal-name.d.ts +13 -0
  327. package/dist/core/principal-name.js +9 -2
  328. package/dist/core/process-identity.d.ts +140 -0
  329. package/dist/core/process-identity.js +215 -0
  330. package/dist/core/protocol-http-auth.d.ts +28 -6
  331. package/dist/core/protocol-http-auth.js +22 -5
  332. package/dist/core/protocol-naming.d.ts +7 -0
  333. package/dist/core/protocol-naming.js +12 -2
  334. package/dist/core/protocol-revocation.d.ts +72 -0
  335. package/dist/core/protocol-revocation.js +98 -0
  336. package/dist/core/protocol-table.d.ts +4 -4
  337. package/dist/core/protocol-table.js +3 -2
  338. package/dist/core/push-queue.d.ts +35 -2
  339. package/dist/core/push-queue.js +60 -4
  340. package/dist/core/read-only-shell.d.ts +19 -0
  341. package/dist/core/read-only-shell.js +38 -11
  342. package/dist/core/real-approval.d.ts +26 -0
  343. package/dist/core/real-approval.js +15 -0
  344. package/dist/core/redaction-marks.d.ts +6 -2
  345. package/dist/core/redaction-marks.js +3 -0
  346. package/dist/core/reminder-mint.d.ts +6 -0
  347. package/dist/core/reminder-mint.js +9 -8
  348. package/dist/core/remote-env.d.ts +31 -15
  349. package/dist/core/remote-env.js +29 -0
  350. package/dist/core/request-copy-projection.d.ts +51 -0
  351. package/dist/core/request-copy-projection.js +410 -0
  352. package/dist/core/resume-config-judge.d.ts +69 -0
  353. package/dist/core/resume-config-judge.js +78 -0
  354. package/dist/core/resume-startup-cause.d.ts +14 -4
  355. package/dist/core/resume-startup-cause.js +12 -2
  356. package/dist/core/retention-policy.js +2 -1
  357. package/dist/core/retention.d.ts +119 -24
  358. package/dist/core/retention.js +60 -16
  359. package/dist/core/retired-keys.d.ts +0 -10
  360. package/dist/core/retired-keys.js +2 -3
  361. package/dist/core/roles.d.ts +24 -25
  362. package/dist/core/roles.js +148 -21
  363. package/dist/core/row-shape.d.ts +149 -0
  364. package/dist/core/row-shape.js +184 -0
  365. package/dist/core/runner/advertised-writable-dirs.js +10 -9
  366. package/dist/core/runner/advisor-instructions.d.ts +11 -27
  367. package/dist/core/runner/advisor-instructions.js +18 -20
  368. package/dist/core/runner/advisor-tool.js +1 -0
  369. package/dist/core/runner/announce-once-ledger.js +4 -1
  370. package/dist/core/runner/approval-feedback.d.ts +17 -8
  371. package/dist/core/runner/approval-feedback.js +18 -13
  372. package/dist/core/runner/approver-defect-announcer.d.ts +17 -0
  373. package/dist/core/runner/approver-defect-announcer.js +22 -0
  374. package/dist/core/runner/assemble-result.d.ts +29 -14
  375. package/dist/core/runner/assemble-result.js +16 -25
  376. package/dist/core/runner/cache-hit-account.d.ts +77 -0
  377. package/dist/core/runner/cache-hit-account.js +46 -0
  378. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  379. package/dist/core/runner/call-hook-stations.js +5 -4
  380. package/dist/core/runner/changed-files-scan.d.ts +43 -0
  381. package/dist/core/runner/changed-files-scan.js +34 -0
  382. package/dist/core/runner/checkpoint-scope.d.ts +33 -9
  383. package/dist/core/runner/checkpoint-scope.js +27 -1
  384. package/dist/core/runner/classifier-ladder.d.ts +2 -2
  385. package/dist/core/runner/classifier-ladder.js +18 -9
  386. package/dist/core/runner/clock-and-limits.d.ts +15 -4
  387. package/dist/core/runner/clock-and-limits.js +19 -1
  388. package/dist/core/runner/compact-session.js +84 -14
  389. package/dist/core/runner/compaction-call-options.d.ts +2 -29
  390. package/dist/core/runner/compaction-call-options.js +2 -9
  391. package/dist/core/runner/compaction-restate.d.ts +18 -2
  392. package/dist/core/runner/compaction-restate.js +36 -2
  393. package/dist/core/runner/construction-doors.js +8 -0
  394. package/dist/core/runner/context-room.d.ts +55 -0
  395. package/dist/core/runner/context-room.js +71 -0
  396. package/dist/core/runner/contracts.d.ts +313 -205
  397. package/dist/core/runner/conversation-segment.d.ts +49 -14
  398. package/dist/core/runner/conversation-segment.js +92 -19
  399. package/dist/core/runner/cross-boundary-lane.d.ts +4 -0
  400. package/dist/core/runner/cross-boundary-lane.js +9 -6
  401. package/dist/core/runner/decide-continuation.js +1 -1
  402. package/dist/core/runner/deferred-ask.d.ts +62 -0
  403. package/dist/core/runner/deferred-ask.js +44 -0
  404. package/dist/core/runner/delegation-owner.d.ts +19 -0
  405. package/dist/core/runner/delegation-owner.js +27 -1
  406. package/dist/core/runner/denial-limit-arms.d.ts +10 -6
  407. package/dist/core/runner/denial-limit-arms.js +13 -7
  408. package/dist/core/runner/env-capability-census.d.ts +1 -1
  409. package/dist/core/runner/file-history-request.js +2 -1
  410. package/dist/core/runner/file-history-restore.d.ts +16 -2
  411. package/dist/core/runner/file-history-restore.js +9 -1
  412. package/dist/core/runner/gate-exit.d.ts +18 -5
  413. package/dist/core/runner/gate-exit.js +26 -15
  414. package/dist/core/runner/git-status-frame.d.ts +26 -8
  415. package/dist/core/runner/git-status-frame.js +14 -9
  416. package/dist/core/runner/halt-attribution.d.ts +29 -12
  417. package/dist/core/runner/halt-attribution.js +38 -11
  418. package/dist/core/runner/image.js +3 -2
  419. package/dist/core/runner/initial-run-state.d.ts +1 -1
  420. package/dist/core/runner/initial-run-state.js +4 -4
  421. package/dist/core/runner/language-frame.d.ts +66 -0
  422. package/dist/core/runner/language-frame.js +76 -0
  423. package/dist/core/runner/leg-frame.d.ts +81 -0
  424. package/dist/core/runner/leg-frame.js +68 -0
  425. package/dist/core/runner/main-call-account.d.ts +34 -0
  426. package/dist/core/runner/main-call-account.js +50 -0
  427. package/dist/core/runner/mcp-redial.d.ts +9 -7
  428. package/dist/core/runner/mcp-redial.js +20 -21
  429. package/dist/core/runner/memory-consolidation-driver.d.ts +2 -0
  430. package/dist/core/runner/memory-consolidation-driver.js +5 -3
  431. package/dist/core/runner/messages-omitted-seat.d.ts +2 -0
  432. package/dist/core/runner/messages-omitted-seat.js +21 -0
  433. package/dist/core/runner/model-fallback-seat.d.ts +23 -0
  434. package/dist/core/runner/model-fallback-seat.js +64 -0
  435. package/dist/core/runner/model-lane-seat.d.ts +12 -0
  436. package/dist/core/runner/model-lane-seat.js +35 -0
  437. package/dist/core/runner/nested-memory-content.d.ts +33 -0
  438. package/dist/core/runner/nested-memory-content.js +171 -0
  439. package/dist/core/runner/nested-memory-lane.d.ts +181 -0
  440. package/dist/core/runner/nested-memory-lane.js +673 -0
  441. package/dist/core/runner/park-commit.d.ts +7 -0
  442. package/dist/core/runner/park-commit.js +3 -0
  443. package/dist/core/runner/prepare-advisor.d.ts +7 -9
  444. package/dist/core/runner/prepare-advisor.js +11 -5
  445. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  446. package/dist/core/runner/prepare-artifact.js +8 -3
  447. package/dist/core/runner/prepare-ask-lane.d.ts +21 -3
  448. package/dist/core/runner/prepare-ask-lane.js +32 -28
  449. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  450. package/dist/core/runner/prepare-boundary-parks.js +21 -17
  451. package/dist/core/runner/prepare-caps-and-workflow.d.ts +10 -2
  452. package/dist/core/runner/prepare-caps-and-workflow.js +24 -18
  453. package/dist/core/runner/prepare-config-doors.d.ts +51 -5
  454. package/dist/core/runner/prepare-config-doors.js +73 -73
  455. package/dist/core/runner/prepare-context-lane.d.ts +68 -3
  456. package/dist/core/runner/prepare-context-lane.js +137 -27
  457. package/dist/core/runner/prepare-defer-classify.d.ts +0 -4
  458. package/dist/core/runner/prepare-defer-classify.js +9 -13
  459. package/dist/core/runner/prepare-delegation-surface.d.ts +8 -8
  460. package/dist/core/runner/prepare-delegation-surface.js +72 -64
  461. package/dist/core/runner/prepare-execution-env.js +1 -9
  462. package/dist/core/runner/prepare-file-history.d.ts +3 -2
  463. package/dist/core/runner/prepare-file-history.js +11 -4
  464. package/dist/core/runner/prepare-gate-stations.d.ts +21 -11
  465. package/dist/core/runner/prepare-gate-stations.js +13 -13
  466. package/dist/core/runner/prepare-hands-readface.d.ts +23 -6
  467. package/dist/core/runner/prepare-hands-readface.js +18 -12
  468. package/dist/core/runner/prepare-inherited-gate.d.ts +12 -5
  469. package/dist/core/runner/prepare-inherited-gate.js +14 -10
  470. package/dist/core/runner/prepare-lsp.js +2 -1
  471. package/dist/core/runner/prepare-memory-engine-session.js +30 -10
  472. package/dist/core/runner/prepare-memory.d.ts +4 -0
  473. package/dist/core/runner/prepare-memory.js +38 -16
  474. package/dist/core/runner/prepare-offload-wrappers.d.ts +3 -16
  475. package/dist/core/runner/prepare-offload-wrappers.js +6 -5
  476. package/dist/core/runner/prepare-park-ask.d.ts +11 -3
  477. package/dist/core/runner/prepare-park-ask.js +23 -19
  478. package/dist/core/runner/prepare-policy-chain.d.ts +17 -3
  479. package/dist/core/runner/prepare-policy-chain.js +144 -120
  480. package/dist/core/runner/prepare-project-context.d.ts +15 -53
  481. package/dist/core/runner/prepare-project-context.js +20 -83
  482. package/dist/core/runner/prepare-prompt-assembly.d.ts +7 -1
  483. package/dist/core/runner/prepare-prompt-assembly.js +9 -7
  484. package/dist/core/runner/prepare-prompt-inputs.d.ts +9 -3
  485. package/dist/core/runner/prepare-prompt-inputs.js +5 -3
  486. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
  487. package/dist/core/runner/prepare-protocol-tools.js +46 -27
  488. package/dist/core/runner/prepare-question-face.d.ts +6 -5
  489. package/dist/core/runner/prepare-question-face.js +7 -6
  490. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -0
  491. package/dist/core/runner/prepare-suspend-saga.js +1 -1
  492. package/dist/core/runner/prepare-task.d.ts +3 -3
  493. package/dist/core/runner/prepare-task.js +113 -61
  494. package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -5
  495. package/dist/core/runner/prepare-turn-wiring.d.ts +33 -7
  496. package/dist/core/runner/prepare-turn-wiring.js +53 -17
  497. package/dist/core/runner/prepare-wiring-manifest.d.ts +42 -5
  498. package/dist/core/runner/prepare-wiring-manifest.js +81 -42
  499. package/dist/core/runner/prepare-workspace-restore.js +3 -2
  500. package/dist/core/runner/read-root-grant.js +2 -1
  501. package/dist/core/runner/reply-pricing.d.ts +31 -18
  502. package/dist/core/runner/reply-pricing.js +10 -15
  503. package/dist/core/runner/resume-admission.js +10 -15
  504. package/dist/core/runner/resume-apply.js +20 -9
  505. package/dist/core/runner/resume-checkpoint-screen.js +2 -4
  506. package/dist/core/runner/resume-internals-and-config.d.ts +12 -9
  507. package/dist/core/runner/resume-internals-and-config.js +37 -9
  508. package/dist/core/runner/resume-preflight.js +3 -3
  509. package/dist/core/runner/retired-runner-deps.js +3 -0
  510. package/dist/core/runner/rewind-files.js +6 -6
  511. package/dist/core/runner/run-attachment-seats.d.ts +1 -3
  512. package/dist/core/runner/run-attachment-seats.js +1 -6
  513. package/dist/core/runner/run-brain-sinks.d.ts +4 -7
  514. package/dist/core/runner/run-brain-sinks.js +7 -10
  515. package/dist/core/runner/run-clock-and-content.d.ts +8 -5
  516. package/dist/core/runner/run-clock-and-content.js +18 -3
  517. package/dist/core/runner/run-compaction-machinery.d.ts +8 -4
  518. package/dist/core/runner/run-compaction-machinery.js +4 -19
  519. package/dist/core/runner/run-git-lane.d.ts +8 -3
  520. package/dist/core/runner/run-git-lane.js +5 -3
  521. package/dist/core/runner/run-harness-handlers.d.ts +4 -1
  522. package/dist/core/runner/run-harness-handlers.js +70 -45
  523. package/dist/core/runner/run-identity-wiring.d.ts +6 -0
  524. package/dist/core/runner/run-identity-wiring.js +17 -8
  525. package/dist/core/runner/run-leg.d.ts +5 -2
  526. package/dist/core/runner/run-leg.js +156 -71
  527. package/dist/core/runner/run-notification-lane.d.ts +1 -1
  528. package/dist/core/runner/run-notification-lane.js +22 -10
  529. package/dist/core/runner/run-recovery-lanes.js +8 -6
  530. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -0
  531. package/dist/core/runner/run-settle-and-teardown.js +77 -26
  532. package/dist/core/runner/run-stop-and-final-verify.js +46 -12
  533. package/dist/core/runner/run-telemetry-and-budget-seats.js +19 -28
  534. package/dist/core/runner/run-terminal-adoption.d.ts +2 -2
  535. package/dist/core/runner/run-terminal-adoption.js +14 -9
  536. package/dist/core/runner/run-tool-mount-facts.js +5 -9
  537. package/dist/core/runner/run-turn-boundary.d.ts +3 -2
  538. package/dist/core/runner/run-turn-boundary.js +112 -106
  539. package/dist/core/runner/runtask.d.ts +28 -8
  540. package/dist/core/runner/runtask.js +132 -41
  541. package/dist/core/runner/session-file-state-replay.d.ts +5 -3
  542. package/dist/core/runner/session-file-state-replay.js +10 -3
  543. package/dist/core/runner/session-rule-policy.d.ts +3 -3
  544. package/dist/core/runner/session-verb-doors.d.ts +18 -3
  545. package/dist/core/runner/session-verb-doors.js +38 -6
  546. package/dist/core/runner/shell-env-withheld.d.ts +8 -5
  547. package/dist/core/runner/shell-env-withheld.js +4 -4
  548. package/dist/core/runner/side-call-account.d.ts +12 -8
  549. package/dist/core/runner/side-call-account.js +24 -15
  550. package/dist/core/runner/stream-halt-verbs.js +1 -0
  551. package/dist/core/runner/stream-mode-verb.js +2 -1
  552. package/dist/core/runner/stream-settle-backstop.js +4 -1
  553. package/dist/core/runner/stream-steer-verb.js +35 -19
  554. package/dist/core/runner/sub-agent-deny-lists.d.ts +47 -11
  555. package/dist/core/runner/sub-agent-deny-lists.js +140 -39
  556. package/dist/core/runner/teardown-bounded.d.ts +6 -0
  557. package/dist/core/runner/teardown-bounded.js +12 -7
  558. package/dist/core/runner/terminal-account.d.ts +2 -0
  559. package/dist/core/runner/terminal-account.js +6 -1
  560. package/dist/core/runner/tool-disclosure.js +2 -1
  561. package/dist/core/runner/tool-end-body.js +3 -1
  562. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  563. package/dist/core/runner/tool-face-overlay.js +1 -1
  564. package/dist/core/runner/tool-occurrence.d.ts +34 -9
  565. package/dist/core/runner/tool-occurrence.js +32 -21
  566. package/dist/core/runner/tool-progress-lane.d.ts +20 -5
  567. package/dist/core/runner/tool-progress-lane.js +27 -5
  568. package/dist/core/runner/tool-result-media-seat.d.ts +15 -4
  569. package/dist/core/runner/tool-result-media-seat.js +17 -1
  570. package/dist/core/runner/tool-table-view.js +1 -1
  571. package/dist/core/runner/turn-attachments.d.ts +44 -71
  572. package/dist/core/runner/turn-attachments.js +52 -104
  573. package/dist/core/runner/usage-accounting.d.ts +3 -2
  574. package/dist/core/runner/usage-accounting.js +3 -2
  575. package/dist/core/runner/void-verifier-pause.js +1 -1
  576. package/dist/core/runner-deps.d.ts +42 -158
  577. package/dist/core/runtime-caps.d.ts +16 -4
  578. package/dist/core/secret-env.d.ts +20 -3
  579. package/dist/core/secret-env.js +46 -23
  580. package/dist/core/sensitive-path-policy.d.ts +8 -0
  581. package/dist/core/sensitive-path-policy.js +10 -2
  582. package/dist/core/session-checkout.d.ts +32 -27
  583. package/dist/core/session-checkout.js +109 -61
  584. package/dist/core/session-log-transfer.js +2 -1
  585. package/dist/core/session-policy-store.d.ts +24 -11
  586. package/dist/core/session-policy-store.js +11 -2
  587. package/dist/core/session-store.d.ts +16 -2
  588. package/dist/core/session-store.js +43 -17
  589. package/dist/core/session.d.ts +31 -3
  590. package/dist/core/session.js +33 -2
  591. package/dist/core/shell-run-candidates.d.ts +20 -8
  592. package/dist/core/shell-run-candidates.js +44 -21
  593. package/dist/core/side-query.d.ts +17 -5
  594. package/dist/core/side-query.js +17 -14
  595. package/dist/core/skill-grant.js +2 -3
  596. package/dist/core/skills-directory.js +3 -66
  597. package/dist/core/snapshot-frame-seat.d.ts +8 -0
  598. package/dist/core/snapshot-frame-seat.js +24 -0
  599. package/dist/core/steer-replay.d.ts +19 -3
  600. package/dist/core/steer-replay.js +8 -1
  601. package/dist/core/store-contracts/background-agent-store-contract.d.ts +17 -2
  602. package/dist/core/store-contracts/background-agent-store-contract.js +131 -2
  603. package/dist/core/store-contracts/checkpoint-store-contract.js +63 -1
  604. package/dist/core/store-contracts/mailbox-store-contract.d.ts +15 -2
  605. package/dist/core/store-contracts/mailbox-store-contract.js +213 -3
  606. package/dist/core/store-contracts/permission-rule-write-contract.js +24 -0
  607. package/dist/core/store-contracts/session-deletion-cascade-contract.d.ts +15 -0
  608. package/dist/core/store-contracts/session-deletion-cascade-contract.js +288 -0
  609. package/dist/core/store-contracts/session-policy-store-contract.js +57 -36
  610. package/dist/core/store-contracts/session-repo-contract.js +130 -5
  611. package/dist/core/store-contracts/session-store-contract.d.ts +1 -1
  612. package/dist/core/store-contracts/session-store-contract.js +17 -0
  613. package/dist/core/store-contracts/task-list-store-contract.d.ts +32 -0
  614. package/dist/core/store-contracts/task-list-store-contract.js +240 -0
  615. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  616. package/dist/core/store-contracts/tool-result-store-contract.js +41 -0
  617. package/dist/core/stub-env.d.ts +2 -2
  618. package/dist/core/stub-env.js +1 -0
  619. package/dist/core/synthetic-read-verdict.d.ts +38 -28
  620. package/dist/core/synthetic-read-verdict.js +19 -28
  621. package/dist/core/task-event.d.ts +171 -19
  622. package/dist/core/task-intake.d.ts +26 -0
  623. package/dist/core/task-intake.js +31 -0
  624. package/dist/core/task-limits.d.ts +8 -6
  625. package/dist/core/task-notification.d.ts +88 -8
  626. package/dist/core/task-notification.js +45 -5
  627. package/dist/core/task-registry-agent.d.ts +24 -7
  628. package/dist/core/task-registry-agent.js +51 -28
  629. package/dist/core/task-registry-monitor.js +16 -14
  630. package/dist/core/task-registry-shared.d.ts +177 -35
  631. package/dist/core/task-registry-shared.js +44 -17
  632. package/dist/core/task-registry-workflow.js +8 -5
  633. package/dist/core/task-registry-yield.d.ts +32 -0
  634. package/dist/core/task-registry-yield.js +85 -0
  635. package/dist/core/task-registry.d.ts +88 -10
  636. package/dist/core/task-registry.js +124 -33
  637. package/dist/core/task-result.d.ts +126 -31
  638. package/dist/core/task-spec-members.d.ts +140 -1
  639. package/dist/core/task-spec-members.js +23 -8
  640. package/dist/core/task-spec.d.ts +181 -51
  641. package/dist/core/task-spec.js +1 -1
  642. package/dist/core/task-stream.d.ts +12 -2
  643. package/dist/core/terminal-cause.d.ts +12 -4
  644. package/dist/core/thrown-value.d.ts +49 -7
  645. package/dist/core/thrown-value.js +38 -2
  646. package/dist/core/tool-catalog-entries.js +13 -3
  647. package/dist/core/tool-data-door.d.ts +7 -0
  648. package/dist/core/tool-data-door.js +13 -0
  649. package/dist/core/tool-face-lists.d.ts +25 -0
  650. package/dist/core/tool-face-lists.js +38 -0
  651. package/dist/core/tool-face-reader.d.ts +0 -10
  652. package/dist/core/tool-face-reader.js +5 -3
  653. package/dist/core/tool-list-grammar.d.ts +103 -0
  654. package/dist/core/tool-list-grammar.js +130 -0
  655. package/dist/core/tool-mount-facts.d.ts +47 -0
  656. package/dist/core/tool-mount-facts.js +50 -0
  657. package/dist/core/tool-mount-plan.d.ts +196 -0
  658. package/dist/core/tool-mount-plan.js +404 -0
  659. package/dist/core/tool-mount-static.d.ts +12 -0
  660. package/dist/core/tool-mount-static.js +174 -0
  661. package/dist/core/tool-name-aliases.d.ts +60 -2
  662. package/dist/core/tool-name-aliases.js +22 -2
  663. package/dist/core/tool-name-list.d.ts +3 -0
  664. package/dist/core/tool-name-readings.d.ts +4 -0
  665. package/dist/core/tool-name-readings.js +1 -0
  666. package/dist/core/tool-policy.d.ts +246 -51
  667. package/dist/core/tool-policy.js +165 -71
  668. package/dist/core/tool-registry.d.ts +4 -11
  669. package/dist/core/tool-registry.js +0 -3
  670. package/dist/core/tool-result-bytes.d.ts +94 -0
  671. package/dist/core/tool-result-bytes.js +34 -0
  672. package/dist/core/tool-result-store.d.ts +97 -13
  673. package/dist/core/tool-result-store.js +52 -4
  674. package/dist/core/tool-roster.d.ts +71 -10
  675. package/dist/core/tool-roster.js +71 -21
  676. package/dist/core/tool-search-setting.d.ts +7 -9
  677. package/dist/core/tool-search-setting.js +23 -7
  678. package/dist/core/tool-spec.d.ts +32 -2
  679. package/dist/core/tools.js +6 -20
  680. package/dist/core/trace.d.ts +63 -11
  681. package/dist/core/trace.js +19 -0
  682. package/dist/core/types.d.ts +8 -6
  683. package/dist/core/types.js +3 -1
  684. package/dist/core/unmatched-tool-names.d.ts +37 -0
  685. package/dist/core/unmatched-tool-names.js +18 -0
  686. package/dist/core/untrusted-egress.d.ts +16 -5
  687. package/dist/core/untrusted-egress.js +202 -32
  688. package/dist/core/untrusted-text.d.ts +29 -8
  689. package/dist/core/untrusted-text.js +6 -3
  690. package/dist/core/user-attachment.d.ts +129 -35
  691. package/dist/core/user-attachment.js +124 -57
  692. package/dist/core/user-row-origin.d.ts +63 -0
  693. package/dist/core/user-row-origin.js +61 -0
  694. package/dist/core/wiring-manifest.d.ts +161 -39
  695. package/dist/core/wiring-manifest.js +42 -6
  696. package/dist/core/workflow-run-store-contract.d.ts +11 -1
  697. package/dist/core/workflow-run-store-contract.js +60 -7
  698. package/dist/core/workflow-run-store.d.ts +61 -12
  699. package/dist/core/workflow-run-store.js +100 -15
  700. package/dist/core/workspace-snapshot.d.ts +10 -14
  701. package/dist/core/workspace-snapshot.js +3 -22
  702. package/dist/core/write-protect.d.ts +3 -5
  703. package/dist/core/write-protect.js +2 -4
  704. package/dist/engine/compaction/compaction.d.ts +3 -0
  705. package/dist/engine/compaction/compaction.js +4 -3
  706. package/dist/engine/execution-env/node-execution-env.d.ts +15 -4
  707. package/dist/engine/execution-env/node-execution-env.js +80 -27
  708. package/dist/engine/harness/agent-harness.d.ts +143 -27
  709. package/dist/engine/harness/agent-harness.js +162 -74
  710. package/dist/engine/harness/types.d.ts +84 -13
  711. package/dist/engine/harness/types.js +21 -1
  712. package/dist/engine/llm/tool-turns.d.ts +4 -0
  713. package/dist/engine/llm/tool-turns.js +7 -2
  714. package/dist/engine/llm/types.d.ts +111 -24
  715. package/dist/engine/llm/types.js +69 -5
  716. package/dist/engine/llm/validation.js +2 -1
  717. package/dist/engine/loop/agent-loop.d.ts +39 -6
  718. package/dist/engine/loop/agent-loop.js +172 -82
  719. package/dist/engine/loop/types.d.ts +43 -4
  720. package/dist/engine/lsp/node-lsp-manager.d.ts +5 -3
  721. package/dist/engine/lsp/node-lsp-manager.js +14 -10
  722. package/dist/engine/session/import-validate.js +9 -0
  723. package/dist/engine/session/memory-repo.d.ts +8 -1
  724. package/dist/engine/session/memory-repo.js +20 -12
  725. package/dist/engine/session/repo-utils.d.ts +10 -0
  726. package/dist/engine/session/repo-utils.js +11 -5
  727. package/dist/engine/session/row-cells.d.ts +32 -0
  728. package/dist/engine/session/row-cells.js +25 -0
  729. package/dist/index.d.ts +64 -34
  730. package/dist/index.js +45 -21
  731. package/dist/internal/harness.d.ts +8 -6
  732. package/dist/internal/harness.js +6 -4
  733. package/dist/internal/llm.d.ts +2 -2
  734. package/dist/internal/llm.js +1 -1
  735. package/dist/orchestration/governance-baseline-validity.d.ts +7 -0
  736. package/dist/orchestration/governance-baseline-validity.js +33 -9
  737. package/dist/orchestration/run-workflow-tool.d.ts +2 -0
  738. package/dist/orchestration/run-workflow-tool.js +25 -12
  739. package/dist/orchestration/workflow-governance.d.ts +19 -4
  740. package/dist/orchestration/workflow-governance.js +30 -9
  741. package/dist/orchestration/workflow-primitives.d.ts +4 -1
  742. package/dist/orchestration/workflow-primitives.js +2 -2
  743. package/dist/orchestration/workflow-script-runner.d.ts +1 -1
  744. package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
  745. package/dist/orchestration/workflow-types.d.ts +21 -12
  746. package/dist/orchestration/workflow-types.js +15 -4
  747. package/dist/orchestration/workflow.d.ts +37 -7
  748. package/dist/orchestration/workflow.js +81 -35
  749. package/dist/prompt-assembly/artifact-store.js +6 -9
  750. package/dist/prompt-assembly/assemble.d.ts +4 -10
  751. package/dist/prompt-assembly/assemble.js +1 -3
  752. package/dist/prompt-assembly/catalog/constitution.d.ts +0 -20
  753. package/dist/prompt-assembly/catalog/constitution.js +2 -0
  754. package/dist/prompt-assembly/catalog/core-behavior.js +5 -3
  755. package/dist/prompt-assembly/catalog/engine.d.ts +108 -0
  756. package/dist/prompt-assembly/catalog/engine.js +19 -0
  757. package/dist/prompt-assembly/catalog/environment.d.ts +276 -0
  758. package/dist/prompt-assembly/catalog/environment.js +61 -0
  759. package/dist/prompt-assembly/catalog/index.d.ts +9 -2
  760. package/dist/prompt-assembly/catalog/index.js +73 -2
  761. package/dist/prompt-assembly/catalog/locales/index.d.ts +16 -0
  762. package/dist/prompt-assembly/catalog/locales/index.js +22 -0
  763. package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.d.ts +7 -0
  764. package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +124 -0
  765. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.d.ts +6 -0
  766. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +120 -0
  767. package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.d.ts +8 -0
  768. package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.js +442 -0
  769. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +7 -0
  770. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +15 -0
  771. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.d.ts +7 -0
  772. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +50 -0
  773. package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.d.ts +7 -0
  774. package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +163 -0
  775. package/dist/prompt-assembly/catalog/locales/zh-Hans/role.d.ts +7 -0
  776. package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +148 -0
  777. package/dist/prompt-assembly/catalog/locales/zh-Hans/team.d.ts +6 -0
  778. package/dist/prompt-assembly/catalog/locales/zh-Hans/team.js +246 -0
  779. package/dist/prompt-assembly/catalog/role.js +3 -6
  780. package/dist/prompt-assembly/catalog/schema.d.ts +23 -1
  781. package/dist/prompt-assembly/catalog/schema.js +2 -0
  782. package/dist/prompt-assembly/composer.d.ts +6 -11
  783. package/dist/prompt-assembly/composer.js +7 -7
  784. package/dist/prompt-assembly/engine-text.d.ts +9 -0
  785. package/dist/prompt-assembly/engine-text.js +33 -0
  786. package/dist/prompt-assembly/event-registry.js +3 -3
  787. package/dist/prompt-assembly/explain.d.ts +1 -0
  788. package/dist/prompt-assembly/explain.js +1 -1
  789. package/dist/prompt-assembly/locale-review.d.ts +13 -0
  790. package/dist/prompt-assembly/locale-review.js +19 -0
  791. package/dist/prompt-assembly/overlay.d.ts +7 -3
  792. package/dist/prompt-assembly/overlay.js +27 -5
  793. package/dist/prompt-assembly/renderers.d.ts +4 -4
  794. package/dist/prompt-assembly/renderers.js +26 -17
  795. package/dist/prompt-assembly/role-base.d.ts +1 -1
  796. package/dist/prompt-assembly/select.d.ts +26 -5
  797. package/dist/prompt-assembly/select.js +25 -2
  798. package/dist/prompt-assembly/slots.d.ts +19 -0
  799. package/dist/prompt-assembly/slots.js +16 -0
  800. package/dist/prompt-assembly/sugar.d.ts +4 -7
  801. package/dist/prompt-assembly/sugar.js +1 -2
  802. package/dist/prompt-assembly/tool-catalog.d.ts +5 -1
  803. package/dist/prompt-assembly/tool-catalog.js +5 -1
  804. package/dist/prompt-assembly/turn-snapshot.d.ts +38 -10
  805. package/dist/prompt-assembly/turn-snapshot.js +43 -13
  806. package/dist/prompt-assembly/types.d.ts +3 -0
  807. package/dist/prompts/cowork.d.ts +6 -25
  808. package/dist/prompts/cowork.js +10 -12
  809. package/dist/prompts/default.d.ts +10 -32
  810. package/dist/prompts/default.js +37 -63
  811. package/dist/shell/lex.d.ts +39 -13
  812. package/dist/shell/lex.js +70 -30
  813. package/dist/stores/file/background-agent-store.d.ts +5 -0
  814. package/dist/stores/file/background-agent-store.js +35 -61
  815. package/dist/stores/file/checkpoint-store.d.ts +5 -3
  816. package/dist/stores/file/checkpoint-store.js +8 -10
  817. package/dist/stores/file/fs-atomic.d.ts +27 -70
  818. package/dist/stores/file/fs-atomic.js +52 -148
  819. package/dist/stores/file/index.d.ts +12 -0
  820. package/dist/stores/file/index.js +27 -2
  821. package/dist/stores/file/mailbox-store.d.ts +10 -1
  822. package/dist/stores/file/mailbox-store.js +40 -12
  823. package/dist/stores/file/permission-rule-adopt.js +5 -2
  824. package/dist/stores/file/permission-rule-store.d.ts +81 -20
  825. package/dist/stores/file/permission-rule-store.js +126 -33
  826. package/dist/stores/file/session-policy-store.d.ts +2 -2
  827. package/dist/stores/file/session-store.d.ts +21 -2
  828. package/dist/stores/file/session-store.js +27 -14
  829. package/dist/stores/file/task-list-store.js +23 -25
  830. package/dist/stores/file/tool-result-store.d.ts +45 -7
  831. package/dist/stores/file/tool-result-store.js +99 -36
  832. package/dist/stores/file/workflow-run-store.d.ts +1 -0
  833. package/dist/stores/file/workflow-run-store.js +14 -11
  834. package/dist/tools/artifact/artifact-tool.js +2 -0
  835. package/dist/tools/artifact/local-stub.js +6 -6
  836. package/dist/tools/fs/bash-program-position.d.ts +1 -2
  837. package/dist/tools/fs/bash-readonly-classifier.d.ts +35 -0
  838. package/dist/tools/fs/bash-readonly-classifier.js +50 -12
  839. package/dist/tools/fs/env-error-detail.d.ts +1 -0
  840. package/dist/tools/fs/env-error-detail.js +7 -0
  841. package/dist/tools/fs/fs-bash.d.ts +24 -6
  842. package/dist/tools/fs/fs-bash.js +73 -25
  843. package/dist/tools/fs/fs-pdf.js +6 -4
  844. package/dist/tools/fs/fs-read.d.ts +76 -31
  845. package/dist/tools/fs/fs-read.js +159 -79
  846. package/dist/tools/fs/fs-search-tools.d.ts +1 -1
  847. package/dist/tools/fs/fs-search-tools.js +3 -1
  848. package/dist/tools/fs/fs-shared.d.ts +59 -63
  849. package/dist/tools/fs/fs-shared.js +31 -18
  850. package/dist/tools/fs/fs-write.d.ts +13 -0
  851. package/dist/tools/fs/fs-write.js +69 -13
  852. package/dist/tools/fs/index.d.ts +19 -1
  853. package/dist/tools/fs/index.js +10 -2
  854. package/dist/tools/fs/pdf.js +10 -9
  855. package/dist/tools/fs/read-deny.js +4 -10
  856. package/dist/tools/fs/read-floor.d.ts +5 -4
  857. package/dist/tools/fs/removal-targets.d.ts +11 -5
  858. package/dist/tools/fs/removal-targets.js +62 -32
  859. package/dist/tools/fs/safety.d.ts +26 -19
  860. package/dist/tools/fs/safety.js +13 -8
  861. package/dist/tools/fs/search.d.ts +1 -1
  862. package/dist/tools/fs/shell-read-argv.js +1 -0
  863. package/dist/tools/fs/shell-read-bindings.d.ts +128 -26
  864. package/dist/tools/fs/shell-read-bindings.js +667 -139
  865. package/dist/tools/fs/shell-read-check.js +1 -1
  866. package/dist/tools/fs/shell-read-judge.d.ts +4 -1
  867. package/dist/tools/fs/shell-read-judge.js +5 -1
  868. package/dist/tools/fs/shell-read-plan.d.ts +4 -0
  869. package/dist/tools/fs/shell-read-plan.js +21 -19
  870. package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
  871. package/dist/tools/fs/shell-read-sourced.js +18 -1
  872. package/dist/tools/fs/shell-read-start.d.ts +6 -6
  873. package/dist/tools/fs/shell-read-start.js +1 -6
  874. package/dist/tools/fs/shell-read-word.d.ts +4 -2
  875. package/dist/tools/fs/shell-read-word.js +7 -6
  876. package/dist/tools/fs/shell-read-workdir.d.ts +1 -1
  877. package/dist/tools/fs/shell-reentry-text.d.ts +24 -9
  878. package/dist/tools/fs/shell-reentry-text.js +50 -20
  879. package/dist/tools/monitor.d.ts +4 -0
  880. package/dist/tools/monitor.js +14 -4
  881. package/dist/tools/scheduler-tools.d.ts +5 -2
  882. package/dist/tools/scheduler-tools.js +8 -6
  883. package/dist/tools/task-list.d.ts +49 -20
  884. package/dist/tools/task-list.js +115 -35
  885. package/dist/tools/web.d.ts +13 -3
  886. package/dist/tools/web.js +17 -6
  887. package/dist/tools/worktree.d.ts +3 -2
  888. package/dist/tools/worktree.js +24 -25
  889. package/package.json +10 -3
  890. package/test/export-surface.snapshot.json +340 -32
  891. package/wire-changes/core-stores-sql@7.67.0.json +39 -0
  892. package/wire-changes/core-stores-sql@7.67.1.json +39 -0
  893. package/wire-changes/core@7.67.0.json +12578 -0
  894. package/wire-changes/core@7.67.1.json +406 -0
  895. package/wire-changes/mods-kernel@7.67.0.json +167 -0
  896. package/wire-changes/mods-kernel@7.67.1.json +39 -0
  897. package/wire-changes/primitives@7.67.0.json +325 -0
  898. package/wire-changes/primitives@7.67.1.json +39 -0
  899. package/wire-changes/wiki-gate@7.67.0.json +1636 -0
  900. package/wire-changes/wiki-gate@7.67.1.json +39 -0
  901. package/dist/brain/degrading.d.ts +0 -93
  902. package/dist/brain/degrading.js +0 -189
  903. package/dist/core/tool-conformance.d.ts +0 -20
  904. package/dist/core/tool-conformance.js +0 -37
@@ -21,6 +21,7 @@ import type { ActiveWorktreeSession, AgentHarness, AgentMessage, AgentTool, Anno
21
21
  import type { Model } from "../../internal/llm.js";
22
22
  import type { WorkflowSizeGuideline } from "../../orchestration/workflow-size-guideline.js";
23
23
  import type { ToolManifestRow } from "../../prompt-assembly/tool-catalog.js";
24
+ import type { EngineText } from "../../prompt-assembly/engine-text.js";
24
25
  import type { CwdRef, ContainmentFace } from "../../tools/fs/index.js";
25
26
  /** A leg's WRITE face: the face in force (read per call, following the mode's face) and whether a seat or a clamp DECLARED the fence (a checkpoint row records it; a resume keeps it). */
26
27
  export interface WriteFaceSeat {
@@ -28,10 +29,11 @@ export interface WriteFaceSeat {
28
29
  readonly fenced: boolean;
29
30
  }
30
31
  import type { MaterializedA2a } from "../a2a.js";
31
- import type { CompactionForkContext, CompactionPhaseDurations, MaybeCompactOptions, RapidRefillState } from "../auto-compaction.js";
32
+ import type { CompactedFrameSource, CompactionForkContext, MaybeCompactOptions, RapidRefillState } from "../auto-compaction.js";
32
33
  import type { AutoModeArmingRecipe } from "../auto-mode-arming.js";
33
34
  import type { AutoModeDecider, AutoModeDenialTracker, DenialLimitFallbackFace } from "../auto-mode.js";
34
- import type { HostDecider, SettlementKind } from "../gate-outcome.js";
35
+ import type { SettlementKind } from "../gate-outcome.js";
36
+ import type { AskClass } from "../ask-origin.js";
35
37
  import type { CacheBreakDetector, ToolFingerprintInput } from "../cache-break-detector.js";
36
38
  import type { Checkpoint, CheckpointState, CheckpointStore, CheckpointToken, PendingSteerEntry, PlatformLimitReason, ReopenReason, ResourceLedger, ResourceLimitReason, ResumeOutcome, SerializedCheckpointState } from "../checkpoint-store.js";
37
39
  import type { ExecutionOutcomeRecordWord } from "../checkpoint-execution-record.js";
@@ -39,6 +41,7 @@ import type { ClearedProjectionLedger, MicroCompactMachine, OccurrenceIndex } fr
39
41
  import type { ModBus } from "../mods/kernel/index.js";
40
42
  import type { LegModBus, LegMods } from "../mods/stations.js";
41
43
  import type { HookInvocationIdentity, OrgGateVerdict, PermissionDeniedPayload, PostToolBatchCall, ToolGateInput } from "../hooks.js";
44
+ import type { LegNotice } from "../leg-identity.js";
42
45
  import type { MaterializedMcp } from "../mcp.js";
43
46
  import type { MemoryEngine } from "../memory-engine/engine.js";
44
47
  import type { ResolvedSkillListingBudget } from "../skill-listing-budget.js";
@@ -48,9 +51,10 @@ import type { SafeNotifier } from "../safe-notify.js";
48
51
  import type { RecoveredOrphan } from "../session-reconcile.js";
49
52
  import type { SessionStore, StoredSession } from "../session.js";
50
53
  import type { TaskOutcome } from "../task-outcome.js";
54
+ import type { SessionBoundSpecMember } from "../task-spec-members.js";
51
55
  import type { ModelPricing } from "../pricing.js";
52
56
  import type { PushQueue } from "../push-queue.js";
53
- import type { SystemInjectionPriority, TaskNotificationPayload } from "../task-notification.js";
57
+ import type { SessionAddress, SessionCompletionLane, SystemInjectionPriority, TaskNotificationPayload, TaskNotificationSink } from "../task-notification.js";
54
58
  import type { OnAsk, PermissionResult, ResolvedAsk, ToolCallRequest, ToolPolicy } from "../tool-policy.js";
55
59
  import type { PlacementTarget, RemoteExecutionEnv, SnapshotId, WorkspaceHandle } from "../remote-env.js";
56
60
  import type { ToolDisclosureManifest } from "../trace.js";
@@ -63,21 +67,15 @@ import type { GitStatusLaneRef } from "./git-status-frame.js";
63
67
  import type { SessionReadFileStates } from "./session-read-file-states.js";
64
68
  import type { LegModeCeiling, SessionModeSeats } from "./session-mode-seats.js";
65
69
  import type { BlockedRef, OutputRef, SkillListingEntry } from "./synthetic-tools.js";
66
- import type { AttachmentSource, createAttachmentState, WriteFamily } from "./turn-attachments.js";
70
+ import type { AttachmentSource } from "../attachment-source.js";
71
+ import type { createAttachmentState, WriteFamily } from "./turn-attachments.js";
67
72
  import type { SideCallBook } from "./side-call-account.js";
73
+ import type { ModelFallbackSeat } from "./model-fallback-seat.js";
74
+ import type { DrainedLegFrame, LegAt } from "./leg-frame.js";
68
75
  import type { cacheFamilyOf } from "./usage-accounting.js";
69
- /**
70
- * The frozen task-start copies of the caller's tool-face control arrays, as the config-doors phase takes them (synchronously,
71
- * before the first await): the selector's own layer (`allow` / `exclude`) and the disclosure lists. The driver compiles the
72
- * selector from them once the leg's delegation facts are known ({@link ToolFaceSnapshot}).
73
- */
74
- export interface ToolFaceLists {
75
- allow: readonly string[] | undefined;
76
- exclude: readonly string[] | undefined;
77
- defer: readonly string[] | undefined;
78
- alwaysLoad: readonly string[] | undefined;
79
- restoreGated: readonly string[] | true | undefined;
80
- }
76
+ /** The frozen task-start copies of the caller's tool-face control arrays (the config-doors phase reads them through
77
+ * `readToolFaceLists`, synchronously, before the first await); the driver compiles the selector from them ({@link ToolFaceSnapshot}). */
78
+ export type { ToolFaceLists } from "../tool-face-lists.js";
81
79
  /**
82
80
  * The leg's tool face: its compiled tool selector (the ONE answer to "may this run use this tool" — the roster valve, every
83
81
  * "is X available" mount decision, the MCP refresh and re-dial, the deferred-search lane, and the ceiling every child inherits)
@@ -171,14 +169,14 @@ export interface UsageGovernance {
171
169
  commit(cumulativeTokens: number, cumulativeCostMicroUsd: number | undefined, now: number): Promise<void>;
172
170
  }
173
171
  /**
174
- * The run's turn-start file-history BOUNDARY seat. `begin(entryId)` starts the capture
175
- * for the turn's own initial entry (first-wins: exactly one boundary per turn incarnation, DV-4);
176
- * `settle()` awaits the in-flight capture's settle and is the caller's LEASE CLOSE (awaited before
177
- * the first tool executes) as well as the finish-tail durability await. The capture is bounded by a
178
- * 30s timeout whose abort FENCES the attempt (the store's `boundaryPublishVerdict` guarantees a
179
- * timed-out capture never publishes); failure is disclosed via onError(phase:"rewind") and NEVER
180
- * blocks the turn — a turn whose capture failed simply has no boundary (the reference behaves the
181
- * same), and there is no mid-turn re-capture (the store's spent lease refuses it with zero reads).
172
+ * The run's turn-start file-history BOUNDARY seat. `begin(entryId)` starts the capture for the turn's own entry — the run's
173
+ * first committed row of a person's input (origin `human_input`; first-wins: at most one boundary per turn incarnation, DV-4);
174
+ * `settle()` awaits the in-flight capture's settle and is the caller's LEASE CLOSE (awaited before the next tool executes) as
175
+ * well as the finish-tail durability await. The capture is bounded by a 30s timeout whose abort FENCES the attempt (the
176
+ * store's `boundaryPublishVerdict` guarantees a timed-out capture never publishes); failure is disclosed via
177
+ * onError(phase:"rewind") and, to the person, `rewind.boundary_unrecorded`, and NEVER blocks the turn — a turn whose capture
178
+ * failed simply has no boundary (the reference behaves the same), and there is no mid-turn re-capture (the store's spent
179
+ * lease refuses it with zero reads).
182
180
  */
183
181
  export interface FileHistoryBoundarySeat {
184
182
  begin(entryId: string): void;
@@ -216,12 +214,21 @@ export interface DateAnchorRead {
216
214
  } | undefined;
217
215
  /** The current segment: the nearest compaction entry's id, null before the first compaction. */
218
216
  segment: string | null;
217
+ /** The request head the anchor for the current segment recorded (the head of the epoch the session last
218
+ * opened); undefined ⇒ none recorded — the leg compares nothing and anchors its own. */
219
+ head?: PrefixHeadDigests;
220
+ }
221
+ /** A leg's request head as the session's epoch anchor keeps it: one short unsalted digest per prompt block (by block
222
+ * id) and the tool table's wire digest — what a later leg compares its own head with to name the segments that moved. */
223
+ export interface PrefixHeadDigests {
224
+ blocks: Readonly<Record<string, string>>;
225
+ tools: string;
219
226
  }
220
227
  /**
221
228
  * One engine frame whose commit waits for the receipt of the message carrying it.
222
229
  *
223
230
  * @contract frames.commit_on_receipt — an engine-minted frame that rides a user message (the git-status
224
- * frame, a leg's first-request frames, every turn-boundary attachment, a limit-approach notice) is recorded —
231
+ * frame, a leg's first-request frames, every turn-boundary attachment) is recorded —
225
232
  * an announced set or value, a drained pending entry, a once digest, a window's stamp, a latch, its echo and count
226
233
  * — ONLY when the run loop's `message_end` walk sees a persisted user entry whose text equals the carrying text it
227
234
  * was registered with; every receipt with that text settles on that one entry. Collection records nothing: a
@@ -234,10 +241,26 @@ export interface FrameReceipt {
234
241
  text: string;
235
242
  /** Which frame this receipt settles. No collector renders a frame whose receipt is still pending (the frame is on
236
243
  * its way, not yet in the transcript) — the one reading is `frameCarried` (compaction-restate.ts). */
237
- source: "git_status" | "posture" | "advisor_tool" | "limit_approach" | AttachmentSource;
238
- /** Runs inside the `message_end` walk (synchronous, never awaited): advances the run-local record
239
- * and parks any session write for the next serialization point. */
240
- commit: (entryId: string) => void;
244
+ source: "git_status" | "posture" | "advisor_tool" | "language" | AttachmentSource;
245
+ /** Runs inside the `message_end` walk: advances the run-local record and parks any session write for the next
246
+ * serialization point. Synchronous, except a step that must read the session first (a changed-files notice's
247
+ * announcement, {@link announceWhenCarried}): it returns a promise the walk's handler hands back, so the
248
+ * announcement lands before the next listener reads the event. */
249
+ commit: (entryId: string) => void | Promise<void>;
250
+ }
251
+ /**
252
+ * The limit-approach notice's leg seat. The turn boundary measures the axes and records the HIGHEST threshold the tightest
253
+ * one has crossed, with the sentence that crossing froze; the request-build handler appends that one sentence to the end of
254
+ * every request built after it — never steered, never written to the transcript, one sentence per request (a higher crossing
255
+ * replaces the lower one, it is not added to it). `announce` is the crossing's echo and count, run by the first request that
256
+ * carries it and then cleared, so each threshold is counted once however many requests carry it.
257
+ */
258
+ export interface LimitApproachSeat {
259
+ crossed?: {
260
+ index: 0 | 1;
261
+ text: string;
262
+ announce?: () => void;
263
+ };
241
264
  }
242
265
  /** The leg's frame-receipt ledger — see {@link FrameReceipt}. `listingSnapshotOwed` is the parked
243
266
  * announced-listing snapshot write (a session append from inside the walk would race the loop's own
@@ -400,7 +423,7 @@ export interface Prepared {
400
423
  * assembly would. Always present on Prepared; independent of whether a fileHistoryStore is wired. */
401
424
  editedFilesSnapshot: () => TaskResult["editedFiles"];
402
425
  /** The run's turn-start boundary seat (present iff the run records file history into a wired store and
403
- * the run mounts a real fs env). runtask calls begin() at the first committed user entry and
426
+ * the run mounts a real fs env). runtask calls begin() at the first committed row of a person's input and
404
427
  * awaits settle() at the lease close + the finish tail. */
405
428
  fileHistoryBoundary?: FileHistoryBoundarySeat;
406
429
  /** The run's RESOLVED read face for the result observation seat
@@ -437,6 +460,10 @@ export interface Prepared {
437
460
  toolProgressRef: {
438
461
  current?: ToolProgressLane;
439
462
  };
463
+ /** The leg's `$.turn.abort` seat, late-bound like `toolProgressRef`: the mods facade is bound during prepare,
464
+ * the turn counter and the notice sink exist only in the run body, which fills `seat`. Unfilled means no run
465
+ * body owns the leg yet, and the method answers "no model request is running". */
466
+ turnAbortRef: import("../mods/dollar.js").TurnAbortRef;
440
467
  /** The run's advertised-writable-directory seat (present with hands): `roots` is what the prompt advertised as writable and the fence admitted. Read live wherever a policy is adjudicated off a resumed leg, so the write gate's exemption domain is that same list. `planFile` is the session plan file it admitted (`TaskSpec.planFile`) — the posture frames name it. */
441
468
  advertisedWritableDirs?: Pick<import("./advertised-writable-dirs.js").AdvertisedWritableDirs, "roots" | "planFile" | "readPlanFile">;
442
469
  /** The leg's ONE exempt root (its single resolution of `RunnerDeps.memoryEngineDir`), stamped wherever a policy is adjudicated off a resumed leg (`ToolCallRequest.exemptRoots`) — the same list the live gate stamps. */
@@ -485,7 +512,7 @@ export interface Prepared {
485
512
  toolCallId: string;
486
513
  toolName: string;
487
514
  args: unknown;
488
- decidedBy: HostDecider;
515
+ answered: readonly AskClass[] | undefined;
489
516
  }) => Promise<{
490
517
  readonly refused: string;
491
518
  readonly extension?: string;
@@ -494,6 +521,11 @@ export interface Prepared {
494
521
  }>;
495
522
  /** The leg's `tool.call` station (`mods/tool-call.ts`) — every execution of a call passes it; absent when no handler hangs on the event. */
496
523
  toolCallStation?: import("../mods/tool-call.js").ToolCallStation;
524
+ /** One call's command sandbox plan by its wire name (`command-sandbox.ts`) — the gate's mint, for an approved call a durable
525
+ * RESUME executes outside the loop: that execution runs under it as a live call runs under the gate's. */
526
+ commandSandboxPlanOf: (call: {
527
+ readonly toolName: string;
528
+ }) => import("../command-sandbox.js").CommandSandboxPlan;
497
529
  /** The leg's shell READ STATION, re-run on a durable RESUME before an approved shell call executes: the parked leg's
498
530
  * admission died with that leg, so the resumed bytes are judged (and admitted for their pre-spawn re-establishment)
499
531
  * on THIS leg — a deny row found now vetoes, an operator's edit is judged on the `rejudge` seat. */
@@ -561,8 +593,15 @@ export interface Prepared {
561
593
  * leg always knows its identity.
562
594
  */
563
595
  hookIdentity: HookInvocationIdentity;
596
+ /** Where this leg's user-face notices go and the admission every one is delivered under, minted ONCE in prepare beside the ask
597
+ * source ({@link mintLegNotice}): the leg's own session on a top-level leg, the delegation tree's root naming this leg on a
598
+ * delegated one. The gate's stations and the shell's withheld-variables line read it; no seat derives an address of its own. */
599
+ legNotice: LegNotice;
564
600
  /** The leg's mods bus: one per leg, admitted at this leg's prepare (both seats, `plugin.register` run once for this leg). Every classic station raises its event on it; its `records` are the manifest's `mods[]`. */
565
601
  modBus: ModBus;
602
+ /** End that bus's lifetime (`LegMods.end`): the leg's terminal does, before `session.end` (`raiseSessionEnd`); the lane
603
+ * that ran the leg does again on its way out, so no exit keeps a timer running. A second call does nothing. */
604
+ endModLife: () => void;
566
605
  /** The leg's one admission seat (`session-append.ts`): a direct writer passes each row through it first (`appendAdmittedRow`). */
567
606
  admitRows: RowAdmission;
568
607
  /** The leg's one receiving station (`session-receive.ts`): the live lane, the turn-open redelivery and the box drain's pull
@@ -757,8 +796,11 @@ export interface Prepared {
757
796
  /** `cause` is the structured mechanical fact the mark records (and the
758
797
  * origin marker minted off it carries): `"observed"` for a witnessed external event,
759
798
  * `"static"` for the capability over-approximation, `"derived"` for recall-taint. Absent
760
- * folds to `"observed"` at mint time (the honest floor). */
761
- markPolluted: (reason: string, cause?: import("../memory-engine/types.js").MemoryOriginCause) => void;
799
+ * folds to `"observed"` at mint time (the honest floor). The in-process half lands before it
800
+ * returns; the promise answers the DURABLE marker's outcome and never rejects — every caller
801
+ * delivers the external content only after it answered, and withholds it on `"unpersisted"`
802
+ * (the marker is what another engine reads when it attributes writes made beside this session). */
803
+ markPolluted: (reason: string, cause?: import("../memory-engine/types.js").MemoryOriginCause) => Promise<import("../memory-engine/layout.js").SessionPollutionMarkOutcome>;
762
804
  };
763
805
  /** The task's content-safety config (normalized memory spec): the allowlist for
764
806
  * UNDECLARED tools and the strict execution-class upgrade. Consumed by the tool wrap only. */
@@ -788,7 +830,10 @@ export interface Prepared {
788
830
  * relative paths and unreadable files answer false (named residuals beside the Bash channel).
789
831
  */
790
832
  recallTaint?: {
791
- judgeDeliveredPath: (absPath: string) => boolean;
833
+ /** The exposure verdict of the committed entry whose seat the delivered path is (`"clean"` when it
834
+ * is none): `"marked"` ⇒ the Read marks the session derived; `"challenged"` ⇒ derived too, and the
835
+ * delivery carries a note that the memory tools withhold the entry until the host resolves its challenge. */
836
+ judgeDeliveredPath: (absPath: string) => Promise<"clean" | "marked" | "challenged">;
792
837
  };
793
838
  };
794
839
  /** A per-task env minted by `RunnerDeps.executionEnvFactory` (the remote seam) that THIS task owns
@@ -836,23 +881,25 @@ export interface Prepared {
836
881
  * (`spec.resourceSuspend`) AND it is eligible to suspend durably (a checkpoint store, durable tool
837
882
  * results, and a remote — or static caller-owned, never per-task-stub — env). The run loop calls it at a
838
883
  * CLEAN turn boundary when a resource limit (turns/budget/walltime) was hit: it mints a `resource_limit`
839
- * checkpoint + pauses the workspace + stops the loop cleanly (NOT abort). Returns true iff it committed a
840
- * resumable checkpoint (publishes the committed pause); false ⇒ caller falls through to normal limit handling.
841
- * `sliceSpend` (Slice 4) is THIS slice's cost/tokens/turns, debited onto the cross-slice ledger. */
842
- suspendForResource?: (reason: ResourceLimitReason, sliceSpend: {
884
+ * checkpoint + pauses the workspace + stops the loop cleanly (NOT abort). Answers what the request came to
885
+ * ({@link BoundarySuspendOutcome}); anything but `committed` ⇒ the caller falls through to the normal limit stop.
886
+ * `sliceSpend` (Slice 4) is THIS slice's cost/tokens/turns, debited onto the cross-slice ledger. Only a TASK-axis
887
+ * reason reaches it — the external causes have their own lane below. */
888
+ suspendForResource?: (reason: Exclude<ResourceLimitReason, PlatformLimitReason>, sliceSpend: {
843
889
  costMicroUsd: number;
844
890
  tokens: number;
845
891
  turns: number;
846
892
  walltimeMs: number;
847
- }) => Promise<boolean>;
893
+ }) => Promise<BoundarySuspendOutcome>;
848
894
  /** The PLATFORM-cause suspend — the same commit saga as {@link suspendForResource},
849
895
  * exposed on the INFRASTRUCTURE alone (checkpoint store + durable tool results + remote/no owned env),
850
- * WITHOUT the `spec.resourceSuspend` opt-in. The run loop calls it at a clean turn boundary when the
851
- * execution environment is about to be reclaimed (`env_lifetime`) or a deployment usage window is
852
- * exhausted (`usage_window`) — causes the task did not choose and cannot ask differently for, so a
853
- * deployment that CAN keep the work has no reason to be asked whether it wants to. `hint.resumeAfterMs`
854
- * (usage windows only) rides the gate and extends the checkpoint deadline. Returns true iff it committed
855
- * a resumable checkpoint; false ⇒ the caller stops the run LOUDLY with the cause's terminal code. */
896
+ * WITHOUT the `spec.resourceSuspend` opt-in. The run loop calls it at a clean turn boundary for the
897
+ * external causes — a scheduler's yield (`preempt`), an exhausted deployment usage window
898
+ * (`usage_window`), an execution environment about to be reclaimed (`env_lifetime`) — causes the task did
899
+ * not choose and cannot ask differently for, so a deployment that CAN keep the work has no reason to be
900
+ * asked whether it wants to. `hint.resumeAfterMs` (usage windows only) rides the gate and extends the
901
+ * checkpoint deadline. Answers what the request came to ({@link BoundarySuspendOutcome}); the caller reads
902
+ * the cause's fallback off the boundary's one table (a preempt continues, the other two stop loudly). */
856
903
  suspendForPlatformLimit?: (reason: PlatformLimitReason, sliceSpend: {
857
904
  costMicroUsd: number;
858
905
  tokens: number;
@@ -860,7 +907,11 @@ export interface Prepared {
860
907
  walltimeMs: number;
861
908
  }, hint?: {
862
909
  resumeAfterMs: number;
863
- }) => Promise<boolean>;
910
+ }) => Promise<BoundarySuspendOutcome>;
911
+ /** Why this leg cannot suspend durably — the clauses of every missing infrastructure piece, the one sentence the
912
+ * `resourceSuspend` INACTIVE line and an unhonourable yield both name (the manifest's `suspendLane.reasons` are its
913
+ * codes). Absent ⇔ the infrastructure is ready. */
914
+ suspendLaneGap?: string;
864
915
  /** Epoch ms at which this run must stop and checkpoint because the EXECUTION
865
916
  * ENVIRONMENT's declared lifetime is about to expire (`ExecutionEnv.lifetimeMs` minus
866
917
  * {@link ENV_LIFETIME_SUSPEND_MARGIN_MS}). Undefined ⇒ the env declared no lifetime (every local env,
@@ -966,8 +1017,8 @@ export interface Prepared {
966
1017
  };
967
1018
  /** The per-task human-review accumulator (synchronous `resolveAsk` waits this leg + the carried
968
1019
  * prior-leg burden seeded from the resumed checkpoint). The run loop ADDS the durable-resume latency
969
- * (`now() − cp.suspendedAt`) on a resume, then surfaces it as `stats.humanReview` at assembly (omitted when
970
- * empty). **Budget-EXCLUDED** — never folded into cost/the budget gate. */
1020
+ * (`now() − cp.suspendedAt`) on a resume, then surfaces it as `stats.humanReview` at settle (always, `count: 0`
1021
+ * included). **Budget-EXCLUDED** — never folded into cost/the budget gate. */
971
1022
  /** borrowed-mutable — the hands' read-state map (the SAME `Map` object the toolkit and the context
972
1023
  * lane hold; absent without hands). Read by the provider-rejection recovery arm so its stale-result
973
1024
  * clears retire the entries those transmissions fed, through the same landing the frontier pass uses. */
@@ -1058,15 +1109,18 @@ export interface Prepared {
1058
1109
  lastSentRequest: () => CompactionForkContext | undefined;
1059
1110
  /** The leg's advisor-instructions seat (advisor-instructions.ts); absent when the leg neither mounts the advisor nor has told the model of it. */
1060
1111
  advisorInstruction?: import("./advisor-instructions.js").AdvisorInstructionSeat;
1112
+ /** The leg's language seat (language-frame.ts); absent when the leg states no language, or has nothing to tell and nothing told. */
1113
+ languageSeat?: import("./language-frame.js").LanguageSeat;
1061
1114
  /** #1123 — the memory notices this prepare drained (whole engine reminders, model lane only, no echo): the leg's first
1062
1115
  * request carries them once, ahead of the user's message — a fresh leg's first user message, a resumed leg's
1063
1116
  * continuation. Never the system prompt (an event there breaks the cached prefix twice). Absent when nothing drained. */
1064
1117
  memoryNoticesFrame?: string;
1065
1118
  /** The post-compaction restore (`MaybeCompactOptions.workingFileAttachments.restore`): re-reads the candidates through
1066
1119
  * the leg's one file reader under the run's synthetic-Read judge — the user attachment's own path read — deduplicated
1067
- * against the read state the summary leaves, and mints their attachment frames (`readCompactionRestore`); a file it
1068
- * does not deliver — or whose frame the transcript does not take — is reported (`onError` phase `degraded`,
1069
- * classification `attachment-read`). Present only with hands. */
1120
+ * against the read state the summary leaves, and mints their attachment frames (`readCompactionRestore`); what became of
1121
+ * each is its record on the `compacted` frame (`restoreOutcomes`). A fault that kept a file from the transcript — the
1122
+ * restore threw, the transcript would not take a frame — is reported (`onError` phase `degraded`, classification
1123
+ * `attachment-read`). Present only with hands. */
1070
1124
  compactionRestore?: Required<Pick<NonNullable<import("../auto-compaction.js").MaybeCompactOptions["workingFileAttachments"]>, "restore" | "undelivered">>;
1071
1125
  /** CC post-compact restore parity (2026-07-03): the task's READ files, most recent
1072
1126
  * first (from the hands' readFileState `lastReadAt` stamps). The restore prefers this over the modified set — CC
@@ -1080,11 +1134,6 @@ export interface Prepared {
1080
1134
  * fires for the common relative-vs-canonical case. Present only with hands; absent there is no
1081
1135
  * containment root to resolve against, and every path source is already in the same raw coordinate anyway. */
1082
1136
  normalizeAttachmentPath?: (raw: string) => Promise<string>;
1083
- /** Recognizes the hands Read tool's own dedup-stub markers
1084
- * ({@link isReadDedupStubResult}), so `maybeCompact`'s kept-tail scan can tell a SUBSTANTIVE Read
1085
- * result from a stub hit whose original full transmission may already be summarized away. Present
1086
- * only with hands. */
1087
- isDedupStubResult?: (resultText: string) => boolean;
1088
1137
  /** Wired to `MaybeCompactOptions.onApplied` by every compaction lane (the reference clears readFileState at its
1089
1138
  * compaction landing site, @388663). Drops every read-state entry the summary took out of view
1090
1139
  * (`readFileStateAfterSummary`); the restored files then re-register through their frames' own commits. Present
@@ -1135,31 +1184,14 @@ export interface Prepared {
1135
1184
  today: () => string;
1136
1185
  anchor: DateAnchorRead | undefined;
1137
1186
  };
1138
- /** [A2] C-4 (design-A §4) — the loadProjectMemory snapshot's declared instruction sources
1139
- * (`ProjectMemoryLoad.instructionSources`): the probe input AND the lane's per-path baseline
1140
- * hashes for the run loop's `instructions_change` attachment. Present only when the deployment's
1141
- * loader declared a non-empty list; the lane additionally requires
1142
- * `RunnerDeps.probeInstructionSources` — either absent ⇒ zero probe calls, byte-identical. */
1143
- instructionSources?: ReadonlyArray<{
1144
- path: string;
1145
- contentHash: string | null;
1146
- }>;
1147
- /** The RAW instruction-file text this leg's `loadProjectMemory` returned
1148
- * (`ProjectMemoryLoad.content`), for the compaction lanes' `contextInstructionFiles` seat.
1149
- *
1150
- * Which bytes, exactly: the string prepare-task hands `composeMemoryBlock(projectMem, "project")`
1151
- * — pre-compose, unfenced, straight from the host seam. The two neighbours are deliberately NOT
1152
- * candidates: the assembled `memoryBlock` carries the memory ENGINE's layers (bytes the model
1153
- * itself authored in-band this session through the memory tools) and the seat's contract is
1154
- * host/systemPrompt tier; the COMPOSED project block would arrive at a mint that neutralizes the
1155
- * whole authority family, `user_memory`/`scope` included, so the engine would rewrite the tags of
1156
- * its own composition. Raw text in, one fence at the mint.
1157
- *
1158
- * Present only when the deployment wired the loader AND it answered non-blank — the same
1159
- * predicate that composes the project layer, so the summarizer's copy and the main prompt's copy
1160
- * can never disagree about whether this deployment HAS instruction files. Absent ⇒ every
1161
- * compaction lane omits the key entirely. */
1162
- projectInstructionContent?: string;
1187
+ /** The leg's epoch-anchor seat: the anchor prepare read (undefined ⇒ the branch was unreadable, nothing is written) and
1188
+ * the leg's request head as it stands when read (`tools` is the table as mounted, after the leg's activations and
1189
+ * roster refreshes, before any request's view). The settle lane
1190
+ * writes the anchor when the head is not the recorded one (`owedDateAnchor`). */
1191
+ prefixAnchor?: {
1192
+ read: DateAnchorRead | undefined;
1193
+ head: () => PrefixHeadDigests;
1194
+ };
1163
1195
  /** The `workflow_size_guideline_change` lane's seam, the {@link dateChange} shape one lane over:
1164
1196
  * `legGuideline` = the RESOLVED guideline this leg's Workflow tool card was built with (the card is
1165
1197
  * a per-mount snapshot, so it never re-renders mid-leg — the model learns a retune from the tail
@@ -1172,20 +1204,23 @@ export interface Prepared {
1172
1204
  legGuideline: WorkflowSizeGuideline;
1173
1205
  current: () => WorkflowSizeGuideline;
1174
1206
  };
1175
- /** Boundary-time external-change scan over the ≤`maxFiles` most-recently-READ
1207
+ /** External-change scan (a turn boundary's, and a leg's first request's — `scanChangedFiles`) over the ≤`maxFiles` most-recently-READ
1176
1208
  * files. Stats each via `env.fileInfo` and reports paths whose `mtimeMs` moved past the recorded
1177
1209
  * `lastReadAt` + 2s epsilon (CC getChangedFiles shape: readFileState needs NO new field; the agent's
1178
1210
  * own write-backs refresh `lastReadAt`, so self-edits are immune). ENOENT evicts the readFileState
1179
- * entry (CC evict-only-on-ENOENT — transient stat failures skip, never evict) and is echoed in
1180
- * `evicted` so the caller drops its per-path dedup state in lockstep (LOW-9). Present only with
1181
- * hands; the run loop calls it ONLY when `spec.attachments.changedFiles` opted in (OFF ⇒ zero stat). */
1211
+ * entry (CC evict-only-on-ENOENT — transient stat failures skip, never evict). Present only with
1212
+ * hands; its callers ask it ONLY when `spec.attachments.changedFiles` opted in (OFF ⇒ zero stat). */
1182
1213
  detectExternalChanges?: (maxFiles: number) => Promise<{
1183
1214
  changed: Array<{
1184
1215
  path: string;
1185
1216
  mtimeMs: number;
1186
1217
  }>;
1187
- evicted: string[];
1188
1218
  }>;
1219
+ /** The instruction files of the task root's level and of the directories the run accesses (the family
1220
+ * `NESTED_MEMORY_LANE.declaration` names): primed at the end of prepare (the manifest's `instructions`), then the leg's first
1221
+ * request, each continuing boundary and a landed compaction ask it what the read state owes. Present only with hands and the
1222
+ * declaration. */
1223
+ nestedMemory?: import("./nested-memory-lane.js").NestedMemoryLane;
1189
1224
  /** G1 通告层 — deferred tools MATERIALIZED (rematerialized) but not yet announced at a
1190
1225
  * turn boundary. Appended by the rematerialize diff (newly-activated names only — the announced set
1191
1226
  * is seeded with prepare-time actives INCLUDING resume-reseeded ones, so a resume never replays);
@@ -1253,6 +1288,9 @@ export interface Prepared {
1253
1288
  /** The frame-receipt ledger — the ONE commit point of every engine frame that rides a user message
1254
1289
  * (the git-status frame, the agent and skills listing frames). Always present; per leg. */
1255
1290
  frameReceipts: FrameReceiptLedger;
1291
+ /** The run's engine text reading, bound to its locale (`TaskSpec.promptLocale`) once at prepare: every engine-minted
1292
+ * text the runner's own lanes send (the MCP frame on both lanes) reads through it. */
1293
+ engineText: EngineText;
1256
1294
  /** env-tail migration — the git-status frame lane's run-local state: this leg's
1257
1295
  * resolved frame (probe outcome rendered + hashed at prepare), the announced `(kind, hash)`
1258
1296
  * mirror the checkpoint serializer reads, the trim-protection slot the request-build context
@@ -1261,6 +1299,11 @@ export interface Prepared {
1261
1299
  gitStatusRef: GitStatusLaneRef;
1262
1300
  /** The posture composition's run-local half (the newest carrier's protection slot; the row last composed for). */
1263
1301
  postureFrameRef: import("../auto-mode-directive.js").PostureFrameRef;
1302
+ /** The request's irreducible core for this leg: the objective input the guard trim never drops (written by the objective
1303
+ * lane before the first request) and the typed terminal a request-build guard parks when a core cannot fit. */
1304
+ requestCoreRef: import("../context-guard.js").RequestCoreRef;
1305
+ /** The limit-approach notice's seat: the turn boundary writes the crossing, the request-build handler carries it ({@link LimitApproachSeat}). */
1306
+ limitApproachRef: LimitApproachSeat;
1264
1307
  /** G1 通告层 — narrow getter over the process task registry: THIS run's visible live background tasks
1265
1308
  * (pending / running / parked under the same owner/scope/session identity the TaskStop tool
1266
1309
  * uses), EVERY one (`TaskRegistry.liveTasks`), as a projection (id/description/status and the row's read handle,
@@ -1362,6 +1405,11 @@ export interface PrepareResume {
1362
1405
  /** Batch tool-call ids of the suspended turn — wake-reconcile SKIPS these (they are resumed, not
1363
1406
  * crash-interrupted; closing them with `[INTERRUPTED]` would DESTROY the suspended batch, §15.2 #7). */
1364
1407
  suspendedBatch: ReadonlySet<string>;
1408
+ /** The parked row's own synchronous-child block (`Checkpoint.parentSessionId` / `parentTaskId` / `rootSessionId` / `rootSessionIncarnation`),
1409
+ * for a synchronous child's resumed leg that is handed no spawner internals: the next row it parks records the same block. It is read
1410
+ * into the park mint only — never folded into the leg's internals, whose root and parent members steer notice routing and placement.
1411
+ * Absent ⇒ the row recorded none. */
1412
+ syncChildBlockOfRow?: import("../leg-identity.js").SyncChildBlock;
1365
1413
  /** The §4.bis correctness-state snapshot to re-seed (activeTools / outputRef / nestedStats /
1366
1414
  * readFileState). */
1367
1415
  seed: CheckpointState;
@@ -1655,6 +1703,8 @@ export interface PromptFeatureFlags {
1655
1703
  worktreeIsolated: boolean;
1656
1704
  withinTaskCompactionEnabled: boolean;
1657
1705
  isSubagent: boolean;
1706
+ /** No store to persist through, on the run that holds the user's conversation (the memory phase's verdict). */
1707
+ memoryStoreAbsent: boolean;
1658
1708
  }
1659
1709
  /**
1660
1710
  * A TRUSTED, run-scoped internal channel into {@link prepareTask}, set
@@ -1715,6 +1765,15 @@ export interface RunInternals {
1715
1765
  readonly definition?: string;
1716
1766
  readonly lists: string;
1717
1767
  };
1768
+ /** Set by the workflow lane when it launches an agent as an agent type whose definition writes tool lists: the definition's name and its
1769
+ * two lists as one selector layer. The leg's selector reads it between the ceiling it was spawned under and its own lists (the
1770
+ * definition bounds which tools the leg is handed, as a delegated child's does; the leg's own lists stay the deployment's), its prepare
1771
+ * judges it once as a definition's lists are judged (`config.agent.unknown_tool`, told to the operator), and its rows record it with
1772
+ * the ceiling. Trusted, never a TaskSpec field. */
1773
+ definitionToolLists?: {
1774
+ readonly agentType: string;
1775
+ readonly layer: import("../tool-face.js").ToolSelectorLayer;
1776
+ };
1718
1777
  /** Set only on an observer sidecar's legs: the leg kind whose protocol is the observer's report tool. */
1719
1778
  observerLeg?: true;
1720
1779
  /** The live repair bundle from a `runRepairLoop` attempt in flight (attemptCount>0). Serialized onto a
@@ -1912,18 +1971,6 @@ export interface RunInternals {
1912
1971
  * carries no placement — byte-identical to before.
1913
1972
  */
1914
1973
  sessionPlacement?: import("../session.js").SessionPlacement;
1915
- /**
1916
- * The DEFAULT role-base persona for a DELEGATED child, threaded by
1917
- * `createSubagentTool`'s execute (a core caller) when neither an agent-definition `systemPrompt` nor the
1918
- * delegation tool's `opts.systemPrompt` names one. It sits at the BOTTOM of the role-base chain —
1919
- * `spec.systemPrompt ?? resolvedRole.systemPrompt ?? internals.defaultSystemPrompt` — so a deployment's
1920
- * `roles.subagent.systemPrompt` / `roles.default.systemPrompt` preset still wins (pre-G1 semantics: an
1921
- * unset child systemPrompt let the role preset apply; G1's first cut put SUBAGENT_PROMPT at spec level
1922
- * and silently shadowed the preset). Only when NO preset resolves does the lean SUBAGENT_PROMPT (general-purpose
1923
- * persona) replace the full DEFAULT_SYSTEM_PROMPT constitution base.
1924
- * TRUSTED run-scoped channel (NOT a {@link TaskSpec} field), mirroring `insideFork`.
1925
- */
1926
- defaultSystemPrompt?: string;
1927
1974
  /**
1928
1975
  * The catalog WORD that chose the model this engine-spawned child was handed on its spec.
1929
1976
  *
@@ -2055,17 +2102,17 @@ export interface RunInternals {
2055
2102
  *
2056
2103
  * Set by the BACKGROUND delegation lanes (plain + fork), whose runs own a registry `a*` row, and by
2057
2104
  * both of the workflow orchestrator's spawn legs. A SYNCHRONOUS delegated child declares nothing —
2058
- * it has no fleet row of any kind, so absence is a fact about the run rather than a gap in the
2059
- * stamping. TRUSTED run-scoped channel (never a {@link TaskSpec} field).
2105
+ * it has no registry identity (INTEGRATION-CORE §1.6a), so absence is a fact, not a stamping gap — save on a delegated
2106
+ * child's checkpoint a host redeems without the lane's internals (KL-3824-a). TRUSTED run-scoped channel (never a {@link TaskSpec} field).
2060
2107
  */
2061
2108
  delegationTaskType?: import("../types.js").DelegationTaskType;
2062
2109
  /**
2063
- * The registry row's stop-cycle generation this run executes as (fresh spawn = 1, a
2064
- * revival's bumped counter), threaded by the BACKGROUND delegation lanes from the registry's own
2065
- * `cycleSeq` so every `task_progress` tick the run mints carries it as `seq` (same axis as
2066
- * `TaskNotificationPayload.seq` / `BackgroundChildEvent.seq`). Absent for runs with no `a*` row
2067
- * (sync children, workflow agents, top-level) — same absence-is-a-fact posture as
2068
- * {@link delegationTaskType} above. TRUSTED run-scoped channel (never a TaskSpec field).
2110
+ * The stop-cycle generation this run executes as (fresh spawn = 1, a wake's bumped counter), threaded by the
2111
+ * BACKGROUND delegation lanes from the registry's own `cycleSeq` and by a retained child's wake from the retain
2112
+ * ledger's (a synchronously born child's wake too: a cycle count, not a row), so every `task_progress` tick the
2113
+ * run mints carries it as `seq` (same axis as `TaskNotificationPayload.seq` / `BackgroundChildEvent.seq`). Absent
2114
+ * on a first synchronous cycle, on workflow agents and top-level runs (INTEGRATION-CORE §1.6a), and on a delegated
2115
+ * child's checkpoint a host redeems without the lane's internals (KL-3824-a). TRUSTED run-scoped channel (never a TaskSpec field).
2069
2116
  */
2070
2117
  cycleSeq?: number;
2071
2118
  /** The ROOT host session of the whole delegation tree (fixed point: the
@@ -2081,6 +2128,11 @@ export interface RunInternals {
2081
2128
  * occupants were minted; a frame the notification lane escalates to the root anchor is then addressed
2082
2129
  * to an unknown occupant, which a root holding a token is not. TRUSTED run-scoped channel (never a TaskSpec field). */
2083
2130
  rootSessionIncarnation?: string;
2131
+ /** The scope {@link rootSessionId}'s legs mount its durable box in, as the tree's root leg mounted it (its registry scope) — the
2132
+ * third member of the root anchor's address, carried beside the other two by the same fixed point and persisted on a background
2133
+ * spawn's row (`BackgroundAgentRecord.rootSessionScope`). A Runner on which no leg of the root runs judges the root's box at it.
2134
+ * Absent = a tree whose root recorded none (a row written before rows recorded it): no box is judged for the root. TRUSTED. */
2135
+ rootSessionScope?: string;
2084
2136
  /** The delegation tree's owner seat ({@link import("./delegation-owner.js").DelegationOwnerSeat}): a fixed point like
2085
2137
  * {@link rootSessionId} — the spawning run hands its own seat down by reference (the delegation and workflow lanes), so the tree
2086
2138
  * reads its root row's owner once. Absent ⇒ this run is nobody's child here (a top-level run, a revival, a resumed park) and its
@@ -2128,12 +2180,13 @@ export interface RunInternals {
2128
2180
  * The REGISTRY SCOPE this run's own background row lives in: the domain its registry-facing
2129
2181
  * tools (TaskStop / SendMessage / AgentTranscript / Monitor, and the announce listing)
2130
2182
  * must mount in to see it. Filled by the delegation tool at spawn, which is the party that CHOSE the
2131
- * domain when it registered the row — `ctx.principal` when the spawning run has one, else the
2132
- * delegation mount's declared `background.scope`, and on a revival the claimed row's own scope.
2183
+ * domain when it registered the row — the spawning run's isolation scope (its `isolationScope`, else its
2184
+ * principal) when it has one, else the delegation mount's declared `background.scope`, and on a revival the
2185
+ * claimed row's own scope.
2133
2186
  *
2134
- * Why this is not just `principal`: a deployment may declare its domain at MOUNT time and run its
2135
- * tasks without `TaskSpec.principal`. The row then lands in the declared domain while the child runs
2136
- * with no principal at all, and `principal ?? "default"` sends every one of its registry-facing tools
2187
+ * Why this is not just the isolation scope: a deployment may declare its domain at MOUNT time and run its
2188
+ * tasks with neither `TaskSpec.isolationScope` nor `TaskSpec.principal`. The row then lands in the declared domain while the child runs
2189
+ * with no scope at all, and isolation scope ?? `"default"` sends every one of its registry-facing tools
2137
2190
  * to a domain the row is not in — scope is fail-closed on both access predicates, so such a child
2138
2191
  * cannot see its own row, its siblings, or the children it spawns. Carrying the domain as its own
2139
2192
  * trusted axis keeps `principal` the IDENTITY it is: the identity also keys the durable
@@ -2174,18 +2227,44 @@ export interface RunInternals {
2174
2227
  */
2175
2228
  onForwardEvent?: (event: TaskEvent) => void;
2176
2229
  /**
2177
- * The run's OWN top-level `status` TaskEvent stream (brain liveness: rate-limit/retry/
2178
- * reconnect/circuit-open), offered to the internals holder beside the queue. The queue alone was
2179
- * enough for a direct `runTask` caller (the TaskStream carries these frames), but a COMPOSITION
2180
- * entry (verify/cascade) drains its inner legs' queues itself — without this seat, an inner leg's
2181
- * retry disclosure died inside the gate and the wire showed a silent stall. Fed the SAME frame
2182
- * object the queue receives, at the same moment; contained by the run's safe notifier (a throwing
2183
- * sink is swallowed, first failure per site disclosed, never faults the leg). Subagent
2184
- * frames still ride {@link onForwardEvent} — this seat is ONLY the run's own status type.
2185
- */
2186
- onStatusEvent?: (event: Extract<TaskEvent, {
2187
- type: "status";
2188
- }>) => void;
2230
+ * The subtree-activity seat: "this run — or something running under it — just did work." Not {@link onActivity} (that one hands a
2231
+ * run's OWN tool starts and ends, with their identity, to whoever observes that run; a descendant's calls never reach it). This one
2232
+ * carries no identity, only the beat: the engine tells it at each of the run's tool calls' start and end (in the one place a run
2233
+ * pushes its content; not at a `tool_progress` heartbeat, which says only that a silent call is still in flight) and at each MCP progress
2234
+ * notification of its tool calls; a delegation hands it to every foreground child
2235
+ * (`ToolExecuteContext.onSubtreeActivity`), so a grandchild's tool work reaches the same seat at any depth — beyond what the display
2236
+ * channel forwards, which is filtered. A background lane that owns a registry row sets it to that row's beat
2237
+ * (`TaskRegistry.noteBackgroundAgentActivity`) and so replaces, not extends, the one it inherited: a background child's work is its
2238
+ * own row's, not its spawner's. TRUSTED spawn-side channel, never a {@link TaskSpec} field; the call is a timestamp write and must not
2239
+ * throw or wait.
2240
+ */
2241
+ onSubtreeActivity?: () => void;
2242
+ /**
2243
+ * The DRAINED-LEG FRAME SEAT: a leg the engine drains itself — entered through `Runner.runTask` or `Runner.resume`, as
2244
+ * every leg a composition entry (the verify gate, the cascade) dispatches is — hands its own frames of the closed set
2245
+ * `DRAINED_LEG_FRAME_TYPES` (`status`, `wiring_manifest`, `message_committed`,
2246
+ * `workspace_changed`) to this seat, because the caller holds no stream for that leg. Branch on `frame.type`.
2247
+ *
2248
+ * ONE FRAME, TWO DELIVERIES, ONE ORDER: `frame` is the very object the leg's queue received, shallow-frozen before the
2249
+ * push (its own members cannot be reassigned; nested objects such as `manifest`, `entered`, `session` are the same objects
2250
+ * the stream frame carries and are not frozen by this rule — read them, do not write them), offered at the push and only
2251
+ * when the queue accepted it, so this seat sees the leg's frames in the order the stream holds them. `at` is
2252
+ * {@link LegAt}: the leg's `taskId` and `sessionId` (engine facts, on every frame) and `leg`,
2253
+ * the composition's label for the leg when the dispatcher bound one — absent means nobody labelled the leg, never
2254
+ * "implementation" (a plain `runTask` and a workflow agent call carry none; the verify gate labels `impl` / `verifier` /
2255
+ * `fix`, the cascade labels each rung `rung` with its place on the ladder).
2256
+ *
2257
+ * DRAINED LEGS ONLY: `Runner.runTaskStream` / `Runner.resumeStream` hand the caller the stream, where these frames ride,
2258
+ * and REFUSE this seat (`config.invalid_argument`) before anything is read — on a resume, before the checkpoint is read
2259
+ * or claimed (it stays pending; resume again without the seat). The draining entries mark the object they hand on; a
2260
+ * copy of it is not marked. A child the leg delegates to, and a workflow agent leg, run on a bag the engine builds, which
2261
+ * never carries this seat: their frames reach the parent through {@link onForwardEvent}, not here.
2262
+ *
2263
+ * Observe-only and failure-isolated through the run's ONE notifier (a throw, or an `async` seat's rejection, is
2264
+ * contained, disclosed once per run, counted after, and never faults the leg). A TRUSTED run-scoped channel, never a
2265
+ * {@link TaskSpec} field.
2266
+ */
2267
+ onLegFrame?: (frame: DrainedLegFrame, at: LegAt) => void;
2189
2268
  /** The run-local per-tool-call detach hub. runtask creates it and exposes
2190
2269
  * `TaskStream.detach(toolCallId)`; the hands Bash tool threads `signalFor(toolCallId)` into env.exec. */
2191
2270
  detachHub?: import("../tool-detach.js").ToolDetachHub;
@@ -2228,6 +2307,9 @@ export interface RunInternals {
2228
2307
  opts?: {
2229
2308
  priority?: import("../task-notification.js").SystemInjectionPriority;
2230
2309
  }) => void;
2310
+ /** The ASSISTANT SEAT (the type's own doc is the contract): host-handed on every leg the host starts for the scope's assistant, a
2311
+ * resumed one included; the engine hands no child this member and a checkpoint does not carry it. */
2312
+ principalInboxAssistant?: import("../../agents/org-delivery-gate.js").PrincipalInboxAssistantSeat;
2231
2313
  /**
2232
2314
  * The PARENT run's notification injector (its runtask-wrapped
2233
2315
  * `injectTaskNotification`), threaded into a CHILD's internals at spawn time so the child's
@@ -2388,47 +2470,14 @@ export interface RunInternals {
2388
2470
  */
2389
2471
  onWorkspaceResolved?: (workspace: ResolvedWorkspace) => void;
2390
2472
  /**
2391
- * A TRUSTED run-scoped WIRING-MANIFEST sink, filled ONLY by a core caller and NEVER a {@link
2392
- * TaskSpec} field — the posture of {@link onActivity} and {@link onWorkspaceResolved} beside it.
2393
- * Handed the very object this leg's `wiring_manifest` frame carries, at the moment that frame is
2394
- * pushed: ONCE per prepared leg, after prepare and before the leg's first model or tool
2395
- * interaction. Rides `internals` on FRESH and RESUMED legs alike, because the mint sits in the
2396
- * run body both entries share.
2397
- *
2398
- * WHY a seat, when the frame already rides the stream: a COMPOSITION entry (the verify gate, the
2399
- * cascade) drains its inner legs' queues ITSELF, so the host holds no TaskStream for any of them
2400
- * and an inner leg's manifest dies inside the gate — the hole {@link onStatusEvent} was opened
2401
- * for, one frame family over. A direct `runTask` caller needs neither seat: its own stream
2402
- * carries both frames.
2403
- *
2404
- * `leg` is the LEG IDENTITY, and the engine mints NONE of it. It is present only where a
2405
- * composition labelled the leg it dispatched: the verify entries hand each leg a per-dispatch
2406
- * copy of this object whose sink closes over that leg's identity, so a consumer can tell the
2407
- * implementation leg from pass 2's verifier without inferring it from arrival order (the
2408
- * ordering is all the sibling sinks have — see the attribution paragraph on `verifyCompleted`).
2409
- * ABSENT therefore means "nobody labelled this leg", never "implementation": a plain `runTask`,
2410
- * a workflow agent call and a cascade rung all reach this sink with no identity, and reading one
2411
- * in would be the engine fabricating a fact it does not hold. NOT the same axis as the manifest's
2412
- * OWN `leg` field ({@link WiringManifest.leg}, `root` / `child` / `resume`), which is a fact about
2413
- * how the ENGINE reached this run; this one is a fact about the composition that dispatched it, and
2414
- * a resumed fix leg carries both at once — `manifest.leg.kind === "resume"` and `leg.kind === "fix"`
2415
- * are both true of it. `pass` is 1-based over the gate's verification rounds: a `verifier` leg
2416
- * carries the one it verifies, a `fix` leg the one whose findings it answers, and the entry
2417
- * implementation leg carries 0 — before the first. The axis is relative to the gate INVOCATION,
2418
- * not to the session's history: a resume entry's work leg is THAT invocation's implementation leg
2419
- * (`impl`, pass 0) even when the checkpoint it resumes was minted inside a previous invocation's
2420
- * fix pass, because the invocation's own pass counter (`VerificationResult.rounds`) restarts with
2421
- * it — one axis for both fields, rather than a leg that reads "fix pass 1" inside a result whose
2422
- * rounds begin at 1 again.
2423
- *
2424
- * Observe-only and failure-isolated through the SAME per-run notifier as {@link onActivity} (one
2425
- * isolation scope for every sink on this object, so a broken sink is counted and disclosed once,
2426
- * not once per site family): a throw — or an `async` sink returning a rejecting promise — is
2427
- * contained and never faults the leg whose manifest it was handed.
2428
- */
2429
- onWiringManifest?: (manifest: WiringManifest, leg?: {
2430
- readonly kind: "impl" | "verifier" | "fix";
2431
- readonly round: number;
2473
+ * Set by a delegation lane that can hold this leg's park: the leg's prepare reports, once, whether it can suspend
2474
+ * durably (`ready` — the same readiness its manifest's `suspendLane` reports), so the spawner's yield seat knows what a
2475
+ * yield of this leg will come to. The leg's `TaskSpec.preemptSignal` is the spawner's fresh per-leg yield signal; the
2476
+ * report is the moment that signal is handed over (after the resume entry's strip of an already-raised one). Fresh and
2477
+ * resumed legs alike. A throwing seat is swallowed — an observation must not fault prepare.
2478
+ */
2479
+ reportSuspendLane?: (lane: {
2480
+ readonly ready: boolean;
2432
2481
  }) => void;
2433
2482
  }
2434
2483
  /**
@@ -2501,6 +2550,26 @@ export interface AskLane {
2501
2550
  /** The deployment-facing half of a crashing PreToolUse hook (swallow-guarded). */
2502
2551
  notifyHookError: (err: unknown) => void;
2503
2552
  }
2553
+ /**
2554
+ * What one boundary-family suspend request (`suspendForResource` / `suspendForPlatformLimit`) came to — the
2555
+ * mint's own answer, so the turn boundary reads the cause's fallback off ONE fact instead of guessing from a
2556
+ * boolean:
2557
+ * · `committed` — a resumable checkpoint exists; the pause is published and the loop stops cleanly;
2558
+ * · `not_written` — no row exists and the world is as it was (no store, a cancelling run, no committed leaf,
2559
+ * a refused `suspendVM`, a store that refused the write with the paused VM restored):
2560
+ * continuing is safe, and `reason` says why in one clause;
2561
+ * · `fatal` — the mint stopped the run itself (the slice cap, a paused VM that could not be restored,
2562
+ * a write whose outcome is unknown): the boundary never continues past it.
2563
+ */
2564
+ export type BoundarySuspendOutcome = {
2565
+ readonly tag: "committed";
2566
+ } | {
2567
+ readonly tag: "not_written";
2568
+ readonly reason: string;
2569
+ } | {
2570
+ readonly tag: "fatal";
2571
+ readonly reason: string;
2572
+ };
2504
2573
  /** How the put-commit + put-failure saga ended (see `commitSuspendSaga` inside the phase for each arm's meaning). */
2505
2574
  export type SuspendSagaOutcome = {
2506
2575
  tag: "committed";
@@ -2540,6 +2609,11 @@ export interface SuspendSaga {
2540
2609
  parkOnlyRemoteEnv: RemoteExecutionEnv | undefined;
2541
2610
  /** The park-only identity capture (snapshotId stripped, `restoreMode: "park_only"`). */
2542
2611
  parkOnlyHandle: (env: RemoteExecutionEnv) => WorkspaceHandle;
2612
+ /** The synchronous-child block every row this leg parks records beside its identity ({@link import("../leg-identity.js").syncChildBlockOf}):
2613
+ * the spawning run's session and task, the tree's root session and its occupant — present only on a synchronous child's leg, empty on a
2614
+ * root run's, a background child's and a workflow agent's. Read once at prepare, so the approval, `resource_limit` and `plan_review` mints stamp the one
2615
+ * value (`Checkpoint.parentSessionId` / `parentTaskId` / `rootSessionId` / `rootSessionIncarnation`). */
2616
+ syncChildBlock: import("../leg-identity.js").SyncChildBlock;
2543
2617
  }
2544
2618
  /** The park closure and the content-ask routing closure the gate station hands to `runToolGate`. Built as ONE value so
2545
2619
  * "the park lane's closures exist" is one fact; `suspendAsk` stays optional INSIDE it because the park predicate (a store,
@@ -2570,9 +2644,13 @@ export interface ParkAsk {
2570
2644
  */
2571
2645
  export interface RunState {
2572
2646
  telemetry: {
2647
+ /** The model the main loop requests — the task's, then the near-budget target once the switch fires. `cacheFamily`,
2648
+ * `pricing` and `pricingConfigured` are ITS price facts; an answer the model lane served from a fallback hop, and every
2649
+ * hop left behind, is priced at its own model ({@link RunState.degrade.priceOf}). Set at the telemetry lane. */
2650
+ requestedModel: Model | undefined;
2573
2651
  cacheFamily: ReturnType<typeof cacheFamilyOf>;
2574
2652
  pricing: ModelPricing;
2575
- /** Whether the CURRENT serving model has a configured price table (a
2653
+ /** Whether the requested model has a configured price table (a
2576
2654
  * `RunnerDeps.pricing` entry or a `Model.cost` declaration). When neither exists,
2577
2655
  * `modelCostToPricing(undefined)` yields an all-zero table and every computed cost is a
2578
2656
  * fabricated 0 — indistinguishable from "declared free". This flag keeps the two apart so
@@ -2594,10 +2672,24 @@ export interface RunState {
2594
2672
  };
2595
2673
  degrade: {
2596
2674
  degradeToModel: Model | undefined;
2675
+ /** The run's FIRST switch away from the requested model (a main-loop fallback walk, or the near-budget switch) — an audit
2676
+ * record only (`TaskResult.degraded`); no pricing reads it. */
2597
2677
  degraded: TaskResult["degraded"];
2678
+ /** The near-budget switch fired — its own bit, so a fallback walk earlier in the run does not latch it. */
2679
+ budgetSwitched: boolean;
2598
2680
  outputErrorStreak: number;
2599
2681
  outputInvalid: boolean;
2600
- recordDegraded: (info: NonNullable<TaskResult["degraded"]>, toModel?: Model) => void;
2682
+ /** Record the run's first switch (audit: `degraded`, the `task.degraded` trace, the operational `onError`); once. */
2683
+ recordDegraded: (info: NonNullable<TaskResult["degraded"]>) => void;
2684
+ /** The price facts of a model a call was billed at: the requested model's are the telemetry's; any other's are read
2685
+ * from the deployment's table (or the model's `cost`) at the call, through the price-table door. */
2686
+ priceOf: (model: Model) => {
2687
+ pricing: ModelPricing;
2688
+ pricingConfigured: boolean;
2689
+ cacheFamily: ReturnType<typeof cacheFamilyOf>;
2690
+ };
2691
+ /** The leg's `model.fallback` announcement (the main loop's and the side-call book's one seat). */
2692
+ fallbackSeat: ModelFallbackSeat;
2601
2693
  };
2602
2694
  limits: {
2603
2695
  turnsExceeded: boolean;
@@ -2648,6 +2740,12 @@ export interface RunState {
2648
2740
  costMicroUsd: number;
2649
2741
  } | undefined;
2650
2742
  turnUsageMissing: boolean;
2743
+ /** The turn's cache marks as `turn_end` carries them (some call of the turn did not report its cache reads / writes;
2744
+ * `cache-hit-account.ts` decides them), reset with the rest of the per-turn bookkeeping. */
2745
+ turnCacheMarks: {
2746
+ cacheReadUnreported?: true;
2747
+ cacheWriteUnreported?: true;
2748
+ };
2651
2749
  turnStopReason: string | undefined;
2652
2750
  /** The PROVIDER-REPORTED model name of this turn's LAST assistant message, when it differed from the
2653
2751
  * requested id — surfaced on `turn_end.responseModel`, reset with the rest of the per-turn
@@ -2658,8 +2756,8 @@ export interface RunState {
2658
2756
  completed?: readonly import("../mods/lifecycle-stations.js").CompletedTurn[];
2659
2757
  };
2660
2758
  counters: {
2661
- /** How many LIMIT-APPROACH frames have been injected this run (0..2). Also the
2662
- * one-shot latch itself: each frame fires when the count is still below its index. */
2759
+ /** How many distinct LIMIT-APPROACH sentences a request has carried this run (0..2): one per threshold, counted by the
2760
+ * first request that carries it (a crossing straight past the second threshold counts 1). */
2663
2761
  approachNoticesSent: number;
2664
2762
  /** B15 三期使能:R9 引用的 R3/压缩区 latch(walltime 收尾 latch — preemptIgnoredReported 同族)。 */
2665
2763
  walltimeSyncBackstopFired: boolean;
@@ -2695,13 +2793,9 @@ export interface RunState {
2695
2793
  dateState: {
2696
2794
  announcedDate: string;
2697
2795
  } | undefined;
2698
- instrProbe: RunnerDeps["probeInstructionSources"];
2699
- instrState: {
2700
- lastAnnouncedHash: Map<string, string | null>;
2701
- } | undefined;
2702
2796
  /** The Workflow tool card's advisory size guideline as last ANNOUNCED to the model,
2703
2797
  * plus the live boundary-time read (Prepared.workflowSizeGuideline). Same deliberate posture as
2704
- * `dateState`/`instrState`: NOT an AttachmentState member, one field, zero reducers. */
2798
+ * `dateState`: NOT an AttachmentState member, one field, zero reducers. */
2705
2799
  sizeGuidelineState: {
2706
2800
  announcedGuideline: WorkflowSizeGuideline;
2707
2801
  current: () => WorkflowSizeGuideline;
@@ -2711,8 +2805,10 @@ export interface RunState {
2711
2805
  };
2712
2806
  }
2713
2807
  /**
2714
- * Config handed to {@link Runner.resume}: the {@link TaskSpec} members the resumed leg runs with. `sessionId` comes from the checkpoint;
2715
- * a resume sends no new human message, so it takes no objective, `userAttachments` or `runOrigin` (either present is refused before the
2808
+ * Config handed to {@link Runner.resume}: the {@link TaskSpec} members the resumed leg runs with. The session comes from the checkpoint,
2809
+ * so the config names none of the members that live and die with a session (`SessionBoundSpecMember`, the member table's one column:
2810
+ * `sessionId`, `requireExistingSession`, `resumeAt`, `resumeAtMode`, `restoreFiles`, `acceptPartialRestore`, `rewindFilesTo`); a
2811
+ * resume sends no new human message, so it takes no objective, `userAttachments` or `runOrigin` (either present is refused before the
2716
2812
  * claim; a wake states its leg's word on the input it hands over). The row records no tool, hand band or server list: `tools`, `mcp`,
2717
2813
  * `a2a` and the `skills` specs are the deployment's CURRENT ones as this resume hands them (the leg dials these lists as the config doors
2718
2814
  * judge them; absent declares none) — a host replaying the parked run's lists re-dials a server its user removed. The parked call is
@@ -2720,7 +2816,7 @@ export interface RunState {
2720
2816
  * reopened `pending`); a replacement ⇒ `resume.tool_contract_mismatch`; a moved face or declaration ⇒ `resume.target_moved`. Identity is
2721
2817
  * kept instead: a contradicting `principal` is refused (`resume.principal_mismatch`), an absent one inherits the row's.
2722
2818
  */
2723
- export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "sessionId" | "userAttachments" | "runOrigin">;
2819
+ export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "userAttachments" | "runOrigin" | SessionBoundSpecMember>;
2724
2820
  /**
2725
2821
  * A composition leg's identity ({@link RunInternals.compositionLeg}, `CheckpointState.compositionLeg`): which entry handed the
2726
2822
  * leg out, which leg of it this is, and the host session the composition runs for. One member per entry; `entry` is a closed
@@ -2798,9 +2894,14 @@ export interface ResumeRun {
2798
2894
  * under the failure's reason (`reopenReasonOf`), recorded on the row so the next re-resume validates per
2799
2895
  * reason — an `env_failed` reopen replays the persisted winner, the fresh-redecision reasons take a new
2800
2896
  * decision. Answers the store's own answer — `"reopened"` (it flipped the row) or `"declined"` (`reopen`
2801
- * answered `false`) — and rejects only with what the store threw (the row's state is then unprovable);
2897
+ * answered `false`) — and rejects only with what the store threw (the row's state is then unproven unless
2898
+ * {@link claimedRowPending} shows the reopen landed);
2802
2899
  * every exit reads it through `compensateUnstarted` (resume-startup-cause.ts), the one reading. */
2803
2900
  reopenUnstarted: (reason: ReopenReason) => Promise<"reopened" | "declined">;
2901
+ /** The row read that can show a reopen landed, bound to THIS resume's token like {@link reopenUnstarted} and REQUIRED beside it:
2902
+ * `true` when the row reads `pending` at a generation past the one the claim won at. `compensateUnstarted` asks it only after a
2903
+ * `reopen` that threw — a write that may have landed — and any other reading, or a read that throws, leaves the state unproven. */
2904
+ claimedRowPending: () => Promise<boolean>;
2804
2905
  /** The row's execution-record verb, bound to THIS resume's token and scope by `resumeStream` (the
2805
2906
  * same closure form as {@link reopenUnstarted}, and REQUIRED for the same reason: the store contract requires the
2806
2907
  * verb, so there is no store this seat could be absent for). The pending-call resolver calls it
@@ -2872,6 +2973,8 @@ export interface TurnBoundaryDeps {
2872
2973
  windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
2873
2974
  rapidRefill: RapidRefillState;
2874
2975
  drainManualCompact: (outcome: CompactOutcome) => void;
2976
+ /** The leg's display (a top-level leg's), waited on at each boundary before its work. */
2977
+ display: import("../mods/message-display.js").MessageDisplay | undefined;
2875
2978
  runnerHooks: {
2876
2979
  onError: RunnerDeps["onError"];
2877
2980
  };
@@ -2884,26 +2987,31 @@ export interface TurnBoundaryDeps {
2884
2987
  * 工厂调用点的 const 稳定引用 + 三个 runLocked 形参;this 面(deps.onError)经 runnerHooks 打包
2885
2988
  * (B13 #coreView / R9 TurnBoundaryDeps 同款)。*/
2886
2989
  /** What a PRODUCER of a `tool_progress` frame knows: the FACTS it observed. The frame minus everything only
2887
- * the run supplies — its discriminator, its {@link TaskEventIdentity} stamp, and the elapsed time, which the
2888
- * lane computes from its own per-call origin. Derived from the union member, so seat and frame cannot drift. */
2990
+ * the run supplies — its discriminator, its {@link TaskEventIdentity} stamp, the elapsed time, which the
2991
+ * lane computes from its own per-call origin, and the gate phase, which it reads off the call's occurrence. Derived from
2992
+ * the union member, so seat and frame cannot drift. */
2889
2993
  export type ToolProgressBody = Omit<Extract<TaskEvent, {
2890
2994
  type: "tool_progress";
2891
- }>, "type" | "elapsedTimeSeconds" | keyof TaskEventIdentity>;
2995
+ }>, "type" | "elapsedTimeSeconds" | "gate" | keyof TaskEventIdentity>;
2892
2996
  /** The run's TOOL-PROGRESS lane: the ONE mint of `tool_progress` plus the heartbeat over the calls in flight —
2893
2997
  * the leg's occurrences (`Prepared.toolOccurrences`), read, never a set of its own. Declared on the FLOOR because
2894
2998
  * both registry-side readers sit above its implementation (the driver builds it, the harness-handler lane drives
2895
2999
  * it) and the Prepared seat that carries it to the tool band is here too. `createToolProgressLane`
2896
3000
  * (tool-progress-lane.ts, layer 1) is its one implementation. */
2897
3001
  export interface ToolProgressLane {
2898
- /** Offer ONE frame — from a tool that observes its own progress (the shell's per-second tick) or from
2899
- * the lane's own heartbeat. The lane stamps the elapsed time, DROPS the offer when it would land inside
2900
- * the cadence floor, and resets that call's beat clock when it does not. NEVER THROWS: a tool calls this
3002
+ /** Offer ONE frame — from a tool that observes its own progress (the shell's per-second tick) or from the lane's own heartbeat.
3003
+ * The lane stamps the elapsed time, DROPS an offer inside the cadence floor, resets that call's beat clock when it keeps one, and
3004
+ * beats the leg's activity seat when a producer's `totalBytes` advanced (never for the heartbeat). NEVER THROWS: a tool calls this
2901
3005
  * from inside an environment output callback, where a throw kills the command it is describing. */
2902
3006
  emit(body: ToolProgressBody): void;
2903
3007
  /** The heartbeat stops covering every call in flight and disarms (turn end / teardown): no beating into the next
2904
3008
  * turn. The occurrences stay — a later end must still know its start went out. */
2905
3009
  clear(): void;
2906
3010
  }
3011
+ /** The run's one `message_committed` mint ({@link runClockAndContent}): a tool result names its `toolCallId` (the join key to the
3012
+ * call already rendered); a user row names its source (`userRow`, {@link UserRowSource} — what the row is and, for a person's input,
3013
+ * which `human_input` key it carries); an assistant message names neither. Naming one where it does not belong is refused. */
3014
+ export type EmitCommitted = (entryId: string, role: "user" | "assistant" | "toolResult", toolCallId?: string, userRow?: import("../user-row-origin.js").UserRowSource) => void;
2907
3015
  export interface HarnessHandlersDeps {
2908
3016
  spec: TaskSpec;
2909
3017
  queue: PushQueue<TaskEvent>;
@@ -2914,7 +3022,10 @@ export interface HarnessHandlersDeps {
2914
3022
  sourceTaskId?: string;
2915
3023
  };
2916
3024
  pushContent: (e: TaskEvent) => void;
2917
- emitCommitted: (entryId: string, role: "user" | "assistant" | "toolResult", toolCallId?: string) => void;
3025
+ /** The leg's display (a top-level leg's): an assistant message's text deltas and block closes are written into it instead of
3026
+ * pushed (it pushes them, or what its handlers show of them). */
3027
+ display: import("../mods/message-display.js").MessageDisplay | undefined;
3028
+ emitCommitted: EmitCommitted;
2918
3029
  startedToolCallIds: Set<string>;
2919
3030
  toolStartAt: Map<string, number>;
2920
3031
  /** The run's tool-progress lane: the handlers tell it when a call enters and leaves execution, and
@@ -2986,8 +3097,18 @@ export interface RunnerSelfSeat {
2986
3097
  * true only when its deps carry an `executionEnvFactory` (live read — `swapDeps` replaces the deps). The delegation tool asks
2987
3098
  * the runner that will run the child, not the one that ran the parent leg. Absent on a hand-built seat ⇒ read as "cannot say" ⇒ no; a hand-built seat answers for the runner its `runTask` forwards to. */
2988
3099
  canRerootChild?(): boolean;
3100
+ /** A completion addressed to a delegation tree's root, through THIS runner's notification route: the route's sink when the
3101
+ * deployment judges the root a durable box at `root.scope` that takes engine frames (the sink then reaches the root's live run
3102
+ * here, else its seat here, else that box), or why not. Asked by a drive that carries no run lane and whose task registry holds
3103
+ * no park of the cycle. `unkept` = where a frame goes when the box of a root seated nowhere here failed it twice. The route
3104
+ * judges again at each delivery. Absent on a hand-built seat ⇒ read as "no route" (the drive keeps the mount's sink). */
3105
+ sessionCompletionLane?(root: SessionAddress, unkept?: TaskNotificationSink): SessionCompletionLane;
2989
3106
  /** Fire `RunnerDeps.onTaskOutcome` through the swallow-guarded chokepoint (thin compositions emit at their terminal state). */
2990
3107
  emitTaskOutcome(outcome: TaskOutcome): void;
3108
+ /** Announce a fact of a composition's own (the verification gate's `verify.verifier_is_implementer`) on `RunnerDeps.onNotice`, live-read,
3109
+ * through the one delivery form every notice leaves by (`deliverEngineNotice`: the same-principal text pass, the session lift, a
3110
+ * throwing sink contained). Absent on a hand-built seat ⇒ the composition cannot say it, and says nothing; the Runner always has it. */
3111
+ emitNotice?(notice: import("../engine-notice.js").EngineNotice): void;
2991
3112
  /** A hold, on the peer seat THIS runner's legs ask, of the references `declared` names — taken by a keeper of declarations
2992
3113
  * outside a leg (a retained child's ledger entry), released by it once (peer-seat.ts `holdPeerDeclarations`). */
2993
3114
  holdDeclarations(declared: import("../peer-seat.js").PeerDeclarations): import("../peer-seat.js").PeerDeclarationHold;
@@ -3062,6 +3183,9 @@ export interface TaskIdRef {
3062
3183
  effectiveReasoning?: TaskResult["effectiveReasoning"];
3063
3184
  delegationTerminalOwed?: HookInvocationIdentity;
3064
3185
  editedFiles?: () => TaskResult["editedFiles"];
3186
+ /** Whether the leg's prompt message was committed: `{ committed: false }` from the carrier's creation, replaced at the prompt
3187
+ * receipt by the commit's reading (`intakeOfCommit`; `undefined` when the store handed back no usable entry id). */
3188
+ intake?: TaskResult["intake"];
3065
3189
  }
3066
3190
  /** The manual `/compact` request seat: the `requested` flag, the parked waiters (each with its
3067
3191
  * caller's cancel signal and per-call instructions), the run body's mooted-frame channel and the registration
@@ -3081,29 +3205,13 @@ export interface ManualCompactRef {
3081
3205
  }
3082
3206
  /**
3083
3207
  * The end-of-task compaction pass's outcome (`Runner.finish`'s return): what the terminal-adoption lane
3084
- * hands the settle lane, which reads it for the `compacted` frame, the phase-timings frame and the detector reset. Named
3085
- * once here so the two lanes and the method spell one type.
3208
+ * hands the settle lane, which reads it for the `compacted` frame, the phase-timings frame and the detector reset: what
3209
+ * the `compacted` frame's mint reads ({@link CompactedFrameSource}), plus whether the pass landed. Named once here so the
3210
+ * two lanes and the method spell one type.
3086
3211
  */
3087
- export type EndOfTaskCompaction = {
3212
+ export type EndOfTaskCompaction = ({
3088
3213
  compacted: boolean;
3089
- pass?: string;
3090
- tokensBefore?: number;
3091
- freedTokens?: number;
3092
- triggerTokens?: number;
3093
- postTriggerTokens?: number;
3094
- durationMs?: number;
3095
- phaseDurations?: CompactionPhaseDurations;
3096
- firstKeptEntryId?: string;
3097
- attachedFiles?: Array<{
3098
- path: string;
3099
- chars: number;
3100
- truncated: boolean;
3101
- }>;
3102
- modelFallback?: true;
3103
- fallbackReason?: "window";
3104
- clampedRatio?: number;
3105
- clampReason?: "budget" | "tolerance";
3106
- } | undefined;
3214
+ } & CompactedFrameSource) | undefined;
3107
3215
  /**
3108
3216
  * The notification lane's BINDINGS: the run-notification-lane's own four `let`s as ONE seat (getters
3109
3217
  * and setters over the lane's variables, never a copy). The identity-wiring lane binds `harness` / `sessionId` /