@sema-agent/core 7.58.0 → 7.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (519) hide show
  1. package/CHANGELOG.md +1340 -0
  2. package/README.md +6 -4
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  6. package/dist/agents/agent-transcript-tool.js +3 -1
  7. package/dist/agents/cc-peer-directory.js +8 -8
  8. package/dist/agents/child-model-seat.d.ts +4 -2
  9. package/dist/agents/child-model-seat.js +9 -4
  10. package/dist/agents/cumulative-stats.js +0 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  12. package/dist/agents/inherited-tool-pool.js +22 -0
  13. package/dist/agents/peer-directory.d.ts +9 -0
  14. package/dist/agents/peer-directory.js +6 -2
  15. package/dist/agents/retain-ledger.d.ts +11 -1
  16. package/dist/agents/retain-ledger.js +13 -2
  17. package/dist/agents/roster-store.d.ts +1 -1
  18. package/dist/agents/roster-store.js +3 -1
  19. package/dist/agents/send-message-tool.d.ts +8 -19
  20. package/dist/agents/send-message-tool.js +32 -50
  21. package/dist/agents/subagent.d.ts +51 -17
  22. package/dist/agents/subagent.js +150 -112
  23. package/dist/agents/tool-filter.d.ts +1 -3
  24. package/dist/agents/tool-filter.js +4 -12
  25. package/dist/bench/metrics.d.ts +3 -5
  26. package/dist/bench/metrics.js +0 -1
  27. package/dist/brain/anthropic.js +161 -45
  28. package/dist/brain/degrading.js +3 -1
  29. package/dist/brain/errors.d.ts +9 -3
  30. package/dist/brain/errors.js +7 -1
  31. package/dist/brain/failover.js +2 -1
  32. package/dist/brain/open-responses.js +3 -3
  33. package/dist/brain/openai.js +103 -53
  34. package/dist/brain/provider-dialect.d.ts +11 -0
  35. package/dist/brain/provider-dialect.js +5 -2
  36. package/dist/brain/reasoning-request.js +5 -4
  37. package/dist/brain/reasoning.d.ts +19 -0
  38. package/dist/brain/reasoning.js +17 -2
  39. package/dist/brain/request-route.d.ts +4 -1
  40. package/dist/brain/request-route.js +4 -1
  41. package/dist/brain/route-adjudicator.d.ts +84 -18
  42. package/dist/brain/route-adjudicator.js +90 -22
  43. package/dist/brain/route-conformance.js +1 -1
  44. package/dist/brain/status-sink.d.ts +7 -1
  45. package/dist/brain/status-sink.js +6 -0
  46. package/dist/brain/stream-engine.js +84 -49
  47. package/dist/brain/stream-shared.d.ts +30 -0
  48. package/dist/brain/stream-shared.js +34 -1
  49. package/dist/brain/timeout.d.ts +65 -6
  50. package/dist/brain/timeout.js +111 -11
  51. package/dist/core/a2a.d.ts +15 -5
  52. package/dist/core/a2a.js +34 -19
  53. package/dist/core/account-row.d.ts +61 -0
  54. package/dist/core/account-row.js +51 -0
  55. package/dist/core/advisor-verdict.d.ts +2 -1
  56. package/dist/core/advisor-verdict.js +1 -1
  57. package/dist/core/agent-definition.d.ts +20 -0
  58. package/dist/core/allow-entry.d.ts +20 -6
  59. package/dist/core/allow-entry.js +17 -7
  60. package/dist/core/approval-object.d.ts +29 -15
  61. package/dist/core/approval-object.js +47 -19
  62. package/dist/core/artifact-host.d.ts +0 -2
  63. package/dist/core/artifact-host.js +0 -1
  64. package/dist/core/auto-compaction.js +1 -1
  65. package/dist/core/auto-mode-defaults.d.ts +8 -0
  66. package/dist/core/auto-mode-defaults.js +1 -0
  67. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  68. package/dist/core/auto-mode.d.ts +39 -4
  69. package/dist/core/auto-mode.js +63 -12
  70. package/dist/core/background-agent-store.d.ts +26 -4
  71. package/dist/core/background-agent-store.js +3 -2
  72. package/dist/core/background-shell.d.ts +12 -1
  73. package/dist/core/background-shell.js +12 -0
  74. package/dist/core/checkpoint-requirements.d.ts +13 -1
  75. package/dist/core/checkpoint-requirements.js +3 -1
  76. package/dist/core/checkpoint-store.d.ts +66 -25
  77. package/dist/core/checkpoint-store.js +22 -9
  78. package/dist/core/child-clamp-seats.d.ts +29 -0
  79. package/dist/core/child-clamp-seats.js +56 -1
  80. package/dist/core/compliance.d.ts +3 -3
  81. package/dist/core/compliance.js +1 -1
  82. package/dist/core/credential-echo.d.ts +52 -0
  83. package/dist/core/credential-echo.js +65 -0
  84. package/dist/core/credential-vocabulary.d.ts +13 -3
  85. package/dist/core/credential-vocabulary.js +12 -4
  86. package/dist/core/cross-boundary-taint.d.ts +4 -5
  87. package/dist/core/effective-path-target.d.ts +8 -2
  88. package/dist/core/effective-path-target.js +8 -3
  89. package/dist/core/engine-notice.d.ts +156 -23
  90. package/dist/core/engine-notice.js +19 -5
  91. package/dist/core/frame-settlement.d.ts +5 -0
  92. package/dist/core/frame-settlement.js +4 -0
  93. package/dist/core/gate-fold.js +8 -6
  94. package/dist/core/gate-lanes.js +47 -12
  95. package/dist/core/gate-outcome.d.ts +32 -3
  96. package/dist/core/gate-outcome.js +19 -1
  97. package/dist/core/governance-codes.d.ts +17 -1
  98. package/dist/core/governance-codes.js +25 -0
  99. package/dist/core/hands-band-screen.js +0 -1
  100. package/dist/core/hands-band.d.ts +0 -3
  101. package/dist/core/hooks.d.ts +70 -59
  102. package/dist/core/hooks.js +125 -80
  103. package/dist/core/image-admission.d.ts +106 -52
  104. package/dist/core/image-admission.js +184 -56
  105. package/dist/core/image-downsample.d.ts +36 -69
  106. package/dist/core/image-downsample.js +111 -73
  107. package/dist/core/integer-option.d.ts +21 -0
  108. package/dist/core/integer-option.js +13 -0
  109. package/dist/core/locked-config.d.ts +59 -5
  110. package/dist/core/locked-config.js +82 -50
  111. package/dist/core/mailbox-store.d.ts +45 -1
  112. package/dist/core/mailbox-store.js +53 -9
  113. package/dist/core/mcp-call-meta.d.ts +2 -2
  114. package/dist/core/mcp-call-meta.js +9 -10
  115. package/dist/core/mcp-failure.d.ts +122 -20
  116. package/dist/core/mcp-failure.js +73 -5
  117. package/dist/core/mcp-host-seat.d.ts +92 -0
  118. package/dist/core/mcp-host-seat.js +131 -0
  119. package/dist/core/mcp-probe.d.ts +7 -2
  120. package/dist/core/mcp-probe.js +7 -2
  121. package/dist/core/mcp-server-link.d.ts +22 -1
  122. package/dist/core/mcp-server-link.js +25 -1
  123. package/dist/core/mcp-server-spec.d.ts +38 -9
  124. package/dist/core/mcp-server-spec.js +55 -21
  125. package/dist/core/mcp.d.ts +27 -12
  126. package/dist/core/mcp.js +105 -76
  127. package/dist/core/memory-admission.d.ts +23 -6
  128. package/dist/core/memory-admission.js +19 -9
  129. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  130. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  131. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  132. package/dist/core/memory-engine/consolidation.js +1 -0
  133. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  134. package/dist/core/memory-engine/content-origin.js +21 -3
  135. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  136. package/dist/core/memory-engine/distiller.js +2 -2
  137. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  138. package/dist/core/memory-engine/dual-root.js +44 -1
  139. package/dist/core/memory-engine/engine.d.ts +67 -14
  140. package/dist/core/memory-engine/engine.js +384 -212
  141. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  142. package/dist/core/memory-engine/export-bundle.js +23 -4
  143. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  144. package/dist/core/memory-engine/file-backend.js +290 -117
  145. package/dist/core/memory-engine/index.d.ts +3 -2
  146. package/dist/core/memory-engine/index.js +2 -1
  147. package/dist/core/memory-engine/layout.d.ts +59 -11
  148. package/dist/core/memory-engine/layout.js +190 -40
  149. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  150. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  151. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  152. package/dist/core/memory-engine/scope-contract.js +2 -2
  153. package/dist/core/memory-engine/sync-client.d.ts +51 -9
  154. package/dist/core/memory-engine/sync-client.js +107 -13
  155. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  156. package/dist/core/memory-engine/sync-report.js +119 -0
  157. package/dist/core/memory-engine/sync.d.ts +8 -1
  158. package/dist/core/memory-engine/types.d.ts +6 -0
  159. package/dist/core/mode-policy.d.ts +9 -1
  160. package/dist/core/mode-policy.js +11 -1
  161. package/dist/core/model-receipt.d.ts +39 -0
  162. package/dist/core/model-receipt.js +139 -0
  163. package/dist/core/mods/agent-stations.d.ts +65 -0
  164. package/dist/core/mods/agent-stations.js +105 -0
  165. package/dist/core/mods/classic-events.d.ts +5 -1
  166. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  167. package/dist/core/mods/kernel/dispatch.js +6 -5
  168. package/dist/core/mods/kernel/events.d.ts +11 -4
  169. package/dist/core/mods/kernel/events.js +11 -7
  170. package/dist/core/mods/kernel/receive.d.ts +5 -0
  171. package/dist/core/mods/kernel/receive.js +10 -0
  172. package/dist/core/mods/kernel/registration.d.ts +4 -0
  173. package/dist/core/mods/kernel/registration.js +3 -0
  174. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  175. package/dist/core/mods/lifecycle-stations.js +35 -0
  176. package/dist/core/mods/stations.d.ts +73 -60
  177. package/dist/core/mods/stations.js +64 -40
  178. package/dist/core/mods/tool-call.d.ts +10 -4
  179. package/dist/core/mods/tool-call.js +28 -12
  180. package/dist/core/mounted-mcp.d.ts +5 -0
  181. package/dist/core/mounted-mcp.js +2 -2
  182. package/dist/core/namespaced-rule-name.d.ts +7 -1
  183. package/dist/core/namespaced-rule-name.js +13 -2
  184. package/dist/core/oracle-isolation.js +1 -1
  185. package/dist/core/own-property-receipt.d.ts +3 -0
  186. package/dist/core/own-property-receipt.js +3 -0
  187. package/dist/core/parent-spec-seat.d.ts +8 -3
  188. package/dist/core/parent-spec-seat.js +2 -0
  189. package/dist/core/park-selfcheck.js +14 -8
  190. package/dist/core/peer-seat.d.ts +133 -16
  191. package/dist/core/peer-seat.js +319 -42
  192. package/dist/core/permission-rule-consent.d.ts +0 -21
  193. package/dist/core/permission-rule-consent.js +11 -6
  194. package/dist/core/permission-rule-model.d.ts +20 -2
  195. package/dist/core/permission-rule-model.js +8 -7
  196. package/dist/core/present-plan-tool.d.ts +11 -3
  197. package/dist/core/present-plan-tool.js +2 -2
  198. package/dist/core/protocol-http-auth.d.ts +14 -2
  199. package/dist/core/protocol-http-auth.js +16 -7
  200. package/dist/core/read-face-seats.d.ts +7 -5
  201. package/dist/core/read-face-seats.js +4 -1
  202. package/dist/core/redaction-marks.d.ts +4 -3
  203. package/dist/core/redaction-marks.js +2 -2
  204. package/dist/core/remote-env.d.ts +146 -98
  205. package/dist/core/remote-env.js +113 -14
  206. package/dist/core/resume-startup-cause.js +1 -0
  207. package/dist/core/retention.js +37 -12
  208. package/dist/core/retired-keys.d.ts +6 -1
  209. package/dist/core/retired-keys.js +4 -1
  210. package/dist/core/rewrite-rejudge.d.ts +13 -5
  211. package/dist/core/rewrite-rejudge.js +9 -5
  212. package/dist/core/roles.d.ts +69 -3
  213. package/dist/core/roles.js +167 -80
  214. package/dist/core/rule-owner.d.ts +3 -0
  215. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  216. package/dist/core/runner/announce-once-ledger.js +4 -2
  217. package/dist/core/runner/assemble-result.d.ts +0 -5
  218. package/dist/core/runner/assemble-result.js +0 -1
  219. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  220. package/dist/core/runner/call-hook-stations.js +23 -12
  221. package/dist/core/runner/child-tree.d.ts +7 -8
  222. package/dist/core/runner/child-tree.js +6 -6
  223. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  224. package/dist/core/runner/classifier-ladder.js +39 -8
  225. package/dist/core/runner/construction-doors.js +5 -0
  226. package/dist/core/runner/contracts.d.ts +82 -57
  227. package/dist/core/runner/credential-origin-seat.js +4 -3
  228. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  229. package/dist/core/runner/cross-boundary-lane.js +11 -2
  230. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  231. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  232. package/dist/core/runner/decide-continuation.d.ts +2 -2
  233. package/dist/core/runner/env-capability-census.d.ts +15 -20
  234. package/dist/core/runner/env-capability-census.js +25 -34
  235. package/dist/core/runner/file-history-request.d.ts +2 -2
  236. package/dist/core/runner/file-history-request.js +0 -8
  237. package/dist/core/runner/gate-exit.d.ts +87 -11
  238. package/dist/core/runner/gate-exit.js +30 -8
  239. package/dist/core/runner/git-status-frame.d.ts +5 -2
  240. package/dist/core/runner/git-status-frame.js +3 -4
  241. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  242. package/dist/core/runner/image-removed-seat.js +19 -0
  243. package/dist/core/runner/image.d.ts +7 -2
  244. package/dist/core/runner/image.js +14 -8
  245. package/dist/core/runner/inline-image.d.ts +10 -8
  246. package/dist/core/runner/inline-image.js +11 -9
  247. package/dist/core/runner/memory-consolidation-driver.js +5 -5
  248. package/dist/core/runner/park-commit.d.ts +1 -1
  249. package/dist/core/runner/park-commit.js +3 -0
  250. package/dist/core/runner/permission-rule-lanes.js +1 -1
  251. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  252. package/dist/core/runner/prepare-ask-lane.js +2 -1
  253. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  254. package/dist/core/runner/prepare-boundary-parks.js +5 -5
  255. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
  256. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  257. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  258. package/dist/core/runner/prepare-config-doors.js +16 -9
  259. package/dist/core/runner/prepare-context-lane.js +2 -0
  260. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
  261. package/dist/core/runner/prepare-delegation-surface.js +5 -4
  262. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  263. package/dist/core/runner/prepare-file-history.js +3 -12
  264. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  265. package/dist/core/runner/prepare-gate-stations.js +4 -3
  266. package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
  267. package/dist/core/runner/prepare-hands-readface.js +19 -6
  268. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
  269. package/dist/core/runner/prepare-inherited-gate.js +22 -31
  270. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  271. package/dist/core/runner/prepare-memory.d.ts +2 -2
  272. package/dist/core/runner/prepare-memory.js +12 -19
  273. package/dist/core/runner/prepare-park-ask.d.ts +4 -6
  274. package/dist/core/runner/prepare-park-ask.js +5 -9
  275. package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
  276. package/dist/core/runner/prepare-policy-chain.js +136 -121
  277. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  278. package/dist/core/runner/prepare-project-context.js +10 -7
  279. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
  280. package/dist/core/runner/prepare-prompt-inputs.js +10 -20
  281. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  282. package/dist/core/runner/prepare-protocol-tools.js +17 -2
  283. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  284. package/dist/core/runner/prepare-run-refs.js +4 -1
  285. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  286. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  287. package/dist/core/runner/prepare-task.js +44 -28
  288. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  289. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  290. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
  291. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  292. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  293. package/dist/core/runner/reply-pricing.d.ts +30 -0
  294. package/dist/core/runner/reply-pricing.js +19 -0
  295. package/dist/core/runner/resume-admission.js +4 -2
  296. package/dist/core/runner/resume-apply.js +6 -1
  297. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  298. package/dist/core/runner/resume-policy-outcome.js +5 -5
  299. package/dist/core/runner/retired-runner-deps.js +4 -1
  300. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  301. package/dist/core/runner/role-seat-defaulted.js +40 -0
  302. package/dist/core/runner/run-attachment-seats.js +3 -3
  303. package/dist/core/runner/run-brain-sinks.js +3 -0
  304. package/dist/core/runner/run-git-lane.d.ts +3 -1
  305. package/dist/core/runner/run-git-lane.js +1 -1
  306. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  307. package/dist/core/runner/run-harness-handlers.js +3 -1
  308. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  309. package/dist/core/runner/run-identity-wiring.js +6 -5
  310. package/dist/core/runner/run-leg.d.ts +2 -0
  311. package/dist/core/runner/run-leg.js +63 -56
  312. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  313. package/dist/core/runner/run-notification-lane.js +16 -10
  314. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  315. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  316. package/dist/core/runner/run-stop-and-final-verify.js +14 -6
  317. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  318. package/dist/core/runner/run-terminal-adoption.js +9 -3
  319. package/dist/core/runner/run-turn-boundary.js +89 -77
  320. package/dist/core/runner/runtask.d.ts +8 -5
  321. package/dist/core/runner/runtask.js +21 -13
  322. package/dist/core/runner/side-call-account.d.ts +1 -1
  323. package/dist/core/runner/side-call-account.js +3 -18
  324. package/dist/core/runner/skills-seat.js +2 -2
  325. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  326. package/dist/core/runner/sub-agent-deny-lists.js +20 -7
  327. package/dist/core/runner/synthetic-tools.js +2 -2
  328. package/dist/core/runner/tool-disclosure.js +0 -2
  329. package/dist/core/runner/tool-end-body.js +2 -2
  330. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  331. package/dist/core/runner/tool-face-overlay.js +26 -19
  332. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  333. package/dist/core/runner/tool-occurrence.js +2 -2
  334. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  335. package/dist/core/runner/tool-result-media-seat.js +17 -1
  336. package/dist/core/runner/turn-attachments.d.ts +29 -27
  337. package/dist/core/runner/turn-attachments.js +27 -42
  338. package/dist/core/runner-deps.d.ts +32 -19
  339. package/dist/core/secret-env.d.ts +35 -4
  340. package/dist/core/secret-env.js +65 -3
  341. package/dist/core/sensitive-path-policy.js +3 -3
  342. package/dist/core/session-policy-store.d.ts +12 -3
  343. package/dist/core/session-policy-store.js +29 -10
  344. package/dist/core/session-store.d.ts +5 -7
  345. package/dist/core/session-store.js +50 -11
  346. package/dist/core/side-query.d.ts +11 -1
  347. package/dist/core/side-query.js +9 -0
  348. package/dist/core/skill-grant-binding.d.ts +31 -2
  349. package/dist/core/skill-grant-binding.js +31 -1
  350. package/dist/core/skill-grant.d.ts +17 -5
  351. package/dist/core/skill-grant.js +24 -6
  352. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  353. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  354. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  355. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  356. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  357. package/dist/core/stub-env.d.ts +5 -5
  358. package/dist/core/stub-env.js +11 -1
  359. package/dist/core/swappable-deps.d.ts +17 -43
  360. package/dist/core/swappable-deps.js +15 -5
  361. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  362. package/dist/core/synthetic-read-verdict.js +2 -1
  363. package/dist/core/task-event.d.ts +50 -10
  364. package/dist/core/task-notification.d.ts +88 -5
  365. package/dist/core/task-notification.js +146 -17
  366. package/dist/core/task-registry-agent.d.ts +18 -12
  367. package/dist/core/task-registry-agent.js +19 -6
  368. package/dist/core/task-registry-monitor.d.ts +7 -0
  369. package/dist/core/task-registry-monitor.js +28 -1
  370. package/dist/core/task-registry-shared.d.ts +43 -3
  371. package/dist/core/task-registry-shared.js +21 -7
  372. package/dist/core/task-registry-workflow.js +1 -1
  373. package/dist/core/task-registry.d.ts +50 -35
  374. package/dist/core/task-registry.js +64 -23
  375. package/dist/core/task-result.d.ts +3 -12
  376. package/dist/core/task-spec.d.ts +15 -7
  377. package/dist/core/task-stream.d.ts +1 -1
  378. package/dist/core/terminal-cause.d.ts +10 -0
  379. package/dist/core/tool-catalog-entries.js +1 -1
  380. package/dist/core/tool-check-reading.d.ts +1 -0
  381. package/dist/core/tool-check-reading.js +3 -3
  382. package/dist/core/tool-face-reader.d.ts +7 -6
  383. package/dist/core/tool-face-reader.js +4 -3
  384. package/dist/core/tool-name-aliases.d.ts +19 -0
  385. package/dist/core/tool-name-aliases.js +54 -2
  386. package/dist/core/tool-policy.d.ts +21 -4
  387. package/dist/core/tool-policy.js +1 -1
  388. package/dist/core/tool-registry.d.ts +5 -5
  389. package/dist/core/tool-registry.js +2 -2
  390. package/dist/core/tool-result-store.d.ts +88 -5
  391. package/dist/core/tool-result-store.js +51 -12
  392. package/dist/core/tool-roster.d.ts +112 -5
  393. package/dist/core/tool-roster.js +42 -1
  394. package/dist/core/tool-spec.d.ts +23 -5
  395. package/dist/core/trace.d.ts +0 -1
  396. package/dist/core/types.d.ts +5 -5
  397. package/dist/core/types.js +2 -2
  398. package/dist/core/untrusted-text.js +1 -1
  399. package/dist/core/user-attachment.d.ts +10 -5
  400. package/dist/core/user-attachment.js +15 -7
  401. package/dist/core/wiring-manifest.d.ts +6 -3
  402. package/dist/engine/compaction/compaction.js +29 -3
  403. package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
  404. package/dist/engine/execution-env/node-execution-env.js +21 -13
  405. package/dist/engine/harness/agent-harness.d.ts +26 -3
  406. package/dist/engine/harness/agent-harness.js +49 -16
  407. package/dist/engine/harness/messages.d.ts +3 -1
  408. package/dist/engine/harness/messages.js +3 -2
  409. package/dist/engine/harness/types.d.ts +119 -28
  410. package/dist/engine/llm/rejected-images.d.ts +46 -0
  411. package/dist/engine/llm/rejected-images.js +54 -0
  412. package/dist/engine/llm/tool-turns.d.ts +2 -1
  413. package/dist/engine/llm/types.d.ts +18 -7
  414. package/dist/engine/loop/agent-loop.d.ts +20 -12
  415. package/dist/engine/loop/agent-loop.js +205 -36
  416. package/dist/engine/loop/types.d.ts +12 -3
  417. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  418. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  419. package/dist/engine/session/path-to-root.d.ts +38 -0
  420. package/dist/engine/session/path-to-root.js +39 -0
  421. package/dist/engine/session/storage-base.js +4 -21
  422. package/dist/index.d.ts +35 -21
  423. package/dist/index.js +26 -17
  424. package/dist/internal/harness-types.d.ts +1 -1
  425. package/dist/internal/harness.d.ts +1 -0
  426. package/dist/internal/llm.d.ts +1 -0
  427. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  428. package/dist/orchestration/run-workflow-tool.js +59 -29
  429. package/dist/orchestration/workflow-governance.d.ts +1 -1
  430. package/dist/orchestration/workflow-governance.js +2 -1
  431. package/dist/orchestration/workflow-observe.d.ts +17 -1
  432. package/dist/orchestration/workflow-observe.js +20 -0
  433. package/dist/orchestration/workflow-types.d.ts +32 -7
  434. package/dist/orchestration/workflow.d.ts +4 -0
  435. package/dist/orchestration/workflow.js +762 -491
  436. package/dist/prompts/default.d.ts +1 -10
  437. package/dist/prompts/default.js +0 -2
  438. package/dist/shell/counting-pass.d.ts +50 -0
  439. package/dist/shell/counting-pass.js +502 -0
  440. package/dist/shell/lex.d.ts +4 -2
  441. package/dist/shell/lex.js +93 -34
  442. package/dist/shell/shell-words.d.ts +1 -1
  443. package/dist/shell/shell-words.js +7 -6
  444. package/dist/stores/file/background-agent-store.d.ts +1 -1
  445. package/dist/stores/file/background-agent-store.js +3 -1
  446. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  447. package/dist/stores/file/checkpoint-store.js +19 -14
  448. package/dist/stores/file/file-history-store.d.ts +1 -1
  449. package/dist/stores/file/file-history-store.js +3 -1
  450. package/dist/stores/file/index.d.ts +4 -3
  451. package/dist/stores/file/index.js +17 -8
  452. package/dist/stores/file/mailbox-store.d.ts +1 -1
  453. package/dist/stores/file/mailbox-store.js +9 -11
  454. package/dist/stores/file/memory-store.d.ts +1 -1
  455. package/dist/stores/file/memory-store.js +3 -1
  456. package/dist/stores/file/session-policy-store.d.ts +1 -1
  457. package/dist/stores/file/session-policy-store.js +3 -1
  458. package/dist/stores/file/session-store.d.ts +1 -1
  459. package/dist/stores/file/session-store.js +3 -1
  460. package/dist/stores/file/shared-ledger.d.ts +26 -0
  461. package/dist/stores/file/shared-ledger.js +38 -9
  462. package/dist/stores/file/tool-result-store.d.ts +20 -2
  463. package/dist/stores/file/tool-result-store.js +74 -6
  464. package/dist/stores/file/usage-window-store.d.ts +1 -1
  465. package/dist/stores/file/usage-window-store.js +3 -1
  466. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  467. package/dist/stores/file/workflow-journal-store.js +3 -2
  468. package/dist/tools/fs/containment-face.d.ts +5 -0
  469. package/dist/tools/fs/encoding.d.ts +13 -4
  470. package/dist/tools/fs/encoding.js +17 -2
  471. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  472. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  473. package/dist/tools/fs/fs-bash.d.ts +14 -4
  474. package/dist/tools/fs/fs-bash.js +29 -35
  475. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  476. package/dist/tools/fs/fs-pdf.js +26 -21
  477. package/dist/tools/fs/fs-read.d.ts +5 -4
  478. package/dist/tools/fs/fs-read.js +35 -18
  479. package/dist/tools/fs/fs-search-tools.js +4 -1
  480. package/dist/tools/fs/fs-shared.d.ts +11 -13
  481. package/dist/tools/fs/fs-shared.js +11 -7
  482. package/dist/tools/fs/fs-write.js +5 -5
  483. package/dist/tools/fs/index.d.ts +14 -8
  484. package/dist/tools/fs/index.js +13 -5
  485. package/dist/tools/fs/program-read-model.d.ts +13 -0
  486. package/dist/tools/fs/program-read-model.js +15 -0
  487. package/dist/tools/fs/program-read-model.rows.js +1 -1
  488. package/dist/tools/fs/read-deny.d.ts +13 -10
  489. package/dist/tools/fs/read-deny.js +25 -5
  490. package/dist/tools/fs/read-floor.d.ts +62 -0
  491. package/dist/tools/fs/read-floor.js +58 -0
  492. package/dist/tools/fs/removal-targets.d.ts +9 -4
  493. package/dist/tools/fs/removal-targets.js +17 -9
  494. package/dist/tools/fs/search.d.ts +3 -3
  495. package/dist/tools/fs/search.js +4 -4
  496. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  497. package/dist/tools/fs/shell-read-check.js +2 -1
  498. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  499. package/dist/tools/fs/shell-read-judge.js +10 -6
  500. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  501. package/dist/tools/fs/shell-read-plan.js +22 -15
  502. package/dist/tools/fs/shell-read-start.js +1 -0
  503. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  504. package/dist/tools/fs/shell-reentry-text.js +25 -3
  505. package/dist/tools/monitor.d.ts +9 -4
  506. package/dist/tools/monitor.js +17 -8
  507. package/dist/tools/scheduler-tools.js +42 -4
  508. package/dist/tools/web.d.ts +0 -10
  509. package/dist/tools/web.js +1 -4
  510. package/package.json +5 -2
  511. package/test/export-surface.snapshot.json +161 -21
  512. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  513. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  514. package/wire-changes/core@7.59.0.json +2459 -0
  515. package/wire-changes/core@7.60.0.json +3274 -0
  516. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  517. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  518. package/wire-changes/primitives@7.59.0.json +29 -0
  519. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -4,10 +4,12 @@ import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
4
4
  import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTRUCTIONS, isCompactionManualCancel, manualCompactOutcomeOf, maybeCompact, mintCompactedEvent, nextTrimForceBackoff, recordCompactionAndCheckRapidRefill } from "../auto-compaction.js";
5
5
  import { emitTrace } from "../trace.js";
6
6
  import { redactThenCut } from "../../agents/subagent-steps.js";
7
- import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, clipToBytes, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame, renderMcpDroppedTools, renderMcpInstructionsDelta, selectMcpDroppedBatch, renderSkillsListingFrame, renderToolsDelta } from "./turn-attachments.js";
7
+ import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, clipToBytes, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame, renderMcpInstructionsDelta, selectMcpDroppedBatch, renderSkillsListingFrame } from "./turn-attachments.js";
8
8
  import { announceListingTruncation } from "../skill-listing-budget.js";
9
9
  import { buildWorkingFileAttachments, centerAdoptionOption, contextInstructionFilesOption, emitInputTruncated, forkContextOption, legCompactionSettings, legContextOverlayOption } from "./compaction-call-options.js";
10
10
  import { classicEventBase, dispatchClassic, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
11
+ import { offeredAgentListing } from "../mods/agent-stations.js";
12
+ import { raiseCompletedTurn } from "../mods/lifecycle-stations.js";
11
13
  import { sanitizeUntrustedText, SHELLED_BODY_ENVELOPE_TAGS } from "../untrusted-text.js";
12
14
  import { droppedToolDigest, withAnnounceDigests } from "./announce-once-ledger.js";
13
15
  import { formatDiagnosticsBlock, withholdListedDiagnostics } from "../lsp-diagnostics.js";
@@ -20,12 +22,21 @@ import { contextUsageSections } from "../../prompt-assembly/section-usage.js";
20
22
  import { asThrownError } from "../thrown-value.js";
21
23
  const BATCH_CONTEXT_MIN_KEEP_BYTES = 160;
22
24
  const BATCH_TRUNCATION_MARKER = "\n…[truncated]";
25
+ function consumeDelivered(pending, delivered) {
26
+ for (const d of delivered) {
27
+ const at = pending.indexOf(d);
28
+ if (at !== -1)
29
+ pending.splice(at, 1);
30
+ }
31
+ }
23
32
  export function createTurnBoundary(input) {
24
33
  const { prepared, stats, rs, deps } = input;
25
34
  const { spec, queue, loopLatch: { callerStop }, manualCompactRef, todoToolMounted, taskToolsMounted, walltimeMonotonicDeadline, timeout, ident, postToolBatchArmed, batchArgs, compactionBrain, withinTaskCompaction, compactionBreaker, windowSafetyOptions, rapidRefill, drainManualCompact, runnerHooks, runner } = deps;
26
35
  let finalVerifySeenAtLastBoundary = 0;
27
36
  let legContinues = true;
28
37
  const boundaryPass = async (event) => {
38
+ if (rs.turn.completed !== undefined)
39
+ await raiseCompletedTurn(prepared.modBus, rs.turn, prepared.hookIdentity, prepared.abortController.signal);
29
40
  const turnOwesRequest = event.continues;
30
41
  let boundarySteered = false;
31
42
  const noNextRequest = () => prepared.stopRequestedRef.current || deps.loopLatch.userHalted;
@@ -152,7 +163,8 @@ export function createTurnBoundary(input) {
152
163
  turnOwesRequest &&
153
164
  prepared.batchHaltRef.current === undefined &&
154
165
  !boundarySteered &&
155
- !prepared.abortController.signal.aborted) {
166
+ !prepared.abortController.signal.aborted &&
167
+ !frameCarried(prepared.frameReceipts, "limit_approach")) {
156
168
  const thresholds = approachCfg?.at ?? LIMIT_APPROACH_DEFAULT_THRESHOLDS;
157
169
  const ratios = [];
158
170
  if (rs.budget.maxTokensWindow !== undefined && rs.budget.maxTokensWindow > 0) {
@@ -177,22 +189,31 @@ export function createTurnBoundary(input) {
177
189
  tightest = r;
178
190
  const index = rs.counters.approachNoticesSent;
179
191
  if (tightest !== undefined && tightest.ratio >= thresholds[index]) {
180
- rs.counters.approachNoticesSent += 1;
181
192
  const percent = Math.min(100, Math.round(tightest.ratio * 100));
182
193
  const body = limitApproachFrames(index === 0 ? 0 : 1, tightest.axis, percent, prepared.reminderMark);
183
- void prepared.harness.steer(body, { engineMinted: true }).catch(() => undefined);
184
- queue.push({ type: "steering_injected", source: "limit_approach", preview: body.slice(0, 220), ...ident() });
194
+ const preview = body.slice(0, 220);
195
+ prepared.frameReceipts.pending.push({
196
+ source: "limit_approach",
197
+ text: body,
198
+ commit: () => {
199
+ rs.counters.approachNoticesSent += 1;
200
+ queue.push({ type: "steering_injected", source: "limit_approach", preview, ...ident() });
201
+ },
202
+ });
203
+ void prepared.harness.steer(body, { engineMinted: true }).catch(() => {
204
+ prepared.frameReceipts.pending = prepared.frameReceipts.pending.filter((r) => r.text !== body);
205
+ });
185
206
  boundarySteered = true;
186
207
  }
187
208
  }
188
209
  if (prepared.reviewRequestRef.pending !== undefined) {
189
- const { reason } = prepared.reviewRequestRef.pending;
210
+ const { reason, requestedByCallId } = prepared.reviewRequestRef.pending;
190
211
  prepared.reviewRequestRef.pending = undefined;
191
212
  const honorable = prepared.suspendForReview !== undefined &&
192
213
  !prepared.abortController.signal.aborted &&
193
214
  prepared.pausedRef.current === undefined;
194
215
  if (honorable && prepared.suspendForReview) {
195
- await prepared.suspendForReview(reason);
216
+ await prepared.suspendForReview(reason, requestedByCallId);
196
217
  legContinues = !prepared.abortController.signal.aborted && prepared.pausedRef.current === undefined;
197
218
  return undefined;
198
219
  }
@@ -215,7 +236,9 @@ export function createTurnBoundary(input) {
215
236
  }
216
237
  let boundaryAttachmentBytes = 0;
217
238
  let attachmentsPayload;
218
- const receiptCommits = [];
239
+ const recordSteps = new Map();
240
+ const bundleReceipts = [];
241
+ const carried = (source) => frameCarried(prepared.frameReceipts, source);
219
242
  if ((rs.attach.dateState !== undefined ||
220
243
  rs.attach.instrState !== undefined ||
221
244
  rs.attach.sizeGuidelineState !== undefined ||
@@ -229,7 +252,7 @@ export function createTurnBoundary(input) {
229
252
  const due = [];
230
253
  if (rs.attach.attachState !== undefined) {
231
254
  const attachState = rs.attach.attachState;
232
- const changedFilesOn = Boolean(rs.attach.attachmentsCfg?.changedFiles);
255
+ const changedFilesOn = Boolean(rs.attach.attachmentsCfg?.changedFiles) && !carried("changed_files");
233
256
  let changed;
234
257
  if (changedFilesOn && prepared.detectExternalChanges !== undefined) {
235
258
  const maxFiles = typeof rs.attach.attachmentsCfg?.changedFiles === "object"
@@ -246,10 +269,9 @@ export function createTurnBoundary(input) {
246
269
  rs.attach.attachState.surfacedMtime.delete(p);
247
270
  changed = scan.changed;
248
271
  }
249
- const backgroundTasksOn = (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true;
272
+ const backgroundTasksOn = (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true && !carried("background_tasks");
250
273
  const bgTasks = backgroundTasksOn && rs.attach.attachState.postCompactPending ? prepared.listBackgroundTasks() : undefined;
251
- const toolsDeltaOn = rs.attach.attachmentsCfg?.toolsDelta === true;
252
- let announcedOnceDirty = false;
274
+ const toolsDeltaOn = rs.attach.attachmentsCfg?.toolsDelta === true && !carried("tools_delta");
253
275
  const tdRef = toolsDeltaOn ? prepared.toolsDeltaRef : undefined;
254
276
  const pendingTools = tdRef !== undefined && tdRef.pending.length > 0 ? [...tdRef.pending] : undefined;
255
277
  const pendingRemovedTools = tdRef !== undefined && tdRef.pendingRemoved.length > 0 ? [...tdRef.pendingRemoved] : undefined;
@@ -264,7 +286,7 @@ export function createTurnBoundary(input) {
264
286
  const mcpDelta = prepared.mcp.instructionsDelta;
265
287
  const mcpAdds = mcpInstructionsOn && mcpDelta.pendingAdds.length > 0 ? [...mcpDelta.pendingAdds] : undefined;
266
288
  const mcpRemovals = mcpInstructionsOn && mcpDelta.pendingRemovals.length > 0 ? [...mcpDelta.pendingRemovals] : undefined;
267
- const mcpDropped = mcpInstructionsOn && prepared.mcp.droppedTools.length > 0 ? selectMcpDroppedBatch(prepared.mcp.droppedTools) : undefined;
289
+ const mcpDropped = mcpInstructionsOn && !carried("mcp_dropped_tools") && prepared.mcp.droppedTools.length > 0 ? selectMcpDroppedBatch(prepared.mcp.droppedTools) : undefined;
268
290
  const budgetUsdOn = rs.attach.attachmentsCfg?.budgetUsd === true && rs.budget.maxCostMicroUsd !== undefined;
269
291
  const totalTokensDeclared = rs.attach.attachmentsCfg?.totalTokensReminder;
270
292
  const totalTokensMode = rs.attach.attachmentsCfg?.totalTokensReminderMode ?? TOTAL_TOKENS_REMINDER_DEFAULT_MODE;
@@ -273,11 +295,12 @@ export function createTurnBoundary(input) {
273
295
  totalTokensMode !== "fixed" &&
274
296
  totalTokensMode !== "infinite";
275
297
  const totalTokensOn = totalTokensDeclared === true || totalTokensArmedByDefault;
276
- const toolSearchReminderOn = rs.attach.attachmentsCfg?.toolSearchReminder === true && prepared.deferredToolNames !== undefined;
298
+ const toolSearchReminderOn = rs.attach.attachmentsCfg?.toolSearchReminder === true && prepared.deferredToolNames !== undefined && !carried("tool_search_usage_reminder");
277
299
  const undiscoveredTools = toolSearchReminderOn
278
300
  ? [...prepared.deferredToolNames].filter((n) => !prepared.activeTools.has(n)).sort()
279
301
  : undefined;
280
- const agentListingDue = rs.attach.agentListingOn && prepared.agentListing !== undefined && !frameCarried(prepared.frameReceipts, "agent_listing");
302
+ const agentListingOwed = rs.attach.agentListingOn && prepared.agentListing !== undefined && !frameCarried(prepared.frameReceipts, "agent_listing");
303
+ const offeredListing = !agentListingOwed ? undefined : prepared.modBus.hasHandlers("agent.offer") ? await offeredAgentListing(prepared.modBus, prepared.agentListing, prepared.abortController.signal) : prepared.agentListing;
281
304
  const skillsListingDue = rs.attach.skillsListingOn && prepared.skillsListing !== undefined && !frameCarried(prepared.frameReceipts, "skills_listing");
282
305
  const listingBudget = prepared.skillsListing?.budget ?? prepared.agentListing?.budget;
283
306
  due.push(...collectDueAttachments(rs.attach.attachState, {
@@ -286,7 +309,7 @@ export function createTurnBoundary(input) {
286
309
  todoMounted: todoToolMounted,
287
310
  taskListMounted: taskToolsMounted,
288
311
  config: {
289
- todoReminder: rs.attach.attachmentsCfg?.todoReminder === true,
312
+ todoReminder: rs.attach.attachmentsCfg?.todoReminder === true && !carried("todo_reminder") && !carried("task_reminder"),
290
313
  ...(rs.attach.attachmentsCfg?.todoReminderMode !== undefined ? { todoReminderMode: rs.attach.attachmentsCfg.todoReminderMode } : {}),
291
314
  toolSearchReminder: toolSearchReminderOn,
292
315
  changedFiles: changedFilesOn,
@@ -322,11 +345,11 @@ export function createTurnBoundary(input) {
322
345
  ? { readdedToolsSwappedUnderStatic: pendingReaddedTools.filter((n) => prepared.staticFaceFor?.(n) !== true) }
323
346
  : {}),
324
347
  ...(mcpToolsDelta !== undefined ? { mcpToolsDelta } : {}),
325
- ...(agentListingDue
348
+ ...(offeredListing !== undefined
326
349
  ? {
327
- agentListing: prepared.agentListing.entries,
328
- agentToolName: prepared.agentListing.toolName,
329
- ...(prepared.agentListing.models !== undefined ? { agentModels: prepared.agentListing.models } : {}),
350
+ agentListing: offeredListing.entries,
351
+ agentToolName: offeredListing.toolName,
352
+ ...(offeredListing.models !== undefined ? { agentModels: offeredListing.models } : {}),
330
353
  }
331
354
  : {}),
332
355
  ...(skillsListingDue ? { skillsListing: prepared.skillsListing.entries } : {}),
@@ -336,27 +359,16 @@ export function createTurnBoundary(input) {
336
359
  : {}),
337
360
  ...(mcpDropped !== undefined ? { mcpDroppedTools: mcpDropped } : {}),
338
361
  }));
339
- if (pendingTools !== undefined || mcpToolsDelta !== undefined) {
340
- const exact = renderToolsDelta({
341
- ...(pendingTools !== undefined ? { added: pendingTools } : {}),
342
- ...(prepared.toolMaterializeStatic ? { staticFace: true } : {}),
343
- ...(prepared.toolMaterializeStatic && pendingTools !== undefined
344
- ? { swappedUnderStatic: pendingTools.filter((n) => prepared.staticFaceFor?.(n) !== true) }
345
- : {}),
346
- ...(prepared.toolMaterializeStatic && pendingReaddedTools !== undefined
347
- ? { readdedSwappedUnderStatic: pendingReaddedTools.filter((n) => prepared.staticFaceFor?.(n) !== true) }
348
- : {}),
349
- ...(mcpToolsDelta ?? {}),
350
- });
351
- if (exact !== undefined && due.some((a) => a.source === "tools_delta" && a.body === exact)) {
352
- const ref = prepared.toolsDeltaRef;
362
+ if ((pendingTools !== undefined || mcpToolsDelta !== undefined) && due.some((a) => a.source === "tools_delta")) {
363
+ const ref = prepared.toolsDeltaRef;
364
+ recordSteps.set("tools_delta", () => {
353
365
  if (pendingTools !== undefined)
354
- ref.pending.splice(0, pendingTools.length);
366
+ consumeDelivered(ref.pending, pendingTools);
355
367
  if (pendingRemovedTools !== undefined)
356
- ref.pendingRemoved.splice(0, pendingRemovedTools.length);
368
+ consumeDelivered(ref.pendingRemoved, pendingRemovedTools);
357
369
  if (pendingReaddedTools !== undefined)
358
- ref.pendingReadded.splice(0, pendingReaddedTools.length);
359
- }
370
+ consumeDelivered(ref.pendingReadded, pendingReaddedTools);
371
+ });
360
372
  }
361
373
  if ((mcpAdds !== undefined || mcpRemovals !== undefined) &&
362
374
  due.some((a) => a.source === "mcp_instructions" && a.body === renderMcpInstructionsDelta(mcpAdds ?? [], mcpRemovals ?? []))) {
@@ -365,64 +377,57 @@ export function createTurnBoundary(input) {
365
377
  if (mcpRemovals !== undefined)
366
378
  mcpDelta.pendingRemovals.splice(0, mcpRemovals.length);
367
379
  }
368
- if (mcpDropped !== undefined &&
369
- due.some((a) => a.source === "mcp_dropped_tools" && a.body === renderMcpDroppedTools(mcpDropped))) {
370
- prepared.mcp.droppedTools.splice(0, mcpDropped.length);
371
- if (!noNextRequest()) {
380
+ if (mcpDropped !== undefined && due.some((a) => a.source === "mcp_dropped_tools")) {
381
+ recordSteps.set("mcp_dropped_tools", () => {
382
+ consumeDelivered(prepared.mcp.droppedTools, mcpDropped);
372
383
  prepared.announcedListingsRef.advisories = withAnnounceDigests(prepared.announcedListingsRef.advisories, mcpDropped.map(droppedToolDigest));
373
- announcedOnceDirty = true;
374
- }
384
+ prepared.frameReceipts.listingSnapshotOwed = true;
385
+ });
375
386
  }
376
- if (agentListingDue && due.some((a) => a.source === "agent_listing")) {
377
- const listing = prepared.agentListing;
387
+ if (offeredListing !== undefined && due.some((a) => a.source === "agent_listing")) {
388
+ const listing = offeredListing;
378
389
  const frame = renderAgentListingFrame(attachState, listing.entries, listing.toolName, listing.models, listing.budget);
379
- receiptCommits.push({
380
- source: "agent_listing",
381
- commit: () => {
382
- commitAgentListing(attachState, listing.entries, listing.models);
383
- prepared.announcedListingsRef.agents = listing.entries.map((e) => e.name);
384
- if (listing.models !== undefined)
385
- prepared.announcedListingsRef.models = [...listing.models];
386
- prepared.frameReceipts.listingSnapshotOwed = true;
387
- announceListingTruncation(deps.runner.deps.onNotice, { listing: "agents", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
388
- },
390
+ recordSteps.set("agent_listing", () => {
391
+ commitAgentListing(attachState, listing.entries, listing.models);
392
+ prepared.announcedListingsRef.agents = listing.entries.map((e) => e.name);
393
+ if (listing.models !== undefined)
394
+ prepared.announcedListingsRef.models = [...listing.models];
395
+ prepared.frameReceipts.listingSnapshotOwed = true;
396
+ announceListingTruncation(deps.runner.deps.onNotice, { listing: "agents", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
389
397
  });
390
398
  }
391
399
  if (skillsListingDue && due.some((a) => a.source === "skills_listing")) {
392
400
  const listing = prepared.skillsListing;
393
401
  const frame = renderSkillsListingFrame(attachState, listing.entries, listing.budget);
394
- receiptCommits.push({
395
- source: "skills_listing",
396
- commit: () => {
397
- commitSkillsListing(attachState, listing.entries);
398
- prepared.announcedListingsRef.skills = listing.entries.map((e) => e.name);
399
- prepared.frameReceipts.listingSnapshotOwed = true;
400
- announceListingTruncation(deps.runner.deps.onNotice, { listing: "skills", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
401
- },
402
+ recordSteps.set("skills_listing", () => {
403
+ commitSkillsListing(attachState, listing.entries);
404
+ prepared.announcedListingsRef.skills = listing.entries.map((e) => e.name);
405
+ prepared.frameReceipts.listingSnapshotOwed = true;
406
+ announceListingTruncation(deps.runner.deps.onNotice, { listing: "skills", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
402
407
  });
403
408
  }
404
- if (announcedOnceDirty)
405
- prepared.frameReceipts.listingSnapshotOwed = true;
406
409
  }
407
410
  if (rs.attach.dateState !== undefined && !frameCarried(prepared.frameReceipts, "date_change")) {
408
411
  const today = prepared.dateChange.today();
409
412
  const cand = collectDateChange(rs.attach.dateState, today);
410
413
  if (cand !== undefined) {
411
414
  due.unshift(cand);
412
- receiptCommits.push({ source: "date_change", commit: () => void (rs.attach.dateState.announcedDate = today) });
415
+ recordSteps.set("date_change", () => void (rs.attach.dateState.announcedDate = today));
413
416
  }
414
417
  }
415
- if (rs.attach.sizeGuidelineState !== undefined) {
416
- const guideline = rs.attach.sizeGuidelineState.current();
417
- if (guideline !== rs.attach.sizeGuidelineState.announcedGuideline) {
418
+ if (rs.attach.sizeGuidelineState !== undefined && !carried("workflow_size_guideline_change")) {
419
+ const sizeState = rs.attach.sizeGuidelineState;
420
+ const guideline = sizeState.current();
421
+ if (guideline !== sizeState.announcedGuideline) {
418
422
  due.splice(due.length > 0 && due[0].source === "date_change" ? 1 : 0, 0, {
419
423
  source: "workflow_size_guideline_change",
420
424
  body: workflowSizeGuidelineChangeNotice(guideline),
421
425
  });
422
- rs.attach.sizeGuidelineState.announcedGuideline = guideline;
426
+ recordSteps.set("workflow_size_guideline_change", () => void (sizeState.announcedGuideline = guideline));
423
427
  }
424
428
  }
425
- if (rs.attach.instrState !== undefined && rs.attach.instrProbe !== undefined) {
429
+ if (rs.attach.instrState !== undefined && rs.attach.instrProbe !== undefined && !carried("instructions_change")) {
430
+ const instrState = rs.attach.instrState;
426
431
  let probed = null;
427
432
  try {
428
433
  const PROBE_CEILING_MS = 2_000;
@@ -436,10 +441,10 @@ export function createTurnBoundary(input) {
436
441
  catch {
437
442
  probed = null;
438
443
  }
439
- const cand = collectInstructionsChange(rs.attach.instrState, probed);
444
+ const cand = collectInstructionsChange(instrState, probed);
440
445
  if (cand !== undefined) {
441
446
  due.splice(due.length > 0 && due[0].source === "date_change" ? 1 : 0, 0, cand.attachment);
442
- commitInstructionsChange(rs.attach.instrState, cand.announced);
447
+ recordSteps.set("instructions_change", () => commitInstructionsChange(instrState, cand.announced));
443
448
  }
444
449
  }
445
450
  if (due.length > 0) {
@@ -447,9 +452,16 @@ export function createTurnBoundary(input) {
447
452
  for (const a of due)
448
453
  if (!isIntactSource(a.source))
449
454
  boundaryAttachmentBytes += Buffer.byteLength(a.body, "utf8");
450
- rs.attach.attachmentsInjected += due.length;
451
455
  for (const a of due) {
452
- queue.push({ type: "steering_injected", source: a.source, preview: redactThenCut(a.body, 220), ...ident() });
456
+ const record = a.commit ?? recordSteps.get(a.source);
457
+ bundleReceipts.push({
458
+ source: a.source,
459
+ commit: () => {
460
+ queue.push({ type: "steering_injected", source: a.source, preview: redactThenCut(a.body, 220), ...ident() });
461
+ rs.attach.attachmentsInjected += 1;
462
+ record?.();
463
+ },
464
+ });
453
465
  }
454
466
  }
455
467
  }
@@ -485,7 +497,7 @@ export function createTurnBoundary(input) {
485
497
  }
486
498
  if ((attachmentsPayload !== undefined || batchContextBlock !== undefined) && prepared.batchHaltRef.current === undefined) {
487
499
  const payload = attachmentsPayload !== undefined && batchContextBlock !== undefined ? `${attachmentsPayload}\n${batchContextBlock}` : (attachmentsPayload ?? batchContextBlock);
488
- for (const c of receiptCommits)
500
+ for (const c of bundleReceipts)
489
501
  prepared.frameReceipts.pending.push({ source: c.source, text: payload, commit: c.commit });
490
502
  void prepared.harness.steer(payload, { engineMinted: true }).catch(() => {
491
503
  prepared.frameReceipts.pending = prepared.frameReceipts.pending.filter((r) => r.text !== payload);
@@ -10,6 +10,7 @@ import type { ResumeRun, ResumeTaskConfig, RunInternals, RunnerSelfSeat } from "
10
10
  export type { ResumeTaskConfig } from "./contracts.js";
11
11
  import type { CompactSessionRequest, CompactSessionResult } from "../auto-compaction.js";
12
12
  import type { RewindFilesRequest, RewindFilesResult } from "../file-history-store.js";
13
+ import { type PeerDeclarationHold, type PeerDeclarations } from "../peer-seat.js";
13
14
  /**
14
15
  * A stateless task runner. Holds shared deps (the external brain, model catalog) and an
15
16
  * in-memory session store so that passing a `sessionId` continues a prior conversation.
@@ -76,6 +77,8 @@ export declare class Runner implements RunnerSelfSeat {
76
77
  emitTaskOutcome(outcome: TaskOutcome): void;
77
78
  /** Whether a child this Runner runs can be placed in another tree: {@link RunnerSelfSeat.canRerootChild}. */
78
79
  canRerootChild(): boolean;
80
+ /** A hold of `declared`'s references on this Runner's peer seat: {@link RunnerSelfSeat.holdDeclarations}. A seat member that throws reaches `onError`. */
81
+ holdDeclarations(declared: PeerDeclarations, sessionId?: string): PeerDeclarationHold;
79
82
  /** The deployment agent catalog (RunnerDeps.agents/builtinAgents), exposed READ-ONLY
80
83
  * so the Agent-tool lane (`createSubagentTool`) defaults to the SAME registry the workflow lane
81
84
  * consumes (single source; the types.ts "pass the same array" follow-on made structural). The array
@@ -127,8 +130,8 @@ export declare class Runner implements RunnerSelfSeat {
127
130
  * `undefined` clears an optional seat: `tiers: undefined` ⇒ no bindings, a face seat `undefined` ⇒ the
128
131
  * engine default); a key absent is kept. `tiers` omitted beside `models` ⇒ the current bindings are
129
132
  * re-applied over the new catalog.
130
- * - **Announced per seat.** `config.models_swapped` (models/tiers counts — key material only, never the
131
- * catalog itself) and
133
+ * - **Announced per seat.** `config.models_swapped` (models/tiers counts and the candidate's `generation` — key
134
+ * material only, never the catalog itself) and
132
135
  * `config.read_face_swapped` / `config.write_face_swapped` (`{ from, to, occurrenceId }`, the seat's
133
136
  * previous and new value, `null` = no declaration) — the table {@link SWAP_SEAT_NOTICE} binds every
134
137
  * seat to its line.
@@ -137,7 +140,7 @@ export declare class Runner implements RunnerSelfSeat {
137
140
  /** one-shot brain-routed utility query (see {@link runSideQuery} for the full contract):
138
141
  * preserves system/multi-turn messages/tool DEFINITIONS, routes through the deployment's brain with
139
142
  * the same model resolution as tasks, returns real usage/model. No session, no tool execution, no
140
- * policy gate, no accounting — caller-trusted. */
143
+ * policy gate, no run accounting — caller-trusted; the result's `account` is its engine-priced line for the host's session account. */
141
144
  sideQuery(spec: SideQuerySpec): Promise<SideQueryResult>;
142
145
  /** The out-of-run code-only rewind, no model call and no session entry — the contract is {@link rewindSessionFiles}'s (refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled). */
143
146
  rewindFiles(request: RewindFilesRequest): Promise<RewindFilesResult>;
@@ -246,8 +249,8 @@ export declare class Runner implements RunnerSelfSeat {
246
249
  * registry auto re-supplies them; see `parentConstraintRegistry`). The re-supplied chain's LENGTH must
247
250
  * match the checkpoint's recorded `parentConstraintCount` (`resume.parent_constraint_mismatch`
248
251
  * otherwise). Most entries are policies the deployment authored and can hand straight back; a
249
- * hook-wired ancestor also contributes a PreToolUse SCREENING entry (issue #33) whose policy the
250
- * engine mints — rebuild that one with the exported `createPreToolUseConstraintPolicy(hook, env)`. The DATA half (ancestorRules/shellGate) rides the checkpoint itself and needs no
252
+ * mods-wired ancestor also contributes a SCREENING entry (issue #33), its installation — rebuild that one as
253
+ * `{ installation: await admitModChain(…), hookEnv, …regime }`. The DATA half (ancestorRules/shellGate) rides the checkpoint itself and needs no
251
254
  * re-supply; on the resumed leg the CHECKPOINT snapshot is the trust floor — live internals may only
252
255
  * TIGHTEN it (per-entry rev-monotonic ancestorRules replacement, max-rank shellGate fold), never
253
256
  * displace it wholesale. TRUST BOUNDARY: `internals` is the DEPLOYMENT trust channel (the same tier as
@@ -8,8 +8,8 @@ import { boundInputHashOf } from "../canonical-json.js";
8
8
  import { emitTrace } from "../trace.js";
9
9
  import { emitTaskOutcome } from "../task-outcome.js";
10
10
  import { runWithCapabilityWithheld, runWithReasoningWireFacts } from "../../brain/status-sink.js";
11
- import { expandTiers } from "../roles.js";
12
- import { announceReadDenySwap, screenSwappableDeps } from "../swappable-deps.js";
11
+ import { receiveModelCatalog } from "../roles.js";
12
+ import { announceReadDenySwap, catalogGenerationOf, screenSwappableDeps } from "../swappable-deps.js";
13
13
  import { runSideQuery } from "../side-query.js";
14
14
  import { PushQueue } from "../push-queue.js";
15
15
  import { TtlSessionStore } from "../session-store.js";
@@ -67,6 +67,8 @@ import { deploymentCanRerootChild } from "./child-tree.js";
67
67
  import { rewindSessionFiles } from "./rewind-files.js";
68
68
  import { compactIdleSession } from "./compact-session.js";
69
69
  import { egressThrownText } from "../untrusted-egress.js";
70
+ import { holdPeerDeclarations } from "../peer-seat.js";
71
+ import { receivePeerDeclarations, receivedDeclarations } from "../locked-config.js";
70
72
  export class Runner {
71
73
  deps;
72
74
  sessions;
@@ -86,8 +88,8 @@ export class Runner {
86
88
  const runner = this;
87
89
  this.depsSeat = { get deps() { return runner.deps; } };
88
90
  this.deps = withDeploymentAllowedTools(retained);
89
- if (this.deps.tiers) {
90
- this.deps = { ...this.deps, models: expandTiers(this.deps.models, this.deps.tiers) };
91
+ if (this.deps.models !== undefined || this.deps.tiers !== undefined) {
92
+ this.deps = { ...this.deps, ...receiveModelCatalog(this.deps.models, this.deps.tiers, "RunnerDeps") };
91
93
  }
92
94
  if (this.deps.contextSettings !== undefined) {
93
95
  this.deps = { ...this.deps, contextSettings: assertContextSettingsWords(assertContextSettingsValue(this.deps.contextSettings, "RunnerDeps"), this.deps.models, "RunnerDeps") };
@@ -132,6 +134,9 @@ export class Runner {
132
134
  emitTaskOutcome(this.deps, outcome);
133
135
  }
134
136
  canRerootChild() { return deploymentCanRerootChild(this.deps); }
137
+ holdDeclarations(declared, sessionId) {
138
+ return holdPeerDeclarations(this.deps.peerSeat, declared, (err) => this.deps.onError?.(err, { phase: "config", sessionId: sessionId ?? "(pre-session)", classification: "peer-seat-hold" }));
139
+ }
135
140
  get agentCatalog() {
136
141
  return {
137
142
  ...(this.deps.agents ? { agents: [...this.deps.agents] } : {}),
@@ -180,9 +185,9 @@ export class Runner {
180
185
  let expanded;
181
186
  let tiers;
182
187
  if (catalogSwap) {
183
- const models = candidate.models;
184
- tiers = Object.hasOwn(candidate, "tiers") ? candidate.tiers : this.deps.tiers;
185
- expanded = tiers && Object.keys(tiers).length > 0 ? expandTiers({ ...models }, tiers) : { ...models };
188
+ const generation = receiveModelCatalog(candidate.models, Object.hasOwn(candidate, "tiers") ? candidate.tiers : this.deps.tiers, "swapDeps");
189
+ expanded = generation.models;
190
+ tiers = generation.tiers;
186
191
  }
187
192
  const faceSeats = ["readFace", "writeFace"].filter((seat) => seats.includes(seat));
188
193
  const priorFaces = {
@@ -212,7 +217,7 @@ export class Runner {
212
217
  deliverEngineNotice(this.deps.onNotice, {
213
218
  code: "config.models_swapped",
214
219
  message: `model catalog swapped: ${modelCount} model(s), ${tiers ? Object.keys(tiers).length : 0} tier binding(s); in-flight tasks finish on their resolved models, new tasks resolve against the new catalog`,
215
- detail: { models: modelCount, tiers: tiers ? Object.keys(tiers).length : 0, occurrenceId: uuidv7() },
220
+ detail: { models: modelCount, tiers: tiers ? Object.keys(tiers).length : 0, generation: catalogGenerationOf(candidate.models, tiers), occurrenceId: uuidv7() },
216
221
  });
217
222
  }
218
223
  if (seats.includes("contextSettings")) {
@@ -239,7 +244,7 @@ export class Runner {
239
244
  announceReadDenySwap(this.deps.onNotice, seats, this.deps);
240
245
  }
241
246
  sideQuery(spec) {
242
- return runWithReasoningWireFacts(() => { }, () => runWithCapabilityWithheld(() => { }, () => runSideQuery(spec, { brain: this.deps.brain, models: this.deps.models, roles: this.deps.roles })));
247
+ return runWithReasoningWireFacts(() => { }, () => runWithCapabilityWithheld(() => { }, () => runSideQuery(spec, { brain: this.deps.brain, models: this.deps.models, roles: this.deps.roles, pricing: this.deps.pricing })));
243
248
  }
244
249
  rewindFiles(request) { return rewindSessionFiles({ deps: this.deps, sessions: this.sessions, readStates: this.sessionReadStates, ...this.verbLockSeats }, request); }
245
250
  compactSession(request) { return compactIdleSession({ deps: this.deps, sessions: this.sessions, ...this.verbLockSeats }, request); }
@@ -291,6 +296,8 @@ export class Runner {
291
296
  };
292
297
  const namedSessionId = spec.sessionId;
293
298
  const legWrites = this.sessionWrites.openLeg((err, sessionId) => this.deps.onError?.(err, { phase: "degraded", sessionId }));
299
+ const receivedPeers = receivePeerDeclarations(spec, this.deps);
300
+ const declarationHold = this.holdDeclarations(receivedDeclarations(receivedPeers), namedSessionId);
294
301
  const run = (async () => {
295
302
  try {
296
303
  if (namedSessionId)
@@ -333,7 +340,7 @@ export class Runner {
333
340
  manualCompactRef,
334
341
  taskIdRef,
335
342
  resume,
336
- internals: { ...(internals ?? {}), detachHub, forwardScope: createForwardSinkScope(this.deps.onNotice) },
343
+ internals: { ...(internals ?? {}), detachHub, forwardScope: createForwardSinkScope(this.deps.onNotice), receivedPeers },
337
344
  notifyRef,
338
345
  captureOptOutRef,
339
346
  mcpRedialRef,
@@ -363,6 +370,7 @@ export class Runner {
363
370
  locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
364
371
  }).onRunRejected);
365
372
  void settled.then(() => acceptedSteerInputs.clear(), () => acceptedSteerInputs.clear());
373
+ void settled.then(() => declarationHold.release(), () => declarationHold.release());
366
374
  const { reapSuspended } = streamReap({
367
375
  live, runner: this.depsSeat,
368
376
  locallyClaimedTokens: this.locallyClaimedTokens, parentConstraintRegistry: this.parentConstraintRegistry, suspendedEnvReaps: this.suspendedEnvReaps,
@@ -399,7 +407,7 @@ export class Runner {
399
407
  spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites,
400
408
  runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, pendingSessionNotifications: this.pendingSessionNotifications,
401
409
  prepareTask,
402
- next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications }) => {
410
+ next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations }) => {
403
411
  const { runSourceTaskId, parentToolCallId, ident, emitDelegationLifecycle, loopLatch, stats, internalsNotifier, undrainedUserAtEnd, userInputLostAtEnd } = runIdentityWiring({
404
412
  spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef,
405
413
  notificationLane, pendingSessionNotifications: this.pendingSessionNotifications, runner: this.depsSeat,
@@ -433,7 +441,7 @@ export class Runner {
433
441
  },
434
442
  });
435
443
  const { compactionBrain, withinTaskCompaction, compactionBreaker, windowSafetyOptions } = runCompactionMachinery({ spec, prepared, rs, stats, noteUnevaluablePriceTable, modelCatalog, runner: this.depsSeat });
436
- runStopAndFinalVerify({ spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, runner: this.depsSeat });
444
+ runStopAndFinalVerify({ spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, runner: this.depsSeat });
437
445
  runRecoveryLanes({ spec, prepared, queue, rs, ident, compactionBrain, compactionBreaker, windowSafetyOptions, callerStop: loopLatch.callerStop, runner: this.depsSeat });
438
446
  const rapidRefill = createRapidRefillState();
439
447
  const drainManualCompact = (outcome) => {
@@ -454,7 +462,7 @@ export class Runner {
454
462
  });
455
463
  const { flushGitMirror, unsubGitRetry, unsubBoundary, unsub } = runGitLane({ prepared, queue, rs, ident, onMessageUpdate, onMessageEnd, onToolStart, onToolEnd, onTurnEnd, onTurnBoundary, runner: this.depsSeat });
456
464
  return withLegRequestSinks(() => runLeg({
457
- spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds,
465
+ spec, queue, prepared, resume, rs, entryActor, operatorObjective: internals?.operatorObjective === true, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds,
458
466
  announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub,
459
467
  runner: this.depsSeat,
460
468
  next: ({ final, threw, abortedLive, userInterruptedLive, strandedHumanAnswers }) => runTerminalAdoption({
@@ -6,7 +6,7 @@
6
6
  * fence, so another lane is a row here, not a second accounting function.
7
7
  */
8
8
  import type { AssistantMessageDiagnostic, Model, Usage } from "../../internal/llm.js";
9
- import { type ModelPricing } from "../pricing.js";
9
+ import type { ModelPricing } from "../pricing.js";
10
10
  import type { AssertAllKeysHandled } from "../ask-origin.js";
11
11
  import type { Brain, RunnerDeps, TaskSpec } from "../types.js";
12
12
  import type { Stats } from "./assemble-result.js";
@@ -1,38 +1,23 @@
1
1
  import { readDegradation } from "../../brain/degrading.js";
2
2
  import { runWithReasoningWireFacts, runWithStatusSink } from "../../brain/status-sink.js";
3
- import { isModelPriced, modelCostToPricing } from "../pricing.js";
4
3
  import { emitTrace } from "../trace.js";
5
- import { cacheFamilyOf, usageCostMicroUsd } from "./usage-accounting.js";
4
+ import { priceReply } from "./reply-pricing.js";
6
5
  export const SIDE_CALL_LANE_TOTAL = {
7
6
  compaction: "compactionMicroUsd",
8
7
  classifier: "sideCallMicroUsd",
9
8
  mod: "sideCallMicroUsd",
10
9
  advisor: "sideCallMicroUsd",
11
10
  };
12
- function catalogModel(id, catalog) {
13
- if (catalog === undefined)
14
- return undefined;
15
- for (const m of Object.values(catalog))
16
- if (m.id === id)
17
- return m;
18
- return Object.hasOwn(catalog, id) ? catalog[id] : undefined;
19
- }
20
11
  export function recordSideCallUsage(stats, usage, lane, call) {
21
12
  if (usage === undefined || call.usageMissing === true)
22
13
  stats.usageMissing = true;
23
14
  if (usage === undefined)
24
15
  return;
25
- const { model: requested, account } = call;
26
- const pricing = account.pricing();
27
- const served = call.servedBy === undefined ? requested : catalogModel(call.servedBy, account.catalog);
28
- const modelId = served?.id ?? call.servedBy ?? requested.id;
29
- const price = pricing?.[modelId] ?? modelCostToPricing(served?.cost);
30
- const priced = served !== undefined ? isModelPriced(served, pricing) : pricing?.[modelId] !== undefined;
16
+ const { account } = call;
17
+ const { modelId, served, price, priced, totalInputTokens, uncachedInputTokens, costMicroUsd } = priceReply(usage, call, { pricing: account.pricing(), catalog: account.catalog });
31
18
  if (!priced)
32
19
  account.telemetry.unpricedSpend = true;
33
20
  account.noteUnevaluablePriceTable(price);
34
- const family = served !== undefined ? cacheFamilyOf(served) : "input-excludes-cached";
35
- const { totalInputTokens, uncachedInputTokens, costMicroUsd } = usageCostMicroUsd(family, usage, price);
36
21
  stats.tokens += usage.totalTokens || 0;
37
22
  stats.promptTokens += uncachedInputTokens;
38
23
  stats.totalInputTokens += totalInputTokens;
@@ -1,5 +1,5 @@
1
1
  import { readSkillTable } from "../skill-grant.js";
2
- import { assertNoRetiredKeys, RETIRED_TASK_SPEC_KEYS } from "../retired-keys.js";
2
+ import { assertNoRetiredKeys, RETIRED_SKILLS_SEAT_KEYS } from "../retired-keys.js";
3
3
  import { skillBaseDirOf } from "./skill-base-dir.js";
4
4
  const SKILLS_SEAT = "TaskSpec.skills";
5
5
  const kindOf = (v) => (v === null ? "null" : Array.isArray(v) ? "an array" : typeof v);
@@ -32,7 +32,7 @@ export function readSkillsSeat(skills) {
32
32
  return [];
33
33
  if (!Array.isArray(skills))
34
34
  throw skillsSeatRefusal(SKILLS_SEAT, `must be a list (got ${kindOf(skills)})`);
35
- assertNoRetiredKeys({ skills }, RETIRED_TASK_SPEC_KEYS, "TaskSpec");
35
+ assertNoRetiredKeys({ skills }, RETIRED_SKILLS_SEAT_KEYS, "TaskSpec");
36
36
  const seen = new Set();
37
37
  const out = [];
38
38
  for (const [i, raw] of skills.entries()) {
@@ -79,6 +79,30 @@ export declare function delegationPoolReading(callerTools: NonNullable<TaskSpec[
79
79
  * ({@link CheckpointErrorReason}): a list the row recorded that is not a list / has a member that is not a string / has a spelling no tool name can have / is not in the
80
80
  * spelling a row records, a record that is not one, a renamed delegation mount, an occupied table of declared names. */
81
81
  export type PersistedToolFaceReason = Extract<CheckpointErrorReason, "not_a_list" | "not_a_string" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied">;
82
+ /** The code of the policy-name refusal — the one spelling its mint and every problem it lists carry. */
83
+ export declare const POLICY_NAME_REFUSAL_CODE = "config.legacy_tool_name";
84
+ /** The layers the prepare-time policy-name audit reads, by the words the trace already gives the first: the run's own policy
85
+ * (`caller_policy`), the stored rules of its session, and the rules an ancestor's session handed it. */
86
+ export type PolicyNameLayer = "caller_policy" | "session_rules" | "ancestor_session_rules";
87
+ /** One entry the policy-name audit refuses, in the shape the entry problems of a rejection body are minted in (code · field ·
88
+ * entry · reason, the engine entry reading's words) plus the layer it sits in: `field` is the policy list (`deny` / `ask` /
89
+ * `allow`), `reason` the name judgment's verdict word (`near_miss` for another spelling of a carried name). */
90
+ export interface PolicyNameProblem {
91
+ readonly code: typeof POLICY_NAME_REFUSAL_CODE;
92
+ readonly field: "deny" | "ask" | "allow";
93
+ readonly entry: string;
94
+ readonly reason: "retired" | "unprefixed_namespace" | "unmintable_segment" | "near_miss";
95
+ readonly layer: PolicyNameLayer;
96
+ }
97
+ /** A refused entry with the sentence that names it. */
98
+ export interface PolicyNameFinding {
99
+ readonly message: string;
100
+ readonly problem: PolicyNameProblem;
101
+ }
102
+ /** The refusal of a policy layer whose name lists hold entries that reach no tool ({@link POLICY_NAME_REFUSAL_CODE}): the sentence is
103
+ * the first entry's, `detail.problems` lists the refused entries of the layer in scan order (within the bounds above), `detail.total`
104
+ * counts every one. */
105
+ export declare function policyNameRefusal(first: PolicyNameFinding, more: readonly PolicyNameFinding[]): Error;
82
106
  /**
83
107
  * The names a definition's denied-tools entries stand for, for a lane that has neither a roster nor a notice sink at the point
84
108
  * it builds its own policy (a workflow leg's agentType): each entry is read by the one reading, so `Tool(content)` denies the