@ai-sdk/xai 2.0.36 → 2.0.38
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 +12 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +89 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -791,11 +791,13 @@ var reasoningSummaryPartSchema = z4.object({
|
|
|
791
791
|
text: z4.string()
|
|
792
792
|
});
|
|
793
793
|
var toolCallSchema = z4.object({
|
|
794
|
-
name: z4.string(),
|
|
795
|
-
arguments: z4.string(),
|
|
796
|
-
|
|
794
|
+
name: z4.string().optional(),
|
|
795
|
+
arguments: z4.string().optional(),
|
|
796
|
+
input: z4.string().optional(),
|
|
797
|
+
call_id: z4.string().optional(),
|
|
797
798
|
id: z4.string(),
|
|
798
|
-
status: z4.string()
|
|
799
|
+
status: z4.string(),
|
|
800
|
+
action: z4.any().optional()
|
|
799
801
|
});
|
|
800
802
|
var outputItemSchema = z4.discriminatedUnion("type", [
|
|
801
803
|
z4.object({
|
|
@@ -822,6 +824,10 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
822
824
|
type: z4.literal("view_x_video_call"),
|
|
823
825
|
...toolCallSchema.shape
|
|
824
826
|
}),
|
|
827
|
+
z4.object({
|
|
828
|
+
type: z4.literal("custom_tool_call"),
|
|
829
|
+
...toolCallSchema.shape
|
|
830
|
+
}),
|
|
825
831
|
z4.object({
|
|
826
832
|
type: z4.literal("message"),
|
|
827
833
|
role: z4.string(),
|
|
@@ -951,6 +957,66 @@ var xaiResponsesChunkSchema = z4.union([
|
|
|
951
957
|
summary_index: z4.number(),
|
|
952
958
|
text: z4.string()
|
|
953
959
|
}),
|
|
960
|
+
z4.object({
|
|
961
|
+
type: z4.literal("response.web_search_call.in_progress"),
|
|
962
|
+
item_id: z4.string(),
|
|
963
|
+
output_index: z4.number()
|
|
964
|
+
}),
|
|
965
|
+
z4.object({
|
|
966
|
+
type: z4.literal("response.web_search_call.searching"),
|
|
967
|
+
item_id: z4.string(),
|
|
968
|
+
output_index: z4.number()
|
|
969
|
+
}),
|
|
970
|
+
z4.object({
|
|
971
|
+
type: z4.literal("response.web_search_call.completed"),
|
|
972
|
+
item_id: z4.string(),
|
|
973
|
+
output_index: z4.number()
|
|
974
|
+
}),
|
|
975
|
+
z4.object({
|
|
976
|
+
type: z4.literal("response.x_search_call.in_progress"),
|
|
977
|
+
item_id: z4.string(),
|
|
978
|
+
output_index: z4.number()
|
|
979
|
+
}),
|
|
980
|
+
z4.object({
|
|
981
|
+
type: z4.literal("response.x_search_call.searching"),
|
|
982
|
+
item_id: z4.string(),
|
|
983
|
+
output_index: z4.number()
|
|
984
|
+
}),
|
|
985
|
+
z4.object({
|
|
986
|
+
type: z4.literal("response.x_search_call.completed"),
|
|
987
|
+
item_id: z4.string(),
|
|
988
|
+
output_index: z4.number()
|
|
989
|
+
}),
|
|
990
|
+
z4.object({
|
|
991
|
+
type: z4.literal("response.code_execution_call.in_progress"),
|
|
992
|
+
item_id: z4.string(),
|
|
993
|
+
output_index: z4.number()
|
|
994
|
+
}),
|
|
995
|
+
z4.object({
|
|
996
|
+
type: z4.literal("response.code_execution_call.executing"),
|
|
997
|
+
item_id: z4.string(),
|
|
998
|
+
output_index: z4.number()
|
|
999
|
+
}),
|
|
1000
|
+
z4.object({
|
|
1001
|
+
type: z4.literal("response.code_execution_call.completed"),
|
|
1002
|
+
item_id: z4.string(),
|
|
1003
|
+
output_index: z4.number()
|
|
1004
|
+
}),
|
|
1005
|
+
z4.object({
|
|
1006
|
+
type: z4.literal("response.code_interpreter_call.in_progress"),
|
|
1007
|
+
item_id: z4.string(),
|
|
1008
|
+
output_index: z4.number()
|
|
1009
|
+
}),
|
|
1010
|
+
z4.object({
|
|
1011
|
+
type: z4.literal("response.code_interpreter_call.executing"),
|
|
1012
|
+
item_id: z4.string(),
|
|
1013
|
+
output_index: z4.number()
|
|
1014
|
+
}),
|
|
1015
|
+
z4.object({
|
|
1016
|
+
type: z4.literal("response.code_interpreter_call.completed"),
|
|
1017
|
+
item_id: z4.string(),
|
|
1018
|
+
output_index: z4.number()
|
|
1019
|
+
}),
|
|
954
1020
|
z4.object({
|
|
955
1021
|
type: z4.literal("response.done"),
|
|
956
1022
|
response: xaiResponsesResponseSchema
|
|
@@ -1492,7 +1558,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1492
1558
|
};
|
|
1493
1559
|
}
|
|
1494
1560
|
async doGenerate(options) {
|
|
1495
|
-
var _a, _b, _c;
|
|
1561
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1496
1562
|
const {
|
|
1497
1563
|
args: body,
|
|
1498
1564
|
warnings,
|
|
@@ -1528,20 +1594,21 @@ var XaiResponsesLanguageModel = class {
|
|
|
1528
1594
|
"x_thread_fetch"
|
|
1529
1595
|
];
|
|
1530
1596
|
for (const part of response.output) {
|
|
1531
|
-
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") {
|
|
1532
|
-
let toolName = part.name;
|
|
1533
|
-
if (webSearchSubTools.includes(part.name)) {
|
|
1597
|
+
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") {
|
|
1598
|
+
let toolName = (_b = part.name) != null ? _b : "";
|
|
1599
|
+
if (webSearchSubTools.includes((_c = part.name) != null ? _c : "")) {
|
|
1534
1600
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1535
|
-
} else if (xSearchSubTools.includes(part.name)) {
|
|
1601
|
+
} else if (xSearchSubTools.includes((_d = part.name) != null ? _d : "")) {
|
|
1536
1602
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1537
1603
|
} else if (part.name === "code_execution") {
|
|
1538
1604
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1539
1605
|
}
|
|
1606
|
+
const toolInput = part.type === "custom_tool_call" ? (_e = part.input) != null ? _e : "" : (_f = part.arguments) != null ? _f : "";
|
|
1540
1607
|
content.push({
|
|
1541
1608
|
type: "tool-call",
|
|
1542
1609
|
toolCallId: part.id,
|
|
1543
1610
|
toolName,
|
|
1544
|
-
input:
|
|
1611
|
+
input: toolInput,
|
|
1545
1612
|
providerExecuted: true
|
|
1546
1613
|
});
|
|
1547
1614
|
continue;
|
|
@@ -1563,7 +1630,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1563
1630
|
sourceType: "url",
|
|
1564
1631
|
id: this.config.generateId(),
|
|
1565
1632
|
url: annotation.url,
|
|
1566
|
-
title: (
|
|
1633
|
+
title: (_g = annotation.title) != null ? _g : annotation.url
|
|
1567
1634
|
});
|
|
1568
1635
|
}
|
|
1569
1636
|
}
|
|
@@ -1592,7 +1659,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1592
1659
|
inputTokens: response.usage.input_tokens,
|
|
1593
1660
|
outputTokens: response.usage.output_tokens,
|
|
1594
1661
|
totalTokens: response.usage.total_tokens,
|
|
1595
|
-
reasoningTokens: (
|
|
1662
|
+
reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens
|
|
1596
1663
|
},
|
|
1597
1664
|
request: { body },
|
|
1598
1665
|
response: {
|
|
@@ -1644,7 +1711,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1644
1711
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1645
1712
|
},
|
|
1646
1713
|
transform(chunk, controller) {
|
|
1647
|
-
var _a2, _b, _c, _d;
|
|
1714
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1648
1715
|
if (options.includeRawChunks) {
|
|
1649
1716
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1650
1717
|
}
|
|
@@ -1746,7 +1813,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1746
1813
|
}
|
|
1747
1814
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
1748
1815
|
const part = event.item;
|
|
1749
|
-
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") {
|
|
1816
|
+
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") {
|
|
1750
1817
|
if (!seenToolCalls.has(part.id)) {
|
|
1751
1818
|
seenToolCalls.add(part.id);
|
|
1752
1819
|
const webSearchSubTools = [
|
|
@@ -1760,14 +1827,15 @@ var XaiResponsesLanguageModel = class {
|
|
|
1760
1827
|
"x_semantic_search",
|
|
1761
1828
|
"x_thread_fetch"
|
|
1762
1829
|
];
|
|
1763
|
-
let toolName = part.name;
|
|
1764
|
-
if (webSearchSubTools.includes(part.name)) {
|
|
1830
|
+
let toolName = (_d = part.name) != null ? _d : "";
|
|
1831
|
+
if (webSearchSubTools.includes((_e = part.name) != null ? _e : "")) {
|
|
1765
1832
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
1766
|
-
} else if (xSearchSubTools.includes(part.name)) {
|
|
1833
|
+
} else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
|
|
1767
1834
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1768
1835
|
} else if (part.name === "code_execution") {
|
|
1769
1836
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1770
1837
|
}
|
|
1838
|
+
const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
|
|
1771
1839
|
controller.enqueue({
|
|
1772
1840
|
type: "tool-input-start",
|
|
1773
1841
|
id: part.id,
|
|
@@ -1776,7 +1844,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1776
1844
|
controller.enqueue({
|
|
1777
1845
|
type: "tool-input-delta",
|
|
1778
1846
|
id: part.id,
|
|
1779
|
-
delta:
|
|
1847
|
+
delta: toolInput
|
|
1780
1848
|
});
|
|
1781
1849
|
controller.enqueue({
|
|
1782
1850
|
type: "tool-input-end",
|
|
@@ -1786,7 +1854,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1786
1854
|
type: "tool-call",
|
|
1787
1855
|
toolCallId: part.id,
|
|
1788
1856
|
toolName,
|
|
1789
|
-
input:
|
|
1857
|
+
input: toolInput,
|
|
1790
1858
|
providerExecuted: true
|
|
1791
1859
|
});
|
|
1792
1860
|
}
|
|
@@ -1817,7 +1885,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1817
1885
|
sourceType: "url",
|
|
1818
1886
|
id: self.config.generateId(),
|
|
1819
1887
|
url: annotation.url,
|
|
1820
|
-
title: (
|
|
1888
|
+
title: (_i = annotation.title) != null ? _i : annotation.url
|
|
1821
1889
|
});
|
|
1822
1890
|
}
|
|
1823
1891
|
}
|
|
@@ -1925,7 +1993,7 @@ var xaiTools = {
|
|
|
1925
1993
|
};
|
|
1926
1994
|
|
|
1927
1995
|
// src/version.ts
|
|
1928
|
-
var VERSION = true ? "2.0.
|
|
1996
|
+
var VERSION = true ? "2.0.38" : "0.0.0-test";
|
|
1929
1997
|
|
|
1930
1998
|
// src/xai-provider.ts
|
|
1931
1999
|
var xaiErrorStructure = {
|