Skip to content

Filesystem

Each sandbox has a workspace (rooted at /home/sandbox). Read, write, list, and watch files through the SDK.

Read / write / list

python
sbx.files.write("main.py", "print('hello')")
print(sbx.files.read("main.py"))

for entry in sbx.files.list("."):
    print(entry["type"], entry["name"], entry["size"])
javascript
await sbx.files.write("main.py", "print('hello')");
console.log(await sbx.files.read("main.py"));

for (const e of await sbx.files.list(".")) {
  console.log(e.type, e.name, e.size);
}

Paths are resolved inside the workspace; traversal outside it is rejected.

Watch for changes

watch reports create / modify / remove events for a subtree. It's poll-based — the JavaScript SDK polls on a timer and invokes your callback; the Python SDK gives you a Watcher you poll yourself.

python
watcher = sbx.files.watch(".", recursive=True)

# later — returns events since the last poll
for event in watcher.poll():
    print(event["type"], event["path"])   # e.g. "create app.log"

watcher.stop()
javascript
const watcher = await sbx.files.watch(".", (event) => {
  console.log(event.type, event.path); // "create app.log"
});

// ... when done
await watcher.stop();

Use watch to react to files an agent's code produces — a build output, a generated report, a log.

Sovereign compute for Indian AI — hosted in Mumbai (ap-south-1).