@mastra/ai-sdk 1.6.3-alpha.0 → 1.6.3-alpha.1
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 +11 -2
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +2 -2
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +7 -3
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +47 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -17
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { TripWire, MessageList, aiV5ModelMessageToV2PromptMessage } from '@mastr
|
|
|
10
10
|
import { RequestContext } from '@mastra/core/di';
|
|
11
11
|
import { WorkingMemory, MessageHistory, SemanticRecall } from '@mastra/core/processors';
|
|
12
12
|
|
|
13
|
-
// ../../packages/_vendored/ai_v5/dist/chunk-
|
|
13
|
+
// ../../packages/_vendored/ai_v5/dist/chunk-NFYQIWQU.js
|
|
14
14
|
var marker = "vercel.ai.error";
|
|
15
15
|
var symbol = Symbol.for(marker);
|
|
16
16
|
var _a;
|
|
@@ -565,7 +565,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
565
565
|
);
|
|
566
566
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
567
567
|
}
|
|
568
|
-
var VERSION = "3.0.
|
|
568
|
+
var VERSION = "3.0.29";
|
|
569
569
|
var getOriginalFetch = () => globalThis.fetch;
|
|
570
570
|
var getFromApi = async ({
|
|
571
571
|
url,
|
|
@@ -714,7 +714,7 @@ function lazyValidator(createValidator) {
|
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
716
|
function asValidator(value) {
|
|
717
|
-
return isValidator(value) ? value :
|
|
717
|
+
return isValidator(value) ? value : "~standard" in value ? standardSchemaValidator(value) : value();
|
|
718
718
|
}
|
|
719
719
|
function standardSchemaValidator(standardSchema2) {
|
|
720
720
|
return validator(async (value) => {
|
|
@@ -2339,18 +2339,27 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
2339
2339
|
var name22 = "GatewayForbiddenError";
|
|
2340
2340
|
var marker32 = `vercel.ai.gateway.error.${name22}`;
|
|
2341
2341
|
var symbol32 = Symbol.for(marker32);
|
|
2342
|
+
var forbiddenParamSchema = lazyValidator(
|
|
2343
|
+
() => zodSchema(
|
|
2344
|
+
z.object({
|
|
2345
|
+
ruleId: z.string()
|
|
2346
|
+
})
|
|
2347
|
+
)
|
|
2348
|
+
);
|
|
2342
2349
|
var _a32;
|
|
2343
2350
|
var _b32;
|
|
2344
2351
|
var GatewayForbiddenError = class extends (_b32 = GatewayError, _a32 = symbol32, _b32) {
|
|
2345
2352
|
constructor({
|
|
2346
2353
|
message = "Forbidden",
|
|
2347
2354
|
statusCode = 403,
|
|
2348
|
-
cause
|
|
2355
|
+
cause,
|
|
2356
|
+
ruleId
|
|
2349
2357
|
} = {}) {
|
|
2350
2358
|
super({ message, statusCode, cause });
|
|
2351
2359
|
this[_a32] = true;
|
|
2352
2360
|
this.name = name22;
|
|
2353
2361
|
this.type = "forbidden";
|
|
2362
|
+
this.ruleId = ruleId;
|
|
2354
2363
|
}
|
|
2355
2364
|
static isInstance(error) {
|
|
2356
2365
|
return GatewayError.hasMarker(error) && symbol32 in error;
|
|
@@ -2518,8 +2527,18 @@ async function createGatewayErrorFromResponse({
|
|
|
2518
2527
|
}
|
|
2519
2528
|
case "internal_server_error":
|
|
2520
2529
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
2521
|
-
case "forbidden":
|
|
2522
|
-
|
|
2530
|
+
case "forbidden": {
|
|
2531
|
+
const ruleResult = await safeValidateTypes({
|
|
2532
|
+
value: validatedResponse.error.param,
|
|
2533
|
+
schema: forbiddenParamSchema
|
|
2534
|
+
});
|
|
2535
|
+
return new GatewayForbiddenError({
|
|
2536
|
+
message,
|
|
2537
|
+
statusCode,
|
|
2538
|
+
cause,
|
|
2539
|
+
ruleId: ruleResult.success ? ruleResult.value.ruleId : void 0
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2523
2542
|
default:
|
|
2524
2543
|
return new GatewayInternalServerError({ message, statusCode, cause });
|
|
2525
2544
|
}
|
|
@@ -3421,7 +3440,7 @@ async function getVercelRequestId() {
|
|
|
3421
3440
|
var _a1032;
|
|
3422
3441
|
return (_a1032 = getContext().headers) == null ? void 0 : _a1032["x-vercel-id"];
|
|
3423
3442
|
}
|
|
3424
|
-
var VERSION2 = "2.0.
|
|
3443
|
+
var VERSION2 = "2.0.113";
|
|
3425
3444
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
3426
3445
|
function createGatewayProvider(options = {}) {
|
|
3427
3446
|
var _a1032, _b103;
|
|
@@ -7028,11 +7047,18 @@ function asSchema2(schema) {
|
|
|
7028
7047
|
}
|
|
7029
7048
|
function standardSchema(standardSchema2) {
|
|
7030
7049
|
return jsonSchema2(
|
|
7031
|
-
() =>
|
|
7032
|
-
standardSchema2
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7050
|
+
() => {
|
|
7051
|
+
if (!hasStandardJsonSchema(standardSchema2)) {
|
|
7052
|
+
throw new Error(
|
|
7053
|
+
`Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`
|
|
7054
|
+
);
|
|
7055
|
+
}
|
|
7056
|
+
return addAdditionalPropertiesToJsonSchema2(
|
|
7057
|
+
standardSchema2["~standard"].jsonSchema.input({
|
|
7058
|
+
target: "draft-07"
|
|
7059
|
+
})
|
|
7060
|
+
);
|
|
7061
|
+
},
|
|
7036
7062
|
{
|
|
7037
7063
|
validate: async (value) => {
|
|
7038
7064
|
const result = await standardSchema2["~standard"].validate(value);
|
|
@@ -7047,6 +7073,9 @@ function standardSchema(standardSchema2) {
|
|
|
7047
7073
|
}
|
|
7048
7074
|
);
|
|
7049
7075
|
}
|
|
7076
|
+
function hasStandardJsonSchema(schema) {
|
|
7077
|
+
return schema["~standard"].jsonSchema != null;
|
|
7078
|
+
}
|
|
7050
7079
|
function zod3Schema2(zodSchema22, options) {
|
|
7051
7080
|
var _a223;
|
|
7052
7081
|
const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
|
|
@@ -9810,13 +9839,14 @@ function convertMastraChunkToAISDKBase({
|
|
|
9810
9839
|
// Preserve messageId from the payload so it can be sent to useChat
|
|
9811
9840
|
...chunk.payload?.messageId ? { messageId: chunk.payload.messageId } : {}
|
|
9812
9841
|
};
|
|
9813
|
-
case "step-start":
|
|
9814
|
-
const { messageId: _messageId, ...rest } = chunk.payload;
|
|
9842
|
+
case "step-start": {
|
|
9843
|
+
const { messageId: _messageId, ...rest } = chunk.payload ?? {};
|
|
9815
9844
|
return {
|
|
9816
9845
|
type: "start-step",
|
|
9817
9846
|
request: rest.request,
|
|
9818
9847
|
warnings: normalizeWarnings(rest.warnings)
|
|
9819
9848
|
};
|
|
9849
|
+
}
|
|
9820
9850
|
case "raw":
|
|
9821
9851
|
return {
|
|
9822
9852
|
type: "raw",
|
|
@@ -9964,14 +9994,14 @@ function convertMastraChunkToAISDKBase({
|
|
|
9964
9994
|
providerMetadata: chunk.payload.providerMetadata
|
|
9965
9995
|
};
|
|
9966
9996
|
case "step-finish": {
|
|
9967
|
-
const { request: _request, providerMetadata, ...
|
|
9997
|
+
const { request: _request, providerMetadata, ...rest } = chunk.payload.metadata;
|
|
9968
9998
|
return {
|
|
9969
9999
|
type: "finish-step",
|
|
9970
10000
|
response: {
|
|
9971
10001
|
id: chunk.payload.id || "",
|
|
9972
10002
|
timestamp: /* @__PURE__ */ new Date(),
|
|
9973
|
-
modelId:
|
|
9974
|
-
...
|
|
10003
|
+
modelId: rest.modelId || "",
|
|
10004
|
+
...rest
|
|
9975
10005
|
},
|
|
9976
10006
|
usage: normalizeUsage(chunk.payload.output.usage),
|
|
9977
10007
|
finishReason: normalizeFinishReason(chunk.payload.stepResult.reason),
|