LiveKit Worker Setup Coordinator (src/worker-setup.ts)

mastra · integrations/livekit/src/worker-setup.ts · typescript · Apache-2.0
voice, infra, tag:livekit, tag:async, tag:coordination

Coordinates LiveKit plugin registration and worker startup sequences to ensure inference runners initialize correctly. Reuse when setting up real-time voice agents.

// Source: https://github.com/mastra-ai/mastra | License: Apache-2.0 | Copyright 2025 Kepler Software, Inc
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Coordination between worker definition and worker startup. LiveKit plugins register
 * their inference runners at module-import time, and the AgentServer only spawns the
 * inference process for runners registered before it starts — so plugin imports kicked
 * off by `createLiveKitWorker()` must complete before `runLiveKitWorker()` boots the
 * server.
 */
const pendingSetup: Promise<unknown>[] = [];
const requestedEouMethods = new Set<string>();

export function queueWorkerSetup(setup: Promise<unknown>): void {
  pendingSetup.push(setup);
}

export function workerSetupComplete(): Promise<unknown> {
  return Promi

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key