手机无法注册,这就是整个设计: 键盘留在服务器上, 手机除了随机识别符号, 服务器的通话, 手机除了随机的识别符号之外, 什么都没有。 device() 代表它。
登记登记登记
// 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"deviceIdstring必填dev_ 之后是16至64个字母和数字,其他任何内容都被拒绝。
namestring显示名称, 最多80个字符。 缺少时从用户代理器中提取 。
userAgentstring电话的用户代理,最多400个字符, 用来命名和描述它。
身份识别资料是留给你的
将它生成到页面中, 保存在浏览器中, 并随每个呼叫发送 。 相同的标识符总是会解析到同一个存储, 所以调用 device() 每一页的负载都是正常的,没有新内容。
// 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 任何不是dev_+16到64个字母和数字的东西 都会回来。 A UUID 其痕迹的落下,是常有的缘故。
其文件在浏览器中
手机数据上没有记录 服务器上也没有 phone.files 所以,抛 storage_is_phone 拒绝,说文件实际上在哪里,而不是假装没有。
要想达到他们,他们所在的网页就是他们的工作:一个代理人,给一个代理人, 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",
)电话从不默认
注册时不会移动账户的默认存储, 不论有其它存储。 保存目标没有目标, 将无处可去 。
每份申请一个电话
appName,在构建该账户时,客户端将分离同一账户的不同应用程序所注册的设备。两个应用程序所使用的同一电话是两个存储器,这样可以避免一个存储器上列另一个。
两次同时登记是一次储存
双火——一个更新,一个双向上升的框架。同时,同一身份识别器的通话就只用一个存储器,两个都取回,所以不需要你的守卫。
错误
| 代码 | 状态 | 触发条件 |
|---|---|---|
| invalid_device_id | 400 | deviceId 不匹配 dev_ + 16-64个字母和数字。 |
| storage_is_phone | 400 | phone.files 是从浏览器外获取的。 |