import type { llm } from '@livekit/agents'; /** * Fixed id LiveKit gives the customer Agent's instructions when it injects them as a leading * `role: 'system'` message into the chat context passed to `chat()` / `llmNode`. We drop this * item so the server-side Mastra agent's own system prompt is authoritative. */ export declare const LIVEKIT_INSTRUCTIONS_MESSAGE_ID = "lk.agent_task.instructions"; /** * A message bound for `agent.stream(...)` (in-process) or the Mastra server stream route (remote). * `id` carries the LiveKit `ChatMessage.id` so the server can dedupe/upsert by id — making * base-class retries, preemptive double-sends, and the interrupted-turn reconciliation recipe idempotent. */ export type VoiceTurnMessage = { role: 'system'; content: string; id?: string; } | { role: 'user'; content: string; id?: string; } | { role: 'assistant'; content: string; id?: string; }; /** * Extracts only the messages added since the agent last spoke. Used when Mastra Memory is * the source of truth for conversation history: prior turns are already persisted in the * thread, so re-sending them would duplicate history. * * Two extensions over the naive "slice after the last assistant message": * * - **Interrupted-turn self-heal:** when the last assistant message was cut off by barge-in * (`interrupted: true`), the server never persisted it — aborted runs skip persistence — so * its heard-only text is missing from the thread. Re-send that fragment (ordered first) this * turn to backfill it. It stops being "the last assistant message" once a full reply lands, * so each interrupted fragment is sent exactly once, on the following turn. * - **Instructions filter:** LiveKit injects the customer Agent's `instructions` as a * leading `system` message ({@link LIVEKIT_INSTRUCTIONS_MESSAGE_ID}); the server-side Mastra * agent owns its own system prompt, so drop it (it would otherwise ship on the first turn, * before any assistant message). */ export declare function extractNewTurnMessages(chatCtx: llm.ChatContext): VoiceTurnMessage[]; /** * Converts the full LiveKit chat context to Mastra messages. Used when the bridge runs * without Mastra Memory and LiveKit's in-session context is the only history. The agent's * LiveKit-level instructions are excluded — the Mastra agent applies its own instructions. */ export declare function chatContextToMessages(chatCtx: llm.ChatContext): VoiceTurnMessage[]; //# sourceMappingURL=messages.d.ts.map