# files

Canonical URL: https://developers.iagenify.com/sdk/agent/bridges/files/
Language: en

`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.

Status: 6 operations · all required · same shape as LocalFiles

## The six {#shape}

```javascript
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 } */ },
};
```

It is deliberately [LocalFiles](/sdk/ref/local-files)'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 {#contract}

| 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 {#everything}

`read`, `write`, `edit`, `glob`, `grep`, generated media, [checkpoints](/sdk/agent/checkpoints) and the [session journal](/sdk/agent/sessions/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 {#remote}

```javascript
// 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
  ]),
);
```

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 {#performance}

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.

- [LocalFiles](/sdk/ref/local-files): The shape to copy.
- [Phone](/sdk/ref/providers/phone): The case this was built for.

```python
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}
```

```python
# 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})
```
