@mastra/deployer-sandbox 0.0.0 → 0.1.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/LICENSE.md +30 -0
  3. package/dist/alias.d.ts +10 -0
  4. package/dist/alias.d.ts.map +1 -0
  5. package/dist/chunk-CSXC6CZL.cjs +115 -0
  6. package/dist/chunk-CSXC6CZL.cjs.map +1 -0
  7. package/dist/chunk-Z636GNUQ.js +101 -0
  8. package/dist/chunk-Z636GNUQ.js.map +1 -0
  9. package/dist/client/index.cjs +159 -0
  10. package/dist/client/index.cjs.map +1 -0
  11. package/dist/client/index.d.ts +98 -0
  12. package/dist/client/index.d.ts.map +1 -0
  13. package/dist/client/index.js +155 -0
  14. package/dist/client/index.js.map +1 -0
  15. package/dist/deployer.d.ts +57 -0
  16. package/dist/deployer.d.ts.map +1 -0
  17. package/dist/engine.d.ts +19 -0
  18. package/dist/engine.d.ts.map +1 -0
  19. package/dist/index.cjs +381 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +372 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/manifest.d.ts +7 -0
  26. package/dist/manifest.d.ts.map +1 -0
  27. package/dist/shared.d.ts +63 -0
  28. package/dist/shared.d.ts.map +1 -0
  29. package/dist/studio/assets/CommitMono-400-Regular-DzkyLZ26.woff2 +0 -0
  30. package/dist/studio/assets/CommitMono-700-Regular-DmOSN4kd.woff2 +0 -0
  31. package/dist/studio/assets/MonaSans-VariableFont_wdth-wght-CX-7s9jm.ttf +0 -0
  32. package/dist/studio/assets/babel-lWBcy2sH.js +16 -0
  33. package/dist/studio/assets/bash-atvbtKCR.js +1 -0
  34. package/dist/studio/assets/core-CBT9ED6Q.js +12 -0
  35. package/dist/studio/assets/engine-compile-BkERmzkH.js +137 -0
  36. package/dist/studio/assets/engine-javascript-CSIo_1eZ.js +1 -0
  37. package/dist/studio/assets/estree-Dd9JfUIE.js +44 -0
  38. package/dist/studio/assets/github-dark-DHJKELXO.js +1 -0
  39. package/dist/studio/assets/github-light-DAi9KRSo.js +1 -0
  40. package/dist/studio/assets/index-CORJOrgI.js +2 -0
  41. package/dist/studio/assets/index-yUiD89B4.js +1 -0
  42. package/dist/studio/assets/javascript-ySlJ1b_l.js +1 -0
  43. package/dist/studio/assets/json-BQoSv7ci.js +1 -0
  44. package/dist/studio/assets/jsx-BAng5TT0.js +1 -0
  45. package/dist/studio/assets/livekit-client.esm-CKIgC2IJ.js +39 -0
  46. package/dist/studio/assets/main-BYaOwSFl.js +784 -0
  47. package/dist/studio/assets/markdown-UIAJJxZW.js +1 -0
  48. package/dist/studio/assets/preload-helper-PPVm8Dsz.js +1 -0
  49. package/dist/studio/assets/python-DhUJRlN_.js +1 -0
  50. package/dist/studio/assets/shell-CjFT_Tl9.js +1 -0
  51. package/dist/studio/assets/standalone-Dfz2oS5J.js +29 -0
  52. package/dist/studio/assets/style-DMLmyAwy.css +1 -0
  53. package/dist/studio/assets/tsx-B6W0miNI.js +1 -0
  54. package/dist/studio/assets/typescript-Dj6nwHGl.js +1 -0
  55. package/dist/studio/index.html +100 -0
  56. package/dist/studio/mastra.svg +17 -0
  57. package/dist/studio/routes-manifest.json +27 -0
  58. package/dist/types.d.ts +90 -0
  59. package/dist/types.d.ts.map +1 -0
  60. package/package.json +18 -18
@@ -0,0 +1,98 @@
1
+ import type { WorkspaceSandbox } from '@mastra/core/workspace';
2
+ export type DeploymentStatus = 'running' | 'stopped' | 'unknown';
3
+ export interface GetDeploymentOptions {
4
+ /**
5
+ * The sandbox to resolve. Provider construction is identity — e.g.
6
+ * `new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] })` resolves
7
+ * the same sandbox from any process.
8
+ */
9
+ sandbox: WorkspaceSandbox;
10
+ /** Port the Mastra server listens on. Defaults to 4111. */
11
+ port?: number;
12
+ /**
13
+ * Wake the sandbox when it is not running. Waking starts (resumes) the
14
+ * sandbox and, only if the server is not answering, relaunches it from the
15
+ * recorded launch script — some providers (e.g. E2B) resume processes on
16
+ * wake, others (e.g. Vercel) restore just the filesystem. Defaults to false.
17
+ */
18
+ wake?: boolean;
19
+ /** Directory the app was deployed into. Defaults to `$HOME/mastra-app` resolved inside the sandbox. */
20
+ remoteDir?: string;
21
+ /** Path polled for health. Defaults to `/api`. */
22
+ healthCheckPath?: string;
23
+ /** Max time to wait for health after a wake, in ms. Defaults to 60000. */
24
+ healthCheckTimeoutMs?: number;
25
+ }
26
+ export interface ResolvedDeployment {
27
+ /** Public URL of the Mastra server, or null when it could not be resolved without waking. */
28
+ url: string | null;
29
+ status: DeploymentStatus;
30
+ /** When the sandbox will auto-shutdown (when known). */
31
+ expiresAt?: Date;
32
+ stop(): Promise<void>;
33
+ destroy(): Promise<void>;
34
+ logs(lines?: number): Promise<string>;
35
+ }
36
+ /**
37
+ * Resolve (and optionally wake) a sandbox deployment.
38
+ *
39
+ * With `wake: false` (default) the sandbox is not started: the URL is resolved
40
+ * only if the sandbox is already running in this process, otherwise
41
+ * `{ url: null, status: 'stopped' | 'unknown' }` is returned and the caller
42
+ * decides whether to wake.
43
+ *
44
+ * With `wake: true` the sandbox is started (providers resume by identity,
45
+ * e.g. name), the server is relaunched if it is not answering, and the
46
+ * deployment is returned once healthy.
47
+ */
48
+ export declare function getDeployment(options: GetDeploymentOptions): Promise<ResolvedDeployment>;
49
+ export interface CreateSandboxHandlerOptions {
50
+ /**
51
+ * Resolve the current sandbox URL. Called once, cached, and re-invoked when
52
+ * a forwarded request fails at the network level (e.g. the sandbox rotated
53
+ * its URL or went to sleep). Typically wraps `getDeployment`:
54
+ *
55
+ * ```typescript
56
+ * createSandboxHandler({
57
+ * resolve: async () => {
58
+ * const dep = await getDeployment({ sandbox, wake: true });
59
+ * return dep.url!;
60
+ * },
61
+ * });
62
+ * ```
63
+ */
64
+ resolve: () => Promise<string>;
65
+ /** Shared secret attached as the `x-mastra-sandbox-secret` header on forwarded requests. */
66
+ secret?: string;
67
+ }
68
+ /**
69
+ * Framework-free route-handler proxy (fetch `Request` → `Response`). Mount it
70
+ * as a catch-all API route; the browser only ever sees your own domain, and
71
+ * the sandbox URL (which rotates across resumes) stays server-side.
72
+ */
73
+ export declare function createSandboxHandler(options: CreateSandboxHandlerOptions): (request: Request) => Promise<Response>;
74
+ export interface CreateSandboxProxyOptions {
75
+ /** Edge Config item key that holds the current sandbox URL. */
76
+ key: string;
77
+ /**
78
+ * Edge Config connection string (`https://edge-config.vercel.com/ecfg_...?token=...`).
79
+ * Defaults to `process.env.EDGE_CONFIG`.
80
+ */
81
+ edgeConfig?: string;
82
+ /** Shared secret attached as the `x-mastra-sandbox-secret` header on the rewrite. */
83
+ secret?: string;
84
+ }
85
+ /**
86
+ * Next.js middleware helper for Tier 3 routing: reads the current sandbox URL
87
+ * from Edge Config (kept fresh by the deployer's `alias` option) and rewrites
88
+ * the request to it. Returns `undefined` when no URL is configured so the
89
+ * request falls through.
90
+ *
91
+ * ```typescript
92
+ * // middleware.ts
93
+ * export const middleware = createSandboxProxy({ key: 'my-preview' });
94
+ * export const config = { matcher: '/api/:path*' };
95
+ * ```
96
+ */
97
+ export declare function createSandboxProxy(options: CreateSandboxProxyOptions): (request: Request) => Promise<Response | undefined>;
98
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAqB/D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,gBAAgB,CAAC;IAC1B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,IAAI,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C,QAAQ,GAAG,SAAS,CAAC,CAqCrD"}
@@ -0,0 +1,155 @@
1
+ import { DEFAULT_PORT, waitForHealthy, resolveRemoteDir, killPreviousServer, launchServer, tailServerLog, getInfoSafe } from '../chunk-Z636GNUQ.js';
2
+ import { supportsNetworking } from '@mastra/core/workspace';
3
+
4
+ function assertServerOnly() {
5
+ if (typeof globalThis.window !== "undefined") {
6
+ throw new Error(
7
+ "@mastra/deployer-sandbox/client is server-only: resolving a sandbox requires provider credentials that must never reach the browser. Proxy requests through your own backend instead (see createSandboxHandler / createSandboxProxy)."
8
+ );
9
+ }
10
+ }
11
+ async function getDeployment(options) {
12
+ assertServerOnly();
13
+ const {
14
+ sandbox,
15
+ port = DEFAULT_PORT,
16
+ wake = false,
17
+ healthCheckPath = "/api",
18
+ healthCheckTimeoutMs = 6e4
19
+ } = options;
20
+ const handle = (url2, status, expiresAt) => ({
21
+ url: url2,
22
+ status,
23
+ expiresAt,
24
+ stop: async () => {
25
+ await sandbox.stop?.();
26
+ },
27
+ destroy: async () => {
28
+ await sandbox.destroy?.();
29
+ },
30
+ // Resolved lazily — reading logs requires a running sandbox anyway.
31
+ logs: async (lines) => tailServerLog(sandbox, await resolveRemoteDir(sandbox, options.remoteDir), lines)
32
+ });
33
+ if (!wake) {
34
+ const url2 = supportsNetworking(sandbox) ? await sandbox.networking.getPortUrl(port) : null;
35
+ if (!url2) {
36
+ return handle(null, "stopped");
37
+ }
38
+ const healthy2 = await waitForHealthy(url2, { path: healthCheckPath, timeoutMs: 3e3, intervalMs: 1e3 });
39
+ return handle(url2, healthy2 ? "running" : "stopped");
40
+ }
41
+ await sandbox.start?.();
42
+ if (!supportsNetworking(sandbox)) {
43
+ throw new Error(`Sandbox provider "${sandbox.provider}" does not support networking (public port URLs).`);
44
+ }
45
+ const url = await sandbox.networking.getPortUrl(port);
46
+ if (!url) {
47
+ throw new Error(
48
+ `Sandbox provider "${sandbox.provider}" did not expose a public URL for port ${port}. Make sure the port is declared when constructing the sandbox (e.g. \`ports: [${port}]\`).`
49
+ );
50
+ }
51
+ let healthy = await waitForHealthy(url, { path: healthCheckPath, timeoutMs: 3e3, intervalMs: 1e3 });
52
+ if (!healthy) {
53
+ const remoteDir = await resolveRemoteDir(sandbox, options.remoteDir);
54
+ await killPreviousServer(sandbox, remoteDir);
55
+ await launchServer(sandbox, remoteDir);
56
+ healthy = await waitForHealthy(url, { path: healthCheckPath, timeoutMs: healthCheckTimeoutMs, intervalMs: 1e3 });
57
+ }
58
+ if (!healthy) {
59
+ const log = await resolveRemoteDir(sandbox, options.remoteDir).then((dir) => tailServerLog(sandbox, dir)).catch(() => "");
60
+ throw new Error(
61
+ `Woke sandbox but the Mastra server did not become healthy at ${url}${healthCheckPath}.` + (log ? `
62
+
63
+ Server log:
64
+ ${log}` : "")
65
+ );
66
+ }
67
+ const info = await getInfoSafe(sandbox);
68
+ return handle(url, "running", info?.timeoutAt);
69
+ }
70
+ function createSandboxHandler(options) {
71
+ assertServerOnly();
72
+ let cachedUrl = null;
73
+ const forward = async (request, baseUrl) => {
74
+ const incoming = new URL(request.url);
75
+ const target = new URL(incoming.pathname + incoming.search, baseUrl);
76
+ const headers = new Headers(request.headers);
77
+ headers.delete("host");
78
+ if (options.secret) {
79
+ headers.set("x-mastra-sandbox-secret", options.secret);
80
+ }
81
+ const response = await fetch(target, {
82
+ method: request.method,
83
+ headers,
84
+ body: request.body,
85
+ // duplex is required by Node's fetch for streamed request bodies
86
+ duplex: "half",
87
+ redirect: "manual"
88
+ });
89
+ const location = response.headers.get("location");
90
+ if (location) {
91
+ const resolved = new URL(location, target);
92
+ if (resolved.origin === new URL(baseUrl).origin) {
93
+ const rewritten = new URL(resolved.pathname + resolved.search + resolved.hash, incoming.origin);
94
+ const responseHeaders = new Headers(response.headers);
95
+ responseHeaders.set("location", rewritten.toString());
96
+ return new Response(response.body, {
97
+ status: response.status,
98
+ statusText: response.statusText,
99
+ headers: responseHeaders
100
+ });
101
+ }
102
+ }
103
+ return response;
104
+ };
105
+ return async (request) => {
106
+ cachedUrl ??= options.resolve();
107
+ try {
108
+ return await forward(request, await cachedUrl);
109
+ } catch (error) {
110
+ cachedUrl = null;
111
+ if (!["GET", "HEAD", "OPTIONS"].includes(request.method)) {
112
+ throw error;
113
+ }
114
+ cachedUrl = options.resolve();
115
+ try {
116
+ return await forward(request, await cachedUrl);
117
+ } catch (retryError) {
118
+ cachedUrl = null;
119
+ throw retryError;
120
+ }
121
+ }
122
+ };
123
+ }
124
+ function createSandboxProxy(options) {
125
+ assertServerOnly();
126
+ return async (request) => {
127
+ const connection = options.edgeConfig ?? process.env.EDGE_CONFIG;
128
+ if (!connection) {
129
+ throw new Error("createSandboxProxy requires an Edge Config connection string (EDGE_CONFIG).");
130
+ }
131
+ const conn = new URL(connection);
132
+ const token = conn.searchParams.get("token");
133
+ const itemUrl = new URL(`${conn.origin}${conn.pathname}/item/${encodeURIComponent(options.key)}`);
134
+ const res = await fetch(itemUrl, { headers: { Authorization: `Bearer ${token}` } });
135
+ if (!res.ok) {
136
+ return void 0;
137
+ }
138
+ const sandboxUrl = await res.json();
139
+ if (typeof sandboxUrl !== "string" || !sandboxUrl) {
140
+ return void 0;
141
+ }
142
+ const incoming = new URL(request.url);
143
+ const target = new URL(incoming.pathname + incoming.search, sandboxUrl);
144
+ const headers = new Headers({ "x-middleware-rewrite": target.toString() });
145
+ if (options.secret) {
146
+ headers.set("x-middleware-request-x-mastra-sandbox-secret", options.secret);
147
+ headers.set("x-middleware-override-headers", "x-mastra-sandbox-secret");
148
+ }
149
+ return new Response(null, { headers });
150
+ };
151
+ }
152
+
153
+ export { createSandboxHandler, createSandboxProxy, getDeployment };
154
+ //# sourceMappingURL=index.js.map
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/index.ts"],"names":["url","healthy"],"mappings":";;;AAoBA,SAAS,gBAAA,GAAyB;AAChC,EAAA,IAAI,OAAQ,UAAA,CAAoC,MAAA,KAAW,WAAA,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A,GAAW,QAAA,CAAS,QAAQ,UAAU,CAAA;AAKtE,IAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,EAAE,wBAAwB,MAAA,CAAO,QAAA,IAAY,CAAA;AACzE,IAAA,IAAI,QAAQ,MAAA,EAAQ;AAClB,MAAA,OAAA,CAAQ,GAAA,CAAI,8CAAA,EAAgD,OAAA,CAAQ,MAAM,CAAA;AAC1E,MAAA,OAAA,CAAQ,GAAA,CAAI,iCAAiC,yBAAyB,CAAA;AAAA,IACxE;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,EAAM,EAAE,SAAS,CAAA;AAAA,EACvC,CAAA;AACF","file":"index.js","sourcesContent":["/**\n * Runtime resolver + routing helpers for sandbox deployments.\n *\n * SERVER-ONLY. This module resolves sandbox URLs using provider credentials\n * (e.g. VERCEL_TOKEN) — importing it in the browser would ship those\n * credentials to the client. Use the proxy/handler patterns instead so the\n * browser only ever talks to your own domain.\n */\nimport { supportsNetworking } from '@mastra/core/workspace';\nimport type { WorkspaceSandbox } from '@mastra/core/workspace';\nimport {\n DEFAULT_PORT,\n getInfoSafe,\n killPreviousServer,\n launchServer,\n resolveRemoteDir,\n tailServerLog,\n waitForHealthy,\n} from '../shared';\n\nfunction assertServerOnly(): void {\n if (typeof (globalThis as { window?: unknown }).window !== 'undefined') {\n throw new Error(\n '@mastra/deployer-sandbox/client is server-only: resolving a sandbox requires provider credentials ' +\n 'that must never reach the browser. Proxy requests through your own backend instead ' +\n '(see createSandboxHandler / createSandboxProxy).',\n );\n }\n}\n\nexport type DeploymentStatus = 'running' | 'stopped' | 'unknown';\n\nexport interface GetDeploymentOptions {\n /**\n * The sandbox to resolve. Provider construction is identity — e.g.\n * `new VercelSandbox({ sandboxName: 'my-preview', ports: [4111] })` resolves\n * the same sandbox from any process.\n */\n sandbox: WorkspaceSandbox;\n /** Port the Mastra server listens on. Defaults to 4111. */\n port?: number;\n /**\n * Wake the sandbox when it is not running. Waking starts (resumes) the\n * sandbox and, only if the server is not answering, relaunches it from the\n * recorded launch script — some providers (e.g. E2B) resume processes on\n * wake, others (e.g. Vercel) restore just the filesystem. Defaults to false.\n */\n wake?: boolean;\n /** Directory the app was deployed into. Defaults to `$HOME/mastra-app` resolved inside the sandbox. */\n remoteDir?: string;\n /** Path polled for health. Defaults to `/api`. */\n healthCheckPath?: string;\n /** Max time to wait for health after a wake, in ms. Defaults to 60000. */\n healthCheckTimeoutMs?: number;\n}\n\nexport interface ResolvedDeployment {\n /** Public URL of the Mastra server, or null when it could not be resolved without waking. */\n url: string | null;\n status: DeploymentStatus;\n /** When the sandbox will auto-shutdown (when known). */\n expiresAt?: Date;\n stop(): Promise<void>;\n destroy(): Promise<void>;\n logs(lines?: number): Promise<string>;\n}\n\n/**\n * Resolve (and optionally wake) a sandbox deployment.\n *\n * With `wake: false` (default) the sandbox is not started: the URL is resolved\n * only if the sandbox is already running in this process, otherwise\n * `{ url: null, status: 'stopped' | 'unknown' }` is returned and the caller\n * decides whether to wake.\n *\n * With `wake: true` the sandbox is started (providers resume by identity,\n * e.g. name), the server is relaunched if it is not answering, and the\n * deployment is returned once healthy.\n */\nexport async function getDeployment(options: GetDeploymentOptions): Promise<ResolvedDeployment> {\n assertServerOnly();\n\n const {\n sandbox,\n port = DEFAULT_PORT,\n wake = false,\n healthCheckPath = '/api',\n healthCheckTimeoutMs = 60_000,\n } = options;\n\n const handle = (url: string | null, status: DeploymentStatus, expiresAt?: Date): ResolvedDeployment => ({\n url,\n status,\n expiresAt,\n stop: async () => {\n await sandbox.stop?.();\n },\n destroy: async () => {\n await sandbox.destroy?.();\n },\n // Resolved lazily — reading logs requires a running sandbox anyway.\n logs: async (lines?: number) => tailServerLog(sandbox, await resolveRemoteDir(sandbox, options.remoteDir), lines),\n });\n\n if (!wake) {\n // Resolve without starting the sandbox (starting can resume billing).\n const url = supportsNetworking(sandbox) ? await sandbox.networking.getPortUrl(port) : null;\n if (!url) {\n return handle(null, 'stopped');\n }\n const healthy = await waitForHealthy(url, { path: healthCheckPath, timeoutMs: 3_000, intervalMs: 1_000 });\n return handle(url, healthy ? 'running' : 'stopped');\n }\n\n await sandbox.start?.();\n\n if (!supportsNetworking(sandbox)) {\n throw new Error(`Sandbox provider \"${sandbox.provider}\" does not support networking (public port URLs).`);\n }\n const url = await sandbox.networking.getPortUrl(port);\n if (!url) {\n throw new Error(\n `Sandbox provider \"${sandbox.provider}\" did not expose a public URL for port ${port}. ` +\n `Make sure the port is declared when constructing the sandbox (e.g. \\`ports: [${port}]\\`).`,\n );\n }\n\n // Some providers (e.g. Vercel) restore the filesystem but not processes on\n // resume, while others (e.g. E2B) resume processes too — relaunch the server\n // from the recorded launch script only when it is not answering.\n let healthy = await waitForHealthy(url, { path: healthCheckPath, timeoutMs: 3_000, intervalMs: 1_000 });\n if (!healthy) {\n const remoteDir = await resolveRemoteDir(sandbox, options.remoteDir);\n await killPreviousServer(sandbox, remoteDir);\n await launchServer(sandbox, remoteDir);\n healthy = await waitForHealthy(url, { path: healthCheckPath, timeoutMs: healthCheckTimeoutMs, intervalMs: 1_000 });\n }\n if (!healthy) {\n const log = await resolveRemoteDir(sandbox, options.remoteDir)\n .then(dir => tailServerLog(sandbox, dir))\n .catch(() => '');\n throw new Error(\n `Woke sandbox but the Mastra server did not become healthy at ${url}${healthCheckPath}.` +\n (log ? `\\n\\nServer log:\\n${log}` : ''),\n );\n }\n\n const info = await getInfoSafe(sandbox);\n return handle(url, 'running', info?.timeoutAt);\n}\n\n// =============================================================================\n// Tier 3 helpers\n// =============================================================================\n\nexport interface CreateSandboxHandlerOptions {\n /**\n * Resolve the current sandbox URL. Called once, cached, and re-invoked when\n * a forwarded request fails at the network level (e.g. the sandbox rotated\n * its URL or went to sleep). Typically wraps `getDeployment`:\n *\n * ```typescript\n * createSandboxHandler({\n * resolve: async () => {\n * const dep = await getDeployment({ sandbox, wake: true });\n * return dep.url!;\n * },\n * });\n * ```\n */\n resolve: () => Promise<string>;\n /** Shared secret attached as the `x-mastra-sandbox-secret` header on forwarded requests. */\n secret?: string;\n}\n\n/**\n * Framework-free route-handler proxy (fetch `Request` → `Response`). Mount it\n * as a catch-all API route; the browser only ever sees your own domain, and\n * the sandbox URL (which rotates across resumes) stays server-side.\n */\nexport function createSandboxHandler(options: CreateSandboxHandlerOptions): (request: Request) => Promise<Response> {\n assertServerOnly();\n\n let cachedUrl: Promise<string> | null = null;\n\n const forward = async (request: Request, baseUrl: string): Promise<Response> => {\n const incoming = new URL(request.url);\n const target = new URL(incoming.pathname + incoming.search, baseUrl);\n\n const headers = new Headers(request.headers);\n headers.delete('host');\n if (options.secret) {\n headers.set('x-mastra-sandbox-secret', options.secret);\n }\n\n const response = await fetch(target, {\n method: request.method,\n headers,\n body: request.body,\n // duplex is required by Node's fetch for streamed request bodies\n duplex: 'half',\n redirect: 'manual',\n } as RequestInit);\n\n // Redirects are passed through manually — rewrite sandbox-host Locations\n // onto the incoming origin so the rotating sandbox URL never reaches the\n // browser (and subsequent requests keep flowing through this handler).\n const location = response.headers.get('location');\n if (location) {\n const resolved = new URL(location, target);\n if (resolved.origin === new URL(baseUrl).origin) {\n const rewritten = new URL(resolved.pathname + resolved.search + resolved.hash, incoming.origin);\n const responseHeaders = new Headers(response.headers);\n responseHeaders.set('location', rewritten.toString());\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: responseHeaders,\n });\n }\n }\n\n return response;\n };\n\n return async (request: Request): Promise<Response> => {\n cachedUrl ??= options.resolve();\n\n try {\n return await forward(request, await cachedUrl);\n } catch (error) {\n // Connection-level failure: the sandbox may have rotated its URL or gone\n // to sleep. Drop the cached URL so the next request re-resolves, and\n // retry once — but only for idempotent, bodyless methods. A failed\n // connection doesn't prove a write never landed, and a streamed body is\n // already consumed.\n cachedUrl = null;\n if (!['GET', 'HEAD', 'OPTIONS'].includes(request.method)) {\n throw error;\n }\n cachedUrl = options.resolve();\n try {\n return await forward(request, await cachedUrl);\n } catch (retryError) {\n cachedUrl = null;\n throw retryError;\n }\n }\n };\n}\n\nexport interface CreateSandboxProxyOptions {\n /** Edge Config item key that holds the current sandbox URL. */\n key: string;\n /**\n * Edge Config connection string (`https://edge-config.vercel.com/ecfg_...?token=...`).\n * Defaults to `process.env.EDGE_CONFIG`.\n */\n edgeConfig?: string;\n /** Shared secret attached as the `x-mastra-sandbox-secret` header on the rewrite. */\n secret?: string;\n}\n\n/**\n * Next.js middleware helper for Tier 3 routing: reads the current sandbox URL\n * from Edge Config (kept fresh by the deployer's `alias` option) and rewrites\n * the request to it. Returns `undefined` when no URL is configured so the\n * request falls through.\n *\n * ```typescript\n * // middleware.ts\n * export const middleware = createSandboxProxy({ key: 'my-preview' });\n * export const config = { matcher: '/api/:path*' };\n * ```\n */\nexport function createSandboxProxy(\n options: CreateSandboxProxyOptions,\n): (request: Request) => Promise<Response | undefined> {\n // Reads (and would transmit) the Edge Config bearer token — same\n // server-only contract as the rest of this module.\n assertServerOnly();\n\n return async (request: Request): Promise<Response | undefined> => {\n const connection = options.edgeConfig ?? process.env.EDGE_CONFIG;\n if (!connection) {\n throw new Error('createSandboxProxy requires an Edge Config connection string (EDGE_CONFIG).');\n }\n\n const conn = new URL(connection);\n const token = conn.searchParams.get('token');\n const itemUrl = new URL(`${conn.origin}${conn.pathname}/item/${encodeURIComponent(options.key)}`);\n\n const res = await fetch(itemUrl, { headers: { Authorization: `Bearer ${token}` } });\n if (!res.ok) {\n return undefined;\n }\n const sandboxUrl: unknown = await res.json();\n if (typeof sandboxUrl !== 'string' || !sandboxUrl) {\n return undefined;\n }\n\n const incoming = new URL(request.url);\n const target = new URL(incoming.pathname + incoming.search, sandboxUrl);\n\n // A Response with the x-middleware-rewrite header is how Next.js\n // middleware expresses a rewrite (NextResponse.rewrite does the same) —\n // this keeps the helper free of a next dependency.\n const headers = new Headers({ 'x-middleware-rewrite': target.toString() });\n if (options.secret) {\n headers.set('x-middleware-request-x-mastra-sandbox-secret', options.secret);\n headers.set('x-middleware-override-headers', 'x-mastra-sandbox-secret');\n }\n return new Response(null, { headers });\n };\n}\n"]}
@@ -0,0 +1,57 @@
1
+ import type { Config } from '@mastra/core/mastra';
2
+ import type { WorkspaceSandbox } from '@mastra/core/workspace';
3
+ import { Deployer } from '@mastra/deployer';
4
+ import type { SandboxDeployerOptions } from './types.js';
5
+ /**
6
+ * Deploy a full Mastra server into any workspace sandbox that supports
7
+ * networking (Vercel Sandbox, E2B, ...) and get a live public URL.
8
+ *
9
+ * Positioning: ephemeral environments — instant previews, PR/CI smoke deploys,
10
+ * agent-built-app verification. Not production hosting.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { SandboxDeployer } from '@mastra/deployer-sandbox';
15
+ * import { VercelSandbox } from '@mastra/vercel';
16
+ *
17
+ * export const mastra = new Mastra({
18
+ * deployer: new SandboxDeployer({
19
+ * sandbox: new VercelSandbox({ sandboxName: 'my-preview', timeout: 3_600_000, ports: [4111] }),
20
+ * }),
21
+ * });
22
+ * ```
23
+ */
24
+ export declare class SandboxDeployer extends Deployer {
25
+ /** Sandbox deploys are push-style: `mastra build` runs `deploy()` after bundling. */
26
+ readonly deployOnBuild = true;
27
+ readonly sandbox: WorkspaceSandbox;
28
+ readonly port: number;
29
+ readonly studio: boolean;
30
+ /** Explicit remote dir, when configured. The engine defaults to `$HOME/mastra-app` inside the sandbox. */
31
+ readonly remoteDir?: string;
32
+ private readonly env;
33
+ private readonly alias?;
34
+ private readonly healthCheckTimeoutMs?;
35
+ constructor(options: SandboxDeployerOptions);
36
+ /**
37
+ * Merge all existing env files instead of only the first one (base behavior).
38
+ * Later files win in `loadEnvVars()`, so order least → most specific: a
39
+ * `.env.local` written by `vercel env pull` shouldn't shadow the `.env` that
40
+ * holds the app's own keys.
41
+ */
42
+ getEnvFiles(): Promise<string[]>;
43
+ protected getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<NonNullable<Config['bundler']>>;
44
+ protected getEntry(): string;
45
+ prepare(outputDirectory: string): Promise<void>;
46
+ bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
47
+ toolsPaths: (string | string[])[];
48
+ projectRoot: string;
49
+ }): Promise<void>;
50
+ /**
51
+ * Deploy the built output into the sandbox and wait for the server to come
52
+ * up on its public URL. Writes `sandbox-deployment.json` into the output
53
+ * directory and updates the Edge Config alias when configured.
54
+ */
55
+ deploy(outputDirectory: string): Promise<void>;
56
+ }
57
+ //# sourceMappingURL=deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAM5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,qFAAqF;IACrF,QAAQ,CAAC,aAAa,QAAQ;IAC9B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,0GAA0G;IAC1G,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAS;gBAEnC,OAAO,EAAE,sBAAsB;IAY3C;;;;;OAKG;IACY,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;cAc/B,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAU1C,SAAS,CAAC,QAAQ,IAAI,MAAM;IAqBtB,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB/C,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;OAIG;IACG,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA8CrD"}
@@ -0,0 +1,19 @@
1
+ import type { DeployToSandboxOptions, SandboxDeployment } from './types.js';
2
+ /**
3
+ * Deploy a prebuilt Mastra server directory into any workspace sandbox that
4
+ * supports networking. Provider-agnostic: only uses the core WorkspaceSandbox
5
+ * contract (`executeCommand` + `networking`, with `writeFiles` / `processes`
6
+ * as fast paths).
7
+ */
8
+ export declare function deployToSandbox(options: DeployToSandboxOptions): Promise<SandboxDeployment>;
9
+ /**
10
+ * Build the POSIX launch script. Re-running the script restarts the server —
11
+ * the wake path uses this after a snapshot resume (which restores the
12
+ * filesystem but not processes).
13
+ */
14
+ export declare function buildLaunchScript(opts: {
15
+ remoteDir: string;
16
+ port: number;
17
+ env: Record<string, string>;
18
+ }): string;
19
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,sBAAsB,EAAuB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAc9F;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+HjG;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,MAAM,CAyBhH"}