@mastra/server 1.62.0-alpha.10 → 1.62.0-alpha.12
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 +14 -0
- package/dist/{dist-DkFSqWZ7.js → dist-L0EogwX_.js} +165 -151
- package/dist/dist-L0EogwX_.js.map +1 -0
- package/dist/{dist-Czh_Btxb.cjs → dist-Xj9TvH1A.cjs} +165 -151
- package/dist/dist-Xj9TvH1A.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-middleware.md +26 -0
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/package.json +5 -5
- package/dist/dist-Czh_Btxb.cjs.map +0 -1
- package/dist/dist-DkFSqWZ7.js.map +0 -1
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-server
|
|
|
3
3
|
description: Documentation for @mastra/server. Use when working with @mastra/server APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/server"
|
|
6
|
-
version: "1.62.0-alpha.
|
|
6
|
+
version: "1.62.0-alpha.12"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -58,6 +58,32 @@ registerApiRoute('/my-custom-route', {
|
|
|
58
58
|
|
|
59
59
|
## Common examples
|
|
60
60
|
|
|
61
|
+
### Block built-in route groups
|
|
62
|
+
|
|
63
|
+
Mastra doesn't provide a configuration option to remove or allowlist built-in routes. On Hono-based serving paths, you can make selected route groups unavailable by returning a response without calling `next()`:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Mastra } from '@mastra/core'
|
|
67
|
+
|
|
68
|
+
const notFound = async () => new Response('Not Found', { status: 404 })
|
|
69
|
+
|
|
70
|
+
export const mastra = new Mastra({
|
|
71
|
+
server: {
|
|
72
|
+
middleware: [
|
|
73
|
+
{ path: '/api/memory/*', handler: notFound },
|
|
74
|
+
{ path: '/api/logs/*', handler: notFound },
|
|
75
|
+
{ path: '/api/observability/*', handler: notFound },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Each wildcard pattern blocks both the route group itself and its nested routes. For example, `/api/logs/*` blocks `/api/logs` and `/api/logs/transports`. Other route groups remain available.
|
|
82
|
+
|
|
83
|
+
Generated servers pass `server.apiPrefix` to the Hono adapter's [`prefix` constructor option](https://mastra.ai/reference/server/hono-adapter), which prefixes built-in routes. Middleware paths are registered unchanged, so they must explicitly include the configured prefix. For example, with `apiPrefix: '/api/v2'`, use `/api/v2/memory/*`. Custom API routes must live outside the configured API prefix and aren't blocked by these patterns.
|
|
84
|
+
|
|
85
|
+
This approach can't block routes declared public with `requiresAuth: false`, because Mastra skips user middleware for those routes. With a non-Hono server adapter, register equivalent middleware through the server framework instead.
|
|
86
|
+
|
|
61
87
|
### Using `RequestContext`
|
|
62
88
|
|
|
63
89
|
You can populate `RequestContext` in a runtime server middleware by extracting information from the request. In this example, the `temperature-unit` is set based on the Cloudflare `CF-IPCountry` header to ensure responses match the user's locale.
|
|
@@ -30,7 +30,7 @@ var agent_builder_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll
|
|
|
30
30
|
});
|
|
31
31
|
let agentBuilderWorkflowsPromise;
|
|
32
32
|
async function loadAgentBuilderWorkflows() {
|
|
33
|
-
agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("../../dist-
|
|
33
|
+
agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("../../dist-Xj9TvH1A.cjs")).then((mod) => mod.agentBuilderWorkflows);
|
|
34
34
|
return agentBuilderWorkflowsPromise;
|
|
35
35
|
}
|
|
36
36
|
async function registerAgentBuilderWorkflows(mastra) {
|
|
@@ -29,7 +29,7 @@ var agent_builder_exports = /* @__PURE__ */ __exportAll({
|
|
|
29
29
|
});
|
|
30
30
|
let agentBuilderWorkflowsPromise;
|
|
31
31
|
async function loadAgentBuilderWorkflows() {
|
|
32
|
-
agentBuilderWorkflowsPromise ??= import("../../dist-
|
|
32
|
+
agentBuilderWorkflowsPromise ??= import("../../dist-L0EogwX_.js").then((mod) => mod.agentBuilderWorkflows);
|
|
33
33
|
return agentBuilderWorkflowsPromise;
|
|
34
34
|
}
|
|
35
35
|
async function registerAgentBuilderWorkflows(mastra) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "1.62.0-alpha.
|
|
3
|
+
"version": "1.62.0-alpha.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -117,13 +117,13 @@
|
|
|
117
117
|
"zod": "^4.4.3",
|
|
118
118
|
"zod-to-ts": "^2.1.0",
|
|
119
119
|
"@internal/lint": "0.0.125",
|
|
120
|
-
"@internal/core": "0.1.2",
|
|
121
120
|
"@internal/test-utils": "0.0.61",
|
|
122
121
|
"@internal/storage-test-utils": "0.0.121",
|
|
123
|
-
"@
|
|
124
|
-
"@internal/types-builder": "0.0.100",
|
|
122
|
+
"@internal/core": "0.1.2",
|
|
125
123
|
"@internal/voice": "0.0.23",
|
|
126
|
-
"@
|
|
124
|
+
"@internal/types-builder": "0.0.100",
|
|
125
|
+
"@mastra/core": "1.62.0-alpha.12",
|
|
126
|
+
"@mastra/agent-builder": "1.1.14-alpha.4",
|
|
127
127
|
"@mastra/schema-compat": "1.3.7"
|
|
128
128
|
},
|
|
129
129
|
"homepage": "https://mastra.ai",
|