@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
@@ -0,0 +1,52 @@
1
+ {
2
+ "repo": "core",
3
+ "package": "@sema-agent/mods-kernel",
4
+ "version": "7.71.0",
5
+ "from": "251a7e3f266181e5433a0126aeb697378f358c3b",
6
+ "to": "v7.71.0",
7
+ "added": [
8
+ {
9
+ "name": "MODS_REGISTRATION_REFUSED_DEPLOYMENT_CODE",
10
+ "kind": "variable",
11
+ "tier": null,
12
+ "at": [
13
+ "src/index.ts:55",
14
+ "src/registration.ts:26"
15
+ ],
16
+ "criteriaCovered": false,
17
+ "breaking": false
18
+ }
19
+ ],
20
+ "removed": [],
21
+ "changed": [],
22
+ "subpaths": [],
23
+ "subpathsUnread": [
24
+ "from",
25
+ "to"
26
+ ],
27
+ "narrowed": [],
28
+ "faces": {
29
+ "open": [],
30
+ "source": null
31
+ },
32
+ "closedSetMembers": [],
33
+ "closedSetsUnreadable": [],
34
+ "typeKeys": [],
35
+ "typeKeysUnreadableArms": [],
36
+ "typeKeysFlattenedCount": 1,
37
+ "signatures": [],
38
+ "versionLiterals": [],
39
+ "declarationMoves": [],
40
+ "mintMoves": [],
41
+ "noticeLineage": [],
42
+ "criteriaObserves": [],
43
+ "consumersHint": {
44
+ "cli": [],
45
+ "server": [],
46
+ "sdk": [],
47
+ "note": "scanned cli@df9465c17 server@d3e2455ce sdk@5ef4a2e — a name listed is MENTIONED there today, which is evidence of consumption, not proof of it"
48
+ },
49
+ "breakingCount": 0,
50
+ "breakingItems": [],
51
+ "toResolvedAt": "429afd579d333c5274d457ff699569aaed1f9ff4"
52
+ }
@@ -0,0 +1,473 @@
1
+ {
2
+ "repo": "core",
3
+ "package": "@sema-agent/primitives",
4
+ "version": "7.71.0",
5
+ "from": "251a7e3f266181e5433a0126aeb697378f358c3b",
6
+ "to": "v7.71.0",
7
+ "added": [
8
+ {
9
+ "name": "EntryCutter",
10
+ "kind": "class",
11
+ "tier": null,
12
+ "at": [
13
+ "src/index.ts:91",
14
+ "src/tool-list-cut.ts:33"
15
+ ],
16
+ "criteriaCovered": false,
17
+ "breaking": false
18
+ },
19
+ {
20
+ "name": "FRONTMATTER_FENCE",
21
+ "kind": "variable",
22
+ "tier": null,
23
+ "at": [
24
+ "src/frontmatter-fence.ts:17",
25
+ "src/index.ts:89"
26
+ ],
27
+ "criteriaCovered": false,
28
+ "breaking": false
29
+ },
30
+ {
31
+ "name": "OFFLOADED_DETAIL_HEAD_CHARS",
32
+ "kind": "variable",
33
+ "tier": null,
34
+ "at": [
35
+ "src/index.ts:86",
36
+ "src/offloaded-detail.ts:11"
37
+ ],
38
+ "criteriaCovered": false,
39
+ "breaking": false
40
+ },
41
+ {
42
+ "name": "OffloadedDetail",
43
+ "kind": "interface",
44
+ "tier": null,
45
+ "at": [
46
+ "src/index.ts:86",
47
+ "src/offloaded-detail.ts:29"
48
+ ],
49
+ "criteriaCovered": false,
50
+ "breaking": false
51
+ },
52
+ {
53
+ "name": "PARENS_NOT_ONE_ZONE",
54
+ "kind": "variable",
55
+ "tier": null,
56
+ "at": [
57
+ "src/index.ts:91",
58
+ "src/tool-list-cut.ts:14"
59
+ ],
60
+ "criteriaCovered": false,
61
+ "breaking": false
62
+ },
63
+ {
64
+ "name": "ParsedPermissionRule",
65
+ "kind": "interface",
66
+ "tier": null,
67
+ "at": [
68
+ "src/index.ts:90",
69
+ "src/permission-rule-syntax.ts:13"
70
+ ],
71
+ "criteriaCovered": false,
72
+ "breaking": false
73
+ },
74
+ {
75
+ "name": "ReadSkillFileOptions",
76
+ "kind": "interface",
77
+ "tier": null,
78
+ "at": [
79
+ "src/index.ts:102",
80
+ "src/skill-file.ts:1019"
81
+ ],
82
+ "criteriaCovered": false,
83
+ "breaking": false
84
+ },
85
+ {
86
+ "name": "RecordedEdit",
87
+ "kind": "interface",
88
+ "tier": null,
89
+ "at": [
90
+ "src/index.ts:87",
91
+ "src/recorded-edit.ts:8"
92
+ ],
93
+ "criteriaCovered": false,
94
+ "breaking": false
95
+ },
96
+ {
97
+ "name": "SEQUENCE_NOT_A_NAME",
98
+ "kind": "variable",
99
+ "tier": null,
100
+ "at": [
101
+ "src/index.ts:91",
102
+ "src/tool-list-cut.ts:16"
103
+ ],
104
+ "criteriaCovered": false,
105
+ "breaking": false
106
+ },
107
+ {
108
+ "name": "SKILL_DESCRIPTION_MAX_CHARS",
109
+ "kind": "variable",
110
+ "tier": null,
111
+ "at": [
112
+ "src/index.ts:95",
113
+ "src/skill-file.ts:65"
114
+ ],
115
+ "criteriaCovered": false,
116
+ "breaking": false
117
+ },
118
+ {
119
+ "name": "SKILL_FILE_REFUSAL_REASONS",
120
+ "kind": "variable",
121
+ "tier": null,
122
+ "at": [
123
+ "src/index.ts:96",
124
+ "src/skill-file.ts:82"
125
+ ],
126
+ "criteriaCovered": false,
127
+ "breaking": false
128
+ },
129
+ {
130
+ "name": "SKILL_NAME_MAX_CHARS",
131
+ "kind": "variable",
132
+ "tier": null,
133
+ "at": [
134
+ "src/index.ts:93",
135
+ "src/skill-file.ts:52"
136
+ ],
137
+ "criteriaCovered": false,
138
+ "breaking": false
139
+ },
140
+ {
141
+ "name": "SkillFileReading",
142
+ "kind": "type",
143
+ "tier": null,
144
+ "at": [
145
+ "src/index.ts:101",
146
+ "src/skill-file.ts:996"
147
+ ],
148
+ "criteriaCovered": false,
149
+ "breaking": false
150
+ },
151
+ {
152
+ "name": "SkillFileRefusalReason",
153
+ "kind": "type",
154
+ "tier": null,
155
+ "at": [
156
+ "src/index.ts:100",
157
+ "src/skill-file.ts:83"
158
+ ],
159
+ "criteriaCovered": false,
160
+ "breaking": false
161
+ },
162
+ {
163
+ "name": "UNCLOSED_FRONTMATTER_REASON",
164
+ "kind": "variable",
165
+ "tier": null,
166
+ "at": [
167
+ "src/frontmatter-fence.ts:22",
168
+ "src/index.ts:89"
169
+ ],
170
+ "criteriaCovered": false,
171
+ "breaking": false
172
+ },
173
+ {
174
+ "name": "applyRecordedEdit",
175
+ "kind": "function",
176
+ "tier": null,
177
+ "at": [
178
+ "src/index.ts:87",
179
+ "src/recorded-edit.ts:27"
180
+ ],
181
+ "criteriaCovered": false,
182
+ "breaking": false
183
+ },
184
+ {
185
+ "name": "callerText",
186
+ "kind": "function",
187
+ "tier": null,
188
+ "at": [
189
+ "src/caller-text-shape.ts:36",
190
+ "src/index.ts:88"
191
+ ],
192
+ "criteriaCovered": false,
193
+ "breaking": false
194
+ },
195
+ {
196
+ "name": "dataKind",
197
+ "kind": "function",
198
+ "tier": null,
199
+ "at": [
200
+ "src/caller-text-shape.ts:44",
201
+ "src/index.ts:88"
202
+ ],
203
+ "criteriaCovered": false,
204
+ "breaking": false
205
+ },
206
+ {
207
+ "name": "formatPermissionRule",
208
+ "kind": "function",
209
+ "tier": null,
210
+ "at": [
211
+ "src/index.ts:90",
212
+ "src/permission-rule-syntax.ts:69"
213
+ ],
214
+ "criteriaCovered": false,
215
+ "breaking": false
216
+ },
217
+ {
218
+ "name": "indexOfUnescaped",
219
+ "kind": "function",
220
+ "tier": null,
221
+ "at": [
222
+ "src/index.ts:90",
223
+ "src/permission-rule-syntax.ts:26"
224
+ ],
225
+ "criteriaCovered": false,
226
+ "breaking": false
227
+ },
228
+ {
229
+ "name": "isBlank",
230
+ "kind": "variable",
231
+ "tier": null,
232
+ "at": [
233
+ "src/index.ts:91",
234
+ "src/tool-list-cut.ts:11"
235
+ ],
236
+ "criteriaCovered": false,
237
+ "breaking": false
238
+ },
239
+ {
240
+ "name": "isFrontmatterFence",
241
+ "kind": "function",
242
+ "tier": null,
243
+ "at": [
244
+ "src/frontmatter-fence.ts:29",
245
+ "src/index.ts:89"
246
+ ],
247
+ "criteriaCovered": false,
248
+ "breaking": false
249
+ },
250
+ {
251
+ "name": "isNameableToolName",
252
+ "kind": "function",
253
+ "tier": null,
254
+ "at": [
255
+ "src/index.ts:90",
256
+ "src/permission-rule-syntax.ts:91"
257
+ ],
258
+ "criteriaCovered": false,
259
+ "breaking": false
260
+ },
261
+ {
262
+ "name": "judgeSkillDescription",
263
+ "kind": "function",
264
+ "tier": null,
265
+ "at": [
266
+ "src/index.ts:98",
267
+ "src/skill-file.ts:1036"
268
+ ],
269
+ "criteriaCovered": false,
270
+ "breaking": false
271
+ },
272
+ {
273
+ "name": "judgeSkillName",
274
+ "kind": "function",
275
+ "tier": null,
276
+ "at": [
277
+ "src/index.ts:97",
278
+ "src/skill-file.ts:1029"
279
+ ],
280
+ "criteriaCovered": false,
281
+ "breaking": false
282
+ },
283
+ {
284
+ "name": "lastIndexOfUnescaped",
285
+ "kind": "function",
286
+ "tier": null,
287
+ "at": [
288
+ "src/index.ts:90",
289
+ "src/permission-rule-syntax.ts:32"
290
+ ],
291
+ "criteriaCovered": false,
292
+ "breaking": false
293
+ },
294
+ {
295
+ "name": "mintOffloadedDetailNotice",
296
+ "kind": "function",
297
+ "tier": null,
298
+ "at": [
299
+ "src/index.ts:86",
300
+ "src/offloaded-detail.ts:21"
301
+ ],
302
+ "criteriaCovered": false,
303
+ "breaking": false
304
+ },
305
+ {
306
+ "name": "notARule",
307
+ "kind": "variable",
308
+ "tier": null,
309
+ "at": [
310
+ "src/index.ts:91",
311
+ "src/tool-list-cut.ts:19"
312
+ ],
313
+ "criteriaCovered": false,
314
+ "breaking": false
315
+ },
316
+ {
317
+ "name": "offloadedDetailOf",
318
+ "kind": "function",
319
+ "tier": null,
320
+ "at": [
321
+ "src/index.ts:86",
322
+ "src/offloaded-detail.ts:51"
323
+ ],
324
+ "criteriaCovered": false,
325
+ "breaking": false
326
+ },
327
+ {
328
+ "name": "parsePermissionRule",
329
+ "kind": "function",
330
+ "tier": null,
331
+ "at": [
332
+ "src/index.ts:90",
333
+ "src/permission-rule-syntax.ts:47"
334
+ ],
335
+ "criteriaCovered": false,
336
+ "breaking": false
337
+ },
338
+ {
339
+ "name": "readSkillFile",
340
+ "kind": "function",
341
+ "tier": null,
342
+ "at": [
343
+ "src/index.ts:99",
344
+ "src/skill-file.ts:1050"
345
+ ],
346
+ "criteriaCovered": false,
347
+ "breaking": false
348
+ },
349
+ {
350
+ "name": "retiredToolNameList",
351
+ "kind": "function",
352
+ "tier": null,
353
+ "at": [
354
+ "src/index.ts:131",
355
+ "src/rule-tool-name.ts:129"
356
+ ],
357
+ "criteriaCovered": false,
358
+ "breaking": false
359
+ },
360
+ {
361
+ "name": "ruleSpellingOf",
362
+ "kind": "function",
363
+ "tier": null,
364
+ "at": [
365
+ "src/index.ts:90",
366
+ "src/permission-rule-syntax.ts:102"
367
+ ],
368
+ "criteriaCovered": false,
369
+ "breaking": false
370
+ },
371
+ {
372
+ "name": "skillNamePattern",
373
+ "kind": "function",
374
+ "tier": null,
375
+ "at": [
376
+ "src/index.ts:94",
377
+ "src/skill-file.ts:61"
378
+ ],
379
+ "criteriaCovered": false,
380
+ "breaking": false
381
+ },
382
+ {
383
+ "name": "urlOfAnySchemePattern",
384
+ "kind": "function",
385
+ "tier": null,
386
+ "at": [
387
+ "src/index.ts:31",
388
+ "src/secret-vocabulary.ts:186"
389
+ ],
390
+ "criteriaCovered": false,
391
+ "breaking": false
392
+ }
393
+ ],
394
+ "removed": [],
395
+ "changed": [],
396
+ "subpaths": [],
397
+ "subpathsUnread": [
398
+ "from",
399
+ "to"
400
+ ],
401
+ "narrowed": [],
402
+ "faces": {
403
+ "open": [],
404
+ "source": null
405
+ },
406
+ "closedSetMembers": [
407
+ {
408
+ "set": "SKILL_FILE_REFUSAL_REASONS",
409
+ "at": [
410
+ "src/skill-file.ts:82"
411
+ ],
412
+ "newSet": true,
413
+ "added": [
414
+ "description_too_long",
415
+ "invalid_name",
416
+ "missing_description",
417
+ "missing_name",
418
+ "name_mismatch",
419
+ "no_frontmatter"
420
+ ],
421
+ "removed": [],
422
+ "breaking": false,
423
+ "criteriaCovered": false
424
+ },
425
+ {
426
+ "set": "SkillFileRefusalReason",
427
+ "at": [
428
+ "src/index.ts:100",
429
+ "src/skill-file.ts:83"
430
+ ],
431
+ "newSet": true,
432
+ "added": [
433
+ "description_too_long",
434
+ "invalid_name",
435
+ "missing_description",
436
+ "missing_name",
437
+ "name_mismatch",
438
+ "no_frontmatter"
439
+ ],
440
+ "removed": [],
441
+ "breaking": false,
442
+ "criteriaCovered": false
443
+ }
444
+ ],
445
+ "closedSetsUnreadable": [],
446
+ "typeKeys": [],
447
+ "typeKeysUnreadableArms": [],
448
+ "typeKeysFlattenedCount": 9,
449
+ "signatures": [],
450
+ "versionLiterals": [],
451
+ "declarationMoves": [],
452
+ "mintMoves": [],
453
+ "noticeLineage": [],
454
+ "criteriaObserves": [],
455
+ "consumersHint": {
456
+ "cli": [
457
+ "isBlank",
458
+ "isFrontmatterFence",
459
+ "parsePermissionRule"
460
+ ],
461
+ "server": [
462
+ "callerText",
463
+ "isBlank",
464
+ "parsePermissionRule",
465
+ "ruleSpellingOf"
466
+ ],
467
+ "sdk": [],
468
+ "note": "scanned cli@df9465c17 server@d3e2455ce sdk@5ef4a2e — a name listed is MENTIONED there today, which is evidence of consumption, not proof of it. Ledger files (**/docs/core-consumption/**, **/docs/wire-consumption/**, **/*LEDGER*.json) are not evidence of use — server: 6 name(s) matched ONLY in bookkeeping files and were set aside (FRONTMATTER_FENCE, OffloadedDetail, ParsedPermissionRule, UNCLOSED_FRONTMATTER_REASON, isFrontmatterFence, offloadedDetailOf)"
469
+ },
470
+ "breakingCount": 0,
471
+ "breakingItems": [],
472
+ "toResolvedAt": "429afd579d333c5274d457ff699569aaed1f9ff4"
473
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "repo": "core",
3
+ "package": "@sema-agent/wiki-gate",
4
+ "version": "7.71.0",
5
+ "from": "251a7e3f266181e5433a0126aeb697378f358c3b",
6
+ "to": "v7.71.0",
7
+ "added": [],
8
+ "removed": [],
9
+ "changed": [],
10
+ "subpaths": [],
11
+ "subpathsUnread": [
12
+ "from",
13
+ "to"
14
+ ],
15
+ "narrowed": [],
16
+ "faces": {
17
+ "open": [],
18
+ "source": null
19
+ },
20
+ "closedSetMembers": [],
21
+ "closedSetsUnreadable": [],
22
+ "typeKeys": [],
23
+ "typeKeysUnreadableArms": [],
24
+ "typeKeysFlattenedCount": 5,
25
+ "signatures": [],
26
+ "versionLiterals": [],
27
+ "declarationMoves": [],
28
+ "mintMoves": [],
29
+ "noticeLineage": [],
30
+ "criteriaObserves": [],
31
+ "consumersHint": {
32
+ "cli": [],
33
+ "server": [],
34
+ "sdk": [],
35
+ "note": "scanned cli@df9465c17 server@d3e2455ce sdk@5ef4a2e — a name listed is MENTIONED there today, which is evidence of consumption, not proof of it"
36
+ },
37
+ "breakingCount": 0,
38
+ "breakingItems": [],
39
+ "toResolvedAt": "429afd579d333c5274d457ff699569aaed1f9ff4"
40
+ }
@@ -1,10 +0,0 @@
1
- /** The fence text a writer emits. The reader below accepts exactly this, plus trailing blanks and a CR. */
2
- export declare const FRONTMATTER_FENCE = "---";
3
- /** The refusal sentence for a file that OPENS a frontmatter block and never reaches a closing fence. One wording for
4
- * every reader that refuses such a file: the block exists and cannot be read, so reading the file as one with no
5
- * frontmatter (and dropping what the block declared) is not an answer. */
6
- export declare const UNCLOSED_FRONTMATTER_REASON = "opens with --- but is not closed by a whole-line ---";
7
- /** True ⇔ `line` is exactly a frontmatter fence: {@link FRONTMATTER_FENCE}, then spaces / tabs only, then
8
- * at most one CR. The line must not contain `\n` (callers split on it first). The SAME predicate judges
9
- * the opening fence (line 0) and the closing fence (the first later line it accepts). */
10
- export declare function isFrontmatterFence(line: string): boolean;
@@ -1,6 +0,0 @@
1
- export const FRONTMATTER_FENCE = "---";
2
- export const UNCLOSED_FRONTMATTER_REASON = "opens with --- but is not closed by a whole-line ---";
3
- const FENCE_TAIL = /^[ \t]*\r?$/;
4
- export function isFrontmatterFence(line) {
5
- return line.startsWith(FRONTMATTER_FENCE) && FENCE_TAIL.test(line.slice(FRONTMATTER_FENCE.length));
6
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * The `Tool(content)` rule SYNTAX — the one reader every rule face shares, as a LEAF module.
3
- *
4
- * Two modules read this grammar and, until this file existed, one imported it from the other: the rule
5
- * DSL compiler (`permission-rules.ts`) declared the parser and the persisted-rule model
6
- * (`permission-rule-model.ts`) imported it. The model's command/path grammars are now consumed by the
7
- * compiler too (a content-form `deny`/`ask` rule compiles through the model's own validator and
8
- * matcher), which would have closed a value-import cycle between the two. The syntax layer has no
9
- * dependency of its own, so it lives here and both read DOWN.
10
- *
11
- * Upstream parity: `Lh` (the split), `Dju`/`Pju` (the escape-aware paren search), `Hju` (the three
12
- * unescapes) — INCLUDING the lenient downgrades (malformed parens / trailing garbage ⇒ the WHOLE string
13
- * becomes the bare tool name). The strict complement that refuses the downgrades is the compiler's
14
- * validator, not this reader.
15
- */
16
- /** Parse result — the tool name and, for a `Tool(content)` spelling, its unescaped content. */
17
- export interface ParsedPermissionRule {
18
- toolName: string;
19
- ruleContent?: string;
20
- }
21
- /** First index of `ch` preceded by an EVEN number of backslashes. */
22
- export declare function indexOfUnescaped(s: string, ch: string): number;
23
- /** Last index of `ch` preceded by an EVEN number of backslashes. */
24
- export declare function lastIndexOfUnescaped(s: string, ch: string): number;
25
- /**
26
- * Parse one rule string, including the lenient downgrades (malformed parens / trailing garbage ⇒ the
27
- * WHOLE string becomes the bare tool name). Use the compiler's `validatePermissionRules` (or the policy
28
- * factory) to refuse the downgrades.
29
- */
30
- export declare function parsePermissionRule(rule: string): ParsedPermissionRule;
31
- /**
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.
37
- */
38
- export declare function isNameableToolName(name: string): boolean;
39
- /**
40
- * One rule entry read by the rule syntax, or `undefined` when the syntax cannot read it: blanks around it, a tool name (the
41
- * text before the first unescaped `(`, as written) outside {@link RULE_TOOL_NAME}, or a `(` the parse cannot close at the
42
- * entry's end (the lenient parser's downgrade: the whole string read as a name); otherwise {@link parsePermissionRule}'s
43
- * reading. THE test of "this is a rule spelling" — every entry list's reader asks it before any rule grammar reads the
44
- * content (what the parentheses hold, a parenthesis or a control character included, is that grammar's to judge).
45
- */
46
- export declare function ruleSpellingOf(rule: string): ParsedPermissionRule | undefined;
@@ -1,52 +0,0 @@
1
- function escapedAt(s, i) {
2
- let backslashes = 0;
3
- for (let j = i - 1; j >= 0 && s[j] === "\\"; j--)
4
- backslashes++;
5
- return backslashes % 2 === 1;
6
- }
7
- export function indexOfUnescaped(s, ch) {
8
- for (let i = 0; i < s.length; i++)
9
- if (s[i] === ch && !escapedAt(s, i))
10
- return i;
11
- return -1;
12
- }
13
- export function lastIndexOfUnescaped(s, ch) {
14
- for (let i = s.length - 1; i >= 0; i--)
15
- if (s[i] === ch && !escapedAt(s, i))
16
- return i;
17
- return -1;
18
- }
19
- function unescapeRuleContent(s) {
20
- return s.replaceAll("\\(", "(").replaceAll("\\)", ")").replaceAll("\\\\", "\\");
21
- }
22
- export function parsePermissionRule(rule) {
23
- const open = indexOfUnescaped(rule, "(");
24
- if (open === -1)
25
- return { toolName: rule.trim() };
26
- const close = lastIndexOfUnescaped(rule, ")");
27
- if (close === -1 || close <= open)
28
- return { toolName: rule.trim() };
29
- if (close !== rule.length - 1)
30
- return { toolName: rule.trim() };
31
- const name = rule.substring(0, open);
32
- const content = rule.substring(open + 1, close);
33
- if (!name)
34
- return { toolName: rule.trim() };
35
- if (content === "" || content === "*")
36
- return { toolName: name.trim() };
37
- return { toolName: name.trim(), ruleContent: unescapeRuleContent(content) };
38
- }
39
- const RULE_TOOL_NAME = /^[A-Za-z0-9_*](?:[A-Za-z0-9_.:*-]*[A-Za-z0-9_*-])?$/;
40
- export function isNameableToolName(name) {
41
- return typeof name === "string" && !name.includes("*") && RULE_TOOL_NAME.test(name);
42
- }
43
- export function ruleSpellingOf(rule) {
44
- if (rule !== rule.trim())
45
- return undefined;
46
- const open = indexOfUnescaped(rule, "(");
47
- const name = open < 0 ? rule : rule.slice(0, open);
48
- if (!RULE_TOOL_NAME.test(name))
49
- return undefined;
50
- const parsed = parsePermissionRule(rule);
51
- return parsed.toolName === name ? parsed : undefined;
52
- }