@mastra/livekit 0.0.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/README.md +59 -0
- package/package.json +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @mastra/livekit
|
|
2
|
+
|
|
3
|
+
LiveKit voice integration for Mastra agents. LiveKit's agents framework runs the audio loop — WebRTC transport, voice activity detection, streaming speech-to-text, semantic turn detection, barge-in, and text-to-speech — and this package bridges reply generation to a Mastra agent's `stream()` call, so tools, memory, and model routing all run inside Mastra.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/livekit @livekit/agents @livekit/agents-plugin-silero @livekit/agents-plugin-livekit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Create a worker entry file:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// src/mastra/voice-worker.ts
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { createLiveKitWorker, runLiveKitWorker } from '@mastra/livekit';
|
|
19
|
+
import { mastra } from './index';
|
|
20
|
+
|
|
21
|
+
export default createLiveKitWorker({
|
|
22
|
+
mastra,
|
|
23
|
+
agent: 'support',
|
|
24
|
+
stt: 'deepgram/nova-3',
|
|
25
|
+
tts: 'cartesia/sonic-3',
|
|
26
|
+
turnDetection: 'multilingual',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
30
|
+
runLiveKitWorker({ entry: import.meta.url, agentName: 'mastra-voice' });
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Add a connection endpoint so frontends can join voice sessions:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// src/mastra/index.ts
|
|
38
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
39
|
+
import { liveKitConnectionRoute } from '@mastra/livekit';
|
|
40
|
+
|
|
41
|
+
export const mastra = new Mastra({
|
|
42
|
+
server: {
|
|
43
|
+
apiRoutes: [liveKitConnectionRoute({ agentName: 'mastra-voice' })],
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Run the worker alongside your Mastra server:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx livekit-agents download-files
|
|
52
|
+
npx tsx src/mastra/voice-worker.ts dev
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
- [Using LiveKit with Mastra](https://mastra.ai/docs/voice/livekit)
|
|
58
|
+
- [`@mastra/livekit` reference](https://mastra.ai/reference/voice/livekit)
|
|
59
|
+
- [LiveKit Agents docs](https://docs.livekit.io/agents/)
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mastra/livekit",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "LiveKit voice integration for Mastra agents — realtime voice with semantic turn detection and barge-in",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"CHANGELOG.md"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
27
|
+
"build:watch": "pnpm build:lib --watch",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "vitest run"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"mastra",
|
|
33
|
+
"livekit",
|
|
34
|
+
"voice",
|
|
35
|
+
"voice-agent",
|
|
36
|
+
"webrtc",
|
|
37
|
+
"turn-detection",
|
|
38
|
+
"ai-agent"
|
|
39
|
+
],
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
44
|
+
"directory": "integrations/livekit"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://mastra.ai",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.13.0"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@livekit/protocol": "^1.46.6",
|
|
55
|
+
"livekit-server-sdk": "^2.15.4"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@livekit/agents": "^1.4.0",
|
|
59
|
+
"@livekit/agents-plugin-livekit": "^1.4.0",
|
|
60
|
+
"@livekit/agents-plugin-silero": "^1.4.0",
|
|
61
|
+
"@mastra/core": ">=1.0.0-0 <2.0.0-0",
|
|
62
|
+
"zod": ">=3.0.0 || >=4.0.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@livekit/agents-plugin-livekit": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@livekit/agents-plugin-silero": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@internal/lint": "workspace:*",
|
|
74
|
+
"@internal/types-builder": "workspace:*",
|
|
75
|
+
"@livekit/agents": "^1.4.5",
|
|
76
|
+
"@livekit/agents-plugin-livekit": "^1.4.5",
|
|
77
|
+
"@livekit/agents-plugin-silero": "^1.4.5",
|
|
78
|
+
"@mastra/core": "workspace:*",
|
|
79
|
+
"@types/node": "22.19.15",
|
|
80
|
+
"eslint": "^10.4.1",
|
|
81
|
+
"tsup": "^8.5.1",
|
|
82
|
+
"typescript": "catalog:",
|
|
83
|
+
"vitest": "catalog:",
|
|
84
|
+
"zod": "catalog:"
|
|
85
|
+
}
|
|
86
|
+
}
|