@mastra/elysia 0.0.0-knowledge-org-scope-20260902233451

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.md ADDED
@@ -0,0 +1,32 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named `ee/` within this
4
+ repository, including but not limited to:
5
+ - `@mastra/core/auth/ee`
6
+ - `@mastra/core/agent-builder/ee`
7
+ - `@mastra/editor/ee`
8
+
9
+ is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
10
+
11
+ - All third-party components incorporated into the Mastra Software are
12
+ licensed under the original license provided by the owner of the
13
+ applicable component.
14
+
15
+ - Content outside of the above-mentioned directories or restrictions is
16
+ available under the "Apache License 2.0" as defined below.
17
+
18
+ # Apache License 2.0
19
+
20
+ Copyright (c) 2025 Kepler Software, Inc.
21
+
22
+ Licensed under the Apache License, Version 2.0 (the "License");
23
+ you may not use this file except in compliance with the License.
24
+ You may obtain a copy of the License at
25
+
26
+ http://www.apache.org/licenses/LICENSE-2.0
27
+
28
+ Unless required by applicable law or agreed to in writing, software
29
+ distributed under the License is distributed on an "AS IS" BASIS,
30
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ See the License for the specific language governing permissions and
32
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @mastra/elysia
2
+
3
+ `@mastra/elysia` mounts Mastra's agent, workflow, tool, memory, and streaming APIs on an Elysia application. Use it when Elysia is already your HTTP server and you want Mastra endpoints in the same process.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/elysia
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { Elysia } from 'elysia';
15
+ import { MastraServer } from '@mastra/elysia';
16
+ import { mastra } from './mastra';
17
+
18
+ const app = new Elysia();
19
+ const server = new MastraServer({ app, mastra });
20
+ await server.init();
21
+ ```
22
+
23
+ ## Documentation
24
+
25
+ - [Reference: Elysia adapter](https://mastra.ai/reference/server/elysia-adapter)
26
+
27
+ ## Changelog
28
+
29
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/server-adapters/elysia/CHANGELOG.md) for version history and release notes.
30
+
31
+ ## Support
32
+
33
+ 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.
@@ -0,0 +1,12 @@
1
+ import type { Server } from 'node:http';
2
+ import type Elysia from 'elysia';
3
+ /**
4
+ * Starts a real Node HTTP server that delegates requests to an Elysia app's fetch method.
5
+ * This is needed for tests that use `fetch()` directly (multipart, OpenAPI, custom routes, MCP transport).
6
+ */
7
+ export declare function startElysiaServer(app: Elysia): Promise<{
8
+ baseUrl: string;
9
+ cleanup: () => Promise<void>;
10
+ server: Server;
11
+ }>;
12
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,MAAM,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAiFD"}
@@ -0,0 +1,7 @@
1
+ import type { Mastra } from '@mastra/core/mastra';
2
+ export interface ElysiaAuthMiddlewareOptions {
3
+ mastra: Mastra;
4
+ requiresAuth?: boolean;
5
+ }
6
+ export declare function createAuthMiddleware({ mastra, requiresAuth, }: ElysiaAuthMiddlewareOptions): (ctx: any) => Promise<globalThis.Response | void>;
7
+ //# sourceMappingURL=auth-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-middleware.d.ts","sourceRoot":"","sources":["../src/auth-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,YAAmB,GACpB,EAAE,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8CjF"}
@@ -0,0 +1,60 @@
1
+ import type { MastraServer } from './index.js';
2
+ /**
3
+ * Get OpenAPI documentation from a MastraServer instance, formatted for Elysia's openapi plugin.
4
+ *
5
+ * This function:
6
+ * - Extracts all Mastra routes with their Zod schemas
7
+ * - Converts them to OpenAPI 3.1.0 format
8
+ * - Merges custom routes if registered
9
+ * - Applies the configured route prefix to all paths
10
+ * - Caches the result for performance
11
+ *
12
+ * @param server - The MastraServer instance (must be initialized with init())
13
+ * @param options - Optional configuration for OpenAPI metadata
14
+ * @returns OpenAPI documentation with paths, components, and info
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { getMastraOpenAPIDoc } from '@mastra/elysia';
19
+ *
20
+ * const srv = new MastraServer({ mastra, app, prefix: '/api' });
21
+ * await srv.init();
22
+ *
23
+ * const openAPIDoc = getMastraOpenAPIDoc(srv, {
24
+ * title: 'My Mastra API',
25
+ * version: '1.0.0',
26
+ * description: 'API with weather agent'
27
+ * });
28
+ *
29
+ * app.use(openapi({
30
+ * documentation: {
31
+ * info: openAPIDoc.info,
32
+ * paths: openAPIDoc.paths,
33
+ * components: openAPIDoc.components
34
+ * }
35
+ * }));
36
+ * ```
37
+ */
38
+ export declare function getMastraOpenAPIDoc(server: MastraServer, options?: {
39
+ title?: string;
40
+ version?: string;
41
+ description?: string;
42
+ clearCache?: boolean;
43
+ }): {
44
+ paths: Record<string, any>;
45
+ components?: Record<string, any>;
46
+ info: {
47
+ title: string;
48
+ version: string;
49
+ description?: string;
50
+ };
51
+ };
52
+ /**
53
+ * Clear the OpenAPI documentation cache.
54
+ * Call this if routes are added dynamically after initialization.
55
+ *
56
+ * `@param` server - The MastraServer instance to clear cache for.
57
+ * Note: WeakMap does not support clearing all entries. Pass the specific server instance whose cache should be invalidated.
58
+ */
59
+ export declare function clearMastraOpenAPICache(server?: MastraServer): void;
60
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAe5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE,CA8DA;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAKnE"}