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.
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
| Expectation | Why |
|---|---|
| Paths are relative, with forward slashes | Every tool passes them through unchanged. |
| A path cannot leave the workspace | The bridge is the boundary — enforce it. |
read returns a string for text, bytes otherwise | The engine decides what to attach from the type. |
Entries starting with a dot are omitted from list | Versions, the recycle bin and the session journal must stay out of the way. |
| Errors carry a code | path_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.