@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,444 @@
1
+ import { types } from "node:util";
2
+ import { resolveModel } from "../roles.js";
3
+ import { brainToRuntime } from "../runtime.js";
4
+ import { deliverEngineNotice } from "../engine-notice.js";
5
+ import { inlineUntrusted } from "../untrusted-text.js";
6
+ import { extensionWords } from "../untrusted-egress.js";
7
+ import { askApproverIdentity, describeThrown, ownArgs } from "../tool-policy.js";
8
+ import { admitMods, expandModPattern } from "./kernel/index.js";
9
+ import { validateOverlay } from "../../prompt-assembly/overlay.js";
10
+ import { modsInvalid } from "./kernel/registration.js";
11
+ import { detachedCopy } from "./kernel/site-rules.js";
12
+ import { isPlainRecord } from "./kernel/receive.js";
13
+ import { engineMethodBottoms } from "./dollar.js";
14
+ import { modSeatsOf, modsReportToOnError, registrationRefusedNotice } from "./host.js";
15
+ export const ENGINE_CORE_ANSWER = Object.freeze({});
16
+ export function engineCore() {
17
+ return ENGINE_CORE_ANSWER;
18
+ }
19
+ export function agentIdOf(identity) {
20
+ return identity?.isDelegatedChild === true ? identity.taskId : undefined;
21
+ }
22
+ export function stopEventOf(identity) {
23
+ return identity?.isDelegatedChild === true ? "classic.SubagentStop" : "classic.Stop";
24
+ }
25
+ export function detachedArgsOf(args) {
26
+ return isRecord(args) ? detachedCopy(args) : args;
27
+ }
28
+ function isRecord(v) {
29
+ return typeof v === "object" && v !== null && !Array.isArray(v);
30
+ }
31
+ export function judgedInputOf(args) {
32
+ const owned = ownArgs(args);
33
+ return owned.ok ? owned.value : args;
34
+ }
35
+ export function admittedChainOf(bus, spec, deps) {
36
+ const offered = new Map();
37
+ for (const r of [...(deps.mods ?? []), ...(spec.mods ?? [])])
38
+ offered.set(r.name, r);
39
+ const hung = bus.mounted();
40
+ const links = [];
41
+ for (const rec of bus.records) {
42
+ if ("refusedBy" in rec)
43
+ continue;
44
+ const registration = offered.get(rec.name);
45
+ if (registration !== undefined)
46
+ links.push(Object.freeze({ registration, handlers: Object.freeze(hung.filter((h) => h.plugin === rec.name)) }));
47
+ }
48
+ return Object.freeze(links);
49
+ }
50
+ const ADMITTED_CHAINS = new WeakMap();
51
+ function recordAdmittedChain(bus, seats) {
52
+ const chain = admittedChainOf(bus, { ...(seats.task !== undefined ? { mods: [...seats.task] } : {}) }, { ...(seats.deployment !== undefined ? { mods: [...seats.deployment] } : {}) });
53
+ ADMITTED_CHAINS.set(bus, chain);
54
+ return chain;
55
+ }
56
+ export function chainOfBus(bus) {
57
+ return ADMITTED_CHAINS.get(bus);
58
+ }
59
+ const sameMatcher = (a, b) => {
60
+ if (a === undefined || b === undefined)
61
+ return a === b;
62
+ const ka = Object.keys(a).sort();
63
+ const kb = Object.keys(b).sort();
64
+ return ka.length === kb.length && ka.every((k, i) => k === kb[i] && a[k] === b[k]);
65
+ };
66
+ const sameHandler = (a, b) => a.seat === b.seat && a.pattern === b.pattern && a.observe === b.observe && a.caught === b.caught && sameMatcher(a.matcher, b.matcher);
67
+ function sameModLink(a, b) {
68
+ return a.registration === b.registration && a.handlers.length === b.handlers.length && a.handlers.every((h, j) => sameHandler(h, b.handlers[j]));
69
+ }
70
+ export function sameModChain(a, b) {
71
+ return a.length === b.length && a.every((l, i) => sameModLink(l, b[i]));
72
+ }
73
+ const judgesCall = (p) => !p.observe;
74
+ export function chainJudges(bus) {
75
+ return bus.hasHandlers("classic.PreToolUse", judgesCall) || bus.hasHandlers("tool.check", judgesCall);
76
+ }
77
+ const SCREENING_CHAINS = new WeakMap();
78
+ export function recordScreeningChain(policy, chain) {
79
+ SCREENING_CHAINS.set(policy, chain);
80
+ }
81
+ export function screeningChainOf(policy) {
82
+ return SCREENING_CHAINS.get(policy);
83
+ }
84
+ export function sameInstallation(pc, leg) {
85
+ const bus = screeningChainOf(pc.policy);
86
+ const chain = bus !== undefined ? chainOfBus(bus) : undefined;
87
+ return (chain !== undefined &&
88
+ sameModChain(chain, leg.chain) &&
89
+ askApproverIdentity(pc.onAsk) === askApproverIdentity(leg.onAsk) &&
90
+ (pc.durableMandate === true) === leg.durableMandate &&
91
+ (pc.contentMandate === true) === leg.contentMandate &&
92
+ pc.hookEnv === leg.hookEnv &&
93
+ pc.autoMode?.decider === leg.decider);
94
+ }
95
+ export function standsInFor(pc, leg, legChainJudges) {
96
+ return legChainJudges && sameInstallation(pc, { ...leg, durableMandate: false, contentMandate: false });
97
+ }
98
+ const judgesToolCheck = (h) => {
99
+ const selected = expandModPattern(h.pattern);
100
+ return !h.observe && "names" in selected && selected.names.includes("tool.check");
101
+ };
102
+ export function screeningInstallationsOf(entries) {
103
+ return entries.flatMap((pc) => {
104
+ const bus = screeningChainOf(pc.policy);
105
+ return bus !== undefined || pc.mods !== undefined ? [{ bus, chain: pc.mods }] : [];
106
+ });
107
+ }
108
+ export function unraisableGuardsOf(installations) {
109
+ const guards = installations.flatMap((i) => (i.bus !== undefined ? [] : (i.chain ?? []).filter((l) => l.handlers.some(judgesToolCheck)).map((l) => `"${inlineUntrusted(l.registration.name, 80)}"`)));
110
+ return guards.length === 0 ? undefined : `an inherited screening entry names the tool.check guard of ${guards.join(", ")}, but its policy is not one createPreToolUseConstraintPolicy minted, so the guard has no chain to judge this leg's calls on — hand the minted policy back as it is`;
111
+ }
112
+ const judges = (p) => judgesCall(p);
113
+ export function inheritedToolChecks(entries, standsIn, settleOf) {
114
+ const unraisable = unraisableGuardsOf(screeningInstallationsOf(entries));
115
+ if (unraisable !== undefined)
116
+ throw modsInvalid(unraisable);
117
+ const checks = [];
118
+ for (const pc of entries) {
119
+ const bus = screeningChainOf(pc.policy);
120
+ if (bus === undefined || standsIn(pc) || !bus.hasHandlers("tool.check", judges))
121
+ continue;
122
+ checks.push(Object.freeze({ bus, judges, settle: settleOf(pc) }));
123
+ }
124
+ return Object.freeze(checks);
125
+ }
126
+ export function classicEventBase(identity, permissionMode) {
127
+ const agentId = agentIdOf(identity);
128
+ return {
129
+ ...(identity !== undefined ? { identity } : {}),
130
+ ...(agentId !== undefined ? { agentId } : {}),
131
+ ...(permissionMode !== undefined ? { permissionMode } : {}),
132
+ };
133
+ }
134
+ export async function observeClassic(bus, event, e, signal) {
135
+ if (!bus.hasHandlers(event))
136
+ return;
137
+ try {
138
+ await bus.dispatch(event, e, { bottom: engineCore, ...(signal !== undefined ? { signal } : {}) });
139
+ }
140
+ catch {
141
+ }
142
+ }
143
+ export async function dispatchClassic(bus, event, e, options) {
144
+ if (!bus.hasHandlers(event))
145
+ return undefined;
146
+ const check = options.checkAnswer;
147
+ return await bus.dispatch(event, e, {
148
+ bottom: engineCore,
149
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
150
+ ...(check !== undefined ? { checkAnswer: (a) => (a === ENGINE_CORE_ANSWER ? undefined : check(a)) } : {}),
151
+ });
152
+ }
153
+ export function stringMembersAnswer(event, members) {
154
+ return (answer) => {
155
+ if (answer === null || answer === false)
156
+ return undefined;
157
+ if (typeof answer !== "object")
158
+ return `answered ${typeof answer}; ${event} takes { ${members.map((m) => `${m}?`).join(", ")} }`;
159
+ for (const m of members) {
160
+ const v = Reflect.get(answer, m);
161
+ if (v !== undefined && typeof v !== "string")
162
+ return `answered a ${typeof v} "${m}"; it is a string`;
163
+ }
164
+ return undefined;
165
+ };
166
+ }
167
+ export function stringMembersOf(answer, members) {
168
+ const out = {};
169
+ if (typeof answer !== "object" || answer === null)
170
+ return out;
171
+ for (const m of members) {
172
+ const v = Reflect.get(answer, m);
173
+ if (typeof v === "string")
174
+ out[m] = v;
175
+ }
176
+ return out;
177
+ }
178
+ const FAILURE_CLAUSE = Object.freeze({
179
+ threw: (who, why) => `crashed (extension "${who}" ${why})`,
180
+ timeout: (who, why) => `did not answer (extension "${who}" ${why})`,
181
+ violation: (who, why) => `gave an answer the station cannot take (extension "${who}" ${why})`,
182
+ reentry: (who, why) => `was skipped on re-entry and its .catch did not answer (extension "${who}" ${why})`,
183
+ });
184
+ export function failedHandlerClause(f) {
185
+ return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), extensionWords(f.reason, 200));
186
+ }
187
+ export async function observePermissionDenied(input) {
188
+ const { payload, hostObserver } = input;
189
+ const e = { ...payload, ...classicEventBase(payload.identity, payload.permissionMode) };
190
+ if (input.legBus?.hasHandlers("classic.PermissionDenied") === true)
191
+ await observeClassic(input.legBus, "classic.PermissionDenied", e, input.signal);
192
+ if (hostObserver === undefined)
193
+ return;
194
+ const own = await admitModChain({
195
+ deployment: [
196
+ {
197
+ name: "toolGate.permissionDenied",
198
+ tier: "user",
199
+ uses: { events: ["classic.PermissionDenied"], calls: [] },
200
+ register: (on) => on("classic.PermissionDenied", async () => void (await hostObserver(payload)), { observe: true }),
201
+ },
202
+ ],
203
+ }, input.onHostObserverFailure);
204
+ await observeClassic(own, "classic.PermissionDenied", e, input.signal);
205
+ }
206
+ export async function screenUserPrompt(bus, e, signal) {
207
+ let outcome;
208
+ try {
209
+ outcome = await dispatchClassic(bus, "classic.UserPromptSubmit", e, {
210
+ ...(signal !== undefined ? { signal } : {}),
211
+ checkAnswer: stringMembersAnswer("classic.UserPromptSubmit", ["block", "additionalContext"]),
212
+ });
213
+ }
214
+ catch (err) {
215
+ return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screen: ${describeThrown(err)}`, skipped: [] };
216
+ }
217
+ if (outcome === undefined)
218
+ return undefined;
219
+ if (outcome.kind !== "answered")
220
+ return outcome;
221
+ return { kind: "answered", ...stringMembersOf(outcome.answer, ["block", "additionalContext"]) };
222
+ }
223
+ export const TOOL_CHECK_DECISIONS = Object.freeze(["allow", "ask", "deny"]);
224
+ const isToolCheckDecision = (v) => TOOL_CHECK_DECISIONS.some((d) => d === v);
225
+ function readToolCheckAnswer(answer) {
226
+ if (typeof answer !== "object" || answer === null)
227
+ return `answered ${answer === null ? "null" : typeof answer}; tool.check takes { decision, reason? }`;
228
+ const decision = Reflect.get(answer, "decision");
229
+ const reason = Reflect.get(answer, "reason");
230
+ if (!isToolCheckDecision(decision))
231
+ return `no { decision } (one of ${TOOL_CHECK_DECISIONS.join(", ")})`;
232
+ if (reason !== undefined && typeof reason !== "string")
233
+ return `answered a ${typeof reason} "reason"; it is a string`;
234
+ return { decision, ...(reason !== undefined ? { reason } : {}) };
235
+ }
236
+ export async function raiseToolCheck(bus, e, projection, signal, judges) {
237
+ if (!bus.hasHandlers("tool.check", judges))
238
+ return undefined;
239
+ let outcome;
240
+ try {
241
+ outcome = await bus.dispatch("tool.check", e, {
242
+ bottom: () => projection,
243
+ ...(judges !== undefined ? { participant: judges } : {}),
244
+ ...(signal !== undefined ? { signal } : {}),
245
+ checkAnswer: (a) => {
246
+ const read = readToolCheckAnswer(a);
247
+ return typeof read === "string" ? read : undefined;
248
+ },
249
+ });
250
+ }
251
+ catch (err) {
252
+ return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the check: ${describeThrown(err)}`, skipped: [] };
253
+ }
254
+ if (outcome.kind !== "answered")
255
+ return outcome;
256
+ const read = readToolCheckAnswer(outcome.answer);
257
+ if (typeof read === "string")
258
+ return { kind: "failed", registration: outcome.answeredBy ?? "engine", cause: "violation", reason: read, skipped: outcome.skipped };
259
+ return { kind: "answered", ...read, ...(outcome.answeredBy !== undefined ? { by: outcome.answeredBy } : {}) };
260
+ }
261
+ const NO_COMPOSE = Object.freeze({ deploy: Object.freeze([]), task: Object.freeze([]), warnings: Object.freeze([]) });
262
+ function composeOverlaysOf(answer) {
263
+ if (!isPlainRecord(answer)) {
264
+ return `answered ${answer === null ? "null" : Array.isArray(answer) ? "an array" : typeof answer === "object" ? "an object that is not a plain record" : typeof answer}; prompt.compose takes a plain { overlays }`;
265
+ }
266
+ const stray = Object.keys(answer).filter((k) => k !== "overlays");
267
+ if (stray.length > 0)
268
+ return `the answer carries ${stray.slice(0, 5).map((k) => JSON.stringify(extensionWords(k, 40))).join(", ")} (overlays only)`;
269
+ const overlays = answer["overlays"];
270
+ return Array.isArray(overlays) && Object.getPrototypeOf(overlays) === Array.prototype ? overlays : "the answer's overlays is not an ordinary array";
271
+ }
272
+ export async function raisePromptCompose(bus, e, options) {
273
+ if (!bus.hasHandlers("prompt.compose"))
274
+ return NO_COMPOSE;
275
+ const sourceOf = (seat) => (seat === "deployment" ? "deploy" : "task");
276
+ const bottom = Object.freeze({ overlays: Object.freeze([]) });
277
+ const taken = new WeakMap([[bottom, Object.freeze([])]]);
278
+ const HEAD = "the answer does not carry what next() returned unchanged at its head (a handler adds overlays; it never rewrites or removes another's)";
279
+ let outcome;
280
+ try {
281
+ outcome = await bus.dispatch("prompt.compose", e, {
282
+ bottom: () => bottom,
283
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
284
+ checkAnswer: (answer, _e, by, below) => {
285
+ if (typeof answer === "object" && answer !== null && taken.has(answer))
286
+ return undefined;
287
+ const mine = composeOverlaysOf(answer);
288
+ if (typeof mine === "string")
289
+ return mine;
290
+ const returned = below[below.length - 1];
291
+ const lower = typeof returned === "object" && returned !== null ? taken.get(returned) : undefined;
292
+ if (lower === undefined) {
293
+ return below.length === 0
294
+ ? "it answered without next(e) — prompt.compose collects: a handler awaits next(e) and adds after what it returned"
295
+ : "next() is still running; prompt.compose answers after it";
296
+ }
297
+ if (mine.length < lower.length)
298
+ return HEAD;
299
+ const out = [...lower];
300
+ for (let i = 0; i < mine.length; i++) {
301
+ const under = lower[i];
302
+ const v = validateOverlay(mine[i], { source: sourceOf(under?.by.seat ?? by.seat), event: "prompt.compose", lowerAdds: options.lowerAdds });
303
+ if (under !== undefined) {
304
+ if ("violation" in v || JSON.stringify(v.overlay) !== JSON.stringify(under.overlay))
305
+ return HEAD;
306
+ continue;
307
+ }
308
+ if ("violation" in v)
309
+ return v.violation;
310
+ out.push(Object.freeze({ overlay: v.overlay, by: Object.freeze({ plugin: by.plugin, seat: by.seat }) }));
311
+ }
312
+ taken.set(answer, Object.freeze(out));
313
+ return undefined;
314
+ },
315
+ });
316
+ }
317
+ catch (err) {
318
+ return { deploy: [], task: [], warnings: [`prompt.compose could not be raised (${describeThrown(err)}); no mods overlay applies this run`] };
319
+ }
320
+ const warnings = (outcome.kind === "aborted" ? [] : outcome.skipped).map((s) => `prompt.compose: extension "${extensionWords(s.registration, 80)}" ${s.cause === "violation" ? "gave an answer the station cannot take" : s.cause}: ${extensionWords(s.reason, 300)} — that answer is skipped; what is below it stands`);
321
+ if (outcome.kind !== "answered")
322
+ return { deploy: [], task: [], warnings };
323
+ const answer = outcome.answer;
324
+ const contributions = typeof answer === "object" && answer !== null ? taken.get(answer) : undefined;
325
+ if (contributions === undefined)
326
+ return { deploy: [], task: [], warnings: [...warnings, "prompt.compose: the chain's answer is not one the station took; no mods overlay applies this run"] };
327
+ const blocks = [];
328
+ for (const { overlay, by } of contributions) {
329
+ const item = { overlay, origin: { source: sourceOf(by.seat), by: by.plugin } };
330
+ const last = blocks[blocks.length - 1];
331
+ if (last !== undefined && last.by.plugin === by.plugin && last.by.seat === by.seat)
332
+ last.items.push(item);
333
+ else
334
+ blocks.push({ by, items: [item] });
335
+ }
336
+ const inChainOrder = blocks.reverse().flatMap((b) => b.items);
337
+ return {
338
+ deploy: Object.freeze(inChainOrder.filter((o) => o.origin.source === "deploy")),
339
+ task: Object.freeze(inChainOrder.filter((o) => o.origin.source === "task")),
340
+ warnings,
341
+ };
342
+ }
343
+ function lateView() {
344
+ let seats;
345
+ const need = (method) => {
346
+ if (seats === undefined)
347
+ throw new Error(`${method}: the engine facade is not available before the leg is prepared`);
348
+ return seats;
349
+ };
350
+ const view = {
351
+ env: { exec: (command, options) => need("process.run").exec(command, options) },
352
+ complete: (request, signal) => need("model.complete").complete(request, signal),
353
+ book: (reply) => need("model.complete").book(reply),
354
+ session: {
355
+ id: () => need("session.id").sessionId,
356
+ cwd: () => need("session.cwd").cwd(),
357
+ root: () => need("session.root").root(),
358
+ model: () => need("session.model").model(),
359
+ messages: () => need("session.messages").messages(),
360
+ },
361
+ now: () => need("clock.now").now(),
362
+ tools: () => need("tool.list").tools(),
363
+ agents: () => need("agent.list").agents(),
364
+ };
365
+ return {
366
+ view,
367
+ bind: (s) => {
368
+ seats = s;
369
+ },
370
+ };
371
+ }
372
+ export async function admitLegMods(input) {
373
+ const late = lateView();
374
+ const seats = modSeatsOf(input.spec, input.deps);
375
+ const bus = await admitMods({
376
+ side: "engine",
377
+ seats,
378
+ bottoms: engineMethodBottoms(late.view),
379
+ report: modsReportToOnError(input.deps.onError, input.sessionId),
380
+ describeThrown,
381
+ isProxy: types.isProxy,
382
+ });
383
+ for (const record of bus.records) {
384
+ if ("refusedBy" in record)
385
+ deliverEngineNotice(input.deps.onNotice, registrationRefusedNotice(record, input.sessionId));
386
+ }
387
+ return { bus, chain: recordAdmittedChain(bus, seats), bindFacade: late.bind };
388
+ }
389
+ function replyText(reply) {
390
+ return reply.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("");
391
+ }
392
+ export function legFacadeSeats(input) {
393
+ const runtime = brainToRuntime(input.deps.brain);
394
+ const answeredBy = new Map();
395
+ const byUsage = new WeakMap();
396
+ return {
397
+ exec: (command, options) => input.executionEnv.exec(command, options),
398
+ complete: async (request, signal) => {
399
+ const model = request.model !== undefined ? resolveModel(request.model, input.deps.models) : input.model;
400
+ answeredBy.set(model.id, model);
401
+ const auth = await input.spec.getApiKeyAndHeaders?.(model);
402
+ const reply = await runtime.completeSimple(model, { ...request.context, messages: [...request.context.messages] }, { signal, maxTokens: request.maxTokens, ...(auth?.apiKey !== undefined ? { apiKey: auth.apiKey } : {}), ...(auth?.headers !== undefined ? { headers: auth.headers } : {}) });
403
+ if (reply.stopReason === "error" || reply.stopReason === "aborted")
404
+ throw new Error(`model.complete: ${reply.errorMessage ?? reply.stopReason}`);
405
+ if (reply.usage !== undefined)
406
+ byUsage.set(reply.usage, { model, ...(reply.diagnostics !== undefined ? { diagnostics: reply.diagnostics } : {}) });
407
+ return Object.freeze({ text: replyText(reply), model: model.id, ...(reply.usage !== undefined ? { usage: reply.usage } : {}) });
408
+ },
409
+ sessionId: input.sessionId,
410
+ book: (reply) => {
411
+ const seen = reply.usage !== undefined ? byUsage.get(reply.usage) : undefined;
412
+ const record = seen !== undefined && seen.model.id === reply.model ? seen : undefined;
413
+ const model = record?.model ?? answeredBy.get(reply.model);
414
+ if (model === undefined)
415
+ throw new Error(`model.complete: the reply names model "${reply.model}", which no call of this leg resolved; it is not booked`);
416
+ input.book(model, { usage: reply.usage, ...(record?.diagnostics !== undefined ? { diagnostics: record.diagnostics } : {}) });
417
+ },
418
+ cwd: () => input.cwdRef?.current ?? input.taskRoot,
419
+ root: () => input.taskRoot,
420
+ model: () => input.model.id,
421
+ messages: () => input.lastBrainContext()?.messages ?? [],
422
+ now: () => (input.deps.now ?? Date.now)(),
423
+ tools: () => [...input.activeTools],
424
+ agents: () => (input.agentListing?.entries ?? []).map((e) => e.name),
425
+ };
426
+ }
427
+ export async function admitModChain(seats, onError) {
428
+ const bus = await admitMods({
429
+ side: "engine",
430
+ seats,
431
+ bottoms: engineMethodBottoms(lateView().view),
432
+ report: (err) => {
433
+ try {
434
+ onError?.(err);
435
+ }
436
+ catch {
437
+ }
438
+ },
439
+ describeThrown,
440
+ isProxy: types.isProxy,
441
+ });
442
+ recordAdmittedChain(bus, seats);
443
+ return bus;
444
+ }
@@ -1,4 +1,5 @@
1
1
  import { types } from "node:util";
2
+ import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
2
3
  export function receiptRefusal(message) {
3
4
  const e = new Error(message);
4
5
  e.code = "config.invalid_argument";
@@ -8,32 +9,19 @@ export function refuseProxy(given, words) {
8
9
  if (types.isProxy(given))
9
10
  throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
10
11
  }
12
+ const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
11
13
  export function receiveOwnProperties(given, words) {
12
14
  refuseProxy(given, words);
13
- const proto = Object.getPrototypeOf(given);
14
- if (proto !== Object.prototype && proto !== null) {
15
+ if (!isPlainRecord(given)) {
15
16
  throw receiptRefusal(`${words.subject} must be a plain object (its prototype is neither Object.prototype nor null): every ${words.unit} is read once as an own property, and a ${words.unit} its prototype would supply is not read — refused rather than wired without it`);
16
17
  }
17
- const captured = Object.getOwnPropertyDescriptors(given);
18
- const received = Object.create(Object.prototype);
19
- for (const name of Object.getOwnPropertyNames(captured)) {
20
- const d = captured[name];
21
- let value;
22
- if (Object.hasOwn(d, "value")) {
23
- value = d.value;
24
- }
25
- else {
26
- const get = Object.hasOwn(d, "get") ? d.get : undefined;
27
- try {
28
- value = get === undefined ? undefined : get.call(given);
29
- }
30
- catch {
31
- throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
32
- }
33
- }
34
- Object.defineProperty(received, name, { value, enumerable: true, writable: true, configurable: true });
35
- }
36
- if (Object.getPrototypeOf(given) !== proto)
18
+ const received = receive(given, CONFIG_RECEIPT_MODE);
19
+ if (received.ok)
20
+ return received.value;
21
+ const name = received.fault.path[0] ?? "";
22
+ if (received.fault.kind === "getter-threw")
23
+ throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
24
+ if (received.fault.kind === "prototype-moved")
37
25
  throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
38
- return received;
26
+ throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
39
27
  }
@@ -9,11 +9,12 @@
9
9
  * The checkpoint seat (`./checkpoint-seat.ts`) is the same shape for one field; this seat carries the rest.
10
10
  */
11
11
  import type { OnQuestion } from "./ask-question.js";
12
- import type { Hooks } from "./hooks.js";
12
+ import type { ModRegistration } from "./mods/kernel/index.js";
13
+ import type { EngineDollar } from "./mods/dollar.js";
13
14
  import type { ToolExecuteContext } from "./tool-spec.js";
14
15
  import type { TaskSpec } from "./types.js";
15
16
  /** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
16
- export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "hooks" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory">;
17
+ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "promptForm" | "promptBinding">;
17
18
  /**
18
19
  * The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
19
20
  * frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
@@ -23,10 +24,13 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
23
24
  * · `clientContext` — the user's TZ/email facts (the child's environment block localizes the same way).
24
25
  * · `onQuestion` — the parent's FROZEN question face (`spec.onQuestion ?? deps.onQuestion`, the value the parent's
25
26
  * own AskUserQuestion resolves at): the child's question tool MOUNTS on it, so without it the child has no tool.
26
- * · `hooks` — the parent's SPEC-level hook seams (`spec.hooks`, the request-level lifecycle hooks a host mounts from
27
- * the user's settings). A deployment's `RunnerDeps.hooks` already serve every leg; the spec-level seams did not,
28
- * so a `stop` seat a user wired ran for the leader and never for its teammates (CC runs `SubagentStop` from the
29
- * same settings). Same law as `onQuestion`: a child's own value wins, the seat fills an unset one.
27
+ * · `mods` — the parent's TASK seat of the mods bus (`spec.mods`, the request-level registrations a host mounts from
28
+ * the user's settings). A deployment's `RunnerDeps.mods` already serve every leg; the task seat did not, so a
29
+ * `classic.Stop` handler a user wired ran for the leader and never for its teammates (CC runs one chain for the
30
+ * session and its subagents, the event carrying `agentId`). A child dispatches the travelled registrations as its
31
+ * own task seat (its events carry the child's identity); an ancestor's chain still rides the constraint fold, and
32
+ * collapses into the child's own phase 1 when the installation is the same. Same law as `onQuestion`: a child's
33
+ * own value wins, the seat fills an unset one.
30
34
  * · `additionalDirectories` / `additionalReadDirectories` — the fs-fence widening (deployment property).
31
35
  * · `envFacts` — the sandbox facts (profile / egress / scratchpad).
32
36
  * · `memoryPersistenceCapable` — the deployment's DECLARED persistence statement: `false` is a REMOVAL (floor),
@@ -45,13 +49,18 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
45
49
  * and every leg multiplies it by its own.
46
50
  * · `fileHistory` — the request's file-history off switch (`"disabled"`, its only word), for the edits its delegates
47
51
  * make on its behalf too. An ORDINARY member (fill law); with one word no child can author it back on.
52
+ * · `promptForm` — the host form of the system prompt (`"minimal"`, its only word: the core-behavior band is out). A
53
+ * host's product choice for the whole delegation tree, so every engine-built child (both delegation lanes and the
54
+ * observer sidecar) composes the same set of sections. An ORDINARY member (fill law).
55
+ * · `promptBinding` — the center binding (a deployment's scenario name). A child composes its parent's center
56
+ * artifact, so it selects that artifact's scoped overlays by the same binding. An ORDINARY member (fill law).
48
57
  */
49
58
  export interface ParentSpecSeat {
50
59
  readonly principal?: string;
51
60
  readonly oneShot?: true;
52
61
  readonly clientContext?: TaskSpec["clientContext"];
53
62
  readonly onQuestion?: OnQuestion;
54
- readonly hooks?: Hooks;
63
+ readonly mods?: readonly ModRegistration<EngineDollar>[];
55
64
  readonly additionalDirectories?: readonly string[];
56
65
  readonly additionalReadDirectories?: readonly string[];
57
66
  readonly envFacts?: TaskSpec["envFacts"];
@@ -61,6 +70,8 @@ export interface ParentSpecSeat {
61
70
  readonly skillListingBudgetFraction?: number;
62
71
  readonly skillListingMaxDescChars?: number;
63
72
  readonly fileHistory?: "disabled";
73
+ readonly promptForm?: "minimal";
74
+ readonly promptBinding?: string;
64
75
  }
65
76
  /** Mint the seat off the parent's REBOUND spec and its frozen question face (spec over deps — the caller resolves it once,
66
77
  * the same value the parent's own question routing reads). Absent fields stay absent; `oneShot` only when `true`. */
@@ -4,7 +4,7 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
4
4
  ...(spec.oneShot === true ? { oneShot: true } : {}),
5
5
  ...(spec.clientContext !== undefined ? { clientContext: spec.clientContext } : {}),
6
6
  ...(frozenOnQuestion !== undefined ? { onQuestion: frozenOnQuestion } : {}),
7
- ...(spec.hooks !== undefined ? { hooks: spec.hooks } : {}),
7
+ ...(spec.mods !== undefined ? { mods: spec.mods } : {}),
8
8
  ...(spec.additionalDirectories !== undefined ? { additionalDirectories: Object.freeze([...spec.additionalDirectories]) } : {}),
9
9
  ...(spec.additionalReadDirectories !== undefined ? { additionalReadDirectories: Object.freeze([...spec.additionalReadDirectories]) } : {}),
10
10
  ...(spec.envFacts !== undefined ? { envFacts: Object.freeze({ ...spec.envFacts }) } : {}),
@@ -13,6 +13,8 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
13
13
  ...(spec.skillListingBudgetFraction !== undefined ? { skillListingBudgetFraction: spec.skillListingBudgetFraction } : {}),
14
14
  ...(spec.skillListingMaxDescChars !== undefined ? { skillListingMaxDescChars: spec.skillListingMaxDescChars } : {}),
15
15
  ...(spec.fileHistory !== undefined ? { fileHistory: spec.fileHistory } : {}),
16
+ ...(spec.promptForm !== undefined ? { promptForm: spec.promptForm } : {}),
17
+ ...(spec.promptBinding !== undefined ? { promptBinding: spec.promptBinding } : {}),
16
18
  ...(spec.memory?.enabled === false ? { memoryOff: true } : {}),
17
19
  });
18
20
  }
@@ -25,7 +27,7 @@ export function applyParentSpecSeat(child, seat) {
25
27
  ...fill("principal", seat.principal),
26
28
  ...fill("clientContext", seat.clientContext),
27
29
  ...fill("onQuestion", seat.onQuestion),
28
- ...fill("hooks", seat.hooks),
30
+ ...fill("mods", seat.mods),
29
31
  ...fill("additionalDirectories", (seat.additionalDirectories !== undefined ? [...seat.additionalDirectories] : undefined)),
30
32
  ...fill("additionalReadDirectories", (seat.additionalReadDirectories !== undefined ? [...seat.additionalReadDirectories] : undefined)),
31
33
  ...fill("envFacts", (seat.envFacts !== undefined ? { ...seat.envFacts } : undefined)),
@@ -33,6 +35,8 @@ export function applyParentSpecSeat(child, seat) {
33
35
  ...fill("skillListingBudgetFraction", seat.skillListingBudgetFraction),
34
36
  ...fill("skillListingMaxDescChars", seat.skillListingMaxDescChars),
35
37
  ...fill("fileHistory", seat.fileHistory),
38
+ ...fill("promptForm", seat.promptForm),
39
+ ...fill("promptBinding", seat.promptBinding),
36
40
  ...(seat.oneShot === true ? { oneShot: true } : {}),
37
41
  ...(seat.memoryPersistenceCapable === false ? { memoryPersistenceCapable: false } : fill("memoryPersistenceCapable", seat.memoryPersistenceCapable)),
38
42
  ...(seat.memoryOff === true ? { memory: memoryTurnedOff(child.memory) } : {}),
@@ -1,4 +1,5 @@
1
- import { anchorSpelling, isUncSpelling, win32NamespaceScreen } from "../tools/fs/safety.js";
1
+ import { anchorSpelling, win32NamespaceScreen } from "../tools/fs/safety.js";
2
+ import { isUncSpelling } from "./unc-spelling.js";
2
3
  export async function symlinkChainHops(env, path, signal, family, baseCwd) {
3
4
  if (typeof env.canonicalChain !== "function")
4
5
  return { ok: false, cause: "the environment declares no symlink-chain reader", asked: false };
@@ -28,3 +28,18 @@ export declare function lastIndexOfUnescaped(s: string, ch: string): number;
28
28
  * factory) to refuse the downgrades.
29
29
  */
30
30
  export declare function parsePermissionRule(rule: string): ParsedPermissionRule;
31
+ /**
32
+ * Can a rule name this tool name — is it the rule syntax's name head ({@link RULE_TOOL_NAME}) and not the lone `*`? The
33
+ * lone `*` is the wildcard (every tool), not a name: a tool called `*` could never be granted or refused on its own. The
34
+ * mount contract for every name a caller tool answers to (its name and each alias), so each one is a name every list can
35
+ * write; a protocol-minted name (`<ns>__<peer>__<tool>`, segments in `[A-Za-z0-9_-]`) is always one.
36
+ */
37
+ export declare function isNameableToolName(name: string): boolean;
38
+ /**
39
+ * One rule entry read by the rule syntax, or `undefined` when the syntax cannot read it: blanks around it, a tool name (the
40
+ * text before the first unescaped `(`, as written) outside {@link RULE_TOOL_NAME}, or a `(` the parse cannot close at the
41
+ * entry's end (the lenient parser's downgrade: the whole string read as a name); otherwise {@link parsePermissionRule}'s
42
+ * reading. THE test of "this is a rule spelling" — every entry list's reader asks it before any rule grammar reads the
43
+ * content (what the parentheses hold, a parenthesis or a control character included, is that grammar's to judge).
44
+ */
45
+ export declare function ruleSpellingOf(rule: string): ParsedPermissionRule | undefined;