@ai-sdk/xai 3.0.127 → 3.0.129

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/dist/index.mjs CHANGED
@@ -1437,6 +1437,29 @@ var toolCallSchema = z7.object({
1437
1437
  status: z7.string(),
1438
1438
  action: z7.any().optional()
1439
1439
  });
1440
+ var webSearchWireSourceSchema = z7.object({
1441
+ type: z7.literal("url"),
1442
+ url: z7.string()
1443
+ });
1444
+ var webSearchWireActionSchema = z7.discriminatedUnion("type", [
1445
+ z7.object({
1446
+ type: z7.literal("search"),
1447
+ query: z7.string().nullish(),
1448
+ queries: z7.array(z7.string()).nullish(),
1449
+ sources: z7.array(z7.unknown()).nullish()
1450
+ }),
1451
+ z7.object({
1452
+ type: z7.literal("open_page"),
1453
+ url: z7.string().nullish(),
1454
+ sources: z7.array(z7.unknown()).nullish()
1455
+ }),
1456
+ z7.object({
1457
+ type: z7.literal("find_in_page"),
1458
+ url: z7.string().nullish(),
1459
+ pattern: z7.string().nullish(),
1460
+ sources: z7.array(z7.unknown()).nullish()
1461
+ })
1462
+ ]);
1440
1463
  var mcpCallSchema = z7.object({
1441
1464
  name: z7.string().optional(),
1442
1465
  arguments: z7.string().optional(),
@@ -1966,14 +1989,23 @@ var webSearchArgsSchema = lazySchema3(
1966
1989
  var webSearchOutputSchema = lazySchema3(
1967
1990
  () => zodSchema3(
1968
1991
  z11.object({
1969
- query: z11.string(),
1970
- sources: z11.array(
1992
+ action: z11.discriminatedUnion("type", [
1993
+ z11.object({
1994
+ type: z11.literal("search"),
1995
+ query: z11.string().optional(),
1996
+ queries: z11.array(z11.string()).optional()
1997
+ }),
1971
1998
  z11.object({
1972
- title: z11.string(),
1973
- url: z11.string(),
1974
- snippet: z11.string()
1999
+ type: z11.literal("openPage"),
2000
+ url: z11.string().nullish()
2001
+ }),
2002
+ z11.object({
2003
+ type: z11.literal("findInPage"),
2004
+ url: z11.string().nullish(),
2005
+ pattern: z11.string().nullish()
1975
2006
  })
1976
- )
2007
+ ]).optional(),
2008
+ sources: z11.array(z11.object({ type: z11.literal("url"), url: z11.string() })).optional()
1977
2009
  })
1978
2010
  )
1979
2011
  );
@@ -2401,6 +2433,14 @@ var XaiResponsesLanguageModel = class {
2401
2433
  input: toolInput,
2402
2434
  providerExecuted: true
2403
2435
  });
2436
+ if (part.type === "web_search_call") {
2437
+ content.push({
2438
+ type: "tool-result",
2439
+ toolCallId: part.id,
2440
+ toolName,
2441
+ result: mapWebSearchAction(part.action)
2442
+ });
2443
+ }
2404
2444
  continue;
2405
2445
  }
2406
2446
  switch (part.type) {
@@ -2842,7 +2882,7 @@ var XaiResponsesLanguageModel = class {
2842
2882
  type: "tool-result",
2843
2883
  toolCallId: part.id,
2844
2884
  toolName,
2845
- result: {}
2885
+ result: part.type === "web_search_call" ? mapWebSearchAction(part.action) : {}
2846
2886
  });
2847
2887
  }
2848
2888
  return;
@@ -2939,6 +2979,35 @@ var XaiResponsesLanguageModel = class {
2939
2979
  };
2940
2980
  }
2941
2981
  };
2982
+ function mapWebSearchAction(action) {
2983
+ var _a;
2984
+ const parsed = webSearchWireActionSchema.safeParse(action);
2985
+ if (!parsed.success) return {};
2986
+ const a = parsed.data;
2987
+ const sources = (_a = a.sources) == null ? void 0 : _a.flatMap((s) => {
2988
+ const source = webSearchWireSourceSchema.safeParse(s);
2989
+ return source.success ? [source.data] : [];
2990
+ });
2991
+ const sourcesExtra = sources != null && sources.length > 0 ? { sources } : {};
2992
+ switch (a.type) {
2993
+ case "search":
2994
+ return {
2995
+ action: {
2996
+ type: "search",
2997
+ ...a.query != null && { query: a.query },
2998
+ ...a.queries != null && { queries: a.queries }
2999
+ },
3000
+ ...sourcesExtra
3001
+ };
3002
+ case "open_page":
3003
+ return { action: { type: "openPage", url: a.url }, ...sourcesExtra };
3004
+ case "find_in_page":
3005
+ return {
3006
+ action: { type: "findInPage", url: a.url, pattern: a.pattern },
3007
+ ...sourcesExtra
3008
+ };
3009
+ }
3010
+ }
2942
3011
 
2943
3012
  // src/tool/code-execution.ts
2944
3013
  import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
@@ -2995,7 +3064,7 @@ var xaiTools = {
2995
3064
  };
2996
3065
 
2997
3066
  // src/version.ts
2998
- var VERSION = true ? "3.0.127" : "0.0.0-test";
3067
+ var VERSION = true ? "3.0.129" : "0.0.0-test";
2999
3068
 
3000
3069
  // src/xai-video-model.ts
3001
3070
  import {