Bridges

files

files: { list, read, write, mkdir, move, remove }

A workspace the engine does not have to own. Six functions, the same shape as a computer's own files — and every file tool goes through them.

6 operationsall requiredsame shape as LocalFiles
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

The six

const bridge = {
  async list(dir, { recursive } = {}) { /* → [{ name, path, type, size, mimeType, modifiedAt }] */ },
  async read(path)                    { /* → { …item, content } — string or bytes */ },
  async write(path, content)          { /* → item */ },
  async mkdir(path)                   { /* → item */ },
  async move(from, to)                { /* → item */ },
  async remove(path)                  { /* → { ok: true } */ },
};
class Bridge:
    def list(self, dir="", *, recursive=False): ...   # → [{"name", "path", "type", "size"}]
    def read(self, path): ...                         # → {…item, "content"} — str or bytes
    def write(self, path, content): ...               # → item
    def mkdir(self, path): ...                        # → item
    def move(self, source, destination): ...          # → item
    def remove(self, path): ...                       # → {"ok": True}

It is deliberately LocalFiles's own shape: anything written against one works against the other, and an agent cannot tell which it has.

All six are required

A bridge missing one is refused at creation with files_required, naming what is absent. Half a file system would fail at the moment a tool needed the missing piece — which is the worst time to find out.

What the engine expects of them

ExpectationWhy
Paths are relative, with forward slashesEvery tool passes them through unchanged.
A path cannot leave the workspaceThe bridge is the boundary — enforce it.
read returns a string for text, bytes otherwiseThe engine decides what to attach from the type.
Entries starting with a dot are omitted from listVersions, the recycle bin and the session journal must stay out of the way.
Errors carry a codepath_not_found and not_a_folder are understood; anything else surfaces as the tool's failure.

Everything goes through it

read, write, edit, glob, grep, generated media, checkpoints and the session journal all use it. There is no second path to the files — which is what makes a phone's browser storage a complete workspace rather than a partial one.

A bridge can be remote

// Each operation is streamed to the page that holds the files,
// run there, and answered back.
const phoneBridge = () => Object.fromEntries(
  ["list", "read", "write", "mkdir", "move", "remove"].map((op) => [
    op,
    (...args) => askThePage({ op, args }),      // resolves when the page answers
  ]),
);
# Each operation is sent to whatever holds the files, run there, and answered back
class PhoneBridge:
    def __getattr__(self, op):
        if op not in ("list", "read", "write", "mkdir", "move", "remove"):
            raise AttributeError(op)
        return lambda *args, **kwargs: ask_the_page({"op": op, "args": args, "kwargs": kwargs})

Give it a timeout of your own: a page that stops answering would otherwise leave a run waiting indefinitely. Rejecting the promise ends the tool call with an error the model can act on.

It is called a lot

A single grep walks the tree. A checkpoint reads every file it records. A remote bridge should batch or cache where it can — the engine makes no attempt to be frugal, because on a disk it does not need to be.