export type DriverVisibility = 'public' | 'unlisted' | 'private'; export type DriverStatus = 'queued' | 'running' | 'succeeded' | 'held' | 'failed' | 'handoff'; export declare const DRIVER_TERMINAL: readonly DriverStatus[]; export interface DriverFailure { code: string; message: string; retriable: boolean; escalate: boolean; } export interface DriverJobView { id: string; kind: string; status: DriverStatus; phase?: string; visibility?: DriverVisibility; stages?: Record; gate?: { state: string; autoApproveAt?: string | null; options?: string[]; } | null; lix?: { spentTotal?: number; byStage?: Record; refunded?: number; }; retry?: { at: string; message: string; } | null; result?: { itemId?: string | null; released?: string; qa?: { verdict?: string; warnings?: unknown[]; blockers?: unknown[]; note?: string; }; } | null; failure?: DriverFailure | null; actions?: string[]; lastEventSeq?: number; [key: string]: unknown; } export interface DriverEvent { seq: number; type: string; [key: string]: unknown; } /** The slice of HelixApi this client needs, so tests can pass a fake. */ export interface DriverApi { request(method: string, path: string, body?: unknown): Promise; } export declare const DRIVER_BASE = "/api/v1/asset-generation"; /** The driver itself waits up to 75 minutes for visual QA; the client waits a little longer. */ export declare const DRIVER_DEFAULT_TIMEOUT_MS: number; export declare const DRIVER_DEFAULT_POLL_MS = 3000; export interface StartDriverAvatarInput { prompt: string; title?: string; /** Sent ONLY when the user chose one; the server owns the default. */ visibility?: DriverVisibility; /** * Seconds (1-120) the reference sheet waits for a look before it auto-approves. Sent ONLY when set. An unattended * caller (an agent) should pass it: with no value the gate waits for a person for ever. */ referenceReviewSeconds?: number; /** The caller's own key (8-96 chars). Default: a fresh UUID. */ idempotencyKey?: string; } export interface StartRetryOptions { /** Total tries of the create call (default 3). Every try carries the SAME idempotency key. */ attempts?: number; /** Backoff before try n+1 (default 1s, 3s). */ backoffMs?: (attempt: number) => number; sleep?: (ms: number) => Promise; /** One human line per retry (the caller sends it to stderr). */ onRetry?: (line: string) => void; } /** A create that may have reached the server: no answer (timeout, dropped connection) or a gateway/server error. */ export declare function isAmbiguousCreateFailure(err: unknown): boolean; /** * Create the avatar job. The idempotency key is chosen ONCE and sent on every try, so a timeout after the server had * already created the job re-attaches to that job on the next try (the backend returns the existing job for the same * owner and key) instead of creating and charging a second one. The key is returned so a caller whose own process * died can re-run the start with it. */ export declare function startDriverAvatarJob(api: DriverApi, input: StartDriverAvatarInput, newKey?: () => string, retry?: StartRetryOptions): Promise; /** The driver job, or null when the id is not a driver job (a legacy generation job id, a prop). */ export declare function getDriverJob(api: DriverApi, id: string): Promise; export declare class DriverVisibilityError extends Error { constructor(requested: string, actual: string); } export declare class DriverTimeoutError extends Error { readonly job: DriverJobView; constructor(job: DriverJobView, timeoutMs: number); } /** One human line for an event, or null when it carries nothing a person needs. */ export declare function describeDriverEvent(e: DriverEvent): string | null; export interface ResumeDriverOptions { /** The user's --visibility, if any. Compared with the job's; never applied. */ visibility?: DriverVisibility; timeoutMs?: number; pollIntervalMs?: number; /** One human progress line (the caller sends it to stderr). */ progress?: (line: string) => void; sleep?: (ms: number) => Promise; now?: () => number; /** Echoed into the printed job JSON as `idempotencyKey`, so a `generate` run records the key its start used. */ idempotencyKey?: string; } /** * Wait for a driver job to reach a terminal status. Returns null when `id` is not a driver job (the caller falls * back to the legacy loop). Throws DriverVisibilityError / DriverTimeoutError / the transport error; a `failed` * job is RETURNED (the caller prints it and exits 1), not thrown. */ export declare function waitForDriverJob(api: DriverApi, id: string, options?: ResumeDriverOptions): Promise; export interface DriverIo { stdout: (text: string) => void; stderr: (text: string) => void; } /** The JSON a consumer reads: the backend's view plus `publishedItemId` once the item exists. */ export declare function driverOutput(job: DriverJobView): DriverJobView & { publishedItemId?: string; }; export declare function renderDriverFailure(job: DriverJobView): string; /** * Wait, print, and return the process exit code. Returns null when `id` is not a driver job. * Never calls process.exit, so piped output is not cut. */ export declare function runDriverResume(api: DriverApi, id: string, options: ResumeDriverOptions, io: DriverIo): Promise;