@mastra/server 0.0.0-switch-to-core-20250424015131 → 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.
- package/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +258 -13
- package/dist/_tsup-dts-rollup.d.ts +258 -13
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- 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-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-RE6YL32K.js → chunk-C7564HUT.js} +52 -30
- package/dist/chunk-D4IRYCUI.cjs +235 -0
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-LFOBHRFO.js → chunk-EJO45KYT.js} +35 -20
- 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-TZK63M5N.cjs → chunk-I2B73Y4I.cjs} +76 -61
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-7IWQE76Z.cjs → chunk-MHKNLNAN.cjs} +13 -10
- package/dist/chunk-MIQYDLLM.js +329 -0
- 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-WTHDCRMY.js → chunk-OR3CIE2H.js} +7 -4
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/chunk-UCTEMO2Q.cjs +341 -0
- package/dist/{chunk-FPIWDH5Y.cjs → chunk-VPNDC2DI.cjs} +62 -40
- package/dist/chunk-WUC6LSTW.js +227 -0
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- 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 +46 -0
- package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
- package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
- package/dist/server/handlers/vNextWorkflows.js +1 -0
- 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 +31 -21
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +8 -6
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-HCOPJZ4A.cjs +0 -164
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-R4J7XQYU.js +0 -156
package/README.md
CHANGED
|
@@ -1,159 +1,72 @@
|
|
|
1
|
-
# @mastra/
|
|
1
|
+
# @mastra/server
|
|
2
2
|
|
|
3
|
-
|
|
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/
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
##
|
|
43
|
+
## Available Handler Groups
|
|
49
44
|
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
58
|
+
## OpenAPI Spec Generation
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
69
|
+
## License
|
|
154
70
|
|
|
155
|
-
|
|
156
|
-
|
|
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,60 @@
|
|
|
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';
|
|
19
|
+
import { NewStep } from '@mastra/core/workflows/vNext';
|
|
20
|
+
import type { NewWorkflow } from '@mastra/core/workflows/vNext';
|
|
12
21
|
import type { QueryResult } from '@mastra/core/vector';
|
|
13
22
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
14
|
-
import
|
|
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';
|
|
15
26
|
import { Step } from '@mastra/core/workflows';
|
|
16
27
|
import { StepExecutionContext } from '@mastra/core/workflows';
|
|
17
28
|
import { StepGraph } from '@mastra/core/workflows';
|
|
18
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';
|
|
19
37
|
import type { ToolAction } from '@mastra/core/tools';
|
|
20
38
|
import type { VercelTool } from '@mastra/core/tools';
|
|
39
|
+
import type { VNextWorkflowRuns } from '@mastra/core/storage';
|
|
21
40
|
import type { Workflow } from '@mastra/core/workflows';
|
|
22
41
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows';
|
|
42
|
+
import { WorkflowResult } from '@mastra/core/workflows/vNext';
|
|
23
43
|
import { WorkflowRunResult } from '@mastra/core/workflows';
|
|
24
44
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
45
|
+
import { ZodType } from 'zod';
|
|
46
|
+
import { ZodTypeDef } from 'zod';
|
|
47
|
+
|
|
48
|
+
export declare namespace a2a {
|
|
49
|
+
export {
|
|
50
|
+
getAgentCardByIdHandler,
|
|
51
|
+
handleTaskSend,
|
|
52
|
+
handleTaskGet,
|
|
53
|
+
handleTaskSendSubscribe,
|
|
54
|
+
handleTaskCancel,
|
|
55
|
+
getAgentExecutionHandler
|
|
56
|
+
}
|
|
57
|
+
}
|
|
25
58
|
|
|
26
59
|
export declare namespace agents {
|
|
27
60
|
export {
|
|
@@ -39,12 +72,18 @@ export declare interface ApiError extends Error {
|
|
|
39
72
|
status?: number;
|
|
40
73
|
}
|
|
41
74
|
|
|
75
|
+
export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
|
|
76
|
+
|
|
42
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;
|
|
43
78
|
|
|
44
79
|
export declare interface Context {
|
|
45
80
|
mastra: Mastra;
|
|
46
81
|
}
|
|
47
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
|
+
|
|
48
87
|
export declare function createIndex({ mastra, vectorName, index, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
49
88
|
index: CreateIndexRequest;
|
|
50
89
|
}): Promise<{
|
|
@@ -61,12 +100,25 @@ export declare function createRunHandler({ mastra, workflowId, runId: prevRunId,
|
|
|
61
100
|
runId: string;
|
|
62
101
|
}>;
|
|
63
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
|
+
|
|
64
112
|
export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
65
113
|
body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
|
|
66
114
|
resourceId?: string;
|
|
67
115
|
};
|
|
68
116
|
}): Promise<StorageThreadType>;
|
|
69
117
|
|
|
118
|
+
export declare function createVNextWorkflowRunHandler({ mastra, workflowId, runId: prevRunId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<{
|
|
119
|
+
runId: string;
|
|
120
|
+
}>;
|
|
121
|
+
|
|
70
122
|
export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
71
123
|
indexName?: string;
|
|
72
124
|
}): Promise<{
|
|
@@ -87,15 +139,17 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
87
139
|
metric: string | undefined;
|
|
88
140
|
}>;
|
|
89
141
|
|
|
90
|
-
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'> & {
|
|
91
143
|
agentId?: string;
|
|
92
144
|
data: any;
|
|
93
|
-
runtimeContext:
|
|
145
|
+
runtimeContext: RuntimeContext_2;
|
|
146
|
+
runtimeContextFromRequest: Record<string, unknown>;
|
|
94
147
|
}): Promise<any>;
|
|
95
148
|
|
|
96
|
-
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"> & {
|
|
97
150
|
data?: unknown;
|
|
98
|
-
runtimeContext:
|
|
151
|
+
runtimeContext: RuntimeContext_2;
|
|
152
|
+
runtimeContextFromRequest: Record<string, unknown>;
|
|
99
153
|
}) => Promise<any>;
|
|
100
154
|
|
|
101
155
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -103,6 +157,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
|
|
|
103
157
|
agentId: string;
|
|
104
158
|
body: GetBody<'generate'> & {
|
|
105
159
|
resourceid?: string;
|
|
160
|
+
runtimeContext?: Record<string, unknown>;
|
|
106
161
|
};
|
|
107
162
|
}): Promise<GenerateTextResult<any, any>>;
|
|
108
163
|
|
|
@@ -123,17 +178,42 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
123
178
|
};
|
|
124
179
|
}): Promise<NodeJS.ReadableStream>;
|
|
125
180
|
|
|
126
|
-
export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
|
|
181
|
+
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
182
|
+
runtimeContext: RuntimeContext;
|
|
127
183
|
agentId: string;
|
|
128
184
|
}): Promise<{
|
|
129
185
|
name: any;
|
|
130
186
|
instructions: string;
|
|
131
187
|
tools: any;
|
|
188
|
+
workflows: {};
|
|
132
189
|
provider: string;
|
|
133
190
|
modelId: string;
|
|
134
191
|
}>;
|
|
135
192
|
|
|
136
|
-
export declare function
|
|
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
|
+
|
|
214
|
+
export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
|
|
215
|
+
runtimeContext: RuntimeContext;
|
|
216
|
+
}): Promise<any>;
|
|
137
217
|
|
|
138
218
|
declare type GetBody<T extends keyof Agent & {
|
|
139
219
|
[K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
|
|
@@ -141,7 +221,8 @@ declare type GetBody<T extends keyof Agent & {
|
|
|
141
221
|
messages: Parameters<Agent[T]>[0];
|
|
142
222
|
} & Parameters<Agent[T]>[1];
|
|
143
223
|
|
|
144
|
-
export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context & {
|
|
224
|
+
export declare function getEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
225
|
+
runtimeContext: RuntimeContext;
|
|
145
226
|
agentId: string;
|
|
146
227
|
}): Promise<{
|
|
147
228
|
id: string;
|
|
@@ -150,7 +231,8 @@ export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context &
|
|
|
150
231
|
evals: EvalRow[];
|
|
151
232
|
}>;
|
|
152
233
|
|
|
153
|
-
export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Context & {
|
|
234
|
+
export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
235
|
+
runtimeContext: RuntimeContext;
|
|
154
236
|
agentId: string;
|
|
155
237
|
}): Promise<{
|
|
156
238
|
id: string;
|
|
@@ -171,12 +253,14 @@ export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryC
|
|
|
171
253
|
result: boolean;
|
|
172
254
|
}>;
|
|
173
255
|
|
|
174
|
-
export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>
|
|
256
|
+
export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
|
|
257
|
+
limit?: number;
|
|
258
|
+
}): Promise<{
|
|
175
259
|
messages: CoreMessage[];
|
|
176
260
|
uiMessages: Message[];
|
|
177
261
|
}>;
|
|
178
262
|
|
|
179
|
-
export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<NetworkContext, 'mastra' | 'networkId'>): Promise<{
|
|
263
|
+
export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
180
264
|
id: string;
|
|
181
265
|
name: string;
|
|
182
266
|
instructions: string;
|
|
@@ -191,7 +275,7 @@ export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<Networ
|
|
|
191
275
|
};
|
|
192
276
|
}>;
|
|
193
277
|
|
|
194
|
-
export declare function getNetworksHandler({ mastra }: Pick<NetworkContext, 'mastra'>): Promise<{
|
|
278
|
+
export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'runtimeContext'>): Promise<{
|
|
195
279
|
id: string;
|
|
196
280
|
name: string;
|
|
197
281
|
instructions: string;
|
|
@@ -223,6 +307,26 @@ export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext,
|
|
|
223
307
|
|
|
224
308
|
export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
|
|
225
309
|
|
|
310
|
+
export declare function getVNextWorkflowByIdHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<{
|
|
311
|
+
steps: SerializedStep[];
|
|
312
|
+
name: string | undefined;
|
|
313
|
+
stepGraph: SerializedStepFlowEntry[];
|
|
314
|
+
inputSchema: string | undefined;
|
|
315
|
+
outputSchema: string | undefined;
|
|
316
|
+
}>;
|
|
317
|
+
|
|
318
|
+
export declare function getVNextWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRunById']>>;
|
|
319
|
+
|
|
320
|
+
export declare function getVNextWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: VNextWorkflowContext & {
|
|
321
|
+
fromDate?: Date;
|
|
322
|
+
toDate?: Date;
|
|
323
|
+
limit?: number;
|
|
324
|
+
offset?: number;
|
|
325
|
+
resourceId?: string;
|
|
326
|
+
}): Promise<VNextWorkflowRuns>;
|
|
327
|
+
|
|
328
|
+
export declare function getVNextWorkflowsHandler({ mastra }: VNextWorkflowContext): Promise<any>;
|
|
329
|
+
|
|
226
330
|
export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{
|
|
227
331
|
stepGraph: StepGraph;
|
|
228
332
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
@@ -235,12 +339,60 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
|
|
|
235
339
|
|
|
236
340
|
export declare function getWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getRun']>>;
|
|
237
341
|
|
|
238
|
-
export declare function getWorkflowRunsHandler({ mastra, workflowId }: WorkflowContext
|
|
342
|
+
export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext & {
|
|
343
|
+
fromDate?: Date;
|
|
344
|
+
toDate?: Date;
|
|
345
|
+
limit?: number;
|
|
346
|
+
offset?: number;
|
|
347
|
+
resourceId?: string;
|
|
348
|
+
}): Promise<WorkflowRuns>;
|
|
239
349
|
|
|
240
350
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
|
|
241
351
|
|
|
242
352
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
243
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
|
+
|
|
244
396
|
/**
|
|
245
397
|
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
246
398
|
*
|
|
@@ -302,8 +454,31 @@ declare type HTTPExceptionOptions = {
|
|
|
302
454
|
*/
|
|
303
455
|
declare type InfoStatusCode = 100 | 101 | 102 | 103;
|
|
304
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
|
+
|
|
305
470
|
export declare function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>): Promise<string[]>;
|
|
306
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
|
+
|
|
307
482
|
export declare namespace logs {
|
|
308
483
|
export {
|
|
309
484
|
getLogsHandler,
|
|
@@ -348,8 +523,11 @@ export declare namespace network {
|
|
|
348
523
|
|
|
349
524
|
declare interface NetworkContext extends Context {
|
|
350
525
|
networkId?: string;
|
|
526
|
+
runtimeContext: RuntimeContext;
|
|
351
527
|
}
|
|
352
528
|
|
|
529
|
+
export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: Logger): JSONRPCResponse<null, unknown>;
|
|
530
|
+
|
|
353
531
|
declare interface QueryRequest {
|
|
354
532
|
indexName: string;
|
|
355
533
|
queryVector: number[];
|
|
@@ -364,6 +542,15 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
|
|
|
364
542
|
|
|
365
543
|
declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
|
|
366
544
|
|
|
545
|
+
export declare function resumeAsyncVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, runtimeContextFromRequest, }: VNextWorkflowContext & {
|
|
546
|
+
body: {
|
|
547
|
+
step: string | string[];
|
|
548
|
+
resumeData?: unknown;
|
|
549
|
+
};
|
|
550
|
+
runtimeContext?: RuntimeContext_2;
|
|
551
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
552
|
+
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
|
|
553
|
+
|
|
367
554
|
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
368
555
|
body: {
|
|
369
556
|
stepId: string;
|
|
@@ -372,6 +559,16 @@ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId,
|
|
|
372
559
|
runtimeContext: RuntimeContext;
|
|
373
560
|
}): Promise<Omit<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
374
561
|
|
|
562
|
+
export declare function resumeVNextWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: VNextWorkflowContext & {
|
|
563
|
+
body: {
|
|
564
|
+
step: string | string[];
|
|
565
|
+
resumeData?: unknown;
|
|
566
|
+
};
|
|
567
|
+
runtimeContext?: RuntimeContext_2;
|
|
568
|
+
}): Promise<{
|
|
569
|
+
message: string;
|
|
570
|
+
}>;
|
|
571
|
+
|
|
375
572
|
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
376
573
|
body: {
|
|
377
574
|
stepId: string;
|
|
@@ -388,13 +585,36 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
|
|
|
388
585
|
};
|
|
389
586
|
}): Promise<MessageType[]>;
|
|
390
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
|
+
|
|
391
597
|
declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
392
598
|
|
|
599
|
+
export declare function startAsyncVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
600
|
+
inputData?: unknown;
|
|
601
|
+
runtimeContext?: RuntimeContext_2;
|
|
602
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
603
|
+
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, NewStep<string, any, any, any, any>[]>>;
|
|
604
|
+
|
|
393
605
|
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
394
606
|
triggerData?: unknown;
|
|
395
607
|
runtimeContext: RuntimeContext;
|
|
396
608
|
}): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
397
609
|
|
|
610
|
+
export declare function startVNextWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
611
|
+
inputData?: unknown;
|
|
612
|
+
runtimeContext?: RuntimeContext_2;
|
|
613
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
614
|
+
}): Promise<{
|
|
615
|
+
message: string;
|
|
616
|
+
}>;
|
|
617
|
+
|
|
398
618
|
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
399
619
|
triggerData?: unknown;
|
|
400
620
|
runtimeContext: RuntimeContext;
|
|
@@ -426,6 +646,7 @@ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId,
|
|
|
426
646
|
agentId: string;
|
|
427
647
|
body: GetBody<'stream'> & {
|
|
428
648
|
resourceid?: string;
|
|
649
|
+
runtimeContext?: string;
|
|
429
650
|
};
|
|
430
651
|
}): Promise<Response | undefined>;
|
|
431
652
|
|
|
@@ -452,6 +673,8 @@ declare interface TelemetryContext extends Context {
|
|
|
452
673
|
page?: number;
|
|
453
674
|
perPage?: number;
|
|
454
675
|
attribute?: string | string[];
|
|
676
|
+
fromDate?: Date;
|
|
677
|
+
toDate?: Date;
|
|
455
678
|
};
|
|
456
679
|
}
|
|
457
680
|
|
|
@@ -534,6 +757,26 @@ declare interface VectorContext extends Context {
|
|
|
534
757
|
vectorName?: string;
|
|
535
758
|
}
|
|
536
759
|
|
|
760
|
+
declare interface VNextWorkflowContext extends Context {
|
|
761
|
+
workflowId?: string;
|
|
762
|
+
runId?: string;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export declare namespace vNextWorkflows {
|
|
766
|
+
export {
|
|
767
|
+
getVNextWorkflowsHandler,
|
|
768
|
+
getVNextWorkflowByIdHandler,
|
|
769
|
+
getVNextWorkflowRunByIdHandler,
|
|
770
|
+
createVNextWorkflowRunHandler,
|
|
771
|
+
startAsyncVNextWorkflowHandler,
|
|
772
|
+
startVNextWorkflowRunHandler,
|
|
773
|
+
watchVNextWorkflowHandler,
|
|
774
|
+
resumeAsyncVNextWorkflowHandler,
|
|
775
|
+
resumeVNextWorkflowHandler,
|
|
776
|
+
getVNextWorkflowRunsHandler
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
537
780
|
export declare namespace voice {
|
|
538
781
|
export {
|
|
539
782
|
getSpeakersHandler,
|
|
@@ -546,6 +789,8 @@ declare interface VoiceContext extends Context {
|
|
|
546
789
|
agentId?: string;
|
|
547
790
|
}
|
|
548
791
|
|
|
792
|
+
export declare function watchVNextWorkflowHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
|
|
793
|
+
|
|
549
794
|
export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
|
|
550
795
|
|
|
551
796
|
declare interface WorkflowContext extends Context {
|