@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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1130,7 +1130,8 @@ var outputItemSchema = import_v44.z.discriminatedUnion("type", [
|
|
|
1130
1130
|
type: import_v44.z.literal("reasoning"),
|
|
1131
1131
|
id: import_v44.z.string(),
|
|
1132
1132
|
summary: import_v44.z.array(reasoningSummaryPartSchema),
|
|
1133
|
-
status: import_v44.z.string()
|
|
1133
|
+
status: import_v44.z.string(),
|
|
1134
|
+
encrypted_content: import_v44.z.string().nullish()
|
|
1134
1135
|
})
|
|
1135
1136
|
]);
|
|
1136
1137
|
var xaiResponsesUsageSchema = import_v44.z.object({
|
|
@@ -1801,6 +1802,32 @@ var XaiResponsesLanguageModel = class {
|
|
|
1801
1802
|
});
|
|
1802
1803
|
break;
|
|
1803
1804
|
}
|
|
1805
|
+
case "reasoning": {
|
|
1806
|
+
const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
|
|
1807
|
+
if (summaryTexts.length > 0) {
|
|
1808
|
+
const reasoningText = summaryTexts.join("");
|
|
1809
|
+
if (part.encrypted_content || part.id) {
|
|
1810
|
+
content.push({
|
|
1811
|
+
type: "reasoning",
|
|
1812
|
+
text: reasoningText,
|
|
1813
|
+
providerMetadata: {
|
|
1814
|
+
xai: {
|
|
1815
|
+
...part.encrypted_content && {
|
|
1816
|
+
reasoningEncryptedContent: part.encrypted_content
|
|
1817
|
+
},
|
|
1818
|
+
...part.id && { itemId: part.id }
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
} else {
|
|
1823
|
+
content.push({
|
|
1824
|
+
type: "reasoning",
|
|
1825
|
+
text: reasoningText
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
break;
|
|
1830
|
+
}
|
|
1804
1831
|
default: {
|
|
1805
1832
|
break;
|
|
1806
1833
|
}
|
|
@@ -1854,6 +1881,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1854
1881
|
let isFirstChunk = true;
|
|
1855
1882
|
const contentBlocks = {};
|
|
1856
1883
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
1884
|
+
const activeReasoning = {};
|
|
1857
1885
|
const self = this;
|
|
1858
1886
|
return {
|
|
1859
1887
|
stream: response.pipeThrough(
|
|
@@ -1862,7 +1890,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1862
1890
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1863
1891
|
},
|
|
1864
1892
|
transform(chunk, controller) {
|
|
1865
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1893
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1866
1894
|
if (options.includeRawChunks) {
|
|
1867
1895
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1868
1896
|
}
|
|
@@ -1885,7 +1913,12 @@ var XaiResponsesLanguageModel = class {
|
|
|
1885
1913
|
const blockId = `reasoning-${event.item_id}`;
|
|
1886
1914
|
controller.enqueue({
|
|
1887
1915
|
type: "reasoning-start",
|
|
1888
|
-
id: blockId
|
|
1916
|
+
id: blockId,
|
|
1917
|
+
providerMetadata: {
|
|
1918
|
+
xai: {
|
|
1919
|
+
itemId: event.item_id
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1889
1922
|
});
|
|
1890
1923
|
}
|
|
1891
1924
|
if (event.type === "response.reasoning_summary_text.delta") {
|
|
@@ -1893,16 +1926,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
1893
1926
|
controller.enqueue({
|
|
1894
1927
|
type: "reasoning-delta",
|
|
1895
1928
|
id: blockId,
|
|
1896
|
-
delta: event.delta
|
|
1929
|
+
delta: event.delta,
|
|
1930
|
+
providerMetadata: {
|
|
1931
|
+
xai: {
|
|
1932
|
+
itemId: event.item_id
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1897
1935
|
});
|
|
1898
1936
|
return;
|
|
1899
1937
|
}
|
|
1900
1938
|
if (event.type === "response.reasoning_summary_text.done") {
|
|
1901
|
-
|
|
1902
|
-
controller.enqueue({
|
|
1903
|
-
type: "reasoning-end",
|
|
1904
|
-
id: blockId
|
|
1905
|
-
});
|
|
1939
|
+
return;
|
|
1906
1940
|
}
|
|
1907
1941
|
if (event.type === "response.output_text.delta") {
|
|
1908
1942
|
const blockId = `text-${event.item_id}`;
|
|
@@ -1964,6 +1998,22 @@ var XaiResponsesLanguageModel = class {
|
|
|
1964
1998
|
}
|
|
1965
1999
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
1966
2000
|
const part = event.item;
|
|
2001
|
+
if (part.type === "reasoning") {
|
|
2002
|
+
if (event.type === "response.output_item.done") {
|
|
2003
|
+
controller.enqueue({
|
|
2004
|
+
type: "reasoning-end",
|
|
2005
|
+
id: `reasoning-${part.id}`,
|
|
2006
|
+
providerMetadata: {
|
|
2007
|
+
xai: {
|
|
2008
|
+
itemId: part.id,
|
|
2009
|
+
reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
delete activeReasoning[part.id];
|
|
2014
|
+
}
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
1967
2017
|
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") {
|
|
1968
2018
|
const webSearchSubTools = [
|
|
1969
2019
|
"web_search",
|
|
@@ -1976,15 +2026,15 @@ var XaiResponsesLanguageModel = class {
|
|
|
1976
2026
|
"x_semantic_search",
|
|
1977
2027
|
"x_thread_fetch"
|
|
1978
2028
|
];
|
|
1979
|
-
let toolName = (
|
|
1980
|
-
if (webSearchSubTools.includes((
|
|
2029
|
+
let toolName = (_d = part.name) != null ? _d : "";
|
|
2030
|
+
if (webSearchSubTools.includes((_e = part.name) != null ? _e : "") || part.type === "web_search_call") {
|
|
1981
2031
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1982
|
-
} else if (xSearchSubTools.includes((
|
|
2032
|
+
} else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "x_search_call") {
|
|
1983
2033
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1984
2034
|
} else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
|
|
1985
2035
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1986
2036
|
}
|
|
1987
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
2037
|
+
const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
|
|
1988
2038
|
const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
|
|
1989
2039
|
if (shouldEmit && !seenToolCalls.has(part.id)) {
|
|
1990
2040
|
seenToolCalls.add(part.id);
|
|
@@ -2037,7 +2087,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2037
2087
|
sourceType: "url",
|
|
2038
2088
|
id: self.config.generateId(),
|
|
2039
2089
|
url: annotation.url,
|
|
2040
|
-
title: (
|
|
2090
|
+
title: (_i = annotation.title) != null ? _i : annotation.url
|
|
2041
2091
|
});
|
|
2042
2092
|
}
|
|
2043
2093
|
}
|
|
@@ -2142,7 +2192,7 @@ var xaiTools = {
|
|
|
2142
2192
|
};
|
|
2143
2193
|
|
|
2144
2194
|
// src/version.ts
|
|
2145
|
-
var VERSION = true ? "3.0.
|
|
2195
|
+
var VERSION = true ? "3.0.15" : "0.0.0-test";
|
|
2146
2196
|
|
|
2147
2197
|
// src/xai-provider.ts
|
|
2148
2198
|
var xaiErrorStructure = {
|