@ai-sdk/xai 3.0.53 → 3.0.54

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,11 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.54
4
+
5
+ ### Patch Changes
6
+
7
+ - 902e93b: Add support for `response.function_call_arguments.delta` and `response.function_call_arguments.done` streaming events in the xAI Responses API provider. Previously, xAI Grok models using function tools would fail with `AI_TypeValidationError` because these standard Responses API events were missing from the Zod schema and stream handler.
8
+
3
9
  ## 3.0.53
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1556,6 +1556,19 @@ var xaiResponsesChunkSchema = import_v46.z.union([
1556
1556
  output_index: import_v46.z.number(),
1557
1557
  input: import_v46.z.string()
1558
1558
  }),
1559
+ // Function call arguments streaming events (standard function tools)
1560
+ import_v46.z.object({
1561
+ type: import_v46.z.literal("response.function_call_arguments.delta"),
1562
+ item_id: import_v46.z.string(),
1563
+ output_index: import_v46.z.number(),
1564
+ delta: import_v46.z.string()
1565
+ }),
1566
+ import_v46.z.object({
1567
+ type: import_v46.z.literal("response.function_call_arguments.done"),
1568
+ item_id: import_v46.z.string(),
1569
+ output_index: import_v46.z.number(),
1570
+ arguments: import_v46.z.string()
1571
+ }),
1559
1572
  import_v46.z.object({
1560
1573
  type: import_v46.z.literal("response.mcp_call.in_progress"),
1561
1574
  item_id: import_v46.z.string(),
@@ -2243,6 +2256,7 @@ var XaiResponsesLanguageModel = class {
2243
2256
  let isFirstChunk = true;
2244
2257
  const contentBlocks = {};
2245
2258
  const seenToolCalls = /* @__PURE__ */ new Set();
2259
+ const ongoingToolCalls = {};
2246
2260
  const activeReasoning = {};
2247
2261
  const self = this;
2248
2262
  return {
@@ -2391,6 +2405,20 @@ var XaiResponsesLanguageModel = class {
2391
2405
  if (event.type === "response.custom_tool_call_input.delta" || event.type === "response.custom_tool_call_input.done") {
2392
2406
  return;
2393
2407
  }
2408
+ if (event.type === "response.function_call_arguments.delta") {
2409
+ const toolCall = ongoingToolCalls[event.output_index];
2410
+ if (toolCall != null) {
2411
+ controller.enqueue({
2412
+ type: "tool-input-delta",
2413
+ id: toolCall.toolCallId,
2414
+ delta: event.delta
2415
+ });
2416
+ }
2417
+ return;
2418
+ }
2419
+ if (event.type === "response.function_call_arguments.done") {
2420
+ return;
2421
+ }
2394
2422
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
2395
2423
  const part = event.item;
2396
2424
  if (part.type === "reasoning") {
@@ -2550,18 +2578,18 @@ var XaiResponsesLanguageModel = class {
2550
2578
  }
2551
2579
  }
2552
2580
  } else if (part.type === "function_call") {
2553
- if (!seenToolCalls.has(part.call_id)) {
2554
- seenToolCalls.add(part.call_id);
2581
+ if (event.type === "response.output_item.added") {
2582
+ ongoingToolCalls[event.output_index] = {
2583
+ toolName: part.name,
2584
+ toolCallId: part.call_id
2585
+ };
2555
2586
  controller.enqueue({
2556
2587
  type: "tool-input-start",
2557
2588
  id: part.call_id,
2558
2589
  toolName: part.name
2559
2590
  });
2560
- controller.enqueue({
2561
- type: "tool-input-delta",
2562
- id: part.call_id,
2563
- delta: part.arguments
2564
- });
2591
+ } else if (event.type === "response.output_item.done") {
2592
+ ongoingToolCalls[event.output_index] = void 0;
2565
2593
  controller.enqueue({
2566
2594
  type: "tool-input-end",
2567
2595
  id: part.call_id
@@ -2662,7 +2690,7 @@ var xaiTools = {
2662
2690
  };
2663
2691
 
2664
2692
  // src/version.ts
2665
- var VERSION = true ? "3.0.53" : "0.0.0-test";
2693
+ var VERSION = true ? "3.0.54" : "0.0.0-test";
2666
2694
 
2667
2695
  // src/xai-provider.ts
2668
2696
  function createXai(options = {}) {