@fastgpt-sdk/sandbox-adapter 0.0.21 → 0.0.23
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ImageSpec, NetworkPolicy, ResourceLimits } from '@/types';
|
|
2
|
+
import type { Volume } from '@alibaba-group/opensandbox';
|
|
2
3
|
/**
|
|
3
4
|
* Configuration for creating a sandbox.
|
|
4
5
|
*/
|
|
@@ -17,6 +18,8 @@ export interface OpenSandboxConfigType {
|
|
|
17
18
|
metadata?: Record<string, any>;
|
|
18
19
|
/** Network access policy */
|
|
19
20
|
networkPolicy?: NetworkPolicy;
|
|
21
|
+
/** Optional volume mounts for persistent storage */
|
|
22
|
+
volumes?: Volume[];
|
|
20
23
|
/** Provider-specific extensions */
|
|
21
24
|
extensions?: Record<string, unknown>;
|
|
22
25
|
/** Skip readiness checks after create/connect */
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
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
|
+
|
|
1
20
|
// src/errors/SandboxException.ts
|
|
2
21
|
class SandboxException extends Error {
|
|
3
22
|
code;
|
|
@@ -1056,6 +1075,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
1056
1075
|
resource,
|
|
1057
1076
|
env: cfg.env,
|
|
1058
1077
|
metadata: cfg.metadata,
|
|
1078
|
+
volumes: cfg.volumes,
|
|
1059
1079
|
skipHealthCheck: cfg.skipHealthCheck,
|
|
1060
1080
|
readyTimeoutSeconds: cfg.readyTimeoutSeconds,
|
|
1061
1081
|
healthCheckPollingInterval: cfg.healthCheckPollingInterval
|
|
@@ -1279,7 +1299,14 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
1279
1299
|
}
|
|
1280
1300
|
|
|
1281
1301
|
// src/adapters/E2BAdapter/index.ts
|
|
1282
|
-
|
|
1302
|
+
var e2bModule = null;
|
|
1303
|
+
async function getE2B() {
|
|
1304
|
+
if (!e2bModule) {
|
|
1305
|
+
e2bModule = await import("@e2b/code-interpreter");
|
|
1306
|
+
}
|
|
1307
|
+
return e2bModule;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1283
1310
|
class E2BAdapter extends BaseSandboxAdapter {
|
|
1284
1311
|
config;
|
|
1285
1312
|
provider = "e2b";
|
|
@@ -1296,6 +1323,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1296
1323
|
}
|
|
1297
1324
|
async findSandbox() {
|
|
1298
1325
|
try {
|
|
1326
|
+
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1299
1327
|
const paginator = Sandbox2.list({
|
|
1300
1328
|
apiKey: this.config.apiKey,
|
|
1301
1329
|
query: {
|
|
@@ -1323,6 +1351,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1323
1351
|
}
|
|
1324
1352
|
async ensureRunning() {
|
|
1325
1353
|
try {
|
|
1354
|
+
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1326
1355
|
if (!this.sandbox) {
|
|
1327
1356
|
this.sandbox = await this.findSandbox();
|
|
1328
1357
|
}
|
|
@@ -1347,6 +1376,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1347
1376
|
async create() {
|
|
1348
1377
|
try {
|
|
1349
1378
|
this._status = { state: "Creating" };
|
|
1379
|
+
const { Sandbox: Sandbox2 } = await getE2B();
|
|
1350
1380
|
const options = {
|
|
1351
1381
|
apiKey: this.config.apiKey,
|
|
1352
1382
|
template: this.config.template,
|
|
@@ -1409,6 +1439,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1409
1439
|
}
|
|
1410
1440
|
}
|
|
1411
1441
|
async execute(command, options) {
|
|
1442
|
+
const { CommandExitError } = await getE2B();
|
|
1412
1443
|
try {
|
|
1413
1444
|
const sandbox = await this.ensureSandbox();
|
|
1414
1445
|
const result = await sandbox.commands.run(command, {
|
|
@@ -1565,6 +1596,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
1565
1596
|
async listDirectory(path) {
|
|
1566
1597
|
const sandbox = await this.ensureSandbox();
|
|
1567
1598
|
try {
|
|
1599
|
+
const { FileType } = await getE2B();
|
|
1568
1600
|
const entries = await sandbox.files.list(path);
|
|
1569
1601
|
return entries.map((entry) => {
|
|
1570
1602
|
const isDirectory = entry.type === FileType.DIR;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastgpt-sdk/sandbox-adapter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"vitest": "^3.0.9"
|
|
68
68
|
},
|
|
69
69
|
"lint-staged": {
|
|
70
|
-
"
|
|
70
|
+
"!(.claude)/**/*.{js,cjs,mjs,ts,tsx,json,md,mdx,yaml,yml}": [
|
|
71
71
|
"prettier --check"
|
|
72
72
|
],
|
|
73
|
-
"
|
|
73
|
+
"!(.claude)/**/*.{js,cjs,mjs,ts,tsx}": [
|
|
74
74
|
"eslint --max-warnings=0"
|
|
75
75
|
]
|
|
76
76
|
}
|