@mastra/memory 1.20.1-alpha.1 → 1.20.2-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.
- package/CHANGELOG.md +42 -0
- package/dist/chunk-43FJOLKM.cjs +108 -0
- package/dist/chunk-43FJOLKM.cjs.map +1 -0
- package/dist/{chunk-3Q3LOVQP.cjs → chunk-D4J4XPGM.cjs} +2 -9
- package/dist/chunk-D4J4XPGM.cjs.map +1 -0
- package/dist/{chunk-VKRZ3O5X.js → chunk-LSJJAJAF.js} +3 -9
- package/dist/chunk-LSJJAJAF.js.map +1 -0
- package/dist/{chunk-P4BYW7GY.cjs → chunk-PTCSCRB6.cjs} +27 -27
- package/dist/{chunk-P4BYW7GY.cjs.map → chunk-PTCSCRB6.cjs.map} +1 -1
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/{chunk-KMJQDCCZ.js → chunk-SXFOZU7K.js} +3 -3
- package/dist/{chunk-KMJQDCCZ.js.map → chunk-SXFOZU7K.js.map} +1 -1
- package/dist/chunk-WCGXQIEN.js +103 -0
- package/dist/chunk-WCGXQIEN.js.map +1 -0
- package/dist/constants-DVRTNEGY.js +3 -0
- package/dist/{constants-SPS7MR4D.js.map → constants-DVRTNEGY.js.map} +1 -1
- package/dist/{constants-D6W7OWCP.cjs → constants-JS5SS7GS.cjs} +8 -8
- package/dist/{constants-D6W7OWCP.cjs.map → constants-JS5SS7GS.cjs.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +43 -30
- package/dist/docs/references/docs-agents-agent-approval.md +1 -1
- package/dist/docs/references/docs-agents-background-tasks.md +2 -2
- package/dist/docs/references/docs-agents-networks.md +1 -1
- package/dist/docs/references/docs-agents-supervisor-agents.md +2 -2
- package/dist/docs/references/docs-memory-memory-processors.md +6 -6
- package/dist/docs/references/docs-memory-multi-user-threads.md +2 -2
- package/dist/docs/references/docs-memory-semantic-recall.md +1 -1
- package/dist/docs/references/docs-memory-storage.md +2 -1
- package/dist/docs/references/docs-memory-working-memory.md +28 -1
- package/dist/docs/references/reference-memory-memory-class.md +3 -3
- package/dist/docs/references/reference-memory-observational-memory.md +4 -4
- package/dist/docs/references/reference-processors-token-limiter-processor.md +3 -3
- package/dist/docs/references/reference-storage-dsql.md +1 -1
- package/dist/docs/references/reference-storage-libsql.md +6 -0
- package/dist/docs/references/reference-storage-mongodb.md +4 -1
- package/dist/docs/references/reference-storage-postgresql.md +4 -1
- package/dist/docs/references/reference-storage-redis.md +1 -1
- package/dist/docs/references/reference-storage-upstash.md +1 -1
- package/dist/docs/references/reference-vectors-libsql.md +1 -1
- package/dist/docs/references/reference-vectors-mongodb.md +1 -1
- package/dist/docs/references/reference-vectors-pg.md +1 -1
- package/dist/docs/references/reference-vectors-upstash.md +1 -1
- package/dist/index.cjs +222 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +184 -72
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-TJFOX3YN.js → observational-memory-G52HNRHE.js} +4 -4
- package/dist/{observational-memory-TJFOX3YN.js.map → observational-memory-G52HNRHE.js.map} +1 -1
- package/dist/{observational-memory-CDLGZL67.cjs → observational-memory-SZF7GKTS.cjs} +31 -31
- package/dist/{observational-memory-CDLGZL67.cjs.map → observational-memory-SZF7GKTS.cjs.map} +1 -1
- package/dist/processors/index.cjs +29 -29
- package/dist/processors/index.js +2 -2
- package/dist/processors/observational-memory/index.d.ts +1 -1
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/working-memory-state/index.d.ts +2 -0
- package/dist/processors/working-memory-state/index.d.ts.map +1 -0
- package/dist/processors/working-memory-state/processor.d.ts +53 -0
- package/dist/processors/working-memory-state/processor.d.ts.map +1 -0
- package/dist/tools/working-memory.d.ts +22 -0
- package/dist/tools/working-memory.d.ts.map +1 -1
- package/dist/working-memory-state-J7ASTNXX.js +3 -0
- package/dist/working-memory-state-J7ASTNXX.js.map +1 -0
- package/dist/working-memory-state-Y2SCKCNU.cjs +24 -0
- package/dist/working-memory-state-Y2SCKCNU.cjs.map +1 -0
- package/package.json +9 -8
- package/dist/chunk-3Q3LOVQP.cjs.map +0 -1
- package/dist/chunk-VKRZ3O5X.js.map +0 -1
- package/dist/constants-SPS7MR4D.js +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkPTCSCRB6_cjs = require('./chunk-PTCSCRB6.cjs');
|
|
4
|
+
var chunk43FJOLKM_cjs = require('./chunk-43FJOLKM.cjs');
|
|
5
|
+
var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
|
|
5
6
|
var agent = require('@mastra/core/agent');
|
|
6
7
|
var features = require('@mastra/core/features');
|
|
7
8
|
var memory = require('@mastra/core/memory');
|
|
@@ -442,7 +443,7 @@ function safeParseJSON({
|
|
|
442
443
|
|
|
443
444
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v3/external.js
|
|
444
445
|
var external_exports = {};
|
|
445
|
-
|
|
446
|
+
chunkQ7SFCCGT_cjs.__export(external_exports, {
|
|
446
447
|
BRAND: () => BRAND,
|
|
447
448
|
DIRTY: () => DIRTY,
|
|
448
449
|
EMPTY_PATH: () => EMPTY_PATH,
|
|
@@ -8159,7 +8160,7 @@ function trimStartOfStream() {
|
|
|
8159
8160
|
|
|
8160
8161
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/external.js
|
|
8161
8162
|
var external_exports2 = {};
|
|
8162
|
-
|
|
8163
|
+
chunkQ7SFCCGT_cjs.__export(external_exports2, {
|
|
8163
8164
|
$brand: () => $brand,
|
|
8164
8165
|
$input: () => $input,
|
|
8165
8166
|
$output: () => $output,
|
|
@@ -8402,7 +8403,7 @@ chunk3Q3LOVQP_cjs.__export(external_exports2, {
|
|
|
8402
8403
|
|
|
8403
8404
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/index.js
|
|
8404
8405
|
var core_exports2 = {};
|
|
8405
|
-
|
|
8406
|
+
chunkQ7SFCCGT_cjs.__export(core_exports2, {
|
|
8406
8407
|
$ZodAny: () => $ZodAny,
|
|
8407
8408
|
$ZodArray: () => $ZodArray,
|
|
8408
8409
|
$ZodAsyncError: () => $ZodAsyncError,
|
|
@@ -8758,7 +8759,7 @@ function config(newConfig) {
|
|
|
8758
8759
|
|
|
8759
8760
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/util.js
|
|
8760
8761
|
var util_exports = {};
|
|
8761
|
-
|
|
8762
|
+
chunkQ7SFCCGT_cjs.__export(util_exports, {
|
|
8762
8763
|
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
8763
8764
|
Class: () => Class,
|
|
8764
8765
|
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
@@ -9679,7 +9680,7 @@ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
|
9679
9680
|
|
|
9680
9681
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/regexes.js
|
|
9681
9682
|
var regexes_exports = {};
|
|
9682
|
-
|
|
9683
|
+
chunkQ7SFCCGT_cjs.__export(regexes_exports, {
|
|
9683
9684
|
base64: () => base64,
|
|
9684
9685
|
base64url: () => base64url,
|
|
9685
9686
|
bigint: () => bigint,
|
|
@@ -12522,7 +12523,7 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
12522
12523
|
|
|
12523
12524
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/locales/index.js
|
|
12524
12525
|
var locales_exports = {};
|
|
12525
|
-
|
|
12526
|
+
chunkQ7SFCCGT_cjs.__export(locales_exports, {
|
|
12526
12527
|
ar: () => ar_default,
|
|
12527
12528
|
az: () => az_default,
|
|
12528
12529
|
be: () => be_default,
|
|
@@ -20542,7 +20543,7 @@ var json_schema_exports = {};
|
|
|
20542
20543
|
|
|
20543
20544
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/schemas.js
|
|
20544
20545
|
var schemas_exports2 = {};
|
|
20545
|
-
|
|
20546
|
+
chunkQ7SFCCGT_cjs.__export(schemas_exports2, {
|
|
20546
20547
|
ZodAny: () => ZodAny2,
|
|
20547
20548
|
ZodArray: () => ZodArray2,
|
|
20548
20549
|
ZodBase64: () => ZodBase64,
|
|
@@ -20713,7 +20714,7 @@ chunk3Q3LOVQP_cjs.__export(schemas_exports2, {
|
|
|
20713
20714
|
|
|
20714
20715
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/checks.js
|
|
20715
20716
|
var checks_exports2 = {};
|
|
20716
|
-
|
|
20717
|
+
chunkQ7SFCCGT_cjs.__export(checks_exports2, {
|
|
20717
20718
|
endsWith: () => _endsWith,
|
|
20718
20719
|
gt: () => _gt,
|
|
20719
20720
|
gte: () => _gte,
|
|
@@ -20747,7 +20748,7 @@ chunk3Q3LOVQP_cjs.__export(checks_exports2, {
|
|
|
20747
20748
|
|
|
20748
20749
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/iso.js
|
|
20749
20750
|
var iso_exports = {};
|
|
20750
|
-
|
|
20751
|
+
chunkQ7SFCCGT_cjs.__export(iso_exports, {
|
|
20751
20752
|
ZodISODate: () => ZodISODate,
|
|
20752
20753
|
ZodISODateTime: () => ZodISODateTime,
|
|
20753
20754
|
ZodISODuration: () => ZodISODuration,
|
|
@@ -22638,7 +22639,7 @@ function fromJSONSchema(schema, params) {
|
|
|
22638
22639
|
|
|
22639
22640
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/coerce.js
|
|
22640
22641
|
var coerce_exports = {};
|
|
22641
|
-
|
|
22642
|
+
chunkQ7SFCCGT_cjs.__export(coerce_exports, {
|
|
22642
22643
|
bigint: () => bigint3,
|
|
22643
22644
|
boolean: () => boolean3,
|
|
22644
22645
|
date: () => date4,
|
|
@@ -22917,7 +22918,7 @@ var ZodFirstPartyTypeKind3;
|
|
|
22917
22918
|
ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
|
|
22918
22919
|
})(ZodFirstPartyTypeKind3 || (ZodFirstPartyTypeKind3 = {}));
|
|
22919
22920
|
|
|
22920
|
-
// ../_vendored/ai_v5/dist/chunk-
|
|
22921
|
+
// ../_vendored/ai_v5/dist/chunk-FJXUDWCB.js
|
|
22921
22922
|
var marker17 = "vercel.ai.error";
|
|
22922
22923
|
var symbol18 = Symbol.for(marker17);
|
|
22923
22924
|
var _a19;
|
|
@@ -23096,6 +23097,9 @@ var ParseError = class extends Error {
|
|
|
23096
23097
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
23097
23098
|
}
|
|
23098
23099
|
};
|
|
23100
|
+
var LF = 10;
|
|
23101
|
+
var CR = 13;
|
|
23102
|
+
var SPACE = 32;
|
|
23099
23103
|
function noop(_arg) {
|
|
23100
23104
|
}
|
|
23101
23105
|
function createParser(callbacks) {
|
|
@@ -23103,39 +23107,109 @@ function createParser(callbacks) {
|
|
|
23103
23107
|
throw new TypeError(
|
|
23104
23108
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
23105
23109
|
);
|
|
23106
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
23107
|
-
let
|
|
23108
|
-
function feed(
|
|
23109
|
-
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
|
|
23115
|
-
|
|
23110
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
23111
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
23112
|
+
function feed(chunk) {
|
|
23113
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
23114
|
+
const trailing2 = processLines(chunk);
|
|
23115
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
23116
|
+
return;
|
|
23117
|
+
}
|
|
23118
|
+
if (chunk.indexOf(`
|
|
23119
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
23120
|
+
pendingFragments.push(chunk);
|
|
23121
|
+
return;
|
|
23122
|
+
}
|
|
23123
|
+
pendingFragments.push(chunk);
|
|
23124
|
+
const input = pendingFragments.join("");
|
|
23125
|
+
pendingFragments.length = 0;
|
|
23126
|
+
const trailing = processLines(input);
|
|
23127
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
23128
|
+
}
|
|
23129
|
+
function processLines(chunk) {
|
|
23130
|
+
let searchIndex = 0;
|
|
23131
|
+
if (chunk.indexOf("\r") === -1) {
|
|
23132
|
+
let lfIndex = chunk.indexOf(`
|
|
23133
|
+
`, searchIndex);
|
|
23134
|
+
for (; lfIndex !== -1; ) {
|
|
23135
|
+
if (searchIndex === lfIndex) {
|
|
23136
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
23137
|
+
`, searchIndex);
|
|
23138
|
+
continue;
|
|
23139
|
+
}
|
|
23140
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
23141
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
23142
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
23143
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
23144
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
23145
|
+
`, searchIndex);
|
|
23146
|
+
continue;
|
|
23147
|
+
}
|
|
23148
|
+
data = dataLines === 0 ? value : `${data}
|
|
23149
|
+
${value}`, dataLines++;
|
|
23150
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
23151
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
23152
|
+
lfIndex
|
|
23153
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
23154
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
23155
|
+
`, searchIndex);
|
|
23156
|
+
}
|
|
23157
|
+
return chunk.slice(searchIndex);
|
|
23158
|
+
}
|
|
23159
|
+
for (; searchIndex < chunk.length; ) {
|
|
23160
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
23161
|
+
`, searchIndex);
|
|
23162
|
+
let lineEnd = -1;
|
|
23163
|
+
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)
|
|
23164
|
+
break;
|
|
23165
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
23166
|
+
}
|
|
23167
|
+
return chunk.slice(searchIndex);
|
|
23168
|
+
}
|
|
23169
|
+
function parseLine(chunk, start, end) {
|
|
23170
|
+
if (start === end) {
|
|
23116
23171
|
dispatchEvent();
|
|
23117
23172
|
return;
|
|
23118
23173
|
}
|
|
23119
|
-
|
|
23120
|
-
|
|
23174
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
23175
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
23176
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
23177
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
23178
|
+
${value2}`, dataLines++;
|
|
23121
23179
|
return;
|
|
23122
23180
|
}
|
|
23123
|
-
|
|
23124
|
-
|
|
23125
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
23126
|
-
processField(field, value, line);
|
|
23181
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
23182
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
23127
23183
|
return;
|
|
23128
23184
|
}
|
|
23129
|
-
|
|
23185
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
23186
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
23187
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
23188
|
+
return;
|
|
23189
|
+
}
|
|
23190
|
+
if (firstCharCode === 58) {
|
|
23191
|
+
if (onComment) {
|
|
23192
|
+
const line2 = chunk.slice(start, end);
|
|
23193
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
23194
|
+
}
|
|
23195
|
+
return;
|
|
23196
|
+
}
|
|
23197
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
23198
|
+
if (fieldSeparatorIndex === -1) {
|
|
23199
|
+
processField(line, "", line);
|
|
23200
|
+
return;
|
|
23201
|
+
}
|
|
23202
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
23203
|
+
processField(field, value, line);
|
|
23130
23204
|
}
|
|
23131
23205
|
function processField(field, value, line) {
|
|
23132
23206
|
switch (field) {
|
|
23133
23207
|
case "event":
|
|
23134
|
-
eventType = value;
|
|
23208
|
+
eventType = value || void 0;
|
|
23135
23209
|
break;
|
|
23136
23210
|
case "data":
|
|
23137
|
-
data = `${data}
|
|
23138
|
-
|
|
23211
|
+
data = dataLines === 0 ? value : `${data}
|
|
23212
|
+
${value}`, dataLines++;
|
|
23139
23213
|
break;
|
|
23140
23214
|
case "id":
|
|
23141
23215
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -23160,37 +23234,26 @@ function createParser(callbacks) {
|
|
|
23160
23234
|
}
|
|
23161
23235
|
}
|
|
23162
23236
|
function dispatchEvent() {
|
|
23163
|
-
|
|
23237
|
+
dataLines > 0 && onEvent({
|
|
23164
23238
|
id,
|
|
23165
|
-
event: eventType
|
|
23166
|
-
|
|
23167
|
-
|
|
23168
|
-
data: data.endsWith(`
|
|
23169
|
-
`) ? data.slice(0, -1) : data
|
|
23170
|
-
}), id = void 0, data = "", eventType = "";
|
|
23239
|
+
event: eventType,
|
|
23240
|
+
data
|
|
23241
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
23171
23242
|
}
|
|
23172
23243
|
function reset(options = {}) {
|
|
23173
|
-
|
|
23244
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
23245
|
+
const incompleteLine = pendingFragments.join("");
|
|
23246
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
23247
|
+
}
|
|
23248
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
23174
23249
|
}
|
|
23175
23250
|
return { feed, reset };
|
|
23176
23251
|
}
|
|
23177
|
-
function
|
|
23178
|
-
|
|
23179
|
-
|
|
23180
|
-
|
|
23181
|
-
|
|
23182
|
-
`, searchIndex);
|
|
23183
|
-
let lineEnd = -1;
|
|
23184
|
-
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) {
|
|
23185
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
23186
|
-
break;
|
|
23187
|
-
} else {
|
|
23188
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
23189
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
23190
|
-
` && searchIndex++;
|
|
23191
|
-
}
|
|
23192
|
-
}
|
|
23193
|
-
return [lines, incompleteLine];
|
|
23252
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
23253
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
23254
|
+
}
|
|
23255
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
23256
|
+
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;
|
|
23194
23257
|
}
|
|
23195
23258
|
var EventSourceParserStream = class extends TransformStream {
|
|
23196
23259
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -28280,7 +28343,7 @@ var object3 = ({
|
|
|
28280
28343
|
|
|
28281
28344
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/classic/external.js
|
|
28282
28345
|
var external_exports3 = {};
|
|
28283
|
-
|
|
28346
|
+
chunkQ7SFCCGT_cjs.__export(external_exports3, {
|
|
28284
28347
|
$brand: () => $brand2,
|
|
28285
28348
|
$input: () => $input2,
|
|
28286
28349
|
$output: () => $output2,
|
|
@@ -28492,7 +28555,7 @@ chunk3Q3LOVQP_cjs.__export(external_exports3, {
|
|
|
28492
28555
|
|
|
28493
28556
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/core/index.js
|
|
28494
28557
|
var core_exports4 = {};
|
|
28495
|
-
|
|
28558
|
+
chunkQ7SFCCGT_cjs.__export(core_exports4, {
|
|
28496
28559
|
$ZodAny: () => $ZodAny2,
|
|
28497
28560
|
$ZodArray: () => $ZodArray2,
|
|
28498
28561
|
$ZodAsyncError: () => $ZodAsyncError2,
|
|
@@ -28796,7 +28859,7 @@ function config2(newConfig) {
|
|
|
28796
28859
|
|
|
28797
28860
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/core/util.js
|
|
28798
28861
|
var util_exports2 = {};
|
|
28799
|
-
|
|
28862
|
+
chunkQ7SFCCGT_cjs.__export(util_exports2, {
|
|
28800
28863
|
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES2,
|
|
28801
28864
|
Class: () => Class2,
|
|
28802
28865
|
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES2,
|
|
@@ -29512,7 +29575,7 @@ var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync2($ZodRealError2);
|
|
|
29512
29575
|
|
|
29513
29576
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/core/regexes.js
|
|
29514
29577
|
var regexes_exports2 = {};
|
|
29515
|
-
|
|
29578
|
+
chunkQ7SFCCGT_cjs.__export(regexes_exports2, {
|
|
29516
29579
|
_emoji: () => _emoji3,
|
|
29517
29580
|
base64: () => base643,
|
|
29518
29581
|
base64url: () => base64url3,
|
|
@@ -31833,7 +31896,7 @@ function handleRefineResult2(result, payload, input, inst) {
|
|
|
31833
31896
|
|
|
31834
31897
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/locales/index.js
|
|
31835
31898
|
var locales_exports2 = {};
|
|
31836
|
-
|
|
31899
|
+
chunkQ7SFCCGT_cjs.__export(locales_exports2, {
|
|
31837
31900
|
ar: () => ar_default2,
|
|
31838
31901
|
az: () => az_default2,
|
|
31839
31902
|
be: () => be_default2,
|
|
@@ -38338,7 +38401,7 @@ var json_schema_exports2 = {};
|
|
|
38338
38401
|
|
|
38339
38402
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/classic/iso.js
|
|
38340
38403
|
var iso_exports2 = {};
|
|
38341
|
-
|
|
38404
|
+
chunkQ7SFCCGT_cjs.__export(iso_exports2, {
|
|
38342
38405
|
ZodISODate: () => ZodISODate2,
|
|
38343
38406
|
ZodISODateTime: () => ZodISODateTime2,
|
|
38344
38407
|
ZodISODuration: () => ZodISODuration2,
|
|
@@ -39379,7 +39442,7 @@ function getErrorMap4() {
|
|
|
39379
39442
|
|
|
39380
39443
|
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/3.25.76/7137186c3790243b593612573154eb5e6c6084f41028ee5828258e8c91251cd6/node_modules/zod/v4/classic/coerce.js
|
|
39381
39444
|
var coerce_exports2 = {};
|
|
39382
|
-
|
|
39445
|
+
chunkQ7SFCCGT_cjs.__export(coerce_exports2, {
|
|
39383
39446
|
bigint: () => bigint6,
|
|
39384
39447
|
boolean: () => boolean6,
|
|
39385
39448
|
date: () => date8,
|
|
@@ -39611,9 +39674,9 @@ var ParseError2 = class extends Error {
|
|
|
39611
39674
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
39612
39675
|
}
|
|
39613
39676
|
};
|
|
39614
|
-
var
|
|
39615
|
-
var
|
|
39616
|
-
var
|
|
39677
|
+
var LF2 = 10;
|
|
39678
|
+
var CR2 = 13;
|
|
39679
|
+
var SPACE2 = 32;
|
|
39617
39680
|
function noop2(_arg) {
|
|
39618
39681
|
}
|
|
39619
39682
|
function createParser2(callbacks) {
|
|
@@ -39652,17 +39715,17 @@ function createParser2(callbacks) {
|
|
|
39652
39715
|
continue;
|
|
39653
39716
|
}
|
|
39654
39717
|
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
39655
|
-
if (
|
|
39656
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) ===
|
|
39657
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) ===
|
|
39718
|
+
if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
|
|
39719
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
39720
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
|
|
39658
39721
|
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
39659
39722
|
`, searchIndex);
|
|
39660
39723
|
continue;
|
|
39661
39724
|
}
|
|
39662
39725
|
data = dataLines === 0 ? value : `${data}
|
|
39663
39726
|
${value}`, dataLines++;
|
|
39664
|
-
} else
|
|
39665
|
-
chunk.charCodeAt(searchIndex + 6) ===
|
|
39727
|
+
} else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
39728
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
|
|
39666
39729
|
lfIndex
|
|
39667
39730
|
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
39668
39731
|
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
@@ -39676,7 +39739,7 @@ ${value}`, dataLines++;
|
|
|
39676
39739
|
let lineEnd = -1;
|
|
39677
39740
|
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)
|
|
39678
39741
|
break;
|
|
39679
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) ===
|
|
39742
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
|
|
39680
39743
|
}
|
|
39681
39744
|
return chunk.slice(searchIndex);
|
|
39682
39745
|
}
|
|
@@ -39686,25 +39749,25 @@ ${value}`, dataLines++;
|
|
|
39686
39749
|
return;
|
|
39687
39750
|
}
|
|
39688
39751
|
const firstCharCode = chunk.charCodeAt(start);
|
|
39689
|
-
if (
|
|
39690
|
-
const valueStart = chunk.charCodeAt(start + 5) ===
|
|
39752
|
+
if (isDataPrefix2(chunk, start, firstCharCode)) {
|
|
39753
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
39691
39754
|
data = dataLines === 0 ? value2 : `${data}
|
|
39692
39755
|
${value2}`, dataLines++;
|
|
39693
39756
|
return;
|
|
39694
39757
|
}
|
|
39695
|
-
if (
|
|
39696
|
-
eventType = chunk.slice(chunk.charCodeAt(start + 6) ===
|
|
39758
|
+
if (isEventPrefix2(chunk, start, firstCharCode)) {
|
|
39759
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
|
|
39697
39760
|
return;
|
|
39698
39761
|
}
|
|
39699
39762
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
39700
|
-
const value2 = chunk.slice(chunk.charCodeAt(start + 3) ===
|
|
39763
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
|
|
39701
39764
|
id = value2.includes("\0") ? void 0 : value2;
|
|
39702
39765
|
return;
|
|
39703
39766
|
}
|
|
39704
39767
|
if (firstCharCode === 58) {
|
|
39705
39768
|
if (onComment) {
|
|
39706
39769
|
const line2 = chunk.slice(start, end);
|
|
39707
|
-
onComment(line2.slice(chunk.charCodeAt(start + 1) ===
|
|
39770
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
|
|
39708
39771
|
}
|
|
39709
39772
|
return;
|
|
39710
39773
|
}
|
|
@@ -39713,7 +39776,7 @@ ${value2}`, dataLines++;
|
|
|
39713
39776
|
processField(line, "", line);
|
|
39714
39777
|
return;
|
|
39715
39778
|
}
|
|
39716
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) ===
|
|
39779
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
39717
39780
|
processField(field, value, line);
|
|
39718
39781
|
}
|
|
39719
39782
|
function processField(field, value, line) {
|
|
@@ -39763,10 +39826,10 @@ ${value}`, dataLines++;
|
|
|
39763
39826
|
}
|
|
39764
39827
|
return { feed, reset };
|
|
39765
39828
|
}
|
|
39766
|
-
function
|
|
39829
|
+
function isDataPrefix2(chunk, i, firstCharCode) {
|
|
39767
39830
|
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
39768
39831
|
}
|
|
39769
|
-
function
|
|
39832
|
+
function isEventPrefix2(chunk, i, firstCharCode) {
|
|
39770
39833
|
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;
|
|
39771
39834
|
}
|
|
39772
39835
|
var EventSourceParserStream2 = class extends TransformStream {
|
|
@@ -45971,7 +46034,7 @@ function formatTimestamp(date9) {
|
|
|
45971
46034
|
}
|
|
45972
46035
|
function truncateByTokens(text4, maxTokens, hint) {
|
|
45973
46036
|
if (tokenx.estimateTokenCount(text4) <= maxTokens) return { text: text4, wasTruncated: false };
|
|
45974
|
-
const truncated =
|
|
46037
|
+
const truncated = chunkPTCSCRB6_cjs.truncateStringByTokens(text4, maxTokens);
|
|
45975
46038
|
const suffix = hint ? ` [${hint} for more]` : "";
|
|
45976
46039
|
return { text: truncated + suffix, wasTruncated: true };
|
|
45977
46040
|
}
|
|
@@ -46023,11 +46086,11 @@ ${JSON.stringify(inv.args, null, 2)}`;
|
|
|
46023
46086
|
});
|
|
46024
46087
|
}
|
|
46025
46088
|
if (inv.state === "result") {
|
|
46026
|
-
const { value: resultValue } =
|
|
46089
|
+
const { value: resultValue } = chunkPTCSCRB6_cjs.resolveToolResultValue(
|
|
46027
46090
|
part,
|
|
46028
46091
|
inv.result
|
|
46029
46092
|
);
|
|
46030
|
-
const resultStr =
|
|
46093
|
+
const resultStr = chunkPTCSCRB6_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
46031
46094
|
const fullText = `[Tool Result: ${inv.toolName}]
|
|
46032
46095
|
${resultStr}`;
|
|
46033
46096
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
|
|
@@ -46054,7 +46117,7 @@ ${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
|
|
|
46054
46117
|
const toolName = part.toolName;
|
|
46055
46118
|
if (toolName) {
|
|
46056
46119
|
const rawResult = part.output ?? part.result;
|
|
46057
|
-
const resultStr =
|
|
46120
|
+
const resultStr = chunkPTCSCRB6_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
46058
46121
|
const fullText = `[Tool Result: ${toolName}]
|
|
46059
46122
|
${resultStr}`;
|
|
46060
46123
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
|
|
@@ -46133,7 +46196,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
46133
46196
|
const text4 = buildRenderedText(parts, timestamps);
|
|
46134
46197
|
let totalTokens = tokenx.estimateTokenCount(text4);
|
|
46135
46198
|
if (totalTokens > options.maxTokens) {
|
|
46136
|
-
const truncated =
|
|
46199
|
+
const truncated = chunkPTCSCRB6_cjs.truncateStringByTokens(text4, options.maxTokens);
|
|
46137
46200
|
return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
|
|
46138
46201
|
}
|
|
46139
46202
|
const truncatedIndices = parts.map((p, i) => ({ part: p, index: i })).filter(({ part }) => part.text !== part.fullText).sort((a, b) => expandPriority(a.part) - expandPriority(b.part));
|
|
@@ -46166,7 +46229,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
46166
46229
|
if (expandedTokens <= options.maxTokens) {
|
|
46167
46230
|
return { text: expanded, truncated: false, tokenOffset: 0 };
|
|
46168
46231
|
}
|
|
46169
|
-
const hardTruncated =
|
|
46232
|
+
const hardTruncated = chunkPTCSCRB6_cjs.truncateStringByTokens(expanded, options.maxTokens);
|
|
46170
46233
|
return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
|
|
46171
46234
|
}
|
|
46172
46235
|
async function recallPart({
|
|
@@ -46217,7 +46280,7 @@ async function recallPart({
|
|
|
46217
46280
|
|
|
46218
46281
|
`;
|
|
46219
46282
|
const fallbackText = `${fallbackNote}${firstNextPart.text}`;
|
|
46220
|
-
const truncatedText2 =
|
|
46283
|
+
const truncatedText2 = chunkPTCSCRB6_cjs.truncateStringByTokens(fallbackText, maxTokens);
|
|
46221
46284
|
const wasTruncated2 = truncatedText2 !== fallbackText;
|
|
46222
46285
|
return {
|
|
46223
46286
|
text: truncatedText2,
|
|
@@ -46232,7 +46295,7 @@ async function recallPart({
|
|
|
46232
46295
|
}
|
|
46233
46296
|
throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
|
|
46234
46297
|
}
|
|
46235
|
-
const truncatedText =
|
|
46298
|
+
const truncatedText = chunkPTCSCRB6_cjs.truncateStringByTokens(target.text, maxTokens);
|
|
46236
46299
|
const wasTruncated = truncatedText !== target.text;
|
|
46237
46300
|
return {
|
|
46238
46301
|
text: truncatedText,
|
|
@@ -46738,6 +46801,8 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
46738
46801
|
}
|
|
46739
46802
|
});
|
|
46740
46803
|
};
|
|
46804
|
+
var UPDATE_WORKING_MEMORY_TOOL_NAME = "updateWorkingMemory";
|
|
46805
|
+
var SET_WORKING_MEMORY_TOOL_NAME = "setWorkingMemory";
|
|
46741
46806
|
function deepMergeWorkingMemory(existing, update) {
|
|
46742
46807
|
if (!update || typeof update !== "object" || Object.keys(update).length === 0) {
|
|
46743
46808
|
return existing && typeof existing === "object" ? { ...existing } : {};
|
|
@@ -46829,7 +46894,9 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
46829
46894
|
};
|
|
46830
46895
|
}
|
|
46831
46896
|
const usesMergeSemantics = Boolean(schema$2);
|
|
46832
|
-
const
|
|
46897
|
+
const useStateSignals = memoryConfig?.workingMemory?.useStateSignals === true;
|
|
46898
|
+
const stateSignalsPreamble = `The current working memory state is delivered to you each turn by the system inside a <working-memory>...</working-memory> block. That block is system-emitted state, NOT something the user typed \u2014 never describe it as the user sharing it. Read from it directly when answering. Only call this tool when the user provides genuinely NEW or CHANGED facts that should be persisted; do NOT call it to re-save unchanged data.`;
|
|
46899
|
+
const description = schema$2 ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory \u2014 only include fields you want to add or update.` : `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : useStateSignals ? `${stateSignalsPreamble} Pass the full updated Markdown blob as a string in the memory field.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`;
|
|
46833
46900
|
return tools.createTool({
|
|
46834
46901
|
id: "update-working-memory",
|
|
46835
46902
|
description,
|
|
@@ -47008,6 +47075,12 @@ var __experimental_updateWorkingMemoryToolVNext = (config3) => {
|
|
|
47008
47075
|
}
|
|
47009
47076
|
});
|
|
47010
47077
|
};
|
|
47078
|
+
function createWorkingMemoryTool(config3, options = {}) {
|
|
47079
|
+
const useStateSignals = config3.workingMemory?.useStateSignals === true;
|
|
47080
|
+
const tool3 = options.vNext ? __experimental_updateWorkingMemoryToolVNext(config3) : updateWorkingMemoryTool(config3);
|
|
47081
|
+
const name21 = useStateSignals ? SET_WORKING_MEMORY_TOOL_NAME : UPDATE_WORKING_MEMORY_TOOL_NAME;
|
|
47082
|
+
return { name: name21, tool: tool3 };
|
|
47083
|
+
}
|
|
47011
47084
|
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
47012
47085
|
var WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
47013
47086
|
var LEGACY_SYSTEM_REMINDER_METADATA_KEY = "dynamicAgentsMdReminder";
|
|
@@ -47125,6 +47198,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
47125
47198
|
},
|
|
47126
47199
|
observationalMemory: config3.options?.observationalMemory
|
|
47127
47200
|
});
|
|
47201
|
+
this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
|
|
47128
47202
|
this.threadConfig = mergedConfig;
|
|
47129
47203
|
const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
|
|
47130
47204
|
if (omConfig?.retrieval && typeof omConfig.retrieval === "object" && omConfig.retrieval.vector) {
|
|
@@ -47492,6 +47566,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
47492
47566
|
memoryConfig
|
|
47493
47567
|
}) {
|
|
47494
47568
|
const config3 = this.getMergedThreadConfig(memoryConfig || {});
|
|
47569
|
+
this.assertWorkingMemoryStateSignalsCompatibility(config3);
|
|
47495
47570
|
if (!config3.workingMemory?.enabled) {
|
|
47496
47571
|
throw new Error("Working memory is not enabled for this memory instance");
|
|
47497
47572
|
}
|
|
@@ -47871,9 +47946,13 @@ ${workingMemory}`;
|
|
|
47871
47946
|
memoryConfig
|
|
47872
47947
|
}) {
|
|
47873
47948
|
const config3 = this.getMergedThreadConfig(memoryConfig);
|
|
47949
|
+
this.assertWorkingMemoryStateSignalsCompatibility(config3);
|
|
47874
47950
|
if (!config3.workingMemory?.enabled) {
|
|
47875
47951
|
return null;
|
|
47876
47952
|
}
|
|
47953
|
+
if (config3.workingMemory?.useStateSignals) {
|
|
47954
|
+
return null;
|
|
47955
|
+
}
|
|
47877
47956
|
const workingMemoryTemplate = await this.getWorkingMemoryTemplate({ memoryConfig });
|
|
47878
47957
|
const workingMemoryData = await this.getWorkingMemory({ threadId, resourceId, memoryConfig: config3 });
|
|
47879
47958
|
if (!workingMemoryTemplate) {
|
|
@@ -47935,7 +48014,7 @@ ${workingMemory}`;
|
|
|
47935
48014
|
if (obsSystemMessage) {
|
|
47936
48015
|
systemParts.push(obsSystemMessage);
|
|
47937
48016
|
}
|
|
47938
|
-
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-
|
|
48017
|
+
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-JS5SS7GS.cjs');
|
|
47939
48018
|
continuationMessage = {
|
|
47940
48019
|
id: "om-continuation",
|
|
47941
48020
|
role: "user",
|
|
@@ -48037,7 +48116,7 @@ ${workingMemory}`;
|
|
|
48037
48116
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
48038
48117
|
);
|
|
48039
48118
|
}
|
|
48040
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
48119
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-SZF7GKTS.cjs');
|
|
48041
48120
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
48042
48121
|
await this.indexObservation(observation);
|
|
48043
48122
|
} : void 0;
|
|
@@ -48188,6 +48267,13 @@ Notes:
|
|
|
48188
48267
|
const isMDWorkingMemory = !(`schema` in config3.workingMemory) && (typeof config3.workingMemory.template === `string` || config3.workingMemory.template) && config3.workingMemory;
|
|
48189
48268
|
return Boolean(isMDWorkingMemory && isMDWorkingMemory.version === `vnext`);
|
|
48190
48269
|
}
|
|
48270
|
+
assertWorkingMemoryStateSignalsCompatibility(config3) {
|
|
48271
|
+
if (config3?.workingMemory?.useStateSignals === true && this.isVNextWorkingMemoryConfig(config3)) {
|
|
48272
|
+
throw new Error(
|
|
48273
|
+
"workingMemory.useStateSignals is not supported with workingMemory.version: 'vnext'. Use stable template working memory or disable useStateSignals."
|
|
48274
|
+
);
|
|
48275
|
+
}
|
|
48276
|
+
}
|
|
48191
48277
|
getObservationEmbeddingIndexName(dimensions) {
|
|
48192
48278
|
const defaultDimensions = 384;
|
|
48193
48279
|
const usedDimensions = dimensions ?? defaultDimensions;
|
|
@@ -48389,9 +48475,13 @@ Notes:
|
|
|
48389
48475
|
}
|
|
48390
48476
|
listTools(config3) {
|
|
48391
48477
|
const mergedConfig = this.getMergedThreadConfig(config3);
|
|
48478
|
+
this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
|
|
48392
48479
|
const tools = {};
|
|
48393
48480
|
if (mergedConfig.workingMemory?.enabled && !mergedConfig.readOnly) {
|
|
48394
|
-
|
|
48481
|
+
const { name: name21, tool: tool3 } = createWorkingMemoryTool(mergedConfig, {
|
|
48482
|
+
vNext: this.isVNextWorkingMemoryConfig(mergedConfig)
|
|
48483
|
+
});
|
|
48484
|
+
tools[name21] = tool3;
|
|
48395
48485
|
}
|
|
48396
48486
|
const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
|
|
48397
48487
|
if (omConfig?.retrieval) {
|
|
@@ -48937,6 +49027,10 @@ Notes:
|
|
|
48937
49027
|
if (om) {
|
|
48938
49028
|
processors.push(om);
|
|
48939
49029
|
}
|
|
49030
|
+
const wm = await this.createWorkingMemoryStateProcessor(configuredProcessors, context2);
|
|
49031
|
+
if (wm) {
|
|
49032
|
+
processors.push(wm);
|
|
49033
|
+
}
|
|
48940
49034
|
return processors;
|
|
48941
49035
|
}
|
|
48942
49036
|
/**
|
|
@@ -48974,20 +49068,50 @@ Notes:
|
|
|
48974
49068
|
if (!effectiveConfig) return null;
|
|
48975
49069
|
const engine = await this.omEngine;
|
|
48976
49070
|
if (!engine) return null;
|
|
48977
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
49071
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-SZF7GKTS.cjs');
|
|
48978
49072
|
return new ObservationalMemoryProcessor(engine, this, {
|
|
48979
49073
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
48980
49074
|
});
|
|
48981
49075
|
}
|
|
49076
|
+
/**
|
|
49077
|
+
* Creates a WorkingMemoryStateProcessor when working memory is enabled and the
|
|
49078
|
+
* `useStateSignals` opt-in is set. Returns null otherwise or if the processor
|
|
49079
|
+
* is already present in the user's configured processors.
|
|
49080
|
+
*/
|
|
49081
|
+
async createWorkingMemoryStateProcessor(configuredProcessors = [], context2) {
|
|
49082
|
+
const runtimeMemory = context2?.get("MastraMemory");
|
|
49083
|
+
const mergedConfig = this.getMergedThreadConfig(runtimeMemory?.memoryConfig);
|
|
49084
|
+
this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
|
|
49085
|
+
if (!mergedConfig.workingMemory?.enabled) return null;
|
|
49086
|
+
if (!mergedConfig.workingMemory?.useStateSignals) return null;
|
|
49087
|
+
const { WORKING_MEMORY_STATE_PROCESSOR_ID: WORKING_MEMORY_STATE_PROCESSOR_ID2, WorkingMemoryStateProcessor: WorkingMemoryStateProcessor2 } = await import('./working-memory-state-Y2SCKCNU.cjs');
|
|
49088
|
+
const alreadyConfigured = configuredProcessors.some(
|
|
49089
|
+
(p) => !("workflow" in p) && p.id === WORKING_MEMORY_STATE_PROCESSOR_ID2
|
|
49090
|
+
);
|
|
49091
|
+
if (alreadyConfigured) return null;
|
|
49092
|
+
return new WorkingMemoryStateProcessor2(this, runtimeMemory?.memoryConfig);
|
|
49093
|
+
}
|
|
48982
49094
|
};
|
|
48983
49095
|
|
|
48984
49096
|
Object.defineProperty(exports, "ModelByInputTokens", {
|
|
48985
49097
|
enumerable: true,
|
|
48986
|
-
get: function () { return
|
|
49098
|
+
get: function () { return chunkPTCSCRB6_cjs.ModelByInputTokens; }
|
|
48987
49099
|
});
|
|
48988
49100
|
Object.defineProperty(exports, "getObservationsAsOf", {
|
|
48989
49101
|
enumerable: true,
|
|
48990
|
-
get: function () { return
|
|
49102
|
+
get: function () { return chunkPTCSCRB6_cjs.getObservationsAsOf; }
|
|
49103
|
+
});
|
|
49104
|
+
Object.defineProperty(exports, "WORKING_MEMORY_STATE_ID", {
|
|
49105
|
+
enumerable: true,
|
|
49106
|
+
get: function () { return chunk43FJOLKM_cjs.WORKING_MEMORY_STATE_ID; }
|
|
49107
|
+
});
|
|
49108
|
+
Object.defineProperty(exports, "WORKING_MEMORY_STATE_PROCESSOR_ID", {
|
|
49109
|
+
enumerable: true,
|
|
49110
|
+
get: function () { return chunk43FJOLKM_cjs.WORKING_MEMORY_STATE_PROCESSOR_ID; }
|
|
49111
|
+
});
|
|
49112
|
+
Object.defineProperty(exports, "WorkingMemoryStateProcessor", {
|
|
49113
|
+
enumerable: true,
|
|
49114
|
+
get: function () { return chunk43FJOLKM_cjs.WorkingMemoryStateProcessor; }
|
|
48991
49115
|
});
|
|
48992
49116
|
Object.defineProperty(exports, "MessageHistory", {
|
|
48993
49117
|
enumerable: true,
|