@mastra/voice-openai-realtime 0.2.0-alpha.3 → 0.2.0-alpha.5

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/voice-openai-realtime@0.2.0-alpha.3 build /home/runner/work/mastra/mastra/voice/openai-realtime-api
2
+ > @mastra/voice-openai-realtime@0.2.0-alpha.5 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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 10105ms
9
+ TSC ⚡️ Build success in 9585ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.2
13
13
  Writing package typings: /home/runner/work/mastra/mastra/voice/openai-realtime-api/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.2
15
15
  Writing package typings: /home/runner/work/mastra/mastra/voice/openai-realtime-api/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11772ms
16
+ DTS ⚡️ Build success in 11761ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 18.72 KB
21
- ESM ⚡️ Build success in 762ms
22
- CJS dist/index.cjs 18.77 KB
23
- CJS ⚡️ Build success in 764ms
20
+ ESM dist/index.js 19.06 KB
21
+ ESM ⚡️ Build success in 844ms
22
+ CJS dist/index.cjs 19.12 KB
23
+ CJS ⚡️ Build success in 848ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/voice-openai-realtime
2
2
 
3
+ ## 0.2.0-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 6cf1417: Voice reference and tool-call-start
8
+ - Updated dependencies [fe3ae4d]
9
+ - @mastra/core@0.9.0-alpha.3
10
+
11
+ ## 0.2.0-alpha.4
12
+
13
+ ### Minor Changes
14
+
15
+ - 1ef0f1f: Disconnect
16
+
3
17
  ## 0.2.0-alpha.3
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -20,6 +20,7 @@ OPENAI_API_KEY=your_api_key
20
20
 
21
21
  ```typescript
22
22
  import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime';
23
+ import { getMicrophoneStream } from '@mastra/node-audio';
23
24
 
24
25
  // Create a voice instance with default configuration
25
26
  const voice = new OpenAIRealtimeVoice();
@@ -221,6 +221,7 @@ export declare class OpenAIRealtimeVoice extends MastraVoice {
221
221
  * ```
222
222
  */
223
223
  connect(): Promise<void>;
224
+ disconnect(): void;
224
225
  /**
225
226
  * Streams audio data in real-time to the OpenAI service.
226
227
  * Useful for continuous audio streaming scenarios like live microphone input.
@@ -221,6 +221,7 @@ export declare class OpenAIRealtimeVoice extends MastraVoice {
221
221
  * ```
222
222
  */
223
223
  connect(): Promise<void>;
224
+ disconnect(): void;
224
225
  /**
225
226
  * Streams audio data in real-time to the OpenAI service.
226
227
  * Useful for continuous audio streaming scenarios like live microphone input.
package/dist/index.cjs CHANGED
@@ -322,8 +322,7 @@ var OpenAIRealtimeVoice = class extends voice.MastraVoice {
322
322
  }
323
323
  });
324
324
  this.setupEventListeners();
325
- await this.waitForOpen();
326
- await this.waitForSessionCreated();
325
+ await Promise.all([this.waitForOpen(), this.waitForSessionCreated()]);
327
326
  const openaiTools = transformTools(this.tools);
328
327
  this.updateConfig({
329
328
  instructions: this.instructions,
@@ -335,6 +334,10 @@ var OpenAIRealtimeVoice = class extends voice.MastraVoice {
335
334
  });
336
335
  this.state = "open";
337
336
  }
337
+ disconnect() {
338
+ this.state = "close";
339
+ this.ws?.close();
340
+ }
338
341
  /**
339
342
  * Streams audio data in real-time to the OpenAI service.
340
343
  * Useful for continuous audio streaming scenarios like live microphone input.
@@ -545,16 +548,25 @@ var OpenAIRealtimeVoice = class extends voice.MastraVoice {
545
548
  console.warn(`Tool "${output.name}" not found`);
546
549
  return;
547
550
  }
551
+ if (tool?.execute) {
552
+ this.emit("tool-call-start", {
553
+ toolCallId: output.call_id,
554
+ toolName: output.name,
555
+ toolDescription: tool.description,
556
+ args: context
557
+ });
558
+ }
548
559
  const result = await tool?.execute?.(
549
560
  { context },
550
561
  {
551
- toolCallId: "unknown",
562
+ toolCallId: output.call_id,
552
563
  messages: []
553
564
  }
554
565
  );
555
- this.emit("tool-result", {
566
+ this.emit("tool-call-result", {
556
567
  toolCallId: output.call_id,
557
568
  toolName: output.name,
569
+ toolDescription: tool.description,
558
570
  args: context,
559
571
  result
560
572
  });
package/dist/index.js CHANGED
@@ -320,8 +320,7 @@ var OpenAIRealtimeVoice = class extends MastraVoice {
320
320
  }
321
321
  });
322
322
  this.setupEventListeners();
323
- await this.waitForOpen();
324
- await this.waitForSessionCreated();
323
+ await Promise.all([this.waitForOpen(), this.waitForSessionCreated()]);
325
324
  const openaiTools = transformTools(this.tools);
326
325
  this.updateConfig({
327
326
  instructions: this.instructions,
@@ -333,6 +332,10 @@ var OpenAIRealtimeVoice = class extends MastraVoice {
333
332
  });
334
333
  this.state = "open";
335
334
  }
335
+ disconnect() {
336
+ this.state = "close";
337
+ this.ws?.close();
338
+ }
336
339
  /**
337
340
  * Streams audio data in real-time to the OpenAI service.
338
341
  * Useful for continuous audio streaming scenarios like live microphone input.
@@ -543,16 +546,25 @@ var OpenAIRealtimeVoice = class extends MastraVoice {
543
546
  console.warn(`Tool "${output.name}" not found`);
544
547
  return;
545
548
  }
549
+ if (tool?.execute) {
550
+ this.emit("tool-call-start", {
551
+ toolCallId: output.call_id,
552
+ toolName: output.name,
553
+ toolDescription: tool.description,
554
+ args: context
555
+ });
556
+ }
546
557
  const result = await tool?.execute?.(
547
558
  { context },
548
559
  {
549
- toolCallId: "unknown",
560
+ toolCallId: output.call_id,
550
561
  messages: []
551
562
  }
552
563
  );
553
- this.emit("tool-result", {
564
+ this.emit("tool-call-result", {
554
565
  toolCallId: output.call_id,
555
566
  toolName: output.name,
567
+ toolDescription: tool.description,
556
568
  args: context,
557
569
  result
558
570
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/voice-openai-realtime",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.5",
4
4
  "description": "Mastra OpenAI Realtime API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "openai-realtime-api": "^1.0.7",
24
24
  "ws": "^8.18.1",
25
25
  "zod-to-json-schema": "^3.24.5",
26
- "@mastra/core": "^0.8.4-alpha.2"
26
+ "@mastra/core": "^0.9.0-alpha.3"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@microsoft/api-extractor": "^7.52.2",
package/src/index.ts CHANGED
@@ -378,8 +378,7 @@ export class OpenAIRealtimeVoice extends MastraVoice {
378
378
  });
379
379
 
380
380
  this.setupEventListeners();
381
- await this.waitForOpen();
382
- await this.waitForSessionCreated();
381
+ await Promise.all([this.waitForOpen(), this.waitForSessionCreated()]);
383
382
 
384
383
  const openaiTools = transformTools(this.tools);
385
384
  this.updateConfig({
@@ -393,6 +392,11 @@ export class OpenAIRealtimeVoice extends MastraVoice {
393
392
  this.state = 'open';
394
393
  }
395
394
 
395
+ disconnect() {
396
+ this.state = 'close';
397
+ this.ws?.close();
398
+ }
399
+
396
400
  /**
397
401
  * Streams audio data in real-time to the OpenAI service.
398
402
  * Useful for continuous audio streaming scenarios like live microphone input.
@@ -623,19 +627,32 @@ export class OpenAIRealtimeVoice extends MastraVoice {
623
627
  console.warn(`Tool "${output.name}" not found`);
624
628
  return;
625
629
  }
630
+
631
+ if (tool?.execute) {
632
+ this.emit('tool-call-start', {
633
+ toolCallId: output.call_id,
634
+ toolName: output.name,
635
+ toolDescription: tool.description,
636
+ args: context,
637
+ });
638
+ }
639
+
626
640
  const result = await tool?.execute?.(
627
641
  { context },
628
642
  {
629
- toolCallId: 'unknown',
643
+ toolCallId: output.call_id,
630
644
  messages: [],
631
645
  },
632
646
  );
633
- this.emit('tool-result', {
647
+
648
+ this.emit('tool-call-result', {
634
649
  toolCallId: output.call_id,
635
650
  toolName: output.name,
651
+ toolDescription: tool.description,
636
652
  args: context,
637
653
  result,
638
654
  });
655
+
639
656
  this.sendEvent('conversation.item.create', {
640
657
  item: {
641
658
  type: 'function_call_output',