Commit Graph

15 Commits

Author SHA1 Message Date
王性驊 430d3f0367 手機點進聊天一次有記錄、一次全空:手機說它那份從哪一則開始(w0,載入更早的 from)用的是那則在整段聊天裡的位置(index,數到 Bot 每個工具步驟),大腦卻當成「發布清單裡第幾則」——清單只是最新 PHONE_TAIL(120)則去掉工具步驟,短得多。有工具步驟的聊天就切到清單外,回一份空的;下一次手機手上沒東西、不帶 w0,又拿到整段——一次有一次空,一直交替(jenny-Host 11/21:1133 則的聊天、index 1105,清單 40 則左右)。11/20 7648c92「聊天分頁」帶進來的,Jenny 半夜升級正好升到它。假模型不叫工具(index 等於清單位置),所以 scratch 重現不出來,原本的測試 index 也是 0..100。
現在 from_index 把 index 換成清單裡第一則 ≥ 它的位置,三個地方都用:api/state 的開著的聊天、api/bots/<id>、api/bots/<id>/older。手機頁面不用改(舊頁面送的也是 index)。另外 httpd 那個測試拿掉「停下後埠可以再綁」那一行:整套測試一起跑時,別的測試會立刻拿走剛放掉的埠(第二次整套跑失敗過一次),要驗的是它停下來,那一行還在。FEATURES.md 補一行。

已驗證: cargo test 全綠(826,連跑兩次);新測試 a_chat_with_steps_comes_back_every_time(40 則、index 從 1013 起每則隔 3:打開拿最新 30、再拿三次都是同一個窗不會空、有新的一則只送那一則、載入更早從那則往前、index 太舊從頭)——把換算拿掉它會失敗;clippy 錯誤數跟之前一樣(12)。
未驗證: Jenny 的手機實機(大腦換新版之後請她點幾次)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 11:52:10 +08:00
王性驊 535f018515 每個請求不再先排隊 40–50 毫秒(上一個 commit 怪錯了對象):部署 f697186 之後帳號伺服器的 /api/hello 還是每個 50 毫秒,本機跑也一樣——不是 Nagle。真正的原因是 httpd 接連線的迴圈:監聽設成非阻塞,沒有新連線就睡 50 毫秒再看;帳號伺服器每個回應後關掉連線(serve_upgrade),所以每個請求都先在那裡等。手機頁面區網 HTTPS 那層(lantls::front)也是同一種迴圈。
現在 httpd::accept_until_stopped:accept 用阻塞的、新連線一到就接;另一條執行緒每 200 毫秒看 alive,要停就連一下自己的埠讓 accept 醒來(閒置時每秒醒 5 次,原本 20 次;停下來最多約 0.25 秒,手機直接連線換埠時 lan_up 本來就每 60 毫秒重試綁定 2.4 秒)。serve_*、lantls 都改用它。上一個 commit 的 Nagle 關閉、小回應一次寫出留著(沒有壞處),FEATURES.md 那行改成真的原因。

已驗證: 本機帳號伺服器 4 個 /api/hello:40/51/59/60 ms → 0.47/0.31/0.25/0.26 ms;cargo test 全綠(822)、relay 全綠(26);測試改成 answers_come_back_at_once_and_a_stopped_server_stops(重用連線、每個請求一條新連線、中間有空檔,平均都要在 15 ms 內;alive 變 false 兩秒內停、埠可以再綁)——把舊的 50 ms 迴圈放回去它會失敗;clippy:app 錯誤數跟之前一樣(12)、relay 乾淨。
未驗證: Linux 上的前後對照,部署到 ai 之後量(之前 50 ms)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 11:10:20 +08:00
王性驊 f6971861d2 每個回應不再多等 40 毫秒:帳號伺服器(ai,家裡)上一個最簡單的 /api/hello,在同一條連線上每個要 40–50 毫秒——直接打 relay 容器也一樣,不是 Caddy 也不是網路。httpd 把回應的標頭和內容分兩次寫,一般的 HTTP 連線又沒有關掉 Nagle(只有 WebSocket 關了):內容要等對方確認標頭才送,對方的確認壓著最多 40 毫秒。帳號伺服器、手機頁面都用這份 httpd,手機經帳號伺服器問大腦一次要付兩次。現在每條連線一接進來就關掉 Nagle,16 KB 以下的回應標頭和內容一次寫出;手機頁面的區網 HTTPS 那層(lantls)兩邊的連線也關掉。
已驗證: cargo test 全綠(822)、relay cargo test 全綠(26);新測試 answers_on_a_kept_connection_come_back_at_once(同一條連線 10 個請求平均要在 15 毫秒內;macOS 的本機迴路不壓確認,這台關掉修正也會過——擋的是 Linux,帳號伺服器和大腦都跑在 Linux);clippy 錯誤數跟之前一樣(12)。
未驗證: Linux 上修正前後的對照,部署到 ai 之後量(修正前 /api/hello 每個 50 毫秒)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 11:03:38 +08:00
王性驊 61d746a064 perf: 帳號伺服器自己壓縮——網頁版不再每次下載 301 KB 等 5–7 秒
正式站前面是 tailscale serve(不壓縮),帳號伺服器卻一直假設前面的 Caddy 會壓:
頁面、狀態、聊天全部原樣傳,又走 Tailscale 的香港中繼,打開一次要 5–7.5 秒。

- 壓縮函式搬到 src/httpd.rs,直接連線和帳號伺服器共用;帳號伺服器的文字回答
  (頁面、狀態、聊天、大腦轉回來的資料)自己用 gzip 壓,頁面 301 KB → 95 KB,只壓一次。
- 連線畫面上的圖示讓瀏覽器留一天(之前每次打開都重新下載)。
- FEATURES.md、docs/feature-map/phone.md 同步。

已驗證: cargo test(主程式 756、帳號伺服器 24,含新的壓縮測試);本機帳號伺服器實測
gzip、內容一字不差、304;verify-anybot 手機區「還沒連上就在外面」「清單和選單」「聊天」
「只傳有變的」;獨立審查無 P0/P1。
未驗證: 正式站的實際秒數(要先 make update-server 部署);主畫面 App、推播(要真的手機)。

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5JgTkqJjkgMtrEXrn
2026-11-20 01:03:47 +08:00
王性驊 668876a9d9 feat: 手機連線韌性與只傳差異(逾時重連、自動重送、keep-alive、gzip)
手機頁面
- 每個請求都有逾時;網路斷掉、回到前景、網路恢復時立刻重連,失敗用退避等待
- 標題列下方「連線中斷,正在重新連線…」,連上自己消失;背景請求的「連不上」不再另外跳提示
- 傳訊息帶 id,斷線時自己重送(最多約一分鐘);重送中寫「網路不穩,重新傳送中…」,不給手動重送按鈕
- 記住這台是不是走帳號伺服器,hello 一時失敗也能照樣開

大腦(remote.rs)
- /send 用 (Bot, id) 認重送,十分鐘內同一則只收一次
- /api/state 帶 ssig 只回有變的欄位、沒變的 Bot 只回 {id, same};chat 帶 chat_delta=1 只回從哪裡開始不一樣
  (都是選用參數,舊頁面照舊拿整份)
- 直接連線:連線保留(keep-alive)、文字回應 gzip、頁面 ETag/304

帳號伺服器(relay)
- 轉送手機的請求時,電腦的回應也壓縮傳輸(要重新部署 relay 才生效)
- 頁面 ETag/304

feature-map:phone.md 新增 phone-net(斷線又回來、只傳有變的);account.md 補壓縮。FEATURES.md 同步。

已驗證: cargo test 728 通過(含 featuremap::、layout_audit::);relay cargo test 23 通過(two_factor_codes_recovery_once_and_logout_everywhere 跑一次跨到 TOTP 時間窗偶發失敗,單跑 4/4、全套重跑 2/2 都過,跟這次無關);verify-anybot 跑完 phone.md 全部步驟和 account.md 直接連線步驟:關掉大腦時提示出現、斷線時傳的那句在大腦回來後自己送到且假模型只收到 1 次、提示自己消失;頁面 299,940→96,872 bytes(gzip)、If-None-Match 回 304、curl 重用同一條連線、ssig 差異回 [true,false,false,true]
未驗證: 帳號伺服器實機路徑(要部署 relay 和 Caddy,只有 relay 單元測試蓋到壓縮來回);真 iPhone 的背景切換和 Wi-Fi/行動網路切換(要實機手機);CLAUDE.md 的乾淨脈絡獨立審查還沒跑

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 18:52:03 +08:00
王性驊 1eb88a9a60 公測前第二輪:區網直連改 HTTPS、手腳只聽大腦簽過的指令、更新驗簽章、聊天各存各的檔、視窗沒在前面也照常運作(提示音不再等你切回來)
- 區網直連:同一個埠用這台電腦自己做的憑證說 HTTPS(lantls),區網的 http 轉到 https,本機和 Tailscale 仍可用 http
- 配對碼後面帶一段不經過帳號伺服器的密鑰,大腦給手腳的指令都簽章(綁電腦、時間、只能用一次)
- deploy/update.sh、install.sh、install.ps1:記住簽章公鑰後,新版不是它簽的就不裝;make sign-setup 啟用
- state.json 只剩設定,聊天存 chats/bot-<id>.json,有變才寫;金鑰密封存檔
- 帳號伺服器:閒置連線少醒、讀取緩衝變小、請求開頭 15 秒沒送完就斷;本機壓測沒有洩漏
- 視窗縮小/被蓋住時照樣處理 Bot 的事件;任務完成也響提示音;Mac 關掉 App Nap
- 團隊成員在 Bot 忙時的訊息排隊不丟、群組沒有 @ 時看擅長分派、手機可改個人檔案
- setup.sh 對 root Docker 提出警告;收到停止訊號先收尾

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-14 00:40:16 +08:00
王性驊 8ed7132e6b /btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理)
支線與介面
- /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完
- 螢幕一次只給一輪工作操作(所有 Bot 適用)
- 「/」只列指令,打字才找這個 Bot 自己的技能
- Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機)
- 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報

安全(中繼伺服器)
- 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案
- 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計
- 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個
- 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要
- 發布的網站不能送表單和對外連線;Caddy 加安全標頭

安全(大腦)
- 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效
- 團隊成員只看得到勾選「團隊成員可以使用」的 Bot
- 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址

資源
- 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動
- App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線
- 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉
- 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 23:36:34 +08:00
王性驊 eb3157852a 安全、修正: 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 14:34:10 +08:00
王性驊 f9a261959c version_0_1_1-alpha 2026-11-11 16:19:06 +08:00
王性驊 a514b33fb3 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 11:46:17 +08:00
AnyBot Dev b23ac40c0b Relay 2FA: TOTP + recovery codes, argon2id, one-page logout (S2)
- login with 2FA on returns a 5-minute challenge, not a session; the session
  comes from /relay/2fa/verify with an authenticator code — or one of eight
  recovery codes, each good once (hash slot emptied)
- /relay/2fa/enroll hands out the secret (QR) + codes once; enabling completes
  only when a real code proves the app has the secret; disable proves the code
- /relay/sessions/logout kicks every device of the account from one page
- password hashes are argon2id (memory-hard, OWASP parameters); stored PBKDF2
  hashes still sign in — no forced reset, upgrade on next password change
- TOTP is RFC 6238 (vectors pinned in tests); mobile page prompts for the
  second step; protocol.md documents the endpoints
- fixes a double-lock in /relay/me found by the flow test (handlers hold one
  data guard: read through it)
2026-11-09 17:52:42 +08:00
王性驊 2867c8e822 Remove what nothing uses and keep one copy of what was written several times
Unused (found by taking away the dead-code allowances; nothing else used them, tests aside):
computer::specs, quiet_button, the never-made Poke::Spin, ten icons and their SVGs, the
theme's chrome/bubble_agent colours, ImportRow.line, voice's multipart/transcribe/speak
wrappers, and the old keychain writers vault::save/remove/index_add with their live test
(the vault store replaced them; reading old keychain entries for the import stays).

One copy each: percent-encoding (httpd::url_encode, was four), tool arguments (tools::args_of,
was three), the WebSocket handshake (httpd::accept_websocket, was three), the read pacing
(wire::Pace, was two: relay and app), docker with input and a time limit (dk_with_input, was
two). Docs: FEATURES §看畫面 (VNC), protocol (v* frames, /screen, tickets), architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:21:47 +08:00
王性驊 96174c4776 Stream deltas keep tool-call slots; chunked bodies accepted; portal sessions race-safe 2026-11-05 15:48:20 +08:00
王性驊 b153051e58 Lasting connection to the account server, per-item sync, files and models via the brain
- Each AnyBot keeps one WebSocket to the account server (pinged, reopened
  within a second when cut). Requests come down it at once; calls to other
  AnyBots of the account (brain sync, hands) go up it. Frames carry raw
  bytes, compressed when that saves space. HTTP long-poll stays as fallback.
- The account server knows at once when an AnyBot goes away.
- Edits to lists and maps go item by item, so two computers editing one
  list keep both changes.
- Screens fetch chat files from the brain, get model lists through the
  brain's keys, and show the brain's computer as the brain's.
- Moving this computer's bots skips starter bots the brain has and bots
  already moved.
- The phone goes to the brain instead of a computer that shows it.
- deploy/linux/hands.sh: a Linux computer (with or without a screen) as
  hands, kept running by systemd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 19:30:32 +08:00
王性驊 d7ee3f5db9 AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 16:51:51 +08:00