@mastra/memory 1.7.0 → 1.8.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.
- package/CHANGELOG.md +52 -0
- package/dist/{chunk-M7RAJAZ6.js → chunk-SUU4IAZJ.js} +307 -39
- package/dist/chunk-SUU4IAZJ.js.map +1 -0
- package/dist/{chunk-SHID74TI.cjs → chunk-YPFNHFT6.cjs} +307 -39
- package/dist/chunk-YPFNHFT6.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +24 -24
- package/dist/docs/references/docs-memory-observational-memory.md +23 -0
- package/dist/docs/references/docs-memory-overview.md +3 -3
- package/dist/docs/references/reference-memory-observational-memory.md +2 -0
- package/dist/index.cjs +64 -368
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -368
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-AU6MIH4Q.cjs → observational-memory-3HFM7PY2.cjs} +17 -17
- package/dist/{observational-memory-AU6MIH4Q.cjs.map → observational-memory-3HFM7PY2.cjs.map} +1 -1
- package/dist/{observational-memory-YRWU6CY3.js → observational-memory-XXD6E2SO.js} +3 -3
- package/dist/{observational-memory-YRWU6CY3.js.map → observational-memory-XXD6E2SO.js.map} +1 -1
- package/dist/processors/index.cjs +15 -15
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +21 -0
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +14 -2
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +7 -0
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-M7RAJAZ6.js.map +0 -1
- package/dist/chunk-SHID74TI.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
|
|
40
40
|
var xxhash__default = /*#__PURE__*/_interopDefault(xxhash);
|
|
41
41
|
|
|
42
|
-
// ../_vendored/ai_v4/dist/chunk-
|
|
42
|
+
// ../_vendored/ai_v4/dist/chunk-GBOGIFXJ.js
|
|
43
43
|
var __create = Object.create;
|
|
44
44
|
var __defProp = Object.defineProperty;
|
|
45
45
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7024,12 +7024,12 @@ async function getVercelRequestId() {
|
|
|
7024
7024
|
var VERSION3 = "2.0.15";
|
|
7025
7025
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7026
7026
|
function createGatewayProvider(options = {}) {
|
|
7027
|
-
var _a832,
|
|
7027
|
+
var _a832, _b83;
|
|
7028
7028
|
let pendingMetadata = null;
|
|
7029
7029
|
let metadataCache = null;
|
|
7030
7030
|
const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
|
|
7031
7031
|
let lastFetchTime = 0;
|
|
7032
|
-
const baseURL = (
|
|
7032
|
+
const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
7033
7033
|
const getHeaders = async () => {
|
|
7034
7034
|
const auth = await getGatewayAuthToken(options);
|
|
7035
7035
|
if (auth) {
|
|
@@ -7082,8 +7082,8 @@ function createGatewayProvider(options = {}) {
|
|
|
7082
7082
|
});
|
|
7083
7083
|
};
|
|
7084
7084
|
const getAvailableModels = async () => {
|
|
7085
|
-
var
|
|
7086
|
-
const now2 = (_c = (_b92 = (
|
|
7085
|
+
var _a922, _b92, _c;
|
|
7086
|
+
const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
|
|
7087
7087
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
7088
7088
|
lastFetchTime = now2;
|
|
7089
7089
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -7260,12 +7260,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
|
|
|
7260
7260
|
return true;
|
|
7261
7261
|
}
|
|
7262
7262
|
function getGlobal2(type) {
|
|
7263
|
-
var _a163,
|
|
7263
|
+
var _a163, _b83;
|
|
7264
7264
|
var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
|
|
7265
7265
|
if (!globalVersion || !isCompatible2(globalVersion)) {
|
|
7266
7266
|
return;
|
|
7267
7267
|
}
|
|
7268
|
-
return (
|
|
7268
|
+
return (_b83 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b83 === void 0 ? void 0 : _b83[type];
|
|
7269
7269
|
}
|
|
7270
7270
|
function unregisterGlobal2(type, diag) {
|
|
7271
7271
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
|
|
@@ -7430,7 +7430,7 @@ var DiagAPI2 = (
|
|
|
7430
7430
|
}
|
|
7431
7431
|
var self = this;
|
|
7432
7432
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
7433
|
-
var _a163,
|
|
7433
|
+
var _a163, _b83, _c;
|
|
7434
7434
|
if (optionsOrLogLevel === void 0) {
|
|
7435
7435
|
optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
|
|
7436
7436
|
}
|
|
@@ -7445,7 +7445,7 @@ var DiagAPI2 = (
|
|
|
7445
7445
|
};
|
|
7446
7446
|
}
|
|
7447
7447
|
var oldLogger = getGlobal2("diag");
|
|
7448
|
-
var newLogger = createLogLevelDiagLogger2((
|
|
7448
|
+
var newLogger = createLogLevelDiagLogger2((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel2.INFO, logger);
|
|
7449
7449
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
7450
7450
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
7451
7451
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -7984,8 +7984,8 @@ var dataContentSchema2 = z4.z.union([
|
|
|
7984
7984
|
z4.z.custom(
|
|
7985
7985
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
7986
7986
|
(value) => {
|
|
7987
|
-
var _a163,
|
|
7988
|
-
return (
|
|
7987
|
+
var _a163, _b83;
|
|
7988
|
+
return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
|
|
7989
7989
|
},
|
|
7990
7990
|
{ message: "Must be a Buffer" }
|
|
7991
7991
|
)
|
|
@@ -9587,7 +9587,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
9587
9587
|
);
|
|
9588
9588
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9589
9589
|
}
|
|
9590
|
-
var VERSION4 = "4.0.
|
|
9590
|
+
var VERSION4 = "4.0.13";
|
|
9591
9591
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
9592
9592
|
var getFromApi2 = async ({
|
|
9593
9593
|
url,
|
|
@@ -9672,8 +9672,8 @@ function loadOptionalSetting2({
|
|
|
9672
9672
|
}
|
|
9673
9673
|
return settingValue;
|
|
9674
9674
|
}
|
|
9675
|
-
var suspectProtoRx2 = /"
|
|
9676
|
-
var suspectConstructorRx2 = /"
|
|
9675
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
9676
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
9677
9677
|
function _parse2(text4) {
|
|
9678
9678
|
const obj = JSON.parse(text4);
|
|
9679
9679
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -9693,7 +9693,7 @@ function filter2(obj) {
|
|
|
9693
9693
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9694
9694
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9695
9695
|
}
|
|
9696
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") &&
|
|
9696
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9697
9697
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9698
9698
|
}
|
|
9699
9699
|
for (const key in node) {
|
|
@@ -11595,7 +11595,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
11595
11595
|
cause,
|
|
11596
11596
|
authMethod
|
|
11597
11597
|
}) {
|
|
11598
|
-
var
|
|
11598
|
+
var _a832;
|
|
11599
11599
|
const parseResult = await safeValidateTypes3({
|
|
11600
11600
|
value: response,
|
|
11601
11601
|
schema: gatewayErrorResponseSchema2
|
|
@@ -11614,7 +11614,7 @@ async function createGatewayErrorFromResponse2({
|
|
|
11614
11614
|
const validatedResponse = parseResult.value;
|
|
11615
11615
|
const errorType = validatedResponse.error.type;
|
|
11616
11616
|
const message = validatedResponse.error.message;
|
|
11617
|
-
const generationId = (
|
|
11617
|
+
const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
|
|
11618
11618
|
switch (errorType) {
|
|
11619
11619
|
case "authentication_error":
|
|
11620
11620
|
return GatewayAuthenticationError2.createContextualError({
|
|
@@ -11680,88 +11680,21 @@ var gatewayErrorResponseSchema2 = lazySchema(
|
|
|
11680
11680
|
})
|
|
11681
11681
|
)
|
|
11682
11682
|
);
|
|
11683
|
-
|
|
11684
|
-
var
|
|
11685
|
-
var symbol86 = Symbol.for(marker86);
|
|
11686
|
-
var _a86;
|
|
11687
|
-
var _b83;
|
|
11688
|
-
var GatewayTimeoutError = class _GatewayTimeoutError extends (_b83 = GatewayError2, _a86 = symbol86, _b83) {
|
|
11689
|
-
constructor({
|
|
11690
|
-
message = "Request timed out",
|
|
11691
|
-
statusCode = 408,
|
|
11692
|
-
cause,
|
|
11693
|
-
generationId
|
|
11694
|
-
} = {}) {
|
|
11695
|
-
super({ message, statusCode, cause, generationId });
|
|
11696
|
-
this[_a86] = true;
|
|
11697
|
-
this.name = name76;
|
|
11698
|
-
this.type = "timeout_error";
|
|
11699
|
-
}
|
|
11700
|
-
static isInstance(error) {
|
|
11701
|
-
return GatewayError2.hasMarker(error) && symbol86 in error;
|
|
11702
|
-
}
|
|
11703
|
-
/**
|
|
11704
|
-
* Creates a helpful timeout error message with troubleshooting guidance
|
|
11705
|
-
*/
|
|
11706
|
-
static createTimeoutError({
|
|
11707
|
-
originalMessage,
|
|
11708
|
-
statusCode = 408,
|
|
11709
|
-
cause,
|
|
11710
|
-
generationId
|
|
11711
|
-
}) {
|
|
11712
|
-
const message = `Gateway request timed out: ${originalMessage}
|
|
11713
|
-
|
|
11714
|
-
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
|
|
11715
|
-
return new _GatewayTimeoutError({
|
|
11716
|
-
message,
|
|
11717
|
-
statusCode,
|
|
11718
|
-
cause,
|
|
11719
|
-
generationId
|
|
11720
|
-
});
|
|
11721
|
-
}
|
|
11722
|
-
};
|
|
11723
|
-
function isTimeoutError(error) {
|
|
11724
|
-
if (!(error instanceof Error)) {
|
|
11725
|
-
return false;
|
|
11726
|
-
}
|
|
11727
|
-
const errorCode = error.code;
|
|
11728
|
-
if (typeof errorCode === "string") {
|
|
11729
|
-
const undiciTimeoutCodes = [
|
|
11730
|
-
"UND_ERR_HEADERS_TIMEOUT",
|
|
11731
|
-
"UND_ERR_BODY_TIMEOUT",
|
|
11732
|
-
"UND_ERR_CONNECT_TIMEOUT"
|
|
11733
|
-
];
|
|
11734
|
-
return undiciTimeoutCodes.includes(errorCode);
|
|
11735
|
-
}
|
|
11736
|
-
return false;
|
|
11737
|
-
}
|
|
11738
|
-
async function asGatewayError2(error, authMethod) {
|
|
11739
|
-
var _a932;
|
|
11683
|
+
function asGatewayError2(error, authMethod) {
|
|
11684
|
+
var _a832;
|
|
11740
11685
|
if (GatewayError2.isInstance(error)) {
|
|
11741
11686
|
return error;
|
|
11742
11687
|
}
|
|
11743
|
-
if (isTimeoutError(error)) {
|
|
11744
|
-
return GatewayTimeoutError.createTimeoutError({
|
|
11745
|
-
originalMessage: error instanceof Error ? error.message : "Unknown error",
|
|
11746
|
-
cause: error
|
|
11747
|
-
});
|
|
11748
|
-
}
|
|
11749
11688
|
if (APICallError3.isInstance(error)) {
|
|
11750
|
-
|
|
11751
|
-
return GatewayTimeoutError.createTimeoutError({
|
|
11752
|
-
originalMessage: error.message,
|
|
11753
|
-
cause: error
|
|
11754
|
-
});
|
|
11755
|
-
}
|
|
11756
|
-
return await createGatewayErrorFromResponse2({
|
|
11689
|
+
return createGatewayErrorFromResponse2({
|
|
11757
11690
|
response: extractApiCallResponse2(error),
|
|
11758
|
-
statusCode: (
|
|
11691
|
+
statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
|
|
11759
11692
|
defaultMessage: "Gateway request failed",
|
|
11760
11693
|
cause: error,
|
|
11761
11694
|
authMethod
|
|
11762
11695
|
});
|
|
11763
11696
|
}
|
|
11764
|
-
return
|
|
11697
|
+
return createGatewayErrorFromResponse2({
|
|
11765
11698
|
response: {},
|
|
11766
11699
|
statusCode: 500,
|
|
11767
11700
|
defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
|
|
@@ -11863,7 +11796,7 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
|
|
|
11863
11796
|
provider: z4.z.string(),
|
|
11864
11797
|
modelId: z4.z.string()
|
|
11865
11798
|
}),
|
|
11866
|
-
modelType: z4.z.enum(["
|
|
11799
|
+
modelType: z4.z.enum(["language", "embedding", "image"]).nullish()
|
|
11867
11800
|
})
|
|
11868
11801
|
)
|
|
11869
11802
|
})
|
|
@@ -12042,7 +11975,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
12042
11975
|
abortSignal,
|
|
12043
11976
|
providerOptions
|
|
12044
11977
|
}) {
|
|
12045
|
-
var
|
|
11978
|
+
var _a832;
|
|
12046
11979
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
12047
11980
|
try {
|
|
12048
11981
|
const {
|
|
@@ -12073,7 +12006,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
12073
12006
|
});
|
|
12074
12007
|
return {
|
|
12075
12008
|
embeddings: responseBody.embeddings,
|
|
12076
|
-
usage: (
|
|
12009
|
+
usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
|
|
12077
12010
|
providerMetadata: responseBody.providerMetadata,
|
|
12078
12011
|
response: { headers: responseHeaders, body: rawValue },
|
|
12079
12012
|
warnings: []
|
|
@@ -12123,7 +12056,7 @@ var GatewayImageModel2 = class {
|
|
|
12123
12056
|
headers,
|
|
12124
12057
|
abortSignal
|
|
12125
12058
|
}) {
|
|
12126
|
-
var
|
|
12059
|
+
var _a832;
|
|
12127
12060
|
const resolvedHeaders = await resolve2(this.config.headers());
|
|
12128
12061
|
try {
|
|
12129
12062
|
const {
|
|
@@ -12162,23 +12095,16 @@ var GatewayImageModel2 = class {
|
|
|
12162
12095
|
return {
|
|
12163
12096
|
images: responseBody.images,
|
|
12164
12097
|
// Always base64 strings from server
|
|
12165
|
-
warnings: (
|
|
12098
|
+
warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
|
|
12166
12099
|
providerMetadata: responseBody.providerMetadata,
|
|
12167
12100
|
response: {
|
|
12168
12101
|
timestamp: /* @__PURE__ */ new Date(),
|
|
12169
12102
|
modelId: this.modelId,
|
|
12170
12103
|
headers: responseHeaders
|
|
12171
|
-
},
|
|
12172
|
-
...responseBody.usage != null && {
|
|
12173
|
-
usage: {
|
|
12174
|
-
inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
|
|
12175
|
-
outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
|
|
12176
|
-
totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
|
|
12177
|
-
}
|
|
12178
12104
|
}
|
|
12179
12105
|
};
|
|
12180
12106
|
} catch (error) {
|
|
12181
|
-
throw
|
|
12107
|
+
throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
12182
12108
|
}
|
|
12183
12109
|
}
|
|
12184
12110
|
getUrl() {
|
|
@@ -12203,230 +12129,17 @@ function maybeEncodeImageFile(file) {
|
|
|
12203
12129
|
var providerMetadataEntrySchema2 = z4.z.object({
|
|
12204
12130
|
images: z4.z.array(z4.z.unknown()).optional()
|
|
12205
12131
|
}).catchall(z4.z.unknown());
|
|
12206
|
-
var gatewayImageWarningSchema = z4.z.discriminatedUnion("type", [
|
|
12207
|
-
z4.z.object({
|
|
12208
|
-
type: z4.z.literal("unsupported"),
|
|
12209
|
-
feature: z4.z.string(),
|
|
12210
|
-
details: z4.z.string().optional()
|
|
12211
|
-
}),
|
|
12212
|
-
z4.z.object({
|
|
12213
|
-
type: z4.z.literal("compatibility"),
|
|
12214
|
-
feature: z4.z.string(),
|
|
12215
|
-
details: z4.z.string().optional()
|
|
12216
|
-
}),
|
|
12217
|
-
z4.z.object({
|
|
12218
|
-
type: z4.z.literal("other"),
|
|
12219
|
-
message: z4.z.string()
|
|
12220
|
-
})
|
|
12221
|
-
]);
|
|
12222
|
-
var gatewayImageUsageSchema = z4.z.object({
|
|
12223
|
-
inputTokens: z4.z.number().nullish(),
|
|
12224
|
-
outputTokens: z4.z.number().nullish(),
|
|
12225
|
-
totalTokens: z4.z.number().nullish()
|
|
12226
|
-
});
|
|
12227
12132
|
var gatewayImageResponseSchema2 = z4.z.object({
|
|
12228
12133
|
images: z4.z.array(z4.z.string()),
|
|
12229
12134
|
// Always base64 strings over the wire
|
|
12230
|
-
warnings: z4.z.array(
|
|
12231
|
-
|
|
12232
|
-
|
|
12135
|
+
warnings: z4.z.array(
|
|
12136
|
+
z4.z.object({
|
|
12137
|
+
type: z4.z.literal("other"),
|
|
12138
|
+
message: z4.z.string()
|
|
12139
|
+
})
|
|
12140
|
+
).optional(),
|
|
12141
|
+
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional()
|
|
12233
12142
|
});
|
|
12234
|
-
var GatewayVideoModel = class {
|
|
12235
|
-
constructor(modelId, config) {
|
|
12236
|
-
this.modelId = modelId;
|
|
12237
|
-
this.config = config;
|
|
12238
|
-
this.specificationVersion = "v3";
|
|
12239
|
-
this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
|
|
12240
|
-
}
|
|
12241
|
-
get provider() {
|
|
12242
|
-
return this.config.provider;
|
|
12243
|
-
}
|
|
12244
|
-
async doGenerate({
|
|
12245
|
-
prompt,
|
|
12246
|
-
n,
|
|
12247
|
-
aspectRatio,
|
|
12248
|
-
resolution,
|
|
12249
|
-
duration,
|
|
12250
|
-
fps,
|
|
12251
|
-
seed,
|
|
12252
|
-
image,
|
|
12253
|
-
providerOptions,
|
|
12254
|
-
headers,
|
|
12255
|
-
abortSignal
|
|
12256
|
-
}) {
|
|
12257
|
-
var _a932;
|
|
12258
|
-
const resolvedHeaders = await resolve2(this.config.headers());
|
|
12259
|
-
try {
|
|
12260
|
-
const { responseHeaders, value: responseBody } = await postJsonToApi2({
|
|
12261
|
-
url: this.getUrl(),
|
|
12262
|
-
headers: combineHeaders2(
|
|
12263
|
-
resolvedHeaders,
|
|
12264
|
-
headers != null ? headers : {},
|
|
12265
|
-
this.getModelConfigHeaders(),
|
|
12266
|
-
await resolve2(this.config.o11yHeaders),
|
|
12267
|
-
{ accept: "text/event-stream" }
|
|
12268
|
-
),
|
|
12269
|
-
body: {
|
|
12270
|
-
prompt,
|
|
12271
|
-
n,
|
|
12272
|
-
...aspectRatio && { aspectRatio },
|
|
12273
|
-
...resolution && { resolution },
|
|
12274
|
-
...duration && { duration },
|
|
12275
|
-
...fps && { fps },
|
|
12276
|
-
...seed && { seed },
|
|
12277
|
-
...providerOptions && { providerOptions },
|
|
12278
|
-
...image && { image: maybeEncodeVideoFile(image) }
|
|
12279
|
-
},
|
|
12280
|
-
successfulResponseHandler: async ({
|
|
12281
|
-
response,
|
|
12282
|
-
url,
|
|
12283
|
-
requestBodyValues
|
|
12284
|
-
}) => {
|
|
12285
|
-
if (response.body == null) {
|
|
12286
|
-
throw new APICallError3({
|
|
12287
|
-
message: "SSE response body is empty",
|
|
12288
|
-
url,
|
|
12289
|
-
requestBodyValues,
|
|
12290
|
-
statusCode: response.status
|
|
12291
|
-
});
|
|
12292
|
-
}
|
|
12293
|
-
const eventStream = parseJsonEventStream2({
|
|
12294
|
-
stream: response.body,
|
|
12295
|
-
schema: gatewayVideoEventSchema
|
|
12296
|
-
});
|
|
12297
|
-
const reader = eventStream.getReader();
|
|
12298
|
-
const { done, value: parseResult } = await reader.read();
|
|
12299
|
-
reader.releaseLock();
|
|
12300
|
-
if (done || !parseResult) {
|
|
12301
|
-
throw new APICallError3({
|
|
12302
|
-
message: "SSE stream ended without a data event",
|
|
12303
|
-
url,
|
|
12304
|
-
requestBodyValues,
|
|
12305
|
-
statusCode: response.status
|
|
12306
|
-
});
|
|
12307
|
-
}
|
|
12308
|
-
if (!parseResult.success) {
|
|
12309
|
-
throw new APICallError3({
|
|
12310
|
-
message: "Failed to parse video SSE event",
|
|
12311
|
-
cause: parseResult.error,
|
|
12312
|
-
url,
|
|
12313
|
-
requestBodyValues,
|
|
12314
|
-
statusCode: response.status
|
|
12315
|
-
});
|
|
12316
|
-
}
|
|
12317
|
-
const event = parseResult.value;
|
|
12318
|
-
if (event.type === "error") {
|
|
12319
|
-
throw new APICallError3({
|
|
12320
|
-
message: event.message,
|
|
12321
|
-
statusCode: event.statusCode,
|
|
12322
|
-
url,
|
|
12323
|
-
requestBodyValues,
|
|
12324
|
-
responseHeaders: Object.fromEntries([...response.headers]),
|
|
12325
|
-
responseBody: JSON.stringify(event),
|
|
12326
|
-
data: {
|
|
12327
|
-
error: {
|
|
12328
|
-
message: event.message,
|
|
12329
|
-
type: event.errorType,
|
|
12330
|
-
param: event.param
|
|
12331
|
-
}
|
|
12332
|
-
}
|
|
12333
|
-
});
|
|
12334
|
-
}
|
|
12335
|
-
return {
|
|
12336
|
-
value: {
|
|
12337
|
-
videos: event.videos,
|
|
12338
|
-
warnings: event.warnings,
|
|
12339
|
-
providerMetadata: event.providerMetadata
|
|
12340
|
-
},
|
|
12341
|
-
responseHeaders: Object.fromEntries([...response.headers])
|
|
12342
|
-
};
|
|
12343
|
-
},
|
|
12344
|
-
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
12345
|
-
errorSchema: z4.z.any(),
|
|
12346
|
-
errorToMessage: (data) => data
|
|
12347
|
-
}),
|
|
12348
|
-
...abortSignal && { abortSignal },
|
|
12349
|
-
fetch: this.config.fetch
|
|
12350
|
-
});
|
|
12351
|
-
return {
|
|
12352
|
-
videos: responseBody.videos,
|
|
12353
|
-
warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
|
|
12354
|
-
providerMetadata: responseBody.providerMetadata,
|
|
12355
|
-
response: {
|
|
12356
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
12357
|
-
modelId: this.modelId,
|
|
12358
|
-
headers: responseHeaders
|
|
12359
|
-
}
|
|
12360
|
-
};
|
|
12361
|
-
} catch (error) {
|
|
12362
|
-
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
12363
|
-
}
|
|
12364
|
-
}
|
|
12365
|
-
getUrl() {
|
|
12366
|
-
return `${this.config.baseURL}/video-model`;
|
|
12367
|
-
}
|
|
12368
|
-
getModelConfigHeaders() {
|
|
12369
|
-
return {
|
|
12370
|
-
"ai-video-model-specification-version": "3",
|
|
12371
|
-
"ai-model-id": this.modelId
|
|
12372
|
-
};
|
|
12373
|
-
}
|
|
12374
|
-
};
|
|
12375
|
-
function maybeEncodeVideoFile(file) {
|
|
12376
|
-
if (file.type === "file" && file.data instanceof Uint8Array) {
|
|
12377
|
-
return {
|
|
12378
|
-
...file,
|
|
12379
|
-
data: convertUint8ArrayToBase643(file.data)
|
|
12380
|
-
};
|
|
12381
|
-
}
|
|
12382
|
-
return file;
|
|
12383
|
-
}
|
|
12384
|
-
var providerMetadataEntrySchema22 = z4.z.object({
|
|
12385
|
-
videos: z4.z.array(z4.z.unknown()).optional()
|
|
12386
|
-
}).catchall(z4.z.unknown());
|
|
12387
|
-
var gatewayVideoDataSchema = z4.z.union([
|
|
12388
|
-
z4.z.object({
|
|
12389
|
-
type: z4.z.literal("url"),
|
|
12390
|
-
url: z4.z.string(),
|
|
12391
|
-
mediaType: z4.z.string()
|
|
12392
|
-
}),
|
|
12393
|
-
z4.z.object({
|
|
12394
|
-
type: z4.z.literal("base64"),
|
|
12395
|
-
data: z4.z.string(),
|
|
12396
|
-
mediaType: z4.z.string()
|
|
12397
|
-
})
|
|
12398
|
-
]);
|
|
12399
|
-
var gatewayVideoWarningSchema = z4.z.discriminatedUnion("type", [
|
|
12400
|
-
z4.z.object({
|
|
12401
|
-
type: z4.z.literal("unsupported"),
|
|
12402
|
-
feature: z4.z.string(),
|
|
12403
|
-
details: z4.z.string().optional()
|
|
12404
|
-
}),
|
|
12405
|
-
z4.z.object({
|
|
12406
|
-
type: z4.z.literal("compatibility"),
|
|
12407
|
-
feature: z4.z.string(),
|
|
12408
|
-
details: z4.z.string().optional()
|
|
12409
|
-
}),
|
|
12410
|
-
z4.z.object({
|
|
12411
|
-
type: z4.z.literal("other"),
|
|
12412
|
-
message: z4.z.string()
|
|
12413
|
-
})
|
|
12414
|
-
]);
|
|
12415
|
-
var gatewayVideoEventSchema = z4.z.discriminatedUnion("type", [
|
|
12416
|
-
z4.z.object({
|
|
12417
|
-
type: z4.z.literal("result"),
|
|
12418
|
-
videos: z4.z.array(gatewayVideoDataSchema),
|
|
12419
|
-
warnings: z4.z.array(gatewayVideoWarningSchema).optional(),
|
|
12420
|
-
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema22).optional()
|
|
12421
|
-
}),
|
|
12422
|
-
z4.z.object({
|
|
12423
|
-
type: z4.z.literal("error"),
|
|
12424
|
-
message: z4.z.string(),
|
|
12425
|
-
errorType: z4.z.string(),
|
|
12426
|
-
statusCode: z4.z.number(),
|
|
12427
|
-
param: z4.z.unknown().nullable()
|
|
12428
|
-
})
|
|
12429
|
-
]);
|
|
12430
12143
|
var parallelSearchInputSchema = lazySchema(
|
|
12431
12144
|
() => zodSchema3(
|
|
12432
12145
|
zod.z.object({
|
|
@@ -12600,18 +12313,18 @@ var gatewayTools = {
|
|
|
12600
12313
|
perplexitySearch
|
|
12601
12314
|
};
|
|
12602
12315
|
async function getVercelRequestId2() {
|
|
12603
|
-
var
|
|
12604
|
-
return (
|
|
12316
|
+
var _a832;
|
|
12317
|
+
return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
|
|
12605
12318
|
}
|
|
12606
|
-
var VERSION5 = "3.0.
|
|
12319
|
+
var VERSION5 = "3.0.32";
|
|
12607
12320
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
12608
12321
|
function createGatewayProvider2(options = {}) {
|
|
12609
|
-
var
|
|
12322
|
+
var _a832, _b83;
|
|
12610
12323
|
let pendingMetadata = null;
|
|
12611
12324
|
let metadataCache = null;
|
|
12612
|
-
const cacheRefreshMillis = (
|
|
12325
|
+
const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
|
|
12613
12326
|
let lastFetchTime = 0;
|
|
12614
|
-
const baseURL = (
|
|
12327
|
+
const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
12615
12328
|
const getHeaders = async () => {
|
|
12616
12329
|
try {
|
|
12617
12330
|
const auth = await getGatewayAuthToken2(options);
|
|
@@ -12646,18 +12359,13 @@ function createGatewayProvider2(options = {}) {
|
|
|
12646
12359
|
settingValue: void 0,
|
|
12647
12360
|
environmentVariableName: "VERCEL_REGION"
|
|
12648
12361
|
});
|
|
12649
|
-
const projectId = loadOptionalSetting2({
|
|
12650
|
-
settingValue: void 0,
|
|
12651
|
-
environmentVariableName: "VERCEL_PROJECT_ID"
|
|
12652
|
-
});
|
|
12653
12362
|
return async () => {
|
|
12654
12363
|
const requestId = await getVercelRequestId2();
|
|
12655
12364
|
return {
|
|
12656
12365
|
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
12657
12366
|
...environment && { "ai-o11y-environment": environment },
|
|
12658
12367
|
...region && { "ai-o11y-region": region },
|
|
12659
|
-
...requestId && { "ai-o11y-request-id": requestId }
|
|
12660
|
-
...projectId && { "ai-o11y-project-id": projectId }
|
|
12368
|
+
...requestId && { "ai-o11y-request-id": requestId }
|
|
12661
12369
|
};
|
|
12662
12370
|
};
|
|
12663
12371
|
};
|
|
@@ -12671,8 +12379,8 @@ function createGatewayProvider2(options = {}) {
|
|
|
12671
12379
|
});
|
|
12672
12380
|
};
|
|
12673
12381
|
const getAvailableModels = async () => {
|
|
12674
|
-
var
|
|
12675
|
-
const now2 = (_c = (
|
|
12382
|
+
var _a922, _b92, _c;
|
|
12383
|
+
const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
|
|
12676
12384
|
if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
|
|
12677
12385
|
lastFetchTime = now2;
|
|
12678
12386
|
pendingMetadata = new GatewayFetchMetadata2({
|
|
@@ -12735,19 +12443,6 @@ function createGatewayProvider2(options = {}) {
|
|
|
12735
12443
|
};
|
|
12736
12444
|
provider.embeddingModel = createEmbeddingModel;
|
|
12737
12445
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
12738
|
-
provider.videoModel = (modelId) => {
|
|
12739
|
-
return new GatewayVideoModel(modelId, {
|
|
12740
|
-
provider: "gateway",
|
|
12741
|
-
baseURL,
|
|
12742
|
-
headers: getHeaders,
|
|
12743
|
-
fetch: options.fetch,
|
|
12744
|
-
o11yHeaders: createO11yHeaders()
|
|
12745
|
-
});
|
|
12746
|
-
};
|
|
12747
|
-
provider.chat = provider.languageModel;
|
|
12748
|
-
provider.embedding = provider.embeddingModel;
|
|
12749
|
-
provider.image = provider.imageModel;
|
|
12750
|
-
provider.video = provider.videoModel;
|
|
12751
12446
|
provider.tools = gatewayTools;
|
|
12752
12447
|
return provider;
|
|
12753
12448
|
}
|
|
@@ -12862,12 +12557,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
|
|
|
12862
12557
|
return true;
|
|
12863
12558
|
}
|
|
12864
12559
|
function getGlobal3(type) {
|
|
12865
|
-
var _a21,
|
|
12560
|
+
var _a21, _b83;
|
|
12866
12561
|
var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
12867
12562
|
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
12868
12563
|
return;
|
|
12869
12564
|
}
|
|
12870
|
-
return (
|
|
12565
|
+
return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
|
|
12871
12566
|
}
|
|
12872
12567
|
function unregisterGlobal3(type, diag) {
|
|
12873
12568
|
diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
|
|
@@ -13032,7 +12727,7 @@ var DiagAPI3 = (
|
|
|
13032
12727
|
}
|
|
13033
12728
|
var self = this;
|
|
13034
12729
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
13035
|
-
var _a21,
|
|
12730
|
+
var _a21, _b83, _c;
|
|
13036
12731
|
if (optionsOrLogLevel === void 0) {
|
|
13037
12732
|
optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
|
|
13038
12733
|
}
|
|
@@ -13047,7 +12742,7 @@ var DiagAPI3 = (
|
|
|
13047
12742
|
};
|
|
13048
12743
|
}
|
|
13049
12744
|
var oldLogger = getGlobal3("diag");
|
|
13050
|
-
var newLogger = createLogLevelDiagLogger3((
|
|
12745
|
+
var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
|
|
13051
12746
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
13052
12747
|
var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
|
|
13053
12748
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -13480,10 +13175,10 @@ var __export3 = (target, all) => {
|
|
|
13480
13175
|
for (var name21 in all)
|
|
13481
13176
|
__defProp4(target, name21, { get: all[name21], enumerable: true });
|
|
13482
13177
|
};
|
|
13483
|
-
var
|
|
13484
|
-
var
|
|
13485
|
-
var
|
|
13486
|
-
var
|
|
13178
|
+
var name76 = "AI_InvalidArgumentError";
|
|
13179
|
+
var marker86 = `vercel.ai.error.${name76}`;
|
|
13180
|
+
var symbol86 = Symbol.for(marker86);
|
|
13181
|
+
var _a86;
|
|
13487
13182
|
var InvalidArgumentError23 = class extends AISDKError3 {
|
|
13488
13183
|
constructor({
|
|
13489
13184
|
parameter,
|
|
@@ -13491,20 +13186,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
|
|
|
13491
13186
|
message
|
|
13492
13187
|
}) {
|
|
13493
13188
|
super({
|
|
13494
|
-
name:
|
|
13189
|
+
name: name76,
|
|
13495
13190
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
13496
13191
|
});
|
|
13497
|
-
this[
|
|
13192
|
+
this[_a86] = true;
|
|
13498
13193
|
this.parameter = parameter;
|
|
13499
13194
|
this.value = value;
|
|
13500
13195
|
}
|
|
13501
13196
|
static isInstance(error) {
|
|
13502
|
-
return AISDKError3.hasMarker(error,
|
|
13197
|
+
return AISDKError3.hasMarker(error, marker86);
|
|
13503
13198
|
}
|
|
13504
13199
|
};
|
|
13505
|
-
|
|
13506
|
-
var
|
|
13507
|
-
var marker823 = `vercel.ai.error.${
|
|
13200
|
+
_a86 = symbol86;
|
|
13201
|
+
var name86 = "AI_NoObjectGeneratedError";
|
|
13202
|
+
var marker823 = `vercel.ai.error.${name86}`;
|
|
13508
13203
|
var symbol823 = Symbol.for(marker823);
|
|
13509
13204
|
var _a823;
|
|
13510
13205
|
var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
@@ -13516,7 +13211,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
|
13516
13211
|
usage,
|
|
13517
13212
|
finishReason
|
|
13518
13213
|
}) {
|
|
13519
|
-
super({ name:
|
|
13214
|
+
super({ name: name86, message, cause });
|
|
13520
13215
|
this[_a823] = true;
|
|
13521
13216
|
this.text = text22;
|
|
13522
13217
|
this.response = response;
|
|
@@ -13676,7 +13371,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
13676
13371
|
}
|
|
13677
13372
|
return timeout.totalMs;
|
|
13678
13373
|
}
|
|
13679
|
-
var VERSION33 = "6.0.
|
|
13374
|
+
var VERSION33 = "6.0.69";
|
|
13680
13375
|
var dataContentSchema3 = z4.z.union([
|
|
13681
13376
|
z4.z.string(),
|
|
13682
13377
|
z4.z.instanceof(Uint8Array),
|
|
@@ -13684,8 +13379,8 @@ var dataContentSchema3 = z4.z.union([
|
|
|
13684
13379
|
z4.z.custom(
|
|
13685
13380
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
13686
13381
|
(value) => {
|
|
13687
|
-
var _a21,
|
|
13688
|
-
return (
|
|
13382
|
+
var _a21, _b83;
|
|
13383
|
+
return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
|
|
13689
13384
|
},
|
|
13690
13385
|
{ message: "Must be a Buffer" }
|
|
13691
13386
|
)
|
|
@@ -16688,7 +16383,7 @@ Notes:
|
|
|
16688
16383
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
16689
16384
|
);
|
|
16690
16385
|
}
|
|
16691
|
-
const { ObservationalMemory } = await import('./observational-memory-
|
|
16386
|
+
const { ObservationalMemory } = await import('./observational-memory-3HFM7PY2.cjs');
|
|
16692
16387
|
return new ObservationalMemory({
|
|
16693
16388
|
storage: memoryStore,
|
|
16694
16389
|
scope: omConfig.scope,
|
|
@@ -16703,6 +16398,7 @@ Notes:
|
|
|
16703
16398
|
bufferTokens: omConfig.observation.bufferTokens,
|
|
16704
16399
|
bufferActivation: omConfig.observation.bufferActivation,
|
|
16705
16400
|
blockAfter: omConfig.observation.blockAfter,
|
|
16401
|
+
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
16706
16402
|
instruction: omConfig.observation.instruction
|
|
16707
16403
|
} : void 0,
|
|
16708
16404
|
reflection: omConfig.reflection ? {
|