@sandagent/sandbox-sandock 0.1.2-beta.3
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/dist/__tests__/sandock-sandbox.test.d.ts +2 -0
- package/dist/__tests__/sandock-sandbox.test.d.ts.map +1 -0
- package/dist/__tests__/sandock-sandbox.test.js +244 -0
- package/dist/__tests__/sandock-sandbox.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sandock-sandbox.d.ts +95 -0
- package/dist/sandock-sandbox.d.ts.map +1 -0
- package/dist/sandock-sandbox.js +507 -0
- package/dist/sandock-sandbox.js.map +1 -0
- package/package.json +40 -0
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandock-sandbox.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sandock-sandbox.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { SandockSandbox } from "../sandock-sandbox.js";
|
|
3
|
+
// Mock the sandock SDK
|
|
4
|
+
vi.mock("sandock", () => ({
|
|
5
|
+
createSandockClient: vi.fn(() => ({
|
|
6
|
+
DELETE: vi.fn().mockResolvedValue({
|
|
7
|
+
data: { data: { id: "sandbox-123", deleted: true } },
|
|
8
|
+
error: null,
|
|
9
|
+
}),
|
|
10
|
+
// High-level sandbox API with streaming support
|
|
11
|
+
sandbox: {
|
|
12
|
+
create: vi.fn().mockResolvedValue({
|
|
13
|
+
success: true,
|
|
14
|
+
data: { id: "sandbox-123" },
|
|
15
|
+
}),
|
|
16
|
+
start: vi.fn().mockResolvedValue({
|
|
17
|
+
success: true,
|
|
18
|
+
data: { id: "sandbox-123", started: true },
|
|
19
|
+
}),
|
|
20
|
+
shell: vi.fn().mockImplementation((_sandboxId, _command, callbacks) => {
|
|
21
|
+
// Simulate streaming output
|
|
22
|
+
if (callbacks?.onStdout) {
|
|
23
|
+
callbacks.onStdout("command output");
|
|
24
|
+
}
|
|
25
|
+
return Promise.resolve({
|
|
26
|
+
success: true,
|
|
27
|
+
data: {
|
|
28
|
+
stdout: "command output",
|
|
29
|
+
stderr: "",
|
|
30
|
+
exitCode: 0,
|
|
31
|
+
timedOut: false,
|
|
32
|
+
durationMs: 100,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}),
|
|
36
|
+
stop: vi.fn().mockResolvedValue({
|
|
37
|
+
success: true,
|
|
38
|
+
data: { id: "sandbox-123", stopped: true },
|
|
39
|
+
}),
|
|
40
|
+
delete: vi.fn().mockResolvedValue({
|
|
41
|
+
success: true,
|
|
42
|
+
data: { id: "sandbox-123", deleted: true },
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
// High-level fs API
|
|
46
|
+
fs: {
|
|
47
|
+
write: vi.fn().mockResolvedValue({
|
|
48
|
+
success: true,
|
|
49
|
+
data: true,
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
})),
|
|
53
|
+
}));
|
|
54
|
+
describe("SandockSandbox", () => {
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
vi.clearAllMocks();
|
|
57
|
+
// Set API key for tests
|
|
58
|
+
process.env.SANDOCK_API_KEY = "test-api-key";
|
|
59
|
+
});
|
|
60
|
+
describe("constructor", () => {
|
|
61
|
+
it("should use default values", () => {
|
|
62
|
+
const sandbox = new SandockSandbox();
|
|
63
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
64
|
+
});
|
|
65
|
+
it("should accept custom options", () => {
|
|
66
|
+
const sandbox = new SandockSandbox({
|
|
67
|
+
baseUrl: "https://custom.sandock.ai",
|
|
68
|
+
apiKey: "custom-api-key",
|
|
69
|
+
image: "python:3.11-slim",
|
|
70
|
+
workdir: "/app",
|
|
71
|
+
memoryLimitMb: 1024,
|
|
72
|
+
cpuShares: 512,
|
|
73
|
+
keep: false,
|
|
74
|
+
});
|
|
75
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
76
|
+
});
|
|
77
|
+
it("should warn when SANDOCK_API_KEY is not set", () => {
|
|
78
|
+
delete process.env.SANDOCK_API_KEY;
|
|
79
|
+
const consoleSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
80
|
+
new SandockSandbox();
|
|
81
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("SANDOCK_API_KEY not set"));
|
|
82
|
+
consoleSpy.mockRestore();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe("attach", () => {
|
|
86
|
+
it("should implement SandboxAdapter interface", () => {
|
|
87
|
+
const sandbox = new SandockSandbox();
|
|
88
|
+
expect(typeof sandbox.attach).toBe("function");
|
|
89
|
+
});
|
|
90
|
+
it("should return a handle with required methods", async () => {
|
|
91
|
+
const sandbox = new SandockSandbox();
|
|
92
|
+
const handle = await sandbox.attach();
|
|
93
|
+
expect(typeof handle.exec).toBe("function");
|
|
94
|
+
expect(typeof handle.upload).toBe("function");
|
|
95
|
+
expect(typeof handle.destroy).toBe("function");
|
|
96
|
+
});
|
|
97
|
+
it("should create and start sandbox via API", async () => {
|
|
98
|
+
const sandbox = new SandockSandbox();
|
|
99
|
+
const handle = await sandbox.attach();
|
|
100
|
+
expect(handle).toBeDefined();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe("SandboxHandle", () => {
|
|
104
|
+
it("should execute commands and return output", async () => {
|
|
105
|
+
const sandbox = new SandockSandbox();
|
|
106
|
+
const handle = await sandbox.attach();
|
|
107
|
+
const chunks = [];
|
|
108
|
+
for await (const chunk of handle.exec(["echo", "hello"])) {
|
|
109
|
+
chunks.push(chunk);
|
|
110
|
+
}
|
|
111
|
+
expect(chunks.length).toBeGreaterThan(0);
|
|
112
|
+
const output = new TextDecoder().decode(chunks[0]);
|
|
113
|
+
expect(output).toBe("command output");
|
|
114
|
+
});
|
|
115
|
+
it("should upload files via API", async () => {
|
|
116
|
+
const sandbox = new SandockSandbox();
|
|
117
|
+
const handle = await sandbox.attach();
|
|
118
|
+
await handle.upload([{ path: "test.txt", content: "Hello, World!" }], "/workspace");
|
|
119
|
+
// No error means success
|
|
120
|
+
});
|
|
121
|
+
it("should destroy sandbox via API", async () => {
|
|
122
|
+
const sandbox = new SandockSandbox();
|
|
123
|
+
const handle = await sandbox.attach();
|
|
124
|
+
await handle.destroy();
|
|
125
|
+
// No error means success
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe("SandockSandbox Configuration", () => {
|
|
130
|
+
beforeEach(() => {
|
|
131
|
+
process.env.SANDOCK_API_KEY = "test-api-key";
|
|
132
|
+
});
|
|
133
|
+
it("should support custom base URLs", () => {
|
|
134
|
+
const sandbox = new SandockSandbox({
|
|
135
|
+
baseUrl: "https://custom.sandock.ai",
|
|
136
|
+
});
|
|
137
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
138
|
+
});
|
|
139
|
+
it("should support custom Docker images", () => {
|
|
140
|
+
const images = [
|
|
141
|
+
"sandockai/sandock-code:latest",
|
|
142
|
+
"python:3.11-slim",
|
|
143
|
+
"node:20-slim",
|
|
144
|
+
];
|
|
145
|
+
for (const image of images) {
|
|
146
|
+
const sandbox = new SandockSandbox({ image });
|
|
147
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
it("should support memory and CPU limits", () => {
|
|
151
|
+
const sandbox = new SandockSandbox({
|
|
152
|
+
memoryLimitMb: 2048,
|
|
153
|
+
cpuShares: 1024,
|
|
154
|
+
});
|
|
155
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
156
|
+
});
|
|
157
|
+
it("should support keep option", () => {
|
|
158
|
+
const keepTrue = new SandockSandbox({ keep: true });
|
|
159
|
+
const keepFalse = new SandockSandbox({ keep: false });
|
|
160
|
+
expect(keepTrue).toBeInstanceOf(SandockSandbox);
|
|
161
|
+
expect(keepFalse).toBeInstanceOf(SandockSandbox);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
describe("SandockSandbox Cache and Reuse", () => {
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
process.env.SANDOCK_API_KEY = "test-api-key";
|
|
167
|
+
vi.clearAllMocks();
|
|
168
|
+
});
|
|
169
|
+
it("should return same handle when attach() is called multiple times on same instance", async () => {
|
|
170
|
+
const sandbox = new SandockSandbox();
|
|
171
|
+
const handle1 = await sandbox.attach();
|
|
172
|
+
const handle2 = await sandbox.attach();
|
|
173
|
+
// Sandock generates new ID each time, but same instance should return cached handle
|
|
174
|
+
// Note: getHandle() returns the current handle if attached
|
|
175
|
+
expect(sandbox.getHandle()).toBeDefined();
|
|
176
|
+
// Both handles should be valid
|
|
177
|
+
expect(handle1).toBeDefined();
|
|
178
|
+
expect(handle2).toBeDefined();
|
|
179
|
+
});
|
|
180
|
+
it("should generate unique ID for each attach() call", async () => {
|
|
181
|
+
const sandbox = new SandockSandbox();
|
|
182
|
+
const handle1 = await sandbox.attach();
|
|
183
|
+
// Note: Each attach() generates a new ID, but same instance returns cached handle
|
|
184
|
+
// This test verifies the caching behavior within the same instance
|
|
185
|
+
expect(handle1).toBeDefined();
|
|
186
|
+
});
|
|
187
|
+
it("should cache sandbox instances in memory", async () => {
|
|
188
|
+
// The cache is static and shared across all SandockSandbox instances
|
|
189
|
+
const sandbox1 = new SandockSandbox();
|
|
190
|
+
const handle1 = await sandbox1.attach();
|
|
191
|
+
// Same instance should return a handle (may be different due to ID generation)
|
|
192
|
+
const handle2 = await sandbox1.attach();
|
|
193
|
+
expect(handle1).toBeDefined();
|
|
194
|
+
expect(handle2).toBeDefined();
|
|
195
|
+
// Both should have required methods
|
|
196
|
+
expect(typeof handle1.exec).toBe("function");
|
|
197
|
+
expect(typeof handle2.exec).toBe("function");
|
|
198
|
+
});
|
|
199
|
+
it("should create new sandbox when cache is empty", async () => {
|
|
200
|
+
const sandbox = new SandockSandbox();
|
|
201
|
+
const handle = await sandbox.attach();
|
|
202
|
+
expect(handle).toBeDefined();
|
|
203
|
+
expect(typeof handle.exec).toBe("function");
|
|
204
|
+
expect(typeof handle.upload).toBe("function");
|
|
205
|
+
expect(typeof handle.destroy).toBe("function");
|
|
206
|
+
});
|
|
207
|
+
it("should document cache limitations (process-local only)", () => {
|
|
208
|
+
// Sandock cache is process-local and does not persist across:
|
|
209
|
+
// - Process restarts
|
|
210
|
+
// - Different processes
|
|
211
|
+
// - Different machines
|
|
212
|
+
const sandbox = new SandockSandbox();
|
|
213
|
+
expect(sandbox).toBeInstanceOf(SandockSandbox);
|
|
214
|
+
// Cache is managed internally via static Map
|
|
215
|
+
});
|
|
216
|
+
it("should support cache eviction when full", async () => {
|
|
217
|
+
// MAX_CACHE_SIZE is 50, so after 50 instances, oldest will be evicted
|
|
218
|
+
const sandboxes = [];
|
|
219
|
+
const handles = [];
|
|
220
|
+
// Create multiple sandbox instances
|
|
221
|
+
for (let i = 0; i < 5; i++) {
|
|
222
|
+
const sandbox = new SandockSandbox();
|
|
223
|
+
sandboxes.push(sandbox);
|
|
224
|
+
const handle = await sandbox.attach();
|
|
225
|
+
handles.push(handle);
|
|
226
|
+
expect(handle).toBeDefined();
|
|
227
|
+
}
|
|
228
|
+
// All should work, cache eviction happens internally
|
|
229
|
+
expect(handles.length).toBe(5);
|
|
230
|
+
});
|
|
231
|
+
it("should skip initialization for cached instances", async () => {
|
|
232
|
+
const sandbox = new SandockSandbox();
|
|
233
|
+
const handle1 = await sandbox.attach();
|
|
234
|
+
// Second attach on same instance should return a handle
|
|
235
|
+
// Note: Sandock generates new ID each time, but uses cache for same ID
|
|
236
|
+
const handle2 = await sandbox.attach();
|
|
237
|
+
expect(handle1).toBeDefined();
|
|
238
|
+
expect(handle2).toBeDefined();
|
|
239
|
+
// Both handles should work
|
|
240
|
+
expect(typeof handle1.exec).toBe("function");
|
|
241
|
+
expect(typeof handle2.exec).toBe("function");
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
//# sourceMappingURL=sandock-sandbox.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandock-sandbox.test.js","sourceRoot":"","sources":["../../src/__tests__/sandock-sandbox.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,uBAAuB;AACvB,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;IACxB,mBAAmB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAChC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;YAChC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACpD,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,gDAAgD;QAChD,OAAO,EAAE;YACP,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;gBAChC,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE;aAC5B,CAAC;YACF,KAAK,EAAE,EAAE,CA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C,CAAC;YACxB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;YACtC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC/B,CAAC;QAED,qDAAqD;QACrD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;QAEvC,wDAAwD;QACxD,uEAAuE;QACvE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,2BAA2B;QAC3B,MAAM,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAEf,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { SandboxAdapter, SandboxHandle } from "@sandagent/manager";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a SandockSandbox instance
|
|
4
|
+
*/
|
|
5
|
+
export interface SandockSandboxOptions {
|
|
6
|
+
/** Sandock API base URL (defaults to https://sandock.ai) */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Sandock API key for authentication */
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
/** Docker image to use for the sandbox */
|
|
11
|
+
image?: string;
|
|
12
|
+
/** Working directory inside the sandbox */
|
|
13
|
+
workdir?: string;
|
|
14
|
+
/** Memory limit in MB */
|
|
15
|
+
memoryLimitMb?: number;
|
|
16
|
+
/** CPU shares */
|
|
17
|
+
cpuShares?: number;
|
|
18
|
+
/** Keep sandbox running after execution */
|
|
19
|
+
keep?: boolean;
|
|
20
|
+
/** Timeout for sandbox operations in milliseconds (default: 300000 = 5 min) */
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/** Path to runner bundle.js (required for running sandagent) */
|
|
23
|
+
runnerBundlePath?: string;
|
|
24
|
+
/** Path to template directory to upload */
|
|
25
|
+
templatesPath?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Environment variables to set in the sandbox.
|
|
28
|
+
* These will be available to all commands executed in the sandbox.
|
|
29
|
+
*/
|
|
30
|
+
env?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sandock-based sandbox implementation.
|
|
34
|
+
*
|
|
35
|
+
* Uses the official Sandock SDK (https://sandock.ai) for cloud-based
|
|
36
|
+
* Docker sandbox execution with persistent filesystems.
|
|
37
|
+
*/
|
|
38
|
+
export declare class SandockSandbox implements SandboxAdapter {
|
|
39
|
+
private readonly client;
|
|
40
|
+
private readonly image;
|
|
41
|
+
private readonly workdir;
|
|
42
|
+
private readonly memoryLimitMb?;
|
|
43
|
+
private readonly cpuShares?;
|
|
44
|
+
private readonly keep;
|
|
45
|
+
private readonly timeout;
|
|
46
|
+
private readonly runnerBundlePath?;
|
|
47
|
+
private readonly templatesPath?;
|
|
48
|
+
private readonly env;
|
|
49
|
+
/** Global cache for sandbox instances (shared across all SandockSandbox instances) */
|
|
50
|
+
private static readonly instances;
|
|
51
|
+
private static readonly initializedInstances;
|
|
52
|
+
/** Maximum number of cached instances */
|
|
53
|
+
private static readonly MAX_CACHE_SIZE;
|
|
54
|
+
/** Instance expiration time in milliseconds (default: 30 minutes) */
|
|
55
|
+
private static readonly INSTANCE_TTL_MS;
|
|
56
|
+
/** Cleanup interval timer (lazy initialized on first cache write) */
|
|
57
|
+
private static cleanupTimer;
|
|
58
|
+
constructor(options?: SandockSandboxOptions);
|
|
59
|
+
/**
|
|
60
|
+
* Get the environment variables configured for this sandbox.
|
|
61
|
+
*/
|
|
62
|
+
getEnv(): Record<string, string>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the working directory configured for this sandbox.
|
|
65
|
+
*/
|
|
66
|
+
getWorkdir(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get the runner command to execute in the sandbox.
|
|
69
|
+
* Returns different commands based on whether a local bundle or npm package is used.
|
|
70
|
+
*/
|
|
71
|
+
getRunnerCommand(): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Ensure cleanup timer is running (lazy initialization)
|
|
74
|
+
*/
|
|
75
|
+
private static ensureCleanupTimer;
|
|
76
|
+
/**
|
|
77
|
+
* Remove expired instances from cache
|
|
78
|
+
*/
|
|
79
|
+
private static cleanupExpiredInstances;
|
|
80
|
+
/**
|
|
81
|
+
* Evict oldest instance if cache is full
|
|
82
|
+
*/
|
|
83
|
+
private evictOldestIfNeeded;
|
|
84
|
+
/**
|
|
85
|
+
* Get the current handle if already attached, or null if not attached yet.
|
|
86
|
+
*/
|
|
87
|
+
getHandle(): SandboxHandle | null;
|
|
88
|
+
/**
|
|
89
|
+
* Attach to or create a sandbox
|
|
90
|
+
*/
|
|
91
|
+
attach(): Promise<SandboxHandle>;
|
|
92
|
+
private initializeSandbox;
|
|
93
|
+
private collectFiles;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=sandock-sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandock-sandbox.d.ts","sourceRoot":"","sources":["../src/sandock-sandbox.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EACd,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAWD;;;;;GAKG;AACH,qBAAa,cAAe,YAAW,cAAc;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAE7C,sFAAsF;IACtF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAA0C;IAC3E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA0B;IAEtE,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAM;IAC5C,qEAAqE;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAkB;IACzD,qEAAqE;IACrE,OAAO,CAAC,MAAM,CAAC,YAAY,CAA+C;gBAE9D,OAAO,GAAE,qBAA0B;IA0B/C;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIhC;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAS5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAgBjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAuBtC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgC3B;;OAEG;IACH,SAAS,IAAI,aAAa,GAAG,IAAI;IAOjC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC;YA8FxB,iBAAiB;IA0C/B,OAAO,CAAC,YAAY;CA2BrB"}
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { createSandockClient } from "sandock";
|
|
4
|
+
/**
|
|
5
|
+
* Sandock-based sandbox implementation.
|
|
6
|
+
*
|
|
7
|
+
* Uses the official Sandock SDK (https://sandock.ai) for cloud-based
|
|
8
|
+
* Docker sandbox execution with persistent filesystems.
|
|
9
|
+
*/
|
|
10
|
+
export class SandockSandbox {
|
|
11
|
+
client;
|
|
12
|
+
image;
|
|
13
|
+
workdir;
|
|
14
|
+
memoryLimitMb;
|
|
15
|
+
cpuShares;
|
|
16
|
+
keep;
|
|
17
|
+
timeout;
|
|
18
|
+
runnerBundlePath;
|
|
19
|
+
templatesPath;
|
|
20
|
+
env;
|
|
21
|
+
/** Global cache for sandbox instances (shared across all SandockSandbox instances) */
|
|
22
|
+
static instances = new Map();
|
|
23
|
+
static initializedInstances = new Set();
|
|
24
|
+
/** Maximum number of cached instances */
|
|
25
|
+
static MAX_CACHE_SIZE = 50;
|
|
26
|
+
/** Instance expiration time in milliseconds (default: 30 minutes) */
|
|
27
|
+
static INSTANCE_TTL_MS = 30 * 60 * 1000;
|
|
28
|
+
/** Cleanup interval timer (lazy initialized on first cache write) */
|
|
29
|
+
static cleanupTimer = null;
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
const apiKey = options.apiKey ?? process.env.SANDOCK_API_KEY;
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
console.warn("SANDOCK_API_KEY not set. Sandock API calls will fail.\n" +
|
|
34
|
+
"Get your API key at https://sandock.ai");
|
|
35
|
+
}
|
|
36
|
+
this.client = createSandockClient({
|
|
37
|
+
baseUrl: options.baseUrl ?? "https://sandock.ai",
|
|
38
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : undefined,
|
|
39
|
+
});
|
|
40
|
+
this.image = options.image ?? "sandockai/sandock-code:latest";
|
|
41
|
+
this.workdir = options.workdir ?? "/workspace";
|
|
42
|
+
this.memoryLimitMb = options.memoryLimitMb;
|
|
43
|
+
this.cpuShares = options.cpuShares;
|
|
44
|
+
this.keep = options.keep ?? true;
|
|
45
|
+
this.timeout = options.timeout ?? 300000;
|
|
46
|
+
this.runnerBundlePath = options.runnerBundlePath;
|
|
47
|
+
this.templatesPath = options.templatesPath;
|
|
48
|
+
this.env = options.env ?? {};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the environment variables configured for this sandbox.
|
|
52
|
+
*/
|
|
53
|
+
getEnv() {
|
|
54
|
+
return this.env;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the working directory configured for this sandbox.
|
|
58
|
+
*/
|
|
59
|
+
getWorkdir() {
|
|
60
|
+
return this.workdir;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the runner command to execute in the sandbox.
|
|
64
|
+
* Returns different commands based on whether a local bundle or npm package is used.
|
|
65
|
+
*/
|
|
66
|
+
getRunnerCommand() {
|
|
67
|
+
if (this.runnerBundlePath && fs.existsSync(this.runnerBundlePath)) {
|
|
68
|
+
// Local bundle is uploaded to ${workdir}/runner/bundle.mjs
|
|
69
|
+
return ["node", `${this.workdir}/runner/bundle.mjs`, "run"];
|
|
70
|
+
}
|
|
71
|
+
// npm installed runner-cli has bin symlink
|
|
72
|
+
return ["sandagent", "run"];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Ensure cleanup timer is running (lazy initialization)
|
|
76
|
+
*/
|
|
77
|
+
static ensureCleanupTimer(client) {
|
|
78
|
+
if (SandockSandbox.cleanupTimer)
|
|
79
|
+
return;
|
|
80
|
+
SandockSandbox.cleanupTimer = setInterval(() => {
|
|
81
|
+
SandockSandbox.cleanupExpiredInstances(client);
|
|
82
|
+
}, 5 * 60 * 1000); // Run every 5 minutes
|
|
83
|
+
// Don't prevent process exit
|
|
84
|
+
if (SandockSandbox.cleanupTimer.unref) {
|
|
85
|
+
SandockSandbox.cleanupTimer.unref();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Remove expired instances from cache
|
|
90
|
+
*/
|
|
91
|
+
static cleanupExpiredInstances(client) {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
const expiredIds = [];
|
|
94
|
+
for (const [id, cached] of SandockSandbox.instances) {
|
|
95
|
+
if (now - cached.lastAccessTime > SandockSandbox.INSTANCE_TTL_MS) {
|
|
96
|
+
expiredIds.push(id);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const id of expiredIds) {
|
|
100
|
+
const cached = SandockSandbox.instances.get(id);
|
|
101
|
+
if (cached) {
|
|
102
|
+
console.log(`[Sandock] Removing expired sandbox instance: ${id}`);
|
|
103
|
+
client.sandbox.stop(cached.sandboxId).catch((e) => {
|
|
104
|
+
console.error(`[Sandock] Error stopping expired sandbox:`, e);
|
|
105
|
+
});
|
|
106
|
+
SandockSandbox.instances.delete(id);
|
|
107
|
+
SandockSandbox.initializedInstances.delete(id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Evict oldest instance if cache is full
|
|
113
|
+
*/
|
|
114
|
+
evictOldestIfNeeded() {
|
|
115
|
+
// Lazy start cleanup timer on first cache write
|
|
116
|
+
SandockSandbox.ensureCleanupTimer(this.client);
|
|
117
|
+
if (SandockSandbox.instances.size < SandockSandbox.MAX_CACHE_SIZE)
|
|
118
|
+
return;
|
|
119
|
+
let oldestId = null;
|
|
120
|
+
let oldestTime = Number.POSITIVE_INFINITY;
|
|
121
|
+
for (const [id, cached] of SandockSandbox.instances) {
|
|
122
|
+
if (cached.lastAccessTime < oldestTime) {
|
|
123
|
+
oldestTime = cached.lastAccessTime;
|
|
124
|
+
oldestId = id;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (oldestId) {
|
|
128
|
+
const cached = SandockSandbox.instances.get(oldestId);
|
|
129
|
+
if (cached) {
|
|
130
|
+
console.log(`[Sandock] Evicting oldest sandbox instance: ${oldestId}`);
|
|
131
|
+
this.client.sandbox.stop(cached.sandboxId).catch((e) => {
|
|
132
|
+
console.error(`[Sandock] Error stopping evicted sandbox ${oldestId}:`, e);
|
|
133
|
+
});
|
|
134
|
+
SandockSandbox.instances.delete(oldestId);
|
|
135
|
+
SandockSandbox.initializedInstances.delete(oldestId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get the current handle if already attached, or null if not attached yet.
|
|
141
|
+
*/
|
|
142
|
+
getHandle() {
|
|
143
|
+
// For Sandock, we need to check the instances cache
|
|
144
|
+
// Since we don't have a single current handle, return null
|
|
145
|
+
// The caller should use attach() with the id
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Attach to or create a sandbox
|
|
150
|
+
*/
|
|
151
|
+
async attach() {
|
|
152
|
+
// Generate a unique id for this sandbox instance (used for caching and logging)
|
|
153
|
+
const id = `sandock-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
154
|
+
console.log(`[Sandock] Attaching sandbox with id: ${id}`);
|
|
155
|
+
// Check if we already have a cached instance for this id
|
|
156
|
+
const cached = SandockSandbox.instances.get(id);
|
|
157
|
+
if (cached) {
|
|
158
|
+
console.log(`[Sandock] Reusing cached sandbox: ${cached.sandboxId} for id: ${id}`);
|
|
159
|
+
cached.lastAccessTime = Date.now();
|
|
160
|
+
// Return cached handle if it exists
|
|
161
|
+
if (cached?.handle) {
|
|
162
|
+
return cached.handle;
|
|
163
|
+
}
|
|
164
|
+
// Create new handle if not cached
|
|
165
|
+
const handle = new SandockHandle(this.client, cached.sandboxId, this.workdir, this.timeout, () => {
|
|
166
|
+
// Cleanup callback when handle is destroyed
|
|
167
|
+
SandockSandbox.instances.delete(id);
|
|
168
|
+
SandockSandbox.initializedInstances.delete(id);
|
|
169
|
+
}, this.env);
|
|
170
|
+
// Only initialize if this is the first time we're using this instance
|
|
171
|
+
if (!SandockSandbox.initializedInstances.has(id)) {
|
|
172
|
+
await this.initializeSandbox(handle);
|
|
173
|
+
SandockSandbox.initializedInstances.add(id);
|
|
174
|
+
}
|
|
175
|
+
// Cache the handle
|
|
176
|
+
cached.handle = handle;
|
|
177
|
+
return handle;
|
|
178
|
+
}
|
|
179
|
+
// Evict oldest instance if cache is full
|
|
180
|
+
this.evictOldestIfNeeded();
|
|
181
|
+
// Create sandbox using high-level API
|
|
182
|
+
const createResult = await this.client.sandbox.create({
|
|
183
|
+
image: this.image,
|
|
184
|
+
memory: this.memoryLimitMb,
|
|
185
|
+
cpu: this.cpuShares,
|
|
186
|
+
});
|
|
187
|
+
console.log(`[Sandock] Sandbox creation result: ${JSON.stringify(createResult)}`);
|
|
188
|
+
const sandboxId = createResult.data.id;
|
|
189
|
+
if (!sandboxId) {
|
|
190
|
+
throw new Error("No sandbox ID returned from Sandock API");
|
|
191
|
+
}
|
|
192
|
+
console.log(`[Sandock] Created new sandbox: ${sandboxId} (user id: ${id})`);
|
|
193
|
+
// Start the sandbox using high-level API
|
|
194
|
+
await this.client.sandbox.start(sandboxId);
|
|
195
|
+
const handle = new SandockHandle(this.client, sandboxId, this.workdir, this.timeout, () => {
|
|
196
|
+
// Cleanup callback when handle is explicitly destroyed
|
|
197
|
+
SandockSandbox.instances.delete(id);
|
|
198
|
+
SandockSandbox.initializedInstances.delete(id);
|
|
199
|
+
}, this.env);
|
|
200
|
+
// Initialize sandbox with runner and templates
|
|
201
|
+
await this.initializeSandbox(handle);
|
|
202
|
+
SandockSandbox.initializedInstances.add(id);
|
|
203
|
+
// Cache the instance with handle
|
|
204
|
+
SandockSandbox.instances.set(id, {
|
|
205
|
+
sandboxId,
|
|
206
|
+
lastAccessTime: Date.now(),
|
|
207
|
+
handle,
|
|
208
|
+
});
|
|
209
|
+
return handle;
|
|
210
|
+
}
|
|
211
|
+
async initializeSandbox(handle) {
|
|
212
|
+
// Upload runner bundle to /sandagent (fixed location for node to find it)
|
|
213
|
+
if (this.runnerBundlePath && fs.existsSync(this.runnerBundlePath)) {
|
|
214
|
+
const bundleContent = fs.readFileSync(this.runnerBundlePath);
|
|
215
|
+
const bundleFileName = path.basename(this.runnerBundlePath);
|
|
216
|
+
const runnerFiles = [
|
|
217
|
+
{
|
|
218
|
+
path: `runner/${bundleFileName}`,
|
|
219
|
+
content: bundleContent,
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
console.log(`[Sandock] Uploading runner bundle (${bundleFileName}) to /sandagent`);
|
|
223
|
+
await handle.upload(runnerFiles, "/sandagent");
|
|
224
|
+
// Install claude-agent-sdk in sandbox
|
|
225
|
+
console.log(`[Sandock] Installing @anthropic-ai/claude-agent-sdk`);
|
|
226
|
+
const installResult = await handle.runCommand("npm install --prefix /sandagent @anthropic-ai/claude-agent-sdk");
|
|
227
|
+
if (installResult.exitCode !== 0) {
|
|
228
|
+
console.error(`[Sandock] Failed to install claude-agent-sdk: ${installResult.stderr}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Upload template to workdir (where runner will execute)
|
|
232
|
+
if (this.templatesPath && fs.existsSync(this.templatesPath)) {
|
|
233
|
+
const templateFiles = this.collectFiles(this.templatesPath, "");
|
|
234
|
+
console.log(`[Sandock] Uploading ${templateFiles.length} template files to ${this.workdir}`);
|
|
235
|
+
await handle.upload(templateFiles, this.workdir);
|
|
236
|
+
}
|
|
237
|
+
else if (this.templatesPath) {
|
|
238
|
+
console.warn(`[Sandock] Template path not found: ${this.templatesPath}, skipping`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
collectFiles(dir, prefix) {
|
|
242
|
+
const files = [];
|
|
243
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
244
|
+
for (const entry of entries) {
|
|
245
|
+
const fullPath = path.join(dir, entry.name);
|
|
246
|
+
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
247
|
+
if (entry.isDirectory()) {
|
|
248
|
+
// Skip node_modules and .git only
|
|
249
|
+
if (entry.name === "node_modules" || entry.name === ".git") {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
files.push(...this.collectFiles(fullPath, relativePath));
|
|
253
|
+
}
|
|
254
|
+
else if (entry.isFile()) {
|
|
255
|
+
files.push({
|
|
256
|
+
path: relativePath,
|
|
257
|
+
content: fs.readFileSync(fullPath),
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return files;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Handle for an active Sandock sandbox
|
|
266
|
+
*/
|
|
267
|
+
class SandockHandle {
|
|
268
|
+
client;
|
|
269
|
+
sandboxId;
|
|
270
|
+
defaultWorkdir;
|
|
271
|
+
timeout;
|
|
272
|
+
onDestroy;
|
|
273
|
+
sandboxEnv;
|
|
274
|
+
constructor(client, sandboxId, defaultWorkdir, timeout, onDestroy, sandboxEnv = {}) {
|
|
275
|
+
this.client = client;
|
|
276
|
+
this.sandboxId = sandboxId;
|
|
277
|
+
this.defaultWorkdir = defaultWorkdir;
|
|
278
|
+
this.timeout = timeout;
|
|
279
|
+
this.onDestroy = onDestroy;
|
|
280
|
+
this.sandboxEnv = sandboxEnv;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Run a command and wait for completion (used internally)
|
|
284
|
+
*/
|
|
285
|
+
async runCommand(cmd) {
|
|
286
|
+
let stdout = "";
|
|
287
|
+
let stderr = "";
|
|
288
|
+
const result = await this.client.sandbox.shell(this.sandboxId, { cmd, timeoutMs: this.timeout }, {
|
|
289
|
+
onStdout: (chunk) => {
|
|
290
|
+
stdout += chunk;
|
|
291
|
+
},
|
|
292
|
+
onStderr: (chunk) => {
|
|
293
|
+
stderr += chunk;
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
return {
|
|
297
|
+
exitCode: result.data.exitCode ?? 0,
|
|
298
|
+
stdout,
|
|
299
|
+
stderr,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Execute a command in the sandbox and stream the output
|
|
304
|
+
*/
|
|
305
|
+
exec(command, opts) {
|
|
306
|
+
const self = this;
|
|
307
|
+
const signal = opts?.signal;
|
|
308
|
+
// Merge sandbox-level env with call-level env (call-level takes precedence)
|
|
309
|
+
// Add NODE_PATH so Node can find packages installed in /sandagent
|
|
310
|
+
const envWithNodePath = {
|
|
311
|
+
...this.sandboxEnv,
|
|
312
|
+
...opts?.env,
|
|
313
|
+
IS_SANDBOX: "1",
|
|
314
|
+
NODE_PATH: "/sandagent/node_modules",
|
|
315
|
+
};
|
|
316
|
+
// Debug: log environment variables being passed to sandbox
|
|
317
|
+
console.log("[Sandock] Executing command:", command.join(" "));
|
|
318
|
+
console.log("[Sandock] Environment variables:", Object.keys(envWithNodePath));
|
|
319
|
+
console.log("[Sandock] ANTHROPIC_API_KEY present:", !!envWithNodePath.ANTHROPIC_API_KEY);
|
|
320
|
+
if (envWithNodePath.ANTHROPIC_API_KEY) {
|
|
321
|
+
console.log("[Sandock] ANTHROPIC_API_KEY prefix:", envWithNodePath.ANTHROPIC_API_KEY.substring(0, 10) + "...");
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
async *[Symbol.asyncIterator]() {
|
|
325
|
+
// Build command string - note: proper shell escaping would be better
|
|
326
|
+
// but we maintain backward compatibility with the original implementation
|
|
327
|
+
const baseCmd = command.length === 1 ? command[0] : command.join(" ");
|
|
328
|
+
// Build full command with cwd and env support
|
|
329
|
+
const parts = [];
|
|
330
|
+
// Add working directory change (escape single quotes in path)
|
|
331
|
+
const workdir = opts?.cwd ?? self.defaultWorkdir;
|
|
332
|
+
if (workdir) {
|
|
333
|
+
const escapedWorkdir = workdir.replace(/'/g, "'\\''");
|
|
334
|
+
parts.push(`cd '${escapedWorkdir}'`);
|
|
335
|
+
}
|
|
336
|
+
// Add environment variables (validate keys and escape values)
|
|
337
|
+
const validKeyPattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
338
|
+
const envParts = Object.entries(envWithNodePath)
|
|
339
|
+
.filter(([key]) => validKeyPattern.test(key))
|
|
340
|
+
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
|
341
|
+
.join(" && ");
|
|
342
|
+
if (envParts) {
|
|
343
|
+
parts.push(envParts);
|
|
344
|
+
}
|
|
345
|
+
// Wrap the command to capture its PID and handle signals
|
|
346
|
+
// We write the PID to a file so we can kill it if needed
|
|
347
|
+
const pidFile = `/tmp/sandagent-${Date.now()}-${Math.random().toString(36).substring(7)}.pid`;
|
|
348
|
+
const wrappedCmd = `(${baseCmd}) & echo $! > ${pidFile}; wait $!; rm -f ${pidFile}`;
|
|
349
|
+
parts.push(wrappedCmd);
|
|
350
|
+
const cmd = parts.join(" && ");
|
|
351
|
+
// Queue for streaming chunks
|
|
352
|
+
const queue = [];
|
|
353
|
+
let done = false;
|
|
354
|
+
let error = null;
|
|
355
|
+
let resolveWait = null;
|
|
356
|
+
// Monitor abort signal and kill the process
|
|
357
|
+
const abortHandler = async () => {
|
|
358
|
+
console.log("[Sandock] Abort signal received, terminating process...");
|
|
359
|
+
console.log("[Sandock] PID file:", pidFile);
|
|
360
|
+
// Try to kill the process using the PID file
|
|
361
|
+
try {
|
|
362
|
+
// First check if PID file exists and read it
|
|
363
|
+
const checkCmd = `if [ -f ${pidFile} ]; then cat ${pidFile}; else echo "PID file not found"; fi`;
|
|
364
|
+
const checkResult = await self.client.sandbox.shell(self.sandboxId, { cmd: checkCmd, timeoutMs: 2000 }, {});
|
|
365
|
+
console.log("[Sandock] PID check result:", checkResult.data.stdout);
|
|
366
|
+
// Now try to kill the process
|
|
367
|
+
const killCmd = `if [ -f ${pidFile} ]; then PID=$(cat ${pidFile}); echo "Killing PID: $PID"; kill -TERM $PID 2>&1 || echo "Kill failed"; rm -f ${pidFile}; else echo "No PID file to kill"; fi`;
|
|
368
|
+
const killResult = await self.client.sandbox.shell(self.sandboxId, { cmd: killCmd, timeoutMs: 5000 }, {});
|
|
369
|
+
console.log("[Sandock] Kill command result:", killResult.data.stdout);
|
|
370
|
+
console.log("[Sandock] Kill command stderr:", killResult.data.stderr);
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
console.error("[Sandock] Failed to send termination signal:", err);
|
|
374
|
+
}
|
|
375
|
+
done = true;
|
|
376
|
+
error = new Error("Operation aborted");
|
|
377
|
+
error.name = "AbortError";
|
|
378
|
+
resolveWait?.();
|
|
379
|
+
};
|
|
380
|
+
if (signal) {
|
|
381
|
+
console.log("[Sandock] Adding abort signal listener");
|
|
382
|
+
signal.addEventListener("abort", abortHandler);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
console.log("[Sandock] No signal provided");
|
|
386
|
+
}
|
|
387
|
+
// Start shell command with streaming callbacks
|
|
388
|
+
const shellPromise = self.client.sandbox.shell(self.sandboxId, { cmd, timeoutMs: self.timeout }, {
|
|
389
|
+
onStdout: (chunk) => {
|
|
390
|
+
// Stop producing stdout chunks if signal is aborted
|
|
391
|
+
if (signal?.aborted)
|
|
392
|
+
return;
|
|
393
|
+
queue.push(new TextEncoder().encode(chunk));
|
|
394
|
+
resolveWait?.();
|
|
395
|
+
},
|
|
396
|
+
onStderr: (chunk) => {
|
|
397
|
+
console.log("STDERR CHUNK:", chunk);
|
|
398
|
+
queue.push(new TextEncoder().encode(chunk));
|
|
399
|
+
resolveWait?.();
|
|
400
|
+
},
|
|
401
|
+
onError: (err) => {
|
|
402
|
+
console.log("SHELL ERROR:", err);
|
|
403
|
+
error = err instanceof Error ? err : new Error(String(err));
|
|
404
|
+
resolveWait?.();
|
|
405
|
+
},
|
|
406
|
+
});
|
|
407
|
+
// Handle completion
|
|
408
|
+
shellPromise
|
|
409
|
+
.then((result) => {
|
|
410
|
+
// Check for errors in the result
|
|
411
|
+
console.log("[Sandock] Command completed with exit code:", result.data.exitCode);
|
|
412
|
+
console.log("[Sandock] Command stdout:", result.data.stdout?.substring(0, 500) || "(empty)");
|
|
413
|
+
console.log("[Sandock] Command stderr:", result.data.stderr?.substring(0, 500) || "(empty)");
|
|
414
|
+
if (result.data.timedOut) {
|
|
415
|
+
error = new Error(`Command timed out after ${result.data.durationMs}ms`);
|
|
416
|
+
}
|
|
417
|
+
else if (result.data.exitCode !== 0 &&
|
|
418
|
+
result.data.exitCode !== null) {
|
|
419
|
+
console.warn(`Command exited with code ${result.data.exitCode}`);
|
|
420
|
+
}
|
|
421
|
+
done = true;
|
|
422
|
+
resolveWait?.();
|
|
423
|
+
})
|
|
424
|
+
.catch((err) => {
|
|
425
|
+
error = err instanceof Error ? err : new Error(String(err));
|
|
426
|
+
// Log AbortError appropriately
|
|
427
|
+
if (error.name === "AbortError") {
|
|
428
|
+
console.log("[Sandock] Command execution aborted by user");
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
console.error("[Sandock] Shell promise rejected:", err);
|
|
432
|
+
}
|
|
433
|
+
done = true;
|
|
434
|
+
resolveWait?.();
|
|
435
|
+
})
|
|
436
|
+
.finally(() => {
|
|
437
|
+
// Remove event listener when iterator completes
|
|
438
|
+
if (signal) {
|
|
439
|
+
signal.removeEventListener("abort", abortHandler);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
// Yield chunks as they arrive
|
|
443
|
+
while (true) {
|
|
444
|
+
// Check if signal is aborted
|
|
445
|
+
if (signal?.aborted) {
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
// Yield all queued chunks
|
|
449
|
+
while (queue.length > 0) {
|
|
450
|
+
const chunk = queue.shift();
|
|
451
|
+
if (chunk) {
|
|
452
|
+
yield chunk;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Check for errors
|
|
456
|
+
if (error) {
|
|
457
|
+
throw error;
|
|
458
|
+
}
|
|
459
|
+
// Check if done
|
|
460
|
+
if (done) {
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
// Wait for more data
|
|
464
|
+
await new Promise((resolve) => {
|
|
465
|
+
resolveWait = resolve;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Upload files to the sandbox
|
|
473
|
+
*/
|
|
474
|
+
async upload(files, targetDir) {
|
|
475
|
+
for (const file of files) {
|
|
476
|
+
const fullPath = `${targetDir}/${file.path}`;
|
|
477
|
+
// Convert content to string
|
|
478
|
+
const content = typeof file.content === "string"
|
|
479
|
+
? file.content
|
|
480
|
+
: new TextDecoder().decode(file.content);
|
|
481
|
+
// Use high-level fs.write API
|
|
482
|
+
await this.client.fs.write(this.sandboxId, fullPath, content);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
async readFile(filePath) {
|
|
486
|
+
const result = await this.client.fs.read(this.sandboxId, filePath);
|
|
487
|
+
// Sandock fs.read returns { success: true, data: { path: string, content: string } }
|
|
488
|
+
if (result.success && result.data) {
|
|
489
|
+
return typeof result.data === "string"
|
|
490
|
+
? result.data
|
|
491
|
+
: result.data.content || "";
|
|
492
|
+
}
|
|
493
|
+
throw new Error(`Failed to read file ${filePath}`);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Destroy the sandbox and release resources
|
|
497
|
+
*/
|
|
498
|
+
async destroy() {
|
|
499
|
+
// Stop the sandbox using high-level API
|
|
500
|
+
await this.client.sandbox.stop(this.sandboxId);
|
|
501
|
+
// Delete sandbox using high-level API
|
|
502
|
+
await this.client.sandbox.delete(this.sandboxId);
|
|
503
|
+
// Clean up from cache
|
|
504
|
+
this.onDestroy();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
//# sourceMappingURL=sandock-sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandock-sandbox.js","sourceRoot":"","sources":["../src/sandock-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAOlC,OAAO,EAAsB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA2ClE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACR,MAAM,CAAgB;IACtB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,aAAa,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C,CAAC;QACnE,qFAAqF;QACrF,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;gBACpC,CAAC,CAAC,MAAM,CAAC,IAAI;gBACb,CAAC,CAAE,MAAM,CAAC,IAA6B,CAAC,OAAO,IAAI,EAAE,CAAC;QAC1D,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,wCAAwC;QACxC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE/C,sCAAsC;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEjD,sBAAsB;QACtB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sandagent/sandbox-sandock",
|
|
3
|
+
"version": "0.1.2-beta.3",
|
|
4
|
+
"description": "Sandock sandbox adapter for SandAgent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/vikadata/sandagent.git",
|
|
21
|
+
"directory": "packages/sandbox-sandock"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"sandock": "^2.2.1",
|
|
26
|
+
"@sandagent/manager": "0.1.2-beta.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.10.0",
|
|
30
|
+
"typescript": "^5.3.0",
|
|
31
|
+
"vitest": "^1.6.1"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"lint": "echo 'no lint configured'",
|
|
38
|
+
"test": "vitest run --passWithNoTests"
|
|
39
|
+
}
|
|
40
|
+
}
|