@ai-sdk/xai 3.0.30 → 3.0.32
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 +43 -9
- package/dist/index.d.ts +43 -9
- package/dist/index.js +214 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +200 -71
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +747 -0
- package/package.json +8 -4
- package/src/index.ts +1 -0
- package/src/responses/xai-responses-api.ts +79 -1
- package/src/responses/xai-responses-language-model.ts +30 -4
- package/src/responses/xai-responses-prepare-tools.test.ts +123 -0
- package/src/responses/xai-responses-prepare-tools.ts +12 -0
- package/src/tool/index.ts +3 -1
- package/src/tool/mcp-server.ts +66 -0
- package/src/tool/web-search.ts +1 -1
- package/src/tool/x-search.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1087,6 +1087,15 @@ var toolCallSchema = z4.object({
|
|
|
1087
1087
|
status: z4.string(),
|
|
1088
1088
|
action: z4.any().optional()
|
|
1089
1089
|
});
|
|
1090
|
+
var mcpCallSchema = z4.object({
|
|
1091
|
+
name: z4.string().optional(),
|
|
1092
|
+
arguments: z4.string().optional(),
|
|
1093
|
+
output: z4.string().optional(),
|
|
1094
|
+
error: z4.string().optional(),
|
|
1095
|
+
id: z4.string(),
|
|
1096
|
+
status: z4.string(),
|
|
1097
|
+
server_label: z4.string().optional()
|
|
1098
|
+
});
|
|
1090
1099
|
var outputItemSchema = z4.discriminatedUnion("type", [
|
|
1091
1100
|
z4.object({
|
|
1092
1101
|
type: z4.literal("web_search_call"),
|
|
@@ -1116,6 +1125,10 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
1116
1125
|
type: z4.literal("custom_tool_call"),
|
|
1117
1126
|
...toolCallSchema.shape
|
|
1118
1127
|
}),
|
|
1128
|
+
z4.object({
|
|
1129
|
+
type: z4.literal("mcp_call"),
|
|
1130
|
+
...mcpCallSchema.shape
|
|
1131
|
+
}),
|
|
1119
1132
|
z4.object({
|
|
1120
1133
|
type: z4.literal("message"),
|
|
1121
1134
|
role: z4.string(),
|
|
@@ -1334,6 +1347,62 @@ var xaiResponsesChunkSchema = z4.union([
|
|
|
1334
1347
|
output_index: z4.number(),
|
|
1335
1348
|
code: z4.string()
|
|
1336
1349
|
}),
|
|
1350
|
+
z4.object({
|
|
1351
|
+
type: z4.literal("response.custom_tool_call_input.delta"),
|
|
1352
|
+
item_id: z4.string(),
|
|
1353
|
+
output_index: z4.number(),
|
|
1354
|
+
delta: z4.string()
|
|
1355
|
+
}),
|
|
1356
|
+
z4.object({
|
|
1357
|
+
type: z4.literal("response.custom_tool_call_input.done"),
|
|
1358
|
+
item_id: z4.string(),
|
|
1359
|
+
output_index: z4.number(),
|
|
1360
|
+
input: z4.string()
|
|
1361
|
+
}),
|
|
1362
|
+
z4.object({
|
|
1363
|
+
type: z4.literal("response.mcp_call.in_progress"),
|
|
1364
|
+
item_id: z4.string(),
|
|
1365
|
+
output_index: z4.number()
|
|
1366
|
+
}),
|
|
1367
|
+
z4.object({
|
|
1368
|
+
type: z4.literal("response.mcp_call.executing"),
|
|
1369
|
+
item_id: z4.string(),
|
|
1370
|
+
output_index: z4.number()
|
|
1371
|
+
}),
|
|
1372
|
+
z4.object({
|
|
1373
|
+
type: z4.literal("response.mcp_call.completed"),
|
|
1374
|
+
item_id: z4.string(),
|
|
1375
|
+
output_index: z4.number()
|
|
1376
|
+
}),
|
|
1377
|
+
z4.object({
|
|
1378
|
+
type: z4.literal("response.mcp_call.failed"),
|
|
1379
|
+
item_id: z4.string(),
|
|
1380
|
+
output_index: z4.number()
|
|
1381
|
+
}),
|
|
1382
|
+
z4.object({
|
|
1383
|
+
type: z4.literal("response.mcp_call_arguments.delta"),
|
|
1384
|
+
item_id: z4.string(),
|
|
1385
|
+
output_index: z4.number(),
|
|
1386
|
+
delta: z4.string()
|
|
1387
|
+
}),
|
|
1388
|
+
z4.object({
|
|
1389
|
+
type: z4.literal("response.mcp_call_arguments.done"),
|
|
1390
|
+
item_id: z4.string(),
|
|
1391
|
+
output_index: z4.number(),
|
|
1392
|
+
arguments: z4.string().optional()
|
|
1393
|
+
}),
|
|
1394
|
+
z4.object({
|
|
1395
|
+
type: z4.literal("response.mcp_call_output.delta"),
|
|
1396
|
+
item_id: z4.string(),
|
|
1397
|
+
output_index: z4.number(),
|
|
1398
|
+
delta: z4.string()
|
|
1399
|
+
}),
|
|
1400
|
+
z4.object({
|
|
1401
|
+
type: z4.literal("response.mcp_call_output.done"),
|
|
1402
|
+
item_id: z4.string(),
|
|
1403
|
+
output_index: z4.number(),
|
|
1404
|
+
output: z4.string().optional()
|
|
1405
|
+
}),
|
|
1337
1406
|
z4.object({
|
|
1338
1407
|
type: z4.literal("response.done"),
|
|
1339
1408
|
response: xaiResponsesResponseSchema
|
|
@@ -1369,80 +1438,115 @@ import {
|
|
|
1369
1438
|
} from "@ai-sdk/provider";
|
|
1370
1439
|
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1371
1440
|
|
|
1372
|
-
// src/tool/
|
|
1441
|
+
// src/tool/mcp-server.ts
|
|
1373
1442
|
import {
|
|
1374
1443
|
createProviderToolFactoryWithOutputSchema,
|
|
1375
1444
|
lazySchema,
|
|
1376
1445
|
zodSchema
|
|
1377
1446
|
} from "@ai-sdk/provider-utils";
|
|
1378
1447
|
import { z as z6 } from "zod/v4";
|
|
1379
|
-
var
|
|
1448
|
+
var mcpServerArgsSchema = lazySchema(
|
|
1380
1449
|
() => zodSchema(
|
|
1381
1450
|
z6.object({
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1451
|
+
serverUrl: z6.string().describe("The URL of the MCP server"),
|
|
1452
|
+
serverLabel: z6.string().optional().describe("A label for the MCP server"),
|
|
1453
|
+
serverDescription: z6.string().optional().describe("Description of the MCP server"),
|
|
1454
|
+
allowedTools: z6.array(z6.string()).optional().describe("List of allowed tool names"),
|
|
1455
|
+
headers: z6.record(z6.string(), z6.string()).optional().describe("Custom headers to send"),
|
|
1456
|
+
authorization: z6.string().optional().describe("Authorization header value")
|
|
1385
1457
|
})
|
|
1386
1458
|
)
|
|
1387
1459
|
);
|
|
1388
|
-
var
|
|
1460
|
+
var mcpServerOutputSchema = lazySchema(
|
|
1389
1461
|
() => zodSchema(
|
|
1390
1462
|
z6.object({
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
title: z6.string(),
|
|
1395
|
-
url: z6.string(),
|
|
1396
|
-
snippet: z6.string()
|
|
1397
|
-
})
|
|
1398
|
-
)
|
|
1463
|
+
name: z6.string(),
|
|
1464
|
+
arguments: z6.string(),
|
|
1465
|
+
result: z6.unknown()
|
|
1399
1466
|
})
|
|
1400
1467
|
)
|
|
1401
1468
|
);
|
|
1402
|
-
var
|
|
1403
|
-
id: "xai.
|
|
1469
|
+
var mcpServerToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
1470
|
+
id: "xai.mcp",
|
|
1404
1471
|
inputSchema: lazySchema(() => zodSchema(z6.object({}))),
|
|
1405
|
-
outputSchema:
|
|
1472
|
+
outputSchema: mcpServerOutputSchema
|
|
1406
1473
|
});
|
|
1407
|
-
var
|
|
1474
|
+
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
1408
1475
|
|
|
1409
|
-
// src/tool/
|
|
1476
|
+
// src/tool/web-search.ts
|
|
1410
1477
|
import {
|
|
1411
1478
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1412
1479
|
lazySchema as lazySchema2,
|
|
1413
1480
|
zodSchema as zodSchema2
|
|
1414
1481
|
} from "@ai-sdk/provider-utils";
|
|
1415
1482
|
import { z as z7 } from "zod/v4";
|
|
1416
|
-
var
|
|
1483
|
+
var webSearchArgsSchema = lazySchema2(
|
|
1417
1484
|
() => zodSchema2(
|
|
1418
1485
|
z7.object({
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
toDate: z7.string().optional(),
|
|
1423
|
-
enableImageUnderstanding: z7.boolean().optional(),
|
|
1424
|
-
enableVideoUnderstanding: z7.boolean().optional()
|
|
1486
|
+
allowedDomains: z7.array(z7.string()).max(5).optional(),
|
|
1487
|
+
excludedDomains: z7.array(z7.string()).max(5).optional(),
|
|
1488
|
+
enableImageUnderstanding: z7.boolean().optional()
|
|
1425
1489
|
})
|
|
1426
1490
|
)
|
|
1427
1491
|
);
|
|
1428
|
-
var
|
|
1492
|
+
var webSearchOutputSchema = lazySchema2(
|
|
1429
1493
|
() => zodSchema2(
|
|
1430
1494
|
z7.object({
|
|
1431
1495
|
query: z7.string(),
|
|
1432
|
-
|
|
1496
|
+
sources: z7.array(
|
|
1433
1497
|
z7.object({
|
|
1434
|
-
|
|
1435
|
-
text: z7.string(),
|
|
1498
|
+
title: z7.string(),
|
|
1436
1499
|
url: z7.string(),
|
|
1437
|
-
|
|
1500
|
+
snippet: z7.string()
|
|
1438
1501
|
})
|
|
1439
1502
|
)
|
|
1440
1503
|
})
|
|
1441
1504
|
)
|
|
1442
1505
|
);
|
|
1443
|
-
var
|
|
1444
|
-
id: "xai.
|
|
1506
|
+
var webSearchToolFactory = createProviderToolFactoryWithOutputSchema2({
|
|
1507
|
+
id: "xai.web_search",
|
|
1445
1508
|
inputSchema: lazySchema2(() => zodSchema2(z7.object({}))),
|
|
1509
|
+
outputSchema: webSearchOutputSchema
|
|
1510
|
+
});
|
|
1511
|
+
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
1512
|
+
|
|
1513
|
+
// src/tool/x-search.ts
|
|
1514
|
+
import {
|
|
1515
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1516
|
+
lazySchema as lazySchema3,
|
|
1517
|
+
zodSchema as zodSchema3
|
|
1518
|
+
} from "@ai-sdk/provider-utils";
|
|
1519
|
+
import { z as z8 } from "zod/v4";
|
|
1520
|
+
var xSearchArgsSchema = lazySchema3(
|
|
1521
|
+
() => zodSchema3(
|
|
1522
|
+
z8.object({
|
|
1523
|
+
allowedXHandles: z8.array(z8.string()).max(10).optional(),
|
|
1524
|
+
excludedXHandles: z8.array(z8.string()).max(10).optional(),
|
|
1525
|
+
fromDate: z8.string().optional(),
|
|
1526
|
+
toDate: z8.string().optional(),
|
|
1527
|
+
enableImageUnderstanding: z8.boolean().optional(),
|
|
1528
|
+
enableVideoUnderstanding: z8.boolean().optional()
|
|
1529
|
+
})
|
|
1530
|
+
)
|
|
1531
|
+
);
|
|
1532
|
+
var xSearchOutputSchema = lazySchema3(
|
|
1533
|
+
() => zodSchema3(
|
|
1534
|
+
z8.object({
|
|
1535
|
+
query: z8.string(),
|
|
1536
|
+
posts: z8.array(
|
|
1537
|
+
z8.object({
|
|
1538
|
+
author: z8.string(),
|
|
1539
|
+
text: z8.string(),
|
|
1540
|
+
url: z8.string(),
|
|
1541
|
+
likes: z8.number()
|
|
1542
|
+
})
|
|
1543
|
+
)
|
|
1544
|
+
})
|
|
1545
|
+
)
|
|
1546
|
+
);
|
|
1547
|
+
var xSearchToolFactory = createProviderToolFactoryWithOutputSchema3({
|
|
1548
|
+
id: "xai.x_search",
|
|
1549
|
+
inputSchema: lazySchema3(() => zodSchema3(z8.object({}))),
|
|
1446
1550
|
outputSchema: xSearchOutputSchema
|
|
1447
1551
|
});
|
|
1448
1552
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -1517,8 +1621,18 @@ async function prepareResponsesTools({
|
|
|
1517
1621
|
break;
|
|
1518
1622
|
}
|
|
1519
1623
|
case "xai.mcp": {
|
|
1624
|
+
const args = await validateTypes({
|
|
1625
|
+
value: tool.args,
|
|
1626
|
+
schema: mcpServerArgsSchema
|
|
1627
|
+
});
|
|
1520
1628
|
xaiTools2.push({
|
|
1521
|
-
type: "mcp"
|
|
1629
|
+
type: "mcp",
|
|
1630
|
+
server_url: args.serverUrl,
|
|
1631
|
+
server_label: args.serverLabel,
|
|
1632
|
+
server_description: args.serverDescription,
|
|
1633
|
+
allowed_tools: args.allowedTools,
|
|
1634
|
+
headers: args.headers,
|
|
1635
|
+
authorization: args.authorization
|
|
1522
1636
|
});
|
|
1523
1637
|
break;
|
|
1524
1638
|
}
|
|
@@ -1650,7 +1764,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1650
1764
|
tools,
|
|
1651
1765
|
toolChoice
|
|
1652
1766
|
}) {
|
|
1653
|
-
var _a, _b, _c, _d, _e;
|
|
1767
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1654
1768
|
const warnings = [];
|
|
1655
1769
|
const options = (_a = await parseProviderOptions2({
|
|
1656
1770
|
provider: "xai",
|
|
@@ -1669,6 +1783,9 @@ var XaiResponsesLanguageModel = class {
|
|
|
1669
1783
|
const codeExecutionToolName = (_d = tools == null ? void 0 : tools.find(
|
|
1670
1784
|
(tool) => tool.type === "provider" && tool.id === "xai.code_execution"
|
|
1671
1785
|
)) == null ? void 0 : _d.name;
|
|
1786
|
+
const mcpToolName = (_e = tools == null ? void 0 : tools.find(
|
|
1787
|
+
(tool) => tool.type === "provider" && tool.id === "xai.mcp"
|
|
1788
|
+
)) == null ? void 0 : _e.name;
|
|
1672
1789
|
const { input, inputWarnings } = await convertToXaiResponsesInput({
|
|
1673
1790
|
prompt,
|
|
1674
1791
|
store: true
|
|
@@ -1695,7 +1812,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1695
1812
|
format: responseFormat.schema != null ? {
|
|
1696
1813
|
type: "json_schema",
|
|
1697
1814
|
strict: true,
|
|
1698
|
-
name: (
|
|
1815
|
+
name: (_f = responseFormat.name) != null ? _f : "response",
|
|
1699
1816
|
description: responseFormat.description,
|
|
1700
1817
|
schema: responseFormat.schema
|
|
1701
1818
|
} : { type: "json_object" }
|
|
@@ -1723,17 +1840,19 @@ var XaiResponsesLanguageModel = class {
|
|
|
1723
1840
|
warnings,
|
|
1724
1841
|
webSearchToolName,
|
|
1725
1842
|
xSearchToolName,
|
|
1726
|
-
codeExecutionToolName
|
|
1843
|
+
codeExecutionToolName,
|
|
1844
|
+
mcpToolName
|
|
1727
1845
|
};
|
|
1728
1846
|
}
|
|
1729
1847
|
async doGenerate(options) {
|
|
1730
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1848
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1731
1849
|
const {
|
|
1732
1850
|
args: body,
|
|
1733
1851
|
warnings,
|
|
1734
1852
|
webSearchToolName,
|
|
1735
1853
|
xSearchToolName,
|
|
1736
|
-
codeExecutionToolName
|
|
1854
|
+
codeExecutionToolName,
|
|
1855
|
+
mcpToolName
|
|
1737
1856
|
} = await this.getArgs(options);
|
|
1738
1857
|
const {
|
|
1739
1858
|
responseHeaders,
|
|
@@ -1763,7 +1882,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1763
1882
|
"x_thread_fetch"
|
|
1764
1883
|
];
|
|
1765
1884
|
for (const part of response.output) {
|
|
1766
|
-
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") {
|
|
1885
|
+
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" || part.type === "mcp_call") {
|
|
1767
1886
|
let toolName = (_b = part.name) != null ? _b : "";
|
|
1768
1887
|
if (webSearchSubTools.includes((_c = part.name) != null ? _c : "") || part.type === "web_search_call") {
|
|
1769
1888
|
toolName = webSearchToolName != null ? webSearchToolName : "web_search";
|
|
@@ -1771,8 +1890,10 @@ var XaiResponsesLanguageModel = class {
|
|
|
1771
1890
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
1772
1891
|
} else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
|
|
1773
1892
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
1893
|
+
} else if (part.type === "mcp_call") {
|
|
1894
|
+
toolName = (_e = mcpToolName != null ? mcpToolName : part.name) != null ? _e : "mcp";
|
|
1774
1895
|
}
|
|
1775
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
1896
|
+
const toolInput = part.type === "custom_tool_call" ? (_f = part.input) != null ? _f : "" : part.type === "mcp_call" ? (_g = part.arguments) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
|
|
1776
1897
|
content.push({
|
|
1777
1898
|
type: "tool-call",
|
|
1778
1899
|
toolCallId: part.id,
|
|
@@ -1799,7 +1920,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1799
1920
|
sourceType: "url",
|
|
1800
1921
|
id: this.config.generateId(),
|
|
1801
1922
|
url: annotation.url,
|
|
1802
|
-
title: (
|
|
1923
|
+
title: (_i = annotation.title) != null ? _i : annotation.url
|
|
1803
1924
|
});
|
|
1804
1925
|
}
|
|
1805
1926
|
}
|
|
@@ -1851,7 +1972,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1851
1972
|
content,
|
|
1852
1973
|
finishReason: {
|
|
1853
1974
|
unified: mapXaiResponsesFinishReason(response.status),
|
|
1854
|
-
raw: (
|
|
1975
|
+
raw: (_j = response.status) != null ? _j : void 0
|
|
1855
1976
|
},
|
|
1856
1977
|
usage: convertXaiResponsesUsage(response.usage),
|
|
1857
1978
|
request: { body },
|
|
@@ -1870,7 +1991,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
1870
1991
|
warnings,
|
|
1871
1992
|
webSearchToolName,
|
|
1872
1993
|
xSearchToolName,
|
|
1873
|
-
codeExecutionToolName
|
|
1994
|
+
codeExecutionToolName,
|
|
1995
|
+
mcpToolName
|
|
1874
1996
|
} = await this.getArgs(options);
|
|
1875
1997
|
const body = {
|
|
1876
1998
|
...args,
|
|
@@ -1904,7 +2026,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1904
2026
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1905
2027
|
},
|
|
1906
2028
|
transform(chunk, controller) {
|
|
1907
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2029
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1908
2030
|
if (options.includeRawChunks) {
|
|
1909
2031
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
1910
2032
|
}
|
|
@@ -2010,6 +2132,9 @@ var XaiResponsesLanguageModel = class {
|
|
|
2010
2132
|
}
|
|
2011
2133
|
return;
|
|
2012
2134
|
}
|
|
2135
|
+
if (event.type === "response.custom_tool_call_input.delta" || event.type === "response.custom_tool_call_input.done") {
|
|
2136
|
+
return;
|
|
2137
|
+
}
|
|
2013
2138
|
if (event.type === "response.output_item.added" || event.type === "response.output_item.done") {
|
|
2014
2139
|
const part = event.item;
|
|
2015
2140
|
if (part.type === "reasoning") {
|
|
@@ -2030,7 +2155,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2030
2155
|
}
|
|
2031
2156
|
return;
|
|
2032
2157
|
}
|
|
2033
|
-
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") {
|
|
2158
|
+
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" || part.type === "mcp_call") {
|
|
2034
2159
|
const webSearchSubTools = [
|
|
2035
2160
|
"web_search",
|
|
2036
2161
|
"web_search_with_snippets",
|
|
@@ -2049,8 +2174,10 @@ var XaiResponsesLanguageModel = class {
|
|
|
2049
2174
|
toolName = xSearchToolName != null ? xSearchToolName : "x_search";
|
|
2050
2175
|
} else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
|
|
2051
2176
|
toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
|
|
2177
|
+
} else if (part.type === "mcp_call") {
|
|
2178
|
+
toolName = (_f = mcpToolName != null ? mcpToolName : part.name) != null ? _f : "mcp";
|
|
2052
2179
|
}
|
|
2053
|
-
const toolInput = part.type === "custom_tool_call" ? (
|
|
2180
|
+
const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : part.type === "mcp_call" ? (_h = part.arguments) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
|
|
2054
2181
|
const shouldEmit = part.type === "custom_tool_call" ? event.type === "response.output_item.done" : !seenToolCalls.has(part.id);
|
|
2055
2182
|
if (shouldEmit && !seenToolCalls.has(part.id)) {
|
|
2056
2183
|
seenToolCalls.add(part.id);
|
|
@@ -2103,7 +2230,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2103
2230
|
sourceType: "url",
|
|
2104
2231
|
id: self.config.generateId(),
|
|
2105
2232
|
url: annotation.url,
|
|
2106
|
-
title: (
|
|
2233
|
+
title: (_j = annotation.title) != null ? _j : annotation.url
|
|
2107
2234
|
});
|
|
2108
2235
|
}
|
|
2109
2236
|
}
|
|
@@ -2156,44 +2283,44 @@ var XaiResponsesLanguageModel = class {
|
|
|
2156
2283
|
};
|
|
2157
2284
|
|
|
2158
2285
|
// src/tool/code-execution.ts
|
|
2159
|
-
import { createProviderToolFactoryWithOutputSchema as
|
|
2160
|
-
import { z as
|
|
2161
|
-
var codeExecutionOutputSchema =
|
|
2162
|
-
output:
|
|
2163
|
-
error:
|
|
2286
|
+
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4 } from "@ai-sdk/provider-utils";
|
|
2287
|
+
import { z as z9 } from "zod/v4";
|
|
2288
|
+
var codeExecutionOutputSchema = z9.object({
|
|
2289
|
+
output: z9.string().describe("the output of the code execution"),
|
|
2290
|
+
error: z9.string().optional().describe("any error that occurred")
|
|
2164
2291
|
});
|
|
2165
|
-
var codeExecutionToolFactory =
|
|
2292
|
+
var codeExecutionToolFactory = createProviderToolFactoryWithOutputSchema4({
|
|
2166
2293
|
id: "xai.code_execution",
|
|
2167
|
-
inputSchema:
|
|
2294
|
+
inputSchema: z9.object({}).describe("no input parameters"),
|
|
2168
2295
|
outputSchema: codeExecutionOutputSchema
|
|
2169
2296
|
});
|
|
2170
2297
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2171
2298
|
|
|
2172
2299
|
// src/tool/view-image.ts
|
|
2173
|
-
import { createProviderToolFactoryWithOutputSchema as
|
|
2174
|
-
import { z as
|
|
2175
|
-
var viewImageOutputSchema =
|
|
2176
|
-
description:
|
|
2177
|
-
objects:
|
|
2300
|
+
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
|
|
2301
|
+
import { z as z10 } from "zod/v4";
|
|
2302
|
+
var viewImageOutputSchema = z10.object({
|
|
2303
|
+
description: z10.string().describe("description of the image"),
|
|
2304
|
+
objects: z10.array(z10.string()).optional().describe("objects detected in the image")
|
|
2178
2305
|
});
|
|
2179
|
-
var viewImageToolFactory =
|
|
2306
|
+
var viewImageToolFactory = createProviderToolFactoryWithOutputSchema5({
|
|
2180
2307
|
id: "xai.view_image",
|
|
2181
|
-
inputSchema:
|
|
2308
|
+
inputSchema: z10.object({}).describe("no input parameters"),
|
|
2182
2309
|
outputSchema: viewImageOutputSchema
|
|
2183
2310
|
});
|
|
2184
2311
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2185
2312
|
|
|
2186
2313
|
// src/tool/view-x-video.ts
|
|
2187
|
-
import { createProviderToolFactoryWithOutputSchema as
|
|
2188
|
-
import { z as
|
|
2189
|
-
var viewXVideoOutputSchema =
|
|
2190
|
-
transcript:
|
|
2191
|
-
description:
|
|
2192
|
-
duration:
|
|
2314
|
+
import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6 } from "@ai-sdk/provider-utils";
|
|
2315
|
+
import { z as z11 } from "zod/v4";
|
|
2316
|
+
var viewXVideoOutputSchema = z11.object({
|
|
2317
|
+
transcript: z11.string().optional().describe("transcript of the video"),
|
|
2318
|
+
description: z11.string().describe("description of the video content"),
|
|
2319
|
+
duration: z11.number().optional().describe("duration in seconds")
|
|
2193
2320
|
});
|
|
2194
|
-
var viewXVideoToolFactory =
|
|
2321
|
+
var viewXVideoToolFactory = createProviderToolFactoryWithOutputSchema6({
|
|
2195
2322
|
id: "xai.view_x_video",
|
|
2196
|
-
inputSchema:
|
|
2323
|
+
inputSchema: z11.object({}).describe("no input parameters"),
|
|
2197
2324
|
outputSchema: viewXVideoOutputSchema
|
|
2198
2325
|
});
|
|
2199
2326
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2201,6 +2328,7 @@ var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
|
2201
2328
|
// src/tool/index.ts
|
|
2202
2329
|
var xaiTools = {
|
|
2203
2330
|
codeExecution,
|
|
2331
|
+
mcpServer,
|
|
2204
2332
|
viewImage,
|
|
2205
2333
|
viewXVideo,
|
|
2206
2334
|
webSearch,
|
|
@@ -2208,7 +2336,7 @@ var xaiTools = {
|
|
|
2208
2336
|
};
|
|
2209
2337
|
|
|
2210
2338
|
// src/version.ts
|
|
2211
|
-
var VERSION = true ? "3.0.
|
|
2339
|
+
var VERSION = true ? "3.0.32" : "0.0.0-test";
|
|
2212
2340
|
|
|
2213
2341
|
// src/xai-provider.ts
|
|
2214
2342
|
var xaiErrorStructure = {
|
|
@@ -2277,6 +2405,7 @@ export {
|
|
|
2277
2405
|
VERSION,
|
|
2278
2406
|
codeExecution,
|
|
2279
2407
|
createXai,
|
|
2408
|
+
mcpServer,
|
|
2280
2409
|
viewImage,
|
|
2281
2410
|
viewXVideo,
|
|
2282
2411
|
webSearch,
|