@fastgpt-sdk/sandbox-adapter 0.0.38 → 0.0.39
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/adapters/BaseSandboxAdapter.d.ts +1 -1
- package/dist/adapters/E2BAdapter/index.d.ts +1 -1
- package/dist/adapters/OpenSandboxAdapter/index.d.ts +1 -1
- package/dist/adapters/SealosDevboxAdapter/api.d.ts +2 -0
- package/dist/adapters/SealosDevboxAdapter/index.d.ts +1 -1
- package/dist/adapters/SealosDevboxAdapter/type.d.ts +2 -1
- package/dist/index.cjs +32 -6
- package/dist/index.js +32 -6
- package/dist/interfaces/ISandboxLifecycle.d.ts +5 -1
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -16,6 +16,8 @@ export declare class DevboxApi {
|
|
|
16
16
|
info(name: string): Promise<DevboxApiResponse<DevboxInfoData>>;
|
|
17
17
|
/** POST /api/v1/devbox/{name}/pause */
|
|
18
18
|
pause(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
19
|
+
/** POST /api/v1/devbox/{name}/stop */
|
|
20
|
+
stop(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
19
21
|
/** POST /api/v1/devbox/{name}/resume */
|
|
20
22
|
resume(name: string): Promise<DevboxApiResponse<DevboxMutationData>>;
|
|
21
23
|
/** DELETE /api/v1/devbox/{name} */
|
|
@@ -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>;
|
|
@@ -46,9 +46,10 @@ export interface ExecResponseData {
|
|
|
46
46
|
stderr: string;
|
|
47
47
|
executedAt: string;
|
|
48
48
|
}
|
|
49
|
-
/** Response data from create/pause/resume/delete endpoints. */
|
|
49
|
+
/** Response data from create/pause/stop/resume/delete endpoints. */
|
|
50
50
|
export interface DevboxMutationData {
|
|
51
51
|
name: string;
|
|
52
|
+
namespace?: string;
|
|
52
53
|
state?: string;
|
|
53
54
|
status?: string;
|
|
54
55
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -45667,6 +45667,11 @@ class DevboxApi {
|
|
|
45667
45667
|
method: "POST"
|
|
45668
45668
|
});
|
|
45669
45669
|
}
|
|
45670
|
+
async stop(name) {
|
|
45671
|
+
return this.request(this.url(`/api/v1/devbox/${name}/stop`), {
|
|
45672
|
+
method: "POST"
|
|
45673
|
+
});
|
|
45674
|
+
}
|
|
45670
45675
|
async resume(name) {
|
|
45671
45676
|
return this.request(this.url(`/api/v1/devbox/${name}/resume`), {
|
|
45672
45677
|
method: "POST"
|
|
@@ -45876,10 +45881,10 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
45876
45881
|
async stop() {
|
|
45877
45882
|
try {
|
|
45878
45883
|
this._status = { state: "Stopping" };
|
|
45879
|
-
await this.api.
|
|
45884
|
+
await this.api.stop(this._id);
|
|
45880
45885
|
this._status = { state: "Stopped" };
|
|
45881
45886
|
} catch (error) {
|
|
45882
|
-
throw new CommandExecutionError("Failed to
|
|
45887
|
+
throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
|
|
45883
45888
|
}
|
|
45884
45889
|
}
|
|
45885
45890
|
async start() {
|
|
@@ -45892,10 +45897,12 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
45892
45897
|
throw new CommandExecutionError("Failed to resume sandbox", "resume", error instanceof Error ? error : undefined);
|
|
45893
45898
|
}
|
|
45894
45899
|
}
|
|
45895
|
-
async delete() {
|
|
45900
|
+
async delete(sandboxId) {
|
|
45896
45901
|
try {
|
|
45902
|
+
const targetId = sandboxId ?? this._id;
|
|
45897
45903
|
this._status = { state: "Deleting" };
|
|
45898
|
-
await this.api.delete(
|
|
45904
|
+
await this.api.delete(targetId);
|
|
45905
|
+
this._id = targetId;
|
|
45899
45906
|
await this.waitUntilDeleted();
|
|
45900
45907
|
this._status = { state: "UnExist" };
|
|
45901
45908
|
} catch (error) {
|
|
@@ -48496,9 +48503,24 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48496
48503
|
throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
|
|
48497
48504
|
}
|
|
48498
48505
|
}
|
|
48499
|
-
async delete() {
|
|
48506
|
+
async delete(sandboxId) {
|
|
48500
48507
|
try {
|
|
48501
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
|
+
}
|
|
48502
48524
|
await this.sandbox.kill();
|
|
48503
48525
|
this.sandbox = undefined;
|
|
48504
48526
|
this._status = { state: "UnExist" };
|
|
@@ -48867,7 +48889,11 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48867
48889
|
throw new CommandExecutionError("Failed to pause E2B sandbox", "stop", error instanceof Error ? error : undefined);
|
|
48868
48890
|
}
|
|
48869
48891
|
}
|
|
48870
|
-
async delete() {
|
|
48892
|
+
async delete(sandboxId) {
|
|
48893
|
+
if (sandboxId) {
|
|
48894
|
+
this._id = sandboxId;
|
|
48895
|
+
this.sandbox = null;
|
|
48896
|
+
}
|
|
48871
48897
|
const sandbox = await this.ensureSandbox();
|
|
48872
48898
|
try {
|
|
48873
48899
|
this._status = { state: "Deleting" };
|
package/dist/index.js
CHANGED
|
@@ -45651,6 +45651,11 @@ class DevboxApi {
|
|
|
45651
45651
|
method: "POST"
|
|
45652
45652
|
});
|
|
45653
45653
|
}
|
|
45654
|
+
async stop(name) {
|
|
45655
|
+
return this.request(this.url(`/api/v1/devbox/${name}/stop`), {
|
|
45656
|
+
method: "POST"
|
|
45657
|
+
});
|
|
45658
|
+
}
|
|
45654
45659
|
async resume(name) {
|
|
45655
45660
|
return this.request(this.url(`/api/v1/devbox/${name}/resume`), {
|
|
45656
45661
|
method: "POST"
|
|
@@ -45860,10 +45865,10 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
45860
45865
|
async stop() {
|
|
45861
45866
|
try {
|
|
45862
45867
|
this._status = { state: "Stopping" };
|
|
45863
|
-
await this.api.
|
|
45868
|
+
await this.api.stop(this._id);
|
|
45864
45869
|
this._status = { state: "Stopped" };
|
|
45865
45870
|
} catch (error) {
|
|
45866
|
-
throw new CommandExecutionError("Failed to
|
|
45871
|
+
throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
|
|
45867
45872
|
}
|
|
45868
45873
|
}
|
|
45869
45874
|
async start() {
|
|
@@ -45876,10 +45881,12 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
45876
45881
|
throw new CommandExecutionError("Failed to resume sandbox", "resume", error instanceof Error ? error : undefined);
|
|
45877
45882
|
}
|
|
45878
45883
|
}
|
|
45879
|
-
async delete() {
|
|
45884
|
+
async delete(sandboxId) {
|
|
45880
45885
|
try {
|
|
45886
|
+
const targetId = sandboxId ?? this._id;
|
|
45881
45887
|
this._status = { state: "Deleting" };
|
|
45882
|
-
await this.api.delete(
|
|
45888
|
+
await this.api.delete(targetId);
|
|
45889
|
+
this._id = targetId;
|
|
45883
45890
|
await this.waitUntilDeleted();
|
|
45884
45891
|
this._status = { state: "UnExist" };
|
|
45885
45892
|
} catch (error) {
|
|
@@ -48480,9 +48487,24 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48480
48487
|
throw new CommandExecutionError("Failed to stop sandbox", "stop", error instanceof Error ? error : undefined);
|
|
48481
48488
|
}
|
|
48482
48489
|
}
|
|
48483
|
-
async delete() {
|
|
48490
|
+
async delete(sandboxId) {
|
|
48484
48491
|
try {
|
|
48485
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
|
+
}
|
|
48486
48508
|
await this.sandbox.kill();
|
|
48487
48509
|
this.sandbox = undefined;
|
|
48488
48510
|
this._status = { state: "UnExist" };
|
|
@@ -48851,7 +48873,11 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48851
48873
|
throw new CommandExecutionError("Failed to pause E2B sandbox", "stop", error instanceof Error ? error : undefined);
|
|
48852
48874
|
}
|
|
48853
48875
|
}
|
|
48854
|
-
async delete() {
|
|
48876
|
+
async delete(sandboxId) {
|
|
48877
|
+
if (sandboxId) {
|
|
48878
|
+
this._id = sandboxId;
|
|
48879
|
+
this.sandbox = null;
|
|
48880
|
+
}
|
|
48855
48881
|
const sandbox = await this.ensureSandbox();
|
|
48856
48882
|
try {
|
|
48857
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