@mastra/livekit 0.0.0-aggregate-trace-20261015182851

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +48 -0
  3. package/dist/bridge.d.ts +256 -0
  4. package/dist/bridge.d.ts.map +1 -0
  5. package/dist/client-entry.cjs +17 -0
  6. package/dist/client-entry.cjs.map +1 -0
  7. package/dist/client-entry.d.ts +8 -0
  8. package/dist/client-entry.d.ts.map +1 -0
  9. package/dist/client-entry.js +16 -0
  10. package/dist/client-entry.js.map +1 -0
  11. package/dist/consent.d.ts +55 -0
  12. package/dist/consent.d.ts.map +1 -0
  13. package/dist/constants.d.ts +3 -0
  14. package/dist/constants.d.ts.map +1 -0
  15. package/dist/dispatch.d.ts +26 -0
  16. package/dist/dispatch.d.ts.map +1 -0
  17. package/dist/end-call.d.ts +50 -0
  18. package/dist/end-call.d.ts.map +1 -0
  19. package/dist/index.cjs +290 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.ts +20 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +281 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/llm-plugin.d.ts +117 -0
  26. package/dist/llm-plugin.d.ts.map +1 -0
  27. package/dist/messages.d.ts +50 -0
  28. package/dist/messages.d.ts.map +1 -0
  29. package/dist/metadata.d.ts +17 -0
  30. package/dist/metadata.d.ts.map +1 -0
  31. package/dist/observability.d.ts +49 -0
  32. package/dist/observability.d.ts.map +1 -0
  33. package/dist/plugin-entry.cjs +222 -0
  34. package/dist/plugin-entry.cjs.map +1 -0
  35. package/dist/plugin-entry.d.ts +10 -0
  36. package/dist/plugin-entry.d.ts.map +1 -0
  37. package/dist/plugin-entry.js +217 -0
  38. package/dist/plugin-entry.js.map +1 -0
  39. package/dist/recording-route.d.ts +31 -0
  40. package/dist/recording-route.d.ts.map +1 -0
  41. package/dist/recording-types.d.ts +11 -0
  42. package/dist/recording-types.d.ts.map +1 -0
  43. package/dist/recording.d.ts +21 -0
  44. package/dist/recording.d.ts.map +1 -0
  45. package/dist/remote-CIMCGicy.js +822 -0
  46. package/dist/remote-CIMCGicy.js.map +1 -0
  47. package/dist/remote-GSOxa--f.cjs +875 -0
  48. package/dist/remote-GSOxa--f.cjs.map +1 -0
  49. package/dist/remote.d.ts +68 -0
  50. package/dist/remote.d.ts.map +1 -0
  51. package/dist/routes.d.ts +66 -0
  52. package/dist/routes.d.ts.map +1 -0
  53. package/dist/run.d.ts +32 -0
  54. package/dist/run.d.ts.map +1 -0
  55. package/dist/speech.d.ts +19 -0
  56. package/dist/speech.d.ts.map +1 -0
  57. package/dist/turn-metrics-CqqzdLDe.js +53 -0
  58. package/dist/turn-metrics-CqqzdLDe.js.map +1 -0
  59. package/dist/turn-metrics-CtVHHdJj.cjs +82 -0
  60. package/dist/turn-metrics-CtVHHdJj.cjs.map +1 -0
  61. package/dist/turn-metrics.d.ts +69 -0
  62. package/dist/turn-metrics.d.ts.map +1 -0
  63. package/dist/voice-stream.d.ts +3 -0
  64. package/dist/voice-stream.d.ts.map +1 -0
  65. package/dist/voice-thread.d.ts +23 -0
  66. package/dist/voice-thread.d.ts.map +1 -0
  67. package/dist/worker-entry.cjs +727 -0
  68. package/dist/worker-entry.cjs.map +1 -0
  69. package/dist/worker-entry.d.ts +15 -0
  70. package/dist/worker-entry.d.ts.map +1 -0
  71. package/dist/worker-entry.js +711 -0
  72. package/dist/worker-entry.js.map +1 -0
  73. package/dist/worker-setup.d.ts +5 -0
  74. package/dist/worker-setup.d.ts.map +1 -0
  75. package/dist/worker.d.ts +487 -0
  76. package/dist/worker.d.ts.map +1 -0
  77. package/dist/workflow-generator-5nHqlZV7.js +210 -0
  78. package/dist/workflow-generator-5nHqlZV7.js.map +1 -0
  79. package/dist/workflow-generator-D67FvbFe.cjs +239 -0
  80. package/dist/workflow-generator-D67FvbFe.cjs.map +1 -0
  81. package/dist/workflow-generator.d.ts +92 -0
  82. package/dist/workflow-generator.d.ts.map +1 -0
  83. package/package.json +121 -0
package/LICENSE.md ADDED
@@ -0,0 +1,32 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named `ee/` within this
4
+ repository, including but not limited to:
5
+ - `@mastra/core/auth/ee`
6
+ - `@mastra/core/agent-builder/ee`
7
+ - `@mastra/editor/ee`
8
+
9
+ is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
10
+
11
+ - All third-party components incorporated into the Mastra Software are
12
+ licensed under the original license provided by the owner of the
13
+ applicable component.
14
+
15
+ - Content outside of the above-mentioned directories or restrictions is
16
+ available under the "Apache License 2.0" as defined below.
17
+
18
+ # Apache License 2.0
19
+
20
+ Copyright (c) 2025 Kepler Software, Inc.
21
+
22
+ Licensed under the Apache License, Version 2.0 (the "License");
23
+ you may not use this file except in compliance with the License.
24
+ You may obtain a copy of the License at
25
+
26
+ http://www.apache.org/licenses/LICENSE-2.0
27
+
28
+ Unless required by applicable law or agreed to in writing, software
29
+ distributed under the License is distributed on an "AS IS" BASIS,
30
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ See the License for the specific language governing permissions and
32
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @mastra/livekit
2
+
3
+ Realtime voice for [Mastra](https://mastra.ai) agents and workflows, powered by [LiveKit Agents](https://docs.livekit.io/agents/).
4
+
5
+ LiveKit's agents framework owns the **audio loop** — WebRTC transport, voice activity detection (VAD), streaming speech-to-text (STT), semantic turn detection, barge-in, and text-to-speech (TTS). This package bridges **reply generation** to Mastra, so each detected user turn is answered by a Mastra **agent** (`agent.stream()`) or **workflow** — with your tools, memory, processors, and model routing all running inside Mastra.
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @mastra/livekit
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ Set `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET`. Add a connection route to your Mastra server so clients can receive a room token and dispatch the configured agent.
15
+
16
+ ```typescript
17
+ import { Agent } from '@mastra/core/agent';
18
+ import { Mastra } from '@mastra/core/mastra';
19
+ import { liveKitConnectionRoute } from '@mastra/livekit';
20
+
21
+ const supportAgent = new Agent({
22
+ id: 'support',
23
+ name: 'Support agent',
24
+ instructions: 'Keep voice responses short and conversational.',
25
+ model: 'openai/gpt-5-mini',
26
+ });
27
+
28
+ export const mastra = new Mastra({
29
+ agents: { supportAgent },
30
+ server: {
31
+ apiRoutes: [liveKitConnectionRoute({ agentName: 'mastra-voice' })],
32
+ },
33
+ });
34
+ ```
35
+
36
+ Run a separate LiveKit worker to own the audio pipeline and call the agent for each detected turn. See the quickstart for the worker setup and required LiveKit plugins.
37
+
38
+ ## Documentation
39
+
40
+ - [@mastra/livekit documentation](https://mastra.ai/integrations/voice/livekit)
41
+
42
+ ## Changelog
43
+
44
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/integrations/livekit/CHANGELOG.md) for version history and release notes.
45
+
46
+ ## Support
47
+
48
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -0,0 +1,256 @@
1
+ import { ReadableStream } from 'node:stream/web';
2
+ import { FlushSentinel, llm, voice } from '@livekit/agents';
3
+ import type { Agent as MastraAgent, AgentExecutionOptionsBase, AgentMemoryOption } from '@mastra/core/agent';
4
+ import type { TracingContext } from '@mastra/core/observability';
5
+ import { RequestContext } from '@mastra/core/request-context';
6
+ import type { VoiceTurnMessage } from './messages.js';
7
+ import { createGenerationMetrics } from './turn-metrics.js';
8
+ import type { VoiceReplyChunk, VoiceTurnMetricsHook } from './turn-metrics.js';
9
+ /** Default spoken text for periodic AI re-disclosure. See {@link MastraVoiceAgentOptions.greetingReminder}. */
10
+ export declare const DEFAULT_DISCLOSURE_REMINDER = "Just a reminder, you're speaking with an AI assistant.";
11
+ /**
12
+ * Tracks periodic AI re-disclosure for a single call. `due()` returns the reminder text once
13
+ * `everyMs` has elapsed since the last disclosure (resetting the clock), otherwise `undefined`.
14
+ * Time is injectable so the interval logic is deterministically testable.
15
+ */
16
+ export declare class DisclosureReminder {
17
+ private readonly everyMs;
18
+ private readonly text;
19
+ private lastAt;
20
+ constructor(everyMs: number, text: string, now?: number);
21
+ /** Call once per turn: the reminder text if it's due, else `undefined`. Does not reset the clock —
22
+ * call {@link DisclosureReminder.markDelivered} once the reminder is actually threaded into the
23
+ * outgoing reply, so a reminder that never makes it out isn't silently skipped for a full interval. */
24
+ due(now?: number): string | undefined;
25
+ /** Resets the clock. Call only once the reminder text from {@link due} was actually emitted. */
26
+ markDelivered(now?: number): void;
27
+ }
28
+ /**
29
+ * Wraps `source` in a stream that emits `text` as a single leading chunk (with a trailing space, so
30
+ * TTS pauses before the reply) before piping the rest of `source` through unchanged. Cancelling the
31
+ * wrapper cancels `source` — so barge-in still aborts the underlying generation.
32
+ */
33
+ export declare function prependText<T>(source: ReadableStream<T>, text: string): ReadableStream<T | string>;
34
+ export type MastraStreamOptions = Partial<AgentExecutionOptionsBase<unknown>>;
35
+ export interface VoiceToolCall {
36
+ toolCallId: string;
37
+ toolName: string;
38
+ args?: unknown;
39
+ }
40
+ /**
41
+ * Token usage for one turn, captured from the model's `finish` chunk. Field names mirror LiveKit's
42
+ * `CompletionUsage` so the plugin can forward it into `metrics_collected` without remapping.
43
+ */
44
+ export interface VoiceTurnUsage {
45
+ /** Tokens in the prompt (LiveKit `promptTokens`). */
46
+ promptTokens: number;
47
+ /** Tokens in the completion (LiveKit `completionTokens`). */
48
+ completionTokens: number;
49
+ /** Cached prompt tokens (LiveKit `promptCachedTokens`). */
50
+ promptCachedTokens: number;
51
+ /** Total tokens for the turn. */
52
+ totalTokens: number;
53
+ }
54
+ /**
55
+ * Maps a Mastra `finish` chunk's usage (`payload.output.usage`, AI-SDK `LanguageModelUsage`) to the
56
+ * LiveKit-shaped {@link VoiceTurnUsage}, or `undefined` when the chunk carries no token counts.
57
+ * Handles both the flat V2 usage shape (`inputTokens`/`outputTokens`) and the nested V3 shape
58
+ * (`inputTokens.total`/`outputTokens.total`).
59
+ */
60
+ export declare function mapTurnUsage(usage: unknown): VoiceTurnUsage | undefined;
61
+ export interface MastraVoiceAgentMemory {
62
+ thread: string;
63
+ resource?: string;
64
+ /**
65
+ * Per-call Mastra memory config forwarded to the agent as `memory.options` (see core's
66
+ * `AgentMemoryOption`). The notable use is `{ readOnly: true }`: the agent still reads thread
67
+ * history but persists nothing, which keeps LiveKit's preemptive (speculative) turns from writing
68
+ * partial user and assistant messages to the thread. With `readOnly` the caller owns persistence
69
+ * of committed turns (e.g. from `onTurnComplete` via `memory.saveMessages`).
70
+ */
71
+ options?: AgentMemoryOption['options'];
72
+ }
73
+ /**
74
+ * Per-turn context handed to a {@link VoiceReplyGenerator}. LiveKit calls `llmNode` once per
75
+ * detected user turn; the bridge builds this context and asks the generator for the reply.
76
+ */
77
+ export interface VoiceTurnContext {
78
+ /** Stable user-turn identifier, supplied by the worker or plugin. */
79
+ turnId?: string;
80
+ /** Unique generation attempt identifier, including speculative replies and retries. */
81
+ attemptId?: string;
82
+ /** @internal Bridge-side timing collector. */
83
+ metrics?: ReturnType<typeof createGenerationMetrics>;
84
+ /**
85
+ * The messages to generate a reply from. With Mastra Memory on, only the messages new since
86
+ * the agent last spoke (history comes from the thread); with memory off, the full session.
87
+ *
88
+ * For a workflow / custom generator: pass these straight to a memory-backed `agent.stream(...,
89
+ * { memory })` inside a step so the agent backfills history from the thread (no duplication). A
90
+ * stateless workflow that wants the entire transcript every turn should read `chatCtx` instead
91
+ * (e.g. `chatContextToMessages(chatCtx)`), since there is no thread to backfill from.
92
+ */
93
+ messages: VoiceTurnMessage[];
94
+ /** The raw LiveKit chat context, for generators that want the full transcript or message parts. */
95
+ chatCtx: llm.ChatContext;
96
+ /** Resolved memory mapping for the call, or `false` when memory is disabled. */
97
+ memory: MastraVoiceAgentMemory | false;
98
+ /** Request context forwarded to generation. */
99
+ requestContext?: RequestContext;
100
+ /** Voice-call span context, so each turn's generation nests under the call trace. */
101
+ tracingContext?: TracingContext;
102
+ /**
103
+ * Internal, per-turn side channel for token usage. A generator invokes this once, when the
104
+ * `finish` chunk carries usage, so the caller (e.g. `MastraLLMStream`) can attribute usage to
105
+ * exactly this turn — kept on the context (not on generator options) so overlapping turns from
106
+ * preemptive generation can't misattribute usage. Fire-and-forget; the generator does not await it.
107
+ */
108
+ onUsage?: (usage: VoiceTurnUsage) => void;
109
+ }
110
+ /**
111
+ * What a turn produced, handed to {@link VoiceTurnCompleteHook} after the reply finishes.
112
+ */
113
+ export interface VoiceTurnResult {
114
+ /** The assistant reply text streamed this turn, accumulated from the model's text deltas. */
115
+ text: string;
116
+ /** Tool calls the agent made during the turn, in order. */
117
+ toolCalls: VoiceToolCall[];
118
+ /** True when barge-in cut the turn short before it finished streaming. */
119
+ interrupted: boolean;
120
+ /** Token usage for the turn when the model reported it in its `finish` chunk. */
121
+ usage?: VoiceTurnUsage;
122
+ }
123
+ /** {@link VoiceTurnContext} plus the reply it produced. Passed to {@link VoiceTurnCompleteHook}. */
124
+ export interface VoiceTurnCompleteContext extends VoiceTurnContext {
125
+ /** The reply the agent produced this turn. */
126
+ result: VoiceTurnResult;
127
+ }
128
+ /**
129
+ * Called once per turn AFTER the reply has finished streaming to text-to-speech — off the audio
130
+ * path. It runs fire-and-forget: the turn does not await it, so post-turn work (memory
131
+ * maintenance, CRM writes, analytics) never delays what the caller hears or the next turn. A
132
+ * thrown error or rejected promise is logged, not propagated. Because the resolved `memory`
133
+ * mapping (`thread`/`resource`) is on the context, this is the place for a truly non-blocking
134
+ * `memory.updateWorkingMemory(...)`. See {@link MastraVoiceAgentOptions.onTurnComplete}.
135
+ */
136
+ export type VoiceTurnCompleteHook = (ctx: VoiceTurnCompleteContext) => void | Promise<void>;
137
+ /**
138
+ * Produces a stream of text deltas for one conversational turn, or `null` to stay silent.
139
+ * Cancelling the returned stream (LiveKit does this on barge-in) must abort the underlying
140
+ * generation. Built-in implementations: {@link createAgentReplyGenerator} (a Mastra agent) and
141
+ * `createWorkflowReplyGenerator` (a Mastra workflow).
142
+ */
143
+ export type VoiceReplyGenerator = (ctx: VoiceTurnContext) => ReadableStream<VoiceReplyChunk> | null | Promise<ReadableStream<VoiceReplyChunk> | null>;
144
+ export interface AgentReplyGeneratorOptions {
145
+ /** The Mastra agent that generates replies. Tools and memory run inside this agent. */
146
+ agent: MastraAgent;
147
+ /** Extra options merged into every `agent.stream()` call (e.g. `tracingContext`). */
148
+ streamOptions?: MastraStreamOptions;
149
+ /** Speak a short phrase while a tool call runs. See {@link MastraVoiceAgentOptions.toolFeedback}. */
150
+ toolFeedback?: (toolCall: VoiceToolCall) => string | undefined | void;
151
+ /** Notified as each tool-call chunk arrives, mid-stream. See {@link MastraVoiceAgentOptions.onToolCall}. */
152
+ onToolCall?: (toolCall: VoiceToolCall) => void;
153
+ /** Fired off the audio path after the reply streams. See {@link MastraVoiceAgentOptions.onTurnComplete}. */
154
+ onTurnComplete?: VoiceTurnCompleteHook;
155
+ }
156
+ /**
157
+ * A {@link VoiceReplyGenerator} backed by a Mastra agent: runs the agent's full loop (model,
158
+ * tools, memory) and streams its text deltas. On barge-in the returned stream is cancelled,
159
+ * which aborts the in-flight `agent.stream()`.
160
+ */
161
+ export declare function createAgentReplyGenerator(options: AgentReplyGeneratorOptions): VoiceReplyGenerator;
162
+ export interface MastraVoiceAgentOptions {
163
+ /** Receives per-attempt generation metrics. Playback metrics come from observeVoiceSession. */
164
+ onTurnMetrics?: VoiceTurnMetricsHook;
165
+ /**
166
+ * The Mastra agent that generates replies. Tools and memory run inside this agent. Provide
167
+ * either this or {@link MastraVoiceAgentOptions.generate}.
168
+ */
169
+ agent?: MastraAgent;
170
+ /**
171
+ * A lower-level reply generator (e.g. from `createWorkflowReplyGenerator`). Use instead of
172
+ * `agent` to drive replies with a workflow or any custom generator.
173
+ */
174
+ generate?: VoiceReplyGenerator;
175
+ /**
176
+ * Conversation persistence. When set, only messages new since the agent last spoke are
177
+ * sent each turn and Mastra Memory supplies history. When `false`, the full LiveKit
178
+ * in-session context is sent on every turn instead.
179
+ */
180
+ memory?: MastraVoiceAgentMemory | false;
181
+ /** Request context entries forwarded to generation. */
182
+ requestContext?: RequestContext | Record<string, unknown>;
183
+ /**
184
+ * Called when the Mastra agent starts a tool call mid-reply. Return a short phrase (e.g. "Let
185
+ * me look that up.") to speak it while the tool runs; it also appears in the transcript. Return
186
+ * nothing to stay silent. Applies to the agent generator built here; the workflow generator
187
+ * takes its own equivalent via `createWorkflowReplyGenerator`.
188
+ */
189
+ toolFeedback?: (toolCall: VoiceToolCall) => string | undefined | void;
190
+ /**
191
+ * Called as each tool call starts mid-reply (before the tool result is known), the building block
192
+ * for tool-driven side effects — analytics, agent-initiated hang-up — without waiting for the turn
193
+ * to finish. Runs synchronously on the stream; keep it cheap and non-throwing. Applies to the agent
194
+ * generator built here; the workflow generator surfaces tool calls via `onTurnComplete` instead.
195
+ */
196
+ onToolCall?: (toolCall: VoiceToolCall) => void;
197
+ /**
198
+ * Called once per turn after the reply has finished streaming to text-to-speech. Runs off the
199
+ * audio path and fire-and-forget — the turn does not await it — so post-turn memory
200
+ * maintenance, CRM writes, or analytics never delay the caller or the next turn. The context
201
+ * carries the produced reply ({@link VoiceTurnResult}) and the resolved `memory` mapping, so
202
+ * this is where a truly non-blocking `memory.updateWorkingMemory(...)` belongs. A thrown error
203
+ * or rejected promise is logged, not propagated. Applies to the agent generator built here; the
204
+ * workflow generator takes its own via `createWorkflowReplyGenerator`.
205
+ */
206
+ onTurnComplete?: VoiceTurnCompleteHook;
207
+ /**
208
+ * Periodic AI re-disclosure. When set, once `everyMs` has elapsed since the last disclosure the
209
+ * NEXT turn's reply is prefixed with `text` (spoken at the turn boundary, never mid-turn), so long
210
+ * calls keep re-disclosing the AI status. Applies to the agent and workflow/custom generators. The
211
+ * worker derives this from `configuration.greeting.repeatEvery` / `repeatText`; `text` defaults to
212
+ * {@link DEFAULT_DISCLOSURE_REMINDER}.
213
+ */
214
+ greetingReminder?: {
215
+ everyMs: number;
216
+ text?: string;
217
+ };
218
+ /** Extra options merged into every `agent.stream()` call (agent generator only). */
219
+ streamOptions?: MastraStreamOptions;
220
+ /** LiveKit agent instructions. Unused for reply generation (the Mastra agent/workflow applies its own). */
221
+ instructions?: string;
222
+ id?: voice.AgentOptions<unknown>['id'];
223
+ stt?: voice.AgentOptions<unknown>['stt'];
224
+ vad?: voice.AgentOptions<unknown>['vad'];
225
+ tts?: voice.AgentOptions<unknown>['tts'];
226
+ turnHandling?: voice.AgentOptions<unknown>['turnHandling'];
227
+ }
228
+ /**
229
+ * A LiveKit `voice.Agent` whose replies come from a Mastra agent or workflow.
230
+ *
231
+ * LiveKit keeps ownership of the audio loop (VAD, STT, turn detection, TTS, barge-in) and calls
232
+ * `llmNode` once per detected user turn; the node delegates to a {@link VoiceReplyGenerator}
233
+ * which streams text deltas back. On barge-in LiveKit cancels the returned stream, which aborts
234
+ * the in-flight generation.
235
+ */
236
+ export declare class MastraVoiceAgent extends voice.Agent {
237
+ readonly mastraAgent?: MastraAgent;
238
+ readonly memory: MastraVoiceAgentMemory | false;
239
+ readonly requestContext?: RequestContext;
240
+ readonly streamOptions?: MastraStreamOptions;
241
+ private readonly replyGenerator;
242
+ private readonly onTurnMetrics?;
243
+ private readonly reminder?;
244
+ constructor(options: MastraVoiceAgentOptions);
245
+ llmNode(chatCtx: llm.ChatContext, _toolCtx: llm.ToolContext, _modelSettings: voice.ModelSettings): Promise<ReadableStream<llm.ChatChunk | string | FlushSentinel> | null>;
246
+ }
247
+ export declare function createMastraVoiceAgent(options: MastraVoiceAgentOptions): MastraVoiceAgent;
248
+ /** @internal Wrap every reply source, including custom generators, with one terminal metric. */
249
+ export declare function instrumentVoiceReply(generator: VoiceReplyGenerator, ctx: VoiceTurnContext, onTurnMetrics?: VoiceTurnMetricsHook): Promise<{
250
+ reply: ReadableStream<VoiceReplyChunk> | null;
251
+ identity: {
252
+ turnId: string;
253
+ attemptId: string;
254
+ };
255
+ }>;
256
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAyC,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAK5E,+GAA+G;AAC/G,eAAO,MAAM,2BAA2B,2DAA2D,CAAC;AAEpG;;;;GAIG;AACH,qBAAa,kBAAkB;IAG3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHvB,OAAO,CAAC,MAAM,CAAS;IACvB,YACmB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAC7B,GAAG,GAAE,MAAmB,EAGzB;IACD;;2GAEuG;IACvG,GAAG,CAAC,GAAG,GAAE,MAAmB,GAAG,MAAM,GAAG,SAAS,CAGhD;IACD,gGAAgG;IAChG,aAAa,CAAC,GAAG,GAAE,MAAmB,GAAG,IAAI,CAE5C;CACF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,IAA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C,CAAC;CAC5D;AAiCD;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,KAAK,CAAC,KAAK;IAC/C,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,KAAK,CAAC;IAChD,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAuB;IACtD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAqB;IAE/C,YAAY,OAAO,EAAE,uBAAuB,EAwC3C;IAEc,OAAO,CACpB,OAAO,EAAE,GAAG,CAAC,WAAW,EACxB,QAAQ,EAAE,GAAG,CAAC,WAAW,EACzB,cAAc,EAAE,KAAK,CAAC,aAAa,GAClC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,GAAG,aAAa,CAAC,GAAG,IAAI,CAAC,CAoCxE;CACF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CAEzF;AAED,gGAAgG;AAChG,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,mBAAmB,EAC9B,GAAG,EAAE,gBAAgB,EACrB,aAAa,CAAC,EAAE,oBAAoB,GACnC,OAAO,CAAC;IAAE,KAAK,EAAE,cAAc,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CA8C7G"}
@@ -0,0 +1,17 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _mastra_client_js = require("@mastra/client-js");
3
+ //#region src/client-entry.ts
4
+ /** Requests a fresh playback URL using the client's authentication and fetch configuration. */
5
+ function getLiveKitRecording(client, traceId, options) {
6
+ return new _mastra_client_js.MastraClient({
7
+ ...client.options,
8
+ apiPrefix: ""
9
+ }).request(`/voice/livekit/recordings/${encodeURIComponent(traceId)}`, {
10
+ retries: 0,
11
+ signal: options?.signal
12
+ });
13
+ }
14
+ //#endregion
15
+ exports.getLiveKitRecording = getLiveKitRecording;
16
+
17
+ //# sourceMappingURL=client-entry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-entry.cjs","names":["MastraClient"],"sources":["../src/client-entry.ts"],"sourcesContent":["// Browser-safe entry point. Keep server routes, credentials, and worker runtimes out of this module.\nimport { MastraClient } from '@mastra/client-js';\nimport type { LiveKitRecordingResponse } from './recording-types';\n\nexport type { LiveKitRecording, LiveKitRecordingResponse } from './recording-types';\n\n/** Requests a fresh playback URL using the client's authentication and fetch configuration. */\nexport function getLiveKitRecording(\n client: Pick<MastraClient, 'options'>,\n traceId: string,\n options?: { signal?: AbortSignal },\n): Promise<LiveKitRecordingResponse> {\n // Custom integration routes mount at the server root, independently of apiPrefix.\n // A separate client preserves the original client's routing and transport settings.\n const integration = new MastraClient({ ...client.options, apiPrefix: '' });\n return integration.request(`/voice/livekit/recordings/${encodeURIComponent(traceId)}`, {\n retries: 0,\n signal: options?.signal,\n });\n}\n"],"mappings":";;;;AAOA,SAAgB,oBACd,QACA,SACA,SACmC;CAInC,OAAO,IADiBA,kBAAAA,aAAa;EAAE,GAAG,OAAO;EAAS,WAAW;CAAG,CACvD,CAAC,CAAC,QAAQ,6BAA6B,mBAAmB,OAAO,KAAK;EACrF,SAAS;EACT,QAAQ,SAAS;CACnB,CAAC;AACH"}
@@ -0,0 +1,8 @@
1
+ import { MastraClient } from '@mastra/client-js';
2
+ import type { LiveKitRecordingResponse } from './recording-types.js';
3
+ export type { LiveKitRecording, LiveKitRecordingResponse } from './recording-types.js';
4
+ /** Requests a fresh playback URL using the client's authentication and fetch configuration. */
5
+ export declare function getLiveKitRecording(client: Pick<MastraClient, 'options'>, traceId: string, options?: {
6
+ signal?: AbortSignal;
7
+ }): Promise<LiveKitRecordingResponse>;
8
+ //# sourceMappingURL=client-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-entry.d.ts","sourceRoot":"","sources":["../src/client-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,YAAY,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEpF,+FAA+F;AAC/F,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,EACrC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAQnC"}
@@ -0,0 +1,16 @@
1
+ import { MastraClient } from "@mastra/client-js";
2
+ //#region src/client-entry.ts
3
+ /** Requests a fresh playback URL using the client's authentication and fetch configuration. */
4
+ function getLiveKitRecording(client, traceId, options) {
5
+ return new MastraClient({
6
+ ...client.options,
7
+ apiPrefix: ""
8
+ }).request(`/voice/livekit/recordings/${encodeURIComponent(traceId)}`, {
9
+ retries: 0,
10
+ signal: options?.signal
11
+ });
12
+ }
13
+ //#endregion
14
+ export { getLiveKitRecording };
15
+
16
+ //# sourceMappingURL=client-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-entry.js","names":[],"sources":["../src/client-entry.ts"],"sourcesContent":["// Browser-safe entry point. Keep server routes, credentials, and worker runtimes out of this module.\nimport { MastraClient } from '@mastra/client-js';\nimport type { LiveKitRecordingResponse } from './recording-types';\n\nexport type { LiveKitRecording, LiveKitRecordingResponse } from './recording-types';\n\n/** Requests a fresh playback URL using the client's authentication and fetch configuration. */\nexport function getLiveKitRecording(\n client: Pick<MastraClient, 'options'>,\n traceId: string,\n options?: { signal?: AbortSignal },\n): Promise<LiveKitRecordingResponse> {\n // Custom integration routes mount at the server root, independently of apiPrefix.\n // A separate client preserves the original client's routing and transport settings.\n const integration = new MastraClient({ ...client.options, apiPrefix: '' });\n return integration.request(`/voice/livekit/recordings/${encodeURIComponent(traceId)}`, {\n retries: 0,\n signal: options?.signal,\n });\n}\n"],"mappings":";;;AAOA,SAAgB,oBACd,QACA,SACA,SACmC;CAInC,OAAO,IADiB,aAAa;EAAE,GAAG,OAAO;EAAS,WAAW;CAAG,CACvD,CAAC,CAAC,QAAQ,6BAA6B,mBAAmB,OAAO,KAAK;EACrF,SAAS;EACT,QAAQ,SAAS;CACnB,CAAC;AACH"}
@@ -0,0 +1,55 @@
1
+ /** A consent decision captured from the caller during a call. */
2
+ export interface ConsentGrant {
3
+ /**
4
+ * The consent item, matching a key in the worker's `configuration.consentPolicy` (e.g.
5
+ * `'summaryStorage'`).
6
+ */
7
+ item: string;
8
+ /** `true` if the caller agreed, `false` if they declined. */
9
+ granted: boolean;
10
+ /** The caller the grant belongs to (the memory `resource`), when the call is memory-scoped. */
11
+ resourceId?: string;
12
+ /** The call thread the grant was captured on, when the call is memory-scoped. */
13
+ threadId?: string;
14
+ }
15
+ export interface ConsentToolOptions {
16
+ /**
17
+ * Persist the caller's decision to YOUR system of record (database, CRM, consent ledger). Called
18
+ * each time the caller answers a consent question — keep it quick, it runs inside the turn. This
19
+ * tool owns extracting the caller's identity from the tool execution context; you own storage, so
20
+ * consent lives in a durable, compliant place rather than an opaque plugin store. Read those
21
+ * grants back at `onCallEnd` (or before any consent-gated step) to enforce the requirement.
22
+ */
23
+ onGrant: (grant: ConsentGrant) => void | Promise<void>;
24
+ /** Tool id the agent calls. Defaults to `'recordConsent'`. */
25
+ id?: string;
26
+ /** Override the description the model sees when deciding to call the tool. */
27
+ description?: string;
28
+ /** Restrict the accepted consent items to this set (becomes an enum). Defaults to any string. */
29
+ items?: readonly string[];
30
+ }
31
+ /**
32
+ * Builds a Mastra tool that captures the caller's consent decisions at runtime — the companion to
33
+ * the worker's `configuration.consentPolicy`, which only DECLARES which consents a call needs. Add
34
+ * it to the agent that answers the call; on each call the tool reads the caller's `resourceId` /
35
+ * `threadId` from its execution context and hands the decision to your `onGrant` store. The runtime
36
+ * grants live only where `onGrant` put them: enforce consent by reading them back from your own
37
+ * store — at `onCallEnd` or before any consent-gated action — cross-checking against the declared
38
+ * requirements in `VoiceCallEndArgs.configuration.consentPolicy` (the configuration carries the
39
+ * policy, never the grants).
40
+ *
41
+ * ```ts
42
+ * // agent tools
43
+ * recordConsent: createConsentTool({
44
+ * items: ['summaryStorage'],
45
+ * onGrant: async ({ item, granted, resourceId }) => {
46
+ * if (resourceId) await db.saveConsent(resourceId, item, granted);
47
+ * },
48
+ * }),
49
+ * ```
50
+ */
51
+ export declare function createConsentTool(options: ConsentToolOptions): import("@mastra/core/tools").Tool<{
52
+ item: string;
53
+ granted: boolean;
54
+ }, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, string, unknown>;
55
+ //# sourceMappingURL=consent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consent.d.ts","sourceRoot":"","sources":["../src/consent.ts"],"names":[],"mappings":"AAMA,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,8DAA8D;IAC9D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB;;;6HAiB5D"}
@@ -0,0 +1,3 @@
1
+ /** Default LiveKit agent name used for explicit dispatch when none is configured. */
2
+ export declare const DEFAULT_LIVEKIT_AGENT_NAME = "mastra-voice";
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,eAAO,MAAM,0BAA0B,iBAAiB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { LiveKitSessionMetadata } from './metadata.js';
2
+ import type { LiveKitRecordingOptions } from './recording.js';
3
+ export interface DispatchVoiceSessionOptions {
4
+ /**
5
+ * Room to dispatch the agent into (created on demand). With recording enabled, use a unique
6
+ * name for each call. An existing room throws LiveKitRecordingRoomConflictError.
7
+ */
8
+ roomName: string;
9
+ /** Must match the worker's `agentName`. Defaults to `'mastra-voice'`. */
10
+ agentName?: string;
11
+ metadata?: LiveKitSessionMetadata;
12
+ /** Create a fresh room with automatic recording before dispatch. Omit to keep dispatch-only behavior. */
13
+ recording?: LiveKitRecordingOptions;
14
+ /** Defaults to `LIVEKIT_URL`. */
15
+ serverUrl?: string;
16
+ /** Defaults to `LIVEKIT_API_KEY`. */
17
+ apiKey?: string;
18
+ /** Defaults to `LIVEKIT_API_SECRET`. */
19
+ apiSecret?: string;
20
+ }
21
+ /**
22
+ * Programmatically dispatches a Mastra voice agent into a LiveKit room — for
23
+ * server-initiated sessions such as outbound calls or joining an existing room.
24
+ */
25
+ export declare function dispatchVoiceSession(options: DispatchVoiceSessionOptions): Promise<import("livekit-server-sdk").AgentDispatch>;
26
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,yGAAyG;IACzG,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,uDA0B9E"}
@@ -0,0 +1,50 @@
1
+ /** Details of the agent's decision to end the call, handed to {@link EndCallToolOptions.onEndCall}. */
2
+ export interface EndCallRequest {
3
+ /** Short reason the agent gave for ending the call, if any (e.g. "caller said goodbye"). */
4
+ reason?: string;
5
+ /** The caller the call belongs to (the memory `resource`), when the call is memory-scoped. */
6
+ resourceId?: string;
7
+ /** The call thread, when the call is memory-scoped. */
8
+ threadId?: string;
9
+ }
10
+ export interface EndCallToolOptions {
11
+ /**
12
+ * Tool id the agent calls to end the call. Must match the worker's
13
+ * `configuration.endCall.tool` (both default to `'endCall'`), since that's the name the worker
14
+ * watches for to hang up.
15
+ */
16
+ id?: string;
17
+ /** Override the description the model sees when deciding to call the tool. */
18
+ description?: string;
19
+ /**
20
+ * Optional bookkeeping hook, called when the agent invokes the tool (records the reason, marks
21
+ * the call resolved in your CRM, …). Runs inside the turn — keep it quick. It does NOT hang up
22
+ * the call; the worker does that once the agent's final words finish playing. The tool reads the
23
+ * caller's identity from its execution context and passes it here.
24
+ */
25
+ onEndCall?: (request: EndCallRequest) => void | Promise<void>;
26
+ }
27
+ /**
28
+ * Builds a Mastra tool the agent calls to end the call itself (say goodbye → hang up). It is the
29
+ * agent-visible half of agent-initiated hang-up: the tool only SIGNALS intent (and runs optional
30
+ * bookkeeping) — it can't reach the LiveKit room from inside `agent.stream()`. The worker owns the
31
+ * hang-up: with `configuration.endCall` set, it watches each turn for this tool, waits for the
32
+ * agent's closing words to finish playing, then disconnects (running `onCallEnd` on the way out).
33
+ * Keeping the tool inside the single agent means it stays visible/editable in Studio and works on
34
+ * the agent and workflow reply paths alike.
35
+ *
36
+ * ```ts
37
+ * // agent tools
38
+ * endCall: createEndCallTool({
39
+ * onEndCall: ({ reason, resourceId }) => log.info('agent ended call', { reason, resourceId }),
40
+ * }),
41
+ * // worker
42
+ * createLiveKitWorker({ mastra, agent: 'support', configuration: { endCall: {} } });
43
+ * ```
44
+ */
45
+ export declare function createEndCallTool(options?: EndCallToolOptions): import("@mastra/core/tools").Tool<{
46
+ reason?: string | null | undefined;
47
+ }, {
48
+ ended: boolean;
49
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, string, unknown>;
50
+ //# sourceMappingURL=end-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"end-call.d.ts","sourceRoot":"","sources":["../src/end-call.ts"],"names":[],"mappings":"AAMA,uGAAuG;AACvG,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAUD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB;;;;oHA0BjE"}