@mastra/vercel 0.1.0-alpha.0 → 0.2.0-alpha.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.
- package/CHANGELOG.md +51 -0
- package/dist/index.cjs +384 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +383 -2
- package/dist/index.js.map +1 -1
- package/dist/microvm/index.d.ts +118 -0
- package/dist/microvm/index.d.ts.map +1 -0
- package/dist/microvm/process-manager.d.ts +25 -0
- package/dist/microvm/process-manager.d.ts.map +1 -0
- package/dist/microvm-provider.d.ts +29 -0
- package/dist/microvm-provider.d.ts.map +1 -0
- package/package.json +12 -10
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/executor/index.ts","../src/sandbox/index.ts","../src/provider.ts"],"names":["MastraSandbox","SandboxNotReadyError"],"mappings":";;;;;;;AAUO,SAAS,iBAAA,CAAkB,QAAgB,GAAA,EAAqC;AACrF,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,CAClC,IAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,KAAK,SAAA,CAAU,CAAC,CAAC,CAAA,EAAA,EAAK,IAAA,CAAK,SAAA,CAAU,CAAC,CAAC,CAAA,CAAE,CAAA,CAC9D,IAAA,CAAK,KAAK,CAAA;AAEb,EAAA,OAAO;AAAA;;AAAA,uBAAA,EAGgB,IAAA,CAAK,SAAA,CAAU,MAAM,CAAC,CAAA;AAAA;AAAA,EAE7C,UAAU;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA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a,uBAAA,EAAyB,SAAS,IAAA,EAAK;AAAA,MAC9E,GAAA,EAAK;AAAA,QACH,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa,uBAAA;AAAA,QACb,oBAAA,EAAsB,EAAE,IAAA,EAAM,QAAA;AAAS,OACzC;AAAA,MACA,gBAAgB,EAAE,IAAA,EAAM,UAAU,WAAA,EAAa,8BAAA,EAAgC,SAAS,IAAA;AAAM;AAChG,GACF;AAAA,EACA,aAAA,EAAe,CAAA,MAAA,KAAU,IAAI,aAAA,CAAc,MAAM;AACnD","file":"index.cjs","sourcesContent":["/**\n * Executor function source code deployed to Vercel as a serverless function.\n *\n * Returns a string because it's sent as inline file content via\n * the Vercel Deployments API — no separate build step needed.\n *\n * The secret and user env vars are embedded as constants in the source\n * because the Vercel Deployments API does not support setting env vars\n * directly — they must be configured via vercel.json or project settings.\n */\nexport function getExecutorSource(secret: string, env: Record<string, string>): string {\n const envEntries = Object.entries(env)\n .map(([k, v]) => ` ${JSON.stringify(k)}: ${JSON.stringify(v)}`)\n .join(',\\n');\n\n return `\nconst { execFileSync } = require('child_process');\n\nconst SANDBOX_SECRET = ${JSON.stringify(secret)};\nconst SANDBOX_ENV = {\n${envEntries}\n};\n\nmodule.exports = async (req, res) => {\n // Auth check\n const authHeader = req.headers['authorization'] || '';\n if (!SANDBOX_SECRET || authHeader !== 'Bearer ' + SANDBOX_SECRET) {\n return res.status(401).json({ error: 'Unauthorized' });\n }\n\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' });\n }\n\n const { command, args = [], env = {}, cwd, timeout = 55000 } = req.body || {};\n\n if (!command) {\n return res.status(400).json({ error: 'Missing required field: command' });\n }\n\n const execCwd = cwd || '/tmp';\n const execEnv = { ...process.env, ...SANDBOX_ENV, ...env };\n\n // When args is empty the caller sent a full shell command string\n // (e.g. \"echo hello\" or \"ls -la | grep foo\"). Run it through\n // /bin/sh so builtins and pipes work. When args is non-empty the\n // caller split the command properly — use execFileSync to avoid\n // shell injection.\n const useShell = !args || args.length === 0;\n const execCommand = useShell ? '/bin/sh' : command;\n const execArgs = useShell ? ['-c', command] : args;\n\n const startTime = Date.now();\n let timedOut = false;\n\n try {\n const stdout = execFileSync(execCommand, execArgs, {\n cwd: execCwd,\n env: execEnv,\n timeout,\n maxBuffer: 10 * 1024 * 1024,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n return res.status(200).json({\n success: true,\n exitCode: 0,\n stdout: stdout || '',\n stderr: '',\n executionTimeMs: Date.now() - startTime,\n timedOut: false,\n });\n } catch (error) {\n timedOut = error.killed || false;\n\n return res.status(200).json({\n success: false,\n exitCode: error.status != null ? error.status : 1,\n stdout: error.stdout || '',\n stderr: error.stderr || '',\n executionTimeMs: Date.now() - startTime,\n timedOut,\n });\n }\n};\n`;\n}\n","/**\n * Vercel Sandbox Provider\n *\n * Deploys code as Vercel serverless functions and executes commands\n * via HTTP invocation. Stateless — no persistent filesystem, no\n * interactive shell, no long-running processes.\n *\n * @see https://vercel.com/docs/rest-api\n */\n\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n SandboxInfo,\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n InstructionsOption,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { getExecutorSource } from '../executor';\n\nconst LOG_PREFIX = '[VercelSandbox]';\n\nconst VERCEL_API_BASE = 'https://api.vercel.com';\n\n/**\n * Shell-quote an argument for safe interpolation into a shell command string.\n * Mirrors the implementation in packages/core/src/workspace/sandbox/utils.ts\n * which is not publicly exported.\n */\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface VercelSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** Vercel API token. Falls back to VERCEL_TOKEN env var. */\n token?: string;\n /** Vercel team ID for team-scoped deployments. */\n teamId?: string;\n /** Existing Vercel project name. Auto-generated if omitted. */\n projectName?: string;\n /** Deployment regions. @default ['iad1'] */\n regions?: string[];\n /** Function max duration in seconds. @default 60 */\n maxDuration?: number;\n /** Function memory in MB. @default 1024 */\n memory?: number;\n /** Environment variables baked into the deployed function. */\n env?: Record<string, string>;\n /** Per-invocation command timeout in ms. @default 55000 */\n commandTimeout?: number;\n /**\n * Custom instructions that override the default instructions\n * returned by `getInstructions()`.\n */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class VercelSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'VercelSandbox';\n readonly provider = 'vercel';\n status: ProviderStatus = 'pending';\n\n private readonly _token: string;\n private readonly _teamId?: string;\n private readonly _projectName?: string;\n private readonly _regions: string[];\n private readonly _maxDuration: number;\n private readonly _memory: number;\n private readonly _env: Record<string, string>;\n private readonly _commandTimeout: number;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _secret: string;\n\n private _deploymentUrl: string | null = null;\n private _deploymentId: string | null = null;\n private _protectionBypass: string | null = null;\n private _createdAt: Date | null = null;\n\n constructor(options: VercelSandboxOptions = {}) {\n super({ name: 'VercelSandbox' });\n\n this.id = `vercel-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._token = options.token || process.env.VERCEL_TOKEN || '';\n this._teamId = options.teamId;\n this._projectName = options.projectName;\n this._regions = options.regions ?? ['iad1'];\n this._maxDuration = options.maxDuration ?? 60;\n this._memory = options.memory ?? 1024;\n this._env = options.env ?? {};\n this._commandTimeout = options.commandTimeout ?? 55_000;\n this._instructionsOverride = options.instructions;\n this._secret = crypto.randomUUID();\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async start(): Promise<void> {\n if (this._deploymentUrl) {\n return;\n }\n\n if (!this._token) {\n throw new Error(`${LOG_PREFIX} Missing Vercel API token. Set VERCEL_TOKEN env var or pass token option.`);\n }\n\n // Clean up any stale deployment from a previous stop() → start() cycle.\n // Without this, the old _deploymentId is overwritten and that deployment leaks.\n if (this._deploymentId) {\n this.logger.debug(`${LOG_PREFIX} Cleaning up stale deployment ${this._deploymentId} before restarting...`);\n try {\n const resp = await this._vercelFetch(`/v13/deployments/${this._deploymentId}`, { method: 'DELETE' });\n if (!resp.ok && resp.status !== 404) {\n this.logger.warn(`${LOG_PREFIX} Failed to delete stale deployment: ${resp.status}`);\n }\n } catch (error) {\n this.logger.warn(`${LOG_PREFIX} Error deleting stale deployment:`, error);\n }\n this._deploymentId = null;\n }\n\n this.logger.debug(`${LOG_PREFIX} Deploying executor function...`);\n\n const vercelJson = JSON.stringify({\n functions: {\n 'api/execute.js': {\n memory: this._memory,\n maxDuration: this._maxDuration,\n },\n },\n regions: this._regions,\n });\n\n // Create the deployment\n const deploymentBody: Record<string, unknown> = {\n name: this._projectName ?? `mastra-sandbox-${this.id}`,\n files: [\n {\n file: 'api/execute.js',\n data: getExecutorSource(this._secret, this._env),\n },\n {\n file: 'vercel.json',\n data: vercelJson,\n },\n ],\n projectSettings: {\n framework: null,\n },\n target: 'production',\n };\n\n const createResp = await this._vercelFetch('/v13/deployments', {\n method: 'POST',\n body: JSON.stringify(deploymentBody),\n });\n\n if (!createResp.ok) {\n const errorBody = await createResp.text();\n throw new Error(`${LOG_PREFIX} Failed to create deployment: ${createResp.status} ${errorBody}`);\n }\n\n const deployment = (await createResp.json()) as { id: string; url: string; readyState: string; projectId?: string };\n this._deploymentId = deployment.id;\n\n this.logger.debug(`${LOG_PREFIX} Deployment created: ${deployment.id}, polling for READY...`);\n\n // Poll until ready\n const maxWaitMs = 120_000;\n const pollIntervalMs = 3_000;\n const deadline = Date.now() + maxWaitMs;\n\n while (Date.now() < deadline) {\n const statusResp = await this._vercelFetch(`/v13/deployments/${deployment.id}`);\n if (!statusResp.ok) {\n throw new Error(`${LOG_PREFIX} Failed to check deployment status: ${statusResp.status}`);\n }\n\n const statusBody = (await statusResp.json()) as { readyState: string; url: string };\n\n if (statusBody.readyState === 'READY') {\n this._deploymentUrl = `https://${statusBody.url}`;\n this._createdAt = new Date();\n this.logger.debug(`${LOG_PREFIX} Deployment ready: ${this._deploymentUrl}`);\n\n // Acquire a deployment protection bypass token.\n // Pro/Enterprise teams have Deployment Protection enabled by default,\n // which intercepts HTTP requests with an SSO login page before they\n // reach the serverless function. The bypass token lets us skip that.\n if (deployment.projectId) {\n try {\n this._protectionBypass = await this._acquireProtectionBypass(deployment.projectId);\n } catch {\n // Non-fatal — if the project has no deployment protection, this is unnecessary.\n }\n }\n\n // Warm-up ping\n try {\n await fetch(`${this._deploymentUrl}/api/execute`, {\n method: 'POST',\n headers: this._executorHeaders(),\n body: JSON.stringify({ command: 'echo', args: ['warm'] }),\n });\n } catch {\n // Warm-up failure is non-fatal\n }\n\n return;\n }\n\n if (statusBody.readyState === 'ERROR' || statusBody.readyState === 'CANCELED') {\n throw new Error(`${LOG_PREFIX} Deployment failed with state: ${statusBody.readyState}`);\n }\n\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n }\n\n throw new Error(`${LOG_PREFIX} Deployment timed out after ${maxWaitMs}ms`);\n }\n\n async stop(): Promise<void> {\n // Only clear the URL (disconnects from the deployment) but keep\n // _deploymentId so a subsequent destroy() can still clean up the\n // cloud resource. Clearing both would make destroy() a no-op and\n // leak the deployment.\n this._deploymentUrl = null;\n }\n\n async destroy(): Promise<void> {\n if (this._deploymentId) {\n try {\n const resp = await this._vercelFetch(`/v13/deployments/${this._deploymentId}`, {\n method: 'DELETE',\n });\n if (!resp.ok) {\n // 404 means the deployment is already gone — that's fine.\n // Other status codes indicate infrastructure issues (auth, network)\n // and should be surfaced more visibly.\n if (resp.status === 404) {\n this.logger.debug(`${LOG_PREFIX} Deployment already deleted (404)`);\n } else {\n this.logger.warn(`${LOG_PREFIX} Failed to delete deployment: ${resp.status}`);\n }\n }\n } catch (error) {\n // Network-level failure — warn rather than debug so it's visible\n this.logger.warn(`${LOG_PREFIX} Error deleting deployment:`, error);\n }\n this._deploymentId = null;\n }\n this._deploymentUrl = null;\n this._protectionBypass = null;\n }\n\n // ---------------------------------------------------------------------------\n // Command Execution\n // ---------------------------------------------------------------------------\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n if (!this._deploymentUrl) {\n throw new SandboxNotReadyError(this.id);\n }\n\n const fullCommand = args?.length ? `${command} ${args.map(a => shellQuote(a)).join(' ')}` : command;\n this.logger.debug(`${LOG_PREFIX} Executing: ${fullCommand}`);\n\n const body = {\n command,\n args: args ?? [],\n env: options?.env ?? {},\n cwd: options?.cwd ?? '/tmp',\n timeout: options?.timeout ?? this._commandTimeout,\n };\n\n const maxRetries = 2;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const resp = await fetch(`${this._deploymentUrl}/api/execute`, {\n method: 'POST',\n headers: this._executorHeaders(),\n body: JSON.stringify(body),\n signal: options?.abortSignal,\n });\n\n // Retry on transient errors\n if ((resp.status === 429 || resp.status === 502 || resp.status === 503) && attempt < maxRetries) {\n this.logger.debug(`${LOG_PREFIX} Retryable status ${resp.status}, attempt ${attempt + 1}/${maxRetries}`);\n await new Promise(resolve => setTimeout(resolve, 1000 * (attempt + 1)));\n continue;\n }\n\n // Gateway timeout → timedOut\n if (resp.status === 504) {\n return {\n command: fullCommand,\n args,\n success: false,\n exitCode: 124,\n stdout: '',\n stderr: 'Function execution timed out (504 Gateway Timeout)',\n executionTimeMs: options?.timeout ?? this._commandTimeout,\n timedOut: true,\n };\n }\n\n if (!resp.ok) {\n const errorText = await resp.text();\n throw new Error(`${LOG_PREFIX} Execute failed: ${resp.status} ${errorText}`);\n }\n\n const result = (await resp.json()) as {\n success: boolean;\n exitCode: number;\n stdout: string;\n stderr: string;\n executionTimeMs: number;\n timedOut: boolean;\n };\n\n // Stream callbacks\n if (options?.onStdout && result.stdout) {\n options.onStdout(result.stdout);\n }\n if (options?.onStderr && result.stderr) {\n options.onStderr(result.stderr);\n }\n\n return {\n command: fullCommand,\n args,\n success: result.success,\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n executionTimeMs: result.executionTimeMs,\n timedOut: result.timedOut,\n };\n } catch (error) {\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw error;\n }\n lastError = error as Error;\n if (attempt < maxRetries) {\n this.logger.debug(`${LOG_PREFIX} Request error, attempt ${attempt + 1}/${maxRetries}:`, error);\n await new Promise(resolve => setTimeout(resolve, 1000 * (attempt + 1)));\n continue;\n }\n }\n }\n\n throw lastError ?? new Error(`${LOG_PREFIX} executeCommand failed after retries`);\n }\n\n // ---------------------------------------------------------------------------\n // Info & Instructions\n // ---------------------------------------------------------------------------\n\n // Matches the resolveInstructions pattern in packages/core/src/workspace/utils.ts\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n if (this._instructionsOverride === undefined) return this._getDefaultInstructions();\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n const defaultInstructions = this._getDefaultInstructions();\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'Vercel serverless sandbox.',\n 'Limitations:',\n '- Stateless: no persistent filesystem between invocations.',\n '- No interactive shell or streaming stdin.',\n '- No long-running or background processes.',\n `- Maximum execution time: ${this._maxDuration} seconds.`,\n '- Only /tmp is writable (ephemeral, cleared between invocations).',\n '- Shell commands (pipes, builtins) are supported via /bin/sh -c.',\n ].join('\\n');\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt ?? new Date(),\n metadata: {\n deploymentId: this._deploymentId,\n deploymentUrl: this._deploymentUrl,\n regions: this._regions,\n maxDuration: this._maxDuration,\n memory: this._memory,\n },\n };\n }\n\n // ---------------------------------------------------------------------------\n // Private Helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Fetch an existing protection bypass token for the project, or create one\n * if none exists. Returns the token string, or null if acquisition fails.\n */\n private async _acquireProtectionBypass(projectId: string): Promise<string | null> {\n // 1. Check if the project already has a bypass token.\n const projResp = await this._vercelFetch(`/v9/projects/${projectId}`);\n if (projResp.ok) {\n const project = (await projResp.json()) as {\n protectionBypass?: Record<string, unknown>;\n };\n const existing = project.protectionBypass ? Object.keys(project.protectionBypass)[0] : undefined;\n if (existing) {\n this.logger.debug(`${LOG_PREFIX} Using existing protection bypass token`);\n return existing;\n }\n }\n\n // 2. No token exists — create one via the dedicated endpoint.\n this.logger.debug(`${LOG_PREFIX} Creating protection bypass token...`);\n const createResp = await this._vercelFetch(`/v1/projects/${projectId}/protection-bypass`, {\n method: 'PATCH',\n body: JSON.stringify({}),\n });\n if (createResp.ok) {\n const result = (await createResp.json()) as {\n protectionBypass?: Record<string, unknown>;\n };\n const created = result.protectionBypass ? Object.keys(result.protectionBypass)[0] : undefined;\n if (created) {\n this.logger.debug(`${LOG_PREFIX} Protection bypass token created`);\n return created;\n }\n }\n\n this.logger.debug(`${LOG_PREFIX} Could not acquire protection bypass token (project may not require it)`);\n return null;\n }\n\n private _executorHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this._secret}`,\n };\n if (this._protectionBypass) {\n headers['x-vercel-protection-bypass'] = this._protectionBypass;\n }\n return headers;\n }\n\n private async _vercelFetch(path: string, options: RequestInit = {}): Promise<Response> {\n const url = new URL(path, VERCEL_API_BASE);\n if (this._teamId) {\n url.searchParams.set('teamId', this._teamId);\n }\n\n return fetch(url.toString(), {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this._token}`,\n ...((options.headers as Record<string, string>) ?? {}),\n },\n });\n }\n}\n","/**\n * Vercel sandbox provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { vercelSandboxProvider } from '@mastra/vercel';\n *\n * const editor = new MastraEditor({\n * sandboxes: [vercelSandboxProvider],\n * });\n * ```\n */\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { VercelSandbox } from './sandbox';\n\n/**\n * Serializable subset of VercelSandboxOptions for editor storage.\n */\ninterface VercelProviderConfig {\n token?: string;\n teamId?: string;\n projectName?: string;\n regions?: string[];\n maxDuration?: number;\n memory?: number;\n env?: Record<string, string>;\n commandTimeout?: number;\n}\n\nexport const vercelSandboxProvider: SandboxProvider<VercelProviderConfig> = {\n id: 'vercel',\n name: 'Vercel Sandbox',\n description: 'Serverless sandbox powered by Vercel Functions',\n configSchema: {\n type: 'object',\n properties: {\n token: { type: 'string', description: 'Vercel API token' },\n teamId: { type: 'string', description: 'Vercel team ID' },\n projectName: { type: 'string', description: 'Existing Vercel project name' },\n regions: {\n type: 'array',\n description: 'Deployment regions',\n items: { type: 'string' },\n default: ['iad1'],\n },\n maxDuration: { type: 'number', description: 'Function max duration in seconds', default: 60 },\n memory: { type: 'number', description: 'Function memory in MB', default: 1024 },\n env: {\n type: 'object',\n description: 'Environment variables',\n additionalProperties: { type: 'string' },\n },\n commandTimeout: { type: 'number', description: 'Per-invocation timeout in ms', default: 55000 },\n },\n },\n createSandbox: config => new VercelSandbox(config),\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/executor/index.ts","../src/sandbox/index.ts","../src/provider.ts","../src/microvm/process-manager.ts","../src/microvm/index.ts","../src/microvm-provider.ts"],"names":["MastraSandbox","SandboxNotReadyError","ProcessHandle","SandboxProcessManager","LOG_PREFIX","Sandbox"],"mappings":";;;;;;;;AAUO,SAAS,iBAAA,CAAkB,QAAgB,GAAA,EAAqC;AACrF,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,CAClC,IAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,KAAK,SAAA,CAAU,CAAC,CAAC,CAA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,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,GAAI,MAAA,CAAO,KAAA,GAAQ,EAAE,SAAA,EAAW,EAAE,KAAA,EAAO,MAAA,CAAO,KAAA,EAAM,EAAE,GAAI,EAAC;AAAA,IAC7D,OAAO,MAAA,CAAO,KAAA;AAAA,IACd,KAAK,MAAA,CAAO;AAAA,GACb;AACL","file":"index.cjs","sourcesContent":["/**\n * Executor function source code deployed to Vercel as a serverless function.\n *\n * Returns a string because it's sent as inline file content via\n * the Vercel Deployments API — no separate build step needed.\n *\n * The secret and user env vars are embedded as constants in the source\n * because the Vercel Deployments API does not support setting env vars\n * directly — they must be configured via vercel.json or project settings.\n */\nexport function getExecutorSource(secret: string, env: Record<string, string>): string {\n const envEntries = Object.entries(env)\n .map(([k, v]) => ` ${JSON.stringify(k)}: ${JSON.stringify(v)}`)\n .join(',\\n');\n\n return `\nconst { execFileSync } = require('child_process');\n\nconst SANDBOX_SECRET = ${JSON.stringify(secret)};\nconst SANDBOX_ENV = {\n${envEntries}\n};\n\nmodule.exports = async (req, res) => {\n // Auth check\n const authHeader = req.headers['authorization'] || '';\n if (!SANDBOX_SECRET || authHeader !== 'Bearer ' + SANDBOX_SECRET) {\n return res.status(401).json({ error: 'Unauthorized' });\n }\n\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' });\n }\n\n const { command, args = [], env = {}, cwd, timeout = 55000 } = req.body || {};\n\n if (!command) {\n return res.status(400).json({ error: 'Missing required field: command' });\n }\n\n const execCwd = cwd || '/tmp';\n const execEnv = { ...process.env, ...SANDBOX_ENV, ...env };\n\n // When args is empty the caller sent a full shell command string\n // (e.g. \"echo hello\" or \"ls -la | grep foo\"). Run it through\n // /bin/sh so builtins and pipes work. When args is non-empty the\n // caller split the command properly — use execFileSync to avoid\n // shell injection.\n const useShell = !args || args.length === 0;\n const execCommand = useShell ? '/bin/sh' : command;\n const execArgs = useShell ? ['-c', command] : args;\n\n const startTime = Date.now();\n let timedOut = false;\n\n try {\n const stdout = execFileSync(execCommand, execArgs, {\n cwd: execCwd,\n env: execEnv,\n timeout,\n maxBuffer: 10 * 1024 * 1024,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n return res.status(200).json({\n success: true,\n exitCode: 0,\n stdout: stdout || '',\n stderr: '',\n executionTimeMs: Date.now() - startTime,\n timedOut: false,\n });\n } catch (error) {\n timedOut = error.killed || false;\n\n return res.status(200).json({\n success: false,\n exitCode: error.status != null ? error.status : 1,\n stdout: error.stdout || '',\n stderr: error.stderr || '',\n executionTimeMs: Date.now() - startTime,\n timedOut,\n });\n }\n};\n`;\n}\n","/**\n * Vercel Sandbox Provider\n *\n * Deploys code as Vercel serverless functions and executes commands\n * via HTTP invocation. Stateless — no persistent filesystem, no\n * interactive shell, no long-running processes.\n *\n * @see https://vercel.com/docs/rest-api\n */\n\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n SandboxInfo,\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n InstructionsOption,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { getExecutorSource } from '../executor';\n\nconst LOG_PREFIX = '[VercelSandbox]';\n\nconst VERCEL_API_BASE = 'https://api.vercel.com';\n\n/**\n * Shell-quote an argument for safe interpolation into a shell command string.\n * Mirrors the implementation in packages/core/src/workspace/sandbox/utils.ts\n * which is not publicly exported.\n */\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface VercelSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** Vercel API token. Falls back to VERCEL_TOKEN env var. */\n token?: string;\n /** Vercel team ID for team-scoped deployments. */\n teamId?: string;\n /** Existing Vercel project name. Auto-generated if omitted. */\n projectName?: string;\n /** Deployment regions. @default ['iad1'] */\n regions?: string[];\n /** Function max duration in seconds. @default 60 */\n maxDuration?: number;\n /** Function memory in MB. @default 1024 */\n memory?: number;\n /** Environment variables baked into the deployed function. */\n env?: Record<string, string>;\n /** Per-invocation command timeout in ms. @default 55000 */\n commandTimeout?: number;\n /**\n * Custom instructions that override the default instructions\n * returned by `getInstructions()`.\n */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class VercelSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'VercelSandbox';\n readonly provider = 'vercel';\n status: ProviderStatus = 'pending';\n\n private readonly _token: string;\n private readonly _teamId?: string;\n private readonly _projectName?: string;\n private readonly _regions: string[];\n private readonly _maxDuration: number;\n private readonly _memory: number;\n private readonly _env: Record<string, string>;\n private readonly _commandTimeout: number;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _secret: string;\n\n private _deploymentUrl: string | null = null;\n private _deploymentId: string | null = null;\n private _protectionBypass: string | null = null;\n private _createdAt: Date | null = null;\n\n constructor(options: VercelSandboxOptions = {}) {\n super({ name: 'VercelSandbox' });\n\n this.id = `vercel-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._token = options.token || process.env.VERCEL_TOKEN || '';\n this._teamId = options.teamId;\n this._projectName = options.projectName;\n this._regions = options.regions ?? ['iad1'];\n this._maxDuration = options.maxDuration ?? 60;\n this._memory = options.memory ?? 1024;\n this._env = options.env ?? {};\n this._commandTimeout = options.commandTimeout ?? 55_000;\n this._instructionsOverride = options.instructions;\n this._secret = crypto.randomUUID();\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async start(): Promise<void> {\n if (this._deploymentUrl) {\n return;\n }\n\n if (!this._token) {\n throw new Error(`${LOG_PREFIX} Missing Vercel API token. Set VERCEL_TOKEN env var or pass token option.`);\n }\n\n // Clean up any stale deployment from a previous stop() → start() cycle.\n // Without this, the old _deploymentId is overwritten and that deployment leaks.\n if (this._deploymentId) {\n this.logger.debug(`${LOG_PREFIX} Cleaning up stale deployment ${this._deploymentId} before restarting...`);\n try {\n const resp = await this._vercelFetch(`/v13/deployments/${this._deploymentId}`, { method: 'DELETE' });\n if (!resp.ok && resp.status !== 404) {\n this.logger.warn(`${LOG_PREFIX} Failed to delete stale deployment: ${resp.status}`);\n }\n } catch (error) {\n this.logger.warn(`${LOG_PREFIX} Error deleting stale deployment:`, error);\n }\n this._deploymentId = null;\n }\n\n this.logger.debug(`${LOG_PREFIX} Deploying executor function...`);\n\n const vercelJson = JSON.stringify({\n functions: {\n 'api/execute.js': {\n memory: this._memory,\n maxDuration: this._maxDuration,\n },\n },\n regions: this._regions,\n });\n\n // Create the deployment\n const deploymentBody: Record<string, unknown> = {\n name: this._projectName ?? `mastra-sandbox-${this.id}`,\n files: [\n {\n file: 'api/execute.js',\n data: getExecutorSource(this._secret, this._env),\n },\n {\n file: 'vercel.json',\n data: vercelJson,\n },\n ],\n projectSettings: {\n framework: null,\n },\n target: 'production',\n };\n\n const createResp = await this._vercelFetch('/v13/deployments', {\n method: 'POST',\n body: JSON.stringify(deploymentBody),\n });\n\n if (!createResp.ok) {\n const errorBody = await createResp.text();\n throw new Error(`${LOG_PREFIX} Failed to create deployment: ${createResp.status} ${errorBody}`);\n }\n\n const deployment = (await createResp.json()) as { id: string; url: string; readyState: string; projectId?: string };\n this._deploymentId = deployment.id;\n\n this.logger.debug(`${LOG_PREFIX} Deployment created: ${deployment.id}, polling for READY...`);\n\n // Poll until ready\n const maxWaitMs = 120_000;\n const pollIntervalMs = 3_000;\n const deadline = Date.now() + maxWaitMs;\n\n while (Date.now() < deadline) {\n const statusResp = await this._vercelFetch(`/v13/deployments/${deployment.id}`);\n if (!statusResp.ok) {\n throw new Error(`${LOG_PREFIX} Failed to check deployment status: ${statusResp.status}`);\n }\n\n const statusBody = (await statusResp.json()) as { readyState: string; url: string };\n\n if (statusBody.readyState === 'READY') {\n this._deploymentUrl = `https://${statusBody.url}`;\n this._createdAt = new Date();\n this.logger.debug(`${LOG_PREFIX} Deployment ready: ${this._deploymentUrl}`);\n\n // Acquire a deployment protection bypass token.\n // Pro/Enterprise teams have Deployment Protection enabled by default,\n // which intercepts HTTP requests with an SSO login page before they\n // reach the serverless function. The bypass token lets us skip that.\n if (deployment.projectId) {\n try {\n this._protectionBypass = await this._acquireProtectionBypass(deployment.projectId);\n } catch {\n // Non-fatal — if the project has no deployment protection, this is unnecessary.\n }\n }\n\n // Warm-up ping\n try {\n await fetch(`${this._deploymentUrl}/api/execute`, {\n method: 'POST',\n headers: this._executorHeaders(),\n body: JSON.stringify({ command: 'echo', args: ['warm'] }),\n });\n } catch {\n // Warm-up failure is non-fatal\n }\n\n return;\n }\n\n if (statusBody.readyState === 'ERROR' || statusBody.readyState === 'CANCELED') {\n throw new Error(`${LOG_PREFIX} Deployment failed with state: ${statusBody.readyState}`);\n }\n\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n }\n\n throw new Error(`${LOG_PREFIX} Deployment timed out after ${maxWaitMs}ms`);\n }\n\n async stop(): Promise<void> {\n // Only clear the URL (disconnects from the deployment) but keep\n // _deploymentId so a subsequent destroy() can still clean up the\n // cloud resource. Clearing both would make destroy() a no-op and\n // leak the deployment.\n this._deploymentUrl = null;\n }\n\n async destroy(): Promise<void> {\n if (this._deploymentId) {\n try {\n const resp = await this._vercelFetch(`/v13/deployments/${this._deploymentId}`, {\n method: 'DELETE',\n });\n if (!resp.ok) {\n // 404 means the deployment is already gone — that's fine.\n // Other status codes indicate infrastructure issues (auth, network)\n // and should be surfaced more visibly.\n if (resp.status === 404) {\n this.logger.debug(`${LOG_PREFIX} Deployment already deleted (404)`);\n } else {\n this.logger.warn(`${LOG_PREFIX} Failed to delete deployment: ${resp.status}`);\n }\n }\n } catch (error) {\n // Network-level failure — warn rather than debug so it's visible\n this.logger.warn(`${LOG_PREFIX} Error deleting deployment:`, error);\n }\n this._deploymentId = null;\n }\n this._deploymentUrl = null;\n this._protectionBypass = null;\n }\n\n // ---------------------------------------------------------------------------\n // Command Execution\n // ---------------------------------------------------------------------------\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n if (!this._deploymentUrl) {\n throw new SandboxNotReadyError(this.id);\n }\n\n const fullCommand = args?.length ? `${command} ${args.map(a => shellQuote(a)).join(' ')}` : command;\n this.logger.debug(`${LOG_PREFIX} Executing: ${fullCommand}`);\n\n const body = {\n command,\n args: args ?? [],\n env: options?.env ?? {},\n cwd: options?.cwd ?? '/tmp',\n timeout: options?.timeout ?? this._commandTimeout,\n };\n\n const maxRetries = 2;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const resp = await fetch(`${this._deploymentUrl}/api/execute`, {\n method: 'POST',\n headers: this._executorHeaders(),\n body: JSON.stringify(body),\n signal: options?.abortSignal,\n });\n\n // Retry on transient errors\n if ((resp.status === 429 || resp.status === 502 || resp.status === 503) && attempt < maxRetries) {\n this.logger.debug(`${LOG_PREFIX} Retryable status ${resp.status}, attempt ${attempt + 1}/${maxRetries}`);\n await new Promise(resolve => setTimeout(resolve, 1000 * (attempt + 1)));\n continue;\n }\n\n // Gateway timeout → timedOut\n if (resp.status === 504) {\n return {\n command: fullCommand,\n args,\n success: false,\n exitCode: 124,\n stdout: '',\n stderr: 'Function execution timed out (504 Gateway Timeout)',\n executionTimeMs: options?.timeout ?? this._commandTimeout,\n timedOut: true,\n };\n }\n\n if (!resp.ok) {\n const errorText = await resp.text();\n throw new Error(`${LOG_PREFIX} Execute failed: ${resp.status} ${errorText}`);\n }\n\n const result = (await resp.json()) as {\n success: boolean;\n exitCode: number;\n stdout: string;\n stderr: string;\n executionTimeMs: number;\n timedOut: boolean;\n };\n\n // Stream callbacks\n if (options?.onStdout && result.stdout) {\n options.onStdout(result.stdout);\n }\n if (options?.onStderr && result.stderr) {\n options.onStderr(result.stderr);\n }\n\n return {\n command: fullCommand,\n args,\n success: result.success,\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n executionTimeMs: result.executionTimeMs,\n timedOut: result.timedOut,\n };\n } catch (error) {\n if (error instanceof DOMException && error.name === 'AbortError') {\n throw error;\n }\n lastError = error as Error;\n if (attempt < maxRetries) {\n this.logger.debug(`${LOG_PREFIX} Request error, attempt ${attempt + 1}/${maxRetries}:`, error);\n await new Promise(resolve => setTimeout(resolve, 1000 * (attempt + 1)));\n continue;\n }\n }\n }\n\n throw lastError ?? new Error(`${LOG_PREFIX} executeCommand failed after retries`);\n }\n\n // ---------------------------------------------------------------------------\n // Info & Instructions\n // ---------------------------------------------------------------------------\n\n // Matches the resolveInstructions pattern in packages/core/src/workspace/utils.ts\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n if (this._instructionsOverride === undefined) return this._getDefaultInstructions();\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n const defaultInstructions = this._getDefaultInstructions();\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'Vercel serverless sandbox.',\n 'Limitations:',\n '- Stateless: no persistent filesystem between invocations.',\n '- No interactive shell or streaming stdin.',\n '- No long-running or background processes.',\n `- Maximum execution time: ${this._maxDuration} seconds.`,\n '- Only /tmp is writable (ephemeral, cleared between invocations).',\n '- Shell commands (pipes, builtins) are supported via /bin/sh -c.',\n ].join('\\n');\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt ?? new Date(),\n metadata: {\n deploymentId: this._deploymentId,\n deploymentUrl: this._deploymentUrl,\n regions: this._regions,\n maxDuration: this._maxDuration,\n memory: this._memory,\n },\n };\n }\n\n // ---------------------------------------------------------------------------\n // Private Helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Fetch an existing protection bypass token for the project, or create one\n * if none exists. Returns the token string, or null if acquisition fails.\n */\n private async _acquireProtectionBypass(projectId: string): Promise<string | null> {\n // 1. Check if the project already has a bypass token.\n const projResp = await this._vercelFetch(`/v9/projects/${projectId}`);\n if (projResp.ok) {\n const project = (await projResp.json()) as {\n protectionBypass?: Record<string, unknown>;\n };\n const existing = project.protectionBypass ? Object.keys(project.protectionBypass)[0] : undefined;\n if (existing) {\n this.logger.debug(`${LOG_PREFIX} Using existing protection bypass token`);\n return existing;\n }\n }\n\n // 2. No token exists — create one via the dedicated endpoint.\n this.logger.debug(`${LOG_PREFIX} Creating protection bypass token...`);\n const createResp = await this._vercelFetch(`/v1/projects/${projectId}/protection-bypass`, {\n method: 'PATCH',\n body: JSON.stringify({}),\n });\n if (createResp.ok) {\n const result = (await createResp.json()) as {\n protectionBypass?: Record<string, unknown>;\n };\n const created = result.protectionBypass ? Object.keys(result.protectionBypass)[0] : undefined;\n if (created) {\n this.logger.debug(`${LOG_PREFIX} Protection bypass token created`);\n return created;\n }\n }\n\n this.logger.debug(`${LOG_PREFIX} Could not acquire protection bypass token (project may not require it)`);\n return null;\n }\n\n private _executorHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this._secret}`,\n };\n if (this._protectionBypass) {\n headers['x-vercel-protection-bypass'] = this._protectionBypass;\n }\n return headers;\n }\n\n private async _vercelFetch(path: string, options: RequestInit = {}): Promise<Response> {\n const url = new URL(path, VERCEL_API_BASE);\n if (this._teamId) {\n url.searchParams.set('teamId', this._teamId);\n }\n\n return fetch(url.toString(), {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this._token}`,\n ...((options.headers as Record<string, string>) ?? {}),\n },\n });\n }\n}\n","/**\n * Vercel sandbox provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { vercelSandboxProvider } from '@mastra/vercel';\n *\n * const editor = new MastraEditor({\n * sandboxes: [vercelSandboxProvider],\n * });\n * ```\n */\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { VercelSandbox } from './sandbox';\n\n/**\n * Serializable subset of VercelSandboxOptions for editor storage.\n */\ninterface VercelProviderConfig {\n token?: string;\n teamId?: string;\n projectName?: string;\n regions?: string[];\n maxDuration?: number;\n memory?: number;\n env?: Record<string, string>;\n commandTimeout?: number;\n}\n\nexport const vercelSandboxProvider: SandboxProvider<VercelProviderConfig> = {\n id: 'vercel',\n name: 'Vercel Sandbox',\n description: 'Serverless sandbox powered by Vercel Functions',\n configSchema: {\n type: 'object',\n properties: {\n token: { type: 'string', description: 'Vercel API token' },\n teamId: { type: 'string', description: 'Vercel team ID' },\n projectName: { type: 'string', description: 'Existing Vercel project name' },\n regions: {\n type: 'array',\n description: 'Deployment regions',\n items: { type: 'string' },\n default: ['iad1'],\n },\n maxDuration: { type: 'number', description: 'Function max duration in seconds', default: 60 },\n memory: { type: 'number', description: 'Function memory in MB', default: 1024 },\n env: {\n type: 'object',\n description: 'Environment variables',\n additionalProperties: { type: 'string' },\n },\n commandTimeout: { type: 'number', description: 'Per-invocation timeout in ms', default: 55000 },\n },\n },\n createSandbox: config => new VercelSandbox(config),\n};\n","/**\n * Vercel Sandbox (MicroVM) Process Manager\n *\n * Implements SandboxProcessManager for the `@vercel/sandbox` SDK. Each spawn()\n * starts a detached command via `sandbox.runCommand({ detached: true })` and\n * streams its output through the command's async `logs()` iterator.\n *\n * The Vercel Sandbox SDK does not expose a stdin channel for running commands,\n * so `sendStdin()` throws a clear \"not supported\" error.\n */\n\nimport { ProcessHandle, SandboxProcessManager } from '@mastra/core/workspace';\nimport type { CommandResult, ProcessInfo, SpawnProcessOptions } from '@mastra/core/workspace';\nimport type { Command } from '@vercel/sandbox';\nimport type { VercelMicroVMSandbox } from './index';\n\n// =============================================================================\n// Process Handle\n// =============================================================================\n\n/**\n * Wraps a detached Vercel Sandbox {@link Command} to conform to Mastra's\n * ProcessHandle. Not exported — internal to this module.\n */\nclass VercelMicroVMProcessHandle extends ProcessHandle {\n readonly pid: string;\n\n private readonly _command: Command;\n private readonly _startTime: number;\n private readonly _timeout?: number;\n\n private _exitCode: number | undefined;\n private _waitPromise: Promise<CommandResult> | null = null;\n private _streamingPromise: Promise<void> | null = null;\n private _killed = false;\n\n constructor(command: Command, startTime: number, options?: SpawnProcessOptions) {\n super(options);\n this.pid = command.cmdId;\n this._command = command;\n this._startTime = startTime;\n this._timeout = options?.timeout;\n }\n\n get exitCode(): number | undefined {\n return this._exitCode;\n }\n\n /** @internal Set by the process manager after streaming starts. */\n set streamingPromise(p: Promise<void>) {\n this._streamingPromise = p;\n }\n\n async wait(): Promise<CommandResult> {\n if (!this._waitPromise) {\n this._waitPromise = this._doWait();\n }\n return this._waitPromise;\n }\n\n private async _doWait(): Promise<CommandResult> {\n const finishedPromise = this._command\n .wait()\n .then(finished => {\n if (this._exitCode === undefined) this._exitCode = finished.exitCode;\n })\n .catch(() => {\n if (this._exitCode === undefined) this._exitCode = 1;\n });\n\n if (this._timeout) {\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<'timeout'>(resolve => {\n timeoutId = setTimeout(() => resolve('timeout'), this._timeout);\n });\n\n const outcome = await Promise.race([finishedPromise.then(() => 'done' as const), timeoutPromise]);\n clearTimeout(timeoutId);\n\n if (outcome === 'timeout') {\n await this.kill();\n this._exitCode = 124;\n await this._streamingPromise?.catch(() => {});\n return {\n success: false,\n exitCode: 124,\n stdout: this.stdout,\n stderr: this.stderr || `Command timed out after ${this._timeout}ms`,\n executionTimeMs: Date.now() - this._startTime,\n killed: true,\n timedOut: true,\n };\n }\n } else {\n await finishedPromise;\n }\n\n // Drain any remaining streamed output before reporting the result.\n await this._streamingPromise?.catch(() => {});\n\n if (this._killed) {\n return {\n success: false,\n exitCode: this._exitCode ?? 137,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: Date.now() - this._startTime,\n killed: true,\n timedOut: false,\n };\n }\n\n return {\n success: this._exitCode === 0,\n exitCode: this._exitCode ?? 1,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: Date.now() - this._startTime,\n };\n }\n\n async kill(): Promise<boolean> {\n if (this._exitCode !== undefined && !this._killed) return false;\n this._killed = true;\n if (this._exitCode === undefined) this._exitCode = 137; // SIGKILL\n try {\n await this._command.kill();\n } catch {\n // Command may already be gone.\n }\n return true;\n }\n\n async sendStdin(_data: string): Promise<void> {\n throw new Error('VercelMicroVMSandbox does not support sending stdin to running processes.');\n }\n}\n\n// =============================================================================\n// Process Manager\n// =============================================================================\n\nexport interface VercelMicroVMProcessManagerOptions {\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Vercel Sandbox implementation of SandboxProcessManager. Uses one detached\n * `runCommand` per spawned process.\n */\nexport class VercelMicroVMProcessManager extends SandboxProcessManager<VercelMicroVMSandbox> {\n async spawn(command: string, options: SpawnProcessOptions = {}): Promise<ProcessHandle> {\n const mergedEnv = { ...this.env, ...options.env };\n const env = Object.fromEntries(\n Object.entries(mergedEnv).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n\n // The workspace passes a full command string; run it through a shell so\n // pipes, redirects, and builtins behave as expected.\n const cmd = await this.sandbox.sandbox.runCommand({\n cmd: 'sh',\n args: ['-c', command],\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(Object.keys(env).length ? { env } : {}),\n detached: true,\n });\n\n const handle = new VercelMicroVMProcessHandle(cmd, Date.now(), options);\n\n const streamingPromise = (async () => {\n for await (const log of cmd.logs()) {\n if (log.stream === 'stdout') handle.emitStdout(log.data);\n else handle.emitStderr(log.data);\n }\n })().catch(() => {\n // Stream ends when the command exits or is killed — swallow the error.\n });\n\n handle.streamingPromise = streamingPromise;\n\n this._tracked.set(handle.pid, handle);\n return handle;\n }\n\n async list(): Promise<ProcessInfo[]> {\n const result: ProcessInfo[] = [];\n for (const [pid, handle] of this._tracked) {\n result.push({\n pid,\n command: handle.command,\n running: handle.exitCode === undefined,\n exitCode: handle.exitCode,\n });\n }\n return result;\n }\n}\n","/**\n * Vercel Sandbox (MicroVM) Provider\n *\n * Wraps the official `@vercel/sandbox` SDK, which provisions ephemeral\n * Firecracker MicroVMs (Amazon Linux 2023) with a persistent in-session\n * filesystem, command execution, background processes, and exposed ports.\n *\n * This is distinct from the `VercelSandbox` provider in this package, which\n * runs commands as Vercel serverless Functions and is stateless.\n *\n * @see https://vercel.com/docs/vercel-sandbox\n */\n\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n CommandResult,\n ExecuteCommandOptions,\n InstructionsOption,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { Sandbox } from '@vercel/sandbox';\nimport { VercelMicroVMProcessManager } from './process-manager';\n\nconst LOG_PREFIX = '[VercelMicroVMSandbox]';\n\n/** Vercel Sandbox runtimes (default `node24`). */\nexport type VercelMicroVMRuntime = 'node24' | 'node22' | 'node26' | 'python3.13';\n\n// =============================================================================\n// Options\n// =============================================================================\n\n/**\n * Vercel Sandbox (MicroVM) provider configuration.\n *\n * Authentication: the SDK uses the `VERCEL_OIDC_TOKEN` environment variable\n * automatically when available. To authenticate from an environment without\n * OIDC, supply `token`, `teamId`, and `projectId` together (falling back to\n * the `VERCEL_TOKEN`, `VERCEL_TEAM_ID`, and `VERCEL_PROJECT_ID` env vars).\n */\nexport interface VercelMicroVMSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** Unique identifier for this sandbox instance. */\n id?: string;\n /** Optional sandbox name passed to the Vercel API. Auto-generated if omitted. */\n sandboxName?: string;\n /** Vercel API token. Falls back to the `VERCEL_TOKEN` env var. */\n token?: string;\n /** Vercel team ID. Falls back to the `VERCEL_TEAM_ID` env var. */\n teamId?: string;\n /** Vercel project ID. Falls back to the `VERCEL_PROJECT_ID` env var. */\n projectId?: string;\n /** Sandbox runtime. @default 'node24' */\n runtime?: VercelMicroVMRuntime;\n /**\n * Timeout in milliseconds before the sandbox auto-terminates.\n * @default 300_000 // 5 minutes\n */\n timeout?: number;\n /** Resources to allocate. `vcpus` controls CPU count (2048 MB memory per vCPU). */\n resources?: { vcpus?: number };\n /** Ports to expose from the sandbox (up to 4). Access via `getInfo().metadata.domains`. */\n ports?: number[];\n /** Default environment variables inherited by all commands. */\n env?: Record<string, string>;\n /** Custom metadata surfaced via `getInfo()`. */\n metadata?: Record<string, unknown>;\n /**\n * Custom instructions that override the default instructions\n * returned by `getInstructions()`.\n *\n * - `string` — Fully replaces the default instructions. Pass an empty\n * string to suppress instructions entirely.\n * - `(opts) => string` — Receives the default instructions and optional\n * request context so you can extend or customise per-request.\n */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Vercel Sandbox (MicroVM) provider for Mastra workspaces.\n *\n * @example Basic usage\n * ```typescript\n * import { Workspace } from '@mastra/core/workspace';\n * import { VercelMicroVMSandbox } from '@mastra/vercel';\n *\n * const workspace = new Workspace({\n * sandbox: new VercelMicroVMSandbox({ runtime: 'node24', timeout: 600_000 }),\n * });\n *\n * const result = await workspace.sandbox.executeCommand('node', ['--version']);\n * ```\n */\nexport class VercelMicroVMSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'VercelMicroVMSandbox';\n readonly provider = 'vercel-microvm';\n status: ProviderStatus = 'pending';\n\n declare readonly processes: VercelMicroVMProcessManager;\n\n private _sandbox: Sandbox | null = null;\n private _createdAt: Date | null = null;\n\n private readonly _sandboxName?: string;\n private readonly _token?: string;\n private readonly _teamId?: string;\n private readonly _projectId?: string;\n private readonly _runtime: VercelMicroVMRuntime;\n private readonly _timeout: number;\n private readonly _vcpus?: number;\n private readonly _ports?: number[];\n private readonly _env: Record<string, string>;\n private readonly _metadata: Record<string, unknown>;\n private readonly _instructionsOverride?: InstructionsOption;\n\n constructor(options: VercelMicroVMSandboxOptions = {}) {\n super({\n ...options,\n name: 'VercelMicroVMSandbox',\n processes: new VercelMicroVMProcessManager({ env: options.env ?? {} }),\n });\n\n this.id = options.id ?? `vercel-microvm-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._sandboxName = options.sandboxName;\n this._token = options.token ?? process.env.VERCEL_TOKEN;\n this._teamId = options.teamId ?? process.env.VERCEL_TEAM_ID;\n this._projectId = options.projectId ?? process.env.VERCEL_PROJECT_ID;\n this._runtime = options.runtime ?? 'node24';\n this._timeout = options.timeout ?? 300_000;\n this._vcpus = options.resources?.vcpus;\n this._ports = options.ports;\n this._env = options.env ?? {};\n this._metadata = options.metadata ?? {};\n this._instructionsOverride = options.instructions;\n }\n\n /**\n * The underlying `@vercel/sandbox` instance.\n * Throws if the sandbox has not been started yet.\n */\n get sandbox(): Sandbox {\n if (!this._sandbox) {\n throw new SandboxNotReadyError(this.id);\n }\n return this._sandbox;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n async start(): Promise<void> {\n if (this._sandbox) {\n return;\n }\n\n // Credentials are all-or-nothing: when any explicit credential is provided,\n // the SDK requires the full triple. Otherwise it falls back to the OIDC token.\n const hasExplicitCreds = Boolean(this._token || this._teamId || this._projectId);\n if (hasExplicitCreds && !(this._token && this._teamId && this._projectId)) {\n throw new Error(\n `${LOG_PREFIX} Incomplete credentials. Provide token, teamId, and projectId together ` +\n `(or the VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID env vars), ` +\n `or omit all three to use the VERCEL_OIDC_TOKEN.`,\n );\n }\n\n this.logger.debug(`${LOG_PREFIX} Creating sandbox...`, { runtime: this._runtime, timeout: this._timeout });\n\n this._sandbox = await Sandbox.create({\n ...(this._sandboxName ? { name: this._sandboxName } : {}),\n runtime: this._runtime,\n timeout: this._timeout,\n ...(this._vcpus ? { resources: { vcpus: this._vcpus } } : {}),\n ...(this._ports?.length ? { ports: this._ports } : {}),\n ...(Object.keys(this._env).length ? { env: this._env } : {}),\n ...(hasExplicitCreds ? { token: this._token!, teamId: this._teamId!, projectId: this._projectId! } : {}),\n });\n\n this._createdAt = new Date();\n this.logger.debug(`${LOG_PREFIX} Sandbox ready: ${this._sandbox.name}`);\n }\n\n async stop(): Promise<void> {\n await this._teardown();\n }\n\n async destroy(): Promise<void> {\n await this._teardown();\n }\n\n private async _teardown(): Promise<void> {\n if (!this._sandbox) {\n return;\n }\n try {\n await this._sandbox.stop();\n } catch (error) {\n this.logger.warn(`${LOG_PREFIX} Error stopping sandbox:`, error);\n }\n this._sandbox = null;\n }\n\n // ---------------------------------------------------------------------------\n // Command Execution\n // ---------------------------------------------------------------------------\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n const startTime = Date.now();\n const fullCommand = args?.length ? `${command} ${args.join(' ')}` : command;\n this.logger.debug(`${LOG_PREFIX} Executing: ${fullCommand}`, { cwd: options?.cwd });\n\n const mergedEnv = { ...this._env, ...options?.env };\n const env = Object.fromEntries(\n Object.entries(mergedEnv).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n\n // Race the command against the optional timeout so we can return a partial\n // result with a 124 exit code (matching other providers) instead of hanging.\n // On timeout we abort the in-flight command so it stops running in the VM.\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const abortController = new AbortController();\n const forwardAbort = () => abortController.abort();\n if (options?.abortSignal) {\n if (options.abortSignal.aborted) abortController.abort();\n else options.abortSignal.addEventListener('abort', forwardAbort, { once: true });\n }\n const signal = abortController.signal;\n const timeoutPromise = options?.timeout\n ? new Promise<'timeout'>(resolve => {\n timeoutId = setTimeout(() => resolve('timeout'), options.timeout);\n })\n : null;\n\n try {\n const commandPromise = this.sandbox.runCommand({\n cmd: command,\n args: args ?? [],\n ...(options?.cwd ? { cwd: options.cwd } : {}),\n ...(Object.keys(env).length ? { env } : {}),\n signal,\n });\n\n const finished = timeoutPromise ? await Promise.race([commandPromise, timeoutPromise]) : await commandPromise;\n\n if (finished === 'timeout') {\n abortController.abort();\n return {\n command: fullCommand,\n args,\n success: false,\n exitCode: 124,\n stdout: '',\n stderr: `Command timed out after ${options!.timeout}ms`,\n executionTimeMs: Date.now() - startTime,\n timedOut: true,\n };\n }\n\n const [stdout, stderr] = await Promise.all([finished.stdout(), finished.stderr()]);\n\n if (options?.onStdout && stdout) options.onStdout(stdout);\n if (options?.onStderr && stderr) options.onStderr(stderr);\n\n return {\n command: fullCommand,\n args,\n success: finished.exitCode === 0,\n exitCode: finished.exitCode,\n stdout,\n stderr,\n executionTimeMs: Date.now() - startTime,\n };\n } finally {\n if (timeoutId) clearTimeout(timeoutId);\n options?.abortSignal?.removeEventListener('abort', forwardAbort);\n }\n }\n\n // ---------------------------------------------------------------------------\n // Info & Instructions\n // ---------------------------------------------------------------------------\n\n getInfo(): SandboxInfo {\n const domains: Record<number, string> = {};\n if (this._sandbox && this._ports?.length) {\n for (const port of this._ports) {\n try {\n domains[port] = this._sandbox.domain(port);\n } catch {\n // Port may not have an associated route yet — skip.\n }\n }\n }\n\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt ?? new Date(),\n metadata: {\n ...this._metadata,\n sandboxName: this._sandbox?.name,\n runtime: this._runtime,\n timeout: this._timeout,\n ...(this._vcpus ? { vcpus: this._vcpus } : {}),\n ...(this._ports?.length ? { ports: this._ports, domains } : {}),\n },\n };\n }\n\n // Matches the resolveInstructions pattern in @mastra/core/workspace.\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n if (this._instructionsOverride === undefined) return this._getDefaultInstructions();\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n const defaultInstructions = this._getDefaultInstructions();\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'Vercel Sandbox: an ephemeral Firecracker MicroVM running Amazon Linux 2023.',\n `- Runtime: ${this._runtime}. Working directory defaults to /vercel/sandbox.`,\n '- Persistent filesystem within the session; state is lost when the sandbox stops.',\n '- Runs as the vercel-sandbox user with sudo access (install packages via dnf).',\n `- The sandbox auto-terminates after ${Math.round(this._timeout / 1000)} seconds.`,\n ...(this._ports?.length\n ? [`- Exposed ports: ${this._ports.join(', ')} (reachable via public HTTPS domains).`]\n : []),\n '- Background/long-running processes are supported via the process tools.',\n '- Filesystem mounting (FUSE) is not supported.',\n ].join('\\n');\n }\n}\n","/**\n * Vercel Sandbox (MicroVM) provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { vercelMicroVMSandboxProvider } from '@mastra/vercel';\n *\n * const editor = new MastraEditor({\n * sandboxes: [vercelMicroVMSandboxProvider],\n * });\n * ```\n */\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { VercelMicroVMSandbox } from './microvm';\n\n/**\n * Serializable subset of VercelMicroVMSandboxOptions for editor storage.\n */\ninterface VercelMicroVMProviderConfig {\n token?: string;\n teamId?: string;\n projectId?: string;\n runtime?: 'node24' | 'node22' | 'node26' | 'python3.13';\n timeout?: number;\n vcpus?: number;\n ports?: number[];\n env?: Record<string, string>;\n}\n\nexport const vercelMicroVMSandboxProvider: SandboxProvider<VercelMicroVMProviderConfig> = {\n id: 'vercel-microvm',\n name: 'Vercel Sandbox (MicroVM)',\n description: 'Ephemeral Firecracker MicroVM sandbox powered by Vercel Sandbox',\n configSchema: {\n type: 'object',\n properties: {\n token: { type: 'string', description: 'Vercel API token (falls back to VERCEL_TOKEN; omit to use OIDC)' },\n teamId: { type: 'string', description: 'Vercel team ID (falls back to VERCEL_TEAM_ID)' },\n projectId: { type: 'string', description: 'Vercel project ID (falls back to VERCEL_PROJECT_ID)' },\n runtime: {\n type: 'string',\n description: 'Sandbox runtime',\n enum: ['node24', 'node22', 'node26', 'python3.13'],\n default: 'node24',\n },\n timeout: { type: 'number', description: 'Auto-terminate timeout in milliseconds', default: 300000 },\n vcpus: { type: 'number', description: 'Number of vCPUs (2048 MB memory per vCPU)' },\n ports: {\n type: 'array',\n description: 'Ports to expose (up to 4)',\n items: { type: 'number' },\n },\n env: {\n type: 'object',\n description: 'Environment variables',\n additionalProperties: { type: 'string' },\n },\n },\n },\n createSandbox: config =>\n new VercelMicroVMSandbox({\n token: config.token,\n teamId: config.teamId,\n projectId: config.projectId,\n runtime: config.runtime,\n timeout: config.timeout,\n ...(config.vcpus ? { resources: { vcpus: config.vcpus } } : {}),\n ports: config.ports,\n env: config.env,\n }),\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { VercelSandbox, type VercelSandboxOptions } from './sandbox/index.js';
|
|
2
2
|
export { vercelSandboxProvider } from './provider.js';
|
|
3
|
+
export { VercelMicroVMSandbox, type VercelMicroVMSandboxOptions, type VercelMicroVMRuntime } from './microvm/index.js';
|
|
4
|
+
export { VercelMicroVMProcessManager } from './microvm/process-manager.js';
|
|
5
|
+
export { vercelMicroVMSandboxProvider } from './microvm-provider.js';
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC"}
|