From 3f46911ba48341a82ff9003aafcc5c326b6e774c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Sun, 15 Nov 2026 16:08:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=B8=8B=E6=8B=89=E9=81=B8=E5=96=AE?= =?UTF-8?q?=E7=94=A8=20value=20=E9=81=B8=E4=B8=8D=E5=88=B0=E5=8D=BB?= =?UTF-8?q?=E5=9B=9E=E5=A0=B1=E6=88=90=E5=8A=9F=E3=80=81fill=20=E6=92=9E?= =?UTF-8?q?=E5=88=B0=E4=BF=9D=E9=9A=AA=E5=BA=AB=E3=80=81sudo=20=E7=95=99?= =?UTF-8?q?=E4=B8=8B=20root=20=E7=9A=84=E6=AA=94=E6=A1=88=E3=80=81--ask=20?= =?UTF-8?q?=E4=B8=8D=E9=80=A3=E9=80=A3=E6=8E=A5=E5=99=A8=E3=80=81=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E8=A3=A1=E7=9A=84=E9=80=A3=E6=8E=A5=E5=99=A8=E8=A2=AB?= =?UTF-8?q?=E8=AA=A4=E6=93=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 電腦操作量測時找到的問題:填表題失敗大多是前兩個造成的(正式版有一次接著呼叫保險庫填入 124 次)。 - browser:select 也接受 value/values;對下拉選單 type 會改成選選項;什麼都沒給就報錯,不再回報「已選「」」 - browser:fill 指著頁面上的欄位(有 ref/text、沒有 kind/id/site)時當成 type(有 option 時當 select),不跑去保險庫 - cloudbox:有 sudo 的指令跑完,把 Bot 家目錄裡 root 新留下的檔案都交還給 Bot,不只它的資料夾(之前 ~/.config/chromium 和 ~/.local/share/pki 會留給 root,Bot 的瀏覽器之後開不起來) - app:anybot --ask 沒有視窗,開始前先連好連接器 - mcp:指令是 docker、ssh 這類在別處執行的,不拿參數裡的路徑到本機檢查 - 功能地圖:browser、files、connectors Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun --- docs/feature-map/browser.md | 2 ++ docs/feature-map/connectors.md | 2 ++ docs/feature-map/files.md | 2 +- src/app.rs | 5 +++ src/browser.rs | 59 +++++++++++++++++++++++++++++++--- src/cloudbox.rs | 11 +++++-- src/mcp.rs | 19 ++++++++--- 7 files changed, 88 insertions(+), 12 deletions(-) diff --git a/docs/feature-map/browser.md b/docs/feature-map/browser.md index bdd5e94..31bfe92 100644 --- a/docs/feature-map/browser.md +++ b/docs/feature-map/browser.md @@ -29,6 +29,8 @@ Bot 用 AnyBot 自己的瀏覽器上網、登入網站、點按、打字、送 - 同一個網站在不同電腦、不同設定檔的登入不共用;沒帶 `profile` 會用到別的設定檔。 - 使用者自己的 Firefox 設定檔,如果他已經用平常的方式開著,要先請他關掉那個視窗,AnyBot 才開得起來。 - 一模一樣的按鈕(例如每篇貼文都有的「回覆」)在清單裡只列一次;要點第二篇的,先 `open` 那篇貼文的網址再點。 +- 下拉選單用 `select`,`option` 填選項上看得到的字(給 `value` 也行,對下拉選單 `type` 也會改成選選項);什麼都沒給會報錯。 +- `fill` 是保險庫的填入;指著頁面上一個欄位(有 `ref`/`text`、沒有 kind/id/site)時當成 `type`(有 `option` 時當 `select`),不會跑去保險庫。 - `eval` 只能讀頁面:不能發請求、讀 cookie 或儲存、送出表單、換頁(會被拒絕);直接呼叫網站內部 API 會被當成機器人。 - 雲端中繼資料位址永遠打不開;本機或內部網路的網址要使用者允許(直接操作模式除外)。 - 發布關卡、已送帳本、送出後確認只管 AnyBot 自己的瀏覽器;用螢幕操作送出的,只能從步驟推算。頁面看不出回哪一篇時,只擋 24 小時內同一頁一模一樣的內容。 diff --git a/docs/feature-map/connectors.md b/docs/feature-map/connectors.md index 86aa287..0e54d98 100644 --- a/docs/feature-map/connectors.md +++ b/docs/feature-map/connectors.md @@ -33,3 +33,5 @@ - 要登入帳號(OAuth)的連接器 AnyBot 還不支援,連線時狀態會說;它若也收 API 金鑰,填在「標頭」。公用市集裡舊式 SSE 的會標「舊式 SSE 連線,AnyBot 還不支援」。 - 公用市集只列用網址連的;要在大腦上跑 npm/PyPI 套件的不列。本機連接器要大腦那台裝了 Node.js(npx)或 uv(uvx)。 - 在螢幕上改了指令或網址,大腦會清掉密碼(免得送到新的位址),要重新填。 +- 參數裡的資料夾在這台找不到(在別台電腦設定的),連接器不連,狀態寫「這台電腦上沒有…」;指令是 `docker`、`ssh` 這類在別處執行的,不檢查(路徑在容器或那台主機上)。 +- `anybot --ask` 沒有視窗,也會先連好連接器再開始。 diff --git a/docs/feature-map/files.md b/docs/feature-map/files.md index d800ec1..b5c5d5d 100644 --- a/docs/feature-map/files.md +++ b/docs/feature-map/files.md @@ -29,7 +29,7 @@ Bot 在它能用的電腦上跑指令、讀寫和搜尋檔案、開背景指令 - 機密檔案一律不能讀、改、傳、打開或發佈:AnyBot 自己的資料資料夾、.git、.ssh、.gnupg、.aws、Keychains、.env、.pem、.key、id_rsa 開頭的檔案等。 - 在這台電腦上:工作資料夾外讀東西先問(可以一律允許);改檔案會問,工作資料夾外的每次都問、不能一律允許;指令除了唯讀的都會問;sudo、rm -rf /、mkfs、dd、shutdown 這類一律拒絕。完整規則見 [safety](safety.md)。 -- 在 Bot 自己的電腦上,指令和檔案都不用問(可以 sudo,但後面接的一律拒絕指令照樣擋);檔案工具只碰得到它自己的資料夾。 +- 在 Bot 自己的電腦上,指令和檔案都不用問(可以 sudo,但後面接的一律拒絕指令照樣擋);檔案工具只碰得到它自己的資料夾。有 sudo 的指令整條用 root 跑,跑完它在 Bot 家目錄裡新留下的檔案會交還給 Bot(不只它的資料夾)。 - SSH 電腦和帳號裡的其他電腦:讀不用問,改檔案和會改變東西的指令會問。 - 開互動的 shell(bash、zsh、PowerShell…)每次都問、沒有一律允許:之後在裡面打的指令不會再一條一條檢查。 - 一般指令的輸入是關的,`write_terminal` 打不進去:要互動就用 interactive 重跑,或用參數答掉(-y、--yes)。 diff --git a/src/app.rs b/src/app.rs index b7a7d64..9bbada6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -5505,6 +5505,11 @@ impl App { let mut app = App::new(ctx, None); app.headless = true; app.asking = true; + // 連接器: the window connects them as it draws (there is no drawing here), so a question + // asked here had none of them. Connected before it starts. + for (name, why) in crate::mcp::sync(&app.state.mcp_servers) { + eprintln!("連接器「{name}」連不上:{why}"); + } let id = app.state.primary_bot; let start = app.state.bot(id).map(|b| b.messages.len()).unwrap_or(0); app.drafts.insert(id, text.to_string()); diff --git a/src/browser.rs b/src/browser.rs index def0b9e..a4cef93 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -583,6 +583,21 @@ pub fn wait_loaded(profile: Option<&str>, max_ms: u64) -> bool { // ---------- the tools ---------- +/// The option a select names: `option`, or what models trained on Playwright give instead +/// (`value`, `values`). It used to read only `option`, and with `value` it chose the empty +/// 「請選擇」 and said 「已選「」」: the form went out without its city. +fn select_option(args: &Value) -> String { + let o = s(args, "option"); + if !o.is_empty() { + return o; + } + let v = s(args, "value"); + if !v.is_empty() { + return v; + } + args["values"].as_array().and_then(|a| a.first()).map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string())).unwrap_or_default().trim().to_string() +} + fn s(args: &Value, k: &str) -> String { args.get(k).map(|v| v.as_str().map(String::from).unwrap_or_else(|| if v.is_null() { String::new() } else { v.to_string() })).unwrap_or_default().trim().to_string() } @@ -655,7 +670,7 @@ pub fn describe(name: &str, args: &str) -> String { let target = if !s(&v, "ref").is_empty() { format!("[{}]", s(&v, "ref")) } else { s(&v, "text") }; match name { "browser_type" => format!("{target} ← {}", s(&v, "value").chars().take(40).collect::()), - "browser_select" => format!("{target} → {}", s(&v, "option")), + "browser_select" => format!("{target} → {}", select_option(&v)), "browser_press" => s(&v, "key"), "browser_scroll" => if target.is_empty() { s(&v, "direction") } else { target }, "browser_wait" => if s(&v, "text").is_empty() { format!("{} 秒", s(&v, "seconds")) } else { format!("等「{}」", s(&v, "text")) }, @@ -730,7 +745,7 @@ actions: - dialog {accept, text}: answer a pop-up dialog the page opened - eval {script}: short read-only JavaScript for data the other actions can't reach; it can't send requests, navigate or submit (site APIs get accounts flagged) - sent {profile, days}: what an account already sent through this browser — AnyBot's own record (which posts, which accounts it answered, kept 60 days); much cheaper than reading a site's own replies page to the end. Sending to a post the same account already answered is refused anyway -- fill {kind: login|card|contact, id, site, submit}: sign in / pay card / address from the person's 保險庫 — you never see the secret; the person approves every use (login_id/card_id/contact_id come from vault_list; default login: the current site's)", +- fill {kind: login|card|contact, id, site, submit}: sign in / pay card / address from the person's 保險庫 (not for ordinary fields: those are type/select) — you never see the secret; the person approves every use (login_id/card_id/contact_id come from vault_list; default login: the current site's)", "parameters": {"type": "object", "properties": { "action": {"type": "string", "enum": ["open","read","elements","find","table","screenshot","click","hover","type","press","select","scroll","wait","tabs","back","upload","download","pdf","dialog","eval","sent","profiles","fill"]}, "url": {"type": "string"}, @@ -748,7 +763,7 @@ actions: "append": {"type": "boolean", "description": "type: keep what's in the field"}, "submit": {"type": "boolean", "description": "type/fill: press Enter / sign in afterwards"}, "key": {"type": "string", "description": "press: Enter, Tab, Escape, ctrl+a…"}, - "option": {"type": "string", "description": "select: the option's visible text"}, + "option": {"type": "string", "description": "select: the option's visible text (value works too)"}, "direction": {"type": "string", "enum": ["down", "up", "top", "bottom", "back", "forward", "reload"], "description": "scroll: down/up/top/bottom; back: back/forward/reload"}, "seconds": {"type": "number"}, "days": {"type": "integer", "description": "sent: how far back (default 30, up to 60)"}, @@ -802,6 +817,13 @@ pub fn expand_call(c: &mut crate::model::ToolCall) { let mut name = action.to_string(); if let Some(o) = v.as_object_mut() { o.remove("action"); + // 「fill」 with a control on the page and the words for it is Playwright's fill (type + // into a field), what models trained on it mean more often than the 保險庫: it went to + // the vault, was refused, and the bot tried again and again (the form never went out). + let on_page = (o.contains_key("ref") || o.contains_key("text")) && !["kind", "id", "site"].iter().any(|k| o.contains_key(*k)); + if name == "browser_fill_login" && on_page { + name = if o.contains_key("option") || o.contains_key("values") { "browser_select" } else { "browser_type" }.to_string(); + } if name == "browser_fill_login" { // fill {kind, id} names the exact vault tool and its id field. let kind = o.remove("kind").and_then(|k| k.as_str().map(|s| s.to_string())).unwrap_or_else(|| "login".into()); @@ -855,6 +877,12 @@ pub fn run(name: &str, args: &Value) -> Result<(String, Option), String> } let mut tab = Tab::current(profile)?; let r = (|| -> Result<(String, Option), String> { + // Typing into a dropdown (a +
商品分潤率
手機殼8%
乳液12%

點擊 0

匯出報表