@mastra/server 0.0.1-alpha.5 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENSE → LICENSE.md} +3 -1
- package/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +305 -52
- package/dist/_tsup-dts-rollup.d.ts +305 -52
- 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-6B4OMWT6.cjs +343 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-VB7KH62D.cjs → chunk-7DLZLWJV.cjs} +16 -12
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-2YONKUWB.js → chunk-C7564HUT.js} +58 -33
- package/dist/chunk-D4IRYCUI.cjs +235 -0
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-3RVHWGWO.js → chunk-HFWCEP5S.js} +6 -12
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-CWSDZEZG.cjs → chunk-MHKNLNAN.cjs} +15 -12
- 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-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/chunk-QY36IPTP.js +331 -0
- package/dist/{chunk-YNSGUC2O.js → chunk-TJKLBTFB.js} +23 -7
- package/dist/chunk-VPNDC2DI.cjs +148 -0
- package/dist/{chunk-ILW7XYNJ.js → chunk-W7VCKPAD.js} +84 -60
- package/dist/{chunk-2JQC6JWP.js → chunk-WFBJJNCK.js} +10 -6
- package/dist/chunk-WUC6LSTW.js +227 -0
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
- package/dist/chunk-YIOVBYZH.cjs +332 -0
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-4C3EPMMF.cjs → chunk-ZE5AAC4I.cjs} +40 -24
- 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/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- 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/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 +13 -13
- package/dist/server/handlers/workflows.d.cts +2 -2
- package/dist/server/handlers/workflows.d.ts +2 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +33 -23
- 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 +9 -7
- package/dist/chunk-5JOF627H.cjs +0 -123
- package/dist/chunk-BMA2ORRT.js +0 -152
- package/dist/chunk-GV52BII2.cjs +0 -160
- package/dist/chunk-QH6XWSXP.cjs +0 -5579
- package/dist/chunk-VK6FX47H.js +0 -5576
- package/dist/chunk-X37I6GZT.cjs +0 -308
package/{LICENSE → LICENSE.md}
RENAMED
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.
|