openllmprovider 0.1.0
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 +192 -0
- package/dist/auth/index.cjs +6 -0
- package/dist/auth/index.d.cts +3 -0
- package/dist/auth/index.d.mts +3 -0
- package/dist/auth/index.mjs +3 -0
- package/dist/auto-C2hXJY13.d.cts +33 -0
- package/dist/auto-C2hXJY13.d.cts.map +1 -0
- package/dist/auto-CBqNYBXs.mjs +48 -0
- package/dist/auto-CBqNYBXs.mjs.map +1 -0
- package/dist/auto-CInerwvs.d.mts +33 -0
- package/dist/auto-CInerwvs.d.mts.map +1 -0
- package/dist/auto-D77wgMqO.cjs +59 -0
- package/dist/auto-D77wgMqO.cjs.map +1 -0
- package/dist/file-DB-rxfzi.mjs +77 -0
- package/dist/file-DB-rxfzi.mjs.map +1 -0
- package/dist/file-DZ7FGcSW.cjs +73 -0
- package/dist/file-DZ7FGcSW.cjs.map +1 -0
- package/dist/index.cjs +1909 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1239 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1241 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1891 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger-BsHpI_fH.mjs +11 -0
- package/dist/logger-BsHpI_fH.mjs.map +1 -0
- package/dist/logger-jRimlMFR.cjs +69 -0
- package/dist/logger-jRimlMFR.cjs.map +1 -0
- package/dist/plugin/index.cjs +29 -0
- package/dist/plugin/index.cjs.map +1 -0
- package/dist/plugin/index.d.cts +10 -0
- package/dist/plugin/index.d.cts.map +1 -0
- package/dist/plugin/index.d.mts +10 -0
- package/dist/plugin/index.d.mts.map +1 -0
- package/dist/plugin/index.mjs +25 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/plugin-BkeUu5LW.d.mts +46 -0
- package/dist/plugin-BkeUu5LW.d.mts.map +1 -0
- package/dist/plugin-wK7RmJhZ.d.cts +46 -0
- package/dist/plugin-wK7RmJhZ.d.cts.map +1 -0
- package/dist/resolver-BA7LWSJO.mjs +645 -0
- package/dist/resolver-BA7LWSJO.mjs.map +1 -0
- package/dist/resolver-BMTvzTt9.cjs +662 -0
- package/dist/resolver-BMTvzTt9.cjs.map +1 -0
- package/dist/resolver-MgJryMWG.d.cts +75 -0
- package/dist/resolver-MgJryMWG.d.cts.map +1 -0
- package/dist/resolver-_gfXzr_S.d.mts +76 -0
- package/dist/resolver-_gfXzr_S.d.mts.map +1 -0
- package/dist/storage/index.cjs +7 -0
- package/dist/storage/index.d.cts +12 -0
- package/dist/storage/index.d.cts.map +1 -0
- package/dist/storage/index.d.mts +12 -0
- package/dist/storage/index.d.mts.map +1 -0
- package/dist/storage/index.mjs +4 -0
- package/package.json +137 -0
- package/src/auth/.gitkeep +0 -0
- package/src/auth/index.ts +10 -0
- package/src/auth/resolver.ts +46 -0
- package/src/auth/scanners.ts +462 -0
- package/src/auth/store.ts +357 -0
- package/src/catalog/.gitkeep +0 -0
- package/src/catalog/catalog.ts +302 -0
- package/src/catalog/index.ts +17 -0
- package/src/catalog/mapper.ts +129 -0
- package/src/catalog/merger.ts +99 -0
- package/src/index.ts +37 -0
- package/src/logger.ts +7 -0
- package/src/plugin/.gitkeep +0 -0
- package/src/plugin/anthropic.test.ts +505 -0
- package/src/plugin/anthropic.ts +324 -0
- package/src/plugin/codex.ts +656 -0
- package/src/plugin/copilot.ts +161 -0
- package/src/plugin/google.ts +454 -0
- package/src/plugin/index.ts +30 -0
- package/src/provider/.gitkeep +0 -0
- package/src/provider/bundled.ts +59 -0
- package/src/provider/index.ts +249 -0
- package/src/provider/state.ts +163 -0
- package/src/storage/.gitkeep +0 -0
- package/src/storage/auto.ts +32 -0
- package/src/storage/file.ts +84 -0
- package/src/storage/index.ts +10 -0
- package/src/storage/memory.ts +23 -0
- package/src/types/.gitkeep +0 -0
- package/src/types/auth.ts +18 -0
- package/src/types/errors.ts +87 -0
- package/src/types/index.ts +26 -0
- package/src/types/model.ts +88 -0
- package/src/types/plugin.ts +49 -0
- package/src/types/provider.ts +48 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1239 @@
|
|
|
1
|
+
import { a as MemoryStorage, n as createDefaultStorage, r as FileStorage } from "./auto-C2hXJY13.cjs";
|
|
2
|
+
import { StorageAdapter } from "./storage/index.cjs";
|
|
3
|
+
import { i as ProviderInfo, n as AuthHook, r as AuthMethod, t as AuthCredential } from "./plugin-wK7RmJhZ.cjs";
|
|
4
|
+
import { a as AuthStoreOptions, c as createAuthStore, d as DiskScanner, f as ScanContext, i as AuthStore, l as DEFAULT_SCANNERS, n as SecretRef, o as DiscoverOptions, r as SecretResolver, s as DiscoveredCredential, u as DiskScanResult } from "./resolver-MgJryMWG.cjs";
|
|
5
|
+
import { getPluginForProvider, getPlugins, registerPlugin } from "./plugin/index.cjs";
|
|
6
|
+
import { JSONSchema7 } from "json-schema";
|
|
7
|
+
import createDebug from "debug";
|
|
8
|
+
|
|
9
|
+
//#region node_modules/@ai-sdk/provider/dist/index.d.ts
|
|
10
|
+
type SharedV3Headers = Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* A JSON value can be a string, number, boolean, object, array, or null.
|
|
13
|
+
* JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
|
|
14
|
+
*/
|
|
15
|
+
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
16
|
+
type JSONObject = {
|
|
17
|
+
[key: string]: JSONValue | undefined;
|
|
18
|
+
};
|
|
19
|
+
type JSONArray = JSONValue[];
|
|
20
|
+
/**
|
|
21
|
+
* Additional provider-specific metadata.
|
|
22
|
+
* Metadata are additional outputs from the provider.
|
|
23
|
+
* They are passed through to the provider from the AI SDK
|
|
24
|
+
* and enable provider-specific functionality
|
|
25
|
+
* that can be fully encapsulated in the provider.
|
|
26
|
+
*
|
|
27
|
+
* This enables us to quickly ship provider-specific functionality
|
|
28
|
+
* without affecting the core AI SDK.
|
|
29
|
+
*
|
|
30
|
+
* The outer record is keyed by the provider name, and the inner
|
|
31
|
+
* record is keyed by the provider-specific metadata key.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* {
|
|
35
|
+
* "anthropic": {
|
|
36
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
type SharedV3ProviderMetadata = Record<string, JSONObject>;
|
|
42
|
+
/**
|
|
43
|
+
* Additional provider-specific options.
|
|
44
|
+
* Options are additional input to the provider.
|
|
45
|
+
* They are passed through to the provider from the AI SDK
|
|
46
|
+
* and enable provider-specific functionality
|
|
47
|
+
* that can be fully encapsulated in the provider.
|
|
48
|
+
*
|
|
49
|
+
* This enables us to quickly ship provider-specific functionality
|
|
50
|
+
* without affecting the core AI SDK.
|
|
51
|
+
*
|
|
52
|
+
* The outer record is keyed by the provider name, and the inner
|
|
53
|
+
* record is keyed by the provider-specific metadata key.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* {
|
|
57
|
+
* "anthropic": {
|
|
58
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
type SharedV3ProviderOptions = Record<string, JSONObject>;
|
|
64
|
+
/**
|
|
65
|
+
* Warning from the model.
|
|
66
|
+
*
|
|
67
|
+
* For example, that certain features are unsupported or compatibility
|
|
68
|
+
* functionality is used (which might lead to suboptimal results).
|
|
69
|
+
*/
|
|
70
|
+
type SharedV3Warning = {
|
|
71
|
+
/**
|
|
72
|
+
* A feature is not supported by the model.
|
|
73
|
+
*/
|
|
74
|
+
type: 'unsupported';
|
|
75
|
+
/**
|
|
76
|
+
* The feature that is not supported.
|
|
77
|
+
*/
|
|
78
|
+
feature: string;
|
|
79
|
+
/**
|
|
80
|
+
* Additional details about the warning.
|
|
81
|
+
*/
|
|
82
|
+
details?: string;
|
|
83
|
+
} | {
|
|
84
|
+
/**
|
|
85
|
+
* A compatibility feature is used that might lead to suboptimal results.
|
|
86
|
+
*/
|
|
87
|
+
type: 'compatibility';
|
|
88
|
+
/**
|
|
89
|
+
* The feature that is used in a compatibility mode.
|
|
90
|
+
*/
|
|
91
|
+
feature: string;
|
|
92
|
+
/**
|
|
93
|
+
* Additional details about the warning.
|
|
94
|
+
*/
|
|
95
|
+
details?: string;
|
|
96
|
+
} | {
|
|
97
|
+
/**
|
|
98
|
+
* Other warning.
|
|
99
|
+
*/
|
|
100
|
+
type: 'other';
|
|
101
|
+
/**
|
|
102
|
+
* The message of the warning.
|
|
103
|
+
*/
|
|
104
|
+
message: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A tool has a name, a description, and a set of parameters.
|
|
108
|
+
*
|
|
109
|
+
* Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
110
|
+
* map the user-facing tool definitions to this format.
|
|
111
|
+
*/
|
|
112
|
+
type LanguageModelV3FunctionTool = {
|
|
113
|
+
/**
|
|
114
|
+
* The type of the tool (always 'function').
|
|
115
|
+
*/
|
|
116
|
+
type: 'function';
|
|
117
|
+
/**
|
|
118
|
+
* The name of the tool. Unique within this model call.
|
|
119
|
+
*/
|
|
120
|
+
name: string;
|
|
121
|
+
/**
|
|
122
|
+
* A description of the tool. The language model uses this to understand the
|
|
123
|
+
* tool's purpose and to provide better completion suggestions.
|
|
124
|
+
*/
|
|
125
|
+
description?: string;
|
|
126
|
+
/**
|
|
127
|
+
* The parameters that the tool expects. The language model uses this to
|
|
128
|
+
* understand the tool's input requirements and to provide matching suggestions.
|
|
129
|
+
*/
|
|
130
|
+
inputSchema: JSONSchema7;
|
|
131
|
+
/**
|
|
132
|
+
* An optional list of input examples that show the language
|
|
133
|
+
* model what the input should look like.
|
|
134
|
+
*/
|
|
135
|
+
inputExamples?: Array<{
|
|
136
|
+
input: JSONObject;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Strict mode setting for the tool.
|
|
140
|
+
*
|
|
141
|
+
* Providers that support strict mode will use this setting to determine
|
|
142
|
+
* how the input should be generated. Strict mode will always produce
|
|
143
|
+
* valid inputs, but it might limit what input schemas are supported.
|
|
144
|
+
*/
|
|
145
|
+
strict?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The provider-specific options for the tool.
|
|
148
|
+
*/
|
|
149
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Data content. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
153
|
+
*/
|
|
154
|
+
type LanguageModelV3DataContent = Uint8Array | string | URL;
|
|
155
|
+
/**
|
|
156
|
+
* A prompt is a list of messages.
|
|
157
|
+
*
|
|
158
|
+
* Note: Not all models and prompt formats support multi-modal inputs and
|
|
159
|
+
* tool calls. The validation happens at runtime.
|
|
160
|
+
*
|
|
161
|
+
* Note: This is not a user-facing prompt. The AI SDK methods will map the
|
|
162
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
163
|
+
*/
|
|
164
|
+
type LanguageModelV3Prompt = Array<LanguageModelV3Message>;
|
|
165
|
+
type LanguageModelV3Message = ({
|
|
166
|
+
role: 'system';
|
|
167
|
+
content: string;
|
|
168
|
+
} | {
|
|
169
|
+
role: 'user';
|
|
170
|
+
content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart>;
|
|
171
|
+
} | {
|
|
172
|
+
role: 'assistant';
|
|
173
|
+
content: Array<LanguageModelV3TextPart | LanguageModelV3FilePart | LanguageModelV3ReasoningPart | LanguageModelV3ToolCallPart | LanguageModelV3ToolResultPart>;
|
|
174
|
+
} | {
|
|
175
|
+
role: 'tool';
|
|
176
|
+
content: Array<LanguageModelV3ToolResultPart | LanguageModelV3ToolApprovalResponsePart>;
|
|
177
|
+
}) & {
|
|
178
|
+
/**
|
|
179
|
+
* Additional provider-specific options. They are passed through
|
|
180
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
181
|
+
* functionality that can be fully encapsulated in the provider.
|
|
182
|
+
*/
|
|
183
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Text content part of a prompt. It contains a string of text.
|
|
187
|
+
*/
|
|
188
|
+
interface LanguageModelV3TextPart {
|
|
189
|
+
type: 'text';
|
|
190
|
+
/**
|
|
191
|
+
* The text content.
|
|
192
|
+
*/
|
|
193
|
+
text: string;
|
|
194
|
+
/**
|
|
195
|
+
* Additional provider-specific options. They are passed through
|
|
196
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
197
|
+
* functionality that can be fully encapsulated in the provider.
|
|
198
|
+
*/
|
|
199
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Reasoning content part of a prompt. It contains a string of reasoning text.
|
|
203
|
+
*/
|
|
204
|
+
interface LanguageModelV3ReasoningPart {
|
|
205
|
+
type: 'reasoning';
|
|
206
|
+
/**
|
|
207
|
+
* The reasoning text.
|
|
208
|
+
*/
|
|
209
|
+
text: string;
|
|
210
|
+
/**
|
|
211
|
+
* Additional provider-specific options. They are passed through
|
|
212
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
213
|
+
* functionality that can be fully encapsulated in the provider.
|
|
214
|
+
*/
|
|
215
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* File content part of a prompt. It contains a file.
|
|
219
|
+
*/
|
|
220
|
+
interface LanguageModelV3FilePart {
|
|
221
|
+
type: 'file';
|
|
222
|
+
/**
|
|
223
|
+
* Optional filename of the file.
|
|
224
|
+
*/
|
|
225
|
+
filename?: string;
|
|
226
|
+
/**
|
|
227
|
+
* File data. Can be a Uint8Array, base64 encoded data as a string or a URL.
|
|
228
|
+
*/
|
|
229
|
+
data: LanguageModelV3DataContent;
|
|
230
|
+
/**
|
|
231
|
+
* IANA media type of the file.
|
|
232
|
+
*
|
|
233
|
+
* Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action).
|
|
234
|
+
*
|
|
235
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
236
|
+
*/
|
|
237
|
+
mediaType: string;
|
|
238
|
+
/**
|
|
239
|
+
* Additional provider-specific options. They are passed through
|
|
240
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
241
|
+
* functionality that can be fully encapsulated in the provider.
|
|
242
|
+
*/
|
|
243
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
247
|
+
*/
|
|
248
|
+
interface LanguageModelV3ToolCallPart {
|
|
249
|
+
type: 'tool-call';
|
|
250
|
+
/**
|
|
251
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
252
|
+
*/
|
|
253
|
+
toolCallId: string;
|
|
254
|
+
/**
|
|
255
|
+
* Name of the tool that is being called.
|
|
256
|
+
*/
|
|
257
|
+
toolName: string;
|
|
258
|
+
/**
|
|
259
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
260
|
+
*/
|
|
261
|
+
input: unknown;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the tool call will be executed by the provider.
|
|
264
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
265
|
+
*/
|
|
266
|
+
providerExecuted?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Additional provider-specific options. They are passed through
|
|
269
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
270
|
+
* functionality that can be fully encapsulated in the provider.
|
|
271
|
+
*/
|
|
272
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
276
|
+
*/
|
|
277
|
+
interface LanguageModelV3ToolResultPart {
|
|
278
|
+
type: 'tool-result';
|
|
279
|
+
/**
|
|
280
|
+
* ID of the tool call that this result is associated with.
|
|
281
|
+
*/
|
|
282
|
+
toolCallId: string;
|
|
283
|
+
/**
|
|
284
|
+
* Name of the tool that generated this result.
|
|
285
|
+
*/
|
|
286
|
+
toolName: string;
|
|
287
|
+
/**
|
|
288
|
+
* Result of the tool call.
|
|
289
|
+
*/
|
|
290
|
+
output: LanguageModelV3ToolResultOutput;
|
|
291
|
+
/**
|
|
292
|
+
* Additional provider-specific options. They are passed through
|
|
293
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
294
|
+
* functionality that can be fully encapsulated in the provider.
|
|
295
|
+
*/
|
|
296
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Tool approval response content part of a prompt. It contains the user's
|
|
300
|
+
* decision to approve or deny a provider-executed tool call.
|
|
301
|
+
*/
|
|
302
|
+
interface LanguageModelV3ToolApprovalResponsePart {
|
|
303
|
+
type: 'tool-approval-response';
|
|
304
|
+
/**
|
|
305
|
+
* ID of the approval request that this response refers to.
|
|
306
|
+
*/
|
|
307
|
+
approvalId: string;
|
|
308
|
+
/**
|
|
309
|
+
* Whether the approval was granted (true) or denied (false).
|
|
310
|
+
*/
|
|
311
|
+
approved: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Optional reason for approval or denial.
|
|
314
|
+
*/
|
|
315
|
+
reason?: string;
|
|
316
|
+
/**
|
|
317
|
+
* Additional provider-specific options. They are passed through
|
|
318
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
319
|
+
* functionality that can be fully encapsulated in the provider.
|
|
320
|
+
*/
|
|
321
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Result of a tool call.
|
|
325
|
+
*/
|
|
326
|
+
type LanguageModelV3ToolResultOutput = {
|
|
327
|
+
/**
|
|
328
|
+
* Text tool output that should be directly sent to the API.
|
|
329
|
+
*/
|
|
330
|
+
type: 'text';
|
|
331
|
+
value: string;
|
|
332
|
+
/**
|
|
333
|
+
* Provider-specific options.
|
|
334
|
+
*/
|
|
335
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
336
|
+
} | {
|
|
337
|
+
type: 'json';
|
|
338
|
+
value: JSONValue;
|
|
339
|
+
/**
|
|
340
|
+
* Provider-specific options.
|
|
341
|
+
*/
|
|
342
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
343
|
+
} | {
|
|
344
|
+
/**
|
|
345
|
+
* Type when the user has denied the execution of the tool call.
|
|
346
|
+
*/
|
|
347
|
+
type: 'execution-denied';
|
|
348
|
+
/**
|
|
349
|
+
* Optional reason for the execution denial.
|
|
350
|
+
*/
|
|
351
|
+
reason?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Provider-specific options.
|
|
354
|
+
*/
|
|
355
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
356
|
+
} | {
|
|
357
|
+
type: 'error-text';
|
|
358
|
+
value: string;
|
|
359
|
+
/**
|
|
360
|
+
* Provider-specific options.
|
|
361
|
+
*/
|
|
362
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
363
|
+
} | {
|
|
364
|
+
type: 'error-json';
|
|
365
|
+
value: JSONValue;
|
|
366
|
+
/**
|
|
367
|
+
* Provider-specific options.
|
|
368
|
+
*/
|
|
369
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
370
|
+
} | {
|
|
371
|
+
type: 'content';
|
|
372
|
+
value: Array<{
|
|
373
|
+
type: 'text';
|
|
374
|
+
/**
|
|
375
|
+
* Text content.
|
|
376
|
+
*/
|
|
377
|
+
text: string;
|
|
378
|
+
/**
|
|
379
|
+
* Provider-specific options.
|
|
380
|
+
*/
|
|
381
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
382
|
+
} | {
|
|
383
|
+
type: 'file-data';
|
|
384
|
+
/**
|
|
385
|
+
* Base-64 encoded media data.
|
|
386
|
+
*/
|
|
387
|
+
data: string;
|
|
388
|
+
/**
|
|
389
|
+
* IANA media type.
|
|
390
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
391
|
+
*/
|
|
392
|
+
mediaType: string;
|
|
393
|
+
/**
|
|
394
|
+
* Optional filename of the file.
|
|
395
|
+
*/
|
|
396
|
+
filename?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Provider-specific options.
|
|
399
|
+
*/
|
|
400
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
401
|
+
} | {
|
|
402
|
+
type: 'file-url';
|
|
403
|
+
/**
|
|
404
|
+
* URL of the file.
|
|
405
|
+
*/
|
|
406
|
+
url: string;
|
|
407
|
+
/**
|
|
408
|
+
* Provider-specific options.
|
|
409
|
+
*/
|
|
410
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
411
|
+
} | {
|
|
412
|
+
type: 'file-id';
|
|
413
|
+
/**
|
|
414
|
+
* ID of the file.
|
|
415
|
+
*
|
|
416
|
+
* If you use multiple providers, you need to
|
|
417
|
+
* specify the provider specific ids using
|
|
418
|
+
* the Record option. The key is the provider
|
|
419
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
420
|
+
*/
|
|
421
|
+
fileId: string | Record<string, string>;
|
|
422
|
+
/**
|
|
423
|
+
* Provider-specific options.
|
|
424
|
+
*/
|
|
425
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
426
|
+
} | {
|
|
427
|
+
/**
|
|
428
|
+
* Images that are referenced using base64 encoded data.
|
|
429
|
+
*/
|
|
430
|
+
type: 'image-data';
|
|
431
|
+
/**
|
|
432
|
+
* Base-64 encoded image data.
|
|
433
|
+
*/
|
|
434
|
+
data: string;
|
|
435
|
+
/**
|
|
436
|
+
* IANA media type.
|
|
437
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
438
|
+
*/
|
|
439
|
+
mediaType: string;
|
|
440
|
+
/**
|
|
441
|
+
* Provider-specific options.
|
|
442
|
+
*/
|
|
443
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
444
|
+
} | {
|
|
445
|
+
/**
|
|
446
|
+
* Images that are referenced using a URL.
|
|
447
|
+
*/
|
|
448
|
+
type: 'image-url';
|
|
449
|
+
/**
|
|
450
|
+
* URL of the image.
|
|
451
|
+
*/
|
|
452
|
+
url: string;
|
|
453
|
+
/**
|
|
454
|
+
* Provider-specific options.
|
|
455
|
+
*/
|
|
456
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
457
|
+
} | {
|
|
458
|
+
/**
|
|
459
|
+
* Images that are referenced using a provider file id.
|
|
460
|
+
*/
|
|
461
|
+
type: 'image-file-id';
|
|
462
|
+
/**
|
|
463
|
+
* Image that is referenced using a provider file id.
|
|
464
|
+
*
|
|
465
|
+
* If you use multiple providers, you need to
|
|
466
|
+
* specify the provider specific ids using
|
|
467
|
+
* the Record option. The key is the provider
|
|
468
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
469
|
+
*/
|
|
470
|
+
fileId: string | Record<string, string>;
|
|
471
|
+
/**
|
|
472
|
+
* Provider-specific options.
|
|
473
|
+
*/
|
|
474
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
475
|
+
} | {
|
|
476
|
+
/**
|
|
477
|
+
* Custom content part. This can be used to implement
|
|
478
|
+
* provider-specific content parts.
|
|
479
|
+
*/
|
|
480
|
+
type: 'custom';
|
|
481
|
+
/**
|
|
482
|
+
* Provider-specific options.
|
|
483
|
+
*/
|
|
484
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
485
|
+
}>;
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* The configuration of a provider tool.
|
|
489
|
+
*
|
|
490
|
+
* Provider tools are tools that are specific to a certain provider.
|
|
491
|
+
* The input and output schemas are defined be the provider, and
|
|
492
|
+
* some of the tools are also executed on the provider systems.
|
|
493
|
+
*/
|
|
494
|
+
type LanguageModelV3ProviderTool = {
|
|
495
|
+
/**
|
|
496
|
+
* The type of the tool (always 'provider').
|
|
497
|
+
*/
|
|
498
|
+
type: 'provider';
|
|
499
|
+
/**
|
|
500
|
+
* The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
|
|
501
|
+
*/
|
|
502
|
+
id: `${string}.${string}`;
|
|
503
|
+
/**
|
|
504
|
+
* The name of the tool. Unique within this model call.
|
|
505
|
+
*/
|
|
506
|
+
name: string;
|
|
507
|
+
/**
|
|
508
|
+
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
509
|
+
*/
|
|
510
|
+
args: Record<string, unknown>;
|
|
511
|
+
};
|
|
512
|
+
type LanguageModelV3ToolChoice = {
|
|
513
|
+
type: 'auto';
|
|
514
|
+
} | {
|
|
515
|
+
type: 'none';
|
|
516
|
+
} | {
|
|
517
|
+
type: 'required';
|
|
518
|
+
} | {
|
|
519
|
+
type: 'tool';
|
|
520
|
+
toolName: string;
|
|
521
|
+
};
|
|
522
|
+
type LanguageModelV3CallOptions = {
|
|
523
|
+
/**
|
|
524
|
+
* A language mode prompt is a standardized prompt type.
|
|
525
|
+
*
|
|
526
|
+
* Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
527
|
+
* user-facing prompt types such as chat or instruction prompts to this format.
|
|
528
|
+
* That approach allows us to evolve the user facing prompts without breaking
|
|
529
|
+
* the language model interface.
|
|
530
|
+
*/
|
|
531
|
+
prompt: LanguageModelV3Prompt;
|
|
532
|
+
/**
|
|
533
|
+
* Maximum number of tokens to generate.
|
|
534
|
+
*/
|
|
535
|
+
maxOutputTokens?: number;
|
|
536
|
+
/**
|
|
537
|
+
* Temperature setting. The range depends on the provider and model.
|
|
538
|
+
*/
|
|
539
|
+
temperature?: number;
|
|
540
|
+
/**
|
|
541
|
+
* Stop sequences.
|
|
542
|
+
* If set, the model will stop generating text when one of the stop sequences is generated.
|
|
543
|
+
* Providers may have limits on the number of stop sequences.
|
|
544
|
+
*/
|
|
545
|
+
stopSequences?: string[];
|
|
546
|
+
/**
|
|
547
|
+
* Nucleus sampling.
|
|
548
|
+
*/
|
|
549
|
+
topP?: number;
|
|
550
|
+
/**
|
|
551
|
+
* Only sample from the top K options for each subsequent token.
|
|
552
|
+
*
|
|
553
|
+
* Used to remove "long tail" low probability responses.
|
|
554
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
555
|
+
*/
|
|
556
|
+
topK?: number;
|
|
557
|
+
/**
|
|
558
|
+
* Presence penalty setting. It affects the likelihood of the model to
|
|
559
|
+
* repeat information that is already in the prompt.
|
|
560
|
+
*/
|
|
561
|
+
presencePenalty?: number;
|
|
562
|
+
/**
|
|
563
|
+
* Frequency penalty setting. It affects the likelihood of the model
|
|
564
|
+
* to repeatedly use the same words or phrases.
|
|
565
|
+
*/
|
|
566
|
+
frequencyPenalty?: number;
|
|
567
|
+
/**
|
|
568
|
+
* Response format. The output can either be text or JSON. Default is text.
|
|
569
|
+
*
|
|
570
|
+
* If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
571
|
+
*/
|
|
572
|
+
responseFormat?: {
|
|
573
|
+
type: 'text';
|
|
574
|
+
} | {
|
|
575
|
+
type: 'json';
|
|
576
|
+
/**
|
|
577
|
+
* JSON schema that the generated output should conform to.
|
|
578
|
+
*/
|
|
579
|
+
schema?: JSONSchema7;
|
|
580
|
+
/**
|
|
581
|
+
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
582
|
+
*/
|
|
583
|
+
name?: string;
|
|
584
|
+
/**
|
|
585
|
+
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
586
|
+
*/
|
|
587
|
+
description?: string;
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* The seed (integer) to use for random sampling. If set and supported
|
|
591
|
+
* by the model, calls will generate deterministic results.
|
|
592
|
+
*/
|
|
593
|
+
seed?: number;
|
|
594
|
+
/**
|
|
595
|
+
* The tools that are available for the model.
|
|
596
|
+
*/
|
|
597
|
+
tools?: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool>;
|
|
598
|
+
/**
|
|
599
|
+
* Specifies how the tool should be selected. Defaults to 'auto'.
|
|
600
|
+
*/
|
|
601
|
+
toolChoice?: LanguageModelV3ToolChoice;
|
|
602
|
+
/**
|
|
603
|
+
* Include raw chunks in the stream. Only applicable for streaming calls.
|
|
604
|
+
*/
|
|
605
|
+
includeRawChunks?: boolean;
|
|
606
|
+
/**
|
|
607
|
+
* Abort signal for cancelling the operation.
|
|
608
|
+
*/
|
|
609
|
+
abortSignal?: AbortSignal;
|
|
610
|
+
/**
|
|
611
|
+
* Additional HTTP headers to be sent with the request.
|
|
612
|
+
* Only applicable for HTTP-based providers.
|
|
613
|
+
*/
|
|
614
|
+
headers?: Record<string, string | undefined>;
|
|
615
|
+
/**
|
|
616
|
+
* Additional provider-specific options. They are passed through
|
|
617
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
618
|
+
* functionality that can be fully encapsulated in the provider.
|
|
619
|
+
*/
|
|
620
|
+
providerOptions?: SharedV3ProviderOptions;
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* A file that has been generated by the model.
|
|
624
|
+
* Generated files as base64 encoded strings or binary data.
|
|
625
|
+
* The files should be returned without any unnecessary conversion.
|
|
626
|
+
*/
|
|
627
|
+
type LanguageModelV3File = {
|
|
628
|
+
type: 'file';
|
|
629
|
+
/**
|
|
630
|
+
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
631
|
+
*
|
|
632
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
633
|
+
*/
|
|
634
|
+
mediaType: string;
|
|
635
|
+
/**
|
|
636
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
637
|
+
*
|
|
638
|
+
* The file data should be returned without any unnecessary conversion.
|
|
639
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
640
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
641
|
+
* be returned as binary data.
|
|
642
|
+
*/
|
|
643
|
+
data: string | Uint8Array;
|
|
644
|
+
/**
|
|
645
|
+
* Optional provider-specific metadata for the file part.
|
|
646
|
+
*/
|
|
647
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* Reasoning that the model has generated.
|
|
651
|
+
*/
|
|
652
|
+
type LanguageModelV3Reasoning = {
|
|
653
|
+
type: 'reasoning';
|
|
654
|
+
text: string;
|
|
655
|
+
/**
|
|
656
|
+
* Optional provider-specific metadata for the reasoning part.
|
|
657
|
+
*/
|
|
658
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
659
|
+
};
|
|
660
|
+
/**
|
|
661
|
+
* A source that has been used as input to generate the response.
|
|
662
|
+
*/
|
|
663
|
+
type LanguageModelV3Source = {
|
|
664
|
+
type: 'source';
|
|
665
|
+
/**
|
|
666
|
+
* The type of source - URL sources reference web content.
|
|
667
|
+
*/
|
|
668
|
+
sourceType: 'url';
|
|
669
|
+
/**
|
|
670
|
+
* The ID of the source.
|
|
671
|
+
*/
|
|
672
|
+
id: string;
|
|
673
|
+
/**
|
|
674
|
+
* The URL of the source.
|
|
675
|
+
*/
|
|
676
|
+
url: string;
|
|
677
|
+
/**
|
|
678
|
+
* The title of the source.
|
|
679
|
+
*/
|
|
680
|
+
title?: string;
|
|
681
|
+
/**
|
|
682
|
+
* Additional provider metadata for the source.
|
|
683
|
+
*/
|
|
684
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
685
|
+
} | {
|
|
686
|
+
type: 'source';
|
|
687
|
+
/**
|
|
688
|
+
* The type of source - document sources reference files/documents.
|
|
689
|
+
*/
|
|
690
|
+
sourceType: 'document';
|
|
691
|
+
/**
|
|
692
|
+
* The ID of the source.
|
|
693
|
+
*/
|
|
694
|
+
id: string;
|
|
695
|
+
/**
|
|
696
|
+
* IANA media type of the document (e.g., 'application/pdf').
|
|
697
|
+
*/
|
|
698
|
+
mediaType: string;
|
|
699
|
+
/**
|
|
700
|
+
* The title of the document.
|
|
701
|
+
*/
|
|
702
|
+
title: string;
|
|
703
|
+
/**
|
|
704
|
+
* Optional filename of the document.
|
|
705
|
+
*/
|
|
706
|
+
filename?: string;
|
|
707
|
+
/**
|
|
708
|
+
* Additional provider metadata for the source.
|
|
709
|
+
*/
|
|
710
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
711
|
+
};
|
|
712
|
+
/**
|
|
713
|
+
* Text that the model has generated.
|
|
714
|
+
*/
|
|
715
|
+
type LanguageModelV3Text = {
|
|
716
|
+
type: 'text';
|
|
717
|
+
/**
|
|
718
|
+
* The text content.
|
|
719
|
+
*/
|
|
720
|
+
text: string;
|
|
721
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
722
|
+
};
|
|
723
|
+
/**
|
|
724
|
+
* Tool approval request emitted by a provider for a provider-executed tool call.
|
|
725
|
+
*
|
|
726
|
+
* This is used for flows where the provider executes the tool (e.g. MCP tools)
|
|
727
|
+
* but requires an explicit user approval before continuing.
|
|
728
|
+
*/
|
|
729
|
+
type LanguageModelV3ToolApprovalRequest = {
|
|
730
|
+
type: 'tool-approval-request';
|
|
731
|
+
/**
|
|
732
|
+
* ID of the approval request. This ID is referenced by the subsequent
|
|
733
|
+
* tool-approval-response (tool message) to approve or deny execution.
|
|
734
|
+
*/
|
|
735
|
+
approvalId: string;
|
|
736
|
+
/**
|
|
737
|
+
* The tool call ID that this approval request is for.
|
|
738
|
+
*/
|
|
739
|
+
toolCallId: string;
|
|
740
|
+
/**
|
|
741
|
+
* Additional provider-specific metadata for the approval request.
|
|
742
|
+
*/
|
|
743
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Tool calls that the model has generated.
|
|
747
|
+
*/
|
|
748
|
+
type LanguageModelV3ToolCall = {
|
|
749
|
+
type: 'tool-call';
|
|
750
|
+
/**
|
|
751
|
+
* The identifier of the tool call. It must be unique across all tool calls.
|
|
752
|
+
*/
|
|
753
|
+
toolCallId: string;
|
|
754
|
+
/**
|
|
755
|
+
* The name of the tool that should be called.
|
|
756
|
+
*/
|
|
757
|
+
toolName: string;
|
|
758
|
+
/**
|
|
759
|
+
* Stringified JSON object with the tool call arguments. Must match the
|
|
760
|
+
* parameters schema of the tool.
|
|
761
|
+
*/
|
|
762
|
+
input: string;
|
|
763
|
+
/**
|
|
764
|
+
* Whether the tool call will be executed by the provider.
|
|
765
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
766
|
+
*/
|
|
767
|
+
providerExecuted?: boolean;
|
|
768
|
+
/**
|
|
769
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
770
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
771
|
+
*/
|
|
772
|
+
dynamic?: boolean;
|
|
773
|
+
/**
|
|
774
|
+
* Additional provider-specific metadata for the tool call.
|
|
775
|
+
*/
|
|
776
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* Result of a tool call that has been executed by the provider.
|
|
780
|
+
*/
|
|
781
|
+
type LanguageModelV3ToolResult = {
|
|
782
|
+
type: 'tool-result';
|
|
783
|
+
/**
|
|
784
|
+
* The ID of the tool call that this result is associated with.
|
|
785
|
+
*/
|
|
786
|
+
toolCallId: string;
|
|
787
|
+
/**
|
|
788
|
+
* Name of the tool that generated this result.
|
|
789
|
+
*/
|
|
790
|
+
toolName: string;
|
|
791
|
+
/**
|
|
792
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
793
|
+
*/
|
|
794
|
+
result: NonNullable<JSONValue>;
|
|
795
|
+
/**
|
|
796
|
+
* Optional flag if the result is an error or an error message.
|
|
797
|
+
*/
|
|
798
|
+
isError?: boolean;
|
|
799
|
+
/**
|
|
800
|
+
* Whether the tool result is preliminary.
|
|
801
|
+
*
|
|
802
|
+
* Preliminary tool results replace each other, e.g. image previews.
|
|
803
|
+
* There always has to be a final, non-preliminary tool result.
|
|
804
|
+
*
|
|
805
|
+
* If this flag is set to true, the tool result is preliminary.
|
|
806
|
+
* If this flag is not set or is false, the tool result is not preliminary.
|
|
807
|
+
*/
|
|
808
|
+
preliminary?: boolean;
|
|
809
|
+
/**
|
|
810
|
+
* Whether the tool is dynamic, i.e. defined at runtime.
|
|
811
|
+
* For example, MCP (Model Context Protocol) tools that are executed by the provider.
|
|
812
|
+
*/
|
|
813
|
+
dynamic?: boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Additional provider-specific metadata for the tool result.
|
|
816
|
+
*/
|
|
817
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
818
|
+
};
|
|
819
|
+
type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult;
|
|
820
|
+
/**
|
|
821
|
+
* Reason why a language model finished generating a response.
|
|
822
|
+
*
|
|
823
|
+
* Contains both a unified finish reason and a raw finish reason from the provider.
|
|
824
|
+
* The unified finish reason is used to provide a consistent finish reason across different providers.
|
|
825
|
+
* The raw finish reason is used to provide the original finish reason from the provider.
|
|
826
|
+
*/
|
|
827
|
+
type LanguageModelV3FinishReason = {
|
|
828
|
+
/**
|
|
829
|
+
* Unified finish reason. This enables using the same finish reason across different providers.
|
|
830
|
+
*
|
|
831
|
+
* Can be one of the following:
|
|
832
|
+
* - `stop`: model generated stop sequence
|
|
833
|
+
* - `length`: model generated maximum number of tokens
|
|
834
|
+
* - `content-filter`: content filter violation stopped the model
|
|
835
|
+
* - `tool-calls`: model triggered tool calls
|
|
836
|
+
* - `error`: model stopped because of an error
|
|
837
|
+
* - `other`: model stopped for other reasons
|
|
838
|
+
*/
|
|
839
|
+
unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
840
|
+
/**
|
|
841
|
+
* Raw finish reason from the provider.
|
|
842
|
+
* This is the original finish reason from the provider.
|
|
843
|
+
*/
|
|
844
|
+
raw: string | undefined;
|
|
845
|
+
};
|
|
846
|
+
interface LanguageModelV3ResponseMetadata {
|
|
847
|
+
/**
|
|
848
|
+
* ID for the generated response, if the provider sends one.
|
|
849
|
+
*/
|
|
850
|
+
id?: string;
|
|
851
|
+
/**
|
|
852
|
+
* Timestamp for the start of the generated response, if the provider sends one.
|
|
853
|
+
*/
|
|
854
|
+
timestamp?: Date;
|
|
855
|
+
/**
|
|
856
|
+
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
857
|
+
*/
|
|
858
|
+
modelId?: string;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Usage information for a language model call.
|
|
862
|
+
*/
|
|
863
|
+
type LanguageModelV3Usage = {
|
|
864
|
+
/**
|
|
865
|
+
* Information about the input tokens.
|
|
866
|
+
*/
|
|
867
|
+
inputTokens: {
|
|
868
|
+
/**
|
|
869
|
+
* The total number of input (prompt) tokens used.
|
|
870
|
+
*/
|
|
871
|
+
total: number | undefined;
|
|
872
|
+
/**
|
|
873
|
+
* The number of non-cached input (prompt) tokens used.
|
|
874
|
+
*/
|
|
875
|
+
noCache: number | undefined;
|
|
876
|
+
/**
|
|
877
|
+
* The number of cached input (prompt) tokens read.
|
|
878
|
+
*/
|
|
879
|
+
cacheRead: number | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* The number of cached input (prompt) tokens written.
|
|
882
|
+
*/
|
|
883
|
+
cacheWrite: number | undefined;
|
|
884
|
+
};
|
|
885
|
+
/**
|
|
886
|
+
* Information about the output tokens.
|
|
887
|
+
*/
|
|
888
|
+
outputTokens: {
|
|
889
|
+
/**
|
|
890
|
+
* The total number of output (completion) tokens used.
|
|
891
|
+
*/
|
|
892
|
+
total: number | undefined;
|
|
893
|
+
/**
|
|
894
|
+
* The number of text tokens used.
|
|
895
|
+
*/
|
|
896
|
+
text: number | undefined;
|
|
897
|
+
/**
|
|
898
|
+
* The number of reasoning tokens used.
|
|
899
|
+
*/
|
|
900
|
+
reasoning: number | undefined;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Raw usage information from the provider.
|
|
904
|
+
*
|
|
905
|
+
* This is the usage information in the shape that the provider returns.
|
|
906
|
+
* It can include additional information that is not part of the standard usage information.
|
|
907
|
+
*/
|
|
908
|
+
raw?: JSONObject;
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* The result of a language model doGenerate call.
|
|
912
|
+
*/
|
|
913
|
+
type LanguageModelV3GenerateResult = {
|
|
914
|
+
/**
|
|
915
|
+
* Ordered content that the model has generated.
|
|
916
|
+
*/
|
|
917
|
+
content: Array<LanguageModelV3Content>;
|
|
918
|
+
/**
|
|
919
|
+
* The finish reason.
|
|
920
|
+
*/
|
|
921
|
+
finishReason: LanguageModelV3FinishReason;
|
|
922
|
+
/**
|
|
923
|
+
* The usage information.
|
|
924
|
+
*/
|
|
925
|
+
usage: LanguageModelV3Usage;
|
|
926
|
+
/**
|
|
927
|
+
* Additional provider-specific metadata. They are passed through
|
|
928
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
929
|
+
* results that can be fully encapsulated in the provider.
|
|
930
|
+
*/
|
|
931
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
932
|
+
/**
|
|
933
|
+
* Optional request information for telemetry and debugging purposes.
|
|
934
|
+
*/
|
|
935
|
+
request?: {
|
|
936
|
+
/**
|
|
937
|
+
* Request HTTP body that was sent to the provider API.
|
|
938
|
+
*/
|
|
939
|
+
body?: unknown;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* Optional response information for telemetry and debugging purposes.
|
|
943
|
+
*/
|
|
944
|
+
response?: LanguageModelV3ResponseMetadata & {
|
|
945
|
+
/**
|
|
946
|
+
* Response headers.
|
|
947
|
+
*/
|
|
948
|
+
headers?: SharedV3Headers;
|
|
949
|
+
/**
|
|
950
|
+
* Response HTTP body.
|
|
951
|
+
*/
|
|
952
|
+
body?: unknown;
|
|
953
|
+
};
|
|
954
|
+
/**
|
|
955
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
956
|
+
*/
|
|
957
|
+
warnings: Array<SharedV3Warning>;
|
|
958
|
+
};
|
|
959
|
+
type LanguageModelV3StreamPart = {
|
|
960
|
+
type: 'text-start';
|
|
961
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
962
|
+
id: string;
|
|
963
|
+
} | {
|
|
964
|
+
type: 'text-delta';
|
|
965
|
+
id: string;
|
|
966
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
967
|
+
delta: string;
|
|
968
|
+
} | {
|
|
969
|
+
type: 'text-end';
|
|
970
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
971
|
+
id: string;
|
|
972
|
+
} | {
|
|
973
|
+
type: 'reasoning-start';
|
|
974
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
975
|
+
id: string;
|
|
976
|
+
} | {
|
|
977
|
+
type: 'reasoning-delta';
|
|
978
|
+
id: string;
|
|
979
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
980
|
+
delta: string;
|
|
981
|
+
} | {
|
|
982
|
+
type: 'reasoning-end';
|
|
983
|
+
id: string;
|
|
984
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
985
|
+
} | {
|
|
986
|
+
type: 'tool-input-start';
|
|
987
|
+
id: string;
|
|
988
|
+
toolName: string;
|
|
989
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
990
|
+
providerExecuted?: boolean;
|
|
991
|
+
dynamic?: boolean;
|
|
992
|
+
title?: string;
|
|
993
|
+
} | {
|
|
994
|
+
type: 'tool-input-delta';
|
|
995
|
+
id: string;
|
|
996
|
+
delta: string;
|
|
997
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
998
|
+
} | {
|
|
999
|
+
type: 'tool-input-end';
|
|
1000
|
+
id: string;
|
|
1001
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
1002
|
+
} | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | {
|
|
1003
|
+
type: 'stream-start';
|
|
1004
|
+
warnings: Array<SharedV3Warning>;
|
|
1005
|
+
} | ({
|
|
1006
|
+
type: 'response-metadata';
|
|
1007
|
+
} & LanguageModelV3ResponseMetadata) | {
|
|
1008
|
+
type: 'finish';
|
|
1009
|
+
usage: LanguageModelV3Usage;
|
|
1010
|
+
finishReason: LanguageModelV3FinishReason;
|
|
1011
|
+
providerMetadata?: SharedV3ProviderMetadata;
|
|
1012
|
+
} | {
|
|
1013
|
+
type: 'raw';
|
|
1014
|
+
rawValue: unknown;
|
|
1015
|
+
} | {
|
|
1016
|
+
type: 'error';
|
|
1017
|
+
error: unknown;
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* The result of a language model doStream call.
|
|
1021
|
+
*/
|
|
1022
|
+
type LanguageModelV3StreamResult = {
|
|
1023
|
+
/**
|
|
1024
|
+
* The stream.
|
|
1025
|
+
*/
|
|
1026
|
+
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Optional request information for telemetry and debugging purposes.
|
|
1029
|
+
*/
|
|
1030
|
+
request?: {
|
|
1031
|
+
/**
|
|
1032
|
+
* Request HTTP body that was sent to the provider API.
|
|
1033
|
+
*/
|
|
1034
|
+
body?: unknown;
|
|
1035
|
+
};
|
|
1036
|
+
/**
|
|
1037
|
+
* Optional response data.
|
|
1038
|
+
*/
|
|
1039
|
+
response?: {
|
|
1040
|
+
/**
|
|
1041
|
+
* Response headers.
|
|
1042
|
+
*/
|
|
1043
|
+
headers?: SharedV3Headers;
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1046
|
+
/**
|
|
1047
|
+
* Specification for a language model that implements the language model interface version 3.
|
|
1048
|
+
*/
|
|
1049
|
+
type LanguageModelV3 = {
|
|
1050
|
+
/**
|
|
1051
|
+
* The language model must specify which language model interface version it implements.
|
|
1052
|
+
*/
|
|
1053
|
+
readonly specificationVersion: 'v3';
|
|
1054
|
+
/**
|
|
1055
|
+
* Provider ID.
|
|
1056
|
+
*/
|
|
1057
|
+
readonly provider: string;
|
|
1058
|
+
/**
|
|
1059
|
+
* Provider-specific model ID.
|
|
1060
|
+
*/
|
|
1061
|
+
readonly modelId: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Supported URL patterns by media type for the provider.
|
|
1064
|
+
*
|
|
1065
|
+
* The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
|
|
1066
|
+
* and the values are arrays of regular expressions that match the URL paths.
|
|
1067
|
+
*
|
|
1068
|
+
* The matching should be against lower-case URLs.
|
|
1069
|
+
*
|
|
1070
|
+
* Matched URLs are supported natively by the model and are not downloaded.
|
|
1071
|
+
*
|
|
1072
|
+
* @returns A map of supported URL patterns by media type (as a promise or a plain object).
|
|
1073
|
+
*/
|
|
1074
|
+
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Generates a language model output (non-streaming).
|
|
1077
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
1078
|
+
* by the user.
|
|
1079
|
+
*/
|
|
1080
|
+
doGenerate(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3GenerateResult>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Generates a language model output (streaming).
|
|
1083
|
+
*
|
|
1084
|
+
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
1085
|
+
* by the user.
|
|
1086
|
+
*
|
|
1087
|
+
* @return A stream of higher-level language model output parts.
|
|
1088
|
+
*/
|
|
1089
|
+
doStream(options: LanguageModelV3CallOptions): PromiseLike<LanguageModelV3StreamResult>;
|
|
1090
|
+
};
|
|
1091
|
+
/**
|
|
1092
|
+
* Experimental middleware for LanguageModelV3.
|
|
1093
|
+
* This type defines the structure for middleware that can be used to modify
|
|
1094
|
+
* the behavior of LanguageModelV3 operations.
|
|
1095
|
+
*/
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region src/types/model.d.ts
|
|
1098
|
+
interface ModelDefinition {
|
|
1099
|
+
modelId: string;
|
|
1100
|
+
name?: string;
|
|
1101
|
+
family?: string;
|
|
1102
|
+
type?: 'chat' | 'embedding' | 'image';
|
|
1103
|
+
reasoning?: boolean;
|
|
1104
|
+
tool_call?: boolean;
|
|
1105
|
+
structured_output?: boolean;
|
|
1106
|
+
temperature?: boolean;
|
|
1107
|
+
attachment?: boolean;
|
|
1108
|
+
streaming?: boolean;
|
|
1109
|
+
system_message?: boolean;
|
|
1110
|
+
modalities: {
|
|
1111
|
+
input: Array<'text' | 'image' | 'audio' | 'video' | 'pdf'>;
|
|
1112
|
+
output: Array<'text' | 'image' | 'audio'>;
|
|
1113
|
+
};
|
|
1114
|
+
limit: {
|
|
1115
|
+
context: number;
|
|
1116
|
+
output: number;
|
|
1117
|
+
input_images?: number;
|
|
1118
|
+
};
|
|
1119
|
+
cost?: {
|
|
1120
|
+
input: number;
|
|
1121
|
+
output: number;
|
|
1122
|
+
cache_read?: number;
|
|
1123
|
+
cache_write?: number;
|
|
1124
|
+
};
|
|
1125
|
+
status?: 'stable' | 'beta' | 'deprecated';
|
|
1126
|
+
knowledgeCutoff?: string;
|
|
1127
|
+
provenance?: 'snapshot' | 'remote' | 'user-override';
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/catalog/catalog.d.ts
|
|
1131
|
+
interface CatalogProvider {
|
|
1132
|
+
id: string;
|
|
1133
|
+
name: string;
|
|
1134
|
+
env?: string[];
|
|
1135
|
+
api?: string;
|
|
1136
|
+
doc?: string;
|
|
1137
|
+
bundledProvider?: string;
|
|
1138
|
+
baseURL?: string;
|
|
1139
|
+
headers?: Record<string, string>;
|
|
1140
|
+
options?: Record<string, unknown>;
|
|
1141
|
+
}
|
|
1142
|
+
interface ExtendModelConfig {
|
|
1143
|
+
name?: string;
|
|
1144
|
+
modalities?: {
|
|
1145
|
+
input: Array<'text' | 'image' | 'audio' | 'video' | 'pdf'>;
|
|
1146
|
+
output: Array<'text' | 'image' | 'audio'>;
|
|
1147
|
+
};
|
|
1148
|
+
limit?: {
|
|
1149
|
+
context: number;
|
|
1150
|
+
output: number;
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
interface ExtendProviderConfig {
|
|
1154
|
+
name: string;
|
|
1155
|
+
env?: string[];
|
|
1156
|
+
bundledProvider?: string;
|
|
1157
|
+
baseURL?: string;
|
|
1158
|
+
headers?: Record<string, string>;
|
|
1159
|
+
options?: Record<string, unknown>;
|
|
1160
|
+
models?: Record<string, ExtendModelConfig>;
|
|
1161
|
+
}
|
|
1162
|
+
interface ExtendConfig {
|
|
1163
|
+
providers?: Record<string, ExtendProviderConfig>;
|
|
1164
|
+
}
|
|
1165
|
+
//#endregion
|
|
1166
|
+
//#region src/types/provider.d.ts
|
|
1167
|
+
interface ProviderUserConfig {
|
|
1168
|
+
apiKey?: SecretRef;
|
|
1169
|
+
baseURL?: string;
|
|
1170
|
+
headers?: Record<string, string>;
|
|
1171
|
+
options?: Record<string, unknown>;
|
|
1172
|
+
}
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/provider/bundled.d.ts
|
|
1175
|
+
interface ProviderInstance {
|
|
1176
|
+
languageModel(modelId: string): LanguageModelV3;
|
|
1177
|
+
}
|
|
1178
|
+
type ProviderFactory = (options: Record<string, unknown>) => ProviderInstance;
|
|
1179
|
+
declare function loadProvider(packageName: string): Promise<ProviderFactory | undefined>;
|
|
1180
|
+
declare function isProviderInstalled(packageName: string): Promise<boolean>;
|
|
1181
|
+
declare function getAllProviderPackages(): string[];
|
|
1182
|
+
//#endregion
|
|
1183
|
+
//#region src/provider/index.d.ts
|
|
1184
|
+
interface ProviderStoreConfig {
|
|
1185
|
+
userConfig?: Record<string, ProviderUserConfig>;
|
|
1186
|
+
}
|
|
1187
|
+
interface ProviderListOptions {
|
|
1188
|
+
includeUnavailable?: boolean;
|
|
1189
|
+
}
|
|
1190
|
+
interface ModelListOptions {
|
|
1191
|
+
includeUnavailable?: boolean;
|
|
1192
|
+
}
|
|
1193
|
+
interface GetModelOptions {
|
|
1194
|
+
includeUnavailable?: boolean;
|
|
1195
|
+
}
|
|
1196
|
+
interface ProviderStore {
|
|
1197
|
+
getLanguageModel(providerId: string, modelId: string): Promise<LanguageModelV3>;
|
|
1198
|
+
extend(config: ExtendConfig): void;
|
|
1199
|
+
listProviders(options?: ProviderListOptions): Promise<CatalogProvider[]>;
|
|
1200
|
+
listModels(providerId?: string, options?: ModelListOptions): Promise<ModelDefinition[]>;
|
|
1201
|
+
getModel(providerId: string, modelId: string, options?: GetModelOptions): Promise<ModelDefinition | undefined>;
|
|
1202
|
+
}
|
|
1203
|
+
declare function createProviderStore(authStore: AuthStore, config?: ProviderStoreConfig): ProviderStore;
|
|
1204
|
+
declare function getLanguageModel(providerId: string, modelId: string, config?: ProviderStoreConfig): Promise<LanguageModelV3>;
|
|
1205
|
+
//#endregion
|
|
1206
|
+
//#region src/plugin/copilot.d.ts
|
|
1207
|
+
declare const copilotPlugin: AuthHook;
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/plugin/codex.d.ts
|
|
1210
|
+
/**
|
|
1211
|
+
* Built-in auth plugin for OpenAI Codex (OAuth).
|
|
1212
|
+
*
|
|
1213
|
+
* Only activates for OAuth credentials (`auth.type === 'oauth'`). API key
|
|
1214
|
+
* credentials fall through with an empty options object so the standard
|
|
1215
|
+
* OpenAI SDK path handles them.
|
|
1216
|
+
*
|
|
1217
|
+
* When active the plugin:
|
|
1218
|
+
* 1. Sets a dummy apiKey so the SDK doesn't reject construction
|
|
1219
|
+
* 2. Wraps fetch to auto-refresh expired tokens via refresh_token
|
|
1220
|
+
* 3. Injects `Authorization: Bearer <access_token>`
|
|
1221
|
+
* 4. Sets `ChatGPT-Account-Id` from stored accountId or JWT claims
|
|
1222
|
+
* 5. Rewrites `/v1/responses` and `/chat/completions` URLs to the Codex endpoint
|
|
1223
|
+
*/
|
|
1224
|
+
declare const codexPlugin: AuthHook;
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/plugin/google.d.ts
|
|
1227
|
+
declare const googlePlugin: AuthHook;
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/plugin/anthropic.d.ts
|
|
1230
|
+
declare const anthropicPlugin: AuthHook;
|
|
1231
|
+
//#endregion
|
|
1232
|
+
//#region src/types/index.d.ts
|
|
1233
|
+
type LanguageModel = LanguageModelV3;
|
|
1234
|
+
//#endregion
|
|
1235
|
+
//#region src/logger.d.ts
|
|
1236
|
+
declare function createLogger(namespace: string): createDebug.Debugger;
|
|
1237
|
+
//#endregion
|
|
1238
|
+
export { type AuthCredential, type AuthHook, type AuthMethod, type AuthStore, type AuthStoreOptions, type CatalogProvider, DEFAULT_SCANNERS, type DiscoverOptions, type DiscoveredCredential, type DiskScanResult, type DiskScanner, type ExtendConfig, type ExtendModelConfig, type ExtendProviderConfig, FileStorage, type GetModelOptions, type LanguageModel, type LanguageModelV3, MemoryStorage, type ModelDefinition, type ModelListOptions, type ProviderInfo, type ProviderListOptions, type ProviderStore, type ProviderStoreConfig, type ProviderUserConfig, type ScanContext, type SecretRef, type SecretResolver, type StorageAdapter, anthropicPlugin, codexPlugin, copilotPlugin, createAuthStore, createDefaultStorage, createLogger, createProviderStore, getAllProviderPackages, getLanguageModel, getPluginForProvider, getPlugins, googlePlugin, isProviderInstalled, loadProvider, registerPlugin };
|
|
1239
|
+
//# sourceMappingURL=index.d.cts.map
|