@sema-agent/core 7.72.0 → 7.74.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 (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -5,15 +5,17 @@ import { createHash, randomUUID } from "node:crypto";
5
5
  import { closeSync, constants, createReadStream, mkdtempSync, openSync, readSync, rmSync, statSync, truncateSync, unlinkSync } from "node:fs";
6
6
  import { access, appendFile, lstat, mkdir, mkdtemp, open, readdir, readFile, readlink, rename, rm, stat, unlink, writeFile, } from "node:fs/promises";
7
7
  import { tmpdir } from "node:os";
8
- import { basename, dirname, isAbsolute, join, sep } from "node:path";
8
+ import { basename, dirname, isAbsolute, join, posix as posixPath, sep, win32 as win32Path } from "node:path";
9
9
  import { createInterface } from "node:readline";
10
10
  import { ExecutionError, err, FileError, ok, toError, } from "../harness/types.js";
11
11
  import { killProcessTree, shutdownDebug } from "./kill-tree.js";
12
- import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub, declaredInheritEntry, hostChildEnv, hostChildEnvProblem, inheritEnvPolicyProblem, inheritedHostEnv } from "../../core/secret-env.js";
12
+ import { __resetSecretEnvScrubNoticeAnnouncement, announceSecretEnvScrub, declaredInheritEntry, envNameKeyOn, hostChildEnv, hostChildEnvProblem, inheritEnvPolicyProblem, inheritedHostEnv, noteChildSpawned } from "../../core/secret-env.js";
13
13
  import { deliverEngineNotice } from "../../core/engine-notice.js";
14
14
  import { confineShellStart, SANDBOX_EXEC, SEATBELT_PROBE_PROFILE } from "../../core/shell-confinement.js";
15
15
  import { physicalPathOfAsync } from "../../core/physical-path.js";
16
16
  import { posixModeBitsMeaningful } from "../../core/posix-mode-face.js";
17
+ import { isAbsoluteForFamily, isWinFormPath } from "../../core/unc-spelling.js";
18
+ import { SHELL_KIND_QUESTION, SHELL_KIND_QUESTION_OPTIONS, configuredNamesKeptOut, configuredShellLayer, inheritedShellState, notStartedInThisVersion, readShellKindAnswer, shellKindQuestionEnv } from "../../core/model-shell.js";
17
19
  import { anchorAtLinkDir, walkSymlinkChain } from "./symlink-chain.js";
18
20
  import { RollingTailBuffer, markTruncated, newStreamCursorState, sliceStreamIncrement, } from "../../core/exec-output-tail.js";
19
21
  import { BackgroundShellError } from "../../core/background-shell.js";
@@ -382,7 +384,7 @@ async function pathExists(path) {
382
384
  return false;
383
385
  }
384
386
  }
385
- async function runCommand(command, args, timeoutMs) {
387
+ async function runCommand(command, args, timeoutMs, start) {
386
388
  return await new Promise((resolveLocal) => {
387
389
  let stdout = "";
388
390
  let child;
@@ -390,7 +392,8 @@ async function runCommand(command, args, timeoutMs) {
390
392
  child = spawn(command, args, {
391
393
  stdio: ["ignore", "pipe", "ignore"],
392
394
  windowsHide: true,
393
- env: inheritedHostEnv("scrub"),
395
+ env: start === undefined ? inheritedHostEnv("scrub") : start.env(),
396
+ ...(start === undefined ? {} : { cwd: start.cwd }),
394
397
  });
395
398
  }
396
399
  catch {
@@ -468,6 +471,99 @@ export async function getShellConfig(customShellPath) {
468
471
  }
469
472
  return ok({ shell: "sh", args: ["-c"] });
470
473
  }
474
+ const HOST_PROBE = {
475
+ get platform() {
476
+ return process.platform;
477
+ },
478
+ exists: pathExists,
479
+ executable: async (path) => {
480
+ try {
481
+ await access(path, constants.X_OK);
482
+ return (await stat(path)).isFile();
483
+ }
484
+ catch {
485
+ return false;
486
+ }
487
+ },
488
+ get programFiles() {
489
+ return [process.env.ProgramFiles, process.env["ProgramFiles(x86)"]];
490
+ },
491
+ };
492
+ export function modelShellSearchPath(env, platform = process.platform) {
493
+ const key = Object.keys(env).find((k) => envNameKeyOn(k, platform) === "PATH");
494
+ const value = key === undefined ? undefined : env[key];
495
+ return value === undefined || value === "" ? [] : value.split(platform === "win32" ? ";" : ":");
496
+ }
497
+ async function programOf(name, place, probe) {
498
+ const at = probe.platform === "win32" ? win32Path : posixPath;
499
+ if (isAbsoluteCandidate(name, probe.platform))
500
+ return (await probe.exists(name)) ? name : undefined;
501
+ if (name.includes("/") || (probe.platform === "win32" && isWinFormPath(name))) {
502
+ const joined = at.resolve(place.cwd, name);
503
+ return (await probe.exists(joined)) ? joined : undefined;
504
+ }
505
+ const names = probe.platform === "win32" && !/\.exe$/i.test(name) ? [name, `${name}.exe`] : [name];
506
+ for (const dir of place.searchPath) {
507
+ if (!isAbsoluteCandidate(dir, probe.platform))
508
+ continue;
509
+ for (const candidate of names.map((n) => at.join(dir, n))) {
510
+ if (probe.platform === "win32" && isWslBashLauncher(candidate))
511
+ continue;
512
+ if (await probe.executable(candidate))
513
+ return candidate;
514
+ }
515
+ }
516
+ return undefined;
517
+ }
518
+ export async function askShellKind(path, cwd) {
519
+ return (await askShellKindOnce(path, cwd)).answer;
520
+ }
521
+ async function askShellKindOnce(path, cwd) {
522
+ const run = await runCommand(path, [...SHELL_KIND_QUESTION_OPTIONS, SHELL_KIND_QUESTION], 5000, { env: () => shellKindQuestionEnv(inheritedHostEnv("scrub")), cwd });
523
+ if (run.status === null)
524
+ return { ran: false, answer: { ok: false, reason: "gave no answer to the shell-kind question (it could not be started, timed out or was ended by a signal)" } };
525
+ return { ran: true, answer: run.status !== 0 ? { ok: false, reason: `gave no answer to the shell-kind question (it exited with status ${run.status})` } : readShellKindAnswer(run.stdout) };
526
+ }
527
+ export async function resolveModelShell(shellPath, place, probe = HOST_PROBE, ask = askShellKind) {
528
+ const refusals = [];
529
+ const asked = new Set();
530
+ const tryOne = async (path) => {
531
+ asked.add(path);
532
+ const answer = await ask(path, place.cwd);
533
+ const refused = answer.ok ? notStartedInThisVersion(answer) : answer.reason;
534
+ if (refused === undefined && answer.ok)
535
+ return answer.version;
536
+ refusals.push(`${path} ${refused}`);
537
+ return undefined;
538
+ };
539
+ const taken = (path, version) => ok({ path, version });
540
+ const unavailable = () => err(new ExecutionError("shell_unavailable", refusals.length === 0 ? "No bash shell found" : `No bash (3.2 or later, not in POSIX mode) to start commands on: ${refusals.join("; ")}`));
541
+ if (shellPath) {
542
+ const program = await programOf(shellPath, place, probe);
543
+ if (program === undefined)
544
+ return err(new ExecutionError("shell_unavailable", `Custom shell path not found: ${shellPath}`));
545
+ const version = await tryOne(program);
546
+ return version !== undefined ? taken(program, version) : unavailable();
547
+ }
548
+ const fixed = probe.platform === "win32" ? probe.programFiles.flatMap((root) => (root ? [`${root}\\Git\\bin\\bash.exe`] : [])) : ["/bin/bash"];
549
+ for (const candidate of fixed) {
550
+ if (!isAbsoluteCandidate(candidate, probe.platform) || !(await probe.exists(candidate)))
551
+ continue;
552
+ const version = await tryOne(candidate);
553
+ if (version !== undefined)
554
+ return taken(candidate, version);
555
+ }
556
+ const onPath = await programOf("bash", place, probe);
557
+ if (onPath !== undefined && !asked.has(onPath)) {
558
+ const version = await tryOne(onPath);
559
+ if (version !== undefined)
560
+ return taken(onPath, version);
561
+ }
562
+ return unavailable();
563
+ }
564
+ function isAbsoluteCandidate(path, platform) {
565
+ return isAbsoluteForFamily(platform === "win32" ? "win" : "posix", path);
566
+ }
471
567
  const EXEC_FORCE_SETTLE_GRACE_MS = 3000;
472
568
  let secretScrubSeatDefectAnnounced = false;
473
569
  export function __resetSecretScrubAnnouncement() {
@@ -565,6 +661,30 @@ function shellChildStdio(spoolFds, stdinFed) {
565
661
  const stdin = stdinFed ? "pipe" : "ignore";
566
662
  return { stdio: spoolFds ? [stdin, spoolFds[0], spoolFds[1]] : [stdin, "pipe", "pipe"] };
567
663
  }
664
+ export const MODEL_SHELL_DROPPED_KEPT = 32;
665
+ const RUN_SHELL = Symbol("NodeExecutionEnv.runShell");
666
+ const START_BACKGROUND = Symbol("NodeExecutionEnv.startBackground");
667
+ const MODEL_START = Symbol("NodeExecutionEnv.modelStart");
668
+ function withModelStart(options, start) {
669
+ const own = options === undefined ? {} : Object.getOwnPropertyDescriptors(options);
670
+ return Object.create(options === undefined ? Object.prototype : Object.getPrototypeOf(options), { ...own, [MODEL_START]: { value: start, enumerable: true } });
671
+ }
672
+ function modelStartOf(options) {
673
+ let s;
674
+ try {
675
+ s = options?.[MODEL_START];
676
+ }
677
+ catch {
678
+ return undefined;
679
+ }
680
+ return typeof s === "object" && s !== null ? s : undefined;
681
+ }
682
+ function modelStartAt(env, options) {
683
+ const carried = modelStartOf(options);
684
+ return carried === undefined || carried.owner === env ? carried : modelStartOfEnv(env);
685
+ }
686
+ let modelStartOfEnv;
687
+ let spawnEnvOf;
568
688
  export class NodeExecutionEnv {
569
689
  cwd;
570
690
  capabilities;
@@ -597,9 +717,9 @@ export class NodeExecutionEnv {
597
717
  return undefined;
598
718
  }
599
719
  }
600
- spawnEnv(extraEnv) {
720
+ spawnEnv(extraEnv, base) {
601
721
  try {
602
- return getShellEnv(this.inheritEnv, this.shellEnv, extraEnv, this.onSecretEnvScrub, this.onNotice);
722
+ return getShellEnv(this.inheritEnv, base === undefined ? this.shellEnv : base.env, extraEnv, this.onSecretEnvScrub, this.onNotice);
603
723
  }
604
724
  catch (error) {
605
725
  const entry = declaredInheritEntry(this.inheritEnv);
@@ -728,12 +848,100 @@ export class NodeExecutionEnv {
728
848
  return { ok: false, refusedBy: "environment", reason: `the read-deny table's confinement profile does not apply on this host (${failed}) — the command was not started` };
729
849
  return { ok: true, ...confined.start };
730
850
  }
731
- async exec(command, options) {
851
+ exec(command, options) {
852
+ const start = modelStartAt(this, options);
853
+ return NodeExecutionEnv.prototype[RUN_SHELL].call(this, command, options, () => start?.shellOf() ?? getShellConfig(this.shellPath), () => start?.childEnvOf() ?? spawnEnvOf(this));
854
+ }
855
+ static {
856
+ spawnEnvOf = (env) => {
857
+ const spawnEnv = env.spawnEnv;
858
+ return (extraEnv) => spawnEnv.call(env, extraEnv);
859
+ };
860
+ }
861
+ get modelShell() {
862
+ const start = () => modelStartOfEnv(this);
863
+ return {
864
+ exec: (script, options) => this.exec(script, withModelStart(options, start())),
865
+ spawnBackground: (script, options) => this.spawnBackground(script, withModelStart(options, start())),
866
+ ready: async () => {
867
+ const resolved = await start().resolvedOf();
868
+ return resolved.ok ? ok({ shell: "bash", version: resolved.value.version }) : resolved;
869
+ },
870
+ };
871
+ }
872
+ static {
873
+ modelStartOfEnv = (self) => {
874
+ let layer;
875
+ const layerOf = () => (layer ??= configuredShellLayer(self.shellEnv, "env grant 1"));
876
+ const resolvedOf = async () => {
877
+ let env;
878
+ try {
879
+ env = self.spawnEnv(undefined, { env: layerOf().kept });
880
+ }
881
+ catch (error) {
882
+ const cause = toError(error);
883
+ const failure = new ExecutionError("spawn_error", cause.message, cause);
884
+ const brief = briefOf(error);
885
+ if (brief !== undefined)
886
+ failure.briefMessage = brief;
887
+ return err(failure);
888
+ }
889
+ return self.modelShellPath(env);
890
+ };
891
+ return {
892
+ owner: self,
893
+ resolvedOf,
894
+ shellOf: async () => {
895
+ const resolved = await (self.modelShellResolved ?? resolvedOf());
896
+ return resolved.ok ? ok({ shell: resolved.value.path, args: ["-c"] }) : resolved;
897
+ },
898
+ childEnvOf: () => (extraEnv) => self.modelShellSpawnEnv(layerOf(), extraEnv),
899
+ };
900
+ };
901
+ }
902
+ modelShellResolved;
903
+ modelShellPath(env) {
904
+ if (this.modelShellResolved !== undefined)
905
+ return this.modelShellResolved;
906
+ let unanswered = false;
907
+ const ask = async (path, cwd) => {
908
+ const asked = await askShellKindOnce(path, cwd);
909
+ if (!asked.ran)
910
+ unanswered = true;
911
+ return asked.answer;
912
+ };
913
+ const resolving = resolveModelShell(this.shellPath, { cwd: this.cwd, searchPath: modelShellSearchPath(env) }, HOST_PROBE, ask).then((resolved) => {
914
+ if (!resolved.ok && unanswered && this.modelShellResolved === resolving)
915
+ this.modelShellResolved = undefined;
916
+ return resolved;
917
+ });
918
+ this.modelShellResolved = resolving;
919
+ return resolving;
920
+ }
921
+ get modelShellDropped() {
922
+ return this.modelShellDroppedRecord;
923
+ }
924
+ modelShellDroppedRecord = { entries: [], more: false };
925
+ modelShellSpawnEnv(layer, extraEnv) {
926
+ const extra = configuredShellLayer(extraEnv, "env grant 2");
927
+ const composed = inheritedShellState(this.spawnEnv(extra.kept, { env: layer.kept }), process.platform, configuredNamesKeptOut([layer, extra]));
928
+ const record = this.modelShellDroppedRecord;
929
+ for (const d of [...layer.dropped, ...extra.dropped, ...composed.dropped]) {
930
+ if (record.entries.some((e) => e.from === d.from && e.key === d.key))
931
+ continue;
932
+ if (record.entries.length >= MODEL_SHELL_DROPPED_KEPT)
933
+ record.more = true;
934
+ else
935
+ record.entries.push(d);
936
+ }
937
+ return composed.kept;
938
+ }
939
+ async [RUN_SHELL](command, options, shellOf, childEnvOf) {
732
940
  if (options?.abortSignal?.aborted) {
733
941
  return err(new ExecutionError("aborted", "aborted"));
734
942
  }
735
943
  const cwd = options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd;
736
- const shellConfig = await getShellConfig(this.shellPath);
944
+ const shellConfig = await shellOf();
737
945
  if (!shellConfig.ok) {
738
946
  return shellConfig;
739
947
  }
@@ -842,10 +1050,11 @@ export class NodeExecutionEnv {
842
1050
  child = spawn(start.command, [...start.args], {
843
1051
  cwd,
844
1052
  detached: process.platform !== "win32",
845
- env: this.spawnEnv(options?.env),
1053
+ env: childEnvOf()(options?.env),
846
1054
  ...shellChildStdio(execSpoolFds, input !== undefined),
847
1055
  windowsHide: true,
848
1056
  });
1057
+ noteChildSpawned(this.inheritEnv);
849
1058
  }
850
1059
  catch (error) {
851
1060
  closeSpoolFds();
@@ -1672,14 +1881,18 @@ export class NodeExecutionEnv {
1672
1881
  this.bgShells.set(shellId, entry);
1673
1882
  return shellId;
1674
1883
  }
1675
- async spawnBackground(command, options) {
1884
+ spawnBackground(command, options) {
1885
+ const start = modelStartAt(this, options);
1886
+ return NodeExecutionEnv.prototype[START_BACKGROUND].call(this, command, options, () => start?.shellOf() ?? getShellConfig(this.shellPath), () => start?.childEnvOf() ?? spawnEnvOf(this));
1887
+ }
1888
+ async [START_BACKGROUND](command, options, shellOf, childEnvOf) {
1676
1889
  const liveCount = [...this.bgShells.values()].filter((e) => e.status === "running").length;
1677
1890
  if (liveCount >= this.backgroundCapabilities.maxConcurrent) {
1678
1891
  return err(new BackgroundShellError("limit_exceeded", `Too many running background shells (max ${this.backgroundCapabilities.maxConcurrent}); TaskStop one first.`));
1679
1892
  }
1680
- const shellConfig = await getShellConfig(this.shellPath);
1893
+ const shellConfig = await shellOf();
1681
1894
  if (!shellConfig.ok) {
1682
- return err(new BackgroundShellError("spawn_failed", shellConfig.error.message, shellConfig.error));
1895
+ return err(Object.assign(new BackgroundShellError("spawn_failed", shellConfig.error.message, shellConfig.error), shellConfig.error.briefMessage !== undefined ? { briefMessage: shellConfig.error.briefMessage } : {}));
1683
1896
  }
1684
1897
  const start = await this.startOf(shellConfig.value, command, options);
1685
1898
  if (!start.ok)
@@ -1707,10 +1920,11 @@ export class NodeExecutionEnv {
1707
1920
  child = spawn(start.command, [...start.args], {
1708
1921
  cwd: options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd,
1709
1922
  detached: process.platform !== "win32",
1710
- env: this.spawnEnv(options?.env),
1923
+ env: childEnvOf()(options?.env),
1711
1924
  ...shellChildStdio(spoolFds, false),
1712
1925
  windowsHide: true,
1713
1926
  });
1927
+ noteChildSpawned(this.inheritEnv);
1714
1928
  }
1715
1929
  catch (error) {
1716
1930
  if (spoolFds) {
@@ -752,6 +752,31 @@ export interface ExecutionEnv extends FileSystem, Shell {
752
752
  * hands it to the Runner's `onNotice` too, once per run, as each of its tool calls ends. Absent ⇒ the environment has not raised one, or
753
753
  * the adapter has no such refusal (a remote adapter omits it). A read: it announces nothing. */
754
754
  readonly lateDeclarationNotice?: import("../../core/engine-notice.js").EngineNotice;
755
+ /**
756
+ * The start for shell text a model wrote. The text is read, whole and unchanged, by the shell the environment started for it — in this version a bash (3.2 or later, not in POSIX mode); `ready` reports which shell it starts, `{ shell: "bash" | "zsh", version }`, from the candidate's own answer, and a start that reports zsh is not mounted in this version — with no start option or startup file of the environment's own that changes how the shell reads text — or nothing of it runs and the start fails with `shell_unavailable` (`exec`) / `spawn_failed` (`spawnBackground`). The question guards against a misconfigured candidate, not a hostile one: a candidate reports its own identity. Handing the text to any other shell is a defect of the environment. A wrapper forwards this member whole or not at all. The engine receives the member once per environment object — the first read that answers an object (the group) is kept, and every later reading and start on that environment uses that group, whose `exec` / `spawnBackground` / `ready` are still read off it at each start or reading — so a host that would hand another group gives another environment object.
757
+ */
758
+ readonly modelShell?: ExecutionEnvModelShell;
759
+ /** What the starts of {@link modelShell} did not pass to the model's shell (variables of `SHELL_STATE_ENV`), each variable once per source (`configured` or `inherited`); `more`
760
+ * says some were not kept. A record the run tells as `config.shell_state_env_dropped` as each tool call ends; absent ⇒ the adapter keeps none. */
761
+ readonly modelShellDropped?: {
762
+ readonly entries: readonly import("../../core/model-shell.js").DroppedShellState[];
763
+ readonly more: boolean;
764
+ };
765
+ }
766
+ /** The method group of {@link ExecutionEnv.modelShell}: the starts of model-written shell text, and whether the environment can make them. */
767
+ export interface ExecutionEnvModelShell {
768
+ /** Run `script` on the environment's bash, as {@link Shell.exec} runs a command: the same options, result and failure words. */
769
+ exec(script: string, options?: ExecutionEnvExecOptions): Promise<Result<ExecResult, ExecutionError>>;
770
+ /** Start `script` on the environment's bash in the background, as the background face's `spawnBackground` starts a command. Absent ⇒ this environment starts no model text in the background. */
771
+ spawnBackground?(script: string, options?: import("../../core/background-shell.js").BackgroundSpawnOptions): Promise<Result<{
772
+ shellId: import("../../core/background-shell.js").BackgroundShellId;
773
+ }, import("../../core/background-shell.js").BackgroundShellError>>;
774
+ /** Whether a start can be made: `ok` with the shell the starts run and its version as it reported them (not what a startup file the host process's own environment names would do), or the `shell_unavailable` failure every start would answer, naming why.
775
+ * A leg waits at most 5 s for it (a `ready` that blocks the thread synchronously is outside that bound). Absent ⇒ the environment answers for its starts without being asked. */
776
+ ready?(): Promise<Result<{
777
+ readonly shell: "bash" | "zsh";
778
+ readonly version: string;
779
+ }, ExecutionError>>;
755
780
  }
756
781
  /** Base fields shared by append-only session tree entries. */
757
782
  export interface SessionTreeEntryBase {
@@ -1059,6 +1084,24 @@ export interface ReminderMarkEntry extends SessionTreeEntryBase {
1059
1084
  /** The opaque mark token (bounded; scheme-verified by the consumer, never by the store). */
1060
1085
  mark: string;
1061
1086
  }
1087
+ /**
1088
+ * A run's MEMBER LEDGER as one delivery carried it (`TaskSpec.runLedger`): written beside each report the run's report tool
1089
+ * delivered and once at the run's end, so a session reopened later replays the engine's half of every delivery exactly as it was.
1090
+ * Never rendered into the model's context. The ledger is an open record (`RunLedger`, `v` its shape version); the log keeps it as
1091
+ * written and a reader judges the members it knows.
1092
+ */
1093
+ export interface RunLedgerEntry extends SessionTreeEntryBase {
1094
+ type: "run_ledger";
1095
+ /** The ledger snapshot (`RunLedger`) — plain data. */
1096
+ ledger: {
1097
+ readonly v: number;
1098
+ readonly seq: number;
1099
+ readonly final: boolean;
1100
+ readonly rows: readonly unknown[];
1101
+ };
1102
+ }
1103
+ /** The shape gate of a {@link RunLedgerEntry}'s ledger (the append's and the import door's one check). */
1104
+ export declare function isRunLedgerRecord(v: unknown): v is RunLedgerEntry["ledger"];
1062
1105
  /**
1063
1106
  * design/319: strict shape gate for the reminder-mark entry — the SINGLE normalization the read
1064
1107
  * walk, the public append, and the import-validate door all use (the {@link normalizeAnnouncedListing}
@@ -1236,7 +1279,7 @@ export declare function isSyntheticApiErrorMessage(m: unknown): boolean;
1236
1279
  export declare function isOptionalDisplayString(v: unknown, max?: number): boolean;
1237
1280
  export declare function normalizeAnnouncedListing(v: unknown): AnnouncedListingSnapshot | undefined;
1238
1281
  /** All persisted session tree entry variants. */
1239
- export type SessionTreeEntry = MessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | CompactionEntry | CustomEntry | CustomMessageEntry | LabelEntry | SessionInfoEntry | LeafEntry | PromptEpochEntry | AnnouncedListingEntry | GitAnnouncementEntry | WorkspaceStateEntry | SessionCheckoutEntry | ReminderMarkEntry;
1282
+ export type SessionTreeEntry = MessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | CompactionEntry | CustomEntry | CustomMessageEntry | LabelEntry | SessionInfoEntry | LeafEntry | PromptEpochEntry | AnnouncedListingEntry | GitAnnouncementEntry | WorkspaceStateEntry | SessionCheckoutEntry | ReminderMarkEntry | RunLedgerEntry;
1240
1283
  export interface SessionContext {
1241
1284
  messages: AgentMessage[];
1242
1285
  thinkingLevel: string;
@@ -1452,6 +1495,11 @@ export interface Session<TMetadata extends SessionMetadata = SessionMetadata> {
1452
1495
  * mark restore ladder — the checkpoint seed stays first, the trusted fork channel second).
1453
1496
  * Undefined ⇒ no entry visible. OPTIONAL, same posture as `appendReminderMark`. */
1454
1497
  getReminderMark?(): Promise<string | undefined>;
1498
+ /** Persist a run's member ledger snapshot as a first-class {@link RunLedgerEntry} (see `Session.appendRunLedger`). OPTIONAL on
1499
+ * the interface — an implementer without it records none (the result and the report tool's own result still carry it). */
1500
+ appendRunLedger?(ledger: RunLedgerEntry["ledger"]): Promise<string>;
1501
+ /** The run-ledger entries on the active branch, oldest first — a reopened session's replay of every delivery's engine half. OPTIONAL, same posture. */
1502
+ getRunLedgers?(): Promise<RunLedgerEntry["ledger"][]>;
1455
1503
  /** The branch's current prompt-epoch descriptor (semantics: `Session.getPromptEpoch`). OPTIONAL on
1456
1504
  * the interface (typecheck 车 2026-07-24): the built-in `Session` class always implements it;
1457
1505
  * optionality keeps external `Session` implementers compatible. The consumer (`maybeCompact`'s
@@ -92,6 +92,16 @@ export class NothingQueuedError extends AgentHarnessError {
92
92
  }
93
93
  export const ANNOUNCED_LANGUAGE_MAX_CHARS = 256;
94
94
  export const REMINDER_MARK_MAX_CHARS = 64;
95
+ export function isRunLedgerRecord(v) {
96
+ if (v === null || typeof v !== "object" || Array.isArray(v))
97
+ return false;
98
+ const l = v;
99
+ const posInt = (x) => typeof x === "number" && Number.isSafeInteger(x) && x > 0;
100
+ const t = l["trigger"];
101
+ const kind = t !== null && typeof t === "object" ? t["kind"] : undefined;
102
+ const consistent = t === undefined || (typeof kind === "string" && (kind === "run_end") === l["final"]);
103
+ return posInt(l["v"]) && posInt(l["seq"]) && typeof l["final"] === "boolean" && Array.isArray(l["rows"]) && consistent;
104
+ }
95
105
  export function normalizeReminderMark(v) {
96
106
  if (typeof v !== "object" || v === null)
97
107
  return undefined;
@@ -812,6 +812,14 @@ export interface ToolResultMessage<TDetails = unknown> {
812
812
  toolCallId: string;
813
813
  toolName: string;
814
814
  content: (TextContent | ImageContent | DocumentContent)[];
815
+ /**
816
+ * Per-tool metadata or engine-owned settlement marks persisted on the row. A call that never ran
817
+ * (`details.notExecuted === true`) whose `tool_end` frame carried a {@link GateOutcome} stores a structural copy as
818
+ * `details.gate` on the row the leg itself writes; a row written by recovery carries `notExecuted` without `gate`
819
+ * (absence = "not recorded", never "no gate judged it"). `gate` says what the gate decided, not why the call did
820
+ * not run. Absent on calls that ran. The engine drops a tool-written `details.gate` / `details.notExecuted` when
821
+ * writing a row; rows stored by earlier versions are not rewritten.
822
+ */
815
823
  details?: TDetails;
816
824
  isError: boolean;
817
825
  /** {@link RowRewrittenBy} */
@@ -947,13 +955,11 @@ export type AssistantMessageEvent = {
947
955
  partial: AssistantMessage;
948
956
  }
949
957
  /**
950
- * design/124 tier B contract note: after a mid-stream failure with only thinking streamed, the
951
- * brain seals the block (`thinking_end`) and RE-SENDS the whole turn WITHOUT a second `start` —
952
- * the retry attempt may then legally reopen a thinking block at the SAME contentIndex (the openai
953
- * parser hardcodes thinking at index 0; the anthropic wire restarts block indexing per attempt).
954
- * Consumers that render by `partial` snapshot are naturally correct (each retry event carries a
955
- * fresh snapshot that REPLACES the previous attempt's content — CC's "drop the thinking" semantics);
956
- * a consumer keying blocks by index gets exactly the intended replacement.
958
+ * design/124 tier B: after a thinking-only mid-stream cut, the brain seals (`thinking_end`) and
959
+ * re-sends without a second `start`, reopening thinking at the same `contentIndex` (each retry
960
+ * carries a fresh `partial` snapshot replacing the previous attempt's thinking). For a turn whose
961
+ * reasoning is interleaved with text, a live event's `contentIndex` is the order of arrival and
962
+ * is not an index into the saved message's `content`.
957
963
  */
958
964
  | {
959
965
  type: "thinking_start";
@@ -6,5 +6,12 @@ export declare function validateToolCall(tools: Tool[], toolCall: ToolCall): unk
6
6
  export declare function toolNameIndex<T extends Tool>(tools: readonly T[] | undefined): (name: string) => T | undefined;
7
7
  /** VENDORED EDIT (design/115 P0): resolve canonical tool names first, then legacy aliases ({@link toolNameIndex} for one name). */
8
8
  export declare function findToolByName<T extends Tool>(tools: readonly T[] | undefined, name: string): T | undefined;
9
- /** Validates tool arguments against TypeBox or plain JSON-schema parameters. */
9
+ /**
10
+ * Validates tool arguments against TypeBox or plain JSON-schema parameters. A limit of the runtime met while the arguments are cloned, converted or
11
+ * checked ({@link runtimeLimitWords}) is a validation failure too — of the usual form, so every reader of the check treats it as one: the call was not
12
+ * run, and the sentence says the check ran into a limit of this runtime, not why (a deep value overflows the stack, a shallow one whose getter
13
+ * raises a length error ends the same way). The original rides on `cause` and the structured marks it carried (`details`, `errorKind`) stay on the
14
+ * error. No depth is refused: what validated before validates now. Every other error — any other class, a `RangeError` that is no limit — leaves as
15
+ * it was thrown.
16
+ */
10
17
  export declare function validateToolArguments(tool: Tool, toolCall: ToolCall): unknown;
@@ -1,6 +1,7 @@
1
1
  import { Compile } from "typebox/compile";
2
2
  import { Value } from "typebox/value";
3
3
  import { sliceHeadSafe } from "../../core/surrogate-safe-slice.js";
4
+ import { thrownIs, thrownMarksOf, thrownText } from "../../core/thrown-value.js";
4
5
  import { projectToolSchema } from "../../brain/tool-schema-projection.js";
5
6
  const validatorCache = new WeakMap();
6
7
  const TYPEBOX_KIND = Symbol.for("TypeBox.Kind");
@@ -394,7 +395,33 @@ export function toolNameIndex(tools) {
394
395
  export function findToolByName(tools, name) {
395
396
  return toolNameIndex(tools)(name);
396
397
  }
398
+ const RUNTIME_LIMIT_PHRASES = [
399
+ "Maximum call stack size exceeded",
400
+ "Invalid array length",
401
+ "Invalid string length",
402
+ "Invalid array buffer length",
403
+ "Invalid typed array length",
404
+ "Array buffer allocation failed",
405
+ ];
406
+ function runtimeLimitWords(err) {
407
+ if (!thrownIs(err, RangeError))
408
+ return undefined;
409
+ const words = thrownText(err);
410
+ return RUNTIME_LIMIT_PHRASES.some((phrase) => words.startsWith(phrase)) ? words : undefined;
411
+ }
397
412
  export function validateToolArguments(tool, toolCall) {
413
+ try {
414
+ return checkToolArguments(tool, toolCall);
415
+ }
416
+ catch (err) {
417
+ const words = runtimeLimitWords(err);
418
+ if (words === undefined)
419
+ throw err;
420
+ const marks = thrownMarksOf(err);
421
+ throw Object.assign(new Error(validationFailureText(tool, toolCall, `- checking the arguments ran into a limit of this runtime (${words}); the call was not run`), { cause: err }), marks !== undefined ? { details: marks } : {});
422
+ }
423
+ }
424
+ function checkToolArguments(tool, toolCall) {
398
425
  const args = structuredClone(toolCall.arguments);
399
426
  Value.Convert(tool.parameters, args);
400
427
  const validator = getValidator(tool.parameters);
@@ -415,7 +442,9 @@ export function validateToolArguments(tool, toolCall) {
415
442
  if (validator.Check(args)) {
416
443
  return args;
417
444
  }
418
- const errors = synthesizeValidationIssues([...validator.Errors(args)], args);
445
+ throw new Error(validationFailureText(tool, toolCall, synthesizeValidationIssues([...validator.Errors(args)], args)));
446
+ }
447
+ function validationFailureText(tool, toolCall, body) {
419
448
  const schemaJson = (() => {
420
449
  try {
421
450
  const s = JSON.stringify(projectToolSchema(tool.parameters));
@@ -425,7 +454,7 @@ export function validateToolArguments(tool, toolCall) {
425
454
  return "(schema not serializable)";
426
455
  }
427
456
  })();
428
- throw new Error(`Validation failed for tool "${toolCall.name}":\n${errors}\n\nExpected parameter schema:\n${schemaJson}`);
457
+ return `Validation failed for tool "${toolCall.name}":\n${body}\n\nExpected parameter schema:\n${schemaJson}`;
429
458
  }
430
459
  const VALIDATION_ERROR_SCHEMA_MAX_CHARS = 4_000;
431
460
  const VALIDATION_ERROR_ISSUES_MAX_CHARS = 2_000;
@@ -11,7 +11,7 @@ import { TransportLspSession } from "../../core/lsp-session.js";
11
11
  import { StdioLspTransport } from "./stdio-lsp-transport.js";
12
12
  import { MAX_LSP_FILE_BYTES, SharedAbortScope, settleOnAbort } from "../../core/lsp.js";
13
13
  import { asThrownError, thrownText } from "../../core/thrown-value.js";
14
- import { announceSecretEnvScrub, hostChildEnv, hostChildEnvProblem } from "../../core/secret-env.js";
14
+ import { announceSecretEnvScrub, hostChildEnv, hostChildEnvProblem, noteChildSpawned } from "../../core/secret-env.js";
15
15
  export const DEFAULT_LSP_SERVERS = {
16
16
  typescript: "typescript-language-server --stdio",
17
17
  javascript: "typescript-language-server --stdio",
@@ -364,6 +364,7 @@ const lspSpawnWithEnv = (grant, onNotice) => (command, args, cwd, signal) => new
364
364
  const { env, withheld } = hostChildEnv("scrub", grant);
365
365
  announceSecretEnvScrub(onNotice, withheld);
366
366
  child = spawn(command, args, { ...lspSpawnOptions(cwd), env });
367
+ noteChildSpawned("scrub");
367
368
  }
368
369
  catch (e) {
369
370
  return reject(asThrownError(e));
@@ -1,4 +1,4 @@
1
- import { SessionError, normalizeAnnouncedListing, normalizeReminderMark, normalizeGitAnnouncement, isSessionCheckoutStand, normalizeSessionCheckoutFact, normalizeSessionCheckoutStatement, normalizeWorkspaceState, normalizeCompactionStateCarrier, isValidThinkingLevelChange, isValidModelChange, isOptionalDisplayString, } from "../harness/types.js";
1
+ import { SessionError, normalizeAnnouncedListing, normalizeReminderMark, isRunLedgerRecord, normalizeGitAnnouncement, isSessionCheckoutStand, normalizeSessionCheckoutFact, normalizeSessionCheckoutStatement, normalizeWorkspaceState, normalizeCompactionStateCarrier, isValidThinkingLevelChange, isValidModelChange, isOptionalDisplayString, } from "../harness/types.js";
2
2
  import { leafIdAfterEntry } from "./storage-base.js";
3
3
  import { parseSessionTimestampMs } from "./timestamps.js";
4
4
  import { flattenableUserText, normalizeEngineSegments } from "../../core/untrusted-text.js";
@@ -127,6 +127,11 @@ export class StreamingImportValidator {
127
127
  throw new SessionError("invalid_session", `reminder_mark entry "${e.id}" is structurally invalid`);
128
128
  }
129
129
  }
130
+ else if (e.type === "run_ledger") {
131
+ if (!isRunLedgerRecord(e.ledger)) {
132
+ throw new SessionError("invalid_session", `run_ledger entry "${e.id}" is structurally invalid`);
133
+ }
134
+ }
130
135
  else if (e.type === "git_announcement") {
131
136
  if (!normalizeGitAnnouncement(e)) {
132
137
  throw new SessionError("invalid_session", `git_announcement entry "${e.id}" is structurally invalid`);
@@ -1,6 +1,6 @@
1
1
  import type { ImageContent, TextContent } from "../llm/index.js";
2
2
  import type { AgentMessage } from "../loop/types.js";
3
- import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput, GitAnnouncementState, Session, SessionCheckoutRecord, SessionCheckoutStand, SessionCheckoutStatement, SessionContext, SessionMetadata, SessionStorage, SessionTreeEntry, WorkspaceState } from "../harness/types.js";
3
+ import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput, GitAnnouncementState, RunLedgerEntry, Session, SessionCheckoutRecord, SessionCheckoutStand, SessionCheckoutStatement, SessionContext, SessionMetadata, SessionStorage, SessionTreeEntry, WorkspaceState } from "../harness/types.js";
4
4
  import type { BuildContextOptions } from "../harness/types.js";
5
5
  import type { PromptEpochDescriptor, StoredPromptEpoch } from "../../prompt-assembly/epoch.js";
6
6
  /** Which entry types the branch renders into the model's context — the one table, read twice: by the renderer below (a type
@@ -95,6 +95,14 @@ export declare class StoredSession<TMetadata extends SessionMetadata = SessionMe
95
95
  * verify port on the value it is persisting.
96
96
  */
97
97
  appendReminderMark(mark: string): Promise<string>;
98
+ /**
99
+ * Persist a run's member ledger snapshot (`TaskSpec.runLedger`) as a first-class {@link RunLedgerEntry} — written beside each
100
+ * delivery of the run's report tool and once at the run's end. The ledger is kept as plain data (a structured copy: nothing the
101
+ * caller holds afterwards can change what was written); a value that is not a ledger record refuses.
102
+ */
103
+ appendRunLedger(ledger: RunLedgerEntry["ledger"]): Promise<string>;
104
+ /** The run-ledger entries on the ACTIVE branch, oldest first (malformed ones skipped) — what a reopened session replays. */
105
+ getRunLedgers(): Promise<RunLedgerEntry["ledger"][]>;
98
106
  /**
99
107
  * design/319: recover the session's reminder provenance mark for the ACTIVE branch — the nearest
100
108
  * `reminder_mark` entry walking back from the leaf (SNAPSHOT semantics: first hit wins).
@@ -225,8 +233,13 @@ export type SessionCheckoutRead = {
225
233
  * reads (a window cut along the branch alone does not load other branches: KNOWN-LIMITS KL-3468-b). Never
226
234
  * best-effort: a store read that throws, an own entry or restatement that is not structurally valid, a restatement that says
227
235
  * unreadable, two different allocations, or a release that names another allocation answers `unreadable`.
236
+ *
237
+ * A package-root export (#4898): a host reads with it whether a session has a checkout record before it releases or admits a leg.
238
+ * `sessionId` absent ⇒ the session row's own id (`getMetadata().id`), the id the release door reads — a row that cannot be read answers
239
+ * `unreadable`, never `none` (an explicit `sessionId` reads the log directly without reading metadata). Zero writes: no entry appended,
240
+ * no environment opened, no git run; every read or fold failure answers `unreadable` rather than rejecting.
228
241
  */
229
- export declare function readSessionCheckout(session: Session, sessionId: string): Promise<SessionCheckoutRead>;
242
+ export declare function readSessionCheckout(session: Session, sessionId?: string): Promise<SessionCheckoutRead>;
230
243
  /** #3468: what a compaction restates of `sessionId`'s checkout — only a fact of the log later entries add to but never overturn: what the
231
244
  * reader vouches for (no `window`: not the view's), and a `none` only where no declaration can follow (`closed`:
232
245
  * {@link checkoutDeclarationClosed} as the compaction lands). Else nothing. */