@mastra/server 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-generate-message-id-20250512171942
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/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +157 -13
- package/dist/_tsup-dts-rollup.d.ts +157 -13
- package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
- package/dist/{chunk-4BIX6GMY.cjs → chunk-3HQNCTZ2.cjs} +36 -26
- package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-5SN4U5AC.cjs +508 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
- package/dist/{chunk-3XTEV33Q.js → chunk-EJO45KYT.js} +19 -16
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
- package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
- package/dist/{chunk-CHFORQ7J.cjs → chunk-I2B73Y4I.cjs} +60 -57
- package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
- package/dist/{chunk-IQTNZSFP.js → chunk-MIQYDLLM.js} +36 -19
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
- package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/{chunk-Y3SV5XK4.js → chunk-Q6KMBIAN.js} +18 -8
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/{chunk-FOXHTOQZ.cjs → chunk-UCTEMO2Q.cjs} +84 -67
- package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
- package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
- package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextWorkflows.cjs +12 -12
- package/dist/server/handlers/vNextWorkflows.d.cts +1 -1
- package/dist/server/handlers/vNextWorkflows.d.ts +1 -1
- package/dist/server/handlers/vNextWorkflows.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +28 -23
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +11 -10
- package/package.json +7 -5
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-OMN3UI6X.js +0 -5576
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
import type { Agent } from '@mastra/core/agent';
|
|
2
|
+
import type { AgentCard } from '@mastra/core/a2a';
|
|
2
3
|
import type { AgentNetwork } from '@mastra/core/network';
|
|
4
|
+
import type { Artifact } from '@mastra/core/a2a';
|
|
3
5
|
import type { BaseLogMessage } from '@mastra/core/logger';
|
|
4
6
|
import { CoreMessage } from 'ai';
|
|
7
|
+
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
5
8
|
import { EvalRow } from '@mastra/core/storage';
|
|
6
9
|
import { GenerateObjectResult } from 'ai';
|
|
7
10
|
import { GenerateTextResult } from 'ai';
|
|
11
|
+
import type { JSONRPCError } from '@mastra/core/a2a';
|
|
12
|
+
import { JSONRPCResponse } from '@mastra/core/a2a';
|
|
13
|
+
import type { Logger } from '@mastra/core/logger';
|
|
8
14
|
import type { Mastra } from '@mastra/core/mastra';
|
|
9
15
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
10
16
|
import { Message } from 'ai';
|
|
17
|
+
import type { Message as Message_2 } from '@mastra/core/a2a';
|
|
11
18
|
import { MessageType } from '@mastra/core/memory';
|
|
12
19
|
import { NewStep } from '@mastra/core/workflows/vNext';
|
|
13
20
|
import type { NewWorkflow } from '@mastra/core/workflows/vNext';
|
|
14
21
|
import type { QueryResult } from '@mastra/core/vector';
|
|
15
22
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { SerializedStepFlowEntry } from '@mastra/core/workflows/vNext';
|
|
23
|
+
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
24
|
+
import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
25
|
+
import type { SerializedStepFlowEntry } from '@mastra/core/workflows/vNext';
|
|
19
26
|
import { Step } from '@mastra/core/workflows';
|
|
20
27
|
import { StepExecutionContext } from '@mastra/core/workflows';
|
|
21
28
|
import { StepGraph } from '@mastra/core/workflows';
|
|
22
29
|
import { StorageThreadType } from '@mastra/core/memory';
|
|
30
|
+
import { Task } from '@mastra/core/a2a';
|
|
31
|
+
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
32
|
+
import type { TaskContext } from '@mastra/core/a2a';
|
|
33
|
+
import type { TaskIdParams } from '@mastra/core/a2a';
|
|
34
|
+
import type { TaskQueryParams } from '@mastra/core/a2a';
|
|
35
|
+
import type { TaskSendParams } from '@mastra/core/a2a';
|
|
36
|
+
import type { TaskStatus } from '@mastra/core/a2a';
|
|
23
37
|
import type { ToolAction } from '@mastra/core/tools';
|
|
24
38
|
import type { VercelTool } from '@mastra/core/tools';
|
|
25
39
|
import type { Workflow } from '@mastra/core/workflows';
|
|
@@ -30,6 +44,17 @@ import type { WorkflowRuns } from '@mastra/core/storage';
|
|
|
30
44
|
import { ZodType } from 'zod';
|
|
31
45
|
import { ZodTypeDef } from 'zod';
|
|
32
46
|
|
|
47
|
+
export declare namespace a2a {
|
|
48
|
+
export {
|
|
49
|
+
getAgentCardByIdHandler,
|
|
50
|
+
handleTaskSend,
|
|
51
|
+
handleTaskGet,
|
|
52
|
+
handleTaskSendSubscribe,
|
|
53
|
+
handleTaskCancel,
|
|
54
|
+
getAgentExecutionHandler
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
export declare namespace agents {
|
|
34
59
|
export {
|
|
35
60
|
getAgentsHandler,
|
|
@@ -46,12 +71,18 @@ export declare interface ApiError extends Error {
|
|
|
46
71
|
status?: number;
|
|
47
72
|
}
|
|
48
73
|
|
|
74
|
+
export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
|
|
75
|
+
|
|
49
76
|
declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
|
|
50
77
|
|
|
51
78
|
export declare interface Context {
|
|
52
79
|
mastra: Mastra;
|
|
53
80
|
}
|
|
54
81
|
|
|
82
|
+
export declare function convertToCoreMessage(message: Message_2): CoreMessage_2;
|
|
83
|
+
|
|
84
|
+
export declare function createErrorResponse(id: number | string | null, error: JSONRPCError<unknown>): JSONRPCResponse<null, unknown>;
|
|
85
|
+
|
|
55
86
|
export declare function createIndex({ mastra, vectorName, index, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
56
87
|
index: CreateIndexRequest;
|
|
57
88
|
}): Promise<{
|
|
@@ -68,6 +99,15 @@ export declare function createRunHandler({ mastra, workflowId, runId: prevRunId,
|
|
|
68
99
|
runId: string;
|
|
69
100
|
}>;
|
|
70
101
|
|
|
102
|
+
export declare function createSuccessResponse<T>(id: number | string | null, result: T): JSONRPCResponse<T>;
|
|
103
|
+
|
|
104
|
+
export declare function createTaskContext({ task, userMessage, history, activeCancellations, }: {
|
|
105
|
+
task: Task;
|
|
106
|
+
userMessage: Message_2;
|
|
107
|
+
history: Message_2[];
|
|
108
|
+
activeCancellations: Set<string>;
|
|
109
|
+
}): TaskContext;
|
|
110
|
+
|
|
71
111
|
export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
72
112
|
body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
|
|
73
113
|
resourceId?: string;
|
|
@@ -98,15 +138,17 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
98
138
|
metric: string | undefined;
|
|
99
139
|
}>;
|
|
100
140
|
|
|
101
|
-
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
141
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
102
142
|
agentId?: string;
|
|
103
143
|
data: any;
|
|
104
|
-
runtimeContext:
|
|
144
|
+
runtimeContext: RuntimeContext_2;
|
|
145
|
+
runtimeContextFromRequest: Record<string, unknown>;
|
|
105
146
|
}): Promise<any>;
|
|
106
147
|
|
|
107
|
-
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
|
|
148
|
+
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
|
|
108
149
|
data?: unknown;
|
|
109
|
-
runtimeContext:
|
|
150
|
+
runtimeContext: RuntimeContext_2;
|
|
151
|
+
runtimeContextFromRequest: Record<string, unknown>;
|
|
110
152
|
}) => Promise<any>;
|
|
111
153
|
|
|
112
154
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -114,6 +156,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
|
|
|
114
156
|
agentId: string;
|
|
115
157
|
body: GetBody<'generate'> & {
|
|
116
158
|
resourceid?: string;
|
|
159
|
+
runtimeContext?: Record<string, unknown>;
|
|
117
160
|
};
|
|
118
161
|
}): Promise<GenerateTextResult<any, any>>;
|
|
119
162
|
|
|
@@ -145,6 +188,27 @@ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }
|
|
|
145
188
|
modelId: string;
|
|
146
189
|
}>;
|
|
147
190
|
|
|
191
|
+
export declare function getAgentCardByIdHandler({ mastra, agentId, executionUrl, provider, version, runtimeContext, }: Context & {
|
|
192
|
+
runtimeContext: RuntimeContext;
|
|
193
|
+
agentId: keyof ReturnType<typeof mastra.getAgents>;
|
|
194
|
+
executionUrl?: string;
|
|
195
|
+
version?: string;
|
|
196
|
+
provider?: {
|
|
197
|
+
organization: string;
|
|
198
|
+
url: string;
|
|
199
|
+
};
|
|
200
|
+
}): Promise<AgentCard>;
|
|
201
|
+
|
|
202
|
+
export declare function getAgentExecutionHandler({ requestId, mastra, agentId, runtimeContext, method, params, taskStore, logger, }: Context & {
|
|
203
|
+
requestId: string;
|
|
204
|
+
runtimeContext: RuntimeContext;
|
|
205
|
+
agentId: string;
|
|
206
|
+
method: 'tasks/send' | 'tasks/sendSubscribe' | 'tasks/get' | 'tasks/cancel';
|
|
207
|
+
params: TaskSendParams | TaskQueryParams | TaskIdParams;
|
|
208
|
+
taskStore?: InMemoryTaskStore;
|
|
209
|
+
logger?: Logger;
|
|
210
|
+
}): Promise<any>;
|
|
211
|
+
|
|
148
212
|
export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
|
|
149
213
|
runtimeContext: RuntimeContext;
|
|
150
214
|
}): Promise<any>;
|
|
@@ -240,14 +304,14 @@ export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext,
|
|
|
240
304
|
export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
|
|
241
305
|
|
|
242
306
|
export declare function getVNextWorkflowByIdHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<{
|
|
243
|
-
steps:
|
|
307
|
+
steps: SerializedStep[];
|
|
244
308
|
name: string | undefined;
|
|
245
309
|
stepGraph: SerializedStepFlowEntry[];
|
|
246
310
|
inputSchema: string | undefined;
|
|
247
311
|
outputSchema: string | undefined;
|
|
248
312
|
}>;
|
|
249
313
|
|
|
250
|
-
export declare function
|
|
314
|
+
export declare function getVNextWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRunById']>>;
|
|
251
315
|
|
|
252
316
|
export declare function getVNextWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: VNextWorkflowContext & {
|
|
253
317
|
fromDate?: Date;
|
|
@@ -283,6 +347,48 @@ export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promis
|
|
|
283
347
|
|
|
284
348
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
285
349
|
|
|
350
|
+
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
351
|
+
requestId: string;
|
|
352
|
+
taskStore: InMemoryTaskStore;
|
|
353
|
+
agentId: string;
|
|
354
|
+
taskId: string;
|
|
355
|
+
logger?: Logger;
|
|
356
|
+
}): Promise<JSONRPCResponse<Task, unknown>>;
|
|
357
|
+
|
|
358
|
+
export declare function handleTaskGet({ requestId, taskStore, agentId, taskId, }: {
|
|
359
|
+
requestId: string;
|
|
360
|
+
taskStore: InMemoryTaskStore;
|
|
361
|
+
agentId: string;
|
|
362
|
+
taskId: string;
|
|
363
|
+
}): Promise<JSONRPCResponse<TaskAndHistory, unknown>>;
|
|
364
|
+
|
|
365
|
+
export declare function handleTaskSend({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
|
|
366
|
+
requestId: string;
|
|
367
|
+
params: TaskSendParams;
|
|
368
|
+
taskStore: InMemoryTaskStore;
|
|
369
|
+
agent: Agent;
|
|
370
|
+
logger?: Logger;
|
|
371
|
+
runtimeContext: RuntimeContext;
|
|
372
|
+
}): Promise<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown>>;
|
|
373
|
+
|
|
374
|
+
export declare function handleTaskSendSubscribe({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
|
|
375
|
+
requestId: string;
|
|
376
|
+
params: TaskSendParams;
|
|
377
|
+
taskStore: InMemoryTaskStore;
|
|
378
|
+
agent: Agent;
|
|
379
|
+
logger?: Logger;
|
|
380
|
+
runtimeContext: RuntimeContext;
|
|
381
|
+
}): AsyncGenerator<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown> | JSONRPCResponse< {
|
|
382
|
+
state: string;
|
|
383
|
+
message: {
|
|
384
|
+
role: string;
|
|
385
|
+
parts: {
|
|
386
|
+
type: string;
|
|
387
|
+
text: string;
|
|
388
|
+
}[];
|
|
389
|
+
};
|
|
390
|
+
}, unknown>, void, unknown>;
|
|
391
|
+
|
|
286
392
|
/**
|
|
287
393
|
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
288
394
|
*
|
|
@@ -344,8 +450,31 @@ declare type HTTPExceptionOptions = {
|
|
|
344
450
|
*/
|
|
345
451
|
declare type InfoStatusCode = 100 | 101 | 102 | 103;
|
|
346
452
|
|
|
453
|
+
export declare class InMemoryTaskStore {
|
|
454
|
+
private store;
|
|
455
|
+
activeCancellations: Set<string>;
|
|
456
|
+
load({ agentId, taskId }: {
|
|
457
|
+
agentId: string;
|
|
458
|
+
taskId: string;
|
|
459
|
+
}): Promise<TaskAndHistory | null>;
|
|
460
|
+
save({ agentId, data }: {
|
|
461
|
+
agentId: string;
|
|
462
|
+
data: TaskAndHistory;
|
|
463
|
+
}): Promise<void>;
|
|
464
|
+
}
|
|
465
|
+
|
|
347
466
|
export declare function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>): Promise<string[]>;
|
|
348
467
|
|
|
468
|
+
export declare function loadOrCreateTaskAndHistory({ agentId, taskId, taskStore, message, sessionId, metadata, logger, }: {
|
|
469
|
+
agentId: string;
|
|
470
|
+
taskId: string;
|
|
471
|
+
taskStore: InMemoryTaskStore;
|
|
472
|
+
message: Message_2;
|
|
473
|
+
sessionId?: string | null;
|
|
474
|
+
metadata?: Record<string, unknown> | null;
|
|
475
|
+
logger?: Logger;
|
|
476
|
+
}): Promise<TaskAndHistory>;
|
|
477
|
+
|
|
349
478
|
export declare namespace logs {
|
|
350
479
|
export {
|
|
351
480
|
getLogsHandler,
|
|
@@ -393,6 +522,8 @@ declare interface NetworkContext extends Context {
|
|
|
393
522
|
runtimeContext: RuntimeContext;
|
|
394
523
|
}
|
|
395
524
|
|
|
525
|
+
export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: Logger): JSONRPCResponse<null, unknown>;
|
|
526
|
+
|
|
396
527
|
declare interface QueryRequest {
|
|
397
528
|
indexName: string;
|
|
398
529
|
queryVector: number[];
|
|
@@ -407,12 +538,13 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
|
|
|
407
538
|
|
|
408
539
|
declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
|
|
409
540
|
|
|
410
|
-
export declare function resumeAsyncVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: VNextWorkflowContext & {
|
|
541
|
+
export declare function resumeAsyncVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, runtimeContextFromRequest, }: VNextWorkflowContext & {
|
|
411
542
|
body: {
|
|
412
543
|
step: string | string[];
|
|
413
544
|
resumeData?: unknown;
|
|
414
545
|
};
|
|
415
546
|
runtimeContext?: RuntimeContext_2;
|
|
547
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
416
548
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
|
|
417
549
|
|
|
418
550
|
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -449,11 +581,21 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
|
|
|
449
581
|
};
|
|
450
582
|
}): Promise<MessageType[]>;
|
|
451
583
|
|
|
584
|
+
declare type SerializedStep = {
|
|
585
|
+
id: string;
|
|
586
|
+
description: string;
|
|
587
|
+
inputSchema: string | undefined;
|
|
588
|
+
outputSchema: string | undefined;
|
|
589
|
+
resumeSchema: string | undefined;
|
|
590
|
+
suspendSchema: string | undefined;
|
|
591
|
+
};
|
|
592
|
+
|
|
452
593
|
declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
453
594
|
|
|
454
|
-
export declare function startAsyncVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
595
|
+
export declare function startAsyncVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
455
596
|
inputData?: unknown;
|
|
456
597
|
runtimeContext?: RuntimeContext_2;
|
|
598
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
457
599
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
|
|
458
600
|
|
|
459
601
|
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -461,9 +603,10 @@ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, work
|
|
|
461
603
|
runtimeContext: RuntimeContext;
|
|
462
604
|
}): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
463
605
|
|
|
464
|
-
export declare function startVNextWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
606
|
+
export declare function startVNextWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
465
607
|
inputData?: unknown;
|
|
466
608
|
runtimeContext?: RuntimeContext_2;
|
|
609
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
467
610
|
}): Promise<{
|
|
468
611
|
message: string;
|
|
469
612
|
}>;
|
|
@@ -499,6 +642,7 @@ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId,
|
|
|
499
642
|
agentId: string;
|
|
500
643
|
body: GetBody<'stream'> & {
|
|
501
644
|
resourceid?: string;
|
|
645
|
+
runtimeContext?: string;
|
|
502
646
|
};
|
|
503
647
|
}): Promise<Response | undefined>;
|
|
504
648
|
|
|
@@ -618,7 +762,7 @@ export declare namespace vNextWorkflows {
|
|
|
618
762
|
export {
|
|
619
763
|
getVNextWorkflowsHandler,
|
|
620
764
|
getVNextWorkflowByIdHandler,
|
|
621
|
-
|
|
765
|
+
getVNextWorkflowRunByIdHandler,
|
|
622
766
|
createVNextWorkflowRunHandler,
|
|
623
767
|
startAsyncVNextWorkflowHandler,
|
|
624
768
|
startVNextWorkflowRunHandler,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
4
|
+
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/memory.ts
|
|
8
9
|
var memory_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
10
11
|
createThreadHandler: () => createThreadHandler,
|
|
11
12
|
deleteThreadHandler: () => deleteThreadHandler,
|
|
12
13
|
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
@@ -22,7 +23,7 @@ function getMemoryFromContext({
|
|
|
22
23
|
}) {
|
|
23
24
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
24
25
|
if (agentId && !agent) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
26
27
|
}
|
|
27
28
|
const memory = agent?.getMemory?.() || mastra.getMemory();
|
|
28
29
|
return memory;
|
|
@@ -35,7 +36,7 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
|
|
|
35
36
|
}
|
|
36
37
|
return { result: true };
|
|
37
38
|
} catch (error) {
|
|
38
|
-
return
|
|
39
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
async function getThreadsHandler({
|
|
@@ -46,13 +47,13 @@ async function getThreadsHandler({
|
|
|
46
47
|
try {
|
|
47
48
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
48
49
|
if (!memory) {
|
|
49
|
-
throw new
|
|
50
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
52
53
|
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
53
54
|
return threads;
|
|
54
55
|
} catch (error) {
|
|
55
|
-
return
|
|
56
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
async function getThreadByIdHandler({
|
|
@@ -61,18 +62,18 @@ async function getThreadByIdHandler({
|
|
|
61
62
|
threadId
|
|
62
63
|
}) {
|
|
63
64
|
try {
|
|
64
|
-
|
|
65
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
65
66
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
66
67
|
if (!memory) {
|
|
67
|
-
throw new
|
|
68
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
68
69
|
}
|
|
69
70
|
const thread = await memory.getThreadById({ threadId });
|
|
70
71
|
if (!thread) {
|
|
71
|
-
throw new
|
|
72
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
72
73
|
}
|
|
73
74
|
return thread;
|
|
74
75
|
} catch (error) {
|
|
75
|
-
return
|
|
76
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
async function saveMessagesHandler({
|
|
@@ -83,13 +84,13 @@ async function saveMessagesHandler({
|
|
|
83
84
|
try {
|
|
84
85
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
85
86
|
if (!memory) {
|
|
86
|
-
throw new
|
|
87
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
87
88
|
}
|
|
88
89
|
if (!body?.messages) {
|
|
89
|
-
throw new
|
|
90
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
90
91
|
}
|
|
91
92
|
if (!Array.isArray(body.messages)) {
|
|
92
|
-
throw new
|
|
93
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
93
94
|
}
|
|
94
95
|
const processedMessages = body.messages.map((message) => ({
|
|
95
96
|
...message,
|
|
@@ -99,7 +100,7 @@ async function saveMessagesHandler({
|
|
|
99
100
|
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
100
101
|
return result;
|
|
101
102
|
} catch (error) {
|
|
102
|
-
return
|
|
103
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
async function createThreadHandler({
|
|
@@ -110,9 +111,9 @@ async function createThreadHandler({
|
|
|
110
111
|
try {
|
|
111
112
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
112
113
|
if (!memory) {
|
|
113
|
-
throw new
|
|
114
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
116
117
|
const result = await memory.createThread({
|
|
117
118
|
resourceId: body?.resourceId,
|
|
118
119
|
title: body?.title,
|
|
@@ -121,7 +122,7 @@ async function createThreadHandler({
|
|
|
121
122
|
});
|
|
122
123
|
return result;
|
|
123
124
|
} catch (error) {
|
|
124
|
-
return
|
|
125
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
async function updateThreadHandler({
|
|
@@ -133,17 +134,17 @@ async function updateThreadHandler({
|
|
|
133
134
|
try {
|
|
134
135
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
135
136
|
if (!body) {
|
|
136
|
-
throw new
|
|
137
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
137
138
|
}
|
|
138
139
|
const { title, metadata, resourceId } = body;
|
|
139
140
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
140
|
-
|
|
141
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
141
142
|
if (!memory) {
|
|
142
|
-
throw new
|
|
143
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
143
144
|
}
|
|
144
145
|
const thread = await memory.getThreadById({ threadId });
|
|
145
146
|
if (!thread) {
|
|
146
|
-
throw new
|
|
147
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
147
148
|
}
|
|
148
149
|
const updatedThread = {
|
|
149
150
|
...thread,
|
|
@@ -156,7 +157,7 @@ async function updateThreadHandler({
|
|
|
156
157
|
const result = await memory.saveThread({ thread: updatedThread });
|
|
157
158
|
return result;
|
|
158
159
|
} catch (error) {
|
|
159
|
-
return
|
|
160
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
async function deleteThreadHandler({
|
|
@@ -165,19 +166,19 @@ async function deleteThreadHandler({
|
|
|
165
166
|
threadId
|
|
166
167
|
}) {
|
|
167
168
|
try {
|
|
168
|
-
|
|
169
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
169
170
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
170
171
|
if (!memory) {
|
|
171
|
-
throw new
|
|
172
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
172
173
|
}
|
|
173
174
|
const thread = await memory.getThreadById({ threadId });
|
|
174
175
|
if (!thread) {
|
|
175
|
-
throw new
|
|
176
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
176
177
|
}
|
|
177
178
|
await memory.deleteThread(threadId);
|
|
178
179
|
return { result: "Thread deleted" };
|
|
179
180
|
} catch (error) {
|
|
180
|
-
return
|
|
181
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
async function getMessagesHandler({
|
|
@@ -186,19 +187,19 @@ async function getMessagesHandler({
|
|
|
186
187
|
threadId
|
|
187
188
|
}) {
|
|
188
189
|
try {
|
|
189
|
-
|
|
190
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
190
191
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
191
192
|
if (!memory) {
|
|
192
|
-
throw new
|
|
193
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
193
194
|
}
|
|
194
195
|
const thread = await memory.getThreadById({ threadId });
|
|
195
196
|
if (!thread) {
|
|
196
|
-
throw new
|
|
197
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
197
198
|
}
|
|
198
199
|
const result = await memory.query({ threadId });
|
|
199
200
|
return result;
|
|
200
201
|
} catch (error) {
|
|
201
|
-
return
|
|
202
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
|