/** * Tool Contract Verifier, registration-time contract checks for all registered tools. * * Validates five contract dimensions for every tool: * 1. Schema validity * 2. Timeout/cancellation semantics * 3. Permission class mapping * 4. Output policy alignment * 5. Idempotency declaration for side-effecting tools * * Invalid tools fail closed: a tool with contract violations is rejected at * registration time with actionable diagnostics surfaced to the caller. */ import type { Tool } from '../../types/tools.js'; /** Severity of a single contract violation. */ export type ContractViolationSeverity = 'error' | 'warn'; /** A single contract check that failed or produced a warning. */ export interface ContractViolation { /** Which of the 5 contract dimensions this belongs to. */ readonly dimension: 'schema' | 'timeout-cancellation' | 'permission-class' | 'output-policy' | 'idempotency'; /** Severity of the violation. */ readonly severity: ContractViolationSeverity; /** Human-readable explanation of what is wrong. */ readonly message: string; /** Optional hint for how to fix the violation. */ readonly hint?: string | undefined; } /** Full contract verification result for a single tool. */ export interface ContractVerificationResult { /** Tool name. */ readonly toolName: string; /** Whether the tool passed all required (error-level) checks. */ readonly passed: boolean; /** All violations found. May include warnings even if passed. */ readonly violations: readonly ContractViolation[]; /** Unix timestamp (ms) when this result was produced. */ readonly verifiedAt: number; /** Whether this tool was verified as a PhasedTool (has extended metadata). */ readonly isPhasedTool: boolean; } /** * Options controlling which contract checks run and how strictly. */ export interface ContractVerifierOptions { /** * Whether to treat missing idempotency declarations on side-effecting tools * as errors (true, default) or warnings (false). * * Set to false while tightening tool metadata requirements incrementally. */ strictIdempotency?: boolean | undefined; /** * Whether to treat missing permission class metadata as errors (true) or * warnings (false, default for tool definitions that omit that metadata). */ strictPermissionClass?: boolean | undefined; } /** * ToolContractVerifier, runs all 5 contract checks on a single tool. * * Usage: * ```ts * const verifier = new ToolContractVerifier(); * const result = verifier.verify(myTool); * if (!result.passed) { * for (const v of result.violations.filter(v => v.severity === 'error')) { * throw new Error(v.message); * } * } * ``` */ export declare class ToolContractVerifier { private readonly _opts; constructor(opts?: ContractVerifierOptions); /** * Verify a single tool against all 5 contract dimensions. * * @param tool - The tool to verify. * @returns A ContractVerificationResult with all violations and a pass/fail flag. */ verify(tool: Tool): ContractVerificationResult; /** * Verify multiple tools at once. * * @param tools - Array of tools to verify. * @returns Map of tool name to verification result. */ verifyAll(tools: readonly Tool[]): Map; /** * Format a verification result as a human-readable diagnostic string. * Suitable for printing to the console or a diagnostics panel. * * @param result - The result to format. * @returns Multi-line formatted diagnostic string. */ static formatResult(result: ContractVerificationResult): string; /** * Format a map of results (from verifyAll) as a human-readable summary. * * @param results - Map of tool name to verification result. * @returns Multi-line formatted diagnostic string. */ static formatAllResults(results: Map): string; } //# sourceMappingURL=contract-verifier.d.ts.map