@computesdk/e2b 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,19 +1,20 @@
1
- import { ComputeSpecification, SandboxConfig, Runtime, ExecutionResult, SandboxInfo } from 'computesdk';
1
+ import * as computesdk from 'computesdk';
2
+ import { Runtime } from 'computesdk';
2
3
 
3
- declare class E2BProvider implements ComputeSpecification {
4
- readonly specificationVersion: "v1";
5
- readonly provider = "e2b";
6
- readonly sandboxId: string;
7
- private session;
8
- private readonly apiKey;
9
- private readonly runtime;
10
- private readonly timeout;
11
- constructor(config: SandboxConfig);
12
- private ensureSession;
13
- doExecute(code: string, runtime?: Runtime): Promise<ExecutionResult>;
14
- doKill(): Promise<void>;
15
- doGetInfo(): Promise<SandboxInfo>;
4
+ /**
5
+ * E2B-specific configuration options
6
+ */
7
+ interface E2BConfig {
8
+ /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */
9
+ apiKey?: string;
10
+ /** Default runtime environment */
11
+ runtime?: Runtime;
12
+ /** Execution timeout in milliseconds */
13
+ timeout?: number;
16
14
  }
17
- declare function e2b(config?: Partial<SandboxConfig>): E2BProvider;
15
+ /**
16
+ * Create an E2B provider instance using the factory pattern
17
+ */
18
+ declare const e2b: (config: E2BConfig) => computesdk.Provider;
18
19
 
19
- export { E2BProvider, e2b };
20
+ export { type E2BConfig, e2b };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,20 @@
1
- import { ComputeSpecification, SandboxConfig, Runtime, ExecutionResult, SandboxInfo } from 'computesdk';
1
+ import * as computesdk from 'computesdk';
2
+ import { Runtime } from 'computesdk';
2
3
 
3
- declare class E2BProvider implements ComputeSpecification {
4
- readonly specificationVersion: "v1";
5
- readonly provider = "e2b";
6
- readonly sandboxId: string;
7
- private session;
8
- private readonly apiKey;
9
- private readonly runtime;
10
- private readonly timeout;
11
- constructor(config: SandboxConfig);
12
- private ensureSession;
13
- doExecute(code: string, runtime?: Runtime): Promise<ExecutionResult>;
14
- doKill(): Promise<void>;
15
- doGetInfo(): Promise<SandboxInfo>;
4
+ /**
5
+ * E2B-specific configuration options
6
+ */
7
+ interface E2BConfig {
8
+ /** E2B API key - if not provided, will fallback to E2B_API_KEY environment variable */
9
+ apiKey?: string;
10
+ /** Default runtime environment */
11
+ runtime?: Runtime;
12
+ /** Execution timeout in milliseconds */
13
+ timeout?: number;
16
14
  }
17
- declare function e2b(config?: Partial<SandboxConfig>): E2BProvider;
15
+ /**
16
+ * Create an E2B provider instance using the factory pattern
17
+ */
18
+ declare const e2b: (config: E2BConfig) => computesdk.Provider;
18
19
 
19
- export { E2BProvider, e2b };
20
+ export { type E2BConfig, e2b };
package/dist/index.js CHANGED
@@ -20,130 +20,298 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- E2BProvider: () => E2BProvider,
24
23
  e2b: () => e2b
25
24
  });
26
25
  module.exports = __toCommonJS(index_exports);
27
26
  var import_code_interpreter = require("@e2b/code-interpreter");
28
- var E2BProvider = class {
29
- constructor(config) {
30
- this.specificationVersion = "v1";
31
- this.provider = "e2b";
32
- this.session = null;
33
- this.sandboxId = `e2b-${Date.now()}-${Math.random().toString(36).substring(7)}`;
34
- this.timeout = config.timeout || 3e5;
35
- this.apiKey = process.env.E2B_API_KEY || "";
36
- if (!this.apiKey) {
37
- throw new Error(
38
- `Missing E2B API key. Set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`
39
- );
40
- }
41
- if (!this.apiKey.startsWith("e2b_")) {
42
- throw new Error(
43
- `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`
44
- );
45
- }
46
- this.runtime = config.runtime || "python";
47
- }
48
- async ensureSession() {
49
- if (this.session) {
50
- return this.session;
51
- }
52
- try {
53
- this.session = await import_code_interpreter.Sandbox.create({
54
- apiKey: this.apiKey,
55
- timeoutMs: this.timeout
56
- });
57
- return this.session;
58
- } catch (error) {
59
- if (error instanceof Error) {
60
- if (error.message.includes("unauthorized") || error.message.includes("API key")) {
27
+ var import_computesdk = require("computesdk");
28
+ var e2b = (0, import_computesdk.createProvider)({
29
+ name: "e2b",
30
+ methods: {
31
+ sandbox: {
32
+ // Collection operations (map to compute.sandbox.*)
33
+ create: async (config, options) => {
34
+ const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.E2B_API_KEY || "";
35
+ if (!apiKey) {
61
36
  throw new Error(
62
- `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`
37
+ `Missing E2B API key. Provide 'apiKey' in config or set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`
63
38
  );
64
39
  }
65
- if (error.message.includes("quota") || error.message.includes("limit")) {
40
+ if (!apiKey.startsWith("e2b_")) {
66
41
  throw new Error(
67
- `E2B quota exceeded. Please check your usage at https://e2b.dev/`
42
+ `Invalid E2B API key format. E2B API keys should start with 'e2b_'. Check your E2B_API_KEY environment variable.`
68
43
  );
69
44
  }
70
- }
71
- throw new Error(
72
- `Failed to initialize E2B session: ${error instanceof Error ? error.message : String(error)}`
73
- );
74
- }
75
- }
76
- async doExecute(code, runtime) {
77
- const startTime = Date.now();
78
- try {
79
- const session = await this.ensureSession();
80
- const execution = await session.runCode(code);
81
- return {
82
- stdout: execution.logs.stdout.join("\n"),
83
- stderr: execution.logs.stderr.join("\n"),
84
- exitCode: execution.error ? 1 : 0,
85
- executionTime: Date.now() - startTime,
86
- sandboxId: this.sandboxId,
87
- provider: this.provider
88
- };
89
- } catch (error) {
90
- if (error instanceof Error) {
91
- if (error.message.includes("timeout")) {
45
+ const timeout = config.timeout || 3e5;
46
+ try {
47
+ let sandbox;
48
+ let sandboxId;
49
+ if (options?.sandboxId) {
50
+ sandbox = await import_code_interpreter.Sandbox.connect(options.sandboxId, {
51
+ apiKey
52
+ });
53
+ sandboxId = options.sandboxId;
54
+ } else {
55
+ sandbox = await import_code_interpreter.Sandbox.create({
56
+ apiKey,
57
+ timeoutMs: timeout
58
+ });
59
+ sandboxId = sandbox.sandboxId || `e2b-${Date.now()}`;
60
+ }
61
+ return {
62
+ sandbox,
63
+ sandboxId
64
+ };
65
+ } catch (error) {
66
+ if (error instanceof Error) {
67
+ if (error.message.includes("unauthorized") || error.message.includes("API key")) {
68
+ throw new Error(
69
+ `E2B authentication failed. Please check your E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`
70
+ );
71
+ }
72
+ if (error.message.includes("quota") || error.message.includes("limit")) {
73
+ throw new Error(
74
+ `E2B quota exceeded. Please check your usage at https://e2b.dev/`
75
+ );
76
+ }
77
+ }
92
78
  throw new Error(
93
- `E2B execution timeout (${this.timeout}ms). Consider increasing the timeout or optimizing your code.`
79
+ `Failed to create E2B sandbox: ${error instanceof Error ? error.message : String(error)}`
94
80
  );
95
81
  }
96
- if (error.message.includes("memory") || error.message.includes("Memory")) {
82
+ },
83
+ getById: async (config, sandboxId) => {
84
+ const apiKey = config.apiKey || process.env.E2B_API_KEY;
85
+ try {
86
+ const sandbox = await import_code_interpreter.Sandbox.connect(sandboxId, {
87
+ apiKey
88
+ });
89
+ return {
90
+ sandbox,
91
+ sandboxId
92
+ };
93
+ } catch (error) {
94
+ return null;
95
+ }
96
+ },
97
+ list: async (_config) => {
98
+ throw new Error(
99
+ `E2B provider does not support listing sandboxes. E2B sandboxes are managed individually and don't have a native list API. Consider using a provider with persistent sandbox management or implement your own tracking system.`
100
+ );
101
+ },
102
+ destroy: async (config, sandboxId) => {
103
+ const apiKey = config.apiKey || process.env.E2B_API_KEY;
104
+ try {
105
+ const sandbox = await import_code_interpreter.Sandbox.connect(sandboxId, {
106
+ apiKey
107
+ });
108
+ await sandbox.kill();
109
+ } catch (error) {
110
+ }
111
+ },
112
+ // Instance operations (map to individual Sandbox methods)
113
+ runCode: async (sandbox, code, runtime) => {
114
+ const startTime = Date.now();
115
+ try {
116
+ const effectiveRuntime = runtime || // Strong Python indicators
117
+ (code.includes("print(") || code.includes("import ") || code.includes("def ") || code.includes("sys.") || code.includes("json.") || code.includes("__") || code.includes('f"') || code.includes("f'") ? "python" : "node");
118
+ let result;
119
+ const encoded = Buffer.from(code).toString("base64");
120
+ if (effectiveRuntime === "python") {
121
+ result = await sandbox.commands.run(`echo "${encoded}" | base64 -d | python3`);
122
+ } else {
123
+ result = await sandbox.commands.run(`echo "${encoded}" | base64 -d | node`);
124
+ }
125
+ if (result.exitCode !== 0 && result.stderr) {
126
+ if (result.stderr.includes("SyntaxError") || result.stderr.includes("invalid syntax") || result.stderr.includes("Unexpected token") || result.stderr.includes("Unexpected identifier")) {
127
+ throw new Error(`Syntax error: ${result.stderr.trim()}`);
128
+ }
129
+ }
130
+ return {
131
+ stdout: result.stdout,
132
+ stderr: result.stderr,
133
+ exitCode: result.exitCode,
134
+ executionTime: Date.now() - startTime,
135
+ sandboxId: sandbox.sandboxId || "e2b-unknown",
136
+ provider: "e2b"
137
+ };
138
+ } catch (error) {
139
+ if (error instanceof Error && error.message === "exit status 1") {
140
+ const actualStderr = error?.result?.stderr || "";
141
+ const isSyntaxError = actualStderr.includes("SyntaxError");
142
+ if (isSyntaxError) {
143
+ const syntaxErrorLine = actualStderr.split("\n").find((line) => line.includes("SyntaxError")) || "SyntaxError: Invalid syntax in code";
144
+ throw new Error(`Syntax error: ${syntaxErrorLine}`);
145
+ } else {
146
+ return {
147
+ stdout: "",
148
+ stderr: actualStderr || "Error: Runtime error occurred during execution",
149
+ exitCode: 1,
150
+ executionTime: Date.now() - startTime,
151
+ sandboxId: sandbox.sandboxId || "e2b-unknown",
152
+ provider: "e2b"
153
+ };
154
+ }
155
+ }
156
+ if (error instanceof Error && error.message.includes("Syntax error")) {
157
+ throw error;
158
+ }
97
159
  throw new Error(
98
- `E2B execution failed due to memory limits. Consider optimizing your code or using smaller data sets.`
160
+ `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`
99
161
  );
100
162
  }
163
+ },
164
+ runCommand: async (sandbox, command, args = []) => {
165
+ const startTime = Date.now();
166
+ try {
167
+ const fullCommand = args.length > 0 ? `${command} ${args.join(" ")}` : command;
168
+ const execution = await sandbox.commands.run(fullCommand);
169
+ return {
170
+ stdout: execution.stdout,
171
+ stderr: execution.stderr,
172
+ exitCode: execution.exitCode,
173
+ executionTime: Date.now() - startTime,
174
+ sandboxId: sandbox.sandboxId || "e2b-unknown",
175
+ provider: "e2b"
176
+ };
177
+ } catch (error) {
178
+ return {
179
+ stdout: "",
180
+ stderr: error instanceof Error ? error.message : String(error),
181
+ exitCode: 127,
182
+ // Command not found exit code
183
+ executionTime: Date.now() - startTime,
184
+ sandboxId: sandbox.sandboxId || "e2b-unknown",
185
+ provider: "e2b"
186
+ };
187
+ }
188
+ },
189
+ getInfo: async (sandbox) => {
190
+ return {
191
+ id: sandbox.sandboxId || "e2b-unknown",
192
+ provider: "e2b",
193
+ runtime: "python",
194
+ // E2B default
195
+ status: "running",
196
+ createdAt: /* @__PURE__ */ new Date(),
197
+ timeout: 3e5,
198
+ metadata: {
199
+ e2bSessionId: sandbox.sandboxId
200
+ }
201
+ };
202
+ },
203
+ // Optional filesystem methods - E2B has full filesystem support
204
+ filesystem: {
205
+ readFile: async (sandbox, path) => {
206
+ return await sandbox.files.read(path);
207
+ },
208
+ writeFile: async (sandbox, path, content) => {
209
+ await sandbox.files.write(path, content);
210
+ },
211
+ mkdir: async (sandbox, path) => {
212
+ await sandbox.files.makeDir(path);
213
+ },
214
+ readdir: async (sandbox, path) => {
215
+ const entries = await sandbox.files.list(path);
216
+ return entries.map((entry) => ({
217
+ name: entry.name,
218
+ path: entry.path,
219
+ isDirectory: Boolean(entry.isDir || entry.isDirectory),
220
+ size: entry.size || 0,
221
+ lastModified: new Date(entry.lastModified || Date.now())
222
+ }));
223
+ },
224
+ exists: async (sandbox, path) => {
225
+ return await sandbox.files.exists(path);
226
+ },
227
+ remove: async (sandbox, path) => {
228
+ await sandbox.files.remove(path);
229
+ }
230
+ },
231
+ // Optional terminal methods - E2B has PTY terminal support
232
+ terminal: {
233
+ create: async (sandbox, options = {}) => {
234
+ const cols = options.cols || 80;
235
+ const rows = options.rows || 24;
236
+ const ptyHandle = await sandbox.pty.create({
237
+ cols,
238
+ rows,
239
+ onData: options.onData || (() => {
240
+ })
241
+ });
242
+ const terminalWrapper = {
243
+ ...ptyHandle,
244
+ onData: options.onData,
245
+ onExit: options.onExit
246
+ };
247
+ return {
248
+ terminal: terminalWrapper,
249
+ terminalId: ptyHandle.pid.toString()
250
+ };
251
+ },
252
+ getById: async (sandbox, terminalId) => {
253
+ try {
254
+ const pid = parseInt(terminalId);
255
+ if (isNaN(pid)) return null;
256
+ const processes = await sandbox.commands.list();
257
+ const ptyProcess = processes.find((p) => p.pid === pid);
258
+ if (!ptyProcess) return null;
259
+ return {
260
+ terminal: { pid: ptyProcess.pid, cmd: ptyProcess.cmd },
261
+ terminalId
262
+ };
263
+ } catch (error) {
264
+ return null;
265
+ }
266
+ },
267
+ list: async (sandbox) => {
268
+ try {
269
+ const processes = await sandbox.commands.list();
270
+ return processes.filter((p) => ["bash", "sh", "zsh", "fish", "pty"].some((term) => p.cmd.includes(term))).map((p) => ({
271
+ terminal: { pid: p.pid, cmd: p.cmd },
272
+ terminalId: p.pid.toString()
273
+ }));
274
+ } catch (error) {
275
+ return [];
276
+ }
277
+ },
278
+ destroy: async (sandbox, terminalId) => {
279
+ const pid = parseInt(terminalId);
280
+ if (isNaN(pid)) {
281
+ throw new Error(`Invalid terminal ID: ${terminalId}. Expected numeric PID.`);
282
+ }
283
+ try {
284
+ await sandbox.pty.kill(pid);
285
+ } catch (error) {
286
+ }
287
+ },
288
+ // Terminal instance methods
289
+ write: async (sandbox, terminal, data) => {
290
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
291
+ if (terminal.pid) {
292
+ await sandbox.pty.sendInput(terminal.pid, bytes);
293
+ } else {
294
+ await sandbox.pty.sendInput(terminal.pid || terminal.id, bytes);
295
+ }
296
+ },
297
+ resize: async (sandbox, terminal, cols, rows) => {
298
+ const pid = terminal.pid || terminal.id;
299
+ await sandbox.pty.resize(pid, { cols, rows });
300
+ },
301
+ kill: async (sandbox, terminal) => {
302
+ const pid = terminal.pid || terminal.id;
303
+ if (terminal.kill) {
304
+ await terminal.kill();
305
+ } else {
306
+ await sandbox.pty.kill(pid);
307
+ }
308
+ }
101
309
  }
102
- throw new Error(
103
- `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`
104
- );
105
- }
106
- }
107
- async doKill() {
108
- if (!this.session) {
109
- return;
110
- }
111
- try {
112
- await this.session.kill();
113
- this.session = null;
114
- } catch (error) {
115
- throw new Error(
116
- `Failed to kill E2B session: ${error instanceof Error ? error.message : String(error)}`
117
- );
118
310
  }
119
311
  }
120
- async doGetInfo() {
121
- await this.ensureSession();
122
- return {
123
- id: this.sandboxId,
124
- provider: this.provider,
125
- runtime: this.runtime,
126
- status: this.session ? "running" : "stopped",
127
- createdAt: /* @__PURE__ */ new Date(),
128
- timeout: this.timeout,
129
- metadata: {
130
- e2bSessionId: this.sandboxId
131
- }
132
- };
133
- }
134
- };
135
- function e2b(config) {
136
- const fullConfig = {
137
- provider: "e2b",
138
- runtime: "python",
139
- timeout: 3e5,
140
- ...config
141
- };
142
- return new E2BProvider(fullConfig);
143
- }
312
+ });
144
313
  // Annotate the CommonJS export names for ESM import in node:
145
314
  0 && (module.exports = {
146
- E2BProvider,
147
315
  e2b
148
316
  });
149
317
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Sandbox as E2BSandbox } from '@e2b/code-interpreter';\nimport type {\n ComputeSpecification,\n ExecutionResult,\n Runtime,\n SandboxInfo,\n SandboxConfig,\n} from 'computesdk';\n\nexport class E2BProvider implements ComputeSpecification {\n public readonly specificationVersion = 'v1' as const;\n public readonly provider = 'e2b';\n public readonly sandboxId: string;\n\n private session: E2BSandbox | null = null;\n private readonly apiKey: string;\n private readonly runtime: Runtime;\n private readonly timeout: number;\n\n constructor(config: SandboxConfig) {\n this.sandboxId = `e2b-${Date.now()}-${Math.random().toString(36).substring(7)}`;\n this.timeout = config.timeout || 300000;\n\n // Get API key from environment\n this.apiKey = process.env.E2B_API_KEY || '';\n\n if (!this.apiKey) {\n throw new Error(\n `Missing E2B API key. Set E2B_API_KEY environment variable. Get your API key from https://e2b.dev/`\n );\n }\n\n // Validate API key format\n if (!this.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 this.runtime = config.runtime || 'python';\n }\n\n private async ensureSession(): Promise<E2BSandbox> {\n if (this.session) {\n return this.session;\n }\n\n try {\n // Create new E2B session with configuration\n this.session = await E2BSandbox.create({\n apiKey: this.apiKey,\n timeoutMs: this.timeout,\n });\n\n return this.session;\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 initialize E2B session: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async doExecute(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n const session = await this.ensureSession();\n\n // Execute code using E2B's runCode API\n const execution = await session.runCode(code);\n\n return {\n stdout: execution.logs.stdout.join('\\n'),\n stderr: execution.logs.stderr.join('\\n'),\n exitCode: execution.error ? 1 : 0,\n executionTime: Date.now() - startTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('timeout')) {\n throw new Error(\n `E2B execution timeout (${this.timeout}ms). Consider increasing the timeout or optimizing your code.`\n );\n }\n if (error.message.includes('memory') || error.message.includes('Memory')) {\n throw new Error(\n `E2B execution failed due to memory limits. Consider optimizing your code or using smaller data sets.`\n );\n }\n }\n throw new Error(\n `E2B execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async doKill(): Promise<void> {\n if (!this.session) {\n return;\n }\n\n try {\n await this.session.kill();\n this.session = null;\n } catch (error) {\n throw new Error(\n `Failed to kill E2B session: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n async doGetInfo(): Promise<SandboxInfo> {\n await this.ensureSession();\n\n return {\n id: this.sandboxId,\n provider: this.provider,\n runtime: this.runtime,\n status: this.session ? 'running' : 'stopped',\n createdAt: new Date(),\n timeout: this.timeout,\n metadata: {\n e2bSessionId: this.sandboxId\n }\n };\n }\n}\n\nexport function e2b(config?: Partial<SandboxConfig>): E2BProvider {\n const fullConfig: SandboxConfig = {\n provider: 'e2b',\n runtime: 'python',\n timeout: 300000,\n ...config\n };\n\n return new E2BProvider(fullConfig);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAsC;AAS/B,IAAM,cAAN,MAAkD;AAAA,EAUvD,YAAY,QAAuB;AATnC,SAAgB,uBAAuB;AACvC,SAAgB,WAAW;AAG3B,SAAQ,UAA6B;AAMnC,SAAK,YAAY,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAC7E,SAAK,UAAU,OAAO,WAAW;AAGjC,SAAK,SAAS,QAAQ,IAAI,eAAe;AAEzC,QAAI,CAAC,KAAK,QAAQ;AAChB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAGA,QAAI,CAAC,KAAK,OAAO,WAAW,MAAM,GAAG;AACnC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,SAAK,UAAU,OAAO,WAAW;AAA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A,YAAI,MAAM,QAAQ,SAAS,QAAQ,KAAK,MAAM,QAAQ,SAAS,QAAQ,GAAG;AACxE,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,YAAM,IAAI;AAAA,QACR,yBAAyB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACjF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,SAAwB;AAC5B,QAAI,CAAC,KAAK,SAAS;AACjB;AAAA,IACF;AAEA,QAAI;AACF,YAAM,KAAK,QAAQ,KAAK;AACxB,WAAK,UAAU;AAAA,IACjB,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,YAAkC;AACtC,UAAM,KAAK,cAAc;AAEzB,WAAO;AAAA,MACL,IAAI,KAAK;AAAA,MACT,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;AAAA,MACd,QAAQ,KAAK,UAAU,YAAY;AAAA,MACnC,WAAW,oBAAI,KAAK;AAAA,MACpB,SAAS,KAAK;AAAA,MACd,UAAU;AAAA,QACR,cAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,IAAI,QAA8C;AAChE,QAAM,aAA4B;AAAA,IAChC,UAAU;AAAA,IACV,SAAS;AAAA,IACT,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAEA,SAAO,IAAI,YAAY,UAAU;AACnC;","names":["E2BSandbox"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * E2B Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem and terminal 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/code-interpreter';\nimport { createProvider } from 'computesdk';\nimport type { \n ExecutionResult, \n SandboxInfo, \n Runtime,\n TerminalCreateOptions,\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 });\n sandboxId = options.sandboxId;\n } else {\n // Create new E2B session\n sandbox = await E2BSandbox.create({\n apiKey: apiKey,\n timeoutMs: timeout,\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 throw new Error(\n `E2B provider does not support listing sandboxes. E2B sandboxes are managed individually and don't have a native list API. Consider using a provider with persistent sandbox management or implement your own tracking system.`\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 // 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 // Optional terminal methods - E2B has PTY terminal support\n terminal: {\n create: async (sandbox: E2BSandbox, options: TerminalCreateOptions = {}) => {\n const cols = options.cols || 80;\n const rows = options.rows || 24;\n\n // Create PTY session using E2B's pty.create\n const ptyHandle = await sandbox.pty.create({ \n cols: cols, \n rows: rows,\n onData: options.onData || (() => {\n // Default no-op if no onData provided\n })\n });\n\n // Create a wrapper object that includes the onData callback\n const terminalWrapper = {\n ...ptyHandle,\n onData: options.onData,\n onExit: options.onExit\n };\n\n return {\n terminal: terminalWrapper,\n terminalId: ptyHandle.pid.toString()\n };\n },\n\n getById: async (sandbox: E2BSandbox, terminalId: string) => {\n try {\n const pid = parseInt(terminalId);\n if (isNaN(pid)) return null;\n\n // List all running processes (includes PTY sessions)\n const processes = await sandbox.commands.list();\n \n // Find PTY process by PID\n const ptyProcess = processes.find(p => p.pid === pid);\n if (!ptyProcess) return null;\n\n return {\n terminal: { pid: ptyProcess.pid, cmd: ptyProcess.cmd },\n terminalId: terminalId\n };\n } catch (error) {\n return null;\n }\n },\n\n list: async (sandbox: E2BSandbox) => {\n try {\n // List all running processes\n const processes = await sandbox.commands.list();\n \n // Filter for PTY sessions and return raw terminal data\n return processes\n .filter(p => ['bash', 'sh', 'zsh', 'fish', 'pty'].some(term => p.cmd.includes(term)))\n .map(p => ({\n terminal: { pid: p.pid, cmd: p.cmd },\n terminalId: p.pid.toString()\n }));\n } catch (error) {\n // If listing fails, return empty array\n return [];\n }\n },\n\n destroy: async (sandbox: E2BSandbox, terminalId: string): Promise<void> => {\n const pid = parseInt(terminalId);\n if (isNaN(pid)) {\n throw new Error(`Invalid terminal ID: ${terminalId}. Expected numeric PID.`);\n }\n\n try {\n await sandbox.pty.kill(pid);\n } catch (error) {\n // Terminal might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Terminal instance methods\n write: async (sandbox: E2BSandbox, terminal: any, data: Uint8Array | string): Promise<void> => {\n const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data;\n if (terminal.pid) {\n // For existing terminals, use PID\n await sandbox.pty.sendInput(terminal.pid, bytes);\n } else {\n // For new terminals, use the ptyHandle directly\n await sandbox.pty.sendInput(terminal.pid || terminal.id, bytes);\n }\n },\n\n resize: async (sandbox: E2BSandbox, terminal: any, cols: number, rows: number): Promise<void> => {\n const pid = terminal.pid || terminal.id;\n await sandbox.pty.resize(pid, { cols, rows });\n },\n\n kill: async (sandbox: E2BSandbox, terminal: any): Promise<void> => {\n const pid = terminal.pid || terminal.id;\n if (terminal.kill) {\n // For ptyHandle objects\n await terminal.kill();\n } else {\n // For process objects\n await sandbox.pty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