{"version":3,"file":"agent-cancelled-error.mjs","names":[],"sources":["../../../../../../../ai/src/errors/agent-cancelled-error.ts"],"sourcesContent":["import { AgentExecutionError } from \"./agent-execution-error\";\nimport type { AIErrorOptions } from \"./ai-error\";\nimport type { ErrorCategory } from \"./error-category.type\";\n\n/**\n * Payload for {@link AgentCancelledError}. `cancelledAt` is the\n * ISO-8601 timestamp at which the abort was observed; `reason`\n * carries the value the caller supplied to `controller.abort(reason)`\n * when present.\n */\nexport type AgentCancelledErrorOptions = AIErrorOptions & {\n  cancelledAt?: string;\n  reason?: string;\n};\n\n/**\n * Agent run was cancelled via `AbortSignal` before it could finish.\n * Between-trip cancellation is guaranteed; mid-trip cancellation is\n * best-effort (the signal is threaded into the provider adapter's\n * HTTP client when supported).\n *\n * Surfaced on `result.error` rather than thrown — `agent.execute()`\n * still returns with `report.status = \"cancelled\"` and partial trip\n * history intact. Consumers branch on the class (not the message) to\n * distinguish caller-initiated stops from other failures.\n *\n * **Why split from `AgentExecutionError`.** Cancellation is a\n * different operational signal from \"the agent crashed\" — retry\n * policy and dashboards typically want different behavior for each.\n * Keeping cancellation in its own class lets the category\n * (`\"cancelled\"`) be set declaratively per type instead of inferred\n * from a `context.cancelled === true` flag.\n *\n * @example\n * const result = await agent.execute(input, { signal });\n * if (result.error instanceof AgentCancelledError) {\n *   // caller pulled the plug — don't retry, surface a \"stopped\" UI\n *   return { status: \"cancelled\" };\n * }\n */\nexport class AgentCancelledError extends AgentExecutionError {\n  public static readonly defaultCategory: ErrorCategory = \"cancelled\";\n\n  public readonly cancelledAt?: string;\n  public readonly reason?: string;\n\n  public constructor(message: string, options?: AgentCancelledErrorOptions) {\n    super(message, options, \"AGENT_CANCELLED\");\n    this.name = \"AgentCancelledError\";\n    this.cancelledAt = options?.cancelledAt;\n    this.reason = options?.reason;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,sBAAb,cAAyC,oBAAoB;;yBACH;;CAKxD,AAAO,YAAY,SAAiB,SAAsC;EACxE,MAAM,SAAS,SAAS,iBAAiB;EACzC,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS;EAC5B,KAAK,SAAS,SAAS;CACzB;AACF"}