@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "4.0.53",
3
+ "version": "4.0.55",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "@standard-schema/spec": "^1.1.0",
37
37
  "eventsource-parser": "^3.0.8",
38
38
  "undici": "^6.28.0",
39
- "@ai-sdk/provider": "3.0.17"
39
+ "@ai-sdk/provider": "3.0.18"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "20.17.24",
@@ -4,7 +4,7 @@ export function combineHeaders(
4
4
  return headers.reduce(
5
5
  (combinedHeaders, currentHeaders) => ({
6
6
  ...combinedHeaders,
7
- ...(currentHeaders ?? {}),
7
+ ...currentHeaders,
8
8
  }),
9
9
  {},
10
10
  ) as Record<string, string | undefined>;
package/src/delay.ts CHANGED
@@ -12,7 +12,7 @@ export async function delay(
12
12
  },
13
13
  ): Promise<void> {
14
14
  if (delayInMs == null) {
15
- return Promise.resolve();
15
+ return;
16
16
  }
17
17
 
18
18
  const signal = options?.abortSignal;
@@ -1,3 +1,5 @@
1
+ import type { SharedV3ProviderOptions } from '@ai-sdk/provider';
2
+
1
3
  /**
2
4
  * Symbol for exposing the UTF-8 input byte budget of an embedding model.
3
5
  *
@@ -7,3 +9,24 @@
7
9
  export const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = Symbol.for(
8
10
  'vercel.ai.embeddingModel.maxInputBytesPerCall',
9
11
  );
12
+
13
+ /**
14
+ * Symbol for transforming provider options for an automatically batched
15
+ * embedding model call.
16
+ *
17
+ * This capability is experimental and intentionally lives outside the versioned
18
+ * embedding model specification.
19
+ */
20
+ export const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER = Symbol.for(
21
+ 'vercel.ai.embeddingModel.providerOptionsTransformer',
22
+ );
23
+
24
+ export type EmbeddingModelProviderOptionsTransformer = (options: {
25
+ providerOptions: SharedV3ProviderOptions | undefined;
26
+ values: Array<string>;
27
+ startIndex: number;
28
+ endIndex: number;
29
+ }) =>
30
+ | SharedV3ProviderOptions
31
+ | undefined
32
+ | PromiseLike<SharedV3ProviderOptions | undefined>;
package/src/index.ts CHANGED
@@ -11,11 +11,15 @@ export { convertImageModelFileToDataUri } from './convert-image-model-file-to-da
11
11
  export { convertToFormData } from './convert-to-form-data';
12
12
  export { downloadBlob } from './download-blob';
13
13
  export { DownloadError } from './download-error';
14
+ export {
15
+ EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
16
+ EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
17
+ type EmbeddingModelProviderOptionsTransformer,
18
+ } from './embedding-model-capabilities';
14
19
  export {
15
20
  readResponseWithSizeLimit,
16
21
  DEFAULT_MAX_DOWNLOAD_SIZE,
17
22
  } from './read-response-with-size-limit';
18
- export { EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from './embedding-model-capabilities';
19
23
  export { fetchWithValidatedRedirects } from './fetch-with-validated-redirects';
20
24
  export * from './fetch-function';
21
25
  export { createIdGenerator, generateId, type IdGenerator } from './generate-id';
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Checks if the given URL is supported natively by the model.
3
3
  *
4
- * @param mediaType - The media type of the URL. Case-sensitive.
4
+ * @param mediaType - The media type of the URL. Case-insensitive.
5
5
  * @param url - The URL to check.
6
- * @param supportedUrls - A record where keys are case-sensitive media types (or '*')
6
+ * @param supportedUrls - A record where keys are case-insensitive media types (or '*')
7
7
  * and values are arrays of RegExp patterns for URLs.
8
8
  *
9
9
  * @returns `true` if the URL matches a pattern under the specific media type
@@ -32,7 +32,11 @@ export function isUrlSupported({
32
32
  : { mediaTypePrefix: mediaType.replace(/\*/, ''), regexes: value };
33
33
  })
34
34
  // gather all regexp pattern from matched media type prefixes:
35
- .filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix))
35
+ .filter(({ mediaTypePrefix }) =>
36
+ mediaTypePrefix === '' || mediaTypePrefix.endsWith('/')
37
+ ? mediaType.startsWith(mediaTypePrefix)
38
+ : mediaType === mediaTypePrefix,
39
+ )
36
40
  .flatMap(({ regexes }) => regexes)
37
41
  // check if any pattern matches the url:
38
42
  .some(pattern => pattern.test(url))
package/src/resolve.ts CHANGED
@@ -13,5 +13,5 @@ export async function resolve<T>(value: Resolvable<T>): Promise<T> {
13
13
  }
14
14
 
15
15
  // Otherwise just resolve whatever we got (value or promise)
16
- return Promise.resolve(value as T);
16
+ return value as T;
17
17
  }
@@ -20,7 +20,7 @@ export const zodPatterns = {
20
20
  * `a-z` was added to replicate /i flag
21
21
  */
22
22
  email:
23
- /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
23
+ /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
24
24
  /**
25
25
  * Constructed a valid Unicode RegExp
26
26
  *
@@ -281,6 +281,12 @@ export type ToolResultOutput =
281
281
  */
282
282
  url: string;
283
283
 
284
+ /**
285
+ * IANA media type.
286
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
287
+ */
288
+ mediaType?: string;
289
+
284
290
  /**
285
291
  * Provider-specific options.
286
292
  */
@@ -19,4 +19,12 @@ export type ToolApprovalRequest = {
19
19
  * Present only when `experimental_toolApprovalSecret` is configured.
20
20
  */
21
21
  signature?: string;
22
+
23
+ /**
24
+ * Tool input before input schema validation and transformation.
25
+ *
26
+ * This is included when it differs from the validated tool input so that
27
+ * approved tool calls can be safely revalidated before execution.
28
+ */
29
+ inputSchemaInput?: unknown;
22
30
  };
@@ -78,7 +78,6 @@ export function validateDownloadUrl(url: string): void {
78
78
  message: `URL with IP address ${hostname} is not allowed`,
79
79
  });
80
80
  }
81
- return;
82
81
  }
83
82
  }
84
83