@mastra/memory 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/{chunk-GBBQIJQF.js → chunk-3CM4XQJO.js} +1940 -463
- package/dist/chunk-3CM4XQJO.js.map +1 -0
- package/dist/{chunk-D6II7EP4.cjs → chunk-5W5463NI.cjs} +1939 -461
- package/dist/chunk-5W5463NI.cjs.map +1 -0
- package/dist/docs/SKILL.md +24 -24
- package/dist/docs/assets/SOURCE_MAP.json +25 -25
- package/dist/docs/references/docs-agents-agent-approval.md +3 -3
- package/dist/docs/references/docs-agents-agent-memory.md +3 -3
- package/dist/docs/references/docs-agents-network-approval.md +5 -2
- package/dist/docs/references/docs-agents-networks.md +2 -2
- package/dist/docs/references/docs-agents-supervisor-agents.md +3 -3
- package/dist/docs/references/docs-memory-memory-processors.md +9 -9
- package/dist/docs/references/docs-memory-message-history.md +4 -4
- package/dist/docs/references/docs-memory-observational-memory.md +11 -7
- package/dist/docs/references/docs-memory-semantic-recall.md +9 -9
- package/dist/docs/references/docs-memory-storage.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +20 -20
- package/dist/docs/references/reference-core-getMemory.md +1 -1
- package/dist/docs/references/reference-core-listMemory.md +1 -1
- package/dist/docs/references/reference-memory-clone-utilities.md +7 -7
- package/dist/docs/references/reference-memory-cloneThread.md +5 -5
- package/dist/docs/references/reference-memory-createThread.md +1 -1
- package/dist/docs/references/reference-memory-getThreadById.md +1 -1
- package/dist/docs/references/reference-memory-listThreads.md +3 -3
- package/dist/docs/references/reference-memory-memory-class.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +8 -6
- package/dist/docs/references/reference-processors-token-limiter-processor.md +2 -2
- package/dist/docs/references/reference-storage-dynamodb.md +7 -7
- package/dist/docs/references/reference-storage-libsql.md +1 -1
- package/dist/docs/references/reference-storage-mongodb.md +6 -6
- package/dist/docs/references/reference-storage-postgresql.md +7 -7
- package/dist/docs/references/reference-storage-upstash.md +4 -4
- package/dist/docs/references/reference-vectors-libsql.md +15 -15
- package/dist/docs/references/reference-vectors-mongodb.md +18 -18
- package/dist/docs/references/reference-vectors-pg.md +23 -21
- package/dist/docs/references/reference-vectors-upstash.md +15 -15
- package/dist/index.cjs +48 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -21
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-AHVELJX4.cjs → observational-memory-C5LO7RBR.cjs} +17 -17
- package/dist/{observational-memory-AHVELJX4.cjs.map → observational-memory-C5LO7RBR.cjs.map} +1 -1
- package/dist/{observational-memory-QFQUF5EY.js → observational-memory-OYK4MEUD.js} +3 -3
- package/dist/{observational-memory-QFQUF5EY.js.map → observational-memory-OYK4MEUD.js.map} +1 -1
- package/dist/processors/index.cjs +15 -15
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +33 -2
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +7 -4
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/repro-capture.d.ts +23 -0
- package/dist/processors/observational-memory/repro-capture.d.ts.map +1 -0
- package/dist/processors/observational-memory/token-counter.d.ts +28 -3
- package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
- package/dist/tools/working-memory.d.ts +6 -10
- package/dist/tools/working-memory.d.ts.map +1 -1
- package/package.json +16 -11
- package/dist/chunk-D6II7EP4.cjs.map +0 -1
- package/dist/chunk-GBBQIJQF.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { embedMany } from './_types/@internal_ai-sdk-v4/dist/index.js';
|
|
2
2
|
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
3
3
|
import { MastraMemory } from '@mastra/core/memory';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MemoryConfigInternal, SharedMemoryConfig, StorageThreadType, WorkingMemoryTemplate, MessageDeleteInput, MemoryConfig } from '@mastra/core/memory';
|
|
5
5
|
import type { InputProcessor, InputProcessorOrWorkflow, OutputProcessor, OutputProcessorOrWorkflow } from '@mastra/core/processors';
|
|
6
6
|
import type { RequestContext } from '@mastra/core/request-context';
|
|
7
7
|
import type { StorageListThreadsInput, StorageListThreadsOutput, StorageListMessagesInput, MemoryStorage, StorageCloneThreadInput, StorageCloneThreadOutput, ThreadCloneMetadata } from '@mastra/core/storage';
|
|
@@ -14,7 +14,7 @@ export { extractWorkingMemoryTags, extractWorkingMemoryContent, removeWorkingMem
|
|
|
14
14
|
* and message injection.
|
|
15
15
|
*/
|
|
16
16
|
export declare class Memory extends MastraMemory {
|
|
17
|
-
constructor(config?: SharedMemoryConfig);
|
|
17
|
+
constructor(config?: Omit<SharedMemoryConfig, 'working'>);
|
|
18
18
|
/**
|
|
19
19
|
* Gets the memory storage domain, throwing if not available.
|
|
20
20
|
*/
|
|
@@ -48,9 +48,9 @@ export declare class Memory extends MastraMemory {
|
|
|
48
48
|
perPage: number | false;
|
|
49
49
|
hasMore: boolean;
|
|
50
50
|
}>;
|
|
51
|
-
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string, config:
|
|
51
|
+
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string, config: MemoryConfigInternal): Promise<void>;
|
|
52
52
|
recall(args: StorageListMessagesInput & {
|
|
53
|
-
threadConfig?:
|
|
53
|
+
threadConfig?: MemoryConfigInternal;
|
|
54
54
|
vectorSearchString?: string;
|
|
55
55
|
threadId: string;
|
|
56
56
|
}): Promise<{
|
|
@@ -70,13 +70,13 @@ export declare class Memory extends MastraMemory {
|
|
|
70
70
|
private handleWorkingMemoryFromMetadata;
|
|
71
71
|
saveThread({ thread, memoryConfig, }: {
|
|
72
72
|
thread: StorageThreadType;
|
|
73
|
-
memoryConfig?:
|
|
73
|
+
memoryConfig?: MemoryConfigInternal;
|
|
74
74
|
}): Promise<StorageThreadType>;
|
|
75
75
|
updateThread({ id, title, metadata, memoryConfig, }: {
|
|
76
76
|
id: string;
|
|
77
77
|
title: string;
|
|
78
78
|
metadata: Record<string, unknown>;
|
|
79
|
-
memoryConfig?:
|
|
79
|
+
memoryConfig?: MemoryConfigInternal;
|
|
80
80
|
}): Promise<StorageThreadType>;
|
|
81
81
|
deleteThread(threadId: string): Promise<void>;
|
|
82
82
|
/**
|
|
@@ -95,7 +95,7 @@ export declare class Memory extends MastraMemory {
|
|
|
95
95
|
threadId: string;
|
|
96
96
|
resourceId?: string;
|
|
97
97
|
workingMemory: string;
|
|
98
|
-
memoryConfig?:
|
|
98
|
+
memoryConfig?: MemoryConfigInternal;
|
|
99
99
|
}): Promise<void>;
|
|
100
100
|
private updateWorkingMemoryMutexes;
|
|
101
101
|
/**
|
|
@@ -106,7 +106,7 @@ export declare class Memory extends MastraMemory {
|
|
|
106
106
|
resourceId?: string;
|
|
107
107
|
workingMemory: string;
|
|
108
108
|
searchString?: string;
|
|
109
|
-
memoryConfig?:
|
|
109
|
+
memoryConfig?: MemoryConfigInternal;
|
|
110
110
|
}): Promise<{
|
|
111
111
|
success: boolean;
|
|
112
112
|
reason: string;
|
|
@@ -137,7 +137,7 @@ export declare class Memory extends MastraMemory {
|
|
|
137
137
|
getWorkingMemory({ threadId, resourceId, memoryConfig, }: {
|
|
138
138
|
threadId: string;
|
|
139
139
|
resourceId?: string;
|
|
140
|
-
memoryConfig?:
|
|
140
|
+
memoryConfig?: MemoryConfigInternal;
|
|
141
141
|
}): Promise<string | null>;
|
|
142
142
|
/**
|
|
143
143
|
* Gets the working memory template for the current memory configuration.
|
|
@@ -147,12 +147,12 @@ export declare class Memory extends MastraMemory {
|
|
|
147
147
|
* @returns The working memory template with format and content, or null if working memory is disabled
|
|
148
148
|
*/
|
|
149
149
|
getWorkingMemoryTemplate({ memoryConfig, }: {
|
|
150
|
-
memoryConfig?:
|
|
150
|
+
memoryConfig?: MemoryConfigInternal;
|
|
151
151
|
}): Promise<WorkingMemoryTemplate | null>;
|
|
152
152
|
getSystemMessage({ threadId, resourceId, memoryConfig, }: {
|
|
153
153
|
threadId: string;
|
|
154
154
|
resourceId?: string;
|
|
155
|
-
memoryConfig?:
|
|
155
|
+
memoryConfig?: MemoryConfigInternal;
|
|
156
156
|
}): Promise<string | null>;
|
|
157
157
|
defaultWorkingMemoryTemplate: string;
|
|
158
158
|
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
@@ -173,7 +173,7 @@ export declare class Memory extends MastraMemory {
|
|
|
173
173
|
data: string | null;
|
|
174
174
|
}): string;
|
|
175
175
|
private isVNextWorkingMemoryConfig;
|
|
176
|
-
listTools(config?:
|
|
176
|
+
listTools(config?: MemoryConfigInternal): Record<string, ToolAction<any, any, any>>;
|
|
177
177
|
/**
|
|
178
178
|
* Updates a list of messages and syncs the vector database for semantic recall.
|
|
179
179
|
* When message content is updated, the corresponding vector embeddings are also updated
|
|
@@ -187,7 +187,7 @@ export declare class Memory extends MastraMemory {
|
|
|
187
187
|
messages: (Partial<MastraDBMessage> & {
|
|
188
188
|
id: string;
|
|
189
189
|
})[];
|
|
190
|
-
memoryConfig?:
|
|
190
|
+
memoryConfig?: MemoryConfigInternal;
|
|
191
191
|
}): Promise<MastraDBMessage[]>;
|
|
192
192
|
/**
|
|
193
193
|
* Deletes one or more messages
|
|
@@ -257,7 +257,7 @@ export declare class Memory extends MastraMemory {
|
|
|
257
257
|
* });
|
|
258
258
|
* ```
|
|
259
259
|
*/
|
|
260
|
-
cloneThread(args: StorageCloneThreadInput, memoryConfig?:
|
|
260
|
+
cloneThread(args: StorageCloneThreadInput, memoryConfig?: MemoryConfigInternal): Promise<StorageCloneThreadOutput>;
|
|
261
261
|
/**
|
|
262
262
|
* Clone observational memory records when cloning a thread.
|
|
263
263
|
* Thread-scoped: always cloned to the new thread.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAwD,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAwD,MAAM,qBAAqB,CAAC;AACzG,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAElB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EAGpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD,OAAO,EAGL,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAiBhC,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AASrH;;;GAGG;AACH,qBAAa,MAAO,SAAQ,YAAY;gBAC1B,MAAM,GAAE,IAAI,CAAC,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mB5E;;;;;;;OAOG;IACG,kBAAkB,CACtB,oBAAoB,GAAE,wBAAwB,EAAO,EACrD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,EAAE,CAAC;IAY5B;;;;OAIG;IACG,mBAAmB,CACvB,oBAAoB,GAAE,yBAAyB,EAAO,EACtD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC;IAW7B;;;;OAIG;YACW,iBAAiB;CA+FhC;AAGD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGxF,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __commonJS, require_token_error, __toESM } from './chunk-BSDWQEU3.js';
|
|
2
2
|
import { __commonJS as __commonJS$1, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-RC6RZVYE.js';
|
|
3
3
|
import { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
4
|
-
import { z
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
import * as z4 from 'zod/v4';
|
|
6
6
|
import { z as z$1 } from 'zod/v4';
|
|
7
7
|
import { MessageList } from '@mastra/core/agent';
|
|
@@ -9,11 +9,11 @@ import { coreFeatures } from '@mastra/core/features';
|
|
|
9
9
|
import { MastraMemory, removeWorkingMemoryTags, extractWorkingMemoryContent } from '@mastra/core/memory';
|
|
10
10
|
export { extractWorkingMemoryContent, extractWorkingMemoryTags, removeWorkingMemoryTags } from '@mastra/core/memory';
|
|
11
11
|
import { generateEmptyFromSchema } from '@mastra/core/utils';
|
|
12
|
-
import {
|
|
12
|
+
import { isStandardSchemaWithJSON, toStandardSchema, standardSchemaToJSONSchema } from '@mastra/schema-compat/schema';
|
|
13
13
|
import { Mutex } from 'async-mutex';
|
|
14
14
|
import xxhash from 'xxhash-wasm';
|
|
15
|
+
import { isStandardSchemaWithJSON as isStandardSchemaWithJSON$1, toStandardSchema as toStandardSchema$1 } from '@mastra/core/schema';
|
|
15
16
|
import { createTool } from '@mastra/core/tools';
|
|
16
|
-
import { convertSchemaToZod } from '@mastra/schema-compat';
|
|
17
17
|
export { MessageHistory, SemanticRecall, WorkingMemory } from '@mastra/core/processors';
|
|
18
18
|
|
|
19
19
|
// ../_vendored/ai_v4/dist/chunk-OPIPXJLE.js
|
|
@@ -15129,10 +15129,17 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
15129
15129
|
memory: z.string().describe(`The Markdown formatted working memory content to store. This MUST be a string. Never pass an object.`)
|
|
15130
15130
|
});
|
|
15131
15131
|
if (schema) {
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15132
|
+
const standardSchema2 = isStandardSchemaWithJSON$1(schema) ? schema : toStandardSchema$1(schema);
|
|
15133
|
+
const jsonSchema4 = standardSchemaToJSONSchema(standardSchema2, { io: "input" });
|
|
15134
|
+
delete jsonSchema4.$schema;
|
|
15135
|
+
inputSchema = toStandardSchema$1({
|
|
15136
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
15137
|
+
type: "object",
|
|
15138
|
+
description: "The JSON formatted working memory content to store.",
|
|
15139
|
+
properties: {
|
|
15140
|
+
memory: jsonSchema4
|
|
15141
|
+
},
|
|
15142
|
+
required: ["memory"]
|
|
15136
15143
|
});
|
|
15137
15144
|
}
|
|
15138
15145
|
const usesMergeSemantics = Boolean(schema);
|
|
@@ -15183,26 +15190,28 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
15183
15190
|
existingData = null;
|
|
15184
15191
|
}
|
|
15185
15192
|
}
|
|
15186
|
-
|
|
15193
|
+
const memoryInput = inputData.memory;
|
|
15194
|
+
if (memoryInput === void 0 || memoryInput === null) {
|
|
15187
15195
|
return { success: true, message: "No memory data provided, existing memory unchanged." };
|
|
15188
15196
|
}
|
|
15189
15197
|
let newData;
|
|
15190
|
-
if (typeof
|
|
15198
|
+
if (typeof memoryInput === "string") {
|
|
15191
15199
|
try {
|
|
15192
|
-
newData = JSON.parse(
|
|
15200
|
+
newData = JSON.parse(memoryInput);
|
|
15193
15201
|
} catch (parseError) {
|
|
15194
15202
|
const errorMessage = parseError instanceof Error ? parseError.message : String(parseError);
|
|
15195
15203
|
throw new Error(
|
|
15196
|
-
`Failed to parse working memory input as JSON: ${errorMessage}. Raw input: ${
|
|
15204
|
+
`Failed to parse working memory input as JSON: ${errorMessage}. Raw input: ${memoryInput.length > 500 ? memoryInput.slice(0, 500) + "..." : memoryInput}`
|
|
15197
15205
|
);
|
|
15198
15206
|
}
|
|
15199
15207
|
} else {
|
|
15200
|
-
newData =
|
|
15208
|
+
newData = memoryInput;
|
|
15201
15209
|
}
|
|
15202
15210
|
const mergedData = deepMergeWorkingMemory(existingData, newData);
|
|
15203
15211
|
workingMemory = JSON.stringify(mergedData);
|
|
15204
15212
|
} else {
|
|
15205
|
-
|
|
15213
|
+
const memoryInput = inputData.memory;
|
|
15214
|
+
workingMemory = typeof memoryInput === "string" ? memoryInput : JSON.stringify(memoryInput);
|
|
15206
15215
|
const existingRaw = await memory.getWorkingMemory({
|
|
15207
15216
|
threadId,
|
|
15208
15217
|
resourceId,
|
|
@@ -15313,7 +15322,6 @@ var CHARS_PER_TOKEN = 4;
|
|
|
15313
15322
|
var DEFAULT_MESSAGE_RANGE = { before: 1, after: 1 };
|
|
15314
15323
|
var DEFAULT_TOP_K = 4;
|
|
15315
15324
|
var VECTOR_DELETE_BATCH_SIZE = 100;
|
|
15316
|
-
var isZodObject = (v) => v instanceof ZodObject;
|
|
15317
15325
|
var Memory = class extends MastraMemory {
|
|
15318
15326
|
constructor(config = {}) {
|
|
15319
15327
|
super({ name: "Memory", ...config });
|
|
@@ -15360,6 +15368,7 @@ var Memory = class extends MastraMemory {
|
|
|
15360
15368
|
const config = this.getMergedThreadConfig(threadConfig || {});
|
|
15361
15369
|
if (resourceId) await this.validateThreadIsOwnedByResource(threadId, resourceId, config);
|
|
15362
15370
|
const perPage = perPageArg !== void 0 ? perPageArg : config.lastMessages;
|
|
15371
|
+
const historyDisabledByConfig = config.lastMessages === false && perPageArg === void 0;
|
|
15363
15372
|
const shouldGetNewestAndReverse = !orderBy && perPage !== false;
|
|
15364
15373
|
const effectiveOrderBy = shouldGetNewestAndReverse ? { field: "createdAt", direction: "DESC" } : orderBy;
|
|
15365
15374
|
const vectorResults = [];
|
|
@@ -15370,7 +15379,8 @@ var Memory = class extends MastraMemory {
|
|
|
15370
15379
|
orderBy: effectiveOrderBy,
|
|
15371
15380
|
hasWorkingMemorySchema: Boolean(config.workingMemory?.schema),
|
|
15372
15381
|
workingMemoryEnabled: config.workingMemory?.enabled,
|
|
15373
|
-
semanticRecallEnabled: Boolean(config.semanticRecall)
|
|
15382
|
+
semanticRecallEnabled: Boolean(config.semanticRecall),
|
|
15383
|
+
historyDisabledByConfig
|
|
15374
15384
|
});
|
|
15375
15385
|
const defaultRange = DEFAULT_MESSAGE_RANGE;
|
|
15376
15386
|
const defaultTopK = DEFAULT_TOP_K;
|
|
@@ -15388,6 +15398,9 @@ var Memory = class extends MastraMemory {
|
|
|
15388
15398
|
);
|
|
15389
15399
|
}
|
|
15390
15400
|
let usage;
|
|
15401
|
+
if (historyDisabledByConfig && (!config.semanticRecall || !vectorSearchString || !this.vector)) {
|
|
15402
|
+
return { messages: [], usage: void 0, total: 0, page: page ?? 0, perPage: 0, hasMore: false };
|
|
15403
|
+
}
|
|
15391
15404
|
if (config?.semanticRecall && vectorSearchString && this.vector) {
|
|
15392
15405
|
const result = await this.embedMessageContent(vectorSearchString);
|
|
15393
15406
|
usage = result.usage;
|
|
@@ -15416,10 +15429,11 @@ var Memory = class extends MastraMemory {
|
|
|
15416
15429
|
);
|
|
15417
15430
|
}
|
|
15418
15431
|
const memoryStore = await this.getMemoryStore();
|
|
15432
|
+
const effectivePerPage = historyDisabledByConfig ? 0 : perPage;
|
|
15419
15433
|
const paginatedResult = await memoryStore.listMessages({
|
|
15420
15434
|
threadId,
|
|
15421
15435
|
resourceId,
|
|
15422
|
-
perPage,
|
|
15436
|
+
perPage: effectivePerPage,
|
|
15423
15437
|
page,
|
|
15424
15438
|
orderBy: effectiveOrderBy,
|
|
15425
15439
|
filter: filter3,
|
|
@@ -15845,7 +15859,10 @@ ${workingMemory}`;
|
|
|
15845
15859
|
return part;
|
|
15846
15860
|
});
|
|
15847
15861
|
if (newMessage.content.parts.length === 0) {
|
|
15848
|
-
|
|
15862
|
+
const hasContentText = typeof newMessage.content.content === "string" && newMessage.content.content.trim().length > 0;
|
|
15863
|
+
if (!hasContentText) {
|
|
15864
|
+
return null;
|
|
15865
|
+
}
|
|
15849
15866
|
}
|
|
15850
15867
|
}
|
|
15851
15868
|
return newMessage;
|
|
@@ -15902,10 +15919,11 @@ ${workingMemory}`;
|
|
|
15902
15919
|
try {
|
|
15903
15920
|
const schema = config.workingMemory.schema;
|
|
15904
15921
|
let convertedSchema;
|
|
15905
|
-
if (
|
|
15906
|
-
convertedSchema =
|
|
15922
|
+
if (isStandardSchemaWithJSON(schema)) {
|
|
15923
|
+
convertedSchema = schema["~standard"].jsonSchema.output({ target: "draft-07" });
|
|
15907
15924
|
} else {
|
|
15908
|
-
|
|
15925
|
+
const standardSchema2 = toStandardSchema(schema);
|
|
15926
|
+
convertedSchema = standardSchema2["~standard"].jsonSchema.output({ target: "draft-07" });
|
|
15909
15927
|
}
|
|
15910
15928
|
return { format: "json", content: JSON.stringify(convertedSchema) };
|
|
15911
15929
|
} catch (error) {
|
|
@@ -16642,7 +16660,12 @@ Notes:
|
|
|
16642
16660
|
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
16643
16661
|
);
|
|
16644
16662
|
}
|
|
16645
|
-
|
|
16663
|
+
if (!coreFeatures.has("request-response-id-rotation")) {
|
|
16664
|
+
throw new Error(
|
|
16665
|
+
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
16666
|
+
);
|
|
16667
|
+
}
|
|
16668
|
+
const { ObservationalMemory } = await import('./observational-memory-OYK4MEUD.js');
|
|
16646
16669
|
return new ObservationalMemory({
|
|
16647
16670
|
storage: memoryStore,
|
|
16648
16671
|
scope: omConfig.scope,
|