/** * Cross-reference invariants for `DataContract`. Validates that every * intra-contract pointer resolves to a declared catalog entry on the * SAME contract — i.e., the contract is internally consistent. * * The protocol exposes two such pointers: * * - `actionSpec[*].nextStep` → `agentCapabilities.tools[*]` key * - `streamSpec[*].source.tool` → `agentCapabilities.tools[*]` key * * These are pure in-contract checks. A contract that declares * `nextStep: 'archive_email'` MUST also declare `archive_email` in its * own `agentCapabilities.tools` catalog — same-MCP and cross-MCP both * funnel through this single resolution path (the catalog is the * declarative source of truth for every referenced tool). Violations * are author-recoverable at render time. */ import type { DataContract, ActionSpec, StreamSpec, AgentCapabilitiesSpec } from '../types/data-contract.js'; import type { ContractViolation } from './contract-validator.js'; /** * Stable error code emitted when an `actionSpec[*].nextStep` value * does not resolve to a declared `agentCapabilities.tools[*]` key on * the same contract. * * Intended for downstream consumers that switch on the code rather * than pattern-matching message strings. */ export declare const CTR_REF_NEXT_STEP = "CTR_REF_NEXT_STEP"; /** * Stable error code emitted when a `streamSpec[*].source.tool` value * does not resolve to a declared `agentCapabilities.tools[*]` key on * the same contract. * * Intended for downstream consumers that switch on the code rather * than pattern-matching message strings. Mentioned by name in * `packages/protocol/src/types/data-contract.ts` (StreamChannelEntry * docstring) — keep in sync. */ export declare const CTR_REF_STREAM_SOURCE = "CTR_REF_STREAM_SOURCE"; /** * Cross-reference violation — adds a stable `code` field on top of * `ContractViolation`. Lives here rather than on the base type so * existing structural violations stay code-less; cross-ref violations * are designed to be machine-discriminated. */ export interface CrossReferenceViolation extends ContractViolation { code: typeof CTR_REF_NEXT_STEP | typeof CTR_REF_STREAM_SOURCE; } /** * Validate every `actionSpec[*].nextStep` resolves to a declared * `agentCapabilities.tools[*]` key on the same contract. Entries * without a `nextStep` are skipped (they're pure event signals — the * agent decides unconstrained by author intent). * * When `agentCapabilities` is undefined but a `nextStep` is declared, * the reference still doesn't resolve — a violation surfaces. Authors * can fix by adding the referenced tool to `agentCapabilities.tools` * or by dropping the `nextStep` hint (no-hint action remains valid). */ export declare function checkActionNextStepRefs(actionSpec: ActionSpec | undefined, agentCapabilities: AgentCapabilitiesSpec | undefined): CrossReferenceViolation[]; /** * Validate every `streamSpec[*].source.tool` resolves to a declared * `agentCapabilities.tools[*]` key on the same contract. Channels * without a `source` declaration are skipped (they're agent-written by * some other mechanism, or server-owned reserved channels). * * When `agentCapabilities` is undefined but a `source.tool` is * declared, the reference still doesn't resolve — a violation * surfaces. Authors fix by adding the referenced tool to * `agentCapabilities.tools` or by dropping `source` (channel becomes * agent-written rather than tool-sourced). */ export declare function checkStreamSourceRefs(streamSpec: StreamSpec | undefined, agentCapabilities: AgentCapabilitiesSpec | undefined): CrossReferenceViolation[]; /** * Run every cross-reference invariant. Returns the aggregated * violation list — order is stable: `nextStep` invariants first, * `stream.source` invariants second. * * Pure check; doesn't throw. Callers that want fail-fast semantics * use {@link assertCrossReferences}. */ export declare function checkCrossReferences(contract: DataContract): CrossReferenceViolation[]; /** * Throwable form of {@link checkCrossReferences}. Use at protocol * boundaries where an unresolved cross-reference is a contract bug * the caller must fix (render handler, blueprint registration). * * Carries the full violation list so error renderers can show every * dangling reference in one pass instead of fix-and-retry per-field. */ export declare class CrossReferenceError extends Error { readonly code: "cross_reference_unresolved"; readonly violations: readonly CrossReferenceViolation[]; constructor(violations: readonly CrossReferenceViolation[]); } /** * Throw-on-violation wrapper around {@link checkCrossReferences}. * No-op when the contract is internally consistent. * * Invoked at handshake AND render time: contract-internal mistakes * surface at the earliest possible boundary so the agent can fix and * retry on the SAME handshakeId. */ export declare function assertCrossReferences(contract: DataContract): void; //# sourceMappingURL=cross-references.d.ts.map