@mastra/server 0.0.0-commonjs-20250414101718 → 0.0.0-course-20250527170450

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.
Files changed (78) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +310 -51
  3. package/dist/_tsup-dts-rollup.d.ts +310 -51
  4. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  5. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  6. package/dist/chunk-5SN4U5AC.cjs +508 -0
  7. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-SKBVVI24.cjs → chunk-7DLZLWJV.cjs} +12 -11
  10. package/dist/chunk-A3KDUGS7.cjs +239 -0
  11. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  12. package/dist/{chunk-YANVFOYA.js → chunk-C7564HUT.js} +56 -34
  13. package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
  14. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  15. package/dist/{chunk-3RVHWGWO.js → chunk-HFWCEP5S.js} +6 -12
  16. package/dist/chunk-J3PKLB3A.js +231 -0
  17. package/dist/chunk-KUNQFY2W.js +365 -0
  18. package/dist/chunk-LIVAK2DM.js +2001 -0
  19. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  20. package/dist/{chunk-CWSDZEZG.cjs → chunk-MHKNLNAN.cjs} +15 -12
  21. package/dist/chunk-MLKGABMK.js +7 -0
  22. package/dist/chunk-MMO2HDM6.cjs +378 -0
  23. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  24. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  25. package/dist/{chunk-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
  26. package/dist/chunk-P6SCPDYW.js +500 -0
  27. package/dist/{chunk-YNSGUC2O.js → chunk-TJKLBTFB.js} +23 -7
  28. package/dist/chunk-VPNDC2DI.cjs +148 -0
  29. package/dist/{chunk-OPP7H5TW.js → chunk-W7VCKPAD.js} +77 -62
  30. package/dist/{chunk-3EJZQ6TQ.js → chunk-WFBJJNCK.js} +6 -5
  31. package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
  32. package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
  33. package/dist/chunk-YIOVBYZH.cjs +332 -0
  34. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  35. package/dist/{chunk-4C3EPMMF.cjs → chunk-ZE5AAC4I.cjs} +40 -24
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  45. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  46. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.js +1 -0
  48. package/dist/server/handlers/logs.cjs +4 -4
  49. package/dist/server/handlers/logs.js +1 -1
  50. package/dist/server/handlers/memory.cjs +9 -9
  51. package/dist/server/handlers/memory.js +1 -1
  52. package/dist/server/handlers/network.cjs +5 -5
  53. package/dist/server/handlers/network.js +1 -1
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vector.cjs +7 -7
  61. package/dist/server/handlers/vector.js +1 -1
  62. package/dist/server/handlers/voice.cjs +4 -4
  63. package/dist/server/handlers/voice.js +1 -1
  64. package/dist/server/handlers/workflows.cjs +17 -13
  65. package/dist/server/handlers/workflows.d.cts +3 -2
  66. package/dist/server/handlers/workflows.d.ts +3 -2
  67. package/dist/server/handlers/workflows.js +1 -1
  68. package/dist/server/handlers.cjs +33 -23
  69. package/dist/server/handlers.d.cts +2 -0
  70. package/dist/server/handlers.d.ts +2 -0
  71. package/dist/server/handlers.js +11 -9
  72. package/package.json +8 -6
  73. package/dist/chunk-67WTHYAV.js +0 -156
  74. package/dist/chunk-B64YROKU.cjs +0 -317
  75. package/dist/chunk-JLDXUWK7.cjs +0 -126
  76. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  77. package/dist/chunk-VK6FX47H.js +0 -5576
  78. package/dist/chunk-Z46X3YCB.cjs +0 -164
@@ -1,27 +1,61 @@
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
- import type { Container } from '@mastra/core/di';
5
6
  import { CoreMessage } from 'ai';
7
+ import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
6
8
  import { EvalRow } from '@mastra/core/storage';
7
9
  import { GenerateObjectResult } from 'ai';
8
10
  import { GenerateTextResult } from 'ai';
11
+ import type { IMastraLogger } from '@mastra/core/logger';
12
+ import type { JSONRPCError } from '@mastra/core/a2a';
13
+ import { JSONRPCResponse } from '@mastra/core/a2a';
14
+ import { LegacyStep } from '@mastra/core/workflows/legacy';
15
+ import type { LegacyWorkflow } from '@mastra/core/workflows/legacy';
16
+ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
17
+ import type { LegacyWorkflowRuns } from '@mastra/core/storage';
9
18
  import type { Mastra } from '@mastra/core/mastra';
10
19
  import type { MastraMemory } from '@mastra/core/memory';
11
20
  import { Message } from 'ai';
21
+ import type { Message as Message_2 } from '@mastra/core/a2a';
12
22
  import { MessageType } from '@mastra/core/memory';
13
23
  import type { QueryResult } from '@mastra/core/vector';
14
24
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
25
+ import { RuntimeContext } from '@mastra/core/runtime-context';
26
+ import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
27
+ import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
15
28
  import { Step } from '@mastra/core/workflows';
16
- import { StepExecutionContext } from '@mastra/core/workflows';
17
- import { StepGraph } from '@mastra/core/workflows';
29
+ import { StepExecutionContext } from '@mastra/core/workflows/legacy';
30
+ import { StepGraph } from '@mastra/core/workflows/legacy';
18
31
  import { StorageThreadType } from '@mastra/core/memory';
32
+ import { Task } from '@mastra/core/a2a';
33
+ import { TaskAndHistory } from '@mastra/core/a2a';
34
+ import type { TaskContext } from '@mastra/core/a2a';
35
+ import type { TaskIdParams } from '@mastra/core/a2a';
36
+ import type { TaskQueryParams } from '@mastra/core/a2a';
37
+ import type { TaskSendParams } from '@mastra/core/a2a';
38
+ import type { TaskStatus } from '@mastra/core/a2a';
19
39
  import type { ToolAction } from '@mastra/core/tools';
20
40
  import type { VercelTool } from '@mastra/core/tools';
41
+ import { WatchEvent } from '@mastra/core/workflows';
21
42
  import type { Workflow } from '@mastra/core/workflows';
22
- import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows';
23
- import { WorkflowRunResult } from '@mastra/core/workflows';
43
+ import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
44
+ import { WorkflowResult } from '@mastra/core/workflows';
24
45
  import type { WorkflowRuns } from '@mastra/core/storage';
46
+ import { ZodType } from 'zod';
47
+ import { ZodTypeDef } from 'zod';
48
+
49
+ export declare namespace a2a {
50
+ export {
51
+ getAgentCardByIdHandler,
52
+ handleTaskSend,
53
+ handleTaskGet,
54
+ handleTaskSendSubscribe,
55
+ handleTaskCancel,
56
+ getAgentExecutionHandler
57
+ }
58
+ }
25
59
 
26
60
  export declare namespace agents {
27
61
  export {
@@ -39,12 +73,18 @@ export declare interface ApiError extends Error {
39
73
  status?: number;
40
74
  }
41
75
 
76
+ export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
77
+
42
78
  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;
43
79
 
44
80
  export declare interface Context {
45
81
  mastra: Mastra;
46
82
  }
47
83
 
84
+ export declare function convertToCoreMessage(message: Message_2): CoreMessage_2;
85
+
86
+ export declare function createErrorResponse(id: number | string | null, error: JSONRPCError<unknown>): JSONRPCResponse<null, unknown>;
87
+
48
88
  export declare function createIndex({ mastra, vectorName, index, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
49
89
  index: CreateIndexRequest;
50
90
  }): Promise<{
@@ -57,16 +97,29 @@ declare interface CreateIndexRequest {
57
97
  metric?: 'cosine' | 'euclidean' | 'dotproduct';
58
98
  }
59
99
 
60
- export declare function createRunHandler({ mastra, workflowId, runId: prevRunId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<{
100
+ export declare function createLegacyWorkflowRunHandler({ mastra, workflowId, runId: prevRunId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<{
61
101
  runId: string;
62
102
  }>;
63
103
 
104
+ export declare function createSuccessResponse<T>(id: number | string | null, result: T): JSONRPCResponse<T>;
105
+
106
+ export declare function createTaskContext({ task, userMessage, history, activeCancellations, }: {
107
+ task: Task;
108
+ userMessage: Message_2;
109
+ history: Message_2[];
110
+ activeCancellations: Set<string>;
111
+ }): TaskContext;
112
+
64
113
  export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
65
114
  body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
66
115
  resourceId?: string;
67
116
  };
68
117
  }): Promise<StorageThreadType>;
69
118
 
119
+ export declare function createWorkflowRunHandler({ mastra, workflowId, runId: prevRunId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
120
+ runId: string;
121
+ }>;
122
+
70
123
  export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
71
124
  indexName?: string;
72
125
  }): Promise<{
@@ -87,25 +140,30 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
87
140
  metric: string | undefined;
88
141
  }>;
89
142
 
90
- export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
143
+ export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
91
144
  agentId?: string;
92
145
  data: any;
146
+ runtimeContext: RuntimeContext_2;
147
+ runtimeContextFromRequest: Record<string, unknown>;
93
148
  }): Promise<any>;
94
149
 
95
- export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
150
+ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
96
151
  data?: unknown;
152
+ runtimeContext: RuntimeContext_2;
153
+ runtimeContextFromRequest: Record<string, unknown>;
97
154
  }) => Promise<any>;
98
155
 
99
- export declare function generateHandler({ mastra, container, agentId, body, }: Context & {
100
- container: Container;
156
+ export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
157
+ runtimeContext: RuntimeContext;
101
158
  agentId: string;
102
159
  body: GetBody<'generate'> & {
103
160
  resourceid?: string;
161
+ runtimeContext?: Record<string, unknown>;
104
162
  };
105
163
  }): Promise<GenerateTextResult<any, any>>;
106
164
 
107
- export declare function generateHandler_alias_1({ mastra, container, networkId, body, }: NetworkContext & {
108
- container: Container;
165
+ export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
166
+ runtimeContext: RuntimeContext;
109
167
  body: {
110
168
  messages?: Parameters<AgentNetwork['generate']>[0];
111
169
  } & Parameters<AgentNetwork['generate']>[1];
@@ -119,21 +177,46 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
119
177
  text?: string;
120
178
  speakerId?: string;
121
179
  };
122
- }): Promise<{
123
- audioData: Buffer<ArrayBuffer>;
124
- }>;
180
+ }): Promise<NodeJS.ReadableStream>;
125
181
 
126
- export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
182
+ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
183
+ runtimeContext: RuntimeContext;
127
184
  agentId: string;
128
185
  }): Promise<{
129
186
  name: any;
130
187
  instructions: string;
131
188
  tools: any;
189
+ workflows: {};
132
190
  provider: string;
133
191
  modelId: string;
192
+ defaultGenerateOptions: any;
193
+ defaultStreamOptions: any;
134
194
  }>;
135
195
 
136
- export declare function getAgentsHandler({ mastra }: Context): Promise<any>;
196
+ export declare function getAgentCardByIdHandler({ mastra, agentId, executionUrl, provider, version, runtimeContext, }: Context & {
197
+ runtimeContext: RuntimeContext;
198
+ agentId: keyof ReturnType<typeof mastra.getAgents>;
199
+ executionUrl?: string;
200
+ version?: string;
201
+ provider?: {
202
+ organization: string;
203
+ url: string;
204
+ };
205
+ }): Promise<AgentCard>;
206
+
207
+ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, runtimeContext, method, params, taskStore, logger, }: Context & {
208
+ requestId: string;
209
+ runtimeContext: RuntimeContext;
210
+ agentId: string;
211
+ method: 'tasks/send' | 'tasks/sendSubscribe' | 'tasks/get' | 'tasks/cancel';
212
+ params: TaskSendParams | TaskQueryParams | TaskIdParams;
213
+ taskStore?: InMemoryTaskStore;
214
+ logger?: IMastraLogger;
215
+ }): Promise<any>;
216
+
217
+ export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
218
+ runtimeContext: RuntimeContext;
219
+ }): Promise<any>;
137
220
 
138
221
  declare type GetBody<T extends keyof Agent & {
139
222
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -141,7 +224,8 @@ declare type GetBody<T extends keyof Agent & {
141
224
  messages: Parameters<Agent[T]>[0];
142
225
  } & Parameters<Agent[T]>[1];
143
226
 
144
- export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context & {
227
+ export declare function getEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
228
+ runtimeContext: RuntimeContext;
145
229
  agentId: string;
146
230
  }): Promise<{
147
231
  id: string;
@@ -150,7 +234,30 @@ export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context &
150
234
  evals: EvalRow[];
151
235
  }>;
152
236
 
153
- export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Context & {
237
+ export declare function getLegacyWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{
238
+ stepGraph: StepGraph;
239
+ stepSubscriberGraph: Record<string, StepGraph>;
240
+ serializedStepGraph: StepGraph;
241
+ serializedStepSubscriberGraph: Record<string, StepGraph>;
242
+ name: string;
243
+ triggerSchema: string | undefined;
244
+ steps: any;
245
+ }>;
246
+
247
+ export declare function getLegacyWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<LegacyWorkflow['getRun']>>;
248
+
249
+ export declare function getLegacyWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext & {
250
+ fromDate?: Date;
251
+ toDate?: Date;
252
+ limit?: number;
253
+ offset?: number;
254
+ resourceId?: string;
255
+ }): Promise<LegacyWorkflowRuns>;
256
+
257
+ export declare function getLegacyWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
258
+
259
+ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
260
+ runtimeContext: RuntimeContext;
154
261
  agentId: string;
155
262
  }): Promise<{
156
263
  id: string;
@@ -159,7 +266,7 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Contex
159
266
  evals: EvalRow[];
160
267
  }>;
161
268
 
162
- export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<BaseLogMessage[] | undefined>;
269
+ export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<any[]>;
163
270
 
164
271
  export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
165
272
 
@@ -171,12 +278,14 @@ export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryC
171
278
  result: boolean;
172
279
  }>;
173
280
 
174
- export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
281
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
282
+ limit?: number;
283
+ }): Promise<{
175
284
  messages: CoreMessage[];
176
285
  uiMessages: Message[];
177
286
  }>;
178
287
 
179
- export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<NetworkContext, 'mastra' | 'networkId'>): Promise<{
288
+ export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
180
289
  id: string;
181
290
  name: string;
182
291
  instructions: string;
@@ -191,7 +300,7 @@ export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<Networ
191
300
  };
192
301
  }>;
193
302
 
194
- export declare function getNetworksHandler({ mastra }: Pick<NetworkContext, 'mastra'>): Promise<{
303
+ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'runtimeContext'>): Promise<{
195
304
  id: string;
196
305
  name: string;
197
306
  instructions: string;
@@ -223,24 +332,71 @@ export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext,
223
332
 
224
333
  export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
225
334
 
226
- export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{
227
- stepGraph: StepGraph;
228
- stepSubscriberGraph: Record<string, StepGraph>;
229
- serializedStepGraph: StepGraph;
230
- serializedStepSubscriberGraph: Record<string, StepGraph>;
231
- name: string;
232
- triggerSchema: string | undefined;
233
- steps: any;
335
+ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
336
+ steps: SerializedStep[];
337
+ name: string | undefined;
338
+ description: string | undefined;
339
+ stepGraph: SerializedStepFlowEntry[];
340
+ inputSchema: string | undefined;
341
+ outputSchema: string | undefined;
234
342
  }>;
235
343
 
236
- export declare function getWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getRun']>>;
344
+ export declare function getWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>>;
237
345
 
238
- export declare function getWorkflowRunsHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowRuns>;
346
+ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext_3 & {
347
+ fromDate?: Date;
348
+ toDate?: Date;
349
+ limit?: number;
350
+ offset?: number;
351
+ resourceId?: string;
352
+ }): Promise<WorkflowRuns>;
239
353
 
240
- export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
354
+ export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
241
355
 
242
356
  export declare function handleError(error: unknown, defaultMessage: string): never;
243
357
 
358
+ export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
359
+ requestId: string;
360
+ taskStore: InMemoryTaskStore;
361
+ agentId: string;
362
+ taskId: string;
363
+ logger?: IMastraLogger;
364
+ }): Promise<JSONRPCResponse<Task, unknown>>;
365
+
366
+ export declare function handleTaskGet({ requestId, taskStore, agentId, taskId, }: {
367
+ requestId: string;
368
+ taskStore: InMemoryTaskStore;
369
+ agentId: string;
370
+ taskId: string;
371
+ }): Promise<JSONRPCResponse<TaskAndHistory, unknown>>;
372
+
373
+ export declare function handleTaskSend({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
374
+ requestId: string;
375
+ params: TaskSendParams;
376
+ taskStore: InMemoryTaskStore;
377
+ agent: Agent;
378
+ logger?: IMastraLogger;
379
+ runtimeContext: RuntimeContext;
380
+ }): Promise<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown>>;
381
+
382
+ export declare function handleTaskSendSubscribe({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
383
+ requestId: string;
384
+ params: TaskSendParams;
385
+ taskStore: InMemoryTaskStore;
386
+ agent: Agent;
387
+ logger?: IMastraLogger;
388
+ runtimeContext: RuntimeContext;
389
+ }): AsyncGenerator<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown> | JSONRPCResponse< {
390
+ state: string;
391
+ message: {
392
+ role: string;
393
+ parts: {
394
+ type: string;
395
+ text: string;
396
+ }[];
397
+ };
398
+ }, unknown>, void, unknown>;
399
+
244
400
  /**
245
401
  * `HTTPException` must be used when a fatal error such as authentication failure occurs.
246
402
  *
@@ -302,8 +458,46 @@ declare type HTTPExceptionOptions = {
302
458
  */
303
459
  declare type InfoStatusCode = 100 | 101 | 102 | 103;
304
460
 
461
+ export declare class InMemoryTaskStore {
462
+ private store;
463
+ activeCancellations: Set<string>;
464
+ load({ agentId, taskId }: {
465
+ agentId: string;
466
+ taskId: string;
467
+ }): Promise<TaskAndHistory | null>;
468
+ save({ agentId, data }: {
469
+ agentId: string;
470
+ data: TaskAndHistory;
471
+ }): Promise<void>;
472
+ }
473
+
474
+ export declare namespace legacyWorkflows {
475
+ export {
476
+ getLegacyWorkflowsHandler,
477
+ getLegacyWorkflowByIdHandler,
478
+ startAsyncLegacyWorkflowHandler,
479
+ getLegacyWorkflowRunHandler,
480
+ createLegacyWorkflowRunHandler,
481
+ startLegacyWorkflowRunHandler,
482
+ watchLegacyWorkflowHandler,
483
+ resumeAsyncLegacyWorkflowHandler,
484
+ resumeLegacyWorkflowHandler,
485
+ getLegacyWorkflowRunsHandler
486
+ }
487
+ }
488
+
305
489
  export declare function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>): Promise<string[]>;
306
490
 
491
+ export declare function loadOrCreateTaskAndHistory({ agentId, taskId, taskStore, message, sessionId, metadata, logger, }: {
492
+ agentId: string;
493
+ taskId: string;
494
+ taskStore: InMemoryTaskStore;
495
+ message: Message_2;
496
+ sessionId?: string | null;
497
+ metadata?: Record<string, unknown> | null;
498
+ logger?: IMastraLogger;
499
+ }): Promise<TaskAndHistory>;
500
+
307
501
  export declare namespace logs {
308
502
  export {
309
503
  getLogsHandler,
@@ -348,8 +542,11 @@ export declare namespace network {
348
542
 
349
543
  declare interface NetworkContext extends Context {
350
544
  networkId?: string;
545
+ runtimeContext: RuntimeContext;
351
546
  }
352
547
 
548
+ export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: IMastraLogger): JSONRPCResponse<null, unknown>;
549
+
353
550
  declare interface QueryRequest {
354
551
  indexName: string;
355
552
  queryVector: number[];
@@ -364,20 +561,39 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
364
561
 
365
562
  declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
366
563
 
367
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
564
+ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
368
565
  body: {
369
566
  stepId: string;
370
567
  context: any;
371
568
  };
372
- container: Container;
373
- }): Promise<Omit<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
569
+ runtimeContext: RuntimeContext;
570
+ }): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
374
571
 
375
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
572
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, runtimeContextFromRequest, }: WorkflowContext_3 & {
573
+ body: {
574
+ step: string | string[];
575
+ resumeData?: unknown;
576
+ };
577
+ runtimeContext?: RuntimeContext_2;
578
+ runtimeContextFromRequest?: Record<string, unknown>;
579
+ }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
580
+
581
+ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
376
582
  body: {
377
583
  stepId: string;
378
584
  context: any;
379
585
  };
380
- container: Container;
586
+ runtimeContext: RuntimeContext;
587
+ }): Promise<{
588
+ message: string;
589
+ }>;
590
+
591
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
592
+ body: {
593
+ step: string | string[];
594
+ resumeData?: unknown;
595
+ };
596
+ runtimeContext?: RuntimeContext_2;
381
597
  }): Promise<{
382
598
  message: string;
383
599
  }>;
@@ -388,16 +604,39 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
388
604
  };
389
605
  }): Promise<MessageType[]>;
390
606
 
607
+ declare type SerializedStep = {
608
+ id: string;
609
+ description: string;
610
+ inputSchema: string | undefined;
611
+ outputSchema: string | undefined;
612
+ resumeSchema: string | undefined;
613
+ suspendSchema: string | undefined;
614
+ };
615
+
391
616
  declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
392
617
 
393
- export declare function startAsyncWorkflowHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
618
+ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
394
619
  triggerData?: unknown;
395
- container: Container;
396
- }): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
620
+ runtimeContext: RuntimeContext;
621
+ }): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
397
622
 
398
- export declare function startWorkflowRunHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
623
+ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
624
+ inputData?: unknown;
625
+ runtimeContext?: RuntimeContext_2;
626
+ runtimeContextFromRequest?: Record<string, unknown>;
627
+ }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
628
+
629
+ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
399
630
  triggerData?: unknown;
400
- container: Container;
631
+ runtimeContext: RuntimeContext;
632
+ }): Promise<{
633
+ message: string;
634
+ }>;
635
+
636
+ export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
637
+ inputData?: unknown;
638
+ runtimeContext?: RuntimeContext_2;
639
+ runtimeContextFromRequest?: Record<string, unknown>;
401
640
  }): Promise<{
402
641
  message: string;
403
642
  }>;
@@ -421,21 +660,31 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
421
660
  traceCount: number;
422
661
  }>;
423
662
 
424
- export declare function streamGenerateHandler({ mastra, container, agentId, body, }: Context & {
425
- container: Container;
663
+ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
664
+ runtimeContext: RuntimeContext;
426
665
  agentId: string;
427
666
  body: GetBody<'stream'> & {
428
667
  resourceid?: string;
668
+ runtimeContext?: string;
429
669
  };
430
670
  }): Promise<Response | undefined>;
431
671
 
432
- export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, container, }: NetworkContext & {
433
- container: Container;
672
+ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, runtimeContext, }: NetworkContext & {
673
+ runtimeContext: RuntimeContext;
434
674
  body: {
435
675
  messages?: Parameters<AgentNetwork['stream']>[0];
436
676
  } & Parameters<AgentNetwork['stream']>[1];
437
677
  }): Promise<Response>;
438
678
 
679
+ export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
680
+ inputData?: unknown;
681
+ runtimeContext?: RuntimeContext_2;
682
+ runtimeContextFromRequest?: Record<string, unknown>;
683
+ }): {
684
+ stream: globalThis.ReadableStream<WatchEvent>;
685
+ getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
686
+ };
687
+
439
688
  declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
440
689
 
441
690
  export declare namespace telemetry {
@@ -452,6 +701,8 @@ declare interface TelemetryContext extends Context {
452
701
  page?: number;
453
702
  perPage?: number;
454
703
  attribute?: string | string[];
704
+ fromDate?: Date;
705
+ toDate?: Date;
455
706
  };
456
707
  }
457
708
 
@@ -546,22 +797,30 @@ declare interface VoiceContext extends Context {
546
797
  agentId?: string;
547
798
  }
548
799
 
549
- export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
800
+ export declare function watchLegacyWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
801
+
802
+ export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
550
803
 
551
804
  declare interface WorkflowContext extends Context {
552
805
  workflowId?: string;
553
806
  runId?: string;
554
807
  }
555
808
 
809
+ declare interface WorkflowContext_3 extends Context {
810
+ workflowId?: string;
811
+ runId?: string;
812
+ }
813
+
556
814
  export declare namespace workflows {
557
815
  export {
558
816
  getWorkflowsHandler,
559
817
  getWorkflowByIdHandler,
818
+ getWorkflowRunByIdHandler,
819
+ createWorkflowRunHandler,
560
820
  startAsyncWorkflowHandler,
561
- getWorkflowRunHandler,
562
- createRunHandler,
563
821
  startWorkflowRunHandler,
564
822
  watchWorkflowHandler,
823
+ streamWorkflowHandler,
565
824
  resumeAsyncWorkflowHandler,
566
825
  resumeWorkflowHandler,
567
826
  getWorkflowRunsHandler