import type { PendingVersion } from './moveUx'; import type { VisualQaVerdictItem } from './types'; import { type Freshness } from './harnessFreshness'; export type HostedJobStatus = 'queued' | 'rendering' | 'passed' | 'failed' | 'error'; export interface HostedJob { id: string; itemId: string; packageVersionId: string; manifestCid: string; status: HostedJobStatus; attempts: number; maxAttempts?: number; requestedBy?: string; trigger?: string; queuedAt?: string; startedAt?: string | null; finishedAt?: string | null; leaseExpiresAt?: string | null; runId: string | null; /** `warn` (avatars only): status is `passed`, nothing blocks, the avatar was released privately with warnings. */ verdict: 'pass' | 'warn' | 'fail' | 'error' | null; contactSheetUrl: string | null; reasons: string[]; error: string | null; } export interface HostedRenderTarget { itemId: string; title: string | null; packageVersionId: string; packageId: string; packageVersion: string; manifestCid: string; category: string; vehicleChecksum: string | null; /** A version move's job: the vehicle package the refused move carried (vehicles), or null. */ vehiclePackage?: Record | null; } export interface HostedClaim { job: HostedJob; leaseToken: string; target?: HostedRenderTarget; } export interface HostedRequestResult { alreadyPassed: boolean; exempt: boolean; job: HostedJob | null; skipped?: string; message?: string; retryAfter?: string; } export declare class HostedApiError extends Error { status: number; constructor(status: number, message: string); } export declare const isTerminal: (s: HostedJobStatus) => boolean; export declare function requestHostedRun(apiBase: string, token: string, itemId: string, retry?: boolean): Promise; /** * `--retry` (requeue): ask for another render of a version whose hosted job ended failed/error (an exhausted job included: * the new job starts again at attempt 1). The backend allows one requeue per cooldown after the last job finished and * answers `skipped: retry_too_soon` + `retryAfter` inside it; this waits that out (bounded by `maxWaitMs`) and asks again * instead of leaving the caller looking at the old, finished job. */ export declare function requestHostedRequeue(apiBase: string, token: string, itemId: string, opts?: { maxWaitMs?: number; onWait?: (line: string) => void; sleepFn?: (ms: number) => Promise; nowFn?: () => number; }): Promise; export interface ItemVisualQaStatus { hostedJob: HostedJob | null; /** `passed` is true for a `warn` verdict too (nothing blocks); `verdict` says which. */ currentVersion: { packageVersionId: string; manifestCid: string | null; passed: boolean; runId: string | null; verdict?: string; warnings?: VisualQaVerdictItem[]; blockers?: VisualQaVerdictItem[]; } | null; runs: Array<{ id?: string; verdict?: string; createdAt?: string; contactSheetUrl?: string | null; reasons?: string[]; warnings?: VisualQaVerdictItem[]; blockers?: VisualQaVerdictItem[]; packageVersion?: string | null; }>; /** Avatars: the release status (`state`: `released_private` for a warn release), with the verdict, warnings and blockers. Absent on other items and older backends. */ release?: { state?: string; verdict?: string; warnings?: VisualQaVerdictItem[]; blockers?: VisualQaVerdictItem[]; [k: string]: unknown; } | null; /** Sealed versions of the item's package that are not current, each with its latest run and hosted job. Absent on a * backend that does not report them yet. */ pendingVersions: PendingVersion[]; } export declare function getItemVisualQaStatus(apiBase: string, itemId: string): Promise; /** One human line for a job, e.g. `rendering (attempt 1/3) — claimed 42 s ago`. */ export declare function describeJob(job: HostedJob | null, now?: number): string; export interface PollOptions { intervalMs?: number; timeoutMs?: number; onUpdate?: (job: HostedJob) => void; } /** Poll `GET .../visual-qa` until the job for the item's current version is terminal (or the timeout passes). */ export declare function waitForHostedJob(apiBase: string, itemId: string, jobId: string | null, opts?: PollOptions): Promise<{ job: HostedJob | null; timedOut: boolean; }>; /** 0 pass (and 0 for a `warn`: the job's status is `passed`, the avatar was released privately; 0 too for a critic-only fail/error, which is advisory), 1 fail, 2 error / anything that is not a judged pass, warn or fail. */ export declare function exitCodeForJob(job: HostedJob | null, timedOut?: boolean, blockers?: readonly VisualQaVerdictItem[]): number; /** Sign in as the bot account exactly as the website's login does: POST /auth/login -> access_token. */ export declare function botLogin(apiBase: string, email: string, password: string): Promise; export declare function claimJob(apiBase: string, token: string, worker: string, leaseSeconds?: number): Promise; export declare const heartbeatJob: (apiBase: string, token: string, id: string, leaseToken: string, leaseSeconds?: number) => Promise<{ status: number; data: unknown; }>; /** `kind: 'mirror_lag'` tells the backend the render never started because the CDN mirror did not serve the model yet: the * attempt is handed back (it says nothing about the item). Any other failure uses an attempt, as before. */ export declare const failJob: (apiBase: string, token: string, id: string, leaseToken: string, error: string, kind?: "mirror_lag") => Promise<{ status: number; data: unknown; }>; /** The signature of a render that could not fetch the pinned model (the mirror had not caught up). */ export declare const MODEL_NOT_FETCHED_RE: RegExp; export interface WorkerOptions { apiBase: string; webBase: string; email: string; password: string; worker?: string; /** Stop after this many jobs (default: unlimited). */ maxJobs?: number; /** Stop claiming new jobs after this long (default: unlimited). */ maxMinutes?: number; /** Keep polling an empty queue this long before exiting (0 = exit as soon as the queue is empty). */ idleExitMinutes?: number; pollSeconds?: number; /** Pause after reporting a failed render before claiming again, so a persistent failure does not burn every attempt at once (default 60). */ failBackoffSeconds?: number; leaseSeconds?: number; /** Hard limit for one render. */ renderTimeoutSeconds?: number; out?: string; chrome?: string; cliVersion: string; /** Asked before a claim (at most every `freshnessEverySeconds`): `stale: true` stops the worker so the next one starts on current source. */ freshness?: () => Freshness | Promise; freshnessEverySeconds?: number; log?: (line: string) => void; } export interface WorkerJobResult { jobId: string; itemId: string; outcome: 'submitted' | 'failed_reported' | 'abandoned'; verdict?: string; contactSheetUrl?: string; error?: string; seconds: number; } export interface WorkerSummary { jobs: WorkerJobResult[]; exit: 'idle' | 'max_jobs' | 'max_minutes' | 'stale'; } export declare const HOSTED_MAX_POLL_SECONDS = 3; /** Pause after a failed render. The backend now sends a retried job to the back of the line (fresh jobs first), so this * only has to keep a crash loop from hammering the GPU; it used to be 60 s of idle GPU per failed attempt. */ export declare const HOSTED_DEFAULT_FAIL_BACKOFF_SECONDS = 10; export declare function runHostedWorker(opts: WorkerOptions): Promise;