@mastra/voice-google-gemini-live 0.10.18 → 0.11.0-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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/voice-google-gemini-live
2
2
 
3
+ ## 0.11.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Backport gemini fix to 0.x ([#10234](https://github.com/mastra-ai/mastra/pull/10234))
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`eebb7bb`](https://github.com/mastra-ai/mastra/commit/eebb7bb407c57342a3be3a2efbe68c696589feeb), [`c6e6d07`](https://github.com/mastra-ai/mastra/commit/c6e6d071ecf346a80dceab410af2c567c7e66a57), [`0e6df8f`](https://github.com/mastra-ai/mastra/commit/0e6df8f66340992cb1b319834657deb17368de52), [`6295fd7`](https://github.com/mastra-ai/mastra/commit/6295fd783d49075d5bf2c18ff9486e94d36aaa56), [`d813cf7`](https://github.com/mastra-ai/mastra/commit/d813cf7251695d85cc60469058384ffa74974484)]:
12
+ - @mastra/core@0.24.2-alpha.0
13
+
3
14
  ## 0.10.18
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2269,6 +2269,18 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2269
2269
  role: "assistant"
2270
2270
  });
2271
2271
  }
2272
+ if (part.functionCall) {
2273
+ this.log("Found function call in serverContent.modelTurn.parts", part.functionCall);
2274
+ const toolCallData = {
2275
+ toolCall: {
2276
+ name: part.functionCall.name,
2277
+ args: part.functionCall.args || {},
2278
+ id: part.functionCall.id || crypto.randomUUID()
2279
+ }
2280
+ };
2281
+ void this.handleToolCall(toolCallData);
2282
+ continue;
2283
+ }
2272
2284
  if (part.inlineData?.mimeType?.includes("audio") && typeof part.inlineData.data === "string") {
2273
2285
  try {
2274
2286
  const audioData = part.inlineData.data;
@@ -2343,9 +2355,24 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2343
2355
  if (!data.toolCall) {
2344
2356
  return;
2345
2357
  }
2346
- const toolName = data.toolCall.name || "";
2347
- const toolArgs = data.toolCall.args || {};
2348
- const toolId = data.toolCall.id || crypto.randomUUID();
2358
+ let toolCalls = [];
2359
+ if (data.toolCall.functionCalls && Array.isArray(data.toolCall.functionCalls)) {
2360
+ toolCalls = data.toolCall.functionCalls;
2361
+ } else if (data.toolCall.name) {
2362
+ toolCalls = [{ name: data.toolCall.name, args: data.toolCall.args, id: data.toolCall.id }];
2363
+ }
2364
+ for (const toolCall of toolCalls) {
2365
+ const toolName = toolCall.name || "";
2366
+ const toolArgs = toolCall.args || {};
2367
+ const toolId = toolCall.id || crypto.randomUUID();
2368
+ await this.processSingleToolCall(toolName, toolArgs, toolId);
2369
+ }
2370
+ }
2371
+ /**
2372
+ * Process a single tool call
2373
+ * @private
2374
+ */
2375
+ async processSingleToolCall(toolName, toolArgs, toolId) {
2349
2376
  this.log("Processing tool call", { toolName, toolArgs, toolId });
2350
2377
  this.emit("toolCall", {
2351
2378
  name: toolName,
@@ -2378,23 +2405,31 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2378
2405
  result = { error: "Tool has no execute function" };
2379
2406
  }
2380
2407
  const toolResultMessage = {
2381
- tool_result: {
2382
- tool_call_id: toolId,
2383
- result
2408
+ toolResponse: {
2409
+ functionResponses: [
2410
+ {
2411
+ id: toolId,
2412
+ response: result
2413
+ }
2414
+ ]
2384
2415
  }
2385
2416
  };
2386
- this.sendEvent("tool_result", toolResultMessage);
2417
+ this.sendEvent("toolResponse", toolResultMessage);
2387
2418
  this.log("Tool result sent", { toolName, toolId, result });
2388
2419
  } catch (error) {
2389
2420
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
2390
2421
  this.log("Tool execution failed", { toolName, error: errorMessage });
2391
2422
  const errorResultMessage = {
2392
- tool_result: {
2393
- tool_call_id: toolId,
2394
- result: { error: errorMessage }
2423
+ toolResponse: {
2424
+ functionResponses: [
2425
+ {
2426
+ id: toolId,
2427
+ response: { error: errorMessage }
2428
+ }
2429
+ ]
2395
2430
  }
2396
2431
  };
2397
- this.sendEvent("tool_result", errorResultMessage);
2432
+ this.sendEvent("toolResponse", errorResultMessage);
2398
2433
  this.createAndEmitError("tool_execution_error" /* TOOL_EXECUTION_ERROR */, `Tool execution failed: ${errorMessage}`, {
2399
2434
  toolName,
2400
2435
  toolArgs,
@@ -2613,6 +2648,8 @@ var GeminiLiveVoice = class _GeminiLiveVoice extends voice.MastraVoice {
2613
2648
  message = data;
2614
2649
  } else if (type === "realtime_input" && data.realtime_input) {
2615
2650
  message = data;
2651
+ } else if (type === "toolResponse" && data.toolResponse) {
2652
+ message = data;
2616
2653
  } else if (type === "session.update" && data.session) {
2617
2654
  message = data;
2618
2655
  } else {