@sema-agent/core 7.51.2 → 7.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +698 -2
- package/README.md +3 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -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/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +8 -1
- package/dist/agents/read-inbox-tool.js +5 -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 +3 -0
- package/dist/agents/subagent.js +105 -76
- package/dist/agents/tool-filter.d.ts +58 -13
- package/dist/agents/tool-filter.js +34 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +17 -13
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +6 -5
- 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 +123 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +42 -9
- package/dist/core/allow-entry.js +25 -18
- package/dist/core/auto-compaction.d.ts +80 -20
- package/dist/core/auto-compaction.js +65 -18
- 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 +57 -24
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/compliance.js +3 -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/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +49 -21
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +8 -25
- package/dist/core/gate-lanes.js +358 -274
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +12 -3
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +283 -739
- package/dist/core/hooks.js +100 -193
- 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 +84 -32
- package/dist/core/locked-config.js +128 -42
- 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 +3 -3
- package/dist/core/mcp-server-spec.d.ts +104 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +31 -20
- package/dist/core/mcp.js +66 -56
- 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 +22 -30
- package/dist/core/memory-engine/engine.js +16 -10
- 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 +5 -16
- package/dist/core/mode-policy.js +7 -19
- 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 +699 -0
- package/dist/core/mods/kernel/events.d.ts +245 -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 +94 -0
- package/dist/core/mods/kernel/receive.js +188 -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 +149 -0
- package/dist/core/mods/kernel/site-rules.js +296 -0
- package/dist/core/mods/stations.d.ts +344 -0
- package/dist/core/mods/stations.js +437 -0
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +13 -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-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- 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 +14 -2
- package/dist/core/permission-rules.js +63 -23
- 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/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +12 -2
- package/dist/core/retired-keys.js +15 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- 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 +86 -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 +12 -5
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- 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/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +3 -2
- 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 +52 -1
- package/dist/core/runner/prepare-config-doors.js +168 -143
- package/dist/core/runner/prepare-defer-classify.js +7 -11
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- 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-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +10 -23
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +20 -7
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +104 -109
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +11 -12
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +138 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
- package/dist/core/runner/prepare-prompt-inputs.js +11 -10
- package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
- package/dist/core/runner/prepare-protocol-tools.js +20 -13
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- 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 +41 -23
- 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 +13 -9
- package/dist/core/runner/prepare-wiring-manifest.js +14 -11
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- 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-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +4 -5
- 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 +103 -95
- 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 +14 -11
- 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 +34 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +32 -37
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +15 -73
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- 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/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -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 +124 -23
- package/dist/core/runner/sub-agent-deny-lists.js +230 -71
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- 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 +43 -36
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +71 -16
- package/dist/core/session-policy-store.js +138 -28
- 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/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +49 -3
- package/dist/core/task-notification.js +2 -2
- 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 +62 -18
- package/dist/core/tool-policy.js +86 -15
- 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 -2
- package/dist/core/types.js +1 -1
- 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/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +25 -4
- package/dist/core/user-attachment.js +63 -42
- package/dist/core/wiring-manifest.d.ts +18 -15
- 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 +5 -4
- package/dist/engine/harness/types.d.ts +20 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +18 -6
- package/dist/engine/loop/types.d.ts +8 -2
- 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 +33 -23
- package/dist/index.js +23 -15
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +2 -1
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- 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 +72 -56
- package/dist/prompt-assembly/artifact-store.js +60 -52
- package/dist/prompt-assembly/artifact.d.ts +90 -76
- package/dist/prompt-assembly/artifact.js +197 -145
- package/dist/prompt-assembly/assemble.d.ts +36 -29
- package/dist/prompt-assembly/assemble.js +34 -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 +60 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -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 +138 -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 +26 -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 +137 -0
- package/dist/prompt-assembly/overlay.js +339 -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 +71 -0
- package/dist/prompt-assembly/select.js +106 -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 -511
- package/dist/prompts/default.js +20 -288
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -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 +306 -103
- package/wire-changes/core@7.52.0.json +5859 -0
- package/wire-changes/core@7.53.0.json +1946 -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
|
@@ -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
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type BandId, type CatalogSection, type OverlayOp, type OverlaySource, type VariantWhen } from "./catalog/schema.js";
|
|
2
|
+
/** One overlay: an operation on a target, carrying text (or a catalog message reference). */
|
|
3
|
+
export interface PromptOverlay {
|
|
4
|
+
/** `<namespace>/<name>`; the `core/` namespace is the task sugar's alone. Names an added entry. */
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly op: OverlayOp;
|
|
7
|
+
/** A message id (`replace` / `append`), a band id (`add`), or a section / added-entry id (`drop`). */
|
|
8
|
+
readonly target: string;
|
|
9
|
+
/** The overlay's text (`replace` / `append` / `add`); exclusive with `message`. */
|
|
10
|
+
readonly text?: string;
|
|
11
|
+
/** A catalog message whose selected variant is the overlay's text; exclusive with `text`. */
|
|
12
|
+
readonly message?: string;
|
|
13
|
+
/** The overlay applies to this run only when this holds (the variant selector's own vocabulary, the binding
|
|
14
|
+
* included) — the one applicability condition of every source class. */
|
|
15
|
+
readonly when?: VariantWhen;
|
|
16
|
+
}
|
|
17
|
+
/** The source classes in application order (later wins). `bundled` is the catalog itself and writes no overlay. */
|
|
18
|
+
export declare const OVERLAY_SOURCE_ORDER: readonly ["bundled", "task", "center", "deploy"];
|
|
19
|
+
/** Who contributed an overlay: its source class and, within it, the contributor (`sugar`, a mods registration, the center). */
|
|
20
|
+
export interface OverlayOrigin {
|
|
21
|
+
readonly source: OverlaySource;
|
|
22
|
+
readonly by: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SourcedOverlay {
|
|
25
|
+
readonly overlay: PromptOverlay;
|
|
26
|
+
readonly origin: OverlayOrigin;
|
|
27
|
+
}
|
|
28
|
+
/** An overlay a later one on the same target overrode (or a drop removed), or one that changed nothing this run. */
|
|
29
|
+
export interface SupersededOverlay {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly source: OverlaySource;
|
|
32
|
+
readonly by: string;
|
|
33
|
+
readonly target: string;
|
|
34
|
+
/** The overlay id that won, or {@link ABSENT_THIS_RUN}. */
|
|
35
|
+
readonly supersededBy: string;
|
|
36
|
+
}
|
|
37
|
+
/** `supersededBy` of an overlay that changed nothing this run: the selector chose no variant of its target, or of
|
|
38
|
+
* the catalog message it takes its text from. */
|
|
39
|
+
export declare const ABSENT_THIS_RUN = "(absent this run)";
|
|
40
|
+
/** The section a message id is placed by, when the catalog places it. */
|
|
41
|
+
export declare function sectionOfMessage(id: string): CatalogSection | undefined;
|
|
42
|
+
export interface LockedEntry {
|
|
43
|
+
readonly message: string;
|
|
44
|
+
readonly variant: string;
|
|
45
|
+
readonly text: string;
|
|
46
|
+
}
|
|
47
|
+
/** Every constitution entry the guard compares: each message a constitution section places, every variant, whole. */
|
|
48
|
+
export declare function lockedEntries(): readonly LockedEntry[];
|
|
49
|
+
/** The constitution entries (`message#variant`) whose canonical text `text` contains verbatim. */
|
|
50
|
+
export declare function lockedTextIn(text: string): string[];
|
|
51
|
+
/** The task sugar's one violation: a role-layer text that carries locked text (an already-assembled prompt). */
|
|
52
|
+
export declare function assembledRoleRefused(field: string, hits: readonly string[]): Error;
|
|
53
|
+
/** Receive a source's prompt data ({@link PROMPT_DATA}): its frozen copy, or the clause naming what in it is not data. */
|
|
54
|
+
export declare function receivePromptData(raw: unknown): {
|
|
55
|
+
readonly value: unknown;
|
|
56
|
+
} | {
|
|
57
|
+
readonly notData: string;
|
|
58
|
+
};
|
|
59
|
+
/** The longest binding a task may name (`TaskSpec.promptBinding`), counted in Unicode code points (`[...s].length`) — not
|
|
60
|
+
* in UTF-16 code units; every binding a `when.binding` list names is held to the same bound. Exported so a host screens
|
|
61
|
+
* with the engine's number and the engine's unit. Code points are the one unit of every character bound of the prompt
|
|
62
|
+
* artifact verifier ({@link codePointsOver}: a binding, an overlay id, `sourceRevision`, `evidence.intent`, a
|
|
63
|
+
* reference), so a character outside the BMP (an emoji, a rare CJK ideograph) counts one, not two; the overlay text
|
|
64
|
+
* budgets are UTF-8 bytes and are named so. */
|
|
65
|
+
export declare const PROMPT_BINDING_MAX_CHARS = 128;
|
|
66
|
+
/** The most bindings one `when.binding` list names — it bounds what a publisher can make the conflict check walk. */
|
|
67
|
+
export declare const PROMPT_BINDING_LIST_MAX = 64;
|
|
68
|
+
/** Whether `s` holds more than `max` Unicode code points — the one length unit of the prompt artifact verifier's
|
|
69
|
+
* character bounds. A string of at most `max` code units fits (a code point is one or two of them); one of more than
|
|
70
|
+
* twice `max` does not; only a string in between is counted — counted, never copied whole. */
|
|
71
|
+
export declare function codePointsOver(s: string, max: number): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The run's binding (`TaskSpec.promptBinding`): the scenario a `when.binding` condition reads, on an overlay of any
|
|
74
|
+
* source class. Its one writer is the task (a deployment names its scenario); absent ⇒ undefined. A value outside the
|
|
75
|
+
* grammar is refused by name (`config.prompt_selector_invalid`), never read as absent.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolvePromptBinding(task: {
|
|
78
|
+
readonly promptBinding?: unknown;
|
|
79
|
+
}): string | undefined;
|
|
80
|
+
/** What a validation needs besides the overlay: its source class, which mods event (if any) carries it, and the
|
|
81
|
+
* entries lower classes added (the only entries a `drop` may name besides a built-in section). */
|
|
82
|
+
export interface OverlayValidationContext {
|
|
83
|
+
readonly source: OverlaySource;
|
|
84
|
+
/** The mods event the overlay arrived on; absent for the sugar and the center. */
|
|
85
|
+
readonly event?: "prompt.compose";
|
|
86
|
+
/** The request-body sugar may use the `core/` namespace; nothing else may. */
|
|
87
|
+
readonly sugar?: boolean;
|
|
88
|
+
/** Ids of entries lower source classes added (`add`) and the band each landed in. */
|
|
89
|
+
readonly lowerAdds?: ReadonlyMap<string, BandId>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate one overlay for one source class. Returns the overlay (a frozen copy of its known members, its `when` in
|
|
93
|
+
* normal form — {@link canonicalWhen}) or why it is a violation: shape, namespace, op, text/message, `when`, target existence, band authorization (and the band's mods
|
|
94
|
+
* write port), and the locked-text guard.
|
|
95
|
+
*/
|
|
96
|
+
export declare function validateOverlay(raw: unknown, ctx: OverlayValidationContext): {
|
|
97
|
+
readonly overlay: PromptOverlay;
|
|
98
|
+
} | {
|
|
99
|
+
readonly violation: string;
|
|
100
|
+
};
|
|
101
|
+
/** One added entry as the fold leaves it. */
|
|
102
|
+
export interface AddedEntry {
|
|
103
|
+
readonly id: string;
|
|
104
|
+
readonly band: BandId;
|
|
105
|
+
readonly rank: number;
|
|
106
|
+
readonly text: string;
|
|
107
|
+
readonly origin: OverlayOrigin;
|
|
108
|
+
}
|
|
109
|
+
/** One overlay in a section's history, in application order; `superseded` once a later one overrode it. The
|
|
110
|
+
* composition puts the catalog's own text (`bundled`) first for a catalog section. */
|
|
111
|
+
export interface ChainLink {
|
|
112
|
+
readonly source: "bundled" | OverlaySource;
|
|
113
|
+
readonly overlay?: string;
|
|
114
|
+
readonly op?: OverlayOp;
|
|
115
|
+
readonly superseded?: true;
|
|
116
|
+
}
|
|
117
|
+
/** The fold's result: per-message text the overlays set, dropped sections, added entries, superseded overlays. */
|
|
118
|
+
export interface OverlayFold {
|
|
119
|
+
/** Message id → its text after the overlays (absent ⇒ the selected variant's text stands). */
|
|
120
|
+
readonly messageText: ReadonlyMap<string, {
|
|
121
|
+
readonly text: string;
|
|
122
|
+
readonly origin: OverlayOrigin;
|
|
123
|
+
readonly replaced: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
/** Built-in section ids a drop removed. */
|
|
126
|
+
readonly dropped: ReadonlySet<string>;
|
|
127
|
+
readonly added: readonly AddedEntry[];
|
|
128
|
+
readonly superseded: readonly SupersededOverlay[];
|
|
129
|
+
/** Section id (or added-entry id) → the overlays applied to it, in order, superseded ones marked. */
|
|
130
|
+
readonly chains: ReadonlyMap<string, readonly ChainLink[]>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Apply sourced overlays, already validated and already in application order, over the selected texts.
|
|
134
|
+
* `selectedText(messageId)` answers the text the selector chose (undefined ⇒ the message is absent this run);
|
|
135
|
+
* `applies(overlay)` answers its `when`.
|
|
136
|
+
*/
|
|
137
|
+
export declare function foldOverlays(ordered: readonly SourcedOverlay[], selectedText: (messageId: string) => string | undefined, applies: (o: PromptOverlay) => boolean, overlayText: (o: PromptOverlay) => string | undefined): OverlayFold;
|