@mastra/voice-openai-realtime 0.1.0-alpha.1 → 0.1.0-alpha.2
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs +7 -5
- package/dist/index.js +7 -5
- package/package.json +2 -2
- package/src/index.ts +22 -21
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/voice-openai-realtime@0.1.0-alpha.
|
|
2
|
+
> @mastra/voice-openai-realtime@0.1.0-alpha.2 build /home/runner/work/mastra/mastra/voice/openai-realtime-api
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 9123ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/voice/openai-realtime-api/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/voice/openai-realtime-api/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 10151ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m17.
|
|
21
|
-
[32mCJS[39m ⚡️ Build success in
|
|
22
|
-
[32mESM[39m [1mdist/index.js [22m[32m17.
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m17.80 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 842ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m17.75 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 843ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/voice-openai-realtime
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a838fde]
|
|
8
|
+
- Updated dependencies [a8bd4cf]
|
|
9
|
+
- Updated dependencies [7a3eeb0]
|
|
10
|
+
- Updated dependencies [6530ad1]
|
|
11
|
+
- @mastra/core@0.7.0-alpha.2
|
|
12
|
+
|
|
3
13
|
## 0.1.0-alpha.1
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var events = require('events');
|
|
4
4
|
var stream = require('stream');
|
|
5
|
-
var
|
|
5
|
+
var voice = require('@mastra/core/voice');
|
|
6
6
|
var ws = require('ws');
|
|
7
|
-
var
|
|
7
|
+
var zodToJsonSchema = require('zod-to-json-schema');
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
var transformTools = (tools) => {
|
|
@@ -65,6 +65,8 @@ var transformTools = (tools) => {
|
|
|
65
65
|
var isReadableStream = (obj) => {
|
|
66
66
|
return obj && obj instanceof stream.Readable && typeof obj.read === "function" && typeof obj.pipe === "function" && obj.readable === true;
|
|
67
67
|
};
|
|
68
|
+
|
|
69
|
+
// src/index.ts
|
|
68
70
|
var DEFAULT_VOICE = "alloy";
|
|
69
71
|
var DEFAULT_URL = "wss://api.openai.com/v1/realtime";
|
|
70
72
|
var DEFAULT_MODEL = "gpt-4o-mini-realtime-preview-2024-12-17";
|
|
@@ -502,8 +504,8 @@ var OpenAIRealtimeVoice = class extends voice.MastraVoice {
|
|
|
502
504
|
this.client.on("response.text.done", (ev) => {
|
|
503
505
|
this.emit("writing", { text: "\n", response_id: ev.response_id });
|
|
504
506
|
});
|
|
505
|
-
this.client.on("response.done", (ev) => {
|
|
506
|
-
this.handleFunctionCalls(ev);
|
|
507
|
+
this.client.on("response.done", async (ev) => {
|
|
508
|
+
await this.handleFunctionCalls(ev);
|
|
507
509
|
this.emit("response.done", ev);
|
|
508
510
|
speakerStreams.delete(ev.response.id);
|
|
509
511
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
2
|
import { PassThrough, Readable } from 'stream';
|
|
3
|
-
import {
|
|
3
|
+
import { MastraVoice } from '@mastra/core/voice';
|
|
4
4
|
import { WebSocket } from 'ws';
|
|
5
|
-
import {
|
|
5
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
var transformTools = (tools) => {
|
|
@@ -63,6 +63,8 @@ var transformTools = (tools) => {
|
|
|
63
63
|
var isReadableStream = (obj) => {
|
|
64
64
|
return obj && obj instanceof Readable && typeof obj.read === "function" && typeof obj.pipe === "function" && obj.readable === true;
|
|
65
65
|
};
|
|
66
|
+
|
|
67
|
+
// src/index.ts
|
|
66
68
|
var DEFAULT_VOICE = "alloy";
|
|
67
69
|
var DEFAULT_URL = "wss://api.openai.com/v1/realtime";
|
|
68
70
|
var DEFAULT_MODEL = "gpt-4o-mini-realtime-preview-2024-12-17";
|
|
@@ -500,8 +502,8 @@ var OpenAIRealtimeVoice = class extends MastraVoice {
|
|
|
500
502
|
this.client.on("response.text.done", (ev) => {
|
|
501
503
|
this.emit("writing", { text: "\n", response_id: ev.response_id });
|
|
502
504
|
});
|
|
503
|
-
this.client.on("response.done", (ev) => {
|
|
504
|
-
this.handleFunctionCalls(ev);
|
|
505
|
+
this.client.on("response.done", async (ev) => {
|
|
506
|
+
await this.handleFunctionCalls(ev);
|
|
505
507
|
this.emit("response.done", ev);
|
|
506
508
|
speakerStreams.delete(ev.response.id);
|
|
507
509
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-openai-realtime",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Mastra OpenAI Realtime API integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"openai-realtime-api": "^1.0.7",
|
|
23
23
|
"ws": "^8.18.1",
|
|
24
24
|
"zod-to-json-schema": "^3.24.1",
|
|
25
|
-
"@mastra/core": "^0.7.0-alpha.
|
|
25
|
+
"@mastra/core": "^0.7.0-alpha.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@microsoft/api-extractor": "^7.49.2",
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { PassThrough } from 'stream';
|
|
1
3
|
import type { ToolsInput } from '@mastra/core/agent';
|
|
2
4
|
import { MastraVoice } from '@mastra/core/voice';
|
|
3
|
-
import { isReadableStream, transformTools } from './utils';
|
|
4
|
-
import { WebSocket } from 'ws';
|
|
5
|
-
import { EventEmitter } from 'events';
|
|
6
5
|
import type { Realtime, RealtimeServerEvents } from 'openai-realtime-api';
|
|
7
|
-
import {
|
|
6
|
+
import { WebSocket } from 'ws';
|
|
7
|
+
import { isReadableStream, transformTools } from './utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Event callback function type
|
|
@@ -36,21 +36,22 @@ const DEFAULT_URL = 'wss://api.openai.com/v1/realtime';
|
|
|
36
36
|
* This model is optimized for low-latency responses while maintaining high quality output.
|
|
37
37
|
*/
|
|
38
38
|
const DEFAULT_MODEL = 'gpt-4o-mini-realtime-preview-2024-12-17';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
|
|
40
|
+
// /**
|
|
41
|
+
// * Default Voice Activity Detection (VAD) configuration.
|
|
42
|
+
// * These settings control how the system detects speech segments.
|
|
43
|
+
// *
|
|
44
|
+
// * @property {string} type - Uses server-side VAD for better accuracy
|
|
45
|
+
// * @property {number} threshold - Speech detection sensitivity (0.5 = balanced)
|
|
46
|
+
// * @property {number} prefix_padding_ms - Includes 1 second of audio before speech
|
|
47
|
+
// * @property {number} silence_duration_ms - Waits 1 second of silence before ending turn
|
|
48
|
+
// */
|
|
49
|
+
// const DEFAULT_VAD_CONFIG = {
|
|
50
|
+
// type: 'server_vad',
|
|
51
|
+
// threshold: 0.5,
|
|
52
|
+
// prefix_padding_ms: 1000,
|
|
53
|
+
// silence_duration_ms: 1000,
|
|
54
|
+
// } as Realtime.TurnDetection;
|
|
54
55
|
|
|
55
56
|
type TTools = ToolsInput;
|
|
56
57
|
|
|
@@ -580,8 +581,8 @@ export class OpenAIRealtimeVoice extends MastraVoice {
|
|
|
580
581
|
this.client.on('response.text.done', ev => {
|
|
581
582
|
this.emit('writing', { text: '\n', response_id: ev.response_id });
|
|
582
583
|
});
|
|
583
|
-
this.client.on('response.done', ev => {
|
|
584
|
-
this.handleFunctionCalls(ev);
|
|
584
|
+
this.client.on('response.done', async ev => {
|
|
585
|
+
await this.handleFunctionCalls(ev);
|
|
585
586
|
this.emit('response.done', ev);
|
|
586
587
|
speakerStreams.delete(ev.response.id);
|
|
587
588
|
});
|