@mastra/deployer 1.0.0-beta.21 → 1.0.0-beta.23
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/CHANGELOG.md +30 -0
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +10 -10
- package/dist/build/index.js +3 -3
- package/dist/build/plugins/tsconfig-paths.d.ts +1 -1
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-UKP4KHBS.js → chunk-5FPJTHRK.js} +4 -4
- package/dist/{chunk-UKP4KHBS.js.map → chunk-5FPJTHRK.js.map} +1 -1
- package/dist/{chunk-HVKR4FT2.cjs → chunk-7EPD2XJR.cjs} +11 -11
- package/dist/{chunk-HVKR4FT2.cjs.map → chunk-7EPD2XJR.cjs.map} +1 -1
- package/dist/{chunk-Z53UZLS3.cjs → chunk-GU4OME5Q.cjs} +11 -11
- package/dist/{chunk-Z53UZLS3.cjs.map → chunk-GU4OME5Q.cjs.map} +1 -1
- package/dist/{chunk-4NPMVODD.js → chunk-HWSYWSD7.js} +3 -3
- package/dist/chunk-HWSYWSD7.js.map +1 -0
- package/dist/{chunk-2ZPRZMBN.js → chunk-NGQZZ54Y.js} +3 -3
- package/dist/{chunk-2ZPRZMBN.js.map → chunk-NGQZZ54Y.js.map} +1 -1
- package/dist/{chunk-NGWTN4SJ.js → chunk-SD6NHZ2H.js} +4 -4
- package/dist/{chunk-NGWTN4SJ.js.map → chunk-SD6NHZ2H.js.map} +1 -1
- package/dist/{chunk-NWQP6PZQ.cjs → chunk-T7NCLSYN.cjs} +3 -3
- package/dist/chunk-T7NCLSYN.cjs.map +1 -0
- package/dist/{chunk-SBGBJ7NB.cjs → chunk-VOI3B5MX.cjs} +11 -11
- package/dist/{chunk-SBGBJ7NB.cjs.map → chunk-VOI3B5MX.cjs.map} +1 -1
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/deployment/01-overview.md +6 -2
- package/dist/docs/deployment/02-mastra-server.md +99 -40
- package/dist/docs/deployment/03-monorepo.md +89 -17
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +12 -10
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +12 -10
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-4NPMVODD.js.map +0 -1
- package/dist/chunk-NWQP6PZQ.cjs.map +0 -1
|
@@ -19,7 +19,7 @@ Mastra can run against any of these runtime environments:
|
|
|
19
19
|
|
|
20
20
|
Mastra provides a [server](https://mastra.ai/docs/v1/server/mastra-server) powered by Hono that can be deployed independently. Use the `mastra build` command to build your application and deploy the output to your preferred VM, container, or PaaS platform.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Use this option when you need full control over your infrastructure, long-running processes, or WebSocket connections. The [Mastra server deployment guide](https://mastra.ai/docs/v1/deployment/mastra-server) provides more details.
|
|
23
23
|
|
|
24
24
|
### Monorepo
|
|
25
25
|
|
|
@@ -31,6 +31,8 @@ Read about [monorepo deployment](https://mastra.ai/docs/v1/deployment/monorepo).
|
|
|
31
31
|
|
|
32
32
|
Mastra applications can be deployed to cloud providers and serverless platforms. Mastra includes optional built-in deployers for Vercel, Netlify, and Cloudflare to automate the build and deployment process.
|
|
33
33
|
|
|
34
|
+
Use this option for auto-scaling, minimal infrastructure management, or when you're already using one of these platforms.
|
|
35
|
+
|
|
34
36
|
- [Amazon EC2](https://mastra.ai/guides/v1/deployment/amazon-ec2)
|
|
35
37
|
- [AWS Lambda](https://mastra.ai/guides/v1/deployment/aws-lambda)
|
|
36
38
|
- [Azure App Services](https://mastra.ai/guides/v1/deployment/azure-app-services)
|
|
@@ -41,7 +43,9 @@ Mastra applications can be deployed to cloud providers and serverless platforms.
|
|
|
41
43
|
|
|
42
44
|
### Web Framework
|
|
43
45
|
|
|
44
|
-
When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. The guides below cover framework-specific configuration requirements for deployment
|
|
46
|
+
When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. The guides below cover framework-specific configuration requirements for deployment.
|
|
47
|
+
|
|
48
|
+
Use these guides when adding Mastra to an existing Next.js or Astro application.
|
|
45
49
|
|
|
46
50
|
- [With Next.js on Vercel](https://mastra.ai/docs/v1/deployment/web-framework#with-nextjs-on-vercel)
|
|
47
51
|
- [With Astro on Vercel](https://mastra.ai/docs/v1/deployment/web-framework#with-astro-on-vercel)
|
|
@@ -1,70 +1,129 @@
|
|
|
1
|
-
> Learn how to build a Mastra server
|
|
1
|
+
> Learn how to build and deploy a Mastra server.
|
|
2
2
|
|
|
3
3
|
# Deploy a Mastra Server
|
|
4
4
|
|
|
5
|
-
Mastra
|
|
5
|
+
Mastra compiles your application into a standalone Node.js server that can run on any platform supporting Node.js, Bun, or Deno.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> **Note:**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This guide covers deploying the standalone server generated by `mastra build`. If you need to integrate Mastra into an existing Express or Hono application, see [Server Adapters](https://mastra.ai/docs/v1/server/server-adapters) instead.
|
|
10
|
+
|
|
11
|
+
## Building your application
|
|
12
|
+
|
|
13
|
+
Run the build command from your project root:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
mastra build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This creates a `.mastra` directory containing your production-ready server.
|
|
20
|
+
|
|
21
|
+
> **Note:**
|
|
22
|
+
|
|
23
|
+
Read the [`mastra build`](https://mastra.ai/reference/v1/cli/mastra#mastra-build) reference for all available flags.
|
|
24
|
+
|
|
25
|
+
## Build output
|
|
26
|
+
|
|
27
|
+
After building, Mastra creates the following structure:
|
|
10
28
|
|
|
11
29
|
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
├──
|
|
16
|
-
├──
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
.mastra/
|
|
31
|
+
├── .build/ # Intermediate build artifacts (module maps, analysis)
|
|
32
|
+
└── output/
|
|
33
|
+
├── index.mjs # Server entry point
|
|
34
|
+
├── mastra.mjs # Your bundled Mastra configuration
|
|
35
|
+
├── tools.mjs # Aggregated tool exports
|
|
36
|
+
├── tools/ # Individual tool bundles
|
|
37
|
+
├── package.json # Production dependencies
|
|
38
|
+
├── node_modules/ # Installed dependencies
|
|
39
|
+
├── .npmrc # Copied from your project (if present)
|
|
40
|
+
├── public/ # Static assets (if src/mastra/public exists)
|
|
41
|
+
└── playground/ # Studio UI (if --studio flag used)
|
|
20
42
|
```
|
|
21
43
|
|
|
22
|
-
|
|
44
|
+
The `output` directory is self-contained. You can copy it to any server and run it directly.
|
|
45
|
+
|
|
46
|
+
## Running the server
|
|
23
47
|
|
|
24
|
-
|
|
48
|
+
Start the server using the Mastra CLI:
|
|
25
49
|
|
|
26
50
|
```bash
|
|
27
|
-
mastra
|
|
51
|
+
mastra start
|
|
28
52
|
```
|
|
29
53
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
If your Mastra files are located elsewhere, use the `--dir` flag to specify the custom location. The `--dir` flag tells Mastra where to find your entry point file (`index.ts` or `index.js`) and related directories.
|
|
54
|
+
Or run directly with Node.js:
|
|
33
55
|
|
|
34
56
|
```bash
|
|
35
|
-
mastra
|
|
57
|
+
node .mastra/output/index.mjs
|
|
36
58
|
```
|
|
37
59
|
|
|
60
|
+
The `mastra start` command provides additional features:
|
|
61
|
+
- Loads environment variables from `.env.production` and `.env`
|
|
62
|
+
- Provides helpful error messages for missing modules
|
|
63
|
+
- Handles process signals for graceful shutdown
|
|
64
|
+
|
|
65
|
+
> **Note:**
|
|
66
|
+
|
|
67
|
+
Read the [`mastra start`](https://mastra.ai/reference/v1/cli/mastra#mastra-start) reference for all available flags.
|
|
68
|
+
|
|
69
|
+
## Build configuration
|
|
70
|
+
|
|
71
|
+
### Public folder
|
|
72
|
+
|
|
73
|
+
If a `public` folder exists in your Mastra directory (`src/mastra/public`), its contents are copied to the output directory during build. These files are served as static assets by the server.
|
|
74
|
+
|
|
75
|
+
### Mastra configuration
|
|
76
|
+
|
|
77
|
+
The build process respects configuration in your Mastra instance. For server behavior like CORS, timeouts, and middleware, see [server overview](https://mastra.ai/docs/v1/server/mastra-server). For all available options, see the [configuration reference](https://mastra.ai/reference/v1/configuration).
|
|
78
|
+
|
|
38
79
|
## Build process
|
|
39
80
|
|
|
40
|
-
The build
|
|
81
|
+
The build follows these steps:
|
|
41
82
|
|
|
42
|
-
1. **Locates entry file**: Finds `index.ts` or `index.js` in your
|
|
43
|
-
2. **
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
83
|
+
1. **Locates entry file**: Finds `index.ts` or `index.js` in your Mastra directory.
|
|
84
|
+
2. **Discovers tools**: Scans for tool files matching `{mastraDir}/tools/**/*.{js,ts}`, excluding test files.
|
|
85
|
+
3. **Analyzes dependencies**: Determines which packages to bundle vs. install externally.
|
|
86
|
+
4. **Bundles code**: Uses Rollup with tree-shaking and optional source maps.
|
|
87
|
+
5. **Generates server**: Creates a Hono-based HTTP server as `index.mjs`.
|
|
88
|
+
6. **Installs dependencies**: Runs `npm install` in the output directory.
|
|
89
|
+
7. **Copies assets**: Copies `public` folder and `.npmrc` if present.
|
|
49
90
|
|
|
50
|
-
|
|
91
|
+
## Environment variables
|
|
51
92
|
|
|
52
|
-
|
|
93
|
+
| Variable | Description |
|
|
94
|
+
|----------|-------------|
|
|
95
|
+
| `PORT` | Server port (default: `4111`) |
|
|
96
|
+
| `MASTRA_STUDIO_PATH` | Path to Studio build directory (default: `./playground`) |
|
|
97
|
+
| `MASTRA_SKIP_DOTENV` | Skip loading `.env` files when set |
|
|
98
|
+
| `NODE_OPTIONS` | Node.js options (e.g., `--max-old-space-size=4096` for build memory issues) |
|
|
53
99
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
## Server endpoints
|
|
101
|
+
|
|
102
|
+
The built server exposes endpoints for health checks, agents, workflows, and more:
|
|
103
|
+
|
|
104
|
+
| Endpoint | Description |
|
|
105
|
+
|----------|-------------|
|
|
106
|
+
| `GET /health` | Health check endpoint, returns `200 OK` |
|
|
107
|
+
| `GET /openapi.json` | OpenAPI specification (if `server.build.openAPIDocs` is enabled) |
|
|
108
|
+
| `GET /swagger-ui` | Interactive API documentation (if `server.build.swaggerUI` is enabled) |
|
|
109
|
+
|
|
110
|
+
This list is not exhaustive. To view all endpoints, run `mastra dev` and visit `http://localhost:4111/swagger-ui`.
|
|
59
111
|
|
|
60
|
-
|
|
112
|
+
To add your own endpoints, see [Custom API Routes](https://mastra.ai/docs/v1/server/custom-api-routes).
|
|
61
113
|
|
|
62
|
-
|
|
114
|
+
## Troubleshooting
|
|
63
115
|
|
|
64
|
-
|
|
116
|
+
### Memory errors during build
|
|
65
117
|
|
|
66
|
-
|
|
118
|
+
If you encounter `JavaScript heap out of memory` errors:
|
|
67
119
|
|
|
68
120
|
```bash
|
|
69
|
-
|
|
70
|
-
```
|
|
121
|
+
NODE_OPTIONS="--max-old-space-size=4096" mastra build
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Related
|
|
125
|
+
|
|
126
|
+
- [Server Overview](https://mastra.ai/docs/v1/server/mastra-server) - Configure server behavior, middleware, and authentication
|
|
127
|
+
- [Server Adapters](https://mastra.ai/docs/v1/server/server-adapters) - Use Express or Hono instead of `mastra build`
|
|
128
|
+
- [Custom API Routes](https://mastra.ai/docs/v1/server/custom-api-routes) - Add custom HTTP endpoints
|
|
129
|
+
- [Configuration Reference](https://mastra.ai/reference/v1/configuration) - Full configuration options
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Deploy in a Monorepo
|
|
4
4
|
|
|
5
|
-
Deploying Mastra in a monorepo follows the same
|
|
5
|
+
Deploying Mastra in a monorepo follows the same process as a standalone application. This guide covers monorepo-specific considerations. For the core build and deployment steps, see [Deploy a Mastra Server](https://mastra.ai/docs/v1/deployment/mastra-server).
|
|
6
6
|
|
|
7
7
|
## Supported monorepos
|
|
8
8
|
|
|
@@ -18,9 +18,9 @@ Known limitations:
|
|
|
18
18
|
- Bun workspaces - partial support; known issues
|
|
19
19
|
- Nx - You can use Nx's [supported dependency strategies](https://nx.dev/concepts/decisions/dependency-management) but you need to have `package.json` files inside your workspace packages
|
|
20
20
|
|
|
21
|
-
## Example
|
|
21
|
+
## Example structure
|
|
22
22
|
|
|
23
|
-
In this example, the Mastra application is located at `apps/api
|
|
23
|
+
In this example, the Mastra application is located at `apps/api`:
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
apps/
|
|
@@ -40,31 +40,103 @@ packages/
|
|
|
40
40
|
package.json
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Building from a monorepo
|
|
44
|
+
|
|
45
|
+
Use your monorepo tool to run the build command from the correct package. There's no need for special flags.
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
|
|
49
|
+
**npm:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run build --workspace=apps/api
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**pnpm:**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pnpm --filter api run build
|
|
59
|
+
```
|
|
44
60
|
|
|
45
|
-
|
|
61
|
+
**yarn:**
|
|
46
62
|
|
|
63
|
+
```bash
|
|
64
|
+
yarn workspace api build
|
|
47
65
|
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
|
|
67
|
+
**turborepo:**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
turbo run build --filter=api
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Your package's `build` script should run `mastra build`:
|
|
74
|
+
|
|
75
|
+
```json title="apps/api/package.json"
|
|
76
|
+
{
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "mastra build"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Workspace packages
|
|
84
|
+
|
|
85
|
+
When your Mastra application imports from other workspace packages, Mastra handles this automatically:
|
|
86
|
+
|
|
87
|
+
- If the package is pre-compiled (e.g., built with `tsc` or `tsdown`), Mastra imports the compiled JavaScript
|
|
88
|
+
- If the package contains uncompiled TypeScript, Mastra transpiles it during the build
|
|
89
|
+
|
|
90
|
+
For most setups, this works without configuration. If you encounter issues with workspace package imports, add the package to [`transpilePackages`](https://mastra.ai/reference/v1/configuration#bundlertranspilepackages):
|
|
91
|
+
|
|
92
|
+
```typescript title="src/mastra/index.ts"
|
|
93
|
+
export const mastra = new Mastra({
|
|
94
|
+
bundler: {
|
|
95
|
+
transpilePackages: ["@my-org/utils"],
|
|
96
|
+
},
|
|
97
|
+
});
|
|
54
98
|
```
|
|
55
99
|
|
|
100
|
+
## Environment variables
|
|
101
|
+
|
|
102
|
+
Store `.env` files in the Mastra application directory (e.g., `apps/api/.env`), not the monorepo root.
|
|
103
|
+
|
|
56
104
|
## Deployment configuration
|
|
57
105
|
|
|
106
|
+
When deploying to cloud providers, ensure the correct package is selected as the deploy target. Selecting the monorepo root instead of the application directory (e.g., `apps/api`) is a common mistake.
|
|
107
|
+
|
|
108
|
+
Most providers let you specify the root directory in their dashboard or configuration file.
|
|
109
|
+
|
|
110
|
+
### Mastra Cloud
|
|
111
|
+
|
|
58
112
|
The image below shows how to select `apps/api` as the project root when deploying to [Mastra Cloud](https://mastra.ai/docs/v1/mastra-cloud/overview). While the interface may differ between providers, the configuration remains the same.
|
|
59
113
|
|
|
60
114
|

|
|
61
115
|
|
|
62
|
-
> **Note:**
|
|
63
|
-
Make sure the correct package (e.g. `apps/api`) is selected as the deploy target. Selecting the wrong project root is a common deployment issue in monorepos.
|
|
64
|
-
|
|
65
116
|
## Dependency management
|
|
66
117
|
|
|
67
|
-
|
|
118
|
+
Keep dependencies consistent to avoid version conflicts and build errors:
|
|
119
|
+
|
|
120
|
+
- Use a **single lockfile** at the monorepo root so all packages resolve the same versions
|
|
121
|
+
- Align versions of **shared libraries** (like Mastra or frameworks) to prevent duplicates
|
|
122
|
+
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
### Workspace package not found
|
|
126
|
+
|
|
127
|
+
If Mastra can't resolve a workspace package, ensure:
|
|
128
|
+
- The package is listed in your `package.json` dependencies
|
|
129
|
+
- Your lockfile is up to date (`pnpm install`, `npm install`, etc.)
|
|
130
|
+
- The package has a valid `main` or `exports` field in its `package.json`
|
|
131
|
+
|
|
132
|
+
### TypeScript errors from workspace packages
|
|
133
|
+
|
|
134
|
+
If you see type errors from uncompiled workspace packages, either:
|
|
135
|
+
- Build the package first (recommended for faster Mastra builds)
|
|
136
|
+
- Add the package to [`transpilePackages`](https://mastra.ai/reference/v1/configuration#bundlertranspilepackages) in your Mastra config
|
|
137
|
+
|
|
138
|
+
## Related
|
|
68
139
|
|
|
69
|
-
-
|
|
70
|
-
-
|
|
140
|
+
- [Deploy a Mastra Server](https://mastra.ai/docs/v1/deployment/mastra-server) - Core build and deployment guide
|
|
141
|
+
- [Configuration Reference](https://mastra.ai/reference/v1/configuration) - `bundler.transpilePackages` and other options
|
|
142
|
+
- [CLI Reference](https://mastra.ai/reference/v1/cli/mastra) - Build command flags
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkVOI3B5MX_cjs = require('./chunk-VOI3B5MX.cjs');
|
|
4
|
+
var chunkT7NCLSYN_cjs = require('./chunk-T7NCLSYN.cjs');
|
|
5
5
|
var chunkJVBCN3RH_cjs = require('./chunk-JVBCN3RH.cjs');
|
|
6
6
|
|
|
7
7
|
// src/deploy/base.ts
|
|
8
|
-
var Deployer = class extends
|
|
8
|
+
var Deployer = class extends chunkVOI3B5MX_cjs.Bundler {
|
|
9
9
|
deps = new chunkJVBCN3RH_cjs.DepsService();
|
|
10
10
|
constructor(args) {
|
|
11
11
|
super(args.name, "DEPLOYER");
|
|
@@ -25,7 +25,7 @@ var Deployer = class extends chunkSBGBJ7NB_cjs.Bundler {
|
|
|
25
25
|
|
|
26
26
|
// src/build/deployer.ts
|
|
27
27
|
async function getDeployer(entryFile, outputDir, logger) {
|
|
28
|
-
const result = await
|
|
28
|
+
const result = await chunkT7NCLSYN_cjs.extractMastraOption("deployer", entryFile, outputDir, logger);
|
|
29
29
|
if (!result) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bundler } from './chunk-
|
|
2
|
-
import { extractMastraOption } from './chunk-
|
|
1
|
+
import { Bundler } from './chunk-SD6NHZ2H.js';
|
|
2
|
+
import { extractMastraOption } from './chunk-HWSYWSD7.js';
|
|
3
3
|
import { DepsService, FileService } from './chunk-DPDWM7HQ.js';
|
|
4
4
|
export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-DPDWM7HQ.js';
|
|
5
5
|
|
package/dist/server/index.cjs
CHANGED
|
@@ -3670,7 +3670,7 @@ var getStudioPath = () => {
|
|
|
3670
3670
|
const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
3671
3671
|
__dirname = path.dirname(__filename);
|
|
3672
3672
|
}
|
|
3673
|
-
const studioPath = process.env.MASTRA_STUDIO_PATH || path.join(__dirname, "
|
|
3673
|
+
const studioPath = process.env.MASTRA_STUDIO_PATH || path.join(__dirname, "studio");
|
|
3674
3674
|
return studioPath;
|
|
3675
3675
|
};
|
|
3676
3676
|
function getToolExports(tools$1) {
|
|
@@ -3821,7 +3821,7 @@ async function createHonoServer(mastra, options = {
|
|
|
3821
3821
|
}
|
|
3822
3822
|
const serverOptions = mastra.getServer();
|
|
3823
3823
|
const studioBasePath = chunk5TYVF4KJ_cjs.normalizeStudioBase(serverOptions?.studioBase ?? "/");
|
|
3824
|
-
if (options?.
|
|
3824
|
+
if (options?.studio) {
|
|
3825
3825
|
app.get(
|
|
3826
3826
|
`${studioBasePath}/refresh-events`,
|
|
3827
3827
|
describeRoute({
|
|
@@ -3874,8 +3874,8 @@ async function createHonoServer(mastra, options = {
|
|
|
3874
3874
|
if (requestPath.includes(".") && !requestPath.endsWith(".html")) {
|
|
3875
3875
|
return await next();
|
|
3876
3876
|
}
|
|
3877
|
-
const
|
|
3878
|
-
if (options?.
|
|
3877
|
+
const isStudioRoute = studioBasePath === "" || requestPath === studioBasePath || requestPath.startsWith(`${studioBasePath}/`);
|
|
3878
|
+
if (options?.studio && isStudioRoute) {
|
|
3879
3879
|
const studioPath = getStudioPath();
|
|
3880
3880
|
let indexHtml = await promises.readFile(path.join(studioPath, "index.html"), "utf-8");
|
|
3881
3881
|
const port = serverOptions?.port ?? (Number(process.env.PORT) || 4111);
|
|
@@ -3884,22 +3884,24 @@ async function createHonoServer(mastra, options = {
|
|
|
3884
3884
|
const key = serverOptions?.https?.key ?? (process.env.MASTRA_HTTPS_KEY ? Buffer.from(process.env.MASTRA_HTTPS_KEY, "base64") : void 0);
|
|
3885
3885
|
const cert = serverOptions?.https?.cert ?? (process.env.MASTRA_HTTPS_CERT ? Buffer.from(process.env.MASTRA_HTTPS_CERT, "base64") : void 0);
|
|
3886
3886
|
const protocol = key && cert ? "https" : "http";
|
|
3887
|
+
const cloudApiEndpoint = process.env.MASTRA_CLOUD_API_ENDPOINT || "";
|
|
3887
3888
|
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_HOST%%'`, `'${host}'`);
|
|
3888
3889
|
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_PORT%%'`, `'${port}'`);
|
|
3889
3890
|
indexHtml = indexHtml.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, `'${hideCloudCta}'`);
|
|
3890
3891
|
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, `'${protocol}'`);
|
|
3892
|
+
indexHtml = indexHtml.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, `'${cloudApiEndpoint}'`);
|
|
3891
3893
|
indexHtml = indexHtml.replaceAll("%%MASTRA_STUDIO_BASE_PATH%%", studioBasePath);
|
|
3892
3894
|
return c.newResponse(indexHtml, 200, { "Content-Type": "text/html" });
|
|
3893
3895
|
}
|
|
3894
3896
|
return c.newResponse(html2, 200, { "Content-Type": "text/html" });
|
|
3895
3897
|
});
|
|
3896
|
-
if (options?.
|
|
3897
|
-
const
|
|
3898
|
-
const
|
|
3898
|
+
if (options?.studio) {
|
|
3899
|
+
const studioRootPath = getStudioPath();
|
|
3900
|
+
const studioPath = studioBasePath ? `${studioBasePath}/*` : "*";
|
|
3899
3901
|
app.use(
|
|
3900
|
-
|
|
3902
|
+
studioPath,
|
|
3901
3903
|
serveStatic({
|
|
3902
|
-
root:
|
|
3904
|
+
root: studioRootPath,
|
|
3903
3905
|
rewriteRequestPath: (path) => {
|
|
3904
3906
|
if (studioBasePath && path.startsWith(studioBasePath)) {
|
|
3905
3907
|
return path.slice(studioBasePath.length);
|
|
@@ -3936,7 +3938,7 @@ async function createNodeServer(mastra, options = { tools: {} }) {
|
|
|
3936
3938
|
() => {
|
|
3937
3939
|
const logger2 = mastra.getLogger();
|
|
3938
3940
|
logger2.info(` Mastra API running on ${protocol}://${host}:${port}/api`);
|
|
3939
|
-
if (options?.
|
|
3941
|
+
if (options?.studio) {
|
|
3940
3942
|
const studioBasePath = chunk5TYVF4KJ_cjs.normalizeStudioBase(serverOptions?.studioBase ?? "/");
|
|
3941
3943
|
const studioUrl = `${protocol}://${host}:${port}${studioBasePath}`;
|
|
3942
3944
|
logger2.info(`\u{1F468}\u200D\u{1F4BB} Studio available at ${studioUrl}`);
|