@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
@@ -1,85 +1,95 @@
1
- import type { PromptPack } from "./types.js";
2
- /** the provider-declared sections of THIS run's resolved prompt (the `origin:"provider"`
3
- * subset of the compiled IR), the declaration axis of the artifact identity.
4
- *
5
- * (S1 round 2): declaration TEXT deliberately does NOT enter this shape — the epoch
6
- * digest is a deterministic, unsalted value persisted in exportable session entries, and session
7
- * readers do not see system prompts; hashing private text into it would be a dictionary-preimage
8
- * surface (the exact class the salted prompt-manifest hashes exist to prevent). Identity instead
9
- * rides `(id, slot, chars)` plus the declarer's OPT-IN `contentHash` (the digest-tiering value,
10
- * already public by declaration): with contentHash — byte-precise re-pin detection (the center
11
- * publish path always mints it); without — length-level detection only, documented degradation
12
- * for private/forwarded text. */
13
- export type EpochDeclaredSections = ReadonlyArray<{
14
- id: string;
15
- slot: string;
16
- chars: number;
17
- contentHash?: string;
18
- }>;
19
- /** How an epoch became active (protocol §9.2 descriptor field; `clear` arrives with a future
20
- * first-class context_reset — v1 clear = new session = `session_start`). */
21
- export type PromptEpochActivation = "session_start" | "compaction" | "legacy_migration";
22
- /** The durable pin, persisted as a first-class session entry (root) and restated in every
23
- * compaction entry's `details.promptEpoch` (same-CAS atomicity; bounded-tail recoverable). */
1
+ import type { PromptCatalog } from "./catalog/schema.js";
2
+ /** Deterministic canonical JSON (sorted keys) — the one identity encoding (the catalog digest, the identity, the
3
+ * center artifact digest). */
4
+ export declare function canonical(node: unknown): string;
5
+ /** `sha256:<hex>` over a canonical encoding. */
6
+ export declare function digestOf(node: unknown): string;
7
+ /** The bundled catalog's digest. Array positions that carry no meaning are normalized (sections by rank, messages and
8
+ * bands by id), so the digest does not depend on how a module lays out its arrays; variant order is meaning (first
9
+ * match wins) and stays. */
10
+ export declare function catalogDigestOf(catalog: PromptCatalog): string;
11
+ /** The inputs of a run's prompt identity. Only `center` is pinned (resolved by digest on resume); the rest are what
12
+ * the run computed, kept so a later run can say what changed. Absent `center` / `deploy` / `task` = that layer
13
+ * contributed nothing. */
14
+ export interface PromptIdentityLayers {
15
+ readonly catalog: string;
16
+ readonly renderers: Readonly<Record<string, number>>;
17
+ /** The adopted center artifact's digest. */
18
+ readonly center?: string;
19
+ readonly deploy?: string;
20
+ readonly task?: string;
21
+ /** H(the run's selector values). */
22
+ readonly binding: string;
23
+ }
24
+ /** A run's prompt identity inputs plus its pinned center layer's provenance — what the epoch record carries. */
25
+ export interface RunPromptIdentity {
26
+ readonly layers: PromptIdentityLayers;
27
+ readonly sourceRevision?: string;
28
+ }
29
+ /** The one identity digest over the four inputs. */
30
+ export declare function promptIdentityOf(layers: PromptIdentityLayers): string;
31
+ /** How a recorded epoch came to be: a legal boundary (`session_start`, `compaction`), or a record that code or
32
+ * inputs moved (`code_change`, naming the changed layers when they are known) or that only the selector values
33
+ * did (`selection_change`). */
34
+ export declare const PROMPT_EPOCH_ACTIVATIONS: readonly ["session_start", "compaction", "code_change", "selection_change"];
35
+ export type PromptEpochActivation = (typeof PROMPT_EPOCH_ACTIVATIONS)[number];
36
+ /** What a `code_change` record names as changed. `published_schema` is the one replacement of a retired-shape center
37
+ * pin by the current center layer. */
38
+ export declare const PROMPT_EPOCH_CHANGES: readonly ["catalog", "renderers", "deploy", "task", "published_schema"];
39
+ export type PromptEpochChange = (typeof PROMPT_EPOCH_CHANGES)[number];
40
+ /** The durable record, persisted as a first-class session entry and restated in every compaction entry's
41
+ * `details.promptEpoch`. */
24
42
  export interface PromptEpochDescriptor {
25
- /** Monotonic per-session epoch counter (session_start = 1). */
26
- epoch: number;
27
- artifactDigest: string;
28
- packId: string;
29
- assemblyApi: number;
30
- activatedBy: PromptEpochActivation;
31
- /** design/148 S1 (additive provenance, present only on center-adopted pins): the VERIFIED center
32
- * artifact this session composes from. `artifactDigest` above stays the computed
33
- * bundled+declarations identity (the existing re-pin machinery); this field is what the resume
34
- * path resolves through the artifact store — a miss is fail-loud (`prompt.snapshot_unavailable`),
35
- * never a silent hybrid recompose (protocol §9.2). */
36
- centerArtifactDigest?: string;
37
- /** Opaque publish provenance of the adopted envelope (audit only — never enters any digest). */
38
- sourceRevision?: string;
43
+ /** Monotonic per-session record counter. */
44
+ readonly epoch: number;
45
+ /** The run's prompt identity ({@link promptIdentityOf}). */
46
+ readonly identity: string;
47
+ readonly layers: PromptIdentityLayers;
48
+ readonly activatedBy: PromptEpochActivation;
49
+ /** Present only on `code_change` records whose changed layers are known. */
50
+ readonly changed?: readonly PromptEpochChange[];
51
+ /** Opaque publish provenance of the pinned center layer (present only with `layers.center`; never digested). */
52
+ readonly sourceRevision?: string;
39
53
  }
40
- /** Deterministic canonical JSON (sorted keys) — shared identity encoding for the bundled-pack
41
- * digest AND the center artifact digests (design/148 S1: one canonicalization, never two). */
42
- export declare function canonical(node: unknown): string;
43
- /**
44
- * Bundled-pack artifact digest: canonical hash over the pack's structural declaration PLUS each
45
- * section's probe-rendered content under the probe-fact vectors — all-off, all-on, and one
46
- * single-axis-flipped vector per axis (content- and admission-binding, incl. single-gate mixed
47
- * states). TOTALITY over the axes the pack forks on is the load-bearing property (see
48
- * PROBE_FACTS_OFF/PROBE_FACTS_ON); it is pinned behaviourally by
49
- * test/hardening-prompt-assembly.test.ts. Deterministic across processes and object insertion order;
50
- * changes to any section's prose, admission behavior, or structure change the digest. Build version
51
- * deliberately EXCLUDED (F3): a release that doesn't touch the pack keeps the same identity.
52
- */
53
- export declare function computeBundledArtifactDigest(pack: PromptPack, declared?: EpochDeclaredSections): string;
54
- /** Mint the descriptor for a NEW session on the current bundled artifact.
55
- * Subagent/fork note (RB-16 ruling, 2026-07-17): children mint their OWN session_start pin rather
56
- * than inheriting the parent's descriptor — under v1 bundled-only resolution both produce the
57
- * identical pin (same process, same pack, same digest), so the protocol's "explicit inheritance
58
- * via RunInternals" is deferred to the multi-artifact era, where a parent pinned to a non-latest
59
- * artifact genuinely diverges from a fresh mint (lands with the center candidate machinery). */
60
- export declare function mintSessionStartEpoch(pack: PromptPack, declared?: EpochDeclaredSections): PromptEpochDescriptor;
61
- /** Epoch selection at a compaction boundary (protocol §9.3 order steps 1-4, v1 bundled form):
62
- * the "latest validated candidate" IS the current bundled artifact. Same digest ⇒ restate the
63
- * current epoch (no advance); different digest (engine upgraded mid-session) ⇒ advance. */
64
- export declare function selectCompactionEpoch(current: PromptEpochDescriptor | undefined, pack: PromptPack, declared?: EpochDeclaredSections,
65
- /** RB-31 (design/148 S2) — a compaction-boundary CENTER ADOPTION: the new candidate's provenance
66
- * rides the advanced descriptor (the caller pre-assembled with the candidate's declarations, so
67
- * `declared` already reflects the new closure — the digest moves, the epoch advances). */
68
- centerAdoption?: {
69
- centerArtifactDigest: string;
70
- sourceRevision?: string;
54
+ /** What a stored epoch record reads as on the resume path: a v3 pin, or a retired shape recognized by name. */
55
+ export type StoredPromptEpoch = {
56
+ readonly kind: "pin";
57
+ readonly descriptor: PromptEpochDescriptor;
71
58
  } | {
72
- clear: true;
73
- }): PromptEpochDescriptor;
59
+ readonly kind: "legacy";
60
+ readonly centerPinned: boolean;
61
+ };
74
62
  /**
75
- * Resolve the session's pinned epoch against the CURRENT bundled artifact (v1 resolution).
76
- * Returns the effective descriptor plus whether a legacy migration happened (pin from another
77
- * build, or a pre-epoch session with no pin at all) — the caller records the migration entry.
63
+ * Shape-normalize an untrusted v3 descriptor — the current shape's one judge (the first reading of
64
+ * {@link readStoredPromptEpoch}; a session backend judges a record with it). Strict: a bounded positive epoch, a full
65
+ * digest identity that MATCHES its layers, the closed activation and change vocabularies, provenance only beside a
66
+ * center layer. Members it does not read (a session entry's own `type` / `id` / `parentId` / `timestamp`) are ignored.
67
+ * Undefined for anything else — including every retired shape.
78
68
  */
79
- export declare function resolveEpochAgainstBundled(pinned: PromptEpochDescriptor | undefined, pack: PromptPack, declared?: EpochDeclaredSections): {
80
- descriptor: PromptEpochDescriptor;
81
- migrated: boolean;
82
- };
83
- /** Shape-normalize an untrusted candidate (session import face — RB-7: import-validate is a
84
- * consumer). Returns undefined for anything that isn't a plausible descriptor. */
85
69
  export declare function normalizePromptEpoch(raw: unknown): PromptEpochDescriptor | undefined;
70
+ /**
71
+ * The resume path's reading of one stored record: a valid v3 pin, `legacy` (a retired shape, recognized by its field
72
+ * names — nothing in it is parsed but whether `centerArtifactDigest` is a digest, the only value the retired reader
73
+ * took for a pin), or undefined (malformed: the walk skips it).
74
+ */
75
+ export declare function readStoredPromptEpoch(raw: unknown): StoredPromptEpoch | undefined;
76
+ /**
77
+ * The record a run leaves at prepare, or undefined when the stored pin already names this run's identity.
78
+ * - no record: `session_start` for a session with no prior conversation; otherwise `code_change` (a session that
79
+ * predates epochs — what changed is unknown);
80
+ * - a v3 pin: the same identity ⇒ nothing; else `code_change` naming the changed code / input layers, or
81
+ * `selection_change` when only the selector values moved;
82
+ * - `legacy`: `code_change` — naming `published_schema` when the retired record pinned a center artifact (the caller
83
+ * applied the center source's tri-state to it), otherwise unknown. The retired record's counter is not read; the
84
+ * v3 line starts at 1.
85
+ */
86
+ export declare function prepareEpochRecord(stored: StoredPromptEpoch | undefined, layers: PromptIdentityLayers, ctx: {
87
+ readonly priorConversation: boolean;
88
+ readonly sourceRevision?: string;
89
+ }): PromptEpochDescriptor | undefined;
90
+ /**
91
+ * The record a compaction restates or advances: the current pin restated when the run's identity is unchanged (the
92
+ * boundary is stamped), otherwise a new record with the run's layers after the boundary — an adopted center
93
+ * candidate, or an emptied center layer after an explicit revocation.
94
+ */
95
+ export declare function selectCompactionEpoch(current: PromptEpochDescriptor | undefined, layers: PromptIdentityLayers, sourceRevision?: string): PromptEpochDescriptor;
@@ -7,140 +7,55 @@ export function canonical(node) {
7
7
  const keys = Object.keys(node).sort();
8
8
  return `{${keys.map((k) => `${JSON.stringify(k)}:${canonical(node[k])}`).join(",")}}`;
9
9
  }
10
- const PROBE_FACTS_OFF = {
11
- policyEnabled: false,
12
- hooksEnabled: false,
13
- isolationEnabled: false,
14
- withinTaskCompactionEnabled: false,
15
- supervisorEnabled: false,
16
- orchestrationEnabled: false,
17
- awarenessEnabled: false,
18
- goalEnabled: false,
19
- worktreeIsolated: false,
20
- teammateEnabled: false,
21
- orchestrationDeferred: false,
22
- isSubagent: false,
23
- promptProfile: "simple",
24
- fableMitigations: false,
25
- readFaceOpen: false,
26
- writeFaceOpen: false,
27
- reminderMark: undefined,
28
- };
29
- const PROBE_FACTS_ON = {
30
- policyEnabled: true,
31
- hooksEnabled: true,
32
- isolationEnabled: true,
33
- withinTaskCompactionEnabled: true,
34
- supervisorEnabled: true,
35
- orchestrationEnabled: true,
36
- awarenessEnabled: true,
37
- goalEnabled: true,
38
- worktreeIsolated: true,
39
- teammateEnabled: true,
40
- orchestrationDeferred: true,
41
- isSubagent: true,
42
- promptProfile: "classic",
43
- fableMitigations: true,
44
- readFaceOpen: true,
45
- writeFaceOpen: true,
46
- reminderMark: "PROBE-FIXED-MARK-AXIS0",
47
- };
48
- const PROBE_VECTORS = [
49
- PROBE_FACTS_OFF,
50
- PROBE_FACTS_ON,
51
- ...Object.keys(PROBE_FACTS_OFF).map((k) => ({ ...PROBE_FACTS_OFF, [k]: PROBE_FACTS_ON[k] })),
52
- ];
53
- const PROBE_INPUTS_BASE = {
54
- roleBase: "\u0000probe-role\u0000",
55
- roleAppend: "\u0000probe-append\u0000",
56
- mcpInstructionsBlock: "\u0000probe-mcp\u0000",
57
- environmentBlock: "\u0000probe-env@2\u0000",
58
- memoryBlock: "\u0000probe-memory\u0000",
59
- modelGuidance: "\u0000probe-guidance\u0000",
60
- };
61
- export function computeBundledArtifactDigest(pack, declared) {
62
- const probeSection = (s) => PROBE_VECTORS.map((facts) => {
63
- const inputs = { ...PROBE_INPUTS_BASE, facts };
64
- try {
65
- if (s.admit && !s.admit(inputs))
66
- return null;
67
- return s.content(inputs) ?? null;
68
- }
69
- catch {
70
- return " probe-threw ";
71
- }
72
- });
73
- const payload = {
74
- packId: pack.packId,
75
- assemblyApi: pack.assemblyApi,
76
- ...(declared !== undefined && declared.length > 0
77
- ? { declaredSections: declared.map((d) => ({ id: d.id, slot: d.slot, chars: d.chars, ...(d.contentHash !== undefined ? { contentHash: d.contentHash } : {}) })) }
78
- : {}),
79
- sections: [...pack.sections].sort((a, b) => a.rank - b.rank).map((s) => ({
80
- id: s.id,
81
- slot: s.slot,
82
- rank: s.rank,
83
- owner: s.owner,
84
- trust: s.trust,
85
- mutability: s.mutability,
86
- cadence: s.cadence,
87
- cacheClass: s.cacheClass,
88
- carrier: s.carrier,
89
- legacyBlockId: s.blockId,
90
- probes: probeSection(s),
91
- })),
92
- };
93
- return `sha256:${createHash("sha256").update(canonical(payload)).digest("hex")}`;
10
+ export function digestOf(node) {
11
+ return `sha256:${createHash("sha256").update(canonical(node)).digest("hex")}`;
94
12
  }
95
- export function mintSessionStartEpoch(pack, declared) {
96
- return {
97
- epoch: 1,
98
- artifactDigest: computeBundledArtifactDigest(pack, declared),
99
- packId: pack.packId,
100
- assemblyApi: pack.assemblyApi,
101
- activatedBy: "session_start",
102
- };
13
+ export function catalogDigestOf(catalog) {
14
+ return digestOf({
15
+ ...catalog,
16
+ bands: [...catalog.bands].sort((a, b) => a.id.localeCompare(b.id)),
17
+ messages: [...catalog.messages].sort((a, b) => a.id.localeCompare(b.id)),
18
+ sections: [...catalog.sections].sort((a, b) => a.rank - b.rank),
19
+ });
103
20
  }
104
- export function selectCompactionEpoch(current, pack, declared, centerAdoption) {
105
- const digest = computeBundledArtifactDigest(pack, declared);
106
- if (centerAdoption === undefined && current && current.artifactDigest === digest) {
107
- return { ...current, activatedBy: "compaction" };
108
- }
109
- return {
110
- epoch: (current?.epoch ?? 0) + 1,
111
- artifactDigest: digest,
112
- packId: pack.packId,
113
- assemblyApi: pack.assemblyApi,
114
- activatedBy: "compaction",
115
- ...(centerAdoption !== undefined
116
- ? "clear" in centerAdoption
117
- ? {}
118
- : {
119
- centerArtifactDigest: centerAdoption.centerArtifactDigest,
120
- ...(centerAdoption.sourceRevision !== undefined ? { sourceRevision: centerAdoption.sourceRevision } : {}),
121
- }
122
- : current?.centerArtifactDigest !== undefined
123
- ? {
124
- centerArtifactDigest: current.centerArtifactDigest,
125
- ...(current.sourceRevision !== undefined ? { sourceRevision: current.sourceRevision } : {}),
126
- }
127
- : {}),
128
- };
21
+ export function promptIdentityOf(layers) {
22
+ return digestOf({
23
+ catalog: layers.catalog,
24
+ renderers: layers.renderers,
25
+ overlays: digestOf({ center: layers.center ?? null, deploy: layers.deploy ?? null, task: layers.task ?? null }),
26
+ binding: layers.binding,
27
+ });
129
28
  }
130
- export function resolveEpochAgainstBundled(pinned, pack, declared) {
131
- const digest = computeBundledArtifactDigest(pack, declared);
132
- if (pinned && pinned.artifactDigest === digest && pinned.packId === pack.packId && pinned.assemblyApi === pack.assemblyApi) {
133
- return { descriptor: pinned, migrated: false };
134
- }
29
+ export const PROMPT_EPOCH_ACTIVATIONS = Object.freeze(["session_start", "compaction", "code_change", "selection_change"]);
30
+ export const PROMPT_EPOCH_CHANGES = Object.freeze(["catalog", "renderers", "deploy", "task", "published_schema"]);
31
+ const DIGEST = /^sha256:[0-9a-f]{64}$/;
32
+ const isDigest = (v) => typeof v === "string" && DIGEST.test(v);
33
+ const RETIRED_DESCRIPTOR_FIELDS = Object.freeze(["artifactDigest", "packId", "assemblyApi", "centerArtifactDigest"]);
34
+ function normalizeLayers(raw) {
35
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw))
36
+ return undefined;
37
+ const r = raw;
38
+ for (const k of Object.keys(r))
39
+ if (!["catalog", "renderers", "center", "deploy", "task", "binding"].includes(k))
40
+ return undefined;
41
+ if (!isDigest(r.catalog) || !isDigest(r.binding))
42
+ return undefined;
43
+ for (const k of ["center", "deploy", "task"])
44
+ if (r[k] !== undefined && !isDigest(r[k]))
45
+ return undefined;
46
+ const rv = r.renderers;
47
+ if (rv === null || typeof rv !== "object" || Array.isArray(rv))
48
+ return undefined;
49
+ const entries = Object.entries(rv);
50
+ if (entries.length > 64 || entries.some(([k, v]) => k.length === 0 || k.length > 64 || typeof v !== "number" || !Number.isInteger(v) || v < 1 || v > 1_000_000))
51
+ return undefined;
135
52
  return {
136
- descriptor: {
137
- epoch: (pinned?.epoch ?? 0) + 1,
138
- artifactDigest: digest,
139
- packId: pack.packId,
140
- assemblyApi: pack.assemblyApi,
141
- activatedBy: "legacy_migration",
142
- },
143
- migrated: true,
53
+ catalog: r.catalog,
54
+ renderers: Object.fromEntries(entries),
55
+ ...(r.center !== undefined ? { center: r.center } : {}),
56
+ ...(r.deploy !== undefined ? { deploy: r.deploy } : {}),
57
+ ...(r.task !== undefined ? { task: r.task } : {}),
58
+ binding: r.binding,
144
59
  };
145
60
  }
146
61
  export function normalizePromptEpoch(raw) {
@@ -149,23 +64,81 @@ export function normalizePromptEpoch(raw) {
149
64
  const r = raw;
150
65
  if (typeof r.epoch !== "number" || !Number.isInteger(r.epoch) || r.epoch < 1 || r.epoch > 1_000_000_000)
151
66
  return undefined;
152
- if (typeof r.artifactDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(r.artifactDigest))
67
+ if (!isDigest(r.identity))
153
68
  return undefined;
154
- if (typeof r.packId !== "string" || !r.packId.trim() || r.packId.length > 200)
69
+ const layers = normalizeLayers(r.layers);
70
+ if (layers === undefined || promptIdentityOf(layers) !== r.identity)
155
71
  return undefined;
156
- if (r.assemblyApi !== 1)
72
+ if (!PROMPT_EPOCH_ACTIVATIONS.some((a) => a === r.activatedBy))
157
73
  return undefined;
158
- if (r.activatedBy !== "session_start" && r.activatedBy !== "compaction" && r.activatedBy !== "legacy_migration")
74
+ const activatedBy = r.activatedBy;
75
+ let changed;
76
+ if (r.changed !== undefined) {
77
+ if (activatedBy !== "code_change" || !Array.isArray(r.changed) || r.changed.length === 0)
78
+ return undefined;
79
+ if (r.changed.some((c) => !PROMPT_EPOCH_CHANGES.some((w) => w === c)) || new Set(r.changed).size !== r.changed.length)
80
+ return undefined;
81
+ changed = [...r.changed];
82
+ }
83
+ if (r.sourceRevision !== undefined && (layers.center === undefined || typeof r.sourceRevision !== "string" || r.sourceRevision.length === 0 || r.sourceRevision.length > 500))
159
84
  return undefined;
160
- const centerArtifactDigest = typeof r.centerArtifactDigest === "string" && /^sha256:[0-9a-f]{64}$/.test(r.centerArtifactDigest) ? r.centerArtifactDigest : undefined;
161
- const sourceRevision = typeof r.sourceRevision === "string" && r.sourceRevision.length > 0 && r.sourceRevision.length <= 500 ? r.sourceRevision : undefined;
162
85
  return {
163
86
  epoch: r.epoch,
164
- artifactDigest: r.artifactDigest,
165
- packId: r.packId,
166
- assemblyApi: 1,
167
- activatedBy: r.activatedBy,
168
- ...(centerArtifactDigest !== undefined ? { centerArtifactDigest } : {}),
169
- ...(centerArtifactDigest !== undefined && sourceRevision !== undefined ? { sourceRevision } : {}),
87
+ identity: r.identity,
88
+ layers,
89
+ activatedBy,
90
+ ...(changed !== undefined ? { changed } : {}),
91
+ ...(r.sourceRevision !== undefined ? { sourceRevision: r.sourceRevision } : {}),
92
+ };
93
+ }
94
+ export function readStoredPromptEpoch(raw) {
95
+ const descriptor = normalizePromptEpoch(raw);
96
+ if (descriptor !== undefined)
97
+ return { kind: "pin", descriptor };
98
+ if (raw === null || typeof raw !== "object")
99
+ return undefined;
100
+ const r = raw;
101
+ if (!RETIRED_DESCRIPTOR_FIELDS.some((f) => f in r))
102
+ return undefined;
103
+ return { kind: "legacy", centerPinned: isDigest(r.centerArtifactDigest) };
104
+ }
105
+ function changedLayers(a, b) {
106
+ const out = [];
107
+ if (a.catalog !== b.catalog)
108
+ out.push("catalog");
109
+ if (canonical(a.renderers) !== canonical(b.renderers))
110
+ out.push("renderers");
111
+ if (a.deploy !== b.deploy)
112
+ out.push("deploy");
113
+ if (a.task !== b.task)
114
+ out.push("task");
115
+ return out;
116
+ }
117
+ function descriptorOf(epoch, layers, activatedBy, extra) {
118
+ return {
119
+ epoch,
120
+ identity: promptIdentityOf(layers),
121
+ layers,
122
+ activatedBy,
123
+ ...(extra.changed !== undefined && extra.changed.length > 0 ? { changed: [...extra.changed] } : {}),
124
+ ...(layers.center !== undefined && extra.sourceRevision !== undefined ? { sourceRevision: extra.sourceRevision } : {}),
170
125
  };
171
126
  }
127
+ export function prepareEpochRecord(stored, layers, ctx) {
128
+ if (stored === undefined)
129
+ return descriptorOf(1, layers, ctx.priorConversation ? "code_change" : "session_start", ctx);
130
+ if (stored.kind === "legacy")
131
+ return descriptorOf(1, layers, "code_change", { ...ctx, ...(stored.centerPinned ? { changed: ["published_schema"] } : {}) });
132
+ const pinned = stored.descriptor;
133
+ if (pinned.identity === promptIdentityOf(layers))
134
+ return undefined;
135
+ const changed = changedLayers(pinned.layers, layers);
136
+ return descriptorOf(pinned.epoch + 1, layers, changed.length > 0 ? "code_change" : "selection_change", { ...ctx, changed });
137
+ }
138
+ export function selectCompactionEpoch(current, layers, sourceRevision) {
139
+ if (current !== undefined && current.identity === promptIdentityOf(layers)) {
140
+ const { changed: _recordOnly, ...restated } = current;
141
+ return { ...restated, activatedBy: "compaction" };
142
+ }
143
+ return descriptorOf((current?.epoch ?? 0) + 1, layers, "compaction", sourceRevision !== undefined ? { sourceRevision } : {});
144
+ }
@@ -1,57 +1,81 @@
1
+ import type { BandId, OverlayOp } from "./catalog/schema.js";
2
+ /** A `prompt.assembled` manifest (v3) as explain reads it: the frame's own members. */
1
3
  export interface ExplainInput {
2
- constitution: "core" | "replaced" | "provider-assembled";
3
- blocks: Array<{
4
+ identity: {
5
+ artifact: string;
6
+ layers: {
7
+ center?: string;
8
+ deploy?: string;
9
+ task?: string;
10
+ };
11
+ epoch: number;
12
+ activatedBy: string;
13
+ };
14
+ selectors: {
15
+ binding?: string;
16
+ traits: readonly string[];
17
+ host: {
18
+ role: string;
19
+ form: string;
20
+ };
21
+ };
22
+ blocks: ReadonlyArray<{
4
23
  id: string;
5
24
  chars: number;
6
25
  hash: string;
7
26
  }>;
8
- sections?: Array<{
27
+ sections: ReadonlyArray<{
9
28
  id: string;
10
- slot: string;
11
- carrier: string;
12
- cadence: string;
13
- cacheClass: string;
29
+ band: string;
30
+ variant?: string;
14
31
  chars: number;
15
- hash: string;
16
- contentHash?: string;
32
+ locale: string;
33
+ contentHash: string;
34
+ chain: ReadonlyArray<{
35
+ source: string;
36
+ overlay?: string;
37
+ op?: string;
38
+ superseded?: true;
39
+ }>;
17
40
  }>;
18
- tools?: Array<{
41
+ superseded?: ReadonlyArray<{
42
+ id: string;
43
+ source: string;
44
+ by: string;
45
+ target: string;
46
+ supersededBy: string;
47
+ }>;
48
+ tools?: ReadonlyArray<{
19
49
  wireName: string;
20
50
  contractId: string;
21
51
  cardId: string;
22
52
  shapeDigest: string;
23
53
  }>;
24
- epoch?: {
25
- epoch: number;
26
- artifactDigest: string;
27
- packId: string;
28
- activatedBy: string;
29
- };
30
54
  }
31
- /** Render a `prompt.assembled` manifest (+ optional epoch pin) as a readable report. */
55
+ /** Render a `prompt.assembled` manifest as a readable report: which prompt (identity, its layers, the selector values),
56
+ * what composed it, and where each section's text came from. */
32
57
  export declare function explainPromptAssembly(input: ExplainInput): string;
33
58
  /**
34
- * the CENTER-facing read-only description of the default pack: section
35
- * metadata (id/slot/rank/ownership/locked) plus the default role-base TEXT (the append-mode
36
- * compile skeleton the web UI prepends to a user's "Role details"). Deliberately NO other section
37
- * texts (the no-prompt-bodies observability line — structure yes, prose no; the role base is
38
- * the one deliberate exception: it is the public compile input of the append mode, and its text is
39
- * this open repo's DEFAULT_SYSTEM_PROMPT). Programmatic — a static copy in the web tier would
40
- * silently drift the moment core's default prompt changes (no static copies).
59
+ * The CENTER-facing read-only description of the bundled catalog: each section's id, band, rank and what each overlay
60
+ * source class may do to it (the band's three op columns — a center editor reads `ops.center`; an empty column for
61
+ * every class is a platform-managed section), plus the default role-base TEXT (the append-mode compile skeleton the web
62
+ * UI prepends to a user's "Role details"). No other section texts. Programmatic — a static copy in the web tier would
63
+ * drift the moment the catalog changes.
41
64
  */
42
- export interface DefaultPackDescription {
43
- packId: string;
44
- /** The pack-default role base (append-mode skeleton). */
65
+ export interface CatalogDescription {
66
+ catalogId: string;
67
+ /** The catalog-default role base (append-mode skeleton). */
45
68
  roleBaseText: string;
46
69
  sections: Array<{
47
70
  id: string;
48
- slot: string;
71
+ band: BandId;
49
72
  rank: number;
50
- owner: string;
51
- trust: string;
52
- mutability: string;
53
- /** True ⇒ not deployment-writable (the UI shows the platform-managed indicator, never an editor). */
54
- locked: boolean;
73
+ /** The band's op columns: what a center artifact, a deployment's mods and a task may do to this section. */
74
+ ops: {
75
+ center: readonly OverlayOp[];
76
+ deploy: readonly OverlayOp[];
77
+ task: readonly OverlayOp[];
78
+ };
55
79
  }>;
56
80
  }
57
- export declare function describeDefaultPack(): DefaultPackDescription;
81
+ export declare function describeCatalog(): CatalogDescription;
@@ -1,23 +1,28 @@
1
1
  import { EVENT_PROMPT_REGISTRY } from "./event-registry.js";
2
- import { SEMA_DEFAULT_PACK } from "./packs/sema-default.js";
3
- import { DEFAULT_SYSTEM_PROMPT } from "../prompts/default.js";
2
+ import { bandOf } from "./bands.js";
3
+ import { SEMA_DEFAULT_CATALOG, catalogText } from "./catalog/index.js";
4
4
  function safeId(raw) {
5
- const cleaned = raw.replace(/[\u0000-\u001f\u007f]/g, "\u2400");
5
+ const cleaned = raw.replace(/[\u0000-\u001f\u007f]/g, "␀");
6
6
  return cleaned.length > 120 ? `${cleaned.slice(0, 117)}...` : cleaned;
7
7
  }
8
8
  export function explainPromptAssembly(input) {
9
9
  const lines = [];
10
- lines.push(`constitution: ${safeId(input.constitution)}${input.constitution === "core" ? "" : " (non-default — see PromptProvider tier docs)"}`);
11
- if (input.epoch) {
12
- lines.push(`epoch: #${input.epoch.epoch} on ${safeId(input.epoch.packId)} (${safeId(input.epoch.artifactDigest).slice(0, 23)}…) via ${safeId(input.epoch.activatedBy)}`);
13
- }
14
- lines.push(`system blocks (v1 view): ${input.blocks.map((b) => `${safeId(b.id)}[${b.chars}ch]`).join(" → ")}`);
15
- if (input.sections?.length) {
16
- lines.push("sections (compiled IR):");
17
- for (const s of input.sections) {
18
- lines.push(` ${safeId(s.id)} slot=${safeId(s.slot)} carrier=${safeId(s.carrier)} cadence=${safeId(s.cadence)} cache=${safeId(s.cacheClass)} ${s.chars}ch #${safeId(s.hash)}${s.contentHash !== undefined ? ` content=${safeId(s.contentHash)}` : ""}`);
10
+ const short = (d) => (d === undefined ? "none" : `${safeId(d).slice(0, 23)}…`);
11
+ lines.push(`identity: ${short(input.identity.artifact)} (record #${input.identity.epoch} via ${safeId(input.identity.activatedBy)})`);
12
+ lines.push(` layers: center=${short(input.identity.layers.center)} deploy=${short(input.identity.layers.deploy)} task=${short(input.identity.layers.task)}`);
13
+ const s = input.selectors;
14
+ lines.push(` selectors: role=${safeId(s.host.role)} form=${safeId(s.host.form)} traits=[${s.traits.map(safeId).join(", ")}]${s.binding !== undefined ? ` binding=${safeId(s.binding)}` : ""}`);
15
+ lines.push(`system blocks: ${input.blocks.map((b) => `${safeId(b.id)}[${b.chars}ch]`).join(" → ")}`);
16
+ if (input.sections.length > 0) {
17
+ lines.push("sections:");
18
+ for (const sec of input.sections) {
19
+ const chain = sec.chain.map((l) => (l.source === "bundled" ? "bundled" : `${safeId(l.source)}:${l.op ?? "?"} ${safeId(l.overlay ?? "?")}${l.superseded === true ? " (superseded)" : ""}`)).join(" > ");
20
+ lines.push(` ${safeId(sec.id)} band=${safeId(sec.band)}${sec.variant !== undefined ? ` variant=${safeId(sec.variant)}` : ""} ${sec.chars}ch ${safeId(sec.locale)} ${safeId(sec.contentHash).slice(0, 19)}… ${chain}`);
19
21
  }
20
22
  }
23
+ if (input.superseded?.length) {
24
+ lines.push(`superseded: ${input.superseded.map((o) => `${safeId(o.id)} (${safeId(o.source)}) on ${safeId(o.target)} by ${safeId(o.supersededBy)}`).join("; ")}`);
25
+ }
21
26
  if (input.tools?.length) {
22
27
  const legacy = input.tools.filter((t) => t.contractId.startsWith("legacy:"));
23
28
  lines.push(`tools: ${input.tools.length} mounted (${input.tools.length - legacy.length} contract-declared, ${legacy.length} legacy/external)`);
@@ -26,18 +31,10 @@ export function explainPromptAssembly(input) {
26
31
  lines.push(`event kinds registered: ${kinds.length} (default-on: ${kinds.filter((k) => k.defaultPolicy === "on").map((k) => k.kind).join(", ")})`);
27
32
  return lines.join("\n");
28
33
  }
29
- export function describeDefaultPack() {
34
+ export function describeCatalog() {
30
35
  return {
31
- packId: SEMA_DEFAULT_PACK.packId,
32
- roleBaseText: DEFAULT_SYSTEM_PROMPT,
33
- sections: [...SEMA_DEFAULT_PACK.sections].sort((a, b) => a.rank - b.rank).map((s) => ({
34
- id: s.id,
35
- slot: s.slot,
36
- rank: s.rank,
37
- owner: s.owner,
38
- trust: s.trust,
39
- mutability: s.mutability,
40
- locked: s.mutability === "locked",
41
- })),
36
+ catalogId: SEMA_DEFAULT_CATALOG.id,
37
+ roleBaseText: catalogText("core/role.base", "default"),
38
+ sections: [...SEMA_DEFAULT_CATALOG.sections].sort((a, b) => a.rank - b.rank).map((s) => ({ id: s.id, band: s.band, rank: s.rank, ops: bandOf(s.band).ops })),
42
39
  };
43
40
  }