@ai-sdk/provider-utils 5.0.7 → 5.0.9

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 4be62c1: fix(provider-utils): validate provider-response URLs in `getFromApi`
8
+
9
+ `getFromApi` now has a `validateUrl` flag. It is optional so existing callers keep compiling (omitting it behaves like `false`, i.e. no validation), but all AI SDK provider packages set it explicitly at every call site so each one makes a visible trust decision. When `true`, the URL is routed through `fetchWithValidatedRedirects` — the same guard used by `downloadBlob` — which rejects private/loopback/link-local targets, re-validates every redirect hop, strips proxy/metadata/cookie request headers, and drops all caller headers except the user-agent on cross-origin redirects (custom API-key headers must not follow a redirect off-origin any more than `Authorization` may); blocked URLs throw `DownloadError`. It is enabled at the image/video/audio download and polling call sites where the URL comes from a provider response body; URLs built from developer-configured endpoints pass `validateUrl: false` and are unaffected.
10
+
11
+ A new optional `credentialedOrigin` withholds caller headers unless the URL is same-origin with it, so the API key is not sent to a response-supplied host on a different origin.
12
+
13
+ A new optional `trustedOrigin` exempts URLs (and redirect hops) that are same-origin with the developer-configured provider endpoint from target validation, so self-hosted and localhost deployments whose response URLs point back at the configured host keep working; all other hops are still validated.
14
+
15
+ Also closes range gaps in `validateDownloadUrl` (IPv4 `224.0.0.0/4` multicast and the TEST-NET documentation ranges `192.0.2.0/24`, `198.51.100.0/24`, `203.0.113.0/24`; IPv6 documentation ranges `2001:db8::/32` and `3fff::/20`), and follows only the fetch-spec redirect status codes (301/302/303/307/308) — a `Location` header on any other status is not followed. This guard performs string/literal checks only and does not resolve DNS; hostnames that resolve to private addresses and DNS rebinding remain out of scope and must be constrained at the network layer (or by injecting a Node `fetch` that pins the resolved IP at connect time) for server deployments handling untrusted URLs. See `contributing/secure-url-handling.md`.
16
+
17
+ - 7805e4a: Add experimental transcription-stream WebSocket envelope (standard doStream-over-WebSocket serialization): frame type constants, `experimental_parseTranscriptionStreamClientFrame`, `experimental_serializeTranscriptionStreamPart`, and `experimental_parseTranscriptionStreamPart` (all APIs are exported with experimental prefixes). `serializeTranscriptionStreamPart` returns `undefined` for payloads that are not JSON-serializable (callers drop the frame) and serializes cross-realm `Error` payloads by brand check.
18
+ - cd12954: Reject empty OpenAI, Anthropic, and Replicate base URLs with a helpful AI SDK
19
+ invalid argument error.
20
+
21
+ ## 5.0.8
22
+
23
+ ### Patch Changes
24
+
25
+ - e193290: Add `connectToWebSocket` to `@ai-sdk/provider-utils`: a shared WebSocket connect layer (constructor resolution, header hygiene, abort wiring, message decoding) analogous to `postToApi` for HTTP. The openai and xai streaming transcription models now use it instead of hand-rolled connects. For openai and xai this also means WebSocket constructor failures now surface as stream errors instead of throwing synchronously from `doStream`, an already-aborted signal no longer constructs a socket, and the caller's audio stream is cancelled on pre-open failures. Messages are processed in order with close handling deferred behind pending frames, audio send loops apply backpressure via the socket's bufferedAmount, and failed sends cancel the caller's audio stream.
26
+
3
27
  ## 5.0.7
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, APICallError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, JSONObject, LanguageModelV4FilePart, LanguageModelV4StreamPart, SharedV4ProviderMetadata, TypeValidationContext } from '@ai-sdk/provider';
1
+ import { SharedV4FileDataUrl, SharedV4FileDataReference, SharedV4FileDataText, SharedV4ProviderOptions, SharedV4ProviderReference, JSONValue, ImageModelV4File, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool, AISDKError, JSONSchema7, JSONParseError, TypeValidationError, APICallError, LanguageModelV4Prompt, LanguageModelV4CallOptions, SharedV4Warning, JSONObject, LanguageModelV4FilePart, LanguageModelV4StreamPart, SharedV4ProviderMetadata, Experimental_TranscriptionModelV4StreamPart, TypeValidationContext } from '@ai-sdk/provider';
2
2
  export { getErrorMessage } from '@ai-sdk/provider';
3
3
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
4
4
  export * from '@standard-schema/spec';
@@ -19,6 +19,77 @@ declare function asArray<T>(value: Arrayable<T>): T[];
19
19
 
20
20
  declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
21
21
 
22
+ type WebSocketLike = {
23
+ readyState: number;
24
+ /** Bytes queued by `send` but not yet transmitted (native + `ws`). */
25
+ readonly bufferedAmount?: number;
26
+ send(data: string | Uint8Array | ArrayBuffer): void;
27
+ close(code?: number, reason?: string): void;
28
+ onopen: ((event: unknown) => void) | null;
29
+ onmessage: ((event: {
30
+ data: unknown;
31
+ }) => void) | null;
32
+ onerror: ((event: unknown) => void) | null;
33
+ onclose: ((event: unknown) => void) | null;
34
+ };
35
+ type WebSocketConstructor = new (url: string | URL, protocols?: string | string[], options?: {
36
+ headers?: Record<string, string | undefined>;
37
+ }) => WebSocketLike;
38
+ declare function getWebSocketConstructor(webSocket: WebSocketConstructor | undefined): WebSocketConstructor;
39
+ /**
40
+ * Converts an http(s) URL to the corresponding ws(s) URL.
41
+ */
42
+ declare function toWebSocketUrl(url: string | URL): URL;
43
+ /**
44
+ * Reads WebSocket message data as text, handling string, binary,
45
+ * and Blob payloads.
46
+ */
47
+ declare function readWebSocketMessageText(data: unknown): Promise<string>;
48
+ /**
49
+ * Waits until the socket's send buffer drains below `highWaterMark` bytes.
50
+ * No-op for implementations that do not expose `bufferedAmount`. There is no
51
+ * portable drain event, so this polls. Returns as soon as the socket is no
52
+ * longer open or the signal aborts — `bufferedAmount` never drains on a
53
+ * closed socket, so waiting on would poll forever.
54
+ */
55
+ declare function waitForWebSocketBufferDrain(socket: WebSocketLike, { highWaterMark, pollIntervalMs, abortSignal, }?: {
56
+ highWaterMark?: number;
57
+ pollIntervalMs?: number;
58
+ abortSignal?: AbortSignal;
59
+ }): Promise<void>;
60
+
61
+ interface WebSocketConnection {
62
+ /** Undefined when the constructor threw or the signal was already aborted. */
63
+ socket: WebSocketLike | undefined;
64
+ /**
65
+ * Unregisters the abort listener and closes the socket. Never throws.
66
+ * Handlers stay attached; callers guard their own terminal state.
67
+ */
68
+ close: (code?: number) => void;
69
+ }
70
+ /**
71
+ * Opens a WebSocket for a provider model, owning the transport-generic layer
72
+ * (analogous to `postToApi` for HTTP): constructor resolution, header hygiene,
73
+ * abort wiring, and message decoding. Callers own the URL, the auth channel
74
+ * (subprotocols vs headers), and the wire protocol.
75
+ */
76
+ declare function connectToWebSocket({ url, protocols, headers, webSocket, abortSignal, onOpen, onMessageText, onProcessingError, onSocketError, onClose, onAbort, }: {
77
+ url: string | URL;
78
+ protocols?: string | string[];
79
+ headers?: Record<string, string | undefined>;
80
+ webSocket?: WebSocketConstructor;
81
+ abortSignal?: AbortSignal;
82
+ onOpen?: (socket: WebSocketLike) => void;
83
+ /** One decoded message. Throws and rejections go to `onProcessingError`. */
84
+ onMessageText: (text: string) => void | PromiseLike<void>;
85
+ /** Constructor throws and message decoding/processing failures. */
86
+ onProcessingError: (error: unknown) => void;
87
+ onSocketError?: () => void;
88
+ onClose?: () => void;
89
+ /** Also called (without opening a socket) when the signal is already aborted. */
90
+ onAbort?: (reason: unknown) => void;
91
+ }): WebSocketConnection;
92
+
22
93
  /**
23
94
  * Converts an AsyncIterator to a ReadableStream.
24
95
  *
@@ -739,33 +810,67 @@ declare class DownloadError extends AISDKError {
739
810
  }
740
811
 
741
812
  /**
742
- * Fetches a URL while enforcing the SSRF download guard on every hop.
813
+ * Fetch function type (standardizes the version of fetch used).
814
+ */
815
+ type FetchFunction = typeof globalThis.fetch;
816
+
817
+ /**
818
+ * Fetches a URL while enforcing the download guard on every hop.
743
819
  *
744
820
  * Redirects are followed manually (`redirect: 'manual'`) so each hop is
745
821
  * validated with {@link validateDownloadUrl} *before* it is requested. Relying
746
822
  * on the default `redirect: 'follow'` would issue the request to a redirect
747
823
  * target (e.g. an internal address) before we ever see its URL, defeating the
748
- * SSRF guard.
824
+ * guard.
825
+ *
826
+ * Request headers are also protected: {@link sanitizeRequestHeaders} strips
827
+ * proxy/metadata/cookie/hop-by-hop headers before the first request, and all
828
+ * caller headers except `User-Agent` are dropped on a cross-origin redirect.
829
+ * The fetch spec only strips `Authorization` on cross-origin redirects because
830
+ * in a browser, CORS preflighting protects custom headers; there is no CORS on
831
+ * the server, so provider API keys carried in custom headers (e.g. `x-key`)
832
+ * must be dropped here as well.
749
833
  *
750
834
  * A `redirect: 'manual'` request yields an unreadable opaque response in the
751
835
  * browser (and in other spec-compliant fetch implementations), so the redirect
752
836
  * target cannot be validated here. In a real browser this is safe to follow
753
- * natively because SSRF is not reachable (fetch is constrained by CORS and
754
- * cannot reach a server's internal network or cloud-metadata). On any other
755
- * runtime we cannot validate the hop, so we fail closed rather than follow it
756
- * blindly and bypass the SSRF guard.
837
+ * natively because reaching an internal network is not possible (fetch is
838
+ * constrained by CORS and cannot reach a server's internal network or
839
+ * cloud-metadata). On any other runtime we cannot validate the hop, so we fail
840
+ * closed rather than follow it blindly and bypass the guard.
841
+ *
842
+ * A hop that is same-origin with `trustedOrigin` (the developer-configured
843
+ * provider endpoint) skips target validation: that origin is exactly what an
844
+ * unvalidated, config-derived request would fetch anyway, and validating it
845
+ * would break legitimate self-hosted / localhost deployments whose response
846
+ * URLs point back at the configured host. Hops on any other origin are always
847
+ * validated.
757
848
  *
758
849
  * The returned response is the final (non-redirect) response. The caller is
759
850
  * responsible for checking `response.ok` and reading the body.
760
851
  *
852
+ * Not solved here: this does string/literal checks only and does not resolve
853
+ * DNS, so a hostname that *resolves* to a private address, and DNS rebinding
854
+ * (the resolved IP flipping between validation and connect), are not blocked.
855
+ * Server deployments fetching untrusted URLs should constrain egress at the
856
+ * network layer or inject a Node `fetch` that pins the resolved IP at connect
857
+ * time — those need DNS/socket APIs not available on all target runtimes
858
+ * (edge, browser, Bun), so they are intentionally not built in.
859
+ *
761
860
  * @throws DownloadError if a hop is unsafe, the redirect limit is exceeded, or
762
861
  * a redirect cannot be validated on a non-browser runtime.
763
862
  */
764
- declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects, }: {
863
+ declare function fetchWithValidatedRedirects({ url, headers, abortSignal, maxRedirects, fetch, trustedOrigin, }: {
765
864
  url: string;
766
865
  headers?: HeadersInit;
767
866
  abortSignal?: AbortSignal;
768
867
  maxRedirects?: number;
868
+ fetch?: FetchFunction;
869
+ /**
870
+ * A developer-configured origin (e.g. the provider's `baseURL`) whose hops
871
+ * skip target validation. Must never be derived from response data.
872
+ */
873
+ trustedOrigin?: string;
769
874
  }): Promise<Response>;
770
875
 
771
876
  /**
@@ -793,11 +898,6 @@ declare function extractResponseHeaders(response: Response): {
793
898
  [k: string]: string;
794
899
  };
795
900
 
796
- /**
797
- * Fetch function type (standardizes the version of fetch used).
798
- */
799
- type FetchFunction = typeof globalThis.fetch;
800
-
801
901
  /**
802
902
  * Filters `null` and `undefined` values out of a list of values.
803
903
  *
@@ -970,13 +1070,46 @@ declare const createJsonResponseHandler: <T>(responseSchema: FlexibleSchema<T>)
970
1070
  declare const createBinaryResponseHandler: () => ResponseHandler<Uint8Array>;
971
1071
  declare const createStatusCodeErrorResponseHandler: () => ResponseHandler<APICallError>;
972
1072
 
973
- declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
1073
+ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
974
1074
  url: string;
975
1075
  headers?: Record<string, string | undefined>;
976
1076
  failedResponseHandler: ResponseHandler<Error>;
977
1077
  successfulResponseHandler: ResponseHandler<T>;
978
1078
  abortSignal?: AbortSignal;
979
1079
  fetch?: FetchFunction;
1080
+ /**
1081
+ * Set `true` when `url` is untrusted (e.g. taken from a provider response
1082
+ * body): it is routed through {@link fetchWithValidatedRedirects}, which
1083
+ * rejects private/loopback/link-local targets and re-validates redirect
1084
+ * hops; blocked URLs throw `DownloadError`. Set `false` only for URLs built
1085
+ * from a developer-configured endpoint.
1086
+ *
1087
+ * Optional for backwards compatibility with existing callers; omitting it
1088
+ * behaves like `false` (no validation). Provider code in this repository
1089
+ * must always pass it explicitly so every call site makes a visible trust
1090
+ * decision — see `contributing/secure-url-handling.md`.
1091
+ */
1092
+ validateUrl?: boolean;
1093
+ /**
1094
+ * When set, `headers` are sent only if `url` is same-origin with this origin
1095
+ * (the user-agent suffix is always kept). Pass the provider's configured
1096
+ * base URL alongside `validateUrl: true` so credentials never ride a request
1097
+ * to a response-supplied host on a different origin (e.g. a CDN). Redirects
1098
+ * that later cross origin drop all caller headers regardless (see
1099
+ * {@link fetchWithValidatedRedirects}).
1100
+ */
1101
+ credentialedOrigin?: string;
1102
+ /**
1103
+ * A developer-configured origin (e.g. the provider's `baseURL`) that is
1104
+ * exempt from URL validation when `validateUrl` is `true`. A response URL
1105
+ * (or redirect hop) that is same-origin with it is fetched without target
1106
+ * validation — it points at exactly the host a config-derived
1107
+ * `validateUrl: false` request would fetch anyway, so blocking it would
1108
+ * only break legitimate self-hosted / localhost deployments whose response
1109
+ * URLs point back at the configured host. Hops on any other origin are
1110
+ * still validated. Must never be derived from response data.
1111
+ */
1112
+ trustedOrigin?: string;
980
1113
  }) => Promise<{
981
1114
  value: T;
982
1115
  rawValue?: unknown;
@@ -2163,10 +2296,108 @@ declare class StreamingToolCallTracker<DELTA extends StreamingToolCallDelta = St
2163
2296
  */
2164
2297
  declare function stripFileExtension(filename: string): string;
2165
2298
 
2299
+ /**
2300
+ * Experimental transcription-stream WebSocket envelope (v1): the standard
2301
+ * serialization of `TranscriptionModelV4.doStream` over a WebSocket. Clients
2302
+ * (e.g. the `@ai-sdk/gateway` provider) encode with this module and servers
2303
+ * (e.g. AI Gateway) decode with it, so the two sides cannot drift.
2304
+ *
2305
+ * Envelope rules:
2306
+ *
2307
+ * 1. The client sends exactly one `transcription-stream.start` TEXT frame
2308
+ * first.
2309
+ * 2. Audio rides BINARY frames containing raw bytes in the declared
2310
+ * `inputAudioFormat` (base64 string chunks are decoded before sending).
2311
+ * 3. The client signals end of audio with the
2312
+ * `transcription-stream.audio-done` TEXT frame; a plain close without it
2313
+ * is an abort.
2314
+ * 4. Every server→client TEXT frame is one JSON-serialized
2315
+ * `TranscriptionModelV4StreamPart` (flattened, no wrapper). Payloads must
2316
+ * be JSON-serializable. `Date` values (`response-metadata.timestamp`)
2317
+ * serialize to ISO 8601 strings and are revived by
2318
+ * `parseTranscriptionStreamPart`. `Error` payloads in `error` parts
2319
+ * serialize as `{ name, message }`.
2320
+ * 5. The server closes with code 1000 after the `finish` part; on failure it
2321
+ * sends an `error` part and closes non-1000. A close without a prior
2322
+ * `finish` is an error.
2323
+ * 6. Unknown frame/part types are ignored in both directions (forward
2324
+ * compatibility).
2325
+ * 7. Servers may enforce a maximum frame size (the AI Gateway rejects frames
2326
+ * over 256 KiB); clients should split audio into frames of at most
2327
+ * 64 KiB.
2328
+ * 8. Connection establishment (URL, auth) is transport-specific and out of
2329
+ * scope.
2330
+ *
2331
+ * The envelope validates frame shape only; server policy (accepted audio
2332
+ * formats, required `rate`, size limits) layers on top. Both parsers use
2333
+ * `secureJsonParse`, so frames carrying `__proto__` / `constructor.prototype`
2334
+ * keys are rejected (prototype-pollution protection) rather than parsed.
2335
+ */
2336
+ /** Type of the first client TEXT frame. */
2337
+ declare const TRANSCRIPTION_STREAM_START_FRAME_TYPE = "transcription-stream.start";
2338
+ /** Type of the client TEXT frame that signals the end of the audio input. */
2339
+ declare const TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE = "transcription-stream.audio-done";
2340
+ /**
2341
+ * The client's session start frame. Optional keys are omitted when undefined.
2342
+ */
2343
+ type TranscriptionStreamStartFrame = {
2344
+ type: typeof TRANSCRIPTION_STREAM_START_FRAME_TYPE;
2345
+ /** Audio format of the binary audio frames, e.g. `{ type: 'audio/pcm', rate: 16000 }`. */
2346
+ inputAudioFormat: {
2347
+ type: string;
2348
+ rate?: number;
2349
+ };
2350
+ /** Provider-specific options, passed through verbatim. */
2351
+ providerOptions?: Record<string, JSONObject>;
2352
+ /** When true, the server should include `raw` parts in the stream. */
2353
+ includeRawChunks?: boolean;
2354
+ };
2355
+ /** Server-side classification of a client TEXT frame. */
2356
+ type TranscriptionStreamClientFrame = {
2357
+ type: 'start';
2358
+ frame: TranscriptionStreamStartFrame;
2359
+ } | {
2360
+ type: 'audio-done';
2361
+ } | {
2362
+ /** Malformed JSON or a recognized frame with an invalid shape. */
2363
+ type: 'invalid';
2364
+ message: string;
2365
+ } | {
2366
+ /** Unrecognized frame type; ignore for forward compatibility. */
2367
+ type: 'unknown';
2368
+ };
2369
+ /**
2370
+ * Server-side: parse a client TEXT frame. Validates envelope shape only and
2371
+ * rejects prototype-pollution payloads (parsed with `secureJsonParse`). Never
2372
+ * throws.
2373
+ */
2374
+ declare function parseTranscriptionStreamClientFrame(text: string): TranscriptionStreamClientFrame;
2375
+ /**
2376
+ * Server-side: serialize a transcription stream part as one TEXT frame.
2377
+ * `Error` payloads in `error` parts serialize as `{ name, message }` —
2378
+ * `Error` properties are non-enumerable, so a plain `JSON.stringify` would
2379
+ * serialize them to `{}` and lose the message end-to-end. Returns
2380
+ * `undefined` for payloads that are not JSON-serializable (envelope rule 4,
2381
+ * e.g. bigint or cyclic values); callers drop the frame.
2382
+ */
2383
+ declare function serializeTranscriptionStreamPart(part: Experimental_TranscriptionModelV4StreamPart): string | undefined;
2384
+ /**
2385
+ * Client-side: parse a server TEXT frame into a transcription stream part.
2386
+ * Returns `undefined` for malformed or unsafe (prototype-polluting) JSON
2387
+ * (parsed with `secureJsonParse`), unknown part types, and known part types
2388
+ * whose required or optional fields are missing or mistyped (including
2389
+ * warning and segment elements) — downstream SDK code dereferences those
2390
+ * fields, so a drifted server must not crash or pollute the stream.
2391
+ * Revives `response-metadata.timestamp` to a `Date`.
2392
+ */
2393
+ declare function parseTranscriptionStreamPart(text: string): Experimental_TranscriptionModelV4StreamPart | undefined;
2394
+
2166
2395
  declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
2167
2396
  declare function convertUint8ArrayToBase64(array: Uint8Array): string;
2168
2397
  declare function convertToBase64(value: string | Uint8Array): string;
2169
2398
 
2399
+ declare function validateBaseURL(baseURL: string | undefined): string | undefined;
2400
+
2170
2401
  /**
2171
2402
  * Validates that a URL is safe to download from, blocking private/internal addresses
2172
2403
  * to prevent SSRF attacks.
@@ -2221,31 +2452,6 @@ declare function safeValidateTypes<OBJECT>({ value, schema, context, }: {
2221
2452
 
2222
2453
  declare const VERSION: string;
2223
2454
 
2224
- type WebSocketLike = {
2225
- readyState: number;
2226
- send(data: string | Uint8Array | ArrayBuffer): void;
2227
- close(code?: number, reason?: string): void;
2228
- onopen: ((event: unknown) => void) | null;
2229
- onmessage: ((event: {
2230
- data: unknown;
2231
- }) => void) | null;
2232
- onerror: ((event: unknown) => void) | null;
2233
- onclose: ((event: unknown) => void) | null;
2234
- };
2235
- type WebSocketConstructor = new (url: string | URL, protocols?: string | string[], options?: {
2236
- headers?: Record<string, string | undefined>;
2237
- }) => WebSocketLike;
2238
- declare function getWebSocketConstructor(webSocket: WebSocketConstructor | undefined): WebSocketConstructor;
2239
- /**
2240
- * Converts an http(s) URL to the corresponding ws(s) URL.
2241
- */
2242
- declare function toWebSocketUrl(url: string | URL): URL;
2243
- /**
2244
- * Reads WebSocket message data as text, handling string, binary,
2245
- * and Blob payloads.
2246
- */
2247
- declare function readWebSocketMessageText(data: unknown): Promise<string>;
2248
-
2249
2455
  /**
2250
2456
  * Appends suffix parts to the `user-agent` header.
2251
2457
  * If a `user-agent` header already exists, the suffix parts are appended to it.
@@ -2411,4 +2617,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
2411
2617
  dynamic?: boolean;
2412
2618
  }
2413
2619
 
2414
- export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type StreamingToolCallDelta, StreamingToolCallTracker, type StreamingToolCallTrackerOptions, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type WebSocketConstructor, type WebSocketLike, asArray, asSchema, cancelResponseBody, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, readWebSocketMessageText, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, stripFileExtension, toWebSocketUrl, tool, validateDownloadUrl, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
2620
+ export { type Arrayable, type AssistantContent, type AssistantModelMessage, type Context, type CustomPart, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type DynamicTool, TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_AUDIO_DONE_FRAME_TYPE, TRANSCRIPTION_STREAM_START_FRAME_TYPE as EXPERIMENTAL_TRANSCRIPTION_STREAM_START_FRAME_TYPE, type ExecutableTool, type SandboxProcess as Experimental_SandboxProcess, type SandboxSession as Experimental_SandboxSession, type TranscriptionStreamClientFrame as Experimental_TranscriptionStreamClientFrame, type TranscriptionStreamStartFrame as Experimental_TranscriptionStreamStartFrame, type FetchFunction, type FileData, type FileDataData, type FileDataReference, type FileDataText, type FileDataUrl, type FilePart, type FlexibleSchema, type FunctionTool, type HasRequiredKey, type IdGenerator, type ImagePart, type InferSchema, type InferToolContext, type InferToolInput, type InferToolOutput, type InferToolSetContext, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderDefinedTool, type ProviderDefinedToolFactory, type ProviderDefinedToolFactoryWithOutputSchema, type ProviderExecutedTool, type ProviderExecutedToolFactory, type ProviderOptions, type ProviderReference, type ReasoningFilePart, type ReasoningPart, type Resolvable, type ResponseHandler, type RetryDelayProvider, type RetryErrorFactory, type RetryErrorReason, type RetryFunction, type Schema, type ShouldRetryFunction, type StreamingToolCallDelta, StreamingToolCallTracker, type StreamingToolCallTrackerOptions, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type ToolSet, type UserContent, type UserModelMessage, VERSION, type ValidationResult, type WebSocketConnection, type WebSocketConstructor, type WebSocketLike, asArray, asSchema, cancelResponseBody, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, detectMediaType, downloadBlob, dynamicTool, executeTool, parseTranscriptionStreamClientFrame as experimental_parseTranscriptionStreamClientFrame, parseTranscriptionStreamPart as experimental_parseTranscriptionStreamPart, serializeTranscriptionStreamPart as experimental_serializeTranscriptionStreamPart, extractLines, extractResponseHeaders, fetchWithValidatedRedirects, filterNullable, generateId, getFromApi, getRuntimeEnvironmentUserAgent, getTopLevelMediaType, getWebSocketConstructor, injectJsonInstructionIntoMessages, isAbortError, isBrowserRuntime, isBuffer, isCustomReasoning, isExecutableTool, isFullMediaType, isNonNullable, isParsableJson, isProviderReference, isSameOrigin, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, readWebSocketMessageText, removeUndefinedEntries, resolve, resolveFullMediaType, resolveProviderReference, retryWithExponentialBackoff, safeParseJSON, safeValidateTypes, secureJsonParse, serializeModelOptions, stripFileExtension, toWebSocketUrl, tool, validateBaseURL, validateDownloadUrl, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema };