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 cli.runApp.

Constructors

  • Parameters

    • options: {
          agent: string;
          agentName?: string;
          agentNameIsEnv?: boolean;
          apiKey?: string;
          apiSecret?: string;
          host?: string;
          initializeProcessTimeout?: number;
          jobMemoryLimitMB?: number;
          jobMemoryWarnMB?: number;
          loadFunc?: ((worker) => Promise<number>);
          loadThreshold?: number;
          logLevel?: string;
          maxRetry?: number;
          numIdleProcesses?: number;
          permissions?: WorkerPermissions;
          port?: number;
          production?: boolean;
          requestFunc?: ((job) => Promise<void>);
          serverType?: JobType;
          shutdownProcessTimeout?: number;
          workerToken?: string;
          wsURL?: string;
      }

      Worker options

      • agent: string

        Path to a file that has Agent as a default export, dynamically imported later for entrypoint and prewarm functions

      • Optional agentName?: string

        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.

      • Optional agentNameIsEnv?: boolean

        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.

      • Optional apiKey?: string
      • Optional apiSecret?: string
      • Optional host?: string
      • Optional initializeProcessTimeout?: number
      • Optional jobMemoryLimitMB?: number
      • Optional jobMemoryWarnMB?: number
      • Optional loadFunc?: ((worker) => Promise<number>)

        Called to determine the current load of the worker. Should return a value between 0 and 1.

          • (worker): Promise<number>
          • Parameters

            Returns Promise<number>

      • Optional loadThreshold?: number

        When the load exceeds this threshold, the worker will be marked as unavailable.

      • Optional logLevel?: string
      • Optional maxRetry?: number
      • Optional numIdleProcesses?: number
      • Optional permissions?: WorkerPermissions
      • Optional port?: number
      • Optional production?: boolean
      • Optional requestFunc?: ((job) => Promise<void>)
          • (job): Promise<void>
          • Parameters

            Returns Promise<void>

      • Optional serverType?: JobType
      • Optional shutdownProcessTimeout?: number
      • Optional workerToken?: string
      • Optional wsURL?: string

    Returns ServerOptions

Properties

agent: string
agentName: string
agentNameIsEnv: boolean
apiKey?: string
apiSecret?: string
host: string
initializeProcessTimeout: number
jobMemoryLimitMB: number
jobMemoryWarnMB: number
loadFunc: ((worker) => Promise<number>)

Type declaration

    • (worker): Promise<number>
    • Parameters

      Returns Promise<number>

loadThreshold: number
logLevel: string
maxRetry: number
numIdleProcesses: number
permissions: WorkerPermissions
port: number
production: boolean
requestFunc: ((job) => Promise<void>)

Type declaration

    • (job): Promise<void>
    • Parameters

      Returns Promise<void>

serverType: JobType
shutdownProcessTimeout: number
workerToken?: string
wsURL: string