# Navegador

Canonical URL: https://developers.iagenify.com/pt/sdk/runtimes/browser/
Language: pt

Il SDK run in una pagina, con la sessione in localStorage. Non c'è disco e shell, quindi un agent obteve le operazion de file da te.

Status: localStorage · sem sistema de arquivos · sem shell

> **Non spedire una chave a un browser**
>
> Si pubblica tutto il codice del lato client. Chiama il SDK del tuo server e manda i risultati; le pagine abaixs describe un dispositivo cui i files il agente raggiunge, non una chiave vivendo in la pagina.

## La sessione {#session}

Cached in `localStorage`, che è per origine. Supervive a una recarga e è invisibile a ogni altra origine — inclusa le vostre altre superficies in altri portos in fase de sviluppo.

## Non c'è disco {#files}

`storage.files` Un dispositivo del browser mantiene i suoi files in suo browser, e un agente li raggiunge attraverso sei operazioni che fornisci.

```javascript
const agent = api.agents.create({
  runtime: "local",
  machine: device,
  model: "gemini-3.5-flash",
  files: {
    list:   async (dir) => [{ name, path, type, size, mimeType, modifiedAt }],
    read:   async (path) => ({ content }),
    write:  async (path, content) => ({ path }),
    mkdir:  async (dir) => ({ path: dir }),
    move:   async (from, to) => ({ path: to }),
    remove: async (path) => ({ ok: true }),
  },
});
```

> **Se nega un e nega in costruzione**
>
> L'errore è files_required e nomina le operazions care mancant. L'agente non è mai creat semi-equipated.

### Onde vivono realmente quei files

It's choice, e il punto del ponte. IndexedDB per i propri files del dispositivo; un stoke objete per i files che devono seguire l'usuario entre i dispositivi; un map in-memorie per un test.

```javascript
// A bridge over any async key-value store
const files = (store) => ({
  list:   async (dir = "") => store.listPrefix(dir),
  read:   async (path) => ({ content: await store.get(path) }),
  write:  async (path, content) => { await store.set(path, content); return { path }; },
  mkdir:  async (dir) => ({ path: dir }),
  move:   async (from, to) => { await store.set(to, await store.get(from)); await store.del(from); return { path: to }; },
  remove: async (path) => { await store.del(path); return { ok: true }; },
});
```

## Registrare un dispositivo {#devices}

Un browser non si registra — il SDK non è là, e la chiave non deve essere. Il servèrve lo registra, con un id la pagina mantiene.

```javascript
// in the page
let deviceId = localStorage.getItem("device");
if (!deviceId) {
  deviceId = crypto.randomUUID();
  localStorage.setItem("device", deviceId);
}

// on your server, with the key
const device = await api.storage.device({
  deviceId,
  name: "Zayd's phone",
  userAgent,
});
// a storage of type "phone", provider "browser"
```

## Comandos {#shell}

`bash` è eliminat del set de ferramentas, perché nulla lo rule. Fornir un shell e il retorna, idnificat dal punto de vista del agente.

```javascript
api.agents.create({
  runtime: "local",
  machine: device,
  model: "gemini-3.5-flash",
  files,
  shell: {
    run: async (command, { timeoutMs, signal }) => {
      const { stdout, stderr, exitCode } = await runSomewhere(command, { timeoutMs, signal });
      return { stdout, stderr, exitCode };
    },
  },
});
```

Restituiu i tre campi. Qualcosa di altre è negat con `invalid_shell` prima di la costruzione del agente.

## - Che non è qui? {#missing}

- `storage.files` — use il ponte `files`.
- `terminals` — un shell que surviva a una risposta necessita di un processo in cui vivere.
- `bash`, a meno che non fornisca `shell`.
- Abilitäs e sub-agentes legü a partir de un disco. La biblioteca del cont ancora funciona, e it it is where them apparten.

```python
class DeviceFiles:
    """Any object with these six methods can be the agent's workspace."""
    def list(self, dir="", *, recursive=False): return [{"name": ..., "path": ..., "type": ..., "size": ...}]
    def read(self, path): return {"content": ...}
    def write(self, path, content): return {"path": path}
    def mkdir(self, dir): return {"path": dir}
    def move(self, source, destination): return {"path": destination}
    def remove(self, path): return {"ok": True}

agent = api.agents.create(
    runtime="local",
    machine=device,
    model="gemini-3.5-flash",
    files=DeviceFiles(),
)
```

```python
# A bridge over any key-value store
class StoreFiles:
    def __init__(self, store): self.store = store
    def list(self, dir="", *, recursive=False): return self.store.list_prefix(dir)
    def read(self, path): return {"content": self.store.get(path)}
    def write(self, path, content):
        self.store.set(path, content)
        return {"path": path}
    def mkdir(self, dir): return {"path": dir}
    def move(self, source, destination):
        self.store.set(destination, self.store.get(source))
        self.store.delete(source)
        return {"path": destination}
    def remove(self, path):
        self.store.delete(path)
        return {"ok": True}
```

```python
# In the page, the browser keeps its own device id (JavaScript):
#   localStorage.getItem("device") || crypto.randomUUID()

# On your Python server, with the key
device = api.storage.device(
    device_id=device_id,
    name="Zayd's phone",
    user_agent=user_agent,
)
# a storage of type "phone", provider "browser"
```

```python
# Python's bash tool runs on a LocalFiles workspace, on the machine that runs the SDK.
# A device without a shell gets the file tools only: leave "bash" out of its tools.
api.agents.create(
    runtime="local",
    machine=device,
    model="gemini-3.5-flash",
    files=StoreFiles(store),
    tools=["read", "list", "glob", "write", "edit", "move", "delete"],
)
```
