@better-agent/providers 0.1.0-beta.1
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/README.md +3 -0
- package/dist/anthropic/index.d.mts +1196 -0
- package/dist/anthropic/index.d.mts.map +1 -0
- package/dist/anthropic/index.mjs +1909 -0
- package/dist/anthropic/index.mjs.map +1 -0
- package/dist/fetch-CW0dWlVC.mjs +84 -0
- package/dist/fetch-CW0dWlVC.mjs.map +1 -0
- package/dist/openai/index.d.mts +1629 -0
- package/dist/openai/index.d.mts.map +1 -0
- package/dist/openai/index.mjs +6690 -0
- package/dist/openai/index.mjs.map +1 -0
- package/dist/xai/index.d.mts +382 -0
- package/dist/xai/index.d.mts.map +1 -0
- package/dist/xai/index.mjs +1277 -0
- package/dist/xai/index.mjs.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { BetterAgentError } from "@better-agent/shared/errors";
|
|
2
|
+
import { Result } from "@better-agent/shared/neverthrow";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { HostedToolDefinition } from "@better-agent/core";
|
|
5
|
+
import { Capabilities, GenerativeModel } from "@better-agent/core/providers";
|
|
6
|
+
|
|
7
|
+
//#region src/xai/shared/schemas.d.ts
|
|
8
|
+
type XAIResponseStreamEvent = {
|
|
9
|
+
type: "error";
|
|
10
|
+
message?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
} | {
|
|
13
|
+
type: "response.completed";
|
|
14
|
+
response: unknown;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
} | {
|
|
17
|
+
type: "response.reasoning_summary_part.added" | "response.reasoning_summary_text.done" | "response.reasoning_text.done" | "response.output_text.done";
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
} | {
|
|
20
|
+
type: "response.reasoning_summary_text.delta" | "response.reasoning_text.delta" | "response.output_text.delta" | "response.function_call_arguments.delta";
|
|
21
|
+
delta?: string;
|
|
22
|
+
item_id?: string;
|
|
23
|
+
call_id?: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
} | {
|
|
26
|
+
type: "response.function_call_arguments.done";
|
|
27
|
+
item_id?: string;
|
|
28
|
+
call_id?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
} | {
|
|
31
|
+
type: "response.output_item.added" | "response.output_item.done";
|
|
32
|
+
item: {
|
|
33
|
+
type: string;
|
|
34
|
+
id?: string;
|
|
35
|
+
call_id?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
status?: string;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
} | {
|
|
42
|
+
type: "response.web_search_call.in_progress" | "response.web_search_call.searching" | "response.web_search_call.completed" | "response.x_search_call.in_progress" | "response.x_search_call.searching" | "response.x_search_call.completed" | "response.file_search_call.in_progress" | "response.file_search_call.searching" | "response.file_search_call.completed" | "response.code_interpreter_call.in_progress" | "response.code_interpreter_call.interpreting" | "response.code_interpreter_call.completed" | "response.code_execution_call.in_progress" | "response.code_execution_call.interpreting" | "response.code_execution_call.completed" | "response.mcp_call.in_progress" | "response.mcp_call.completed" | "response.mcp_call.failed" | "response.mcp_list_tools.in_progress" | "response.mcp_list_tools.completed" | "response.mcp_list_tools.failed";
|
|
43
|
+
item_id?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
};
|
|
46
|
+
type XAIFileObjectSchema = z.infer<typeof XAIFileObjectSchema>;
|
|
47
|
+
type XAIFileListSchema = z.infer<typeof XAIFileListSchema>;
|
|
48
|
+
type XAIDeleteFileResponseSchema = z.infer<typeof XAIDeleteFileResponseSchema>;
|
|
49
|
+
declare const XAIResponseModels: z.ZodEnum<{
|
|
50
|
+
"grok-3": "grok-3";
|
|
51
|
+
"grok-3-latest": "grok-3-latest";
|
|
52
|
+
"grok-3-beta": "grok-3-beta";
|
|
53
|
+
"grok-3-fast": "grok-3-fast";
|
|
54
|
+
"grok-3-fast-latest": "grok-3-fast-latest";
|
|
55
|
+
"grok-3-fast-beta": "grok-3-fast-beta";
|
|
56
|
+
"grok-3-mini": "grok-3-mini";
|
|
57
|
+
"grok-4": "grok-4";
|
|
58
|
+
"grok-4-1-fast-reasoning": "grok-4-1-fast-reasoning";
|
|
59
|
+
"grok-4.20-beta-latest-non-reasoning": "grok-4.20-beta-latest-non-reasoning";
|
|
60
|
+
"grok-4.20-multi-agent-beta-0309": "grok-4.20-multi-agent-beta-0309";
|
|
61
|
+
"grok-code-fast-1": "grok-code-fast-1";
|
|
62
|
+
}>;
|
|
63
|
+
declare const XAIImageModels: z.ZodEnum<{
|
|
64
|
+
"grok-imagine-image": "grok-imagine-image";
|
|
65
|
+
}>;
|
|
66
|
+
type XAIResponseModels = z.infer<typeof XAIResponseModels>;
|
|
67
|
+
type XAIImageModels = z.infer<typeof XAIImageModels>;
|
|
68
|
+
declare const XAIFileObjectSchema: z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
object: z.ZodOptional<z.ZodString>;
|
|
71
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
75
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
76
|
+
status: z.ZodOptional<z.ZodString>;
|
|
77
|
+
status_details: z.ZodOptional<z.ZodAny>;
|
|
78
|
+
}, z.core.$loose>;
|
|
79
|
+
declare const XAIFileListSchema: z.ZodObject<{
|
|
80
|
+
object: z.ZodOptional<z.ZodString>;
|
|
81
|
+
data: z.ZodArray<z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
object: z.ZodOptional<z.ZodString>;
|
|
84
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
87
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
88
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
89
|
+
status: z.ZodOptional<z.ZodString>;
|
|
90
|
+
status_details: z.ZodOptional<z.ZodAny>;
|
|
91
|
+
}, z.core.$loose>>;
|
|
92
|
+
first_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
93
|
+
last_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
94
|
+
has_more: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
+
}, z.core.$loose>;
|
|
96
|
+
declare const XAIDeleteFileResponseSchema: z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
object: z.ZodOptional<z.ZodString>;
|
|
99
|
+
deleted: z.ZodBoolean;
|
|
100
|
+
}, z.core.$loose>;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/xai/images/schemas.d.ts
|
|
103
|
+
type XAICreateImageSchema = z.input<typeof XAICreateImageSchema>;
|
|
104
|
+
type XAIEditImageSchema = z.input<typeof XAIEditImageSchema>;
|
|
105
|
+
declare const XAICreateImageSchema: z.ZodObject<{
|
|
106
|
+
model: z.ZodEnum<{
|
|
107
|
+
"grok-imagine-image": "grok-imagine-image";
|
|
108
|
+
}>;
|
|
109
|
+
n: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
110
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
111
|
+
quality: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
112
|
+
response_format: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
113
|
+
size: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
114
|
+
style: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
115
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
declare const XAIEditImageSchema: z.ZodObject<{
|
|
118
|
+
model: z.ZodEnum<{
|
|
119
|
+
"grok-imagine-image": "grok-imagine-image";
|
|
120
|
+
}>;
|
|
121
|
+
prompt: z.ZodString;
|
|
122
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
type: z.ZodDefault<z.ZodLiteral<"image_url">>;
|
|
124
|
+
image_url: z.ZodString;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
images: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
127
|
+
type: z.ZodDefault<z.ZodLiteral<"image_url">>;
|
|
128
|
+
image_url: z.ZodString;
|
|
129
|
+
}, z.core.$strip>>>;
|
|
130
|
+
n: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>>;
|
|
131
|
+
quality: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>>;
|
|
132
|
+
response_format: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>>;
|
|
133
|
+
size: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>>;
|
|
134
|
+
style: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>>;
|
|
135
|
+
user: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>>;
|
|
136
|
+
aspect_ratio: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
137
|
+
resolution: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/xai/images/types.d.ts
|
|
141
|
+
type XAIImageCaps = {
|
|
142
|
+
inputModalities: {
|
|
143
|
+
text: true;
|
|
144
|
+
image: true;
|
|
145
|
+
};
|
|
146
|
+
inputShape: "prompt";
|
|
147
|
+
replayMode: "single_turn_persistent";
|
|
148
|
+
supportsInstruction: false;
|
|
149
|
+
outputModalities: {
|
|
150
|
+
image: true;
|
|
151
|
+
};
|
|
152
|
+
additionalSupportedRoles: readonly ["developer"];
|
|
153
|
+
};
|
|
154
|
+
type XAIImageEndpointOptions = {
|
|
155
|
+
n?: XAICreateImageSchema["n"];
|
|
156
|
+
quality?: XAICreateImageSchema["quality"];
|
|
157
|
+
response_format?: XAICreateImageSchema["response_format"];
|
|
158
|
+
size?: XAICreateImageSchema["size"];
|
|
159
|
+
style?: XAICreateImageSchema["style"];
|
|
160
|
+
aspect_ratio?: XAIEditImageSchema["aspect_ratio"];
|
|
161
|
+
resolution?: XAIEditImageSchema["resolution"];
|
|
162
|
+
user?: XAICreateImageSchema["user"];
|
|
163
|
+
};
|
|
164
|
+
type SuggestedModelId$1<TKnown extends string> = TKnown | (string & {});
|
|
165
|
+
type XAIImageModelId = SuggestedModelId$1<XAIImageModels>;
|
|
166
|
+
type XAIImageGenerativeModel<M extends XAIImageModelId = XAIImageModelId> = GenerativeModel<XAIImageEndpointOptions, "xai", M, XAIImageCaps>;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/xai/responses/schemas.d.ts
|
|
169
|
+
type XAICreateResponseSchema = z.input<typeof XAICreateResponseSchema>;
|
|
170
|
+
declare const XAICreateResponseSchema: z.ZodObject<{
|
|
171
|
+
background: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull]>>;
|
|
172
|
+
include: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodNull]>>;
|
|
173
|
+
input: z.ZodAny;
|
|
174
|
+
instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
175
|
+
logprobs: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull]>>;
|
|
176
|
+
max_output_tokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
177
|
+
metadata: z.ZodOptional<z.ZodAny>;
|
|
178
|
+
model: z.ZodEnum<{
|
|
179
|
+
"grok-3": "grok-3";
|
|
180
|
+
"grok-3-latest": "grok-3-latest";
|
|
181
|
+
"grok-3-beta": "grok-3-beta";
|
|
182
|
+
"grok-3-fast": "grok-3-fast";
|
|
183
|
+
"grok-3-fast-latest": "grok-3-fast-latest";
|
|
184
|
+
"grok-3-fast-beta": "grok-3-fast-beta";
|
|
185
|
+
"grok-3-mini": "grok-3-mini";
|
|
186
|
+
"grok-4": "grok-4";
|
|
187
|
+
"grok-4-1-fast-reasoning": "grok-4-1-fast-reasoning";
|
|
188
|
+
"grok-4.20-beta-latest-non-reasoning": "grok-4.20-beta-latest-non-reasoning";
|
|
189
|
+
"grok-4.20-multi-agent-beta-0309": "grok-4.20-multi-agent-beta-0309";
|
|
190
|
+
"grok-code-fast-1": "grok-code-fast-1";
|
|
191
|
+
}>;
|
|
192
|
+
parallel_tool_calls: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull]>>;
|
|
193
|
+
previous_response_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
194
|
+
reasoning: z.ZodOptional<z.ZodUnion<readonly [z.ZodAny, z.ZodNull]>>;
|
|
195
|
+
search_parameters: z.ZodOptional<z.ZodUnion<readonly [z.ZodAny, z.ZodNull]>>;
|
|
196
|
+
service_tier: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
197
|
+
store: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull]>>;
|
|
198
|
+
stream: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull]>>;
|
|
199
|
+
temperature: z.ZodDefault<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
200
|
+
text: z.ZodOptional<z.ZodUnion<readonly [z.ZodAny, z.ZodNull]>>;
|
|
201
|
+
tool_choice: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodLiteral<"auto">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
202
|
+
type: z.ZodLiteral<"function">;
|
|
203
|
+
name: z.ZodString;
|
|
204
|
+
}, z.core.$strip>]>, z.ZodNull]>>;
|
|
205
|
+
tools: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
206
|
+
type: z.ZodLiteral<"function">;
|
|
207
|
+
name: z.ZodString;
|
|
208
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
209
|
+
parameters: z.ZodAny;
|
|
210
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
212
|
+
type: z.ZodLiteral<"web_search">;
|
|
213
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
214
|
+
allowed_websites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
215
|
+
excluded_websites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
216
|
+
}, z.core.$strip>>;
|
|
217
|
+
enable_image_understanding: z.ZodOptional<z.ZodBoolean>;
|
|
218
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
219
|
+
type: z.ZodLiteral<"x_search">;
|
|
220
|
+
max_results: z.ZodOptional<z.ZodNumber>;
|
|
221
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
222
|
+
auto: "auto";
|
|
223
|
+
on: "on";
|
|
224
|
+
off: "off";
|
|
225
|
+
}>>;
|
|
226
|
+
return_citations: z.ZodOptional<z.ZodBoolean>;
|
|
227
|
+
from_date: z.ZodOptional<z.ZodString>;
|
|
228
|
+
to_date: z.ZodOptional<z.ZodString>;
|
|
229
|
+
included_x_handles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
230
|
+
excluded_x_handles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
231
|
+
post_favorite_count: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
post_view_count: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
234
|
+
type: z.ZodLiteral<"code_execution">;
|
|
235
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
236
|
+
type: z.ZodLiteral<"code_interpreter">;
|
|
237
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
238
|
+
type: z.ZodLiteral<"attachment_search">;
|
|
239
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
240
|
+
type: z.ZodLiteral<"collections_search">;
|
|
241
|
+
collection_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
242
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
243
|
+
type: z.ZodLiteral<"file_search">;
|
|
244
|
+
vector_store_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
245
|
+
max_num_results: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
247
|
+
type: z.ZodLiteral<"mcp">;
|
|
248
|
+
server_url: z.ZodString;
|
|
249
|
+
server_label: z.ZodOptional<z.ZodString>;
|
|
250
|
+
server_description: z.ZodOptional<z.ZodString>;
|
|
251
|
+
authorization: z.ZodOptional<z.ZodString>;
|
|
252
|
+
extra_headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
253
|
+
allowed_tool_names: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
254
|
+
}, z.core.$strip>]>>, z.ZodNull]>>;
|
|
255
|
+
top_logprobs: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
256
|
+
top_p: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
257
|
+
user: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/xai/responses/types.d.ts
|
|
261
|
+
interface XAIResponseCaps extends Capabilities {
|
|
262
|
+
inputModalities: {
|
|
263
|
+
text: true;
|
|
264
|
+
image: true;
|
|
265
|
+
file: true;
|
|
266
|
+
};
|
|
267
|
+
inputShape: "chat";
|
|
268
|
+
replayMode: "multi_turn";
|
|
269
|
+
supportsInstruction: true;
|
|
270
|
+
outputModalities: {
|
|
271
|
+
text: {
|
|
272
|
+
options: {
|
|
273
|
+
logprobs?: XAICreateResponseSchema["logprobs"];
|
|
274
|
+
max_output_tokens?: XAICreateResponseSchema["max_output_tokens"];
|
|
275
|
+
temperature?: XAICreateResponseSchema["temperature"];
|
|
276
|
+
top_logprobs?: XAICreateResponseSchema["top_logprobs"];
|
|
277
|
+
top_p?: XAICreateResponseSchema["top_p"];
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
tools: true;
|
|
282
|
+
structured_output: true;
|
|
283
|
+
additionalSupportedRoles: readonly ["developer"];
|
|
284
|
+
}
|
|
285
|
+
type XAIResponseEndpointOptions = {
|
|
286
|
+
include?: XAICreateResponseSchema["include"];
|
|
287
|
+
instructions?: XAICreateResponseSchema["instructions"];
|
|
288
|
+
metadata?: XAICreateResponseSchema["metadata"];
|
|
289
|
+
parallel_tool_calls?: XAICreateResponseSchema["parallel_tool_calls"];
|
|
290
|
+
previous_response_id?: XAICreateResponseSchema["previous_response_id"];
|
|
291
|
+
reasoning?: XAICreateResponseSchema["reasoning"];
|
|
292
|
+
search_parameters?: XAICreateResponseSchema["search_parameters"];
|
|
293
|
+
service_tier?: XAICreateResponseSchema["service_tier"];
|
|
294
|
+
store?: XAICreateResponseSchema["store"];
|
|
295
|
+
logprobs?: XAICreateResponseSchema["logprobs"];
|
|
296
|
+
temperature?: XAICreateResponseSchema["temperature"];
|
|
297
|
+
top_logprobs?: XAICreateResponseSchema["top_logprobs"];
|
|
298
|
+
top_p?: XAICreateResponseSchema["top_p"];
|
|
299
|
+
user?: XAICreateResponseSchema["user"];
|
|
300
|
+
max_output_tokens?: XAICreateResponseSchema["max_output_tokens"];
|
|
301
|
+
};
|
|
302
|
+
type SuggestedModelId<TKnown extends string> = TKnown | (string & {});
|
|
303
|
+
type XAIResponseModelId = SuggestedModelId<XAIResponseModels>;
|
|
304
|
+
type XAIResponseGenerativeModel<M extends XAIResponseModelId = XAIResponseModelId> = GenerativeModel<XAIResponseEndpointOptions, "xai", M, XAIResponseCaps>;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/xai/tools/index.d.ts
|
|
307
|
+
type XAINativeToolByType<TType extends string> = NonNullable<XAICreateResponseSchema["tools"]>[number] extends infer TTool ? TTool extends {
|
|
308
|
+
type: infer ToolType extends string;
|
|
309
|
+
} ? TType extends ToolType ? TTool : never : never : never;
|
|
310
|
+
type XAINativeToolConfig<TType extends string> = [XAINativeToolByType<TType>] extends [never] ? Record<string, unknown> : Omit<XAINativeToolByType<TType>, "type">;
|
|
311
|
+
type XAINativeToolType = "web_search" | "x_search" | "code_execution" | "code_interpreter" | "attachment_search" | "collections_search" | "file_search" | "mcp";
|
|
312
|
+
type XAINativeToolDefinition<TType extends XAINativeToolType = XAINativeToolType> = HostedToolDefinition<"xai", TType, XAINativeToolConfig<TType>>;
|
|
313
|
+
type XAINativeToolBuilders = ReturnType<typeof createXAINativeToolBuilders>;
|
|
314
|
+
declare function createXAINativeToolBuilders(): {
|
|
315
|
+
webSearch: (config?: XAINativeToolConfig<"web_search">) => XAINativeToolDefinition<"web_search">;
|
|
316
|
+
xSearch: (config?: XAINativeToolConfig<"x_search">) => XAINativeToolDefinition<"x_search">;
|
|
317
|
+
codeExecution: (config?: XAINativeToolConfig<"code_execution">) => XAINativeToolDefinition<"code_execution">;
|
|
318
|
+
codeInterpreter: (config?: XAINativeToolConfig<"code_interpreter">) => XAINativeToolDefinition<"code_interpreter">;
|
|
319
|
+
attachmentSearch: (config?: XAINativeToolConfig<"attachment_search">) => XAINativeToolDefinition<"attachment_search">;
|
|
320
|
+
collectionsSearch: (config?: XAINativeToolConfig<"collections_search">) => XAINativeToolDefinition<"collections_search">;
|
|
321
|
+
fileSearch: (config?: XAINativeToolConfig<"file_search">) => XAINativeToolDefinition<"file_search">;
|
|
322
|
+
mcp: (config: XAINativeToolConfig<"mcp">) => XAINativeToolDefinition<"mcp">;
|
|
323
|
+
};
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/xai/types.d.ts
|
|
326
|
+
type XAIConfig = {
|
|
327
|
+
apiKey?: string;
|
|
328
|
+
baseURL?: string;
|
|
329
|
+
headers?: Record<string, string>;
|
|
330
|
+
};
|
|
331
|
+
type XAIError = {
|
|
332
|
+
error?: {
|
|
333
|
+
code?: string | number;
|
|
334
|
+
message?: string;
|
|
335
|
+
type?: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
type XAIUploadableFile = Blob | File | Uint8Array | ArrayBuffer;
|
|
339
|
+
type XAIFileUploadRequest = {
|
|
340
|
+
file: XAIUploadableFile;
|
|
341
|
+
filename?: string;
|
|
342
|
+
mimeType?: string;
|
|
343
|
+
purpose?: string;
|
|
344
|
+
};
|
|
345
|
+
interface XAIFilesClient {
|
|
346
|
+
/** Uploads a file and returns the provider-managed file object. */
|
|
347
|
+
upload(body: XAIFileUploadRequest, options?: {
|
|
348
|
+
signal?: AbortSignal | null;
|
|
349
|
+
}): Promise<Result<XAIFileObjectSchema, BetterAgentError>>;
|
|
350
|
+
/** Lists files available to the current xAI project. */
|
|
351
|
+
list(options?: {
|
|
352
|
+
signal?: AbortSignal | null;
|
|
353
|
+
}): Promise<Result<XAIFileListSchema, BetterAgentError>>;
|
|
354
|
+
/** Retrieves metadata for a single xAI file id. */
|
|
355
|
+
retrieve(fileId: string, options?: {
|
|
356
|
+
signal?: AbortSignal | null;
|
|
357
|
+
}): Promise<Result<XAIFileObjectSchema, BetterAgentError>>;
|
|
358
|
+
/** Deletes a provider-managed xAI file. */
|
|
359
|
+
delete(fileId: string, options?: {
|
|
360
|
+
signal?: AbortSignal | null;
|
|
361
|
+
}): Promise<Result<XAIDeleteFileResponseSchema, BetterAgentError>>;
|
|
362
|
+
/** Downloads raw file content for a provider-managed xAI file. */
|
|
363
|
+
content(fileId: string, options?: {
|
|
364
|
+
signal?: AbortSignal | null;
|
|
365
|
+
}): Promise<Result<Uint8Array, BetterAgentError>>;
|
|
366
|
+
}
|
|
367
|
+
type XAIModelId = XAIResponseModelId | XAIImageModelId;
|
|
368
|
+
type XAIGenerativeModel<M extends XAIModelId = XAIModelId> = M extends XAIImageModelId ? XAIImageGenerativeModel<M> : XAIResponseGenerativeModel<M>;
|
|
369
|
+
interface XAIProvider {
|
|
370
|
+
readonly id: "xai";
|
|
371
|
+
readonly tools: XAINativeToolBuilders;
|
|
372
|
+
readonly files: XAIFilesClient;
|
|
373
|
+
model<M extends XAIModelId>(modelId: M): XAIGenerativeModel<M>;
|
|
374
|
+
text<M extends XAIResponseModelId>(modelId: M): XAIResponseGenerativeModel<M>;
|
|
375
|
+
image<M extends XAIImageModelId>(modelId: M): XAIImageGenerativeModel<M>;
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/xai/provider.d.ts
|
|
379
|
+
declare const createXAI: (config: XAIConfig) => XAIProvider;
|
|
380
|
+
//#endregion
|
|
381
|
+
export { XAIConfig, XAIError, XAIFileUploadRequest, XAIFilesClient, XAIGenerativeModel, type XAIImageCaps, type XAIImageEndpointOptions, type XAIImageGenerativeModel, type XAIImageModelId, XAIModelId, XAIProvider, type XAIResponseCaps, type XAIResponseEndpointOptions, type XAIResponseGenerativeModel, type XAIResponseModelId, type XAIResponseStreamEvent, XAIUploadableFile, createXAI };
|
|
382
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/xai/shared/schemas.ts","../../src/xai/images/schemas.ts","../../src/xai/images/types.ts","../../src/xai/responses/schemas.ts","../../src/xai/responses/types.ts","../../src/xai/tools/index.ts","../../src/xai/types.ts","../../src/xai/provider.ts"],"mappings":";;;;;;;KAEY,sBAAA;EAEF,IAAA;EACA,OAAA;EAAA,CACC,GAAA;AAAA;EAGD,IAAA;EACA,QAAA;EAAA,CACC,GAAA;AAAA;EAGD,IAAA;EAAA,CAKC,GAAA;AAAA;EAGD,IAAA;EAKA,KAAA;EACA,OAAA;EACA,OAAA;EAAA,CACC,GAAA;AAAA;EAGD,IAAA;EACA,OAAA;EACA,OAAA;EAAA,CACC,GAAA;AAAA;EAGD,IAAA;EACA,IAAA;IACI,IAAA;IACA,EAAA;IACA,OAAA;IACA,IAAA;IACA,MAAA;IAAA,CACC,GAAA;EAAA;EAAA,CAEJ,GAAA;AAAA;EAGD,IAAA;EAsBA,OAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAGC,mBAAA,GAAsB,CAAA,CAAE,KAAA,QAAa,mBAAA;AAAA,KACrC,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,KACnC,2BAAA,GAA8B,CAAA,CAAE,KAAA,QAAa,2BAAA;AAAA,cAmB5C,iBAAA,EAAiB,CAAA,CAAA,OAAA;;;;;;;;;;;;;;cAMjB,cAAA,EAAc,CAAA,CAAA,OAAA;;;KAMf,iBAAA,GAAoB,CAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,KACnC,cAAA,GAAiB,CAAA,CAAE,KAAA,QAAa,cAAA;AAAA,cAsBtC,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;;;;;cAmBnB,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAWjB,2BAAA,EAA2B,CAAA,CAAA,SAAA;;;;;;;KC/JrB,oBAAA,GAAuB,CAAA,CAAE,KAAA,QAAa,oBAAA;AAAA,KAEtC,kBAAA,GAAqB,CAAA,CAAE,KAAA,QAAa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