@mastra/memory 1.28.1-alpha.0 → 1.28.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 +22 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/subconscious/capture.d.ts.map +1 -1
- package/dist/processors/observational-memory/subconscious/curate.d.ts.map +1 -1
- package/dist/processors/observational-memory/subconscious/knowledge-write-tools.d.ts.map +1 -1
- package/dist/processors/observational-memory/subconscious/semantic-index.d.ts.map +1 -1
- package/dist/{src-BsEVZAdq.js → src-BNtoxIHL.js} +52 -7
- package/dist/src-BNtoxIHL.js.map +1 -0
- package/dist/{src-BWo0fcaP.cjs → src-Br56ncef.cjs} +51 -6
- package/dist/src-Br56ncef.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/src-BWo0fcaP.cjs.map +0 -1
- package/dist/src-BsEVZAdq.js.map +0 -1
|
@@ -227,7 +227,7 @@ let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
|
227
227
|
return (size = defaultSize) => {
|
|
228
228
|
let id = "";
|
|
229
229
|
let i = size | 0;
|
|
230
|
-
while (i--) id += alphabet[Math.random() * alphabet.length | 0];
|
|
230
|
+
while (i-- > 0) id += alphabet[Math.random() * alphabet.length | 0];
|
|
231
231
|
return id;
|
|
232
232
|
};
|
|
233
233
|
};
|
|
@@ -3734,7 +3734,7 @@ function trimStartOfStream() {
|
|
|
3734
3734
|
};
|
|
3735
3735
|
}
|
|
3736
3736
|
//#endregion
|
|
3737
|
-
//#region ../_vendored/ai_v5/dist/dist-
|
|
3737
|
+
//#region ../_vendored/ai_v5/dist/dist-Dqv4QeJJ.js
|
|
3738
3738
|
var marker$1$4 = "vercel.ai.error";
|
|
3739
3739
|
var symbol$1$3 = Symbol.for(marker$1$4);
|
|
3740
3740
|
var _a$1$3;
|
|
@@ -8623,7 +8623,7 @@ var object$1 = ({ schema: inputSchema }) => {
|
|
|
8623
8623
|
};
|
|
8624
8624
|
};
|
|
8625
8625
|
//#endregion
|
|
8626
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
8626
|
+
//#region ../_vendored/ai_v6/dist/dist-Cx98_f-i.js
|
|
8627
8627
|
var marker$1 = "vercel.ai.error";
|
|
8628
8628
|
var symbol$1$1 = Symbol.for(marker$1);
|
|
8629
8629
|
var _a$1$1;
|
|
@@ -10776,7 +10776,7 @@ function withoutTrailingSlash(url) {
|
|
|
10776
10776
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
10777
10777
|
}
|
|
10778
10778
|
//#endregion
|
|
10779
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
10779
|
+
//#region ../_vendored/ai_v6/dist/dist-pa8X6y1Z.js
|
|
10780
10780
|
function getContext() {
|
|
10781
10781
|
return { headers: {} };
|
|
10782
10782
|
}
|
|
@@ -15294,6 +15294,7 @@ Return nodes with short stable names, a freeform kind, and knowledge records nes
|
|
|
15294
15294
|
Use common kinds such as person, task, event, project, organization, or document when they fit.
|
|
15295
15295
|
Set node scope to the narrowest level where that identity and content should be shared. Omit it to use the configured default scope.
|
|
15296
15296
|
Knowledge records must be grounded in the conversation, concise, and written as prose. Do not infer unstated information.
|
|
15297
|
+
When the conversation states a canonical identifier or URL for an entity, preserve it verbatim in the record text.
|
|
15297
15298
|
Wrap every named node mentioned in record text in [[wikilinks]].
|
|
15298
15299
|
Set a record scope only when the conversation establishes where it applies. Use org for organization-wide records, resource for records shared across this resource's conversations, and thread for conversation-private records.
|
|
15299
15300
|
Omit scope when uncertain; omitted record scopes stay private to the current thread.
|
|
@@ -16269,6 +16270,48 @@ function createKnowledgeWriteTools(memory, options) {
|
|
|
16269
16270
|
});
|
|
16270
16271
|
}
|
|
16271
16272
|
}),
|
|
16273
|
+
knowledge_write_node_description: (0, _mastra_core_tools.createTool)({
|
|
16274
|
+
id: "knowledge_write_node_description",
|
|
16275
|
+
description: `Write the bounded synopsis (max ${_mastra_core_storage.MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH} UTF-16 code units) on an existing visible node using optimistic concurrency. Pass an empty string to clear it. Does not create nodes.`,
|
|
16276
|
+
inputSchema: {
|
|
16277
|
+
type: "object",
|
|
16278
|
+
properties: {
|
|
16279
|
+
node: {
|
|
16280
|
+
type: "string",
|
|
16281
|
+
minLength: 1
|
|
16282
|
+
},
|
|
16283
|
+
expectedVersion: {
|
|
16284
|
+
type: "integer",
|
|
16285
|
+
minimum: 1
|
|
16286
|
+
},
|
|
16287
|
+
description: {
|
|
16288
|
+
type: "string",
|
|
16289
|
+
minLength: 0,
|
|
16290
|
+
maxLength: _mastra_core_storage.MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH,
|
|
16291
|
+
description: `One or two plain-text sentences describing the node, targeting 40-75 tokens. Hard limit ${_mastra_core_storage.MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH} UTF-16 code units, enforced by storage on every write; the length check on execution is authoritative. Long-form detail belongs in node content, not here. An empty string clears the description.`
|
|
16292
|
+
}
|
|
16293
|
+
},
|
|
16294
|
+
required: [
|
|
16295
|
+
"node",
|
|
16296
|
+
"expectedVersion",
|
|
16297
|
+
"description"
|
|
16298
|
+
],
|
|
16299
|
+
additionalProperties: false
|
|
16300
|
+
},
|
|
16301
|
+
execute: async (input) => {
|
|
16302
|
+
const value = input;
|
|
16303
|
+
if (value.description.length > _mastra_core_storage.MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH) throw new Error(`Node descriptions are limited to ${_mastra_core_storage.MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH} UTF-16 code units. Shorten the description and retry.`);
|
|
16304
|
+
const store = await getStore(memory);
|
|
16305
|
+
const node = await store.getNode(value.node);
|
|
16306
|
+
if (!node || node.mergedInto) throw new Error(`Knowledge node not found: ${value.node}`);
|
|
16307
|
+
requireVisible(node.scope, options, "Knowledge node");
|
|
16308
|
+
return store.updateNode({
|
|
16309
|
+
id: node.id,
|
|
16310
|
+
version: value.expectedVersion,
|
|
16311
|
+
description: value.description
|
|
16312
|
+
});
|
|
16313
|
+
}
|
|
16314
|
+
}),
|
|
16272
16315
|
knowledge_write_node_content: (0, _mastra_core_tools.createTool)({
|
|
16273
16316
|
id: "knowledge_write_node_content",
|
|
16274
16317
|
description: "Create or replace long-form content on a scoped knowledge node. Existing nodes require expectedVersion.",
|
|
@@ -16477,7 +16520,7 @@ var KnowledgeSemanticIndexCoordinator = class {
|
|
|
16477
16520
|
const node = await this.#knowledge.getNode(entry.documentId.slice(15));
|
|
16478
16521
|
if (!node || node.mergedInto) return null;
|
|
16479
16522
|
return {
|
|
16480
|
-
text: `${node.name}\n${node.content ?? ""}`,
|
|
16523
|
+
text: node.description ? `${node.name}\n${node.description}\n${node.content ?? ""}` : `${node.name}\n${node.content ?? ""}`,
|
|
16481
16524
|
name: node.name,
|
|
16482
16525
|
scope: node.scope,
|
|
16483
16526
|
recordId: node.id,
|
|
@@ -16703,6 +16746,8 @@ const DEFAULT_INSTRUCTIONS$1 = `Maintain durable scoped knowledge from the commi
|
|
|
16703
16746
|
|
|
16704
16747
|
Use the read tools to inspect existing nodes, knowledge records, mentions, backlinks, and long-form node content. Use the write tools to merge true duplicates, repair names and links, soft-delete superseded knowledge records, rescope knowledge records only when justified and permitted by their ceilings, and synthesize useful node content. Never restore deleted knowledge records. Never invent provenance, capture timestamps, scopes, ceilings, IDs, or versions; those are enforced by code. Resolve optimistic-concurrency conflicts by reading the latest record and retrying the intended mutation. Keep the reserved capture-guidance node concise and update it only with durable guidance that will improve future capture.
|
|
16705
16748
|
|
|
16749
|
+
For each significant entity node touched by a KnowledgeRecord in the current worklist, including people, projects, pull requests, issues, repositories, documents, and organizations, maintain a short entity description; do not walk nodes outside the worklist for this. Use the supplied record and read the named node once; do not search or browse unless its identity is ambiguous. Describe what the entity is, its current state, and links to its real-world object, then write it with knowledge_write_node_description, which always requires expectedVersion from the node you just read; after a version conflict, re-read the node and regenerate the description from its current state before retrying. If the node does not exist yet, create it first with knowledge_write_node_content, then re-read it for its fresh version before writing the description. Write one or two plain-text sentences, roughly 40 to 75 tokens; storage rejects any description over its hard length cap, so keep them tight and put long-form detail in node content instead. Include links only from the entity's own records or observations that explicitly associate the link with that entity; never invent a URL, identifier, file path, or provenance. Leave long-form node content alone unless you are synthesizing it deliberately; never shrink content into a synopsis. For entity-description maintenance only, skip low-signal nodes with only a trivial record, any system-kind node, and the reserved capture-guidance node.
|
|
16750
|
+
|
|
16706
16751
|
Process the worklist in ID order. Every time you finish processing a KnowledgeRecord, include <curation-complete through="RECORD_ID" /> in your next text response with that record's ID. The latest marker is your acknowledged cursor, so progress survives if you run out of steps mid-batch. Your final response must end with the marker for the last KnowledgeRecord you fully processed. If you cannot finish the batch, acknowledge only the last KnowledgeRecord you did finish. Do not emit a completion marker when no KnowledgeRecord was fully processed.`;
|
|
16707
16752
|
const PINNED_INSTRUCTIONS = `Maintain the pin set with knowledge_pin, knowledge_edit_pin, and knowledge_unpin. Pinned entries are delivered to the main agent on every turn, so they cost tokens permanently and must stay short. Pin only knowledge that should apply without being asked for, such as standing instructions, durable preferences, and hard constraints. Pin only knowledge that is BOTH costly to rediscover AND not the kind of thing a future agent would think to search for; anything a reminder can surface on demand does not belong in the pin set. Unpin an entry as soon as it stops being unconditionally true.`;
|
|
16708
16753
|
function resolveScope$1(context) {
|
|
@@ -31824,4 +31869,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
|
|
|
31824
31869
|
}
|
|
31825
31870
|
});
|
|
31826
31871
|
|
|
31827
|
-
//# sourceMappingURL=src-
|
|
31872
|
+
//# sourceMappingURL=src-Br56ncef.cjs.map
|