@ai-sdk/xai 3.0.14 → 3.0.16

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
@@ -1125,7 +1125,8 @@ var outputItemSchema = z4.discriminatedUnion("type", [
1125
1125
  type: z4.literal("reasoning"),
1126
1126
  id: z4.string(),
1127
1127
  summary: z4.array(reasoningSummaryPartSchema),
1128
- status: z4.string()
1128
+ status: z4.string(),
1129
+ encrypted_content: z4.string().nullish()
1129
1130
  })
1130
1131
  ]);
1131
1132
  var xaiResponsesUsageSchema = z4.object({
@@ -1806,6 +1807,32 @@ var XaiResponsesLanguageModel = class {
1806
1807
  });
1807
1808
  break;
1808
1809
  }
1810
+ case "reasoning": {
1811
+ const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
1812
+ if (summaryTexts.length > 0) {
1813
+ const reasoningText = summaryTexts.join("");
1814
+ if (part.encrypted_content || part.id) {
1815
+ content.push({
1816
+ type: "reasoning",
1817
+ text: reasoningText,
1818
+ providerMetadata: {
1819
+ xai: {
1820
+ ...part.encrypted_content && {
1821
+ reasoningEncryptedContent: part.encrypted_content
1822
+ },
1823
+ ...part.id && { itemId: part.id }
1824
+ }
1825
+ }
1826
+ });
1827
+ } else {
1828
+ content.push({
1829
+ type: "reasoning",
1830
+ text: reasoningText
1831
+ });
1832
+ }
1833
+ }
1834
+ break;
1835
+ }
1809
1836
  default: {
1810
1837
  break;
1811
1838
  }
@@ -1859,6 +1886,7 @@ var XaiResponsesLanguageModel = class {
1859
1886
  let isFirstChunk = true;
1860
1887
  const contentBlocks = {};
1861
1888
  const seenToolCalls = /* @__PURE__ */ new Set();
1889
+ const activeReasoning = {};
1862
1890
  const self = this;
1863
1891
  return {
1864
1892
  stream: response.pipeThrough(
@@ -1890,7 +1918,12 @@ var XaiResponsesLanguageModel = class {
1890
1918
  const blockId = `reasoning-${event.item_id}`;
1891
1919
  controller.enqueue({
1892
1920
  type: "reasoning-start",
1893
- id: blockId
1921
+ id: blockId,
1922
+ providerMetadata: {
1923
+ xai: {
1924
+ itemId: event.item_id
1925
+ }
1926
+ }
1894
1927
  });
1895
1928
  }
1896
1929
  if (event.type === "response.reasoning_summary_text.delta") {
@@ -1898,16 +1931,17 @@ var XaiResponsesLanguageModel = class {
1898
1931
  controller.enqueue({
1899
1932
  type: "reasoning-delta",
1900
1933
  id: blockId,
1901
- delta: event.delta
1934
+ delta: event.delta,
1935
+ providerMetadata: {
1936
+ xai: {
1937
+ itemId: event.item_id
1938
+ }
1939
+ }
1902
1940
  });
1903
1941
  return;
1904
1942
  }
1905
1943
  if (event.type === "response.reasoning_summary_text.done") {
1906
- const blockId = `reasoning-${event.item_id}`;
1907
- controller.enqueue({
1908
- type: "reasoning-end",
1909
- id: blockId
1910
- });
1944
+ return;
1911
1945
  }
1912
1946
  if (event.type === "response.output_text.delta") {
1913
1947
  const blockId = `text-${event.item_id}`;
@@ -1969,6 +2003,24 @@ var XaiResponsesLanguageModel = class {
1969
2003
  }
1970
2004
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1971
2005
  const part = event.item;
2006
+ if (part.type === "reasoning") {
2007
+ if (event.type === "response.output_item.done") {
2008
+ controller.enqueue({
2009
+ type: "reasoning-end",
2010
+ id: `reasoning-${part.id}`,
2011
+ providerMetadata: {
2012
+ xai: {
2013
+ ...part.encrypted_content && {
2014
+ reasoningEncryptedContent: part.encrypted_content
2015
+ },
2016
+ ...part.id && { itemId: part.id }
2017
+ }
2018
+ }
2019
+ });
2020
+ delete activeReasoning[part.id];
2021
+ }
2022
+ return;
2023
+ }
1972
2024
  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") {
1973
2025
  const webSearchSubTools = [
1974
2026
  "web_search",
@@ -2147,7 +2199,7 @@ var xaiTools = {
2147
2199
  };
2148
2200
 
2149
2201
  // src/version.ts
2150
- var VERSION = true ? "3.0.14" : "0.0.0-test";
2202
+ var VERSION = true ? "3.0.16" : "0.0.0-test";
2151
2203
 
2152
2204
  // src/xai-provider.ts
2153
2205
  var xaiErrorStructure = {