@opencoredev/sandbox-sdk 0.1.1 → 1.0.0-beta.0
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/CHANGELOG.md +34 -7
- package/README.md +350 -23
- package/dist/ai.d.ts +5 -0
- package/dist/ai.js +1 -0
- package/dist/chunk-59t3rqja.js +2 -0
- package/dist/chunk-cwx6cc31.js +2 -0
- package/dist/chunk-exv1kf89.js +60 -0
- package/dist/chunk-gc8zdxyb.js +2 -0
- package/dist/chunk-hjzhc3qg.js +40 -0
- package/dist/chunk-md6fmprc.js +1 -0
- package/dist/chunk-t5vr9nd8.js +8 -0
- package/dist/chunk-v6y7eqxw.js +27 -0
- package/dist/chunk-yed8mvs7.js +2 -0
- package/dist/chunk-yrsb6hws.js +5 -0
- package/dist/chunk-z9rjzn28.js +2 -0
- package/dist/errors.d.ts +60 -0
- package/dist/files.d.ts +57 -0
- package/dist/git.d.ts +28 -0
- package/dist/handle.d.ts +4 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1 -0
- package/dist/keys.d.ts +5 -0
- package/dist/logs.d.ts +8 -0
- package/dist/mastra.d.ts +43 -0
- package/dist/mastra.js +1 -0
- package/dist/memory.d.ts +34 -0
- package/dist/memory.js +11 -0
- package/dist/openai.d.ts +39 -0
- package/dist/openai.js +1 -0
- package/dist/peer.d.ts +5 -0
- package/dist/processes.d.ts +71 -0
- package/dist/provider.d.ts +138 -0
- package/dist/provider.js +0 -0
- package/dist/providers/agentos/errors.d.ts +4 -0
- package/dist/providers/agentos/index.d.ts +11 -0
- package/dist/providers/agentos/index.js +2 -0
- package/dist/providers/boat/index.d.ts +23 -0
- package/dist/providers/boat/index.js +1 -0
- package/dist/providers/boat-api/errors.d.ts +6 -0
- package/dist/providers/boat-api/exec.d.ts +11 -0
- package/dist/providers/boat-api/index.d.ts +22 -0
- package/dist/providers/boxd/errors.d.ts +3 -0
- package/dist/providers/boxd/execute.d.ts +3 -0
- package/dist/providers/boxd/guest.d.ts +14 -0
- package/dist/providers/boxd/index.d.ts +23 -0
- package/dist/providers/boxd/index.js +85 -0
- package/dist/providers/boxd/transfers.d.ts +19 -0
- package/dist/providers/daytona/buffered.d.ts +3 -0
- package/dist/providers/daytona/errors.d.ts +3 -0
- package/dist/providers/daytona/exec.d.ts +14 -0
- package/dist/providers/daytona/index.d.ts +24 -0
- package/dist/providers/daytona/index.js +88 -0
- package/dist/providers/e2b/errors.d.ts +3 -0
- package/dist/providers/e2b/index.d.ts +15 -0
- package/dist/providers/e2b/index.js +1 -0
- package/dist/providers/freestyle/deadline.d.ts +4 -0
- package/dist/providers/freestyle/errors.d.ts +16 -0
- package/dist/providers/freestyle/execute.d.ts +12 -0
- package/dist/providers/freestyle/index.d.ts +14 -0
- package/dist/providers/freestyle/index.js +133 -0
- package/dist/providers/freestyle/wire.d.ts +10 -0
- package/dist/providers/local/docker.d.ts +32 -0
- package/dist/providers/local/index.d.ts +17 -0
- package/dist/providers/local/index.js +2 -0
- package/dist/providers/railway/errors.d.ts +4 -0
- package/dist/providers/railway/index.d.ts +24 -0
- package/dist/providers/railway/index.js +1 -0
- package/dist/providers/sandboxer/index.d.ts +33 -0
- package/dist/providers/sandboxer/index.js +1 -0
- package/dist/providers/superserve/bootstrap.d.ts +11 -0
- package/dist/providers/superserve/errors.d.ts +3 -0
- package/dist/providers/superserve/execute.d.ts +13 -0
- package/dist/providers/superserve/index.d.ts +23 -0
- package/dist/providers/superserve/index.js +126 -0
- package/dist/providers/tenki/deadline.d.ts +2 -0
- package/dist/providers/tenki/errors.d.ts +10 -0
- package/dist/providers/tenki/exec.d.ts +4 -0
- package/dist/providers/tenki/files.d.ts +3 -0
- package/dist/providers/tenki/index.d.ts +28 -0
- package/dist/providers/tenki/index.js +172 -0
- package/dist/providers/tenki/ready.d.ts +7 -0
- package/dist/providers/tenki/stream.d.ts +3 -0
- package/dist/providers/upstash/buffered.d.ts +3 -0
- package/dist/providers/upstash/errors.d.ts +3 -0
- package/dist/providers/upstash/exec.d.ts +18 -0
- package/dist/providers/upstash/files.d.ts +15 -0
- package/dist/providers/upstash/index.d.ts +38 -0
- package/dist/providers/upstash/index.js +111 -0
- package/dist/providers/vercel/errors.d.ts +3 -0
- package/dist/providers/vercel/index.d.ts +14 -0
- package/dist/providers/vercel/index.js +1 -0
- package/dist/providers/vercel/provider.d.ts +10 -0
- package/dist/providers/vercel/transport.d.ts +40 -0
- package/dist/run.d.ts +41 -0
- package/dist/testing.d.ts +17 -0
- package/dist/testing.js +6 -0
- package/dist/tool-security.d.ts +9 -0
- package/dist/tools.d.ts +117 -0
- package/dist/tools.js +1 -0
- package/dist/types.d.ts +189 -0
- package/package.json +170 -92
- package/dist/agentos-DFJ4TFaY.mjs +0 -389
- package/dist/agentos-DFJ4TFaY.mjs.map +0 -1
- package/dist/ai/harness.d.mts +0 -16
- package/dist/ai/harness.mjs +0 -69
- package/dist/ai/harness.mjs.map +0 -1
- package/dist/ai/index.d.mts +0 -54
- package/dist/ai/index.mjs +0 -4
- package/dist/ai-DhfwIZdL.mjs +0 -243
- package/dist/ai-DhfwIZdL.mjs.map +0 -1
- package/dist/capabilities-CEowrzRM.mjs +0 -99
- package/dist/capabilities-CEowrzRM.mjs.map +0 -1
- package/dist/capabilities-COKpwoFH.mjs +0 -28
- package/dist/capabilities-COKpwoFH.mjs.map +0 -1
- package/dist/capabilities-DftdOpIu.d.mts +0 -13
- package/dist/errors-Ch9PHKTd.mjs +0 -61
- package/dist/errors-Ch9PHKTd.mjs.map +0 -1
- package/dist/eve/index.d.mts +0 -19
- package/dist/eve/index.mjs +0 -155
- package/dist/eve/index.mjs.map +0 -1
- package/dist/index-Bk6GmoEt.d.mts +0 -25
- package/dist/index-BufLdrbp.d.mts +0 -31
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -38
- package/dist/index.mjs.map +0 -1
- package/dist/mastra/index.d.mts +0 -118
- package/dist/mastra/index.mjs +0 -662
- package/dist/mastra/index.mjs.map +0 -1
- package/dist/metadata.d.mts +0 -34
- package/dist/metadata.mjs +0 -103
- package/dist/metadata.mjs.map +0 -1
- package/dist/provider-BzzkIVmv.d.mts +0 -91
- package/dist/provider-utils-BjOSWNsh.mjs +0 -201
- package/dist/provider-utils-BjOSWNsh.mjs.map +0 -1
- package/dist/providers/agentos/index.d.mts +0 -7
- package/dist/providers/agentos/index.mjs +0 -8
- package/dist/providers/daytona/index.d.mts +0 -21
- package/dist/providers/daytona/index.mjs +0 -205
- package/dist/providers/daytona/index.mjs.map +0 -1
- package/dist/providers/e2b/index.d.mts +0 -17
- package/dist/providers/e2b/index.mjs +0 -168
- package/dist/providers/e2b/index.mjs.map +0 -1
- package/dist/providers/local/index.d.mts +0 -22
- package/dist/providers/local/index.mjs +0 -21
- package/dist/providers/local/index.mjs.map +0 -1
- package/dist/providers/upstash/index.d.mts +0 -17
- package/dist/providers/upstash/index.mjs +0 -210
- package/dist/providers/upstash/index.mjs.map +0 -1
- package/dist/providers/vercel/index.d.mts +0 -28
- package/dist/providers/vercel/index.mjs +0 -185
- package/dist/providers/vercel/index.mjs.map +0 -1
- package/dist/sandbox-Dco6z9aB.d.mts +0 -26
- package/dist/sandbox-rIOcbhtM.mjs +0 -112
- package/dist/sandbox-rIOcbhtM.mjs.map +0 -1
- package/dist/testing/index.d.mts +0 -27
- package/dist/testing/index.mjs +0 -173
- package/dist/testing/index.mjs.map +0 -1
- package/dist/types-DEi_dfRR.d.mts +0 -103
package/dist/testing/index.d.mts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import "../types-DEi_dfRR.mjs";
|
|
2
|
-
import { o as SandboxProvider } from "../provider-BzzkIVmv.mjs";
|
|
3
|
-
import { t as CreateSandboxOptions } from "../sandbox-Dco6z9aB.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/testing/conformance.d.ts
|
|
6
|
-
declare const conformanceCases: readonly ["create and stop", "idempotent stop", "text files", "binary files", "directories", "relative paths", "invalid paths", "successful command", "stdout", "stderr", "nonzero exit", "timeout", "background process", "stdin", "ports", "snapshot create", "snapshot delete", "snapshot restore", "cleanup after failure"];
|
|
7
|
-
interface ConformanceSubject<TProvider extends SandboxProvider<unknown>> {
|
|
8
|
-
create: CreateSandboxOptions<TProvider>;
|
|
9
|
-
commands: {
|
|
10
|
-
success: string;
|
|
11
|
-
stdout: string;
|
|
12
|
-
stderr: string;
|
|
13
|
-
nonzero: string;
|
|
14
|
-
timeout: string;
|
|
15
|
-
background: string;
|
|
16
|
-
stdin: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
interface ConformanceResult {
|
|
20
|
-
name: (typeof conformanceCases)[number];
|
|
21
|
-
status: "passed" | "failed" | "skipped";
|
|
22
|
-
error?: unknown;
|
|
23
|
-
}
|
|
24
|
-
declare function runConformance<TProvider extends SandboxProvider<unknown>>(subject: ConformanceSubject<TProvider>): Promise<ConformanceResult[]>;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { type ConformanceResult, type ConformanceSubject, conformanceCases, runConformance };
|
|
27
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/testing/index.mjs
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import "../errors-Ch9PHKTd.mjs";
|
|
2
|
-
import { i as supports } from "../capabilities-COKpwoFH.mjs";
|
|
3
|
-
import { t as createSandbox } from "../sandbox-rIOcbhtM.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/testing/conformance.ts
|
|
6
|
-
const conformanceCases = [
|
|
7
|
-
"create and stop",
|
|
8
|
-
"idempotent stop",
|
|
9
|
-
"text files",
|
|
10
|
-
"binary files",
|
|
11
|
-
"directories",
|
|
12
|
-
"relative paths",
|
|
13
|
-
"invalid paths",
|
|
14
|
-
"successful command",
|
|
15
|
-
"stdout",
|
|
16
|
-
"stderr",
|
|
17
|
-
"nonzero exit",
|
|
18
|
-
"timeout",
|
|
19
|
-
"background process",
|
|
20
|
-
"stdin",
|
|
21
|
-
"ports",
|
|
22
|
-
"snapshot create",
|
|
23
|
-
"snapshot delete",
|
|
24
|
-
"snapshot restore",
|
|
25
|
-
"cleanup after failure"
|
|
26
|
-
];
|
|
27
|
-
async function runConformance(subject) {
|
|
28
|
-
const results = [];
|
|
29
|
-
const check = async (name, test) => {
|
|
30
|
-
try {
|
|
31
|
-
await test();
|
|
32
|
-
results.push({
|
|
33
|
-
name,
|
|
34
|
-
status: "passed"
|
|
35
|
-
});
|
|
36
|
-
} catch (error) {
|
|
37
|
-
results.push({
|
|
38
|
-
name,
|
|
39
|
-
status: "failed",
|
|
40
|
-
error
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
await check("create and stop", async () => {
|
|
45
|
-
await (await createSandbox(subject.create)).stop();
|
|
46
|
-
});
|
|
47
|
-
await check("idempotent stop", async () => {
|
|
48
|
-
const sandbox$1 = await createSandbox(subject.create);
|
|
49
|
-
await sandbox$1.stop();
|
|
50
|
-
await sandbox$1.stop();
|
|
51
|
-
});
|
|
52
|
-
const sandbox = await createSandbox(subject.create);
|
|
53
|
-
try {
|
|
54
|
-
await check("text files", async () => {
|
|
55
|
-
await sandbox.files.write("text.txt", "hello");
|
|
56
|
-
if (await sandbox.files.text("text.txt") !== "hello") throw new Error("text mismatch");
|
|
57
|
-
});
|
|
58
|
-
await check("binary files", async () => {
|
|
59
|
-
const expected = new Uint8Array([
|
|
60
|
-
0,
|
|
61
|
-
1,
|
|
62
|
-
2,
|
|
63
|
-
255
|
|
64
|
-
]);
|
|
65
|
-
await sandbox.files.write("binary.bin", expected);
|
|
66
|
-
if (!(await sandbox.files.read("binary.bin")).every((value, index) => value === expected[index])) throw new Error("binary mismatch");
|
|
67
|
-
});
|
|
68
|
-
await check("directories", async () => {
|
|
69
|
-
await sandbox.files.mkdir("nested");
|
|
70
|
-
await sandbox.files.write("nested/item.txt", "item");
|
|
71
|
-
if (!(await sandbox.files.list("nested")).some((entry) => entry.name === "item.txt")) throw new Error("list mismatch");
|
|
72
|
-
await sandbox.files.remove("nested");
|
|
73
|
-
});
|
|
74
|
-
await check("relative paths", async () => {
|
|
75
|
-
await sandbox.files.write("relative.txt", "yes");
|
|
76
|
-
if (!await sandbox.files.exists("relative.txt")) throw new Error("relative path not resolved");
|
|
77
|
-
});
|
|
78
|
-
await check("invalid paths", async () => {
|
|
79
|
-
try {
|
|
80
|
-
await sandbox.files.read("../escape");
|
|
81
|
-
} catch {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
throw new Error("path traversal accepted");
|
|
85
|
-
});
|
|
86
|
-
await check("successful command", async () => {
|
|
87
|
-
if (!(await sandbox.run(subject.commands.success)).success) throw new Error("command failed");
|
|
88
|
-
});
|
|
89
|
-
await check("stdout", async () => {
|
|
90
|
-
if (!(await sandbox.run(subject.commands.stdout)).stdout.includes("stdout")) throw new Error("stdout missing");
|
|
91
|
-
});
|
|
92
|
-
await check("stderr", async () => {
|
|
93
|
-
const result = await sandbox.run(subject.commands.stderr);
|
|
94
|
-
if (!(sandbox.capabilities["process.run"] === "combined-stream" ? `${result.stdout}${result.stderr}` : result.stderr).includes("stderr")) throw new Error("stderr missing");
|
|
95
|
-
});
|
|
96
|
-
await check("nonzero exit", async () => {
|
|
97
|
-
if ((await sandbox.run(subject.commands.nonzero)).exitCode === 0) throw new Error("expected nonzero exit");
|
|
98
|
-
});
|
|
99
|
-
await check("timeout", async () => {
|
|
100
|
-
try {
|
|
101
|
-
await sandbox.run(subject.commands.timeout, { timeout: 20 });
|
|
102
|
-
} catch {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
throw new Error("timeout not enforced");
|
|
106
|
-
});
|
|
107
|
-
if (supports(sandbox, "process.background")) await check("background process", async () => {
|
|
108
|
-
await (await sandbox.processes.start(subject.commands.background)).kill();
|
|
109
|
-
});
|
|
110
|
-
else results.push({
|
|
111
|
-
name: "background process",
|
|
112
|
-
status: "skipped"
|
|
113
|
-
});
|
|
114
|
-
if (supports(sandbox, "process.stdin")) await check("stdin", async () => {
|
|
115
|
-
const process = await sandbox.processes.start(subject.commands.stdin);
|
|
116
|
-
await process.write("received\n");
|
|
117
|
-
for await (const event of process.output()) if ((typeof event.data === "string" ? event.data : new TextDecoder().decode(event.data)).includes("received")) return;
|
|
118
|
-
throw new Error("stdin output missing");
|
|
119
|
-
});
|
|
120
|
-
else results.push({
|
|
121
|
-
name: "stdin",
|
|
122
|
-
status: "skipped"
|
|
123
|
-
});
|
|
124
|
-
if (supports(sandbox, "ports.expose")) await check("ports", async () => {
|
|
125
|
-
const port = await sandbox.ports.expose(3e3);
|
|
126
|
-
if (port.port !== 3e3 || !port.url) throw new Error("invalid exposed port");
|
|
127
|
-
});
|
|
128
|
-
else results.push({
|
|
129
|
-
name: "ports",
|
|
130
|
-
status: "skipped"
|
|
131
|
-
});
|
|
132
|
-
let createdSnapshot;
|
|
133
|
-
if (supports(sandbox, "snapshot.create")) await check("snapshot create", async () => {
|
|
134
|
-
await sandbox.files.write("snapshot.txt", "before");
|
|
135
|
-
createdSnapshot = await sandbox.snapshots.create({ name: "conformance" });
|
|
136
|
-
});
|
|
137
|
-
else results.push({
|
|
138
|
-
name: "snapshot create",
|
|
139
|
-
status: "skipped"
|
|
140
|
-
});
|
|
141
|
-
if (createdSnapshot && supports(sandbox, "snapshot.restore")) await check("snapshot restore", async () => {
|
|
142
|
-
await sandbox.files.write("snapshot.txt", "after");
|
|
143
|
-
await sandbox.snapshots.restore(createdSnapshot);
|
|
144
|
-
if (await sandbox.files.text("snapshot.txt") !== "before") throw new Error("snapshot not restored");
|
|
145
|
-
});
|
|
146
|
-
else results.push({
|
|
147
|
-
name: "snapshot restore",
|
|
148
|
-
status: "skipped"
|
|
149
|
-
});
|
|
150
|
-
if (createdSnapshot && supports(sandbox, "snapshot.delete")) await check("snapshot delete", async () => {
|
|
151
|
-
await sandbox.snapshots.delete(createdSnapshot);
|
|
152
|
-
});
|
|
153
|
-
else results.push({
|
|
154
|
-
name: "snapshot delete",
|
|
155
|
-
status: "skipped"
|
|
156
|
-
});
|
|
157
|
-
} finally {
|
|
158
|
-
await sandbox.stop();
|
|
159
|
-
}
|
|
160
|
-
await check("cleanup after failure", async () => {
|
|
161
|
-
const temporary = await createSandbox(subject.create);
|
|
162
|
-
try {
|
|
163
|
-
throw new Error("expected");
|
|
164
|
-
} catch {} finally {
|
|
165
|
-
await temporary.stop();
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
return results;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
export { conformanceCases, runConformance };
|
|
173
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["results: ConformanceResult[]","sandbox","createdSnapshot: Awaited<ReturnType<typeof sandbox.snapshots.create>> | undefined"],"sources":["../../src/testing/conformance.ts"],"sourcesContent":["import { createSandbox, type CreateSandboxOptions } from \"../core/sandbox\";\nimport { supports } from \"../core/capabilities\";\nimport type { SandboxProvider } from \"../core/provider\";\n\nexport const conformanceCases = [\n \"create and stop\",\n \"idempotent stop\",\n \"text files\",\n \"binary files\",\n \"directories\",\n \"relative paths\",\n \"invalid paths\",\n \"successful command\",\n \"stdout\",\n \"stderr\",\n \"nonzero exit\",\n \"timeout\",\n \"background process\",\n \"stdin\",\n \"ports\",\n \"snapshot create\",\n \"snapshot delete\",\n \"snapshot restore\",\n \"cleanup after failure\",\n] as const;\n\nexport interface ConformanceSubject<TProvider extends SandboxProvider<unknown>> {\n create: CreateSandboxOptions<TProvider>;\n commands: {\n success: string;\n stdout: string;\n stderr: string;\n nonzero: string;\n timeout: string;\n background: string;\n stdin: string;\n };\n}\n\nexport interface ConformanceResult {\n name: (typeof conformanceCases)[number];\n status: \"passed\" | \"failed\" | \"skipped\";\n error?: unknown;\n}\n\nexport async function runConformance<TProvider extends SandboxProvider<unknown>>(\n subject: ConformanceSubject<TProvider>,\n): Promise<ConformanceResult[]> {\n const results: ConformanceResult[] = [];\n const check = async (name: ConformanceResult[\"name\"], test: () => Promise<void>) => {\n try {\n await test();\n results.push({ name, status: \"passed\" });\n } catch (error) {\n results.push({ name, status: \"failed\", error });\n }\n };\n await check(\"create and stop\", async () => {\n const sandbox = await createSandbox(subject.create);\n await sandbox.stop();\n });\n await check(\"idempotent stop\", async () => {\n const sandbox = await createSandbox(subject.create);\n await sandbox.stop();\n await sandbox.stop();\n });\n const sandbox = await createSandbox(subject.create);\n try {\n await check(\"text files\", async () => {\n await sandbox.files.write(\"text.txt\", \"hello\");\n if ((await sandbox.files.text(\"text.txt\")) !== \"hello\") throw new Error(\"text mismatch\");\n });\n await check(\"binary files\", async () => {\n const expected = new Uint8Array([0, 1, 2, 255]);\n await sandbox.files.write(\"binary.bin\", expected);\n const actual = await sandbox.files.read(\"binary.bin\");\n if (!actual.every((value, index) => value === expected[index]))\n throw new Error(\"binary mismatch\");\n });\n await check(\"directories\", async () => {\n await sandbox.files.mkdir(\"nested\");\n await sandbox.files.write(\"nested/item.txt\", \"item\");\n if (!(await sandbox.files.list(\"nested\")).some((entry) => entry.name === \"item.txt\"))\n throw new Error(\"list mismatch\");\n await sandbox.files.remove(\"nested\");\n });\n await check(\"relative paths\", async () => {\n await sandbox.files.write(\"relative.txt\", \"yes\");\n if (!(await sandbox.files.exists(\"relative.txt\")))\n throw new Error(\"relative path not resolved\");\n });\n await check(\"invalid paths\", async () => {\n try {\n await sandbox.files.read(\"../escape\");\n } catch {\n return;\n }\n throw new Error(\"path traversal accepted\");\n });\n await check(\"successful command\", async () => {\n if (!(await sandbox.run(subject.commands.success)).success) throw new Error(\"command failed\");\n });\n await check(\"stdout\", async () => {\n if (!(await sandbox.run(subject.commands.stdout)).stdout.includes(\"stdout\"))\n throw new Error(\"stdout missing\");\n });\n await check(\"stderr\", async () => {\n const result = await sandbox.run(subject.commands.stderr);\n const output =\n sandbox.capabilities[\"process.run\"] === \"combined-stream\"\n ? `${result.stdout}${result.stderr}`\n : result.stderr;\n if (!output.includes(\"stderr\")) throw new Error(\"stderr missing\");\n });\n await check(\"nonzero exit\", async () => {\n if ((await sandbox.run(subject.commands.nonzero)).exitCode === 0)\n throw new Error(\"expected nonzero exit\");\n });\n await check(\"timeout\", async () => {\n try {\n await sandbox.run(subject.commands.timeout, { timeout: 20 });\n } catch {\n return;\n }\n throw new Error(\"timeout not enforced\");\n });\n if (supports(sandbox, \"process.background\"))\n await check(\"background process\", async () => {\n const process = await sandbox.processes.start(subject.commands.background);\n await process.kill();\n });\n else results.push({ name: \"background process\", status: \"skipped\" });\n if (supports(sandbox, \"process.stdin\"))\n await check(\"stdin\", async () => {\n const process = await sandbox.processes.start(subject.commands.stdin);\n await process.write(\"received\\n\");\n for await (const event of process.output()) {\n const data =\n typeof event.data === \"string\" ? event.data : new TextDecoder().decode(event.data);\n if (data.includes(\"received\")) return;\n }\n throw new Error(\"stdin output missing\");\n });\n else results.push({ name: \"stdin\", status: \"skipped\" });\n if (supports(sandbox, \"ports.expose\"))\n await check(\"ports\", async () => {\n const port = await sandbox.ports.expose(30_00);\n if (port.port !== 3000 || !port.url) throw new Error(\"invalid exposed port\");\n });\n else results.push({ name: \"ports\", status: \"skipped\" });\n let createdSnapshot: Awaited<ReturnType<typeof sandbox.snapshots.create>> | undefined;\n if (supports(sandbox, \"snapshot.create\"))\n await check(\"snapshot create\", async () => {\n await sandbox.files.write(\"snapshot.txt\", \"before\");\n createdSnapshot = await sandbox.snapshots.create({ name: \"conformance\" });\n });\n else results.push({ name: \"snapshot create\", status: \"skipped\" });\n if (createdSnapshot && supports(sandbox, \"snapshot.restore\"))\n await check(\"snapshot restore\", async () => {\n await sandbox.files.write(\"snapshot.txt\", \"after\");\n await sandbox.snapshots.restore(createdSnapshot!);\n if ((await sandbox.files.text(\"snapshot.txt\")) !== \"before\")\n throw new Error(\"snapshot not restored\");\n });\n else results.push({ name: \"snapshot restore\", status: \"skipped\" });\n if (createdSnapshot && supports(sandbox, \"snapshot.delete\"))\n await check(\"snapshot delete\", async () => {\n await sandbox.snapshots.delete(createdSnapshot!);\n });\n else results.push({ name: \"snapshot delete\", status: \"skipped\" });\n } finally {\n await sandbox.stop();\n }\n await check(\"cleanup after failure\", async () => {\n const temporary = await createSandbox(subject.create);\n try {\n throw new Error(\"expected\");\n } catch {\n /* expected */\n } finally {\n await temporary.stop();\n }\n });\n return results;\n}\n"],"mappings":";;;;;AAIA,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAqBD,eAAsB,eACpB,SAC8B;CAC9B,MAAMA,UAA+B,EAAE;CACvC,MAAM,QAAQ,OAAO,MAAiC,SAA8B;AAClF,MAAI;AACF,SAAM,MAAM;AACZ,WAAQ,KAAK;IAAE;IAAM,QAAQ;IAAU,CAAC;WACjC,OAAO;AACd,WAAQ,KAAK;IAAE;IAAM,QAAQ;IAAU;IAAO,CAAC;;;AAGnD,OAAM,MAAM,mBAAmB,YAAY;AAEzC,SADgB,MAAM,cAAc,QAAQ,OAAO,EACrC,MAAM;GACpB;AACF,OAAM,MAAM,mBAAmB,YAAY;EACzC,MAAMC,YAAU,MAAM,cAAc,QAAQ,OAAO;AACnD,QAAMA,UAAQ,MAAM;AACpB,QAAMA,UAAQ,MAAM;GACpB;CACF,MAAM,UAAU,MAAM,cAAc,QAAQ,OAAO;AACnD,KAAI;AACF,QAAM,MAAM,cAAc,YAAY;AACpC,SAAM,QAAQ,MAAM,MAAM,YAAY,QAAQ;AAC9C,OAAK,MAAM,QAAQ,MAAM,KAAK,WAAW,KAAM,QAAS,OAAM,IAAI,MAAM,gBAAgB;IACxF;AACF,QAAM,MAAM,gBAAgB,YAAY;GACtC,MAAM,WAAW,IAAI,WAAW;IAAC;IAAG;IAAG;IAAG;IAAI,CAAC;AAC/C,SAAM,QAAQ,MAAM,MAAM,cAAc,SAAS;AAEjD,OAAI,EADW,MAAM,QAAQ,MAAM,KAAK,aAAa,EACzC,OAAO,OAAO,UAA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Ae,CAAC;IACzE;MACC,SAAQ,KAAK;GAAE,MAAM;GAAmB,QAAQ;GAAW,CAAC;AACjE,MAAI,mBAAmB,SAAS,SAAS,mBAAmB,CAC1D,OAAM,MAAM,oBAAoB,YAAY;AAC1C,SAAM,QAAQ,MAAM,MAAM,gBAAgB,QAAQ;AAClD,SAAM,QAAQ,UAAU,QAAQ,gBAAiB;AACjD,OAAK,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAM,SACjD,OAAM,IAAI,MAAM,wBAAwB;IAC1C;MACC,SAAQ,KAAK;GAAE,MAAM;GAAoB,QAAQ;GAAW,CAAC;AAClE,MAAI,mBAAmB,SAAS,SAAS,kBAAkB,CACzD,OAAM,MAAM,mBAAmB,YAAY;AACzC,SAAM,QAAQ,UAAU,OAAO,gBAAiB;IAChD;MACC,SAAQ,KAAK;GAAE,MAAM;GAAmB,QAAQ;GAAW,CAAC;WACzD;AACR,QAAM,QAAQ,MAAM;;AAEtB,OAAM,MAAM,yBAAyB,YAAY;EAC/C,MAAM,YAAY,MAAM,cAAc,QAAQ,OAAO;AACrD,MAAI;AACF,SAAM,IAAI,MAAM,WAAW;UACrB,WAEE;AACR,SAAM,UAAU,MAAM;;GAExB;AACF,QAAO"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
//#region src/core/types.d.ts
|
|
2
|
-
declare const providerNames: readonly ["local", "e2b", "daytona", "vercel", "upstash"];
|
|
3
|
-
type ProviderName = (typeof providerNames)[number];
|
|
4
|
-
declare const capabilityNames: readonly ["files.read", "files.write", "files.list", "files.remove", "process.run", "process.stream", "process.background", "process.stdin", "process.cancel", "ports.expose", "ports.authenticatedRequest", "snapshot.create", "snapshot.delete", "snapshot.restore", "sandbox.resume", "filesystem.persistent", "image.custom", "network.policy", "process.pty", "compute.gpu"];
|
|
5
|
-
type Capability = (typeof capabilityNames)[number];
|
|
6
|
-
type CapabilityMode = "filesystem" | "memory" | "template" | "fork" | "public" | "authenticated" | "combined-stream" | "separate-streams" | "ephemeral" | "persistent" | "localhost" | "in-process" | "full" | "native";
|
|
7
|
-
type CapabilityMap = Readonly<Record<Capability, false | CapabilityMode>>;
|
|
8
|
-
type CommandInput = string | {
|
|
9
|
-
command: string;
|
|
10
|
-
args?: readonly string[];
|
|
11
|
-
};
|
|
12
|
-
interface RunOptions {
|
|
13
|
-
cwd?: string;
|
|
14
|
-
env?: Readonly<Record<string, string>>;
|
|
15
|
-
timeout?: number;
|
|
16
|
-
signal?: AbortSignal;
|
|
17
|
-
}
|
|
18
|
-
interface CommandResult {
|
|
19
|
-
stdout: string;
|
|
20
|
-
stderr: string;
|
|
21
|
-
exitCode: number;
|
|
22
|
-
success: boolean;
|
|
23
|
-
signal?: string;
|
|
24
|
-
durationMs?: number;
|
|
25
|
-
}
|
|
26
|
-
type FileValue = string | Uint8Array | ArrayBuffer | Blob | ReadableStream<Uint8Array>;
|
|
27
|
-
interface SandboxDirectoryEntry {
|
|
28
|
-
name: string;
|
|
29
|
-
path: string;
|
|
30
|
-
type: "file" | "directory" | "symlink" | "unknown";
|
|
31
|
-
size?: number;
|
|
32
|
-
}
|
|
33
|
-
interface SandboxFiles {
|
|
34
|
-
write(path: string, value: FileValue): Promise<void>;
|
|
35
|
-
read(path: string): Promise<Uint8Array>;
|
|
36
|
-
text(path: string): Promise<string>;
|
|
37
|
-
list(path?: string): Promise<SandboxDirectoryEntry[]>;
|
|
38
|
-
mkdir(path: string): Promise<void>;
|
|
39
|
-
remove(path: string): Promise<void>;
|
|
40
|
-
exists(path: string): Promise<boolean>;
|
|
41
|
-
}
|
|
42
|
-
interface ProcessOutputEvent {
|
|
43
|
-
stream: "stdout" | "stderr";
|
|
44
|
-
data: string | Uint8Array;
|
|
45
|
-
timestamp?: Date;
|
|
46
|
-
}
|
|
47
|
-
type ProcessStatus = "starting" | "running" | "exited" | "killed" | "unknown";
|
|
48
|
-
interface SandboxProcess {
|
|
49
|
-
readonly id: string;
|
|
50
|
-
status(): Promise<ProcessStatus>;
|
|
51
|
-
output(): AsyncIterable<ProcessOutputEvent>;
|
|
52
|
-
write(value: string | Uint8Array): Promise<void>;
|
|
53
|
-
wait(): Promise<{
|
|
54
|
-
exitCode: number;
|
|
55
|
-
}>;
|
|
56
|
-
kill(signal?: string): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
interface SandboxProcesses {
|
|
59
|
-
start(command: CommandInput, options?: RunOptions): Promise<SandboxProcess>;
|
|
60
|
-
}
|
|
61
|
-
interface ExposedPort {
|
|
62
|
-
readonly port: number;
|
|
63
|
-
readonly url: string;
|
|
64
|
-
readonly public: boolean;
|
|
65
|
-
readonly authenticated: boolean;
|
|
66
|
-
request?(path?: string, init?: RequestInit): Promise<Response>;
|
|
67
|
-
toJSON(): Omit<ExposedPort, "request" | "toJSON">;
|
|
68
|
-
}
|
|
69
|
-
interface SandboxPorts {
|
|
70
|
-
expose(port: number): Promise<ExposedPort>;
|
|
71
|
-
}
|
|
72
|
-
interface SandboxSnapshot {
|
|
73
|
-
readonly id: string;
|
|
74
|
-
readonly name?: string;
|
|
75
|
-
readonly mode: CapabilityMode;
|
|
76
|
-
readonly createdAt?: Date;
|
|
77
|
-
}
|
|
78
|
-
interface SandboxSnapshots {
|
|
79
|
-
create(options?: {
|
|
80
|
-
name?: string;
|
|
81
|
-
}): Promise<SandboxSnapshot>;
|
|
82
|
-
delete(snapshot: SandboxSnapshot | string): Promise<void>;
|
|
83
|
-
restore(snapshot: SandboxSnapshot | string): Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
interface Sandbox<TRaw = unknown> {
|
|
86
|
-
readonly id: string;
|
|
87
|
-
readonly provider: ProviderName;
|
|
88
|
-
readonly cwd: string;
|
|
89
|
-
readonly capabilities: CapabilityMap;
|
|
90
|
-
readonly raw: TRaw;
|
|
91
|
-
readonly files: SandboxFiles;
|
|
92
|
-
readonly processes: SandboxProcesses;
|
|
93
|
-
readonly ports: SandboxPorts;
|
|
94
|
-
readonly snapshots: SandboxSnapshots;
|
|
95
|
-
run(command: CommandInput, options?: RunOptions): Promise<CommandResult>;
|
|
96
|
-
/** Stops the provider runtime. Repeated calls share the same cleanup operation. */
|
|
97
|
-
stop(): Promise<void>;
|
|
98
|
-
/** Stops the sandbox when an `await using` scope exits. */
|
|
99
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
export { SandboxProcesses as _, CommandResult as a, capabilityNames as b, ProcessOutputEvent as c, RunOptions as d, Sandbox as f, SandboxProcess as g, SandboxPorts as h, CommandInput as i, ProcessStatus as l, SandboxFiles as m, CapabilityMap as n, ExposedPort as o, SandboxDirectoryEntry as p, CapabilityMode as r, FileValue as s, Capability as t, ProviderName as u, SandboxSnapshot as v, providerNames as x, SandboxSnapshots as y };
|
|
103
|
-
//# sourceMappingURL=types-DEi_dfRR.d.mts.map
|