@fastgpt-sdk/sandbox-adapter 0.0.38-beta.0 → 0.0.38-beta.2

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.
@@ -32,7 +32,7 @@ export declare abstract class BaseSandboxAdapter implements ISandbox {
32
32
  abstract create(): Promise<void>;
33
33
  abstract start(): Promise<void>;
34
34
  abstract stop(): Promise<void>;
35
- abstract delete(): Promise<void>;
35
+ abstract delete(sandboxId?: SandboxId): Promise<void>;
36
36
  abstract getInfo(): Promise<SandboxInfo | null>;
37
37
  waitUntilReady(timeoutMs?: number): Promise<void>;
38
38
  waitUntilDeleted(timeoutMs?: number): Promise<void>;
@@ -24,7 +24,7 @@ export declare class E2BAdapter extends BaseSandboxAdapter {
24
24
  create(): Promise<void>;
25
25
  start(): Promise<void>;
26
26
  stop(): Promise<void>;
27
- delete(): Promise<void>;
27
+ delete(sandboxId?: SandboxId): Promise<void>;
28
28
  getInfo(): Promise<SandboxInfo | null>;
29
29
  execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
30
30
  readFiles(paths: string[]): Promise<FileReadResult[]>;
@@ -80,7 +80,7 @@ export declare class OpenSandboxAdapter extends BaseSandboxAdapter {
80
80
  private resume;
81
81
  start(): Promise<void>;
82
82
  stop(): Promise<void>;
83
- delete(): Promise<void>;
83
+ delete(sandboxId?: SandboxId): Promise<void>;
84
84
  /**
85
85
  * Release client-side resources owned by this Sandbox instance.
86
86
  * Does NOT stop or delete the container - the sandbox keeps running.
@@ -41,7 +41,7 @@ export declare class SealosDevboxAdapter extends BaseSandboxAdapter {
41
41
  create(): Promise<void>;
42
42
  stop(): Promise<void>;
43
43
  start(): Promise<void>;
44
- delete(): Promise<void>;
44
+ delete(sandboxId?: SandboxId): Promise<void>;
45
45
  execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
46
46
  getEndpoint(selector: SandboxEndpointSelector): Promise<Endpoint>;
47
47
  getProxyTarget(service?: SandboxProxyService): Promise<SandboxProxyTarget>;
package/dist/index.cjs CHANGED
@@ -45897,10 +45897,12 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45897
45897
  throw new CommandExecutionError("Failed to resume sandbox", "resume", error instanceof Error ? error : undefined);
45898
45898
  }
45899
45899
  }
45900
- async delete() {
45900
+ async delete(sandboxId) {
45901
45901
  try {
45902
+ const targetId = sandboxId ?? this._id;
45902
45903
  this._status = { state: "Deleting" };
45903
- await this.api.delete(this._id);
45904
+ await this.api.delete(targetId);
45905
+ this._id = targetId;
45904
45906
  await this.waitUntilDeleted();
45905
45907
  this._status = { state: "UnExist" };
45906
45908
  } catch (error) {
@@ -48501,9 +48503,24 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
48501
48503
  throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
48502
48504
  }
48503
48505
  }
48504
- async delete() {
48506
+ async delete(sandboxId) {
48505
48507
  try {
48506
48508
  this._status = { state: "Deleting" };
48509
+ if (sandboxId) {
48510
+ const manager = SandboxManager.create({ connectionConfig: this._connection });
48511
+ try {
48512
+ await manager.killSandbox(sandboxId);
48513
+ } finally {
48514
+ await manager.close().catch(() => {
48515
+ return;
48516
+ });
48517
+ }
48518
+ if (sandboxId === this._id) {
48519
+ this.sandbox = undefined;
48520
+ }
48521
+ this._status = { state: "UnExist" };
48522
+ return;
48523
+ }
48507
48524
  await this.sandbox.kill();
48508
48525
  this.sandbox = undefined;
48509
48526
  this._status = { state: "UnExist" };
@@ -48872,7 +48889,11 @@ class E2BAdapter extends BaseSandboxAdapter {
48872
48889
  throw new CommandExecutionError("Failed to pause E2B sandbox", "stop", error instanceof Error ? error : undefined);
48873
48890
  }
48874
48891
  }
48875
- async delete() {
48892
+ async delete(sandboxId) {
48893
+ if (sandboxId) {
48894
+ this._id = sandboxId;
48895
+ this.sandbox = null;
48896
+ }
48876
48897
  const sandbox = await this.ensureSandbox();
48877
48898
  try {
48878
48899
  this._status = { state: "Deleting" };
package/dist/index.js CHANGED
@@ -45881,10 +45881,12 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45881
45881
  throw new CommandExecutionError("Failed to resume sandbox", "resume", error instanceof Error ? error : undefined);
45882
45882
  }
45883
45883
  }
45884
- async delete() {
45884
+ async delete(sandboxId) {
45885
45885
  try {
45886
+ const targetId = sandboxId ?? this._id;
45886
45887
  this._status = { state: "Deleting" };
45887
- await this.api.delete(this._id);
45888
+ await this.api.delete(targetId);
45889
+ this._id = targetId;
45888
45890
  await this.waitUntilDeleted();
45889
45891
  this._status = { state: "UnExist" };
45890
45892
  } catch (error) {
@@ -48485,9 +48487,24 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
48485
48487
  throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
48486
48488
  }
48487
48489
  }
48488
- async delete() {
48490
+ async delete(sandboxId) {
48489
48491
  try {
48490
48492
  this._status = { state: "Deleting" };
48493
+ if (sandboxId) {
48494
+ const manager = SandboxManager.create({ connectionConfig: this._connection });
48495
+ try {
48496
+ await manager.killSandbox(sandboxId);
48497
+ } finally {
48498
+ await manager.close().catch(() => {
48499
+ return;
48500
+ });
48501
+ }
48502
+ if (sandboxId === this._id) {
48503
+ this.sandbox = undefined;
48504
+ }
48505
+ this._status = { state: "UnExist" };
48506
+ return;
48507
+ }
48491
48508
  await this.sandbox.kill();
48492
48509
  this.sandbox = undefined;
48493
48510
  this._status = { state: "UnExist" };
@@ -48856,7 +48873,11 @@ class E2BAdapter extends BaseSandboxAdapter {
48856
48873
  throw new CommandExecutionError("Failed to pause E2B sandbox", "stop", error instanceof Error ? error : undefined);
48857
48874
  }
48858
48875
  }
48859
- async delete() {
48876
+ async delete(sandboxId) {
48877
+ if (sandboxId) {
48878
+ this._id = sandboxId;
48879
+ this.sandbox = null;
48880
+ }
48860
48881
  const sandbox = await this.ensureSandbox();
48861
48882
  try {
48862
48883
  this._status = { state: "Deleting" };
@@ -27,8 +27,12 @@ export interface ISandboxLifecycle {
27
27
  stop(): Promise<void>;
28
28
  /**
29
29
  * Delete the sandbox permanently.
30
+ *
31
+ * When `sandboxId` is provided, implementations should delete that provider
32
+ * sandbox directly without requiring callers to first bind the adapter via
33
+ * `connect()`.
30
34
  */
31
- delete(): Promise<void>;
35
+ delete(sandboxId?: SandboxId): Promise<void>;
32
36
  /**
33
37
  * Get detailed information about the sandbox.
34
38
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastgpt-sdk/sandbox-adapter",
3
- "version": "0.0.38-beta.0",
3
+ "version": "0.0.38-beta.2",
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.cjs",