@mastra/voice-google 0.12.1-alpha.0 → 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.
- package/CHANGELOG.md +15 -0
- package/dist/_types/@internal_voice/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +15 -167
- package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +2 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-adding-voice.md +37 -6
- package/dist/docs/references/docs-voice-overview.md +86 -24
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/voice-google
|
|
2
2
|
|
|
3
|
+
## 0.12.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dependencies updates: ([#17518](https://github.com/mastra-ai/mastra/pull/17518))
|
|
8
|
+
- Updated dependency [`@google-cloud/text-to-speech@^6.4.1` ↗︎](https://www.npmjs.com/package/@google-cloud/text-to-speech/v/6.4.1) (from `^6.4.0`, in `dependencies`)
|
|
9
|
+
|
|
10
|
+
## 0.12.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Moved shared voice primitives and route metadata into the new `@internal/voice` package so voice providers no longer depend on `@mastra/core` and server voice routes share the same route definitions. ([#16725](https://github.com/mastra-ai/mastra/pull/16725))
|
|
15
|
+
|
|
16
|
+
`@mastra/core/voice` continues to re-export the voice APIs for backwards compatibility.
|
|
17
|
+
|
|
3
18
|
## 0.12.1-alpha.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import { JSONSchema7Definition } from 'json-schema';
|
|
1
3
|
import { ServerResponse } from 'node:http';
|
|
2
4
|
import { ServerResponse as ServerResponse_2 } from 'http';
|
|
3
5
|
import { z } from '../../zod/v4/index.d.cts';
|
|
@@ -1547,16 +1549,16 @@ declare interface EventSourceMessage {
|
|
|
1547
1549
|
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
1548
1550
|
* leave this as `undefined` if not explicitly declared.
|
|
1549
1551
|
*/
|
|
1550
|
-
event?: string | undefined
|
|
1552
|
+
event?: string | undefined;
|
|
1551
1553
|
/**
|
|
1552
1554
|
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
1553
1555
|
* last received message ID in sync when reconnecting.
|
|
1554
1556
|
*/
|
|
1555
|
-
id?: string | undefined
|
|
1557
|
+
id?: string | undefined;
|
|
1556
1558
|
/**
|
|
1557
1559
|
* The data received for this message
|
|
1558
1560
|
*/
|
|
1559
|
-
data: string
|
|
1561
|
+
data: string;
|
|
1560
1562
|
}
|
|
1561
1563
|
|
|
1562
1564
|
/**
|
|
@@ -1580,8 +1582,11 @@ declare interface EventSourceMessage {
|
|
|
1580
1582
|
*
|
|
1581
1583
|
* @public
|
|
1582
1584
|
*/
|
|
1583
|
-
declare class EventSourceParserStream extends TransformStream<
|
|
1584
|
-
|
|
1585
|
+
declare class EventSourceParserStream extends TransformStream<
|
|
1586
|
+
string,
|
|
1587
|
+
EventSourceMessage
|
|
1588
|
+
> {
|
|
1589
|
+
constructor({ onError, onRetry, onComment }?: StreamOptions);
|
|
1585
1590
|
}
|
|
1586
1591
|
|
|
1587
1592
|
/**
|
|
@@ -3507,164 +3512,7 @@ export declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7 | (
|
|
|
3507
3512
|
validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
|
3508
3513
|
}): Schema<OBJECT>;
|
|
3509
3514
|
|
|
3510
|
-
export
|
|
3511
|
-
$id?: string | undefined;
|
|
3512
|
-
$ref?: string | undefined;
|
|
3513
|
-
$schema?: JSONSchema7Version | undefined;
|
|
3514
|
-
$comment?: string | undefined;
|
|
3515
|
-
|
|
3516
|
-
/**
|
|
3517
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
3518
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
3519
|
-
*/
|
|
3520
|
-
$defs?: {
|
|
3521
|
-
[key: string]: JSONSchema7Definition;
|
|
3522
|
-
} | undefined;
|
|
3523
|
-
|
|
3524
|
-
/**
|
|
3525
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
3526
|
-
*/
|
|
3527
|
-
type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
|
|
3528
|
-
enum?: JSONSchema7Type[] | undefined;
|
|
3529
|
-
const?: JSONSchema7Type | undefined;
|
|
3530
|
-
|
|
3531
|
-
/**
|
|
3532
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
3533
|
-
*/
|
|
3534
|
-
multipleOf?: number | undefined;
|
|
3535
|
-
maximum?: number | undefined;
|
|
3536
|
-
exclusiveMaximum?: number | undefined;
|
|
3537
|
-
minimum?: number | undefined;
|
|
3538
|
-
exclusiveMinimum?: number | undefined;
|
|
3539
|
-
|
|
3540
|
-
/**
|
|
3541
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
|
|
3542
|
-
*/
|
|
3543
|
-
maxLength?: number | undefined;
|
|
3544
|
-
minLength?: number | undefined;
|
|
3545
|
-
pattern?: string | undefined;
|
|
3546
|
-
|
|
3547
|
-
/**
|
|
3548
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
3549
|
-
*/
|
|
3550
|
-
items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
|
|
3551
|
-
additionalItems?: JSONSchema7Definition | undefined;
|
|
3552
|
-
maxItems?: number | undefined;
|
|
3553
|
-
minItems?: number | undefined;
|
|
3554
|
-
uniqueItems?: boolean | undefined;
|
|
3555
|
-
contains?: JSONSchema7Definition | undefined;
|
|
3556
|
-
|
|
3557
|
-
/**
|
|
3558
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
3559
|
-
*/
|
|
3560
|
-
maxProperties?: number | undefined;
|
|
3561
|
-
minProperties?: number | undefined;
|
|
3562
|
-
required?: string[] | undefined;
|
|
3563
|
-
properties?: {
|
|
3564
|
-
[key: string]: JSONSchema7Definition;
|
|
3565
|
-
} | undefined;
|
|
3566
|
-
patternProperties?: {
|
|
3567
|
-
[key: string]: JSONSchema7Definition;
|
|
3568
|
-
} | undefined;
|
|
3569
|
-
additionalProperties?: JSONSchema7Definition | undefined;
|
|
3570
|
-
dependencies?: {
|
|
3571
|
-
[key: string]: JSONSchema7Definition | string[];
|
|
3572
|
-
} | undefined;
|
|
3573
|
-
propertyNames?: JSONSchema7Definition | undefined;
|
|
3574
|
-
|
|
3575
|
-
/**
|
|
3576
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
3577
|
-
*/
|
|
3578
|
-
if?: JSONSchema7Definition | undefined;
|
|
3579
|
-
then?: JSONSchema7Definition | undefined;
|
|
3580
|
-
else?: JSONSchema7Definition | undefined;
|
|
3581
|
-
|
|
3582
|
-
/**
|
|
3583
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
3584
|
-
*/
|
|
3585
|
-
allOf?: JSONSchema7Definition[] | undefined;
|
|
3586
|
-
anyOf?: JSONSchema7Definition[] | undefined;
|
|
3587
|
-
oneOf?: JSONSchema7Definition[] | undefined;
|
|
3588
|
-
not?: JSONSchema7Definition | undefined;
|
|
3589
|
-
|
|
3590
|
-
/**
|
|
3591
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
3592
|
-
*/
|
|
3593
|
-
format?: string | undefined;
|
|
3594
|
-
|
|
3595
|
-
/**
|
|
3596
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
3597
|
-
*/
|
|
3598
|
-
contentMediaType?: string | undefined;
|
|
3599
|
-
contentEncoding?: string | undefined;
|
|
3600
|
-
|
|
3601
|
-
/**
|
|
3602
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
3603
|
-
*/
|
|
3604
|
-
definitions?: {
|
|
3605
|
-
[key: string]: JSONSchema7Definition;
|
|
3606
|
-
} | undefined;
|
|
3607
|
-
|
|
3608
|
-
/**
|
|
3609
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
3610
|
-
*/
|
|
3611
|
-
title?: string | undefined;
|
|
3612
|
-
description?: string | undefined;
|
|
3613
|
-
default?: JSONSchema7Type | undefined;
|
|
3614
|
-
readOnly?: boolean | undefined;
|
|
3615
|
-
writeOnly?: boolean | undefined;
|
|
3616
|
-
examples?: JSONSchema7Type | undefined;
|
|
3617
|
-
}
|
|
3618
|
-
|
|
3619
|
-
declare interface JSONSchema7Array extends Array<JSONSchema7Type> {}
|
|
3620
|
-
|
|
3621
|
-
/**
|
|
3622
|
-
* JSON Schema v7
|
|
3623
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
3624
|
-
*/
|
|
3625
|
-
declare type JSONSchema7Definition = JSONSchema7 | boolean;
|
|
3626
|
-
|
|
3627
|
-
declare interface JSONSchema7Object {
|
|
3628
|
-
[key: string]: JSONSchema7Type;
|
|
3629
|
-
}
|
|
3630
|
-
|
|
3631
|
-
/**
|
|
3632
|
-
* Primitive type
|
|
3633
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
3634
|
-
*/
|
|
3635
|
-
declare type JSONSchema7Type =
|
|
3636
|
-
| string //
|
|
3637
|
-
| number
|
|
3638
|
-
| boolean
|
|
3639
|
-
| JSONSchema7Object
|
|
3640
|
-
| JSONSchema7Array
|
|
3641
|
-
| null;
|
|
3642
|
-
|
|
3643
|
-
/**
|
|
3644
|
-
* Primitive type
|
|
3645
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
|
|
3646
|
-
*/
|
|
3647
|
-
declare type JSONSchema7TypeName =
|
|
3648
|
-
| "string" //
|
|
3649
|
-
| "number"
|
|
3650
|
-
| "integer"
|
|
3651
|
-
| "boolean"
|
|
3652
|
-
| "object"
|
|
3653
|
-
| "array"
|
|
3654
|
-
| "null";
|
|
3655
|
-
|
|
3656
|
-
/**
|
|
3657
|
-
* Meta schema
|
|
3658
|
-
*
|
|
3659
|
-
* Recommended values:
|
|
3660
|
-
* - 'http://json-schema.org/schema#'
|
|
3661
|
-
* - 'http://json-schema.org/hyper-schema#'
|
|
3662
|
-
* - 'http://json-schema.org/draft-07/schema#'
|
|
3663
|
-
* - 'http://json-schema.org/draft-07/hyper-schema#'
|
|
3664
|
-
*
|
|
3665
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
|
|
3666
|
-
*/
|
|
3667
|
-
declare type JSONSchema7Version = string;
|
|
3515
|
+
export { JSONSchema7 }
|
|
3668
3516
|
|
|
3669
3517
|
export declare class JsonToSseTransformStream extends TransformStream<unknown, string> {
|
|
3670
3518
|
constructor();
|
|
@@ -6985,19 +6833,19 @@ declare interface StreamOptions {
|
|
|
6985
6833
|
*
|
|
6986
6834
|
* @defaultValue `undefined`
|
|
6987
6835
|
*/
|
|
6988
|
-
onError?: (
|
|
6836
|
+
onError?: ("terminate" | ((error: Error) => void)) | undefined;
|
|
6989
6837
|
/**
|
|
6990
6838
|
* Callback for when a reconnection interval is sent from the server.
|
|
6991
6839
|
*
|
|
6992
6840
|
* @param retry - The number of milliseconds to wait before reconnecting.
|
|
6993
6841
|
*/
|
|
6994
|
-
onRetry?: ((retry: number) => void) | undefined
|
|
6842
|
+
onRetry?: ((retry: number) => void) | undefined;
|
|
6995
6843
|
/**
|
|
6996
6844
|
* Callback for when a comment is encountered in the stream.
|
|
6997
6845
|
*
|
|
6998
6846
|
* @param comment - The comment encountered in the stream.
|
|
6999
6847
|
*/
|
|
7000
|
-
onComment?: ((comment: string) => void) | undefined
|
|
6848
|
+
onComment?: ((comment: string) => void) | undefined;
|
|
7001
6849
|
}
|
|
7002
6850
|
|
|
7003
6851
|
/**
|
|
@@ -9039,5 +8887,5 @@ export declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, an
|
|
|
9039
8887
|
}): Schema<OBJECT>;
|
|
9040
8888
|
|
|
9041
8889
|
export { }
|
|
9042
|
-
export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, ParseResult as ParseResult, FlexibleValidator as FlexibleValidator, ValidationResult as ValidationResult, LanguageModelV2ToolResultOutput as LanguageModelV2ToolResultOutput, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, LanguageModelV2ToolResultPart as LanguageModelV2ToolResultPart, FlexibleSchema as FlexibleSchema,
|
|
8890
|
+
export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, ParseResult as ParseResult, FlexibleValidator as FlexibleValidator, ValidationResult as ValidationResult, LanguageModelV2ToolResultOutput as LanguageModelV2ToolResultOutput, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, LanguageModelV2ToolResultPart as LanguageModelV2ToolResultPart, FlexibleSchema as FlexibleSchema, ImageModelV2CallWarning as ImageModelV2CallWarning, SpeechModelV2CallWarning as SpeechModelV2CallWarning, TranscriptionModelV2CallWarning as TranscriptionModelV2CallWarning, AttributeValue as AttributeValue, Tracer as Tracer, EmbeddingModelV2Embedding as EmbeddingModelV2Embedding, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2FinishReason as LanguageModelV2FinishReason, LanguageModelV2CallWarning as LanguageModelV2CallWarning, LanguageModelV2Middleware as LanguageModelV2Middleware, SharedV2ProviderMetadata as SharedV2ProviderMetadata, LanguageModelV2Usage as LanguageModelV2Usage, Source as Source, ResponseMessage as ResponseMessage, DeepPartialInternal as DeepPartialInternal, LanguageModelV2ToolCall as LanguageModelV2ToolCall, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils as _ai_sdk_provider_utils, _ai_sdk_provider as _ai_sdk_provider, DataUIMessageChunk as DataUIMessageChunk, ConsumeStreamOptions as ConsumeStreamOptions, Output_2 as Output_2, InferAgentTools as InferAgentTools, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, InferSchema as InferSchema, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, JSONValue_2 as JSONValue_2, LanguageModelV2CallOptions as LanguageModelV2CallOptions, LanguageModelV2 as LanguageModelV2, EmbeddingModelV2 as EmbeddingModelV2, ImageModelV2 as ImageModelV2, TranscriptionModelV2 as TranscriptionModelV2, SpeechModelV2 as SpeechModelV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV2 as ProviderV2, getOriginalFetch as getOriginalFetch, UIMessageStreamResponseInit as UIMessageStreamResponseInit, InferUIMessageToolCall as InferUIMessageToolCall, Validator as Validator, StandardSchemaV1 as StandardSchemaV1, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, InferUIMessageTools as InferUIMessageTools, Resolvable as Resolvable, FetchFunction as FetchFunction };
|
|
9043
8891
|
export { schemaSymbol, symbol$1, symbol$1_2, symbol$2, symbol$2_2, symbol$3, symbol$3_2, symbol$4, symbol$4_2, symbol$5, symbol$5_2, symbol$6, symbol$6_2, symbol$7, symbol$7_2, symbol$8, symbol$8_2, symbol$9, symbol$9_2, symbol$a, symbol$a_2, symbol$b, symbol$b_2, symbol$c, symbol$c_2, symbol$d, symbol$d_2, symbol$e, symbol, symbol_2, symbol_3, validatorSymbol };
|
package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ type VersionSelector = {
|
|
|
52
52
|
};
|
|
53
53
|
type VersionOverrides = {
|
|
54
54
|
agents?: Record<string, VersionSelector>;
|
|
55
|
+
/** Fallback status for sub-agents (and future primitives) without an explicit entry. */
|
|
56
|
+
defaultStatus?: 'draft' | 'published';
|
|
55
57
|
};
|
|
56
58
|
declare function mergeVersionOverrides(base?: VersionOverrides, overrides?: VersionOverrides): VersionOverrides | undefined;
|
|
57
59
|
declare class RequestContext<Values extends Record<string, any> | unknown = unknown> {
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-voice-google
|
|
|
3
3
|
description: Documentation for @mastra/voice-google. Use when working with @mastra/voice-google APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/voice-google"
|
|
6
|
-
version: "0.12.
|
|
6
|
+
version: "0.12.2-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -20,7 +20,7 @@ export const agent = new Agent({
|
|
|
20
20
|
id: 'voice-agent',
|
|
21
21
|
name: 'Voice Agent',
|
|
22
22
|
instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
|
|
23
|
-
model: 'openai/gpt-5.
|
|
23
|
+
model: 'openai/gpt-5.5',
|
|
24
24
|
voice,
|
|
25
25
|
})
|
|
26
26
|
|
|
@@ -109,7 +109,7 @@ export const agent = new Agent({
|
|
|
109
109
|
id: 'speech-to-speech-agent',
|
|
110
110
|
name: 'Speech-to-Speech Agent',
|
|
111
111
|
instructions: `You are a helpful assistant with speech-to-speech capabilities.`,
|
|
112
|
-
model: 'openai/gpt-5.
|
|
112
|
+
model: 'openai/gpt-5.5',
|
|
113
113
|
tools: {
|
|
114
114
|
// Tools configured on Agent are passed to voice provider
|
|
115
115
|
search,
|
|
@@ -132,6 +132,37 @@ agent.voice.send(microphoneStream)
|
|
|
132
132
|
agent.voice.close()
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
+
### Per-session voice for concurrent sessions
|
|
136
|
+
|
|
137
|
+
A static `voice` instance is shared across every request. For one-shot text-to-speech this is fine, but realtime and speech-to-speech providers store one WebSocket, one set of tools, and one request context per instance. If you deploy a single agent that handles several live sessions at once, a shared instance lets one session overwrite another session's tools, instructions, and request context.
|
|
138
|
+
|
|
139
|
+
To give each session its own voice, provide `voice` as a resolver. Mastra runs the resolver on every `getVoice()` call and returns a fresh, session-owned instance:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { Agent } from '@mastra/core/agent'
|
|
143
|
+
import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
|
|
144
|
+
|
|
145
|
+
export const agent = new Agent({
|
|
146
|
+
id: 'support-line',
|
|
147
|
+
name: 'Support Line',
|
|
148
|
+
instructions: ({ requestContext }) => `Help user ${requestContext.get('user')}.`,
|
|
149
|
+
model: 'openai/gpt-5.5',
|
|
150
|
+
voice: ({ requestContext }) => new OpenAIRealtimeVoice({ apiKey: requestContext.get('apiKey') }),
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
// Each concurrent session resolves its own voice instance
|
|
154
|
+
const voice = await agent.getVoice({ requestContext })
|
|
155
|
+
await voice.connect()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
When you use a resolver:
|
|
159
|
+
|
|
160
|
+
- Each call to `getVoice()` returns a new instance, so concurrent sessions never share state.
|
|
161
|
+
- Mastra does not add tools or instructions to a resolver instance. Configure those inside the resolver or on the provider.
|
|
162
|
+
- You own the lifecycle of the returned instance, so call `disconnect()` or `close()` when the session ends.
|
|
163
|
+
|
|
164
|
+
The `agent.voice` getter has no request context, so it throws when `voice` is a resolver. Use `agent.getVoice({ requestContext })` instead.
|
|
165
|
+
|
|
135
166
|
### Event System
|
|
136
167
|
|
|
137
168
|
The realtime voice provider emits several events you can listen for:
|
|
@@ -209,7 +240,7 @@ export const convertToText = async (input: string | NodeJS.ReadableStream): Prom
|
|
|
209
240
|
export const hybridVoiceAgent = new Agent({
|
|
210
241
|
id: 'hybrid-voice-agent',
|
|
211
242
|
name: 'Hybrid Voice Agent',
|
|
212
|
-
model: 'openai/gpt-5.
|
|
243
|
+
model: 'openai/gpt-5.5',
|
|
213
244
|
instructions: 'You can speak and listen using different providers.',
|
|
214
245
|
voice: new CompositeVoice({
|
|
215
246
|
input: new OpenAIVoice(),
|
|
@@ -221,7 +252,7 @@ export const unifiedVoiceAgent = new Agent({
|
|
|
221
252
|
id: 'unified-voice-agent',
|
|
222
253
|
name: 'Unified Voice Agent',
|
|
223
254
|
instructions: 'You are an agent with both STT and TTS capabilities.',
|
|
224
|
-
model: 'openai/gpt-5.
|
|
255
|
+
model: 'openai/gpt-5.5',
|
|
225
256
|
voice: new OpenAIVoice(),
|
|
226
257
|
})
|
|
227
258
|
|
|
@@ -263,7 +294,7 @@ export const agent = new Agent({
|
|
|
263
294
|
id: 'voice-agent',
|
|
264
295
|
name: 'Voice Agent',
|
|
265
296
|
instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
|
|
266
|
-
model: 'openai/gpt-5.
|
|
297
|
+
model: 'openai/gpt-5.5',
|
|
267
298
|
|
|
268
299
|
// Create a composite voice using OpenAI for listening and PlayAI for speaking
|
|
269
300
|
voice: new CompositeVoice({
|
|
@@ -288,7 +319,7 @@ export const agent = new Agent({
|
|
|
288
319
|
id: 'aisdk-voice-agent',
|
|
289
320
|
name: 'AI SDK Voice Agent',
|
|
290
321
|
instructions: `You are a helpful assistant with voice capabilities.`,
|
|
291
|
-
model: 'openai/gpt-5.
|
|
322
|
+
model: 'openai/gpt-5.5',
|
|
292
323
|
|
|
293
324
|
// Pass AI SDK models directly to CompositeVoice
|
|
294
325
|
voice: new CompositeVoice({
|
|
@@ -16,7 +16,7 @@ const voiceAgent = new Agent({
|
|
|
16
16
|
id: 'voice-agent',
|
|
17
17
|
name: 'Voice Agent',
|
|
18
18
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
19
|
-
model: 'openai/gpt-5.
|
|
19
|
+
model: 'openai/gpt-5.5',
|
|
20
20
|
voice: new OpenAIVoice(),
|
|
21
21
|
})
|
|
22
22
|
```
|
|
@@ -40,7 +40,7 @@ const voiceAgent = new Agent({
|
|
|
40
40
|
id: 'voice-agent',
|
|
41
41
|
name: 'Voice Agent',
|
|
42
42
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
43
|
-
model: 'openai/gpt-5.
|
|
43
|
+
model: 'openai/gpt-5.5',
|
|
44
44
|
voice: new OpenAIVoice(),
|
|
45
45
|
})
|
|
46
46
|
|
|
@@ -68,7 +68,7 @@ const voiceAgent = new Agent({
|
|
|
68
68
|
id: 'voice-agent',
|
|
69
69
|
name: 'Voice Agent',
|
|
70
70
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
71
|
-
model: 'openai/gpt-5.
|
|
71
|
+
model: 'openai/gpt-5.5',
|
|
72
72
|
voice: new AzureVoice(),
|
|
73
73
|
})
|
|
74
74
|
|
|
@@ -95,7 +95,7 @@ const voiceAgent = new Agent({
|
|
|
95
95
|
id: 'voice-agent',
|
|
96
96
|
name: 'Voice Agent',
|
|
97
97
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
98
|
-
model: 'openai/gpt-5.
|
|
98
|
+
model: 'openai/gpt-5.5',
|
|
99
99
|
voice: new ElevenLabsVoice(),
|
|
100
100
|
})
|
|
101
101
|
|
|
@@ -122,7 +122,7 @@ const voiceAgent = new Agent({
|
|
|
122
122
|
id: 'voice-agent',
|
|
123
123
|
name: 'Voice Agent',
|
|
124
124
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
125
|
-
model: 'openai/gpt-5.
|
|
125
|
+
model: 'openai/gpt-5.5',
|
|
126
126
|
voice: new PlayAIVoice(),
|
|
127
127
|
})
|
|
128
128
|
|
|
@@ -149,7 +149,7 @@ const voiceAgent = new Agent({
|
|
|
149
149
|
id: 'voice-agent',
|
|
150
150
|
name: 'Voice Agent',
|
|
151
151
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
152
|
-
model: 'openai/gpt-5.
|
|
152
|
+
model: 'openai/gpt-5.5',
|
|
153
153
|
voice: new GoogleVoice(),
|
|
154
154
|
})
|
|
155
155
|
|
|
@@ -176,7 +176,7 @@ const voiceAgent = new Agent({
|
|
|
176
176
|
id: 'voice-agent',
|
|
177
177
|
name: 'Voice Agent',
|
|
178
178
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
179
|
-
model: 'openai/gpt-5.
|
|
179
|
+
model: 'openai/gpt-5.5',
|
|
180
180
|
voice: new CloudflareVoice(),
|
|
181
181
|
})
|
|
182
182
|
|
|
@@ -203,7 +203,7 @@ const voiceAgent = new Agent({
|
|
|
203
203
|
id: 'voice-agent',
|
|
204
204
|
name: 'Voice Agent',
|
|
205
205
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
206
|
-
model: 'openai/gpt-5.
|
|
206
|
+
model: 'openai/gpt-5.5',
|
|
207
207
|
voice: new DeepgramVoice(),
|
|
208
208
|
})
|
|
209
209
|
|
|
@@ -230,7 +230,7 @@ const voiceAgent = new Agent({
|
|
|
230
230
|
id: 'voice-agent',
|
|
231
231
|
name: 'Voice Agent',
|
|
232
232
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
233
|
-
model: 'openai/gpt-5.
|
|
233
|
+
model: 'openai/gpt-5.5',
|
|
234
234
|
voice: new InworldVoice(),
|
|
235
235
|
})
|
|
236
236
|
|
|
@@ -257,7 +257,7 @@ const voiceAgent = new Agent({
|
|
|
257
257
|
id: 'voice-agent',
|
|
258
258
|
name: 'Voice Agent',
|
|
259
259
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
260
|
-
model: 'openai/gpt-5.
|
|
260
|
+
model: 'openai/gpt-5.5',
|
|
261
261
|
voice: new SpeechifyVoice(),
|
|
262
262
|
})
|
|
263
263
|
|
|
@@ -284,7 +284,7 @@ const voiceAgent = new Agent({
|
|
|
284
284
|
id: 'voice-agent',
|
|
285
285
|
name: 'Voice Agent',
|
|
286
286
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
287
|
-
model: 'openai/gpt-5.
|
|
287
|
+
model: 'openai/gpt-5.5',
|
|
288
288
|
voice: new SarvamVoice(),
|
|
289
289
|
})
|
|
290
290
|
|
|
@@ -311,7 +311,7 @@ const voiceAgent = new Agent({
|
|
|
311
311
|
id: 'voice-agent',
|
|
312
312
|
name: 'Voice Agent',
|
|
313
313
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
314
|
-
model: 'openai/gpt-5.
|
|
314
|
+
model: 'openai/gpt-5.5',
|
|
315
315
|
voice: new MurfVoice(),
|
|
316
316
|
})
|
|
317
317
|
|
|
@@ -346,7 +346,7 @@ const voiceAgent = new Agent({
|
|
|
346
346
|
id: 'voice-agent',
|
|
347
347
|
name: 'Voice Agent',
|
|
348
348
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
349
|
-
model: 'openai/gpt-5.
|
|
349
|
+
model: 'openai/gpt-5.5',
|
|
350
350
|
voice: new OpenAIVoice(),
|
|
351
351
|
})
|
|
352
352
|
|
|
@@ -375,7 +375,7 @@ const voiceAgent = new Agent({
|
|
|
375
375
|
id: 'voice-agent',
|
|
376
376
|
name: 'Voice Agent',
|
|
377
377
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
378
|
-
model: 'openai/gpt-5.
|
|
378
|
+
model: 'openai/gpt-5.5',
|
|
379
379
|
voice: new AzureVoice(),
|
|
380
380
|
})
|
|
381
381
|
|
|
@@ -403,7 +403,7 @@ const voiceAgent = new Agent({
|
|
|
403
403
|
id: 'voice-agent',
|
|
404
404
|
name: 'Voice Agent',
|
|
405
405
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
406
|
-
model: 'openai/gpt-5.
|
|
406
|
+
model: 'openai/gpt-5.5',
|
|
407
407
|
voice: new ElevenLabsVoice(),
|
|
408
408
|
})
|
|
409
409
|
|
|
@@ -431,7 +431,7 @@ const voiceAgent = new Agent({
|
|
|
431
431
|
id: 'voice-agent',
|
|
432
432
|
name: 'Voice Agent',
|
|
433
433
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
434
|
-
model: 'openai/gpt-5.
|
|
434
|
+
model: 'openai/gpt-5.5',
|
|
435
435
|
voice: new GoogleVoice(),
|
|
436
436
|
})
|
|
437
437
|
|
|
@@ -459,7 +459,7 @@ const voiceAgent = new Agent({
|
|
|
459
459
|
id: 'voice-agent',
|
|
460
460
|
name: 'Voice Agent',
|
|
461
461
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
462
|
-
model: 'openai/gpt-5.
|
|
462
|
+
model: 'openai/gpt-5.5',
|
|
463
463
|
voice: new CloudflareVoice(),
|
|
464
464
|
})
|
|
465
465
|
|
|
@@ -487,7 +487,7 @@ const voiceAgent = new Agent({
|
|
|
487
487
|
id: 'voice-agent',
|
|
488
488
|
name: 'Voice Agent',
|
|
489
489
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
490
|
-
model: 'openai/gpt-5.
|
|
490
|
+
model: 'openai/gpt-5.5',
|
|
491
491
|
voice: new DeepgramVoice(),
|
|
492
492
|
})
|
|
493
493
|
|
|
@@ -515,7 +515,7 @@ const voiceAgent = new Agent({
|
|
|
515
515
|
id: 'voice-agent',
|
|
516
516
|
name: 'Voice Agent',
|
|
517
517
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
518
|
-
model: 'openai/gpt-5.
|
|
518
|
+
model: 'openai/gpt-5.5',
|
|
519
519
|
voice: new InworldVoice(),
|
|
520
520
|
})
|
|
521
521
|
|
|
@@ -543,7 +543,7 @@ const voiceAgent = new Agent({
|
|
|
543
543
|
id: 'voice-agent',
|
|
544
544
|
name: 'Voice Agent',
|
|
545
545
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
546
|
-
model: 'openai/gpt-5.
|
|
546
|
+
model: 'openai/gpt-5.5',
|
|
547
547
|
voice: new SarvamVoice(),
|
|
548
548
|
})
|
|
549
549
|
|
|
@@ -575,7 +575,7 @@ const voiceAgent = new Agent({
|
|
|
575
575
|
id: 'voice-agent',
|
|
576
576
|
name: 'Voice Agent',
|
|
577
577
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
578
|
-
model: 'openai/gpt-5.
|
|
578
|
+
model: 'openai/gpt-5.5',
|
|
579
579
|
voice: new OpenAIRealtimeVoice(),
|
|
580
580
|
})
|
|
581
581
|
|
|
@@ -605,7 +605,7 @@ const voiceAgent = new Agent({
|
|
|
605
605
|
id: 'voice-agent',
|
|
606
606
|
name: 'Voice Agent',
|
|
607
607
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
608
|
-
model: 'openai/gpt-5.
|
|
608
|
+
model: 'openai/gpt-5.5',
|
|
609
609
|
voice: new GeminiLiveVoice({
|
|
610
610
|
// Live API mode
|
|
611
611
|
apiKey: process.env.GOOGLE_API_KEY,
|
|
@@ -654,7 +654,7 @@ const voiceAgent = new Agent({
|
|
|
654
654
|
id: 'voice-agent',
|
|
655
655
|
name: 'Voice Agent',
|
|
656
656
|
instructions: 'You are a voice assistant that can help users with their tasks.',
|
|
657
|
-
model: 'openai/gpt-5.
|
|
657
|
+
model: 'openai/gpt-5.5',
|
|
658
658
|
voice: new NovaSonicVoice({
|
|
659
659
|
region: 'us-east-1',
|
|
660
660
|
speaker: 'matthew',
|
|
@@ -686,6 +686,48 @@ await voiceAgent.voice.send(micStream)
|
|
|
686
686
|
|
|
687
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
688
|
|
|
689
|
+
**Inworld Realtime**:
|
|
690
|
+
|
|
691
|
+
```typescript
|
|
692
|
+
import { Agent } from '@mastra/core/agent'
|
|
693
|
+
import { playAudio, getMicrophoneStream } from '@mastra/node-audio'
|
|
694
|
+
import { InworldRealtimeVoice } from '@mastra/voice-inworld'
|
|
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: 'openai/gpt-5.5',
|
|
701
|
+
voice: new InworldRealtimeVoice({
|
|
702
|
+
apiKey: process.env.INWORLD_API_KEY,
|
|
703
|
+
model: 'inworld/models/gemma-4-26b-a4b-it',
|
|
704
|
+
speaker: 'Sarah',
|
|
705
|
+
}),
|
|
706
|
+
})
|
|
707
|
+
|
|
708
|
+
// Connect before using speak/send
|
|
709
|
+
await voiceAgent.voice.connect()
|
|
710
|
+
|
|
711
|
+
// Listen for agent audio (PCM stream)
|
|
712
|
+
voiceAgent.voice.on('speaker', stream => {
|
|
713
|
+
playAudio(stream)
|
|
714
|
+
})
|
|
715
|
+
|
|
716
|
+
// Listen for text responses and transcriptions
|
|
717
|
+
voiceAgent.voice.on('writing', ({ text, role }) => {
|
|
718
|
+
console.log(`${role}: ${text}`)
|
|
719
|
+
})
|
|
720
|
+
|
|
721
|
+
// Initiate the conversation
|
|
722
|
+
await voiceAgent.voice.speak('How can I help you today?')
|
|
723
|
+
|
|
724
|
+
// Send continuous audio from the microphone
|
|
725
|
+
const micStream = getMicrophoneStream()
|
|
726
|
+
await voiceAgent.voice.send(micStream)
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
Visit the [Inworld Realtime Reference](https://mastra.ai/reference/voice/inworld-realtime) for more information on the Inworld Realtime voice provider.
|
|
730
|
+
|
|
689
731
|
**xAI**:
|
|
690
732
|
|
|
691
733
|
```typescript
|
|
@@ -1051,6 +1093,26 @@ const voice = new NovaSonicVoice({
|
|
|
1051
1093
|
|
|
1052
1094
|
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
1095
|
|
|
1096
|
+
**Inworld Realtime**:
|
|
1097
|
+
|
|
1098
|
+
```typescript
|
|
1099
|
+
// Inworld Realtime Voice Configuration
|
|
1100
|
+
const voice = new InworldRealtimeVoice({
|
|
1101
|
+
apiKey: process.env.INWORLD_API_KEY,
|
|
1102
|
+
model: 'inworld/models/gemma-4-26b-a4b-it',
|
|
1103
|
+
speaker: 'Sarah',
|
|
1104
|
+
// Typed Inworld realtime knobs (semantic VAD, playback speed, MCP tool routing, ...)
|
|
1105
|
+
session: {
|
|
1106
|
+
audio: {
|
|
1107
|
+
output: { speed: 1.1 },
|
|
1108
|
+
input: { turn_detection: { type: 'semantic_vad', eagerness: 'high' } },
|
|
1109
|
+
},
|
|
1110
|
+
},
|
|
1111
|
+
})
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
Visit the [Inworld Realtime Reference](https://mastra.ai/reference/voice/inworld-realtime) for more information on the Inworld Realtime voice provider.
|
|
1115
|
+
|
|
1054
1116
|
**AI SDK**:
|
|
1055
1117
|
|
|
1056
1118
|
```typescript
|
|
@@ -1070,7 +1132,7 @@ const voiceAgent = new Agent({
|
|
|
1070
1132
|
id: 'aisdk-voice-agent',
|
|
1071
1133
|
name: 'AI SDK Voice Agent',
|
|
1072
1134
|
instructions: 'You are a helpful assistant with voice capabilities.',
|
|
1073
|
-
model: 'openai/gpt-5.
|
|
1135
|
+
model: 'openai/gpt-5.5',
|
|
1074
1136
|
voice,
|
|
1075
1137
|
})
|
|
1076
1138
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var textToSpeech = require('@google-cloud/text-to-speech');
|
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
|
|
9
|
-
// ../../packages/_internal-core/dist/chunk-
|
|
9
|
+
// ../../packages/_internal-core/dist/chunk-3M4SEWMI.js
|
|
10
10
|
var RegisteredLogger = {
|
|
11
11
|
LLM: "LLM"};
|
|
12
12
|
var LogLevel = {
|
|
@@ -103,7 +103,7 @@ var ConsoleLogger = class _ConsoleLogger extends MastraLogger {
|
|
|
103
103
|
}
|
|
104
104
|
warn(message, ...args) {
|
|
105
105
|
if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) {
|
|
106
|
-
console.
|
|
106
|
+
console.warn(`${this.prefix()}${message}`, ...args);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
error(message, ...args) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":["TextToSpeechClient","SpeechClient","stream","PassThrough"],"mappings":";;;;;;;;;AAEO,IAAM,gBAAA,GAAmB;EAO9B,GAAA,EAAK,KAcP,CAAA;AAIO,IAAM,QAAA,GAAW;EACtB,KAAA,EAAO,OAAA;EACP,IAAA,EAAM,MAAA;EACN,IAAA,EAAM,MAAA;EACN,KAAA,EAAO,OAET,CAAA;AAsGO,IAAe,eAAf,MAAqD;AAChD,EAAA,IAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;EAEV,WAAA,CACE,OAAA,GAII,EAAA,EACJ;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,QAAQ,IAAA,IAAQ,QAAA;AAC5B,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,CAAQ,KAAA,IAAS,QAAA,CAAS,KAAA;AACvC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,GAAA,CAAI,MAAA,CAAO,QAAQ,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAC,CAAA;AACpE,EAAA;EAOA,aAAA,GAAgB;AACd,IAAA,OAAO,IAAA,CAAK,UAAA;AACd,EAAA;AAEA,EAAA,cAAA,CAAe,QAAe,S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E,UAAA,IAAc,EAAA;AAAA,IAC9C,CAAC,CAAA,CACA,MAAA,CAAO,CAAC,IAAA,KAAiB,KAAK,MAAA,GAAS,CAAC,CAAA,CACxC,IAAA,CAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,IAC3D;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;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 { PassThrough } from 'node:stream';\n\nimport { SpeechClient } from '@google-cloud/speech';\nimport type { google as SpeechTypes } from '@google-cloud/speech/build/protos/protos';\nimport { TextToSpeechClient } from '@google-cloud/text-to-speech';\nimport type { google as TextToSpeechTypes } from '@google-cloud/text-to-speech/build/protos/protos';\nimport { MastraVoice } from '@internal/voice';\n\n/**\n * Configuration for Google Cloud Voice models\n * @interface GoogleModelConfig\n * @property {string} [apiKey] - Optional Google Cloud API key. If not provided, will use GOOGLE_API_KEY environment variable\n * @property {string} [keyFilename] - Optional path to a service account key file. If not provided, will use GOOGLE_APPLICATION_CREDENTIALS environment variable\n * @property {{ client_email?: string; private_key?: string }} [credentials] - Optional in-memory service account credentials\n */\nexport interface GoogleModelConfig {\n apiKey?: string;\n keyFilename?: string;\n credentials?: {\n client_email?: string;\n private_key?: string;\n [key: string]: unknown;\n };\n}\n\n/**\n * Configuration options for GoogleVoice\n * @interface GoogleVoiceConfig\n */\nexport interface GoogleVoiceConfig {\n /** Configuration for speech synthesis (TTS) */\n speechModel?: GoogleModelConfig;\n /** Configuration for speech recognition (STT) */\n listeningModel?: GoogleModelConfig;\n /** Default voice ID to use for speech synthesis */\n speaker?: string;\n /**\n * Enable Vertex AI mode for enterprise deployments.\n * When true, uses Google Cloud project-based authentication instead of API keys.\n * Requires `project` to be set or GOOGLE_CLOUD_PROJECT environment variable.\n */\n vertexAI?: boolean;\n /**\n * Google Cloud project ID (required when vertexAI is true).\n * Falls back to GOOGLE_CLOUD_PROJECT environment variable.\n */\n project?: string;\n /**\n * Google Cloud region for Vertex AI endpoints.\n * Falls back to GOOGLE_CLOUD_LOCATION environment variable.\n * @default 'us-central1'\n */\n location?: string;\n}\n\ntype AuthConfig = Pick<GoogleModelConfig, 'apiKey' | 'keyFilename' | 'credentials'> & {\n projectId?: string;\n};\n\ntype GoogleClientOptions = AuthConfig;\n\nconst resolveAuthConfig = (\n modelConfig: GoogleModelConfig | undefined,\n fallback: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; project?: string },\n): AuthConfig => {\n const resolved: AuthConfig = {};\n\n // For Vertex AI, prioritize project-based auth over API keys\n if (vertexConfig?.vertexAI) {\n const projectId = vertexConfig.project || process.env.GOOGLE_CLOUD_PROJECT;\n if (projectId) {\n resolved.projectId = projectId;\n }\n }\n\n const apiKey = modelConfig?.apiKey ?? fallback.apiKey;\n // Only use API key if not in Vertex AI mode\n if (apiKey && !vertexConfig?.vertexAI) {\n resolved.apiKey = apiKey;\n }\n\n const keyFilename = modelConfig?.keyFilename ?? fallback.keyFilename;\n if (keyFilename) {\n resolved.keyFilename = keyFilename;\n }\n\n const credentials = modelConfig?.credentials ?? fallback.credentials;\n if (credentials) {\n resolved.credentials = credentials;\n }\n\n return resolved;\n};\n\nconst buildAuthOptions = (\n config: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; location?: string },\n): GoogleClientOptions => {\n const options: GoogleClientOptions = {};\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n if (config.keyFilename) {\n options.keyFilename = config.keyFilename;\n }\n\n // Only use API key if not using Vertex AI\n if (config.apiKey && !vertexConfig?.vertexAI) {\n options.apiKey = config.apiKey;\n }\n\n // For Vertex AI, set the project ID\n if (config.projectId) {\n options.projectId = config.projectId;\n }\n\n return options;\n};\n\nconst DEFAULT_VOICE = 'en-US-Casual-K';\n\n/**\n * GoogleVoice class provides Text-to-Speech and Speech-to-Text capabilities using Google Cloud services.\n * Supports both standard Google Cloud API authentication and Vertex AI mode for enterprise deployments.\n *\n * @class GoogleVoice\n * @extends MastraVoice\n *\n * @example Standard usage with API key\n * ```typescript\n * const voice = new GoogleVoice({\n * speechModel: { apiKey: 'your-api-key' },\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI mode (recommended for production)\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * location: 'us-central1',\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI with service account\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * speechModel: {\n * keyFilename: '/path/to/service-account.json',\n * },\n * });\n * ```\n */\nexport class GoogleVoice extends MastraVoice {\n private ttsClient: TextToSpeechClient;\n private speechClient: SpeechClient;\n private readonly vertexAI: boolean;\n private readonly project?: string;\n private readonly location: string;\n\n /**\n * Creates an instance of GoogleVoice\n * @param {GoogleVoiceConfig} config - Configuration options\n * @param {GoogleModelConfig} [config.speechModel] - Configuration for speech synthesis\n * @param {GoogleModelConfig} [config.listeningModel] - Configuration for speech recognition\n * @param {string} [config.speaker] - Default voice ID to use for speech synthesis\n * @param {boolean} [config.vertexAI] - Enable Vertex AI mode\n * @param {string} [config.project] - Google Cloud project ID (required for Vertex AI)\n * @param {string} [config.location] - Google Cloud region (default: 'us-central1')\n */\n constructor({ listeningModel, speechModel, speaker, vertexAI = false, project, location }: GoogleVoiceConfig = {}) {\n const defaultApiKey = process.env.GOOGLE_API_KEY;\n const defaultKeyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n const defaultSpeaker = DEFAULT_VOICE;\n\n // Resolve Vertex AI configuration\n const resolvedProject = project || process.env.GOOGLE_CLOUD_PROJECT;\n const resolvedLocation = location || process.env.GOOGLE_CLOUD_LOCATION || 'us-central1';\n\n // Validate Vertex AI configuration\n if (vertexAI && !resolvedProject) {\n throw new Error(\n 'Google Cloud project ID is required when using Vertex AI. ' +\n 'Set GOOGLE_CLOUD_PROJECT environment variable or pass project to constructor.',\n );\n }\n\n const vertexConfig = { vertexAI, project: resolvedProject };\n\n const sharedFallback: AuthConfig = {\n apiKey: defaultApiKey ?? speechModel?.apiKey ?? listeningModel?.apiKey,\n keyFilename: defaultKeyFilename ?? speechModel?.keyFilename ?? listeningModel?.keyFilename,\n credentials: speechModel?.credentials ?? listeningModel?.credentials,\n projectId: resolvedProject,\n };\n\n const speechAuthConfig = resolveAuthConfig(speechModel, sharedFallback, vertexConfig);\n const listeningAuthConfig = resolveAuthConfig(listeningModel, sharedFallback, vertexConfig);\n\n super({\n speechModel: {\n name: '',\n apiKey: speechAuthConfig.apiKey ?? defaultApiKey,\n },\n listeningModel: {\n name: '',\n apiKey: listeningAuthConfig.apiKey ?? defaultApiKey,\n },\n speaker: speaker ?? defaultSpeaker,\n });\n\n this.vertexAI = vertexAI;\n this.project = resolvedProject;\n this.location = resolvedLocation;\n\n const ttsOptions = buildAuthOptions(speechAuthConfig, { vertexAI, location: resolvedLocation });\n const speechOptions = buildAuthOptions(listeningAuthConfig, { vertexAI, location: resolvedLocation });\n\n this.ttsClient = new TextToSpeechClient(ttsOptions);\n this.speechClient = new SpeechClient(speechOptions);\n }\n\n /**\n * Check if Vertex AI mode is enabled\n * @returns {boolean} True if using Vertex AI\n */\n isUsingVertexAI(): boolean {\n return this.vertexAI;\n }\n\n /**\n * Get the configured Google Cloud project ID\n * @returns {string | undefined} The project ID or undefined if not set\n */\n getProject(): string | undefined {\n return this.project;\n }\n\n /**\n * Get the configured Google Cloud location/region\n * @returns {string} The location (default: 'us-central1')\n */\n getLocation(): string {\n return this.location;\n }\n\n /**\n * Gets a list of available voices\n * @returns {Promise<Array<{voiceId: string, languageCodes: string[]}>>} List of available voices and their supported languages. Default language is en-US.\n */\n async getSpeakers({ languageCode = 'en-US' }: { languageCode?: string } = {}) {\n const [response] = await this.ttsClient.listVoices({ languageCode: languageCode });\n return (response?.voices || [])\n .filter(voice => voice.name && voice.languageCodes)\n .map(voice => ({\n voiceId: voice.name!,\n languageCodes: voice.languageCodes!,\n }));\n }\n\n private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n return Buffer.concat(chunks).toString('utf-8');\n }\n\n /**\n * Converts text to speech\n * @param {string | NodeJS.ReadableStream} input - Text or stream to convert to speech\n * @param {Object} [options] - Speech synthesis options\n * @param {string} [options.speaker] - Voice ID to use\n * @param {string} [options.languageCode] - Language code for the voice\n * @param {TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig']} [options.audioConfig] - Audio configuration options\n * @returns {Promise<NodeJS.ReadableStream>} Stream of synthesized audio. Default encoding is LINEAR16.\n */\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n languageCode?: string;\n audioConfig?: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig'];\n },\n ): Promise<NodeJS.ReadableStream> {\n const text = typeof input === 'string' ? input : await this.streamToString(input);\n\n const request: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest = {\n input: { text },\n voice: {\n name: options?.speaker || this.speaker,\n languageCode: options?.languageCode || options?.speaker?.split('-').slice(0, 2).join('-') || 'en-US',\n },\n audioConfig: options?.audioConfig || { audioEncoding: 'LINEAR16' },\n };\n\n const [response] = await this.ttsClient.synthesizeSpeech(request);\n\n if (!response.audioContent) {\n throw new Error('No audio content returned.');\n }\n\n if (typeof response.audioContent === 'string') {\n throw new Error('Audio content is a string.');\n }\n\n const stream = new PassThrough();\n stream.end(Buffer.from(response.audioContent));\n return stream;\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 /**\n * Converts speech to text\n * @param {NodeJS.ReadableStream} audioStream - Audio stream to transcribe. Default encoding is LINEAR16.\n * @param {Object} [options] - Recognition options\n * @param {SpeechTypes.cloud.speech.v1.IRecognitionConfig} [options.config] - Recognition configuration\n * @returns {Promise<string>} Transcribed text\n */\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: { stream?: boolean; config?: SpeechTypes.cloud.speech.v1.IRecognitionConfig },\n ): Promise<string> {\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 buffer = Buffer.concat(chunks);\n\n let request = {\n config: {\n encoding: 'LINEAR16',\n languageCode: 'en-US',\n ...options?.config,\n },\n audio: {\n content: buffer.toString('base64'),\n },\n };\n const [response] = await this.speechClient.recognize(request as SpeechTypes.cloud.speech.v1.IRecognizeRequest);\n\n if (!response.results || response.results.length === 0) {\n throw new Error('No transcription results returned');\n }\n\n const transcription = response.results\n .map((result: any) => {\n if (!result.alternatives || result.alternatives.length === 0) {\n return '';\n }\n return result.alternatives[0].transcript || '';\n })\n .filter((text: string) => text.length > 0)\n .join(' ');\n\n if (!transcription) {\n throw new Error('No valid transcription found in results');\n }\n\n return transcription;\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":["TextToSpeechClient","SpeechClient","stream","PassThrough"],"mappings":";;;;;;;;;AAEO,IAAM,gBAAA,GAAmB;EAO9B,GAAA,EAAK,KAcP,CAAA;AAIO,IAAM,QAAA,GAAW;EACtB,KAAA,EAAO,OAAA;EACP,IAAA,EAAM,MAAA;EACN,IAAA,EAAM,MAAA;EACN,KAAA,EAAO,OAET,CAAA;AAsGO,IAAe,eAAf,MAAqD;AAChD,EAAA,IAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;EAEV,WAAA,CACE,OAAA,GAII,EAAA,EACJ;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,QAAQ,IAAA,IAAQ,QAAA;AAC5B,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,CAAQ,KAAA,IAAS,QAAA,CAAS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AS,OAAA,CAC5B,GAAA,CAAI,CAAC,MAAA,KAAgB;AACpB,MAAA,IAAI,CAAC,MAAA,CAAO,YAAA,IAAgB,MAAA,CAAO,YAAA,CAAa,WAAW,CAAA,EAAG;AAC5D,QAAA,OAAO,EAAA;AAAA,MACT;AACA,MAAA,OAAO,MAAA,CAAO,YAAA,CAAa,CAAC,CAAA,CAAE,UAAA,IAAc,EAAA;AAAA,IAC9C,CAAC,CAAA,CACA,MAAA,CAAO,CAAC,IAAA,KAAiB,KAAK,MAAA,GAAS,CAAC,CAAA,CACxC,IAAA,CAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,IAC3D;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;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.warn(`${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 { PassThrough } from 'node:stream';\n\nimport { SpeechClient } from '@google-cloud/speech';\nimport type { google as SpeechTypes } from '@google-cloud/speech/build/protos/protos';\nimport { TextToSpeechClient } from '@google-cloud/text-to-speech';\nimport type { google as TextToSpeechTypes } from '@google-cloud/text-to-speech/build/protos/protos';\nimport { MastraVoice } from '@internal/voice';\n\n/**\n * Configuration for Google Cloud Voice models\n * @interface GoogleModelConfig\n * @property {string} [apiKey] - Optional Google Cloud API key. If not provided, will use GOOGLE_API_KEY environment variable\n * @property {string} [keyFilename] - Optional path to a service account key file. If not provided, will use GOOGLE_APPLICATION_CREDENTIALS environment variable\n * @property {{ client_email?: string; private_key?: string }} [credentials] - Optional in-memory service account credentials\n */\nexport interface GoogleModelConfig {\n apiKey?: string;\n keyFilename?: string;\n credentials?: {\n client_email?: string;\n private_key?: string;\n [key: string]: unknown;\n };\n}\n\n/**\n * Configuration options for GoogleVoice\n * @interface GoogleVoiceConfig\n */\nexport interface GoogleVoiceConfig {\n /** Configuration for speech synthesis (TTS) */\n speechModel?: GoogleModelConfig;\n /** Configuration for speech recognition (STT) */\n listeningModel?: GoogleModelConfig;\n /** Default voice ID to use for speech synthesis */\n speaker?: string;\n /**\n * Enable Vertex AI mode for enterprise deployments.\n * When true, uses Google Cloud project-based authentication instead of API keys.\n * Requires `project` to be set or GOOGLE_CLOUD_PROJECT environment variable.\n */\n vertexAI?: boolean;\n /**\n * Google Cloud project ID (required when vertexAI is true).\n * Falls back to GOOGLE_CLOUD_PROJECT environment variable.\n */\n project?: string;\n /**\n * Google Cloud region for Vertex AI endpoints.\n * Falls back to GOOGLE_CLOUD_LOCATION environment variable.\n * @default 'us-central1'\n */\n location?: string;\n}\n\ntype AuthConfig = Pick<GoogleModelConfig, 'apiKey' | 'keyFilename' | 'credentials'> & {\n projectId?: string;\n};\n\ntype GoogleClientOptions = AuthConfig;\n\nconst resolveAuthConfig = (\n modelConfig: GoogleModelConfig | undefined,\n fallback: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; project?: string },\n): AuthConfig => {\n const resolved: AuthConfig = {};\n\n // For Vertex AI, prioritize project-based auth over API keys\n if (vertexConfig?.vertexAI) {\n const projectId = vertexConfig.project || process.env.GOOGLE_CLOUD_PROJECT;\n if (projectId) {\n resolved.projectId = projectId;\n }\n }\n\n const apiKey = modelConfig?.apiKey ?? fallback.apiKey;\n // Only use API key if not in Vertex AI mode\n if (apiKey && !vertexConfig?.vertexAI) {\n resolved.apiKey = apiKey;\n }\n\n const keyFilename = modelConfig?.keyFilename ?? fallback.keyFilename;\n if (keyFilename) {\n resolved.keyFilename = keyFilename;\n }\n\n const credentials = modelConfig?.credentials ?? fallback.credentials;\n if (credentials) {\n resolved.credentials = credentials;\n }\n\n return resolved;\n};\n\nconst buildAuthOptions = (\n config: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; location?: string },\n): GoogleClientOptions => {\n const options: GoogleClientOptions = {};\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n if (config.keyFilename) {\n options.keyFilename = config.keyFilename;\n }\n\n // Only use API key if not using Vertex AI\n if (config.apiKey && !vertexConfig?.vertexAI) {\n options.apiKey = config.apiKey;\n }\n\n // For Vertex AI, set the project ID\n if (config.projectId) {\n options.projectId = config.projectId;\n }\n\n return options;\n};\n\nconst DEFAULT_VOICE = 'en-US-Casual-K';\n\n/**\n * GoogleVoice class provides Text-to-Speech and Speech-to-Text capabilities using Google Cloud services.\n * Supports both standard Google Cloud API authentication and Vertex AI mode for enterprise deployments.\n *\n * @class GoogleVoice\n * @extends MastraVoice\n *\n * @example Standard usage with API key\n * ```typescript\n * const voice = new GoogleVoice({\n * speechModel: { apiKey: 'your-api-key' },\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI mode (recommended for production)\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * location: 'us-central1',\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI with service account\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * speechModel: {\n * keyFilename: '/path/to/service-account.json',\n * },\n * });\n * ```\n */\nexport class GoogleVoice extends MastraVoice {\n private ttsClient: TextToSpeechClient;\n private speechClient: SpeechClient;\n private readonly vertexAI: boolean;\n private readonly project?: string;\n private readonly location: string;\n\n /**\n * Creates an instance of GoogleVoice\n * @param {GoogleVoiceConfig} config - Configuration options\n * @param {GoogleModelConfig} [config.speechModel] - Configuration for speech synthesis\n * @param {GoogleModelConfig} [config.listeningModel] - Configuration for speech recognition\n * @param {string} [config.speaker] - Default voice ID to use for speech synthesis\n * @param {boolean} [config.vertexAI] - Enable Vertex AI mode\n * @param {string} [config.project] - Google Cloud project ID (required for Vertex AI)\n * @param {string} [config.location] - Google Cloud region (default: 'us-central1')\n */\n constructor({ listeningModel, speechModel, speaker, vertexAI = false, project, location }: GoogleVoiceConfig = {}) {\n const defaultApiKey = process.env.GOOGLE_API_KEY;\n const defaultKeyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n const defaultSpeaker = DEFAULT_VOICE;\n\n // Resolve Vertex AI configuration\n const resolvedProject = project || process.env.GOOGLE_CLOUD_PROJECT;\n const resolvedLocation = location || process.env.GOOGLE_CLOUD_LOCATION || 'us-central1';\n\n // Validate Vertex AI configuration\n if (vertexAI && !resolvedProject) {\n throw new Error(\n 'Google Cloud project ID is required when using Vertex AI. ' +\n 'Set GOOGLE_CLOUD_PROJECT environment variable or pass project to constructor.',\n );\n }\n\n const vertexConfig = { vertexAI, project: resolvedProject };\n\n const sharedFallback: AuthConfig = {\n apiKey: defaultApiKey ?? speechModel?.apiKey ?? listeningModel?.apiKey,\n keyFilename: defaultKeyFilename ?? speechModel?.keyFilename ?? listeningModel?.keyFilename,\n credentials: speechModel?.credentials ?? listeningModel?.credentials,\n projectId: resolvedProject,\n };\n\n const speechAuthConfig = resolveAuthConfig(speechModel, sharedFallback, vertexConfig);\n const listeningAuthConfig = resolveAuthConfig(listeningModel, sharedFallback, vertexConfig);\n\n super({\n speechModel: {\n name: '',\n apiKey: speechAuthConfig.apiKey ?? defaultApiKey,\n },\n listeningModel: {\n name: '',\n apiKey: listeningAuthConfig.apiKey ?? defaultApiKey,\n },\n speaker: speaker ?? defaultSpeaker,\n });\n\n this.vertexAI = vertexAI;\n this.project = resolvedProject;\n this.location = resolvedLocation;\n\n const ttsOptions = buildAuthOptions(speechAuthConfig, { vertexAI, location: resolvedLocation });\n const speechOptions = buildAuthOptions(listeningAuthConfig, { vertexAI, location: resolvedLocation });\n\n this.ttsClient = new TextToSpeechClient(ttsOptions);\n this.speechClient = new SpeechClient(speechOptions);\n }\n\n /**\n * Check if Vertex AI mode is enabled\n * @returns {boolean} True if using Vertex AI\n */\n isUsingVertexAI(): boolean {\n return this.vertexAI;\n }\n\n /**\n * Get the configured Google Cloud project ID\n * @returns {string | undefined} The project ID or undefined if not set\n */\n getProject(): string | undefined {\n return this.project;\n }\n\n /**\n * Get the configured Google Cloud location/region\n * @returns {string} The location (default: 'us-central1')\n */\n getLocation(): string {\n return this.location;\n }\n\n /**\n * Gets a list of available voices\n * @returns {Promise<Array<{voiceId: string, languageCodes: string[]}>>} List of available voices and their supported languages. Default language is en-US.\n */\n async getSpeakers({ languageCode = 'en-US' }: { languageCode?: string } = {}) {\n const [response] = await this.ttsClient.listVoices({ languageCode: languageCode });\n return (response?.voices || [])\n .filter(voice => voice.name && voice.languageCodes)\n .map(voice => ({\n voiceId: voice.name!,\n languageCodes: voice.languageCodes!,\n }));\n }\n\n private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n return Buffer.concat(chunks).toString('utf-8');\n }\n\n /**\n * Converts text to speech\n * @param {string | NodeJS.ReadableStream} input - Text or stream to convert to speech\n * @param {Object} [options] - Speech synthesis options\n * @param {string} [options.speaker] - Voice ID to use\n * @param {string} [options.languageCode] - Language code for the voice\n * @param {TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig']} [options.audioConfig] - Audio configuration options\n * @returns {Promise<NodeJS.ReadableStream>} Stream of synthesized audio. Default encoding is LINEAR16.\n */\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n languageCode?: string;\n audioConfig?: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig'];\n },\n ): Promise<NodeJS.ReadableStream> {\n const text = typeof input === 'string' ? input : await this.streamToString(input);\n\n const request: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest = {\n input: { text },\n voice: {\n name: options?.speaker || this.speaker,\n languageCode: options?.languageCode || options?.speaker?.split('-').slice(0, 2).join('-') || 'en-US',\n },\n audioConfig: options?.audioConfig || { audioEncoding: 'LINEAR16' },\n };\n\n const [response] = await this.ttsClient.synthesizeSpeech(request);\n\n if (!response.audioContent) {\n throw new Error('No audio content returned.');\n }\n\n if (typeof response.audioContent === 'string') {\n throw new Error('Audio content is a string.');\n }\n\n const stream = new PassThrough();\n stream.end(Buffer.from(response.audioContent));\n return stream;\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 /**\n * Converts speech to text\n * @param {NodeJS.ReadableStream} audioStream - Audio stream to transcribe. Default encoding is LINEAR16.\n * @param {Object} [options] - Recognition options\n * @param {SpeechTypes.cloud.speech.v1.IRecognitionConfig} [options.config] - Recognition configuration\n * @returns {Promise<string>} Transcribed text\n */\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: { stream?: boolean; config?: SpeechTypes.cloud.speech.v1.IRecognitionConfig },\n ): Promise<string> {\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 buffer = Buffer.concat(chunks);\n\n let request = {\n config: {\n encoding: 'LINEAR16',\n languageCode: 'en-US',\n ...options?.config,\n },\n audio: {\n content: buffer.toString('base64'),\n },\n };\n const [response] = await this.speechClient.recognize(request as SpeechTypes.cloud.speech.v1.IRecognizeRequest);\n\n if (!response.results || response.results.length === 0) {\n throw new Error('No transcription results returned');\n }\n\n const transcription = response.results\n .map((result: any) => {\n if (!result.alternatives || result.alternatives.length === 0) {\n return '';\n }\n return result.alternatives[0].transcript || '';\n })\n .filter((text: string) => text.length > 0)\n .join(' ');\n\n if (!transcription) {\n throw new Error('No valid transcription found in results');\n }\n\n return transcription;\n }\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { TextToSpeechClient } from '@google-cloud/text-to-speech';
|
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
|
|
7
|
-
// ../../packages/_internal-core/dist/chunk-
|
|
7
|
+
// ../../packages/_internal-core/dist/chunk-3M4SEWMI.js
|
|
8
8
|
var RegisteredLogger = {
|
|
9
9
|
LLM: "LLM"};
|
|
10
10
|
var LogLevel = {
|
|
@@ -101,7 +101,7 @@ var ConsoleLogger = class _ConsoleLogger extends MastraLogger {
|
|
|
101
101
|
}
|
|
102
102
|
warn(message, ...args) {
|
|
103
103
|
if ((this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) && this.shouldLog(LogLevel.WARN, message, args)) {
|
|
104
|
-
console.
|
|
104
|
+
console.warn(`${this.prefix()}${message}`, ...args);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
error(message, ...args) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":[],"mappings":";;;;;;;AAEO,IAAM,gBAAA,GAAmB;EAO9B,GAAA,EAAK,KAcP,CAAA;AAIO,IAAM,QAAA,GAAW;EACtB,KAAA,EAAO,OAAA;EACP,IAAA,EAAM,MAAA;EACN,IAAA,EAAM,MAAA;EACN,KAAA,EAAO,OAET,CAAA;AAsGO,IAAe,eAAf,MAAqD;AAChD,EAAA,IAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;EAEV,WAAA,CACE,OAAA,GAII,EAAA,EACJ;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,QAAQ,IAAA,IAAQ,QAAA;AAC5B,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,CAAQ,KAAA,IAAS,QAAA,CAAS,KAAA;AACvC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,GAAA,CAAI,MAAA,CAAO,QAAQ,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAC,CAAA;AACpE,EAAA;EAOA,aAAA,GAAgB;AACd,IAAA,OAAO,IAAA,CAAK,UAAA;AACd,EAAA;AAEA,EAAA,cAAA,CAAe,QAAe,SAAA,EAAqC;AAAC,EAAA;EAEpE,MAAM,QAAA,CACJ,aACA,MAAA,EAQA;AACA,IAAA,IAAI,CAAC,WAAA,IAAe,CAAC,KAAK,UAAA,CAAW,GAAA,CAAI,WAAW,CAAA,EAAG;AACrD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A,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,IAC3D;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;AACF","file":"index.js","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 { PassThrough } from 'node:stream';\n\nimport { SpeechClient } from '@google-cloud/speech';\nimport type { google as SpeechTypes } from '@google-cloud/speech/build/protos/protos';\nimport { TextToSpeechClient } from '@google-cloud/text-to-speech';\nimport type { google as TextToSpeechTypes } from '@google-cloud/text-to-speech/build/protos/protos';\nimport { MastraVoice } from '@internal/voice';\n\n/**\n * Configuration for Google Cloud Voice models\n * @interface GoogleModelConfig\n * @property {string} [apiKey] - Optional Google Cloud API key. If not provided, will use GOOGLE_API_KEY environment variable\n * @property {string} [keyFilename] - Optional path to a service account key file. If not provided, will use GOOGLE_APPLICATION_CREDENTIALS environment variable\n * @property {{ client_email?: string; private_key?: string }} [credentials] - Optional in-memory service account credentials\n */\nexport interface GoogleModelConfig {\n apiKey?: string;\n keyFilename?: string;\n credentials?: {\n client_email?: string;\n private_key?: string;\n [key: string]: unknown;\n };\n}\n\n/**\n * Configuration options for GoogleVoice\n * @interface GoogleVoiceConfig\n */\nexport interface GoogleVoiceConfig {\n /** Configuration for speech synthesis (TTS) */\n speechModel?: GoogleModelConfig;\n /** Configuration for speech recognition (STT) */\n listeningModel?: GoogleModelConfig;\n /** Default voice ID to use for speech synthesis */\n speaker?: string;\n /**\n * Enable Vertex AI mode for enterprise deployments.\n * When true, uses Google Cloud project-based authentication instead of API keys.\n * Requires `project` to be set or GOOGLE_CLOUD_PROJECT environment variable.\n */\n vertexAI?: boolean;\n /**\n * Google Cloud project ID (required when vertexAI is true).\n * Falls back to GOOGLE_CLOUD_PROJECT environment variable.\n */\n project?: string;\n /**\n * Google Cloud region for Vertex AI endpoints.\n * Falls back to GOOGLE_CLOUD_LOCATION environment variable.\n * @default 'us-central1'\n */\n location?: string;\n}\n\ntype AuthConfig = Pick<GoogleModelConfig, 'apiKey' | 'keyFilename' | 'credentials'> & {\n projectId?: string;\n};\n\ntype GoogleClientOptions = AuthConfig;\n\nconst resolveAuthConfig = (\n modelConfig: GoogleModelConfig | undefined,\n fallback: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; project?: string },\n): AuthConfig => {\n const resolved: AuthConfig = {};\n\n // For Vertex AI, prioritize project-based auth over API keys\n if (vertexConfig?.vertexAI) {\n const projectId = vertexConfig.project || process.env.GOOGLE_CLOUD_PROJECT;\n if (projectId) {\n resolved.projectId = projectId;\n }\n }\n\n const apiKey = modelConfig?.apiKey ?? fallback.apiKey;\n // Only use API key if not in Vertex AI mode\n if (apiKey && !vertexConfig?.vertexAI) {\n resolved.apiKey = apiKey;\n }\n\n const keyFilename = modelConfig?.keyFilename ?? fallback.keyFilename;\n if (keyFilename) {\n resolved.keyFilename = keyFilename;\n }\n\n const credentials = modelConfig?.credentials ?? fallback.credentials;\n if (credentials) {\n resolved.credentials = credentials;\n }\n\n return resolved;\n};\n\nconst buildAuthOptions = (\n config: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; location?: string },\n): GoogleClientOptions => {\n const options: GoogleClientOptions = {};\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n if (config.keyFilename) {\n options.keyFilename = config.keyFilename;\n }\n\n // Only use API key if not using Vertex AI\n if (config.apiKey && !vertexConfig?.vertexAI) {\n options.apiKey = config.apiKey;\n }\n\n // For Vertex AI, set the project ID\n if (config.projectId) {\n options.projectId = config.projectId;\n }\n\n return options;\n};\n\nconst DEFAULT_VOICE = 'en-US-Casual-K';\n\n/**\n * GoogleVoice class provides Text-to-Speech and Speech-to-Text capabilities using Google Cloud services.\n * Supports both standard Google Cloud API authentication and Vertex AI mode for enterprise deployments.\n *\n * @class GoogleVoice\n * @extends MastraVoice\n *\n * @example Standard usage with API key\n * ```typescript\n * const voice = new GoogleVoice({\n * speechModel: { apiKey: 'your-api-key' },\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI mode (recommended for production)\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * location: 'us-central1',\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI with service account\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * speechModel: {\n * keyFilename: '/path/to/service-account.json',\n * },\n * });\n * ```\n */\nexport class GoogleVoice extends MastraVoice {\n private ttsClient: TextToSpeechClient;\n private speechClient: SpeechClient;\n private readonly vertexAI: boolean;\n private readonly project?: string;\n private readonly location: string;\n\n /**\n * Creates an instance of GoogleVoice\n * @param {GoogleVoiceConfig} config - Configuration options\n * @param {GoogleModelConfig} [config.speechModel] - Configuration for speech synthesis\n * @param {GoogleModelConfig} [config.listeningModel] - Configuration for speech recognition\n * @param {string} [config.speaker] - Default voice ID to use for speech synthesis\n * @param {boolean} [config.vertexAI] - Enable Vertex AI mode\n * @param {string} [config.project] - Google Cloud project ID (required for Vertex AI)\n * @param {string} [config.location] - Google Cloud region (default: 'us-central1')\n */\n constructor({ listeningModel, speechModel, speaker, vertexAI = false, project, location }: GoogleVoiceConfig = {}) {\n const defaultApiKey = process.env.GOOGLE_API_KEY;\n const defaultKeyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n const defaultSpeaker = DEFAULT_VOICE;\n\n // Resolve Vertex AI configuration\n const resolvedProject = project || process.env.GOOGLE_CLOUD_PROJECT;\n const resolvedLocation = location || process.env.GOOGLE_CLOUD_LOCATION || 'us-central1';\n\n // Validate Vertex AI configuration\n if (vertexAI && !resolvedProject) {\n throw new Error(\n 'Google Cloud project ID is required when using Vertex AI. ' +\n 'Set GOOGLE_CLOUD_PROJECT environment variable or pass project to constructor.',\n );\n }\n\n const vertexConfig = { vertexAI, project: resolvedProject };\n\n const sharedFallback: AuthConfig = {\n apiKey: defaultApiKey ?? speechModel?.apiKey ?? listeningModel?.apiKey,\n keyFilename: defaultKeyFilename ?? speechModel?.keyFilename ?? listeningModel?.keyFilename,\n credentials: speechModel?.credentials ?? listeningModel?.credentials,\n projectId: resolvedProject,\n };\n\n const speechAuthConfig = resolveAuthConfig(speechModel, sharedFallback, vertexConfig);\n const listeningAuthConfig = resolveAuthConfig(listeningModel, sharedFallback, vertexConfig);\n\n super({\n speechModel: {\n name: '',\n apiKey: speechAuthConfig.apiKey ?? defaultApiKey,\n },\n listeningModel: {\n name: '',\n apiKey: listeningAuthConfig.apiKey ?? defaultApiKey,\n },\n speaker: speaker ?? defaultSpeaker,\n });\n\n this.vertexAI = vertexAI;\n this.project = resolvedProject;\n this.location = resolvedLocation;\n\n const ttsOptions = buildAuthOptions(speechAuthConfig, { vertexAI, location: resolvedLocation });\n const speechOptions = buildAuthOptions(listeningAuthConfig, { vertexAI, location: resolvedLocation });\n\n this.ttsClient = new TextToSpeechClient(ttsOptions);\n this.speechClient = new SpeechClient(speechOptions);\n }\n\n /**\n * Check if Vertex AI mode is enabled\n * @returns {boolean} True if using Vertex AI\n */\n isUsingVertexAI(): boolean {\n return this.vertexAI;\n }\n\n /**\n * Get the configured Google Cloud project ID\n * @returns {string | undefined} The project ID or undefined if not set\n */\n getProject(): string | undefined {\n return this.project;\n }\n\n /**\n * Get the configured Google Cloud location/region\n * @returns {string} The location (default: 'us-central1')\n */\n getLocation(): string {\n return this.location;\n }\n\n /**\n * Gets a list of available voices\n * @returns {Promise<Array<{voiceId: string, languageCodes: string[]}>>} List of available voices and their supported languages. Default language is en-US.\n */\n async getSpeakers({ languageCode = 'en-US' }: { languageCode?: string } = {}) {\n const [response] = await this.ttsClient.listVoices({ languageCode: languageCode });\n return (response?.voices || [])\n .filter(voice => voice.name && voice.languageCodes)\n .map(voice => ({\n voiceId: voice.name!,\n languageCodes: voice.languageCodes!,\n }));\n }\n\n private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n return Buffer.concat(chunks).toString('utf-8');\n }\n\n /**\n * Converts text to speech\n * @param {string | NodeJS.ReadableStream} input - Text or stream to convert to speech\n * @param {Object} [options] - Speech synthesis options\n * @param {string} [options.speaker] - Voice ID to use\n * @param {string} [options.languageCode] - Language code for the voice\n * @param {TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig']} [options.audioConfig] - Audio configuration options\n * @returns {Promise<NodeJS.ReadableStream>} Stream of synthesized audio. Default encoding is LINEAR16.\n */\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n languageCode?: string;\n audioConfig?: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig'];\n },\n ): Promise<NodeJS.ReadableStream> {\n const text = typeof input === 'string' ? input : await this.streamToString(input);\n\n const request: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest = {\n input: { text },\n voice: {\n name: options?.speaker || this.speaker,\n languageCode: options?.languageCode || options?.speaker?.split('-').slice(0, 2).join('-') || 'en-US',\n },\n audioConfig: options?.audioConfig || { audioEncoding: 'LINEAR16' },\n };\n\n const [response] = await this.ttsClient.synthesizeSpeech(request);\n\n if (!response.audioContent) {\n throw new Error('No audio content returned.');\n }\n\n if (typeof response.audioContent === 'string') {\n throw new Error('Audio content is a string.');\n }\n\n const stream = new PassThrough();\n stream.end(Buffer.from(response.audioContent));\n return stream;\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 /**\n * Converts speech to text\n * @param {NodeJS.ReadableStream} audioStream - Audio stream to transcribe. Default encoding is LINEAR16.\n * @param {Object} [options] - Recognition options\n * @param {SpeechTypes.cloud.speech.v1.IRecognitionConfig} [options.config] - Recognition configuration\n * @returns {Promise<string>} Transcribed text\n */\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: { stream?: boolean; config?: SpeechTypes.cloud.speech.v1.IRecognitionConfig },\n ): Promise<string> {\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 buffer = Buffer.concat(chunks);\n\n let request = {\n config: {\n encoding: 'LINEAR16',\n languageCode: 'en-US',\n ...options?.config,\n },\n audio: {\n content: buffer.toString('base64'),\n },\n };\n const [response] = await this.speechClient.recognize(request as SpeechTypes.cloud.speech.v1.IRecognizeRequest);\n\n if (!response.results || response.results.length === 0) {\n throw new Error('No transcription results returned');\n }\n\n const transcription = response.results\n .map((result: any) => {\n if (!result.alternatives || result.alternatives.length === 0) {\n return '';\n }\n return result.alternatives[0].transcript || '';\n })\n .filter((text: string) => text.length > 0)\n .join(' ');\n\n if (!transcription) {\n throw new Error('No valid transcription found in results');\n }\n\n return transcription;\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":[],"mappings":";;;;;;;AAEO,IAAM,gBAAA,GAAmB;EAO9B,GAAA,EAAK,KAcP,CAAA;AAIO,IAAM,QAAA,GAAW;EACtB,KAAA,EAAO,OAAA;EACP,IAAA,EAAM,MAAA;EACN,IAAA,EAAM,MAAA;EACN,KAAA,EAAO,OAET,CAAA;AAsGO,IAAe,eAAf,MAAqD;AAChD,EAAA,IAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;EAEV,WAAA,CACE,OAAA,GAII,EAAA,EACJ;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,QAAQ,IAAA,IAAQ,QAAA;AAC5B,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,CAAQ,KAAA,IAAS,QAAA,CAAS,KAAA;AACvC,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,GAAA,CAAI,MAAA,CAAO,QAAQ,OAAA,CAAQ,UAAA,IAAc,EAAE,CAAC,CAAA;AACpE,EAAA;EAOA,aAAA,GAAgB;AACd,IAAA,OAAO,IAAA,CAAK,UAAA;AACd,EAAA;AAEA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,CAAC,CAAA,CAAE,UAAA,IAAc,EAAA;AAAA,IAC9C,CAAC,CAAA,CACA,MAAA,CAAO,CAAC,IAAA,KAAiB,KAAK,MAAA,GAAS,CAAC,CAAA,CACxC,IAAA,CAAK,GAAG,CAAA;AAEX,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,IAC3D;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;AACF","file":"index.js","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.warn(`${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 { PassThrough } from 'node:stream';\n\nimport { SpeechClient } from '@google-cloud/speech';\nimport type { google as SpeechTypes } from '@google-cloud/speech/build/protos/protos';\nimport { TextToSpeechClient } from '@google-cloud/text-to-speech';\nimport type { google as TextToSpeechTypes } from '@google-cloud/text-to-speech/build/protos/protos';\nimport { MastraVoice } from '@internal/voice';\n\n/**\n * Configuration for Google Cloud Voice models\n * @interface GoogleModelConfig\n * @property {string} [apiKey] - Optional Google Cloud API key. If not provided, will use GOOGLE_API_KEY environment variable\n * @property {string} [keyFilename] - Optional path to a service account key file. If not provided, will use GOOGLE_APPLICATION_CREDENTIALS environment variable\n * @property {{ client_email?: string; private_key?: string }} [credentials] - Optional in-memory service account credentials\n */\nexport interface GoogleModelConfig {\n apiKey?: string;\n keyFilename?: string;\n credentials?: {\n client_email?: string;\n private_key?: string;\n [key: string]: unknown;\n };\n}\n\n/**\n * Configuration options for GoogleVoice\n * @interface GoogleVoiceConfig\n */\nexport interface GoogleVoiceConfig {\n /** Configuration for speech synthesis (TTS) */\n speechModel?: GoogleModelConfig;\n /** Configuration for speech recognition (STT) */\n listeningModel?: GoogleModelConfig;\n /** Default voice ID to use for speech synthesis */\n speaker?: string;\n /**\n * Enable Vertex AI mode for enterprise deployments.\n * When true, uses Google Cloud project-based authentication instead of API keys.\n * Requires `project` to be set or GOOGLE_CLOUD_PROJECT environment variable.\n */\n vertexAI?: boolean;\n /**\n * Google Cloud project ID (required when vertexAI is true).\n * Falls back to GOOGLE_CLOUD_PROJECT environment variable.\n */\n project?: string;\n /**\n * Google Cloud region for Vertex AI endpoints.\n * Falls back to GOOGLE_CLOUD_LOCATION environment variable.\n * @default 'us-central1'\n */\n location?: string;\n}\n\ntype AuthConfig = Pick<GoogleModelConfig, 'apiKey' | 'keyFilename' | 'credentials'> & {\n projectId?: string;\n};\n\ntype GoogleClientOptions = AuthConfig;\n\nconst resolveAuthConfig = (\n modelConfig: GoogleModelConfig | undefined,\n fallback: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; project?: string },\n): AuthConfig => {\n const resolved: AuthConfig = {};\n\n // For Vertex AI, prioritize project-based auth over API keys\n if (vertexConfig?.vertexAI) {\n const projectId = vertexConfig.project || process.env.GOOGLE_CLOUD_PROJECT;\n if (projectId) {\n resolved.projectId = projectId;\n }\n }\n\n const apiKey = modelConfig?.apiKey ?? fallback.apiKey;\n // Only use API key if not in Vertex AI mode\n if (apiKey && !vertexConfig?.vertexAI) {\n resolved.apiKey = apiKey;\n }\n\n const keyFilename = modelConfig?.keyFilename ?? fallback.keyFilename;\n if (keyFilename) {\n resolved.keyFilename = keyFilename;\n }\n\n const credentials = modelConfig?.credentials ?? fallback.credentials;\n if (credentials) {\n resolved.credentials = credentials;\n }\n\n return resolved;\n};\n\nconst buildAuthOptions = (\n config: AuthConfig,\n vertexConfig?: { vertexAI?: boolean; location?: string },\n): GoogleClientOptions => {\n const options: GoogleClientOptions = {};\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n if (config.keyFilename) {\n options.keyFilename = config.keyFilename;\n }\n\n // Only use API key if not using Vertex AI\n if (config.apiKey && !vertexConfig?.vertexAI) {\n options.apiKey = config.apiKey;\n }\n\n // For Vertex AI, set the project ID\n if (config.projectId) {\n options.projectId = config.projectId;\n }\n\n return options;\n};\n\nconst DEFAULT_VOICE = 'en-US-Casual-K';\n\n/**\n * GoogleVoice class provides Text-to-Speech and Speech-to-Text capabilities using Google Cloud services.\n * Supports both standard Google Cloud API authentication and Vertex AI mode for enterprise deployments.\n *\n * @class GoogleVoice\n * @extends MastraVoice\n *\n * @example Standard usage with API key\n * ```typescript\n * const voice = new GoogleVoice({\n * speechModel: { apiKey: 'your-api-key' },\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI mode (recommended for production)\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * location: 'us-central1',\n * speaker: 'en-US-Studio-O',\n * });\n * ```\n *\n * @example Vertex AI with service account\n * ```typescript\n * const voice = new GoogleVoice({\n * vertexAI: true,\n * project: 'your-gcp-project',\n * speechModel: {\n * keyFilename: '/path/to/service-account.json',\n * },\n * });\n * ```\n */\nexport class GoogleVoice extends MastraVoice {\n private ttsClient: TextToSpeechClient;\n private speechClient: SpeechClient;\n private readonly vertexAI: boolean;\n private readonly project?: string;\n private readonly location: string;\n\n /**\n * Creates an instance of GoogleVoice\n * @param {GoogleVoiceConfig} config - Configuration options\n * @param {GoogleModelConfig} [config.speechModel] - Configuration for speech synthesis\n * @param {GoogleModelConfig} [config.listeningModel] - Configuration for speech recognition\n * @param {string} [config.speaker] - Default voice ID to use for speech synthesis\n * @param {boolean} [config.vertexAI] - Enable Vertex AI mode\n * @param {string} [config.project] - Google Cloud project ID (required for Vertex AI)\n * @param {string} [config.location] - Google Cloud region (default: 'us-central1')\n */\n constructor({ listeningModel, speechModel, speaker, vertexAI = false, project, location }: GoogleVoiceConfig = {}) {\n const defaultApiKey = process.env.GOOGLE_API_KEY;\n const defaultKeyFilename = process.env.GOOGLE_APPLICATION_CREDENTIALS;\n const defaultSpeaker = DEFAULT_VOICE;\n\n // Resolve Vertex AI configuration\n const resolvedProject = project || process.env.GOOGLE_CLOUD_PROJECT;\n const resolvedLocation = location || process.env.GOOGLE_CLOUD_LOCATION || 'us-central1';\n\n // Validate Vertex AI configuration\n if (vertexAI && !resolvedProject) {\n throw new Error(\n 'Google Cloud project ID is required when using Vertex AI. ' +\n 'Set GOOGLE_CLOUD_PROJECT environment variable or pass project to constructor.',\n );\n }\n\n const vertexConfig = { vertexAI, project: resolvedProject };\n\n const sharedFallback: AuthConfig = {\n apiKey: defaultApiKey ?? speechModel?.apiKey ?? listeningModel?.apiKey,\n keyFilename: defaultKeyFilename ?? speechModel?.keyFilename ?? listeningModel?.keyFilename,\n credentials: speechModel?.credentials ?? listeningModel?.credentials,\n projectId: resolvedProject,\n };\n\n const speechAuthConfig = resolveAuthConfig(speechModel, sharedFallback, vertexConfig);\n const listeningAuthConfig = resolveAuthConfig(listeningModel, sharedFallback, vertexConfig);\n\n super({\n speechModel: {\n name: '',\n apiKey: speechAuthConfig.apiKey ?? defaultApiKey,\n },\n listeningModel: {\n name: '',\n apiKey: listeningAuthConfig.apiKey ?? defaultApiKey,\n },\n speaker: speaker ?? defaultSpeaker,\n });\n\n this.vertexAI = vertexAI;\n this.project = resolvedProject;\n this.location = resolvedLocation;\n\n const ttsOptions = buildAuthOptions(speechAuthConfig, { vertexAI, location: resolvedLocation });\n const speechOptions = buildAuthOptions(listeningAuthConfig, { vertexAI, location: resolvedLocation });\n\n this.ttsClient = new TextToSpeechClient(ttsOptions);\n this.speechClient = new SpeechClient(speechOptions);\n }\n\n /**\n * Check if Vertex AI mode is enabled\n * @returns {boolean} True if using Vertex AI\n */\n isUsingVertexAI(): boolean {\n return this.vertexAI;\n }\n\n /**\n * Get the configured Google Cloud project ID\n * @returns {string | undefined} The project ID or undefined if not set\n */\n getProject(): string | undefined {\n return this.project;\n }\n\n /**\n * Get the configured Google Cloud location/region\n * @returns {string} The location (default: 'us-central1')\n */\n getLocation(): string {\n return this.location;\n }\n\n /**\n * Gets a list of available voices\n * @returns {Promise<Array<{voiceId: string, languageCodes: string[]}>>} List of available voices and their supported languages. Default language is en-US.\n */\n async getSpeakers({ languageCode = 'en-US' }: { languageCode?: string } = {}) {\n const [response] = await this.ttsClient.listVoices({ languageCode: languageCode });\n return (response?.voices || [])\n .filter(voice => voice.name && voice.languageCodes)\n .map(voice => ({\n voiceId: voice.name!,\n languageCodes: voice.languageCodes!,\n }));\n }\n\n private async streamToString(stream: NodeJS.ReadableStream): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(Buffer.from(chunk));\n } else {\n chunks.push(chunk);\n }\n }\n return Buffer.concat(chunks).toString('utf-8');\n }\n\n /**\n * Converts text to speech\n * @param {string | NodeJS.ReadableStream} input - Text or stream to convert to speech\n * @param {Object} [options] - Speech synthesis options\n * @param {string} [options.speaker] - Voice ID to use\n * @param {string} [options.languageCode] - Language code for the voice\n * @param {TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig']} [options.audioConfig] - Audio configuration options\n * @returns {Promise<NodeJS.ReadableStream>} Stream of synthesized audio. Default encoding is LINEAR16.\n */\n async speak(\n input: string | NodeJS.ReadableStream,\n options?: {\n speaker?: string;\n languageCode?: string;\n audioConfig?: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest['audioConfig'];\n },\n ): Promise<NodeJS.ReadableStream> {\n const text = typeof input === 'string' ? input : await this.streamToString(input);\n\n const request: TextToSpeechTypes.cloud.texttospeech.v1.ISynthesizeSpeechRequest = {\n input: { text },\n voice: {\n name: options?.speaker || this.speaker,\n languageCode: options?.languageCode || options?.speaker?.split('-').slice(0, 2).join('-') || 'en-US',\n },\n audioConfig: options?.audioConfig || { audioEncoding: 'LINEAR16' },\n };\n\n const [response] = await this.ttsClient.synthesizeSpeech(request);\n\n if (!response.audioContent) {\n throw new Error('No audio content returned.');\n }\n\n if (typeof response.audioContent === 'string') {\n throw new Error('Audio content is a string.');\n }\n\n const stream = new PassThrough();\n stream.end(Buffer.from(response.audioContent));\n return stream;\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 /**\n * Converts speech to text\n * @param {NodeJS.ReadableStream} audioStream - Audio stream to transcribe. Default encoding is LINEAR16.\n * @param {Object} [options] - Recognition options\n * @param {SpeechTypes.cloud.speech.v1.IRecognitionConfig} [options.config] - Recognition configuration\n * @returns {Promise<string>} Transcribed text\n */\n async listen(\n audioStream: NodeJS.ReadableStream,\n options?: { stream?: boolean; config?: SpeechTypes.cloud.speech.v1.IRecognitionConfig },\n ): Promise<string> {\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 buffer = Buffer.concat(chunks);\n\n let request = {\n config: {\n encoding: 'LINEAR16',\n languageCode: 'en-US',\n ...options?.config,\n },\n audio: {\n content: buffer.toString('base64'),\n },\n };\n const [response] = await this.speechClient.recognize(request as SpeechTypes.cloud.speech.v1.IRecognizeRequest);\n\n if (!response.results || response.results.length === 0) {\n throw new Error('No transcription results returned');\n }\n\n const transcription = response.results\n .map((result: any) => {\n if (!result.alternatives || result.alternatives.length === 0) {\n return '';\n }\n return result.alternatives[0].transcript || '';\n })\n .filter((text: string) => text.length > 0)\n .join(' ');\n\n if (!transcription) {\n throw new Error('No valid transcription found in results');\n }\n\n return transcription;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-google",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2-alpha.0",
|
|
4
4
|
"description": "Mastra Google voice integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -25,19 +25,20 @@
|
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@google-cloud/speech": "^6.7.1",
|
|
28
|
-
"@google-cloud/text-to-speech": "^6.4.
|
|
28
|
+
"@google-cloud/text-to-speech": "^6.4.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "22.19.15",
|
|
32
32
|
"@vitest/coverage-v8": "4.1.5",
|
|
33
33
|
"@vitest/ui": "4.1.5",
|
|
34
|
-
"eslint": "^10.
|
|
34
|
+
"eslint": "^10.4.1",
|
|
35
35
|
"tsup": "^8.5.1",
|
|
36
|
+
"tsx": "^4.22.4",
|
|
36
37
|
"typescript": "^6.0.3",
|
|
37
38
|
"vitest": "4.1.5",
|
|
38
|
-
"@internal/
|
|
39
|
-
"@internal/
|
|
40
|
-
"@internal/
|
|
39
|
+
"@internal/types-builder": "0.0.78",
|
|
40
|
+
"@internal/voice": "0.0.4",
|
|
41
|
+
"@internal/lint": "0.0.103"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"zod": "^3.25.0 || ^4.0.0"
|