@mastra/memory 1.17.5 → 1.17.6-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 +17 -0
- package/dist/{chunk-BPJLUC2F.js → chunk-QZGJY67D.js} +85 -6
- package/dist/chunk-QZGJY67D.js.map +1 -0
- package/dist/{chunk-UZDSNIGD.cjs → chunk-WNLFJKTX.cjs} +85 -6
- package/dist/chunk-WNLFJKTX.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +39 -39
- package/dist/docs/references/docs-agents-background-tasks.md +62 -2
- package/dist/docs/references/docs-memory-observational-memory.md +7 -2
- package/dist/docs/references/docs-memory-overview.md +2 -1
- package/dist/index.cjs +298 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +289 -163
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-KWFKMLG6.cjs → observational-memory-BJF72NKJ.cjs} +26 -26
- package/dist/{observational-memory-KWFKMLG6.cjs.map → observational-memory-BJF72NKJ.cjs.map} +1 -1
- package/dist/{observational-memory-FBBKXNO5.js → observational-memory-HAJ3K5JJ.js} +3 -3
- package/dist/{observational-memory-FBBKXNO5.js.map → observational-memory-HAJ3K5JJ.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-BPJLUC2F.js.map +0 -1
- package/dist/chunk-UZDSNIGD.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-
|
|
2
|
-
export { ModelByInputTokens, getObservationsAsOf } from './chunk-
|
|
1
|
+
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-QZGJY67D.js';
|
|
2
|
+
export { ModelByInputTokens, getObservationsAsOf } from './chunk-QZGJY67D.js';
|
|
3
3
|
import { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import * as z4 from 'zod/v4';
|
|
@@ -17,7 +17,7 @@ import { estimateTokenCount } from 'tokenx';
|
|
|
17
17
|
import { isStandardSchemaWithJSON as isStandardSchemaWithJSON$1, toStandardSchema as toStandardSchema$1 } from '@mastra/core/schema';
|
|
18
18
|
export { MessageHistory, SemanticRecall, WorkingMemory } from '@mastra/core/processors';
|
|
19
19
|
|
|
20
|
-
// ../_vendored/ai_v4/dist/chunk-
|
|
20
|
+
// ../_vendored/ai_v4/dist/chunk-HB6FLTHO.js
|
|
21
21
|
var __create = Object.create;
|
|
22
22
|
var __defProp = Object.defineProperty;
|
|
23
23
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -4291,6 +4291,9 @@ var ParseError = class extends Error {
|
|
|
4291
4291
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
4292
4292
|
}
|
|
4293
4293
|
};
|
|
4294
|
+
var LF = 10;
|
|
4295
|
+
var CR = 13;
|
|
4296
|
+
var SPACE = 32;
|
|
4294
4297
|
function noop(_arg) {
|
|
4295
4298
|
}
|
|
4296
4299
|
function createParser(callbacks) {
|
|
@@ -4298,39 +4301,109 @@ function createParser(callbacks) {
|
|
|
4298
4301
|
throw new TypeError(
|
|
4299
4302
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
4300
4303
|
);
|
|
4301
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
4302
|
-
let
|
|
4303
|
-
function feed(
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4304
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
4305
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
4306
|
+
function feed(chunk) {
|
|
4307
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
4308
|
+
const trailing2 = processLines(chunk);
|
|
4309
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
4310
|
+
return;
|
|
4311
|
+
}
|
|
4312
|
+
if (chunk.indexOf(`
|
|
4313
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
4314
|
+
pendingFragments.push(chunk);
|
|
4315
|
+
return;
|
|
4316
|
+
}
|
|
4317
|
+
pendingFragments.push(chunk);
|
|
4318
|
+
const input = pendingFragments.join("");
|
|
4319
|
+
pendingFragments.length = 0;
|
|
4320
|
+
const trailing = processLines(input);
|
|
4321
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
4322
|
+
}
|
|
4323
|
+
function processLines(chunk) {
|
|
4324
|
+
let searchIndex = 0;
|
|
4325
|
+
if (chunk.indexOf("\r") === -1) {
|
|
4326
|
+
let lfIndex = chunk.indexOf(`
|
|
4327
|
+
`, searchIndex);
|
|
4328
|
+
for (; lfIndex !== -1; ) {
|
|
4329
|
+
if (searchIndex === lfIndex) {
|
|
4330
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
4331
|
+
`, searchIndex);
|
|
4332
|
+
continue;
|
|
4333
|
+
}
|
|
4334
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
4335
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
4336
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
4337
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
4338
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
4339
|
+
`, searchIndex);
|
|
4340
|
+
continue;
|
|
4341
|
+
}
|
|
4342
|
+
data = dataLines === 0 ? value : `${data}
|
|
4343
|
+
${value}`, dataLines++;
|
|
4344
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
4345
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
4346
|
+
lfIndex
|
|
4347
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
4348
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
4349
|
+
`, searchIndex);
|
|
4350
|
+
}
|
|
4351
|
+
return chunk.slice(searchIndex);
|
|
4352
|
+
}
|
|
4353
|
+
for (; searchIndex < chunk.length; ) {
|
|
4354
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
4355
|
+
`, searchIndex);
|
|
4356
|
+
let lineEnd = -1;
|
|
4357
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
4358
|
+
break;
|
|
4359
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
4360
|
+
}
|
|
4361
|
+
return chunk.slice(searchIndex);
|
|
4362
|
+
}
|
|
4363
|
+
function parseLine(chunk, start, end) {
|
|
4364
|
+
if (start === end) {
|
|
4311
4365
|
dispatchEvent();
|
|
4312
4366
|
return;
|
|
4313
4367
|
}
|
|
4314
|
-
|
|
4315
|
-
|
|
4368
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
4369
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
4370
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
4371
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
4372
|
+
${value2}`, dataLines++;
|
|
4373
|
+
return;
|
|
4374
|
+
}
|
|
4375
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
4376
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
4380
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
4381
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
4382
|
+
return;
|
|
4383
|
+
}
|
|
4384
|
+
if (firstCharCode === 58) {
|
|
4385
|
+
if (onComment) {
|
|
4386
|
+
const line2 = chunk.slice(start, end);
|
|
4387
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
4388
|
+
}
|
|
4316
4389
|
return;
|
|
4317
4390
|
}
|
|
4318
|
-
const fieldSeparatorIndex = line.indexOf(":");
|
|
4319
|
-
if (fieldSeparatorIndex
|
|
4320
|
-
|
|
4321
|
-
processField(field, value, line);
|
|
4391
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
4392
|
+
if (fieldSeparatorIndex === -1) {
|
|
4393
|
+
processField(line, "", line);
|
|
4322
4394
|
return;
|
|
4323
4395
|
}
|
|
4324
|
-
|
|
4396
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
4397
|
+
processField(field, value, line);
|
|
4325
4398
|
}
|
|
4326
4399
|
function processField(field, value, line) {
|
|
4327
4400
|
switch (field) {
|
|
4328
4401
|
case "event":
|
|
4329
|
-
eventType = value;
|
|
4402
|
+
eventType = value || void 0;
|
|
4330
4403
|
break;
|
|
4331
4404
|
case "data":
|
|
4332
|
-
data = `${data}
|
|
4333
|
-
|
|
4405
|
+
data = dataLines === 0 ? value : `${data}
|
|
4406
|
+
${value}`, dataLines++;
|
|
4334
4407
|
break;
|
|
4335
4408
|
case "id":
|
|
4336
4409
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -4355,37 +4428,26 @@ function createParser(callbacks) {
|
|
|
4355
4428
|
}
|
|
4356
4429
|
}
|
|
4357
4430
|
function dispatchEvent() {
|
|
4358
|
-
|
|
4431
|
+
dataLines > 0 && onEvent({
|
|
4359
4432
|
id,
|
|
4360
|
-
event: eventType
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
data: data.endsWith(`
|
|
4364
|
-
`) ? data.slice(0, -1) : data
|
|
4365
|
-
}), id = void 0, data = "", eventType = "";
|
|
4433
|
+
event: eventType,
|
|
4434
|
+
data
|
|
4435
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
4366
4436
|
}
|
|
4367
4437
|
function reset(options = {}) {
|
|
4368
|
-
|
|
4438
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
4439
|
+
const incompleteLine = pendingFragments.join("");
|
|
4440
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
4441
|
+
}
|
|
4442
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
4369
4443
|
}
|
|
4370
4444
|
return { feed, reset };
|
|
4371
4445
|
}
|
|
4372
|
-
function
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
`, searchIndex);
|
|
4378
|
-
let lineEnd = -1;
|
|
4379
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
4380
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
4381
|
-
break;
|
|
4382
|
-
} else {
|
|
4383
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
4384
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
4385
|
-
` && searchIndex++;
|
|
4386
|
-
}
|
|
4387
|
-
}
|
|
4388
|
-
return [lines, incompleteLine];
|
|
4446
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
4447
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
4448
|
+
}
|
|
4449
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
4450
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
4389
4451
|
}
|
|
4390
4452
|
var EventSourceParserStream = class extends TransformStream {
|
|
4391
4453
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -4561,7 +4623,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
4561
4623
|
);
|
|
4562
4624
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
4563
4625
|
}
|
|
4564
|
-
var VERSION2 = "3.0.
|
|
4626
|
+
var VERSION2 = "3.0.25";
|
|
4565
4627
|
var getOriginalFetch = () => globalThis.fetch;
|
|
4566
4628
|
var getFromApi = async ({
|
|
4567
4629
|
url,
|
|
@@ -5030,6 +5092,33 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
5030
5092
|
rawValue: parsedResult.rawValue
|
|
5031
5093
|
};
|
|
5032
5094
|
};
|
|
5095
|
+
var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
5096
|
+
function lazySchema(createSchema) {
|
|
5097
|
+
let schema;
|
|
5098
|
+
return () => {
|
|
5099
|
+
if (schema == null) {
|
|
5100
|
+
schema = createSchema();
|
|
5101
|
+
}
|
|
5102
|
+
return schema;
|
|
5103
|
+
};
|
|
5104
|
+
}
|
|
5105
|
+
function jsonSchema2(jsonSchema22, {
|
|
5106
|
+
validate
|
|
5107
|
+
} = {}) {
|
|
5108
|
+
return {
|
|
5109
|
+
[schemaSymbol2]: true,
|
|
5110
|
+
_type: void 0,
|
|
5111
|
+
// should never be used directly
|
|
5112
|
+
[validatorSymbol2]: true,
|
|
5113
|
+
get jsonSchema() {
|
|
5114
|
+
if (typeof jsonSchema22 === "function") {
|
|
5115
|
+
jsonSchema22 = jsonSchema22();
|
|
5116
|
+
}
|
|
5117
|
+
return jsonSchema22;
|
|
5118
|
+
},
|
|
5119
|
+
validate
|
|
5120
|
+
};
|
|
5121
|
+
}
|
|
5033
5122
|
function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
|
|
5034
5123
|
if (jsonSchema22.type === "object") {
|
|
5035
5124
|
jsonSchema22.additionalProperties = false;
|
|
@@ -5055,13 +5144,6 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
|
|
|
5055
5144
|
}
|
|
5056
5145
|
return jsonSchema22;
|
|
5057
5146
|
}
|
|
5058
|
-
var getRelativePath2 = (pathA, pathB) => {
|
|
5059
|
-
let i = 0;
|
|
5060
|
-
for (; i < pathA.length && i < pathB.length; i++) {
|
|
5061
|
-
if (pathA[i] !== pathB[i]) break;
|
|
5062
|
-
}
|
|
5063
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
5064
|
-
};
|
|
5065
5147
|
var ignoreOverride2 = /* @__PURE__ */ Symbol(
|
|
5066
5148
|
"Let zodToJsonSchema decide on which parser to use"
|
|
5067
5149
|
);
|
|
@@ -6005,6 +6087,13 @@ var selectParser2 = (def, typeName, refs) => {
|
|
|
6005
6087
|
return /* @__PURE__ */ ((_) => void 0)();
|
|
6006
6088
|
}
|
|
6007
6089
|
};
|
|
6090
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
6091
|
+
let i = 0;
|
|
6092
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
6093
|
+
if (pathA[i] !== pathB[i]) break;
|
|
6094
|
+
}
|
|
6095
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
6096
|
+
};
|
|
6008
6097
|
function parseDef2(def, refs, forceResolution = false) {
|
|
6009
6098
|
var _a224;
|
|
6010
6099
|
const seenItem = refs.seen.get(def);
|
|
@@ -6184,33 +6273,6 @@ function zodSchema2(zodSchema22, options) {
|
|
|
6184
6273
|
return zod3Schema(zodSchema22);
|
|
6185
6274
|
}
|
|
6186
6275
|
}
|
|
6187
|
-
var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
6188
|
-
function lazySchema(createSchema) {
|
|
6189
|
-
let schema;
|
|
6190
|
-
return () => {
|
|
6191
|
-
if (schema == null) {
|
|
6192
|
-
schema = createSchema();
|
|
6193
|
-
}
|
|
6194
|
-
return schema;
|
|
6195
|
-
};
|
|
6196
|
-
}
|
|
6197
|
-
function jsonSchema2(jsonSchema22, {
|
|
6198
|
-
validate
|
|
6199
|
-
} = {}) {
|
|
6200
|
-
return {
|
|
6201
|
-
[schemaSymbol2]: true,
|
|
6202
|
-
_type: void 0,
|
|
6203
|
-
// should never be used directly
|
|
6204
|
-
[validatorSymbol2]: true,
|
|
6205
|
-
get jsonSchema() {
|
|
6206
|
-
if (typeof jsonSchema22 === "function") {
|
|
6207
|
-
jsonSchema22 = jsonSchema22();
|
|
6208
|
-
}
|
|
6209
|
-
return jsonSchema22;
|
|
6210
|
-
},
|
|
6211
|
-
validate
|
|
6212
|
-
};
|
|
6213
|
-
}
|
|
6214
6276
|
function isSchema2(value) {
|
|
6215
6277
|
return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
|
|
6216
6278
|
}
|
|
@@ -6498,6 +6560,19 @@ var gatewayErrorResponseSchema = lazyValidator(
|
|
|
6498
6560
|
})
|
|
6499
6561
|
)
|
|
6500
6562
|
);
|
|
6563
|
+
function extractApiCallResponse(error) {
|
|
6564
|
+
if (error.data !== void 0) {
|
|
6565
|
+
return error.data;
|
|
6566
|
+
}
|
|
6567
|
+
if (error.responseBody != null) {
|
|
6568
|
+
try {
|
|
6569
|
+
return JSON.parse(error.responseBody);
|
|
6570
|
+
} catch (e) {
|
|
6571
|
+
return error.responseBody;
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6574
|
+
return {};
|
|
6575
|
+
}
|
|
6501
6576
|
var name74 = "GatewayTimeoutError";
|
|
6502
6577
|
var marker84 = `vercel.ai.gateway.error.${name74}`;
|
|
6503
6578
|
var symbol84 = Symbol.for(marker84);
|
|
@@ -6584,19 +6659,6 @@ async function asGatewayError(error, authMethod) {
|
|
|
6584
6659
|
authMethod
|
|
6585
6660
|
});
|
|
6586
6661
|
}
|
|
6587
|
-
function extractApiCallResponse(error) {
|
|
6588
|
-
if (error.data !== void 0) {
|
|
6589
|
-
return error.data;
|
|
6590
|
-
}
|
|
6591
|
-
if (error.responseBody != null) {
|
|
6592
|
-
try {
|
|
6593
|
-
return JSON.parse(error.responseBody);
|
|
6594
|
-
} catch (e) {
|
|
6595
|
-
return error.responseBody;
|
|
6596
|
-
}
|
|
6597
|
-
}
|
|
6598
|
-
return {};
|
|
6599
|
-
}
|
|
6600
6662
|
var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
|
|
6601
6663
|
async function parseAuthMethod(headers) {
|
|
6602
6664
|
const result = await safeValidateTypes2({
|
|
@@ -7383,7 +7445,7 @@ async function getVercelRequestId() {
|
|
|
7383
7445
|
var _a932;
|
|
7384
7446
|
return (_a932 = getContext().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
7385
7447
|
}
|
|
7386
|
-
var VERSION3 = "2.0.
|
|
7448
|
+
var VERSION3 = "2.0.86";
|
|
7387
7449
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7388
7450
|
function createGatewayProvider(options = {}) {
|
|
7389
7451
|
var _a932, _b93;
|
|
@@ -8370,7 +8432,7 @@ function getGlobalProvider() {
|
|
|
8370
8432
|
var _a163;
|
|
8371
8433
|
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
8372
8434
|
}
|
|
8373
|
-
var VERSION32 = "5.0.
|
|
8435
|
+
var VERSION32 = "5.0.184";
|
|
8374
8436
|
var dataContentSchema2 = z$1.union([
|
|
8375
8437
|
z$1.string(),
|
|
8376
8438
|
z$1.instanceof(Uint8Array),
|
|
@@ -9675,6 +9737,9 @@ var ParseError2 = class extends Error {
|
|
|
9675
9737
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
9676
9738
|
}
|
|
9677
9739
|
};
|
|
9740
|
+
var LF2 = 10;
|
|
9741
|
+
var CR2 = 13;
|
|
9742
|
+
var SPACE2 = 32;
|
|
9678
9743
|
function noop2(_arg) {
|
|
9679
9744
|
}
|
|
9680
9745
|
function createParser2(callbacks) {
|
|
@@ -9682,39 +9747,109 @@ function createParser2(callbacks) {
|
|
|
9682
9747
|
throw new TypeError(
|
|
9683
9748
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
9684
9749
|
);
|
|
9685
|
-
const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment } = callbacks;
|
|
9686
|
-
let
|
|
9687
|
-
function feed(
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9750
|
+
const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment } = callbacks, pendingFragments = [];
|
|
9751
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
9752
|
+
function feed(chunk) {
|
|
9753
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
9754
|
+
const trailing2 = processLines(chunk);
|
|
9755
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
9756
|
+
return;
|
|
9757
|
+
}
|
|
9758
|
+
if (chunk.indexOf(`
|
|
9759
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
9760
|
+
pendingFragments.push(chunk);
|
|
9761
|
+
return;
|
|
9762
|
+
}
|
|
9763
|
+
pendingFragments.push(chunk);
|
|
9764
|
+
const input = pendingFragments.join("");
|
|
9765
|
+
pendingFragments.length = 0;
|
|
9766
|
+
const trailing = processLines(input);
|
|
9767
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
9768
|
+
}
|
|
9769
|
+
function processLines(chunk) {
|
|
9770
|
+
let searchIndex = 0;
|
|
9771
|
+
if (chunk.indexOf("\r") === -1) {
|
|
9772
|
+
let lfIndex = chunk.indexOf(`
|
|
9773
|
+
`, searchIndex);
|
|
9774
|
+
for (; lfIndex !== -1; ) {
|
|
9775
|
+
if (searchIndex === lfIndex) {
|
|
9776
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
9777
|
+
`, searchIndex);
|
|
9778
|
+
continue;
|
|
9779
|
+
}
|
|
9780
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
9781
|
+
if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
|
|
9782
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
9783
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
|
|
9784
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
9785
|
+
`, searchIndex);
|
|
9786
|
+
continue;
|
|
9787
|
+
}
|
|
9788
|
+
data = dataLines === 0 ? value : `${data}
|
|
9789
|
+
${value}`, dataLines++;
|
|
9790
|
+
} else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
9791
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
|
|
9792
|
+
lfIndex
|
|
9793
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
9794
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
9795
|
+
`, searchIndex);
|
|
9796
|
+
}
|
|
9797
|
+
return chunk.slice(searchIndex);
|
|
9798
|
+
}
|
|
9799
|
+
for (; searchIndex < chunk.length; ) {
|
|
9800
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
9801
|
+
`, searchIndex);
|
|
9802
|
+
let lineEnd = -1;
|
|
9803
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
9804
|
+
break;
|
|
9805
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
|
|
9806
|
+
}
|
|
9807
|
+
return chunk.slice(searchIndex);
|
|
9808
|
+
}
|
|
9809
|
+
function parseLine(chunk, start, end) {
|
|
9810
|
+
if (start === end) {
|
|
9695
9811
|
dispatchEvent();
|
|
9696
9812
|
return;
|
|
9697
9813
|
}
|
|
9698
|
-
|
|
9699
|
-
|
|
9814
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
9815
|
+
if (isDataPrefix2(chunk, start, firstCharCode)) {
|
|
9816
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
9817
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
9818
|
+
${value2}`, dataLines++;
|
|
9819
|
+
return;
|
|
9820
|
+
}
|
|
9821
|
+
if (isEventPrefix2(chunk, start, firstCharCode)) {
|
|
9822
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
|
|
9823
|
+
return;
|
|
9824
|
+
}
|
|
9825
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
9826
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
|
|
9827
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
9828
|
+
return;
|
|
9829
|
+
}
|
|
9830
|
+
if (firstCharCode === 58) {
|
|
9831
|
+
if (onComment) {
|
|
9832
|
+
const line2 = chunk.slice(start, end);
|
|
9833
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
|
|
9834
|
+
}
|
|
9700
9835
|
return;
|
|
9701
9836
|
}
|
|
9702
|
-
const fieldSeparatorIndex = line.indexOf(":");
|
|
9703
|
-
if (fieldSeparatorIndex
|
|
9704
|
-
|
|
9705
|
-
processField(field, value, line);
|
|
9837
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
9838
|
+
if (fieldSeparatorIndex === -1) {
|
|
9839
|
+
processField(line, "", line);
|
|
9706
9840
|
return;
|
|
9707
9841
|
}
|
|
9708
|
-
|
|
9842
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
9843
|
+
processField(field, value, line);
|
|
9709
9844
|
}
|
|
9710
9845
|
function processField(field, value, line) {
|
|
9711
9846
|
switch (field) {
|
|
9712
9847
|
case "event":
|
|
9713
|
-
eventType = value;
|
|
9848
|
+
eventType = value || void 0;
|
|
9714
9849
|
break;
|
|
9715
9850
|
case "data":
|
|
9716
|
-
data = `${data}
|
|
9717
|
-
|
|
9851
|
+
data = dataLines === 0 ? value : `${data}
|
|
9852
|
+
${value}`, dataLines++;
|
|
9718
9853
|
break;
|
|
9719
9854
|
case "id":
|
|
9720
9855
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -9739,37 +9874,26 @@ function createParser2(callbacks) {
|
|
|
9739
9874
|
}
|
|
9740
9875
|
}
|
|
9741
9876
|
function dispatchEvent() {
|
|
9742
|
-
|
|
9877
|
+
dataLines > 0 && onEvent({
|
|
9743
9878
|
id,
|
|
9744
|
-
event: eventType
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
data: data.endsWith(`
|
|
9748
|
-
`) ? data.slice(0, -1) : data
|
|
9749
|
-
}), id = void 0, data = "", eventType = "";
|
|
9879
|
+
event: eventType,
|
|
9880
|
+
data
|
|
9881
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
9750
9882
|
}
|
|
9751
9883
|
function reset(options = {}) {
|
|
9752
|
-
|
|
9884
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
9885
|
+
const incompleteLine = pendingFragments.join("");
|
|
9886
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
9887
|
+
}
|
|
9888
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
9753
9889
|
}
|
|
9754
9890
|
return { feed, reset };
|
|
9755
9891
|
}
|
|
9756
|
-
function
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
`, searchIndex);
|
|
9762
|
-
let lineEnd = -1;
|
|
9763
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
9764
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
9765
|
-
break;
|
|
9766
|
-
} else {
|
|
9767
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
9768
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
9769
|
-
` && searchIndex++;
|
|
9770
|
-
}
|
|
9771
|
-
}
|
|
9772
|
-
return [lines, incompleteLine];
|
|
9892
|
+
function isDataPrefix2(chunk, i, firstCharCode) {
|
|
9893
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
9894
|
+
}
|
|
9895
|
+
function isEventPrefix2(chunk, i, firstCharCode) {
|
|
9896
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
9773
9897
|
}
|
|
9774
9898
|
var EventSourceParserStream2 = class extends TransformStream {
|
|
9775
9899
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -9981,7 +10105,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
9981
10105
|
);
|
|
9982
10106
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9983
10107
|
}
|
|
9984
|
-
var VERSION4 = "4.0.
|
|
10108
|
+
var VERSION4 = "4.0.26";
|
|
9985
10109
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
9986
10110
|
var getFromApi2 = async ({
|
|
9987
10111
|
url,
|
|
@@ -11953,6 +12077,19 @@ var gatewayErrorResponseSchema2 = lazySchema2(
|
|
|
11953
12077
|
})
|
|
11954
12078
|
)
|
|
11955
12079
|
);
|
|
12080
|
+
function extractApiCallResponse2(error) {
|
|
12081
|
+
if (error.data !== void 0) {
|
|
12082
|
+
return error.data;
|
|
12083
|
+
}
|
|
12084
|
+
if (error.responseBody != null) {
|
|
12085
|
+
try {
|
|
12086
|
+
return JSON.parse(error.responseBody);
|
|
12087
|
+
} catch (e) {
|
|
12088
|
+
return error.responseBody;
|
|
12089
|
+
}
|
|
12090
|
+
}
|
|
12091
|
+
return {};
|
|
12092
|
+
}
|
|
11956
12093
|
var name76 = "GatewayTimeoutError";
|
|
11957
12094
|
var marker86 = `vercel.ai.gateway.error.${name76}`;
|
|
11958
12095
|
var symbol86 = Symbol.for(marker86);
|
|
@@ -12042,19 +12179,6 @@ async function asGatewayError2(error, authMethod) {
|
|
|
12042
12179
|
authMethod
|
|
12043
12180
|
});
|
|
12044
12181
|
}
|
|
12045
|
-
function extractApiCallResponse2(error) {
|
|
12046
|
-
if (error.data !== void 0) {
|
|
12047
|
-
return error.data;
|
|
12048
|
-
}
|
|
12049
|
-
if (error.responseBody != null) {
|
|
12050
|
-
try {
|
|
12051
|
-
return JSON.parse(error.responseBody);
|
|
12052
|
-
} catch (e) {
|
|
12053
|
-
return error.responseBody;
|
|
12054
|
-
}
|
|
12055
|
-
}
|
|
12056
|
-
return {};
|
|
12057
|
-
}
|
|
12058
12182
|
var GATEWAY_AUTH_METHOD_HEADER2 = "ai-gateway-auth-method";
|
|
12059
12183
|
async function parseAuthMethod2(headers) {
|
|
12060
12184
|
const result = await safeValidateTypes3({
|
|
@@ -13148,7 +13272,7 @@ async function getVercelRequestId2() {
|
|
|
13148
13272
|
var _a932;
|
|
13149
13273
|
return (_a932 = getContext2().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
13150
13274
|
}
|
|
13151
|
-
var VERSION5 = "3.0.
|
|
13275
|
+
var VERSION5 = "3.0.110";
|
|
13152
13276
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
13153
13277
|
function createGatewayProvider2(options = {}) {
|
|
13154
13278
|
var _a932, _b93;
|
|
@@ -14258,7 +14382,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
14258
14382
|
}
|
|
14259
14383
|
return timeout.totalMs;
|
|
14260
14384
|
}
|
|
14261
|
-
var VERSION33 = "6.0.
|
|
14385
|
+
var VERSION33 = "6.0.175";
|
|
14262
14386
|
var dataContentSchema3 = z$1.union([
|
|
14263
14387
|
z$1.string(),
|
|
14264
14388
|
z$1.instanceof(Uint8Array),
|
|
@@ -17602,7 +17726,7 @@ ${workingMemory}`;
|
|
|
17602
17726
|
messageCount: messages.length
|
|
17603
17727
|
});
|
|
17604
17728
|
try {
|
|
17605
|
-
const updatedMessages = messages.map((m) => {
|
|
17729
|
+
const updatedMessages = messages.filter((m) => m.role !== "system").map((m) => {
|
|
17606
17730
|
return this.updateMessageToHideWorkingMemoryV2(m);
|
|
17607
17731
|
}).filter((m) => Boolean(m));
|
|
17608
17732
|
const config = this.getMergedThreadConfig(memoryConfig);
|
|
@@ -17917,8 +18041,10 @@ ${workingMemory}`;
|
|
|
17917
18041
|
*/
|
|
17918
18042
|
async persistMessages(messages) {
|
|
17919
18043
|
if (messages.length === 0) return;
|
|
18044
|
+
const persistableMessages = messages.filter((m) => m.role !== "system");
|
|
18045
|
+
if (persistableMessages.length === 0) return;
|
|
17920
18046
|
const memoryStore = await this.getMemoryStore();
|
|
17921
|
-
await memoryStore.saveMessages({ messages });
|
|
18047
|
+
await memoryStore.saveMessages({ messages: persistableMessages });
|
|
17922
18048
|
}
|
|
17923
18049
|
/**
|
|
17924
18050
|
* One-time initialization of the shared ObservationalMemory engine.
|
|
@@ -17945,7 +18071,7 @@ ${workingMemory}`;
|
|
|
17945
18071
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
17946
18072
|
);
|
|
17947
18073
|
}
|
|
17948
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
18074
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-HAJ3K5JJ.js');
|
|
17949
18075
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
17950
18076
|
await this.indexObservation(observation);
|
|
17951
18077
|
} : void 0;
|
|
@@ -18871,7 +18997,7 @@ Notes:
|
|
|
18871
18997
|
if (!effectiveConfig) return null;
|
|
18872
18998
|
const engine = await this.omEngine;
|
|
18873
18999
|
if (!engine) return null;
|
|
18874
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
19000
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-HAJ3K5JJ.js');
|
|
18875
19001
|
return new ObservationalMemoryProcessor(engine, this, {
|
|
18876
19002
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
18877
19003
|
});
|