@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
@@ -6,10 +6,11 @@ import { callKeyOrdinal, readWorkflowJournalEntry, launchRecordToKeepOrThrow, re
6
6
  import { processCensus, processFingerprint } from "../../core/process-identity.js";
7
7
  import { AppendLog, readJsonlRecords } from "./fs-atomic.js";
8
8
  import { guardCorruptSink } from "./corrupt-read-sink.js";
9
- import { BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
9
+ import { atomicWriteFile, BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
10
10
  import { assertAdoptionBootGate } from "./adoption/marker.js";
11
11
  import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
12
12
  import { assertJournalEntryFits } from "../../core/workflow-journal-store.js";
13
+ const TOMBSTONE_CLAIM_HOLDER = "workflow:stopped";
13
14
  function holderProcessOf(v) {
14
15
  if (v === null || typeof v !== "object" || Array.isArray(v))
15
16
  return undefined;
@@ -26,12 +27,14 @@ function holderProcessOf(v) {
26
27
  return { pid: r.pid, startedAtMs, startedSinceBootMs, host: r.host, ...(typeof r.pidNs === "string" ? { pidNs: r.pidNs } : {}) };
27
28
  }
28
29
  function claimBinds(claim, now) {
30
+ if (claim.stopped !== undefined)
31
+ return true;
29
32
  if (claim.rec.expiresAt <= now)
30
33
  return false;
31
34
  return claim.process === undefined || processCensus().verdict(claim.process).state !== "gone";
32
35
  }
33
36
  function heldHere(claim, newRunId) {
34
- if (claim.rec.holder !== newRunId || claim.process === undefined)
37
+ if (claim.stopped !== undefined || claim.rec.holder !== newRunId || claim.process === undefined)
35
38
  return false;
36
39
  const me = processFingerprint();
37
40
  return claim.process.pid === me.pid && claim.process.host === me.host && claim.process.pidNs === me.pidNs;
@@ -298,7 +301,8 @@ export class FileWorkflowJournalStore {
298
301
  if (typeof rec.holder !== "string" || typeof rec.expiresAt !== "number" || !Number.isFinite(rec.expiresAt)) {
299
302
  return { raw, claim: undefined };
300
303
  }
301
- return { raw, claim: { rec, process: holderProcessOf(rec.holderProcess) } };
304
+ const stopped = typeof rec.stoppedBy === "string" && rec.stoppedBy.length > 0 ? { by: rec.stoppedBy } : undefined;
305
+ return { raw, claim: { rec, process: holderProcessOf(rec.holderProcess), stopped } };
302
306
  }
303
307
  catch {
304
308
  return { raw, claim: undefined };
@@ -335,6 +339,35 @@ export class FileWorkflowJournalStore {
335
339
  gate.release();
336
340
  }
337
341
  }
342
+ replaceIfUnchanged(path, judged, payload) {
343
+ const gate = this.gateAt(path, judged);
344
+ try {
345
+ gate.acquire();
346
+ }
347
+ catch (err) {
348
+ if (err instanceof FileStoreLockError && (err.code === "store.dir_in_use" || err.code === "store.dir_claiming"))
349
+ return "contended";
350
+ throw err;
351
+ }
352
+ try {
353
+ let now;
354
+ try {
355
+ now = readFileSync(path, "utf8");
356
+ }
357
+ catch (err) {
358
+ if (err.code === "ENOENT")
359
+ return "changed";
360
+ throw err;
361
+ }
362
+ if (now !== judged)
363
+ return "changed";
364
+ atomicWriteFile(this.claimsDir, path, payload);
365
+ return "replaced";
366
+ }
367
+ finally {
368
+ gate.release();
369
+ }
370
+ }
338
371
  gateAt(path, judged) {
339
372
  const gatePath = judged === undefined ? path : join(this.claimsDir, `${createHash("sha256").update(`${basename(path)}\n${judged}`).digest("hex").slice(0, 32)}.takeover`);
340
373
  return new BootLock(gatePath, RESUME_CLAIM_TTL_MS);
@@ -358,7 +391,9 @@ export class FileWorkflowJournalStore {
358
391
  const read = this.readClaimAt(path);
359
392
  if (read === undefined)
360
393
  continue;
361
- if (read.claim !== undefined ? read.claim.rec.expiresAt + RESUME_CLAIM_REAP_GRACE_MS > now : now - statSync(path).mtimeMs <= RESUME_CLAIM_TTL_MS) {
394
+ if (read.claim !== undefined
395
+ ? read.claim.stopped !== undefined || read.claim.rec.expiresAt + RESUME_CLAIM_REAP_GRACE_MS > now
396
+ : now - statSync(path).mtimeMs <= RESUME_CLAIM_TTL_MS) {
362
397
  continue;
363
398
  }
364
399
  this.removeIfUnchanged(path, read.raw);
@@ -399,6 +434,9 @@ export class FileWorkflowJournalStore {
399
434
  if (read === undefined)
400
435
  continue;
401
436
  const existing = read.claim;
437
+ if (existing !== undefined && existing.stopped !== undefined) {
438
+ return { granted: false, stopped: existing.stopped };
439
+ }
402
440
  const now = Date.now();
403
441
  if (existing !== undefined && claimBinds(existing, now)) {
404
442
  const left = resumeClaimRemainingMember(existing.rec.expiresAt, now);
@@ -409,6 +447,9 @@ export class FileWorkflowJournalStore {
409
447
  this.removeIfUnchanged(path, read.raw);
410
448
  }
411
449
  const winner = this.readClaimAt(path)?.claim;
450
+ if (winner !== undefined && winner.stopped !== undefined) {
451
+ return { granted: false, stopped: winner.stopped };
452
+ }
412
453
  const lastLook = Date.now();
413
454
  const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
414
455
  if (bound !== undefined && heldHere(bound, newRunId))
@@ -425,7 +466,7 @@ export class FileWorkflowJournalStore {
425
466
  return;
426
467
  }
427
468
  const existing = read?.claim;
428
- if (read === undefined || existing === undefined || !heldHere(existing, input.newRunId))
469
+ if (read === undefined || existing === undefined || existing.stopped !== undefined || !heldHere(existing, input.newRunId))
429
470
  return;
430
471
  if (existing.rec.expiresAt - Date.now() <= RESUME_CLAIM_RELEASE_GRACE_MS)
431
472
  return;
@@ -435,6 +476,53 @@ export class FileWorkflowJournalStore {
435
476
  catch {
436
477
  }
437
478
  }
479
+ async stopResumeClaim(input) {
480
+ if (typeof input.stoppedBy !== "string" || input.stoppedBy === "") {
481
+ throw new TypeError("workflow journal: stopResumeClaim requires a non-empty stoppedBy string");
482
+ }
483
+ const { sourceRunId, scope, stoppedBy, holder } = input;
484
+ const path = this.claimPathFor(sourceRunId, scope);
485
+ mkdirSync(this.claimsDir, { recursive: true, mode: 0o700 });
486
+ const record = {
487
+ sourceRunId,
488
+ holder: TOMBSTONE_CLAIM_HOLDER,
489
+ expiresAt: Number.MAX_SAFE_INTEGER,
490
+ stoppedBy,
491
+ stoppedAt: Date.now(),
492
+ };
493
+ const payload = JSON.stringify(record);
494
+ for (let attempt = 0; attempt < 2; attempt++) {
495
+ try {
496
+ writeThenLink(path, payload);
497
+ return { stopped: true };
498
+ }
499
+ catch (err) {
500
+ if (err.code !== "EEXIST")
501
+ throw err;
502
+ }
503
+ const read = this.readClaimAt(path);
504
+ if (read === undefined)
505
+ continue;
506
+ const existing = read.claim;
507
+ if (existing !== undefined && existing.stopped !== undefined) {
508
+ return { stopped: true };
509
+ }
510
+ const now = Date.now();
511
+ const binds = existing !== undefined && claimBinds(existing, now);
512
+ if (binds && (holder === undefined || existing.rec.holder !== holder)) {
513
+ return { stopped: false, holder: existing.rec.holder };
514
+ }
515
+ const replaced = this.replaceIfUnchanged(path, read.raw, payload);
516
+ if (replaced === "replaced")
517
+ return { stopped: true };
518
+ }
519
+ const winner = this.readClaimAt(path)?.claim;
520
+ if (winner !== undefined && winner.stopped !== undefined)
521
+ return { stopped: true };
522
+ const lastLook = Date.now();
523
+ const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
524
+ return { stopped: false, ...(bound !== undefined ? { holder: bound.rec.holder } : {}) };
525
+ }
438
526
  dispose() {
439
527
  if (this.closed)
440
528
  return;
@@ -95,7 +95,7 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
95
95
  /** The end of a batch of {@link deleteRun} calls (interface: {@link WorkflowRunStore.settleErasure}): the ledger compacted once. */
96
96
  settleErasure(): Promise<void>;
97
97
  /** The session's terminal runs, deleted each under its own id lock with the selection re-checked against the live row (interface:
98
- * {@link WorkflowRunStore.deleteBySession}) — a run a concurrent update flipped back to running is kept, as `reap` keeps one. */
98
+ * {@link WorkflowRunStore.deleteBySession}) — a run removed or replaced by a new running run is skipped, as `reap` skips one. */
99
99
  deleteBySession(sessionId: string, scope: string): Promise<string[]>;
100
100
  /** Force a compaction now (test/inspection): rewrite the snapshot from the authoritative map and
101
101
  * truncate the live ledger (RB-167's closeForSwap recipe lives in the base). */
@@ -0,0 +1,23 @@
1
+ import { type ExecutionEnv } from "../../internal/harness.js";
2
+ import type { ExecutionEnvExecOptions, ReadFloor } from "../../internal/harness-types.js";
3
+ import { modelShellOf, startsInBackground } from "../../core/model-shell.js";
4
+ export { modelShellOf, startsInBackground };
5
+ /** The one result a background command gets where none can run here (`BASH_BACKGROUND_UNAVAILABLE`, a module constant). */
6
+ export declare function bashBackgroundUnavailable(): {
7
+ content: string;
8
+ isError: true;
9
+ };
10
+ /** What both Bash faces answer, first of all, on an environment that declares no start for model text — before any admission, probe
11
+ * or start: a background command the background-unavailable result; a foreground one the never-started failure, thrown. `undefined`
12
+ * when the environment declares a start. */
13
+ export declare function refuseWithoutModelShell(env: ExecutionEnv, background: boolean): {
14
+ content: string;
15
+ isError: true;
16
+ } | undefined;
17
+ /** The foreground start for model text, with the call's byte floor (`readFloor`, a parameter every caller gives — `undefined` when the
18
+ * call carries none — written into the start's options here, where the start is made): the start's `exec`, called on the start — or,
19
+ * on an environment that declares none, the never-started failure (`shell_unavailable`), nothing started. */
20
+ export declare function modelShellExec(env: ExecutionEnv, command: string, readFloor: ReadFloor | undefined, options: ExecutionEnvExecOptions): ReturnType<ExecutionEnv["exec"]>;
21
+ /** Whether a background command can run here: the environment runs background processes and its start for model text has a
22
+ * background face (a background command is model text too). */
23
+ export declare function startsModelTextInBackground(env: ExecutionEnv): boolean;
@@ -0,0 +1,25 @@
1
+ import { errorResult } from "../../core/tools.js";
2
+ import { ExecutionError } from "../../internal/harness.js";
3
+ import { MODEL_SHELL_UNDECLARED_REFUSAL, modelShellOf, startsInBackground } from "../../core/model-shell.js";
4
+ import { hasBackgroundShell } from "../../core/background-shell.js";
5
+ import { BASH_BACKGROUND_UNAVAILABLE } from "./fs-bash-background-text.js";
6
+ export { modelShellOf, startsInBackground };
7
+ export function bashBackgroundUnavailable() {
8
+ return errorResult(BASH_BACKGROUND_UNAVAILABLE);
9
+ }
10
+ export function refuseWithoutModelShell(env, background) {
11
+ if (modelShellOf(env) !== undefined)
12
+ return undefined;
13
+ if (background)
14
+ return bashBackgroundUnavailable();
15
+ throw new Error(`Error (Bash): command did not run: ${MODEL_SHELL_UNDECLARED_REFUSAL}`);
16
+ }
17
+ export function modelShellExec(env, command, readFloor, options) {
18
+ const start = modelShellOf(env);
19
+ if (start === undefined)
20
+ return Promise.resolve({ ok: false, error: new ExecutionError("shell_unavailable", MODEL_SHELL_UNDECLARED_REFUSAL) });
21
+ return start.exec(command, { ...options, ...(readFloor !== undefined ? { readFloor } : {}) });
22
+ }
23
+ export function startsModelTextInBackground(env) {
24
+ return hasBackgroundShell(env) && startsInBackground(modelShellOf(env));
25
+ }
@@ -468,6 +468,12 @@ export declare function expansionInWord(w: {
468
468
  export declare function globInWord(w: {
469
469
  readonly pieces: readonly WordPiece[];
470
470
  }): boolean;
471
+ /** Does this word carry a BRACKET expression the shell forms — a pathname-expansion piece the lexer carved from an unquoted `[`
472
+ * with an unquoted `]` after it (the one such piece with a `body`; `*` and `?` have none)? Where the class closes is the
473
+ * lexer's business, not this answer's: a collating symbol by name (`[[.period.]]`) is one too. */
474
+ export declare function bracketInWord(w: {
475
+ readonly pieces: readonly WordPiece[];
476
+ }): boolean;
471
477
  /**
472
478
  * Read ONE sed script and answer whether it can name a file or run a command.
473
479
  *
@@ -287,6 +287,9 @@ export function globInWord(w) {
287
287
  }
288
288
  return false;
289
289
  }
290
+ export function bracketInWord(w) {
291
+ return w.pieces.some((p) => isGlobPiece(p) && p.expansion?.body !== undefined);
292
+ }
290
293
  const SED_READONLY_SCRIPT_PIECE = /^(?:\d+|\d+,\d+)?p$/;
291
294
  const SED_FILE_OR_EXEC_COMMANDS = new Set(["r", "R", "w", "W", "e"]);
292
295
  const SED_PLAIN_COMMANDS = new Set(["=", "d", "D", "F", "g", "G", "h", "H", "n", "N", "p", "P", "x", "z"]);
@@ -23,10 +23,16 @@ export function createFileWriteStation(opts) {
23
23
  return null;
24
24
  return (async () => {
25
25
  const r = await opts.contain(spelled, signal, callOpts.toolCallId);
26
- if (r.ok || r.violation.code !== "path_not_in_root")
26
+ if (r.ok)
27
27
  return VOUCH;
28
- const details = violationDetails(r.violation);
29
- return { disposition: "refuse", finding: "outside_roots", face: "write", sentence: violationText(call.toolName, r.violation), ...(details !== undefined ? { details } : {}) };
28
+ if (r.violation.code === "path_not_in_root") {
29
+ const details = violationDetails(r.violation);
30
+ return { disposition: "refuse", finding: "outside_roots", face: "write", sentence: violationText(call.toolName, r.violation), ...(details !== undefined ? { details } : {}) };
31
+ }
32
+ if (r.violation.code === "write_path_denied") {
33
+ return { disposition: "refuse", finding: "deny_hit", face: "write", sentence: violationText(call.toolName, r.violation), ...(r.violation.echoed !== undefined ? { echoed: r.violation.echoed } : {}) };
34
+ }
35
+ return VOUCH;
30
36
  })();
31
37
  },
32
38
  unanswered: () => VOUCH,
@@ -1,6 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { Type } from "typebox";
3
3
  import { defineTool, errorResult } from "../../core/tools.js";
4
+ import { bashBackgroundUnavailable, modelShellExec, modelShellOf, refuseWithoutModelShell, startsInBackground, startsModelTextInBackground } from "./bash-model-shell.js";
4
5
  import { callOccupant } from "../../core/task-registry-shared.js";
5
6
  import { markTruncated, RollingTailBuffer } from "../../core/exec-output-tail.js";
6
7
  import { BACKGROUND_START_FAILURE_KINDS, createBackgroundOutputFile, envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../../core/background-shell.js";
@@ -11,7 +12,7 @@ import { admitImageBytes, sniffImageMime } from "../../core/image-admission.js";
11
12
  import { isDeadCwd, diagnoseDeadCwd } from "./dead-cwd.js";
12
13
  import { boundaryIsTheSandbox, hasDestroy, isIsolated } from "../../core/remote-env.js";
13
14
  import { ghRateLimitHint } from "./gh-rate-limit.js";
14
- import { backgroundLifetimeNote, backgroundOutputFileNote, BASH_BACKGROUND_UNAVAILABLE, ONE_SHOT_BACKGROUND_COMMAND_NOTE } from "./fs-bash-background-text.js";
15
+ import { backgroundLifetimeNote, backgroundOutputFileNote, ONE_SHOT_BACKGROUND_COMMAND_NOTE } from "./fs-bash-background-text.js";
15
16
  import { admitsBackgroundLaunch, resolveCompletionSink } from "../../core/task-notification.js";
16
17
  import { resolveBashTimeoutCaps, bashTimeoutCapsSec, bashTimeoutArgRefusal, bashTimeoutParamDescription, bashMaxOutputChars, clipShellOutput, writeShellOverflowFile, shellRecoveryHint, zeroOutputSentence, targetUnavailableCard, targetUnavailableSentence, bashFailureCard, CWD_SENTINEL, stripCwdSentinel, } from "./fs-shared.js";
17
18
  import { envErrorDetail, failureMessageOnce } from "./env-error-detail.js";
@@ -323,13 +324,12 @@ async function runShell(env, cwd, toolName, command, timeoutSec, caps, signal, c
323
324
  const live = onTick === undefined ? undefined : startLivenessTicks(onTick, cwdRef ? createEpilogueFilter(cwdMarker) : undefined);
324
325
  let res;
325
326
  try {
326
- res = await env.exec(toRun, {
327
+ res = await modelShellExec(env, toRun, readFloor, {
327
328
  cwd: effectiveCwd,
328
329
  timeout,
329
330
  abortSignal: signal,
330
331
  ...execEnv,
331
332
  ...(live !== undefined ? { onStdout: live.onStdout, onStderr: live.onStderr } : {}),
332
- ...(readFloor !== undefined ? { readFloor } : {}),
333
333
  ...(sandboxStart?.ok === true && sandboxStart.sandbox !== undefined ? { sandbox: sandboxStart.sandbox } : {}),
334
334
  ...(detach
335
335
  ? {
@@ -557,8 +557,9 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
557
557
  const timeoutCapsSecView = bashTimeoutCapsSec(timeoutCaps);
558
558
  const refusalTold = new Set();
559
559
  const breachLedger = execFailureBreachLedger();
560
- const bgOffered = hasBackgroundShell(env) && taskOpts.taskRegistry !== undefined;
561
- const bgRetained = hasBackgroundShell(env) && retainsBackgroundProcesses({ env: envDeclaresRetain(env), task: taskOpts.retainBackgroundProcesses === true });
560
+ const bgStarts = startsModelTextInBackground(env);
561
+ const bgOffered = bgStarts && taskOpts.taskRegistry !== undefined;
562
+ const bgRetained = bgStarts && retainsBackgroundProcesses({ env: envDeclaresRetain(env), task: taskOpts.retainBackgroundProcesses === true });
562
563
  const bgSessionScoped = taskOpts.sessionId !== undefined && taskOpts.taskRegistry !== undefined;
563
564
  const bgEnvIsolatedOwned = hasDestroy(env) && isIsolated(env);
564
565
  const cardOf = (shellFirst) => bashDescription(coAuthor, timeoutCaps, bgOffered, bgRetained, bgSessionScoped, bgEnvIsolatedOwned, taskOpts.commandSandbox !== undefined ? "command" : isIsolated(env) ? "env" : "none", shellFirst);
@@ -605,14 +606,15 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
605
606
  const timeoutRefusal = bashTimeoutArgRefusal(timeout, timeoutCaps);
606
607
  if (timeoutRefusal !== undefined)
607
608
  return errorResult(timeoutRefusal, { type: "bash_invalid_timeout", code: "bash_invalid_timeout" });
608
- const refused = (await taskOpts.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal)) ?? (await patternKillRefusal(command, env, cwdRef.current, ctx.signal));
609
+ const refused = refuseWithoutModelShell(env, run_in_background === true) ?? (await taskOpts.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal)) ?? (await patternKillRefusal(command, env, cwdRef.current, ctx.signal));
609
610
  if (refused !== undefined)
610
611
  return refused;
611
612
  if (run_in_background) {
612
613
  const registry = taskOpts.taskRegistry;
613
614
  const onNotify = resolveCompletionSink(ctx.onTaskNotification, taskOpts.onTaskNotification);
614
- if (!hasBackgroundShell(env) || registry === undefined || !admitsBackgroundLaunch(onNotify))
615
- return errorResult(BASH_BACKGROUND_UNAVAILABLE);
615
+ const start = modelShellOf(env);
616
+ if (!hasBackgroundShell(env) || !startsInBackground(start) || registry === undefined || !admitsBackgroundLaunch(onNotify))
617
+ return bashBackgroundUnavailable();
616
618
  if (cwdRef && (await isDeadCwd(env, cwdRef.current, ctx.signal))) {
617
619
  const diagnosis = await diagnoseDeadCwd(env, "Bash", cwdRef.current, rootCanonical, cwdRef, ctx.signal);
618
620
  if (diagnosis !== undefined)
@@ -625,7 +627,7 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
625
627
  const sandbox = taskOpts.commandSandbox?.start();
626
628
  if (sandbox !== undefined && !sandbox.ok)
627
629
  return errorResult(sandboxRefusalText("Bash", { by: "plan", reason: sandbox.reason }), { type: "bash", sandboxUnavailable: true });
628
- const r = await env.spawnBackground(command, {
630
+ const r = await start.spawnBackground(command, {
629
631
  cwd: cwdRef.current,
630
632
  ...(requestedTimeoutSec !== undefined ? { timeout: requestedTimeoutSec } : {}),
631
633
  ...(readFloor !== undefined ? { readFloor } : {}),
@@ -706,7 +708,7 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
706
708
  backgroundedForQueuedMessage = true;
707
709
  detachHub.request(ctx.toolCallId);
708
710
  };
709
- const detachEnv = hasBackgroundShell(env) ? env : undefined;
711
+ const detachEnv = bgStarts && hasBackgroundShell(env) ? env : undefined;
710
712
  const detachSink = resolveCompletionSink(ctx.onTaskNotification, taskOpts.onTaskNotification);
711
713
  const detachChain = detachHub !== undefined && detachRegistry !== undefined && detachEnv !== undefined && admitsBackgroundLaunch(detachSink) && detachEnv.backgroundCapabilities.supportsDetach === true
712
714
  ? {
@@ -844,7 +846,7 @@ export function createBashReadonlyTool(env, rootCanonical, allow, opts) {
844
846
  const reason = readOnlyFaceRefusal(command, allow);
845
847
  if (reason)
846
848
  return errorResult(`Error (Bash): ${reason}`);
847
- const refused = await opts?.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal);
849
+ const refused = refuseWithoutModelShell(env, false) ?? (await opts?.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal));
848
850
  if (refused !== undefined)
849
851
  return refused;
850
852
  const readOnlyTick = opts?.onToolProgress === undefined ? undefined : (t) => describeSafely(opts.onToolProgress, { toolCallId: ctx.toolCallId, toolName: "Bash", ...t });
@@ -180,13 +180,14 @@ export interface HandsToolkitOptions {
180
180
  * roster (the Runner mounts Monitor, this band never does). `false` drops the gh rate-limit hint's
181
181
  * Monitor clause; absent ⇒ the full wording. */
182
182
  monitorToolActive?: boolean;
183
- /** ADDITIONS to the built-in sensitive-path READ deny set
184
- * ({@link import("./read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}), judged by the structured read
185
- * faces (Read/Grep/Glob/RepoMap and their traversals) in BOTH containment modes. Add-only:
186
- * additions union with the active built-ins, `[]` ≡ absent (union identity), and additions can
187
- * never remove a built-in — the one removal channel is the deployment's built-in configuration
188
- * ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude}). Bad entry shapes throw at wiring
189
- * time. The write faces are untouched (their guard is createSensitivePathPolicy). */
183
+ /** ADDITIONS to the sensitive-path deny set ({@link import("./read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}):
184
+ * judged on BOTH the read faces (Read/Grep/Glob/RepoMap and their traversals) and the write faces
185
+ * (Write/Edit/NotebookEdit/SaveToolResult; this band's Bash meets them only through a caller-supplied shell
186
+ * station, which judges literal write operands) in every containment mode. Built-in tiers
187
+ * stay read-only (their write side is the write-protection table). Add-only: additions union with the active
188
+ * built-ins, `[]` ≡ absent (union identity), and additions never remove a built-in — the one removal channel
189
+ * is the deployment's built-in configuration ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude}).
190
+ * Bad entry shapes throw at wiring time. */
190
191
  readDenyPatterns?: readonly ReadDenyEntry[];
191
192
  /** The deployment's built-in-table TIER selection ({@link import("./read-deny.js").ReadDenyBuiltinConfig}
192
193
  * `tiers` key) — the switch for the built-in table:
@@ -91,12 +91,12 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
91
91
  afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.imageProcessor, opts.pdfModelCapabilities, bgOutputReadExemption, readDeny, readFace, opts.reminderMark, opts.reminderDisclosureCounts, reader)),
92
92
  ];
93
93
  if (handsWriteHalfMounts({ readOnly })) {
94
- tools.push(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, readDeny, opts.readFirstWaiver), createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, opts.readFirstWaiver), createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
94
+ tools.push(afterPlacement(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, readDeny, opts.readFirstWaiver)), afterPlacement(createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, opts.readFirstWaiver)), afterPlacement(createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny)));
95
95
  const keptBytes = opts.toolResultBytes;
96
96
  if (opts.writeContainmentSeat !== undefined)
97
97
  opts.writeContainmentSeat.current = writeContainmentOf(env, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, writeDeny, writeFaceOf);
98
98
  if (keptBytes?.bytesOf !== undefined)
99
- tools.push(createSaveToolResultTool(env, keptBytes, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
99
+ tools.push(afterPlacement(createSaveToolResultTool(env, keptBytes, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny)));
100
100
  }
101
101
  tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)));
102
102
  if (includeShell) {
@@ -171,7 +171,7 @@ function bandOwnTables(env, opts) {
171
171
  return await tool.execute(...args);
172
172
  },
173
173
  };
174
- const writeDenyCompiled = compileWriteDeny(readDenyRules);
175
- const writeDeny = writeDenyCompiled.ruleRows.length > 0 ? carryHomeViews(writeDenyCompiled, readDeny.homeViews) : undefined;
174
+ const writeDenyCompiled = compileWriteDeny(readDeny);
175
+ const writeDeny = writeDenyCompiled.hasRows ? carryHomeViews(writeDenyCompiled, readDeny.homeViews) : undefined;
176
176
  return { readDeny, writeDeny, afterPlacement };
177
177
  }
@@ -171,7 +171,7 @@ export declare function homeViewsAt(env: HomeViewEnv, homes: readonly string[]):
171
171
  /** The home views of one judgment, off the judge it judges with: the views of the judge's placement. A judge that
172
172
  * carries none (one built outside a mount) reads the declared home alone. */
173
173
  export declare function homeViewsOf(env: HomeViewEnv, judge: HomeViewsCarrier | undefined, signal?: AbortSignal): HomeViews;
174
- /** A judge with the home views `source` gives it. */
174
+ /** A judge with the home views `source` gives it, preserving getters (live projections) and non-enumerable identity (`id`). */
175
175
  export declare function carryHomeViews<T extends object>(judge: T, source: HomeViewSource): T & {
176
176
  readonly homeViews: HomeViewSource;
177
177
  };
@@ -397,6 +397,9 @@ export function readDenyOver(current, homeViews) {
397
397
  get compiledSegments() {
398
398
  return current().compiledSegments;
399
399
  },
400
+ get tableRows() {
401
+ return current().tableRows;
402
+ },
400
403
  homeViews: homeViews ?? { views: (signal) => current().homeViews.views(signal) },
401
404
  };
402
405
  }
@@ -418,11 +421,8 @@ export function homeViewsOf(env, judge, signal) {
418
421
  return (judge?.homeViews ?? homeViewsAt(env, [])).views(signal, env);
419
422
  }
420
423
  export function carryHomeViews(judge, source) {
421
- const carried = { ...judge, homeViews: source };
422
- const id = judge.id;
423
- if (typeof id === "string")
424
- Object.defineProperty(carried, "id", { value: id, enumerable: false });
425
- return carried;
424
+ const descriptors = Object.getOwnPropertyDescriptors(judge);
425
+ return Object.defineProperties({}, { ...descriptors, homeViews: { value: source, enumerable: true, writable: true, configurable: true } });
426
426
  }
427
427
  export async function placeReadDenyAtHome(env, compile, homes, signal, places) {
428
428
  const entries = compile([]).entries;
@@ -152,13 +152,17 @@ export declare function segmentGuardRow(pat: CompiledSegmentPattern, columns: {
152
152
  readonly tier?: string;
153
153
  }): PathGuardRow;
154
154
  /**
155
- * The WRITE face of the deny table: the rule rows whose faces include `write` — the judge the shell station reads for a
156
- * command's write targets (a redirection, `tee`, `sed -i`, `cp` / `mv` / `touch` / `mkdir` / `rm` operands). Same row
157
- * type, same judgment ({@link judgePathRows}) as the read face's rows; a hit names the row by its rule text.
155
+ * The WRITE face of the deny table: every row of the one deny table whose faces include `write` — deployment / task
156
+ * `readDenyPatterns` additions (`faces: ["read", "write"]`) and `Read(…)` / `Edit(…)` rule rows — judged for
157
+ * file write tools (`Write`, `Edit`, `NotebookEdit`, `SaveToolResult`) and shell write targets (a redirection, `tee`,
158
+ * `sed -i`, `cp` / `mv` / `touch` / `mkdir` / `rm` operands). Built-in read-deny tiers stay `faces: ["read"]`. Same row
159
+ * type and judgment ({@link judgePathRows}) as the read face.
158
160
  */
159
161
  export interface WriteDenyMatcher {
160
162
  /** Which face this judge is — the write tools' path resolution reads it to word and code the refusal as a write. */
161
163
  readonly face: "write";
164
+ /** True iff the write projection holds at least one row (a `readDenyPatterns` addition or a write-facing rule row). */
165
+ readonly hasRows: boolean;
162
166
  readonly ruleRows: readonly PathRuleDenyRow[];
163
167
  matchPath(path: string): ReadDenyHit | null;
164
168
  /** The target judgment the read face makes, on this face's rows: canonical key, lexical view, the leaf chain's hops. */
@@ -168,13 +172,26 @@ export interface WriteDenyMatcher {
168
172
  }): ReadDenyHit | null;
169
173
  /** The table ONE call judges with ({@link ReadDenyMatcher.forCall}). */
170
174
  forCall?(toolCallId: string | undefined): WriteDenyMatcher;
171
- /** Is the row a hit named (its rule text) a row that guards the READ face too — a `Read(…)` rule on the write face, whose
172
- * paths are not written because their reads are denied — rather than a row of the write face alone? The refusal's sentence
173
- * says which of the two refused ({@link readDenySentence}'s `readRow`). Absent ⇒ no row of this table guards reads. */
175
+ /** Is the row a hit named (its pattern or rule text) a row that guards the READ face too — a `readDenyPatterns` addition
176
+ * or a `Read(…)` rule, whose paths are not written because their reads are denied — rather than a write-only row (`Edit(…)`)?
177
+ * The refusal's sentence says which of the two refused ({@link readDenySentence}'s `readRow`). Absent ⇒ none. */
174
178
  guardsReads?(pattern: string): boolean;
179
+ /** The write-facing segment row the absolute directory `scope` names or contains ({@link ReadDenyMatcher.rowUnderRoot}),
180
+ * judged on locations alone without enumerating disk (used for subtree removal / rename operations). */
181
+ rowUnderRoot?(scope: string): ReadDenyRootHit | null;
182
+ /** A write-facing row that lies AT or BELOW `path` ({@link ReadDenyMatcher.rowAtOrBelow}): segment rows are judged per row;
183
+ * non-enumerable rule rows answer for any path. */
184
+ rowAtOrBelow?(path: string): ReadDenyHit | null;
185
+ /** The write-facing segment rows no location places (an unanchored row: its match may start in any folder), in table order —
186
+ * the rows a recursive removal's subtree is searched for by name, since {@link rowUnderRoot} cannot place them below an
187
+ * operand that does not spell them. */
188
+ readonly unanchoredRows?: readonly string[];
189
+ /** The first {@link unanchoredRows} row whose leading named segment (its first segment that is not stars only) the ONE
190
+ * directory entry name `name` matches, folded as that row folds; null where none. */
191
+ rowLedByName?(name: string): string | null;
175
192
  }
176
- /** Compile the write face over the rule rows (the rows not on it are dropped here, once). */
177
- export declare function compileWriteDeny(rules?: readonly PathRuleDenyRow[]): WriteDenyMatcher;
193
+ /** Project the write face (`faces.includes("write")`) out of one compiled deny table ({@link compileReadDeny}). */
194
+ export declare function compileWriteDeny(table: ReadDenyMatcher): WriteDenyMatcher;
178
195
  /** One compiled ripgrep glob flag for the traversal legs (`--iglob` = case-insensitive entry). */
179
196
  export interface ReadDenyRgGlob {
180
197
  flag: "--glob" | "--iglob";
@@ -243,6 +260,9 @@ export interface ReadDenyMatcher {
243
260
  * OS confinement translates the table from (read-floor.ts); the rule rows are {@link ruleRows}. Absent on a hand-built
244
261
  * matcher: such a table has no confinement. */
245
262
  readonly compiledSegments?: readonly CompiledSegmentPattern[];
263
+ /** Every compiled row of this table (built-in tiers, additions, placements, and rule rows across both faces),
264
+ * each carrying its `faces` column — the one source {@link compileWriteDeny} projects the write face from. */
265
+ readonly tableRows?: readonly PathGuardRow[];
246
266
  /** The table's identity, minted once where {@link compileReadDeny} compiles it: a compiled table never changes its
247
267
  * judgment, so two tables with one `id` judge every path alike. Not enumerable: a spread copy (which may replace the
248
268
  * judgment) has none; the copy that only carries other home views (`carryHomeViews`) keeps it. Absent on a hand-built
@@ -326,6 +346,11 @@ export interface ReadDenyFinding {
326
346
  * alone. The sentence then says the search below the folder is refused for a location it holds, and that no file need be
327
347
  * there — naming a row as what "the target matches" would send the reader looking for a file that may not exist. */
328
348
  readonly under?: true;
349
+ /** On the write face, a recursive REMOVAL whose subtree was searched by name for an unanchored row
350
+ * ({@link WriteDenyMatcher.rowLedByName}) and FOUND below it: `found` — the entry the search found, which the sentence names. */
351
+ readonly lookup?: {
352
+ readonly found: string;
353
+ };
329
354
  }
330
355
  /**
331
356
  * The deny finding minted ONCE as both of its faces: the sentence ({@link readDenySentence}) and the literals that sentence