import type { OperationLifecycleLike } from '../types/lifecycle.js'; /** A job in an in-process queue. */ export interface QueueJob { /** The job's id. */ id: string; /** What the worker receives. */ payload: T; /** Times it has been tried. */ attempts: number; /** Where it stands. */ status: 'queued' | 'running' | 'completed' | 'failed'; /** What the worker returned. */ result?: unknown; /** Why the last attempt failed. */ error?: string; } /** Options for an in-process job queue. */ export interface QueueOptions { /** Jobs run at once. Defaults to 1. */ concurrency?: number; /** Tries per job before it is marked failed. Defaults to 1. */ maxAttempts?: number; /** * Runs every attempt as one operation of a client's lifecycle, labelled `job`: pass * `ai.lifecycle`. A refused job fails like any other, and is retried if attempts remain. */ lifecycle?: OperationLifecycleLike; } /** * An in-process job queue with concurrency and retries. Jobs are lost on restart; the operations * family is the durable option. */ export declare class JobQueue { private worker; private options; private jobs; private running; constructor(worker: (payload: TPayload, job: QueueJob) => Promise, options?: QueueOptions); /** Adds a job and starts it when a slot is free. */ enqueue(payload: TPayload, id?: string): QueueJob; /** Every job, in the order added. */ list(): Array>; /** Reads a job. */ get(id: string): QueueJob | undefined; private drain; private run; }