@fastgpt-sdk/sandbox-adapter 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
-
|
|
20
1
|
// src/errors/SandboxException.ts
|
|
21
2
|
class SandboxException extends Error {
|
|
22
3
|
code;
|
|
@@ -1299,14 +1280,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
1299
1280
|
}
|
|
1300
1281
|
|
|
1301
1282
|
// src/adapters/E2BAdapter/index.ts
|
|
1302
|
-
|
|
1303
|
-
async function getE2B() {
|
|
1304
|
-
if (!e2bModule) {
|
|
1305
|
-
e2bModule = await import("@e2b/code-interpreter");
|
|
1306
|
-
}
|
|
1307
|
-
return e2bModule;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1283
|
+
import { Sandbox as Sandbox2, CommandExitError, FileType } from "@e2b/code-interpreter";
|
|
1310
1284
|
class E2BAdapter extends BaseSandboxAdapter {
|
|
1311
1285
|
config;
|
|
1312
1286
|
provider = "e2b";
|
|
@@ -1323,7 +1297,6 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1323
1297
|
}
|
|
1324
1298
|
async findSandbox() {
|
|
1325
1299
|
try {
|
|
1326
|
-
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1327
1300
|
const paginator = Sandbox2.list({
|
|
1328
1301
|
apiKey: this.config.apiKey,
|
|
1329
1302
|
query: {
|
|
@@ -1351,7 +1324,6 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1351
1324
|
}
|
|
1352
1325
|
async ensureRunning() {
|
|
1353
1326
|
try {
|
|
1354
|
-
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1355
1327
|
if (!this.sandbox) {
|
|
1356
1328
|
this.sandbox = await this.findSandbox();
|
|
1357
1329
|
}
|
|
@@ -1376,7 +1348,6 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1376
1348
|
async create() {
|
|
1377
1349
|
try {
|
|
1378
1350
|
this._status = { state: "Creating" };
|
|
1379
|
-
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1380
1351
|
const options = {
|
|
1381
1352
|
apiKey: this.config.apiKey,
|
|
1382
1353
|
template: this.config.template,
|
|
@@ -1439,7 +1410,6 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1439
1410
|
}
|
|
1440
1411
|
}
|
|
1441
1412
|
async execute(command, options) {
|
|
1442
|
-
const { CommandExitError } = await getE2B();
|
|
1443
1413
|
try {
|
|
1444
1414
|
const sandbox = await this.ensureSandbox();
|
|
1445
1415
|
const result = await sandbox.commands.run(command, {
|
|
@@ -1596,7 +1566,6 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1596
1566
|
async listDirectory(path) {
|
|
1597
1567
|
const sandbox = await this.ensureSandbox();
|
|
1598
1568
|
try {
|
|
1599
|
-
const { FileType } = await getE2B();
|
|
1600
1569
|
const entries = await sandbox.files.list(path);
|
|
1601
1570
|
return entries.map((entry) => {
|
|
1602
1571
|
const isDirectory = entry.type === FileType.DIR;
|
package/package.json
CHANGED