@mastra/schema-compat 1.4.1-alpha.0 → 1.4.2-alpha.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/dist/_types/{@internal_ai-v6@0.0.98 → @internal_ai-v6@0.0.99}/dist/index.d.ts +2075 -123
- package/dist/json-schema.d.ts +2 -2
- package/dist/json-to-zod.cjs +6 -1
- package/dist/json-to-zod.js +6 -1
- package/dist/provider-compats/anthropic.d.ts +1 -1
- package/dist/provider-compats/deepseek.d.ts +1 -1
- package/dist/provider-compats/meta.d.ts +1 -1
- package/dist/schema.types.d.ts +3 -3
- package/dist/standard-schema/adapters/ai-sdk.d.ts +1 -1
- package/package.json +8 -8
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.98 → @internal_ai-sdk-v4@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.98 → @internal_ai-sdk-v4@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_ai-sdk-v5@0.0.98 → @internal_ai-sdk-v5@0.0.99}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_ai-sdk-v5@0.0.98 → @internal_ai-sdk-v5@0.0.99}/package.json +0 -0
- /package/dist/_types/{@internal_ai-v6@0.0.98 → @internal_ai-v6@0.0.99}/package.json +0 -0
|
@@ -237,26 +237,26 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
237
237
|
export {
|
|
238
238
|
EventSourceMessage,
|
|
239
239
|
EventSourceParserStream,
|
|
240
|
-
AssistantContent,
|
|
241
|
-
AssistantModelMessage,
|
|
240
|
+
AssistantContent_2 as AssistantContent,
|
|
241
|
+
AssistantModelMessage_2 as AssistantModelMessage,
|
|
242
242
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
243
|
-
DataContent,
|
|
243
|
+
DataContent_2 as DataContent,
|
|
244
244
|
DelayedPromise,
|
|
245
|
-
DownloadError,
|
|
245
|
+
DownloadError_2 as DownloadError,
|
|
246
246
|
EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
|
|
247
247
|
EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
248
248
|
EmbeddingModelProviderOptionsTransformer,
|
|
249
249
|
FetchFunction,
|
|
250
|
-
FilePart,
|
|
251
|
-
FlexibleSchema,
|
|
252
|
-
IdGenerator,
|
|
253
|
-
ImagePart,
|
|
254
|
-
InferSchema,
|
|
255
|
-
InferToolInput,
|
|
256
|
-
InferToolOutput,
|
|
250
|
+
FilePart_2 as FilePart,
|
|
251
|
+
FlexibleSchema_2 as FlexibleSchema,
|
|
252
|
+
IdGenerator_2 as IdGenerator,
|
|
253
|
+
ImagePart_2 as ImagePart,
|
|
254
|
+
InferSchema_2 as InferSchema,
|
|
255
|
+
InferToolInput_2 as InferToolInput,
|
|
256
|
+
InferToolOutput_2 as InferToolOutput,
|
|
257
257
|
LazySchema,
|
|
258
258
|
MaybePromiseLike,
|
|
259
|
-
ModelMessage,
|
|
259
|
+
ModelMessage_2 as ModelMessage,
|
|
260
260
|
ParseResult,
|
|
261
261
|
ProviderOptions,
|
|
262
262
|
ProviderToolFactory,
|
|
@@ -268,33 +268,33 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
268
268
|
RetryErrorFactory,
|
|
269
269
|
RetryErrorReason,
|
|
270
270
|
RetryFunction,
|
|
271
|
-
Schema,
|
|
271
|
+
Schema_2 as Schema,
|
|
272
272
|
ShouldRetryFunction,
|
|
273
273
|
StreamingToolCallDelta,
|
|
274
274
|
StreamingToolCallTracker,
|
|
275
275
|
StreamingToolCallTrackerOptions,
|
|
276
|
-
SystemModelMessage,
|
|
277
|
-
TextPart,
|
|
278
|
-
Tool,
|
|
279
|
-
ToolApprovalRequest,
|
|
280
|
-
ToolApprovalResponse,
|
|
276
|
+
SystemModelMessage_2 as SystemModelMessage,
|
|
277
|
+
TextPart_2 as TextPart,
|
|
278
|
+
Tool_2 as Tool,
|
|
279
|
+
ToolApprovalRequest_2 as ToolApprovalRequest,
|
|
280
|
+
ToolApprovalResponse_2 as ToolApprovalResponse,
|
|
281
281
|
ToolCall,
|
|
282
|
-
ToolCallOptions,
|
|
283
|
-
ToolCallPart,
|
|
284
|
-
ToolContent,
|
|
285
|
-
ToolExecuteFunction,
|
|
286
|
-
ToolExecutionOptions,
|
|
287
|
-
ToolModelMessage,
|
|
282
|
+
ToolCallOptions_2 as ToolCallOptions,
|
|
283
|
+
ToolCallPart_2 as ToolCallPart,
|
|
284
|
+
ToolContent_2 as ToolContent,
|
|
285
|
+
ToolExecuteFunction_2 as ToolExecuteFunction,
|
|
286
|
+
ToolExecutionOptions_2 as ToolExecutionOptions,
|
|
287
|
+
ToolModelMessage_2 as ToolModelMessage,
|
|
288
288
|
ToolNameMapping,
|
|
289
289
|
ToolNeedsApprovalFunction,
|
|
290
290
|
ToolResult,
|
|
291
291
|
ToolResultOutput,
|
|
292
|
-
ToolResultPart,
|
|
293
|
-
UserContent,
|
|
294
|
-
UserModelMessage,
|
|
292
|
+
ToolResultPart_2 as ToolResultPart,
|
|
293
|
+
UserContent_2 as UserContent,
|
|
294
|
+
UserModelMessage_2 as UserModelMessage,
|
|
295
295
|
VERSION,
|
|
296
296
|
ValidationResult,
|
|
297
|
-
asSchema,
|
|
297
|
+
asSchema_2 as asSchema,
|
|
298
298
|
cancelResponseBody,
|
|
299
299
|
combineHeaders,
|
|
300
300
|
convertAsyncIteratorToReadableStream,
|
|
@@ -305,7 +305,7 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
305
305
|
convertUint8ArrayToBase64,
|
|
306
306
|
createBinaryResponseHandler,
|
|
307
307
|
createEventSourceResponseHandler,
|
|
308
|
-
createIdGenerator,
|
|
308
|
+
createIdGenerator_2 as createIdGenerator,
|
|
309
309
|
createJsonErrorResponseHandler,
|
|
310
310
|
createJsonResponseHandler,
|
|
311
311
|
createProviderToolFactory,
|
|
@@ -314,13 +314,13 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
314
314
|
createToolNameMapping,
|
|
315
315
|
delay,
|
|
316
316
|
downloadBlob,
|
|
317
|
-
dynamicTool,
|
|
317
|
+
dynamicTool_2 as dynamicTool,
|
|
318
318
|
encodePathSegment,
|
|
319
319
|
executeTool,
|
|
320
320
|
extractResponseHeaders,
|
|
321
321
|
fetchWithValidatedEndpoint,
|
|
322
322
|
fetchWithValidatedRedirects,
|
|
323
|
-
generateId,
|
|
323
|
+
generateId_2 as generateId,
|
|
324
324
|
getErrorMessage,
|
|
325
325
|
getFromApi,
|
|
326
326
|
getRuntimeEnvironmentUserAgent,
|
|
@@ -333,7 +333,7 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
333
333
|
isSameOrigin,
|
|
334
334
|
isUint8Array,
|
|
335
335
|
isUrlSupported,
|
|
336
|
-
jsonSchema,
|
|
336
|
+
jsonSchema_2 as jsonSchema,
|
|
337
337
|
lazySchema,
|
|
338
338
|
loadApiKey,
|
|
339
339
|
loadOptionalSetting,
|
|
@@ -341,7 +341,7 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
341
341
|
mediaTypeToExtension,
|
|
342
342
|
normalizeHeaders,
|
|
343
343
|
parseJSON,
|
|
344
|
-
parseJsonEventStream,
|
|
344
|
+
parseJsonEventStream_2 as parseJsonEventStream,
|
|
345
345
|
parseProviderOptions,
|
|
346
346
|
postFormDataToApi,
|
|
347
347
|
postJsonToApi,
|
|
@@ -355,11 +355,145 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
355
355
|
secureJsonParse,
|
|
356
356
|
stringifyWithBigIntAndCycles,
|
|
357
357
|
stripFileExtension,
|
|
358
|
-
tool,
|
|
358
|
+
tool_2 as tool,
|
|
359
359
|
validateDownloadUrl,
|
|
360
360
|
validateTypes,
|
|
361
361
|
withUserAgentSuffix,
|
|
362
362
|
withoutTrailingSlash,
|
|
363
|
+
zodSchema_2 as zodSchema,
|
|
364
|
+
StandardJSONSchemaV1,
|
|
365
|
+
StandardSchemaV1,
|
|
366
|
+
StandardTypedV1
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare namespace _ai_sdk_provider_utils_2 {
|
|
371
|
+
export {
|
|
372
|
+
EventSourceMessage,
|
|
373
|
+
EventSourceParserStream,
|
|
374
|
+
AssistantContent,
|
|
375
|
+
AssistantModelMessage,
|
|
376
|
+
DEFAULT_MAX_DOWNLOAD_SIZE_2 as DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
377
|
+
DataContent,
|
|
378
|
+
DelayedPromise_2 as DelayedPromise,
|
|
379
|
+
DownloadError,
|
|
380
|
+
EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL_2 as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
|
|
381
|
+
EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER_2 as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
382
|
+
EmbeddingModelProviderOptionsTransformer_2 as EmbeddingModelProviderOptionsTransformer,
|
|
383
|
+
FetchFunction_2 as FetchFunction,
|
|
384
|
+
FilePart,
|
|
385
|
+
FlexibleSchema,
|
|
386
|
+
IdGenerator,
|
|
387
|
+
ImagePart,
|
|
388
|
+
InferSchema,
|
|
389
|
+
InferToolInput,
|
|
390
|
+
InferToolOutput,
|
|
391
|
+
LazySchema_2 as LazySchema,
|
|
392
|
+
MaybePromiseLike_2 as MaybePromiseLike,
|
|
393
|
+
ModelMessage,
|
|
394
|
+
ParseResult_2 as ParseResult,
|
|
395
|
+
ProviderOptions_2 as ProviderOptions,
|
|
396
|
+
ProviderToolFactory_2 as ProviderToolFactory,
|
|
397
|
+
ProviderToolFactoryWithOutputSchema_2 as ProviderToolFactoryWithOutputSchema,
|
|
398
|
+
ReasoningPart_2 as ReasoningPart,
|
|
399
|
+
Resolvable_2 as Resolvable,
|
|
400
|
+
ResponseHandler_2 as ResponseHandler,
|
|
401
|
+
RetryDelayProvider_2 as RetryDelayProvider,
|
|
402
|
+
RetryErrorFactory_2 as RetryErrorFactory,
|
|
403
|
+
RetryErrorReason_3 as RetryErrorReason,
|
|
404
|
+
RetryFunction_2 as RetryFunction,
|
|
405
|
+
Schema,
|
|
406
|
+
ShouldRetryFunction_2 as ShouldRetryFunction,
|
|
407
|
+
StreamingToolCallDelta_2 as StreamingToolCallDelta,
|
|
408
|
+
StreamingToolCallTracker_2 as StreamingToolCallTracker,
|
|
409
|
+
StreamingToolCallTrackerOptions_2 as StreamingToolCallTrackerOptions,
|
|
410
|
+
SystemModelMessage,
|
|
411
|
+
TextPart,
|
|
412
|
+
Tool,
|
|
413
|
+
ToolApprovalRequest,
|
|
414
|
+
ToolApprovalResponse,
|
|
415
|
+
ToolCall_2 as ToolCall,
|
|
416
|
+
ToolCallOptions,
|
|
417
|
+
ToolCallPart,
|
|
418
|
+
ToolContent,
|
|
419
|
+
ToolExecuteFunction,
|
|
420
|
+
ToolExecutionOptions,
|
|
421
|
+
ToolModelMessage,
|
|
422
|
+
ToolNameMapping_2 as ToolNameMapping,
|
|
423
|
+
ToolNeedsApprovalFunction_2 as ToolNeedsApprovalFunction,
|
|
424
|
+
ToolResult_2 as ToolResult,
|
|
425
|
+
ToolResultOutput_2 as ToolResultOutput,
|
|
426
|
+
ToolResultPart,
|
|
427
|
+
UserContent,
|
|
428
|
+
UserModelMessage,
|
|
429
|
+
VERSION_2 as VERSION,
|
|
430
|
+
ValidationResult_2 as ValidationResult,
|
|
431
|
+
asSchema,
|
|
432
|
+
cancelResponseBody_2 as cancelResponseBody,
|
|
433
|
+
combineHeaders_2 as combineHeaders,
|
|
434
|
+
convertAsyncIteratorToReadableStream_2 as convertAsyncIteratorToReadableStream,
|
|
435
|
+
convertBase64ToUint8Array_2 as convertBase64ToUint8Array,
|
|
436
|
+
convertImageModelFileToDataUri_2 as convertImageModelFileToDataUri,
|
|
437
|
+
convertToBase64_2 as convertToBase64,
|
|
438
|
+
convertToFormData_2 as convertToFormData,
|
|
439
|
+
convertUint8ArrayToBase64_2 as convertUint8ArrayToBase64,
|
|
440
|
+
createBinaryResponseHandler_2 as createBinaryResponseHandler,
|
|
441
|
+
createEventSourceResponseHandler_2 as createEventSourceResponseHandler,
|
|
442
|
+
createIdGenerator,
|
|
443
|
+
createJsonErrorResponseHandler_2 as createJsonErrorResponseHandler,
|
|
444
|
+
createJsonResponseHandler_2 as createJsonResponseHandler,
|
|
445
|
+
createProviderToolFactory_2 as createProviderToolFactory,
|
|
446
|
+
createProviderToolFactoryWithOutputSchema_2 as createProviderToolFactoryWithOutputSchema,
|
|
447
|
+
createStatusCodeErrorResponseHandler_2 as createStatusCodeErrorResponseHandler,
|
|
448
|
+
createToolNameMapping_2 as createToolNameMapping,
|
|
449
|
+
delay_2 as delay,
|
|
450
|
+
downloadBlob_2 as downloadBlob,
|
|
451
|
+
dynamicTool,
|
|
452
|
+
encodePathSegment_2 as encodePathSegment,
|
|
453
|
+
executeTool_2 as executeTool,
|
|
454
|
+
extractResponseHeaders_2 as extractResponseHeaders,
|
|
455
|
+
fetchWithValidatedEndpoint_2 as fetchWithValidatedEndpoint,
|
|
456
|
+
fetchWithValidatedRedirects_2 as fetchWithValidatedRedirects,
|
|
457
|
+
generateId,
|
|
458
|
+
getErrorMessage_2 as getErrorMessage,
|
|
459
|
+
getFromApi_2 as getFromApi,
|
|
460
|
+
getRuntimeEnvironmentUserAgent_2 as getRuntimeEnvironmentUserAgent,
|
|
461
|
+
injectJsonInstructionIntoMessages_2 as injectJsonInstructionIntoMessages,
|
|
462
|
+
isAbortError_2 as isAbortError,
|
|
463
|
+
isArrayBuffer_2 as isArrayBuffer,
|
|
464
|
+
isBrowserRuntime_2 as isBrowserRuntime,
|
|
465
|
+
isNonNullable_2 as isNonNullable,
|
|
466
|
+
isParsableJson_2 as isParsableJson,
|
|
467
|
+
isSameOrigin_2 as isSameOrigin,
|
|
468
|
+
isUint8Array_2 as isUint8Array,
|
|
469
|
+
isUrlSupported_2 as isUrlSupported,
|
|
470
|
+
jsonSchema,
|
|
471
|
+
lazySchema_2 as lazySchema,
|
|
472
|
+
loadApiKey_2 as loadApiKey,
|
|
473
|
+
loadOptionalSetting_2 as loadOptionalSetting,
|
|
474
|
+
loadSetting_2 as loadSetting,
|
|
475
|
+
mediaTypeToExtension_2 as mediaTypeToExtension,
|
|
476
|
+
normalizeHeaders_2 as normalizeHeaders,
|
|
477
|
+
parseJSON_2 as parseJSON,
|
|
478
|
+
parseJsonEventStream,
|
|
479
|
+
parseProviderOptions_2 as parseProviderOptions,
|
|
480
|
+
postFormDataToApi_2 as postFormDataToApi,
|
|
481
|
+
postJsonToApi_2 as postJsonToApi,
|
|
482
|
+
postToApi_2 as postToApi,
|
|
483
|
+
readResponseWithSizeLimit_2 as readResponseWithSizeLimit,
|
|
484
|
+
removeUndefinedEntries_2 as removeUndefinedEntries,
|
|
485
|
+
resolve_2 as resolve,
|
|
486
|
+
retryWithExponentialBackoff_2 as retryWithExponentialBackoff,
|
|
487
|
+
safeParseJSON_2 as safeParseJSON,
|
|
488
|
+
safeValidateTypes_2 as safeValidateTypes,
|
|
489
|
+
secureJsonParse_2 as secureJsonParse,
|
|
490
|
+
stringifyWithBigIntAndCycles_2 as stringifyWithBigIntAndCycles,
|
|
491
|
+
stripFileExtension_2 as stripFileExtension,
|
|
492
|
+
tool,
|
|
493
|
+
validateDownloadUrl_2 as validateDownloadUrl,
|
|
494
|
+
validateTypes_2 as validateTypes,
|
|
495
|
+
withUserAgentSuffix_2 as withUserAgentSuffix,
|
|
496
|
+
withoutTrailingSlash_2 as withoutTrailingSlash,
|
|
363
497
|
zodSchema,
|
|
364
498
|
StandardJSONSchemaV1,
|
|
365
499
|
StandardSchemaV1,
|
|
@@ -455,11 +589,19 @@ export declare class APICallError extends AISDKError {
|
|
|
455
589
|
|
|
456
590
|
export declare function asSchema<OBJECT>(schema: FlexibleSchema<OBJECT> | undefined): Schema<OBJECT>;
|
|
457
591
|
|
|
592
|
+
declare function asSchema_2<OBJECT>(schema: FlexibleSchema_2<OBJECT> | undefined): Schema_2<OBJECT>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Content of an assistant message.
|
|
596
|
+
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
|
597
|
+
*/
|
|
598
|
+
export declare type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart_2 | ToolCallPart | ToolResultPart | ToolApprovalRequest>;
|
|
599
|
+
|
|
458
600
|
/**
|
|
459
601
|
* Content of an assistant message.
|
|
460
602
|
* It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
|
461
603
|
*/
|
|
462
|
-
|
|
604
|
+
declare type AssistantContent_2 = string | Array<TextPart_2 | FilePart_2 | ReasoningPart | ToolCallPart_2 | ToolResultPart_2 | ToolApprovalRequest_2>;
|
|
463
605
|
|
|
464
606
|
/**
|
|
465
607
|
* An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
|
|
@@ -467,6 +609,20 @@ export declare type AssistantContent = string | Array<TextPart | FilePart | Reas
|
|
|
467
609
|
export declare type AssistantModelMessage = {
|
|
468
610
|
role: 'assistant';
|
|
469
611
|
content: AssistantContent;
|
|
612
|
+
/**
|
|
613
|
+
* Additional provider-specific metadata. They are passed through
|
|
614
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
615
|
+
* functionality that can be fully encapsulated in the provider.
|
|
616
|
+
*/
|
|
617
|
+
providerOptions?: ProviderOptions_2;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
|
|
622
|
+
*/
|
|
623
|
+
declare type AssistantModelMessage_2 = {
|
|
624
|
+
role: 'assistant';
|
|
625
|
+
content: AssistantContent_2;
|
|
470
626
|
/**
|
|
471
627
|
* Additional provider-specific metadata. They are passed through
|
|
472
628
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -758,6 +914,20 @@ export declare type CallWarning = SharedV3Warning;
|
|
|
758
914
|
*/
|
|
759
915
|
declare function cancelResponseBody(response: Response): Promise<void>;
|
|
760
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Cancels a response body to release the underlying connection.
|
|
919
|
+
*
|
|
920
|
+
* When a fetch Response is rejected without consuming its body (e.g. a failed
|
|
921
|
+
* status code, an open-redirect rejection, or a Content-Length that exceeds the
|
|
922
|
+
* size limit), the underlying TCP socket is not returned to the connection pool
|
|
923
|
+
* and may stay open until the process runs out of file descriptors. Cancelling
|
|
924
|
+
* the body avoids this leak.
|
|
925
|
+
*
|
|
926
|
+
* Errors thrown while cancelling are ignored: the body may already be locked,
|
|
927
|
+
* disturbed, or absent, none of which should mask the original rejection.
|
|
928
|
+
*/
|
|
929
|
+
declare function cancelResponseBody_2(response: Response): Promise<void>;
|
|
930
|
+
|
|
761
931
|
/**
|
|
762
932
|
* Function that can be called to add a tool approval response to the chat.
|
|
763
933
|
*/
|
|
@@ -996,6 +1166,8 @@ export declare type ChunkDetector = (buffer: string) => string | undefined | nul
|
|
|
996
1166
|
|
|
997
1167
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
|
998
1168
|
|
|
1169
|
+
declare function combineHeaders_2(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
|
1170
|
+
|
|
999
1171
|
export declare type CompletionRequestOptions = {
|
|
1000
1172
|
/**
|
|
1001
1173
|
* An optional object of headers to be passed to the API endpoint.
|
|
@@ -1089,8 +1261,19 @@ declare interface Context {
|
|
|
1089
1261
|
*/
|
|
1090
1262
|
declare function convertAsyncIteratorToReadableStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
1091
1263
|
|
|
1264
|
+
/**
|
|
1265
|
+
* Converts an AsyncIterator to a ReadableStream.
|
|
1266
|
+
*
|
|
1267
|
+
* @template T - The type of elements produced by the AsyncIterator.
|
|
1268
|
+
* @param { <T>} iterator - The AsyncIterator to convert.
|
|
1269
|
+
* @returns {ReadableStream<T>} - A ReadableStream that provides the same data as the AsyncIterator.
|
|
1270
|
+
*/
|
|
1271
|
+
declare function convertAsyncIteratorToReadableStream_2<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
1272
|
+
|
|
1092
1273
|
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
1093
1274
|
|
|
1275
|
+
declare function convertBase64ToUint8Array_2(base64String: string): Uint8Array<ArrayBuffer>;
|
|
1276
|
+
|
|
1094
1277
|
export declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
|
1095
1278
|
|
|
1096
1279
|
/**
|
|
@@ -1102,8 +1285,19 @@ export declare function convertFileListToFileUIParts(files: FileList | undefined
|
|
|
1102
1285
|
*/
|
|
1103
1286
|
declare function convertImageModelFileToDataUri(file: ImageModelV3File): string;
|
|
1104
1287
|
|
|
1288
|
+
/**
|
|
1289
|
+
* Convert an ImageModelV3File to a URL or data URI string.
|
|
1290
|
+
*
|
|
1291
|
+
* If the file is a URL, it returns the URL as-is.
|
|
1292
|
+
* If the file is base64 data, it returns a data URI with the base64 data.
|
|
1293
|
+
* If the file is a Uint8Array, it converts it to base64 and returns a data URI.
|
|
1294
|
+
*/
|
|
1295
|
+
declare function convertImageModelFileToDataUri_2(file: ImageModelV3File): string;
|
|
1296
|
+
|
|
1105
1297
|
declare function convertToBase64(value: string | Uint8Array): string;
|
|
1106
1298
|
|
|
1299
|
+
declare function convertToBase64_2(value: string | Uint8Array): string;
|
|
1300
|
+
|
|
1107
1301
|
/**
|
|
1108
1302
|
* Converts an input object to FormData for multipart/form-data requests.
|
|
1109
1303
|
*
|
|
@@ -1139,6 +1333,41 @@ declare function convertToFormData<T extends Record<string, unknown>>(input: T,
|
|
|
1139
1333
|
useArrayBrackets?: boolean;
|
|
1140
1334
|
}): FormData;
|
|
1141
1335
|
|
|
1336
|
+
/**
|
|
1337
|
+
* Converts an input object to FormData for multipart/form-data requests.
|
|
1338
|
+
*
|
|
1339
|
+
* Handles the following cases:
|
|
1340
|
+
* - `null` or `undefined` values are skipped
|
|
1341
|
+
* - Arrays with a single element are appended as a single value
|
|
1342
|
+
* - Arrays with multiple elements are appended with `[]` suffix (e.g., `image[]`)
|
|
1343
|
+
* unless `useArrayBrackets` is set to `false`
|
|
1344
|
+
* - All other values are appended directly
|
|
1345
|
+
*
|
|
1346
|
+
* @param input - The input object to convert. Use a generic type for type validation.
|
|
1347
|
+
* @param options - Optional configuration object.
|
|
1348
|
+
* @param options.useArrayBrackets - Whether to add `[]` suffix for multi-element arrays.
|
|
1349
|
+
* Defaults to `true`. Set to `false` for APIs that expect repeated keys without brackets.
|
|
1350
|
+
* @returns A FormData object containing the input values.
|
|
1351
|
+
*
|
|
1352
|
+
* @example
|
|
1353
|
+
* ```ts
|
|
1354
|
+
* type MyInput = {
|
|
1355
|
+
* model: string;
|
|
1356
|
+
* prompt: string;
|
|
1357
|
+
* images: Blob[];
|
|
1358
|
+
* };
|
|
1359
|
+
*
|
|
1360
|
+
* const formData = convertToFormData<MyInput>({
|
|
1361
|
+
* model: 'gpt-image-1',
|
|
1362
|
+
* prompt: 'A cat',
|
|
1363
|
+
* images: [blob1, blob2],
|
|
1364
|
+
* });
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
declare function convertToFormData_2<T extends Record<string, unknown>>(input: T, options?: {
|
|
1368
|
+
useArrayBrackets?: boolean;
|
|
1369
|
+
}): FormData;
|
|
1370
|
+
|
|
1142
1371
|
/**
|
|
1143
1372
|
* Converts an array of UI messages from useChat into an array of ModelMessages that can be used
|
|
1144
1373
|
* with the AI functions (e.g. `streamText`, `generateText`).
|
|
@@ -1158,6 +1387,8 @@ export declare function convertToModelMessages<UI_MESSAGE extends UIMessage>(mes
|
|
|
1158
1387
|
|
|
1159
1388
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
|
1160
1389
|
|
|
1390
|
+
declare function convertUint8ArrayToBase64_2(array: Uint8Array): string;
|
|
1391
|
+
|
|
1161
1392
|
/**
|
|
1162
1393
|
* Calculates the cosine similarity between two vectors. This is a useful metric for
|
|
1163
1394
|
* comparing the similarity of two vectors such as embeddings.
|
|
@@ -1224,6 +1455,8 @@ export declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS
|
|
|
1224
1455
|
|
|
1225
1456
|
declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
|
|
1226
1457
|
|
|
1458
|
+
declare const createBinaryResponseHandler_2: () => ResponseHandler_2<Uint8Array>;
|
|
1459
|
+
|
|
1227
1460
|
/**
|
|
1228
1461
|
* Creates a download function with configurable options.
|
|
1229
1462
|
*
|
|
@@ -1241,7 +1474,9 @@ export declare function createDownload(options?: {
|
|
|
1241
1474
|
mediaType: string | undefined;
|
|
1242
1475
|
}>;
|
|
1243
1476
|
|
|
1244
|
-
declare const createEventSourceResponseHandler: <T>(chunkSchema:
|
|
1477
|
+
declare const createEventSourceResponseHandler: <T>(chunkSchema: FlexibleSchema_2<T>) => ResponseHandler<ReadableStream<ParseResult<T>>>;
|
|
1478
|
+
|
|
1479
|
+
declare const createEventSourceResponseHandler_2: <T>(chunkSchema: FlexibleSchema<T>) => ResponseHandler_2<ReadableStream<ParseResult_2<T>>>;
|
|
1245
1480
|
|
|
1246
1481
|
/**
|
|
1247
1482
|
* Create a remote provider instance.
|
|
@@ -1265,13 +1500,38 @@ export declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?
|
|
|
1265
1500
|
alphabet?: string;
|
|
1266
1501
|
}) => IdGenerator;
|
|
1267
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Creates an ID generator.
|
|
1505
|
+
* The total length of the ID is the sum of the prefix, separator, and random part length.
|
|
1506
|
+
* Not cryptographically secure.
|
|
1507
|
+
*
|
|
1508
|
+
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
|
|
1509
|
+
* @param prefix - The prefix of the ID to generate. Optional.
|
|
1510
|
+
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
|
|
1511
|
+
* @param size - The size of the random part of the ID to generate. Default: 16.
|
|
1512
|
+
*/
|
|
1513
|
+
declare const createIdGenerator_2: ({ prefix, size, alphabet, separator, }?: {
|
|
1514
|
+
prefix?: string;
|
|
1515
|
+
separator?: string;
|
|
1516
|
+
size?: number;
|
|
1517
|
+
alphabet?: string;
|
|
1518
|
+
}) => IdGenerator_2;
|
|
1519
|
+
|
|
1268
1520
|
declare const createJsonErrorResponseHandler: <T>({ errorSchema, errorToMessage, isRetryable, }: {
|
|
1269
|
-
errorSchema:
|
|
1521
|
+
errorSchema: FlexibleSchema_2<T>;
|
|
1270
1522
|
errorToMessage: (error: T) => string;
|
|
1271
1523
|
isRetryable?: (response: Response, error?: T) => boolean;
|
|
1272
1524
|
}) => ResponseHandler<APICallError>;
|
|
1273
1525
|
|
|
1274
|
-
declare const
|
|
1526
|
+
declare const createJsonErrorResponseHandler_2: <T>({ errorSchema, errorToMessage, isRetryable, }: {
|
|
1527
|
+
errorSchema: FlexibleSchema<T>;
|
|
1528
|
+
errorToMessage: (error: T) => string;
|
|
1529
|
+
isRetryable?: (response: Response, error?: T) => boolean;
|
|
1530
|
+
}) => ResponseHandler_2<APICallError>;
|
|
1531
|
+
|
|
1532
|
+
declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema_2<T>) => ResponseHandler<T>;
|
|
1533
|
+
|
|
1534
|
+
declare const createJsonResponseHandler_2: <T>(responseSchema: FlexibleSchema<T>) => ResponseHandler_2<T>;
|
|
1275
1535
|
|
|
1276
1536
|
/**
|
|
1277
1537
|
* Creates a registry for the given providers with optional middleware functionality.
|
|
@@ -1294,10 +1554,32 @@ export declare function createProviderRegistry<PROVIDERS extends Record<string,
|
|
|
1294
1554
|
|
|
1295
1555
|
declare function createProviderToolFactory<INPUT, ARGS extends object>({ id, inputSchema, }: {
|
|
1296
1556
|
id: `${string}.${string}`;
|
|
1297
|
-
inputSchema:
|
|
1557
|
+
inputSchema: FlexibleSchema_2<INPUT>;
|
|
1298
1558
|
}): ProviderToolFactory<INPUT, ARGS>;
|
|
1299
1559
|
|
|
1560
|
+
declare function createProviderToolFactory_2<INPUT, ARGS extends object>({ id, inputSchema, }: {
|
|
1561
|
+
id: `${string}.${string}`;
|
|
1562
|
+
inputSchema: FlexibleSchema<INPUT>;
|
|
1563
|
+
}): ProviderToolFactory_2<INPUT, ARGS>;
|
|
1564
|
+
|
|
1300
1565
|
declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, supportsDeferredResults, }: {
|
|
1566
|
+
id: `${string}.${string}`;
|
|
1567
|
+
inputSchema: FlexibleSchema_2<INPUT>;
|
|
1568
|
+
outputSchema: FlexibleSchema_2<OUTPUT>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Whether this provider-executed tool supports deferred results.
|
|
1571
|
+
*
|
|
1572
|
+
* When true, the tool result may not be returned in the same turn as the
|
|
1573
|
+
* tool call (e.g., when using programmatic tool calling where a server tool
|
|
1574
|
+
* triggers a client-executed tool, and the server tool's result is deferred
|
|
1575
|
+
* until the client tool is resolved).
|
|
1576
|
+
*
|
|
1577
|
+
* @default false
|
|
1578
|
+
*/
|
|
1579
|
+
supportsDeferredResults?: boolean;
|
|
1580
|
+
}): ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS>;
|
|
1581
|
+
|
|
1582
|
+
declare function createProviderToolFactoryWithOutputSchema_2<INPUT, OUTPUT, ARGS extends object>({ id, inputSchema, outputSchema, supportsDeferredResults, }: {
|
|
1301
1583
|
id: `${string}.${string}`;
|
|
1302
1584
|
inputSchema: FlexibleSchema<INPUT>;
|
|
1303
1585
|
outputSchema: FlexibleSchema<OUTPUT>;
|
|
@@ -1312,10 +1594,12 @@ declare function createProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS e
|
|
|
1312
1594
|
* @default false
|
|
1313
1595
|
*/
|
|
1314
1596
|
supportsDeferredResults?: boolean;
|
|
1315
|
-
}):
|
|
1597
|
+
}): ProviderToolFactoryWithOutputSchema_2<INPUT, OUTPUT, ARGS>;
|
|
1316
1598
|
|
|
1317
1599
|
declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
|
|
1318
1600
|
|
|
1601
|
+
declare const createStatusCodeErrorResponseHandler_2: () => ResponseHandler_2<APICallError>;
|
|
1602
|
+
|
|
1319
1603
|
/**
|
|
1320
1604
|
* Creates a Response object from a text stream.
|
|
1321
1605
|
* Each text chunk is encoded as UTF-8 and sent as a separate chunk.
|
|
@@ -1352,6 +1636,26 @@ declare function createToolNameMapping({ tools, providerToolNames, resolveProvid
|
|
|
1352
1636
|
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
|
|
1353
1637
|
}): ToolNameMapping;
|
|
1354
1638
|
|
|
1639
|
+
/**
|
|
1640
|
+
* @param tools - Tools that were passed to the language model.
|
|
1641
|
+
* @param providerToolNames - Maps the provider tool ids to the provider tool names.
|
|
1642
|
+
*/
|
|
1643
|
+
declare function createToolNameMapping_2({ tools, providerToolNames, resolveProviderToolName, }: {
|
|
1644
|
+
/**
|
|
1645
|
+
* Tools that were passed to the language model.
|
|
1646
|
+
*/
|
|
1647
|
+
tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined;
|
|
1648
|
+
/**
|
|
1649
|
+
* Maps the provider tool ids to the provider tool names.
|
|
1650
|
+
*/
|
|
1651
|
+
providerToolNames: Record<`${string}.${string}`, string>;
|
|
1652
|
+
/**
|
|
1653
|
+
* Optional resolver for provider tool names that cannot be represented as
|
|
1654
|
+
* static id -> name mappings (e.g. dynamic provider names).
|
|
1655
|
+
*/
|
|
1656
|
+
resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
|
|
1657
|
+
}): ToolNameMapping_2;
|
|
1658
|
+
|
|
1355
1659
|
export declare type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
|
1356
1660
|
id?: UI_MESSAGE['id'];
|
|
1357
1661
|
role?: UI_MESSAGE['role'];
|
|
@@ -1445,6 +1749,11 @@ export declare function customProvider<LANGUAGE_MODELS extends Record<string, La
|
|
|
1445
1749
|
*/
|
|
1446
1750
|
export declare type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
1447
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
1754
|
+
*/
|
|
1755
|
+
declare type DataContent_2 = string | Uint8Array | ArrayBuffer | Buffer;
|
|
1756
|
+
|
|
1448
1757
|
declare type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
|
1449
1758
|
[NAME in keyof DATA_TYPES & string]: {
|
|
1450
1759
|
type: `data-${NAME}`;
|
|
@@ -1546,6 +1855,19 @@ declare const deepseekSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFact
|
|
|
1546
1855
|
*/
|
|
1547
1856
|
declare const DEFAULT_MAX_DOWNLOAD_SIZE: number;
|
|
1548
1857
|
|
|
1858
|
+
/**
|
|
1859
|
+
* Default maximum download size: 2 GiB.
|
|
1860
|
+
*
|
|
1861
|
+
* `fetch().arrayBuffer()` has ~2x peak memory overhead (undici buffers the
|
|
1862
|
+
* body internally, then creates the JS ArrayBuffer), so very large downloads
|
|
1863
|
+
* risk exceeding the default V8 heap limit on 64-bit systems and terminating
|
|
1864
|
+
* the process with an out-of-memory error.
|
|
1865
|
+
*
|
|
1866
|
+
* Setting this limit converts an unrecoverable OOM crash into a catchable
|
|
1867
|
+
* `DownloadError`.
|
|
1868
|
+
*/
|
|
1869
|
+
declare const DEFAULT_MAX_DOWNLOAD_SIZE_2: number;
|
|
1870
|
+
|
|
1549
1871
|
export declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> extends HttpChatTransport<UI_MESSAGE> {
|
|
1550
1872
|
readonly resumeStreamIsReplay: boolean;
|
|
1551
1873
|
constructor({ resumeStreamIsReplay, ...options }?: HttpChatTransportInitOptions<UI_MESSAGE> & {
|
|
@@ -1613,6 +1935,17 @@ declare function delay(delayInMs?: number | null, options?: {
|
|
|
1613
1935
|
abortSignal?: AbortSignal;
|
|
1614
1936
|
}): Promise<void>;
|
|
1615
1937
|
|
|
1938
|
+
/**
|
|
1939
|
+
* Creates a Promise that resolves after a specified delay
|
|
1940
|
+
* @param delayInMs - The delay duration in milliseconds. If null or undefined, resolves immediately.
|
|
1941
|
+
* @param signal - Optional AbortSignal to cancel the delay
|
|
1942
|
+
* @returns A Promise that resolves after the specified delay
|
|
1943
|
+
* @throws {DOMException} When the signal is aborted
|
|
1944
|
+
*/
|
|
1945
|
+
declare function delay_2(delayInMs?: number | null, options?: {
|
|
1946
|
+
abortSignal?: AbortSignal;
|
|
1947
|
+
}): Promise<void>;
|
|
1948
|
+
|
|
1616
1949
|
/**
|
|
1617
1950
|
* Delayed promise. It is only constructed once the value is accessed.
|
|
1618
1951
|
* This is useful to avoid unhandled promise rejections when the promise is created
|
|
@@ -1632,14 +1965,32 @@ declare class DelayedPromise<T> {
|
|
|
1632
1965
|
}
|
|
1633
1966
|
|
|
1634
1967
|
/**
|
|
1635
|
-
*
|
|
1636
|
-
*
|
|
1637
|
-
*
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1968
|
+
* Delayed promise. It is only constructed once the value is accessed.
|
|
1969
|
+
* This is useful to avoid unhandled promise rejections when the promise is created
|
|
1970
|
+
* but not accessed.
|
|
1971
|
+
*/
|
|
1972
|
+
declare class DelayedPromise_2<T> {
|
|
1973
|
+
private status;
|
|
1974
|
+
private _promise;
|
|
1975
|
+
private _resolve;
|
|
1976
|
+
private _reject;
|
|
1977
|
+
get promise(): Promise<T>;
|
|
1978
|
+
resolve(value: T): void;
|
|
1979
|
+
reject(error: unknown): void;
|
|
1980
|
+
isResolved(): boolean;
|
|
1981
|
+
isRejected(): boolean;
|
|
1982
|
+
isPending(): boolean;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* A transport that directly communicates with an Agent in-process,
|
|
1987
|
+
* without going through HTTP. This is useful for:
|
|
1988
|
+
* - Server-side rendering scenarios
|
|
1989
|
+
* - Testing without network
|
|
1990
|
+
* - Single-process applications
|
|
1991
|
+
*
|
|
1992
|
+
* @example
|
|
1993
|
+
* ```tsx
|
|
1643
1994
|
* import { useChat } from '@ai-sdk/react';
|
|
1644
1995
|
* import { DirectChatTransport } from 'ai';
|
|
1645
1996
|
* import { myAgent } from './my-agent';
|
|
@@ -1694,8 +2045,24 @@ declare function downloadBlob(url: string, options?: {
|
|
|
1694
2045
|
abortSignal?: AbortSignal;
|
|
1695
2046
|
}): Promise<Blob>;
|
|
1696
2047
|
|
|
2048
|
+
/**
|
|
2049
|
+
* Download a file from a URL and return it as a Blob.
|
|
2050
|
+
*
|
|
2051
|
+
* @param url - The URL to download from.
|
|
2052
|
+
* @param options - Optional settings for the download.
|
|
2053
|
+
* @param options.maxBytes - Maximum allowed download size in bytes. Defaults to 100 MiB.
|
|
2054
|
+
* @param options.abortSignal - An optional abort signal to cancel the download.
|
|
2055
|
+
* @returns A Promise that resolves to the downloaded Blob.
|
|
2056
|
+
*
|
|
2057
|
+
* @throws DownloadError if the download fails or exceeds maxBytes.
|
|
2058
|
+
*/
|
|
2059
|
+
declare function downloadBlob_2(url: string, options?: {
|
|
2060
|
+
maxBytes?: number;
|
|
2061
|
+
abortSignal?: AbortSignal;
|
|
2062
|
+
}): Promise<Blob>;
|
|
2063
|
+
|
|
1697
2064
|
export declare class DownloadError extends AISDKError {
|
|
1698
|
-
private readonly [
|
|
2065
|
+
private readonly [symbol_3];
|
|
1699
2066
|
readonly url: string;
|
|
1700
2067
|
readonly statusCode?: number;
|
|
1701
2068
|
readonly statusText?: string;
|
|
@@ -1709,16 +2076,68 @@ export declare class DownloadError extends AISDKError {
|
|
|
1709
2076
|
static isInstance(error: unknown): error is DownloadError;
|
|
1710
2077
|
}
|
|
1711
2078
|
|
|
2079
|
+
declare class DownloadError_2 extends AISDKError {
|
|
2080
|
+
private readonly [symbol_2];
|
|
2081
|
+
readonly url: string;
|
|
2082
|
+
readonly statusCode?: number;
|
|
2083
|
+
readonly statusText?: string;
|
|
2084
|
+
constructor({ url, statusCode, statusText, cause, message, }: {
|
|
2085
|
+
url: string;
|
|
2086
|
+
statusCode?: number;
|
|
2087
|
+
statusText?: string;
|
|
2088
|
+
message?: string;
|
|
2089
|
+
cause?: unknown;
|
|
2090
|
+
});
|
|
2091
|
+
static isInstance(error: unknown): error is DownloadError_2;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
1712
2094
|
/**
|
|
1713
2095
|
* Defines a dynamic tool.
|
|
1714
2096
|
*/
|
|
1715
2097
|
export declare function dynamicTool(tool: {
|
|
1716
2098
|
description?: string;
|
|
1717
2099
|
title?: string;
|
|
1718
|
-
providerOptions?:
|
|
2100
|
+
providerOptions?: ProviderOptions_2;
|
|
1719
2101
|
metadata?: JSONObject;
|
|
1720
2102
|
inputSchema: FlexibleSchema<unknown>;
|
|
1721
2103
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
2104
|
+
/**
|
|
2105
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
2106
|
+
*
|
|
2107
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
2108
|
+
*/
|
|
2109
|
+
toModelOutput?: (options: {
|
|
2110
|
+
/**
|
|
2111
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
2112
|
+
*/
|
|
2113
|
+
toolCallId: string;
|
|
2114
|
+
/**
|
|
2115
|
+
* The input of the tool call.
|
|
2116
|
+
*/
|
|
2117
|
+
input: unknown;
|
|
2118
|
+
/**
|
|
2119
|
+
* The output of the tool call.
|
|
2120
|
+
*/
|
|
2121
|
+
output: unknown;
|
|
2122
|
+
}) => ToolResultOutput_2 | PromiseLike<ToolResultOutput_2>;
|
|
2123
|
+
/**
|
|
2124
|
+
* Whether the tool needs approval before it can be executed.
|
|
2125
|
+
*/
|
|
2126
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction_2<unknown>;
|
|
2127
|
+
}): Tool<unknown, unknown> & {
|
|
2128
|
+
type: 'dynamic';
|
|
2129
|
+
};
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* Defines a dynamic tool.
|
|
2133
|
+
*/
|
|
2134
|
+
declare function dynamicTool_2(tool: {
|
|
2135
|
+
description?: string;
|
|
2136
|
+
title?: string;
|
|
2137
|
+
providerOptions?: ProviderOptions;
|
|
2138
|
+
metadata?: JSONObject;
|
|
2139
|
+
inputSchema: FlexibleSchema_2<unknown>;
|
|
2140
|
+
execute: ToolExecuteFunction_2<unknown, unknown>;
|
|
1722
2141
|
/**
|
|
1723
2142
|
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
1724
2143
|
*
|
|
@@ -1742,7 +2161,7 @@ export declare function dynamicTool(tool: {
|
|
|
1742
2161
|
* Whether the tool needs approval before it can be executed.
|
|
1743
2162
|
*/
|
|
1744
2163
|
needsApproval?: boolean | ToolNeedsApprovalFunction<unknown>;
|
|
1745
|
-
}):
|
|
2164
|
+
}): Tool_2<unknown, unknown> & {
|
|
1746
2165
|
type: 'dynamic';
|
|
1747
2166
|
};
|
|
1748
2167
|
|
|
@@ -1957,7 +2376,7 @@ export declare function embed({ model: modelArg, value, providerOptions, maxRetr
|
|
|
1957
2376
|
* to the provider from the AI SDK and enable provider-specific
|
|
1958
2377
|
* functionality that can be fully encapsulated in the provider.
|
|
1959
2378
|
*/
|
|
1960
|
-
providerOptions?:
|
|
2379
|
+
providerOptions?: ProviderOptions_2;
|
|
1961
2380
|
/**
|
|
1962
2381
|
* Optional telemetry configuration (experimental).
|
|
1963
2382
|
*/
|
|
@@ -1977,6 +2396,14 @@ export declare type Embedding = EmbeddingModelV3Embedding;
|
|
|
1977
2396
|
*/
|
|
1978
2397
|
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
1979
2398
|
|
|
2399
|
+
/**
|
|
2400
|
+
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
2401
|
+
*
|
|
2402
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
2403
|
+
* embedding model specification.
|
|
2404
|
+
*/
|
|
2405
|
+
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL_2: unique symbol;
|
|
2406
|
+
|
|
1980
2407
|
/**
|
|
1981
2408
|
* Symbol for transforming provider options for an automatically batched
|
|
1982
2409
|
* embedding model call.
|
|
@@ -1986,6 +2413,15 @@ declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
|
1986
2413
|
*/
|
|
1987
2414
|
declare const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER: unique symbol;
|
|
1988
2415
|
|
|
2416
|
+
/**
|
|
2417
|
+
* Symbol for transforming provider options for an automatically batched
|
|
2418
|
+
* embedding model call.
|
|
2419
|
+
*
|
|
2420
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
2421
|
+
* embedding model specification.
|
|
2422
|
+
*/
|
|
2423
|
+
declare const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER_2: unique symbol;
|
|
2424
|
+
|
|
1989
2425
|
/**
|
|
1990
2426
|
* Embedding model that is used by the AI SDK.
|
|
1991
2427
|
*/
|
|
@@ -2000,6 +2436,13 @@ declare type EmbeddingModelProviderOptionsTransformer = (options: {
|
|
|
2000
2436
|
endIndex: number;
|
|
2001
2437
|
}) => SharedV3ProviderOptions | undefined | PromiseLike<SharedV3ProviderOptions | undefined>;
|
|
2002
2438
|
|
|
2439
|
+
declare type EmbeddingModelProviderOptionsTransformer_2 = (options: {
|
|
2440
|
+
providerOptions: SharedV3ProviderOptions | undefined;
|
|
2441
|
+
values: Array<string>;
|
|
2442
|
+
startIndex: number;
|
|
2443
|
+
endIndex: number;
|
|
2444
|
+
}) => SharedV3ProviderOptions | undefined | PromiseLike<SharedV3ProviderOptions | undefined>;
|
|
2445
|
+
|
|
2003
2446
|
/**
|
|
2004
2447
|
* Represents the number of tokens used in an embedding.
|
|
2005
2448
|
*/
|
|
@@ -2342,7 +2785,7 @@ export declare function embedMany({ model: modelArg, values, maxParallelCalls, m
|
|
|
2342
2785
|
* to the provider from the AI SDK and enable provider-specific
|
|
2343
2786
|
* functionality that can be fully encapsulated in the provider.
|
|
2344
2787
|
*/
|
|
2345
|
-
providerOptions?:
|
|
2788
|
+
providerOptions?: ProviderOptions_2;
|
|
2346
2789
|
/**
|
|
2347
2790
|
* Maximum number of concurrent requests.
|
|
2348
2791
|
*
|
|
@@ -2446,6 +2889,13 @@ export declare class EmptyResponseBodyError extends AISDKError {
|
|
|
2446
2889
|
*/
|
|
2447
2890
|
declare function encodePathSegment(value: string): string;
|
|
2448
2891
|
|
|
2892
|
+
/**
|
|
2893
|
+
* Encodes a raw identifier as one URL path segment, including standalone dot
|
|
2894
|
+
* segments that URL parsers would otherwise normalize. Pass unencoded values;
|
|
2895
|
+
* for resource paths with intentional slashes, encode each segment separately.
|
|
2896
|
+
*/
|
|
2897
|
+
declare function encodePathSegment_2(value: string): string;
|
|
2898
|
+
|
|
2449
2899
|
declare type EnforcedToolChoice = Extract<LanguageModelV3ToolChoice, {
|
|
2450
2900
|
type: 'none';
|
|
2451
2901
|
} | {
|
|
@@ -2683,6 +3133,18 @@ declare interface ExceptionWithName {
|
|
|
2683
3133
|
}
|
|
2684
3134
|
|
|
2685
3135
|
declare function executeTool<INPUT, OUTPUT>({ execute, input, options, }: {
|
|
3136
|
+
execute: ToolExecuteFunction_2<INPUT, OUTPUT>;
|
|
3137
|
+
input: INPUT;
|
|
3138
|
+
options: ToolExecutionOptions_2;
|
|
3139
|
+
}): AsyncGenerator<{
|
|
3140
|
+
type: 'preliminary';
|
|
3141
|
+
output: OUTPUT;
|
|
3142
|
+
} | {
|
|
3143
|
+
type: 'final';
|
|
3144
|
+
output: OUTPUT;
|
|
3145
|
+
}>;
|
|
3146
|
+
|
|
3147
|
+
declare function executeTool_2<INPUT, OUTPUT>({ execute, input, options, }: {
|
|
2686
3148
|
execute: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
2687
3149
|
input: INPUT;
|
|
2688
3150
|
options: ToolExecutionOptions;
|
|
@@ -2799,7 +3261,7 @@ export declare function experimental_generateSpeech({ model, text, voice, output
|
|
|
2799
3261
|
* }
|
|
2800
3262
|
* ```
|
|
2801
3263
|
*/
|
|
2802
|
-
providerOptions?:
|
|
3264
|
+
providerOptions?: ProviderOptions_2;
|
|
2803
3265
|
/**
|
|
2804
3266
|
* Maximum number of retries per speech model call. Set to 0 to disable retries.
|
|
2805
3267
|
*
|
|
@@ -2893,7 +3355,7 @@ export declare function experimental_generateVideo({ model: modelArg, prompt: pr
|
|
|
2893
3355
|
* Additional provider-specific options that are passed through to the provider
|
|
2894
3356
|
* as body parameters.
|
|
2895
3357
|
*/
|
|
2896
|
-
providerOptions?:
|
|
3358
|
+
providerOptions?: ProviderOptions_2;
|
|
2897
3359
|
/**
|
|
2898
3360
|
* Maximum number of retries per video model call. Set to 0 to disable retries.
|
|
2899
3361
|
*
|
|
@@ -2970,7 +3432,7 @@ export declare function experimental_transcribe({ model, audio, providerOptions,
|
|
|
2970
3432
|
* }
|
|
2971
3433
|
* ```
|
|
2972
3434
|
*/
|
|
2973
|
-
providerOptions?:
|
|
3435
|
+
providerOptions?: ProviderOptions_2;
|
|
2974
3436
|
/**
|
|
2975
3437
|
* Maximum number of retries per transcript model call. Set to 0 to disable retries.
|
|
2976
3438
|
*
|
|
@@ -3100,11 +3562,26 @@ declare function extractResponseHeaders(response: Response): {
|
|
|
3100
3562
|
[k: string]: string;
|
|
3101
3563
|
};
|
|
3102
3564
|
|
|
3565
|
+
/**
|
|
3566
|
+
* Extracts the headers from a response object and returns them as a key-value object.
|
|
3567
|
+
*
|
|
3568
|
+
* @param response - The response object to extract headers from.
|
|
3569
|
+
* @returns The headers as a key-value object.
|
|
3570
|
+
*/
|
|
3571
|
+
declare function extractResponseHeaders_2(response: Response): {
|
|
3572
|
+
[k: string]: string;
|
|
3573
|
+
};
|
|
3574
|
+
|
|
3103
3575
|
/**
|
|
3104
3576
|
* Fetch function type (standardizes the version of fetch used).
|
|
3105
3577
|
*/
|
|
3106
3578
|
declare type FetchFunction = typeof globalThis.fetch;
|
|
3107
3579
|
|
|
3580
|
+
/**
|
|
3581
|
+
* Fetch function type (standardizes the version of fetch used).
|
|
3582
|
+
*/
|
|
3583
|
+
declare type FetchFunction_2 = typeof globalThis.fetch;
|
|
3584
|
+
|
|
3108
3585
|
/**
|
|
3109
3586
|
* Fetches one validated URL without following redirects.
|
|
3110
3587
|
*
|
|
@@ -3130,6 +3607,31 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
|
|
|
3130
3607
|
requireDnsValidation?: boolean;
|
|
3131
3608
|
}): Promise<Response>;
|
|
3132
3609
|
|
|
3610
|
+
/**
|
|
3611
|
+
* Fetches one validated URL without following redirects.
|
|
3612
|
+
*
|
|
3613
|
+
* On Node.js, the default fetch validates and pins DNS results at connect time.
|
|
3614
|
+
* An injected fetch is responsible for equivalent connect-time validation.
|
|
3615
|
+
* Redirects are rejected by default. Callers using `redirect: 'manual'` must
|
|
3616
|
+
* validate the Location target before issuing another request.
|
|
3617
|
+
*/
|
|
3618
|
+
declare function fetchWithValidatedEndpoint_2({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
|
|
3619
|
+
url: string | URL;
|
|
3620
|
+
init?: RequestInit;
|
|
3621
|
+
fetch?: FetchFunction_2;
|
|
3622
|
+
/**
|
|
3623
|
+
* A developer-configured origin that may legitimately resolve to a private
|
|
3624
|
+
* address. This must never be derived from untrusted response data.
|
|
3625
|
+
*/
|
|
3626
|
+
trustedOrigin?: string;
|
|
3627
|
+
redirect?: 'error' | 'manual';
|
|
3628
|
+
/**
|
|
3629
|
+
* Reject untrusted URLs on server runtimes without a DNS-pinned default
|
|
3630
|
+
* transport unless an explicit custom fetch provides equivalent validation.
|
|
3631
|
+
*/
|
|
3632
|
+
requireDnsValidation?: boolean;
|
|
3633
|
+
}): Promise<Response>;
|
|
3634
|
+
|
|
3133
3635
|
/**
|
|
3134
3636
|
* Fetches a URL while enforcing the download guard on every hop.
|
|
3135
3637
|
*
|
|
@@ -3192,6 +3694,68 @@ declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRed
|
|
|
3192
3694
|
trustedOrigin?: string;
|
|
3193
3695
|
}): Promise<Response>;
|
|
3194
3696
|
|
|
3697
|
+
/**
|
|
3698
|
+
* Fetches a URL while enforcing the download guard on every hop.
|
|
3699
|
+
*
|
|
3700
|
+
* Redirects are followed manually (`redirect: 'manual'`) so each hop is
|
|
3701
|
+
* validated with {@link validateDownloadUrl} *before* it is requested. Relying
|
|
3702
|
+
* on the default `redirect: 'follow'` would issue the request to a redirect
|
|
3703
|
+
* target (e.g. an internal address) before we ever see its URL, defeating the
|
|
3704
|
+
* guard.
|
|
3705
|
+
*
|
|
3706
|
+
* Manually followed redirects from HTTPS to HTTP are rejected before requesting
|
|
3707
|
+
* the target.
|
|
3708
|
+
*
|
|
3709
|
+
* Request headers are also protected: {@link sanitizeRequestHeaders} strips
|
|
3710
|
+
* proxy/metadata/cookie/hop-by-hop headers before the first request, and all
|
|
3711
|
+
* caller headers except `User-Agent` are dropped on a cross-origin redirect.
|
|
3712
|
+
* Credentials and custom headers are preserved on the first hop for backwards
|
|
3713
|
+
* compatibility. The caller must ensure that the initial URL may receive them.
|
|
3714
|
+
* The fetch spec only strips `Authorization` on cross-origin redirects because
|
|
3715
|
+
* in a browser, CORS preflighting protects custom headers; there is no CORS on
|
|
3716
|
+
* the server, so provider API keys carried in custom headers (e.g. `x-key`)
|
|
3717
|
+
* must be dropped here as well.
|
|
3718
|
+
*
|
|
3719
|
+
* A `redirect: 'manual'` request yields an unreadable opaque response in the
|
|
3720
|
+
* browser (and in other spec-compliant fetch implementations), so the redirect
|
|
3721
|
+
* target cannot be validated here. In a real browser this is safe to follow
|
|
3722
|
+
* natively because reaching an internal network is not possible (fetch is
|
|
3723
|
+
* constrained by CORS and cannot reach a server's internal network or
|
|
3724
|
+
* cloud-metadata). On any other runtime we cannot validate the hop, so we fail
|
|
3725
|
+
* closed rather than follow it blindly and bypass the guard.
|
|
3726
|
+
*
|
|
3727
|
+
* A hop that is same-origin with `trustedOrigin` (the developer-configured
|
|
3728
|
+
* provider endpoint) skips target validation: that origin is exactly what an
|
|
3729
|
+
* unvalidated, config-derived request would fetch anyway, and validating it
|
|
3730
|
+
* would break legitimate self-hosted / localhost deployments whose response
|
|
3731
|
+
* URLs point back at the configured host. Hops on any other origin are always
|
|
3732
|
+
* validated.
|
|
3733
|
+
*
|
|
3734
|
+
* The returned response is the final (non-redirect) response. The caller is
|
|
3735
|
+
* responsible for checking `response.ok` and reading the body.
|
|
3736
|
+
*
|
|
3737
|
+
* On Node.js, the default fetch resolves every hostname through a validating
|
|
3738
|
+
* lookup hook and passes those exact addresses to the connector, preventing
|
|
3739
|
+
* hostname-to-private-IP and DNS-rebinding bypasses. An injected fetch is
|
|
3740
|
+
* responsible for equivalent connect-time validation. Other runtimes should
|
|
3741
|
+
* constrain egress at the network layer when handling untrusted URLs.
|
|
3742
|
+
*
|
|
3743
|
+
* @throws DownloadError if a hop is unsafe, the redirect limit is exceeded, or
|
|
3744
|
+
* a redirect cannot be validated on a non-browser runtime.
|
|
3745
|
+
*/
|
|
3746
|
+
declare function fetchWithValidatedRedirects_2({ url, headers, abortSignal, maxRedirects, fetch: customFetch, trustedOrigin, }: {
|
|
3747
|
+
url: string;
|
|
3748
|
+
headers?: HeadersInit;
|
|
3749
|
+
abortSignal?: AbortSignal;
|
|
3750
|
+
maxRedirects?: number;
|
|
3751
|
+
fetch?: FetchFunction_2;
|
|
3752
|
+
/**
|
|
3753
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) whose hops
|
|
3754
|
+
* skip target validation. Must never be derived from response data.
|
|
3755
|
+
*/
|
|
3756
|
+
trustedOrigin?: string;
|
|
3757
|
+
}): Promise<Response>;
|
|
3758
|
+
|
|
3195
3759
|
/**
|
|
3196
3760
|
* File content part of a prompt. It contains a file.
|
|
3197
3761
|
*/
|
|
@@ -3214,6 +3778,36 @@ export declare interface FilePart {
|
|
|
3214
3778
|
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
3215
3779
|
*/
|
|
3216
3780
|
mediaType: string;
|
|
3781
|
+
/**
|
|
3782
|
+
* Additional provider-specific metadata. They are passed through
|
|
3783
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3784
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3785
|
+
*/
|
|
3786
|
+
providerOptions?: ProviderOptions_2;
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
/**
|
|
3790
|
+
* File content part of a prompt. It contains a file.
|
|
3791
|
+
*/
|
|
3792
|
+
declare interface FilePart_2 {
|
|
3793
|
+
type: 'file';
|
|
3794
|
+
/**
|
|
3795
|
+
* File data. Can either be:
|
|
3796
|
+
*
|
|
3797
|
+
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
|
|
3798
|
+
* - URL: a URL that points to the image
|
|
3799
|
+
*/
|
|
3800
|
+
data: DataContent_2 | URL;
|
|
3801
|
+
/**
|
|
3802
|
+
* Optional filename of the file.
|
|
3803
|
+
*/
|
|
3804
|
+
filename?: string;
|
|
3805
|
+
/**
|
|
3806
|
+
* IANA media type of the file.
|
|
3807
|
+
*
|
|
3808
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
3809
|
+
*/
|
|
3810
|
+
mediaType: string;
|
|
3217
3811
|
/**
|
|
3218
3812
|
* Additional provider-specific metadata. They are passed through
|
|
3219
3813
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -3261,7 +3855,9 @@ export declare type FileUIPart = {
|
|
|
3261
3855
|
*/
|
|
3262
3856
|
export declare type FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
|
|
3263
3857
|
|
|
3264
|
-
export declare type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> |
|
|
3858
|
+
export declare type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema_2<SCHEMA> | ZodSchema_2<SCHEMA> | StandardSchema_2<SCHEMA>;
|
|
3859
|
+
|
|
3860
|
+
declare type FlexibleSchema_2<SCHEMA = any> = Schema_2<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
|
|
3265
3861
|
|
|
3266
3862
|
export declare const gateway: GatewayProvider;
|
|
3267
3863
|
|
|
@@ -3662,8 +4258,14 @@ export { GeneratedFile }
|
|
|
3662
4258
|
export declare const generateId: IdGenerator;
|
|
3663
4259
|
|
|
3664
4260
|
/**
|
|
3665
|
-
* Generates
|
|
3666
|
-
*
|
|
4261
|
+
* Generates a 16-character random string to use for IDs.
|
|
4262
|
+
* Not cryptographically secure.
|
|
4263
|
+
*/
|
|
4264
|
+
declare const generateId_2: IdGenerator_2;
|
|
4265
|
+
|
|
4266
|
+
/**
|
|
4267
|
+
* Generates images using an image model.
|
|
4268
|
+
*
|
|
3667
4269
|
* @param model - The image model to use.
|
|
3668
4270
|
* @param prompt - The prompt that should be used to generate the image.
|
|
3669
4271
|
* @param n - Number of images to generate. Default: 1.
|
|
@@ -3722,7 +4324,7 @@ export declare function generateImage({ model: modelArg, prompt: promptArg, n, m
|
|
|
3722
4324
|
* }
|
|
3723
4325
|
* ```
|
|
3724
4326
|
*/
|
|
3725
|
-
providerOptions?:
|
|
4327
|
+
providerOptions?: ProviderOptions_2;
|
|
3726
4328
|
/**
|
|
3727
4329
|
* Maximum number of retries per image model call, including retries after
|
|
3728
4330
|
* unclassified empty responses. Empty responses marked as not retryable by
|
|
@@ -3895,7 +4497,7 @@ export declare function generateObject<SCHEMA extends FlexibleSchema<unknown> =
|
|
|
3895
4497
|
* to the provider from the AI SDK and enable provider-specific
|
|
3896
4498
|
* functionality that can be fully encapsulated in the provider.
|
|
3897
4499
|
*/
|
|
3898
|
-
providerOptions?:
|
|
4500
|
+
providerOptions?: ProviderOptions_2;
|
|
3899
4501
|
/**
|
|
3900
4502
|
* Internal. For test use only. May change without notice.
|
|
3901
4503
|
*/
|
|
@@ -4040,7 +4642,7 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
|
|
|
4040
4642
|
* to the provider from the AI SDK and enable provider-specific
|
|
4041
4643
|
* functionality that can be fully encapsulated in the provider.
|
|
4042
4644
|
*/
|
|
4043
|
-
providerOptions?:
|
|
4645
|
+
providerOptions?: ProviderOptions_2;
|
|
4044
4646
|
/**
|
|
4045
4647
|
* @deprecated Use `activeTools` instead.
|
|
4046
4648
|
*/
|
|
@@ -4386,6 +4988,8 @@ export declare interface GenerateVideoResult {
|
|
|
4386
4988
|
|
|
4387
4989
|
declare function getErrorMessage(error: unknown | undefined): string;
|
|
4388
4990
|
|
|
4991
|
+
declare function getErrorMessage_2(error: unknown | undefined): string;
|
|
4992
|
+
|
|
4389
4993
|
declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
|
|
4390
4994
|
url: string;
|
|
4391
4995
|
headers?: Record<string, string | undefined>;
|
|
@@ -4430,6 +5034,50 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
|
4430
5034
|
responseHeaders?: Record<string, string>;
|
|
4431
5035
|
}>;
|
|
4432
5036
|
|
|
5037
|
+
declare const getFromApi_2: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
|
|
5038
|
+
url: string;
|
|
5039
|
+
headers?: Record<string, string | undefined>;
|
|
5040
|
+
failedResponseHandler: ResponseHandler_2<Error>;
|
|
5041
|
+
successfulResponseHandler: ResponseHandler_2<T>;
|
|
5042
|
+
abortSignal?: AbortSignal;
|
|
5043
|
+
fetch?: FetchFunction_2;
|
|
5044
|
+
/**
|
|
5045
|
+
* Set `true` when `url` is untrusted (e.g. taken from a provider response
|
|
5046
|
+
* body): it is routed through {@link fetchWithValidatedRedirects}, which
|
|
5047
|
+
* rejects private/loopback/link-local targets and re-validates redirect
|
|
5048
|
+
* hops; blocked URLs throw `DownloadError`. Set `false` only for URLs built
|
|
5049
|
+
* from a developer-configured endpoint.
|
|
5050
|
+
*
|
|
5051
|
+
* Optional for backwards compatibility with existing callers; omitting it
|
|
5052
|
+
* behaves like `false` (no validation).
|
|
5053
|
+
*/
|
|
5054
|
+
validateUrl?: boolean;
|
|
5055
|
+
/**
|
|
5056
|
+
* When set, `headers` are sent only if `url` is same-origin with this origin
|
|
5057
|
+
* (the user-agent suffix is always kept). Pass the provider's configured
|
|
5058
|
+
* base URL alongside `validateUrl: true` so credentials never ride a request
|
|
5059
|
+
* to a response-supplied host on a different origin (e.g. a CDN). Redirects
|
|
5060
|
+
* that later cross origin drop all caller headers regardless (see
|
|
5061
|
+
* {@link fetchWithValidatedRedirects}).
|
|
5062
|
+
*/
|
|
5063
|
+
credentialedOrigin?: string;
|
|
5064
|
+
/**
|
|
5065
|
+
* A developer-configured origin (e.g. the provider's `baseURL`) that is
|
|
5066
|
+
* exempt from URL validation when `validateUrl` is `true`. A response URL
|
|
5067
|
+
* (or redirect hop) that is same-origin with it is fetched without target
|
|
5068
|
+
* validation — it points at exactly the host a config-derived
|
|
5069
|
+
* `validateUrl: false` request would fetch anyway, so blocking it would
|
|
5070
|
+
* only break legitimate self-hosted / localhost deployments whose response
|
|
5071
|
+
* URLs point back at the configured host. Hops on any other origin are
|
|
5072
|
+
* still validated. Must never be derived from response data.
|
|
5073
|
+
*/
|
|
5074
|
+
trustedOrigin?: string;
|
|
5075
|
+
}) => Promise<{
|
|
5076
|
+
value: T;
|
|
5077
|
+
rawValue?: unknown;
|
|
5078
|
+
responseHeaders?: Record<string, string>;
|
|
5079
|
+
}>;
|
|
5080
|
+
|
|
4433
5081
|
declare type GetMaxImagesPerCallFunction$1 = (options: {
|
|
4434
5082
|
modelId: string;
|
|
4435
5083
|
}) => PromiseLike<number | undefined> | number | undefined;
|
|
@@ -4446,6 +5094,8 @@ declare const getOriginalFetch: () => typeof fetch;
|
|
|
4446
5094
|
|
|
4447
5095
|
declare function getRuntimeEnvironmentUserAgent(globalThisAny?: any): string;
|
|
4448
5096
|
|
|
5097
|
+
declare function getRuntimeEnvironmentUserAgent_2(globalThisAny?: any): string;
|
|
5098
|
+
|
|
4449
5099
|
/**
|
|
4450
5100
|
* Returns the name of the static tool.
|
|
4451
5101
|
*
|
|
@@ -4502,7 +5152,7 @@ export declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> im
|
|
|
4502
5152
|
protected credentials: HttpChatTransportInitOptions<UI_MESSAGE>['credentials'];
|
|
4503
5153
|
protected headers: HttpChatTransportInitOptions<UI_MESSAGE>['headers'];
|
|
4504
5154
|
protected body: HttpChatTransportInitOptions<UI_MESSAGE>['body'];
|
|
4505
|
-
protected fetch?:
|
|
5155
|
+
protected fetch?: FetchFunction_2;
|
|
4506
5156
|
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
|
4507
5157
|
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
|
4508
5158
|
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
|
@@ -4527,11 +5177,11 @@ export declare type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> =
|
|
|
4527
5177
|
* Possible values are: 'omit', 'same-origin', 'include'.
|
|
4528
5178
|
* Defaults to 'same-origin'.
|
|
4529
5179
|
*/
|
|
4530
|
-
credentials?:
|
|
5180
|
+
credentials?: Resolvable_2<RequestCredentials>;
|
|
4531
5181
|
/**
|
|
4532
5182
|
* HTTP headers to be sent with the API request.
|
|
4533
5183
|
*/
|
|
4534
|
-
headers?:
|
|
5184
|
+
headers?: Resolvable_2<Record<string, string> | Headers>;
|
|
4535
5185
|
/**
|
|
4536
5186
|
* Extra body object to be sent with the API request.
|
|
4537
5187
|
* @example
|
|
@@ -4544,12 +5194,12 @@ export declare type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> =
|
|
|
4544
5194
|
* })
|
|
4545
5195
|
* ```
|
|
4546
5196
|
*/
|
|
4547
|
-
body?:
|
|
5197
|
+
body?: Resolvable_2<object>;
|
|
4548
5198
|
/**
|
|
4549
5199
|
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
4550
5200
|
* or to provide a custom fetch implementation for e.g. testing.
|
|
4551
5201
|
*/
|
|
4552
|
-
fetch?:
|
|
5202
|
+
fetch?: FetchFunction_2;
|
|
4553
5203
|
/**
|
|
4554
5204
|
* When a function is provided, it will be used
|
|
4555
5205
|
* to prepare the request body for the chat API. This can be useful for
|
|
@@ -4569,6 +5219,11 @@ export declare type HttpChatTransportInitOptions<UI_MESSAGE extends UIMessage> =
|
|
|
4569
5219
|
*/
|
|
4570
5220
|
export declare type IdGenerator = () => string;
|
|
4571
5221
|
|
|
5222
|
+
/**
|
|
5223
|
+
* A function that generates an ID.
|
|
5224
|
+
*/
|
|
5225
|
+
declare type IdGenerator_2 = () => string;
|
|
5226
|
+
|
|
4572
5227
|
/**
|
|
4573
5228
|
* Image model that is used by the AI SDK.
|
|
4574
5229
|
*/
|
|
@@ -5038,6 +5693,32 @@ export declare interface ImagePart {
|
|
|
5038
5693
|
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
5039
5694
|
*/
|
|
5040
5695
|
mediaType?: string;
|
|
5696
|
+
/**
|
|
5697
|
+
* Additional provider-specific metadata. They are passed through
|
|
5698
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
5699
|
+
* functionality that can be fully encapsulated in the provider.
|
|
5700
|
+
*/
|
|
5701
|
+
providerOptions?: ProviderOptions_2;
|
|
5702
|
+
}
|
|
5703
|
+
|
|
5704
|
+
/**
|
|
5705
|
+
* Image content part of a prompt. It contains an image.
|
|
5706
|
+
*/
|
|
5707
|
+
declare interface ImagePart_2 {
|
|
5708
|
+
type: 'image';
|
|
5709
|
+
/**
|
|
5710
|
+
* Image data. Can either be:
|
|
5711
|
+
*
|
|
5712
|
+
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
|
|
5713
|
+
* - URL: a URL that points to the image
|
|
5714
|
+
*/
|
|
5715
|
+
image: DataContent_2 | URL;
|
|
5716
|
+
/**
|
|
5717
|
+
* Optional IANA media type of the image.
|
|
5718
|
+
*
|
|
5719
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
5720
|
+
*/
|
|
5721
|
+
mediaType?: string;
|
|
5041
5722
|
/**
|
|
5042
5723
|
* Additional provider-specific metadata. They are passed through
|
|
5043
5724
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -5068,7 +5749,9 @@ declare type InferElementOutput<OUTPUT extends OutputInterface> = OUTPUT extends
|
|
|
5068
5749
|
*/
|
|
5069
5750
|
export declare type InferGenerateOutput<OUTPUT extends OutputInterface> = OUTPUT extends OutputInterface<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
|
|
5070
5751
|
|
|
5071
|
-
export declare type InferSchema<SCHEMA> = SCHEMA extends
|
|
5752
|
+
export declare type InferSchema<SCHEMA> = SCHEMA extends ZodSchema_2<infer T> ? T : SCHEMA extends StandardSchema_2<infer T> ? T : SCHEMA extends LazySchema_2<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
|
|
5753
|
+
|
|
5754
|
+
declare type InferSchema_2<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema_2<infer T> ? T : never;
|
|
5072
5755
|
|
|
5073
5756
|
/**
|
|
5074
5757
|
* Infers the partial output type from the output specification.
|
|
@@ -5080,11 +5763,21 @@ export declare type InferStreamOutput<OUTPUT extends OutputInterface> = OUTPUT e
|
|
|
5080
5763
|
*/
|
|
5081
5764
|
export declare type InferToolInput<TOOL extends Tool> = TOOL extends Tool<infer INPUT, any> ? INPUT : never;
|
|
5082
5765
|
|
|
5766
|
+
/**
|
|
5767
|
+
* Infer the input type of a tool.
|
|
5768
|
+
*/
|
|
5769
|
+
declare type InferToolInput_2<TOOL extends Tool_2> = TOOL extends Tool_2<infer INPUT, any> ? INPUT : never;
|
|
5770
|
+
|
|
5083
5771
|
/**
|
|
5084
5772
|
* Infer the output type of a tool.
|
|
5085
5773
|
*/
|
|
5086
5774
|
export declare type InferToolOutput<TOOL extends Tool> = TOOL extends Tool<any, infer OUTPUT> ? OUTPUT : never;
|
|
5087
5775
|
|
|
5776
|
+
/**
|
|
5777
|
+
* Infer the output type of a tool.
|
|
5778
|
+
*/
|
|
5779
|
+
declare type InferToolOutput_2<TOOL extends Tool_2> = TOOL extends Tool_2<any, infer OUTPUT> ? OUTPUT : never;
|
|
5780
|
+
|
|
5088
5781
|
export declare type InferUIDataParts<T extends UIDataPartSchemas> = {
|
|
5089
5782
|
[K in keyof T]: InferSchema<T[K]>;
|
|
5090
5783
|
};
|
|
@@ -5096,12 +5789,12 @@ declare type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unkno
|
|
|
5096
5789
|
declare type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
|
5097
5790
|
|
|
5098
5791
|
declare type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
|
5099
|
-
[NAME in keyof InferUIMessageTools<UI_MESSAGE>]:
|
|
5792
|
+
[NAME in keyof InferUIMessageTools<UI_MESSAGE>]: ToolCall_2<NAME & string, InferUIMessageTools<UI_MESSAGE>[NAME] extends {
|
|
5100
5793
|
input: infer INPUT;
|
|
5101
5794
|
} ? INPUT : never> & {
|
|
5102
5795
|
dynamic?: false;
|
|
5103
5796
|
};
|
|
5104
|
-
}> | (
|
|
5797
|
+
}> | (ToolCall_2<string, unknown> & {
|
|
5105
5798
|
dynamic: true;
|
|
5106
5799
|
});
|
|
5107
5800
|
|
|
@@ -5129,6 +5822,13 @@ declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPre
|
|
|
5129
5822
|
schemaSuffix?: string;
|
|
5130
5823
|
}): LanguageModelV3Prompt;
|
|
5131
5824
|
|
|
5825
|
+
declare function injectJsonInstructionIntoMessages_2({ messages, schema, schemaPrefix, schemaSuffix, }: {
|
|
5826
|
+
messages: LanguageModelV3Prompt;
|
|
5827
|
+
schema?: JSONSchema7;
|
|
5828
|
+
schemaPrefix?: string;
|
|
5829
|
+
schemaSuffix?: string;
|
|
5830
|
+
}): LanguageModelV3Prompt;
|
|
5831
|
+
|
|
5132
5832
|
export declare class InvalidArgumentError extends AISDKError {
|
|
5133
5833
|
private readonly [symbol$j];
|
|
5134
5834
|
readonly parameter: string;
|
|
@@ -5237,8 +5937,12 @@ export declare class InvalidToolInputError extends AISDKError {
|
|
|
5237
5937
|
|
|
5238
5938
|
declare function isAbortError(error: unknown): error is Error;
|
|
5239
5939
|
|
|
5940
|
+
declare function isAbortError_2(error: unknown): error is Error;
|
|
5941
|
+
|
|
5240
5942
|
declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
|
|
5241
5943
|
|
|
5944
|
+
declare function isArrayBuffer_2(value: unknown): value is ArrayBuffer;
|
|
5945
|
+
|
|
5242
5946
|
/**
|
|
5243
5947
|
* Returns `true` when running in a browser.
|
|
5244
5948
|
*
|
|
@@ -5249,6 +5953,16 @@ declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
|
|
|
5249
5953
|
*/
|
|
5250
5954
|
declare function isBrowserRuntime(globalThisAny?: any): boolean;
|
|
5251
5955
|
|
|
5956
|
+
/**
|
|
5957
|
+
* Returns `true` when running in a browser.
|
|
5958
|
+
*
|
|
5959
|
+
* Detection keys on the presence of a global `window`, matching the browser
|
|
5960
|
+
* check used elsewhere in this package (see `getRuntimeEnvironmentUserAgent`)
|
|
5961
|
+
* so the SDK has a single, consistent definition of "browser". Server runtimes
|
|
5962
|
+
* (Node.js, Deno, Bun, edge/workers) do not define `window`.
|
|
5963
|
+
*/
|
|
5964
|
+
declare function isBrowserRuntime_2(globalThisAny?: any): boolean;
|
|
5965
|
+
|
|
5252
5966
|
/**
|
|
5253
5967
|
* Check if a message part is a data part.
|
|
5254
5968
|
*/
|
|
@@ -5286,8 +6000,19 @@ export declare function isLoopFinished(): StopCondition<any>;
|
|
|
5286
6000
|
*/
|
|
5287
6001
|
declare function isNonNullable<T>(value: T | undefined | null): value is NonNullable<T>;
|
|
5288
6002
|
|
|
6003
|
+
/**
|
|
6004
|
+
* Type guard that checks whether a value is not `null` or `undefined`.
|
|
6005
|
+
*
|
|
6006
|
+
* @template T - The type of the value to check.
|
|
6007
|
+
* @param value - The value to check.
|
|
6008
|
+
* @returns `true` if the value is neither `null` nor `undefined`, otherwise `false`.
|
|
6009
|
+
*/
|
|
6010
|
+
declare function isNonNullable_2<T>(value: T | undefined | null): value is NonNullable<T>;
|
|
6011
|
+
|
|
5289
6012
|
declare function isParsableJson(input: string): boolean;
|
|
5290
6013
|
|
|
6014
|
+
declare function isParsableJson_2(input: string): boolean;
|
|
6015
|
+
|
|
5291
6016
|
/**
|
|
5292
6017
|
* Type guard to check if a message part is a reasoning part.
|
|
5293
6018
|
*/
|
|
@@ -5307,6 +6032,20 @@ export declare function isReasoningUIPart(part: UIMessagePart<UIDataTypes, UIToo
|
|
|
5307
6032
|
*/
|
|
5308
6033
|
declare function isSameOrigin(url: string, baseUrl: string): boolean;
|
|
5309
6034
|
|
|
6035
|
+
/**
|
|
6036
|
+
* Returns true when `url` has the same origin (scheme + host + port) as
|
|
6037
|
+
* `baseUrl`.
|
|
6038
|
+
*
|
|
6039
|
+
* Used to decide whether provider credentials may be attached to a request to a
|
|
6040
|
+
* URL taken from a provider response (e.g. a polling or media-download URL).
|
|
6041
|
+
* Credentials must only be sent to the provider's own origin; a response that
|
|
6042
|
+
* names a foreign host (a CDN, or an attacker-controlled host if the response
|
|
6043
|
+
* is tampered with) must not receive the API key.
|
|
6044
|
+
*
|
|
6045
|
+
* Returns false if either value is not a valid absolute URL (fail-closed).
|
|
6046
|
+
*/
|
|
6047
|
+
declare function isSameOrigin_2(url: string, baseUrl: string): boolean;
|
|
6048
|
+
|
|
5310
6049
|
/**
|
|
5311
6050
|
* Check if a message part is a static tool part.
|
|
5312
6051
|
*
|
|
@@ -5335,6 +6074,8 @@ export declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<
|
|
|
5335
6074
|
|
|
5336
6075
|
declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
5337
6076
|
|
|
6077
|
+
declare function isUint8Array_2(value: unknown): value is Uint8Array;
|
|
6078
|
+
|
|
5338
6079
|
/**
|
|
5339
6080
|
* Checks if the given URL is supported natively by the model.
|
|
5340
6081
|
*
|
|
@@ -5352,6 +6093,23 @@ declare function isUrlSupported({ mediaType, url, supportedUrls, }: {
|
|
|
5352
6093
|
supportedUrls: Record<string, RegExp[]>;
|
|
5353
6094
|
}): boolean;
|
|
5354
6095
|
|
|
6096
|
+
/**
|
|
6097
|
+
* Checks if the given URL is supported natively by the model.
|
|
6098
|
+
*
|
|
6099
|
+
* @param mediaType - The media type of the URL. Case-insensitive.
|
|
6100
|
+
* @param url - The URL to check.
|
|
6101
|
+
* @param supportedUrls - A record where keys are case-insensitive media types (or '*')
|
|
6102
|
+
* and values are arrays of RegExp patterns for URLs.
|
|
6103
|
+
*
|
|
6104
|
+
* @returns `true` if the URL matches a pattern under the specific media type
|
|
6105
|
+
* or the wildcard '*', `false` otherwise.
|
|
6106
|
+
*/
|
|
6107
|
+
declare function isUrlSupported_2({ mediaType, url, supportedUrls, }: {
|
|
6108
|
+
mediaType: string;
|
|
6109
|
+
url: string;
|
|
6110
|
+
supportedUrls: Record<string, RegExp[]>;
|
|
6111
|
+
}): boolean;
|
|
6112
|
+
|
|
5355
6113
|
declare type Job = () => Promise<void>;
|
|
5356
6114
|
|
|
5357
6115
|
declare type JSONArray = JSONValue_2[];
|
|
@@ -5377,11 +6135,21 @@ export declare class JSONParseError extends AISDKError {
|
|
|
5377
6135
|
* @param options.validate Optional. A validation function for the schema.
|
|
5378
6136
|
*/
|
|
5379
6137
|
export declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7> | (() => JSONSchema7 | PromiseLike<JSONSchema7>), { validate, }?: {
|
|
5380
|
-
validate?: (value: unknown) =>
|
|
6138
|
+
validate?: (value: unknown) => ValidationResult_2<OBJECT> | PromiseLike<ValidationResult_2<OBJECT>>;
|
|
5381
6139
|
}): Schema<OBJECT>;
|
|
5382
6140
|
|
|
5383
6141
|
export { JSONSchema7 }
|
|
5384
6142
|
|
|
6143
|
+
/**
|
|
6144
|
+
* Create a schema using a JSON Schema.
|
|
6145
|
+
*
|
|
6146
|
+
* @param jsonSchema The JSON Schema for the schema.
|
|
6147
|
+
* @param options.validate Optional. A validation function for the schema.
|
|
6148
|
+
*/
|
|
6149
|
+
declare function jsonSchema_2<OBJECT = unknown>(jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7> | (() => JSONSchema7 | PromiseLike<JSONSchema7>), { validate, }?: {
|
|
6150
|
+
validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
|
6151
|
+
}): Schema_2<OBJECT>;
|
|
6152
|
+
|
|
5385
6153
|
/**
|
|
5386
6154
|
* A TransformStream that converts JSON objects to Server-Sent Events (SSE) format.
|
|
5387
6155
|
* Each object is serialized to JSON and wrapped in `data: ...\n\n` format.
|
|
@@ -7398,7 +8166,19 @@ export declare function lastAssistantMessageIsCompleteWithToolCalls({ messages,
|
|
|
7398
8166
|
messages: UIMessage[];
|
|
7399
8167
|
}): boolean;
|
|
7400
8168
|
|
|
7401
|
-
declare type LazySchema<SCHEMA> = () =>
|
|
8169
|
+
declare type LazySchema<SCHEMA> = () => Schema_2<SCHEMA>;
|
|
8170
|
+
|
|
8171
|
+
/**
|
|
8172
|
+
* Creates a schema with deferred creation.
|
|
8173
|
+
* This is important to reduce the startup time of the library
|
|
8174
|
+
* and to avoid initializing unused validators.
|
|
8175
|
+
*
|
|
8176
|
+
* @param createValidator A function that creates a schema.
|
|
8177
|
+
* @returns A function that returns a schema.
|
|
8178
|
+
*/
|
|
8179
|
+
declare function lazySchema<SCHEMA>(createSchema: () => Schema_2<SCHEMA>): LazySchema<SCHEMA>;
|
|
8180
|
+
|
|
8181
|
+
declare type LazySchema_2<SCHEMA> = () => Schema<SCHEMA>;
|
|
7402
8182
|
|
|
7403
8183
|
/**
|
|
7404
8184
|
* Creates a schema with deferred creation.
|
|
@@ -7408,7 +8188,7 @@ declare type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
|
|
|
7408
8188
|
* @param createValidator A function that creates a schema.
|
|
7409
8189
|
* @returns A function that returns a schema.
|
|
7410
8190
|
*/
|
|
7411
|
-
declare function
|
|
8191
|
+
declare function lazySchema_2<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema_2<SCHEMA>;
|
|
7412
8192
|
|
|
7413
8193
|
/**
|
|
7414
8194
|
* A pointer from the current {@link Span} to another span in the same trace or
|
|
@@ -7452,6 +8232,13 @@ declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterNa
|
|
|
7452
8232
|
description: string;
|
|
7453
8233
|
}): string;
|
|
7454
8234
|
|
|
8235
|
+
declare function loadApiKey_2({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
|
|
8236
|
+
apiKey: string | undefined;
|
|
8237
|
+
environmentVariableName: string;
|
|
8238
|
+
apiKeyParameterName?: string;
|
|
8239
|
+
description: string;
|
|
8240
|
+
}): string;
|
|
8241
|
+
|
|
7455
8242
|
export declare class LoadAPIKeyError extends AISDKError {
|
|
7456
8243
|
private readonly [symbol$6];
|
|
7457
8244
|
constructor({ message }: {
|
|
@@ -7472,6 +8259,18 @@ declare function loadOptionalSetting({ settingValue, environmentVariableName, }:
|
|
|
7472
8259
|
environmentVariableName: string;
|
|
7473
8260
|
}): string | undefined;
|
|
7474
8261
|
|
|
8262
|
+
/**
|
|
8263
|
+
* Loads an optional `string` setting from the environment or a parameter.
|
|
8264
|
+
*
|
|
8265
|
+
* @param settingValue - The setting value.
|
|
8266
|
+
* @param environmentVariableName - The environment variable name.
|
|
8267
|
+
* @returns The setting value.
|
|
8268
|
+
*/
|
|
8269
|
+
declare function loadOptionalSetting_2({ settingValue, environmentVariableName, }: {
|
|
8270
|
+
settingValue: string | undefined;
|
|
8271
|
+
environmentVariableName: string;
|
|
8272
|
+
}): string | undefined;
|
|
8273
|
+
|
|
7475
8274
|
/**
|
|
7476
8275
|
* Loads a `string` setting from the environment or a parameter.
|
|
7477
8276
|
*
|
|
@@ -7488,6 +8287,22 @@ declare function loadSetting({ settingValue, environmentVariableName, settingNam
|
|
|
7488
8287
|
description: string;
|
|
7489
8288
|
}): string;
|
|
7490
8289
|
|
|
8290
|
+
/**
|
|
8291
|
+
* Loads a `string` setting from the environment or a parameter.
|
|
8292
|
+
*
|
|
8293
|
+
* @param settingValue - The setting value.
|
|
8294
|
+
* @param environmentVariableName - The environment variable name.
|
|
8295
|
+
* @param settingName - The setting name.
|
|
8296
|
+
* @param description - The description of the setting.
|
|
8297
|
+
* @returns The setting value.
|
|
8298
|
+
*/
|
|
8299
|
+
declare function loadSetting_2({ settingValue, environmentVariableName, settingName, description, }: {
|
|
8300
|
+
settingValue: string | undefined;
|
|
8301
|
+
environmentVariableName: string;
|
|
8302
|
+
settingName: string;
|
|
8303
|
+
description: string;
|
|
8304
|
+
}): string;
|
|
8305
|
+
|
|
7491
8306
|
export declare class LoadSettingError extends AISDKError {
|
|
7492
8307
|
private readonly [symbol$5];
|
|
7493
8308
|
constructor({ message }: {
|
|
@@ -7527,6 +8342,8 @@ export { LogWarningsFunction }
|
|
|
7527
8342
|
|
|
7528
8343
|
declare type MaybePromiseLike<T> = T | PromiseLike<T>;
|
|
7529
8344
|
|
|
8345
|
+
declare type MaybePromiseLike_2<T> = T | PromiseLike<T>;
|
|
8346
|
+
|
|
7530
8347
|
/**
|
|
7531
8348
|
* Maps a media type to its corresponding file extension.
|
|
7532
8349
|
* It was originally introduced to set a filename for audio file uploads
|
|
@@ -7538,6 +8355,17 @@ declare type MaybePromiseLike<T> = T | PromiseLike<T>;
|
|
|
7538
8355
|
*/
|
|
7539
8356
|
declare function mediaTypeToExtension(mediaType: string): string;
|
|
7540
8357
|
|
|
8358
|
+
/**
|
|
8359
|
+
* Maps a media type to its corresponding file extension.
|
|
8360
|
+
* It was originally introduced to set a filename for audio file uploads
|
|
8361
|
+
* in https://github.com/vercel/ai/pull/8159.
|
|
8362
|
+
*
|
|
8363
|
+
* @param mediaType The media type to map.
|
|
8364
|
+
* @returns The corresponding file extension
|
|
8365
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types
|
|
8366
|
+
*/
|
|
8367
|
+
declare function mediaTypeToExtension_2(mediaType: string): string;
|
|
8368
|
+
|
|
7541
8369
|
export declare class MessageConversionError extends AISDKError {
|
|
7542
8370
|
private readonly [symbol$2_2];
|
|
7543
8371
|
readonly originalMessage: Omit<UIMessage, 'id'>;
|
|
@@ -7563,10 +8391,18 @@ export declare class MissingToolResultsError extends AISDKError {
|
|
|
7563
8391
|
*/
|
|
7564
8392
|
export declare type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
|
|
7565
8393
|
|
|
8394
|
+
/**
|
|
8395
|
+
* A message that can be used in the `messages` field of a prompt.
|
|
8396
|
+
* It can be a user message, an assistant message, or a tool message.
|
|
8397
|
+
*/
|
|
8398
|
+
declare type ModelMessage_2 = SystemModelMessage_2 | UserModelMessage_2 | AssistantModelMessage_2 | ToolModelMessage_2;
|
|
8399
|
+
|
|
7566
8400
|
export declare const modelMessageSchema: z.ZodType<ModelMessage>;
|
|
7567
8401
|
|
|
7568
8402
|
declare type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
7569
8403
|
|
|
8404
|
+
declare type NeverOptional_2<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
|
8405
|
+
|
|
7570
8406
|
/**
|
|
7571
8407
|
* Thrown when the AI provider fails to generate any content.
|
|
7572
8408
|
*/
|
|
@@ -7659,6 +8495,15 @@ export declare class NoOutputGeneratedError extends AISDKError {
|
|
|
7659
8495
|
*/
|
|
7660
8496
|
declare function normalizeHeaders(headers: HeadersInit | Record<string, string | undefined> | Array<[string, string | undefined]> | undefined): Record<string, string>;
|
|
7661
8497
|
|
|
8498
|
+
/**
|
|
8499
|
+
* Normalizes different header inputs into a plain record with lower-case keys.
|
|
8500
|
+
* Entries with `undefined` or `null` values are removed.
|
|
8501
|
+
*
|
|
8502
|
+
* @param headers - Input headers (`Headers`, tuples array, plain record) to normalize.
|
|
8503
|
+
* @returns A record containing the normalized header entries.
|
|
8504
|
+
*/
|
|
8505
|
+
declare function normalizeHeaders_2(headers: HeadersInit | Record<string, string | undefined> | Array<[string, string | undefined]> | undefined): Record<string, string>;
|
|
8506
|
+
|
|
7662
8507
|
/**
|
|
7663
8508
|
* Error that is thrown when no speech audio was generated.
|
|
7664
8509
|
*/
|
|
@@ -7685,7 +8530,7 @@ export declare class NoSuchModelError extends AISDKError {
|
|
|
7685
8530
|
}
|
|
7686
8531
|
|
|
7687
8532
|
export declare class NoSuchProviderError extends NoSuchModelError {
|
|
7688
|
-
private readonly [
|
|
8533
|
+
private readonly [symbol_4];
|
|
7689
8534
|
readonly providerId: string;
|
|
7690
8535
|
readonly availableProviders: string[];
|
|
7691
8536
|
constructor({ modelId, modelType, providerId, availableProviders, message, }: {
|
|
@@ -7838,7 +8683,7 @@ export declare interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT ex
|
|
|
7838
8683
|
/** Additional HTTP headers sent with the request. */
|
|
7839
8684
|
readonly headers: Record<string, string | undefined> | undefined;
|
|
7840
8685
|
/** Additional provider-specific options. */
|
|
7841
|
-
readonly providerOptions:
|
|
8686
|
+
readonly providerOptions: ProviderOptions_2 | undefined;
|
|
7842
8687
|
/**
|
|
7843
8688
|
* Condition(s) for stopping the generation.
|
|
7844
8689
|
* When the condition is an array, any of the conditions can be met to stop.
|
|
@@ -7904,7 +8749,7 @@ export declare interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPU
|
|
|
7904
8749
|
/** Array of results from previous steps (empty for first step). */
|
|
7905
8750
|
readonly steps: ReadonlyArray<StepResult<TOOLS>>;
|
|
7906
8751
|
/** Additional provider-specific options for this step. */
|
|
7907
|
-
readonly providerOptions:
|
|
8752
|
+
readonly providerOptions: ProviderOptions_2 | undefined;
|
|
7908
8753
|
/**
|
|
7909
8754
|
* Timeout configuration for the generation.
|
|
7910
8755
|
* Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
|
|
@@ -8252,6 +9097,30 @@ declare function parseJSON(options: {
|
|
|
8252
9097
|
* @returns {Promise<T>} - The parsed object.
|
|
8253
9098
|
*/
|
|
8254
9099
|
declare function parseJSON<T>(options: {
|
|
9100
|
+
text: string;
|
|
9101
|
+
schema: FlexibleSchema_2<T>;
|
|
9102
|
+
}): Promise<T>;
|
|
9103
|
+
|
|
9104
|
+
/**
|
|
9105
|
+
* Parses a JSON string into an unknown object.
|
|
9106
|
+
*
|
|
9107
|
+
* @param text - The JSON string to parse.
|
|
9108
|
+
* @returns {JSONValue} - The parsed JSON object.
|
|
9109
|
+
*/
|
|
9110
|
+
declare function parseJSON_2(options: {
|
|
9111
|
+
text: string;
|
|
9112
|
+
schema?: undefined;
|
|
9113
|
+
}): Promise<JSONValue_2>;
|
|
9114
|
+
|
|
9115
|
+
/**
|
|
9116
|
+
* Parses a JSON string into a strongly-typed object using the provided schema.
|
|
9117
|
+
*
|
|
9118
|
+
* @template T - The type of the object to parse the JSON into.
|
|
9119
|
+
* @param {string} text - The JSON string to parse.
|
|
9120
|
+
* @param {Validator<T>} schema - The schema to use for parsing the JSON.
|
|
9121
|
+
* @returns {Promise<T>} - The parsed object.
|
|
9122
|
+
*/
|
|
9123
|
+
declare function parseJSON_2<T>(options: {
|
|
8255
9124
|
text: string;
|
|
8256
9125
|
schema: FlexibleSchema<T>;
|
|
8257
9126
|
}): Promise<T>;
|
|
@@ -8262,6 +9131,14 @@ declare function parseJSON<T>(options: {
|
|
|
8262
9131
|
export declare function parseJsonEventStream<T>({ stream, schema, }: {
|
|
8263
9132
|
stream: ReadableStream<Uint8Array>;
|
|
8264
9133
|
schema: FlexibleSchema<T>;
|
|
9134
|
+
}): ReadableStream<ParseResult_2<T>>;
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* Parses a JSON event stream into a stream of parsed JSON objects.
|
|
9138
|
+
*/
|
|
9139
|
+
declare function parseJsonEventStream_2<T>({ stream, schema, }: {
|
|
9140
|
+
stream: ReadableStream<Uint8Array>;
|
|
9141
|
+
schema: FlexibleSchema_2<T>;
|
|
8265
9142
|
}): ReadableStream<ParseResult<T>>;
|
|
8266
9143
|
|
|
8267
9144
|
export declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
|
@@ -8270,6 +9147,12 @@ export declare function parsePartialJson(jsonText: string | undefined): Promise<
|
|
|
8270
9147
|
}>;
|
|
8271
9148
|
|
|
8272
9149
|
declare function parseProviderOptions<OPTIONS>({ provider, providerOptions, schema, }: {
|
|
9150
|
+
provider: string;
|
|
9151
|
+
providerOptions: Record<string, unknown> | undefined;
|
|
9152
|
+
schema: FlexibleSchema_2<OPTIONS>;
|
|
9153
|
+
}): Promise<OPTIONS | undefined>;
|
|
9154
|
+
|
|
9155
|
+
declare function parseProviderOptions_2<OPTIONS>({ provider, providerOptions, schema, }: {
|
|
8273
9156
|
provider: string;
|
|
8274
9157
|
providerOptions: Record<string, unknown> | undefined;
|
|
8275
9158
|
schema: FlexibleSchema<OPTIONS>;
|
|
@@ -8285,10 +9168,20 @@ declare type ParseResult<T> = {
|
|
|
8285
9168
|
rawValue: unknown;
|
|
8286
9169
|
};
|
|
8287
9170
|
|
|
8288
|
-
declare type
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
9171
|
+
declare type ParseResult_2<T> = {
|
|
9172
|
+
success: true;
|
|
9173
|
+
value: T;
|
|
9174
|
+
rawValue: unknown;
|
|
9175
|
+
} | {
|
|
9176
|
+
success: false;
|
|
9177
|
+
error: JSONParseError | TypeValidationError;
|
|
9178
|
+
rawValue: unknown;
|
|
9179
|
+
};
|
|
9180
|
+
|
|
9181
|
+
declare type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
9182
|
+
|
|
9183
|
+
declare type PartialObject<ObjectType extends object> = {
|
|
9184
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
|
8292
9185
|
};
|
|
8293
9186
|
|
|
8294
9187
|
declare type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
@@ -8509,6 +9402,20 @@ declare const postFormDataToApi: <T>({ url, headers, formData, failedResponseHan
|
|
|
8509
9402
|
responseHeaders?: Record<string, string>;
|
|
8510
9403
|
}>;
|
|
8511
9404
|
|
|
9405
|
+
declare const postFormDataToApi_2: <T>({ url, headers, formData, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
|
9406
|
+
url: string;
|
|
9407
|
+
headers?: Record<string, string | undefined>;
|
|
9408
|
+
formData: FormData;
|
|
9409
|
+
failedResponseHandler: ResponseHandler_2<APICallError>;
|
|
9410
|
+
successfulResponseHandler: ResponseHandler_2<T>;
|
|
9411
|
+
abortSignal?: AbortSignal;
|
|
9412
|
+
fetch?: FetchFunction_2;
|
|
9413
|
+
}) => Promise<{
|
|
9414
|
+
value: T;
|
|
9415
|
+
rawValue?: unknown;
|
|
9416
|
+
responseHeaders?: Record<string, string>;
|
|
9417
|
+
}>;
|
|
9418
|
+
|
|
8512
9419
|
declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
|
8513
9420
|
url: string;
|
|
8514
9421
|
headers?: Record<string, string | undefined>;
|
|
@@ -8523,6 +9430,20 @@ declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, su
|
|
|
8523
9430
|
responseHeaders?: Record<string, string>;
|
|
8524
9431
|
}>;
|
|
8525
9432
|
|
|
9433
|
+
declare const postJsonToApi_2: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
|
9434
|
+
url: string;
|
|
9435
|
+
headers?: Record<string, string | undefined>;
|
|
9436
|
+
body: unknown;
|
|
9437
|
+
failedResponseHandler: ResponseHandler_2<APICallError>;
|
|
9438
|
+
successfulResponseHandler: ResponseHandler_2<T>;
|
|
9439
|
+
abortSignal?: AbortSignal;
|
|
9440
|
+
fetch?: FetchFunction_2;
|
|
9441
|
+
}) => Promise<{
|
|
9442
|
+
value: T;
|
|
9443
|
+
rawValue?: unknown;
|
|
9444
|
+
responseHeaders?: Record<string, string>;
|
|
9445
|
+
}>;
|
|
9446
|
+
|
|
8526
9447
|
declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
|
|
8527
9448
|
url: string;
|
|
8528
9449
|
headers?: Record<string, string | undefined>;
|
|
@@ -8540,6 +9461,23 @@ declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, fa
|
|
|
8540
9461
|
responseHeaders?: Record<string, string>;
|
|
8541
9462
|
}>;
|
|
8542
9463
|
|
|
9464
|
+
declare const postToApi_2: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
|
|
9465
|
+
url: string;
|
|
9466
|
+
headers?: Record<string, string | undefined>;
|
|
9467
|
+
body: {
|
|
9468
|
+
content: string | FormData | Uint8Array;
|
|
9469
|
+
values: unknown;
|
|
9470
|
+
};
|
|
9471
|
+
failedResponseHandler: ResponseHandler_2<Error>;
|
|
9472
|
+
successfulResponseHandler: ResponseHandler_2<T>;
|
|
9473
|
+
abortSignal?: AbortSignal;
|
|
9474
|
+
fetch?: FetchFunction_2;
|
|
9475
|
+
}) => Promise<{
|
|
9476
|
+
value: T;
|
|
9477
|
+
rawValue?: unknown;
|
|
9478
|
+
responseHeaders?: Record<string, string>;
|
|
9479
|
+
}>;
|
|
9480
|
+
|
|
8543
9481
|
export declare type PrepareReconnectToStreamRequest = (options: {
|
|
8544
9482
|
id: string;
|
|
8545
9483
|
requestMetadata: unknown;
|
|
@@ -8662,7 +9600,7 @@ export declare type PrepareStepResult<TOOLS extends Record<string, Tool> = Recor
|
|
|
8662
9600
|
* Can be used to pass provider-specific configuration such as
|
|
8663
9601
|
* container IDs for Anthropic's code execution.
|
|
8664
9602
|
*/
|
|
8665
|
-
providerOptions?:
|
|
9603
|
+
providerOptions?: ProviderOptions_2;
|
|
8666
9604
|
} & PrepareStepCallSettings) | undefined;
|
|
8667
9605
|
|
|
8668
9606
|
/**
|
|
@@ -8765,15 +9703,14 @@ export declare type Provider = {
|
|
|
8765
9703
|
* This is needed to enable provider-specific functionality that can be
|
|
8766
9704
|
* fully encapsulated in the provider.
|
|
8767
9705
|
*/
|
|
8768
|
-
export declare type ProviderMetadata = SharedV3ProviderMetadata;
|
|
8769
|
-
|
|
9706
|
+
export declare type ProviderMetadata = SharedV3ProviderMetadata;
|
|
8770
9707
|
/**
|
|
8771
9708
|
* Additional provider-specific options.
|
|
8772
9709
|
*
|
|
8773
9710
|
* They are passed through to the provider from the AI SDK and enable
|
|
8774
9711
|
* provider-specific functionality that can be fully encapsulated in the provider.
|
|
8775
9712
|
*/
|
|
8776
|
-
declare type
|
|
9713
|
+
declare type ProviderOptions_2 = SharedV3ProviderOptions;
|
|
8777
9714
|
|
|
8778
9715
|
export declare interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV3> = Record<string, ProviderV3>, SEPARATOR extends string = ':'> {
|
|
8779
9716
|
languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['languageModel']>>[0]>}` : never): LanguageModelV3;
|
|
@@ -8791,6 +9728,15 @@ export declare interface ProviderRegistryProvider<PROVIDERS extends Record<strin
|
|
|
8791
9728
|
}
|
|
8792
9729
|
|
|
8793
9730
|
declare type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
|
9731
|
+
execute?: ToolExecuteFunction_2<INPUT, OUTPUT>;
|
|
9732
|
+
needsApproval?: Tool_2<INPUT, OUTPUT>['needsApproval'];
|
|
9733
|
+
toModelOutput?: Tool_2<INPUT, OUTPUT>['toModelOutput'];
|
|
9734
|
+
onInputStart?: Tool_2<INPUT, OUTPUT>['onInputStart'];
|
|
9735
|
+
onInputDelta?: Tool_2<INPUT, OUTPUT>['onInputDelta'];
|
|
9736
|
+
onInputAvailable?: Tool_2<INPUT, OUTPUT>['onInputAvailable'];
|
|
9737
|
+
}) => Tool_2<INPUT, OUTPUT>;
|
|
9738
|
+
|
|
9739
|
+
declare type ProviderToolFactory_2<INPUT, ARGS extends object> = <OUTPUT>(options: ARGS & {
|
|
8794
9740
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
8795
9741
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
8796
9742
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -8800,6 +9746,15 @@ declare type ProviderToolFactory<INPUT, ARGS extends object> = <OUTPUT>(options:
|
|
|
8800
9746
|
}) => Tool<INPUT, OUTPUT>;
|
|
8801
9747
|
|
|
8802
9748
|
declare type ProviderToolFactoryWithOutputSchema<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
|
9749
|
+
execute?: ToolExecuteFunction_2<INPUT, OUTPUT>;
|
|
9750
|
+
needsApproval?: Tool_2<INPUT, OUTPUT>['needsApproval'];
|
|
9751
|
+
toModelOutput?: Tool_2<INPUT, OUTPUT>['toModelOutput'];
|
|
9752
|
+
onInputStart?: Tool_2<INPUT, OUTPUT>['onInputStart'];
|
|
9753
|
+
onInputDelta?: Tool_2<INPUT, OUTPUT>['onInputDelta'];
|
|
9754
|
+
onInputAvailable?: Tool_2<INPUT, OUTPUT>['onInputAvailable'];
|
|
9755
|
+
}) => Tool_2<INPUT, OUTPUT>;
|
|
9756
|
+
|
|
9757
|
+
declare type ProviderToolFactoryWithOutputSchema_2<INPUT, OUTPUT, ARGS extends object> = (options: ARGS & {
|
|
8803
9758
|
execute?: ToolExecuteFunction<INPUT, OUTPUT>;
|
|
8804
9759
|
needsApproval?: Tool<INPUT, OUTPUT>['needsApproval'];
|
|
8805
9760
|
toModelOutput?: Tool<INPUT, OUTPUT>['toModelOutput'];
|
|
@@ -8982,6 +9937,25 @@ declare function readResponseWithSizeLimit({ response, url, maxBytes, }: {
|
|
|
8982
9937
|
maxBytes?: number;
|
|
8983
9938
|
}): Promise<Uint8Array>;
|
|
8984
9939
|
|
|
9940
|
+
/**
|
|
9941
|
+
* Reads a fetch Response body with a size limit to prevent memory exhaustion.
|
|
9942
|
+
*
|
|
9943
|
+
* Checks the Content-Length header for early rejection, then reads the body
|
|
9944
|
+
* incrementally via ReadableStream and aborts with a DownloadError when the
|
|
9945
|
+
* limit is exceeded.
|
|
9946
|
+
*
|
|
9947
|
+
* @param response - The fetch Response to read.
|
|
9948
|
+
* @param url - The URL being downloaded (used in error messages).
|
|
9949
|
+
* @param maxBytes - Maximum allowed bytes. Defaults to DEFAULT_MAX_DOWNLOAD_SIZE.
|
|
9950
|
+
* @returns A Uint8Array containing the response body.
|
|
9951
|
+
* @throws DownloadError if the response exceeds maxBytes.
|
|
9952
|
+
*/
|
|
9953
|
+
declare function readResponseWithSizeLimit_2({ response, url, maxBytes, }: {
|
|
9954
|
+
response: Response;
|
|
9955
|
+
url: string;
|
|
9956
|
+
maxBytes?: number;
|
|
9957
|
+
}): Promise<Uint8Array>;
|
|
9958
|
+
|
|
8985
9959
|
/**
|
|
8986
9960
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
8987
9961
|
*
|
|
@@ -9034,6 +10008,23 @@ declare interface ReasoningPart {
|
|
|
9034
10008
|
providerOptions?: ProviderOptions;
|
|
9035
10009
|
}
|
|
9036
10010
|
|
|
10011
|
+
/**
|
|
10012
|
+
* Reasoning content part of a prompt. It contains a reasoning.
|
|
10013
|
+
*/
|
|
10014
|
+
declare interface ReasoningPart_2 {
|
|
10015
|
+
type: 'reasoning';
|
|
10016
|
+
/**
|
|
10017
|
+
* The reasoning text.
|
|
10018
|
+
*/
|
|
10019
|
+
text: string;
|
|
10020
|
+
/**
|
|
10021
|
+
* Additional provider-specific metadata. They are passed through
|
|
10022
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
10023
|
+
* functionality that can be fully encapsulated in the provider.
|
|
10024
|
+
*/
|
|
10025
|
+
providerOptions?: ProviderOptions_2;
|
|
10026
|
+
}
|
|
10027
|
+
|
|
9037
10028
|
/**
|
|
9038
10029
|
* A reasoning part of a message.
|
|
9039
10030
|
*/
|
|
@@ -9069,6 +10060,13 @@ export declare function registerTelemetryIntegration(integration: TelemetryInteg
|
|
|
9069
10060
|
*/
|
|
9070
10061
|
declare function removeUndefinedEntries<T>(record: Record<string, T | undefined>): Record<string, T>;
|
|
9071
10062
|
|
|
10063
|
+
/**
|
|
10064
|
+
* Removes entries from a record where the value is null or undefined.
|
|
10065
|
+
* @param record - The input object whose entries may be null or undefined.
|
|
10066
|
+
* @returns A new object containing only entries with non-null and non-undefined values.
|
|
10067
|
+
*/
|
|
10068
|
+
declare function removeUndefinedEntries_2<T>(record: Record<string, T | undefined>): Record<string, T>;
|
|
10069
|
+
|
|
9072
10070
|
/**
|
|
9073
10071
|
* A function that attempts to repair the raw output of the model
|
|
9074
10072
|
* to enable JSON parsing.
|
|
@@ -9137,7 +10135,7 @@ export declare function rerank<VALUE extends JSONObject | string>({ model: model
|
|
|
9137
10135
|
* to the provider from the AI SDK and enable provider-specific
|
|
9138
10136
|
* functionality that can be fully encapsulated in the provider.
|
|
9139
10137
|
*/
|
|
9140
|
-
providerOptions?:
|
|
10138
|
+
providerOptions?: ProviderOptions_2;
|
|
9141
10139
|
}): Promise<RerankResult<VALUE>>;
|
|
9142
10140
|
|
|
9143
10141
|
/**
|
|
@@ -9317,12 +10315,20 @@ export declare interface RerankResult<VALUE> {
|
|
|
9317
10315
|
|
|
9318
10316
|
declare type Resolvable<T> = MaybePromiseLike<T> | (() => MaybePromiseLike<T>);
|
|
9319
10317
|
|
|
10318
|
+
declare type Resolvable_2<T> = MaybePromiseLike_2<T> | (() => MaybePromiseLike_2<T>);
|
|
10319
|
+
|
|
9320
10320
|
/**
|
|
9321
10321
|
* Resolves a value that could be a raw value, a Promise, a function returning a value,
|
|
9322
10322
|
* or a function returning a Promise.
|
|
9323
10323
|
*/
|
|
9324
10324
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
|
9325
10325
|
|
|
10326
|
+
/**
|
|
10327
|
+
* Resolves a value that could be a raw value, a Promise, a function returning a value,
|
|
10328
|
+
* or a function returning a Promise.
|
|
10329
|
+
*/
|
|
10330
|
+
declare function resolve_2<T>(value: Resolvable_2<T>): Promise<T>;
|
|
10331
|
+
|
|
9326
10332
|
declare type ResponseHandler<RETURN_TYPE> = (options: {
|
|
9327
10333
|
url: string;
|
|
9328
10334
|
requestBodyValues: unknown;
|
|
@@ -9333,6 +10339,16 @@ declare type ResponseHandler<RETURN_TYPE> = (options: {
|
|
|
9333
10339
|
responseHeaders?: Record<string, string>;
|
|
9334
10340
|
}>;
|
|
9335
10341
|
|
|
10342
|
+
declare type ResponseHandler_2<RETURN_TYPE> = (options: {
|
|
10343
|
+
url: string;
|
|
10344
|
+
requestBodyValues: unknown;
|
|
10345
|
+
response: Response;
|
|
10346
|
+
}) => PromiseLike<{
|
|
10347
|
+
value: RETURN_TYPE;
|
|
10348
|
+
rawValue?: unknown;
|
|
10349
|
+
responseHeaders?: Record<string, string>;
|
|
10350
|
+
}>;
|
|
10351
|
+
|
|
9336
10352
|
/**
|
|
9337
10353
|
* A message that was generated during the generation process.
|
|
9338
10354
|
* It can be either an assistant message or a tool message.
|
|
@@ -9344,6 +10360,11 @@ declare type RetryDelayProvider = ({ error, exponentialBackoffDelay, }: {
|
|
|
9344
10360
|
exponentialBackoffDelay: number;
|
|
9345
10361
|
}) => number;
|
|
9346
10362
|
|
|
10363
|
+
declare type RetryDelayProvider_2 = ({ error, exponentialBackoffDelay, }: {
|
|
10364
|
+
error: unknown;
|
|
10365
|
+
exponentialBackoffDelay: number;
|
|
10366
|
+
}) => number;
|
|
10367
|
+
|
|
9347
10368
|
export declare class RetryError extends AISDKError {
|
|
9348
10369
|
private readonly [symbol$1_2];
|
|
9349
10370
|
readonly reason: RetryErrorReason_2;
|
|
@@ -9363,12 +10384,22 @@ declare type RetryErrorFactory = ({ message, reason, errors, }: {
|
|
|
9363
10384
|
errors: Array<unknown>;
|
|
9364
10385
|
}) => unknown;
|
|
9365
10386
|
|
|
10387
|
+
declare type RetryErrorFactory_2 = ({ message, reason, errors, }: {
|
|
10388
|
+
message: string;
|
|
10389
|
+
reason: RetryErrorReason_3;
|
|
10390
|
+
errors: Array<unknown>;
|
|
10391
|
+
}) => unknown;
|
|
10392
|
+
|
|
9366
10393
|
declare type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable';
|
|
9367
10394
|
|
|
9368
10395
|
declare type RetryErrorReason_2 = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
|
|
9369
10396
|
|
|
10397
|
+
declare type RetryErrorReason_3 = 'maxRetriesExceeded' | 'errorNotRetryable';
|
|
10398
|
+
|
|
9370
10399
|
declare type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
|
|
9371
10400
|
|
|
10401
|
+
declare type RetryFunction_2 = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
|
|
10402
|
+
|
|
9372
10403
|
/**
|
|
9373
10404
|
* Retries a failed operation with exponential backoff.
|
|
9374
10405
|
*/
|
|
@@ -9382,6 +10413,19 @@ declare const retryWithExponentialBackoff: ({ maxRetries, initialDelayInMs, back
|
|
|
9382
10413
|
createRetryError?: RetryErrorFactory;
|
|
9383
10414
|
}) => RetryFunction;
|
|
9384
10415
|
|
|
10416
|
+
/**
|
|
10417
|
+
* Retries a failed operation with exponential backoff.
|
|
10418
|
+
*/
|
|
10419
|
+
declare const retryWithExponentialBackoff_2: ({ maxRetries, initialDelayInMs, backoffFactor, abortSignal, shouldRetry, getDelayInMs, createRetryError, }: {
|
|
10420
|
+
maxRetries?: number;
|
|
10421
|
+
initialDelayInMs?: number;
|
|
10422
|
+
backoffFactor?: number;
|
|
10423
|
+
abortSignal?: AbortSignal;
|
|
10424
|
+
shouldRetry: ShouldRetryFunction_2;
|
|
10425
|
+
getDelayInMs?: RetryDelayProvider_2;
|
|
10426
|
+
createRetryError?: RetryErrorFactory_2;
|
|
10427
|
+
}) => RetryFunction_2;
|
|
10428
|
+
|
|
9385
10429
|
/**
|
|
9386
10430
|
* Safely parses a JSON string and returns the result as an object of type `unknown`.
|
|
9387
10431
|
*
|
|
@@ -9403,9 +10447,33 @@ declare function safeParseJSON(options: {
|
|
|
9403
10447
|
*/
|
|
9404
10448
|
declare function safeParseJSON<T>(options: {
|
|
9405
10449
|
text: string;
|
|
9406
|
-
schema:
|
|
10450
|
+
schema: FlexibleSchema_2<T>;
|
|
9407
10451
|
}): Promise<ParseResult<T>>;
|
|
9408
10452
|
|
|
10453
|
+
/**
|
|
10454
|
+
* Safely parses a JSON string and returns the result as an object of type `unknown`.
|
|
10455
|
+
*
|
|
10456
|
+
* @param text - The JSON string to parse.
|
|
10457
|
+
* @returns {Promise<object>} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
|
|
10458
|
+
*/
|
|
10459
|
+
declare function safeParseJSON_2(options: {
|
|
10460
|
+
text: string;
|
|
10461
|
+
schema?: undefined;
|
|
10462
|
+
}): Promise<ParseResult_2<JSONValue_2>>;
|
|
10463
|
+
|
|
10464
|
+
/**
|
|
10465
|
+
* Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
|
|
10466
|
+
*
|
|
10467
|
+
* @template T - The type of the object to parse the JSON into.
|
|
10468
|
+
* @param {string} text - The JSON string to parse.
|
|
10469
|
+
* @param {Validator<T>} schema - The schema to use for parsing the JSON.
|
|
10470
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
10471
|
+
*/
|
|
10472
|
+
declare function safeParseJSON_2<T>(options: {
|
|
10473
|
+
text: string;
|
|
10474
|
+
schema: FlexibleSchema<T>;
|
|
10475
|
+
}): Promise<ParseResult_2<T>>;
|
|
10476
|
+
|
|
9409
10477
|
/**
|
|
9410
10478
|
* Safely validates the types of an unknown object using a schema and
|
|
9411
10479
|
* return a strongly-typed object.
|
|
@@ -9417,6 +10485,30 @@ declare function safeParseJSON<T>(options: {
|
|
|
9417
10485
|
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
9418
10486
|
*/
|
|
9419
10487
|
declare function safeValidateTypes<OBJECT>({ value, schema, context, }: {
|
|
10488
|
+
value: unknown;
|
|
10489
|
+
schema: FlexibleSchema_2<OBJECT>;
|
|
10490
|
+
context?: TypeValidationContext;
|
|
10491
|
+
}): Promise<{
|
|
10492
|
+
success: true;
|
|
10493
|
+
value: OBJECT;
|
|
10494
|
+
rawValue: unknown;
|
|
10495
|
+
} | {
|
|
10496
|
+
success: false;
|
|
10497
|
+
error: TypeValidationError;
|
|
10498
|
+
rawValue: unknown;
|
|
10499
|
+
}>;
|
|
10500
|
+
|
|
10501
|
+
/**
|
|
10502
|
+
* Safely validates the types of an unknown object using a schema and
|
|
10503
|
+
* return a strongly-typed object.
|
|
10504
|
+
*
|
|
10505
|
+
* @template T - The type of the object to validate.
|
|
10506
|
+
* @param {string} options.value - The JSON object to validate.
|
|
10507
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
10508
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
10509
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
10510
|
+
*/
|
|
10511
|
+
declare function safeValidateTypes_2<OBJECT>({ value, schema, context, }: {
|
|
9420
10512
|
value: unknown;
|
|
9421
10513
|
schema: FlexibleSchema<OBJECT>;
|
|
9422
10514
|
context?: TypeValidationContext;
|
|
@@ -9446,6 +10538,26 @@ export declare type SafeValidateUIMessagesResult<UI_MESSAGE extends UIMessage> =
|
|
|
9446
10538
|
};
|
|
9447
10539
|
|
|
9448
10540
|
export declare type Schema<OBJECT = unknown> = {
|
|
10541
|
+
/**
|
|
10542
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
|
10543
|
+
*/
|
|
10544
|
+
[schemaSymbol_2]: true;
|
|
10545
|
+
/**
|
|
10546
|
+
* Schema type for inference.
|
|
10547
|
+
*/
|
|
10548
|
+
_type: OBJECT;
|
|
10549
|
+
/**
|
|
10550
|
+
* Optional. Validates that the structure of a value matches this schema,
|
|
10551
|
+
* and returns a typed version of the value if it does.
|
|
10552
|
+
*/
|
|
10553
|
+
readonly validate?: (value: unknown) => ValidationResult_2<OBJECT> | PromiseLike<ValidationResult_2<OBJECT>>;
|
|
10554
|
+
/**
|
|
10555
|
+
* The JSON Schema for the schema. It is passed to the providers.
|
|
10556
|
+
*/
|
|
10557
|
+
readonly jsonSchema: JSONSchema7 | PromiseLike<JSONSchema7>;
|
|
10558
|
+
};
|
|
10559
|
+
|
|
10560
|
+
declare type Schema_2<OBJECT = unknown> = {
|
|
9449
10561
|
/**
|
|
9450
10562
|
* Used to mark schemas so we can support both Zod and custom schemas.
|
|
9451
10563
|
*/
|
|
@@ -9470,8 +10582,15 @@ export declare type Schema<OBJECT = unknown> = {
|
|
|
9470
10582
|
*/
|
|
9471
10583
|
declare const schemaSymbol: unique symbol;
|
|
9472
10584
|
|
|
10585
|
+
/**
|
|
10586
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
|
10587
|
+
*/
|
|
10588
|
+
declare const schemaSymbol_2: unique symbol;
|
|
10589
|
+
|
|
9473
10590
|
declare function secureJsonParse(text: string): any;
|
|
9474
10591
|
|
|
10592
|
+
declare function secureJsonParse_2(text: string): any;
|
|
10593
|
+
|
|
9475
10594
|
export declare class SerialJobExecutor {
|
|
9476
10595
|
private queue;
|
|
9477
10596
|
private isProcessing;
|
|
@@ -9622,6 +10741,8 @@ declare type SharedV3Warning = {
|
|
|
9622
10741
|
|
|
9623
10742
|
declare type ShouldRetryFunction = (error: unknown) => boolean | Promise<boolean>;
|
|
9624
10743
|
|
|
10744
|
+
declare type ShouldRetryFunction_2 = (error: unknown) => boolean | Promise<boolean>;
|
|
10745
|
+
|
|
9625
10746
|
/**
|
|
9626
10747
|
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
9627
10748
|
*
|
|
@@ -10390,6 +11511,12 @@ declare type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> &
|
|
|
10390
11511
|
};
|
|
10391
11512
|
};
|
|
10392
11513
|
|
|
11514
|
+
declare type StandardSchema_2<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
|
|
11515
|
+
readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & {
|
|
11516
|
+
readonly jsonSchema?: StandardJSONSchemaV1.Converter;
|
|
11517
|
+
};
|
|
11518
|
+
};
|
|
11519
|
+
|
|
10393
11520
|
/** The Standard Schema interface. */
|
|
10394
11521
|
declare interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
10395
11522
|
/** The Standard Schema properties. */
|
|
@@ -10570,7 +11697,7 @@ export declare type StepResult<TOOLS extends ToolSet> = {
|
|
|
10570
11697
|
/**
|
|
10571
11698
|
* The reasoning that was generated during the generation.
|
|
10572
11699
|
*/
|
|
10573
|
-
readonly reasoning: Array<
|
|
11700
|
+
readonly reasoning: Array<ReasoningPart_2>;
|
|
10574
11701
|
/**
|
|
10575
11702
|
* The reasoning text that was generated during the generation.
|
|
10576
11703
|
*/
|
|
@@ -10674,6 +11801,19 @@ declare interface StreamingToolCallDelta {
|
|
|
10674
11801
|
} | null;
|
|
10675
11802
|
}
|
|
10676
11803
|
|
|
11804
|
+
/**
|
|
11805
|
+
* Minimal interface for a streaming tool call delta from an OpenAI-compatible API.
|
|
11806
|
+
*/
|
|
11807
|
+
declare interface StreamingToolCallDelta_2 {
|
|
11808
|
+
index?: number | null;
|
|
11809
|
+
id?: string | null;
|
|
11810
|
+
type?: string | null;
|
|
11811
|
+
function?: {
|
|
11812
|
+
name?: string | null;
|
|
11813
|
+
arguments?: string | null;
|
|
11814
|
+
} | null;
|
|
11815
|
+
}
|
|
11816
|
+
|
|
10677
11817
|
/**
|
|
10678
11818
|
* Tracks streaming tool call state across multiple deltas from an
|
|
10679
11819
|
* OpenAI-compatible chat completion stream.
|
|
@@ -10704,8 +11844,40 @@ declare class StreamingToolCallTracker<DELTA extends StreamingToolCallDelta = St
|
|
|
10704
11844
|
private finishToolCall;
|
|
10705
11845
|
}
|
|
10706
11846
|
|
|
11847
|
+
/**
|
|
11848
|
+
* Tracks streaming tool call state across multiple deltas from an
|
|
11849
|
+
* OpenAI-compatible chat completion stream.
|
|
11850
|
+
*/
|
|
11851
|
+
declare class StreamingToolCallTracker_2<DELTA extends StreamingToolCallDelta_2 = StreamingToolCallDelta_2> {
|
|
11852
|
+
private toolCalls;
|
|
11853
|
+
private toolCallsById;
|
|
11854
|
+
private toolCallsByIndex;
|
|
11855
|
+
private usedToolCallIds;
|
|
11856
|
+
private nextGeneratedIdSuffixes;
|
|
11857
|
+
private readonly controller;
|
|
11858
|
+
private readonly _generateId;
|
|
11859
|
+
private readonly typeValidation;
|
|
11860
|
+
private readonly extractMetadata?;
|
|
11861
|
+
private readonly buildToolCallProviderMetadata?;
|
|
11862
|
+
constructor(controller: StreamingToolCallTrackerController_2, options?: StreamingToolCallTrackerOptions_2<DELTA>);
|
|
11863
|
+
processDelta(toolCallDelta: DELTA): void;
|
|
11864
|
+
flush(): void;
|
|
11865
|
+
private resolveToolCall;
|
|
11866
|
+
private filterToolCallsByName;
|
|
11867
|
+
private resolveMatchingToolCall;
|
|
11868
|
+
private processNewToolCall;
|
|
11869
|
+
private associateWireId;
|
|
11870
|
+
private associateIndex;
|
|
11871
|
+
private createToolCallId;
|
|
11872
|
+
private getNonBlankString;
|
|
11873
|
+
private processExistingToolCall;
|
|
11874
|
+
private finishToolCall;
|
|
11875
|
+
}
|
|
11876
|
+
|
|
10707
11877
|
declare type StreamingToolCallTrackerController = Pick<TransformStreamDefaultController<LanguageModelV3StreamPart>, 'enqueue'>;
|
|
10708
11878
|
|
|
11879
|
+
declare type StreamingToolCallTrackerController_2 = Pick<TransformStreamDefaultController<LanguageModelV3StreamPart>, 'enqueue'>;
|
|
11880
|
+
|
|
10709
11881
|
declare interface StreamingToolCallTrackerOptions<DELTA extends StreamingToolCallDelta = StreamingToolCallDelta> {
|
|
10710
11882
|
/**
|
|
10711
11883
|
* ID generator function for tool call IDs.
|
|
@@ -10731,29 +11903,54 @@ declare interface StreamingToolCallTrackerOptions<DELTA extends StreamingToolCal
|
|
|
10731
11903
|
buildToolCallProviderMetadata?: (metadata: SharedV3ProviderMetadata | undefined) => SharedV3ProviderMetadata | undefined;
|
|
10732
11904
|
}
|
|
10733
11905
|
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
11906
|
+
declare interface StreamingToolCallTrackerOptions_2<DELTA extends StreamingToolCallDelta_2 = StreamingToolCallDelta_2> {
|
|
11907
|
+
/**
|
|
11908
|
+
* ID generator function for tool call IDs.
|
|
11909
|
+
* Blank or repeated outputs are converted to usable unique IDs.
|
|
11910
|
+
* Defaults to the standard generateId.
|
|
11911
|
+
*/
|
|
11912
|
+
generateId?: () => string;
|
|
11913
|
+
/**
|
|
11914
|
+
* How to validate the `type` field on new tool call deltas.
|
|
11915
|
+
* - `'none'`: no validation (default)
|
|
11916
|
+
* - `'if-present'`: throw if type is present and not `'function'`
|
|
11917
|
+
* - `'required'`: throw if type is not exactly `'function'`
|
|
11918
|
+
*/
|
|
11919
|
+
typeValidation?: 'none' | 'if-present' | 'required';
|
|
11920
|
+
/**
|
|
11921
|
+
* Extract provider-specific metadata from a tool call delta.
|
|
11922
|
+
* Called once when a new tool call is detected.
|
|
11923
|
+
*/
|
|
11924
|
+
extractMetadata?: (delta: DELTA) => SharedV3ProviderMetadata | undefined;
|
|
11925
|
+
/**
|
|
11926
|
+
* Build the `providerMetadata` object for a `tool-call` event.
|
|
11927
|
+
*/
|
|
11928
|
+
buildToolCallProviderMetadata?: (metadata: SharedV3ProviderMetadata | undefined) => SharedV3ProviderMetadata | undefined;
|
|
11929
|
+
}
|
|
11930
|
+
|
|
11931
|
+
/**
|
|
11932
|
+
* Generate a structured, typed object for a given prompt and schema using a language model.
|
|
11933
|
+
*
|
|
11934
|
+
* This function streams the output. If you do not want to stream the output, use `generateObject` instead.
|
|
11935
|
+
*
|
|
11936
|
+
* @param model - The language model to use.
|
|
11937
|
+
*
|
|
11938
|
+
* @param system - A system message that will be part of the prompt.
|
|
11939
|
+
* @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
|
11940
|
+
* @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
|
11941
|
+
* @param allowSystemInMessages - Whether system messages are allowed in the `prompt` or `messages` fields. When unset, system messages are allowed with a warning.
|
|
11942
|
+
*
|
|
11943
|
+
* @param maxOutputTokens - Maximum number of tokens to generate.
|
|
11944
|
+
* @param temperature - Temperature setting.
|
|
11945
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
11946
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
11947
|
+
* @param topP - Nucleus sampling.
|
|
11948
|
+
* The value is passed through to the provider. The range depends on the provider and model.
|
|
11949
|
+
* It is recommended to set either `temperature` or `topP`, but not both.
|
|
11950
|
+
* @param topK - Only sample from the top K options for each subsequent token.
|
|
11951
|
+
* Used to remove "long tail" low probability responses.
|
|
11952
|
+
* Recommended for advanced use cases only. You usually only need to use temperature.
|
|
11953
|
+
* @param presencePenalty - Presence penalty setting.
|
|
10757
11954
|
* It affects the likelihood of the model to repeat information that is already in the prompt.
|
|
10758
11955
|
* The value is passed through to the provider. The range depends on the provider and model.
|
|
10759
11956
|
* @param frequencyPenalty - Frequency penalty setting.
|
|
@@ -10843,7 +12040,7 @@ export declare function streamObject<SCHEMA extends FlexibleSchema<unknown> = Fl
|
|
|
10843
12040
|
* to the provider from the AI SDK and enable provider-specific
|
|
10844
12041
|
* functionality that can be fully encapsulated in the provider.
|
|
10845
12042
|
*/
|
|
10846
|
-
providerOptions?:
|
|
12043
|
+
providerOptions?: ProviderOptions_2;
|
|
10847
12044
|
/**
|
|
10848
12045
|
* Callback that is invoked when an error occurs during streaming.
|
|
10849
12046
|
* You can use it to log errors.
|
|
@@ -11100,7 +12297,7 @@ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends OutputI
|
|
|
11100
12297
|
* to the provider from the AI SDK and enable provider-specific
|
|
11101
12298
|
* functionality that can be fully encapsulated in the provider.
|
|
11102
12299
|
*/
|
|
11103
|
-
providerOptions?:
|
|
12300
|
+
providerOptions?: ProviderOptions_2;
|
|
11104
12301
|
/**
|
|
11105
12302
|
* @deprecated Use `activeTools` instead.
|
|
11106
12303
|
*/
|
|
@@ -11562,6 +12759,13 @@ export declare type StreamTextTransform<TOOLS extends ToolSet> = (options: {
|
|
|
11562
12759
|
*/
|
|
11563
12760
|
declare function stringifyWithBigIntAndCycles(value: unknown): string;
|
|
11564
12761
|
|
|
12762
|
+
/**
|
|
12763
|
+
* Serializes a value as JSON, representing BigInt values as decimal strings and
|
|
12764
|
+
* ancestor cycles as "[Circular]". Reused objects, toJSON methods, and other JSON
|
|
12765
|
+
* serialization behavior are preserved. Getters and toJSON methods may throw.
|
|
12766
|
+
*/
|
|
12767
|
+
declare function stringifyWithBigIntAndCycles_2(value: unknown): string;
|
|
12768
|
+
|
|
11565
12769
|
/**
|
|
11566
12770
|
* Strips file extension segments from a filename.
|
|
11567
12771
|
*
|
|
@@ -11572,6 +12776,16 @@ declare function stringifyWithBigIntAndCycles(value: unknown): string;
|
|
|
11572
12776
|
*/
|
|
11573
12777
|
declare function stripFileExtension(filename: string): string;
|
|
11574
12778
|
|
|
12779
|
+
/**
|
|
12780
|
+
* Strips file extension segments from a filename.
|
|
12781
|
+
*
|
|
12782
|
+
* Examples:
|
|
12783
|
+
* - "report.pdf" -> "report"
|
|
12784
|
+
* - "archive.tar.gz" -> "archive"
|
|
12785
|
+
* - "filename" -> "filename"
|
|
12786
|
+
*/
|
|
12787
|
+
declare function stripFileExtension_2(filename: string): string;
|
|
12788
|
+
|
|
11575
12789
|
declare const symbol$1: unique symbol;
|
|
11576
12790
|
|
|
11577
12791
|
declare const symbol$1_2: unique symbol;
|
|
@@ -11644,6 +12858,8 @@ declare const symbol_2: unique symbol;
|
|
|
11644
12858
|
|
|
11645
12859
|
declare const symbol_3: unique symbol;
|
|
11646
12860
|
|
|
12861
|
+
declare const symbol_4: unique symbol;
|
|
12862
|
+
|
|
11647
12863
|
/**
|
|
11648
12864
|
* A system message. It can contain system information.
|
|
11649
12865
|
*
|
|
@@ -11652,6 +12868,24 @@ declare const symbol_3: unique symbol;
|
|
|
11652
12868
|
* and because not all providers support several system messages.
|
|
11653
12869
|
*/
|
|
11654
12870
|
export declare type SystemModelMessage = {
|
|
12871
|
+
role: 'system';
|
|
12872
|
+
content: string;
|
|
12873
|
+
/**
|
|
12874
|
+
* Additional provider-specific metadata. They are passed through
|
|
12875
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
12876
|
+
* functionality that can be fully encapsulated in the provider.
|
|
12877
|
+
*/
|
|
12878
|
+
providerOptions?: ProviderOptions_2;
|
|
12879
|
+
};
|
|
12880
|
+
|
|
12881
|
+
/**
|
|
12882
|
+
* A system message. It can contain system information.
|
|
12883
|
+
*
|
|
12884
|
+
* Note: using the "system" part of the prompt is strongly preferred
|
|
12885
|
+
* to increase the resilience against prompt injection attacks,
|
|
12886
|
+
* and because not all providers support several system messages.
|
|
12887
|
+
*/
|
|
12888
|
+
declare type SystemModelMessage_2 = {
|
|
11655
12889
|
role: 'system';
|
|
11656
12890
|
content: string;
|
|
11657
12891
|
/**
|
|
@@ -11967,6 +13201,23 @@ export declare type TelemetrySettings = {
|
|
|
11967
13201
|
* Text content part of a prompt. It contains a string of text.
|
|
11968
13202
|
*/
|
|
11969
13203
|
export declare interface TextPart {
|
|
13204
|
+
type: 'text';
|
|
13205
|
+
/**
|
|
13206
|
+
* The text content.
|
|
13207
|
+
*/
|
|
13208
|
+
text: string;
|
|
13209
|
+
/**
|
|
13210
|
+
* Additional provider-specific metadata. They are passed through
|
|
13211
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
13212
|
+
* functionality that can be fully encapsulated in the provider.
|
|
13213
|
+
*/
|
|
13214
|
+
providerOptions?: ProviderOptions_2;
|
|
13215
|
+
}
|
|
13216
|
+
|
|
13217
|
+
/**
|
|
13218
|
+
* Text content part of a prompt. It contains a string of text.
|
|
13219
|
+
*/
|
|
13220
|
+
declare interface TextPart_2 {
|
|
11970
13221
|
type: 'text';
|
|
11971
13222
|
/**
|
|
11972
13223
|
* The text content.
|
|
@@ -12137,7 +13388,7 @@ export declare type Tool<INPUT extends JSONValue_2 | unknown | never = any, OUTP
|
|
|
12137
13388
|
* to the provider from the AI SDK and enable provider-specific
|
|
12138
13389
|
* functionality that can be fully encapsulated in the provider.
|
|
12139
13390
|
*/
|
|
12140
|
-
providerOptions?:
|
|
13391
|
+
providerOptions?: ProviderOptions_2;
|
|
12141
13392
|
/**
|
|
12142
13393
|
* Optional metadata about the tool itself (e.g. its source).
|
|
12143
13394
|
*
|
|
@@ -12166,7 +13417,7 @@ export declare type Tool<INPUT extends JSONValue_2 | unknown | never = any, OUTP
|
|
|
12166
13417
|
/**
|
|
12167
13418
|
* Whether the tool needs approval before it can be executed.
|
|
12168
13419
|
*/
|
|
12169
|
-
needsApproval?: boolean |
|
|
13420
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction_2<[INPUT] extends [never] ? unknown : INPUT>;
|
|
12170
13421
|
/**
|
|
12171
13422
|
* Strict mode setting for the tool.
|
|
12172
13423
|
*
|
|
@@ -12194,7 +13445,7 @@ export declare type Tool<INPUT extends JSONValue_2 | unknown | never = any, OUTP
|
|
|
12194
13445
|
onInputAvailable?: (options: {
|
|
12195
13446
|
input: [INPUT] extends [never] ? unknown : INPUT;
|
|
12196
13447
|
} & ToolExecutionOptions) => void | PromiseLike<void>;
|
|
12197
|
-
} &
|
|
13448
|
+
} & ToolOutputProperties_2<INPUT, OUTPUT> & {
|
|
12198
13449
|
/**
|
|
12199
13450
|
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
12200
13451
|
*
|
|
@@ -12215,7 +13466,7 @@ export declare type Tool<INPUT extends JSONValue_2 | unknown | never = any, OUTP
|
|
|
12215
13466
|
* The output of the tool call.
|
|
12216
13467
|
*/
|
|
12217
13468
|
output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>;
|
|
12218
|
-
}) =>
|
|
13469
|
+
}) => ToolResultOutput_2 | PromiseLike<ToolResultOutput_2>;
|
|
12219
13470
|
} & ({
|
|
12220
13471
|
/**
|
|
12221
13472
|
* Tool with user-defined input and output schemas.
|
|
@@ -12267,6 +13518,158 @@ export declare function tool<OUTPUT>(tool: Tool<never, OUTPUT>): Tool<never, OUT
|
|
|
12267
13518
|
|
|
12268
13519
|
export declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
|
12269
13520
|
|
|
13521
|
+
/**
|
|
13522
|
+
* A tool contains the description and the schema of the input that the tool expects.
|
|
13523
|
+
* This enables the language model to generate the input.
|
|
13524
|
+
*
|
|
13525
|
+
* The tool can also contain an optional execute function for the actual execution function of the tool.
|
|
13526
|
+
*/
|
|
13527
|
+
declare type Tool_2<INPUT extends JSONValue_2 | unknown | never = any, OUTPUT extends JSONValue_2 | unknown | never = any> = {
|
|
13528
|
+
/**
|
|
13529
|
+
* An optional description of what the tool does.
|
|
13530
|
+
* Will be used by the language model to decide whether to use the tool.
|
|
13531
|
+
* Not used for provider-defined tools.
|
|
13532
|
+
*/
|
|
13533
|
+
description?: string;
|
|
13534
|
+
/**
|
|
13535
|
+
* An optional title of the tool.
|
|
13536
|
+
*/
|
|
13537
|
+
title?: string;
|
|
13538
|
+
/**
|
|
13539
|
+
* Additional provider-specific metadata. They are passed through
|
|
13540
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
13541
|
+
* functionality that can be fully encapsulated in the provider.
|
|
13542
|
+
*/
|
|
13543
|
+
providerOptions?: ProviderOptions;
|
|
13544
|
+
/**
|
|
13545
|
+
* Optional metadata about the tool itself (e.g. its source).
|
|
13546
|
+
*
|
|
13547
|
+
* Unlike `providerOptions`, this metadata is not sent to the language
|
|
13548
|
+
* model. Instead, it is propagated onto the resulting tool call's
|
|
13549
|
+
* `toolMetadata` so consumers can read it from tool call / result parts
|
|
13550
|
+
* and UI message parts. This is useful for sources of dynamic tools (e.g.
|
|
13551
|
+
* an MCP server) to identify themselves.
|
|
13552
|
+
*/
|
|
13553
|
+
metadata?: JSONObject;
|
|
13554
|
+
/**
|
|
13555
|
+
* The schema of the input that the tool expects.
|
|
13556
|
+
* The language model will use this to generate the input.
|
|
13557
|
+
* It is also used to validate the output of the language model.
|
|
13558
|
+
*
|
|
13559
|
+
* You can use descriptions on the schema properties to make the input understandable for the language model.
|
|
13560
|
+
*/
|
|
13561
|
+
inputSchema: FlexibleSchema_2<INPUT>;
|
|
13562
|
+
/**
|
|
13563
|
+
* An optional list of input examples that show the language
|
|
13564
|
+
* model what the input should look like.
|
|
13565
|
+
*/
|
|
13566
|
+
inputExamples?: Array<{
|
|
13567
|
+
input: NoInfer<INPUT>;
|
|
13568
|
+
}>;
|
|
13569
|
+
/**
|
|
13570
|
+
* Whether the tool needs approval before it can be executed.
|
|
13571
|
+
*/
|
|
13572
|
+
needsApproval?: boolean | ToolNeedsApprovalFunction<[INPUT] extends [never] ? unknown : INPUT>;
|
|
13573
|
+
/**
|
|
13574
|
+
* Strict mode setting for the tool.
|
|
13575
|
+
*
|
|
13576
|
+
* Providers that support strict mode will use this setting to determine
|
|
13577
|
+
* how the input should be generated. Strict mode will always produce
|
|
13578
|
+
* valid inputs, but it might limit what input schemas are supported.
|
|
13579
|
+
*/
|
|
13580
|
+
strict?: boolean;
|
|
13581
|
+
/**
|
|
13582
|
+
* Optional function that is called when the model starts generating the tool input.
|
|
13583
|
+
* In non-streaming contexts, it is called immediately before `onInputAvailable`.
|
|
13584
|
+
*/
|
|
13585
|
+
onInputStart?: (options: ToolExecutionOptions_2) => void | PromiseLike<void>;
|
|
13586
|
+
/**
|
|
13587
|
+
* Optional function that is called when an argument streaming delta is available.
|
|
13588
|
+
* Only called when the tool is used in a streaming context.
|
|
13589
|
+
*/
|
|
13590
|
+
onInputDelta?: (options: {
|
|
13591
|
+
inputTextDelta: string;
|
|
13592
|
+
} & ToolExecutionOptions_2) => void | PromiseLike<void>;
|
|
13593
|
+
/**
|
|
13594
|
+
* Optional function that is called when a tool call can be started,
|
|
13595
|
+
* even if the execute function is not provided.
|
|
13596
|
+
*/
|
|
13597
|
+
onInputAvailable?: (options: {
|
|
13598
|
+
input: [INPUT] extends [never] ? unknown : INPUT;
|
|
13599
|
+
} & ToolExecutionOptions_2) => void | PromiseLike<void>;
|
|
13600
|
+
} & ToolOutputProperties<INPUT, OUTPUT> & {
|
|
13601
|
+
/**
|
|
13602
|
+
* Optional conversion function that maps the tool result to an output that can be used by the language model.
|
|
13603
|
+
*
|
|
13604
|
+
* If not provided, the tool result will be sent as a JSON object.
|
|
13605
|
+
*
|
|
13606
|
+
* This function is invoked on the server by `convertToModelMessages`, so ensure that you pass the same "tools" (ToolSet) to both "convertToModelMessages" and "streamText" (or other generation APIs).
|
|
13607
|
+
*/
|
|
13608
|
+
toModelOutput?: (options: {
|
|
13609
|
+
/**
|
|
13610
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
13611
|
+
*/
|
|
13612
|
+
toolCallId: string;
|
|
13613
|
+
/**
|
|
13614
|
+
* The input of the tool call.
|
|
13615
|
+
*/
|
|
13616
|
+
input: [INPUT] extends [never] ? unknown : INPUT;
|
|
13617
|
+
/**
|
|
13618
|
+
* The output of the tool call.
|
|
13619
|
+
*/
|
|
13620
|
+
output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>;
|
|
13621
|
+
}) => ToolResultOutput | PromiseLike<ToolResultOutput>;
|
|
13622
|
+
} & ({
|
|
13623
|
+
/**
|
|
13624
|
+
* Tool with user-defined input and output schemas.
|
|
13625
|
+
*/
|
|
13626
|
+
type?: undefined | 'function';
|
|
13627
|
+
} | {
|
|
13628
|
+
/**
|
|
13629
|
+
* Tool that is defined at runtime (e.g. an MCP tool).
|
|
13630
|
+
* The types of input and output are not known at development time.
|
|
13631
|
+
*/
|
|
13632
|
+
type: 'dynamic';
|
|
13633
|
+
} | {
|
|
13634
|
+
/**
|
|
13635
|
+
* Tool with provider-defined input and output schemas.
|
|
13636
|
+
*/
|
|
13637
|
+
type: 'provider';
|
|
13638
|
+
/**
|
|
13639
|
+
* The ID of the tool. Must follow the format `<provider-name>.<unique-tool-name>`.
|
|
13640
|
+
*/
|
|
13641
|
+
id: `${string}.${string}`;
|
|
13642
|
+
/**
|
|
13643
|
+
* The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
13644
|
+
*/
|
|
13645
|
+
args: Record<string, unknown>;
|
|
13646
|
+
/**
|
|
13647
|
+
* Whether this provider-executed tool supports deferred results.
|
|
13648
|
+
*
|
|
13649
|
+
* When true, the tool result may not be returned in the same turn as the
|
|
13650
|
+
* tool call (e.g., when using programmatic tool calling where a server tool
|
|
13651
|
+
* triggers a client-executed tool, and the server tool's result is deferred
|
|
13652
|
+
* until the client tool is resolved).
|
|
13653
|
+
*
|
|
13654
|
+
* This flag allows the AI SDK to handle tool results that arrive without
|
|
13655
|
+
* a matching tool call in the current response.
|
|
13656
|
+
*
|
|
13657
|
+
* @default false
|
|
13658
|
+
*/
|
|
13659
|
+
supportsDeferredResults?: boolean;
|
|
13660
|
+
});
|
|
13661
|
+
|
|
13662
|
+
/**
|
|
13663
|
+
* Helper function for inferring the execute args of a tool.
|
|
13664
|
+
*/
|
|
13665
|
+
declare function tool_2<INPUT, OUTPUT>(tool: Tool_2<INPUT, OUTPUT>): Tool_2<INPUT, OUTPUT>;
|
|
13666
|
+
|
|
13667
|
+
declare function tool_2<INPUT>(tool: Tool_2<INPUT, never>): Tool_2<INPUT, never>;
|
|
13668
|
+
|
|
13669
|
+
declare function tool_2<OUTPUT>(tool: Tool_2<never, OUTPUT>): Tool_2<never, OUTPUT>;
|
|
13670
|
+
|
|
13671
|
+
declare function tool_2(tool: Tool_2<never, never>): Tool_2<never, never>;
|
|
13672
|
+
|
|
12270
13673
|
/**
|
|
12271
13674
|
* Tool approval request prompt part.
|
|
12272
13675
|
*/
|
|
@@ -12294,6 +13697,33 @@ export declare type ToolApprovalRequest = {
|
|
|
12294
13697
|
inputSchemaInput?: unknown;
|
|
12295
13698
|
};
|
|
12296
13699
|
|
|
13700
|
+
/**
|
|
13701
|
+
* Tool approval request prompt part.
|
|
13702
|
+
*/
|
|
13703
|
+
declare type ToolApprovalRequest_2 = {
|
|
13704
|
+
type: 'tool-approval-request';
|
|
13705
|
+
/**
|
|
13706
|
+
* ID of the tool approval.
|
|
13707
|
+
*/
|
|
13708
|
+
approvalId: string;
|
|
13709
|
+
/**
|
|
13710
|
+
* ID of the tool call that the approval request is for.
|
|
13711
|
+
*/
|
|
13712
|
+
toolCallId: string;
|
|
13713
|
+
/**
|
|
13714
|
+
* HMAC-SHA256 signature binding this approval to its tool call.
|
|
13715
|
+
* Present only when `experimental_toolApprovalSecret` is configured.
|
|
13716
|
+
*/
|
|
13717
|
+
signature?: string;
|
|
13718
|
+
/**
|
|
13719
|
+
* Tool input before input schema validation and transformation.
|
|
13720
|
+
*
|
|
13721
|
+
* This is included when it differs from the validated tool input so that
|
|
13722
|
+
* approved tool calls can be safely revalidated before execution.
|
|
13723
|
+
*/
|
|
13724
|
+
inputSchemaInput?: unknown;
|
|
13725
|
+
};
|
|
13726
|
+
|
|
12297
13727
|
/**
|
|
12298
13728
|
* Output part that indicates that a tool approval request has been made.
|
|
12299
13729
|
*
|
|
@@ -12346,6 +13776,37 @@ export declare type ToolApprovalResponse = {
|
|
|
12346
13776
|
providerExecuted?: boolean;
|
|
12347
13777
|
};
|
|
12348
13778
|
|
|
13779
|
+
/**
|
|
13780
|
+
* Tool approval response prompt part.
|
|
13781
|
+
*/
|
|
13782
|
+
declare type ToolApprovalResponse_2 = {
|
|
13783
|
+
type: 'tool-approval-response';
|
|
13784
|
+
/**
|
|
13785
|
+
* ID of the tool approval.
|
|
13786
|
+
*/
|
|
13787
|
+
approvalId: string;
|
|
13788
|
+
/**
|
|
13789
|
+
* Flag indicating whether the approval was granted or denied.
|
|
13790
|
+
*/
|
|
13791
|
+
approved: boolean;
|
|
13792
|
+
/**
|
|
13793
|
+
* Optional reason for the approval or denial.
|
|
13794
|
+
*
|
|
13795
|
+
* For denied tool calls, the reason is included in the `execution-denied`
|
|
13796
|
+
* tool result that is sent to the model. For approved tool calls that are
|
|
13797
|
+
* executed by the SDK, the reason remains in the message history: it is not
|
|
13798
|
+
* included in the model prompt and is not exposed through a dedicated tool
|
|
13799
|
+
* execution option. For provider-executed tools, the approval response
|
|
13800
|
+
* (including the reason) is forwarded to the provider.
|
|
13801
|
+
*/
|
|
13802
|
+
reason?: string;
|
|
13803
|
+
/**
|
|
13804
|
+
* Flag indicating whether the tool call is provider-executed.
|
|
13805
|
+
* Only provider-executed tool approval responses should be sent to the model.
|
|
13806
|
+
*/
|
|
13807
|
+
providerExecuted?: boolean;
|
|
13808
|
+
};
|
|
13809
|
+
|
|
12349
13810
|
/**
|
|
12350
13811
|
* Typed tool call that is returned by generateText and streamText.
|
|
12351
13812
|
* It contains the tool call ID, the tool name, and the tool arguments.
|
|
@@ -12374,6 +13835,34 @@ declare interface ToolCall<NAME extends string, INPUT> {
|
|
|
12374
13835
|
dynamic?: boolean;
|
|
12375
13836
|
}
|
|
12376
13837
|
|
|
13838
|
+
/**
|
|
13839
|
+
* Typed tool call that is returned by generateText and streamText.
|
|
13840
|
+
* It contains the tool call ID, the tool name, and the tool arguments.
|
|
13841
|
+
*/
|
|
13842
|
+
declare interface ToolCall_2<NAME extends string, INPUT> {
|
|
13843
|
+
/**
|
|
13844
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
13845
|
+
*/
|
|
13846
|
+
toolCallId: string;
|
|
13847
|
+
/**
|
|
13848
|
+
* Name of the tool that is being called.
|
|
13849
|
+
*/
|
|
13850
|
+
toolName: NAME;
|
|
13851
|
+
/**
|
|
13852
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
13853
|
+
*/
|
|
13854
|
+
input: INPUT;
|
|
13855
|
+
/**
|
|
13856
|
+
* Whether the tool call will be executed by the provider.
|
|
13857
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
13858
|
+
*/
|
|
13859
|
+
providerExecuted?: boolean;
|
|
13860
|
+
/**
|
|
13861
|
+
* Whether the tool is dynamic.
|
|
13862
|
+
*/
|
|
13863
|
+
dynamic?: boolean;
|
|
13864
|
+
}
|
|
13865
|
+
|
|
12377
13866
|
export declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
12378
13867
|
private readonly [symbol$f];
|
|
12379
13868
|
readonly toolCallId: string;
|
|
@@ -12390,10 +13879,44 @@ export declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
|
12390
13879
|
*/
|
|
12391
13880
|
export declare type ToolCallOptions = ToolExecutionOptions;
|
|
12392
13881
|
|
|
13882
|
+
/**
|
|
13883
|
+
* @deprecated Use ToolExecutionOptions instead.
|
|
13884
|
+
*/
|
|
13885
|
+
declare type ToolCallOptions_2 = ToolExecutionOptions_2;
|
|
13886
|
+
|
|
12393
13887
|
/**
|
|
12394
13888
|
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
12395
13889
|
*/
|
|
12396
13890
|
export declare interface ToolCallPart {
|
|
13891
|
+
type: 'tool-call';
|
|
13892
|
+
/**
|
|
13893
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
13894
|
+
*/
|
|
13895
|
+
toolCallId: string;
|
|
13896
|
+
/**
|
|
13897
|
+
* Name of the tool that is being called.
|
|
13898
|
+
*/
|
|
13899
|
+
toolName: string;
|
|
13900
|
+
/**
|
|
13901
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
13902
|
+
*/
|
|
13903
|
+
input: unknown;
|
|
13904
|
+
/**
|
|
13905
|
+
* Additional provider-specific metadata. They are passed through
|
|
13906
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
13907
|
+
* functionality that can be fully encapsulated in the provider.
|
|
13908
|
+
*/
|
|
13909
|
+
providerOptions?: ProviderOptions_2;
|
|
13910
|
+
/**
|
|
13911
|
+
* Whether the tool call was executed by the provider.
|
|
13912
|
+
*/
|
|
13913
|
+
providerExecuted?: boolean;
|
|
13914
|
+
}
|
|
13915
|
+
|
|
13916
|
+
/**
|
|
13917
|
+
* Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
13918
|
+
*/
|
|
13919
|
+
declare interface ToolCallPart_2 {
|
|
12397
13920
|
type: 'tool-call';
|
|
12398
13921
|
/**
|
|
12399
13922
|
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
@@ -12511,8 +14034,15 @@ export declare class ToolChoiceViolationError extends AISDKError {
|
|
|
12511
14034
|
*/
|
|
12512
14035
|
export declare type ToolContent = Array<ToolResultPart | ToolApprovalResponse>;
|
|
12513
14036
|
|
|
14037
|
+
/**
|
|
14038
|
+
* Content of a tool message. It is an array of tool result parts.
|
|
14039
|
+
*/
|
|
14040
|
+
declare type ToolContent_2 = Array<ToolResultPart_2 | ToolApprovalResponse_2>;
|
|
14041
|
+
|
|
12514
14042
|
export declare type ToolExecuteFunction<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
|
|
12515
14043
|
|
|
14044
|
+
declare type ToolExecuteFunction_2<INPUT, OUTPUT> = (input: INPUT, options: ToolExecutionOptions_2) => AsyncIterable<OUTPUT> | PromiseLike<OUTPUT> | OUTPUT;
|
|
14045
|
+
|
|
12516
14046
|
/**
|
|
12517
14047
|
* Additional options that are sent into each tool call.
|
|
12518
14048
|
*/
|
|
@@ -12545,6 +14075,38 @@ export declare interface ToolExecutionOptions {
|
|
|
12545
14075
|
experimental_context?: unknown;
|
|
12546
14076
|
}
|
|
12547
14077
|
|
|
14078
|
+
/**
|
|
14079
|
+
* Additional options that are sent into each tool call.
|
|
14080
|
+
*/
|
|
14081
|
+
declare interface ToolExecutionOptions_2 {
|
|
14082
|
+
/**
|
|
14083
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
14084
|
+
*/
|
|
14085
|
+
toolCallId: string;
|
|
14086
|
+
/**
|
|
14087
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
14088
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
14089
|
+
*/
|
|
14090
|
+
messages: ModelMessage_2[];
|
|
14091
|
+
/**
|
|
14092
|
+
* An optional abort signal that indicates that the overall operation should be aborted.
|
|
14093
|
+
*/
|
|
14094
|
+
abortSignal?: AbortSignal;
|
|
14095
|
+
/**
|
|
14096
|
+
* User-defined context.
|
|
14097
|
+
*
|
|
14098
|
+
* Treat the context object as immutable inside tools.
|
|
14099
|
+
* Mutating the context object can lead to race conditions and unexpected results
|
|
14100
|
+
* when tools are called in parallel.
|
|
14101
|
+
*
|
|
14102
|
+
* If you need to mutate the context, analyze the tool calls and results
|
|
14103
|
+
* in `prepareStep` and update it there.
|
|
14104
|
+
*
|
|
14105
|
+
* Experimental (can break in patch releases).
|
|
14106
|
+
*/
|
|
14107
|
+
experimental_context?: unknown;
|
|
14108
|
+
}
|
|
14109
|
+
|
|
12548
14110
|
/**
|
|
12549
14111
|
* A tool loop agent is an agent that runs tools in a loop. In each step,
|
|
12550
14112
|
* it calls the LLM, and if there are tool calls, it executes the tools
|
|
@@ -12668,7 +14230,7 @@ declare type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet =
|
|
|
12668
14230
|
* to the provider from the AI SDK and enable provider-specific
|
|
12669
14231
|
* functionality that can be fully encapsulated in the provider.
|
|
12670
14232
|
*/
|
|
12671
|
-
providerOptions?:
|
|
14233
|
+
providerOptions?: ProviderOptions_2;
|
|
12672
14234
|
/**
|
|
12673
14235
|
* Context that is passed into tool calls.
|
|
12674
14236
|
*
|
|
@@ -12702,7 +14264,7 @@ declare type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet =
|
|
|
12702
14264
|
* }),
|
|
12703
14265
|
* ```
|
|
12704
14266
|
*/
|
|
12705
|
-
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'experimental_toolApprovalSecret' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) =>
|
|
14267
|
+
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'experimental_toolApprovalSecret' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike_2<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'timeout' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'experimental_toolApprovalSecret' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
12706
14268
|
};
|
|
12707
14269
|
export { ToolLoopAgentSettings as Experimental_AgentSettings }
|
|
12708
14270
|
export { ToolLoopAgentSettings }
|
|
@@ -12713,6 +14275,20 @@ export { ToolLoopAgentSettings }
|
|
|
12713
14275
|
export declare type ToolModelMessage = {
|
|
12714
14276
|
role: 'tool';
|
|
12715
14277
|
content: ToolContent;
|
|
14278
|
+
/**
|
|
14279
|
+
* Additional provider-specific metadata. They are passed through
|
|
14280
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
14281
|
+
* functionality that can be fully encapsulated in the provider.
|
|
14282
|
+
*/
|
|
14283
|
+
providerOptions?: ProviderOptions_2;
|
|
14284
|
+
};
|
|
14285
|
+
|
|
14286
|
+
/**
|
|
14287
|
+
* A tool message. It contains the result of one or more tool calls.
|
|
14288
|
+
*/
|
|
14289
|
+
declare type ToolModelMessage_2 = {
|
|
14290
|
+
role: 'tool';
|
|
14291
|
+
content: ToolContent_2;
|
|
12716
14292
|
/**
|
|
12717
14293
|
* Additional provider-specific metadata. They are passed through
|
|
12718
14294
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -12745,10 +14321,53 @@ declare interface ToolNameMapping {
|
|
|
12745
14321
|
toCustomToolName: (providerToolName: string) => string;
|
|
12746
14322
|
}
|
|
12747
14323
|
|
|
14324
|
+
/**
|
|
14325
|
+
* Interface for mapping between custom tool names and provider tool names.
|
|
14326
|
+
*/
|
|
14327
|
+
declare interface ToolNameMapping_2 {
|
|
14328
|
+
/**
|
|
14329
|
+
* Maps a custom tool name (used by the client) to the provider's tool name.
|
|
14330
|
+
* If the custom tool name does not have a mapping, returns the input name.
|
|
14331
|
+
*
|
|
14332
|
+
* @param customToolName - The custom name of the tool defined by the client.
|
|
14333
|
+
* @returns The corresponding provider tool name, or the input name if not mapped.
|
|
14334
|
+
*/
|
|
14335
|
+
toProviderToolName: (customToolName: string) => string;
|
|
14336
|
+
/**
|
|
14337
|
+
* Maps a provider tool name to the custom tool name used by the client.
|
|
14338
|
+
* If the provider tool name does not have a mapping, returns the input name.
|
|
14339
|
+
*
|
|
14340
|
+
* @param providerToolName - The name of the tool as understood by the provider.
|
|
14341
|
+
* @returns The corresponding custom tool name, or the input name if not mapped.
|
|
14342
|
+
*/
|
|
14343
|
+
toCustomToolName: (providerToolName: string) => string;
|
|
14344
|
+
}
|
|
14345
|
+
|
|
12748
14346
|
/**
|
|
12749
14347
|
* Function that is called to determine if the tool needs approval before it can be executed.
|
|
12750
14348
|
*/
|
|
12751
14349
|
declare type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
|
|
14350
|
+
/**
|
|
14351
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
14352
|
+
*/
|
|
14353
|
+
toolCallId: string;
|
|
14354
|
+
/**
|
|
14355
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
|
14356
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
|
14357
|
+
*/
|
|
14358
|
+
messages: ModelMessage_2[];
|
|
14359
|
+
/**
|
|
14360
|
+
* Additional context.
|
|
14361
|
+
*
|
|
14362
|
+
* Experimental (can break in patch releases).
|
|
14363
|
+
*/
|
|
14364
|
+
experimental_context?: unknown;
|
|
14365
|
+
}) => boolean | PromiseLike<boolean>;
|
|
14366
|
+
|
|
14367
|
+
/**
|
|
14368
|
+
* Function that is called to determine if the tool needs approval before it can be executed.
|
|
14369
|
+
*/
|
|
14370
|
+
declare type ToolNeedsApprovalFunction_2<INPUT> = (input: INPUT, options: {
|
|
12752
14371
|
/**
|
|
12753
14372
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
|
12754
14373
|
*/
|
|
@@ -12767,6 +14386,21 @@ declare type ToolNeedsApprovalFunction<INPUT> = (input: INPUT, options: {
|
|
|
12767
14386
|
}) => boolean | PromiseLike<boolean>;
|
|
12768
14387
|
|
|
12769
14388
|
declare type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
|
|
14389
|
+
/**
|
|
14390
|
+
* An async function that is called with the arguments from the tool call and produces a result.
|
|
14391
|
+
* If not provided, the tool will not be executed automatically.
|
|
14392
|
+
*
|
|
14393
|
+
* @args is the input of the tool call.
|
|
14394
|
+
* @options.abortSignal is a signal that can be used to abort the tool call.
|
|
14395
|
+
*/
|
|
14396
|
+
execute: ToolExecuteFunction_2<INPUT, OUTPUT>;
|
|
14397
|
+
outputSchema?: FlexibleSchema_2<OUTPUT>;
|
|
14398
|
+
} | {
|
|
14399
|
+
outputSchema: FlexibleSchema_2<OUTPUT>;
|
|
14400
|
+
execute?: never;
|
|
14401
|
+
}>;
|
|
14402
|
+
|
|
14403
|
+
declare type ToolOutputProperties_2<INPUT, OUTPUT> = NeverOptional_2<OUTPUT, {
|
|
12770
14404
|
/**
|
|
12771
14405
|
* An async function that is called with the arguments from the tool call and produces a result.
|
|
12772
14406
|
* If not provided, the tool will not be executed automatically.
|
|
@@ -12785,7 +14419,38 @@ declare type ToolOutputProperties<INPUT, OUTPUT> = NeverOptional<OUTPUT, {
|
|
|
12785
14419
|
* Typed tool result that is returned by `generateText` and `streamText`.
|
|
12786
14420
|
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
|
|
12787
14421
|
*/
|
|
12788
|
-
declare interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
14422
|
+
declare interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
14423
|
+
/**
|
|
14424
|
+
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
14425
|
+
*/
|
|
14426
|
+
toolCallId: string;
|
|
14427
|
+
/**
|
|
14428
|
+
* Name of the tool that was called.
|
|
14429
|
+
*/
|
|
14430
|
+
toolName: NAME;
|
|
14431
|
+
/**
|
|
14432
|
+
* Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
14433
|
+
*/
|
|
14434
|
+
input: INPUT;
|
|
14435
|
+
/**
|
|
14436
|
+
* Result of the tool call. This is the result of the tool's execution.
|
|
14437
|
+
*/
|
|
14438
|
+
output: OUTPUT;
|
|
14439
|
+
/**
|
|
14440
|
+
* Whether the tool result has been executed by the provider.
|
|
14441
|
+
*/
|
|
14442
|
+
providerExecuted?: boolean;
|
|
14443
|
+
/**
|
|
14444
|
+
* Whether the tool is dynamic.
|
|
14445
|
+
*/
|
|
14446
|
+
dynamic?: boolean;
|
|
14447
|
+
}
|
|
14448
|
+
|
|
14449
|
+
/**
|
|
14450
|
+
* Typed tool result that is returned by `generateText` and `streamText`.
|
|
14451
|
+
* It contains the tool call ID, the tool name, the tool arguments, and the tool result.
|
|
14452
|
+
*/
|
|
14453
|
+
declare interface ToolResult_2<NAME extends string, INPUT, OUTPUT> {
|
|
12789
14454
|
/**
|
|
12790
14455
|
* ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
12791
14456
|
*/
|
|
@@ -12989,10 +14654,212 @@ declare type ToolResultOutput = {
|
|
|
12989
14654
|
}>;
|
|
12990
14655
|
};
|
|
12991
14656
|
|
|
14657
|
+
/**
|
|
14658
|
+
* Output of a tool result.
|
|
14659
|
+
*/
|
|
14660
|
+
declare type ToolResultOutput_2 = {
|
|
14661
|
+
/**
|
|
14662
|
+
* Text tool output that should be directly sent to the API.
|
|
14663
|
+
*/
|
|
14664
|
+
type: 'text';
|
|
14665
|
+
value: string;
|
|
14666
|
+
/**
|
|
14667
|
+
* Provider-specific options.
|
|
14668
|
+
*/
|
|
14669
|
+
providerOptions?: ProviderOptions_2;
|
|
14670
|
+
} | {
|
|
14671
|
+
type: 'json';
|
|
14672
|
+
value: JSONValue_2;
|
|
14673
|
+
/**
|
|
14674
|
+
* Provider-specific options.
|
|
14675
|
+
*/
|
|
14676
|
+
providerOptions?: ProviderOptions_2;
|
|
14677
|
+
} | {
|
|
14678
|
+
/**
|
|
14679
|
+
* Type when the user has denied the execution of the tool call.
|
|
14680
|
+
*/
|
|
14681
|
+
type: 'execution-denied';
|
|
14682
|
+
/**
|
|
14683
|
+
* Optional reason for the execution denial.
|
|
14684
|
+
*/
|
|
14685
|
+
reason?: string;
|
|
14686
|
+
/**
|
|
14687
|
+
* Provider-specific options.
|
|
14688
|
+
*/
|
|
14689
|
+
providerOptions?: ProviderOptions_2;
|
|
14690
|
+
} | {
|
|
14691
|
+
type: 'error-text';
|
|
14692
|
+
value: string;
|
|
14693
|
+
/**
|
|
14694
|
+
* Provider-specific options.
|
|
14695
|
+
*/
|
|
14696
|
+
providerOptions?: ProviderOptions_2;
|
|
14697
|
+
} | {
|
|
14698
|
+
type: 'error-json';
|
|
14699
|
+
value: JSONValue_2;
|
|
14700
|
+
/**
|
|
14701
|
+
* Provider-specific options.
|
|
14702
|
+
*/
|
|
14703
|
+
providerOptions?: ProviderOptions_2;
|
|
14704
|
+
} | {
|
|
14705
|
+
type: 'content';
|
|
14706
|
+
value: Array<{
|
|
14707
|
+
type: 'text';
|
|
14708
|
+
/**
|
|
14709
|
+
* Text content.
|
|
14710
|
+
*/
|
|
14711
|
+
text: string;
|
|
14712
|
+
/**
|
|
14713
|
+
* Provider-specific options.
|
|
14714
|
+
*/
|
|
14715
|
+
providerOptions?: ProviderOptions_2;
|
|
14716
|
+
} | {
|
|
14717
|
+
/**
|
|
14718
|
+
* @deprecated Use image-data or file-data instead.
|
|
14719
|
+
*/
|
|
14720
|
+
type: 'media';
|
|
14721
|
+
data: string;
|
|
14722
|
+
mediaType: string;
|
|
14723
|
+
} | {
|
|
14724
|
+
type: 'file-data';
|
|
14725
|
+
/**
|
|
14726
|
+
* Base-64 encoded media data.
|
|
14727
|
+
*/
|
|
14728
|
+
data: string;
|
|
14729
|
+
/**
|
|
14730
|
+
* IANA media type.
|
|
14731
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
14732
|
+
*/
|
|
14733
|
+
mediaType: string;
|
|
14734
|
+
/**
|
|
14735
|
+
* Optional filename of the file.
|
|
14736
|
+
*/
|
|
14737
|
+
filename?: string;
|
|
14738
|
+
/**
|
|
14739
|
+
* Provider-specific options.
|
|
14740
|
+
*/
|
|
14741
|
+
providerOptions?: ProviderOptions_2;
|
|
14742
|
+
} | {
|
|
14743
|
+
type: 'file-url';
|
|
14744
|
+
/**
|
|
14745
|
+
* URL of the file.
|
|
14746
|
+
*/
|
|
14747
|
+
url: string;
|
|
14748
|
+
/**
|
|
14749
|
+
* IANA media type.
|
|
14750
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
14751
|
+
*/
|
|
14752
|
+
mediaType?: string;
|
|
14753
|
+
/**
|
|
14754
|
+
* Provider-specific options.
|
|
14755
|
+
*/
|
|
14756
|
+
providerOptions?: ProviderOptions_2;
|
|
14757
|
+
} | {
|
|
14758
|
+
type: 'file-id';
|
|
14759
|
+
/**
|
|
14760
|
+
* ID of the file.
|
|
14761
|
+
*
|
|
14762
|
+
* If you use multiple providers, you need to
|
|
14763
|
+
* specify the provider specific ids using
|
|
14764
|
+
* the Record option. The key is the provider
|
|
14765
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
14766
|
+
*/
|
|
14767
|
+
fileId: string | Record<string, string>;
|
|
14768
|
+
/**
|
|
14769
|
+
* Provider-specific options.
|
|
14770
|
+
*/
|
|
14771
|
+
providerOptions?: ProviderOptions_2;
|
|
14772
|
+
} | {
|
|
14773
|
+
/**
|
|
14774
|
+
* Images that are referenced using base64 encoded data.
|
|
14775
|
+
*/
|
|
14776
|
+
type: 'image-data';
|
|
14777
|
+
/**
|
|
14778
|
+
* Base-64 encoded image data.
|
|
14779
|
+
*/
|
|
14780
|
+
data: string;
|
|
14781
|
+
/**
|
|
14782
|
+
* IANA media type.
|
|
14783
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
14784
|
+
*/
|
|
14785
|
+
mediaType: string;
|
|
14786
|
+
/**
|
|
14787
|
+
* Provider-specific options.
|
|
14788
|
+
*/
|
|
14789
|
+
providerOptions?: ProviderOptions_2;
|
|
14790
|
+
} | {
|
|
14791
|
+
/**
|
|
14792
|
+
* Images that are referenced using a URL.
|
|
14793
|
+
*/
|
|
14794
|
+
type: 'image-url';
|
|
14795
|
+
/**
|
|
14796
|
+
* URL of the image.
|
|
14797
|
+
*/
|
|
14798
|
+
url: string;
|
|
14799
|
+
/**
|
|
14800
|
+
* Provider-specific options.
|
|
14801
|
+
*/
|
|
14802
|
+
providerOptions?: ProviderOptions_2;
|
|
14803
|
+
} | {
|
|
14804
|
+
/**
|
|
14805
|
+
* Images that are referenced using a provider file id.
|
|
14806
|
+
*/
|
|
14807
|
+
type: 'image-file-id';
|
|
14808
|
+
/**
|
|
14809
|
+
* Image that is referenced using a provider file id.
|
|
14810
|
+
*
|
|
14811
|
+
* If you use multiple providers, you need to
|
|
14812
|
+
* specify the provider specific ids using
|
|
14813
|
+
* the Record option. The key is the provider
|
|
14814
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
14815
|
+
*/
|
|
14816
|
+
fileId: string | Record<string, string>;
|
|
14817
|
+
/**
|
|
14818
|
+
* Provider-specific options.
|
|
14819
|
+
*/
|
|
14820
|
+
providerOptions?: ProviderOptions_2;
|
|
14821
|
+
} | {
|
|
14822
|
+
/**
|
|
14823
|
+
* Custom content part. This can be used to implement
|
|
14824
|
+
* provider-specific content parts.
|
|
14825
|
+
*/
|
|
14826
|
+
type: 'custom';
|
|
14827
|
+
/**
|
|
14828
|
+
* Provider-specific options.
|
|
14829
|
+
*/
|
|
14830
|
+
providerOptions?: ProviderOptions_2;
|
|
14831
|
+
}>;
|
|
14832
|
+
};
|
|
14833
|
+
|
|
12992
14834
|
/**
|
|
12993
14835
|
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
12994
14836
|
*/
|
|
12995
14837
|
export declare interface ToolResultPart {
|
|
14838
|
+
type: 'tool-result';
|
|
14839
|
+
/**
|
|
14840
|
+
* ID of the tool call that this result is associated with.
|
|
14841
|
+
*/
|
|
14842
|
+
toolCallId: string;
|
|
14843
|
+
/**
|
|
14844
|
+
* Name of the tool that generated this result.
|
|
14845
|
+
*/
|
|
14846
|
+
toolName: string;
|
|
14847
|
+
/**
|
|
14848
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
14849
|
+
*/
|
|
14850
|
+
output: ToolResultOutput_2;
|
|
14851
|
+
/**
|
|
14852
|
+
* Additional provider-specific metadata. They are passed through
|
|
14853
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
14854
|
+
* functionality that can be fully encapsulated in the provider.
|
|
14855
|
+
*/
|
|
14856
|
+
providerOptions?: ProviderOptions_2;
|
|
14857
|
+
}
|
|
14858
|
+
|
|
14859
|
+
/**
|
|
14860
|
+
* Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
14861
|
+
*/
|
|
14862
|
+
declare interface ToolResultPart_2 {
|
|
12996
14863
|
type: 'tool-result';
|
|
12997
14864
|
/**
|
|
12998
14865
|
* ID of the tool call that this result is associated with.
|
|
@@ -13698,7 +15565,7 @@ export declare type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIData
|
|
|
13698
15565
|
messageMetadata: METADATA;
|
|
13699
15566
|
};
|
|
13700
15567
|
|
|
13701
|
-
export declare const uiMessageChunkSchema:
|
|
15568
|
+
export declare const uiMessageChunkSchema: _ai_sdk_provider_utils_2.LazySchema<UIMessageChunk<unknown, UIDataTypes>>;
|
|
13702
15569
|
|
|
13703
15570
|
export declare type UIMessagePart<DATA_TYPES extends UIDataTypes, TOOLS extends UITools> = TextUIPart | ReasoningUIPart | ToolUIPart<TOOLS> | DynamicToolUIPart | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
|
13704
15571
|
|
|
@@ -14113,7 +15980,7 @@ export declare type UseCompletionOptions = {
|
|
|
14113
15980
|
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
14114
15981
|
* or to provide a custom fetch implementation for e.g. testing.
|
|
14115
15982
|
*/
|
|
14116
|
-
fetch?:
|
|
15983
|
+
fetch?: FetchFunction_2;
|
|
14117
15984
|
};
|
|
14118
15985
|
|
|
14119
15986
|
/**
|
|
@@ -14121,12 +15988,31 @@ export declare type UseCompletionOptions = {
|
|
|
14121
15988
|
*/
|
|
14122
15989
|
export declare type UserContent = string | Array<TextPart | ImagePart | FilePart>;
|
|
14123
15990
|
|
|
15991
|
+
/**
|
|
15992
|
+
* Content of a user message. It can be a string or an array of text and image parts.
|
|
15993
|
+
*/
|
|
15994
|
+
declare type UserContent_2 = string | Array<TextPart_2 | ImagePart_2 | FilePart_2>;
|
|
15995
|
+
|
|
14124
15996
|
/**
|
|
14125
15997
|
* A user message. It can contain text or a combination of text and images.
|
|
14126
15998
|
*/
|
|
14127
15999
|
export declare type UserModelMessage = {
|
|
14128
16000
|
role: 'user';
|
|
14129
16001
|
content: UserContent;
|
|
16002
|
+
/**
|
|
16003
|
+
* Additional provider-specific metadata. They are passed through
|
|
16004
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
16005
|
+
* functionality that can be fully encapsulated in the provider.
|
|
16006
|
+
*/
|
|
16007
|
+
providerOptions?: ProviderOptions_2;
|
|
16008
|
+
};
|
|
16009
|
+
|
|
16010
|
+
/**
|
|
16011
|
+
* A user message. It can contain text or a combination of text and images.
|
|
16012
|
+
*/
|
|
16013
|
+
declare type UserModelMessage_2 = {
|
|
16014
|
+
role: 'user';
|
|
16015
|
+
content: UserContent_2;
|
|
14130
16016
|
/**
|
|
14131
16017
|
* Additional provider-specific metadata. They are passed through
|
|
14132
16018
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -14149,6 +16035,18 @@ export declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
|
|
|
14149
16035
|
*/
|
|
14150
16036
|
declare function validateDownloadUrl(url: string): void;
|
|
14151
16037
|
|
|
16038
|
+
/**
|
|
16039
|
+
* Validates that a URL is safe to download from, blocking private/internal addresses
|
|
16040
|
+
* to prevent SSRF attacks.
|
|
16041
|
+
*
|
|
16042
|
+
* Note: this function performs string/literal-IP checks only. The Node.js
|
|
16043
|
+
* download fetch additionally validates and pins DNS results at connect time.
|
|
16044
|
+
*
|
|
16045
|
+
* @param url - The URL string to validate.
|
|
16046
|
+
* @throws DownloadError if the URL is unsafe.
|
|
16047
|
+
*/
|
|
16048
|
+
declare function validateDownloadUrl_2(url: string): void;
|
|
16049
|
+
|
|
14152
16050
|
/**
|
|
14153
16051
|
* Validates the types of an unknown object using a schema and
|
|
14154
16052
|
* return a strongly-typed object.
|
|
@@ -14160,6 +16058,22 @@ declare function validateDownloadUrl(url: string): void;
|
|
|
14160
16058
|
* @returns {Promise<T>} - The typed object.
|
|
14161
16059
|
*/
|
|
14162
16060
|
declare function validateTypes<OBJECT>({ value, schema, context, }: {
|
|
16061
|
+
value: unknown;
|
|
16062
|
+
schema: FlexibleSchema_2<OBJECT>;
|
|
16063
|
+
context?: TypeValidationContext;
|
|
16064
|
+
}): Promise<OBJECT>;
|
|
16065
|
+
|
|
16066
|
+
/**
|
|
16067
|
+
* Validates the types of an unknown object using a schema and
|
|
16068
|
+
* return a strongly-typed object.
|
|
16069
|
+
*
|
|
16070
|
+
* @template T - The type of the object to validate.
|
|
16071
|
+
* @param {string} options.value - The object to validate.
|
|
16072
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
16073
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
16074
|
+
* @returns {Promise<T>} - The typed object.
|
|
16075
|
+
*/
|
|
16076
|
+
declare function validateTypes_2<OBJECT>({ value, schema, context, }: {
|
|
14163
16077
|
value: unknown;
|
|
14164
16078
|
schema: FlexibleSchema<OBJECT>;
|
|
14165
16079
|
context?: TypeValidationContext;
|
|
@@ -14193,6 +16107,14 @@ declare type ValidationResult<OBJECT> = {
|
|
|
14193
16107
|
error: Error;
|
|
14194
16108
|
};
|
|
14195
16109
|
|
|
16110
|
+
declare type ValidationResult_2<OBJECT> = {
|
|
16111
|
+
success: true;
|
|
16112
|
+
value: OBJECT;
|
|
16113
|
+
} | {
|
|
16114
|
+
success: false;
|
|
16115
|
+
error: Error;
|
|
16116
|
+
};
|
|
16117
|
+
|
|
14196
16118
|
/**
|
|
14197
16119
|
* Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
14198
16120
|
*
|
|
@@ -14237,6 +16159,8 @@ declare type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof Obje
|
|
|
14237
16159
|
|
|
14238
16160
|
declare const VERSION: string;
|
|
14239
16161
|
|
|
16162
|
+
declare const VERSION_2: string;
|
|
16163
|
+
|
|
14240
16164
|
/**
|
|
14241
16165
|
* A video model can be a string (model ID) or a Experimental_VideoModelV3 object.
|
|
14242
16166
|
*/
|
|
@@ -14537,6 +16461,8 @@ export declare type Warning = SharedV3Warning;
|
|
|
14537
16461
|
|
|
14538
16462
|
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
|
14539
16463
|
|
|
16464
|
+
declare function withoutTrailingSlash_2(url: string | undefined): string | undefined;
|
|
16465
|
+
|
|
14540
16466
|
/**
|
|
14541
16467
|
* Appends suffix parts to the `user-agent` header.
|
|
14542
16468
|
* If a `user-agent` header already exists, the suffix parts are appended to it.
|
|
@@ -14549,6 +16475,18 @@ declare function withoutTrailingSlash(url: string | undefined): string | undefin
|
|
|
14549
16475
|
*/
|
|
14550
16476
|
declare function withUserAgentSuffix(headers: HeadersInit | Record<string, string | undefined> | undefined, ...userAgentSuffixParts: string[]): Record<string, string>;
|
|
14551
16477
|
|
|
16478
|
+
/**
|
|
16479
|
+
* Appends suffix parts to the `user-agent` header.
|
|
16480
|
+
* If a `user-agent` header already exists, the suffix parts are appended to it.
|
|
16481
|
+
* If no `user-agent` header exists, a new one is created with the suffix parts.
|
|
16482
|
+
* Automatically removes undefined entries from the headers.
|
|
16483
|
+
*
|
|
16484
|
+
* @param headers - The original headers.
|
|
16485
|
+
* @param userAgentSuffixParts - The parts to append to the `user-agent` header.
|
|
16486
|
+
* @returns The new headers with the `user-agent` header set or updated.
|
|
16487
|
+
*/
|
|
16488
|
+
declare function withUserAgentSuffix_2(headers: HeadersInit | Record<string, string | undefined> | undefined, ...userAgentSuffixParts: string[]): Record<string, string>;
|
|
16489
|
+
|
|
14552
16490
|
/**
|
|
14553
16491
|
* Wraps an EmbeddingModelV3 instance with middleware functionality.
|
|
14554
16492
|
* This function allows you to apply middleware to transform parameters,
|
|
@@ -14636,6 +16574,20 @@ export declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, an
|
|
|
14636
16574
|
useReferences?: boolean;
|
|
14637
16575
|
}): Schema<OBJECT>;
|
|
14638
16576
|
|
|
16577
|
+
declare type ZodSchema_2<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>;
|
|
16578
|
+
|
|
16579
|
+
declare function zodSchema_2<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, any> | z3.Schema<OBJECT, z3.ZodTypeDef, any>, options?: {
|
|
16580
|
+
/**
|
|
16581
|
+
* Enables support for references in the schema.
|
|
16582
|
+
* This is required for recursive schemas, e.g. with `z.lazy`.
|
|
16583
|
+
* However, not all language models and providers support such references.
|
|
16584
|
+
* Defaults to `false`.
|
|
16585
|
+
*/
|
|
16586
|
+
useReferences?: boolean;
|
|
16587
|
+
}): Schema_2<OBJECT>;
|
|
16588
|
+
|
|
14639
16589
|
export { }
|
|
14640
|
-
export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider,
|
|
14641
|
-
export { EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, schemaSymbol, symbol$1, symbol$1_2, symbol$2, symbol$2_2, symbol$3, symbol$3_2, symbol$4, symbol$4_2, symbol$5, symbol$5_2, symbol$6, symbol$6_2, symbol$7, symbol$7_2, symbol$8, symbol$8_2, symbol$9, symbol$9_2, symbol$a, symbol$b, symbol$b_2, symbol$c, symbol$c_2, symbol$d, symbol$d_2, symbol$e, symbol$f, symbol$g, symbol$h, symbol$i, symbol$j, symbol$k, symbol$l, symbol, symbol_2, symbol_3 };
|
|
16590
|
+
export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, LazySchema_2 as LazySchema_2, ZodSchema_2 as ZodSchema_2, StandardSchema_2 as StandardSchema_2, ValidationResult_2 as ValidationResult_2, ParseResult_2 as ParseResult_2, ProviderOptions_2 as ProviderOptions_2, ReasoningPart_2 as ReasoningPart_2, ToolOutputProperties_2 as ToolOutputProperties_2, ToolResultOutput_2 as ToolResultOutput_2, ToolNeedsApprovalFunction_2 as ToolNeedsApprovalFunction_2, TypeValidationContext as TypeValidationContext, EmbeddingModelV2 as EmbeddingModelV2, EmbeddingModelV3Embedding as EmbeddingModelV3Embedding, EmbeddingModelV3Middleware as EmbeddingModelV3Middleware, ImageModelV2 as ImageModelV2, ImageModelV3ProviderMetadata as ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, ImageModelV3Middleware as ImageModelV3Middleware, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2 as LanguageModelV2, SharedV3Warning as SharedV3Warning, LanguageModelV3Middleware as LanguageModelV3Middleware, SharedV3ProviderMetadata as SharedV3ProviderMetadata, SpeechModelV2 as SpeechModelV2, TranscriptionModelV2 as TranscriptionModelV2, ImageModelV3Usage as ImageModelV3Usage, DeepPartialInternal as DeepPartialInternal, AttributeValue as AttributeValue, Tracer as Tracer, BaseToolCall as BaseToolCall, Source as Source, PrepareStepCallSettings as PrepareStepCallSettings, ResponseMessage as ResponseMessage, LanguageModelV3ToolCall as LanguageModelV3ToolCall, GenerateTextIncludeSettings as GenerateTextIncludeSettings, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils_2 as _ai_sdk_provider_utils_2, DataUIMessageChunk as DataUIMessageChunk, InferElementOutput as InferElementOutput, ConsumeStreamOptions as ConsumeStreamOptions, StreamTextIncludeSettings as StreamTextIncludeSettings, StreamTextOnAbortCallback as StreamTextOnAbortCallback, EnrichedStreamPart as EnrichedStreamPart, CallbackModelInfo as CallbackModelInfo, LanguageModelV3ToolChoice as LanguageModelV3ToolChoice, Listener as Listener, MaybePromiseLike_2 as MaybePromiseLike_2, InferAgentTools as InferAgentTools, UIMessageStreamResponseInit as UIMessageStreamResponseInit, getOriginalFetch as getOriginalFetch, InferUIMessageTools as InferUIMessageTools, InferUIMessageToolCall as InferUIMessageToolCall, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, Resolvable_2 as Resolvable_2, FetchFunction_2 as FetchFunction_2, ValidateUIMessagesOptions as ValidateUIMessagesOptions, SingleRequestTextStreamPart as SingleRequestTextStreamPart, EnforcedToolChoice as EnforcedToolChoice, LanguageModelV3Content as LanguageModelV3Content, RetryErrorReason_2 as RetryErrorReason_2, GenerateImagePrompt as GenerateImagePrompt, JSONValue_2 as JSONValue_2, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, VideoModelResponseMetadata as VideoModelResponseMetadata, VideoModelProviderMetadata as VideoModelProviderMetadata, VideoModel as VideoModel, VideoModelV3FrameType as VideoModelV3FrameType, EmbeddingModelV3CallOptions as EmbeddingModelV3CallOptions, LanguageModelV3CallOptions as LanguageModelV3CallOptions, JSONObject as JSONObject, LanguageModelV3 as LanguageModelV3, EmbeddingModelV3 as EmbeddingModelV3, ImageModelV3 as ImageModelV3, TranscriptionModelV3 as TranscriptionModelV3, SpeechModelV3 as SpeechModelV3, RerankingModelV3 as RerankingModelV3, VideoModelV3 as VideoModelV3, ProviderV2 as ProviderV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV3 as ProviderV3 };
|
|
16591
|
+
export { EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL_2, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER_2, schemaSymbol, schemaSymbol_2, symbol$1, symbol$1_2, symbol$2, symbol$2_2, symbol$3, symbol$3_2, symbol$4, symbol$4_2, symbol$5, symbol$5_2, symbol$6, symbol$6_2, symbol$7, symbol$7_2, symbol$8, symbol$8_2, symbol$9, symbol$9_2, symbol$a, symbol$b, symbol$b_2, symbol$c, symbol$c_2, symbol$d, symbol$d_2, symbol$e, symbol$f, symbol$g, symbol$h, symbol$i, symbol$j, symbol$k, symbol$l, symbol, symbol_2, symbol_3, symbol_4 };
|
|
16592
|
+
|
|
16593
|
+
export type ProviderOptions = NonNullable<EmbeddingModelV3CallOptions['providerOptions']>;
|