import { ErrorCategory } from "./error-category.type.mjs"; import { AIErrorOptions } from "./ai-error.mjs"; import { AgentExecutionError } from "./agent-execution-error.mjs"; //#region ../ai/src/errors/agent-cancelled-error.d.ts /** * Payload for {@link AgentCancelledError}. `cancelledAt` is the * ISO-8601 timestamp at which the abort was observed; `reason` * carries the value the caller supplied to `controller.abort(reason)` * when present. */ type AgentCancelledErrorOptions = AIErrorOptions & { cancelledAt?: string; reason?: string; }; /** * Agent run was cancelled via `AbortSignal` before it could finish. * Between-trip cancellation is guaranteed; mid-trip cancellation is * best-effort (the signal is threaded into the provider adapter's * HTTP client when supported). * * Surfaced on `result.error` rather than thrown — `agent.execute()` * still returns with `report.status = "cancelled"` and partial trip * history intact. Consumers branch on the class (not the message) to * distinguish caller-initiated stops from other failures. * * **Why split from `AgentExecutionError`.** Cancellation is a * different operational signal from "the agent crashed" — retry * policy and dashboards typically want different behavior for each. * Keeping cancellation in its own class lets the category * (`"cancelled"`) be set declaratively per type instead of inferred * from a `context.cancelled === true` flag. * * @example * const result = await agent.execute(input, { signal }); * if (result.error instanceof AgentCancelledError) { * // caller pulled the plug — don't retry, surface a "stopped" UI * return { status: "cancelled" }; * } */ declare class AgentCancelledError extends AgentExecutionError { static readonly defaultCategory: ErrorCategory; readonly cancelledAt?: string; readonly reason?: string; constructor(message: string, options?: AgentCancelledErrorOptions); } //#endregion export { AgentCancelledError, AgentCancelledErrorOptions }; //# sourceMappingURL=agent-cancelled-error.d.mts.map