# Overview

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

`storage.files → LocalFiles`

The files of a computer storage, read and written where they are. Six methods, no network call, no credit — this is a filesystem, reached through the same object as every other storage.

Status: Node only · no network · free

You never construct one. It is what `storage.files` hands back on a storage whose `type` is `filesystem`, and reaching for it on anything else throws rather than returning an empty list — see [files](/sdk/ref/connected-storage/files).

## The six methods {#surface}

| Call | Does | Gives back |
| --- | --- | --- |
| list(dir, options) | Reads a folder. | An array of items. |
| mkdir(dir) | Creates a folder, parents included. | The folder item. |
| write(file, content) | Writes a file, parents included. | The file item. |
| read(file) | Reads a file. | The item, plus `content`. |
| move(from, to) | Moves or renames. | The item at its new path. |
| remove(target) | Deletes a file, or a folder and its contents. | `{ ok: true }`. |

## End to end {#walk}

```javascript
const pc = await api.storage.get();        // the computer this process is on

await pc.files.mkdir("Launch plan");
await pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.");

const brief = await pc.files.read("Launch plan/brief.md");
console.log(brief.content);                 // a string: it is text

for (const item of await pc.files.list("Launch plan")) {
  console.log(item.type, item.path, item.size);
}
```

## The workspace {#workspace}

Everything happens under one folder in the user's home directory: `~/.iagenify/files`. It is created on first use, readable by its owner only, and shared by every application on that machine that uses the package — so a file written by your script is the file an agent reads.

> **Paths are relative to the workspace, always**
>
> There is no current directory to change and no way to name a folder above it. A path is a position inside the workspace, which is what makes a path safe to accept from a model or from a form.

## What a path may be {#paths}

| Written | Result |
| --- | --- |
| `notes.md` | The file at the top of the workspace. |
| `Launch plan/brief.md` | Nested. Forward slashes on every system. |
| `Launch\\plan/brief.md` | Backslashes are normalised to forward slashes. |
| `""` (empty) | The workspace itself. Accepted by `list` only. |
| `/etc/passwd` · `C:/Windows` | Refused: `invalid_path`. |
| `../../secrets` | Refused: `invalid_path`, after resolution. |

The check is made on the **resolved** path, not on the text: a path that climbs out and comes back is fine, and one that merely looks harmless but lands outside is refused.

## The shape every method returns {#item}

```javascript
// A file
{
  name: "brief.md",
  path: "Launch plan/brief.md",      // relative to the workspace, forward slashes
  type: "file",
  size: 1284,                         // bytes
  mimeType: "text/markdown",          // from the extension
  modifiedAt: "2026-10-07T09:12:44.000Z"
}

// A folder — size and mimeType are null
{ name: "Launch plan", path: "Launch plan", type: "folder", size: null, mimeType: null, modifiedAt: "…" }
```

## Hidden entries are left out {#hidden}

Anything whose name starts with a dot is omitted from `list()`. That is what keeps the two folders an agent writes behind the scenes — the kept versions under `.versions/` and the recycle bin under `.trash/` — out of a listing, while leaving them readable by name if you want them.

```javascript
// Not in list(), but readable
const previous = await pc.files.list(".versions/notes.md");
const bin = await pc.files.list(".trash");
```

## It needs a disk, and the right disk {#runtime}

Two guards run before any method touches the filesystem, and both throw rather than degrade.

- `local_files_require_node` — the runtime has no filesystem. A browser and a worker reach their own storage a different way.
- `storage_not_on_this_machine` — the storage you are holding belongs to another computer, and its files are on that one.

> **Holding the object is not having the machine**
>
> api.storage.list() hands back every computer on the account, including ones you are not sitting at. The second guard is what turns that into a clear refusal instead of a read of the wrong disk.

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

const computers = (await api.storage.list()).filter((s) => s.type === "filesystem");

for (const computer of computers) {
  try {
    await computer.files.list();
  } catch (err) {
    if (err instanceof IaGenifyError && err.code === "storage_not_on_this_machine") {
      console.log(`${computer.label} is elsewhere — skipping.`);
      continue;
    }
    throw err;
  }
}
```

## Nothing leaves the machine {#nothing-leaves}

No method here makes a request. Nothing is uploaded to be read, nothing is indexed, and no credit is spent. The account knows that this computer is registered as a storage; it does not know what is in it.

- [list()](/sdk/ref/local-files/list): Read a folder, or the whole tree.
- [write()](/sdk/ref/local-files/write): Create or replace a file, text or binary.
- [Computer](/sdk/ref/providers/computer): What a computer storage is, and how it registers itself.

```python
pc = api.storage.get()        # the computer this process is on

pc.files.mkdir("Launch plan")
pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.")

brief = pc.files.read("Launch plan/brief.md")
print(brief["content"])        # a str: it is text

for item in pc.files.list("Launch plan"):
    print(item["type"], item["path"], item["size"])
```

```python
# A file
{
    "name": "brief.md",
    "path": "Launch plan/brief.md",   # relative to the workspace, forward slashes
    "type": "file",
    "size": 1284,                     # bytes
}

# A folder — size is 0
{"name": "Launch plan", "path": "Launch plan", "type": "folder", "size": 0}
```

```python
# Python's list() hides dot folders; read them from the workspace root directly
previous = sorted((pc.files.root / ".versions" / "notes.md").glob("*"))
trash = sorted((pc.files.root / ".trash").glob("*"))
```

```python
# A computer that is not this one has files = None in Python
computers = [s for s in api.storage.list() if s.type == "filesystem"]

for computer in computers:
    if computer.files is None:
        print(f"{computer.label} is elsewhere — skipping.")
        continue
    computer.files.list()
```
