@ai-sdk/xai 2.0.87 → 2.0.91
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 +30 -0
- package/dist/index.d.mts +56 -16
- package/dist/index.d.ts +56 -16
- package/dist/index.js +84 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -942,6 +942,29 @@ var toolCallSchema = z4.object({
|
|
|
942
942
|
status: z4.string(),
|
|
943
943
|
action: z4.any().optional()
|
|
944
944
|
});
|
|
945
|
+
var webSearchWireSourceSchema = z4.object({
|
|
946
|
+
type: z4.literal("url"),
|
|
947
|
+
url: z4.string()
|
|
948
|
+
});
|
|
949
|
+
var webSearchWireActionSchema = z4.discriminatedUnion("type", [
|
|
950
|
+
z4.object({
|
|
951
|
+
type: z4.literal("search"),
|
|
952
|
+
query: z4.string().nullish(),
|
|
953
|
+
queries: z4.array(z4.string()).nullish(),
|
|
954
|
+
sources: z4.array(z4.unknown()).nullish()
|
|
955
|
+
}),
|
|
956
|
+
z4.object({
|
|
957
|
+
type: z4.literal("open_page"),
|
|
958
|
+
url: z4.string().nullish(),
|
|
959
|
+
sources: z4.array(z4.unknown()).nullish()
|
|
960
|
+
}),
|
|
961
|
+
z4.object({
|
|
962
|
+
type: z4.literal("find_in_page"),
|
|
963
|
+
url: z4.string().nullish(),
|
|
964
|
+
pattern: z4.string().nullish(),
|
|
965
|
+
sources: z4.array(z4.unknown()).nullish()
|
|
966
|
+
})
|
|
967
|
+
]);
|
|
945
968
|
var outputItemSchema = z4.discriminatedUnion("type", [
|
|
946
969
|
z4.object({
|
|
947
970
|
type: z4.literal("web_search_call"),
|
|
@@ -1485,14 +1508,23 @@ var webSearchArgsSchema = lazySchema(
|
|
|
1485
1508
|
var webSearchOutputSchema = lazySchema(
|
|
1486
1509
|
() => zodSchema(
|
|
1487
1510
|
z6.object({
|
|
1488
|
-
|
|
1489
|
-
|
|
1511
|
+
action: z6.discriminatedUnion("type", [
|
|
1512
|
+
z6.object({
|
|
1513
|
+
type: z6.literal("search"),
|
|
1514
|
+
query: z6.string().optional(),
|
|
1515
|
+
queries: z6.array(z6.string()).optional()
|
|
1516
|
+
}),
|
|
1490
1517
|
z6.object({
|
|
1491
|
-
|
|
1492
|
-
url: z6.string()
|
|
1493
|
-
|
|
1518
|
+
type: z6.literal("openPage"),
|
|
1519
|
+
url: z6.string().nullish()
|
|
1520
|
+
}),
|
|
1521
|
+
z6.object({
|
|
1522
|
+
type: z6.literal("findInPage"),
|
|
1523
|
+
url: z6.string().nullish(),
|
|
1524
|
+
pattern: z6.string().nullish()
|
|
1494
1525
|
})
|
|
1495
|
-
)
|
|
1526
|
+
]).optional(),
|
|
1527
|
+
sources: z6.array(z6.object({ type: z6.literal("url"), url: z6.string() })).optional()
|
|
1496
1528
|
})
|
|
1497
1529
|
)
|
|
1498
1530
|
);
|
|
@@ -1900,6 +1932,14 @@ var XaiResponsesLanguageModel = class {
|
|
|
1900
1932
|
input: toolInput,
|
|
1901
1933
|
providerExecuted: true
|
|
1902
1934
|
});
|
|
1935
|
+
if (part.type === "web_search_call") {
|
|
1936
|
+
content.push({
|
|
1937
|
+
type: "tool-result",
|
|
1938
|
+
toolCallId: part.id,
|
|
1939
|
+
toolName,
|
|
1940
|
+
result: mapWebSearchAction(part.action)
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1903
1943
|
continue;
|
|
1904
1944
|
}
|
|
1905
1945
|
switch (part.type) {
|
|
@@ -2278,6 +2318,14 @@ var XaiResponsesLanguageModel = class {
|
|
|
2278
2318
|
providerExecuted: true
|
|
2279
2319
|
});
|
|
2280
2320
|
}
|
|
2321
|
+
if (event.type === "response.output_item.done") {
|
|
2322
|
+
controller.enqueue({
|
|
2323
|
+
type: "tool-result",
|
|
2324
|
+
toolCallId: part.id,
|
|
2325
|
+
toolName,
|
|
2326
|
+
result: part.type === "web_search_call" ? mapWebSearchAction(part.action) : {}
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2281
2329
|
return;
|
|
2282
2330
|
}
|
|
2283
2331
|
if (part.type === "message") {
|
|
@@ -2357,6 +2405,35 @@ var XaiResponsesLanguageModel = class {
|
|
|
2357
2405
|
};
|
|
2358
2406
|
}
|
|
2359
2407
|
};
|
|
2408
|
+
function mapWebSearchAction(action) {
|
|
2409
|
+
var _a;
|
|
2410
|
+
const parsed = webSearchWireActionSchema.safeParse(action);
|
|
2411
|
+
if (!parsed.success) return {};
|
|
2412
|
+
const a = parsed.data;
|
|
2413
|
+
const sources = (_a = a.sources) == null ? void 0 : _a.flatMap((s) => {
|
|
2414
|
+
const source = webSearchWireSourceSchema.safeParse(s);
|
|
2415
|
+
return source.success ? [source.data] : [];
|
|
2416
|
+
});
|
|
2417
|
+
const sourcesExtra = sources != null && sources.length > 0 ? { sources } : {};
|
|
2418
|
+
switch (a.type) {
|
|
2419
|
+
case "search":
|
|
2420
|
+
return {
|
|
2421
|
+
action: {
|
|
2422
|
+
type: "search",
|
|
2423
|
+
...a.query != null && { query: a.query },
|
|
2424
|
+
...a.queries != null && { queries: a.queries }
|
|
2425
|
+
},
|
|
2426
|
+
...sourcesExtra
|
|
2427
|
+
};
|
|
2428
|
+
case "open_page":
|
|
2429
|
+
return { action: { type: "openPage", url: a.url }, ...sourcesExtra };
|
|
2430
|
+
case "find_in_page":
|
|
2431
|
+
return {
|
|
2432
|
+
action: { type: "findInPage", url: a.url, pattern: a.pattern },
|
|
2433
|
+
...sourcesExtra
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2360
2437
|
|
|
2361
2438
|
// src/tool/code-execution.ts
|
|
2362
2439
|
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3 } from "@ai-sdk/provider-utils";
|
|
@@ -2414,7 +2491,7 @@ var xaiTools = {
|
|
|
2414
2491
|
};
|
|
2415
2492
|
|
|
2416
2493
|
// src/version.ts
|
|
2417
|
-
var VERSION = true ? "2.0.
|
|
2494
|
+
var VERSION = true ? "2.0.91" : "0.0.0-test";
|
|
2418
2495
|
|
|
2419
2496
|
// src/xai-provider.ts
|
|
2420
2497
|
var xaiErrorStructure = {
|