@ai-sdk/xai 3.0.14 → 3.0.15
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 +6 -0
- package/dist/index.js +65 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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(
|
|
@@ -1867,7 +1895,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1867
1895
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1868
1896
|
},
|
|
1869
1897
|
transform(chunk, controller) {
|
|
1870
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1898
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1871
1899
|
if (options.includeRawChunks) {
|
|
1872
1900
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1873
1901
|
}
|
|
@@ -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
|
-
|
|
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,22 @@ 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
|
+
itemId: part.id,
|
|
2014
|
+
reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
delete activeReasoning[part.id];
|
|
2019
|
+
}
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
1972
2022
|
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
2023
|
const webSearchSubTools = [
|
|
1974
2024
|
"web_search",
|
|
@@ -1981,15 +2031,15 @@ var XaiResponsesLanguageModel = class {
|
|
|
1981
2031
|
"x_semantic_search",
|
|
1982
2032
|
"x_thread_fetch"
|
|
1983
2033
|
];
|
|
1984
|
-
let toolName = (
|
|
1985
|
-
if (webSearchSubTools.includes((
|
|
2034
|
+
let toolName = (_d = part.name) != null ? _d : "";
|
|
2035
|
+
if (webSearchSubTools.includes((_e = part.name) != null ? _e : "") || part.type === "web_search_call") {
|
|
1986
2036
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1987
|
-
} else if (xSearchSubTools.includes((
|
|
2037
|
+
} else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "x_search_call") {
|
|
1988
2038
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1989
2039
|
} else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
|
|
1990
2040
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1991
2041
|
}
|
|
1992
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
2042
|
+
const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
|
|
1993
2043
|
const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
|
|
1994
2044
|
if (shouldEmit && !seenToolCalls.has(part.id)) {
|
|
1995
2045
|
seenToolCalls.add(part.id);
|
|
@@ -2042,7 +2092,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2042
2092
|
sourceType: "url",
|
|
2043
2093
|
id: self.config.generateId(),
|
|
2044
2094
|
url: annotation.url,
|
|
2045
|
-
title: (
|
|
2095
|
+
title: (_i = annotation.title) != null ? _i : annotation.url
|
|
2046
2096
|
});
|
|
2047
2097
|
}
|
|
2048
2098
|
}
|
|
@@ -2147,7 +2197,7 @@ var xaiTools = {
|
|
|
2147
2197
|
};
|
|
2148
2198
|
|
|
2149
2199
|
// src/version.ts
|
|
2150
|
-
var VERSION = true ? "3.0.
|
|
2200
|
+
var VERSION = true ? "3.0.15" : "0.0.0-test";
|
|
2151
2201
|
|
|
2152
2202
|
// src/xai-provider.ts
|
|
2153
2203
|
var xaiErrorStructure = {
|