@ai-sdk/xai 2.0.51 → 2.0.52

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
@@ -937,7 +937,8 @@ var outputItemSchema = z4.discriminatedUnion("type", [
937
937
  type: z4.literal("reasoning"),
938
938
  id: z4.string(),
939
939
  summary: z4.array(reasoningSummaryPartSchema),
940
- status: z4.string()
940
+ status: z4.string(),
941
+ encrypted_content: z4.string().nullish()
941
942
  })
942
943
  ]);
943
944
  var xaiResponsesUsageSchema = z4.object({
@@ -1776,6 +1777,32 @@ var XaiResponsesLanguageModel = class {
1776
1777
  });
1777
1778
  break;
1778
1779
  }
1780
+ case "reasoning": {
1781
+ const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
1782
+ if (summaryTexts.length > 0) {
1783
+ const reasoningText = summaryTexts.join("");
1784
+ if (part.encrypted_content || part.id) {
1785
+ content.push({
1786
+ type: "reasoning",
1787
+ text: reasoningText,
1788
+ providerMetadata: {
1789
+ xai: {
1790
+ ...part.encrypted_content && {
1791
+ reasoningEncryptedContent: part.encrypted_content
1792
+ },
1793
+ ...part.id && { itemId: part.id }
1794
+ }
1795
+ }
1796
+ });
1797
+ } else {
1798
+ content.push({
1799
+ type: "reasoning",
1800
+ text: reasoningText
1801
+ });
1802
+ }
1803
+ }
1804
+ break;
1805
+ }
1779
1806
  default: {
1780
1807
  break;
1781
1808
  }
@@ -1833,6 +1860,7 @@ var XaiResponsesLanguageModel = class {
1833
1860
  let isFirstChunk = true;
1834
1861
  const contentBlocks = {};
1835
1862
  const seenToolCalls = /* @__PURE__ */ new Set();
1863
+ const activeReasoning = {};
1836
1864
  const self = this;
1837
1865
  return {
1838
1866
  stream: response.pipeThrough(
@@ -1864,7 +1892,12 @@ var XaiResponsesLanguageModel = class {
1864
1892
  const blockId = `reasoning-${event.item_id}`;
1865
1893
  controller.enqueue({
1866
1894
  type: "reasoning-start",
1867
- id: blockId
1895
+ id: blockId,
1896
+ providerMetadata: {
1897
+ xai: {
1898
+ itemId: event.item_id
1899
+ }
1900
+ }
1868
1901
  });
1869
1902
  }
1870
1903
  if (event.type === "response.reasoning_summary_text.delta") {
@@ -1872,16 +1905,17 @@ var XaiResponsesLanguageModel = class {
1872
1905
  controller.enqueue({
1873
1906
  type: "reasoning-delta",
1874
1907
  id: blockId,
1875
- delta: event.delta
1908
+ delta: event.delta,
1909
+ providerMetadata: {
1910
+ xai: {
1911
+ itemId: event.item_id
1912
+ }
1913
+ }
1876
1914
  });
1877
1915
  return;
1878
1916
  }
1879
1917
  if (event.type === "response.reasoning_summary_text.done") {
1880
- const blockId = `reasoning-${event.item_id}`;
1881
- controller.enqueue({
1882
- type: "reasoning-end",
1883
- id: blockId
1884
- });
1918
+ return;
1885
1919
  }
1886
1920
  if (event.type === "response.output_text.delta") {
1887
1921
  const blockId = `text-${event.item_id}`;
@@ -1944,6 +1978,24 @@ var XaiResponsesLanguageModel = class {
1944
1978
  }
1945
1979
  if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
1946
1980
  const part = event.item;
1981
+ if (part.type === "reasoning") {
1982
+ if (event.type === "response.output_item.done") {
1983
+ controller.enqueue({
1984
+ type: "reasoning-end",
1985
+ id: `reasoning-${part.id}`,
1986
+ providerMetadata: {
1987
+ xai: {
1988
+ ...part.encrypted_content && {
1989
+ reasoningEncryptedContent: part.encrypted_content
1990
+ },
1991
+ ...part.id && { itemId: part.id }
1992
+ }
1993
+ }
1994
+ });
1995
+ delete activeReasoning[part.id];
1996
+ }
1997
+ return;
1998
+ }
1947
1999
  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") {
1948
2000
  const webSearchSubTools = [
1949
2001
  "web_search",
@@ -2125,7 +2177,7 @@ var xaiTools = {
2125
2177
  };
2126
2178
 
2127
2179
  // src/version.ts
2128
- var VERSION = true ? "2.0.51" : "0.0.0-test";
2180
+ var VERSION = true ? "2.0.52" : "0.0.0-test";
2129
2181
 
2130
2182
  // src/xai-provider.ts
2131
2183
  var xaiErrorStructure = {