@sema-agent/core 7.70.0 → 7.71.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 (434) hide show
  1. package/CHANGELOG.md +728 -0
  2. package/dist/agents/agent-transcript-tool.js +43 -19
  3. package/dist/agents/inherited-tool-pool.d.ts +5 -1
  4. package/dist/agents/inherited-tool-pool.js +6 -0
  5. package/dist/agents/retain-ledger.js +2 -0
  6. package/dist/agents/send-message-tool.d.ts +12 -1
  7. package/dist/agents/send-message-tool.js +47 -9
  8. package/dist/agents/subagent.js +31 -10
  9. package/dist/agents/tool-filter.js +1 -2
  10. package/dist/agents/verify.js +13 -2
  11. package/dist/agents/yield-adoption.js +11 -1
  12. package/dist/brain/claude-model-id.d.ts +11 -0
  13. package/dist/brain/claude-model-id.js +3 -1
  14. package/dist/config/catalog.js +10 -1
  15. package/dist/config/defaults.d.ts +3 -0
  16. package/dist/config/defaults.js +1 -0
  17. package/dist/core/allow-entry.js +1 -2
  18. package/dist/core/ask-origin.d.ts +55 -21
  19. package/dist/core/ask-origin.js +19 -11
  20. package/dist/core/ask-question.d.ts +4 -7
  21. package/dist/core/ask-question.js +2 -4
  22. package/dist/core/ask-unresolvable-notice.d.ts +17 -3
  23. package/dist/core/ask-unresolvable-notice.js +18 -4
  24. package/dist/core/attachment-source.d.ts +1 -1
  25. package/dist/core/attachment-source.js +2 -0
  26. package/dist/core/auto-compaction.d.ts +14 -4
  27. package/dist/core/auto-compaction.js +3 -2
  28. package/dist/core/auto-strip.js +2 -0
  29. package/dist/core/caller-text.d.ts +2 -33
  30. package/dist/core/caller-text.js +2 -23
  31. package/dist/core/caller-tool-name.js +1 -2
  32. package/dist/core/canonical-json.d.ts +9 -0
  33. package/dist/core/canonical-json.js +6 -0
  34. package/dist/core/checkpoint-features.d.ts +43 -80
  35. package/dist/core/checkpoint-features.js +10 -20
  36. package/dist/core/checkpoint-generation.d.ts +89 -19
  37. package/dist/core/checkpoint-generation.js +89 -14
  38. package/dist/core/checkpoint-queries.d.ts +95 -15
  39. package/dist/core/checkpoint-queries.js +108 -7
  40. package/dist/core/checkpoint-rekey.d.ts +2 -1
  41. package/dist/core/checkpoint-rekey.js +2 -2
  42. package/dist/core/checkpoint-requirements.d.ts +7 -6
  43. package/dist/core/checkpoint-requirements.js +2 -5
  44. package/dist/core/checkpoint-row-verdict.d.ts +3 -4
  45. package/dist/core/checkpoint-row-verdict.js +20 -41
  46. package/dist/core/checkpoint-store.d.ts +65 -41
  47. package/dist/core/checkpoint-store.js +28 -14
  48. package/dist/core/command-sandbox.d.ts +5 -3
  49. package/dist/core/command-sandbox.js +17 -9
  50. package/dist/core/config-refusal-codes.d.ts +1 -1
  51. package/dist/core/config-refusal-codes.js +1 -0
  52. package/dist/core/declaration-words.d.ts +2 -1
  53. package/dist/core/declaration-words.js +13 -2
  54. package/dist/core/effective-path-target.d.ts +23 -0
  55. package/dist/core/effective-path-target.js +15 -1
  56. package/dist/core/engine-attestation.d.ts +5 -1
  57. package/dist/core/engine-attestation.js +1 -0
  58. package/dist/core/engine-capabilities.d.ts +14 -9
  59. package/dist/core/engine-capabilities.js +1 -1
  60. package/dist/core/engine-notice.d.ts +62 -32
  61. package/dist/core/engine-version.js +1 -1
  62. package/dist/core/entries-not-applied.d.ts +1 -1
  63. package/dist/core/entries-not-applied.js +1 -0
  64. package/dist/core/file-history-store.d.ts +95 -11
  65. package/dist/core/file-history-store.js +117 -19
  66. package/dist/core/gate-fold.js +13 -7
  67. package/dist/core/gate-lanes.js +9 -9
  68. package/dist/core/governance-codes.d.ts +56 -7
  69. package/dist/core/governance-codes.js +105 -7
  70. package/dist/core/grant-holder.d.ts +53 -0
  71. package/dist/core/grant-holder.js +80 -0
  72. package/dist/core/hooks.d.ts +7 -3
  73. package/dist/core/hooks.js +2 -2
  74. package/dist/core/locked-config.d.ts +7 -1
  75. package/dist/core/locked-config.js +9 -2
  76. package/dist/core/mcp-call-meta.d.ts +52 -7
  77. package/dist/core/mcp-call-meta.js +21 -2
  78. package/dist/core/mcp-host-read.d.ts +1 -1
  79. package/dist/core/mcp-server-spec.d.ts +18 -0
  80. package/dist/core/mcp-server-spec.js +1 -0
  81. package/dist/core/mcp.js +2 -2
  82. package/dist/core/member-outcome.d.ts +22 -1
  83. package/dist/core/member-outcome.js +18 -6
  84. package/dist/core/memory-engine/delegation-settlement.js +5 -5
  85. package/dist/core/memory-engine/engine.js +19 -19
  86. package/dist/core/memory-engine/file-backend.d.ts +7 -2
  87. package/dist/core/memory-engine/file-backend.js +14 -12
  88. package/dist/core/memory-engine/frontmatter.js +1 -1
  89. package/dist/core/memory-engine/index.d.ts +1 -0
  90. package/dist/core/memory-engine/index.js +1 -0
  91. package/dist/core/memory-engine/layout.d.ts +34 -9
  92. package/dist/core/memory-engine/layout.js +36 -19
  93. package/dist/core/memory-engine/memory-deployment.js +8 -8
  94. package/dist/core/memory-engine/mount-failed-notice.d.ts +8 -5
  95. package/dist/core/memory-engine/mount-failed-notice.js +5 -2
  96. package/dist/core/mode-policy.d.ts +5 -0
  97. package/dist/core/mode-policy.js +6 -0
  98. package/dist/core/mods/host.d.ts +2 -1
  99. package/dist/core/mods/host.js +7 -6
  100. package/dist/core/mods/kernel/index.d.ts +1 -1
  101. package/dist/core/mods/kernel/index.js +1 -1
  102. package/dist/core/mods/kernel/registration.d.ts +5 -2
  103. package/dist/core/mods/kernel/registration.js +19 -3
  104. package/dist/core/mods/package.d.ts +12 -1
  105. package/dist/core/mods/package.js +36 -9
  106. package/dist/core/mods/stations.d.ts +7 -1
  107. package/dist/core/mods/stations.js +17 -3
  108. package/dist/core/mods/teammate-stations.d.ts +4 -1
  109. package/dist/core/mods/teammate-stations.js +1 -1
  110. package/dist/core/native-signal.d.ts +13 -0
  111. package/dist/core/native-signal.js +18 -0
  112. package/dist/core/park-resumability.d.ts +16 -14
  113. package/dist/core/park-resumability.js +9 -4
  114. package/dist/core/path-rule-binding.js +1 -1
  115. package/dist/core/permission-rule-model.d.ts +11 -5
  116. package/dist/core/permission-rule-model.js +5 -3
  117. package/dist/core/permission-rule-org.js +1 -1
  118. package/dist/core/permission-rule-provider.d.ts +5 -1
  119. package/dist/core/permission-rule-provider.js +6 -1
  120. package/dist/core/permission-rule-session.d.ts +35 -5
  121. package/dist/core/permission-rule-session.js +32 -1
  122. package/dist/core/permission-rule-store.d.ts +5 -1
  123. package/dist/core/permission-rule-store.js +28 -5
  124. package/dist/core/permission-rules.d.ts +2 -2
  125. package/dist/core/permission-rules.js +2 -3
  126. package/dist/core/principal-name.d.ts +12 -0
  127. package/dist/core/principal-name.js +6 -2
  128. package/dist/core/read-root-grant-screen.d.ts +7 -6
  129. package/dist/core/read-root-grant-screen.js +7 -8
  130. package/dist/core/remote-env.d.ts +42 -8
  131. package/dist/core/resume-config-judge.js +1 -1
  132. package/dist/core/resume-startup-cause.d.ts +19 -4
  133. package/dist/core/resume-startup-cause.js +25 -6
  134. package/dist/core/rewind-conversation.d.ts +4 -0
  135. package/dist/core/rewrite-rejudge.d.ts +9 -1
  136. package/dist/core/rewrite-rejudge.js +11 -1
  137. package/dist/core/rule-offer-read.js +3 -2
  138. package/dist/core/runner/assemble-result.d.ts +21 -11
  139. package/dist/core/runner/assemble-result.js +24 -4
  140. package/dist/core/runner/boundary-reminders.d.ts +104 -0
  141. package/dist/core/runner/boundary-reminders.js +108 -0
  142. package/dist/core/runner/branch-writeback.d.ts +21 -7
  143. package/dist/core/runner/branch-writeback.js +44 -6
  144. package/dist/core/runner/command-sandbox-frame.js +2 -1
  145. package/dist/core/runner/compact-session.js +11 -4
  146. package/dist/core/runner/constraint-layers.d.ts +24 -5
  147. package/dist/core/runner/constraint-layers.js +21 -2
  148. package/dist/core/runner/continuation-gate.js +3 -1
  149. package/dist/core/runner/contracts.d.ts +83 -13
  150. package/dist/core/runner/cross-boundary-lane.js +2 -1
  151. package/dist/core/runner/delegation-owner.d.ts +246 -45
  152. package/dist/core/runner/delegation-owner.js +237 -63
  153. package/dist/core/runner/expire-settle.d.ts +17 -0
  154. package/dist/core/runner/expire-settle.js +8 -2
  155. package/dist/core/runner/file-history-request.d.ts +4 -3
  156. package/dist/core/runner/file-history-request.js +4 -1
  157. package/dist/core/runner/file-history-restore.d.ts +11 -3
  158. package/dist/core/runner/file-history-restore.js +11 -3
  159. package/dist/core/runner/gate-exit.d.ts +22 -1
  160. package/dist/core/runner/gate-exit.js +12 -14
  161. package/dist/core/runner/nested-memory-content.js +1 -1
  162. package/dist/core/runner/nested-memory-lane.d.ts +10 -2
  163. package/dist/core/runner/nested-memory-lane.js +29 -8
  164. package/dist/core/runner/own-model-money-door.d.ts +13 -0
  165. package/dist/core/runner/own-model-money-door.js +17 -0
  166. package/dist/core/runner/park-commit.d.ts +4 -2
  167. package/dist/core/runner/park-commit.js +2 -1
  168. package/dist/core/runner/permission-rule-lanes.d.ts +4 -0
  169. package/dist/core/runner/permission-rule-lanes.js +7 -0
  170. package/dist/core/runner/person-path-rows.js +1 -1
  171. package/dist/core/runner/placement-fence.d.ts +8 -2
  172. package/dist/core/runner/placement-fence.js +8 -3
  173. package/dist/core/runner/policy-throw.d.ts +3 -2
  174. package/dist/core/runner/policy-throw.js +2 -2
  175. package/dist/core/runner/prepare-acquire-reconcile.d.ts +23 -14
  176. package/dist/core/runner/prepare-acquire-reconcile.js +33 -15
  177. package/dist/core/runner/prepare-artifact.d.ts +14 -1
  178. package/dist/core/runner/prepare-artifact.js +7 -2
  179. package/dist/core/runner/prepare-ask-lane.d.ts +8 -0
  180. package/dist/core/runner/prepare-ask-lane.js +14 -5
  181. package/dist/core/runner/prepare-boundary-parks.js +5 -4
  182. package/dist/core/runner/prepare-config-doors.d.ts +9 -4
  183. package/dist/core/runner/prepare-config-doors.js +25 -8
  184. package/dist/core/runner/prepare-defer-classify.d.ts +8 -4
  185. package/dist/core/runner/prepare-defer-classify.js +6 -6
  186. package/dist/core/runner/prepare-execution-env.d.ts +4 -1
  187. package/dist/core/runner/prepare-execution-env.js +8 -3
  188. package/dist/core/runner/prepare-file-history.d.ts +26 -0
  189. package/dist/core/runner/prepare-file-history.js +15 -1
  190. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -3
  191. package/dist/core/runner/prepare-inherited-gate.js +9 -2
  192. package/dist/core/runner/prepare-leg-adoption.d.ts +2 -2
  193. package/dist/core/runner/prepare-park-ask.js +8 -5
  194. package/dist/core/runner/prepare-policy-chain.d.ts +5 -0
  195. package/dist/core/runner/prepare-policy-chain.js +18 -7
  196. package/dist/core/runner/prepare-prompt-assembly.d.ts +3 -0
  197. package/dist/core/runner/prepare-prompt-assembly.js +4 -3
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -1
  199. package/dist/core/runner/prepare-suspend-saga.js +19 -5
  200. package/dist/core/runner/prepare-task.d.ts +2 -5
  201. package/dist/core/runner/prepare-task.js +71 -26
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -5
  203. package/dist/core/runner/prepare-workspace-restore.js +59 -28
  204. package/dist/core/runner/read-root-grant.d.ts +1 -0
  205. package/dist/core/runner/read-root-grant.js +1 -2
  206. package/dist/core/runner/resume-admission.d.ts +3 -0
  207. package/dist/core/runner/resume-admission.js +6 -4
  208. package/dist/core/runner/resume-apply.js +7 -5
  209. package/dist/core/runner/resume-claim.d.ts +2 -2
  210. package/dist/core/runner/resume-claim.js +4 -4
  211. package/dist/core/runner/resume-policy-outcome.d.ts +1 -1
  212. package/dist/core/runner/resume-policy-outcome.js +6 -4
  213. package/dist/core/runner/resume-preflight.d.ts +3 -0
  214. package/dist/core/runner/resume-preflight.js +10 -3
  215. package/dist/core/runner/rewind-conversation.js +11 -4
  216. package/dist/core/runner/rewind-files.js +29 -14
  217. package/dist/core/runner/rewind-outcome.d.ts +27 -0
  218. package/dist/core/runner/rewind-outcome.js +14 -0
  219. package/dist/core/runner/run-attachment-seats.js +2 -1
  220. package/dist/core/runner/run-clock-and-content.js +2 -0
  221. package/dist/core/runner/run-identity-wiring.js +2 -0
  222. package/dist/core/runner/run-leg.js +11 -1
  223. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  224. package/dist/core/runner/run-notification-lane.js +2 -2
  225. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -2
  226. package/dist/core/runner/run-settle-and-teardown.js +52 -40
  227. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  228. package/dist/core/runner/run-stop-and-final-verify.js +5 -4
  229. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  230. package/dist/core/runner/run-terminal-adoption.js +3 -3
  231. package/dist/core/runner/run-turn-boundary.js +7 -0
  232. package/dist/core/runner/runtask.d.ts +7 -4
  233. package/dist/core/runner/runtask.js +18 -9
  234. package/dist/core/runner/session-call-grant-station.d.ts +64 -0
  235. package/dist/core/runner/session-call-grant-station.js +119 -0
  236. package/dist/core/runner/session-file-state-replay.js +2 -2
  237. package/dist/core/runner/session-prompt-seats.d.ts +95 -0
  238. package/dist/core/runner/session-prompt-seats.js +62 -0
  239. package/dist/core/runner/session-rule-policy.js +1 -1
  240. package/dist/core/runner/session-write-ledger.d.ts +8 -0
  241. package/dist/core/runner/session-write-ledger.js +16 -0
  242. package/dist/core/runner/side-call-account.js +5 -1
  243. package/dist/core/runner/stop-tail-notice.d.ts +7 -0
  244. package/dist/core/runner/stop-tail-notice.js +23 -8
  245. package/dist/core/runner/stream-reap.js +4 -2
  246. package/dist/core/runner/stream-settle-backstop.d.ts +1 -1
  247. package/dist/core/runner/stream-settle-backstop.js +17 -18
  248. package/dist/core/runner/terminal-account.js +17 -8
  249. package/dist/core/runner/terminal-projection.d.ts +3 -2
  250. package/dist/core/runner/terminal-projection.js +1 -1
  251. package/dist/core/runner/tool-turn-repair-seat.d.ts +2 -2
  252. package/dist/core/runner/tool-turn-repair-seat.js +12 -7
  253. package/dist/core/runner/turn-attachments.d.ts +22 -1
  254. package/dist/core/runner/turn-attachments.js +20 -3
  255. package/dist/core/runner-deps.d.ts +6 -2
  256. package/dist/core/secret-env.d.ts +26 -6
  257. package/dist/core/secret-env.js +6 -6
  258. package/dist/core/session-call-grant-screen.d.ts +58 -0
  259. package/dist/core/session-call-grant-screen.js +18 -0
  260. package/dist/core/session-call-grant.d.ts +93 -0
  261. package/dist/core/session-call-grant.js +524 -0
  262. package/dist/core/session-checkout.d.ts +3 -0
  263. package/dist/core/session-checkout.js +8 -3
  264. package/dist/core/session-policy-store.d.ts +14 -0
  265. package/dist/core/session-policy-store.js +16 -2
  266. package/dist/core/session-store.d.ts +18 -1
  267. package/dist/core/session-store.js +20 -4
  268. package/dist/core/session.d.ts +36 -4
  269. package/dist/core/shared-artifact-reads.d.ts +93 -0
  270. package/dist/core/shared-artifact-reads.js +94 -0
  271. package/dist/core/skill-grant.js +1 -1
  272. package/dist/core/skills-directory.d.ts +9 -45
  273. package/dist/core/skills-directory.js +9 -722
  274. package/dist/core/spend-account.js +3 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +22 -4
  276. package/dist/core/store-contracts/checkpoint-store-contract.js +363 -29
  277. package/dist/core/store-contracts/file-history-store-contract.d.ts +11 -3
  278. package/dist/core/store-contracts/file-history-store-contract.js +62 -2
  279. package/dist/core/store-contracts/grant-fixture.d.ts +52 -0
  280. package/dist/core/store-contracts/grant-fixture.js +84 -0
  281. package/dist/core/store-contracts/session-repo-contract.js +18 -0
  282. package/dist/core/store-contracts/session-store-contract.d.ts +15 -1
  283. package/dist/core/store-contracts/session-store-contract.js +211 -2
  284. package/dist/core/store-contracts/workflow-journal-store-contract.js +47 -8
  285. package/dist/core/suspend-lane-reasons.d.ts +13 -0
  286. package/dist/core/suspend-lane-reasons.js +5 -0
  287. package/dist/core/synthetic-read-verdict.d.ts +5 -3
  288. package/dist/core/synthetic-read-verdict.js +1 -1
  289. package/dist/core/task-limits.d.ts +15 -0
  290. package/dist/core/task-notification.d.ts +33 -7
  291. package/dist/core/task-notification.js +34 -9
  292. package/dist/core/task-registry-agent.d.ts +1 -1
  293. package/dist/core/task-registry-agent.js +18 -7
  294. package/dist/core/task-registry-shared.d.ts +29 -4
  295. package/dist/core/task-registry-shared.js +7 -0
  296. package/dist/core/task-registry.d.ts +21 -1
  297. package/dist/core/task-registry.js +36 -9
  298. package/dist/core/task-result.d.ts +55 -1
  299. package/dist/core/task-spec.d.ts +17 -3
  300. package/dist/core/terminal-cause.d.ts +68 -5
  301. package/dist/core/tool-catalog-entries.js +1 -1
  302. package/dist/core/tool-check-reading.js +2 -1
  303. package/dist/core/tool-errors.js +1 -0
  304. package/dist/core/tool-list-grammar.d.ts +0 -47
  305. package/dist/core/tool-list-grammar.js +1 -75
  306. package/dist/core/tool-model-gate.d.ts +7 -11
  307. package/dist/core/tool-model-gate.js +5 -8
  308. package/dist/core/tool-name-aliases.js +2 -3
  309. package/dist/core/tool-name-readings.d.ts +4 -0
  310. package/dist/core/tool-name-readings.js +1 -0
  311. package/dist/core/tool-policy.d.ts +46 -4
  312. package/dist/core/tool-policy.js +47 -18
  313. package/dist/core/tool-result-store.d.ts +0 -24
  314. package/dist/core/tool-result-store.js +1 -36
  315. package/dist/core/tool-spec.d.ts +8 -4
  316. package/dist/core/untrusted-egress.js +2 -2
  317. package/dist/core/untrusted-text.d.ts +8 -0
  318. package/dist/core/untrusted-text.js +14 -0
  319. package/dist/core/user-attachment.d.ts +16 -1
  320. package/dist/core/user-attachment.js +42 -18
  321. package/dist/core/wiring-manifest.d.ts +4 -9
  322. package/dist/core/wiring-manifest.js +1 -1
  323. package/dist/core/workflow-journal-store.d.ts +55 -8
  324. package/dist/core/workflow-journal-store.js +34 -10
  325. package/dist/core/workflow-run-store-contract.js +56 -1
  326. package/dist/core/workflow-run-store.d.ts +43 -19
  327. package/dist/core/workflow-run-store.js +17 -2
  328. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  329. package/dist/engine/execution-env/node-execution-env.js +4 -0
  330. package/dist/engine/harness/agent-harness.d.ts +10 -5
  331. package/dist/engine/harness/agent-harness.js +12 -4
  332. package/dist/engine/harness/types.d.ts +18 -0
  333. package/dist/engine/llm/tool-turns.d.ts +1 -1
  334. package/dist/engine/llm/types.d.ts +5 -4
  335. package/dist/engine/session/memory-repo.d.ts +15 -3
  336. package/dist/engine/session/memory-repo.js +21 -3
  337. package/dist/engine/session/memory-storage.d.ts +5 -0
  338. package/dist/engine/session/memory-storage.js +8 -3
  339. package/dist/engine/session/repo-utils.d.ts +9 -0
  340. package/dist/engine/session/repo-utils.js +14 -0
  341. package/dist/engine/session/storage-base.d.ts +20 -7
  342. package/dist/engine/session/storage-base.js +13 -1
  343. package/dist/index.d.ts +37 -19
  344. package/dist/index.js +30 -15
  345. package/dist/internal/harness.d.ts +1 -1
  346. package/dist/internal/harness.js +1 -1
  347. package/dist/orchestration/run-workflow-tool.d.ts +13 -1
  348. package/dist/orchestration/run-workflow-tool.js +101 -32
  349. package/dist/orchestration/workflow-park-adoption.d.ts +309 -92
  350. package/dist/orchestration/workflow-park-adoption.js +588 -323
  351. package/dist/orchestration/workflow-tree-id.d.ts +66 -0
  352. package/dist/orchestration/workflow-tree-id.js +66 -0
  353. package/dist/orchestration/workflow-types.d.ts +90 -11
  354. package/dist/orchestration/workflow-types.js +10 -1
  355. package/dist/orchestration/workflow.d.ts +30 -4
  356. package/dist/orchestration/workflow.js +424 -114
  357. package/dist/prompt-assembly/catalog/constitution.js +5 -1
  358. package/dist/prompt-assembly/catalog/core-behavior.d.ts +3 -4
  359. package/dist/prompt-assembly/catalog/core-behavior.js +61 -22
  360. package/dist/prompt-assembly/catalog/environment.js +2 -2
  361. package/dist/prompt-assembly/catalog/events.d.ts +16 -0
  362. package/dist/prompt-assembly/catalog/events.js +2 -0
  363. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +72 -44
  364. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +2 -2
  365. package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +2 -0
  366. package/dist/prompt-assembly/catalog/schema.d.ts +5 -1
  367. package/dist/prompt-assembly/catalog/schema.js +2 -0
  368. package/dist/prompt-assembly/catalog/sections.js +3 -14
  369. package/dist/prompt-assembly/event-registry.js +2 -0
  370. package/dist/prompt-assembly/select.js +1 -0
  371. package/dist/prompt-assembly/tool-catalog.d.ts +10 -7
  372. package/dist/prompt-assembly/tool-catalog.js +21 -7
  373. package/dist/prompt-assembly/types.d.ts +3 -0
  374. package/dist/prompts/default.d.ts +4 -1
  375. package/dist/prompts/default.js +6 -0
  376. package/dist/stores/file/checkpoint-store.d.ts +11 -10
  377. package/dist/stores/file/checkpoint-store.js +36 -10
  378. package/dist/stores/file/file-history-store.d.ts +6 -0
  379. package/dist/stores/file/file-history-store.js +21 -4
  380. package/dist/stores/file/fs-atomic.d.ts +1 -1
  381. package/dist/stores/file/index.d.ts +14 -4
  382. package/dist/stores/file/index.js +21 -5
  383. package/dist/stores/file/process-anchor.d.ts +9 -1
  384. package/dist/stores/file/session-policy-store.js +2 -17
  385. package/dist/stores/file/session-store.d.ts +27 -0
  386. package/dist/stores/file/session-store.js +81 -9
  387. package/dist/stores/file/workflow-journal-store.d.ts +14 -4
  388. package/dist/stores/file/workflow-journal-store.js +32 -24
  389. package/dist/stores/file/workflow-run-store.d.ts +15 -4
  390. package/dist/stores/file/workflow-run-store.js +76 -0
  391. package/dist/tools/artifact/artifact-tool.d.ts +10 -3
  392. package/dist/tools/artifact/artifact-tool.js +16 -1
  393. package/dist/tools/fs/bash-program-position.d.ts +10 -4
  394. package/dist/tools/fs/bash-program-position.js +11 -8
  395. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -1
  396. package/dist/tools/fs/bash-readonly-classifier.js +9 -2
  397. package/dist/tools/fs/find-actions.d.ts +30 -16
  398. package/dist/tools/fs/find-actions.js +272 -19
  399. package/dist/tools/fs/fs-bash.js +8 -5
  400. package/dist/tools/fs/fs-shared.d.ts +0 -29
  401. package/dist/tools/fs/fs-shared.js +0 -5
  402. package/dist/tools/fs/fs-write.js +2 -1
  403. package/dist/tools/fs/read-deny.d.ts +6 -1
  404. package/dist/tools/fs/read-deny.js +6 -1
  405. package/dist/tools/fs/read-floor.d.ts +6 -0
  406. package/dist/tools/fs/read-floor.js +5 -1
  407. package/dist/tools/fs/removal-actions.d.ts +43 -0
  408. package/dist/tools/fs/removal-actions.js +25 -0
  409. package/dist/tools/fs/removal-targets.d.ts +2 -21
  410. package/dist/tools/fs/removal-targets.js +2 -3
  411. package/dist/tools/fs/safety.d.ts +37 -1
  412. package/dist/tools/fs/safety.js +52 -0
  413. package/dist/tools/fs/shell-climb.d.ts +46 -0
  414. package/dist/tools/fs/shell-climb.js +79 -0
  415. package/dist/tools/fs/shell-read-check.js +47 -19
  416. package/dist/tools/fs/shell-read-establish.js +36 -22
  417. package/dist/tools/fs/shell-read-judge.d.ts +10 -2
  418. package/dist/tools/fs/shell-read-judge.js +4 -4
  419. package/dist/tools/fs/shell-read-plan.d.ts +3 -0
  420. package/dist/tools/fs/shell-read-plan.js +1 -1
  421. package/dist/tools/fs/shell-read-workdir.js +3 -2
  422. package/dist/tools/fs/shell-read-write-targets.d.ts +4 -3
  423. package/dist/tools/fs/shell-read-write-targets.js +3 -0
  424. package/package.json +2 -2
  425. package/test/export-surface.snapshot.json +169 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core@7.71.0.json +5827 -0
  428. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  429. package/wire-changes/primitives@7.71.0.json +473 -0
  430. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  431. package/dist/core/frontmatter-fence.d.ts +0 -10
  432. package/dist/core/frontmatter-fence.js +0 -6
  433. package/dist/core/permission-rule-syntax.d.ts +0 -46
  434. package/dist/core/permission-rule-syntax.js +0 -52
@@ -8,8 +8,10 @@ import type { ModParticipant } from "./dispatch.js";
8
8
  import type { ModEventPayload, ModFailureCause, ModMatcher, ModSkip } from "./site-rules.js";
9
9
  /** The configuration refusal: a registration the kernel cannot take refuses the whole prepare. */
10
10
  export declare const MODS_INVALID_CODE = "config.mods_invalid";
11
- /** The notice an admission refusal becomes (the run goes on without the refused registration). */
11
+ /** The notice an admission refusal of a task-seat registration becomes (the run goes on without the refused registration). */
12
12
  export declare const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
13
+ /** The notice an admission refusal of a deployment-seat registration becomes: the same fact, the operator's. */
14
+ export declare const MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE = "mods.registration_refused_deployment";
13
15
  /** What a registration declares it will touch — the upper bound the kernel holds it to. */
14
16
  export interface ModUses {
15
17
  /** Events it hangs handlers on (names or `<prefix>.*`, of its bus's side). */
@@ -127,7 +129,8 @@ export interface ModRegistration<D extends ModDollarBase = ModDollarBase> {
127
129
  /** Deployment seat: required. Task seat: absent or `user`. */
128
130
  readonly tier?: ModRegistrationTier;
129
131
  readonly uses: ModUses;
130
- /** The host's provenance label, handed to admission as given. */
132
+ /** The host's provenance label, handed to admission as given: one line of 1 to 256 characters, with no control character or
133
+ * line break — any other value refuses the prepare (`config.mods_invalid`), never cut or cleaned. */
131
134
  readonly provenance?: string;
132
135
  /** Each handler's own time; default 10 000 ms. */
133
136
  readonly budgetMs?: number;
@@ -2,6 +2,7 @@ import { describe, expandOnSide, envReach, MOD_SEATS, SEAT_TIER_TABLE, } from ".
2
2
  import { resolveModBudgetMs } from "./budget.js";
3
3
  export const MODS_INVALID_CODE = "config.mods_invalid";
4
4
  export const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
5
+ export const MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE = "mods.registration_refused_deployment";
5
6
  export const ENGINE_ORIGIN = Object.freeze({ plugin: "engine", tier: "core" });
6
7
  export const MOD_REGISTRATION_NAME = /^[A-Za-z0-9._:-]{1,64}$/;
7
8
  export function namedRegistration(registration) {
@@ -81,8 +82,9 @@ function screenOne(item, seat, side, report) {
81
82
  throw modsInvalid(`a ${seat} registration is named "${name}", the engine's own origin word — choose another name`);
82
83
  const tier = tierOf(item.tier, seat, name);
83
84
  const uses = usesOf(item.uses, name);
84
- if (item.provenance !== undefined && typeof item.provenance !== "string")
85
- throw modsInvalid(`${name}: provenance is ${describe(item.provenance)}; it is a label (a string)`);
85
+ const provenance = item.provenance;
86
+ if (provenance !== undefined)
87
+ refuseProvenance(provenance, name);
86
88
  const eventsBound = new Set();
87
89
  for (const p of uses.events)
88
90
  for (const n of namesOf(p, name, "uses.events", side))
@@ -98,11 +100,25 @@ function screenOne(item, seat, side, report) {
98
100
  tier,
99
101
  budgetMs: resolveModBudgetMs(item.budgetMs, report, name),
100
102
  uses,
101
- ...(item.provenance !== undefined ? { provenance: item.provenance } : {}),
103
+ ...(provenance !== undefined ? { provenance: provenance } : {}),
102
104
  eventsBound,
103
105
  callsBound,
104
106
  };
105
107
  }
108
+ const MOD_PROVENANCE_MAX = 256;
109
+ const NOT_ONE_LINE = /[\p{Cc}\p{Zl}\p{Zp}]/u;
110
+ function refuseProvenance(provenance, name) {
111
+ if (typeof provenance !== "string")
112
+ throw modsInvalid(`${name}: provenance is ${describe(provenance)}; it is a label (a string)`);
113
+ const length = [...provenance].length;
114
+ const form = `a provenance label is one line of 1 to ${MOD_PROVENANCE_MAX} characters, with no control character or line break`;
115
+ if (NOT_ONE_LINE.test(provenance))
116
+ throw modsInvalid(`${name}: provenance (${length} characters) holds a control character or a line break; ${form}`);
117
+ if (length === 0)
118
+ throw modsInvalid(`${name}: provenance is empty; ${form} (leave it out to give none)`);
119
+ if (length > MOD_PROVENANCE_MAX)
120
+ throw modsInvalid(`${name}: provenance is ${length} characters long; ${form}`);
121
+ }
106
122
  function tierOf(declared, seat, name) {
107
123
  const row = SEAT_TIER_TABLE[seat];
108
124
  const allowed = row.tiers;
@@ -4,11 +4,19 @@ import type { EngineModRegistration } from "./classic-events.js";
4
4
  export interface ModPackageHost {
5
5
  /** The tier the host seats it in (a deployment seat requires one; the task seat takes `user` or none). */
6
6
  readonly tier?: ModRegistrationTier;
7
- /** The host's provenance label, handed to admission and carried on the admission record as given. */
7
+ /** The host's provenance label, handed to admission and carried on the admission record as given (its form is the kernel's). */
8
8
  readonly provenance?: string;
9
9
  /** The values handed to the package's `register(on, options)`. */
10
10
  readonly options?: unknown;
11
11
  }
12
+ /** A member of `plugin.json` or `hooks.json` this reader does not read: the package loaded without it. */
13
+ export interface ModPackageUnreadKey {
14
+ /** The file it stands in, relative to the package (`.claude-plugin/plugin.json` or `hooks/hooks.json`, in the platform's separator). */
15
+ readonly file: string;
16
+ /** The member's name, spelled as a foreign line: one line, the name whole up to 60 characters (a longer one: its first 60
17
+ * and the cut mark; the fence's defusing of a sentinel such as `<<<` may lengthen what is kept). Never its value. */
18
+ readonly key: string;
19
+ }
12
20
  /** A package read into a registration, with the identity of the bytes it was read from. */
13
21
  export interface ModPackageRegistration extends EngineModRegistration {
14
22
  /**
@@ -18,6 +26,9 @@ export interface ModPackageRegistration extends EngineModRegistration {
18
26
  * absolute URL, a file it reads) is not among them.
19
27
  */
20
28
  readonly digest: string;
29
+ /** The members of the two files this reader does not read (`plugin.json`'s first, each in its parsed object's key order),
30
+ * each also told as a `mods.package_key_unread` notice. Present iff there is one. */
31
+ readonly unread?: readonly ModPackageUnreadKey[];
21
32
  }
22
33
  /** Read the package at `dir` into a registration the host seats in `RunnerDeps.mods` or `TaskSpec.mods`. */
23
34
  export declare function loadModPackage(dir: string, host?: ModPackageHost): Promise<ModPackageRegistration>;
@@ -7,10 +7,20 @@ import { modsInvalid } from "./kernel/registration.js";
7
7
  import { physicalPathOfAsync } from "../physical-path.js";
8
8
  import { describeThrown } from "../tool-policy.js";
9
9
  import { foreignLine } from "../protocol-http-auth.js";
10
+ import { deliverEngineNotice } from "../engine-notice.js";
11
+ import { callerKey } from "../caller-text.js";
10
12
  const PLUGIN_FILE = join(".claude-plugin", "plugin.json");
11
13
  const HOOKS_FILE = join("hooks", "hooks.json");
12
- const PLUGIN_KEYS = ["name", "version", "description", "author"];
13
- const HOOKS_KEYS = ["modules", "contract", "uses", "description"];
14
+ const HOST_FACT = "which is the host's to give (the seat, tier, provenance, options and budget are never read from a package)";
15
+ const HOST_FACTS = { tier: HOST_FACT, provenance: HOST_FACT, seat: HOST_FACT, options: HOST_FACT, budgetMs: HOST_FACT };
16
+ const PLUGIN_SHAPE = { file: PLUGIN_FILE, takes: ["name", "version", "description", "author"], refuses: HOST_FACTS };
17
+ const HOOKS_SHAPE = {
18
+ file: HOOKS_FILE,
19
+ takes: ["modules", "contract", "uses", "description"],
20
+ refuses: { ...HOST_FACTS, surface: "which names a surface module: a surface module is mounted by the client that renders it, never by this engine" },
21
+ };
22
+ const KEY_SPELLING_MAX = 60;
23
+ const ROOT_SPELLING_MAX = 1024;
14
24
  const MODULE_EXTENSION = ".mjs";
15
25
  const MODULE_URL_HEAD = "data:text/javascript;base64,";
16
26
  const MODULE_URL_TEXT = /data:text\/javascript;base64,[A-Za-z0-9+/=]*/g;
@@ -18,9 +28,10 @@ export async function loadModPackage(dir, host = {}) {
18
28
  const root = await realRoot(dir);
19
29
  const refuse = (file, why) => modsInvalid(`mod package ${root}: ${file}: ${why}`);
20
30
  const pluginFile = await packageFile(root, PLUGIN_FILE, refuse);
21
- const plugin = jsonRecord(pluginFile.bytes, PLUGIN_FILE, PLUGIN_KEYS, refuse);
31
+ const unread = [];
32
+ const plugin = jsonRecord(pluginFile.bytes, PLUGIN_SHAPE, refuse, unread);
22
33
  const hooksFile = await packageFile(root, HOOKS_FILE, refuse);
23
- const hooks = jsonRecord(hooksFile.bytes, HOOKS_FILE, HOOKS_KEYS, refuse);
34
+ const hooks = jsonRecord(hooksFile.bytes, HOOKS_SHAPE, refuse, unread);
24
35
  const contract = hooks["contract"];
25
36
  if (contract !== KERNEL_CONTRACT_VERSION) {
26
37
  throw refuse(HOOKS_FILE, `contract is ${kind(contract)}; this engine's mods kernel is contract ${KERNEL_CONTRACT_VERSION}, and a package loads only under the contract it was written against`);
@@ -44,7 +55,7 @@ export async function loadModPackage(dir, host = {}) {
44
55
  const said = describeThrown(err).replace(MODULE_URL_TEXT, moduleFile.inside);
45
56
  throw refuse(moduleFile.inside, `could not be imported (${said}); a hooks module is imported from its own bytes, so it is one self-contained file: a relative or package import has nothing to resolve from`);
46
57
  }
47
- return Object.freeze({
58
+ const registration = Object.freeze({
48
59
  name: plugin["name"],
49
60
  uses: hooks["uses"],
50
61
  ...(host.tier !== undefined ? { tier: host.tier } : {}),
@@ -52,7 +63,17 @@ export async function loadModPackage(dir, host = {}) {
52
63
  ...(host.options !== undefined ? { options: host.options } : {}),
53
64
  register: (typeof ns === "object" && ns !== null ? Reflect.get(ns, "register") : undefined),
54
65
  digest,
66
+ ...(unread.length > 0 ? { unread: Object.freeze(unread.map((u) => Object.freeze({ file: u.file, key: u.key }))) } : {}),
55
67
  });
68
+ const shownRoot = foreignLine(root, ROOT_SPELLING_MAX);
69
+ for (const u of unread) {
70
+ deliverEngineNotice(undefined, {
71
+ code: "mods.package_key_unread",
72
+ message: `mod package ${shownRoot}: ${u.file} carries the member ${callerKey(u.name)}, which this engine's mod package reader does not read; the package is loaded without it`,
73
+ detail: { package: root, file: u.file, key: u.key },
74
+ });
75
+ }
76
+ return registration;
56
77
  }
57
78
  async function realRoot(dir) {
58
79
  try {
@@ -89,7 +110,8 @@ async function packageFile(root, file, refuse) {
89
110
  await handle?.close();
90
111
  }
91
112
  }
92
- function jsonRecord(bytes, file, keys, refuse) {
113
+ function jsonRecord(bytes, shape, refuse, unread) {
114
+ const { file, takes, refuses } = shape;
93
115
  let parsed;
94
116
  try {
95
117
  parsed = JSON.parse(bytes.toString("utf8"));
@@ -99,9 +121,14 @@ function jsonRecord(bytes, file, keys, refuse) {
99
121
  }
100
122
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
101
123
  throw refuse(file, `is ${kind(parsed)}; it is a JSON object`);
102
- const extra = Object.keys(parsed).find((k) => !keys.includes(k));
103
- if (extra !== undefined)
104
- throw refuse(file, `carries "${foreignLine(extra, 60)}", which a mod package does not state here (it takes ${keys.join(", ")})`);
124
+ for (const k of Object.keys(parsed)) {
125
+ if (takes.includes(k))
126
+ continue;
127
+ const why = Object.hasOwn(refuses, k) ? refuses[k] : undefined;
128
+ if (why !== undefined)
129
+ throw refuse(file, `carries ${callerKey(k)}, ${why}`);
130
+ unread.push({ file, key: foreignLine(k, KEY_SPELLING_MAX), name: k });
131
+ }
105
132
  return parsed;
106
133
  }
107
134
  function sha256(data) {
@@ -21,6 +21,7 @@ import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult,
21
21
  import { type LegModSeats } from "./host.js";
22
22
  export { listLegModSeats, type LegModSeats } from "./host.js";
23
23
  import { type SkillScopes } from "./spec-seats.js";
24
+ import { type DelegationOwnerSeat } from "../runner/delegation-owner.js";
24
25
  /**
25
26
  * What the engine's core answers at the bottom of every classic chain: the engine itself has nothing to add.
26
27
  * Frozen and empty, so it reads as "no opinion" in every classic station's answer form, and a handler that
@@ -429,7 +430,8 @@ export interface LegMods {
429
430
  /**
430
431
  * Admit the leg's bus: both seats (`RunnerDeps.mods`, `TaskSpec.mods`), screened and put to `plugin.register`.
431
432
  * Called once per leg, at that leg's own prepare (a delegated child and a resumed leg each admit their own);
432
- * each refused registration becomes one `mods.registration_refused` notice. Throws `config.mods_invalid` for a
433
+ * each refused registration becomes one notice (`mods.registration_refused` for the task seat, `mods.registration_refused_deployment`
434
+ * for the deployment seat). Throws `config.mods_invalid` for a
433
435
  * registration the kernel cannot take.
434
436
  */
435
437
  export declare function admitLegMods(input: {
@@ -503,6 +505,10 @@ export interface LegFacadeInput {
503
505
  export interface AgentSessionsSeat {
504
506
  readonly registry: Pick<TaskRegistry, "anchoredSession">;
505
507
  readonly access: TaskAccess;
508
+ /** The leg's own tree-owner seat: a subagent's session is read only once the one row judge holds for it (absent = the leg holds none). */
509
+ readonly owner?: DelegationOwnerSeat;
510
+ /** The leg's stop: the judge's read ends with it (absent = the read is ended only by its bound). */
511
+ readonly signal?: AbortSignal;
506
512
  }
507
513
  /** The engine facade's seats over a prepared leg — each one a seat the leg already has (no new capability). */
508
514
  export declare function legFacadeSeats(input: LegFacadeInput): LegFacadeSeats;
@@ -21,6 +21,7 @@ export { listLegModSeats } from "./host.js";
21
21
  import { scopedLegBus, skillScopeRecord, standingBus } from "./spec-seats.js";
22
22
  import { modelLaneBrainOf } from "../runner/model-lane-seat.js";
23
23
  import { observingBrain } from "../runner/prefix-ledger.js";
24
+ import { judgeRowForSeat, readJudgedRow } from "../runner/delegation-owner.js";
24
25
  export const ENGINE_CORE_ANSWER = Object.freeze({});
25
26
  export function engineCore() {
26
27
  return ENGINE_CORE_ANSWER;
@@ -639,14 +640,27 @@ async function agentRowsOf(seat, agentId) {
639
640
  const store = anchor.store;
640
641
  if (store === undefined)
641
642
  throw refused("its session was bound without the store that holds it");
642
- let branch;
643
+ const notOurs = () => refused("its row names no session — not a subagent's row, or its session is not bound yet or was released");
644
+ const verdict = await judgeRowForSeat(store, { sessionId: anchor.sessionId }, seat.owner, seat.signal);
645
+ if (!verdict.open && verdict.kind === "store")
646
+ throw Object.assign(refused(`its session could not be judged for this conversation — ${verdict.why}`), { code: verdict.code });
647
+ if (!verdict.open)
648
+ throw notOurs();
649
+ let read;
643
650
  try {
644
- branch = await (await store.acquire(anchor.sessionId, { requireExisting: true })).session.getBranch();
651
+ read = await readJudgedRow(store, anchor.sessionId, verdict, (held) => held.session.getBranch(), seat.signal);
645
652
  }
646
653
  catch (err) {
654
+ if (seat.signal?.aborted === true)
655
+ throw err;
647
656
  throw refused(`its session could not be read (${describeThrown(err)})`);
648
657
  }
649
- return branch.flatMap((e) => (e.type === "message" ? [e.message] : []));
658
+ if ("refused" in read) {
659
+ if (read.refused.kind === "store")
660
+ throw Object.assign(refused(`its session could not be judged for this conversation — ${read.refused.why}`), { code: read.refused.code });
661
+ throw notOurs();
662
+ }
663
+ return read.read.flatMap((e) => (e.type === "message" ? [e.message] : []));
650
664
  }
651
665
  const NO_REQUEST_RUNNING = Object.freeze({ kind: "none" });
652
666
  function replyText(reply) {
@@ -31,7 +31,10 @@ export interface StopFamilyVerdict {
31
31
  export declare function judgeStopFamily<K extends StopFamilyEvent>(bus: LegModBus, event: K, e: ClassicEventMap[K]["e"], signal: AbortSignal | undefined, report: (err: Error) => void): Promise<StopFamilyVerdict | "aborted">;
32
32
  /** The word a stop-family event's texts name it by: the two stop events speak as `Stop` (CC's own stop feedback). */
33
33
  export declare function stopFamilyWord(event: StopFamilyEvent): string;
34
- /** The model-readable text of a `block` (a push-back's reason, a task tool's refusal). */
34
+ /** The model-readable text of a `block` (a push-back's reason, a task tool's refusal): the reference's one form for the
35
+ * four events, `<event> hook feedback:` and the reason on the next line (`a$r` / `DOo`, cli321.js B[10650520,10650646)),
36
+ * the reason's `<` written `&lt;` as the reference writes it there (#5315, measured on the reference's own binary; `>` stays), so a
37
+ * reason cannot open or close a tag in the frame it rides. */
35
38
  export declare function stopFamilyBlockText(event: StopFamilyEvent, reason: string): string;
36
39
  /** The model-readable text of an `additionalContext` fed back at a stop point. */
37
40
  export declare function stopFamilyContextText(event: StopFamilyEvent, context: string): string;
@@ -36,7 +36,7 @@ export function stopFamilyWord(event) {
36
36
  return event === "classic.Stop" || event === "classic.SubagentStop" ? "Stop" : event.slice("classic.".length);
37
37
  }
38
38
  export function stopFamilyBlockText(event, reason) {
39
- return `${stopFamilyWord(event)} hook stopped continuation: ${reason}`;
39
+ return `${stopFamilyWord(event)} hook feedback:\n${reason.replaceAll("<", "&lt;")}`;
40
40
  }
41
41
  export function stopFamilyContextText(event, context) {
42
42
  return `${stopFamilyWord(event)} hook additional context: ${context}`;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The engine reads a host's abort signal STRUCTURALLY — `aborted`, `reason`, and the `abort` event — while
3
+ * `AbortSignal.any` takes Node's own class alone (it brand-checks). A host's signal reaches an engine composition only
4
+ * through this one follower: Node's own signal is returned as it is; any other is followed by an engine-minted native
5
+ * one, aborted with the host's `reason` (at once when the host's signal is already aborted). The follower acts on the
6
+ * host's `aborted`, not on the event alone: an `abort` event dispatched on a signal that still reads `aborted: false`
7
+ * aborts nothing (as on Node's own signal) and the listener stays. The listener comes off at the first genuine abort or
8
+ * at `release`; `release` does nothing for a native signal or one that was already aborted.
9
+ */
10
+ export declare function nativeSignalOf(signal: Pick<AbortSignal, "aborted" | "reason" | "addEventListener" | "removeEventListener">): {
11
+ readonly signal: AbortSignal;
12
+ release(): void;
13
+ };
@@ -0,0 +1,18 @@
1
+ export function nativeSignalOf(signal) {
2
+ if (signal instanceof AbortSignal)
3
+ return { signal, release: () => undefined };
4
+ const ctl = new AbortController();
5
+ if (signal.aborted) {
6
+ ctl.abort(signal.reason);
7
+ return { signal: ctl.signal, release: () => undefined };
8
+ }
9
+ const release = () => signal.removeEventListener("abort", follow);
10
+ function follow() {
11
+ if (!signal.aborted)
12
+ return;
13
+ release();
14
+ ctl.abort(signal.reason);
15
+ }
16
+ signal.addEventListener("abort", follow);
17
+ return { signal: ctl.signal, release };
18
+ }
@@ -1,8 +1,3 @@
1
- /**
2
- * Can a park of this leg be resumed? — the one leg fact a park reads before it is minted, and the two sentences every refusal
3
- * of such a leg shares. A park (a durable checkpoint row a decision or a limit waits on) is minted only on a leg someone resumes;
4
- * the driver derives the fact once per leg ({@link approvalParkNotResumableOf}) and every park arm reads it by name.
5
- */
6
1
  /** Who says a leg's parks cannot be resumed — the closed set of {@link approvalParkNotResumableOf}'s two sources. `lane`: the leg was
7
2
  * started in this run by an engine lane that holds no resume seat for it, so NO park of it (a decision or a resource one) can be
8
3
  * resumed; `host`: the host declared its decision parks cannot be resumed (`TaskSpec.durableApproval: false`) — its resource parks can. */
@@ -11,6 +6,11 @@ export type ApprovalParkNotResumable = "lane" | "host";
11
6
  * leg was started with (never a row's seed): the park fact below reads it, and so does the leg's kind (a lane's leg is no root —
12
7
  * `wiringLegKindOf`, the wiring manifest's `leg` and the reading of who takes the deployment's start word). */
13
8
  export declare function engineLaneLegOf(internals: Pick<import("./runner/contracts.js").RunInternals, "isDelegatedChild" | "observerLeg"> | undefined): boolean;
9
+ /** The grant holder this leg's durable writes carry — its session writes and its card writes (a park's `put`, the writes on that park
10
+ * after it): the host-started leg's `RunInternals.holder`; NONE on a leg {@link engineLaneLegOf} reads as an engine lane's, whatever its
11
+ * internals hold (a workflow drive hands its member the host's holder for the resume CAS of that moment only — the resume reads
12
+ * `internals.holder` itself, never this). The one reading of the rule, by the same internals the leg was started with. */
13
+ export declare function writeHolderOf(internals: Pick<import("./runner/contracts.js").RunInternals, "holder" | "isDelegatedChild" | "observerLeg"> | undefined): string | undefined;
14
14
  /**
15
15
  * THE leg fact "a park of this leg cannot be resumed", derived once per leg (the driver) and read by name: absent ⇔ every park the leg
16
16
  * can mint has someone to resume it. Two sources, nothing else:
@@ -50,16 +50,18 @@ export interface NotResumableLeg {
50
50
  readonly source: ApprovalParkNotResumable;
51
51
  readonly mandated: boolean;
52
52
  }
53
- /** The refusal of an ask such a leg could not have answered, whatever asked it (the leg's own mandated ask, an inherited mandate, a
54
- * question): `subject` says what wanted a person; the cause is the leg's (never a facility it lacks); how it was refused — without
55
- * asking anyone, or after a live face was asked and gave no answer (`faced`: only a question that no mandate kept off its face is ever
56
- * put to one here); then what came of it — a call did not run, a question got no answer — and that asking again on this leg is no use.
57
- * No stop and no way out: the gate's deny exit appends the leg's way out ({@link notResumableWayOut}) and {@link NOT_RESUMABLE_CARRY_ON}
58
- * to every ask nobody could answer but the agent's own question, whose sentence says how to go on ({@link questionNotShownOnLeg}). */
59
- export declare function notResumableRefusal(subject: string, source: ApprovalParkNotResumable, asked: "call" | "question", faced?: boolean): string;
53
+ /** The refusal of a call such a leg could not have run, whatever wanted a person for it (the leg's own mandated ask, an inherited
54
+ * mandate): `subject` says what wanted a person; the cause is the leg's (never a facility it lacks); nobody was asked, the call did not
55
+ * run, and asking again on this leg is no use. No stop and no way out: the gate's deny exit appends the leg's way out
56
+ * ({@link notResumableWayOut}) and {@link NOT_RESUMABLE_CARRY_ON}. The agent's own question is no call: its refusal is the one mint of
57
+ * every unanswered question ({@link questionNotShownOnLeg}). */
58
+ export declare function notResumableRefusal(subject: string, source: ApprovalParkNotResumable): string;
60
59
  /** What the model does after such a refusal while the way out is not taken: say what was blocked, and go on with what needs no approval.
61
60
  * Beside the way out only: where nobody may answer on the leg the one sentence that replaces the way out already says it. */
62
61
  export declare const NOT_RESUMABLE_CARRY_ON = "Meanwhile, tell the user what was blocked and why you needed it, and continue with the parts of the task that need no approval.";
63
- /** The question tool's refusal on such a leg, read by both sites of the content route's not-shown refusal: the leg's cause; "once the
64
- * live face gave no answer" only where a face was tried (one is wired and no mandate kept the question off it). */
62
+ /** The question tool's refusal on such a leg, read by both sites of the content route's not-shown refusal: the one mint of every
63
+ * unanswered question ({@link unansweredAskRefusal}), the leg's account in its parenthesis — the leg's cause, then how it went: past a
64
+ * live face only where one was tried (one is wired and no mandate kept the question off it), else without asking anyone, and then
65
+ * that trying again on this leg cannot help (nobody can be asked on it; where a face was tried, it is asked again on every call, so a
66
+ * later one may be answered). Its only instruction is the mint's (`PROCEED_ON_JUDGMENT`). */
65
67
  export declare function questionNotShownOnLeg(leg: NotResumableLeg, faceWired: boolean): string;
@@ -1,6 +1,10 @@
1
+ import { unansweredAskRefusal } from "./ask-origin.js";
1
2
  export function engineLaneLegOf(internals) {
2
3
  return internals?.isDelegatedChild === true || internals?.observerLeg === true;
3
4
  }
5
+ export function writeHolderOf(internals) {
6
+ return engineLaneLegOf(internals) ? undefined : internals?.holder;
7
+ }
4
8
  export function approvalParkNotResumableOf(leg) {
5
9
  if (leg.engineLaneLeg && !leg.parkLaneHeld)
6
10
  return "lane";
@@ -12,7 +16,7 @@ export function notResumableSaysOf(fact, hostDeclared) {
12
16
  export function notResumableWayOut(source, mandated, asks = "approval") {
13
17
  const verb = asks === "answer" ? "answer" : "approve";
14
18
  const later = source === "lane"
15
- ? `ask from the parent leg itself, or delegate the work as a background agent on a lane that can park — its ${asks === "answer" ? "questions" : "approvals"} wait for a person to ${verb} later, and its result comes back`
19
+ ? `ask from the parent leg itself, or delegate the work as a background agent that can pause — its ${asks === "answer" ? "questions" : "approvals"} wait for a person to ${verb} later, and its result comes back`
16
20
  : `run it where its host can resume a parked ${asks === "answer" ? "question" : "approval"} (this host declared it cannot)`;
17
21
  return mandated ? later : `have a person who is present ${verb} it live, or ${later}`;
18
22
  }
@@ -24,10 +28,11 @@ export function notResumableClause(source) {
24
28
  ? "this leg runs on a lane that holds no park of it (a synchronous or fork child, a background child whose lane cannot park, an observer, or a woken retained agent)"
25
29
  : "its host declared that a parked approval of this run cannot be resumed";
26
30
  }
27
- export function notResumableRefusal(subject, source, asked, faced = false) {
28
- return `${subject}, and this leg cannot be resumed — ${notResumableClause(source)} — so it was refused ${faced ? "once the live face gave no answer" : "without asking anyone"} (fail-closed): ${asked === "call" ? "the call did not run (do not report it as done)" : "nobody answered it"}; do not retry it on this leg, where nothing can wait for a person`;
31
+ export function notResumableRefusal(subject, source) {
32
+ return `${subject}, and this leg cannot be resumed — ${notResumableClause(source)} — so it was refused without asking anyone (fail-closed): the call did not run (do not report it as done); do not retry it on this leg, where nothing can wait for a person`;
29
33
  }
30
34
  export const NOT_RESUMABLE_CARRY_ON = "Meanwhile, tell the user what was blocked and why you needed it, and continue with the parts of the task that need no approval.";
31
35
  export function questionNotShownOnLeg(leg, faceWired) {
32
- return `${notResumableRefusal("AskUserQuestion's question could not wait for a person's answer and no live face answered it", leg.source, "question", faceWired && !leg.mandated)}. Proceed with your best judgment and state the assumption you made.`;
36
+ const how = faceWired && !leg.mandated ? "nothing could keep it waiting past the live face" : "it was refused without asking anyone; trying again on this leg cannot help";
37
+ return unansweredAskRefusal({ cause: "question", noAttempt: true, leg: `this leg cannot be resumed — ${notResumableClause(leg.source)} — so ${how}` });
33
38
  }
@@ -1,4 +1,4 @@
1
- import { parsePermissionRule } from "./permission-rule-syntax.js";
1
+ import { parsePermissionRule } from "@sema-agent/primitives";
2
2
  import { isUsablePathBase, pathRuleHeadOf, pathRuleReachOf, pathRuleReachShapeOf, ruleBasesNeeded } from "./permission-rule-model.js";
3
3
  import { pathFamilyOf, spellingOfIdentity } from "../tools/fs/safety.js";
4
4
  import { absoluteTargetIdentityOf } from "./effective-path-target.js";
@@ -72,8 +72,7 @@
72
72
  * here) and no leading-env-assignment stripping (`FOO=1 git status` simply does not match
73
73
  * `Bash(git status:*)`) — the last two are strict-side divergences from upstream, registered as such.
74
74
  */
75
- import { type ParsedPermissionRule } from "./permission-rule-syntax.js";
76
- import { isRuleBehavior, RULE_BEHAVIOR_PRECEDENCE, RULE_BEHAVIORS, RULE_BEHAVIORS_BY_PRECEDENCE, type RuleBehavior } from "@sema-agent/primitives";
75
+ import { type ParsedPermissionRule, isRuleBehavior, RULE_BEHAVIOR_PRECEDENCE, RULE_BEHAVIORS, RULE_BEHAVIORS_BY_PRECEDENCE, type RuleBehavior } from "@sema-agent/primitives";
77
76
  import { type DenyFace } from "../tools/fs/read-deny.js";
78
77
  import type { AssertAllKeysHandled, RuleOffersAbsence } from "./ask-origin.js";
79
78
  import { type ToolCallLike } from "./tool-registry.js";
@@ -327,7 +326,7 @@ export declare function ruleWordsOf(req: NamedCall, behavior: RuleBehavior): rea
327
326
  /** The match words a persisted rule is stored with, spelled once: {@link PersistedRuleMatch} is derived from this
328
327
  * tuple (each form is documented there). A store backend that checks a stored row's `match` reads this value
329
328
  * rather than keeping its own list. */
330
- export declare const PERSISTED_RULE_MATCHES: readonly ["exact", "prefix", "wildcard", "pattern", "subpath", "path", "name", "name_prefix", "host", "subdomain", "tool"];
329
+ export declare const PERSISTED_RULE_MATCHES: readonly ["exact", "prefix", "wildcard", "pattern", "subpath", "path", "name", "name_prefix", "host", "subdomain", "tool", "call"];
331
330
  /**
332
331
  * Match forms, one family per grammar (`prefix` and `wildcard` are one predicate):
333
332
  * · `exact` — admits the one string the rule spells.
@@ -361,6 +360,10 @@ export declare const PERSISTED_RULE_MATCHES: readonly ["exact", "prefix", "wildc
361
360
  * host below one domain.
362
361
  * · `tool` — the WHOLE-TOOL form, a rule with no content (`SendUserFile`, `Bash`, `mcp__srv__get_issue`), on any tool:
363
362
  * `command` is empty and the rule reaches every call that answers to the name it spells ({@link wholeToolRuleReaches}).
363
+ * · `call` — a SESSION grant of one shell call (`session-call-grant.ts`): `command` is the call's binding (canonical JSON of
364
+ * paths, identities and digests), the text its digest. It exists only as a session-scope allow the engine writes from a
365
+ * person's answer on a card; no rule text parses to it, so it reaches no text matcher here — the person's lane admits a
366
+ * call by it when the same reading of the call comes out equal.
364
367
  */
365
368
  export type PersistedRuleMatch = (typeof PERSISTED_RULE_MATCHES)[number];
366
369
  /**
@@ -378,8 +381,8 @@ export type PersistedRuleMatch = (typeof PERSISTED_RULE_MATCHES)[number];
378
381
  * the write deltas, sync in both directions, at-rest bytes — refuses or drops a session row
379
382
  * (design/382 §4.3, the durable two-member face). `sessionId` uniqueness is the HOST's duty (the
380
383
  * `principal` posture): reusing an id is a declaration that it is the same session. A session row
381
- * cannot be individually deleted — it dies with its session (design/382 §10, ruled; the durable
382
- * removal entry refuses it rather than answering a false no-op).
384
+ * dies with its session, and a person can take one back sooner: the removal entry routes a session
385
+ * scope to the session partition's `revoke`.
383
386
  *
384
387
  * ORG is deliberately NOT a member (design/382 §4.1): an approval card must be structurally unable to
385
388
  * spell an org-wide grant — org governance is a deny/ask snapshot published by an admin surface, with
@@ -1619,6 +1622,9 @@ export type RuleOfferBatchMemberArmsCoverEveryKind = AssertAllKeysHandled<Exclud
1619
1622
  * render source for a card is the PREPARED record's own offers (record-is-what-you-see); the ask-time
1620
1623
  * projection here may drift from it across a coverage change, and the drift direction is harmless
1621
1624
  * (the record is what gets confirmed).
1625
+ *
1626
+ * No offer, and no batch member, ever carries `match: "call"`: a session call grant is a card's own option
1627
+ * (`AskRequest.sessionCallGrant`), never a rule offer, and the offer reader reads that word in an offer as one it does not know.
1622
1628
  */
1623
1629
  export type RuleOffer = {
1624
1630
  readonly kind: "single";
@@ -1,11 +1,11 @@
1
1
  import { homedir } from "node:os";
2
+ import { createHash } from "node:crypto";
2
3
  import { shellWordsOf } from "../shell/shell-words.js";
3
4
  import { lexShell } from "../shell/lex.js";
4
5
  import { readProgramPosition } from "../tools/fs/bash-program-position.js";
5
- import { isNameableToolName, parsePermissionRule, ruleSpellingOf } from "./permission-rule-syntax.js";
6
6
  import { namesASetOfTools, ruleNameCovers } from "./namespaced-rule-name.js";
7
7
  import { toolNameFaultOf } from "./tool-name-aliases.js";
8
- import { A2A_FINGERPRINT_MAX_CHARS, A2A_NAMESPACE, isRuleBehavior, peerReadingsOf, readsNameGlob, RULE_BEHAVIOR_PRECEDENCE, RULE_BEHAVIORS, RULE_BEHAVIORS_BY_PRECEDENCE, splitNamespacedName, } from "@sema-agent/primitives";
8
+ import { A2A_FINGERPRINT_MAX_CHARS, A2A_NAMESPACE, isNameableToolName, parsePermissionRule, ruleSpellingOf, isRuleBehavior, peerReadingsOf, readsNameGlob, RULE_BEHAVIOR_PRECEDENCE, RULE_BEHAVIORS, RULE_BEHAVIORS_BY_PRECEDENCE, splitNamespacedName, } from "@sema-agent/primitives";
9
9
  import { compileReadDeny } from "../tools/fs/read-deny.js";
10
10
  import { carriesShellRedirection, parseLeadingCommandName, splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
11
11
  import { INLINE_TRUNCATION_MARK, inlineUntrusted, UNRENDERABLE_CHAR_CLASS } from "./untrusted-text.js";
@@ -196,7 +196,7 @@ function ruleWordOf(name) {
196
196
  return COMMAND_RULE_TOOL;
197
197
  return ruleToolGrammarOf(name) !== undefined ? name : undefined;
198
198
  }
199
- export const PERSISTED_RULE_MATCHES = Object.freeze(["exact", "prefix", "wildcard", "pattern", "subpath", "path", "name", "name_prefix", "host", "subdomain", "tool"]);
199
+ export const PERSISTED_RULE_MATCHES = Object.freeze(["exact", "prefix", "wildcard", "pattern", "subpath", "path", "name", "name_prefix", "host", "subdomain", "tool", "call"]);
200
200
  function isCommandMatch(match) {
201
201
  return match === "exact" || match === "prefix" || match === "wildcard" || match === "pattern";
202
202
  }
@@ -594,6 +594,8 @@ export function parseRuleText(text, behavior) {
594
594
  export function formatRuleText(command, match, tool) {
595
595
  if (match === "tool")
596
596
  return tool;
597
+ if (match === "call")
598
+ return `${tool}(<call sha256:${createHash("sha256").update(command).digest("hex")}>)`;
597
599
  if (match === "subpath")
598
600
  return `${tool}(//${command.startsWith("/") ? command.slice(1) : command}/**)`;
599
601
  if (match === "path")
@@ -1,5 +1,5 @@
1
1
  import { COMMAND_RULE_TOOL, PATH_RULE_FACES, escapeForDisclosure, parseRuleText, programRunReachOf, ruleReachesProgramRun, ruleToolGrammarOf } from "./permission-rule-model.js";
2
- import { isNameableToolName, ruleSpellingOf } from "./permission-rule-syntax.js";
2
+ import { isNameableToolName, ruleSpellingOf } from "@sema-agent/primitives";
3
3
  import { isShellFaceToolName, pathTargetOf } from "./tool-registry.js";
4
4
  import { writerOf } from "./permission-rule-store.js";
5
5
  import { canonicalize } from "./canonical-json.js";
@@ -39,7 +39,7 @@ import { type DurableRulePartitionProvider, type QuarantinedRuleAdd } from "./pe
39
39
  import { type RuleOwner } from "./rule-owner.js";
40
40
  import { type RuleStoreFault } from "./rule-store-fault.js";
41
41
  import { type OrgRulePartitionConfig, type OrgRuleResolution } from "./permission-rule-org.js";
42
- import type { SessionRulePartition } from "./permission-rule-session.js";
42
+ import type { SessionRulePartition, SessionRuleRevokeResult, SessionRuleTarget } from "./permission-rule-session.js";
43
43
  import type { StoreDurability, StoreFidelity } from "./checkpoint-store.js";
44
44
  import { type AutoStripRowReason } from "./auto-strip.js";
45
45
  import { type MountedPeersSeat } from "./a2a-bound-grant.js";
@@ -254,6 +254,10 @@ export interface PermissionRuleStoreProvider {
254
254
  * stamp every grant the engine writes for an inside A2A peer carries — the run's card and the consent protocol's record read it.
255
255
  * Absent ⇒ the engine writes no stamp. */
256
256
  readonly a2aPeers?: MountedPeersSeat;
257
+ /** Take one session row back — the session partition's `revoke`, as configured. Present exactly when the configured session
258
+ * partition has that verb. The removal entry (`removePersistedRule` with a session scope) is the one caller a host needs; the
259
+ * session call grant is offered only where this is present (a grant whose promise is that it can be taken back). */
260
+ revokeSessionRule?(sessionId: string, target: SessionRuleTarget): Promise<SessionRuleRevokeResult>;
257
261
  }
258
262
  /**
259
263
  * The store one task reads its person's rules from. The unauthenticated floor is enforced HERE, not merely asked of the
@@ -1,6 +1,6 @@
1
1
  import { types } from "node:util";
2
2
  import { PATH_RULE_FACES, escapeForDisclosure, formatRuleText, isRuleBehavior, parseRuleText } from "./permission-rule-model.js";
3
- import { isNameableToolName } from "./permission-rule-syntax.js";
3
+ import { isNameableToolName } from "@sema-agent/primitives";
4
4
  import { PERMISSION_RULES_DAMAGED_BUCKET_CODE, PERMISSION_RULE_WRITER, errText, holdsRuleWriter, isValidDurableScope, normalizePersistedRule, sameRuleIdentity, writerOf, } from "./permission-rule-store.js";
5
5
  import { readRuleOwner } from "./rule-owner.js";
6
6
  import { ruleStoreFaultReasonOf } from "./rule-store-fault.js";
@@ -349,6 +349,10 @@ export function createPermissionRuleStoreProvider(cfg) {
349
349
  if (session !== undefined && (typeof session.read !== "function" || typeof session.apply !== "function")) {
350
350
  throw new Error("the session partition must implement read(sessionId) and apply(sessionId, add) — refusing a partial face rather than serving a session source that cannot answer");
351
351
  }
352
+ const revokeVerb = session?.revoke;
353
+ if (session !== undefined && revokeVerb !== undefined && typeof revokeVerb !== "function") {
354
+ throw new Error("the session partition's revoke is present and is not a function — refusing a face whose take-back verb cannot be called (omit it to declare a partition whose rows end only with their session)");
355
+ }
352
356
  const partitions = Object.freeze({ durable: durable !== undefined, org: org !== undefined, session: session !== undefined });
353
357
  const a2aPeers = cfg.a2aPeers;
354
358
  if (a2aPeers !== undefined && typeof a2aPeers !== "function") {
@@ -363,6 +367,7 @@ export function createPermissionRuleStoreProvider(cfg) {
363
367
  return storeOver(durable?.forPrincipal(name));
364
368
  },
365
369
  ...(durable?.forLocalOwner !== undefined ? { forLocalOwner: () => storeOver(durable.forLocalOwner()) } : {}),
370
+ ...(session !== undefined && typeof revokeVerb === "function" ? { revokeSessionRule: (sessionId, target) => session.revoke(sessionId, target) } : {}),
366
371
  };
367
372
  return provider;
368
373
  }