AnyBot/src/app/remote_ui.rs

2244 lines
133 KiB
Rust
Raw Normal View History

// 手機與帳號 in the window: what the phone sees (published when something changes), carrying out
// what the phone asks, and the settings page (phone password, account at the relay, backups,
// 裝置連結).
use super::*;
use crate::remote::{self, Cmd, Settings};
use serde_json::json;
use std::hash::{Hash, Hasher};
/// 團隊 as the relay answered: each (user, role), or why it could not be loaded.
type Members = Result<Vec<(String, String)>, String>;
#[derive(Default)]
pub struct RemoteUi {
sig: u64,
last_publish: Option<Instant>,
/// The settings the server threads were last given.
pushed: Option<Settings>,
Voice: its own 設定 › 語音, run by the brain for every screen and the phone Voice was three implementations that broke on their own: speech to text borrowed the OpenAI key (so with only Grok set up the mic recorded, then failed), OpenAI's models it hard-coded stop on 2027-02-26, read aloud was macOS `say` or espeak-ng (silently nothing on Windows, where espeak isn't installed), and the phone used the browser's own recognition. Now: - 設定 › 語音 has 聽 and 說, each a service: off, OpenAI-compatible (OpenAI, Groq, a Whisper server of your own: the address decides), xAI or ElevenLabs. An empty key borrows 設定 › 模型's for the same service. Each side says 可以用 or what it lacks; 聽 has 試試看 (record a sentence, show what was heard), 說 has 試聽 and the voice list. speech.rs does the calls; xAI's both ways were checked for real (Mandarin read, then heard back, in Traditional characters). - The brain does it all: the phone POSTs its recording (MediaRecorder) to /api/voice/transcribe, screens to /api/sync/voice/transcribe; answers come back as MP3 from …/voice/speech and are played on the device (rodio; an <audio> on the phone, 「唸出來」 in a message's menu). Keys stay on the brain (the voice keys are redacted for screens like the others). - No service, no voice anywhere: the mic, 語音聊天, 會議錄音 and 朗讀 only appear once 聽 (and 說) can be called; the phone's state says which. Without voice the send arrow just rests where 語音聊天 was. - 會議錄音 is uploaded to the brain, which turns it into text in the background and hands it to the bot itself: a meeting is longer than the 35 s the account lets a request wait, and a brain on a server has no window (the jobs are polled in background()). - Recognisers answer Mandarin in Simplified: in a Traditional Chinese window or phone the text becomes Traditional with Taiwan wording. - Older saves: whoever had an OpenAI key keeps voice input (聽 = OpenAI); everyone else starts with it off. Bots' macOS voice names are cleared. 對話詳細資訊's 加入會議 started plain voice input; it starts a meeting now.
2026-11-10 14:58:18 +00:00
/// And the voice service.
voice: crate::speech::Engines,
pw1: String,
pw2: String,
relay_url: String,
user: String,
pass: String,
invite: String,
create: bool,
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
/// 兩步驗證: the code that goes with the password, asked once the account said it has it on.
code: String,
need_code: bool,
pub(super) note: Arc<Mutex<String>>,
join_rx: Option<Receiver<Result<(Settings, remote::AccountFind), String>>>,
restore_rx: Option<Receiver<Result<Vec<u8>, String>>>,
busy: Arc<AtomicBool>,
feat: /doctor 診斷這台電腦:連線、Tailscale 直連還是中繼、大腦、模型服務、Bot 的電腦、連接器、磁碟、上次出錯 工程基礎計畫 E11(grok-build 的 /doctor)。早上「連不到大腦」花了半小時用指令查出是 Tailscale 走香港中繼,現在打一句就看得到。 - doctor.rs:報告的樣子(一項一行 ✓/✗,最後數有幾項要看);帳號伺服器網址是 *.ts.net 時跑 tailscale ping,讀出是直連還是走哪個中繼(走中繼寫延遲和「多半是中間擋了 UDP 41641」);df 看磁碟;找最新的當掉報告。 - app/doctor_ui.rs:當下就知道的(版本、資料夾、紀錄檔、這台 ↔ 帳號伺服器、帳號伺服器 ↔ 大腦、螢幕連不連得到大腦和原因、上次同步的大小和速度、Bot 的電腦、每個開著的連接器、磁碟少於 2 GB、上次出錯),要上網的在背景跑(Tailscale、每個 Bot 用到的模型服務列模型清單),好了在聊天留一行。 - 在連到大腦的螢幕電腦上:/doctor 在連不到大腦的檢查之前就處理,檢查的是這台本身,結果跳成提示(那個聊天是大腦的)。手機打的是大腦檢查自己。 - / 清單、手機的指令清單多一個 doctor;功能地圖 garden.md、chat.md,FEATURES.md。 已驗證:cargo test 全過、clippy -D warnings 過。新測試:報告的格式和計數;tailscale ping 的直連和中繼兩種輸出(用今天早上這台真的輸出「via DERP(hkg) in 63ms」);最新的當掉報告、磁碟;從聊天打 /doctor 先說「診斷中」、再一份報告(模型服務指向測試用的假模型)。 未驗證:螢幕電腦上真的跑一次(要更新這台 App)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:48:01 +00:00
pub(super) peers: Arc<Mutex<Vec<(String, String, bool)>>>,
last_seen_mark: Option<Instant>,
peers_at: Option<Instant>,
/// 團隊: (user, role) shared with, loaded from the relay; the form to add one.
members: Arc<Mutex<Option<Members>>>,
new_member: String,
new_admin: bool,
started: bool,
}
/// Approvals as the phone shows them.
/// An address without what may be secret in it: no 「user:password@」, no query, no fragment.
fn address_only(url: &str) -> String {
let (scheme, rest) = url.split_once("://").map(|(a, b)| (format!("{a}://"), b)).unwrap_or((String::new(), url));
let rest = rest.split(['?', '#']).next().unwrap_or("");
let (host, path) = rest.split_once('/').map(|(h, p)| (h, format!("/{p}"))).unwrap_or((rest, String::new()));
format!("{scheme}{}{path}", host.rsplit('@').next().unwrap_or(host))
}
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
/// A card as the phone draws it. `key`: the card's own (on_new_approval) — the phone sends it
/// back with the answer, so the brain applies it only to this card.
fn approval_json(bot: &Bot, a: &Approval, key: &str) -> serde_json::Value {
let what = remote::tool_label(&a.tool);
let title = match a.kind {
ApprovalKind::EnableTools => format!("允許 {} 使用電腦工具嗎?", bot.name),
ApprovalKind::EnableThisComputer => format!("允許 {} 在你的電腦上執行任務嗎?", bot.name),
ApprovalKind::Action => format!("{} 想要{what}", bot.name),
ApprovalKind::Handoff => format!("{}:需要你", bot.name),
問題卡、搜尋: the bot asks with a card; every chat is searched; a refusal holds for the turn - 問題卡 (ask_person, src/ask.rs): up to 6 questions on a card above the input, one at a time — a choice (one click moves on), several choices, or a field that arrives filled for the person to correct; 「自己回答」 on every question, 上一題 and 略過. The turn waits; a message typed instead leaves the card unanswered. Travels as an approval of kind Question (questions as JSON) with a new answer Answered, so the window, a screen of another brain and the phone draw the same card. - 搜尋所有聊天 (src/find.rs): the sidebar's search also lists what the person and the bots said in every chat, past conversations included, and attachment names; newest first, 40 at most. A click opens the bot (bringing a past conversation back first), scrolls to the message and lights it for a moment. - 拒絕後停下: a step the person refused is refused for them when it comes back unchanged in the same turn — no second card, no second review — until they write again. - The bot's instructions: stop after a refusal instead of trying another way; before sending, posting, buying or deleting, check the person's own messages asked for exactly that, and ask with the card when they didn't. - 直接操作 no longer answers a hand-off (or a question) on the person's behalf. - The repeated-step check leaves questions to the person alone. - Screenshot views `ask` and `find`; FEATURES.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
2026-11-12 02:17:32 +00:00
ApprovalKind::Question => format!("{} 問你", bot.name),
};
問題卡、搜尋: the bot asks with a card; every chat is searched; a refusal holds for the turn - 問題卡 (ask_person, src/ask.rs): up to 6 questions on a card above the input, one at a time — a choice (one click moves on), several choices, or a field that arrives filled for the person to correct; 「自己回答」 on every question, 上一題 and 略過. The turn waits; a message typed instead leaves the card unanswered. Travels as an approval of kind Question (questions as JSON) with a new answer Answered, so the window, a screen of another brain and the phone draw the same card. - 搜尋所有聊天 (src/find.rs): the sidebar's search also lists what the person and the bots said in every chat, past conversations included, and attachment names; newest first, 40 at most. A click opens the bot (bringing a past conversation back first), scrolls to the message and lights it for a moment. - 拒絕後停下: a step the person refused is refused for them when it comes back unchanged in the same turn — no second card, no second review — until they write again. - The bot's instructions: stop after a refusal instead of trying another way; before sending, posting, buying or deleting, check the person's own messages asked for exactly that, and ask with the card when they didn't. - 直接操作 no longer answers a hand-off (or a question) on the person's behalf. - The repeated-step check leaves questions to the person alone. - Screenshot views `ask` and `find`; FEATURES.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
2026-11-12 02:17:32 +00:00
// 問題卡: the questions themselves, for the phone to draw.
if a.kind == ApprovalKind::Question {
let questions: serde_json::Value = serde_json::from_str(&a.reason).unwrap_or(json!([]));
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
return json!({"bot": bot.id, "title": title, "reason": crate::ask::describe(&a.reason), "tool": a.tool, "can_always": false, "kind": "question", "computer": "", "call_id": a.call_id, "questions": questions, "key": key});
問題卡、搜尋: the bot asks with a card; every chat is searched; a refusal holds for the turn - 問題卡 (ask_person, src/ask.rs): up to 6 questions on a card above the input, one at a time — a choice (one click moves on), several choices, or a field that arrives filled for the person to correct; 「自己回答」 on every question, 上一題 and 略過. The turn waits; a message typed instead leaves the card unanswered. Travels as an approval of kind Question (questions as JSON) with a new answer Answered, so the window, a screen of another brain and the phone draw the same card. - 搜尋所有聊天 (src/find.rs): the sidebar's search also lists what the person and the bots said in every chat, past conversations included, and attachment names; newest first, 40 at most. A click opens the bot (bringing a past conversation back first), scrolls to the message and lights it for a moment. - 拒絕後停下: a step the person refused is refused for them when it comes back unchanged in the same turn — no second card, no second review — until they write again. - The bot's instructions: stop after a refusal instead of trying another way; before sending, posting, buying or deleting, check the person's own messages asked for exactly that, and ask with the card when they didn't. - 直接操作 no longer answers a hand-off (or a question) on the person's behalf. - The repeated-step check leaves questions to the person alone. - Screenshot views `ask` and `find`; FEATURES.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
2026-11-12 02:17:32 +00:00
}
let handoff = a.kind == ApprovalKind::Handoff;
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
json!({"bot": bot.id, "title": title, "reason": a.reason, "tool": a.tool, "can_always": !handoff && (a.kind != ApprovalKind::Action || !a.grant.is_empty()), "kind": if handoff { "handoff" } else { "ask" }, "computer": if handoff { a.grant.as_str() } else { "" }, "key": key})
}
/// A teammate's messages waiting for a busy bot (more than this are not taken).
const MAX_WAITING_FROM_MEMBERS: usize = 8;
design: 手機網頁顏色跟著電腦版、改成 Claude 手機 App 的感覺,實點修好 12 個問題 - 顏色:api/state 帶出電腦的主題和淺色/深色兩組顏色(theme::shell 換成手機的 CSS 變數);手機「這支手機的外觀」預設「跟著電腦」,也可選跟著手機、淺色、深色;先驗證是 hex 才套用,存一份避免打開時閃預設色;狀態列跟著畫面。舊版電腦沒送顏色時維持「紙」。電腦畫面頁改成暖色深色。 - 感覺:標題列沒有底線、第二行只寫在做什麼或模型;輸入框是底部圓角卡片;回答下只留時間和三個操作;群組、晶片、建議、記憶卡拿掉框線;開關的「開」用墨色;允許卡細框;點擊範圍加大(44/40/36px)。 - 字更少:設定首頁拿掉重複說明;每列說明一行;「模型」頁右邊只寫可以用/未設定;Bot 那列選單少用的收進「更多…」。 - 修好:長 Bot 名字超出 @// 選單;引用顯示原始 Markdown 且沒有長度上限;第 8 個表情換行;.note 在清單裡變灰條;圖片點了跳出 App;上傳吐司蓋住輸入框;「聊天的顏色」永遠沒有 ✓(電腦送 "Quiet",改送 quiet/black/bot_color);「:」後的網址不成連結;深色模式黑頭像看不見;稽核分頁出現 ** 和多行 JSON;頁面卡標題重複;記憶搜尋框 14px 讓 iPhone 放大。 - 問題卡的「略過」、交辦的「跳過」、允許卡的「拒絕」不再是紅字,跟電腦版一樣是一般按鈕。 已驗證:cargo test --bin anybot 523 通過(含 phone_login_and_api 檢查主題和兩組顏色)、relay 22 通過;手機圖表 65/65、通知 9/9、電腦畫面 13/13;playwright 390×844 淺色深色點過登入、首頁、聊天、詳細資訊、Bot 設定、頁面、例行任務、電腦、設定每一頁,沒有 console 錯誤、失敗請求或橫向溢出;電腦換靛藍深色,手機跟著變。 未驗證:真的 iPhone/Android 實機。
2026-11-16 15:16:38 +00:00
/// 設定 › 一般 › 外觀 as the phone's colours: the shell the desktop draws, light and dark.
pub(super) fn phone_palettes(st: &crate::model::State) -> serde_json::Value {
let one = |dark| remote::palette_json(&crate::theme::shell(st.shell_tone, &st.shell_accent, st.shell_contrast, dark));
json!({"light": one(false), "dark": one(true)})
}
impl App {
pub(super) fn remote_start(&mut self, ctx: &egui::Context) {
if self.demo || self.rm.started {
return;
}
self.rm.started = true;
self.ctx_handle = Some(ctx.clone());
let c = ctx.clone();
remote::hub().set_repaint(Arc::new(move || c.request_repaint()));
self.remote_apply_settings();
self.mirror_boot();
// 傳送: whatever was still on its way when AnyBot stopped goes on.
crate::drops::kick();
}
/// Hand changed settings to the server threads (and restart what depends on them).
fn remote_apply_settings(&mut self) {
let s = self.state.remote.clone();
if self.rm.pushed.as_ref() == Some(&s) {
return;
}
let old = self.rm.pushed.replace(s.clone());
remote::hub().set_settings(&s);
let lan_changed = old.as_ref().map(|o| o.lan) != Some(s.lan);
if lan_changed {
match remote::set_lan(s.lan) {
Ok(_) => {}
Err(e) => *self.rm.note.lock().unwrap() = e,
}
}
let relay_changed = old.as_ref().map(|o| (o.relay_url.clone(), o.host_token.clone())) != Some((s.relay_url.clone(), s.host_token.clone()));
if relay_changed {
remote::relay_restart(&s);
}
}
/// Every frame: run what the phone asked and refresh what it sees.
pub(super) fn remote_tick(&mut self, ctx: &egui::Context) {
if self.demo {
return;
}
self.remote_apply_settings();
Voice: its own 設定 › 語音, run by the brain for every screen and the phone Voice was three implementations that broke on their own: speech to text borrowed the OpenAI key (so with only Grok set up the mic recorded, then failed), OpenAI's models it hard-coded stop on 2027-02-26, read aloud was macOS `say` or espeak-ng (silently nothing on Windows, where espeak isn't installed), and the phone used the browser's own recognition. Now: - 設定 › 語音 has 聽 and 說, each a service: off, OpenAI-compatible (OpenAI, Groq, a Whisper server of your own: the address decides), xAI or ElevenLabs. An empty key borrows 設定 › 模型's for the same service. Each side says 可以用 or what it lacks; 聽 has 試試看 (record a sentence, show what was heard), 說 has 試聽 and the voice list. speech.rs does the calls; xAI's both ways were checked for real (Mandarin read, then heard back, in Traditional characters). - The brain does it all: the phone POSTs its recording (MediaRecorder) to /api/voice/transcribe, screens to /api/sync/voice/transcribe; answers come back as MP3 from …/voice/speech and are played on the device (rodio; an <audio> on the phone, 「唸出來」 in a message's menu). Keys stay on the brain (the voice keys are redacted for screens like the others). - No service, no voice anywhere: the mic, 語音聊天, 會議錄音 and 朗讀 only appear once 聽 (and 說) can be called; the phone's state says which. Without voice the send arrow just rests where 語音聊天 was. - 會議錄音 is uploaded to the brain, which turns it into text in the background and hands it to the bot itself: a meeting is longer than the 35 s the account lets a request wait, and a brain on a server has no window (the jobs are polled in background()). - Recognisers answer Mandarin in Simplified: in a Traditional Chinese window or phone the text becomes Traditional with Taiwan wording. - Older saves: whoever had an OpenAI key keeps voice input (聽 = OpenAI); everyone else starts with it off. Bots' macOS voice names are cleared. 對話詳細資訊's 加入會議 started plain voice input; it starts a meeting now.
2026-11-10 14:58:18 +00:00
// 設定 › 語音 with its keys, for the phone's and the screens' recordings.
let voice = crate::speech::Engines::of(&self.state);
if self.rm.voice != voice {
remote::hub().set_voice(voice.clone());
self.rm.voice = voice;
}
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
let cmds = remote::hub().take_cmds();
let had_cmds = !cmds.is_empty();
for c in cmds {
// A screen of another brain has no bots of its own to run phone requests on.
if self.mir.on && !matches!(c, Cmd::DeviceAdded(_) | Cmd::DeviceSeen(_)) {
continue;
}
self.remote_cmd(ctx, c);
}
self.brain_serve(ctx);
self.brain_watch();
if let Some(rx) = &self.rm.join_rx {
if let Ok(r) = rx.try_recv() {
self.rm.join_rx = None;
match r {
Ok((s, found)) => {
self.state.remote = s;
self.rm.pass.clear();
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
self.rm.code.clear();
self.rm.need_code = false;
self.account_sync(found);
self.mark();
}
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
Err(e) => {
self.rm.need_code |= e.starts_with(remote::NEED_CODE);
// (A code is good for one try.)
self.rm.code.clear();
*self.rm.note.lock().unwrap() = e;
}
}
}
}
if let Some(rx) = &self.rm.restore_rx {
if let Ok(r) = rx.try_recv() {
self.rm.restore_rx = None;
match r.and_then(|bytes| serde_json::from_slice::<State>(&bytes).map_err(|e| format!("備份內容讀不出來:{e}"))) {
Ok(mut st) => {
// Keep this computer's own phone and account settings.
st.remote = self.state.remote.clone();
let n = st.bots.len();
self.state = st;
self.state.save();
*self.rm.note.lock().unwrap() = format!("已從備份還原 {n} 個 Bot");
}
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
Err(e) => {
self.rm.need_code |= e.starts_with(remote::NEED_CODE);
self.rm.code.clear();
*self.rm.note.lock().unwrap() = e;
}
}
}
}
// 自動備份: once a day while signed in.
let s = &self.state.remote;
if !self.mir.on && s.auto_backup && !s.backup_key.is_empty() && !s.relay_url.is_empty() && chrono::Utc::now().timestamp() - s.last_backup > 86_400 && !self.rm.busy.load(Ordering::SeqCst) {
self.remote_backup();
}
// 裝置連結: keep the list of this account's computers fresh (every 15 s: a computer that
// comes on is one the bots can use soon after).
if !self.state.remote.host_token.is_empty() && !self.rm.peers_at.map(|t| t.elapsed().as_secs() < 15).unwrap_or(false) {
self.rm.peers_at = Some(Instant::now());
let (peers, s) = (self.rm.peers.clone(), self.state.remote.clone());
std::thread::spawn(move || {
let v = remote::devices_online(&s);
if !v.is_empty() {
*peers.lock().unwrap() = v;
}
});
}
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
if !self.mir.on && (had_cmds || !self.rm.last_publish.map(|t| t.elapsed().as_millis() < 75).unwrap_or(false)) {
self.remote_publish();
}
}
/// 加一台電腦: lines for Mac, any Linux (desktop or headless) and Windows. Each installs
/// AnyBot if needed and joins as hands, including the first pairing, with nothing to answer.
fn pair_section(&mut self, ui: &mut egui::Ui) {
let p = self.pal;
ui.add_space(6.0);
ui.separator();
ui.horizontal(|ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("加一台電腦")).size(FONT_SM).strong().family(crate::bold()));
help_mark(ui, "讓另一台電腦當大腦的手腳:Mac、任何 Linux(含沒有螢幕的)、已登入的 Windows。貼上對應的那一行就會裝好並完成第一次配對,不用帳號密碼。它會在開機或登入後自動執行,只讓這個大腦使用。", p);
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add(secondary_button("產生配對碼")).clicked() {
let (s, slot) = (self.state.remote.clone(), self.mir.pair.clone());
let for_host = if self.mir.on { s.brain_id.clone() } else { s.host_id.clone() };
*slot.lock().unwrap() = (t("正在產生…"), false, None);
// This computer is the brain: a key goes with the code (in the line to
// paste, never to the account server) and its commands to the new computer
// are signed with it. (As a screen of a brain elsewhere there is none: the
// key would have to cross the account server to reach that brain.)
let key = if self.mir.on { String::new() } else { crate::remote::new_link_key() };
if !key.is_empty() {
let keys = &mut self.state.remote.link_keys;
keys.push(key.clone());
let extra = keys.len().saturating_sub(crate::remote::MAX_LINK_KEYS);
keys.drain(..extra);
remote::hub().set_settings(&self.state.remote);
self.dirty = true;
}
std::thread::spawn(move || {
*slot.lock().unwrap() = match crate::remote::pair_code(&s, &for_host) {
Ok(code) if !key.is_empty() => (crate::remote::pair_block(&s.relay_url, &format!("{code}-{key}")), true, Some(Instant::now())),
Ok(code) => (crate::remote::pair_block(&s.relay_url, &code), true, Some(Instant::now())),
Err(e) => (e, false, None),
};
});
}
});
});
let (line, ok, at) = self.mir.pair.lock().unwrap().clone();
if line.is_empty() {
return;
}
let left = at.map(|t| 600u64.saturating_sub(t.elapsed().as_secs())).unwrap_or(0);
if ok && left == 0 {
hint(ui, "配對碼過期了,再按一次「產生配對碼」。", p);
return;
}
if !ok {
let c = if line.ends_with('…') { p.text2 } else { p.danger };
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(line).size(FONT_SM).color(c));
return;
}
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.hover).corner_radius(R_M).inner_margin(Margin::symmetric(10, 8)).show(ui, |ui| {
ui.horizontal(|ui| {
2026-11-16 14:07:07 +00:00
ui.add(egui::Label::new(RichText::new(&line).monospace().size(FONT_SM)).selectable(true).wrap());
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add(secondary_button("複製")).clicked() {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
crate::platform::copy_text(ui.ctx(), &line);
self.notice = Some(t("已複製。Mac 和 Linux 貼終端機那一行,Windows 貼 PowerShell 那一行"));
}
});
});
});
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(format!("{}(還有 {} 分 {:02} 秒,只能用一次)", t("在那台電腦貼上對應的那一行"), left / 60, left % 60)).size(FONT_XS).color(p.text3));
// Just made: bring it into view.
if at.map(|t| t.elapsed().as_millis() < 800).unwrap_or(false) {
ui.scroll_to_cursor(Some(Align::Max));
}
ui.ctx().request_repaint_after(std::time::Duration::from_secs(1));
}
fn remote_signature(&self) -> u64 {
let mut h = std::collections::hash_map::DefaultHasher::new();
self.state.remote.host_name.hash(&mut h);
self.state.timezone.hash(&mut h);
self.scr.cfg_hash.hash(&mut h);
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
(&self.state.folders, self.state.loose_index, &self.state.pin_order, self.state.accent as u8, self.newer_build.is_some()).hash(&mut h);
design: 手機網頁顏色跟著電腦版、改成 Claude 手機 App 的感覺,實點修好 12 個問題 - 顏色:api/state 帶出電腦的主題和淺色/深色兩組顏色(theme::shell 換成手機的 CSS 變數);手機「這支手機的外觀」預設「跟著電腦」,也可選跟著手機、淺色、深色;先驗證是 hex 才套用,存一份避免打開時閃預設色;狀態列跟著畫面。舊版電腦沒送顏色時維持「紙」。電腦畫面頁改成暖色深色。 - 感覺:標題列沒有底線、第二行只寫在做什麼或模型;輸入框是底部圓角卡片;回答下只留時間和三個操作;群組、晶片、建議、記憶卡拿掉框線;開關的「開」用墨色;允許卡細框;點擊範圍加大(44/40/36px)。 - 字更少:設定首頁拿掉重複說明;每列說明一行;「模型」頁右邊只寫可以用/未設定;Bot 那列選單少用的收進「更多…」。 - 修好:長 Bot 名字超出 @// 選單;引用顯示原始 Markdown 且沒有長度上限;第 8 個表情換行;.note 在清單裡變灰條;圖片點了跳出 App;上傳吐司蓋住輸入框;「聊天的顏色」永遠沒有 ✓(電腦送 "Quiet",改送 quiet/black/bot_color);「:」後的網址不成連結;深色模式黑頭像看不見;稽核分頁出現 ** 和多行 JSON;頁面卡標題重複;記憶搜尋框 14px 讓 iPhone 放大。 - 問題卡的「略過」、交辦的「跳過」、允許卡的「拒絕」不再是紅字,跟電腦版一樣是一般按鈕。 已驗證:cargo test --bin anybot 523 通過(含 phone_login_and_api 檢查主題和兩組顏色)、relay 22 通過;手機圖表 65/65、通知 9/9、電腦畫面 13/13;playwright 390×844 淺色深色點過登入、首頁、聊天、詳細資訊、Bot 設定、頁面、例行任務、電腦、設定每一頁,沒有 console 錯誤、失敗請求或橫向溢出;電腦換靛藍深色,手機跟著變。 未驗證:真的 iPhone/Android 實機。
2026-11-16 15:16:38 +00:00
// 外觀: the phone wears the desktop's theme and colours.
(self.state.theme as u8, &self.state.shell_accent, self.state.shell_tone.to_bits(), self.state.shell_contrast.to_bits()).hash(&mut h);
for b in &self.state.bots {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
(b.id, &b.name, &b.color, b.unread, b.messages.len(), &b.thinking, &b.step_model).hash(&mut h);
// (What the phone's home, editor and reactions show.)
(&b.description, &b.shape, b.pinned, &b.folder, b.members.len(), b.instructions.len(), b.memories.len(), b.tools_enabled).hash(&mut h);
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
for m in b.messages.iter().rev().take(remote::PHONE_TAIL) {
(m.role as u8, m.text.len(), m.thinking.len(), m.attachments.len(), m.tool_calls.len(), m.error, m.summary, m.interrupted, &m.reactions, m.memories.len()).hash(&mut h);
for c in &m.tool_calls {
(c.status as u8).hash(&mut h);
}
}
if let Some(l) = self.streams.get(&b.id) {
(1u8, &l.status, l.paused, l.steer.lock().unwrap().len()).hash(&mut h);
}
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
// (With its key: call ids repeat — call_0 every round — and a new card has to reach
// the phone with its own key.)
self.approvals.get(&b.id).map(|a| (a.call_id.clone(), self.ask_keys.get(&b.id).cloned())).hash(&mut h);
// The phone's home and bot sheet: its model, computer, routines and past chats.
(b.provider, &b.model, &b.default_computer, b.threads.len(), b.id == self.state.primary_bot).hash(&mut h);
for r in &b.routines {
(r.id, &r.title, r.paused, r.next_run).hash(&mut h);
}
}
for (id, _, online) in self.rm.peers.lock().unwrap().iter() {
(id, online).hash(&mut h);
}
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
// A 支線's card (shown in its main bot's chat), with its key.
for br in &self.state.branch_bots {
self.approvals.get(&br.id).map(|a| (br.id, a.call_id.clone(), self.ask_keys.get(&br.id).cloned())).hash(&mut h);
}
crate::cloudbox::run_state().label().hash(&mut h);
// A connector connected or failing: screens and phones hear of it now, not at the next
// long poll's end.
let mut up: Vec<(String, usize)> = crate::mcp::status().into_iter().collect();
up.sort();
(up, self.ch.mcp_errors.lock().unwrap().clone(), self.ch.mcp_busy.load(Ordering::SeqCst)).hash(&mut h);
for pg in &self.state.pages {
(pg.id, pg.revision, pg.updated, &pg.title).hash(&mut h);
}
h.finish()
}
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
pub(super) fn remote_publish(&mut self) {
let sig = self.remote_signature();
if sig == self.rm.sig {
return;
}
self.rm.sig = sig;
self.rm.last_publish = Some(Instant::now());
crate::routines::set_person_timezone(&self.state.timezone);
let names: HashMap<u64, String> = self.state.bots.iter().map(|b| (b.id, b.name.clone())).collect();
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
let raw_order: HashMap<u64, usize> = self.state.bots.iter().enumerate().map(|(i, b)| (b.id, i)).collect();
let mut bots: Vec<&Bot> = self.state.bots.iter().collect();
// Pinned first, then the most recently active.
bots.sort_by_key(|b| (!b.pinned, -(b.last_turn.as_ref().map(|t| t.settled_at_ms).unwrap_or(0))));
// 聊天的顏色, in the names update_settings takes (the phone compares and sends these).
let accent = match self.state.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot_color",
}
.to_string();
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
let mut view = remote::View {
host: self.state.remote.host_name.clone(),
person: self.person_name(),
accent,
pin_order: self.pinned_ids(),
newer: self.newer_build.is_some(),
sections: self.section_order(),
design: 手機網頁顏色跟著電腦版、改成 Claude 手機 App 的感覺,實點修好 12 個問題 - 顏色:api/state 帶出電腦的主題和淺色/深色兩組顏色(theme::shell 換成手機的 CSS 變數);手機「這支手機的外觀」預設「跟著電腦」,也可選跟著手機、淺色、深色;先驗證是 hex 才套用,存一份避免打開時閃預設色;狀態列跟著畫面。舊版電腦沒送顏色時維持「紙」。電腦畫面頁改成暖色深色。 - 感覺:標題列沒有底線、第二行只寫在做什麼或模型;輸入框是底部圓角卡片;回答下只留時間和三個操作;群組、晶片、建議、記憶卡拿掉框線;開關的「開」用墨色;允許卡細框;點擊範圍加大(44/40/36px)。 - 字更少:設定首頁拿掉重複說明;每列說明一行;「模型」頁右邊只寫可以用/未設定;Bot 那列選單少用的收進「更多…」。 - 修好:長 Bot 名字超出 @// 選單;引用顯示原始 Markdown 且沒有長度上限;第 8 個表情換行;.note 在清單裡變灰條;圖片點了跳出 App;上傳吐司蓋住輸入框;「聊天的顏色」永遠沒有 ✓(電腦送 "Quiet",改送 quiet/black/bot_color);「:」後的網址不成連結;深色模式黑頭像看不見;稽核分頁出現 ** 和多行 JSON;頁面卡標題重複;記憶搜尋框 14px 讓 iPhone 放大。 - 問題卡的「略過」、交辦的「跳過」、允許卡的「拒絕」不再是紅字,跟電腦版一樣是一般按鈕。 已驗證:cargo test --bin anybot 523 通過(含 phone_login_and_api 檢查主題和兩組顏色)、relay 22 通過;手機圖表 65/65、通知 9/9、電腦畫面 13/13;playwright 390×844 淺色深色點過登入、首頁、聊天、詳細資訊、Bot 設定、頁面、例行任務、電腦、設定每一頁,沒有 console 錯誤、失敗請求或橫向溢出;電腦換靛藍深色,手機跟著變。 未驗證:真的 iPhone/Android 實機。
2026-11-16 15:16:38 +00:00
theme: match self.state.theme {
crate::model::Theme::Light => "light",
crate::model::Theme::Dark => "dark",
crate::model::Theme::System => "system",
}
.to_string(),
palettes: phone_palettes(&self.state),
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
..Default::default()
};
let peers = self.rm.peers.lock().unwrap().clone();
for b in bots {
// Its computers, each as the phone shows it: what it is and whether it is there now.
let targets = self.targets_for(b);
let roles = self.roles_for(b, &targets);
let computer = Self::chosen_computer(b, &targets, &roles).0;
let computers: Vec<serde_json::Value> = targets.iter().map(|t| {
let (kind, online) = match &t.place {
tools::Place::Box { .. } => ("own", crate::cloudbox::available()),
tools::Place::Sealed { .. } => ("own", false),
tools::Place::Local { .. } => ("this", true),
tools::Place::Device { host, .. } => ("device", peers.iter().any(|(id, _, on)| id == host && *on)),
tools::Place::Ssh { .. } => ("ssh", true),
};
json!({"name": t.name, "kind": kind, "online": online, "person": roles.person.as_deref() == Some(t.name.as_str())})
}).collect();
let live = self.streams.get(&b.id);
// The last thing said (not an error the model service sent, which then sat on the home).
let last = b.messages.iter().rev().find(|m| !m.text.trim().is_empty() && m.role != Role::Tool && !m.error).map(|m| first_line(&m.text, 60)).unwrap_or_default();
let c = crate::avatar::color(&b.color);
let hex = format!("#{:02x}{:02x}{:02x}", c.r(), c.g(), c.b());
view.bots.push(json!({
"id": b.id, "name": b.name, "description": b.description, "color": hex, "shape": b.shape,
"busy": live.is_some(), // (What it is doing now, in the same words as above the input on the computer.)
"status": self.working_phrase(crate::model::now_ms() as f64 / 1000.0, b).unwrap_or_default(),
"unread": b.unread, "last": last, "members": !b.members.is_empty(), "pinned": b.pinned,
Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等 問同事(ask_bot) - A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A - 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停 - message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定) 群組 @點名 - 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則) - 電腦和手機的輸入框打 @ 會列出成員 - 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的 共用資源 - Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改) - 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶 - teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能 修正 - 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著 - 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉) - 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉 - 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著 - Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話 - 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 13:34:03 +00:00
// 重新產生 replaced an answer: 「還原上一個答案」 can put it back.
"can_restore": !b.regen_undo.is_empty(),
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
// 團隊: whether teammates may use it (remote.rs shows a member only these).
"team": b.team,
// Its skills (null: every one), for the phone's 「/word」 list.
"skills": b.skills,
Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等 問同事(ask_bot) - A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A - 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停 - message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定) 群組 @點名 - 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則) - 電腦和手機的輸入框打 @ 會列出成員 - 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的 共用資源 - Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改) - 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶 - teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能 修正 - 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著 - 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉) - 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉 - 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著 - Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話 - 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 13:34:03 +00:00
// @點名: a group's members, as the phone's @ list offers them.
"member_names": self.member_names(b).into_iter().map(|(_, n)| n).collect::<Vec<_>>(),
"primary": b.id == self.state.primary_bot,
"time": b.messages.iter().rev().find(|m| m.role != Role::Tool).map(|m| m.at).unwrap_or(0),
"via": format!("{} · {}", b.provider.label(), b.model),
"provider": serde_json::to_value(b.provider).unwrap_or_default(), "model": b.model,
"computer": computer, "computers": computers,
"routines": b.routines.iter().map(|r| json!({"id": r.id, "title": r.title, "paused": r.paused, "when": crate::appctl::routine_when(r)})).collect::<Vec<_>>(),
"threads": b.threads.iter().enumerate().rev().take(20).map(|(i, (title, msgs))| json!({"index": i, "title": title, "count": msgs.len(), "at": msgs.last().map(|m| m.at).unwrap_or(0)})).collect::<Vec<_>>(),
// The sidebar's sections, the colour by name (the editor), what is queued while it works.
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"folder": b.folder, "color_key": b.color, "order": raw_order.get(&b.id).copied().unwrap_or(0),
// 聊天的顏色 (設定 › 一般): how the phone draws your bubbles — the same choice.
"bubble": match self.state.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot",
},
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"thinking": b.thinking, "step_model": b.step_model,
A turn cut off by a crash leaves a 「繼續」 card, and nothing it may have done runs twice Each bot keeps a work log (oplog/bot-<id>.jsonl, after pi's durable-harness design, cut down): before something happens a line says it is about to — the turn, each model call, each step once its checks passed (with the arguments it runs with and whether it may run again), each message typed mid-turn — synced to disk first. When the turn ends the file shrinks to the messages still waiting, usually nothing. On the next start after AnyBot was killed mid-turn, the log puts the chat right before anything runs: the message the turn answered comes back if the chat lost it; a step that was running and reaches outside (a text, a click, a file, a published site) shows as 「可能已經執行了」, both to the person and in the result the bot reads — no longer as "not allowed"; a step that only looked shows as cut off; messages typed mid-turn that never reached the bot go back into the chat. The chat is saved, then the log closes the turn. A turn the person didn't stop ends with a 「繼續」 card (what it was doing, what may have run, the messages put back); it goes on only when they press it — in the window, on a screen of the brain, or on the phone — from where its steps stand, never running a step that may have run again. Pressing stop is on disk at once, and a stopped turn stays stopped. Also in the turn loop: - 自動審核 that doesn't answer (or answers something that isn't a verdict) asks the person; in 直接操作 mode it used to let the step through unchecked. - "Too long for this model" folds older messages into a summary and asks the same step again, once per thing the person said, instead of ending the turn. - Folding keeps the person's chat whole: the summary goes in at the fold and the model reads from the newest summary on (it used to delete what it folded). - A step moved to the chosen computer runs there, but the chat keeps the call as the model wrote it; the result says where it ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5F5gJt93t3yEx3XcS
2026-11-08 16:49:12 +00:00
"queued": live.map(|l| l.steer.lock().unwrap().iter().map(|q| q.text.clone()).collect::<Vec<_>>()).unwrap_or_default(),
// 目標: how it stands (its icon's words above the input), worded here so the phone says it the same way.
// 計畫: where it is (its icon's words above the input), worded here like the window's.
feat: /plan 先規劃再動手、聊天裡請 Bot 管理連接器、/always-approve 一律放行;輸入框上方的狀態不再破版 /plan(照 Claude Code 的 plan mode、Cursor 的 Plan Mode、Codex 的 update_plan) - 「/plan 要做的事」:這一輪只給會看的工具(讀檔、搜尋、web_fetch、瀏覽器的打開/讀取/捲動、截圖、anybot_guide、問題卡),在執行那一層擋下其他步驟(回「計畫還沒核准」),不是只靠提示詞。 - Bot 用 submit_plan 交計畫:聊天裡一張「計畫」卡(摘要、步驟、怎麼確認做對了、注意),下面的問題卡「照這個計畫做嗎?」:開始照計畫做/先不要/打字寫要改哪裡。 - 核准後同一輪接著做:工具全開、系統指示換成照計畫做,第 1 步自動進行中;update_plan 每做完一步更新一次(整份清單、只有一步進行中),卡上打勾、輸入框上方「照計畫做 · 2/6 · 這一步」;全部做完留「計畫完成」那一行。 - 「/plan」看狀態、「/plan clear」取消;例行任務、訊息管道、團隊成員的訊息不受影響;群組不能用;支線不帶計畫;清除聊天或新對話一起清;分享 Bot 檔不含。手機:計畫卡、計畫列、取消計畫。 - 新功能地圖 plan.md;研究(Claude Code、Codex、Cursor、Gemini CLI…)的結論寫進提示:只寫建議的做法、通常 3 到 7 步、問題最多 3 題、打勾不要太勤。 聊天裡管理連接器(設定能做的聊天也要能做) - 新工具 manage_connectors(管理 App 能力):list、add、update(含開關)、reconnect、remove。改的就是大腦上 設定 › 整合 › 連接器 那一份,不會寫到手腳電腦的檔案(進化之神之前叫使用者去 nobledesktop 的 ~/.local/share/AnyBot 設)。 - 新增、修改、移除先跳卡片:指令(在大腦上執行)或網址、環境變數、標頭;TOKEN、KEY、SECRET、PASS、AUTH… 和密碼顯示「••••(已填)」。名稱重複、command 和 url 都給、網址不對、還有「{…}」、沒東西可改,在問之前就回給 Bot。 - 加好後等它連上(最多 90 秒)再回報幾個工具或原因;一輪裡連接器的工具變了,下一步起就換新(加完同一輪就能用)。 /always-approve(也可以 /yolo) - 使用者自己打(電腦、大腦的螢幕、手機的擁有者)或 設定 › 權限 ›「一律放行」:打開直接操作,之後所有要等「允許」的都自動允許(含一律詢問規則、付款/傳送/刪除的點擊、寄信、傳訊息、打電話、發文、保險庫卡片),自動審核略過;打開時在等的卡片一起放行。 - 照樣擋:安全規則一律拒絕的;別人傳來的訊息那一輪;問題卡、需要處理、計畫卡。Bot、例行任務、訊息管道打不開;管理員和成員打的變成「【名字】/always-approve」。管理員鎖了直接操作就打不開。 - 開著時每個聊天輸入框上方一條「一律放行」和「關閉」;「/always-approve off」關掉,直接操作是它打開的就一起關。 輸入框上方的狀態 - 好幾行的狀態(模型忙碌重試:錯誤、說明、幾秒後重試)以前疊出那一列、壓到輸入框;現在一行:「模型供應商目前負載過高,15 秒後重試(第 3 次,共 3 次)…」。 已驗證:cargo test 548 通過、1 個失敗(layout_audit 的 設定 › 電腦 被這台 Mac 的 Docker 位址 unix:///Users/daniel/.lima/anybot-gvisor 撐寬;把這次的改動 stash 掉一樣失敗,跟這次無關)。新測試:plan:: 7 個;agent 的計畫模式三個(只看到卡片說開始、先不要什麼都不做、修改後重交);app 的 /plan 從打字到計畫完成、Bot 從聊天加連接器(卡片不露 Token、同一輪就用它的工具算出 sum=5)、/always-approve(之前會問、之後不問直接在這台跑、陌生人的訊息照樣問、off 回原樣);mcp::manage_tests 4 個;狀態一行。截圖看過:計畫卡等你決定/照著做打勾、503 重試那一行。手機頁面 JS 語法檢查和計畫卡四種狀態的 HTML。 未驗證:真的模型走一次 /plan 和加 GitLab 連接器;手機實機;伺服器上的大腦(要 make update-server)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:55:37 +00:00
"plan": b.plan.as_ref().map(|p| json!({
"task": p.task, "stage": p.stage, "line": crate::plan::bar_text(p),
"steps": if p.stage == crate::plan::Stage::Doing { crate::plan::checklist(&p.steps) } else { String::new() },
})),
"goal": b.goal.as_ref().map(|g| json!({
"condition": g.condition, "reason": g.reason, "active": g.active(),
"line": if g.active() && self.goal_checking.contains(&b.id) { "目標 · 正在檢查有沒有達成…".to_string() } else { crate::goal::bar_text(g, crate::model::now_ms()) },
})),
}));
let start = b.messages.len().saturating_sub(remote::PHONE_TAIL);
// Each message with its place in the chat (表情回應), its thinking and, on each step,
// what came back (the desktop's 顯示步驟 / 思考過程), in short.
let results: HashMap<&str, &str> = b.messages[start..].iter().filter(|m| m.role == Role::Tool).map(|m| (m.tool_call_id.as_str(), m.text.as_str())).collect();
// 頁面 cards: once a reply, under the step that saved the page last (over the whole chat,
// so a reply cut by the tail still knows its later steps).
let cards = crate::pages::cards_by_message(&b.messages);
let msgs: Vec<serde_json::Value> = b.messages[start..]
.iter()
.enumerate()
.filter_map(|(k, m)| {
let mut v = remote::message_json(m, &names, &self.state.pages, cards.get(start + k).map(Vec::as_slice).unwrap_or(&[]))?;
v["index"] = json!(start + k);
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
// 支線: its record, for the card (and the report's label).
if m.branch != 0 {
if let Some(r) = b.branches.iter().find(|r| r.id == m.branch) {
v["branch"] = json!({"id": r.id, "task": r.task, "state": r.state, "note": r.note, "doing": r.doing, "steps": r.steps, "log": r.log, "result": r.result});
}
}
if !m.thinking.trim().is_empty() {
v["thinking"] = json!(clip(m.thinking.trim(), 1500));
}
if let Some(tools) = v["tools"].as_array_mut() {
for (t, c) in tools.iter_mut().zip(m.tool_calls.iter()) {
feat: /plan 先規劃再動手、聊天裡請 Bot 管理連接器、/always-approve 一律放行;輸入框上方的狀態不再破版 /plan(照 Claude Code 的 plan mode、Cursor 的 Plan Mode、Codex 的 update_plan) - 「/plan 要做的事」:這一輪只給會看的工具(讀檔、搜尋、web_fetch、瀏覽器的打開/讀取/捲動、截圖、anybot_guide、問題卡),在執行那一層擋下其他步驟(回「計畫還沒核准」),不是只靠提示詞。 - Bot 用 submit_plan 交計畫:聊天裡一張「計畫」卡(摘要、步驟、怎麼確認做對了、注意),下面的問題卡「照這個計畫做嗎?」:開始照計畫做/先不要/打字寫要改哪裡。 - 核准後同一輪接著做:工具全開、系統指示換成照計畫做,第 1 步自動進行中;update_plan 每做完一步更新一次(整份清單、只有一步進行中),卡上打勾、輸入框上方「照計畫做 · 2/6 · 這一步」;全部做完留「計畫完成」那一行。 - 「/plan」看狀態、「/plan clear」取消;例行任務、訊息管道、團隊成員的訊息不受影響;群組不能用;支線不帶計畫;清除聊天或新對話一起清;分享 Bot 檔不含。手機:計畫卡、計畫列、取消計畫。 - 新功能地圖 plan.md;研究(Claude Code、Codex、Cursor、Gemini CLI…)的結論寫進提示:只寫建議的做法、通常 3 到 7 步、問題最多 3 題、打勾不要太勤。 聊天裡管理連接器(設定能做的聊天也要能做) - 新工具 manage_connectors(管理 App 能力):list、add、update(含開關)、reconnect、remove。改的就是大腦上 設定 › 整合 › 連接器 那一份,不會寫到手腳電腦的檔案(進化之神之前叫使用者去 nobledesktop 的 ~/.local/share/AnyBot 設)。 - 新增、修改、移除先跳卡片:指令(在大腦上執行)或網址、環境變數、標頭;TOKEN、KEY、SECRET、PASS、AUTH… 和密碼顯示「••••(已填)」。名稱重複、command 和 url 都給、網址不對、還有「{…}」、沒東西可改,在問之前就回給 Bot。 - 加好後等它連上(最多 90 秒)再回報幾個工具或原因;一輪裡連接器的工具變了,下一步起就換新(加完同一輪就能用)。 /always-approve(也可以 /yolo) - 使用者自己打(電腦、大腦的螢幕、手機的擁有者)或 設定 › 權限 ›「一律放行」:打開直接操作,之後所有要等「允許」的都自動允許(含一律詢問規則、付款/傳送/刪除的點擊、寄信、傳訊息、打電話、發文、保險庫卡片),自動審核略過;打開時在等的卡片一起放行。 - 照樣擋:安全規則一律拒絕的;別人傳來的訊息那一輪;問題卡、需要處理、計畫卡。Bot、例行任務、訊息管道打不開;管理員和成員打的變成「【名字】/always-approve」。管理員鎖了直接操作就打不開。 - 開著時每個聊天輸入框上方一條「一律放行」和「關閉」;「/always-approve off」關掉,直接操作是它打開的就一起關。 輸入框上方的狀態 - 好幾行的狀態(模型忙碌重試:錯誤、說明、幾秒後重試)以前疊出那一列、壓到輸入框;現在一行:「模型供應商目前負載過高,15 秒後重試(第 3 次,共 3 次)…」。 已驗證:cargo test 548 通過、1 個失敗(layout_audit 的 設定 › 電腦 被這台 Mac 的 Docker 位址 unix:///Users/daniel/.lima/anybot-gvisor 撐寬;把這次的改動 stash 掉一樣失敗,跟這次無關)。新測試:plan:: 7 個;agent 的計畫模式三個(只看到卡片說開始、先不要什麼都不做、修改後重交);app 的 /plan 從打字到計畫完成、Bot 從聊天加連接器(卡片不露 Token、同一輪就用它的工具算出 sum=5)、/always-approve(之前會問、之後不問直接在這台跑、陌生人的訊息照樣問、off 回原樣);mcp::manage_tests 4 個;狀態一行。截圖看過:計畫卡等你決定/照著做打勾、503 重試那一行。手機頁面 JS 語法檢查和計畫卡四種狀態的 HTML。 未驗證:真的模型走一次 /plan 和加 GitLab 連接器;手機實機;伺服器上的大腦(要 make update-server)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:55:37 +00:00
if t["plan"].is_object() {
let (state, live) = super::plan_ui::plan_card_state(b, c);
t["plan"]["state"] = state;
t["plan"]["live"] = live;
continue;
}
if t.get("talk").is_some() {
if let Some(r) = results.get(c.id.as_str()) {
t["talk"]["answer"] = json!(clip(r.trim(), 2000));
}
continue;
}
if t.get("label").is_some() {
t["name"] = json!(c.name);
if let Some(r) = results.get(c.id.as_str()) {
feat: 紀錄檔、當掉報告、秘密遮罩 參考 xai-org/grok-build(每個 session 的 debug log、xai-crash-handler、xai-grok-secrets 的 sanitizer)。工程基礎計畫的 E2–E4。 - 紀錄檔(logfile.rs):AnyBot 自己說的話寫到資料夾的 logs/anybot-YYYY-MM-DD.log(時間、等級、來源;一天一個、留 7 天、一天上限 20 MB),終端機照舊印,伺服器的 docker logs 不變。ANYBOT_LOG 設等級(預設 info),其他套件只收 warn 以上。36 個執行中的 eprintln! 改成 log::info!/warn!/error!;終端機給人看的(用法、setup 的 ✗、更新進度、截圖、測試)照舊。cargo test 不開紀錄檔。 - 當掉報告:panic hook 寫 logs/crash-時間.txt(版本、執行緒、位置、訊息、backtrace);下次打開在主要 Bot 的聊天留一行並記進待改進,每份只說一次(改名 .seen.txt);螢幕電腦跳提示。 - 秘密遮罩(secrets.rs):glpat-、ghp_/github_pat_、sk-、xai-、AKIA/ASIA、xox、AIza、私鑰區塊、Bearer/Basic、JWT,名字像 TOKEN/SECRET/PASSWORD/API_KEY 的變數值 → ••••(留前綴)。用在紀錄檔、當掉報告、手機上的步驟細節和結果。工作紀錄(oplog)不遮:當掉後要照原本的參數重做;Bot 看到的不遮。 - regex、log 改成直接相依(本來就在建置裡,沒有新的下載)。 已驗證:cargo test 557 全過;新測試 secrets:: 3 個(每種格式、變數名留著、一般文字不動)、logfile:: 4 個(等級和來源、一行的格式和遮罩、每天換檔/上限只說一次/七天前的刪掉、當掉報告遮過且只說一次)。隔離的 --serve(沒有金鑰、DOCKER_HOST 指向不存在、自己的 HOME 和資料夾)跑 10 秒:logs/anybot-2026-11-17.log 有啟動版本、手機密碼提醒、記憶整理、收到停止訊號四行,終端機一樣。 未驗證:真的 panic 寫出報告後重開看到那一行(測試直接呼叫寫報告和讀報告的函式,沒有讓程式真的當掉)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:09:13 +00:00
// (秘密遮罩: what a step printed may hold a key; the phone shows it masked.)
t["result"] = json!(clip(&crate::secrets::mask(r.trim()), 600));
}
}
}
}
Some(v)
})
.collect();
view.messages.insert(b.id, msgs);
if let Some(a) = self.approvals.get(&b.id) {
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
view.approvals.push(approval_json(b, a, self.ask_keys.get(&b.id).map(String::as_str).unwrap_or("")));
}
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
// A 支線's step waiting for a yes: shown in its main bot's chat, answered for it.
for br in self.state.branch_bots.iter().filter(|x| x.branch_of == b.id) {
if let Some(a) = self.approvals.get(&br.id) {
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
let mut j = approval_json(br, a, self.ask_keys.get(&br.id).map(String::as_str).unwrap_or(""));
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
j["bot"] = json!(b.id);
j["target"] = json!(br.id);
j["title"] = json!(format!("支線:{}", j["title"].as_str().unwrap_or("")));
view.approvals.push(j);
}
}
}
view.pages = self.state.pages.clone();
// The models a bot can be switched to from the phone: each provider that is ready.
view.models = crate::providers::ALL_PROVIDERS
.iter()
feat: ChatGPT 方案——用 ChatGPT 帳號登入,Bot 用你 ChatGPT 方案的額度,不用 API 金鑰 - 新供應商「ChatGPT 方案」(src/chatgpt.rs):照 OpenAI 給開源 App 的 Sign in with ChatGPT。 第一次登入註冊 AnyBot(dynamic_agent_client → oaiapp_…)並重用;PKCE、state、nonce; ID token 驗 RS256 簽章、iss、aud、exp、nonce;沒同意使用方案算登入但不能用(再登入會要求同意)。 - 要求走 Responses API(api.openai.com/v1/responses,store:false、stream:true、instructions), token 只送 OpenAI 自己的網址;收到 response.completed 才算完成;額度用完停下來給管理用量連結, 不重試、不改用 API 金鑰。token 快到期或 401 時更新(一次一個,refresh token 會輪替)。 - 設定 › 模型 › ChatGPT 方案:使用 ChatGPT 繼續、登出、換帳號、打開登入頁、管理用量; 連到伺服器大腦的螢幕電腦和手機也能登入(登入頁開在自己這台,打不開的那頁網址貼回給大腦)。 - Bot 工具 chatgpt_login(status、login、logout、switch_account;登出和換帳號先問)。 - 修連接器登入:封存的 token 前綴寫錯("sealed:" 實際是 "enc:v1:"),重開 App 後 token 沒解開就被當成憑證送出,登入等於每次重開都失效。 已驗證: cargo test 全綠(chatgpt::、providers::、appctl::、remote::、mcp_oauth::、featuremap::、layout_audit::); 授權網址的參數送到 auth.openai.com 沒被拒(302 到登入頁)。 未驗證: 實際用 ChatGPT 帳號登入、同意、Responses 串流與工具呼叫(要真的 ChatGPT 付費帳號和瀏覽器); 螢幕電腦貼回網址、手機登入(要實機);Windows 的「打開登入頁」。 動到審批路徑(appctl::needs_approval 的 chatgpt_login):需要實機測試+人類簽名。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:23:10 +00:00
.filter(|&&k| crate::providers::ready(k, &self.state.provider(k).api_key))
// Only models that chat: an image or video generator picked for a bot would break it.
.map(|&k| json!({"provider": serde_json::to_value(k).unwrap_or_default(), "label": k.label(), "models": self.models_for(k).into_iter().filter(|m| chats(m)).collect::<Vec<_>>()}))
.collect();
remote::hub().publish(view);
}
Voice: its own 設定 › 語音, run by the brain for every screen and the phone Voice was three implementations that broke on their own: speech to text borrowed the OpenAI key (so with only Grok set up the mic recorded, then failed), OpenAI's models it hard-coded stop on 2027-02-26, read aloud was macOS `say` or espeak-ng (silently nothing on Windows, where espeak isn't installed), and the phone used the browser's own recognition. Now: - 設定 › 語音 has 聽 and 說, each a service: off, OpenAI-compatible (OpenAI, Groq, a Whisper server of your own: the address decides), xAI or ElevenLabs. An empty key borrows 設定 › 模型's for the same service. Each side says 可以用 or what it lacks; 聽 has 試試看 (record a sentence, show what was heard), 說 has 試聽 and the voice list. speech.rs does the calls; xAI's both ways were checked for real (Mandarin read, then heard back, in Traditional characters). - The brain does it all: the phone POSTs its recording (MediaRecorder) to /api/voice/transcribe, screens to /api/sync/voice/transcribe; answers come back as MP3 from …/voice/speech and are played on the device (rodio; an <audio> on the phone, 「唸出來」 in a message's menu). Keys stay on the brain (the voice keys are redacted for screens like the others). - No service, no voice anywhere: the mic, 語音聊天, 會議錄音 and 朗讀 only appear once 聽 (and 說) can be called; the phone's state says which. Without voice the send arrow just rests where 語音聊天 was. - 會議錄音 is uploaded to the brain, which turns it into text in the background and hands it to the bot itself: a meeting is longer than the 35 s the account lets a request wait, and a brain on a server has no window (the jobs are polled in background()). - Recognisers answer Mandarin in Simplified: in a Traditional Chinese window or phone the text becomes Traditional with Taiwan wording. - Older saves: whoever had an OpenAI key keeps voice input (聽 = OpenAI); everyone else starts with it off. Bots' macOS voice names are cleared. 對話詳細資訊's 加入會議 started plain voice input; it starts a meeting now.
2026-11-10 14:58:18 +00:00
pub(super) fn remote_cmd(&mut self, ctx: &egui::Context, c: Cmd) {
match c {
Voice: its own 設定 › 語音, run by the brain for every screen and the phone Voice was three implementations that broke on their own: speech to text borrowed the OpenAI key (so with only Grok set up the mic recorded, then failed), OpenAI's models it hard-coded stop on 2027-02-26, read aloud was macOS `say` or espeak-ng (silently nothing on Windows, where espeak isn't installed), and the phone used the browser's own recognition. Now: - 設定 › 語音 has 聽 and 說, each a service: off, OpenAI-compatible (OpenAI, Groq, a Whisper server of your own: the address decides), xAI or ElevenLabs. An empty key borrows 設定 › 模型's for the same service. Each side says 可以用 or what it lacks; 聽 has 試試看 (record a sentence, show what was heard), 說 has 試聽 and the voice list. speech.rs does the calls; xAI's both ways were checked for real (Mandarin read, then heard back, in Traditional characters). - The brain does it all: the phone POSTs its recording (MediaRecorder) to /api/voice/transcribe, screens to /api/sync/voice/transcribe; answers come back as MP3 from …/voice/speech and are played on the device (rodio; an <audio> on the phone, 「唸出來」 in a message's menu). Keys stay on the brain (the voice keys are redacted for screens like the others). - No service, no voice anywhere: the mic, 語音聊天, 會議錄音 and 朗讀 only appear once 聽 (and 說) can be called; the phone's state says which. Without voice the send arrow just rests where 語音聊天 was. - 會議錄音 is uploaded to the brain, which turns it into text in the background and hands it to the bot itself: a meeting is longer than the 35 s the account lets a request wait, and a brain on a server has no window (the jobs are polled in background()). - Recognisers answer Mandarin in Simplified: in a Traditional Chinese window or phone the text becomes Traditional with Taiwan wording. - Older saves: whoever had an OpenAI key keeps voice input (聽 = OpenAI); everyone else starts with it off. Bots' macOS voice names are cleared. 對話詳細資訊's 加入會議 started plain voice input; it starts a meeting now.
2026-11-10 14:58:18 +00:00
Cmd::Meeting { bot, path, lang } => {
// Only a recording the app itself stored (uploaded into its attachments).
let root = crate::model::State::path().parent().map(|p| p.join("attachments")).and_then(|p| p.canonicalize().ok());
match (std::path::Path::new(&path).canonicalize().ok(), root) {
(Some(f), Some(root)) if f.starts_with(&root) && f.is_file() => self.meeting_job(bot, f, lang, true),
_ => {}
}
}
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
Cmd::Send { bot, text, attachments, from, memories, member } => {
if self.state.bot(bot).is_none() {
return;
}
// Typed on one of the account's computers: that one is the person's now (for
// 「我的電腦」 and the model on their network). The phone isn't a computer.
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
if !from.is_empty() && !member {
remote::set_person_host(&from);
// A computer this brain hasn't heard of yet (it just came on): look the
// account's computers up now, or its 「我的電腦」 wouldn't be known for a minute.
if !self.rm.peers.lock().unwrap().iter().any(|(id, _, online)| *id == from && *online) {
let v = remote::devices_online(&self.state.remote);
if !v.is_empty() {
*self.rm.peers.lock().unwrap() = v;
}
self.rm.peers_at = Some(Instant::now());
}
self.typed_on = Some(from);
}
// Only files the app itself stored in its attachments folder may ride along;
// resolve first, so "../../" paths cannot escape it (the phone can name any path).
let root = crate::model::State::path().parent().map(|p| p.join("attachments")).and_then(|p| p.canonicalize().ok());
let atts: Vec<crate::attach::Attachment> = attachments
.iter()
.filter_map(|p| {
let f = std::path::Path::new(p).canonicalize().ok()?;
if !root.as_ref().map(|r| f.starts_with(r) && f.is_file()).unwrap_or(false) {
return None;
}
let meta = std::fs::metadata(&f).ok()?;
let file = f.file_name()?.to_string_lossy().to_string();
let name = file.split_once('-').map(|x| x.1.to_string()).unwrap_or(file);
// Also on the bot's own computer, where it works (a brain on a server
// has no other computer of its own to read it from).
let on_box = crate::cloudbox::copy_in(&f.display().to_string(), bot, &name).unwrap_or_default();
Some(crate::attach::Attachment { image: crate::attach::is_image_name(&name), name, path: f.display().to_string(), bytes: meta.len(), on_box })
})
.collect();
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
// 目標: 「/goal …」 is AnyBot's, not the bot's (owner/admin only); anything else takes a paused goal up again.
if !member {
// AnyBot's own commands from the phone or a screen (commands.rs): the owner's
// only (a teammate's words arrive as 「【名字】…」, never a command). A
// /doctor from there: the brain checks itself.
if let Some(cmd) = self.command_for(bot, &text) {
self.run_app_command(ctx, bot, cmd, &text, atts, memories);
feat: /doctor 診斷這台電腦:連線、Tailscale 直連還是中繼、大腦、模型服務、Bot 的電腦、連接器、磁碟、上次出錯 工程基礎計畫 E11(grok-build 的 /doctor)。早上「連不到大腦」花了半小時用指令查出是 Tailscale 走香港中繼,現在打一句就看得到。 - doctor.rs:報告的樣子(一項一行 ✓/✗,最後數有幾項要看);帳號伺服器網址是 *.ts.net 時跑 tailscale ping,讀出是直連還是走哪個中繼(走中繼寫延遲和「多半是中間擋了 UDP 41641」);df 看磁碟;找最新的當掉報告。 - app/doctor_ui.rs:當下就知道的(版本、資料夾、紀錄檔、這台 ↔ 帳號伺服器、帳號伺服器 ↔ 大腦、螢幕連不連得到大腦和原因、上次同步的大小和速度、Bot 的電腦、每個開著的連接器、磁碟少於 2 GB、上次出錯),要上網的在背景跑(Tailscale、每個 Bot 用到的模型服務列模型清單),好了在聊天留一行。 - 在連到大腦的螢幕電腦上:/doctor 在連不到大腦的檢查之前就處理,檢查的是這台本身,結果跳成提示(那個聊天是大腦的)。手機打的是大腦檢查自己。 - / 清單、手機的指令清單多一個 doctor;功能地圖 garden.md、chat.md,FEATURES.md。 已驗證:cargo test 全過、clippy -D warnings 過。新測試:報告的格式和計數;tailscale ping 的直連和中繼兩種輸出(用今天早上這台真的輸出「via DERP(hkg) in 63ms」);最新的當掉報告、磁碟;從聊天打 /doctor 先說「診斷中」、再一份報告(模型服務指向測試用的假模型)。 未驗證:螢幕電腦上真的跑一次(要更新這台 App)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:48:01 +00:00
return;
}
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
self.goal_heard(bot);
}
A turn cut off by a crash leaves a 「繼續」 card, and nothing it may have done runs twice Each bot keeps a work log (oplog/bot-<id>.jsonl, after pi's durable-harness design, cut down): before something happens a line says it is about to — the turn, each model call, each step once its checks passed (with the arguments it runs with and whether it may run again), each message typed mid-turn — synced to disk first. When the turn ends the file shrinks to the messages still waiting, usually nothing. On the next start after AnyBot was killed mid-turn, the log puts the chat right before anything runs: the message the turn answered comes back if the chat lost it; a step that was running and reaches outside (a text, a click, a file, a published site) shows as 「可能已經執行了」, both to the person and in the result the bot reads — no longer as "not allowed"; a step that only looked shows as cut off; messages typed mid-turn that never reached the bot go back into the chat. The chat is saved, then the log closes the turn. A turn the person didn't stop ends with a 「繼續」 card (what it was doing, what may have run, the messages put back); it goes on only when they press it — in the window, on a screen of the brain, or on the phone — from where its steps stand, never running a step that may have run again. Pressing stop is on disk at once, and a stopped turn stays stopped. Also in the turn loop: - 自動審核 that doesn't answer (or answers something that isn't a verdict) asks the person; in 直接操作 mode it used to let the step through unchecked. - "Too long for this model" folds older messages into a summary and asks the same step again, once per thing the person said, instead of ending the turn. - Folding keeps the person's chat whole: the summary goes in at the fold and the model reads from the newest summary on (it used to delete what it folded). - A step moved to the chosen computer runs there, but the chat keeps the call as the model wrote it; the result says where it ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5F5gJt93t3yEx3XcS
2026-11-08 16:49:12 +00:00
if self.streams.contains_key(&bot) {
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
if !member {
Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等 問同事(ask_bot) - A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A - 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停 - message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定) 群組 @點名 - 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則) - 電腦和手機的輸入框打 @ 會列出成員 - 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的 共用資源 - Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改) - 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶 - teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能 修正 - 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著 - 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉) - 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉 - 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著 - Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話 - 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 13:34:03 +00:00
self.queue_steer(bot, text, atts);
} else if self.waiting_wakes.iter().filter(|(b, _)| *b == bot).count() < MAX_WAITING_FROM_MEMBERS {
// A teammate's words never go into the owner's running turn (they are
// not the owner's): they get a turn of their own once the bot is free.
// (They used to be dropped without a word.)
let mut m = super::person_message(&self.state, bot, &text, atts, Some(vec![]));
m.untrusted_sender = true;
self.waiting_wakes.push((bot, m));
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
}
return;
}
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
let mut m = super::person_message(&self.state, bot, &text, atts, if member { Some(vec![]) } else { memories });
m.untrusted_sender = member;
if let Some(b) = self.state.bot_mut(bot) {
記憶: a page to see it, a few lines picked while typing, a local model The memory had grown into a list carried whole, a top-14 recalled by a trigram index and pasted into the system prompt with the clock, and a page that broke its own layout. Nobody could see what went to the model, the prompt cache missed every message, and 「記住」 kept saying the same thing twice. Rebuilt per the spec (docs/memory.md): - Three kinds in memory.db: 記得的事 (fact), 做過的事 (event, a line per finished turn), 整理過的 (rollup). Each keeps pinned, uses, last_used, deleted, superseded_by, span. state.json keeps the facts as the copy that syncs; the page reads SQLite. - Search: jieba words ∪ CJK bigrams in an FTS5 unicode61 table (Traditional text goes through Simplified first), weighted share of query terms hit; plus local vectors, vec = clamp((cos−0.35)/0.35). score = max + 0.15×min, events ×0.9. ≥0.15 suggested, ≥0.5 ticked, ≥0.55 carried when nobody chose (3 at most). - What the model gets: the system prompt has the time zone and the pinned memories only, the same every turn. Each person message gets 〔送出時間〕 and 〔相關記憶〕 from Message.memories, built in group_history into a transient Message.context, so the beginning of a chat reads the same next turn (cache hits) and the event log, skills and audit see only what was typed. A memory already carried in view isn't carried again; each carry counts a use. - Picks travel with the message: Cmd::Send / POST send / sync act "memories" (empty = none; absent = the brain chooses, once, saved). - remember finds the like one (cos ≥ 0.85 or the same words) and asks for `replaces`; the old one is superseded, never carried. A fact forgotten and remembered again comes back. New search_memory (query, kind), with dates; read-only. - Nightly on the brain, no model: events past 30 days fold into a line per week (「11/3–11/9 做過的事(14 件):整理照片 ×3…」, ≤400 chars, like with like by words or vectors), weeks past 180 days into months; the folded go to 最近刪除 for 30 days. Facts are never removed. The page offers duplicates, facts unused for half a year, and what can fold now. - Local model: minishlab/potion-multilingual-128M through m2v.rs (same token ids as model2vec-rs on 13/13 sentences, cos ≥ 0.9999, without tokenizers' 1.1 GB). Converted while downloading: vocab.bin, table.i8 (int8 + row scales), dims.json, 137 MB kept of 530 MB; ANYBOT_HF_BASE picks a mirror (now passed into the server's brain container too). Loaded when first needed (34 ms), let go after 10 idle minutes. The brain loads it; a screen only with a document folder set; hands and phones never. 設定 › 一般 › 語意搜尋: 本機模型/Ollama/關閉; a new engine clears every vector. - Three files, three connections: memory.db (backed up nightly, 7 kept), docs.db (a cache), oplog/audit.db (30 days). An old audit.db hands its memories and documents over once and shrinks (a real one: 172 MB → 16 KB). docs_search scans every chunk now, vectors cached in RAM (it stopped at 8000); FTS optimize + VACUUM daily (260 MB of tombstones over 31 MB of text). - API: POST /api/memory (owner) and /api/sync/memory (mirror). Reads answer on the HTTP thread; writes go through phone_act("memory"). - Screens: a memory dialog (Bot menu 記憶…, Bot settings 打開記憶) with counts, live search, filters, suggestions, per-item kind/date/uses and pin/edit/forget/restore; chips above the composer 300 ms after typing stops, with a token estimate; 「帶了 N 條記憶」 under person messages. The phone has the same as a 記憶 tab, chips and tag. Checked: make test passes (app 297, relay 16), with new tests for the scores and thresholds, Traditional Chinese segmentation, remember's dedupe and replaces, two turns sending the same beginning, no double carry, weekly/monthly folding and the trash, and the audit.db move. Brain idle 37 MB as before, ~230 MB with the model loaded; search on the brain 0.2–0.5 ms, 7–44 ms from the phone page. A deadlock found on the way (stats re-taking the lock) is fixed and tested. Docs: docs/memory.md has the whole design; FEATURES.md, protocol, architecture (zh/en), multi-device and install say what changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3SYw9JJ9dXwaNvYh4
2026-11-10 23:46:50 +00:00
b.messages.push(m);
}
self.start_reply(ctx, bot);
}
Cmd::Stop { bot } => self.stop(bot),
// The server's own zone (UTC) was never the person's choice: take theirs. A zone the
// person set on purpose stays.
Cmd::PersonTimezone(tz) => {
if crate::routines::is_server_default_zone(&self.state.timezone) && tz != self.state.timezone {
self.state.timezone = tz;
self.mark();
}
}
Cmd::SetBot { bot, provider, model, computer } => {
let kind = serde_json::from_value::<crate::providers::ProviderKind>(json!(provider)).ok();
if let (Some(k), false) = (kind, model.is_empty()) {
if let Some(b) = self.state.bot_mut(bot) {
b.provider = k;
b.model = model;
}
self.mark();
}
if !computer.is_empty() {
let _ = self.update_bot_computer(bot, &json!({"default_computer": computer}).to_string());
self.mark();
}
}
Cmd::Regenerate { bot } => self.regenerate(ctx, bot),
Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等 問同事(ask_bot) - A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A - 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停 - message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定) 群組 @點名 - 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則) - 電腦和手機的輸入框打 @ 會列出成員 - 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的 共用資源 - Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改) - 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶 - teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能 修正 - 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著 - 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉) - 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉 - 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著 - Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話 - 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 13:34:03 +00:00
Cmd::RestoreAnswer { bot } => self.restore_regenerated(bot),
Cmd::Reply { bot } => {
if !self.streams.contains_key(&bot) && self.state.bot(bot).and_then(|b| b.messages.last()).map(|m| m.role == Role::User).unwrap_or(false) {
self.start_reply(ctx, bot);
}
}
A turn cut off by a crash leaves a 「繼續」 card, and nothing it may have done runs twice Each bot keeps a work log (oplog/bot-<id>.jsonl, after pi's durable-harness design, cut down): before something happens a line says it is about to — the turn, each model call, each step once its checks passed (with the arguments it runs with and whether it may run again), each message typed mid-turn — synced to disk first. When the turn ends the file shrinks to the messages still waiting, usually nothing. On the next start after AnyBot was killed mid-turn, the log puts the chat right before anything runs: the message the turn answered comes back if the chat lost it; a step that was running and reaches outside (a text, a click, a file, a published site) shows as 「可能已經執行了」, both to the person and in the result the bot reads — no longer as "not allowed"; a step that only looked shows as cut off; messages typed mid-turn that never reached the bot go back into the chat. The chat is saved, then the log closes the turn. A turn the person didn't stop ends with a 「繼續」 card (what it was doing, what may have run, the messages put back); it goes on only when they press it — in the window, on a screen of the brain, or on the phone — from where its steps stand, never running a step that may have run again. Pressing stop is on disk at once, and a stopped turn stays stopped. Also in the turn loop: - 自動審核 that doesn't answer (or answers something that isn't a verdict) asks the person; in 直接操作 mode it used to let the step through unchecked. - "Too long for this model" folds older messages into a summary and asks the same step again, once per thing the person said, instead of ending the turn. - Folding keeps the person's chat whole: the summary goes in at the fold and the model reads from the newest summary on (it used to delete what it folded). - A step moved to the chosen computer runs there, but the chat keeps the call as the model wrote it; the result says where it ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5F5gJt93t3yEx3XcS
2026-11-08 16:49:12 +00:00
Cmd::Resume { bot } => self.resume_turn(ctx, bot),
Cmd::RestoreThread { bot, index } => {
self.stop(bot);
if let Some(b) = self.state.bot_mut(bot) {
if index < b.threads.len() {
let (_, msgs) = b.threads.remove(index);
if !b.messages.is_empty() {
let title = b.messages.iter().find(|m| m.role == Role::User).map(|m| first_line(&m.text, 24)).unwrap_or_else(|| "對話".into());
let cur = std::mem::take(&mut b.messages);
b.threads.insert(0, (title, cur));
}
b.messages = msgs;
}
}
self.mark();
}
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
Cmd::Answer { bot, answer, text, call, notice } => {
// Only the card it was given for: every answer from afar (the phone's card, a
// notification, a screen) names its card by the key on_new_approval gave it. A
// card answered, gone or replaced since — or a page too old to name one — takes
// nothing (it used to answer whatever waited by then: an 允許 for one step went
// to the next, and 一律允許 remembered the next one's kind).
let waiting = self.approvals.get(&bot);
let this_card = waiting.is_some() && !call.is_empty() && self.ask_keys.get(&bot) == Some(&call);
// A notification's 允許/拒絕 only on a card notice_answers gave the buttons to:
// never 「我完成了」 on a hand-off or 「略過」 on a question, whatever the key.
let fits = !notice || (waiting.is_some_and(super::notice_answers) && matches!(answer.as_str(), "once" | "reject"));
if !(this_card && fits) {
// (Said only while something waits: with nothing waiting the answer was for a
// card already settled — 直接操作 just let it through, say.)
if waiting.is_some() {
let note = if notice { "通知上的「允許/拒絕」沒有用上:那個請求已經不在等了(回答過,或換成了別的)。打開聊天看現在在等什麼。" } else { "手機(或螢幕電腦)上的回答沒有用上:那張卡已經不在等了(回答過,或換成了別的),或那個頁面太舊。重新整理,看現在在等什麼再回答。" };
self.goal_note(bot, note);
}
return;
}
let grant = self.approvals.get(&bot).map(|a| a.grant.clone()).unwrap_or_default();
問題卡、搜尋: the bot asks with a card; every chat is searched; a refusal holds for the turn - 問題卡 (ask_person, src/ask.rs): up to 6 questions on a card above the input, one at a time — a choice (one click moves on), several choices, or a field that arrives filled for the person to correct; 「自己回答」 on every question, 上一題 and 略過. The turn waits; a message typed instead leaves the card unanswered. Travels as an approval of kind Question (questions as JSON) with a new answer Answered, so the window, a screen of another brain and the phone draw the same card. - 搜尋所有聊天 (src/find.rs): the sidebar's search also lists what the person and the bots said in every chat, past conversations included, and attachment names; newest first, 40 at most. A click opens the bot (bringing a past conversation back first), scrolls to the message and lights it for a moment. - 拒絕後停下: a step the person refused is refused for them when it comes back unchanged in the same turn — no second card, no second review — until they write again. - The bot's instructions: stop after a refusal instead of trying another way; before sending, posting, buying or deleting, check the person's own messages asked for exactly that, and ask with the card when they didn't. - 直接操作 no longer answers a hand-off (or a question) on the person's behalf. - The repeated-step check leaves questions to the person alone. - Screenshot views `ask` and `find`; FEATURES.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
2026-11-12 02:17:32 +00:00
let question = self.approvals.get(&bot).is_some_and(|a| a.kind == ApprovalKind::Question);
let a = match answer.as_str() {
問題卡、搜尋: the bot asks with a card; every chat is searched; a refusal holds for the turn - 問題卡 (ask_person, src/ask.rs): up to 6 questions on a card above the input, one at a time — a choice (one click moves on), several choices, or a field that arrives filled for the person to correct; 「自己回答」 on every question, 上一題 and 略過. The turn waits; a message typed instead leaves the card unanswered. Travels as an approval of kind Question (questions as JSON) with a new answer Answered, so the window, a screen of another brain and the phone draw the same card. - 搜尋所有聊天 (src/find.rs): the sidebar's search also lists what the person and the bots said in every chat, past conversations included, and attachment names; newest first, 40 at most. A click opens the bot (bringing a past conversation back first), scrolls to the message and lights it for a moment. - 拒絕後停下: a step the person refused is refused for them when it comes back unchanged in the same turn — no second card, no second review — until they write again. - The bot's instructions: stop after a refusal instead of trying another way; before sending, posting, buying or deleting, check the person's own messages asked for exactly that, and ask with the card when they didn't. - 直接操作 no longer answers a hand-off (or a question) on the person's behalf. - The repeated-step check leaves questions to the person alone. - Screenshot views `ask` and `find`; FEATURES.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
2026-11-12 02:17:32 +00:00
// (Only a question takes an answer in words, and nothing else answers one.)
"answered" if question => ApprovalAnswer::Answered(text),
_ if question => ApprovalAnswer::Reject,
"once" => ApprovalAnswer::Once,
"always" => ApprovalAnswer::Always(grant),
_ => ApprovalAnswer::Reject,
};
self.answer(ctx, bot, a);
}
Cmd::Read { bot } => {
if let Some(b) = self.state.bot_mut(bot) {
if b.unread {
b.unread = false;
self.mark();
}
}
}
Cmd::Clear { bot } => {
self.goal_drop(bot);
self.stop(bot);
if let Some(b) = self.state.bot_mut(bot) {
b.messages.clear();
}
self.mark();
}
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
Cmd::RunRoutine { bot, routine } => {
let now = crate::routines::now();
let mut wake = None;
if let Some(b) = self.state.bot_mut(bot) {
if let Some(r) = b.routines.iter_mut().find(|r| r.id == routine) {
r.last_run = Some(now);
wake = Some(appctl::wake_message(r));
}
}
if let Some(m) = wake {
self.wake(ctx, bot, m);
self.mark();
}
}
Cmd::NewThread { bot } => {
self.goal_drop(bot);
self.stop(bot);
if let Some(b) = self.state.bot_mut(bot) {
if !b.messages.is_empty() {
let title = b.messages.iter().find(|m| m.role == Role::User).map(|m| first_line(&m.text, 24)).unwrap_or_else(|| "對話".into());
let msgs = std::mem::take(&mut b.messages);
b.threads.insert(0, (title, msgs));
b.threads.truncate(50);
}
}
self.mark();
}
Cmd::DeviceAdded(d) => {
self.state.remote.devices.push(d);
self.mark();
}
Cmd::DeviceSeen(h) => {
if let Some(gone) = h.strip_prefix('-') {
self.state.remote.devices.retain(|d| d.token_hash != gone);
self.mark();
} else if !self.rm.last_seen_mark.map(|t| t.elapsed().as_secs() < 60).unwrap_or(false) {
self.rm.last_seen_mark = Some(Instant::now());
if let Some(d) = self.state.remote.devices.iter_mut().find(|d| d.token_hash == h) {
d.last_seen = chrono::Utc::now().timestamp();
self.mark();
}
}
}
}
}
/// 登入後同步: the account's bots and this computer's become one set.
/// • Another AnyBot of the account is the brain → show it, and copy this computer's bots
/// there (once it answers; bots it already has are skipped).
/// • This one is the only one → take in the backup's bots it doesn't have, then back up
/// the whole set, so the account has this computer's bots too.
fn account_sync(&mut self, found: remote::AccountFind) {
if let Some((id, name)) = found.brain {
*self.rm.note.lock().unwrap() = format!("已登入,改用「{name}」當大腦:那邊的 Bot 會同步過來,這台的也會搬過去");
self.mir.want = Some((id, name));
self.mir.move_after_join = true;
// The brain's bots may use this computer (each action still asks).
self.state.remote.device_link = true;
return;
}
let got = found.backup.and_then(|b| serde_json::from_slice::<State>(&b).ok());
let n = got.map(|st| self.state.take_in_bots(&st)).unwrap_or(0);
*self.rm.note.lock().unwrap() = if n > 0 { format!("已登入,帳號裡的 {n} 個 Bot 已同步到這台") } else { "已登入,這台 AnyBot 已加入帳號".into() };
if !self.state.bots.is_empty() && self.state.remote.auto_backup {
self.remote_backup();
}
}
fn remote_backup(&mut self) {
if self.rm.busy.swap(true, Ordering::SeqCst) {
return;
}
self.state.remote.last_backup = chrono::Utc::now().timestamp();
self.mark();
let s = self.state.remote.clone();
let mut st = self.state.clone();
// The backup is for the bots; this computer's own keys to the relay and phones stay here.
st.remote = Default::default();
let bytes = serde_json::to_vec(&st).unwrap_or_default();
let (note, busy) = (self.rm.note.clone(), self.rm.busy.clone());
std::thread::spawn(move || {
*note.lock().unwrap() = match remote::backup_now(&s, &bytes) {
Ok(n) => format!("已備份({},已加密)", crate::cloudbox::human(n as u64)),
Err(e) => e,
};
busy.store(false, Ordering::SeqCst);
});
}
pub(super) fn remote_page(&mut self, ui: &mut egui::Ui, _ctx: &egui::Context) {
let p = self.pal;
let mut changed = false;
setting_card(ui, p, |ui| {
setting_title(ui, "手機與帳號", "在手機上和 Bot 聊天、核准它要做的事、看著它的電腦。", p);
hint(ui, "兩種連法:同一個網路(或 Tailscale)直接連這台電腦;或登入帳號,透過你的帳號伺服器從任何地方連,這台電腦不用開放任何連接埠。", p);
});
// ── 帳號(薄後端) ──
setting_card(ui, p, |ui| {
setting_title(ui, "AnyBot 帳號", "帳號伺服器保管帳號、裝置清單和加密備份,手機從外面連進來也靠它轉送。", p);
let s = &self.state.remote;
if !s.host_token.is_empty() {
let status = remote::hub().relay_status();
ui.horizontal(|ui| {
let ok = status == "已連線";
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.0, if ok { p.up } else { p.text3 });
ui.label(RichText::new(format!("{} · {}", s.relay_user, s.relay_url)).size(FONT_BASE));
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(if status.is_empty() { "—".to_string() } else { status }).size(FONT_XS).color(p.text3));
});
hint(ui, format!("手機打開 {} 用同一個帳號登入就能用。可以「加入主畫面」當成 App。", s.relay_url), p);
ui.add_space(4.0);
ui.horizontal(|ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("這台電腦在手機上叫")).size(FONT_SM).color(p.text2));
if ui.add(egui::TextEdit::singleline(&mut self.state.remote.host_name).desired_width(180.0)).lost_focus() {
changed = true;
}
});
if ui.checkbox(&mut self.state.remote.auto_backup, t("每天自動備份到帳號(加密,金鑰由你的密碼產生,伺服器打不開)")).changed() {
changed = true;
}
ui.horizontal(|ui| {
let busy = self.rm.busy.load(Ordering::SeqCst);
if ui.add_enabled(!busy, secondary_button(if busy { "備份中…" } else { "立刻備份" })).clicked() {
self.remote_backup();
}
if self.state.remote.last_backup > 0 {
let t = chrono::DateTime::from_timestamp(self.state.remote.last_backup, 0).map(|d| d.with_timezone(&chrono::Local).format("%m/%d %H:%M").to_string()).unwrap_or_default();
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(format!("上次備份 {t}")).size(FONT_XS).color(p.text3));
}
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("登出帳號")).size(FONT_SM).color(p.danger)).frame(false)).clicked() {
let keep_name = self.state.remote.host_name.clone();
// Say goodbye to the account server: the machine's registration is
// removed, so its key dies with the sign-out.
let (url, token) = (self.state.remote.relay_url.clone(), self.state.remote.host_token.clone());
if !url.is_empty() && !token.is_empty() {
std::thread::spawn(move || {
let _ = remote::relay_post(&format!("{url}/relay/host/remove"), &token, &serde_json::json!({}));
});
}
let s = &mut self.state.remote;
s.host_id.clear();
s.host_token.clear();
s.backup_key.clear();
s.host_name = keep_name;
changed = true;
}
});
});
} else {
let busy = self.rm.join_rx.is_some();
form_row(ui, "帳號伺服器", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.relay_url).hint_text(t("https://anybot.你的網域")).desired_width(f32::INFINITY));
});
form_row(ui, "帳號", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.user).desired_width(f32::INFINITY));
});
form_row(ui, "密碼", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.pass).password(true).desired_width(f32::INFINITY));
});
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
if self.rm.need_code {
form_row(ui, "驗證碼", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.code).hint_text(t("驗證器 App 的六位碼,或一組恢復碼")).desired_width(f32::INFINITY));
});
}
ui.checkbox(&mut self.rm.create, t("建立新帳號"));
if self.rm.create {
form_row(ui, "邀請碼", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.invite).hint_text(t("伺服器設定了才需要")).desired_width(f32::INFINITY));
});
}
ui.horizontal(|ui| {
let ready = !self.rm.relay_url.trim().is_empty() && !self.rm.user.trim().is_empty() && self.rm.pass.len() >= 8;
if ui.add_enabled(ready && !busy, primary_button(if busy { "連線中…" } else if self.rm.create { "建立並登入" } else { "登入" }, p)).clicked() {
let (tx, rx) = channel();
self.rm.join_rx = Some(rx);
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
let (url, user, pass, create, invite, base, code) = (self.rm.relay_url.clone(), self.rm.user.trim().to_string(), self.rm.pass.clone(), self.rm.create, self.rm.invite.clone(), self.state.remote.clone(), self.rm.code.clone());
std::thread::spawn(move || {
// Signed in: look right away for the bots the account already has.
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
let r = remote::relay_join(&base, &url, &user, &pass, create, &invite, &code).map(|s| {
let found = remote::find_account_bots(&s, &pass, &code);
(s, found)
});
let _ = tx.send(r);
});
}
if ui.add_enabled(ready && self.rm.restore_rx.is_none(), secondary_button("從帳號備份還原")).on_hover_text(t("把這台電腦的 Bot 換成帳號裡最新的備份")).clicked() {
let (tx, rx) = channel();
self.rm.restore_rx = Some(rx);
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
let (url, user, pass, code) = (self.rm.relay_url.clone(), self.rm.user.trim().to_string(), self.rm.pass.clone(), self.rm.code.clone());
std::thread::spawn(move || {
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
let _ = tx.send(remote::restore(&url, &user, &pass, &code));
});
}
});
hint(ui, "密碼至少 8 個字。帳號伺服器在 relay/ 資料夾,可以放在任何一台小主機(說明見 relay/README.md)。", p);
}
let note = self.rm.note.lock().unwrap().clone();
if !note.is_empty() {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(note).size(FONT_SM).color(p.text2));
}
});
// ── 大腦 ──
if !self.state.remote.host_token.is_empty() {
setting_card(ui, p, |ui| {
ui.horizontal(|ui| {
ui.label(RichText::new(t("大腦")).size(FONT_BASE).strong().family(crate::bold()));
help_mark(ui, "帳號裡選一台 AnyBot 當大腦(通常是跟帳號伺服器放在一起、一直開著的那台)。所有 Bot、聊天、記憶和例行任務都放在大腦上,由它思考和排程。其他電腦打開 AnyBot 看到的都是同一份,同時也是大腦的手腳:大腦的 Bot 可以透過裝置連結操作它們。大腦連不到時,這裡還能看之前的對話,但不能傳訊息,連回來就恢復。", p);
});
let s = &self.state.remote;
let status = self.mir.status.lock().unwrap().clone();
if self.mir.on {
ui.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.0, if self.mir.online { p.up } else { p.text3 });
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(status).size(FONT_SM).color(p.text2));
});
fix: 慢的線上長連線不再被切斷;斷線接回馬上重新同步;大腦那一欄看得出是哪一段 計畫 R7。2026-11-17 早上:Mac mini 經 Tailscale 香港中繼連 nobledesktop(約 100 KB/s),大腦整份資料約 5 MB 要 45–55 秒。這台 45 秒沒收到「一則完整訊息」就算斷線,傳到一半被切、螢幕又從頭要整份,一直循環(實測:連線 9:41:48 開、9:42:33 剛好 45 秒時被切;第二次 9:43:55 一樣)。帳號那欄寫已連線、大腦那欄寫「和帳號伺服器的連線斷了」,看不出是哪一段。 - tunnel.rs:Stream 讀到資料就記(bytes_in、receiving);keep() 有資料進來就算還活著(DEAD_SECS 照舊,但量的是真的沒聲音)。call() 過了自己的時間、但連線還在收資料就繼續等(最多 10 分鐘)。link_serial() 給螢幕知道長連線接回了。 - 帳號伺服器(relay)的長連線同樣:Counted 包住 TcpStream,資料進來就算活著(這台上傳大份資料時不會被那端的 60 秒切掉)。要 make update-server 才生效。relay/clippy.toml:主程式的「HTTP 用戶端只能在 net.rs 建」不套用到 relay。 - 螢幕(mirror_ui):等重試時每 0.2 秒看一次長連線,接回就馬上再要(以前最多等 20 秒,這段時間帳號那欄已經寫已連線);記下上次同步的時間、大小、秒數。 - 設定的大腦那一欄:狀態下面分段寫「這台 ↔ 帳號伺服器」「帳號伺服器 ↔ 大腦(在線上/不在線上,帳號伺服器說的)」「上次同步 …(大小、秒數、KB/s)」。 已驗證:cargo test 571 全過、clippy -D warnings 過;relay cargo test 22 全過。新測試:假的帳號伺服器把一則 64 KB 的訊息分 3 秒慢慢送(允許的沉默設成 1 秒),連線不斷;之後真的沒聲音就斷。把「有資料進來就算活著」拿掉,同一個測試失敗:「已連線」後馬上「連線中斷」——就是早上的情況。 未驗證:真的 Tailscale 中繼線路上走一次(要更新這台的 App 和伺服器)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:41:15 +00:00
// Which leg: this computer ↔ the account server, the account server ↔ the
// brain (as the account server last said), and the line's speed.
let brain_on = self.rm.peers.lock().unwrap().iter().find(|(id, _, _)| *id == s.brain_id).map(|x| x.2);
let legs = remote_legs(&remote::hub().relay_status(), brain_on, &s.brain_name, *self.mir.last_sync.lock().unwrap());
for line in legs {
ui.add(egui::Label::new(RichText::new(line).size(FONT_XS).color(p.text3)).wrap());
}
ui.horizontal(|ui| {
let busy = self.mir.moving.load(Ordering::SeqCst);
if ui.add_enabled(self.mir.online && !busy, secondary_button("把這台的 Bot 搬過去")).on_hover_text(t("把這台電腦原本的 Bot(連同聊天)、模型金鑰、技能和連接器複製到大腦。這台的原始資料不會刪掉。")).clicked() {
self.mirror_move_local();
}
if ui.add(secondary_button("改回用這台自己的 Bot")).clicked() {
self.mir.leave = true;
}
});
let note = self.mir.move_note.lock().unwrap().clone();
if !note.is_empty() {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(note).size(FONT_SM).color(p.text2));
}
} else {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("這台就是大腦:Bot 在這台電腦上思考和工作。")).size(FONT_SM).color(p.text2));
let me = s.host_id.clone();
let peers: Vec<(String, String, bool)> = self.rm.peers.lock().unwrap().iter().filter(|(id, _, _)| !id.is_empty() && *id != me && !remote::is_hands(id)).cloned().collect();
if peers.is_empty() {
hint(ui, "帳號裡還沒有別台可以當大腦的 AnyBot。", p);
}
for (id, name, online) in peers {
ui.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.0, if online { p.up } else { p.text3 });
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(&name).size(FONT_SM));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add_enabled(online, secondary_button("改用它當大腦")).clicked() {
self.mir.want = Some((id.clone(), name.clone()));
// The brain's bots may use this computer (each action still asks).
self.state.remote.device_link = true;
changed = true;
}
});
});
}
}
self.pair_section(ui);
});
}
// ── 同一個網路 ──
setting_card(ui, p, |ui| {
setting_title(ui, "同一個網路直接連", "手機和這台電腦在同一個 Wi-Fi,或都裝了 Tailscale 時使用。", p);
let has_pw = !self.state.remote.password.is_empty();
if ui.add_enabled(has_pw, egui::Checkbox::new(&mut self.state.remote.lan, t("讓手機直接連這台電腦"))).changed() {
changed = true;
}
if self.state.remote.lan {
if let Some(port) = remote::lan_port() {
for a in remote::addresses(port) {
ui.horizontal(|ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(&a).monospace().size(FONT_SM));
if ui.small_button(t("複製")).clicked() {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
crate::platform::copy_text(ui.ctx(), &a);
}
});
}
if let Some(print) = remote::lan_fingerprint() {
ui.add_space(2.0);
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("https 的連線有加密。第一次打開,手機會問要不要信任這台電腦自己做的憑證:選「繼續」(進階 › 繼續前往)。要確認沒連錯台,比對憑證的 SHA-256 指紋:")).size(FONT_XS).color(p.text3));
ui.label(RichText::new(print).monospace().size(FONT_XS).color(p.text3));
} else {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("這個連線沒有加密:只在你信任的網路上使用。")).size(FONT_XS).color(p.danger));
}
}
}
ui.add_space(4.0);
form_row(ui, if has_pw { "更改手機密碼" } else { "設定手機密碼" }, p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.pw1).password(true).hint_text(t("至少 8 個字")).desired_width(f32::INFINITY));
});
form_row(ui, "再輸入一次", p, |ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.pw2).password(true).desired_width(f32::INFINITY));
});
let ok = self.rm.pw1.chars().count() >= 8 && self.rm.pw1 == self.rm.pw2;
if ui.add_enabled(ok, secondary_button("儲存密碼")).clicked() {
self.state.remote.password = crate::httpd::hash_password(&self.rm.pw1);
// A new password signs every phone out.
self.state.remote.devices.clear();
self.rm.pw1.clear();
self.rm.pw2.clear();
changed = true;
}
if !self.rm.pw2.is_empty() && self.rm.pw1 != self.rm.pw2 {
hint(ui, "兩次輸入的密碼不一樣", p);
}
hint(ui, "不要把這個連接埠開放到網際網路上;從外面連請用上面的帳號,或 Tailscale。", p);
});
// ── 允許手機做什麼 ──
setting_card(ui, p, |ui| {
setting_title(ui, "手機可以做什麼", "聊天、核准、看 Bot 的電腦一律可以。下面這些會碰到這台電腦本身,預設關閉。", p);
if ui.checkbox(&mut self.state.remote.mac_from_phone, t("從手機看這台電腦的螢幕並操作(點、打字、按鍵)")).changed() {
changed = true;
}
if ui.checkbox(&mut self.state.remote.device_link, t("裝置連結:讓帳號裡其他的 AnyBot(例如放在伺服器上的)操作這台電腦")).changed() {
changed = true;
}
hint(ui, "裝置連結開著時,伺服器上的 Bot 可以把「你的電腦」的螢幕、檔案、指令和 Mac App 工具交給這台電腦執行。每個動作仍照那邊的權限規則詢問你(手機上也能核准)。", p);
});
// ── 已登入的裝置 ──
setting_card(ui, p, |ui| {
setting_title(ui, "直接連線的裝置", "用手機密碼登入過的手機和瀏覽器", p);
if self.state.remote.devices.is_empty() {
hint(ui, "還沒有", p);
}
let mut remove = None;
for (i, d) in self.state.remote.devices.iter().enumerate() {
ui.horizontal(|ui| {
ui.label(RichText::new(&d.name).size(FONT_BASE));
let seen = chrono::DateTime::from_timestamp(d.last_seen.max(d.created), 0).map(|t| t.with_timezone(&chrono::Local).format("最近 %m/%d %H:%M").to_string()).unwrap_or_default();
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(seen).size(FONT_XS).color(p.text3));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("登出")).size(FONT_XS).color(p.danger)).frame(false)).clicked() {
remove = Some(i);
}
});
});
}
if let Some(i) = remove {
self.state.remote.devices.remove(i);
changed = true;
}
});
// ── 團隊 ──
if !self.state.remote.host_token.is_empty() {
setting_card(ui, p, |ui| {
setting_title(ui, "分享給團隊", "讓帳號伺服器上的其他帳號也能用這台 AnyBot 的 Bot。", p);
hint(ui, "成員:可以和 Bot 聊天、附加檔案;Bot 會知道是誰在說話。管理員:另外可以核准 Bot 要做的事、停止、看和操作電腦畫面。需要你允許的事只通知你和管理員。", p);
let loaded = self.rm.members.lock().unwrap().clone();
if loaded.is_none() {
*self.rm.members.lock().unwrap() = Some(Ok(vec![]));
let (m, s) = (self.rm.members.clone(), self.state.remote.clone());
std::thread::spawn(move || *m.lock().unwrap() = Some(remote::members(&s)));
}
let mut change: Option<(String, &str)> = None;
match loaded {
Some(Ok(list)) => {
for (user, role) in list {
ui.horizontal(|ui| {
ui.label(RichText::new(&user).size(FONT_BASE));
let waits = role.ends_with('?');
let role = role.trim_end_matches('?').to_string();
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(format!("{}{}", if role == "admin" { "管理員" } else { "成員" }, if waits { "(已邀請,等對方接受)" } else { "" })).size(FONT_XS).color(p.text3));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("移除")).size(FONT_XS).color(p.danger)).frame(false)).clicked() {
change = Some((user.clone(), "remove"));
}
});
});
}
}
Some(Err(e)) => hint(ui, format!("讀不到分享清單:{e}"), p),
None => {}
}
ui.horizontal(|ui| {
ui.add(egui::TextEdit::singleline(&mut self.rm.new_member).hint_text(t("對方的帳號")).desired_width(160.0));
ui.checkbox(&mut self.rm.new_admin, t("管理員"));
if ui.add_enabled(!self.rm.new_member.trim().is_empty(), secondary_button("分享")).clicked() {
change = Some((self.rm.new_member.trim().to_string(), if self.rm.new_admin { "admin" } else { "member" }));
self.rm.new_member.clear();
}
});
// Talk to the relay off the window's thread, then show the new list.
if let Some((user, role)) = change {
let (m, note, s, role) = (self.rm.members.clone(), self.rm.note.clone(), self.state.remote.clone(), role.to_string());
std::thread::spawn(move || {
let r = remote::set_member(&s, &user, &role);
*note.lock().unwrap() = match r {
Ok(()) if role == "remove" => format!("已停止分享給 {user}"),
Ok(()) => format!("已分享給 {user}"),
Err(e) => e,
};
*m.lock().unwrap() = Some(remote::members(&s));
});
}
});
}
// ── 帳號裡的其他電腦 ──
if !self.state.remote.host_token.is_empty() {
setting_card(ui, p, |ui| {
setting_title(ui, "帳號裡的電腦", "登入同一個帳號的 AnyBot。開了裝置連結的電腦,Bot 可以操作它。", p);
if ui.small_button(t("重新整理")).clicked() || (self.rm.peers.lock().unwrap().is_empty() && !self.rm.busy.load(Ordering::SeqCst)) {
let (peers, s) = (self.rm.peers.clone(), self.state.remote.clone());
let first = peers.lock().unwrap().is_empty();
if first {
peers.lock().unwrap().push((String::new(), "讀取中…".into(), false));
}
std::thread::spawn(move || {
let v = remote::devices_online(&s);
*peers.lock().unwrap() = if v.is_empty() { vec![(String::new(), "(沒有)".into(), false)] } else { v };
});
}
for (id, name, online) in self.rm.peers.lock().unwrap().iter() {
ui.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
if !id.is_empty() {
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.0, if *online { p.up } else { p.text3 });
}
let me = *id == self.state.remote.host_id;
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(format!("{name}{}", if me { "(這台)" } else { "" })).size(FONT_SM));
});
}
});
}
if changed {
self.mark();
}
}
/// Other AnyBots of this account that let bots operate them (裝置連結), as computers.
pub(super) fn linked_devices(&self) -> Vec<tools::Target> {
if self.state.remote.host_token.is_empty() {
return vec![];
}
let has_hands = !remote::my_hands(&self.state.remote.host_id).is_empty();
self.rm
.peers
.lock()
.unwrap()
.iter()
.filter(|(id, _, online)| !id.is_empty() && *online && *id != self.state.remote.host_id)
// A brain with hands of its own works on those, not on the account's other brains.
.filter(|(id, _, _)| !has_hands || remote::is_hands(id))
// A computer showing another brain lends its hands to that one, not to this.
.filter(|(id, _, _)| {
let uses = remote::peer_uses(id);
uses.is_empty() || uses == self.state.remote.host_id
})
.map(|(id, name, _)| tools::Target { name: name.clone(), place: tools::Place::Device { host: id.clone(), dir: String::new() } })
.collect()
}
}
/// A model one can chat with (not an image, video, speech or embedding one).
fn chats(model: &str) -> bool {
let m = model.to_lowercase();
!["imagine", "image", "video", "embed", "tts", "whisper", "audio", "moderation", "dall-e", "sora", "veo"].iter().any(|k| m.contains(k))
}
fix: 慢的線上長連線不再被切斷;斷線接回馬上重新同步;大腦那一欄看得出是哪一段 計畫 R7。2026-11-17 早上:Mac mini 經 Tailscale 香港中繼連 nobledesktop(約 100 KB/s),大腦整份資料約 5 MB 要 45–55 秒。這台 45 秒沒收到「一則完整訊息」就算斷線,傳到一半被切、螢幕又從頭要整份,一直循環(實測:連線 9:41:48 開、9:42:33 剛好 45 秒時被切;第二次 9:43:55 一樣)。帳號那欄寫已連線、大腦那欄寫「和帳號伺服器的連線斷了」,看不出是哪一段。 - tunnel.rs:Stream 讀到資料就記(bytes_in、receiving);keep() 有資料進來就算還活著(DEAD_SECS 照舊,但量的是真的沒聲音)。call() 過了自己的時間、但連線還在收資料就繼續等(最多 10 分鐘)。link_serial() 給螢幕知道長連線接回了。 - 帳號伺服器(relay)的長連線同樣:Counted 包住 TcpStream,資料進來就算活著(這台上傳大份資料時不會被那端的 60 秒切掉)。要 make update-server 才生效。relay/clippy.toml:主程式的「HTTP 用戶端只能在 net.rs 建」不套用到 relay。 - 螢幕(mirror_ui):等重試時每 0.2 秒看一次長連線,接回就馬上再要(以前最多等 20 秒,這段時間帳號那欄已經寫已連線);記下上次同步的時間、大小、秒數。 - 設定的大腦那一欄:狀態下面分段寫「這台 ↔ 帳號伺服器」「帳號伺服器 ↔ 大腦(在線上/不在線上,帳號伺服器說的)」「上次同步 …(大小、秒數、KB/s)」。 已驗證:cargo test 571 全過、clippy -D warnings 過;relay cargo test 22 全過。新測試:假的帳號伺服器把一則 64 KB 的訊息分 3 秒慢慢送(允許的沉默設成 1 秒),連線不斷;之後真的沒聲音就斷。把「有資料進來就算活著」拿掉,同一個測試失敗:「已連線」後馬上「連線中斷」——就是早上的情況。 未驗證:真的 Tailscale 中繼線路上走一次(要更新這台的 App 和伺服器)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:41:15 +00:00
/// The 大腦 section's lines under its state: this computer ↔ the account server (the lasting
/// connection's own words), the account server ↔ the brain (online or not, as the account server
/// last said), and the last sync's size and speed.
pub(super) fn remote_legs(relay: &str, brain_online: Option<bool>, brain: &str, last: Option<(i64, u64, u64)>) -> Vec<String> {
let mut out = vec![];
if !relay.is_empty() {
out.push(format!("這台 ↔ 帳號伺服器:{relay}"));
}
match brain_online {
Some(true) => out.push(format!("帳號伺服器 ↔ 大腦「{brain}」:在線上")),
Some(false) => out.push(format!("帳號伺服器 ↔ 大腦「{brain}」:不在線上(大腦那台的 AnyBot 沒開、沒網路,或正在重新啟動)")),
None => {}
}
if let Some((at, bytes, ms)) = last {
out.push(super::mirror_ui::sync_words(at, bytes, ms));
}
out
}
#[cfg(test)]
mod phone_tests {
#[test]
fn only_chat_models_are_offered() {
assert!(super::chats("grok-4.7") && super::chats("claude-opus-5-5") && super::chats("gpt-5-mini"));
assert!(!super::chats("grok-imagine-video-1.5") && !super::chats("text-embedding-3-large") && !super::chats("gpt-4o-mini-tts"));
}
}
// ---------- 手機: everything the desktop does, from the phone ----------
// Each action calls what the desktop's own button calls (appctl for the actions a bot can take
// too, set_pinned, restart_bot, toggle_reaction, enable_direct_mode, box_task…), so the phone
// adds no ways of its own. Members never get here (remote::role_allows); some things are the
// owner's alone: deleting a bot, permissions and rules, channels, connectors and the box's
// runtime, update and schedule. Keys, tokens and the vault's secrets are never sent.
/// Docker facts for the phone's 電腦 settings, refreshed in the background (asking Docker on the
/// app's thread would stall the window): (when, update available, gVisor here, runs on).
static BOX_FACTS: std::sync::Mutex<Option<(Instant, serde_json::Value)>> = std::sync::Mutex::new(None);
static BOX_FACTS_BUSY: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
fn box_facts() -> serde_json::Value {
let (stale, v) = {
let g = BOX_FACTS.lock().unwrap_or_else(|e| e.into_inner());
(g.as_ref().map(|(t, _)| t.elapsed().as_secs() > 20).unwrap_or(true), g.as_ref().map(|(_, v)| v.clone()).unwrap_or_else(|| json!({})))
};
// (Unit tests don't ask Docker.)
if stale && !cfg!(test) && !BOX_FACTS_BUSY.swap(true, std::sync::atomic::Ordering::SeqCst) {
std::thread::spawn(|| {
let (n, exec_ms, total_ms) = crate::cloudbox::step_stats();
let v = json!({
"update": crate::cloudbox::update_available(),
"gvisor": crate::cloudbox::host_has_gvisor(),
"running": crate::cloudbox::running_runtime(),
"steps": {"n": n, "exec_ms": exec_ms, "total_ms": total_ms},
});
*BOX_FACTS.lock().unwrap_or_else(|e| e.into_inner()) = Some((Instant::now(), v));
BOX_FACTS_BUSY.store(false, std::sync::atomic::Ordering::SeqCst);
});
}
v
}
/// At most `n` characters (the phone shows excerpts).
fn clip(s: &str, n: usize) -> String {
if s.chars().count() <= n {
s.to_string()
} else {
format!("{}…", s.chars().take(n).collect::<String>())
}
}
impl App {
pub(super) fn phone_act(&mut self, ctx: &egui::Context, action: &str, b: &serde_json::Value, role: &str) -> serde_json::Value {
let owner = role == "owner";
let bot = b["bot"].as_u64().unwrap_or(0);
let s = |k: &str| b[k].as_str().unwrap_or("").trim().to_string();
let fail = |e: &str| json!({"error": e});
let done = |t: &str| json!({"ok": true, "text": t});
let owner_only = || json!({"error": "這件事只有這台 AnyBot 的擁有者能做"});
// 團隊: an admin keeps what the phone always let them do (approve, stop, the screens, the
// model and computer, a new chat, regenerate) plus looking and small chat things; making,
// changing or deleting bots, routines, memories, pages and settings stays the owner's.
let admin_ok = match action {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"detail" | "settings" | "pages" | "search" | "export_bot" | "export_transcript" | "restart_bot" | "react" | "reply" | "resume" => true,
"bot" => b["key"].as_str() == Some("unread"),
"box" => matches!(b["op"].as_str(), Some("wake" | "disk")),
_ => false,
};
if !owner && !admin_ok {
return owner_only();
}
match action {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"search" => {
let q = s("q");
let (hits, more) = crate::find::search(&self.state.bots, &q);
let items: Vec<serde_json::Value> = hits
.into_iter()
.map(|h| {
let bname = self.state.bot(h.bot).map(|x| x.name.clone()).unwrap_or_default();
let tname = h.thread.and_then(|ti| self.state.bot(h.bot).and_then(|x| x.threads.get(ti)).map(|t| t.0.clone()));
json!({"bot": h.bot, "bot_name": bname, "thread": h.thread, "thread_title": tname, "index": h.index, "at": h.at, "mine": h.mine, "file": h.file, "snippet": h.snippet})
})
.collect();
json!({"ok": true, "hits": items, "more": more})
}
"export_bot" => match self.state.bot(bot) {
Some(x) => json!({"ok": true, "filename": format!("{}.anybot", x.name), "content": crate::share::export(x)}),
None => fail("找不到這個 Bot"),
},
"export_transcript" => match self.state.bot(bot) {
Some(x) => json!({"ok": true, "filename": format!("{} 對話.md", x.name), "content": super::transcript_markdown(x)}),
None => fail("找不到這個 Bot"),
},
"import_bot" => {
if !owner {
return owner_only();
}
let content = b["content"].as_str().unwrap_or("");
let id = self.state.next_id;
let mut next_rt = self.state.bots.iter().flat_map(|x| x.routines.iter()).map(|r| r.id).max().unwrap_or(0) + 1;
match crate::share::import(content, id, &mut next_rt, crate::routines::now()) {
Ok(nb) => {
let name = nb.name.clone();
self.state.next_id += 1;
self.state.bots.push(nb);
self.dirty = true;
json!({"ok": true, "bot": id, "text": format!("已匯入「{name}」")})
}
Err(e) => fail(&e),
}
}
"section_move" => {
if !owner {
return owner_only();
}
let folder = b["folder"].as_str().map(str::trim).filter(|f| !f.is_empty()).map(String::from);
let by = b["by"].as_i64().unwrap_or(0).clamp(-1, 1) as i32;
if by != 0 {
self.move_section(&folder, by);
}
done("好了")
}
記憶: a page to see it, a few lines picked while typing, a local model The memory had grown into a list carried whole, a top-14 recalled by a trigram index and pasted into the system prompt with the clock, and a page that broke its own layout. Nobody could see what went to the model, the prompt cache missed every message, and 「記住」 kept saying the same thing twice. Rebuilt per the spec (docs/memory.md): - Three kinds in memory.db: 記得的事 (fact), 做過的事 (event, a line per finished turn), 整理過的 (rollup). Each keeps pinned, uses, last_used, deleted, superseded_by, span. state.json keeps the facts as the copy that syncs; the page reads SQLite. - Search: jieba words ∪ CJK bigrams in an FTS5 unicode61 table (Traditional text goes through Simplified first), weighted share of query terms hit; plus local vectors, vec = clamp((cos−0.35)/0.35). score = max + 0.15×min, events ×0.9. ≥0.15 suggested, ≥0.5 ticked, ≥0.55 carried when nobody chose (3 at most). - What the model gets: the system prompt has the time zone and the pinned memories only, the same every turn. Each person message gets 〔送出時間〕 and 〔相關記憶〕 from Message.memories, built in group_history into a transient Message.context, so the beginning of a chat reads the same next turn (cache hits) and the event log, skills and audit see only what was typed. A memory already carried in view isn't carried again; each carry counts a use. - Picks travel with the message: Cmd::Send / POST send / sync act "memories" (empty = none; absent = the brain chooses, once, saved). - remember finds the like one (cos ≥ 0.85 or the same words) and asks for `replaces`; the old one is superseded, never carried. A fact forgotten and remembered again comes back. New search_memory (query, kind), with dates; read-only. - Nightly on the brain, no model: events past 30 days fold into a line per week (「11/3–11/9 做過的事(14 件):整理照片 ×3…」, ≤400 chars, like with like by words or vectors), weeks past 180 days into months; the folded go to 最近刪除 for 30 days. Facts are never removed. The page offers duplicates, facts unused for half a year, and what can fold now. - Local model: minishlab/potion-multilingual-128M through m2v.rs (same token ids as model2vec-rs on 13/13 sentences, cos ≥ 0.9999, without tokenizers' 1.1 GB). Converted while downloading: vocab.bin, table.i8 (int8 + row scales), dims.json, 137 MB kept of 530 MB; ANYBOT_HF_BASE picks a mirror (now passed into the server's brain container too). Loaded when first needed (34 ms), let go after 10 idle minutes. The brain loads it; a screen only with a document folder set; hands and phones never. 設定 › 一般 › 語意搜尋: 本機模型/Ollama/關閉; a new engine clears every vector. - Three files, three connections: memory.db (backed up nightly, 7 kept), docs.db (a cache), oplog/audit.db (30 days). An old audit.db hands its memories and documents over once and shrinks (a real one: 172 MB → 16 KB). docs_search scans every chunk now, vectors cached in RAM (it stopped at 8000); FTS optimize + VACUUM daily (260 MB of tombstones over 31 MB of text). - API: POST /api/memory (owner) and /api/sync/memory (mirror). Reads answer on the HTTP thread; writes go through phone_act("memory"). - Screens: a memory dialog (Bot menu 記憶…, Bot settings 打開記憶) with counts, live search, filters, suggestions, per-item kind/date/uses and pin/edit/forget/restore; chips above the composer 300 ms after typing stops, with a token estimate; 「帶了 N 條記憶」 under person messages. The phone has the same as a 記憶 tab, chips and tag. Checked: make test passes (app 297, relay 16), with new tests for the scores and thresholds, Traditional Chinese segmentation, remember's dedupe and replaces, two turns sending the same beginning, no double carry, weekly/monthly folding and the trash, and the audit.db move. Brain idle 37 MB as before, ~230 MB with the model loaded; search on the brain 0.2–0.5 ms, 7–44 ms from the phone page. A deadlock found on the way (stats re-taking the lock) is fixed and tested. Docs: docs/memory.md has the whole design; FEATURES.md, protocol, architecture (zh/en), multi-device and install say what changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3SYw9JJ9dXwaNvYh4
2026-11-10 23:46:50 +00:00
"memory" => {
let v = crate::memory::api_write(&mut self.state, b);
if v.get("ok").is_some() {
self.dirty = true;
}
v
}
"detail" => match self.state.bot(bot) {
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
Some(x) => self.phone_detail(x, owner),
None => fail("找不到這個 Bot"),
},
"settings" => self.phone_settings(owner),
// Every page, newest first (the state the phone polls carries only the latest few).
"pages" => {
let now = crate::model::now_ms();
let mut list: Vec<&crate::pages::Page> = self.state.pages.iter().collect();
list.sort_by_key(|p| std::cmp::Reverse(p.updated));
let pages: Vec<serde_json::Value> = list
.into_iter()
.map(|p| {
let mut c = crate::pages::card_json(p, now);
c["bot"] = json!(self.state.bot(p.bot).map(|x| x.name.clone()).unwrap_or_default());
c
})
.collect();
json!({"ok": true, "pages": pages})
}
// The actions a bot can take on the app (the same appctl path as its tools).
"app" => {
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
// (skillify and skill_install are the phone's 「教我做」 and 「從網址安裝技能」.)
const ALLOWED: [&str; 17] = [
"create_bot", "update_bot", "remember", "forget", "save_skill", "delete_skill", "skillify", "skill_install", "create_routine", "update_routine",
"delete_routine", "run_routine_now", "create_group", "move_to_group", "rename_group", "delete_group", "update_settings",
];
let name = s("name");
if !ALLOWED.contains(&name.as_str()) {
return fail("手機不能做這件事");
}
let args = match &b["args"] {
serde_json::Value::String(t) => t.clone(),
v if v.is_object() => v.to_string(),
_ => "{}".to_string(),
};
// (The bot it is about; the app-wide ones act as the main bot, as from its chat.)
let id = [bot, self.state.primary_bot].into_iter().find(|i| self.state.bot(*i).is_some()).or_else(|| self.state.bots.first().map(|x| x.id)).unwrap_or(0);
let next = self.state.next_id;
let out = if name == "update_bot" && serde_json::from_str::<serde_json::Value>(&args).map(|v| v["default_computer"].is_string()).unwrap_or(false) {
self.update_bot_computer(id, &args)
} else {
appctl::apply(&mut self.state, id, &name, &args)
};
if out.theme_changed {
self.apply_theme(ctx);
}
for (target, msg) in out.wake {
self.wake(ctx, target, msg);
}
self.dirty = true;
if !out.ok {
return fail(&out.text);
}
let made = (self.state.next_id > next).then_some(next);
json!({"ok": true, "text": out.text, "bot": made})
}
// A bot's switches from its menu and editor.
"bot" => {
if self.state.bot(bot).is_none() {
return fail("找不到這個 Bot");
}
let v = &b["value"];
let key = s("key");
if matches!(key.as_str(), "tools" | "allow_remove" | "strengths" | "not_for" | "abilities" | "skills" | "may_use") && !owner {
return owner_only();
}
match key.as_str() {
"pinned" => self.set_pinned(bot, v.as_bool().unwrap_or(false), None),
// 團隊: whether teammates may use this bot (the owner's choice only).
"team" => {
if !owner {
return owner_only();
}
if let Some(b) = self.state.bot_mut(bot) {
b.team = v.as_bool().unwrap_or(false);
}
}
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"pin_at" => self.set_pinned(bot, true, v.as_u64().map(|n| n as usize)),
"folder" => {
let f = v.as_str().unwrap_or("").trim().to_string();
self.set_pinned(bot, false, None);
if !f.is_empty() && !self.state.folders.contains(&f) {
self.state.folders.push(f.clone());
}
if let Some(x) = self.state.bot_mut(bot) {
x.folder = f;
}
}
"primary" => self.state.primary_bot = bot,
"members" => {
let ids: Vec<u64> = v.as_array().map(|a| a.iter().filter_map(|x| x.as_u64()).collect()).unwrap_or_default();
let ok: Vec<u64> = ids.into_iter().filter(|i| *i != bot && self.state.bot(*i).map(|x| x.members.is_empty()).unwrap_or(false)).collect();
if ok.is_empty() {
return fail("群組至少要有一個成員");
}
if let Some(x) = self.state.bot_mut(bot) {
x.members = ok;
}
}
// 個人檔案: 能力、技能、可以用的電腦 — the ticked ones; all of them is "no list".
"abilities" | "skills" | "may_use" => {
let ticked: Vec<String> = v.as_array().map(|a| a.iter().filter_map(|x| x.as_str().map(String::from)).collect()).unwrap_or_default();
let every: Vec<String> = match key.as_str() {
"abilities" => crate::profile::ABILITIES.iter().map(|a| a.0.to_string()).collect(),
"skills" => self.state.skills.iter().filter(|k| k.enabled).map(|k| k.name.clone()).collect(),
_ => self.state.bot(bot).map(|x| self.every_computer(x).into_iter().skip(1).map(|c| c.0).collect()).unwrap_or_default(),
};
// (In the list's own order, so what the bot is told reads the same every turn.)
let kept: Vec<String> = every.iter().filter(|n| ticked.contains(n)).cloned().collect();
let list = if kept.len() == every.len() { None } else { Some(kept) };
let Some(x) = self.state.bot_mut(bot) else { return fail("找不到這個 Bot") };
match key.as_str() {
"abilities" => x.abilities = list,
"skills" => x.skills = list,
_ => {
// The computer it works on by default must be one it may use.
let chosen = x.default_computer.trim().to_string();
let allowed = chosen.is_empty() || chosen == crate::model::BOT_COMPUTER_NAME || chosen == crate::model::own_computer_name(&x.name) || list.as_ref().is_none_or(|l| l.contains(&chosen));
if !allowed {
x.default_computer = crate::model::BOT_COMPUTER_NAME.to_string();
}
x.computers = list
}
}
}
k => {
let Some(x) = self.state.bot_mut(bot) else { return fail("找不到這個 Bot") };
match k {
"strengths" if v.is_string() => x.strengths = v.as_str().unwrap_or("").trim().chars().take(400).collect(),
"not_for" if v.is_string() => x.not_for = v.as_str().unwrap_or("").trim().chars().take(400).collect(),
"unread" => x.unread = v.as_bool().unwrap_or(true),
"tools" => x.tools_enabled = v.as_bool().unwrap_or(true),
"shape" if v.as_str().map(|t| crate::avatar::SHAPES.contains(&t)).unwrap_or(false) => x.shape = v.as_str().unwrap_or("").to_string(),
"color" if v.as_str().map(|t| crate::avatar::COLORS.iter().any(|c| c.0 == t)).unwrap_or(false) => x.color = v.as_str().unwrap_or("").to_string(),
"context" => x.context_tokens = v.as_u64().unwrap_or(x.context_tokens).clamp(4_000, 2_000_000),
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"thinking" if v.as_str().is_some_and(|t| ["", "low", "medium", "high"].contains(&t)) => x.thinking = v.as_str().unwrap_or("").to_string(),
"step_model" if v.is_string() => x.step_model = v.as_str().unwrap_or("").trim().to_string(),
"allow_remove" => x.allow_rules.retain(|r| Some(r.as_str()) != v.as_str()),
_ => return fail("不認得這個設定"),
}
}
}
self.dirty = true;
done("好了")
}
"group_chat" => {
// 群組聊天, as the desktop's new-bot menu makes it.
let ids: Vec<u64> = b["members"].as_array().map(|a| a.iter().filter_map(|x| x.as_u64()).collect()).unwrap_or_default();
let members: Vec<u64> = ids.into_iter().filter(|i| self.state.bot(*i).map(|x| x.members.is_empty()).unwrap_or(false)).collect();
if members.is_empty() {
return fail("選至少一個 Bot 當成員");
}
let id = self.state.next_id;
let name = Some(s("name")).filter(|n| !n.is_empty()).unwrap_or_else(|| "群組聊天".into());
let sel = self.state.selected;
let out = appctl::apply(&mut self.state, sel, "create_bot", &json!({"name": name, "description": "成員依序回答"}).to_string());
if !out.ok {
return fail(&out.text);
}
if let Some(x) = self.state.bot_mut(id) {
x.members = members;
x.shape = "cloud".into();
}
self.dirty = true;
json!({"ok": true, "text": out.text, "bot": id})
}
"delete_bot" => {
if !owner {
return owner_only();
}
if self.state.bot(bot).is_none() {
return fail("找不到這個 Bot");
}
// As the desktop's 刪除 Bot dialog.
self.stop(bot);
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
self.bot_gone(bot);
self.state.bots.retain(|x| x.id != bot);
self.state.fix_primary();
self.dirty = true;
done("已刪除")
}
"restart_bot" => {
if self.state.bot(bot).is_none() {
return fail("找不到這個 Bot");
}
self.restart_bot(bot);
done("已重新啟動")
}
"react" => {
let idx = b["index"].as_u64().unwrap_or(u64::MAX) as usize;
let emoji = s("emoji");
if emoji.is_empty() || emoji.chars().count() > 8 || self.state.bot(bot).map(|x| idx >= x.messages.len()).unwrap_or(true) {
return fail("找不到這則訊息");
}
self.toggle_reaction(bot, idx, &emoji);
done("好了")
}
"reply" => {
self.remote_cmd(ctx, Cmd::Reply { bot });
done("重新傳送中…")
}
A turn cut off by a crash leaves a 「繼續」 card, and nothing it may have done runs twice Each bot keeps a work log (oplog/bot-<id>.jsonl, after pi's durable-harness design, cut down): before something happens a line says it is about to — the turn, each model call, each step once its checks passed (with the arguments it runs with and whether it may run again), each message typed mid-turn — synced to disk first. When the turn ends the file shrinks to the messages still waiting, usually nothing. On the next start after AnyBot was killed mid-turn, the log puts the chat right before anything runs: the message the turn answered comes back if the chat lost it; a step that was running and reaches outside (a text, a click, a file, a published site) shows as 「可能已經執行了」, both to the person and in the result the bot reads — no longer as "not allowed"; a step that only looked shows as cut off; messages typed mid-turn that never reached the bot go back into the chat. The chat is saved, then the log closes the turn. A turn the person didn't stop ends with a 「繼續」 card (what it was doing, what may have run, the messages put back); it goes on only when they press it — in the window, on a screen of the brain, or on the phone — from where its steps stand, never running a step that may have run again. Pressing stop is on disk at once, and a stopped turn stays stopped. Also in the turn loop: - 自動審核 that doesn't answer (or answers something that isn't a verdict) asks the person; in 直接操作 mode it used to let the step through unchecked. - "Too long for this model" folds older messages into a summary and asks the same step again, once per thing the person said, instead of ending the turn. - Folding keeps the person's chat whole: the summary goes in at the fold and the model reads from the newest summary on (it used to delete what it folded). - A step moved to the chosen computer runs there, but the chat keeps the call as the model wrote it; the result says where it ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5F5gJt93t3yEx3XcS
2026-11-08 16:49:12 +00:00
"resume" => {
self.remote_cmd(ctx, Cmd::Resume { bot });
done("繼續中…")
}
"clear" => {
self.remote_cmd(ctx, Cmd::Clear { bot });
done("已清除聊天記錄")
}
"delete_page" => {
let id = b["id"].as_u64().unwrap_or(0);
let before = self.state.pages.len();
self.state.pages.retain(|x| x.id != id);
if self.state.pages.len() == before {
return fail("這個頁面已經刪除了");
}
self.mark();
done("已刪除頁面")
}
// 設定 › 一般 / 權限 (the owner's).
"setting" => {
if !owner {
return owner_only();
}
let v = &b["value"];
match s("key").as_str() {
"direct_mode" => {
if v.as_bool().unwrap_or(false) {
self.enable_direct_mode()
} else {
self.disable_direct_mode()
}
}
"auto_review" => self.state.auto_review = v.as_bool().unwrap_or(false),
"notify" => self.state.notify = v.as_bool().unwrap_or(true),
"rule_add" | "rule_remove" => {
let text = v.as_str().unwrap_or("").trim().to_string();
let list = if s("list") == "ask" { &mut self.state.review_ask_rules } else { &mut self.state.review_allow_rules };
if s("key") == "rule_add" {
if text.is_empty() {
return fail("規則是空的");
}
if !list.contains(&text) {
list.push(text);
}
} else {
list.retain(|r| *r != text);
}
}
_ => return fail("不認得這個設定"),
}
self.dirty = true;
done("好了")
}
// 設定 › 模型: a provider's key (written, never read back) and new bots' model.
"provider" => {
if !owner {
return owner_only();
}
let Some(kind) = crate::providers::ALL_PROVIDERS.iter().copied().find(|k| serde_json::to_value(k).ok().as_ref() == Some(&b["provider"])) else { return fail("不認得這個模型服務") };
let ps = self.state.providers.entry(kind.key().to_string()).or_default();
if let Some(k) = b["key"].as_str() {
ps.api_key = k.trim().to_string();
}
if let Some(m) = b["default_model"].as_str() {
ps.default_model = m.trim().to_string();
}
self.dirty = true;
done("好了")
}
// 手機與帳號: sign a direct-connection phone out (as the desktop's list does).
"device_remove" => {
if !owner {
return owner_only();
}
let (name, created) = (s("name"), b["created"].as_i64().unwrap_or(0));
let before = self.state.remote.devices.len();
self.state.remote.devices.retain(|d| !(d.name == name && d.created == created));
if self.state.remote.devices.len() == before {
return fail("找不到這支手機");
}
self.dirty = true;
done("已登出那支手機")
}
"channel" => {
if !owner {
return owner_only();
}
let id = b["id"].as_u64().unwrap_or(0);
if !self.state.channels.iter().any(|c| c.id == id) {
return fail("找不到這個管道");
}
if b["remove"].as_bool().unwrap_or(false) {
self.state.channels.retain(|c| c.id != id);
} else if let Some(c) = self.state.channels.iter_mut().find(|c| c.id == id) {
c.enabled = b["enabled"].as_bool().unwrap_or(c.enabled);
}
self.dirty = true;
self.channels_restart(ctx);
done("好了")
}
"mcp" => {
if !owner {
return owner_only();
}
連接器: a 公用市集 of remote servers from the official MCP Registry, on the computer and the phone - 連接器市集 gets a search box over registry.modelcontextprotocol.io (public, with an API): servers reached by address only (a package would have to run on the brain, which may have no Node or uv); old SSE ones are marked as not yet supported, taken-down ones left out. A name that only says "mcp" (com.notion/mcp) reads as whose it is (notion). - 加入 on the computer fills 新增連接器 and scrolls to it: a free name, the address, and the header with the registry's placeholder ("Authorization: Bearer {smithery_api_key}"), shown unmasked with what to put there (the key's description, an address variable's choices). 新增 stays off while a 「{…}」 is left. - The phone: 設定 › 整合 › 從公用市集加入. The brain searches (the phone's page may only talk to its own server; GET /api/mcp/registry, owner only, on the HTTP thread); a pick asks for the key or the address part and the brain adds it (the 「mcp」 action's new `add`). - A server that answers 401 (or a 403 asking for a login) with no key given now says it signs people in with OAuth, which AnyBot can't do yet; with a key, that the key is wrong or old. - mcpservers.org and the like are pages for people behind a browser check, with no list a program may read, so the market uses the registry. - Checked live: 「notion」 finds 6; AWS Knowledge (no key) connects with 5 tools; Notion's own server (OAuth) gives the OAuth sentence. `cargo test -- --ignored registry_search_live`. - Screenshot mode: ANYBOT_SHOT_MCP=<search> shows the 公用市集 after that search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:12:12 +00:00
// From the phone's 公用市集: a server reached by address, with its key filled in.
if b["add"].is_object() {
let a = &b["add"];
let (url, header) = (a["url"].as_str().unwrap_or("").trim(), a["header"].as_str().unwrap_or("").trim());
if !(url.starts_with("https://") || url.starts_with("http://")) {
return fail("連接器要有網址");
}
if url.contains('{') || header.contains('{') {
return fail("還有「{…}」沒換成你的值");
}
let name = crate::mcp::free_name(a["name"].as_str().filter(|n| !n.trim().is_empty()).unwrap_or("連接器"), &self.state.mcp_servers);
self.state.mcp_servers.push(crate::mcp::remote_server(&name, url, header));
self.dirty = true;
return done(&format!("已加入連接器「{name}」"));
}
let name = s("name");
if !self.state.mcp_servers.iter().any(|m| m.name == name) {
return fail("找不到這個連接器");
}
if b["reconnect"].as_bool().unwrap_or(false) {
self.mcp_reconnect(&name);
return done("重新連線中…");
}
// Renamed (from a screen): this entry keeps its keys, its place and its sign-in.
if let Some(new) = b["rename"].as_str().map(str::trim) {
if new.is_empty() || self.state.mcp_servers.iter().any(|m| m.name == new) {
return fail("名稱不能空白,也不能跟別的連接器一樣");
}
if let Some(m) = self.state.mcp_servers.iter_mut().find(|m| m.name == name) {
m.name = new.to_string();
}
crate::mcp_oauth::rename(&name, new);
self.ch.mcp_errors.lock().unwrap().retain(|e| e.0 != name);
fix: 連接器改名不走手機的路、一律允許跟著改名;在別處按 Enter 不再替你允許 - 手機的 /api/act/mcp 不收改名(區網沒加密:讀到一次登入的人可以靠兩次改名,讓別的連接器 接手某個連接器的「一律允許」)。改名只走螢幕電腦的 /api/sync/mcp-rename。 - 改名時每個 Bot 的「一律允許」(mcp:<名稱>)跟著改到新名字;之後別的連接器取舊名字也不會繼承。 - 螢幕電腦上改名不先改本機:請大腦改,新名字隨大腦的更新回來(期間連接器的頁照舊找得到); 大腦沒改成,兩邊都還是舊名字。沒改成的原因:還在那一頁寫在頁上,已經離開就用通知說。 - 審批:聊天裡有等你允許的卡片時,在設定視窗或別的輸入框按 Enter,會被當成「允許」 (main 就有)。現在設定開著、或這一幀開始時游標在別的輸入框,Enter/Esc 不回答卡片。 一張沒有選項的問題卡也不在設定開著時搶走游標。 - 測試:改名的打字測試改成照欄位 id 給游標(平行的測試會換語言、版面跟著變), 原因用頁面記下的字比對。這兩個問題是這個測試在整套一起跑時時好時壞找到的。 已驗證: cargo test 整套連跑 8 次全綠(620);新測試 enter_elsewhere_does_not_approve_the_waiting_step、 a_screen_asks_the_brain_to_rename_a_connector、a_connector_is_never_renamed_through_the_phones_road; the_brain_renames_a_connector_for_a_screen(一律允許跟著改)。 未驗證: 螢幕電腦連真的大腦實際改名(要兩台機器)。 動到審批路徑(approval_dock 的 Enter/Esc):依 CLAUDE.md 需要實機測試+人類簽名,不得自行發佈。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3KhvSzysuKUobKUTR
2026-11-17 10:35:57 +00:00
self.move_mcp_grants(&name, new);
self.dirty = true;
return done("好了");
}
// (mcp_poll connects or drops it when the list changes.)
if b["remove"].as_bool().unwrap_or(false) {
self.state.mcp_servers.retain(|m| m.name != name);
self.forget_mcp_grants(&name);
} else if let Some(m) = self.state.mcp_servers.iter_mut().find(|m| m.name == name) {
m.enabled = b["enabled"].as_bool().unwrap_or(m.enabled);
}
self.dirty = true;
done("好了")
}
2026-11-11 08:19:06 +00:00
"skill" => {
if !owner {
return owner_only();
}
if let Some(slug) = b["builtin"].as_str().filter(|s| !s.trim().is_empty()) {
return match crate::skills::install_builtin(slug, &mut self.state.skills) {
Ok(name) => {
self.dirty = true;
done(&format!("已加入技能「{name}」"))
}
Err(e) => fail(&e),
};
}
技能: / in the input picks one; on a brain's screen the brain adds, installs and deletes them; 設定 › 整合's lists keep their buttons clear - Typing / at the start of the input (computer and phone) lists the skills that are on: names that start with what is typed first, then names containing it, then descriptions (「/簡報」 finds pptx). A click, or ↑↓ and Enter/Tab, puts 「/name 」 in the input; Esc closes the list. Sent, the brain recognises 「/name」 and adds a line after the message telling the model to read that skill with use_skill first, so a phone or a message channel gets it too; a / that names no skill (a path) gets nothing. The phone asks the brain for the list again at each new /, so a skill added since is there. - On a screen, 加入 / 安裝 / 刪除 ran on the screen's own disk and only the list entry reached the brain: a GitHub skill's scripts stayed on the screen's computer, an install also pushed every skill in that computer's folder into the brain's list, and a deleted skill's folder stayed on the brain and came back at its next start. These now go to the brain (/api/sync/skill, the phone's own 「skill」 action): it fetches an address itself, a folder or .md file on the screen's computer goes up whole with its files, and a delete takes the folder too. 「把這台的 Bot 搬到大腦」 hands over skills the same way. A refused package leaves no folder behind. - 技能, 技能市集 and 連接器市集 rows: a long description took the whole row and 開啟 / 檢視 / 刪除 / 已加入 / 安裝 were drawn over it. The buttons are laid out first and the description ends in … before them (the whole of it on hover). - Screenshot mode: ANYBOT_SHOT_KEYS="ArrowDown@60;Enter@64" presses keys at given frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:54:58 +00:00
// From a screen (設定 › 整合 on a computer showing this brain): a GitHub or web
// address is fetched here, and a folder on that computer arrives whole — the
// bots read skills from this disk.
if let Some(src) = b["install"].as_str().filter(|s| !s.trim().is_empty()) {
return match crate::skills::install_from_source(src) {
Ok(name) => {
crate::memory::merge_skill_files(&mut self.state.skills);
self.dirty = true;
done(&format!("已安裝技能「{name}」"))
}
Err(e) => fail(&e),
};
}
if b["package"].is_object() {
return match crate::skills::install_package(&b["package"]) {
Ok(k) => {
let name = k.name.clone();
crate::memory::upsert_skill(&mut self.state.skills, k);
self.dirty = true;
done(&format!("已安裝技能「{name}」"))
}
Err(e) => fail(&e),
};
}
2026-11-11 08:19:06 +00:00
let name = s("name");
if !self.state.skills.iter().any(|k| k.name == name) {
return fail("找不到這個技能");
}
if b["remove"].as_bool().unwrap_or(false) {
self.state.skills.retain(|k| k.name != name);
crate::memory::remove_skill_files(&name);
} else if let Some(k) = self.state.skills.iter_mut().find(|k| k.name == name) {
k.enabled = b["enabled"].as_bool().unwrap_or(k.enabled);
}
self.dirty = true;
done("好了")
}
// 設定 › 電腦's buttons for Bot 的電腦.
"box" => {
let op = s("op");
if matches!(op.as_str(), "update" | "reset" | "runtime" | "auto_update") && !owner {
return owner_only();
}
match op.as_str() {
"wake" => self.box_task(|| crate::cloudbox::ensure_running().map(|_| "Bot 的電腦已經開好了。".to_string())),
"snapshot" => self.box_task(|| crate::cloudbox::save_snapshot().map(|n| format!("已儲存快照({})。", crate::cloudbox::human(n)))),
"disk" => {
let slot = self.cu.disk.clone();
*slot.lock().unwrap() = Some("檢查中…".into());
std::thread::spawn(move || {
let r = crate::cloudbox::disk_report().unwrap_or_else(|e| e);
*slot.lock().unwrap() = Some(r);
});
}
"update" => {
// As the desktop's 更新: the bots stop first, the files and logins stay.
let ids: Vec<u64> = self.streams.keys().copied().collect();
for id in ids {
self.stop(id);
}
*self.cu.note.lock().unwrap() = match crate::cloudbox::rebuild(crate::cloudbox::Rebuild::Update) {
Ok(()) => t("更新已開始。"),
Err(e) => e,
};
}
"reset" => {
// As the desktop's 重設: back to the last snapshot (the current box saved
// first), or a brand-new computer when there is none.
let ids: Vec<u64> = self.streams.keys().copied().collect();
for id in ids {
self.stop(id);
}
let kind = if crate::cloudbox::snapshot_time().is_some() { crate::cloudbox::Rebuild::Restore } else { crate::cloudbox::Rebuild::Reset };
*self.cu.note.lock().unwrap() = match crate::cloudbox::rebuild(kind) {
Ok(()) => t("已開始。"),
Err(e) => e,
};
}
"runtime" => crate::cloudbox::set_box_runtime(&s("value")),
"auto_update" => {
let at = s("value");
if !at.is_empty() && chrono::NaiveTime::parse_from_str(&at, "%H:%M").is_err() {
return fail("時間要寫成 HH:MM");
}
crate::cloudbox::set_auto_update_at((!at.is_empty()).then_some(at));
}
_ => return fail("不認得這個動作"),
}
*BOX_FACTS.lock().unwrap_or_else(|e| e.into_inner()) = None;
done("好了")
}
_ => fail("沒有這個動作"),
}
}
/// A bot as its editor and the panel beside the chat show it.
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
fn phone_detail(&self, b: &Bot, owner: bool) -> serde_json::Value {
let names: HashMap<u64, String> = self.state.bots.iter().map(|x| (x.id, x.name.clone())).collect();
let (choices, chosen) = self.computer_choices(b);
let trig = crate::triggers::statuses().lock().unwrap().clone();
// 資料庫: the chat's files, newest first (pictures and documents the person or the bot sent).
let mut files: Vec<serde_json::Value> = vec![];
for m in b.messages.iter().rev() {
for a in &m.attachments {
if files.len() < 80 {
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
files.push(json!({"name": a.name, "path": a.path, "image": a.image, "bytes": a.bytes, "kind": crate::preview::kind_label(&a.name), "at": m.at, "mine": m.role == Role::User}));
}
}
}
json!({
"id": b.id, "name": b.name, "description": b.description, "instructions": b.instructions,
"shape": b.shape, "color": b.color, "provider": serde_json::to_value(b.provider).unwrap_or_default(), "model": b.model,
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
"thinking": b.thinking, "step_model": b.step_model,
// 個人檔案 (each list: every choice there is, and whether this bot has it).
"strengths": b.strengths, "not_for": b.not_for,
"abilities": crate::profile::ABILITIES.iter().map(|(k, label, what)| json!({"key": k, "name": label, "note": what, "on": b.abilities.as_ref().is_none_or(|a| a.iter().any(|x| x == k))})).collect::<Vec<_>>(),
"skills": self.state.skills.iter().filter(|k| k.enabled).map(|k| json!({"key": k.name, "name": k.name, "note": k.description, "on": b.skills.as_ref().is_none_or(|a| a.contains(&k.name))})).collect::<Vec<_>>(),
"may_use": self.every_computer(b).into_iter().enumerate().map(|(i, (name, kind))| json!({"key": name, "name": name, "note": kind, "on": i == 0 || b.computers.as_ref().is_none_or(|a| a.contains(&name)), "fixed": i == 0})).collect::<Vec<_>>(),
"computer": chosen, "computers": choices.iter().map(|(name, note)| json!({"name": name, "note": note})).collect::<Vec<_>>(),
"tools_enabled": b.tools_enabled, "context_tokens": b.context_tokens, "folder": b.folder, "pinned": b.pinned,
"primary": b.id == self.state.primary_bot, "unread": b.unread,
"members": b.members.iter().map(|i| json!({"id": i, "name": names.get(i).cloned().unwrap_or_default()})).collect::<Vec<_>>(),
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
"memories": if owner { b.memories.clone() } else { vec![] }, "allow_rules": if owner { b.allow_rules.clone() } else { vec![] },
"demos": b.demos.iter().map(|d| json!({"name": d.name, "created": d.created, "steps": d.steps.len()})).collect::<Vec<_>>(),
"routines": b.routines.iter().map(|r| json!({
"id": r.id, "title": r.title, "prompt": r.prompt, "paused": r.paused, "when": appctl::routine_when(r),
"schedule": serde_json::to_value(&r.schedule).unwrap_or_default(), "repeat": crate::routines::describe(&r.schedule),
"trigger": r.trigger.as_ref().map(|t| t.describe()), "status": trig.get(&r.id).cloned(),
"last": r.last_run.map(|t| crate::routines::describe_when(t, &r.schedule.timezone)), "computer": r.computer,
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
"paused_why": if r.paused { r.paused_why.clone() } else { String::new() },
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
"runs": r.runs.iter().rev().take(5).map(|x| json!({"line": crate::routines::describe_run(x, &r.schedule.timezone), "bad": matches!(x.outcome, crate::routines::RunOutcome::Failed | crate::routines::RunOutcome::Interrupted), "sends": x.sends})).collect::<Vec<_>>(),
"target": crate::appctl::target_words(r),
})).collect::<Vec<_>>(),
"threads": b.threads.iter().enumerate().rev().map(|(i, (title, msgs))| json!({"index": i, "title": title, "count": msgs.len(), "at": msgs.last().map(|m| m.at).unwrap_or(0)})).collect::<Vec<_>>(),
"files": files,
})
}
/// 設定 as the phone shows it (nothing secret: keys only as "set or not").
fn phone_settings(&self, owner: bool) -> serde_json::Value {
let st = &self.state;
let ch_status = crate::channels::statuses().lock().unwrap().iter().map(|(k, v)| (*k, (v.ok, v.note.clone(), v.received))).collect::<HashMap<_, _>>();
let mcp = crate::mcp::status();
let mcp_err = self.ch.mcp_errors.lock().unwrap().clone();
let bot_name = |id: u64| st.bot(id).map(|b| b.name.clone()).unwrap_or_else(|| "(Bot 已刪除)".into());
let log = crate::cloudbox::log_lines();
let mut out = json!({
"role": if owner { "owner" } else { "admin" },
"host": st.remote.host_name, "version": crate::version::LABEL, "built": crate::version::epoch_ms(self.exe_built), "newer": self.newer_build.is_some(),
"theme": match st.theme { Theme::Light => "light", Theme::Dark => "dark", Theme::System => "system" },
design: 手機網頁顏色跟著電腦版、改成 Claude 手機 App 的感覺,實點修好 12 個問題 - 顏色:api/state 帶出電腦的主題和淺色/深色兩組顏色(theme::shell 換成手機的 CSS 變數);手機「這支手機的外觀」預設「跟著電腦」,也可選跟著手機、淺色、深色;先驗證是 hex 才套用,存一份避免打開時閃預設色;狀態列跟著畫面。舊版電腦沒送顏色時維持「紙」。電腦畫面頁改成暖色深色。 - 感覺:標題列沒有底線、第二行只寫在做什麼或模型;輸入框是底部圓角卡片;回答下只留時間和三個操作;群組、晶片、建議、記憶卡拿掉框線;開關的「開」用墨色;允許卡細框;點擊範圍加大(44/40/36px)。 - 字更少:設定首頁拿掉重複說明;每列說明一行;「模型」頁右邊只寫可以用/未設定;Bot 那列選單少用的收進「更多…」。 - 修好:長 Bot 名字超出 @// 選單;引用顯示原始 Markdown 且沒有長度上限;第 8 個表情換行;.note 在清單裡變灰條;圖片點了跳出 App;上傳吐司蓋住輸入框;「聊天的顏色」永遠沒有 ✓(電腦送 "Quiet",改送 quiet/black/bot_color);「:」後的網址不成連結;深色模式黑頭像看不見;稽核分頁出現 ** 和多行 JSON;頁面卡標題重複;記憶搜尋框 14px 讓 iPhone 放大。 - 問題卡的「略過」、交辦的「跳過」、允許卡的「拒絕」不再是紅字,跟電腦版一樣是一般按鈕。 已驗證:cargo test --bin anybot 523 通過(含 phone_login_and_api 檢查主題和兩組顏色)、relay 22 通過;手機圖表 65/65、通知 9/9、電腦畫面 13/13;playwright 390×844 淺色深色點過登入、首頁、聊天、詳細資訊、Bot 設定、頁面、例行任務、電腦、設定每一頁,沒有 console 錯誤、失敗請求或橫向溢出;電腦換靛藍深色,手機跟著變。 未驗證:真的 iPhone/Android 實機。
2026-11-16 15:16:38 +00:00
// 聊天的顏色 in the words update_settings takes (the phone ticks the one in use; the
// enum's own names, "Quiet", matched none of them).
"accent": match st.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot_color",
},
"timezone": st.timezone, "notify": st.notify, "language": st.language,
"direct_mode": st.direct_mode, "direct_locked": !self.managed.direct.allows() || !self.managed.local.allows(),
"auto_review": st.auto_review, "allow_rules": st.review_allow_rules, "ask_rules": st.review_ask_rules,
"providers": crate::providers::ALL_PROVIDERS.iter().map(|&k| {
let ps = st.provider(k);
feat: ChatGPT 方案——用 ChatGPT 帳號登入,Bot 用你 ChatGPT 方案的額度,不用 API 金鑰 - 新供應商「ChatGPT 方案」(src/chatgpt.rs):照 OpenAI 給開源 App 的 Sign in with ChatGPT。 第一次登入註冊 AnyBot(dynamic_agent_client → oaiapp_…)並重用;PKCE、state、nonce; ID token 驗 RS256 簽章、iss、aud、exp、nonce;沒同意使用方案算登入但不能用(再登入會要求同意)。 - 要求走 Responses API(api.openai.com/v1/responses,store:false、stream:true、instructions), token 只送 OpenAI 自己的網址;收到 response.completed 才算完成;額度用完停下來給管理用量連結, 不重試、不改用 API 金鑰。token 快到期或 401 時更新(一次一個,refresh token 會輪替)。 - 設定 › 模型 › ChatGPT 方案:使用 ChatGPT 繼續、登出、換帳號、打開登入頁、管理用量; 連到伺服器大腦的螢幕電腦和手機也能登入(登入頁開在自己這台,打不開的那頁網址貼回給大腦)。 - Bot 工具 chatgpt_login(status、login、logout、switch_account;登出和換帳號先問)。 - 修連接器登入:封存的 token 前綴寫錯("sealed:" 實際是 "enc:v1:"),重開 App 後 token 沒解開就被當成憑證送出,登入等於每次重開都失效。 已驗證: cargo test 全綠(chatgpt::、providers::、appctl::、remote::、mcp_oauth::、featuremap::、layout_audit::); 授權網址的參數送到 auth.openai.com 沒被拒(302 到登入頁)。 未驗證: 實際用 ChatGPT 帳號登入、同意、Responses 串流與工具呼叫(要真的 ChatGPT 付費帳號和瀏覽器); 螢幕電腦貼回網址、手機登入(要實機);Windows 的「打開登入頁」。 動到審批路徑(appctl::needs_approval 的 chatgpt_login):需要實機測試+人類簽名。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:23:10 +00:00
// (ChatGPT 方案 signs in with an account, not a key: `account`.)
json!({"key": serde_json::to_value(k).unwrap_or_default(), "label": k.label(), "needs_key": k.needs_key() && k != crate::providers::ProviderKind::ChatGpt, "account": k == crate::providers::ProviderKind::ChatGpt,
"ready": crate::providers::ready(k, &ps.api_key),
"default_model": ps.default_model, "custom_url": !ps.base_url.is_empty()})
}).collect::<Vec<_>>(),
2026-11-11 08:19:06 +00:00
"skills": st.skills.iter().map(|k| json!({
"name": k.name,
"description": k.description,
"instructions": k.instructions,
"enabled": k.enabled,
"resources": k.resources,
"steps": k.steps.len(),
"source": k.source,
})).collect::<Vec<_>>(),
"skill_market": crate::skills::BUILTIN_SKILLS.iter().map(|b| json!({
"name": b.slug,
"title": b.title,
"summary": b.summary,
"source": format!("builtin:{}", b.slug),
"remote": false,
})).chain(crate::skills::REMOTE_MARKET.iter().map(|r| json!({
"name": r.name,
"title": r.name,
"summary": r.summary,
"source": r.source,
"remote": true,
}))).collect::<Vec<_>>(),
"templates": crate::memory::TEMPLATES.iter().map(|t| {
let c = crate::avatar::color(t.color);
json!({"name": t.name, "description": t.description, "shape": t.shape, "color": format!("#{:02x}{:02x}{:02x}", c.r(), c.g(), c.b())})
}).collect::<Vec<_>>(),
"shapes": crate::avatar::SHAPES,
"colors": crate::avatar::COLORS.iter().map(|(k, n, c)| json!({"key": k, "name": n, "hex": format!("#{:02x}{:02x}{:02x}", c[0], c[1], c[2])})).collect::<Vec<_>>(),
"folders": st.folders,
"channels": st.channels.iter().map(|c| {
let (ok, note, received) = ch_status.get(&c.id).cloned().unwrap_or((false, String::new(), 0));
json!({"id": c.id, "kind": c.kind.label(), "name": c.name, "bot": bot_name(c.bot_id), "target": c.target, "enabled": c.enabled, "ok": ok, "note": note, "received": received})
}).collect::<Vec<_>>(),
"mcp": st.mcp_servers.iter().map(|m| json!({
"name": m.name, "enabled": m.enabled, "tools": mcp.get(&m.name), "error": mcp_err.iter().find(|e| e.0 == m.name).map(|e| e.1.clone()),
"what": if m.url.is_empty() { m.command.clone() } else { address_only(&m.url) },
})).collect::<Vec<_>>(),
"box": {
"state": crate::cloudbox::run_state().label(), "available": crate::cloudbox::available(),
"version": crate::cloudbox::wanted_version(), "runtime": crate::cloudbox::box_runtime(),
"snapshot": crate::cloudbox::snapshot_time().map(|t| t.format("%m/%d %H:%M").to_string()),
"auto_update": crate::cloudbox::auto_update_at(),
"note": self.cu.note.lock().unwrap().clone(), "disk": self.cu.disk.lock().unwrap().clone(),
"log": log.iter().rev().take(40).rev().cloned().collect::<Vec<_>>(),
"facts": box_facts(),
},
});
if owner {
out["devices"] = json!(st.remote.devices.iter().map(|d| json!({"name": d.name, "created": d.created, "last_seen": d.last_seen})).collect::<Vec<_>>());
out["docker_host"] = json!(crate::cloudbox::docker_host());
}
out
}
}
#[cfg(test)]
mod phone_act_tests {
use super::*;
/// The demo app (sample bots, nothing read from or saved to disk).
fn demo() -> (egui::Context, App) {
let ctx = egui::Context::default();
let app = App::new(&ctx, Some(std::env::temp_dir().join("anybot-phone-act-test.png")));
(ctx, app)
}
/// 允許/拒絕 on a phone notification answers only the request it showed: once that one
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
/// is gone and another waits, the old banner answers nothing (a note says so). And only a
/// request to allow that fits on the banner: never 我完成了, 略過 or 一律允許 from there.
#[test]
fn a_banner_answers_only_its_own_request() {
let (ctx, mut app) = demo();
let bot = app.state.bots[0].id;
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
let card = |app: &mut App, kind: ApprovalKind, reason: &str, key: &str| {
let (tx, rx) = std::sync::mpsc::channel();
// (The same tool call asking again, as one step does: a new key each time.)
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
app.approvals.insert(bot, crate::providers::Approval { call_id: "c0".into(), tool: "shell".into(), reason: reason.into(), grant: "rm".into(), reply: tx, kind });
app.ask_keys.insert(bot, key.into());
rx
};
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
let banner = |answer: &str, call: &str| Cmd::Answer { bot, answer: answer.into(), text: String::new(), call: call.into(), notice: true };
let rx = card(&mut app, ApprovalKind::Action, "刪除 build", "call-2");
app.remote_cmd(&ctx, banner("once", "call-1"));
assert!(rx.try_recv().is_err(), "an old banner doesn't allow the new request");
assert!(app.approvals.contains_key(&bot));
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
assert!(app.state.bot(bot).unwrap().messages.iter().any(|m| m.note && m.text.contains("通知上的「允許/拒絕」沒有用上")));
// Its key, but 一律允許 (a banner has none) or a command too long for the banner: no.
app.remote_cmd(&ctx, banner("always", "call-2"));
assert!(rx.try_recv().is_err() && app.state.bot(bot).unwrap().allow_rules.is_empty());
app.remote_cmd(&ctx, banner("once", "call-2"));
assert!(matches!(rx.try_recv(), Ok(ApprovalAnswer::Once)));
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
let rx = card(&mut app, ApprovalKind::Action, "執行指令:\nrm -rf build\nrm -rf dist", "long");
app.remote_cmd(&ctx, banner("once", "long"));
assert!(rx.try_recv().is_err(), "the banner showed only its first line");
// A hand-off or a question isn't answered from a banner, even with its key…
let rx = card(&mut app, ApprovalKind::Handoff, "登入", "h");
app.remote_cmd(&ctx, banner("once", "h"));
assert!(rx.try_recv().is_err(), "允許 on a banner is never 我完成了");
// …but the phone's own card answers it, with that key.
app.remote_cmd(&ctx, Cmd::Answer { bot, answer: "once".into(), text: String::new(), call: "h".into(), notice: false });
assert!(matches!(rx.try_recv(), Ok(ApprovalAnswer::Once)), "我完成了 on the phone's card");
let rx = card(&mut app, ApprovalKind::Question, r#"[{"question":"哪一天?"}]"#, "q");
app.remote_cmd(&ctx, banner("reject", "q"));
assert!(rx.try_recv().is_err(), "拒絕 on a banner is never 略過");
app.remote_cmd(&ctx, Cmd::Answer { bot, answer: "answered".into(), text: r#"["週五"]"#.into(), call: "q".into(), notice: false });
assert_eq!(rx.try_recv(), Ok(ApprovalAnswer::Answered(r#"["週五"]"#.into())));
}
/// The phone's own card (and a screen) names its card too: a page too old to send a key, or
/// a card answered and replaced since, answers nothing while the next one waits; with nothing
/// waiting there is nothing to say.
#[test]
fn a_phone_answer_without_its_cards_key_answers_nothing() {
let (ctx, mut app) = demo();
let bot = app.state.bots[0].id;
let dock = |answer: &str, call: &str| Cmd::Answer { bot, answer: answer.into(), text: String::new(), call: call.into(), notice: false };
let (tx, rx) = std::sync::mpsc::channel();
app.approvals.insert(bot, crate::providers::Approval { call_id: "c0".into(), tool: "shell".into(), reason: "刪除 build".into(), grant: "rm".into(), reply: tx, kind: ApprovalKind::Action });
app.ask_keys.insert(bot, "now".into());
let notes = |app: &App| app.state.bot(bot).unwrap().messages.iter().filter(|m| m.note && m.text.contains("頁面太舊")).count();
app.remote_cmd(&ctx, dock("always", ""));
app.remote_cmd(&ctx, dock("once", "before"));
assert!(rx.try_recv().is_err() && app.state.bot(bot).unwrap().allow_rules.is_empty(), "no key, or an old one: nothing");
assert_eq!(notes(&app), 2, "each one says so");
app.remote_cmd(&ctx, dock("reject", "now"));
assert_eq!(rx.try_recv(), Ok(ApprovalAnswer::Reject));
// Nothing waits now: an answer that comes late says nothing.
app.remote_cmd(&ctx, dock("once", "now"));
assert_eq!(notes(&app), 2);
}
#[test]
fn the_phone_does_what_the_desktop_does() {
let (ctx, mut app) = demo();
assert!(app.demo && app.state.bots.len() >= 2);
let b = app.state.bots[0].id;
let act = |app: &mut App, what: &str, body: serde_json::Value, role: &str| app.phone_act(&ctx, what, &body, role);
// The actions a bot can take, by the same appctl path.
let v = act(&mut app, "app", json!({"bot": b, "name": "create_routine", "args": {"title": "早報", "prompt": "整理新聞", "schedule": {"frequency": "daily", "time": "08:00"}}}), "owner");
assert_eq!(v["ok"], true, "{v}");
let rid = app.state.bot(b).unwrap().routines.iter().find(|r| r.title == "早報").map(|r| r.id).expect("routine made");
assert_eq!(act(&mut app, "app", json!({"bot": b, "name": "update_routine", "args": {"id": rid, "paused": true}}), "owner")["ok"], true);
assert!(app.state.bot(b).unwrap().routines.iter().any(|r| r.id == rid && r.paused));
assert_eq!(act(&mut app, "app", json!({"bot": b, "name": "remember", "args": {"fact": "週末不排工作"}}), "owner")["ok"], true);
assert!(app.state.bot(b).unwrap().memories.contains(&"週末不排工作".to_string()));
// Only the app actions a bot has; nothing else through this door.
assert!(act(&mut app, "app", json!({"bot": b, "name": "write_page", "args": {}}), "owner")["error"].is_string());
assert!(act(&mut app, "nothing", json!({}), "owner")["error"].is_string());
// A bot's switches, checked like the editor checks them.
assert_eq!(act(&mut app, "bot", json!({"bot": b, "key": "shape", "value": "star"}), "owner")["ok"], true);
assert_eq!(app.state.bot(b).unwrap().shape, "star");
assert!(act(&mut app, "bot", json!({"bot": b, "key": "shape", "value": "<script>"}), "owner")["error"].is_string());
assert_eq!(act(&mut app, "bot", json!({"bot": b, "key": "pinned", "value": true}), "owner")["ok"], true);
assert!(app.state.bot(b).unwrap().pinned);
// 團隊: an admin keeps what the phone always let them do, and small chat things…
assert_eq!(act(&mut app, "bot", json!({"bot": b, "key": "unread", "value": true}), "admin")["ok"], true);
assert!(act(&mut app, "detail", json!({"bot": b}), "admin")["id"].is_u64());
// …but making, changing or deleting bots, routines, memories, pages and folders is the owner's.
for (what, body) in [
("app", json!({"bot": b, "name": "update_routine", "args": {"id": rid, "paused": false}})),
("app", json!({"bot": b, "name": "create_bot", "args": {"name": "x"}})),
("app", json!({"bot": b, "name": "remember", "args": {"fact": "x"}})),
("bot", json!({"bot": b, "key": "pinned", "value": false})),
("bot", json!({"bot": b, "key": "shape", "value": "cloud"})),
("group_chat", json!({"members": [b]})),
("clear", json!({"bot": b})),
("delete_page", json!({"id": 1})),
("box", json!({"op": "snapshot"})),
] {
assert!(act(&mut app, what, body.clone(), "admin")["error"].is_string(), "admin did {what} {body}");
}
assert!(app.state.bot(b).unwrap().routines.iter().any(|r| r.id == rid && r.paused));
assert!(app.state.bot(b).unwrap().pinned && app.state.bot(b).unwrap().shape == "star");
// The owner's alone: permissions, a bot's computer tools, deleting a bot.
assert!(act(&mut app, "setting", json!({"key": "auto_review", "value": true}), "admin")["error"].is_string());
assert!(act(&mut app, "bot", json!({"bot": b, "key": "tools", "value": true}), "admin")["error"].is_string());
assert!(act(&mut app, "delete_bot", json!({"bot": b}), "admin")["error"].is_string());
assert_eq!(act(&mut app, "setting", json!({"key": "rule_add", "list": "ask", "value": "付款前先問我"}), "owner")["ok"], true);
assert!(app.state.review_ask_rules.contains(&"付款前先問我".to_string()));
assert_eq!(act(&mut app, "setting", json!({"key": "rule_remove", "list": "ask", "value": "付款前先問我"}), "owner")["ok"], true);
assert!(!app.state.review_ask_rules.contains(&"付款前先問我".to_string()));
// 群組聊天 as the desktop's menu makes it.
let others: Vec<u64> = app.state.bots.iter().filter(|x| x.members.is_empty()).map(|x| x.id).take(2).collect();
let g = act(&mut app, "group_chat", json!({"members": others}), "owner");
let gid = g["bot"].as_u64().expect("group made");
assert_eq!(app.state.bot(gid).unwrap().members, others);
// Deleting (the owner): gone, and there is still a main bot.
assert_eq!(act(&mut app, "delete_bot", json!({"bot": gid}), "owner")["ok"], true);
assert!(app.state.bot(gid).is_none() && app.state.bot(app.state.primary_bot).is_some());
}
技能: / in the input picks one; on a brain's screen the brain adds, installs and deletes them; 設定 › 整合's lists keep their buttons clear - Typing / at the start of the input (computer and phone) lists the skills that are on: names that start with what is typed first, then names containing it, then descriptions (「/簡報」 finds pptx). A click, or ↑↓ and Enter/Tab, puts 「/name 」 in the input; Esc closes the list. Sent, the brain recognises 「/name」 and adds a line after the message telling the model to read that skill with use_skill first, so a phone or a message channel gets it too; a / that names no skill (a path) gets nothing. The phone asks the brain for the list again at each new /, so a skill added since is there. - On a screen, 加入 / 安裝 / 刪除 ran on the screen's own disk and only the list entry reached the brain: a GitHub skill's scripts stayed on the screen's computer, an install also pushed every skill in that computer's folder into the brain's list, and a deleted skill's folder stayed on the brain and came back at its next start. These now go to the brain (/api/sync/skill, the phone's own 「skill」 action): it fetches an address itself, a folder or .md file on the screen's computer goes up whole with its files, and a delete takes the folder too. 「把這台的 Bot 搬到大腦」 hands over skills the same way. A refused package leaves no folder behind. - 技能, 技能市集 and 連接器市集 rows: a long description took the whole row and 開啟 / 檢視 / 刪除 / 已加入 / 安裝 were drawn over it. The buttons are laid out first and the description ends in … before them (the whole of it on hover). - Screenshot mode: ANYBOT_SHOT_KEYS="ArrowDown@60;Enter@64" presses keys at given frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:54:58 +00:00
/// 技能 from a screen are the brain's to do: a folder from that computer lands on the brain's
/// disk whole (text and binary files), and a delete takes the folder too, so the next start
/// doesn't bring the skill back.
#[test]
fn a_screen_hands_a_skill_to_the_brain_and_takes_it_away() {
let (ctx, mut app) = demo();
let name = format!("螢幕交來的技能-{}", std::process::id());
let src = std::env::temp_dir().join(format!("anybot-screen-skill-{}", std::process::id()));
std::fs::create_dir_all(src.join("scripts")).unwrap();
std::fs::write(src.join("SKILL.md"), format!("---\nname: {name}\ndescription: 測試用\n---\n\n先跑 scripts/go.py\n")).unwrap();
std::fs::write(src.join("scripts/go.py"), "print('hi')\n").unwrap();
std::fs::write(src.join("scripts/logo.bin"), [0u8, 159, 146, 150]).unwrap();
let pkg = crate::skills::package_from_path(&src).unwrap();
// (The brain never sees the screen's disk.)
std::fs::remove_dir_all(&src).unwrap();
let r = app.phone_act(&ctx, "skill", &json!({"package": pkg}), "owner");
assert_eq!(r["ok"], true, "{r}");
let k = app.state.skills.iter().find(|k| k.name == name).cloned().expect("on the brain's list");
assert_eq!(k.resources, ["scripts/go.py", "scripts/logo.bin"]);
assert_eq!(crate::skills::read_resource(&k, "scripts/go.py").unwrap(), "print('hi')\n");
let dir = crate::skills::resolve_skill_dir(&k).expect("a folder on the brain");
assert_eq!(std::fs::read(dir.join("scripts/logo.bin")).unwrap(), [0u8, 159, 146, 150]);
// Deleted from the screen: off the list and off the disk.
assert_eq!(app.phone_act(&ctx, "skill", &json!({"name": name, "remove": true}), "owner")["ok"], true);
assert!(!dir.exists());
crate::memory::merge_skill_files(&mut app.state.skills);
assert!(!app.state.skills.iter().any(|k| k.name == name), "a restart doesn't bring it back");
// Only the owner's.
assert!(app.phone_act(&ctx, "skill", &json!({"builtin": "pdf"}), "admin")["error"].is_string());
連接器: a 公用市集 of remote servers from the official MCP Registry, on the computer and the phone - 連接器市集 gets a search box over registry.modelcontextprotocol.io (public, with an API): servers reached by address only (a package would have to run on the brain, which may have no Node or uv); old SSE ones are marked as not yet supported, taken-down ones left out. A name that only says "mcp" (com.notion/mcp) reads as whose it is (notion). - 加入 on the computer fills 新增連接器 and scrolls to it: a free name, the address, and the header with the registry's placeholder ("Authorization: Bearer {smithery_api_key}"), shown unmasked with what to put there (the key's description, an address variable's choices). 新增 stays off while a 「{…}」 is left. - The phone: 設定 › 整合 › 從公用市集加入. The brain searches (the phone's page may only talk to its own server; GET /api/mcp/registry, owner only, on the HTTP thread); a pick asks for the key or the address part and the brain adds it (the 「mcp」 action's new `add`). - A server that answers 401 (or a 403 asking for a login) with no key given now says it signs people in with OAuth, which AnyBot can't do yet; with a key, that the key is wrong or old. - mcpservers.org and the like are pages for people behind a browser check, with no list a program may read, so the market uses the registry. - Checked live: 「notion」 finds 6; AWS Knowledge (no key) connects with 5 tools; Notion's own server (OAuth) gives the OAuth sentence. `cargo test -- --ignored registry_search_live`. - Screenshot mode: ANYBOT_SHOT_MCP=<search> shows the 公用市集 after that search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:12:12 +00:00
}
/// A connector renamed on a screen: the brain renames its own entry — its keys, its place in
/// the list and its sign-in stay — and refuses an empty or taken name.
#[test]
fn the_brain_renames_a_connector_for_a_screen() {
let (ctx, mut app) = demo();
let tag = crate::httpd::random_hex(4);
let (gh, other) = (format!("gh-{tag}"), format!("x-{tag}"));
let server = |n: &str, url: &str| crate::mcp::Server { name: n.into(), url: url.into(), password: "pw".into(), enabled: true, ..Default::default() };
app.state.mcp_servers = vec![server(&gh, "https://gh.example/mcp"), server(&other, "https://x.example/mcp")];
crate::mcp_oauth::save_for_test(&gh, crate::mcp_oauth::Tokens { access: "tok".into(), url: "https://gh.example/mcp".into(), ..Default::default() });
fix: 連接器改名不走手機的路、一律允許跟著改名;在別處按 Enter 不再替你允許 - 手機的 /api/act/mcp 不收改名(區網沒加密:讀到一次登入的人可以靠兩次改名,讓別的連接器 接手某個連接器的「一律允許」)。改名只走螢幕電腦的 /api/sync/mcp-rename。 - 改名時每個 Bot 的「一律允許」(mcp:<名稱>)跟著改到新名字;之後別的連接器取舊名字也不會繼承。 - 螢幕電腦上改名不先改本機:請大腦改,新名字隨大腦的更新回來(期間連接器的頁照舊找得到); 大腦沒改成,兩邊都還是舊名字。沒改成的原因:還在那一頁寫在頁上,已經離開就用通知說。 - 審批:聊天裡有等你允許的卡片時,在設定視窗或別的輸入框按 Enter,會被當成「允許」 (main 就有)。現在設定開著、或這一幀開始時游標在別的輸入框,Enter/Esc 不回答卡片。 一張沒有選項的問題卡也不在設定開著時搶走游標。 - 測試:改名的打字測試改成照欄位 id 給游標(平行的測試會換語言、版面跟著變), 原因用頁面記下的字比對。這兩個問題是這個測試在整套一起跑時時好時壞找到的。 已驗證: cargo test 整套連跑 8 次全綠(620);新測試 enter_elsewhere_does_not_approve_the_waiting_step、 a_screen_asks_the_brain_to_rename_a_connector、a_connector_is_never_renamed_through_the_phones_road; the_brain_renames_a_connector_for_a_screen(一律允許跟著改)。 未驗證: 螢幕電腦連真的大腦實際改名(要兩台機器)。 動到審批路徑(approval_dock 的 Enter/Esc):依 CLAUDE.md 需要實機測試+人類簽名,不得自行發佈。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3KhvSzysuKUobKUTR
2026-11-17 10:35:57 +00:00
app.state.bots[0].allow_rules.push(format!("mcp:{gh}"));
let new = format!("{gh}-work");
assert_eq!(app.phone_act(&ctx, "mcp", &json!({"name": gh, "rename": new}), "owner")["ok"], true);
let first = &app.state.mcp_servers[0];
assert_eq!((first.name.as_str(), first.password.as_str()), (new.as_str(), "pw"), "same place, same keys");
assert_eq!(crate::mcp_oauth::bearer(&new, "https://gh.example/mcp").as_deref(), Some("tok"));
assert!(crate::mcp_oauth::tokens(&gh).is_none());
fix: 連接器改名不走手機的路、一律允許跟著改名;在別處按 Enter 不再替你允許 - 手機的 /api/act/mcp 不收改名(區網沒加密:讀到一次登入的人可以靠兩次改名,讓別的連接器 接手某個連接器的「一律允許」)。改名只走螢幕電腦的 /api/sync/mcp-rename。 - 改名時每個 Bot 的「一律允許」(mcp:<名稱>)跟著改到新名字;之後別的連接器取舊名字也不會繼承。 - 螢幕電腦上改名不先改本機:請大腦改,新名字隨大腦的更新回來(期間連接器的頁照舊找得到); 大腦沒改成,兩邊都還是舊名字。沒改成的原因:還在那一頁寫在頁上,已經離開就用通知說。 - 審批:聊天裡有等你允許的卡片時,在設定視窗或別的輸入框按 Enter,會被當成「允許」 (main 就有)。現在設定開著、或這一幀開始時游標在別的輸入框,Enter/Esc 不回答卡片。 一張沒有選項的問題卡也不在設定開著時搶走游標。 - 測試:改名的打字測試改成照欄位 id 給游標(平行的測試會換語言、版面跟著變), 原因用頁面記下的字比對。這兩個問題是這個測試在整套一起跑時時好時壞找到的。 已驗證: cargo test 整套連跑 8 次全綠(620);新測試 enter_elsewhere_does_not_approve_the_waiting_step、 a_screen_asks_the_brain_to_rename_a_connector、a_connector_is_never_renamed_through_the_phones_road; the_brain_renames_a_connector_for_a_screen(一律允許跟著改)。 未驗證: 螢幕電腦連真的大腦實際改名(要兩台機器)。 動到審批路徑(approval_dock 的 Enter/Esc):依 CLAUDE.md 需要實機測試+人類簽名,不得自行發佈。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3KhvSzysuKUobKUTR
2026-11-17 10:35:57 +00:00
assert!(app.state.bots[0].allow_rules.contains(&format!("mcp:{new}")) && !app.state.bots[0].allow_rules.contains(&format!("mcp:{gh}")), "「一律允許」 follows it");
for bad in [other.as_str(), " "] {
assert!(app.phone_act(&ctx, "mcp", &json!({"name": new, "rename": bad}), "owner")["error"].is_string(), "{bad:?}");
}
assert!(app.phone_act(&ctx, "mcp", &json!({"name": new, "rename": "y"}), "admin")["error"].is_string(), "the owner's only");
// Removed: its 「一律允許」 go with it (one given its name later starts from nothing).
assert_eq!(app.phone_act(&ctx, "mcp", &json!({"name": new, "remove": true}), "owner")["ok"], true);
assert!(!app.state.bots[0].allow_rules.iter().any(|r| r.starts_with("mcp:gh-")));
let _ = crate::mcp_oauth::logout(&new);
}
連接器: a 公用市集 of remote servers from the official MCP Registry, on the computer and the phone - 連接器市集 gets a search box over registry.modelcontextprotocol.io (public, with an API): servers reached by address only (a package would have to run on the brain, which may have no Node or uv); old SSE ones are marked as not yet supported, taken-down ones left out. A name that only says "mcp" (com.notion/mcp) reads as whose it is (notion). - 加入 on the computer fills 新增連接器 and scrolls to it: a free name, the address, and the header with the registry's placeholder ("Authorization: Bearer {smithery_api_key}"), shown unmasked with what to put there (the key's description, an address variable's choices). 新增 stays off while a 「{…}」 is left. - The phone: 設定 › 整合 › 從公用市集加入. The brain searches (the phone's page may only talk to its own server; GET /api/mcp/registry, owner only, on the HTTP thread); a pick asks for the key or the address part and the brain adds it (the 「mcp」 action's new `add`). - A server that answers 401 (or a 403 asking for a login) with no key given now says it signs people in with OAuth, which AnyBot can't do yet; with a key, that the key is wrong or old. - mcpservers.org and the like are pages for people behind a browser check, with no list a program may read, so the market uses the registry. - Checked live: 「notion」 finds 6; AWS Knowledge (no key) connects with 5 tools; Notion's own server (OAuth) gives the OAuth sentence. `cargo test -- --ignored registry_search_live`. - Screenshot mode: ANYBOT_SHOT_MCP=<search> shows the 公用市集 after that search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:12:12 +00:00
/// The phone's 公用市集 adds a server reached by address, with its key; never one with a
/// 「{…}」 left in it, never twice under one name, only the owner.
#[test]
fn the_phone_adds_a_connector_from_the_public_market() {
let (ctx, mut app) = demo();
let add = |name: &str, url: &str, header: &str| json!({"add": {"name": name, "url": url, "header": header}});
let r = app.phone_act(&ctx, "mcp", &add("Smithery", "https://server.smithery.ai/x/mcp", "Authorization: Bearer sk-1"), "owner");
assert_eq!(r["ok"], true, "{r}");
let m = app.state.mcp_servers.iter().find(|m| m.name == "Smithery").expect("added");
assert_eq!((m.url.as_str(), m.headers.get("Authorization").map(String::as_str), m.enabled), ("https://server.smithery.ai/x/mcp", Some("Bearer sk-1"), true));
assert_eq!(app.phone_act(&ctx, "mcp", &add("Smithery", "https://y.example/mcp", ""), "owner")["ok"], true);
assert!(app.state.mcp_servers.iter().any(|m| m.name == "Smithery 2"));
assert!(app.phone_act(&ctx, "mcp", &add("x", "https://y.example/mcp", "Authorization: Bearer {key}"), "owner")["error"].is_string());
assert!(app.phone_act(&ctx, "mcp", &add("x", "https://{host}/mcp", ""), "owner")["error"].is_string());
assert!(app.phone_act(&ctx, "mcp", &add("x", "npx -y evil", ""), "owner")["error"].is_string());
assert!(app.phone_act(&ctx, "mcp", &add("x", "https://y.example/mcp", ""), "admin")["error"].is_string());
// 重新連線: its old error goes, and the next poll connects it again (owner only).
app.ch.mcp_errors.lock().unwrap().push(("Smithery".into(), "連不上".into()));
app.ch.mcp_sig = "connected before".into();
assert!(app.phone_act(&ctx, "mcp", &json!({"name": "Smithery", "reconnect": true}), "admin")["error"].is_string());
let r = app.phone_act(&ctx, "mcp", &json!({"name": "Smithery", "reconnect": true}), "owner");
assert_eq!(r["ok"], true, "{r}");
assert!(app.ch.mcp_errors.lock().unwrap().is_empty() && app.ch.mcp_sig.is_empty());
assert!(app.state.mcp_servers.iter().any(|m| m.name == "Smithery"), "reconnecting keeps it");
// What 連接器 shows (here, and at a screen of this brain).
app.ch.mcp_errors.lock().unwrap().push(("Smithery 2".into(), "HTTP 401".into()));
let st = app.mcp_state();
assert_eq!(st["servers"]["Smithery 2"]["error"], "HTTP 401");
assert!(st["servers"]["Smithery"]["tools"].is_null() && st["servers"]["Smithery"]["error"].is_null());
技能: / in the input picks one; on a brain's screen the brain adds, installs and deletes them; 設定 › 整合's lists keep their buttons clear - Typing / at the start of the input (computer and phone) lists the skills that are on: names that start with what is typed first, then names containing it, then descriptions (「/簡報」 finds pptx). A click, or ↑↓ and Enter/Tab, puts 「/name 」 in the input; Esc closes the list. Sent, the brain recognises 「/name」 and adds a line after the message telling the model to read that skill with use_skill first, so a phone or a message channel gets it too; a / that names no skill (a path) gets nothing. The phone asks the brain for the list again at each new /, so a skill added since is there. - On a screen, 加入 / 安裝 / 刪除 ran on the screen's own disk and only the list entry reached the brain: a GitHub skill's scripts stayed on the screen's computer, an install also pushed every skill in that computer's folder into the brain's list, and a deleted skill's folder stayed on the brain and came back at its next start. These now go to the brain (/api/sync/skill, the phone's own 「skill」 action): it fetches an address itself, a folder or .md file on the screen's computer goes up whole with its files, and a delete takes the folder too. 「把這台的 Bot 搬到大腦」 hands over skills the same way. A refused package leaves no folder behind. - 技能, 技能市集 and 連接器市集 rows: a long description took the whole row and 開啟 / 檢視 / 刪除 / 已加入 / 安裝 were drawn over it. The buttons are laid out first and the description ends in … before them (the whole of it on hover). - Screenshot mode: ANYBOT_SHOT_KEYS="ArrowDown@60;Enter@64" presses keys at given frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 08:54:58 +00:00
}
#[test]
fn the_phone_never_gets_keys_or_secrets() {
let (ctx, mut app) = demo();
let key = "sk-test-very-secret-1234567890";
app.state.providers.entry("openai".into()).or_default().api_key = key.into();
app.state.channels.push(crate::channels::Channel { id: 9, kind: crate::channels::Kind::Telegram, name: "t".into(), bot_id: app.state.bots[0].id, token: "tg-secret-token".into(), target: String::new(), enabled: true, client_id: String::new(), tenant: String::new() });
for role in ["owner", "admin"] {
let s = app.phone_act(&ctx, "settings", &json!({}), role).to_string();
assert!(!s.contains(key) && !s.contains("tg-secret-token"), "{role}: {s}");
assert!(s.contains("\"ready\":true"), "{s}");
}
// A key goes in (the owner's), and still never comes out.
let openai = serde_json::to_value(crate::providers::ProviderKind::OpenAi).unwrap();
assert!(app.phone_act(&ctx, "provider", &json!({"provider": openai, "key": "sk-new-secret-999"}), "admin")["error"].is_string());
assert_eq!(app.phone_act(&ctx, "provider", &json!({"provider": openai, "key": "sk-new-secret-999", "default_model": "gpt-5"}), "owner")["ok"], true);
assert_eq!(app.state.provider(crate::providers::ProviderKind::OpenAi).api_key, "sk-new-secret-999");
assert!(!app.phone_act(&ctx, "settings", &json!({}), "owner").to_string().contains("sk-new-secret-999"));
assert!(app.phone_act(&ctx, "box", &json!({"op": "reset"}), "admin")["error"].is_string());
// The owner's own lists only to the owner.
assert!(app.phone_act(&ctx, "settings", &json!({}), "admin").get("devices").is_none());
assert!(app.phone_act(&ctx, "settings", &json!({}), "owner").get("devices").is_some());
let b = app.state.bots[0].id;
let d = app.phone_act(&ctx, "detail", &json!({"bot": b}), "owner").to_string();
assert!(!d.contains(key) && d.contains("\"memories\""), "{d}");
}
修正卡死: ⌘ 一按視窗就鎖死、圖表縮小凍結、打字每鍵寫檔;複製中文亂碼;頭像不再擋住思考動畫 卡住當機 - ⌘1–⌘9(Win/Linux 為 Ctrl)在 ctx.input 裡又呼叫 ctx.input,egui 的 Context 被鎖兩次, 按住 ⌘(⌘C、⌘V、⌘Tab)視窗就永遠不動;改為只讀一次(bot_jump_key),加回歸測試 - 圖表 x 軸格線固定每 1 一條,縮小後一幀要畫上百萬條(凍結、記憶體爆);改為最多約 40 條, 滾輪不再被圖表吃掉(⌘/Ctrl+滾輪或雙指縮放) - 草稿每打一個字就同步重寫整個 state.json(含 fsync);改為停手 1.5 秒後才存,結尾空白也 不再造成每幀存檔 複製(三個系統) - Mac:pbcopy 從 Finder/Dock 開時沒有 UTF-8 語系,中文變亂碼;指定 UTF-8 - ⌘C 攔截只拿 CopyText,不再丟掉開連結、複製圖片、Linux 中鍵選取等指令(且只在 Mac 攔) - Windows:改用 Win32 剪貼簿(arboard,獨立執行緒),不再走 clip.exe(缺 BOM、多一個 NUL) - Linux:依 WAYLAND_DISPLAY/DISPLAY 選 wl-copy 或 xclip/xsel,都沒有時退回視窗剪貼簿 其他 - 頁面目錄點了不跳(標題位置從未記錄);目錄搜尋框按 Esc 會關掉整頁 - 圖表:單一系列欄名被 String::max 換成「數值」;同尺寸無標題的圖共用縮放;inf/NaN 不入圖 - KPI 卡片寬度未扣內距而超出欄寬 - 「還原上一個答案」在送出新訊息後會插錯位置;重試錯誤回覆不再存可還原的版本 - 手機:長輪詢回來時已切到別的聊天,不再把上一個聊天的訊息畫進來 - 輸入框上方頭像:思考時頭稍微縮小,三顆小球繞著頭轉(後面的從頭後經過、前面的壓在頭上並描邊), 不再被頭像蓋住 - 刪除未使用的 src/app/ui_kit.rs 驗證:macOS cargo test 374 通過(relay 18 通過);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 06:19:59 +00:00
#[test]
fn web_client_search_export_import_and_pin_order() {
let (ctx, mut app) = demo();
let b0 = app.state.bots[0].id;
let b1 = app.state.bots[1].id;
let b2 = app.state.bots[2].id;
app.state.bot_mut(b1).unwrap().messages.push(Message { at: 12345, ..Message::user("台南高鐵票與牛肉湯清單") });
// Cross-chat search finds the message and names its bot.
let s = app.phone_act(&ctx, "search", &json!({"q": "牛肉湯"}), "owner");
assert_eq!(s["ok"], true);
assert_eq!(s["hits"][0]["bot"], b1);
assert!(s["hits"][0]["snippet"].as_str().unwrap_or("").contains("牛肉湯"));
// Pin ordering and dragging into a folder unpins cleanly.
assert_eq!(app.phone_act(&ctx, "bot", &json!({"bot": b1, "key": "pin_at", "value": 0}), "owner")["ok"], true);
assert_eq!(app.phone_act(&ctx, "bot", &json!({"bot": b2, "key": "pin_at", "value": 0}), "owner")["ok"], true);
assert_eq!(app.pinned_ids()[0], b2);
assert_eq!(app.phone_act(&ctx, "bot", &json!({"bot": b2, "key": "folder", "value": "工作"}), "owner")["ok"], true);
assert!(!app.state.bot(b2).unwrap().pinned && app.state.bot(b2).unwrap().folder == "工作");
// Export .anybot and import back as a new bot; transcript exports Markdown.
let ex = app.phone_act(&ctx, "export_bot", &json!({"bot": b0}), "owner");
assert_eq!(ex["ok"], true);
let content = ex["content"].as_str().unwrap();
let im = app.phone_act(&ctx, "import_bot", &json!({"content": content}), "owner");
assert_eq!(im["ok"], true, "{im}");
assert!(app.state.bot(im["bot"].as_u64().unwrap()).is_some());
let md = app.phone_act(&ctx, "export_transcript", &json!({"bot": b1}), "admin");
assert_eq!(md["ok"], true);
assert!(md["content"].as_str().unwrap_or("").contains("牛肉湯"));
}
}
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
/// 等你允許的卡片:一個回答落在哪一張卡上(.claude/skills/verify-approval-routing 的 TLA+
/// 模型)。模型找到的步驟在真的程式上一步一步重走,每一行註解是模型的一個動作
/// (ApprovalRouting.tla)。這裡只有測試,不改任何行為。
#[cfg(test)]
mod approval_routing_replay {
use super::*;
use std::sync::mpsc::{channel, Receiver};
/// 大腦(示範資料,不讀也不寫磁碟),第一個 Bot 有一輪在跑:drain_events 只收這一輪的事件。
fn brain(name: &str) -> (egui::Context, App, u64) {
let ctx = egui::Context::default();
let mut app = App::new(&ctx, Some(std::env::temp_dir().join(name)));
let id = app.state.bots[0].id;
app.streams.insert(id, Live { cancel: Arc::new(AtomicBool::new(false)), started: Instant::now(), last: Instant::now(), produced: true, status: None, paused: false, paused_at: None, unattended: false, steer: Arc::new(Mutex::new(vec![])), direct: Arc::new(AtomicBool::new(false)), turn_id: "t".into(), turn: 1 });
(ctx, app, id)
}
/// BotAsks + CardShows:Bot 送出 NeedApproval(帶這張卡自己的 reply),大腦的 drain_events
/// 收下:approvals.insert、on_new_approval 發這張卡的 key。call_0:沒給編號的模型服務每一輪
/// 都從 call_0 數起。
fn bot_asks(app: &mut App, ctx: &egui::Context, id: u64, reason: &str, grant: &str) -> Receiver<ApprovalAnswer> {
let (reply, got) = channel();
app.tx.send((id, 1, StreamEvent::NeedApproval(crate::providers::Approval { call_id: "call_0".into(), tool: "shell".into(), reason: reason.into(), grant: grant.into(), reply, kind: ApprovalKind::Action }))).unwrap();
app.drain_events(ctx);
assert!(app.approvals.get(&id).is_some_and(|a| a.reason == reason), "the card is up");
got
}
/// Guarded.cfg 守的那條路(FreshKeyPerCard、BannerKeyChecked 任一條不成立時模型的反例):
/// 手機通知是第一張卡的,第一張在電腦上回答了、Bot 問了第二件事,這時按通知上的「允許」,
/// 第二件事不能通過。
#[test]
fn an_old_banner_does_not_allow_the_next_card() {
let (ctx, mut app, id) = brain("anybot-replay-banner.png");
let first = bot_asks(&mut app, &ctx, id, "執行指令:ls", "ls");
// (通知帶的是這張卡的 key:on_new_approval → remote::notify_approval(…, &key)。)
let banner_key = app.ask_keys.get(&id).cloned().unwrap_or_default();
// YouAnswerOnDesk:電腦上按「允許」。
app.answer(&ctx, id, ApprovalAnswer::Once);
assert_eq!(first.try_recv(), Ok(ApprovalAnswer::Once));
// BotAsks + CardShows:下一件事。
let second = bot_asks(&mut app, &ctx, id, "執行指令:rm -rf ~/Documents/報告", "rm");
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
// YouTapBanner + BrainTakesAnswer:舊通知上的「允許」(sw.js:answer=once、call=d.ask;
// 頁面送出時加 from: "notice")。
app.remote_cmd(&ctx, Cmd::Answer { bot: id, answer: "once".into(), text: String::new(), call: banner_key, notice: true });
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
assert!(second.try_recv().is_err(), "第一張卡的通知讓第二件事通過了");
assert!(app.approvals.contains_key(&id), "the second card still waits");
}
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
/// F1(以前 AllSurfaces.cfg 的反例,已修好):手機頁面上畫的還是第一張卡,第一張已經不在了
/// (電腦上回答了),Bot 問了第二件事;這時在手機上按「一律允許」,第二件事不能通過,
/// 也不能把第二件事的類別記成一律允許——不管手機送的是它畫的那張卡的 key(現在的頁面),
/// 還是什麼都沒送(開了很久的舊頁面)。照舊的程式(沒帶 call 就交給那時候在等的卡)這個
/// 測試會失敗。最後,帶著第二張卡自己的 key 才算數。
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
#[test]
fn a_phone_card_tapped_after_it_changed_answers_nothing_else() {
let (ctx, mut app, id) = brain("anybot-replay-page.png");
let first = bot_asks(&mut app, &ctx, id, "執行指令:npm install", "npm install");
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
// PageRefreshes:手機輪詢 api/state,renderDock 畫出 approval_json 給的這張卡(和它的 key)。
let shown = approval_json(app.state.bot(id).unwrap(), app.approvals.get(&id).unwrap(), app.ask_keys.get(&id).map(String::as_str).unwrap_or(""));
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
assert!(shown["reason"].as_str().unwrap_or("").contains("npm install"), "{shown}");
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
let seen_key = shown["key"].as_str().unwrap_or("").to_string();
assert!(!seen_key.is_empty(), "the phone gets the card's key: {shown}");
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
// YouAnswerOnDesk:電腦上按「允許」。
app.answer(&ctx, id, ApprovalAnswer::Once);
assert_eq!(first.try_recv(), Ok(ApprovalAnswer::Once));
// BotAsks + CardShows:下一件事。
let second = bot_asks(&mut app, &ctx, id, "執行指令:rm -rf ~/Documents/報告", "rm");
// YouTapOnPage + BrainTakesAnswer:手機上還是 npm install 那張,按「一律允許」:
fix: 手機頁面和螢幕電腦的回答只交給它畫出來的那張卡(F1);通知上的按鈕只答允許請求 - 每張卡的 key(on_new_approval 發的)給手機(approval_json;支線的卡用支線自己的)和螢幕電腦 (brain_pull 的 approvals → mir.keys)。手機的允許/一律允許/拒絕、「全部允許,之後直接操作」、 問題卡的送出和略過、螢幕電腦的回答都帶 call。 - Cmd::Answer:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收; 有卡在等時聊天寫「沒有用上」。通知送來的(from: "notice")另外要過 notice_answers——放通知按鈕和 收通知回答用同一條規則——而且只收 once/reject:絕不是「我完成了」「略過」或一律允許。 - 螢幕電腦用大腦的 key 分辨新卡(call id 會重複),自己的卡也用那把 key;手機問題卡的表單用 key 分辨;手機畫面的簽章帶 key,新卡一定送到手機。 - verify-approval-routing 跟到修好的程式:程式事實換成現在的、加上卡的種類和 NoticeNeverFinishesHandoff;AllSurfaces 通過,CanAnswer 確認手機頁面、通知、螢幕電腦都還答得到; F1 的重走測試不再 ignore(舊程式會失敗),新增 a_phone_answer_without_its_cards_key_answers_nothing、 a_screen_answers_only_the_card_it_shows;同步 commit 改成「最後一次改 coverage.tsv 的 commit」。 - 功能地圖 phone、safety 和 FEATURES.md 跟著改。 - 部署要注意:帳號伺服器(relay/)自己編進一份手機頁面。它更新以前,用帳號登入的手機送不出 key, 手機上的卡都答不了(安全,但要在電腦上答);直接連線的手機用大腦給的頁面,沒有這個問題。 已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)644 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;verify-approval-routing 的 run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、5 個重走測試通過;暫時改壞兩次都抓到(大腦收沒帶 key 的回答 → AllSurfaces 違反 AllowOnlyWhatWasSeen、兩個回歸測試失敗;手機不送 key → CanAnswer 不預期地通過),改回後回到基準;verify-anybot(scratch AnyBot、假模型、無頭 Chrome 的手機頁面):手機上的允許、拒絕、問題卡照樣有用;第三張卡在等時,用第二張卡的 key、不帶 key、舊通知(from notice)各送一次都不算、聊天寫「沒有用上」、第三張卡和它的 key 還在,之後手機自己的「允許」才讓它通過(證據 target/verify-anybot/20261118-104552) 未驗證: 真的手機上的推播通知按鈕(要帳號伺服器和 Android 手機);螢幕電腦實機(要第二台電腦登入同一個帳號,只有 mirror_ui 的測試);帳號伺服器給的頁面(relay/ 要重新部署);支線的卡、需要處理卡在手機上的「我完成了」只有單元測試(scratch Bot 沒有可以交給使用者的螢幕);--ignored 的實機測試(會開真的視窗和瀏覽器,留給人跑);大腦視窗按住「允許」時卡被換掉:沒有新發現,沒改 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:48:10 +00:00
// renderDock POST {answer: "always", call: a.key};舊頁面 POST {answer: "always"}。
for call in [seen_key, String::new()] {
app.remote_cmd(&ctx, Cmd::Answer { bot: id, answer: "always".into(), text: String::new(), call, notice: false });
let got = second.try_recv();
let rules = app.state.bot(id).map(|b| b.allow_rules.clone()).unwrap_or_default();
assert!(got.is_err() && !rules.iter().any(|g| g == "rm"), "手機上看到的是 npm install;rm -rf 那張收到 {got:?},一律允許記下 {rules:?}");
}
assert!(app.state.bot(id).unwrap().messages.iter().any(|m| m.note && m.text.contains("沒有用上")), "the person is told");
// 第二張卡畫到手機上以後,帶它自己的 key 才算數。
let now = approval_json(app.state.bot(id).unwrap(), app.approvals.get(&id).unwrap(), app.ask_keys.get(&id).map(String::as_str).unwrap_or(""));
app.remote_cmd(&ctx, Cmd::Answer { bot: id, answer: "reject".into(), text: String::new(), call: now["key"].as_str().unwrap_or("").into(), notice: false });
assert_eq!(second.try_recv(), Ok(ApprovalAnswer::Reject));
test: 等你允許的卡片「回答落在哪一張」用 TLA+ 驗證;找到 F1:手機頁面、螢幕電腦的允許會落在後來的卡上 - .claude/skills/verify-approval-routing:模型(ApprovalRouting.tla,每個動作對到程式碼)、三個 cfg、 一個指令 run.sh(固定 tla2tools 1.7.4+SHA-256、比對對照的程式碼有沒有改過、跑三個 cfg、--replay 在真的程式上重走)。 - 規則:允許/一律允許只讓按的人當時看到的那張卡通過;一律允許記下的類別就是那張卡的。 - 大腦視窗+手機通知(Guarded)通過;四個地方都能回答(AllSurfaces)違反:手機頁面 renderDock 和螢幕電腦的回答不帶 call,Cmd::Answer 交給「那時候」在等的卡,一律允許的 grant 也讀那張卡的(F1,沒有修)。 - src/app/remote_ui.rs 加 approval_routing_replay(只有測試):舊通知那條通過;F1 那條 #[ignore],在真的程式上失敗。 已驗證: run.sh 基準(Guarded、AllSurfacesKeyed 通過,AllSurfaces 只違反 F1),約 7 秒;--replay 在真的程式上重現 F1(rm -rf 那張收到 Always("rm")、allow_rules 記下 rm),舊通知那條通過;暫時把 on_new_approval 改成只發第一把 key:run.sh 報對照的程式碼改過,照技能對過模型(FreshKeyPerCard = FALSE)後 Guarded 違反、--replay 也失敗,現有的 a_banner_answers_only_its_own_request 等四個 approval 測試都沒抓到,改回後回到基準;每條規則都在改壞的版本上看過違反;/pstack:statechart 讀得出反例;cargo test featuremap:: app::remote_ui:: tool_specs_are_locked approval_decisions_are_characterized;cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh 未驗證: 真的手機和螢幕電腦上的 F1(要實機手機和第二台電腦);大腦視窗上按住「允許」時卡被換掉(沒放進模型);完整的 cargo test(只跑上面那些,免得 app 測試碰到 Bot 的 Docker 電腦) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:10:44 +00:00
}
}