@ai-sdk/provider-utils 4.0.0-beta.18 → 4.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +190 -10
- package/dist/index.d.ts +190 -10
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions
|
|
1
|
+
import { JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
|
|
2
2
|
import * as z4 from 'zod/v4';
|
|
3
3
|
import { ZodType } from 'zod/v4';
|
|
4
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
@@ -232,6 +232,15 @@ declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPre
|
|
|
232
232
|
|
|
233
233
|
declare function isAbortError(error: unknown): error is Error;
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Type guard that checks whether a value is not `null` or `undefined`.
|
|
237
|
+
*
|
|
238
|
+
* @template T - The type of the value to check.
|
|
239
|
+
* @param value - The value to check.
|
|
240
|
+
* @returns `true` if the value is neither `null` nor `undefined`, otherwise `false`.
|
|
241
|
+
*/
|
|
242
|
+
declare function isNonNullable<T>(value: T | undefined | null): value is NonNullable<T>;
|
|
243
|
+
|
|
235
244
|
/**
|
|
236
245
|
* Checks if the given URL is supported natively by the model.
|
|
237
246
|
*
|
|
@@ -352,6 +361,11 @@ declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, fa
|
|
|
352
361
|
responseHeaders?: Record<string, string>;
|
|
353
362
|
}>;
|
|
354
363
|
|
|
364
|
+
/**
|
|
365
|
+
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
366
|
+
*/
|
|
367
|
+
type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
368
|
+
|
|
355
369
|
/**
|
|
356
370
|
Additional provider-specific options.
|
|
357
371
|
|
|
@@ -360,11 +374,6 @@ provider-specific functionality that can be fully encapsulated in the provider.
|
|
|
360
374
|
*/
|
|
361
375
|
type ProviderOptions = SharedV3ProviderOptions;
|
|
362
376
|
|
|
363
|
-
/**
|
|
364
|
-
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
365
|
-
*/
|
|
366
|
-
type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
367
|
-
|
|
368
377
|
/**
|
|
369
378
|
Text content part of a prompt. It contains a string of text.
|
|
370
379
|
*/
|
|
@@ -495,7 +504,7 @@ interface ToolResultPart {
|
|
|
495
504
|
/**
|
|
496
505
|
Result of the tool call. This is a JSON-serializable object.
|
|
497
506
|
*/
|
|
498
|
-
output:
|
|
507
|
+
output: ToolResultOutput;
|
|
499
508
|
/**
|
|
500
509
|
Additional provider-specific metadata. They are passed through
|
|
501
510
|
to the provider from the AI SDK and enable provider-specific
|
|
@@ -503,6 +512,177 @@ interface ToolResultPart {
|
|
|
503
512
|
*/
|
|
504
513
|
providerOptions?: ProviderOptions;
|
|
505
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* Output of a tool result.
|
|
517
|
+
*/
|
|
518
|
+
type ToolResultOutput = {
|
|
519
|
+
/**
|
|
520
|
+
* Text tool output that should be directly sent to the API.
|
|
521
|
+
*/
|
|
522
|
+
type: 'text';
|
|
523
|
+
value: string;
|
|
524
|
+
/**
|
|
525
|
+
* Provider-specific options.
|
|
526
|
+
*/
|
|
527
|
+
providerOptions?: ProviderOptions;
|
|
528
|
+
} | {
|
|
529
|
+
type: 'json';
|
|
530
|
+
value: JSONValue;
|
|
531
|
+
/**
|
|
532
|
+
* Provider-specific options.
|
|
533
|
+
*/
|
|
534
|
+
providerOptions?: ProviderOptions;
|
|
535
|
+
} | {
|
|
536
|
+
/**
|
|
537
|
+
* Type when the user has denied the execution of the tool call.
|
|
538
|
+
*/
|
|
539
|
+
type: 'execution-denied';
|
|
540
|
+
/**
|
|
541
|
+
* Optional reason for the execution denial.
|
|
542
|
+
*/
|
|
543
|
+
reason?: string;
|
|
544
|
+
/**
|
|
545
|
+
* Provider-specific options.
|
|
546
|
+
*/
|
|
547
|
+
providerOptions?: ProviderOptions;
|
|
548
|
+
} | {
|
|
549
|
+
type: 'error-text';
|
|
550
|
+
value: string;
|
|
551
|
+
/**
|
|
552
|
+
* Provider-specific options.
|
|
553
|
+
*/
|
|
554
|
+
providerOptions?: ProviderOptions;
|
|
555
|
+
} | {
|
|
556
|
+
type: 'error-json';
|
|
557
|
+
value: JSONValue;
|
|
558
|
+
/**
|
|
559
|
+
* Provider-specific options.
|
|
560
|
+
*/
|
|
561
|
+
providerOptions?: ProviderOptions;
|
|
562
|
+
} | {
|
|
563
|
+
type: 'content';
|
|
564
|
+
value: Array<{
|
|
565
|
+
type: 'text';
|
|
566
|
+
/**
|
|
567
|
+
Text content.
|
|
568
|
+
*/
|
|
569
|
+
text: string;
|
|
570
|
+
/**
|
|
571
|
+
* Provider-specific options.
|
|
572
|
+
*/
|
|
573
|
+
providerOptions?: ProviderOptions;
|
|
574
|
+
} | {
|
|
575
|
+
/**
|
|
576
|
+
* @deprecated Use image-data or file-data instead.
|
|
577
|
+
*/
|
|
578
|
+
type: 'media';
|
|
579
|
+
data: string;
|
|
580
|
+
mediaType: string;
|
|
581
|
+
} | {
|
|
582
|
+
type: 'file-data';
|
|
583
|
+
/**
|
|
584
|
+
Base-64 encoded media data.
|
|
585
|
+
*/
|
|
586
|
+
data: string;
|
|
587
|
+
/**
|
|
588
|
+
IANA media type.
|
|
589
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
590
|
+
*/
|
|
591
|
+
mediaType: string;
|
|
592
|
+
/**
|
|
593
|
+
* Optional filename of the file.
|
|
594
|
+
*/
|
|
595
|
+
filename?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Provider-specific options.
|
|
598
|
+
*/
|
|
599
|
+
providerOptions?: ProviderOptions;
|
|
600
|
+
} | {
|
|
601
|
+
type: 'file-url';
|
|
602
|
+
/**
|
|
603
|
+
* URL of the file.
|
|
604
|
+
*/
|
|
605
|
+
url: string;
|
|
606
|
+
/**
|
|
607
|
+
* Provider-specific options.
|
|
608
|
+
*/
|
|
609
|
+
providerOptions?: ProviderOptions;
|
|
610
|
+
} | {
|
|
611
|
+
type: 'file-id';
|
|
612
|
+
/**
|
|
613
|
+
* ID of the file.
|
|
614
|
+
*
|
|
615
|
+
* If you use multiple providers, you need to
|
|
616
|
+
* specify the provider specific ids using
|
|
617
|
+
* the Record option. The key is the provider
|
|
618
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
619
|
+
*/
|
|
620
|
+
fileId: string | Record<string, string>;
|
|
621
|
+
/**
|
|
622
|
+
* Provider-specific options.
|
|
623
|
+
*/
|
|
624
|
+
providerOptions?: ProviderOptions;
|
|
625
|
+
} | {
|
|
626
|
+
/**
|
|
627
|
+
* Images that are referenced using base64 encoded data.
|
|
628
|
+
*/
|
|
629
|
+
type: 'image-data';
|
|
630
|
+
/**
|
|
631
|
+
Base-64 encoded image data.
|
|
632
|
+
*/
|
|
633
|
+
data: string;
|
|
634
|
+
/**
|
|
635
|
+
IANA media type.
|
|
636
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
637
|
+
*/
|
|
638
|
+
mediaType: string;
|
|
639
|
+
/**
|
|
640
|
+
* Provider-specific options.
|
|
641
|
+
*/
|
|
642
|
+
providerOptions?: ProviderOptions;
|
|
643
|
+
} | {
|
|
644
|
+
/**
|
|
645
|
+
* Images that are referenced using a URL.
|
|
646
|
+
*/
|
|
647
|
+
type: 'image-url';
|
|
648
|
+
/**
|
|
649
|
+
* URL of the image.
|
|
650
|
+
*/
|
|
651
|
+
url: string;
|
|
652
|
+
/**
|
|
653
|
+
* Provider-specific options.
|
|
654
|
+
*/
|
|
655
|
+
providerOptions?: ProviderOptions;
|
|
656
|
+
} | {
|
|
657
|
+
/**
|
|
658
|
+
* Images that are referenced using a provider file id.
|
|
659
|
+
*/
|
|
660
|
+
type: 'image-file-id';
|
|
661
|
+
/**
|
|
662
|
+
* Image that is referenced using a provider file id.
|
|
663
|
+
*
|
|
664
|
+
* If you use multiple providers, you need to
|
|
665
|
+
* specify the provider specific ids using
|
|
666
|
+
* the Record option. The key is the provider
|
|
667
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
668
|
+
*/
|
|
669
|
+
fileId: string | Record<string, string>;
|
|
670
|
+
/**
|
|
671
|
+
* Provider-specific options.
|
|
672
|
+
*/
|
|
673
|
+
providerOptions?: ProviderOptions;
|
|
674
|
+
} | {
|
|
675
|
+
/**
|
|
676
|
+
* Custom content part. This can be used to implement
|
|
677
|
+
* provider-specific content parts.
|
|
678
|
+
*/
|
|
679
|
+
type: 'custom';
|
|
680
|
+
/**
|
|
681
|
+
* Provider-specific options.
|
|
682
|
+
*/
|
|
683
|
+
providerOptions?: ProviderOptions;
|
|
684
|
+
}>;
|
|
685
|
+
};
|
|
506
686
|
|
|
507
687
|
/**
|
|
508
688
|
* Tool approval request prompt part.
|
|
@@ -731,7 +911,7 @@ Optional conversion function that maps the tool result to an output that can be
|
|
|
731
911
|
|
|
732
912
|
If not provided, the tool result will be sent as a JSON object.
|
|
733
913
|
*/
|
|
734
|
-
toModelOutput?: (output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>) =>
|
|
914
|
+
toModelOutput?: (output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>) => ToolResultOutput;
|
|
735
915
|
} & ({
|
|
736
916
|
/**
|
|
737
917
|
Tool with user-defined input and output schemas.
|
|
@@ -784,7 +964,7 @@ declare function dynamicTool(tool: {
|
|
|
784
964
|
providerOptions?: ProviderOptions;
|
|
785
965
|
inputSchema: FlexibleSchema<unknown>;
|
|
786
966
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
787
|
-
toModelOutput?: (output: unknown) =>
|
|
967
|
+
toModelOutput?: (output: unknown) => ToolResultOutput;
|
|
788
968
|
/**
|
|
789
969
|
* Whether the tool needs approval before it can be executed.
|
|
790
970
|
*/
|
|
@@ -961,4 +1141,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
961
1141
|
dynamic?: boolean;
|
|
962
1142
|
}
|
|
963
1143
|
|
|
964
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1144
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions
|
|
1
|
+
import { JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
|
|
2
2
|
import * as z4 from 'zod/v4';
|
|
3
3
|
import { ZodType } from 'zod/v4';
|
|
4
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
@@ -232,6 +232,15 @@ declare function injectJsonInstructionIntoMessages({ messages, schema, schemaPre
|
|
|
232
232
|
|
|
233
233
|
declare function isAbortError(error: unknown): error is Error;
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Type guard that checks whether a value is not `null` or `undefined`.
|
|
237
|
+
*
|
|
238
|
+
* @template T - The type of the value to check.
|
|
239
|
+
* @param value - The value to check.
|
|
240
|
+
* @returns `true` if the value is neither `null` nor `undefined`, otherwise `false`.
|
|
241
|
+
*/
|
|
242
|
+
declare function isNonNullable<T>(value: T | undefined | null): value is NonNullable<T>;
|
|
243
|
+
|
|
235
244
|
/**
|
|
236
245
|
* Checks if the given URL is supported natively by the model.
|
|
237
246
|
*
|
|
@@ -352,6 +361,11 @@ declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, fa
|
|
|
352
361
|
responseHeaders?: Record<string, string>;
|
|
353
362
|
}>;
|
|
354
363
|
|
|
364
|
+
/**
|
|
365
|
+
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
366
|
+
*/
|
|
367
|
+
type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
368
|
+
|
|
355
369
|
/**
|
|
356
370
|
Additional provider-specific options.
|
|
357
371
|
|
|
@@ -360,11 +374,6 @@ provider-specific functionality that can be fully encapsulated in the provider.
|
|
|
360
374
|
*/
|
|
361
375
|
type ProviderOptions = SharedV3ProviderOptions;
|
|
362
376
|
|
|
363
|
-
/**
|
|
364
|
-
Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
|
|
365
|
-
*/
|
|
366
|
-
type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
|
|
367
|
-
|
|
368
377
|
/**
|
|
369
378
|
Text content part of a prompt. It contains a string of text.
|
|
370
379
|
*/
|
|
@@ -495,7 +504,7 @@ interface ToolResultPart {
|
|
|
495
504
|
/**
|
|
496
505
|
Result of the tool call. This is a JSON-serializable object.
|
|
497
506
|
*/
|
|
498
|
-
output:
|
|
507
|
+
output: ToolResultOutput;
|
|
499
508
|
/**
|
|
500
509
|
Additional provider-specific metadata. They are passed through
|
|
501
510
|
to the provider from the AI SDK and enable provider-specific
|
|
@@ -503,6 +512,177 @@ interface ToolResultPart {
|
|
|
503
512
|
*/
|
|
504
513
|
providerOptions?: ProviderOptions;
|
|
505
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* Output of a tool result.
|
|
517
|
+
*/
|
|
518
|
+
type ToolResultOutput = {
|
|
519
|
+
/**
|
|
520
|
+
* Text tool output that should be directly sent to the API.
|
|
521
|
+
*/
|
|
522
|
+
type: 'text';
|
|
523
|
+
value: string;
|
|
524
|
+
/**
|
|
525
|
+
* Provider-specific options.
|
|
526
|
+
*/
|
|
527
|
+
providerOptions?: ProviderOptions;
|
|
528
|
+
} | {
|
|
529
|
+
type: 'json';
|
|
530
|
+
value: JSONValue;
|
|
531
|
+
/**
|
|
532
|
+
* Provider-specific options.
|
|
533
|
+
*/
|
|
534
|
+
providerOptions?: ProviderOptions;
|
|
535
|
+
} | {
|
|
536
|
+
/**
|
|
537
|
+
* Type when the user has denied the execution of the tool call.
|
|
538
|
+
*/
|
|
539
|
+
type: 'execution-denied';
|
|
540
|
+
/**
|
|
541
|
+
* Optional reason for the execution denial.
|
|
542
|
+
*/
|
|
543
|
+
reason?: string;
|
|
544
|
+
/**
|
|
545
|
+
* Provider-specific options.
|
|
546
|
+
*/
|
|
547
|
+
providerOptions?: ProviderOptions;
|
|
548
|
+
} | {
|
|
549
|
+
type: 'error-text';
|
|
550
|
+
value: string;
|
|
551
|
+
/**
|
|
552
|
+
* Provider-specific options.
|
|
553
|
+
*/
|
|
554
|
+
providerOptions?: ProviderOptions;
|
|
555
|
+
} | {
|
|
556
|
+
type: 'error-json';
|
|
557
|
+
value: JSONValue;
|
|
558
|
+
/**
|
|
559
|
+
* Provider-specific options.
|
|
560
|
+
*/
|
|
561
|
+
providerOptions?: ProviderOptions;
|
|
562
|
+
} | {
|
|
563
|
+
type: 'content';
|
|
564
|
+
value: Array<{
|
|
565
|
+
type: 'text';
|
|
566
|
+
/**
|
|
567
|
+
Text content.
|
|
568
|
+
*/
|
|
569
|
+
text: string;
|
|
570
|
+
/**
|
|
571
|
+
* Provider-specific options.
|
|
572
|
+
*/
|
|
573
|
+
providerOptions?: ProviderOptions;
|
|
574
|
+
} | {
|
|
575
|
+
/**
|
|
576
|
+
* @deprecated Use image-data or file-data instead.
|
|
577
|
+
*/
|
|
578
|
+
type: 'media';
|
|
579
|
+
data: string;
|
|
580
|
+
mediaType: string;
|
|
581
|
+
} | {
|
|
582
|
+
type: 'file-data';
|
|
583
|
+
/**
|
|
584
|
+
Base-64 encoded media data.
|
|
585
|
+
*/
|
|
586
|
+
data: string;
|
|
587
|
+
/**
|
|
588
|
+
IANA media type.
|
|
589
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
590
|
+
*/
|
|
591
|
+
mediaType: string;
|
|
592
|
+
/**
|
|
593
|
+
* Optional filename of the file.
|
|
594
|
+
*/
|
|
595
|
+
filename?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Provider-specific options.
|
|
598
|
+
*/
|
|
599
|
+
providerOptions?: ProviderOptions;
|
|
600
|
+
} | {
|
|
601
|
+
type: 'file-url';
|
|
602
|
+
/**
|
|
603
|
+
* URL of the file.
|
|
604
|
+
*/
|
|
605
|
+
url: string;
|
|
606
|
+
/**
|
|
607
|
+
* Provider-specific options.
|
|
608
|
+
*/
|
|
609
|
+
providerOptions?: ProviderOptions;
|
|
610
|
+
} | {
|
|
611
|
+
type: 'file-id';
|
|
612
|
+
/**
|
|
613
|
+
* ID of the file.
|
|
614
|
+
*
|
|
615
|
+
* If you use multiple providers, you need to
|
|
616
|
+
* specify the provider specific ids using
|
|
617
|
+
* the Record option. The key is the provider
|
|
618
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
619
|
+
*/
|
|
620
|
+
fileId: string | Record<string, string>;
|
|
621
|
+
/**
|
|
622
|
+
* Provider-specific options.
|
|
623
|
+
*/
|
|
624
|
+
providerOptions?: ProviderOptions;
|
|
625
|
+
} | {
|
|
626
|
+
/**
|
|
627
|
+
* Images that are referenced using base64 encoded data.
|
|
628
|
+
*/
|
|
629
|
+
type: 'image-data';
|
|
630
|
+
/**
|
|
631
|
+
Base-64 encoded image data.
|
|
632
|
+
*/
|
|
633
|
+
data: string;
|
|
634
|
+
/**
|
|
635
|
+
IANA media type.
|
|
636
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
637
|
+
*/
|
|
638
|
+
mediaType: string;
|
|
639
|
+
/**
|
|
640
|
+
* Provider-specific options.
|
|
641
|
+
*/
|
|
642
|
+
providerOptions?: ProviderOptions;
|
|
643
|
+
} | {
|
|
644
|
+
/**
|
|
645
|
+
* Images that are referenced using a URL.
|
|
646
|
+
*/
|
|
647
|
+
type: 'image-url';
|
|
648
|
+
/**
|
|
649
|
+
* URL of the image.
|
|
650
|
+
*/
|
|
651
|
+
url: string;
|
|
652
|
+
/**
|
|
653
|
+
* Provider-specific options.
|
|
654
|
+
*/
|
|
655
|
+
providerOptions?: ProviderOptions;
|
|
656
|
+
} | {
|
|
657
|
+
/**
|
|
658
|
+
* Images that are referenced using a provider file id.
|
|
659
|
+
*/
|
|
660
|
+
type: 'image-file-id';
|
|
661
|
+
/**
|
|
662
|
+
* Image that is referenced using a provider file id.
|
|
663
|
+
*
|
|
664
|
+
* If you use multiple providers, you need to
|
|
665
|
+
* specify the provider specific ids using
|
|
666
|
+
* the Record option. The key is the provider
|
|
667
|
+
* name, e.g. 'openai' or 'anthropic'.
|
|
668
|
+
*/
|
|
669
|
+
fileId: string | Record<string, string>;
|
|
670
|
+
/**
|
|
671
|
+
* Provider-specific options.
|
|
672
|
+
*/
|
|
673
|
+
providerOptions?: ProviderOptions;
|
|
674
|
+
} | {
|
|
675
|
+
/**
|
|
676
|
+
* Custom content part. This can be used to implement
|
|
677
|
+
* provider-specific content parts.
|
|
678
|
+
*/
|
|
679
|
+
type: 'custom';
|
|
680
|
+
/**
|
|
681
|
+
* Provider-specific options.
|
|
682
|
+
*/
|
|
683
|
+
providerOptions?: ProviderOptions;
|
|
684
|
+
}>;
|
|
685
|
+
};
|
|
506
686
|
|
|
507
687
|
/**
|
|
508
688
|
* Tool approval request prompt part.
|
|
@@ -731,7 +911,7 @@ Optional conversion function that maps the tool result to an output that can be
|
|
|
731
911
|
|
|
732
912
|
If not provided, the tool result will be sent as a JSON object.
|
|
733
913
|
*/
|
|
734
|
-
toModelOutput?: (output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>) =>
|
|
914
|
+
toModelOutput?: (output: 0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>) => ToolResultOutput;
|
|
735
915
|
} & ({
|
|
736
916
|
/**
|
|
737
917
|
Tool with user-defined input and output schemas.
|
|
@@ -784,7 +964,7 @@ declare function dynamicTool(tool: {
|
|
|
784
964
|
providerOptions?: ProviderOptions;
|
|
785
965
|
inputSchema: FlexibleSchema<unknown>;
|
|
786
966
|
execute: ToolExecuteFunction<unknown, unknown>;
|
|
787
|
-
toModelOutput?: (output: unknown) =>
|
|
967
|
+
toModelOutput?: (output: unknown) => ToolResultOutput;
|
|
788
968
|
/**
|
|
789
969
|
* Whether the tool needs approval before it can be executed.
|
|
790
970
|
*/
|
|
@@ -961,4 +1141,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
961
1141
|
dynamic?: boolean;
|
|
962
1142
|
}
|
|
963
1143
|
|
|
964
|
-
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1144
|
+
export { type AssistantContent, type AssistantModelMessage, type DataContent, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type ModelMessage, type ParseResult, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderOptions, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolModelMessage, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, delay, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ __export(src_exports, {
|
|
|
58
58
|
getRuntimeEnvironmentUserAgent: () => getRuntimeEnvironmentUserAgent,
|
|
59
59
|
injectJsonInstructionIntoMessages: () => injectJsonInstructionIntoMessages,
|
|
60
60
|
isAbortError: () => isAbortError,
|
|
61
|
+
isNonNullable: () => isNonNullable,
|
|
61
62
|
isParsableJson: () => isParsableJson,
|
|
62
63
|
isUrlSupported: () => isUrlSupported,
|
|
63
64
|
jsonSchema: () => jsonSchema,
|
|
@@ -280,7 +281,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
280
281
|
}
|
|
281
282
|
|
|
282
283
|
// src/version.ts
|
|
283
|
-
var VERSION = true ? "4.0.0-beta.
|
|
284
|
+
var VERSION = true ? "4.0.0-beta.19" : "0.0.0-test";
|
|
284
285
|
|
|
285
286
|
// src/get-from-api.ts
|
|
286
287
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -391,6 +392,11 @@ function injectJsonInstructionIntoMessages({
|
|
|
391
392
|
];
|
|
392
393
|
}
|
|
393
394
|
|
|
395
|
+
// src/is-non-nullable.ts
|
|
396
|
+
function isNonNullable(value) {
|
|
397
|
+
return value != null;
|
|
398
|
+
}
|
|
399
|
+
|
|
394
400
|
// src/is-url-supported.ts
|
|
395
401
|
function isUrlSupported({
|
|
396
402
|
mediaType,
|
|
@@ -2456,6 +2462,7 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2456
2462
|
getRuntimeEnvironmentUserAgent,
|
|
2457
2463
|
injectJsonInstructionIntoMessages,
|
|
2458
2464
|
isAbortError,
|
|
2465
|
+
isNonNullable,
|
|
2459
2466
|
isParsableJson,
|
|
2460
2467
|
isUrlSupported,
|
|
2461
2468
|
jsonSchema,
|