@sema-agent/core 7.51.1 → 7.52.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 (372) hide show
  1. package/CHANGELOG.md +550 -2
  2. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  3. package/dist/agents/cascade.js +4 -0
  4. package/dist/agents/cumulative-stats.d.ts +3 -0
  5. package/dist/agents/cumulative-stats.js +3 -0
  6. package/dist/agents/list-agents-tool.d.ts +1 -1
  7. package/dist/agents/read-inbox-tool.d.ts +1 -1
  8. package/dist/agents/repair-loop.js +4 -0
  9. package/dist/agents/send-message-tool.d.ts +11 -16
  10. package/dist/agents/send-message-tool.js +11 -13
  11. package/dist/agents/subagent.d.ts +5 -0
  12. package/dist/agents/subagent.js +7 -4
  13. package/dist/agents/tool-filter.d.ts +40 -13
  14. package/dist/agents/tool-filter.js +28 -14
  15. package/dist/bench/metrics.d.ts +1 -0
  16. package/dist/brain/anthropic.js +16 -12
  17. package/dist/brain/model-presets.d.ts +4 -5
  18. package/dist/brain/model-presets.js +4 -4
  19. package/dist/brain/open-responses.js +16 -12
  20. package/dist/brain/openai.js +16 -12
  21. package/dist/brain/request-params.d.ts +12 -33
  22. package/dist/brain/request-params.js +5 -2
  23. package/dist/brain/request-route.d.ts +9 -8
  24. package/dist/brain/request-route.js +1 -0
  25. package/dist/brain/route-adjudicator.d.ts +117 -47
  26. package/dist/brain/route-adjudicator.js +171 -42
  27. package/dist/brain/route-conformance.js +2 -2
  28. package/dist/brain/status-sink.d.ts +18 -0
  29. package/dist/brain/status-sink.js +7 -0
  30. package/dist/core/allow-entry.d.ts +42 -8
  31. package/dist/core/allow-entry.js +24 -17
  32. package/dist/core/auto-compaction.d.ts +23 -20
  33. package/dist/core/auto-compaction.js +37 -16
  34. package/dist/core/auto-promote.d.ts +2 -1
  35. package/dist/core/auto-promote.js +2 -2
  36. package/dist/core/caller-tool-name.d.ts +9 -0
  37. package/dist/core/caller-tool-name.js +13 -0
  38. package/dist/core/checkpoint-requirements.d.ts +7 -1
  39. package/dist/core/checkpoint-requirements.js +2 -0
  40. package/dist/core/checkpoint-store.d.ts +36 -12
  41. package/dist/core/checkpoint-store.js +1 -1
  42. package/dist/core/child-clamp-seats.d.ts +6 -0
  43. package/dist/core/child-clamp-seats.js +2 -1
  44. package/dist/core/credential-vocabulary.d.ts +33 -8
  45. package/dist/core/credential-vocabulary.js +32 -7
  46. package/dist/core/decision-receipt.d.ts +2 -2
  47. package/dist/core/delegation-frames.d.ts +9 -2
  48. package/dist/core/delegation-name.d.ts +18 -0
  49. package/dist/core/delegation-name.js +47 -0
  50. package/dist/core/engine-capabilities.d.ts +8 -1
  51. package/dist/core/engine-capabilities.js +1 -1
  52. package/dist/core/engine-notice.d.ts +36 -19
  53. package/dist/core/frontmatter-fence.d.ts +10 -0
  54. package/dist/core/frontmatter-fence.js +6 -0
  55. package/dist/core/gate-fold.js +5 -23
  56. package/dist/core/gate-lanes.js +356 -270
  57. package/dist/core/governance-codes.d.ts +9 -4
  58. package/dist/core/governance-codes.js +9 -3
  59. package/dist/core/hooks.d.ts +276 -734
  60. package/dist/core/hooks.js +97 -192
  61. package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
  62. package/dist/{tools/fs → core}/image-admission.js +24 -6
  63. package/dist/core/locked-config.d.ts +26 -5
  64. package/dist/core/locked-config.js +31 -6
  65. package/dist/core/mcp-connection-pool.d.ts +4 -1
  66. package/dist/core/mcp-connection-pool.js +7 -2
  67. package/dist/core/mcp-probe.d.ts +12 -9
  68. package/dist/core/mcp-probe.js +2 -2
  69. package/dist/core/mcp-server-spec.d.ts +53 -7
  70. package/dist/core/mcp-server-spec.js +84 -1
  71. package/dist/core/mcp.d.ts +11 -7
  72. package/dist/core/mcp.js +27 -9
  73. package/dist/core/memory-engine/data-plane.js +5 -1
  74. package/dist/core/memory-engine/distiller.js +16 -2
  75. package/dist/core/memory-engine/engine.d.ts +8 -11
  76. package/dist/core/memory-engine/engine.js +9 -5
  77. package/dist/core/memory-engine/frontmatter.d.ts +6 -0
  78. package/dist/core/memory-engine/frontmatter.js +19 -16
  79. package/dist/core/memory.d.ts +2 -2
  80. package/dist/core/mode-policy.d.ts +4 -0
  81. package/dist/core/mode-policy.js +7 -5
  82. package/dist/core/model-seat.d.ts +4 -1
  83. package/dist/core/mods/dollar.d.ts +109 -0
  84. package/dist/core/mods/dollar.js +154 -0
  85. package/dist/core/mods/host.d.ts +23 -0
  86. package/dist/core/mods/host.js +21 -0
  87. package/dist/core/mods/kernel/budget.d.ts +43 -0
  88. package/dist/core/mods/kernel/budget.js +83 -0
  89. package/dist/core/mods/kernel/dispatch.d.ts +100 -0
  90. package/dist/core/mods/kernel/dispatch.js +701 -0
  91. package/dist/core/mods/kernel/events.d.ts +242 -0
  92. package/dist/core/mods/kernel/events.js +210 -0
  93. package/dist/core/mods/kernel/index.d.ts +6 -0
  94. package/dist/core/mods/kernel/index.js +5 -0
  95. package/dist/core/mods/kernel/receive.d.ts +65 -0
  96. package/dist/core/mods/kernel/receive.js +123 -0
  97. package/dist/core/mods/kernel/registration.d.ts +131 -0
  98. package/dist/core/mods/kernel/registration.js +102 -0
  99. package/dist/core/mods/kernel/site-rules.d.ts +84 -0
  100. package/dist/core/mods/kernel/site-rules.js +104 -0
  101. package/dist/core/mods/stations.d.ts +350 -0
  102. package/dist/core/mods/stations.js +444 -0
  103. package/dist/core/own-property-receipt.js +11 -23
  104. package/dist/core/parent-spec-seat.d.ts +18 -7
  105. package/dist/core/parent-spec-seat.js +6 -2
  106. package/dist/core/path-identity.js +2 -1
  107. package/dist/core/permission-rule-syntax.d.ts +15 -0
  108. package/dist/core/permission-rule-syntax.js +24 -16
  109. package/dist/core/permission-rules.d.ts +7 -1
  110. package/dist/core/permission-rules.js +26 -15
  111. package/dist/core/prompt-section-seat.d.ts +15 -27
  112. package/dist/core/prompt-section-seat.js +73 -40
  113. package/dist/core/protocol-http-auth.d.ts +3 -1
  114. package/dist/core/protocol-http-auth.js +2 -0
  115. package/dist/core/reminder-mint.d.ts +2 -2
  116. package/dist/core/remote-env.d.ts +24 -12
  117. package/dist/core/remote-env.js +1 -0
  118. package/dist/core/resume-startup-cause.d.ts +16 -1
  119. package/dist/core/resume-startup-cause.js +4 -1
  120. package/dist/core/retired-keys.d.ts +4 -0
  121. package/dist/core/retired-keys.js +3 -0
  122. package/dist/core/runner/announce-once-ledger.d.ts +31 -1
  123. package/dist/core/runner/announce-once-ledger.js +22 -0
  124. package/dist/core/runner/assemble-result.d.ts +9 -0
  125. package/dist/core/runner/assemble-result.js +3 -1
  126. package/dist/core/runner/call-hook-stations.d.ts +23 -27
  127. package/dist/core/runner/call-hook-stations.js +58 -42
  128. package/dist/core/runner/caller-stop-gate.d.ts +25 -0
  129. package/dist/core/runner/caller-stop-gate.js +7 -0
  130. package/dist/core/runner/compaction-seams.d.ts +8 -22
  131. package/dist/core/runner/compaction-seams.js +28 -53
  132. package/dist/core/runner/construction-doors.js +11 -1
  133. package/dist/core/runner/contracts.d.ts +85 -83
  134. package/dist/core/runner/credential-origin-seat.d.ts +2 -0
  135. package/dist/core/runner/credential-origin-seat.js +19 -0
  136. package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
  137. package/dist/core/runner/gate-exit.d.ts +47 -36
  138. package/dist/core/runner/gate-exit.js +8 -2
  139. package/dist/core/runner/image.js +1 -2
  140. package/dist/core/runner/inline-image.js +1 -1
  141. package/dist/core/runner/notice-seat-input.d.ts +11 -0
  142. package/dist/core/runner/notice-seat-input.js +1 -0
  143. package/dist/core/runner/person-path-rows.js +1 -0
  144. package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
  145. package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
  146. package/dist/core/runner/prepare-ask-lane.js +6 -15
  147. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
  148. package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
  149. package/dist/core/runner/prepare-config-doors.d.ts +5 -0
  150. package/dist/core/runner/prepare-config-doors.js +9 -0
  151. package/dist/core/runner/prepare-defer-classify.js +3 -4
  152. package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
  153. package/dist/core/runner/prepare-gate-stations.js +11 -10
  154. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
  155. package/dist/core/runner/prepare-inherited-gate.js +8 -21
  156. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  157. package/dist/core/runner/prepare-park-ask.js +10 -14
  158. package/dist/core/runner/prepare-policy-chain.d.ts +18 -16
  159. package/dist/core/runner/prepare-policy-chain.js +98 -101
  160. package/dist/core/runner/prepare-project-context.js +7 -10
  161. package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
  162. package/dist/core/runner/prepare-prompt-assembly.js +134 -101
  163. package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
  164. package/dist/core/runner/prepare-prompt-inputs.js +5 -7
  165. package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
  166. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  167. package/dist/core/runner/prepare-safety-scan.js +6 -10
  168. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
  169. package/dist/core/runner/prepare-suspend-saga.js +7 -5
  170. package/dist/core/runner/prepare-task.js +33 -15
  171. package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
  172. package/dist/core/runner/prepare-turn-wiring.js +29 -27
  173. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
  174. package/dist/core/runner/prepare-wiring-manifest.js +7 -7
  175. package/dist/core/runner/resume-apply.d.ts +5 -2
  176. package/dist/core/runner/resume-apply.js +24 -42
  177. package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
  178. package/dist/core/runner/resume-checkpoint-screen.js +9 -1
  179. package/dist/core/runner/resume-preflight.js +38 -16
  180. package/dist/core/runner/retired-runner-deps.js +3 -1
  181. package/dist/core/runner/run-brain-sinks.d.ts +3 -2
  182. package/dist/core/runner/run-brain-sinks.js +5 -1
  183. package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
  184. package/dist/core/runner/run-compaction-machinery.js +7 -33
  185. package/dist/core/runner/run-harness-handlers.js +4 -2
  186. package/dist/core/runner/run-identity-wiring.d.ts +3 -1
  187. package/dist/core/runner/run-identity-wiring.js +3 -2
  188. package/dist/core/runner/run-leg.js +62 -84
  189. package/dist/core/runner/run-notification-lane.js +1 -0
  190. package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
  191. package/dist/core/runner/run-recovery-lanes.js +11 -10
  192. package/dist/core/runner/run-settle-and-teardown.js +9 -28
  193. package/dist/core/runner/run-stop-and-final-verify.js +18 -25
  194. package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
  195. package/dist/core/runner/run-terminal-adoption.js +33 -22
  196. package/dist/core/runner/run-tool-mount-facts.js +5 -3
  197. package/dist/core/runner/run-turn-boundary.js +23 -34
  198. package/dist/core/runner/runtask.d.ts +6 -7
  199. package/dist/core/runner/runtask.js +14 -72
  200. package/dist/core/runner/session-rule-policy.d.ts +6 -4
  201. package/dist/core/runner/session-rule-policy.js +17 -10
  202. package/dist/core/runner/side-call-account.d.ts +68 -0
  203. package/dist/core/runner/side-call-account.js +61 -0
  204. package/dist/core/runner/stream-halt-verbs.js +12 -17
  205. package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
  206. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  207. package/dist/core/runner/stream-steer-verb.js +20 -38
  208. package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
  209. package/dist/core/runner/sub-agent-deny-lists.js +228 -71
  210. package/dist/core/runner/tool-end-body.d.ts +5 -6
  211. package/dist/core/runner/tool-end-body.js +6 -4
  212. package/dist/core/runner/tool-not-executed.d.ts +15 -0
  213. package/dist/core/runner/tool-not-executed.js +30 -0
  214. package/dist/core/runner/tool-occurrence.d.ts +8 -7
  215. package/dist/core/runner/tool-occurrence.js +5 -5
  216. package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
  217. package/dist/core/runner-deps.d.ts +20 -28
  218. package/dist/core/safety-merge-corpus.js +18 -2
  219. package/dist/core/secret-env.d.ts +93 -20
  220. package/dist/core/secret-env.js +192 -38
  221. package/dist/core/session-policy-store.d.ts +93 -17
  222. package/dist/core/session-policy-store.js +178 -25
  223. package/dist/core/session-reconcile.d.ts +4 -0
  224. package/dist/core/session-reconcile.js +2 -1
  225. package/dist/core/shell-read-silence.js +3 -32
  226. package/dist/core/side-query.d.ts +5 -3
  227. package/dist/core/skill-grant.d.ts +3 -2
  228. package/dist/core/skill-grant.js +17 -9
  229. package/dist/core/skills-directory.d.ts +31 -11
  230. package/dist/core/skills-directory.js +655 -104
  231. package/dist/core/task-event.d.ts +13 -3
  232. package/dist/core/task-result.d.ts +8 -0
  233. package/dist/core/task-spec.d.ts +20 -19
  234. package/dist/core/task-stream.d.ts +14 -4
  235. package/dist/core/tighten-task-spec.d.ts +4 -3
  236. package/dist/core/tighten-task-spec.js +2 -4
  237. package/dist/core/tool-check-reading.d.ts +74 -0
  238. package/dist/core/tool-check-reading.js +80 -0
  239. package/dist/core/tool-policy.d.ts +59 -18
  240. package/dist/core/tool-policy.js +77 -12
  241. package/dist/core/tool-registry.d.ts +20 -0
  242. package/dist/core/tool-registry.js +4 -0
  243. package/dist/core/tool-spec.d.ts +10 -6
  244. package/dist/core/tools.js +2 -0
  245. package/dist/core/trace.d.ts +51 -32
  246. package/dist/core/types.d.ts +2 -1
  247. package/dist/core/types.js +1 -0
  248. package/dist/core/unc-spelling.d.ts +10 -0
  249. package/dist/core/unc-spelling.js +3 -0
  250. package/dist/core/untrusted-egress.d.ts +8 -0
  251. package/dist/core/untrusted-egress.js +4 -1
  252. package/dist/core/user-attachment.d.ts +12 -2
  253. package/dist/core/user-attachment.js +17 -2
  254. package/dist/core/wiring-manifest.d.ts +14 -13
  255. package/dist/core/wiring-manifest.js +2 -2
  256. package/dist/engine/compaction/utils.js +1 -2
  257. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  258. package/dist/engine/execution-env/symlink-chain.js +1 -1
  259. package/dist/engine/harness/agent-harness.d.ts +1 -1
  260. package/dist/engine/harness/agent-harness.js +3 -3
  261. package/dist/engine/harness/types.d.ts +17 -16
  262. package/dist/engine/harness/types.js +7 -1
  263. package/dist/engine/llm/types.d.ts +12 -7
  264. package/dist/engine/loop/agent-loop.js +1 -1
  265. package/dist/engine/loop/types.d.ts +1 -1
  266. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  267. package/dist/engine/session/import-validate.js +3 -10
  268. package/dist/engine/session/session.d.ts +4 -4
  269. package/dist/engine/session/session.js +4 -4
  270. package/dist/index.d.ts +24 -17
  271. package/dist/index.js +15 -12
  272. package/dist/internal/harness.d.ts +1 -1
  273. package/dist/internal/harness.js +1 -1
  274. package/dist/orchestration/run-spec.d.ts +4 -6
  275. package/dist/orchestration/run-spec.js +39 -63
  276. package/dist/orchestration/run-workflow-tool.js +1 -2
  277. package/dist/orchestration/workflow.d.ts +11 -3
  278. package/dist/orchestration/workflow.js +11 -2
  279. package/dist/prompt-assembly/artifact-store.d.ts +37 -56
  280. package/dist/prompt-assembly/artifact-store.js +31 -49
  281. package/dist/prompt-assembly/artifact.d.ts +89 -76
  282. package/dist/prompt-assembly/artifact.js +167 -146
  283. package/dist/prompt-assembly/assemble.d.ts +34 -29
  284. package/dist/prompt-assembly/assemble.js +33 -220
  285. package/dist/prompt-assembly/bands.d.ts +20 -0
  286. package/dist/prompt-assembly/bands.js +18 -0
  287. package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
  288. package/dist/prompt-assembly/catalog/constitution.js +69 -0
  289. package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
  290. package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
  291. package/dist/prompt-assembly/catalog/index.d.ts +11 -0
  292. package/dist/prompt-assembly/catalog/index.js +59 -0
  293. package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
  294. package/dist/prompt-assembly/catalog/modes.js +137 -0
  295. package/dist/prompt-assembly/catalog/role.d.ts +10 -0
  296. package/dist/prompt-assembly/catalog/role.js +157 -0
  297. package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
  298. package/dist/prompt-assembly/catalog/schema.js +25 -0
  299. package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
  300. package/dist/prompt-assembly/catalog/sections.js +98 -0
  301. package/dist/prompt-assembly/catalog/team.d.ts +4 -0
  302. package/dist/prompt-assembly/catalog/team.js +258 -0
  303. package/dist/prompt-assembly/composer.d.ts +24 -28
  304. package/dist/prompt-assembly/composer.js +124 -46
  305. package/dist/prompt-assembly/epoch.d.ts +89 -79
  306. package/dist/prompt-assembly/epoch.js +115 -142
  307. package/dist/prompt-assembly/explain.d.ts +58 -34
  308. package/dist/prompt-assembly/explain.js +21 -24
  309. package/dist/prompt-assembly/overlay.d.ts +127 -0
  310. package/dist/prompt-assembly/overlay.js +301 -0
  311. package/dist/prompt-assembly/renderers.d.ts +21 -0
  312. package/dist/prompt-assembly/renderers.js +39 -0
  313. package/dist/prompt-assembly/section-usage.d.ts +3 -3
  314. package/dist/prompt-assembly/section-usage.js +1 -1
  315. package/dist/prompt-assembly/select.d.ts +56 -0
  316. package/dist/prompt-assembly/select.js +69 -0
  317. package/dist/prompt-assembly/sugar.d.ts +31 -0
  318. package/dist/prompt-assembly/sugar.js +20 -0
  319. package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
  320. package/dist/prompt-assembly/types.d.ts +45 -148
  321. package/dist/prompts/coordinator.d.ts +2 -21
  322. package/dist/prompts/coordinator.js +3 -255
  323. package/dist/prompts/cowork.d.ts +27 -16
  324. package/dist/prompts/cowork.js +2 -23
  325. package/dist/prompts/default.d.ts +38 -500
  326. package/dist/prompts/default.js +20 -285
  327. package/dist/prompts/supervisor.d.ts +6 -71
  328. package/dist/prompts/supervisor.js +6 -117
  329. package/dist/stores/file/session-policy-store.d.ts +3 -3
  330. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
  331. package/dist/tools/fs/dir-entries.d.ts +4 -2
  332. package/dist/tools/fs/dir-entries.js +16 -4
  333. package/dist/tools/fs/fs-bash.d.ts +1 -1
  334. package/dist/tools/fs/fs-bash.js +22 -11
  335. package/dist/tools/fs/fs-pdf.js +17 -13
  336. package/dist/tools/fs/fs-read.js +4 -3
  337. package/dist/tools/fs/fs-shared.d.ts +1 -10
  338. package/dist/tools/fs/fs-shared.js +3 -4
  339. package/dist/tools/fs/fs-write.js +2 -1
  340. package/dist/tools/fs/notebook.js +1 -1
  341. package/dist/tools/fs/pdf.d.ts +20 -10
  342. package/dist/tools/fs/pdf.js +19 -10
  343. package/dist/tools/fs/program-read-model.d.ts +68 -8
  344. package/dist/tools/fs/program-read-model.js +112 -33
  345. package/dist/tools/fs/program-read-model.rows.js +30 -10
  346. package/dist/tools/fs/read-deny-home.d.ts +25 -9
  347. package/dist/tools/fs/read-deny-home.js +28 -27
  348. package/dist/tools/fs/read-deny.d.ts +41 -11
  349. package/dist/tools/fs/read-deny.js +51 -5
  350. package/dist/tools/fs/safety.d.ts +4 -26
  351. package/dist/tools/fs/safety.js +10 -32
  352. package/dist/tools/fs/search.js +15 -10
  353. package/dist/tools/fs/shell-read-argv.d.ts +3 -2
  354. package/dist/tools/fs/shell-read-argv.js +118 -38
  355. package/dist/tools/fs/shell-read-establish.d.ts +5 -5
  356. package/dist/tools/fs/shell-read-establish.js +11 -61
  357. package/dist/tools/fs/shell-read-identity.js +6 -3
  358. package/dist/tools/fs/shell-read-judge.d.ts +13 -15
  359. package/dist/tools/fs/shell-read-judge.js +18 -4
  360. package/dist/tools/fs/shell-read-plan.d.ts +2 -2
  361. package/dist/tools/web.js +1 -1
  362. package/package.json +13 -1
  363. package/test/export-surface.snapshot.json +256 -99
  364. package/wire-changes/core@7.51.1.json +5 -5
  365. package/wire-changes/core@7.51.2.json +293 -0
  366. package/wire-changes/core@7.52.0.json +5859 -0
  367. package/dist/core/hook-seats.d.ts +0 -66
  368. package/dist/core/hook-seats.js +0 -37
  369. package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
  370. package/dist/prompt-assembly/packs/sema-default.js +0 -147
  371. package/dist/prompts/simple-sections.d.ts +0 -58
  372. package/dist/prompts/simple-sections.js +0 -43
@@ -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,84 @@
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
+ /** Why a handler did not answer for itself: it threw, it ran past its budget, it broke the site's contract, or it was
11
+ * 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"). */
12
+ export declare const MOD_FAILURE_CAUSES: readonly ["threw", "timeout", "violation", "reentry"];
13
+ export type ModFailureCause = (typeof MOD_FAILURE_CAUSES)[number];
14
+ /** A handler the dispatch skipped (a failure on a skip event), and why. */
15
+ export interface ModSkip {
16
+ readonly registration: string;
17
+ readonly cause: ModFailureCause;
18
+ readonly reason: string;
19
+ }
20
+ /** An event payload as the kernel carries it: an object, top level frozen by the bus. */
21
+ export type ModEventPayload = Readonly<Record<string, unknown>>;
22
+ /** The registration whose handler gave an answer, as the station's answer check sees it. */
23
+ export interface ModAnswerer {
24
+ readonly plugin: string;
25
+ readonly seat: ModSeat;
26
+ readonly tier: ModTier;
27
+ }
28
+ /** What an answer check reads, in `below`, for a `next` the handler started that has not answered yet (no `deny`, no `value`). */
29
+ export declare const NEXT_IN_FLIGHT: Readonly<{
30
+ inFlight: true;
31
+ }>;
32
+ /** The station's own reading of an answer: undefined when it is one the station takes, else why not. `below` is every
33
+ * answer the handler's `next` resolved with, plus `NEXT_IN_FLIGHT` while its `next` is still in flight —
34
+ * empty when it never called `next`. */
35
+ export type ModAnswerCheck = (answer: unknown, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[]) => string | undefined;
36
+ /** A matcher: top-level fields of `e` that must equal these values exactly. */
37
+ export type ModMatcher = Readonly<Record<string, string | number | boolean>>;
38
+ /** The first pinned key `next` changed, or undefined. Identity comparison: a pinned value is handed on as is. */
39
+ export declare function pinnedKeyChanged(pinned: readonly string[], received: ModEventPayload, passed: ModEventPayload): string | undefined;
40
+ /** Why a handler's answer breaks the site, or undefined. No answer at all is never an answer. */
41
+ export declare function answerViolation(answer: unknown, check: ModAnswerCheck | undefined, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[]): string | undefined;
42
+ /**
43
+ * A `$` method's answer form: `{ value }` (the call's result) or `{ deny }` (the call throws). A `{ deny }` given after
44
+ * the handler's `next` was answered with something that is not a deny — or while that `next` is still running — breaks
45
+ * the form (the deny would stand in place of a call that already ran or is running) — a deny handed up from below is
46
+ * no such thing. A `{ value }` given while that `next` is still running stands in place of the same running call, so it
47
+ * breaks the form too; one given after `next` answered is the handler rewriting what it read, and stands. Counting the
48
+ * running `next` is stricter than the reference, which reads answered runs only.
49
+ */
50
+ export declare function methodAnswerViolation(answer: unknown, _e?: ModEventPayload, _by?: ModAnswerer, below?: readonly unknown[]): string | undefined;
51
+ /** Why `m` is not a matcher, or undefined. */
52
+ export declare function matcherViolation(m: unknown): string | undefined;
53
+ /** Whether every matcher field equals `e`'s own top-level field exactly. */
54
+ export declare function matcherMatches(m: ModMatcher | undefined, e: ModEventPayload): boolean;
55
+ /**
56
+ * What a payload hands on, received by the one receipt in the mods mode: a plain record, copied whole at every depth
57
+ * (cycles and shared references kept, a function or a class instance handed as it is), its top level frozen. A member
58
+ * the reader already holds (`held`: the dispatch's own members) is kept as itself, so a pinned value handed back
59
+ * unchanged is the same value. An accessor anywhere is refused (a getter is never run), and a payload that cannot be
60
+ * copied whole is refused — never handed on shorter than it was given.
61
+ */
62
+ export declare function receivePayload(v: unknown, held?: ModEventPayload, isProxy?: ProxyProbe): {
63
+ readonly payload: ModEventPayload;
64
+ } | {
65
+ readonly refusal: string;
66
+ };
67
+ /**
68
+ * The bottom's answer as it starts up the chain: its top level frozen, so no handler can turn the answer it got from
69
+ * `next` into another one (a deny in place of a result that already ran). A plain record or array the bottom made is
70
+ * copied once and frozen; an answer already frozen (an engine sentinel) or not a plain container is itself.
71
+ */
72
+ export declare function answerUpward(v: unknown): unknown;
73
+ /** A handler's answer, received by the same receipt and mode (an answer need not be a record; a primitive is itself). */
74
+ export declare function receiveAnswer(answer: unknown, isProxy?: ProxyProbe): {
75
+ readonly answer: unknown;
76
+ } | {
77
+ readonly refusal: string;
78
+ };
79
+ /**
80
+ * A copy for an observe handler: every data container (a plain object, an array) detached at whatever depth, a
81
+ * leaf the structured clone refuses (a function, a handle, a class instance holding one) handed as is. An
82
+ * uncloneable leaf therefore never leaves the data beside it — at the top or nested — aliased.
83
+ */
84
+ export declare function detachedCopy(e: ModEventPayload): Record<string, unknown>;
@@ -0,0 +1,104 @@
1
+ import { describe } from "./events.js";
2
+ import { describeFault, isPlainRecord, MODS_PAYLOAD_MODE, receive } from "./receive.js";
3
+ function payloadMode(isProxy) {
4
+ return isProxy === undefined ? MODS_PAYLOAD_MODE : Object.freeze({ ...MODS_PAYLOAD_MODE, isProxy });
5
+ }
6
+ export const MOD_FAILURE_CAUSES = Object.freeze(["threw", "timeout", "violation", "reentry"]);
7
+ export const NEXT_IN_FLIGHT = Object.freeze({ inFlight: true });
8
+ export function pinnedKeyChanged(pinned, received, passed) {
9
+ return pinned.find((k) => !Object.is(received[k], passed[k]));
10
+ }
11
+ export function answerViolation(answer, check, e, by, below) {
12
+ if (answer === undefined)
13
+ return "returned no answer (return next(e) to pass the event on)";
14
+ if (check === undefined)
15
+ return undefined;
16
+ try {
17
+ return check(answer, e, by, below);
18
+ }
19
+ catch {
20
+ return "returned an answer the station cannot read";
21
+ }
22
+ }
23
+ const denyOf = (a) => (typeof a === "object" && a !== null && Object.prototype.hasOwnProperty.call(a, "deny") ? Reflect.get(a, "deny") : undefined);
24
+ export function methodAnswerViolation(answer, _e, _by, below = []) {
25
+ if (!isPlainRecord(answer))
26
+ return "takes { value } or { deny }";
27
+ const hasValue = Object.prototype.hasOwnProperty.call(answer, "value");
28
+ const deny = denyOf(answer);
29
+ if (deny !== undefined) {
30
+ if (hasValue || typeof deny !== "string" || deny === "")
31
+ return "takes { value } or { deny: <reason> }";
32
+ return below.some((b) => denyOf(b) === undefined) ? "a deny after its next() was answered or while it still runs (deny in place of next)" : undefined;
33
+ }
34
+ if (!hasValue)
35
+ return "takes { value } or { deny }";
36
+ return below.includes(NEXT_IN_FLIGHT) ? "a value while its next() still runs (value in place of next)" : undefined;
37
+ }
38
+ export function matcherViolation(m) {
39
+ if (typeof m !== "object" || m === null || Array.isArray(m))
40
+ return `a matcher is an object of top-level fields, not ${describe(m)}`;
41
+ for (const [k, v] of Object.entries(m)) {
42
+ if (typeof v !== "string" && typeof v !== "number" && typeof v !== "boolean")
43
+ return `matcher field "${k}" is ${describe(v)}; a matcher value is a string, a number or a boolean`;
44
+ }
45
+ return undefined;
46
+ }
47
+ export function matcherMatches(m, e) {
48
+ if (m === undefined)
49
+ return true;
50
+ return Object.entries(m).every(([k, v]) => Object.prototype.hasOwnProperty.call(e, k) && e[k] === v);
51
+ }
52
+ export function receivePayload(v, held, isProxy) {
53
+ if (isProxy !== undefined && typeof v === "object" && v !== null && isProxy(v))
54
+ return { refusal: "the payload is a Proxy (refused before any of its traps runs)" };
55
+ if (!isPlainRecord(v))
56
+ return { refusal: `an event payload is a plain object, not ${describe(v)}` };
57
+ const r = receive(v, payloadMode(isProxy), held === undefined ? undefined : Object.values(held));
58
+ return r.ok ? { payload: Object.freeze(r.value) } : { refusal: `the payload holds ${describeFault(r.fault)}` };
59
+ }
60
+ export function answerUpward(v) {
61
+ if (typeof v !== "object" || v === null || Object.isFrozen(v))
62
+ return v;
63
+ if (Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype)
64
+ return Object.freeze([...v]);
65
+ return isPlainRecord(v) ? Object.freeze({ ...v }) : v;
66
+ }
67
+ export function receiveAnswer(answer, isProxy) {
68
+ const r = receive(answer, payloadMode(isProxy));
69
+ return r.ok ? { answer: r.value } : { refusal: `answered ${describeFault(r.fault)}` };
70
+ }
71
+ export function detachedCopy(e) {
72
+ const seen = new Map();
73
+ const out = {};
74
+ for (const [k, v] of Object.entries(e))
75
+ Object.defineProperty(out, k, { value: detachedValue(v, seen), enumerable: true, writable: true, configurable: true });
76
+ return out;
77
+ }
78
+ function detachedValue(v, seen) {
79
+ if (typeof v !== "object" || v === null)
80
+ return v;
81
+ const done = seen.get(v);
82
+ if (done !== undefined)
83
+ return done;
84
+ try {
85
+ return structuredClone(v);
86
+ }
87
+ catch {
88
+ }
89
+ const proto = Object.getPrototypeOf(v);
90
+ if (Array.isArray(v)) {
91
+ const arr = [];
92
+ seen.set(v, arr);
93
+ for (const x of v)
94
+ arr.push(detachedValue(x, seen));
95
+ return arr;
96
+ }
97
+ if (proto !== Object.prototype && proto !== null)
98
+ return v;
99
+ const obj = {};
100
+ seen.set(v, obj);
101
+ for (const [k, x] of Object.entries(v))
102
+ Object.defineProperty(obj, k, { value: detachedValue(x, seen), enumerable: true, writable: true, configurable: true });
103
+ return obj;
104
+ }