@sema-agent/core 7.59.0 → 7.61.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 (643) hide show
  1. package/CHANGELOG.md +1169 -0
  2. package/README.md +2 -2
  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 +4 -3
  6. package/dist/agents/agent-transcript-tool.js +4 -2
  7. package/dist/agents/cascade.d.ts +61 -10
  8. package/dist/agents/cascade.js +60 -20
  9. package/dist/agents/child-model-seat.js +6 -3
  10. package/dist/agents/composition-allowance.d.ts +53 -0
  11. package/dist/agents/composition-allowance.js +49 -0
  12. package/dist/agents/composition-placement.d.ts +29 -0
  13. package/dist/agents/composition-placement.js +24 -0
  14. package/dist/agents/cumulative-stats.d.ts +4 -0
  15. package/dist/agents/cumulative-stats.js +3 -1
  16. package/dist/agents/inherited-tool-pool.d.ts +28 -1
  17. package/dist/agents/inherited-tool-pool.js +22 -0
  18. package/dist/agents/list-agents-tool.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.d.ts +1 -1
  20. package/dist/agents/peer-notice-route.js +4 -3
  21. package/dist/agents/peer-notices.d.ts +4 -4
  22. package/dist/agents/peer-notices.js +8 -4
  23. package/dist/agents/peer-session-drain.d.ts +8 -1
  24. package/dist/agents/peer-session-drain.js +36 -7
  25. package/dist/agents/repair-loop.js +16 -6
  26. package/dist/agents/retain-ledger.d.ts +11 -1
  27. package/dist/agents/retain-ledger.js +16 -3
  28. package/dist/agents/roster-store.d.ts +2 -2
  29. package/dist/agents/roster-store.js +8 -3
  30. package/dist/agents/send-message-tool.d.ts +14 -27
  31. package/dist/agents/send-message-tool.js +47 -54
  32. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  33. package/dist/agents/subagent-completion-gate.js +62 -0
  34. package/dist/agents/subagent-steps.d.ts +7 -6
  35. package/dist/agents/subagent.d.ts +52 -28
  36. package/dist/agents/subagent.js +276 -246
  37. package/dist/agents/suspend-guard.d.ts +9 -0
  38. package/dist/agents/suspend-guard.js +4 -0
  39. package/dist/agents/tool-filter.d.ts +1 -3
  40. package/dist/agents/tool-filter.js +4 -12
  41. package/dist/agents/verify.d.ts +41 -14
  42. package/dist/agents/verify.js +37 -27
  43. package/dist/bench/metrics.d.ts +3 -5
  44. package/dist/bench/metrics.js +0 -1
  45. package/dist/brain/anthropic.js +1 -0
  46. package/dist/brain/degrading.js +3 -1
  47. package/dist/brain/errors.d.ts +7 -1
  48. package/dist/brain/errors.js +6 -0
  49. package/dist/brain/failover.js +2 -1
  50. package/dist/brain/open-responses.js +1 -0
  51. package/dist/brain/openai.js +1 -0
  52. package/dist/brain/provider-dialect.d.ts +10 -0
  53. package/dist/brain/provider-dialect.js +13 -2
  54. package/dist/brain/route-adjudicator.js +3 -1
  55. package/dist/brain/status-sink.d.ts +7 -1
  56. package/dist/brain/status-sink.js +6 -0
  57. package/dist/brain/stream-engine.d.ts +3 -0
  58. package/dist/brain/stream-engine.js +4 -0
  59. package/dist/brain/timeout.d.ts +3 -1
  60. package/dist/brain/timeout.js +18 -5
  61. package/dist/core/a2a.d.ts +15 -5
  62. package/dist/core/a2a.js +34 -19
  63. package/dist/core/agent-definition.d.ts +20 -0
  64. package/dist/core/agent-state.d.ts +1 -1
  65. package/dist/core/allow-entry.d.ts +61 -23
  66. package/dist/core/allow-entry.js +134 -39
  67. package/dist/core/artifact-host.d.ts +0 -2
  68. package/dist/core/artifact-host.js +0 -1
  69. package/dist/core/ask-origin.d.ts +79 -0
  70. package/dist/core/ask-origin.js +76 -0
  71. package/dist/core/ask-question.d.ts +19 -13
  72. package/dist/core/ask-question.js +8 -2
  73. package/dist/core/auto-compaction.d.ts +2 -0
  74. package/dist/core/auto-compaction.js +2 -1
  75. package/dist/core/auto-mode-defaults.d.ts +8 -0
  76. package/dist/core/auto-mode-defaults.js +1 -0
  77. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  78. package/dist/core/auto-mode.d.ts +39 -4
  79. package/dist/core/auto-mode.js +66 -17
  80. package/dist/core/background-agent-store.d.ts +17 -6
  81. package/dist/core/background-agent-store.js +15 -13
  82. package/dist/core/background-shell.d.ts +12 -1
  83. package/dist/core/background-shell.js +12 -0
  84. package/dist/core/checkpoint-requirements.d.ts +24 -3
  85. package/dist/core/checkpoint-requirements.js +9 -1
  86. package/dist/core/checkpoint-store.d.ts +86 -32
  87. package/dist/core/checkpoint-store.js +10 -5
  88. package/dist/core/child-clamp-seats.d.ts +3 -2
  89. package/dist/core/child-clamp-seats.js +4 -3
  90. package/dist/core/closest-name.d.ts +13 -0
  91. package/dist/core/closest-name.js +35 -0
  92. package/dist/core/compliance.d.ts +1 -1
  93. package/dist/core/context-settings.js +3 -5
  94. package/dist/core/credential-echo.d.ts +52 -0
  95. package/dist/core/credential-echo.js +65 -0
  96. package/dist/core/credential-vocabulary.d.ts +13 -3
  97. package/dist/core/credential-vocabulary.js +12 -4
  98. package/dist/core/cross-boundary-taint.d.ts +5 -6
  99. package/dist/core/decision-receipt.d.ts +14 -1
  100. package/dist/core/decision-receipt.js +6 -3
  101. package/dist/core/delegation-frames.d.ts +13 -9
  102. package/dist/core/effective-path-target.js +2 -3
  103. package/dist/core/engine-attestation.d.ts +11 -1
  104. package/dist/core/engine-attestation.js +2 -0
  105. package/dist/core/engine-notice.d.ts +106 -32
  106. package/dist/core/file-history-retention.d.ts +8 -0
  107. package/dist/core/file-history-retention.js +14 -11
  108. package/dist/core/file-history-store.d.ts +31 -1
  109. package/dist/core/file-history-store.js +31 -2
  110. package/dist/core/frame-settlement.d.ts +15 -0
  111. package/dist/core/frame-settlement.js +10 -1
  112. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  113. package/dist/core/fs-write-gate-policy.js +8 -7
  114. package/dist/core/gate-fold.js +9 -6
  115. package/dist/core/gate-lanes.js +46 -12
  116. package/dist/core/gate-outcome.d.ts +40 -1
  117. package/dist/core/gate-outcome.js +10 -0
  118. package/dist/core/git-worktree-env.d.ts +7 -3
  119. package/dist/core/git-worktree-env.js +16 -13
  120. package/dist/core/governance-codes.d.ts +19 -3
  121. package/dist/core/governance-codes.js +27 -3
  122. package/dist/core/hands-band-screen.js +0 -1
  123. package/dist/core/hands-band.d.ts +0 -3
  124. package/dist/core/hooks.d.ts +51 -60
  125. package/dist/core/hooks.js +131 -78
  126. package/dist/core/host-floor.js +3 -5
  127. package/dist/core/image-admission.d.ts +145 -52
  128. package/dist/core/image-admission.js +202 -47
  129. package/dist/core/image-downsample.d.ts +36 -69
  130. package/dist/core/image-downsample.js +111 -73
  131. package/dist/core/input-author.d.ts +36 -0
  132. package/dist/core/input-author.js +39 -0
  133. package/dist/core/integer-option.d.ts +21 -0
  134. package/dist/core/integer-option.js +13 -0
  135. package/dist/core/leg-identity.d.ts +62 -0
  136. package/dist/core/leg-identity.js +18 -0
  137. package/dist/core/locked-config.d.ts +55 -3
  138. package/dist/core/locked-config.js +84 -51
  139. package/dist/core/lsp.d.ts +5 -3
  140. package/dist/core/lsp.js +3 -2
  141. package/dist/core/mailbox-store.d.ts +85 -10
  142. package/dist/core/mailbox-store.js +31 -10
  143. package/dist/core/mcp-call-meta.d.ts +2 -2
  144. package/dist/core/mcp-call-meta.js +9 -10
  145. package/dist/core/mcp-connection-pool.d.ts +6 -20
  146. package/dist/core/mcp-connection-pool.js +10 -28
  147. package/dist/core/mcp-failure.d.ts +83 -16
  148. package/dist/core/mcp-failure.js +67 -30
  149. package/dist/core/mcp-host-seat.d.ts +131 -0
  150. package/dist/core/mcp-host-seat.js +305 -0
  151. package/dist/core/mcp-probe.d.ts +7 -2
  152. package/dist/core/mcp-probe.js +9 -4
  153. package/dist/core/mcp-server-link.d.ts +18 -6
  154. package/dist/core/mcp-server-link.js +19 -4
  155. package/dist/core/mcp-server-spec.d.ts +39 -9
  156. package/dist/core/mcp-server-spec.js +55 -21
  157. package/dist/core/mcp-session-end.d.ts +1 -2
  158. package/dist/core/mcp-session-end.js +1 -1
  159. package/dist/core/mcp.d.ts +23 -55
  160. package/dist/core/mcp.js +172 -156
  161. package/dist/core/media-byte-cap.d.ts +21 -46
  162. package/dist/core/media-byte-cap.js +55 -55
  163. package/dist/core/member-group.d.ts +7 -0
  164. package/dist/core/member-group.js +35 -0
  165. package/dist/core/memory-admission.d.ts +23 -6
  166. package/dist/core/memory-admission.js +19 -9
  167. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  168. package/dist/core/memory-engine/consolidation.js +7 -1
  169. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  170. package/dist/core/memory-engine/content-origin.js +21 -3
  171. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  172. package/dist/core/memory-engine/dual-root.js +59 -11
  173. package/dist/core/memory-engine/engine.js +27 -24
  174. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  175. package/dist/core/memory-engine/file-backend.js +35 -15
  176. package/dist/core/memory-engine/index.d.ts +2 -1
  177. package/dist/core/memory-engine/index.js +2 -1
  178. package/dist/core/memory-engine/layout.d.ts +3 -0
  179. package/dist/core/memory-engine/layout.js +13 -3
  180. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  181. package/dist/core/memory-engine/memory-deployment.js +182 -0
  182. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  183. package/dist/core/memory-engine/scope-contract.js +2 -2
  184. package/dist/core/memory-engine/sync-client.d.ts +68 -13
  185. package/dist/core/memory-engine/sync-client.js +147 -18
  186. package/dist/core/memory-engine/sync-report.d.ts +106 -0
  187. package/dist/core/memory-engine/sync-report.js +119 -0
  188. package/dist/core/memory-engine/sync.d.ts +13 -3
  189. package/dist/core/mode-policy.d.ts +15 -7
  190. package/dist/core/mode-policy.js +18 -6
  191. package/dist/core/model-receipt.d.ts +39 -0
  192. package/dist/core/model-receipt.js +139 -0
  193. package/dist/core/mods/agent-stations.d.ts +100 -0
  194. package/dist/core/mods/agent-stations.js +154 -0
  195. package/dist/core/mods/dollar.d.ts +62 -0
  196. package/dist/core/mods/extension-call.d.ts +15 -1
  197. package/dist/core/mods/extension-call.js +7 -2
  198. package/dist/core/mods/kernel/dispatch.d.ts +9 -4
  199. package/dist/core/mods/kernel/dispatch.js +8 -8
  200. package/dist/core/mods/kernel/events.d.ts +13 -4
  201. package/dist/core/mods/kernel/events.js +14 -10
  202. package/dist/core/mods/kernel/receive.d.ts +5 -0
  203. package/dist/core/mods/kernel/receive.js +10 -0
  204. package/dist/core/mods/kernel/registration.d.ts +3 -0
  205. package/dist/core/mods/kernel/registration.js +5 -0
  206. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  207. package/dist/core/mods/kernel/site-rules.js +10 -2
  208. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  209. package/dist/core/mods/lifecycle-stations.js +35 -0
  210. package/dist/core/mods/session-append.d.ts +115 -0
  211. package/dist/core/mods/session-append.js +311 -0
  212. package/dist/core/mods/session-compact.d.ts +48 -0
  213. package/dist/core/mods/session-compact.js +194 -0
  214. package/dist/core/mods/session-receive.d.ts +93 -0
  215. package/dist/core/mods/session-receive.js +141 -0
  216. package/dist/core/mods/session-send.d.ts +72 -0
  217. package/dist/core/mods/session-send.js +88 -0
  218. package/dist/core/mods/stations.d.ts +89 -75
  219. package/dist/core/mods/stations.js +57 -53
  220. package/dist/core/mods/tool-call.d.ts +12 -4
  221. package/dist/core/mods/tool-call.js +32 -16
  222. package/dist/core/mounted-mcp.d.ts +5 -0
  223. package/dist/core/mounted-mcp.js +2 -2
  224. package/dist/core/namespaced-rule-name.d.ts +7 -1
  225. package/dist/core/namespaced-rule-name.js +13 -2
  226. package/dist/core/oracle-isolation.js +1 -1
  227. package/dist/core/output-style.js +3 -4
  228. package/dist/core/own-property-receipt.d.ts +62 -0
  229. package/dist/core/own-property-receipt.js +43 -0
  230. package/dist/core/park-selfcheck.js +12 -10
  231. package/dist/core/path-identity.d.ts +11 -0
  232. package/dist/core/path-identity.js +4 -0
  233. package/dist/core/path-rule-binding.d.ts +3 -1
  234. package/dist/core/path-rule-binding.js +3 -1
  235. package/dist/core/peer-seat.d.ts +66 -11
  236. package/dist/core/peer-seat.js +199 -42
  237. package/dist/core/permission-rule-consent.d.ts +21 -26
  238. package/dist/core/permission-rule-consent.js +22 -3
  239. package/dist/core/permission-rule-model.d.ts +38 -13
  240. package/dist/core/permission-rule-model.js +54 -16
  241. package/dist/core/permission-rule-org.d.ts +1 -1
  242. package/dist/core/permission-rule-provider.js +4 -1
  243. package/dist/core/permission-rules.d.ts +4 -0
  244. package/dist/core/permission-rules.js +11 -16
  245. package/dist/core/protocol-http-auth.d.ts +14 -2
  246. package/dist/core/protocol-http-auth.js +16 -7
  247. package/dist/core/read-face-seats.d.ts +7 -5
  248. package/dist/core/read-face-seats.js +4 -1
  249. package/dist/core/redaction-marks.d.ts +4 -3
  250. package/dist/core/redaction-marks.js +2 -2
  251. package/dist/core/remote-env.d.ts +218 -122
  252. package/dist/core/remote-env.js +133 -14
  253. package/dist/core/retention-policy.d.ts +24 -23
  254. package/dist/core/retention-policy.js +36 -2
  255. package/dist/core/retention.d.ts +4 -1
  256. package/dist/core/retention.js +37 -12
  257. package/dist/core/retired-keys.d.ts +8 -3
  258. package/dist/core/retired-keys.js +4 -1
  259. package/dist/core/rewrite-rejudge.d.ts +12 -5
  260. package/dist/core/rewrite-rejudge.js +9 -5
  261. package/dist/core/roles.d.ts +37 -3
  262. package/dist/core/roles.js +126 -78
  263. package/dist/core/row-admission.d.ts +10 -0
  264. package/dist/core/row-admission.js +5 -0
  265. package/dist/core/rule-owner.d.ts +3 -0
  266. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  267. package/dist/core/runner/advisor-instructions.js +2 -1
  268. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  269. package/dist/core/runner/assemble-result.d.ts +13 -8
  270. package/dist/core/runner/assemble-result.js +12 -8
  271. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  272. package/dist/core/runner/call-hook-stations.js +21 -10
  273. package/dist/core/runner/caller-roster.d.ts +12 -9
  274. package/dist/core/runner/caller-roster.js +5 -2
  275. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  276. package/dist/core/runner/checkpoint-scope.js +21 -0
  277. package/dist/core/runner/child-tree.d.ts +7 -8
  278. package/dist/core/runner/child-tree.js +6 -6
  279. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  280. package/dist/core/runner/classifier-ladder.js +39 -8
  281. package/dist/core/runner/compact-session.js +14 -2
  282. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  283. package/dist/core/runner/compaction-restate.d.ts +2 -2
  284. package/dist/core/runner/compaction-restate.js +4 -3
  285. package/dist/core/runner/construction-doors.d.ts +2 -2
  286. package/dist/core/runner/construction-doors.js +7 -2
  287. package/dist/core/runner/contracts.d.ts +158 -65
  288. package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
  289. package/dist/core/runner/cross-boundary-lane.js +11 -2
  290. package/dist/core/runner/decide-continuation.d.ts +4 -2
  291. package/dist/core/runner/decide-continuation.js +7 -4
  292. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  293. package/dist/core/runner/denial-limit-arms.js +17 -10
  294. package/dist/core/runner/env-capability-census.d.ts +15 -20
  295. package/dist/core/runner/env-capability-census.js +25 -34
  296. package/dist/core/runner/expire-settle.d.ts +44 -0
  297. package/dist/core/runner/expire-settle.js +55 -0
  298. package/dist/core/runner/file-history-request.d.ts +2 -2
  299. package/dist/core/runner/file-history-request.js +0 -8
  300. package/dist/core/runner/gate-exit.d.ts +75 -7
  301. package/dist/core/runner/gate-exit.js +20 -1
  302. package/dist/core/runner/git-status-frame.d.ts +5 -2
  303. package/dist/core/runner/git-status-frame.js +4 -4
  304. package/dist/core/runner/halt-attribution.d.ts +2 -1
  305. package/dist/core/runner/halt-attribution.js +2 -1
  306. package/dist/core/runner/image.d.ts +7 -2
  307. package/dist/core/runner/image.js +14 -8
  308. package/dist/core/runner/inline-image.d.ts +10 -8
  309. package/dist/core/runner/inline-image.js +11 -9
  310. package/dist/core/runner/local-claims.d.ts +17 -0
  311. package/dist/core/runner/local-claims.js +18 -0
  312. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  313. package/dist/core/runner/media-removed-seat.js +88 -0
  314. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  315. package/dist/core/runner/park-commit.d.ts +2 -2
  316. package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
  317. package/dist/core/runner/permission-rule-lanes.js +29 -10
  318. package/dist/core/runner/person-path-rows.js +1 -1
  319. package/dist/core/runner/placement-fence.d.ts +26 -0
  320. package/dist/core/runner/placement-fence.js +38 -0
  321. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  322. package/dist/core/runner/prepare-ask-lane.js +4 -4
  323. package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
  324. package/dist/core/runner/prepare-boundary-parks.js +4 -4
  325. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
  326. package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
  327. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  328. package/dist/core/runner/prepare-config-doors.js +30 -26
  329. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  330. package/dist/core/runner/prepare-context-lane.js +13 -13
  331. package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
  332. package/dist/core/runner/prepare-delegation-surface.js +7 -8
  333. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  334. package/dist/core/runner/prepare-execution-env.js +7 -4
  335. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  336. package/dist/core/runner/prepare-file-history.js +3 -12
  337. package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
  338. package/dist/core/runner/prepare-gate-stations.js +10 -7
  339. package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
  340. package/dist/core/runner/prepare-hands-readface.js +19 -11
  341. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  342. package/dist/core/runner/prepare-inherited-gate.js +12 -5
  343. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  344. package/dist/core/runner/prepare-lsp.js +2 -2
  345. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  346. package/dist/core/runner/prepare-memory.d.ts +2 -2
  347. package/dist/core/runner/prepare-memory.js +2 -2
  348. package/dist/core/runner/prepare-park-ask.d.ts +8 -7
  349. package/dist/core/runner/prepare-park-ask.js +6 -12
  350. package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
  351. package/dist/core/runner/prepare-policy-chain.js +131 -128
  352. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  353. package/dist/core/runner/prepare-project-context.js +8 -5
  354. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
  355. package/dist/core/runner/prepare-prompt-inputs.js +4 -2
  356. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  357. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  358. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  359. package/dist/core/runner/prepare-question-face.js +2 -2
  360. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  361. package/dist/core/runner/prepare-run-refs.js +2 -2
  362. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
  363. package/dist/core/runner/prepare-suspend-saga.js +21 -13
  364. package/dist/core/runner/prepare-task.d.ts +1 -1
  365. package/dist/core/runner/prepare-task.js +84 -42
  366. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  367. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  368. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  369. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  370. package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
  371. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  372. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  373. package/dist/core/runner/prepare-workspace-restore.js +12 -8
  374. package/dist/core/runner/read-root-grant.d.ts +1 -1
  375. package/dist/core/runner/read-root-grant.js +2 -1
  376. package/dist/core/runner/resume-admission.d.ts +5 -3
  377. package/dist/core/runner/resume-admission.js +17 -3
  378. package/dist/core/runner/resume-apply.js +3 -1
  379. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  380. package/dist/core/runner/resume-claim.d.ts +8 -3
  381. package/dist/core/runner/resume-claim.js +28 -12
  382. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  383. package/dist/core/runner/resume-internals-and-config.js +10 -1
  384. package/dist/core/runner/resume-preflight.d.ts +3 -2
  385. package/dist/core/runner/resume-preflight.js +13 -26
  386. package/dist/core/runner/retired-runner-deps.js +6 -1
  387. package/dist/core/runner/run-attachment-seats.js +3 -3
  388. package/dist/core/runner/run-brain-sinks.js +1 -0
  389. package/dist/core/runner/run-git-lane.d.ts +3 -1
  390. package/dist/core/runner/run-git-lane.js +3 -2
  391. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  392. package/dist/core/runner/run-harness-handlers.js +5 -3
  393. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  394. package/dist/core/runner/run-identity-wiring.js +15 -6
  395. package/dist/core/runner/run-leg.d.ts +3 -3
  396. package/dist/core/runner/run-leg.js +65 -56
  397. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  398. package/dist/core/runner/run-notification-lane.js +36 -12
  399. package/dist/core/runner/run-recovery-lanes.js +3 -2
  400. package/dist/core/runner/run-settle-and-teardown.js +14 -8
  401. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  402. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  403. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  404. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  405. package/dist/core/runner/run-terminal-adoption.js +26 -17
  406. package/dist/core/runner/run-turn-boundary.js +37 -19
  407. package/dist/core/runner/runtask.d.ts +25 -7
  408. package/dist/core/runner/runtask.js +46 -22
  409. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  410. package/dist/core/runner/session-rule-policy.js +6 -1
  411. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  412. package/dist/core/runner/skills-seat.js +2 -2
  413. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  414. package/dist/core/runner/stream-halt-verbs.js +4 -3
  415. package/dist/core/runner/stream-reap.d.ts +7 -6
  416. package/dist/core/runner/stream-reap.js +13 -16
  417. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  418. package/dist/core/runner/stream-settle-backstop.js +5 -3
  419. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  420. package/dist/core/runner/stream-steer-verb.js +8 -7
  421. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  422. package/dist/core/runner/synthetic-tools.js +2 -2
  423. package/dist/core/runner/terminal-account.d.ts +11 -1
  424. package/dist/core/runner/terminal-account.js +20 -0
  425. package/dist/core/runner/terminal-projection.d.ts +8 -2
  426. package/dist/core/runner/terminal-projection.js +2 -2
  427. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  428. package/dist/core/runner/tool-disclosure.js +5 -4
  429. package/dist/core/runner/tool-end-body.d.ts +3 -3
  430. package/dist/core/runner/tool-end-body.js +1 -1
  431. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  432. package/dist/core/runner/tool-face-overlay.js +26 -19
  433. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  434. package/dist/core/runner/tool-output-projection.js +7 -6
  435. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  436. package/dist/core/runner/tool-result-media-seat.js +17 -1
  437. package/dist/core/runner/tool-table-view.d.ts +56 -0
  438. package/dist/core/runner/tool-table-view.js +51 -0
  439. package/dist/core/runner/turn-attachments.d.ts +6 -7
  440. package/dist/core/runner/turn-attachments.js +4 -17
  441. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  442. package/dist/core/runner/void-verifier-pause.js +41 -0
  443. package/dist/core/runner-deps.d.ts +55 -43
  444. package/dist/core/secret-env.d.ts +14 -13
  445. package/dist/core/secret-env.js +8 -9
  446. package/dist/core/session-log-transfer.js +9 -10
  447. package/dist/core/session-policy-store.d.ts +10 -3
  448. package/dist/core/session-policy-store.js +21 -3
  449. package/dist/core/session-reconcile.d.ts +3 -2
  450. package/dist/core/session-reconcile.js +7 -4
  451. package/dist/core/session-store.d.ts +5 -2
  452. package/dist/core/session-store.js +53 -16
  453. package/dist/core/session.d.ts +2 -1
  454. package/dist/core/shell-confinement.d.ts +37 -0
  455. package/dist/core/shell-confinement.js +56 -0
  456. package/dist/core/skill-grant.d.ts +9 -0
  457. package/dist/core/skill-grant.js +18 -0
  458. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
  459. package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
  460. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  461. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  462. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  463. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  464. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  465. package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
  466. package/dist/core/stub-env.d.ts +5 -5
  467. package/dist/core/stub-env.js +11 -1
  468. package/dist/core/swappable-deps.d.ts +17 -43
  469. package/dist/core/swappable-deps.js +15 -5
  470. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  471. package/dist/core/task-event.d.ts +35 -10
  472. package/dist/core/task-limits.d.ts +5 -0
  473. package/dist/core/task-notification.d.ts +172 -12
  474. package/dist/core/task-notification.js +209 -12
  475. package/dist/core/task-registry-agent.d.ts +23 -55
  476. package/dist/core/task-registry-agent.js +41 -56
  477. package/dist/core/task-registry-monitor.d.ts +8 -1
  478. package/dist/core/task-registry-monitor.js +43 -61
  479. package/dist/core/task-registry-shared.d.ts +52 -114
  480. package/dist/core/task-registry-shared.js +24 -48
  481. package/dist/core/task-registry-workflow.js +5 -22
  482. package/dist/core/task-registry.d.ts +64 -90
  483. package/dist/core/task-registry.js +73 -119
  484. package/dist/core/task-result.d.ts +27 -19
  485. package/dist/core/task-spec-members.d.ts +39 -0
  486. package/dist/core/task-spec-members.js +92 -0
  487. package/dist/core/task-spec.d.ts +13 -16
  488. package/dist/core/task-stream.d.ts +1 -1
  489. package/dist/core/task-tool-shape.d.ts +7 -57
  490. package/dist/core/task-tool-shape.js +7 -66
  491. package/dist/core/terminal-cause.d.ts +30 -0
  492. package/dist/core/terminal-cause.js +1 -0
  493. package/dist/core/tool-catalog-entries.js +3 -6
  494. package/dist/core/tool-check-reading.js +16 -10
  495. package/dist/core/tool-conformance.js +1 -2
  496. package/dist/core/tool-errors.d.ts +6 -3
  497. package/dist/core/tool-errors.js +2 -0
  498. package/dist/core/tool-face-reader.d.ts +7 -6
  499. package/dist/core/tool-face-reader.js +6 -4
  500. package/dist/core/tool-face.d.ts +2 -3
  501. package/dist/core/tool-name-aliases.d.ts +23 -28
  502. package/dist/core/tool-name-aliases.js +63 -7
  503. package/dist/core/tool-name-readings.d.ts +14 -3
  504. package/dist/core/tool-name-readings.js +2 -0
  505. package/dist/core/tool-policy.d.ts +113 -22
  506. package/dist/core/tool-policy.js +85 -15
  507. package/dist/core/tool-registry.d.ts +5 -5
  508. package/dist/core/tool-registry.js +2 -2
  509. package/dist/core/tool-result-store.d.ts +111 -5
  510. package/dist/core/tool-result-store.js +52 -12
  511. package/dist/core/tool-spec.d.ts +39 -10
  512. package/dist/core/trace.d.ts +18 -2
  513. package/dist/core/types.d.ts +3 -3
  514. package/dist/core/types.js +1 -1
  515. package/dist/core/untrusted-text.js +1 -1
  516. package/dist/core/user-attachment.d.ts +10 -5
  517. package/dist/core/user-attachment.js +40 -27
  518. package/dist/core/workflow-journal-store.d.ts +1 -1
  519. package/dist/core/workflow-run-store.d.ts +2 -0
  520. package/dist/core/workflow-run-store.js +6 -5
  521. package/dist/core/workflow-settled-run.d.ts +5 -0
  522. package/dist/core/workflow-settled-run.js +7 -0
  523. package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
  524. package/dist/engine/execution-env/node-execution-env.js +224 -21
  525. package/dist/engine/harness/agent-harness.d.ts +66 -19
  526. package/dist/engine/harness/agent-harness.js +98 -27
  527. package/dist/engine/harness/messages.d.ts +4 -3
  528. package/dist/engine/harness/messages.js +2 -2
  529. package/dist/engine/harness/types.d.ts +151 -34
  530. package/dist/engine/llm/media-removed.d.ts +14 -0
  531. package/dist/engine/llm/media-removed.js +9 -0
  532. package/dist/engine/llm/rejected-images.d.ts +35 -25
  533. package/dist/engine/llm/rejected-images.js +59 -10
  534. package/dist/engine/llm/types.d.ts +24 -3
  535. package/dist/engine/llm/types.js +7 -3
  536. package/dist/engine/loop/agent-loop.d.ts +18 -13
  537. package/dist/engine/loop/agent-loop.js +173 -32
  538. package/dist/engine/loop/types.d.ts +21 -5
  539. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  540. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  541. package/dist/engine/session/import-validate.js +7 -0
  542. package/dist/fixtures/index.d.ts +7 -5
  543. package/dist/fixtures/index.js +5 -3
  544. package/dist/index.d.ts +41 -23
  545. package/dist/index.js +29 -16
  546. package/dist/internal/harness-types.d.ts +3 -1
  547. package/dist/internal/llm.d.ts +2 -1
  548. package/dist/internal/llm.js +1 -0
  549. package/dist/orchestration/goal.d.ts +6 -2
  550. package/dist/orchestration/goal.js +6 -3
  551. package/dist/orchestration/run-workflow-tool.d.ts +20 -20
  552. package/dist/orchestration/run-workflow-tool.js +63 -56
  553. package/dist/orchestration/workflow-governance.d.ts +1 -1
  554. package/dist/orchestration/workflow-governance.js +2 -1
  555. package/dist/orchestration/workflow-types.d.ts +2 -2
  556. package/dist/orchestration/workflow.d.ts +8 -0
  557. package/dist/orchestration/workflow.js +33 -9
  558. package/dist/prompts/default.d.ts +1 -10
  559. package/dist/prompts/default.js +0 -2
  560. package/dist/stores/file/background-agent-store.d.ts +1 -1
  561. package/dist/stores/file/background-agent-store.js +19 -14
  562. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  563. package/dist/stores/file/checkpoint-store.js +24 -16
  564. package/dist/stores/file/file-history-store.d.ts +1 -1
  565. package/dist/stores/file/file-history-store.js +4 -1
  566. package/dist/stores/file/index.d.ts +9 -6
  567. package/dist/stores/file/index.js +33 -9
  568. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  569. package/dist/stores/file/ledger-tuning.js +21 -0
  570. package/dist/stores/file/mailbox-store.d.ts +1 -1
  571. package/dist/stores/file/mailbox-store.js +43 -21
  572. package/dist/stores/file/memory-store.d.ts +1 -1
  573. package/dist/stores/file/memory-store.js +4 -1
  574. package/dist/stores/file/permission-rule-adopt.js +24 -21
  575. package/dist/stores/file/permission-rule-store.js +6 -3
  576. package/dist/stores/file/session-policy-store.d.ts +1 -1
  577. package/dist/stores/file/session-policy-store.js +4 -1
  578. package/dist/stores/file/session-store.d.ts +17 -4
  579. package/dist/stores/file/session-store.js +22 -19
  580. package/dist/stores/file/shared-ledger.d.ts +26 -0
  581. package/dist/stores/file/shared-ledger.js +38 -9
  582. package/dist/stores/file/tool-result-store.d.ts +31 -2
  583. package/dist/stores/file/tool-result-store.js +129 -7
  584. package/dist/stores/file/usage-window-store.d.ts +1 -1
  585. package/dist/stores/file/usage-window-store.js +4 -1
  586. package/dist/stores/file/workflow-journal-store.d.ts +1 -13
  587. package/dist/stores/file/workflow-journal-store.js +4 -18
  588. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  589. package/dist/stores/file/workflow-run-store.js +15 -10
  590. package/dist/tools/fs/containment-face.d.ts +5 -0
  591. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  592. package/dist/tools/fs/dead-cwd.js +4 -11
  593. package/dist/tools/fs/encoding.d.ts +13 -4
  594. package/dist/tools/fs/encoding.js +17 -2
  595. package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
  596. package/dist/tools/fs/fs-bash-background-text.js +7 -0
  597. package/dist/tools/fs/fs-bash.d.ts +11 -22
  598. package/dist/tools/fs/fs-bash.js +58 -154
  599. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  600. package/dist/tools/fs/fs-pdf.js +34 -27
  601. package/dist/tools/fs/fs-read.d.ts +5 -4
  602. package/dist/tools/fs/fs-read.js +35 -18
  603. package/dist/tools/fs/fs-search-tools.js +4 -1
  604. package/dist/tools/fs/fs-shared.d.ts +39 -16
  605. package/dist/tools/fs/fs-shared.js +25 -6
  606. package/dist/tools/fs/fs-write.js +5 -5
  607. package/dist/tools/fs/index.d.ts +15 -9
  608. package/dist/tools/fs/index.js +12 -18
  609. package/dist/tools/fs/pdf.d.ts +4 -4
  610. package/dist/tools/fs/pdf.js +6 -6
  611. package/dist/tools/fs/read-deny-home.js +8 -1
  612. package/dist/tools/fs/read-deny.d.ts +26 -2
  613. package/dist/tools/fs/read-deny.js +9 -2
  614. package/dist/tools/fs/read-floor.d.ts +57 -6
  615. package/dist/tools/fs/read-floor.js +241 -2
  616. package/dist/tools/fs/removal-targets.d.ts +9 -4
  617. package/dist/tools/fs/removal-targets.js +17 -9
  618. package/dist/tools/fs/search.d.ts +6 -5
  619. package/dist/tools/fs/search.js +10 -10
  620. package/dist/tools/fs/shell-read-establish.js +3 -1
  621. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  622. package/dist/tools/fs/shell-read-identity.js +4 -2
  623. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  624. package/dist/tools/fs/shell-read-judge.js +1 -1
  625. package/dist/tools/monitor.d.ts +12 -10
  626. package/dist/tools/monitor.js +22 -13
  627. package/dist/tools/scheduler-tools.js +42 -4
  628. package/dist/tools/web.d.ts +0 -10
  629. package/dist/tools/web.js +1 -4
  630. package/dist/tools/worktree.d.ts +5 -1
  631. package/dist/tools/worktree.js +20 -17
  632. package/package.json +8 -3
  633. package/test/export-surface.snapshot.json +166 -30
  634. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  635. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  636. package/wire-changes/core@7.60.0.json +3274 -0
  637. package/wire-changes/core@7.61.0.json +4405 -0
  638. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  639. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  640. package/wire-changes/primitives@7.60.0.json +30 -0
  641. package/wire-changes/primitives@7.61.0.json +30 -0
  642. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  643. package/dist/core/runner/image-removed-seat.js +0 -19
@@ -1,10 +1,11 @@
1
1
  import { createAssistantMessageEventStream, ensureToolTurnInvariants, findToolByName, snapshotActorAssertion, stripEngineMetadata, userAttachmentOf } from "../llm/index.js";
2
- import { imageRefusalAt, isImageRefusal, removeRejectedImages } from "../llm/rejected-images.js";
3
- import { finalizeToolOutcome, isBatchSafeToolCall, runAgentLoop, runToolCall } from "../loop/agent-loop.js";
2
+ import { imageRefusalAt, isImageRefusal, removeRefusedRequestParts } from "../llm/rejected-images.js";
3
+ import { finalizeToolOutcome, findUnansweredToolBatch, isBatchSafeToolCall, runAgentLoop, runToolCall } from "../loop/agent-loop.js";
4
4
  import { resolveAgentCoreStreamFn } from "../loop/runtime-deps.js";
5
5
  import { normalizeEngineSegments } from "../../core/untrusted-text.js";
6
6
  import { isCredentialHeaderName } from "../../core/secret-env.js";
7
7
  import { isRunOrigin } from "../../core/run-origin.js";
8
+ import { countsAsOperator, readInputAuthor } from "../../core/input-author.js";
8
9
  import { isProviderEchoShape } from "../../brain/errors.js";
9
10
  import { convertToLlm } from "./messages.js";
10
11
  import { readMember, thrownText } from "../../core/thrown-value.js";
@@ -47,6 +48,10 @@ function createTrailingMessage(seed) {
47
48
  }
48
49
  const engineNotePayloads = new WeakMap();
49
50
  const engineAuthoredInjections = new WeakSet();
51
+ const inputAuthors = new WeakMap();
52
+ function isOperatorInput(m) {
53
+ return !engineAuthoredInjections.has(m) && countsAsOperator(readInputAuthor(inputAuthors.get(m)));
54
+ }
50
55
  function isEngineAdvisory(m) {
51
56
  return engineAuthoredInjections.has(m) && !engineNotePayloads.has(m);
52
57
  }
@@ -59,7 +64,7 @@ function isEngineAuthoredInjection(options) {
59
64
  return false;
60
65
  if (options.engineMinted === true || options.enginePayload !== undefined)
61
66
  return true;
62
- return options.provenance === "engine-note" && options.callerAuthored !== true;
67
+ return options.provenance === "engine-note" && options.author === undefined;
63
68
  }
64
69
  const ENGINE_NOTE_STEER_BACKLOG_CAP = 50;
65
70
  function createFailureMessage(model, error, aborted) {
@@ -196,6 +201,7 @@ function normalizeHarnessError(error, fallbackCode) {
196
201
  function normalizeHookError(error) {
197
202
  return normalizeHarnessError(error, "hook");
198
203
  }
204
+ const PORT_PARKED_REFUSAL = "$.session.append: refused: the leg parked durably — the conversation it resumes is its checkpoint's";
199
205
  export class AgentHarness {
200
206
  env;
201
207
  session;
@@ -210,7 +216,7 @@ export class AgentHarness {
210
216
  boundaryStopConsumed;
211
217
  lastPublishedSeat;
212
218
  seatCutSources = new WeakMap();
213
- trailingBatchEndedOn;
219
+ endedOnPriorAnswer = false;
214
220
  promptReceipt;
215
221
  turnCutConsumed;
216
222
  committedEntryIds = new WeakMap();
@@ -220,21 +226,25 @@ export class AgentHarness {
220
226
  runAbortController;
221
227
  runPromise;
222
228
  pendingSessionWrites = [];
229
+ parkCaptureInFlight;
230
+ parkedPortClosed = false;
223
231
  model;
224
232
  modelRef;
225
233
  thinkingLevel;
226
234
  onUndrainedEngineNotes;
227
235
  onToolTurnRepaired;
228
236
  onImagesRemoved;
237
+ onToolSchemaRefused;
229
238
  priorImageRefusals;
230
239
  runHistory;
231
240
  onUndrainedUserInputs;
241
+ onUndrainedOtherInputs;
232
242
  onEngineNoteConsumed;
233
243
  onUserInputConsumed;
234
244
  onFrameCommitted;
235
245
  engineInjectionsHeld;
236
246
  imageRefusalView(messages) {
237
- const view = removeRejectedImages(messages);
247
+ const view = removeRefusedRequestParts(messages);
238
248
  const met = view.removals.filter((r) => this.priorImageRefusals?.has(r.refusalAt) !== true);
239
249
  if (met.length > 0) {
240
250
  try {
@@ -280,10 +290,10 @@ export class AgentHarness {
280
290
  }
281
291
  }
282
292
  pendingUserInputFramesByLane() {
283
- const inFlight = (lane) => this.drainedPendingInjection.filter((m) => !engineAuthoredInjections.has(m) && drainedFromLane.get(m) === lane);
293
+ const inFlight = (lane) => this.drainedPendingInjection.filter((m) => isOperatorInput(m) && drainedFromLane.get(m) === lane);
284
294
  return {
285
- steer: [...inFlight("steer"), ...this.steerQueue.filter((m) => !engineAuthoredInjections.has(m))],
286
- followUp: [...inFlight("followUp"), ...this.followUpQueue.filter((m) => !engineAuthoredInjections.has(m))],
295
+ steer: [...inFlight("steer"), ...this.steerQueue.filter((m) => isOperatorInput(m))],
296
+ followUp: [...inFlight("followUp"), ...this.followUpQueue.filter((m) => isOperatorInput(m))],
287
297
  };
288
298
  }
289
299
  pendingUserInputsByLane() {
@@ -309,6 +319,14 @@ export class AgentHarness {
309
319
  catch {
310
320
  }
311
321
  }
322
+ const others = [this.drainedPendingInjection, this.steerQueue, this.followUpQueue].flatMap((q) => q.flatMap((m) => (engineAuthoredInjections.has(m) || isOperatorInput(m) ? [] : [inputAuthors.get(m)])));
323
+ if (others.length > 0 && this.onUndrainedOtherInputs) {
324
+ try {
325
+ this.onUndrainedOtherInputs(others);
326
+ }
327
+ catch {
328
+ }
329
+ }
312
330
  return counts;
313
331
  }
314
332
  systemPrompt;
@@ -326,10 +344,11 @@ export class AgentHarness {
326
344
  stallTimeoutsPerCall;
327
345
  abortResultDetails;
328
346
  executeTool;
347
+ admitRows;
329
348
  activeRun;
330
349
  loopTrace;
331
350
  onToolInputValidationFault;
332
- onToolMediaRefused;
351
+ toolResultMedia;
333
352
  resilience;
334
353
  maxToolConcurrency;
335
354
  streamingToolExecution;
@@ -364,9 +383,15 @@ export class AgentHarness {
364
383
  this.stallTimeoutsPerCall = options.stallTimeoutsPerCall;
365
384
  this.abortResultDetails = options.abortResultDetails;
366
385
  this.executeTool = options.executeTool;
386
+ this.admitRows = options.admitRows ?? (async (rows) => rows);
387
+ this.pendingSessionWrites = (options.heldWrites ?? []).map((message) => ({ type: "message", message }));
367
388
  this.loopTrace = options.loopTrace;
368
389
  this.onToolInputValidationFault = options.onToolInputValidationFault;
369
- this.onToolMediaRefused = options.onToolMediaRefused;
390
+ this.toolResultMedia = {
391
+ ...(options.imageProcessor !== undefined ? { imageProcessor: options.imageProcessor } : {}),
392
+ ...(options.onToolMediaRefused !== undefined ? { onToolMediaRefused: options.onToolMediaRefused } : {}),
393
+ ...(options.onImageUnprocessed !== undefined ? { onImageUnprocessed: options.onImageUnprocessed } : {}),
394
+ };
370
395
  this.resilience = options.resilience;
371
396
  this.maxToolConcurrency = options.maxToolConcurrency;
372
397
  this.streamingToolExecution = options.streamingToolExecution;
@@ -685,7 +710,8 @@ export class AgentHarness {
685
710
  ...(this.abortResultDetails !== undefined ? { abortResultDetails: this.abortResultDetails } : {}),
686
711
  ...(this.executeTool !== undefined ? { executeTool: this.executeTool } : {}),
687
712
  ...(this.onToolInputValidationFault !== undefined ? { onToolInputValidationFault: this.onToolInputValidationFault } : {}),
688
- ...(this.onToolMediaRefused !== undefined ? { onToolMediaRefused: this.onToolMediaRefused } : {}),
713
+ onToolSchemaRefused: (refusal) => this.onToolSchemaRefused?.(refusal),
714
+ ...this.toolResultMedia,
689
715
  ...(this.resilience !== undefined ? { resilience: this.resilience } : {}),
690
716
  ...(this.maxToolConcurrency !== undefined ? { maxToolConcurrency: this.maxToolConcurrency } : {}),
691
717
  ...(this.streamingToolExecution === true && (this.getHandlers("tool_call")?.size ?? 0) === 0
@@ -816,8 +842,7 @@ export class AgentHarness {
816
842
  if (this.runAbortController?.signal.aborted) {
817
843
  return;
818
844
  }
819
- while (this.pendingSessionWrites.length > 0) {
820
- const write = this.pendingSessionWrites[0];
845
+ for (let write = this.pendingSessionWrites[0]; write !== undefined; write = this.pendingSessionWrites[0]) {
821
846
  if (write.type === "message") {
822
847
  await this.session.appendMessage(write.message);
823
848
  }
@@ -831,7 +856,9 @@ export class AgentHarness {
831
856
  const unreachable = write;
832
857
  throw new AgentHarnessError("invalid_argument", `flushPendingSessionWrites: unhandled queued write type ${unreachable.type}`);
833
858
  }
834
- this.pendingSessionWrites.shift();
859
+ const at = this.pendingSessionWrites.indexOf(write);
860
+ if (at >= 0)
861
+ this.pendingSessionWrites.splice(at, 1);
835
862
  }
836
863
  }
837
864
  async recordApiFailure(failure) {
@@ -839,6 +866,7 @@ export class AgentHarness {
839
866
  const apiErrorStatus = readMember(failure, "apiErrorStatus");
840
867
  const requestId = readMember(failure, "requestId");
841
868
  const errorKind = readMember(failure, "errorKind");
869
+ const refusedTool = readMember(failure, "refusedTool");
842
870
  const raw = typeof errorMessage === "string" ? errorMessage.trim() : undefined;
843
871
  const detail = raw !== undefined && raw.length > API_FAILURE_RECORD_MAX_CHARS
844
872
  ? `${raw.slice(0, API_FAILURE_RECORD_MAX_CHARS)}… (truncated)`
@@ -857,9 +885,11 @@ export class AgentHarness {
857
885
  stopReason: "error",
858
886
  ...(typeof errorMessage === "string" ? { errorMessage } : {}),
859
887
  ...(errorKind === "length_empty" || errorKind === "degenerate" || errorKind === "input_too_long" || errorKind === "image_unprocessable" ? { errorKind } : {}),
888
+ ...(errorKind === "tool_schema_refused" && typeof refusedTool === "string" ? { errorKind, refusedTool } : {}),
860
889
  timestamp: failure.timestamp,
861
890
  };
862
891
  try {
892
+ await this.admitRows([record]);
863
893
  await this.session.appendMessage(record);
864
894
  }
865
895
  catch {
@@ -869,6 +899,7 @@ export class AgentHarness {
869
899
  if (event.type === "message_end") {
870
900
  let entryId;
871
901
  if (!isEmptyFailureAssistant(event.message)) {
902
+ await this.admitRows([event.message]);
872
903
  entryId = await this.session.appendMessage(event.message);
873
904
  this.committedEntryIds.set(event.message, entryId);
874
905
  this.settleInjectedFrame(event.message, entryId);
@@ -999,11 +1030,12 @@ export class AgentHarness {
999
1030
  ...(options.settleUnansweredToolCalls.halt !== undefined ? { halt: options.settleUnansweredToolCalls.halt } : {}),
1000
1031
  report: (outcome) => {
1001
1032
  if (outcome.aborted)
1002
- this.trailingBatchEndedOn = outcome.assistantMessage;
1033
+ this.endedOnPriorAnswer = true;
1003
1034
  },
1004
1035
  },
1005
1036
  }
1006
1037
  : {}),
1038
+ ...(options?.endsAwaitingUser === true ? { endsAwaitingUser: true } : {}),
1007
1039
  });
1008
1040
  }
1009
1041
  catch (error) {
@@ -1027,8 +1059,13 @@ export class AgentHarness {
1027
1059
  }
1028
1060
  if (this.stopRequested || abortController.signal.aborted)
1029
1061
  return undefined;
1030
- if (this.trailingBatchEndedOn !== undefined)
1031
- return this.answeredFrom(this.trailingBatchEndedOn, [this.trailingBatchEndedOn]);
1062
+ if (this.endedOnPriorAnswer || options?.endsAwaitingUser === true) {
1063
+ const prior = turnState.messages.findLast((m) => m.role === "assistant");
1064
+ if (prior !== undefined)
1065
+ return this.answeredFrom(prior, [prior]);
1066
+ if (options?.endsAwaitingUser === true)
1067
+ return undefined;
1068
+ }
1032
1069
  throw new AgentHarnessError("invalid_state", "AgentHarness prompt completed without an assistant message");
1033
1070
  }
1034
1071
  finally {
@@ -1047,7 +1084,7 @@ export class AgentHarness {
1047
1084
  if (this.phase !== "idle") {
1048
1085
  throw new AgentHarnessError("busy", "AgentHarness is busy");
1049
1086
  }
1050
- this.trailingBatchEndedOn = undefined;
1087
+ this.endedOnPriorAnswer = false;
1051
1088
  this.stopRequestSources.clear();
1052
1089
  this.boundaryStopConsumed = undefined;
1053
1090
  this.turnCutConsumed = undefined;
@@ -1070,7 +1107,8 @@ export class AgentHarness {
1070
1107
  this.runAbortController = abortController;
1071
1108
  const finishRunPromise = this.startRunPromise();
1072
1109
  try {
1073
- await this.flushPendingSessionWrites();
1110
+ if (this.pendingSessionWrites.length > 0 && findUnansweredToolBatch((await this.session.buildContext()).messages) === undefined)
1111
+ await this.flushPendingSessionWrites();
1074
1112
  const turnState = await this.createTurnState();
1075
1113
  return await this.executeTurn(turnState, text, options, abortController);
1076
1114
  }
@@ -1105,6 +1143,8 @@ export class AgentHarness {
1105
1143
  engineNotePayloads.set(m, options.enginePayload);
1106
1144
  if (isEngineAuthoredInjection(options))
1107
1145
  engineAuthoredInjections.add(m);
1146
+ if (options?.author !== undefined)
1147
+ inputAuthors.set(m, options.author);
1108
1148
  if (options?.parkRecord !== undefined)
1109
1149
  userInputParkRecords.set(m, options.parkRecord);
1110
1150
  if (options?.immediate === true)
@@ -1281,9 +1321,16 @@ export class AgentHarness {
1281
1321
  async nextTurn(text, options) {
1282
1322
  await this.enqueueInjection(this.nextTurnQueue, text, options);
1283
1323
  }
1284
- async appendMessage(message) {
1324
+ async appendMessage(message, raising) {
1325
+ const kept = await this.admitRows([message], raising);
1326
+ if (!kept.includes(message))
1327
+ return;
1328
+ while (this.parkCaptureInFlight !== undefined)
1329
+ await this.parkCaptureInFlight;
1330
+ if (this.parkedPortClosed)
1331
+ throw new AgentHarnessError("invalid_state", PORT_PARKED_REFUSAL);
1285
1332
  try {
1286
- if (this.phase === "idle") {
1333
+ if (this.phase === "idle" && this.pendingSessionWrites.length === 0) {
1287
1334
  await this.session.appendMessage(message);
1288
1335
  }
1289
1336
  else {
@@ -1307,7 +1354,7 @@ export class AgentHarness {
1307
1354
  return patch;
1308
1355
  }
1309
1356
  finalizeToolCall(toolCall, args, executed) {
1310
- return finalizeToolOutcome(toolCall, executed, (result, isError) => this.afterToolCallHook(toolCall, args, result, isError), this.onToolMediaRefused);
1357
+ return finalizeToolOutcome(toolCall, executed, (result, isError) => this.afterToolCallHook(toolCall, args, result, isError), this.toolResultMedia);
1311
1358
  }
1312
1359
  async callTool(toolCall, signal, admit) {
1313
1360
  const run = this.activeRun;
@@ -1445,12 +1492,39 @@ export class AgentHarness {
1445
1492
  throw normalizeHarnessError(error, "session");
1446
1493
  }
1447
1494
  }
1495
+ parkCapture() {
1496
+ if (this.parkCaptureInFlight !== undefined)
1497
+ throw new AgentHarnessError("invalid_state", "a park's capture of the held rows is already in progress");
1498
+ const rows = this.pendingSessionWrites.flatMap((write) => (write.type === "message" ? [write.message] : []));
1499
+ let release = () => undefined;
1500
+ this.parkCaptureInFlight = new Promise((resolve) => (release = resolve));
1501
+ let settled = false;
1502
+ return {
1503
+ rows,
1504
+ settle: (outcome) => {
1505
+ if (settled)
1506
+ return;
1507
+ settled = true;
1508
+ if (outcome === "committed") {
1509
+ const taken = new Set(rows);
1510
+ this.pendingSessionWrites = this.pendingSessionWrites.filter((write) => write.type !== "message" || !taken.has(write.message));
1511
+ }
1512
+ if (outcome !== "absent")
1513
+ this.parkedPortClosed = true;
1514
+ this.parkCaptureInFlight = undefined;
1515
+ release();
1516
+ },
1517
+ };
1518
+ }
1519
+ heldSessionWrites() {
1520
+ return [...this.pendingSessionWrites];
1521
+ }
1448
1522
  readParkableUserInputs() {
1449
1523
  const out = [];
1450
1524
  for (const q of [this.drainedPendingInjection, this.steerQueue, this.followUpQueue]) {
1451
1525
  for (const m of q) {
1452
1526
  const record = userInputParkRecords.get(m);
1453
- if (record !== undefined)
1527
+ if (record !== undefined && isOperatorInput(m))
1454
1528
  out.push(record);
1455
1529
  }
1456
1530
  }
@@ -1497,10 +1571,7 @@ export class AgentHarness {
1497
1571
  errors.push(toError(error));
1498
1572
  }
1499
1573
  this.sweepUndrainedEngineNotes([this.drainedPendingInjection, this.nextTurnQueue, this.steerQueue, this.followUpQueue]);
1500
- const userAuthored = (m) => !engineAuthoredInjections.has(m);
1501
- const inFlightOf = (lane) => this.drainedPendingInjection.filter((m) => userAuthored(m) && drainedFromLane.get(m) === lane);
1502
- const undrainedSteer = [...inFlightOf("steer"), ...this.steerQueue.filter(userAuthored)];
1503
- const undrainedFollowUp = [...inFlightOf("followUp"), ...this.followUpQueue.filter(userAuthored)];
1574
+ const { steer: undrainedSteer, followUp: undrainedFollowUp } = this.pendingUserInputFramesByLane();
1504
1575
  try {
1505
1576
  await this.emitOwn({ type: "abort", undrainedSteer, undrainedFollowUp });
1506
1577
  }
@@ -26,7 +26,8 @@ export declare const NORMALIZED_CONTENT_PREFIX = "[invalid content block normali
26
26
  * `convertToLlm` (provider leg) and `serializeConversation` (compaction leg) — one helper, two mouths.
27
27
  */
28
28
  export declare function normalizeLlmMessageContent<T extends Message>(message: T): T;
29
- /** Convert harness transcript messages into the LLM-facing message sequence. A provider's image refusal (live or its
30
- * record) removes the images it refused ({@link removeRejectedImages}) for every leg — provider and compaction alike;
31
- * the request leg applies it earlier, where its view starts, so there this pass is the identity. */
29
+ /** Convert harness transcript messages into the LLM-facing message sequence. A provider's refusal of part of a request
30
+ * (live or its record) leaves the view, and an image refusal removes the images it refused ({@link removeRefusedRequestParts})
31
+ * for every leg — provider and compaction alike; the request leg applies it earlier, where its view starts, so there this
32
+ * pass is the identity. */
32
33
  export declare function convertToLlm(messages: AgentMessage[]): Message[];
@@ -1,5 +1,5 @@
1
1
  import { isSyntheticApiErrorMessage } from "./types.js";
2
- import { removeRejectedImages } from "../llm/rejected-images.js";
2
+ import { removeRefusedRequestParts } from "../llm/rejected-images.js";
3
3
  import { parseSessionTimestampMs, requireSessionTimestampMs } from "../session/timestamps.js";
4
4
  export function asAgentMessage(message) {
5
5
  return message;
@@ -108,7 +108,7 @@ export function normalizeLlmMessageContent(message) {
108
108
  return changed ? { ...message, content: blocks } : message;
109
109
  }
110
110
  export function convertToLlm(messages) {
111
- return removeRejectedImages(messages)
111
+ return removeRefusedRequestParts(messages)
112
112
  .messages.map((m) => {
113
113
  const message = m;
114
114
  switch (message.role) {
@@ -108,7 +108,13 @@ export type FileErrorCode = "aborted" | "not_found" | "permission_denied" | "not
108
108
  /** A name this filesystem cannot hold (POSIX `ENAMETOOLONG` for a path component past `NAME_MAX`) — nothing can be there, and
109
109
  * a program that opens it fails the same way: an absence as conclusive as `not_found`. A path past `PATH_MAX` whose
110
110
  * components are short is not this word (such a file may exist, reached from a directory below it). */
111
- | "name_too_long" | "invalid" | "not_supported"
111
+ | "name_too_long"
112
+ /** A symbolic-link chain that loops (POSIX `ELOOP`: a link that points at itself, a cycle of links, a chain past the platform's
113
+ * follow limit) — nothing can be opened through it, but it is NOT an absence: the entries exist and the path resolves to
114
+ * nothing. The word says "this path leads to no directory": a probe that asks whether a directory is usable reads it as
115
+ * unusable (as `not_found` / `not_directory`), while a judge that must vouch for where a path lands reads it as unresolved
116
+ * (as the catch-all `unknown`), never as "nothing is there". */
117
+ | "symlink_loop" | "invalid" | "not_supported"
112
118
  /** Exclusive create refused because the path already exists ({@link FileSystem.writeFileExclusive},
113
119
  * POSIX `O_EXCL` shape). Discriminable so a caller can distinguish "lost the create race" from a
114
120
  * write failure and give honest guidance instead of overwriting. */
@@ -202,7 +208,7 @@ export declare class ExecutionError extends Error {
202
208
  * never observed, but its captured output is real work). Reference behavior (BashTask settle): a
203
209
  * timed-out command keeps ALL captured stdout/stderr and only APPENDS a "Command timed out after
204
210
  * X" line — discarding 600s of build logs forces the model to rerun blind. Optional: envs that
205
- * cannot capture partial output simply omit these; never-started codes
211
+ * cannot capture partial output omit these (absent = not captured, never "not produced"); never-started codes
206
212
  * (spawn_error/shell_unavailable) have no output by definition.
207
213
  */
208
214
  partialStdout?: string;
@@ -340,14 +346,28 @@ export interface ExecutionEnvExecOptions {
340
346
  * behavior. Envs without detach support ignore this (opt-in, backward compatible).
341
347
  */
342
348
  autoBackgroundOnTimeout?: boolean;
343
- /** VENDORED EDIT (the byte floor) — the read-deny table in force for the call starting this command ({@link ReadFloor}); what its processes OPEN is the environment's to keep. */
349
+ /** VENDORED EDIT (the byte floor) — the read-deny table this start judges with ({@link ReadFloor}): a call's own pinned table, else the run's; every start a run makes carries it, whether or not its output reaches the model.
350
+ * What its processes OPEN is the environment's to keep ({@link ExecutionEnvCapabilities.keepsReadFloor}). Absent ⇔ the table holds no row, or the start is no run's (`runExecGate`, the oracle's isolation probe). */
344
351
  readFloor?: ReadFloor;
345
352
  }
346
- /** The read-deny table one command start carries ({@link ExecutionEnvExecOptions.readFloor}); what an environment keeps of it is INTEGRATION-CORE §11.1. */
353
+ /** The read-deny table one command start carries ({@link ExecutionEnvExecOptions.readFloor}); what an environment keeps of it is INTEGRATION-CORE §11.1.
354
+ * Path semantics: a path is judged as spelled, never resolved (a hard link is another path; a symbolic link is resolved where the environment opens it). Pinned at the start: a floor with an `id` judges with that start's table for its processes' life. Exec is no read: a `#!` line's bytes, a self-printing binary (KNOWN-LIMITS KL-3190-a). */
347
355
  export interface ReadFloor {
356
+ /** The compiled table this floor stands on (`ReadDenyMatcher.id`): one `id` ⇒ one judgment of every path, so a relay may keep what it derived by it; absent ⇒ no one compiled table (hand-built, or a band's placement in flight) — derive per start. */
357
+ readonly id?: string;
348
358
  readonly rows: readonly string[];
349
359
  /** The row denying an absolute path in this environment's namespace, or `null`: the read station's own judgment. Never throws. */
350
360
  denies(absolutePath: string): string | null;
361
+ /** The floor as an OS confinement profile (`"seatbelt"`: `sandbox-exec -p`), from the table `denies` judges with; a row the
362
+ * dialect cannot express answers `{ ok: false, row, reason }` and the start is refused, never run looser. Never throws. */
363
+ confinement(dialect: "seatbelt"): {
364
+ readonly ok: true;
365
+ readonly profile: string;
366
+ } | {
367
+ readonly ok: false;
368
+ readonly row: string;
369
+ readonly reason: string;
370
+ };
351
371
  }
352
372
  /**
353
373
  * Filesystem capability used by the harness.
@@ -377,7 +397,8 @@ export interface FileSystem {
377
397
  /** Create or overwrite a file, creating parent directories when supported. Implementation note
378
398
  * (RB-221): the Node env replaces the file as a WHOLE (same-directory staging + fsync +
379
399
  * rename; `aborted` ⇒ target untouched), falling back to an in-place rewrite where rename cannot
380
- * apply (cross-device, symlink chains, non-regular targets, read-only parent dir). Atomicity is an
400
+ * apply (cross-device, symlink chains, non-regular targets, read-only parent dir) — a fallback judges
401
+ * the signal once, before its first byte, so `aborted` never describes a truncated file. Atomicity is an
381
402
  * implementation quality, NOT an interface-level contract — a remote/transport env may only have a
382
403
  * plain in-place write. */
383
404
  writeFile(path: string, content: string | Uint8Array, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
@@ -490,8 +511,114 @@ export interface Shell {
490
511
  /** Release shell resources. Must be best-effort and must not throw or reject. */
491
512
  cleanup(): Promise<void>;
492
513
  }
514
+ /**
515
+ * #2891 — what an execution environment can do and where its actions land: the ONE place each of these questions is
516
+ * answered, declared by the ADAPTER on every environment ({@link ExecutionEnv.capabilities}), local or remote.
517
+ *
518
+ * Every key is REQUIRED and has no default reading: for each one, either answer an absent value could be given is
519
+ * wrong for some environment, so an adapter states it. A value that is absent, not a boolean, or cannot be received (a
520
+ * throwing getter, a Proxy — a JS adapter's block) — and a member outside the eight keys — is announced once per run at
521
+ * the admission point (`config.execution_env_capability_invalid`, `detail.key` naming it, or `capabilities` for a block
522
+ * that is no object or cannot be received), and each reader takes that key's SAFE side, written beside the readers
523
+ * (`UNDECLARED_CAPABILITY_READING`, `src/core/remote-env.ts`). Every key is read through its one reader there.
524
+ *
525
+ * What an INTERFACE answers is a different question: whether a group of methods can be called (the remote seam's
526
+ * lifecycle, a background shell, a scheduler, an optional filesystem method). Implementing a group of methods never
527
+ * declares a capability, and a capability never stands in for a method.
528
+ *
529
+ * The block is a constant of the adapter: the engine receives it ONCE per environment object (at its first read, a
530
+ * run's admission point) into a frozen copy every reader reads; a later change by the host is never read.
531
+ */
532
+ export interface ExecutionEnvCapabilities {
533
+ /** True iff the commands run inside a sandbox that IS the security boundary (container, microVM, pod); false for
534
+ * a real target (the engine's own host, an SSH host, a device). Every consumer of a `true` here RELAXES something
535
+ * (autonomy, a policy tier, a containment leg the sandbox is then answerable for), so only the boolean `true`
536
+ * counts. Undeclared ⇒ `false`. Read through `isIsolated`. */
537
+ readonly isolation: boolean;
538
+ /** True iff the environment can be snapshot (`suspendVM`) and restored; false for one that cannot (a local
539
+ * process, an SSH host, a device).
540
+ *
541
+ * ⚠️ LOAD-BEARING INVARIANT: `suspendable: false` on a remote environment also asserts the workspace is
542
+ * EXTERNALLY DURABLE — it persists on the target across the environment object's lifetime (true for SSH hosts and
543
+ * devices). The durable-park-only suspend degrade rests on this: it skips `suspendVM` and trusts the factory to
544
+ * reconnect to the SAME workspace on resume. An adapter for a non-suspendable EPHEMERAL backend (a snapshot-less
545
+ * container torn down with its transport) must NOT be modeled as `suspendable: false` remote — it would silently
546
+ * take the park-only branch and resume onto a fresh empty workspace. Model such a backend as a per-task
547
+ * environment without durable suspend instead (the human gate refuses it), or split this key before building one.
548
+ * Undeclared ⇒ neither suspendable nor parkable. Read through `declaredSuspend` (three states) and `isSuspendable`
549
+ * (a declared `true` with the remote interface and its restore surface). */
550
+ readonly suspendable: boolean;
551
+ /** True iff the commands this environment runs are processes on a table that holds THIS process — the table the
552
+ * engine itself and the processes above it are on, so a kill the model writes there can reach them. `true` for an
553
+ * environment that spawns the commands as this process's own descendants (`NodeExecutionEnv`, a host lane) and for
554
+ * one whose commands run in a PID namespace that contains this process's (the host of the container the engine
555
+ * runs in); `false` only for one whose commands run where this process is not: another machine (SSH host, device,
556
+ * cloud sandbox) or a PID namespace this process is not in (a sandbox container, a pod). Not {@link isolation}: a
557
+ * non-isolated SSH host is a real machine and still another table. The self-preservation guard of the Bash tool
558
+ * asks its question exactly when this is `true`, and does not ask where it is `false`.
559
+ *
560
+ * What a `true` buys is the guard's question exactly as a `NodeExecutionEnv` gets it, limits included: on this
561
+ * process's own table, of the platform's `pgrep`, with the kill's words as written, from this process's own
562
+ * working directory. It is put as for this process's descendants, so for commands on the same table that are not
563
+ * (SSH to `localhost`) BSD's `pgrep` leaves its OWN caller's ancestors out where the real kill would not, and from
564
+ * an enclosing namespace the question sees only this process's namespace, not the ancestors above it.
565
+ *
566
+ * Undeclared ⇒ the guard refuses every pattern kill that needs the question on this environment (`pkill -P $$`
567
+ * runs), naming this declaration. Read through `processTableOf`. */
568
+ readonly sharesProcessTable: boolean;
569
+ /** True iff this environment's {@link FileSystem.canonicalPath} is the AUTHORITY on where a path lands — it
570
+ * answers for the very filesystem the commands run on, so a failure to answer is a failure of the resolver rather
571
+ * than a namespace it cannot see into. A `true` makes the read boundary's execute-time recheck REFUSE a chain its
572
+ * resolver cannot answer at all instead of passing the written spelling through; `false` keeps the lexical
573
+ * verdict for a chain the resolver answers `not_supported` (no file face). A resolver that FAILS (any other
574
+ * non-answer) is a failure either way. `NodeExecutionEnv` declares `true` (its resolver always answers `/`, so the
575
+ * arm has no case to fire on); an environment with no path resolution surface declares `false`. Undeclared ⇒
576
+ * `true` (silence refuses). Read through `canonicalPathIsAuthoritative`. */
577
+ readonly canonicalPathAuthoritative: boolean;
578
+ /** True iff a path this environment names is the same file on the ENGINE HOST's filesystem — the engine may
579
+ * present this environment's cwd as a host path (the workflow workspace observer's `worktreeDir`) and record
580
+ * host-path receipts for it. `true` for `NodeExecutionEnv` and for a host lane that drives the engine's own
581
+ * machine; `false` for an environment whose paths never map onto the host (an in-memory environment, a sandbox
582
+ * or container the host does not mount at the same paths, another machine). Undeclared ⇒ `false`. Read through
583
+ * `pathsAreHostLocal`. */
584
+ readonly hostLocalPaths: boolean;
585
+ /** True iff content produced by THIS environment (every FileSystem / Shell result — stdout, file bytes, listings,
586
+ * names) originates from a target OUTSIDE the deployment's trust boundary (a personal device, an unmanaged host).
587
+ * `true` feeds three existing channels, no new vocabulary:
588
+ * - memory: the run's hand-tool results are treated as external-class content — the session mark
589
+ * (`memory.session_polluted`) and the origin carriage at harvest, via the same fold `execIsExternalContent`
590
+ * upgrades through (this key ORs into that fold for the run);
591
+ * - env facts / prompt renderer: one declarative line disclosing the execution locus and trust posture;
592
+ * - audit: TaskResult / checkpoint carry it implicitly through `WorkspaceHandle{provider, deviceId}`.
593
+ * Suspend / resume: the run-level fold is PRESENCE-persisted on the checkpoint (`CheckpointState.externalContentTarget`,
594
+ * monotonic) and resume joins persisted OR live declaration — a run minted under a declaring adapter never
595
+ * silently downgrades on an undeclaring or older one. ONE declaration, two readers: the content-class fold above
596
+ * (no gate, policy or roster reads that fold) and the cross-boundary taint (it arms the run tree's taint bit; a
597
+ * call's `env` leg is judged by whether the environment THAT CALL reaches declares this, never by the
598
+ * fold). ORTHOGONAL to {@link isolation}: an SSH environment to an organization-managed build host can be
599
+ * non-isolated and still declare `false`. Undeclared ⇒ each consumer's safe side: the content fold reads it as outside,
600
+ * and a call that reaches the environment owes what reaching the target and what leaving it both owe. Read through
601
+ * `targetIsExternal` (three states). */
602
+ readonly externalContentTarget: boolean;
603
+ /** True iff the filesystem and shell faces reach a target. `false` only for a placeholder whose every operation
604
+ * refuses (each filesystem operation `not_supported`, every `exec` `shell_unavailable` — `StubExecutionEnv`, the
605
+ * environment of a run without hands). Undeclared ⇒ no shell face mounts, and the project marker is still read
606
+ * through it, never past its read limits. Read through `performsIo` (three states). */
607
+ readonly io: boolean;
608
+ /** True iff this environment keeps the byte floor a command start carries ({@link ExecutionEnvExecOptions.readFloor}):
609
+ * every path its `denies` answers non-null for stays unreadable to every program the command runs, judged where the
610
+ * environment itself resolves the path — or the environment refuses a start whose whole table it cannot keep
611
+ * (`spawn_error`, naming the row) rather than run with fewer rows (INTEGRATION-CORE §11.1). `false` for an
612
+ * environment that cannot confine a process (`NodeExecutionEnv`, a host lane, an SSH host, a device): a run whose
613
+ * read-deny table is non-empty on such an environment is announced (`config.read_deny_floor_unkept`), or refused
614
+ * at prepare when the deployment sets `RunnerDeps.readDenyFloorRequired`. `StubExecutionEnv` declares `true`:
615
+ * it refuses every start, so no byte can be read through it. Undeclared ⇒ `false`. Read through `keepsReadFloor`. */
616
+ readonly keepsReadFloor: boolean;
617
+ }
493
618
  /** Filesystem and process execution environment used by the harness. */
494
619
  export interface ExecutionEnv extends FileSystem, Shell {
620
+ /** What this environment can do and where its actions land — {@link ExecutionEnvCapabilities}, every key required. */
621
+ readonly capabilities: ExecutionEnvCapabilities;
495
622
  /**
496
623
  * design/164 件四 — the environment's PLATFORM LIFETIME in milliseconds: how long this sandbox/VM is
497
624
  * allowed to exist before the platform reclaims it, counted from {@link lifetimeStartedAt}. Declared by
@@ -522,34 +649,6 @@ export interface ExecutionEnv extends FileSystem, Shell {
522
649
  * mechanism exists to prevent.
523
650
  */
524
651
  readonly lifetimeStartedAt?: number;
525
- /**
526
- * #211 (design/199 seam) — does this environment's path NAMESPACE live on the CONTROL-PLANE HOST's
527
- * filesystem? Declared by the ADAPTER: `false` for a virtual/sandboxed env whose paths never map
528
- * onto the host (an in-memory env, a container the host cannot mount) — consumers that record
529
- * host-path receipts (the workflow workspace observer's `worktreeDir`) then refuse to present this
530
- * env's cwd as a host path. Omitted ⇒ the historical structural inference stays in force
531
- * (isRemoteExecutionEnv shape detection; a plain NodeExecutionEnv is host-local). `true` is a
532
- * harmless explicit spelling of the local default.
533
- */
534
- readonly hostLocalPaths?: boolean;
535
- /**
536
- * design/380 O9 — declared by the ADAPTER: content produced by THIS env (every FileSystem/Shell
537
- * result — stdout, file bytes, listings, names) originates from a target OUTSIDE the deployment's
538
- * trust boundary (a personal device, an unmanaged host). Omitted ⇒ historic behavior (trusted-side
539
- * results). `true` feeds three EXISTING channels, no new vocabulary:
540
- * - memory: the run's hand-tool results are treated as external-class content — the session mark
541
- * (`memory.session_polluted`) + the design/336 origin carriage at harvest, via the same fold
542
- * `execIsExternalContent` upgrades through (this flag ORs into that fold for the run);
543
- * - env facts / prompt renderer: one declarative line disclosing the execution locus + trust posture;
544
- * - audit: TaskResult/checkpoint carry it implicitly through WorkspaceHandle{provider, deviceId}.
545
- * Suspend/resume: the run-level fold is PRESENCE-persisted on the checkpoint
546
- * (`CheckpointState.externalContentTarget`, monotonic) and resume joins persisted OR live
547
- * declaration — a run minted under a declaring adapter never silently downgrades on an
548
- * undeclared/older one. ONE declaration, two readers: the content-class fold above (the design/378 red line binds that fold — no gate/policy/roster reads it) and the
549
- * cross-boundary taint (it arms the run tree's taint bit; a call's `env` leg is judged by whether the env it reaches declares this flag AT THAT MOMENT, never by the fold).
550
- * ORTHOGONAL to `capabilities.isolation` — an SSH env to an organization-managed build host can be non-isolated yet omit this flag.
551
- */
552
- readonly externalContentTarget?: boolean;
553
652
  /**
554
653
  * #644 — declared by the ADAPTER: the HOME DIRECTORY of the user this environment runs as, as an absolute
555
654
  * path in the environment's own namespace. The base a `~/`-relative permission rule (`Edit(~/.ssh/**)`)
@@ -1552,6 +1651,10 @@ export interface AgentHarnessOptions<TSkill extends Skill = Skill, TPromptTempla
1552
1651
  /** Loop-config pass-through — see `AgentLoopConfig.onToolMediaRefused` (the tool-result seat's account of the media it
1553
1652
  * refused); the harness's own finalization of a resumed approved call reports through the same sink. */
1554
1653
  onToolMediaRefused?: import("../loop/types.js").AgentLoopConfig["onToolMediaRefused"];
1654
+ /** Loop-config pass-through — see `AgentLoopConfig.imageProcessor` (the tool-result seat's processor). */
1655
+ imageProcessor?: import("../loop/types.js").AgentLoopConfig["imageProcessor"];
1656
+ /** Loop-config pass-through — see `AgentLoopConfig.onImageUnprocessed` (an image that goes on unprocessed over the soft target). */
1657
+ onImageUnprocessed?: import("../loop/types.js").AgentLoopConfig["onImageUnprocessed"];
1555
1658
  /**
1556
1659
  * design/131 (拍): per-task resilience intent flags, forwarded to every provider
1557
1660
  * call (`StreamOptions.resilience`) so the deployment's decorator stack (degrading / failover /
@@ -1569,5 +1672,19 @@ export interface AgentHarnessOptions<TSkill extends Skill = Skill, TPromptTempla
1569
1672
  * contract, see AgentLoopConfig.streamingToolExecution).
1570
1673
  */
1571
1674
  streamingToolExecution?: boolean;
1572
- }
1675
+ /** The one seat every row passes at each harness commit point (a row the loop ends, an API failure's record, a row handed
1676
+ * to {@link AgentHarness.appendMessage}), before the live context and the store; absent ⇒ every row passes as made. */
1677
+ admitRows?: RowAdmission;
1678
+ /** The rows a parked leg's port held when its checkpoint was taken (`Checkpoint.heldRows`): the queue's first entries, written
1679
+ * at the transcript's first legal point (the prompt start, or — while the branch ends in a batch with unanswered calls — that
1680
+ * batch's settlement boundary), never through the admission seat again. Absent ⇒ the queue starts empty. */
1681
+ heldWrites?: readonly AgentMessage[];
1682
+ }
1683
+ /** A row its caller raises itself: a token the admitting seat minted and knows by identity; the harness hands it on unread. */
1684
+ export interface RowRaising {
1685
+ readonly door: "note";
1686
+ }
1687
+ /** The admission seat ({@link AgentHarnessOptions.admitRows}): the rows to keep, in order — every row handed in, except a
1688
+ * raised one its raiser's handlers refused. A rewrite is made in place, on the row itself. */
1689
+ export type RowAdmission = (rows: readonly AgentMessage[], raising?: RowRaising) => Promise<readonly AgentMessage[]>;
1573
1690
  export type { AgentHarness } from "./agent-harness.js";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The one wording of a media block that left the model's view of a request while the transcript keeps it. A block leaves
3
+ * for one of two reasons ({@link MEDIA_REMOVED_REASONS}): the provider refused the request because an image in it could
4
+ * not be processed (`engine/llm/rejected-images.ts`), or the request's media budget had no room left for it (the request
5
+ * trim, `core/media-byte-cap.ts`). Either way the block's slot holds the line {@link mediaRemovedPlaceholder} writes, and
6
+ * the person hears it under the one code `context.media_removed`, whose `detail.reason` is the same word.
7
+ */
8
+ /** The `errorKind` a provider's image refusal carries (`AssistantMessage.errorKind`). */
9
+ export declare const IMAGE_REFUSAL_KIND = "image_unprocessable";
10
+ /** Why a media block left the request view — `context.media_removed` `detail.reason`, closed. */
11
+ export declare const MEDIA_REMOVED_REASONS: readonly ["rejected_by_provider", "media_budget"];
12
+ export type MediaRemovedReason = (typeof MEDIA_REMOVED_REASONS)[number];
13
+ /** The text that stands in for the `ordinal`-th (1-based) block of its `type` in its message, removed for `reason`. */
14
+ export declare function mediaRemovedPlaceholder(reason: MediaRemovedReason, type: "image" | "document", ordinal: number): string;
@@ -0,0 +1,9 @@
1
+ export const IMAGE_REFUSAL_KIND = "image_unprocessable";
2
+ export const MEDIA_REMOVED_REASONS = Object.freeze(["rejected_by_provider", "media_budget"]);
3
+ const WHY = Object.freeze({
4
+ rejected_by_provider: `rejected by provider: ${IMAGE_REFUSAL_KIND}`,
5
+ media_budget: "over the request media budget — re-read the file if you still need to see it",
6
+ });
7
+ export function mediaRemovedPlaceholder(reason, type, ordinal) {
8
+ return `[${type} ${ordinal} removed: ${WHY[reason]}]`;
9
+ }