@sema-agent/core 7.51.2 → 7.53.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 (446) hide show
  1. package/CHANGELOG.md +698 -2
  2. package/README.md +3 -1
  3. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  4. package/dist/agents/cascade.js +4 -0
  5. package/dist/agents/cross-session-envelope.d.ts +8 -0
  6. package/dist/agents/cross-session-envelope.js +6 -0
  7. package/dist/agents/cross-session-judge.d.ts +21 -1
  8. package/dist/agents/cross-session-judge.js +8 -0
  9. package/dist/agents/cross-session-ref.d.ts +5 -0
  10. package/dist/agents/cross-session-ref.js +1 -0
  11. package/dist/agents/cumulative-stats.d.ts +3 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/list-agents-tool.d.ts +1 -1
  14. package/dist/agents/org-delivery-gate.d.ts +122 -0
  15. package/dist/agents/org-delivery-gate.js +69 -0
  16. package/dist/agents/peer-held-queue.d.ts +9 -4
  17. package/dist/agents/peer-held-queue.js +6 -5
  18. package/dist/agents/peer-session-drain.d.ts +35 -5
  19. package/dist/agents/peer-session-drain.js +271 -180
  20. package/dist/agents/read-inbox-tool.d.ts +8 -1
  21. package/dist/agents/read-inbox-tool.js +5 -1
  22. package/dist/agents/repair-loop.js +4 -0
  23. package/dist/agents/send-message-tool.d.ts +11 -16
  24. package/dist/agents/send-message-tool.js +11 -13
  25. package/dist/agents/subagent.d.ts +3 -0
  26. package/dist/agents/subagent.js +105 -76
  27. package/dist/agents/tool-filter.d.ts +58 -13
  28. package/dist/agents/tool-filter.js +34 -14
  29. package/dist/bench/metrics.d.ts +1 -0
  30. package/dist/brain/anthropic.d.ts +6 -1
  31. package/dist/brain/anthropic.js +17 -13
  32. package/dist/brain/model-presets.d.ts +4 -5
  33. package/dist/brain/model-presets.js +6 -5
  34. package/dist/brain/open-responses.js +16 -12
  35. package/dist/brain/openai.js +16 -12
  36. package/dist/brain/request-params.d.ts +12 -33
  37. package/dist/brain/request-params.js +5 -2
  38. package/dist/brain/request-route.d.ts +9 -8
  39. package/dist/brain/request-route.js +1 -0
  40. package/dist/brain/route-adjudicator.d.ts +123 -47
  41. package/dist/brain/route-adjudicator.js +171 -42
  42. package/dist/brain/route-conformance.js +2 -2
  43. package/dist/brain/routing.d.ts +24 -1
  44. package/dist/brain/routing.js +54 -19
  45. package/dist/brain/status-sink.d.ts +18 -0
  46. package/dist/brain/status-sink.js +7 -0
  47. package/dist/brain/timeout.js +5 -4
  48. package/dist/core/a2a.d.ts +5 -2
  49. package/dist/core/a2a.js +30 -13
  50. package/dist/core/allow-entry.d.ts +42 -9
  51. package/dist/core/allow-entry.js +25 -18
  52. package/dist/core/auto-compaction.d.ts +80 -20
  53. package/dist/core/auto-compaction.js +65 -18
  54. package/dist/core/auto-promote.d.ts +2 -1
  55. package/dist/core/auto-promote.js +2 -2
  56. package/dist/core/caller-tool-name.d.ts +9 -0
  57. package/dist/core/caller-tool-name.js +13 -0
  58. package/dist/core/checkpoint-requirements.d.ts +7 -1
  59. package/dist/core/checkpoint-requirements.js +2 -0
  60. package/dist/core/checkpoint-store.d.ts +57 -24
  61. package/dist/core/checkpoint-store.js +3 -3
  62. package/dist/core/child-clamp-seats.d.ts +6 -0
  63. package/dist/core/child-clamp-seats.js +2 -1
  64. package/dist/core/compliance.js +3 -1
  65. package/dist/core/credential-vocabulary.d.ts +33 -8
  66. package/dist/core/credential-vocabulary.js +32 -7
  67. package/dist/core/decision-receipt.d.ts +2 -2
  68. package/dist/core/delegation-frames.d.ts +9 -2
  69. package/dist/core/delegation-name.d.ts +18 -0
  70. package/dist/core/delegation-name.js +47 -0
  71. package/dist/core/effective-path-target.d.ts +25 -6
  72. package/dist/core/effective-path-target.js +24 -2
  73. package/dist/core/engine-capabilities.d.ts +8 -1
  74. package/dist/core/engine-capabilities.js +1 -1
  75. package/dist/core/engine-notice.d.ts +49 -21
  76. package/dist/core/frontmatter-fence.d.ts +10 -0
  77. package/dist/core/frontmatter-fence.js +6 -0
  78. package/dist/core/gate-fold.js +8 -25
  79. package/dist/core/gate-lanes.js +358 -274
  80. package/dist/core/gate-outcome.d.ts +11 -6
  81. package/dist/core/governance-codes.d.ts +11 -4
  82. package/dist/core/governance-codes.js +12 -3
  83. package/dist/core/hands-band-screen.d.ts +7 -0
  84. package/dist/core/hands-band-screen.js +32 -0
  85. package/dist/core/hooks.d.ts +283 -739
  86. package/dist/core/hooks.js +100 -193
  87. package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
  88. package/dist/{tools/fs → core}/image-admission.js +24 -6
  89. package/dist/core/locked-config.d.ts +84 -32
  90. package/dist/core/locked-config.js +128 -42
  91. package/dist/core/mcp-connection-pool.d.ts +4 -1
  92. package/dist/core/mcp-connection-pool.js +7 -2
  93. package/dist/core/mcp-probe.d.ts +12 -9
  94. package/dist/core/mcp-probe.js +3 -3
  95. package/dist/core/mcp-server-spec.d.ts +104 -10
  96. package/dist/core/mcp-server-spec.js +183 -33
  97. package/dist/core/mcp.d.ts +31 -20
  98. package/dist/core/mcp.js +66 -56
  99. package/dist/core/memory-engine/data-plane.js +5 -1
  100. package/dist/core/memory-engine/distiller.js +16 -2
  101. package/dist/core/memory-engine/engine.d.ts +22 -30
  102. package/dist/core/memory-engine/engine.js +16 -10
  103. package/dist/core/memory-engine/frontmatter.d.ts +6 -0
  104. package/dist/core/memory-engine/frontmatter.js +19 -16
  105. package/dist/core/memory.d.ts +2 -2
  106. package/dist/core/mode-policy.d.ts +5 -16
  107. package/dist/core/mode-policy.js +7 -19
  108. package/dist/core/model-seat.d.ts +4 -1
  109. package/dist/core/mods/dollar.d.ts +109 -0
  110. package/dist/core/mods/dollar.js +154 -0
  111. package/dist/core/mods/host.d.ts +23 -0
  112. package/dist/core/mods/host.js +21 -0
  113. package/dist/core/mods/kernel/budget.d.ts +43 -0
  114. package/dist/core/mods/kernel/budget.js +83 -0
  115. package/dist/core/mods/kernel/dispatch.d.ts +100 -0
  116. package/dist/core/mods/kernel/dispatch.js +699 -0
  117. package/dist/core/mods/kernel/events.d.ts +245 -0
  118. package/dist/core/mods/kernel/events.js +210 -0
  119. package/dist/core/mods/kernel/index.d.ts +6 -0
  120. package/dist/core/mods/kernel/index.js +5 -0
  121. package/dist/core/mods/kernel/receive.d.ts +94 -0
  122. package/dist/core/mods/kernel/receive.js +188 -0
  123. package/dist/core/mods/kernel/registration.d.ts +131 -0
  124. package/dist/core/mods/kernel/registration.js +102 -0
  125. package/dist/core/mods/kernel/site-rules.d.ts +149 -0
  126. package/dist/core/mods/kernel/site-rules.js +296 -0
  127. package/dist/core/mods/stations.d.ts +344 -0
  128. package/dist/core/mods/stations.js +437 -0
  129. package/dist/core/mounted-mcp.d.ts +57 -0
  130. package/dist/core/mounted-mcp.js +71 -2
  131. package/dist/core/own-property-receipt.d.ts +13 -0
  132. package/dist/core/own-property-receipt.js +13 -23
  133. package/dist/core/parent-spec-seat.d.ts +18 -7
  134. package/dist/core/parent-spec-seat.js +6 -2
  135. package/dist/core/path-identity.js +2 -1
  136. package/dist/core/permission-rule-model.d.ts +58 -9
  137. package/dist/core/permission-rule-model.js +81 -7
  138. package/dist/core/permission-rule-org.d.ts +163 -33
  139. package/dist/core/permission-rule-org.js +205 -71
  140. package/dist/core/permission-rule-syntax.d.ts +15 -0
  141. package/dist/core/permission-rule-syntax.js +24 -16
  142. package/dist/core/permission-rules.d.ts +14 -2
  143. package/dist/core/permission-rules.js +63 -23
  144. package/dist/core/prompt-section-seat.d.ts +15 -27
  145. package/dist/core/prompt-section-seat.js +73 -40
  146. package/dist/core/protocol-http-auth.d.ts +3 -1
  147. package/dist/core/protocol-http-auth.js +2 -0
  148. package/dist/core/reminder-mint.d.ts +2 -2
  149. package/dist/core/remote-env.d.ts +24 -12
  150. package/dist/core/remote-env.js +1 -0
  151. package/dist/core/resume-startup-cause.d.ts +16 -1
  152. package/dist/core/resume-startup-cause.js +4 -1
  153. package/dist/core/retention.js +7 -2
  154. package/dist/core/retired-keys.d.ts +12 -2
  155. package/dist/core/retired-keys.js +15 -1
  156. package/dist/core/roles.js +60 -10
  157. package/dist/core/rule-lane-reads.js +1 -1
  158. package/dist/core/runner/announce-once-ledger.d.ts +31 -1
  159. package/dist/core/runner/announce-once-ledger.js +22 -0
  160. package/dist/core/runner/assemble-result.d.ts +9 -0
  161. package/dist/core/runner/assemble-result.js +3 -1
  162. package/dist/core/runner/call-hook-stations.d.ts +23 -27
  163. package/dist/core/runner/call-hook-stations.js +58 -42
  164. package/dist/core/runner/caller-stop-gate.d.ts +25 -0
  165. package/dist/core/runner/caller-stop-gate.js +7 -0
  166. package/dist/core/runner/compaction-seams.d.ts +8 -22
  167. package/dist/core/runner/compaction-seams.js +28 -53
  168. package/dist/core/runner/construction-doors.js +11 -1
  169. package/dist/core/runner/contracts.d.ts +86 -83
  170. package/dist/core/runner/credential-origin-seat.d.ts +2 -0
  171. package/dist/core/runner/credential-origin-seat.js +19 -0
  172. package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
  173. package/dist/core/runner/gate-exit.d.ts +47 -36
  174. package/dist/core/runner/gate-exit.js +12 -5
  175. package/dist/core/runner/image.js +1 -2
  176. package/dist/core/runner/inline-image.js +1 -1
  177. package/dist/core/runner/mcp-redial.d.ts +52 -10
  178. package/dist/core/runner/mcp-redial.js +38 -9
  179. package/dist/core/runner/notice-seat-input.d.ts +11 -0
  180. package/dist/core/runner/notice-seat-input.js +1 -0
  181. package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
  182. package/dist/core/runner/permission-rule-lanes.js +22 -10
  183. package/dist/core/runner/person-path-rows.d.ts +3 -1
  184. package/dist/core/runner/person-path-rows.js +3 -2
  185. package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
  186. package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
  187. package/dist/core/runner/prepare-ask-lane.js +6 -15
  188. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
  189. package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
  190. package/dist/core/runner/prepare-config-doors.d.ts +52 -1
  191. package/dist/core/runner/prepare-config-doors.js +168 -143
  192. package/dist/core/runner/prepare-defer-classify.js +7 -11
  193. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  194. package/dist/core/runner/prepare-delegation-surface.js +7 -5
  195. package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
  196. package/dist/core/runner/prepare-gate-stations.js +11 -10
  197. package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
  198. package/dist/core/runner/prepare-hands-readface.js +2 -1
  199. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
  200. package/dist/core/runner/prepare-inherited-gate.js +10 -23
  201. package/dist/core/runner/prepare-listings.d.ts +1 -1
  202. package/dist/core/runner/prepare-listings.js +4 -2
  203. package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
  204. package/dist/core/runner/prepare-memory-engine-session.js +20 -7
  205. package/dist/core/runner/prepare-memory.d.ts +3 -2
  206. package/dist/core/runner/prepare-memory.js +6 -2
  207. package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
  208. package/dist/core/runner/prepare-offload-wrappers.js +2 -1
  209. package/dist/core/runner/prepare-park-ask.js +10 -14
  210. package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
  211. package/dist/core/runner/prepare-policy-chain.js +104 -109
  212. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  213. package/dist/core/runner/prepare-project-context.js +11 -12
  214. package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
  215. package/dist/core/runner/prepare-prompt-assembly.js +138 -101
  216. package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
  217. package/dist/core/runner/prepare-prompt-inputs.js +11 -10
  218. package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
  219. package/dist/core/runner/prepare-protocol-tools.js +20 -13
  220. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  221. package/dist/core/runner/prepare-question-face.js +4 -3
  222. package/dist/core/runner/prepare-safety-scan.js +6 -10
  223. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
  224. package/dist/core/runner/prepare-suspend-saga.js +7 -5
  225. package/dist/core/runner/prepare-task.js +41 -23
  226. package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
  227. package/dist/core/runner/prepare-turn-wiring.js +29 -27
  228. package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
  229. package/dist/core/runner/prepare-wiring-manifest.js +14 -11
  230. package/dist/core/runner/resume-admission.d.ts +4 -1
  231. package/dist/core/runner/resume-admission.js +7 -5
  232. package/dist/core/runner/resume-apply.d.ts +5 -2
  233. package/dist/core/runner/resume-apply.js +24 -42
  234. package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
  235. package/dist/core/runner/resume-checkpoint-screen.js +9 -1
  236. package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
  237. package/dist/core/runner/resume-internals-and-config.js +3 -8
  238. package/dist/core/runner/resume-preflight.js +38 -16
  239. package/dist/core/runner/retired-runner-deps.d.ts +5 -6
  240. package/dist/core/runner/retired-runner-deps.js +4 -5
  241. package/dist/core/runner/run-brain-sinks.d.ts +3 -2
  242. package/dist/core/runner/run-brain-sinks.js +5 -1
  243. package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
  244. package/dist/core/runner/run-compaction-machinery.js +7 -33
  245. package/dist/core/runner/run-harness-handlers.js +4 -2
  246. package/dist/core/runner/run-identity-wiring.d.ts +3 -1
  247. package/dist/core/runner/run-identity-wiring.js +3 -2
  248. package/dist/core/runner/run-leg.js +103 -95
  249. package/dist/core/runner/run-notification-lane.js +1 -0
  250. package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
  251. package/dist/core/runner/run-recovery-lanes.js +14 -11
  252. package/dist/core/runner/run-settle-and-teardown.js +9 -28
  253. package/dist/core/runner/run-stop-and-final-verify.js +18 -25
  254. package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
  255. package/dist/core/runner/run-terminal-adoption.js +34 -22
  256. package/dist/core/runner/run-tool-mount-facts.js +5 -3
  257. package/dist/core/runner/run-turn-boundary.js +32 -37
  258. package/dist/core/runner/runtask.d.ts +6 -7
  259. package/dist/core/runner/runtask.js +15 -73
  260. package/dist/core/runner/session-rule-policy.d.ts +5 -5
  261. package/dist/core/runner/session-rule-policy.js +13 -8
  262. package/dist/core/runner/side-call-account.d.ts +68 -0
  263. package/dist/core/runner/side-call-account.js +61 -0
  264. package/dist/core/runner/skills-seat.d.ts +15 -0
  265. package/dist/core/runner/skills-seat.js +57 -0
  266. package/dist/core/runner/stream-halt-verbs.js +12 -17
  267. package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
  268. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  269. package/dist/core/runner/stream-steer-verb.js +20 -38
  270. package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
  271. package/dist/core/runner/sub-agent-deny-lists.js +230 -71
  272. package/dist/core/runner/synthetic-tools.d.ts +5 -2
  273. package/dist/core/runner/synthetic-tools.js +2 -12
  274. package/dist/core/runner/tool-end-body.d.ts +5 -6
  275. package/dist/core/runner/tool-end-body.js +6 -4
  276. package/dist/core/runner/tool-not-executed.d.ts +15 -0
  277. package/dist/core/runner/tool-not-executed.js +30 -0
  278. package/dist/core/runner/tool-occurrence.d.ts +8 -7
  279. package/dist/core/runner/tool-occurrence.js +5 -5
  280. package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
  281. package/dist/core/runner-deps.d.ts +43 -36
  282. package/dist/core/safety-merge-corpus.js +18 -2
  283. package/dist/core/secret-env.d.ts +88 -20
  284. package/dist/core/secret-env.js +192 -38
  285. package/dist/core/session-policy-store.d.ts +71 -16
  286. package/dist/core/session-policy-store.js +138 -28
  287. package/dist/core/session-reconcile.d.ts +4 -0
  288. package/dist/core/session-reconcile.js +2 -1
  289. package/dist/core/shell-read-silence.js +3 -32
  290. package/dist/core/side-query.d.ts +5 -3
  291. package/dist/core/skill-grant.d.ts +3 -2
  292. package/dist/core/skill-grant.js +17 -9
  293. package/dist/core/skills-directory.d.ts +31 -11
  294. package/dist/core/skills-directory.js +655 -104
  295. package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
  296. package/dist/core/task-event.d.ts +49 -3
  297. package/dist/core/task-notification.js +2 -2
  298. package/dist/core/task-result.d.ts +8 -0
  299. package/dist/core/task-spec.d.ts +20 -19
  300. package/dist/core/task-stream.d.ts +14 -4
  301. package/dist/core/tighten-task-spec.d.ts +4 -3
  302. package/dist/core/tighten-task-spec.js +2 -4
  303. package/dist/core/tool-check-reading.d.ts +74 -0
  304. package/dist/core/tool-check-reading.js +80 -0
  305. package/dist/core/tool-policy.d.ts +62 -18
  306. package/dist/core/tool-policy.js +86 -15
  307. package/dist/core/tool-registry.d.ts +20 -0
  308. package/dist/core/tool-registry.js +4 -0
  309. package/dist/core/tool-spec.d.ts +10 -6
  310. package/dist/core/tools.js +2 -0
  311. package/dist/core/trace.d.ts +51 -32
  312. package/dist/core/types.d.ts +2 -2
  313. package/dist/core/types.js +1 -1
  314. package/dist/core/unc-spelling.d.ts +10 -0
  315. package/dist/core/unc-spelling.js +3 -0
  316. package/dist/core/untrusted-egress.d.ts +8 -0
  317. package/dist/core/untrusted-egress.js +4 -1
  318. package/dist/core/untrusted-text.d.ts +16 -0
  319. package/dist/core/untrusted-text.js +7 -2
  320. package/dist/core/user-attachment.d.ts +25 -4
  321. package/dist/core/user-attachment.js +63 -42
  322. package/dist/core/wiring-manifest.d.ts +18 -15
  323. package/dist/core/wiring-manifest.js +2 -2
  324. package/dist/engine/compaction/utils.js +1 -2
  325. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  326. package/dist/engine/execution-env/symlink-chain.js +1 -1
  327. package/dist/engine/harness/agent-harness.d.ts +1 -1
  328. package/dist/engine/harness/agent-harness.js +5 -4
  329. package/dist/engine/harness/types.d.ts +20 -16
  330. package/dist/engine/harness/types.js +7 -1
  331. package/dist/engine/llm/types.d.ts +12 -7
  332. package/dist/engine/loop/agent-loop.d.ts +12 -1
  333. package/dist/engine/loop/agent-loop.js +18 -6
  334. package/dist/engine/loop/types.d.ts +8 -2
  335. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  336. package/dist/engine/session/import-validate.js +3 -10
  337. package/dist/engine/session/session.d.ts +4 -4
  338. package/dist/engine/session/session.js +4 -4
  339. package/dist/index.d.ts +33 -23
  340. package/dist/index.js +23 -15
  341. package/dist/internal/harness.d.ts +2 -1
  342. package/dist/internal/harness.js +2 -1
  343. package/dist/orchestration/goal.d.ts +24 -1
  344. package/dist/orchestration/goal.js +3 -2
  345. package/dist/orchestration/run-spec.d.ts +4 -6
  346. package/dist/orchestration/run-spec.js +39 -63
  347. package/dist/orchestration/run-workflow-tool.js +1 -2
  348. package/dist/orchestration/workflow.d.ts +11 -3
  349. package/dist/orchestration/workflow.js +11 -2
  350. package/dist/prompt-assembly/artifact-store.d.ts +72 -56
  351. package/dist/prompt-assembly/artifact-store.js +60 -52
  352. package/dist/prompt-assembly/artifact.d.ts +90 -76
  353. package/dist/prompt-assembly/artifact.js +197 -145
  354. package/dist/prompt-assembly/assemble.d.ts +36 -29
  355. package/dist/prompt-assembly/assemble.js +34 -220
  356. package/dist/prompt-assembly/bands.d.ts +20 -0
  357. package/dist/prompt-assembly/bands.js +18 -0
  358. package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
  359. package/dist/prompt-assembly/catalog/constitution.js +69 -0
  360. package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
  361. package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
  362. package/dist/prompt-assembly/catalog/index.d.ts +11 -0
  363. package/dist/prompt-assembly/catalog/index.js +60 -0
  364. package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
  365. package/dist/prompt-assembly/catalog/memory.js +6 -0
  366. package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
  367. package/dist/prompt-assembly/catalog/modes.js +137 -0
  368. package/dist/prompt-assembly/catalog/role.d.ts +10 -0
  369. package/dist/prompt-assembly/catalog/role.js +157 -0
  370. package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
  371. package/dist/prompt-assembly/catalog/schema.js +25 -0
  372. package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
  373. package/dist/prompt-assembly/catalog/sections.js +98 -0
  374. package/dist/prompt-assembly/catalog/team.d.ts +4 -0
  375. package/dist/prompt-assembly/catalog/team.js +258 -0
  376. package/dist/prompt-assembly/composer.d.ts +26 -28
  377. package/dist/prompt-assembly/composer.js +124 -46
  378. package/dist/prompt-assembly/epoch.d.ts +89 -79
  379. package/dist/prompt-assembly/epoch.js +115 -142
  380. package/dist/prompt-assembly/explain.d.ts +58 -34
  381. package/dist/prompt-assembly/explain.js +21 -24
  382. package/dist/prompt-assembly/overlay.d.ts +137 -0
  383. package/dist/prompt-assembly/overlay.js +339 -0
  384. package/dist/prompt-assembly/renderers.d.ts +21 -0
  385. package/dist/prompt-assembly/renderers.js +39 -0
  386. package/dist/prompt-assembly/section-usage.d.ts +3 -3
  387. package/dist/prompt-assembly/section-usage.js +1 -1
  388. package/dist/prompt-assembly/select.d.ts +71 -0
  389. package/dist/prompt-assembly/select.js +106 -0
  390. package/dist/prompt-assembly/sugar.d.ts +31 -0
  391. package/dist/prompt-assembly/sugar.js +20 -0
  392. package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
  393. package/dist/prompt-assembly/types.d.ts +45 -148
  394. package/dist/prompts/coordinator.d.ts +2 -21
  395. package/dist/prompts/coordinator.js +3 -255
  396. package/dist/prompts/cowork.d.ts +27 -16
  397. package/dist/prompts/cowork.js +2 -23
  398. package/dist/prompts/default.d.ts +38 -511
  399. package/dist/prompts/default.js +20 -288
  400. package/dist/prompts/supervisor.d.ts +6 -71
  401. package/dist/prompts/supervisor.js +6 -117
  402. package/dist/stores/file/permission-rule-store.d.ts +1 -1
  403. package/dist/stores/file/permission-rule-store.js +2 -1
  404. package/dist/tools/artifact/artifact-tool.js +4 -3
  405. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
  406. package/dist/tools/fs/dir-entries.d.ts +4 -2
  407. package/dist/tools/fs/dir-entries.js +16 -4
  408. package/dist/tools/fs/fs-bash.d.ts +1 -1
  409. package/dist/tools/fs/fs-bash.js +22 -11
  410. package/dist/tools/fs/fs-pdf.js +17 -13
  411. package/dist/tools/fs/fs-read.js +4 -3
  412. package/dist/tools/fs/fs-shared.d.ts +1 -10
  413. package/dist/tools/fs/fs-shared.js +3 -4
  414. package/dist/tools/fs/fs-write.js +2 -1
  415. package/dist/tools/fs/notebook.js +1 -1
  416. package/dist/tools/fs/pdf.d.ts +20 -10
  417. package/dist/tools/fs/pdf.js +19 -10
  418. package/dist/tools/fs/program-read-model.d.ts +68 -8
  419. package/dist/tools/fs/program-read-model.js +112 -33
  420. package/dist/tools/fs/program-read-model.rows.js +30 -10
  421. package/dist/tools/fs/read-deny-home.d.ts +25 -9
  422. package/dist/tools/fs/read-deny-home.js +28 -27
  423. package/dist/tools/fs/read-deny.d.ts +41 -11
  424. package/dist/tools/fs/read-deny.js +51 -5
  425. package/dist/tools/fs/safety.d.ts +4 -26
  426. package/dist/tools/fs/safety.js +10 -32
  427. package/dist/tools/fs/search.js +15 -10
  428. package/dist/tools/fs/shell-read-argv.d.ts +3 -2
  429. package/dist/tools/fs/shell-read-argv.js +118 -38
  430. package/dist/tools/fs/shell-read-establish.d.ts +5 -5
  431. package/dist/tools/fs/shell-read-establish.js +11 -61
  432. package/dist/tools/fs/shell-read-identity.js +6 -3
  433. package/dist/tools/fs/shell-read-judge.d.ts +13 -15
  434. package/dist/tools/fs/shell-read-judge.js +18 -4
  435. package/dist/tools/fs/shell-read-plan.d.ts +2 -2
  436. package/dist/tools/web.js +1 -1
  437. package/package.json +13 -1
  438. package/test/export-surface.snapshot.json +306 -103
  439. package/wire-changes/core@7.52.0.json +5859 -0
  440. package/wire-changes/core@7.53.0.json +1946 -0
  441. package/dist/core/hook-seats.d.ts +0 -66
  442. package/dist/core/hook-seats.js +0 -37
  443. package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
  444. package/dist/prompt-assembly/packs/sema-default.js +0 -147
  445. package/dist/prompts/simple-sections.d.ts +0 -58
  446. package/dist/prompts/simple-sections.js +0 -43
@@ -0,0 +1,188 @@
1
+ export const RECEIPT_FAULTS = Object.freeze(["proxy", "accessor", "hidden", "getter-threw", "prototype-moved", "not-data", "cycle", "too-deep", "uncopyable"]);
2
+ export function isPlainRecord(v) {
3
+ if (typeof v !== "object" || v === null || Array.isArray(v))
4
+ return false;
5
+ const proto = Object.getPrototypeOf(v);
6
+ return proto === Object.prototype || proto === null;
7
+ }
8
+ function isOrdinaryArray(v) {
9
+ return Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype;
10
+ }
11
+ export function receive(value, mode, held) {
12
+ const seen = new Map();
13
+ const path = [];
14
+ const open = new Set();
15
+ const heights = new Map();
16
+ const faults = [];
17
+ const refusedAt = new Map();
18
+ const stack = [];
19
+ const refusals = new Set();
20
+ const refuse = (kind) => {
21
+ const fault = Object.freeze({ kind, path: Object.freeze([...path]) });
22
+ refusals.add(fault);
23
+ throw fault;
24
+ };
25
+ const faultOf = (err) => typeof err === "object" && err !== null && refusals.has(err) ? err : Object.freeze({ kind: "uncopyable", path: Object.freeze([...path]) });
26
+ const other = (v, kind) => (mode.others === "as-is" ? v : refuse(kind));
27
+ const refuseContainer = (v, kind) => {
28
+ if (mode.contain === true) {
29
+ refusedAt.set(v, kind);
30
+ open.delete(v);
31
+ }
32
+ return refuse(kind);
33
+ };
34
+ const memberOf = (v, d) => {
35
+ if (Object.hasOwn(d, "value")) {
36
+ if (mode.accessors === "refuse" && d.enumerable !== true)
37
+ refuse("hidden");
38
+ return d.value;
39
+ }
40
+ if (mode.accessors === "refuse")
41
+ refuse("accessor");
42
+ const get = Object.hasOwn(d, "get") ? d.get : undefined;
43
+ try {
44
+ return get === undefined ? undefined : Reflect.apply(get, v, []);
45
+ }
46
+ catch {
47
+ return refuse("getter-threw");
48
+ }
49
+ };
50
+ const measured = mode.past === "refuse" || mode.others !== "as-is";
51
+ const heightOf = (v) => heights.get(v) ?? (open.has(v) || (held?.has(v) === true && mode.isProxy?.(v) !== true && (isOrdinaryArray(v) || isPlainRecord(v))) ? 1 : 0);
52
+ const pastDepth = (v, level) => measured && level + heightOf(v) > mode.depth;
53
+ const meet = (v, level) => {
54
+ if (v === null || v === undefined || typeof v === "string" || typeof v === "number" || typeof v === "boolean")
55
+ return v;
56
+ if (typeof v !== "object")
57
+ return other(v, "not-data");
58
+ if (held?.has(v) === true)
59
+ return pastDepth(v, level) ? refuse("too-deep") : v;
60
+ if (seen.has(v)) {
61
+ if (refusedAt.has(v))
62
+ return refuse(refusedAt.get(v));
63
+ if (open.has(v) && mode.others !== "as-is")
64
+ return refuse("cycle");
65
+ return pastDepth(v, level) ? refuse("too-deep") : seen.get(v);
66
+ }
67
+ if (level >= mode.depth && mode.past === "refuse") {
68
+ if (mode.isProxy?.(v) === true)
69
+ return refuse("proxy");
70
+ if (isOrdinaryArray(v) || isPlainRecord(v))
71
+ return refuse("too-deep");
72
+ }
73
+ if (level >= mode.depth)
74
+ return other(v, "too-deep");
75
+ if (mode.isProxy?.(v) === true)
76
+ return refuse("proxy");
77
+ const list = isOrdinaryArray(v) || (mode.others === "copy" && Array.isArray(v));
78
+ if (!list && !isPlainRecord(v) && mode.others !== "copy")
79
+ return other(v, "not-data");
80
+ const proto = Object.getPrototypeOf(v);
81
+ const captured = Object.getOwnPropertyDescriptors(v);
82
+ const out = list ? [] : {};
83
+ seen.set(v, out);
84
+ open.add(v);
85
+ if (mode.accessors === "refuse" && Object.getOwnPropertySymbols(captured).length > 0)
86
+ refuseContainer(v, "hidden");
87
+ stack.push({ v, out, list, proto, captured, keys: Object.getOwnPropertyNames(captured), level, next: 0, height: 1, key: "", member: undefined });
88
+ return out;
89
+ };
90
+ const land = (f, key, copy, member) => {
91
+ if (measured && typeof member === "object" && member !== null)
92
+ f.height = Math.max(f.height, heightOf(member) + 1);
93
+ Object.defineProperty(f.out, key, { value: copy, enumerable: true, writable: true, configurable: true });
94
+ path.length = f.level;
95
+ };
96
+ const finish = (f) => {
97
+ heights.set(f.v, f.height);
98
+ if (mode.accessors === "call-once" && mode.others !== "copy" && Object.getPrototypeOf(f.v) !== f.proto)
99
+ refuseContainer(f.v, "prototype-moved");
100
+ if (Array.isArray(f.out)) {
101
+ const length = f.captured["length"]?.value;
102
+ if (typeof length === "number")
103
+ f.out.length = length;
104
+ }
105
+ if (mode.freeze === true)
106
+ Object.freeze(f.out);
107
+ open.delete(f.v);
108
+ return f.out;
109
+ };
110
+ const received = (copy) => (mode.contain === true ? { ok: true, value: copy, faults: Object.freeze(faults) } : { ok: true, value: copy });
111
+ try {
112
+ const copy = meet(value, 0);
113
+ if (stack.length === 0)
114
+ return received(copy);
115
+ }
116
+ catch (err) {
117
+ return { ok: false, fault: faultOf(err) };
118
+ }
119
+ for (;;) {
120
+ const f = stack[stack.length - 1];
121
+ if (f.next < f.keys.length) {
122
+ const key = f.keys[f.next++];
123
+ if (f.list && key === "length")
124
+ continue;
125
+ path.push(key);
126
+ try {
127
+ const member = memberOf(f.v, f.captured[key]);
128
+ const frames = stack.length;
129
+ const copy = meet(member, f.level + 1);
130
+ if (stack.length > frames) {
131
+ f.key = key;
132
+ f.member = member;
133
+ }
134
+ else
135
+ land(f, key, copy, member);
136
+ }
137
+ catch (err) {
138
+ if (mode.contain !== true)
139
+ return { ok: false, fault: faultOf(err) };
140
+ faults.push(faultOf(err));
141
+ path.length = f.level;
142
+ }
143
+ continue;
144
+ }
145
+ let copy;
146
+ try {
147
+ copy = finish(f);
148
+ }
149
+ catch (err) {
150
+ stack.pop();
151
+ const holder = stack[stack.length - 1];
152
+ if (mode.contain !== true || holder === undefined)
153
+ return { ok: false, fault: faultOf(err) };
154
+ faults.push(faultOf(err));
155
+ path.length = holder.level;
156
+ continue;
157
+ }
158
+ stack.pop();
159
+ const holder = stack[stack.length - 1];
160
+ if (holder === undefined)
161
+ return received(copy);
162
+ land(holder, holder.key, copy, holder.member);
163
+ }
164
+ }
165
+ export const MODS_PAYLOAD_MODE = Object.freeze({ accessors: "refuse", depth: Infinity, others: "as-is", freeze: true });
166
+ export function describeFault(fault) {
167
+ const at = fault.path.length > 0 ? ` at ${fault.path.join(".")}` : "";
168
+ switch (fault.kind) {
169
+ case "proxy":
170
+ return `a Proxy${at}`;
171
+ case "accessor":
172
+ return `an accessor${at} (a getter is never run)`;
173
+ case "hidden":
174
+ return `a member that is not an enumerable data property${at}`;
175
+ case "getter-threw":
176
+ return `a getter that threw${at}`;
177
+ case "prototype-moved":
178
+ return `a prototype that moved while it was read${at}`;
179
+ case "not-data":
180
+ return `a value that is not data${at}`;
181
+ case "cycle":
182
+ return `a cycle${at}`;
183
+ case "too-deep":
184
+ return `a value nested too deep${at}`;
185
+ case "uncopyable":
186
+ return `a value that could not be copied whole${at}`;
187
+ }
188
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * The registration form, the two seats, and the screen every registration passes before admission:
3
+ * shape, unique name, the seat × tier table, the `uses` declaration, and the `budgetMs` fallback.
4
+ */
5
+ import { type ModBusSide, type ModEventName, type ModRegistrationTier, type ModSeat, type ModTier } from "./events.js";
6
+ import { type ModBudgetReading } from "./budget.js";
7
+ import type { ModEventPayload, ModFailureCause, ModMatcher, ModSkip } from "./site-rules.js";
8
+ /** The configuration refusal: a registration the kernel cannot take refuses the whole prepare. */
9
+ export declare const MODS_INVALID_CODE = "config.mods_invalid";
10
+ /** The notice an admission refusal becomes (the run goes on without the refused registration). */
11
+ export declare const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
12
+ /** What a registration declares it will touch — the upper bound the kernel holds it to. */
13
+ export interface ModUses {
14
+ /** Events it hangs handlers on (names or `<prefix>.*`). */
15
+ readonly events: readonly string[];
16
+ /** `$` methods it calls (method event names). */
17
+ readonly calls: readonly string[];
18
+ }
19
+ /** Who raised a dispatch: a registration (through its `$`), or the engine (`{plugin: "engine", tier: "core"}`). */
20
+ export interface ModOrigin {
21
+ readonly plugin: string;
22
+ readonly tier: ModTier;
23
+ }
24
+ /** The engine's own origin; its `plugin` word is reserved (no registration may take it). */
25
+ export declare const ENGINE_ORIGIN: ModOrigin;
26
+ /** The facts `$.plugin` carries. */
27
+ export interface ModPluginFacts {
28
+ readonly name: string;
29
+ }
30
+ /** The part of `$` every bus gives; each side adds its methods (`$.<noun>.<method>`). */
31
+ export interface ModDollarBase {
32
+ readonly plugin: ModPluginFacts;
33
+ }
34
+ /** One entry of `next.trace`: a handler (or the core) that ran beneath, and how it ended. */
35
+ export interface ModTraceEntry {
36
+ readonly index: number;
37
+ readonly plugin: string;
38
+ readonly tier: ModTier;
39
+ readonly outcome: ModTraceOutcome;
40
+ readonly ms: number;
41
+ }
42
+ /** How a chain member ended (CC words). */
43
+ export declare const MOD_TRACE_OUTCOMES: readonly ["returned", "passed", "rejected", "caught", "expired", "kept", "skipped", "bypassed"];
44
+ export type ModTraceOutcome = (typeof MOD_TRACE_OUTCOMES)[number];
45
+ /** What a `.catch` reads off `next.error`. */
46
+ export interface ModCaughtError {
47
+ readonly kind: ModFailureCause;
48
+ readonly message?: string;
49
+ readonly budget: number;
50
+ }
51
+ /** The third argument of a handler: continue the chain, or jump (prepend / append only). */
52
+ export interface ModNext {
53
+ (e: ModEventPayload): Promise<unknown>;
54
+ to(e: ModEventPayload, tier: ModTier): Promise<unknown>;
55
+ readonly origin: ModOrigin;
56
+ readonly signal: AbortSignal;
57
+ /** What ran beneath this handler's last `next`. */
58
+ readonly trace: readonly ModTraceEntry[];
59
+ readonly budget: ModBudgetReading;
60
+ /** Present on a `.catch`'s `next` only. */
61
+ readonly error?: ModCaughtError;
62
+ /** Present on a `.catch`'s `next` only: whether the failed handler had called `next`. */
63
+ readonly called?: boolean;
64
+ }
65
+ export type ModHandler<D extends ModDollarBase = ModDollarBase> = ($: D, e: ModEventPayload, next: ModNext) => unknown;
66
+ export interface ModHandlerOptions<D extends ModDollarBase = ModDollarBase> {
67
+ /** Answers for the handler when it throws, runs out of budget or breaks the site's contract. */
68
+ readonly catch?: ModHandler<D>;
69
+ /** Watch only: a detached `e`, outside the chain, its answer refused and disclosed. */
70
+ readonly observe?: boolean;
71
+ }
72
+ /** `on(pattern, handler, options?)` or `on(pattern, matcher, handler, options?)`. */
73
+ export interface On<D extends ModDollarBase = ModDollarBase> {
74
+ (pattern: string, handler: ModHandler<D>, options?: ModHandlerOptions<D>): void;
75
+ (pattern: string, matcher: ModMatcher, handler: ModHandler<D>, options?: ModHandlerOptions<D>): void;
76
+ }
77
+ export interface ModRegistration<D extends ModDollarBase = ModDollarBase> {
78
+ /** Unique in the run; names the registration everywhere (origin, trace, disclosures, admission). */
79
+ readonly name: string;
80
+ /** Deployment seat: required. Task seat: absent or `user`. */
81
+ readonly tier?: ModRegistrationTier;
82
+ readonly uses: ModUses;
83
+ /** The host's provenance label, handed to admission as given. */
84
+ readonly provenance?: string;
85
+ /** Each handler's own time; default 10 000 ms. */
86
+ readonly budgetMs?: number;
87
+ readonly options?: unknown;
88
+ register(on: On<D>, options: unknown): void;
89
+ }
90
+ /** One admission result: mounted (with the patterns it actually hung) or refused (by whom, why). */
91
+ export type ModAdmissionRecord = {
92
+ readonly name: string;
93
+ readonly seat: ModSeat;
94
+ readonly tier: ModTier;
95
+ readonly events: readonly string[];
96
+ readonly observe?: readonly string[];
97
+ /** Judges skipped while this registration was judged (their failure or site violation), as the dispatch listed them. */
98
+ readonly skipped?: readonly ModSkip[];
99
+ } | {
100
+ readonly name: string;
101
+ readonly seat: ModSeat;
102
+ readonly tier: ModTier;
103
+ readonly refusedBy: string;
104
+ readonly reason: string;
105
+ };
106
+ /** The two seats as a bus receives them; a seat is a list of registrations or absent. Screened as untrusted input. */
107
+ export interface ModSeats<D extends ModDollarBase = ModDollarBase> {
108
+ readonly deployment?: readonly ModRegistration<D>[];
109
+ readonly task?: readonly ModRegistration<D>[];
110
+ }
111
+ /** A registration that passed the screen, in run order. */
112
+ export interface ScreenedRegistration<D extends ModDollarBase = ModDollarBase> {
113
+ readonly registration: ModRegistration<D>;
114
+ readonly name: string;
115
+ readonly seat: ModSeat;
116
+ readonly tier: ModRegistrationTier;
117
+ readonly budgetMs: number;
118
+ readonly uses: ModUses;
119
+ readonly provenance?: string;
120
+ readonly eventsBound: ReadonlySet<ModEventName>;
121
+ readonly callsBound: ReadonlySet<ModEventName>;
122
+ }
123
+ export declare function modsInvalid(message: string): Error & {
124
+ readonly code: string;
125
+ };
126
+ /**
127
+ * Screen both seats and put the registrations in run order: by tier, then deployment before task, then
128
+ * each seat's own order. Throws `config.mods_invalid` for anything the kernel cannot take; a bad
129
+ * `budgetMs` is reported and replaced by the default instead.
130
+ */
131
+ export declare function screenModSeats<D extends ModDollarBase>(seats: ModSeats<D>, side: ModBusSide, report: (err: Error) => void): ScreenedRegistration<D>[];
@@ -0,0 +1,102 @@
1
+ import { describe, expandModPattern, MOD_SEATS, readOnSide, SEAT_TIER_TABLE, } from "./events.js";
2
+ import { resolveModBudgetMs } from "./budget.js";
3
+ export const MODS_INVALID_CODE = "config.mods_invalid";
4
+ export const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
5
+ export const ENGINE_ORIGIN = Object.freeze({ plugin: "engine", tier: "core" });
6
+ export const MOD_TRACE_OUTCOMES = Object.freeze(["returned", "passed", "rejected", "caught", "expired", "kept", "skipped", "bypassed"]);
7
+ export function modsInvalid(message) {
8
+ return Object.assign(new Error(message), { code: MODS_INVALID_CODE });
9
+ }
10
+ const TIER_ORDER = ["prepend", "user", "append"];
11
+ export function screenModSeats(seats, side, report) {
12
+ const out = [];
13
+ const names = new Set();
14
+ for (const seat of MOD_SEATS) {
15
+ const list = seats[seat];
16
+ if (list === undefined)
17
+ continue;
18
+ if (!Array.isArray(list))
19
+ throw modsInvalid(`the ${seat} seat's mods must be a list of registrations, not ${describe(list)}`);
20
+ for (const item of list) {
21
+ const screened = screenOne(item, seat, side, report);
22
+ if (names.has(screened.name))
23
+ throw modsInvalid(`two registrations are named "${screened.name}" — a registration name is unique in the run`);
24
+ names.add(screened.name);
25
+ out.push(screened);
26
+ }
27
+ }
28
+ return out.sort((a, b) => TIER_ORDER.indexOf(a.tier) - TIER_ORDER.indexOf(b.tier));
29
+ }
30
+ function isRegistration(v) {
31
+ return typeof v === "object" && v !== null && typeof Reflect.get(v, "name") === "string" && typeof Reflect.get(v, "register") === "function";
32
+ }
33
+ function screenOne(item, seat, side, report) {
34
+ if (!isRegistration(item))
35
+ throw modsInvalid(`a ${seat} mods entry is ${describe(item)}; a registration has a name and a register function`);
36
+ const name = item.name;
37
+ if (name === "")
38
+ throw modsInvalid(`a ${seat} registration has an empty name`);
39
+ if (name === ENGINE_ORIGIN.plugin)
40
+ throw modsInvalid(`a ${seat} registration is named "${name}", the engine's own origin word — choose another name`);
41
+ const tier = tierOf(item.tier, seat, name);
42
+ const uses = usesOf(item.uses, name);
43
+ if (item.provenance !== undefined && typeof item.provenance !== "string")
44
+ throw modsInvalid(`${name}: provenance is ${describe(item.provenance)}; it is a label (a string)`);
45
+ const eventsBound = new Set();
46
+ for (const p of uses.events)
47
+ for (const n of namesOf(p, name, "uses.events"))
48
+ eventsBound.add(n);
49
+ const callsBound = new Set();
50
+ for (const c of uses.calls)
51
+ for (const n of namesOf(c, name, "uses.calls"))
52
+ if (readOnSide(n, side))
53
+ callsBound.add(n);
54
+ return {
55
+ registration: item,
56
+ name,
57
+ seat,
58
+ tier,
59
+ budgetMs: resolveModBudgetMs(item.budgetMs, report, name),
60
+ uses,
61
+ ...(item.provenance !== undefined ? { provenance: item.provenance } : {}),
62
+ eventsBound,
63
+ callsBound,
64
+ };
65
+ }
66
+ function tierOf(declared, seat, name) {
67
+ const row = SEAT_TIER_TABLE[seat];
68
+ const allowed = row.tiers;
69
+ if (declared === undefined) {
70
+ if (row.declared === "required")
71
+ throw modsInvalid(`${name}: a ${seat} registration declares its tier (${allowed.join(", ")})`);
72
+ return allowed[0];
73
+ }
74
+ const tier = allowed.find((t) => t === declared);
75
+ if (tier === undefined)
76
+ throw modsInvalid(`${name}: a ${seat} registration's tier is ${allowed.join(" or ")}, not ${describe(declared)}`);
77
+ return tier;
78
+ }
79
+ function usesOf(uses, name) {
80
+ if (typeof uses !== "object" || uses === null)
81
+ throw modsInvalid(`${name}: uses is ${describe(uses)}; it declares { events, calls }`);
82
+ const events = stringList(Reflect.get(uses, "events"), name, "uses.events");
83
+ const calls = stringList(Reflect.get(uses, "calls"), name, "uses.calls");
84
+ return Object.freeze({ events, calls });
85
+ }
86
+ function stringList(v, name, field) {
87
+ if (!Array.isArray(v))
88
+ throw modsInvalid(`${name}: ${field} is ${describe(v)}; it is a list of event names`);
89
+ const out = [];
90
+ for (const x of v) {
91
+ if (typeof x !== "string")
92
+ throw modsInvalid(`${name}: ${field} holds ${describe(x)}; it is a list of event names`);
93
+ out.push(x);
94
+ }
95
+ return Object.freeze(out);
96
+ }
97
+ function namesOf(pattern, name, field) {
98
+ const expanded = expandModPattern(pattern);
99
+ if ("refusal" in expanded)
100
+ throw modsInvalid(`${name}: ${field}: ${expanded.refusal}`);
101
+ return expanded.names;
102
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Site rules: what a handler may hand on and answer. A handler that changes a pinned key on the way down,
3
+ * or answers outside the station's answer form, breaks the site's contract — a VIOLATION, judged by the
4
+ * failure column like a crash but never reported as one (no code crashed).
5
+ */
6
+ import { type ModSeat, type ModTier } from "./events.js";
7
+ /** The host's Proxy probe (this folder cannot recognise a Proxy on its own): with one, a handler's Proxy is refused
8
+ * before any of its traps runs; without one, it is read like any object. */
9
+ export type ProxyProbe = (value: object) => boolean;
10
+ /**
11
+ * The one depth the bus holds a handler's values to: how many container levels a value may have below a payload member
12
+ * or an answer's top (1 = the member itself). Every value a handler gives the bus — what it hands to `next`, a `$`
13
+ * call's arguments, its answer — is received in a mode bounded by it (a shared reference measured again where it sits
14
+ * each time it is met), so a value nested deeper is refused by the first walk that meets it before that
15
+ * walk goes any deeper. Every walk keeps its own stack, so neither the platform nor the caller's stack depth decides.
16
+ * The pinned-key comparison is held to the same depth. A container is one level wherever it is met, so the verdict
17
+ * does not depend on member order for a value without a cycle; through a cycle, depth is measured on the walk's way (a
18
+ * container still being walked counts as one level where it is met again). The engine's own event is received at any
19
+ * depth, and its objects — handed back anywhere in what a handler hands on, answers or passes to a `$` call — are taken
20
+ * as themselves, never walked: one of its containers is one level where it sits, whatever it holds.
21
+ */
22
+ export declare const MODS_VALUE_DEPTH = 1000;
23
+ /** Why a handler did not answer for itself: it threw, it ran past its budget, it broke the site's contract, or it was
24
+ * not run because the dispatch re-entered a frame it is part of (its `.catch` answers for it — CC 296 form, (cli296.js:242947) "hasCatch"). */
25
+ export declare const MOD_FAILURE_CAUSES: readonly ["threw", "timeout", "violation", "reentry"];
26
+ export type ModFailureCause = (typeof MOD_FAILURE_CAUSES)[number];
27
+ /** A handler the dispatch skipped (a failure on a skip event), and why. */
28
+ export interface ModSkip {
29
+ readonly registration: string;
30
+ readonly cause: ModFailureCause;
31
+ readonly reason: string;
32
+ }
33
+ /** An event payload as the kernel carries it: an object, top level frozen by the bus. */
34
+ export type ModEventPayload = Readonly<Record<string, unknown>>;
35
+ /** The registration whose handler gave an answer, as the station's answer check sees it. */
36
+ export interface ModAnswerer {
37
+ readonly plugin: string;
38
+ readonly seat: ModSeat;
39
+ readonly tier: ModTier;
40
+ }
41
+ /** What an answer check reads, in `below`, for a `next` the handler started that has not answered yet (no `deny`, no `value`). */
42
+ export declare const NEXT_IN_FLIGHT: Readonly<{
43
+ inFlight: true;
44
+ }>;
45
+ /** The station's own reading of an answer: undefined when it is one the station takes, else why not. `below` is every
46
+ * answer the handler's `next` resolved with, plus `NEXT_IN_FLIGHT` while its `next` is still in flight —
47
+ * empty when it never called `next`. */
48
+ export type ModAnswerCheck = (answer: unknown, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[]) => string | undefined;
49
+ /** A matcher: top-level fields of `e` that must equal these values exactly. */
50
+ export type ModMatcher = Readonly<Record<string, string | number | boolean>>;
51
+ /** Why a pinned key of what a handler handed on is not taken: it holds another value, or it is a copy the comparison
52
+ * could not walk to the end (`unproven` says why) — refused all the same, since only a copy proven the same is taken. */
53
+ export interface PinnedKeyBreak {
54
+ readonly key: string;
55
+ readonly unproven?: string;
56
+ }
57
+ /**
58
+ * The first pinned key `next` did not hand on as the engine's fact, or undefined. A pinned value is compared by value
59
+ * ({@link sameModValue}): the engine's own fact handed on as is, or a copy of it, is not a change.
60
+ */
61
+ export declare function pinnedKeyChanged(pinned: readonly string[], received: ModEventPayload, passed: ModEventPayload): PinnedKeyBreak | undefined;
62
+ /** {@link engineObjects} of a dispatch's own event, found the first time it is asked and the same set every time after:
63
+ * the event is frozen, so one finding serves every receipt of the dispatch. */
64
+ export declare function engineObjectsOnce(held: ModEventPayload): () => ReadonlySet<object>;
65
+ /**
66
+ * What the next handler reads when a handler hands `passed` to `next` (not the dispatch's own e): `passed` received
67
+ * whole in the mode held to {@link MODS_VALUE_DEPTH} (every object of the dispatch's own e in it — `engines`, found once
68
+ * per dispatch by {@link engineObjectsOnce} — kept as itself), then {@link pinnedHandOn}. A value nested past the depth
69
+ * is refused by the receipt, before any deeper walk — under a pinned key in the comparison's own words (too deep to
70
+ * compare), under any other member as the payload holding it.
71
+ */
72
+ export declare function handedOn(pinned: readonly string[], held: ModEventPayload, passed: unknown, engines: ReadonlySet<object>, isProxy?: ProxyProbe): {
73
+ readonly payload: ModEventPayload;
74
+ } | {
75
+ readonly violation: string;
76
+ };
77
+ /**
78
+ * What the next handler reads when a handler hands on `passed` (already received whole): the payload with every
79
+ * pinned key the engine's own member — the same object `held` carries, or no member where `held` has none — so a
80
+ * handler below a copy-forwarder reads the engine's fact, not the copy's shape (a member that is `undefined`, a
81
+ * member order, a −0 the comparison does not count). A pinned key the copy did not hand on as the engine's fact
82
+ * ({@link pinnedKeyChanged}) breaks the site instead. The comparison decides only whether to refuse; what travels down
83
+ * for a pinned key is the engine's member, always. The payload keeps the shape it was received in: a reference inside
84
+ * it to the payload itself is a reference to what is handed on (a cycle stays a cycle), and one to any object inside
85
+ * what the handler handed on under a pinned key — the copy itself, a member of it, an element of one of its lists, at
86
+ * any depth — is a reference to the engine's object it was proven the same as (a shared reference stays shared; an
87
+ * object of the copy standing for two of the engine's goes to the one the comparison met first). `engines`: every
88
+ * object of `held` (found here when not given).
89
+ */
90
+ export declare function pinnedHandOn(pinned: readonly string[], held: ModEventPayload, passed: ModEventPayload, engines?: ReadonlySet<object>): {
91
+ readonly payload: ModEventPayload;
92
+ } | {
93
+ readonly violation: string;
94
+ };
95
+ /** Why a handler's answer breaks the site, or undefined. No answer at all is never an answer. */
96
+ export declare function answerViolation(answer: unknown, check: ModAnswerCheck | undefined, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[]): string | undefined;
97
+ /**
98
+ * A `$` method's answer form: `{ value }` (the call's result) or `{ deny }` (the call throws). A `{ deny }` given after
99
+ * the handler's `next` was answered with something that is not a deny — or while that `next` is still running — breaks
100
+ * the form (the deny would stand in place of a call that already ran or is running) — a deny handed up from below is
101
+ * no such thing. A `{ value }` given while that `next` is still running stands in place of the same running call, so it
102
+ * breaks the form too; one given after `next` answered is the handler rewriting what it read, and stands. Counting the
103
+ * running `next` is stricter than the reference, which reads answered runs only.
104
+ */
105
+ export declare function methodAnswerViolation(answer: unknown, _e?: ModEventPayload, _by?: ModAnswerer, below?: readonly unknown[]): string | undefined;
106
+ /** Why `m` is not a matcher, or undefined. */
107
+ export declare function matcherViolation(m: unknown): string | undefined;
108
+ /** Whether every matcher field equals `e`'s own top-level field exactly. */
109
+ export declare function matcherMatches(m: ModMatcher | undefined, e: ModEventPayload): boolean;
110
+ /** A record a handler gives the bus other than through `next` — a `$` call's arguments, and a method's `enter` shaping
111
+ * of them — received held to {@link MODS_VALUE_DEPTH}; an object of `held` ({@link engineObjectsOnce} of what the bus
112
+ * already holds: the dispatch the handler runs in, or the call's received arguments) is kept as itself, never walked. */
113
+ export declare function receivePayload(v: unknown, isProxy?: ProxyProbe, held?: ReadonlySet<object>): {
114
+ readonly payload: ModEventPayload;
115
+ } | {
116
+ readonly refusal: string;
117
+ };
118
+ /** The engine's own event at a dispatch's entry, received whole at any depth (one the receipt cannot copy whole —
119
+ * reading it threw where none of its getters runs, or it holds more objects than one receipt can index — is refused,
120
+ * never handed on shorter). */
121
+ export declare function receiveEvent(e: unknown): {
122
+ readonly payload: ModEventPayload;
123
+ } | {
124
+ readonly refusal: string;
125
+ };
126
+ /**
127
+ * The bottom's answer as it starts up the chain: its top level frozen, so no handler can turn the answer it got from
128
+ * `next` into another one (a deny in place of a result that already ran). A plain record or array the bottom made is
129
+ * copied once and frozen; an answer already frozen (an engine sentinel) or not a plain container is itself.
130
+ */
131
+ export declare function answerUpward(v: unknown): unknown;
132
+ /** A handler's answer, received by the same receipt held to {@link MODS_VALUE_DEPTH} (an answer need not be a record; a
133
+ * primitive is itself); an object of the dispatch's own event in it (`engines`, {@link engineObjectsOnce}) is kept as
134
+ * itself, never walked. */
135
+ export declare function receiveAnswer(answer: unknown, engines: ReadonlySet<object>, isProxy?: ProxyProbe): {
136
+ readonly answer: unknown;
137
+ } | {
138
+ readonly refusal: string;
139
+ };
140
+ /**
141
+ * A copy for an observe handler, made by the one receipt (its own stack, so no depth of the event decides whether an
142
+ * observer runs — the event it observes was received at any depth too): every data container (a plain object, an
143
+ * ordinary array) detached at any depth; then every other object the copy holds — a tool result's `Map`, `Date` or
144
+ * typed array — detached by a structured clone of that object alone (one clone per object, so a shared one stays shared),
145
+ * and one the clone refuses (a function, a handle, a class instance holding one) handed as is. The engine's own event
146
+ * holds data properties only, so the copy is whole; a receipt that could not make it (a Proxy whose trap throws, on a bus
147
+ * given no probe) is the observer's failure, reported like any other.
148
+ */
149
+ export declare function detachedCopy(e: ModEventPayload): Record<string, unknown>;