@ai-sdk/provider-utils 5.0.45 → 5.0.47

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": "5.0.45",
3
+ "version": "5.0.47",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@ai-sdk/provider": "4.0.17",
40
+ "@ai-sdk/provider": "4.0.18",
41
41
  "@standard-schema/spec": "^1.1.0",
42
42
  "@workflow/serde": "4.1.0",
43
43
  "eventsource-parser": "^3.0.8",
@@ -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;
@@ -299,8 +299,6 @@ function detectMediaTypeBySignatures<T extends MediaTypeSignatures>({
299
299
  return signature.mediaType;
300
300
  }
301
301
  }
302
-
303
- return undefined;
304
302
  }
305
303
 
306
304
  const topLevelSignatureTables = {
@@ -1,3 +1,5 @@
1
+ import type { SharedV4ProviderOptions } 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: SharedV4ProviderOptions | undefined;
26
+ values: Array<string>;
27
+ startIndex: number;
28
+ endIndex: number;
29
+ }) =>
30
+ | SharedV4ProviderOptions
31
+ | undefined
32
+ | PromiseLike<SharedV4ProviderOptions | undefined>;
@@ -36,8 +36,6 @@ function findNetworkError(
36
36
 
37
37
  current = (current as Error & { cause?: unknown }).cause;
38
38
  }
39
-
40
- return undefined;
41
39
  }
42
40
 
43
41
  export function handleFetchError({
package/src/index.ts CHANGED
@@ -30,7 +30,11 @@ export {
30
30
  } from './detect-media-type';
31
31
  export { downloadBlob } from './download-blob';
32
32
  export { DownloadError } from './download-error';
33
- export { EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from './embedding-model-capabilities';
33
+ export {
34
+ EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
35
+ EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
36
+ type EmbeddingModelProviderOptionsTransformer,
37
+ } from './embedding-model-capabilities';
34
38
  export {
35
39
  fetchWithValidatedEndpoint,
36
40
  fetchWithValidatedRedirects,
@@ -31,8 +31,6 @@ export function normalizeBatchRequestCounts({
31
31
  failed,
32
32
  };
33
33
  }
34
-
35
- return undefined;
36
34
  }
37
35
 
38
36
  function isNonNegativeSafeInteger(
package/src/resolve.ts CHANGED
@@ -28,5 +28,5 @@ export async function resolve<T>(value: Resolvable<T>): Promise<T> {
28
28
  }
29
29
 
30
30
  // Otherwise just resolve whatever we got (value or promise)
31
- return Promise.resolve(value as T);
31
+ return value as T;
32
32
  }
@@ -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
  *
@@ -31,4 +31,12 @@ export type ToolApprovalRequest = {
31
31
  * Present only when `experimental_toolApprovalSecret` is configured.
32
32
  */
33
33
  signature?: string;
34
+
35
+ /**
36
+ * Tool input before input schema validation and transformation.
37
+ *
38
+ * This is included when it differs from the validated tool input so that
39
+ * approved tool calls can be safely revalidated before execution.
40
+ */
41
+ inputSchemaInput?: unknown;
34
42
  };
@@ -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