@ai-sdk/xai 3.0.8 → 3.0.10

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,17 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 659c53d: fixed streaming tool input for custom_tool_call types (x_search, view_x_video) which were incorrectly returning empty input values
8
+
9
+ ## 3.0.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 173dcfd: added support for streaming custom tool input chunks in xAI
14
+
3
15
  ## 3.0.8
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1196,6 +1196,16 @@ var xaiResponsesChunkSchema = import_v44.z.union([
1196
1196
  item_id: import_v44.z.string(),
1197
1197
  output_index: import_v44.z.number()
1198
1198
  }),
1199
+ import_v44.z.object({
1200
+ type: import_v44.z.literal("response.custom_tool_call_input.done"),
1201
+ item_id: import_v44.z.string(),
1202
+ output_index: import_v44.z.number()
1203
+ }),
1204
+ import_v44.z.object({
1205
+ type: import_v44.z.literal("response.custom_tool_call_input.delta"),
1206
+ item_id: import_v44.z.string(),
1207
+ output_index: import_v44.z.number()
1208
+ }),
1199
1209
  import_v44.z.object({
1200
1210
  type: import_v44.z.literal("response.code_execution_call.in_progress"),
1201
1211
  item_id: import_v44.z.string(),
@@ -1868,28 +1878,29 @@ var XaiResponsesLanguageModel = class {
1868
1878
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1869
1879
  const part = event.item;
1870
1880
  if (part.type === "web_search_call" || part.type === "x_search_call" || part.type === "code_interpreter_call" || part.type === "code_execution_call" || part.type === "view_image_call" || part.type === "view_x_video_call" || part.type === "custom_tool_call") {
1871
- if (!seenToolCalls.has(part.id)) {
1881
+ const webSearchSubTools = [
1882
+ "web_search",
1883
+ "web_search_with_snippets",
1884
+ "browse_page"
1885
+ ];
1886
+ const xSearchSubTools = [
1887
+ "x_user_search",
1888
+ "x_keyword_search",
1889
+ "x_semantic_search",
1890
+ "x_thread_fetch"
1891
+ ];
1892
+ let toolName = (_c = part.name) != null ? _c : "";
1893
+ if (webSearchSubTools.includes((_d = part.name) != null ? _d : "") || part.type === "web_search_call") {
1894
+ toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1895
+ } else if (xSearchSubTools.includes((_e = part.name) != null ? _e : "") || part.type === "x_search_call") {
1896
+ toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1897
+ } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1898
+ toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1899
+ }
1900
+ const toolInput = part.type === "custom_tool_call" ? (_f = part.input) != null ? _f : "" : (_g = part.arguments) != null ? _g : "";
1901
+ const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
1902
+ if (shouldEmit && !seenToolCalls.has(part.id)) {
1872
1903
  seenToolCalls.add(part.id);
1873
- const webSearchSubTools = [
1874
- "web_search",
1875
- "web_search_with_snippets",
1876
- "browse_page"
1877
- ];
1878
- const xSearchSubTools = [
1879
- "x_user_search",
1880
- "x_keyword_search",
1881
- "x_semantic_search",
1882
- "x_thread_fetch"
1883
- ];
1884
- let toolName = (_c = part.name) != null ? _c : "";
1885
- if (webSearchSubTools.includes((_d = part.name) != null ? _d : "") || part.type === "web_search_call") {
1886
- toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1887
- } else if (xSearchSubTools.includes((_e = part.name) != null ? _e : "") || part.type === "x_search_call") {
1888
- toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1889
- } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1890
- toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1891
- }
1892
- const toolInput = part.type === "custom_tool_call" ? (_f = part.input) != null ? _f : "" : (_g = part.arguments) != null ? _g : "";
1893
1904
  controller.enqueue({
1894
1905
  type: "tool-input-start",
1895
1906
  id: part.id,
@@ -2044,7 +2055,7 @@ var xaiTools = {
2044
2055
  };
2045
2056
 
2046
2057
  // src/version.ts
2047
- var VERSION = true ? "3.0.8" : "0.0.0-test";
2058
+ var VERSION = true ? "3.0.10" : "0.0.0-test";
2048
2059
 
2049
2060
  // src/xai-provider.ts
2050
2061
  var xaiErrorStructure = {