the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1import consola from "consola";
2import { Sandbox } from "@pocketenv/sdk";
3import { configureSdk } from "../lib/sdk";
4
5export async function exec(sandboxName: string, command: string[]) {
6 await configureSdk();
7
8 try {
9 const sandbox = await Sandbox.get(sandboxName);
10 const [cmd, ...args] = command;
11 const result = await sandbox.exec(`${cmd} ${args.join(" ")}`);
12
13 if (result.stdout) {
14 process.stdout.write(
15 result.stdout.endsWith("\n") ? result.stdout : result.stdout + "\n",
16 );
17 }
18 if (result.stderr) {
19 process.stderr.write(
20 result.stderr.endsWith("\n") ? result.stderr : result.stderr + "\n",
21 );
22 }
23
24 if (result.exitCode !== 0) {
25 consola.error(`Command exited with code ${result.exitCode}`);
26 }
27
28 process.exit(result.exitCode);
29 } catch (error) {
30 consola.error("Failed to execute command:", error);
31 }
32}