@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
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The start of shell text a model wrote ({@link ExecutionEnv.modelShell}): whether an environment declares one, a leg's one reading of it,
3
+ * the question an environment asks a candidate shell and the reader of its answer, the table of the environment variables that
4
+ * change how the shell reads a command (so configuration never supplies them), and the two notices that say so.
5
+ */
6
+ import type { ExecutionEnv, ExecutionEnvModelShell } from "../internal/harness-types.js";
7
+ import { type EngineNotice } from "./engine-notice.js";
8
+ /** Whether `env` declares a start for model text: a `modelShell` member whose `exec` is a function. A member that cannot be read is none. */
9
+ export declare function hasModelShell(env: ExecutionEnv): env is ExecutionEnv & {
10
+ readonly modelShell: ExecutionEnvModelShell;
11
+ };
12
+ /** The start a tool hands model text to: the member as received ({@link receivedStart}) — or `undefined` when the environment declares
13
+ * none (as {@link hasModelShell} reads it). */
14
+ export declare function modelShellOf(env: ExecutionEnv): ExecutionEnvModelShell | undefined;
15
+ /** Whether the start has a background face: a `spawnBackground` function beside its `exec`. A member that throws when read is none. */
16
+ export declare function startsInBackground(start: ExecutionEnvModelShell | undefined): start is ExecutionEnvModelShell & Required<Pick<ExecutionEnvModelShell, "spawnBackground">>;
17
+ /** What a tool mounted on an environment without the member answers, before anything starts. */
18
+ export declare const MODEL_SHELL_UNDECLARED_REFUSAL = "this environment does not start commands on bash; no command can run here";
19
+ /** A leg's reading of {@link ExecutionEnv.modelShell}: not declared, declared and ready, or declared and unable to start (`cause` says why). */
20
+ export type ModelShellReading = {
21
+ readonly kind: "undeclared";
22
+ } | {
23
+ readonly kind: "mounted";
24
+ } | {
25
+ readonly kind: "unavailable";
26
+ readonly cause: string;
27
+ };
28
+ /** How long a leg's reading waits for `ExecutionEnv.modelShell.ready` to settle before it reads the start as unavailable. */
29
+ export declare const MODEL_SHELL_READY_TIMEOUT_MS = 5000;
30
+ /** The start's fact as a reader that asks nothing states it (`describeStaticWiring`): `false` undeclared or unusable by its shape,
31
+ * `true` declared with no `ready` (nothing to ask), `undefined` — not stated — when its `ready` is still to be asked: the leg's
32
+ * reading ({@link readModelShell}) decides, from the same declaration. */
33
+ export declare function modelShellFactBeforeAsking(env: ExecutionEnv): boolean | undefined;
34
+ /** The one reading of an environment's start for model text: its declaration ({@link declaredModelShell}), then its `ready`, called
35
+ * with the group as its receiver; an absent `ready` is `mounted`, one that reports a bash of 3.2 or later is `mounted`. A member that
36
+ * throws when read, a group with no `exec` function, a `ready` that is no function, reports zsh (not started in this version), a bash
37
+ * below 3.2 or a version that does not read, or no shell kind, answers a failure, rejects, throws, or does not settle within the bound
38
+ * (`timeoutMs`, capped at {@link MODEL_SHELL_READY_TIMEOUT_MS}) — each is `unavailable` with its cause; the reading itself never throws.
39
+ * The words of a thrown value or a failure reach the cause through the engine's credential pass (`egressThrownText`). A `ready` that
40
+ * blocks the thread synchronously is outside the bound: no timer can run until it returns. */
41
+ export declare function readModelShell(env: ExecutionEnv, timeoutMs?: number): Promise<ModelShellReading>;
42
+ /** The question a candidate is asked, as `[path, ...SHELL_KIND_QUESTION_OPTIONS, SHELL_KIND_QUESTION]`, which a bash and a zsh both read:
43
+ * a bash with brace expansion on and not in POSIX mode answers `bash M.N`; a zsh in its own default state (its options, no function,
44
+ * no global or suffix alias, only its own two aliases) answers `zsh M.N[.P]`; any other shell, or either in another state, answers
45
+ * nothing that reads as an answer. */
46
+ export declare const SHELL_KIND_QUESTION = "if [ -n \"${ZSH_VERSION-}\" ]; then [ \"$(emulate)\" = zsh ] && [[ \"$(builtin set -o)\" == \"$(builtin emulate zsh; builtin set -o)\" ]] && (( ${#functions} + ${#galiases} + ${#saliases} == 0 )) && [[ \"${(ok)aliases}\" == \"run-help which-command\" ]] && builtin print -rn -- \"zsh $ZSH_VERSION\"; else builtin shopt -qo braceexpand && ! builtin shopt -qo posix && builtin printf \"bash %s.%s\" \"${BASH_VERSINFO[0]}\" \"${BASH_VERSINFO[1]}\"; fi";
47
+ /** The options the question is asked with: no filename expansion, privileged mode (no startup file, no imported function), `-c`. */
48
+ export declare const SHELL_KIND_QUESTION_OPTIONS: readonly string[];
49
+ /** What a candidate's answer says: the shell it is and its version, or why it is neither (a reason that follows the candidate's path).
50
+ * A bash below 3.2 is a reason, not an answer. */
51
+ export type ShellKindAnswer = {
52
+ readonly ok: true;
53
+ readonly shell: "bash" | "zsh";
54
+ readonly version: string;
55
+ } | {
56
+ readonly ok: false;
57
+ readonly reason: string;
58
+ };
59
+ /** Reads a candidate's stdout: exactly `bash M.N` (compared as integers against 3.2) or `zsh M.N[.P]`; anything else gave no answer. */
60
+ export declare function readShellKindAnswer(stdout: string): ShellKindAnswer;
61
+ /** Why a candidate whose answer reads is not started in this version — a zsh — or `undefined` for a bash. */
62
+ export declare function notStartedInThisVersion(answer: Extract<ShellKindAnswer, {
63
+ ok: true;
64
+ }>): string | undefined;
65
+ /** What a start does with a value of a row that the host process's own environment holds (the configuration's — `shellEnv`, a
66
+ * call's `env` — is never passed): `"dropped"` never passed, `"passes"` passed as it is, `"absolute-path"` passed only when the value
67
+ * is an absolute path (a relative one would name a file in the directory each command starts in). */
68
+ export type ShellStateInherited = "dropped" | "passes" | "absolute-path";
69
+ /** One row of {@link SHELL_STATE_ENV}: a variable name (`match: "name"`), a name prefix (`"name-prefix"`), or a value prefix
70
+ * (`"value-prefix"`: a variable of any name whose value starts with `text`). Names compare as the platform compares them. */
71
+ export interface ShellStateEnvRow {
72
+ readonly match: "name" | "name-prefix" | "value-prefix";
73
+ readonly text: string;
74
+ readonly inherited: ShellStateInherited;
75
+ }
76
+ /** The environment variables that change how the shell reads a command or run code before it: the one table every start (and a host
77
+ * that composes the environment of one) reads, through {@link shellStateEnvRowOf}. A value starting `() {` is a function body bash 3.2
78
+ * imports under any name; `POSIXLY_CORRECT` and `POSIX_PEDANTIC` put bash in POSIX mode (measured on bash 3.2 and 5.3), which the
79
+ * question excludes. */
80
+ export declare const SHELL_STATE_ENV: readonly ShellStateEnvRow[];
81
+ /** The row of {@link SHELL_STATE_ENV} that holds the variable `name` (with `value`), names compared as `platform` compares them, or
82
+ * `undefined`. A name row is read before the value row. */
83
+ export declare function shellStateEnvRowOf(name: string, value?: string, platform?: NodeJS.Platform): ShellStateEnvRow | undefined;
84
+ /** A variable a bash start does not pass: its name, where it came from, and the row that holds it. */
85
+ export interface DroppedShellState {
86
+ readonly key: string;
87
+ readonly from: "configured" | "inherited";
88
+ readonly row: ShellStateEnvRow;
89
+ }
90
+ /** One configured layer (`shellEnv`, a call's `env`) as a bash start receives it: read once, as the composition reads a grant
91
+ * (`label` is its name there, and its refusal is thrown in the composition's words), into a copy without any entry a row holds. */
92
+ export declare function configuredShellLayer(layer: unknown, label: string, platform?: NodeJS.Platform): {
93
+ readonly kept: Record<string, string | undefined> | undefined;
94
+ readonly dropped: readonly DroppedShellState[];
95
+ };
96
+ /** Of the configured layers' lost entries (`layers` in the order they are laid: `shellEnv`, then a call's `env`), the ones that decide
97
+ * their name: the last layer that gives a name decides it — its value lost keeps the name out of the child (the host process's own
98
+ * value too); its value kept stands, whatever an earlier layer gave. Names compared as `platform` compares them. */
99
+ export declare function configuredNamesKeptOut(layers: readonly ReturnType<typeof configuredShellLayer>[], platform?: NodeJS.Platform): DroppedShellState[];
100
+ /** The composed child environment of a bash start (whose configured layers were already {@link configuredShellLayer}'s, so every row
101
+ * left in it is the host process's own) by each row's `inherited` rule. A name a configured layer gave and lost (`configuredDropped`)
102
+ * is not in the child at all: configuration that sets or clears a variable of the table never uncovers the host process's own value
103
+ * (that value is not told again — the configured entry already is). */
104
+ export declare function inheritedShellState(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, configuredDropped?: readonly DroppedShellState[]): {
105
+ readonly kept: NodeJS.ProcessEnv;
106
+ readonly dropped: readonly DroppedShellState[];
107
+ };
108
+ /** An environment without any variable a row holds, whatever its source. */
109
+ export declare function withoutAnyShellState(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
110
+ /** The names the question is asked with — all it needs to start a program and answer "what are you": `PATH` (a wrapper that execs a
111
+ * shell by name finds it), `HOME`, `LANG` and every `LC_*`. Nothing else: not `shellEnv`, not any other inherited name (a credential,
112
+ * `BASH_VERSION` / `ZSH_VERSION`, which tell the two shells apart). On win32 the runtime adds its own required variables to every
113
+ * child (libuv: `SYSTEMROOT`, `WINDIR`, `TEMP`, …) whatever is passed. A host that asks {@link SHELL_KIND_QUESTION} itself gives the
114
+ * candidate the same environment ({@link shellKindQuestionEnv}). */
115
+ export declare const SHELL_KIND_QUESTION_ENV_NAMES: readonly string[];
116
+ /** The environment a candidate is asked {@link SHELL_KIND_QUESTION} in, out of `env` (the host process's own, as the scrub hands it
117
+ * on, read when the question is asked): only {@link SHELL_KIND_QUESTION_ENV_NAMES}, without any variable a row holds. Names
118
+ * compared as `platform` compares them. */
119
+ export declare function shellKindQuestionEnv(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
120
+ /** A leg's one telling of its reading (as it is prepared): when its hands are on, its environment performs I/O, and the start is not
121
+ * `mounted` — the shell tools it would have offered are not. */
122
+ export declare function announceModelShellUnmounted(reading: ModelShellReading, facts: Readonly<Partial<Record<"env.hands" | "env.performsIo", boolean>>>, onNotice: ((notice: EngineNotice) => void) | undefined): void;
123
+ /** The leg's notice that the shell tools are not offered: its environment declares no start for model text, or its start is unavailable. */
124
+ export declare function modelShellUnmountedNotice(reading: Exclude<ModelShellReading, {
125
+ readonly kind: "mounted";
126
+ }>): EngineNotice;
127
+ /** The environment's notice that variables of {@link SHELL_STATE_ENV} were not passed to the model's shell — names, never values; the
128
+ * way out is said by where each came from and what its row allows. */
129
+ export declare function shellStateEnvDroppedNotice(dropped: readonly DroppedShellState[]): EngineNotice;
@@ -0,0 +1,249 @@
1
+ import { deliverEngineNotice } from "./engine-notice.js";
2
+ import { envNameKeyOn, readEnvLayer } from "./secret-env.js";
3
+ import { egressThrownText } from "./untrusted-egress.js";
4
+ import { isAbsoluteForFamily } from "./unc-spelling.js";
5
+ export function hasModelShell(env) {
6
+ return modelShellOf(env) !== undefined;
7
+ }
8
+ const receivedStarts = new WeakMap();
9
+ function receivedStart(env) {
10
+ const kept = receivedStarts.get(env);
11
+ if (kept !== undefined)
12
+ return kept;
13
+ const start = env.modelShell;
14
+ if (typeof start === "object" && start !== null)
15
+ receivedStarts.set(env, start);
16
+ return start;
17
+ }
18
+ export function modelShellOf(env) {
19
+ try {
20
+ const start = receivedStart(env);
21
+ return typeof start === "object" && start !== null && typeof start.exec === "function" ? start : undefined;
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
27
+ export function startsInBackground(start) {
28
+ try {
29
+ return typeof start?.spawnBackground === "function";
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
35
+ export const MODEL_SHELL_UNDECLARED_REFUSAL = "this environment does not start commands on bash; no command can run here";
36
+ const UNDECLARED = Object.freeze({ kind: "undeclared" });
37
+ const MOUNTED = Object.freeze({ kind: "mounted" });
38
+ const unavailable = (cause) => Object.freeze({ kind: "unavailable", cause });
39
+ export const MODEL_SHELL_READY_TIMEOUT_MS = 5_000;
40
+ function declaredModelShell(env) {
41
+ let start;
42
+ try {
43
+ start = receivedStart(env);
44
+ }
45
+ catch (error) {
46
+ return unavailable(`reading ExecutionEnv.modelShell threw: ${egressThrownText("same-principal", error)}`);
47
+ }
48
+ if (start === undefined)
49
+ return UNDECLARED;
50
+ if (typeof start !== "object" || start === null)
51
+ return unavailable("ExecutionEnv.modelShell is not a method group with an exec function");
52
+ let exec;
53
+ let ready;
54
+ try {
55
+ exec = start.exec;
56
+ }
57
+ catch (error) {
58
+ return unavailable(`reading ExecutionEnv.modelShell.exec threw: ${egressThrownText("same-principal", error)}`);
59
+ }
60
+ if (typeof exec !== "function")
61
+ return unavailable("ExecutionEnv.modelShell is not a method group with an exec function");
62
+ try {
63
+ void start.spawnBackground;
64
+ }
65
+ catch (error) {
66
+ return unavailable(`reading ExecutionEnv.modelShell.spawnBackground threw: ${egressThrownText("same-principal", error)}`);
67
+ }
68
+ try {
69
+ ready = start.ready;
70
+ }
71
+ catch (error) {
72
+ return unavailable(`reading ExecutionEnv.modelShell.ready threw: ${egressThrownText("same-principal", error)}`);
73
+ }
74
+ if (ready === undefined)
75
+ return MOUNTED;
76
+ if (typeof ready !== "function")
77
+ return unavailable("ExecutionEnv.modelShell.ready is not a function");
78
+ return { kind: "asks", start, ready: ready };
79
+ }
80
+ export function modelShellFactBeforeAsking(env) {
81
+ const declared = declaredModelShell(env);
82
+ return declared.kind === "asks" ? undefined : declared.kind === "mounted";
83
+ }
84
+ export async function readModelShell(env, timeoutMs = MODEL_SHELL_READY_TIMEOUT_MS) {
85
+ const declared = declaredModelShell(env);
86
+ if (declared.kind !== "asks")
87
+ return declared;
88
+ const { start, ready } = declared;
89
+ const bound = Number.isFinite(timeoutMs) && timeoutMs > 0 ? Math.min(timeoutMs, MODEL_SHELL_READY_TIMEOUT_MS) : MODEL_SHELL_READY_TIMEOUT_MS;
90
+ let timer;
91
+ const late = new Promise((settle) => {
92
+ timer = setTimeout(() => settle(unavailable(`ExecutionEnv.modelShell.ready did not settle within ${bound} ms (timed out)`)), bound);
93
+ });
94
+ const asked = (async () => {
95
+ try {
96
+ const answer = await Reflect.apply(ready, start, []);
97
+ if (typeof answer === "object" && answer !== null && answer.ok === true)
98
+ return kindReading(answer.value);
99
+ const failure = typeof answer === "object" && answer !== null ? answer.error : undefined;
100
+ return unavailable(failure === undefined ? "ExecutionEnv.modelShell.ready answered no result" : egressThrownText("same-principal", failure));
101
+ }
102
+ catch (error) {
103
+ return unavailable(`ExecutionEnv.modelShell.ready threw: ${egressThrownText("same-principal", error)}`);
104
+ }
105
+ })();
106
+ try {
107
+ return await Promise.race([asked, late]);
108
+ }
109
+ finally {
110
+ clearTimeout(timer);
111
+ }
112
+ }
113
+ function kindReading(value) {
114
+ const shell = typeof value === "object" && value !== null ? value.shell : undefined;
115
+ const version = typeof value === "object" && value !== null ? value.version : undefined;
116
+ if (typeof version !== "string")
117
+ return unavailable("ready reported no shell kind");
118
+ if (shell === "bash") {
119
+ const read = bashVersionReading(version);
120
+ if (read === undefined)
121
+ return unavailable("ready reported a version that is not of the form M.N");
122
+ return read.below === undefined ? MOUNTED : unavailable(`the start ${read.below}`);
123
+ }
124
+ if (shell === "zsh")
125
+ return ZSH_VERSION_FORM.test(version) ? unavailable(zshNotStarted(version)) : unavailable("ready reported a version that is not of the form M.N[.P]");
126
+ return unavailable("ready reported no shell kind");
127
+ }
128
+ function bashVersionReading(text) {
129
+ const read = /^([0-9]+)\.([0-9]+)$/.exec(text);
130
+ if (read === null)
131
+ return undefined;
132
+ const m = Number(read[1]);
133
+ const n = Number(read[2]);
134
+ return { version: text, below: m > 3 || (m === 3 && n >= 2) ? undefined : `is bash ${text}, below 3.2` };
135
+ }
136
+ const ZSH_VERSION_FORM = /^[0-9]+\.[0-9]+(?:\.[0-9]+)?$/;
137
+ const zshNotStarted = (version) => `is zsh ${version}; this version starts commands only on bash`;
138
+ export const SHELL_KIND_QUESTION = 'if [ -n "${ZSH_VERSION-}" ]; then [ "$(emulate)" = zsh ] && [[ "$(builtin set -o)" == "$(builtin emulate zsh; builtin set -o)" ]] && (( ${#functions} + ${#galiases} + ${#saliases} == 0 )) && [[ "${(ok)aliases}" == "run-help which-command" ]] && builtin print -rn -- "zsh $ZSH_VERSION"; else builtin shopt -qo braceexpand && ! builtin shopt -qo posix && builtin printf "bash %s.%s" "${BASH_VERSINFO[0]}" "${BASH_VERSINFO[1]}"; fi';
139
+ export const SHELL_KIND_QUESTION_OPTIONS = Object.freeze(["-f", "-p", "-c"]);
140
+ export function readShellKindAnswer(stdout) {
141
+ const answered = /^bash (.*)$/s.exec(stdout);
142
+ const bash = answered === null ? undefined : bashVersionReading(answered[1]);
143
+ if (bash !== undefined)
144
+ return bash.below === undefined ? { ok: true, shell: "bash", version: bash.version } : { ok: false, reason: bash.below };
145
+ const zsh = stdout.startsWith("zsh ") ? stdout.slice("zsh ".length) : undefined;
146
+ if (zsh !== undefined && ZSH_VERSION_FORM.test(zsh))
147
+ return { ok: true, shell: "zsh", version: zsh };
148
+ return { ok: false, reason: "gave no answer to the shell-kind question" };
149
+ }
150
+ export function notStartedInThisVersion(answer) {
151
+ return answer.shell === "zsh" ? zshNotStarted(answer.version) : undefined;
152
+ }
153
+ const row = (match, text, inherited) => Object.freeze({ match, text, inherited });
154
+ export const SHELL_STATE_ENV = Object.freeze([
155
+ row("name", "SHELLOPTS", "dropped"),
156
+ row("name", "BASHOPTS", "dropped"),
157
+ row("name", "BASH_ENV", "absolute-path"),
158
+ row("name", "ENV", "absolute-path"),
159
+ row("name", "BASH_COMPAT", "passes"),
160
+ row("name", "POSIXLY_CORRECT", "dropped"),
161
+ row("name", "POSIX_PEDANTIC", "dropped"),
162
+ row("name", "PS4", "passes"),
163
+ row("name-prefix", "BASH_FUNC_", "passes"),
164
+ row("value-prefix", "() {", "passes"),
165
+ ]);
166
+ export function shellStateEnvRowOf(name, value, platform = process.platform) {
167
+ const key = envNameKeyOn(name, platform);
168
+ return SHELL_STATE_ENV.find((r) => r.match === "name" ? key === envNameKeyOn(r.text, platform) : r.match === "name-prefix" ? key.startsWith(envNameKeyOn(r.text, platform)) : typeof value === "string" && value.startsWith(r.text));
169
+ }
170
+ export function configuredShellLayer(layer, label, platform = process.platform) {
171
+ if (layer === undefined)
172
+ return { kept: undefined, dropped: [] };
173
+ const entries = readEnvLayer(layer, label);
174
+ if (typeof entries === "string")
175
+ throw new Error(entries);
176
+ const dropped = [];
177
+ const kept = [];
178
+ for (const [key, value] of entries) {
179
+ const held = shellStateEnvRowOf(key, value, platform);
180
+ if (held === undefined)
181
+ kept.push([key, value]);
182
+ else
183
+ dropped.push({ key, from: "configured", row: held });
184
+ }
185
+ return { kept: Object.fromEntries(kept), dropped };
186
+ }
187
+ export function configuredNamesKeptOut(layers, platform = process.platform) {
188
+ const gives = (layer, key) => Object.keys(layer.kept ?? {}).some((k) => envNameKeyOn(k, platform) === key) || layer.dropped.some((d) => envNameKeyOn(d.key, platform) === key);
189
+ return layers.flatMap((layer, i) => layer.dropped.filter((d) => !layers.slice(i + 1).some((later) => gives(later, envNameKeyOn(d.key, platform)))));
190
+ }
191
+ export function inheritedShellState(env, platform = process.platform, configuredDropped = []) {
192
+ const named = new Set(configuredDropped.map((d) => envNameKeyOn(d.key, platform)));
193
+ const dropped = [];
194
+ const kept = [];
195
+ for (const [key, value] of Object.entries(env)) {
196
+ if (named.has(envNameKeyOn(key, platform)))
197
+ continue;
198
+ const held = shellStateEnvRowOf(key, value, platform);
199
+ const passes = held === undefined || held.inherited === "passes" || (held.inherited === "absolute-path" && typeof value === "string" && isAbsoluteFor(value, platform));
200
+ if (passes)
201
+ kept.push([key, value]);
202
+ else
203
+ dropped.push({ key, from: "inherited", row: held });
204
+ }
205
+ return { kept: Object.fromEntries(kept), dropped };
206
+ }
207
+ function isAbsoluteFor(path, platform) {
208
+ return isAbsoluteForFamily("posix", path) || (platform === "win32" && isAbsoluteForFamily("win", path));
209
+ }
210
+ export function withoutAnyShellState(env, platform = process.platform) {
211
+ return Object.fromEntries(Object.entries(env).filter(([key, value]) => shellStateEnvRowOf(key, value, platform) === undefined));
212
+ }
213
+ export const SHELL_KIND_QUESTION_ENV_NAMES = Object.freeze(["PATH", "HOME", "LANG", "LC_*"]);
214
+ export function shellKindQuestionEnv(env, platform = process.platform) {
215
+ const wanted = (key) => SHELL_KIND_QUESTION_ENV_NAMES.some((n) => (n.endsWith("*") ? envNameKeyOn(key, platform).startsWith(envNameKeyOn(n.slice(0, -1), platform)) : envNameKeyOn(key, platform) === envNameKeyOn(n, platform)));
216
+ return Object.fromEntries(Object.entries(withoutAnyShellState(env, platform)).filter(([key]) => wanted(key)));
217
+ }
218
+ export function announceModelShellUnmounted(reading, facts, onNotice) {
219
+ if (reading.kind === "mounted" || facts["env.hands"] !== true || facts["env.performsIo"] !== true)
220
+ return;
221
+ deliverEngineNotice(onNotice, modelShellUnmountedNotice(reading));
222
+ }
223
+ export function modelShellUnmountedNotice(reading) {
224
+ const because = reading.kind === "undeclared" ? "it declares no ExecutionEnv.modelShell" : `its start is unavailable: ${reading.cause}`;
225
+ return {
226
+ code: "config.model_shell_unmounted",
227
+ message: `The execution environment does not start commands on bash (${because}), so Bash, Monitor and background commands are not offered on this leg. Declare \`ExecutionEnv.modelShell\` on the adapter, or give the host a bash (3.2 or later).`,
228
+ detail: reading.kind === "undeclared" ? { reason: "undeclared" } : { reason: "unavailable", cause: reading.cause },
229
+ };
230
+ }
231
+ export function shellStateEnvDroppedNotice(dropped) {
232
+ const keys = dropped.map((d) => d.key);
233
+ const list = (of) => of.map((d) => `\`${d.key}\``).join(", ");
234
+ const never = dropped.filter((d) => d.row.inherited === "dropped");
235
+ const bodies = dropped.filter((d) => d.from === "configured" && d.row.match === "value-prefix");
236
+ const relative = dropped.filter((d) => d.from === "inherited" && d.row.inherited === "absolute-path");
237
+ const movable = dropped.filter((d) => d.from === "configured" && d.row.inherited !== "dropped" && d.row.match !== "value-prefix");
238
+ const ways = [
239
+ ...(movable.length > 0 ? [`Set ${list(movable)} in the host process's own environment if the host needs them (\`BASH_ENV\` and \`ENV\` as absolute paths).`] : []),
240
+ ...(relative.length > 0 ? [`${list(relative)} in the host process's own environment ${relative.length === 1 ? "is" : "are"} not an absolute path; give the startup file as one.`] : []),
241
+ ...(never.length > 0 ? [`${list(never)} ${never.length === 1 ? "is" : "are"} not passed from any source; set the option inside the command.`] : []),
242
+ ...(bodies.length > 0 ? [`${list(bodies)} ${bodies.length === 1 ? "holds" : "hold"} a function body, which configuration never passes.`] : []),
243
+ ];
244
+ return {
245
+ code: "config.shell_state_env_dropped",
246
+ message: `The environment for the model's shell carries ${list(dropped)}, which change how the shell reads a command; they are not passed to it. ${ways.join(" ")}`,
247
+ detail: { keys },
248
+ };
249
+ }
@@ -0,0 +1,4 @@
1
+ export { sha256Hex } from "./hash-mirror.js";
2
+ /** A mod package's digest: the sha256 of the newline-joined sha256 of `plugin.json`, `hooks.json` and the hooks module, in
3
+ * that order (the value 7.58 – 7.73 computed with `node:crypto` for the same bytes). */
4
+ export declare function modPackageDigest(plugin: Uint8Array, hooks: Uint8Array, module: Uint8Array): string;
@@ -0,0 +1,5 @@
1
+ import { sha256Hex } from "./hash-mirror.js";
2
+ export { sha256Hex } from "./hash-mirror.js";
3
+ export function modPackageDigest(plugin, hooks, module) {
4
+ return sha256Hex([plugin, hooks, module].map(sha256Hex).join("\n"));
5
+ }
@@ -93,6 +93,9 @@ export interface ModDispatchOptions {
93
93
  readonly ranks?: ModAnswerRanks;
94
94
  /** Which mounted handlers take part (absent ⇒ every handler on the event). A handler it leaves out neither runs nor observes. */
95
95
  readonly participant?: (p: ModParticipant) => boolean;
96
+ /** The owning plugin of an event whose row is `ownerOnly` (required there; delivery is that plugin's handlers only); not read
97
+ * on any other event. */
98
+ readonly owner?: string;
96
99
  }
97
100
  /** One handler as admission hung it — what a registration's `register` mounted, never its code. */
98
101
  export interface ModMountedHandler {
@@ -1,7 +1,7 @@
1
1
  import { CATCH_BUDGET_MS, clockMsRefusal, createSelfBudget, POST_ABORT_GRACE_MS, RUNAWAY_AFTER_MS, unrefTimer, watchRunaway } from "./budget.js";
2
2
  import { expandOnSide, failureRefuses, isModEventName, MOD_SEATS, nextToRefusal, stationOn } from "./events.js";
3
3
  import { ENGINE_ORIGIN, modsInvalid, screenModSeats, } from "./registration.js";
4
- import { answerUpward, answerViolation, detachedCopy, engineObjectsOnce, handedOn, handOnViolation, matcherMatches, matcherViolation, methodAnswerViolation, NEXT_IN_FLIGHT, receiveAnswer, receiveEvent, receivePayload, sealedObjects, } from "./site-rules.js";
4
+ import { answerUpward, answerViolation, detachedCopy, engineObjectsOnce, handedOn, handOnViolation, matcherMatches, ownAnswerViolation, sameMembers, matcherViolation, methodAnswerViolation, NEXT_IN_FLIGHT, receiveAnswer, receiveEvent, receivePayload, sealedObjects, } from "./site-rules.js";
5
5
  function handlerFrame(below, plugin, handler, event) {
6
6
  return Object.freeze([...below, Object.freeze({ kind: "handler", plugin, handler, event })]);
7
7
  }
@@ -215,23 +215,27 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
215
215
  hasHandlers: (event, participant) => mounted.some((h) => h.events.has(event) && admits(participant, h)),
216
216
  dispatch: (event, e, options) => {
217
217
  const st = stationOn(event, side);
218
+ const owner = st?.ownerOnly === true ? options.owner : undefined;
219
+ if (st?.ownerOnly === true && (typeof owner !== "string" || owner === "")) {
220
+ return Promise.reject(new Error(`${event}: requires options.owner (a non-empty plugin name) — this event is dispatched only to its owning plugin`));
221
+ }
218
222
  const received = st === undefined ? { refusal: `${event} is not raised on the ${side} bus` } : receiveEvent(e);
219
223
  if (st === undefined || "refusal" in received) {
220
224
  const reason = `${event}: ${"refusal" in received ? received.refusal : "not raised"}`;
221
225
  report(new Error(`engine: ${reason} — the dispatch was not run`));
222
226
  return Promise.resolve(Object.freeze({ kind: "failed", registration: ENGINE_ORIGIN.plugin, cause: "violation", reason, skipped: Object.freeze([]) }));
223
227
  }
224
- return runDispatch(event, st, received.payload, options);
228
+ return runDispatch(event, st, received.payload, options, owner);
225
229
  },
226
230
  };
227
- function participants(event, e, frames, participant) {
231
+ function participants(event, e, frames, participant, owner) {
228
232
  const inFrames = (fs, h) => fs.some((f) => f.plugin === h.reg.name && (f.kind === "dollar" || f.handler === h.index));
229
233
  const caller = frames.slice(-1);
230
234
  const above = frames.slice(0, -1);
231
235
  const all = [];
232
236
  const guards = [];
233
237
  for (const h of mounted) {
234
- if (!h.events.has(event) || !admits(participant, h) || !matcherMatches(h.matcher, e))
238
+ if (!h.events.has(event) || (owner !== undefined && h.reg.name !== owner) || !admits(participant, h) || !matcherMatches(h.matcher, e))
235
239
  continue;
236
240
  if (inFrames(caller, h))
237
241
  continue;
@@ -382,7 +386,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
382
386
  p.then(settle, settle);
383
387
  return p;
384
388
  }
385
- function runDispatch(event, st, e0, options) {
389
+ function runDispatch(event, st, e0, options, owner) {
386
390
  const frames = options.frames ?? [];
387
391
  const origin = options.origin ?? ENGINE_ORIGIN;
388
392
  const refusing = failureRefuses(st.failure);
@@ -392,7 +396,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
392
396
  };
393
397
  if (refusing && options.ranks === undefined)
394
398
  return engineFault("a dispatch of an event whose failure column refuses names no answer ranks (the seat-trust law reads them)");
395
- const { all, guards } = participants(event, e0, frames, options.participant);
399
+ const { all, guards } = participants(event, e0, frames, options.participant, owner);
396
400
  const guard = refusing ? guards[0] : undefined;
397
401
  if (guard !== undefined) {
398
402
  const reason = "not run: the dispatch re-entered a frame it is part of, and it has no .catch to answer for it — a guard that cannot answer refuses";
@@ -471,6 +475,8 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
471
475
  const handed = handedOn(st.pinned, e0, passed, engines(), isProxy);
472
476
  if ("violation" in handed)
473
477
  return handed;
478
+ if (st.closed === true && !sameMembers(handed.payload, e0))
479
+ return { violation: "next() was handed an event with a member added or dropped — this event's handlers change only what its members hold" };
474
480
  const why = handOnViolation(handed.payload, options.checkHandOn, answererOf(h));
475
481
  return why !== undefined ? { violation: why } : { snap: handed.payload };
476
482
  };
@@ -517,6 +523,9 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
517
523
  if ("refusal" in received)
518
524
  return { violation: received.refusal };
519
525
  taken = received.answer;
526
+ const own = st.answers === undefined || taken === undefined ? undefined : ownAnswerViolation(taken, st.answers);
527
+ if (own !== undefined)
528
+ return { violation: own };
520
529
  }
521
530
  const below = s.pending > 0 ? [...s.answers, NEXT_IN_FLIGHT] : s.answers;
522
531
  const why = answerViolation(taken, options.checkAnswer, e, answererOf(h), below, Object.freeze({ bottomStarted }));
@@ -63,8 +63,11 @@
63
63
  * once the body ran: the call ran and its result is withheld.
64
64
  * 12: `classic.TaskCreated`, `classic.TaskCompleted` and `classic.TeammateIdle` have stations (the stop events' columns and answer
65
65
  * form: a task-list write a `block` undoes or fails, and a named teammate's stop point).
66
+ * 13: the closed set is 151 names (+`theme.set`, `theme.clear`, `ui.place`, `ui.cancelNotify`, `prompt.paint`, `decision.ask`);
67
+ * the eleven named surface methods have `method(true)` stations; `ui.message` and `ui.fault` have `ownerOnly` surface stations,
68
+ * `closed` (what is handed on keeps the event's members) and with `answers` (`{ props }` on `ui.message`, none on `ui.fault`).
66
69
  */
67
- export declare const KERNEL_CONTRACT_VERSION = 12;
70
+ export declare const KERNEL_CONTRACT_VERSION = 13;
68
71
  /** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
69
72
  export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
70
73
  export type ModTier = (typeof MOD_TIERS)[number];
@@ -145,6 +148,13 @@ export interface ModStation {
145
148
  /** The event's own ceiling on a handler's time: every clock a handler runs under on this event (its body, its
146
149
  * `.catch`, an observer) is the smaller of its own and this — a registration's budget never widens it. */
147
150
  readonly budgetMs?: number;
151
+ /** Dispatched only to the plugin named in `options.owner` (omitting `owner` rejects). */
152
+ readonly ownerOnly?: true;
153
+ /** What a handler hands on carries the event's own members, none added or dropped: with `pinned`, the rest is all it changes. */
154
+ readonly closed?: true;
155
+ /** The members an answer of a handler's own (not what its `next` answered) may carry: a record of these alone; `[]` — it
156
+ * answers only what its `next` answered. Absent ⇒ the raiser's check reads it. */
157
+ readonly answers?: readonly string[];
148
158
  }
149
159
  /** One event: its side, and its station when a bus raises it in this version (absent ⇒ named, not raised). */
150
160
  export interface ModEventRow {
@@ -152,10 +162,10 @@ export interface ModEventRow {
152
162
  readonly station?: ModStation;
153
163
  }
154
164
  /**
155
- * Every event the kernel knows: the reference's closed set of 145 names (CC 2.1.309 `_De` (cli309.js:253322) — its 33 `classic.*` names,
156
- * its 47 engine events and its 65 `$` methods, in its own order). The shell's names (`ui.*`, `command.*`,
157
- * `config.*`, `audio.*`, the prompt-box events and `prompt.read`) carry `side: "surface"`: one table serves both
158
- * buses, and the shell's stations are its rows here, raised by the shell where their chain bottoms are. A row with a
165
+ * Every event the kernel knows: the reference's closed set of 151 names (CC 2.1.321 `hFe` (cli321.js:276613) — its 33 `classic.*` names,
166
+ * its 47 events and its 71 `$` methods). The shell's names (`ui.*`, `theme.*`, `command.*`, `config.*`, `audio.*`,
167
+ * the prompt-box events and `prompt.read` / `prompt.paint`) carry `side: "surface"`: one table serves both buses,
168
+ * and the shell's stations are its rows here, raised by the shell where their chain bottoms are. A row with a
159
169
  * station is raised on its side in this version; a name with none is named, not raised, and a registration that
160
170
  * selects only such names is refused.
161
171
  */
@@ -265,6 +275,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
265
275
  "session.version": ModEventRow;
266
276
  "turn.abort": ModEventRow;
267
277
  "prompt.read": ModEventRow;
278
+ "prompt.paint": ModEventRow;
268
279
  "flag.value": ModEventRow;
269
280
  "tool.list": ModEventRow;
270
281
  "tool.register": ModEventRow;
@@ -273,6 +284,9 @@ export declare const MOD_EVENT_TABLE: Readonly<{
273
284
  "config.list": ModEventRow;
274
285
  "agent.list": ModEventRow;
275
286
  "agent.register": ModEventRow;
287
+ "theme.set": ModEventRow;
288
+ "theme.clear": ModEventRow;
289
+ "decision.ask": ModEventRow;
276
290
  "ui.toast": ModEventRow;
277
291
  "ui.status": ModEventRow;
278
292
  "ui.log": ModEventRow;
@@ -281,10 +295,12 @@ export declare const MOD_EVENT_TABLE: Readonly<{
281
295
  "ui.open": ModEventRow;
282
296
  "ui.close": ModEventRow;
283
297
  "ui.panes": ModEventRow;
298
+ "ui.place": ModEventRow;
284
299
  "ui.selection": ModEventRow;
285
300
  "ui.copy": ModEventRow;
286
301
  "ui.view": ModEventRow;
287
302
  "ui.notify": ModEventRow;
303
+ "ui.cancelNotify": ModEventRow;
288
304
  "ui.blit": ModEventRow;
289
305
  "fs.read": ModEventRow;
290
306
  "fs.write": ModEventRow;
@@ -1,4 +1,4 @@
1
- export const KERNEL_CONTRACT_VERSION = 12;
1
+ export const KERNEL_CONTRACT_VERSION = 13;
2
2
  export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
3
3
  export const MOD_SEATS = Object.freeze(["deployment", "task"]);
4
4
  export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
@@ -37,6 +37,9 @@ const station = (failure, abort, pinned = [], more = {}) => Object.freeze({
37
37
  ...(more.call === true ? { call: Object.freeze({ pausesCallerBudget: true }) } : {}),
38
38
  ...(more.budgetMs !== undefined ? { budgetMs: more.budgetMs } : {}),
39
39
  ...(more.env !== undefined ? { env: more.env } : {}),
40
+ ...(more.ownerOnly === true ? { ownerOnly: true } : {}),
41
+ ...(more.closed === true ? { closed: true } : {}),
42
+ ...(more.answers !== undefined ? { answers: Object.freeze([...more.answers]) } : {}),
40
43
  });
41
44
  const method = (pausesCallerBudget, more = {}) => Object.freeze({ failure: "skip", abort: "caller", pinned: Object.freeze([]), method: Object.freeze({ pausesCallerBudget }), ...(more.env !== undefined ? { env: more.env } : {}) });
42
45
  const timer = (repeats) => Object.freeze({ failure: "skip", abort: "caller", pinned: Object.freeze([]), method: Object.freeze({ pausesCallerBudget: false, timer: Object.freeze({ repeats }) }) });
@@ -90,8 +93,8 @@ export const MOD_EVENT_TABLE = Object.freeze({
90
93
  "ui.press": surface(station("skip", "grace", ELEMENT_PINNED)),
91
94
  "ui.input": surface(station("skip", "grace", ELEMENT_PINNED)),
92
95
  "ui.select": surface(station("skip", "grace", ELEMENT_PINNED)),
93
- "ui.message": surface(),
94
- "ui.fault": surface(),
96
+ "ui.message": surface(station("skip", "grace", ["surface", "component", "requestId", "element", "module"], { ownerOnly: true, closed: true, answers: ["props"] })),
97
+ "ui.fault": surface(station("skip", "grace", ["surface", "component", "requestId", "element", "module", "phase", "reason"], { ownerOnly: true, closed: true, answers: [] })),
95
98
  "ui.scroll": surface(station("skip", "grace", ["component", "requestId", "by", "bodyRows", "contentRows", "origin", "pointer"], { call: true })),
96
99
  "ui.focus": surface(station("skip", "grace", ["component", "requestId", "plugin", "origin", "element"], { call: true })),
97
100
  "agent.offer": engine(station("skip", "grace", ["agent", "provider"])),
@@ -152,6 +155,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
152
155
  "session.version": engine(method(true)),
153
156
  "turn.abort": engine(method(false)),
154
157
  "prompt.read": surface(method(true)),
158
+ "prompt.paint": surface(),
155
159
  "flag.value": engine(),
156
160
  "tool.list": engine(method(true)),
157
161
  "tool.register": engine(),
@@ -160,19 +164,24 @@ export const MOD_EVENT_TABLE = Object.freeze({
160
164
  "config.list": surface(method(true)),
161
165
  "agent.list": engine(method(true)),
162
166
  "agent.register": engine(),
167
+ "theme.set": surface(method(true)),
168
+ "theme.clear": surface(method(true)),
169
+ "decision.ask": engine(),
163
170
  "ui.toast": surface(method(true)),
164
- "ui.status": surface(),
171
+ "ui.status": surface(method(true)),
165
172
  "ui.log": surface(method(true)),
166
173
  "ui.notice": surface(method(true)),
167
174
  "ui.invalidate": surface(method(true)),
168
- "ui.open": surface(),
169
- "ui.close": surface(),
170
- "ui.panes": surface(),
175
+ "ui.open": surface(method(true)),
176
+ "ui.close": surface(method(true)),
177
+ "ui.panes": surface(method(true)),
178
+ "ui.place": surface(method(true)),
171
179
  "ui.selection": surface(method(true)),
172
180
  "ui.copy": surface(method(true)),
173
- "ui.view": surface(),
174
- "ui.notify": surface(),
175
- "ui.blit": surface(),
181
+ "ui.view": surface(method(true)),
182
+ "ui.notify": surface(method(true)),
183
+ "ui.cancelNotify": surface(method(true)),
184
+ "ui.blit": surface(method(true)),
176
185
  "fs.read": engine(),
177
186
  "fs.write": engine(),
178
187
  "fs.list": engine(),
@@ -0,0 +1 @@
1
+ export declare function sha256Hex(data: Uint8Array | string): string;