@sandagent/manager 0.1.0-beta.0 → 0.2.0-beta.5
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/LICENSE +201 -0
- package/README.md +1 -1
- package/dist/__tests__/local-sandbox.test.d.ts +2 -0
- package/dist/__tests__/local-sandbox.test.d.ts.map +1 -0
- package/dist/__tests__/local-sandbox.test.js +300 -0
- package/dist/__tests__/local-sandbox.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/local-sandbox.d.ts +83 -0
- package/dist/local-sandbox.d.ts.map +1 -0
- package/dist/local-sandbox.js +281 -0
- package/dist/local-sandbox.js.map +1 -0
- package/dist/sand-agent.d.ts.map +1 -1
- package/dist/sand-agent.js +4 -1
- package/dist/sand-agent.js.map +1 -1
- package/dist/types.d.ts +0 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Core manager package for SandAgent - manages sandbox and runner lifecycle, defin
|
|
|
11
11
|
- **Transcript Writers**: Tools for logging agent execution (JSONL, Memory, Console, Multi)
|
|
12
12
|
- **Type Definitions**: Shared types for messages, streams, and sandbox operations
|
|
13
13
|
|
|
14
|
-
This package is typically used as a dependency by higher-level packages like `@sandagent/
|
|
14
|
+
This package is typically used as a dependency by higher-level packages like `@sandagent/sdk` and sandbox adapters.
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-sandbox.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/local-sandbox.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { LocalSandbox } from "../local-sandbox.js";
|
|
6
|
+
describe("LocalSandbox", () => {
|
|
7
|
+
let tempDir;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
// Create a temporary directory for testing
|
|
10
|
+
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "local-sandbox-test-"));
|
|
11
|
+
});
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
// Clean up temporary directory
|
|
14
|
+
try {
|
|
15
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.warn(`Failed to clean up temp dir: ${tempDir}`, error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
describe("constructor", () => {
|
|
22
|
+
it("should create an instance with default options", () => {
|
|
23
|
+
const sandbox = new LocalSandbox();
|
|
24
|
+
expect(sandbox).toBeInstanceOf(LocalSandbox);
|
|
25
|
+
});
|
|
26
|
+
it("should accept custom options", () => {
|
|
27
|
+
const sandbox = new LocalSandbox({
|
|
28
|
+
baseDir: tempDir,
|
|
29
|
+
isolate: true,
|
|
30
|
+
defaultTimeout: 30000,
|
|
31
|
+
});
|
|
32
|
+
expect(sandbox).toBeInstanceOf(LocalSandbox);
|
|
33
|
+
});
|
|
34
|
+
it("should use process.cwd() as default baseDir", () => {
|
|
35
|
+
const sandbox = new LocalSandbox();
|
|
36
|
+
expect(sandbox).toBeInstanceOf(LocalSandbox);
|
|
37
|
+
});
|
|
38
|
+
it("should allow disabling isolation", () => {
|
|
39
|
+
const sandbox = new LocalSandbox({
|
|
40
|
+
baseDir: tempDir,
|
|
41
|
+
isolate: false,
|
|
42
|
+
});
|
|
43
|
+
expect(sandbox).toBeInstanceOf(LocalSandbox);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe("attach", () => {
|
|
47
|
+
it("should create isolated directory for sandbox ID", async () => {
|
|
48
|
+
const sandbox = new LocalSandbox({
|
|
49
|
+
baseDir: tempDir,
|
|
50
|
+
isolate: true,
|
|
51
|
+
});
|
|
52
|
+
const handle = await sandbox.attach();
|
|
53
|
+
expect(handle).toBeDefined();
|
|
54
|
+
// Verify a directory was created (with auto-generated name)
|
|
55
|
+
// Since isolate is true, a unique subdirectory should be created
|
|
56
|
+
const dirs = await fs.readdir(tempDir);
|
|
57
|
+
expect(dirs.length).toBeGreaterThan(0);
|
|
58
|
+
const createdDir = dirs.find((d) => d.startsWith("sandbox-"));
|
|
59
|
+
expect(createdDir).toBeDefined();
|
|
60
|
+
const expectedDir = path.join(tempDir, createdDir);
|
|
61
|
+
const stat = await fs.stat(expectedDir);
|
|
62
|
+
expect(stat.isDirectory()).toBe(true);
|
|
63
|
+
await handle.destroy();
|
|
64
|
+
});
|
|
65
|
+
it("should use base directory when isolation is disabled", async () => {
|
|
66
|
+
const sandbox = new LocalSandbox({
|
|
67
|
+
baseDir: tempDir,
|
|
68
|
+
isolate: false,
|
|
69
|
+
});
|
|
70
|
+
const handle = await sandbox.attach();
|
|
71
|
+
expect(handle).toBeDefined();
|
|
72
|
+
await handle.destroy();
|
|
73
|
+
});
|
|
74
|
+
it("should return a SandboxHandle", async () => {
|
|
75
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
76
|
+
const handle = await sandbox.attach();
|
|
77
|
+
expect(typeof handle.exec).toBe("function");
|
|
78
|
+
expect(typeof handle.upload).toBe("function");
|
|
79
|
+
expect(typeof handle.destroy).toBe("function");
|
|
80
|
+
await handle.destroy();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe("SandboxHandle.exec", () => {
|
|
84
|
+
it("should execute a simple command", async () => {
|
|
85
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
86
|
+
const handle = await sandbox.attach();
|
|
87
|
+
const chunks = [];
|
|
88
|
+
for await (const chunk of handle.exec(["echo", "hello world"])) {
|
|
89
|
+
chunks.push(new TextDecoder().decode(chunk));
|
|
90
|
+
}
|
|
91
|
+
const output = chunks.join("");
|
|
92
|
+
expect(output.trim()).toBe("hello world");
|
|
93
|
+
await handle.destroy();
|
|
94
|
+
});
|
|
95
|
+
it("should execute commands in specified working directory", async () => {
|
|
96
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
97
|
+
const handle = await sandbox.attach();
|
|
98
|
+
// Create a subdirectory
|
|
99
|
+
const subDir = "subdir";
|
|
100
|
+
await handle.upload([], subDir); // Creates the directory
|
|
101
|
+
// Create a test file in the subdirectory
|
|
102
|
+
await handle.upload([{ path: "test.txt", content: "test content" }], subDir);
|
|
103
|
+
// List files in the subdirectory
|
|
104
|
+
const chunks = [];
|
|
105
|
+
for await (const chunk of handle.exec(["ls"], { cwd: subDir })) {
|
|
106
|
+
chunks.push(new TextDecoder().decode(chunk));
|
|
107
|
+
}
|
|
108
|
+
const output = chunks.join("");
|
|
109
|
+
expect(output).toContain("test.txt");
|
|
110
|
+
await handle.destroy();
|
|
111
|
+
});
|
|
112
|
+
it("should pass environment variables", async () => {
|
|
113
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
114
|
+
const handle = await sandbox.attach();
|
|
115
|
+
const chunks = [];
|
|
116
|
+
for await (const chunk of handle.exec(["sh", "-c", "echo $TEST_VAR"], {
|
|
117
|
+
env: { TEST_VAR: "test-value" },
|
|
118
|
+
})) {
|
|
119
|
+
chunks.push(new TextDecoder().decode(chunk));
|
|
120
|
+
}
|
|
121
|
+
const output = chunks.join("");
|
|
122
|
+
expect(output.trim()).toBe("test-value");
|
|
123
|
+
await handle.destroy();
|
|
124
|
+
});
|
|
125
|
+
it("should throw error for non-existent command", async () => {
|
|
126
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
127
|
+
const handle = await sandbox.attach();
|
|
128
|
+
await expect(async () => {
|
|
129
|
+
const chunks = [];
|
|
130
|
+
for await (const chunk of handle.exec([
|
|
131
|
+
"non-existent-command-xyz123",
|
|
132
|
+
])) {
|
|
133
|
+
chunks.push(chunk);
|
|
134
|
+
}
|
|
135
|
+
}).rejects.toThrow();
|
|
136
|
+
await handle.destroy();
|
|
137
|
+
});
|
|
138
|
+
it("should throw error for empty command", async () => {
|
|
139
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
140
|
+
const handle = await sandbox.attach();
|
|
141
|
+
await expect(async () => {
|
|
142
|
+
const chunks = [];
|
|
143
|
+
for await (const chunk of handle.exec([])) {
|
|
144
|
+
chunks.push(chunk);
|
|
145
|
+
}
|
|
146
|
+
}).rejects.toThrow("Command cannot be empty");
|
|
147
|
+
await handle.destroy();
|
|
148
|
+
});
|
|
149
|
+
it("should handle command timeout", async () => {
|
|
150
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
151
|
+
const handle = await sandbox.attach();
|
|
152
|
+
await expect(async () => {
|
|
153
|
+
const chunks = [];
|
|
154
|
+
for await (const chunk of handle.exec(["sleep", "10"], {
|
|
155
|
+
timeout: 100, // 100ms timeout
|
|
156
|
+
})) {
|
|
157
|
+
chunks.push(chunk);
|
|
158
|
+
}
|
|
159
|
+
}).rejects.toThrow(/timed out/i);
|
|
160
|
+
await handle.destroy();
|
|
161
|
+
}, 10000); // Test timeout of 10 seconds
|
|
162
|
+
it("should support abort signal", async () => {
|
|
163
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
164
|
+
const handle = await sandbox.attach();
|
|
165
|
+
const abortController = new AbortController();
|
|
166
|
+
// Abort after 100ms
|
|
167
|
+
setTimeout(() => abortController.abort(), 100);
|
|
168
|
+
await expect(async () => {
|
|
169
|
+
const chunks = [];
|
|
170
|
+
for await (const chunk of handle.exec(["sleep", "10"], {
|
|
171
|
+
signal: abortController.signal,
|
|
172
|
+
})) {
|
|
173
|
+
chunks.push(chunk);
|
|
174
|
+
}
|
|
175
|
+
}).rejects.toThrow();
|
|
176
|
+
await handle.destroy();
|
|
177
|
+
}, 10000);
|
|
178
|
+
});
|
|
179
|
+
describe("SandboxHandle.upload", () => {
|
|
180
|
+
it("should upload a single file", async () => {
|
|
181
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
182
|
+
const handle = await sandbox.attach();
|
|
183
|
+
await handle.upload([{ path: "test.txt", content: "Hello, World!" }], ".");
|
|
184
|
+
// Verify the file was created
|
|
185
|
+
const filePath = path.join(tempDir, "test.txt");
|
|
186
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
187
|
+
expect(content).toBe("Hello, World!");
|
|
188
|
+
await handle.destroy();
|
|
189
|
+
});
|
|
190
|
+
it("should upload multiple files", async () => {
|
|
191
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
192
|
+
const handle = await sandbox.attach();
|
|
193
|
+
await handle.upload([
|
|
194
|
+
{ path: "file1.txt", content: "Content 1" },
|
|
195
|
+
{ path: "file2.txt", content: "Content 2" },
|
|
196
|
+
{ path: "file3.txt", content: "Content 3" },
|
|
197
|
+
], "uploads");
|
|
198
|
+
// Verify all files were created
|
|
199
|
+
const uploadsDir = path.join(tempDir, "uploads");
|
|
200
|
+
const files = await fs.readdir(uploadsDir);
|
|
201
|
+
expect(files).toContain("file1.txt");
|
|
202
|
+
expect(files).toContain("file2.txt");
|
|
203
|
+
expect(files).toContain("file3.txt");
|
|
204
|
+
await handle.destroy();
|
|
205
|
+
});
|
|
206
|
+
it("should upload binary content", async () => {
|
|
207
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
208
|
+
const handle = await sandbox.attach();
|
|
209
|
+
const binaryData = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]); // "Hello"
|
|
210
|
+
await handle.upload([{ path: "binary.dat", content: binaryData }], ".");
|
|
211
|
+
// Verify the binary file
|
|
212
|
+
const filePath = path.join(tempDir, "binary.dat");
|
|
213
|
+
const content = await fs.readFile(filePath);
|
|
214
|
+
expect(content).toEqual(Buffer.from(binaryData));
|
|
215
|
+
await handle.destroy();
|
|
216
|
+
});
|
|
217
|
+
it("should create nested directories", async () => {
|
|
218
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
219
|
+
const handle = await sandbox.attach();
|
|
220
|
+
await handle.upload([{ path: "deep/nested/dir/file.txt", content: "Nested content" }], ".");
|
|
221
|
+
// Verify nested file
|
|
222
|
+
const filePath = path.join(tempDir, "deep/nested/dir/file.txt");
|
|
223
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
224
|
+
expect(content).toBe("Nested content");
|
|
225
|
+
await handle.destroy();
|
|
226
|
+
});
|
|
227
|
+
it("should upload to custom target directory", async () => {
|
|
228
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
229
|
+
const handle = await sandbox.attach();
|
|
230
|
+
await handle.upload([{ path: "file.txt", content: "Custom target" }], "custom/target");
|
|
231
|
+
// Verify file in custom location
|
|
232
|
+
const filePath = path.join(tempDir, "custom/target/file.txt");
|
|
233
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
234
|
+
expect(content).toBe("Custom target");
|
|
235
|
+
await handle.destroy();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
describe("SandboxHandle.destroy", () => {
|
|
239
|
+
it("should complete successfully", async () => {
|
|
240
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
241
|
+
const handle = await sandbox.attach();
|
|
242
|
+
await expect(handle.destroy()).resolves.toBeUndefined();
|
|
243
|
+
});
|
|
244
|
+
it("should not delete the working directory by default", async () => {
|
|
245
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir, isolate: false });
|
|
246
|
+
const handle = await sandbox.attach();
|
|
247
|
+
await handle.upload([{ path: "file.txt", content: "Test" }], ".");
|
|
248
|
+
await handle.destroy();
|
|
249
|
+
// Directory should still exist
|
|
250
|
+
const stat = await fs.stat(tempDir);
|
|
251
|
+
expect(stat.isDirectory()).toBe(true);
|
|
252
|
+
// File should still exist
|
|
253
|
+
const filePath = path.join(tempDir, "file.txt");
|
|
254
|
+
const fileStat = await fs.stat(filePath);
|
|
255
|
+
expect(fileStat.isFile()).toBe(true);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
describe("Integration tests", () => {
|
|
259
|
+
it("should support a complete workflow", async () => {
|
|
260
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
261
|
+
const handle = await sandbox.attach();
|
|
262
|
+
// Upload a Python script
|
|
263
|
+
await handle.upload([
|
|
264
|
+
{
|
|
265
|
+
path: "script.py",
|
|
266
|
+
content: 'print("Hello from Python!")\nprint("Line 2")',
|
|
267
|
+
},
|
|
268
|
+
], ".");
|
|
269
|
+
// Execute the script
|
|
270
|
+
const chunks = [];
|
|
271
|
+
for await (const chunk of handle.exec(["python3", "script.py"])) {
|
|
272
|
+
chunks.push(new TextDecoder().decode(chunk));
|
|
273
|
+
}
|
|
274
|
+
const output = chunks.join("");
|
|
275
|
+
expect(output).toContain("Hello from Python!");
|
|
276
|
+
expect(output).toContain("Line 2");
|
|
277
|
+
await handle.destroy();
|
|
278
|
+
});
|
|
279
|
+
it("should handle multiple sequential commands", async () => {
|
|
280
|
+
const sandbox = new LocalSandbox({ baseDir: tempDir });
|
|
281
|
+
const handle = await sandbox.attach();
|
|
282
|
+
// Create a file
|
|
283
|
+
await handle.upload([{ path: "data.txt", content: "test data" }], ".");
|
|
284
|
+
// Read the file with cat
|
|
285
|
+
const chunks1 = [];
|
|
286
|
+
for await (const chunk of handle.exec(["cat", "data.txt"])) {
|
|
287
|
+
chunks1.push(new TextDecoder().decode(chunk));
|
|
288
|
+
}
|
|
289
|
+
expect(chunks1.join("")).toContain("test data");
|
|
290
|
+
// List files
|
|
291
|
+
const chunks2 = [];
|
|
292
|
+
for await (const chunk of handle.exec(["ls", "-la"])) {
|
|
293
|
+
chunks2.push(new TextDecoder().decode(chunk));
|
|
294
|
+
}
|
|
295
|
+
expect(chunks2.join("")).toContain("data.txt");
|
|
296
|
+
await handle.destroy();
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
//# sourceMappingURL=local-sandbox.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-sandbox.test.js","sourceRoot":"","sources":["../../src/__tests__/local-sandbox.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,2CAA2C;QAC3C,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,+BAA+B;QAC/B,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EA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ACrD,OAAO,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;YACD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAE/C,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { SandAgent } from "./sand-agent.js";
|
|
2
2
|
export { JsonlTranscriptWriter, MemoryTranscriptWriter, ConsoleTranscriptWriter, MultiTranscriptWriter, } from "./transcript.js";
|
|
3
3
|
export type { SandAgentOptions, SandboxAdapter, SandboxHandle, RunnerSpec, StreamInput, Message, ExecOptions, TranscriptWriter, TranscriptEntry, } from "./types.js";
|
|
4
|
+
export { LocalSandbox } from "./local-sandbox.js";
|
|
5
|
+
export type { LocalSandboxOptions } from "./local-sandbox.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { SandAgent } from "./sand-agent.js";
|
|
2
2
|
export { JsonlTranscriptWriter, MemoryTranscriptWriter, ConsoleTranscriptWriter, MultiTranscriptWriter, } from "./transcript.js";
|
|
3
|
+
// Default sandbox adapter (built-in)
|
|
4
|
+
export { LocalSandbox } from "./local-sandbox.js";
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAazB,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SandboxAdapter, SandboxHandle } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a LocalSandbox instance
|
|
4
|
+
*/
|
|
5
|
+
export interface LocalSandboxOptions {
|
|
6
|
+
/** Base working directory for all operations (defaults to process.cwd()) */
|
|
7
|
+
baseDir?: string;
|
|
8
|
+
/** Whether to isolate each sandbox ID in its own subdirectory (default: true) */
|
|
9
|
+
isolate?: boolean;
|
|
10
|
+
/** Default timeout for commands in milliseconds (default: 60000) */
|
|
11
|
+
defaultTimeout?: number;
|
|
12
|
+
/** Environment variables to pass to all commands */
|
|
13
|
+
env?: Record<string, string>;
|
|
14
|
+
/** Runner command to execute in the sandbox (default: ["sandagent", "run"]) */
|
|
15
|
+
runnerCommand?: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Local sandbox implementation that runs commands on the local machine.
|
|
19
|
+
*
|
|
20
|
+
* This adapter is useful for:
|
|
21
|
+
* - Development and testing
|
|
22
|
+
* - Running agents locally without cloud dependencies
|
|
23
|
+
* - Quick prototyping
|
|
24
|
+
*
|
|
25
|
+
* Warning: This runs commands directly on your local machine with your user's
|
|
26
|
+
* permissions. Use with caution and only with trusted code.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { LocalSandbox, SandAgent } from "@sandagent/manager";
|
|
31
|
+
*
|
|
32
|
+
* // Use current directory as workspace (no isolation)
|
|
33
|
+
* const sandbox = new LocalSandbox({
|
|
34
|
+
* baseDir: process.cwd(),
|
|
35
|
+
* isolate: false,
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const agent = new SandAgent({
|
|
39
|
+
* sandbox,
|
|
40
|
+
* runner: {
|
|
41
|
+
* kind: "claude-agent-sdk",
|
|
42
|
+
* model: "claude-sonnet-4-20250514",
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Attach and run commands
|
|
47
|
+
* const handle = await sandbox.attach();
|
|
48
|
+
* const result = await handle.runCommand("ls -la");
|
|
49
|
+
* console.log(result.stdout);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class LocalSandbox implements SandboxAdapter {
|
|
53
|
+
private readonly baseDir;
|
|
54
|
+
private readonly isolate;
|
|
55
|
+
private readonly defaultTimeout;
|
|
56
|
+
private readonly env;
|
|
57
|
+
private readonly runnerCommand;
|
|
58
|
+
/** Current handle for the sandbox instance */
|
|
59
|
+
private currentHandle;
|
|
60
|
+
constructor(options?: LocalSandboxOptions);
|
|
61
|
+
getHandle(): SandboxHandle | null;
|
|
62
|
+
/**
|
|
63
|
+
* Get the environment variables configured for this sandbox.
|
|
64
|
+
*/
|
|
65
|
+
getEnv(): Record<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the working directory configured for this sandbox.
|
|
68
|
+
* Returns the current workDir if attached, otherwise the baseDir.
|
|
69
|
+
* Note: When isolate=true, the actual workDir will be baseDir/sandbox-xxx after attach().
|
|
70
|
+
*/
|
|
71
|
+
getWorkdir(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get the runner command to execute in the sandbox.
|
|
74
|
+
*/
|
|
75
|
+
getRunnerCommand(): string[];
|
|
76
|
+
attach(): Promise<SandboxHandle>;
|
|
77
|
+
/**
|
|
78
|
+
* Reset the sandbox, clearing the current handle.
|
|
79
|
+
* Next call to attach() will create a new working directory (if isolate is true).
|
|
80
|
+
*/
|
|
81
|
+
reset(): void;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=local-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-sandbox.d.ts","sourceRoot":"","sources":["../src/local-sandbox.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,YAAa,YAAW,cAAc;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAW;IAEzC,8CAA8C;IAC9C,OAAO,CAAC,aAAa,CAAmC;gBAE5C,OAAO,GAAE,mBAAwB;IAQ7C,SAAS,IAAI,aAAa,GAAG,IAAI;IAIjC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIhC;;;;OAIG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAItB,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC;IA+BtC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Local sandbox implementation that runs commands on the local machine.
|
|
6
|
+
*
|
|
7
|
+
* This adapter is useful for:
|
|
8
|
+
* - Development and testing
|
|
9
|
+
* - Running agents locally without cloud dependencies
|
|
10
|
+
* - Quick prototyping
|
|
11
|
+
*
|
|
12
|
+
* Warning: This runs commands directly on your local machine with your user's
|
|
13
|
+
* permissions. Use with caution and only with trusted code.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { LocalSandbox, SandAgent } from "@sandagent/manager";
|
|
18
|
+
*
|
|
19
|
+
* // Use current directory as workspace (no isolation)
|
|
20
|
+
* const sandbox = new LocalSandbox({
|
|
21
|
+
* baseDir: process.cwd(),
|
|
22
|
+
* isolate: false,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const agent = new SandAgent({
|
|
26
|
+
* sandbox,
|
|
27
|
+
* runner: {
|
|
28
|
+
* kind: "claude-agent-sdk",
|
|
29
|
+
* model: "claude-sonnet-4-20250514",
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Attach and run commands
|
|
34
|
+
* const handle = await sandbox.attach();
|
|
35
|
+
* const result = await handle.runCommand("ls -la");
|
|
36
|
+
* console.log(result.stdout);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class LocalSandbox {
|
|
40
|
+
baseDir;
|
|
41
|
+
isolate;
|
|
42
|
+
defaultTimeout;
|
|
43
|
+
env;
|
|
44
|
+
runnerCommand;
|
|
45
|
+
/** Current handle for the sandbox instance */
|
|
46
|
+
currentHandle = null;
|
|
47
|
+
constructor(options = {}) {
|
|
48
|
+
this.baseDir = options.baseDir ?? process.cwd();
|
|
49
|
+
this.isolate = options.isolate ?? true;
|
|
50
|
+
this.defaultTimeout = options.defaultTimeout ?? 60000;
|
|
51
|
+
this.env = options.env ?? {};
|
|
52
|
+
this.runnerCommand = options.runnerCommand ?? ["sandagent", "run"];
|
|
53
|
+
}
|
|
54
|
+
getHandle() {
|
|
55
|
+
return this.currentHandle;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the environment variables configured for this sandbox.
|
|
59
|
+
*/
|
|
60
|
+
getEnv() {
|
|
61
|
+
return { ...this.env };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the working directory configured for this sandbox.
|
|
65
|
+
* Returns the current workDir if attached, otherwise the baseDir.
|
|
66
|
+
* Note: When isolate=true, the actual workDir will be baseDir/sandbox-xxx after attach().
|
|
67
|
+
*/
|
|
68
|
+
getWorkdir() {
|
|
69
|
+
return this.currentHandle?.getWorkdir() ?? this.baseDir;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the runner command to execute in the sandbox.
|
|
73
|
+
*/
|
|
74
|
+
getRunnerCommand() {
|
|
75
|
+
return [...this.runnerCommand];
|
|
76
|
+
}
|
|
77
|
+
async attach() {
|
|
78
|
+
// Return existing handle if already attached
|
|
79
|
+
if (this.currentHandle) {
|
|
80
|
+
return this.currentHandle;
|
|
81
|
+
}
|
|
82
|
+
// Determine the working directory for this sandbox
|
|
83
|
+
// If isolation is enabled, use a unique subdirectory
|
|
84
|
+
const workDir = this.isolate
|
|
85
|
+
? path.join(this.baseDir, `sandbox-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`)
|
|
86
|
+
: this.baseDir;
|
|
87
|
+
// Create the directory if it doesn't exist
|
|
88
|
+
await fs.mkdir(workDir, { recursive: true });
|
|
89
|
+
console.log(`[LocalSandbox] Created/using directory: ${workDir}`);
|
|
90
|
+
const handle = new LocalSandboxHandle(workDir, this.defaultTimeout, this.env);
|
|
91
|
+
// Store the handle
|
|
92
|
+
this.currentHandle = handle;
|
|
93
|
+
return handle;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Reset the sandbox, clearing the current handle.
|
|
97
|
+
* Next call to attach() will create a new working directory (if isolate is true).
|
|
98
|
+
*/
|
|
99
|
+
reset() {
|
|
100
|
+
this.currentHandle = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Handle for a local sandbox instance
|
|
105
|
+
*/
|
|
106
|
+
class LocalSandboxHandle {
|
|
107
|
+
workDir;
|
|
108
|
+
defaultTimeout;
|
|
109
|
+
env;
|
|
110
|
+
constructor(workDir, defaultTimeout, env) {
|
|
111
|
+
this.workDir = workDir;
|
|
112
|
+
this.defaultTimeout = defaultTimeout;
|
|
113
|
+
this.env = env;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the working directory for this sandbox handle
|
|
117
|
+
*/
|
|
118
|
+
getWorkdir() {
|
|
119
|
+
return this.workDir;
|
|
120
|
+
}
|
|
121
|
+
async *exec(command, opts = {}) {
|
|
122
|
+
if (command.length === 0) {
|
|
123
|
+
throw new Error("Command cannot be empty");
|
|
124
|
+
}
|
|
125
|
+
const cwd = opts.cwd ? path.resolve(this.workDir, opts.cwd) : this.workDir;
|
|
126
|
+
const timeout = opts.timeout ?? this.defaultTimeout;
|
|
127
|
+
const env = { ...process.env, ...this.env, ...opts.env };
|
|
128
|
+
console.log(`[LocalSandbox] Executing command: ${command.join(" ")}`);
|
|
129
|
+
console.log(`[LocalSandbox] Working directory: ${cwd}`);
|
|
130
|
+
// Ensure the working directory exists
|
|
131
|
+
await fs.mkdir(cwd, { recursive: true });
|
|
132
|
+
const [cmd, ...args] = command;
|
|
133
|
+
const child = spawn(cmd, args, {
|
|
134
|
+
cwd,
|
|
135
|
+
env,
|
|
136
|
+
shell: false,
|
|
137
|
+
});
|
|
138
|
+
let timeoutId;
|
|
139
|
+
let isTimedOut = false;
|
|
140
|
+
let isAborted = false;
|
|
141
|
+
// Set up timeout if specified
|
|
142
|
+
if (timeout > 0) {
|
|
143
|
+
timeoutId = setTimeout(() => {
|
|
144
|
+
isTimedOut = true;
|
|
145
|
+
child.kill("SIGTERM");
|
|
146
|
+
// Force kill after 5 seconds if still running
|
|
147
|
+
setTimeout(() => {
|
|
148
|
+
if (!child.killed) {
|
|
149
|
+
child.kill("SIGKILL");
|
|
150
|
+
}
|
|
151
|
+
}, 5000);
|
|
152
|
+
}, timeout);
|
|
153
|
+
}
|
|
154
|
+
// Set up abort signal if provided
|
|
155
|
+
if (opts.signal) {
|
|
156
|
+
opts.signal.addEventListener("abort", () => {
|
|
157
|
+
isAborted = true;
|
|
158
|
+
child.kill("SIGTERM");
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
if (!child.killed) {
|
|
161
|
+
child.kill("SIGKILL");
|
|
162
|
+
}
|
|
163
|
+
}, 5000);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// Handle spawn errors (e.g., command not found)
|
|
167
|
+
const spawnError = await new Promise((resolve) => {
|
|
168
|
+
child.once("error", resolve);
|
|
169
|
+
child.once("spawn", () => resolve(null));
|
|
170
|
+
});
|
|
171
|
+
if (spawnError) {
|
|
172
|
+
if (timeoutId) {
|
|
173
|
+
clearTimeout(timeoutId);
|
|
174
|
+
}
|
|
175
|
+
throw spawnError;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
// Yield stdout chunks
|
|
179
|
+
for await (const chunk of child.stdout) {
|
|
180
|
+
yield chunk;
|
|
181
|
+
}
|
|
182
|
+
// Wait for the process to complete
|
|
183
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
184
|
+
child.on("error", reject);
|
|
185
|
+
child.on("close", (code) => resolve(code ?? 0));
|
|
186
|
+
});
|
|
187
|
+
if (timeoutId) {
|
|
188
|
+
clearTimeout(timeoutId);
|
|
189
|
+
}
|
|
190
|
+
if (isAborted) {
|
|
191
|
+
throw new Error("Command was aborted");
|
|
192
|
+
}
|
|
193
|
+
if (isTimedOut) {
|
|
194
|
+
throw new Error(`Command timed out after ${timeout}ms`);
|
|
195
|
+
}
|
|
196
|
+
if (exitCode !== 0) {
|
|
197
|
+
// Collect stderr for error message
|
|
198
|
+
let stderr = "";
|
|
199
|
+
for await (const chunk of child.stderr) {
|
|
200
|
+
stderr += chunk.toString();
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`Command exited with code ${exitCode}${stderr ? `\nstderr: ${stderr}` : ""}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if (timeoutId) {
|
|
207
|
+
clearTimeout(timeoutId);
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async upload(files, targetDir) {
|
|
213
|
+
const resolvedTargetDir = path.resolve(this.workDir, targetDir);
|
|
214
|
+
console.log(`[LocalSandbox] Uploading ${files.length} file(s) to ${resolvedTargetDir}`);
|
|
215
|
+
// Create target directory
|
|
216
|
+
await fs.mkdir(resolvedTargetDir, { recursive: true });
|
|
217
|
+
// Write each file
|
|
218
|
+
for (const file of files) {
|
|
219
|
+
const filePath = path.join(resolvedTargetDir, file.path);
|
|
220
|
+
const fileDir = path.dirname(filePath);
|
|
221
|
+
// Ensure the file's directory exists
|
|
222
|
+
await fs.mkdir(fileDir, { recursive: true });
|
|
223
|
+
// Write the file
|
|
224
|
+
const content = typeof file.content === "string"
|
|
225
|
+
? Buffer.from(file.content, "utf-8")
|
|
226
|
+
: file.content;
|
|
227
|
+
await fs.writeFile(filePath, content);
|
|
228
|
+
console.log(`[LocalSandbox] Wrote file: ${filePath}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async readFile(filePath) {
|
|
232
|
+
const resolvedPath = path.resolve(this.workDir, filePath);
|
|
233
|
+
const content = await fs.readFile(resolvedPath, "utf-8");
|
|
234
|
+
return content;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Execute a command and wait for completion, returning stdout, stderr, and exit code
|
|
238
|
+
*/
|
|
239
|
+
async runCommand(command) {
|
|
240
|
+
console.log(`[LocalSandbox] Running command: ${command}`);
|
|
241
|
+
return new Promise((resolve, reject) => {
|
|
242
|
+
// Use sh -c to execute the command
|
|
243
|
+
const child = spawn("sh", ["-c", command], {
|
|
244
|
+
cwd: this.workDir,
|
|
245
|
+
env: { ...process.env, ...this.env }, // Use instance env
|
|
246
|
+
stdio: "pipe",
|
|
247
|
+
});
|
|
248
|
+
let stdout = "";
|
|
249
|
+
let stderr = "";
|
|
250
|
+
child.stdout?.on("data", (data) => {
|
|
251
|
+
stdout += data.toString();
|
|
252
|
+
});
|
|
253
|
+
child.stderr?.on("data", (data) => {
|
|
254
|
+
stderr += data.toString();
|
|
255
|
+
});
|
|
256
|
+
child.on("close", (code) => {
|
|
257
|
+
resolve({
|
|
258
|
+
stdout,
|
|
259
|
+
stderr,
|
|
260
|
+
exitCode: code ?? 0,
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
child.on("error", reject);
|
|
264
|
+
// Timeout handling
|
|
265
|
+
const timeout = this.defaultTimeout;
|
|
266
|
+
const timeoutId = setTimeout(() => {
|
|
267
|
+
child.kill();
|
|
268
|
+
reject(new Error(`Command timed out after ${timeout}ms`));
|
|
269
|
+
}, timeout);
|
|
270
|
+
child.on("close", () => {
|
|
271
|
+
clearTimeout(timeoutId);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
async destroy() {
|
|
276
|
+
console.log(`[LocalSandbox] Cleanup complete for: ${this.workDir}`);
|
|
277
|
+
// Note: We don't delete the directory by default to preserve work
|
|
278
|
+
// Users can manually delete it if needed
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=local-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-sandbox.js","sourceRoot":"","sources":["../src/local-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAmBlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,YAAY;IACN,OAAO,CAAS;IAChB,OAAO,CAAU;IACjB,cAAc,CAAS;IACvB,GAAG,CAAyB;IAC5B,aAAa,CAAW;IAEzC,8CAA8C;IACtC,aAAa,GAA8B,IAAI,CAAC;IAExD,YAAY,UAA+B,EAAE;QAC3C,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ources":["../src/sand-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAGhB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAC7C,OAAO,CAAC,MAAM,CAA8B;gBAEhC,OAAO,EAAE,gBAAgB;IAMrC;;OAEG;YACW,cAAc;IAO5B;;OAEG;IACH,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"sand-agent.d.ts","sourceRoot":"","sources":["../src/sand-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,gBAAgB,EAGhB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAC7C,OAAO,CAAC,MAAM,CAA8B;gBAEhC,OAAO,EAAE,gBAAgB;IAMrC;;OAEG;YACW,cAAc;IAO5B;;OAEG;IACH,OAAO,CAAC,YAAY;IA2DpB;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IA8FrE;;OAEG;IACG,WAAW,CACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAA;KAAE,CAAC,EAC5D,SAAS,SAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
|
package/dist/sand-agent.js
CHANGED
|
@@ -30,7 +30,10 @@ export class SandAgent {
|
|
|
30
30
|
*/
|
|
31
31
|
buildCommand(input) {
|
|
32
32
|
// Get runner command from sandbox, or use default "sandagent run"
|
|
33
|
-
const cmd = this.sandbox.getRunnerCommand?.() ?? [
|
|
33
|
+
const cmd = this.sandbox.getRunnerCommand?.() ?? [
|
|
34
|
+
"sandagent",
|
|
35
|
+
"run",
|
|
36
|
+
];
|
|
34
37
|
// Add model
|
|
35
38
|
cmd.push("--model", this.runner.model);
|
|
36
39
|
// Add workspace path
|
package/dist/sand-agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sand-agent.js","sourceRoot":"","sources":["../src/sand-agent.ts"],"names":[],"mappings":"AASA;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IACH,OAAO,CAAiB;IACxB,MAAM,CAAa;IACnB,GAAG,CAAyB;IACrC,MAAM,GAAyB,IAAI,CAAC;IAE5C,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,cAAc;QAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,KAAkB;QACrC,kEAAkE;QAClE,MAAM,GAAG,GAAa,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"sand-agent.js","sourceRoot":"","sources":["../src/sand-agent.ts"],"names":[],"mappings":"AASA;;;;;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;oBACH,CAAC;oBAED,kEAAkE;oBAClE,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACtB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,KAA4D,EAC5D,SAAS,GAAG,YAAY;QAExB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC3C,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -61,11 +61,6 @@ export interface SandboxAdapter {
|
|
|
61
61
|
* These will be passed to all commands executed in the sandbox.
|
|
62
62
|
*/
|
|
63
63
|
getEnv?(): Record<string, string>;
|
|
64
|
-
/**
|
|
65
|
-
* Get the agent template configured for this sandbox.
|
|
66
|
-
* (e.g., "default", "coder", "analyst", "researcher")
|
|
67
|
-
*/
|
|
68
|
-
getAgentTemplate?(): string;
|
|
69
64
|
/**
|
|
70
65
|
* Get the working directory configured for this sandbox.
|
|
71
66
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7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OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandagent/manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "SandAgent Manager - Manages sandbox and runner lifecycle, defines core interfaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"dev": "tsc --watch",
|
|
21
|
-
"clean": "rm -rf dist",
|
|
22
|
-
"typecheck": "tsc --noEmit",
|
|
23
|
-
"lint": "echo 'no lint configured'",
|
|
24
|
-
"test": "vitest run --passWithNoTests"
|
|
25
|
-
},
|
|
26
18
|
"repository": {
|
|
27
19
|
"type": "git",
|
|
28
20
|
"url": "https://github.com/vikadata/sandagent.git",
|
|
@@ -47,5 +39,13 @@
|
|
|
47
39
|
"@types/node": "^20.10.0",
|
|
48
40
|
"typescript": "^5.3.0",
|
|
49
41
|
"vitest": "^1.6.1"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"dev": "tsc --watch",
|
|
46
|
+
"clean": "rm -rf dist",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"lint": "echo 'no lint configured'",
|
|
49
|
+
"test": "vitest run --passWithNoTests"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|