Documentation

Filesystem

Read and write files inside the sandbox.

Write files

TypeScript
await sandbox.writeFile("input.txt", "hello");

Write many files

TypeScript
await sandbox.writeFiles([
  { path: "package.json", data: JSON.stringify({ type: "module" }) },
  { path: "index.mjs", data: "console.log('ready')\n" },
]);

Read files

TypeScript
const data = await sandbox.readFileToBuffer("input.txt");
if (data) {
  console.log(new TextDecoder().decode(data));
}

Manage paths

Directory operations return metadata for artifact trees and generated outputs.

TypeScript
await sandbox.mkDir("results");
await sandbox.writeFile("results/output.txt", "done\n");

const entries = await sandbox.fs.list("/workspace/results");
console.log(entries.map((entry) => entry.name));

const info = await sandbox.fs.stat("/workspace/results/output.txt");
console.log(info.type, info.size);

await sandbox.fs.rm("/workspace/results", { recursive: true });

Paths

Top-level helpers resolve relative paths from /workspace. The sandbox.fs namespace accepts absolute paths.