List a Directory

List the immediate children of a directory inside a sandbox, the way to discover what's there before you read or delete. The path is the agent-visible absolute path (e.g. /workspace) and must resolve beneath one of the sandbox's configured mounts.

List the children of a directory

Returns one entry per child. Each entry has:

FieldDescription
nameThe entry's base name.
pathIts agent-visible absolute path.
is_dirtrue for a directory, false for a file.
sizeSize in bytes.
index.ts
const entries = await sandbox.listDirectory("/workspace");
for (const e of entries) {
  console.log(e.is_dir ? "dir " : "file", e.size, e.path);
}

Listing returns only the immediate children, it does not recurse. To walk a tree, list a subdirectory whenever an entry's is_dir is true. For example, download every file directly under a directory:

index.ts
for (const e of await sandbox.listDirectory("/workspace/output")) {
  if (!e.is_dir) {
    const bytes = await sandbox.readFile(e.path);
    console.log(e.name, bytes.length);
  }
}
i
Like the other file methods, this runs as the operator and bypasses the per-mount ACLs that govern the agent.

Next: Delete a File