@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,567 @@
1
+ import { types } from "node:util";
2
+ import { shellWordsOf } from "../shell/shell-words.js";
3
+ import { ENGINE_TOOLS } from "./tool-catalog-entries.js";
4
+ const objectFreeze = Object.freeze;
5
+ const objectPrototype = Object.prototype;
6
+ const arrayPrototype = Array.prototype;
7
+ const objectGetPrototypeOf = Object.getPrototypeOf;
8
+ const objectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
9
+ const objectHasOwn = Object.hasOwn;
10
+ const objectKeys = Object.keys;
11
+ const reflectOwnKeys = Reflect.ownKeys;
12
+ const arrayIsArray = Array.isArray;
13
+ const numberIsInteger = Number.isInteger;
14
+ const isProxy = types.isProxy;
15
+ const callBind = Function.prototype.bind.bind(Function.prototype.call);
16
+ const strCharCodeAt = callBind(String.prototype.charCodeAt);
17
+ const strIndexOf = callBind(String.prototype.indexOf);
18
+ const strLastIndexOf = callBind(String.prototype.lastIndexOf);
19
+ const strIncludes = callBind(String.prototype.includes);
20
+ const strSlice = callBind(String.prototype.slice);
21
+ const strStartsWith = callBind(String.prototype.startsWith);
22
+ const strEndsWith = callBind(String.prototype.endsWith);
23
+ const strTrim = callBind(String.prototype.trim);
24
+ const strToLowerCase = callBind(String.prototype.toLowerCase);
25
+ const arrPush = callBind(Array.prototype.push);
26
+ const arrJoin = callBind(Array.prototype.join);
27
+ const setHas = callBind(Set.prototype.has);
28
+ const mapGet = callBind(Map.prototype.get);
29
+ function snapshotOwnKeys(proto) {
30
+ const raw = reflectOwnKeys(proto);
31
+ const copy = [];
32
+ for (let i = 0; i < raw.length; i++) {
33
+ copy[i] = raw[i];
34
+ }
35
+ return objectFreeze(copy);
36
+ }
37
+ const OBJECT_PROTO_KEYS = snapshotOwnKeys(objectPrototype);
38
+ const ARRAY_PROTO_KEYS = snapshotOwnKeys(arrayPrototype);
39
+ export const HOOK_CONDITION_EVENTS = objectFreeze([
40
+ "PreToolUse",
41
+ "PostToolUse",
42
+ "PostToolUseFailure",
43
+ "PermissionRequest",
44
+ "PermissionDenied",
45
+ ]);
46
+ export const HOOK_CONDITION_UNTESTED_REASONS = objectFreeze([
47
+ "not_a_tool_event",
48
+ "condition_unreadable",
49
+ "name_unjudged",
50
+ "content_unjudged",
51
+ "invalid_input",
52
+ ]);
53
+ function frozenUntested(reason, detail) {
54
+ return objectFreeze({ verdict: "untested", reason, detail });
55
+ }
56
+ const MATCHED = objectFreeze({ verdict: "matched" });
57
+ const INVALID_REALM_PROTOTYPES = frozenUntested("invalid_input", "the own-key lists of the realm's base prototypes differ from those at load");
58
+ const INVALID_UNREADABLE = frozenUntested("invalid_input", "the input is not plain data");
59
+ const INVALID_ENVELOPE_KEY = frozenUntested("invalid_input", "the input carries an unrecognized member");
60
+ const INVALID_EVENT = frozenUntested("invalid_input", "event must be a string");
61
+ const INVALID_TOOL_NAME = frozenUntested("invalid_input", "toolName must be a string");
62
+ const INVALID_TOOL_NAME_REQUIRED = frozenUntested("invalid_input", "toolName must be a non-empty string for tool events");
63
+ const INVALID_ENGINE_OWNED = frozenUntested("invalid_input", "engineOwned must be true when present");
64
+ const INVALID_TOOL_INPUT_DATA = frozenUntested("invalid_input", "toolInput is not plain data");
65
+ const INVALID_BASH_KEY = frozenUntested("invalid_input", "toolInput carries an unrecognized Bash parameter");
66
+ const INVALID_BASH_COMMAND = frozenUntested("invalid_input", "Bash toolInput.command must be a string");
67
+ const INVALID_BASH_TYPE = frozenUntested("invalid_input", "Bash toolInput carries a parameter of the wrong type");
68
+ const CONDITION_UNREADABLE = frozenUntested("condition_unreadable", "condition is not a readable unescaped string");
69
+ const NOT_A_TOOL_EVENT = frozenUntested("not_a_tool_event", "event is not one of the five tool hook events");
70
+ const NAME_MISMATCH = frozenUntested("name_unjudged", "condition tool name does not match call tool name");
71
+ const NAME_OUTSIDE_CATALOG = frozenUntested("name_unjudged", "tool name is outside the engine tool catalog");
72
+ const NAME_MONITOR = frozenUntested("name_unjudged", "Monitor hook conditions depend on outer routing context");
73
+ const CONTENT_REQUIRES_ENGINE_OWNED = frozenUntested("content_unjudged", "a condition with content requires engineOwned: true");
74
+ const CONTENT_NON_BASH = frozenUntested("content_unjudged", "content matching is only judged for Bash in v1");
75
+ const CONTENT_ABSENT_TOOL_INPUT = frozenUntested("content_unjudged", "toolInput is absent for Bash content condition");
76
+ const CONTENT_TIMEOUT_RANGE = frozenUntested("content_unjudged", "Bash toolInput.timeout is outside the judged integer range");
77
+ const CONTENT_CONFIG_DEPENDENT_KEY = frozenUntested("content_unjudged", "Bash toolInput carries run_in_background or dangerouslyDisableSandbox, whose schema membership depends on reference configuration");
78
+ const CONTENT_TOO_LONG = frozenUntested("content_unjudged", "condition content exceeds the 1000-character ceiling");
79
+ const CONTENT_NOT_FLAT = frozenUntested("content_unjudged", "Bash command is not strictly flat");
80
+ const CONTENT_NOT_MATCHED = frozenUntested("content_unjudged", "Bash command did not match the condition pattern");
81
+ const ENVELOPE_KEYS = objectFreeze(new Set(["condition", "event", "toolName", "toolInput", "engineOwned"]));
82
+ const TOOL_EVENT_SET = objectFreeze(new Set(HOOK_CONDITION_EVENTS));
83
+ const FORMER_NAMES = new Map([
84
+ ["Task", "Agent"],
85
+ ["KillShell", "TaskStop"],
86
+ ["KillBash", "TaskStop"],
87
+ ["Brief", "SendUserMessage"],
88
+ ]);
89
+ const CATALOG_NAMES = objectFreeze(new Set(ENGINE_TOOLS.map((e) => e.name)));
90
+ const CATALOG_ALIASES = new Map(ENGINE_TOOLS.flatMap((e) => (e.aliases ?? []).map((alias) => [alias, e.name])));
91
+ const BASH_INPUT_KEYS = new Map([
92
+ ["command", "string"],
93
+ ["timeout", "number"],
94
+ ["description", "string"],
95
+ ["run_in_background", "boolean"],
96
+ ["dangerouslyDisableSandbox", "boolean"],
97
+ ]);
98
+ const BASH_RESERVED_WORDS = objectFreeze(new Set(shellWordsOf("rule_reserved")));
99
+ const WRAPPER_WORDS = objectFreeze(new Set(["timeout", "env", "nice", "sudo", "xargs"]));
100
+ const MAX_COMMAND_CHARS = 10_000;
101
+ const MAX_CONTENT_CHARS = 1_000;
102
+ const MAX_TIMEOUT_MS = 600_000;
103
+ function protoKeysUnchanged(proto, expected) {
104
+ const current = reflectOwnKeys(proto);
105
+ if (current.length !== expected.length)
106
+ return false;
107
+ for (let i = 0; i < expected.length; i++) {
108
+ if (current[i] !== expected[i])
109
+ return false;
110
+ }
111
+ return true;
112
+ }
113
+ function admitPlainRecord(v) {
114
+ try {
115
+ if (typeof v === "function")
116
+ return false;
117
+ if (isProxy(v))
118
+ return false;
119
+ if (v === null || typeof v !== "object" || arrayIsArray(v))
120
+ return false;
121
+ const proto = objectGetPrototypeOf(v);
122
+ if (proto !== objectPrototype && proto !== null)
123
+ return false;
124
+ const keys = reflectOwnKeys(v);
125
+ for (let i = 0; i < keys.length; i++) {
126
+ const k = keys[i];
127
+ if (typeof k === "symbol")
128
+ return false;
129
+ const desc = objectGetOwnPropertyDescriptor(v, k);
130
+ if (desc === undefined || !objectHasOwn(desc, "value") || desc.enumerable !== true) {
131
+ return false;
132
+ }
133
+ }
134
+ return true;
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ }
140
+ function validateBashInputShape(toolInput) {
141
+ const inputKeys = objectKeys(toolInput);
142
+ for (let i = 0; i < inputKeys.length; i++) {
143
+ const k = inputKeys[i];
144
+ const expectedType = mapGet(BASH_INPUT_KEYS, k);
145
+ if (expectedType === undefined) {
146
+ return INVALID_BASH_KEY;
147
+ }
148
+ const val = toolInput[k];
149
+ if (k === "command") {
150
+ if (typeof val !== "string") {
151
+ return INVALID_BASH_COMMAND;
152
+ }
153
+ }
154
+ else if (val !== undefined && typeof val !== expectedType) {
155
+ return INVALID_BASH_TYPE;
156
+ }
157
+ }
158
+ if (!objectHasOwn(toolInput, "command") || typeof toolInput.command !== "string") {
159
+ return INVALID_BASH_COMMAND;
160
+ }
161
+ return undefined;
162
+ }
163
+ function splitCondition(s) {
164
+ const o = strIndexOf(s, "(");
165
+ const c = strLastIndexOf(s, ")");
166
+ if (o <= 0 || c <= o || c !== s.length - 1) {
167
+ return { name: s, content: undefined };
168
+ }
169
+ const name = strSlice(s, 0, o);
170
+ if (strIncludes(name, "(") || strIncludes(name, ")")) {
171
+ return { name: s, content: undefined };
172
+ }
173
+ const inner = strSlice(s, o + 1, c);
174
+ if (inner === "" || inner === "*") {
175
+ return { name, content: undefined };
176
+ }
177
+ return { name, content: inner };
178
+ }
179
+ function canonicalName(n) {
180
+ const afterFormer = mapGet(FORMER_NAMES, n) ?? n;
181
+ return mapGet(CATALOG_ALIASES, afterFormer) ?? afterFormer;
182
+ }
183
+ function isAllowedCommandChar(code) {
184
+ if (code >= 0x30 && code <= 0x39)
185
+ return true;
186
+ if (code >= 0x41 && code <= 0x5a)
187
+ return true;
188
+ if (code >= 0x61 && code <= 0x7a)
189
+ return true;
190
+ if (code === 0x20)
191
+ return true;
192
+ return (code === 0x5f ||
193
+ code === 0x2e ||
194
+ code === 0x2f ||
195
+ code === 0x3d ||
196
+ code === 0x3a ||
197
+ code === 0x2c ||
198
+ code === 0x40 ||
199
+ code === 0x25 ||
200
+ code === 0x2b ||
201
+ code === 0x2d);
202
+ }
203
+ function isAssignmentWord(word) {
204
+ const len = word.length;
205
+ if (len < 2)
206
+ return false;
207
+ const c0 = strCharCodeAt(word, 0);
208
+ const firstOk = (c0 >= 0x41 && c0 <= 0x5a) || (c0 >= 0x61 && c0 <= 0x7a) || c0 === 0x5f;
209
+ if (!firstOk)
210
+ return false;
211
+ let i = 1;
212
+ while (i < len) {
213
+ const c = strCharCodeAt(word, i);
214
+ if ((c >= 0x41 && c <= 0x5a) ||
215
+ (c >= 0x61 && c <= 0x7a) ||
216
+ (c >= 0x30 && c <= 0x39) ||
217
+ c === 0x5f) {
218
+ i++;
219
+ continue;
220
+ }
221
+ break;
222
+ }
223
+ if (i >= len)
224
+ return false;
225
+ const op = strCharCodeAt(word, i);
226
+ if (op === 0x3d)
227
+ return true;
228
+ if (op === 0x2b && i + 1 < len && strCharCodeAt(word, i + 1) === 0x3d)
229
+ return true;
230
+ return false;
231
+ }
232
+ function flatWords(command) {
233
+ const len = command.length;
234
+ if (len === 0 || len > MAX_COMMAND_CHARS)
235
+ return undefined;
236
+ if (strCharCodeAt(command, 0) === 0x20 || strCharCodeAt(command, len - 1) === 0x20) {
237
+ return undefined;
238
+ }
239
+ const words = [];
240
+ let wordStart = 0;
241
+ let prevCode = -1;
242
+ for (let i = 0; i < len; i++) {
243
+ const code = strCharCodeAt(command, i);
244
+ if (!isAllowedCommandChar(code))
245
+ return undefined;
246
+ if (code === 0x20) {
247
+ if (prevCode === 0x20)
248
+ return undefined;
249
+ arrPush(words, strSlice(command, wordStart, i));
250
+ wordStart = i + 1;
251
+ }
252
+ prevCode = code;
253
+ }
254
+ arrPush(words, strSlice(command, wordStart, len));
255
+ if (words.length === 0)
256
+ return undefined;
257
+ if (setHas(BASH_RESERVED_WORDS, words[0]))
258
+ return undefined;
259
+ for (let i = 0; i < words.length; i++) {
260
+ const w = words[i];
261
+ if (w.length === 0)
262
+ return undefined;
263
+ if (strCharCodeAt(w, 0) === 0x3d)
264
+ return undefined;
265
+ if (isAssignmentWord(w))
266
+ return undefined;
267
+ if (setHas(WRAPPER_WORDS, w))
268
+ return undefined;
269
+ }
270
+ return words;
271
+ }
272
+ function collapseBlanks(s) {
273
+ let out = "";
274
+ let inBlank = false;
275
+ for (let i = 0; i < s.length; i++) {
276
+ const code = strCharCodeAt(s, i);
277
+ if (code === 0x20 || code === 0x09) {
278
+ if (!inBlank) {
279
+ out += " ";
280
+ inBlank = true;
281
+ }
282
+ }
283
+ else {
284
+ out += strSlice(s, i, i + 1);
285
+ inBlank = false;
286
+ }
287
+ }
288
+ return out;
289
+ }
290
+ function colonStarPrefix(content) {
291
+ if (content.length < 3 || !strEndsWith(content, ":*"))
292
+ return undefined;
293
+ if (strIndexOf(content, "\n") >= 0 ||
294
+ strIndexOf(content, "\r") >= 0 ||
295
+ strIndexOf(content, "\u2028") >= 0 ||
296
+ strIndexOf(content, "\u2029") >= 0) {
297
+ return undefined;
298
+ }
299
+ return strSlice(content, 0, content.length - 2);
300
+ }
301
+ function referenceWildcardMatch(pattern, value, ignoreCase = false, foldBlanks = false) {
302
+ if (strIncludes(pattern, "\u0000"))
303
+ return false;
304
+ const l = strTrim(pattern);
305
+ const c0 = foldBlanks ? collapseBlanks(l) : l;
306
+ const g0 = foldBlanks ? collapseBlanks(value) : value;
307
+ const c = ignoreCase ? strToLowerCase(c0) : c0;
308
+ const g = ignoreCase ? strToLowerCase(g0) : g0;
309
+ const chars = [];
310
+ const isUnescapedStar = [];
311
+ let starCount = 0;
312
+ for (let i = 0; i < c.length; i++) {
313
+ const ch = strSlice(c, i, i + 1);
314
+ if (ch === "\\" && i + 1 < c.length) {
315
+ const next = strSlice(c, i + 1, i + 2);
316
+ if (next === "*") {
317
+ arrPush(chars, "*");
318
+ arrPush(isUnescapedStar, false);
319
+ i++;
320
+ continue;
321
+ }
322
+ if (next === "\\") {
323
+ arrPush(chars, "\\");
324
+ arrPush(isUnescapedStar, false);
325
+ i++;
326
+ continue;
327
+ }
328
+ }
329
+ arrPush(chars, ch);
330
+ const star = ch === "*";
331
+ arrPush(isUnescapedStar, star);
332
+ if (star)
333
+ starCount++;
334
+ }
335
+ const tokens = [];
336
+ let litBuf = "";
337
+ const flushLit = () => {
338
+ if (litBuf.length > 0) {
339
+ arrPush(tokens, { kind: "lit", text: litBuf });
340
+ litBuf = "";
341
+ }
342
+ };
343
+ let pos = 0;
344
+ while (pos < chars.length) {
345
+ if (chars[pos] === "/" && !isUnescapedStar[pos]) {
346
+ let p = pos + 1;
347
+ let groups = 0;
348
+ while (p + 2 < chars.length &&
349
+ isUnescapedStar[p] &&
350
+ isUnescapedStar[p + 1] &&
351
+ chars[p + 2] === "/" &&
352
+ !isUnescapedStar[p + 2]) {
353
+ groups++;
354
+ p += 3;
355
+ }
356
+ if (groups > 0) {
357
+ flushLit();
358
+ arrPush(tokens, { kind: "globstar" });
359
+ pos = p;
360
+ continue;
361
+ }
362
+ }
363
+ if (isUnescapedStar[pos]) {
364
+ flushLit();
365
+ arrPush(tokens, { kind: "star" });
366
+ pos++;
367
+ continue;
368
+ }
369
+ litBuf += chars[pos];
370
+ pos++;
371
+ }
372
+ flushLit();
373
+ if (starCount === 1 && tokens.length >= 2) {
374
+ const last = tokens[tokens.length - 1];
375
+ const prev = tokens[tokens.length - 2];
376
+ if (last.kind === "star" && prev.kind === "lit" && strEndsWith(prev.text, " ")) {
377
+ const trimmedPrev = strSlice(prev.text, 0, prev.text.length - 1);
378
+ if (trimmedPrev.length > 0) {
379
+ tokens[tokens.length - 2] = { kind: "lit", text: trimmedPrev };
380
+ tokens[tokens.length - 1] = { kind: "optSpaceStar" };
381
+ }
382
+ else {
383
+ tokens[tokens.length - 2] = { kind: "optSpaceStar" };
384
+ tokens.length = tokens.length - 1;
385
+ }
386
+ }
387
+ }
388
+ const n = g.length;
389
+ let dp = [];
390
+ for (let i = 0; i <= n; i++)
391
+ dp[i] = i === 0;
392
+ for (let t = 0; t < tokens.length; t++) {
393
+ const tok = tokens[t];
394
+ const next = [];
395
+ for (let i = 0; i <= n; i++)
396
+ next[i] = false;
397
+ if (tok.kind === "lit") {
398
+ const tlen = tok.text.length;
399
+ for (let j = 0; j + tlen <= n; j++) {
400
+ if (dp[j] && strSlice(g, j, j + tlen) === tok.text) {
401
+ next[j + tlen] = true;
402
+ }
403
+ }
404
+ }
405
+ else if (tok.kind === "star") {
406
+ let first = -1;
407
+ for (let j = 0; j <= n; j++) {
408
+ if (dp[j]) {
409
+ first = j;
410
+ break;
411
+ }
412
+ }
413
+ if (first >= 0) {
414
+ for (let p = first; p <= n; p++)
415
+ next[p] = true;
416
+ }
417
+ }
418
+ else if (tok.kind === "globstar") {
419
+ let firstSlash = -1;
420
+ for (let j = 0; j < n; j++) {
421
+ if (dp[j] && strCharCodeAt(g, j) === 0x2f) {
422
+ firstSlash = j;
423
+ break;
424
+ }
425
+ }
426
+ if (firstSlash >= 0) {
427
+ for (let p = firstSlash; p < n; p++) {
428
+ if (strCharCodeAt(g, p) === 0x2f) {
429
+ next[p + 1] = true;
430
+ }
431
+ }
432
+ }
433
+ }
434
+ else {
435
+ let firstAfterSpace = -1;
436
+ for (let j = 0; j <= n; j++) {
437
+ if (!dp[j])
438
+ continue;
439
+ next[j] = true;
440
+ if (firstAfterSpace < 0 && j < n && strCharCodeAt(g, j) === 0x20) {
441
+ firstAfterSpace = j + 1;
442
+ }
443
+ }
444
+ if (firstAfterSpace >= 0) {
445
+ for (let p = firstAfterSpace; p <= n; p++)
446
+ next[p] = true;
447
+ }
448
+ }
449
+ dp = next;
450
+ }
451
+ return dp[n] === true;
452
+ }
453
+ export function judgeHookCondition(input) {
454
+ try {
455
+ if (!protoKeysUnchanged(objectPrototype, OBJECT_PROTO_KEYS) ||
456
+ !protoKeysUnchanged(arrayPrototype, ARRAY_PROTO_KEYS)) {
457
+ return INVALID_REALM_PROTOTYPES;
458
+ }
459
+ if (!admitPlainRecord(input)) {
460
+ return INVALID_UNREADABLE;
461
+ }
462
+ const keys = objectKeys(input);
463
+ for (let i = 0; i < keys.length; i++) {
464
+ if (!setHas(ENVELOPE_KEYS, keys[i])) {
465
+ return INVALID_ENVELOPE_KEY;
466
+ }
467
+ }
468
+ const event = objectHasOwn(input, "event") ? input.event : undefined;
469
+ if (typeof event !== "string") {
470
+ return INVALID_EVENT;
471
+ }
472
+ const hasToolName = objectHasOwn(input, "toolName") && input.toolName !== undefined;
473
+ const toolName = hasToolName ? input.toolName : undefined;
474
+ if (hasToolName && typeof toolName !== "string") {
475
+ return INVALID_TOOL_NAME;
476
+ }
477
+ const hasEngineOwned = objectHasOwn(input, "engineOwned") && input.engineOwned !== undefined;
478
+ if (hasEngineOwned && input.engineOwned !== true) {
479
+ return INVALID_ENGINE_OWNED;
480
+ }
481
+ const hasToolInput = objectHasOwn(input, "toolInput") && input.toolInput !== undefined;
482
+ const toolInput = hasToolInput ? input.toolInput : undefined;
483
+ if (hasToolInput && !admitPlainRecord(toolInput)) {
484
+ return INVALID_TOOL_INPUT_DATA;
485
+ }
486
+ if (hasToolInput && typeof toolName === "string" && canonicalName(toolName) === "Bash") {
487
+ const bashErr = validateBashInputShape(toolInput);
488
+ if (bashErr !== undefined) {
489
+ return bashErr;
490
+ }
491
+ }
492
+ const condition = objectHasOwn(input, "condition") ? input.condition : undefined;
493
+ if (typeof condition !== "string" || strIncludes(condition, "\\")) {
494
+ return CONDITION_UNREADABLE;
495
+ }
496
+ if (condition === "") {
497
+ return MATCHED;
498
+ }
499
+ if (!setHas(TOOL_EVENT_SET, event)) {
500
+ return NOT_A_TOOL_EVENT;
501
+ }
502
+ if (typeof toolName !== "string" || toolName.length === 0) {
503
+ return INVALID_TOOL_NAME_REQUIRED;
504
+ }
505
+ const { name: rawCondName, content } = splitCondition(condition);
506
+ const condName = canonicalName(rawCondName);
507
+ const callName = canonicalName(toolName);
508
+ if (condName !== callName) {
509
+ return NAME_MISMATCH;
510
+ }
511
+ if (!setHas(CATALOG_NAMES, condName)) {
512
+ return NAME_OUTSIDE_CATALOG;
513
+ }
514
+ if (condName === "Monitor") {
515
+ return NAME_MONITOR;
516
+ }
517
+ if (content === undefined) {
518
+ return MATCHED;
519
+ }
520
+ if (!hasEngineOwned) {
521
+ return CONTENT_REQUIRES_ENGINE_OWNED;
522
+ }
523
+ if (condName !== "Bash") {
524
+ return CONTENT_NON_BASH;
525
+ }
526
+ if (content.length > MAX_CONTENT_CHARS) {
527
+ return CONTENT_TOO_LONG;
528
+ }
529
+ if (!hasToolInput) {
530
+ return CONTENT_ABSENT_TOOL_INPUT;
531
+ }
532
+ const bashInput = toolInput;
533
+ if (objectHasOwn(bashInput, "run_in_background") ||
534
+ objectHasOwn(bashInput, "dangerouslyDisableSandbox")) {
535
+ return CONTENT_CONFIG_DEPENDENT_KEY;
536
+ }
537
+ if (objectHasOwn(bashInput, "timeout") && bashInput.timeout !== undefined) {
538
+ const timeout = bashInput.timeout;
539
+ if (!numberIsInteger(timeout) || timeout < 0 || timeout > MAX_TIMEOUT_MS) {
540
+ return CONTENT_TIMEOUT_RANGE;
541
+ }
542
+ }
543
+ const words = flatWords(bashInput.command);
544
+ if (words === undefined) {
545
+ return CONTENT_NOT_FLAT;
546
+ }
547
+ const w = arrJoin(words, " ");
548
+ const prefix = colonStarPrefix(content);
549
+ if (prefix !== undefined) {
550
+ if (w === prefix ||
551
+ strStartsWith(w, prefix + " ") ||
552
+ w === "xargs " + prefix ||
553
+ strStartsWith(w, "xargs " + prefix + " ")) {
554
+ return MATCHED;
555
+ }
556
+ return CONTENT_NOT_MATCHED;
557
+ }
558
+ if (referenceWildcardMatch(content, w, false, true) ||
559
+ referenceWildcardMatch("xargs " + content, w, false, true)) {
560
+ return MATCHED;
561
+ }
562
+ return CONTENT_NOT_MATCHED;
563
+ }
564
+ catch {
565
+ return INVALID_UNREADABLE;
566
+ }
567
+ }
@@ -543,6 +543,9 @@ export declare function createHookEnvCapabilities(env: ExecutionEnv): HookEnvCap
543
543
  export interface HookInvocationIdentity {
544
544
  /** The run's session id (uuid domain) — the same key `TaskResult.sessionId` reports. */
545
545
  readonly sessionId: string;
546
+ /** The delegation tree's root session id — the session the tree's shared task list belongs to (`task_list.partition_is_root_session`):
547
+ * `internals.rootSessionId` when present, else {@link sessionId} on a top-level leg, else absent (never fabricated on a child/observer leg with no root anchor). */
548
+ readonly rootSessionId?: string;
546
549
  /** The run's unified task id (the leg's one mint; TaskEvent's `sourceTaskId` and `task_progress` key on it): a background
547
550
  * sub-agent's registry task id, else the host's declared task id, else {@link sessionId}. */
548
551
  readonly taskId: string;
@@ -1235,6 +1238,8 @@ export interface ToolGateInput extends PermissionSeatInputs, SkillGateSeats, All
1235
1238
  * `dangerouslyDisableSandbox` (`command-sandbox.ts`)? Such a call is never let go without an answer: a surviving `allow` becomes
1236
1239
  * the `sandbox_override` question and every ask on the call carries that class. Absent ⇒ the run has no command sandbox. */
1237
1240
  leavesCommandSandbox?: (args: unknown) => boolean;
1241
+ /** PRESENT ⇔ the Runner declares its shape: the call's destination on these arguments, the leg's mode fold for a bypass request, the deny rows the call may meet and the allow layer's read-only reading ({@link import("./ask-origin.js").ConfinedCall}). */
1242
+ confined?: import("./shell-read-silence.js").ConfinedSeat;
1238
1243
  /** The deployment's A2A peer-isolation switch: a set switch makes the A2A egress default an operator mandate. */
1239
1244
  a2aIsolatePeers?: boolean;
1240
1245
  /** The call goes to an A2A peer registered inside the trust boundary (and not isolated): the peer and the identity stamp its registration
@@ -81,6 +81,7 @@ const IDENTITY_AGENT_NAME_MAX = 80;
81
81
  export function mintHookInvocationIdentity(facts) {
82
82
  return Object.freeze(Object.assign(Object.create(null), {
83
83
  sessionId: facts.sessionId,
84
+ ...(facts.rootSessionId !== undefined ? { rootSessionId: facts.rootSessionId } : {}),
84
85
  taskId: facts.taskId,
85
86
  legKind: facts.legKind,
86
87
  isDelegatedChild: facts.isDelegatedChild,
@@ -0,0 +1,23 @@
1
+ /** Deployment-declared host process identity (`RunnerDeps.host`, projected onto `WiringManifest.host`). */
2
+ export interface HostInstanceDeclaration {
3
+ /** Stable identifier of the host process / replica (single-line visible string, 1..256 UTF-16 units). */
4
+ readonly instanceId: string;
5
+ /** Epoch milliseconds when the host process started (non-negative safe integer, matching `/health.startedAt`). */
6
+ readonly startedAt: number;
7
+ }
8
+ /** Engine-minted per-leg instance identity (`WiringManifest.leg.instance`). */
9
+ export interface WiringLegInstance {
10
+ /** The leg's per-run invocation id (`TaskResult.runId`), minted once at prepare entry. */
11
+ readonly runId: string;
12
+ /** Wall-clock epoch milliseconds minted once beside {@link runId} at prepare entry. */
13
+ readonly startedAt: number;
14
+ }
15
+ /**
16
+ * Receive `RunnerDeps.host` (or `WiringFacts.host`) through the engine's one member door (`receiveMembers`).
17
+ * Absent (`undefined`) ⇒ `undefined` (omitted from the manifest). Present ⇒ validated and returned as a frozen copy;
18
+ * any bad container, stray member, throwing getter, invalid `instanceId`, or invalid `startedAt` throws
19
+ * `config.invalid_argument` naming `<subject>` or `<subject>.<member>` (each member is read once: a getter is kept at its first answer).
20
+ */
21
+ export declare function receiveHostInstance(raw: unknown, subject?: string): Readonly<HostInstanceDeclaration> | undefined;
22
+ /** Screen and freeze a `WiringFacts.legInstance` fact for `deriveWiringManifest`. */
23
+ export declare function readLegInstanceFact(raw: unknown): Readonly<WiringLegInstance>;
@@ -0,0 +1,69 @@
1
+ import { callerText } from "./caller-text.js";
2
+ import { optionKeys, receiveMembers } from "./own-property-receipt.js";
3
+ import { describeRejectedValue } from "./tool-search-setting.js";
4
+ const HOST_INSTANCE_KEYS = optionKeys()({ instanceId: 0, startedAt: 0 });
5
+ const HOST_INSTANCE_ID_MAX_CHARS = 256;
6
+ function hostRefusal(message, field) {
7
+ const e = new Error(message);
8
+ e.code = "config.invalid_argument";
9
+ e.detail = Object.freeze({ field });
10
+ return e;
11
+ }
12
+ export function receiveHostInstance(raw, subject = "RunnerDeps.host") {
13
+ if (raw === undefined)
14
+ return undefined;
15
+ if (typeof raw !== "object" || raw === null) {
16
+ throw hostRefusal(`${subject} must be a plain object { instanceId, startedAt }, got ${raw === null ? "null" : typeof raw}`, subject);
17
+ }
18
+ let copy;
19
+ try {
20
+ copy = receiveMembers(raw, { subject, unit: "member", moment: "when host identity is declared" }, HOST_INSTANCE_KEYS, (msg, [stray]) => hostRefusal(msg, typeof stray === "string" ? `${subject}.${stray}` : subject));
21
+ }
22
+ catch (err) {
23
+ if (err instanceof Error && err.detail === undefined) {
24
+ const { member } = err;
25
+ const field = typeof member === "string" ? `${subject}.${member}` : subject;
26
+ err.detail = Object.freeze({ field });
27
+ }
28
+ throw err;
29
+ }
30
+ const idField = `${subject}.instanceId`;
31
+ const id = copy.instanceId;
32
+ if (typeof id !== "string") {
33
+ throw hostRefusal(`${idField} must be a non-empty string, got ${describeRejectedValue(id)}`, idField);
34
+ }
35
+ if (id.length === 0 || id.trim().length === 0) {
36
+ throw hostRefusal(`${idField} must be a non-empty visible string (got empty or whitespace-only)`, idField);
37
+ }
38
+ if (id.trim() !== id) {
39
+ throw hostRefusal(`${idField} must not carry leading or trailing whitespace (${callerText(id)})`, idField);
40
+ }
41
+ if (/[\u0000-\u001f\u007f-\u009f\u{2028}\u{2029}]/u.test(id)) {
42
+ throw hostRefusal(`${idField} must be a single-line visible string without control characters (${callerText(id)})`, idField);
43
+ }
44
+ if (/(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:$|[^\uDC00-\uDFFF])/.test(id)) {
45
+ throw hostRefusal(`${idField} must be well-formed Unicode`, idField);
46
+ }
47
+ if (id.length > HOST_INSTANCE_ID_MAX_CHARS) {
48
+ throw hostRefusal(`${idField} exceeds ${HOST_INSTANCE_ID_MAX_CHARS} UTF-16 code units (got ${id.length})`, idField);
49
+ }
50
+ const startedAtField = `${subject}.startedAt`;
51
+ const startedAt = copy.startedAt;
52
+ if (typeof startedAt !== "number" || !Number.isSafeInteger(startedAt) || startedAt < 0) {
53
+ throw hostRefusal(`${startedAtField} must be a non-negative safe integer epoch-ms timestamp, got ${describeRejectedValue(startedAt)}`, startedAtField);
54
+ }
55
+ return Object.freeze({ instanceId: id, startedAt });
56
+ }
57
+ export function readLegInstanceFact(raw) {
58
+ if (typeof raw !== "object" || raw === null) {
59
+ throw new Error(`the legInstance wiring fact must be { runId, startedAt }, got ${raw === null ? "null" : typeof raw}`);
60
+ }
61
+ const { runId, startedAt } = raw;
62
+ if (typeof runId !== "string" || runId.length === 0) {
63
+ throw new Error(`the legInstance wiring fact requires a non-empty string runId, got ${describeRejectedValue(runId)}`);
64
+ }
65
+ if (typeof startedAt !== "number" || !Number.isSafeInteger(startedAt) || startedAt < 0) {
66
+ throw new Error(`the legInstance wiring fact requires a non-negative safe integer epoch-ms startedAt, got ${describeRejectedValue(startedAt)}`);
67
+ }
68
+ return Object.freeze({ runId, startedAt });
69
+ }