import type { VoiceReplyGenerator, VoiceToolCall, VoiceTurnCompleteHook } from './bridge.js'; /** Connect + first-token budget when not overridden. Plugin mode passes `connOptions.timeoutMs`. */ export declare const DEFAULT_REMOTE_TIMEOUT_MS = 10000; /** Standalone initial-connection retry attempts. Plugin mode forces this to 0 (base class owns retries). */ export declare const DEFAULT_REMOTE_RETRIES = 2; /** * Options for the remote Mastra transport. Shape mirrors the in-process `AgentReplyGeneratorOptions` * so `MastraLLM` can accept either source interchangeably. */ export interface RemoteMastraAgentOptions { /** Base URL of the remote Mastra server, e.g. `https://my-app.mastra.cloud`. */ baseUrl: string; /** Agent key in the Mastra config's `agents`. */ agentId: string; /** Path prefix for the Mastra API. Defaults to `'/api'`. */ apiPrefix?: string; /** Static headers, or a (possibly async) resolver invoked per turn — e.g. to mint a fresh token. */ headers?: Record | (() => Record | Promise>); /** Injectable `fetch` for tests/proxies. Defaults to `globalThis.fetch`. */ fetch?: typeof globalThis.fetch; /** * Connect + first-token timeout in ms. Plugin mode default: LiveKit's `connOptions.timeoutMs` (10s). * Standalone default: {@link DEFAULT_REMOTE_TIMEOUT_MS}. */ timeoutMs?: number; /** * Initial-connection retry attempts (before the first chunk only). Standalone default: * {@link DEFAULT_REMOTE_RETRIES}. In plugin mode the LiveKit base class owns retries and this is * forced to 0. */ retries?: number; /** Extra fields merged into each stream request body (advanced). */ body?: Record; } /** {@link RemoteMastraAgentOptions} plus the per-turn observer hooks the generator threads through. */ export interface RemoteAgentReplyGeneratorOptions extends RemoteMastraAgentOptions { /** Speak a short phrase while a tool runs. See {@link MastraVoiceAgentOptions.toolFeedback}. */ toolFeedback?: (toolCall: VoiceToolCall) => string | undefined | void; /** Notified as each tool-call chunk arrives, mid-stream. See {@link MastraVoiceAgentOptions.onToolCall}. */ onToolCall?: (toolCall: VoiceToolCall) => void; /** Fired off the audio path after the reply streams. See {@link MastraVoiceAgentOptions.onTurnComplete}. */ onTurnComplete?: VoiceTurnCompleteHook; } type RawChunk = { type?: string; payload?: Record; }; /** * Reads a Mastra SSE stream and yields each event's parsed JSON. Framing matches the server's * `processMastraStream` (buffer, split on `\n\n`, strip `data: `, stop on `[DONE]`); undecodable * `data:` lines are skipped. Aborting `signal` cancels the underlying reader. */ export declare function readMastraSSE(body: globalThis.ReadableStream, signal: AbortSignal): AsyncGenerator; /** * A {@link VoiceReplyGenerator} that runs the Mastra agent loop on a **remote** Mastra server over * HTTP/SSE. Shaped exactly like the in-process `createAgentReplyGenerator`: it consumes the same * chunk vocabulary, drives the same `toolFeedback` / `onToolCall` / `onTurnComplete` seams, and * cancelling the returned stream (LiveKit does this on barge-in) tears down the HTTP request so the * server aborts generation. * * Usable standalone via the worker's `generate:` hatch (a minimum-viable remote worker mode), and as * the transport `MastraLLM` wraps. Errors are thrown as LiveKit `APIError` subclasses so the plugin's * base-class retry loop and `FallbackAdapter` behave; a connect + first-token watchdog prevents * indefinite dead air. */ export declare function createRemoteAgentReplyGenerator(options: RemoteAgentReplyGeneratorOptions): VoiceReplyGenerator; export {}; //# sourceMappingURL=remote.d.ts.map