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

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
@@ -795,11 +795,13 @@ var reasoningSummaryPartSchema = z4.object({
795
795
  text: z4.string()
796
796
  });
797
797
  var toolCallSchema = z4.object({
798
- name: z4.string(),
799
- arguments: z4.string(),
800
- call_id: z4.string(),
798
+ name: z4.string().optional(),
799
+ arguments: z4.string().optional(),
800
+ input: z4.string().optional(),
801
+ call_id: z4.string().optional(),
801
802
  id: z4.string(),
802
- status: z4.string()
803
+ status: z4.string(),
804
+ action: z4.any().optional()
803
805
  });
804
806
  var outputItemSchema = z4.discriminatedUnion("type", [
805
807
  z4.object({
@@ -826,6 +828,10 @@ var outputItemSchema = z4.discriminatedUnion("type", [
826
828
  type: z4.literal("view_x_video_call"),
827
829
  ...toolCallSchema.shape
828
830
  }),
831
+ z4.object({
832
+ type: z4.literal("custom_tool_call"),
833
+ ...toolCallSchema.shape
834
+ }),
829
835
  z4.object({
830
836
  type: z4.literal("message"),
831
837
  role: z4.string(),
@@ -955,6 +961,66 @@ var xaiResponsesChunkSchema = z4.union([
955
961
  summary_index: z4.number(),
956
962
  text: z4.string()
957
963
  }),
964
+ z4.object({
965
+ type: z4.literal("response.web_search_call.in_progress"),
966
+ item_id: z4.string(),
967
+ output_index: z4.number()
968
+ }),
969
+ z4.object({
970
+ type: z4.literal("response.web_search_call.searching"),
971
+ item_id: z4.string(),
972
+ output_index: z4.number()
973
+ }),
974
+ z4.object({
975
+ type: z4.literal("response.web_search_call.completed"),
976
+ item_id: z4.string(),
977
+ output_index: z4.number()
978
+ }),
979
+ z4.object({
980
+ type: z4.literal("response.x_search_call.in_progress"),
981
+ item_id: z4.string(),
982
+ output_index: z4.number()
983
+ }),
984
+ z4.object({
985
+ type: z4.literal("response.x_search_call.searching"),
986
+ item_id: z4.string(),
987
+ output_index: z4.number()
988
+ }),
989
+ z4.object({
990
+ type: z4.literal("response.x_search_call.completed"),
991
+ item_id: z4.string(),
992
+ output_index: z4.number()
993
+ }),
994
+ z4.object({
995
+ type: z4.literal("response.code_execution_call.in_progress"),
996
+ item_id: z4.string(),
997
+ output_index: z4.number()
998
+ }),
999
+ z4.object({
1000
+ type: z4.literal("response.code_execution_call.executing"),
1001
+ item_id: z4.string(),
1002
+ output_index: z4.number()
1003
+ }),
1004
+ z4.object({
1005
+ type: z4.literal("response.code_execution_call.completed"),
1006
+ item_id: z4.string(),
1007
+ output_index: z4.number()
1008
+ }),
1009
+ z4.object({
1010
+ type: z4.literal("response.code_interpreter_call.in_progress"),
1011
+ item_id: z4.string(),
1012
+ output_index: z4.number()
1013
+ }),
1014
+ z4.object({
1015
+ type: z4.literal("response.code_interpreter_call.executing"),
1016
+ item_id: z4.string(),
1017
+ output_index: z4.number()
1018
+ }),
1019
+ z4.object({
1020
+ type: z4.literal("response.code_interpreter_call.completed"),
1021
+ item_id: z4.string(),
1022
+ output_index: z4.number()
1023
+ }),
958
1024
  z4.object({
959
1025
  type: z4.literal("response.done"),
960
1026
  response: xaiResponsesResponseSchema
@@ -1499,7 +1565,7 @@ var XaiResponsesLanguageModel = class {
1499
1565
  };
1500
1566
  }
1501
1567
  async doGenerate(options) {
1502
- var _a, _b, _c;
1568
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1503
1569
  const {
1504
1570
  args: body,
1505
1571
  warnings,
@@ -1535,20 +1601,21 @@ var XaiResponsesLanguageModel = class {
1535
1601
  "x_thread_fetch"
1536
1602
  ];
1537
1603
  for (const part of response.output) {
1538
- 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") {
1539
- let toolName = part.name;
1540
- if (webSearchSubTools.includes(part.name)) {
1604
+ 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") {
1605
+ let toolName = (_b = part.name) != null ? _b : "";
1606
+ if (webSearchSubTools.includes((_c = part.name) != null ? _c : "")) {
1541
1607
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1542
- } else if (xSearchSubTools.includes(part.name)) {
1608
+ } else if (xSearchSubTools.includes((_d = part.name) != null ? _d : "")) {
1543
1609
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1544
1610
  } else if (part.name === "code_execution") {
1545
1611
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1546
1612
  }
1613
+ const toolInput = part.type === "custom_tool_call" ? (_e = part.input) != null ? _e : "" : (_f = part.arguments) != null ? _f : "";
1547
1614
  content.push({
1548
1615
  type: "tool-call",
1549
1616
  toolCallId: part.id,
1550
1617
  toolName,
1551
- input: part.arguments,
1618
+ input: toolInput,
1552
1619
  providerExecuted: true
1553
1620
  });
1554
1621
  continue;
@@ -1570,7 +1637,7 @@ var XaiResponsesLanguageModel = class {
1570
1637
  sourceType: "url",
1571
1638
  id: this.config.generateId(),
1572
1639
  url: annotation.url,
1573
- title: (_b = annotation.title) != null ? _b : annotation.url
1640
+ title: (_g = annotation.title) != null ? _g : annotation.url
1574
1641
  });
1575
1642
  }
1576
1643
  }
@@ -1599,7 +1666,7 @@ var XaiResponsesLanguageModel = class {
1599
1666
  inputTokens: response.usage.input_tokens,
1600
1667
  outputTokens: response.usage.output_tokens,
1601
1668
  totalTokens: response.usage.total_tokens,
1602
- reasoningTokens: (_c = response.usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens
1669
+ reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens
1603
1670
  },
1604
1671
  request: { body },
1605
1672
  response: {
@@ -1651,7 +1718,7 @@ var XaiResponsesLanguageModel = class {
1651
1718
  controller.enqueue({ type: "stream-start", warnings });
1652
1719
  },
1653
1720
  transform(chunk, controller) {
1654
- var _a2, _b, _c, _d;
1721
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
1655
1722
  if (options.includeRawChunks) {
1656
1723
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1657
1724
  }
@@ -1753,7 +1820,7 @@ var XaiResponsesLanguageModel = class {
1753
1820
  }
1754
1821
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1755
1822
  const part = event.item;
1756
- 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") {
1823
+ 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") {
1757
1824
  if (!seenToolCalls.has(part.id)) {
1758
1825
  seenToolCalls.add(part.id);
1759
1826
  const webSearchSubTools = [
@@ -1767,14 +1834,15 @@ var XaiResponsesLanguageModel = class {
1767
1834
  "x_semantic_search",
1768
1835
  "x_thread_fetch"
1769
1836
  ];
1770
- let toolName = part.name;
1771
- if (webSearchSubTools.includes(part.name)) {
1837
+ let toolName = (_d = part.name) != null ? _d : "";
1838
+ if (webSearchSubTools.includes((_e = part.name) != null ? _e : "")) {
1772
1839
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1773
- } else if (xSearchSubTools.includes(part.name)) {
1840
+ } else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
1774
1841
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1775
1842
  } else if (part.name === "code_execution") {
1776
1843
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1777
1844
  }
1845
+ const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
1778
1846
  controller.enqueue({
1779
1847
  type: "tool-input-start",
1780
1848
  id: part.id,
@@ -1783,7 +1851,7 @@ var XaiResponsesLanguageModel = class {
1783
1851
  controller.enqueue({
1784
1852
  type: "tool-input-delta",
1785
1853
  id: part.id,
1786
- delta: part.arguments
1854
+ delta: toolInput
1787
1855
  });
1788
1856
  controller.enqueue({
1789
1857
  type: "tool-input-end",
@@ -1793,7 +1861,7 @@ var XaiResponsesLanguageModel = class {
1793
1861
  type: "tool-call",
1794
1862
  toolCallId: part.id,
1795
1863
  toolName,
1796
- input: part.arguments,
1864
+ input: toolInput,
1797
1865
  providerExecuted: true
1798
1866
  });
1799
1867
  }
@@ -1824,7 +1892,7 @@ var XaiResponsesLanguageModel = class {
1824
1892
  sourceType: "url",
1825
1893
  id: self.config.generateId(),
1826
1894
  url: annotation.url,
1827
- title: (_d = annotation.title) != null ? _d : annotation.url
1895
+ title: (_i = annotation.title) != null ? _i : annotation.url
1828
1896
  });
1829
1897
  }
1830
1898
  }
@@ -1932,7 +2000,7 @@ var xaiTools = {
1932
2000
  };
1933
2001
 
1934
2002
  // src/version.ts
1935
- var VERSION = true ? "3.0.0-beta.41" : "0.0.0-test";
2003
+ var VERSION = true ? "3.0.0-beta.42" : "0.0.0-test";
1936
2004
 
1937
2005
  // src/xai-provider.ts
1938
2006
  var xaiErrorStructure = {