@ai-sdk/xai 4.0.0-beta.34 → 4.0.0-beta.36

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.js CHANGED
@@ -1,50 +1,43 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- codeExecution: () => codeExecution,
25
- createXai: () => createXai,
26
- mcpServer: () => mcpServer,
27
- viewImage: () => viewImage,
28
- viewXVideo: () => viewXVideo,
29
- webSearch: () => webSearch,
30
- xSearch: () => xSearch,
31
- xai: () => xai,
32
- xaiTools: () => xaiTools
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
-
36
1
  // src/xai-provider.ts
37
- var import_provider7 = require("@ai-sdk/provider");
38
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId,
7
+ loadApiKey,
8
+ withoutTrailingSlash,
9
+ withUserAgentSuffix
10
+ } from "@ai-sdk/provider-utils";
39
11
 
40
12
  // src/xai-chat-language-model.ts
41
- var import_provider3 = require("@ai-sdk/provider");
42
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
43
- var import_v43 = require("zod/v4");
13
+ import {
14
+ APICallError
15
+ } from "@ai-sdk/provider";
16
+ import {
17
+ combineHeaders,
18
+ createEventSourceResponseHandler,
19
+ createJsonResponseHandler,
20
+ extractResponseHeaders,
21
+ isCustomReasoning,
22
+ mapReasoningToProviderEffort,
23
+ parseProviderOptions,
24
+ postJsonToApi,
25
+ safeParseJSON,
26
+ serializeModelOptions,
27
+ WORKFLOW_SERIALIZE,
28
+ WORKFLOW_DESERIALIZE
29
+ } from "@ai-sdk/provider-utils";
30
+ import { z as z3 } from "zod/v4";
44
31
 
45
32
  // src/convert-to-xai-chat-messages.ts
46
- var import_provider = require("@ai-sdk/provider");
47
- var import_provider_utils = require("@ai-sdk/provider-utils");
33
+ import {
34
+ UnsupportedFunctionalityError
35
+ } from "@ai-sdk/provider";
36
+ import {
37
+ convertToBase64,
38
+ isProviderReference,
39
+ resolveProviderReference
40
+ } from "@ai-sdk/provider-utils";
48
41
  function convertToXaiChatMessages(prompt) {
49
42
  var _a;
50
43
  const messages = [];
@@ -68,11 +61,11 @@ function convertToXaiChatMessages(prompt) {
68
61
  return { type: "text", text: part.text };
69
62
  }
70
63
  case "file": {
71
- if ((0, import_provider_utils.isProviderReference)(part.data)) {
64
+ if (isProviderReference(part.data)) {
72
65
  return {
73
66
  type: "file",
74
67
  file: {
75
- file_id: (0, import_provider_utils.resolveProviderReference)({
68
+ file_id: resolveProviderReference({
76
69
  reference: part.data,
77
70
  provider: "xai"
78
71
  })
@@ -84,11 +77,11 @@ function convertToXaiChatMessages(prompt) {
84
77
  return {
85
78
  type: "image_url",
86
79
  image_url: {
87
- url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`
80
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
88
81
  }
89
82
  };
90
83
  } else {
91
- throw new import_provider.UnsupportedFunctionalityError({
84
+ throw new UnsupportedFunctionalityError({
92
85
  functionality: `file part media type ${part.mediaType}`
93
86
  });
94
87
  }
@@ -220,79 +213,79 @@ function mapXaiFinishReason(finishReason) {
220
213
  }
221
214
 
222
215
  // src/xai-chat-options.ts
223
- var import_v4 = require("zod/v4");
224
- var webSourceSchema = import_v4.z.object({
225
- type: import_v4.z.literal("web"),
226
- country: import_v4.z.string().length(2).optional(),
227
- excludedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
228
- allowedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
229
- safeSearch: import_v4.z.boolean().optional()
216
+ import { z } from "zod/v4";
217
+ var webSourceSchema = z.object({
218
+ type: z.literal("web"),
219
+ country: z.string().length(2).optional(),
220
+ excludedWebsites: z.array(z.string()).max(5).optional(),
221
+ allowedWebsites: z.array(z.string()).max(5).optional(),
222
+ safeSearch: z.boolean().optional()
230
223
  });
231
- var xSourceSchema = import_v4.z.object({
232
- type: import_v4.z.literal("x"),
233
- excludedXHandles: import_v4.z.array(import_v4.z.string()).optional(),
234
- includedXHandles: import_v4.z.array(import_v4.z.string()).optional(),
235
- postFavoriteCount: import_v4.z.number().int().optional(),
236
- postViewCount: import_v4.z.number().int().optional(),
224
+ var xSourceSchema = z.object({
225
+ type: z.literal("x"),
226
+ excludedXHandles: z.array(z.string()).optional(),
227
+ includedXHandles: z.array(z.string()).optional(),
228
+ postFavoriteCount: z.number().int().optional(),
229
+ postViewCount: z.number().int().optional(),
237
230
  /**
238
231
  * @deprecated use `includedXHandles` instead
239
232
  */
240
- xHandles: import_v4.z.array(import_v4.z.string()).optional()
233
+ xHandles: z.array(z.string()).optional()
241
234
  });
242
- var newsSourceSchema = import_v4.z.object({
243
- type: import_v4.z.literal("news"),
244
- country: import_v4.z.string().length(2).optional(),
245
- excludedWebsites: import_v4.z.array(import_v4.z.string()).max(5).optional(),
246
- safeSearch: import_v4.z.boolean().optional()
235
+ var newsSourceSchema = z.object({
236
+ type: z.literal("news"),
237
+ country: z.string().length(2).optional(),
238
+ excludedWebsites: z.array(z.string()).max(5).optional(),
239
+ safeSearch: z.boolean().optional()
247
240
  });
248
- var rssSourceSchema = import_v4.z.object({
249
- type: import_v4.z.literal("rss"),
250
- links: import_v4.z.array(import_v4.z.string().url()).max(1)
241
+ var rssSourceSchema = z.object({
242
+ type: z.literal("rss"),
243
+ links: z.array(z.string().url()).max(1)
251
244
  // currently only supports one RSS link
252
245
  });
253
- var searchSourceSchema = import_v4.z.discriminatedUnion("type", [
246
+ var searchSourceSchema = z.discriminatedUnion("type", [
254
247
  webSourceSchema,
255
248
  xSourceSchema,
256
249
  newsSourceSchema,
257
250
  rssSourceSchema
258
251
  ]);
259
- var xaiLanguageModelChatOptions = import_v4.z.object({
260
- reasoningEffort: import_v4.z.enum(["low", "high"]).optional(),
261
- logprobs: import_v4.z.boolean().optional(),
262
- topLogprobs: import_v4.z.number().int().min(0).max(8).optional(),
252
+ var xaiLanguageModelChatOptions = z.object({
253
+ reasoningEffort: z.enum(["low", "high"]).optional(),
254
+ logprobs: z.boolean().optional(),
255
+ topLogprobs: z.number().int().min(0).max(8).optional(),
263
256
  /**
264
257
  * Whether to enable parallel function calling during tool use.
265
258
  * When true, the model can call multiple functions in parallel.
266
259
  * When false, the model will call functions sequentially.
267
260
  * Defaults to true.
268
261
  */
269
- parallel_function_calling: import_v4.z.boolean().optional(),
270
- searchParameters: import_v4.z.object({
262
+ parallel_function_calling: z.boolean().optional(),
263
+ searchParameters: z.object({
271
264
  /**
272
265
  * search mode preference
273
266
  * - "off": disables search completely
274
267
  * - "auto": model decides whether to search (default)
275
268
  * - "on": always enables search
276
269
  */
277
- mode: import_v4.z.enum(["off", "auto", "on"]),
270
+ mode: z.enum(["off", "auto", "on"]),
278
271
  /**
279
272
  * whether to return citations in the response
280
273
  * defaults to true
281
274
  */
282
- returnCitations: import_v4.z.boolean().optional(),
275
+ returnCitations: z.boolean().optional(),
283
276
  /**
284
277
  * start date for search data (ISO8601 format: YYYY-MM-DD)
285
278
  */
286
- fromDate: import_v4.z.string().optional(),
279
+ fromDate: z.string().optional(),
287
280
  /**
288
281
  * end date for search data (ISO8601 format: YYYY-MM-DD)
289
282
  */
290
- toDate: import_v4.z.string().optional(),
283
+ toDate: z.string().optional(),
291
284
  /**
292
285
  * maximum number of search results to consider
293
286
  * defaults to 20
294
287
  */
295
- maxSearchResults: import_v4.z.number().min(1).max(50).optional(),
288
+ maxSearchResults: z.number().min(1).max(50).optional(),
296
289
  /**
297
290
  * data sources to search from.
298
291
  * defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
@@ -300,28 +293,30 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
300
293
  * @example
301
294
  * sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
302
295
  */
303
- sources: import_v4.z.array(searchSourceSchema).optional()
296
+ sources: z.array(searchSourceSchema).optional()
304
297
  }).optional()
305
298
  });
306
299
 
307
300
  // src/xai-error.ts
308
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
309
- var import_v42 = require("zod/v4");
310
- var xaiErrorDataSchema = import_v42.z.object({
311
- error: import_v42.z.object({
312
- message: import_v42.z.string(),
313
- type: import_v42.z.string().nullish(),
314
- param: import_v42.z.any().nullish(),
315
- code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
301
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
302
+ import { z as z2 } from "zod/v4";
303
+ var xaiErrorDataSchema = z2.object({
304
+ error: z2.object({
305
+ message: z2.string(),
306
+ type: z2.string().nullish(),
307
+ param: z2.any().nullish(),
308
+ code: z2.union([z2.string(), z2.number()]).nullish()
316
309
  })
317
310
  });
318
- var xaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
311
+ var xaiFailedResponseHandler = createJsonErrorResponseHandler({
319
312
  errorSchema: xaiErrorDataSchema,
320
313
  errorToMessage: (data) => data.error.message
321
314
  });
322
315
 
323
316
  // src/xai-prepare-tools.ts
324
- var import_provider2 = require("@ai-sdk/provider");
317
+ import {
318
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
319
+ } from "@ai-sdk/provider";
325
320
  function prepareTools({
326
321
  tools,
327
322
  toolChoice
@@ -371,7 +366,7 @@ function prepareTools({
371
366
  };
372
367
  default: {
373
368
  const _exhaustiveCheck = type;
374
- throw new import_provider2.UnsupportedFunctionalityError({
369
+ throw new UnsupportedFunctionalityError2({
375
370
  functionality: `tool choice type: ${_exhaustiveCheck}`
376
371
  });
377
372
  }
@@ -379,7 +374,7 @@ function prepareTools({
379
374
  }
380
375
 
381
376
  // src/xai-chat-language-model.ts
382
- var XaiChatLanguageModel = class {
377
+ var XaiChatLanguageModel = class _XaiChatLanguageModel {
383
378
  constructor(modelId, config) {
384
379
  this.specificationVersion = "v4";
385
380
  this.supportedUrls = {
@@ -388,6 +383,15 @@ var XaiChatLanguageModel = class {
388
383
  this.modelId = modelId;
389
384
  this.config = config;
390
385
  }
386
+ static [WORKFLOW_SERIALIZE](model) {
387
+ return serializeModelOptions({
388
+ modelId: model.modelId,
389
+ config: model.config
390
+ });
391
+ }
392
+ static [WORKFLOW_DESERIALIZE](options) {
393
+ return new _XaiChatLanguageModel(options.modelId, options.config);
394
+ }
391
395
  get provider() {
392
396
  return this.config.provider;
393
397
  }
@@ -409,7 +413,7 @@ var XaiChatLanguageModel = class {
409
413
  }) {
410
414
  var _a, _b, _c, _d;
411
415
  const warnings = [];
412
- const options = (_a = await (0, import_provider_utils3.parseProviderOptions)({
416
+ const options = (_a = await parseProviderOptions({
413
417
  provider: "xai",
414
418
  providerOptions,
415
419
  schema: xaiLanguageModelChatOptions
@@ -447,7 +451,7 @@ var XaiChatLanguageModel = class {
447
451
  temperature,
448
452
  top_p: topP,
449
453
  seed,
450
- reasoning_effort: (_b = options.reasoningEffort) != null ? _b : (0, import_provider_utils3.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils3.mapReasoningToProviderEffort)({
454
+ reasoning_effort: (_b = options.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort({
451
455
  reasoning,
452
456
  effortMap: {
453
457
  minimal: "low",
@@ -515,26 +519,26 @@ var XaiChatLanguageModel = class {
515
519
  };
516
520
  }
517
521
  async doGenerate(options) {
518
- var _a, _b;
522
+ var _a, _b, _c, _d;
519
523
  const { args: body, warnings } = await this.getArgs(options);
520
524
  const url = `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/chat/completions`;
521
525
  const {
522
526
  responseHeaders,
523
527
  value: response,
524
528
  rawValue: rawResponse
525
- } = await (0, import_provider_utils3.postJsonToApi)({
529
+ } = await postJsonToApi({
526
530
  url,
527
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
531
+ headers: combineHeaders((_c = (_b = this.config).headers) == null ? void 0 : _c.call(_b), options.headers),
528
532
  body,
529
533
  failedResponseHandler: xaiFailedResponseHandler,
530
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
534
+ successfulResponseHandler: createJsonResponseHandler(
531
535
  xaiChatResponseSchema
532
536
  ),
533
537
  abortSignal: options.abortSignal,
534
538
  fetch: this.config.fetch
535
539
  });
536
540
  if (response.error != null) {
537
- throw new import_provider3.APICallError({
541
+ throw new APICallError({
538
542
  message: response.error,
539
543
  url,
540
544
  requestBodyValues: body,
@@ -586,7 +590,7 @@ var XaiChatLanguageModel = class {
586
590
  content,
587
591
  finishReason: {
588
592
  unified: mapXaiFinishReason(choice.finish_reason),
589
- raw: (_b = choice.finish_reason) != null ? _b : void 0
593
+ raw: (_d = choice.finish_reason) != null ? _d : void 0
590
594
  },
591
595
  usage: response.usage ? convertXaiChatUsage(response.usage) : {
592
596
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
@@ -602,7 +606,7 @@ var XaiChatLanguageModel = class {
602
606
  };
603
607
  }
604
608
  async doStream(options) {
605
- var _a;
609
+ var _a, _b, _c;
606
610
  const { args, warnings } = await this.getArgs(options);
607
611
  const body = {
608
612
  ...args,
@@ -612,22 +616,22 @@ var XaiChatLanguageModel = class {
612
616
  }
613
617
  };
614
618
  const url = `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/chat/completions`;
615
- const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
619
+ const { responseHeaders, value: response } = await postJsonToApi({
616
620
  url,
617
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
621
+ headers: combineHeaders((_c = (_b = this.config).headers) == null ? void 0 : _c.call(_b), options.headers),
618
622
  body,
619
623
  failedResponseHandler: xaiFailedResponseHandler,
620
624
  successfulResponseHandler: async ({ response: response2 }) => {
621
- const responseHeaders2 = (0, import_provider_utils3.extractResponseHeaders)(response2);
625
+ const responseHeaders2 = extractResponseHeaders(response2);
622
626
  const contentType = response2.headers.get("content-type");
623
627
  if (contentType == null ? void 0 : contentType.includes("application/json")) {
624
628
  const responseBody = await response2.text();
625
- const parsedError = await (0, import_provider_utils3.safeParseJSON)({
629
+ const parsedError = await safeParseJSON({
626
630
  text: responseBody,
627
631
  schema: xaiStreamErrorSchema
628
632
  });
629
633
  if (parsedError.success) {
630
- throw new import_provider3.APICallError({
634
+ throw new APICallError({
631
635
  message: parsedError.value.error,
632
636
  url,
633
637
  requestBodyValues: body,
@@ -637,7 +641,7 @@ var XaiChatLanguageModel = class {
637
641
  isRetryable: parsedError.value.code === "The service is currently unavailable"
638
642
  });
639
643
  }
640
- throw new import_provider3.APICallError({
644
+ throw new APICallError({
641
645
  message: "Invalid JSON response",
642
646
  url,
643
647
  requestBodyValues: body,
@@ -646,7 +650,7 @@ var XaiChatLanguageModel = class {
646
650
  responseBody
647
651
  });
648
652
  }
649
- return (0, import_provider_utils3.createEventSourceResponseHandler)(xaiChatChunkSchema)({
653
+ return createEventSourceResponseHandler(xaiChatChunkSchema)({
650
654
  response: response2,
651
655
  url,
652
656
  requestBodyValues: body
@@ -824,104 +828,116 @@ var XaiChatLanguageModel = class {
824
828
  };
825
829
  }
826
830
  };
827
- var xaiUsageSchema = import_v43.z.object({
828
- prompt_tokens: import_v43.z.number(),
829
- completion_tokens: import_v43.z.number(),
830
- total_tokens: import_v43.z.number(),
831
- prompt_tokens_details: import_v43.z.object({
832
- text_tokens: import_v43.z.number().nullish(),
833
- audio_tokens: import_v43.z.number().nullish(),
834
- image_tokens: import_v43.z.number().nullish(),
835
- cached_tokens: import_v43.z.number().nullish()
831
+ var xaiUsageSchema = z3.object({
832
+ prompt_tokens: z3.number(),
833
+ completion_tokens: z3.number(),
834
+ total_tokens: z3.number(),
835
+ prompt_tokens_details: z3.object({
836
+ text_tokens: z3.number().nullish(),
837
+ audio_tokens: z3.number().nullish(),
838
+ image_tokens: z3.number().nullish(),
839
+ cached_tokens: z3.number().nullish()
836
840
  }).nullish(),
837
- completion_tokens_details: import_v43.z.object({
838
- reasoning_tokens: import_v43.z.number().nullish(),
839
- audio_tokens: import_v43.z.number().nullish(),
840
- accepted_prediction_tokens: import_v43.z.number().nullish(),
841
- rejected_prediction_tokens: import_v43.z.number().nullish()
841
+ completion_tokens_details: z3.object({
842
+ reasoning_tokens: z3.number().nullish(),
843
+ audio_tokens: z3.number().nullish(),
844
+ accepted_prediction_tokens: z3.number().nullish(),
845
+ rejected_prediction_tokens: z3.number().nullish()
842
846
  }).nullish()
843
847
  });
844
- var xaiChatResponseSchema = import_v43.z.object({
845
- id: import_v43.z.string().nullish(),
846
- created: import_v43.z.number().nullish(),
847
- model: import_v43.z.string().nullish(),
848
- choices: import_v43.z.array(
849
- import_v43.z.object({
850
- message: import_v43.z.object({
851
- role: import_v43.z.literal("assistant"),
852
- content: import_v43.z.string().nullish(),
853
- reasoning_content: import_v43.z.string().nullish(),
854
- tool_calls: import_v43.z.array(
855
- import_v43.z.object({
856
- id: import_v43.z.string(),
857
- type: import_v43.z.literal("function"),
858
- function: import_v43.z.object({
859
- name: import_v43.z.string(),
860
- arguments: import_v43.z.string()
848
+ var xaiChatResponseSchema = z3.object({
849
+ id: z3.string().nullish(),
850
+ created: z3.number().nullish(),
851
+ model: z3.string().nullish(),
852
+ choices: z3.array(
853
+ z3.object({
854
+ message: z3.object({
855
+ role: z3.literal("assistant"),
856
+ content: z3.string().nullish(),
857
+ reasoning_content: z3.string().nullish(),
858
+ tool_calls: z3.array(
859
+ z3.object({
860
+ id: z3.string(),
861
+ type: z3.literal("function"),
862
+ function: z3.object({
863
+ name: z3.string(),
864
+ arguments: z3.string()
861
865
  })
862
866
  })
863
867
  ).nullish()
864
868
  }),
865
- index: import_v43.z.number(),
866
- finish_reason: import_v43.z.string().nullish()
869
+ index: z3.number(),
870
+ finish_reason: z3.string().nullish()
867
871
  })
868
872
  ).nullish(),
869
- object: import_v43.z.literal("chat.completion").nullish(),
873
+ object: z3.literal("chat.completion").nullish(),
870
874
  usage: xaiUsageSchema.nullish(),
871
- citations: import_v43.z.array(import_v43.z.string().url()).nullish(),
872
- code: import_v43.z.string().nullish(),
873
- error: import_v43.z.string().nullish()
875
+ citations: z3.array(z3.string().url()).nullish(),
876
+ code: z3.string().nullish(),
877
+ error: z3.string().nullish()
874
878
  });
875
- var xaiChatChunkSchema = import_v43.z.object({
876
- id: import_v43.z.string().nullish(),
877
- created: import_v43.z.number().nullish(),
878
- model: import_v43.z.string().nullish(),
879
- choices: import_v43.z.array(
880
- import_v43.z.object({
881
- delta: import_v43.z.object({
882
- role: import_v43.z.enum(["assistant"]).optional(),
883
- content: import_v43.z.string().nullish(),
884
- reasoning_content: import_v43.z.string().nullish(),
885
- tool_calls: import_v43.z.array(
886
- import_v43.z.object({
887
- id: import_v43.z.string(),
888
- type: import_v43.z.literal("function"),
889
- function: import_v43.z.object({
890
- name: import_v43.z.string(),
891
- arguments: import_v43.z.string()
879
+ var xaiChatChunkSchema = z3.object({
880
+ id: z3.string().nullish(),
881
+ created: z3.number().nullish(),
882
+ model: z3.string().nullish(),
883
+ choices: z3.array(
884
+ z3.object({
885
+ delta: z3.object({
886
+ role: z3.enum(["assistant"]).optional(),
887
+ content: z3.string().nullish(),
888
+ reasoning_content: z3.string().nullish(),
889
+ tool_calls: z3.array(
890
+ z3.object({
891
+ id: z3.string(),
892
+ type: z3.literal("function"),
893
+ function: z3.object({
894
+ name: z3.string(),
895
+ arguments: z3.string()
892
896
  })
893
897
  })
894
898
  ).nullish()
895
899
  }),
896
- finish_reason: import_v43.z.string().nullish(),
897
- index: import_v43.z.number()
900
+ finish_reason: z3.string().nullish(),
901
+ index: z3.number()
898
902
  })
899
903
  ),
900
904
  usage: xaiUsageSchema.nullish(),
901
- citations: import_v43.z.array(import_v43.z.string().url()).nullish()
905
+ citations: z3.array(z3.string().url()).nullish()
902
906
  });
903
- var xaiStreamErrorSchema = import_v43.z.object({
904
- code: import_v43.z.string(),
905
- error: import_v43.z.string()
907
+ var xaiStreamErrorSchema = z3.object({
908
+ code: z3.string(),
909
+ error: z3.string()
906
910
  });
907
911
 
908
912
  // src/xai-image-model.ts
909
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
910
- var import_v45 = require("zod/v4");
913
+ import {
914
+ combineHeaders as combineHeaders2,
915
+ convertImageModelFileToDataUri,
916
+ createBinaryResponseHandler,
917
+ createJsonResponseHandler as createJsonResponseHandler2,
918
+ createStatusCodeErrorResponseHandler,
919
+ getFromApi,
920
+ parseProviderOptions as parseProviderOptions2,
921
+ postJsonToApi as postJsonToApi2,
922
+ serializeModelOptions as serializeModelOptions2,
923
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
924
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
925
+ } from "@ai-sdk/provider-utils";
926
+ import { z as z5 } from "zod/v4";
911
927
 
912
928
  // src/xai-image-options.ts
913
- var import_v44 = require("zod/v4");
914
- var xaiImageModelOptions = import_v44.z.object({
915
- aspect_ratio: import_v44.z.string().optional(),
916
- output_format: import_v44.z.string().optional(),
917
- sync_mode: import_v44.z.boolean().optional(),
918
- resolution: import_v44.z.enum(["1k", "2k"]).optional(),
919
- quality: import_v44.z.enum(["low", "medium", "high"]).optional(),
920
- user: import_v44.z.string().optional()
929
+ import { z as z4 } from "zod/v4";
930
+ var xaiImageModelOptions = z4.object({
931
+ aspect_ratio: z4.string().optional(),
932
+ output_format: z4.string().optional(),
933
+ sync_mode: z4.boolean().optional(),
934
+ resolution: z4.enum(["1k", "2k"]).optional(),
935
+ quality: z4.enum(["low", "medium", "high"]).optional(),
936
+ user: z4.string().optional()
921
937
  });
922
938
 
923
939
  // src/xai-image-model.ts
924
- var XaiImageModel = class {
940
+ var XaiImageModel = class _XaiImageModel {
925
941
  constructor(modelId, config) {
926
942
  this.modelId = modelId;
927
943
  this.config = config;
@@ -931,6 +947,15 @@ var XaiImageModel = class {
931
947
  get provider() {
932
948
  return this.config.provider;
933
949
  }
950
+ static [WORKFLOW_SERIALIZE2](model) {
951
+ return serializeModelOptions2({
952
+ modelId: model.modelId,
953
+ config: model.config
954
+ });
955
+ }
956
+ static [WORKFLOW_DESERIALIZE2](options) {
957
+ return new _XaiImageModel(options.modelId, options.config);
958
+ }
934
959
  async doGenerate({
935
960
  prompt,
936
961
  n,
@@ -943,7 +968,7 @@ var XaiImageModel = class {
943
968
  files,
944
969
  mask
945
970
  }) {
946
- var _a, _b, _c, _d, _e;
971
+ var _a, _b, _c, _d, _e, _f, _g;
947
972
  const warnings = [];
948
973
  if (size != null) {
949
974
  warnings.push({
@@ -964,13 +989,13 @@ var XaiImageModel = class {
964
989
  feature: "mask"
965
990
  });
966
991
  }
967
- const xaiOptions = await (0, import_provider_utils4.parseProviderOptions)({
992
+ const xaiOptions = await parseProviderOptions2({
968
993
  provider: "xai",
969
994
  providerOptions,
970
995
  schema: xaiImageModelOptions
971
996
  });
972
997
  const hasFiles = files != null && files.length > 0;
973
- const imageUrls = hasFiles ? files.map((file) => (0, import_provider_utils4.convertImageModelFileToDataUri)(file)) : [];
998
+ const imageUrls = hasFiles ? files.map((file) => convertImageModelFileToDataUri(file)) : [];
974
999
  const endpoint = hasFiles ? "/images/edits" : "/images/generations";
975
1000
  const body = {
976
1001
  model: this.modelId,
@@ -1006,12 +1031,12 @@ var XaiImageModel = class {
1006
1031
  }
1007
1032
  const baseURL = (_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1";
1008
1033
  const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
1009
- const { value: response, responseHeaders } = await (0, import_provider_utils4.postJsonToApi)({
1034
+ const { value: response, responseHeaders } = await postJsonToApi2({
1010
1035
  url: `${baseURL}${endpoint}`,
1011
- headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
1036
+ headers: combineHeaders2((_f = (_e = this.config).headers) == null ? void 0 : _f.call(_e), headers),
1012
1037
  body,
1013
1038
  failedResponseHandler: xaiFailedResponseHandler,
1014
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1039
+ successfulResponseHandler: createJsonResponseHandler2(
1015
1040
  xaiImageResponseSchema
1016
1041
  ),
1017
1042
  abortSignal,
@@ -1036,41 +1061,58 @@ var XaiImageModel = class {
1036
1061
  images: response.data.map((item) => ({
1037
1062
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {}
1038
1063
  })),
1039
- ...((_e = response.usage) == null ? void 0 : _e.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {}
1064
+ ...((_g = response.usage) == null ? void 0 : _g.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {}
1040
1065
  }
1041
1066
  }
1042
1067
  };
1043
1068
  }
1044
1069
  async downloadImage(url, abortSignal) {
1045
- const { value } = await (0, import_provider_utils4.getFromApi)({
1070
+ const { value } = await getFromApi({
1046
1071
  url,
1047
1072
  abortSignal,
1048
- failedResponseHandler: (0, import_provider_utils4.createStatusCodeErrorResponseHandler)(),
1049
- successfulResponseHandler: (0, import_provider_utils4.createBinaryResponseHandler)(),
1073
+ failedResponseHandler: createStatusCodeErrorResponseHandler(),
1074
+ successfulResponseHandler: createBinaryResponseHandler(),
1050
1075
  fetch: this.config.fetch
1051
1076
  });
1052
1077
  return value;
1053
1078
  }
1054
1079
  };
1055
- var xaiImageResponseSchema = import_v45.z.object({
1056
- data: import_v45.z.array(
1057
- import_v45.z.object({
1058
- url: import_v45.z.string().nullish(),
1059
- b64_json: import_v45.z.string().nullish(),
1060
- revised_prompt: import_v45.z.string().nullish()
1080
+ var xaiImageResponseSchema = z5.object({
1081
+ data: z5.array(
1082
+ z5.object({
1083
+ url: z5.string().nullish(),
1084
+ b64_json: z5.string().nullish(),
1085
+ revised_prompt: z5.string().nullish()
1061
1086
  })
1062
1087
  ),
1063
- usage: import_v45.z.object({
1064
- cost_in_usd_ticks: import_v45.z.number().nullish()
1088
+ usage: z5.object({
1089
+ cost_in_usd_ticks: z5.number().nullish()
1065
1090
  }).nullish()
1066
1091
  });
1067
1092
 
1068
1093
  // src/responses/xai-responses-language-model.ts
1069
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1094
+ import {
1095
+ combineHeaders as combineHeaders3,
1096
+ createEventSourceResponseHandler as createEventSourceResponseHandler2,
1097
+ createJsonResponseHandler as createJsonResponseHandler3,
1098
+ isCustomReasoning as isCustomReasoning2,
1099
+ mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
1100
+ parseProviderOptions as parseProviderOptions3,
1101
+ postJsonToApi as postJsonToApi3,
1102
+ serializeModelOptions as serializeModelOptions3,
1103
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
1104
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
1105
+ } from "@ai-sdk/provider-utils";
1070
1106
 
1071
1107
  // src/responses/convert-to-xai-responses-input.ts
1072
- var import_provider4 = require("@ai-sdk/provider");
1073
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1108
+ import {
1109
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
1110
+ } from "@ai-sdk/provider";
1111
+ import {
1112
+ convertToBase64 as convertToBase642,
1113
+ isProviderReference as isProviderReference2,
1114
+ resolveProviderReference as resolveProviderReference2
1115
+ } from "@ai-sdk/provider-utils";
1074
1116
  async function convertToXaiResponsesInput({
1075
1117
  prompt
1076
1118
  }) {
@@ -1095,20 +1137,20 @@ async function convertToXaiResponsesInput({
1095
1137
  break;
1096
1138
  }
1097
1139
  case "file": {
1098
- if ((0, import_provider_utils5.isProviderReference)(block.data)) {
1140
+ if (isProviderReference2(block.data)) {
1099
1141
  contentParts.push({
1100
1142
  type: "input_file",
1101
- file_id: (0, import_provider_utils5.resolveProviderReference)({
1143
+ file_id: resolveProviderReference2({
1102
1144
  reference: block.data,
1103
1145
  provider: "xai"
1104
1146
  })
1105
1147
  });
1106
1148
  } else if (block.mediaType.startsWith("image/")) {
1107
1149
  const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
1108
- const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
1150
+ const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${convertToBase642(block.data)}`;
1109
1151
  contentParts.push({ type: "input_image", image_url: imageUrl });
1110
1152
  } else {
1111
- throw new import_provider4.UnsupportedFunctionalityError({
1153
+ throw new UnsupportedFunctionalityError3({
1112
1154
  functionality: `file part media type ${block.mediaType}`
1113
1155
  });
1114
1156
  }
@@ -1274,594 +1316,612 @@ function mapXaiResponsesFinishReason(finishReason) {
1274
1316
  }
1275
1317
 
1276
1318
  // src/responses/xai-responses-api.ts
1277
- var import_v46 = require("zod/v4");
1278
- var annotationSchema = import_v46.z.union([
1279
- import_v46.z.object({
1280
- type: import_v46.z.literal("url_citation"),
1281
- url: import_v46.z.string(),
1282
- title: import_v46.z.string().optional()
1319
+ import { z as z6 } from "zod/v4";
1320
+ var annotationSchema = z6.union([
1321
+ z6.object({
1322
+ type: z6.literal("url_citation"),
1323
+ url: z6.string(),
1324
+ title: z6.string().optional()
1283
1325
  }),
1284
- import_v46.z.object({
1285
- type: import_v46.z.string()
1326
+ z6.object({
1327
+ type: z6.string()
1286
1328
  })
1287
1329
  ]);
1288
- var messageContentPartSchema = import_v46.z.object({
1289
- type: import_v46.z.string(),
1290
- text: import_v46.z.string().optional(),
1291
- logprobs: import_v46.z.array(import_v46.z.any()).optional(),
1292
- annotations: import_v46.z.array(annotationSchema).optional()
1330
+ var messageContentPartSchema = z6.object({
1331
+ type: z6.string(),
1332
+ text: z6.string().optional(),
1333
+ logprobs: z6.array(z6.any()).optional(),
1334
+ annotations: z6.array(annotationSchema).optional()
1293
1335
  });
1294
- var reasoningSummaryPartSchema = import_v46.z.object({
1295
- type: import_v46.z.string(),
1296
- text: import_v46.z.string()
1336
+ var reasoningSummaryPartSchema = z6.object({
1337
+ type: z6.string(),
1338
+ text: z6.string()
1297
1339
  });
1298
- var toolCallSchema = import_v46.z.object({
1299
- name: import_v46.z.string().optional(),
1300
- arguments: import_v46.z.string().optional(),
1301
- input: import_v46.z.string().optional(),
1302
- call_id: import_v46.z.string().optional(),
1303
- id: import_v46.z.string(),
1304
- status: import_v46.z.string(),
1305
- action: import_v46.z.any().optional()
1340
+ var toolCallSchema = z6.object({
1341
+ name: z6.string().optional(),
1342
+ arguments: z6.string().optional(),
1343
+ input: z6.string().optional(),
1344
+ call_id: z6.string().optional(),
1345
+ id: z6.string(),
1346
+ status: z6.string(),
1347
+ action: z6.any().optional()
1306
1348
  });
1307
- var mcpCallSchema = import_v46.z.object({
1308
- name: import_v46.z.string().optional(),
1309
- arguments: import_v46.z.string().optional(),
1310
- output: import_v46.z.string().optional(),
1311
- error: import_v46.z.string().optional(),
1312
- id: import_v46.z.string(),
1313
- status: import_v46.z.string(),
1314
- server_label: import_v46.z.string().optional()
1349
+ var mcpCallSchema = z6.object({
1350
+ name: z6.string().optional(),
1351
+ arguments: z6.string().optional(),
1352
+ output: z6.string().optional(),
1353
+ error: z6.string().optional(),
1354
+ id: z6.string(),
1355
+ status: z6.string(),
1356
+ server_label: z6.string().optional()
1315
1357
  });
1316
- var outputItemSchema = import_v46.z.discriminatedUnion("type", [
1317
- import_v46.z.object({
1318
- type: import_v46.z.literal("web_search_call"),
1358
+ var outputItemSchema = z6.discriminatedUnion("type", [
1359
+ z6.object({
1360
+ type: z6.literal("web_search_call"),
1319
1361
  ...toolCallSchema.shape
1320
1362
  }),
1321
- import_v46.z.object({
1322
- type: import_v46.z.literal("x_search_call"),
1363
+ z6.object({
1364
+ type: z6.literal("x_search_call"),
1323
1365
  ...toolCallSchema.shape
1324
1366
  }),
1325
- import_v46.z.object({
1326
- type: import_v46.z.literal("code_interpreter_call"),
1367
+ z6.object({
1368
+ type: z6.literal("code_interpreter_call"),
1327
1369
  ...toolCallSchema.shape
1328
1370
  }),
1329
- import_v46.z.object({
1330
- type: import_v46.z.literal("code_execution_call"),
1371
+ z6.object({
1372
+ type: z6.literal("code_execution_call"),
1331
1373
  ...toolCallSchema.shape
1332
1374
  }),
1333
- import_v46.z.object({
1334
- type: import_v46.z.literal("view_image_call"),
1375
+ z6.object({
1376
+ type: z6.literal("view_image_call"),
1335
1377
  ...toolCallSchema.shape
1336
1378
  }),
1337
- import_v46.z.object({
1338
- type: import_v46.z.literal("view_x_video_call"),
1379
+ z6.object({
1380
+ type: z6.literal("view_x_video_call"),
1339
1381
  ...toolCallSchema.shape
1340
1382
  }),
1341
- import_v46.z.object({
1342
- type: import_v46.z.literal("file_search_call"),
1343
- id: import_v46.z.string(),
1344
- status: import_v46.z.string(),
1345
- queries: import_v46.z.array(import_v46.z.string()).optional(),
1346
- results: import_v46.z.array(
1347
- import_v46.z.object({
1348
- file_id: import_v46.z.string(),
1349
- filename: import_v46.z.string(),
1350
- score: import_v46.z.number(),
1351
- text: import_v46.z.string()
1383
+ z6.object({
1384
+ type: z6.literal("file_search_call"),
1385
+ id: z6.string(),
1386
+ status: z6.string(),
1387
+ queries: z6.array(z6.string()).optional(),
1388
+ results: z6.array(
1389
+ z6.object({
1390
+ file_id: z6.string(),
1391
+ filename: z6.string(),
1392
+ score: z6.number(),
1393
+ text: z6.string()
1352
1394
  })
1353
1395
  ).nullish()
1354
1396
  }),
1355
- import_v46.z.object({
1356
- type: import_v46.z.literal("custom_tool_call"),
1397
+ z6.object({
1398
+ type: z6.literal("custom_tool_call"),
1357
1399
  ...toolCallSchema.shape
1358
1400
  }),
1359
- import_v46.z.object({
1360
- type: import_v46.z.literal("mcp_call"),
1401
+ z6.object({
1402
+ type: z6.literal("mcp_call"),
1361
1403
  ...mcpCallSchema.shape
1362
1404
  }),
1363
- import_v46.z.object({
1364
- type: import_v46.z.literal("message"),
1365
- role: import_v46.z.string(),
1366
- content: import_v46.z.array(messageContentPartSchema),
1367
- id: import_v46.z.string(),
1368
- status: import_v46.z.string()
1405
+ z6.object({
1406
+ type: z6.literal("message"),
1407
+ role: z6.string(),
1408
+ content: z6.array(messageContentPartSchema),
1409
+ id: z6.string(),
1410
+ status: z6.string()
1369
1411
  }),
1370
- import_v46.z.object({
1371
- type: import_v46.z.literal("function_call"),
1372
- name: import_v46.z.string(),
1373
- arguments: import_v46.z.string(),
1374
- call_id: import_v46.z.string(),
1375
- id: import_v46.z.string()
1412
+ z6.object({
1413
+ type: z6.literal("function_call"),
1414
+ name: z6.string(),
1415
+ arguments: z6.string(),
1416
+ call_id: z6.string(),
1417
+ id: z6.string()
1376
1418
  }),
1377
- import_v46.z.object({
1378
- type: import_v46.z.literal("reasoning"),
1379
- id: import_v46.z.string(),
1380
- summary: import_v46.z.array(reasoningSummaryPartSchema),
1381
- content: import_v46.z.array(import_v46.z.object({ type: import_v46.z.string(), text: import_v46.z.string() })).nullish(),
1382
- status: import_v46.z.string(),
1383
- encrypted_content: import_v46.z.string().nullish()
1419
+ z6.object({
1420
+ type: z6.literal("reasoning"),
1421
+ id: z6.string(),
1422
+ summary: z6.array(reasoningSummaryPartSchema),
1423
+ content: z6.array(z6.object({ type: z6.string(), text: z6.string() })).nullish(),
1424
+ status: z6.string(),
1425
+ encrypted_content: z6.string().nullish()
1384
1426
  })
1385
1427
  ]);
1386
- var xaiResponsesUsageSchema = import_v46.z.object({
1387
- input_tokens: import_v46.z.number(),
1388
- output_tokens: import_v46.z.number(),
1389
- total_tokens: import_v46.z.number().optional(),
1390
- input_tokens_details: import_v46.z.object({
1391
- cached_tokens: import_v46.z.number().optional()
1428
+ var xaiResponsesUsageSchema = z6.object({
1429
+ input_tokens: z6.number(),
1430
+ output_tokens: z6.number(),
1431
+ total_tokens: z6.number().optional(),
1432
+ input_tokens_details: z6.object({
1433
+ cached_tokens: z6.number().optional()
1392
1434
  }).optional(),
1393
- output_tokens_details: import_v46.z.object({
1394
- reasoning_tokens: import_v46.z.number().optional()
1435
+ output_tokens_details: z6.object({
1436
+ reasoning_tokens: z6.number().optional()
1395
1437
  }).optional(),
1396
- num_sources_used: import_v46.z.number().optional(),
1397
- num_server_side_tools_used: import_v46.z.number().optional()
1438
+ num_sources_used: z6.number().optional(),
1439
+ num_server_side_tools_used: z6.number().optional()
1398
1440
  });
1399
- var xaiResponsesResponseSchema = import_v46.z.object({
1400
- id: import_v46.z.string().nullish(),
1401
- created_at: import_v46.z.number().nullish(),
1402
- model: import_v46.z.string().nullish(),
1403
- object: import_v46.z.literal("response"),
1404
- output: import_v46.z.array(outputItemSchema),
1441
+ var xaiResponsesResponseSchema = z6.object({
1442
+ id: z6.string().nullish(),
1443
+ created_at: z6.number().nullish(),
1444
+ model: z6.string().nullish(),
1445
+ object: z6.literal("response"),
1446
+ output: z6.array(outputItemSchema),
1405
1447
  usage: xaiResponsesUsageSchema.nullish(),
1406
- status: import_v46.z.string()
1448
+ status: z6.string()
1407
1449
  });
1408
- var xaiResponsesChunkSchema = import_v46.z.union([
1409
- import_v46.z.object({
1410
- type: import_v46.z.literal("response.created"),
1450
+ var xaiResponsesChunkSchema = z6.union([
1451
+ z6.object({
1452
+ type: z6.literal("response.created"),
1411
1453
  response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
1412
1454
  }),
1413
- import_v46.z.object({
1414
- type: import_v46.z.literal("response.in_progress"),
1455
+ z6.object({
1456
+ type: z6.literal("response.in_progress"),
1415
1457
  response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
1416
1458
  }),
1417
- import_v46.z.object({
1418
- type: import_v46.z.literal("response.output_item.added"),
1459
+ z6.object({
1460
+ type: z6.literal("response.output_item.added"),
1419
1461
  item: outputItemSchema,
1420
- output_index: import_v46.z.number()
1462
+ output_index: z6.number()
1421
1463
  }),
1422
- import_v46.z.object({
1423
- type: import_v46.z.literal("response.output_item.done"),
1464
+ z6.object({
1465
+ type: z6.literal("response.output_item.done"),
1424
1466
  item: outputItemSchema,
1425
- output_index: import_v46.z.number()
1467
+ output_index: z6.number()
1426
1468
  }),
1427
- import_v46.z.object({
1428
- type: import_v46.z.literal("response.content_part.added"),
1429
- item_id: import_v46.z.string(),
1430
- output_index: import_v46.z.number(),
1431
- content_index: import_v46.z.number(),
1469
+ z6.object({
1470
+ type: z6.literal("response.content_part.added"),
1471
+ item_id: z6.string(),
1472
+ output_index: z6.number(),
1473
+ content_index: z6.number(),
1432
1474
  part: messageContentPartSchema
1433
1475
  }),
1434
- import_v46.z.object({
1435
- type: import_v46.z.literal("response.content_part.done"),
1436
- item_id: import_v46.z.string(),
1437
- output_index: import_v46.z.number(),
1438
- content_index: import_v46.z.number(),
1476
+ z6.object({
1477
+ type: z6.literal("response.content_part.done"),
1478
+ item_id: z6.string(),
1479
+ output_index: z6.number(),
1480
+ content_index: z6.number(),
1439
1481
  part: messageContentPartSchema
1440
1482
  }),
1441
- import_v46.z.object({
1442
- type: import_v46.z.literal("response.output_text.delta"),
1443
- item_id: import_v46.z.string(),
1444
- output_index: import_v46.z.number(),
1445
- content_index: import_v46.z.number(),
1446
- delta: import_v46.z.string(),
1447
- logprobs: import_v46.z.array(import_v46.z.any()).optional()
1483
+ z6.object({
1484
+ type: z6.literal("response.output_text.delta"),
1485
+ item_id: z6.string(),
1486
+ output_index: z6.number(),
1487
+ content_index: z6.number(),
1488
+ delta: z6.string(),
1489
+ logprobs: z6.array(z6.any()).optional()
1448
1490
  }),
1449
- import_v46.z.object({
1450
- type: import_v46.z.literal("response.output_text.done"),
1451
- item_id: import_v46.z.string(),
1452
- output_index: import_v46.z.number(),
1453
- content_index: import_v46.z.number(),
1454
- text: import_v46.z.string(),
1455
- logprobs: import_v46.z.array(import_v46.z.any()).optional(),
1456
- annotations: import_v46.z.array(annotationSchema).optional()
1491
+ z6.object({
1492
+ type: z6.literal("response.output_text.done"),
1493
+ item_id: z6.string(),
1494
+ output_index: z6.number(),
1495
+ content_index: z6.number(),
1496
+ text: z6.string(),
1497
+ logprobs: z6.array(z6.any()).optional(),
1498
+ annotations: z6.array(annotationSchema).optional()
1457
1499
  }),
1458
- import_v46.z.object({
1459
- type: import_v46.z.literal("response.output_text.annotation.added"),
1460
- item_id: import_v46.z.string(),
1461
- output_index: import_v46.z.number(),
1462
- content_index: import_v46.z.number(),
1463
- annotation_index: import_v46.z.number(),
1500
+ z6.object({
1501
+ type: z6.literal("response.output_text.annotation.added"),
1502
+ item_id: z6.string(),
1503
+ output_index: z6.number(),
1504
+ content_index: z6.number(),
1505
+ annotation_index: z6.number(),
1464
1506
  annotation: annotationSchema
1465
1507
  }),
1466
- import_v46.z.object({
1467
- type: import_v46.z.literal("response.reasoning_summary_part.added"),
1468
- item_id: import_v46.z.string(),
1469
- output_index: import_v46.z.number(),
1470
- summary_index: import_v46.z.number(),
1508
+ z6.object({
1509
+ type: z6.literal("response.reasoning_summary_part.added"),
1510
+ item_id: z6.string(),
1511
+ output_index: z6.number(),
1512
+ summary_index: z6.number(),
1471
1513
  part: reasoningSummaryPartSchema
1472
1514
  }),
1473
- import_v46.z.object({
1474
- type: import_v46.z.literal("response.reasoning_summary_part.done"),
1475
- item_id: import_v46.z.string(),
1476
- output_index: import_v46.z.number(),
1477
- summary_index: import_v46.z.number(),
1515
+ z6.object({
1516
+ type: z6.literal("response.reasoning_summary_part.done"),
1517
+ item_id: z6.string(),
1518
+ output_index: z6.number(),
1519
+ summary_index: z6.number(),
1478
1520
  part: reasoningSummaryPartSchema
1479
1521
  }),
1480
- import_v46.z.object({
1481
- type: import_v46.z.literal("response.reasoning_summary_text.delta"),
1482
- item_id: import_v46.z.string(),
1483
- output_index: import_v46.z.number(),
1484
- summary_index: import_v46.z.number(),
1485
- delta: import_v46.z.string()
1522
+ z6.object({
1523
+ type: z6.literal("response.reasoning_summary_text.delta"),
1524
+ item_id: z6.string(),
1525
+ output_index: z6.number(),
1526
+ summary_index: z6.number(),
1527
+ delta: z6.string()
1486
1528
  }),
1487
- import_v46.z.object({
1488
- type: import_v46.z.literal("response.reasoning_summary_text.done"),
1489
- item_id: import_v46.z.string(),
1490
- output_index: import_v46.z.number(),
1491
- summary_index: import_v46.z.number(),
1492
- text: import_v46.z.string()
1529
+ z6.object({
1530
+ type: z6.literal("response.reasoning_summary_text.done"),
1531
+ item_id: z6.string(),
1532
+ output_index: z6.number(),
1533
+ summary_index: z6.number(),
1534
+ text: z6.string()
1493
1535
  }),
1494
- import_v46.z.object({
1495
- type: import_v46.z.literal("response.reasoning_text.delta"),
1496
- item_id: import_v46.z.string(),
1497
- output_index: import_v46.z.number(),
1498
- content_index: import_v46.z.number(),
1499
- delta: import_v46.z.string()
1536
+ z6.object({
1537
+ type: z6.literal("response.reasoning_text.delta"),
1538
+ item_id: z6.string(),
1539
+ output_index: z6.number(),
1540
+ content_index: z6.number(),
1541
+ delta: z6.string()
1500
1542
  }),
1501
- import_v46.z.object({
1502
- type: import_v46.z.literal("response.reasoning_text.done"),
1503
- item_id: import_v46.z.string(),
1504
- output_index: import_v46.z.number(),
1505
- content_index: import_v46.z.number(),
1506
- text: import_v46.z.string()
1543
+ z6.object({
1544
+ type: z6.literal("response.reasoning_text.done"),
1545
+ item_id: z6.string(),
1546
+ output_index: z6.number(),
1547
+ content_index: z6.number(),
1548
+ text: z6.string()
1507
1549
  }),
1508
- import_v46.z.object({
1509
- type: import_v46.z.literal("response.web_search_call.in_progress"),
1510
- item_id: import_v46.z.string(),
1511
- output_index: import_v46.z.number()
1550
+ z6.object({
1551
+ type: z6.literal("response.web_search_call.in_progress"),
1552
+ item_id: z6.string(),
1553
+ output_index: z6.number()
1512
1554
  }),
1513
- import_v46.z.object({
1514
- type: import_v46.z.literal("response.web_search_call.searching"),
1515
- item_id: import_v46.z.string(),
1516
- output_index: import_v46.z.number()
1555
+ z6.object({
1556
+ type: z6.literal("response.web_search_call.searching"),
1557
+ item_id: z6.string(),
1558
+ output_index: z6.number()
1517
1559
  }),
1518
- import_v46.z.object({
1519
- type: import_v46.z.literal("response.web_search_call.completed"),
1520
- item_id: import_v46.z.string(),
1521
- output_index: import_v46.z.number()
1560
+ z6.object({
1561
+ type: z6.literal("response.web_search_call.completed"),
1562
+ item_id: z6.string(),
1563
+ output_index: z6.number()
1522
1564
  }),
1523
- import_v46.z.object({
1524
- type: import_v46.z.literal("response.x_search_call.in_progress"),
1525
- item_id: import_v46.z.string(),
1526
- output_index: import_v46.z.number()
1565
+ z6.object({
1566
+ type: z6.literal("response.x_search_call.in_progress"),
1567
+ item_id: z6.string(),
1568
+ output_index: z6.number()
1527
1569
  }),
1528
- import_v46.z.object({
1529
- type: import_v46.z.literal("response.x_search_call.searching"),
1530
- item_id: import_v46.z.string(),
1531
- output_index: import_v46.z.number()
1570
+ z6.object({
1571
+ type: z6.literal("response.x_search_call.searching"),
1572
+ item_id: z6.string(),
1573
+ output_index: z6.number()
1532
1574
  }),
1533
- import_v46.z.object({
1534
- type: import_v46.z.literal("response.x_search_call.completed"),
1535
- item_id: import_v46.z.string(),
1536
- output_index: import_v46.z.number()
1575
+ z6.object({
1576
+ type: z6.literal("response.x_search_call.completed"),
1577
+ item_id: z6.string(),
1578
+ output_index: z6.number()
1537
1579
  }),
1538
- import_v46.z.object({
1539
- type: import_v46.z.literal("response.file_search_call.in_progress"),
1540
- item_id: import_v46.z.string(),
1541
- output_index: import_v46.z.number()
1580
+ z6.object({
1581
+ type: z6.literal("response.file_search_call.in_progress"),
1582
+ item_id: z6.string(),
1583
+ output_index: z6.number()
1542
1584
  }),
1543
- import_v46.z.object({
1544
- type: import_v46.z.literal("response.file_search_call.searching"),
1545
- item_id: import_v46.z.string(),
1546
- output_index: import_v46.z.number()
1585
+ z6.object({
1586
+ type: z6.literal("response.file_search_call.searching"),
1587
+ item_id: z6.string(),
1588
+ output_index: z6.number()
1547
1589
  }),
1548
- import_v46.z.object({
1549
- type: import_v46.z.literal("response.file_search_call.completed"),
1550
- item_id: import_v46.z.string(),
1551
- output_index: import_v46.z.number()
1590
+ z6.object({
1591
+ type: z6.literal("response.file_search_call.completed"),
1592
+ item_id: z6.string(),
1593
+ output_index: z6.number()
1552
1594
  }),
1553
- import_v46.z.object({
1554
- type: import_v46.z.literal("response.code_execution_call.in_progress"),
1555
- item_id: import_v46.z.string(),
1556
- output_index: import_v46.z.number()
1595
+ z6.object({
1596
+ type: z6.literal("response.code_execution_call.in_progress"),
1597
+ item_id: z6.string(),
1598
+ output_index: z6.number()
1557
1599
  }),
1558
- import_v46.z.object({
1559
- type: import_v46.z.literal("response.code_execution_call.executing"),
1560
- item_id: import_v46.z.string(),
1561
- output_index: import_v46.z.number()
1600
+ z6.object({
1601
+ type: z6.literal("response.code_execution_call.executing"),
1602
+ item_id: z6.string(),
1603
+ output_index: z6.number()
1562
1604
  }),
1563
- import_v46.z.object({
1564
- type: import_v46.z.literal("response.code_execution_call.completed"),
1565
- item_id: import_v46.z.string(),
1566
- output_index: import_v46.z.number()
1605
+ z6.object({
1606
+ type: z6.literal("response.code_execution_call.completed"),
1607
+ item_id: z6.string(),
1608
+ output_index: z6.number()
1567
1609
  }),
1568
- import_v46.z.object({
1569
- type: import_v46.z.literal("response.code_interpreter_call.in_progress"),
1570
- item_id: import_v46.z.string(),
1571
- output_index: import_v46.z.number()
1610
+ z6.object({
1611
+ type: z6.literal("response.code_interpreter_call.in_progress"),
1612
+ item_id: z6.string(),
1613
+ output_index: z6.number()
1572
1614
  }),
1573
- import_v46.z.object({
1574
- type: import_v46.z.literal("response.code_interpreter_call.executing"),
1575
- item_id: import_v46.z.string(),
1576
- output_index: import_v46.z.number()
1615
+ z6.object({
1616
+ type: z6.literal("response.code_interpreter_call.executing"),
1617
+ item_id: z6.string(),
1618
+ output_index: z6.number()
1577
1619
  }),
1578
- import_v46.z.object({
1579
- type: import_v46.z.literal("response.code_interpreter_call.interpreting"),
1580
- item_id: import_v46.z.string(),
1581
- output_index: import_v46.z.number()
1620
+ z6.object({
1621
+ type: z6.literal("response.code_interpreter_call.interpreting"),
1622
+ item_id: z6.string(),
1623
+ output_index: z6.number()
1582
1624
  }),
1583
- import_v46.z.object({
1584
- type: import_v46.z.literal("response.code_interpreter_call.completed"),
1585
- item_id: import_v46.z.string(),
1586
- output_index: import_v46.z.number()
1625
+ z6.object({
1626
+ type: z6.literal("response.code_interpreter_call.completed"),
1627
+ item_id: z6.string(),
1628
+ output_index: z6.number()
1587
1629
  }),
1588
1630
  // Code interpreter code streaming events
1589
- import_v46.z.object({
1590
- type: import_v46.z.literal("response.code_interpreter_call_code.delta"),
1591
- item_id: import_v46.z.string(),
1592
- output_index: import_v46.z.number(),
1593
- delta: import_v46.z.string()
1631
+ z6.object({
1632
+ type: z6.literal("response.code_interpreter_call_code.delta"),
1633
+ item_id: z6.string(),
1634
+ output_index: z6.number(),
1635
+ delta: z6.string()
1594
1636
  }),
1595
- import_v46.z.object({
1596
- type: import_v46.z.literal("response.code_interpreter_call_code.done"),
1597
- item_id: import_v46.z.string(),
1598
- output_index: import_v46.z.number(),
1599
- code: import_v46.z.string()
1637
+ z6.object({
1638
+ type: z6.literal("response.code_interpreter_call_code.done"),
1639
+ item_id: z6.string(),
1640
+ output_index: z6.number(),
1641
+ code: z6.string()
1600
1642
  }),
1601
- import_v46.z.object({
1602
- type: import_v46.z.literal("response.custom_tool_call_input.delta"),
1603
- item_id: import_v46.z.string(),
1604
- output_index: import_v46.z.number(),
1605
- delta: import_v46.z.string()
1643
+ z6.object({
1644
+ type: z6.literal("response.custom_tool_call_input.delta"),
1645
+ item_id: z6.string(),
1646
+ output_index: z6.number(),
1647
+ delta: z6.string()
1606
1648
  }),
1607
- import_v46.z.object({
1608
- type: import_v46.z.literal("response.custom_tool_call_input.done"),
1609
- item_id: import_v46.z.string(),
1610
- output_index: import_v46.z.number(),
1611
- input: import_v46.z.string()
1649
+ z6.object({
1650
+ type: z6.literal("response.custom_tool_call_input.done"),
1651
+ item_id: z6.string(),
1652
+ output_index: z6.number(),
1653
+ input: z6.string()
1612
1654
  }),
1613
1655
  // Function call arguments streaming events (standard function tools)
1614
- import_v46.z.object({
1615
- type: import_v46.z.literal("response.function_call_arguments.delta"),
1616
- item_id: import_v46.z.string(),
1617
- output_index: import_v46.z.number(),
1618
- delta: import_v46.z.string()
1656
+ z6.object({
1657
+ type: z6.literal("response.function_call_arguments.delta"),
1658
+ item_id: z6.string(),
1659
+ output_index: z6.number(),
1660
+ delta: z6.string()
1619
1661
  }),
1620
- import_v46.z.object({
1621
- type: import_v46.z.literal("response.function_call_arguments.done"),
1622
- item_id: import_v46.z.string(),
1623
- output_index: import_v46.z.number(),
1624
- arguments: import_v46.z.string()
1662
+ z6.object({
1663
+ type: z6.literal("response.function_call_arguments.done"),
1664
+ item_id: z6.string(),
1665
+ output_index: z6.number(),
1666
+ arguments: z6.string()
1625
1667
  }),
1626
- import_v46.z.object({
1627
- type: import_v46.z.literal("response.mcp_call.in_progress"),
1628
- item_id: import_v46.z.string(),
1629
- output_index: import_v46.z.number()
1668
+ z6.object({
1669
+ type: z6.literal("response.mcp_call.in_progress"),
1670
+ item_id: z6.string(),
1671
+ output_index: z6.number()
1630
1672
  }),
1631
- import_v46.z.object({
1632
- type: import_v46.z.literal("response.mcp_call.executing"),
1633
- item_id: import_v46.z.string(),
1634
- output_index: import_v46.z.number()
1673
+ z6.object({
1674
+ type: z6.literal("response.mcp_call.executing"),
1675
+ item_id: z6.string(),
1676
+ output_index: z6.number()
1635
1677
  }),
1636
- import_v46.z.object({
1637
- type: import_v46.z.literal("response.mcp_call.completed"),
1638
- item_id: import_v46.z.string(),
1639
- output_index: import_v46.z.number()
1678
+ z6.object({
1679
+ type: z6.literal("response.mcp_call.completed"),
1680
+ item_id: z6.string(),
1681
+ output_index: z6.number()
1640
1682
  }),
1641
- import_v46.z.object({
1642
- type: import_v46.z.literal("response.mcp_call.failed"),
1643
- item_id: import_v46.z.string(),
1644
- output_index: import_v46.z.number()
1683
+ z6.object({
1684
+ type: z6.literal("response.mcp_call.failed"),
1685
+ item_id: z6.string(),
1686
+ output_index: z6.number()
1645
1687
  }),
1646
- import_v46.z.object({
1647
- type: import_v46.z.literal("response.mcp_call_arguments.delta"),
1648
- item_id: import_v46.z.string(),
1649
- output_index: import_v46.z.number(),
1650
- delta: import_v46.z.string()
1688
+ z6.object({
1689
+ type: z6.literal("response.mcp_call_arguments.delta"),
1690
+ item_id: z6.string(),
1691
+ output_index: z6.number(),
1692
+ delta: z6.string()
1651
1693
  }),
1652
- import_v46.z.object({
1653
- type: import_v46.z.literal("response.mcp_call_arguments.done"),
1654
- item_id: import_v46.z.string(),
1655
- output_index: import_v46.z.number(),
1656
- arguments: import_v46.z.string().optional()
1694
+ z6.object({
1695
+ type: z6.literal("response.mcp_call_arguments.done"),
1696
+ item_id: z6.string(),
1697
+ output_index: z6.number(),
1698
+ arguments: z6.string().optional()
1657
1699
  }),
1658
- import_v46.z.object({
1659
- type: import_v46.z.literal("response.mcp_call_output.delta"),
1660
- item_id: import_v46.z.string(),
1661
- output_index: import_v46.z.number(),
1662
- delta: import_v46.z.string()
1700
+ z6.object({
1701
+ type: z6.literal("response.mcp_call_output.delta"),
1702
+ item_id: z6.string(),
1703
+ output_index: z6.number(),
1704
+ delta: z6.string()
1663
1705
  }),
1664
- import_v46.z.object({
1665
- type: import_v46.z.literal("response.mcp_call_output.done"),
1666
- item_id: import_v46.z.string(),
1667
- output_index: import_v46.z.number(),
1668
- output: import_v46.z.string().optional()
1706
+ z6.object({
1707
+ type: z6.literal("response.mcp_call_output.done"),
1708
+ item_id: z6.string(),
1709
+ output_index: z6.number(),
1710
+ output: z6.string().optional()
1669
1711
  }),
1670
- import_v46.z.object({
1671
- type: import_v46.z.literal("response.incomplete"),
1672
- response: import_v46.z.object({
1673
- incomplete_details: import_v46.z.object({ reason: import_v46.z.string() }).nullish(),
1712
+ z6.object({
1713
+ type: z6.literal("response.incomplete"),
1714
+ response: z6.object({
1715
+ incomplete_details: z6.object({ reason: z6.string() }).nullish(),
1674
1716
  usage: xaiResponsesUsageSchema.nullish()
1675
1717
  })
1676
1718
  }),
1677
- import_v46.z.object({
1678
- type: import_v46.z.literal("response.failed"),
1679
- response: import_v46.z.object({
1680
- error: import_v46.z.object({
1681
- code: import_v46.z.string().nullish(),
1682
- message: import_v46.z.string()
1719
+ z6.object({
1720
+ type: z6.literal("response.failed"),
1721
+ response: z6.object({
1722
+ error: z6.object({
1723
+ code: z6.string().nullish(),
1724
+ message: z6.string()
1683
1725
  }).nullish(),
1684
- incomplete_details: import_v46.z.object({ reason: import_v46.z.string() }).nullish(),
1726
+ incomplete_details: z6.object({ reason: z6.string() }).nullish(),
1685
1727
  usage: xaiResponsesUsageSchema.nullish()
1686
1728
  })
1687
1729
  }),
1688
- import_v46.z.object({
1689
- type: import_v46.z.literal("error"),
1690
- code: import_v46.z.string().nullish(),
1691
- message: import_v46.z.string(),
1692
- param: import_v46.z.string().nullish()
1730
+ z6.object({
1731
+ type: z6.literal("error"),
1732
+ code: z6.string().nullish(),
1733
+ message: z6.string(),
1734
+ param: z6.string().nullish()
1693
1735
  }),
1694
- import_v46.z.object({
1695
- type: import_v46.z.literal("response.done"),
1736
+ z6.object({
1737
+ type: z6.literal("response.done"),
1696
1738
  response: xaiResponsesResponseSchema
1697
1739
  }),
1698
- import_v46.z.object({
1699
- type: import_v46.z.literal("response.completed"),
1740
+ z6.object({
1741
+ type: z6.literal("response.completed"),
1700
1742
  response: xaiResponsesResponseSchema
1701
1743
  })
1702
1744
  ]);
1703
1745
 
1704
1746
  // src/responses/xai-responses-options.ts
1705
- var import_v47 = require("zod/v4");
1706
- var xaiLanguageModelResponsesOptions = import_v47.z.object({
1747
+ import { z as z7 } from "zod/v4";
1748
+ var xaiLanguageModelResponsesOptions = z7.object({
1707
1749
  /**
1708
1750
  * Constrains how hard a reasoning model thinks before responding.
1709
1751
  * Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
1710
1752
  */
1711
- reasoningEffort: import_v47.z.enum(["low", "medium", "high"]).optional(),
1712
- reasoningSummary: import_v47.z.enum(["auto", "concise", "detailed"]).optional(),
1713
- logprobs: import_v47.z.boolean().optional(),
1714
- topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
1753
+ reasoningEffort: z7.enum(["low", "medium", "high"]).optional(),
1754
+ reasoningSummary: z7.enum(["auto", "concise", "detailed"]).optional(),
1755
+ logprobs: z7.boolean().optional(),
1756
+ topLogprobs: z7.number().int().min(0).max(8).optional(),
1715
1757
  /**
1716
1758
  * Whether to store the input message(s) and model response for later retrieval.
1717
1759
  * @default true
1718
1760
  */
1719
- store: import_v47.z.boolean().optional(),
1761
+ store: z7.boolean().optional(),
1720
1762
  /**
1721
1763
  * The ID of the previous response from the model.
1722
1764
  */
1723
- previousResponseId: import_v47.z.string().optional(),
1765
+ previousResponseId: z7.string().optional(),
1724
1766
  /**
1725
1767
  * Specify additional output data to include in the model response.
1726
1768
  * Example values: 'file_search_call.results'.
1727
1769
  */
1728
- include: import_v47.z.array(import_v47.z.enum(["file_search_call.results"])).nullish()
1770
+ include: z7.array(z7.enum(["file_search_call.results"])).nullish()
1729
1771
  });
1730
1772
 
1731
1773
  // src/responses/xai-responses-prepare-tools.ts
1732
- var import_provider5 = require("@ai-sdk/provider");
1733
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1774
+ import {
1775
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError4
1776
+ } from "@ai-sdk/provider";
1777
+ import { validateTypes } from "@ai-sdk/provider-utils";
1734
1778
 
1735
1779
  // src/tool/file-search.ts
1736
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1737
- var import_v48 = require("zod/v4");
1738
- var fileSearchArgsSchema = (0, import_provider_utils6.lazySchema)(
1739
- () => (0, import_provider_utils6.zodSchema)(
1740
- import_v48.z.object({
1741
- vectorStoreIds: import_v48.z.array(import_v48.z.string()),
1742
- maxNumResults: import_v48.z.number().optional()
1780
+ import {
1781
+ createProviderToolFactoryWithOutputSchema,
1782
+ lazySchema,
1783
+ zodSchema
1784
+ } from "@ai-sdk/provider-utils";
1785
+ import { z as z8 } from "zod/v4";
1786
+ var fileSearchArgsSchema = lazySchema(
1787
+ () => zodSchema(
1788
+ z8.object({
1789
+ vectorStoreIds: z8.array(z8.string()),
1790
+ maxNumResults: z8.number().optional()
1743
1791
  })
1744
1792
  )
1745
1793
  );
1746
- var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
1747
- () => (0, import_provider_utils6.zodSchema)(
1748
- import_v48.z.object({
1749
- queries: import_v48.z.array(import_v48.z.string()),
1750
- results: import_v48.z.array(
1751
- import_v48.z.object({
1752
- fileId: import_v48.z.string(),
1753
- filename: import_v48.z.string(),
1754
- score: import_v48.z.number().min(0).max(1),
1755
- text: import_v48.z.string()
1794
+ var fileSearchOutputSchema = lazySchema(
1795
+ () => zodSchema(
1796
+ z8.object({
1797
+ queries: z8.array(z8.string()),
1798
+ results: z8.array(
1799
+ z8.object({
1800
+ fileId: z8.string(),
1801
+ filename: z8.string(),
1802
+ score: z8.number().min(0).max(1),
1803
+ text: z8.string()
1756
1804
  })
1757
1805
  ).nullable()
1758
1806
  })
1759
1807
  )
1760
1808
  );
1761
- var fileSearchToolFactory = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
1809
+ var fileSearchToolFactory = createProviderToolFactoryWithOutputSchema({
1762
1810
  id: "xai.file_search",
1763
- inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v48.z.object({}))),
1811
+ inputSchema: lazySchema(() => zodSchema(z8.object({}))),
1764
1812
  outputSchema: fileSearchOutputSchema
1765
1813
  });
1766
1814
  var fileSearch = (args) => fileSearchToolFactory(args);
1767
1815
 
1768
1816
  // src/tool/mcp-server.ts
1769
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1770
- var import_v49 = require("zod/v4");
1771
- var mcpServerArgsSchema = (0, import_provider_utils7.lazySchema)(
1772
- () => (0, import_provider_utils7.zodSchema)(
1773
- import_v49.z.object({
1774
- serverUrl: import_v49.z.string().describe("The URL of the MCP server"),
1775
- serverLabel: import_v49.z.string().optional().describe("A label for the MCP server"),
1776
- serverDescription: import_v49.z.string().optional().describe("Description of the MCP server"),
1777
- allowedTools: import_v49.z.array(import_v49.z.string()).optional().describe("List of allowed tool names"),
1778
- headers: import_v49.z.record(import_v49.z.string(), import_v49.z.string()).optional().describe("Custom headers to send"),
1779
- authorization: import_v49.z.string().optional().describe("Authorization header value")
1817
+ import {
1818
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
1819
+ lazySchema as lazySchema2,
1820
+ zodSchema as zodSchema2
1821
+ } from "@ai-sdk/provider-utils";
1822
+ import { z as z9 } from "zod/v4";
1823
+ var mcpServerArgsSchema = lazySchema2(
1824
+ () => zodSchema2(
1825
+ z9.object({
1826
+ serverUrl: z9.string().describe("The URL of the MCP server"),
1827
+ serverLabel: z9.string().optional().describe("A label for the MCP server"),
1828
+ serverDescription: z9.string().optional().describe("Description of the MCP server"),
1829
+ allowedTools: z9.array(z9.string()).optional().describe("List of allowed tool names"),
1830
+ headers: z9.record(z9.string(), z9.string()).optional().describe("Custom headers to send"),
1831
+ authorization: z9.string().optional().describe("Authorization header value")
1780
1832
  })
1781
1833
  )
1782
1834
  );
1783
- var mcpServerOutputSchema = (0, import_provider_utils7.lazySchema)(
1784
- () => (0, import_provider_utils7.zodSchema)(
1785
- import_v49.z.object({
1786
- name: import_v49.z.string(),
1787
- arguments: import_v49.z.string(),
1788
- result: import_v49.z.unknown()
1835
+ var mcpServerOutputSchema = lazySchema2(
1836
+ () => zodSchema2(
1837
+ z9.object({
1838
+ name: z9.string(),
1839
+ arguments: z9.string(),
1840
+ result: z9.unknown()
1789
1841
  })
1790
1842
  )
1791
1843
  );
1792
- var mcpServerToolFactory = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
1844
+ var mcpServerToolFactory = createProviderToolFactoryWithOutputSchema2({
1793
1845
  id: "xai.mcp",
1794
- inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v49.z.object({}))),
1846
+ inputSchema: lazySchema2(() => zodSchema2(z9.object({}))),
1795
1847
  outputSchema: mcpServerOutputSchema
1796
1848
  });
1797
1849
  var mcpServer = (args) => mcpServerToolFactory(args);
1798
1850
 
1799
1851
  // src/tool/web-search.ts
1800
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1801
- var import_v410 = require("zod/v4");
1802
- var webSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
1803
- () => (0, import_provider_utils8.zodSchema)(
1804
- import_v410.z.object({
1805
- allowedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
1806
- excludedDomains: import_v410.z.array(import_v410.z.string()).max(5).optional(),
1807
- enableImageUnderstanding: import_v410.z.boolean().optional()
1852
+ import {
1853
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
1854
+ lazySchema as lazySchema3,
1855
+ zodSchema as zodSchema3
1856
+ } from "@ai-sdk/provider-utils";
1857
+ import { z as z10 } from "zod/v4";
1858
+ var webSearchArgsSchema = lazySchema3(
1859
+ () => zodSchema3(
1860
+ z10.object({
1861
+ allowedDomains: z10.array(z10.string()).max(5).optional(),
1862
+ excludedDomains: z10.array(z10.string()).max(5).optional(),
1863
+ enableImageUnderstanding: z10.boolean().optional()
1808
1864
  })
1809
1865
  )
1810
1866
  );
1811
- var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
1812
- () => (0, import_provider_utils8.zodSchema)(
1813
- import_v410.z.object({
1814
- query: import_v410.z.string(),
1815
- sources: import_v410.z.array(
1816
- import_v410.z.object({
1817
- title: import_v410.z.string(),
1818
- url: import_v410.z.string(),
1819
- snippet: import_v410.z.string()
1867
+ var webSearchOutputSchema = lazySchema3(
1868
+ () => zodSchema3(
1869
+ z10.object({
1870
+ query: z10.string(),
1871
+ sources: z10.array(
1872
+ z10.object({
1873
+ title: z10.string(),
1874
+ url: z10.string(),
1875
+ snippet: z10.string()
1820
1876
  })
1821
1877
  )
1822
1878
  })
1823
1879
  )
1824
1880
  );
1825
- var webSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
1881
+ var webSearchToolFactory = createProviderToolFactoryWithOutputSchema3({
1826
1882
  id: "xai.web_search",
1827
- inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v410.z.object({}))),
1883
+ inputSchema: lazySchema3(() => zodSchema3(z10.object({}))),
1828
1884
  outputSchema: webSearchOutputSchema
1829
1885
  });
1830
1886
  var webSearch = (args = {}) => webSearchToolFactory(args);
1831
1887
 
1832
1888
  // src/tool/x-search.ts
1833
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1834
- var import_v411 = require("zod/v4");
1835
- var xSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
1836
- () => (0, import_provider_utils9.zodSchema)(
1837
- import_v411.z.object({
1838
- allowedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
1839
- excludedXHandles: import_v411.z.array(import_v411.z.string()).max(10).optional(),
1840
- fromDate: import_v411.z.string().optional(),
1841
- toDate: import_v411.z.string().optional(),
1842
- enableImageUnderstanding: import_v411.z.boolean().optional(),
1843
- enableVideoUnderstanding: import_v411.z.boolean().optional()
1889
+ import {
1890
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
1891
+ lazySchema as lazySchema4,
1892
+ zodSchema as zodSchema4
1893
+ } from "@ai-sdk/provider-utils";
1894
+ import { z as z11 } from "zod/v4";
1895
+ var xSearchArgsSchema = lazySchema4(
1896
+ () => zodSchema4(
1897
+ z11.object({
1898
+ allowedXHandles: z11.array(z11.string()).max(10).optional(),
1899
+ excludedXHandles: z11.array(z11.string()).max(10).optional(),
1900
+ fromDate: z11.string().optional(),
1901
+ toDate: z11.string().optional(),
1902
+ enableImageUnderstanding: z11.boolean().optional(),
1903
+ enableVideoUnderstanding: z11.boolean().optional()
1844
1904
  })
1845
1905
  )
1846
1906
  );
1847
- var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
1848
- () => (0, import_provider_utils9.zodSchema)(
1849
- import_v411.z.object({
1850
- query: import_v411.z.string(),
1851
- posts: import_v411.z.array(
1852
- import_v411.z.object({
1853
- author: import_v411.z.string(),
1854
- text: import_v411.z.string(),
1855
- url: import_v411.z.string(),
1856
- likes: import_v411.z.number()
1907
+ var xSearchOutputSchema = lazySchema4(
1908
+ () => zodSchema4(
1909
+ z11.object({
1910
+ query: z11.string(),
1911
+ posts: z11.array(
1912
+ z11.object({
1913
+ author: z11.string(),
1914
+ text: z11.string(),
1915
+ url: z11.string(),
1916
+ likes: z11.number()
1857
1917
  })
1858
1918
  )
1859
1919
  })
1860
1920
  )
1861
1921
  );
1862
- var xSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
1922
+ var xSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
1863
1923
  id: "xai.x_search",
1864
- inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v411.z.object({}))),
1924
+ inputSchema: lazySchema4(() => zodSchema4(z11.object({}))),
1865
1925
  outputSchema: xSearchOutputSchema
1866
1926
  });
1867
1927
  var xSearch = (args = {}) => xSearchToolFactory(args);
@@ -1883,7 +1943,7 @@ async function prepareResponsesTools({
1883
1943
  if (tool.type === "provider") {
1884
1944
  switch (tool.id) {
1885
1945
  case "xai.web_search": {
1886
- const args = await (0, import_provider_utils10.validateTypes)({
1946
+ const args = await validateTypes({
1887
1947
  value: tool.args,
1888
1948
  schema: webSearchArgsSchema
1889
1949
  });
@@ -1896,7 +1956,7 @@ async function prepareResponsesTools({
1896
1956
  break;
1897
1957
  }
1898
1958
  case "xai.x_search": {
1899
- const args = await (0, import_provider_utils10.validateTypes)({
1959
+ const args = await validateTypes({
1900
1960
  value: tool.args,
1901
1961
  schema: xSearchArgsSchema
1902
1962
  });
@@ -1930,7 +1990,7 @@ async function prepareResponsesTools({
1930
1990
  break;
1931
1991
  }
1932
1992
  case "xai.file_search": {
1933
- const args = await (0, import_provider_utils10.validateTypes)({
1993
+ const args = await validateTypes({
1934
1994
  value: tool.args,
1935
1995
  schema: fileSearchArgsSchema
1936
1996
  });
@@ -1942,7 +2002,7 @@ async function prepareResponsesTools({
1942
2002
  break;
1943
2003
  }
1944
2004
  case "xai.mcp": {
1945
- const args = await (0, import_provider_utils10.validateTypes)({
2005
+ const args = await validateTypes({
1946
2006
  value: tool.args,
1947
2007
  schema: mcpServerArgsSchema
1948
2008
  });
@@ -2009,7 +2069,7 @@ async function prepareResponsesTools({
2009
2069
  }
2010
2070
  default: {
2011
2071
  const _exhaustiveCheck = type;
2012
- throw new import_provider5.UnsupportedFunctionalityError({
2072
+ throw new UnsupportedFunctionalityError4({
2013
2073
  functionality: `tool choice type: ${_exhaustiveCheck}`
2014
2074
  });
2015
2075
  }
@@ -2017,7 +2077,7 @@ async function prepareResponsesTools({
2017
2077
  }
2018
2078
 
2019
2079
  // src/responses/xai-responses-language-model.ts
2020
- var XaiResponsesLanguageModel = class {
2080
+ var XaiResponsesLanguageModel = class _XaiResponsesLanguageModel {
2021
2081
  constructor(modelId, config) {
2022
2082
  this.specificationVersion = "v4";
2023
2083
  this.supportedUrls = {
@@ -2026,6 +2086,15 @@ var XaiResponsesLanguageModel = class {
2026
2086
  this.modelId = modelId;
2027
2087
  this.config = config;
2028
2088
  }
2089
+ static [WORKFLOW_SERIALIZE3](model) {
2090
+ return serializeModelOptions3({
2091
+ modelId: model.modelId,
2092
+ config: model.config
2093
+ });
2094
+ }
2095
+ static [WORKFLOW_DESERIALIZE3](options) {
2096
+ return new _XaiResponsesLanguageModel(options.modelId, options.config);
2097
+ }
2029
2098
  get provider() {
2030
2099
  return this.config.provider;
2031
2100
  }
@@ -2044,7 +2113,7 @@ var XaiResponsesLanguageModel = class {
2044
2113
  }) {
2045
2114
  var _a, _b, _c, _d, _e, _f, _g, _h;
2046
2115
  const warnings = [];
2047
- const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
2116
+ const options = (_a = await parseProviderOptions3({
2048
2117
  provider: "xai",
2049
2118
  providerOptions,
2050
2119
  schema: xaiLanguageModelResponsesOptions
@@ -2089,7 +2158,7 @@ var XaiResponsesLanguageModel = class {
2089
2158
  include = [...include, "reasoning.encrypted_content"];
2090
2159
  }
2091
2160
  }
2092
- const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : (0, import_provider_utils11.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils11.mapReasoningToProviderEffort)({
2161
+ const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : isCustomReasoning2(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort2({
2093
2162
  reasoning,
2094
2163
  effortMap: {
2095
2164
  minimal: "low",
@@ -2157,7 +2226,7 @@ var XaiResponsesLanguageModel = class {
2157
2226
  };
2158
2227
  }
2159
2228
  async doGenerate(options) {
2160
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
2229
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2161
2230
  const {
2162
2231
  args: body,
2163
2232
  warnings,
@@ -2171,12 +2240,12 @@ var XaiResponsesLanguageModel = class {
2171
2240
  responseHeaders,
2172
2241
  value: response,
2173
2242
  rawValue: rawResponse
2174
- } = await (0, import_provider_utils11.postJsonToApi)({
2243
+ } = await postJsonToApi3({
2175
2244
  url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
2176
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2245
+ headers: combineHeaders3((_c = (_b = this.config).headers) == null ? void 0 : _c.call(_b), options.headers),
2177
2246
  body,
2178
2247
  failedResponseHandler: xaiFailedResponseHandler,
2179
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2248
+ successfulResponseHandler: createJsonResponseHandler3(
2180
2249
  xaiResponsesResponseSchema
2181
2250
  ),
2182
2251
  abortSignal: options.abortSignal,
@@ -2210,29 +2279,29 @@ var XaiResponsesLanguageModel = class {
2210
2279
  toolCallId: part.id,
2211
2280
  toolName,
2212
2281
  result: {
2213
- queries: (_b = part.queries) != null ? _b : [],
2214
- results: (_d = (_c = part.results) == null ? void 0 : _c.map((result) => ({
2282
+ queries: (_d = part.queries) != null ? _d : [],
2283
+ results: (_f = (_e = part.results) == null ? void 0 : _e.map((result) => ({
2215
2284
  fileId: result.file_id,
2216
2285
  filename: result.filename,
2217
2286
  score: result.score,
2218
2287
  text: result.text
2219
- }))) != null ? _d : null
2288
+ }))) != null ? _f : null
2220
2289
  }
2221
2290
  });
2222
2291
  continue;
2223
2292
  }
2224
2293
  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") {
2225
- let toolName = (_e = part.name) != null ? _e : "";
2226
- if (webSearchSubTools.includes((_f = part.name) != null ? _f : "") || part.type === "web_search_call") {
2294
+ let toolName = (_g = part.name) != null ? _g : "";
2295
+ if (webSearchSubTools.includes((_h = part.name) != null ? _h : "") || part.type === "web_search_call") {
2227
2296
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
2228
- } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "") || part.type === "x_search_call") {
2297
+ } else if (xSearchSubTools.includes((_i = part.name) != null ? _i : "") || part.type === "x_search_call") {
2229
2298
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
2230
2299
  } else if (part.name === "code_execution" || part.type === "code_interpreter_call" || part.type === "code_execution_call") {
2231
2300
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
2232
2301
  } else if (part.type === "mcp_call") {
2233
- toolName = (_h = mcpToolName != null ? mcpToolName : part.name) != null ? _h : "mcp";
2302
+ toolName = (_j = mcpToolName != null ? mcpToolName : part.name) != null ? _j : "mcp";
2234
2303
  }
2235
- const toolInput = part.type === "custom_tool_call" ? (_i = part.input) != null ? _i : "" : part.type === "mcp_call" ? (_j = part.arguments) != null ? _j : "" : (_k = part.arguments) != null ? _k : "";
2304
+ const toolInput = part.type === "custom_tool_call" ? (_k = part.input) != null ? _k : "" : part.type === "mcp_call" ? (_l = part.arguments) != null ? _l : "" : (_m = part.arguments) != null ? _m : "";
2236
2305
  content.push({
2237
2306
  type: "tool-call",
2238
2307
  toolCallId: part.id,
@@ -2259,7 +2328,7 @@ var XaiResponsesLanguageModel = class {
2259
2328
  sourceType: "url",
2260
2329
  id: this.config.generateId(),
2261
2330
  url: annotation.url,
2262
- title: (_l = annotation.title) != null ? _l : annotation.url
2331
+ title: (_n = annotation.title) != null ? _n : annotation.url
2263
2332
  });
2264
2333
  }
2265
2334
  }
@@ -2278,7 +2347,7 @@ var XaiResponsesLanguageModel = class {
2278
2347
  break;
2279
2348
  }
2280
2349
  case "reasoning": {
2281
- const texts = part.summary.length > 0 ? part.summary.map((s) => s.text) : ((_m = part.content) != null ? _m : []).map((c) => c.text);
2350
+ const texts = part.summary.length > 0 ? part.summary.map((s) => s.text) : ((_o = part.content) != null ? _o : []).map((c) => c.text);
2282
2351
  const reasoningText = texts.filter((text) => text && text.length > 0).join("");
2283
2352
  if (reasoningText) {
2284
2353
  if (part.encrypted_content || part.id) {
@@ -2312,7 +2381,7 @@ var XaiResponsesLanguageModel = class {
2312
2381
  content,
2313
2382
  finishReason: {
2314
2383
  unified: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response.status),
2315
- raw: (_n = response.status) != null ? _n : void 0
2384
+ raw: (_p = response.status) != null ? _p : void 0
2316
2385
  },
2317
2386
  usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
2318
2387
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
@@ -2328,7 +2397,7 @@ var XaiResponsesLanguageModel = class {
2328
2397
  };
2329
2398
  }
2330
2399
  async doStream(options) {
2331
- var _a;
2400
+ var _a, _b, _c;
2332
2401
  const {
2333
2402
  args,
2334
2403
  warnings,
@@ -2342,12 +2411,12 @@ var XaiResponsesLanguageModel = class {
2342
2411
  ...args,
2343
2412
  stream: true
2344
2413
  };
2345
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2414
+ const { responseHeaders, value: response } = await postJsonToApi3({
2346
2415
  url: `${(_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1"}/responses`,
2347
- headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
2416
+ headers: combineHeaders3((_c = (_b = this.config).headers) == null ? void 0 : _c.call(_b), options.headers),
2348
2417
  body,
2349
2418
  failedResponseHandler: xaiFailedResponseHandler,
2350
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2419
+ successfulResponseHandler: createEventSourceResponseHandler2(
2351
2420
  xaiResponsesChunkSchema
2352
2421
  ),
2353
2422
  abortSignal: options.abortSignal,
@@ -2372,7 +2441,7 @@ var XaiResponsesLanguageModel = class {
2372
2441
  controller.enqueue({ type: "stream-start", warnings });
2373
2442
  },
2374
2443
  transform(chunk, controller) {
2375
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
2444
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
2376
2445
  if (options.includeRawChunks) {
2377
2446
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2378
2447
  }
@@ -2490,7 +2559,7 @@ var XaiResponsesLanguageModel = class {
2490
2559
  sourceType: "url",
2491
2560
  id: self.config.generateId(),
2492
2561
  url: annotation.url,
2493
- title: (_b = annotation.title) != null ? _b : annotation.url
2562
+ title: (_b2 = annotation.title) != null ? _b2 : annotation.url
2494
2563
  });
2495
2564
  }
2496
2565
  return;
@@ -2501,7 +2570,7 @@ var XaiResponsesLanguageModel = class {
2501
2570
  usage = convertXaiResponsesUsage(response2.usage);
2502
2571
  }
2503
2572
  if (event.type === "response.incomplete") {
2504
- const reason = "incomplete_details" in response2 ? (_c = response2.incomplete_details) == null ? void 0 : _c.reason : void 0;
2573
+ const reason = "incomplete_details" in response2 ? (_c2 = response2.incomplete_details) == null ? void 0 : _c2.reason : void 0;
2505
2574
  finishReason = {
2506
2575
  unified: reason ? mapXaiResponsesFinishReason(reason) : "other",
2507
2576
  raw: reason != null ? reason : "incomplete"
@@ -2764,44 +2833,44 @@ var XaiResponsesLanguageModel = class {
2764
2833
  };
2765
2834
 
2766
2835
  // src/tool/code-execution.ts
2767
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2768
- var import_v412 = require("zod/v4");
2769
- var codeExecutionOutputSchema = import_v412.z.object({
2770
- output: import_v412.z.string().describe("the output of the code execution"),
2771
- error: import_v412.z.string().optional().describe("any error that occurred")
2836
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5 } from "@ai-sdk/provider-utils";
2837
+ import { z as z12 } from "zod/v4";
2838
+ var codeExecutionOutputSchema = z12.object({
2839
+ output: z12.string().describe("the output of the code execution"),
2840
+ error: z12.string().optional().describe("any error that occurred")
2772
2841
  });
2773
- var codeExecutionToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
2842
+ var codeExecutionToolFactory = createProviderToolFactoryWithOutputSchema5({
2774
2843
  id: "xai.code_execution",
2775
- inputSchema: import_v412.z.object({}).describe("no input parameters"),
2844
+ inputSchema: z12.object({}).describe("no input parameters"),
2776
2845
  outputSchema: codeExecutionOutputSchema
2777
2846
  });
2778
2847
  var codeExecution = (args = {}) => codeExecutionToolFactory(args);
2779
2848
 
2780
2849
  // src/tool/view-image.ts
2781
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2782
- var import_v413 = require("zod/v4");
2783
- var viewImageOutputSchema = import_v413.z.object({
2784
- description: import_v413.z.string().describe("description of the image"),
2785
- objects: import_v413.z.array(import_v413.z.string()).optional().describe("objects detected in the image")
2850
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6 } from "@ai-sdk/provider-utils";
2851
+ import { z as z13 } from "zod/v4";
2852
+ var viewImageOutputSchema = z13.object({
2853
+ description: z13.string().describe("description of the image"),
2854
+ objects: z13.array(z13.string()).optional().describe("objects detected in the image")
2786
2855
  });
2787
- var viewImageToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
2856
+ var viewImageToolFactory = createProviderToolFactoryWithOutputSchema6({
2788
2857
  id: "xai.view_image",
2789
- inputSchema: import_v413.z.object({}).describe("no input parameters"),
2858
+ inputSchema: z13.object({}).describe("no input parameters"),
2790
2859
  outputSchema: viewImageOutputSchema
2791
2860
  });
2792
2861
  var viewImage = (args = {}) => viewImageToolFactory(args);
2793
2862
 
2794
2863
  // src/tool/view-x-video.ts
2795
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2796
- var import_v414 = require("zod/v4");
2797
- var viewXVideoOutputSchema = import_v414.z.object({
2798
- transcript: import_v414.z.string().optional().describe("transcript of the video"),
2799
- description: import_v414.z.string().describe("description of the video content"),
2800
- duration: import_v414.z.number().optional().describe("duration in seconds")
2864
+ import { createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7 } from "@ai-sdk/provider-utils";
2865
+ import { z as z14 } from "zod/v4";
2866
+ var viewXVideoOutputSchema = z14.object({
2867
+ transcript: z14.string().optional().describe("transcript of the video"),
2868
+ description: z14.string().describe("description of the video content"),
2869
+ duration: z14.number().optional().describe("duration in seconds")
2801
2870
  });
2802
- var viewXVideoToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
2871
+ var viewXVideoToolFactory = createProviderToolFactoryWithOutputSchema7({
2803
2872
  id: "xai.view_x_video",
2804
- inputSchema: import_v414.z.object({}).describe("no input parameters"),
2873
+ inputSchema: z14.object({}).describe("no input parameters"),
2805
2874
  outputSchema: viewXVideoOutputSchema
2806
2875
  });
2807
2876
  var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
@@ -2818,36 +2887,42 @@ var xaiTools = {
2818
2887
  };
2819
2888
 
2820
2889
  // src/version.ts
2821
- var VERSION = true ? "4.0.0-beta.34" : "0.0.0-test";
2890
+ var VERSION = true ? "4.0.0-beta.36" : "0.0.0-test";
2822
2891
 
2823
2892
  // src/files/xai-files.ts
2824
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
2893
+ import {
2894
+ combineHeaders as combineHeaders4,
2895
+ convertBase64ToUint8Array,
2896
+ createJsonResponseHandler as createJsonResponseHandler4,
2897
+ parseProviderOptions as parseProviderOptions4,
2898
+ postFormDataToApi
2899
+ } from "@ai-sdk/provider-utils";
2825
2900
 
2826
2901
  // src/files/xai-files-api.ts
2827
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2828
- var import_v415 = require("zod/v4");
2829
- var xaiFilesResponseSchema = (0, import_provider_utils15.lazySchema)(
2830
- () => (0, import_provider_utils15.zodSchema)(
2831
- import_v415.z.object({
2832
- id: import_v415.z.string(),
2833
- object: import_v415.z.string().nullish(),
2834
- bytes: import_v415.z.number().nullish(),
2835
- created_at: import_v415.z.number().nullish(),
2836
- filename: import_v415.z.string().nullish(),
2837
- purpose: import_v415.z.string().nullish(),
2838
- status: import_v415.z.string().nullish()
2902
+ import { lazySchema as lazySchema5, zodSchema as zodSchema5 } from "@ai-sdk/provider-utils";
2903
+ import { z as z15 } from "zod/v4";
2904
+ var xaiFilesResponseSchema = lazySchema5(
2905
+ () => zodSchema5(
2906
+ z15.object({
2907
+ id: z15.string(),
2908
+ object: z15.string().nullish(),
2909
+ bytes: z15.number().nullish(),
2910
+ created_at: z15.number().nullish(),
2911
+ filename: z15.string().nullish(),
2912
+ purpose: z15.string().nullish(),
2913
+ status: z15.string().nullish()
2839
2914
  })
2840
2915
  )
2841
2916
  );
2842
2917
 
2843
2918
  // src/files/xai-files-options.ts
2844
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
2845
- var import_v416 = require("zod/v4");
2846
- var xaiFilesOptionsSchema = (0, import_provider_utils16.lazySchema)(
2847
- () => (0, import_provider_utils16.zodSchema)(
2848
- import_v416.z.object({
2849
- teamId: import_v416.z.string().optional(),
2850
- filePath: import_v416.z.string().optional()
2919
+ import { lazySchema as lazySchema6, zodSchema as zodSchema6 } from "@ai-sdk/provider-utils";
2920
+ import { z as z16 } from "zod/v4";
2921
+ var xaiFilesOptionsSchema = lazySchema6(
2922
+ () => zodSchema6(
2923
+ z16.object({
2924
+ teamId: z16.string().optional(),
2925
+ filePath: z16.string().optional()
2851
2926
  }).passthrough()
2852
2927
  )
2853
2928
  );
@@ -2868,12 +2943,12 @@ var XaiFiles = class {
2868
2943
  providerOptions
2869
2944
  }) {
2870
2945
  var _a, _b;
2871
- const xaiOptions = await (0, import_provider_utils17.parseProviderOptions)({
2946
+ const xaiOptions = await parseProviderOptions4({
2872
2947
  provider: "xai",
2873
2948
  providerOptions,
2874
2949
  schema: xaiFilesOptionsSchema
2875
2950
  });
2876
- const fileBytes = data instanceof Uint8Array ? data : (0, import_provider_utils17.convertBase64ToUint8Array)(data);
2951
+ const fileBytes = data instanceof Uint8Array ? data : convertBase64ToUint8Array(data);
2877
2952
  const blob = new Blob([fileBytes], {
2878
2953
  type: mediaType
2879
2954
  });
@@ -2886,12 +2961,12 @@ var XaiFiles = class {
2886
2961
  if ((xaiOptions == null ? void 0 : xaiOptions.teamId) != null) {
2887
2962
  formData.append("team_id", xaiOptions.teamId);
2888
2963
  }
2889
- const { value: response } = await (0, import_provider_utils17.postFormDataToApi)({
2964
+ const { value: response } = await postFormDataToApi({
2890
2965
  url: `${this.config.baseURL}/files`,
2891
- headers: (0, import_provider_utils17.combineHeaders)(this.config.headers()),
2966
+ headers: combineHeaders4(this.config.headers()),
2892
2967
  formData,
2893
2968
  failedResponseHandler: xaiFailedResponseHandler,
2894
- successfulResponseHandler: (0, import_provider_utils17.createJsonResponseHandler)(
2969
+ successfulResponseHandler: createJsonResponseHandler4(
2895
2970
  xaiFilesResponseSchema
2896
2971
  ),
2897
2972
  fetch: this.config.fetch
@@ -2913,59 +2988,69 @@ var XaiFiles = class {
2913
2988
  };
2914
2989
 
2915
2990
  // src/xai-video-model.ts
2916
- var import_provider6 = require("@ai-sdk/provider");
2917
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
2918
- var import_v418 = require("zod/v4");
2991
+ import {
2992
+ AISDKError
2993
+ } from "@ai-sdk/provider";
2994
+ import {
2995
+ combineHeaders as combineHeaders5,
2996
+ convertUint8ArrayToBase64,
2997
+ createJsonResponseHandler as createJsonResponseHandler5,
2998
+ delay,
2999
+ getFromApi as getFromApi2,
3000
+ parseProviderOptions as parseProviderOptions5,
3001
+ postJsonToApi as postJsonToApi4
3002
+ } from "@ai-sdk/provider-utils";
3003
+ import { z as z18 } from "zod/v4";
2919
3004
 
2920
3005
  // src/xai-video-options.ts
2921
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
2922
- var import_v417 = require("zod/v4");
2923
- var nonEmptyStringSchema = import_v417.z.string().min(1);
2924
- var resolutionSchema = import_v417.z.enum(["480p", "720p"]);
2925
- var modeSchema = import_v417.z.enum(["edit-video", "extend-video", "reference-to-video"]);
3006
+ import { lazySchema as lazySchema7, zodSchema as zodSchema7 } from "@ai-sdk/provider-utils";
3007
+ import { z as z17 } from "zod/v4";
3008
+ var nonEmptyStringSchema = z17.string().min(1);
3009
+ var resolutionSchema = z17.enum(["480p", "720p"]);
3010
+ var modeSchema = z17.enum(["edit-video", "extend-video", "reference-to-video"]);
2926
3011
  var baseFields = {
2927
- pollIntervalMs: import_v417.z.number().positive().nullish(),
2928
- pollTimeoutMs: import_v417.z.number().positive().nullish(),
3012
+ pollIntervalMs: z17.number().positive().nullish(),
3013
+ pollTimeoutMs: z17.number().positive().nullish(),
2929
3014
  resolution: resolutionSchema.nullish()
2930
3015
  };
2931
- var editVideoSchema = import_v417.z.object({
3016
+ var editVideoSchema = z17.object({
2932
3017
  ...baseFields,
2933
- mode: import_v417.z.literal("edit-video"),
3018
+ mode: z17.literal("edit-video"),
2934
3019
  videoUrl: nonEmptyStringSchema,
2935
- referenceImageUrls: import_v417.z.undefined().optional()
3020
+ referenceImageUrls: z17.undefined().optional()
2936
3021
  });
2937
- var extendVideoSchema = import_v417.z.object({
3022
+ var extendVideoSchema = z17.object({
2938
3023
  ...baseFields,
2939
- mode: import_v417.z.literal("extend-video"),
3024
+ mode: z17.literal("extend-video"),
2940
3025
  videoUrl: nonEmptyStringSchema,
2941
- referenceImageUrls: import_v417.z.undefined().optional()
3026
+ referenceImageUrls: z17.undefined().optional()
2942
3027
  });
2943
- var referenceToVideoSchema = import_v417.z.object({
3028
+ var referenceToVideoSchema = z17.object({
2944
3029
  ...baseFields,
2945
- mode: import_v417.z.literal("reference-to-video"),
2946
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7),
2947
- videoUrl: import_v417.z.undefined().optional()
3030
+ mode: z17.literal("reference-to-video"),
3031
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7),
3032
+ videoUrl: z17.undefined().optional()
2948
3033
  });
2949
- var autoDetectSchema = import_v417.z.object({
3034
+ var autoDetectSchema = z17.object({
2950
3035
  ...baseFields,
2951
- mode: import_v417.z.undefined().optional(),
3036
+ mode: z17.undefined().optional(),
2952
3037
  videoUrl: nonEmptyStringSchema.optional(),
2953
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7).optional()
3038
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7).optional()
2954
3039
  });
2955
- var xaiVideoModelOptions = import_v417.z.union([
3040
+ var xaiVideoModelOptions = z17.union([
2956
3041
  editVideoSchema,
2957
3042
  extendVideoSchema,
2958
3043
  referenceToVideoSchema,
2959
3044
  autoDetectSchema
2960
3045
  ]);
2961
- var runtimeSchema = import_v417.z.object({
3046
+ var runtimeSchema = z17.object({
2962
3047
  mode: modeSchema.optional(),
2963
3048
  videoUrl: nonEmptyStringSchema.optional(),
2964
- referenceImageUrls: import_v417.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
3049
+ referenceImageUrls: z17.array(nonEmptyStringSchema).min(1).max(7).optional(),
2965
3050
  ...baseFields
2966
3051
  }).passthrough();
2967
- var xaiVideoModelOptionsSchema = (0, import_provider_utils18.lazySchema)(
2968
- () => (0, import_provider_utils18.zodSchema)(runtimeSchema)
3052
+ var xaiVideoModelOptionsSchema = lazySchema7(
3053
+ () => zodSchema7(runtimeSchema)
2969
3054
  );
2970
3055
 
2971
3056
  // src/xai-video-model.ts
@@ -3000,7 +3085,7 @@ var XaiVideoModel = class {
3000
3085
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3001
3086
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3002
3087
  const warnings = [];
3003
- const xaiOptions = await (0, import_provider_utils19.parseProviderOptions)({
3088
+ const xaiOptions = await parseProviderOptions5({
3004
3089
  provider: "xai",
3005
3090
  providerOptions: options.providerOptions,
3006
3091
  schema: xaiVideoModelOptionsSchema
@@ -3102,7 +3187,7 @@ var XaiVideoModel = class {
3102
3187
  if (options.image.type === "url") {
3103
3188
  body.image = { url: options.image.url };
3104
3189
  } else {
3105
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils19.convertUint8ArrayToBase64)(options.image.data);
3190
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
3106
3191
  body.image = {
3107
3192
  url: `data:${options.image.mediaType};base64,${base64Data}`
3108
3193
  };
@@ -3136,12 +3221,12 @@ var XaiVideoModel = class {
3136
3221
  } else {
3137
3222
  endpoint = `${baseURL}/videos/generations`;
3138
3223
  }
3139
- const { value: createResponse } = await (0, import_provider_utils19.postJsonToApi)({
3224
+ const { value: createResponse } = await postJsonToApi4({
3140
3225
  url: endpoint,
3141
- headers: (0, import_provider_utils19.combineHeaders)(this.config.headers(), options.headers),
3226
+ headers: combineHeaders5(this.config.headers(), options.headers),
3142
3227
  body,
3143
3228
  failedResponseHandler: xaiFailedResponseHandler,
3144
- successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
3229
+ successfulResponseHandler: createJsonResponseHandler5(
3145
3230
  xaiCreateVideoResponseSchema
3146
3231
  ),
3147
3232
  abortSignal: options.abortSignal,
@@ -3149,7 +3234,7 @@ var XaiVideoModel = class {
3149
3234
  });
3150
3235
  const requestId = createResponse.request_id;
3151
3236
  if (!requestId) {
3152
- throw new import_provider6.AISDKError({
3237
+ throw new AISDKError({
3153
3238
  name: "XAI_VIDEO_GENERATION_ERROR",
3154
3239
  message: `No request_id returned from xAI API. Response: ${JSON.stringify(createResponse)}`
3155
3240
  });
@@ -3159,17 +3244,17 @@ var XaiVideoModel = class {
3159
3244
  const startTime = Date.now();
3160
3245
  let responseHeaders;
3161
3246
  while (true) {
3162
- await (0, import_provider_utils19.delay)(pollIntervalMs, { abortSignal: options.abortSignal });
3247
+ await delay(pollIntervalMs, { abortSignal: options.abortSignal });
3163
3248
  if (Date.now() - startTime > pollTimeoutMs) {
3164
- throw new import_provider6.AISDKError({
3249
+ throw new AISDKError({
3165
3250
  name: "XAI_VIDEO_GENERATION_TIMEOUT",
3166
3251
  message: `Video generation timed out after ${pollTimeoutMs}ms`
3167
3252
  });
3168
3253
  }
3169
- const { value: statusResponse, responseHeaders: pollHeaders } = await (0, import_provider_utils19.getFromApi)({
3254
+ const { value: statusResponse, responseHeaders: pollHeaders } = await getFromApi2({
3170
3255
  url: `${baseURL}/videos/${requestId}`,
3171
- headers: (0, import_provider_utils19.combineHeaders)(this.config.headers(), options.headers),
3172
- successfulResponseHandler: (0, import_provider_utils19.createJsonResponseHandler)(
3256
+ headers: combineHeaders5(this.config.headers(), options.headers),
3257
+ successfulResponseHandler: createJsonResponseHandler5(
3173
3258
  xaiVideoStatusResponseSchema
3174
3259
  ),
3175
3260
  failedResponseHandler: xaiFailedResponseHandler,
@@ -3179,13 +3264,13 @@ var XaiVideoModel = class {
3179
3264
  responseHeaders = pollHeaders;
3180
3265
  if (statusResponse.status === "done" || statusResponse.status == null && ((_g = statusResponse.video) == null ? void 0 : _g.url)) {
3181
3266
  if (((_h = statusResponse.video) == null ? void 0 : _h.respect_moderation) === false) {
3182
- throw new import_provider6.AISDKError({
3267
+ throw new AISDKError({
3183
3268
  name: "XAI_VIDEO_MODERATION_ERROR",
3184
3269
  message: "Video generation was blocked due to a content policy violation."
3185
3270
  });
3186
3271
  }
3187
3272
  if (!((_i = statusResponse.video) == null ? void 0 : _i.url)) {
3188
- throw new import_provider6.AISDKError({
3273
+ throw new AISDKError({
3189
3274
  name: "XAI_VIDEO_GENERATION_ERROR",
3190
3275
  message: "Video generation completed but no video URL was returned."
3191
3276
  });
@@ -3216,13 +3301,13 @@ var XaiVideoModel = class {
3216
3301
  };
3217
3302
  }
3218
3303
  if (statusResponse.status === "expired") {
3219
- throw new import_provider6.AISDKError({
3304
+ throw new AISDKError({
3220
3305
  name: "XAI_VIDEO_GENERATION_EXPIRED",
3221
3306
  message: "Video generation request expired."
3222
3307
  });
3223
3308
  }
3224
3309
  if (statusResponse.status === "failed") {
3225
- throw new import_provider6.AISDKError({
3310
+ throw new AISDKError({
3226
3311
  name: "XAI_VIDEO_GENERATION_FAILED",
3227
3312
  message: "Video generation failed."
3228
3313
  });
@@ -3230,36 +3315,36 @@ var XaiVideoModel = class {
3230
3315
  }
3231
3316
  }
3232
3317
  };
3233
- var xaiCreateVideoResponseSchema = import_v418.z.object({
3234
- request_id: import_v418.z.string().nullish()
3318
+ var xaiCreateVideoResponseSchema = z18.object({
3319
+ request_id: z18.string().nullish()
3235
3320
  });
3236
- var xaiVideoStatusResponseSchema = import_v418.z.object({
3237
- status: import_v418.z.string().nullish(),
3238
- video: import_v418.z.object({
3239
- url: import_v418.z.string(),
3240
- duration: import_v418.z.number().nullish(),
3241
- respect_moderation: import_v418.z.boolean().nullish()
3321
+ var xaiVideoStatusResponseSchema = z18.object({
3322
+ status: z18.string().nullish(),
3323
+ video: z18.object({
3324
+ url: z18.string(),
3325
+ duration: z18.number().nullish(),
3326
+ respect_moderation: z18.boolean().nullish()
3242
3327
  }).nullish(),
3243
- model: import_v418.z.string().nullish(),
3244
- usage: import_v418.z.object({
3245
- cost_in_usd_ticks: import_v418.z.number().nullish()
3328
+ model: z18.string().nullish(),
3329
+ usage: z18.object({
3330
+ cost_in_usd_ticks: z18.number().nullish()
3246
3331
  }).nullish(),
3247
- progress: import_v418.z.number().nullish(),
3248
- error: import_v418.z.object({
3249
- code: import_v418.z.string().nullish(),
3250
- message: import_v418.z.string().nullish()
3332
+ progress: z18.number().nullish(),
3333
+ error: z18.object({
3334
+ code: z18.string().nullish(),
3335
+ message: z18.string().nullish()
3251
3336
  }).nullish()
3252
3337
  });
3253
3338
 
3254
3339
  // src/xai-provider.ts
3255
3340
  function createXai(options = {}) {
3256
3341
  var _a;
3257
- const baseURL = (0, import_provider_utils20.withoutTrailingSlash)(
3342
+ const baseURL = withoutTrailingSlash(
3258
3343
  (_a = options.baseURL) != null ? _a : "https://api.x.ai/v1"
3259
3344
  );
3260
- const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3345
+ const getHeaders = () => withUserAgentSuffix(
3261
3346
  {
3262
- Authorization: `Bearer ${(0, import_provider_utils20.loadApiKey)({
3347
+ Authorization: `Bearer ${loadApiKey({
3263
3348
  apiKey: options.apiKey,
3264
3349
  environmentVariableName: "XAI_API_KEY",
3265
3350
  description: "xAI API key"
@@ -3273,7 +3358,7 @@ function createXai(options = {}) {
3273
3358
  provider: "xai.chat",
3274
3359
  baseURL,
3275
3360
  headers: getHeaders,
3276
- generateId: import_provider_utils20.generateId,
3361
+ generateId,
3277
3362
  fetch: options.fetch
3278
3363
  });
3279
3364
  };
@@ -3282,7 +3367,7 @@ function createXai(options = {}) {
3282
3367
  provider: "xai.responses",
3283
3368
  baseURL,
3284
3369
  headers: getHeaders,
3285
- generateId: import_provider_utils20.generateId,
3370
+ generateId,
3286
3371
  fetch: options.fetch
3287
3372
  });
3288
3373
  };
@@ -3314,7 +3399,7 @@ function createXai(options = {}) {
3314
3399
  provider.chat = createChatLanguageModel;
3315
3400
  provider.responses = createResponsesLanguageModel;
3316
3401
  provider.embeddingModel = (modelId) => {
3317
- throw new import_provider7.NoSuchModelError({ modelId, modelType: "embeddingModel" });
3402
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
3318
3403
  };
3319
3404
  provider.textEmbeddingModel = provider.embeddingModel;
3320
3405
  provider.imageModel = createImageModel;
@@ -3326,8 +3411,7 @@ function createXai(options = {}) {
3326
3411
  return provider;
3327
3412
  }
3328
3413
  var xai = createXai();
3329
- // Annotate the CommonJS export names for ESM import in node:
3330
- 0 && (module.exports = {
3414
+ export {
3331
3415
  VERSION,
3332
3416
  codeExecution,
3333
3417
  createXai,
@@ -3338,5 +3422,5 @@ var xai = createXai();
3338
3422
  xSearch,
3339
3423
  xai,
3340
3424
  xaiTools
3341
- });
3425
+ };
3342
3426
  //# sourceMappingURL=index.js.map