import type { ContextWithMastra, ApiRoute } from '@mastra/core/server'; import type { LiveKitSessionMetadata } from './metadata.js'; import type { LiveKitRecordingOptions } from './recording.js'; /** Response body of the connection-details route. Matches LiveKit's frontend starter contract. */ export interface LiveKitConnectionDetails { serverUrl: string; roomName: string; participantName: string; participantToken: string; } export interface ConnectionRequestArgs { body: Record; context: ContextWithMastra; } export interface LiveKitConnectionRouteOptions { /** * Route path. Defaults to `/voice/livekit/connection-details`. Mastra reserves the * `/api` prefix for built-in routes, so custom paths must not start with `/api`. */ path?: string; /** LiveKit server URL (`wss://...`). Defaults to `LIVEKIT_URL`. */ serverUrl?: string; /** Defaults to `LIVEKIT_API_KEY`. */ apiKey?: string; /** Defaults to `LIVEKIT_API_SECRET`. */ apiSecret?: string; /** LiveKit agent name for explicit dispatch. Must match the worker's `agentName`. */ agentName?: string; /** Token time-to-live. Defaults to `'15m'`. */ ttl?: string | number; /** Defaults to `true` (Mastra custom routes require auth unless opted out). */ requiresAuth?: boolean; /** * Room name or a function that derives one from the request. Defaults to a generated name. * With recording enabled, use a unique name for each call. An existing room returns HTTP 409 * before agent dispatch or token issuance. */ roomName?: string | ((args: ConnectionRequestArgs) => string); participantIdentity?: string | ((args: ConnectionRequestArgs) => string); /** * Session metadata delivered to the worker via agent dispatch. Defaults to passing * through `agentId`, `threadId`, and `resourceId` from the request body. */ metadata?: (args: ConnectionRequestArgs) => LiveKitSessionMetadata | Promise; /** * Create a fresh room with automatic recording and dispatch the agent before returning a token. * The server-side callback receives the resolved room name; return undefined to skip recording. * Recording settings and storage credentials are never included in the participant token. */ recording?: LiveKitRecordingOptions | ((args: ConnectionRequestArgs & { roomName: string; }) => LiveKitRecordingOptions | undefined | Promise); } /** * An ApiRoute for `server.apiRoutes` that mints a LiveKit access token with the Mastra * voice agent dispatched into the room. Frontends call it to join a voice session: * * ```ts * export const mastra = new Mastra({ * agents: { support }, * server: { apiRoutes: [liveKitConnectionRoute({ agentName: 'mastra-voice' })] }, * }); * ``` */ export declare function liveKitConnectionRoute(options?: LiveKitConnectionRouteOptions): ApiRoute; //# sourceMappingURL=routes.d.ts.map