import type { TrackSource } from '@livekit/protocol';
import { JobType } from '@livekit/protocol';
import { type Throws } from '@livekit/throws-transformer/throws';
import { EventEmitter } from 'node:events';
import type { JobProcess, RunningJobInfo } from './job.js';
import { JobRequest } from './job.js';
/** Necessary credentials not provided and not found in an appropriate environment variable. */
export declare class MissingCredentialsError extends Error {
    constructor(msg?: string);
}
/** Worker did not run as expected. */
export declare class WorkerError extends Error {
    constructor(msg?: string);
}
/** @internal */
export declare const defaultInitializeProcessFunc: (_: JobProcess) => JobProcess<Record<string, unknown>>;
/** Participant permissions to pass to every agent spun up by this worker. */
export declare class WorkerPermissions {
    canPublish: boolean;
    canSubscribe: boolean;
    canPublishData: boolean;
    canUpdateMetadata: boolean;
    canPublishSources: TrackSource[];
    hidden: boolean;
    constructor(canPublish?: boolean, canSubscribe?: boolean, canPublishData?: boolean, canUpdateMetadata?: boolean, canPublishSources?: TrackSource[], hidden?: boolean);
}
/**
 * Data class describing worker behaviour.
 *
 * @remarks
 * The Agents framework provides sane worker defaults, and works out-of-the-box with no tweaking
 * necessary. The only mandatory parameter is `agent`, which points to the entry function.
 *
 * This class is mostly useful in conjunction with {@link cli.runApp}.
 */
export declare class ServerOptions {
    agent: string;
    requestFunc: (job: JobRequest) => Promise<void>;
    loadFunc: (worker: AgentServer) => Promise<number>;
    loadThreshold: number;
    numIdleProcesses: number;
    drainTimeout: number;
    shutdownProcessTimeout: number;
    /**
     * Maximum time to wait for `onSessionEnd`. Defaults to five minutes.
     */
    sessionEndTimeout: number;
    initializeProcessTimeout: number;
    permissions: WorkerPermissions;
    agentName: string;
    agentNameIsEnv: boolean;
    serverType: JobType;
    maxRetry: number;
    wsURL: string;
    apiKey?: string;
    apiSecret?: string;
    workerToken?: string;
    host: string;
    port: number;
    logLevel: string;
    production: boolean;
    simulation: boolean;
    jobMemoryWarnMB: number;
    jobMemoryLimitMB: number;
    /** @param options - Worker options */
    constructor({ agent, requestFunc, loadFunc, loadThreshold, numIdleProcesses, drainTimeout, shutdownProcessTimeout, sessionEndTimeout, initializeProcessTimeout, permissions, agentName, agentNameIsEnv, serverType, maxRetry, wsURL, apiKey, apiSecret, workerToken, host, port, logLevel, production, simulation, jobMemoryWarnMB, jobMemoryLimitMB, }: {
        /**
         * Path to a file that has {@link Agent} as a default export, dynamically imported later for
         * entrypoint and prewarm functions
         */
        agent: string;
        requestFunc?: (job: JobRequest) => Promise<void>;
        /** Called to determine the current load of the worker. Should return a value between 0 and 1. */
        loadFunc?: (worker: AgentServer) => Promise<number>;
        /** When the load exceeds this threshold, the worker will be marked as unavailable. */
        loadThreshold?: number;
        numIdleProcesses?: number;
        /** Number of milliseconds to wait for current jobs to finish upon shutdown. */
        drainTimeout?: number;
        shutdownProcessTimeout?: number;
        /**
         * Maximum number of milliseconds to wait for `onSessionEnd`.
         */
        sessionEndTimeout?: number;
        initializeProcessTimeout?: number;
        permissions?: WorkerPermissions;
        /**
         * Set agentName to enable explicit dispatch. When explicit dispatch is enabled, jobs will not
         * be dispatched to rooms automatically. Instead, you can either specify the agent(s) to be
         * dispatched in the end-user's token, or use the AgentDispatch.createDispatch API.
         *
         * By default it uses `LIVEKIT_AGENT_NAME` from environment.
         */
        agentName?: string;
        /**
         * Internal flag indicating that `agentName` was resolved from `LIVEKIT_AGENT_NAME`. Forwarded
         * through ServerOptions re-construction (e.g. cli.ts spread) so the env-source signal isn't
         * lost.
         */
        agentNameIsEnv?: boolean;
        serverType?: JobType;
        maxRetry?: number;
        wsURL?: string;
        apiKey?: string;
        apiSecret?: string;
        workerToken?: string;
        host?: string;
        port?: number;
        logLevel?: string;
        production?: boolean;
        simulation?: boolean;
        jobMemoryWarnMB?: number;
        jobMemoryLimitMB?: number;
    });
}
/**
 * Central orchestrator for all processes and job requests.
 *
 * @remarks
 * For most usecases, Worker should not be initialized or handled directly; you should instead call
 * for its creation through {@link cli.runApp}. This could, however, be useful in situations where
 * you don't have access to a command line, such as a headless program, or one that uses Agents
 * behind a wrapper.
 */
export declare class AgentServer {
    #private;
    event: EventEmitter<[never]>;
    constructor(opts: ServerOptions);
    /** @throws {@link WorkerError} if worker failed to connect or already running */
    run(): Promise<void>;
    get id(): string;
    get activeJobs(): RunningJobInfo[];
    /** @throws {@link WorkerError} if worker did not drain in time */
    drain(timeout?: number): Promise<Throws<void, WorkerError | Error>>;
    simulateJob(roomName: string, participantIdentity?: string): Promise<void>;
    close(): Promise<void>;
}
/**
 * @deprecated Use {@link AgentServer} instead. This alias is provided for backward compatibility.
 */
export declare const Worker: typeof AgentServer;
/**
 * @deprecated Use {@link ServerOptions} instead. This alias is provided for backward compatibility.
 */
export declare const WorkerOptions: typeof ServerOptions;
//# sourceMappingURL=worker.d.ts.map