/** Options for {@link RecordingOptions}. */ export type RecordingOptionsInit = { /** Record participant video. Defaults to `false`. */ video?: boolean; /** Record screen-share. Defaults to `false`. */ screenShare?: boolean; }; /** Resolved recording toggles for a room. Build with the {@link RecordingOptions} factory. */ export type RecordingOptions = { video: boolean; screenShare: boolean; }; /** Configure which media a room recording captures. See {@link RecordingOptionsInit}. */ export declare function RecordingOptions(init?: RecordingOptionsInit): RecordingOptions; /** Options for {@link WebSocketConfig}. */ export type WebSocketConfigInit = { /** WebSocket port. Defaults to `8080`. */ port?: number; /** WebSocket path. Defaults to `'/ws'`. */ path?: string; }; /** Resolved WebSocket transport settings. Build with the {@link WebSocketConfig} factory. */ export type WebSocketConfig = { port: number; path: string; }; /** Configure the WebSocket transport endpoint. See {@link WebSocketConfigInit}. */ export declare function WebSocketConfig(init?: WebSocketConfigInit): WebSocketConfig; /** Options for {@link WebRTCConfig}. */ export type WebRTCConfigInit = { /** Signaling server URL. Defaults to `null` (the default). */ signalingUrl?: string | null; /** Signaling transport type. Defaults to `'websocket'`. */ signalingType?: string; /** ICE server entries (STUN/TURN). Defaults to `null` (the default). */ iceServers?: any[] | null; }; /** Resolved WebRTC transport settings. Build with the {@link WebRTCConfig} factory. */ export type WebRTCConfig = { signalingUrl: string | null; signalingType: string; iceServers: any[] | null; }; /** Configure the WebRTC transport (signaling and ICE servers). See {@link WebRTCConfigInit}. */ export declare function WebRTCConfig(init?: WebRTCConfigInit): WebRTCConfig; /** Options for {@link TracesOptions}. */ export type TracesOptionsInit = { /** Whether tracing is enabled. Defaults to `true`. */ enabled?: boolean; /** OTLP endpoint to export traces to. Defaults to `null` (no external export). */ exportUrl?: string | null; /** Headers sent with trace exports (e.g. auth). Defaults to `null`. */ exportHeaders?: Record | null; }; /** Resolved tracing configuration. Build with the {@link TracesOptions} factory. */ export type TracesOptions = { enabled: boolean; exportUrl: string | null; exportHeaders: Record | null; }; /** Configure distributed tracing export. See {@link TracesOptionsInit}. */ export declare function TracesOptions(init?: TracesOptionsInit): TracesOptions; /** Options for {@link MetricsOptions}. */ export type MetricsOptionsInit = { /** Whether metrics collection is enabled. Defaults to `true`. */ enabled?: boolean; /** OTLP endpoint to export metrics to. Defaults to `null` (no external export). */ exportUrl?: string | null; /** Headers sent with metric exports (e.g. auth). Defaults to `null`. */ exportHeaders?: Record | null; }; /** Resolved metrics configuration. Build with the {@link MetricsOptions} factory. */ export type MetricsOptions = { enabled: boolean; exportUrl: string | null; exportHeaders: Record | null; }; /** Configure metrics export. See {@link MetricsOptionsInit}. */ export declare function MetricsOptions(init?: MetricsOptionsInit): MetricsOptions; /** Options for {@link LoggingOptions}. */ export type LoggingOptionsInit = { /** Whether log export is enabled. Defaults to `false`. */ enabled?: boolean; /** Minimum log level(s) to export (e.g. `'INFO'`). Defaults to `'INFO'`. */ level?: string | string[]; /** Endpoint to export logs to. Defaults to `null` (no external export). */ exportUrl?: string | null; /** Headers sent with log exports (e.g. auth). Defaults to `null`. */ exportHeaders?: Record | null; }; /** Resolved logging configuration. Build with the {@link LoggingOptions} factory. */ export type LoggingOptions = { enabled: boolean; level: string | string[]; exportUrl: string | null; exportHeaders: Record | null; }; /** Configure log export. See {@link LoggingOptionsInit}. */ export declare function LoggingOptions(init?: LoggingOptionsInit): LoggingOptions; /** Options for {@link ObservabilityOptions}. */ export type ObservabilityOptionsInit = { /** Tracing settings. See {@link TracesOptions}. Defaults to `null`. */ traces?: TracesOptions | null; /** Metrics settings. See {@link MetricsOptions}. Defaults to `null`. */ metrics?: MetricsOptions | null; /** Logging settings. See {@link LoggingOptions}. Defaults to `null`. */ logs?: LoggingOptions | null; }; /** Bundled observability configuration (traces, metrics, logs). Build with the {@link ObservabilityOptions} factory. */ export type ObservabilityOptions = { traces: TracesOptions | null; metrics: MetricsOptions | null; logs: LoggingOptions | null; }; /** Group tracing, metrics, and logging settings into one object. See {@link ObservabilityOptionsInit}. */ export declare function ObservabilityOptions(init?: ObservabilityOptionsInit): ObservabilityOptions; /** Options for {@link RoomOptions}. */ export type RoomOptionsInit = { /** Room to join. When omitted, a room is created on demand. Defaults to `null`. */ roomId?: string | null; /** ZRT auth token. Falls back to environment credentials. Defaults to `null`. */ authToken?: string | null; /** Display name for the agent participant. Defaults to `'Agent'`. */ name?: string | null; /** Fixed participant id for the agent. Defaults to `null` (assigned automatically). */ agentParticipantId?: string | null; /** Whether to expose a playground URL for this room. Defaults to `true`. */ playground?: boolean; /** Enable video/vision input. Defaults to `false`. */ vision?: boolean; /** Enable session recording. Defaults to `false`. */ recording?: boolean; recordingOptions?: RecordingOptions | null; /** Avatar configuration for the agent participant. Defaults to `null`. */ avatar?: any; /** Whether the agent joins the meeting on start. Defaults to `true`. */ joinMeeting?: boolean | null; /** Callback invoked on a room error. Defaults to `null`. */ onRoomError?: ((err: any) => void) | null; /** Callback invoked when the session ends, with end info. Defaults to `null`. */ onSessionEnd?: ((info: any) => void) | null; /** End the session automatically when the agent completes. Defaults to `true`. */ autoEndSession?: boolean; /** Maximum session length in seconds; `null` for no limit. Defaults to `15`. */ sessionTimeoutSeconds?: number | null; /** Seconds to wait with no participant before ending; `null` for no limit. Defaults to `90`. */ noParticipantTimeoutSeconds?: number | null; /** Base URL of the signaling service. Defaults to `ZRT_SIGNALING_URL` or `api.videosdk.live`. */ signalingBaseUrl?: string | null; /** Enable background audio playback. Defaults to `false`. */ backgroundAudio?: boolean; /** Enable the audio listener. Defaults to `false`. */ audioListenerEnabled?: boolean; /** Forward session logs to the dashboard. Note: dashboard logging is always enabled in the resolved options. */ sendLogsToDashboard?: boolean; /** Minimum log level for dashboard logs (`DEBUG`/`INFO`/`WARNING`/`ERROR`/`CRITICAL`). Defaults to `'INFO'`. */ dashboardLogLevel?: string; /** Tracing settings. See {@link TracesOptions}. Defaults to `null`. */ traces?: TracesOptions | null; /** Metrics settings. See {@link MetricsOptions}. Defaults to `null`. */ metrics?: MetricsOptions | null; /** Logging settings. See {@link LoggingOptions}. Defaults to `null`. */ logs?: LoggingOptions | null; /** WebSocket transport settings. See {@link WebSocketConfig}. Defaults to `null`. */ websocket?: WebSocketConfig | null; /** WebRTC transport settings. See {@link WebRTCConfig}. Defaults to `null`. */ webrtc?: WebRTCConfig | null; /** Bundled observability settings; used to fill any of `traces`/`metrics`/`logs` left unset. See {@link ObservabilityOptions}. Defaults to `null`. */ observability?: ObservabilityOptions | null; /** Transport mode selector. Defaults to `null` (the default). */ transportMode?: any; }; /** * Resolved room configuration. Build with the {@link RoomOptions} factory. * Each setting is exposed under both its camelCase name and a read-only * snake_case alias (e.g. {@link RoomOptions.roomId} / `room_id`) for compatibility. */ export type RoomOptions = { roomId: string | null; authToken: string | null; name: string | null; agentParticipantId: string | null; playground: boolean; vision: boolean; recording: boolean; recordingOptions: RecordingOptions | null; avatar: any; joinMeeting: boolean | null; onRoomError: ((err: any) => void) | null; onSessionEnd: ((info: any) => void) | null; autoEndSession: boolean; sessionTimeoutSeconds: number | null; noParticipantTimeoutSeconds: number | null; signalingBaseUrl: string | null; backgroundAudio: boolean; audioListenerEnabled: boolean; sendLogsToDashboard: boolean; dashboardLogLevel: string; traces: TracesOptions | null; metrics: MetricsOptions | null; logs: LoggingOptions | null; websocket: WebSocketConfig | null; webrtc: WebRTCConfig | null; observability: ObservabilityOptions | null; transportMode: any; readonly room_id: string | null; readonly auth_token: string | null; readonly agent_participant_id: string | null; readonly auto_end_session: boolean; readonly session_timeout_seconds: number | null; readonly no_participant_timeout_seconds: number | null; readonly signaling_base_url: string | null; readonly background_audio: boolean; readonly audio_listener_enabled: boolean; readonly send_logs_to_dashboard: boolean; readonly dashboard_log_level: string; readonly on_room_error: ((err: any) => void) | null; readonly on_session_end: ((info: any) => void) | null; }; /** * Configure the room a session joins. Applies defaults, fills `traces`/`metrics`/ * `logs` from `observability` when not set individually, normalizes * `dashboardLogLevel` (falling back to `'INFO'` if invalid), and populates the * read-only snake_case aliases. See {@link RoomOptionsInit}. */ export declare function RoomOptions(init?: RoomOptionsInit): RoomOptions; /** Options for {@link Options} (worker/job configuration). */ export type OptionsInit = { /** Executor type. Deprecated and has no effect; setting it logs a warning. */ executorType?: any; /** Number of idle worker slots to keep warm. Defaults to `1`. */ numIdleProcesses?: number; /** Seconds allowed for initialization. Defaults to `10`. */ initializeTimeout?: number; /** Seconds allowed for graceful shutdown. Defaults to `60`. */ closeTimeout?: number; /** Memory usage (MB) at which a warning is logged. Defaults to `500.0`. */ memoryWarnMb?: number; /** Memory cap (MB); `0` disables the limit. Defaults to `0`. */ memoryLimitMb?: number; /** Seconds between liveness pings. Defaults to `30`. */ pingInterval?: number; /** Maximum concurrent sessions. Defaults to `1`. */ maxProcesses?: number; /** Registration id for the agent. Defaults to `'ZeroRuntimeAgent'`. */ agentId?: string; /** ZRT auth token. Falls back to environment credentials. Defaults to `null`. */ authToken?: string | null; /** Room participant permissions. Defaults to `null`. */ permissions?: any; /** Maximum registration retry attempts. Defaults to `16`. */ maxRetry?: number; /** Load fraction (0-1) above which the worker reports itself busy. Defaults to `0.75`. */ loadThreshold?: number; /** * Register with the Zero Runtime registry (serve mode) rather than running the * entrypoint once locally. **/ register?: boolean; /** Base URL of the signaling/registry service. Defaults to `ZRT_SIGNALING_URL` or `api.videosdk.live`. */ signalingBaseUrl?: string; /** Bind host for local servers. Defaults to `'0.0.0.0'`. */ host?: string; /** Bind port. Defaults to `8081`. */ port?: number; /** Log level (`DEBUG`/`INFO`/`WARNING`/`ERROR`/`CRITICAL`). Defaults to `'INFO'`. */ logLevel?: string; /** Start the local debug HTTP server. Defaults to `true`. */ debugEnabled?: boolean; /** Port for the debug server. Defaults to `8081`. */ debugPort?: number; }; /** Resolved worker/job configuration. Build with the {@link Options} factory. */ export type Options = { executorType: any; numIdleProcesses: number; initializeTimeout: number; closeTimeout: number; memoryWarnMb: number; memoryLimitMb: number; pingInterval: number; maxProcesses: number; agentId: string; authToken: string | null; permissions: any; maxRetry: number; loadThreshold: number; register: boolean; signalingBaseUrl: string; host: string; port: number; logLevel: string; debugEnabled: boolean; debugPort: number; }; /** Build worker/job {@link Options} with defaults applied. See {@link OptionsInit}. */ export declare function Options(init?: OptionsInit): Options; /** Read-only view of the active session's room. @internal */ export declare class _RoomProxy { private readonly _session; constructor(session: any); /** The active session's id, or `null` if unavailable. @internal */ get _session_id(): string | null; /** The active session's id, or `null` if unavailable. */ get sessionId(): string | null; } /** Options for constructing a {@link JobContext}. */ export type JobContextInit = { /** Room configuration for the job. See {@link RoomOptions}. */ roomOptions: RoomOptions; /** Arbitrary per-job metadata. Defaults to `{}`. */ metadata?: Record | null; /** Reserved event-loop handle; rarely needed. Defaults to `null`. */ loop?: any; }; declare class JobContextImpl { /** Room configuration for this job. See {@link RoomOptions}. */ roomOptions: RoomOptions; /** Arbitrary per-job metadata (e.g. dispatch/SIP details). */ metadata: Record; private _loop; private _shutdownCallbacks; private readonly _meetingJoined; private _pipeline; private _shuttingDown; registeredMode: boolean; registeredSessionId: string; registeredRegistry: any; registeredAgentOverride: any; registeredDispatchMetadata: Record; registrationProbe: boolean; _activeSession: any; _workerJob: any; _captured_agent: any; _captured_pipeline: any; _captured_recording: any; constructor(init: JobContextInit); _setPipelineInternal(pipeline: any): void; registerSession(session: any): void; /** A read-only view of the active session's room, or `null` if no session is running. */ get room(): _RoomProxy | null; get isRegistrationProbe(): boolean; /** Mark the job as connected, signaling any waiters on {@link JobContext.waitForMeetingJoined}. */ connect(): Promise; /** Close the active session and run all registered shutdown callbacks. Idempotent. */ shutdown(): Promise; /** Register a callback to run during {@link JobContext.shutdown}. May be async. */ addShutdownCallback(callback: () => unknown): void; /** Snake_case alias for {@link JobContext.addShutdownCallback}. */ add_shutdown_callback(callback: () => unknown): void; /** Signal that the meeting has been joined, releasing {@link JobContext.waitForMeetingJoined} waiters. */ notifyMeetingJoined(): void; /** Snake_case alias for {@link JobContext.notifyMeetingJoined}. */ notify_meeting_joined(): void; /** * Wait until the meeting is joined. * @param timeout - Maximum seconds to wait. Defaults to `30`. * @returns `true` if joined within the timeout, `false` otherwise. */ waitForMeetingJoined(timeout?: number): Promise; /** Snake_case alias for {@link JobContext.waitForMeetingJoined}. */ wait_for_meeting_joined(timeout?: number): Promise; /** * Wait until a participant has joined the room. Blocks on the active session's * participant-arrival (or its shutdown, whichever comes first); returns * immediately when no session is active yet. * @param participantId - A specific id, or `null` for the next participant. * @returns The given id, or `'participant'` when none is provided. */ waitForParticipant(participantId?: string | null): Promise; /** Snake_case alias for {@link JobContext.waitForParticipant}. */ wait_for_participant(participantId?: string | null): Promise; /** * Register a session and run it until shutdown, creating a room first if none * is set. No-op when `session` is falsy. * @param session - The session to run. * @param waitForParticipant - Wait for a participant before starting. Defaults to `false`. */ runUntilShutdown(session?: any, waitForParticipant?: boolean): Promise; /** Snake_case alias for {@link JobContext.runUntilShutdown}. */ run_until_shutdown(session?: any, waitForParticipant?: boolean): Promise; private _buildRoomConfig; /** * Create a new room via the signaling service and return its id. * @param authToken - ZRT auth token used to authorize room creation. * @param signalingBaseUrl - Signaling base URL; defaults to `ZRT_SIGNALING_URL` or `api.videosdk.live`. * @throws If the request fails or returns no room id. */ static createRoomStatic(authToken: string, signalingBaseUrl?: string): Promise; /** Snake_case alias for {@link JobContext.createRoomStatic}. */ static create_room_static(authToken: string, signalingBaseUrl?: string): Promise; /** * Resolve this job's room id, creating a room if necessary, and cache it on * {@link JobContext.roomOptions}. Uses the existing id, then `ZRT_ROOM_ID`, then creates * a new room. Returns the id directly when already known, or a promise when a room must * be created. * @throws If a room must be created but no auth token is available. */ getRoomId(): string | Promise; get_room_id(): string | Promise; } /** Opaque token from {@link setActiveJobContext} used to restore the previous context. @internal */ export type JobContextToken = { readonly previous: JobContext | null; readonly __jobCtxToken: true; }; /** Return the {@link JobContext} active for the current async context, or `null`. */ export declare function getActiveJobContext(): JobContext | null; /** Set the active {@link JobContext} for the current async context. @internal */ export declare function setActiveJobContext(ctx: JobContext | null, token?: JobContextToken | null): JobContextToken; /** Set the process-wide fallback active {@link JobContext}. @internal */ export declare function _setActiveJobContextGlobal(ctx: JobContext | null): void; /** Thrown to unwind once a registration probe has gathered the agent's config. @internal */ export declare class _RegistrationProbeComplete extends Error { readonly __registrationProbeComplete = true; constructor(); } /** Alias for {@link _RegistrationProbeComplete}. @internal */ export declare const RegistrationProbeComplete: typeof _RegistrationProbeComplete; type JobctxFactory = (() => JobContext) | JobContext | null | undefined; /** Tracks a single running session and its job/status for worker stats. @internal */ export declare class _RunnerInfo { session: any; job: any; status: string; sessionId: string; constructor(session: any, job: any, status?: string, sessionId?: string); } /** * Your agent's main function, invoked once per job with its {@link JobContext}. * May be sync or async; it typically starts a session and runs until shutdown. */ export type Entrypoint = (ctx: JobContext) => Promise | void; declare class WorkerJobImpl { private readonly _entrypoint; private readonly _jobctxFactory; private readonly _options; private readonly _onReady; private _currentJobs; private _debugServer; private _registration; private _draining; constructor(entrypoint: Entrypoint, jobctx?: JobctxFactory, options?: Options | null, onReady?: (() => void) | null); /** The worker's resolved {@link Options}. */ get options(): Options; /** A snapshot of worker stats (agent id, current/max jobs, load, registration state). */ getStats(): Record; _registerRunner(session: any, roomOptions: any): void; _unregisterRunner(session: any): void; /** * Run the worker until shutdown (Ctrl+C / SIGTERM). When * {@link Options.register} is set, registers with the Zero Runtime and serves * dispatched sessions; otherwise runs the entrypoint once locally. */ start(): Promise; private _startDebugServer; private _stopDebugServer; private _run; private _runRegistered; } /** * The context handed to an {@link Entrypoint} for a single job. Carries the * {@link RoomOptions} and metadata, manages the session lifecycle, and exposes * helpers like {@link JobContext.runUntilShutdown} and {@link JobContext.shutdown}. */ export type JobContext = JobContextImpl; /** * Create a {@link JobContext} (call as a factory, without `new`). Also exposes * {@link JobContext.createRoomStatic} to create a room without a context. */ export declare const JobContext: ((init: JobContextInit) => JobContext) & { /** Create a new room and return its id. See {@link JobContextImpl.createRoomStatic}. */ createRoomStatic: (authToken: string, signalingBaseUrl?: string) => Promise; }; /** * The per-session context handed to an agent factory/class by `serve()` when it declares * a parameter. Alias of {@link JobContext} - same value, same type - so an agent can read * `context.metadata` at construction time (before `super(...)`). */ export type SessionContext = JobContext; /** Alias of {@link JobContext}. See {@link SessionContext}. */ export declare const SessionContext: ((init: JobContextInit) => JobContext) & { /** Create a new room and return its id. See {@link JobContextImpl.createRoomStatic}. */ createRoomStatic: (authToken: string, signalingBaseUrl?: string) => Promise; }; /** A worker that runs your agent {@link Entrypoint}, optionally registering with the Zero Runtime. */ export type WorkerJob = WorkerJobImpl; /** * Create a worker for an agent entrypoint (call as a factory, without `new`). * Call `.start()` to run it: locally for a single job, or - when * {@link Options.register} is set - registered with the Zero Runtime to serve * dispatched sessions. * @param entrypoint - Your agent's main function. See {@link Entrypoint}. * @param jobctx - Optional {@link JobContext} or a factory that produces one per job. * @param options - Worker {@link Options}; defaults are applied when omitted. * @param onReady - Called once registration succeeds (registered mode only). */ export declare const WorkerJob: (entrypoint: Entrypoint, jobctx?: JobctxFactory, options?: Options | null, onReady?: (() => void) | null) => WorkerJob; export {};