export interface OperationProgress { /** Coarse stage, e.g. 'queue', 'poll', 'download', 'encode'. */ phase: string; /** Human-readable detail line, e.g. 'shot 3/12 PROCESSING 41s'. */ detail?: string; /** Completed units, when the operation has countable work. */ current?: number; /** Total units, when known. */ total?: number; } export interface OperationContext { /** Aborted when the operator cancels (Ctrl-C in the shell, kill in MCP). */ signal?: AbortSignal; /** Short label for status output, e.g. 'generate-videos ep 2'. */ label?: string; /** Sink for progress updates; the shell renders these on a status line. */ onProgress?: (update: OperationProgress) => void; } /** * Thrown when an operation is cancelled. Distinct from a Venice API failure so * callers can report "cancelled" instead of "failed" and skip retries. */ export declare class OperationAbortedError extends Error { constructor(message?: string); } /** Run `fn` with `context` visible to every async descendant. */ export declare function runInOperation(context: OperationContext, fn: () => Promise): Promise; export declare function currentOperation(): OperationContext | undefined; export declare function currentSignal(): AbortSignal | undefined; /** True when the ambient operation has been cancelled. */ export declare function isAborted(): boolean; /** Bail out of a loop as soon as the operator cancels. */ export declare function throwIfAborted(): void; /** * Recognise both our own abort error and the DOMException that `fetch` raises * when its signal fires, so retry logic can tell cancellation from failure. */ export declare function isAbortError(error: unknown): boolean; /** * Sleep that resolves early -- by rejecting -- when the operation is cancelled. * Poll loops wait 5-10s between attempts; without this, cancelling would take * up to a full poll interval to be noticed. */ export declare function abortableSleep(ms: number, signal?: AbortSignal | undefined): Promise; /** Emit a progress update if anything is listening. */ export declare function reportProgress(update: OperationProgress): void; //# sourceMappingURL=operation-context.d.ts.map