@mastra/server 0.0.0-trigger-playground-ui-package-20250506151043 → 0.0.0-vector-query-sources-20250516172905

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 (70) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +161 -13
  3. package/dist/_tsup-dts-rollup.d.ts +161 -13
  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-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  10. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  11. package/dist/{chunk-4BIX6GMY.cjs → chunk-D4IRYCUI.cjs} +72 -26
  12. package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
  13. package/dist/{chunk-3XTEV33Q.js → chunk-EJO45KYT.js} +19 -16
  14. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  15. package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
  16. package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
  17. package/dist/{chunk-CHFORQ7J.cjs → chunk-I2B73Y4I.cjs} +60 -57
  18. package/dist/chunk-LIVAK2DM.js +2001 -0
  19. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  20. package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
  21. package/dist/{chunk-OWNA6I2H.js → chunk-MIQYDLLM.js} +28 -11
  22. package/dist/chunk-MLKGABMK.js +7 -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-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  26. package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
  27. package/dist/chunk-P6SCPDYW.js +500 -0
  28. package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/{chunk-M2RXDCPV.cjs → chunk-UCTEMO2Q.cjs} +76 -59
  30. package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
  31. package/dist/{chunk-Y3SV5XK4.js → chunk-WUC6LSTW.js} +54 -8
  32. package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
  33. package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
  34. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  35. package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  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/logs.cjs +4 -4
  45. package/dist/server/handlers/logs.js +1 -1
  46. package/dist/server/handlers/memory.cjs +9 -9
  47. package/dist/server/handlers/memory.js +1 -1
  48. package/dist/server/handlers/network.cjs +5 -5
  49. package/dist/server/handlers/network.js +1 -1
  50. package/dist/server/handlers/telemetry.cjs +3 -3
  51. package/dist/server/handlers/telemetry.js +1 -1
  52. package/dist/server/handlers/tools.cjs +5 -5
  53. package/dist/server/handlers/tools.js +1 -1
  54. package/dist/server/handlers/utils.cjs +2 -2
  55. package/dist/server/handlers/utils.js +1 -1
  56. package/dist/server/handlers/vNextWorkflows.cjs +11 -11
  57. package/dist/server/handlers/vNextWorkflows.js +1 -1
  58. package/dist/server/handlers/vector.cjs +7 -7
  59. package/dist/server/handlers/vector.js +1 -1
  60. package/dist/server/handlers/voice.cjs +4 -4
  61. package/dist/server/handlers/voice.js +1 -1
  62. package/dist/server/handlers/workflows.cjs +11 -11
  63. package/dist/server/handlers/workflows.js +1 -1
  64. package/dist/server/handlers.cjs +28 -23
  65. package/dist/server/handlers.d.cts +1 -0
  66. package/dist/server/handlers.d.ts +1 -0
  67. package/dist/server/handlers.js +11 -10
  68. package/package.json +7 -5
  69. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  70. package/dist/chunk-OMN3UI6X.js +0 -5576
package/README.md CHANGED
@@ -1,159 +1,72 @@
1
- # @mastra/deployer
1
+ # @mastra/server
2
2
 
3
- Core deployment infrastructure for Mastra applications, handling build, packaging, and deployment processes.
3
+ Typed HTTP handlers and utilities for exposing a `Mastra` instance over HTTP.
4
+ This package powers `mastra dev` and can be added to your own server to provide
5
+ REST and streaming endpoints for agents, workflows, telemetry and more.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  ```bash
8
- npm install @mastra/deployer
10
+ npm install @mastra/server
9
11
  ```
10
12
 
11
- ## Overview
12
-
13
- The `@mastra/deployer` package provides the foundational deployment infrastructure for Mastra applications. It handles:
14
-
15
- - Project building and bundling
16
- - Dependency management
17
- - Environment configuration
18
- - Development and production deployments
19
-
20
13
  ## Usage
21
14
 
22
- ```typescript
23
- import { Deployer } from '@mastra/deployer';
15
+ The handlers are framework agnostic functions which accept a `Mastra` instance
16
+ and a request context. They are typically mounted under a URL prefix within your
17
+ web framework of choice:
24
18
 
25
- // Create a deployer instance
26
- const deployer = new Deployer({
27
- dir: '/path/to/project',
28
- type: 'Deploy', // or 'Dev' for development mode
19
+ ```typescript
20
+ import { Hono } from 'hono';
21
+ import { handlers } from '@mastra/server';
22
+ import { mastra } from './mastra-instance';
23
+
24
+ const app = new Hono();
25
+
26
+ app.get('/mastra/agents', ctx => handlers.agents.getAgentsHandler({ mastra, runtimeContext: ctx }));
27
+ app.post('/mastra/agents/:id/generate', async ctx => {
28
+ const body = await ctx.req.json();
29
+ return handlers.agents.generateHandler({
30
+ mastra,
31
+ runtimeContext: ctx,
32
+ agentId: ctx.req.param('id'),
33
+ body,
34
+ });
29
35
  });
30
36
 
31
- // Install dependencies
32
- await deployer.install();
33
-
34
- // Write package.json
35
- await deployer.writePackageJson();
36
-
37
- // Get Mastra instance
38
- const { mastra } = await deployer.getMastra();
37
+ // Mount additional handlers as required
39
38
  ```
40
39
 
41
- ## Configuration
42
-
43
- ### Required Parameters
44
-
45
- - `dir`: Project directory path
46
- - `type`: Deployment type ('Deploy' or 'Dev')
40
+ Running `mastra dev` starts a local development UI at
41
+ `http://localhost:3000` using these handlers.
47
42
 
48
- ## Features
43
+ ## Available Handler Groups
49
44
 
50
- ### Project Structure Management
45
+ - **Agents** - list defined agents, retrieve metadata, and run `generate`
46
+ or `stream`.
47
+ - **Workflows** - start and inspect workflow runs.
48
+ - **Tools** - discover tools available to the `Mastra` instance.
49
+ - **Memory** - interact with configured memory stores.
50
+ - **Logs** - query runtime logs when a supporting logger transport is used.
51
+ - **Telemetry** - expose metrics produced by the telemetry subsystem.
52
+ - **Networks** - interact with agent networks.
53
+ - **Vector / Voice** - endpoints related to vector stores and voice synthesis.
51
54
 
52
- - Creates and manages `.mastra` directory
53
- - Handles package.json generation and updates
54
- - Manages project dependencies
55
+ Handlers return JSON serialisable data and throw an `HTTPException` (subclass of
56
+ `Error`) when a failure should result in a non-2xx HTTP status.
55
57
 
56
- ### Dependency Management
58
+ ## OpenAPI Spec Generation
57
59
 
58
- - Automatic dependency installation
59
- - Workspace dependency resolution
60
- - Version management for @mastra packages
60
+ The local OpenAPI specification used by the CLI playground and similar tools can
61
+ be refreshed by running:
61
62
 
62
- ### Environment Handling
63
-
64
- - Support for multiple environment files:
65
- - `.env`
66
- - `.env.development`
67
- - `.env.local`
68
- - Environment variable validation and processing
69
-
70
- ### Build Process
71
-
72
- - Project bundling
73
- - Asset management
74
- - Source code transformation
75
-
76
- ### Development Support
77
-
78
- - Development server configuration
79
- - Hot reloading capabilities
80
- - Debug logging
81
-
82
- ## Project Structure
83
-
84
- The deployer creates and manages the following structure:
85
-
86
- ```
87
- your-project/
88
- ├── .mastra/
89
- │ ├── package.json
90
- │ ├── mastra.mjs
91
- │ └── index.mjs
92
- ├── .env
93
- ├── .env.development
94
- ├── .env.local
95
- └── package.json
96
- ```
97
-
98
- ## Package.json Management
99
-
100
- The deployer automatically manages dependencies in the `.mastra/package.json`:
101
-
102
- ```json
103
- {
104
- "name": "server",
105
- "version": "1.0.0",
106
- "type": "module",
107
- "dependencies": {
108
- "@mastra/loggers": "latest",
109
- "hono": "4.6.17",
110
- "@hono/node-server": "^1.13.7",
111
- "superjson": "^2.2.2",
112
- "zod-to-json-schema": "^3.24.1"
113
- }
114
- }
63
+ ```bash
64
+ pnpm run pull:openapispec
115
65
  ```
116
66
 
117
- ## Methods
118
-
119
- ### `install()`
120
-
121
- Installs and updates project dependencies.
122
-
123
- ### `writePackageJson()`
124
-
125
- Generates or updates the package.json in the .mastra directory.
126
-
127
- ### `getMastra()`
128
-
129
- Returns the Mastra instance for the project.
130
-
131
- ### `getMastraPath()`
132
-
133
- Returns the path to the .mastra directory.
134
-
135
- ## Error Handling
136
-
137
- The deployer includes comprehensive error handling for:
138
-
139
- - Dependency installation failures
140
- - File system operations
141
- - Environment configuration issues
142
- - Build process errors
143
-
144
- ## Logging
145
-
146
- Built-in logging support through @mastra/core:
147
-
148
- - Debug information
149
- - Installation progress
150
- - Build status
151
- - Error reporting
67
+ within the `@mastra/server` directory.
152
68
 
153
- ## Related Packages
69
+ ## License
154
70
 
155
- - `@mastra/core`: Core Mastra functionality
156
- - `@mastra/loggers`: Logging infrastructure
157
- - Deployer implementations:
158
- - `@mastra/deployer-cloudflare`
159
- - Other platform-specific deployers
71
+ Released under the Elastic License 2.0. The full license text is available in
72
+ this repository.
@@ -1,27 +1,42 @@
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 type { RuntimeContext } from '@mastra/core/runtime-context';
17
- import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
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';
39
+ import type { VNextWorkflowRuns } from '@mastra/core/storage';
25
40
  import type { Workflow } from '@mastra/core/workflows';
26
41
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows';
27
42
  import { WorkflowResult } from '@mastra/core/workflows/vNext';
@@ -30,6 +45,17 @@ import type { WorkflowRuns } from '@mastra/core/storage';
30
45
  import { ZodType } from 'zod';
31
46
  import { ZodTypeDef } from 'zod';
32
47
 
48
+ export declare namespace a2a {
49
+ export {
50
+ getAgentCardByIdHandler,
51
+ handleTaskSend,
52
+ handleTaskGet,
53
+ handleTaskSendSubscribe,
54
+ handleTaskCancel,
55
+ getAgentExecutionHandler
56
+ }
57
+ }
58
+
33
59
  export declare namespace agents {
34
60
  export {
35
61
  getAgentsHandler,
@@ -46,12 +72,18 @@ export declare interface ApiError extends Error {
46
72
  status?: number;
47
73
  }
48
74
 
75
+ export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
76
+
49
77
  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
78
 
51
79
  export declare interface Context {
52
80
  mastra: Mastra;
53
81
  }
54
82
 
83
+ export declare function convertToCoreMessage(message: Message_2): CoreMessage_2;
84
+
85
+ export declare function createErrorResponse(id: number | string | null, error: JSONRPCError<unknown>): JSONRPCResponse<null, unknown>;
86
+
55
87
  export declare function createIndex({ mastra, vectorName, index, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
56
88
  index: CreateIndexRequest;
57
89
  }): Promise<{
@@ -68,6 +100,15 @@ export declare function createRunHandler({ mastra, workflowId, runId: prevRunId,
68
100
  runId: string;
69
101
  }>;
70
102
 
103
+ export declare function createSuccessResponse<T>(id: number | string | null, result: T): JSONRPCResponse<T>;
104
+
105
+ export declare function createTaskContext({ task, userMessage, history, activeCancellations, }: {
106
+ task: Task;
107
+ userMessage: Message_2;
108
+ history: Message_2[];
109
+ activeCancellations: Set<string>;
110
+ }): TaskContext;
111
+
71
112
  export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
72
113
  body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
73
114
  resourceId?: string;
@@ -98,15 +139,17 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
98
139
  metric: string | undefined;
99
140
  }>;
100
141
 
101
- export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
142
+ export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
102
143
  agentId?: string;
103
144
  data: any;
104
- runtimeContext: RuntimeContext;
145
+ runtimeContext: RuntimeContext_2;
146
+ runtimeContextFromRequest: Record<string, unknown>;
105
147
  }): Promise<any>;
106
148
 
107
- export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
149
+ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
108
150
  data?: unknown;
109
- runtimeContext: RuntimeContext;
151
+ runtimeContext: RuntimeContext_2;
152
+ runtimeContextFromRequest: Record<string, unknown>;
110
153
  }) => Promise<any>;
111
154
 
112
155
  export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
@@ -114,6 +157,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
114
157
  agentId: string;
115
158
  body: GetBody<'generate'> & {
116
159
  resourceid?: string;
160
+ runtimeContext?: Record<string, unknown>;
117
161
  };
118
162
  }): Promise<GenerateTextResult<any, any>>;
119
163
 
@@ -141,10 +185,32 @@ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }
141
185
  name: any;
142
186
  instructions: string;
143
187
  tools: any;
188
+ workflows: {};
144
189
  provider: string;
145
190
  modelId: string;
146
191
  }>;
147
192
 
193
+ export declare function getAgentCardByIdHandler({ mastra, agentId, executionUrl, provider, version, runtimeContext, }: Context & {
194
+ runtimeContext: RuntimeContext;
195
+ agentId: keyof ReturnType<typeof mastra.getAgents>;
196
+ executionUrl?: string;
197
+ version?: string;
198
+ provider?: {
199
+ organization: string;
200
+ url: string;
201
+ };
202
+ }): Promise<AgentCard>;
203
+
204
+ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, runtimeContext, method, params, taskStore, logger, }: Context & {
205
+ requestId: string;
206
+ runtimeContext: RuntimeContext;
207
+ agentId: string;
208
+ method: 'tasks/send' | 'tasks/sendSubscribe' | 'tasks/get' | 'tasks/cancel';
209
+ params: TaskSendParams | TaskQueryParams | TaskIdParams;
210
+ taskStore?: InMemoryTaskStore;
211
+ logger?: Logger;
212
+ }): Promise<any>;
213
+
148
214
  export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
149
215
  runtimeContext: RuntimeContext;
150
216
  }): Promise<any>;
@@ -187,7 +253,9 @@ export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryC
187
253
  result: boolean;
188
254
  }>;
189
255
 
190
- export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
256
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
257
+ limit?: number;
258
+ }): Promise<{
191
259
  messages: CoreMessage[];
192
260
  uiMessages: Message[];
193
261
  }>;
@@ -240,7 +308,7 @@ export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext,
240
308
  export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
241
309
 
242
310
  export declare function getVNextWorkflowByIdHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<{
243
- steps: any;
311
+ steps: SerializedStep[];
244
312
  name: string | undefined;
245
313
  stepGraph: SerializedStepFlowEntry[];
246
314
  inputSchema: string | undefined;
@@ -255,7 +323,7 @@ export declare function getVNextWorkflowRunsHandler({ mastra, workflowId, fromDa
255
323
  limit?: number;
256
324
  offset?: number;
257
325
  resourceId?: string;
258
- }): Promise<WorkflowRuns>;
326
+ }): Promise<VNextWorkflowRuns>;
259
327
 
260
328
  export declare function getVNextWorkflowsHandler({ mastra }: VNextWorkflowContext): Promise<any>;
261
329
 
@@ -283,6 +351,48 @@ export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promis
283
351
 
284
352
  export declare function handleError(error: unknown, defaultMessage: string): never;
285
353
 
354
+ export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
355
+ requestId: string;
356
+ taskStore: InMemoryTaskStore;
357
+ agentId: string;
358
+ taskId: string;
359
+ logger?: Logger;
360
+ }): Promise<JSONRPCResponse<Task, unknown>>;
361
+
362
+ export declare function handleTaskGet({ requestId, taskStore, agentId, taskId, }: {
363
+ requestId: string;
364
+ taskStore: InMemoryTaskStore;
365
+ agentId: string;
366
+ taskId: string;
367
+ }): Promise<JSONRPCResponse<TaskAndHistory, unknown>>;
368
+
369
+ export declare function handleTaskSend({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
370
+ requestId: string;
371
+ params: TaskSendParams;
372
+ taskStore: InMemoryTaskStore;
373
+ agent: Agent;
374
+ logger?: Logger;
375
+ runtimeContext: RuntimeContext;
376
+ }): Promise<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown>>;
377
+
378
+ export declare function handleTaskSendSubscribe({ requestId, params, taskStore, agent, logger, runtimeContext, }: {
379
+ requestId: string;
380
+ params: TaskSendParams;
381
+ taskStore: InMemoryTaskStore;
382
+ agent: Agent;
383
+ logger?: Logger;
384
+ runtimeContext: RuntimeContext;
385
+ }): AsyncGenerator<JSONRPCResponse<null, unknown> | JSONRPCResponse<Task, unknown> | JSONRPCResponse< {
386
+ state: string;
387
+ message: {
388
+ role: string;
389
+ parts: {
390
+ type: string;
391
+ text: string;
392
+ }[];
393
+ };
394
+ }, unknown>, void, unknown>;
395
+
286
396
  /**
287
397
  * `HTTPException` must be used when a fatal error such as authentication failure occurs.
288
398
  *
@@ -344,8 +454,31 @@ declare type HTTPExceptionOptions = {
344
454
  */
345
455
  declare type InfoStatusCode = 100 | 101 | 102 | 103;
346
456
 
457
+ export declare class InMemoryTaskStore {
458
+ private store;
459
+ activeCancellations: Set<string>;
460
+ load({ agentId, taskId }: {
461
+ agentId: string;
462
+ taskId: string;
463
+ }): Promise<TaskAndHistory | null>;
464
+ save({ agentId, data }: {
465
+ agentId: string;
466
+ data: TaskAndHistory;
467
+ }): Promise<void>;
468
+ }
469
+
347
470
  export declare function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>): Promise<string[]>;
348
471
 
472
+ export declare function loadOrCreateTaskAndHistory({ agentId, taskId, taskStore, message, sessionId, metadata, logger, }: {
473
+ agentId: string;
474
+ taskId: string;
475
+ taskStore: InMemoryTaskStore;
476
+ message: Message_2;
477
+ sessionId?: string | null;
478
+ metadata?: Record<string, unknown> | null;
479
+ logger?: Logger;
480
+ }): Promise<TaskAndHistory>;
481
+
349
482
  export declare namespace logs {
350
483
  export {
351
484
  getLogsHandler,
@@ -393,6 +526,8 @@ declare interface NetworkContext extends Context {
393
526
  runtimeContext: RuntimeContext;
394
527
  }
395
528
 
529
+ export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: Logger): JSONRPCResponse<null, unknown>;
530
+
396
531
  declare interface QueryRequest {
397
532
  indexName: string;
398
533
  queryVector: number[];
@@ -407,12 +542,13 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
407
542
 
408
543
  declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
409
544
 
410
- export declare function resumeAsyncVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: VNextWorkflowContext & {
545
+ export declare function resumeAsyncVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, runtimeContextFromRequest, }: VNextWorkflowContext & {
411
546
  body: {
412
547
  step: string | string[];
413
548
  resumeData?: unknown;
414
549
  };
415
550
  runtimeContext?: RuntimeContext_2;
551
+ runtimeContextFromRequest?: Record<string, unknown>;
416
552
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
417
553
 
418
554
  export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
@@ -449,11 +585,21 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
449
585
  };
450
586
  }): Promise<MessageType[]>;
451
587
 
588
+ declare type SerializedStep = {
589
+ id: string;
590
+ description: string;
591
+ inputSchema: string | undefined;
592
+ outputSchema: string | undefined;
593
+ resumeSchema: string | undefined;
594
+ suspendSchema: string | undefined;
595
+ };
596
+
452
597
  declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
453
598
 
454
- export declare function startAsyncVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
599
+ export declare function startAsyncVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
455
600
  inputData?: unknown;
456
601
  runtimeContext?: RuntimeContext_2;
602
+ runtimeContextFromRequest?: Record<string, unknown>;
457
603
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
458
604
 
459
605
  export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
@@ -461,9 +607,10 @@ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, work
461
607
  runtimeContext: RuntimeContext;
462
608
  }): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
463
609
 
464
- export declare function startVNextWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
610
+ export declare function startVNextWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
465
611
  inputData?: unknown;
466
612
  runtimeContext?: RuntimeContext_2;
613
+ runtimeContextFromRequest?: Record<string, unknown>;
467
614
  }): Promise<{
468
615
  message: string;
469
616
  }>;
@@ -499,6 +646,7 @@ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId,
499
646
  agentId: string;
500
647
  body: GetBody<'stream'> & {
501
648
  resourceid?: string;
649
+ runtimeContext?: string;
502
650
  };
503
651
  }): Promise<Response | undefined>;
504
652