@sema-agent/core 7.70.0 → 7.71.1

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 (439) hide show
  1. package/CHANGELOG.md +740 -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 +21 -7
  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 +69 -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 +39 -21
  344. package/dist/index.js +32 -17
  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 +173 -15
  426. package/wire-changes/core-stores-sql@7.71.0.json +40 -0
  427. package/wire-changes/core-stores-sql@7.71.1.json +40 -0
  428. package/wire-changes/core@7.71.0.json +5827 -0
  429. package/wire-changes/core@7.71.1.json +118 -0
  430. package/wire-changes/mods-kernel@7.71.0.json +52 -0
  431. package/wire-changes/mods-kernel@7.71.1.json +40 -0
  432. package/wire-changes/primitives@7.71.0.json +473 -0
  433. package/wire-changes/primitives@7.71.1.json +40 -0
  434. package/wire-changes/wiki-gate@7.71.0.json +40 -0
  435. package/wire-changes/wiki-gate@7.71.1.json +40 -0
  436. package/dist/core/frontmatter-fence.d.ts +0 -10
  437. package/dist/core/frontmatter-fence.js +0 -6
  438. package/dist/core/permission-rule-syntax.d.ts +0 -46
  439. package/dist/core/permission-rule-syntax.js +0 -52
@@ -1,6 +1,7 @@
1
- import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo } from "../internal/harness.js";
1
+ import { type ForkPoint, type Session, type SessionHead, type SessionPlacementRecord, type SessionRepo, type SessionRowExpectation } from "../internal/harness.js";
2
2
  import { type AcquiredSession, type PlacedSessionRow, type SessionListQuery, type SessionLogTransfer, type SessionPlacement, type SessionStore, type SessionStoreHooks, type SessionStoreSummary } from "./session.js";
3
3
  import type { StoreDurability } from "./checkpoint-store.js";
4
+ import { type StoreHolderFence } from "./checkpoint-generation.js";
4
5
  import { type RetentionDeclaration } from "./retention.js";
5
6
  /** Test seam: the notice is said once per process, so a test asserting it must be able to clear that. Never called by production code. */
6
7
  export declare function __resetSessionDeleteWithheldNotice(): void;
@@ -21,6 +22,14 @@ export interface TtlSessionStoreOptions {
21
22
  * runner instance — even after a restart or on another replica — continues the same conversation.
22
23
  */
23
24
  repo?: SessionRepo;
25
+ /**
26
+ * The deployment's grant judge (`HolderJudge`) for the store's OWN default repo: the store builds its `InMemorySessionRepo` with it,
27
+ * so every session write carrying a holder is judged and the store declares `fence = { holder: "writes" }` — the defaults that come
28
+ * with the default repo (`evict: "delete"`, `durability: "process-local"`) stay. A store given a `repo` takes the judge from that repo
29
+ * (`new InMemorySessionRepo({ holderIsCurrent })`, `FileSessionRepo(root, { holderIsCurrent })`): both together are refused
30
+ * (`config.invalid_argument`) — the judge has one place. A value that is not a function is refused too.
31
+ */
32
+ holderIsCurrent?: import("./checkpoint-generation.js").HolderJudge;
24
33
  /**
25
34
  * What idle-eviction and `release` do to the repo:
26
35
  * - `"delete"` — remove the session from the repo too (correct for the throwaway in-memory repo).
@@ -129,6 +138,10 @@ export declare class TtlSessionStore implements SessionStore {
129
138
  durability: StoreDurability;
130
139
  };
131
140
  };
141
+ /** The grant-holder declaration ({@link SessionStore.fence}): the repo's own ({@link SessionRepo.fence}), mirrored as the repo answers
142
+ * it when this store is built, as {@link headOf} is — the writes are the repo's storages', so only the repo can say they judge.
143
+ * Absent when the repo declares none. */
144
+ readonly fence?: StoreHolderFence;
132
145
  /** The repo's transcript directory, relayed as the repo answers it ({@link SessionStore.transcriptDirectory}); absent when it has none. */
133
146
  readonly transcriptDirectory?: string;
134
147
  /** Placed-partition enumeration, present only when the backing repo can enumerate placements
@@ -158,6 +171,10 @@ export declare class TtlSessionStore implements SessionStore {
158
171
  /** The operator's removal of a row whose head cannot be read ({@link SessionStore.deleteUnreadable}): present only when the repo has a
159
172
  * head read and its own unreadable-row removal ({@link SessionRepo.deleteUnreadable}), which re-reads the head in the step that removes. */
160
173
  readonly deleteUnreadable?: (sessionId: string) => Promise<boolean>;
174
+ /** The claim of a row that records no owner ({@link SessionStore.recordOwner}): present only when the repo has a head read and its own
175
+ * conditional owner write ({@link SessionRepo.recordOwner}), which judges and writes the row in one step; this store holds the id as a
176
+ * register does (a release in flight settles first). */
177
+ readonly recordOwner?: (sessionId: string, owner: string, expect: SessionRowExpectation) => Promise<SessionHead | undefined>;
161
178
  /** Whether the repo judges the expectation of the writes this store hands it (`SessionRepo.delete` / `importEntries` with `expect`):
162
179
  * a repo with a head read and the row read ({@link SessionRepo.readRow}). Over any other repo a deletion is of the id it judged. */
163
180
  private readonly judgesRows;
@@ -1,5 +1,6 @@
1
- import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, sessionLogMarkOf, uuidv7, } from "../internal/harness.js";
1
+ import { InMemorySessionRepo, ParentChainGuard, SessionError, findUnansweredToolBatch, compareOccupants, ownerCell, readSessionRepoRowCells, recordedOwnerName, sessionLogMarkOf, uuidv7, } from "../internal/harness.js";
2
2
  import { isSessionConflict, readSessionListQuery, readUnreadableDeleteId, rowUnreadableAt } from "./session.js";
3
+ import { readHolderJudge } from "./checkpoint-generation.js";
3
4
  import { readRetentionDeclaration } from "./retention.js";
4
5
  import { readMember, thrownText } from "./thrown-value.js";
5
6
  import { principalNameFault, RECORDED_PRINCIPAL_NAME_SPELLING, recordedPrincipalNameOf } from "./principal-name.js";
@@ -34,12 +35,13 @@ function createdCells(opts) {
34
35
  const placement = opts?.placement, owner = opts?.owner;
35
36
  return { ...(placement !== undefined ? { placement } : {}), ...(owner !== undefined ? { owner } : {}) };
36
37
  }
37
- const TTL_SESSION_STORE_OPTION_KEYS = optionKeys()({ defaultTtlDays: 0, sweepIntervalMs: 0, repo: 0, evict: 0, durability: 0, placements: 0, retention: 0, hooks: 0 });
38
+ const TTL_SESSION_STORE_OPTION_KEYS = optionKeys()({ defaultTtlDays: 0, sweepIntervalMs: 0, repo: 0, holderIsCurrent: 0, evict: 0, durability: 0, placements: 0, retention: 0, hooks: 0 });
38
39
  export const STORE_HOOK_KEYS = optionKeys()({ beforeSessionDelete: 0 });
39
40
  export class TtlSessionStore {
40
41
  retention;
41
42
  durability;
42
43
  placements;
44
+ fence;
43
45
  transcriptDirectory;
44
46
  listPlaced;
45
47
  headOf;
@@ -47,6 +49,7 @@ export class TtlSessionStore {
47
49
  logTransfer;
48
50
  delete;
49
51
  deleteUnreadable;
52
+ recordOwner;
50
53
  judgesRows = false;
51
54
  beforeRowDelete;
52
55
  repo;
@@ -63,7 +66,10 @@ export class TtlSessionStore {
63
66
  const opts = receiveOptions(options, "TtlSessionStore", TTL_SESSION_STORE_OPTION_KEYS);
64
67
  this.retention = readRetentionDeclaration("TtlSessionStoreOptions.retention", opts.retention);
65
68
  const givenRepo = opts.repo;
66
- this.repo = givenRepo ?? new InMemorySessionRepo();
69
+ const judge = readHolderJudge("TtlSessionStoreOptions.holderIsCurrent", opts.holderIsCurrent);
70
+ if (judge !== undefined && givenRepo !== undefined)
71
+ throw receiptRefusal("TtlSessionStoreOptions: `holderIsCurrent` and `repo` were both given — the judge has one place: the store's own default repo takes `holderIsCurrent`, a repo you supply takes it itself (`new InMemorySessionRepo({ holderIsCurrent })`, `FileSessionRepo(root, { holderIsCurrent })`)");
72
+ this.repo = givenRepo ?? new InMemorySessionRepo(judge !== undefined ? { holderIsCurrent: judge } : undefined);
67
73
  if (readSessionRepoRowCells("TtlSessionStoreOptions.repo", this.repo.rowCells) === "host") {
68
74
  throw receiptRefusal(`TtlSessionStoreOptions.repo holds no occupant cells (rowCells "host") and this layer has no occupant source — a repo whose host holds the occupant is served by the host's own session store, which puts the occupant on the metadata its sessions answer and on its head read`);
69
75
  }
@@ -74,6 +80,9 @@ export class TtlSessionStore {
74
80
  this.evictPolicy = opts.evict !== undefined ? evictWord(opts.evict) : givenRepo ? "forget" : "delete";
75
81
  if (opts.placements !== undefined)
76
82
  this.placements = placementsDeclaration(opts.placements);
83
+ const repoFence = this.repo.fence;
84
+ if (repoFence !== undefined)
85
+ this.fence = repoFence;
77
86
  const repoTranscripts = this.repo.transcriptDirectory;
78
87
  if (typeof repoTranscripts === "string" && repoTranscripts !== "")
79
88
  this.transcriptDirectory = repoTranscripts;
@@ -86,7 +95,14 @@ export class TtlSessionStore {
86
95
  const repoHead = (sessionId) => repoHeadOf.call(this.repo, sessionId);
87
96
  this.repoHead = repoHead;
88
97
  this.headOf = repoHead;
89
- const { readRow, importEntries, deleteUnreadable, placementOf } = this.repo;
98
+ const { readRow, importEntries, deleteUnreadable, placementOf, recordOwner } = this.repo;
99
+ if (typeof recordOwner === "function") {
100
+ this.recordOwner = async (sessionId, owner, expect) => {
101
+ const name = recordedOwnerName(owner);
102
+ await this.settledHolds(sessionId);
103
+ return recordOwner.call(this.repo, sessionId, name, expect);
104
+ };
105
+ }
90
106
  if (typeof deleteUnreadable === "function") {
91
107
  const repoRemoval = (sessionId) => deleteUnreadable.call(this.repo, sessionId);
92
108
  this.deleteUnreadable = (sessionId) => this.deleteUnreadableRow(sessionId, repoHead, repoRemoval);
@@ -220,6 +220,21 @@ export interface SessionStore<S extends SessionStoreSummary = SessionStoreSummar
220
220
  * fact.
221
221
  */
222
222
  readonly durability?: import("./checkpoint-store.js").StoreDurability;
223
+ /**
224
+ * The grant-holder declaration — ONE per store, the same shape and meaning as `CheckpointStore.fence`
225
+ * ({@link import("./checkpoint-generation.js").StoreHolderFence}): `{ holder: "writes" }` = every storage this store hands out judges
226
+ * {@link import("../engine/harness/types.js").SessionWriteOptions.holder} on each append and leaf move that carries one, first and in
227
+ * the write's own atomic step, by the deployment's one judge — a holder not current throws `holder.superseded` with nothing written.
228
+ * `requireHolder: true` asks the engine's run and verb doors to refuse a run or verb the HOST starts without a holder (a leg the engine
229
+ * starts — a delegated child, a workflow member, an observer — is exempt); the store itself never refuses a write for carrying none.
230
+ * ABSENT ⇒ judges no holder, and a run carrying one over this store is refused at its seat (`config.invalid_session_store`); the
231
+ * retired `{ holder: true }` and every other form are refused there too. `TtlSessionStore` mirrors its repo's
232
+ * ({@link import("../engine/harness/types.js").SessionRepo.fence}); a host's own store declares it directly; a wrapper forwards it
233
+ * (and the holder of every write it forwards); a routing store declares only when every store it routes to judges. The engine reads
234
+ * it at the door and never calls the judge itself; a store declaring it without judging is caught by the contract kit
235
+ * (`sessionStoreContract` with `composed` and `grants`), not at startup.
236
+ */
237
+ readonly fence?: import("./checkpoint-generation.js").StoreHolderFence;
223
238
  /**
224
239
  * The directory this store writes its sessions' transcripts into, absolute — present only where they are files there
225
240
  * (`TtlSessionStore` relays its repo's {@link import("../engine/harness/types.js").SessionRepo.transcriptDirectory}; a file
@@ -397,9 +412,10 @@ export interface SessionStore<S extends SessionStoreSummary = SessionStoreSummar
397
412
  * agent, a synchronous or background child, an observer — carries the owner of its delegation tree: the creating acquire names it
398
413
  * (`opts.owner`, read by the engine from the tree root's row as the root run read it, and carried unchanged down the tree; a fork
399
414
  * names it through its owner argument), and no store derives an owner of its own; the child's owner VALUE is its root's (`null` when
400
- * the root is anonymous). A deployment's gate may still read an ownerless child row more narrowly than an ownerless root row: a row
401
- * created before its engine named owners keeps what its creating write recorded (`null` on the bundled stores — placed rows before
402
- * 7.62.0, every other delegated row before 7.69.0), and a descendant spawned from such a row after a revival records that `null` too.
415
+ * the root is anonymous). A row created before its engine named owners records what its creating write recorded (`null` on the bundled
416
+ * stores — placed rows before 7.62.0, every other delegated row before 7.69.0) until a leg of a tree with an owner first runs on it
417
+ * (reading it records nothing): the engine then records that owner through {@link recordOwner}, and from then on every other
418
+ * principal's tree is refused it.
403
419
  * **Optional**: absent ⇒ no by-id read, and a deployment's authorizer, which needs this and {@link register} together, takes its
404
420
  * fail-closed arm.
405
421
  */
@@ -410,12 +426,28 @@ export interface SessionStore<S extends SessionStoreSummary = SessionStoreSummar
410
426
  * callers' re-reads see the same winner (durable implementations need a real uniqueness guarantee, not read-then-write). On an id
411
427
  * whose row EXISTS it does nothing, whatever it carries — an owned row, an anonymous row, a row `acquire` created (which
412
428
  * records the owner it named, `null` when it named none), or a placed row (likewise) stays as it is: a row's owner is recorded by the write that
413
- * creates it and `register` never changes it; there is no claiming of an existing row. A FIRST write whose `owner` is neither a principal
429
+ * creates it and `register` never changes it; the one write that records an owner on an existing row is {@link recordOwner}, and only on a
430
+ * row that records none. A FIRST write whose `owner` is neither a principal
414
431
  * name (`PRINCIPAL_NAME_SPELLING`) nor `null` is refused loudly and leaves no row; a later call stays a silent no-op
415
432
  * whatever it carries. Deliberately makes NO
416
433
  * authorization decision — the caller re-reads {@link headOf} and judges there. The owner lives and dies with its row.
417
434
  */
418
435
  register?(sessionId: string, owner: string | null): Promise<void>;
436
+ /**
437
+ * The claim of a row that records no owner — the one write that records an owner on a row that exists. In ONE step, against every writer
438
+ * of the row: only while the row records no owner (`null`) and is the row `expect` names ({@link SessionRowExpectation}: `row.owner`
439
+ * `null` and the occupant cell its caller read, judged by `sessionRowMatches`) it records `owner`; nothing else of the row changes (its
440
+ * occupant, placement, lineage and log stay), and a session this store handed out for the row before the write keeps writing to it and
441
+ * answers the recorded owner. Answers the row's head after that step: the head the write committed; on a row that already records a name,
442
+ * the row as read, nothing written (a claim never changes an owner, and never makes a row anonymous again). The row `expect` does not name
443
+ * (another occupant, another owner than `null`) is refused `SessionError("conflict")`, nothing written; no row ⇒ `undefined`; an `owner`
444
+ * that is not a principal name (`PRINCIPAL_NAME_SPELLING`) is refused `config.invalid_argument` before the row is read. Of two concurrent
445
+ * claims of one row, exactly one records its owner and both answers name it. Makes NO authorization decision: the engine reads the
446
+ * answered head and judges there (a leg of a tree with an owner claims a row that records none the first time it runs on it; an entry
447
+ * that only opens or reads such a row records nothing). **Optional**: absent ⇒ a leg of a tree with an owner is refused every row that
448
+ * records none (the refusal names this member); reading such a row, and an anonymous tree, are not affected. `TtlSessionStore` offers it over a repo that has `SessionRepo.recordOwner`.
449
+ */
450
+ recordOwner?(sessionId: string, owner: string, expect: SessionRowExpectation): Promise<SessionHead | undefined>;
419
451
  /**
420
452
  * The storage half of moving a session's log between backends (session-sync): read it out ({@link SessionLogTransfer.listEntryIds},
421
453
  * {@link SessionLogTransfer.exportStream}) and replace it whole through a staging the readers never see
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The `sharedArtifactReads` setting: whether reading an artifact another person shared with this user asks first.
3
+ *
4
+ * One rule: the first of the organization's (`managed`) and the user's own (`user`) layers that states a value decides — a word
5
+ * of the set as written, anything else `ask` — and unset everywhere is `ask`; a project's or a checkout's local settings (`repo`)
6
+ * have no vote. Every stated value not in force is named on `config.entries_not_applied` (kind `setting_not_applied`).
7
+ *
8
+ * - The layers are the ones `crossSessionInbound` takes (`managed`, `user`, `repo`), so a host hands both settings from the same
9
+ * reading of its settings files; a layer's value is its object's OWN member (`undefined` / `null` = unset), each read once. A
10
+ * `repo` value never decides — a file that arrives with a cloned repository must not stop the questions of whoever opens it — and
11
+ * is only quoted, to be named.
12
+ * - What `allow` answers is the Artifact tool's own consent question on a shared target (wherever the tool asks it: `read`,
13
+ * `list_files`, `read_file`, and a publish conflict's snapshot): yes, with nobody asked, under every permission mode (`dontAsk`
14
+ * included — there is no question left for it to refuse). Nothing else moves: the gate's rules on the tool (a person's or the
15
+ * organization's deny or ask) and its hooks still speak before the tool runs, and the read-deny tables, the credential floor a
16
+ * published local file is read through, and the read face of the file tools are each judged where they were.
17
+ *
18
+ * Bad values, each with its way out: a value that is no word of the set (garbage, a boolean, a number, any other spelling — a
19
+ * two-word set has no range to exceed) ⇒ `unrecognized`, and `ask` where its layer decides; a value in `repo` ⇒ `layer_not_read`;
20
+ * the user's word where the organization's layer decided ⇒ `organization_decides` (when it differs from the word in force).
21
+ *
22
+ * One reading per run: a root leg reads the seat once at its prepare; a leg an engine lane bears now (a delegated child in the
23
+ * foreground, in the background, a fork, an observer) holds the reading of the leg that spawned it, carried on its inherited chain
24
+ * (`InheritedGate.sharedArtifactReads`, accepted on such a leg only — a root leg reads the seat whatever its internals carry). Every
25
+ * wake is a run of its own and reads the seat again: a retained teammate's wake, a teammate SendMessage revives from its stored row
26
+ * (tier 3), a checkpoint resume. A leg passes on the reading it holds (read or received) even where its own Artifact seat is not valid;
27
+ * only a leg that holds none and reads none hands none down, and its child reads the seat itself.
28
+ *
29
+ * The notice: on every leg that read the seat (a root leg or a woken one) whose Artifact tool mounts, once per session per entry set
30
+ * (while the announce ledger holds it), addressed as the leg's other notices are; of a `repo` list only the first 16 places are looked
31
+ * at, and how many more there are is said (`repoNotLookedAt`). Each entry:
32
+ * `entry` (the value as written, bounded), `setting` (`"sharedArtifactReads"`), `layer` (`managed` / `user` / `repo`), `reason`;
33
+ * frame members `inForce` (the word in force) and `decidedBy`; routing `sessionId` (plus `sourceSessionId` / `agentId` on a delegated
34
+ * leg), `runId?`. The seat's getter, or a layer
35
+ * member's accessor, that throws fails the prepare; a value that
36
+ * throws while it is quoted is named by a placeholder.
37
+ */
38
+ import { type EngineNotice } from "./engine-notice.js";
39
+ import type { LegNotice, NoticeAddress } from "./leg-identity.js";
40
+ /** The words of `sharedArtifactReads`: `ask` (the engine default — the tool's consent question is put as without the setting) and `allow`. */
41
+ export declare const SHARED_ARTIFACT_READS_SETTINGS: readonly ["ask", "allow"];
42
+ export type SharedArtifactReadsSetting = (typeof SHARED_ARTIFACT_READS_SETTINGS)[number];
43
+ /** The setting's values as a host read them from its settings files, one member per layer (`unknown`: the engine reads them). */
44
+ export interface SharedArtifactReadsLayers {
45
+ /** The organization's layer: decides whenever it states a value. */
46
+ managed?: unknown;
47
+ /** The user's own layer: decides where the organization's states none. */
48
+ user?: unknown;
49
+ /** A project's and a checkout's local settings: no vote for this key; any value there is named as not applied. */
50
+ repo?: readonly unknown[];
51
+ }
52
+ /** Which layer decided: `default` = neither stated a value; `unreadable` = the deciding layer's value is no word of the set. */
53
+ export type SharedArtifactReadsDecidedBy = "managed" | "user" | "default" | "unreadable";
54
+ /** Why an entry did not apply — the `reason` of a `setting_not_applied` entry. */
55
+ export declare const SETTING_NOT_APPLIED_REASONS: readonly ["unrecognized", "layer_not_read", "organization_decides"];
56
+ export type SettingNotAppliedReason = (typeof SETTING_NOT_APPLIED_REASONS)[number];
57
+ export interface SettingNotApplied {
58
+ readonly layer: "managed" | "user" | "repo";
59
+ /** What was written, as a bounded quotation (a string as is, anything else its JSON or `String` form, or a fixed placeholder). */
60
+ readonly entry: string;
61
+ readonly reason: SettingNotAppliedReason;
62
+ }
63
+ /** The resolution: `allow` is only ever a layer's own word (`managed` or `user`), so the pair is a union by `value`. */
64
+ export type ResolvedSharedArtifactReads = ({
65
+ readonly value: "allow";
66
+ readonly decidedBy: "managed" | "user";
67
+ } | {
68
+ readonly value: "ask";
69
+ readonly decidedBy: SharedArtifactReadsDecidedBy;
70
+ }) & {
71
+ /** Every entry that did not apply, in layer order (managed, user, repo). */
72
+ readonly notApplied: readonly SettingNotApplied[];
73
+ /** How many places of a `repo` list past the first {@link REPO_SHOWN} were not looked at; absent when there are none. */
74
+ readonly repoNotLookedAt?: number;
75
+ };
76
+ /** The one reading of the setting's layers (no I/O; each layer's member is read once). */
77
+ export declare function resolveSharedArtifactReads(layers: SharedArtifactReadsLayers | undefined): ResolvedSharedArtifactReads;
78
+ /** The layers a deployment's seat hands (a value or a getter read once per prepare). */
79
+ export declare function sharedArtifactReadsLayersOf(seat: SharedArtifactReadsLayers | (() => SharedArtifactReadsLayers | undefined) | undefined): SharedArtifactReadsLayers | undefined;
80
+ /** The notice for a resolution with entries that did not apply (`undefined` when every entry applied). */
81
+ export declare function sharedArtifactReadsNotice(r: ResolvedSharedArtifactReads, ids: NoticeAddress & {
82
+ runId?: string;
83
+ }): EngineNotice | undefined;
84
+ /** Say the resolution's not-applied entries once per conversation per set, on every leg that read the seat (the caller calls it only
85
+ * there: a leg holding a handed reading read nothing), addressed and admitted as the leg's notices are (`legNotice`: its own session on
86
+ * a top-level leg, the tree's root naming the leg on a delegated one — whose digest names its own session, as a fork starts with its
87
+ * parent's record). */
88
+ export declare function announceSharedArtifactReads(r: ResolvedSharedArtifactReads, input: {
89
+ onNotice?: (n: EngineNotice) => void;
90
+ oncePerSession?: (digest: string, deliver: () => void) => void;
91
+ legNotice: Pick<LegNotice, "route" | "admission">;
92
+ runId?: string;
93
+ }): void;
@@ -0,0 +1,94 @@
1
+ import { deliverEngineNotice } from "./engine-notice.js";
2
+ import { entriesNotAppliedDetail } from "./entries-not-applied.js";
3
+ import { announceDigest } from "./notice-fact.js";
4
+ export const SHARED_ARTIFACT_READS_SETTINGS = Object.freeze(["ask", "allow"]);
5
+ export const SETTING_NOT_APPLIED_REASONS = Object.freeze(["unrecognized", "layer_not_read", "organization_decides"]);
6
+ const ENTRY_SHOWN = 80;
7
+ const REPO_SHOWN = 16;
8
+ function quoted(v) {
9
+ let s;
10
+ try {
11
+ s = typeof v === "string" ? v : (JSON.stringify(v) ?? String(v));
12
+ }
13
+ catch {
14
+ s = "(a value that cannot be shown)";
15
+ }
16
+ return s.length > ENTRY_SHOWN ? `${s.slice(0, ENTRY_SHOWN)}…` : s;
17
+ }
18
+ function ownValue(layers, key) {
19
+ return layers !== undefined && layers !== null && Object.prototype.hasOwnProperty.call(layers, key) ? layers[key] : undefined;
20
+ }
21
+ function readLayer(v) {
22
+ if (v === undefined || v === null)
23
+ return { kind: "unset" };
24
+ return typeof v === "string" && SHARED_ARTIFACT_READS_SETTINGS.includes(v) ? { kind: "word", word: v } : { kind: "unrecognized", raw: v };
25
+ }
26
+ export function resolveSharedArtifactReads(layers) {
27
+ const managed = readLayer(ownValue(layers, "managed"));
28
+ const user = readLayer(ownValue(layers, "user"));
29
+ const deciding = managed.kind !== "unset" ? "managed" : user.kind !== "unset" ? "user" : undefined;
30
+ const decider = deciding === "managed" ? managed : user;
31
+ const resolved = deciding === undefined ? { value: "ask", decidedBy: "default" } : decider.kind === "word" ? (decider.word === "allow" ? { value: "allow", decidedBy: deciding } : { value: "ask", decidedBy: deciding }) : { value: "ask", decidedBy: "unreadable" };
32
+ const notApplied = [];
33
+ if (managed.kind === "unrecognized")
34
+ notApplied.push({ layer: "managed", entry: quoted(managed.raw), reason: "unrecognized" });
35
+ if (user.kind === "unrecognized")
36
+ notApplied.push({ layer: "user", entry: quoted(user.raw), reason: "unrecognized" });
37
+ else if (user.kind === "word" && deciding === "managed" && user.word !== resolved.value)
38
+ notApplied.push({ layer: "user", entry: user.word, reason: "organization_decides" });
39
+ const repo = ownValue(layers, "repo");
40
+ const repoValues = [];
41
+ let repoNotLookedAt = 0;
42
+ if (Array.isArray(repo)) {
43
+ const len = repo.length;
44
+ const n = typeof len === "number" && Number.isSafeInteger(len) && len > 0 ? len : 0;
45
+ for (let i = 0; i < Math.min(n, REPO_SHOWN); i++)
46
+ if (Object.prototype.hasOwnProperty.call(repo, i))
47
+ repoValues.push(repo[i]);
48
+ repoNotLookedAt = Math.max(0, n - REPO_SHOWN);
49
+ }
50
+ else if (repo !== undefined && repo !== null)
51
+ repoValues.push(repo);
52
+ for (const v of repoValues)
53
+ if (v !== undefined && v !== null)
54
+ notApplied.push({ layer: "repo", entry: quoted(v), reason: "layer_not_read" });
55
+ return { ...resolved, notApplied, ...(repoNotLookedAt > 0 ? { repoNotLookedAt } : {}) };
56
+ }
57
+ export function sharedArtifactReadsLayersOf(seat) {
58
+ return typeof seat === "function" ? seat() : seat;
59
+ }
60
+ const LANE = "config.entries_not_applied:setting_not_applied";
61
+ const WHY = {
62
+ unrecognized: "it is not one of the setting's words (ask, allow)",
63
+ layer_not_read: "a project's or a checkout's local settings are not read for this setting (only the user's own settings and the organization's are)",
64
+ organization_decides: "the organization's settings state a value for this setting, and theirs decides",
65
+ };
66
+ export function sharedArtifactReadsNotice(r, ids) {
67
+ const unseen = r.repoNotLookedAt ?? 0;
68
+ if (r.notApplied.length === 0 && unseen === 0)
69
+ return undefined;
70
+ const clauses = r.notApplied.map((e) => `the ${e.layer === "repo" ? "project" : e.layer === "managed" ? "organization" : "user"} value ${JSON.stringify(e.entry)} did not apply: ${WHY[e.reason]}`);
71
+ if (unseen > 0)
72
+ clauses.push(`the project settings list has ${unseen} more place${unseen === 1 ? "" : "s"} past the first ${REPO_SHOWN}, not looked at (project settings have no vote for this setting)`);
73
+ const entries = r.notApplied.map((e) => ({ entry: e.entry, setting: "sharedArtifactReads", layer: e.layer, reason: e.reason }));
74
+ return {
75
+ code: "config.entries_not_applied",
76
+ message: `The sharedArtifactReads setting: ${clauses.join("; ")}. ` +
77
+ `In force: ${r.value === "allow" ? "allow (reading an artifact another person shared does not ask)" : "ask (reading an artifact another person shared is approved as without the setting)"}. ` +
78
+ `${r.notApplied.length > 0 ? "Correct or remove the entry" : "Project values have no vote for this setting; remove any there"}. Said once per conversation for this set of entries.`,
79
+ detail: { ...entriesNotAppliedDetail("setting_not_applied", entries), inForce: r.value, decidedBy: r.decidedBy, ...(unseen > 0 ? { repoNotLookedAt: unseen } : {}), ...ids },
80
+ sessionId: ids.sessionId,
81
+ };
82
+ }
83
+ export function announceSharedArtifactReads(r, input) {
84
+ const { address } = input.legNotice.route;
85
+ const notice = sharedArtifactReadsNotice(r, { ...address, ...(input.runId !== undefined ? { runId: input.runId } : {}) });
86
+ if (notice === undefined)
87
+ return;
88
+ const deliver = () => deliverEngineNotice(input.onNotice, notice, input.legNotice.admission);
89
+ if (input.oncePerSession === undefined)
90
+ return deliver();
91
+ const identity = notice.detail.identity;
92
+ const key = (r.repoNotLookedAt !== undefined ? `${identity}:${r.repoNotLookedAt}` : identity) + (address.sourceSessionId !== undefined ? `\n\n${address.sourceSessionId}` : "");
93
+ input.oncePerSession(announceDigest(LANE, key), deliver);
94
+ }
@@ -1,5 +1,5 @@
1
1
  import { wireOf } from "./tool-name-readings.js";
2
- import { ruleSpellingOf } from "./permission-rule-syntax.js";
2
+ import { ruleSpellingOf } from "@sema-agent/primitives";
3
3
  import { mountedToolPermissionSeat } from "./mode-policy.js";
4
4
  import { inlineUntrusted } from "./untrusted-text.js";
5
5
  import { boundInputHashOf } from "./canonical-json.js";
@@ -18,56 +18,20 @@
18
18
  * directory third parties can write to is the same as pasting their text into the system prompt. The
19
19
  * loader validates SHAPE (spec conformance), never intent.
20
20
  *
21
- * **`allowed-tools` / `disallowed-tools` are COPIED, never judged for what they mean.** Each frontmatter list reaches
22
- * {@link SkillSpec.allowedTools} / {@link SkillSpec.disallowedTools} entry by entry as the author wrote it — no
23
- * intersection with a roster, no projection onto a tool name, no de-duplication. Each entry must be a rule SPELLING — the
24
- * rule syntax's own test, `ruleSpellingOf` (a tool name, then at most one parenthesized rule) — or the skill is refused;
25
- * what a spelled entry means (a tool, a namespace, a command rule, a path, a wildcard that grants nothing) is read in ONE
26
- * place, the run's grant table, which announces what it cannot read. The deny list has a second spelling,
27
- * `disallowedTools`, read where `disallowed-tools` is absent or null (YAML's null is the key's absence); a hyphen key with
28
- * a value is the list and the alias is not looked at. The allow list has none. **Each list is read whole by ONE scanner,
29
- * {@link scanValue} (its JSDoc states the rules), or the skill is refused by name (`no_frontmatter`)** — never installed
30
- * shorter: a `disallowed-tools` that lost entries is a looser skill than the one its author wrote. The scanner reads YAML's
31
- * structure as YAML does — a comment, a flow's `,` / `]` and a mapping's `: ` are YAML's inside a rule's parentheses too —
32
- * and departs from what YAML and the reference's reader give only where the list is cut into entries, on purpose: the cut
33
- * counts a rule's parentheses by depth and refuses an entry whose parentheses are not one group closing it — unmatched
34
- * either way, or followed by more text (the reference's zone is boolean and installs such an entry); a `*` entry is
35
- * copied, the list not collapsed to `*` alone; tab-indented block items are read (the reference's retry reads them too);
36
- * and a block scalar's text is cut line by line — each line of a literal one (`|`) as written, a folded one (`>`) after
37
- * YAML's folding, so `>` lines that hold one rule read as that rule (YAML keeps the line breaks of `|` in one string, which
38
- * the reference installs as one entry no rule reads).
39
- *
40
- * Frontmatter is read by a deliberately closed subset reader (no YAML dependency — the runtime dependency budget is a
41
- * standing constraint): top-level key lines ({@link yamlKeyLineOf}), `#` comment lines, block scalars (`|` / `>` with their
42
- * indentation and chomping indicators), the tool lists, and nested blocks (a mapping or a sequence under a key with nothing
43
- * on its line) skipped wholesale but for a line that opens a tool-list key (below). A key other than the tool lists keeps its
44
- * value as written on its line (a value that is one quoted scalar, the scanner's own judgment, is that scalar decoded, over
45
- * every line it runs); a value of it that opens a quote, a `[` or a `{` and does not
46
- * close it refuses the skill too — the same scanner, over the same lines, says so. Every value takes its own lines and no
47
- * more, and every line no value takes is judged in one place: an indented `key:` line under a value that is not a nested
48
- * block — plain, quoted, a flow, a block scalar — refuses the skill naming both keys (YAML reads no key there), and a
49
- * flush-left line that is no key line refuses it naming the line (YAML reads no key there either). A tool list is read only
50
- * as a key of the frontmatter, written flush left: a tool-list key written in another key's nested block (at any depth), or
51
- * after another key's closing quote or `]` on its line, or as a key of a flow mapping (or a pair in a flow sequence) that
52
- * value holds, refuses the skill naming both keys — its list would be lost.
21
+ * **One reader of a `SKILL.md` text.** Each directory's file is read by `readSkillFile` (`@sema-agent/primitives`), the
22
+ * function an editor or a browser asks too: what it reads (the head, the tool lists copied as written, the body), what it
23
+ * skips and what it refuses, and the sentence each warning carries, are that reader's. This module adds what only a disk has:
24
+ * listing the root, following and containing links, the attachments.
53
25
  */
26
+ import { type SkillFileRefusalReason } from "@sema-agent/primitives";
54
27
  import type { SkillSpec } from "./types.js";
55
28
  /** Why one skill directory (or one of its parts) was not taken as-declared. */
56
29
  export type SkillsDirectoryWarningCode =
30
+ /** The `SKILL.md` was not read as a skill — the skill file reader's reason (`SKILL_FILE_REFUSAL_REASONS`: `no_frontmatter`,
31
+ * `missing_name`, `invalid_name`, `name_mismatch`, `missing_description`, `description_too_long`). */
32
+ SkillFileRefusalReason
57
33
  /** The directory holds no `SKILL.md`. */
58
- "no_skill_file"
59
- /** `SKILL.md` has no well-formed `---` fenced frontmatter block: no opening fence, an opening fence never closed by a whole-line `---`, a tool list (`allowed-tools` / `disallowed-tools`) whose value the reader cannot read as a list, a key whose value opens a quote, a `[` or a `{` it does not close, a value that is not a nested block followed by an indented `key:` line, a tool-list key written anywhere but flush left (in a nested block, or after a closing quote or `]` on a key's line), or a flush-left line that is no key line. */
60
- | "no_frontmatter"
61
- /** Required `name` absent. */
62
- | "missing_name"
63
- /** `name` breaks the charset/length rule. */
64
- | "invalid_name"
65
- /** `name` disagrees with the directory name (the spec requires they match). */
66
- | "name_mismatch"
67
- /** Required `description` absent. */
68
- | "missing_description"
69
- /** `description` exceeds the spec cap. */
70
- | "description_too_long"
34
+ | "no_skill_file"
71
35
  /** An attachment was left out (non-text bytes, over budget, unreadable, or resolving outside the skill). */
72
36
  | "attachment_skipped"
73
37
  /** A file or directory entry existed but could not be read/resolved. */