Write a File

Write a file into a sandbox directly from your client, handy for seeding inputs before an agent runs, or dropping in config the agent will read. The path is the agent-visible absolute path (e.g. /workspace/data.csv) and must resolve beneath one of the sandbox's configured mounts.

Write a file

Returns { path, bytes }, where the file landed and how many bytes were written.

index.ts
const { path, bytes } = await sandbox.writeFile(
  "/workspace/data.csv",
  "name,score\nada,99\n", // string | Uint8Array | ArrayBuffer | Blob
);
console.log(`wrote ${bytes} bytes to ${path}`);

Upload binary content the same way, read it from disk and pass the bytes:

index.ts
import { readFile } from "node:fs/promises";

const buf = await readFile("./logo.png");
await sandbox.writeFile("/workspace/logo.png", buf);
i
Like the other file methods, writeFile runs as the operator and bypasses the per-mount ACLs. It writes through the mount's backend, so uploading to a GCS or Drive mount persists the object to that store.

To remove a file, see Delete a File.


Next: List a Directory