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
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
storage.files Un dispositivo del browser mantiene i suoi files in suo browser, e un agente li raggiunge attraverso sei operazioni che fornisci.
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(),
)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.
// 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}Registrare un dispositivo
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.
// 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"Comandos
bash è eliminat del set de ferramentas, perché nulla lo rule. Fornir un shell e il retorna, idnificat dal punto de vista del agente.
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"],
)Restituiu i tre campi. Qualcosa di altre è negat con invalid_shell prima di la costruzione del agente.
- Che non è qui?
storage.files— use il pontefiles.terminals— un shell que surviva a una risposta necessita di un processo in cui vivere.bash, a meno che non forniscashell.- Abilitäs e sub-agentes legü a partir de un disco. La biblioteca del cont ancora funciona, e it it is where them apparten.