Un telefono non può registrarse, e che è l'intero design: la chiave sta sul tuo server, il telefono non tiene ninguna cosa se non un identificatore al azar, e il server chiama device() in suo nome.
Registrare un
// On your server — this is where the key is
const phone = await api.storage.device({
deviceId, // kept in the phone's own browser
name: "Zayd's iPhone", // optional
userAgent, // optional, used to name it
});
// phone.type === "phone" phone.provider === "browser" phone.deviceId === deviceId# On your server — this is where the key is
phone = api.storage.device(
device_id=device_id, # kept in the phone's own browser
name="Zayd's iPhone", # optional
user_agent=user_agent, # optional, used to name it
)
# phone.type == "phone" phone.provider == "browser"deviceIdstringobrigatóriodev_ seguiu da 16 a 64 lettere e cifres. Tutto o resto è rifiutato.
namestringIl nome display, 80 caracteres a macis. Derivè del agente utente quando ausente.
userAgentstringAgent d'usuari del telefono, 400 caracteres al massimo. Usato per nome e decrivi-lo.
L'identificant è a te da conservare
Generalo una volta nella pagina, tèlo in quel browser, e envialo con ogni chiamata. Il medesimo identificator sempre risolve al medesimo storage, dicindo device() in ogni page lo lo load è normal e crea nulla di nuovo.
// In the page
const id = localStorage.getItem("device")
|| `dev_${crypto.randomUUID().replace(/-/g, "")}`;
localStorage.setItem("device", id);# In the page (JavaScript) — the browser keeps its own id:
# const id = localStorage.getItem("device")
# || "dev_" + crypto.randomUUID().replace(/-/g, "");
# localStorage.setItem("device", id);
#
# Python receives that id from the page, e.g. in a request header.
device_id = request.headers["X-Device-Id"]invalid_device_id ritorna su qualsiasi cosa che non è dev_ plus 16 a 64 lettere e digits. A UUID con i suoi guilleti lasciati in è la causa usual.
I suoi files sono in suo browser
Nulla dei dati di un telefono è sul conto, e nulla di esso è sul servidor. phone.files quindi lança storage_is_phone — un renie que dice dove i files realmente sono, invece di fingir non c'è.
Per raggiunger-li, la pagina che li tiene fa il lavoro: un agent dato files come un ponte fluisce ogni operazion aquella pagina, la pagina lo runde su su propri storage, e la risposta retorna. It is the sujett of bridges · files.
const agent = api.agents.create({
runtime: "local",
machine: phone,
files: phoneBridge(), // yours: it talks to the page
model: "gemini-3.5-flash",
});agent = api.agents.create(
runtime="local",
machine=phone,
files=PhoneBridge(), # yours: an object with list/read/write/mkdir/move/remove that talks to the page
model="gemini-3.5-flash",
)Un telefono non è mai il predefinit
Registrare uno non move il stoccaj predefinit del cont, qualunque altra cosa è là. Un salvament senza target non avrebbe nòdù per ande.
Un telefono per petizione
appName, dato al cliente quando lo costruisci, separa dispositivi registratis da diverse applicazioni del mesmo compte. Il mesmo telefono utilizzato da due de tes applicazioni è dos storages, che è o que impede uno de listare dels altri.
Due registrazioni simultanee sono un stoccaggio
Pages duplo-fogo — un refresco, un framework que monta due vezes. Concurrente chiamas con o mesmo identificator se assente sobre un solo storage e ambos lo recupera, por lo que no es necesario guarda de la tua.
Erros
| Código | Status | Quando |
|---|---|---|
| invalid_device_id | 400 | deviceId non corrisponde dev_ + 16–64 letras e cifres. |
| storage_is_phone | 400 | phone.files a fost rtlltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltltl |