@mastra/voice-google-gemini-live 0.11.0-beta.0 → 0.11.0-beta.1

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/voice-google-gemini-live
2
2
 
3
+ ## 0.11.0-beta.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Fix tool calling args and execution for Gemini Live ([#10226](https://github.com/mastra-ai/mastra/pull/10226))
8
+
9
+ ### Patch Changes
10
+
11
+ - 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)]:
12
+ - @mastra/core@1.0.0-beta.3
13
+
3
14
  ## 0.11.0-beta.0
4
15
 
5
16
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -2259,6 +2259,18 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2259
2259
  role: "assistant"
2260
2260
  });
2261
2261
  }
2262
+ if (part.functionCall) {
2263
+ this.log("Found function call in serverContent.modelTurn.parts", part.functionCall);
2264
+ const toolCallData = {
2265
+ toolCall: {
2266
+ name: part.functionCall.name,
2267
+ args: part.functionCall.args || {},
2268
+ id: part.functionCall.id || crypto.randomUUID()
2269
+ }
2270
+ };
2271
+ void this.handleToolCall(toolCallData);
2272
+ continue;
2273
+ }
2262
2274
  if (part.inlineData?.mimeType?.includes("audio") && typeof part.inlineData.data === "string") {
2263
2275
  try {
2264
2276
  const audioData = part.inlineData.data;
@@ -2333,9 +2345,24 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2333
2345
  if (!data.toolCall) {
2334
2346
  return;
2335
2347
  }
2336
- const toolName = data.toolCall.name || "";
2337
- const toolArgs = data.toolCall.args || {};
2338
- const toolId = data.toolCall.id || crypto.randomUUID();
2348
+ let toolCalls = [];
2349
+ if (data.toolCall.functionCalls && Array.isArray(data.toolCall.functionCalls)) {
2350
+ toolCalls = data.toolCall.functionCalls;
2351
+ } else if (data.toolCall.name) {
2352
+ toolCalls = [{ name: data.toolCall.name, args: data.toolCall.args, id: data.toolCall.id }];
2353
+ }
2354
+ for (const toolCall of toolCalls) {
2355
+ const toolName = toolCall.name || "";
2356
+ const toolArgs = toolCall.args || {};
2357
+ const toolId = toolCall.id || crypto.randomUUID();
2358
+ await this.processSingleToolCall(toolName, toolArgs, toolId);
2359
+ }
2360
+ }
2361
+ /**
2362
+ * Process a single tool call
2363
+ * @private
2364
+ */
2365
+ async processSingleToolCall(toolName, toolArgs, toolId) {
2339
2366
  this.log("Processing tool call", { toolName, toolArgs, toolId });
2340
2367
  this.emit("toolCall", {
2341
2368
  name: toolName,
@@ -2362,23 +2389,31 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2362
2389
  result = { error: "Tool has no execute function" };
2363
2390
  }
2364
2391
  const toolResultMessage = {
2365
- tool_result: {
2366
- tool_call_id: toolId,
2367
- result
2392
+ toolResponse: {
2393
+ functionResponses: [
2394
+ {
2395
+ id: toolId,
2396
+ response: result
2397
+ }
2398
+ ]
2368
2399
  }
2369
2400
  };
2370
- this.sendEvent("tool_result", toolResultMessage);
2401
+ this.sendEvent("toolResponse", toolResultMessage);
2371
2402
  this.log("Tool result sent", { toolName, toolId, result });
2372
2403
  } catch (error) {
2373
2404
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
2374
2405
  this.log("Tool execution failed", { toolName, error: errorMessage });
2375
2406
  const errorResultMessage = {
2376
- tool_result: {
2377
- tool_call_id: toolId,
2378
- result: { error: errorMessage }
2407
+ toolResponse: {
2408
+ functionResponses: [
2409
+ {
2410
+ id: toolId,
2411
+ response: { error: errorMessage }
2412
+ }
2413
+ ]
2379
2414
  }
2380
2415
  };
2381
- this.sendEvent("tool_result", errorResultMessage);
2416
+ this.sendEvent("toolResponse", errorResultMessage);
2382
2417
  this.createAndEmitError("tool_execution_error" /* TOOL_EXECUTION_ERROR */, `Tool execution failed: ${errorMessage}`, {
2383
2418
  toolName,
2384
2419
  toolArgs,
@@ -2597,6 +2632,8 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2597
2632
  message = data;
2598
2633
  } else if (type === "realtime_input" && data.realtime_input) {
2599
2634
  message = data;
2635
+ } else if (type === "toolResponse" && data.toolResponse) {
2636
+ message = data;
2600
2637
  } else if (type === "session.update" && data.session) {
2601
2638
  message = data;
2602
2639
  } else {