@mastra/memory 1.15.1-alpha.0 → 1.15.1-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 +8 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-memory-processors.md +3 -3
- package/dist/docs/references/docs-memory-message-history.md +2 -2
- package/dist/docs/references/docs-memory-observational-memory.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/index.cjs +55 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/working-memory.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -16431,6 +16431,25 @@ function deepMergeWorkingMemory(existing, update) {
|
|
|
16431
16431
|
}
|
|
16432
16432
|
return result;
|
|
16433
16433
|
}
|
|
16434
|
+
function stripNullsFromOptional(value, schema) {
|
|
16435
|
+
if (Array.isArray(value)) {
|
|
16436
|
+
const itemSchema = schema.items ?? {};
|
|
16437
|
+
return value.map((item) => stripNullsFromOptional(item, itemSchema));
|
|
16438
|
+
}
|
|
16439
|
+
if (typeof value === "object" && value !== null) {
|
|
16440
|
+
const properties = schema.properties ?? {};
|
|
16441
|
+
const required = schema.required ?? [];
|
|
16442
|
+
const result = {};
|
|
16443
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
16444
|
+
if (propertyValue === null && !required.includes(key)) {
|
|
16445
|
+
continue;
|
|
16446
|
+
}
|
|
16447
|
+
result[key] = stripNullsFromOptional(propertyValue, properties[key] ?? {});
|
|
16448
|
+
}
|
|
16449
|
+
return result;
|
|
16450
|
+
}
|
|
16451
|
+
return value;
|
|
16452
|
+
}
|
|
16434
16453
|
var updateWorkingMemoryTool = (memoryConfig) => {
|
|
16435
16454
|
const schema = memoryConfig?.workingMemory?.schema;
|
|
16436
16455
|
let inputSchema = z.object({
|
|
@@ -16440,7 +16459,7 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
16440
16459
|
const standardSchema2 = isStandardSchemaWithJSON$1(schema) ? schema : toStandardSchema$1(schema);
|
|
16441
16460
|
const jsonSchema4 = standardSchemaToJSONSchema(standardSchema2, { io: "input" });
|
|
16442
16461
|
delete jsonSchema4.$schema;
|
|
16443
|
-
|
|
16462
|
+
const wrappedSchema = toStandardSchema$1({
|
|
16444
16463
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
16445
16464
|
type: "object",
|
|
16446
16465
|
description: "The JSON formatted working memory content to store.",
|
|
@@ -16449,6 +16468,41 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
16449
16468
|
},
|
|
16450
16469
|
required: ["memory"]
|
|
16451
16470
|
});
|
|
16471
|
+
inputSchema = {
|
|
16472
|
+
"~standard": {
|
|
16473
|
+
version: 1,
|
|
16474
|
+
vendor: "mastra",
|
|
16475
|
+
validate: (value) => {
|
|
16476
|
+
const wrappedResult = wrappedSchema["~standard"].validate(value);
|
|
16477
|
+
if (wrappedResult instanceof Promise) {
|
|
16478
|
+
return wrappedResult.then((result) => {
|
|
16479
|
+
if (!("issues" in result) || !result.issues) {
|
|
16480
|
+
return result;
|
|
16481
|
+
}
|
|
16482
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || "memory" in value) {
|
|
16483
|
+
return result;
|
|
16484
|
+
}
|
|
16485
|
+
return wrappedSchema["~standard"].validate({
|
|
16486
|
+
memory: stripNullsFromOptional(value, jsonSchema4)
|
|
16487
|
+
});
|
|
16488
|
+
});
|
|
16489
|
+
}
|
|
16490
|
+
if (!("issues" in wrappedResult) || !wrappedResult.issues) {
|
|
16491
|
+
return wrappedResult;
|
|
16492
|
+
}
|
|
16493
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || "memory" in value) {
|
|
16494
|
+
return wrappedResult;
|
|
16495
|
+
}
|
|
16496
|
+
return wrappedSchema["~standard"].validate({
|
|
16497
|
+
memory: stripNullsFromOptional(value, jsonSchema4)
|
|
16498
|
+
});
|
|
16499
|
+
},
|
|
16500
|
+
jsonSchema: {
|
|
16501
|
+
input: (props) => wrappedSchema["~standard"].jsonSchema.input(props),
|
|
16502
|
+
output: (props) => wrappedSchema["~standard"].jsonSchema.output(props)
|
|
16503
|
+
}
|
|
16504
|
+
}
|
|
16505
|
+
};
|
|
16452
16506
|
}
|
|
16453
16507
|
const usesMergeSemantics = Boolean(schema);
|
|
16454
16508
|
const description = schema ? `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.` : `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.`;
|