@ai-sdk/xai 2.0.58 → 2.0.59

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/dist/index.mjs CHANGED
@@ -1151,6 +1151,19 @@ var xaiResponsesChunkSchema = z4.union([
1151
1151
  output_index: z4.number(),
1152
1152
  code: z4.string()
1153
1153
  }),
1154
+ // Function call arguments streaming events (standard function tools)
1155
+ z4.object({
1156
+ type: z4.literal("response.function_call_arguments.delta"),
1157
+ item_id: z4.string(),
1158
+ output_index: z4.number(),
1159
+ delta: z4.string()
1160
+ }),
1161
+ z4.object({
1162
+ type: z4.literal("response.function_call_arguments.done"),
1163
+ item_id: z4.string(),
1164
+ output_index: z4.number(),
1165
+ arguments: z4.string()
1166
+ }),
1154
1167
  z4.object({
1155
1168
  type: z4.literal("response.done"),
1156
1169
  response: xaiResponsesResponseSchema
@@ -1887,6 +1900,7 @@ var XaiResponsesLanguageModel = class {
1887
1900
  let isFirstChunk = true;
1888
1901
  const contentBlocks = {};
1889
1902
  const seenToolCalls = /* @__PURE__ */ new Set();
1903
+ const ongoingToolCalls = {};
1890
1904
  const activeReasoning = {};
1891
1905
  const self = this;
1892
1906
  return {
@@ -2032,6 +2046,20 @@ var XaiResponsesLanguageModel = class {
2032
2046
  }
2033
2047
  return;
2034
2048
  }
2049
+ if (event.type === "response.function_call_arguments.delta") {
2050
+ const toolCall = ongoingToolCalls[event.output_index];
2051
+ if (toolCall != null) {
2052
+ controller.enqueue({
2053
+ type: "tool-input-delta",
2054
+ id: toolCall.toolCallId,
2055
+ delta: event.delta
2056
+ });
2057
+ }
2058
+ return;
2059
+ }
2060
+ if (event.type === "response.function_call_arguments.done") {
2061
+ return;
2062
+ }
2035
2063
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
2036
2064
  const part = event.item;
2037
2065
  if (part.type === "reasoning") {
@@ -2143,18 +2171,18 @@ var XaiResponsesLanguageModel = class {
2143
2171
  }
2144
2172
  }
2145
2173
  } else if (part.type === "function_call") {
2146
- if (!seenToolCalls.has(part.call_id)) {
2147
- seenToolCalls.add(part.call_id);
2174
+ if (event.type === "response.output_item.added") {
2175
+ ongoingToolCalls[event.output_index] = {
2176
+ toolName: part.name,
2177
+ toolCallId: part.call_id
2178
+ };
2148
2179
  controller.enqueue({
2149
2180
  type: "tool-input-start",
2150
2181
  id: part.call_id,
2151
2182
  toolName: part.name
2152
2183
  });
2153
- controller.enqueue({
2154
- type: "tool-input-delta",
2155
- id: part.call_id,
2156
- delta: part.arguments
2157
- });
2184
+ } else if (event.type === "response.output_item.done") {
2185
+ ongoingToolCalls[event.output_index] = void 0;
2158
2186
  controller.enqueue({
2159
2187
  type: "tool-input-end",
2160
2188
  id: part.call_id
@@ -2244,7 +2272,7 @@ var xaiTools = {
2244
2272
  };
2245
2273
 
2246
2274
  // src/version.ts
2247
- var VERSION = true ? "2.0.58" : "0.0.0-test";
2275
+ var VERSION = true ? "2.0.59" : "0.0.0-test";
2248
2276
 
2249
2277
  // src/xai-provider.ts
2250
2278
  var xaiErrorStructure = {