@mastra/ai-sdk 1.12.0 → 1.12.1-alpha.0

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.
Files changed (47) hide show
  1. package/dist/_types/{@internal_ai-sdk-v5@0.0.96 → @internal_ai-sdk-v5@0.0.98}/dist/index.d.ts +61 -2
  2. package/dist/_types/{@internal_ai-v6@0.0.96 → @internal_ai-v6@0.0.98}/dist/index.d.ts +9 -1
  3. package/dist/_types/{@internal_ai-v7@0.0.96 → @internal_ai-v7@0.0.98}/dist/index.d.ts +260 -37
  4. package/dist/chat-route.d.ts +3 -3
  5. package/dist/convert-streams.d.ts +3 -3
  6. package/dist/docs/SKILL.md +1 -1
  7. package/dist/docs/assets/SOURCE_MAP.json +15 -15
  8. package/dist/docs/references/docs-memory-message-history.md +1 -1
  9. package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
  10. package/dist/docs/references/integrations-agentic-ui-ai-sdk-ui.md +3 -3
  11. package/dist/docs/references/reference-ai-sdk-overview.md +2 -2
  12. package/dist/docs/references/reference-memory-recall.md +1 -1
  13. package/dist/docs/references/reference-streaming-agents-stream.md +5 -5
  14. package/dist/helpers.d.ts +2 -2
  15. package/dist/index.cjs +10 -9
  16. package/dist/index.js +10 -10
  17. package/dist/middleware.d.ts +1 -1
  18. package/dist/public-types.d.ts +3 -3
  19. package/dist/transformers.d.ts +23 -23
  20. package/dist/ui.cjs +0 -2
  21. package/dist/ui.js +0 -2
  22. package/package.json +13 -12
  23. package/dist/__tests__/__fixtures__/network.stream.d.ts.map +0 -1
  24. package/dist/__tests__/v7-ui-message-types.test-d.d.ts.map +0 -1
  25. package/dist/chat-route.d.ts.map +0 -1
  26. package/dist/convert-messages.d.ts.map +0 -1
  27. package/dist/convert-snapshot.d.ts.map +0 -1
  28. package/dist/convert-streams.d.ts.map +0 -1
  29. package/dist/helpers.d.ts.map +0 -1
  30. package/dist/index.cjs.map +0 -1
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/index.js.map +0 -1
  33. package/dist/middleware.d.ts.map +0 -1
  34. package/dist/network-route.d.ts.map +0 -1
  35. package/dist/public-types.d.ts.map +0 -1
  36. package/dist/smooth-stream.d.ts.map +0 -1
  37. package/dist/sse-heartbeat.d.ts.map +0 -1
  38. package/dist/to-ai-sdk-format.d.ts.map +0 -1
  39. package/dist/transformers.d.ts.map +0 -1
  40. package/dist/ui.cjs.map +0 -1
  41. package/dist/ui.d.ts.map +0 -1
  42. package/dist/ui.js.map +0 -1
  43. package/dist/utils.d.ts.map +0 -1
  44. package/dist/workflow-route.d.ts.map +0 -1
  45. /package/dist/_types/{@internal_ai-sdk-v5@0.0.96 → @internal_ai-sdk-v5@0.0.98}/package.json +0 -0
  46. /package/dist/_types/{@internal_ai-v6@0.0.96 → @internal_ai-v6@0.0.98}/package.json +0 -0
  47. /package/dist/_types/{@internal_ai-v7@0.0.96 → @internal_ai-v7@0.0.98}/package.json +0 -0
@@ -200,9 +200,11 @@ declare namespace _ai_sdk_provider_utils {
200
200
  getRuntimeEnvironmentUserAgent,
201
201
  injectJsonInstructionIntoMessages,
202
202
  isAbortError,
203
+ isArrayBuffer,
203
204
  isBrowserRuntime,
204
205
  isParsableJson,
205
206
  isSameOrigin,
207
+ isUint8Array,
206
208
  isUrlSupported,
207
209
  isValidator,
208
210
  jsonSchema,
@@ -224,7 +226,9 @@ declare namespace _ai_sdk_provider_utils {
224
226
  resolve,
225
227
  safeParseJSON,
226
228
  safeValidateTypes,
229
+ secureJsonParse,
227
230
  standardSchemaValidator,
231
+ stringifyWithBigIntAndCycles,
228
232
  tool,
229
233
  validateDownloadUrl,
230
234
  validateTypes,
@@ -2178,7 +2182,7 @@ declare type FetchFunction = typeof globalThis.fetch;
2178
2182
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
2179
2183
  * validate the Location target before issuing another request.
2180
2184
  */
2181
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
2185
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
2182
2186
  url: string | URL;
2183
2187
  init?: RequestInit;
2184
2188
  fetch?: FetchFunction;
@@ -2188,6 +2192,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
2188
2192
  */
2189
2193
  trustedOrigin?: string;
2190
2194
  redirect?: 'error' | 'manual';
2195
+ /**
2196
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
2197
+ * transport unless an explicit custom fetch provides equivalent validation.
2198
+ */
2199
+ requireDnsValidation?: boolean;
2191
2200
  }): Promise<Response>;
2192
2201
 
2193
2202
  /**
@@ -2199,6 +2208,12 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
2199
2208
  * target (e.g. an internal address) before we ever see its URL, defeating the
2200
2209
  * SSRF guard.
2201
2210
  *
2211
+ * Manually followed redirects from HTTPS to HTTP are rejected before requesting
2212
+ * the target.
2213
+ *
2214
+ * All caller headers except User-Agent are dropped on cross-origin redirects.
2215
+ * Callers must decide which credentials may be sent to the initial URL.
2216
+ *
2202
2217
  * A `redirect: 'manual'` request yields an unreadable opaque response in the
2203
2218
  * browser (and in other spec-compliant fetch implementations), so the redirect
2204
2219
  * target cannot be validated here. In a real browser this is safe to follow
@@ -3029,13 +3044,44 @@ export declare interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
3029
3044
 
3030
3045
  declare function getErrorMessage(error: unknown | undefined): string;
3031
3046
 
3032
- declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
3047
+ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin, }: {
3033
3048
  url: string;
3034
3049
  headers?: Record<string, string | undefined>;
3035
3050
  failedResponseHandler: ResponseHandler<Error>;
3036
3051
  successfulResponseHandler: ResponseHandler<T>;
3037
3052
  abortSignal?: AbortSignal;
3038
3053
  fetch?: FetchFunction;
3054
+ /**
3055
+ * Set `true` when `url` is untrusted (e.g. taken from a provider response
3056
+ * body): it is routed through {@link fetchWithValidatedRedirects}, which
3057
+ * rejects private/loopback/link-local targets and re-validates redirect
3058
+ * hops; blocked URLs throw `DownloadError`. Set `false` only for URLs built
3059
+ * from a developer-configured endpoint.
3060
+ *
3061
+ * Optional for backwards compatibility with existing callers; omitting it
3062
+ * behaves like `false` (no validation).
3063
+ */
3064
+ validateUrl?: boolean;
3065
+ /**
3066
+ * When set, `headers` are sent only if `url` is same-origin with this origin
3067
+ * (the user-agent suffix is always kept). Pass the provider's configured
3068
+ * base URL alongside `validateUrl: true` so credentials never ride a request
3069
+ * to a response-supplied host on a different origin (e.g. a CDN). Redirects
3070
+ * that later cross origin drop all caller headers regardless (see
3071
+ * {@link fetchWithValidatedRedirects}).
3072
+ */
3073
+ credentialedOrigin?: string;
3074
+ /**
3075
+ * A developer-configured origin (e.g. the provider's `baseURL`) that is
3076
+ * exempt from URL validation when `validateUrl` is `true`. A response URL
3077
+ * (or redirect hop) that is same-origin with it is fetched without target
3078
+ * validation — it points at exactly the host a config-derived
3079
+ * `validateUrl: false` request would fetch anyway, so blocking it would
3080
+ * only break legitimate self-hosted / localhost deployments whose response
3081
+ * URLs point back at the configured host. Hops on any other origin are
3082
+ * still validated. Must never be derived from response data.
3083
+ */
3084
+ trustedOrigin?: string;
3039
3085
  }) => Promise<{
3040
3086
  value: T;
3041
3087
  rawValue?: unknown;
@@ -3524,6 +3570,8 @@ export declare class InvalidToolInputError extends AISDKError {
3524
3570
 
3525
3571
  declare function isAbortError(error: unknown): error is Error;
3526
3572
 
3573
+ declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
3574
+
3527
3575
  /**
3528
3576
  * Returns `true` when running in a browser.
3529
3577
  *
@@ -3585,6 +3633,8 @@ export declare function isToolOrDynamicToolUIPart<TOOLS extends UITools>(part: U
3585
3633
 
3586
3634
  export declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
3587
3635
 
3636
+ declare function isUint8Array(value: unknown): value is Uint8Array;
3637
+
3588
3638
  /**
3589
3639
  * Checks if the given URL is supported natively by the model.
3590
3640
  *
@@ -5833,6 +5883,8 @@ export declare type Schema<OBJECT = unknown> = Validator<OBJECT> & {
5833
5883
  */
5834
5884
  declare const schemaSymbol: unique symbol;
5835
5885
 
5886
+ declare function secureJsonParse(text: string): any;
5887
+
5836
5888
  export declare class SerialJobExecutor {
5837
5889
  private queue;
5838
5890
  private isProcessing;
@@ -7548,6 +7600,13 @@ export declare type StreamTextTransform<TOOLS extends ToolSet> = (options: {
7548
7600
  stopStream: () => void;
7549
7601
  }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
7550
7602
 
7603
+ /**
7604
+ * Serializes a value as JSON, representing BigInt values as decimal strings and
7605
+ * ancestor cycles as "[Circular]". Reused objects, toJSON methods, and other JSON
7606
+ * serialization behavior are preserved. Getters and toJSON methods may throw.
7607
+ */
7608
+ declare function stringifyWithBigIntAndCycles(value: unknown): string;
7609
+
7551
7610
  declare const symbol$1: unique symbol;
7552
7611
 
7553
7612
  declare const symbol$1_2: unique symbol;
@@ -3113,7 +3113,7 @@ declare type FetchFunction = typeof globalThis.fetch;
3113
3113
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
3114
3114
  * validate the Location target before issuing another request.
3115
3115
  */
3116
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
3116
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
3117
3117
  url: string | URL;
3118
3118
  init?: RequestInit;
3119
3119
  fetch?: FetchFunction;
@@ -3123,6 +3123,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
3123
3123
  */
3124
3124
  trustedOrigin?: string;
3125
3125
  redirect?: 'error' | 'manual';
3126
+ /**
3127
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
3128
+ * transport unless an explicit custom fetch provides equivalent validation.
3129
+ */
3130
+ requireDnsValidation?: boolean;
3126
3131
  }): Promise<Response>;
3127
3132
 
3128
3133
  /**
@@ -3134,6 +3139,9 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
3134
3139
  * target (e.g. an internal address) before we ever see its URL, defeating the
3135
3140
  * guard.
3136
3141
  *
3142
+ * Manually followed redirects from HTTPS to HTTP are rejected before requesting
3143
+ * the target.
3144
+ *
3137
3145
  * Request headers are also protected: {@link sanitizeRequestHeaders} strips
3138
3146
  * proxy/metadata/cookie/hop-by-hop headers before the first request, and all
3139
3147
  * caller headers except `User-Agent` are dropped on a cross-origin redirect.