@mastra/voice-google-gemini-live 0.11.0-beta.0 → 0.11.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/index.cjs +76 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -13
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/voice-google-gemini-live
|
|
2
2
|
|
|
3
|
+
## 0.11.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(voice): Fix Vertex AI WebSocket connection failures in GeminiLiveVoice ([#10243](https://github.com/mastra-ai/mastra/pull/10243))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`352a5d6`](https://github.com/mastra-ai/mastra/commit/352a5d625cfe09849b21e8f52a24c9f0366759d5), [`a0a5b4b`](https://github.com/mastra-ai/mastra/commit/a0a5b4bbebe6c701ebbadf744873aa0d5ca01371), [`69ea758`](https://github.com/mastra-ai/mastra/commit/69ea758358edd7117f191c2e69c8bb5fc79e7a1a), [`993ad98`](https://github.com/mastra-ai/mastra/commit/993ad98d7ad3bebda9ecef5fec5c94349a0d04bc), [`3ff2c17`](https://github.com/mastra-ai/mastra/commit/3ff2c17a58e312fad5ea37377262c12d92ca0908)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.4
|
|
11
|
+
|
|
12
|
+
## 0.11.0-beta.1
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Fix tool calling args and execution for Gemini Live ([#10226](https://github.com/mastra-ai/mastra/pull/10226))
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4)]:
|
|
21
|
+
- @mastra/core@1.0.0-beta.3
|
|
22
|
+
|
|
3
23
|
## 0.11.0-beta.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1510,7 +1510,8 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
1510
1510
|
let wsUrl;
|
|
1511
1511
|
let headers = {};
|
|
1512
1512
|
if (this.options.vertexAI) {
|
|
1513
|
-
|
|
1513
|
+
const location = this.getVertexLocation();
|
|
1514
|
+
wsUrl = `wss://${location}-aiplatform.googleapis.com/ws/google.cloud.aiplatform.v1beta1.LlmBidiService/BidiGenerateContent`;
|
|
1514
1515
|
await this.authManager.initialize();
|
|
1515
1516
|
const accessToken = await this.authManager.getAccessToken();
|
|
1516
1517
|
headers = { headers: { Authorization: `Bearer ${accessToken}` } };
|
|
@@ -2259,6 +2260,18 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2259
2260
|
role: "assistant"
|
|
2260
2261
|
});
|
|
2261
2262
|
}
|
|
2263
|
+
if (part.functionCall) {
|
|
2264
|
+
this.log("Found function call in serverContent.modelTurn.parts", part.functionCall);
|
|
2265
|
+
const toolCallData = {
|
|
2266
|
+
toolCall: {
|
|
2267
|
+
name: part.functionCall.name,
|
|
2268
|
+
args: part.functionCall.args || {},
|
|
2269
|
+
id: part.functionCall.id || crypto.randomUUID()
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
void this.handleToolCall(toolCallData);
|
|
2273
|
+
continue;
|
|
2274
|
+
}
|
|
2262
2275
|
if (part.inlineData?.mimeType?.includes("audio") && typeof part.inlineData.data === "string") {
|
|
2263
2276
|
try {
|
|
2264
2277
|
const audioData = part.inlineData.data;
|
|
@@ -2333,9 +2346,24 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2333
2346
|
if (!data.toolCall) {
|
|
2334
2347
|
return;
|
|
2335
2348
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2349
|
+
let toolCalls = [];
|
|
2350
|
+
if (data.toolCall.functionCalls && Array.isArray(data.toolCall.functionCalls)) {
|
|
2351
|
+
toolCalls = data.toolCall.functionCalls;
|
|
2352
|
+
} else if (data.toolCall.name) {
|
|
2353
|
+
toolCalls = [{ name: data.toolCall.name, args: data.toolCall.args, id: data.toolCall.id }];
|
|
2354
|
+
}
|
|
2355
|
+
for (const toolCall of toolCalls) {
|
|
2356
|
+
const toolName = toolCall.name || "";
|
|
2357
|
+
const toolArgs = toolCall.args || {};
|
|
2358
|
+
const toolId = toolCall.id || crypto.randomUUID();
|
|
2359
|
+
await this.processSingleToolCall(toolName, toolArgs, toolId);
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Process a single tool call
|
|
2364
|
+
* @private
|
|
2365
|
+
*/
|
|
2366
|
+
async processSingleToolCall(toolName, toolArgs, toolId) {
|
|
2339
2367
|
this.log("Processing tool call", { toolName, toolArgs, toolId });
|
|
2340
2368
|
this.emit("toolCall", {
|
|
2341
2369
|
name: toolName,
|
|
@@ -2362,23 +2390,31 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2362
2390
|
result = { error: "Tool has no execute function" };
|
|
2363
2391
|
}
|
|
2364
2392
|
const toolResultMessage = {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2393
|
+
toolResponse: {
|
|
2394
|
+
functionResponses: [
|
|
2395
|
+
{
|
|
2396
|
+
id: toolId,
|
|
2397
|
+
response: result
|
|
2398
|
+
}
|
|
2399
|
+
]
|
|
2368
2400
|
}
|
|
2369
2401
|
};
|
|
2370
|
-
this.sendEvent("
|
|
2402
|
+
this.sendEvent("toolResponse", toolResultMessage);
|
|
2371
2403
|
this.log("Tool result sent", { toolName, toolId, result });
|
|
2372
2404
|
} catch (error) {
|
|
2373
2405
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
2374
2406
|
this.log("Tool execution failed", { toolName, error: errorMessage });
|
|
2375
2407
|
const errorResultMessage = {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2408
|
+
toolResponse: {
|
|
2409
|
+
functionResponses: [
|
|
2410
|
+
{
|
|
2411
|
+
id: toolId,
|
|
2412
|
+
response: { error: errorMessage }
|
|
2413
|
+
}
|
|
2414
|
+
]
|
|
2379
2415
|
}
|
|
2380
2416
|
};
|
|
2381
|
-
this.sendEvent("
|
|
2417
|
+
this.sendEvent("toolResponse", errorResultMessage);
|
|
2382
2418
|
this.createAndEmitError("tool_execution_error" /* TOOL_EXECUTION_ERROR */, `Tool execution failed: ${errorMessage}`, {
|
|
2383
2419
|
toolName,
|
|
2384
2420
|
toolArgs,
|
|
@@ -2438,6 +2474,31 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2438
2474
|
}
|
|
2439
2475
|
return "text";
|
|
2440
2476
|
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Resolve Vertex AI location with sensible default
|
|
2479
|
+
* @private
|
|
2480
|
+
*/
|
|
2481
|
+
getVertexLocation() {
|
|
2482
|
+
return this.options.location?.trim() || "us-central1";
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Resolve the correct model identifier for Gemini API or Vertex AI
|
|
2486
|
+
* @private
|
|
2487
|
+
*/
|
|
2488
|
+
resolveModelIdentifier() {
|
|
2489
|
+
const model = this.options.model ?? DEFAULT_MODEL;
|
|
2490
|
+
if (!this.options.vertexAI) {
|
|
2491
|
+
return `models/${model}`;
|
|
2492
|
+
}
|
|
2493
|
+
if (!this.options.project) {
|
|
2494
|
+
throw this.createAndEmitError(
|
|
2495
|
+
"project_id_missing" /* PROJECT_ID_MISSING */,
|
|
2496
|
+
"Google Cloud project ID is required when using Vertex AI."
|
|
2497
|
+
);
|
|
2498
|
+
}
|
|
2499
|
+
const location = this.getVertexLocation();
|
|
2500
|
+
return `projects/${this.options.project}/locations/${location}/publishers/google/models/${model}`;
|
|
2501
|
+
}
|
|
2441
2502
|
/**
|
|
2442
2503
|
* Send initial configuration to Gemini Live API
|
|
2443
2504
|
* @private
|
|
@@ -2448,7 +2509,7 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2448
2509
|
}
|
|
2449
2510
|
const setupMessage = {
|
|
2450
2511
|
setup: {
|
|
2451
|
-
model:
|
|
2512
|
+
model: this.resolveModelIdentifier()
|
|
2452
2513
|
}
|
|
2453
2514
|
};
|
|
2454
2515
|
if (this.options.instructions) {
|
|
@@ -2597,6 +2658,8 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
|
|
|
2597
2658
|
message = data;
|
|
2598
2659
|
} else if (type === "realtime_input" && data.realtime_input) {
|
|
2599
2660
|
message = data;
|
|
2661
|
+
} else if (type === "toolResponse" && data.toolResponse) {
|
|
2662
|
+
message = data;
|
|
2600
2663
|
} else if (type === "session.update" && data.session) {
|
|
2601
2664
|
message = data;
|
|
2602
2665
|
} else {
|