@mastra/server 0.10.14 → 0.10.15-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/dist/_tsup-dts-rollup.d.cts +38 -9
- package/dist/_tsup-dts-rollup.d.ts +38 -9
- package/dist/{chunk-DN7K6FJK.cjs → chunk-3CNDE7QY.cjs} +58 -1
- package/dist/{chunk-MKLYEKEF.js → chunk-KOHWJYJT.js} +57 -2
- package/dist/server/handlers/memory.cjs +17 -9
- package/dist/server/handlers/memory.d.cts +2 -0
- package/dist/server/handlers/memory.d.ts +2 -0
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/package.json +3 -3
|
@@ -5,8 +5,8 @@ import type { Artifact } from '@mastra/core/a2a';
|
|
|
5
5
|
import type { BaseLogMessage } from '@mastra/core/logger';
|
|
6
6
|
import { CoreMessage } from 'ai';
|
|
7
7
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
8
|
-
import { DefaultEngineType } from '@mastra/core
|
|
9
|
-
import { EvalRow } from '@mastra/core
|
|
8
|
+
import { DefaultEngineType } from '@mastra/core';
|
|
9
|
+
import { EvalRow } from '@mastra/core';
|
|
10
10
|
import { GenerateObjectResult } from 'ai';
|
|
11
11
|
import { GenerateTextResult } from 'ai';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
@@ -20,7 +20,7 @@ import type { LogLevel } from '@mastra/core/logger';
|
|
|
20
20
|
import type { Mastra } from '@mastra/core/mastra';
|
|
21
21
|
import type { MastraError } from '@mastra/core/error';
|
|
22
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
23
|
-
import { MastraMessageV1 } from '@mastra/core
|
|
23
|
+
import { MastraMessageV1 } from '@mastra/core';
|
|
24
24
|
import type { Message } from '@mastra/core/a2a';
|
|
25
25
|
import type { QueryResult } from '@mastra/core/vector';
|
|
26
26
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
@@ -28,12 +28,12 @@ import { ReadableStream as ReadableStream_3 } from 'stream/web';
|
|
|
28
28
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
29
29
|
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
30
30
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
31
|
-
import { Step } from '@mastra/core
|
|
31
|
+
import { Step } from '@mastra/core';
|
|
32
32
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
33
33
|
import { StepGraph } from '@mastra/core/workflows/legacy';
|
|
34
|
-
import { StepResult } from '@mastra/core
|
|
35
|
-
import { StorageThreadType } from '@mastra/core
|
|
36
|
-
import { StreamEvent } from '@mastra/core
|
|
34
|
+
import { StepResult } from '@mastra/core';
|
|
35
|
+
import { StorageThreadType } from '@mastra/core';
|
|
36
|
+
import { StreamEvent } from '@mastra/core';
|
|
37
37
|
import { Task } from '@mastra/core/a2a';
|
|
38
38
|
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
39
39
|
import type { TaskContext } from '@mastra/core/a2a';
|
|
@@ -47,8 +47,9 @@ import type { VercelTool } from '@mastra/core/tools';
|
|
|
47
47
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
48
48
|
import type { Workflow } from '@mastra/core/workflows';
|
|
49
49
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
50
|
-
import { WorkflowResult } from '@mastra/core
|
|
50
|
+
import { WorkflowResult } from '@mastra/core';
|
|
51
51
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
52
|
+
import { WorkingMemoryTemplate } from '@mastra/core';
|
|
52
53
|
import { ZodBoolean } from 'zod';
|
|
53
54
|
import { ZodEnum } from 'zod';
|
|
54
55
|
import { ZodNumber } from 'zod';
|
|
@@ -466,6 +467,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
|
|
|
466
467
|
|
|
467
468
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
|
|
468
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Handler to get the working memory for a thread (optionally resource-scoped).
|
|
472
|
+
* @returns workingMemory - the working memory for the thread
|
|
473
|
+
* @returns source - thread or resource
|
|
474
|
+
*/
|
|
475
|
+
export declare function getWorkingMemoryHandler({ mastra, agentId, threadId, resourceId, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
476
|
+
resourceId?: Parameters<MastraMemory['getWorkingMemory']>[0]['resourceId'];
|
|
477
|
+
memoryConfig?: Parameters<MastraMemory['getWorkingMemory']>[0]['memoryConfig'];
|
|
478
|
+
}): Promise<{
|
|
479
|
+
workingMemory: string | null;
|
|
480
|
+
source: string;
|
|
481
|
+
workingMemoryTemplate: WorkingMemoryTemplate | null;
|
|
482
|
+
threadExists: boolean;
|
|
483
|
+
}>;
|
|
484
|
+
|
|
469
485
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
470
486
|
|
|
471
487
|
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
@@ -702,7 +718,9 @@ export declare namespace memory {
|
|
|
702
718
|
createThreadHandler,
|
|
703
719
|
updateThreadHandler,
|
|
704
720
|
deleteThreadHandler,
|
|
705
|
-
getMessagesHandler
|
|
721
|
+
getMessagesHandler,
|
|
722
|
+
getWorkingMemoryHandler,
|
|
723
|
+
updateWorkingMemoryHandler
|
|
706
724
|
}
|
|
707
725
|
}
|
|
708
726
|
|
|
@@ -999,6 +1017,17 @@ export declare function updateThreadHandler({ mastra, agentId, threadId, body, n
|
|
|
999
1017
|
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
1000
1018
|
}): Promise<StorageThreadType>;
|
|
1001
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Handler to update the working memory for a thread (optionally resource-scoped).
|
|
1022
|
+
* @param threadId - the thread id
|
|
1023
|
+
* @param body - the body containing the working memory to update and the resource id (optional)
|
|
1024
|
+
*/
|
|
1025
|
+
export declare function updateWorkingMemoryHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
1026
|
+
body: Omit<Parameters<MastraMemory['updateWorkingMemory']>[0], 'threadId'>;
|
|
1027
|
+
}): Promise<{
|
|
1028
|
+
success: boolean;
|
|
1029
|
+
}>;
|
|
1030
|
+
|
|
1002
1031
|
declare interface UpsertRequest {
|
|
1003
1032
|
indexName: string;
|
|
1004
1033
|
vectors: number[][];
|
|
@@ -5,8 +5,8 @@ import type { Artifact } from '@mastra/core/a2a';
|
|
|
5
5
|
import type { BaseLogMessage } from '@mastra/core/logger';
|
|
6
6
|
import { CoreMessage } from 'ai';
|
|
7
7
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
8
|
-
import { DefaultEngineType } from '@mastra/core
|
|
9
|
-
import { EvalRow } from '@mastra/core
|
|
8
|
+
import { DefaultEngineType } from '@mastra/core';
|
|
9
|
+
import { EvalRow } from '@mastra/core';
|
|
10
10
|
import { GenerateObjectResult } from 'ai';
|
|
11
11
|
import { GenerateTextResult } from 'ai';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
@@ -20,7 +20,7 @@ import type { LogLevel } from '@mastra/core/logger';
|
|
|
20
20
|
import type { Mastra } from '@mastra/core/mastra';
|
|
21
21
|
import type { MastraError } from '@mastra/core/error';
|
|
22
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
23
|
-
import { MastraMessageV1 } from '@mastra/core
|
|
23
|
+
import { MastraMessageV1 } from '@mastra/core';
|
|
24
24
|
import type { Message } from '@mastra/core/a2a';
|
|
25
25
|
import type { QueryResult } from '@mastra/core/vector';
|
|
26
26
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
@@ -28,12 +28,12 @@ import { ReadableStream as ReadableStream_3 } from 'stream/web';
|
|
|
28
28
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
29
29
|
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
30
30
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
31
|
-
import { Step } from '@mastra/core
|
|
31
|
+
import { Step } from '@mastra/core';
|
|
32
32
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
33
33
|
import { StepGraph } from '@mastra/core/workflows/legacy';
|
|
34
|
-
import { StepResult } from '@mastra/core
|
|
35
|
-
import { StorageThreadType } from '@mastra/core
|
|
36
|
-
import { StreamEvent } from '@mastra/core
|
|
34
|
+
import { StepResult } from '@mastra/core';
|
|
35
|
+
import { StorageThreadType } from '@mastra/core';
|
|
36
|
+
import { StreamEvent } from '@mastra/core';
|
|
37
37
|
import { Task } from '@mastra/core/a2a';
|
|
38
38
|
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
39
39
|
import type { TaskContext } from '@mastra/core/a2a';
|
|
@@ -47,8 +47,9 @@ import type { VercelTool } from '@mastra/core/tools';
|
|
|
47
47
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
48
48
|
import type { Workflow } from '@mastra/core/workflows';
|
|
49
49
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
50
|
-
import { WorkflowResult } from '@mastra/core
|
|
50
|
+
import { WorkflowResult } from '@mastra/core';
|
|
51
51
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
52
|
+
import { WorkingMemoryTemplate } from '@mastra/core';
|
|
52
53
|
import { ZodBoolean } from 'zod';
|
|
53
54
|
import { ZodEnum } from 'zod';
|
|
54
55
|
import { ZodNumber } from 'zod';
|
|
@@ -466,6 +467,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
|
|
|
466
467
|
|
|
467
468
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
|
|
468
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Handler to get the working memory for a thread (optionally resource-scoped).
|
|
472
|
+
* @returns workingMemory - the working memory for the thread
|
|
473
|
+
* @returns source - thread or resource
|
|
474
|
+
*/
|
|
475
|
+
export declare function getWorkingMemoryHandler({ mastra, agentId, threadId, resourceId, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
476
|
+
resourceId?: Parameters<MastraMemory['getWorkingMemory']>[0]['resourceId'];
|
|
477
|
+
memoryConfig?: Parameters<MastraMemory['getWorkingMemory']>[0]['memoryConfig'];
|
|
478
|
+
}): Promise<{
|
|
479
|
+
workingMemory: string | null;
|
|
480
|
+
source: string;
|
|
481
|
+
workingMemoryTemplate: WorkingMemoryTemplate | null;
|
|
482
|
+
threadExists: boolean;
|
|
483
|
+
}>;
|
|
484
|
+
|
|
469
485
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
470
486
|
|
|
471
487
|
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
@@ -702,7 +718,9 @@ export declare namespace memory {
|
|
|
702
718
|
createThreadHandler,
|
|
703
719
|
updateThreadHandler,
|
|
704
720
|
deleteThreadHandler,
|
|
705
|
-
getMessagesHandler
|
|
721
|
+
getMessagesHandler,
|
|
722
|
+
getWorkingMemoryHandler,
|
|
723
|
+
updateWorkingMemoryHandler
|
|
706
724
|
}
|
|
707
725
|
}
|
|
708
726
|
|
|
@@ -999,6 +1017,17 @@ export declare function updateThreadHandler({ mastra, agentId, threadId, body, n
|
|
|
999
1017
|
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
1000
1018
|
}): Promise<StorageThreadType>;
|
|
1001
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Handler to update the working memory for a thread (optionally resource-scoped).
|
|
1022
|
+
* @param threadId - the thread id
|
|
1023
|
+
* @param body - the body containing the working memory to update and the resource id (optional)
|
|
1024
|
+
*/
|
|
1025
|
+
export declare function updateWorkingMemoryHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
1026
|
+
body: Omit<Parameters<MastraMemory['updateWorkingMemory']>[0], 'threadId'>;
|
|
1027
|
+
}): Promise<{
|
|
1028
|
+
success: boolean;
|
|
1029
|
+
}>;
|
|
1030
|
+
|
|
1002
1031
|
declare interface UpsertRequest {
|
|
1003
1032
|
indexName: string;
|
|
1004
1033
|
vectors: number[][];
|
|
@@ -4,6 +4,7 @@ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
|
|
|
4
4
|
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
5
5
|
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
|
+
var core = require('@mastra/core');
|
|
7
8
|
|
|
8
9
|
// src/server/handlers/memory.ts
|
|
9
10
|
var memory_exports = {};
|
|
@@ -14,8 +15,10 @@ chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
|
14
15
|
getMessagesHandler: () => getMessagesHandler,
|
|
15
16
|
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
16
17
|
getThreadsHandler: () => getThreadsHandler,
|
|
18
|
+
getWorkingMemoryHandler: () => getWorkingMemoryHandler,
|
|
17
19
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
18
|
-
updateThreadHandler: () => updateThreadHandler
|
|
20
|
+
updateThreadHandler: () => updateThreadHandler,
|
|
21
|
+
updateWorkingMemoryHandler: () => updateWorkingMemoryHandler
|
|
19
22
|
});
|
|
20
23
|
async function getMemoryFromContext({
|
|
21
24
|
mastra,
|
|
@@ -239,6 +242,58 @@ async function getMessagesHandler({
|
|
|
239
242
|
return chunkPZQDCRPV_cjs.handleError(error, "Error getting messages");
|
|
240
243
|
}
|
|
241
244
|
}
|
|
245
|
+
async function getWorkingMemoryHandler({
|
|
246
|
+
mastra,
|
|
247
|
+
agentId,
|
|
248
|
+
threadId,
|
|
249
|
+
resourceId,
|
|
250
|
+
networkId,
|
|
251
|
+
runtimeContext,
|
|
252
|
+
memoryConfig
|
|
253
|
+
}) {
|
|
254
|
+
try {
|
|
255
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
256
|
+
chunkCCGRCYWJ_cjs.validateBody({ threadId });
|
|
257
|
+
if (!memory) {
|
|
258
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
259
|
+
}
|
|
260
|
+
const thread = await memory.getThreadById({ threadId });
|
|
261
|
+
const threadExists = !!thread;
|
|
262
|
+
const template = await memory.getWorkingMemoryTemplate({ memoryConfig });
|
|
263
|
+
const workingMemoryTemplate = template?.format === "json" ? { ...template, content: JSON.stringify(core.generateEmptyFromSchema(template.content)) } : template;
|
|
264
|
+
const workingMemory = await memory.getWorkingMemory({ threadId, resourceId, memoryConfig });
|
|
265
|
+
const config = memory.getMergedThreadConfig(memoryConfig || {});
|
|
266
|
+
const source = config.workingMemory?.scope === "resource" && resourceId ? "resource" : "thread";
|
|
267
|
+
return { workingMemory, source, workingMemoryTemplate, threadExists };
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting working memory");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function updateWorkingMemoryHandler({
|
|
273
|
+
mastra,
|
|
274
|
+
agentId,
|
|
275
|
+
threadId,
|
|
276
|
+
body,
|
|
277
|
+
networkId,
|
|
278
|
+
runtimeContext
|
|
279
|
+
}) {
|
|
280
|
+
try {
|
|
281
|
+
chunkCCGRCYWJ_cjs.validateBody({ threadId });
|
|
282
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
283
|
+
const { resourceId, memoryConfig, workingMemory } = body;
|
|
284
|
+
if (!memory) {
|
|
285
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
286
|
+
}
|
|
287
|
+
const thread = await memory.getThreadById({ threadId });
|
|
288
|
+
if (!thread) {
|
|
289
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
|
|
290
|
+
}
|
|
291
|
+
await memory.updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig });
|
|
292
|
+
return { success: true };
|
|
293
|
+
} catch (error) {
|
|
294
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error updating working memory");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
242
297
|
|
|
243
298
|
exports.createThreadHandler = createThreadHandler;
|
|
244
299
|
exports.deleteThreadHandler = deleteThreadHandler;
|
|
@@ -246,6 +301,8 @@ exports.getMemoryStatusHandler = getMemoryStatusHandler;
|
|
|
246
301
|
exports.getMessagesHandler = getMessagesHandler;
|
|
247
302
|
exports.getThreadByIdHandler = getThreadByIdHandler;
|
|
248
303
|
exports.getThreadsHandler = getThreadsHandler;
|
|
304
|
+
exports.getWorkingMemoryHandler = getWorkingMemoryHandler;
|
|
249
305
|
exports.memory_exports = memory_exports;
|
|
250
306
|
exports.saveMessagesHandler = saveMessagesHandler;
|
|
251
307
|
exports.updateThreadHandler = updateThreadHandler;
|
|
308
|
+
exports.updateWorkingMemoryHandler = updateWorkingMemoryHandler;
|
|
@@ -2,6 +2,7 @@ import { validateBody } from './chunk-RSEO4XPX.js';
|
|
|
2
2
|
import { handleError } from './chunk-LF7P5PLR.js';
|
|
3
3
|
import { HTTPException } from './chunk-LCM566I4.js';
|
|
4
4
|
import { __export } from './chunk-MLKGABMK.js';
|
|
5
|
+
import { generateEmptyFromSchema } from '@mastra/core';
|
|
5
6
|
|
|
6
7
|
// src/server/handlers/memory.ts
|
|
7
8
|
var memory_exports = {};
|
|
@@ -12,8 +13,10 @@ __export(memory_exports, {
|
|
|
12
13
|
getMessagesHandler: () => getMessagesHandler,
|
|
13
14
|
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
14
15
|
getThreadsHandler: () => getThreadsHandler,
|
|
16
|
+
getWorkingMemoryHandler: () => getWorkingMemoryHandler,
|
|
15
17
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
16
|
-
updateThreadHandler: () => updateThreadHandler
|
|
18
|
+
updateThreadHandler: () => updateThreadHandler,
|
|
19
|
+
updateWorkingMemoryHandler: () => updateWorkingMemoryHandler
|
|
17
20
|
});
|
|
18
21
|
async function getMemoryFromContext({
|
|
19
22
|
mastra,
|
|
@@ -237,5 +240,57 @@ async function getMessagesHandler({
|
|
|
237
240
|
return handleError(error, "Error getting messages");
|
|
238
241
|
}
|
|
239
242
|
}
|
|
243
|
+
async function getWorkingMemoryHandler({
|
|
244
|
+
mastra,
|
|
245
|
+
agentId,
|
|
246
|
+
threadId,
|
|
247
|
+
resourceId,
|
|
248
|
+
networkId,
|
|
249
|
+
runtimeContext,
|
|
250
|
+
memoryConfig
|
|
251
|
+
}) {
|
|
252
|
+
try {
|
|
253
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
254
|
+
validateBody({ threadId });
|
|
255
|
+
if (!memory) {
|
|
256
|
+
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
257
|
+
}
|
|
258
|
+
const thread = await memory.getThreadById({ threadId });
|
|
259
|
+
const threadExists = !!thread;
|
|
260
|
+
const template = await memory.getWorkingMemoryTemplate({ memoryConfig });
|
|
261
|
+
const workingMemoryTemplate = template?.format === "json" ? { ...template, content: JSON.stringify(generateEmptyFromSchema(template.content)) } : template;
|
|
262
|
+
const workingMemory = await memory.getWorkingMemory({ threadId, resourceId, memoryConfig });
|
|
263
|
+
const config = memory.getMergedThreadConfig(memoryConfig || {});
|
|
264
|
+
const source = config.workingMemory?.scope === "resource" && resourceId ? "resource" : "thread";
|
|
265
|
+
return { workingMemory, source, workingMemoryTemplate, threadExists };
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return handleError(error, "Error getting working memory");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function updateWorkingMemoryHandler({
|
|
271
|
+
mastra,
|
|
272
|
+
agentId,
|
|
273
|
+
threadId,
|
|
274
|
+
body,
|
|
275
|
+
networkId,
|
|
276
|
+
runtimeContext
|
|
277
|
+
}) {
|
|
278
|
+
try {
|
|
279
|
+
validateBody({ threadId });
|
|
280
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
281
|
+
const { resourceId, memoryConfig, workingMemory } = body;
|
|
282
|
+
if (!memory) {
|
|
283
|
+
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
284
|
+
}
|
|
285
|
+
const thread = await memory.getThreadById({ threadId });
|
|
286
|
+
if (!thread) {
|
|
287
|
+
throw new HTTPException(404, { message: "Thread not found" });
|
|
288
|
+
}
|
|
289
|
+
await memory.updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig });
|
|
290
|
+
return { success: true };
|
|
291
|
+
} catch (error) {
|
|
292
|
+
return handleError(error, "Error updating working memory");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
240
295
|
|
|
241
|
-
export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, memory_exports, saveMessagesHandler, updateThreadHandler };
|
|
296
|
+
export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, getWorkingMemoryHandler, memory_exports, saveMessagesHandler, updateThreadHandler, updateWorkingMemoryHandler };
|
|
@@ -1,38 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3CNDE7QY_cjs = require('../../chunk-3CNDE7QY.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "createThreadHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk3CNDE7QY_cjs.createThreadHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "deleteThreadHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk3CNDE7QY_cjs.deleteThreadHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getMemoryStatusHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk3CNDE7QY_cjs.getMemoryStatusHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getMessagesHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk3CNDE7QY_cjs.getMessagesHandler; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "getThreadByIdHandler", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk3CNDE7QY_cjs.getThreadByIdHandler; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "getThreadsHandler", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk3CNDE7QY_cjs.getThreadsHandler; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "getWorkingMemoryHandler", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunk3CNDE7QY_cjs.getWorkingMemoryHandler; }
|
|
30
34
|
});
|
|
31
35
|
Object.defineProperty(exports, "saveMessagesHandler", {
|
|
32
36
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunk3CNDE7QY_cjs.saveMessagesHandler; }
|
|
34
38
|
});
|
|
35
39
|
Object.defineProperty(exports, "updateThreadHandler", {
|
|
36
40
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunk3CNDE7QY_cjs.updateThreadHandler; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "updateWorkingMemoryHandler", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunk3CNDE7QY_cjs.updateWorkingMemoryHandler; }
|
|
38
46
|
});
|
|
@@ -6,3 +6,5 @@ export { createThreadHandler } from '../../_tsup-dts-rollup.cjs';
|
|
|
6
6
|
export { updateThreadHandler } from '../../_tsup-dts-rollup.cjs';
|
|
7
7
|
export { deleteThreadHandler } from '../../_tsup-dts-rollup.cjs';
|
|
8
8
|
export { getMessagesHandler } from '../../_tsup-dts-rollup.cjs';
|
|
9
|
+
export { getWorkingMemoryHandler } from '../../_tsup-dts-rollup.cjs';
|
|
10
|
+
export { updateWorkingMemoryHandler } from '../../_tsup-dts-rollup.cjs';
|
|
@@ -6,3 +6,5 @@ export { createThreadHandler } from '../../_tsup-dts-rollup.js';
|
|
|
6
6
|
export { updateThreadHandler } from '../../_tsup-dts-rollup.js';
|
|
7
7
|
export { deleteThreadHandler } from '../../_tsup-dts-rollup.js';
|
|
8
8
|
export { getMessagesHandler } from '../../_tsup-dts-rollup.js';
|
|
9
|
+
export { getWorkingMemoryHandler } from '../../_tsup-dts-rollup.js';
|
|
10
|
+
export { updateWorkingMemoryHandler } from '../../_tsup-dts-rollup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, saveMessagesHandler, updateThreadHandler } from '../../chunk-
|
|
1
|
+
export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, getWorkingMemoryHandler, saveMessagesHandler, updateThreadHandler, updateWorkingMemoryHandler } from '../../chunk-KOHWJYJT.js';
|
package/dist/server/handlers.cjs
CHANGED
|
@@ -10,7 +10,7 @@ var chunkSDPGVWQJ_cjs = require('../chunk-SDPGVWQJ.cjs');
|
|
|
10
10
|
var chunkLZ3VJXSO_cjs = require('../chunk-LZ3VJXSO.cjs');
|
|
11
11
|
var chunkJMLYCXMK_cjs = require('../chunk-JMLYCXMK.cjs');
|
|
12
12
|
var chunkQGX47B5D_cjs = require('../chunk-QGX47B5D.cjs');
|
|
13
|
-
var
|
|
13
|
+
var chunk3CNDE7QY_cjs = require('../chunk-3CNDE7QY.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -56,5 +56,5 @@ Object.defineProperty(exports, "logs", {
|
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "memory", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunk3CNDE7QY_cjs.memory_exports; }
|
|
60
60
|
});
|
package/dist/server/handlers.js
CHANGED
|
@@ -8,4 +8,4 @@ export { a2a_exports as a2a } from '../chunk-GHC4YV6R.js';
|
|
|
8
8
|
export { agents_exports as agents } from '../chunk-BK4XT6EG.js';
|
|
9
9
|
export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-5PQQ42EZ.js';
|
|
10
10
|
export { logs_exports as logs } from '../chunk-4D66QEKC.js';
|
|
11
|
-
export { memory_exports as memory } from '../chunk-
|
|
11
|
+
export { memory_exports as memory } from '../chunk-KOHWJYJT.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.15-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@ai-sdk/openai": "^1.3.22",
|
|
53
53
|
"@microsoft/api-extractor": "^7.52.8",
|
|
54
54
|
"@types/node": "^20.19.0",
|
|
55
|
-
"eslint": "^9.
|
|
55
|
+
"eslint": "^9.30.1",
|
|
56
56
|
"superjson": "^2.2.2",
|
|
57
57
|
"tsup": "^8.5.0",
|
|
58
58
|
"typescript": "^5.8.3",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"zod": "^3.25.67",
|
|
61
61
|
"zod-to-json-schema": "^3.24.5",
|
|
62
62
|
"@internal/lint": "0.0.19",
|
|
63
|
-
"@mastra/core": "0.10.
|
|
63
|
+
"@mastra/core": "0.10.15-alpha.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",
|