/** * Zod Schemas for Response Validation Types * * Runtime validation schemas for MCP tool response validation. * Provides safe parsing of MCP SDK response types to replace type assertions. * * @module assessment/responseValidatorSchemas * @see ResponseValidator.ts - Consumer of these schemas * @see resultTypes.ts - ResponseMetadata interface definition */ import { z } from "zod"; import { ZOD_SCHEMA_VERSION } from "../../lib/assessment/sharedSchemas.js"; export { ZOD_SCHEMA_VERSION }; /** * Schema for MCP content type enum values. */ export declare const ContentTypeSchema: z.ZodEnum<["text", "image", "resource", "resource_link", "audio"]>; export type ContentType = z.infer; /** * Schema for a text content block. */ export declare const TextContentBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; type?: "text"; }, { text?: string; type?: "text"; }>; /** * Schema for an image content block. */ export declare const ImageContentBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodString; mimeType: z.ZodString; }, "strip", z.ZodTypeAny, { type?: "image"; mimeType?: string; data?: string; }, { type?: "image"; mimeType?: string; data?: string; }>; /** * Schema for a resource content block. */ export declare const ResourceContentBlockSchema: z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"resource">, z.ZodLiteral<"resource_link">]>; uri: z.ZodOptional; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }>; /** * Schema for an audio content block. */ export declare const AudioContentBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"audio">; data: z.ZodString; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "audio"; mimeType?: string; data?: string; }, { type?: "audio"; mimeType?: string; data?: string; }>; /** * Generic content block schema that accepts any type string. * Used as fallback for unknown content types. */ export declare const GenericContentBlockSchema: z.ZodObject<{ type: z.ZodString; text: z.ZodOptional; data: z.ZodOptional; mimeType: z.ZodOptional; uri: z.ZodOptional; }, "strip", z.ZodTypeAny, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }>; /** * Union of all known content block types, with fallback for unknown types. */ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; type?: "text"; }, { text?: string; type?: "text"; }>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodString; mimeType: z.ZodString; }, "strip", z.ZodTypeAny, { type?: "image"; mimeType?: string; data?: string; }, { type?: "image"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"resource">, z.ZodLiteral<"resource_link">]>; uri: z.ZodOptional; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }>, z.ZodObject<{ type: z.ZodLiteral<"audio">; data: z.ZodString; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "audio"; mimeType?: string; data?: string; }, { type?: "audio"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodString; text: z.ZodOptional; data: z.ZodOptional; mimeType: z.ZodOptional; uri: z.ZodOptional; }, "strip", z.ZodTypeAny, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }>]>; export type ContentBlock = z.infer; /** * Schema for content array in MCP responses. * Uses ContentBlockSchema union for stricter type discrimination. */ export declare const ContentArraySchema: z.ZodArray; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; type?: "text"; }, { text?: string; type?: "text"; }>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodString; mimeType: z.ZodString; }, "strip", z.ZodTypeAny, { type?: "image"; mimeType?: string; data?: string; }, { type?: "image"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"resource">, z.ZodLiteral<"resource_link">]>; uri: z.ZodOptional; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }>, z.ZodObject<{ type: z.ZodLiteral<"audio">; data: z.ZodString; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "audio"; mimeType?: string; data?: string; }, { type?: "audio"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodString; text: z.ZodOptional; data: z.ZodOptional; mimeType: z.ZodOptional; uri: z.ZodOptional; }, "strip", z.ZodTypeAny, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }>]>, "many">; export type ContentArray = z.infer; /** * Schema for output schema validation result. */ export declare const OutputSchemaValidationSchema: z.ZodObject<{ hasOutputSchema: z.ZodBoolean; isValid: z.ZodBoolean; error: z.ZodOptional; }, "strip", z.ZodTypeAny, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }>; export type OutputSchemaValidationParsed = z.infer; /** * Schema for response metadata tracking. * Matches ResponseMetadata interface in resultTypes.ts. */ export declare const ResponseMetadataSchema: z.ZodObject<{ contentTypes: z.ZodArray, "many">; hasStructuredContent: z.ZodBoolean; hasMeta: z.ZodBoolean; textBlockCount: z.ZodNumber; imageCount: z.ZodNumber; resourceCount: z.ZodNumber; outputSchemaValidation: z.ZodOptional; }, "strip", z.ZodTypeAny, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }>>; }, "strip", z.ZodTypeAny, { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }, { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }>; export type ResponseMetadataParsed = z.infer; /** * Schema for validation classification enum. */ export declare const ValidationClassificationSchema: z.ZodEnum<["fully_working", "partially_working", "connectivity_only", "broken", "error"]>; export type ValidationClassification = z.infer; /** * Schema for validation result. * Matches ValidationResult interface in ResponseValidator.ts. */ export declare const ValidationResultSchema: z.ZodObject<{ isValid: z.ZodBoolean; isError: z.ZodBoolean; confidence: z.ZodNumber; issues: z.ZodArray; evidence: z.ZodArray; classification: z.ZodEnum<["fully_working", "partially_working", "connectivity_only", "broken", "error"]>; responseMetadata: z.ZodOptional, "many">; hasStructuredContent: z.ZodBoolean; hasMeta: z.ZodBoolean; textBlockCount: z.ZodNumber; imageCount: z.ZodNumber; resourceCount: z.ZodNumber; outputSchemaValidation: z.ZodOptional; }, "strip", z.ZodTypeAny, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }, { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }>>; }, "strip", z.ZodTypeAny, { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }, { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }>>; }, "strip", z.ZodTypeAny, { evidence?: string[]; confidence?: number; isError?: boolean; isValid?: boolean; issues?: string[]; classification?: "error" | "fully_working" | "partially_working" | "connectivity_only" | "broken"; responseMetadata?: { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }; }, { evidence?: string[]; confidence?: number; isError?: boolean; isValid?: boolean; issues?: string[]; classification?: "error" | "fully_working" | "partially_working" | "connectivity_only" | "broken"; responseMetadata?: { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }; }>; export type ValidationResultParsed = z.infer; /** * Schema for MCP tool call result (CompatibilityCallToolResult). * Validates the structure of tool responses from MCP SDK. */ export declare const MCPToolCallResultSchema: z.ZodObject<{ content: z.ZodOptional; text: z.ZodString; }, "strip", z.ZodTypeAny, { text?: string; type?: "text"; }, { text?: string; type?: "text"; }>, z.ZodObject<{ type: z.ZodLiteral<"image">; data: z.ZodString; mimeType: z.ZodString; }, "strip", z.ZodTypeAny, { type?: "image"; mimeType?: string; data?: string; }, { type?: "image"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"resource">, z.ZodLiteral<"resource_link">]>; uri: z.ZodOptional; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }, { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; }>, z.ZodObject<{ type: z.ZodLiteral<"audio">; data: z.ZodString; mimeType: z.ZodOptional; }, "strip", z.ZodTypeAny, { type?: "audio"; mimeType?: string; data?: string; }, { type?: "audio"; mimeType?: string; data?: string; }>, z.ZodObject<{ type: z.ZodString; text: z.ZodOptional; data: z.ZodOptional; mimeType: z.ZodOptional; uri: z.ZodOptional; }, "strip", z.ZodTypeAny, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }, { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; }>]>, "many">>; isError: z.ZodOptional; structuredContent: z.ZodOptional; _meta: z.ZodOptional; }, "strip", z.ZodTypeAny, { content?: ({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[]; isError?: boolean; _meta?: unknown; structuredContent?: unknown; }, { content?: ({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[]; isError?: boolean; _meta?: unknown; structuredContent?: unknown; }>; export type MCPToolCallResultParsed = z.infer; /** * Validate content array from MCP response. * * @param content - Content array to validate * @returns Array of validation error messages (empty if valid) */ export declare function validateContentArray(content: unknown): string[]; /** * Safely parse content array without throwing. * * @param content - Raw content array * @returns SafeParseResult with success status and data/error */ export declare function safeParseContentArray(content: unknown): z.SafeParseReturnType<({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[], ({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[]>; /** * Safely parse MCP tool call result. * * @param result - Raw tool call result * @returns SafeParseResult with success status and data/error */ export declare function safeParseMCPToolCallResult(result: unknown): z.SafeParseReturnType<{ content?: ({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[]; isError?: boolean; _meta?: unknown; structuredContent?: unknown; }, { content?: ({ text?: string; type?: "text"; } | { type?: "image"; mimeType?: string; data?: string; } | { type?: "resource_link" | "resource"; mimeType?: string; uri?: string; } | { type?: "audio"; mimeType?: string; data?: string; } | { text?: string; type?: string; mimeType?: string; data?: string; uri?: string; })[]; isError?: boolean; _meta?: unknown; structuredContent?: unknown; }>; /** * Validate validation result structure. * * @param result - Validation result to validate * @returns Array of validation error messages (empty if valid) */ export declare function validateValidationResult(result: unknown): string[]; /** * Parse validation result with validation. * * @param result - Raw validation result * @returns Validated result * @throws ZodError if validation fails */ export declare function parseValidationResult(result: unknown): ValidationResultParsed; /** * Safely parse validation result without throwing. * * @param result - Raw validation result * @returns SafeParseResult with success status and data/error */ export declare function safeParseValidationResult(result: unknown): z.SafeParseReturnType<{ evidence?: string[]; confidence?: number; isError?: boolean; isValid?: boolean; issues?: string[]; classification?: "error" | "fully_working" | "partially_working" | "connectivity_only" | "broken"; responseMetadata?: { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }; }, { evidence?: string[]; confidence?: number; isError?: boolean; isValid?: boolean; issues?: string[]; classification?: "error" | "fully_working" | "partially_working" | "connectivity_only" | "broken"; responseMetadata?: { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }; }>; /** * Validate response metadata structure. * * @param metadata - Response metadata to validate * @returns Array of validation error messages (empty if valid) */ export declare function validateResponseMetadata(metadata: unknown): string[]; /** * Safely parse response metadata without throwing. * * @param metadata - Raw response metadata * @returns SafeParseResult with success status and data/error */ export declare function safeParseResponseMetadata(metadata: unknown): z.SafeParseReturnType<{ contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }, { contentTypes?: ("text" | "image" | "audio" | "resource_link" | "resource")[]; hasStructuredContent?: boolean; hasMeta?: boolean; textBlockCount?: number; imageCount?: number; resourceCount?: number; outputSchemaValidation?: { error?: string; hasOutputSchema?: boolean; isValid?: boolean; }; }>; //# sourceMappingURL=responseValidatorSchemas.d.ts.map