@ai-sdk/provider-utils 4.0.53 → 4.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/combine-headers.ts +1 -1
- package/src/delay.ts +1 -1
- package/src/embedding-model-capabilities.ts +23 -0
- package/src/index.ts +5 -1
- package/src/is-url-supported.ts +7 -3
- package/src/resolve.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +1 -1
- package/src/types/content-part.ts +6 -0
- package/src/types/tool-approval-request.ts +8 -0
- package/src/validate-download-url.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3983fea: fix(provider): preserve media types on tool result file URLs and match full MIME types exactly when checking native URL support.
|
|
8
|
+
- Updated dependencies [3983fea]
|
|
9
|
+
- @ai-sdk/provider@3.0.18
|
|
10
|
+
|
|
11
|
+
## 4.0.54
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 069a945: Fix Google `embedMany` calls with more than 100 values by keeping per-value multimodal content aligned across automatic batches, including text-only entries. Validate content length before sending requests and validate each batch's provider options after middleware transforms them.
|
|
16
|
+
- d1a36d2: fix(ai): execute manually approved tool inputs produced by schema transforms
|
|
17
|
+
|
|
18
|
+
Preserve approved inputs during revalidation and reject histories whose reconstructed schema output differs, including signed approvals with missing original input. Validate transformed UI tool inputs against the reconstructed output before returning them as static tool parts.
|
|
19
|
+
|
|
20
|
+
- f7f36d2: chore: enable dead code lint rules
|
|
21
|
+
|
|
3
22
|
## 4.0.53
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt,
|
|
1
|
+
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, SharedV3ProviderOptions, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONObject, TypeValidationContext } from '@ai-sdk/provider';
|
|
2
2
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
@@ -172,6 +172,28 @@ declare class DownloadError extends AISDKError {
|
|
|
172
172
|
static isInstance(error: unknown): error is DownloadError;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
177
|
+
*
|
|
178
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
179
|
+
* embedding model specification.
|
|
180
|
+
*/
|
|
181
|
+
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
182
|
+
/**
|
|
183
|
+
* Symbol for transforming provider options for an automatically batched
|
|
184
|
+
* embedding model call.
|
|
185
|
+
*
|
|
186
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
187
|
+
* embedding model specification.
|
|
188
|
+
*/
|
|
189
|
+
declare const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER: unique symbol;
|
|
190
|
+
type EmbeddingModelProviderOptionsTransformer = (options: {
|
|
191
|
+
providerOptions: SharedV3ProviderOptions | undefined;
|
|
192
|
+
values: Array<string>;
|
|
193
|
+
startIndex: number;
|
|
194
|
+
endIndex: number;
|
|
195
|
+
}) => SharedV3ProviderOptions | undefined | PromiseLike<SharedV3ProviderOptions | undefined>;
|
|
196
|
+
|
|
175
197
|
/**
|
|
176
198
|
* Default maximum download size: 2 GiB.
|
|
177
199
|
*
|
|
@@ -203,14 +225,6 @@ declare function readResponseWithSizeLimit({ response, url, maxBytes, }: {
|
|
|
203
225
|
maxBytes?: number;
|
|
204
226
|
}): Promise<Uint8Array>;
|
|
205
227
|
|
|
206
|
-
/**
|
|
207
|
-
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
208
|
-
*
|
|
209
|
-
* This capability is experimental and intentionally lives outside the versioned
|
|
210
|
-
* embedding model specification.
|
|
211
|
-
*/
|
|
212
|
-
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
213
|
-
|
|
214
228
|
/**
|
|
215
229
|
* Fetches a URL while enforcing the SSRF download guard on every hop.
|
|
216
230
|
*
|
|
@@ -481,9 +495,9 @@ declare function isSameOrigin(url: string, baseUrl: string): boolean;
|
|
|
481
495
|
/**
|
|
482
496
|
* Checks if the given URL is supported natively by the model.
|
|
483
497
|
*
|
|
484
|
-
* @param mediaType - The media type of the URL. Case-
|
|
498
|
+
* @param mediaType - The media type of the URL. Case-insensitive.
|
|
485
499
|
* @param url - The URL to check.
|
|
486
|
-
* @param supportedUrls - A record where keys are case-
|
|
500
|
+
* @param supportedUrls - A record where keys are case-insensitive media types (or '*')
|
|
487
501
|
* and values are arrays of RegExp patterns for URLs.
|
|
488
502
|
*
|
|
489
503
|
* @returns `true` if the URL matches a pattern under the specific media type
|
|
@@ -851,6 +865,11 @@ type ToolResultOutput = {
|
|
|
851
865
|
* URL of the file.
|
|
852
866
|
*/
|
|
853
867
|
url: string;
|
|
868
|
+
/**
|
|
869
|
+
* IANA media type.
|
|
870
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
871
|
+
*/
|
|
872
|
+
mediaType?: string;
|
|
854
873
|
/**
|
|
855
874
|
* Provider-specific options.
|
|
856
875
|
*/
|
|
@@ -950,6 +969,13 @@ type ToolApprovalRequest = {
|
|
|
950
969
|
* Present only when `experimental_toolApprovalSecret` is configured.
|
|
951
970
|
*/
|
|
952
971
|
signature?: string;
|
|
972
|
+
/**
|
|
973
|
+
* Tool input before input schema validation and transformation.
|
|
974
|
+
*
|
|
975
|
+
* This is included when it differs from the validated tool input so that
|
|
976
|
+
* approved tool calls can be safely revalidated before execution.
|
|
977
|
+
*/
|
|
978
|
+
inputSchemaInput?: unknown;
|
|
953
979
|
};
|
|
954
980
|
|
|
955
981
|
/**
|
|
@@ -1563,4 +1589,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1563
1589
|
*/
|
|
1564
1590
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1565
1591
|
|
|
1566
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, fetchWithValidatedRedirects, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isNonNullable, isParsableJson, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1592
|
+
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, type EmbeddingModelProviderOptionsTransformer, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, fetchWithValidatedRedirects, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isNonNullable, isParsableJson, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt,
|
|
1
|
+
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, ImageModelV3File, AISDKError, SharedV3ProviderOptions, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, JSONObject, TypeValidationContext } from '@ai-sdk/provider';
|
|
2
2
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
@@ -172,6 +172,28 @@ declare class DownloadError extends AISDKError {
|
|
|
172
172
|
static isInstance(error: unknown): error is DownloadError;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
177
|
+
*
|
|
178
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
179
|
+
* embedding model specification.
|
|
180
|
+
*/
|
|
181
|
+
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
182
|
+
/**
|
|
183
|
+
* Symbol for transforming provider options for an automatically batched
|
|
184
|
+
* embedding model call.
|
|
185
|
+
*
|
|
186
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
187
|
+
* embedding model specification.
|
|
188
|
+
*/
|
|
189
|
+
declare const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER: unique symbol;
|
|
190
|
+
type EmbeddingModelProviderOptionsTransformer = (options: {
|
|
191
|
+
providerOptions: SharedV3ProviderOptions | undefined;
|
|
192
|
+
values: Array<string>;
|
|
193
|
+
startIndex: number;
|
|
194
|
+
endIndex: number;
|
|
195
|
+
}) => SharedV3ProviderOptions | undefined | PromiseLike<SharedV3ProviderOptions | undefined>;
|
|
196
|
+
|
|
175
197
|
/**
|
|
176
198
|
* Default maximum download size: 2 GiB.
|
|
177
199
|
*
|
|
@@ -203,14 +225,6 @@ declare function readResponseWithSizeLimit({ response, url, maxBytes, }: {
|
|
|
203
225
|
maxBytes?: number;
|
|
204
226
|
}): Promise<Uint8Array>;
|
|
205
227
|
|
|
206
|
-
/**
|
|
207
|
-
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
208
|
-
*
|
|
209
|
-
* This capability is experimental and intentionally lives outside the versioned
|
|
210
|
-
* embedding model specification.
|
|
211
|
-
*/
|
|
212
|
-
declare const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: unique symbol;
|
|
213
|
-
|
|
214
228
|
/**
|
|
215
229
|
* Fetches a URL while enforcing the SSRF download guard on every hop.
|
|
216
230
|
*
|
|
@@ -481,9 +495,9 @@ declare function isSameOrigin(url: string, baseUrl: string): boolean;
|
|
|
481
495
|
/**
|
|
482
496
|
* Checks if the given URL is supported natively by the model.
|
|
483
497
|
*
|
|
484
|
-
* @param mediaType - The media type of the URL. Case-
|
|
498
|
+
* @param mediaType - The media type of the URL. Case-insensitive.
|
|
485
499
|
* @param url - The URL to check.
|
|
486
|
-
* @param supportedUrls - A record where keys are case-
|
|
500
|
+
* @param supportedUrls - A record where keys are case-insensitive media types (or '*')
|
|
487
501
|
* and values are arrays of RegExp patterns for URLs.
|
|
488
502
|
*
|
|
489
503
|
* @returns `true` if the URL matches a pattern under the specific media type
|
|
@@ -851,6 +865,11 @@ type ToolResultOutput = {
|
|
|
851
865
|
* URL of the file.
|
|
852
866
|
*/
|
|
853
867
|
url: string;
|
|
868
|
+
/**
|
|
869
|
+
* IANA media type.
|
|
870
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
871
|
+
*/
|
|
872
|
+
mediaType?: string;
|
|
854
873
|
/**
|
|
855
874
|
* Provider-specific options.
|
|
856
875
|
*/
|
|
@@ -950,6 +969,13 @@ type ToolApprovalRequest = {
|
|
|
950
969
|
* Present only when `experimental_toolApprovalSecret` is configured.
|
|
951
970
|
*/
|
|
952
971
|
signature?: string;
|
|
972
|
+
/**
|
|
973
|
+
* Tool input before input schema validation and transformation.
|
|
974
|
+
*
|
|
975
|
+
* This is included when it differs from the validated tool input so that
|
|
976
|
+
* approved tool calls can be safely revalidated before execution.
|
|
977
|
+
*/
|
|
978
|
+
inputSchemaInput?: unknown;
|
|
953
979
|
};
|
|
954
980
|
|
|
955
981
|
/**
|
|
@@ -1563,4 +1589,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1563
1589
|
*/
|
|
1564
1590
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1565
1591
|
|
|
1566
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, fetchWithValidatedRedirects, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isNonNullable, isParsableJson, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1592
|
+
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER, type EmbeddingModelProviderOptionsTransformer, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, fetchWithValidatedRedirects, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isNonNullable, isParsableJson, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, stripFileExtension, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
DelayedPromise: () => DelayedPromise,
|
|
35
35
|
DownloadError: () => DownloadError,
|
|
36
36
|
EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL: () => EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
|
|
37
|
+
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER: () => EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
37
38
|
EventSourceParserStream: () => import_stream2.EventSourceParserStream,
|
|
38
39
|
VERSION: () => VERSION,
|
|
39
40
|
asSchema: () => asSchema,
|
|
@@ -106,7 +107,7 @@ function combineHeaders(...headers) {
|
|
|
106
107
|
return headers.reduce(
|
|
107
108
|
(combinedHeaders, currentHeaders) => ({
|
|
108
109
|
...combinedHeaders,
|
|
109
|
-
...currentHeaders
|
|
110
|
+
...currentHeaders
|
|
110
111
|
}),
|
|
111
112
|
{}
|
|
112
113
|
);
|
|
@@ -184,7 +185,7 @@ function createToolNameMapping({
|
|
|
184
185
|
// src/delay.ts
|
|
185
186
|
async function delay(delayInMs, options) {
|
|
186
187
|
if (delayInMs == null) {
|
|
187
|
-
return
|
|
188
|
+
return;
|
|
188
189
|
}
|
|
189
190
|
const signal = options == null ? void 0 : options.abortSignal;
|
|
190
191
|
return new Promise((resolve2, reject) => {
|
|
@@ -401,7 +402,6 @@ function validateDownloadUrl(url) {
|
|
|
401
402
|
message: `URL with IP address ${hostname} is not allowed`
|
|
402
403
|
});
|
|
403
404
|
}
|
|
404
|
-
return;
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
function validateDownloadAddress({
|
|
@@ -739,6 +739,9 @@ async function downloadBlob(url, options) {
|
|
|
739
739
|
var EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = /* @__PURE__ */ Symbol.for(
|
|
740
740
|
"vercel.ai.embeddingModel.maxInputBytesPerCall"
|
|
741
741
|
);
|
|
742
|
+
var EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER = /* @__PURE__ */ Symbol.for(
|
|
743
|
+
"vercel.ai.embeddingModel.providerOptionsTransformer"
|
|
744
|
+
);
|
|
742
745
|
|
|
743
746
|
// src/generate-id.ts
|
|
744
747
|
var import_provider2 = require("@ai-sdk/provider");
|
|
@@ -923,7 +926,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
923
926
|
}
|
|
924
927
|
|
|
925
928
|
// src/version.ts
|
|
926
|
-
var VERSION = true ? "4.0.
|
|
929
|
+
var VERSION = true ? "4.0.55" : "0.0.0-test";
|
|
927
930
|
|
|
928
931
|
// src/get-from-api.ts
|
|
929
932
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -1059,7 +1062,9 @@ function isUrlSupported({
|
|
|
1059
1062
|
return Object.entries(supportedUrls).map(([key, value]) => {
|
|
1060
1063
|
const mediaType2 = key.toLowerCase();
|
|
1061
1064
|
return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
|
|
1062
|
-
}).filter(
|
|
1065
|
+
}).filter(
|
|
1066
|
+
({ mediaTypePrefix }) => mediaTypePrefix === "" || mediaTypePrefix.endsWith("/") ? mediaType.startsWith(mediaTypePrefix) : mediaType === mediaTypePrefix
|
|
1067
|
+
).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));
|
|
1063
1068
|
}
|
|
1064
1069
|
|
|
1065
1070
|
// src/load-api-key.ts
|
|
@@ -1496,7 +1501,7 @@ var zodPatterns = {
|
|
|
1496
1501
|
/**
|
|
1497
1502
|
* `a-z` was added to replicate /i flag
|
|
1498
1503
|
*/
|
|
1499
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
1504
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
1500
1505
|
/**
|
|
1501
1506
|
* Constructed a valid Unicode RegExp
|
|
1502
1507
|
*
|
|
@@ -2873,7 +2878,7 @@ async function resolve(value) {
|
|
|
2873
2878
|
if (typeof value === "function") {
|
|
2874
2879
|
value = value();
|
|
2875
2880
|
}
|
|
2876
|
-
return
|
|
2881
|
+
return value;
|
|
2877
2882
|
}
|
|
2878
2883
|
|
|
2879
2884
|
// src/retry-with-exponential-backoff.ts
|
|
@@ -3211,6 +3216,7 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
3211
3216
|
DelayedPromise,
|
|
3212
3217
|
DownloadError,
|
|
3213
3218
|
EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
|
|
3219
|
+
EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
3214
3220
|
EventSourceParserStream,
|
|
3215
3221
|
VERSION,
|
|
3216
3222
|
asSchema,
|