@opencoredev/sandbox-sdk 0.1.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +33 -0
  4. package/dist/agentos-BOFA_q-a.mjs +389 -0
  5. package/dist/agentos-BOFA_q-a.mjs.map +1 -0
  6. package/dist/ai/harness.d.mts +16 -0
  7. package/dist/ai/harness.mjs +69 -0
  8. package/dist/ai/harness.mjs.map +1 -0
  9. package/dist/ai/index.d.mts +54 -0
  10. package/dist/ai/index.mjs +4 -0
  11. package/dist/ai-DhfwIZdL.mjs +243 -0
  12. package/dist/ai-DhfwIZdL.mjs.map +1 -0
  13. package/dist/capabilities-CEowrzRM.mjs +99 -0
  14. package/dist/capabilities-CEowrzRM.mjs.map +1 -0
  15. package/dist/capabilities-CMnszzpt.d.mts +13 -0
  16. package/dist/capabilities-COKpwoFH.mjs +28 -0
  17. package/dist/capabilities-COKpwoFH.mjs.map +1 -0
  18. package/dist/errors-Ch9PHKTd.mjs +61 -0
  19. package/dist/errors-Ch9PHKTd.mjs.map +1 -0
  20. package/dist/eve/index.d.mts +19 -0
  21. package/dist/eve/index.mjs +155 -0
  22. package/dist/eve/index.mjs.map +1 -0
  23. package/dist/index-B1YT6OQ8.d.mts +25 -0
  24. package/dist/index-BMFkO6Fv.d.mts +31 -0
  25. package/dist/index.d.mts +5 -0
  26. package/dist/index.mjs +38 -0
  27. package/dist/index.mjs.map +1 -0
  28. package/dist/mastra/index.d.mts +118 -0
  29. package/dist/mastra/index.mjs +662 -0
  30. package/dist/mastra/index.mjs.map +1 -0
  31. package/dist/metadata.d.mts +34 -0
  32. package/dist/metadata.mjs +103 -0
  33. package/dist/metadata.mjs.map +1 -0
  34. package/dist/provider-_caCV8kk.d.mts +91 -0
  35. package/dist/provider-utils-DilOYLBO.mjs +201 -0
  36. package/dist/provider-utils-DilOYLBO.mjs.map +1 -0
  37. package/dist/providers/agentos/index.d.mts +7 -0
  38. package/dist/providers/agentos/index.mjs +8 -0
  39. package/dist/providers/daytona/index.d.mts +21 -0
  40. package/dist/providers/daytona/index.mjs +205 -0
  41. package/dist/providers/daytona/index.mjs.map +1 -0
  42. package/dist/providers/e2b/index.d.mts +17 -0
  43. package/dist/providers/e2b/index.mjs +168 -0
  44. package/dist/providers/e2b/index.mjs.map +1 -0
  45. package/dist/providers/local/index.d.mts +22 -0
  46. package/dist/providers/local/index.mjs +21 -0
  47. package/dist/providers/local/index.mjs.map +1 -0
  48. package/dist/providers/upstash/index.d.mts +17 -0
  49. package/dist/providers/upstash/index.mjs +210 -0
  50. package/dist/providers/upstash/index.mjs.map +1 -0
  51. package/dist/providers/vercel/index.d.mts +27 -0
  52. package/dist/providers/vercel/index.mjs +185 -0
  53. package/dist/providers/vercel/index.mjs.map +1 -0
  54. package/dist/sandbox-BUYT-1C9.d.mts +17 -0
  55. package/dist/sandbox-BwyHcB_C.mjs +102 -0
  56. package/dist/sandbox-BwyHcB_C.mjs.map +1 -0
  57. package/dist/testing/index.d.mts +27 -0
  58. package/dist/testing/index.mjs +173 -0
  59. package/dist/testing/index.mjs.map +1 -0
  60. package/dist/types-BTagTtsp.d.mts +100 -0
  61. package/package.json +151 -0
@@ -0,0 +1,210 @@
1
+ import { t as SandboxError } from "../../errors-Ch9PHKTd.mjs";
2
+ import "../../capabilities-COKpwoFH.mjs";
3
+ import "../../sandbox-BwyHcB_C.mjs";
4
+ import { a as upstashCapabilities } from "../../capabilities-CEowrzRM.mjs";
5
+ import { i as unsupported, n as portResult, o as withManagedSessions, r as toUint8Array, t as commandString } from "../../provider-utils-DilOYLBO.mjs";
6
+ import { Box } from "@upstash/box";
7
+
8
+ //#region src/providers/upstash/index.ts
9
+ function upstash(options = {}) {
10
+ const { public: publicPorts = true, ...boxOptions } = options;
11
+ return withManagedSessions({
12
+ id: "upstash",
13
+ capabilities: upstashCapabilities,
14
+ async create(createOptions) {
15
+ assertNotAborted(createOptions.signal);
16
+ const raw = await Box.create({
17
+ ...boxOptions,
18
+ env: { ...createOptions.env },
19
+ timeout: boxOptions.timeout ?? createOptions.timeout
20
+ });
21
+ const remoteCwd = raw.cwd;
22
+ const toRemotePath = (path) => replacePathPrefix(path, createOptions.cwd, remoteCwd);
23
+ const toVirtualPath = (path) => replacePathPrefix(path, remoteCwd, createOptions.cwd);
24
+ return {
25
+ id: raw.id,
26
+ raw,
27
+ capabilities: upstashCapabilities,
28
+ files: {
29
+ async write(path, value) {
30
+ const content = Buffer.from(await toUint8Array(value)).toString("base64");
31
+ await raw.files.write({
32
+ path: toRemotePath(path),
33
+ content,
34
+ encoding: "base64"
35
+ });
36
+ },
37
+ async read(path) {
38
+ const content = await raw.files.read(toRemotePath(path), { encoding: "base64" });
39
+ return new Uint8Array(Buffer.from(content, "base64"));
40
+ },
41
+ async list(path) {
42
+ return (await raw.files.list(toRemotePath(path))).map((entry) => ({
43
+ name: entry.name,
44
+ path: toVirtualPath(entry.path),
45
+ type: entry.is_dir ? "directory" : "file",
46
+ size: entry.size
47
+ }));
48
+ },
49
+ async mkdir(path) {
50
+ const result = await raw.exec.command(`mkdir -p ${shellQuote(toRemotePath(path))}`);
51
+ assertCommandSucceeded(result.exitCode, result.result, "files.mkdir");
52
+ },
53
+ async remove(path) {
54
+ const result = await raw.exec.command(`rm -rf -- ${shellQuote(toRemotePath(path))}`);
55
+ assertCommandSucceeded(result.exitCode, result.result, "files.remove");
56
+ },
57
+ async exists(path) {
58
+ return (await raw.exec.command(`test -e ${shellQuote(toRemotePath(path))}`)).exitCode === 0;
59
+ }
60
+ },
61
+ async run(command, runOptions) {
62
+ assertNotAborted(runOptions.signal);
63
+ const started = performance.now();
64
+ const run = await raw.exec.command(scopedCommand(command, runOptions, createOptions.cwd, remoteCwd));
65
+ if (runOptions.timeout !== void 0 && run.exitCode === 124) throw new SandboxError({
66
+ code: "timeout",
67
+ provider: "upstash",
68
+ operation: "process.run",
69
+ message: `Command timed out after ${runOptions.timeout}ms`
70
+ });
71
+ return {
72
+ stdout: run.result,
73
+ stderr: "",
74
+ exitCode: run.exitCode ?? 1,
75
+ success: run.exitCode === 0,
76
+ durationMs: Math.round(performance.now() - started)
77
+ };
78
+ },
79
+ async start(command, runOptions) {
80
+ assertNotAborted(runOptions.signal);
81
+ const handle = await raw.exec.stream(scopedCommand(command, runOptions, createOptions.cwd, remoteCwd));
82
+ const events = [];
83
+ const waiters = /* @__PURE__ */ new Set();
84
+ let status = "running";
85
+ let exitCode = 1;
86
+ const wake = () => {
87
+ for (const waiter of waiters) waiter();
88
+ waiters.clear();
89
+ };
90
+ const streamCompleted = consumeStream(handle, (chunk) => {
91
+ if (chunk.type === "output") {
92
+ events.push({
93
+ stream: "stdout",
94
+ data: chunk.data,
95
+ timestamp: /* @__PURE__ */ new Date()
96
+ });
97
+ wake();
98
+ } else exitCode = chunk.exitCode;
99
+ }).then(() => {
100
+ if (status === "running") status = "exited";
101
+ return { exitCode };
102
+ }).catch((error) => {
103
+ status = "exited";
104
+ throw error;
105
+ }).finally(() => {
106
+ wake();
107
+ });
108
+ return {
109
+ id: handle.id,
110
+ async status() {
111
+ return status;
112
+ },
113
+ async *output() {
114
+ let index = 0;
115
+ while (status === "running" || index < events.length) {
116
+ while (index < events.length) yield events[index++];
117
+ if (status !== "running") break;
118
+ await new Promise((resolve) => waiters.add(resolve));
119
+ }
120
+ },
121
+ async write() {
122
+ unsupported("upstash", "process.stdin");
123
+ },
124
+ wait: () => streamCompleted,
125
+ async kill() {
126
+ unsupported("upstash", "process.cancel");
127
+ }
128
+ };
129
+ },
130
+ async expose(port) {
131
+ const preview = await raw.getPublicURL(port, publicPorts ? void 0 : { bearerToken: true });
132
+ const token = preview.token;
133
+ return portResult(port, preview.url, !token, Boolean(token), token ? (path = "/", init = {}) => fetch(new URL(path, preview.url), {
134
+ ...init,
135
+ headers: {
136
+ ...Object.fromEntries(new Headers(init.headers)),
137
+ authorization: `Bearer ${token}`
138
+ }
139
+ }) : void 0);
140
+ },
141
+ snapshots: {
142
+ async create(snapshotOptions) {
143
+ const snapshot = await raw.snapshot({ name: snapshotOptions?.name ?? `sandbox-sdk-${Date.now()}` });
144
+ return {
145
+ id: snapshot.id,
146
+ name: snapshot.name,
147
+ mode: "filesystem",
148
+ createdAt: timestamp(snapshot.created_at)
149
+ };
150
+ },
151
+ async delete(snapshot) {
152
+ await raw.deleteSnapshot(typeof snapshot === "string" ? snapshot : snapshot.id);
153
+ },
154
+ async restore() {
155
+ unsupported("upstash", "snapshot.restore");
156
+ }
157
+ },
158
+ async stop() {
159
+ await raw.delete();
160
+ }
161
+ };
162
+ }
163
+ }, [], {
164
+ stop: (sandbox) => sandbox.raw.pause(),
165
+ resume: (sandbox) => sandbox.raw.resume(),
166
+ destroy: (sandbox) => sandbox.raw.delete(),
167
+ setNetworkPolicy: (sandbox, policy) => sandbox.raw.updateNetworkPolicy(networkPolicy(policy))
168
+ });
169
+ }
170
+ async function consumeStream(stream, onChunk) {
171
+ for await (const chunk of stream) onChunk(chunk);
172
+ }
173
+ function scopedCommand(input, options, virtualCwd, remoteCwd) {
174
+ const environment = Object.entries(options.env ?? {}).map(([key, value]) => shellQuote(`${key}=${value}`));
175
+ const shell = `sh -c ${shellQuote(commandString(input))}`;
176
+ const timed = options.timeout ? `timeout ${Math.max(1, Math.ceil(options.timeout / 1e3))}s ${shell}` : shell;
177
+ return `cd ${shellQuote(replacePathPrefix(options.cwd ?? virtualCwd, virtualCwd, remoteCwd))} && ${environment.length ? `env ${environment.join(" ")} ` : ""}${timed} 2>&1`;
178
+ }
179
+ function replacePathPrefix(path, from, to) {
180
+ if (path === from) return to;
181
+ if (path.startsWith(`${from}/`)) return `${to}${path.slice(from.length)}`;
182
+ return path;
183
+ }
184
+ function shellQuote(value) {
185
+ return `'${value.replaceAll("'", `'"'"'`)}'`;
186
+ }
187
+ function assertNotAborted(signal) {
188
+ if (signal?.aborted) throw signal.reason ?? new DOMException("Aborted", "AbortError");
189
+ }
190
+ function assertCommandSucceeded(exitCode, output, operation) {
191
+ if (exitCode === 0) return;
192
+ throw new Error(`${operation} failed${output ? `: ${output}` : ""}`);
193
+ }
194
+ function timestamp(value) {
195
+ return new Date(value < 0xe8d4a51000 ? value * 1e3 : value);
196
+ }
197
+ function networkPolicy(policy) {
198
+ if (policy.mode === "allow-all" || policy.mode === "deny-all") return { mode: policy.mode };
199
+ if (policy.mode === "native") return policy.value;
200
+ return {
201
+ mode: "custom",
202
+ allowedDomains: [...policy.allowedHosts ?? []],
203
+ allowedCidrs: [...policy.allowedCIDRs ?? []],
204
+ deniedCidrs: [...policy.deniedCIDRs ?? []]
205
+ };
206
+ }
207
+
208
+ //#endregion
209
+ export { upstash, upstashCapabilities };
210
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["events: ProcessOutputEvent[]","status: \"running\" | \"exited\""],"sources":["../../../src/providers/upstash/index.ts"],"sourcesContent":["import { Box, type BoxConfig, type ExecStreamChunk } from \"@upstash/box\";\nimport { SandboxError } from \"../../core/errors\";\nimport type { SandboxNetworkPolicy, SandboxProvider } from \"../../core/provider\";\nimport type {\n CommandInput,\n ProcessOutputEvent,\n RunOptions,\n SandboxProcess,\n SandboxSnapshot,\n} from \"../../core/types\";\nimport { withManagedSessions } from \"../../internal/managed-provider\";\nimport {\n commandString,\n portResult,\n toUint8Array,\n unsupported,\n} from \"../../internal/provider-utils\";\nimport { upstashCapabilities } from \"../capabilities\";\n\nexport type UpstashOptions = Omit<BoxConfig, \"env\"> & {\n /** Expose ports publicly. Set to false to return bearer-token URLs. */\n public?: boolean;\n};\n\nexport { upstashCapabilities } from \"../capabilities\";\n\nexport function upstash(options: UpstashOptions = {}): SandboxProvider<Box> {\n const { public: publicPorts = true, ...boxOptions } = options;\n\n return withManagedSessions(\n {\n id: \"upstash\",\n capabilities: upstashCapabilities,\n async create(createOptions) {\n assertNotAborted(createOptions.signal);\n const raw = await Box.create({\n ...boxOptions,\n env: { ...createOptions.env },\n timeout: boxOptions.timeout ?? createOptions.timeout,\n });\n const remoteCwd = raw.cwd;\n const toRemotePath = (path: string) =>\n replacePathPrefix(path, createOptions.cwd, remoteCwd);\n const toVirtualPath = (path: string) =>\n replacePathPrefix(path, remoteCwd, createOptions.cwd);\n\n return {\n id: raw.id,\n raw,\n capabilities: upstashCapabilities,\n files: {\n async write(path, value) {\n const content = Buffer.from(await toUint8Array(value)).toString(\"base64\");\n await raw.files.write({\n path: toRemotePath(path),\n content,\n encoding: \"base64\",\n });\n },\n async read(path) {\n const content = await raw.files.read(toRemotePath(path), {\n encoding: \"base64\",\n });\n return new Uint8Array(Buffer.from(content, \"base64\"));\n },\n async list(path) {\n return (await raw.files.list(toRemotePath(path))).map((entry) => ({\n name: entry.name,\n path: toVirtualPath(entry.path),\n type: entry.is_dir ? (\"directory\" as const) : (\"file\" as const),\n size: entry.size,\n }));\n },\n async mkdir(path) {\n const result = await raw.exec.command(`mkdir -p ${shellQuote(toRemotePath(path))}`);\n assertCommandSucceeded(result.exitCode, result.result, \"files.mkdir\");\n },\n async remove(path) {\n const result = await raw.exec.command(`rm -rf -- ${shellQuote(toRemotePath(path))}`);\n assertCommandSucceeded(result.exitCode, result.result, \"files.remove\");\n },\n async exists(path) {\n const result = await raw.exec.command(`test -e ${shellQuote(toRemotePath(path))}`);\n return result.exitCode === 0;\n },\n },\n async run(command, runOptions) {\n assertNotAborted(runOptions.signal);\n const started = performance.now();\n const run = await raw.exec.command(\n scopedCommand(command, runOptions, createOptions.cwd, remoteCwd),\n );\n if (runOptions.timeout !== undefined && run.exitCode === 124) {\n throw new SandboxError({\n code: \"timeout\",\n provider: \"upstash\",\n operation: \"process.run\",\n message: `Command timed out after ${runOptions.timeout}ms`,\n });\n }\n return {\n stdout: run.result,\n stderr: \"\",\n exitCode: run.exitCode ?? 1,\n success: run.exitCode === 0,\n durationMs: Math.round(performance.now() - started),\n };\n },\n async start(command, runOptions) {\n assertNotAborted(runOptions.signal);\n const handle = await raw.exec.stream(\n scopedCommand(command, runOptions, createOptions.cwd, remoteCwd),\n );\n const events: ProcessOutputEvent[] = [];\n const waiters = new Set<() => void>();\n let status: \"running\" | \"exited\" = \"running\";\n let exitCode = 1;\n const wake = () => {\n for (const waiter of waiters) waiter();\n waiters.clear();\n };\n const streamCompleted = consumeStream(handle, (chunk) => {\n if (chunk.type === \"output\") {\n events.push({\n stream: \"stdout\",\n data: chunk.data,\n timestamp: new Date(),\n });\n wake();\n } else {\n exitCode = chunk.exitCode;\n }\n })\n .then(() => {\n if (status === \"running\") status = \"exited\";\n return { exitCode };\n })\n .catch((error: unknown) => {\n status = \"exited\";\n throw error;\n })\n .finally(() => {\n wake();\n });\n\n return {\n id: handle.id,\n async status() {\n return status;\n },\n async *output() {\n let index = 0;\n while (status === \"running\" || index < events.length) {\n while (index < events.length) yield events[index++]!;\n if (status !== \"running\") break;\n await new Promise<void>((resolve) => waiters.add(resolve));\n }\n },\n async write() {\n unsupported(\"upstash\", \"process.stdin\");\n },\n wait: () => streamCompleted,\n async kill() {\n unsupported(\"upstash\", \"process.cancel\");\n },\n } satisfies SandboxProcess;\n },\n async expose(port) {\n const preview = await raw.getPublicURL(\n port,\n publicPorts ? undefined : { bearerToken: true },\n );\n const token = preview.token;\n return portResult(\n port,\n preview.url,\n !token,\n Boolean(token),\n token\n ? (path = \"/\", init = {}) =>\n fetch(new URL(path, preview.url), {\n ...init,\n headers: {\n ...Object.fromEntries(new Headers(init.headers)),\n authorization: `Bearer ${token}`,\n },\n })\n : undefined,\n );\n },\n snapshots: {\n async create(snapshotOptions) {\n const snapshot = await raw.snapshot({\n name: snapshotOptions?.name ?? `sandbox-sdk-${Date.now()}`,\n });\n return {\n id: snapshot.id,\n name: snapshot.name,\n mode: \"filesystem\",\n createdAt: timestamp(snapshot.created_at),\n } satisfies SandboxSnapshot;\n },\n async delete(snapshot) {\n await raw.deleteSnapshot(typeof snapshot === \"string\" ? snapshot : snapshot.id);\n },\n async restore() {\n unsupported(\"upstash\", \"snapshot.restore\");\n },\n },\n async stop() {\n await raw.delete();\n },\n };\n },\n },\n [],\n {\n stop: (sandbox) => sandbox.raw.pause(),\n resume: (sandbox) => sandbox.raw.resume(),\n destroy: (sandbox) => sandbox.raw.delete(),\n setNetworkPolicy: (sandbox, policy) => sandbox.raw.updateNetworkPolicy(networkPolicy(policy)),\n },\n );\n}\n\nasync function consumeStream(\n stream: AsyncIterable<ExecStreamChunk>,\n onChunk: (chunk: ExecStreamChunk) => void,\n): Promise<void> {\n for await (const chunk of stream) onChunk(chunk);\n}\n\nfunction scopedCommand(\n input: CommandInput,\n options: RunOptions,\n virtualCwd: string,\n remoteCwd: string,\n): string {\n const environment = Object.entries(options.env ?? {}).map(([key, value]) =>\n shellQuote(`${key}=${value}`),\n );\n const command = commandString(input);\n const shell = `sh -c ${shellQuote(command)}`;\n const timed = options.timeout\n ? `timeout ${Math.max(1, Math.ceil(options.timeout / 1_000))}s ${shell}`\n : shell;\n const cwd = replacePathPrefix(options.cwd ?? virtualCwd, virtualCwd, remoteCwd);\n return `cd ${shellQuote(cwd)} && ${\n environment.length ? `env ${environment.join(\" \")} ` : \"\"\n }${timed} 2>&1`;\n}\n\nfunction replacePathPrefix(path: string, from: string, to: string): string {\n if (path === from) return to;\n if (path.startsWith(`${from}/`)) return `${to}${path.slice(from.length)}`;\n return path;\n}\n\nfunction shellQuote(value: string): string {\n return `'${value.replaceAll(\"'\", `'\"'\"'`)}'`;\n}\n\nfunction assertNotAborted(signal?: AbortSignal): void {\n if (signal?.aborted) throw signal.reason ?? new DOMException(\"Aborted\", \"AbortError\");\n}\n\nfunction assertCommandSucceeded(exitCode: number | null, output: string, operation: string): void {\n if (exitCode === 0) return;\n throw new Error(`${operation} failed${output ? `: ${output}` : \"\"}`);\n}\n\nfunction timestamp(value: number): Date {\n return new Date(value < 1_000_000_000_000 ? value * 1_000 : value);\n}\n\nfunction networkPolicy(policy: SandboxNetworkPolicy): import(\"@upstash/box\").NetworkPolicy {\n if (policy.mode === \"allow-all\" || policy.mode === \"deny-all\") return { mode: policy.mode };\n if (policy.mode === \"native\") return policy.value as import(\"@upstash/box\").NetworkPolicy;\n return {\n mode: \"custom\",\n allowedDomains: [...(policy.allowedHosts ?? [])],\n allowedCidrs: [...(policy.allowedCIDRs ?? [])],\n deniedCidrs: [...(policy.deniedCIDRs ?? [])],\n };\n}\n\nexport type UpstashBox = Box;\n"],"mappings":";;;;;;;;AA0BA,SAAgB,QAAQ,UAA0B,EAAE,EAAwB;CAC1E,MAAM,EAAE,QAAQ,cAAc,MAAM,GAAG,eAAe;AAEtD,QAAO,oBACL;EACE,IAAI;EACJ,cAAc;EACd,MAAM,OAAO,eAAe;AAC1B,oBAAiB,cAAc,OAAO;GACtC,MAAM,MAAM,MAAM,IAAI,OAAO;IAC3B,GAAG;IACH,KAAK,EAAE,GAAG,cAAc,KAAK;IAC7B,SAAS,WAAW,WAAW,cAAc;IAC9C,CAAC;GACF,MAAM,YAAY,IAAI;GACtB,MAAM,gBAAgB,SACpB,kBAAkB,MAAM,cAAc,KAAK,UAAU;GACvD,MAAM,iBAAiB,SACrB,kBAAkB,MAAM,WAAW,cAAc,IAAI;AAEvD,UAAO;IACL,IAAI,IAAI;IACR;IACA,cAAc;IACd,OAAO;KACL,MAAM,MAAM,MAAM,OAAO;MACvB,MAAM,UAAU,OAAO,KAAK,MAAM,aAAa,MAAM,CAAC,CAAC,SAAS,SAAS;AACzE,YAAM,IAAI,MAAM,MAAM;OACpB,MAAM,aAAa,KAAK;OACxB;OACA,UAAU;OACX,CAAC;;KAEJ,MAAM,KAAK,MAAM;MACf,MAAM,UAAU,MAAM,IAAI,MAAM,KAAK,aAAa,KAAK,EAAE,EACvD,UAAU,UACX,CAAC;AACF,aAAO,IAAI,WAAW,OAAO,KAAK,SAAS,SAAS,CAAC;;KAEvD,MAAM,KAAK,MAAM;AACf,cAAQ,MAAM,IAAI,MAAM,KAAK,aAAa,KAAK,CAAC,EAAE,KAAK,WAAW;O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,GAAG,CAAE,QAAO,GAAG,KAAK,KAAK,MAAM,KAAK,OAAO;AACvE,QAAO;;AAGT,SAAS,WAAW,OAAuB;AACzC,QAAO,IAAI,MAAM,WAAW,KAAK,QAAQ,CAAC;;AAG5C,SAAS,iBAAiB,QAA4B;AACpD,KAAI,QAAQ,QAAS,OAAM,OAAO,UAAU,IAAI,aAAa,WAAW,aAAa;;AAGvF,SAAS,uBAAuB,UAAyB,QAAgB,WAAyB;AAChG,KAAI,aAAa,EAAG;AACpB,OAAM,IAAI,MAAM,GAAG,UAAU,SAAS,SAAS,KAAK,WAAW,KAAK;;AAGtE,SAAS,UAAU,OAAqB;AACtC,QAAO,IAAI,KAAK,QAAQ,eAAoB,QAAQ,MAAQ,MAAM;;AAGpE,SAAS,cAAc,QAAoE;AACzF,KAAI,OAAO,SAAS,eAAe,OAAO,SAAS,WAAY,QAAO,EAAE,MAAM,OAAO,MAAM;AAC3F,KAAI,OAAO,SAAS,SAAU,QAAO,OAAO;AAC5C,QAAO;EACL,MAAM;EACN,gBAAgB,CAAC,GAAI,OAAO,gBAAgB,EAAE,CAAE;EAChD,cAAc,CAAC,GAAI,OAAO,gBAAgB,EAAE,CAAE;EAC9C,aAAa,CAAC,GAAI,OAAO,eAAe,EAAE,CAAE;EAC7C"}
@@ -0,0 +1,27 @@
1
+ import "../../types-BTagTtsp.mjs";
2
+ import { o as SandboxProvider } from "../../provider-_caCV8kk.mjs";
3
+ import "../../index-BMFkO6Fv.mjs";
4
+ import "../../sandbox-BUYT-1C9.mjs";
5
+ import { o as vercelCapabilities } from "../../capabilities-CMnszzpt.mjs";
6
+ import { Sandbox as VercelSandbox } from "@vercel/sandbox";
7
+
8
+ //#region src/providers/vercel/index.d.ts
9
+ interface VercelBaseOptions {
10
+ runtime?: "node24" | "node22" | "node26" | "python3.13" | (string & {});
11
+ name?: string;
12
+ ports?: number[];
13
+ persistent?: boolean;
14
+ }
15
+ type VercelOptions = VercelBaseOptions & ({
16
+ token: string;
17
+ teamId: string;
18
+ projectId: string;
19
+ } | {
20
+ token?: never;
21
+ teamId?: never;
22
+ projectId?: never;
23
+ });
24
+ declare function vercel(options?: VercelOptions): SandboxProvider<VercelSandbox>;
25
+ //#endregion
26
+ export { VercelOptions, type VercelSandbox, vercel, vercelCapabilities };
27
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,185 @@
1
+ import { r as normalizeError, t as SandboxError } from "../../errors-Ch9PHKTd.mjs";
2
+ import "../../capabilities-COKpwoFH.mjs";
3
+ import "../../sandbox-BwyHcB_C.mjs";
4
+ import { o as vercelCapabilities } from "../../capabilities-CEowrzRM.mjs";
5
+ import { i as unsupported, n as portResult, o as withManagedSessions, r as toUint8Array } from "../../provider-utils-DilOYLBO.mjs";
6
+ import { Sandbox, Snapshot } from "@vercel/sandbox";
7
+
8
+ //#region src/providers/vercel/index.ts
9
+ function vercel(options = {}) {
10
+ return withManagedSessions({
11
+ id: "vercel",
12
+ capabilities: vercelCapabilities,
13
+ async create(createOptions) {
14
+ const credentials = options.token && options.teamId && options.projectId ? {
15
+ token: options.token,
16
+ teamId: options.teamId,
17
+ projectId: options.projectId
18
+ } : {};
19
+ const exposed = new Set(options.ports ?? []);
20
+ const raw = await Sandbox.create({
21
+ ...credentials,
22
+ runtime: options.runtime ?? "node24",
23
+ name: options.name,
24
+ ports: [...exposed],
25
+ persistent: options.persistent,
26
+ timeout: createOptions.timeout,
27
+ env: { ...createOptions.env },
28
+ signal: createOptions.signal
29
+ });
30
+ const snapshots = /* @__PURE__ */ new Map();
31
+ await raw.fs.mkdir(createOptions.cwd, { recursive: true });
32
+ return {
33
+ id: raw.name,
34
+ raw,
35
+ capabilities: vercelCapabilities,
36
+ files: {
37
+ async write(path, value) {
38
+ await raw.fs.writeFile(path, await toUint8Array(value));
39
+ },
40
+ async read(path) {
41
+ return new Uint8Array(await raw.fs.readFile(path));
42
+ },
43
+ async list(path) {
44
+ const entries = await raw.fs.readdir(path, { withFileTypes: true });
45
+ return Promise.all(entries.map(async (entry) => {
46
+ const entryPath = `${path.replace(/\/$/, "")}/${entry.name}`;
47
+ const info = await raw.fs.lstat(entryPath);
48
+ return {
49
+ name: entry.name,
50
+ path: entryPath,
51
+ type: entry.isFile() ? "file" : entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : "unknown",
52
+ size: entry.isFile() ? info.size : void 0
53
+ };
54
+ }));
55
+ },
56
+ async mkdir(path) {
57
+ await raw.fs.mkdir(path, { recursive: true });
58
+ },
59
+ async remove(path) {
60
+ await raw.fs.rm(path, {
61
+ recursive: true,
62
+ force: true
63
+ });
64
+ },
65
+ exists: (path) => raw.fs.exists(path)
66
+ },
67
+ async run(command, runOptions) {
68
+ try {
69
+ const result = await runCommand(raw, command, runOptions, false);
70
+ const [stdout, stderr] = await Promise.all([result.stdout({ signal: runOptions.signal }), result.stderr({ signal: runOptions.signal })]);
71
+ if (runOptions.timeout !== void 0 && result.exitCode === 137 && result.durationMs !== void 0 && result.durationMs >= runOptions.timeout) throw new SandboxError({
72
+ code: "timeout",
73
+ provider: "vercel",
74
+ operation: "process.run",
75
+ message: `Command timed out after ${runOptions.timeout}ms`
76
+ });
77
+ return {
78
+ stdout,
79
+ stderr,
80
+ exitCode: result.exitCode,
81
+ success: result.exitCode === 0,
82
+ durationMs: result.durationMs
83
+ };
84
+ } catch (error) {
85
+ throw normalizeError("vercel", "process.run", error);
86
+ }
87
+ },
88
+ async start(command, runOptions) {
89
+ const handle = await runCommand(raw, command, runOptions, true);
90
+ const events = [];
91
+ let running = true;
92
+ const stream = handle.logs({ signal: runOptions.signal });
93
+ const completed = handle.wait().then((result) => ({ exitCode: result.exitCode }));
94
+ return {
95
+ id: handle.cmdId,
96
+ async status() {
97
+ return running ? "running" : "exited";
98
+ },
99
+ async *output() {
100
+ try {
101
+ for await (const event of stream) {
102
+ const normalized = {
103
+ stream: event.stream,
104
+ data: event.data,
105
+ timestamp: /* @__PURE__ */ new Date()
106
+ };
107
+ events.push(normalized);
108
+ yield normalized;
109
+ }
110
+ } finally {
111
+ running = false;
112
+ }
113
+ },
114
+ async write() {
115
+ unsupported("vercel", "process.stdin");
116
+ },
117
+ wait: () => completed,
118
+ async kill(signal = "SIGTERM") {
119
+ await handle.kill(signal);
120
+ running = false;
121
+ }
122
+ };
123
+ },
124
+ async expose(port) {
125
+ if (!exposed.has(port)) {
126
+ exposed.add(port);
127
+ await raw.update({ ports: [...exposed] });
128
+ }
129
+ return portResult(port, raw.domain(port), true, false);
130
+ },
131
+ snapshots: {
132
+ async create() {
133
+ const snapshot = await raw.snapshot();
134
+ snapshots.set(snapshot.snapshotId, snapshot);
135
+ return {
136
+ id: snapshot.snapshotId,
137
+ mode: "filesystem",
138
+ createdAt: snapshot.createdAt
139
+ };
140
+ },
141
+ async delete(snapshot) {
142
+ const id = typeof snapshot === "string" ? snapshot : snapshot.id;
143
+ await (snapshots.get(id) ?? await Snapshot.get({
144
+ snapshotId: id,
145
+ ...credentials
146
+ })).delete();
147
+ snapshots.delete(id);
148
+ },
149
+ async restore() {
150
+ unsupported("vercel", "snapshot.restore");
151
+ }
152
+ },
153
+ async stop() {
154
+ if (raw.status !== "stopped") await raw.stop();
155
+ }
156
+ };
157
+ }
158
+ }, options.ports, {
159
+ stop: async (sandbox) => {
160
+ await sandbox.raw.stop();
161
+ },
162
+ destroy: (sandbox) => sandbox.raw.delete(),
163
+ setPorts: (sandbox, ports, signal) => sandbox.raw.update({ ports: [...ports] }, { signal }),
164
+ setNetworkPolicy: (sandbox, policy) => sandbox.raw.update({ networkPolicy: policy.mode === "allow-all" || policy.mode === "deny-all" ? policy.mode : policy.mode === "native" ? policy.value : { allow: [...policy.allowedHosts ?? []] } })
165
+ });
166
+ }
167
+ async function runCommand(raw, input, options, detached) {
168
+ const command = typeof input === "string" ? {
169
+ command: "/bin/sh",
170
+ args: ["-lc", input]
171
+ } : input;
172
+ return raw.runCommand({
173
+ cmd: command.command,
174
+ args: [...command.args ?? []],
175
+ cwd: options.cwd,
176
+ env: { ...options.env },
177
+ signal: options.signal,
178
+ timeoutMs: options.timeout,
179
+ detached
180
+ });
181
+ }
182
+
183
+ //#endregion
184
+ export { vercel, vercelCapabilities };
185
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["VercelSandbox","events: ProcessOutputEvent[]","VercelSnapshot"],"sources":["../../../src/providers/vercel/index.ts"],"sourcesContent":["import { Sandbox as VercelSandbox, Snapshot as VercelSnapshot } from \"@vercel/sandbox\";\nimport { normalizeError, SandboxError } from \"../../core/errors\";\nimport type { SandboxProvider } from \"../../core/provider\";\nimport type {\n CommandInput,\n ProcessOutputEvent,\n SandboxProcess,\n SandboxSnapshot,\n} from \"../../core/types\";\nimport { portResult, toUint8Array, unsupported } from \"../../internal/provider-utils\";\nimport { vercelCapabilities } from \"../capabilities\";\nimport { withManagedSessions } from \"../../internal/managed-provider\";\n\ninterface VercelBaseOptions {\n runtime?: \"node24\" | \"node22\" | \"node26\" | \"python3.13\" | (string & {});\n name?: string;\n ports?: number[];\n persistent?: boolean;\n}\n\nexport type VercelOptions = VercelBaseOptions &\n (\n | { token: string; teamId: string; projectId: string }\n | { token?: never; teamId?: never; projectId?: never }\n );\n\nexport { vercelCapabilities } from \"../capabilities\";\n\nexport function vercel(options: VercelOptions = {}): SandboxProvider<VercelSandbox> {\n return withManagedSessions(\n {\n id: \"vercel\",\n capabilities: vercelCapabilities,\n async create(createOptions) {\n const credentials =\n options.token && options.teamId && options.projectId\n ? {\n token: options.token,\n teamId: options.teamId,\n projectId: options.projectId,\n }\n : {};\n const exposed = new Set(options.ports ?? []);\n const raw = await VercelSandbox.create({\n ...credentials,\n runtime: options.runtime ?? \"node24\",\n name: options.name,\n ports: [...exposed],\n persistent: options.persistent,\n timeout: createOptions.timeout,\n env: { ...createOptions.env },\n signal: createOptions.signal,\n });\n const snapshots = new Map<string, VercelSnapshot>();\n await raw.fs.mkdir(createOptions.cwd, { recursive: true });\n return {\n id: raw.name,\n raw,\n capabilities: vercelCapabilities,\n files: {\n async write(path, value) {\n await raw.fs.writeFile(path, await toUint8Array(value));\n },\n async read(path) {\n return new Uint8Array(await raw.fs.readFile(path));\n },\n async list(path) {\n const entries = await raw.fs.readdir(path, {\n withFileTypes: true,\n });\n return Promise.all(\n entries.map(async (entry) => {\n const entryPath = `${path.replace(/\\/$/, \"\")}/${entry.name}`;\n const info = await raw.fs.lstat(entryPath);\n return {\n name: entry.name,\n path: entryPath,\n type: entry.isFile()\n ? (\"file\" as const)\n : entry.isDirectory()\n ? (\"directory\" as const)\n : entry.isSymbolicLink()\n ? (\"symlink\" as const)\n : (\"unknown\" as const),\n size: entry.isFile() ? info.size : undefined,\n };\n }),\n );\n },\n async mkdir(path) {\n await raw.fs.mkdir(path, { recursive: true });\n },\n async remove(path) {\n await raw.fs.rm(path, { recursive: true, force: true });\n },\n exists: (path) => raw.fs.exists(path),\n },\n async run(command, runOptions) {\n try {\n const result = await runCommand(raw, command, runOptions, false);\n const [stdout, stderr] = await Promise.all([\n result.stdout({ signal: runOptions.signal }),\n result.stderr({ signal: runOptions.signal }),\n ]);\n if (\n runOptions.timeout !== undefined &&\n result.exitCode === 137 &&\n result.durationMs !== undefined &&\n result.durationMs >= runOptions.timeout\n ) {\n throw new SandboxError({\n code: \"timeout\",\n provider: \"vercel\",\n operation: \"process.run\",\n message: `Command timed out after ${runOptions.timeout}ms`,\n });\n }\n return {\n stdout,\n stderr,\n exitCode: result.exitCode,\n success: result.exitCode === 0,\n durationMs: result.durationMs,\n };\n } catch (error) {\n throw normalizeError(\"vercel\", \"process.run\", error);\n }\n },\n async start(command, runOptions) {\n const handle = await runCommand(raw, command, runOptions, true);\n const events: ProcessOutputEvent[] = [];\n let running = true;\n const stream = handle.logs({ signal: runOptions.signal });\n const completed = handle.wait().then((result) => ({ exitCode: result.exitCode }));\n const process: SandboxProcess = {\n id: handle.cmdId,\n async status() {\n return running ? \"running\" : \"exited\";\n },\n async *output() {\n try {\n for await (const event of stream) {\n const normalized = {\n stream: event.stream,\n data: event.data,\n timestamp: new Date(),\n } satisfies ProcessOutputEvent;\n events.push(normalized);\n yield normalized;\n }\n } finally {\n running = false;\n }\n },\n async write() {\n unsupported(\"vercel\", \"process.stdin\");\n },\n wait: () => completed,\n async kill(signal = \"SIGTERM\") {\n await handle.kill(signal as Parameters<typeof handle.kill>[0]);\n running = false;\n },\n };\n return process;\n },\n async expose(port) {\n if (!exposed.has(port)) {\n exposed.add(port);\n await raw.update({ ports: [...exposed] });\n }\n const url = raw.domain(port);\n return portResult(port, url, true, false);\n },\n snapshots: {\n async create() {\n const snapshot = await raw.snapshot();\n snapshots.set(snapshot.snapshotId, snapshot);\n return {\n id: snapshot.snapshotId,\n mode: \"filesystem\",\n createdAt: snapshot.createdAt,\n } satisfies SandboxSnapshot;\n },\n async delete(snapshot) {\n const id = typeof snapshot === \"string\" ? snapshot : snapshot.id;\n const native =\n snapshots.get(id) ?? (await VercelSnapshot.get({ snapshotId: id, ...credentials }));\n await native.delete();\n snapshots.delete(id);\n },\n async restore() {\n unsupported(\"vercel\", \"snapshot.restore\");\n },\n },\n async stop() {\n if (raw.status !== \"stopped\") await raw.stop();\n },\n };\n },\n },\n options.ports,\n {\n stop: async (sandbox) => {\n await sandbox.raw.stop();\n },\n destroy: (sandbox) => sandbox.raw.delete(),\n setPorts: (sandbox, ports, signal) => sandbox.raw.update({ ports: [...ports] }, { signal }),\n setNetworkPolicy: (sandbox, policy) =>\n sandbox.raw.update({\n networkPolicy:\n policy.mode === \"allow-all\" || policy.mode === \"deny-all\"\n ? policy.mode\n : policy.mode === \"native\"\n ? (policy.value as import(\"@vercel/sandbox\").NetworkPolicy)\n : { allow: [...(policy.allowedHosts ?? [])] },\n }),\n },\n );\n}\n\nasync function runCommand(\n raw: VercelSandbox,\n input: CommandInput,\n options: import(\"../../core/types\").RunOptions,\n detached: false,\n): Promise<import(\"@vercel/sandbox\").CommandFinished>;\nasync function runCommand(\n raw: VercelSandbox,\n input: CommandInput,\n options: import(\"../../core/types\").RunOptions,\n detached: true,\n): Promise<import(\"@vercel/sandbox\").Command>;\nasync function runCommand(\n raw: VercelSandbox,\n input: CommandInput,\n options: import(\"../../core/types\").RunOptions,\n detached: boolean,\n) {\n const command = typeof input === \"string\" ? { command: \"/bin/sh\", args: [\"-lc\", input] } : input;\n return raw.runCommand({\n cmd: command.command,\n args: [...(command.args ?? [])],\n cwd: options.cwd,\n env: { ...options.env },\n signal: options.signal,\n timeoutMs: options.timeout,\n detached,\n });\n}\n\nexport type { VercelSandbox };\n"],"mappings":";;;;;;;;AA4BA,SAAgB,OAAO,UAAyB,EAAE,EAAkC;AAClF,QAAO,oBACL;EACE,IAAI;EACJ,cAAc;EACd,MAAM,OAAO,eAAe;GAC1B,MAAM,cACJ,QAAQ,SAAS,QAAQ,UAAU,QAAQ,YACvC;IACE,OAAO,QAAQ;IACf,QAAQ,QAAQ;IAChB,WAAW,QAAQ;IACpB,GACD,EAAE;GACR,MAAM,UAAU,IAAI,IAAI,QAAQ,SAAS,EAAE,CAAC;GAC5C,MAAM,MAAM,MAAMA,QAAc,OAAO;IACrC,GAAG;IACH,SAAS,QAAQ,WAAW;IAC5B,MAAM,QAAQ;IACd,OAAO,CAAC,GAAG,QAAQ;IACnB,YAAY,QAAQ;IACpB,SAAS,cAAc;IACvB,KAAK,EAAE,GAAG,cAAc,KAAK;IAC7B,QAAQ,cAAc;IACvB,CAAC;GACF,MAAM,4BAAY,IAAI,KAA6B;AACnD,SAAM,IAAI,GAAG,MAAM,cAAc,KAAK,EAAE,WAAW,MAAM,CAAC;AAC1D,UAAO;IACL,IAAI,IAAI;IACR;IACA,cAAc;IACd,OAAO;KACL,MAAM,MAAM,MAAM,OAAO;AACvB,YAAM,IAAI,GAAG,UAAU,MAAM,MAAM,aAAa,MAAM,CAAC;;KAEzD,MAAM,KAAK,MAAM;AACf,aAAO,IAAI,WAAW,MAAM,IAAI,GAAG,SAAS,KAAK,CAAC;;KAEpD,MAAM,KAAK,MAAM;MACf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AI,GAAG;OAAa,CAAC,EACvE,QAAQ;AACrB,gBAAU,OAAO,GAAG;;KAEtB,MAAM,UAAU;AACd,kBAAY,UAAU,mBAAmB;;KAE5C;IACD,MAAM,OAAO;AACX,SAAI,IAAI,WAAW,UAAW,OAAM,IAAI,MAAM;;IAEjD;;EAEJ,EACD,QAAQ,OACR;EACE,MAAM,OAAO,YAAY;AACvB,SAAM,QAAQ,IAAI,MAAM;;EAE1B,UAAU,YAAY,QAAQ,IAAI,QAAQ;EAC1C,WAAW,SAAS,OAAO,WAAW,QAAQ,IAAI,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC;EAC3F,mBAAmB,SAAS,WAC1B,QAAQ,IAAI,OAAO,EACjB,eACE,OAAO,SAAS,eAAe,OAAO,SAAS,aAC3C,OAAO,OACP,OAAO,SAAS,WACb,OAAO,QACR,EAAE,OAAO,CAAC,GAAI,OAAO,gBAAgB,EAAE,CAAE,EAAE,EACpD,CAAC;EACL,CACF;;AAeH,eAAe,WACb,KACA,OACA,SACA,UACA;CACA,MAAM,UAAU,OAAO,UAAU,WAAW;EAAE,SAAS;EAAW,MAAM,CAAC,OAAO,MAAM;EAAE,GAAG;AAC3F,QAAO,IAAI,WAAW;EACpB,KAAK,QAAQ;EACb,MAAM,CAAC,GAAI,QAAQ,QAAQ,EAAE,CAAE;EAC/B,KAAK,QAAQ;EACb,KAAK,EAAE,GAAG,QAAQ,KAAK;EACvB,QAAQ,QAAQ;EAChB,WAAW,QAAQ;EACnB;EACD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { f as Sandbox } from "./types-BTagTtsp.mjs";
2
+ import { o as SandboxProvider } from "./provider-_caCV8kk.mjs";
3
+
4
+ //#region src/core/sandbox.d.ts
5
+ interface CreateSandboxOptions<TProvider extends SandboxProvider<unknown>> {
6
+ provider: TProvider;
7
+ cwd?: string;
8
+ env?: Readonly<Record<string, string>>;
9
+ timeout?: number;
10
+ signal?: AbortSignal;
11
+ }
12
+ type RawOf<TProvider> = TProvider extends SandboxProvider<infer TRaw> ? TRaw : never;
13
+ declare function createSandbox<TProvider extends SandboxProvider<unknown>>(options: CreateSandboxOptions<TProvider>): Promise<Sandbox<RawOf<TProvider>>>;
14
+ declare function withSandbox<TProvider extends SandboxProvider<unknown>, TResult>(options: CreateSandboxOptions<TProvider>, callback: (sandbox: Sandbox<RawOf<TProvider>>) => TResult | Promise<TResult>): Promise<TResult>;
15
+ //#endregion
16
+ export { createSandbox as n, withSandbox as r, CreateSandboxOptions as t };
17
+ //# sourceMappingURL=sandbox-BUYT-1C9.d.mts.map
@@ -0,0 +1,102 @@
1
+ import { r as normalizeError, t as SandboxError } from "./errors-Ch9PHKTd.mjs";
2
+
3
+ //#region src/core/sandbox.ts
4
+ function validateCwd(cwd) {
5
+ if (!cwd.startsWith("/") || cwd.includes("\0")) throw new SandboxError({
6
+ code: "invalid_input",
7
+ provider: "core",
8
+ operation: "create",
9
+ message: "cwd must be an absolute path"
10
+ });
11
+ return cwd.replace(/\/$/, "") || "/";
12
+ }
13
+ function validatePath(cwd, value) {
14
+ if (!value || value.includes("\0") || value.split("/").includes("..")) throw new SandboxError({
15
+ code: "invalid_input",
16
+ provider: "core",
17
+ operation: "path",
18
+ message: `Invalid sandbox path: ${value}`
19
+ });
20
+ if (value.startsWith("/")) return value.replace(/\/{2,}/g, "/");
21
+ return `${cwd}/${value}`.replace(/\/{2,}/g, "/");
22
+ }
23
+ async function createSandbox(options) {
24
+ const cwd = validateCwd(options.cwd ?? "/workspace");
25
+ const env = options.env ?? {};
26
+ let runtime;
27
+ try {
28
+ runtime = await options.provider.create({
29
+ cwd,
30
+ env,
31
+ timeout: options.timeout,
32
+ signal: options.signal
33
+ });
34
+ } catch (error) {
35
+ throw normalizeError(options.provider.id, "sandbox.create", error);
36
+ }
37
+ let stopPromise;
38
+ const stop = async () => {
39
+ stopPromise ??= call("sandbox.stop", () => runtime.stop());
40
+ return stopPromise;
41
+ };
42
+ const call = async (operation, fn) => {
43
+ try {
44
+ return await fn();
45
+ } catch (error) {
46
+ throw normalizeError(options.provider.id, operation, error);
47
+ }
48
+ };
49
+ return {
50
+ id: runtime.id,
51
+ provider: options.provider.id,
52
+ cwd,
53
+ capabilities: runtime.capabilities,
54
+ raw: runtime.raw,
55
+ files: {
56
+ write: async (path, value) => call("files.write", () => runtime.files.write(validatePath(cwd, path), value)),
57
+ read: async (path) => call("files.read", () => runtime.files.read(validatePath(cwd, path))),
58
+ text: async (path) => new TextDecoder().decode(await call("files.read", () => runtime.files.read(validatePath(cwd, path)))),
59
+ list: async (path = ".") => call("files.list", () => runtime.files.list(path === "." ? cwd : validatePath(cwd, path))),
60
+ mkdir: async (path) => call("files.mkdir", () => runtime.files.mkdir(validatePath(cwd, path))),
61
+ remove: async (path) => call("files.remove", () => runtime.files.remove(validatePath(cwd, path))),
62
+ exists: async (path) => call("files.exists", () => runtime.files.exists(validatePath(cwd, path)))
63
+ },
64
+ processes: { start: (command, runOptions = {}) => call("process.start", () => runtime.start(command, normalizeRunOptions(cwd, runOptions))) },
65
+ ports: { expose: (port) => call("ports.expose", () => runtime.expose(port)) },
66
+ snapshots: {
67
+ create: (snapshotOptions) => call("snapshot.create", () => runtime.snapshots.create(snapshotOptions)),
68
+ delete: (snapshot) => call("snapshot.delete", () => runtime.snapshots.delete(snapshot)),
69
+ restore: (snapshot) => call("snapshot.restore", () => runtime.snapshots.restore(snapshot))
70
+ },
71
+ run: (command, runOptions = {}) => call("process.run", () => runtime.run(command, normalizeRunOptions(cwd, runOptions))),
72
+ stop
73
+ };
74
+ }
75
+ function normalizeRunOptions(cwd, options) {
76
+ return {
77
+ ...options,
78
+ cwd: options.cwd ? validatePath(cwd, options.cwd) : cwd
79
+ };
80
+ }
81
+ async function withSandbox(options, callback) {
82
+ const sandbox = await createSandbox(options);
83
+ try {
84
+ const result = await callback(sandbox);
85
+ await sandbox.stop();
86
+ return result;
87
+ } catch (error) {
88
+ try {
89
+ await sandbox.stop();
90
+ } catch (cleanupError) {
91
+ if (error instanceof Error) Object.defineProperty(error, "cleanupError", {
92
+ value: cleanupError,
93
+ enumerable: false
94
+ });
95
+ }
96
+ throw error;
97
+ }
98
+ }
99
+
100
+ //#endregion
101
+ export { withSandbox as n, createSandbox as t };
102
+ //# sourceMappingURL=sandbox-BwyHcB_C.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-BwyHcB_C.mjs","names":["stopPromise: Promise<void> | undefined"],"sources":["../src/core/sandbox.ts"],"sourcesContent":["import { normalizeError, SandboxError } from \"./errors\";\nimport type { SandboxProvider } from \"./provider\";\nimport type { FileValue, RunOptions, Sandbox } from \"./types\";\n\nexport interface CreateSandboxOptions<TProvider extends SandboxProvider<unknown>> {\n provider: TProvider;\n cwd?: string;\n env?: Readonly<Record<string, string>>;\n timeout?: number;\n signal?: AbortSignal;\n}\n\ntype RawOf<TProvider> = TProvider extends SandboxProvider<infer TRaw> ? TRaw : never;\n\nfunction validateCwd(cwd: string): string {\n if (!cwd.startsWith(\"/\") || cwd.includes(\"\\0\")) {\n throw new SandboxError({\n code: \"invalid_input\",\n provider: \"core\",\n operation: \"create\",\n message: \"cwd must be an absolute path\",\n });\n }\n return cwd.replace(/\\/$/, \"\") || \"/\";\n}\n\nfunction validatePath(cwd: string, value: string): string {\n if (!value || value.includes(\"\\0\") || value.split(\"/\").includes(\"..\")) {\n throw new SandboxError({\n code: \"invalid_input\",\n provider: \"core\",\n operation: \"path\",\n message: `Invalid sandbox path: ${value}`,\n });\n }\n if (value.startsWith(\"/\")) return value.replace(/\\/{2,}/g, \"/\");\n return `${cwd}/${value}`.replace(/\\/{2,}/g, \"/\");\n}\n\nexport async function createSandbox<TProvider extends SandboxProvider<unknown>>(\n options: CreateSandboxOptions<TProvider>,\n): Promise<Sandbox<RawOf<TProvider>>> {\n const cwd = validateCwd(options.cwd ?? \"/workspace\");\n const env = options.env ?? {};\n let runtime;\n try {\n runtime = await options.provider.create({\n cwd,\n env,\n timeout: options.timeout,\n signal: options.signal,\n });\n } catch (error) {\n throw normalizeError(options.provider.id, \"sandbox.create\", error);\n }\n let stopPromise: Promise<void> | undefined;\n const stop = async () => {\n stopPromise ??= call(\"sandbox.stop\", () => runtime.stop());\n return stopPromise;\n };\n const call = async <T>(operation: string, fn: () => Promise<T>): Promise<T> => {\n try {\n return await fn();\n } catch (error) {\n throw normalizeError(options.provider.id, operation, error);\n }\n };\n return {\n id: runtime.id,\n provider: options.provider.id,\n cwd,\n capabilities: runtime.capabilities,\n raw: runtime.raw as RawOf<TProvider>,\n files: {\n write: async (path: string, value: FileValue) =>\n call(\"files.write\", () => runtime.files.write(validatePath(cwd, path), value)),\n read: async (path: string) =>\n call(\"files.read\", () => runtime.files.read(validatePath(cwd, path))),\n text: async (path: string) =>\n new TextDecoder().decode(\n await call(\"files.read\", () => runtime.files.read(validatePath(cwd, path))),\n ),\n list: async (path = \".\") =>\n call(\"files.list\", () => runtime.files.list(path === \".\" ? cwd : validatePath(cwd, path))),\n mkdir: async (path: string) =>\n call(\"files.mkdir\", () => runtime.files.mkdir(validatePath(cwd, path))),\n remove: async (path: string) =>\n call(\"files.remove\", () => runtime.files.remove(validatePath(cwd, path))),\n exists: async (path: string) =>\n call(\"files.exists\", () => runtime.files.exists(validatePath(cwd, path))),\n },\n processes: {\n start: (command, runOptions = {}) =>\n call(\"process.start\", () => runtime.start(command, normalizeRunOptions(cwd, runOptions))),\n },\n ports: { expose: (port) => call(\"ports.expose\", () => runtime.expose(port)) },\n snapshots: {\n create: (snapshotOptions) =>\n call(\"snapshot.create\", () => runtime.snapshots.create(snapshotOptions)),\n delete: (snapshot) => call(\"snapshot.delete\", () => runtime.snapshots.delete(snapshot)),\n restore: (snapshot) => call(\"snapshot.restore\", () => runtime.snapshots.restore(snapshot)),\n },\n run: (command, runOptions = {}) =>\n call(\"process.run\", () => runtime.run(command, normalizeRunOptions(cwd, runOptions))),\n stop,\n };\n}\n\nfunction normalizeRunOptions(cwd: string, options: RunOptions): RunOptions {\n return { ...options, cwd: options.cwd ? validatePath(cwd, options.cwd) : cwd };\n}\n\nexport async function withSandbox<TProvider extends SandboxProvider<unknown>, TResult>(\n options: CreateSandboxOptions<TProvider>,\n callback: (sandbox: Sandbox<RawOf<TProvider>>) => TResult | Promise<TResult>,\n): Promise<TResult> {\n const sandbox = await createSandbox(options);\n try {\n const result = await callback(sandbox);\n await sandbox.stop();\n return result;\n } catch (error) {\n try {\n await sandbox.stop();\n } catch (cleanupError) {\n if (error instanceof Error) {\n Object.defineProperty(error, \"cleanupError\", { value: cleanupError, enumerable: false });\n }\n }\n throw error;\n }\n}\n"],"mappings":";;;AAcA,SAAS,YAAY,KAAqB;AACxC,KAAI,CAAC,IAAI,WAAW,IAAI,IAAI,IAAI,SAAS,KAAK,CAC5C,OAAM,IAAI,aAAa;EACrB,MAAM;EACN,UAAU;EACV,WAAW;EACX,SAAS;EACV,CAAC;AAEJ,QAAO,IAAI,QAAQ,OAAO,GAAG,IAAI;;AAGnC,SAAS,aAAa,KAAa,OAAuB;AACxD,KAAI,CAAC,SAAS,MAAM,SAAS,KAAK,IAAI,MAAM,MAAM,IAAI,CAAC,SAAS,KAAK,CACnE,OAAM,IAAI,aAAa;EACrB,MAAM;EACN,UAAU;EACV,WAAW;EACX,SAAS,yBAAyB;EACnC,CAAC;AAEJ,KAAI,MAAM,WAAW,IAAI,CAAE,QAAO,MAAM,QAAQ,WAAW,IAAI;AAC/D,QAAO,GAAG,IAAI,GAAG,QAAQ,QAAQ,WAAW,IAAI;;AAGlD,eAAsB,cACpB,SACoC;CACpC,MAAM,MAAM,YAAY,QAAQ,OAAO,aAAa;CACpD,MAAM,MAAM,QAAQ,OAAO,EAAE;CAC7B,IAAI;AACJ,KAAI;AACF,YAAU,MAAM,QAAQ,SAAS,OAAO;GACtC;GACA;GACA,SAAS,QAAQ;GACjB,QAAQ,QAAQ;GACjB,CAAC;UACK,OAAO;AACd,QAAM,eAAe,QAAQ,SAAS,IAAI,kBAAkB,MA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AAC,EAAE;EAC7E,WAAW;GACT,SAAS,oBACP,KAAK,yBAAyB,QAAQ,UAAU,OAAO,gBAAgB,CAAC;GAC1E,SAAS,aAAa,KAAK,yBAAyB,QAAQ,UAAU,OAAO,SAAS,CAAC;GACvF,UAAU,aAAa,KAAK,0BAA0B,QAAQ,UAAU,QAAQ,SAAS,CAAC;GAC3F;EACD,MAAM,SAAS,aAAa,EAAE,KAC5B,KAAK,qBAAqB,QAAQ,IAAI,SAAS,oBAAoB,KAAK,WAAW,CAAC,CAAC;EACvF;EACD;;AAGH,SAAS,oBAAoB,KAAa,SAAiC;AACzE,QAAO;EAAE,GAAG;EAAS,KAAK,QAAQ,MAAM,aAAa,KAAK,QAAQ,IAAI,GAAG;EAAK;;AAGhF,eAAsB,YACpB,SACA,UACkB;CAClB,MAAM,UAAU,MAAM,cAAc,QAAQ;AAC5C,KAAI;EACF,MAAM,SAAS,MAAM,SAAS,QAAQ;AACtC,QAAM,QAAQ,MAAM;AACpB,SAAO;UACA,OAAO;AACd,MAAI;AACF,SAAM,QAAQ,MAAM;WACb,cAAc;AACrB,OAAI,iBAAiB,MACnB,QAAO,eAAe,OAAO,gBAAgB;IAAE,OAAO;IAAc,YAAY;IAAO,CAAC;;AAG5F,QAAM"}
@@ -0,0 +1,27 @@
1
+ import "../types-BTagTtsp.mjs";
2
+ import { o as SandboxProvider } from "../provider-_caCV8kk.mjs";
3
+ import { t as CreateSandboxOptions } from "../sandbox-BUYT-1C9.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