{"version":3,"file":"prompt-refinement-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/prompt-refinement-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport { AIError } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Why a prompt refinement was rejected:\n *\n * - `\"model\"` — the refiner model call itself failed (provider error, no\n *   key, timeout); the underlying `AIError` rides on `cause`.\n * - `\"parity\"` — the rewrite broke placeholder parity (added, removed, or\n *   renamed a `{{placeholder}}` / changed its `|default`) and one repair\n *   attempt didn't fix it; the offending tokens are listed in `context.issues`.\n * - `\"empty\"` — the refiner returned no usable text.\n */\nexport type PromptRefinementFailureReason = \"model\" | \"parity\" | \"empty\";\n\nexport type PromptRefinementErrorOptions = AIErrorOptions & {\n  reason: PromptRefinementFailureReason;\n};\n\n/**\n * An explicit `refine()` / `refinePrompt()` call could not produce an\n * acceptable compiled prompt. Thrown (not degraded) because the explicit\n * compilation surface is used by routes, warmup, and CI — callers there need\n * the failure, not a silently-served original.\n *\n * The LAZY agent path never sees this error: `materialize()` catches it,\n * warns once, and serves the original prompt text — refinement is advisory\n * there, mirroring the Nova-safe judge policy in `ai.prompts.validate`.\n */\nexport class PromptRefinementError extends AIError {\n  public static readonly defaultCategory: ErrorCategory = \"validation\";\n\n  public readonly reason: PromptRefinementFailureReason;\n\n  public constructor(message: string, options: PromptRefinementErrorOptions) {\n    super(\"PROMPT_REFINEMENT_FAILED\", message, options);\n    this.name = \"PromptRefinementError\";\n    this.reason = options.reason;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,IAAa,wBAAb,cAA2C,QAAQ;;yBACO;;CAIxD,AAAO,YAAY,SAAiB,SAAuC;EACzE,MAAM,4BAA4B,SAAS,OAAO;EAClD,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;CACxB;AACF"}