@sema-agent/core 7.67.3 → 7.68.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/CHANGELOG.md +1537 -0
  2. package/README.md +18 -9
  3. package/README.zh-CN.md +16 -8
  4. package/dist/agents/agent-definition.d.ts +1 -1
  5. package/dist/agents/agent-definition.js +4 -1
  6. package/dist/agents/cascade.d.ts +2 -2
  7. package/dist/agents/cascade.js +3 -1
  8. package/dist/agents/cumulative-stats.d.ts +2 -1
  9. package/dist/agents/cumulative-stats.js +4 -1
  10. package/dist/agents/list-agents-tool.d.ts +30 -0
  11. package/dist/agents/list-agents-tool.js +45 -3
  12. package/dist/agents/peer-admission.d.ts +2 -2
  13. package/dist/agents/peer-session-drain.d.ts +2 -0
  14. package/dist/agents/peer-session-drain.js +1 -0
  15. package/dist/agents/repair-loop.js +3 -1
  16. package/dist/agents/retain-ledger.d.ts +61 -8
  17. package/dist/agents/retain-ledger.js +25 -3
  18. package/dist/agents/roster-store.d.ts +4 -2
  19. package/dist/agents/send-message-tool.d.ts +1 -1
  20. package/dist/agents/send-message-tool.js +20 -15
  21. package/dist/agents/subagent-steps.js +2 -10
  22. package/dist/agents/subagent.d.ts +3 -0
  23. package/dist/agents/subagent.js +106 -76
  24. package/dist/agents/tool-filter.d.ts +20 -11
  25. package/dist/agents/tool-filter.js +8 -4
  26. package/dist/agents/verify.d.ts +3 -1
  27. package/dist/agents/verify.js +2 -0
  28. package/dist/brain/anthropic.js +4 -4
  29. package/dist/brain/open-responses.js +3 -1
  30. package/dist/brain/openai.js +3 -1
  31. package/dist/brain/reasoning-request.d.ts +73 -19
  32. package/dist/brain/reasoning-request.js +164 -72
  33. package/dist/brain/reasoning-stamp.d.ts +26 -0
  34. package/dist/brain/reasoning-stamp.js +10 -0
  35. package/dist/brain/reasoning.d.ts +95 -162
  36. package/dist/brain/reasoning.js +31 -86
  37. package/dist/brain/route-adjudicator.d.ts +9 -7
  38. package/dist/brain/route-adjudicator.js +12 -10
  39. package/dist/brain/status-sink.d.ts +19 -64
  40. package/dist/brain/status-sink.js +5 -21
  41. package/dist/brain/stream-engine.d.ts +11 -2
  42. package/dist/brain/stream-engine.js +10 -0
  43. package/dist/core/a2a.d.ts +17 -5
  44. package/dist/core/a2a.js +11 -3
  45. package/dist/core/allow-entry.d.ts +35 -15
  46. package/dist/core/allow-entry.js +47 -60
  47. package/dist/core/ask-headline.d.ts +68 -0
  48. package/dist/core/ask-headline.js +23 -0
  49. package/dist/core/ask-origin.d.ts +36 -8
  50. package/dist/core/ask-origin.js +17 -10
  51. package/dist/core/ask-question.d.ts +34 -7
  52. package/dist/core/ask-question.js +10 -1
  53. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  54. package/dist/core/ask-unresolvable-notice.js +9 -3
  55. package/dist/core/auto-strip.d.ts +53 -0
  56. package/dist/core/auto-strip.js +76 -0
  57. package/dist/core/background-agent-store.d.ts +45 -5
  58. package/dist/core/background-agent-store.js +69 -15
  59. package/dist/core/background-shell.d.ts +2 -2
  60. package/dist/core/caller-text.js +2 -2
  61. package/dist/core/canonical-json.d.ts +13 -0
  62. package/dist/core/canonical-json.js +7 -0
  63. package/dist/core/checkpoint-features.d.ts +66 -20
  64. package/dist/core/checkpoint-features.js +12 -1
  65. package/dist/core/checkpoint-generation.d.ts +1 -1
  66. package/dist/core/checkpoint-queries.d.ts +1 -1
  67. package/dist/core/checkpoint-queries.js +4 -1
  68. package/dist/core/checkpoint-requirements.d.ts +45 -2
  69. package/dist/core/checkpoint-requirements.js +16 -6
  70. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  71. package/dist/core/checkpoint-row-verdict.js +4 -0
  72. package/dist/core/checkpoint-store.d.ts +66 -38
  73. package/dist/core/checkpoint-store.js +15 -6
  74. package/dist/core/child-clamp-seats.d.ts +6 -0
  75. package/dist/core/child-clamp-seats.js +1 -0
  76. package/dist/core/config-refusal-codes.d.ts +1 -1
  77. package/dist/core/config-refusal-codes.js +1 -0
  78. package/dist/core/delegation-frames.d.ts +9 -12
  79. package/dist/core/delegation-frames.js +9 -8
  80. package/dist/core/engine-capabilities.d.ts +21 -8
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +147 -34
  83. package/dist/core/engine-notice.js +27 -16
  84. package/dist/core/engine-storage-backend.d.ts +2 -1
  85. package/dist/core/env-budget.js +3 -3
  86. package/dist/core/env-knob-announce.d.ts +10 -10
  87. package/dist/core/env-knob-announce.js +3 -6
  88. package/dist/core/file-history-store.d.ts +29 -4
  89. package/dist/core/file-history-store.js +13 -0
  90. package/dist/core/frame-settlement.d.ts +2 -1
  91. package/dist/core/gate-fold.js +1 -1
  92. package/dist/core/gate-lanes.js +56 -49
  93. package/dist/core/governance-codes.d.ts +39 -3
  94. package/dist/core/governance-codes.js +61 -3
  95. package/dist/core/hooks.d.ts +29 -11
  96. package/dist/core/hooks.js +5 -2
  97. package/dist/core/human-input-projection.js +3 -3
  98. package/dist/core/input-author.d.ts +17 -3
  99. package/dist/core/input-author.js +15 -3
  100. package/dist/core/leg-identity.d.ts +10 -28
  101. package/dist/core/leg-identity.js +1 -21
  102. package/dist/core/lsp.d.ts +18 -13
  103. package/dist/core/lsp.js +30 -22
  104. package/dist/core/mailbox-store.d.ts +1 -1
  105. package/dist/core/mailbox-store.js +4 -4
  106. package/dist/core/mcp-connection-pool.d.ts +93 -4
  107. package/dist/core/mcp-connection-pool.js +104 -1
  108. package/dist/core/mcp-failure.d.ts +38 -12
  109. package/dist/core/mcp-failure.js +9 -13
  110. package/dist/core/mcp-probe.d.ts +4 -3
  111. package/dist/core/mcp-server-link.d.ts +4 -2
  112. package/dist/core/mcp-server-link.js +4 -5
  113. package/dist/core/mcp-server-spec.d.ts +3 -3
  114. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  115. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  116. package/dist/core/mcp.d.ts +40 -6
  117. package/dist/core/mcp.js +39 -13
  118. package/dist/core/memory-engine/content-origin.js +2 -2
  119. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  120. package/dist/core/memory-engine/control-objects.js +2 -10
  121. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  122. package/dist/core/memory-engine/dual-root.js +3 -0
  123. package/dist/core/memory-engine/engine.d.ts +6 -4
  124. package/dist/core/memory-engine/engine.js +32 -29
  125. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  126. package/dist/core/memory-engine/file-backend.js +21 -31
  127. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  128. package/dist/core/memory-engine/frontmatter.js +4 -0
  129. package/dist/core/memory-engine/layout.d.ts +114 -20
  130. package/dist/core/memory-engine/layout.js +340 -22
  131. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  132. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  133. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  134. package/dist/core/memory-engine/sync-client.js +4 -5
  135. package/dist/core/model-fallbacks.d.ts +5 -1
  136. package/dist/core/model-fallbacks.js +3 -3
  137. package/dist/core/model-receipt.d.ts +2 -1
  138. package/dist/core/model-receipt.js +12 -1
  139. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  140. package/dist/core/mods/kernel/dispatch.js +14 -6
  141. package/dist/core/mods/kernel/events.d.ts +8 -5
  142. package/dist/core/mods/kernel/events.js +2 -2
  143. package/dist/core/mods/kernel/index.d.ts +1 -1
  144. package/dist/core/mods/kernel/registration.d.ts +9 -0
  145. package/dist/core/mods/package.js +1 -1
  146. package/dist/core/mods/session-append.d.ts +4 -2
  147. package/dist/core/mods/session-append.js +3 -0
  148. package/dist/core/mods/stations.d.ts +7 -11
  149. package/dist/core/mods/stations.js +4 -7
  150. package/dist/core/mods/tool-call.d.ts +10 -8
  151. package/dist/core/mods/tool-call.js +15 -18
  152. package/dist/core/mounted-mcp.d.ts +0 -4
  153. package/dist/core/mounted-mcp.js +1 -1
  154. package/dist/core/park-noun.d.ts +24 -0
  155. package/dist/core/park-noun.js +21 -0
  156. package/dist/core/park-resumability.d.ts +60 -0
  157. package/dist/core/park-resumability.js +30 -0
  158. package/dist/core/permission-rule-provider.d.ts +24 -2
  159. package/dist/core/permission-rule-provider.js +11 -8
  160. package/dist/core/permission-rule-store.d.ts +8 -1
  161. package/dist/core/permission-rule-store.js +2 -3
  162. package/dist/core/permission-rules.d.ts +2 -1
  163. package/dist/core/permission-rules.js +8 -4
  164. package/dist/core/persisted-rule-arms.d.ts +3 -0
  165. package/dist/core/persisted-rule-arms.js +2 -1
  166. package/dist/core/present-plan-tool.d.ts +47 -3
  167. package/dist/core/present-plan-tool.js +62 -4
  168. package/dist/core/principal-name.d.ts +1 -1
  169. package/dist/core/principal-name.js +5 -5
  170. package/dist/core/process-identity.js +10 -5
  171. package/dist/core/protocol-http-auth.d.ts +20 -14
  172. package/dist/core/protocol-http-auth.js +70 -50
  173. package/dist/core/read-only-shell.js +9 -5
  174. package/dist/core/redaction-marks.d.ts +4 -26
  175. package/dist/core/redaction-marks.js +9 -21
  176. package/dist/core/remote-env.d.ts +43 -16
  177. package/dist/core/remote-env.js +1 -1
  178. package/dist/core/request-copy-projection.d.ts +1 -1
  179. package/dist/core/request-copy-projection.js +40 -50
  180. package/dist/core/resume-config-judge.js +1 -1
  181. package/dist/core/resume-startup-cause.d.ts +35 -18
  182. package/dist/core/resume-startup-cause.js +13 -10
  183. package/dist/core/retention.d.ts +167 -25
  184. package/dist/core/retention.js +100 -20
  185. package/dist/core/roles.d.ts +6 -0
  186. package/dist/core/roles.js +11 -5
  187. package/dist/core/rule-lane-reads.d.ts +3 -0
  188. package/dist/core/rule-lane-reads.js +5 -1
  189. package/dist/core/rule-store-fault.d.ts +70 -0
  190. package/dist/core/rule-store-fault.js +102 -0
  191. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  192. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  193. package/dist/core/runner/announce-once-ledger.js +24 -2
  194. package/dist/core/runner/assemble-result.d.ts +6 -0
  195. package/dist/core/runner/assemble-result.js +1 -1
  196. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  197. package/dist/core/runner/auto-strip-notice.js +59 -0
  198. package/dist/core/runner/branch-window.d.ts +3 -0
  199. package/dist/core/runner/branch-window.js +37 -0
  200. package/dist/core/runner/caller-roster.d.ts +8 -3
  201. package/dist/core/runner/capability-withheld-seat.js +3 -9
  202. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  203. package/dist/core/runner/clock-and-limits.js +30 -0
  204. package/dist/core/runner/contracts.d.ts +58 -35
  205. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  206. package/dist/core/runner/credential-refusal-seat.js +47 -0
  207. package/dist/core/runner/cross-boundary-lane.js +6 -4
  208. package/dist/core/runner/decide-continuation.js +1 -1
  209. package/dist/core/runner/file-history-restore.d.ts +53 -2
  210. package/dist/core/runner/file-history-restore.js +29 -10
  211. package/dist/core/runner/forward-sink.d.ts +14 -1
  212. package/dist/core/runner/forward-sink.js +14 -12
  213. package/dist/core/runner/gate-exit.d.ts +8 -7
  214. package/dist/core/runner/gate-exit.js +13 -13
  215. package/dist/core/runner/git-status-frame.js +2 -4
  216. package/dist/core/runner/initial-run-state.js +1 -1
  217. package/dist/core/runner/main-call-account.d.ts +3 -1
  218. package/dist/core/runner/main-call-account.js +5 -3
  219. package/dist/core/runner/mcp-redial.d.ts +2 -5
  220. package/dist/core/runner/mcp-redial.js +2 -2
  221. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  222. package/dist/core/runner/nested-memory-content.js +73 -13
  223. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  224. package/dist/core/runner/nested-memory-lane.js +152 -76
  225. package/dist/core/runner/park-commit.js +3 -1
  226. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  227. package/dist/core/runner/permission-rule-lanes.js +29 -3
  228. package/dist/core/runner/person-path-rows.d.ts +3 -11
  229. package/dist/core/runner/person-path-rows.js +21 -24
  230. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  231. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  232. package/dist/core/runner/prepare-artifact.js +20 -14
  233. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  234. package/dist/core/runner/prepare-ask-lane.js +6 -5
  235. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  236. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  237. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  238. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  239. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  240. package/dist/core/runner/prepare-config-doors.js +58 -41
  241. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  242. package/dist/core/runner/prepare-context-lane.js +3 -5
  243. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  244. package/dist/core/runner/prepare-defer-classify.js +1 -1
  245. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  246. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  247. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  248. package/dist/core/runner/prepare-file-history.js +117 -46
  249. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  250. package/dist/core/runner/prepare-gate-stations.js +6 -5
  251. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  252. package/dist/core/runner/prepare-hands-readface.js +8 -4
  253. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  254. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  255. package/dist/core/runner/prepare-listings.d.ts +1 -1
  256. package/dist/core/runner/prepare-listings.js +1 -1
  257. package/dist/core/runner/prepare-memory.js +2 -2
  258. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  259. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  260. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  261. package/dist/core/runner/prepare-park-ask.js +7 -9
  262. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  263. package/dist/core/runner/prepare-policy-chain.js +18 -13
  264. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  265. package/dist/core/runner/prepare-project-context.js +5 -3
  266. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  267. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  268. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  269. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  270. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  271. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  272. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  273. package/dist/core/runner/prepare-run-refs.js +8 -7
  274. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  275. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  276. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  277. package/dist/core/runner/prepare-task.js +66 -53
  278. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  279. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  280. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  281. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  282. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  283. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  284. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  285. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  286. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  287. package/dist/core/runner/restore-seat.d.ts +41 -0
  288. package/dist/core/runner/restore-seat.js +38 -0
  289. package/dist/core/runner/resume-admission.js +1 -1
  290. package/dist/core/runner/resume-apply.js +4 -3
  291. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  292. package/dist/core/runner/resume-internals-and-config.js +2 -1
  293. package/dist/core/runner/resume-preflight.js +2 -1
  294. package/dist/core/runner/rewind-files.js +22 -6
  295. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  296. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  297. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  298. package/dist/core/runner/run-brain-sinks.js +6 -6
  299. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  300. package/dist/core/runner/run-git-lane.d.ts +2 -0
  301. package/dist/core/runner/run-git-lane.js +2 -1
  302. package/dist/core/runner/run-harness-handlers.js +5 -4
  303. package/dist/core/runner/run-identity-wiring.js +20 -12
  304. package/dist/core/runner/run-leg.js +31 -72
  305. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  306. package/dist/core/runner/run-notification-lane.js +2 -4
  307. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  308. package/dist/core/runner/run-reasoning-seat.js +13 -18
  309. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  310. package/dist/core/runner/run-terminal-adoption.js +4 -8
  311. package/dist/core/runner/run-turn-boundary.js +6 -3
  312. package/dist/core/runner/runtask.d.ts +9 -4
  313. package/dist/core/runner/runtask.js +29 -22
  314. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  315. package/dist/core/runner/shell-env-withheld.js +2 -7
  316. package/dist/core/runner/side-call-account.d.ts +5 -6
  317. package/dist/core/runner/side-call-account.js +2 -2
  318. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  319. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  320. package/dist/core/runner/stream-settle-backstop.js +4 -6
  321. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  322. package/dist/core/runner/stream-steer-verb.js +4 -4
  323. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  324. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  325. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  326. package/dist/core/runner/teardown-bounded.js +7 -0
  327. package/dist/core/runner/terminal-account.js +41 -13
  328. package/dist/core/runner/terminal-projection.d.ts +1 -5
  329. package/dist/core/runner/tool-end-body.d.ts +9 -3
  330. package/dist/core/runner/tool-end-body.js +6 -3
  331. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  332. package/dist/core/runner/tool-output-projection.js +10 -14
  333. package/dist/core/runner/turn-attachments.d.ts +3 -2
  334. package/dist/core/runner/turn-attachments.js +12 -5
  335. package/dist/core/runner-deps.d.ts +6 -6
  336. package/dist/core/runtime-caps.d.ts +2 -1
  337. package/dist/core/secret-env.d.ts +20 -3
  338. package/dist/core/secret-env.js +13 -15
  339. package/dist/core/session-checkout.d.ts +115 -15
  340. package/dist/core/session-checkout.js +435 -136
  341. package/dist/core/session-policy-store.js +21 -3
  342. package/dist/core/session-reconcile.js +1 -0
  343. package/dist/core/session-store.js +2 -0
  344. package/dist/core/session.d.ts +11 -1
  345. package/dist/core/shell-run-candidates.d.ts +1 -0
  346. package/dist/core/shell-run-candidates.js +1 -1
  347. package/dist/core/shutdown-debug.d.ts +6 -5
  348. package/dist/core/shutdown-debug.js +5 -1
  349. package/dist/core/skill-grant.js +4 -1
  350. package/dist/core/skills-directory.js +5 -3
  351. package/dist/core/spec-contract.d.ts +1 -1
  352. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  353. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  354. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  355. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  356. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  357. package/dist/core/task-event.d.ts +48 -27
  358. package/dist/core/task-notification.d.ts +15 -9
  359. package/dist/core/task-notification.js +12 -0
  360. package/dist/core/task-registry-agent.d.ts +24 -22
  361. package/dist/core/task-registry-agent.js +65 -46
  362. package/dist/core/task-registry-shared.d.ts +17 -5
  363. package/dist/core/task-registry.d.ts +17 -6
  364. package/dist/core/task-registry.js +6 -1
  365. package/dist/core/task-result.d.ts +71 -25
  366. package/dist/core/task-spec-members.d.ts +0 -1
  367. package/dist/core/task-spec-members.js +1 -1
  368. package/dist/core/task-spec.d.ts +60 -52
  369. package/dist/core/task-stream.d.ts +45 -12
  370. package/dist/core/terminal-cause.d.ts +45 -8
  371. package/dist/core/terminal-cause.js +5 -0
  372. package/dist/core/tool-card-bound.d.ts +32 -0
  373. package/dist/core/tool-card-bound.js +33 -0
  374. package/dist/core/tool-catalog-entries.d.ts +9 -0
  375. package/dist/core/tool-catalog-entries.js +48 -0
  376. package/dist/core/tool-errors.d.ts +4 -3
  377. package/dist/core/tool-face.d.ts +3 -3
  378. package/dist/core/tool-mount-facts.d.ts +3 -2
  379. package/dist/core/tool-mount-facts.js +1 -1
  380. package/dist/core/tool-mount-static.js +7 -5
  381. package/dist/core/tool-policy.d.ts +21 -19
  382. package/dist/core/tool-policy.js +5 -6
  383. package/dist/core/tool-registry.d.ts +3 -1
  384. package/dist/core/tool-registry.js +15 -1
  385. package/dist/core/tool-result-store.d.ts +9 -3
  386. package/dist/core/tool-result-store.js +14 -1
  387. package/dist/core/tool-roster.d.ts +18 -0
  388. package/dist/core/tool-roster.js +30 -1
  389. package/dist/core/tool-spec.d.ts +17 -8
  390. package/dist/core/trace.d.ts +35 -31
  391. package/dist/core/types.d.ts +2 -2
  392. package/dist/core/untrusted-egress.d.ts +10 -9
  393. package/dist/core/untrusted-egress.js +9 -9
  394. package/dist/core/untrusted-text.d.ts +0 -18
  395. package/dist/core/untrusted-text.js +7 -3
  396. package/dist/core/user-attachment.d.ts +9 -6
  397. package/dist/core/user-attachment.js +12 -10
  398. package/dist/core/user-row-origin.d.ts +44 -25
  399. package/dist/core/user-row-origin.js +30 -20
  400. package/dist/core/wiring-manifest.d.ts +26 -7
  401. package/dist/core/wiring-manifest.js +14 -11
  402. package/dist/core/workspace-snapshot.d.ts +3 -1
  403. package/dist/core/workspace-snapshot.js +1 -0
  404. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  405. package/dist/engine/execution-env/node-execution-env.js +127 -67
  406. package/dist/engine/harness/agent-harness.d.ts +4 -5
  407. package/dist/engine/harness/agent-harness.js +2 -7
  408. package/dist/engine/harness/types.d.ts +51 -19
  409. package/dist/engine/harness/types.js +28 -1
  410. package/dist/engine/llm/types.d.ts +26 -14
  411. package/dist/engine/llm/types.js +2 -2
  412. package/dist/engine/loop/agent-loop.d.ts +2 -2
  413. package/dist/engine/loop/agent-loop.js +51 -275
  414. package/dist/engine/loop/types.d.ts +0 -18
  415. package/dist/engine/session/import-validate.d.ts +3 -0
  416. package/dist/engine/session/import-validate.js +34 -2
  417. package/dist/engine/session/repo-utils.d.ts +42 -4
  418. package/dist/engine/session/repo-utils.js +33 -5
  419. package/dist/engine/session/session.d.ts +41 -14
  420. package/dist/engine/session/session.js +96 -25
  421. package/dist/index.d.ts +21 -16
  422. package/dist/index.js +16 -10
  423. package/dist/orchestration/run-spec.d.ts +1 -1
  424. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  425. package/dist/orchestration/run-workflow-tool.js +15 -19
  426. package/dist/orchestration/workflow-governance.js +13 -21
  427. package/dist/orchestration/workflow-observe.d.ts +4 -3
  428. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  429. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  430. package/dist/orchestration/workflow-record-artifact.js +32 -0
  431. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  432. package/dist/orchestration/workflow-script-store.js +20 -1
  433. package/dist/orchestration/workflow-types.d.ts +33 -3
  434. package/dist/orchestration/workflow.d.ts +24 -14
  435. package/dist/orchestration/workflow.js +52 -23
  436. package/dist/prompt-assembly/artifact.js +4 -8
  437. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  438. package/dist/prompt-assembly/catalog/engine.js +30 -0
  439. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  440. package/dist/prompt-assembly/catalog/index.js +2 -2
  441. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  442. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  443. package/dist/prompt-assembly/epoch.js +6 -8
  444. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  445. package/dist/stores/file/background-agent-store.js +5 -6
  446. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  447. package/dist/stores/file/checkpoint-store.js +7 -3
  448. package/dist/stores/file/file-history-store.d.ts +8 -0
  449. package/dist/stores/file/file-history-store.js +72 -0
  450. package/dist/stores/file/fs-atomic.js +17 -12
  451. package/dist/stores/file/index.js +11 -5
  452. package/dist/stores/file/mailbox-store.js +13 -4
  453. package/dist/stores/file/permission-rule-store.js +14 -13
  454. package/dist/stores/file/shared-ledger.d.ts +4 -0
  455. package/dist/stores/file/shared-ledger.js +4 -0
  456. package/dist/stores/file/task-list-store.js +12 -3
  457. package/dist/stores/file/workflow-run-store.js +1 -0
  458. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  459. package/dist/tools/fs/bash-program-position.js +1 -1
  460. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  461. package/dist/tools/fs/bound-open.d.ts +97 -0
  462. package/dist/tools/fs/bound-open.js +103 -0
  463. package/dist/tools/fs/containment-face.d.ts +2 -2
  464. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  465. package/dist/tools/fs/fs-pdf.js +31 -23
  466. package/dist/tools/fs/fs-read.d.ts +24 -17
  467. package/dist/tools/fs/fs-read.js +84 -53
  468. package/dist/tools/fs/fs-shared.d.ts +14 -12
  469. package/dist/tools/fs/fs-shared.js +5 -4
  470. package/dist/tools/fs/fs-write.d.ts +2 -2
  471. package/dist/tools/fs/fs-write.js +20 -12
  472. package/dist/tools/fs/index.d.ts +4 -4
  473. package/dist/tools/fs/index.js +2 -2
  474. package/dist/tools/fs/notebook.d.ts +1 -1
  475. package/dist/tools/fs/pdf.d.ts +12 -3
  476. package/dist/tools/fs/pdf.js +22 -9
  477. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  478. package/dist/tools/fs/read-deny-home.js +8 -11
  479. package/dist/tools/fs/safety.d.ts +3 -2
  480. package/dist/tools/fs/shell-read-check.js +10 -9
  481. package/dist/tools/monitor.d.ts +6 -5
  482. package/dist/tools/task-list.d.ts +16 -6
  483. package/dist/tools/task-list.js +4 -0
  484. package/dist/tools/web.d.ts +9 -1
  485. package/dist/tools/web.js +8 -3
  486. package/dist/tools/worktree.d.ts +7 -5
  487. package/dist/tools/worktree.js +4 -3
  488. package/package.json +4 -3
  489. package/test/export-surface.snapshot.json +93 -7
  490. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  491. package/wire-changes/core-stores-sql@7.68.1.json +39 -0
  492. package/wire-changes/core@7.68.0.json +4257 -0
  493. package/wire-changes/core@7.68.1.json +95 -0
  494. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  495. package/wire-changes/mods-kernel@7.68.1.json +39 -0
  496. package/wire-changes/primitives@7.68.0.json +253 -0
  497. package/wire-changes/primitives@7.68.1.json +39 -0
  498. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  499. package/wire-changes/wiki-gate@7.68.1.json +39 -0
  500. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  501. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -231,11 +231,11 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
231
231
  appendFile(path: string, content: string | Uint8Array): Promise<Result<void, FileError>>;
232
232
  fileInfo(path: string): Promise<Result<FileInfo, FileError>>;
233
233
  /**
234
- * design/381 DV-8 — {@link FileInfo.mode}'s write half. NO-FOLLOW by construction: `lchmod` exists
235
- * only on BSD, so a symlink at the leaf is REFUSED (`invalid`) instead of being traversed, which
236
- * would re-permission whatever the link points at — the same posture every other guard in this
237
- * family takes when it cannot verify what it is about to touch. Absent on platforms without the
238
- * permission face ({@link HAS_POSIX_MODE_FACE}), where the caller's disclosure is the honest answer.
234
+ * design/381 DV-8 — {@link FileInfo.mode}'s write half, applied to the descriptor of the one placed open a bound read takes
235
+ * ({@link openPlaced}): no link anywhere on the canonical path is followed (`precondition_failed`), a FIFO swapped in is
236
+ * refused without waiting (`invalid`), and a platform that cannot place an opened object answers `not_supported` — a
237
+ * restore must never re-permission a file a link led it to. Absent on platforms without the permission face
238
+ * ({@link HAS_POSIX_MODE_FACE}), where the caller's disclosure is the honest answer.
239
239
  */
240
240
  setFileMode(path: string, mode: number, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
241
241
  listDir(path: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>>;
@@ -243,22 +243,29 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
243
243
  /** {@link FileSystem.fileIdentity}: `stat` (links followed) read as BIGINT — an inode past 2^53 (an APFS volume root)
244
244
  * is not exact as a number, and two inodes that collapse to one number would name two directories as one. */
245
245
  fileIdentity(path: string): Promise<Result<string, FileError>>;
246
- /** {@link FileSystem.openBound}: opened without following a leaf link and without blocking (a FIFO swapped in is refused,
247
- * not waited on); right after the open the held object must be at the path ({@link heldIsAt}), and it must be a regular
248
- * file or a directory. The held object reads by position from its descriptor and sizes by `fstat`; a directory lists by
249
- * {@link listOpenDirectory}. win32 holds files only. */
246
+ /** {@link FileSystem.openBound}: the object of the one placed open ({@link openPlaced}), held. It reads by position from its
247
+ * descriptor and sizes by `fstat`; a directory lists by {@link listOpenDirectory}. */
250
248
  openBound(path: string, abortSignal?: AbortSignal): Promise<Result<BoundFileObject, FileError>>;
251
- /** Is the object just opened ({@link openBound}) at the canonical `resolved`? Linux answers for the descriptor itself: the
252
- * kernel's path of the held object (`/proc/self/fd/<fd>`) must be `resolved` — whatever the path named before or after;
253
- * an unreadable answer is no. Elsewhere Node has no descriptor→path (darwin: no `F_GETPATH`), so the path is read
254
- * instead: it must name the held object (`lstat` identity) and be canonical — an ancestor turned into a link before the
255
- * open and put back between those two reads passes. */
256
- private heldIsAt;
249
+ /** The one open a bound read ({@link openBound}) and a mode change ({@link setFileMode}) take at a canonical `resolved`:
250
+ * read-only, never blocking (a FIFO swapped in is refused, not waited on), and placed at `resolved` by ONE kernel
251
+ * observation — on darwin the open itself, which refuses a link on any component of the path ({@link O_NOFOLLOW_ANY}; a
252
+ * kernel that does not refuse them answers `not_supported`); on Linux the kernel's path of the opened descriptor
253
+ * ({@link heldPlace}). A platform with neither (win32, the BSDs) answers `not_supported` and opens nothing. A link where
254
+ * the open stood is `precondition_failed`; an opened object that is not a regular file or a directory is `invalid` (one the
255
+ * kernel will not open read-only, a socket, keeps the kernel's answer); a signal cancelled by the time it is placed is
256
+ * `aborted`, nothing handed back. The caller owns the handle. */
257
+ private openPlaced;
258
+ /** Where is the object just opened ({@link openPlaced}, Linux) against the canonical `resolved`? The descriptor answers for
259
+ * itself: the kernel's path of the held object (`/proc/self/fd/<fd>`) must be `resolved` — whatever the path named before
260
+ * or after (`elsewhere` when it is another); an unreadable answer (no `/proc`) is `unobservable`: this host cannot place
261
+ * the object, answered `not_supported`, the member's absence on this target. */
262
+ private heldPlace;
257
263
  /** The platform's listing of a directory already held open ({@link openBound}): Linux through the descriptor
258
264
  * (`/proc/self/fd/<fd>` — the listing is of the held object whatever the path names); darwin, which cannot enumerate an
259
265
  * open directory from Node (`/dev/fd/<fd>` of a directory answers ENOTDIR), lists the PATH once and requires it to
260
266
  * name the held object afterwards — a path swapped away and back during that one listing can list another directory's
261
- * entry NAMES (never bytes; every entry still meets its own read judgment). */
267
+ * entry NAMES (never bytes). Those entries are judged as names under the held directory's own spelling: a read-deny row
268
+ * that names the other directory's real location does not reach them (KL-1311a2-g). */
262
269
  protected listOpenDirectory(held: FileHandle, resolved: string, identity: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>>;
263
270
  readLink(path: string): Promise<Result<string, FileError>>;
264
271
  /**
@@ -94,6 +94,36 @@ function fileKindFromStats(stats) {
94
94
  return undefined;
95
95
  }
96
96
  const HAS_POSIX_MODE_FACE = posixModeBitsMeaningful();
97
+ const O_NOFOLLOW_ANY = 0x20000000;
98
+ let linksRefusedOnTheWay;
99
+ function refusesLinksOnTheWay() {
100
+ return (linksRefusedOnTheWay ??= probeLinksRefusedOnTheWay().then((answer) => {
101
+ if (answer === undefined)
102
+ linksRefusedOnTheWay = undefined;
103
+ return answer === true;
104
+ }));
105
+ }
106
+ async function probeLinksRefusedOnTheWay() {
107
+ try {
108
+ if (!(await lstat("/var")).isSymbolicLink())
109
+ return undefined;
110
+ await stat("/var/tmp");
111
+ }
112
+ catch {
113
+ return undefined;
114
+ }
115
+ try {
116
+ await (await open("/var/tmp", constants.O_RDONLY | (constants.O_NONBLOCK ?? 0) | O_NOFOLLOW_ANY)).close();
117
+ return false;
118
+ }
119
+ catch (error) {
120
+ if (isNodeError(error) && error.code === "ELOOP")
121
+ return true;
122
+ if (isNodeError(error) && error.code === "EINVAL")
123
+ return false;
124
+ return undefined;
125
+ }
126
+ }
97
127
  async function readUpTo(handle, size, limit, aborted) {
98
128
  const readAt = async (into, offset, length, position) => {
99
129
  const { bytesRead } = await handle.read(into, offset, length, position);
@@ -138,10 +168,15 @@ async function readAllFrom(handle, max, aborted) {
138
168
  async function readFirstBytes(resolved, maxBytes, abortSignal) {
139
169
  let handle;
140
170
  try {
141
- handle = await open(resolved, "r");
171
+ handle = await open(resolved, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
142
172
  const held = await handle.stat();
143
173
  if (held.isDirectory())
144
174
  return err(new FileError("is_directory", `EISDIR: illegal operation on a directory, read '${resolved}'`, resolved));
175
+ if (!held.isFile())
176
+ return err(new FileError("invalid", "Not a regular file (a FIFO, socket or device is not read by name)", resolved));
177
+ const aborted = abortResult(abortSignal, resolved);
178
+ if (aborted)
179
+ return aborted;
145
180
  return ok(await readUpTo(handle, Number(held.size), maxBytes, () => abortResult(abortSignal, resolved) !== undefined));
146
181
  }
147
182
  catch (error) {
@@ -441,11 +476,11 @@ function getShellEnv(inheritEnv, baseEnv, extraEnv, onScrub, onNotice) {
441
476
  }
442
477
  else if (onScrub !== undefined && !secretScrubSeatDefectAnnounced) {
443
478
  secretScrubSeatDefectAnnounced = true;
444
- try {
445
- console.warn(`onSecretEnvScrub seat holds ${onScrub === null ? "null" : typeof onScrub} — not a function; scrub findings fall back to the console summary (once per process)`);
446
- }
447
- catch {
448
- }
479
+ deliverEngineNotice(onNotice, {
480
+ code: "config.seat_malformed",
481
+ message: `onSecretEnvScrub seat holds ${onScrub === null ? "null" : typeof onScrub} — not a function; scrub findings fall back to the console summary (once per process)`,
482
+ detail: { seat: "onSecretEnvScrub" },
483
+ });
449
484
  }
450
485
  if (!(typeof onScrub === "function" && onNotice === undefined)) {
451
486
  announceSecretEnvScrub(onNotice, findings);
@@ -493,6 +528,10 @@ export function openSpoolPair(base) {
493
528
  }
494
529
  return { outPath, errPath, fds: [fdOut, fdErr] };
495
530
  }
531
+ function shellChildStdio(spoolFds, stdinFed) {
532
+ const stdin = stdinFed ? "pipe" : "ignore";
533
+ return { stdio: spoolFds ? [stdin, spoolFds[0], spoolFds[1]] : [stdin, "pipe", "pipe"] };
534
+ }
496
535
  export class NodeExecutionEnv {
497
536
  cwd;
498
537
  capabilities;
@@ -749,12 +788,13 @@ export class NodeExecutionEnv {
749
788
  }
750
789
  execSpoolFds = undefined;
751
790
  };
791
+ const input = options?.stdinFrom;
752
792
  try {
753
793
  child = spawn(start.command, [...start.args], {
754
794
  cwd,
755
795
  detached: process.platform !== "win32",
756
796
  env: this.spawnEnv(options?.env),
757
- stdio: execSpoolFds ? ["ignore", execSpoolFds[0], execSpoolFds[1]] : ["ignore", "pipe", "pipe"],
797
+ ...shellChildStdio(execSpoolFds, input !== undefined),
758
798
  windowsHide: true,
759
799
  });
760
800
  }
@@ -765,6 +805,16 @@ export class NodeExecutionEnv {
765
805
  return;
766
806
  }
767
807
  closeSpoolFds();
808
+ if (input !== undefined && child.stdin !== null) {
809
+ const stdin = child.stdin;
810
+ stdin.on("error", () => { });
811
+ try {
812
+ stdin.end(Buffer.from(input.buffer, input.byteOffset, input.byteLength));
813
+ }
814
+ catch {
815
+ stdin.destroy();
816
+ }
817
+ }
768
818
  const timeoutMs = resolveExecTimeoutMs(options?.timeout);
769
819
  timeoutRef.current =
770
820
  timeoutMs === undefined
@@ -1259,29 +1309,22 @@ export class NodeExecutionEnv {
1259
1309
  }
1260
1310
  async setFileMode(path, mode, abortSignal) {
1261
1311
  const resolved = resolvePath(this.cwd, path);
1262
- const aborted = abortResult(abortSignal, resolved);
1263
- if (aborted) {
1264
- return aborted;
1265
- }
1266
1312
  if (!HAS_POSIX_MODE_FACE) {
1267
1313
  return err(new FileError("not_supported", "This platform has no POSIX permission model", resolved));
1268
1314
  }
1315
+ const placed = await this.openPlaced(resolved, abortSignal);
1316
+ if (!placed.ok)
1317
+ return placed;
1269
1318
  try {
1270
- const handle = await open(resolved, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
1271
- try {
1272
- await handle.chmod(mode & 0o7777);
1273
- }
1274
- finally {
1275
- await handle.close().catch(() => { });
1276
- }
1319
+ await placed.value.handle.chmod(mode & 0o7777);
1277
1320
  return ok(undefined);
1278
1321
  }
1279
1322
  catch (error) {
1280
- if (isNodeError(error) && error.code === "ELOOP") {
1281
- return err(new FileError("invalid", "Refusing to change the mode of a symlink (the target is not the addressed path)", resolved));
1282
- }
1283
1323
  return err(toFileError(error, resolved));
1284
1324
  }
1325
+ finally {
1326
+ await placed.value.handle.close().catch(() => { });
1327
+ }
1285
1328
  }
1286
1329
  async listDir(path, abortSignal) {
1287
1330
  const resolved = resolvePath(this.cwd, path);
@@ -1335,16 +1378,66 @@ export class NodeExecutionEnv {
1335
1378
  }
1336
1379
  async openBound(path, abortSignal) {
1337
1380
  const resolved = resolvePath(this.cwd, path);
1381
+ const placed = await this.openPlaced(resolved, abortSignal);
1382
+ if (!placed.ok)
1383
+ return placed;
1384
+ const { handle, held } = placed.value;
1385
+ const identity = `${held.dev}:${held.ino}`;
1386
+ const kind = held.isDirectory() ? "directory" : "file";
1387
+ return ok({
1388
+ identity,
1389
+ kind,
1390
+ size: async () => {
1391
+ try {
1392
+ return ok(Number((await handle.stat()).size));
1393
+ }
1394
+ catch (error) {
1395
+ return err(toFileError(error, resolved));
1396
+ }
1397
+ },
1398
+ readBytes: async (max, signal) => {
1399
+ if (kind !== "file")
1400
+ return err(new FileError("is_directory", "The held object is a directory", resolved));
1401
+ try {
1402
+ return ok(await readAllFrom(handle, max, () => abortResult(signal, resolved) !== undefined));
1403
+ }
1404
+ catch (error) {
1405
+ return err(toFileError(error, resolved));
1406
+ }
1407
+ },
1408
+ list: async (signal) => {
1409
+ if (kind !== "directory")
1410
+ return err(new FileError("not_directory", "The held object is a file", resolved));
1411
+ try {
1412
+ return await this.listOpenDirectory(handle, resolved, identity, signal);
1413
+ }
1414
+ catch (error) {
1415
+ return err(toFileError(error, resolved));
1416
+ }
1417
+ },
1418
+ close: () => handle.close().catch(() => { }),
1419
+ });
1420
+ }
1421
+ async openPlaced(resolved, abortSignal) {
1338
1422
  const aborted = abortResult(abortSignal, resolved);
1339
1423
  if (aborted)
1340
1424
  return aborted;
1425
+ const observation = process.platform === "darwin" ? "open" : process.platform === "linux" ? "descriptor" : undefined;
1426
+ if (observation === undefined)
1427
+ return err(new FileError("not_supported", "This platform gives no kernel observation of where an opened object is, so it cannot be placed at the path that was checked", resolved));
1428
+ if (observation === "open" && !(await refusesLinksOnTheWay())) {
1429
+ return err(new FileError("not_supported", "This macOS does not refuse a link on the way of an open, so a read cannot be bound to the path that was checked", resolved));
1430
+ }
1431
+ const abortedWhileAsked = abortResult(abortSignal, resolved);
1432
+ if (abortedWhileAsked)
1433
+ return abortedWhileAsked;
1341
1434
  let handle;
1342
1435
  try {
1343
- handle = await open(resolved, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
1436
+ handle = await open(resolved, constants.O_RDONLY | (observation === "open" ? O_NOFOLLOW_ANY : (constants.O_NOFOLLOW ?? 0)) | (constants.O_NONBLOCK ?? 0));
1344
1437
  }
1345
1438
  catch (error) {
1346
1439
  if (isNodeError(error) && error.code === "ELOOP")
1347
- return err(new FileError("precondition_failed", "The path is now a link, not the object that was checked", resolved));
1440
+ return err(new FileError("precondition_failed", "A link stands on the path now, so it is not the object that was checked", resolved));
1348
1441
  return err(toFileError(error, resolved));
1349
1442
  }
1350
1443
  const refuse = async (code, message) => {
@@ -1353,57 +1446,24 @@ export class NodeExecutionEnv {
1353
1446
  };
1354
1447
  try {
1355
1448
  const held = await handle.stat({ bigint: true });
1356
- if (!(await this.heldIsAt(handle, held, resolved)))
1449
+ const place = observation === "open" ? "at" : await this.heldPlace(handle, resolved);
1450
+ if (place === "unobservable")
1451
+ return refuse("not_supported", "This platform gives no kernel path for an opened descriptor, so the opened object cannot be placed at its path");
1452
+ if (place === "elsewhere")
1357
1453
  return refuse("precondition_failed", "The path named another object than the one opened");
1358
1454
  if (!held.isFile() && !held.isDirectory())
1359
1455
  return refuse("invalid", "Neither a regular file nor a directory");
1360
- const identity = `${held.dev}:${held.ino}`;
1361
- const kind = held.isDirectory() ? "directory" : "file";
1362
- return ok({
1363
- identity,
1364
- kind,
1365
- size: async () => {
1366
- try {
1367
- return ok(Number((await handle.stat()).size));
1368
- }
1369
- catch (error) {
1370
- return err(toFileError(error, resolved));
1371
- }
1372
- },
1373
- readBytes: async (max, signal) => {
1374
- if (kind !== "file")
1375
- return err(new FileError("is_directory", "The held object is a directory", resolved));
1376
- try {
1377
- return ok(await readAllFrom(handle, max, () => abortResult(signal, resolved) !== undefined));
1378
- }
1379
- catch (error) {
1380
- return err(toFileError(error, resolved));
1381
- }
1382
- },
1383
- list: async (signal) => {
1384
- if (kind !== "directory")
1385
- return err(new FileError("not_directory", "The held object is a file", resolved));
1386
- if (process.platform === "win32")
1387
- return err(new FileError("not_supported", "This platform cannot list a held directory", resolved));
1388
- try {
1389
- return await this.listOpenDirectory(handle, resolved, identity, signal);
1390
- }
1391
- catch (error) {
1392
- return err(toFileError(error, resolved));
1393
- }
1394
- },
1395
- close: () => handle.close().catch(() => { }),
1396
- });
1456
+ if (abortSignal?.aborted === true)
1457
+ return refuse("aborted", "aborted");
1458
+ return ok({ handle, held });
1397
1459
  }
1398
1460
  catch (error) {
1399
1461
  return refuse(toFileError(error, resolved).code, error.message ?? "open failed");
1400
1462
  }
1401
1463
  }
1402
- async heldIsAt(handle, held, resolved) {
1403
- if (process.platform === "linux")
1404
- return (await readlink(`/proc/self/fd/${handle.fd}`).catch(() => undefined)) === resolved;
1405
- const named = await lstat(resolved, { bigint: true });
1406
- return held.dev === named.dev && held.ino === named.ino && (await physicalPathOfAsync(resolved)) === resolved;
1464
+ async heldPlace(handle, resolved) {
1465
+ const placed = await readlink(`/proc/self/fd/${handle.fd}`).catch(() => undefined);
1466
+ return placed === undefined ? "unobservable" : placed === resolved ? "at" : "elsewhere";
1407
1467
  }
1408
1468
  async listOpenDirectory(held, resolved, identity, abortSignal) {
1409
1469
  const throughHandle = process.platform === "linux";
@@ -1595,7 +1655,7 @@ export class NodeExecutionEnv {
1595
1655
  cwd: options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd,
1596
1656
  detached: process.platform !== "win32",
1597
1657
  env: this.spawnEnv(options?.env),
1598
- stdio: spoolFds ? ["ignore", spoolFds[0], spoolFds[1]] : ["ignore", "pipe", "pipe"],
1658
+ ...shellChildStdio(spoolFds, false),
1599
1659
  windowsHide: true,
1600
1660
  });
1601
1661
  }
@@ -148,10 +148,10 @@ export interface UserMessageProvenance {
148
148
  * text, so annotation stays adjacent to the frame it attributes. */
149
149
  actor?: ActorAssertion;
150
150
  /** This message carries a person's input — and, when it is the one input a `human_input` frame accounts for, that frame's key
151
- * (`inputId`; a resume's continuation merging several parked steers is a person's input with no single key). A sidecar entry judged at
152
- * the mint (a key that is given and hollow is refused), never a message field: it does not reach the transcript or the model. Read back,
153
- * once the message is committed, by `userRowSourceOf` — which is how the commit frame says what the row is. Absent on every message that
154
- * is not a person's input (an engine note, an attachment frame). */
151
+ * (`inputId`; a resume's continuation merging several parked steers is a person's input with no single key). Minted onto the message
152
+ * as its row members `origin: "human_input"` and `inputId` (`personInputRow`: a key that is given and hollow is refused), which the
153
+ * store keeps and `userRowSourceOf` reads — for the commit frame and for a reader of the store alike; never sent to a provider. Absent
154
+ * on every message that is not a person's input (an engine note, an attachment frame): the leg's admission seat stamps those. */
155
155
  input?: {
156
156
  inputId?: string;
157
157
  };
@@ -457,7 +457,6 @@ export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate
457
457
  private toolResultMedia;
458
458
  private resilience?;
459
459
  private maxToolConcurrency?;
460
- private streamingToolExecution?;
461
460
  private followUpQueue;
462
461
  private followUpQueueMode;
463
462
  private nextTurnQueue;
@@ -7,7 +7,7 @@ import { isCredentialHeaderName } from "../../core/secret-env.js";
7
7
  import { isRunOrigin } from "../../core/run-origin.js";
8
8
  import { readBundledAttachments } from "../../core/attachment-source.js";
9
9
  import { countsAsOperator, isBlankInput, readInputAuthor } from "../../core/input-author.js";
10
- import { noteUserInput } from "../../core/user-row-origin.js";
10
+ import { personInputRow } from "../../core/user-row-origin.js";
11
11
  import { isProviderEchoShape } from "../../brain/errors.js";
12
12
  import { convertToLlm } from "./messages.js";
13
13
  import { readMember, thrownText } from "../../core/thrown-value.js";
@@ -54,7 +54,7 @@ function createUserMessage(text, images, provenance) {
54
54
  if (notices !== undefined)
55
55
  message.changedFilesNotices = notices;
56
56
  if (provenance?.input !== undefined)
57
- noteUserInput(message, provenance.input.inputId);
57
+ Object.assign(message, personInputRow(provenance.input.inputId));
58
58
  return message;
59
59
  }
60
60
  export function turnContextOptions(model) {
@@ -378,7 +378,6 @@ export class AgentHarness {
378
378
  toolResultMedia;
379
379
  resilience;
380
380
  maxToolConcurrency;
381
- streamingToolExecution;
382
381
  followUpQueue = [];
383
382
  followUpQueueMode;
384
383
  nextTurnQueue = [];
@@ -423,7 +422,6 @@ export class AgentHarness {
423
422
  };
424
423
  this.resilience = options.resilience;
425
424
  this.maxToolConcurrency = options.maxToolConcurrency;
426
- this.streamingToolExecution = options.streamingToolExecution;
427
425
  this.followUpQueueMode = options.followUpMode ?? "one-at-a-time";
428
426
  }
429
427
  getHandlers(type) {
@@ -741,9 +739,6 @@ export class AgentHarness {
741
739
  ...this.toolResultMedia,
742
740
  ...(this.resilience !== undefined ? { resilience: this.resilience } : {}),
743
741
  ...(this.maxToolConcurrency !== undefined ? { maxToolConcurrency: this.maxToolConcurrency } : {}),
744
- ...(this.streamingToolExecution === true && (this.getHandlers("tool_call")?.size ?? 0) === 0
745
- ? { streamingToolExecution: true }
746
- : {}),
747
742
  convertToLlm: (messages) => stripEngineMetadata(this.holdToolTurnLaw(convertToLlm(messages))),
748
743
  shouldStopAfterTurn: () => this.consultStopLatch("post_turn"),
749
744
  shouldHaltBeforeTurn: () => this.consultStopLatch("pre_turn"),
@@ -315,9 +315,13 @@ export interface FileInfo {
315
315
  */
316
316
  mode?: number;
317
317
  }
318
- /** A filesystem object held open by {@link FileSystem.openBound}: every answer is about THIS object, whatever the path
319
- * names later. `list` reads a directory's entries through the held object where the backend can; where it cannot, it
320
- * lists the path once and requires the path to name the held object afterwards (the implementation says where). */
318
+ /** A filesystem object bound by {@link FileSystem.openBound}: every answer is about THIS object or is a refusal. A backend
319
+ * that holds a handle answers from it, whatever the path names later; one that binds again on every answer opens the
320
+ * canonical path, answers only when one observation of that open places it at the path with the identity and kind it
321
+ * had when bound (else `precondition_failed`), takes every byte, size and entry from that open alone, and may refuse
322
+ * after a rename or a removal — equal identities across two opens do not prove one object once an inode is reused.
323
+ * `list` reads a directory's entries through the held object where the backend can; where it cannot, it lists the path
324
+ * once and requires the path to name the held object afterwards (the implementation says where). */
321
325
  export interface BoundFileObject {
322
326
  /** `<device>:<inode>` of the held object. */
323
327
  readonly identity: string;
@@ -378,6 +382,10 @@ export interface ExecutionEnvExecOptions {
378
382
  * without it. Carried only to an environment that declares {@link ExecutionEnvCapabilities.commandSandbox}, only by a start
379
383
  * a model-written command makes in a run that requires the sandbox. Absent ⇒ the start runs as it always did. */
380
384
  sandbox?: CommandSandboxInstruction;
385
+ /** The bytes this start's standard input carries, then its end (a program reading `-` reads exactly them, no path): how an
386
+ * engine reader hands a program a file {@link FileSystem.openBound} held — carried only to an environment whose `openBound`
387
+ * held it, which writes them (ignored ⇒ the program reads empty input, never another file). Absent ⇒ empty, as before. */
388
+ stdinFrom?: Uint8Array;
381
389
  }
382
390
  /** The read-deny table one command start carries ({@link ExecutionEnvExecOptions.readFloor}); what an environment keeps of it is INTEGRATION-CORE §11.1.
383
391
  * 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). */
@@ -473,7 +481,7 @@ export interface FileSystem {
473
481
  fileInfo(path: string, abortSignal?: AbortSignal): Promise<Result<FileInfo, FileError>>;
474
482
  /**
475
483
  * design/381 DV-8 — OPTIONAL companion of {@link FileInfo.mode}: set the addressed object's POSIX
476
- * permission bits (`mode & 0o7777`), symlinks NOT followed (an env whose backend can only chmod
484
+ * permission bits (`mode & 0o7777`), no symlink on the path followed, leaf or directory (an env whose backend can only chmod
477
485
  * through a link omits this method rather than following one — a restore must never re-permission
478
486
  * a file it was pointed at by a link it did not verify).
479
487
  *
@@ -498,10 +506,14 @@ export interface FileSystem {
498
506
  /** OPTIONAL: the identity of the object `path` names, links followed (`<device>:<inode>` on POSIX, exact): equal answers name one object, where
499
507
  * a firmlink or bind mount keeps its own {@link canonicalPath}. Home-anchored deny rows are placed by it; omitted ⇒ by spelling only. */
500
508
  fileIdentity?(path: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>>;
501
- /** OPTIONAL: open the file or directory at a canonical `path` and HOLD it ({@link BoundFileObject}): the leaf link is not
502
- * followed, and the path must still name that object, through no link, right after the open (else `precondition_failed`).
503
- * A caller judges the held object and then reads, sizes or lists that same object; it closes it. Omitted ⇒ a caller that
504
- * must bind its read to what it judged does not read. */
509
+ /** OPTIONAL: open the file or directory at a canonical `path` and BIND it ({@link BoundFileObject}): no answer ever comes
510
+ * from an object reached through a link, and the object is placed at the path by ONE observation — an open that refuses
511
+ * a link anywhere on the path, or the kernel's path of the opened descriptor — never by separate reads of the path
512
+ * (else `precondition_failed`). An open that cannot refuse a link may pass through one and is then refused; it is
513
+ * bounded (a FIFO blocks it, a device has its open-time effects) and made with no more reach than the run's own
514
+ * commands. A backend that cannot make that one observation on this target answers `not_supported`, which every caller
515
+ * reads exactly as this member's absence. A caller judges the bound object and then reads, sizes or lists that same
516
+ * object; it closes it. Omitted, or `not_supported` ⇒ a caller that must bind its read to what it judged does not read. */
505
517
  openBound?(path: string, abortSignal?: AbortSignal): Promise<Result<BoundFileObject, FileError>>;
506
518
  /** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */
507
519
  exists(path: string, abortSignal?: AbortSignal): Promise<Result<boolean, FileError>>;
@@ -920,13 +932,18 @@ export interface SessionCheckoutDeclared {
920
932
  baseRef?: "fresh" | "head";
921
933
  name?: string;
922
934
  sources?: SessionCheckoutSource[];
935
+ /** The roots whose repositories are isolated; absent ⇒ the task root alone. */
936
+ roots?: Array<"taskRoot" | {
937
+ directory: string;
938
+ }>;
923
939
  }
924
940
  /** One repository of a session checkout. `dir` / `name` / `branch` / `baseRef` are present together iff the repository is
925
941
  * isolated (the session's own tree); `source` iff a declared source names this repository. */
926
942
  export interface SessionCheckoutCell {
927
943
  /** The repository's main worktree root (canonical) — the repository this cell answers for. */
928
944
  repository: string;
929
- /** Which declared root lives in this cell. */
945
+ /** The declared root this cell was made for: for a tree, the first listed root (`roots`, in its order) in this repository;
946
+ * for a repository with no tree, its source's root. Every other declared root in the repository lives in the same cell. */
930
947
  root: "taskRoot" | {
931
948
  directory: string;
932
949
  };
@@ -1058,6 +1075,28 @@ export declare const SESSION_CHECKOUT_MAX_CELLS = 64;
1058
1075
  * a checkout that cannot be read is a checkout the session cannot use).
1059
1076
  */
1060
1077
  export declare function normalizeSessionCheckout(value: unknown): SessionCheckoutRecord | undefined;
1078
+ /**
1079
+ * #3468: a compaction's restatement of ONE session's checkout (`details.sessionCheckout`) — what the record reader answered for
1080
+ * `sessionId` when the compaction was written: its record (with `released` when released), no record, or a record it could not
1081
+ * read. A storage woken from a bounded window (F3) loads no entry below its floor, and the newest compaction is always inside
1082
+ * that window, so the restatement carries the record across it (a window cut in log order then reads what the whole log reads; one
1083
+ * cut along the branch alone does not load other branches, KNOWN-LIMITS KL-3468-b). The engine writes it (`Session.appendCompaction`),
1084
+ * and only a fact of the log that later entries can add to (a release) but never overturn, and that does not depend on the view it was
1085
+ * read through: a record; an `unreadable` no window's floor alone causes; `none` once the session can no longer declare a checkout (a
1086
+ * fork's `none` is never stated). A reader treats it as one more copy of the same fact; the import door refuses one that contradicts the allocation
1087
+ * entry its log holds. `details.sessionCheckout` is the engine's key: a caller of `appendCompaction` that names it is refused.
1088
+ */
1089
+ export type SessionCheckoutStatement = {
1090
+ readonly sessionId: string;
1091
+ readonly kind: "none" | "unreadable";
1092
+ } | {
1093
+ readonly sessionId: string;
1094
+ readonly kind: "record";
1095
+ readonly record: SessionCheckoutRecord;
1096
+ };
1097
+ /** The strict shape gate of a {@link SessionCheckoutStatement} — the ONE normalization its write, its read and the import door
1098
+ * use. A `record` statement holds a valid record of the statement's own session; `undefined` = not a valid statement. */
1099
+ export declare function normalizeSessionCheckoutStatement(value: unknown): SessionCheckoutStatement | undefined;
1061
1100
  /** Bounded caps for {@link normalizeAnnouncedListing} — a roster is dozens of names, never thousands;
1062
1101
  * a "name" is a short identifier, never a document. Oversize ⇒ structurally invalid (forgery signal). */
1063
1102
  export declare const ANNOUNCED_LISTING_MAX_NAMES = 500;
@@ -1148,7 +1187,7 @@ export interface SessionMetadata {
1148
1187
  * {@link SessionPlacementRecord}). Absent on every ordinary (host-lane) session; a repo that does
1149
1188
  * not understand placement never surfaces it (additive, old readers tolerate). */
1150
1189
  placement?: SessionPlacementRecord;
1151
- /** WHICH occupant this row is: minted by the repo once when the row comes into existence (create / fork / import onto an absent id), carried by every other write; only compared; absent = UNKNOWN, never backfilled; not wire / model-context material. */
1190
+ /** WHICH occupant this row is: minted by the repo once when the row comes into existence (create / fork / import onto an absent id), carried by every other write; only compared; absent = UNKNOWN, never backfilled; not wire / model-context material. A token the bundled mint point (`incarnationCell`) minted ends in `.2` and states one fact: the row was born from that write, so what is recorded per occupant for it (its file history, `fileHistoryScopeOf`) is at its address; any other value states nothing about that. An opaque string of at most 64 characters to a host that stores it. */
1152
1191
  incarnation?: string;
1153
1192
  /** Fork lineage's OCCUPANT half: the source row's `incarnation` at fork time (the occupant copied, not whoever holds `forkedFrom` later); absent = unknown. */
1154
1193
  forkedFromIncarnation?: string;
@@ -1230,6 +1269,8 @@ export interface SessionStorage<TMetadata extends SessionMetadata = SessionMetad
1230
1269
  setLeafId(leafId: string | null, opts?: SessionWriteOptions): Promise<void>;
1231
1270
  createEntryId(): Promise<string>;
1232
1271
  appendEntry(entry: SessionTreeEntry, opts?: SessionWriteOptions): Promise<void>;
1272
+ /** The entry of THIS session's log with that id, or undefined. A backend that wakes a bounded window ({@link getFloorId}) answers an id below
1273
+ * its floor too: a branch target (`resumeAt`) and a file-rewind target are judged by this read. */
1233
1274
  getEntry(id: string): Promise<SessionTreeEntry | undefined>;
1234
1275
  findEntries<TType extends SessionTreeEntry["type"]>(type: TType): Promise<Array<Extract<SessionTreeEntry, {
1235
1276
  type: TType;
@@ -1811,15 +1852,6 @@ export interface AgentHarnessOptions<TSkill extends Skill = Skill, TPromptTempla
1811
1852
  resilience?: import("../llm/types.js").ResilienceOptions;
1812
1853
  /** design/120 P1: parallel-batch tool concurrency cap forwarded to the loop (default 10). */
1813
1854
  maxToolConcurrency?: number;
1814
- /**
1815
- * design/120 P2: opt in to in-stream tool execution (safe tool calls start while the model is
1816
- * still streaming). Default OFF. The harness forwards this to the loop ONLY when no `tool_call`
1817
- * hook handler is registered at run start (snapshot per prompt()) — a policy/approval gate on
1818
- * that hook could durably suspend, which has no stable leaf mid-stream. Hosts that register a
1819
- * suspending `tool_call` handler mid-run after opting in get undefined behavior (documented
1820
- * contract, see AgentLoopConfig.streamingToolExecution).
1821
- */
1822
- streamingToolExecution?: boolean;
1823
1855
  /** The one seat every row passes at each harness commit point (a row the loop ends, an API failure's record, a row handed
1824
1856
  * to {@link AgentHarness.appendMessage}), before the live context and the store; absent ⇒ every row passes as made. */
1825
1857
  admitRows?: RowAdmission;
@@ -1,4 +1,5 @@
1
1
  import { asThrownError } from "../../core/thrown-value.js";
2
+ import { isTextContentHash } from "../../core/canonical-json.js";
2
3
  export function ok(value) {
3
4
  return { ok: true, value };
4
5
  }
@@ -99,7 +100,7 @@ export function normalizeGitAnnouncement(v) {
99
100
  const src = v;
100
101
  if (src.kind !== "full" && src.kind !== "degraded" && src.kind !== "unavailable" && src.kind !== "non-repo")
101
102
  return undefined;
102
- if (typeof src.hash !== "string" || !/^sha256:[0-9a-f]{64}$/.test(src.hash))
103
+ if (!isTextContentHash(src.hash))
103
104
  return undefined;
104
105
  if (src.entryId !== undefined && (typeof src.entryId !== "string" || src.entryId.length === 0 || src.entryId.length > GIT_ANNOUNCEMENT_MAX_ENTRY_ID_CHARS))
105
106
  return undefined;
@@ -205,10 +206,23 @@ export function normalizeSessionCheckout(value) {
205
206
  sources.push(shaped);
206
207
  }
207
208
  }
209
+ let roots;
210
+ if (d.roots !== undefined) {
211
+ if (d.isolation === undefined || !Array.isArray(d.roots) || d.roots.length === 0 || d.roots.length > SESSION_CHECKOUT_MAX_CELLS)
212
+ return undefined;
213
+ roots = [];
214
+ for (const r of d.roots) {
215
+ const shaped = normalizeCheckoutRoot(r);
216
+ if (shaped === undefined)
217
+ return undefined;
218
+ roots.push(shaped);
219
+ }
220
+ }
208
221
  const declared = {
209
222
  ...(d.isolation !== undefined ? { isolation: "worktree" } : {}),
210
223
  ...(d.baseRef !== undefined ? { baseRef: d.baseRef } : {}),
211
224
  ...(d.name !== undefined ? { name: d.name } : {}),
225
+ ...(roots !== undefined ? { roots } : {}),
212
226
  ...(sources !== undefined ? { sources } : {}),
213
227
  };
214
228
  if (!Array.isArray(v.checkouts) || v.checkouts.length > SESSION_CHECKOUT_MAX_CELLS)
@@ -252,6 +266,19 @@ export function normalizeSessionCheckout(value) {
252
266
  }
253
267
  return { allocationId: v.allocationId, sessionId: v.sessionId, declared, checkouts, ...(v.released === true ? { released: true } : {}) };
254
268
  }
269
+ export function normalizeSessionCheckoutStatement(value) {
270
+ if (value === null || typeof value !== "object" || Array.isArray(value))
271
+ return undefined;
272
+ const v = value;
273
+ if (typeof v.sessionId !== "string" || v.sessionId.length === 0 || v.sessionId.length > 512)
274
+ return undefined;
275
+ if (v.kind === "none" || v.kind === "unreadable")
276
+ return v.record === undefined ? { sessionId: v.sessionId, kind: v.kind } : undefined;
277
+ if (v.kind !== "record")
278
+ return undefined;
279
+ const record = normalizeSessionCheckout(v.record);
280
+ return record !== undefined && record.sessionId === v.sessionId ? { sessionId: v.sessionId, kind: "record", record } : undefined;
281
+ }
255
282
  export const ANNOUNCED_LISTING_MAX_NAMES = 500;
256
283
  export const ANNOUNCED_LISTING_MAX_NAME_CHARS = 200;
257
284
  export const ANNOUNCED_MCP_ERROR_MAX_CHARS = 400;