@ai-sdk/xai 3.0.103 → 3.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +635 -595
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +645 -605
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +36 -0
- package/package.json +4 -4
- package/src/convert-to-xai-chat-messages.ts +48 -35
- package/src/index.ts +1 -0
- package/src/responses/convert-to-xai-responses-input.ts +15 -2
- package/src/responses/xai-responses-api.ts +8 -1
- package/src/responses/xai-responses-language-model.ts +8 -5
- package/src/xai-chat-language-model.ts +1 -1
- package/src/xai-chat-prompt.ts +4 -1
- package/src/xai-file-part-options.ts +21 -0
package/dist/index.js
CHANGED
|
@@ -40,12 +40,31 @@ var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
|
40
40
|
// src/xai-chat-language-model.ts
|
|
41
41
|
var import_provider3 = require("@ai-sdk/provider");
|
|
42
42
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
43
|
-
var
|
|
43
|
+
var import_v44 = require("zod/v4");
|
|
44
44
|
|
|
45
45
|
// src/convert-to-xai-chat-messages.ts
|
|
46
46
|
var import_provider = require("@ai-sdk/provider");
|
|
47
47
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// src/xai-file-part-options.ts
|
|
50
|
+
var import_v4 = require("zod/v4");
|
|
51
|
+
var xaiFilePartProviderOptions = import_v4.z.object({
|
|
52
|
+
/**
|
|
53
|
+
* Controls the resolution at which the model processes the image.
|
|
54
|
+
* `low` processes the image at reduced resolution and consumes fewer
|
|
55
|
+
* input tokens, `high` processes the image at full resolution, and
|
|
56
|
+
* `auto` lets the API decide. Defaults to full resolution when not set.
|
|
57
|
+
*
|
|
58
|
+
* Note: the xAI API silently ignores invalid values, so the value is
|
|
59
|
+
* validated client-side.
|
|
60
|
+
*
|
|
61
|
+
* @see https://docs.x.ai/developers/model-capabilities/images/understanding
|
|
62
|
+
*/
|
|
63
|
+
imageDetail: import_v4.z.enum(["low", "high", "auto"]).optional()
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/convert-to-xai-chat-messages.ts
|
|
67
|
+
async function convertToXaiChatMessages(prompt) {
|
|
49
68
|
var _a;
|
|
50
69
|
const messages = [];
|
|
51
70
|
const warnings = [];
|
|
@@ -60,31 +79,40 @@ function convertToXaiChatMessages(prompt) {
|
|
|
60
79
|
messages.push({ role: "user", content: content[0].text });
|
|
61
80
|
break;
|
|
62
81
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
const userContent = [];
|
|
83
|
+
for (const part of content) {
|
|
84
|
+
switch (part.type) {
|
|
85
|
+
case "text": {
|
|
86
|
+
userContent.push({ type: "text", text: part.text });
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "file": {
|
|
90
|
+
if (part.mediaType.startsWith("image/")) {
|
|
91
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
92
|
+
const filePartOptions = await (0, import_provider_utils.parseProviderOptions)({
|
|
93
|
+
provider: "xai",
|
|
94
|
+
providerOptions: part.providerOptions,
|
|
95
|
+
schema: xaiFilePartProviderOptions
|
|
96
|
+
});
|
|
97
|
+
userContent.push({
|
|
98
|
+
type: "image_url",
|
|
99
|
+
image_url: {
|
|
100
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`,
|
|
101
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
102
|
+
detail: filePartOptions.imageDetail
|
|
77
103
|
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
108
|
+
functionality: `file part media type ${part.mediaType}`
|
|
109
|
+
});
|
|
84
110
|
}
|
|
111
|
+
break;
|
|
85
112
|
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
messages.push({ role: "user", content: userContent });
|
|
88
116
|
break;
|
|
89
117
|
}
|
|
90
118
|
case "assistant": {
|
|
@@ -129,7 +157,7 @@ function convertToXaiChatMessages(prompt) {
|
|
|
129
157
|
contentValue = output.value;
|
|
130
158
|
break;
|
|
131
159
|
case "execution-denied":
|
|
132
|
-
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
160
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
133
161
|
break;
|
|
134
162
|
case "content":
|
|
135
163
|
case "json":
|
|
@@ -209,53 +237,53 @@ function mapXaiFinishReason(finishReason) {
|
|
|
209
237
|
}
|
|
210
238
|
|
|
211
239
|
// src/xai-chat-options.ts
|
|
212
|
-
var
|
|
213
|
-
var webSourceSchema =
|
|
214
|
-
type:
|
|
215
|
-
country:
|
|
216
|
-
excludedWebsites:
|
|
217
|
-
allowedWebsites:
|
|
218
|
-
safeSearch:
|
|
240
|
+
var import_v42 = require("zod/v4");
|
|
241
|
+
var webSourceSchema = import_v42.z.object({
|
|
242
|
+
type: import_v42.z.literal("web"),
|
|
243
|
+
country: import_v42.z.string().length(2).optional(),
|
|
244
|
+
excludedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
245
|
+
allowedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
246
|
+
safeSearch: import_v42.z.boolean().optional()
|
|
219
247
|
});
|
|
220
|
-
var xSourceSchema =
|
|
221
|
-
type:
|
|
222
|
-
excludedXHandles:
|
|
223
|
-
includedXHandles:
|
|
224
|
-
postFavoriteCount:
|
|
225
|
-
postViewCount:
|
|
248
|
+
var xSourceSchema = import_v42.z.object({
|
|
249
|
+
type: import_v42.z.literal("x"),
|
|
250
|
+
excludedXHandles: import_v42.z.array(import_v42.z.string()).optional(),
|
|
251
|
+
includedXHandles: import_v42.z.array(import_v42.z.string()).optional(),
|
|
252
|
+
postFavoriteCount: import_v42.z.number().int().optional(),
|
|
253
|
+
postViewCount: import_v42.z.number().int().optional(),
|
|
226
254
|
/**
|
|
227
255
|
* @deprecated use `includedXHandles` instead
|
|
228
256
|
*/
|
|
229
|
-
xHandles:
|
|
257
|
+
xHandles: import_v42.z.array(import_v42.z.string()).optional()
|
|
230
258
|
});
|
|
231
|
-
var newsSourceSchema =
|
|
232
|
-
type:
|
|
233
|
-
country:
|
|
234
|
-
excludedWebsites:
|
|
235
|
-
safeSearch:
|
|
259
|
+
var newsSourceSchema = import_v42.z.object({
|
|
260
|
+
type: import_v42.z.literal("news"),
|
|
261
|
+
country: import_v42.z.string().length(2).optional(),
|
|
262
|
+
excludedWebsites: import_v42.z.array(import_v42.z.string()).max(5).optional(),
|
|
263
|
+
safeSearch: import_v42.z.boolean().optional()
|
|
236
264
|
});
|
|
237
|
-
var rssSourceSchema =
|
|
238
|
-
type:
|
|
239
|
-
links:
|
|
265
|
+
var rssSourceSchema = import_v42.z.object({
|
|
266
|
+
type: import_v42.z.literal("rss"),
|
|
267
|
+
links: import_v42.z.array(import_v42.z.string().url()).max(1)
|
|
240
268
|
// currently only supports one RSS link
|
|
241
269
|
});
|
|
242
|
-
var searchSourceSchema =
|
|
270
|
+
var searchSourceSchema = import_v42.z.discriminatedUnion("type", [
|
|
243
271
|
webSourceSchema,
|
|
244
272
|
xSourceSchema,
|
|
245
273
|
newsSourceSchema,
|
|
246
274
|
rssSourceSchema
|
|
247
275
|
]);
|
|
248
|
-
var xaiLanguageModelChatOptions =
|
|
249
|
-
reasoningEffort:
|
|
250
|
-
logprobs:
|
|
251
|
-
topLogprobs:
|
|
276
|
+
var xaiLanguageModelChatOptions = import_v42.z.object({
|
|
277
|
+
reasoningEffort: import_v42.z.enum(["none", "low", "medium", "high"]).optional(),
|
|
278
|
+
logprobs: import_v42.z.boolean().optional(),
|
|
279
|
+
topLogprobs: import_v42.z.number().int().min(0).max(8).optional(),
|
|
252
280
|
/**
|
|
253
281
|
* Whether to enable parallel function calling during tool use.
|
|
254
282
|
* When true, the model can call multiple functions in parallel.
|
|
255
283
|
* When false, the model will call functions sequentially.
|
|
256
284
|
* Defaults to true.
|
|
257
285
|
*/
|
|
258
|
-
parallel_function_calling:
|
|
286
|
+
parallel_function_calling: import_v42.z.boolean().optional(),
|
|
259
287
|
/**
|
|
260
288
|
* @deprecated xAI has deprecated Live Search (`search_parameters`) in favor
|
|
261
289
|
* of the Agent Tools API. Requests using this option now return a "Live
|
|
@@ -265,32 +293,32 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
|
265
293
|
*
|
|
266
294
|
* @see https://docs.x.ai/docs/guides/tools/overview
|
|
267
295
|
*/
|
|
268
|
-
searchParameters:
|
|
296
|
+
searchParameters: import_v42.z.object({
|
|
269
297
|
/**
|
|
270
298
|
* search mode preference
|
|
271
299
|
* - "off": disables search completely
|
|
272
300
|
* - "auto": model decides whether to search (default)
|
|
273
301
|
* - "on": always enables search
|
|
274
302
|
*/
|
|
275
|
-
mode:
|
|
303
|
+
mode: import_v42.z.enum(["off", "auto", "on"]),
|
|
276
304
|
/**
|
|
277
305
|
* whether to return citations in the response
|
|
278
306
|
* defaults to true
|
|
279
307
|
*/
|
|
280
|
-
returnCitations:
|
|
308
|
+
returnCitations: import_v42.z.boolean().optional(),
|
|
281
309
|
/**
|
|
282
310
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
283
311
|
*/
|
|
284
|
-
fromDate:
|
|
312
|
+
fromDate: import_v42.z.string().optional(),
|
|
285
313
|
/**
|
|
286
314
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
287
315
|
*/
|
|
288
|
-
toDate:
|
|
316
|
+
toDate: import_v42.z.string().optional(),
|
|
289
317
|
/**
|
|
290
318
|
* maximum number of search results to consider
|
|
291
319
|
* defaults to 20
|
|
292
320
|
*/
|
|
293
|
-
maxSearchResults:
|
|
321
|
+
maxSearchResults: import_v42.z.number().min(1).max(50).optional(),
|
|
294
322
|
/**
|
|
295
323
|
* data sources to search from.
|
|
296
324
|
* defaults to [{ type: 'web' }, { type: 'x' }] if not specified.
|
|
@@ -298,26 +326,26 @@ var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
|
298
326
|
* @example
|
|
299
327
|
* sources: [{ type: 'web', country: 'US' }, { type: 'x' }]
|
|
300
328
|
*/
|
|
301
|
-
sources:
|
|
329
|
+
sources: import_v42.z.array(searchSourceSchema).optional()
|
|
302
330
|
}).optional()
|
|
303
331
|
});
|
|
304
332
|
|
|
305
333
|
// src/xai-error.ts
|
|
306
334
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
307
|
-
var
|
|
308
|
-
var chatCompletionsErrorSchema =
|
|
309
|
-
error:
|
|
310
|
-
message:
|
|
311
|
-
type:
|
|
312
|
-
param:
|
|
313
|
-
code:
|
|
335
|
+
var import_v43 = require("zod/v4");
|
|
336
|
+
var chatCompletionsErrorSchema = import_v43.z.object({
|
|
337
|
+
error: import_v43.z.object({
|
|
338
|
+
message: import_v43.z.string(),
|
|
339
|
+
type: import_v43.z.string().nullish(),
|
|
340
|
+
param: import_v43.z.any().nullish(),
|
|
341
|
+
code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish()
|
|
314
342
|
})
|
|
315
343
|
});
|
|
316
|
-
var responsesErrorSchema =
|
|
317
|
-
code:
|
|
318
|
-
error:
|
|
344
|
+
var responsesErrorSchema = import_v43.z.object({
|
|
345
|
+
code: import_v43.z.string(),
|
|
346
|
+
error: import_v43.z.string()
|
|
319
347
|
});
|
|
320
|
-
var xaiErrorDataSchema =
|
|
348
|
+
var xaiErrorDataSchema = import_v43.z.union([
|
|
321
349
|
chatCompletionsErrorSchema,
|
|
322
350
|
responsesErrorSchema
|
|
323
351
|
]);
|
|
@@ -451,7 +479,7 @@ var XaiChatLanguageModel = class {
|
|
|
451
479
|
if (stopSequences != null) {
|
|
452
480
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
453
481
|
}
|
|
454
|
-
const { messages, warnings: messageWarnings } = convertToXaiChatMessages(prompt);
|
|
482
|
+
const { messages, warnings: messageWarnings } = await convertToXaiChatMessages(prompt);
|
|
455
483
|
warnings.push(...messageWarnings);
|
|
456
484
|
const {
|
|
457
485
|
tools: xaiTools2,
|
|
@@ -839,100 +867,100 @@ var XaiChatLanguageModel = class {
|
|
|
839
867
|
};
|
|
840
868
|
}
|
|
841
869
|
};
|
|
842
|
-
var xaiUsageSchema =
|
|
843
|
-
prompt_tokens:
|
|
844
|
-
completion_tokens:
|
|
845
|
-
total_tokens:
|
|
846
|
-
prompt_tokens_details:
|
|
847
|
-
text_tokens:
|
|
848
|
-
audio_tokens:
|
|
849
|
-
image_tokens:
|
|
850
|
-
cached_tokens:
|
|
870
|
+
var xaiUsageSchema = import_v44.z.object({
|
|
871
|
+
prompt_tokens: import_v44.z.number(),
|
|
872
|
+
completion_tokens: import_v44.z.number(),
|
|
873
|
+
total_tokens: import_v44.z.number(),
|
|
874
|
+
prompt_tokens_details: import_v44.z.object({
|
|
875
|
+
text_tokens: import_v44.z.number().nullish(),
|
|
876
|
+
audio_tokens: import_v44.z.number().nullish(),
|
|
877
|
+
image_tokens: import_v44.z.number().nullish(),
|
|
878
|
+
cached_tokens: import_v44.z.number().nullish()
|
|
851
879
|
}).nullish(),
|
|
852
|
-
completion_tokens_details:
|
|
853
|
-
reasoning_tokens:
|
|
854
|
-
audio_tokens:
|
|
855
|
-
accepted_prediction_tokens:
|
|
856
|
-
rejected_prediction_tokens:
|
|
880
|
+
completion_tokens_details: import_v44.z.object({
|
|
881
|
+
reasoning_tokens: import_v44.z.number().nullish(),
|
|
882
|
+
audio_tokens: import_v44.z.number().nullish(),
|
|
883
|
+
accepted_prediction_tokens: import_v44.z.number().nullish(),
|
|
884
|
+
rejected_prediction_tokens: import_v44.z.number().nullish()
|
|
857
885
|
}).nullish()
|
|
858
886
|
});
|
|
859
|
-
var xaiChatResponseSchema =
|
|
860
|
-
id:
|
|
861
|
-
created:
|
|
862
|
-
model:
|
|
863
|
-
choices:
|
|
864
|
-
|
|
865
|
-
message:
|
|
866
|
-
role:
|
|
867
|
-
content:
|
|
868
|
-
reasoning_content:
|
|
869
|
-
tool_calls:
|
|
870
|
-
|
|
871
|
-
id:
|
|
872
|
-
type:
|
|
873
|
-
function:
|
|
874
|
-
name:
|
|
875
|
-
arguments:
|
|
887
|
+
var xaiChatResponseSchema = import_v44.z.object({
|
|
888
|
+
id: import_v44.z.string().nullish(),
|
|
889
|
+
created: import_v44.z.number().nullish(),
|
|
890
|
+
model: import_v44.z.string().nullish(),
|
|
891
|
+
choices: import_v44.z.array(
|
|
892
|
+
import_v44.z.object({
|
|
893
|
+
message: import_v44.z.object({
|
|
894
|
+
role: import_v44.z.literal("assistant"),
|
|
895
|
+
content: import_v44.z.string().nullish(),
|
|
896
|
+
reasoning_content: import_v44.z.string().nullish(),
|
|
897
|
+
tool_calls: import_v44.z.array(
|
|
898
|
+
import_v44.z.object({
|
|
899
|
+
id: import_v44.z.string(),
|
|
900
|
+
type: import_v44.z.literal("function"),
|
|
901
|
+
function: import_v44.z.object({
|
|
902
|
+
name: import_v44.z.string(),
|
|
903
|
+
arguments: import_v44.z.string()
|
|
876
904
|
})
|
|
877
905
|
})
|
|
878
906
|
).nullish()
|
|
879
907
|
}),
|
|
880
|
-
index:
|
|
881
|
-
finish_reason:
|
|
908
|
+
index: import_v44.z.number(),
|
|
909
|
+
finish_reason: import_v44.z.string().nullish()
|
|
882
910
|
})
|
|
883
911
|
).nullish(),
|
|
884
|
-
object:
|
|
912
|
+
object: import_v44.z.literal("chat.completion").nullish(),
|
|
885
913
|
usage: xaiUsageSchema.nullish(),
|
|
886
|
-
citations:
|
|
887
|
-
code:
|
|
888
|
-
error:
|
|
914
|
+
citations: import_v44.z.array(import_v44.z.string().url()).nullish(),
|
|
915
|
+
code: import_v44.z.string().nullish(),
|
|
916
|
+
error: import_v44.z.string().nullish()
|
|
889
917
|
});
|
|
890
|
-
var xaiChatChunkSchema =
|
|
891
|
-
id:
|
|
892
|
-
created:
|
|
893
|
-
model:
|
|
894
|
-
choices:
|
|
895
|
-
|
|
896
|
-
delta:
|
|
897
|
-
role:
|
|
898
|
-
content:
|
|
899
|
-
reasoning_content:
|
|
900
|
-
tool_calls:
|
|
901
|
-
|
|
902
|
-
id:
|
|
903
|
-
type:
|
|
904
|
-
function:
|
|
905
|
-
name:
|
|
906
|
-
arguments:
|
|
918
|
+
var xaiChatChunkSchema = import_v44.z.object({
|
|
919
|
+
id: import_v44.z.string().nullish(),
|
|
920
|
+
created: import_v44.z.number().nullish(),
|
|
921
|
+
model: import_v44.z.string().nullish(),
|
|
922
|
+
choices: import_v44.z.array(
|
|
923
|
+
import_v44.z.object({
|
|
924
|
+
delta: import_v44.z.object({
|
|
925
|
+
role: import_v44.z.enum(["assistant"]).optional(),
|
|
926
|
+
content: import_v44.z.string().nullish(),
|
|
927
|
+
reasoning_content: import_v44.z.string().nullish(),
|
|
928
|
+
tool_calls: import_v44.z.array(
|
|
929
|
+
import_v44.z.object({
|
|
930
|
+
id: import_v44.z.string(),
|
|
931
|
+
type: import_v44.z.literal("function"),
|
|
932
|
+
function: import_v44.z.object({
|
|
933
|
+
name: import_v44.z.string(),
|
|
934
|
+
arguments: import_v44.z.string()
|
|
907
935
|
})
|
|
908
936
|
})
|
|
909
937
|
).nullish()
|
|
910
938
|
}),
|
|
911
|
-
finish_reason:
|
|
912
|
-
index:
|
|
939
|
+
finish_reason: import_v44.z.string().nullish(),
|
|
940
|
+
index: import_v44.z.number()
|
|
913
941
|
})
|
|
914
942
|
),
|
|
915
943
|
usage: xaiUsageSchema.nullish(),
|
|
916
|
-
citations:
|
|
944
|
+
citations: import_v44.z.array(import_v44.z.string().url()).nullish()
|
|
917
945
|
});
|
|
918
|
-
var xaiStreamErrorSchema =
|
|
919
|
-
code:
|
|
920
|
-
error:
|
|
946
|
+
var xaiStreamErrorSchema = import_v44.z.object({
|
|
947
|
+
code: import_v44.z.string(),
|
|
948
|
+
error: import_v44.z.string()
|
|
921
949
|
});
|
|
922
950
|
|
|
923
951
|
// src/xai-image-model.ts
|
|
924
952
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
925
|
-
var
|
|
953
|
+
var import_v46 = require("zod/v4");
|
|
926
954
|
|
|
927
955
|
// src/xai-image-options.ts
|
|
928
|
-
var
|
|
929
|
-
var xaiImageModelOptions =
|
|
930
|
-
aspect_ratio:
|
|
931
|
-
output_format:
|
|
932
|
-
sync_mode:
|
|
933
|
-
resolution:
|
|
934
|
-
quality:
|
|
935
|
-
user:
|
|
956
|
+
var import_v45 = require("zod/v4");
|
|
957
|
+
var xaiImageModelOptions = import_v45.z.object({
|
|
958
|
+
aspect_ratio: import_v45.z.string().optional(),
|
|
959
|
+
output_format: import_v45.z.string().optional(),
|
|
960
|
+
sync_mode: import_v45.z.boolean().optional(),
|
|
961
|
+
resolution: import_v45.z.enum(["1k", "2k"]).optional(),
|
|
962
|
+
quality: import_v45.z.enum(["low", "medium", "high"]).optional(),
|
|
963
|
+
user: import_v45.z.string().optional()
|
|
936
964
|
});
|
|
937
965
|
|
|
938
966
|
// src/xai-image-model.ts
|
|
@@ -1067,16 +1095,16 @@ var XaiImageModel = class {
|
|
|
1067
1095
|
return value;
|
|
1068
1096
|
}
|
|
1069
1097
|
};
|
|
1070
|
-
var xaiImageResponseSchema =
|
|
1071
|
-
data:
|
|
1072
|
-
|
|
1073
|
-
url:
|
|
1074
|
-
b64_json:
|
|
1075
|
-
revised_prompt:
|
|
1098
|
+
var xaiImageResponseSchema = import_v46.z.object({
|
|
1099
|
+
data: import_v46.z.array(
|
|
1100
|
+
import_v46.z.object({
|
|
1101
|
+
url: import_v46.z.string().nullish(),
|
|
1102
|
+
b64_json: import_v46.z.string().nullish(),
|
|
1103
|
+
revised_prompt: import_v46.z.string().nullish()
|
|
1076
1104
|
})
|
|
1077
1105
|
),
|
|
1078
|
-
usage:
|
|
1079
|
-
cost_in_usd_ticks:
|
|
1106
|
+
usage: import_v46.z.object({
|
|
1107
|
+
cost_in_usd_ticks: import_v46.z.number().nullish()
|
|
1080
1108
|
}).nullish()
|
|
1081
1109
|
});
|
|
1082
1110
|
|
|
@@ -1113,7 +1141,18 @@ async function convertToXaiResponsesInput({
|
|
|
1113
1141
|
if (block.mediaType.startsWith("image/")) {
|
|
1114
1142
|
const mediaType = block.mediaType === "image/*" ? "image/jpeg" : block.mediaType;
|
|
1115
1143
|
const imageUrl = block.data instanceof URL ? block.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils5.convertToBase64)(block.data)}`;
|
|
1116
|
-
|
|
1144
|
+
const filePartOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
1145
|
+
provider: "xai",
|
|
1146
|
+
providerOptions: block.providerOptions,
|
|
1147
|
+
schema: xaiFilePartProviderOptions
|
|
1148
|
+
});
|
|
1149
|
+
contentParts.push({
|
|
1150
|
+
type: "input_image",
|
|
1151
|
+
image_url: imageUrl,
|
|
1152
|
+
...(filePartOptions == null ? void 0 : filePartOptions.imageDetail) != null && {
|
|
1153
|
+
detail: filePartOptions.imageDetail
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1117
1156
|
} else if (block.data instanceof URL) {
|
|
1118
1157
|
contentParts.push({
|
|
1119
1158
|
type: "input_file",
|
|
@@ -1311,460 +1350,461 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
1311
1350
|
}
|
|
1312
1351
|
|
|
1313
1352
|
// src/responses/xai-responses-api.ts
|
|
1314
|
-
var
|
|
1315
|
-
var annotationSchema =
|
|
1316
|
-
|
|
1317
|
-
type:
|
|
1318
|
-
url:
|
|
1319
|
-
title:
|
|
1353
|
+
var import_v47 = require("zod/v4");
|
|
1354
|
+
var annotationSchema = import_v47.z.union([
|
|
1355
|
+
import_v47.z.object({
|
|
1356
|
+
type: import_v47.z.literal("url_citation"),
|
|
1357
|
+
url: import_v47.z.string(),
|
|
1358
|
+
title: import_v47.z.string().optional()
|
|
1320
1359
|
}),
|
|
1321
|
-
|
|
1322
|
-
type:
|
|
1360
|
+
import_v47.z.object({
|
|
1361
|
+
type: import_v47.z.string()
|
|
1323
1362
|
})
|
|
1324
1363
|
]);
|
|
1325
|
-
var messageContentPartSchema =
|
|
1326
|
-
type:
|
|
1327
|
-
text:
|
|
1328
|
-
logprobs:
|
|
1329
|
-
annotations:
|
|
1364
|
+
var messageContentPartSchema = import_v47.z.object({
|
|
1365
|
+
type: import_v47.z.string(),
|
|
1366
|
+
text: import_v47.z.string().optional(),
|
|
1367
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional(),
|
|
1368
|
+
annotations: import_v47.z.array(annotationSchema).optional()
|
|
1330
1369
|
});
|
|
1331
|
-
var reasoningSummaryPartSchema =
|
|
1332
|
-
type:
|
|
1333
|
-
text:
|
|
1370
|
+
var reasoningSummaryPartSchema = import_v47.z.object({
|
|
1371
|
+
type: import_v47.z.string(),
|
|
1372
|
+
text: import_v47.z.string()
|
|
1334
1373
|
});
|
|
1335
|
-
var toolCallSchema =
|
|
1336
|
-
name:
|
|
1337
|
-
arguments:
|
|
1338
|
-
input:
|
|
1339
|
-
call_id:
|
|
1340
|
-
id:
|
|
1341
|
-
status:
|
|
1342
|
-
action:
|
|
1374
|
+
var toolCallSchema = import_v47.z.object({
|
|
1375
|
+
name: import_v47.z.string().optional(),
|
|
1376
|
+
arguments: import_v47.z.string().optional(),
|
|
1377
|
+
input: import_v47.z.string().optional(),
|
|
1378
|
+
call_id: import_v47.z.string().optional(),
|
|
1379
|
+
id: import_v47.z.string(),
|
|
1380
|
+
status: import_v47.z.string(),
|
|
1381
|
+
action: import_v47.z.any().optional()
|
|
1343
1382
|
});
|
|
1344
|
-
var mcpCallSchema =
|
|
1345
|
-
name:
|
|
1346
|
-
arguments:
|
|
1347
|
-
output:
|
|
1348
|
-
error:
|
|
1349
|
-
id:
|
|
1350
|
-
status:
|
|
1351
|
-
server_label:
|
|
1383
|
+
var mcpCallSchema = import_v47.z.object({
|
|
1384
|
+
name: import_v47.z.string().optional(),
|
|
1385
|
+
arguments: import_v47.z.string().optional(),
|
|
1386
|
+
output: import_v47.z.string().optional(),
|
|
1387
|
+
error: import_v47.z.string().optional(),
|
|
1388
|
+
id: import_v47.z.string(),
|
|
1389
|
+
status: import_v47.z.string(),
|
|
1390
|
+
server_label: import_v47.z.string().optional()
|
|
1352
1391
|
});
|
|
1353
|
-
var outputItemSchema =
|
|
1354
|
-
|
|
1355
|
-
type:
|
|
1392
|
+
var outputItemSchema = import_v47.z.discriminatedUnion("type", [
|
|
1393
|
+
import_v47.z.object({
|
|
1394
|
+
type: import_v47.z.literal("web_search_call"),
|
|
1356
1395
|
...toolCallSchema.shape
|
|
1357
1396
|
}),
|
|
1358
|
-
|
|
1359
|
-
type:
|
|
1397
|
+
import_v47.z.object({
|
|
1398
|
+
type: import_v47.z.literal("x_search_call"),
|
|
1360
1399
|
...toolCallSchema.shape
|
|
1361
1400
|
}),
|
|
1362
|
-
|
|
1363
|
-
type:
|
|
1401
|
+
import_v47.z.object({
|
|
1402
|
+
type: import_v47.z.literal("code_interpreter_call"),
|
|
1364
1403
|
...toolCallSchema.shape
|
|
1365
1404
|
}),
|
|
1366
|
-
|
|
1367
|
-
type:
|
|
1405
|
+
import_v47.z.object({
|
|
1406
|
+
type: import_v47.z.literal("code_execution_call"),
|
|
1368
1407
|
...toolCallSchema.shape
|
|
1369
1408
|
}),
|
|
1370
|
-
|
|
1371
|
-
type:
|
|
1409
|
+
import_v47.z.object({
|
|
1410
|
+
type: import_v47.z.literal("view_image_call"),
|
|
1372
1411
|
...toolCallSchema.shape
|
|
1373
1412
|
}),
|
|
1374
|
-
|
|
1375
|
-
type:
|
|
1413
|
+
import_v47.z.object({
|
|
1414
|
+
type: import_v47.z.literal("view_x_video_call"),
|
|
1376
1415
|
...toolCallSchema.shape
|
|
1377
1416
|
}),
|
|
1378
|
-
|
|
1379
|
-
type:
|
|
1380
|
-
id:
|
|
1381
|
-
status:
|
|
1382
|
-
queries:
|
|
1383
|
-
results:
|
|
1384
|
-
|
|
1385
|
-
file_id:
|
|
1386
|
-
filename:
|
|
1387
|
-
score:
|
|
1388
|
-
text:
|
|
1417
|
+
import_v47.z.object({
|
|
1418
|
+
type: import_v47.z.literal("file_search_call"),
|
|
1419
|
+
id: import_v47.z.string(),
|
|
1420
|
+
status: import_v47.z.string(),
|
|
1421
|
+
queries: import_v47.z.array(import_v47.z.string()).optional(),
|
|
1422
|
+
results: import_v47.z.array(
|
|
1423
|
+
import_v47.z.object({
|
|
1424
|
+
file_id: import_v47.z.string(),
|
|
1425
|
+
filename: import_v47.z.string(),
|
|
1426
|
+
score: import_v47.z.number(),
|
|
1427
|
+
text: import_v47.z.string()
|
|
1389
1428
|
})
|
|
1390
1429
|
).nullish()
|
|
1391
1430
|
}),
|
|
1392
|
-
|
|
1393
|
-
type:
|
|
1431
|
+
import_v47.z.object({
|
|
1432
|
+
type: import_v47.z.literal("custom_tool_call"),
|
|
1394
1433
|
...toolCallSchema.shape
|
|
1395
1434
|
}),
|
|
1396
|
-
|
|
1397
|
-
type:
|
|
1435
|
+
import_v47.z.object({
|
|
1436
|
+
type: import_v47.z.literal("mcp_call"),
|
|
1398
1437
|
...mcpCallSchema.shape
|
|
1399
1438
|
}),
|
|
1400
|
-
|
|
1401
|
-
type:
|
|
1402
|
-
role:
|
|
1403
|
-
content:
|
|
1404
|
-
id:
|
|
1405
|
-
status:
|
|
1439
|
+
import_v47.z.object({
|
|
1440
|
+
type: import_v47.z.literal("message"),
|
|
1441
|
+
role: import_v47.z.string(),
|
|
1442
|
+
content: import_v47.z.array(messageContentPartSchema),
|
|
1443
|
+
id: import_v47.z.string(),
|
|
1444
|
+
status: import_v47.z.string()
|
|
1406
1445
|
}),
|
|
1407
|
-
|
|
1408
|
-
type:
|
|
1409
|
-
name:
|
|
1410
|
-
arguments:
|
|
1411
|
-
call_id:
|
|
1412
|
-
id:
|
|
1446
|
+
import_v47.z.object({
|
|
1447
|
+
type: import_v47.z.literal("function_call"),
|
|
1448
|
+
name: import_v47.z.string(),
|
|
1449
|
+
arguments: import_v47.z.string(),
|
|
1450
|
+
call_id: import_v47.z.string(),
|
|
1451
|
+
id: import_v47.z.string()
|
|
1413
1452
|
}),
|
|
1414
|
-
|
|
1415
|
-
type:
|
|
1416
|
-
id:
|
|
1417
|
-
summary:
|
|
1418
|
-
|
|
1419
|
-
|
|
1453
|
+
import_v47.z.object({
|
|
1454
|
+
type: import_v47.z.literal("reasoning"),
|
|
1455
|
+
id: import_v47.z.string(),
|
|
1456
|
+
summary: import_v47.z.array(reasoningSummaryPartSchema),
|
|
1457
|
+
content: import_v47.z.array(import_v47.z.object({ type: import_v47.z.string(), text: import_v47.z.string() })).nullish(),
|
|
1458
|
+
status: import_v47.z.string(),
|
|
1459
|
+
encrypted_content: import_v47.z.string().nullish()
|
|
1420
1460
|
})
|
|
1421
1461
|
]);
|
|
1422
|
-
var xaiResponsesUsageSchema =
|
|
1423
|
-
input_tokens:
|
|
1424
|
-
output_tokens:
|
|
1425
|
-
total_tokens:
|
|
1426
|
-
input_tokens_details:
|
|
1427
|
-
cached_tokens:
|
|
1462
|
+
var xaiResponsesUsageSchema = import_v47.z.object({
|
|
1463
|
+
input_tokens: import_v47.z.number(),
|
|
1464
|
+
output_tokens: import_v47.z.number(),
|
|
1465
|
+
total_tokens: import_v47.z.number().optional(),
|
|
1466
|
+
input_tokens_details: import_v47.z.object({
|
|
1467
|
+
cached_tokens: import_v47.z.number().optional()
|
|
1428
1468
|
}).optional(),
|
|
1429
|
-
output_tokens_details:
|
|
1430
|
-
reasoning_tokens:
|
|
1469
|
+
output_tokens_details: import_v47.z.object({
|
|
1470
|
+
reasoning_tokens: import_v47.z.number().optional()
|
|
1431
1471
|
}).optional(),
|
|
1432
|
-
num_sources_used:
|
|
1433
|
-
num_server_side_tools_used:
|
|
1472
|
+
num_sources_used: import_v47.z.number().optional(),
|
|
1473
|
+
num_server_side_tools_used: import_v47.z.number().optional()
|
|
1434
1474
|
});
|
|
1435
|
-
var xaiResponsesResponseSchema =
|
|
1436
|
-
id:
|
|
1437
|
-
created_at:
|
|
1438
|
-
model:
|
|
1439
|
-
object:
|
|
1440
|
-
output:
|
|
1475
|
+
var xaiResponsesResponseSchema = import_v47.z.object({
|
|
1476
|
+
id: import_v47.z.string().nullish(),
|
|
1477
|
+
created_at: import_v47.z.number().nullish(),
|
|
1478
|
+
model: import_v47.z.string().nullish(),
|
|
1479
|
+
object: import_v47.z.literal("response"),
|
|
1480
|
+
output: import_v47.z.array(outputItemSchema),
|
|
1441
1481
|
usage: xaiResponsesUsageSchema.nullish(),
|
|
1442
|
-
status:
|
|
1482
|
+
status: import_v47.z.string()
|
|
1443
1483
|
});
|
|
1444
|
-
var xaiResponsesChunkSchema =
|
|
1445
|
-
|
|
1446
|
-
type:
|
|
1484
|
+
var xaiResponsesChunkSchema = import_v47.z.union([
|
|
1485
|
+
import_v47.z.object({
|
|
1486
|
+
type: import_v47.z.literal("response.created"),
|
|
1447
1487
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1448
1488
|
}),
|
|
1449
|
-
|
|
1450
|
-
type:
|
|
1489
|
+
import_v47.z.object({
|
|
1490
|
+
type: import_v47.z.literal("response.in_progress"),
|
|
1451
1491
|
response: xaiResponsesResponseSchema.partial({ usage: true, status: true })
|
|
1452
1492
|
}),
|
|
1453
|
-
|
|
1454
|
-
type:
|
|
1493
|
+
import_v47.z.object({
|
|
1494
|
+
type: import_v47.z.literal("response.output_item.added"),
|
|
1455
1495
|
item: outputItemSchema,
|
|
1456
|
-
output_index:
|
|
1496
|
+
output_index: import_v47.z.number()
|
|
1457
1497
|
}),
|
|
1458
|
-
|
|
1459
|
-
type:
|
|
1498
|
+
import_v47.z.object({
|
|
1499
|
+
type: import_v47.z.literal("response.output_item.done"),
|
|
1460
1500
|
item: outputItemSchema,
|
|
1461
|
-
output_index:
|
|
1501
|
+
output_index: import_v47.z.number()
|
|
1462
1502
|
}),
|
|
1463
|
-
|
|
1464
|
-
type:
|
|
1465
|
-
item_id:
|
|
1466
|
-
output_index:
|
|
1467
|
-
content_index:
|
|
1503
|
+
import_v47.z.object({
|
|
1504
|
+
type: import_v47.z.literal("response.content_part.added"),
|
|
1505
|
+
item_id: import_v47.z.string(),
|
|
1506
|
+
output_index: import_v47.z.number(),
|
|
1507
|
+
content_index: import_v47.z.number(),
|
|
1468
1508
|
part: messageContentPartSchema
|
|
1469
1509
|
}),
|
|
1470
|
-
|
|
1471
|
-
type:
|
|
1472
|
-
item_id:
|
|
1473
|
-
output_index:
|
|
1474
|
-
content_index:
|
|
1510
|
+
import_v47.z.object({
|
|
1511
|
+
type: import_v47.z.literal("response.content_part.done"),
|
|
1512
|
+
item_id: import_v47.z.string(),
|
|
1513
|
+
output_index: import_v47.z.number(),
|
|
1514
|
+
content_index: import_v47.z.number(),
|
|
1475
1515
|
part: messageContentPartSchema
|
|
1476
1516
|
}),
|
|
1477
|
-
|
|
1478
|
-
type:
|
|
1479
|
-
item_id:
|
|
1480
|
-
output_index:
|
|
1481
|
-
content_index:
|
|
1482
|
-
delta:
|
|
1483
|
-
logprobs:
|
|
1517
|
+
import_v47.z.object({
|
|
1518
|
+
type: import_v47.z.literal("response.output_text.delta"),
|
|
1519
|
+
item_id: import_v47.z.string(),
|
|
1520
|
+
output_index: import_v47.z.number(),
|
|
1521
|
+
content_index: import_v47.z.number(),
|
|
1522
|
+
delta: import_v47.z.string(),
|
|
1523
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional()
|
|
1484
1524
|
}),
|
|
1485
|
-
|
|
1486
|
-
type:
|
|
1487
|
-
item_id:
|
|
1488
|
-
output_index:
|
|
1489
|
-
content_index:
|
|
1490
|
-
text:
|
|
1491
|
-
logprobs:
|
|
1492
|
-
annotations:
|
|
1525
|
+
import_v47.z.object({
|
|
1526
|
+
type: import_v47.z.literal("response.output_text.done"),
|
|
1527
|
+
item_id: import_v47.z.string(),
|
|
1528
|
+
output_index: import_v47.z.number(),
|
|
1529
|
+
content_index: import_v47.z.number(),
|
|
1530
|
+
text: import_v47.z.string(),
|
|
1531
|
+
logprobs: import_v47.z.array(import_v47.z.any()).optional(),
|
|
1532
|
+
annotations: import_v47.z.array(annotationSchema).optional()
|
|
1493
1533
|
}),
|
|
1494
|
-
|
|
1495
|
-
type:
|
|
1496
|
-
item_id:
|
|
1497
|
-
output_index:
|
|
1498
|
-
content_index:
|
|
1499
|
-
annotation_index:
|
|
1534
|
+
import_v47.z.object({
|
|
1535
|
+
type: import_v47.z.literal("response.output_text.annotation.added"),
|
|
1536
|
+
item_id: import_v47.z.string(),
|
|
1537
|
+
output_index: import_v47.z.number(),
|
|
1538
|
+
content_index: import_v47.z.number(),
|
|
1539
|
+
annotation_index: import_v47.z.number(),
|
|
1500
1540
|
annotation: annotationSchema
|
|
1501
1541
|
}),
|
|
1502
|
-
|
|
1503
|
-
type:
|
|
1504
|
-
item_id:
|
|
1505
|
-
output_index:
|
|
1506
|
-
summary_index:
|
|
1542
|
+
import_v47.z.object({
|
|
1543
|
+
type: import_v47.z.literal("response.reasoning_summary_part.added"),
|
|
1544
|
+
item_id: import_v47.z.string(),
|
|
1545
|
+
output_index: import_v47.z.number(),
|
|
1546
|
+
summary_index: import_v47.z.number(),
|
|
1507
1547
|
part: reasoningSummaryPartSchema
|
|
1508
1548
|
}),
|
|
1509
|
-
|
|
1510
|
-
type:
|
|
1511
|
-
item_id:
|
|
1512
|
-
output_index:
|
|
1513
|
-
summary_index:
|
|
1549
|
+
import_v47.z.object({
|
|
1550
|
+
type: import_v47.z.literal("response.reasoning_summary_part.done"),
|
|
1551
|
+
item_id: import_v47.z.string(),
|
|
1552
|
+
output_index: import_v47.z.number(),
|
|
1553
|
+
summary_index: import_v47.z.number(),
|
|
1514
1554
|
part: reasoningSummaryPartSchema
|
|
1515
1555
|
}),
|
|
1516
|
-
|
|
1517
|
-
type:
|
|
1518
|
-
item_id:
|
|
1519
|
-
output_index:
|
|
1520
|
-
summary_index:
|
|
1521
|
-
delta:
|
|
1556
|
+
import_v47.z.object({
|
|
1557
|
+
type: import_v47.z.literal("response.reasoning_summary_text.delta"),
|
|
1558
|
+
item_id: import_v47.z.string(),
|
|
1559
|
+
output_index: import_v47.z.number(),
|
|
1560
|
+
summary_index: import_v47.z.number(),
|
|
1561
|
+
delta: import_v47.z.string()
|
|
1522
1562
|
}),
|
|
1523
|
-
|
|
1524
|
-
type:
|
|
1525
|
-
item_id:
|
|
1526
|
-
output_index:
|
|
1527
|
-
summary_index:
|
|
1528
|
-
text:
|
|
1563
|
+
import_v47.z.object({
|
|
1564
|
+
type: import_v47.z.literal("response.reasoning_summary_text.done"),
|
|
1565
|
+
item_id: import_v47.z.string(),
|
|
1566
|
+
output_index: import_v47.z.number(),
|
|
1567
|
+
summary_index: import_v47.z.number(),
|
|
1568
|
+
text: import_v47.z.string()
|
|
1529
1569
|
}),
|
|
1530
|
-
|
|
1531
|
-
type:
|
|
1532
|
-
item_id:
|
|
1533
|
-
output_index:
|
|
1534
|
-
content_index:
|
|
1535
|
-
delta:
|
|
1570
|
+
import_v47.z.object({
|
|
1571
|
+
type: import_v47.z.literal("response.reasoning_text.delta"),
|
|
1572
|
+
item_id: import_v47.z.string(),
|
|
1573
|
+
output_index: import_v47.z.number(),
|
|
1574
|
+
content_index: import_v47.z.number(),
|
|
1575
|
+
delta: import_v47.z.string()
|
|
1536
1576
|
}),
|
|
1537
|
-
|
|
1538
|
-
type:
|
|
1539
|
-
item_id:
|
|
1540
|
-
output_index:
|
|
1541
|
-
content_index:
|
|
1542
|
-
text:
|
|
1577
|
+
import_v47.z.object({
|
|
1578
|
+
type: import_v47.z.literal("response.reasoning_text.done"),
|
|
1579
|
+
item_id: import_v47.z.string(),
|
|
1580
|
+
output_index: import_v47.z.number(),
|
|
1581
|
+
content_index: import_v47.z.number(),
|
|
1582
|
+
text: import_v47.z.string()
|
|
1543
1583
|
}),
|
|
1544
|
-
|
|
1545
|
-
type:
|
|
1546
|
-
item_id:
|
|
1547
|
-
output_index:
|
|
1584
|
+
import_v47.z.object({
|
|
1585
|
+
type: import_v47.z.literal("response.web_search_call.in_progress"),
|
|
1586
|
+
item_id: import_v47.z.string(),
|
|
1587
|
+
output_index: import_v47.z.number()
|
|
1548
1588
|
}),
|
|
1549
|
-
|
|
1550
|
-
type:
|
|
1551
|
-
item_id:
|
|
1552
|
-
output_index:
|
|
1589
|
+
import_v47.z.object({
|
|
1590
|
+
type: import_v47.z.literal("response.web_search_call.searching"),
|
|
1591
|
+
item_id: import_v47.z.string(),
|
|
1592
|
+
output_index: import_v47.z.number()
|
|
1553
1593
|
}),
|
|
1554
|
-
|
|
1555
|
-
type:
|
|
1556
|
-
item_id:
|
|
1557
|
-
output_index:
|
|
1594
|
+
import_v47.z.object({
|
|
1595
|
+
type: import_v47.z.literal("response.web_search_call.completed"),
|
|
1596
|
+
item_id: import_v47.z.string(),
|
|
1597
|
+
output_index: import_v47.z.number()
|
|
1558
1598
|
}),
|
|
1559
|
-
|
|
1560
|
-
type:
|
|
1561
|
-
item_id:
|
|
1562
|
-
output_index:
|
|
1599
|
+
import_v47.z.object({
|
|
1600
|
+
type: import_v47.z.literal("response.x_search_call.in_progress"),
|
|
1601
|
+
item_id: import_v47.z.string(),
|
|
1602
|
+
output_index: import_v47.z.number()
|
|
1563
1603
|
}),
|
|
1564
|
-
|
|
1565
|
-
type:
|
|
1566
|
-
item_id:
|
|
1567
|
-
output_index:
|
|
1604
|
+
import_v47.z.object({
|
|
1605
|
+
type: import_v47.z.literal("response.x_search_call.searching"),
|
|
1606
|
+
item_id: import_v47.z.string(),
|
|
1607
|
+
output_index: import_v47.z.number()
|
|
1568
1608
|
}),
|
|
1569
|
-
|
|
1570
|
-
type:
|
|
1571
|
-
item_id:
|
|
1572
|
-
output_index:
|
|
1609
|
+
import_v47.z.object({
|
|
1610
|
+
type: import_v47.z.literal("response.x_search_call.completed"),
|
|
1611
|
+
item_id: import_v47.z.string(),
|
|
1612
|
+
output_index: import_v47.z.number()
|
|
1573
1613
|
}),
|
|
1574
|
-
|
|
1575
|
-
type:
|
|
1576
|
-
item_id:
|
|
1577
|
-
output_index:
|
|
1614
|
+
import_v47.z.object({
|
|
1615
|
+
type: import_v47.z.literal("response.file_search_call.in_progress"),
|
|
1616
|
+
item_id: import_v47.z.string(),
|
|
1617
|
+
output_index: import_v47.z.number()
|
|
1578
1618
|
}),
|
|
1579
|
-
|
|
1580
|
-
type:
|
|
1581
|
-
item_id:
|
|
1582
|
-
output_index:
|
|
1619
|
+
import_v47.z.object({
|
|
1620
|
+
type: import_v47.z.literal("response.file_search_call.searching"),
|
|
1621
|
+
item_id: import_v47.z.string(),
|
|
1622
|
+
output_index: import_v47.z.number()
|
|
1583
1623
|
}),
|
|
1584
|
-
|
|
1585
|
-
type:
|
|
1586
|
-
item_id:
|
|
1587
|
-
output_index:
|
|
1624
|
+
import_v47.z.object({
|
|
1625
|
+
type: import_v47.z.literal("response.file_search_call.completed"),
|
|
1626
|
+
item_id: import_v47.z.string(),
|
|
1627
|
+
output_index: import_v47.z.number()
|
|
1588
1628
|
}),
|
|
1589
|
-
|
|
1590
|
-
type:
|
|
1591
|
-
item_id:
|
|
1592
|
-
output_index:
|
|
1629
|
+
import_v47.z.object({
|
|
1630
|
+
type: import_v47.z.literal("response.code_execution_call.in_progress"),
|
|
1631
|
+
item_id: import_v47.z.string(),
|
|
1632
|
+
output_index: import_v47.z.number()
|
|
1593
1633
|
}),
|
|
1594
|
-
|
|
1595
|
-
type:
|
|
1596
|
-
item_id:
|
|
1597
|
-
output_index:
|
|
1634
|
+
import_v47.z.object({
|
|
1635
|
+
type: import_v47.z.literal("response.code_execution_call.executing"),
|
|
1636
|
+
item_id: import_v47.z.string(),
|
|
1637
|
+
output_index: import_v47.z.number()
|
|
1598
1638
|
}),
|
|
1599
|
-
|
|
1600
|
-
type:
|
|
1601
|
-
item_id:
|
|
1602
|
-
output_index:
|
|
1639
|
+
import_v47.z.object({
|
|
1640
|
+
type: import_v47.z.literal("response.code_execution_call.completed"),
|
|
1641
|
+
item_id: import_v47.z.string(),
|
|
1642
|
+
output_index: import_v47.z.number()
|
|
1603
1643
|
}),
|
|
1604
|
-
|
|
1605
|
-
type:
|
|
1606
|
-
item_id:
|
|
1607
|
-
output_index:
|
|
1644
|
+
import_v47.z.object({
|
|
1645
|
+
type: import_v47.z.literal("response.code_interpreter_call.in_progress"),
|
|
1646
|
+
item_id: import_v47.z.string(),
|
|
1647
|
+
output_index: import_v47.z.number()
|
|
1608
1648
|
}),
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
1611
|
-
item_id:
|
|
1612
|
-
output_index:
|
|
1649
|
+
import_v47.z.object({
|
|
1650
|
+
type: import_v47.z.literal("response.code_interpreter_call.executing"),
|
|
1651
|
+
item_id: import_v47.z.string(),
|
|
1652
|
+
output_index: import_v47.z.number()
|
|
1613
1653
|
}),
|
|
1614
|
-
|
|
1615
|
-
type:
|
|
1616
|
-
item_id:
|
|
1617
|
-
output_index:
|
|
1654
|
+
import_v47.z.object({
|
|
1655
|
+
type: import_v47.z.literal("response.code_interpreter_call.interpreting"),
|
|
1656
|
+
item_id: import_v47.z.string(),
|
|
1657
|
+
output_index: import_v47.z.number()
|
|
1618
1658
|
}),
|
|
1619
|
-
|
|
1620
|
-
type:
|
|
1621
|
-
item_id:
|
|
1622
|
-
output_index:
|
|
1659
|
+
import_v47.z.object({
|
|
1660
|
+
type: import_v47.z.literal("response.code_interpreter_call.completed"),
|
|
1661
|
+
item_id: import_v47.z.string(),
|
|
1662
|
+
output_index: import_v47.z.number()
|
|
1623
1663
|
}),
|
|
1624
1664
|
// Code interpreter code streaming events
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
item_id:
|
|
1628
|
-
output_index:
|
|
1629
|
-
delta:
|
|
1665
|
+
import_v47.z.object({
|
|
1666
|
+
type: import_v47.z.literal("response.code_interpreter_call_code.delta"),
|
|
1667
|
+
item_id: import_v47.z.string(),
|
|
1668
|
+
output_index: import_v47.z.number(),
|
|
1669
|
+
delta: import_v47.z.string()
|
|
1630
1670
|
}),
|
|
1631
|
-
|
|
1632
|
-
type:
|
|
1633
|
-
item_id:
|
|
1634
|
-
output_index:
|
|
1635
|
-
code:
|
|
1671
|
+
import_v47.z.object({
|
|
1672
|
+
type: import_v47.z.literal("response.code_interpreter_call_code.done"),
|
|
1673
|
+
item_id: import_v47.z.string(),
|
|
1674
|
+
output_index: import_v47.z.number(),
|
|
1675
|
+
code: import_v47.z.string()
|
|
1636
1676
|
}),
|
|
1637
|
-
|
|
1638
|
-
type:
|
|
1639
|
-
item_id:
|
|
1640
|
-
output_index:
|
|
1641
|
-
delta:
|
|
1677
|
+
import_v47.z.object({
|
|
1678
|
+
type: import_v47.z.literal("response.custom_tool_call_input.delta"),
|
|
1679
|
+
item_id: import_v47.z.string(),
|
|
1680
|
+
output_index: import_v47.z.number(),
|
|
1681
|
+
delta: import_v47.z.string()
|
|
1642
1682
|
}),
|
|
1643
|
-
|
|
1644
|
-
type:
|
|
1645
|
-
item_id:
|
|
1646
|
-
output_index:
|
|
1647
|
-
input:
|
|
1683
|
+
import_v47.z.object({
|
|
1684
|
+
type: import_v47.z.literal("response.custom_tool_call_input.done"),
|
|
1685
|
+
item_id: import_v47.z.string(),
|
|
1686
|
+
output_index: import_v47.z.number(),
|
|
1687
|
+
input: import_v47.z.string()
|
|
1648
1688
|
}),
|
|
1649
1689
|
// Function call arguments streaming events (standard function tools)
|
|
1650
|
-
|
|
1651
|
-
type:
|
|
1652
|
-
item_id:
|
|
1653
|
-
output_index:
|
|
1654
|
-
delta:
|
|
1690
|
+
import_v47.z.object({
|
|
1691
|
+
type: import_v47.z.literal("response.function_call_arguments.delta"),
|
|
1692
|
+
item_id: import_v47.z.string(),
|
|
1693
|
+
output_index: import_v47.z.number(),
|
|
1694
|
+
delta: import_v47.z.string()
|
|
1655
1695
|
}),
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
item_id:
|
|
1659
|
-
output_index:
|
|
1660
|
-
arguments:
|
|
1696
|
+
import_v47.z.object({
|
|
1697
|
+
type: import_v47.z.literal("response.function_call_arguments.done"),
|
|
1698
|
+
item_id: import_v47.z.string(),
|
|
1699
|
+
output_index: import_v47.z.number(),
|
|
1700
|
+
arguments: import_v47.z.string()
|
|
1661
1701
|
}),
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
1664
|
-
item_id:
|
|
1665
|
-
output_index:
|
|
1702
|
+
import_v47.z.object({
|
|
1703
|
+
type: import_v47.z.literal("response.mcp_call.in_progress"),
|
|
1704
|
+
item_id: import_v47.z.string(),
|
|
1705
|
+
output_index: import_v47.z.number()
|
|
1666
1706
|
}),
|
|
1667
|
-
|
|
1668
|
-
type:
|
|
1669
|
-
item_id:
|
|
1670
|
-
output_index:
|
|
1707
|
+
import_v47.z.object({
|
|
1708
|
+
type: import_v47.z.literal("response.mcp_call.executing"),
|
|
1709
|
+
item_id: import_v47.z.string(),
|
|
1710
|
+
output_index: import_v47.z.number()
|
|
1671
1711
|
}),
|
|
1672
|
-
|
|
1673
|
-
type:
|
|
1674
|
-
item_id:
|
|
1675
|
-
output_index:
|
|
1712
|
+
import_v47.z.object({
|
|
1713
|
+
type: import_v47.z.literal("response.mcp_call.completed"),
|
|
1714
|
+
item_id: import_v47.z.string(),
|
|
1715
|
+
output_index: import_v47.z.number()
|
|
1676
1716
|
}),
|
|
1677
|
-
|
|
1678
|
-
type:
|
|
1679
|
-
item_id:
|
|
1680
|
-
output_index:
|
|
1717
|
+
import_v47.z.object({
|
|
1718
|
+
type: import_v47.z.literal("response.mcp_call.failed"),
|
|
1719
|
+
item_id: import_v47.z.string(),
|
|
1720
|
+
output_index: import_v47.z.number()
|
|
1681
1721
|
}),
|
|
1682
|
-
|
|
1683
|
-
type:
|
|
1684
|
-
item_id:
|
|
1685
|
-
output_index:
|
|
1686
|
-
delta:
|
|
1722
|
+
import_v47.z.object({
|
|
1723
|
+
type: import_v47.z.literal("response.mcp_call_arguments.delta"),
|
|
1724
|
+
item_id: import_v47.z.string(),
|
|
1725
|
+
output_index: import_v47.z.number(),
|
|
1726
|
+
delta: import_v47.z.string()
|
|
1687
1727
|
}),
|
|
1688
|
-
|
|
1689
|
-
type:
|
|
1690
|
-
item_id:
|
|
1691
|
-
output_index:
|
|
1692
|
-
arguments:
|
|
1728
|
+
import_v47.z.object({
|
|
1729
|
+
type: import_v47.z.literal("response.mcp_call_arguments.done"),
|
|
1730
|
+
item_id: import_v47.z.string(),
|
|
1731
|
+
output_index: import_v47.z.number(),
|
|
1732
|
+
arguments: import_v47.z.string().optional()
|
|
1693
1733
|
}),
|
|
1694
|
-
|
|
1695
|
-
type:
|
|
1696
|
-
item_id:
|
|
1697
|
-
output_index:
|
|
1698
|
-
delta:
|
|
1734
|
+
import_v47.z.object({
|
|
1735
|
+
type: import_v47.z.literal("response.mcp_call_output.delta"),
|
|
1736
|
+
item_id: import_v47.z.string(),
|
|
1737
|
+
output_index: import_v47.z.number(),
|
|
1738
|
+
delta: import_v47.z.string()
|
|
1699
1739
|
}),
|
|
1700
|
-
|
|
1701
|
-
type:
|
|
1702
|
-
item_id:
|
|
1703
|
-
output_index:
|
|
1704
|
-
output:
|
|
1740
|
+
import_v47.z.object({
|
|
1741
|
+
type: import_v47.z.literal("response.mcp_call_output.done"),
|
|
1742
|
+
item_id: import_v47.z.string(),
|
|
1743
|
+
output_index: import_v47.z.number(),
|
|
1744
|
+
output: import_v47.z.string().optional()
|
|
1705
1745
|
}),
|
|
1706
|
-
|
|
1707
|
-
type:
|
|
1708
|
-
response:
|
|
1709
|
-
incomplete_details:
|
|
1746
|
+
import_v47.z.object({
|
|
1747
|
+
type: import_v47.z.literal("response.incomplete"),
|
|
1748
|
+
response: import_v47.z.object({
|
|
1749
|
+
incomplete_details: import_v47.z.object({ reason: import_v47.z.string() }).nullish(),
|
|
1710
1750
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1711
1751
|
})
|
|
1712
1752
|
}),
|
|
1713
|
-
|
|
1714
|
-
type:
|
|
1715
|
-
response:
|
|
1716
|
-
error:
|
|
1717
|
-
code:
|
|
1718
|
-
message:
|
|
1753
|
+
import_v47.z.object({
|
|
1754
|
+
type: import_v47.z.literal("response.failed"),
|
|
1755
|
+
response: import_v47.z.object({
|
|
1756
|
+
error: import_v47.z.object({
|
|
1757
|
+
code: import_v47.z.string().nullish(),
|
|
1758
|
+
message: import_v47.z.string()
|
|
1719
1759
|
}).nullish(),
|
|
1720
|
-
incomplete_details:
|
|
1760
|
+
incomplete_details: import_v47.z.object({ reason: import_v47.z.string() }).nullish(),
|
|
1721
1761
|
usage: xaiResponsesUsageSchema.nullish()
|
|
1722
1762
|
})
|
|
1723
1763
|
}),
|
|
1724
|
-
|
|
1725
|
-
type:
|
|
1726
|
-
code:
|
|
1727
|
-
message:
|
|
1728
|
-
param:
|
|
1764
|
+
import_v47.z.object({
|
|
1765
|
+
type: import_v47.z.literal("error"),
|
|
1766
|
+
code: import_v47.z.string().nullish(),
|
|
1767
|
+
message: import_v47.z.string(),
|
|
1768
|
+
param: import_v47.z.string().nullish()
|
|
1729
1769
|
}),
|
|
1730
|
-
|
|
1731
|
-
type:
|
|
1770
|
+
import_v47.z.object({
|
|
1771
|
+
type: import_v47.z.literal("response.done"),
|
|
1732
1772
|
response: xaiResponsesResponseSchema
|
|
1733
1773
|
}),
|
|
1734
|
-
|
|
1735
|
-
type:
|
|
1774
|
+
import_v47.z.object({
|
|
1775
|
+
type: import_v47.z.literal("response.completed"),
|
|
1736
1776
|
response: xaiResponsesResponseSchema
|
|
1737
1777
|
})
|
|
1738
1778
|
]);
|
|
1739
1779
|
|
|
1740
1780
|
// src/responses/xai-responses-options.ts
|
|
1741
|
-
var
|
|
1742
|
-
var xaiLanguageModelResponsesOptions =
|
|
1781
|
+
var import_v48 = require("zod/v4");
|
|
1782
|
+
var xaiLanguageModelResponsesOptions = import_v48.z.object({
|
|
1743
1783
|
/**
|
|
1744
1784
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1745
1785
|
* Possible values are `none` (disables reasoning), `low` (uses fewer reasoning
|
|
1746
1786
|
* tokens), `medium` and `high` (uses more reasoning tokens). Not all models
|
|
1747
1787
|
* support reasoning effort; see xAI's docs for the values each model accepts.
|
|
1748
1788
|
*/
|
|
1749
|
-
reasoningEffort:
|
|
1750
|
-
logprobs:
|
|
1751
|
-
topLogprobs:
|
|
1789
|
+
reasoningEffort: import_v48.z.enum(["none", "low", "medium", "high"]).optional(),
|
|
1790
|
+
logprobs: import_v48.z.boolean().optional(),
|
|
1791
|
+
topLogprobs: import_v48.z.number().int().min(0).max(8).optional(),
|
|
1752
1792
|
/**
|
|
1753
1793
|
* Whether to store the input message(s) and model response for later retrieval.
|
|
1754
1794
|
* Must be set to `false` for teams with Zero Data Retention (ZDR) enabled,
|
|
1755
1795
|
* otherwise the API will return an error.
|
|
1756
1796
|
* @default true
|
|
1757
1797
|
*/
|
|
1758
|
-
store:
|
|
1798
|
+
store: import_v48.z.boolean().optional(),
|
|
1759
1799
|
/**
|
|
1760
1800
|
* The ID of the previous response from the model.
|
|
1761
1801
|
*/
|
|
1762
|
-
previousResponseId:
|
|
1802
|
+
previousResponseId: import_v48.z.string().optional(),
|
|
1763
1803
|
/**
|
|
1764
1804
|
* Specify additional output data to include in the model response.
|
|
1765
1805
|
* Example values: 'file_search_call.results'.
|
|
1766
1806
|
*/
|
|
1767
|
-
include:
|
|
1807
|
+
include: import_v48.z.array(import_v48.z.enum(["file_search_call.results"])).nullish()
|
|
1768
1808
|
});
|
|
1769
1809
|
|
|
1770
1810
|
// src/responses/xai-responses-prepare-tools.ts
|
|
@@ -1773,25 +1813,25 @@ var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
|
1773
1813
|
|
|
1774
1814
|
// src/tool/file-search.ts
|
|
1775
1815
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1776
|
-
var
|
|
1816
|
+
var import_v49 = require("zod/v4");
|
|
1777
1817
|
var fileSearchArgsSchema = (0, import_provider_utils6.lazySchema)(
|
|
1778
1818
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1779
|
-
|
|
1780
|
-
vectorStoreIds:
|
|
1781
|
-
maxNumResults:
|
|
1819
|
+
import_v49.z.object({
|
|
1820
|
+
vectorStoreIds: import_v49.z.array(import_v49.z.string()),
|
|
1821
|
+
maxNumResults: import_v49.z.number().optional()
|
|
1782
1822
|
})
|
|
1783
1823
|
)
|
|
1784
1824
|
);
|
|
1785
1825
|
var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
1786
1826
|
() => (0, import_provider_utils6.zodSchema)(
|
|
1787
|
-
|
|
1788
|
-
queries:
|
|
1789
|
-
results:
|
|
1790
|
-
|
|
1791
|
-
fileId:
|
|
1792
|
-
filename:
|
|
1793
|
-
score:
|
|
1794
|
-
text:
|
|
1827
|
+
import_v49.z.object({
|
|
1828
|
+
queries: import_v49.z.array(import_v49.z.string()),
|
|
1829
|
+
results: import_v49.z.array(
|
|
1830
|
+
import_v49.z.object({
|
|
1831
|
+
fileId: import_v49.z.string(),
|
|
1832
|
+
filename: import_v49.z.string(),
|
|
1833
|
+
score: import_v49.z.number().min(0).max(1),
|
|
1834
|
+
text: import_v49.z.string()
|
|
1795
1835
|
})
|
|
1796
1836
|
).nullable()
|
|
1797
1837
|
})
|
|
@@ -1799,64 +1839,64 @@ var fileSearchOutputSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1799
1839
|
);
|
|
1800
1840
|
var fileSearchToolFactory = (0, import_provider_utils6.createProviderToolFactoryWithOutputSchema)({
|
|
1801
1841
|
id: "xai.file_search",
|
|
1802
|
-
inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(
|
|
1842
|
+
inputSchema: (0, import_provider_utils6.lazySchema)(() => (0, import_provider_utils6.zodSchema)(import_v49.z.object({}))),
|
|
1803
1843
|
outputSchema: fileSearchOutputSchema
|
|
1804
1844
|
});
|
|
1805
1845
|
var fileSearch = (args) => fileSearchToolFactory(args);
|
|
1806
1846
|
|
|
1807
1847
|
// src/tool/mcp-server.ts
|
|
1808
1848
|
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1809
|
-
var
|
|
1849
|
+
var import_v410 = require("zod/v4");
|
|
1810
1850
|
var mcpServerArgsSchema = (0, import_provider_utils7.lazySchema)(
|
|
1811
1851
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1812
|
-
|
|
1813
|
-
serverUrl:
|
|
1814
|
-
serverLabel:
|
|
1815
|
-
serverDescription:
|
|
1816
|
-
allowedTools:
|
|
1817
|
-
headers:
|
|
1818
|
-
authorization:
|
|
1852
|
+
import_v410.z.object({
|
|
1853
|
+
serverUrl: import_v410.z.string().describe("The URL of the MCP server"),
|
|
1854
|
+
serverLabel: import_v410.z.string().optional().describe("A label for the MCP server"),
|
|
1855
|
+
serverDescription: import_v410.z.string().optional().describe("Description of the MCP server"),
|
|
1856
|
+
allowedTools: import_v410.z.array(import_v410.z.string()).optional().describe("List of allowed tool names"),
|
|
1857
|
+
headers: import_v410.z.record(import_v410.z.string(), import_v410.z.string()).optional().describe("Custom headers to send"),
|
|
1858
|
+
authorization: import_v410.z.string().optional().describe("Authorization header value")
|
|
1819
1859
|
})
|
|
1820
1860
|
)
|
|
1821
1861
|
);
|
|
1822
1862
|
var mcpServerOutputSchema = (0, import_provider_utils7.lazySchema)(
|
|
1823
1863
|
() => (0, import_provider_utils7.zodSchema)(
|
|
1824
|
-
|
|
1825
|
-
name:
|
|
1826
|
-
arguments:
|
|
1827
|
-
result:
|
|
1864
|
+
import_v410.z.object({
|
|
1865
|
+
name: import_v410.z.string(),
|
|
1866
|
+
arguments: import_v410.z.string(),
|
|
1867
|
+
result: import_v410.z.unknown()
|
|
1828
1868
|
})
|
|
1829
1869
|
)
|
|
1830
1870
|
);
|
|
1831
1871
|
var mcpServerToolFactory = (0, import_provider_utils7.createProviderToolFactoryWithOutputSchema)({
|
|
1832
1872
|
id: "xai.mcp",
|
|
1833
|
-
inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(
|
|
1873
|
+
inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v410.z.object({}))),
|
|
1834
1874
|
outputSchema: mcpServerOutputSchema
|
|
1835
1875
|
});
|
|
1836
1876
|
var mcpServer = (args) => mcpServerToolFactory(args);
|
|
1837
1877
|
|
|
1838
1878
|
// src/tool/web-search.ts
|
|
1839
1879
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1840
|
-
var
|
|
1880
|
+
var import_v411 = require("zod/v4");
|
|
1841
1881
|
var webSearchArgsSchema = (0, import_provider_utils8.lazySchema)(
|
|
1842
1882
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1843
|
-
|
|
1844
|
-
allowedDomains:
|
|
1845
|
-
excludedDomains:
|
|
1846
|
-
enableImageSearch:
|
|
1847
|
-
enableImageUnderstanding:
|
|
1883
|
+
import_v411.z.object({
|
|
1884
|
+
allowedDomains: import_v411.z.array(import_v411.z.string()).max(5).optional(),
|
|
1885
|
+
excludedDomains: import_v411.z.array(import_v411.z.string()).max(5).optional(),
|
|
1886
|
+
enableImageSearch: import_v411.z.boolean().optional(),
|
|
1887
|
+
enableImageUnderstanding: import_v411.z.boolean().optional()
|
|
1848
1888
|
})
|
|
1849
1889
|
)
|
|
1850
1890
|
);
|
|
1851
1891
|
var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
1852
1892
|
() => (0, import_provider_utils8.zodSchema)(
|
|
1853
|
-
|
|
1854
|
-
query:
|
|
1855
|
-
sources:
|
|
1856
|
-
|
|
1857
|
-
title:
|
|
1858
|
-
url:
|
|
1859
|
-
snippet:
|
|
1893
|
+
import_v411.z.object({
|
|
1894
|
+
query: import_v411.z.string(),
|
|
1895
|
+
sources: import_v411.z.array(
|
|
1896
|
+
import_v411.z.object({
|
|
1897
|
+
title: import_v411.z.string(),
|
|
1898
|
+
url: import_v411.z.string(),
|
|
1899
|
+
snippet: import_v411.z.string()
|
|
1860
1900
|
})
|
|
1861
1901
|
)
|
|
1862
1902
|
})
|
|
@@ -1864,36 +1904,36 @@ var webSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
|
|
|
1864
1904
|
);
|
|
1865
1905
|
var webSearchToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1866
1906
|
id: "xai.web_search",
|
|
1867
|
-
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(
|
|
1907
|
+
inputSchema: (0, import_provider_utils8.lazySchema)(() => (0, import_provider_utils8.zodSchema)(import_v411.z.object({}))),
|
|
1868
1908
|
outputSchema: webSearchOutputSchema
|
|
1869
1909
|
});
|
|
1870
1910
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
1871
1911
|
|
|
1872
1912
|
// src/tool/x-search.ts
|
|
1873
1913
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1874
|
-
var
|
|
1914
|
+
var import_v412 = require("zod/v4");
|
|
1875
1915
|
var xSearchArgsSchema = (0, import_provider_utils9.lazySchema)(
|
|
1876
1916
|
() => (0, import_provider_utils9.zodSchema)(
|
|
1877
|
-
|
|
1878
|
-
allowedXHandles:
|
|
1879
|
-
excludedXHandles:
|
|
1880
|
-
fromDate:
|
|
1881
|
-
toDate:
|
|
1882
|
-
enableImageUnderstanding:
|
|
1883
|
-
enableVideoUnderstanding:
|
|
1917
|
+
import_v412.z.object({
|
|
1918
|
+
allowedXHandles: import_v412.z.array(import_v412.z.string()).max(10).optional(),
|
|
1919
|
+
excludedXHandles: import_v412.z.array(import_v412.z.string()).max(10).optional(),
|
|
1920
|
+
fromDate: import_v412.z.string().optional(),
|
|
1921
|
+
toDate: import_v412.z.string().optional(),
|
|
1922
|
+
enableImageUnderstanding: import_v412.z.boolean().optional(),
|
|
1923
|
+
enableVideoUnderstanding: import_v412.z.boolean().optional()
|
|
1884
1924
|
})
|
|
1885
1925
|
)
|
|
1886
1926
|
);
|
|
1887
1927
|
var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
1888
1928
|
() => (0, import_provider_utils9.zodSchema)(
|
|
1889
|
-
|
|
1890
|
-
query:
|
|
1891
|
-
posts:
|
|
1892
|
-
|
|
1893
|
-
author:
|
|
1894
|
-
text:
|
|
1895
|
-
url:
|
|
1896
|
-
likes:
|
|
1929
|
+
import_v412.z.object({
|
|
1930
|
+
query: import_v412.z.string(),
|
|
1931
|
+
posts: import_v412.z.array(
|
|
1932
|
+
import_v412.z.object({
|
|
1933
|
+
author: import_v412.z.string(),
|
|
1934
|
+
text: import_v412.z.string(),
|
|
1935
|
+
url: import_v412.z.string(),
|
|
1936
|
+
likes: import_v412.z.number()
|
|
1897
1937
|
})
|
|
1898
1938
|
)
|
|
1899
1939
|
})
|
|
@@ -1901,7 +1941,7 @@ var xSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
|
|
|
1901
1941
|
);
|
|
1902
1942
|
var xSearchToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1903
1943
|
id: "xai.x_search",
|
|
1904
|
-
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(
|
|
1944
|
+
inputSchema: (0, import_provider_utils9.lazySchema)(() => (0, import_provider_utils9.zodSchema)(import_v412.z.object({}))),
|
|
1905
1945
|
outputSchema: xSearchOutputSchema
|
|
1906
1946
|
});
|
|
1907
1947
|
var xSearch = (args = {}) => xSearchToolFactory(args);
|
|
@@ -2184,7 +2224,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2184
2224
|
};
|
|
2185
2225
|
}
|
|
2186
2226
|
async doGenerate(options) {
|
|
2187
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2227
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2188
2228
|
const {
|
|
2189
2229
|
args: body,
|
|
2190
2230
|
warnings,
|
|
@@ -2305,8 +2345,8 @@ var XaiResponsesLanguageModel = class {
|
|
|
2305
2345
|
break;
|
|
2306
2346
|
}
|
|
2307
2347
|
case "reasoning": {
|
|
2308
|
-
const
|
|
2309
|
-
const reasoningText =
|
|
2348
|
+
const texts = part.summary.length > 0 ? part.summary.map((s) => s.text) : ((_m = part.content) != null ? _m : []).map((c) => c.text);
|
|
2349
|
+
const reasoningText = texts.filter((text) => text && text.length > 0).join("");
|
|
2310
2350
|
if (reasoningText || part.encrypted_content) {
|
|
2311
2351
|
const hasMetadata = part.encrypted_content || part.id;
|
|
2312
2352
|
content.push({
|
|
@@ -2335,7 +2375,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2335
2375
|
content,
|
|
2336
2376
|
finishReason: {
|
|
2337
2377
|
unified: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response.status),
|
|
2338
|
-
raw: (
|
|
2378
|
+
raw: (_n = response.status) != null ? _n : void 0
|
|
2339
2379
|
},
|
|
2340
2380
|
usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
|
|
2341
2381
|
inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
|
|
@@ -2798,43 +2838,43 @@ var XaiResponsesLanguageModel = class {
|
|
|
2798
2838
|
|
|
2799
2839
|
// src/tool/code-execution.ts
|
|
2800
2840
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
2801
|
-
var
|
|
2802
|
-
var codeExecutionOutputSchema =
|
|
2803
|
-
output:
|
|
2804
|
-
error:
|
|
2841
|
+
var import_v413 = require("zod/v4");
|
|
2842
|
+
var codeExecutionOutputSchema = import_v413.z.object({
|
|
2843
|
+
output: import_v413.z.string().describe("the output of the code execution"),
|
|
2844
|
+
error: import_v413.z.string().optional().describe("any error that occurred")
|
|
2805
2845
|
});
|
|
2806
2846
|
var codeExecutionToolFactory = (0, import_provider_utils12.createProviderToolFactoryWithOutputSchema)({
|
|
2807
2847
|
id: "xai.code_execution",
|
|
2808
|
-
inputSchema:
|
|
2848
|
+
inputSchema: import_v413.z.object({}).describe("no input parameters"),
|
|
2809
2849
|
outputSchema: codeExecutionOutputSchema
|
|
2810
2850
|
});
|
|
2811
2851
|
var codeExecution = (args = {}) => codeExecutionToolFactory(args);
|
|
2812
2852
|
|
|
2813
2853
|
// src/tool/view-image.ts
|
|
2814
2854
|
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
2815
|
-
var
|
|
2816
|
-
var viewImageOutputSchema =
|
|
2817
|
-
description:
|
|
2818
|
-
objects:
|
|
2855
|
+
var import_v414 = require("zod/v4");
|
|
2856
|
+
var viewImageOutputSchema = import_v414.z.object({
|
|
2857
|
+
description: import_v414.z.string().describe("description of the image"),
|
|
2858
|
+
objects: import_v414.z.array(import_v414.z.string()).optional().describe("objects detected in the image")
|
|
2819
2859
|
});
|
|
2820
2860
|
var viewImageToolFactory = (0, import_provider_utils13.createProviderToolFactoryWithOutputSchema)({
|
|
2821
2861
|
id: "xai.view_image",
|
|
2822
|
-
inputSchema:
|
|
2862
|
+
inputSchema: import_v414.z.object({}).describe("no input parameters"),
|
|
2823
2863
|
outputSchema: viewImageOutputSchema
|
|
2824
2864
|
});
|
|
2825
2865
|
var viewImage = (args = {}) => viewImageToolFactory(args);
|
|
2826
2866
|
|
|
2827
2867
|
// src/tool/view-x-video.ts
|
|
2828
2868
|
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
2829
|
-
var
|
|
2830
|
-
var viewXVideoOutputSchema =
|
|
2831
|
-
transcript:
|
|
2832
|
-
description:
|
|
2833
|
-
duration:
|
|
2869
|
+
var import_v415 = require("zod/v4");
|
|
2870
|
+
var viewXVideoOutputSchema = import_v415.z.object({
|
|
2871
|
+
transcript: import_v415.z.string().optional().describe("transcript of the video"),
|
|
2872
|
+
description: import_v415.z.string().describe("description of the video content"),
|
|
2873
|
+
duration: import_v415.z.number().optional().describe("duration in seconds")
|
|
2834
2874
|
});
|
|
2835
2875
|
var viewXVideoToolFactory = (0, import_provider_utils14.createProviderToolFactoryWithOutputSchema)({
|
|
2836
2876
|
id: "xai.view_x_video",
|
|
2837
|
-
inputSchema:
|
|
2877
|
+
inputSchema: import_v415.z.object({}).describe("no input parameters"),
|
|
2838
2878
|
outputSchema: viewXVideoOutputSchema
|
|
2839
2879
|
});
|
|
2840
2880
|
var viewXVideo = (args = {}) => viewXVideoToolFactory(args);
|
|
@@ -2851,58 +2891,58 @@ var xaiTools = {
|
|
|
2851
2891
|
};
|
|
2852
2892
|
|
|
2853
2893
|
// src/version.ts
|
|
2854
|
-
var VERSION = true ? "3.0.
|
|
2894
|
+
var VERSION = true ? "3.0.105" : "0.0.0-test";
|
|
2855
2895
|
|
|
2856
2896
|
// src/xai-video-model.ts
|
|
2857
2897
|
var import_provider6 = require("@ai-sdk/provider");
|
|
2858
2898
|
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
2859
|
-
var
|
|
2899
|
+
var import_v417 = require("zod/v4");
|
|
2860
2900
|
|
|
2861
2901
|
// src/xai-video-options.ts
|
|
2862
2902
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2863
|
-
var
|
|
2864
|
-
var nonEmptyStringSchema =
|
|
2865
|
-
var resolutionSchema =
|
|
2866
|
-
var modeSchema =
|
|
2903
|
+
var import_v416 = require("zod/v4");
|
|
2904
|
+
var nonEmptyStringSchema = import_v416.z.string().min(1);
|
|
2905
|
+
var resolutionSchema = import_v416.z.enum(["480p", "720p"]);
|
|
2906
|
+
var modeSchema = import_v416.z.enum(["edit-video", "extend-video", "reference-to-video"]);
|
|
2867
2907
|
var baseFields = {
|
|
2868
|
-
pollIntervalMs:
|
|
2869
|
-
pollTimeoutMs:
|
|
2908
|
+
pollIntervalMs: import_v416.z.number().positive().nullish(),
|
|
2909
|
+
pollTimeoutMs: import_v416.z.number().positive().nullish(),
|
|
2870
2910
|
resolution: resolutionSchema.nullish()
|
|
2871
2911
|
};
|
|
2872
|
-
var editVideoSchema =
|
|
2912
|
+
var editVideoSchema = import_v416.z.object({
|
|
2873
2913
|
...baseFields,
|
|
2874
|
-
mode:
|
|
2914
|
+
mode: import_v416.z.literal("edit-video"),
|
|
2875
2915
|
videoUrl: nonEmptyStringSchema,
|
|
2876
|
-
referenceImageUrls:
|
|
2916
|
+
referenceImageUrls: import_v416.z.undefined().optional()
|
|
2877
2917
|
});
|
|
2878
|
-
var extendVideoSchema =
|
|
2918
|
+
var extendVideoSchema = import_v416.z.object({
|
|
2879
2919
|
...baseFields,
|
|
2880
|
-
mode:
|
|
2920
|
+
mode: import_v416.z.literal("extend-video"),
|
|
2881
2921
|
videoUrl: nonEmptyStringSchema,
|
|
2882
|
-
referenceImageUrls:
|
|
2922
|
+
referenceImageUrls: import_v416.z.undefined().optional()
|
|
2883
2923
|
});
|
|
2884
|
-
var referenceToVideoSchema =
|
|
2924
|
+
var referenceToVideoSchema = import_v416.z.object({
|
|
2885
2925
|
...baseFields,
|
|
2886
|
-
mode:
|
|
2887
|
-
referenceImageUrls:
|
|
2888
|
-
videoUrl:
|
|
2926
|
+
mode: import_v416.z.literal("reference-to-video"),
|
|
2927
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7),
|
|
2928
|
+
videoUrl: import_v416.z.undefined().optional()
|
|
2889
2929
|
});
|
|
2890
|
-
var autoDetectSchema =
|
|
2930
|
+
var autoDetectSchema = import_v416.z.object({
|
|
2891
2931
|
...baseFields,
|
|
2892
|
-
mode:
|
|
2932
|
+
mode: import_v416.z.undefined().optional(),
|
|
2893
2933
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2894
|
-
referenceImageUrls:
|
|
2934
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional()
|
|
2895
2935
|
});
|
|
2896
|
-
var xaiVideoModelOptions =
|
|
2936
|
+
var xaiVideoModelOptions = import_v416.z.union([
|
|
2897
2937
|
editVideoSchema,
|
|
2898
2938
|
extendVideoSchema,
|
|
2899
2939
|
referenceToVideoSchema,
|
|
2900
2940
|
autoDetectSchema
|
|
2901
2941
|
]);
|
|
2902
|
-
var runtimeSchema =
|
|
2942
|
+
var runtimeSchema = import_v416.z.object({
|
|
2903
2943
|
mode: modeSchema.optional(),
|
|
2904
2944
|
videoUrl: nonEmptyStringSchema.optional(),
|
|
2905
|
-
referenceImageUrls:
|
|
2945
|
+
referenceImageUrls: import_v416.z.array(nonEmptyStringSchema).min(1).max(7).optional(),
|
|
2906
2946
|
...baseFields
|
|
2907
2947
|
}).passthrough();
|
|
2908
2948
|
var xaiVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
|
|
@@ -3214,24 +3254,24 @@ var XaiVideoModel = class {
|
|
|
3214
3254
|
}
|
|
3215
3255
|
}
|
|
3216
3256
|
};
|
|
3217
|
-
var xaiCreateVideoResponseSchema =
|
|
3218
|
-
request_id:
|
|
3257
|
+
var xaiCreateVideoResponseSchema = import_v417.z.object({
|
|
3258
|
+
request_id: import_v417.z.string().nullish()
|
|
3219
3259
|
});
|
|
3220
|
-
var xaiVideoStatusResponseSchema =
|
|
3221
|
-
status:
|
|
3222
|
-
video:
|
|
3223
|
-
url:
|
|
3224
|
-
duration:
|
|
3225
|
-
respect_moderation:
|
|
3260
|
+
var xaiVideoStatusResponseSchema = import_v417.z.object({
|
|
3261
|
+
status: import_v417.z.string().nullish(),
|
|
3262
|
+
video: import_v417.z.object({
|
|
3263
|
+
url: import_v417.z.string(),
|
|
3264
|
+
duration: import_v417.z.number().nullish(),
|
|
3265
|
+
respect_moderation: import_v417.z.boolean().nullish()
|
|
3226
3266
|
}).nullish(),
|
|
3227
|
-
model:
|
|
3228
|
-
usage:
|
|
3229
|
-
cost_in_usd_ticks:
|
|
3267
|
+
model: import_v417.z.string().nullish(),
|
|
3268
|
+
usage: import_v417.z.object({
|
|
3269
|
+
cost_in_usd_ticks: import_v417.z.number().nullish()
|
|
3230
3270
|
}).nullish(),
|
|
3231
|
-
progress:
|
|
3232
|
-
error:
|
|
3233
|
-
code:
|
|
3234
|
-
message:
|
|
3271
|
+
progress: import_v417.z.number().nullish(),
|
|
3272
|
+
error: import_v417.z.object({
|
|
3273
|
+
code: import_v417.z.string().nullish(),
|
|
3274
|
+
message: import_v417.z.string().nullish()
|
|
3235
3275
|
}).nullish()
|
|
3236
3276
|
});
|
|
3237
3277
|
|