@fastgpt-sdk/sandbox-adapter 0.0.22 → 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.
Files changed (2) hide show
  1. package/dist/index.js +32 -1
  2. package/package.json +1 -1
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;
@@ -1280,7 +1299,14 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
1280
1299
  }
1281
1300
 
1282
1301
  // src/adapters/E2BAdapter/index.ts
1283
- import { Sandbox as Sandbox2, CommandExitError, FileType } from "@e2b/code-interpreter";
1302
+ var e2bModule = null;
1303
+ async function getE2B() {
1304
+ if (!e2bModule) {
1305
+ e2bModule = await import("@e2b/code-interpreter");
1306
+ }
1307
+ return e2bModule;
1308
+ }
1309
+
1284
1310
  class E2BAdapter extends BaseSandboxAdapter {
1285
1311
  config;
1286
1312
  provider = "e2b";
@@ -1297,6 +1323,7 @@ class E2BAdapter extends BaseSandboxAdapter {
1297
1323
  }
1298
1324
  async findSandbox() {
1299
1325
  try {
1326
+ const { Sandbox: Sandbox2 } = await getE2B();
1300
1327
  const paginator = Sandbox2.list({
1301
1328
  apiKey: this.config.apiKey,
1302
1329
  query: {
@@ -1324,6 +1351,7 @@ class E2BAdapter extends BaseSandboxAdapter {
1324
1351
  }
1325
1352
  async ensureRunning() {
1326
1353
  try {
1354
+ const { Sandbox: Sandbox2 } = await getE2B();
1327
1355
  if (!this.sandbox) {
1328
1356
  this.sandbox = await this.findSandbox();
1329
1357
  }
@@ -1348,6 +1376,7 @@ class E2BAdapter extends BaseSandboxAdapter {
1348
1376
  async create() {
1349
1377
  try {
1350
1378
  this._status = { state: "Creating" };
1379
+ const { Sandbox: Sandbox2 } = await getE2B();
1351
1380
  const options = {
1352
1381
  apiKey: this.config.apiKey,
1353
1382
  template: this.config.template,
@@ -1410,6 +1439,7 @@ class E2BAdapter extends BaseSandboxAdapter {
1410
1439
  }
1411
1440
  }
1412
1441
  async execute(command, options) {
1442
+ const { CommandExitError } = await getE2B();
1413
1443
  try {
1414
1444
  const sandbox = await this.ensureSandbox();
1415
1445
  const result = await sandbox.commands.run(command, {
@@ -1566,6 +1596,7 @@ class E2BAdapter extends BaseSandboxAdapter {
1566
1596
  async listDirectory(path) {
1567
1597
  const sandbox = await this.ensureSandbox();
1568
1598
  try {
1599
+ const { FileType } = await getE2B();
1569
1600
  const entries = await sandbox.files.list(path);
1570
1601
  return entries.map((entry) => {
1571
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.22",
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",