@ai-sdk/xai 2.0.46 → 2.0.48

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,18 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 2.0.48
4
+
5
+ ### Patch Changes
6
+
7
+ - c7d45b4: fixed streaming tool input for custom_tool_call types (x_search, view_x_video) which were incorrectly returning empty input values
8
+ - 547e0c2: fix (provider/xai): no duplicate text delta in responses api
9
+
10
+ ## 2.0.47
11
+
12
+ ### Patch Changes
13
+
14
+ - 6e3beb1: added support for streaming custom tool input chunks in xAI
15
+
3
16
  ## 2.0.46
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -999,6 +999,16 @@ var xaiResponsesChunkSchema = import_v44.z.union([
999
999
  item_id: import_v44.z.string(),
1000
1000
  output_index: import_v44.z.number()
1001
1001
  }),
1002
+ import_v44.z.object({
1003
+ type: import_v44.z.literal("response.custom_tool_call_input.done"),
1004
+ item_id: import_v44.z.string(),
1005
+ output_index: import_v44.z.number()
1006
+ }),
1007
+ import_v44.z.object({
1008
+ type: import_v44.z.literal("response.custom_tool_call_input.delta"),
1009
+ item_id: import_v44.z.string(),
1010
+ output_index: import_v44.z.number()
1011
+ }),
1002
1012
  import_v44.z.object({
1003
1013
  type: import_v44.z.literal("response.code_execution_call.in_progress"),
1004
1014
  item_id: import_v44.z.string(),
@@ -1834,28 +1844,29 @@ var XaiResponsesLanguageModel = class {
1834
1844
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1835
1845
  const part = event.item;
1836
1846
  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") {
1837
- if (!seenToolCalls.has(part.id)) {
1847
+ const webSearchSubTools = [
1848
+ "web_search",
1849
+ "web_search_with_snippets",
1850
+ "browse_page"
1851
+ ];
1852
+ const xSearchSubTools = [
1853
+ "x_user_search",
1854
+ "x_keyword_search",
1855
+ "x_semantic_search",
1856
+ "x_thread_fetch"
1857
+ ];
1858
+ let toolName = (_e = part.name) != null ? _e : "";
1859
+ if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
1860
+ toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1861
+ } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
1862
+ toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1863
+ } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1864
+ toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1865
+ }
1866
+ const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
1867
+ const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
1868
+ if (shouldEmit && !seenToolCalls.has(part.id)) {
1838
1869
  seenToolCalls.add(part.id);
1839
- const webSearchSubTools = [
1840
- "web_search",
1841
- "web_search_with_snippets",
1842
- "browse_page"
1843
- ];
1844
- const xSearchSubTools = [
1845
- "x_user_search",
1846
- "x_keyword_search",
1847
- "x_semantic_search",
1848
- "x_thread_fetch"
1849
- ];
1850
- let toolName = (_e = part.name) != null ? _e : "";
1851
- if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
1852
- toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1853
- } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
1854
- toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1855
- } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1856
- toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1857
- }
1858
- const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
1859
1870
  controller.enqueue({
1860
1871
  type: "tool-input-start",
1861
1872
  id: part.id,
@@ -1890,12 +1901,12 @@ var XaiResponsesLanguageModel = class {
1890
1901
  type: "text-start",
1891
1902
  id: blockId
1892
1903
  });
1904
+ controller.enqueue({
1905
+ type: "text-delta",
1906
+ id: blockId,
1907
+ delta: contentPart.text
1908
+ });
1893
1909
  }
1894
- controller.enqueue({
1895
- type: "text-delta",
1896
- id: blockId,
1897
- delta: contentPart.text
1898
- });
1899
1910
  }
1900
1911
  if (contentPart.annotations) {
1901
1912
  for (const annotation of contentPart.annotations) {
@@ -2013,7 +2024,7 @@ var xaiTools = {
2013
2024
  };
2014
2025
 
2015
2026
  // src/version.ts
2016
- var VERSION = true ? "2.0.46" : "0.0.0-test";
2027
+ var VERSION = true ? "2.0.48" : "0.0.0-test";
2017
2028
 
2018
2029
  // src/xai-provider.ts
2019
2030
  var xaiErrorStructure = {