{"version":3,"file":"schema-validation-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/schema-validation-error.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { AIError, type AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Payload passed to `SchemaValidationError`. Subset of\n * `AIErrorOptions` plus the machine-readable validation issues list.\n */\nexport type SchemaValidationErrorOptions = AIErrorOptions & {\n  issues?: readonly StandardSchemaV1.Issue[];\n};\n\n/**\n * A `StandardSchemaV1` validation call returned issues, or the input\n * was not valid JSON before validation could even run.\n *\n * Produced in two places today:\n * - Agent output parsing — the final trip text failed `JSON.parse` or\n *   the parsed value failed `~standard.validate`.\n * - Tool input validation — the model's raw arguments for a tool call\n *   didn't match the tool's `input` schema.\n *\n * `issues` carries the structured validation result when available so\n * consumers can present per-field feedback.\n *\n * @example\n * if (result.error instanceof SchemaValidationError) {\n *   for (const issue of result.error.issues ?? []) {\n *     console.warn(issue.path, issue.message);\n *   }\n * }\n */\nexport class SchemaValidationError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"schema\";\n\n  public readonly issues?: readonly StandardSchemaV1.Issue[];\n\n  public constructor(message: string, options?: SchemaValidationErrorOptions) {\n    super(\"SCHEMA_VALIDATION_FAILED\", message, options);\n    this.name = \"SchemaValidationError\";\n    this.issues = options?.issues;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,wBAAb,cAA2C,QAAQ;;yBACO;;CAIxD,AAAO,YAAY,SAAiB,SAAwC;EAC1E,MAAM,4BAA4B,SAAS,OAAO;EAClD,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS;CACzB;AACF"}