Runtimes

Browser

The SDK runs in a page, with the session in localStorage. There is no disk and no shell, so an agent gets its file operations from you.

localStorageno filesystemno shell
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Do not ship a key to a browser

Anything in client-side code is published. Call the SDK from your own server and send the results down; the pages below describe a device whose files the agent reaches, not a key living in the page.

The session

Cached in localStorage, which is per origin. It survives a reload and is invisible to every other origin — including your other surfaces on other ports in development.

There is no disk

storage.files throws here. A browser device keeps its files in its own browser, and an agent reaches them through six operations you supply.

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 }),
  },
});
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(),
)
Miss one and it refuses at construction

The error is files_required and it names the operations that are missing. The agent is never created half-equipped.

Where those files actually live

That is your choice, and it is the whole point of the bridge. IndexedDB for a device's own files; an object store for files that must follow the user between devices; an in-memory map for a test.

// 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 }; },
});
# 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}

Registering a device

A browser never registers itself — the SDK is not there, and the key must not be. Your server registers it, with an id the page keeps.

// 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"
# 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"

Commands

bash is removed from the tool set here, because nothing would run it. Supply a shell and it comes back, identical from the agent's point of view.

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 };
    },
  },
});
# 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"],
)

Return the three fields. Anything else is refused with invalid_shell before the agent is built.

What is not here

  • storage.files — use the files bridge.
  • terminals — a shell that outlives an answer needs a process to live in.
  • bash, unless you supply shell.
  • Skills and sub-agents read from a disk. The account's library still works, and that is where they belong.