@sema-agent/core 7.55.0 → 7.57.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 (502) hide show
  1. package/CHANGELOG.md +1054 -0
  2. package/LICENSE +1 -1
  3. package/dist/agents/cascade.js +1 -1
  4. package/dist/agents/cc-peer-directory.js +1 -0
  5. package/dist/agents/child-model-seat.d.ts +0 -11
  6. package/dist/agents/child-model-seat.js +0 -3
  7. package/dist/agents/list-agents-tool.d.ts +3 -1
  8. package/dist/agents/list-agents-tool.js +7 -7
  9. package/dist/agents/org-delivery-gate.js +3 -4
  10. package/dist/agents/peer-directory.d.ts +22 -4
  11. package/dist/agents/peer-directory.js +24 -2
  12. package/dist/agents/peer-held-queue.d.ts +69 -49
  13. package/dist/agents/peer-held-queue.js +255 -106
  14. package/dist/agents/peer-session-drain.js +65 -45
  15. package/dist/agents/repair-loop.js +2 -2
  16. package/dist/agents/send-message-tool.js +7 -6
  17. package/dist/agents/subagent.d.ts +6 -4
  18. package/dist/agents/subagent.js +72 -68
  19. package/dist/agents/tool-filter.d.ts +7 -5
  20. package/dist/agents/tool-filter.js +12 -9
  21. package/dist/agents/verify.d.ts +3 -2
  22. package/dist/agents/verify.js +3 -3
  23. package/dist/brain/anthropic.js +45 -80
  24. package/dist/brain/media-degrade.d.ts +18 -7
  25. package/dist/brain/media-degrade.js +13 -2
  26. package/dist/brain/model-capability.d.ts +37 -0
  27. package/dist/brain/model-capability.js +34 -0
  28. package/dist/brain/model-presets.d.ts +2 -8
  29. package/dist/brain/model-presets.js +1 -6
  30. package/dist/brain/open-responses.js +23 -34
  31. package/dist/brain/openai.js +25 -96
  32. package/dist/brain/provider-dialect.d.ts +3 -2
  33. package/dist/brain/provider-dialect.js +2 -2
  34. package/dist/brain/reasoning-request.d.ts +96 -0
  35. package/dist/brain/reasoning-request.js +174 -0
  36. package/dist/brain/reasoning.d.ts +11 -11
  37. package/dist/brain/reasoning.js +4 -3
  38. package/dist/brain/request-params.d.ts +13 -4
  39. package/dist/brain/request-params.js +21 -5
  40. package/dist/brain/status-sink.d.ts +20 -0
  41. package/dist/brain/status-sink.js +7 -0
  42. package/dist/brain/stream-engine.d.ts +9 -0
  43. package/dist/brain/stream-engine.js +24 -10
  44. package/dist/brain/stream-shared.d.ts +5 -4
  45. package/dist/brain/stream-shared.js +4 -4
  46. package/dist/core/a2a.d.ts +2 -1
  47. package/dist/core/a2a.js +19 -13
  48. package/dist/core/agent-definition.d.ts +10 -0
  49. package/dist/core/allow-entry.d.ts +23 -23
  50. package/dist/core/allow-entry.js +42 -46
  51. package/dist/core/allow-rule-shadow.d.ts +3 -3
  52. package/dist/core/approval-object.d.ts +21 -5
  53. package/dist/core/approval-object.js +44 -17
  54. package/dist/core/ask-origin.d.ts +66 -20
  55. package/dist/core/ask-origin.js +63 -23
  56. package/dist/core/ask-question.d.ts +51 -8
  57. package/dist/core/ask-question.js +3 -4
  58. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  59. package/dist/core/ask-unresolvable-notice.js +16 -2
  60. package/dist/core/auto-compaction.d.ts +71 -6
  61. package/dist/core/auto-compaction.js +42 -26
  62. package/dist/core/background-agent-store.d.ts +6 -2
  63. package/dist/core/background-agent-store.js +1 -1
  64. package/dist/core/checkpoint-generation.d.ts +53 -0
  65. package/dist/core/checkpoint-generation.js +35 -0
  66. package/dist/core/checkpoint-queries.d.ts +180 -0
  67. package/dist/core/checkpoint-queries.js +272 -0
  68. package/dist/core/checkpoint-requirements.d.ts +19 -1
  69. package/dist/core/checkpoint-requirements.js +6 -0
  70. package/dist/core/checkpoint-store.d.ts +105 -53
  71. package/dist/core/checkpoint-store.js +43 -20
  72. package/dist/core/cross-boundary-taint.d.ts +6 -5
  73. package/dist/core/cross-boundary-taint.js +5 -5
  74. package/dist/core/decision-receipt.d.ts +37 -3
  75. package/dist/core/decision-receipt.js +17 -17
  76. package/dist/core/delegation-not-started.d.ts +6 -0
  77. package/dist/core/delegation-not-started.js +17 -0
  78. package/dist/core/engine-attestation.d.ts +93 -0
  79. package/dist/core/engine-attestation.js +70 -0
  80. package/dist/core/engine-capabilities.d.ts +4 -1
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +32 -12
  83. package/dist/core/engine-notice.js +6 -0
  84. package/dist/core/file-history-store.d.ts +104 -22
  85. package/dist/core/file-history-store.js +37 -19
  86. package/dist/core/gate-fold.d.ts +1 -1
  87. package/dist/core/gate-fold.js +22 -10
  88. package/dist/core/gate-lanes.js +73 -65
  89. package/dist/core/gate-outcome.d.ts +26 -5
  90. package/dist/core/gate-outcome.js +26 -0
  91. package/dist/core/governance-codes.d.ts +5 -1
  92. package/dist/core/governance-codes.js +6 -0
  93. package/dist/core/hooks.d.ts +19 -18
  94. package/dist/core/hooks.js +3 -1
  95. package/dist/core/host-floor.d.ts +128 -0
  96. package/dist/core/host-floor.js +206 -0
  97. package/dist/core/host-target.d.ts +38 -3
  98. package/dist/core/host-target.js +38 -5
  99. package/dist/core/mailbox-store.d.ts +62 -1
  100. package/dist/core/mailbox-store.js +59 -0
  101. package/dist/core/mcp-name-judge.d.ts +46 -0
  102. package/dist/core/mcp-name-judge.js +61 -0
  103. package/dist/core/mcp-probe.d.ts +1 -1
  104. package/dist/core/mcp-probe.js +2 -5
  105. package/dist/core/mcp.d.ts +5 -1
  106. package/dist/core/mcp.js +70 -64
  107. package/dist/core/memory-engine/consolidation-driver.js +4 -3
  108. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  109. package/dist/core/memory-engine/distiller.js +26 -17
  110. package/dist/core/memory-engine/engine.js +4 -4
  111. package/dist/core/memory-engine/layout.d.ts +60 -8
  112. package/dist/core/memory-engine/layout.js +70 -8
  113. package/dist/core/model-seat.d.ts +10 -3
  114. package/dist/core/mods/classic-events.d.ts +67 -0
  115. package/dist/core/mods/classic-events.js +1 -0
  116. package/dist/core/mods/dollar.d.ts +13 -0
  117. package/dist/core/mods/extension-call.d.ts +31 -0
  118. package/dist/core/mods/extension-call.js +43 -0
  119. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  120. package/dist/core/mods/kernel/dispatch.js +140 -69
  121. package/dist/core/mods/kernel/events.d.ts +47 -11
  122. package/dist/core/mods/kernel/events.js +66 -42
  123. package/dist/core/mods/kernel/index.d.ts +4 -4
  124. package/dist/core/mods/kernel/index.js +2 -2
  125. package/dist/core/mods/kernel/receive.d.ts +39 -5
  126. package/dist/core/mods/kernel/receive.js +290 -17
  127. package/dist/core/mods/kernel/registration.d.ts +33 -2
  128. package/dist/core/mods/kernel/registration.js +6 -7
  129. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  130. package/dist/core/mods/kernel/site-rules.js +24 -42
  131. package/dist/core/mods/spec-seats.d.ts +69 -0
  132. package/dist/core/mods/spec-seats.js +114 -0
  133. package/dist/core/mods/stations.d.ts +28 -8
  134. package/dist/core/mods/stations.js +29 -13
  135. package/dist/core/mods/tool-call.d.ts +79 -0
  136. package/dist/core/mods/tool-call.js +152 -0
  137. package/dist/core/namespaced-rule-name.d.ts +32 -38
  138. package/dist/core/namespaced-rule-name.js +29 -36
  139. package/dist/core/parent-spec-seat.d.ts +6 -1
  140. package/dist/core/parent-spec-seat.js +2 -0
  141. package/dist/core/park-selfcheck.js +3 -0
  142. package/dist/core/permission-rule-consent.d.ts +24 -3
  143. package/dist/core/permission-rule-consent.js +136 -41
  144. package/dist/core/permission-rule-model.d.ts +57 -5
  145. package/dist/core/permission-rule-model.js +90 -31
  146. package/dist/core/permission-rule-org.d.ts +6 -2
  147. package/dist/core/permission-rule-org.js +8 -4
  148. package/dist/core/permission-rule-provider.d.ts +5 -2
  149. package/dist/core/permission-rule-provider.js +41 -11
  150. package/dist/core/permission-rule-store.d.ts +3 -2
  151. package/dist/core/permission-rule-store.js +11 -2
  152. package/dist/core/permission-rule-sync.js +3 -2
  153. package/dist/core/permission-rule-syntax.d.ts +5 -4
  154. package/dist/core/permission-rule-syntax.js +2 -2
  155. package/dist/core/permission-rules.d.ts +4 -4
  156. package/dist/core/permission-rules.js +11 -20
  157. package/dist/core/persisted-rule-arms.d.ts +2 -2
  158. package/dist/core/persisted-rule-arms.js +10 -12
  159. package/dist/core/principal-name.d.ts +20 -0
  160. package/dist/core/principal-name.js +22 -0
  161. package/dist/core/prompt-section-seat.js +4 -6
  162. package/dist/core/protocol-http-auth.d.ts +40 -5
  163. package/dist/core/protocol-http-auth.js +168 -4
  164. package/dist/core/protocol-naming.d.ts +20 -0
  165. package/dist/core/protocol-naming.js +20 -3
  166. package/dist/core/read-only-shell.d.ts +20 -5
  167. package/dist/core/read-only-shell.js +29 -14
  168. package/dist/core/remote-env.d.ts +37 -1
  169. package/dist/core/remote-env.js +11 -0
  170. package/dist/core/resume-startup-cause.d.ts +24 -2
  171. package/dist/core/resume-startup-cause.js +20 -1
  172. package/dist/core/retired-keys.d.ts +16 -0
  173. package/dist/core/retired-keys.js +16 -4
  174. package/dist/core/rewrite-rejudge.d.ts +60 -0
  175. package/dist/core/rewrite-rejudge.js +36 -0
  176. package/dist/core/roles.d.ts +28 -1
  177. package/dist/core/roles.js +81 -26
  178. package/dist/core/rule-lane-reads.d.ts +20 -15
  179. package/dist/core/rule-lane-reads.js +45 -17
  180. package/dist/core/rule-owner.d.ts +3 -3
  181. package/dist/core/rule-owner.js +3 -2
  182. package/dist/core/runner/announce-once-ledger.d.ts +14 -0
  183. package/dist/core/runner/announce-once-ledger.js +5 -0
  184. package/dist/core/runner/assemble-result.d.ts +1 -0
  185. package/dist/core/runner/assemble-result.js +1 -1
  186. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  187. package/dist/core/runner/caller-roster.d.ts +16 -4
  188. package/dist/core/runner/caller-roster.js +33 -6
  189. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  190. package/dist/core/runner/capability-withheld-seat.js +24 -0
  191. package/dist/core/runner/classifier-ladder.d.ts +7 -9
  192. package/dist/core/runner/classifier-ladder.js +3 -3
  193. package/dist/core/runner/compact-session.d.ts +10 -0
  194. package/dist/core/runner/compact-session.js +202 -0
  195. package/dist/core/runner/compaction-call-options.d.ts +2 -2
  196. package/dist/core/runner/compaction-seams.d.ts +21 -1
  197. package/dist/core/runner/compaction-seams.js +11 -8
  198. package/dist/core/runner/construction-doors.js +3 -0
  199. package/dist/core/runner/contracts.d.ts +50 -40
  200. package/dist/core/runner/cross-boundary-lane.d.ts +17 -13
  201. package/dist/core/runner/cross-boundary-lane.js +40 -27
  202. package/dist/core/runner/denial-limit-arms.d.ts +2 -2
  203. package/dist/core/runner/denial-limit-arms.js +1 -1
  204. package/dist/core/runner/derived-route-fallback.d.ts +13 -0
  205. package/dist/core/runner/derived-route-fallback.js +6 -0
  206. package/dist/core/runner/env-capability-census.d.ts +3 -2
  207. package/dist/core/runner/env-capability-census.js +9 -3
  208. package/dist/core/runner/file-history-request.d.ts +18 -0
  209. package/dist/core/runner/file-history-request.js +21 -13
  210. package/dist/core/runner/file-history-restore.d.ts +45 -0
  211. package/dist/core/runner/file-history-restore.js +46 -0
  212. package/dist/core/runner/gate-exit.d.ts +3 -3
  213. package/dist/core/runner/gate-exit.js +4 -3
  214. package/dist/core/runner/image.d.ts +7 -17
  215. package/dist/core/runner/image.js +9 -60
  216. package/dist/core/runner/permission-rule-lanes.d.ts +11 -11
  217. package/dist/core/runner/permission-rule-lanes.js +39 -17
  218. package/dist/core/runner/person-path-rows.d.ts +12 -9
  219. package/dist/core/runner/person-path-rows.js +18 -7
  220. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
  221. package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
  222. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  223. package/dist/core/runner/prepare-ask-lane.js +5 -2
  224. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  225. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  226. package/dist/core/runner/prepare-config-doors.d.ts +35 -38
  227. package/dist/core/runner/prepare-config-doors.js +46 -28
  228. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  229. package/dist/core/runner/prepare-defer-classify.js +7 -8
  230. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  231. package/dist/core/runner/prepare-file-history.js +7 -39
  232. package/dist/core/runner/prepare-gate-stations.d.ts +1 -1
  233. package/dist/core/runner/prepare-gate-stations.js +10 -1
  234. package/dist/core/runner/prepare-hands-readface.d.ts +5 -9
  235. package/dist/core/runner/prepare-hands-readface.js +17 -14
  236. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  237. package/dist/core/runner/prepare-inherited-gate.js +5 -3
  238. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  239. package/dist/core/runner/prepare-park-ask.d.ts +2 -0
  240. package/dist/core/runner/prepare-park-ask.js +7 -7
  241. package/dist/core/runner/prepare-policy-chain.d.ts +6 -3
  242. package/dist/core/runner/prepare-policy-chain.js +67 -76
  243. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  244. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  245. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  246. package/dist/core/runner/prepare-prompt-inputs.js +3 -5
  247. package/dist/core/runner/prepare-protocol-tools.d.ts +2 -0
  248. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  249. package/dist/core/runner/prepare-safety-scan.d.ts +1 -1
  250. package/dist/core/runner/prepare-safety-scan.js +0 -17
  251. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  252. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  253. package/dist/core/runner/prepare-task.d.ts +5 -2
  254. package/dist/core/runner/prepare-task.js +48 -43
  255. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +20 -4
  256. package/dist/core/runner/prepare-tool-disclosure-mount.js +33 -23
  257. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  258. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  259. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -2
  260. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  261. package/dist/core/runner/resume-admission.js +1 -1
  262. package/dist/core/runner/resume-apply.js +11 -12
  263. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  264. package/dist/core/runner/resume-claim.d.ts +4 -2
  265. package/dist/core/runner/resume-claim.js +15 -8
  266. package/dist/core/runner/retired-runner-deps.js +1 -0
  267. package/dist/core/runner/rewind-files.d.ts +12 -0
  268. package/dist/core/runner/rewind-files.js +90 -0
  269. package/dist/core/runner/run-attachment-seats.js +2 -1
  270. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  271. package/dist/core/runner/run-brain-sinks.js +4 -2
  272. package/dist/core/runner/run-harness-handlers.js +12 -4
  273. package/dist/core/runner/run-leg.d.ts +1 -1
  274. package/dist/core/runner/run-leg.js +40 -39
  275. package/dist/core/runner/run-notification-lane.d.ts +2 -0
  276. package/dist/core/runner/run-notification-lane.js +2 -2
  277. package/dist/core/runner/run-recovery-lanes.js +3 -4
  278. package/dist/core/runner/run-settle-and-teardown.js +7 -12
  279. package/dist/core/runner/run-terminal-adoption.js +3 -4
  280. package/dist/core/runner/run-turn-boundary.js +4 -15
  281. package/dist/core/runner/runtask.d.ts +10 -0
  282. package/dist/core/runner/runtask.js +35 -42
  283. package/dist/core/runner/send-message-continuation.js +1 -1
  284. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  285. package/dist/core/runner/session-read-file-states.js +28 -0
  286. package/dist/core/runner/session-rule-policy.js +4 -3
  287. package/dist/core/runner/session-verb-doors.d.ts +28 -0
  288. package/dist/core/runner/session-verb-doors.js +48 -0
  289. package/dist/core/runner/session-write-ledger.d.ts +30 -0
  290. package/dist/core/runner/session-write-ledger.js +101 -0
  291. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  292. package/dist/core/runner/shell-env-withheld.js +51 -0
  293. package/dist/core/runner/skills-seat.js +6 -2
  294. package/dist/core/runner/stream-settle-backstop.js +12 -15
  295. package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
  296. package/dist/core/runner/sub-agent-deny-lists.js +25 -17
  297. package/dist/core/runner/synthetic-tools.d.ts +6 -0
  298. package/dist/core/runner/synthetic-tools.js +4 -1
  299. package/dist/core/runner/teardown-bounded.d.ts +1 -0
  300. package/dist/core/runner/teardown-bounded.js +1 -0
  301. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  302. package/dist/core/runner/tool-disclosure.js +1 -3
  303. package/dist/core/runner/tool-end-body.d.ts +1 -1
  304. package/dist/core/runner/tool-end-body.js +10 -9
  305. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  306. package/dist/core/runner/tool-not-executed.js +11 -0
  307. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  308. package/dist/core/runner/tool-occurrence.js +7 -0
  309. package/dist/core/runner/turn-attachments.d.ts +33 -15
  310. package/dist/core/runner/turn-attachments.js +62 -37
  311. package/dist/core/runner-deps.d.ts +7 -7
  312. package/dist/core/safety-axis-vocab.d.ts +6 -4
  313. package/dist/core/safety-axis-vocab.js +6 -5
  314. package/dist/core/safety-merge-corpus.js +11 -3
  315. package/dist/core/secret-env.d.ts +30 -3
  316. package/dist/core/secret-env.js +47 -8
  317. package/dist/core/select-model.js +3 -3
  318. package/dist/core/session-policy-store.d.ts +32 -15
  319. package/dist/core/session-policy-store.js +156 -36
  320. package/dist/core/session-store.d.ts +29 -10
  321. package/dist/core/session-store.js +51 -19
  322. package/dist/core/session.d.ts +82 -16
  323. package/dist/core/session.js +53 -0
  324. package/dist/core/shell-read-silence.d.ts +11 -12
  325. package/dist/core/shell-read-silence.js +9 -5
  326. package/dist/core/shell-run-candidates.js +3 -1
  327. package/dist/core/shell-wrapper-projection.d.ts +1 -1
  328. package/dist/core/shell-wrapper-projection.js +1 -1
  329. package/dist/core/shell-wrapper-table.d.ts +14 -7
  330. package/dist/core/shell-wrapper-table.js +5 -4
  331. package/dist/core/side-query.js +10 -1
  332. package/dist/core/skill-grant.d.ts +7 -2
  333. package/dist/core/skill-grant.js +5 -0
  334. package/dist/core/skills-directory.js +6 -2
  335. package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
  336. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  337. package/dist/core/store-contracts/checkpoint-store-contract.js +141 -2
  338. package/dist/core/store-contracts/file-history-store-contract.js +40 -1
  339. package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
  340. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  341. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  342. package/dist/core/store-contracts/session-repo-contract.js +51 -0
  343. package/dist/core/store-contracts/session-store-contract.d.ts +2 -1
  344. package/dist/core/store-contracts/session-store-contract.js +150 -14
  345. package/dist/core/stub-env.d.ts +2 -0
  346. package/dist/core/stub-env.js +1 -0
  347. package/dist/core/synthetic-read-verdict.js +3 -3
  348. package/dist/core/task-event.d.ts +32 -4
  349. package/dist/core/task-notification.d.ts +16 -12
  350. package/dist/core/task-registry-agent.d.ts +8 -4
  351. package/dist/core/task-registry-agent.js +14 -8
  352. package/dist/core/task-registry-shared.d.ts +35 -6
  353. package/dist/core/task-registry-shared.js +11 -0
  354. package/dist/core/task-registry.d.ts +10 -1
  355. package/dist/core/task-registry.js +12 -2
  356. package/dist/core/task-result.d.ts +18 -0
  357. package/dist/core/task-spec.d.ts +18 -13
  358. package/dist/core/tighten-task-spec.js +2 -1
  359. package/dist/core/tool-catalog-entries.d.ts +23 -0
  360. package/dist/core/tool-catalog-entries.js +14 -2
  361. package/dist/core/tool-check-reading.d.ts +11 -0
  362. package/dist/core/tool-check-reading.js +11 -6
  363. package/dist/core/tool-model-gate.d.ts +2 -2
  364. package/dist/core/tool-name-aliases.d.ts +48 -18
  365. package/dist/core/tool-name-aliases.js +36 -19
  366. package/dist/core/tool-name-readings.d.ts +6 -32
  367. package/dist/core/tool-name-readings.js +2 -9
  368. package/dist/core/tool-policy.d.ts +78 -204
  369. package/dist/core/tool-policy.js +152 -204
  370. package/dist/core/tool-result-store.js +3 -0
  371. package/dist/core/tool-roster.d.ts +14 -19
  372. package/dist/core/tool-roster.js +11 -44
  373. package/dist/core/tool-spec-members.js +7 -2
  374. package/dist/core/tool-spec.d.ts +19 -11
  375. package/dist/core/tools.js +49 -9
  376. package/dist/core/trace.d.ts +6 -3
  377. package/dist/core/trace.js +2 -1
  378. package/dist/core/types.d.ts +1 -1
  379. package/dist/core/untrusted-egress.d.ts +20 -0
  380. package/dist/core/untrusted-egress.js +77 -3
  381. package/dist/core/user-attachment.d.ts +8 -1
  382. package/dist/core/user-attachment.js +64 -4
  383. package/dist/core/wiring-manifest.d.ts +9 -0
  384. package/dist/core/wiring-manifest.js +1 -0
  385. package/dist/core/workflow-journal-store.js +1 -1
  386. package/dist/engine/compaction/compaction.js +3 -2
  387. package/dist/engine/execution-env/node-execution-env.d.ts +7 -3
  388. package/dist/engine/execution-env/node-execution-env.js +11 -2
  389. package/dist/engine/harness/agent-harness.d.ts +32 -6
  390. package/dist/engine/harness/agent-harness.js +65 -9
  391. package/dist/engine/harness/types.d.ts +29 -2
  392. package/dist/engine/llm/types.d.ts +28 -11
  393. package/dist/engine/loop/agent-loop.d.ts +23 -4
  394. package/dist/engine/loop/agent-loop.js +42 -30
  395. package/dist/engine/loop/types.d.ts +16 -6
  396. package/dist/engine/session/memory-repo.d.ts +9 -2
  397. package/dist/engine/session/memory-repo.js +11 -1
  398. package/dist/engine/session/repo-utils.d.ts +6 -5
  399. package/dist/engine/session/repo-utils.js +14 -6
  400. package/dist/index.d.ts +34 -17
  401. package/dist/index.js +22 -11
  402. package/dist/internal/harness-types.d.ts +1 -1
  403. package/dist/internal/harness.d.ts +2 -1
  404. package/dist/internal/harness.js +1 -0
  405. package/dist/internal/llm.d.ts +1 -1
  406. package/dist/orchestration/run-workflow-tool.d.ts +6 -4
  407. package/dist/orchestration/run-workflow-tool.js +5 -3
  408. package/dist/orchestration/workflow.d.ts +3 -0
  409. package/dist/orchestration/workflow.js +36 -18
  410. package/dist/primitives/credential-ref.d.ts +89 -0
  411. package/dist/primitives/credential-ref.js +125 -0
  412. package/dist/primitives/index.d.ts +2 -0
  413. package/dist/primitives/index.js +1 -0
  414. package/dist/prompt-assembly/artifact.d.ts +2 -2
  415. package/dist/prompt-assembly/artifact.js +5 -3
  416. package/dist/prompt-assembly/assemble.d.ts +3 -2
  417. package/dist/prompt-assembly/assemble.js +1 -1
  418. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  419. package/dist/prompt-assembly/catalog/schema.js +34 -2
  420. package/dist/prompt-assembly/catalog/sections.js +0 -1
  421. package/dist/prompt-assembly/composer.d.ts +3 -1
  422. package/dist/prompt-assembly/composer.js +1 -1
  423. package/dist/prompt-assembly/event-registry.js +1 -0
  424. package/dist/prompt-assembly/overlay.js +3 -3
  425. package/dist/prompt-assembly/renderers.d.ts +1 -1
  426. package/dist/prompt-assembly/renderers.js +0 -3
  427. package/dist/prompt-assembly/role-base.d.ts +15 -0
  428. package/dist/prompt-assembly/role-base.js +9 -0
  429. package/dist/prompt-assembly/select.d.ts +39 -14
  430. package/dist/prompt-assembly/select.js +47 -16
  431. package/dist/prompt-assembly/sugar.d.ts +17 -11
  432. package/dist/prompt-assembly/sugar.js +8 -3
  433. package/dist/prompt-assembly/tool-catalog.d.ts +37 -3
  434. package/dist/prompt-assembly/tool-catalog.js +114 -4
  435. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  436. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  437. package/dist/prompt-assembly/types.d.ts +0 -7
  438. package/dist/scenarios/full-body.d.ts +11 -11
  439. package/dist/scenarios/full-body.js +4 -3
  440. package/dist/shell/lex.js +10 -1
  441. package/dist/stores/file/adoption/adopt.js +4 -3
  442. package/dist/stores/file/adoption/marker.js +3 -2
  443. package/dist/stores/file/checkpoint-store.d.ts +21 -4
  444. package/dist/stores/file/checkpoint-store.js +38 -7
  445. package/dist/stores/file/file-history-store.js +18 -11
  446. package/dist/stores/file/index.js +2 -1
  447. package/dist/stores/file/mailbox-store.d.ts +2 -1
  448. package/dist/stores/file/mailbox-store.js +26 -1
  449. package/dist/stores/file/permission-rule-adopt.js +4 -3
  450. package/dist/stores/file/permission-rule-store.js +11 -5
  451. package/dist/stores/file/session-store.d.ts +29 -6
  452. package/dist/stores/file/session-store.js +42 -50
  453. package/dist/tools/artifact/artifact-tool.js +3 -2
  454. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  455. package/dist/tools/fs/bash-program-position.js +56 -9
  456. package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
  457. package/dist/tools/fs/bash-readonly-classifier.js +5 -10
  458. package/dist/tools/fs/fs-bash.js +15 -8
  459. package/dist/tools/fs/fs-glob.d.ts +86 -0
  460. package/dist/tools/fs/fs-glob.js +226 -0
  461. package/dist/tools/fs/fs-read.js +14 -14
  462. package/dist/tools/fs/fs-search-tools.js +7 -7
  463. package/dist/tools/fs/pattern-kill-guard.d.ts +23 -0
  464. package/dist/tools/fs/pattern-kill-guard.js +429 -0
  465. package/dist/tools/fs/pdf.d.ts +9 -6
  466. package/dist/tools/fs/pdf.js +3 -3
  467. package/dist/tools/fs/program-read-model.d.ts +57 -7
  468. package/dist/tools/fs/program-read-model.js +11 -1
  469. package/dist/tools/fs/program-read-model.rows.js +78 -21
  470. package/dist/tools/fs/read-deny-home.js +3 -2
  471. package/dist/tools/fs/removal-targets.d.ts +17 -7
  472. package/dist/tools/fs/removal-targets.js +47 -20
  473. package/dist/tools/fs/search.d.ts +10 -0
  474. package/dist/tools/fs/search.js +20 -26
  475. package/dist/tools/fs/shell-read-argv.js +89 -12
  476. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  477. package/dist/tools/fs/shell-read-bindings.js +41 -0
  478. package/dist/tools/fs/shell-read-check.d.ts +10 -0
  479. package/dist/tools/fs/shell-read-check.js +13 -20
  480. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  481. package/dist/tools/fs/shell-read-environment.js +3 -2
  482. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  483. package/dist/tools/fs/shell-read-establish.js +19 -20
  484. package/dist/tools/fs/shell-read-identity.d.ts +12 -9
  485. package/dist/tools/fs/shell-read-identity.js +9 -4
  486. package/dist/tools/fs/shell-read-plan.js +24 -16
  487. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  488. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  489. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  490. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  491. package/dist/tools/fs/shell-reentry-text.js +40 -2
  492. package/dist/tools/todo.js +63 -63
  493. package/dist/tools/web.d.ts +19 -14
  494. package/dist/tools/web.js +46 -61
  495. package/package.json +1 -1
  496. package/test/export-surface.snapshot.json +221 -7
  497. package/wire-changes/core-stores-sql@7.57.0.json +29 -0
  498. package/wire-changes/core@7.56.0.json +3891 -0
  499. package/wire-changes/core@7.57.0.json +1487 -0
  500. package/wire-changes/mods-kernel@7.56.0.json +303 -0
  501. package/wire-changes/mods-kernel@7.57.0.json +29 -0
  502. package/wire-changes/primitives@7.57.0.json +245 -0
@@ -284,12 +284,13 @@ function orgStateCopyOf(state) {
284
284
  function readOrgRow(row, index) {
285
285
  const { rule: text, behavior: said } = orgRowPolicyOf(row);
286
286
  const behavior = said === "ask" ? "ask" : "deny";
287
- const unreadable = (code, detail) => ({
287
+ const unreadable = (code, detail, respelling) => ({
288
288
  kind: "unreadable",
289
289
  index,
290
290
  rule: typeof text === "string" ? text : text === undefined ? "<unreadable>" : escapeForDisclosure(text),
291
291
  code,
292
292
  ...(detail !== undefined ? { detail } : {}),
293
+ ...(respelling !== undefined ? { respelling } : {}),
293
294
  behavior,
294
295
  reach: reachOfRowHead(text, behavior),
295
296
  });
@@ -299,8 +300,8 @@ function readOrgRow(row, index) {
299
300
  return unreadable("invalid.grammar", said === undefined ? "no behavior" : `behavior "${escapeForDisclosure(said)}" is not deny or ask`);
300
301
  const parsed = parseRuleText(text, said);
301
302
  if ("reject" in parsed)
302
- return unreadable(parsed.reject.code);
303
- if (parsed.rule.tool !== COMMAND_RULE_TOOL)
303
+ return unreadable(parsed.reject.code, undefined, parsed.reject.respelling);
304
+ if (parsed.rule.tool !== COMMAND_RULE_TOOL || parsed.rule.match === "tool")
304
305
  return unreadable("unsupported.tool");
305
306
  return { kind: "read", index, rule: text, behavior: said, parsed: parsed.rule };
306
307
  }
@@ -355,6 +356,9 @@ function readListedOrgRules(rules) {
355
356
  return reading;
356
357
  }
357
358
  export function unreadableOrgRowReason(row) {
359
+ if (row.respelling !== undefined) {
360
+ return `row ${row.index} of the organization snapshot, "${escapeForDisclosure(row.rule)}", is not a rule spelling (${row.code}); republish it as "${escapeForDisclosure(row.respelling)}"`;
361
+ }
358
362
  return `row ${row.index} of the organization snapshot is not a rule this layer reads (${row.code}${row.detail !== undefined ? `: ${row.detail}` : ""}); republish it in the shell tool's command grammar`;
359
363
  }
360
364
  export function orgUnreadableClause(reason) {
@@ -365,7 +369,7 @@ export function describeUnreadableOrgRows(unreadable, revision) {
365
369
  return undefined;
366
370
  const named = unreadable
367
371
  .slice(0, DISCLOSED_UNREADABLE_ROWS)
368
- .map((u) => `row ${u.index} "${escapeForDisclosure(u.rule)}" (${u.code}${u.detail !== undefined ? `: ${u.detail}` : ""})`)
372
+ .map((u) => `row ${u.index} "${escapeForDisclosure(u.rule)}" (${u.code}${u.detail !== undefined ? `: ${u.detail}` : ""}${u.respelling !== undefined ? `; republish it as "${escapeForDisclosure(u.respelling)}"` : ""})`)
369
373
  .join(", ");
370
374
  const more = unreadable.length - DISCLOSED_UNREADABLE_ROWS;
371
375
  return (`the org snapshot${revision !== undefined ? ` (revision ${escapeForDisclosure(revision)})` : ""} is served DEGRADED: ${unreadable.length} row(s) this layer cannot read — ${named}${more > 0 ? ` and ${more} more` : ""}; ` +
@@ -36,7 +36,7 @@
36
36
  */
37
37
  import type { PersistedRule, RuleScope } from "./permission-rule-model.js";
38
38
  import { type DurableRulePartitionProvider, type QuarantinedRuleAdd } from "./permission-rule-store.js";
39
- import type { RuleOwner } from "./rule-owner.js";
39
+ import { type RuleOwner } from "./rule-owner.js";
40
40
  import { type OrgRulePartitionConfig, type OrgRuleResolution } from "./permission-rule-org.js";
41
41
  import type { SessionRulePartition } from "./permission-rule-session.js";
42
42
  import type { StoreDurability, StoreFidelity } from "./checkpoint-store.js";
@@ -146,7 +146,10 @@ export interface PermissionRuleStoreProvider {
146
146
  * provider: an absent principal resolves to zero personal rules, and a provider that forgot it would hand one person's
147
147
  * standing approvals to an anonymous task. The ONE exception is an explicitly declared LOCAL-OWNER deployment, where "no
148
148
  * principal" is the typed absence of identity — the machine owner's own bucket (a provider with no such face resolves
149
- * the anonymous store; {@link createPermissionRuleLanes} refuses that declaration loudly).
149
+ * the anonymous store; {@link createPermissionRuleLanes} refuses that declaration loudly). "No principal" is ABSENCE only —
150
+ * `undefined`, and the empty string the engine has always spelled the same ({@link readPrincipal}). A principal that was provided
151
+ * and is not a name (white space, an invisible or control character) is a bad value and is refused here: read as absence it
152
+ * would be the machine owner's bucket on a local-owner deployment.
150
153
  */
151
154
  export declare function ownerStoreOf(provider: PermissionRuleStoreProvider, principal: string | undefined, localOwnerDeclared: boolean): PermissionRuleStore;
152
155
  /** What {@link createPermissionRuleStoreProvider} composes. */
@@ -1,17 +1,39 @@
1
- import { escapeForDisclosure } from "./permission-rule-model.js";
1
+ import { escapeForDisclosure, isRuleBehavior, parseRuleText } from "./permission-rule-model.js";
2
2
  import { PERMISSION_RULE_WRITER, errText, isValidDurableScope, normalizePersistedRule, sameRuleIdentity, writerOf, } from "./permission-rule-store.js";
3
+ import { readRuleOwner } from "./rule-owner.js";
4
+ import { readPrincipal } from "./principal-name.js";
3
5
  import { UNGOVERNED_ORG_RESOLUTION, compileOrgShadowPredicate, createOrgRulePartition } from "./permission-rule-org.js";
4
6
  export function ruleSourceOf(scope) {
5
7
  return scope.kind === "global" ? "user" : scope.kind;
6
8
  }
7
9
  export function ownerStoreOf(provider, principal, localOwnerDeclared) {
8
- const anonymous = principal === undefined || principal === "";
9
- return anonymous && localOwnerDeclared && provider.forLocalOwner !== undefined ? provider.forLocalOwner() : provider.forPrincipal(anonymous ? undefined : principal);
10
+ const reading = readPrincipal(principal);
11
+ if (reading.kind === "invalid") {
12
+ throw new Error(`the principal given is not a principal name (got ${reading.fault}) — refusing to resolve a bucket for it; a provided value that names nobody is not "no principal"`);
13
+ }
14
+ if (reading.kind === "name")
15
+ return provider.forPrincipal(reading.name);
16
+ return localOwnerDeclared && provider.forLocalOwner !== undefined ? provider.forLocalOwner() : provider.forPrincipal(undefined);
10
17
  }
11
18
  function usableSessionId(sessionId) {
12
19
  return typeof sessionId === "string" && sessionId !== "" ? sessionId : undefined;
13
20
  }
14
21
  const EMPTY_DURABLE = { rules: [], tombstones: [], rev: 0 };
22
+ function durableReadOf(settled) {
23
+ if (!settled.ok)
24
+ return settled;
25
+ for (const [kind, rows] of [["rule", settled.v.rules], ["tombstone", settled.v.tombstones]]) {
26
+ const at = rows.findIndex((r) => !isRuleBehavior(r?.behavior));
27
+ if (at < 0)
28
+ continue;
29
+ const row = rows[at];
30
+ return {
31
+ ok: false,
32
+ e: new Error(`the persisted rule partition served a ${kind} row (#${at}, ${escapeForDisclosure(row?.rule)}) whose behavior word ${escapeForDisclosure(row?.behavior)} is outside deny/ask/allow — whether it refuses a call is unknown, so the partition is read as one that could not be read`),
33
+ };
34
+ }
35
+ return settled;
36
+ }
15
37
  export function createPermissionRuleStoreProvider(cfg) {
16
38
  if (cfg === null || typeof cfg !== "object") {
17
39
  throw new Error("createPermissionRuleStoreProvider takes a config object naming the partitions to compose");
@@ -61,7 +83,7 @@ class UnifiedPermissionRuleStore {
61
83
  const disclosures = [];
62
84
  const [orgSettled, durableSettled, sessionRows] = await Promise.all([
63
85
  this.org !== undefined ? this.org.resolve() : Promise.resolve({ ...UNGOVERNED_ORG_RESOLUTION, rules: [], disclosures: [] }),
64
- this.durable !== undefined ? this.durable.list().then((v) => ({ ok: true, v }), (e) => ({ ok: false, e })) : Promise.resolve({ ok: true, v: EMPTY_DURABLE }),
86
+ this.durable !== undefined ? this.durable.list().then((v) => durableReadOf({ ok: true, v }), (e) => ({ ok: false, e })) : Promise.resolve({ ok: true, v: EMPTY_DURABLE }),
65
87
  this.readSessionRows(usableSessionId(query?.sessionId), disclosures),
66
88
  ]);
67
89
  const orgResolution = orgSettled;
@@ -106,7 +128,7 @@ class UnifiedPermissionRuleStore {
106
128
  const served = structuredClone(await this.session.read(sessionId));
107
129
  const rows = served.filter((r) => {
108
130
  const scope = r?.scope;
109
- return scope?.kind === "session" && scope.sessionId === sessionId && !("reject" in normalizePersistedRule(r));
131
+ return scope?.kind === "session" && scope.sessionId === sessionId && (!("reject" in normalizePersistedRule(r)) || ((r.behavior === "deny" || r.behavior === "ask") && "reject" in parseRuleText(r.rule, r.behavior)));
110
132
  });
111
133
  if (rows.length < served.length) {
112
134
  disclosures.push(`the session rule partition served ${served.length - rows.length} row(s) that are not canonical session rows of this session — dropped, not adjudicated`);
@@ -157,8 +179,17 @@ export async function effectivePermissionRules(opts) {
157
179
  return await resolveOwnerStore(opts).effective(opts.sessionId !== undefined ? { sessionId: opts.sessionId } : undefined);
158
180
  }
159
181
  export function resolveOwnerStore(opts) {
160
- if (opts.owner !== undefined && opts.owner.kind === "local-owner") {
161
- if (opts.principal !== undefined) {
182
+ const owner = opts.owner === undefined ? undefined : readRuleOwner(opts.owner);
183
+ if (opts.owner !== undefined && owner === undefined) {
184
+ throw new Error("the owner given is neither a principal nor the local owner (a principal owner names a principal name) — refusing to resolve a bucket nobody can name");
185
+ }
186
+ const given = readPrincipal(opts.principal);
187
+ if (given.kind === "invalid") {
188
+ throw new Error(`the principal given is not a principal name (got ${given.fault}) — pass a verified principal, the local owner, or neither; a provided value that names nobody is not "no principal"`);
189
+ }
190
+ const principal = given.kind === "name" ? given.name : undefined;
191
+ if (owner?.kind === "local-owner") {
192
+ if (principal !== undefined) {
162
193
  throw new Error("pass either a principal or a local-owner, not both — a bucket has one owner");
163
194
  }
164
195
  const store = opts.provider.forLocalOwner?.();
@@ -167,9 +198,8 @@ export function resolveOwnerStore(opts) {
167
198
  }
168
199
  return store;
169
200
  }
170
- if (opts.owner !== undefined && opts.owner.kind === "principal" && opts.principal !== undefined && opts.owner.principal !== opts.principal) {
171
- throw new Error(`contradictory identity: principal "${escapeForDisclosure(opts.principal)}" and owner principal "${escapeForDisclosure(opts.owner.principal)}" disagree`);
201
+ if (owner?.kind === "principal" && principal !== undefined && owner.principal !== principal) {
202
+ throw new Error(`contradictory identity: principal "${escapeForDisclosure(principal)}" and owner principal "${escapeForDisclosure(owner.principal)}" disagree`);
172
203
  }
173
- const principal = opts.owner?.kind === "principal" ? opts.owner.principal : opts.principal;
174
- return opts.provider.forPrincipal(principal);
204
+ return opts.provider.forPrincipal(owner?.kind === "principal" ? owner.principal : principal);
175
205
  }
@@ -45,7 +45,7 @@ import type { PersistedRule, RuleAdd, RuleDot, RuleScope, RuleTombstone } from "
45
45
  import { type RuleBehavior } from "./permission-rule-model.js";
46
46
  import type { RuleSyncDropReason, RuleQuarantineReason } from "./governance-codes.js";
47
47
  import type { StoreDurability, StoreFidelity } from "./checkpoint-store.js";
48
- import type { RuleOwner } from "./rule-owner.js";
48
+ import { type RuleOwner } from "./rule-owner.js";
49
49
  /** One store read: the rules as persisted, their tombstones, and the revision they were read at. */
50
50
  export interface StoredRules {
51
51
  /** Rules with their FULL add sets — tombstoned dots already removed by the backend on read. */
@@ -93,7 +93,8 @@ export interface DurableRulePartition {
93
93
  /** Declared serialization fidelity, same doctrine as the other store families. */
94
94
  readonly fidelity?: StoreFidelity;
95
95
  }
96
- /** Resolves one owner's durable partition. `undefined` ⇒ a partition that reports zero rules. This is
96
+ /** Resolves one owner's durable partition. `undefined` — or anything that is not a principal name
97
+ * (`principalNameOf`: the empty and the blank string included) ⇒ a partition that reports zero rules. This is
97
98
  * the BACKEND contract (file, in-memory, an out-of-repo SQL twin); the engine never consumes it
98
99
  * directly — `createPermissionRuleStoreProvider({ durable })` composes it into the unified store. */
99
100
  export interface DurableRulePartitionProvider {
@@ -1,6 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { canonicalize } from "./canonical-json.js";
3
3
  import { escapeForDisclosure, isRuleBehavior, isRuleLive, parseRuleText } from "./permission-rule-model.js";
4
+ import { readRuleOwner } from "./rule-owner.js";
4
5
  import { thrownText } from "./thrown-value.js";
5
6
  import { validatePath } from "./effective-path-target.js";
6
7
  export const PERMISSION_RULES_LATER_GRAMMAR_CODE = "permission_rules.later_grammar";
@@ -510,6 +511,10 @@ async function readRuleLiveness(store, identity) {
510
511
  }
511
512
  }
512
513
  const REMOVE_MAX_ATTEMPTS = 8;
514
+ const NO_TARGET_OWNER = "the principal given is neither a principal name (a string with a visible character, no control or separator character, and no format character but a joiner) nor an owner (a principal owner names a principal name; the local owner is { kind: \"local-owner\" })";
515
+ function persistedRuleTargetOwner(target) {
516
+ return readRuleOwner(typeof target === "string" ? { kind: "principal", principal: target } : target);
517
+ }
513
518
  export async function removePersistedRule(opts) {
514
519
  const behavior = opts.behavior;
515
520
  const rule = opts.rule;
@@ -519,7 +524,9 @@ export async function removePersistedRule(opts) {
519
524
  return { status: "failed", error: `removePersistedRule: behavior ${escapeForDisclosure(behavior)} is not one of ${["deny", "ask", "allow"].join("/")} — refusing to name a rule identity nothing can carry`, committed: "no" };
520
525
  }
521
526
  const identity = { behavior, rule, scope };
522
- const owner = typeof target === "string" ? { kind: "principal", principal: target } : structuredClone(target);
527
+ const owner = persistedRuleTargetOwner(target);
528
+ if (owner === undefined)
529
+ return { status: "failed", error: `removePersistedRule: ${NO_TARGET_OWNER} — refusing to remove from a bucket nobody can name`, committed: "no" };
523
530
  const provider = opts.provider;
524
531
  if (scope?.kind === "session") {
525
532
  return {
@@ -686,7 +693,9 @@ export async function addPersistedRule(opts) {
686
693
  if ("reject" in parsed)
687
694
  return { status: "failed", error: `addPersistedRule: ${parsed.reject.code}: ${parsed.reject.message}`, committed: "no" };
688
695
  const identity = { behavior, rule: parsed.rule.rule, scope };
689
- const owner = typeof target === "string" ? { kind: "principal", principal: target } : structuredClone(target);
696
+ const owner = persistedRuleTargetOwner(target);
697
+ if (owner === undefined)
698
+ return { status: "failed", error: `addPersistedRule: ${NO_TARGET_OWNER} — refusing to write into a bucket nobody can name`, committed: "no" };
690
699
  const provider = opts.provider;
691
700
  if (owner.kind === "local-owner" && provider.forLocalOwner === undefined) {
692
701
  return { status: "failed", error: "this provider has no local-owner bucket (forLocalOwner is not implemented) — a local-owner rule cannot be added through it", committed: "no" };
@@ -1,4 +1,5 @@
1
1
  import { escapeForDisclosure, isRuleBehavior, parseRuleText, RULE_ADD_ORIGINS } from "./permission-rule-model.js";
2
+ import { principalNameOf } from "./principal-name.js";
2
3
  import { PERMISSION_RULES_LATER_GRAMMAR_CODE, applyTombstones, errText, isProjectScopeRoot, joinFrontiers, joinRuleStates, normalizePersistedRule, readRuleWriteOutcome, ruleSyncVector, sameRuleIdentity, screenRuleSyncState, writerOf, } from "./permission-rule-store.js";
3
4
  import { emitTrace } from "./trace.js";
4
5
  import { SESSION_RULES_GRAMMAR, readRuleGrammarStamp } from "./session-policy-store.js";
@@ -23,8 +24,8 @@ export async function syncPermissionRules(opts) {
23
24
  throw new Error(`contradictory identity: principal "${escapeForDisclosure(principal)}" and owner principal "${escapeForDisclosure(owner.principal)}" disagree`);
24
25
  }
25
26
  }
26
- if (typeof principal !== "string" || principal === "") {
27
- throw new Error("syncPermissionRules requires a verified principal — an unauthenticated deployment has no cloud bucket to sync");
27
+ if (principalNameOf(principal) === undefined) {
28
+ throw new Error("syncPermissionRules requires a verified principal — an unauthenticated deployment has no cloud bucket to sync (a blank name, or one holding a control, separator or invisible format character, is not a principal)");
28
29
  }
29
30
  const traceClock = opts.now ?? Date.now;
30
31
  const disclose = (result) => {
@@ -29,10 +29,11 @@ export declare function lastIndexOfUnescaped(s: string, ch: string): number;
29
29
  */
30
30
  export declare function parsePermissionRule(rule: string): ParsedPermissionRule;
31
31
  /**
32
- * Can a rule name this tool name — is it the rule syntax's name head ({@link RULE_TOOL_NAME}) and not the lone `*`? The
33
- * lone `*` is the wildcard (every tool), not a name: a tool called `*` could never be granted or refused on its own. The
34
- * mount contract for every name a caller tool answers to (its name and each alias), so each one is a name every list can
35
- * write; a protocol-minted name (`<ns>__<peer>__<tool>`, segments in `[A-Za-z0-9_-]`) is always one.
32
+ * Can a rule name this tool name — is it the rule syntax's name head ({@link RULE_TOOL_NAME}) with no `*` in it? A `*` makes a
33
+ * spelling a glob over names, not a name: a tool whose name held one would be reached by every rule whose glob matches it and
34
+ * could never be named on its own (the reference's mount spelling holds no `*` either). The mount contract for every name a
35
+ * caller tool answers to (its name and each alias), so each one is a name every list can write; a protocol-minted name
36
+ * (`<ns>__<peer>__<tool>`, segments in `[A-Za-z0-9_-]`) is always one.
36
37
  */
37
38
  export declare function isNameableToolName(name: string): boolean;
38
39
  /**
@@ -36,9 +36,9 @@ export function parsePermissionRule(rule) {
36
36
  return { toolName: name.trim() };
37
37
  return { toolName: name.trim(), ruleContent: unescapeRuleContent(content) };
38
38
  }
39
- const RULE_TOOL_NAME = /^(?:\*|[A-Za-z0-9_](?:[A-Za-z0-9_.:*-]*[A-Za-z0-9_*-])?)$/;
39
+ const RULE_TOOL_NAME = /^[A-Za-z0-9_*](?:[A-Za-z0-9_.:*-]*[A-Za-z0-9_*-])?$/;
40
40
  export function isNameableToolName(name) {
41
- return typeof name === "string" && name !== "*" && RULE_TOOL_NAME.test(name);
41
+ return typeof name === "string" && !name.includes("*") && RULE_TOOL_NAME.test(name);
42
42
  }
43
43
  export function ruleSpellingOf(rule) {
44
44
  if (rule !== rule.trim())
@@ -90,8 +90,8 @@ export interface PermissionRuleIssue {
90
90
  /** A rule the rule syntax reads no rule in (`ruleSpellingOf`) whose name is the reason: blanks around the rule, a
91
91
  * character outside a tool name's spelling (a variation selector, a filler, a zero-width space), a blank or an invisible
92
92
  * character before the `(`, a leading `-`. Refused — the lenient reading would deny a tool under another spelling, or none.
93
- * Also a rule whose tool name the syntax reads as the wildcard `*` (`*`, `*()`, `*(*)`): a rule reaches the tool it
94
- * names, and `*` names none. */
93
+ * (A `*` in a tool name is no such spelling: a deny or ask rule reads it as a glob over the whole name, `*` alone as every
94
+ * tool.) */
95
95
  | "invalid.tool_name" | "invalid.param_split" | "invalid.primary_field" | "invalid.cap_exceeded"
96
96
  /** An ALLOW rule (any spelling): a policy fold says deny / ask only — "this does not need asking" is the allow
97
97
  * layer's (`TaskSpec.allowedTools`, `RunnerDeps.allowedTools`). One issue per allow rule. */
@@ -206,8 +206,8 @@ export interface PermissionRulePolicyOptions {
206
206
  */
207
207
  pathBases?: PathRuleBases;
208
208
  }
209
- import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
210
- export { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch };
209
+ import { isCoveringRuleName, ruleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
210
+ export { isCoveringRuleName, ruleNameCovers, wildcardMatch };
211
211
  /**
212
212
  * design/388 A-6/7/8/9 (D-3): the per-tool RULE FACE — the parameters a `Tool(param:pattern)` rule may name
213
213
  * (`params`, the SCALAR top-level keys ∪ the path target's aliases), the ones the generic lexical matcher must
@@ -1,5 +1,5 @@
1
1
  import { attest } from "./tool-policy.js";
2
- import { MCP_NAMESPACE, protocolOf } from "./protocol-table.js";
2
+ import { MCP_NAMESPACE } from "./protocol-table.js";
3
3
  import { catalogRuleFaceOf, isShellFaceToolName, pathTargetOf } from "./tool-registry.js";
4
4
  import { HOST_UNREADABLE_SENTENCE, callHostTargetOf } from "./host-target.js";
5
5
  import { indexOfUnescaped, lastIndexOfUnescaped, parsePermissionRule, ruleSpellingOf } from "./permission-rule-syntax.js";
@@ -36,9 +36,8 @@ export const DEFAULT_CAPS = {
36
36
  maxStars: 16,
37
37
  maxScalarValueChars: DEFAULT_MAX_SCALAR_VALUE_CHARS,
38
38
  };
39
- import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
40
- import { wildcardPeerRefusalOf } from "./tool-name-aliases.js";
41
- export { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch };
39
+ import { isCoveringRuleName, ruleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
40
+ export { isCoveringRuleName, ruleNameCovers, wildcardMatch };
42
41
  const vocabularyOf = (face) => face.params ?? face.primaryParams;
43
42
  const carriedPhrase = (face) => {
44
43
  const vocabulary = vocabularyOf(face);
@@ -119,22 +118,13 @@ function compile(rules, caps, primaryFieldGeneric, ruleFaces, pathBases = {}) {
119
118
  bad(text, why.code, why.message);
120
119
  continue;
121
120
  }
122
- if (parsed.toolName === "*") {
123
- bad(text, "invalid.tool_name", "`*` names no tool — a rule reaches the tool it names, so this one would compile and never match; name the tool", { name: "defaultAction" });
124
- continue;
125
- }
126
121
  const toolName = parsed.toolName;
127
122
  const parenthesised = parsed.ruleContent !== undefined || indexOfUnescaped(text, "(") !== -1;
128
123
  if (toolName.startsWith(MCP_NAMESPACE.prefix) && parenthesised) {
129
124
  bad(text, "unsupported.mcp_paren", "MCP rules do not support patterns in parentheses (CC parity); a rule names a whole tool (`mcp__<server>__<tool>`) or a whole server (`mcp__<server>`), and what a tool does is declared per tool in the MCP server's spec", { name: "toolAxes" });
130
125
  continue;
131
126
  }
132
- const wildPeer = wildcardPeerRefusalOf(toolName, verb);
133
- if (wildPeer !== undefined) {
134
- bad(text, "invalid.tool_name", wildPeer);
135
- continue;
136
- }
137
- if (parenthesised && isNamespacedCoveringRuleName(toolName, verb)) {
127
+ if (ruleContentOf(parsed) !== undefined && isCoveringRuleName(toolName, verb)) {
138
128
  bad(text, "unsupported.covering_paren", `"${toolName}" reaches a SET of tools, and the generic param DSL is keyed by exact tool name — a parenthesised rule on it can never match. ` +
139
129
  `Write the parenthesised rule against one exact tool name, or drop the parentheses to keep the covering rule.`);
140
130
  continue;
@@ -142,7 +132,7 @@ function compile(rules, caps, primaryFieldGeneric, ruleFaces, pathBases = {}) {
142
132
  const entry = byTool.get(toolName) ?? { bare: {}, param: { deny: [], ask: [] }, content: { deny: [], ask: [] } };
143
133
  const content = ruleContentOf(parsed);
144
134
  if (content === undefined) {
145
- if (isNamespacedCoveringRuleName(toolName, verb)) {
135
+ if (isCoveringRuleName(toolName, verb)) {
146
136
  namespacedCovering[verb].push({ ruleName: toolName, ruleText: text, ...(r.source !== undefined ? { source: r.source } : {}) });
147
137
  continue;
148
138
  }
@@ -339,7 +329,8 @@ export function createPermissionRulePolicy(rules, opts) {
339
329
  for (const r of namespacedCovering[behavior])
340
330
  nameSets[behavior].push(r.ruleName);
341
331
  }
342
- const coveringHit = (lane, toolName) => lane.length === 0 ? undefined : lane.find((r) => namespacedRuleNameCovers(r.ruleName, toolName));
332
+ const heldFor = (table, req) => heldValues("policy.permissionRules", table, req);
333
+ const coveringHit = (lane, req) => lane.length === 0 ? undefined : heldFor({ get: (name) => lane.find((r) => ruleNameCovers(r.ruleName, name)) }, req)[0];
343
334
  const hasCovering = namespacedCovering.deny.length > 0 || namespacedCovering.ask.length > 0;
344
335
  const faceRules = {
345
336
  deny: [...byTool.values()].flatMap((e) => e.content.deny.filter((r) => r.faces !== undefined)),
@@ -454,7 +445,7 @@ export function createPermissionRulePolicy(rules, opts) {
454
445
  requiresRealApproval: true,
455
446
  });
456
447
  const entryFor = (req) => {
457
- const entries = heldValues("policy.permissionRules", byTool, req);
448
+ const entries = heldFor(byTool, req);
458
449
  if (entries.length <= 1)
459
450
  return entries[0];
460
451
  const bare = {};
@@ -474,12 +465,12 @@ export function createPermissionRulePolicy(rules, opts) {
474
465
  ...(pathSpecs.length > 0 ? { pathRules: (anchors) => boundAt(policyAnchors(pathBases, anchors)).rows } : {}),
475
466
  check(req) {
476
467
  const entry = entryFor(req);
477
- const covering = hasCovering && protocolOf(req.toolName) !== undefined;
468
+ const covering = hasCovering;
478
469
  if (entry?.bare.deny) {
479
470
  return { action: "deny", message: ruleDenial(req, entry.bare.deny.ruleText, entry.bare.deny.source) };
480
471
  }
481
472
  if (covering) {
482
- const coveringDeny = coveringHit(namespacedCovering.deny, req.toolName);
473
+ const coveringDeny = coveringHit(namespacedCovering.deny, req);
483
474
  if (coveringDeny)
484
475
  return { action: "deny", message: ruleDenial(req, coveringDeny.ruleText, coveringDeny.source) };
485
476
  }
@@ -509,7 +500,7 @@ export function createPermissionRulePolicy(rules, opts) {
509
500
  }
510
501
  }
511
502
  if (covering) {
512
- const coveringAsk = coveringHit(namespacedCovering.ask, req.toolName);
503
+ const coveringAsk = coveringHit(namespacedCovering.ask, req);
513
504
  if (coveringAsk)
514
505
  return { action: "ask", message: ruleAskMessage(coveringAsk.ruleText, coveringAsk.source), matchedAskRule: coveringAsk.ruleText };
515
506
  }
@@ -44,7 +44,7 @@ export declare function disclosedRuleSet(rules: readonly PersistedRuleHitRule[])
44
44
  * lane's allow carries: one authority, one word) and the rule text disclosed through the display
45
45
  * transform; the STATION attributes the refusal (`tightened: "deny"` ⇒ it writes the pass's refusing
46
46
  * layer — the attribution is a station's word and lives in the station file). A path row's hit reports where
47
- * it met the call; with `call` given and the face the call's own, the deny carries that as its attested `pathDenial`, so every exit that
47
+ * it met the call; with the face the call's own (`call`, the request the lane read), the deny carries that as its attested `pathDenial`, so every exit that
48
48
  * reads the deny (the gate's exit, the approved-edit re-check, a resumed leg's belt) mints the same card from the same fact.
49
49
  * · ASK — on an allow, a fresh ask is minted carrying `matchedAskRule` (the marker an explicit `ask`
50
50
  * permission rule stamps, so the ask's origin derives as `ask_rule`: the classifier never answers
@@ -69,7 +69,7 @@ export declare function disclosedRuleSet(rules: readonly PersistedRuleHitRule[])
69
69
  * resumed-call belt, which vetoes only the call form: a person already answered that call's question.
70
70
  * An allow hit (or no hit) returns the decision untouched: the allow arm is the station's.
71
71
  */
72
- export declare function applyPersistedTightening(decision: PermissionResult, read: PersistedRuleRead | undefined, call?: ToolCallRequest): {
72
+ export declare function applyPersistedTightening(decision: PermissionResult, read: PersistedRuleRead | undefined, call: ToolCallRequest): {
73
73
  decision: PermissionResult;
74
74
  tightened?: "deny" | "ask" | "unreadable" | "store_unreadable";
75
75
  };
@@ -1,6 +1,6 @@
1
- import { attest } from "./tool-policy.js";
1
+ import { attest, attestationOf } from "./tool-policy.js";
2
2
  import { callPathFaceOf } from "./permission-rule-model.js";
3
- import { decisionAskClassesOf } from "./ask-origin.js";
3
+ import { ownAskClassesOf } from "./ask-origin.js";
4
4
  import { inlineUntrusted } from "./untrusted-text.js";
5
5
  export function strongestAnswer(answers) {
6
6
  const rank = (a) => (a === undefined ? 0 : "unreadable" in a ? 4 : "behavior" in a ? { deny: 5, ask: 3, allow: 2 }[a.behavior] : 1);
@@ -20,15 +20,13 @@ export function applyPersistedTightening(decision, read, call) {
20
20
  ? `this call could not be read against the person's standing deny/ask rules (${read.reason}) — whether one of them forbids it is unknown, so it needs a real approval`
21
21
  : "the person's standing permission rules could not be read — whether one of them forbids this call is unknown, so it needs a real approval";
22
22
  const unreadableCall = callForm ? { ruleUnreadable: "persisted_call" } : {};
23
- const standingFence = decision.action === "ask" && decisionAskClassesOf({ ...decision, foldedAskClasses: undefined }).has("policy_rra")
24
- ? { foldedAskClasses: [...(decision.foldedAskClasses ?? []), "policy_rra"] }
25
- : {};
26
- return {
27
- decision: decision.action === "allow"
28
- ? { action: "ask", message, decisionReason: "persisted_rule", requiresRealApproval: true, ...unreadableCall, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) }
29
- : { ...decision, requiresRealApproval: true, ...unreadableCall, ...standingFence, message: `${decision.message !== undefined ? `${decision.message} ` : ""}(${message})` },
30
- tightened: callForm ? "unreadable" : "store_unreadable",
31
- };
23
+ const tightened = callForm ? "unreadable" : "store_unreadable";
24
+ if (decision.action === "allow") {
25
+ return { decision: { action: "ask", message, decisionReason: "persisted_rule", requiresRealApproval: true, ...unreadableCall, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) }, tightened };
26
+ }
27
+ const record = attestationOf(decision, call);
28
+ const asked = { ...decision, requiresRealApproval: true, ...unreadableCall, message: `${decision.message !== undefined ? `${decision.message} ` : ""}(${message})` };
29
+ return { decision: ownAskClassesOf(decision, record).has("policy_rra") ? attest(asked, call, { foldedClasses: [...new Set([...(record?.foldedClasses ?? []), "policy_rra"])] }) : asked, tightened };
32
30
  }
33
31
  const hit = read?.hit;
34
32
  if (hit === undefined || hit.behavior === "allow")
@@ -36,7 +34,7 @@ export function applyPersistedTightening(decision, read, call) {
36
34
  const shown = disclosedRuleSet(hit.rules);
37
35
  if (hit.behavior === "deny") {
38
36
  const denied = { action: "deny", message: `a persisted deny rule (${shown}) refuses this call`, decisionReason: "persisted_rule" };
39
- const attested = hit.denial !== undefined && call !== undefined && hit.denial.face === callPathFaceOf(call);
37
+ const attested = hit.denial !== undefined && hit.denial.face === callPathFaceOf(call);
40
38
  return { decision: attested ? attest(denied, call, { pathDenial: hit.denial }) : denied, tightened: "deny" };
41
39
  }
42
40
  if (decision.action === "deny")
@@ -0,0 +1,20 @@
1
+ export declare function principalNameOf(raw: unknown): string | undefined;
2
+ /** What a value offered as THE principal of a task or of a lookup is — read once, here, so no face decides it on its own. */
3
+ export type PrincipalReading = {
4
+ readonly kind: "name";
5
+ readonly name: string;
6
+ } | {
7
+ readonly kind: "absent";
8
+ } | {
9
+ readonly kind: "invalid";
10
+ readonly fault: string;
11
+ };
12
+ /**
13
+ * A principal offered to a face that tolerates having none: `name` (a principal name), `absent` (no principal — `undefined`, and the
14
+ * empty string, which the task door and the bucket resolvers have always spelled the same), or `invalid` (it was PROVIDED and is not a name). Only absence reaches
15
+ * the unauthenticated floor, or the declared local owner's bucket; an invalid value is a bad value, refused where a principal is taken
16
+ * (never read as absence — a caller who appends one invisible character to a principal must not become the machine owner).
17
+ */
18
+ export declare function readPrincipal(raw: unknown): PrincipalReading;
19
+ /** Why a value is not a principal name, as a clause for a refusal sentence: the kind of string it is, or the type of the value. */
20
+ export declare function principalNameFault(raw: unknown): string;
@@ -0,0 +1,22 @@
1
+ const NOT_IN_A_NAME = /[\p{Cc}\p{Zl}\p{Zp}]|(?![\u200c\u200d])\p{Cf}/u;
2
+ const NOT_VISIBLE = /[\s\p{Cf}]+/gu;
3
+ export function principalNameOf(raw) {
4
+ return typeof raw === "string" && raw.replace(NOT_VISIBLE, "") !== "" && !NOT_IN_A_NAME.test(raw) ? raw : undefined;
5
+ }
6
+ export function readPrincipal(raw) {
7
+ if (raw === undefined || raw === "")
8
+ return { kind: "absent" };
9
+ const name = principalNameOf(raw);
10
+ return name !== undefined ? { kind: "name", name } : { kind: "invalid", fault: principalNameFault(raw) };
11
+ }
12
+ export function principalNameFault(raw) {
13
+ if (typeof raw !== "string")
14
+ return raw === null ? "null" : typeof raw;
15
+ if (raw === "")
16
+ return "an empty string";
17
+ if (raw.trim() === "")
18
+ return "a blank string";
19
+ if (raw.replace(NOT_VISIBLE, "") === "")
20
+ return "a string with no visible character";
21
+ return "a string holding a control, separator or format character";
22
+ }
@@ -1,16 +1,14 @@
1
1
  import { bandOf } from "../prompt-assembly/bands.js";
2
- import { lockedTextIn, receivePromptData } from "../prompt-assembly/overlay.js";
2
+ import { lockedTextIn } from "../prompt-assembly/overlay.js";
3
+ import { isPlainRecord } from "./mods/kernel/receive.js";
3
4
  import { inlineUntrusted } from "./untrusted-text.js";
4
5
  import { egressThrownText, extensionWords } from "./untrusted-egress.js";
5
6
  export const DISPOSABLE_PROMPT_SECTIONS = Object.freeze(["core/discovery.mcp-instructions"]);
6
7
  const DEFECT_MAX = 600;
7
8
  function readAnswer(answer, seat) {
8
- if (typeof answer !== "object" || answer === null || Array.isArray(answer))
9
+ if (!isPlainRecord(answer))
9
10
  return `answered ${answer === null ? "null" : Array.isArray(answer) ? "an array" : typeof answer}; prompt.section takes { text: string | null }`;
10
- const received = receivePromptData(answer);
11
- if ("notData" in received)
12
- return `a prompt.section answer is data (plain objects, arrays, strings, booleans); it holds ${received.notData}`;
13
- const data = received.value;
11
+ const data = answer;
14
12
  const keys = Object.keys(data);
15
13
  const stray = keys.filter((k) => k !== "text");
16
14
  if (stray.length > 0)
@@ -10,10 +10,11 @@
10
10
  * A declaration that breaks the rule is that peer's defect: the resolver throws inside the peer's own dial,
11
11
  * so the peer is skipped with a coded warning and its siblings still mount. The MCP transport binds its
12
12
  * endpoint by dialing only the declared URL with redirects not followed (`declaredEndpointFetch`); the A2A
13
- * peer, whose card may name another endpoint, is bound by {@link assertEndpointBound} and by
14
- * {@link redirectPolicy}.
13
+ * peer, whose card may name another endpoint, is bound by {@link assertEndpointBound} and by its follow law (a request carrying
14
+ * declared headers follows no redirect, {@link carriesDeclaredHeaders}).
15
15
  */
16
16
  import type { ProtocolId } from "./protocol-table.js";
17
+ import { type Egress } from "./untrusted-egress.js";
17
18
  /** The per-peer HTTP auth declaration every protocol spec carries in the same two fields. */
18
19
  export interface ProtocolHttpAuth {
19
20
  headers?: Record<string, string>;
@@ -35,10 +36,44 @@ export declare function resolveProtocolHttpHeaders(protocol: ProtocolId, t: Prot
35
36
  /** The engine's default request headers under the declared ones: a declared name, in any case, owns that header
36
37
  * (the default of the same name is not sent beside it). */
37
38
  export declare function underDeclaredHeaders(defaults: Readonly<Record<string, string>>, declared: Record<string, string> | undefined): Record<string, string>;
38
- /** Whether a resolved header set carries anything the declaration bound to its endpoints. */
39
+ /**
40
+ * Every header VALUE one HTTP peer's requests carry, whatever the header's NAME: each string value of the declaration's static
41
+ * `headers` and the principal the engine sends under `principalHeader`, as declared. The transport knows these; the credential vocabulary
42
+ * can only guess by name. How an endpoint can print one back — edges dropped, its credentials part, percent-encoded — is derived from
43
+ * each value by {@link requestEchoSpellings}, once, and nowhere else.
44
+ * Total: a declaration whose members cannot be read yields what could be read, because it is called on a failure path.
45
+ */
46
+ export declare function declaredHeaderValues(transport: unknown, principal?: string): readonly string[];
47
+ /**
48
+ * A peer's error text with what the peer was SENT taken out of it. Both kinds of removal are found on the ORIGINAL text (so no marker is
49
+ * rescanned and no replacement can disturb what another one reads) and the ranges they take are merged, one marker per merged range: every
50
+ * occurrence of a declared value in any spelling {@link requestEchoSpellings} derives from it (as declared and as sent, its credentials
51
+ * part, JSON-escaped with or without `\/`, percent-encoded, form-urlencoded, `+` for a space), in any letter case, longest first, and every `Cookie` / `Set-Cookie` member
52
+ * whole — a header line to its end, a record member's string, array or object to its close. The two never disarm each other: a declared
53
+ * value that lies wholly inside a Cookie member's NAME leaves the name (and the member's value is still taken); one that overlaps the name
54
+ * from outside takes its own range and the member's value goes with it. A declared value that is also an ordinary word or number (`en`, `1`,
55
+ * `application/json`) goes wherever it occurs in the remote's words, in any case — a legibility cost, never a leak; the failure's closed
56
+ * fields (code, status, delivery) are not text. A declaration too large for one matcher (tens of thousands of characters, which no header
57
+ * carries) makes the whole text the marker: the pass never throws and never shows what it could not match. A hit that lies wholly inside
58
+ * a marker a pass already wrote (the exact literals, `redactionMarkerSpans`) is no hit, and one that reaches into a marker takes the
59
+ * whole marker with it, so the pass over its own output answers the same text.
60
+ */
61
+ export declare function scrubRequestEcho(text: string, declared: readonly string[]): string;
62
+ /**
63
+ * THE one form a remote endpoint's words take when the engine carries them in its own words — an MCP server's failure, a model
64
+ * provider's error body, frame or transport failure, a memory distiller seat's failure: what the request was declared with
65
+ * ({@link scrubRequestEcho}: `declared` is required, so no mint reads a remote's words without naming its request), then the credential
66
+ * vocabulary. Words with no declared value in them read exactly as the vocabulary renders them. Where a declared value is there, the
67
+ * values the vocabulary finds in the ORIGINAL words are taken out with it, so neither disarms the other: removing a declared `Bearer`
68
+ * cannot hide the token after it from the vocabulary, and the vocabulary rewriting part of a declared value cannot leave the rest. A
69
+ * caller that bounds the text for display cuts what this returns, never the remote's raw words, so a cut can leave no part of a value.
70
+ * The function is a fixed point (its own output answers the same text). A store, a log or an event lane that receives the result does
71
+ * not redact again: persistence is not an exit, the mint is.
72
+ */
73
+ export declare function remoteWords(text: string, declared: readonly string[]): Egress<"same-principal">;
74
+ /** Whether a resolved header set carries anything the declaration bound to its endpoints — a request that does follows no redirect (the
75
+ * next hop is not a declared endpoint; A2A's follow law reads this). */
39
76
  export declare function carriesDeclaredHeaders(headers: Record<string, string> | undefined): boolean;
40
- /** A request carrying declared headers does not follow a redirect (the next hop is not a declared endpoint). */
41
- export declare function redirectPolicy(headers: Record<string, string> | undefined): "manual" | "follow";
42
77
  /**
43
78
  * Refuse an endpoint a peer advertised (an A2A card's interface URL) when it lies outside every origin the
44
79
  * declaration names and the peer's requests carry declared headers: `config.protocol_endpoint_unbound`.