@computesdk/e2b 1.7.37 → 1.7.39
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 +94 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var e2b = (0, import_provider.defineProvider)({
|
|
|
42
42
|
`Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
-
const timeout = config.timeout
|
|
45
|
+
const timeout = options?.timeout ?? config.timeout ?? 3e5;
|
|
46
46
|
try {
|
|
47
47
|
let sandbox;
|
|
48
48
|
let sandboxId;
|
|
@@ -53,20 +53,34 @@ var e2b = (0, import_provider.defineProvider)({
|
|
|
53
53
|
});
|
|
54
54
|
sandboxId = options.sandboxId;
|
|
55
55
|
} else {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
const {
|
|
57
|
+
runtime: _runtime,
|
|
58
|
+
timeout: _timeout,
|
|
59
|
+
envs,
|
|
60
|
+
name: _name,
|
|
61
|
+
metadata,
|
|
62
|
+
templateId,
|
|
63
|
+
snapshotId,
|
|
64
|
+
sandboxId: _sandboxId,
|
|
65
|
+
namespace: _namespace,
|
|
66
|
+
directory: _directory,
|
|
67
|
+
overlays: _overlays,
|
|
68
|
+
servers: _servers,
|
|
69
|
+
...providerOptions
|
|
70
|
+
} = options || {};
|
|
71
|
+
const createOpts = {
|
|
72
|
+
apiKey,
|
|
73
|
+
timeoutMs: timeout,
|
|
74
|
+
envs,
|
|
75
|
+
metadata,
|
|
76
|
+
...providerOptions
|
|
77
|
+
// Spread provider-specific options (e.g., domain)
|
|
78
|
+
};
|
|
79
|
+
const templateOrSnapshot = templateId || snapshotId;
|
|
80
|
+
if (templateOrSnapshot) {
|
|
81
|
+
sandbox = await import_e2b.Sandbox.create(templateOrSnapshot, createOpts);
|
|
63
82
|
} else {
|
|
64
|
-
sandbox = await import_e2b.Sandbox.create(
|
|
65
|
-
apiKey,
|
|
66
|
-
timeoutMs: timeout,
|
|
67
|
-
domain: options?.domain,
|
|
68
|
-
envs: options?.envs
|
|
69
|
-
});
|
|
83
|
+
sandbox = await import_e2b.Sandbox.create(createOpts);
|
|
70
84
|
}
|
|
71
85
|
sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;
|
|
72
86
|
}
|
|
@@ -265,6 +279,72 @@ var e2b = (0, import_provider.defineProvider)({
|
|
|
265
279
|
getInstance: (sandbox) => {
|
|
266
280
|
return sandbox;
|
|
267
281
|
}
|
|
282
|
+
},
|
|
283
|
+
snapshot: {
|
|
284
|
+
create: async (config, sandboxId, options) => {
|
|
285
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
286
|
+
try {
|
|
287
|
+
const sandbox = await import_e2b.Sandbox.connect(sandboxId, { apiKey });
|
|
288
|
+
const snapshotResult = await sandbox.createSnapshot({
|
|
289
|
+
name: options?.name
|
|
290
|
+
});
|
|
291
|
+
const snapshotId = typeof snapshotResult === "string" ? snapshotResult : snapshotResult.id || snapshotResult.templateId;
|
|
292
|
+
return {
|
|
293
|
+
id: snapshotId,
|
|
294
|
+
provider: "e2b",
|
|
295
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
296
|
+
metadata: {
|
|
297
|
+
name: options?.name
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
} catch (error) {
|
|
301
|
+
throw new Error(`Failed to create E2B snapshot: ${error instanceof Error ? error.message : String(error)}`);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
list: async (config) => {
|
|
305
|
+
try {
|
|
306
|
+
if (typeof import_e2b.Sandbox.listTemplates === "function") {
|
|
307
|
+
return await import_e2b.Sandbox.listTemplates({ apiKey: config.apiKey || process.env.E2B_API_KEY });
|
|
308
|
+
}
|
|
309
|
+
return [];
|
|
310
|
+
} catch (error) {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
delete: async (config, snapshotId) => {
|
|
315
|
+
try {
|
|
316
|
+
if (typeof import_e2b.Sandbox.deleteTemplate === "function") {
|
|
317
|
+
await import_e2b.Sandbox.deleteTemplate(snapshotId, { apiKey: config.apiKey || process.env.E2B_API_KEY });
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
// In E2B, Snapshots create Templates. They are interchangeable concepts for spawning.
|
|
324
|
+
template: {
|
|
325
|
+
create: async (config, options) => {
|
|
326
|
+
throw new Error("To create a template in E2B, create a snapshot from a running sandbox using snapshot.create(), or use the E2B CLI to build from a Dockerfile.");
|
|
327
|
+
},
|
|
328
|
+
list: async (config) => {
|
|
329
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
330
|
+
try {
|
|
331
|
+
if (typeof import_e2b.Sandbox.listTemplates === "function") {
|
|
332
|
+
return await import_e2b.Sandbox.listTemplates({ apiKey });
|
|
333
|
+
}
|
|
334
|
+
return [];
|
|
335
|
+
} catch (error) {
|
|
336
|
+
return [];
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
delete: async (config, templateId) => {
|
|
340
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
341
|
+
try {
|
|
342
|
+
if (typeof import_e2b.Sandbox.deleteTemplate === "function") {
|
|
343
|
+
await import_e2b.Sandbox.deleteTemplate(templateId, { apiKey });
|
|
344
|
+
}
|
|
345
|
+
} catch (error) {
|
|
346
|
+
}
|
|
347
|
+
}
|
|
268
348
|
}
|
|
269
349
|
}
|
|
270
350
|
});
|
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 { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 = defineProvider<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 envs: options?.envs,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n envs: options?.envs,\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<CodeResult> => {\n try {\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 code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n const result = effectiveRuntime === 'python'\n ? await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`)\n : await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n\n // Check for syntax errors and throw them\n if (result.exitCode !== 0 && result.stderr) {\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 // Combine stdout and stderr for output\n const output = result.stderr\n ? `${result.stdout}${result.stdout && result.stderr ? '\\n' : ''}${result.stderr}`\n : result.stdout;\n\n return {\n output,\n exitCode: result.exitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Handle E2B's CommandExitError\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n if (actualStderr.includes('SyntaxError')) {\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 }\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: runtime || 'node'\n };\n }\n\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, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options (E2B doesn't support these natively, so we wrap with shell)\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // E2B throws errors for non-zero exit codes\n // Extract the actual result from the error if available\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exitCode || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\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 type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n size: entry.size || 0,\n modified: 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\n// Export E2B sandbox type for explicit typing\nexport type { Sandbox as E2BSandbox } from 'e2b';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAsC;AACtC,sBAA+C;AAqBxC,IAAM,UAAM,gCAAsC;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;AAE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BAAM,IAAI;AAAA,YACR,mCAAmC,QAAQ,IAAI,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,UAC5G;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAGA,YAAY;AAAA,QACV,UAAU,OAAO,SAAqB,SAAkC;AACtE,iBAAO,MAAM,QAAQ,MAAM,KAAK,IAAI;AAAA,QACtC;AAAA,QAEA,WAAW,OAAO,SAAqB,MAAc,YAAmC;AACtF,gBAAM,QAAQ,MAAM,MAAM,MAAM,OAAO;AAAA,QACzC;AAAA,QAEA,OAAO,OAAO,SAAqB,SAAgC;AACjE,gBAAM,QAAQ,MAAM,QAAQ,IAAI;AAAA,QAClC;AAAA,QAEA,SAAS,OAAO,SAAqB,SAAuC;AAC1E,gBAAM,UAAU,MAAM,QAAQ,MAAM,KAAK,IAAI;AAE7C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAO,MAAM,SAAS,MAAM,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ;AAAA,YACpB,UAAU,IAAI,KAAK,MAAM,gBAAgB,KAAK,IAAI,CAAC;AAAA,UACrD,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 { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 = defineProvider<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 // options.timeout takes precedence over config.timeout\n const timeout = options?.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 // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name: _name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n overlays: _overlays,\n servers: _servers,\n ...providerOptions\n } = options || {};\n\n // Build create options, spreading provider-specific options (e.g., domain)\n const createOpts: Record<string, any> = {\n apiKey: apiKey,\n timeoutMs: timeout,\n envs,\n metadata,\n ...providerOptions, // Spread provider-specific options (e.g., domain)\n };\n\n // Create new E2B session\n // E2B supports both templateId and snapshotId (snapshotId maps to template)\n const templateOrSnapshot = templateId || snapshotId;\n if (templateOrSnapshot) {\n sandbox = await E2BSandbox.create(templateOrSnapshot, createOpts);\n } else {\n sandbox = await E2BSandbox.create(createOpts);\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<CodeResult> => {\n try {\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 code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n const result = effectiveRuntime === 'python'\n ? await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`)\n : await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n\n // Check for syntax errors and throw them\n if (result.exitCode !== 0 && result.stderr) {\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 // Combine stdout and stderr for output\n const output = result.stderr\n ? `${result.stdout}${result.stdout && result.stderr ? '\\n' : ''}${result.stderr}`\n : result.stdout;\n\n return {\n output,\n exitCode: result.exitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Handle E2B's CommandExitError\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n if (actualStderr.includes('SyntaxError')) {\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 }\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: runtime || 'node'\n };\n }\n\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, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options (E2B doesn't support these natively, so we wrap with shell)\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // E2B throws errors for non-zero exit codes\n // Extract the actual result from the error if available\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exitCode || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\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 type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n size: entry.size || 0,\n modified: 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 snapshot: {\n create: async (config: E2BConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n \n try {\n // Reconnect to the sandbox to snapshot it\n const sandbox = await E2BSandbox.connect(sandboxId, { apiKey });\n \n // Note: createSnapshot is a feature referenced in E2B docs for saving running state\n // It typically returns a template ID that can be used to spawn new sandboxes\n // We cast to any to avoid type issues if the installed SDK version is slightly older\n // but the feature is available on the API\n const snapshotResult = await (sandbox as any).createSnapshot({\n name: options?.name\n });\n\n // Handle different potential return shapes (ID string or object with ID)\n const snapshotId = typeof snapshotResult === 'string' ? snapshotResult : snapshotResult.id || snapshotResult.templateId;\n\n return {\n id: snapshotId,\n provider: 'e2b',\n createdAt: new Date(),\n metadata: {\n name: options?.name\n }\n };\n } catch (error) {\n throw new Error(`Failed to create E2B snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: E2BConfig) => {\n // Listing snapshots in E2B is effectively listing templates\n // since snapshots create templates\n try {\n // Attempt to list templates/snapshots via SDK static method if available\n // or return empty if not supported in this SDK version\n if (typeof (E2BSandbox as any).listTemplates === 'function') {\n return await (E2BSandbox as any).listTemplates({ apiKey: config.apiKey || process.env.E2B_API_KEY });\n }\n return [];\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: E2BConfig, snapshotId: string) => {\n try {\n // Attempt to delete template/snapshot\n if (typeof (E2BSandbox as any).deleteTemplate === 'function') {\n await (E2BSandbox as any).deleteTemplate(snapshotId, { apiKey: config.apiKey || process.env.E2B_API_KEY });\n }\n } catch (error) {\n // Ignore\n }\n }\n },\n\n // In E2B, Snapshots create Templates. They are interchangeable concepts for spawning.\n template: {\n create: async (config: E2BConfig, options: { name: string }) => {\n throw new Error('To create a template in E2B, create a snapshot from a running sandbox using snapshot.create(), or use the E2B CLI to build from a Dockerfile.');\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n try {\n if (typeof (E2BSandbox as any).listTemplates === 'function') {\n return await (E2BSandbox as any).listTemplates({ apiKey });\n }\n return [];\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: E2BConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n try {\n if (typeof (E2BSandbox as any).deleteTemplate === 'function') {\n await (E2BSandbox as any).deleteTemplate(templateId, { apiKey });\n }\n } catch (error) {\n // Ignore\n }\n }\n }\n }\n});\n\n// Export E2B sandbox type for explicit typing\nexport type { Sandbox as E2BSandbox } from 'e2b';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,iBAAsC;AACtC,sBAA+C;AAqBxC,IAAM,UAAM,gCAAsC;AAAA,EACvD,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAA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b_'. Check your E2B_API_KEY environment variable.`
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
const timeout = config.timeout
|
|
21
|
+
const timeout = options?.timeout ?? config.timeout ?? 3e5;
|
|
22
22
|
try {
|
|
23
23
|
let sandbox;
|
|
24
24
|
let sandboxId;
|
|
@@ -29,20 +29,34 @@ var e2b = defineProvider({
|
|
|
29
29
|
});
|
|
30
30
|
sandboxId = options.sandboxId;
|
|
31
31
|
} else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const {
|
|
33
|
+
runtime: _runtime,
|
|
34
|
+
timeout: _timeout,
|
|
35
|
+
envs,
|
|
36
|
+
name: _name,
|
|
37
|
+
metadata,
|
|
38
|
+
templateId,
|
|
39
|
+
snapshotId,
|
|
40
|
+
sandboxId: _sandboxId,
|
|
41
|
+
namespace: _namespace,
|
|
42
|
+
directory: _directory,
|
|
43
|
+
overlays: _overlays,
|
|
44
|
+
servers: _servers,
|
|
45
|
+
...providerOptions
|
|
46
|
+
} = options || {};
|
|
47
|
+
const createOpts = {
|
|
48
|
+
apiKey,
|
|
49
|
+
timeoutMs: timeout,
|
|
50
|
+
envs,
|
|
51
|
+
metadata,
|
|
52
|
+
...providerOptions
|
|
53
|
+
// Spread provider-specific options (e.g., domain)
|
|
54
|
+
};
|
|
55
|
+
const templateOrSnapshot = templateId || snapshotId;
|
|
56
|
+
if (templateOrSnapshot) {
|
|
57
|
+
sandbox = await E2BSandbox.create(templateOrSnapshot, createOpts);
|
|
39
58
|
} else {
|
|
40
|
-
sandbox = await E2BSandbox.create(
|
|
41
|
-
apiKey,
|
|
42
|
-
timeoutMs: timeout,
|
|
43
|
-
domain: options?.domain,
|
|
44
|
-
envs: options?.envs
|
|
45
|
-
});
|
|
59
|
+
sandbox = await E2BSandbox.create(createOpts);
|
|
46
60
|
}
|
|
47
61
|
sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;
|
|
48
62
|
}
|
|
@@ -241,6 +255,72 @@ var e2b = defineProvider({
|
|
|
241
255
|
getInstance: (sandbox) => {
|
|
242
256
|
return sandbox;
|
|
243
257
|
}
|
|
258
|
+
},
|
|
259
|
+
snapshot: {
|
|
260
|
+
create: async (config, sandboxId, options) => {
|
|
261
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
262
|
+
try {
|
|
263
|
+
const sandbox = await E2BSandbox.connect(sandboxId, { apiKey });
|
|
264
|
+
const snapshotResult = await sandbox.createSnapshot({
|
|
265
|
+
name: options?.name
|
|
266
|
+
});
|
|
267
|
+
const snapshotId = typeof snapshotResult === "string" ? snapshotResult : snapshotResult.id || snapshotResult.templateId;
|
|
268
|
+
return {
|
|
269
|
+
id: snapshotId,
|
|
270
|
+
provider: "e2b",
|
|
271
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
272
|
+
metadata: {
|
|
273
|
+
name: options?.name
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
} catch (error) {
|
|
277
|
+
throw new Error(`Failed to create E2B snapshot: ${error instanceof Error ? error.message : String(error)}`);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
list: async (config) => {
|
|
281
|
+
try {
|
|
282
|
+
if (typeof E2BSandbox.listTemplates === "function") {
|
|
283
|
+
return await E2BSandbox.listTemplates({ apiKey: config.apiKey || process.env.E2B_API_KEY });
|
|
284
|
+
}
|
|
285
|
+
return [];
|
|
286
|
+
} catch (error) {
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
delete: async (config, snapshotId) => {
|
|
291
|
+
try {
|
|
292
|
+
if (typeof E2BSandbox.deleteTemplate === "function") {
|
|
293
|
+
await E2BSandbox.deleteTemplate(snapshotId, { apiKey: config.apiKey || process.env.E2B_API_KEY });
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
// In E2B, Snapshots create Templates. They are interchangeable concepts for spawning.
|
|
300
|
+
template: {
|
|
301
|
+
create: async (config, options) => {
|
|
302
|
+
throw new Error("To create a template in E2B, create a snapshot from a running sandbox using snapshot.create(), or use the E2B CLI to build from a Dockerfile.");
|
|
303
|
+
},
|
|
304
|
+
list: async (config) => {
|
|
305
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
306
|
+
try {
|
|
307
|
+
if (typeof E2BSandbox.listTemplates === "function") {
|
|
308
|
+
return await E2BSandbox.listTemplates({ apiKey });
|
|
309
|
+
}
|
|
310
|
+
return [];
|
|
311
|
+
} catch (error) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
delete: async (config, templateId) => {
|
|
316
|
+
const apiKey = config.apiKey || process.env.E2B_API_KEY;
|
|
317
|
+
try {
|
|
318
|
+
if (typeof E2BSandbox.deleteTemplate === "function") {
|
|
319
|
+
await E2BSandbox.deleteTemplate(templateId, { apiKey });
|
|
320
|
+
}
|
|
321
|
+
} catch (error) {
|
|
322
|
+
}
|
|
323
|
+
}
|
|
244
324
|
}
|
|
245
325
|
}
|
|
246
326
|
});
|
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 { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 = defineProvider<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 envs: options?.envs,\n });\n } else {\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\n domain: options?.domain,\n envs: options?.envs,\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<CodeResult> => {\n try {\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 code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n const result = effectiveRuntime === 'python'\n ? await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`)\n : await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n\n // Check for syntax errors and throw them\n if (result.exitCode !== 0 && result.stderr) {\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 // Combine stdout and stderr for output\n const output = result.stderr\n ? `${result.stdout}${result.stdout && result.stderr ? '\\n' : ''}${result.stderr}`\n : result.stdout;\n\n return {\n output,\n exitCode: result.exitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Handle E2B's CommandExitError\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n if (actualStderr.includes('SyntaxError')) {\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 }\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: runtime || 'node'\n };\n }\n\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, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options (E2B doesn't support these natively, so we wrap with shell)\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // E2B throws errors for non-zero exit codes\n // Extract the actual result from the error if available\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exitCode || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\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 type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n size: entry.size || 0,\n modified: 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\n// Export E2B sandbox type for explicit typing\nexport type { Sandbox as E2BSandbox } from 'e2b';\n"],"mappings":";AAOA,SAAS,WAAW,kBAAkB;AACtC,SAAS,gBAAgB,sBAAsB;AAqBxC,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,SAAS;AAAA,gBACjB,MAAM,SAAS;AAAA,cACjB,CAAC;AAAA,YACH,OAAO;AACL,wBAAU,MAAM,WAAW,OAAO;AAAA,gBAChC;AAAA,gBACA,WAAW;AAAA,gBACX,QAAQ,SAAS;AAAA,gBACjB,MAAM,SAAS;AAAA,cACjB,CAAC;AAAA,YACH;AACA,wBAAY,QAAQ,aAAa,OAAO,KAAK,IAAI,CAAC;AAAA,UACpD;AAEA,iBAAO;AAAA,YACL;AAAA,YACA;AAAA,UACF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qB,SAAuC;AAC1E,gBAAM,UAAU,MAAM,QAAQ,MAAM,KAAK,IAAI;AAE7C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAO,MAAM,SAAS,MAAM,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ;AAAA,YACpB,UAAU,IAAI,KAAK,MAAM,gBAAgB,KAAK,IAAI,CAAC;AAAA,UACrD,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 { defineProvider, escapeShellArg } from '@computesdk/provider';\n\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from '@computesdk/provider';\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 = defineProvider<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 // options.timeout takes precedence over config.timeout\n const timeout = options?.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 // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name: _name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n overlays: _overlays,\n servers: _servers,\n ...providerOptions\n } = options || {};\n\n // Build create options, spreading provider-specific options (e.g., domain)\n const createOpts: Record<string, any> = {\n apiKey: apiKey,\n timeoutMs: timeout,\n envs,\n metadata,\n ...providerOptions, // Spread provider-specific options (e.g., domain)\n };\n\n // Create new E2B session\n // E2B supports both templateId and snapshotId (snapshotId maps to template)\n const templateOrSnapshot = templateId || snapshotId;\n if (templateOrSnapshot) {\n sandbox = await E2BSandbox.create(templateOrSnapshot, createOpts);\n } else {\n sandbox = await E2BSandbox.create(createOpts);\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<CodeResult> => {\n try {\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 code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n const result = effectiveRuntime === 'python'\n ? await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | python3`)\n : await sandbox.commands.run(`echo \"${encoded}\" | base64 -d | node`);\n\n // Check for syntax errors and throw them\n if (result.exitCode !== 0 && result.stderr) {\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 // Combine stdout and stderr for output\n const output = result.stderr\n ? `${result.stdout}${result.stdout && result.stderr ? '\\n' : ''}${result.stderr}`\n : result.stdout;\n\n return {\n output,\n exitCode: result.exitCode,\n language: effectiveRuntime\n };\n } catch (error) {\n // Handle E2B's CommandExitError\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n if (actualStderr.includes('SyntaxError')) {\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 }\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: runtime || 'node'\n };\n }\n\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, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Build command with options (E2B doesn't support these natively, so we wrap with shell)\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await sandbox.commands.run(fullCommand);\n\n return {\n stdout: execution.stdout,\n stderr: execution.stderr,\n exitCode: execution.exitCode,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // E2B throws errors for non-zero exit codes\n // Extract the actual result from the error if available\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exitCode || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\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 type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n size: entry.size || 0,\n modified: 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 snapshot: {\n create: async (config: E2BConfig, sandboxId: string, options?: { name?: string }) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n \n try {\n // Reconnect to the sandbox to snapshot it\n const sandbox = await E2BSandbox.connect(sandboxId, { apiKey });\n \n // Note: createSnapshot is a feature referenced in E2B docs for saving running state\n // It typically returns a template ID that can be used to spawn new sandboxes\n // We cast to any to avoid type issues if the installed SDK version is slightly older\n // but the feature is available on the API\n const snapshotResult = await (sandbox as any).createSnapshot({\n name: options?.name\n });\n\n // Handle different potential return shapes (ID string or object with ID)\n const snapshotId = typeof snapshotResult === 'string' ? snapshotResult : snapshotResult.id || snapshotResult.templateId;\n\n return {\n id: snapshotId,\n provider: 'e2b',\n createdAt: new Date(),\n metadata: {\n name: options?.name\n }\n };\n } catch (error) {\n throw new Error(`Failed to create E2B snapshot: ${error instanceof Error ? error.message : String(error)}`);\n }\n },\n\n list: async (config: E2BConfig) => {\n // Listing snapshots in E2B is effectively listing templates\n // since snapshots create templates\n try {\n // Attempt to list templates/snapshots via SDK static method if available\n // or return empty if not supported in this SDK version\n if (typeof (E2BSandbox as any).listTemplates === 'function') {\n return await (E2BSandbox as any).listTemplates({ apiKey: config.apiKey || process.env.E2B_API_KEY });\n }\n return [];\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: E2BConfig, snapshotId: string) => {\n try {\n // Attempt to delete template/snapshot\n if (typeof (E2BSandbox as any).deleteTemplate === 'function') {\n await (E2BSandbox as any).deleteTemplate(snapshotId, { apiKey: config.apiKey || process.env.E2B_API_KEY });\n }\n } catch (error) {\n // Ignore\n }\n }\n },\n\n // In E2B, Snapshots create Templates. They are interchangeable concepts for spawning.\n template: {\n create: async (config: E2BConfig, options: { name: string }) => {\n throw new Error('To create a template in E2B, create a snapshot from a running sandbox using snapshot.create(), or use the E2B CLI to build from a Dockerfile.');\n },\n\n list: async (config: E2BConfig) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n try {\n if (typeof (E2BSandbox as any).listTemplates === 'function') {\n return await (E2BSandbox as any).listTemplates({ apiKey });\n }\n return [];\n } catch (error) {\n return [];\n }\n },\n\n delete: async (config: E2BConfig, templateId: string) => {\n const apiKey = config.apiKey || process.env.E2B_API_KEY!;\n try {\n if (typeof (E2BSandbox as any).deleteTemplate === 'function') {\n await (E2BSandbox as any).deleteTemplate(templateId, { apiKey });\n }\n } catch (error) {\n // Ignore\n }\n }\n }\n }\n});\n\n// Export E2B sandbox type for explicit typing\nexport type { Sandbox as E2BSandbox } from 'e2b';\n"],"mappings":";AAOA,SAAS,WAAW,kBAAkB;AACtC,SAAS,gBAAgB,sBAAsB;AAqBxC,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;AAIA,cAAM,UAAU,SAAS,WAAW,OAAO,WAAW;AAEtD,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;AAE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AU,QAAQ,IAAI;AAC5C,YAAI;AACD,cAAI,OAAQ,WAAmB,kBAAkB,YAAY;AAC5D,mBAAO,MAAO,WAAmB,cAAc,EAAE,OAAO,CAAC;AAAA,UAC3D;AACA,iBAAO,CAAC;AAAA,QACV,SAAS,OAAO;AACd,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAmB,eAAuB;AACtD,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,YAAI;AACH,cAAI,OAAQ,WAAmB,mBAAmB,YAAY;AAC5D,kBAAO,WAAmB,eAAe,YAAY,EAAE,OAAO,CAAC;AAAA,UACjE;AAAA,QACF,SAAS,OAAO;AAAA,QAEhB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/e2b",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.39",
|
|
4
4
|
"description": "E2B provider for ComputeSDK - cloud sandboxes with full Linux environments, filesystem access, and microVM isolation",
|
|
5
5
|
"author": "Garrison",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"e2b": "^2.12.1",
|
|
22
|
-
"@computesdk/provider": "1.0.
|
|
23
|
-
"computesdk": "2.
|
|
22
|
+
"@computesdk/provider": "1.0.31",
|
|
23
|
+
"computesdk": "2.5.1"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|