@mastra/e2b 0.0.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/LICENSE.md +15 -0
- package/README.md +68 -0
- package/dist/index.cjs +858 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +855 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/index.d.ts +253 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/mounts/gcs.d.ts +20 -0
- package/dist/sandbox/mounts/gcs.d.ts.map +1 -0
- package/dist/sandbox/mounts/index.d.ts +4 -0
- package/dist/sandbox/mounts/index.d.ts.map +1 -0
- package/dist/sandbox/mounts/s3.d.ts +30 -0
- package/dist/sandbox/mounts/s3.d.ts.map +1 -0
- package/dist/sandbox/mounts/types.d.ts +36 -0
- package/dist/sandbox/mounts/types.d.ts.map +1 -0
- package/dist/utils/shell-quote.d.ts +8 -0
- package/dist/utils/shell-quote.d.ts.map +1 -0
- package/dist/utils/template.d.ts +84 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/shell-quote.ts","../src/utils/template.ts","../src/sandbox/mounts/types.ts","../src/sandbox/mounts/s3.ts","../src/sandbox/mounts/gcs.ts","../src/sandbox/index.ts"],"names":["Template","template","buildResult"],"mappings":";;;;;;;AAMO,SAAS,WAAW,GAAA,EAAqB;AAE9C,EAAA,IAAI,wBAAA,CAAyB,IAAA,CAAK,GAAG,CAAA,EAAG,OAAO,GAAA;AAE/C,EAAA,OAAO,GAAA,GAAM,GAAA,CAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA,GAAI,GAAA;AAC5C;ACsDO,IAAM,0BAAA,GAA6B,IAAA;AAgCnC,SAAS,8BAAA,GAA0D;AACxE,EAAA,MAAM,WAAA,GAAc,CAAC,MAAA,E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AAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAA,CAAA;AAChG,MAAA,MAAM,QAAA,GAAW,QAAA,CAAS,MAAA,EAAQ,QAAA,IAAY,CAAA;AAE9C,MAAA,IAAA,CAAK,MAAA,CAAO,MAAM,CAAA,EAAG,UAAU,eAAe,QAAQ,CAAA,EAAA,EAAK,eAAe,CAAA,WAAA,CAAa,CAAA;AACvF,MAAA,IAAI,MAAA,EAAQ,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,UAAU,CAAA;AAAA,EAAa,MAAM,CAAA,CAAE,CAAA;AAChE,MAAA,IAAI,MAAA,EAAQ,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,GAAG,UAAU,CAAA;AAAA,EAAa,MAAM,CAAA,CAAE,CAAA;AAEhE,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,KAAA;AAAA,QACT,QAAA;AAAA,QACA,MAAA;AAAA,QACA,MAAA;AAAA,QACA,eAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF","file":"index.js","sourcesContent":["/**\n * Shell-quote a single argument for safe use in a command string.\n *\n * Arguments containing only safe characters are returned as-is.\n * All others are wrapped in single quotes with embedded single quotes escaped.\n */\nexport function shellQuote(arg: string): string {\n // Safe characters that don't need quoting\n if (/^[a-zA-Z0-9._\\-/@:=]+$/.test(arg)) return arg;\n // Wrap in single quotes, escaping any embedded single quotes\n return \"'\" + arg.replace(/'/g, \"'\\\\''\") + \"'\";\n}\n","/**\n * E2B Template Utilities\n *\n * Helper functions for creating and managing E2B sandbox templates.\n */\nimport { createHash } from 'node:crypto';\nimport { Template } from 'e2b';\nimport type { TemplateBuilder } from 'e2b';\n\n// =============================================================================\n// Template Types\n// =============================================================================\n\n/**\n * Template specification for E2B sandbox.\n *\n * Can be:\n * - `string` - Existing template ID (e.g., 'base', 'my-custom-template')\n * - `TemplateBuilder` - A built template object from Template()\n * - `(base: TemplateBuilder) => TemplateBuilder` - Callback to customize the base template\n *\n * @example Using template ID\n * ```typescript\n * new E2BSandbox({ template: 'my-custom-template' })\n * ```\n *\n * @example Using Template builder\n * ```typescript\n * import { Template } from 'e2b';\n *\n * new E2BSandbox({\n * template: Template()\n * .fromUbuntuImage('22.04')\n * .aptInstall(['s3fs', 'curl'])\n * .setEnvs({ NODE_ENV: 'production' })\n * })\n * ```\n *\n * @example Customizing default mountable template\n * ```typescript\n * new E2BSandbox({\n * template: base => base\n * .aptInstall(['nodejs', 'npm'])\n * .runCmd('npm install -g typescript')\n * })\n * ```\n */\nexport type TemplateSpec = string | TemplateBuilder | ((base: TemplateBuilder) => TemplateBuilder);\n\n/**\n * Result from createMountableTemplate containing both the template and its ID.\n */\nexport interface MountableTemplateResult {\n /** The template builder with mount dependencies */\n template: TemplateBuilder;\n /** Deterministic template ID for caching */\n id: string;\n /** List of apt packages installed in the template */\n aptPackages: string[];\n}\n\n/**\n * Version of the default mountable template.\n * Increment this when changing the default template dependencies.\n */\nexport const MOUNTABLE_TEMPLATE_VERSION = 'v1';\n\n/**\n * Create a base template with FUSE mounting dependencies pre-installed.\n *\n * This template includes s3fs and fuse packages required for mounting\n * cloud filesystems (S3, GCS, R2) into the sandbox.\n *\n * The returned `id` is deterministic, allowing E2BSandbox to check if\n * the template already exists before building it.\n *\n * @example Basic usage\n * ```typescript\n * const { template, id } = createMountableTemplate();\n * // First time: builds and caches the template\n * // Subsequent times: reuses existing template\n * const sandbox = new E2BSandbox({ template });\n * ```\n *\n * @example With customization\n * ```typescript\n * const { template } = createMountableTemplate();\n * const customTemplate = template\n * .aptInstall(['nodejs', 'npm'])\n * .runCmd('npm install -g typescript');\n *\n * // Note: customized templates get a unique ID, not the cached one\n * const sandbox = new E2BSandbox({ template: customTemplate });\n * ```\n *\n * @returns Object with template builder and deterministic ID\n */\nexport function createDefaultMountableTemplate(): MountableTemplateResult {\n const aptPackages = ['s3fs', 'fuse'];\n const config = { version: MOUNTABLE_TEMPLATE_VERSION, aptPackages };\n\n const hash = createHash('sha256')\n .update(JSON.stringify(config, Object.keys(config).sort()))\n .digest('hex')\n .slice(0, 16);\n\n const template = Template().fromTemplate('base').aptInstall(aptPackages);\n\n // Note: gcsfuse requires adding Google's apt repo which can be flaky\n // For now, we'll install it at mount time if needed\n\n return {\n template,\n id: `mastra-${hash}`,\n aptPackages,\n };\n}\n","/**\n * Shared types for E2B mount operations.\n */\n\nimport type { Sandbox } from 'e2b';\n\nexport const LOG_PREFIX = '[@mastra/e2b]';\n\nimport type { E2BGCSMountConfig } from './gcs';\nimport type { E2BS3MountConfig } from './s3';\n\n/**\n * Union of mount configs supported by E2B sandbox.\n */\nexport type E2BMountConfig = E2BS3MountConfig | E2BGCSMountConfig;\n\n/**\n * Context for mount operations.\n */\nexport interface MountContext {\n sandbox: Sandbox;\n logger: {\n debug: (message: string, ...args: unknown[]) => void;\n info: (message: string, ...args: unknown[]) => void;\n warn: (message: string, ...args: unknown[]) => void;\n error: (message: string, ...args: unknown[]) => void;\n };\n}\n\n/**\n * Result of a mount operation.\n */\nexport interface MountOperationResult {\n success: boolean;\n error?: string;\n}\n\n/**\n * Validate a bucket name before interpolating into shell commands.\n * Covers S3, GCS, and S3-compatible (R2, MinIO) naming rules.\n */\nconst SAFE_BUCKET_NAME = /^[a-z0-9][a-z0-9.\\-]{1,61}[a-z0-9]$/;\n\nexport function validateBucketName(bucket: string): void {\n if (!SAFE_BUCKET_NAME.test(bucket)) {\n throw new Error(\n `Invalid bucket name: \"${bucket}\". Bucket names must be 3-63 characters, lowercase alphanumeric, hyphens, or dots.`,\n );\n }\n}\n\n/**\n * Validate an endpoint URL before interpolating into shell commands.\n */\nexport function validateEndpoint(endpoint: string): void {\n try {\n new URL(endpoint);\n } catch {\n throw new Error(`Invalid endpoint URL: \"${endpoint}\"`);\n }\n}\n","import type { FilesystemMountConfig } from '@mastra/core/workspace';\n\nimport { LOG_PREFIX, validateBucketName, validateEndpoint } from './types';\nimport type { MountContext } from './types';\n\n/**\n * S3 mount config for E2B (mounted via s3fs-fuse).\n *\n * If credentials are not provided, the bucket will be mounted as read-only\n * using the `public_bucket=1` option (for public AWS S3 buckets only).\n *\n * Note: S3-compatible services (R2, MinIO, etc.) always require credentials.\n */\nexport interface E2BS3MountConfig extends FilesystemMountConfig {\n type: 's3';\n /** S3 bucket name */\n bucket: string;\n /** AWS region */\n region: string;\n /** S3 endpoint for S3-compatible storage (MinIO, etc.) */\n endpoint?: string;\n /** AWS access key ID (optional - omit for public buckets) */\n accessKeyId?: string;\n /** AWS secret access key (optional - omit for public buckets) */\n secretAccessKey?: string;\n /** Mount as read-only (even if credentials have write access) */\n readOnly?: boolean;\n}\n\n/**\n * Mount an S3 bucket using s3fs-fuse.\n */\nexport async function mountS3(mountPath: string, config: E2BS3MountConfig, ctx: MountContext): Promise<void> {\n const { sandbox, logger } = ctx;\n\n // Validate inputs before interpolating into shell commands\n validateBucketName(config.bucket);\n if (config.endpoint) {\n validateEndpoint(config.endpoint);\n }\n\n // Check if s3fs is installed\n const checkResult = await sandbox.commands.run('which s3fs || echo \"not found\"');\n if (checkResult.stdout.includes('not found')) {\n logger.warn(`${LOG_PREFIX} s3fs not found, attempting runtime installation...`);\n logger.info(\n `${LOG_PREFIX} Tip: For faster startup, use createMountableTemplate() to pre-install s3fs in your sandbox template`,\n );\n\n await sandbox.commands.run('sudo apt-get update 2>&1', { timeoutMs: 60000 });\n\n const installResult = await sandbox.commands.run(\n 'sudo apt-get install -y s3fs fuse 2>&1 || sudo apt-get install -y s3fs-fuse fuse 2>&1',\n { timeoutMs: 120000 },\n );\n\n if (installResult.exitCode !== 0) {\n throw new Error(\n `Failed to install s3fs. ` +\n `For S3 mounting, your template needs s3fs and fuse packages.\\n\\n` +\n `Option 1: Use createMountableTemplate() helper:\\n` +\n ` import { E2BSandbox, createMountableTemplate } from '@mastra/e2b';\\n` +\n ` const sandbox = new E2BSandbox({ template: createMountableTemplate() });\\n\\n` +\n `Option 2: Customize the base template:\\n` +\n ` new E2BSandbox({ template: base => base.aptInstall(['your-packages']) })\\n\\n` +\n `Error details: ${installResult.stderr || installResult.stdout}`,\n );\n }\n }\n\n // Get user's uid/gid for proper file ownership\n const idResult = await sandbox.commands.run('id -u && id -g');\n const [uid, gid] = idResult.stdout.trim().split('\\n');\n\n // Determine if we have credentials or using public bucket mode\n const hasCredentials = config.accessKeyId && config.secretAccessKey;\n const credentialsPath = '/tmp/.passwd-s3fs';\n\n // S3-compatible services (R2, MinIO, etc.) require credentials\n // public_bucket=1 only works for truly public AWS S3 buckets\n if (!hasCredentials && config.endpoint) {\n throw new Error(\n `S3-compatible storage requires credentials. ` +\n `Detected endpoint: ${config.endpoint}. ` +\n `The public_bucket option only works for AWS S3 public buckets, not R2, MinIO, etc.`,\n );\n }\n\n if (hasCredentials) {\n // Write credentials file (remove old one first to avoid permission issues)\n const credentialsContent = `${config.accessKeyId}:${config.secretAccessKey}`;\n await sandbox.commands.run(`sudo rm -f ${credentialsPath}`);\n await sandbox.files.write(credentialsPath, credentialsContent);\n await sandbox.commands.run(`chmod 600 ${credentialsPath}`);\n }\n\n // Build mount options\n const mountOptions: string[] = [];\n\n if (hasCredentials) {\n mountOptions.push(`passwd_file=${credentialsPath}`);\n } else {\n // Public bucket mode - read-only access without credentials\n mountOptions.push('public_bucket=1');\n logger.debug(`${LOG_PREFIX} No credentials provided, mounting as public bucket (read-only)`);\n }\n\n mountOptions.push('allow_other'); // Allow non-root users to access the mount\n\n // Set uid/gid so mounted files are owned by user, not root\n if (uid && gid) {\n mountOptions.push(`uid=${uid}`, `gid=${gid}`);\n }\n\n if (config.endpoint) {\n // For S3-compatible storage (MinIO, R2, etc.)\n const endpoint = config.endpoint.replace(/\\/$/, '');\n mountOptions.push(`url=${endpoint}`, 'use_path_request_style', 'sigv4', 'nomultipart');\n }\n\n if (config.readOnly) {\n mountOptions.push('ro');\n logger.debug(`${LOG_PREFIX} Mounting as read-only`);\n }\n\n // Mount with sudo (required for /dev/fuse access)\n const mountCmd = `sudo s3fs ${config.bucket} ${mountPath} -o ${mountOptions.join(' -o ')}`;\n logger.debug(`${LOG_PREFIX} Mounting S3:`, hasCredentials ? mountCmd.replace(credentialsPath, '***') : mountCmd);\n\n try {\n const result = await sandbox.commands.run(mountCmd, { timeoutMs: 60_000 });\n logger.debug(`${LOG_PREFIX} s3fs result:`, {\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to mount S3 bucket: ${result.stderr || result.stdout}`);\n }\n } catch (error: unknown) {\n const errorObj = error as { result?: { exitCode: number; stdout: string; stderr: string } };\n const stderr = errorObj.result?.stderr || '';\n const stdout = errorObj.result?.stdout || '';\n logger.error(`${LOG_PREFIX} s3fs error:`, { stderr, stdout, error: String(error) });\n throw new Error(`Failed to mount S3 bucket: ${stderr || stdout || error}`);\n }\n}\n","import type { FilesystemMountConfig } from '@mastra/core/workspace';\n\nimport { LOG_PREFIX, validateBucketName } from './types';\nimport type { MountContext } from './types';\n\n/**\n * GCS mount config for E2B (mounted via gcsfuse).\n *\n * If credentials are not provided, the bucket will be mounted as read-only\n * using anonymous access (for public buckets only).\n */\nexport interface E2BGCSMountConfig extends FilesystemMountConfig {\n type: 'gcs';\n /** GCS bucket name */\n bucket: string;\n /** Service account key JSON (optional - omit for public buckets) */\n serviceAccountKey?: string;\n}\n\n/**\n * Mount a GCS bucket using gcsfuse.\n */\nexport async function mountGCS(mountPath: string, config: E2BGCSMountConfig, ctx: MountContext): Promise<void> {\n const { sandbox, logger } = ctx;\n\n // Validate inputs before interpolating into shell commands\n validateBucketName(config.bucket);\n\n // Install gcsfuse if not present\n const checkResult = await sandbox.commands.run('which gcsfuse || echo \"not found\"');\n if (checkResult.stdout.includes('not found')) {\n // Detect Ubuntu codename for the gcsfuse repo (default to jammy if unknown)\n const codenameResult = await sandbox.commands.run('lsb_release -cs 2>/dev/null || echo jammy');\n const codename = codenameResult.stdout.trim() || 'jammy';\n\n // Use signed-by keyring instead of deprecated apt-key\n await sandbox.commands.run(\n 'curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/gcsfuse.gpg && ' +\n `echo \"deb [signed-by=/etc/apt/keyrings/gcsfuse.gpg] https://packages.cloud.google.com/apt gcsfuse-${codename} main\" | sudo tee /etc/apt/sources.list.d/gcsfuse.list && ` +\n 'sudo apt-get update && sudo apt-get install -y gcsfuse',\n { timeoutMs: 120_000 },\n );\n }\n\n // Get user's uid/gid for proper file ownership\n const idResult = await sandbox.commands.run('id -u && id -g');\n const [uid, gid] = idResult.stdout.trim().split('\\n');\n\n // Build gcsfuse flags\n // Note: gcsfuse uses --uid/--gid flags, not -o uid=X style\n const uidGidFlags = uid && gid ? `--uid=${uid} --gid=${gid}` : '';\n\n const hasCredentials = !!config.serviceAccountKey;\n let mountCmd: string;\n\n if (hasCredentials) {\n // Write service account key with root ownership so sudo gcsfuse can read it\n const keyPath = '/tmp/gcs-key.json';\n await sandbox.commands.run(`sudo rm -f ${keyPath}`);\n await sandbox.files.write(keyPath, config.serviceAccountKey!);\n // Make readable by root (sudo gcsfuse runs as root)\n await sandbox.commands.run(`sudo chown root:root ${keyPath} && sudo chmod 600 ${keyPath}`);\n\n // Mount with credentials using --key-file flag\n // Use sudo for /dev/fuse access (same as s3fs)\n // -o allow_other lets non-root users access the FUSE mount\n mountCmd = `sudo gcsfuse --key-file=${keyPath} -o allow_other ${uidGidFlags} ${config.bucket} ${mountPath}`;\n } else {\n // Public bucket mode - read-only access without credentials\n // Use --anonymous-access flag (not -o option)\n // Use sudo for /dev/fuse access (same as s3fs)\n logger.debug(`${LOG_PREFIX} No credentials provided, mounting GCS as public bucket (read-only)`);\n\n mountCmd = `sudo gcsfuse --anonymous-access -o allow_other ${uidGidFlags} ${config.bucket} ${mountPath}`;\n }\n\n logger.debug(`${LOG_PREFIX} Mounting GCS:`, mountCmd);\n\n try {\n const result = await sandbox.commands.run(mountCmd, { timeoutMs: 60_000 });\n logger.debug(`${LOG_PREFIX} gcsfuse result:`, {\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n });\n if (result.exitCode !== 0) {\n throw new Error(`Failed to mount GCS bucket: ${result.stderr || result.stdout}`);\n }\n } catch (error: unknown) {\n const errorObj = error as { result?: { exitCode: number; stdout: string; stderr: string } };\n const stderr = errorObj.result?.stderr || '';\n const stdout = errorObj.result?.stdout || '';\n logger.error(`${LOG_PREFIX} gcsfuse error:`, { stderr, stdout, error: String(error) });\n throw new Error(`Failed to mount GCS bucket: ${stderr || stdout || error}`);\n }\n}\n","/**\n * E2B Sandbox Provider\n *\n * A simplified E2B sandbox implementation that supports mounting\n * cloud filesystems (S3, GCS, R2) via FUSE.\n *\n * @see https://e2b.dev/docs\n */\n\nimport type {\n SandboxInfo,\n ExecuteCommandOptions,\n CommandResult,\n WorkspaceFilesystem,\n MountResult,\n FilesystemMountConfig,\n ProviderStatus,\n MountManager,\n MastraSandboxOptions,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { Sandbox, Template } from 'e2b';\nimport type { TemplateBuilder, TemplateClass } from 'e2b';\n\nimport { shellQuote } from '../utils/shell-quote';\nimport { createDefaultMountableTemplate } from '../utils/template';\nimport type { TemplateSpec } from '../utils/template';\nimport { mountS3, mountGCS, LOG_PREFIX } from './mounts';\nimport type { E2BMountConfig, E2BS3MountConfig, E2BGCSMountConfig, MountContext } from './mounts';\n\n/** Allowlist pattern for mount paths — absolute path with safe characters only. */\nconst SAFE_MOUNT_PATH = /^\\/[a-zA-Z0-9_.\\-/]+$/;\n\nfunction validateMountPath(mountPath: string): void {\n if (!SAFE_MOUNT_PATH.test(mountPath)) {\n throw new Error(\n `Invalid mount path: ${mountPath}. Must be an absolute path with alphanumeric, dash, dot, underscore, or slash characters only.`,\n );\n }\n}\n\n/** Allowlist for marker filenames from ls output — e.g. \"mount-abc123\" */\nconst SAFE_MARKER_NAME = /^mount-[a-z0-9]+$/;\n\n// =============================================================================\n// E2B Sandbox Options\n// =============================================================================\n\n/**\n * Runtime types supported by E2B.\n */\nexport type SandboxRuntime = 'node' | 'python' | 'bash' | 'ruby' | 'go' | 'rust' | 'java' | 'cpp' | 'r';\n\n/**\n * E2B sandbox provider configuration.\n */\nexport interface E2BSandboxOptions extends Pick<MastraSandboxOptions, 'onStart' | 'onStop' | 'onDestroy'> {\n /** Unique identifier for this sandbox instance */\n id?: string;\n /**\n * Sandbox template specification.\n *\n * - `string` - Use an existing template by ID\n * - `TemplateBuilder` - Use a custom template (e.g., from `createMountableTemplate()`)\n * - `(base) => base.aptInstall([...])` - Customize the default mountable template\n *\n * If not provided and mounting is used, a default template with s3fs will be built.\n * For best performance, pre-build your template and use the template ID.\n *\n * @see createDefaultMountableTemplate\n */\n template?: TemplateSpec;\n /** Execution timeout in milliseconds\n *\n * @default 300_000 // 5 minutes\n */\n timeout?: number;\n /** Environment variables to set in the sandbox */\n env?: Record<string, string>;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n /** Supported runtimes (default: ['node', 'python', 'bash']) */\n runtimes?: SandboxRuntime[];\n\n /** Domain for self-hosted E2B. Falls back to E2B_DOMAIN env var. */\n domain?: string;\n /** API URL for self-hosted E2B. Falls back to E2B_API_URL env var. */\n apiUrl?: string;\n /** API key for authentication. Falls back to E2B_API_KEY env var. */\n apiKey?: string;\n /** Access token for authentication. Falls back to E2B_ACCESS_TOKEN env var. */\n accessToken?: string;\n}\n\n// =============================================================================\n// E2B Sandbox Implementation\n// =============================================================================\n\n/**\n * Simplified E2B sandbox implementation.\n *\n * Features:\n * - Single sandbox instance lifecycle\n * - Supports mounting cloud filesystems (S3, GCS, R2) via FUSE\n * - Automatic sandbox timeout handling with retry\n *\n * @example Basic usage\n * ```typescript\n * import { Workspace } from '@mastra/core/workspace';\n * import { E2BSandbox } from '@mastra/e2b';\n *\n * const sandbox = new E2BSandbox({\n * timeout: 60000,\n * });\n *\n * const workspace = new Workspace({ sandbox });\n * const result = await workspace.executeCode('console.log(\"Hello!\")');\n * ```\n *\n * @example With S3 filesystem mounting\n * ```typescript\n * import { Workspace } from '@mastra/core/workspace';\n * import { E2BSandbox } from '@mastra/e2b';\n * import { S3Filesystem } from '@mastra/s3';\n *\n * const workspace = new Workspace({\n * mounts: {\n * '/bucket': new S3Filesystem({\n * bucket: 'my-bucket',\n * region: 'us-east-1',\n * }),\n * },\n * sandbox: new E2BSandbox({ timeout: 60000 }),\n * });\n *\n * ```\n */\nexport class E2BSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'E2BSandbox';\n readonly provider = 'e2b';\n\n // Status is managed by base class lifecycle methods\n status: ProviderStatus = 'pending';\n\n private _sandbox: Sandbox | null = null;\n private _createdAt: Date | null = null;\n private _isRetrying = false;\n\n private readonly timeout: number;\n private readonly templateSpec?: TemplateSpec;\n private readonly env: Record<string, string>;\n private readonly metadata: Record<string, unknown>;\n private readonly configuredRuntimes: SandboxRuntime[];\n private readonly connectionOpts: Record<string, string>;\n declare readonly mounts: MountManager; // Non-optional (initialized by BaseSandbox)\n\n /** Resolved template ID after building (if needed) */\n private _resolvedTemplateId?: string;\n\n /** Promise for template preparation (started in constructor) */\n private _templatePreparePromise?: Promise<string>;\n\n constructor(options: E2BSandboxOptions = {}) {\n super({ name: 'E2BSandbox', onStart: options.onStart, onStop: options.onStop, onDestroy: options.onDestroy });\n\n this.id = options.id ?? this.generateId();\n this.timeout = options.timeout ?? 300_000; // 5 minutes;\n this.templateSpec = options.template;\n this.env = options.env ?? {};\n this.metadata = options.metadata ?? {};\n this.configuredRuntimes = options.runtimes ?? ['node', 'python', 'bash'];\n this.connectionOpts = {\n ...(options.domain && { domain: options.domain }),\n ...(options.apiUrl && { apiUrl: options.apiUrl }),\n ...(options.apiKey && { apiKey: options.apiKey }),\n ...(options.accessToken && { accessToken: options.accessToken }),\n };\n\n // Start template preparation immediately in background\n // This way template build (if needed) begins before start() is called\n this._templatePreparePromise = this.resolveTemplate().catch(err => {\n this.logger.debug(`${LOG_PREFIX} Template preparation error (will retry on start):`, err);\n return ''; // Return empty string, will be retried in start()\n });\n }\n\n private generateId(): string {\n return `e2b-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n }\n\n get supportedRuntimes(): readonly SandboxRuntime[] {\n return this.configuredRuntimes;\n }\n\n get defaultRuntime(): SandboxRuntime {\n return this.configuredRuntimes[0] ?? 'node';\n }\n\n /**\n * Get the underlying E2B Sandbox instance for direct access to E2B APIs.\n *\n * Use this when you need to access E2B features not exposed through the\n * WorkspaceSandbox interface (e.g., files API, ports, etc.).\n *\n * @throws {SandboxNotReadyError} If the sandbox has not been started\n *\n * @example Direct file operations\n * ```typescript\n * const e2bSandbox = sandbox.instance;\n * await e2bSandbox.files.write('/tmp/test.txt', 'Hello');\n * const content = await e2bSandbox.files.read('/tmp/test.txt');\n * const files = await e2bSandbox.files.list('/tmp');\n * ```\n *\n * @example Access ports\n * ```typescript\n * const e2bSandbox = sandbox.instance;\n * const url = e2bSandbox.getHost(3000);\n * ```\n */\n get instance(): Sandbox {\n if (!this._sandbox) {\n throw new SandboxNotReadyError(this.id);\n }\n return this._sandbox;\n }\n\n // ---------------------------------------------------------------------------\n // Mount Support\n // ---------------------------------------------------------------------------\n\n /**\n * Mount a filesystem at a path in the sandbox.\n * Uses FUSE tools (s3fs, gcsfuse) to mount cloud storage.\n */\n async mount(filesystem: WorkspaceFilesystem, mountPath: string): Promise<MountResult> {\n validateMountPath(mountPath);\n\n if (!this._sandbox) {\n throw new SandboxNotReadyError(this.id);\n }\n\n this.logger.debug(`${LOG_PREFIX} Mounting \"${mountPath}\"...`);\n\n // Get mount config - MountManager validates this exists before calling mount()\n const config = filesystem.getMountConfig?.() as E2BMountConfig | undefined;\n if (!config) {\n const error = `Filesystem \"${filesystem.id}\" does not provide a mount config`;\n this.logger.error(`${LOG_PREFIX} ${error}`);\n this.mounts.set(mountPath, { filesystem, state: 'error', error });\n return { success: false, mountPath, error };\n }\n\n // Check if already mounted with matching config (e.g., when reconnecting to existing sandbox)\n const existingMount = await this.checkExistingMount(mountPath, config);\n if (existingMount === 'matching') {\n this.logger.debug(\n `${LOG_PREFIX} Detected existing mount for ${filesystem.provider} (\"${filesystem.id}\") at \"${mountPath}\" with correct config, skipping`,\n );\n this.mounts.set(mountPath, { state: 'mounted', config });\n return { success: true, mountPath };\n } else if (existingMount === 'mismatched') {\n // Different config - unmount and re-mount\n this.logger.debug(`${LOG_PREFIX} Config mismatch, unmounting to re-mount with new config...`);\n await this.unmount(mountPath);\n }\n this.logger.debug(`${LOG_PREFIX} Config type: ${config.type}`);\n\n // Mark as mounting (handles direct mount() calls; MountManager also sets this for processPending)\n this.mounts.set(mountPath, { filesystem, state: 'mounting', config });\n\n // Check if directory exists and is non-empty (would shadow existing files)\n try {\n const checkResult = await this._sandbox.commands.run(\n `[ -d \"${mountPath}\" ] && [ \"$(ls -A \"${mountPath}\" 2>/dev/null)\" ] && echo \"non-empty\" || echo \"ok\"`,\n );\n if (checkResult.stdout.trim() === 'non-empty') {\n const error = `Cannot mount at ${mountPath}: directory exists and is not empty. Mounting would hide existing files. Use a different path or empty the directory first.`;\n this.logger.error(`${LOG_PREFIX} ${error}`);\n this.mounts.set(mountPath, { filesystem, state: 'error', config, error });\n return { success: false, mountPath, error };\n }\n } catch {\n // Check failed, proceed anyway\n }\n\n // Create mount directory with sudo (for paths outside home dir like /data)\n // Then chown to current user so mount works without issues\n try {\n this.logger.debug(`${LOG_PREFIX} Creating mount directory for ${mountPath}...`);\n const mkdirCommand = `sudo mkdir -p \"${mountPath}\" && sudo chown $(id -u):$(id -g) \"${mountPath}\"`;\n\n this.logger.debug(`${LOG_PREFIX} Running command: ${mkdirCommand}`);\n const mkdirResult = await this._sandbox.commands.run(mkdirCommand);\n\n this.logger.debug(`${LOG_PREFIX} Created mount directory for mount path \"${mountPath}\":`, mkdirResult);\n } catch (mkdirError) {\n this.logger.debug(`${LOG_PREFIX} mkdir error for \"${mountPath}\":`, mkdirError);\n this.mounts.set(mountPath, { filesystem, state: 'error', config, error: String(mkdirError) });\n return { success: false, mountPath, error: String(mkdirError) };\n }\n\n // Create mount context for mount operations\n const mountCtx: MountContext = {\n sandbox: this._sandbox,\n logger: this.logger,\n };\n\n try {\n switch (config.type) {\n case 's3':\n this.logger.debug(`${LOG_PREFIX} Mounting S3 bucket at ${mountPath}...`);\n await mountS3(mountPath, config as E2BS3MountConfig, mountCtx);\n this.logger.debug(`${LOG_PREFIX} Mounted S3 bucket at ${mountPath}`);\n break;\n case 'gcs':\n this.logger.debug(`${LOG_PREFIX} Mounting GCS bucket at ${mountPath}...`);\n await mountGCS(mountPath, config as E2BGCSMountConfig, mountCtx);\n this.logger.debug(`${LOG_PREFIX} Mounted GCS bucket at ${mountPath}`);\n break;\n default:\n this.mounts.set(mountPath, {\n filesystem,\n state: 'unsupported',\n config,\n error: `Unsupported mount type: ${(config as FilesystemMountConfig).type}`,\n });\n return {\n success: false,\n mountPath,\n error: `Unsupported mount type: ${(config as FilesystemMountConfig).type}`,\n };\n }\n } catch (error) {\n this.logger.error(\n `${LOG_PREFIX} Error mounting \"${filesystem.provider}\" (${filesystem.id}) at \"${mountPath}\":`,\n error,\n );\n this.mounts.set(mountPath, { filesystem, state: 'error', config, error: String(error) });\n\n // Clean up the directory we created since mount failed\n try {\n await this._sandbox!.commands.run(`sudo rmdir \"${mountPath}\" 2>/dev/null || true`);\n this.logger.debug(`${LOG_PREFIX} Cleaned up directory after failed mount: ${mountPath}`);\n } catch {\n // Ignore cleanup errors\n }\n\n return { success: false, mountPath, error: String(error) };\n }\n\n // Mark as mounted\n this.mounts.set(mountPath, { state: 'mounted', config });\n\n // Write marker file so we can detect config changes on reconnect\n await this.writeMarkerFile(mountPath);\n\n this.logger.debug(`${LOG_PREFIX} Mounted ${mountPath}`);\n return { success: true, mountPath };\n }\n\n /**\n * Write marker file for detecting config changes on reconnect.\n * Stores both the mount path and config hash in the file.\n */\n private async writeMarkerFile(mountPath: string): Promise<void> {\n if (!this._sandbox) return;\n\n const markerContent = this.mounts.getMarkerContent(mountPath);\n if (!markerContent) return;\n\n const filename = this.mounts.markerFilename(mountPath);\n const markerPath = `/tmp/.mastra-mounts/${filename}`;\n try {\n await this._sandbox.commands.run('mkdir -p /tmp/.mastra-mounts');\n await this._sandbox.files.write(markerPath, markerContent);\n } catch {\n // Non-fatal - marker is just for optimization\n this.logger.debug(`${LOG_PREFIX} Warning: Could not write marker file at ${markerPath}`);\n }\n }\n\n /**\n * Unmount a filesystem from a path in the sandbox.\n */\n async unmount(mountPath: string): Promise<void> {\n validateMountPath(mountPath);\n\n if (!this._sandbox) {\n throw new SandboxNotReadyError(this.id);\n }\n\n this.logger.debug(`${LOG_PREFIX} Unmounting ${mountPath}...`);\n\n try {\n // Use fusermount for FUSE mounts, fall back to umount\n const result = await this._sandbox.commands.run(\n `sudo fusermount -u \"${mountPath}\" 2>/dev/null || sudo umount \"${mountPath}\"`,\n );\n if (result.exitCode !== 0) {\n this.logger.debug(`${LOG_PREFIX} Unmount warning: ${result.stderr || result.stdout}`);\n }\n } catch (error) {\n this.logger.debug(`${LOG_PREFIX} Unmount error:`, error);\n // Try lazy unmount as last resort\n await this._sandbox.commands.run(`sudo umount -l \"${mountPath}\" 2>/dev/null || true`);\n }\n\n this.mounts.delete(mountPath);\n\n // Clean up marker file\n const filename = this.mounts.markerFilename(mountPath);\n const markerPath = `/tmp/.mastra-mounts/${filename}`;\n await this._sandbox.commands.run(`rm -f \"${markerPath}\" 2>/dev/null || true`);\n\n // Remove empty mount directory (only if empty, rmdir fails on non-empty)\n // Use sudo since mount directories outside home (like /data) were created with sudo\n const rmdirResult = await this._sandbox.commands.run(`sudo rmdir \"${mountPath}\" 2>&1`);\n if (rmdirResult.exitCode === 0) {\n this.logger.debug(`${LOG_PREFIX} Unmounted and removed ${mountPath}`);\n } else {\n this.logger.debug(\n `${LOG_PREFIX} Unmounted ${mountPath} (directory not removed: ${rmdirResult.stderr?.trim() || 'not empty'})`,\n );\n }\n }\n\n /**\n * Get list of current mounts in the sandbox.\n */\n async getMounts(): Promise<Array<{ path: string; filesystem: string }>> {\n return Array.from(this.mounts.entries).map(([path, entry]) => ({\n path,\n filesystem: entry.filesystem?.provider ?? entry.config?.type ?? 'unknown',\n }));\n }\n\n /**\n * Unmount all stale mounts that are not in the expected mounts list.\n * Also cleans up orphaned directories and marker files from failed mount attempts.\n * Call this after reconnecting to an existing sandbox to clean up old mounts.\n */\n async reconcileMounts(expectedMountPaths: string[]): Promise<void> {\n if (!this._sandbox) {\n throw new SandboxNotReadyError(this.id);\n }\n\n this.logger.debug(`${LOG_PREFIX} Reconciling mounts. Expected paths:`, expectedMountPaths);\n\n // Get current FUSE mounts in the sandbox\n const mountsResult = await this._sandbox.commands.run(\n `grep -E 'fuse\\\\.(s3fs|gcsfuse)' /proc/mounts | awk '{print $2}'`,\n );\n const currentMounts = mountsResult.stdout\n .trim()\n .split('\\n')\n .filter(p => p.length > 0);\n\n this.logger.debug(`${LOG_PREFIX} Current FUSE mounts in sandbox:`, currentMounts);\n\n // Read our marker files to know which mounts WE created\n const markersResult = await this._sandbox.commands.run(`ls /tmp/.mastra-mounts/ 2>/dev/null || echo \"\"`);\n const markerFiles = markersResult.stdout\n .trim()\n .split('\\n')\n .filter(f => f.length > 0 && SAFE_MARKER_NAME.test(f));\n\n // Build a map of mount paths → marker filenames for mounts WE created\n const managedMountPaths = new Map<string, string>();\n for (const markerFile of markerFiles) {\n const markerResult = await this._sandbox.commands.run(\n `cat \"/tmp/.mastra-mounts/${markerFile}\" 2>/dev/null || echo \"\"`,\n );\n const parsed = this.mounts.parseMarkerContent(markerResult.stdout.trim());\n if (parsed && SAFE_MOUNT_PATH.test(parsed.path)) {\n managedMountPaths.set(parsed.path, markerFile);\n }\n }\n\n // Find mounts that exist but shouldn't — only unmount if WE created them (have a marker)\n const staleMounts = currentMounts.filter(path => !expectedMountPaths.includes(path));\n\n for (const stalePath of staleMounts) {\n if (managedMountPaths.has(stalePath)) {\n this.logger.debug(`${LOG_PREFIX} Found stale managed FUSE mount at ${stalePath}, unmounting...`);\n await this.unmount(stalePath);\n } else {\n this.logger.debug(`${LOG_PREFIX} Found external FUSE mount at ${stalePath}, leaving untouched`);\n }\n }\n\n // Clean up orphaned marker files and empty directories from failed mounts\n try {\n const expectedMarkerFiles = new Set(expectedMountPaths.map(p => this.mounts.markerFilename(p)));\n\n // Build a reverse map: markerFile → mountPath\n const markerToPath = new Map<string, string>();\n for (const [path, file] of managedMountPaths) {\n markerToPath.set(file, path);\n }\n\n for (const markerFile of markerFiles) {\n // If this marker file doesn't correspond to an expected mount path, clean it up\n if (!expectedMarkerFiles.has(markerFile)) {\n const mountPath = markerToPath.get(markerFile);\n\n if (mountPath) {\n // Only clean up directory if not currently FUSE mounted\n if (!currentMounts.includes(mountPath)) {\n this.logger.debug(`${LOG_PREFIX} Cleaning up orphaned marker and directory for ${mountPath}`);\n\n // Remove marker file\n await this._sandbox.commands.run(`rm -f \"/tmp/.mastra-mounts/${markerFile}\" 2>/dev/null || true`);\n\n // Try to remove the directory (will fail if not empty or doesn't exist, which is fine)\n await this._sandbox.commands.run(`sudo rmdir \"${mountPath}\" 2>/dev/null || true`);\n }\n } else {\n // Malformed marker file - just delete it\n this.logger.debug(`${LOG_PREFIX} Removing malformed marker file: ${markerFile}`);\n await this._sandbox.commands.run(`rm -f \"/tmp/.mastra-mounts/${markerFile}\" 2>/dev/null || true`);\n }\n }\n }\n } catch {\n // Ignore errors during orphan cleanup\n this.logger.debug(`${LOG_PREFIX} Error during orphan cleanup (non-fatal)`);\n }\n }\n\n /**\n * Check if a path is already mounted and if the config matches.\n *\n * @param mountPath - The mount path to check\n * @param newConfig - The new config to compare against the stored config\n * @returns 'not_mounted' | 'matching' | 'mismatched'\n */\n private async checkExistingMount(\n mountPath: string,\n newConfig: E2BMountConfig,\n ): Promise<'not_mounted' | 'matching' | 'mismatched'> {\n if (!this._sandbox) throw new SandboxNotReadyError(this.id);\n\n // Check if path is a mount point\n const mountCheck = await this._sandbox.commands.run(\n `mountpoint -q \"${mountPath}\" && echo \"mounted\" || echo \"not mounted\"`,\n );\n\n if (mountCheck.stdout.trim() !== 'mounted') {\n return 'not_mounted';\n }\n\n // Path is mounted - check if config matches via marker file\n const filename = this.mounts.markerFilename(mountPath);\n const markerPath = `/tmp/.mastra-mounts/${filename}`;\n\n try {\n const markerResult = await this._sandbox.commands.run(`cat \"${markerPath}\" 2>/dev/null || echo \"\"`);\n const parsed = this.mounts.parseMarkerContent(markerResult.stdout.trim());\n\n if (!parsed) {\n return 'mismatched';\n }\n\n // Compute hash of the NEW config and compare with stored hash\n const newConfigHash = this.mounts.computeConfigHash(newConfig);\n this.logger.debug(\n `${LOG_PREFIX} Marker check - stored hash: \"${parsed.configHash}\", new config hash: \"${newConfigHash}\"`,\n );\n\n if (parsed.path === mountPath && parsed.configHash === newConfigHash) {\n return 'matching';\n }\n } catch {\n // Marker doesn't exist or can't be read - treat as mismatched\n }\n\n return 'mismatched';\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle (overrides base class protected methods)\n // ---------------------------------------------------------------------------\n\n /**\n * Start the E2B sandbox.\n * Handles template preparation, existing sandbox reconnection, and new sandbox creation.\n *\n * Status management and mount processing are handled by the base class.\n */\n async start(): Promise<void> {\n // Already have a sandbox instance\n if (this._sandbox) {\n return;\n }\n\n // Await template preparation (started in constructor) and existing sandbox search in parallel\n const [existingSandbox, templateId] = await Promise.all([\n this.findExistingSandbox(),\n this._templatePreparePromise || this.resolveTemplate(),\n ]);\n\n if (existingSandbox) {\n this._sandbox = existingSandbox;\n this._createdAt = new Date();\n this.logger.debug(`${LOG_PREFIX} Reconnected to existing sandbox for: ${this.id}`);\n\n // Clean up stale mounts from previous config\n // (processPending is called by base class after start completes)\n const expectedPaths = Array.from(this.mounts.entries.keys());\n this.logger.debug(`${LOG_PREFIX} Running mount reconciliation...`);\n await this.reconcileMounts(expectedPaths);\n this.logger.debug(`${LOG_PREFIX} Mount reconciliation complete`);\n return;\n }\n\n // If template preparation failed earlier, retry now\n let resolvedTemplateId = templateId;\n if (!resolvedTemplateId) {\n this.logger.debug(`${LOG_PREFIX} Template preparation failed earlier, retrying...`);\n resolvedTemplateId = await this.resolveTemplate();\n }\n\n // Create a new sandbox with our logical ID in metadata\n // Using betaCreate with autoPause so sandbox pauses on timeout instead of being destroyed\n this.logger.debug(`${LOG_PREFIX} Creating new sandbox for: ${this.id} with template: ${resolvedTemplateId}`);\n\n try {\n this._sandbox = await Sandbox.betaCreate(resolvedTemplateId, {\n ...this.connectionOpts,\n autoPause: true,\n metadata: {\n ...this.metadata,\n 'mastra-sandbox-id': this.id,\n },\n timeoutMs: this.timeout,\n });\n } catch (createError) {\n // If template not found (404), rebuild it and retry\n const errorStr = String(createError);\n if (errorStr.includes('404') && errorStr.includes('not found') && !this.templateSpec) {\n this.logger.debug(`${LOG_PREFIX} Template not found, rebuilding: ${templateId}`);\n this._resolvedTemplateId = undefined; // Clear cached ID to force rebuild\n const rebuiltTemplateId = await this.buildDefaultTemplate();\n\n this.logger.debug(`${LOG_PREFIX} Retrying sandbox creation with rebuilt template: ${rebuiltTemplateId}`);\n this._sandbox = await Sandbox.betaCreate(rebuiltTemplateId, {\n ...this.connectionOpts,\n autoPause: true,\n metadata: {\n ...this.metadata,\n 'mastra-sandbox-id': this.id,\n },\n timeoutMs: this.timeout,\n });\n } else {\n throw createError;\n }\n }\n\n this.logger.debug(`${LOG_PREFIX} Created sandbox ${this._sandbox.sandboxId} for logical ID: ${this.id}`);\n this._createdAt = new Date();\n // Note: processPending is called by base class after start completes\n }\n\n /**\n * Build the default mountable template (bypasses exists check).\n */\n private async buildDefaultTemplate(): Promise<string> {\n const { template, id } = createDefaultMountableTemplate();\n this.logger.debug(`${LOG_PREFIX} Building default mountable template: ${id}...`);\n const buildResult = await Template.build(template as TemplateClass, id, this.connectionOpts);\n this._resolvedTemplateId = buildResult.templateId;\n this.logger.debug(`${LOG_PREFIX} Template built: ${buildResult.templateId}`);\n return buildResult.templateId;\n }\n\n /**\n * Resolve the template specification to a template ID.\n *\n * - String: Use as-is (template ID)\n * - TemplateBuilder: Build and return the template ID\n * - Function: Apply to base mountable template, then build\n * - undefined: Use default mountable template (cached)\n */\n private async resolveTemplate(): Promise<string> {\n // If already resolved, return cached ID\n if (this._resolvedTemplateId) {\n return this._resolvedTemplateId;\n }\n\n // No template specified - use default mountable template with caching\n if (!this.templateSpec) {\n const { template, id } = createDefaultMountableTemplate();\n\n // Check if template already exists (cached from previous runs)\n const exists = await Template.exists(id, this.connectionOpts);\n if (exists) {\n this.logger.debug(`${LOG_PREFIX} Using cached mountable template: ${id}`);\n this._resolvedTemplateId = id;\n return id;\n }\n\n // Build the template (first time only)\n this.logger.debug(`${LOG_PREFIX} Building default mountable template: ${id}...`);\n const buildResult = await Template.build(template as TemplateClass, id, this.connectionOpts);\n this._resolvedTemplateId = buildResult.templateId;\n this.logger.debug(`${LOG_PREFIX} Template built and cached: ${buildResult.templateId}`);\n return buildResult.templateId;\n }\n\n // String template ID - use directly\n if (typeof this.templateSpec === 'string') {\n this._resolvedTemplateId = this.templateSpec;\n return this.templateSpec;\n }\n\n // TemplateBuilder or function - need to build\n let template: TemplateBuilder;\n let templateName: string;\n\n if (typeof this.templateSpec === 'function') {\n // Apply customization function to base mountable template\n const { template: baseTemplate } = createDefaultMountableTemplate();\n template = this.templateSpec(baseTemplate);\n // Custom templates get unique names since they're modified\n templateName = `mastra-custom-${this.id.replace(/[^a-zA-Z0-9-]/g, '-')}`;\n } else {\n // Use provided TemplateBuilder directly\n template = this.templateSpec;\n templateName = `mastra-${this.id.replace(/[^a-zA-Z0-9-]/g, '-')}`;\n }\n\n // Build the template\n this.logger.debug(`${LOG_PREFIX} Building custom template: ${templateName}...`);\n const buildResult = await Template.build(template as TemplateClass, templateName, this.connectionOpts);\n this._resolvedTemplateId = buildResult.templateId;\n this.logger.debug(`${LOG_PREFIX} Template built: ${buildResult.templateId}`);\n\n return buildResult.templateId;\n }\n\n /**\n * Find an existing sandbox with matching mastra-sandbox-id metadata.\n * Returns the connected sandbox if found, null otherwise.\n */\n private async findExistingSandbox(): Promise<Sandbox | null> {\n try {\n // Query E2B for existing sandbox with our logical ID in metadata\n const paginator = Sandbox.list({\n ...this.connectionOpts,\n query: {\n metadata: { 'mastra-sandbox-id': this.id },\n state: ['running', 'paused'],\n },\n });\n\n const sandboxes = await paginator.nextItems();\n\n this.logger.debug(`${LOG_PREFIX} sandboxes:`, sandboxes);\n\n // Sandbox.list only returns running/paused sandboxes, so no need to filter\n if (sandboxes.length > 0) {\n const existingSandbox = sandboxes[0]!;\n this.logger.debug(\n `${LOG_PREFIX} Found existing sandbox for ${this.id}: ${existingSandbox.sandboxId} (state: ${existingSandbox.state})`,\n );\n return await Sandbox.connect(existingSandbox.sandboxId, this.connectionOpts);\n }\n } catch (e) {\n this.logger.debug(`${LOG_PREFIX} Error querying for existing sandbox:`, e);\n // Continue to create new sandbox\n }\n\n return null;\n }\n\n /**\n * Stop the E2B sandbox.\n * Unmounts all filesystems and releases the sandbox reference.\n * Status management is handled by the base class.\n */\n async stop(): Promise<void> {\n // Unmount all filesystems before stopping\n // Collect keys first since unmount() mutates the map\n for (const mountPath of [...this.mounts.entries.keys()]) {\n try {\n await this.unmount(mountPath);\n } catch {\n // Best-effort unmount; sandbox may already be dead\n }\n }\n\n this._sandbox = null;\n }\n\n /**\n * Destroy the E2B sandbox and clean up all resources.\n * Unmounts filesystems, kills the sandbox, and clears mount state.\n * Status management is handled by the base class.\n */\n async destroy(): Promise<void> {\n // Unmount all filesystems\n // Collect keys first since unmount() mutates the map\n for (const mountPath of [...this.mounts.entries.keys()]) {\n try {\n await this.unmount(mountPath);\n } catch {\n // Ignore errors during cleanup\n }\n }\n\n if (this._sandbox) {\n try {\n await this._sandbox.kill();\n } catch {\n // Ignore errors during destroy\n }\n }\n\n this._sandbox = null;\n this.mounts.clear();\n }\n\n /**\n * Check if the sandbox is ready for operations.\n */\n async isReady(): Promise<boolean> {\n return this.status === 'running' && this._sandbox !== null;\n }\n\n /**\n * Get information about the current state of the sandbox.\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 mounts: Array.from(this.mounts.entries).map(([path, entry]) => ({\n path,\n filesystem: entry.filesystem?.provider ?? entry.config?.type ?? 'unknown',\n })),\n metadata: {\n ...this.metadata,\n },\n };\n }\n\n /**\n * Get instructions describing this E2B sandbox.\n * Used by agents to understand the execution environment.\n */\n getInstructions(): string {\n const mountCount = this.mounts.entries.size;\n const mountInfo = mountCount > 0 ? ` ${mountCount} filesystem(s) mounted via FUSE.` : '';\n return `Cloud sandbox with /home/user as working directory.${mountInfo}`;\n }\n\n // ---------------------------------------------------------------------------\n // Internal Helpers\n // ---------------------------------------------------------------------------\n\n /**\n * Ensure the sandbox is started and return the E2B Sandbox instance.\n * Uses base class ensureRunning() for status management and error handling.\n * @throws {SandboxNotReadyError} if sandbox fails to start\n */\n private async ensureSandbox(): Promise<Sandbox> {\n await this.ensureRunning();\n return this._sandbox!;\n }\n\n /**\n * Check if an error indicates the sandbox itself is dead/gone.\n * Does NOT include code execution timeouts (those are the user's code taking too long).\n * Does NOT include \"port is not open\" - that needs sandbox kill, not reconnect.\n */\n private isSandboxDeadError(error: unknown): boolean {\n if (!error) return false;\n const errorStr = String(error);\n return (\n errorStr.includes('sandbox was not found') ||\n errorStr.includes('Sandbox is probably not running') ||\n errorStr.includes('Sandbox not found') ||\n errorStr.includes('sandbox has been killed')\n );\n }\n\n /**\n * Handle sandbox timeout by clearing the instance and resetting state.\n *\n * Bypasses the normal stop() lifecycle because the sandbox is already dead —\n * we can't unmount filesystems or run cleanup commands. Instead we reset\n * mount states to 'pending' so they get re-mounted when start() runs again.\n */\n private handleSandboxTimeout(): void {\n this._sandbox = null;\n\n // Reset mounted entries to pending so they get re-mounted on restart\n for (const [path, entry] of this.mounts.entries) {\n if (entry.state === 'mounted' || entry.state === 'mounting') {\n this.mounts.set(path, { state: 'pending' });\n }\n }\n\n this.status = 'stopped';\n }\n\n // ---------------------------------------------------------------------------\n // Command Execution\n // ---------------------------------------------------------------------------\n\n /**\n * Execute a shell command in the sandbox.\n * Automatically starts the sandbox if not already running.\n * Retries once if the sandbox is found to be dead.\n */\n async executeCommand(\n command: string,\n args: string[] = [],\n options: ExecuteCommandOptions = {},\n ): Promise<CommandResult> {\n this.logger.debug(`${LOG_PREFIX} Executing: ${command} ${args.join(' ')}`, options);\n const sandbox = await this.ensureSandbox();\n\n const startTime = Date.now();\n const fullCommand = args.length > 0 ? `${command} ${args.map(shellQuote).join(' ')}` : command;\n\n this.logger.debug(`${LOG_PREFIX} Executing: ${fullCommand}`);\n\n try {\n // Merge sandbox default env with per-command env (per-command overrides)\n // Filter out undefined values to get Record<string, string>\n const mergedEnv = { ...this.env, ...options.env };\n const envs = Object.fromEntries(\n Object.entries(mergedEnv).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n\n const result = await sandbox.commands.run(fullCommand, {\n cwd: options.cwd,\n envs,\n timeoutMs: options.timeout,\n onStdout: options.onStdout,\n onStderr: options.onStderr,\n });\n\n const executionTimeMs = Date.now() - startTime;\n\n this.logger.debug(`${LOG_PREFIX} Exit code: ${result.exitCode} (${executionTimeMs}ms)`);\n if (result.stdout) this.logger.debug(`${LOG_PREFIX} stdout:\\n${result.stdout}`);\n if (result.stderr) this.logger.debug(`${LOG_PREFIX} stderr:\\n${result.stderr}`);\n\n return {\n success: result.exitCode === 0,\n exitCode: result.exitCode,\n stdout: result.stdout,\n stderr: result.stderr,\n executionTimeMs,\n command,\n args,\n };\n } catch (error) {\n // Handle sandbox-is-dead errors - retry once (not infinitely)\n if (this.isSandboxDeadError(error) && !this._isRetrying) {\n this.handleSandboxTimeout();\n this._isRetrying = true;\n try {\n return await this.executeCommand(command, args, options);\n } finally {\n this._isRetrying = false;\n }\n }\n\n const executionTimeMs = Date.now() - startTime;\n\n // E2B errors often contain the actual command result in error.result\n const errorObj = error as { result?: { exitCode: number; stdout: string; stderr: string } };\n const stdout = errorObj.result?.stdout || '';\n const stderr = errorObj.result?.stderr || (error instanceof Error ? error.message : String(error));\n const exitCode = errorObj.result?.exitCode ?? 1;\n\n this.logger.debug(`${LOG_PREFIX} Exit code: ${exitCode} (${executionTimeMs}ms) [error]`);\n if (stdout) this.logger.debug(`${LOG_PREFIX} stdout:\\n${stdout}`);\n if (stderr) this.logger.debug(`${LOG_PREFIX} stderr:\\n${stderr}`);\n\n return {\n success: false,\n exitCode,\n stdout,\n stderr,\n executionTimeMs,\n command,\n args,\n };\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2B Sandbox Provider
|
|
3
|
+
*
|
|
4
|
+
* A simplified E2B sandbox implementation that supports mounting
|
|
5
|
+
* cloud filesystems (S3, GCS, R2) via FUSE.
|
|
6
|
+
*
|
|
7
|
+
* @see https://e2b.dev/docs
|
|
8
|
+
*/
|
|
9
|
+
import type { SandboxInfo, ExecuteCommandOptions, CommandResult, WorkspaceFilesystem, MountResult, ProviderStatus, MountManager, MastraSandboxOptions } from '@mastra/core/workspace';
|
|
10
|
+
import { MastraSandbox } from '@mastra/core/workspace';
|
|
11
|
+
import { Sandbox } from 'e2b';
|
|
12
|
+
import type { TemplateSpec } from '../utils/template.js';
|
|
13
|
+
/**
|
|
14
|
+
* Runtime types supported by E2B.
|
|
15
|
+
*/
|
|
16
|
+
export type SandboxRuntime = 'node' | 'python' | 'bash' | 'ruby' | 'go' | 'rust' | 'java' | 'cpp' | 'r';
|
|
17
|
+
/**
|
|
18
|
+
* E2B sandbox provider configuration.
|
|
19
|
+
*/
|
|
20
|
+
export interface E2BSandboxOptions extends Pick<MastraSandboxOptions, 'onStart' | 'onStop' | 'onDestroy'> {
|
|
21
|
+
/** Unique identifier for this sandbox instance */
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Sandbox template specification.
|
|
25
|
+
*
|
|
26
|
+
* - `string` - Use an existing template by ID
|
|
27
|
+
* - `TemplateBuilder` - Use a custom template (e.g., from `createMountableTemplate()`)
|
|
28
|
+
* - `(base) => base.aptInstall([...])` - Customize the default mountable template
|
|
29
|
+
*
|
|
30
|
+
* If not provided and mounting is used, a default template with s3fs will be built.
|
|
31
|
+
* For best performance, pre-build your template and use the template ID.
|
|
32
|
+
*
|
|
33
|
+
* @see createDefaultMountableTemplate
|
|
34
|
+
*/
|
|
35
|
+
template?: TemplateSpec;
|
|
36
|
+
/** Execution timeout in milliseconds
|
|
37
|
+
*
|
|
38
|
+
* @default 300_000 // 5 minutes
|
|
39
|
+
*/
|
|
40
|
+
timeout?: number;
|
|
41
|
+
/** Environment variables to set in the sandbox */
|
|
42
|
+
env?: Record<string, string>;
|
|
43
|
+
/** Custom metadata */
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
/** Supported runtimes (default: ['node', 'python', 'bash']) */
|
|
46
|
+
runtimes?: SandboxRuntime[];
|
|
47
|
+
/** Domain for self-hosted E2B. Falls back to E2B_DOMAIN env var. */
|
|
48
|
+
domain?: string;
|
|
49
|
+
/** API URL for self-hosted E2B. Falls back to E2B_API_URL env var. */
|
|
50
|
+
apiUrl?: string;
|
|
51
|
+
/** API key for authentication. Falls back to E2B_API_KEY env var. */
|
|
52
|
+
apiKey?: string;
|
|
53
|
+
/** Access token for authentication. Falls back to E2B_ACCESS_TOKEN env var. */
|
|
54
|
+
accessToken?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Simplified E2B sandbox implementation.
|
|
58
|
+
*
|
|
59
|
+
* Features:
|
|
60
|
+
* - Single sandbox instance lifecycle
|
|
61
|
+
* - Supports mounting cloud filesystems (S3, GCS, R2) via FUSE
|
|
62
|
+
* - Automatic sandbox timeout handling with retry
|
|
63
|
+
*
|
|
64
|
+
* @example Basic usage
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { Workspace } from '@mastra/core/workspace';
|
|
67
|
+
* import { E2BSandbox } from '@mastra/e2b';
|
|
68
|
+
*
|
|
69
|
+
* const sandbox = new E2BSandbox({
|
|
70
|
+
* timeout: 60000,
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const workspace = new Workspace({ sandbox });
|
|
74
|
+
* const result = await workspace.executeCode('console.log("Hello!")');
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example With S3 filesystem mounting
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { Workspace } from '@mastra/core/workspace';
|
|
80
|
+
* import { E2BSandbox } from '@mastra/e2b';
|
|
81
|
+
* import { S3Filesystem } from '@mastra/s3';
|
|
82
|
+
*
|
|
83
|
+
* const workspace = new Workspace({
|
|
84
|
+
* mounts: {
|
|
85
|
+
* '/bucket': new S3Filesystem({
|
|
86
|
+
* bucket: 'my-bucket',
|
|
87
|
+
* region: 'us-east-1',
|
|
88
|
+
* }),
|
|
89
|
+
* },
|
|
90
|
+
* sandbox: new E2BSandbox({ timeout: 60000 }),
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare class E2BSandbox extends MastraSandbox {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly name = "E2BSandbox";
|
|
98
|
+
readonly provider = "e2b";
|
|
99
|
+
status: ProviderStatus;
|
|
100
|
+
private _sandbox;
|
|
101
|
+
private _createdAt;
|
|
102
|
+
private _isRetrying;
|
|
103
|
+
private readonly timeout;
|
|
104
|
+
private readonly templateSpec?;
|
|
105
|
+
private readonly env;
|
|
106
|
+
private readonly metadata;
|
|
107
|
+
private readonly configuredRuntimes;
|
|
108
|
+
private readonly connectionOpts;
|
|
109
|
+
readonly mounts: MountManager;
|
|
110
|
+
/** Resolved template ID after building (if needed) */
|
|
111
|
+
private _resolvedTemplateId?;
|
|
112
|
+
/** Promise for template preparation (started in constructor) */
|
|
113
|
+
private _templatePreparePromise?;
|
|
114
|
+
constructor(options?: E2BSandboxOptions);
|
|
115
|
+
private generateId;
|
|
116
|
+
get supportedRuntimes(): readonly SandboxRuntime[];
|
|
117
|
+
get defaultRuntime(): SandboxRuntime;
|
|
118
|
+
/**
|
|
119
|
+
* Get the underlying E2B Sandbox instance for direct access to E2B APIs.
|
|
120
|
+
*
|
|
121
|
+
* Use this when you need to access E2B features not exposed through the
|
|
122
|
+
* WorkspaceSandbox interface (e.g., files API, ports, etc.).
|
|
123
|
+
*
|
|
124
|
+
* @throws {SandboxNotReadyError} If the sandbox has not been started
|
|
125
|
+
*
|
|
126
|
+
* @example Direct file operations
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const e2bSandbox = sandbox.instance;
|
|
129
|
+
* await e2bSandbox.files.write('/tmp/test.txt', 'Hello');
|
|
130
|
+
* const content = await e2bSandbox.files.read('/tmp/test.txt');
|
|
131
|
+
* const files = await e2bSandbox.files.list('/tmp');
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @example Access ports
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const e2bSandbox = sandbox.instance;
|
|
137
|
+
* const url = e2bSandbox.getHost(3000);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
get instance(): Sandbox;
|
|
141
|
+
/**
|
|
142
|
+
* Mount a filesystem at a path in the sandbox.
|
|
143
|
+
* Uses FUSE tools (s3fs, gcsfuse) to mount cloud storage.
|
|
144
|
+
*/
|
|
145
|
+
mount(filesystem: WorkspaceFilesystem, mountPath: string): Promise<MountResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Write marker file for detecting config changes on reconnect.
|
|
148
|
+
* Stores both the mount path and config hash in the file.
|
|
149
|
+
*/
|
|
150
|
+
private writeMarkerFile;
|
|
151
|
+
/**
|
|
152
|
+
* Unmount a filesystem from a path in the sandbox.
|
|
153
|
+
*/
|
|
154
|
+
unmount(mountPath: string): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Get list of current mounts in the sandbox.
|
|
157
|
+
*/
|
|
158
|
+
getMounts(): Promise<Array<{
|
|
159
|
+
path: string;
|
|
160
|
+
filesystem: string;
|
|
161
|
+
}>>;
|
|
162
|
+
/**
|
|
163
|
+
* Unmount all stale mounts that are not in the expected mounts list.
|
|
164
|
+
* Also cleans up orphaned directories and marker files from failed mount attempts.
|
|
165
|
+
* Call this after reconnecting to an existing sandbox to clean up old mounts.
|
|
166
|
+
*/
|
|
167
|
+
reconcileMounts(expectedMountPaths: string[]): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Check if a path is already mounted and if the config matches.
|
|
170
|
+
*
|
|
171
|
+
* @param mountPath - The mount path to check
|
|
172
|
+
* @param newConfig - The new config to compare against the stored config
|
|
173
|
+
* @returns 'not_mounted' | 'matching' | 'mismatched'
|
|
174
|
+
*/
|
|
175
|
+
private checkExistingMount;
|
|
176
|
+
/**
|
|
177
|
+
* Start the E2B sandbox.
|
|
178
|
+
* Handles template preparation, existing sandbox reconnection, and new sandbox creation.
|
|
179
|
+
*
|
|
180
|
+
* Status management and mount processing are handled by the base class.
|
|
181
|
+
*/
|
|
182
|
+
start(): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Build the default mountable template (bypasses exists check).
|
|
185
|
+
*/
|
|
186
|
+
private buildDefaultTemplate;
|
|
187
|
+
/**
|
|
188
|
+
* Resolve the template specification to a template ID.
|
|
189
|
+
*
|
|
190
|
+
* - String: Use as-is (template ID)
|
|
191
|
+
* - TemplateBuilder: Build and return the template ID
|
|
192
|
+
* - Function: Apply to base mountable template, then build
|
|
193
|
+
* - undefined: Use default mountable template (cached)
|
|
194
|
+
*/
|
|
195
|
+
private resolveTemplate;
|
|
196
|
+
/**
|
|
197
|
+
* Find an existing sandbox with matching mastra-sandbox-id metadata.
|
|
198
|
+
* Returns the connected sandbox if found, null otherwise.
|
|
199
|
+
*/
|
|
200
|
+
private findExistingSandbox;
|
|
201
|
+
/**
|
|
202
|
+
* Stop the E2B sandbox.
|
|
203
|
+
* Unmounts all filesystems and releases the sandbox reference.
|
|
204
|
+
* Status management is handled by the base class.
|
|
205
|
+
*/
|
|
206
|
+
stop(): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Destroy the E2B sandbox and clean up all resources.
|
|
209
|
+
* Unmounts filesystems, kills the sandbox, and clears mount state.
|
|
210
|
+
* Status management is handled by the base class.
|
|
211
|
+
*/
|
|
212
|
+
destroy(): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Check if the sandbox is ready for operations.
|
|
215
|
+
*/
|
|
216
|
+
isReady(): Promise<boolean>;
|
|
217
|
+
/**
|
|
218
|
+
* Get information about the current state of the sandbox.
|
|
219
|
+
*/
|
|
220
|
+
getInfo(): Promise<SandboxInfo>;
|
|
221
|
+
/**
|
|
222
|
+
* Get instructions describing this E2B sandbox.
|
|
223
|
+
* Used by agents to understand the execution environment.
|
|
224
|
+
*/
|
|
225
|
+
getInstructions(): string;
|
|
226
|
+
/**
|
|
227
|
+
* Ensure the sandbox is started and return the E2B Sandbox instance.
|
|
228
|
+
* Uses base class ensureRunning() for status management and error handling.
|
|
229
|
+
* @throws {SandboxNotReadyError} if sandbox fails to start
|
|
230
|
+
*/
|
|
231
|
+
private ensureSandbox;
|
|
232
|
+
/**
|
|
233
|
+
* Check if an error indicates the sandbox itself is dead/gone.
|
|
234
|
+
* Does NOT include code execution timeouts (those are the user's code taking too long).
|
|
235
|
+
* Does NOT include "port is not open" - that needs sandbox kill, not reconnect.
|
|
236
|
+
*/
|
|
237
|
+
private isSandboxDeadError;
|
|
238
|
+
/**
|
|
239
|
+
* Handle sandbox timeout by clearing the instance and resetting state.
|
|
240
|
+
*
|
|
241
|
+
* Bypasses the normal stop() lifecycle because the sandbox is already dead —
|
|
242
|
+
* we can't unmount filesystems or run cleanup commands. Instead we reset
|
|
243
|
+
* mount states to 'pending' so they get re-mounted when start() runs again.
|
|
244
|
+
*/
|
|
245
|
+
private handleSandboxTimeout;
|
|
246
|
+
/**
|
|
247
|
+
* Execute a shell command in the sandbox.
|
|
248
|
+
* Automatically starts the sandbox if not already running.
|
|
249
|
+
* Retries once if the sandbox is found to be dead.
|
|
250
|
+
*/
|
|
251
|
+
executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult>;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,WAAW,EAEX,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAY,MAAM,KAAK,CAAC;AAKxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAsBtD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,GAAG,CAAC;AAExG;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IACvG,kDAAkD;IAClD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO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mastra/core/workspace';
|
|
2
|
+
import type { MountContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* GCS mount config for E2B (mounted via gcsfuse).
|
|
5
|
+
*
|
|
6
|
+
* If credentials are not provided, the bucket will be mounted as read-only
|
|
7
|
+
* using anonymous access (for public buckets only).
|
|
8
|
+
*/
|
|
9
|
+
export interface E2BGCSMountConfig extends FilesystemMountConfig {
|
|
10
|
+
type: 'gcs';
|
|
11
|
+
/** GCS bucket name */
|
|
12
|
+
bucket: string;
|
|
13
|
+
/** Service account key JSON (optional - omit for public buckets) */
|
|
14
|
+
serviceAccountKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Mount a GCS bucket using gcsfuse.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mountGCS(mountPath: string, config: E2BGCSMountConfig, ctx: MountContext): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=gcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcs.d.ts","sourceRoot":"","sources":["../../../src/sandbox/mounts/gcs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,IAAI,EAAE,KAAK,CAAC;IACZ,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyE7G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sandbox/mounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC;AACrB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FilesystemMountConfig } from '@mastra/core/workspace';
|
|
2
|
+
import type { MountContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* S3 mount config for E2B (mounted via s3fs-fuse).
|
|
5
|
+
*
|
|
6
|
+
* If credentials are not provided, the bucket will be mounted as read-only
|
|
7
|
+
* using the `public_bucket=1` option (for public AWS S3 buckets only).
|
|
8
|
+
*
|
|
9
|
+
* Note: S3-compatible services (R2, MinIO, etc.) always require credentials.
|
|
10
|
+
*/
|
|
11
|
+
export interface E2BS3MountConfig extends FilesystemMountConfig {
|
|
12
|
+
type: 's3';
|
|
13
|
+
/** S3 bucket name */
|
|
14
|
+
bucket: string;
|
|
15
|
+
/** AWS region */
|
|
16
|
+
region: string;
|
|
17
|
+
/** S3 endpoint for S3-compatible storage (MinIO, etc.) */
|
|
18
|
+
endpoint?: string;
|
|
19
|
+
/** AWS access key ID (optional - omit for public buckets) */
|
|
20
|
+
accessKeyId?: string;
|
|
21
|
+
/** AWS secret access key (optional - omit for public buckets) */
|
|
22
|
+
secretAccessKey?: string;
|
|
23
|
+
/** Mount as read-only (even if credentials have write access) */
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Mount an S3 bucket using s3fs-fuse.
|
|
28
|
+
*/
|
|
29
|
+
export declare function mountS3(mountPath: string, config: E2BS3MountConfig, ctx: MountContext): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=s3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../src/sandbox/mounts/s3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAiB,SAAQ,qBAAqB;IAC7D,IAAI,EAAE,IAAI,CAAC;IACX,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkH3G"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for E2B mount operations.
|
|
3
|
+
*/
|
|
4
|
+
import type { Sandbox } from 'e2b';
|
|
5
|
+
export declare const LOG_PREFIX = "[@mastra/e2b]";
|
|
6
|
+
import type { E2BGCSMountConfig } from './gcs.js';
|
|
7
|
+
import type { E2BS3MountConfig } from './s3.js';
|
|
8
|
+
/**
|
|
9
|
+
* Union of mount configs supported by E2B sandbox.
|
|
10
|
+
*/
|
|
11
|
+
export type E2BMountConfig = E2BS3MountConfig | E2BGCSMountConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Context for mount operations.
|
|
14
|
+
*/
|
|
15
|
+
export interface MountContext {
|
|
16
|
+
sandbox: Sandbox;
|
|
17
|
+
logger: {
|
|
18
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
19
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
20
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
21
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of a mount operation.
|
|
26
|
+
*/
|
|
27
|
+
export interface MountOperationResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function validateBucketName(bucket: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Validate an endpoint URL before interpolating into shell commands.
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateEndpoint(endpoint: string): void;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sandbox/mounts/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QACrD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QACpD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QACpD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;KACtD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMvD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell-quote a single argument for safe use in a command string.
|
|
3
|
+
*
|
|
4
|
+
* Arguments containing only safe characters are returned as-is.
|
|
5
|
+
* All others are wrapped in single quotes with embedded single quotes escaped.
|
|
6
|
+
*/
|
|
7
|
+
export declare function shellQuote(arg: string): string;
|
|
8
|
+
//# sourceMappingURL=shell-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-quote.d.ts","sourceRoot":"","sources":["../../src/utils/shell-quote.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C"}
|