@ai-sdk/xai 2.0.44 → 2.0.46

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
+ ## 2.0.46
4
+
5
+ ### Patch Changes
6
+
7
+ - eed2ef1: fix(xai): add missing stream response schema and provider tool name parsing
8
+
9
+ ## 2.0.45
10
+
11
+ ### Patch Changes
12
+
13
+ - 9d16e4e: fix (provider/xai): use correct format for function tools
14
+
3
15
  ## 2.0.44
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1024,11 +1024,29 @@ var xaiResponsesChunkSchema = import_v44.z.union([
1024
1024
  item_id: import_v44.z.string(),
1025
1025
  output_index: import_v44.z.number()
1026
1026
  }),
1027
+ import_v44.z.object({
1028
+ type: import_v44.z.literal("response.code_interpreter_call.interpreting"),
1029
+ item_id: import_v44.z.string(),
1030
+ output_index: import_v44.z.number()
1031
+ }),
1027
1032
  import_v44.z.object({
1028
1033
  type: import_v44.z.literal("response.code_interpreter_call.completed"),
1029
1034
  item_id: import_v44.z.string(),
1030
1035
  output_index: import_v44.z.number()
1031
1036
  }),
1037
+ // Code interpreter code streaming events
1038
+ import_v44.z.object({
1039
+ type: import_v44.z.literal("response.code_interpreter_call_code.delta"),
1040
+ item_id: import_v44.z.string(),
1041
+ output_index: import_v44.z.number(),
1042
+ delta: import_v44.z.string()
1043
+ }),
1044
+ import_v44.z.object({
1045
+ type: import_v44.z.literal("response.code_interpreter_call_code.done"),
1046
+ item_id: import_v44.z.string(),
1047
+ output_index: import_v44.z.number(),
1048
+ code: import_v44.z.string()
1049
+ }),
1032
1050
  import_v44.z.object({
1033
1051
  type: import_v44.z.literal("response.done"),
1034
1052
  response: xaiResponsesResponseSchema
@@ -1376,11 +1394,9 @@ async function prepareResponsesTools({
1376
1394
  } else {
1377
1395
  xaiTools2.push({
1378
1396
  type: "function",
1379
- function: {
1380
- name: tool.name,
1381
- description: tool.description,
1382
- parameters: tool.inputSchema
1383
- }
1397
+ name: tool.name,
1398
+ description: tool.description,
1399
+ parameters: tool.inputSchema
1384
1400
  });
1385
1401
  }
1386
1402
  }
@@ -1598,11 +1614,11 @@ var XaiResponsesLanguageModel = class {
1598
1614
  for (const part of response.output) {
1599
1615
  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") {
1600
1616
  let toolName = (_b = part.name) != null ? _b : "";
1601
- if (webSearchSubTools.includes((_c = part.name) != null ? _c : "")) {
1617
+ if (webSearchSubTools.includes((_c = part.name) != null ? _c : "") || part.type === "web_search_call") {
1602
1618
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1603
- } else if (xSearchSubTools.includes((_d = part.name) != null ? _d : "")) {
1619
+ } else if (xSearchSubTools.includes((_d = part.name) != null ? _d : "") || part.type === "x_search_call") {
1604
1620
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1605
- } else if (part.name === "code_execution") {
1621
+ } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1606
1622
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1607
1623
  }
1608
1624
  const toolInput = part.type === "custom_tool_call" ? (_e = part.input) != null ? _e : "" : (_f = part.arguments) != null ? _f : "";
@@ -1832,11 +1848,11 @@ var XaiResponsesLanguageModel = class {
1832
1848
  "x_thread_fetch"
1833
1849
  ];
1834
1850
  let toolName = (_e = part.name) != null ? _e : "";
1835
- if (webSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
1851
+ if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
1836
1852
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1837
- } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "")) {
1853
+ } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
1838
1854
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1839
- } else if (part.name === "code_execution") {
1855
+ } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
1840
1856
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1841
1857
  }
1842
1858
  const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
@@ -1997,7 +2013,7 @@ var xaiTools = {
1997
2013
  };
1998
2014
 
1999
2015
  // src/version.ts
2000
- var VERSION = true ? "2.0.44" : "0.0.0-test";
2016
+ var VERSION = true ? "2.0.46" : "0.0.0-test";
2001
2017
 
2002
2018
  // src/xai-provider.ts
2003
2019
  var xaiErrorStructure = {