import { type Task } from "./models.js"; /** The single shape of the JSON error envelope (see PROTOCOL.md). Everything that * records an error — a handler exception, a missing handler, lease expiry, a thrown * TaskError — builds it here, so the contract's fields live in one place. */ export declare function errorEnvelope(e: { type: string; code: string; message: string; retryable: boolean; details?: Record; }): Record; export declare class CairnQError extends Error { constructor(message?: string); } export declare class AlreadyExists extends CairnQError { key: string; constructor(key: string); } /** A gated submit waited out `maxWaitMs` without the queue draining below its * depth limit. Nothing was enqueued. Distinct from a slow submit on purpose: a * queue this far behind is a capacity problem, and a caller that silently * retries forever converts it into an invisible one. */ export declare class QueueFull extends CairnQError { queue: string; maxDepth: number; waitedMs: number; constructor(queue: string, maxDepth: number, waitedMs: number); } /** wait/call did not reach a terminal status in time. The task keeps running. * `task` is the last snapshot wait() observed (null if get() found nothing), and * the message says what state it was stuck in — a queued-never-claimed task is * the classic first-run failure (no worker, no handler, wrong queue or file). */ export declare class TaskTimeout extends CairnQError { taskId: string; readonly task: Task | null; constructor(taskId: string, opts?: { timeoutMs?: number; task?: Task | null; }); } /** A waited-on task ended in `failed`. The envelope's fields are unpacked onto the * error — read `e.code` / `e.message` / `e.retryable` / `e.details` instead of * digging into `e.error` (the raw envelope stays available on `e.error`). */ export declare class TaskFailed extends CairnQError { error: unknown; readonly type: string; readonly code: string; readonly retryable: boolean; readonly details: Record; constructor(error: unknown); } export declare class TaskCanceled extends CairnQError { taskId: string; constructor(taskId: string); } /** A worker write affected 0 rows: the lease expired and was reclaimed. */ export declare class LostLease extends CairnQError { taskId: string; constructor(taskId: string); } export declare class ProtocolVersionMismatch extends CairnQError { constructor(message: string); } /** A value could not be encoded for a protocol JSON column (non-finite number, * BigInt, circular structure, …). Raised at the boundary — submit rejects with * it, and a worker records a handler result that triggers it as a permanent * `unserializable_result` failure. The Python SDK raises the same named error. */ export declare class SerializationError extends CairnQError { constructor(message: string); } /** Throw inside a handler to control how the failure is recorded. Defaults to * non-retryable so deterministic errors fail fast instead of burning retries. * Any other thrown value is treated as retryable. */ export declare class TaskError extends CairnQError { code: string; retryable: boolean; type: string; details: Record; constructor(message: string, opts?: { code?: string; retryable?: boolean; type?: string; details?: Record; }); envelope(): Record; }