@ai-sdk/xai 3.0.0-beta.41 → 3.0.0-beta.43

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,20 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.0-beta.43
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [10d819b]
8
+ - @ai-sdk/provider@3.0.0-beta.18
9
+ - @ai-sdk/openai-compatible@2.0.0-beta.36
10
+ - @ai-sdk/provider-utils@4.0.0-beta.35
11
+
12
+ ## 3.0.0-beta.42
13
+
14
+ ### Patch Changes
15
+
16
+ - b39ec2c: Fix Responses API validation errors for server-side tools (web_search, x_search, code_execution). Add missing custom_tool_call type and streaming event schemas.
17
+
3
18
  ## 3.0.0-beta.41
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -804,11 +804,13 @@ var reasoningSummaryPartSchema = import_v44.z.object({
804
804
  text: import_v44.z.string()
805
805
  });
806
806
  var toolCallSchema = import_v44.z.object({
807
- name: import_v44.z.string(),
808
- arguments: import_v44.z.string(),
809
- call_id: import_v44.z.string(),
807
+ name: import_v44.z.string().optional(),
808
+ arguments: import_v44.z.string().optional(),
809
+ input: import_v44.z.string().optional(),
810
+ call_id: import_v44.z.string().optional(),
810
811
  id: import_v44.z.string(),
811
- status: import_v44.z.string()
812
+ status: import_v44.z.string(),
813
+ action: import_v44.z.any().optional()
812
814
  });
813
815
  var outputItemSchema = import_v44.z.discriminatedUnion("type", [
814
816
  import_v44.z.object({
@@ -835,6 +837,10 @@ var outputItemSchema = import_v44.z.discriminatedUnion("type", [
835
837
  type: import_v44.z.literal("view_x_video_call"),
836
838
  ...toolCallSchema.shape
837
839
  }),
840
+ import_v44.z.object({
841
+ type: import_v44.z.literal("custom_tool_call"),
842
+ ...toolCallSchema.shape
843
+ }),
838
844
  import_v44.z.object({
839
845
  type: import_v44.z.literal("message"),
840
846
  role: import_v44.z.string(),
@@ -964,6 +970,66 @@ var xaiResponsesChunkSchema = import_v44.z.union([
964
970
  summary_index: import_v44.z.number(),
965
971
  text: import_v44.z.string()
966
972
  }),
973
+ import_v44.z.object({
974
+ type: import_v44.z.literal("response.web_search_call.in_progress"),
975
+ item_id: import_v44.z.string(),
976
+ output_index: import_v44.z.number()
977
+ }),
978
+ import_v44.z.object({
979
+ type: import_v44.z.literal("response.web_search_call.searching"),
980
+ item_id: import_v44.z.string(),
981
+ output_index: import_v44.z.number()
982
+ }),
983
+ import_v44.z.object({
984
+ type: import_v44.z.literal("response.web_search_call.completed"),
985
+ item_id: import_v44.z.string(),
986
+ output_index: import_v44.z.number()
987
+ }),
988
+ import_v44.z.object({
989
+ type: import_v44.z.literal("response.x_search_call.in_progress"),
990
+ item_id: import_v44.z.string(),
991
+ output_index: import_v44.z.number()
992
+ }),
993
+ import_v44.z.object({
994
+ type: import_v44.z.literal("response.x_search_call.searching"),
995
+ item_id: import_v44.z.string(),
996
+ output_index: import_v44.z.number()
997
+ }),
998
+ import_v44.z.object({
999
+ type: import_v44.z.literal("response.x_search_call.completed"),
1000
+ item_id: import_v44.z.string(),
1001
+ output_index: import_v44.z.number()
1002
+ }),
1003
+ import_v44.z.object({
1004
+ type: import_v44.z.literal("response.code_execution_call.in_progress"),
1005
+ item_id: import_v44.z.string(),
1006
+ output_index: import_v44.z.number()
1007
+ }),
1008
+ import_v44.z.object({
1009
+ type: import_v44.z.literal("response.code_execution_call.executing"),
1010
+ item_id: import_v44.z.string(),
1011
+ output_index: import_v44.z.number()
1012
+ }),
1013
+ import_v44.z.object({
1014
+ type: import_v44.z.literal("response.code_execution_call.completed"),
1015
+ item_id: import_v44.z.string(),
1016
+ output_index: import_v44.z.number()
1017
+ }),
1018
+ import_v44.z.object({
1019
+ type: import_v44.z.literal("response.code_interpreter_call.in_progress"),
1020
+ item_id: import_v44.z.string(),
1021
+ output_index: import_v44.z.number()
1022
+ }),
1023
+ import_v44.z.object({
1024
+ type: import_v44.z.literal("response.code_interpreter_call.executing"),
1025
+ item_id: import_v44.z.string(),
1026
+ output_index: import_v44.z.number()
1027
+ }),
1028
+ import_v44.z.object({
1029
+ type: import_v44.z.literal("response.code_interpreter_call.completed"),
1030
+ item_id: import_v44.z.string(),
1031
+ output_index: import_v44.z.number()
1032
+ }),
967
1033
  import_v44.z.object({
968
1034
  type: import_v44.z.literal("response.done"),
969
1035
  response: xaiResponsesResponseSchema
@@ -1498,7 +1564,7 @@ var XaiResponsesLanguageModel = class {
1498
1564
  };
1499
1565
  }
1500
1566
  async doGenerate(options) {
1501
- var _a, _b, _c;
1567
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1502
1568
  const {
1503
1569
  args: body,
1504
1570
  warnings,
@@ -1534,20 +1600,21 @@ var XaiResponsesLanguageModel = class {
1534
1600
  "x_thread_fetch"
1535
1601
  ];
1536
1602
  for (const part of response.output) {
1537
- 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") {
1538
- let toolName = part.name;
1539
- if (webSearchSubTools.includes(part.name)) {
1603
+ 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") {
1604
+ let toolName = (_b = part.name) != null ? _b : "";
1605
+ if (webSearchSubTools.includes((_c = part.name) != null ? _c : "")) {
1540
1606
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1541
- } else if (xSearchSubTools.includes(part.name)) {
1607
+ } else if (xSearchSubTools.includes((_d = part.name) != null ? _d : "")) {
1542
1608
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1543
1609
  } else if (part.name === "code_execution") {
1544
1610
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1545
1611
  }
1612
+ const toolInput = part.type === "custom_tool_call" ? (_e = part.input) != null ? _e : "" : (_f = part.arguments) != null ? _f : "";
1546
1613
  content.push({
1547
1614
  type: "tool-call",
1548
1615
  toolCallId: part.id,
1549
1616
  toolName,
1550
- input: part.arguments,
1617
+ input: toolInput,
1551
1618
  providerExecuted: true
1552
1619
  });
1553
1620
  continue;
@@ -1569,7 +1636,7 @@ var XaiResponsesLanguageModel = class {
1569
1636
  sourceType: "url",
1570
1637
  id: this.config.generateId(),
1571
1638
  url: annotation.url,
1572
- title: (_b = annotation.title) != null ? _b : annotation.url
1639
+ title: (_g = annotation.title) != null ? _g : annotation.url
1573
1640
  });
1574
1641
  }
1575
1642
  }
@@ -1598,7 +1665,7 @@ var XaiResponsesLanguageModel = class {
1598
1665
  inputTokens: response.usage.input_tokens,
1599
1666
  outputTokens: response.usage.output_tokens,
1600
1667
  totalTokens: response.usage.total_tokens,
1601
- reasoningTokens: (_c = response.usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens
1668
+ reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens
1602
1669
  },
1603
1670
  request: { body },
1604
1671
  response: {
@@ -1650,7 +1717,7 @@ var XaiResponsesLanguageModel = class {
1650
1717
  controller.enqueue({ type: "stream-start", warnings });
1651
1718
  },
1652
1719
  transform(chunk, controller) {
1653
- var _a2, _b, _c, _d;
1720
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
1654
1721
  if (options.includeRawChunks) {
1655
1722
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1656
1723
  }
@@ -1752,7 +1819,7 @@ var XaiResponsesLanguageModel = class {
1752
1819
  }
1753
1820
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1754
1821
  const part = event.item;
1755
- 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") {
1822
+ 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") {
1756
1823
  if (!seenToolCalls.has(part.id)) {
1757
1824
  seenToolCalls.add(part.id);
1758
1825
  const webSearchSubTools = [
@@ -1766,14 +1833,15 @@ var XaiResponsesLanguageModel = class {
1766
1833
  "x_semantic_search",
1767
1834
  "x_thread_fetch"
1768
1835
  ];
1769
- let toolName = part.name;
1770
- if (webSearchSubTools.includes(part.name)) {
1836
+ let toolName = (_d = part.name) != null ? _d : "";
1837
+ if (webSearchSubTools.includes((_e = part.name) != null ? _e : "")) {
1771
1838
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1772
- } else if (xSearchSubTools.includes(part.name)) {
1839
+ } else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
1773
1840
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1774
1841
  } else if (part.name === "code_execution") {
1775
1842
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1776
1843
  }
1844
+ const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
1777
1845
  controller.enqueue({
1778
1846
  type: "tool-input-start",
1779
1847
  id: part.id,
@@ -1782,7 +1850,7 @@ var XaiResponsesLanguageModel = class {
1782
1850
  controller.enqueue({
1783
1851
  type: "tool-input-delta",
1784
1852
  id: part.id,
1785
- delta: part.arguments
1853
+ delta: toolInput
1786
1854
  });
1787
1855
  controller.enqueue({
1788
1856
  type: "tool-input-end",
@@ -1792,7 +1860,7 @@ var XaiResponsesLanguageModel = class {
1792
1860
  type: "tool-call",
1793
1861
  toolCallId: part.id,
1794
1862
  toolName,
1795
- input: part.arguments,
1863
+ input: toolInput,
1796
1864
  providerExecuted: true
1797
1865
  });
1798
1866
  }
@@ -1823,7 +1891,7 @@ var XaiResponsesLanguageModel = class {
1823
1891
  sourceType: "url",
1824
1892
  id: self.config.generateId(),
1825
1893
  url: annotation.url,
1826
- title: (_d = annotation.title) != null ? _d : annotation.url
1894
+ title: (_i = annotation.title) != null ? _i : annotation.url
1827
1895
  });
1828
1896
  }
1829
1897
  }
@@ -1931,7 +1999,7 @@ var xaiTools = {
1931
1999
  };
1932
2000
 
1933
2001
  // src/version.ts
1934
- var VERSION = true ? "3.0.0-beta.41" : "0.0.0-test";
2002
+ var VERSION = true ? "3.0.0-beta.43" : "0.0.0-test";
1935
2003
 
1936
2004
  // src/xai-provider.ts
1937
2005
  var xaiErrorStructure = {