AnyBot/src/web.rs

867 lines
46 KiB
Rust
Raw Normal View History

// Websites: read a public page, open a link in the person's browser, and read the tab they have
// open there (where they're already logged in: Threads, Instagram, Gmail…). The original reaches
// sites through its own browser; its old "copy logins from Chrome" import is retired (SAND-E0801..
// E0812 all say "removed"), so nothing is copied here either. AnyBot's own browser (botbrowser.rs)
// is used when a Chrome-family browser is installed; AppleScript on the person's browser otherwise.
use serde_json::{json, Value};
use std::process::{Command, Stdio};
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, Instant};
pub const NAMES: [&str; 4] = ["web_fetch", "browser_open", "browser_read", "browser_profiles"];
/// Longest page text handed to the model (estimated).
pub const MAX_PAGE_CHARS: usize = 20_000;
/// Largest download read for web_fetch (estimated).
const MAX_FETCH_BYTES: u64 = 3_000_000;
/// AppleScript can wait on macOS's "allow AnyBot to control Chrome?" prompt; give the person time.
const SCRIPT_TIMEOUT_SECS: u64 = 90;
/// Time for a page to load after opening it (estimated).
const OPEN_SETTLE_SECS: u64 = 4;
/// Browsers in the order they're tried (Chromium-style ones share the same AppleScript).
const BROWSERS: [(&str, bool); 6] = [("Google Chrome", true), ("Arc", true), ("Microsoft Edge", true), ("Brave Browser", true), ("Chromium", true), ("Safari", false)];
pub fn is_web_tool(name: &str) -> bool {
NAMES.contains(&name) || crate::browser::is_tool(name)
}
pub fn label(name: &str) -> &'static str {
match name {
"web_fetch" => "讀取網頁",
"browser_open" => "在瀏覽器打開",
"browser_read" => "讀取瀏覽器分頁",
"browser_profiles" => "瀏覽器設定檔",
n if crate::browser::is_tool(n) => crate::browser::label(n),
_ => "網頁",
}
}
/// Does this call use the person's own browser ("你的瀏覽器", or the fallback when no
/// Chrome-family browser is installed)?
pub fn uses_person_browser(args: &str) -> bool {
// The box has one browser, the bot's own; the person's browser is never in there.
if crate::botbrowser::using_box() {
return false;
}
if !crate::botbrowser::available() {
return true;
}
let v: Value = serde_json::from_str(if args.trim().is_empty() { "{}" } else { args }).unwrap_or(Value::Null);
crate::botbrowser::resolve(Some(arg(&v, "profile").as_str())).map(|p| p == crate::botbrowser::PERSON_PROFILE).unwrap_or(false)
}
/// browser_open / browser_read on the person's own browser run on this Mac.
pub fn uses_this_computer(name: &str, args: &str) -> bool {
// AnyBot's own browser is the bot's, like the reference assistant's; only the person's own browser counts
// as working on their computer. Profiles are the bot's browser's, never the person's.
(name == "browser_open" || name == "browser_read") && uses_person_browser(args)
}
/// Reading a tab asks first only when it's the person's own browser.
pub fn read_needs_permission(args: &str) -> bool {
uses_person_browser(args)
}
/// The browser tools. `browsers`: the computers with an AnyBot browser this bot can use (its own,
/// this one, the account's other computers), by name; each has its own logins.
pub fn specs_for(browsers: &[String], default: &str) -> Vec<Value> {
let mut v = specs_inner(!browsers.is_empty());
if !browsers.is_empty() {
let desc = format!("Which computer's AnyBot browser to use, by the computer's name. Each computer's browser has its own logins (a site logged in on one isn't on another). Default: {default}. Use another only when the person names it.");
for t in v.iter_mut().filter(|t| t["name"].as_str().map(|n| n == "browser" || n.starts_with("browser_")).unwrap_or(false)) {
t["parameters"]["properties"]["computer"] = json!({"type": "string", "enum": browsers, "description": desc});
}
}
v
}
fn specs_inner(browser: bool) -> Vec<Value> {
let (names, current) = if crate::botbrowser::available() {
(crate::botbrowser::choices().join(", "), crate::botbrowser::current())
} else {
(crate::botbrowser::DEFAULT_PROFILE.to_string(), crate::botbrowser::DEFAULT_PROFILE.to_string())
};
let profile = json!({"type": "string", "description": format!("Which AnyBot browser profile (設定檔) to use; each has its own logins (e.g. a different account). Profiles now: {names}. Names ending in {} are the person's own Firefox profiles (their logins; AnyBot opens them in a window it can operate — if the person has that profile open the everyday way, ask them to close that window first). \"{}\" is the person's own everyday browser (read through accessibility), in whichever Chrome profile they have open there. Leave out to use the current one ({current}).", crate::botbrowser::FIREFOX_MARK, crate::botbrowser::PERSON_PROFILE)});
安全、修正: 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 _ = browser;
let v = vec![
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
json!({"name": "web_fetch", "description": "Download a public web page and return its text (no login). For pages that need the person's login, or that only show text after scripts run, use browser_open.",
"parameters": {"type": "object", "properties": {"url": {"type": "string"}}, "required": ["url"]}}),
crate::browser::tool(&profile),
];
v
}
fn arg(v: &Value, k: &str) -> String {
v.get(k).and_then(Value::as_str).unwrap_or("").trim().to_string()
}
pub fn describe(name: &str, args: &str) -> String {
let v: Value = serde_json::from_str(args).unwrap_or(Value::Null);
match name {
"browser_read" => match arg(&v, "profile") {
p if p.is_empty() => "目前的分頁".into(),
p => format!("目前的分頁(設定檔「{p}」)"),
},
"browser_profiles" => match (arg(&v, "action").as_str(), arg(&v, "name")) {
("add" | "create", n) => format!("新增「{n}」"),
("use" | "switch", n) => format!("切換到「{n}」"),
fix: 十一個小錯——瀏覽器設定檔換得了、支線改不了設定、直接連線的拒絕照實說、手機的標籤和設定頁照實寫 1. 瀏覽器設定檔只能列出:browser 的 action 就是 profiles,裡面的 list/add/use 傳不到 browser_profiles,帶 name 也只列出。現在帶 name 就換到那個設定檔、還沒有就先新增 (profiles_tool 自己判斷,工具定義不變);步驟寫「切換到「…」」。 2. 支線改得了設定:支線的 update_bot 按允許後把主 Bot 改名。update_bot、update_settings、 update_my_profile、teach_skill,和新增/修改/移除連接器或 hook,在支線一律馬上回 「支線改不了設定:回到主線再請它改。」,不跳卡片;ChatGPT 登入登出照樣跳卡。 3. 直接連線的拒絕說「區網連線(沒有加密)」:直接連線是 https,擋的原因是只憑手機密碼。 改成「這會放寬 Bot 能做的事:同一個網路直接連的裝置只能收緊、不能放寬…」;能力、可以 用的電腦只有勾回才擋(勾掉以前也被擋)。 4. 本機網址的卡寫「(在 上)」:Bot 的電腦都開不了瀏覽器時,寫「(在 執行 AnyBot 的這台 電腦 上)」。 5. 手機把監看叫醒的訊息標「例行任務」:照電腦版的標籤表(目標、例行任務、觸發、訊息管道、 來自其他 Bot),加上「監看」;測試確認手機和電腦用同一張表。 6. 步驟名字:replay_skill 寫「重播技能 「記一筆」」(以前「工具 工作資料夾」);例行任務的 送出證據寫「傳訊息給其他 Bot 給 同事:早安」(以前「message_bot 工作資料夾」);只有 檔案步驟會寫資料夾。 7. 執行步驟用的模型的卡寫「自動 → 不分開」(以前「(空) → 「off」」)。 8. ChatGPT 的卡照要做的事寫標題:「…想要登出 ChatGPT 方案」「…想要換 ChatGPT 帳號」 (以前「想要ChatGPT 方案登入」),手機和電腦都是。 9. 正常關掉 AnyBot 時,沒做完的支線寫「AnyBot 關掉了,這條支線停了」(以前「被停止了」, 像使用者按了停止);還在等主線的也一起照實寫。 10. 手機的設定頁只讀一次:狀態版本一變就重讀開著的設定頁,其他頁下次打開重讀(/always-approve 填了預設規則,權限頁不用重新整理)。 11. 沒有 Docker 時手機的電腦頁寫「已是 v14」「這台 Docker 主機沒有 gVisor」:問不到的事送 null,頁面寫「沒有 Docker,現在沒有這台電腦」,不說有沒有 gVisor。 功能地圖:browser、branch、profile、autonomy、models、market、phone、files、replay、 routines、box 的子功能、Bot 那一行、步驟和看到的結果照新行為改;拿掉只在描述錯誤的陷阱 (autonomy 的設定頁不更新、box 的已是 v14)。FEATURES.md 同步。verify-approval-routing: approval_json、approval_body 只改了標題的字,模型的假設不變,rehash coverage.tsv(這個 commit 是新的同步 commit)。 找到但沒修:browser 的 tabs 也一樣,裡面的 switch/new/close 傳不到 browser_tabs(工具 說明本身就叫模型用 action 帶),要改工具定義才修得好。 已驗證: env -u 金鑰… DOCKER_HOST=unix:///nonexistent cargo test(676 過、46 ignored)、 cargo clippy --bin anybot --all-targets -D warnings、sh deploy/ci/lint-sh.sh、 verify-approval-routing run.sh --replay(10 個重走都過);新測試先在拿掉修正的程式上跑過、 11 個都失敗;verify-anybot 照地圖跑 box、browser、models、files、replay、routines、branch、 autonomy、profile、phone、market 的步驟,全部通過(證據在 target/verify-anybot/)。 未驗證: --ignored 的實機瀏覽器測試(botbrowser 的 reads_a_real_page、a_persons_firefox_profile、 a_finished_job_quits_its_firefox、a_finished_job_quits_its_chrome,browser 的 lines_go_in_whole_and_numbers_stay_put、a_send_is_seen_with_the_post_it_answers_and_its_own_address) 會開真的瀏覽器,要人在實機跑、簽名;本機網址的卡按「允許」(會開真的瀏覽器);電腦版視窗 上的卡片標題和支線卡(要開視窗);帳號連線的手機(要帳號伺服器)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 09:44:16 +00:00
// The model's call: a name alone switches to it (adding it when it is new).
("", n) if !n.is_empty() => format!("切換到「{n}」"),
_ => "列出設定檔".into(),
},
n if crate::browser::is_tool(n) => crate::browser::describe(n, args),
_ => arg(&v, "url"),
}
}
/// Run a web tool, with a picture when it took one (browser_screenshot).
pub fn run_full(name: &str, args: &str, cancel: &AtomicBool) -> (String, bool, Option<String>) {
if crate::browser::is_tool(name) {
if !crate::botbrowser::available() {
return ("這些瀏覽器工具需要 AnyBot 自己的瀏覽器(Chrome、Brave、Edge、Chromium 或 Firefox)。".into(), false, None);
}
if uses_person_browser(args) {
return ("點擊、輸入和其他操作只能在 AnyBot 自己的瀏覽器裡做。請用 browser_open 在 AnyBot 瀏覽器打開網頁(第一次要請使用者在那個視窗登入)。".into(), false, None);
}
let v: Value = serde_json::from_str(if args.trim().is_empty() { "{}" } else { args }).unwrap_or(Value::Null);
return crate::botbrowser::as_job(&arg(&v, "_job"), || {
// A click or a key can open a tab (a link to a new window): it is this job's.
let watch = matches!(name, "browser_click" | "browser_press");
let profile = Some(arg(&v, "profile")).filter(|p| !p.is_empty());
let before = if watch { crate::botbrowser::tab_ids(profile.as_deref()) } else { vec![] };
let r = match crate::browser::run(name, &v) {
Ok((t, img)) => (t, true, img),
Err(e) => (e, false, None),
};
if watch {
crate::botbrowser::adopt_new(profile.as_deref(), &before);
}
r
});
}
// browser_open / browser_read on the bot's browser: the job's own tabs too.
let v: Value = serde_json::from_str(if args.trim().is_empty() { "{}" } else { args }).unwrap_or(Value::Null);
let (t, ok) = crate::botbrowser::as_job(&arg(&v, "_job"), || run(name, args, cancel));
(t, ok, None)
}
/// Run a web tool. Returns (text, ok).
pub fn run(name: &str, args: &str, cancel: &AtomicBool) -> (String, bool) {
let v: Value = serde_json::from_str(if args.trim().is_empty() { "{}" } else { args }).unwrap_or(Value::Null);
let r = match name {
"web_fetch" => fetch(&arg(&v, "url")),
"browser_open" if crate::botbrowser::available() && uses_person_browser(args) => browser_open(&arg(&v, "url"), cancel),
"browser_read" if crate::botbrowser::available() && uses_person_browser(args) => browser_read(v.get("max_chars").and_then(Value::as_u64).map(|n| n as usize).unwrap_or(MAX_PAGE_CHARS).min(MAX_PAGE_CHARS * 2), cancel),
fix: 直接連線再補三個放寬的路:/always-approve、匯入帶團隊分享、關機的電腦被算進「每一台」 複審 36420f3 用測試證明的三個繞過,和幾個小的: 1. 在聊天打「/always-approve」(/yolo):直接連線的 api/bots/:id/send 從沒問過檢查, 擁有者身分就開了直接操作和一律放行。現在 remote.rs 在門口先看這句話是不是會放寬的 AnyBot 指令(commands.rs 的 AppCommand::loosens,每個指令都要列在其中一邊,新的指令 一定得決定),是就 403、什麼都不送;status、off 照常。只有門口知道是不是直接連線 (帳號那條路送進來的 Cmd 一模一樣),所以擋在那裡。順便:`--ask` 跑 AnyBot 自己的 指令(沒開一輪)以前結束碼是 1,現在是 0——地圖改在這台電腦上打「/always-approve」。 2. api/act/import_bot 帶著檔案裡的 team:true 就分享給團隊:share 的匯出不寫、匯入不收 team(也清 branch_of、branches),電腦版一樣;lan_guard 把每個 api/act 動作都列在 一邊,沒列到的一律 400,不再默默放行。 3. 可以用的電腦:帳號裡關機的電腦不在清單上,全勾就存成 None(每一台),被排除的那台 開機又能用。現在沒列出的電腦維持原狀,有清單的 Bot 從手機上不會變成「每一台」(帳號 那條路也一樣)。能力沒有這個問題:11 類永遠都列出來,None 只多出以後新版加的類別。 P2:支線的瀏覽器步驟指名 profile 只用在那一步(不再 set_current);支線換掉技能庫已有 技能的檢查跟寫資料夾一樣忽略大小寫;直接連線把 Bot 加進分享給團隊的群組算放寬 (phone_detail 多帶 team);SECURITY.md、account.md、autonomy.md 寫明打開「從手機看 這台電腦的螢幕並操作」時這個保證不成立;autonomy.md「手機用擁有者身分打也可以」改成 帳號連線才行。 P3:phone_act 照原字讀名字的那一半有自己的測試了。 已驗證: env -u 金鑰… DOCKER_HOST=unix:///nonexistent cargo test(683 過、46 ignored)、 cargo clippy --bin anybot --all-targets -D warnings、sh deploy/ci/lint-sh.sh、 verify-approval-routing run.sh --replay(沒有漂移,10 個重走都過);新的測試在放回 36420f3 的程式時都失敗(/always-approve 403、沒分類的動作、匯入的 team、關機的電腦、 phone_act 去空白、技能大小寫、支線的瀏覽器步驟、分享群組加成員);verify-anybot: autonomy 照新步驟跑(手機打 /always-approve 被擋、字放回輸入框,--ask 打開),另外 手機打 /yolo 被擋、status 照答、直接連線匯入帶 team:true 的檔案後新 Bot 沒分享、沒分類的 動作 400;branch、browser、profile、phone、market 照地圖跑。 未驗證: --ignored 的實機瀏覽器測試(botbrowser 的 reads_a_real_page、a_persons_firefox_profile、 a_finished_job_quits_its_firefox、a_finished_job_quits_its_chrome,browser 的 lines_go_in_whole_and_numbers_stay_put、a_send_is_seen_with_the_post_it_answers_and_its_own_address、 numbers_controls_inside_web_components、drives_a_dashboard,vault 的 fill_live——open 的 參數改了)要人在實機跑、簽名;帳號裡的電腦關機那條要帳號伺服器(只有單元測試);分享 群組要帳號(只有單元測試)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:09:52 +00:00
"browser_open" if crate::botbrowser::available() => normalize_url(&arg(&v, "url")).and_then(|u| crate::botbrowser::open(&u, Some(arg(&v, "profile").as_str()), v["_this_step_only"] == true)),
"browser_read" if crate::botbrowser::available() => crate::botbrowser::read(v.get("max_chars").and_then(Value::as_u64).map(|n| n as usize).unwrap_or(MAX_PAGE_CHARS).min(MAX_PAGE_CHARS * 2), Some(arg(&v, "profile").as_str())),
"browser_profiles" if crate::botbrowser::available() => crate::botbrowser::profiles_tool(&arg(&v, "action"), &arg(&v, "name")),
"browser_profiles" => Err("設定檔要 AnyBot 自己的瀏覽器(需要 Chrome、Brave、Edge、Chromium 或 Firefox)。現在用的是你自己的 Safari。".into()),
"browser_open" => browser_open(&arg(&v, "url"), cancel),
"browser_read" => browser_read(v.get("max_chars").and_then(Value::as_u64).map(|n| n as usize).unwrap_or(MAX_PAGE_CHARS).min(MAX_PAGE_CHARS * 2), cancel),
other => Err(format!("沒有「{other}」這個工具")),
};
match r {
Ok(s) => (s, true),
Err(e) => (e, false),
}
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
/// A web address as a browser reads it (WHATWG URL, the `url` crate): `\` is `/`, `user@` is not
/// the host, the host lowercased and in punycode, an IP in any spelling made plain. Everything that
/// checks an address (the private-network card, the rules, web_fetch's own check) reads it this
/// way, and the browser is handed the address as parsed — what is checked is what opens. (Taking
/// the host apart by hand let `http://127.0.0.1\@a.com/` past the private-network card.)
pub fn parse_url(u: &str) -> Result<url::Url, String> {
let u = u.trim();
if u.is_empty() {
return Err("請給網址".into());
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
let bad = || format!("「{u}」看起來不是網址");
let has_scheme = ["http://", "https://"].iter().any(|p| u.get(..p.len()).is_some_and(|h| h.eq_ignore_ascii_case(p)));
let full = if has_scheme { u.to_string() } else { format!("https://{u}") };
if full.contains(char::is_whitespace) {
return Err(bad());
安全、修正: 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
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
let parsed = url::Url::parse(&full).map_err(|_| bad())?;
match parsed.host() {
Some(url::Host::Domain(d)) if d.trim_end_matches('.').contains('.') || d.trim_end_matches('.') == "localhost" => Ok(parsed),
Some(url::Host::Ipv4(_) | url::Host::Ipv6(_)) => Ok(parsed),
_ => Err(bad()),
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
}
/// [`parse_url`], written out (the form handed to the browser).
pub fn normalize_url(u: &str) -> Result<String, String> {
parse_url(u).map(|p| p.to_string())
}
/// The host a browser would open for this address: lowercased, punycode, no trailing dot, an IP
/// plain (an IPv6 one without brackets). None when it isn't a web address.
pub fn host_of(u: &str) -> Option<String> {
parse_url(u).ok().and_then(|p| host_text(&p))
}
fn host_text(p: &url::Url) -> Option<String> {
Some(match p.host()? {
url::Host::Domain(d) => d.trim_end_matches('.').to_ascii_lowercase(),
url::Host::Ipv4(a) => a.to_string(),
url::Host::Ipv6(a) => a.to_string(),
})
}
// ---------- web_fetch ----------
2026-11-11 08:19:06 +00:00
/// An address web_fetch (and the box's egress proxy) may reach: out on the internet. Not this
/// computer, not the network it sits on (the router, the NAS, another service's port), not a
/// cloud machine's metadata.
pub fn public_addr(ip: std::net::IpAddr) -> 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
match ip {
std::net::IpAddr::V4(a) => {
let o = a.octets();
安全、修正: 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
// (100.64/10: carrier NAT and Tailscale; 198.18/15: benchmark / OrbStack VM subnets; 192.0.0/24 and 240/4: reserved.)
!(a.is_loopback()
|| a.is_private()
|| a.is_link_local()
|| a.is_unspecified()
|| a.is_broadcast()
|| a.is_multicast()
|| o[0] == 0
|| (o[0] == 100 && o[1] & 0xc0 == 64)
|| (o[0] == 192 && o[1] == 0 && o[2] == 0)
|| (o[0] == 198 && (o[1] == 18 || o[1] == 19))
|| o[0] >= 240)
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
}
std::net::IpAddr::V6(a) => match a.to_ipv4_mapped() {
Some(v4) => public_addr(std::net::IpAddr::V4(v4)),
安全、修正: 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
// (fc00::/7 is private, fe80::/10 link-local, ::/96 IPv4-compatible, 2002::/16 6to4, 2001::/32 Teredo, 64:ff9b::/96 NAT64.)
None => {
let s = a.segments();
let ipv4_compat = s[..6] == [0, 0, 0, 0, 0, 0];
let six_to_four = s[0] == 0x2002;
let teredo = s[0] == 0x2001 && s[1] == 0;
let nat64 = s[0] == 0x64 && s[1] == 0xff9b;
!(a.is_loopback() || a.is_unspecified() || a.is_multicast() || ipv4_compat || six_to_four || teredo || nat64 || s[0] & 0xfe00 == 0xfc00 || s[0] & 0xffc0 == 0xfe80)
}
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
},
}
}
安全、修正: 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
/// True when `url` is an always-forbidden cloud metadata or Docker daemon API endpoint.
pub fn is_forbidden_browser_url(url: &str) -> bool {
let Some((host, port)) = host_port(url) else { return false };
let h = host.trim_end_matches('.').to_ascii_lowercase();
if h == "docker-socket-proxy" || port == 2375 || port == 2376 {
return true;
}
if let Ok(ip) = h.parse::<std::net::IpAddr>() {
return match ip {
std::net::IpAddr::V4(v) => v.is_link_local(),
std::net::IpAddr::V6(v) => v.is_unicast_link_local() || v.to_ipv4_mapped().is_some_and(|v4| v4.is_link_local()),
};
}
false
}
/// True when `url` points to localhost or a private/internal network (so opening it in a browser
/// should ask the person first instead of running silently on prompt injection).
pub fn is_private_browser_url(url: &str) -> bool {
let Ok(full) = normalize_url(url) else { return false };
public_only(&full).is_err()
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
/// The host and port of a web address as a browser reads it ([`parse_url`]; an IPv6 host without
/// brackets).
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
fn host_port(url: &str) -> Option<(String, u16)> {
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
let p = parse_url(url).ok()?;
Some((host_text(&p)?, p.port_or_known_default()?))
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
}
/// web_fetch runs with nothing asked, so it reads the public web only: a page (or a redirect)
/// that names this computer or the network around it is refused. It used to reach them all.
fn public_only(url: &str) -> Result<(), String> {
use std::net::ToSocketAddrs;
let (host, port) = host_port(url).ok_or_else(|| format!("「{url}」看起來不是網址"))?;
let h = host.trim_end_matches('.').to_lowercase();
let addrs: Vec<std::net::IpAddr> = match h.parse::<std::net::IpAddr>() {
Ok(ip) => vec![ip],
// (A name that can't be looked up here is left to the request, which fails the same
// way, or to the person's proxy, which looks it up itself.)
Err(_) => (h.as_str(), port).to_socket_addrs().map(|a| a.map(|s| s.ip()).collect()).unwrap_or_default(),
};
安全、修正: 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 h == "localhost" || h.ends_with(".localhost") || h.ends_with(".local") || h.ends_with(".internal") || (!h.contains('.') && !h.contains(':')) || addrs.iter().any(|a| !public_addr(*a)) {
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
return Err(format!("web_fetch 只讀公開的網頁,「{host}」是這台電腦或內部網路的位址。要看本機或區網上的服務,用 shell(例如 curl)或 browser_open。"));
}
Ok(())
}
/// Looks names up like the default resolver, and hands back only public addresses: the check
/// that holds at the moment of connecting (a name can answer differently the second time).
#[derive(Debug)]
struct PublicResolver(ureq::unversioned::resolver::DefaultResolver);
impl ureq::unversioned::resolver::Resolver for PublicResolver {
fn resolve(&self, uri: &ureq::http::Uri, config: &ureq::config::Config, timeout: ureq::unversioned::transport::NextTimeout) -> Result<ureq::unversioned::resolver::ResolvedSocketAddrs, ureq::Error> {
let addrs = self.0.resolve(uri, config, timeout)?;
// The proxy the person set up is theirs to reach, wherever it is.
let proxy = config.proxy().is_some_and(|p| p.uri() == uri);
if !proxy && addrs.iter().any(|a| !public_addr(a.ip())) {
return Err(ureq::Error::Io(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "內部網路的位址")));
}
Ok(addrs)
}
}
/// Where a redirect leads, from the page it came from.
fn follow(base: &str, location: &str) -> String {
let location = location.trim();
let scheme = base.split_once("://").map(|(s, _)| s).unwrap_or("https");
let origin_end = base.find("://").map(|i| i + 3).and_then(|i| base[i..].find(['/', '?', '#']).map(|j| i + j)).unwrap_or(base.len());
if location.starts_with("http://") || location.starts_with("https://") {
location.to_string()
} else if location.starts_with("//") {
format!("{scheme}:{location}")
} else if location.starts_with('/') {
format!("{}{location}", &base[..origin_end])
} else {
let path = base[origin_end..].split(['?', '#']).next().unwrap_or("");
let dir = path.rfind('/').map(|i| &path[..=i]).unwrap_or("/");
format!("{}{dir}{location}", &base[..origin_end])
}
}
/// Redirects web_fetch follows before it gives up (ureq's own default).
const MAX_REDIRECTS: usize = 10;
/// A page off the public web, as text in its own encoding: where it ended up after redirects,
/// the status, and the text. Every stop on the way is checked (`public_only`), so nothing on
/// this computer or its network is read. (skill_install fetches through here too: it took any
/// address, the router's and a cloud machine's metadata included.)
2026-11-11 08:19:06 +00:00
pub fn get_public_bytes(url: &str, limit: u64) -> Result<(String, u16, String, Vec<u8>), String> {
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 mut url = normalize_url(url)?;
// Redirects are followed here, one at a time, so each stop is checked like the first.
feat: 所有 HTTP 用戶端信任同一份憑證;連接器連同它帶起來的程式一起關;按停止馬上結束連接器的呼叫 工程基礎計畫 E5,參考 grok-build 的 clippy.toml(HTTP 用戶端只能從一個地方建)和 ProcessScope。 - net.rs:net::config() 是所有 HTTP 用戶端的起點,憑證是公開的加上這台電腦自己信任的(tunnel::trusted_roots);net::agent(秒數) 是常用的那種(整個請求的逾時、錯誤狀態當成回答,一種逾時一個、重複用)。18 個自己建 ureq 的地方全部換成 net::config(),各自的逾時、轉址、User-Agent 不變。以前只有連帳號伺服器的那條看這台電腦信任的憑證:公司自己簽憑證的連接器、模型服務、Webhook 在別處會失敗。帳號伺服器的用戶端改用 net::agent,拿掉它自己的那份快取。 - clippy.toml:disallowed-methods 擋 ureq::Agent::config_builder(net.rs 以外)。 - 連接器:關掉、移除、重新連線、連不上時用 tools::kill_tree 連同子行程一起關(npx/uvx/sh 底下真正的伺服器以前留著)。 - mcp::call_until:本機連接器的呼叫每 0.2 秒看一次停止,按停止馬上回「已停止」;伺服器晚到的答案下一次會跳過。用網址連的還是等它回或 120 秒(ureq 的請求停不下來)。 - 測試用的假連接器多一個 slow 工具(FAKE_SLOW=1 才列出,不影響其他測試的工具數)。 已驗證:cargo test 560 全過;cargo clippy 沒有 disallowed 的違規。新測試:按停止 0.3 秒後呼叫在 2 秒內結束、之後同一個連接器照樣能用(sum=3);用 sh 帶起來的連接器關掉後,它帶起來的 sleep 也沒了;所有用戶端的憑證至少是公開那一份。 未驗證:公司自己簽憑證的真的連接器(這台沒有)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:13:59 +00:00
let config = crate::net::config()
.http_status_as_error(false)
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
.max_redirects(0)
.timeout_global(Some(Duration::from_secs(20)))
.user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15")
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
.build();
let agent = ureq::Agent::with_parts(config, ureq::unversioned::transport::DefaultConnector::new(), PublicResolver(Default::default()));
let mut hops = 0;
let resp = loop {
public_only(&url)?;
let resp = agent.get(&url).call().map_err(|e| format!("連不上 {url}:{e}"))?;
let next = resp.headers().get("location").and_then(|l| l.to_str().ok()).filter(|_| matches!(resp.status().as_u16(), 301 | 302 | 303 | 307 | 308)).map(|l| follow(&url, l));
match next {
Some(_) if hops >= MAX_REDIRECTS => return Err(format!("{url} 一直轉址,讀不到內容。")),
Some(to) => {
hops += 1;
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
// (As parsed: the stop that is checked is the one asked for.)
url = normalize_url(&to)?;
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
}
None => break resp,
}
};
let status = resp.status().as_u16();
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 said = resp.headers().get("content-type").and_then(|c| c.to_str().ok()).unwrap_or("").to_string();
2026-11-11 08:19:06 +00:00
let raw = resp.into_body().with_config().limit(limit).read_to_vec().map_err(|e| format!("讀取失敗:{e}"))?;
Ok((url, status, said, raw))
}
pub fn get_public(url: &str, limit: u64) -> Result<(String, u16, String), String> {
let (url, status, said, raw) = get_public_bytes(url, limit)?;
Ok((url, status, page_text(&raw, &said)))
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
}
fn fetch(url: &str) -> Result<String, String> {
let (url, status, body) = get_public(url, MAX_FETCH_BYTES)?;
if status >= 400 {
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
return Err(format!("網站回應 {status}。如果這個頁面要登入,請改用 browser_open。"));
}
let title = between(&body, "<title", "</title>").map(|t| t.split_once('>').map(|x| x.1).unwrap_or(t).trim().to_string()).unwrap_or_default();
let text = html_to_text(&body);
let thin = text.chars().count() < 200;
let mut out = format!("網址:{url}\n標題:{}\n\n{}", decode_entities(&title), clip(&text, MAX_PAGE_CHARS));
if thin {
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
out.push_str("\n\n(頁面幾乎沒有文字,可能要登入或靠程式載入。可以改用 browser_open 打開,它會等頁面載入再回傳內容。)");
}
Ok(out)
}
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 name after `charset=` (a Content-Type header, or the start of a page with its
/// `<meta charset="big5">` / `<meta http-equiv … content="text/html; charset=big5">`).
fn charset_named(s: &str) -> Option<String> {
let l = s.to_ascii_lowercase();
let at = l.find("charset=")? + "charset=".len();
let name: String = l[at..].trim_start_matches(['"', '\'', ' ']).chars().take_while(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_')).collect();
(!name.is_empty()).then_some(name)
}
/// A page's bytes as text, in the encoding the answer's header names, else the one the page
/// itself names, else UTF-8 (bytes that are no text in it become <20>). Pages in Big5, GBK or
/// Shift_JIS — many older Taiwanese sites — were refused whole as 「讀取失敗」: they were read
/// as UTF-8 or not at all.
fn page_text(bytes: &[u8], content_type: &str) -> String {
let named = charset_named(content_type).or_else(|| charset_named(&String::from_utf8_lossy(&bytes[..bytes.len().min(4096)])));
let encoding = named.and_then(|n| encoding_rs::Encoding::for_label(n.as_bytes())).unwrap_or(encoding_rs::UTF_8);
encoding.decode(bytes).0.into_owned()
}
fn between<'a>(s: &'a str, a: &str, b: &str) -> Option<&'a str> {
let lower = s.to_ascii_lowercase();
let i = lower.find(a)?;
let j = lower[i..].find(b)? + i;
s.get(i + a.len()..j)
}
fn clip(s: &str, n: usize) -> String {
let mut t: String = s.chars().take(n).collect();
if s.chars().count() > n {
t.push_str("\n…(後面還有,已截斷)");
}
t
}
pub fn decode_entities(s: &str) -> String {
let mut out = s.replace("&nbsp;", " ").replace("&lt;", "<").replace("&gt;", ">").replace("&quot;", "\"").replace("&#39;", "'").replace("&#x27;", "'");
// Numeric entities like &#20013;
while let Some(i) = out.find("&#") {
let Some(j) = out[i..].find(';').map(|j| j + i) else { break };
let code = &out[i + 2..j];
let ch = if let Some(h) = code.strip_prefix('x').or_else(|| code.strip_prefix('X')) { u32::from_str_radix(h, 16).ok() } else { code.parse().ok() };
match ch.and_then(char::from_u32) {
Some(c) => out.replace_range(i..=j, &c.to_string()),
None => break,
}
}
out.replace("&amp;", "&")
}
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
/// Where `<tag` opens as that very tag: `<head>` and `<head lang=…>`, never `<header>` (taking
/// `<header>` for `<head>` cut every page with a header off there — articles came back as their
/// menus).
fn open_tag(lower: &str, tag: &str) -> Option<usize> {
let pat = format!("<{tag}");
let mut from = 0;
while let Some(i) = lower[from..].find(&pat).map(|i| i + from) {
match lower[i + pat.len()..].chars().next() {
Some(c) if c == '>' || c == '/' || c.is_whitespace() => return Some(i),
None => return Some(i),
_ => from = i + pat.len(),
}
}
None
}
/// Visible text of an HTML page: drop scripts, styles and tags, keep line breaks for blocks.
pub fn html_to_text(html: &str) -> String {
let mut s = html.to_string();
for tag in ["script", "style", "noscript", "svg", "head"] {
loop {
let lower = s.to_ascii_lowercase();
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
let Some(a) = open_tag(&lower, tag) else { break };
let end_tag = format!("</{tag}>");
match lower[a..].find(&end_tag) {
Some(b) => s.replace_range(a..a + b + end_tag.len(), " "),
None => {
s.truncate(a);
break;
}
}
}
}
let mut out = String::new();
let mut in_tag = false;
let mut tag = String::new();
for c in s.chars() {
match c {
'<' => {
in_tag = true;
tag.clear();
}
'>' if in_tag => {
in_tag = false;
let t = tag.trim_start_matches('/').split(|c: char| c.is_whitespace()).next().unwrap_or("").to_ascii_lowercase();
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
if ["p", "div", "br", "li", "h1", "h2", "h3", "h4", "h5", "h6", "tr", "section", "article", "header", "footer", "main", "nav", "aside", "ul", "ol", "table", "blockquote", "pre", "dt", "dd", "figcaption"].contains(&t.as_str()) {
out.push('\n');
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
} else if t == "td" || t == "th" {
out.push(' ');
}
}
_ if in_tag => tag.push(c),
_ => out.push(c),
}
}
let text = decode_entities(&out);
let lines: Vec<String> = text.lines().map(|l| l.split_whitespace().collect::<Vec<_>>().join(" ")).filter(|l| !l.is_empty()).collect();
lines.join("\n")
}
// ---------- the person's browser ----------
fn applescript_string(s: &str) -> String {
format!("\"{}\"", s.replace('\\', "\\\\").replace('"', "\\\""))
}
/// Run AppleScript and wait (macOS may first ask the person to allow AnyBot to control the browser).
fn osascript(script: &str, cancel: &AtomicBool) -> Result<String, String> {
if !cfg!(target_os = "macos") {
return Err("在 Linux 上讀不到你自己瀏覽器裡的分頁。請改用 AnyBot 的瀏覽器(profile 用「預設」或其他設定檔)打開那個網址再讀;要登入的網站,請先在 AnyBot 的瀏覽器登入一次。".into());
}
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 child = Command::new("osascript").arg("-e").arg(script).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped()).spawn().map_err(|e| e.to_string())?;
match wait_piped(child, cancel, Duration::from_secs(SCRIPT_TIMEOUT_SECS)) {
Waited::Done(true, so, _) => Ok(so.trim_end().to_string()),
Waited::Done(false, _, se) => Err(se.trim().to_string()),
Waited::Stopped => Err("已停止".into()),
Waited::TooLong => Err("等瀏覽器回應太久了(macOS 可能在問你要不要允許,請看看螢幕)".into()),
}
}
/// How waiting for a command ended: it finished (went well?, what it printed, what it
/// complained of), the turn was stopped, or it took too long (then it is killed).
enum Waited {
Done(bool, String, String),
Stopped,
TooLong,
}
/// Wait for a command whose output comes through pipes, reading the pipes while waiting. A
/// pipe holds 64 KB: a command that prints more (a long page's text) stood still at that
/// point, was waited on until the time ran out, and the page was called unreachable.
fn wait_piped(mut child: std::process::Child, cancel: &AtomicBool, limit: Duration) -> Waited {
fn read_all(pipe: Option<impl std::io::Read + Send + 'static>) -> std::thread::JoinHandle<Vec<u8>> {
std::thread::spawn(move || {
let mut all = vec![];
if let Some(mut p) = pipe {
let _ = std::io::Read::read_to_end(&mut p, &mut all);
}
all
})
}
let (out, err) = (read_all(child.stdout.take()), read_all(child.stderr.take()));
let start = Instant::now();
loop {
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 let Ok(Some(st)) = child.try_wait() {
let text = |h: std::thread::JoinHandle<Vec<u8>>| String::from_utf8_lossy(&h.join().unwrap_or_default()).into_owned();
return Waited::Done(st.success(), text(out), text(err));
}
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 stopped = cancel.load(Ordering::Relaxed);
if stopped || start.elapsed() > limit {
let _ = child.kill();
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 _ = child.wait();
return if stopped { Waited::Stopped } else { Waited::TooLong };
}
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
std::thread::sleep(Duration::from_millis(if start.elapsed() < Duration::from_millis(500) { 10 } else { 100 }));
}
}
fn is_running(app: &str, cancel: &AtomicBool) -> bool {
osascript(&format!("application {} is running", applescript_string(app)), cancel).map(|s| s == "true").unwrap_or(false)
}
/// On-screen windows, front to back, the way the original's `listWindows` (
/// 0x52c0) reads them: `CGWindowListCopyWindowInfo(0x11 = on-screen only | exclude desktop, 0)`.
const WINDOW_LIST_JXA: &str = "ObjC.import('CoreGraphics');var a=ObjC.deepUnwrap(ObjC.castRefToObject($.CGWindowListCopyWindowInfo(0x11,0)))||[];JSON.stringify(a.map(function(w){var b=w.kCGWindowBounds||{};return {owner:w.kCGWindowOwnerName||'',layer:w.kCGWindowLayer||0,alpha:(w.kCGWindowAlpha===undefined?1:w.kCGWindowAlpha),w:b.Width||0,h:b.Height||0};}));";
/// App names of the windows that can be seen, front first. Same filter as `listWindows`: skip
/// fully transparent windows and ones with no width or height; plus only normal app windows
/// (layer 0), so menu-bar items and overlays don't count.
pub fn visible_window_owners(json: &str) -> Vec<String> {
let v: Value = serde_json::from_str(json).unwrap_or(Value::Null);
v.as_array()
.map(|a| {
a.iter()
.filter(|w| w["alpha"].as_f64().unwrap_or(1.0) > 0.0 && w["w"].as_f64().unwrap_or(0.0) > 0.0 && w["h"].as_f64().unwrap_or(0.0) > 0.0 && w["layer"].as_i64().unwrap_or(0) == 0)
.filter_map(|w| w["owner"].as_str().map(str::to_string))
.collect()
})
.unwrap_or_default()
}
fn front_window_owners(cancel: &AtomicBool) -> Vec<String> {
if !cfg!(target_os = "macos") {
return vec![];
}
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 Ok(child) = Command::new("osascript").args(["-l", "JavaScript", "-e", WINDOW_LIST_JXA]).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn() else { return vec![] };
match wait_piped(child, cancel, Duration::from_secs(10)) {
Waited::Done(_, out, _) => visible_window_owners(&out),
_ => vec![],
}
}
/// The browser whose window is closest to the front: the one the person is looking at.
pub fn frontmost_browser(owners: &[String]) -> Option<(&'static str, bool)> {
owners.iter().find_map(|o| BROWSERS.iter().find(|(name, _)| name == o).copied())
}
/// The browser to use: the front-most browser window, else the first one that's open, else
/// Chrome if installed, else Safari.
fn pick_browser(cancel: &AtomicBool) -> (&'static str, bool) {
if let Some(b) = frontmost_browser(&front_window_owners(cancel)) {
return b;
}
for (name, chromium) in BROWSERS {
if is_running(name, cancel) {
return (name, chromium);
}
}
if std::path::Path::new("/Applications/Google Chrome.app").exists() {
return ("Google Chrome", true);
}
("Safari", false)
}
/// macOS refused to let AnyBot control the browser (-1743): open the Automation settings pane
/// right away so the switch is in front of the person, and say what to turn on.
fn explain(err: &str, browser: &str) -> String {
let lower = err.to_lowercase();
if err.contains("-1743") || lower.contains("not authorized") || lower.contains("不允許") {
let _ = crate::computer::spawn_reaped(Command::new("open").arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Automation"));
format!("macOS 擋下了 AnyBot 控制 {browser}。我已經幫你打開「系統設定 → 隱私權與安全性 → 自動化」:在 AnyBot(或「終端機」)底下打開「{browser}」,然後再叫我試一次。")
} else if lower.contains("javascript") {
if browser == "Safari" {
"Safari 還沒允許讀取網頁內容:請在 Safari 選單「開發 → 允許來自 Apple 事件的 JavaScript」打開(沒有「開發」選單的話,先到 Safari 設定 → 進階 → 勾選「顯示網頁開發者功能」),然後再叫我試一次。".to_string()
} else {
format!("{browser} 還沒允許讀取網頁內容:請在 {browser} 選單「檢視 → 開發人員 → 允許來自 Apple 事件的 JavaScript」打開,然後再叫我試一次。")
}
} else {
format!("{browser} 沒有回應:{err}")
}
}
fn browser_open(url: &str, cancel: &AtomicBool) -> Result<String, String> {
let url = normalize_url(url)?;
if !cfg!(target_os = "macos") {
// Linux: the person's default browser.
crate::preview::system_open(&url).status().map_err(|e| format!("打不開瀏覽器:{e}"))?;
return Ok(format!("已在你的預設瀏覽器打開 {url}。"));
}
let (browser, chromium) = pick_browser(cancel);
// A Chromium browser started without a folder hands the link to the person's own running
// window (their normal profile), never to AnyBot's own window, which `open -a` might pick.
let exe = app_exe(browser);
let handed = chromium
&& std::path::Path::new(&exe).exists()
&& {
let mut c = Command::new(&exe);
c.arg(&url).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
c.process_group(0);
}
crate::computer::spawn_reaped(&mut c).is_ok()
};
if !handed {
let st = Command::new("open").arg("-a").arg(browser).arg(&url).status().map_err(|e| e.to_string())?;
if !st.success() {
Command::new("open").arg(&url).status().map_err(|e| e.to_string())?;
}
}
let until = Instant::now() + Duration::from_secs(OPEN_SETTLE_SECS);
while Instant::now() < until {
if cancel.load(Ordering::Relaxed) {
return Err("已停止".into());
}
std::thread::sleep(Duration::from_millis(100));
}
Ok(format!("已在 {browser} 打開 {url}。接著可以用 browser_read 讀這個分頁。"))
}
/// The main executable of a browser app in /Applications.
pub fn app_exe(browser: &str) -> String {
format!("/Applications/{browser}.app/Contents/MacOS/{browser}")
}
fn browser_read(max_chars: usize, cancel: &AtomicBool) -> Result<String, String> {
let (browser, chromium) = pick_browser(cancel);
// First through accessibility, like the reference assistant's Computer Use helper: no browser setting, and
// it reads whichever profile's window the person has in front.
match crate::axread::read_person_browser(&app_exe(browser), max_chars) {
Ok(page) if !page.text.trim().is_empty() => {
return Ok(format!("瀏覽器:{browser}(你的瀏覽器)\n標題:{}\n網址:{}\n\n{}", page.title, page.url, clip(&page.text, max_chars)));
}
Err(e) if e.contains("輔助使用") => return Err(e),
_ => {}
}
let app = applescript_string(browser);
let (title_s, url_s, text_s) = if chromium {
(
format!("tell application {app} to get title of active tab of front window"),
format!("tell application {app} to get URL of active tab of front window"),
format!("tell application {app} to execute active tab of front window javascript \"document.body ? document.body.innerText : ''\""),
)
} else {
(
format!("tell application {app} to get name of current tab of front window"),
format!("tell application {app} to get URL of current tab of front window"),
format!("tell application {app} to do JavaScript \"document.body ? document.body.innerText : ''\" in current tab of front window"),
)
};
let title = osascript(&title_s, cancel).map_err(|e| explain(&e, browser))?;
let url = osascript(&url_s, cancel).unwrap_or_default();
match osascript(&text_s, cancel) {
Ok(text) => {
let text: String = text.lines().map(str::trim).filter(|l| !l.is_empty()).collect::<Vec<_>>().join("\n");
Ok(format!("瀏覽器:{browser}\n標題:{title}\n網址:{url}\n\n{}", clip(&text, max_chars)))
}
// Title and address still help; say how to allow the page text.
Err(e) => Ok(format!("瀏覽器:{browser}\n標題:{title}\n網址:{url}\n\n(讀不到頁面文字){}", explain(&e, browser))),
}
}
#[cfg(test)]
mod tests {
use super::*;
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00
#[test]
fn a_page_with_a_header_keeps_its_article() {
// Taking <header> for <head> cut pages off at their header (WordPress sites, news sites).
let html = "<!doctype html><html><head><title>T</title></head><body><header class=site-header><nav>首頁 課程</nav></header><main><article><h1>預售策略</h1><p>先賣再錄</p><table><tr><td>方案</td><td>價格</td></tr></table></article></main><footer>©</footer></body></html>";
let t = html_to_text(html);
assert!(t.contains("首頁 課程") && t.contains("預售策略") && t.contains("先賣再錄") && t.contains("©"), "{t}");
assert!(t.contains("方案 價格"), "{t}");
// A page with no <head> at all, only a <header>.
assert!(html_to_text("<header>選單</header><p>內文</p>").contains("內文"));
// <head lang=…> is still the head.
assert!(!html_to_text("<head lang=zh><title>不要</title></head><p>要</p>").contains("不要"));
}
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
/// A command that prints more than a pipe holds is read to its end, not waited on until
/// the time runs out.
#[cfg(unix)]
#[test]
fn long_output_is_read_while_waiting() {
let run = |script: &str| Command::new("sh").args(["-c", script]).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped()).spawn().unwrap();
let start = Instant::now();
match wait_piped(run("head -c 300000 /dev/zero | tr '\\0' a; echo oops >&2; exit 3"), &AtomicBool::new(false), Duration::from_secs(20)) {
Waited::Done(ok, out, err) => assert_eq!((ok, out.len(), err.trim()), (false, 300_000, "oops")),
_ => panic!("it should have finished"),
}
assert!(start.elapsed() < Duration::from_secs(10), "{:?}", start.elapsed());
assert!(matches!(wait_piped(run("sleep 30"), &AtomicBool::new(false), Duration::from_millis(200)), Waited::TooLong));
assert!(matches!(wait_piped(run("sleep 30"), &AtomicBool::new(true), Duration::from_secs(20)), Waited::Stopped));
}
/// A page is read in the encoding it says it is in.
#[test]
fn a_page_is_read_in_its_own_encoding() {
let (big5, _, _) = encoding_rs::BIG5.encode("<html><head><meta charset=\"big5\"><title>臺南市政府</title></head><body>公告事項</body></html>");
assert!(std::str::from_utf8(&big5).is_err(), "not UTF-8 to begin with");
assert!(page_text(&big5, "text/html").contains("臺南市政府"), "named by the page");
let (gbk, _, _) = encoding_rs::GBK.encode("<title>中文网页</title>");
assert!(page_text(&gbk, "text/html; charset=GB2312").contains("中文网页"), "named by the header");
let (old, _, _) = encoding_rs::BIG5.encode("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=Big5\"><title>舊網站</title>");
assert!(page_text(&old, "").contains("舊網站"));
assert_eq!(page_text("純 UTF-8".as_bytes(), "text/html; charset=utf-8"), "純 UTF-8");
assert_eq!(page_text("沒說編碼".as_bytes(), ""), "沒說編碼");
assert!(page_text(&[b'a', 0xff, b'b'], "text/html").starts_with('a'), "bad bytes don't lose the page");
assert_eq!(charset_named("text/html; charset=\"x-unknown\"").as_deref(), Some("x-unknown"));
assert_eq!(page_text("未知編碼照 UTF-8".as_bytes(), "text/html; charset=x-unknown"), "未知編碼照 UTF-8");
}
/// web_fetch asks nothing, so it reaches the public web only.
#[test]
fn a_fetch_stays_on_the_public_web() {
for inside in [
"http://127.0.0.1:8080/admin",
"http://localhost:3000/",
"http://api.localhost/",
"http://192.168.1.1/",
"http://10.0.0.5:9200/_cat/indices",
"http://172.16.4.4/",
"http://169.254.169.254/latest/meta-data/",
"http://100.100.100.100/",
"http://0.0.0.0:8000/",
"http://[::1]:8080/",
"http://[fd00::1]/",
"http://[fe80::1]/",
"http://[::ffff:127.0.0.1]/",
// Other spellings of 127.0.0.1 the system reads as an address.
"http://2130706433/",
"http://0x7f.1/",
"http://user:pw@127.0.0.1/",
"http://example.com@127.0.0.1/",
] {
assert!(public_only(inside).is_err(), "{inside} was let through");
// (Refused before any connection: by this check, or as not an address at all.)
assert!(fetch(inside).is_err_and(|e| e.contains("只讀公開的網頁") || e.contains("不是網址")), "{inside}");
}
for outside in ["https://93.184.215.14/", "http://8.8.8.8:8080/x", "https://[2606:4700:4700::1111]/", "http://127.0.0.1.nip.invalid/"] {
assert!(public_only(outside).is_ok(), "{outside}");
}
assert_eq!(host_port("https://example.com/a?b=http://127.0.0.1/"), Some(("example.com".to_string(), 443)));
assert_eq!(host_port("http://[::1]:81/x"), Some(("::1".to_string(), 81)));
assert_eq!(host_port("http://example.com:8080"), Some(("example.com".to_string(), 8080)));
assert_eq!(host_port("http://example.com?x=1"), Some(("example.com".to_string(), 80)));
// A redirect is read from the page it came from, then checked like any address.
assert_eq!(follow("https://a.example/x/y?q=1", "http://127.0.0.1/"), "http://127.0.0.1/");
assert_eq!(follow("https://a.example/x/y?q=1", "//b.example/z"), "https://b.example/z");
assert_eq!(follow("https://a.example/x/y?q=1", "/z"), "https://a.example/z");
assert_eq!(follow("https://a.example/x/y?q=1", "z"), "https://a.example/x/z");
assert_eq!(follow("https://a.example", "z"), "https://a.example/z");
}
#[test]
fn html_becomes_readable_text() {
let html = "<html><head><title>T</title><style>.a{}</style></head><body><script>var x=1;</script><h1>標題</h1><p>第一段&nbsp;文字 &amp; 更多</p><div>中&#25991;</div></body></html>";
assert_eq!(html_to_text(html), "標題\n第一段 文字 & 更多\n中文");
}
#[test]
fn urls_are_checked() {
assert_eq!(normalize_url("threads.net/@me").unwrap(), "https://threads.net/@me");
assert!(normalize_url("not a url").is_err());
assert!(normalize_url("").is_err());
}
fix: 網址照瀏覽器的讀法比對(web(domain:…)、內部網址卡);審核員只讀兩端時照樣問;上傳的開關卡不給審核省掉 第三輪審查(6a6d905..4303646)的四個 P1,加上能收的 P2。 P1-1 `web(domain:…)` 比對的不是瀏覽器打開的那個網站:gate.rs 自己切網址,`me@example.com`、 `example.com.`、`example.com\cart`、`browser_tabs` 帶網址開新分頁都對不上(0 張卡)。 P1-2 同一個根:web.rs 的 normalize_url/host_port 用 rsplit('@')、不把 `\` 當 `/`, `http://127.0.0.1\@a.com/`、`http://192.168.1.1\.example.com/` 被當成公開網址,內部網址卡不跳。 修法:web::parse_url 用 WHATWG 的 `url` crate(Cargo.lock 本來就有,改成直接依賴)——`\` 是 `/`、 帳號@ 不是主機、小寫、punycode、結尾的點、各種寫法的 IP;normalize_url、host_port、web::host_of 都用它, gate 的 web(…) 用 host_of 比主機(規則的網域也同樣讀),比對清單加上 browser_tabs 帶網址。 InBotsBrowser 把解析過的網址交給瀏覽器(open、新分頁、web_fetch),檢查的就是打開的;web_fetch 轉址的每一站也照解析過的去要。地圖寫清楚:只比對用網址打開或讀的那一步,點連結、轉址、上一頁不算。 P1-3 審核員只讀長參數的兩端:模型可以把要擋的東西塞在中間,審核員說允許就不跳卡片。修法:參數被截過、 而且這一步真的給模型看了(model_reads,跟 review_action 一樣的判斷)時,審核員的允許、直接操作下的 「都不符合」都改成跳卡片:「參數很長,自動審核只讀了開頭和結尾,所以先問你」(沒有直接操作時照舊可以 一律允許,跟審核失敗一樣)。選這個而不是把上限拉高:上限拉多高,中間都還是可能藏東西。 P1-4 從這台上傳檔案、電腦工具或「在這台電腦上執行」沒開時,那張卡被送進 reviewed(),允許規則就省掉了。 修法:抽成 here_upload_decision——開關沒開的那張卡(工作資料夾內外都是)一律跳、不給審核,別的 yes (樣式卡的允許)也省不掉它;開關開著才照檔案規則和 reviewed()。 P2: - browser.md 的陷阱和自動審核說的對齊(本機網址:一律允許、直接操作、自動審核的允許都可以不問, 「一律詢問」照樣問)。 - 「對不上任何東西」的提醒(gate::rule_warning)擴到 web(…)(沒寫 domain:、用 *、寫了 https:// 或路徑、 不是網站)和 tool(…)(不是哪一步的名字,例如 tool(browser) 要寫 tool(browser_*));featuremap 的 every_tool 搬出測試,提醒用同一份工具清單。 - hook 的「ask」跟瀏覽器的樣式卡放在同一張(run_call 的通用 hook 詢問不再管 InBotsBrowser)。 沒改,記著(略過樣式規則的路):伺服器大腦上的 open_for_person、/goal 評審自己呼叫的 web_fetch、 在使用者自己的瀏覽器 browser_open(OnComputer,不用問的不比對)、別人傳來的訊息那一輪的 web_fetch (沒有自動審核)。vault.rs 的 host_of 也是自己切網址,沒動。沒碰 src/remote.rs、src/botbrowser.rs。 特性表 connector_decisions_are_characterized 多 20 列(38 → 58):審核員說允許、長參數 × 審核員允許/ 都不符合/允許樣式/詢問樣式。tool_specs_are_locked、approval_decisions_are_characterized 沒有 diff。 已驗證: 全部 cargo test 686 通過(不帶金鑰、DOCKER_HOST 指到不存在、ANYBOT_VAULT_KEY_FILE 放暫存、 PATH 前面放假的 security 記下每次呼叫:這次 0 次);把四個修法和 hook 合併各自改回去, addresses_are_read_as_a_browser_reads_them、pattern_rules_decide_before_the_model、an_ask_pattern_stops_the_bots_browser、 connector_decisions_are_characterized、an_upload_with_the_switches_off_always_asks、 a_hook_ask_and_a_rule_make_one_card_for_a_browser_step 都失敗,改回來都過;clippy -D warnings、lint-sh、 verify-approval-routing run.sh --replay(跟基準一樣);verify-anybot:browser 每一步可跑的照 md 原文冷跑全過 (target/verify-anybot/20261118-200336:「在瀏覽器打開 http://127.0.0.1/@a.com/(符合你的「一律詢問」規則: web(domain:127.0.0.1))」,192.168.1.5\.example.com 跳內部網址卡、先給審核員看;全部拒絕、沒有開瀏覽器) 未驗證: 真的瀏覽器打開解析過的網址(scratch 沒有 Docker,這台開會出現真的瀏覽器);直接操作那一半的實機; 電腦設定頁提醒那一行的樣子;--ignored 的瀏覽器實機測試(清單見 4303646) 未簽: 審批路徑、瀏覽器——要人類跑 --ignored 並簽名才能合併,沒有合併、沒有推 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 12:06:35 +00:00
/// Addresses are read the way a browser reads them (WHATWG): a backslash is a slash, `user@`
/// isn't the host, case, a trailing dot, punycode and an IP in any spelling don't change which
/// host it is — so the private-network card and the person's rules see the host that opens,
/// and the browser is handed that same address. (By hand, `http://127.0.0.1\@a.com/` and
/// `http://192.168.1.1\.example.com/` passed as public; `me@example.com` as host `me@example.com`.)
#[test]
fn addresses_are_read_as_a_browser_reads_them() {
for private in ["http://127.0.0.1\\@a.com/", "http://192.168.1.1\\.example.com/", "http://me@127.0.0.1/", "http://localhost./", "http://2130706433/", "http://0x7f.1/", "http://[::1]:8080/", "http://[::ffff:127.0.0.1]/", "HTTP://192.168.1.5/"] {
assert!(is_private_browser_url(private), "{private}");
}
assert!(is_forbidden_browser_url(&normalize_url("http://169.254.169.254\\@a.com/latest").unwrap()));
assert!(is_forbidden_browser_url(&normalize_url("http://2852039166/").unwrap()), "169.254.169.254 written as one number");
for (given, host) in [
("https://me@example.com/cart", "example.com"),
("https://shop.EXAMPLE.com./cart", "shop.example.com"),
("https://example.com\\cart", "example.com"),
("https://bücher.example/", "xn--bcher-kva.example"),
("example.com:8443/x", "example.com"),
("http://[::1]:8080/", "::1"),
("http://2130706433/", "127.0.0.1"),
] {
assert_eq!(host_of(given).as_deref(), Some(host), "{given}");
}
assert_eq!(normalize_url("http://127.0.0.1\\@a.com/").unwrap(), "http://127.0.0.1/@a.com/", "what is checked is what opens");
assert_eq!(normalize_url("https://me@example.com\\cart").unwrap(), "https://me@example.com/cart");
assert!(normalize_url("ftp://example.com/").is_err() && normalize_url("javascript:alert(1)").is_err() && normalize_url("intranet").is_err());
}
#[test]
fn front_browser_follows_window_order() {
let json = r#"[{"owner":"Window Server","layer":24,"alpha":1,"w":1920,"h":30},
{"owner":"Ghost","layer":0,"alpha":0,"w":800,"h":600},
{"owner":"Safari","layer":0,"alpha":1,"w":0,"h":600},
{"owner":"Finder","layer":0,"alpha":1,"w":800,"h":600},
{"owner":"Google Chrome","layer":0,"alpha":1,"w":1200,"h":800},
{"owner":"Safari","layer":0,"alpha":1,"w":1200,"h":800}]"#;
let owners = visible_window_owners(json);
assert_eq!(owners, vec!["Finder", "Google Chrome", "Safari"]);
assert_eq!(frontmost_browser(&owners), Some(("Google Chrome", true)));
assert_eq!(frontmost_browser(&["Finder".to_string()]), None);
}
#[test]
fn automation_refusal_is_explained() {
assert!(explain("execution error: Not authorized to send Apple events to Google Chrome. (-1743)", "Google Chrome").contains("自動化"));
assert!(explain("Executing JavaScript through AppleScript is turned off.", "Google Chrome").contains("允許來自 Apple 事件的 JavaScript"));
}
}
Whole control flow checked against real chats: what the bot sees is what is there, every step lands, nothing done twice Web - web_fetch kept pages with a <header> only up to it (taken for <head>): articles came back as their menus. - browser_open waits for the page to load and returns it like browser_read (one step fewer per page); actions wait for the page to hold still instead of fixed 1-2.5 s sleeps; one way to reach the tab. The bot's computer (box v6) - Numbers only on what can be seen: clipped to the window and the page's visible area, none under another app's window (a link scrolled under the toolbar was numbered on Back). - press_key with a typed character no longer swallows the keys after it (xdotool type --args 1). - The person's input through noVNC/TigerVNC is noticed again (fence, continuous updates, QEMU keys). - "Nothing changed" only after clicks, scrolls and drags; long text is pasted; one screen step at a time; one docker inspect per step when the box is known ready; poppler-utils for long PDFs. - One typing path and fewer round trips (stdin variant, unused picture path, extra batch execs gone). The person's computers - Linux: the window system's front app when it has one, and the reason when there is none (was 「」); hidden and off-screen controls get no number; wording no longer names a tool that doesn't exist. The loop - Without Docker, the bot's own computer runs no commands where there is no sandbox (Linux, Windows): it was a plain shell on the brain itself, keys in reach, asked nothing. - The bot's own computer is re-checked each step; unreachable computers are failures, not safety blocks; no direct-mode note on every result; an empty reply is asked again; scrolling and keys aren't counted as going in circles; steps aren't moved to a computer that can't do them. - One finish() for every step's result, keep_grant(), dead appctl list_computers/SERVING and the impossible server branches removed; duplicated prompt instructions merged. Tests: 162 (Mac) / 166 (Linux) unit; real box drills 6/6 on box v6; a brain without Chrome browses on its box; remote E2E 28/28. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 09:44:59 +00:00