/** * LiveWire -- LiveKit-compatible agents powered by SignalWire. * * Provides the same class/function names as @livekit/agents-js so that * developers can swap their import path and run on SignalWire's * infrastructure. STT, TTS, VAD, LLM orchestration, and call control * are all handled by SignalWire's control plane -- the noop'd options * are accepted silently (logged once) to keep existing code compiling. */ import { AgentBase } from '../AgentBase.js'; declare const banner = "\n __ _ _ ___\n / / (_) _____ | | / (_)_______\n / / / / | / / _ \\ | | /| / / / ___/ _ \\\n / /___/ /| |/ / __/ | |/ |/ / / / / __/\n/_____/_/ |___/\\___/ |__/|__/_/_/ \\___/\n\n LiveKit-compatible agents powered by SignalWire\n"; /** Print the ASCII banner to stderr, using ANSI cyan when stderr is a TTY. */ declare function printBanner(): void; /** * Rotating "Did you know?" tips printed to stderr by the LiveWire banner. * Exported for tests; reorder or extend to change what's displayed. */ export declare const tips: string[]; declare function printTip(): void; /** * NoopTracker ensures each informational message is logged at most once, * preventing spam when the same noop path is exercised repeatedly. */ declare class NoopTracker { private logged; /** * Log the given message the first time this key is seen. * * @param key - Dedup key. Subsequent calls with the same key are silent. * @param message - Message to write to stderr on first occurrence. */ once(key: string, message: string): void; /** Expose whether a key has been logged (for testing). */ hasLogged(key: string): boolean; /** Reset all tracked keys (for testing). */ reset(): void; } declare const globalNoop: NoopTracker; export { NoopTracker, globalNoop }; /** Voice configuration options passed through to the SignalWire AI config. */ export interface VoiceOptions { /** TTS voice identifier (e.g. `"en-US-Standard-A"`). */ voice: string; /** TTS engine identifier (e.g. `"google"`, `"elevenlabs"`). */ engine: string; /** BCP-47 language code (e.g. `"en-US"`). */ language: string; } /** A tool definition that can be registered on an {@link Agent}. */ export interface FunctionTool { /** Tool name. Populated when the tool is attached to an `Agent.tools` map. */ name: string; /** Human-readable description shown to the LLM. */ description: string; /** JSON schema (or Zod schema passthrough) for the tool's parameters. */ parameters?: Record; /** Handler invoked by the platform when the LLM calls this tool. */ execute: (params: any, context: { ctx: RunContext; }) => any; } /** * Mirrors a LiveKit `voice.Agent` — holds instructions and tool definitions. * * Pipeline options (`stt`, `tts`, `vad`, `llm`, `turnDetection`) are accepted * for API parity but are **no-ops** — SignalWire's control plane handles the * entire AI pipeline server-side. Set instructions and tools; everything else * just logs once and continues. * * @example Minimal LiveKit-compatible agent * ```ts * import { livewire } from '@signalwire/sdk'; * * const timeTool = livewire.tool({ * description: 'Return the current time.', * execute: () => new Date().toISOString(), * }); * * const agent = new livewire.Agent({ * instructions: 'You are a friendly helper.', * tools: [{ ...timeTool, name: 'time' }], * }); * * const session = new livewire.AgentSession(); * await session.start({ agent }); * ``` */ export declare class Agent { /** System instructions passed through to the SignalWire AI prompt. */ instructions: string; /** Registered tools keyed by name. Mutated by {@link updateTools}. */ tools: Record; /** Arbitrary per-session user data passed to tool handlers via {@link RunContext.userData}. */ userData?: UserData; /** @internal Pipeline hint stored for AgentSession mapping. */ _llmHint: unknown; /** @internal */ _allowInterruptions: unknown; /** @internal */ _minEndpointingDelay: unknown; /** @internal */ _maxEndpointingDelay: unknown; private _session?; constructor(options?: { instructions?: string; tools?: FunctionTool[]; userData?: UserData; chatCtx?: unknown; stt?: unknown; tts?: unknown; llm?: unknown; vad?: unknown; turnDetection?: unknown; mcpServers?: unknown; allowInterruptions?: boolean; minEndpointingDelay?: number; maxEndpointingDelay?: number; }); /** The currently-bound {@link AgentSession}, or `undefined` until {@link AgentSession.start} is called. */ get session(): AgentSession | undefined; set session(value: AgentSession | undefined); /** * Lifecycle hook called when the agent enters an active call. * Override in a subclass to run setup logic — the default is a no-op. */ onEnter(): Promise; /** * Lifecycle hook called when the agent exits (call ended or handoff). * Override in a subclass to run teardown logic — the default is a no-op. */ onExit(): Promise; /** * Lifecycle hook called when the user finishes speaking. * Override in a subclass to inspect / mutate the turn context before the * LLM responds — the default is a no-op. * * @param _turnCtx - Turn context (LiveKit shape; passed through opaquely). * @param _newMessage - Newly-captured user message. */ onUserTurnCompleted(_turnCtx?: unknown, _newMessage?: unknown): Promise; /** * LiveKit-compatible STT node. **No-op** on SignalWire — the control plane * handles speech recognition server-side. * * @param _audio - Audio input (ignored). * @param _modelSettings - Model settings (ignored). */ sttNode(_audio?: unknown, _modelSettings?: unknown): Promise; /** * LiveKit-compatible LLM node. **No-op** on SignalWire — the control plane * handles LLM inference server-side. * * @param _chatCtx - Chat context (ignored). * @param _tools - Tool list (ignored). * @param _modelSettings - Model settings (ignored). */ llmNode(_chatCtx?: unknown, _tools?: unknown, _modelSettings?: unknown): Promise; /** * LiveKit-compatible TTS node. **No-op** on SignalWire — the control plane * handles text-to-speech server-side. * * @param _text - Text to synthesise (ignored). * @param _modelSettings - Model settings (ignored). */ ttsNode(_text?: unknown, _modelSettings?: unknown): Promise; /** * Update the agent's instructions mid-session. * * @param instructions - New system-instructions string for the agent. */ updateInstructions(instructions: string): Promise; /** * Update the agent's tool list mid-session. * * Replaces the current tool record with one built from the given array, * keyed by `tool.name`. Useful for dynamic tool injection based on * conversation state. * * @param tools - Ordered array of {@link FunctionTool} definitions. Each * tool's `name` is used as its map key. */ updateTools(tools: FunctionTool[]): Promise; } /** * Mirrors a LiveKit `RunContext` — passed to tool handlers so they can * read the current session, call handle, and user data. */ export declare class RunContext { /** The owning {@link AgentSession}, when one is bound. */ session?: AgentSession; /** Opaque speech-turn handle (LiveKit shape; passed through untouched). */ speechHandle?: unknown; /** Opaque function-call descriptor (LiveKit shape; passed through untouched). */ functionCall?: unknown; /** * @param session - Owning session, when available. * @param options - Optional pass-through values. * @param options.speechHandle - Opaque LiveKit speech handle. * @param options.functionCall - Opaque LiveKit function-call descriptor. */ constructor(session?: AgentSession, options?: { speechHandle?: unknown; functionCall?: unknown; }); /** * Per-session user data, or an empty object when no session is bound. * * @returns The {@link AgentSession.userData} payload cast to `UserData`. */ get userData(): UserData; } /** * Mirrors a LiveKit `AgentSession` — binds an {@link Agent} to SignalWire. * * Call {@link AgentSession.start} with an `Agent` to construct an internal * {@link AgentBase} and begin serving SWML. Pipeline-related options are * accepted for API parity but are no-ops server-side. */ export declare class AgentSession { private _llm; private _tools; private _userData; private _agent?; private _swAgent?; private _allowInterruptions; private _minInterruptionDuration; private _minEndpointingDelay; private _maxEndpointingDelay; private _maxToolSteps; private _preemptiveGeneration; private _history; private _sayQueue; private noop; constructor(options?: { stt?: any; tts?: any; llm?: any; vad?: any; turnDetection?: any; tools?: FunctionTool[]; mcpServers?: unknown; userData?: UserData; allowInterruptions?: boolean; minInterruptionDuration?: number; minEndpointingDelay?: number; maxEndpointingDelay?: number; maxToolSteps?: number; preemptiveGeneration?: boolean; }); /** * Start the session by binding the agent to a freshly-constructed * {@link AgentBase}, mapping LiveKit-style options onto SignalWire AI params. * * Must be called before any other method on this session. The underlying * `AgentBase` is not started here — use {@link runApp} or an `AgentServer` * to serve it. * * @param params - Start parameters. * @param params.agent - The {@link Agent} to bind. * @param params.room - LiveKit room placeholder; ignored on SignalWire. * @param params.record - Call-recording flag placeholder; ignored on SignalWire. * @returns Resolves once the underlying `AgentBase` has been built. */ start(params: { agent: Agent; room?: any; record?: boolean; }): Promise; /** * Queue text to be spoken by the agent. * * Before {@link start} is called, text is buffered and injected at start * time as the agent's initial greeting. After start, text is added as an * additional prompt section. * * @param text - Line for the agent to speak. */ say(text: string): void; /** * Trigger the agent to generate a reply, optionally with extra instructions. * * @param options - Generation options. * @param options.instructions - Extra instructions injected as a new prompt * section before the next LLM turn. */ generateReply(options?: { instructions?: string; }): void; /** * Interrupt current speech. **No-op** on SignalWire — barge-in is handled * automatically by the control plane. */ interrupt(): void; /** * Swap the {@link Agent} bound to this session. * * Preserves the underlying `AgentBase` but replaces its prompt with the new * agent's instructions. * * @param agent - Replacement agent. */ updateAgent(agent: Agent): void; /** Current per-session user data. Set by the constructor or via the setter. */ get userData(): UserData; set userData(val: UserData); /** Conversation history entries captured over the session's lifetime. */ get history(): Array>; /** * Return the underlying SignalWire {@link AgentBase}. Useful for tests and * advanced use cases that need to reach past the LiveKit facade. * * @returns The wrapped `AgentBase`, or `undefined` before {@link start}. */ getSwAgent(): AgentBase | undefined; } /** * Create a tool definition — mirrors `llm.tool()` from `@livekit/agents-js`. * * The returned tool has an empty `name` — the caller assigns it when the tool * is attached to an agent's tools map (see the {@link Agent} example). * * @typeParam P - Parameter type passed into `execute`. * @param options - Tool configuration. * @param options.description - Human-readable tool description exposed to the LLM. * @param options.parameters - JSON Schema or Zod schema describing the tool's inputs. * @param options.execute - Handler invoked when the LLM calls the tool. * @returns A {@link FunctionTool} ready to be attached to an agent. */ export declare function tool

(options: { description: string; parameters?: any; execute: (params: P, context: { ctx: RunContext; }) => any; }): FunctionTool; /** * Create an {@link AgentHandoff} descriptor for multi-agent scenarios. * * @param options - Handoff parameters. * @param options.agent - Agent to transfer control to. * @param options.returns - Optional string returned to the current agent when * the handoff completes. * @returns A handoff descriptor that can be returned from a tool handler. */ export declare function handoff(options: { agent: Agent; returns?: string; }): AgentHandoff; /** Signals a handoff to another agent in multi-agent scenarios. */ export declare class AgentHandoff { /** Target agent that should take over the conversation. */ agent: Agent; /** Optional return value surfaced when the handoff completes. */ returns?: string; } /** Signals that a tool should not trigger another LLM reply. */ export declare class StopResponse extends Error { /** * @param message - Optional error message. Defaults to `"StopResponse"`. */ constructor(message?: string); } /** Error thrown from a tool to signal failure back to the LLM. */ export declare class ToolError extends Error { /** * @param message - Error message surfaced to the LLM. */ constructor(message: string); } /** * Mirrors a LiveKit `JobProcess` — placeholder for prewarm / setup hooks. * * On SignalWire the control plane pre-warms infrastructure at scale, so this * class carries no real state beyond the LiveKit-compatible `userData` bag. */ export declare class JobProcess { /** Mutable bag shared across prewarm and entry-point callbacks. */ userData: Record; } /** * Stub `Room` — SignalWire does not use the LiveKit room abstraction. * * Present purely for API parity so LiveKit-shaped code compiles; its only * meaningful attribute is the constant name. */ export declare class Room { /** Always `"livewire-room"` — SignalWire has no per-call room identity. */ readonly name: string; } /** * Mirrors a LiveKit `JobContext` — provides room and connection info to the * entry-point callback registered via {@link defineAgent}. */ export declare class JobContext { /** Placeholder {@link Room} (see class docs). */ room: Room; /** Shared {@link JobProcess} instance for prewarm-to-entry data passing. */ proc: JobProcess; /** @internal */ _swAgent?: AgentBase; constructor(); /** * Connect to the platform. **No-op** on SignalWire — the control plane * manages connection lifecycle automatically. * * @returns Resolves immediately. */ connect(): Promise; /** * Wait for a participant to join. **No-op** on SignalWire — returns an * immediate stub participant. * * @param options - Participant match options. * @param options.identity - Requested identity; echoed back in the stub. * Defaults to `"caller"`. * @returns A stub participant `{ identity }` record. */ waitForParticipant(options?: { identity?: string; }): Promise; } /** * Mirrors `@livekit/agents.defineAgent()`. * * Packages an entry function (plus an optional prewarm hook) for later * execution by {@link runApp}. Pass-through — no side effects. * * @param agent - Entry and (optional) prewarm functions. * @param agent.entry - Main callback invoked with a {@link JobContext} when * the agent runs. * @param agent.prewarm - Optional prewarm callback invoked with a * {@link JobProcess} before `entry`. * @returns The same record (pass-through), typed consistently. */ export declare function defineAgent(agent: { entry: (ctx: JobContext) => Promise; prewarm?: (proc: JobProcess) => any; }): { entry: (ctx: JobContext) => Promise; prewarm?: (proc: JobProcess) => any; }; /** * Mirrors `cli.runApp()` from `@livekit/agents-js`. * * 1. Prints the LiveWire banner * 2. Runs the registered prewarm callback (if any) with a fresh {@link JobProcess} * 3. Creates a fresh {@link JobContext} * 4. Prints a random tip * 5. Invokes the entry function with the context * 6. Starts the underlying SignalWire `AgentBase` once the entry function * binds one (via an `AgentSession.start()` call) * * Accepts either an object `{ entry, prewarm? }`, a bare entry function, or * an {@link AgentServer} instance. * * @param options - Agent descriptor, entry function, or `AgentServer`. */ export declare function runApp(options: any): void; /** * Stub class mirroring LiveKit's `WorkerOptions`. * * Accepts any configuration for source-compatibility with LiveKit code; * SignalWire ignores these settings. */ export declare class WorkerOptions { /** @param _opts - LiveKit-shaped worker options (ignored). */ constructor(_opts?: any); } /** * Stub class mirroring LiveKit's `ServerOptions`. * * Accepts any configuration for source-compatibility with LiveKit code; * SignalWire ignores these settings. */ export declare class ServerOptions { /** @param _opts - LiveKit-shaped server options (ignored). */ constructor(_opts?: any); } /** * Mirrors a LiveKit AgentServer -- registers entrypoints and starts. * * Usage: * const server = new AgentServer(); * server.setupFnc = async (proc) => { ... }; * * // Bare decorator usage: * server.rtcSession(myEntryFn); * * // Parameterized decorator usage: * server.rtcSession({ agentName: 'myAgent' })(myEntryFn); * * cli.runApp(server); */ export declare class AgentServer { /** Optional prewarm hook called before the entrypoint. Mirrors Python's setup_fnc. */ setupFnc?: (proc: JobProcess) => void; /** @internal Registered entrypoint function. */ private _entryFn?; /** @internal Agent name hint registered via rtcSession(). */ private _agentName; constructor(_opts?: any); /** * Decorator that registers the session entrypoint. * * Supports both bare and parameterized usage: * server.rtcSession(fn) // bare * server.rtcSession(fn, { agentName: 'x' }) // with opts, explicit fn * server.rtcSession({ agentName: 'x' })(fn) // parameterized decorator * @server.rtcSession // decorator (bare) * @server.rtcSession({ agentName: 'x' }) // decorator (parameterized) */ rtcSession(fnOrOpts?: ((ctx: JobContext) => Promise) | { agentName?: string; type?: string; onRequest?: ((...args: any[]) => any) | null; onSessionEnd?: ((...args: any[]) => any) | null; }, opts?: { agentName?: string; type?: string; onRequest?: ((...args: any[]) => any) | null; onSessionEnd?: ((...args: any[]) => any) | null; }): ((fn: (ctx: JobContext) => Promise) => (ctx: JobContext) => Promise) | void; /** @internal Extract agentDef-compatible shape for use by runApp. */ _toAgentDef(): { entry: (ctx: JobContext) => Promise; prewarm?: (proc: JobProcess) => void; }; } /** * Stub providers matching common LiveKit plugin packages. * * None of these do anything — they exist so LiveKit code that imports and * constructs these classes still compiles and runs under SignalWire. The * first construction of each logs an advisory to stderr. */ export declare namespace plugins { /** LiveKit Deepgram-STT plugin stub. No-op on SignalWire. */ class DeepgramSTT { /** @param _opts - Deepgram options (ignored). */ constructor(_opts?: any); } /** * LiveKit OpenAI-LLM plugin stub. * * The `model` string is captured and mapped to the SignalWire AI `model` * param by {@link AgentSession.start}. Other options are ignored. */ class OpenAILLM { /** Model identifier captured from the constructor options. */ model: string; /** @param _opts - OpenAI options. `_opts.model` is captured; everything else ignored. */ constructor(_opts?: any); } /** LiveKit Cartesia-TTS plugin stub. No-op on SignalWire. */ class CartesiaTTS { /** @param _opts - Cartesia options (ignored). */ constructor(_opts?: any); } /** LiveKit ElevenLabs-TTS plugin stub. No-op on SignalWire. */ class ElevenLabsTTS { /** @param _opts - ElevenLabs options (ignored). */ constructor(_opts?: any); } /** LiveKit Silero-VAD plugin stub. No-op on SignalWire. */ class SileroVAD { /** @param _opts - Silero VAD options (ignored). */ constructor(_opts?: Record); /** * Load a Silero VAD model. * * **No-op** on SignalWire — returns a fresh stub instance and emits a * one-time advisory to stderr. * * @returns A new `SileroVAD` stub. */ static load(): SileroVAD; } } /** * Stub inference types matching LiveKit's `inference` namespace. * * None of these run inference on the client — SignalWire performs STT / LLM / * TTS in its control plane. These classes exist so LiveKit code that imports * and instantiates them still compiles. */ export declare namespace inference { /** LiveKit inference-STT stub. Captures the model name; runs no inference locally. */ class STT { /** Model identifier captured from the constructor. */ model: string; /** * @param model - Model identifier (captured). * @param _opts - Additional options (ignored). */ constructor(model?: string, _opts?: any); } /** LiveKit inference-LLM stub. Captures the model name; runs no inference locally. */ class LLM { /** Model identifier captured from the constructor. */ model: string; /** * @param model - Model identifier (captured). * @param _opts - Additional options (ignored). */ constructor(model?: string, _opts?: any); } /** LiveKit inference-TTS stub. Captures the model name; runs no inference locally. */ class TTS { /** Model identifier captured from the constructor. */ model: string; /** * @param model - Model identifier (captured). * @param _opts - Additional options (ignored). */ constructor(model?: string, _opts?: any); } } /** LiveKit voice namespace equivalent. */ export declare const voice: { Agent: typeof Agent; AgentSession: typeof AgentSession; AgentSessionEventTypes: Record; }; /** Minimal `ChatContext` matching LiveKit's `ChatContext`. */ export declare class ChatContext { /** Ordered chat messages, each `{ role, content }`. */ messages: Array>; /** * Append a chat message. * * @param options - Message content. * @param options.role - Speaker role (`"user"`, `"assistant"`, or `"system"`). * Defaults to `"user"`. * @param options.text - Message text. Defaults to `""`. * @returns This instance for chaining. */ append(options: { role?: string; text?: string; }): this; } /** LiveKit llm namespace equivalent. */ export declare const llm: { tool: typeof tool; handoff: typeof handoff; ToolError: typeof ToolError; ChatContext: typeof ChatContext; }; /** LiveKit cli namespace equivalent. */ export declare const cli: { runApp: typeof runApp; }; export { printBanner, printTip, banner };