@mastra/livekit 0.3.0-alpha.0 → 0.3.0
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.
- package/CHANGELOG.md +136 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,141 @@
|
|
|
1
1
|
# @mastra/livekit
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added per-call speech-to-text and text-to-speech selection to `createLiveKitWorker`. Set the new `configuration.stt` and `configuration.tts` resolvers to pick the transcriber and voice for each call — one voice or language per tenant — keyed off the dispatch metadata and request context. Each resolver runs once per call and falls back to the top-level `stt` / `tts` option when it returns `undefined`. ([#19136](https://github.com/mastra-ai/mastra/pull/19136))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export default createLiveKitWorker({
|
|
11
|
+
mastra,
|
|
12
|
+
agent: 'support',
|
|
13
|
+
stt: 'deepgram/nova-3',
|
|
14
|
+
tts: 'cartesia/sonic-3', // fallback voice
|
|
15
|
+
configuration: {
|
|
16
|
+
// Give each tenant its own voice, resolved per call from the dispatch metadata.
|
|
17
|
+
tts: ({ requestContext }) => tenantVoices[requestContext?.tenant as string],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Previously the worker's speech pipeline was fixed at construction, so a multi-tenant worker could not vary voices or transcription per call. Customers who own their LiveKit session (the `MastraLLM` plugin path) already choose STT/TTS per call by construction; this brings the same flexibility to the batteries-included worker.
|
|
23
|
+
|
|
24
|
+
- Added `MastraLLM`, a standard LiveKit LLM plugin, on the new `@mastra/livekit/plugin` entry point. Build your own `voice.AgentSession` and put a Mastra agent in the `llm` slot — the agent loop, tools, and memory run on a remote Mastra server reached over HTTP, so the worker process needs no Mastra app, database, or model provider keys. ([#19136](https://github.com/mastra-ai/mastra/pull/19136))
|
|
25
|
+
|
|
26
|
+
Before, the worker wrapper always owned the LiveKit session:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createLiveKitWorker } from '@mastra/livekit/worker';
|
|
30
|
+
import { mastra } from './index';
|
|
31
|
+
|
|
32
|
+
export default createLiveKitWorker({
|
|
33
|
+
mastra,
|
|
34
|
+
agent: 'support',
|
|
35
|
+
stt: 'deepgram/nova-3',
|
|
36
|
+
tts: 'cartesia/sonic-3',
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Now you can own the session and keep Mastra as the LLM component:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { voice } from '@livekit/agents';
|
|
44
|
+
import { MastraLLM } from '@mastra/livekit/plugin';
|
|
45
|
+
|
|
46
|
+
const session = new voice.AgentSession({
|
|
47
|
+
llm: new MastraLLM({
|
|
48
|
+
remote: { baseUrl: process.env.MASTRA_URL!, agentId: 'support' },
|
|
49
|
+
memory: { thread: callId, resource: userId },
|
|
50
|
+
}),
|
|
51
|
+
stt: 'deepgram/nova-3',
|
|
52
|
+
tts: 'cartesia/sonic-3',
|
|
53
|
+
// Required with `memory`: LiveKit enables preemptive generation by default.
|
|
54
|
+
turnHandling: { preemptiveGeneration: { enabled: false } },
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`createLiveKitWorker` stays the batteries-included path; the plugin is the composable one. Tools keep running server-side on the Mastra agent, and interrupting the agent aborts the server-side generation.
|
|
59
|
+
|
|
60
|
+
**New transport and helpers**
|
|
61
|
+
- Added `createRemoteAgentReplyGenerator()`: streams replies from a remote Mastra server over HTTP with per-turn abort, LiveKit-typed errors, and a connect + first-token timeout. It also plugs into `createLiveKitWorker`'s `generate` option to run the existing worker against a remote server.
|
|
62
|
+
- Promoted `speakGreeting()`, `waitForAgentDoneSpeaking()`, and `runEndCall()` to public exports of `@mastra/livekit/worker`, so a worker that owns its session can rebuild the greeting and agent-initiated hang-up patterns in a few lines.
|
|
63
|
+
|
|
64
|
+
**Improvements to the existing worker**
|
|
65
|
+
- Interrupted turns now self-heal: when a caller interrupts a reply, nothing is persisted at that moment, and the part the caller actually heard is backfilled into the memory thread on the next turn — so saved transcripts match the call.
|
|
66
|
+
- Added an `onToolCall` hook that fires as each tool call starts mid-reply, the building block for tool-driven side effects such as analytics or hang-up.
|
|
67
|
+
- `onTurnComplete` now receives the turn's token usage as `result.usage`.
|
|
68
|
+
|
|
69
|
+
- Added a `configuration` option to `createLiveKitWorker` — one grouped home for conversation and compliance controls, so these don't each become a separate top-level worker option. It ships with greeting/AI-disclosure controls, a consent model, and agent-initiated hang-up, and is where further compliance controls will land. ([#19136](https://github.com/mastra-ai/mastra/pull/19136))
|
|
70
|
+
|
|
71
|
+
**Greeting and AI disclosure**
|
|
72
|
+
|
|
73
|
+
`configuration.greeting` controls the opening line spoken at call start. Set `allowInterruptions: false` so a legally-required AI disclosure plays through and can't be talked over (EU AI Act Art. 50), `awaitPlayout: true` to hold post-greeting work until it finishes, and `repeatEvery` to re-disclose periodically on long calls (spoken at the next turn boundary, never mid-sentence).
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
createLiveKitWorker({
|
|
77
|
+
mastra,
|
|
78
|
+
agent: 'support',
|
|
79
|
+
configuration: {
|
|
80
|
+
greeting: {
|
|
81
|
+
text: 'You are speaking with an AI assistant. This call may be recorded. How can I help?',
|
|
82
|
+
allowInterruptions: false,
|
|
83
|
+
awaitPlayout: true,
|
|
84
|
+
repeatEvery: 3 * 60_000, // re-disclose ~every 3 minutes
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Per-tenant greeting**
|
|
91
|
+
|
|
92
|
+
`greeting.text` also accepts a resolver, called once per call with the call context, so one multi-tenant agent can open differently per tenant based on the dispatch metadata:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
greeting: {
|
|
96
|
+
text: ({ metadata }) => `Thanks for calling ${tenantName(metadata)}. You're speaking with an AI assistant.`,
|
|
97
|
+
allowInterruptions: false,
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Consent**
|
|
102
|
+
|
|
103
|
+
`configuration.consentPolicy` declares which data-use consents a call needs, as a named, extensible set (starting with `summaryStorage`) rather than one global flag. Declaring the policy enforces nothing by itself: the new `createConsentTool` captures the caller's decision at runtime — add it to your agent and it hands each decision to your own store — and your code enforces the requirement at `onCallEnd` (or before any consent-gated step).
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { createConsentTool } from '@mastra/livekit';
|
|
107
|
+
|
|
108
|
+
// in your agent's tools:
|
|
109
|
+
recordConsent: createConsentTool({
|
|
110
|
+
items: ['summaryStorage'],
|
|
111
|
+
onGrant: async ({ item, granted, resourceId }) => {
|
|
112
|
+
if (resourceId) await db.saveConsent(resourceId, item, granted);
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Agent-initiated hang-up**
|
|
118
|
+
|
|
119
|
+
`configuration.endCall` lets the agent end the call itself. Add the new `createEndCallTool` to your agent and instruct it to say goodbye and then call the tool; the worker waits for the closing words to finish playing, holds a short audio drain (`drainMs`, default 800ms) so the tail of the goodbye isn't clipped while it's still buffered at the caller, then hangs up — running `onCallEnd` on the way out, exactly as a caller hang-up does. It works on both the agent and workflow reply paths.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { createEndCallTool } from '@mastra/livekit';
|
|
123
|
+
|
|
124
|
+
// in your agent's tools:
|
|
125
|
+
endCall: (createEndCallTool(),
|
|
126
|
+
// on the worker:
|
|
127
|
+
createLiveKitWorker({ mastra, agent: 'support', configuration: { endCall: {} } }));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Backwards compatible**
|
|
131
|
+
|
|
132
|
+
The previous top-level `greeting` (string) and `persistGreeting` options still work as deprecated aliases for `configuration.greeting.text` and `configuration.greeting.persist`. When both are set, `configuration.greeting` wins field by field, so existing worker configs keep running unchanged.
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- Updated dependencies [[`bd6d240`](https://github.com/mastra-ai/mastra/commit/bd6d2402db93dddaef0721667e7e8a030e7c6e16), [`0111486`](https://github.com/mastra-ai/mastra/commit/01114867612593eef5cfa2fda6a1194dfedda841), [`96a3749`](https://github.com/mastra-ai/mastra/commit/96a37492235f5b8076b3e3177d83ed5a5e44a640), [`fe1bda0`](https://github.com/mastra-ai/mastra/commit/fe1bda06f6af92a694a51712db747cda1e7185f0), [`25e7c12`](https://github.com/mastra-ai/mastra/commit/25e7c126a770069ae7fb7ecf1d2adb40e017b009), [`1ce5121`](https://github.com/mastra-ai/mastra/commit/1ce512155d122bb21f47d98383e82ffbf84b39e8), [`fb8aea3`](https://github.com/mastra-ai/mastra/commit/fb8aea384291e77311be3a64ee1717320d5c3c73), [`4adc391`](https://github.com/mastra-ai/mastra/commit/4adc3911075249c352bb4832d2471922826344de), [`a5c6337`](https://github.com/mastra-ai/mastra/commit/a5c6337d23c7686c81a32ce62f550f610543a240), [`3cfc47a`](https://github.com/mastra-ai/mastra/commit/3cfc47a6b89940aadd0f46fb01ae9624a73a865d), [`2bb7817`](https://github.com/mastra-ai/mastra/commit/2bb78176112fde628483de2830528f7eee911e56), [`51d9870`](https://github.com/mastra-ai/mastra/commit/51d987032c689c2855374d0f244f5d654da809d1), [`5cab274`](https://github.com/mastra-ai/mastra/commit/5cab2744250e22d12fefa7b32637dce224233cee), [`7fa27d3`](https://github.com/mastra-ai/mastra/commit/7fa27d3b6f5ed68cd34e454a4d3ad9c482a0cfbc), [`8b97958`](https://github.com/mastra-ai/mastra/commit/8b979589f9aa59ba67cac565949475f2ffeb4ac3), [`8410541`](https://github.com/mastra-ai/mastra/commit/84105412c60ecd3bb33a9838146f59c4b588228f), [`a58dcbb`](https://github.com/mastra-ai/mastra/commit/a58dcbb546d7e1d65ebdc1f39e55f0908fcd9391), [`aa38805`](https://github.com/mastra-ai/mastra/commit/aa38805b878b827403be785eb90688d7172f5a40), [`153bd3b`](https://github.com/mastra-ai/mastra/commit/153bd3b396bdfed6b74cf43de12db8fd2d83c04a), [`45a8e65`](https://github.com/mastra-ai/mastra/commit/45a8e65e1556d1362cb3f25187023c36de26661d), [`e955965`](https://github.com/mastra-ai/mastra/commit/e955965dce575a903e37cf054d28ea99aa48785e), [`2d22570`](https://github.com/mastra-ai/mastra/commit/2d22570c7dfdd02123d0ecc529efb05ccba2d9fc), [`07bb863`](https://github.com/mastra-ai/mastra/commit/07bb8631919c6f7cf377dccd45b096e0f17fbed0), [`c8ed116`](https://github.com/mastra-ai/mastra/commit/c8ed11699f62bcac70102ab4ec84d80d20541da6), [`01b338c`](https://github.com/mastra-ai/mastra/commit/01b338c56271f0219606710e3e8b26dee27ac6c2), [`a99eae8`](https://github.com/mastra-ai/mastra/commit/a99eae8908e500c1b2d12f9d277be616b98617a5), [`860ef7e`](https://github.com/mastra-ai/mastra/commit/860ef7e77d92b63469cbe5857aa1e626197e43e9), [`17e818c`](https://github.com/mastra-ai/mastra/commit/17e818c51a958ba90641b1a959dc38faf8c034e9), [`edce8d2`](https://github.com/mastra-ai/mastra/commit/edce8d2769f19e27a05737c627af2d765472a4f8), [`8a586ec`](https://github.com/mastra-ai/mastra/commit/8a586eca9a4914f31dff6140d0d45ac375b00669), [`4451dfe`](https://github.com/mastra-ai/mastra/commit/4451dfe857428e7abcc0261a507a2e186dae6d47), [`8b7361d`](https://github.com/mastra-ai/mastra/commit/8b7361d35de68b80d05d30a74e0c69e7218fd612), [`1d39058`](https://github.com/mastra-ai/mastra/commit/1d39058e548efd691799985d5c8af2737f1c3bd2), [`3927473`](https://github.com/mastra-ai/mastra/commit/392747323ddb10c643d12be7b9ae913159dfaeed), [`dce50dc`](https://github.com/mastra-ai/mastra/commit/dce50dc9a1c1fcd0f427bb5f6250ec74910cb04b), [`fd13f8e`](https://github.com/mastra-ai/mastra/commit/fd13f8e21990f9904c3eedba3a626bb4a929cdb8), [`634caff`](https://github.com/mastra-ai/mastra/commit/634caff29a9200ad058b67d53f96d9e5832fb8a2), [`f703f87`](https://github.com/mastra-ai/mastra/commit/f703f878de072d51fda557f9c50867d8252bef05), [`3e26c87`](https://github.com/mastra-ai/mastra/commit/3e26c87de0c5bc2583b795ce6ca5889b6b161acb), [`33f2b88`](https://github.com/mastra-ai/mastra/commit/33f2b88842c09a567f906fac4cb61cd5277ced59), [`177010f`](https://github.com/mastra-ai/mastra/commit/177010ff096d2e4b28d89803be5b1a4cad2a0d6b), [`0ad646f`](https://github.com/mastra-ai/mastra/commit/0ad646f71a530f2454664299e5e01bfd13fa12e5), [`b486abf`](https://github.com/mastra-ai/mastra/commit/b486abfa2a7528c6f527e4015c819ea9fa54aaad), [`54a51e0`](https://github.com/mastra-ai/mastra/commit/54a51e0a484fe1ebad3fb1f7ef5282a075709eb7), [`c43f3a9`](https://github.com/mastra-ai/mastra/commit/c43f3a9d1efde99b38789364ba4d0ba670f430e3), [`a5008f2`](https://github.com/mastra-ai/mastra/commit/a5008f22ae710ad9402ea9f2547d8c02f74d384b), [`e2d5f37`](https://github.com/mastra-ai/mastra/commit/e2d5f373bd289be534d5f8694d34465010533df6), [`4ce0163`](https://github.com/mastra-ai/mastra/commit/4ce0163dc86e675a86809685c8ce6c49f1aeb87e), [`4378341`](https://github.com/mastra-ai/mastra/commit/43783412df5ea3dd35f5b1f6e4851e79c346fc89)]:
|
|
137
|
+
- @mastra/core@1.51.0
|
|
138
|
+
|
|
3
139
|
## 0.3.0-alpha.0
|
|
4
140
|
|
|
5
141
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/livekit",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "LiveKit voice integration for Mastra agents — realtime voice with semantic turn detection and barge-in",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -87,15 +87,15 @@
|
|
|
87
87
|
"@livekit/agents": "^1.4.5",
|
|
88
88
|
"@livekit/agents-plugin-livekit": "^1.4.5",
|
|
89
89
|
"@livekit/agents-plugin-silero": "^1.4.5",
|
|
90
|
-
"@types/node": "22.
|
|
90
|
+
"@types/node": "22.20.1",
|
|
91
91
|
"eslint": "^10.4.1",
|
|
92
92
|
"tsup": "^8.5.1",
|
|
93
93
|
"typescript": "^6.0.3",
|
|
94
|
-
"vitest": "4.1.
|
|
94
|
+
"vitest": "4.1.10",
|
|
95
95
|
"zod": "^4.4.3",
|
|
96
|
-
"@
|
|
97
|
-
"@internal/
|
|
98
|
-
"@
|
|
96
|
+
"@internal/types-builder": "0.0.89",
|
|
97
|
+
"@internal/lint": "0.0.114",
|
|
98
|
+
"@mastra/core": "1.51.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"build:lib": "tsup --silent --config tsup.config.ts",
|