# files

Canonical URL: https://developers.iagenify.com/sdk/ref/connected-storage/files/
Language: en

`storage.files → LocalFiles`

A computer's own files, on that machine. Nothing is uploaded to be read, and nothing of it is kept on the account.

Status: a computer only · no bytes on the account · throws elsewhere

A computer is a storage whose data is its files, and they stay where they are. That is the whole idea: an agent working on a machine reads the disk it is on, rather than a copy of it.

```javascript
const pc = await api.storage.get({ id: machineId });

await pc.files.list();                       // what is in the workspace
await pc.files.write("notes/today.md", "…"); // write
await pc.files.read("notes/today.md");       // read back
await pc.files.mkdir("notes/archive");
await pc.files.move("notes/today.md", "notes/archive/today.md");
await pc.files.remove("notes/archive/today.md");
```

The full signatures are on [LocalFiles](/sdk/ref/local-files).

## Where these files are {#where}

In the workspace on that machine, under the SDK's own folder in the user's home directory. Paths you pass are relative to it, and a path cannot leave it.

> **They are not on the account, and they are not backed up**
>
> Nothing of this reaches the server — which is also why saving to a computer through api.files is refused. If the machine goes, so do they.

## It throws on anything else {#throws}

| storage.type | What you get |
| --- | --- |
| filesystem | A LocalFiles. |
| phone | storage_is_phone — its files are in that browser. |
| database · object · browser | storage_not_local — use run(). |

Two different refusals on purpose: one says « wrong kind of storage », the other says « right idea, wrong place to ask from ». A phone's files exist; they are reachable from the page that holds them.

```javascript
import { IaGenifyError } from "iagenify";

function filesOf(storage) {
  try {
    return storage.files;
  } catch (err) {
    if (err instanceof IaGenifyError && err.code === "storage_is_phone") {
      return null;   // reachable through the page, not from here
    }
    if (err instanceof IaGenifyError && err.code === "storage_not_local") {
      return null;   // its data is read through run()
    }
    throw err;
  }
}
```

## It is this machine's files, not any machine's {#which}

> **Reaching for another computer's files from here reads this one**
>
> The accessor works on the process you are in. Holding a ConnectedStorage for a machine does not give you a remote filesystem — check machineId against the machine you are actually on before acting.

## What an agent does with this {#agent}

An agent given a computer as its `machine` reads and writes through exactly this. Which is why its tools are permissioned per category rather than per file: the boundary is the workspace, and the decision is yours at each step.

- [LocalFiles](/sdk/ref/local-files): list · mkdir · write · read · move · remove.
- [The files bridge](/sdk/agent/bridges/files): Giving an agent files that are somewhere else — a phone, a browser.

```python
pc = api.storage.get(id=machine_id)

pc.files.list()                        # what is in the workspace
pc.files.write("notes/today.md", "…")  # write
pc.files.read("notes/today.md")        # read back
pc.files.mkdir("notes/archive")
pc.files.move("notes/today.md", "notes/archive/today.md")
pc.files.remove("notes/archive/today.md")
```

```python
def files_of(storage):
    # None on a phone (reachable through the page, not from here)
    # and on any storage that is not a computer (its data is read through run()).
    return storage.files
```
