@sema-agent/core 5.20.0 → 5.21.1
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 +19 -0
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-transcript-tool.d.ts +30 -0
- package/dist/agents/builtin-agents.d.ts +60 -0
- package/dist/agents/cascade.d.ts +107 -0
- package/dist/agents/cumulative-stats.d.ts +56 -0
- package/dist/agents/observer.d.ts +162 -0
- package/dist/agents/peer-admission.d.ts +95 -0
- package/dist/agents/repair-loop.d.ts +226 -0
- package/dist/agents/retain-ledger.d.ts +141 -0
- package/dist/agents/roster-store.d.ts +105 -0
- package/dist/agents/send-message-tool.d.ts +92 -0
- package/dist/agents/session-util.d.ts +5 -0
- package/dist/agents/subagent-steps.d.ts +66 -0
- package/dist/agents/subagent.d.ts +600 -0
- package/dist/agents/suspend-guard.d.ts +29 -0
- package/dist/agents/teacher.d.ts +75 -0
- package/dist/agents/team.d.ts +120 -1
- package/dist/agents/tool-filter.d.ts +34 -0
- package/dist/agents/verify.d.ts +198 -0
- package/dist/bench/metrics.d.ts +455 -0
- package/dist/brain/anthropic.d.ts +30 -0
- package/dist/brain/circuit-breaker.d.ts +33 -0
- package/dist/brain/context-overflow.d.ts +60 -3
- package/dist/brain/degrading.d.ts +67 -0
- package/dist/brain/errors.d.ts +42 -0
- package/dist/brain/failover.d.ts +15 -0
- package/dist/brain/media-degrade.d.ts +39 -0
- package/dist/brain/model-presets.d.ts +31 -0
- package/dist/brain/open-responses.d.ts +19 -0
- package/dist/brain/openai.d.ts +46 -0
- package/dist/brain/reasoning.d.ts +106 -1
- package/dist/brain/repetition.d.ts +83 -0
- package/dist/brain/request-params.d.ts +56 -0
- package/dist/brain/retry.d.ts +46 -0
- package/dist/brain/routing.d.ts +12 -0
- package/dist/brain/status-sink.d.ts +30 -1
- package/dist/brain/stream-engine.d.ts +147 -0
- package/dist/brain/stream-shared.d.ts +34 -0
- package/dist/brain/terminal-cause.d.ts +31 -0
- package/dist/brain/timeout.d.ts +107 -0
- package/dist/brain/tool-call-id.d.ts +20 -0
- package/dist/brain/tool-call-repair.d.ts +13 -0
- package/dist/config/catalog.d.ts +47 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/core/a2a-task-state.d.ts +53 -0
- package/dist/core/a2a.d.ts +51 -0
- package/dist/core/arg-summary.d.ts +62 -0
- package/dist/core/ask-question.d.ts +272 -2
- package/dist/core/auto-compaction.d.ts +467 -0
- package/dist/core/auto-compaction.js +20 -6
- package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
- package/dist/core/auto-mode-prompt.d.ts +27 -0
- package/dist/core/auto-mode.d.ts +54 -3
- package/dist/core/auto-promote.d.ts +100 -0
- package/dist/core/background-agent-store.d.ts +292 -0
- package/dist/core/background-shell.d.ts +110 -0
- package/dist/core/cache-break-detector.d.ts +34 -0
- package/dist/core/canonical-json.d.ts +57 -0
- package/dist/core/checkpoint-store.d.ts +1574 -16
- package/dist/core/compliance.d.ts +30 -0
- package/dist/core/consolidate-scope.d.ts +75 -0
- package/dist/core/context-edit.d.ts +99 -0
- package/dist/core/context-guard.d.ts +46 -0
- package/dist/core/exec-gate.d.ts +44 -0
- package/dist/core/exec-output-tail.d.ts +61 -0
- package/dist/core/file-snapshot-store.d.ts +104 -0
- package/dist/core/fs-write-gate-policy.d.ts +36 -0
- package/dist/core/git-worktree-env.d.ts +31 -0
- package/dist/core/governance-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +608 -1
- package/dist/core/human-input-projection.d.ts +37 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/image-downsample.d.ts +74 -0
- package/dist/core/locked-config.d.ts +37 -0
- package/dist/core/lsp-diagnostics.d.ts +77 -0
- package/dist/core/lsp-protocol.d.ts +29 -0
- package/dist/core/lsp-session.d.ts +60 -1
- package/dist/core/lsp.d.ts +150 -1
- package/dist/core/mailbox-store.d.ts +57 -0
- package/dist/core/mcp.d.ts +381 -0
- package/dist/core/media-byte-cap.d.ts +21 -0
- package/dist/core/memory-admission.d.ts +71 -0
- package/dist/core/memory-engine/content-origin.d.ts +64 -0
- package/dist/core/memory-engine/data-plane.d.ts +43 -0
- package/dist/core/memory-engine/dual-root.d.ts +24 -0
- package/dist/core/memory-engine/engine.d.ts +230 -0
- package/dist/core/memory-engine/engine.js +103 -35
- package/dist/core/memory-engine/file-backend.d.ts +155 -0
- package/dist/core/memory-engine/frontmatter.d.ts +16 -0
- package/dist/core/memory-engine/layout.d.ts +217 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
- package/dist/core/memory-engine/migrate.d.ts +9 -0
- package/dist/core/memory-engine/scan.d.ts +12 -0
- package/dist/core/memory-engine/scope-contract.d.ts +61 -1
- package/dist/core/memory-engine/sync-client.d.ts +87 -0
- package/dist/core/memory-engine/sync.d.ts +60 -0
- package/dist/core/memory-engine/tools.d.ts +41 -0
- package/dist/core/memory-engine/types.d.ts +188 -0
- package/dist/core/memory-recall.d.ts +141 -0
- package/dist/core/memory-vector.d.ts +20 -0
- package/dist/core/memory.d.ts +458 -0
- package/dist/core/message-utils.d.ts +6 -0
- package/dist/core/oracle-isolation.d.ts +69 -0
- package/dist/core/permission-rule-consent.d.ts +138 -0
- package/dist/core/permission-rule-model.d.ts +122 -0
- package/dist/core/permission-rule-store.d.ts +119 -3
- package/dist/core/permission-rules.d.ts +87 -1
- package/dist/core/present-plan-tool.d.ts +20 -0
- package/dist/core/pricing.d.ts +26 -0
- package/dist/core/property-harness.d.ts +86 -0
- package/dist/core/protocol-naming.d.ts +38 -0
- package/dist/core/protocol-table.d.ts +61 -0
- package/dist/core/push-queue.d.ts +1 -0
- package/dist/core/remote-env.d.ts +383 -1
- package/dist/core/retention-policy.d.ts +33 -0
- package/dist/core/retention.d.ts +51 -0
- package/dist/core/roles.d.ts +59 -0
- package/dist/core/runner/active-skill-scope.d.ts +34 -0
- package/dist/core/runner/assemble-result.d.ts +134 -0
- package/dist/core/runner/compaction-call-options.d.ts +97 -1
- package/dist/core/runner/grounding-signal.d.ts +10 -0
- package/dist/core/runner/image.d.ts +17 -0
- package/dist/core/runner/image.js +29 -15
- package/dist/core/runner/memory-consolidation.d.ts +60 -0
- package/dist/core/runner/prepare-memory.d.ts +59 -0
- package/dist/core/runner/prepare-task.d.ts +1011 -2
- package/dist/core/runner/prepare-task.js +12 -11
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/session-file-state-replay.d.ts +49 -0
- package/dist/core/runner/session-rule-policy.d.ts +58 -0
- package/dist/core/runner/strict-output-schema.d.ts +18 -3
- package/dist/core/runner/synthetic-tools.d.ts +113 -0
- package/dist/core/runner/teardown-bounded.d.ts +34 -0
- package/dist/core/runner/tool-disclosure.d.ts +227 -0
- package/dist/core/runner/tool-output-projection.d.ts +6 -0
- package/dist/core/runner/turn-attachments.d.ts +634 -0
- package/dist/core/runner/usage-accounting.d.ts +32 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/safe-notify.d.ts +64 -0
- package/dist/core/safety-axis-vocab.d.ts +23 -0
- package/dist/core/safety-merge-corpus.d.ts +37 -0
- package/dist/core/scheduler.d.ts +121 -0
- package/dist/core/secret-env.d.ts +32 -0
- package/dist/core/select-model.d.ts +15 -0
- package/dist/core/sensitive-path-policy.d.ts +42 -0
- package/dist/core/session-policy-store.d.ts +94 -0
- package/dist/core/session-reconcile.d.ts +80 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session.d.ts +153 -0
- package/dist/core/shared-memory/contract.d.ts +22 -0
- package/dist/core/shared-memory/normalize.d.ts +123 -2
- package/dist/core/shared-memory/tools.d.ts +14 -0
- package/dist/core/shared-memory/types.d.ts +105 -0
- package/dist/core/shutdown-debug.d.ts +6 -0
- package/dist/core/side-query.d.ts +38 -0
- package/dist/core/side-query.js +6 -1
- package/dist/core/skill-tool-specifier.d.ts +72 -0
- package/dist/core/skills-directory.d.ts +100 -1
- package/dist/core/spec-contract.d.ts +89 -0
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
- package/dist/core/store-contracts/contract-harness.d.ts +20 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
- package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
- package/dist/core/strategy-store.d.ts +37 -0
- package/dist/core/stub-env.d.ts +7 -0
- package/dist/core/surrogate-safe-slice.d.ts +35 -0
- package/dist/core/task-notification.d.ts +202 -0
- package/dist/core/task-outcome.d.ts +53 -0
- package/dist/core/task-registry-agent.d.ts +337 -1
- package/dist/core/task-registry-monitor.d.ts +12 -0
- package/dist/core/task-registry-shared.d.ts +540 -0
- package/dist/core/task-registry.d.ts +343 -0
- package/dist/core/task-registry.js +13 -2
- package/dist/core/task-tool-shape.d.ts +44 -0
- package/dist/core/tighten-task-spec.d.ts +21 -0
- package/dist/core/tool-detach.d.ts +21 -0
- package/dist/core/tool-errors.d.ts +131 -0
- package/dist/core/tool-errors.js +4 -0
- package/dist/core/tool-name-aliases.d.ts +27 -0
- package/dist/core/tool-policy.d.ts +555 -0
- package/dist/core/tool-result-budget.d.ts +32 -0
- package/dist/core/tool-result-store.d.ts +174 -1
- package/dist/core/tools.d.ts +45 -0
- package/dist/core/trace.d.ts +323 -0
- package/dist/core/types.d.ts +3859 -2
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-text.d.ts +156 -0
- package/dist/core/usage-window-store.d.ts +95 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/warm-resume.d.ts +17 -0
- package/dist/core/wiring-manifest.d.ts +169 -0
- package/dist/core/with-retry.d.ts +24 -0
- package/dist/core/workflow-journal-store.d.ts +160 -0
- package/dist/core/workflow-run-store-contract.d.ts +25 -0
- package/dist/core/workflow-run-store.d.ts +119 -0
- package/dist/engine/compaction/compaction.d.ts +256 -1
- package/dist/engine/compaction/utils.d.ts +94 -0
- package/dist/engine/execution-env/kill-tree.d.ts +29 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
- package/dist/engine/harness/agent-harness.d.ts +116 -0
- package/dist/engine/harness/agent-harness.js +3 -14
- package/dist/engine/harness/messages.d.ts +15 -0
- package/dist/engine/harness/types.d.ts +464 -2
- package/dist/engine/llm/diagnostics.d.ts +4 -0
- package/dist/engine/llm/event-stream.d.ts +3 -0
- package/dist/engine/llm/index.d.ts +7 -0
- package/dist/engine/llm/types.d.ts +500 -3
- package/dist/engine/llm/validation.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +87 -2
- package/dist/engine/loop/runtime-deps.d.ts +7 -0
- package/dist/engine/loop/types.d.ts +424 -0
- package/dist/engine/lsp/frame-decoder.d.ts +13 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
- package/dist/engine/session/import-validate.d.ts +27 -0
- package/dist/engine/session/log-digest.d.ts +93 -0
- package/dist/engine/session/memory-repo.d.ts +6 -0
- package/dist/engine/session/memory-storage.d.ts +2 -0
- package/dist/engine/session/session.d.ts +75 -0
- package/dist/engine/session/storage-base.d.ts +8 -0
- package/dist/fixtures/index.d.ts +36 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +0 -1
- package/dist/internal/harness-types.d.ts +6 -0
- package/dist/internal/harness.d.ts +11 -0
- package/dist/internal/llm.d.ts +6 -0
- package/dist/orchestration/builtin-workflows.d.ts +53 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
- package/dist/orchestration/goal.d.ts +57 -0
- package/dist/orchestration/goal.js +3 -0
- package/dist/orchestration/run-spec.d.ts +42 -0
- package/dist/orchestration/run-workflow-tool.d.ts +169 -0
- package/dist/orchestration/workflow-governance.d.ts +61 -0
- package/dist/orchestration/workflow-meta.d.ts +28 -0
- package/dist/orchestration/workflow-observe.d.ts +60 -0
- package/dist/orchestration/workflow-primitives.d.ts +23 -1
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
- package/dist/orchestration/workflow-script-runner.d.ts +88 -0
- package/dist/orchestration/workflow-script-store.d.ts +98 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
- package/dist/orchestration/workflow-types.d.ts +169 -2
- package/dist/orchestration/workflow.d.ts +358 -0
- package/dist/prompt-assembly/artifact-store.d.ts +33 -0
- package/dist/prompt-assembly/artifact.d.ts +25 -0
- package/dist/prompt-assembly/assemble.d.ts +20 -0
- package/dist/prompt-assembly/composer.d.ts +29 -0
- package/dist/prompt-assembly/epoch.d.ts +55 -1
- package/dist/prompt-assembly/event-registry.d.ts +35 -0
- package/dist/prompt-assembly/explain.d.ts +12 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
- package/dist/prompt-assembly/types.d.ts +115 -0
- package/dist/prompts/coordinator.d.ts +27 -0
- package/dist/prompts/default.d.ts +539 -0
- package/dist/prompts/simple-sections.d.ts +45 -0
- package/dist/prompts/supervisor.d.ts +66 -0
- package/dist/scenarios/env.d.ts +28 -0
- package/dist/scenarios/full-body.d.ts +50 -0
- package/dist/scenarios/scenario-registry.d.ts +60 -0
- package/dist/scenarios/teacher-quickstart.d.ts +27 -0
- package/dist/server/http.d.ts +17 -0
- package/dist/stores/cc/lockfile.d.ts +6 -0
- package/dist/stores/cc/mailbox-store.d.ts +8 -0
- package/dist/stores/cc/roster-adapter.d.ts +4 -0
- package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
- package/dist/stores/file/background-agent-store.d.ts +24 -0
- package/dist/stores/file/checkpoint-store.d.ts +38 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/fs-atomic.d.ts +155 -0
- package/dist/stores/file/index.d.ts +89 -0
- package/dist/stores/file/mailbox-store.d.ts +36 -0
- package/dist/stores/file/memory-store.d.ts +82 -0
- package/dist/stores/file/permission-rule-store.d.ts +79 -0
- package/dist/stores/file/session-policy-store.d.ts +28 -0
- package/dist/stores/file/session-store.d.ts +40 -0
- package/dist/stores/file/shared-ledger.d.ts +83 -0
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/usage-window-store.d.ts +18 -0
- package/dist/stores/file/workflow-journal-store.d.ts +100 -0
- package/dist/stores/file/workflow-run-store.d.ts +11 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
- package/dist/tools/fs/encoding.d.ts +60 -0
- package/dist/tools/fs/fs-bash.d.ts +133 -0
- package/dist/tools/fs/fs-pdf.d.ts +28 -0
- package/dist/tools/fs/fs-search-tools.d.ts +5 -0
- package/dist/tools/fs/fs-search-tools.js +0 -1
- package/dist/tools/fs/fs-shared.d.ts +360 -0
- package/dist/tools/fs/fs-write.d.ts +16 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
- package/dist/tools/fs/index.d.ts +79 -0
- package/dist/tools/fs/notebook.d.ts +56 -0
- package/dist/tools/fs/pdf.d.ts +70 -0
- package/dist/tools/fs/pdf.js +8 -2
- package/dist/tools/fs/repo-map.d.ts +10 -0
- package/dist/tools/fs/safety.d.ts +376 -0
- package/dist/tools/fs/search.d.ts +131 -0
- package/dist/tools/loop-tick.d.ts +24 -0
- package/dist/tools/monitor.d.ts +55 -0
- package/dist/tools/scheduler-tools.d.ts +51 -0
- package/dist/tools/sql-adapters.d.ts +18 -0
- package/dist/tools/sql.d.ts +25 -0
- package/dist/tools/task-list.d.ts +77 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/web.d.ts +184 -0
- package/dist/tools/worktree.d.ts +81 -0
- package/package.json +2 -2
- package/dist/tools/gitea-issue.d.ts +0 -13
- package/dist/tools/gitea-issue.js +0 -75
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { PromptTextDeclaration } from "../prompts/default.js";
|
|
2
|
+
/** v1 overlay slots — the same reserved rank bands the stableBlocks lane mounts into. */
|
|
2
3
|
export type CenterOverlaySlot = "identity" | "scenario" | "behavior";
|
|
3
4
|
export interface CenterOverlaySection {
|
|
5
|
+
/** Same grammar as stableBlocks ids (manifest/trace/explain-safe, never `core/`). */
|
|
4
6
|
id: string;
|
|
5
7
|
slot: CenterOverlaySlot;
|
|
8
|
+
/** Immutable rendered text (v1: fixed text, no renderer — center compiles before publishing). */
|
|
6
9
|
text: string;
|
|
10
|
+
/** REQUIRED on the center lane (unlike caller stableBlocks): sha256 of `text`. The center
|
|
11
|
+
* publish path always mints it — it is the reconciliation anchor ([1050]② tiering). */
|
|
7
12
|
contentHash: string;
|
|
8
13
|
}
|
|
9
14
|
export interface PromptCatalogSnapshot {
|
|
15
|
+
/** Center pack identity, e.g. "center:acme@3". Logical name only — history identity is digests. */
|
|
10
16
|
packId: string;
|
|
11
17
|
sections: ReadonlyArray<CenterOverlaySection>;
|
|
12
18
|
}
|
|
13
19
|
export interface PromptDependencyClosure {
|
|
20
|
+
/** v1: only the bundled base is a legal foundation (exact-archive multi-base = later slice). */
|
|
14
21
|
basePackId: string;
|
|
15
22
|
promptCatalog: PromptCatalogSnapshot;
|
|
16
23
|
}
|
|
24
|
+
/** Dependency-free core-compat range: dotted-triple compares, absent bound = unbounded. */
|
|
17
25
|
export interface CoreCompatRange {
|
|
18
26
|
minCore?: string;
|
|
19
27
|
maxCoreExclusive?: string;
|
|
@@ -29,10 +37,16 @@ export interface PromptEpochArtifact {
|
|
|
29
37
|
payload: PromptEpochArtifactPayload;
|
|
30
38
|
artifactDigest: string;
|
|
31
39
|
}
|
|
40
|
+
/** The publish envelope (§9.2): artifact + opaque source provenance. Attestation = later slice
|
|
41
|
+
* (protocol: first phase does not require full PKI for internal artifacts). */
|
|
32
42
|
export interface PublishedPromptArtifactEnvelope {
|
|
33
43
|
artifact: PromptEpochArtifact;
|
|
44
|
+
/** Opaque ETag-like revision. State transitions key off "last successfully verified response";
|
|
45
|
+
* NEVER ordered or compared for recency. */
|
|
34
46
|
sourceRevision: string;
|
|
35
47
|
}
|
|
48
|
+
/** Validator hard limits (§9.2: sections/bytes caps so a hostile or runaway publish cannot wedge
|
|
49
|
+
* the composer). Deliberately generous — these bound abuse, not legitimate catalogs. */
|
|
36
50
|
export declare const ARTIFACT_LIMITS: {
|
|
37
51
|
readonly maxSections: 64;
|
|
38
52
|
readonly maxSectionBytes: 32000;
|
|
@@ -51,10 +65,21 @@ export type ArtifactVerifyResult = {
|
|
|
51
65
|
code: string;
|
|
52
66
|
reason: string;
|
|
53
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Full §9.2 verify pipeline over an UNTRUSTED envelope (network body or disk bytes — the store
|
|
70
|
+
* re-verifies on read; nothing on disk is trusted by location). Every arm is a distinct coded
|
|
71
|
+
* rejection so the source-state machine can log honestly. Verification is pure — no IO.
|
|
72
|
+
*/
|
|
54
73
|
export declare function verifyPromptArtifact(raw: unknown, opts: {
|
|
55
74
|
engineVersion: string;
|
|
56
75
|
}): ArtifactVerifyResult;
|
|
76
|
+
/**
|
|
77
|
+
* Compile a VERIFIED artifact into the declaration lane (v1 adoption channel — see file header).
|
|
78
|
+
* Deterministic order: catalog order preserved (it entered the digest, so it is stable).
|
|
79
|
+
*/
|
|
57
80
|
export declare function artifactDeclarations(artifact: PromptEpochArtifact): PromptTextDeclaration[];
|
|
81
|
+
/** Test/fixture helper: build a correctly-digested envelope from plain sections (the shape a
|
|
82
|
+
* center's publish pipeline produces). Exported for tests and the fixture-center harness. */
|
|
58
83
|
export declare function buildPromptArtifactEnvelope(opts: {
|
|
59
84
|
packId: string;
|
|
60
85
|
sections: ReadonlyArray<{
|
|
@@ -3,6 +3,8 @@ import { type PromptProvider, type PromptTextDeclaration } from "../prompts/defa
|
|
|
3
3
|
import type { CompiledSection, CompiledSystemBlock, PromptRuntimeFacts } from "./types.js";
|
|
4
4
|
export interface AssembleInputs {
|
|
5
5
|
provider: PromptProvider;
|
|
6
|
+
/** True when the provider is the built-in defaultPromptProvider (checked FIRST — its stableSystem
|
|
7
|
+
* output contains the constitution anchors and would misroute through the M9 guard). */
|
|
6
8
|
isDefaultProvider: boolean;
|
|
7
9
|
userSystemPrompt?: string;
|
|
8
10
|
userAppendSystemPrompt?: string;
|
|
@@ -10,22 +12,40 @@ export interface AssembleInputs {
|
|
|
10
12
|
facts: PromptRuntimeFacts;
|
|
11
13
|
mcpInstructionsBlock?: string;
|
|
12
14
|
memoryBlock?: string;
|
|
15
|
+
/** Renders the environment tail for a given date (leg-frozen; date_change re-render seam). */
|
|
13
16
|
buildEnvBlock: (date: string) => string | undefined;
|
|
17
|
+
/** The leg's frozen date — the initial render input (design/66 date_change). */
|
|
14
18
|
date: string;
|
|
15
19
|
modelGuidance?: string;
|
|
20
|
+
/** design/148 S1 — declarations compiled from a VERIFIED center prompt artifact (the adoption
|
|
21
|
+
* channel: core verifies the artifact, synthesizes these, and they ride the same mount loop as
|
|
22
|
+
* provider stableBlocks — same manifest/epoch/contentHash faces, zero new assembly machinery).
|
|
23
|
+
* Mounted ahead of provider declarations on every COMPOSED path; the provider-assembled
|
|
24
|
+
* pass-through path cannot mount them (operator-visible warn, never silent). */
|
|
16
25
|
centerDeclarations?: PromptTextDeclaration[];
|
|
26
|
+
/** Structured warning channel (maps to deps.onError with a phase). */
|
|
17
27
|
onWarn?: (message: string, phase: "prompt-constitution") => void;
|
|
18
28
|
}
|
|
19
29
|
export interface AssembledPrompt {
|
|
20
30
|
constitution: "core" | "replaced" | "provider-assembled";
|
|
31
|
+
/** design/148 S1 (codex F3): true ⇔ the supplied centerDeclarations were actually COMPILED into
|
|
32
|
+
* this prompt. The caller must never persist a center pin when this is false — a pin that claims
|
|
33
|
+
* an artifact the model never received is a durable lie (the assembled-identity pass-through path
|
|
34
|
+
* warns + false). */
|
|
21
35
|
centerMounted?: boolean;
|
|
36
|
+
/** Re-render the full prompt for a date. */
|
|
22
37
|
renderWithDate?: (date: string) => string;
|
|
38
|
+
/** The initially-rendered system prompt. */
|
|
23
39
|
systemPrompt: string;
|
|
40
|
+
/** v1 `prompt.assembled` block view (id wordlist contract preserved). */
|
|
24
41
|
legacyBlocks: Array<{
|
|
25
42
|
id: string;
|
|
26
43
|
text: string;
|
|
27
44
|
}>;
|
|
45
|
+
/** Compiled IR of the last render — manifest v2 source. */
|
|
28
46
|
sections?: CompiledSection[];
|
|
47
|
+
/** S4: physical system blocks of the last render (sema-default: ONE block, text === systemPrompt —
|
|
48
|
+
* byte-identity). */
|
|
29
49
|
systemBlocks?: CompiledSystemBlock[];
|
|
30
50
|
}
|
|
31
51
|
export declare function assemblePrompt(inputs: AssembleInputs): AssembledPrompt;
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prompt Composer — the single deterministic assembly path (campaign S1; protocol §6).
|
|
3
|
+
*
|
|
4
|
+
* compose() is a pure function of (pack, inputs): validate → admit → render → join. The legacy
|
|
5
|
+
* date re-render seam (design/66 date_change) is expressed by re-running compose with a different
|
|
6
|
+
* `environmentBlock` — everything else stays byte-identical, so the prefix-cache property is
|
|
7
|
+
* preserved exactly as before (only the env tail differs between legs).
|
|
8
|
+
*
|
|
9
|
+
* Manifest duality: the compiled IR (sections, manifest-v2 source) coexists with the v1
|
|
10
|
+
* `prompt.assembled` block view — adjacent sections sharing a `legacyBlockId` merge into one
|
|
11
|
+
* legacy block (the harness.context composite), keeping the downstream id-wordlist contract
|
|
12
|
+
* intact (sentence-index #28).
|
|
13
|
+
*/
|
|
1
14
|
import type { CompiledSystemBlock, ComposedPrompt, PromptPack, SectionRenderInputs, SystemLayout } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Structural pack validation (protocol §14.1 negative cases — fail-loud, never a silent skip):
|
|
17
|
+
* duplicate section id, duplicate rank, empty id, or an unknown legacy joiner all reject the pack.
|
|
18
|
+
* Called once per pack instance (composePack callers may cache); cheap enough to run per compose.
|
|
19
|
+
*/
|
|
2
20
|
export declare function validatePack(pack: PromptPack): void;
|
|
21
|
+
/**
|
|
22
|
+
* Assemble the pack's system-prompt plane from prepare-frozen inputs. Sections emit in ascending
|
|
23
|
+
* rank (the pack-declared global order — slot NEVER drives physical order, see types.ts header).
|
|
24
|
+
*/
|
|
3
25
|
export declare function compose(pack: PromptPack, inputs: SectionRenderInputs): ComposedPrompt;
|
|
26
|
+
/** The implicit single-group layout — the legacy wire face (one system block, one cache span). */
|
|
4
27
|
export declare const SINGLE_BLOCK_LAYOUT: SystemLayout;
|
|
28
|
+
/**
|
|
29
|
+
* Route a composed prompt's sections into PHYSICAL system blocks per the layout (campaign S4).
|
|
30
|
+
* Sections keep their emission order; groups partition by rank range (routing never reorders —
|
|
31
|
+
* see types.ts header on slot interleaving). Empty groups are dropped. With SINGLE_BLOCK_LAYOUT
|
|
32
|
+
* the result is one block whose text === composed.text (byte-identity, golden-pinned).
|
|
33
|
+
*/
|
|
5
34
|
export declare function layoutSystemBlocks(composed: ComposedPrompt, layout?: SystemLayout): CompiledSystemBlock[];
|
|
@@ -1,31 +1,85 @@
|
|
|
1
1
|
import type { PromptPack } from "./types.js";
|
|
2
|
+
/** [1068] — the provider-declared sections of THIS run's resolved prompt (the `origin:"provider"`
|
|
3
|
+
* subset of the compiled IR), the declaration axis of the artifact identity.
|
|
4
|
+
*
|
|
5
|
+
* codex F6 (S1 round 2): declaration TEXT deliberately does NOT enter this shape — the epoch
|
|
6
|
+
* digest is a deterministic, unsalted value persisted in exportable session entries, and session
|
|
7
|
+
* readers do not see system prompts; hashing private text into it would be a dictionary-preimage
|
|
8
|
+
* surface (the exact class the salted prompt-manifest hashes exist to prevent). Identity instead
|
|
9
|
+
* rides `(id, slot, chars)` plus the declarer's OPT-IN `contentHash` (the digest-tiering value,
|
|
10
|
+
* already public by declaration): with contentHash — byte-precise re-pin detection (the center
|
|
11
|
+
* publish path always mints it); without — length-level detection only, documented degradation
|
|
12
|
+
* for private/forwarded text. */
|
|
2
13
|
export type EpochDeclaredSections = ReadonlyArray<{
|
|
3
14
|
id: string;
|
|
4
15
|
slot: string;
|
|
5
16
|
chars: number;
|
|
6
17
|
contentHash?: string;
|
|
7
18
|
}>;
|
|
19
|
+
/** How an epoch became active (protocol §9.2 descriptor field; `clear` arrives with a future
|
|
20
|
+
* first-class context_reset — v1 clear = new session = `session_start`). */
|
|
8
21
|
export type PromptEpochActivation = "session_start" | "compaction" | "legacy_migration";
|
|
22
|
+
/** The durable pin, persisted as a first-class session entry (root) and restated in every
|
|
23
|
+
* compaction entry's `details.promptEpoch` (same-CAS atomicity; bounded-tail recoverable). */
|
|
9
24
|
export interface PromptEpochDescriptor {
|
|
25
|
+
/** Monotonic per-session epoch counter (session_start = 1). */
|
|
10
26
|
epoch: number;
|
|
11
27
|
artifactDigest: string;
|
|
12
28
|
packId: string;
|
|
13
29
|
assemblyApi: number;
|
|
14
30
|
activatedBy: PromptEpochActivation;
|
|
31
|
+
/** design/148 S1 (additive provenance, present only on center-adopted pins): the VERIFIED center
|
|
32
|
+
* artifact this session composes from. `artifactDigest` above stays the computed
|
|
33
|
+
* bundled+declarations identity (the existing re-pin machinery); this field is what the resume
|
|
34
|
+
* path resolves through the artifact store — a miss is fail-loud (`prompt.snapshot_unavailable`),
|
|
35
|
+
* never a silent hybrid recompose (protocol §9.2). */
|
|
15
36
|
centerArtifactDigest?: string;
|
|
37
|
+
/** Opaque publish provenance of the adopted envelope (audit only — never enters any digest). */
|
|
16
38
|
sourceRevision?: string;
|
|
17
39
|
}
|
|
40
|
+
/** Deterministic canonical JSON (sorted keys) — shared identity encoding for the bundled-pack
|
|
41
|
+
* digest AND the center artifact digests (design/148 S1: one canonicalization, never two). */
|
|
18
42
|
export declare function canonical(node: unknown): string;
|
|
43
|
+
/**
|
|
44
|
+
* Bundled-pack artifact digest: canonical hash over the pack's structural declaration PLUS each
|
|
45
|
+
* section's probe-rendered content under the probe-fact vectors — all-off, all-on, and one
|
|
46
|
+
* single-axis-flipped vector per axis (content- and admission-binding, incl. single-gate mixed
|
|
47
|
+
* states). TOTALITY over the axes the pack forks on is the load-bearing property (see
|
|
48
|
+
* PROBE_FACTS_OFF/PROBE_FACTS_ON); it is pinned behaviourally by
|
|
49
|
+
* test/hardening-prompt-assembly.test.ts. Deterministic across processes and object insertion order;
|
|
50
|
+
* changes to any section's prose, admission behavior, or structure change the digest. Build version
|
|
51
|
+
* deliberately EXCLUDED (F3): a release that doesn't touch the pack keeps the same identity.
|
|
52
|
+
*/
|
|
19
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). */
|
|
20
60
|
export declare function mintSessionStartEpoch(pack: PromptPack, declared?: EpochDeclaredSections): PromptEpochDescriptor;
|
|
21
|
-
|
|
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?: {
|
|
22
69
|
centerArtifactDigest: string;
|
|
23
70
|
sourceRevision?: string;
|
|
24
71
|
} | {
|
|
25
72
|
clear: true;
|
|
26
73
|
}): PromptEpochDescriptor;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the session's pinned epoch against the CURRENT bundled artifact (v1 resolution).
|
|
76
|
+
* Returns the effective descriptor plus whether a legacy migration happened (pin from another
|
|
77
|
+
* build, or a pre-epoch session with no pin at all) — the caller records the migration entry.
|
|
78
|
+
*/
|
|
27
79
|
export declare function resolveEpochAgainstBundled(pinned: PromptEpochDescriptor | undefined, pack: PromptPack, declared?: EpochDeclaredSections): {
|
|
28
80
|
descriptor: PromptEpochDescriptor;
|
|
29
81
|
migrated: boolean;
|
|
30
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. */
|
|
31
85
|
export declare function normalizePromptEpoch(raw: unknown): PromptEpochDescriptor | undefined;
|
|
@@ -1,20 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event prompt registry (campaign S5; protocol §5.3) — the typed catalog of every runtime
|
|
3
|
+
* message-injection kind: its carrier, trust, dedupe semantics, byte budget and DEFAULT policy.
|
|
4
|
+
* Mechanism/copy separation: the registry owns the MECHANISM row (who fires, how it dedupes,
|
|
5
|
+
* where it rides); the render functions stay where they live (turn-attachments.ts / runtask.ts,
|
|
6
|
+
* next to their attribution comments — the S1 indexing posture). Behavior-zero slice: the rows
|
|
7
|
+
* below DESCRIBE the shipped behavior byte-for-byte; the default-policy matrix is consumed live
|
|
8
|
+
* by the run loop (single source for the M12 attachment-default carve-out).
|
|
9
|
+
*/
|
|
1
10
|
import type { PromptCarrier, PromptTrust } from "./types.js";
|
|
11
|
+
/** Dedupe/replay semantics of one event kind (protocol §5.3). */
|
|
2
12
|
export type EventDedupe = "once-per-epoch" | "once-per-run" | "replace-by-key" | "repeat";
|
|
13
|
+
/** Default mount policy (plan M12): `on` = fires unless explicitly disabled (the [c209-C] Q2
|
|
14
|
+
* carve-out pair — the listing frames are the ONLY roster/skills carrier); `off` = fires only
|
|
15
|
+
* when the task opts in (the 133 attachment-family constitution: new injection surfaces never
|
|
16
|
+
* disturb existing deployments by default); `always` = not policy-gated (mechanism lanes). */
|
|
3
17
|
export type EventDefaultPolicy = "on" | "off" | "always";
|
|
4
18
|
export interface CompiledEventPrompt {
|
|
19
|
+
/** Event kind — attachment kinds reuse the AttachmentSource wordlist verbatim. */
|
|
5
20
|
kind: string;
|
|
6
21
|
carrier: PromptCarrier;
|
|
7
22
|
trust: PromptTrust;
|
|
8
23
|
dedupe: EventDedupe;
|
|
24
|
+
/** Byte budget note: attachment kinds share the 8KB boundary cap (evidence-strength ordered);
|
|
25
|
+
* a per-kind number here is the kind's OWN clamp where one exists. */
|
|
9
26
|
maxBytes?: number;
|
|
10
27
|
defaultPolicy: EventDefaultPolicy;
|
|
28
|
+
/** Where the renderer lives (index, not a copy — attribution comments stay at the source). */
|
|
11
29
|
rendererRef: string;
|
|
12
30
|
}
|
|
31
|
+
/** The shipped registry. Rows mirror the live behavior exactly (S5 is formalization, not change):
|
|
32
|
+
* - carrier: every boundary attachment + first-frame listing rides the user turn wrapped in a
|
|
33
|
+
* single-point `<system-reminder>` shell (`message.user-prefix` on the first frame, user-turn
|
|
34
|
+
* steer afterwards — both are the user-prefix carrier class);
|
|
35
|
+
* - trust: bodies are engine-rendered (operator) except where the content embeds external text
|
|
36
|
+
* (mcp instructions — fenced/sanitized by the renderer, marked external);
|
|
37
|
+
* - defaultPolicy: the M12 matrix (runtask.ts attachment-config derivation, single-sourced here).
|
|
38
|
+
*/
|
|
13
39
|
export declare const EVENT_PROMPT_REGISTRY: ReadonlyMap<string, CompiledEventPrompt>;
|
|
40
|
+
/** The M12 default matrix, single-sourced: is this attachment kind on when the task supplies no
|
|
41
|
+
* `attachments` config? (Live consumer: the run loop's attachment-config derivation.) */
|
|
14
42
|
export declare function eventDefaultOn(kind: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* One compiled message injection (protocol §5.4; plan M7) — the provider-neutral unit the S4 turn
|
|
45
|
+
* snapshot will carry. Provenance fields are FIRST-CLASS (mirroring the shipped 1.301 metadata
|
|
46
|
+
* system verbatim — the consumers' stripping semantics are behavior-frozen): see
|
|
47
|
+
* `engine/llm/types.ts` UserMessage for the field-by-field contract.
|
|
48
|
+
*/
|
|
15
49
|
export interface CompiledMessageInjection {
|
|
16
50
|
kind: string;
|
|
17
51
|
carrier: PromptCarrier;
|
|
52
|
+
/** Inner body text — the `<system-reminder>` shell is added at the single delivery point (F3). */
|
|
18
53
|
body: string;
|
|
19
54
|
provenance?: {
|
|
20
55
|
enginePrefixChars?: number;
|
|
@@ -28,9 +28,20 @@ export interface ExplainInput {
|
|
|
28
28
|
activatedBy: string;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/** Render a `prompt.assembled` manifest (+ optional epoch pin) as a readable report. */
|
|
31
32
|
export declare function explainPromptAssembly(input: ExplainInput): string;
|
|
33
|
+
/**
|
|
34
|
+
* [1050]①d / [1051]③b — the CENTER-facing read-only description of the default pack: section
|
|
35
|
+
* metadata (id/slot/rank/ownership/locked) plus the default role-base TEXT (the append-mode
|
|
36
|
+
* compile skeleton the web UI prepends to a user's "Role details"). Deliberately NO other section
|
|
37
|
+
* texts (the [989] no-prompt-bodies observability line — structure yes, prose no; the role base is
|
|
38
|
+
* the one deliberate exception: it is the public compile input of the append mode, and its text is
|
|
39
|
+
* this open repo's DEFAULT_SYSTEM_PROMPT). Programmatic — a static copy in the web tier would
|
|
40
|
+
* silently drift the moment core's default prompt changes ([1049]①d 禁静态拷贝).
|
|
41
|
+
*/
|
|
32
42
|
export interface DefaultPackDescription {
|
|
33
43
|
packId: string;
|
|
44
|
+
/** The pack-default role base (append-mode skeleton). */
|
|
34
45
|
roleBaseText: string;
|
|
35
46
|
sections: Array<{
|
|
36
47
|
id: string;
|
|
@@ -39,6 +50,7 @@ export interface DefaultPackDescription {
|
|
|
39
50
|
owner: string;
|
|
40
51
|
trust: string;
|
|
41
52
|
mutability: string;
|
|
53
|
+
/** True ⇒ not deployment-writable (the UI shows the platform-managed indicator, never an editor). */
|
|
42
54
|
locked: boolean;
|
|
43
55
|
}>;
|
|
44
56
|
}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
import type { TSchema } from "typebox";
|
|
2
2
|
import type { AgentTool } from "../internal/harness-types.js";
|
|
3
3
|
import type { ProtocolId } from "../core/protocol-table.js";
|
|
4
|
+
/** The protocol slice comes from the protocol table — adding a protocol extends ProtocolId and this
|
|
5
|
+
* union follows automatically (the origin projection is table-driven, prepare-task). */
|
|
4
6
|
export type ToolOrigin = "core" | "caller" | "synthetic" | ProtocolId;
|
|
5
7
|
export interface ToolContractDescriptor {
|
|
8
|
+
/** Stable contract identity, e.g. `core.read@2`. Versioned independently of the wire name. */
|
|
6
9
|
contractId: string;
|
|
10
|
+
/** Declared behavior revision (protocol §7.1: declarative — hashing a JS closure proves nothing). */
|
|
7
11
|
implementationRevision: string;
|
|
8
12
|
wireName: string;
|
|
13
|
+
/** Live deployment aliases (ToolSpec.aliases) — dispatchable alternate wire names. Retired-name
|
|
14
|
+
* replay aliases are gone (RB-476-A, 5.0.0): a persisted old name misses loudly instead. */
|
|
9
15
|
aliases?: string[];
|
|
10
16
|
origin: ToolOrigin;
|
|
17
|
+
/** Structure-only schema digest (descriptions/titles/examples stripped) — presentation-invariant. */
|
|
11
18
|
shapeDigest: string;
|
|
19
|
+
/** Full materialized schema digest (incl. descriptions) — the model-visible wire face. */
|
|
12
20
|
wireSchemaDigest: string;
|
|
21
|
+
/** The presentation card in effect. v1: `builtin:<wireName>` (the factory's inline text). */
|
|
13
22
|
cardId: string;
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Manifest v2 row (protocol §5.4) — {@link projectToolManifest}'s per-tool projection of
|
|
26
|
+
* {@link ToolContractDescriptor} onto the wire-visible manifest plane. REF-D25 (2026-08):
|
|
27
|
+
* this is an intentional projection, not a subset alias — it drops `origin` and normalizes
|
|
28
|
+
* `aliases` from optional to required (empty array when there are none), so it cannot be
|
|
29
|
+
* expressed as `Pick<ToolContractDescriptor, ...>`. `core/trace.ts` (TraceEvent's
|
|
30
|
+
* `prompt.assembled` manifest) and `core/runner/prepare-task.ts` (`Prepared.promptManifest.tools`)
|
|
31
|
+
* both reference this same type — the value flows prepare-task.ts → runtask.ts → trace.ts
|
|
32
|
+
* untouched, so a shape drift between those two sites would make a real call-shape change
|
|
33
|
+
* invisible to replay/audit (the same shapeDigest-collision class documented above on
|
|
34
|
+
* `stripPresentation`).
|
|
35
|
+
*/
|
|
15
36
|
export interface ToolManifestRow {
|
|
16
37
|
wireName: string;
|
|
17
38
|
aliases: string[];
|
|
@@ -29,10 +50,27 @@ export interface AttachContractInput {
|
|
|
29
50
|
origin: ToolOrigin;
|
|
30
51
|
aliases?: string[];
|
|
31
52
|
}
|
|
53
|
+
/** Attach a contract descriptor to a materialized tool (factory exit point). Digests are computed
|
|
54
|
+
* from the tool's REAL mounted schema/description, so they always reflect the wire face. */
|
|
32
55
|
export declare function attachToolContract(tool: AgentTool, input: AttachContractInput): void;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a tool's descriptor. Undeclared tools get a deterministic legacy descriptor derived from
|
|
58
|
+
* their shape (`legacy:<shapeDigest>`), origin per the mount channel — an external tool NEVER
|
|
59
|
+
* inherits a core contract by name (§7.2: don't guess contracts from names).
|
|
60
|
+
*/
|
|
33
61
|
export declare function getToolContract(tool: AgentTool, fallbackOrigin?: ToolOrigin): ToolContractDescriptor;
|
|
34
62
|
export declare function hasToolContract(tool: AgentTool): boolean;
|
|
63
|
+
/** Manifest projection for the final mounted tool set (manifest v2 `tools`, protocol §5.4). */
|
|
35
64
|
export declare function projectToolManifest(tools: AgentTool[], originOf?: (tool: AgentTool) => ToolOrigin): ToolManifestRow[];
|
|
65
|
+
/**
|
|
66
|
+
* RB-15 (campaign review): wire-identity collision audit over the FINAL mounted tool set.
|
|
67
|
+
* Rules (plan §6.2 tool row):
|
|
68
|
+
* - an ALIAS colliding with another tool's canonical name or alias = FATAL (silent misdispatch
|
|
69
|
+
* of durable replays would follow — never ship such a mount);
|
|
70
|
+
* - two tools sharing a CANONICAL name = the historic deliberate yield (a caller tool may shadow
|
|
71
|
+
* a built-in; the harness Map keeps the later mount) — NOT fatal, but returned as an explicit
|
|
72
|
+
* exemption record so the mount site can surface it (observable, never silent).
|
|
73
|
+
*/
|
|
36
74
|
export declare function auditToolCollisions(tools: AgentTool[]): {
|
|
37
75
|
yields: Array<{
|
|
38
76
|
name: string;
|
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
import type { ToolFingerprintInput } from "../core/cache-break-detector.js";
|
|
2
|
+
/** Every prefix-shaping input a request carries — the CLASSIFICATION DOMAIN. Adding a field here
|
|
3
|
+
* without classifying it in {@link PREFIX_INPUT_CLASSIFICATION} is a compile error. */
|
|
2
4
|
export interface RawPrefixInputs {
|
|
5
|
+
/** Provider namespace (cache namespaces never span providers). */
|
|
3
6
|
provider: string;
|
|
7
|
+
/** Model id (a switch is a new cache namespace). */
|
|
4
8
|
modelId: string;
|
|
9
|
+
/** The session's pinned prompt-epoch artifact digest (bundled+declarations identity). */
|
|
5
10
|
artifactDigest: string;
|
|
11
|
+
/** Presentation/policy axis: promptProfile + fable mitigations (prose forks on these). */
|
|
6
12
|
promptProfile: string;
|
|
7
13
|
fableMitigations: boolean;
|
|
14
|
+
/** Physical block layout as SERVED (derived from the composed system blocks; single-block default). */
|
|
8
15
|
layoutGroups: ReadonlyArray<{
|
|
9
16
|
groupId: string;
|
|
10
17
|
cacheControlBoundary: boolean;
|
|
11
18
|
}>;
|
|
19
|
+
/** The composed stable system text (digested — text never enters the snapshot object).
|
|
20
|
+
* UNSALTED by design, same rule as the tool wireSchemaDigest ("schemas are code"): a full-text
|
|
21
|
+
* sha of a LONG composed prompt is an equality oracle only for someone who already possesses the
|
|
22
|
+
* exact bytes — unlike the SHORT guessable manifest blocks (env facts, one-line memory) whose
|
|
23
|
+
* dictionary-preimage risk is why block hashes are salted. Cross-run comparability is the whole
|
|
24
|
+
* point of this identity; salting would destroy it. */
|
|
12
25
|
stableSystemText: string;
|
|
26
|
+
/** Wire-face tool projections (name/description/schema — the mounted set, post-defer). */
|
|
13
27
|
toolWire: ReadonlyArray<ToolFingerprintInput>;
|
|
28
|
+
/** Request-shaping controls that alter the wire body. */
|
|
14
29
|
thinkingLevel: string;
|
|
15
30
|
maxTokens: number | undefined;
|
|
16
31
|
hasOutputSchema: boolean;
|
|
32
|
+
/** Routing/audit fields — provably NOT part of the cacheable prefix. */
|
|
17
33
|
sessionId: string;
|
|
18
34
|
taskId: string | undefined;
|
|
35
|
+
/** Per-call variables — never reusable, never identity. */
|
|
19
36
|
turn: number;
|
|
20
37
|
cacheRead: number;
|
|
21
38
|
}
|
|
22
39
|
export type PrefixInputClass = "cache-identity" | "volatile-no-reuse" | "proven-irrelevant";
|
|
40
|
+
/** The EXHAUSTIVE classification (§10.2). The `satisfies` bound is the CI gate: a new
|
|
41
|
+
* {@link RawPrefixInputs} field fails typecheck until classified here; the runtime pin
|
|
42
|
+
* (`test/turn-snapshot.test.ts`) asserts totality survives refactors. Reasons ride inline. */
|
|
23
43
|
export declare const PREFIX_INPUT_CLASSIFICATION: {
|
|
24
44
|
readonly provider: "cache-identity";
|
|
25
45
|
readonly modelId: "cache-identity";
|
|
@@ -37,6 +57,7 @@ export declare const PREFIX_INPUT_CLASSIFICATION: {
|
|
|
37
57
|
readonly turn: "volatile-no-reuse";
|
|
38
58
|
readonly cacheRead: "volatile-no-reuse";
|
|
39
59
|
};
|
|
60
|
+
/** The lowering face (§10.1): version + wire form + that form's KNOWN intentional divergences. */
|
|
40
61
|
export interface LoweringRecord {
|
|
41
62
|
version: string;
|
|
42
63
|
form: "openai-merged" | "anthropic-blocks" | "other";
|
|
@@ -44,6 +65,7 @@ export interface LoweringRecord {
|
|
|
44
65
|
}
|
|
45
66
|
export declare const LOWERING_VERSION = "sema-lowering@1";
|
|
46
67
|
export declare function loweringRecordFor(api: string): LoweringRecord;
|
|
68
|
+
/** The nine identity elements, individually digested (observable without shipping prompt text). */
|
|
47
69
|
export interface CacheIdentityElements {
|
|
48
70
|
provider: string;
|
|
49
71
|
modelId: string;
|
|
@@ -57,11 +79,19 @@ export interface CacheIdentityElements {
|
|
|
57
79
|
}
|
|
58
80
|
export interface TurnPromptSnapshot {
|
|
59
81
|
elements: CacheIdentityElements;
|
|
82
|
+
/** sha256(canonical(elements)) — the ONE nine-element identity value. */
|
|
60
83
|
cacheIdentity: string;
|
|
61
84
|
lowering: LoweringRecord;
|
|
85
|
+
/** codex S3 F3 — invoked after EVERY refresh so the run loop can emit the changed identity
|
|
86
|
+
* (`prompt.snapshot_changed` trace); traces must never keep claiming a superseded prefix. */
|
|
62
87
|
onChange?: (snapshot: TurnPromptSnapshot) => void;
|
|
88
|
+
/** Refresh the tool half (design/36 rematerialize follows the declared mid-run change). */
|
|
63
89
|
refreshTools(toolWire: RawPrefixInputs["toolWire"]): void;
|
|
90
|
+
/** Refresh the stable-system half (RB-31 adoption swap — pass the COMMITTED epoch digest so the
|
|
91
|
+
* identity never mixes old-artifact/new-prompt, codex S3 F2). */
|
|
64
92
|
refreshStableSystem(stableSystemText: string, artifactDigest?: string): void;
|
|
93
|
+
/** codex S3 F1 — request-policy element follows mid-run wire changes (finalize lanes flip the
|
|
94
|
+
* thinking level; a served-model swap re-namespaces the cache). */
|
|
65
95
|
refreshRequestPolicy(p: {
|
|
66
96
|
thinkingLevel?: string;
|
|
67
97
|
maxTokens?: number | null;
|
|
@@ -71,4 +101,14 @@ export interface TurnPromptSnapshot {
|
|
|
71
101
|
modelId: string;
|
|
72
102
|
}): void;
|
|
73
103
|
}
|
|
104
|
+
/** Build the run's snapshot from classified raw inputs. Volatile/irrelevant fields are accepted so
|
|
105
|
+
* the CLASSIFICATION stays total over everything callers hold, but only identity-class fields can
|
|
106
|
+
* reach the digest — enforced structurally (this function reads exactly the identity fields).
|
|
107
|
+
*
|
|
108
|
+
* `promptHasher` (codex S3 F4): the digest applied to COMPOSED PROMPT TEXT — callers inject a
|
|
109
|
+
* KEYED/salted hasher (the run loop uses the per-process manifest salt): a fixed public prefix +
|
|
110
|
+
* short unknown suffix (an env fact, a memory note, a tenant string) makes an unsalted full-text
|
|
111
|
+
* sha ENUMERABLE, recreating exactly the disclosure the salted block hashes prevent. Consequence,
|
|
112
|
+
* documented: `stableSystemDigest` (and thus `cacheIdentity`) compares within one process only;
|
|
113
|
+
* cross-process reconciliation rides the CODE-class digests (artifact/toolWire — unsalted). */
|
|
74
114
|
export declare function buildTurnPromptSnapshot(raw: Omit<RawPrefixInputs, "turn" | "cacheRead">, api: string, promptHasher?: (text: string) => string): TurnPromptSnapshot;
|