{"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../ai/src/prompt/errors.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"../errors/ai-error\";\nimport type { ErrorCategory } from \"../errors/error-category.type\";\n\n/**\n * A prompt name was looked up in the registry but is not registered.\n *\n * Thrown by `resolve(name, …)` and `versions(name)` on an unknown name —\n * closing the silent first-match / empty-result gap a bare `Map.get` would\n * leave. The missing name is carried in `context.name` for logging.\n *\n * Reuses the `\"validation\"` category (an authoring-time lookup mistake, not a\n * provider failure) and the shared `PROVIDER_INVALID_REQUEST` code, since the\n * prompt registry is a local primitive with no dedicated error code.\n *\n * @example\n * try {\n *   prompts.resolve(\"unknown-agent\");\n * } catch (error) {\n *   if (error instanceof PromptNotFoundError) {\n *     console.error(error.context?.name);\n *   }\n * }\n */\nexport class PromptNotFoundError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"validation\";\n\n  public constructor(name: string, options?: AIErrorOptions) {\n    super(\"PROVIDER_INVALID_REQUEST\", `Prompt \"${name}\" is not registered.`, {\n      ...options,\n      context: { name, ...options?.context },\n    });\n    this.name = \"PromptNotFoundError\";\n  }\n}\n\n/**\n * A prompt-registry authoring or resolution invariant was violated:\n *\n * - `add(name, version)` / `register(entry)` with a duplicate version label\n *   (no silent overwrite).\n * - `resolve(name, …)` where the picked version declares `required` keys that\n *   are missing from the merged placeholders (the missing keys are listed in\n *   the message and carried on `context.missing`).\n *\n * Reuses the `\"validation\"` category and the shared `SCHEMA_VALIDATION_FAILED`\n * code — it is the same class of \"you supplied something the registry can't\n * use\" failure as a schema-validation miss.\n *\n * @example\n * try {\n *   prompts.resolve(\"support-agent\", { placeholders: {} });\n * } catch (error) {\n *   if (error instanceof PromptValidationError) {\n *     console.error(error.context?.missing); // [\"product\"]\n *   }\n * }\n */\nexport class PromptValidationError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"validation\";\n\n  public constructor(message: string, options?: AIErrorOptions) {\n    super(\"SCHEMA_VALIDATION_FAILED\", message, options);\n    this.name = \"PromptValidationError\";\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,sBAAb,cAAyC,QAAQ;;yBACS;;CAExD,AAAO,YAAY,MAAc,SAA0B;EACzD,MAAM,4BAA4B,WAAW,KAAK,uBAAuB;GACvE,GAAG;GACH,SAAS;IAAE;IAAM,GAAG,SAAS;GAAQ;EACvC,CAAC;EACD,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,wBAAb,cAA2C,QAAQ;;yBACO;;CAExD,AAAO,YAAY,SAAiB,SAA0B;EAC5D,MAAM,4BAA4B,SAAS,OAAO;EAClD,KAAK,OAAO;CACd;AACF"}