@mastra/server 1.64.0-alpha.6 → 1.64.0-alpha.7
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 +27 -33
- package/dist/{a2a-CMi5AZNR.js → a2a-DdCHhKh5.js} +7 -7
- package/dist/{a2a-CMi5AZNR.js.map → a2a-DdCHhKh5.js.map} +1 -1
- package/dist/{api-schema-manifest-C0fowe3V.js → api-schema-manifest-Ckuac2Uz.js} +2 -2
- package/dist/{api-schema-manifest-C0fowe3V.js.map → api-schema-manifest-Ckuac2Uz.js.map} +1 -1
- package/dist/{dist-JaHKn7NU.js → dist-BwPO-2NT.js} +1667 -1378
- package/dist/dist-BwPO-2NT.js.map +1 -0
- package/dist/{dist-BuyLBfu3.cjs → dist-mj70vroq.cjs} +1667 -1377
- package/dist/dist-mj70vroq.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{routes-D9HqtkO2.js → routes-DCdH7ljX.js} +2 -2
- package/dist/{routes-D9HqtkO2.js.map → routes-DCdH7ljX.js.map} +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +1 -1
- package/dist/server/handlers/mcp-client-versions.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +1 -1
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +1 -1
- package/dist/server/handlers/scorer-versions.js +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
- package/dist/server/handlers/stored-mcp-clients.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers/stored-scorers.cjs +1 -1
- package/dist/server/handlers/stored-scorers.js +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
- package/dist/server/handlers/stored-skill-favorites.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +1 -1
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers.js +1 -1
- package/dist/server/schemas/index.cjs +1 -1
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/package.json +7 -7
- package/dist/dist-BuyLBfu3.cjs.map +0 -1
- package/dist/dist-JaHKn7NU.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
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.
|
|
3
|
+
Typed, framework-agnostic HTTP route definitions, handlers, schemas, and adapter utilities for exposing a `Mastra` instance over HTTP. This package powers Mastra's development server and the framework-specific server adapters.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -12,56 +10,52 @@ npm install @mastra/server
|
|
|
12
10
|
|
|
13
11
|
## Usage
|
|
14
12
|
|
|
15
|
-
The handlers are framework
|
|
16
|
-
and a request context. They are typically mounted under a URL prefix within your
|
|
17
|
-
web framework of choice:
|
|
13
|
+
The handlers are framework-agnostic functions that accept a `Mastra` instance and request context. Import them from `@mastra/server/handlers`, then mount the route handlers under a URL prefix in your web framework:
|
|
18
14
|
|
|
19
15
|
```typescript
|
|
16
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
17
|
+
import { agents } from '@mastra/server/handlers';
|
|
20
18
|
import { Hono } from 'hono';
|
|
21
|
-
import { handlers } from '@mastra/server';
|
|
22
19
|
import { mastra } from './mastra-instance';
|
|
23
20
|
|
|
24
21
|
const app = new Hono();
|
|
25
22
|
|
|
26
|
-
app.get('/mastra/agents',
|
|
27
|
-
|
|
28
|
-
const body = await ctx.req.json();
|
|
29
|
-
return handlers.agents.generateHandler({
|
|
23
|
+
app.get('/mastra/agents', async c => {
|
|
24
|
+
const result = await agents.LIST_AGENTS_ROUTE.handler({
|
|
30
25
|
mastra,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
body,
|
|
26
|
+
partial: c.req.query('partial'),
|
|
27
|
+
requestContext: new RequestContext(),
|
|
34
28
|
});
|
|
29
|
+
|
|
30
|
+
return c.json(result);
|
|
35
31
|
});
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
export default app;
|
|
38
34
|
```
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
`http://localhost:3000` using these handlers.
|
|
36
|
+
Each exported route combines its HTTP method, path, validation schemas, permission requirements, response type, and handler. Framework adapter packages automate this registration and translate framework requests and responses into the common handler context.
|
|
42
37
|
|
|
43
|
-
##
|
|
38
|
+
## Documentation
|
|
44
39
|
|
|
45
|
-
|
|
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.
|
|
40
|
+
Handler groups cover agents and agent controllers, conversations, workflows and dynamic workflows, tools, MCP, memory, vectors, voice, logs, observability, scores, schedules, datasets, processors, workspaces, skills, plans, authentication, A2A tasks, and stored entities.
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
`Error`) when a failure should result in a non-2xx HTTP status.
|
|
42
|
+
Route handlers return serializable values or streams and throw `HTTPException` when an error should map to a non-2xx response. Shared schemas and error-formatting helpers are available through package subpaths for adapters that need to validate requests or emit OpenAPI metadata.
|
|
57
43
|
|
|
58
|
-
|
|
44
|
+
`@mastra/server/server-adapter` exports the abstract `MastraServer` contract and common route-registration utilities. Adapter packages implement framework-specific streaming, parameter extraction, response handling, context middleware, authentication middleware, and HTTP logging around this contract.
|
|
59
45
|
|
|
60
|
-
The
|
|
61
|
-
be refreshed by running:
|
|
46
|
+
The package's OpenAPI-derived route metadata can be refreshed from `packages/server` with:
|
|
62
47
|
|
|
63
48
|
```bash
|
|
64
49
|
pnpm run pull:openapispec
|
|
65
50
|
```
|
|
66
51
|
|
|
67
|
-
|
|
52
|
+
- [`MastraServer` adapter reference](https://mastra.ai/reference/server/mastra-server)
|
|
53
|
+
- [Server adapter guide](https://mastra.ai/docs/server/server-adapters)
|
|
54
|
+
|
|
55
|
+
## Changelog
|
|
56
|
+
|
|
57
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/packages/server/CHANGELOG.md) for version history and release notes.
|
|
58
|
+
|
|
59
|
+
## Support
|
|
60
|
+
|
|
61
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
|
@@ -8,7 +8,7 @@ import { getPublicOrigin } from "./server/handlers/auth.js";
|
|
|
8
8
|
import { z } from "zod/v4";
|
|
9
9
|
import { isDeepStrictEqual } from "util";
|
|
10
10
|
import { MastraA2AError } from "@mastra/core/a2a";
|
|
11
|
-
import * as crypto$
|
|
11
|
+
import * as crypto$2 from "crypto";
|
|
12
12
|
import { lookup } from "dns/promises";
|
|
13
13
|
import { request } from "http";
|
|
14
14
|
import { request as request$1 } from "https";
|
|
@@ -47,8 +47,8 @@ function stripAgentCardSignatures(agentCard) {
|
|
|
47
47
|
}
|
|
48
48
|
function importSigningKey(signing) {
|
|
49
49
|
const { privateKey } = signing;
|
|
50
|
-
if (typeof privateKey === "string") return crypto$
|
|
51
|
-
return crypto$
|
|
50
|
+
if (typeof privateKey === "string") return crypto$2.createPrivateKey(privateKey);
|
|
51
|
+
return crypto$2.createPrivateKey({
|
|
52
52
|
key: privateKey,
|
|
53
53
|
format: "jwk"
|
|
54
54
|
});
|
|
@@ -64,8 +64,8 @@ function getProtectedHeader(signing) {
|
|
|
64
64
|
function getSignatureOptions(algorithm) {
|
|
65
65
|
if (algorithm.startsWith("ES")) return { dsaEncoding: "ieee-p1363" };
|
|
66
66
|
if (algorithm.startsWith("PS")) return {
|
|
67
|
-
padding: crypto$
|
|
68
|
-
saltLength: crypto$
|
|
67
|
+
padding: crypto$2.constants.RSA_PKCS1_PSS_PADDING,
|
|
68
|
+
saltLength: crypto$2.constants.RSA_PSS_SALTLEN_DIGEST
|
|
69
69
|
};
|
|
70
70
|
return {};
|
|
71
71
|
}
|
|
@@ -82,7 +82,7 @@ async function signAgentCard({ agentCard, signing }) {
|
|
|
82
82
|
const protectedHeader = getProtectedHeader(signing);
|
|
83
83
|
const encodedHeader = Buffer.from(JSON.stringify(protectedHeader), "utf8").toString("base64url");
|
|
84
84
|
const signingInput = `${encodedHeader}.${Buffer.from(canonicalPayload, "utf8").toString("base64url")}`;
|
|
85
|
-
const signatureValue = crypto$
|
|
85
|
+
const signatureValue = crypto$2.sign(getDigestAlgorithm(String(protectedHeader.alg)), Buffer.from(signingInput, "utf8"), {
|
|
86
86
|
key,
|
|
87
87
|
...getSignatureOptions(String(protectedHeader.alg))
|
|
88
88
|
}).toString("base64url");
|
|
@@ -1973,4 +1973,4 @@ const AGENT_EXECUTION_ROUTE = createRoute({
|
|
|
1973
1973
|
//#endregion
|
|
1974
1974
|
export { getAgentExecutionHandler as a, handleListTaskPushNotificationConfig as c, handleSetTaskPushNotificationConfig as d, handleTaskCancel as f, resolveA2AProtocolVersion as g, handleTaskResubscribe as h, getAgentCardByIdHandler as i, handleMessageSend as l, handleTaskList as m, GET_AGENT_CARD_ROUTE as n, handleDeleteTaskPushNotificationConfig as o, handleTaskGet as p, a2a_exports as r, handleGetTaskPushNotificationConfig as s, AGENT_EXECUTION_ROUTE as t, handleMessageStream as u };
|
|
1975
1975
|
|
|
1976
|
-
//# sourceMappingURL=a2a-
|
|
1976
|
+
//# sourceMappingURL=a2a-DdCHhKh5.js.map
|