@e2b/n8n-nodes-e2b 0.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/credentials/E2BApi.credentials.d.ts +13 -0
  4. package/dist/credentials/E2BApi.credentials.js +58 -0
  5. package/dist/credentials/E2BApi.credentials.js.map +1 -0
  6. package/dist/credentials/e2b.dark.svg +1 -0
  7. package/dist/credentials/e2b.svg +1 -0
  8. package/dist/nodes/E2B/E2b.node.d.ts +5 -0
  9. package/dist/nodes/E2B/E2b.node.js +2901 -0
  10. package/dist/nodes/E2B/E2b.node.js.map +7 -0
  11. package/dist/nodes/E2B/E2b.node.json +20 -0
  12. package/dist/nodes/E2B/actions/code.operations.d.ts +8 -0
  13. package/dist/nodes/E2B/actions/code.operations.js +67 -0
  14. package/dist/nodes/E2B/actions/code.operations.js.map +1 -0
  15. package/dist/nodes/E2B/actions/file.operations.d.ts +95 -0
  16. package/dist/nodes/E2B/actions/file.operations.js +183 -0
  17. package/dist/nodes/E2B/actions/file.operations.js.map +1 -0
  18. package/dist/nodes/E2B/actions/git.operations.d.ts +48 -0
  19. package/dist/nodes/E2B/actions/git.operations.js +554 -0
  20. package/dist/nodes/E2B/actions/git.operations.js.map +1 -0
  21. package/dist/nodes/E2B/actions/index.d.ts +2 -0
  22. package/dist/nodes/E2B/actions/index.js +95 -0
  23. package/dist/nodes/E2B/actions/index.js.map +1 -0
  24. package/dist/nodes/E2B/actions/sandbox.operations.d.ts +48 -0
  25. package/dist/nodes/E2B/actions/sandbox.operations.js +93 -0
  26. package/dist/nodes/E2B/actions/sandbox.operations.js.map +1 -0
  27. package/dist/nodes/E2B/actions/snapshot.operations.d.ts +22 -0
  28. package/dist/nodes/E2B/actions/snapshot.operations.js +46 -0
  29. package/dist/nodes/E2B/actions/snapshot.operations.js.map +1 -0
  30. package/dist/nodes/E2B/actions/volume.operations.d.ts +28 -0
  31. package/dist/nodes/E2B/actions/volume.operations.js +57 -0
  32. package/dist/nodes/E2B/actions/volume.operations.js.map +1 -0
  33. package/dist/nodes/E2B/client.d.ts +97 -0
  34. package/dist/nodes/E2B/client.js +546 -0
  35. package/dist/nodes/E2B/client.js.map +1 -0
  36. package/dist/nodes/E2B/e2b.dark.svg +1 -0
  37. package/dist/nodes/E2B/e2b.svg +1 -0
  38. package/dist/nodes/E2B/helpers.d.ts +22 -0
  39. package/dist/nodes/E2B/helpers.js +224 -0
  40. package/dist/nodes/E2B/helpers.js.map +1 -0
  41. package/dist/nodes/E2B/types.d.ts +21 -0
  42. package/dist/nodes/E2B/types.js +21 -0
  43. package/dist/nodes/E2B/types.js.map +1 -0
  44. package/package.json +70 -0
@@ -0,0 +1,2901 @@
1
+ "use strict";
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __commonJS = (cb, mod) => function __require() {
4
+ try {
5
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
+ } catch (e) {
7
+ throw mod = 0, e;
8
+ }
9
+ };
10
+
11
+ // dist/nodes/E2B/client.js
12
+ var require_client = __commonJS({
13
+ "dist/nodes/E2B/client.js"(exports2) {
14
+ "use strict";
15
+ Object.defineProperty(exports2, "__esModule", { value: true });
16
+ exports2.createSandbox = createSandbox;
17
+ exports2.connectSandbox = connectSandbox;
18
+ exports2.getSandboxInfo = getSandboxInfo;
19
+ exports2.listSandboxes = listSandboxes;
20
+ exports2.killSandbox = killSandbox;
21
+ exports2.pauseSandbox = pauseSandbox;
22
+ exports2.createSnapshot = createSnapshot;
23
+ exports2.listSnapshots = listSnapshots;
24
+ exports2.deleteSnapshot = deleteSnapshot;
25
+ exports2.createVolume = createVolume;
26
+ exports2.getVolume = getVolume;
27
+ exports2.listVolumes = listVolumes;
28
+ exports2.deleteVolume = deleteVolume;
29
+ exports2.getPreviewHost = getPreviewHost;
30
+ exports2.readSandboxFile = readSandboxFile;
31
+ exports2.writeSandboxFile = writeSandboxFile;
32
+ exports2.listSandboxFiles = listSandboxFiles;
33
+ exports2.createSandboxFolder = createSandboxFolder;
34
+ exports2.deleteSandboxFile = deleteSandboxFile;
35
+ exports2.getSandboxFileInfo = getSandboxFileInfo;
36
+ exports2.moveSandboxFile = moveSandboxFile;
37
+ exports2.runSandboxCommand = runSandboxCommand;
38
+ var n8n_workflow_12 = require("n8n-workflow");
39
+ var CREDENTIAL_TYPE = "e2bApi";
40
+ var DEFAULT_DOMAIN = "e2b.app";
41
+ var DEFAULT_API_URL = `https://api.${DEFAULT_DOMAIN}`;
42
+ var DEFAULT_SANDBOX_TIMEOUT_MS = 3e5;
43
+ var ENVD_PORT = 49983;
44
+ var ENVD_DEFAULT_USER = "0.4.0";
45
+ var SUPPORTED_SANDBOX_DOMAINS = /* @__PURE__ */ new Set(["e2b.app", "e2b.dev", "e2b.pro", "e2b-staging.dev"]);
46
+ var CONNECT_PROTOCOL_VERSION = "1";
47
+ var CONNECT_END_STREAM_FLAG = 2;
48
+ var CONNECT_COMPRESSED_FLAG = 1;
49
+ function asRecord(value) {
50
+ if (typeof value !== "object" || value === null || Array.isArray(value))
51
+ return void 0;
52
+ return Object.fromEntries(Object.entries(value));
53
+ }
54
+ function asString(value) {
55
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
56
+ }
57
+ function asNumber(value) {
58
+ const numberValue = typeof value === "number" ? value : Number(value);
59
+ return Number.isFinite(numberValue) ? numberValue : void 0;
60
+ }
61
+ function asBoolean(value) {
62
+ return typeof value === "boolean" ? value : void 0;
63
+ }
64
+ function asStringArray(value) {
65
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
66
+ }
67
+ function cleanBaseUrl(url) {
68
+ return url.replace(/\/+$/, "");
69
+ }
70
+ function getCredentialString(credentials, key) {
71
+ return asString(credentials[key]);
72
+ }
73
+ function getApiBaseUrl(credentials) {
74
+ return cleanBaseUrl(getCredentialString(credentials, "apiUrl") ?? DEFAULT_API_URL);
75
+ }
76
+ function getDomain(credentials) {
77
+ return getCredentialString(credentials, "domain") ?? DEFAULT_DOMAIN;
78
+ }
79
+ function getStatusCode(response) {
80
+ return response.statusCode ?? response.status;
81
+ }
82
+ function toJsonObject(value, fallbackMessage) {
83
+ const record = asRecord(value);
84
+ if (record)
85
+ return record;
86
+ return { message: fallbackMessage };
87
+ }
88
+ function getErrorMessageFromBody(body, fallback) {
89
+ const record = asRecord(body);
90
+ const message = asString(record?.message);
91
+ if (message)
92
+ return message;
93
+ const error = record?.error;
94
+ if (typeof error === "string")
95
+ return error;
96
+ const nested = asRecord(error);
97
+ const nestedMessage = asString(nested?.message);
98
+ return nestedMessage ?? fallback;
99
+ }
100
+ function throwApiResponseError(executeFunctions, response, fallbackMessage) {
101
+ const statusCode = getStatusCode(response);
102
+ const message = getErrorMessageFromBody(response.body, statusCode ? `${statusCode}: ${fallbackMessage}` : fallbackMessage);
103
+ throw new n8n_workflow_12.NodeApiError(executeFunctions.getNode(), toJsonObject(response.body, message));
104
+ }
105
+ async function apiRequest(connection, method, endpoint, options = {}) {
106
+ const requestOptions = {
107
+ method,
108
+ url: `${getApiBaseUrl(connection.credentials)}${endpoint}`,
109
+ headers: options.headers,
110
+ qs: options.qs,
111
+ body: options.body,
112
+ encoding: options.encoding,
113
+ returnFullResponse: options.returnFullResponse,
114
+ ignoreHttpStatusErrors: options.ignoreHttpStatusErrors,
115
+ timeout: connection.timeoutMs
116
+ };
117
+ try {
118
+ return await connection.executeFunctions.helpers.httpRequestWithAuthentication.call(connection.executeFunctions, CREDENTIAL_TYPE, requestOptions);
119
+ } catch (error) {
120
+ throw new n8n_workflow_12.NodeApiError(connection.executeFunctions.getNode(), toJsonObject(error, "E2B API request failed"));
121
+ }
122
+ }
123
+ async function apiRequestFull(connection, method, endpoint, options = {}) {
124
+ return await apiRequest(connection, method, endpoint, {
125
+ ...options,
126
+ returnFullResponse: true,
127
+ ignoreHttpStatusErrors: true
128
+ });
129
+ }
130
+ function mapSandboxInfo(value) {
131
+ const record = asRecord(value) ?? {};
132
+ return {
133
+ sandboxId: asString(record.sandboxID) ?? asString(record.sandboxId) ?? "",
134
+ templateId: asString(record.templateID) ?? asString(record.templateId) ?? "",
135
+ ...asString(record.alias) ? { name: asString(record.alias) } : {},
136
+ metadata: asRecord(record.metadata) ?? {},
137
+ startedAt: asString(record.startedAt),
138
+ endAt: asString(record.endAt),
139
+ state: asString(record.state),
140
+ cpuCount: asNumber(record.cpuCount),
141
+ memoryMB: asNumber(record.memoryMB),
142
+ envdVersion: asString(record.envdVersion),
143
+ allowInternetAccess: asBoolean(record.allowInternetAccess),
144
+ network: asRecord(record.network),
145
+ lifecycle: asRecord(record.lifecycle),
146
+ volumeMounts: Array.isArray(record.volumeMounts) ? record.volumeMounts : [],
147
+ sandboxDomain: asString(record.domain) ?? asString(record.sandboxDomain)
148
+ };
149
+ }
150
+ function mapConnectedSandbox(value, sandboxId) {
151
+ const record = asRecord(value) ?? {};
152
+ return {
153
+ sandboxId: asString(record.sandboxID) ?? asString(record.sandboxId) ?? sandboxId ?? "",
154
+ sandboxDomain: asString(record.domain) ?? asString(record.sandboxDomain),
155
+ envdVersion: asString(record.envdVersion) ?? "0.0.0",
156
+ envdAccessToken: asString(record.envdAccessToken),
157
+ trafficAccessToken: asString(record.trafficAccessToken)
158
+ };
159
+ }
160
+ function mapSnapshot(value) {
161
+ const record = asRecord(value) ?? {};
162
+ return {
163
+ snapshotId: asString(record.snapshotID) ?? asString(record.snapshotId) ?? "",
164
+ names: asStringArray(record.names)
165
+ };
166
+ }
167
+ function mapVolume(value) {
168
+ const record = asRecord(value) ?? {};
169
+ return {
170
+ volumeId: asString(record.volumeID) ?? asString(record.volumeId) ?? "",
171
+ name: asString(record.name) ?? "",
172
+ token: asString(record.token)
173
+ };
174
+ }
175
+ function timeoutToSeconds(timeoutMs) {
176
+ return Math.round(timeoutMs / 1e3);
177
+ }
178
+ async function createSandbox(connection, options) {
179
+ const body = {
180
+ templateID: options.template ?? "base",
181
+ metadata: options.metadata,
182
+ envVars: options.envs,
183
+ timeout: timeoutToSeconds(options.timeoutMs),
184
+ secure: true,
185
+ allow_internet_access: options.allowInternetAccess
186
+ };
187
+ if (options.volumeMounts) {
188
+ body.volumeMounts = Object.entries(options.volumeMounts).map(([path, name]) => ({ name, path }));
189
+ }
190
+ const response = await apiRequest(connection, "POST", "/sandboxes", { body });
191
+ return mapConnectedSandbox(response);
192
+ }
193
+ async function connectSandbox(connection, sandboxId) {
194
+ const response = await apiRequest(connection, "POST", `/sandboxes/${encodeURIComponent(sandboxId)}/connect`, {
195
+ body: {
196
+ timeout: timeoutToSeconds(DEFAULT_SANDBOX_TIMEOUT_MS)
197
+ }
198
+ });
199
+ return mapConnectedSandbox(response, sandboxId);
200
+ }
201
+ async function getSandboxInfo(connection, sandboxId) {
202
+ const response = await apiRequest(connection, "GET", `/sandboxes/${encodeURIComponent(sandboxId)}`);
203
+ return mapSandboxInfo(response);
204
+ }
205
+ async function listSandboxes(connection, limit) {
206
+ const response = await apiRequest(connection, "GET", "/v2/sandboxes", { qs: { limit } });
207
+ return Array.isArray(response) ? response.map(mapSandboxInfo) : [];
208
+ }
209
+ async function killSandbox(connection, sandboxId) {
210
+ const response = await apiRequestFull(connection, "DELETE", `/sandboxes/${encodeURIComponent(sandboxId)}`);
211
+ const statusCode = getStatusCode(response);
212
+ if (statusCode === 404)
213
+ return false;
214
+ if (statusCode && statusCode >= 400)
215
+ throwApiResponseError(connection.executeFunctions, response, "Failed to kill sandbox");
216
+ return true;
217
+ }
218
+ async function pauseSandbox(connection, sandboxId) {
219
+ const response = await apiRequestFull(connection, "POST", `/sandboxes/${encodeURIComponent(sandboxId)}/pause`, {
220
+ body: { memory: true }
221
+ });
222
+ const statusCode = getStatusCode(response);
223
+ if (statusCode === 409)
224
+ return false;
225
+ if (statusCode && statusCode >= 400)
226
+ throwApiResponseError(connection.executeFunctions, response, "Failed to pause sandbox");
227
+ return true;
228
+ }
229
+ async function createSnapshot(connection, sandboxId, name) {
230
+ const response = await apiRequest(connection, "POST", `/sandboxes/${encodeURIComponent(sandboxId)}/snapshots`, {
231
+ body: name ? { name } : {}
232
+ });
233
+ return mapSnapshot(response);
234
+ }
235
+ async function listSnapshots(connection, limit, sandboxId) {
236
+ const response = await apiRequest(connection, "GET", "/snapshots", {
237
+ qs: {
238
+ limit,
239
+ ...sandboxId ? { sandboxID: sandboxId } : {}
240
+ }
241
+ });
242
+ return Array.isArray(response) ? response.map(mapSnapshot) : [];
243
+ }
244
+ async function deleteSnapshot(connection, snapshotId) {
245
+ const response = await apiRequestFull(connection, "DELETE", `/templates/${encodeURIComponent(snapshotId)}`);
246
+ const statusCode = getStatusCode(response);
247
+ if (statusCode === 404)
248
+ return false;
249
+ if (statusCode && statusCode >= 400)
250
+ throwApiResponseError(connection.executeFunctions, response, "Failed to delete snapshot");
251
+ return true;
252
+ }
253
+ async function createVolume(connection, name) {
254
+ const response = await apiRequest(connection, "POST", "/volumes", { body: { name } });
255
+ return mapVolume(response);
256
+ }
257
+ async function getVolume(connection, volumeId) {
258
+ const response = await apiRequest(connection, "GET", `/volumes/${encodeURIComponent(volumeId)}`);
259
+ return mapVolume(response);
260
+ }
261
+ async function listVolumes(connection) {
262
+ const response = await apiRequest(connection, "GET", "/volumes");
263
+ return Array.isArray(response) ? response.map(mapVolume) : [];
264
+ }
265
+ async function deleteVolume(connection, volumeId) {
266
+ const response = await apiRequestFull(connection, "DELETE", `/volumes/${encodeURIComponent(volumeId)}`);
267
+ const statusCode = getStatusCode(response);
268
+ if (statusCode === 404)
269
+ return false;
270
+ if (statusCode && statusCode >= 400)
271
+ throwApiResponseError(connection.executeFunctions, response, "Failed to delete volume");
272
+ return true;
273
+ }
274
+ function getSandboxHost(connection, sandboxId, port, sandboxDomain) {
275
+ return `${port}-${sandboxId}.${sandboxDomain ?? getDomain(connection.credentials)}`;
276
+ }
277
+ function getPreviewHost(connection, sandbox, port) {
278
+ return getSandboxHost(connection, sandbox.sandboxId, port, sandbox.sandboxDomain);
279
+ }
280
+ function getEnvdBaseUrl(connection, sandbox) {
281
+ const sandboxUrl = getCredentialString(connection.credentials, "sandboxUrl");
282
+ if (sandboxUrl)
283
+ return cleanBaseUrl(sandboxUrl);
284
+ const sandboxDomain = sandbox.sandboxDomain ?? getDomain(connection.credentials);
285
+ if (SUPPORTED_SANDBOX_DOMAINS.has(sandboxDomain)) {
286
+ return `https://sandbox.${sandboxDomain}`;
287
+ }
288
+ return `https://${getSandboxHost(connection, sandbox.sandboxId, ENVD_PORT, sandboxDomain)}`;
289
+ }
290
+ function compareVersion(left, right) {
291
+ const leftParts = left.split(".").map((part) => Number.parseInt(part, 10) || 0);
292
+ const rightParts = right.split(".").map((part) => Number.parseInt(part, 10) || 0);
293
+ const length = Math.max(leftParts.length, rightParts.length);
294
+ for (let index = 0; index < length; index++) {
295
+ const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
296
+ if (diff !== 0)
297
+ return diff;
298
+ }
299
+ return 0;
300
+ }
301
+ function sandboxHeaders(connection, sandbox) {
302
+ const headers = {
303
+ "E2b-Sandbox-Id": sandbox.sandboxId,
304
+ "E2b-Sandbox-Port": ENVD_PORT.toString()
305
+ };
306
+ if (sandbox.envdAccessToken) {
307
+ headers["X-Access-Token"] = sandbox.envdAccessToken;
308
+ }
309
+ if (compareVersion(sandbox.envdVersion, ENVD_DEFAULT_USER) < 0) {
310
+ headers.Authorization = `Basic ${Buffer.from("user:").toString("base64")}`;
311
+ }
312
+ return headers;
313
+ }
314
+ async function envdRequest(connection, sandbox, method, path, options = {}) {
315
+ const requestOptions = {
316
+ method,
317
+ url: `${getEnvdBaseUrl(connection, sandbox)}${path}`,
318
+ headers: {
319
+ ...sandboxHeaders(connection, sandbox),
320
+ ...options.headers
321
+ },
322
+ qs: options.qs,
323
+ body: options.body,
324
+ encoding: options.encoding,
325
+ returnFullResponse: options.returnFullResponse,
326
+ ignoreHttpStatusErrors: options.ignoreHttpStatusErrors,
327
+ timeout: connection.timeoutMs
328
+ };
329
+ try {
330
+ return await connection.executeFunctions.helpers.httpRequest(requestOptions);
331
+ } catch (error) {
332
+ throw new n8n_workflow_12.NodeApiError(connection.executeFunctions.getNode(), toJsonObject(error, "E2B sandbox request failed"));
333
+ }
334
+ }
335
+ function encodeConnectEnvelope(message) {
336
+ const payload = Buffer.from(JSON.stringify(message), "utf8");
337
+ const envelope = Buffer.alloc(payload.length + 5);
338
+ envelope.writeUInt8(0, 0);
339
+ envelope.writeUInt32BE(payload.length, 1);
340
+ payload.copy(envelope, 5);
341
+ return envelope;
342
+ }
343
+ function parseConnectEnvelopes(body) {
344
+ const buffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
345
+ const messages = [];
346
+ let offset = 0;
347
+ while (offset < buffer.length) {
348
+ if (offset + 5 > buffer.length) {
349
+ throw new Error("Incomplete Connect response envelope");
350
+ }
351
+ const flags = buffer.readUInt8(offset);
352
+ const length = buffer.readUInt32BE(offset + 1);
353
+ const start = offset + 5;
354
+ const end = start + length;
355
+ if (end > buffer.length) {
356
+ throw new Error("Incomplete Connect response message");
357
+ }
358
+ if ((flags & CONNECT_COMPRESSED_FLAG) === CONNECT_COMPRESSED_FLAG) {
359
+ throw new Error("Compressed Connect responses are not supported");
360
+ }
361
+ const json = JSON.parse(buffer.subarray(start, end).toString("utf8"));
362
+ const record = asRecord(json) ?? {};
363
+ if ((flags & CONNECT_END_STREAM_FLAG) === CONNECT_END_STREAM_FLAG) {
364
+ const error = asRecord(record.error);
365
+ if (error)
366
+ throw new Error(getErrorMessageFromBody(error, "E2B Connect request failed"));
367
+ } else {
368
+ messages.push(record);
369
+ }
370
+ offset = end;
371
+ }
372
+ return messages;
373
+ }
374
+ async function connectUnary(connection, sandbox, service, method, body) {
375
+ const response = await envdRequest(connection, sandbox, "POST", `/${service}/${method}`, {
376
+ body,
377
+ headers: {
378
+ "Content-Type": "application/json",
379
+ "Connect-Protocol-Version": CONNECT_PROTOCOL_VERSION,
380
+ "Connect-Timeout-Ms": connection.timeoutMs.toString()
381
+ },
382
+ encoding: "json",
383
+ returnFullResponse: true,
384
+ ignoreHttpStatusErrors: true
385
+ });
386
+ const statusCode = getStatusCode(response);
387
+ if (statusCode && statusCode >= 400)
388
+ throwApiResponseError(connection.executeFunctions, response, "E2B Connect request failed");
389
+ return asRecord(response.body) ?? {};
390
+ }
391
+ async function connectStream(connection, sandbox, service, method, body) {
392
+ const response = await envdRequest(connection, sandbox, "POST", `/${service}/${method}`, {
393
+ body: encodeConnectEnvelope(body),
394
+ headers: {
395
+ "Content-Type": "application/connect+json",
396
+ "Connect-Protocol-Version": CONNECT_PROTOCOL_VERSION,
397
+ "Connect-Timeout-Ms": connection.timeoutMs.toString(),
398
+ "Keepalive-Ping-Interval": "50"
399
+ },
400
+ encoding: "arraybuffer",
401
+ returnFullResponse: true,
402
+ ignoreHttpStatusErrors: true
403
+ });
404
+ const statusCode = getStatusCode(response);
405
+ if (statusCode && statusCode >= 400)
406
+ throwApiResponseError(connection.executeFunctions, response, "E2B Connect stream failed");
407
+ if (!response.body || !(response.body instanceof ArrayBuffer || Buffer.isBuffer(response.body))) {
408
+ throw new Error("Expected E2B Connect stream response body");
409
+ }
410
+ return parseConnectEnvelopes(response.body);
411
+ }
412
+ function mapFileType(value) {
413
+ if (value === 1 || value === "FILE" || value === "FILE_TYPE_FILE")
414
+ return "file";
415
+ if (value === 2 || value === "DIRECTORY" || value === "FILE_TYPE_DIRECTORY")
416
+ return "dir";
417
+ return void 0;
418
+ }
419
+ function mapFileInfo(value) {
420
+ const record = asRecord(value) ?? {};
421
+ const modifiedTime = record.modifiedTime;
422
+ return {
423
+ name: asString(record.name) ?? "",
424
+ type: mapFileType(record.type),
425
+ path: asString(record.path) ?? "",
426
+ metadata: asRecord(record.metadata),
427
+ size: asNumber(record.size),
428
+ mode: asNumber(record.mode),
429
+ permissions: asString(record.permissions),
430
+ owner: asString(record.owner),
431
+ group: asString(record.group),
432
+ modifiedTime: typeof modifiedTime === "string" ? modifiedTime : asString(asRecord(modifiedTime)?.seconds) ? new Date(Number(asString(asRecord(modifiedTime)?.seconds)) * 1e3).toISOString() : void 0,
433
+ symlinkTarget: asString(record.symlinkTarget)
434
+ };
435
+ }
436
+ function mapWriteInfo(value) {
437
+ const record = asRecord(value) ?? {};
438
+ return {
439
+ name: asString(record.name) ?? "",
440
+ type: mapFileType(record.type),
441
+ path: asString(record.path) ?? "",
442
+ metadata: asRecord(record.metadata)
443
+ };
444
+ }
445
+ function parseJsonArray(value) {
446
+ if (Array.isArray(value))
447
+ return value;
448
+ if (typeof value !== "string")
449
+ return [];
450
+ try {
451
+ const parsed = JSON.parse(value);
452
+ return Array.isArray(parsed) ? parsed : [];
453
+ } catch {
454
+ return [];
455
+ }
456
+ }
457
+ async function readSandboxFile(connection, sandbox, path, format) {
458
+ const response = await envdRequest(connection, sandbox, "GET", "/files", {
459
+ qs: { path },
460
+ encoding: format === "bytes" ? "arraybuffer" : "text",
461
+ returnFullResponse: true,
462
+ ignoreHttpStatusErrors: true
463
+ });
464
+ const statusCode = getStatusCode(response);
465
+ if (statusCode && statusCode >= 400)
466
+ throwApiResponseError(connection.executeFunctions, response, "Failed to read sandbox file");
467
+ if (format === "bytes") {
468
+ return Buffer.isBuffer(response.body) ? response.body : Buffer.from(response.body);
469
+ }
470
+ return typeof response.body === "string" ? response.body : "";
471
+ }
472
+ async function writeSandboxFile(connection, sandbox, path, content) {
473
+ const formData = new FormData();
474
+ const blobContent = Buffer.isBuffer(content) ? new Uint8Array(content) : content;
475
+ formData.append("file", new Blob([blobContent]), path);
476
+ const response = await envdRequest(connection, sandbox, "POST", "/files", {
477
+ qs: { path },
478
+ body: formData
479
+ });
480
+ const files = parseJsonArray(response);
481
+ if (files.length === 0)
482
+ throw new Error("Expected to receive information about written file");
483
+ return mapWriteInfo(files[0]);
484
+ }
485
+ async function listSandboxFiles(connection, sandbox, path, depth) {
486
+ const response = await connectUnary(connection, sandbox, "filesystem.Filesystem", "ListDir", { path, depth });
487
+ const entries = Array.isArray(response.entries) ? response.entries : [];
488
+ return entries.map(mapFileInfo).filter((entry) => entry.type !== void 0);
489
+ }
490
+ async function createSandboxFolder(connection, sandbox, path) {
491
+ const response = await connectUnary(connection, sandbox, "filesystem.Filesystem", "MakeDir", { path });
492
+ return Object.keys(response).length >= 0;
493
+ }
494
+ async function deleteSandboxFile(connection, sandbox, path) {
495
+ await connectUnary(connection, sandbox, "filesystem.Filesystem", "Remove", { path });
496
+ }
497
+ async function getSandboxFileInfo(connection, sandbox, path) {
498
+ const response = await connectUnary(connection, sandbox, "filesystem.Filesystem", "Stat", { path });
499
+ return mapFileInfo(response.entry);
500
+ }
501
+ async function moveSandboxFile(connection, sandbox, source, destination) {
502
+ const response = await connectUnary(connection, sandbox, "filesystem.Filesystem", "Move", {
503
+ source,
504
+ destination
505
+ });
506
+ return mapFileInfo(response.entry);
507
+ }
508
+ function decodeBase64Text(value) {
509
+ if (typeof value !== "string")
510
+ return "";
511
+ return Buffer.from(value, "base64").toString("utf8");
512
+ }
513
+ function mapCommandEvent(message, result) {
514
+ const event = asRecord(message.event);
515
+ if (!event)
516
+ return;
517
+ const data = asRecord(event.data);
518
+ if (data) {
519
+ result.stdout += decodeBase64Text(data.stdout);
520
+ result.stderr += decodeBase64Text(data.stderr);
521
+ return;
522
+ }
523
+ const end = asRecord(event.end);
524
+ if (end) {
525
+ result.exitCode = asNumber(end.exitCode) ?? result.exitCode;
526
+ result.error = asString(end.error);
527
+ }
528
+ }
529
+ async function runSandboxCommand(connection, sandbox, command, options = {}) {
530
+ const process = {
531
+ cmd: "/bin/bash",
532
+ args: ["-l", "-c", command],
533
+ envs: options.envs ?? {}
534
+ };
535
+ if (options.cwd)
536
+ process.cwd = options.cwd;
537
+ const messages = await connectStream(connection, sandbox, "process.Process", "Start", {
538
+ process,
539
+ stdin: false
540
+ });
541
+ const result = {
542
+ exitCode: 0,
543
+ stdout: "",
544
+ stderr: ""
545
+ };
546
+ for (const message of messages) {
547
+ mapCommandEvent(message, result);
548
+ }
549
+ return result;
550
+ }
551
+ }
552
+ });
553
+
554
+ // dist/nodes/E2B/helpers.js
555
+ var require_helpers = __commonJS({
556
+ "dist/nodes/E2B/helpers.js"(exports2) {
557
+ "use strict";
558
+ Object.defineProperty(exports2, "__esModule", { value: true });
559
+ exports2.asNonEmptyString = asNonEmptyString;
560
+ exports2.getErrorMessage = getErrorMessage;
561
+ exports2.getCollectionParameter = getCollectionParameter;
562
+ exports2.getRecordString = getRecordString;
563
+ exports2.getRecordBoolean = getRecordBoolean;
564
+ exports2.getRecordNumber = getRecordNumber;
565
+ exports2.splitCommaSeparated = splitCommaSeparated;
566
+ exports2.quoteShellArg = quoteShellArg;
567
+ exports2.parseStringMapParameter = parseStringMapParameter;
568
+ exports2.getTimeoutMs = getTimeoutMs;
569
+ exports2.getLimit = getLimit;
570
+ exports2.getPort = getPort;
571
+ exports2.getRequiredStringParameter = getRequiredStringParameter;
572
+ exports2.getSandboxCreateOptions = getSandboxCreateOptions;
573
+ exports2.toSandboxInfoData = toSandboxInfoData;
574
+ exports2.toSnapshotInfoData = toSnapshotInfoData;
575
+ exports2.toFileInfoData = toFileInfoData;
576
+ exports2.toVolumeInfoData = toVolumeInfoData;
577
+ exports2.toCommandResultData = toCommandResultData;
578
+ exports2.toOperationCommandResultData = toOperationCommandResultData;
579
+ var n8n_workflow_12 = require("n8n-workflow");
580
+ function asNonEmptyString(value) {
581
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
582
+ }
583
+ function getErrorMessage(error) {
584
+ if (error instanceof Error)
585
+ return error.message;
586
+ return String(error);
587
+ }
588
+ function isRecord(value) {
589
+ return typeof value === "object" && value !== null && !Array.isArray(value);
590
+ }
591
+ function getCollectionParameter(executeFunctions, name, itemIndex) {
592
+ const value = executeFunctions.getNodeParameter(name, itemIndex, {});
593
+ return isRecord(value) ? value : {};
594
+ }
595
+ function getRecordString(record, key) {
596
+ return asNonEmptyString(record[key]);
597
+ }
598
+ function getRecordBoolean(record, key) {
599
+ return typeof record[key] === "boolean" ? record[key] : void 0;
600
+ }
601
+ function getRecordNumber(record, key) {
602
+ const value = record[key];
603
+ const numberValue = typeof value === "number" ? value : Number(value);
604
+ return Number.isFinite(numberValue) ? numberValue : void 0;
605
+ }
606
+ function splitCommaSeparated(value) {
607
+ if (!value)
608
+ return void 0;
609
+ const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
610
+ return entries.length > 0 ? entries : void 0;
611
+ }
612
+ function quoteShellArg(value) {
613
+ return `'${value.replaceAll("'", "'\\''")}'`;
614
+ }
615
+ function parseStringMapParameter(executeFunctions, value, displayName, itemIndex) {
616
+ if (value === void 0 || value === null || value === "")
617
+ return void 0;
618
+ let parsed = value;
619
+ if (typeof value === "string") {
620
+ try {
621
+ parsed = JSON.parse(value);
622
+ } catch (error) {
623
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `${displayName} must be valid JSON: ${getErrorMessage(error)}`, { itemIndex });
624
+ }
625
+ }
626
+ if (!isRecord(parsed)) {
627
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `${displayName} must be a JSON object`, {
628
+ itemIndex
629
+ });
630
+ }
631
+ const output = {};
632
+ for (const [key, entryValue] of Object.entries(parsed)) {
633
+ if (entryValue === void 0 || entryValue === null)
634
+ continue;
635
+ if (typeof entryValue === "object") {
636
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `${displayName} values must be strings, numbers, or booleans`, { itemIndex });
637
+ }
638
+ output[key] = String(entryValue);
639
+ }
640
+ return Object.keys(output).length > 0 ? output : void 0;
641
+ }
642
+ function getTimeoutMs(executeFunctions, itemIndex) {
643
+ const timeoutSeconds = Number(executeFunctions.getNodeParameter("timeoutSeconds", itemIndex, 300));
644
+ if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
645
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), "Timeout must be greater than 0", {
646
+ itemIndex
647
+ });
648
+ }
649
+ return Math.round(timeoutSeconds * 1e3);
650
+ }
651
+ function getLimit(executeFunctions, itemIndex) {
652
+ const limit = Number(executeFunctions.getNodeParameter("limit", itemIndex, 50));
653
+ if (!Number.isInteger(limit) || limit <= 0) {
654
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), "Limit must be a positive integer", {
655
+ itemIndex
656
+ });
657
+ }
658
+ return limit;
659
+ }
660
+ function getPort(executeFunctions, itemIndex) {
661
+ const port = Number(executeFunctions.getNodeParameter("port", itemIndex, 3e3));
662
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
663
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), "Port must be an integer between 1 and 65535", { itemIndex });
664
+ }
665
+ return port;
666
+ }
667
+ function getRequiredStringParameter(executeFunctions, name, displayName, itemIndex) {
668
+ const value = asNonEmptyString(executeFunctions.getNodeParameter(name, itemIndex));
669
+ if (!value) {
670
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `${displayName} is required`, {
671
+ itemIndex
672
+ });
673
+ }
674
+ return value;
675
+ }
676
+ function getSandboxCreateOptions(executeFunctions, itemIndex) {
677
+ const timeoutMs = getTimeoutMs(executeFunctions, itemIndex);
678
+ const template = asNonEmptyString(executeFunctions.getNodeParameter("template", itemIndex, ""));
679
+ const metadata = parseStringMapParameter(executeFunctions, executeFunctions.getNodeParameter("metadataJson", itemIndex, ""), "Metadata", itemIndex);
680
+ const envs = parseStringMapParameter(executeFunctions, executeFunctions.getNodeParameter("envJson", itemIndex, ""), "Environment Variables", itemIndex);
681
+ const volumeMounts = parseStringMapParameter(executeFunctions, executeFunctions.getNodeParameter("volumeMountsJson", itemIndex, ""), "Volume Mounts", itemIndex);
682
+ const allowInternetAccess = executeFunctions.getNodeParameter("allowInternetAccess", itemIndex, true) === true;
683
+ return {
684
+ ...template ? { template } : {},
685
+ ...metadata ? { metadata } : {},
686
+ ...envs ? { envs } : {},
687
+ ...volumeMounts ? { volumeMounts } : {},
688
+ allowInternetAccess,
689
+ timeoutMs
690
+ };
691
+ }
692
+ function toIsoString(value) {
693
+ if (value instanceof Date)
694
+ return value.toISOString();
695
+ return value;
696
+ }
697
+ function toSandboxInfoData(info, sandboxDomain) {
698
+ return {
699
+ sandboxId: info.sandboxId,
700
+ templateId: info.templateId,
701
+ name: info.name,
702
+ state: info.state,
703
+ metadata: info.metadata ?? {},
704
+ startedAt: toIsoString(info.startedAt),
705
+ endAt: toIsoString(info.endAt),
706
+ cpuCount: info.cpuCount,
707
+ memoryMB: info.memoryMB,
708
+ envdVersion: info.envdVersion,
709
+ allowInternetAccess: info.allowInternetAccess,
710
+ network: info.network,
711
+ lifecycle: info.lifecycle,
712
+ volumeMounts: info.volumeMounts ?? [],
713
+ sandboxDomain: sandboxDomain ?? info.sandboxDomain
714
+ };
715
+ }
716
+ function toSnapshotInfoData(info) {
717
+ return {
718
+ snapshotId: info.snapshotId,
719
+ names: info.names
720
+ };
721
+ }
722
+ function toFileInfoData(info) {
723
+ return {
724
+ name: info.name,
725
+ type: info.type,
726
+ path: info.path,
727
+ metadata: info.metadata ?? {},
728
+ ..."size" in info ? {
729
+ size: info.size,
730
+ mode: info.mode,
731
+ permissions: info.permissions,
732
+ owner: info.owner,
733
+ group: info.group,
734
+ modifiedTime: toIsoString(info.modifiedTime),
735
+ symlinkTarget: info.symlinkTarget
736
+ } : {}
737
+ };
738
+ }
739
+ function toVolumeInfoData(info) {
740
+ return {
741
+ volumeId: info.volumeId,
742
+ name: info.name,
743
+ ...info.token ? { token: info.token } : {}
744
+ };
745
+ }
746
+ function toCommandResultData(result, sandbox, command, startedAt, createdSandbox, killedAfterRun) {
747
+ return {
748
+ sandboxId: sandbox.sandboxId,
749
+ sandboxDomain: sandbox.sandboxDomain,
750
+ createdSandbox,
751
+ killedAfterRun,
752
+ command,
753
+ success: result.exitCode === 0,
754
+ exitCode: result.exitCode,
755
+ stdout: result.stdout,
756
+ stderr: result.stderr,
757
+ error: result.error,
758
+ executionTimeMs: Date.now() - startedAt
759
+ };
760
+ }
761
+ function toOperationCommandResultData(result, sandboxId, operation, startedAt, extra = {}) {
762
+ return {
763
+ sandboxId,
764
+ operation,
765
+ success: result.exitCode === 0,
766
+ exitCode: result.exitCode,
767
+ stdout: result.stdout,
768
+ stderr: result.stderr,
769
+ error: result.error,
770
+ executionTimeMs: Date.now() - startedAt,
771
+ ...extra
772
+ };
773
+ }
774
+ }
775
+ });
776
+
777
+ // dist/nodes/E2B/actions/code.operations.js
778
+ var require_code_operations = __commonJS({
779
+ "dist/nodes/E2B/actions/code.operations.js"(exports2) {
780
+ "use strict";
781
+ Object.defineProperty(exports2, "__esModule", { value: true });
782
+ exports2.runCommand = runCommand;
783
+ var n8n_workflow_12 = require("n8n-workflow");
784
+ var client_1 = require_client();
785
+ var helpers_12 = require_helpers();
786
+ async function runCommand(context) {
787
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
788
+ const connection = { executeFunctions, credentials, timeoutMs };
789
+ const sandboxId = (0, helpers_12.asNonEmptyString)(executeFunctions.getNodeParameter("sandboxId", itemIndex, ""));
790
+ const command = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "command", "Command", itemIndex);
791
+ const cwd = (0, helpers_12.asNonEmptyString)(executeFunctions.getNodeParameter("cwd", itemIndex, ""));
792
+ const killAfterRun = executeFunctions.getNodeParameter("killAfterRun", itemIndex, false) === true;
793
+ const envs = (0, helpers_12.parseStringMapParameter)(executeFunctions, executeFunctions.getNodeParameter("envJson", itemIndex, ""), "Environment Variables", itemIndex);
794
+ const createdSandbox = !sandboxId;
795
+ const sandbox = sandboxId ? await (0, client_1.connectSandbox)(connection, sandboxId) : await (0, client_1.createSandbox)(connection, (0, helpers_12.getSandboxCreateOptions)(executeFunctions, itemIndex));
796
+ let resultData;
797
+ let executionError;
798
+ let cleanupError;
799
+ try {
800
+ const startedAt = Date.now();
801
+ const result = await (0, client_1.runSandboxCommand)(connection, sandbox, command, {
802
+ ...cwd ? { cwd } : {},
803
+ ...envs ? { envs } : {}
804
+ });
805
+ resultData = (0, helpers_12.toCommandResultData)(result, sandbox, command, startedAt, createdSandbox, false);
806
+ } catch (error) {
807
+ executionError = error;
808
+ } finally {
809
+ if (killAfterRun) {
810
+ try {
811
+ await (0, client_1.killSandbox)(connection, sandbox.sandboxId);
812
+ if (resultData)
813
+ resultData.killedAfterRun = true;
814
+ } catch (error) {
815
+ cleanupError = error;
816
+ if (resultData)
817
+ resultData.cleanupError = (0, helpers_12.getErrorMessage)(error);
818
+ }
819
+ }
820
+ }
821
+ if (executionError) {
822
+ if (cleanupError) {
823
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `E2B command failed and the sandbox could not be killed: ${(0, helpers_12.getErrorMessage)(executionError)}; cleanup error: ${(0, helpers_12.getErrorMessage)(cleanupError)}`, { itemIndex });
824
+ }
825
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), (0, helpers_12.getErrorMessage)(executionError), {
826
+ itemIndex
827
+ });
828
+ }
829
+ if (cleanupError) {
830
+ throw new n8n_workflow_12.NodeOperationError(executeFunctions.getNode(), `E2B command succeeded but the sandbox could not be killed: ${(0, helpers_12.getErrorMessage)(cleanupError)}`, { itemIndex });
831
+ }
832
+ return resultData ? [
833
+ {
834
+ json: resultData,
835
+ pairedItem: { item: itemIndex }
836
+ }
837
+ ] : [];
838
+ }
839
+ }
840
+ });
841
+
842
+ // dist/nodes/E2B/actions/file.operations.js
843
+ var require_file_operations = __commonJS({
844
+ "dist/nodes/E2B/actions/file.operations.js"(exports2) {
845
+ "use strict";
846
+ Object.defineProperty(exports2, "__esModule", { value: true });
847
+ exports2.createFolder = createFolder;
848
+ exports2.deleteFile = deleteFile;
849
+ exports2.download = download;
850
+ exports2.info = info;
851
+ exports2.list = list;
852
+ exports2.move = move;
853
+ exports2.read = read;
854
+ exports2.upload = upload;
855
+ exports2.write = write;
856
+ var client_1 = require_client();
857
+ var helpers_12 = require_helpers();
858
+ async function getConnectedSandbox(context) {
859
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
860
+ const connection = { executeFunctions, credentials, timeoutMs };
861
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
862
+ const sandbox = await (0, client_1.connectSandbox)(connection, sandboxId);
863
+ return { connection, sandbox, sandboxId };
864
+ }
865
+ async function createFolder(context) {
866
+ const { executeFunctions, itemIndex } = context;
867
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
868
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
869
+ const created = await (0, client_1.createSandboxFolder)(connection, sandbox, path);
870
+ return [
871
+ {
872
+ json: {
873
+ sandboxId,
874
+ path,
875
+ created
876
+ },
877
+ pairedItem: { item: itemIndex }
878
+ }
879
+ ];
880
+ }
881
+ async function deleteFile(context) {
882
+ const { executeFunctions, itemIndex } = context;
883
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
884
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
885
+ await (0, client_1.deleteSandboxFile)(connection, sandbox, path);
886
+ return [
887
+ {
888
+ json: {
889
+ sandboxId,
890
+ path,
891
+ deleted: true
892
+ },
893
+ pairedItem: { item: itemIndex }
894
+ }
895
+ ];
896
+ }
897
+ async function download(context) {
898
+ const { executeFunctions, itemIndex } = context;
899
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
900
+ const remotePath = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "remotePath", "Remote Path", itemIndex);
901
+ const binaryPropertyName = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "binaryPropertyName", "Binary Field", itemIndex);
902
+ const content = await (0, client_1.readSandboxFile)(connection, sandbox, remotePath, "bytes");
903
+ const buffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
904
+ const filename = remotePath.split("/").pop()?.trim() || "download";
905
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(buffer, filename, "application/octet-stream");
906
+ return [
907
+ {
908
+ json: {
909
+ sandboxId,
910
+ remotePath,
911
+ fileName: filename,
912
+ sizeBytes: buffer.byteLength
913
+ },
914
+ binary: {
915
+ [binaryPropertyName]: binaryData
916
+ },
917
+ pairedItem: { item: itemIndex }
918
+ }
919
+ ];
920
+ }
921
+ async function info(context) {
922
+ const { executeFunctions, itemIndex } = context;
923
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
924
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
925
+ const fileInfo = await (0, client_1.getSandboxFileInfo)(connection, sandbox, path);
926
+ return [
927
+ {
928
+ json: {
929
+ sandboxId,
930
+ ...(0, helpers_12.toFileInfoData)(fileInfo)
931
+ },
932
+ pairedItem: { item: itemIndex }
933
+ }
934
+ ];
935
+ }
936
+ async function list(context) {
937
+ const { executeFunctions, itemIndex } = context;
938
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
939
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
940
+ const depth = Number(executeFunctions.getNodeParameter("depth", itemIndex, 1));
941
+ const entries = await (0, client_1.listSandboxFiles)(connection, sandbox, path, Number.isInteger(depth) && depth > 0 ? depth : 1);
942
+ return [
943
+ {
944
+ json: {
945
+ sandboxId,
946
+ path,
947
+ count: entries.length,
948
+ files: entries.map(helpers_12.toFileInfoData)
949
+ },
950
+ pairedItem: { item: itemIndex }
951
+ }
952
+ ];
953
+ }
954
+ async function move(context) {
955
+ const { executeFunctions, itemIndex } = context;
956
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
957
+ const source = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "source", "Source", itemIndex);
958
+ const destination = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "destination", "Destination", itemIndex);
959
+ const fileInfo = await (0, client_1.moveSandboxFile)(connection, sandbox, source, destination);
960
+ return [
961
+ {
962
+ json: {
963
+ sandboxId,
964
+ source,
965
+ destination,
966
+ ...(0, helpers_12.toFileInfoData)(fileInfo)
967
+ },
968
+ pairedItem: { item: itemIndex }
969
+ }
970
+ ];
971
+ }
972
+ async function read(context) {
973
+ const { executeFunctions, itemIndex } = context;
974
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
975
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
976
+ const content = await (0, client_1.readSandboxFile)(connection, sandbox, path, "text");
977
+ return [
978
+ {
979
+ json: {
980
+ sandboxId,
981
+ path,
982
+ content
983
+ },
984
+ pairedItem: { item: itemIndex }
985
+ }
986
+ ];
987
+ }
988
+ async function upload(context) {
989
+ const { executeFunctions, itemIndex } = context;
990
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
991
+ const remotePath = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "remotePath", "Remote Path", itemIndex);
992
+ const binaryPropertyName = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "binaryPropertyName", "Binary Field", itemIndex);
993
+ const binaryMeta = executeFunctions.helpers.assertBinaryData(itemIndex, binaryPropertyName);
994
+ const buffer = await executeFunctions.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
995
+ const fileInfo = await (0, client_1.writeSandboxFile)(connection, sandbox, remotePath, buffer);
996
+ return [
997
+ {
998
+ json: {
999
+ sandboxId,
1000
+ remotePath,
1001
+ fileName: binaryMeta.fileName,
1002
+ mimeType: binaryMeta.mimeType,
1003
+ sizeBytes: buffer.length,
1004
+ ...(0, helpers_12.toFileInfoData)(fileInfo)
1005
+ },
1006
+ pairedItem: { item: itemIndex }
1007
+ }
1008
+ ];
1009
+ }
1010
+ async function write(context) {
1011
+ const { executeFunctions, itemIndex } = context;
1012
+ const { connection, sandbox, sandboxId } = await getConnectedSandbox(context);
1013
+ const path = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "path", "Path", itemIndex);
1014
+ const content = executeFunctions.getNodeParameter("content", itemIndex, "");
1015
+ const fileInfo = await (0, client_1.writeSandboxFile)(connection, sandbox, path, String(content));
1016
+ return [
1017
+ {
1018
+ json: {
1019
+ sandboxId,
1020
+ contentLength: String(content).length,
1021
+ ...(0, helpers_12.toFileInfoData)(fileInfo)
1022
+ },
1023
+ pairedItem: { item: itemIndex }
1024
+ }
1025
+ ];
1026
+ }
1027
+ }
1028
+ });
1029
+
1030
+ // dist/nodes/E2B/actions/git.operations.js
1031
+ var require_git_operations = __commonJS({
1032
+ "dist/nodes/E2B/actions/git.operations.js"(exports2) {
1033
+ "use strict";
1034
+ Object.defineProperty(exports2, "__esModule", { value: true });
1035
+ exports2.status = status;
1036
+ exports2.add = add;
1037
+ exports2.checkout = checkout;
1038
+ exports2.clone = clone;
1039
+ exports2.commit = commit;
1040
+ exports2.pull = pull;
1041
+ exports2.push = push;
1042
+ var n8n_workflow_12 = require("n8n-workflow");
1043
+ var client_1 = require_client();
1044
+ var helpers_12 = require_helpers();
1045
+ var DEFAULT_GIT_ENV = {
1046
+ GIT_TERMINAL_PROMPT: "0"
1047
+ };
1048
+ function parseAheadBehind(segment) {
1049
+ if (!segment)
1050
+ return { ahead: 0, behind: 0 };
1051
+ let ahead = 0;
1052
+ let behind = 0;
1053
+ if (segment.includes("ahead")) {
1054
+ const value = Number.parseInt(segment.split("ahead")[1].split(",")[0].trim(), 10);
1055
+ ahead = Number.isFinite(value) ? value : 0;
1056
+ }
1057
+ if (segment.includes("behind")) {
1058
+ const value = Number.parseInt(segment.split("behind")[1].split(",")[0].trim(), 10);
1059
+ behind = Number.isFinite(value) ? value : 0;
1060
+ }
1061
+ return { ahead, behind };
1062
+ }
1063
+ function normalizeBranchName(name) {
1064
+ if (name.startsWith("HEAD (detached at ")) {
1065
+ return name.replace("HEAD (detached at ", "").replace(/\)$/, "");
1066
+ }
1067
+ return name.replace("HEAD (no branch)", "HEAD").replace("No commits yet on ", "").replace("Initial commit on ", "");
1068
+ }
1069
+ function deriveStatus(indexStatus, workingStatus) {
1070
+ const statuses = /* @__PURE__ */ new Set([indexStatus, workingStatus]);
1071
+ if (statuses.has("U"))
1072
+ return "conflict";
1073
+ if (statuses.has("R"))
1074
+ return "renamed";
1075
+ if (statuses.has("C"))
1076
+ return "copied";
1077
+ if (statuses.has("D"))
1078
+ return "deleted";
1079
+ if (statuses.has("A"))
1080
+ return "added";
1081
+ if (statuses.has("M"))
1082
+ return "modified";
1083
+ if (statuses.has("T"))
1084
+ return "typechange";
1085
+ if (statuses.has("?"))
1086
+ return "untracked";
1087
+ return "unknown";
1088
+ }
1089
+ function parseGitStatus(output) {
1090
+ const lines = output.split("\n").map((line) => line.replace(/\r$/, "")).filter((line) => line.trim().length > 0);
1091
+ let currentBranch;
1092
+ let upstream;
1093
+ let ahead = 0;
1094
+ let behind = 0;
1095
+ let detached = false;
1096
+ const fileStatus = [];
1097
+ if (lines.length === 0) {
1098
+ return {
1099
+ currentBranch,
1100
+ upstream,
1101
+ ahead,
1102
+ behind,
1103
+ detached,
1104
+ fileStatus,
1105
+ isClean: true,
1106
+ hasChanges: false,
1107
+ hasStaged: false,
1108
+ hasUntracked: false,
1109
+ hasConflicts: false,
1110
+ totalCount: 0,
1111
+ stagedCount: 0,
1112
+ unstagedCount: 0,
1113
+ untrackedCount: 0,
1114
+ conflictCount: 0
1115
+ };
1116
+ }
1117
+ const branchLine = lines[0];
1118
+ if (branchLine.startsWith("## ")) {
1119
+ const branchInfo = branchLine.slice(3);
1120
+ const aheadStart = branchInfo.indexOf(" [");
1121
+ const branchPart = aheadStart === -1 ? branchInfo : branchInfo.slice(0, aheadStart);
1122
+ const aheadPart = aheadStart === -1 ? void 0 : branchInfo.slice(aheadStart + 2, -1);
1123
+ const normalizedBranch = normalizeBranchName(branchPart);
1124
+ const isDetached = branchPart.startsWith("HEAD (detached at ") || branchPart.includes("detached");
1125
+ if (isDetached || normalizedBranch.startsWith("HEAD")) {
1126
+ detached = true;
1127
+ } else if (normalizedBranch.includes("...")) {
1128
+ const [branch, upstreamBranch] = normalizedBranch.split("...");
1129
+ currentBranch = branch || void 0;
1130
+ upstream = upstreamBranch || void 0;
1131
+ } else {
1132
+ currentBranch = normalizedBranch || void 0;
1133
+ }
1134
+ const aheadBehind = parseAheadBehind(aheadPart);
1135
+ ahead = aheadBehind.ahead;
1136
+ behind = aheadBehind.behind;
1137
+ }
1138
+ for (const line of lines.slice(1)) {
1139
+ if (line.startsWith("?? ")) {
1140
+ const name2 = line.slice(3);
1141
+ fileStatus.push({
1142
+ name: name2,
1143
+ status: "untracked",
1144
+ indexStatus: "?",
1145
+ workingTreeStatus: "?",
1146
+ staged: false
1147
+ });
1148
+ continue;
1149
+ }
1150
+ if (line.length < 3)
1151
+ continue;
1152
+ const indexStatus = line[0];
1153
+ const workingTreeStatus = line[1];
1154
+ const path = line.slice(3);
1155
+ let renamedFrom;
1156
+ let name = path;
1157
+ if (path.includes(" -> ")) {
1158
+ const parts = path.split(" -> ");
1159
+ renamedFrom = parts[0];
1160
+ name = parts.slice(1).join(" -> ");
1161
+ }
1162
+ fileStatus.push({
1163
+ name,
1164
+ status: deriveStatus(indexStatus, workingTreeStatus),
1165
+ indexStatus,
1166
+ workingTreeStatus,
1167
+ staged: indexStatus !== " " && indexStatus !== "?",
1168
+ ...renamedFrom ? { renamedFrom } : {}
1169
+ });
1170
+ }
1171
+ const totalCount = fileStatus.length;
1172
+ const stagedCount = fileStatus.filter((item) => item.staged).length;
1173
+ const untrackedCount = fileStatus.filter((item) => item.status === "untracked").length;
1174
+ const conflictCount = fileStatus.filter((item) => item.status === "conflict").length;
1175
+ const unstagedCount = totalCount - stagedCount;
1176
+ return {
1177
+ currentBranch,
1178
+ upstream,
1179
+ ahead,
1180
+ behind,
1181
+ detached,
1182
+ fileStatus,
1183
+ isClean: totalCount === 0,
1184
+ hasChanges: totalCount > 0,
1185
+ hasStaged: stagedCount > 0,
1186
+ hasUntracked: untrackedCount > 0,
1187
+ hasConflicts: conflictCount > 0,
1188
+ totalCount,
1189
+ stagedCount,
1190
+ unstagedCount,
1191
+ untrackedCount,
1192
+ conflictCount
1193
+ };
1194
+ }
1195
+ function buildGitCommand(args, repoPath) {
1196
+ const parts = ["git"];
1197
+ if (repoPath)
1198
+ parts.push("-C", repoPath);
1199
+ parts.push(...args);
1200
+ return parts.map(helpers_12.quoteShellArg).join(" ");
1201
+ }
1202
+ function resultMessage(result) {
1203
+ const details = [result.error, result.stderr.trim(), result.stdout.trim()].filter((entry) => entry && entry.length > 0).join("; ");
1204
+ return details || `Git command exited with code ${result.exitCode}`;
1205
+ }
1206
+ function commandText(result) {
1207
+ return `${result.stderr}
1208
+ ${result.stdout}`.toLowerCase();
1209
+ }
1210
+ function isAuthFailure(result) {
1211
+ if (result.exitCode === 0)
1212
+ return false;
1213
+ const message = commandText(result);
1214
+ const authSnippets = [
1215
+ "authentication failed",
1216
+ "terminal prompts disabled",
1217
+ "could not read username",
1218
+ "invalid username or password",
1219
+ "access denied",
1220
+ "permission denied",
1221
+ "not authorized"
1222
+ ];
1223
+ return authSnippets.some((snippet) => message.includes(snippet));
1224
+ }
1225
+ function isMissingUpstream(result) {
1226
+ if (result.exitCode === 0)
1227
+ return false;
1228
+ const message = commandText(result);
1229
+ const upstreamSnippets = [
1230
+ "has no upstream branch",
1231
+ "no upstream branch",
1232
+ "no upstream configured",
1233
+ "no tracking information for the current branch",
1234
+ "no tracking information",
1235
+ "set the remote as upstream",
1236
+ "set the upstream branch",
1237
+ "please specify which branch you want to merge with"
1238
+ ];
1239
+ return upstreamSnippets.some((snippet) => message.includes(snippet));
1240
+ }
1241
+ function buildAuthErrorMessage(action, missingPassword) {
1242
+ if (missingPassword) {
1243
+ return `Git ${action} requires a password/token for private repositories.`;
1244
+ }
1245
+ return `Git ${action} requires credentials for private repositories.`;
1246
+ }
1247
+ function buildUpstreamErrorMessage(action) {
1248
+ if (action === "push") {
1249
+ return "Git push failed because no upstream branch is configured. Set upstream once with the Set Upstream option, or pass remote and branch explicitly.";
1250
+ }
1251
+ return "Git pull failed because no upstream branch is configured. Pass remote and branch explicitly, or set upstream once before pulling.";
1252
+ }
1253
+ function throwGitError(context, message) {
1254
+ throw new n8n_workflow_12.NodeOperationError(context.executeFunctions.getNode(), message, {
1255
+ itemIndex: context.itemIndex
1256
+ });
1257
+ }
1258
+ function addCredentialsToUrl(context, url, username, password) {
1259
+ let parsed;
1260
+ try {
1261
+ parsed = new URL(url);
1262
+ } catch {
1263
+ throwGitError(context, `Invalid Git URL: ${url}`);
1264
+ }
1265
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
1266
+ throwGitError(context, "Only http(s) Git URLs support username/password credentials.");
1267
+ }
1268
+ parsed.username = username;
1269
+ parsed.password = password;
1270
+ return parsed.toString();
1271
+ }
1272
+ function stripCredentials(url) {
1273
+ let parsed;
1274
+ try {
1275
+ parsed = new URL(url);
1276
+ } catch {
1277
+ return url;
1278
+ }
1279
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
1280
+ return url;
1281
+ if (!parsed.username && !parsed.password)
1282
+ return url;
1283
+ parsed.username = "";
1284
+ parsed.password = "";
1285
+ return parsed.toString();
1286
+ }
1287
+ function buildPushArgs(remote, branch, setUpstream) {
1288
+ const args = ["push"];
1289
+ if (setUpstream && remote)
1290
+ args.push("--set-upstream");
1291
+ if (remote)
1292
+ args.push(remote);
1293
+ if (branch)
1294
+ args.push(branch);
1295
+ return args;
1296
+ }
1297
+ async function getGitContext(context) {
1298
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1299
+ const connection = { executeFunctions, credentials, timeoutMs };
1300
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1301
+ const repositoryPath = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "repositoryPath", "Repository Path", itemIndex);
1302
+ const sandbox = await (0, client_1.connectSandbox)(connection, sandboxId);
1303
+ const startedAt = Date.now();
1304
+ return { ...context, connection, sandbox, sandboxId, repositoryPath, startedAt };
1305
+ }
1306
+ async function runGit(context, args, repoPath = context.repositoryPath, envs) {
1307
+ const targetRepoPath = repoPath === null ? void 0 : repoPath;
1308
+ return await (0, client_1.runSandboxCommand)(context.connection, context.sandbox, buildGitCommand(args, targetRepoPath), {
1309
+ envs: { ...DEFAULT_GIT_ENV, ...envs ?? {} }
1310
+ });
1311
+ }
1312
+ function assertSuccessfulGitResult(context, result) {
1313
+ if (result.exitCode === 0)
1314
+ return;
1315
+ throwGitError(context, resultMessage(result));
1316
+ }
1317
+ async function getRemoteUrl(context, remote) {
1318
+ const result = await runGit(context, ["remote", "get-url", remote]);
1319
+ assertSuccessfulGitResult(context, result);
1320
+ const url = result.stdout.trim();
1321
+ if (!url)
1322
+ throwGitError(context, `Remote "${remote}" URL not found in repository.`);
1323
+ return url;
1324
+ }
1325
+ async function resolveRemoteName(context, remote) {
1326
+ if (remote)
1327
+ return remote;
1328
+ const result = await runGit(context, ["remote"]);
1329
+ assertSuccessfulGitResult(context, result);
1330
+ const remotes = result.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
1331
+ if (remotes.length === 1)
1332
+ return remotes[0];
1333
+ throwGitError(context, "Remote is required when using username/password and the repository has multiple remotes.");
1334
+ }
1335
+ async function withRemoteCredentials(context, remote, username, password, operation) {
1336
+ const originalUrl = await getRemoteUrl(context, remote);
1337
+ const credentialUrl = addCredentialsToUrl(context, originalUrl, username, password);
1338
+ assertSuccessfulGitResult(context, await runGit(context, ["remote", "set-url", remote, credentialUrl]));
1339
+ let operationResult;
1340
+ let operationError;
1341
+ try {
1342
+ operationResult = await operation();
1343
+ } catch (error) {
1344
+ operationError = error;
1345
+ }
1346
+ let restoreError;
1347
+ try {
1348
+ assertSuccessfulGitResult(context, await runGit(context, ["remote", "set-url", remote, originalUrl]));
1349
+ } catch (error) {
1350
+ restoreError = error;
1351
+ }
1352
+ if (operationError)
1353
+ throw operationError;
1354
+ if (restoreError)
1355
+ throw restoreError;
1356
+ if (!operationResult)
1357
+ throwGitError(context, "Git operation did not return a result.");
1358
+ return operationResult;
1359
+ }
1360
+ function handleAuthOrUpstreamError(context, result, action, missingPassword) {
1361
+ if (isAuthFailure(result))
1362
+ throwGitError(context, buildAuthErrorMessage(action, missingPassword));
1363
+ if ((action === "push" || action === "pull") && isMissingUpstream(result)) {
1364
+ throwGitError(context, buildUpstreamErrorMessage(action));
1365
+ }
1366
+ }
1367
+ async function status(context) {
1368
+ const gitContext = await getGitContext(context);
1369
+ const result = await runGit(gitContext, ["status", "--porcelain=1", "-b"]);
1370
+ assertSuccessfulGitResult(gitContext, result);
1371
+ const statusData = parseGitStatus(result.stdout);
1372
+ return [
1373
+ {
1374
+ json: {
1375
+ sandboxId: gitContext.sandboxId,
1376
+ repositoryPath: gitContext.repositoryPath,
1377
+ status: statusData
1378
+ },
1379
+ pairedItem: { item: context.itemIndex }
1380
+ }
1381
+ ];
1382
+ }
1383
+ async function add(context) {
1384
+ const gitContext = await getGitContext(context);
1385
+ const filesRaw = (0, helpers_12.asNonEmptyString)(context.executeFunctions.getNodeParameter("files", context.itemIndex, "."));
1386
+ const files = (0, helpers_12.splitCommaSeparated)(filesRaw);
1387
+ const addAll = !files || files.length === 1 && files[0] === ".";
1388
+ const result = await runGit(gitContext, addAll ? ["add", "-A"] : ["add", "--", ...files ?? []]);
1389
+ return [
1390
+ {
1391
+ json: (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.add", gitContext.startedAt, {
1392
+ repositoryPath: gitContext.repositoryPath,
1393
+ files: addAll ? ["."] : files
1394
+ }),
1395
+ pairedItem: { item: context.itemIndex }
1396
+ }
1397
+ ];
1398
+ }
1399
+ async function checkout(context) {
1400
+ const gitContext = await getGitContext(context);
1401
+ const gitRef = (0, helpers_12.getRequiredStringParameter)(context.executeFunctions, "gitRef", "Git Ref", context.itemIndex);
1402
+ const result = await runGit(gitContext, ["checkout", gitRef]);
1403
+ return [
1404
+ {
1405
+ json: (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.checkout", gitContext.startedAt, {
1406
+ repositoryPath: gitContext.repositoryPath,
1407
+ gitRef
1408
+ }),
1409
+ pairedItem: { item: context.itemIndex }
1410
+ }
1411
+ ];
1412
+ }
1413
+ async function clone(context) {
1414
+ const gitContext = await getGitContext(context);
1415
+ const repositoryUrl = (0, helpers_12.getRequiredStringParameter)(context.executeFunctions, "repositoryUrl", "Repository URL", context.itemIndex);
1416
+ const cloneOptions = (0, helpers_12.getCollectionParameter)(context.executeFunctions, "cloneOptions", context.itemIndex);
1417
+ const branch = (0, helpers_12.getRecordString)(cloneOptions, "branch");
1418
+ const commitId = (0, helpers_12.getRecordString)(cloneOptions, "commitId");
1419
+ const depth = (0, helpers_12.getRecordNumber)(cloneOptions, "depth");
1420
+ const username = (0, helpers_12.getRecordString)(cloneOptions, "username");
1421
+ const password = (0, helpers_12.getRecordString)(cloneOptions, "password");
1422
+ const dangerouslyStoreCredentials = (0, helpers_12.getRecordBoolean)(cloneOptions, "dangerouslyStoreCredentials") === true;
1423
+ if (password && !username) {
1424
+ throwGitError(context, "Username is required when using a password or token for git clone.");
1425
+ }
1426
+ const urlWithCreds = username && password ? addCredentialsToUrl(context, repositoryUrl, username, password) : repositoryUrl;
1427
+ const sanitizedUrl = stripCredentials(urlWithCreds);
1428
+ const shouldStripInlineCreds = !dangerouslyStoreCredentials && sanitizedUrl !== urlWithCreds;
1429
+ const args = ["clone", urlWithCreds];
1430
+ if (branch)
1431
+ args.push("--branch", branch, "--single-branch");
1432
+ if (depth)
1433
+ args.push("--depth", depth.toString());
1434
+ args.push(gitContext.repositoryPath);
1435
+ const result = await runGit(gitContext, args, null);
1436
+ handleAuthOrUpstreamError(gitContext, result, "clone", Boolean(username) && !password);
1437
+ if (shouldStripInlineCreds && result.exitCode === 0) {
1438
+ assertSuccessfulGitResult(gitContext, await runGit(gitContext, ["remote", "set-url", "origin", sanitizedUrl]));
1439
+ }
1440
+ const resultData = (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.clone", gitContext.startedAt, {
1441
+ repositoryPath: gitContext.repositoryPath,
1442
+ repositoryUrl,
1443
+ branch,
1444
+ depth
1445
+ });
1446
+ if (commitId) {
1447
+ const checkoutResult = await runGit(gitContext, ["checkout", commitId]);
1448
+ resultData.checkout = {
1449
+ success: checkoutResult.exitCode === 0,
1450
+ exitCode: checkoutResult.exitCode,
1451
+ stdout: checkoutResult.stdout,
1452
+ stderr: checkoutResult.stderr,
1453
+ error: checkoutResult.error,
1454
+ commitId
1455
+ };
1456
+ resultData.success = result.exitCode === 0 && checkoutResult.exitCode === 0;
1457
+ }
1458
+ return [
1459
+ {
1460
+ json: resultData,
1461
+ pairedItem: { item: context.itemIndex }
1462
+ }
1463
+ ];
1464
+ }
1465
+ async function commit(context) {
1466
+ const gitContext = await getGitContext(context);
1467
+ const message = (0, helpers_12.getRequiredStringParameter)(context.executeFunctions, "message", "Message", context.itemIndex);
1468
+ const commitOptions = (0, helpers_12.getCollectionParameter)(context.executeFunctions, "commitOptions", context.itemIndex);
1469
+ const authorName = (0, helpers_12.asNonEmptyString)(context.executeFunctions.getNodeParameter("authorName", context.itemIndex, ""));
1470
+ const authorEmail = (0, helpers_12.asNonEmptyString)(context.executeFunctions.getNodeParameter("authorEmail", context.itemIndex, ""));
1471
+ const allowEmpty = (0, helpers_12.getRecordBoolean)(commitOptions, "allowEmpty") === true;
1472
+ const args = ["commit", "-m", message];
1473
+ if (allowEmpty)
1474
+ args.push("--allow-empty");
1475
+ const authorArgs = [];
1476
+ if (authorName)
1477
+ authorArgs.push("-c", `user.name=${authorName}`);
1478
+ if (authorEmail)
1479
+ authorArgs.push("-c", `user.email=${authorEmail}`);
1480
+ const result = await runGit(gitContext, [...authorArgs, ...args]);
1481
+ return [
1482
+ {
1483
+ json: (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.commit", gitContext.startedAt, {
1484
+ repositoryPath: gitContext.repositoryPath,
1485
+ message,
1486
+ authorName,
1487
+ authorEmail,
1488
+ allowEmpty
1489
+ }),
1490
+ pairedItem: { item: context.itemIndex }
1491
+ }
1492
+ ];
1493
+ }
1494
+ async function pull(context) {
1495
+ const gitContext = await getGitContext(context);
1496
+ const remoteOptions = (0, helpers_12.getCollectionParameter)(context.executeFunctions, "remoteOptions", context.itemIndex);
1497
+ const remote = (0, helpers_12.getRecordString)(remoteOptions, "remote");
1498
+ const branch = (0, helpers_12.getRecordString)(remoteOptions, "branch");
1499
+ const username = (0, helpers_12.getRecordString)(remoteOptions, "username");
1500
+ const password = (0, helpers_12.getRecordString)(remoteOptions, "password");
1501
+ if (password && !username) {
1502
+ throwGitError(context, "Username is required when using a password or token for git pull.");
1503
+ }
1504
+ if (!remote && !branch) {
1505
+ const hasUpstream = await runGit(gitContext, [
1506
+ "rev-parse",
1507
+ "--abbrev-ref",
1508
+ "--symbolic-full-name",
1509
+ "@{u}"
1510
+ ]);
1511
+ if (hasUpstream.exitCode !== 0 || hasUpstream.stdout.trim().length === 0) {
1512
+ throwGitError(gitContext, buildUpstreamErrorMessage("pull"));
1513
+ }
1514
+ }
1515
+ const args = ["pull"];
1516
+ if (remote)
1517
+ args.push(remote);
1518
+ if (branch)
1519
+ args.push(branch);
1520
+ const result = username && password ? await withRemoteCredentials(gitContext, await resolveRemoteName(gitContext, remote), username, password, async () => await runGit(gitContext, args)) : await runGit(gitContext, args);
1521
+ handleAuthOrUpstreamError(gitContext, result, "pull", Boolean(username) && !password);
1522
+ return [
1523
+ {
1524
+ json: (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.pull", gitContext.startedAt, {
1525
+ repositoryPath: gitContext.repositoryPath,
1526
+ remote,
1527
+ branch
1528
+ }),
1529
+ pairedItem: { item: context.itemIndex }
1530
+ }
1531
+ ];
1532
+ }
1533
+ async function push(context) {
1534
+ const gitContext = await getGitContext(context);
1535
+ const remoteOptions = (0, helpers_12.getCollectionParameter)(context.executeFunctions, "remoteOptions", context.itemIndex);
1536
+ const remote = (0, helpers_12.getRecordString)(remoteOptions, "remote");
1537
+ const branch = (0, helpers_12.getRecordString)(remoteOptions, "branch");
1538
+ const setUpstream = (0, helpers_12.getRecordBoolean)(remoteOptions, "setUpstream") === true;
1539
+ const username = (0, helpers_12.getRecordString)(remoteOptions, "username");
1540
+ const password = (0, helpers_12.getRecordString)(remoteOptions, "password");
1541
+ if (password && !username) {
1542
+ throwGitError(context, "Username is required when using a password or token for git push.");
1543
+ }
1544
+ const args = buildPushArgs(remote, branch, setUpstream);
1545
+ let result;
1546
+ if (username && password) {
1547
+ const remoteName = await resolveRemoteName(gitContext, remote);
1548
+ result = await withRemoteCredentials(gitContext, remoteName, username, password, async () => await runGit(gitContext, buildPushArgs(remoteName, branch, setUpstream)));
1549
+ } else {
1550
+ result = await runGit(gitContext, args);
1551
+ }
1552
+ handleAuthOrUpstreamError(gitContext, result, "push", Boolean(username) && !password);
1553
+ return [
1554
+ {
1555
+ json: (0, helpers_12.toOperationCommandResultData)(result, gitContext.sandboxId, "git.push", gitContext.startedAt, {
1556
+ repositoryPath: gitContext.repositoryPath,
1557
+ remote,
1558
+ branch,
1559
+ setUpstream
1560
+ }),
1561
+ pairedItem: { item: context.itemIndex }
1562
+ }
1563
+ ];
1564
+ }
1565
+ }
1566
+ });
1567
+
1568
+ // dist/nodes/E2B/actions/sandbox.operations.js
1569
+ var require_sandbox_operations = __commonJS({
1570
+ "dist/nodes/E2B/actions/sandbox.operations.js"(exports2) {
1571
+ "use strict";
1572
+ Object.defineProperty(exports2, "__esModule", { value: true });
1573
+ exports2.create = create;
1574
+ exports2.get = get;
1575
+ exports2.getMany = getMany;
1576
+ exports2.getPreviewUrl = getPreviewUrl;
1577
+ exports2.kill = kill;
1578
+ exports2.pause = pause;
1579
+ var client_1 = require_client();
1580
+ var helpers_12 = require_helpers();
1581
+ async function create(context) {
1582
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1583
+ const connection = { executeFunctions, credentials, timeoutMs };
1584
+ const sandbox = await (0, client_1.createSandbox)(connection, (0, helpers_12.getSandboxCreateOptions)(executeFunctions, itemIndex));
1585
+ const info = await (0, client_1.getSandboxInfo)(connection, sandbox.sandboxId);
1586
+ return [
1587
+ {
1588
+ json: (0, helpers_12.toSandboxInfoData)(info, sandbox.sandboxDomain),
1589
+ pairedItem: { item: itemIndex }
1590
+ }
1591
+ ];
1592
+ }
1593
+ async function get(context) {
1594
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1595
+ const connection = { executeFunctions, credentials, timeoutMs };
1596
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1597
+ const info = await (0, client_1.getSandboxInfo)(connection, sandboxId);
1598
+ return [
1599
+ {
1600
+ json: (0, helpers_12.toSandboxInfoData)(info),
1601
+ pairedItem: { item: itemIndex }
1602
+ }
1603
+ ];
1604
+ }
1605
+ async function getMany(context) {
1606
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1607
+ const connection = { executeFunctions, credentials, timeoutMs };
1608
+ const sandboxes = await (0, client_1.listSandboxes)(connection, (0, helpers_12.getLimit)(executeFunctions, itemIndex));
1609
+ return sandboxes.map((sandbox) => ({
1610
+ json: (0, helpers_12.toSandboxInfoData)(sandbox),
1611
+ pairedItem: { item: itemIndex }
1612
+ }));
1613
+ }
1614
+ async function getPreviewUrl(context) {
1615
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1616
+ const connection = { executeFunctions, credentials, timeoutMs };
1617
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1618
+ const port = (0, helpers_12.getPort)(executeFunctions, itemIndex);
1619
+ const sandbox = await (0, client_1.connectSandbox)(connection, sandboxId);
1620
+ const host = (0, client_1.getPreviewHost)(connection, sandbox, port);
1621
+ return [
1622
+ {
1623
+ json: {
1624
+ sandboxId,
1625
+ port,
1626
+ host,
1627
+ url: `https://${host}`
1628
+ },
1629
+ pairedItem: { item: itemIndex }
1630
+ }
1631
+ ];
1632
+ }
1633
+ async function kill(context) {
1634
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1635
+ const connection = { executeFunctions, credentials, timeoutMs };
1636
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1637
+ const killed = await (0, client_1.killSandbox)(connection, sandboxId);
1638
+ return [
1639
+ {
1640
+ json: {
1641
+ sandboxId,
1642
+ killed
1643
+ },
1644
+ pairedItem: { item: itemIndex }
1645
+ }
1646
+ ];
1647
+ }
1648
+ async function pause(context) {
1649
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1650
+ const connection = { executeFunctions, credentials, timeoutMs };
1651
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1652
+ const paused = await (0, client_1.pauseSandbox)(connection, sandboxId);
1653
+ return [
1654
+ {
1655
+ json: {
1656
+ sandboxId,
1657
+ paused
1658
+ },
1659
+ pairedItem: { item: itemIndex }
1660
+ }
1661
+ ];
1662
+ }
1663
+ }
1664
+ });
1665
+
1666
+ // dist/nodes/E2B/actions/snapshot.operations.js
1667
+ var require_snapshot_operations = __commonJS({
1668
+ "dist/nodes/E2B/actions/snapshot.operations.js"(exports2) {
1669
+ "use strict";
1670
+ Object.defineProperty(exports2, "__esModule", { value: true });
1671
+ exports2.create = create;
1672
+ exports2.getMany = getMany;
1673
+ exports2.deleteSnapshot = deleteSnapshot;
1674
+ var client_1 = require_client();
1675
+ var helpers_12 = require_helpers();
1676
+ async function create(context) {
1677
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1678
+ const connection = { executeFunctions, credentials, timeoutMs };
1679
+ const sandboxId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "sandboxId", "Sandbox ID", itemIndex);
1680
+ const snapshotName = (0, helpers_12.asNonEmptyString)(executeFunctions.getNodeParameter("snapshotName", itemIndex, ""));
1681
+ const snapshot = await (0, client_1.createSnapshot)(connection, sandboxId, snapshotName);
1682
+ return [
1683
+ {
1684
+ json: (0, helpers_12.toSnapshotInfoData)(snapshot),
1685
+ pairedItem: { item: itemIndex }
1686
+ }
1687
+ ];
1688
+ }
1689
+ async function getMany(context) {
1690
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1691
+ const connection = { executeFunctions, credentials, timeoutMs };
1692
+ const sandboxId = (0, helpers_12.asNonEmptyString)(executeFunctions.getNodeParameter("sandboxId", itemIndex, ""));
1693
+ const snapshots = await (0, client_1.listSnapshots)(connection, (0, helpers_12.getLimit)(executeFunctions, itemIndex), sandboxId);
1694
+ return snapshots.map((snapshot) => ({
1695
+ json: (0, helpers_12.toSnapshotInfoData)(snapshot),
1696
+ pairedItem: { item: itemIndex }
1697
+ }));
1698
+ }
1699
+ async function deleteSnapshot(context) {
1700
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1701
+ const connection = { executeFunctions, credentials, timeoutMs };
1702
+ const snapshotId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "snapshotId", "Snapshot ID", itemIndex);
1703
+ const deleted = await (0, client_1.deleteSnapshot)(connection, snapshotId);
1704
+ return [
1705
+ {
1706
+ json: {
1707
+ snapshotId,
1708
+ deleted
1709
+ },
1710
+ pairedItem: { item: itemIndex }
1711
+ }
1712
+ ];
1713
+ }
1714
+ }
1715
+ });
1716
+
1717
+ // dist/nodes/E2B/actions/volume.operations.js
1718
+ var require_volume_operations = __commonJS({
1719
+ "dist/nodes/E2B/actions/volume.operations.js"(exports2) {
1720
+ "use strict";
1721
+ Object.defineProperty(exports2, "__esModule", { value: true });
1722
+ exports2.create = create;
1723
+ exports2.get = get;
1724
+ exports2.getMany = getMany;
1725
+ exports2.deleteVolume = deleteVolume;
1726
+ var client_1 = require_client();
1727
+ var helpers_12 = require_helpers();
1728
+ async function create(context) {
1729
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1730
+ const connection = { executeFunctions, credentials, timeoutMs };
1731
+ const name = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "volumeName", "Volume Name", itemIndex);
1732
+ const volume = await (0, client_1.createVolume)(connection, name);
1733
+ return [
1734
+ {
1735
+ json: (0, helpers_12.toVolumeInfoData)(volume),
1736
+ pairedItem: { item: itemIndex }
1737
+ }
1738
+ ];
1739
+ }
1740
+ async function get(context) {
1741
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1742
+ const connection = { executeFunctions, credentials, timeoutMs };
1743
+ const volumeId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "volumeId", "Volume ID", itemIndex);
1744
+ const volume = await (0, client_1.getVolume)(connection, volumeId);
1745
+ return [
1746
+ {
1747
+ json: (0, helpers_12.toVolumeInfoData)(volume),
1748
+ pairedItem: { item: itemIndex }
1749
+ }
1750
+ ];
1751
+ }
1752
+ async function getMany(context) {
1753
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1754
+ const connection = { executeFunctions, credentials, timeoutMs };
1755
+ const volumes = await (0, client_1.listVolumes)(connection);
1756
+ return volumes.slice(0, (0, helpers_12.getLimit)(executeFunctions, itemIndex)).map((volume) => ({
1757
+ json: (0, helpers_12.toVolumeInfoData)(volume),
1758
+ pairedItem: { item: itemIndex }
1759
+ }));
1760
+ }
1761
+ async function deleteVolume(context) {
1762
+ const { executeFunctions, credentials, itemIndex, timeoutMs } = context;
1763
+ const connection = { executeFunctions, credentials, timeoutMs };
1764
+ const volumeId = (0, helpers_12.getRequiredStringParameter)(executeFunctions, "volumeId", "Volume ID", itemIndex);
1765
+ const deleted = await (0, client_1.deleteVolume)(connection, volumeId);
1766
+ return [
1767
+ {
1768
+ json: {
1769
+ volumeId,
1770
+ deleted
1771
+ },
1772
+ pairedItem: { item: itemIndex }
1773
+ }
1774
+ ];
1775
+ }
1776
+ }
1777
+ });
1778
+
1779
+ // dist/nodes/E2B/actions/index.js
1780
+ var require_actions = __commonJS({
1781
+ "dist/nodes/E2B/actions/index.js"(exports2) {
1782
+ "use strict";
1783
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
1784
+ if (k2 === void 0) k2 = k;
1785
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1786
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1787
+ desc = { enumerable: true, get: function() {
1788
+ return m[k];
1789
+ } };
1790
+ }
1791
+ Object.defineProperty(o, k2, desc);
1792
+ }) : (function(o, m, k, k2) {
1793
+ if (k2 === void 0) k2 = k;
1794
+ o[k2] = m[k];
1795
+ }));
1796
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
1797
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1798
+ }) : function(o, v) {
1799
+ o["default"] = v;
1800
+ });
1801
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
1802
+ var ownKeys = function(o) {
1803
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1804
+ var ar = [];
1805
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1806
+ return ar;
1807
+ };
1808
+ return ownKeys(o);
1809
+ };
1810
+ return function(mod) {
1811
+ if (mod && mod.__esModule) return mod;
1812
+ var result = {};
1813
+ if (mod != null) {
1814
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1815
+ }
1816
+ __setModuleDefault(result, mod);
1817
+ return result;
1818
+ };
1819
+ })();
1820
+ Object.defineProperty(exports2, "__esModule", { value: true });
1821
+ exports2.getOperationHandler = getOperationHandler;
1822
+ var code = __importStar(require_code_operations());
1823
+ var file = __importStar(require_file_operations());
1824
+ var git = __importStar(require_git_operations());
1825
+ var sandbox = __importStar(require_sandbox_operations());
1826
+ var snapshot = __importStar(require_snapshot_operations());
1827
+ var volume = __importStar(require_volume_operations());
1828
+ var operationHandlers = {
1829
+ code: {
1830
+ runCommand: code.runCommand
1831
+ },
1832
+ file: {
1833
+ createFolder: file.createFolder,
1834
+ delete: file.deleteFile,
1835
+ download: file.download,
1836
+ info: file.info,
1837
+ list: file.list,
1838
+ move: file.move,
1839
+ read: file.read,
1840
+ upload: file.upload,
1841
+ write: file.write
1842
+ },
1843
+ git: {
1844
+ add: git.add,
1845
+ checkout: git.checkout,
1846
+ clone: git.clone,
1847
+ commit: git.commit,
1848
+ pull: git.pull,
1849
+ push: git.push,
1850
+ status: git.status
1851
+ },
1852
+ sandbox: {
1853
+ create: sandbox.create,
1854
+ get: sandbox.get,
1855
+ getMany: sandbox.getMany,
1856
+ getPreviewUrl: sandbox.getPreviewUrl,
1857
+ kill: sandbox.kill,
1858
+ pause: sandbox.pause
1859
+ },
1860
+ snapshot: {
1861
+ create: snapshot.create,
1862
+ delete: snapshot.deleteSnapshot,
1863
+ getMany: snapshot.getMany
1864
+ },
1865
+ volume: {
1866
+ create: volume.create,
1867
+ delete: volume.deleteVolume,
1868
+ get: volume.get,
1869
+ getMany: volume.getMany
1870
+ }
1871
+ };
1872
+ function getOperationHandler(resource, operation) {
1873
+ const resourceHandlers = operationHandlers[resource];
1874
+ const handler = resourceHandlers[operation];
1875
+ if (!handler) {
1876
+ throw new Error(`Operation "${operation}" is not implemented for resource "${resource}"`);
1877
+ }
1878
+ return handler;
1879
+ }
1880
+ }
1881
+ });
1882
+
1883
+ // dist/nodes/E2B/types.js
1884
+ var require_types = __commonJS({
1885
+ "dist/nodes/E2B/types.js"(exports2) {
1886
+ "use strict";
1887
+ Object.defineProperty(exports2, "__esModule", { value: true });
1888
+ exports2.RESOURCE_OPERATIONS = void 0;
1889
+ exports2.isResource = isResource;
1890
+ exports2.isOperationForResource = isOperationForResource;
1891
+ exports2.RESOURCE_OPERATIONS = {
1892
+ code: ["runCommand"],
1893
+ file: ["createFolder", "delete", "download", "info", "list", "move", "read", "upload", "write"],
1894
+ git: ["add", "checkout", "clone", "commit", "pull", "push", "status"],
1895
+ sandbox: ["create", "get", "getMany", "getPreviewUrl", "kill", "pause"],
1896
+ snapshot: ["create", "delete", "getMany"],
1897
+ volume: ["create", "delete", "get", "getMany"]
1898
+ };
1899
+ function isResource(value) {
1900
+ return typeof value === "string" && value in exports2.RESOURCE_OPERATIONS;
1901
+ }
1902
+ function isOperationForResource(resource, value) {
1903
+ return typeof value === "string" && exports2.RESOURCE_OPERATIONS[resource].some((operation) => operation === value);
1904
+ }
1905
+ }
1906
+ });
1907
+
1908
+ // dist/nodes/E2B/E2b.node.js
1909
+ Object.defineProperty(exports, "__esModule", { value: true });
1910
+ exports.E2b = void 0;
1911
+ var n8n_workflow_1 = require("n8n-workflow");
1912
+ var actions_1 = require_actions();
1913
+ var helpers_1 = require_helpers();
1914
+ var types_1 = require_types();
1915
+ var E2b = class {
1916
+ description = {
1917
+ displayName: "E2B",
1918
+ name: "e2b",
1919
+ icon: {
1920
+ light: "file:e2b.svg",
1921
+ dark: "file:e2b.dark.svg"
1922
+ },
1923
+ group: ["transform"],
1924
+ version: 1,
1925
+ subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
1926
+ description: "Run commands and manage E2B sandboxes and snapshots",
1927
+ defaults: {
1928
+ name: "E2B"
1929
+ },
1930
+ usableAsTool: true,
1931
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
1932
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
1933
+ credentials: [
1934
+ {
1935
+ name: "e2bApi",
1936
+ required: true
1937
+ }
1938
+ ],
1939
+ properties: [
1940
+ {
1941
+ displayName: "Resource",
1942
+ name: "resource",
1943
+ type: "options",
1944
+ noDataExpression: true,
1945
+ options: [
1946
+ {
1947
+ name: "Code",
1948
+ value: "code"
1949
+ },
1950
+ {
1951
+ name: "File",
1952
+ value: "file"
1953
+ },
1954
+ {
1955
+ name: "Git",
1956
+ value: "git"
1957
+ },
1958
+ {
1959
+ name: "Sandbox",
1960
+ value: "sandbox"
1961
+ },
1962
+ {
1963
+ name: "Snapshot",
1964
+ value: "snapshot"
1965
+ },
1966
+ {
1967
+ name: "Volume",
1968
+ value: "volume"
1969
+ }
1970
+ ],
1971
+ default: "code"
1972
+ },
1973
+ {
1974
+ displayName: "Operation",
1975
+ name: "operation",
1976
+ type: "options",
1977
+ noDataExpression: true,
1978
+ displayOptions: {
1979
+ show: {
1980
+ resource: ["code"]
1981
+ }
1982
+ },
1983
+ options: [
1984
+ {
1985
+ name: "Run Command",
1986
+ value: "runCommand",
1987
+ action: "Run a command in a sandbox",
1988
+ description: "Run a shell command in an existing sandbox, or create a temporary sandbox for this execution"
1989
+ }
1990
+ ],
1991
+ default: "runCommand"
1992
+ },
1993
+ {
1994
+ displayName: "Operation",
1995
+ name: "operation",
1996
+ type: "options",
1997
+ noDataExpression: true,
1998
+ displayOptions: {
1999
+ show: {
2000
+ resource: ["file"]
2001
+ }
2002
+ },
2003
+ options: [
2004
+ {
2005
+ name: "Create Folder",
2006
+ value: "createFolder",
2007
+ action: "Create a folder in a sandbox",
2008
+ description: "Create a directory inside an E2B sandbox"
2009
+ },
2010
+ {
2011
+ name: "Delete",
2012
+ value: "delete",
2013
+ action: "Delete a file or folder in a sandbox",
2014
+ description: "Delete a file or directory inside an E2B sandbox"
2015
+ },
2016
+ {
2017
+ name: "Download",
2018
+ value: "download",
2019
+ action: "Download a file from a sandbox",
2020
+ description: "Read a sandbox file and return it as binary data"
2021
+ },
2022
+ {
2023
+ name: "Get Info",
2024
+ value: "info",
2025
+ action: "Get file info in a sandbox",
2026
+ description: "Get metadata for a file or directory inside an E2B sandbox"
2027
+ },
2028
+ {
2029
+ name: "List",
2030
+ value: "list",
2031
+ action: "List files in a sandbox",
2032
+ description: "List files and directories under a sandbox path"
2033
+ },
2034
+ {
2035
+ name: "Move",
2036
+ value: "move",
2037
+ action: "Move a file or folder in a sandbox",
2038
+ description: "Move or rename a file or directory inside an E2B sandbox"
2039
+ },
2040
+ {
2041
+ name: "Read",
2042
+ value: "read",
2043
+ action: "Read a text file from a sandbox",
2044
+ description: "Read a sandbox file as text"
2045
+ },
2046
+ {
2047
+ name: "Upload",
2048
+ value: "upload",
2049
+ action: "Upload a file to a sandbox",
2050
+ description: "Write input binary data to a sandbox file"
2051
+ },
2052
+ {
2053
+ name: "Write",
2054
+ value: "write",
2055
+ action: "Write text to a sandbox file",
2056
+ description: "Write text content to a file inside an E2B sandbox"
2057
+ }
2058
+ ],
2059
+ default: "write"
2060
+ },
2061
+ {
2062
+ displayName: "Operation",
2063
+ name: "operation",
2064
+ type: "options",
2065
+ noDataExpression: true,
2066
+ displayOptions: {
2067
+ show: {
2068
+ resource: ["git"]
2069
+ }
2070
+ },
2071
+ options: [
2072
+ {
2073
+ name: "Add",
2074
+ value: "add",
2075
+ action: "Stage files in a sandbox repository",
2076
+ description: "Stage files for the next commit"
2077
+ },
2078
+ {
2079
+ name: "Checkout",
2080
+ value: "checkout",
2081
+ action: "Check out a git ref in a sandbox",
2082
+ description: "Check out a branch, tag, or commit in a sandbox repository"
2083
+ },
2084
+ {
2085
+ name: "Clone",
2086
+ value: "clone",
2087
+ action: "Clone a repository into a sandbox",
2088
+ description: "Clone a git repository into an E2B sandbox"
2089
+ },
2090
+ {
2091
+ name: "Commit",
2092
+ value: "commit",
2093
+ action: "Commit staged files in a sandbox repository",
2094
+ description: "Create a git commit from staged changes"
2095
+ },
2096
+ {
2097
+ name: "Pull",
2098
+ value: "pull",
2099
+ action: "Pull changes in a sandbox repository",
2100
+ description: "Pull changes from the configured remote"
2101
+ },
2102
+ {
2103
+ name: "Push",
2104
+ value: "push",
2105
+ action: "Push changes from a sandbox repository",
2106
+ description: "Push commits to the configured remote"
2107
+ },
2108
+ {
2109
+ name: "Status",
2110
+ value: "status",
2111
+ action: "Get git status in a sandbox repository",
2112
+ description: "Return parsed git status for a repository"
2113
+ }
2114
+ ],
2115
+ default: "status"
2116
+ },
2117
+ {
2118
+ displayName: "Operation",
2119
+ name: "operation",
2120
+ type: "options",
2121
+ noDataExpression: true,
2122
+ displayOptions: {
2123
+ show: {
2124
+ resource: ["sandbox"]
2125
+ }
2126
+ },
2127
+ options: [
2128
+ {
2129
+ name: "Create",
2130
+ value: "create",
2131
+ action: "Create a sandbox",
2132
+ description: "Create a new E2B sandbox"
2133
+ },
2134
+ {
2135
+ name: "Get",
2136
+ value: "get",
2137
+ action: "Get a sandbox",
2138
+ description: "Retrieve a sandbox by ID"
2139
+ },
2140
+ {
2141
+ name: "Get Many",
2142
+ value: "getMany",
2143
+ action: "Get many sandboxes",
2144
+ description: "List running E2B sandboxes"
2145
+ },
2146
+ {
2147
+ name: "Get Preview URL",
2148
+ value: "getPreviewUrl",
2149
+ action: "Get a sandbox preview URL",
2150
+ description: "Get an external URL for a port exposed inside a sandbox"
2151
+ },
2152
+ {
2153
+ name: "Kill",
2154
+ value: "kill",
2155
+ action: "Kill a sandbox",
2156
+ description: "Kill a sandbox by ID"
2157
+ },
2158
+ {
2159
+ name: "Pause",
2160
+ value: "pause",
2161
+ action: "Pause a sandbox",
2162
+ description: "Pause a sandbox by ID"
2163
+ }
2164
+ ],
2165
+ default: "getMany"
2166
+ },
2167
+ {
2168
+ displayName: "Operation",
2169
+ name: "operation",
2170
+ type: "options",
2171
+ noDataExpression: true,
2172
+ displayOptions: {
2173
+ show: {
2174
+ resource: ["snapshot"]
2175
+ }
2176
+ },
2177
+ options: [
2178
+ {
2179
+ name: "Create",
2180
+ value: "create",
2181
+ action: "Create a snapshot",
2182
+ description: "Create a snapshot from a sandbox"
2183
+ },
2184
+ {
2185
+ name: "Delete",
2186
+ value: "delete",
2187
+ action: "Delete a snapshot",
2188
+ description: "Delete a snapshot by ID"
2189
+ },
2190
+ {
2191
+ name: "Get Many",
2192
+ value: "getMany",
2193
+ action: "Get many snapshots",
2194
+ description: "List E2B snapshots"
2195
+ }
2196
+ ],
2197
+ default: "getMany"
2198
+ },
2199
+ {
2200
+ displayName: "Operation",
2201
+ name: "operation",
2202
+ type: "options",
2203
+ noDataExpression: true,
2204
+ displayOptions: {
2205
+ show: {
2206
+ resource: ["volume"]
2207
+ }
2208
+ },
2209
+ options: [
2210
+ {
2211
+ name: "Create",
2212
+ value: "create",
2213
+ action: "Create a volume",
2214
+ description: "Create a persistent E2B volume"
2215
+ },
2216
+ {
2217
+ name: "Delete",
2218
+ value: "delete",
2219
+ action: "Delete a volume",
2220
+ description: "Delete a persistent E2B volume"
2221
+ },
2222
+ {
2223
+ name: "Get",
2224
+ value: "get",
2225
+ action: "Get a volume",
2226
+ description: "Retrieve a persistent E2B volume by ID"
2227
+ },
2228
+ {
2229
+ name: "Get Many",
2230
+ value: "getMany",
2231
+ action: "Get many volumes",
2232
+ description: "List persistent E2B volumes"
2233
+ }
2234
+ ],
2235
+ default: "getMany"
2236
+ },
2237
+ {
2238
+ displayName: "Sandbox ID",
2239
+ name: "sandboxId",
2240
+ type: "string",
2241
+ required: true,
2242
+ default: "",
2243
+ displayOptions: {
2244
+ show: {
2245
+ resource: ["sandbox"],
2246
+ operation: ["get", "getPreviewUrl", "kill", "pause"]
2247
+ }
2248
+ }
2249
+ },
2250
+ {
2251
+ displayName: "Sandbox ID",
2252
+ name: "sandboxId",
2253
+ type: "string",
2254
+ required: true,
2255
+ default: "",
2256
+ description: "Source sandbox ID to snapshot",
2257
+ displayOptions: {
2258
+ show: {
2259
+ resource: ["snapshot"],
2260
+ operation: ["create"]
2261
+ }
2262
+ }
2263
+ },
2264
+ {
2265
+ displayName: "Snapshot ID",
2266
+ name: "snapshotId",
2267
+ type: "string",
2268
+ required: true,
2269
+ default: "",
2270
+ displayOptions: {
2271
+ show: {
2272
+ resource: ["snapshot"],
2273
+ operation: ["delete"]
2274
+ }
2275
+ }
2276
+ },
2277
+ {
2278
+ displayName: "Sandbox ID",
2279
+ name: "sandboxId",
2280
+ type: "string",
2281
+ default: "",
2282
+ description: "Existing sandbox ID. Leave empty to create a sandbox for this command.",
2283
+ displayOptions: {
2284
+ show: {
2285
+ resource: ["code"],
2286
+ operation: ["runCommand"]
2287
+ }
2288
+ }
2289
+ },
2290
+ {
2291
+ displayName: "Sandbox ID",
2292
+ name: "sandboxId",
2293
+ type: "string",
2294
+ default: "",
2295
+ description: "Optional source sandbox ID to filter snapshots by",
2296
+ displayOptions: {
2297
+ show: {
2298
+ resource: ["snapshot"],
2299
+ operation: ["getMany"]
2300
+ }
2301
+ }
2302
+ },
2303
+ {
2304
+ displayName: "Sandbox ID",
2305
+ name: "sandboxId",
2306
+ type: "string",
2307
+ required: true,
2308
+ default: "",
2309
+ description: "ID of the sandbox to work with",
2310
+ displayOptions: {
2311
+ show: {
2312
+ resource: ["file", "git"]
2313
+ }
2314
+ }
2315
+ },
2316
+ {
2317
+ displayName: "Port",
2318
+ name: "port",
2319
+ type: "number",
2320
+ required: true,
2321
+ default: 3e3,
2322
+ typeOptions: {
2323
+ minValue: 1,
2324
+ maxValue: 65535
2325
+ },
2326
+ description: "Port inside the sandbox to expose",
2327
+ displayOptions: {
2328
+ show: {
2329
+ resource: ["sandbox"],
2330
+ operation: ["getPreviewUrl"]
2331
+ }
2332
+ }
2333
+ },
2334
+ {
2335
+ displayName: "Path",
2336
+ name: "path",
2337
+ type: "string",
2338
+ required: true,
2339
+ default: "",
2340
+ placeholder: "/home/user/project",
2341
+ description: "Path inside the sandbox",
2342
+ displayOptions: {
2343
+ show: {
2344
+ resource: ["file"],
2345
+ operation: ["createFolder", "delete", "info", "list", "read", "write"]
2346
+ }
2347
+ }
2348
+ },
2349
+ {
2350
+ displayName: "Remote Path",
2351
+ name: "remotePath",
2352
+ type: "string",
2353
+ required: true,
2354
+ default: "",
2355
+ placeholder: "/home/user/file.txt",
2356
+ description: "File path inside the sandbox",
2357
+ displayOptions: {
2358
+ show: {
2359
+ resource: ["file"],
2360
+ operation: ["download", "upload"]
2361
+ }
2362
+ }
2363
+ },
2364
+ {
2365
+ displayName: "Content",
2366
+ name: "content",
2367
+ type: "string",
2368
+ required: true,
2369
+ default: "",
2370
+ typeOptions: {
2371
+ rows: 8
2372
+ },
2373
+ description: "Text content to write to the sandbox file",
2374
+ displayOptions: {
2375
+ show: {
2376
+ resource: ["file"],
2377
+ operation: ["write"]
2378
+ }
2379
+ }
2380
+ },
2381
+ {
2382
+ displayName: "Source",
2383
+ name: "source",
2384
+ type: "string",
2385
+ required: true,
2386
+ default: "",
2387
+ placeholder: "/home/user/old-name.txt",
2388
+ description: "Source path inside the sandbox",
2389
+ displayOptions: {
2390
+ show: {
2391
+ resource: ["file"],
2392
+ operation: ["move"]
2393
+ }
2394
+ }
2395
+ },
2396
+ {
2397
+ displayName: "Destination",
2398
+ name: "destination",
2399
+ type: "string",
2400
+ required: true,
2401
+ default: "",
2402
+ placeholder: "/home/user/new-name.txt",
2403
+ description: "Destination path inside the sandbox",
2404
+ displayOptions: {
2405
+ show: {
2406
+ resource: ["file"],
2407
+ operation: ["move"]
2408
+ }
2409
+ }
2410
+ },
2411
+ {
2412
+ displayName: "Depth",
2413
+ name: "depth",
2414
+ type: "number",
2415
+ typeOptions: {
2416
+ minValue: 1
2417
+ },
2418
+ default: 1,
2419
+ description: "Directory depth to list",
2420
+ displayOptions: {
2421
+ show: {
2422
+ resource: ["file"],
2423
+ operation: ["list"]
2424
+ }
2425
+ }
2426
+ },
2427
+ {
2428
+ displayName: "Binary Field",
2429
+ name: "binaryPropertyName",
2430
+ type: "string",
2431
+ required: true,
2432
+ default: "data",
2433
+ description: "Name of the binary field to read from or write to",
2434
+ displayOptions: {
2435
+ show: {
2436
+ resource: ["file"],
2437
+ operation: ["download", "upload"]
2438
+ }
2439
+ }
2440
+ },
2441
+ {
2442
+ displayName: "Repository URL",
2443
+ name: "repositoryUrl",
2444
+ type: "string",
2445
+ required: true,
2446
+ default: "",
2447
+ placeholder: "https://github.com/owner/repo.git",
2448
+ description: "Git repository URL to clone",
2449
+ displayOptions: {
2450
+ show: {
2451
+ resource: ["git"],
2452
+ operation: ["clone"]
2453
+ }
2454
+ }
2455
+ },
2456
+ {
2457
+ displayName: "Repository Path",
2458
+ name: "repositoryPath",
2459
+ type: "string",
2460
+ required: true,
2461
+ default: "",
2462
+ placeholder: "/home/user/repo",
2463
+ description: "Path to the git repository inside the sandbox",
2464
+ displayOptions: {
2465
+ show: {
2466
+ resource: ["git"]
2467
+ }
2468
+ }
2469
+ },
2470
+ {
2471
+ displayName: "Files",
2472
+ name: "files",
2473
+ type: "string",
2474
+ default: ".",
2475
+ placeholder: ". or README.md,src/index.ts",
2476
+ description: 'Comma-separated list of files to stage. Use "." to stage all changes.',
2477
+ displayOptions: {
2478
+ show: {
2479
+ resource: ["git"],
2480
+ operation: ["add"]
2481
+ }
2482
+ }
2483
+ },
2484
+ {
2485
+ displayName: "Git Ref",
2486
+ name: "gitRef",
2487
+ type: "string",
2488
+ required: true,
2489
+ default: "",
2490
+ placeholder: "main, feature/new-thing, or a commit SHA",
2491
+ description: "Branch, tag, or commit SHA to check out",
2492
+ displayOptions: {
2493
+ show: {
2494
+ resource: ["git"],
2495
+ operation: ["checkout"]
2496
+ }
2497
+ }
2498
+ },
2499
+ {
2500
+ displayName: "Message",
2501
+ name: "message",
2502
+ type: "string",
2503
+ required: true,
2504
+ default: "",
2505
+ typeOptions: {
2506
+ rows: 3
2507
+ },
2508
+ description: "Commit message",
2509
+ displayOptions: {
2510
+ show: {
2511
+ resource: ["git"],
2512
+ operation: ["commit"]
2513
+ }
2514
+ }
2515
+ },
2516
+ {
2517
+ displayName: "Author Name",
2518
+ name: "authorName",
2519
+ type: "string",
2520
+ default: "",
2521
+ description: "Optional commit author name",
2522
+ displayOptions: {
2523
+ show: {
2524
+ resource: ["git"],
2525
+ operation: ["commit"]
2526
+ }
2527
+ }
2528
+ },
2529
+ {
2530
+ displayName: "Author Email",
2531
+ name: "authorEmail",
2532
+ type: "string",
2533
+ default: "",
2534
+ description: "Optional commit author email",
2535
+ displayOptions: {
2536
+ show: {
2537
+ resource: ["git"],
2538
+ operation: ["commit"]
2539
+ }
2540
+ }
2541
+ },
2542
+ {
2543
+ displayName: "Clone Options",
2544
+ name: "cloneOptions",
2545
+ type: "collection",
2546
+ placeholder: "Add Option",
2547
+ default: {},
2548
+ displayOptions: {
2549
+ show: {
2550
+ resource: ["git"],
2551
+ operation: ["clone"]
2552
+ }
2553
+ },
2554
+ options: [
2555
+ {
2556
+ displayName: "Branch",
2557
+ name: "branch",
2558
+ type: "string",
2559
+ default: "",
2560
+ description: "Branch to check out after cloning"
2561
+ },
2562
+ {
2563
+ displayName: "Commit ID",
2564
+ name: "commitId",
2565
+ type: "string",
2566
+ default: "",
2567
+ description: "Commit SHA to check out after cloning"
2568
+ },
2569
+ {
2570
+ displayName: "Depth",
2571
+ name: "depth",
2572
+ type: "number",
2573
+ typeOptions: {
2574
+ minValue: 1
2575
+ },
2576
+ default: 1,
2577
+ description: "Shallow clone depth"
2578
+ },
2579
+ {
2580
+ displayName: "Password or Token",
2581
+ name: "password",
2582
+ type: "string",
2583
+ typeOptions: {
2584
+ password: true
2585
+ },
2586
+ default: "",
2587
+ description: "HTTPS password or personal access token"
2588
+ },
2589
+ {
2590
+ displayName: "Store Credentials in Repository",
2591
+ name: "dangerouslyStoreCredentials",
2592
+ type: "boolean",
2593
+ default: false,
2594
+ description: "Whether to persist clone credentials in the repository config"
2595
+ },
2596
+ {
2597
+ displayName: "Username",
2598
+ name: "username",
2599
+ type: "string",
2600
+ default: "",
2601
+ description: "HTTPS username for private repositories"
2602
+ }
2603
+ ]
2604
+ },
2605
+ {
2606
+ displayName: "Remote Options",
2607
+ name: "remoteOptions",
2608
+ type: "collection",
2609
+ placeholder: "Add Option",
2610
+ default: {},
2611
+ displayOptions: {
2612
+ show: {
2613
+ resource: ["git"],
2614
+ operation: ["pull", "push"]
2615
+ }
2616
+ },
2617
+ options: [
2618
+ {
2619
+ displayName: "Branch",
2620
+ name: "branch",
2621
+ type: "string",
2622
+ default: "",
2623
+ description: "Branch name to pull or push"
2624
+ },
2625
+ {
2626
+ displayName: "Password or Token",
2627
+ name: "password",
2628
+ type: "string",
2629
+ typeOptions: {
2630
+ password: true
2631
+ },
2632
+ default: "",
2633
+ description: "HTTPS password or personal access token for the remote"
2634
+ },
2635
+ {
2636
+ displayName: "Remote",
2637
+ name: "remote",
2638
+ type: "string",
2639
+ default: "",
2640
+ description: "Remote name, for example origin"
2641
+ },
2642
+ {
2643
+ displayName: "Set Upstream",
2644
+ name: "setUpstream",
2645
+ type: "boolean",
2646
+ default: false,
2647
+ description: "Whether to set upstream tracking when pushing",
2648
+ displayOptions: {
2649
+ show: {
2650
+ "/operation": ["push"]
2651
+ }
2652
+ }
2653
+ },
2654
+ {
2655
+ displayName: "Username",
2656
+ name: "username",
2657
+ type: "string",
2658
+ default: "",
2659
+ description: "HTTPS username for the remote"
2660
+ }
2661
+ ]
2662
+ },
2663
+ {
2664
+ displayName: "Commit Options",
2665
+ name: "commitOptions",
2666
+ type: "collection",
2667
+ placeholder: "Add Option",
2668
+ default: {},
2669
+ displayOptions: {
2670
+ show: {
2671
+ resource: ["git"],
2672
+ operation: ["commit"]
2673
+ }
2674
+ },
2675
+ options: [
2676
+ {
2677
+ displayName: "Allow Empty Commit",
2678
+ name: "allowEmpty",
2679
+ type: "boolean",
2680
+ default: false,
2681
+ description: "Whether to create a commit when no files are staged"
2682
+ }
2683
+ ]
2684
+ },
2685
+ {
2686
+ displayName: "Volume Name",
2687
+ name: "volumeName",
2688
+ type: "string",
2689
+ required: true,
2690
+ default: "",
2691
+ description: "Name for the new volume",
2692
+ displayOptions: {
2693
+ show: {
2694
+ resource: ["volume"],
2695
+ operation: ["create"]
2696
+ }
2697
+ }
2698
+ },
2699
+ {
2700
+ displayName: "Volume ID",
2701
+ name: "volumeId",
2702
+ type: "string",
2703
+ required: true,
2704
+ default: "",
2705
+ description: "ID of the volume",
2706
+ displayOptions: {
2707
+ show: {
2708
+ resource: ["volume"],
2709
+ operation: ["get", "delete"]
2710
+ }
2711
+ }
2712
+ },
2713
+ {
2714
+ displayName: "Command",
2715
+ name: "command",
2716
+ type: "string",
2717
+ required: true,
2718
+ default: "",
2719
+ placeholder: 'python -c "print(1 + 1)"',
2720
+ typeOptions: {
2721
+ rows: 4
2722
+ },
2723
+ displayOptions: {
2724
+ show: {
2725
+ resource: ["code"],
2726
+ operation: ["runCommand"]
2727
+ }
2728
+ }
2729
+ },
2730
+ {
2731
+ displayName: "Working Directory",
2732
+ name: "cwd",
2733
+ type: "string",
2734
+ default: "",
2735
+ displayOptions: {
2736
+ show: {
2737
+ resource: ["code"],
2738
+ operation: ["runCommand"]
2739
+ }
2740
+ }
2741
+ },
2742
+ {
2743
+ displayName: "Template or Snapshot ID",
2744
+ name: "template",
2745
+ type: "string",
2746
+ default: "",
2747
+ description: "E2B template name/ID or snapshot ID. Leave empty to use the default E2B sandbox template.",
2748
+ displayOptions: {
2749
+ show: {
2750
+ resource: ["sandbox", "code"],
2751
+ operation: ["create", "runCommand"]
2752
+ }
2753
+ }
2754
+ },
2755
+ {
2756
+ displayName: "Snapshot Name",
2757
+ name: "snapshotName",
2758
+ type: "string",
2759
+ default: "",
2760
+ description: "Optional name for the snapshot template",
2761
+ displayOptions: {
2762
+ show: {
2763
+ resource: ["snapshot"],
2764
+ operation: ["create"]
2765
+ }
2766
+ }
2767
+ },
2768
+ {
2769
+ displayName: "Metadata",
2770
+ name: "metadataJson",
2771
+ type: "json",
2772
+ default: "{}",
2773
+ description: "Metadata to attach when creating a sandbox",
2774
+ displayOptions: {
2775
+ show: {
2776
+ resource: ["sandbox", "code"],
2777
+ operation: ["create", "runCommand"]
2778
+ }
2779
+ }
2780
+ },
2781
+ {
2782
+ displayName: "Environment Variables",
2783
+ name: "envJson",
2784
+ type: "json",
2785
+ default: "{}",
2786
+ description: "Environment variables to set for the sandbox or command",
2787
+ displayOptions: {
2788
+ show: {
2789
+ resource: ["sandbox", "code"],
2790
+ operation: ["create", "runCommand"]
2791
+ }
2792
+ }
2793
+ },
2794
+ {
2795
+ displayName: "Allow Internet Access",
2796
+ name: "allowInternetAccess",
2797
+ type: "boolean",
2798
+ default: true,
2799
+ displayOptions: {
2800
+ show: {
2801
+ resource: ["sandbox", "code"],
2802
+ operation: ["create", "runCommand"]
2803
+ }
2804
+ }
2805
+ },
2806
+ {
2807
+ displayName: "Volume Mounts",
2808
+ name: "volumeMountsJson",
2809
+ type: "json",
2810
+ default: "{}",
2811
+ description: 'JSON object mapping sandbox mount paths to E2B volume names, for example {"\\/data":"my-volume"}',
2812
+ displayOptions: {
2813
+ show: {
2814
+ resource: ["sandbox", "code"],
2815
+ operation: ["create", "runCommand"]
2816
+ }
2817
+ }
2818
+ },
2819
+ {
2820
+ displayName: "Kill Sandbox After Run",
2821
+ name: "killAfterRun",
2822
+ type: "boolean",
2823
+ default: false,
2824
+ description: "Whether to kill the sandbox after running the command",
2825
+ displayOptions: {
2826
+ show: {
2827
+ resource: ["code"],
2828
+ operation: ["runCommand"]
2829
+ }
2830
+ }
2831
+ },
2832
+ {
2833
+ displayName: "Limit",
2834
+ name: "limit",
2835
+ type: "number",
2836
+ typeOptions: {
2837
+ minValue: 1
2838
+ },
2839
+ default: 50,
2840
+ description: "Max number of results to return",
2841
+ displayOptions: {
2842
+ show: {
2843
+ resource: ["sandbox", "snapshot", "volume"],
2844
+ operation: ["getMany"]
2845
+ }
2846
+ }
2847
+ },
2848
+ {
2849
+ displayName: "Timeout",
2850
+ name: "timeoutSeconds",
2851
+ type: "number",
2852
+ typeOptions: {
2853
+ minValue: 1
2854
+ },
2855
+ default: 300,
2856
+ description: "Timeout in seconds for the E2B operation"
2857
+ }
2858
+ ]
2859
+ };
2860
+ async execute() {
2861
+ const items = this.getInputData();
2862
+ const credentials = await this.getCredentials("e2bApi");
2863
+ const returnData = [];
2864
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
2865
+ try {
2866
+ const rawResource = this.getNodeParameter("resource", itemIndex);
2867
+ if (!(0, types_1.isResource)(rawResource)) {
2868
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The resource "${rawResource}" is not known`, {
2869
+ itemIndex
2870
+ });
2871
+ }
2872
+ const rawOperation = this.getNodeParameter("operation", itemIndex);
2873
+ if (!(0, types_1.isOperationForResource)(rawResource, rawOperation)) {
2874
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${rawOperation}" is not known for resource "${rawResource}"`, { itemIndex });
2875
+ }
2876
+ const handler = (0, actions_1.getOperationHandler)(rawResource, rawOperation);
2877
+ const itemData = await handler({
2878
+ executeFunctions: this,
2879
+ credentials,
2880
+ itemIndex,
2881
+ timeoutMs: (0, helpers_1.getTimeoutMs)(this, itemIndex)
2882
+ });
2883
+ returnData.push(...itemData);
2884
+ } catch (error) {
2885
+ if (this.continueOnFail()) {
2886
+ returnData.push({
2887
+ json: {
2888
+ error: (0, helpers_1.getErrorMessage)(error)
2889
+ },
2890
+ pairedItem: { item: itemIndex }
2891
+ });
2892
+ continue;
2893
+ }
2894
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), (0, helpers_1.getErrorMessage)(error), { itemIndex });
2895
+ }
2896
+ }
2897
+ return [returnData];
2898
+ }
2899
+ };
2900
+ exports.E2b = E2b;
2901
+ //# sourceMappingURL=E2b.node.bundle.js.map