@fastgpt-sdk/sandbox-adapter 0.0.32 → 0.0.33
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 +13 -0
- package/dist/adapters/E2BAdapter/index.d.ts +1 -0
- package/dist/adapters/OpenSandboxAdapter/index.d.ts +1 -0
- package/dist/adapters/SealosDevboxAdapter/index.d.ts +1 -0
- package/dist/index.cjs +47 -21
- package/dist/index.js +47 -21
- package/package.json +1 -1
|
@@ -14,6 +14,19 @@ export declare abstract class BaseSandboxAdapter implements ISandbox {
|
|
|
14
14
|
protected _status: SandboxStatus;
|
|
15
15
|
protected polyfillService?: CommandPolyfillService;
|
|
16
16
|
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* The root path of the sandbox filesystem.
|
|
19
|
+
* Subclasses should override this to return the provider-specific root path.
|
|
20
|
+
*/
|
|
21
|
+
get rootPath(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a path relative to rootPath.
|
|
24
|
+
* - '.' or './' → rootPath
|
|
25
|
+
* - './foo' → rootPath/foo
|
|
26
|
+
* - 'foo' → rootPath/foo
|
|
27
|
+
* - '/absolute' → '/absolute' (pass through)
|
|
28
|
+
*/
|
|
29
|
+
protected normalizePath(path?: string): string;
|
|
17
30
|
get status(): SandboxStatus;
|
|
18
31
|
abstract ensureRunning(): Promise<void>;
|
|
19
32
|
abstract create(): Promise<void>;
|
|
@@ -58,6 +58,7 @@ export declare class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
58
58
|
private _connection;
|
|
59
59
|
private _id?;
|
|
60
60
|
constructor(connectionConfig: OpenSandboxConnectionConfig, createConfig: OpenSandboxConfigType);
|
|
61
|
+
get rootPath(): string;
|
|
61
62
|
get id(): SandboxId | undefined;
|
|
62
63
|
private set sandbox(value);
|
|
63
64
|
private get sandbox();
|
|
@@ -13,6 +13,7 @@ export interface SealosDevboxConfig {
|
|
|
13
13
|
export declare class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
14
14
|
private config;
|
|
15
15
|
readonly provider: "sealosdevbox";
|
|
16
|
+
get rootPath(): string;
|
|
16
17
|
private api;
|
|
17
18
|
private _id;
|
|
18
19
|
constructor(config: SealosDevboxConfig);
|
package/dist/index.cjs
CHANGED
|
@@ -47506,6 +47506,19 @@ class BaseSandboxAdapter {
|
|
|
47506
47506
|
_status = { state: "Creating" };
|
|
47507
47507
|
polyfillService;
|
|
47508
47508
|
constructor() {}
|
|
47509
|
+
get rootPath() {
|
|
47510
|
+
return "/";
|
|
47511
|
+
}
|
|
47512
|
+
normalizePath(path = "") {
|
|
47513
|
+
if (path === "." || path === "./")
|
|
47514
|
+
return this.rootPath;
|
|
47515
|
+
const root = this.rootPath.replace(/\/+$/, "");
|
|
47516
|
+
if (path.startsWith("./"))
|
|
47517
|
+
return `${root}/${path.slice(2)}`;
|
|
47518
|
+
if (!path.startsWith("/"))
|
|
47519
|
+
return `${root}/${path}`;
|
|
47520
|
+
return path;
|
|
47521
|
+
}
|
|
47509
47522
|
get status() {
|
|
47510
47523
|
return this._status;
|
|
47511
47524
|
}
|
|
@@ -47557,7 +47570,7 @@ class BaseSandboxAdapter {
|
|
|
47557
47570
|
async readFiles(paths, options) {
|
|
47558
47571
|
const polyfillService = this.requirePolyfillService("readFiles", "File read not supported by this provider");
|
|
47559
47572
|
const results = [];
|
|
47560
|
-
for (const path of paths) {
|
|
47573
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
47561
47574
|
try {
|
|
47562
47575
|
let content;
|
|
47563
47576
|
if (options?.range) {
|
|
@@ -47585,7 +47598,7 @@ class BaseSandboxAdapter {
|
|
|
47585
47598
|
async writeFiles(entries) {
|
|
47586
47599
|
const polyfillService = this.requirePolyfillService("writeFiles", "File write not supported by this provider");
|
|
47587
47600
|
const results = [];
|
|
47588
|
-
for (const entry of entries) {
|
|
47601
|
+
for (const entry of entries.map((e) => ({ ...e, path: this.normalizePath(e.path) }))) {
|
|
47589
47602
|
try {
|
|
47590
47603
|
let bytesWritten;
|
|
47591
47604
|
if (typeof entry.data === "string") {
|
|
@@ -47629,7 +47642,7 @@ class BaseSandboxAdapter {
|
|
|
47629
47642
|
}
|
|
47630
47643
|
async deleteFiles(paths) {
|
|
47631
47644
|
const polyfillService = this.requirePolyfillService("deleteFiles", "File delete not supported by this provider");
|
|
47632
|
-
const polyfillResults = await polyfillService.deleteFiles(paths);
|
|
47645
|
+
const polyfillResults = await polyfillService.deleteFiles(paths.map((p) => this.normalizePath(p)));
|
|
47633
47646
|
return polyfillResults.map((r) => ({
|
|
47634
47647
|
path: r.path,
|
|
47635
47648
|
success: r.success,
|
|
@@ -47638,7 +47651,10 @@ class BaseSandboxAdapter {
|
|
|
47638
47651
|
}
|
|
47639
47652
|
async moveFiles(entries) {
|
|
47640
47653
|
const polyfillService = this.requirePolyfillService("moveFiles", "File move not supported by this provider");
|
|
47641
|
-
await polyfillService.moveFiles(entries.map((e) => ({
|
|
47654
|
+
await polyfillService.moveFiles(entries.map((e) => ({
|
|
47655
|
+
source: this.normalizePath(e.source),
|
|
47656
|
+
destination: this.normalizePath(e.destination)
|
|
47657
|
+
})));
|
|
47642
47658
|
}
|
|
47643
47659
|
async replaceContent(entries) {
|
|
47644
47660
|
const polyfillService = this.requirePolyfillService("replaceContent", "Content replace not supported by this provider");
|
|
@@ -47646,15 +47662,15 @@ class BaseSandboxAdapter {
|
|
|
47646
47662
|
}
|
|
47647
47663
|
async createDirectories(paths, options) {
|
|
47648
47664
|
const polyfillService = this.requirePolyfillService("createDirectories", "Directory creation not supported by this provider");
|
|
47649
|
-
await polyfillService.createDirectories(paths, options);
|
|
47665
|
+
await polyfillService.createDirectories(paths.map((p) => this.normalizePath(p)), options);
|
|
47650
47666
|
}
|
|
47651
47667
|
async deleteDirectories(paths, options) {
|
|
47652
47668
|
const polyfillService = this.requirePolyfillService("deleteDirectories", "Directory deletion not supported by this provider");
|
|
47653
|
-
await polyfillService.deleteDirectories(paths, options);
|
|
47669
|
+
await polyfillService.deleteDirectories(paths.map((p) => this.normalizePath(p)), options);
|
|
47654
47670
|
}
|
|
47655
47671
|
async listDirectory(path) {
|
|
47656
47672
|
const polyfillService = this.requirePolyfillService("listDirectory", "Directory listing not supported by this provider");
|
|
47657
|
-
return polyfillService.listDirectory(path);
|
|
47673
|
+
return polyfillService.listDirectory(this.normalizePath(path));
|
|
47658
47674
|
}
|
|
47659
47675
|
async* readFileStream(path) {
|
|
47660
47676
|
this.requirePolyfillService("readFileStream", "File stream read not supported by this provider");
|
|
@@ -47706,7 +47722,7 @@ class BaseSandboxAdapter {
|
|
|
47706
47722
|
}
|
|
47707
47723
|
async getFileInfo(paths) {
|
|
47708
47724
|
const polyfillService = this.requirePolyfillService("getFileInfo", "File info not supported by this provider");
|
|
47709
|
-
return polyfillService.getFileInfo(paths);
|
|
47725
|
+
return polyfillService.getFileInfo(paths.map((p) => this.normalizePath(p)));
|
|
47710
47726
|
}
|
|
47711
47727
|
async setPermissions(entries) {
|
|
47712
47728
|
const polyfillService = this.requirePolyfillService("setPermissions", "Permission setting not supported by this provider");
|
|
@@ -47714,7 +47730,7 @@ class BaseSandboxAdapter {
|
|
|
47714
47730
|
}
|
|
47715
47731
|
async search(pattern, path) {
|
|
47716
47732
|
const polyfillService = this.requirePolyfillService("search", "File search not supported by this provider");
|
|
47717
|
-
return polyfillService.search(pattern, path);
|
|
47733
|
+
return polyfillService.search(pattern, path !== undefined ? this.normalizePath(path) : path);
|
|
47718
47734
|
}
|
|
47719
47735
|
async ping() {
|
|
47720
47736
|
const polyfillService = this.requirePolyfillService("ping", "Health check not supported by this provider");
|
|
@@ -47837,6 +47853,9 @@ class DevboxApi {
|
|
|
47837
47853
|
class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
47838
47854
|
config;
|
|
47839
47855
|
provider = "sealosdevbox";
|
|
47856
|
+
get rootPath() {
|
|
47857
|
+
return "/home/devbox/workspace";
|
|
47858
|
+
}
|
|
47840
47859
|
api;
|
|
47841
47860
|
_id;
|
|
47842
47861
|
constructor(config) {
|
|
@@ -47956,7 +47975,7 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
47956
47975
|
}
|
|
47957
47976
|
}
|
|
47958
47977
|
async execute(command, options) {
|
|
47959
|
-
const cmd = this.buildCommand(command, options?.workingDirectory);
|
|
47978
|
+
const cmd = this.buildCommand(command, this.normalizePath(options?.workingDirectory));
|
|
47960
47979
|
try {
|
|
47961
47980
|
const res = await this.api.exec(this._id, {
|
|
47962
47981
|
command: cmd,
|
|
@@ -48004,6 +48023,10 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48004
48023
|
this._connection = this.createConnectionConfig();
|
|
48005
48024
|
this.polyfillService = new CommandPolyfillService(this);
|
|
48006
48025
|
}
|
|
48026
|
+
get rootPath() {
|
|
48027
|
+
const mountPath = this.createConfig.volumes?.[0]?.mountPath;
|
|
48028
|
+
return mountPath ? mountPath.replace(/\/+$/, "") : "/home/sandbox";
|
|
48029
|
+
}
|
|
48007
48030
|
get id() {
|
|
48008
48031
|
return this._id;
|
|
48009
48032
|
}
|
|
@@ -48331,7 +48354,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48331
48354
|
async execute(command, options) {
|
|
48332
48355
|
try {
|
|
48333
48356
|
const execution = await this.sandbox.commands.run(command, {
|
|
48334
|
-
workingDirectory: options?.workingDirectory,
|
|
48357
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48335
48358
|
background: options?.background
|
|
48336
48359
|
});
|
|
48337
48360
|
const stdout = execution.logs.stdout.map((msg) => msg.text).join(`
|
|
@@ -48368,7 +48391,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48368
48391
|
} : {}
|
|
48369
48392
|
};
|
|
48370
48393
|
const execution = await this.sandbox.commands.run(command, {
|
|
48371
|
-
workingDirectory: options?.workingDirectory,
|
|
48394
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48372
48395
|
background: options?.background
|
|
48373
48396
|
}, sdkHandlers);
|
|
48374
48397
|
if (handlers.onComplete) {
|
|
@@ -48390,7 +48413,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48390
48413
|
async executeBackground(command, options) {
|
|
48391
48414
|
try {
|
|
48392
48415
|
const execution = await this.sandbox.commands.run(command, {
|
|
48393
|
-
workingDirectory: options?.workingDirectory,
|
|
48416
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48394
48417
|
background: true
|
|
48395
48418
|
});
|
|
48396
48419
|
if (!execution.id) {
|
|
@@ -48438,6 +48461,9 @@ var import_code_interpreter = __toESM(require_dist4());
|
|
|
48438
48461
|
class E2BAdapter extends BaseSandboxAdapter {
|
|
48439
48462
|
config;
|
|
48440
48463
|
provider = "e2b";
|
|
48464
|
+
get rootPath() {
|
|
48465
|
+
return "/home/user";
|
|
48466
|
+
}
|
|
48441
48467
|
sandbox = null;
|
|
48442
48468
|
_id;
|
|
48443
48469
|
constructor(config) {
|
|
@@ -48567,7 +48593,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48567
48593
|
try {
|
|
48568
48594
|
const sandbox = await this.ensureSandbox();
|
|
48569
48595
|
const result = await sandbox.commands.run(command, {
|
|
48570
|
-
cwd: options?.workingDirectory,
|
|
48596
|
+
cwd: this.normalizePath(options?.workingDirectory),
|
|
48571
48597
|
timeoutMs: options?.timeoutMs
|
|
48572
48598
|
});
|
|
48573
48599
|
return {
|
|
@@ -48590,7 +48616,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48590
48616
|
const sandbox = await this.ensureSandbox();
|
|
48591
48617
|
try {
|
|
48592
48618
|
const results = [];
|
|
48593
|
-
for (const path of paths) {
|
|
48619
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48594
48620
|
try {
|
|
48595
48621
|
const content = await sandbox.files.read(path);
|
|
48596
48622
|
results.push({
|
|
@@ -48627,7 +48653,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48627
48653
|
data = "";
|
|
48628
48654
|
}
|
|
48629
48655
|
return {
|
|
48630
|
-
path: f.path,
|
|
48656
|
+
path: this.normalizePath(f.path),
|
|
48631
48657
|
data
|
|
48632
48658
|
};
|
|
48633
48659
|
});
|
|
@@ -48666,7 +48692,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48666
48692
|
const sandbox = await this.ensureSandbox();
|
|
48667
48693
|
try {
|
|
48668
48694
|
const results = [];
|
|
48669
|
-
for (const path of paths) {
|
|
48695
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48670
48696
|
try {
|
|
48671
48697
|
await sandbox.files.remove(path);
|
|
48672
48698
|
results.push({
|
|
@@ -48691,7 +48717,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48691
48717
|
const sandbox = await this.ensureSandbox();
|
|
48692
48718
|
try {
|
|
48693
48719
|
for (const { source, destination } of moves) {
|
|
48694
|
-
await sandbox.files.rename(source, destination);
|
|
48720
|
+
await sandbox.files.rename(this.normalizePath(source), this.normalizePath(destination));
|
|
48695
48721
|
}
|
|
48696
48722
|
} catch (error) {
|
|
48697
48723
|
throw new CommandExecutionError("Failed to move files", "moveFiles", error instanceof Error ? error : undefined);
|
|
@@ -48700,7 +48726,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48700
48726
|
async createDirectories(paths) {
|
|
48701
48727
|
const sandbox = await this.ensureSandbox();
|
|
48702
48728
|
try {
|
|
48703
|
-
for (const path of paths) {
|
|
48729
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48704
48730
|
await sandbox.files.makeDir(path);
|
|
48705
48731
|
}
|
|
48706
48732
|
} catch (error) {
|
|
@@ -48710,7 +48736,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48710
48736
|
async deleteDirectories(paths) {
|
|
48711
48737
|
const sandbox = await this.ensureSandbox();
|
|
48712
48738
|
try {
|
|
48713
|
-
for (const path of paths) {
|
|
48739
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48714
48740
|
await sandbox.files.remove(path);
|
|
48715
48741
|
}
|
|
48716
48742
|
} catch (error) {
|
|
@@ -48720,7 +48746,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48720
48746
|
async listDirectory(path) {
|
|
48721
48747
|
const sandbox = await this.ensureSandbox();
|
|
48722
48748
|
try {
|
|
48723
|
-
const entries = await sandbox.files.list(path);
|
|
48749
|
+
const entries = await sandbox.files.list(this.normalizePath(path));
|
|
48724
48750
|
return entries.map((entry) => {
|
|
48725
48751
|
const isDirectory = entry.type === import_code_interpreter.FileType.DIR;
|
|
48726
48752
|
return {
|
package/dist/index.js
CHANGED
|
@@ -47490,6 +47490,19 @@ class BaseSandboxAdapter {
|
|
|
47490
47490
|
_status = { state: "Creating" };
|
|
47491
47491
|
polyfillService;
|
|
47492
47492
|
constructor() {}
|
|
47493
|
+
get rootPath() {
|
|
47494
|
+
return "/";
|
|
47495
|
+
}
|
|
47496
|
+
normalizePath(path = "") {
|
|
47497
|
+
if (path === "." || path === "./")
|
|
47498
|
+
return this.rootPath;
|
|
47499
|
+
const root = this.rootPath.replace(/\/+$/, "");
|
|
47500
|
+
if (path.startsWith("./"))
|
|
47501
|
+
return `${root}/${path.slice(2)}`;
|
|
47502
|
+
if (!path.startsWith("/"))
|
|
47503
|
+
return `${root}/${path}`;
|
|
47504
|
+
return path;
|
|
47505
|
+
}
|
|
47493
47506
|
get status() {
|
|
47494
47507
|
return this._status;
|
|
47495
47508
|
}
|
|
@@ -47541,7 +47554,7 @@ class BaseSandboxAdapter {
|
|
|
47541
47554
|
async readFiles(paths, options) {
|
|
47542
47555
|
const polyfillService = this.requirePolyfillService("readFiles", "File read not supported by this provider");
|
|
47543
47556
|
const results = [];
|
|
47544
|
-
for (const path of paths) {
|
|
47557
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
47545
47558
|
try {
|
|
47546
47559
|
let content;
|
|
47547
47560
|
if (options?.range) {
|
|
@@ -47569,7 +47582,7 @@ class BaseSandboxAdapter {
|
|
|
47569
47582
|
async writeFiles(entries) {
|
|
47570
47583
|
const polyfillService = this.requirePolyfillService("writeFiles", "File write not supported by this provider");
|
|
47571
47584
|
const results = [];
|
|
47572
|
-
for (const entry of entries) {
|
|
47585
|
+
for (const entry of entries.map((e) => ({ ...e, path: this.normalizePath(e.path) }))) {
|
|
47573
47586
|
try {
|
|
47574
47587
|
let bytesWritten;
|
|
47575
47588
|
if (typeof entry.data === "string") {
|
|
@@ -47613,7 +47626,7 @@ class BaseSandboxAdapter {
|
|
|
47613
47626
|
}
|
|
47614
47627
|
async deleteFiles(paths) {
|
|
47615
47628
|
const polyfillService = this.requirePolyfillService("deleteFiles", "File delete not supported by this provider");
|
|
47616
|
-
const polyfillResults = await polyfillService.deleteFiles(paths);
|
|
47629
|
+
const polyfillResults = await polyfillService.deleteFiles(paths.map((p) => this.normalizePath(p)));
|
|
47617
47630
|
return polyfillResults.map((r) => ({
|
|
47618
47631
|
path: r.path,
|
|
47619
47632
|
success: r.success,
|
|
@@ -47622,7 +47635,10 @@ class BaseSandboxAdapter {
|
|
|
47622
47635
|
}
|
|
47623
47636
|
async moveFiles(entries) {
|
|
47624
47637
|
const polyfillService = this.requirePolyfillService("moveFiles", "File move not supported by this provider");
|
|
47625
|
-
await polyfillService.moveFiles(entries.map((e) => ({
|
|
47638
|
+
await polyfillService.moveFiles(entries.map((e) => ({
|
|
47639
|
+
source: this.normalizePath(e.source),
|
|
47640
|
+
destination: this.normalizePath(e.destination)
|
|
47641
|
+
})));
|
|
47626
47642
|
}
|
|
47627
47643
|
async replaceContent(entries) {
|
|
47628
47644
|
const polyfillService = this.requirePolyfillService("replaceContent", "Content replace not supported by this provider");
|
|
@@ -47630,15 +47646,15 @@ class BaseSandboxAdapter {
|
|
|
47630
47646
|
}
|
|
47631
47647
|
async createDirectories(paths, options) {
|
|
47632
47648
|
const polyfillService = this.requirePolyfillService("createDirectories", "Directory creation not supported by this provider");
|
|
47633
|
-
await polyfillService.createDirectories(paths, options);
|
|
47649
|
+
await polyfillService.createDirectories(paths.map((p) => this.normalizePath(p)), options);
|
|
47634
47650
|
}
|
|
47635
47651
|
async deleteDirectories(paths, options) {
|
|
47636
47652
|
const polyfillService = this.requirePolyfillService("deleteDirectories", "Directory deletion not supported by this provider");
|
|
47637
|
-
await polyfillService.deleteDirectories(paths, options);
|
|
47653
|
+
await polyfillService.deleteDirectories(paths.map((p) => this.normalizePath(p)), options);
|
|
47638
47654
|
}
|
|
47639
47655
|
async listDirectory(path) {
|
|
47640
47656
|
const polyfillService = this.requirePolyfillService("listDirectory", "Directory listing not supported by this provider");
|
|
47641
|
-
return polyfillService.listDirectory(path);
|
|
47657
|
+
return polyfillService.listDirectory(this.normalizePath(path));
|
|
47642
47658
|
}
|
|
47643
47659
|
async* readFileStream(path) {
|
|
47644
47660
|
this.requirePolyfillService("readFileStream", "File stream read not supported by this provider");
|
|
@@ -47690,7 +47706,7 @@ class BaseSandboxAdapter {
|
|
|
47690
47706
|
}
|
|
47691
47707
|
async getFileInfo(paths) {
|
|
47692
47708
|
const polyfillService = this.requirePolyfillService("getFileInfo", "File info not supported by this provider");
|
|
47693
|
-
return polyfillService.getFileInfo(paths);
|
|
47709
|
+
return polyfillService.getFileInfo(paths.map((p) => this.normalizePath(p)));
|
|
47694
47710
|
}
|
|
47695
47711
|
async setPermissions(entries) {
|
|
47696
47712
|
const polyfillService = this.requirePolyfillService("setPermissions", "Permission setting not supported by this provider");
|
|
@@ -47698,7 +47714,7 @@ class BaseSandboxAdapter {
|
|
|
47698
47714
|
}
|
|
47699
47715
|
async search(pattern, path) {
|
|
47700
47716
|
const polyfillService = this.requirePolyfillService("search", "File search not supported by this provider");
|
|
47701
|
-
return polyfillService.search(pattern, path);
|
|
47717
|
+
return polyfillService.search(pattern, path !== undefined ? this.normalizePath(path) : path);
|
|
47702
47718
|
}
|
|
47703
47719
|
async ping() {
|
|
47704
47720
|
const polyfillService = this.requirePolyfillService("ping", "Health check not supported by this provider");
|
|
@@ -47821,6 +47837,9 @@ class DevboxApi {
|
|
|
47821
47837
|
class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
47822
47838
|
config;
|
|
47823
47839
|
provider = "sealosdevbox";
|
|
47840
|
+
get rootPath() {
|
|
47841
|
+
return "/home/devbox/workspace";
|
|
47842
|
+
}
|
|
47824
47843
|
api;
|
|
47825
47844
|
_id;
|
|
47826
47845
|
constructor(config) {
|
|
@@ -47940,7 +47959,7 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
|
|
|
47940
47959
|
}
|
|
47941
47960
|
}
|
|
47942
47961
|
async execute(command, options) {
|
|
47943
|
-
const cmd = this.buildCommand(command, options?.workingDirectory);
|
|
47962
|
+
const cmd = this.buildCommand(command, this.normalizePath(options?.workingDirectory));
|
|
47944
47963
|
try {
|
|
47945
47964
|
const res = await this.api.exec(this._id, {
|
|
47946
47965
|
command: cmd,
|
|
@@ -47988,6 +48007,10 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
47988
48007
|
this._connection = this.createConnectionConfig();
|
|
47989
48008
|
this.polyfillService = new CommandPolyfillService(this);
|
|
47990
48009
|
}
|
|
48010
|
+
get rootPath() {
|
|
48011
|
+
const mountPath = this.createConfig.volumes?.[0]?.mountPath;
|
|
48012
|
+
return mountPath ? mountPath.replace(/\/+$/, "") : "/home/sandbox";
|
|
48013
|
+
}
|
|
47991
48014
|
get id() {
|
|
47992
48015
|
return this._id;
|
|
47993
48016
|
}
|
|
@@ -48315,7 +48338,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48315
48338
|
async execute(command, options) {
|
|
48316
48339
|
try {
|
|
48317
48340
|
const execution = await this.sandbox.commands.run(command, {
|
|
48318
|
-
workingDirectory: options?.workingDirectory,
|
|
48341
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48319
48342
|
background: options?.background
|
|
48320
48343
|
});
|
|
48321
48344
|
const stdout = execution.logs.stdout.map((msg) => msg.text).join(`
|
|
@@ -48352,7 +48375,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48352
48375
|
} : {}
|
|
48353
48376
|
};
|
|
48354
48377
|
const execution = await this.sandbox.commands.run(command, {
|
|
48355
|
-
workingDirectory: options?.workingDirectory,
|
|
48378
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48356
48379
|
background: options?.background
|
|
48357
48380
|
}, sdkHandlers);
|
|
48358
48381
|
if (handlers.onComplete) {
|
|
@@ -48374,7 +48397,7 @@ class OpenSandboxAdapter extends BaseSandboxAdapter {
|
|
|
48374
48397
|
async executeBackground(command, options) {
|
|
48375
48398
|
try {
|
|
48376
48399
|
const execution = await this.sandbox.commands.run(command, {
|
|
48377
|
-
workingDirectory: options?.workingDirectory,
|
|
48400
|
+
workingDirectory: this.normalizePath(options?.workingDirectory),
|
|
48378
48401
|
background: true
|
|
48379
48402
|
});
|
|
48380
48403
|
if (!execution.id) {
|
|
@@ -48422,6 +48445,9 @@ var import_code_interpreter = __toESM(require_dist4(), 1);
|
|
|
48422
48445
|
class E2BAdapter extends BaseSandboxAdapter {
|
|
48423
48446
|
config;
|
|
48424
48447
|
provider = "e2b";
|
|
48448
|
+
get rootPath() {
|
|
48449
|
+
return "/home/user";
|
|
48450
|
+
}
|
|
48425
48451
|
sandbox = null;
|
|
48426
48452
|
_id;
|
|
48427
48453
|
constructor(config) {
|
|
@@ -48551,7 +48577,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48551
48577
|
try {
|
|
48552
48578
|
const sandbox = await this.ensureSandbox();
|
|
48553
48579
|
const result = await sandbox.commands.run(command, {
|
|
48554
|
-
cwd: options?.workingDirectory,
|
|
48580
|
+
cwd: this.normalizePath(options?.workingDirectory),
|
|
48555
48581
|
timeoutMs: options?.timeoutMs
|
|
48556
48582
|
});
|
|
48557
48583
|
return {
|
|
@@ -48574,7 +48600,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48574
48600
|
const sandbox = await this.ensureSandbox();
|
|
48575
48601
|
try {
|
|
48576
48602
|
const results = [];
|
|
48577
|
-
for (const path of paths) {
|
|
48603
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48578
48604
|
try {
|
|
48579
48605
|
const content = await sandbox.files.read(path);
|
|
48580
48606
|
results.push({
|
|
@@ -48611,7 +48637,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48611
48637
|
data = "";
|
|
48612
48638
|
}
|
|
48613
48639
|
return {
|
|
48614
|
-
path: f.path,
|
|
48640
|
+
path: this.normalizePath(f.path),
|
|
48615
48641
|
data
|
|
48616
48642
|
};
|
|
48617
48643
|
});
|
|
@@ -48650,7 +48676,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48650
48676
|
const sandbox = await this.ensureSandbox();
|
|
48651
48677
|
try {
|
|
48652
48678
|
const results = [];
|
|
48653
|
-
for (const path of paths) {
|
|
48679
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48654
48680
|
try {
|
|
48655
48681
|
await sandbox.files.remove(path);
|
|
48656
48682
|
results.push({
|
|
@@ -48675,7 +48701,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48675
48701
|
const sandbox = await this.ensureSandbox();
|
|
48676
48702
|
try {
|
|
48677
48703
|
for (const { source, destination } of moves) {
|
|
48678
|
-
await sandbox.files.rename(source, destination);
|
|
48704
|
+
await sandbox.files.rename(this.normalizePath(source), this.normalizePath(destination));
|
|
48679
48705
|
}
|
|
48680
48706
|
} catch (error) {
|
|
48681
48707
|
throw new CommandExecutionError("Failed to move files", "moveFiles", error instanceof Error ? error : undefined);
|
|
@@ -48684,7 +48710,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48684
48710
|
async createDirectories(paths) {
|
|
48685
48711
|
const sandbox = await this.ensureSandbox();
|
|
48686
48712
|
try {
|
|
48687
|
-
for (const path of paths) {
|
|
48713
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48688
48714
|
await sandbox.files.makeDir(path);
|
|
48689
48715
|
}
|
|
48690
48716
|
} catch (error) {
|
|
@@ -48694,7 +48720,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48694
48720
|
async deleteDirectories(paths) {
|
|
48695
48721
|
const sandbox = await this.ensureSandbox();
|
|
48696
48722
|
try {
|
|
48697
|
-
for (const path of paths) {
|
|
48723
|
+
for (const path of paths.map((p) => this.normalizePath(p))) {
|
|
48698
48724
|
await sandbox.files.remove(path);
|
|
48699
48725
|
}
|
|
48700
48726
|
} catch (error) {
|
|
@@ -48704,7 +48730,7 @@ class E2BAdapter extends BaseSandboxAdapter {
|
|
|
48704
48730
|
async listDirectory(path) {
|
|
48705
48731
|
const sandbox = await this.ensureSandbox();
|
|
48706
48732
|
try {
|
|
48707
|
-
const entries = await sandbox.files.list(path);
|
|
48733
|
+
const entries = await sandbox.files.list(this.normalizePath(path));
|
|
48708
48734
|
return entries.map((entry) => {
|
|
48709
48735
|
const isDirectory = entry.type === import_code_interpreter.FileType.DIR;
|
|
48710
48736
|
return {
|
package/package.json
CHANGED