@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.
- package/CHANGELOG.md +550 -2
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/read-inbox-tool.d.ts +1 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.d.ts +5 -0
- package/dist/agents/subagent.js +7 -4
- package/dist/agents/tool-filter.d.ts +40 -13
- package/dist/agents/tool-filter.js +28 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.js +16 -12
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +4 -4
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +117 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/core/allow-entry.d.ts +42 -8
- package/dist/core/allow-entry.js +24 -17
- package/dist/core/auto-compaction.d.ts +23 -20
- package/dist/core/auto-compaction.js +37 -16
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +36 -12
- package/dist/core/checkpoint-store.js +1 -1
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +36 -19
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +5 -23
- package/dist/core/gate-lanes.js +356 -270
- package/dist/core/governance-codes.d.ts +9 -4
- package/dist/core/governance-codes.js +9 -3
- package/dist/core/hooks.d.ts +276 -734
- package/dist/core/hooks.js +97 -192
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/locked-config.d.ts +26 -5
- package/dist/core/locked-config.js +31 -6
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-spec.d.ts +53 -7
- package/dist/core/mcp-server-spec.js +84 -1
- package/dist/core/mcp.d.ts +11 -7
- package/dist/core/mcp.js +27 -9
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +8 -11
- package/dist/core/memory-engine/engine.js +9 -5
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +4 -0
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +701 -0
- package/dist/core/mods/kernel/events.d.ts +242 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +65 -0
- package/dist/core/mods/kernel/receive.js +123 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +84 -0
- package/dist/core/mods/kernel/site-rules.js +104 -0
- package/dist/core/mods/stations.d.ts +350 -0
- package/dist/core/mods/stations.js +444 -0
- package/dist/core/own-property-receipt.js +11 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +7 -1
- package/dist/core/permission-rules.js +26 -15
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +85 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +8 -2
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/person-path-rows.js +1 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +5 -0
- package/dist/core/runner/prepare-config-doors.js +9 -0
- package/dist/core/runner/prepare-defer-classify.js +3 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +8 -21
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -16
- package/dist/core/runner/prepare-policy-chain.js +98 -101
- package/dist/core/runner/prepare-project-context.js +7 -10
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +134 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
- package/dist/core/runner/prepare-prompt-inputs.js +5 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +33 -15
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
- package/dist/core/runner/prepare-wiring-manifest.js +7 -7
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.js +3 -1
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +62 -84
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +11 -10
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +33 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +23 -34
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +14 -72
- package/dist/core/runner/session-rule-policy.d.ts +6 -4
- package/dist/core/runner/session-rule-policy.js +17 -10
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
- package/dist/core/runner/sub-agent-deny-lists.js +228 -71
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +20 -28
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +93 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +93 -17
- package/dist/core/session-policy-store.js +178 -25
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/task-event.d.ts +13 -3
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +59 -18
- package/dist/core/tool-policy.js +77 -12
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.js +1 -0
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/user-attachment.d.ts +12 -2
- package/dist/core/user-attachment.js +17 -2
- package/dist/core/wiring-manifest.d.ts +14 -13
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +3 -3
- package/dist/engine/harness/types.d.ts +17 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.js +1 -1
- package/dist/engine/loop/types.d.ts +1 -1
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +24 -17
- package/dist/index.js +15 -12
- package/dist/internal/harness.d.ts +1 -1
- package/dist/internal/harness.js +1 -1
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +37 -56
- package/dist/prompt-assembly/artifact-store.js +31 -49
- package/dist/prompt-assembly/artifact.d.ts +89 -76
- package/dist/prompt-assembly/artifact.js +167 -146
- package/dist/prompt-assembly/assemble.d.ts +34 -29
- package/dist/prompt-assembly/assemble.js +33 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +59 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +24 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +127 -0
- package/dist/prompt-assembly/overlay.js +301 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +56 -0
- package/dist/prompt-assembly/select.js +69 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -500
- package/dist/prompts/default.js +20 -285
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/session-policy-store.d.ts +3 -3
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +256 -99
- package/wire-changes/core@7.51.1.json +5 -5
- package/wire-changes/core@7.51.2.json +293 -0
- package/wire-changes/core@7.52.0.json +5859 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -1,85 +1,95 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
26
|
-
epoch: number;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
activatedBy: PromptEpochActivation;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
73
|
-
|
|
59
|
+
readonly kind: "legacy";
|
|
60
|
+
readonly centerPinned: boolean;
|
|
61
|
+
};
|
|
74
62
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
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
|
-
|
|
11
|
-
|
|
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
|
|
96
|
-
return {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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 (
|
|
67
|
+
if (!isDigest(r.identity))
|
|
153
68
|
return undefined;
|
|
154
|
-
|
|
69
|
+
const layers = normalizeLayers(r.layers);
|
|
70
|
+
if (layers === undefined || promptIdentityOf(layers) !== r.identity)
|
|
155
71
|
return undefined;
|
|
156
|
-
if (
|
|
72
|
+
if (!PROMPT_EPOCH_ACTIVATIONS.some((a) => a === r.activatedBy))
|
|
157
73
|
return undefined;
|
|
158
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
...(
|
|
169
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
|
27
|
+
sections: ReadonlyArray<{
|
|
9
28
|
id: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cadence: string;
|
|
13
|
-
cacheClass: string;
|
|
29
|
+
band: string;
|
|
30
|
+
variant?: string;
|
|
14
31
|
chars: number;
|
|
15
|
-
|
|
16
|
-
contentHash
|
|
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
|
-
|
|
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
|
|
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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
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
|
|
43
|
-
|
|
44
|
-
/** The
|
|
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
|
-
|
|
71
|
+
band: BandId;
|
|
49
72
|
rank: number;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
81
|
+
export declare function describeCatalog(): CatalogDescription;
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { EVENT_PROMPT_REGISTRY } from "./event-registry.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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, "
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
lines.push(`
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
34
|
+
export function describeCatalog() {
|
|
30
35
|
return {
|
|
31
|
-
|
|
32
|
-
roleBaseText:
|
|
33
|
-
sections: [...
|
|
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
|
}
|