{"version":3,"file":"supervisor-routing-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/supervisor-routing-error.ts"],"sourcesContent":["import type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\nimport { SupervisorFailedError } from \"./supervisor-failed-error\";\n\nexport type SupervisorRoutingErrorOptions = AIErrorOptions & {\n  /**\n   * The raw value the `route` callback or router agent returned. Keyed\n   * `unknown` because a misbehaving router can emit any JSON value —\n   * consumers should format it for display, not trust its shape.\n   */\n  returned: unknown;\n  /** Every legal intent key configured on the supervisor at run time. */\n  availableKeys: string[];\n};\n\n/**\n * A `route` callback or router agent returned a value that doesn't\n * resolve to a configured agent key, a `string[]` of configured keys,\n * or the `END` sentinel. Routing is authoritative — there is no\n * recovery path, so the supervisor terminates the run immediately.\n *\n * Named `SupervisorRoutingError` (not `RoutingError`) to avoid\n * colliding with `@warlock.js/ai`'s existing workflow `RoutingError`\n * (`WORKFLOW_INVALID_GOTO`). Both carry the same semantic weight —\n * \"routing asked for something I can't dispatch\" — in their\n * respective primitives.\n *\n * @example\n * const { error } = await supervisor.execute(input);\n * if (error?.code === \"SUPERVISOR_INVALID_ROUTE\") {\n *   logger.error(\"bad router decision\", {\n *     returned: (error as SupervisorRoutingError).returned,\n *     available: (error as SupervisorRoutingError).availableKeys,\n *   });\n * }\n */\nexport class SupervisorRoutingError extends SupervisorFailedError {\n  public static readonly defaultCategory: ErrorCategory = \"routing\";\n\n  public readonly returned: unknown;\n  public readonly availableKeys: string[];\n\n  public constructor(message: string, options: SupervisorRoutingErrorOptions) {\n    super(message, options, \"SUPERVISOR_INVALID_ROUTE\");\n    this.name = \"SupervisorRoutingError\";\n    this.returned = options.returned;\n    this.availableKeys = options.availableKeys;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,yBAAb,cAA4C,sBAAsB;;yBACR;;CAKxD,AAAO,YAAY,SAAiB,SAAwC;EAC1E,MAAM,SAAS,SAAS,0BAA0B;EAClD,KAAK,OAAO;EACZ,KAAK,WAAW,QAAQ;EACxB,KAAK,gBAAgB,QAAQ;CAC/B;AACF"}