@mastra/voice-cloudflare 0.12.1 → 0.12.2-alpha.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/_types/@internal_voice/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +9043 -0
  3. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/base/index.d.ts +31 -0
  4. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/logger/index.d.ts +217 -0
  5. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +145 -0
  6. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/types/index.d.ts +3 -0
  7. package/dist/_types/@internal_voice/dist/_types/zod/v3/ZodError.d.ts +164 -0
  8. package/dist/_types/@internal_voice/dist/_types/zod/v3/errors.d.ts +5 -0
  9. package/dist/_types/@internal_voice/dist/_types/zod/v3/external.d.ts +6 -0
  10. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/enumUtil.d.ts +8 -0
  11. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/errorUtil.d.ts +9 -0
  12. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/parseUtil.d.ts +78 -0
  13. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/partialUtil.d.ts +8 -0
  14. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/typeAliases.d.ts +2 -0
  15. package/dist/_types/@internal_voice/dist/_types/zod/v3/helpers/util.d.ts +85 -0
  16. package/dist/_types/@internal_voice/dist/_types/zod/v3/index.d.cts +4 -0
  17. package/dist/_types/@internal_voice/dist/_types/zod/v3/index.d.ts +4 -0
  18. package/dist/_types/@internal_voice/dist/_types/zod/v3/locales/en.d.ts +3 -0
  19. package/dist/_types/@internal_voice/dist/_types/zod/v3/standard-schema.d.ts +102 -0
  20. package/dist/_types/@internal_voice/dist/_types/zod/v3/types.d.ts +1034 -0
  21. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/checks.d.ts +1 -0
  22. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/coerce.d.ts +17 -0
  23. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/compat.d.ts +50 -0
  24. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/errors.d.ts +30 -0
  25. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/external.d.ts +16 -0
  26. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/from-json-schema.d.ts +12 -0
  27. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/index.d.ts +4 -0
  28. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/iso.d.ts +22 -0
  29. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/parse.d.ts +31 -0
  30. package/dist/_types/@internal_voice/dist/_types/zod/v4/classic/schemas.d.ts +767 -0
  31. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/api.d.ts +325 -0
  32. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/checks.d.ts +278 -0
  33. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/core.d.ts +70 -0
  34. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/doc.d.ts +14 -0
  35. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/errors.d.ts +221 -0
  36. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/index.d.ts +16 -0
  37. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema-generator.d.ts +65 -0
  38. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema-processors.d.ts +49 -0
  39. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/json-schema.d.ts +88 -0
  40. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/parse.d.ts +49 -0
  41. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/regexes.d.ts +85 -0
  42. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/registries.d.ts +35 -0
  43. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/schemas.d.ts +1184 -0
  44. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/standard-schema.d.ts +126 -0
  45. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/to-json-schema.d.ts +114 -0
  46. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/util.d.ts +200 -0
  47. package/dist/_types/@internal_voice/dist/_types/zod/v4/core/versions.d.ts +5 -0
  48. package/dist/_types/@internal_voice/dist/_types/zod/v4/index.d.cts +3 -0
  49. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ar.d.ts +4 -0
  50. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/az.d.ts +4 -0
  51. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/be.d.ts +4 -0
  52. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/bg.d.ts +4 -0
  53. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ca.d.ts +4 -0
  54. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/cs.d.ts +4 -0
  55. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/da.d.ts +4 -0
  56. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/de.d.ts +4 -0
  57. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/el.d.ts +4 -0
  58. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/en.d.ts +4 -0
  59. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/eo.d.ts +4 -0
  60. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/es.d.ts +4 -0
  61. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fa.d.ts +4 -0
  62. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fi.d.ts +4 -0
  63. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fr-CA.d.ts +4 -0
  64. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/fr.d.ts +4 -0
  65. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/he.d.ts +4 -0
  66. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hr.d.ts +4 -0
  67. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hu.d.ts +4 -0
  68. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/hy.d.ts +4 -0
  69. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/id.d.ts +4 -0
  70. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/index.d.ts +52 -0
  71. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/is.d.ts +4 -0
  72. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/it.d.ts +4 -0
  73. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ja.d.ts +4 -0
  74. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ka.d.ts +4 -0
  75. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/kh.d.ts +5 -0
  76. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/km.d.ts +4 -0
  77. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ko.d.ts +4 -0
  78. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/lt.d.ts +4 -0
  79. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/mk.d.ts +4 -0
  80. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ms.d.ts +4 -0
  81. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/nl.d.ts +4 -0
  82. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/no.d.ts +4 -0
  83. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ota.d.ts +4 -0
  84. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/pl.d.ts +4 -0
  85. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ps.d.ts +4 -0
  86. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/pt.d.ts +4 -0
  87. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ro.d.ts +4 -0
  88. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ru.d.ts +4 -0
  89. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/sl.d.ts +4 -0
  90. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/sv.d.ts +4 -0
  91. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ta.d.ts +4 -0
  92. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/th.d.ts +4 -0
  93. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/tr.d.ts +4 -0
  94. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ua.d.ts +5 -0
  95. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/uk.d.ts +4 -0
  96. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/ur.d.ts +4 -0
  97. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/uz.d.ts +4 -0
  98. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/vi.d.ts +4 -0
  99. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/yo.d.ts +4 -0
  100. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/zh-CN.d.ts +4 -0
  101. package/dist/_types/@internal_voice/dist/_types/zod/v4/locales/zh-TW.d.ts +4 -0
  102. package/dist/_types/@internal_voice/dist/index.d.ts +16 -0
  103. package/dist/_types/@internal_voice/dist/voice/aisdk/index.d.ts +3 -0
  104. package/dist/_types/@internal_voice/dist/voice/aisdk/speech.d.ts +23 -0
  105. package/dist/_types/@internal_voice/dist/voice/aisdk/transcription.d.ts +22 -0
  106. package/dist/_types/@internal_voice/dist/voice/composite-voice.d.ts +72 -0
  107. package/dist/_types/@internal_voice/dist/voice/default-voice.d.ts +13 -0
  108. package/dist/_types/@internal_voice/dist/voice/index.d.ts +5 -0
  109. package/dist/_types/@internal_voice/dist/voice/voice.d.ts +172 -0
  110. package/dist/docs/SKILL.md +1 -1
  111. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  112. package/dist/docs/references/docs-agents-adding-voice.md +18 -17
  113. package/dist/docs/references/docs-voice-overview.md +234 -5
  114. package/dist/docs/references/reference-voice-cloudflare.md +3 -3
  115. package/dist/index.cjs +259 -3
  116. package/dist/index.cjs.map +1 -1
  117. package/dist/index.d.ts +1 -1
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +258 -2
  120. package/dist/index.js.map +1 -1
  121. package/package.json +11 -12
@@ -219,6 +219,33 @@ playAudio(audioStream)
219
219
 
220
220
  Visit the [Deepgram Voice Reference](https://mastra.ai/reference/voice/deepgram) for more information on the Deepgram voice provider.
221
221
 
222
+ **Inworld**:
223
+
224
+ ```typescript
225
+ import { Agent } from '@mastra/core/agent'
226
+ import { InworldVoice } from '@mastra/voice-inworld'
227
+ import { playAudio } from '@mastra/node-audio'
228
+
229
+ const voiceAgent = new Agent({
230
+ id: 'voice-agent',
231
+ name: 'Voice Agent',
232
+ instructions: 'You are a voice assistant that can help users with their tasks.',
233
+ model: 'openai/gpt-5.4',
234
+ voice: new InworldVoice(),
235
+ })
236
+
237
+ const { text } = await voiceAgent.generate('What color is the sky?')
238
+
239
+ // Convert text to speech to an Audio Stream
240
+ const audioStream = await voiceAgent.voice.speak(text, {
241
+ speaker: 'Dennis', // Optional: specify a speaker
242
+ })
243
+
244
+ playAudio(audioStream)
245
+ ```
246
+
247
+ Visit the [Inworld Voice Reference](https://mastra.ai/reference/voice/inworld) for more information on the Inworld voice provider.
248
+
222
249
  **Speechify**:
223
250
 
224
251
  ```typescript
@@ -265,7 +292,7 @@ const { text } = await voiceAgent.generate('What color is the sky?')
265
292
 
266
293
  // Convert text to speech to an Audio Stream
267
294
  const audioStream = await voiceAgent.voice.speak(text, {
268
- speaker: 'default', // Optional: specify a speaker
295
+ speaker: 'shubh', // Optional: specify a bulbul:v3 speaker
269
296
  })
270
297
 
271
298
  playAudio(audioStream)
@@ -477,6 +504,34 @@ const { text } = await voiceAgent.generate(transcript)
477
504
 
478
505
  Visit the [Deepgram Voice Reference](https://mastra.ai/reference/voice/deepgram) for more information on the Deepgram voice provider.
479
506
 
507
+ **Inworld**:
508
+
509
+ ```typescript
510
+ import { Agent } from '@mastra/core/agent'
511
+ import { InworldVoice } from '@mastra/voice-inworld'
512
+ import { createReadStream } from 'fs'
513
+
514
+ const voiceAgent = new Agent({
515
+ id: 'voice-agent',
516
+ name: 'Voice Agent',
517
+ instructions: 'You are a voice assistant that can help users with their tasks.',
518
+ model: 'openai/gpt-5.4',
519
+ voice: new InworldVoice(),
520
+ })
521
+
522
+ // Use an audio file from a URL
523
+ const audioStream = await createReadStream('./how_can_i_help_you.mp3')
524
+
525
+ // Convert audio to text
526
+ const transcript = await voiceAgent.voice.listen(audioStream)
527
+ console.log(`User said: ${transcript}`)
528
+
529
+ // Generate a response based on the transcript
530
+ const { text } = await voiceAgent.generate(transcript)
531
+ ```
532
+
533
+ Visit the [Inworld Voice Reference](https://mastra.ai/reference/voice/inworld) for more information on the Inworld voice provider.
534
+
480
535
  **Sarvam**:
481
536
 
482
537
  ```typescript
@@ -588,6 +643,92 @@ await voiceAgent.voice.send(micStream)
588
643
 
589
644
  Visit the [Google Gemini Live Reference](https://mastra.ai/reference/voice/google-gemini-live) for more information on the Google Gemini Live voice provider.
590
645
 
646
+ **AWS Nova Sonic**:
647
+
648
+ ```typescript
649
+ import { Agent } from '@mastra/core/agent'
650
+ import { playAudio, getMicrophoneStream } from '@mastra/node-audio'
651
+ import { NovaSonicVoice } from '@mastra/voice-aws-nova-sonic'
652
+
653
+ const voiceAgent = new Agent({
654
+ id: 'voice-agent',
655
+ name: 'Voice Agent',
656
+ instructions: 'You are a voice assistant that can help users with their tasks.',
657
+ model: 'openai/gpt-5.4',
658
+ voice: new NovaSonicVoice({
659
+ region: 'us-east-1',
660
+ speaker: 'matthew',
661
+ // Static credentials are optional. The default AWS credential
662
+ // provider chain is used when none are passed.
663
+ }),
664
+ })
665
+
666
+ // Connect before using speak/send
667
+ await voiceAgent.voice.connect()
668
+
669
+ // Listen for assistant audio (Int16Array PCM)
670
+ voiceAgent.voice.on('speaking', ({ audioData }) => {
671
+ if (audioData) playAudio(audioData)
672
+ })
673
+
674
+ // Listen for transcribed text
675
+ voiceAgent.voice.on('writing', ({ text, role }) => {
676
+ console.log(`${role}: ${text}`)
677
+ })
678
+
679
+ // Initiate the conversation
680
+ await voiceAgent.voice.speak('How can I help you today?')
681
+
682
+ // Send continuous audio from the microphone
683
+ const micStream = getMicrophoneStream()
684
+ await voiceAgent.voice.send(micStream)
685
+ ```
686
+
687
+ Visit the [AWS Nova Sonic Reference](https://mastra.ai/reference/voice/aws-nova-sonic) for more information on the AWS Nova Sonic voice provider.
688
+
689
+ **xAI**:
690
+
691
+ ```typescript
692
+ import { Agent } from '@mastra/core/agent'
693
+ import { playAudio, getMicrophoneStream } from '@mastra/node-audio'
694
+ import { XAIRealtimeVoice } from '@mastra/voice-xai-realtime'
695
+
696
+ const voiceAgent = new Agent({
697
+ id: 'voice-agent',
698
+ name: 'Voice Agent',
699
+ instructions: 'You are a voice assistant that can help users with their tasks.',
700
+ model: 'xai/grok-4.3',
701
+ voice: new XAIRealtimeVoice({
702
+ apiKey: process.env.XAI_API_KEY,
703
+ model: 'grok-voice-think-fast-1.0',
704
+ speaker: 'eve',
705
+ turnDetection: { type: 'server_vad' },
706
+ }),
707
+ })
708
+
709
+ // Connect before using speak/send
710
+ await voiceAgent.voice.connect()
711
+
712
+ // Listen for agent audio responses
713
+ voiceAgent.voice.on('speaker', audioStream => {
714
+ playAudio(audioStream)
715
+ })
716
+
717
+ // Listen for text responses and transcriptions
718
+ voiceAgent.voice.on('writing', ({ text, role }) => {
719
+ console.log(`${role}: ${text}`)
720
+ })
721
+
722
+ // Initiate the conversation
723
+ await voiceAgent.voice.speak('How can I help you today?')
724
+
725
+ // Send continuous audio from the microphone
726
+ const micStream = getMicrophoneStream()
727
+ await voiceAgent.voice.send(micStream)
728
+ ```
729
+
730
+ Visit the [xAI Realtime Voice Reference](https://mastra.ai/reference/voice/xai-realtime) for more information on the xAI voice provider.
731
+
591
732
  ## Voice configuration
592
733
 
593
734
  Each voice provider can be configured with different models and options. Below are the detailed configuration options for all supported providers:
@@ -736,6 +877,34 @@ const voice = new DeepgramVoice({
736
877
 
737
878
  Visit the [Deepgram Voice Reference](https://mastra.ai/reference/voice/deepgram) for more information on the Deepgram voice provider.
738
879
 
880
+ **Inworld**:
881
+
882
+ ```typescript
883
+ // Inworld Voice Configuration
884
+ const voice = new InworldVoice({
885
+ speechModel: {
886
+ name: 'inworld-tts-2',
887
+ apiKey: process.env.INWORLD_API_KEY,
888
+ },
889
+ listeningModel: {
890
+ name: 'groq/whisper-large-v3',
891
+ apiKey: process.env.INWORLD_API_KEY,
892
+ },
893
+ speaker: 'Dennis',
894
+ audioEncoding: 'MP3',
895
+ sampleRateHertz: 48000,
896
+ language: 'en-US',
897
+ })
898
+
899
+ // Per-call options: `deliveryMode` is honored only by `inworld-tts-2`.
900
+ const audioStream = await voice.speak('Hello!', {
901
+ deliveryMode: 'BALANCED', // 'STABLE' | 'BALANCED' | 'CREATIVE'
902
+ language: 'en-US', // BCP-47 per-call override
903
+ })
904
+ ```
905
+
906
+ Visit the [Inworld Voice Reference](https://mastra.ai/reference/voice/inworld) for more information on the Inworld voice provider.
907
+
739
908
  **Speechify**:
740
909
 
741
910
  ```typescript
@@ -760,12 +929,15 @@ Visit the [Speechify Voice Reference](https://mastra.ai/reference/voice/speechif
760
929
  // Sarvam Voice Configuration
761
930
  const voice = new SarvamVoice({
762
931
  speechModel: {
763
- name: 'sarvam-voice', // Example model name
932
+ model: 'bulbul:v3', // TTS model (bulbul:v2 or bulbul:v3)
764
933
  apiKey: process.env.SARVAM_API_KEY,
765
- language: 'en-IN', // Language code
766
- style: 'conversational', // Style setting
934
+ language: 'en-IN', // BCP-47 language code
767
935
  },
768
- // Sarvam may not have a separate listening model
936
+ listeningModel: {
937
+ model: 'saarika:v2.5', // STT model (saarika:v2.5 or saaras:v3)
938
+ apiKey: process.env.SARVAM_API_KEY,
939
+ },
940
+ speaker: 'shubh', // Default bulbul:v3 speaker
769
941
  })
770
942
  ```
771
943
 
@@ -809,6 +981,38 @@ const voice = new OpenAIRealtimeVoice({
809
981
 
810
982
  For more information on the OpenAI Realtime voice provider, refer to the [OpenAI Realtime Voice Reference](https://mastra.ai/reference/voice/openai-realtime).
811
983
 
984
+ **xAI Realtime**:
985
+
986
+ ```typescript
987
+ // xAI Realtime Voice Configuration
988
+ const voice = new XAIRealtimeVoice({
989
+ apiKey: process.env.XAI_API_KEY,
990
+ model: 'grok-voice-think-fast-1.0',
991
+ speaker: 'eve',
992
+ instructions: 'You are a concise voice assistant.',
993
+ turnDetection: {
994
+ type: 'server_vad',
995
+ threshold: 0.85,
996
+ silence_duration_ms: 1000,
997
+ prefix_padding_ms: 333,
998
+ },
999
+ audio: {
1000
+ input: { format: { type: 'audio/pcm', rate: 24000 } },
1001
+ output: { format: { type: 'audio/pcm', rate: 24000 } },
1002
+ },
1003
+ serverTools: [
1004
+ { type: 'web_search' },
1005
+ {
1006
+ type: 'mcp',
1007
+ server_url: 'https://mcp.example.com/mcp',
1008
+ server_label: 'business-tools',
1009
+ },
1010
+ ],
1011
+ })
1012
+ ```
1013
+
1014
+ Visit the [xAI Realtime Voice Reference](https://mastra.ai/reference/voice/xai-realtime) for more information on the xAI realtime voice provider.
1015
+
812
1016
  **Google Gemini Live**:
813
1017
 
814
1018
  ```typescript
@@ -825,6 +1029,28 @@ const voice = new GeminiLiveVoice({
825
1029
 
826
1030
  Visit the [Google Gemini Live Reference](https://mastra.ai/reference/voice/google-gemini-live) for more information on the Google Gemini Live voice provider.
827
1031
 
1032
+ **AWS Nova Sonic**:
1033
+
1034
+ ```typescript
1035
+ // AWS Nova Sonic Voice Configuration
1036
+ const voice = new NovaSonicVoice({
1037
+ region: 'us-east-1',
1038
+ speaker: 'matthew',
1039
+ sessionConfig: {
1040
+ inferenceConfiguration: {
1041
+ temperature: 0.7,
1042
+ maxTokens: 1024,
1043
+ },
1044
+ turnDetectionConfiguration: {
1045
+ endpointingSensitivity: 'MEDIUM',
1046
+ },
1047
+ },
1048
+ // AWS Nova Sonic is a realtime bidirectional API without separate speech and listening models
1049
+ })
1050
+ ```
1051
+
1052
+ Visit the [AWS Nova Sonic Reference](https://mastra.ai/reference/voice/aws-nova-sonic) for more information on the AWS Nova Sonic voice provider.
1053
+
828
1054
  **AI SDK**:
829
1055
 
830
1056
  ```typescript
@@ -951,9 +1177,12 @@ For more information on the CompositeVoice, refer to the [CompositeVoice Referen
951
1177
  - [MastraVoice](https://mastra.ai/reference/voice/mastra-voice)
952
1178
  - [OpenAI Voice](https://mastra.ai/reference/voice/openai)
953
1179
  - [OpenAI Realtime Voice](https://mastra.ai/reference/voice/openai-realtime)
1180
+ - [xAI Realtime Voice](https://mastra.ai/reference/voice/xai-realtime)
954
1181
  - [Azure Voice](https://mastra.ai/reference/voice/azure)
955
1182
  - [Google Voice](https://mastra.ai/reference/voice/google)
956
1183
  - [Google Gemini Live Voice](https://mastra.ai/reference/voice/google-gemini-live)
1184
+ - [AWS Nova Sonic Voice](https://mastra.ai/reference/voice/aws-nova-sonic)
957
1185
  - [Deepgram Voice](https://mastra.ai/reference/voice/deepgram)
1186
+ - [Inworld Voice](https://mastra.ai/reference/voice/inworld)
958
1187
  - [PlayAI Voice](https://mastra.ai/reference/voice/playai)
959
1188
  - [Voice Examples](https://github.com/mastra-ai/voice-examples)
@@ -78,6 +78,6 @@ Returns an array of available voice options, where each node contains:
78
78
 
79
79
  If you need speech-to-text capabilities in addition to text-to-speech, consider using one of these providers:
80
80
 
81
- - [OpenAI](https://mastra.ai/reference/voice/openai) - Provides both TTS and STT
82
- - [Google](https://mastra.ai/reference/voice/google) - Provides both TTS and STT
83
- - [Azure](https://mastra.ai/reference/voice/azure) - Provides both TTS and STT
81
+ - [OpenAI](https://mastra.ai/reference/voice/openai): Provides both TTS and STT
82
+ - [Google](https://mastra.ai/reference/voice/google): Provides both TTS and STT
83
+ - [Azure](https://mastra.ai/reference/voice/azure): Provides both TTS and STT
package/dist/index.cjs CHANGED
@@ -1,19 +1,275 @@
1
1
  'use strict';
2
2
 
3
- var voice = require('@mastra/core/voice');
4
3
  var Cloudflare = require('cloudflare');
5
4
 
6
5
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
6
 
8
7
  var Cloudflare__default = /*#__PURE__*/_interopDefault(Cloudflare);
9
8
 
10
- // src/index.ts
9
+ // ../../packages/_internal-core/dist/chunk-HDURQPU2.js
10
+ var RegisteredLogger = {
11
+ LLM: "LLM"};
12
+ var LogLevel = {
13
+ DEBUG: "debug",
14
+ INFO: "info",
15
+ WARN: "warn",
16
+ ERROR: "error"};
17
+ var MastraLogger = class {
18
+ name;
19
+ level;
20
+ transports;
21
+ constructor(options = {}) {
22
+ this.name = options.name || "Mastra";
23
+ this.level = options.level || LogLevel.ERROR;
24
+ this.transports = new Map(Object.entries(options.transports || {}));
25
+ }
26
+ getTransports() {
27
+ return this.transports;
28
+ }
29
+ trackException(_error, _metadata) {
30
+ }
31
+ async listLogs(transportId, params) {
32
+ if (!transportId || !this.transports.has(transportId)) {
33
+ return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
34
+ }
35
+ return this.transports.get(transportId).listLogs?.(params) ?? {
36
+ logs: [],
37
+ total: 0,
38
+ page: params?.page ?? 1,
39
+ perPage: params?.perPage ?? 100,
40
+ hasMore: false
41
+ };
42
+ }
43
+ async listLogsByRunId({
44
+ transportId,
45
+ runId,
46
+ fromDate,
47
+ toDate,
48
+ logLevel,
49
+ filters,
50
+ page,
51
+ perPage
52
+ }) {
53
+ if (!transportId || !this.transports.has(transportId) || !runId) {
54
+ return { logs: [], total: 0, page: page ?? 1, perPage: perPage ?? 100, hasMore: false };
55
+ }
56
+ return this.transports.get(transportId).listLogsByRunId?.({ runId, fromDate, toDate, logLevel, filters, page, perPage }) ?? {
57
+ logs: [],
58
+ total: 0,
59
+ page: page ?? 1,
60
+ perPage: perPage ?? 100,
61
+ hasMore: false
62
+ };
63
+ }
64
+ };
65
+ var ConsoleLogger = class _ConsoleLogger extends MastraLogger {
66
+ component;
67
+ filter;
68
+ constructor(options = {}) {
69
+ super(options);
70
+ this.component = options.component;
71
+ this.filter = options.filter;
72
+ }
73
+ child(componentOrBindings) {
74
+ const component = typeof componentOrBindings === "string" ? componentOrBindings : componentOrBindings?.component ?? this.component;
75
+ return new _ConsoleLogger({
76
+ name: this.name,
77
+ level: this.level,
78
+ component,
79
+ filter: this.filter
80
+ });
81
+ }
82
+ shouldLog(level, message, args) {
83
+ if (!this.filter) return true;
84
+ try {
85
+ return this.filter({ component: this.component, level, message, args });
86
+ } catch (e) {
87
+ console.error(`[Logger] Filter error for component=${this.component} level=${level}:`, e);
88
+ return true;
89
+ }
90
+ }
91
+ prefix() {
92
+ return this.component ? `[${this.component}] ` : "";
93
+ }
94
+ debug(message, ...args) {
95
+ if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) {
96
+ console.info(`${this.prefix()}${message}`, ...args);
97
+ }
98
+ }
99
+ info(message, ...args) {
100
+ if ((this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.INFO, message, args)) {
101
+ console.info(`${this.prefix()}${message}`, ...args);
102
+ }
103
+ }
104
+ warn(message, ...args) {
105
+ if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) {
106
+ console.info(`${this.prefix()}${message}`, ...args);
107
+ }
108
+ }
109
+ error(message, ...args) {
110
+ if ((this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.ERROR, message, args)) {
111
+ console.error(`${this.prefix()}${message}`, ...args);
112
+ }
113
+ }
114
+ async listLogs(_transportId, _params) {
115
+ return { logs: [], total: 0, page: _params?.page ?? 1, perPage: _params?.perPage ?? 100, hasMore: false };
116
+ }
117
+ async listLogsByRunId(_args) {
118
+ return { logs: [], total: 0, page: _args.page ?? 1, perPage: _args.perPage ?? 100, hasMore: false };
119
+ }
120
+ };
121
+
122
+ // ../../packages/_internal-core/dist/base/index.js
123
+ var MastraBase = class {
124
+ component = RegisteredLogger.LLM;
125
+ logger;
126
+ name;
127
+ #rawConfig;
128
+ constructor({
129
+ component,
130
+ name,
131
+ rawConfig
132
+ }) {
133
+ this.component = component || RegisteredLogger.LLM;
134
+ this.name = name;
135
+ this.#rawConfig = rawConfig;
136
+ this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });
137
+ }
138
+ /**
139
+ * Returns the raw storage configuration this primitive was created from,
140
+ * or undefined if it was created from code.
141
+ */
142
+ toRawConfig() {
143
+ return this.#rawConfig;
144
+ }
145
+ /**
146
+ * Sets the raw storage configuration for this primitive.
147
+ * @internal
148
+ */
149
+ __setRawConfig(rawConfig) {
150
+ this.#rawConfig = rawConfig;
151
+ }
152
+ /**
153
+ * Set the logger for the agent
154
+ * @param logger
155
+ */
156
+ __setLogger(logger) {
157
+ this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
158
+ }
159
+ };
160
+
161
+ // ../../packages/_internals/voice/dist/chunk-NWNKSBZV.js
162
+ var MastraVoice = class extends MastraBase {
163
+ listeningModel;
164
+ speechModel;
165
+ speaker;
166
+ realtimeConfig;
167
+ constructor({ listeningModel, speechModel, speaker, realtimeConfig, name } = {}) {
168
+ super({
169
+ component: "VOICE",
170
+ name
171
+ });
172
+ this.listeningModel = listeningModel;
173
+ this.speechModel = speechModel;
174
+ this.speaker = speaker;
175
+ this.realtimeConfig = realtimeConfig;
176
+ }
177
+ /**
178
+ * Custom serialization for tracing/observability spans.
179
+ * Excludes `apiKey` from listeningModel / speechModel / realtimeConfig
180
+ * and any provider-specific state held by subclasses. Subclasses that
181
+ * need to expose additional non-sensitive fields can override.
182
+ */
183
+ serializeForSpan() {
184
+ return {
185
+ component: "VOICE",
186
+ name: this.name,
187
+ speaker: this.speaker,
188
+ listeningModel: this.listeningModel ? { name: this.listeningModel.name } : void 0,
189
+ speechModel: this.speechModel ? { name: this.speechModel.name } : void 0,
190
+ realtimeModel: this.realtimeConfig?.model
191
+ };
192
+ }
193
+ updateConfig(_options) {
194
+ this.logger.debug("updateConfig not implemented by this voice provider");
195
+ }
196
+ /**
197
+ * Initializes a WebSocket or WebRTC connection for real-time communication
198
+ * @returns Promise that resolves when the connection is established
199
+ */
200
+ async connect(_options) {
201
+ this.logger.debug("connect not implemented by this voice provider");
202
+ }
203
+ /**
204
+ * Relay audio data to the voice provider for real-time processing
205
+ * @param audioData Audio data to relay
206
+ */
207
+ async send(_audioData) {
208
+ this.logger.debug("relay not implemented by this voice provider");
209
+ }
210
+ /**
211
+ * Trigger voice providers to respond
212
+ */
213
+ async answer(_options) {
214
+ this.logger.debug("answer not implemented by this voice provider");
215
+ }
216
+ /**
217
+ * Equip the voice provider with instructions
218
+ * @param instructions Instructions to add
219
+ */
220
+ addInstructions(_instructions) {
221
+ }
222
+ /**
223
+ * Equip the voice provider with tools
224
+ * @param tools Array of tools to add
225
+ */
226
+ addTools(_tools) {
227
+ }
228
+ /**
229
+ * Disconnect from the WebSocket or WebRTC connection
230
+ */
231
+ close() {
232
+ this.logger.debug("close not implemented by this voice provider");
233
+ }
234
+ /**
235
+ * Register an event listener
236
+ * @param event Event name (e.g., 'speaking', 'writing', 'error')
237
+ * @param callback Callback function that receives event data
238
+ */
239
+ on(_event, _callback) {
240
+ this.logger.debug("on not implemented by this voice provider");
241
+ }
242
+ /**
243
+ * Remove an event listener
244
+ * @param event Event name (e.g., 'speaking', 'writing', 'error')
245
+ * @param callback Callback function to remove
246
+ */
247
+ off(_event, _callback) {
248
+ this.logger.debug("off not implemented by this voice provider");
249
+ }
250
+ /**
251
+ * Get available speakers/voices
252
+ * @returns Array of available voice IDs and their metadata
253
+ */
254
+ getSpeakers() {
255
+ this.logger.debug("getSpeakers not implemented by this voice provider");
256
+ return Promise.resolve([]);
257
+ }
258
+ /**
259
+ * Get available speakers/voices
260
+ * @returns Array of available voice IDs and their metadata
261
+ */
262
+ getListener() {
263
+ this.logger.debug("getListener not implemented by this voice provider");
264
+ return Promise.resolve({ enabled: false });
265
+ }
266
+ };
11
267
  var defaultListeningModel = {
12
268
  model: "@cf/openai/whisper-large-v3-turbo",
13
269
  apiKey: process.env.CLOUDFLARE_AI_API_KEY,
14
270
  account_id: process.env.CLOUDFLARE_ACCOUNT_ID
15
271
  };
16
- var CloudflareVoice = class extends voice.MastraVoice {
272
+ var CloudflareVoice = class extends MastraVoice {
17
273
  apiToken;
18
274
  client = null;
19
275
  binding;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["MastraVoice","Cloudflare"],"mappings":";;;;;;;;;;AAoBA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,KAAA,EAAO,mCAAA;AAAA,EACP,MAAA,EAAQ,QAAQ,GAAA,CAAI,qBAAA;AAAA,EACpB,UAAA,EAAY,QAAQ,GAAA,CAAI;AAC1B,CAAA;AAEO,IAAM,eAAA,GAAN,cAA8BA,iBAAA,CAAY;AAAA,EACvC,QAAA;AAAA,EACA,MAAA,GAA4B,IAAA;AAAA,EAC5B,OAAA;AAAA,EAER,WAAA,CAAY;AAAA,IACV,cAAA;AAAA,IACA;AAAA,GACF,GAGI,EAAC,EAAG;AACN,IAAA,KAAA,CAAM;AAAA,MACJ,cAAA,EAAgB;AAAA,QACd,IAAA,EAAM,cAAA,EAAgB,KAAA,IAAS,qBAAA,CAAsB,KAAA;AAAA,QACrD,MAAA,EAAQ,cAAA,EAAgB,MAAA,IAAU,qBAAA,CAAsB;AAAA;AAC1D,KACD,CAAA;AAGD,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAGf,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,IAAA,CAAK,QAAA,GAAW,cAAA,EAAgB,MAAA,IAAU,qBAAA,CAAsB,MAAA;AAChE,MAAA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G,MAAA,MAAM,WAAY,MAAM,IAAA,CAAK,OAAO,EAAA,CAAG,GAAA,CAAI,OAAO,OAAO,CAAA;AACzD,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,MAAM,+CAA+C,CAAA;AAAA,IACjE;AAAA,EACF;AAAA,EACA,MAAM,KAAA,GAAwC;AAC5C,IAAA,MAAM,IAAI,MAAM,sCAAsC,CAAA;AAAA,EACxD;AAAA,EACA,MAAM,WAAA,GAAuE;AAC3E,IAAA,MAAM,IAAI,MAAM,sCAAsC,CAAA;AAAA,EACxD;AACF","file":"index.cjs","sourcesContent":["import type {\n Ai,\n Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output,\n Ai_Cf_Openai_Whisper_Output,\n Ai_Cf_Openai_Whisper_Tiny_En_Output,\n} from '@cloudflare/workers-types';\nimport { MastraVoice } from '@mastra/core/voice';\nimport Cloudflare from 'cloudflare';\n\ninterface CloudflareListenOptions {\n apiKey?: string;\n model?: '@cf/openai/whisper-tiny-en' | '@cf/openai/whisper' | '@cf/openai/whisper-large-v3-turbo';\n account_id?: string;\n}\n\ntype CloudflareListenOutput =\n | Ai_Cf_Openai_Whisper_Tiny_En_Output\n | Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output\n | Ai_Cf_Openai_Whisper_Output;\n\nconst defaultListeningModel = {\n model: '@cf/openai/whisper-large-v3-turbo' as const,\n apiKey: process.env.CLOUDFLARE_AI_API_KEY,\n account_id: process.env.CLOUDFLARE_ACCOUNT_ID!,\n};\n\nexport class CloudflareVoice extends MastraVoice {\n private apiToken?: string;\n private client: Cloudflare | null = null;\n private binding?: Ai;\n\n constructor({\n listeningModel,\n binding,\n }: {\n listeningModel?: CloudflareListenOptions;\n binding?: Ai;\n } = {}) {\n super({\n listeningModel: {\n name: listeningModel?.model ?? defaultListeningModel.model,\n apiKey: listeningModel?.apiKey ?? defaultListeningModel.apiKey,\n },\n });\n\n // Store Workers AI binding if provided\n this.binding = binding;\n\n // Only setup REST client if no binding provided or both are needed\n if (!binding) {\n this.apiToken = listeningModel?.apiKey || defaultListeningModel.apiKey;\n if (!this.apiToken) {\n throw new Error('CLOUDFLARE_AI_API_KEY must be set when not using bindings');\n }\n this.client = new Cloudflare({ apiToken: this.apiToken });\n }\n }\n\n /**\n * Checks if listening capabilities are enabled.\n *\n * @returns {Promise<{ enabled: boolean }>}\n */\n async getListener() {\n return { enabled: true };\n }\n\n async listen(audioStream: NodeJS.ReadableStream, options?: CloudflareListenOptions): Promise<string> {\n // Collect audio data into buffer\n const chunks: Buffer[] = [];\n for await (const chunk of audioStream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n const audioBuffer = Buffer.concat(chunks);\n const base64Audio = audioBuffer.toString('base64');\n\n const model = options?.model || defaultListeningModel.model;\n\n // Use native binding if available, otherwise use REST API\n if (this.binding) {\n // Using Workers AI binding\n const response = (await this.binding.run(model, {\n audio: base64Audio,\n })) as CloudflareListenOutput;\n return response.text;\n } else if (this.client) {\n // Using REST API client\n const payload = { audio: base64Audio, account_id: options?.account_id || defaultListeningModel.account_id };\n const response = (await this.client.ai.run(model, payload)) as any;\n return response.text as string;\n } else {\n throw new Error('Neither binding nor REST client is configured');\n }\n }\n async speak(): Promise<NodeJS.ReadableStream> {\n throw new Error('This feature is not yet implemented.');\n }\n async getSpeakers(): Promise<Array<{ voiceId: string; [key: string]: any }>> {\n throw new Error('This feature is not yet implemented.');\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../packages/_internal-core/src/logger/index.ts","../../../packages/_internal-core/src/base/MastraBase.ts","../../../packages/_internals/voice/src/voice/voice.ts","../src/index.ts"],"names":["Cloudflare"],"mappings":";;;;;;;;;AAEO,IAAM,gBAAA,GAAmB;EAO9B,GAAA,EAAK,KAcP,CAAA;AAIO,IAAM,QAAA,GAAW;EACtB,KAAA,EAAO,OAAA;EACP,IAAA,EAAM,MAAA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A,IAAI,KAAK,OAAA,EAAS;AAEhB,MAAA,MAAM,QAAA,GAAY,MAAM,IAAA,CAAK,OAAA,CAAQ,IAAI,KAAA,EAAO;AAAA,QAC9C,KAAA,EAAO;AAAA,OACR,CAAA;AACD,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA,MAAA,IAAW,KAAK,MAAA,EAAQ;AAEtB,MAAA,MAAM,OAAA,GAAU,EAAE,KAAA,EAAO,WAAA,EAAa,YAAY,OAAA,EAAS,UAAA,IAAc,sBAAsB,UAAA,EAAW;AAC1G,MAAA,MAAM,WAAY,MAAM,IAAA,CAAK,OAAO,EAAA,CAAG,GAAA,CAAI,OAAO,OAAO,CAAA;AACzD,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA,MAAO;AACL,MAAA,MAAM,IAAI,MAAM,+CAA+C,CAAA;AAAA,IACjE;AAAA,EACF;AAAA,EACA,MAAM,KAAA,GAAwC;AAC5C,IAAA,MAAM,IAAI,MAAM,sCAAsC,CAAA;AAAA,EACxD;AAAA,EACA,MAAM,WAAA,GAAuE;AAC3E,IAAA,MAAM,IAAI,MAAM,sCAAsC,CAAA;AAAA,EACxD;AACF","file":"index.cjs","sourcesContent":["import { Transform } from 'node:stream';\n\nexport const RegisteredLogger = {\n AGENT: 'AGENT',\n OBSERVABILITY: 'OBSERVABILITY',\n AUTH: 'AUTH',\n BROWSER: 'BROWSER',\n NETWORK: 'NETWORK',\n WORKFLOW: 'WORKFLOW',\n LLM: 'LLM',\n TTS: 'TTS',\n VOICE: 'VOICE',\n VECTOR: 'VECTOR',\n BUNDLER: 'BUNDLER',\n DEPLOYER: 'DEPLOYER',\n MEMORY: 'MEMORY',\n STORAGE: 'STORAGE',\n EMBEDDINGS: 'EMBEDDINGS',\n MCP_SERVER: 'MCP_SERVER',\n SERVER_CACHE: 'SERVER_CACHE',\n SERVER: 'SERVER',\n WORKSPACE: 'WORKSPACE',\n CHANNEL: 'CHANNEL',\n} as const;\n\nexport type RegisteredLogger = (typeof RegisteredLogger)[keyof typeof RegisteredLogger];\n\nexport const LogLevel = {\n DEBUG: 'debug',\n INFO: 'info',\n WARN: 'warn',\n ERROR: 'error',\n NONE: 'silent',\n} as const;\n\nexport type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];\n\nexport interface BaseLogMessage {\n runId?: string;\n msg: string;\n level: LogLevel;\n time: Date;\n pid: number;\n hostname: string;\n name: string;\n}\n\nexport abstract class LoggerTransport extends Transform {\n constructor(opts: any = {}) {\n super({ ...opts, objectMode: true });\n }\n\n async listLogsByRunId(_args: {\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };\n }\n\n async listLogs(_args?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };\n }\n}\n\nexport const createCustomTransport = (\n stream: Transform,\n listLogs?: LoggerTransport['listLogs'],\n listLogsByRunId?: LoggerTransport['listLogsByRunId'],\n) => {\n let transport = stream as LoggerTransport;\n if (listLogs) {\n transport.listLogs = listLogs;\n }\n if (listLogsByRunId) {\n transport.listLogsByRunId = listLogsByRunId;\n }\n return transport as LoggerTransport;\n};\n\nexport interface IMastraLogger {\n debug(message: string, ...args: any[]): void;\n info(message: string, ...args: any[]): void;\n warn(message: string, ...args: any[]): void;\n error(message: string, ...args: any[]): void;\n trackException(error: Error, metadata?: Record<string, unknown>): void;\n\n getTransports(): Map<string, LoggerTransport>;\n listLogs(\n _transportId: string,\n _params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n },\n ): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }>;\n listLogsByRunId(_args: {\n transportId: string;\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }>;\n}\n\nexport abstract class MastraLogger implements IMastraLogger {\n protected name: string;\n protected level: LogLevel;\n protected transports: Map<string, LoggerTransport>;\n\n constructor(\n options: {\n name?: string;\n level?: LogLevel;\n transports?: Record<string, LoggerTransport>;\n } = {},\n ) {\n this.name = options.name || 'Mastra';\n this.level = options.level || LogLevel.ERROR;\n this.transports = new Map(Object.entries(options.transports || {}));\n }\n\n abstract debug(message: string, ...args: any[]): void;\n abstract info(message: string, ...args: any[]): void;\n abstract warn(message: string, ...args: any[]): void;\n abstract error(message: string, ...args: any[]): void;\n\n getTransports() {\n return this.transports;\n }\n\n trackException(_error: Error, _metadata?: Record<string, unknown>) {}\n\n async listLogs(\n transportId: string,\n params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n },\n ) {\n if (!transportId || !this.transports.has(transportId)) {\n return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };\n }\n\n return (\n this.transports.get(transportId)!.listLogs?.(params) ?? {\n logs: [],\n total: 0,\n page: params?.page ?? 1,\n perPage: params?.perPage ?? 100,\n hasMore: false,\n }\n );\n }\n\n async listLogsByRunId({\n transportId,\n runId,\n fromDate,\n toDate,\n logLevel,\n filters,\n page,\n perPage,\n }: {\n transportId: string;\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }) {\n if (!transportId || !this.transports.has(transportId) || !runId) {\n return { logs: [], total: 0, page: page ?? 1, perPage: perPage ?? 100, hasMore: false };\n }\n\n return (\n this.transports\n .get(transportId)!\n .listLogsByRunId?.({ runId, fromDate, toDate, logLevel, filters, page, perPage }) ?? {\n logs: [],\n total: 0,\n page: page ?? 1,\n perPage: perPage ?? 100,\n hasMore: false,\n }\n );\n }\n}\n\nexport type LogFilterContext = {\n component?: RegisteredLogger;\n level: LogLevel;\n message: string;\n args: unknown[];\n};\n\nexport type LogFilter = (ctx: LogFilterContext) => boolean;\n\nexport interface ConsoleLoggerOptions {\n name?: string;\n level?: LogLevel;\n component?: RegisteredLogger;\n filter?: LogFilter;\n}\n\nexport class ConsoleLogger extends MastraLogger {\n protected component?: RegisteredLogger;\n protected filter?: LogFilter;\n\n constructor(options: ConsoleLoggerOptions = {}) {\n super(options);\n this.component = options.component;\n this.filter = options.filter;\n }\n\n child(componentOrBindings: RegisteredLogger | Record<string, unknown>): ConsoleLogger {\n const component =\n typeof componentOrBindings === 'string'\n ? componentOrBindings\n : ((componentOrBindings?.component as RegisteredLogger) ?? this.component);\n return new ConsoleLogger({\n name: this.name,\n level: this.level,\n component,\n filter: this.filter,\n });\n }\n\n private shouldLog(level: LogLevel, message: string, args: unknown[]): boolean {\n if (!this.filter) return true;\n try {\n return this.filter({ component: this.component, level, message, args });\n } catch (e) {\n console.error(`[Logger] Filter error for component=${this.component} level=${level}:`, e);\n return true;\n }\n }\n\n private prefix(): string {\n return this.component ? `[${this.component}] ` : '';\n }\n\n debug(message: string, ...args: any[]): void {\n if (this.level === LogLevel.DEBUG && this.shouldLog(LogLevel.DEBUG, message, args)) {\n console.info(`${this.prefix()}${message}`, ...args);\n }\n }\n\n info(message: string, ...args: any[]): void {\n if (\n (this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) &&\n this.shouldLog(LogLevel.INFO, message, args)\n ) {\n console.info(`${this.prefix()}${message}`, ...args);\n }\n }\n\n warn(message: string, ...args: any[]): void {\n if (\n (this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) &&\n this.shouldLog(LogLevel.WARN, message, args)\n ) {\n console.info(`${this.prefix()}${message}`, ...args);\n }\n }\n\n error(message: string, ...args: any[]): void {\n if (\n (this.level === LogLevel.ERROR ||\n this.level === LogLevel.WARN ||\n this.level === LogLevel.INFO ||\n this.level === LogLevel.DEBUG) &&\n this.shouldLog(LogLevel.ERROR, message, args)\n ) {\n console.error(`${this.prefix()}${message}`, ...args);\n }\n }\n\n async listLogs(\n _transportId: string,\n _params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n },\n ) {\n return { logs: [], total: 0, page: _params?.page ?? 1, perPage: _params?.perPage ?? 100, hasMore: false };\n }\n\n async listLogsByRunId(_args: {\n transportId: string;\n runId: string;\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n page?: number;\n perPage?: number;\n }) {\n return { logs: [], total: 0, page: _args.page ?? 1, perPage: _args.perPage ?? 100, hasMore: false };\n }\n}\n","import type { IMastraLogger } from '../logger';\nimport { ConsoleLogger, RegisteredLogger } from '../logger';\n\nexport class MastraBase {\n component: RegisteredLogger = RegisteredLogger.LLM;\n protected logger: IMastraLogger;\n name?: string;\n #rawConfig?: Record<string, unknown>;\n\n constructor({\n component,\n name,\n rawConfig,\n }: {\n component?: RegisteredLogger;\n name?: string;\n rawConfig?: Record<string, unknown>;\n }) {\n this.component = component || RegisteredLogger.LLM;\n this.name = name;\n this.#rawConfig = rawConfig;\n this.logger = new ConsoleLogger({ name: `${this.component} - ${this.name}` });\n }\n\n /**\n * Returns the raw storage configuration this primitive was created from,\n * or undefined if it was created from code.\n */\n toRawConfig(): Record<string, unknown> | undefined {\n return this.#rawConfig;\n }\n\n /**\n * Sets the raw storage configuration for this primitive.\n * @internal\n */\n __setRawConfig(rawConfig: Record<string, unknown>): void {\n this.#rawConfig = rawConfig;\n }\n\n /**\n * Set the logger for the agent\n * @param logger\n */\n __setLogger(logger: IMastraLogger) {\n this.logger =\n 'child' in logger && typeof (logger as any).child === 'function'\n ? (logger as any).child({ component: this.component })\n : logger;\n }\n}\n","import { MastraBase } from '@internal/core/base';\nimport type { ToolsInput } from '@internal/core/types';\n\nexport type VoiceEventType = 'speaking' | 'writing' | 'error' | string;\n\nexport interface VoiceEventMap {\n speaker: NodeJS.ReadableStream;\n speaking: { audio?: string };\n writing: { text: string; role: 'assistant' | 'user' };\n error: { message: string; code?: string; details?: unknown };\n [key: string]: unknown;\n}\n\ninterface BuiltInModelConfig {\n name: string;\n apiKey?: string;\n}\n\nexport interface VoiceConfig<T = unknown> {\n listeningModel?: BuiltInModelConfig;\n speechModel?: BuiltInModelConfig;\n speaker?: string;\n name?: string;\n realtimeConfig?: {\n model?: string;\n apiKey?: string;\n options?: T;\n };\n}\n\nexport interface VoiceSpanConfig {\n component: 'VOICE';\n name?: string;\n speaker?: string;\n listeningModel?: { name: string };\n speechModel?: { name: string };\n realtimeModel?: string;\n}\n\nexport interface IMastraVoice<\n TSpeakOptions = unknown,\n TListenOptions = unknown,\n TTools extends ToolsInput = ToolsInput,\n TEventArgs extends VoiceEventMap = VoiceEventMap,\n TSpeakerMetadata = unknown,\n> {\n serializeForSpan(): VoiceSpanConfig;\n speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n } & TSpeakOptions,\n ): Promise<NodeJS.ReadableStream | void>;\n listen(\n audioStream: NodeJS.ReadableStream | unknown,\n options?: TListenOptions,\n ): Promise<string | NodeJS.ReadableStream | void>;\n updateConfig(options: Record<string, unknown>): void;\n connect(options?: Record<string, unknown>): Promise<void>;\n send(audioData: NodeJS.ReadableStream | Int16Array): Promise<void>;\n answer(options?: Record<string, unknown>): Promise<void>;\n addInstructions(instructions?: string): void;\n addTools(tools: TTools): void;\n close(): void;\n on<E extends VoiceEventType>(\n event: E,\n callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void,\n ): void;\n off<E extends VoiceEventType>(\n event: E,\n callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void,\n ): void;\n getSpeakers(): Promise<\n Array<\n {\n voiceId: string;\n } & TSpeakerMetadata\n >\n >;\n getListener(): Promise<{ enabled: boolean }>;\n}\n\nexport abstract class MastraVoice<\n TOptions = unknown,\n TSpeakOptions = unknown,\n TListenOptions = unknown,\n TTools extends ToolsInput = ToolsInput,\n TEventArgs extends VoiceEventMap = VoiceEventMap,\n TSpeakerMetadata = unknown,\n>\n extends MastraBase\n implements IMastraVoice<TSpeakOptions, TListenOptions, TTools, TEventArgs, TSpeakerMetadata>\n{\n protected listeningModel?: BuiltInModelConfig;\n protected speechModel?: BuiltInModelConfig;\n protected speaker?: string;\n protected realtimeConfig?: {\n model?: string;\n apiKey?: string;\n options?: TOptions;\n };\n\n constructor({ listeningModel, speechModel, speaker, realtimeConfig, name }: VoiceConfig<TOptions> = {}) {\n super({\n component: 'VOICE',\n name,\n });\n this.listeningModel = listeningModel;\n this.speechModel = speechModel;\n this.speaker = speaker;\n this.realtimeConfig = realtimeConfig;\n }\n\n /**\n * Custom serialization for tracing/observability spans.\n * Excludes `apiKey` from listeningModel / speechModel / realtimeConfig\n * and any provider-specific state held by subclasses. Subclasses that\n * need to expose additional non-sensitive fields can override.\n */\n serializeForSpan(): VoiceSpanConfig {\n return {\n component: 'VOICE',\n name: this.name,\n speaker: this.speaker,\n listeningModel: this.listeningModel ? { name: this.listeningModel.name } : undefined,\n speechModel: this.speechModel ? { name: this.speechModel.name } : undefined,\n realtimeModel: this.realtimeConfig?.model,\n };\n }\n\n /**\n * Convert text to speech\n * @param input Text or text stream to convert to speech\n * @param options Speech options including speaker and provider-specific options\n * @returns Audio stream\n */\n /**\n * Convert text to speech\n * @param input Text or text stream to convert to speech\n * @param options Speech options including speaker and provider-specific options\n * @returns Audio stream or void if in chat mode\n */\n abstract speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n } & TSpeakOptions,\n ): Promise<NodeJS.ReadableStream | void>;\n\n /**\n * Convert speech to text\n * @param audioStream Audio stream to transcribe\n * @param options Provider-specific transcription options\n * @returns Text or text stream\n */\n /**\n * Convert speech to text\n * @param audioStream Audio stream to transcribe\n * @param options Provider-specific transcription options\n * @returns Text, text stream, or void if in chat mode\n */\n abstract listen(\n audioStream: NodeJS.ReadableStream | unknown, // Allow other audio input types for OpenAI realtime API\n options?: TListenOptions,\n ): Promise<string | NodeJS.ReadableStream | void>;\n\n updateConfig(_options: Record<string, unknown>): void {\n this.logger.debug('updateConfig not implemented by this voice provider');\n }\n\n /**\n * Initializes a WebSocket or WebRTC connection for real-time communication\n * @returns Promise that resolves when the connection is established\n */\n async connect(_options?: Record<string, unknown>): Promise<void> {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('connect not implemented by this voice provider');\n }\n\n /**\n * Relay audio data to the voice provider for real-time processing\n * @param audioData Audio data to relay\n */\n async send(_audioData: NodeJS.ReadableStream | Int16Array): Promise<void> {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('relay not implemented by this voice provider');\n }\n\n /**\n * Trigger voice providers to respond\n */\n async answer(_options?: Record<string, unknown>): Promise<void> {\n this.logger.debug('answer not implemented by this voice provider');\n }\n\n /**\n * Equip the voice provider with instructions\n * @param instructions Instructions to add\n */\n addInstructions(_instructions?: string): void {\n // Default implementation - voice providers can override if they support this feature\n }\n\n /**\n * Equip the voice provider with tools\n * @param tools Array of tools to add\n */\n addTools(_tools: TTools): void {\n // Default implementation - voice providers can override if they support this feature\n }\n\n /**\n * Disconnect from the WebSocket or WebRTC connection\n */\n close(): void {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('close not implemented by this voice provider');\n }\n\n /**\n * Register an event listener\n * @param event Event name (e.g., 'speaking', 'writing', 'error')\n * @param callback Callback function that receives event data\n */\n on<E extends VoiceEventType>(\n _event: E,\n _callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void,\n ): void {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('on not implemented by this voice provider');\n }\n\n /**\n * Remove an event listener\n * @param event Event name (e.g., 'speaking', 'writing', 'error')\n * @param callback Callback function to remove\n */\n off<E extends VoiceEventType>(\n _event: E,\n _callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void,\n ): void {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('off not implemented by this voice provider');\n }\n\n /**\n * Get available speakers/voices\n * @returns Array of available voice IDs and their metadata\n */\n getSpeakers(): Promise<\n Array<\n {\n voiceId: string;\n } & TSpeakerMetadata\n >\n > {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('getSpeakers not implemented by this voice provider');\n return Promise.resolve([]);\n }\n\n /**\n * Get available speakers/voices\n * @returns Array of available voice IDs and their metadata\n */\n getListener(): Promise<{ enabled: boolean }> {\n // Default implementation - voice providers can override if they support this feature\n this.logger.debug('getListener not implemented by this voice provider');\n return Promise.resolve({ enabled: false });\n }\n}\n","import type {\n Ai,\n Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output,\n Ai_Cf_Openai_Whisper_Output,\n Ai_Cf_Openai_Whisper_Tiny_En_Output,\n} from '@cloudflare/workers-types';\nimport { MastraVoice } from '@internal/voice';\nimport Cloudflare from 'cloudflare';\n\ninterface CloudflareListenOptions {\n apiKey?: string;\n model?: '@cf/openai/whisper-tiny-en' | '@cf/openai/whisper' | '@cf/openai/whisper-large-v3-turbo';\n account_id?: string;\n}\n\ntype CloudflareListenOutput =\n | Ai_Cf_Openai_Whisper_Tiny_En_Output\n | Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output\n | Ai_Cf_Openai_Whisper_Output;\n\nconst defaultListeningModel = {\n model: '@cf/openai/whisper-large-v3-turbo' as const,\n apiKey: process.env.CLOUDFLARE_AI_API_KEY,\n account_id: process.env.CLOUDFLARE_ACCOUNT_ID!,\n};\n\nexport class CloudflareVoice extends MastraVoice {\n private apiToken?: string;\n private client: Cloudflare | null = null;\n private binding?: Ai;\n\n constructor({\n listeningModel,\n binding,\n }: {\n listeningModel?: CloudflareListenOptions;\n binding?: Ai;\n } = {}) {\n super({\n listeningModel: {\n name: listeningModel?.model ?? defaultListeningModel.model,\n apiKey: listeningModel?.apiKey ?? defaultListeningModel.apiKey,\n },\n });\n\n // Store Workers AI binding if provided\n this.binding = binding;\n\n // Only setup REST client if no binding provided or both are needed\n if (!binding) {\n this.apiToken = listeningModel?.apiKey || defaultListeningModel.apiKey;\n if (!this.apiToken) {\n throw new Error('CLOUDFLARE_AI_API_KEY must be set when not using bindings');\n }\n this.client = new Cloudflare({ apiToken: this.apiToken });\n }\n }\n\n /**\n * Checks if listening capabilities are enabled.\n *\n * @returns {Promise<{ enabled: boolean }>}\n */\n async getListener() {\n return { enabled: true };\n }\n\n async listen(audioStream: NodeJS.ReadableStream, options?: CloudflareListenOptions): Promise<string> {\n // Collect audio data into buffer\n const chunks: Buffer[] = [];\n for await (const chunk of audioStream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n const audioBuffer = Buffer.concat(chunks);\n const base64Audio = audioBuffer.toString('base64');\n\n const model = options?.model || defaultListeningModel.model;\n\n // Use native binding if available, otherwise use REST API\n if (this.binding) {\n // Using Workers AI binding\n const response = (await this.binding.run(model, {\n audio: base64Audio,\n })) as CloudflareListenOutput;\n return response.text;\n } else if (this.client) {\n // Using REST API client\n const payload = { audio: base64Audio, account_id: options?.account_id || defaultListeningModel.account_id };\n const response = (await this.client.ai.run(model, payload)) as any;\n return response.text as string;\n } else {\n throw new Error('Neither binding nor REST client is configured');\n }\n }\n async speak(): Promise<NodeJS.ReadableStream> {\n throw new Error('This feature is not yet implemented.');\n }\n async getSpeakers(): Promise<Array<{ voiceId: string; [key: string]: any }>> {\n throw new Error('This feature is not yet implemented.');\n }\n}\n"]}