@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
@@ -10,15 +10,19 @@
10
10
  * {@link isNamespaceCredentialName} — the engine's own slots are no one else's to hand on), a list is exactly the names it
11
11
  * lists. Whatever the policy, an entry that is one of the engine's own credentials is never inherited:
12
12
  * its name is one the deployment declared, or its value equals a credential value the deployment declared or the
13
- * engine holds ({@link declareWithheldEnv}, {@link holdOwnCredentialValues}). One judgment per variable ({@link classifySecretEnvEntry}), the first rule that answers:
14
- * 1. exempt — git's environment config and the proxy variables, handed on as written ({@link isExemptEnvName});
13
+ * engine holds ({@link declareWithheldEnv}, {@link holdOwnCredentialValues}). One judgment per variable and policy
14
+ * ({@link judgeInheritedEntries}) — the first rule that answers:
15
+ * 1. exempt — git's environment config and the proxy variables, handed on as written by the shape rules ({@link isExemptEnvName});
15
16
  * 2. `exact-name` — a known credential name (the vocabulary's exact env names);
16
17
  * 3. `prefix-rule` — the OpenTelemetry settings ({@link OTEL_ENV_RE});
17
18
  * 4. `namespace-rule` — a credential word as any segment of a name in the engine's own `SEMA_` namespace;
18
19
  * 5. `name-rule` — a credential-shaped name ({@link nameIsCredentialShaped}) off the vocabulary's non-secret exact names;
19
- * 6. `value-rule` — a value that carries a credential ({@link looksLikeCredentialValue}).
20
- * {@link isSecretEnvKey} and {@link scrubSecretEnv} both answer with this one judgment; rules 2–5 are its name half
21
- * ({@link isSensitiveName}), rule 6 its value half, and rule 1 the env-entry exemption read before both. The exempt families, the
20
+ * 6. `value-rule` — a value that carries a credential ({@link looksLikeCredentialValue});
21
+ * 7. `own-credential` — one of the engine's own credentials: no policy hands it on;
22
+ * 8. `peer-held` — a variable held for a protocol peer.
23
+ * Rules 1–6 are the shape rules ({@link classifySecretEnvEntry}): 2–5 its name half ({@link isSensitiveName}), 6 its value half, 1 the
24
+ * env-entry exemption read before both. The scrub reads 1–8; `"all"` reads 4 and 7; a list reads 7. {@link isSecretEnvKey} and
25
+ * {@link scrubSecretEnv} — what a host asks — answer with the scrub's judgment the composition reads, over the tables as they stand. The exempt families, the
22
26
  * credential names, the name shape and the value predicate follow the reference implementation's subprocess-env scrub
23
27
  * as written, three ways stricter: plural `TOKENS` is a credential word unless a count word touches it, the GitHub
24
28
  * token names are not held back from the name shape, and the name shape always runs.
@@ -39,10 +43,11 @@ export declare function isNamespaceCredentialName(name: string): boolean;
39
43
  * value forms are the vocabulary's rows, {@link ENV_VALUES}). Reads the first {@link VALUE_SCAN_LIMIT} code units. The value half of the judgment, exported apart from the env
40
44
  * entry's exemptions ({@link isExemptEnvName}): a caller holding a value that is no environment variable asks this. */
41
45
  export declare function looksLikeCredentialValue(value: string): boolean;
42
- /** Which rule withheld an entry: one of the scrub's rules (the `"all"` policy withholds under `namespace-rule` alone); `peer-held` — a
43
- * variable a protocol peer's credential reference names, a token the engine holds for that peer ({@link holdPeerHeldNames}), which the
44
- * `"scrub"` policy withholds by name; or `own-credential` — the entry is one of the engine's own credentials (its name is declared, or
45
- * its value equals a declared or engine-held credential value: {@link declareWithheldEnv}), which every policy withholds. */
46
+ /** Which rule withheld an entry — the first that answers ({@link judgeInheritedEntries}): one of the scrub's shape rules (the `"all"` policy
47
+ * withholds under `namespace-rule` alone); `own-credential` — the entry is one of the engine's own credentials (its name is declared, or
48
+ * its value equals a declared or engine-held credential value: {@link declareWithheldEnv}), which every policy withholds; or `peer-held` —
49
+ * a variable a protocol peer's credential reference names, a token the engine holds for that peer ({@link holdPeerHeldNames}), which the
50
+ * `"scrub"` policy withholds by name, and which is `own-credential` when it is also one of the engine's own. */
46
51
  export type SecretEnvFindingKind = "exact-name" | "name-rule" | "namespace-rule" | "prefix-rule" | "value-rule" | "peer-held" | "own-credential";
47
52
  /** One env entry withheld (deleted) from a child's environment: its name — never its value, so the record is
48
53
  * loggable —, the rule that withheld it, how strong that claim is, and the minting module. */
@@ -60,15 +65,21 @@ export interface SecretEnvFinding {
60
65
  * entry's exemptions ({@link isExemptEnvName}): a caller holding a key that is no environment variable (a member of a
61
66
  * record) asks this, and an exempt name is no exception there. */
62
67
  export declare function isSensitiveName(key: string): boolean;
63
- /** Does the `"scrub"` policy withhold `key`? With `value`, exactly the answer {@link scrubSecretEnv} gives for that
64
- * entry; without it, the answer for its name alone (the value rule then has nothing to read). */
68
+ /** Does an entry carry a credential by its look alone (the shape rules, no table)? The question a protocol peer's seat answer is read
69
+ * by (`peer-seat.ts`: which of its environment members' values are credentials the engine takes in); not part of the package entry. */
70
+ export declare function entryLooksLikeCredential(name: string, value: string | undefined): boolean;
71
+ /** Does the `"scrub"` policy withhold `key`? The scrub's judgment ({@link judgeInheritedEntries}) over the tables as they stand — what a
72
+ * child composed now under the scrub loses: with `value`, exactly the answer {@link scrubSecretEnv} gives for that entry; without it,
73
+ * the answer for its name alone (the value rule and an own credential's value then have nothing to read). */
65
74
  export declare function isSecretEnvKey(key: string, value?: string): boolean;
66
- /** The `"scrub"` policy: `env` without every entry {@link isSecretEnvKey} withholds, the rest as written. `findings` is
67
- * an optional caller-owned collector: each withheld entry is pushed onto it (name, rule, confidence), none of them
68
- * present in the result. `env` itself is not modified. */
75
+ /** The `"scrub"` policy over `env`: `env` without every entry {@link isSecretEnvKey} withholds, the rest as written — the arm a child
76
+ * composed under the scrub reads ({@link inheritedHostEnv}). `findings` is an optional caller-owned collector: each withheld entry is
77
+ * pushed onto it (name, rule, confidence), none of them present in the result. `env` itself is not modified. */
69
78
  export declare function scrubSecretEnv(env: NodeJS.ProcessEnv, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
70
79
  /** How much of this process's environment a child spawned on this host inherits — the `inheritEnv` value. */
71
80
  export type InheritEnvPolicy = "all" | "scrub" | string[];
81
+ /** {@link envNameKey} on a named platform — the one fold, for a reader that judges another platform's environment. */
82
+ export declare function envNameKeyOn(name: string, platform: NodeJS.Platform): string;
72
83
  /** What {@link declareWithheldEnv} takes: the engine's own credentials in this process's environment. */
73
84
  export interface WithheldEnvDeclaration {
74
85
  /** Names of variables that are the engine's own credentials: never inherited, and an allow list naming one is refused. */
@@ -230,9 +241,10 @@ export interface PeerHeldEnvDeclaration {
230
241
  };
231
242
  /** To whom a person's notice that one of these variables was held back names this entry. Absent — to no one: every leg's notice says
232
243
  * another entry in this process names the variable (the narrowest, and the reading before this declaration existed).
233
- * `{ isolationScope }` — to the top-level legs whose isolation scope (`TaskSpec.isolationScope`, else `TaskSpec.principal`) is this
234
- * one; a leg that names neither is in no scope and is never named to (a scope declared as `"default"` included), and a delegated leg
235
- * never is (its notice is read at its tree's root, whose scope it cannot vouch for). `"every_leg"` — to every leg
244
+ * `{ isolationScope }` — to the legs whose isolation scope (`TaskSpec.isolationScope`, else `TaskSpec.principal`) is this one; a leg
245
+ * that names neither is in no scope and is never named to (a scope declared as `"default"` included). A delegated leg's notice is read
246
+ * at its tree's root, so it is named to only while it works in its delegation tree's domain (the one the root works in — a child the
247
+ * delegation tool starts does); a delegated leg with no tree domain, or outside it, never is. `"every_leg"` — to every leg
236
248
  * of this thread: ONLY for an entry of the deployment itself, never one of a principal's — in a deployment of several principals it
237
249
  * says the entry's name to every session. */
238
250
  readonly namedTo?: PeerHeldEnvAudience;
@@ -247,14 +259,13 @@ export interface PeerHeldEnvReceipt {
247
259
  /** The names not taken in, in the order given, each with its reason ({@link PEER_HELD_ENV_NOT_TAKEN_REASONS}). Not a refusal: every other
248
260
  * name was taken in. Empty when all were. */
249
261
  readonly notTaken: readonly PeerHeldEnvNameNotTaken[];
250
- /** The names this call took in that the table did not hold before, that this process's environment holds now, while a child's
251
- * environment was already composed under the scrub in this thread ({@link inheritedHostEnv} or {@link hostChildEnv} with a policy
252
- * that is neither `"all"` nor a list — an execution environment's read of what its shell child would get is one such composition):
253
- * a child started before this call MAY still hold one — a child's environment is composed when it starts, so a long-lived one (a
254
- * language server, a background shell) keeps what it started with. Not a statement that one does: a child composed before may have
255
- * exited, and a composition may have been a read. A child composed only under `"all"` or a list was handed these variables by its
256
- * policy anyway, so it makes nothing late. Empty otherwise. Once a Runner has been built or a child's environment composed once,
257
- * it lists every name newly taken in that this process's environment holds: it says only "may still be in a child already started". */
262
+ /** The names this call took in that the table did not hold before, that this process's environment holds now, once the engine has
263
+ * spawned a child under the scrub in this thread: a shell child of `NodeExecutionEnv` (a command — which may be adopted as a
264
+ * background shell — or a background shell) or a language server of `NodeLspManager`, from its spawn call on, whether or not the spawn
265
+ * later failed. Only ever true from then: such a child keeps the environment it started with, and one that has ended may have left a
266
+ * service holding it, so it says only "may still be in a child already started". A child under `"all"` or a list was handed these
267
+ * variables by its policy anyway; a read or a host's composition of an environment, a Runner built and the engine's own probes spawn
268
+ * no such child: none of them makes a name late. A child a host spawns itself is the host's to know about. Empty otherwise. */
258
269
  readonly heldLate: readonly string[];
259
270
  }
260
271
  /**
@@ -281,7 +292,7 @@ export interface PeerHeldEnvReceipt {
281
292
  *
282
293
  * WHEN: at start-up, before the first child is spawned — it needs no Runner, and the table is made at its first use — and again at each
283
294
  * configuration change (only what is new takes effect). A child's environment is composed when it starts: a child already running keeps
284
- * what it started with, so a declaration made after a long-lived child started is late for that child — {@link PeerHeldEnvReceipt.heldLate}
295
+ * what it started with, so a declaration made after such a child started may be late for it — {@link PeerHeldEnvReceipt.heldLate}
285
296
  * names what may be. Per THREAD, as {@link declareWithheldEnv}: a host that composes a child's environment in a worker declares there too.
286
297
  *
287
298
  * The two declarations, side by side: {@link declareWithheldEnv} — the engine's own credentials (names and values): withheld under EVERY
@@ -357,14 +368,14 @@ export declare function credentialHeaderValues(headers: Readonly<Record<string,
357
368
  /** Test seam: never called by production code (a host re-declares `{ names: [], values: [] }`; what the engine took in stays). */
358
369
  export declare function __resetWithheldEnv(): void;
359
370
  /**
360
- * THE environment a child spawned ON THIS HOST inherits: the policy's arm, less the engine's own credentials — a
361
- * declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
371
+ * THE environment a child spawned ON THIS HOST inherits: the policy's arm, which under every policy withholds the engine's own
372
+ * credentials — a declared name, or a value equal to a declared or engine-held credential value ({@link declareWithheldEnv},
362
373
  * {@link holdOwnCredentialValues}). The arms: `"scrub"` (and absent) is this process's environment through
363
- * {@link scrubSecretEnv}, less the variables the engine holds for a protocol peer ({@link holdPeerHeldNames}, by name); `"all"` is this process's environment as written, less the credential names of the engine's own
374
+ * {@link scrubSecretEnv} (the shape rules and the variables the engine holds for a protocol peer, {@link holdPeerHeldNames}, by name); `"all"` is this process's environment as written, less the credential names of the engine's own
364
375
  * namespace (the namespace rule, {@link isNamespaceCredentialName}, and none of the scrub's other rules); a `string[]` is exactly the
365
376
  * named variables that are set, as written — a strict allow list, so a name it leaves out (`PATH` included) is not
366
- * inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld: the scrub's and each
367
- * peer-held name under `"scrub"`, the namespace rule's under `"all"`, and each own credential the arm held.
377
+ * inherited, and one it names is handed on whatever its shape. `findings` collects every entry withheld, one each, under the first rule
378
+ * that answers ({@link judgeInheritedEntries}: a shape rule, else `own-credential`, else `peer-held`).
368
379
  *
369
380
  * A policy {@link inheritEnvPolicyProblem} refuses throws that reason HERE, at every spawn, read against the
370
381
  * declaration as it stands: a value that is no policy at all (never read as the scrub), and an allow list naming a
@@ -373,6 +384,13 @@ export declare function __resetWithheldEnv(): void;
373
384
  * ask first, so a host that declared before building them hears it at start-up.
374
385
  */
375
386
  export declare function inheritedHostEnv(policy: InheritEnvPolicy | undefined, findings?: SecretEnvFinding[]): NodeJS.ProcessEnv;
387
+ /** Record that the engine spawned a child — a shell child (a command, which may be adopted as a background shell; a background shell)
388
+ * or a language server — with an environment composed under `policy`: the question {@link PeerHeldEnvReceipt.heldLate} asks ("may a
389
+ * child already started hold this name"). Only ever set: a child that has closed may have left a service holding the same environment
390
+ * behind (a background shell that starts a daemon and exits), so no end is read. A child under `"all"` or a list records nothing (its
391
+ * policy handed it every variable a later declaration holds). Called by the site that spawned it, right after the spawn call — the
392
+ * environment is the child's from that call on, whether or not the spawn later fails. Not part of the package entry. */
393
+ export declare function noteChildSpawned(policy: InheritEnvPolicy | undefined): void;
376
394
  /** What a child spawned on this host starts with ({@link hostChildEnv}), and the inherited entries it does not receive:
377
395
  * the inheritance's findings less every name the composed environment sets (a grant's entry is the host's, never a loss). */
378
396
  export interface HostChildEnv {
@@ -385,13 +403,18 @@ export interface HostChildInheritance {
385
403
  /** How much of the base a child inherits — the {@link InheritEnvPolicy} (absent: `"scrub"`). */
386
404
  readonly policy?: InheritEnvPolicy | undefined;
387
405
  /** The settings file's `env` block: laid over this process's environment BEFORE the policy reads it, so it is part of
388
- * the base — read by the same arm and the same own-credentials subtraction as every other inherited entry (by name and
406
+ * the base — read by the same arm and the same own-credentials judgment as every other inherited entry (by name and
389
407
  * by value), its withheld entries accounted with `layer: "settingsEnv"`. A name it sets wins over this process's
390
408
  * variable of that name (compared as the platform compares names, the value under the spelling the process has);
391
409
  * an `undefined` value unsets it. A grant laid after the inherited part wins over it. Absent: the base is this
392
410
  * process's environment, exactly. Read once, as a grant is read; a bad one is refused as a bad grant is. */
393
411
  readonly settingsEnv?: Readonly<NodeJS.ProcessEnv> | undefined;
394
412
  }
413
+ type EnvEntries = readonly (readonly [string, string | undefined])[];
414
+ /** Why one environment layer — a grant (`label` = `env grant <n>`) or the settings layer (`settingsEnv`) — is not an
415
+ * object of variable names to strings, or its entries: read once, as a spread reads it (own enumerable entries). A bad
416
+ * name is not repeated and no value is: either may hold a credential. */
417
+ export declare function readEnvLayer(layer: unknown, label: string): EnvEntries | string;
395
418
  /** Why {@link hostChildEnv} would refuse these inputs, or `undefined` — the same judgment. It takes the table (or a bare policy), so
396
419
  * `{}` reads as `scrub`; to judge one policy value alone — a configuration field — use {@link inheritEnvPolicyProblem}. It answers a
397
420
  * sentence for every input the judgment can read; a caller's own getter or list element that reads once and throws on a later read
@@ -429,8 +452,8 @@ export declare function declaredInheritEntry(value: unknown): {
429
452
  /** Test seam: never called by production code. */
430
453
  export declare function __resetSecretEnvScrubNoticeAnnouncement(): void;
431
454
  /** What both disclosures say about one set of findings: every withheld name, and those that are the engine's own
432
- * credentials — withheld under every policy — whichever rule withheld them first ({@link ownCredentialJudge}, the
433
- * subtraction's own judgment, over the entry's value in this process's environment: every finding names an entry of
455
+ * credentials — withheld under every policy — whatever kind a finding says ({@link ownCredentialJudge}, the
456
+ * composition's own judgment, over the entry's value in this process's environment: every finding names an entry of
434
457
  * it). The rest the policy withheld: an allow list naming them hands them on, and so does `"all"` — except the names of the
435
458
  * engine's own namespace ({@link isNamespaceCredentialName}), which `"all"` withholds too. */
436
459
  export declare function withheldEnvNames(findings: readonly SecretEnvFinding[]): {
@@ -473,12 +496,13 @@ export interface WithheldEnvRemedy {
473
496
  * and the one thing to do if a command needs a withheld variable (the engine's own credentials: nothing hands them on; a name
474
497
  * the namespace rule caught: a list naming it, or the host's explicit grant, does, and the sentence says `"all"` does not; a name a
475
498
  * protocol peer's credential reference named: the entry that names it is the reason, named when the leg whose shell this is took in that
476
- * variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope` —
477
- * {@link peerHeldHalf}).
499
+ * variable and entry at its receipt — `mine` — or the host declared that entry to an audience the leg is in — its `isolationScope`, read
500
+ * against `deliveredScope`, the scope of the root a delegated leg's notice is delivered to ({@link noticeReaderScope}) — {@link peerHeldHalf}).
478
501
  */
479
502
  export declare function withheldEnvUserNotice(withheld: readonly SecretEnvFinding[] | "unknown", at: {
480
503
  sessionId: string;
481
504
  runId?: string | undefined;
482
505
  sourceSessionId?: string | undefined;
483
506
  agentId?: string | undefined;
484
- }, mine?: PeerEntriesTaken, isolationScope?: string): EngineNotice | undefined;
507
+ }, mine?: PeerEntriesTaken, isolationScope?: string, deliveredScope?: string): EngineNotice | undefined;
508
+ export {};
@@ -9,6 +9,7 @@ import { describeRejectedValue } from "./tool-search-setting.js";
9
9
  import { authSchemeCredentials } from "./protocol-http-auth.js";
10
10
  import { declarationSubject, isToolAxesSurface, toolAxesSurfaceList } from "./declaration-words.js";
11
11
  import { principalNameOf } from "./principal-name.js";
12
+ import { ANONYMOUS_SCOPE } from "./isolation-scope.js";
12
13
  const GIT_CONFIG_ENV_RE = /^GIT_CONFIG_(?:COUNT|PARAMETERS|(?:KEY|VALUE)_[0-9]+)$/;
13
14
  const PROXY_ENV_RE = /^(?:(?:https?|ftp|all|no)_proxy|npm_config_(?:https?_)?proxy|npm_config_noproxy|yarn_proxy|(?:yarn|global_agent|docker|claude_code)_(?:https?|no)_proxy|cloudsdk_proxy_[a-z]+|electron_get_use_proxy)$/i;
14
15
  function isExemptEnvName(name) {
@@ -122,17 +123,27 @@ function classifySecretEnvEntry(name, value) {
122
123
  return named;
123
124
  return value !== undefined && looksLikeCredentialValue(typeof value === "string" ? value : String(value)) ? "value-rule" : undefined;
124
125
  }
126
+ export function entryLooksLikeCredential(name, value) {
127
+ return classifySecretEnvEntry(name, value) !== undefined;
128
+ }
129
+ function judgeInheritedEntries(policy, entries) {
130
+ const shaped = entries.map(([name, value]) => (policy === "all" ? (isNamespaceCredentialName(name) ? "namespace-rule" : undefined) : Array.isArray(policy) ? undefined : classifySecretEnvEntry(name, value)));
131
+ const isOwn = ownCredentialJudge();
132
+ const peerHeld = policy === "all" || Array.isArray(policy) ? undefined : peerHeldOf();
133
+ return entries.map(([name, value], i) => shaped[i] ?? (isOwn !== undefined && isOwn(name, value) ? "own-credential" : peerHeld?.has(envNameKey(name)) === true ? "peer-held" : undefined));
134
+ }
125
135
  export function isSecretEnvKey(key, value) {
126
- return classifySecretEnvEntry(key, value) !== undefined;
136
+ return judgeInheritedEntries("scrub", [[key, value]])[0] !== undefined;
127
137
  }
128
138
  export function scrubSecretEnv(env, findings) {
129
- return withholdEntries(env, classifySecretEnvEntry, findings);
139
+ return withholdEntries(env, "scrub", findings);
130
140
  }
131
- function withholdEntries(env, judge, findings) {
141
+ function withholdEntries(env, policy, findings) {
142
+ const entries = Object.keys(env).map((key) => [key, env[key]]);
143
+ const kinds = judgeInheritedEntries(policy, entries);
132
144
  const kept = [];
133
- for (const key of Object.keys(env)) {
134
- const value = env[key];
135
- const kind = judge(key, value);
145
+ for (const [i, [key, value]] of entries.entries()) {
146
+ const kind = kinds[i];
136
147
  if (kind === undefined)
137
148
  kept.push([key, value]);
138
149
  else
@@ -141,7 +152,10 @@ function withholdEntries(env, judge, findings) {
141
152
  return Object.fromEntries(kept);
142
153
  }
143
154
  function envNameKey(name) {
144
- return process.platform === "win32" ? name.toUpperCase() : name;
155
+ return envNameKeyOn(name, process.platform);
156
+ }
157
+ export function envNameKeyOn(name, platform) {
158
+ return platform === "win32" ? name.toUpperCase() : name;
145
159
  }
146
160
  const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
147
161
  function isDeclarableVariableName(k) {
@@ -196,7 +210,7 @@ const peerHeldAudiencesOf = () => {
196
210
  const slot = Reflect.get(globalThis, PEER_HELD_AUDIENCES);
197
211
  if (typeof slot === "object" && slot !== null && slot.named instanceof Map)
198
212
  return slot;
199
- const fresh = { named: new Map(), scrubComposed: false };
213
+ const fresh = { named: new Map() };
200
214
  Reflect.set(globalThis, PEER_HELD_AUDIENCES, fresh);
201
215
  return fresh;
202
216
  };
@@ -219,7 +233,7 @@ const CANNOT_BE_WITHHELD = "which a child is handed from this process's environm
219
233
  function runtimeSuppliedHolderOf(value, supplied = suppliedInProcess()) {
220
234
  return Object.keys(supplied).find((k) => supplied[k] === value);
221
235
  }
222
- const suppliedIn = (env) => policyArm([...runtimeSuppliedEnv()], env);
236
+ const suppliedIn = (env) => namedIn(runtimeSuppliedEnv(), env);
223
237
  const suppliedInProcess = () => suppliedIn(process.env);
224
238
  const PLACEHOLDER_KEY_WORDS = new Set([...ENV_VALUES.flagWords, ...ENV_VALUES.placeholderWords]);
225
239
  export function isOneCharacterRepeated(text) {
@@ -449,7 +463,7 @@ export function declarePeerHeldEnv(declaration) {
449
463
  continue;
450
464
  }
451
465
  const { key, isNew } = admitted;
452
- if (isNew && audiences.scrubComposed && Object.hasOwn(process.env, spellingIn(process.env, name)) && !heldLate.includes(name))
466
+ if (isNew && audiences.childSpawned === true && Object.hasOwn(process.env, spellingIn(process.env, name)) && !heldLate.includes(name))
453
467
  heldLate.push(name);
454
468
  if (read.audience !== undefined) {
455
469
  let entries = audiences.named.get(key);
@@ -551,7 +565,7 @@ function sayNotTaken(value, why, onNotice) {
551
565
  export function __resetWithheldEnv() {
552
566
  Reflect.set(globalThis, WITHHELD_ENV, { names: NOTHING_NAMED, declared: new Map(), held: new Map() });
553
567
  Reflect.set(globalThis, PEER_HELD_ENV, new Map());
554
- Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map(), scrubComposed: false });
568
+ Reflect.set(globalThis, PEER_HELD_AUDIENCES, { named: new Map() });
555
569
  intakeSaid.clear();
556
570
  }
557
571
  function ownCredentialJudge() {
@@ -561,20 +575,6 @@ function ownCredentialJudge() {
561
575
  const own = new Set(table.names.map(envNameKey));
562
576
  return (key, value) => own.has(envNameKey(key)) || (typeof value === "string" && (indexHas(table.declared, value) || indexHas(table.held, value)));
563
577
  }
564
- function withholdOwnCredentials(inherited, findings) {
565
- const isOwn = ownCredentialJudge();
566
- if (isOwn === undefined)
567
- return inherited;
568
- const kept = [];
569
- for (const key of Object.keys(inherited)) {
570
- const value = inherited[key];
571
- if (!isOwn(key, value))
572
- kept.push([key, value]);
573
- else
574
- findings?.push({ key, kind: "own-credential", confidence: SECRET_ENV_KIND_CONFIDENCE["own-credential"], source: "secret-env" });
575
- }
576
- return Object.fromEntries(kept);
577
- }
578
578
  function policyShapeProblem(value) {
579
579
  if (value === undefined || value === "all" || value === "scrub")
580
580
  return undefined;
@@ -601,21 +601,18 @@ function inheritedOver(policy, settings, findings) {
601
601
  base = Object.fromEntries([...layered.values()].filter((entry) => entry[1] !== undefined));
602
602
  }
603
603
  const found = [];
604
- const inherited = withholdOwnCredentials(policyArm(policy, base, found), found);
604
+ const inherited = policyArm(policy, base, found);
605
605
  for (const f of found)
606
606
  findings?.push(settingsNames.has(envNameKey(f.key)) ? { ...f, layer: "settingsEnv" } : f);
607
607
  return inherited;
608
608
  }
609
609
  export function inheritedHostEnv(policy, findings) {
610
- const underScrub = isScrubPolicy(policy);
611
- const inherited = inheritedOver(policy, undefined, findings);
612
- if (underScrub)
613
- noteScrubComposed();
614
- return inherited;
610
+ return inheritedOver(policy, undefined, findings);
615
611
  }
616
- const isScrubPolicy = (policy) => policy !== "all" && !Array.isArray(policy);
617
- function noteScrubComposed() {
618
- peerHeldAudiencesOf().scrubComposed = true;
612
+ export function noteChildSpawned(policy) {
613
+ if (policy === "all" || Array.isArray(policy))
614
+ return;
615
+ peerHeldAudiencesOf().childSpawned = true;
619
616
  }
620
617
  const HOST_CHILD_INHERITANCE_KEYS = optionKeys()({ policy: 0, settingsEnv: 0 });
621
618
  function layInto(entries, layer) {
@@ -623,7 +620,7 @@ function layInto(entries, layer) {
623
620
  entries.set(envNameKey(name), [entries.get(envNameKey(name))?.[0] ?? name, value]);
624
621
  }
625
622
  const unkeptCharacter = (text) => (text.includes("\0") ? "a NUL" : UNPAIRED_SURROGATE_RE.test(text) ? "an unpaired surrogate" : undefined);
626
- function readEnvLayer(layer, label) {
623
+ export function readEnvLayer(layer, label) {
627
624
  try {
628
625
  if (typeof layer !== "object" || layer === null || Array.isArray(layer))
629
626
  return `${label} must be an object of variable names to strings (got ${kindOf(layer)})`;
@@ -664,7 +661,7 @@ function readInheritance(inherit) {
664
661
  }
665
662
  return { policy: table.policy, settings: table.settingsEnv === undefined ? undefined : readEnvLayer(table.settingsEnv, "settingsEnv") };
666
663
  }
667
- function composeHostChildEnv(inherit, grants, forChild = false) {
664
+ function composeHostChildEnv(inherit, grants) {
668
665
  const read = readInheritance(inherit);
669
666
  if (typeof read === "string")
670
667
  return read;
@@ -681,7 +678,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
681
678
  return read.settings;
682
679
  const findings = [];
683
680
  const entries = new Map();
684
- const underScrub = forChild && isScrubPolicy(read.policy);
685
681
  for (const entry of Object.entries(inheritedOver(read.policy, read.settings, findings)))
686
682
  entries.set(envNameKey(entry[0]), entry);
687
683
  for (let i = 0; i < grants.length; i++) {
@@ -693,8 +689,6 @@ function composeHostChildEnv(inherit, grants, forChild = false) {
693
689
  layInto(entries, layer);
694
690
  }
695
691
  const env = Object.fromEntries(entries.values());
696
- if (underScrub)
697
- noteScrubComposed();
698
692
  return { env, withheld: findings.filter((f) => entries.get(envNameKey(f.key))?.[1] === undefined) };
699
693
  }
700
694
  export function hostChildEnvProblem(inherit, ...grants) {
@@ -702,21 +696,21 @@ export function hostChildEnvProblem(inherit, ...grants) {
702
696
  return typeof composed === "string" ? composed : undefined;
703
697
  }
704
698
  export function hostChildEnv(inherit, ...grants) {
705
- const composed = composeHostChildEnv(inherit, grants, true);
699
+ const composed = composeHostChildEnv(inherit, grants);
706
700
  if (typeof composed === "string")
707
701
  throw new Error(composed);
708
702
  return composed;
709
703
  }
710
704
  function policyArm(policy, base, findings) {
711
705
  if (policy === "all")
712
- return withholdEntries(base, (name) => (isNamespaceCredentialName(name) ? "namespace-rule" : undefined), findings);
713
- if (!Array.isArray(policy)) {
714
- const scrubbed = scrubSecretEnv(base, findings);
715
- const peerHeld = peerHeldOf();
716
- return peerHeld.size === 0 ? scrubbed : withholdEntries(scrubbed, (name) => (peerHeld.has(envNameKey(name)) ? "peer-held" : undefined), findings);
717
- }
706
+ return withholdEntries(base, policy, findings);
707
+ if (!Array.isArray(policy))
708
+ return scrubSecretEnv(base, findings);
709
+ return withholdEntries(namedIn(policy, base), policy, findings);
710
+ }
711
+ function namedIn(names, base) {
718
712
  const arm = [];
719
- for (const k of policy) {
713
+ for (const k of names) {
720
714
  const name = spellingIn(base, k);
721
715
  const value = Object.hasOwn(base, name) ? base[name] : undefined;
722
716
  if (value !== undefined)
@@ -785,9 +779,15 @@ function peerHeldHalf(peers, mine, isolationScope) {
785
779
  `through the shell's own environment or the environment of a single execution; letting the run inherit all of them hands it on as well, but once the engine has started connecting to that peer ` +
786
780
  `neither that nor a list is sure to, since a credential value the engine took in for it is held back whatever the run inherits)`);
787
781
  }
788
- export function withheldEnvUserNotice(withheld, at, mine, isolationScope) {
782
+ function noticeReaderScope(delegated, isolationScope, deliveredScope) {
783
+ if (!delegated)
784
+ return isolationScope;
785
+ return deliveredScope !== ANONYMOUS_SCOPE && isolationScope !== undefined && isolationScope === deliveredScope ? isolationScope : undefined;
786
+ }
787
+ export function withheldEnvUserNotice(withheld, at, mine, isolationScope, deliveredScope) {
789
788
  const route = { sessionId: at.sessionId, ...(at.sourceSessionId !== undefined ? { sourceSessionId: at.sourceSessionId } : {}), ...(at.agentId !== undefined ? { agentId: at.agentId } : {}), ...(at.runId !== undefined ? { runId: at.runId } : {}) };
790
789
  const delegated = at.sourceSessionId !== undefined;
790
+ const readerScope = noticeReaderScope(delegated, isolationScope, deliveredScope);
791
791
  const shell = delegated ? "the tool shell of a delegated agent in this session" : "the tool shell in this session";
792
792
  const subject = delegated ? "A delegated agent's tool shell in this session" : "The tool shell in this session";
793
793
  if (withheld === "unknown") {
@@ -809,7 +809,7 @@ export function withheldEnvUserNotice(withheld, at, mine, isolationScope) {
809
809
  const needs = (list) => (list.length === 1 ? "it" : "one of them");
810
810
  const halves = [
811
811
  ...(others.length > 0 ? [`${others.join(", ")} — held back because ${others.length === 1 ? "it looks like a credential" : "they look like credentials"} (if a command needs ${needs(others)}, name it among the variables the run inherits, or let the run inherit all of them)`] : []),
812
- ...(peers.length > 0 ? [peerHeldHalf(peers, mine, isolationScope)] : []),
812
+ ...(peers.length > 0 ? [peerHeldHalf(peers, mine, readerScope)] : []),
813
813
  ...(slots.length > 0 ? [`${slots.join(", ")} — held back because ${slots.length === 1 ? "it is named" : "they are named"} like the engine's own credential slots (if a command needs ${needs(slots)}, name it among the variables the run inherits, or have the host hand it to the shell explicitly, through the shell's own environment or the environment of a single execution — letting the run inherit everything does not hand ${slots.length === 1 ? "it" : "them"} on)`] : []),
814
814
  ...(ownCredentials.length > 0 ? [`${ownCredentials.join(", ")} — ${OWN_CREDENTIAL}(s), never handed on, whatever the run's environment inheritance says`] : []),
815
815
  ];
@@ -54,6 +54,9 @@ export interface WorktreeCapability {
54
54
  readonly detail?: string;
55
55
  }
56
56
  export type { ReleasedTree } from "./git-worktree-env.js";
57
+ /** The one reader of a session's checkout record, the one this module's doors read (#4898: a host reads it too). */
58
+ export { readSessionCheckout, type SessionCheckoutRead } from "../engine/session/session.js";
59
+ export type { SessionCheckoutRecord } from "../internal/harness-types.js";
57
60
  /**
58
61
  * THE shape judge of `TaskSpec.workspace` — `undefined` for an absent declaration, else the normalized declaration the record
59
62
  * stores and every later leg is compared on. Read once as data ({@link DECLARATION_DATA}), then judged on that copy. Refused
@@ -21,6 +21,7 @@ export const WORKTREE_INCAPABLE_REASONS = Object.freeze([
21
21
  "parent_not_writable",
22
22
  "name_in_use",
23
23
  ]);
24
+ export { readSessionCheckout } from "../engine/session/session.js";
24
25
  const refusal = (code, message) => Object.assign(new Error(message), { code });
25
26
  const invalid = (problem) => refusal("config.session_workspace_invalid", `TaskSpec.workspace ${problem}`);
26
27
  const FULL_SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
@@ -1,4 +1,4 @@
1
- import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo, type SessionRowExpectation } from "../internal/harness.js";
1
+ import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo, type SessionRowExpectation, type SessionRowRead } from "../internal/harness.js";
2
2
  import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionLogTransfer, type SessionPlacement, type SessionStore, type SessionStoreHooks, type SessionStoreSummary } from "./session.js";
3
3
  import type { StoreDurability } from "./checkpoint-store.js";
4
4
  import { type StoreHolderFence } from "./checkpoint-generation.js";
@@ -157,6 +157,9 @@ export declare class TtlSessionStore implements SessionStore {
157
157
  /** The repo's head read as this store's own decisions read the row through it (the cache check, the existence check), held
158
158
  * privately so the store's reading of its rows is the repo's whatever a host does with the face. */
159
159
  private readonly repoHead?;
160
+ /** The row read ({@link SessionStore.readRow}): the repo's own, verbatim — no sweep, no activity, nothing cached. Present only when the
161
+ * repo has a head read and a row read. */
162
+ readonly readRow?: (sessionId: string) => Promise<SessionRowRead | undefined>;
160
163
  /** The storage half of a cross-backend move ({@link SessionStore.logTransfer}), over the repo's row read and its conditional import:
161
164
  * present only when the repo has both and a head read. A staging lives in this process; a commit holds the id as a release does, and
162
165
  * the import it ends with is conditional on the row the commit read. */
@@ -166,7 +169,9 @@ export declare class TtlSessionStore implements SessionStore {
166
169
  * deletion is judged on the head, never on the log). A repo with the first two and not the third is said once
167
170
  * (`config.session_delete_withheld`). */
168
171
  readonly delete?: (sessionId: string, guard: {
169
- owner: string | null;
172
+ readonly owner: string | null;
173
+ } | {
174
+ readonly row: NonNullable<SessionRowExpectation["row"]>;
170
175
  }) => Promise<boolean>;
171
176
  /** The operator's removal of a row whose head cannot be read ({@link SessionStore.deleteUnreadable}): present only when the repo has a
172
177
  * head read and its own unreadable-row removal ({@link SessionRepo.deleteUnreadable}), which re-reads the head in the step that removes. */
@@ -330,10 +335,11 @@ export declare class TtlSessionStore implements SessionStore {
330
335
  */
331
336
  private deleteUnreadableRow;
332
337
  /**
333
- * The owner-guarded delete ({@link SessionStore.delete}), holding the id as a release does: the row's head decides — no row, or an
334
- * owner other than `guard.owner` (null-safe), deletes nothing — and a placed row (read off the header alone) is left to `release`
335
- * (the joint reap). The log is never read, so a log whose open is refused `corrupt_session` is deleted like any other row. A deleted row
336
- * leaves no cached view and no pin: the id answers nothing afterwards, and a later create under it is a new occupant.
338
+ * The owner-guarded delete ({@link SessionStore.delete}), holding the id as a release does: the row's head decides — no row, an
339
+ * owner other than `guard.owner` (null-safe), or, for the occupant form, a head `sessionRowMatches` does not take for `guard.row`,
340
+ * deletes nothing — and a placed row (read off the header alone) is left to `release` (the joint reap). The log is never read, so a
341
+ * log whose open is refused `corrupt_session` is deleted like any other row. A deleted row leaves no cached view and no pin: the id
342
+ * answers nothing afterwards, and a later create under it is a new occupant.
337
343
  */
338
344
  private deleteOwned;
339
345
  /** The row's metadata as the repo holds it, its placement included; `undefined` = no row. A read fault rejects. */
@@ -1,4 +1,4 @@
1
- import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, recordedOwnerName, sessionLogMarkOf, uuidv7, } from "../internal/harness.js";
1
+ import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, recordedOwnerName, sessionLogMarkOf, sessionRowMatches, uuidv7, } from "../internal/harness.js";
2
2
  import { isSessionConflict, readSessionListQuery, readUnreadableDeleteId, rowUnreadableAt } from "./session.js";
3
3
  import { readHolderJudge } from "./checkpoint-generation.js";
4
4
  import { readRetentionDeclaration } from "./retention.js";
@@ -9,6 +9,7 @@ import { describeFault, receive } from "./mods/kernel/receive.js";
9
9
  import { describeRejectedValue } from "./tool-search-setting.js";
10
10
  import { readIntegerOption, TIMER_DELAY_MS } from "./integer-option.js";
11
11
  import { repoLogTransfer } from "./session-log-transfer.js";
12
+ import { readOccupantExpectation } from "./runner/session-verb-doors.js";
12
13
  import { deliverEngineNotice } from "./engine-notice.js";
13
14
  let ownerDeleteWithheldSaid = false;
14
15
  export function __resetSessionDeleteWithheldNotice() {
@@ -46,6 +47,7 @@ export class TtlSessionStore {
46
47
  listPlaced;
47
48
  headOf;
48
49
  repoHead;
50
+ readRow;
49
51
  logTransfer;
50
52
  delete;
51
53
  deleteUnreadable;
@@ -96,6 +98,8 @@ export class TtlSessionStore {
96
98
  this.repoHead = repoHead;
97
99
  this.headOf = repoHead;
98
100
  const { readRow, importEntries, deleteUnreadable, placementOf, recordOwner } = this.repo;
101
+ if (typeof readRow === "function")
102
+ this.readRow = (sessionId) => readRow.call(this.repo, sessionId);
99
103
  if (typeof recordOwner === "function") {
100
104
  this.recordOwner = async (sessionId, owner, expect) => {
101
105
  const name = recordedOwnerName(owner);
@@ -454,11 +458,11 @@ export class TtlSessionStore {
454
458
  });
455
459
  }
456
460
  async deleteOwned(sessionId, guard, readHead, readHeaderPlacement) {
457
- const want = readDeleteGuard(guard);
461
+ const wants = readDeleteGuard(guard);
458
462
  return this.holdingId(sessionId, async () => {
459
463
  this.entries.delete(sessionId);
460
464
  const head = await readHead(sessionId);
461
- if (head === undefined || head.owner !== want)
465
+ if (head === undefined || !wants(head))
462
466
  return false;
463
467
  if ((await readHeaderPlacement(sessionId)) !== undefined)
464
468
  return false;
@@ -640,14 +644,30 @@ function readStoreHooks(hooks) {
640
644
  }
641
645
  function readDeleteGuard(guard) {
642
646
  if (typeof guard !== "object" || guard === null)
643
- throw new TypeError(`SessionStore.delete: the guard must be an object { owner }, got ${guard === null ? "null" : typeof guard}`);
647
+ throw new TypeError(`SessionStore.delete: the guard must be an object { owner } or { row: { owner, incarnation } }, got ${guard === null ? "null" : typeof guard}`);
648
+ let hasRow;
649
+ try {
650
+ hasRow = "row" in guard;
651
+ }
652
+ catch {
653
+ hasRow = true;
654
+ }
655
+ if (hasRow) {
656
+ const occupant = readOccupantExpectation(guard, (what) => {
657
+ throw new TypeError(`SessionStore.delete: the guard's ${what}`);
658
+ });
659
+ return (head) => sessionRowMatches(occupant, head, occupantBindsNoLog);
660
+ }
644
661
  const owner = readMember(guard, "owner");
645
662
  if (owner === null)
646
- return null;
663
+ return (head) => head.owner === null;
647
664
  const name = recordedPrincipalNameOf(owner);
648
665
  if (name === undefined)
649
666
  throw new TypeError(`SessionStore.delete: guard.owner must be null (anonymous) or the owner name a session row holds — ${RECORDED_PRINCIPAL_NAME_SPELLING} — got ${principalNameFault(owner)}`);
650
- return name;
667
+ return (head) => head.owner === name;
668
+ }
669
+ function occupantBindsNoLog() {
670
+ throw new TypeError("SessionStore.delete: an occupant guard binds no log");
651
671
  }
652
672
  function isNotFound(err) {
653
673
  return readMember(err, "code") === "not_found";