@fastgpt-sdk/sandbox-adapter 0.0.13 → 0.0.15

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 +8 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -650,7 +650,8 @@ class DevboxApi {
650
650
  headers.set("Content-Type", "application/json");
651
651
  }
652
652
  const res = await fetch(input, { ...init, headers });
653
- return await res.json();
653
+ const result = await res.json();
654
+ return result;
654
655
  }
655
656
  async create(name) {
656
657
  return this.request(this.url("/api/v1/devbox"), {
@@ -763,6 +764,8 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
763
764
  const res = await this.api.info(this._id);
764
765
  if (res.code !== 200)
765
766
  return null;
767
+ if (!res.data)
768
+ return Promise.reject(res.message);
766
769
  const data = res.data;
767
770
  this._status = { state: this.StatusAdapt(data), message: res.message };
768
771
  return {
@@ -845,14 +848,14 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
845
848
  }
846
849
  }
847
850
  async execute(command, options) {
848
- const cmd = options?.workingDirectory ? [`cd ${options.workingDirectory} && ${command}`] : [command];
851
+ const cmd = options?.workingDirectory ? ["sh", "-lc", `cd ${options.workingDirectory} && ${command}`] : ["sh", "-lc", command];
849
852
  try {
850
853
  const res = await this.api.exec(this._id, {
851
854
  command: cmd,
852
855
  timeoutSeconds: options?.timeoutMs ? Math.ceil(options.timeoutMs / 1000) : undefined
853
856
  });
854
857
  if (!res.data) {
855
- throw new CommandExecutionError(`Command execution failed: ${command}`, command);
858
+ throw new CommandExecutionError(`Command execution failed: ${res.message}`, command);
856
859
  }
857
860
  return {
858
861
  stdout: res.data.stdout,
@@ -860,7 +863,7 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
860
863
  exitCode: res.data.exitCode
861
864
  };
862
865
  } catch (error) {
863
- throw new CommandExecutionError(`Command execution failed: ${command}`, command, error instanceof Error ? error : undefined);
866
+ throw new CommandExecutionError(`Command execution failed: ${error?.message || error?.code}`, command, error instanceof Error ? error : undefined);
864
867
  }
865
868
  }
866
869
  async ping() {
@@ -1080,7 +1083,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
1080
1083
  resourceLimits: this.parseResourceLimits(info.resourceLimits)
1081
1084
  };
1082
1085
  } catch (error) {
1083
- throw new CommandExecutionError("Failed to get sandbox info", "getInfo", error instanceof Error ? error : undefined);
1086
+ throw new CommandExecutionError(`Failed to get sandbox info: ${error?.message || error?.code}`, "getInfo", error instanceof Error ? error : undefined);
1084
1087
  }
1085
1088
  }
1086
1089
  async renewExpiration(additionalSeconds) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastgpt-sdk/sandbox-adapter",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
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",