@computesdk/e2b 1.4.0 → 1.4.1
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/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -181,10 +181,11 @@ var e2b = (0, import_computesdk.createProvider)({
|
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
|
-
runCommand: async (sandbox, command, args = []) => {
|
|
184
|
+
runCommand: async (sandbox, command, args = [], options) => {
|
|
185
185
|
const startTime = Date.now();
|
|
186
186
|
try {
|
|
187
|
-
const
|
|
187
|
+
const { command: finalCommand, args: finalArgs, isBackground } = (0, import_computesdk.createBackgroundCommand)(command, args, options);
|
|
188
|
+
const fullCommand = finalArgs.length > 0 ? `${finalCommand} ${finalArgs.join(" ")}` : finalCommand;
|
|
188
189
|
const execution = await sandbox.commands.run(fullCommand);
|
|
189
190
|
return {
|
|
190
191
|
stdout: execution.stdout,
|
|
@@ -192,7 +193,10 @@ var e2b = (0, import_computesdk.createProvider)({
|
|
|
192
193
|
exitCode: execution.exitCode,
|
|
193
194
|
executionTime: Date.now() - startTime,
|
|
194
195
|
sandboxId: sandbox.sandboxId || "e2b-unknown",
|
|
195
|
-
provider: "e2b"
|
|
196
|
+
provider: "e2b",
|
|
197
|
+
isBackground,
|
|
198
|
+
// For background commands, we can't get a real PID, but we can indicate it's running
|
|
199
|
+
...isBackground && { pid: -1 }
|
|
196
200
|
};
|
|
197
201
|
} catch (error) {
|
|
198
202
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * E2B Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Sandbox as E2BSandbox } from 'e2b';\nimport { createProvider } from 'computesdk';\nimport type {\n ExecutionResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry\n} from 'computesdk';\n\n/**\n * E2B-specific configuration options\n */\nexport interface E2BConfig {\n /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n\n\n/**\n * Create an E2B provider instance using the factory pattern\n */\nexport const e2b = createProvider<E2BSandbox, E2BConfig>({\n name: 'e2b',\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: E2BConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.E2B_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing E2B API key. Provide 'apiKey' in config or set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n\n // Validate API key format\n if (!apiKey.startsWith('e2b_')) {\n throw new Error(\n `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`\n );\n }\n\n\n const timeout = config.timeout || 300000;\n\n try {\n let sandbox: E2BSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing E2B session\n sandbox = await E2BSandbox.connect(options.sandboxId, {\n apiKey: apiKey,\n domain: options.domain,\n });\n sandboxId = options.sandboxId;\n } else {\n // Create new E2B session\n if (options?.templateId) {\n sandbox = await E2BSandbox.create(options.templateId, {\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options.domain,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n });\n }\n sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `E2B quota exceeded. Please check your usage at https://e2b.dev/`\n );\n }\n }\n throw new Error(\n `Failed to create E2B sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const paginator = E2BSandbox.list({\n apiKey: apiKey,\n });\n // Get first page of results using nextItems\n const items = await paginator.nextItems();\n return items.map((sandbox: any) => ({\n sandbox,\n sandboxId: sandbox.id\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: E2BSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\")\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use runCommand for consistent execution across all providers\n let result;\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n if (effectiveRuntime === 'python') {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (result.exitCode !== 0 && result.stderr) {\n // Check for common syntax error patterns\n if (result.stderr.includes('SyntaxError') ||\n result.stderr.includes('invalid syntax') ||\n result.stderr.includes('Unexpected token') ||\n result.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${result.stderr.trim()}`);\n }\n }\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // Handle E2B's CommandExitError - check if it contains actual error details\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n stdout: '',\n stderr: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: E2BSandbox, command: string, args: string[] = []): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Construct full command with arguments\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n\n // Execute command using E2B's bash execution via Python subprocess\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n },\n\n getInfo: async (sandbox: E2BSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n runtime: 'python', // E2B default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n e2bSessionId: sandbox.sandboxId\n }\n };\n },\n\n getUrl: async (sandbox: E2BSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use E2B's built-in getHost method for accurate host information\n const host = sandbox.getHost(options.port);\n const protocol = options.protocol || 'https';\n return `${protocol}://${host}`;\n } catch (error) {\n throw new Error(\n `Failed to get E2B host for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Optional filesystem methods - E2B has full filesystem support\n filesystem: {\n readFile: async (sandbox: E2BSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n writeFile: async (sandbox: E2BSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n mkdir: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.makeDir(path);\n },\n\n readdir: async (sandbox: E2BSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: Boolean(entry.isDir || entry.isDirectory),\n size: entry.size || 0,\n lastModified: new Date(entry.lastModified || Date.now())\n }));\n },\n\n exists: async (sandbox: E2BSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n remove: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: E2BSandbox): E2BSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAsC;AACtC,wBAA+B;AA0BxB,IAAM,UAAM,kCAAsC;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAmB,YAAmC;AAEnE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,eAAgB;AAEhG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAGA,YAAI,CAAC,OAAO,WAAW,MAAM,GAAG;AAC9B,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAGA,cAAM,UAAU,OAAO,WAAW;AAElC,YAAI;AACF,cAAI;AACJ,cAAI;AAEJ,cAAI,SAAS,WAAW;AAEtB,sBAAU,MAAM,WAAAA,QAAW,QAAQ,QAAQ,WAAW;AAAA,cACpD;AAAA,cACA,QAAQ,QAAQ;AAAA,YAClB,CAAC;AACD,wBAAY,QAAQ;AAAA,UACtB,OAAO;AAEL,gBAAI,SAAS,YAAY;AACvB,wBAAU,MAAM,WAAAA,QAAW,OAAO,QAAQ,YAAY;AAAA,gBACpD;AAAA,gBACA,WAAW;AAAA,gBACX,QAAQ,QAAQ;AAAA,cAClB,CAAC;AAAA,YACH,OAAO;AACL,wBAAU,MAAM,WAAAA,QAAW,OAAO;AAAA,gBAChC;AAAA,gBACA,WAAW;AAAA,gBACX,QAAQ,SAAS;AAAA,cACnB,CAAC;AAAA,YACH;AACA,wBAAY,QAAQ,aAAa,OAAO,KA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AM,SAAS,MAAM,WAAW;AAAA,YACrD,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,IAAI,KAAK,MAAM,gBAAgB,KAAK,IAAI,CAAC;AAAA,UACzD,EAAE;AAAA,QACJ;AAAA,QAEA,QAAQ,OAAO,SAAqB,SAAmC;AACrE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA,QAEA,QAAQ,OAAO,SAAqB,SAAgC;AAClE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoC;AAChD,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":["E2BSandbox"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * E2B Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Sandbox as E2BSandbox } from 'e2b';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type {\n ExecutionResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * E2B-specific configuration options\n */\nexport interface E2BConfig {\n /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n\n\n/**\n * Create an E2B provider instance using the factory pattern\n */\nexport const e2b = createProvider<E2BSandbox, E2BConfig>({\n name: 'e2b',\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: E2BConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.E2B_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing E2B API key. Provide 'apiKey' in config or set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n\n // Validate API key format\n if (!apiKey.startsWith('e2b_')) {\n throw new Error(\n `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`\n );\n }\n\n\n const timeout = config.timeout || 300000;\n\n try {\n let sandbox: E2BSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing E2B session\n sandbox = await E2BSandbox.connect(options.sandboxId, {\n apiKey: apiKey,\n domain: options.domain,\n });\n sandboxId = options.sandboxId;\n } else {\n // Create new E2B session\n if (options?.templateId) {\n sandbox = await E2BSandbox.create(options.templateId, {\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options.domain,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n });\n }\n sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `E2B quota exceeded. Please check your usage at https://e2b.dev/`\n );\n }\n }\n throw new Error(\n `Failed to create E2B sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const paginator = E2BSandbox.list({\n apiKey: apiKey,\n });\n // Get first page of results using nextItems\n const items = await paginator.nextItems();\n return items.map((sandbox: any) => ({\n sandbox,\n sandboxId: sandbox.id\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: E2BSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\")\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use runCommand for consistent execution across all providers\n let result;\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n if (effectiveRuntime === 'python') {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (result.exitCode !== 0 && result.stderr) {\n // Check for common syntax error patterns\n if (result.stderr.includes('SyntaxError') ||\n result.stderr.includes('invalid syntax') ||\n result.stderr.includes('Unexpected token') ||\n result.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${result.stderr.trim()}`);\n }\n }\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // Handle E2B's CommandExitError - check if it contains actual error details\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n stdout: '',\n stderr: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: E2BSandbox, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Handle background command execution\n const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n \n // Construct full command with arguments\n const fullCommand = finalArgs.length > 0 ? `${finalCommand} ${finalArgs.join(' ')}` : finalCommand;\n\n // Execute command using E2B's bash execution via Python subprocess\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n isBackground,\n // For background commands, we can't get a real PID, but we can indicate it's running\n ...(isBackground && { pid: -1 })\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n },\n\n getInfo: async (sandbox: E2BSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n runtime: 'python', // E2B default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n e2bSessionId: sandbox.sandboxId\n }\n };\n },\n\n getUrl: async (sandbox: E2BSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use E2B's built-in getHost method for accurate host information\n const host = sandbox.getHost(options.port);\n const protocol = options.protocol || 'https';\n return `${protocol}://${host}`;\n } catch (error) {\n throw new Error(\n `Failed to get E2B host for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Optional filesystem methods - E2B has full filesystem support\n filesystem: {\n readFile: async (sandbox: E2BSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n writeFile: async (sandbox: E2BSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n mkdir: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.makeDir(path);\n },\n\n readdir: async (sandbox: E2BSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: Boolean(entry.isDir || entry.isDirectory),\n size: entry.size || 0,\n lastModified: new Date(entry.lastModified || Date.now())\n }));\n },\n\n exists: async (sandbox: E2BSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n remove: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: E2BSandbox): E2BSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAsC;AACtC,wBAAwD;AA2BjD,IAAM,UAAM,kCAAsC;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAmB,YAAmC;AA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C;AAClE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoC;AAChD,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":["E2BSandbox"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { Sandbox as E2BSandbox } from "e2b";
|
|
3
|
-
import { createProvider } from "computesdk";
|
|
3
|
+
import { createProvider, createBackgroundCommand } from "computesdk";
|
|
4
4
|
var e2b = createProvider({
|
|
5
5
|
name: "e2b",
|
|
6
6
|
methods: {
|
|
@@ -157,10 +157,11 @@ var e2b = createProvider({
|
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
|
-
runCommand: async (sandbox, command, args = []) => {
|
|
160
|
+
runCommand: async (sandbox, command, args = [], options) => {
|
|
161
161
|
const startTime = Date.now();
|
|
162
162
|
try {
|
|
163
|
-
const
|
|
163
|
+
const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);
|
|
164
|
+
const fullCommand = finalArgs.length > 0 ? `${finalCommand} ${finalArgs.join(" ")}` : finalCommand;
|
|
164
165
|
const execution = await sandbox.commands.run(fullCommand);
|
|
165
166
|
return {
|
|
166
167
|
stdout: execution.stdout,
|
|
@@ -168,7 +169,10 @@ var e2b = createProvider({
|
|
|
168
169
|
exitCode: execution.exitCode,
|
|
169
170
|
executionTime: Date.now() - startTime,
|
|
170
171
|
sandboxId: sandbox.sandboxId || "e2b-unknown",
|
|
171
|
-
provider: "e2b"
|
|
172
|
+
provider: "e2b",
|
|
173
|
+
isBackground,
|
|
174
|
+
// For background commands, we can't get a real PID, but we can indicate it's running
|
|
175
|
+
...isBackground && { pid: -1 }
|
|
172
176
|
};
|
|
173
177
|
} catch (error) {
|
|
174
178
|
return {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * E2B Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Sandbox as E2BSandbox } from 'e2b';\nimport { createProvider } from 'computesdk';\nimport type {\n ExecutionResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry\n} from 'computesdk';\n\n/**\n * E2B-specific configuration options\n */\nexport interface E2BConfig {\n /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n\n\n/**\n * Create an E2B provider instance using the factory pattern\n */\nexport const e2b = createProvider<E2BSandbox, E2BConfig>({\n name: 'e2b',\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: E2BConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.E2B_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing E2B API key. Provide 'apiKey' in config or set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n\n // Validate API key format\n if (!apiKey.startsWith('e2b_')) {\n throw new Error(\n `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`\n );\n }\n\n\n const timeout = config.timeout || 300000;\n\n try {\n let sandbox: E2BSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing E2B session\n sandbox = await E2BSandbox.connect(options.sandboxId, {\n apiKey: apiKey,\n domain: options.domain,\n });\n sandboxId = options.sandboxId;\n } else {\n // Create new E2B session\n if (options?.templateId) {\n sandbox = await E2BSandbox.create(options.templateId, {\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options.domain,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n });\n }\n sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `E2B quota exceeded. Please check your usage at https://e2b.dev/`\n );\n }\n }\n throw new Error(\n `Failed to create E2B sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const paginator = E2BSandbox.list({\n apiKey: apiKey,\n });\n // Get first page of results using nextItems\n const items = await paginator.nextItems();\n return items.map((sandbox: any) => ({\n sandbox,\n sandboxId: sandbox.id\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: E2BSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\")\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use runCommand for consistent execution across all providers\n let result;\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n if (effectiveRuntime === 'python') {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (result.exitCode !== 0 && result.stderr) {\n // Check for common syntax error patterns\n if (result.stderr.includes('SyntaxError') ||\n result.stderr.includes('invalid syntax') ||\n result.stderr.includes('Unexpected token') ||\n result.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${result.stderr.trim()}`);\n }\n }\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // Handle E2B's CommandExitError - check if it contains actual error details\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n stdout: '',\n stderr: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: E2BSandbox, command: string, args: string[] = []): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Construct full command with arguments\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n\n // Execute command using E2B's bash execution via Python subprocess\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n },\n\n getInfo: async (sandbox: E2BSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n runtime: 'python', // E2B default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n e2bSessionId: sandbox.sandboxId\n }\n };\n },\n\n getUrl: async (sandbox: E2BSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use E2B's built-in getHost method for accurate host information\n const host = sandbox.getHost(options.port);\n const protocol = options.protocol || 'https';\n return `${protocol}://${host}`;\n } catch (error) {\n throw new Error(\n `Failed to get E2B host for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Optional filesystem methods - E2B has full filesystem support\n filesystem: {\n readFile: async (sandbox: E2BSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n writeFile: async (sandbox: E2BSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n mkdir: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.makeDir(path);\n },\n\n readdir: async (sandbox: E2BSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: Boolean(entry.isDir || entry.isDirectory),\n size: entry.size || 0,\n lastModified: new Date(entry.lastModified || Date.now())\n }));\n },\n\n exists: async (sandbox: E2BSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n remove: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: E2BSandbox): E2BSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";AAOA,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AA0BxB,IAAM,MAAM,eAAsC;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAmB,YAAmC;AAEnE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,eAAgB;AAEhG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAGA,YAAI,CAAC,OAAO,WAAW,MAAM,GAAG;AAC9B,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAGA,cAAM,UAAU,OAAO,WAAW;AAElC,YAAI;AACF,cAAI;AACJ,cAAI;AAEJ,cAAI,SAAS,WAAW;AAEtB,sBAAU,MAAM,WAAW,QAAQ,QAAQ,WAAW;AAAA,cACpD;AAAA,cACA,QAAQ,QAAQ;AAAA,YAClB,CAAC;AACD,wBAAY,QAAQ;AAAA,UACtB,OAAO;AAEL,gBAAI,SAAS,YAAY;AACvB,wBAAU,MAAM,WAAW,OAAO,QAAQ,YAAY;AAAA,gBACpD;AAAA,gBACA,WAAW;AAAA,gBACX,QAAQ,QAAQ;AAAA,cAClB,CAAC;AAAA,YACH,OAAO;AACL,wBAAU,MAAM,WAAW,OAAO;AAAA,gBAChC;AAA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AgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAM,MAAM;AAAA,YACZ,aAAa,QAAQ,MAAM,SAAS,MAAM,WAAW;AAAA,YACrD,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,IAAI,KAAK,MAAM,gBAAgB,KAAK,IAAI,CAAC;AAAA,UACzD,EAAE;AAAA,QACJ;AAAA,QAEA,QAAQ,OAAO,SAAqB,SAAmC;AACrE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA,QAEA,QAAQ,OAAO,SAAqB,SAAgC;AAClE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoC;AAChD,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * E2B Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Sandbox as E2BSandbox } from 'e2b';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type {\n ExecutionResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * E2B-specific configuration options\n */\nexport interface E2BConfig {\n /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n\n\n/**\n * Create an E2B provider instance using the factory pattern\n */\nexport const e2b = createProvider<E2BSandbox, E2BConfig>({\n name: 'e2b',\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: E2BConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.E2B_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing E2B API key. Provide 'apiKey' in config or set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n\n // Validate API key format\n if (!apiKey.startsWith('e2b_')) {\n throw new Error(\n `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`\n );\n }\n\n\n const timeout = config.timeout || 300000;\n\n try {\n let sandbox: E2BSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Reconnect to existing E2B session\n sandbox = await E2BSandbox.connect(options.sandboxId, {\n apiKey: apiKey,\n domain: options.domain,\n });\n sandboxId = options.sandboxId;\n } else {\n // Create new E2B session\n if (options?.templateId) {\n sandbox = await E2BSandbox.create(options.templateId, {\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options.domain,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n });\n }\n sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `E2B quota exceeded. Please check your usage at https://e2b.dev/`\n );\n }\n }\n throw new Error(\n `Failed to create E2B sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const paginator = E2BSandbox.list({\n apiKey: apiKey,\n });\n // Get first page of results using nextItems\n const items = await paginator.nextItems();\n return items.map((sandbox: any) => ({\n sandbox,\n sandboxId: sandbox.id\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: E2BConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n\n try {\n const sandbox = await E2BSandbox.connect(sandboxId, {\n apiKey: apiKey,\n });\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: E2BSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\")\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use runCommand for consistent execution across all providers\n let result;\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n if (effectiveRuntime === 'python') {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`);\n } else {\n result = await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n }\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (result.exitCode !== 0 && result.stderr) {\n // Check for common syntax error patterns\n if (result.stderr.includes('SyntaxError') ||\n result.stderr.includes('invalid syntax') ||\n result.stderr.includes('Unexpected token') ||\n result.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${result.stderr.trim()}`);\n }\n }\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n } catch (error) {\n // Handle E2B's CommandExitError - check if it contains actual error details\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n stdout: '',\n stderr: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: E2BSandbox, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Handle background command execution\n const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n \n // Construct full command with arguments\n const fullCommand = finalArgs.length > 0 ? `${finalCommand} ${finalArgs.join(' ')}` : finalCommand;\n\n // Execute command using E2B's bash execution via Python subprocess\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n isBackground,\n // For background commands, we can't get a real PID, but we can indicate it's running\n ...(isBackground && { pid: -1 })\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b'\n };\n }\n },\n\n getInfo: async (sandbox: E2BSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.sandboxId || 'e2b-unknown',\n provider: 'e2b',\n runtime: 'python', // E2B default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n e2bSessionId: sandbox.sandboxId\n }\n };\n },\n\n getUrl: async (sandbox: E2BSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use E2B's built-in getHost method for accurate host information\n const host = sandbox.getHost(options.port);\n const protocol = options.protocol || 'https';\n return `${protocol}://${host}`;\n } catch (error) {\n throw new Error(\n `Failed to get E2B host for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n // Optional filesystem methods - E2B has full filesystem support\n filesystem: {\n readFile: async (sandbox: E2BSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n writeFile: async (sandbox: E2BSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n mkdir: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.makeDir(path);\n },\n\n readdir: async (sandbox: E2BSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: Boolean(entry.isDir || entry.isDirectory),\n size: entry.size || 0,\n lastModified: new Date(entry.lastModified || Date.now())\n }));\n },\n\n exists: async (sandbox: E2BSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n remove: async (sandbox: E2BSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: E2BSandbox): E2BSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";AAOA,SAAS,WAAW,kBAAkB;AACtC,SAAS,gBAAgB,+BAA+B;AA2BjD,IAAM,MAAM,eAAsC;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA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C;AAClE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoC;AAChD,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/e2b",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "E2B provider for ComputeSDK",
|
|
5
5
|
"author": "Garrison",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"e2b": "^2.0.1",
|
|
22
|
-
"computesdk": "1.
|
|
22
|
+
"computesdk": "1.5.0"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"e2b",
|