Commit Graph

13 Commits

Author SHA1 Message Date
王性驊 e755e5878d fix: 「教我做」帶附件的訊息、更新前的回合也學得到;稽核紀錄加不了新欄位時照樣寫
- 帶附件的訊息:送給模型的那一份會在使用者的字後面接上附件的說明(app.rs 組歷史時),工作紀錄記的
  就是那一份,所以短訊息的前 40 字對不上,只會說「找不到(只找得到 30 天內…)」。現在帶了 at 就只認
  時間(那則訊息本身),技能的名字和說明用 attach::typed_part 拿掉附件說明、只留使用者打的字;
  照字找的路(沒帶 at 的舊手機頁面)也先拿掉附件說明再比。
- 更新前的回合:那時的稽核紀錄沒記訊息時間(讀成 0),帶了 at 一定對不上。對不上時改在「沒記時間」
  的回合裡照字找最近一次——有記時間的回合不會被這樣找到,所以插話、重新產生的判斷不受影響;風險只有
  更新前 30 天內、插話剛好跟某一回合開頭一樣,跟舊手機頁面同一種,陷阱照實寫。
- 稽核紀錄:ALTER TABLE 失敗(例如另一個 AnyBot 正拿著寫入鎖)時,回合那一列原本因為指名 prompt_at
  而寫不進去,手機的稽核時間軸也跟著空掉。insert_turn 寫不進時改寫不帶 prompt_at 的版本;讀的時候沒有
  那一欄就當時間不知道。
- verify-anybot:phone 多一個 upload <css> <檔>(DOM.setFileInputFiles,代替系統的檔案選擇器),
  用來驗證聊天的附件;SKILL.md、ctl 的用法一起寫。
- 功能地圖 replay.md:陷阱補上「這一版以前做的回合照字找」;自動測試列上新測試。
- 沒改:學習步驟裡的 computer_use_show、當掉後「繼續」把一件事拆成兩回合——都不會讓 Bot 或使用者
  誤會到要寫進陷阱。

已驗證: 完整 cargo test(金鑰清空、DOCKER_HOST 指到不存在、ANYBOT_HF_BASE 連不到)全綠(678 過、46 ignored
  沒跑);cargo clippy --bin anybot --all-targets -- -D warnings 沒有警告;sh deploy/ci/lint-sh.sh 過。新測試
  memory::a_message_with_a_file_and_an_older_turn_can_be_taught、store::the_trail_keeps_writing_when_the_new_column_cannot_be_added
  (真的讓 ALTER 失敗:另一條連線 BEGIN IMMEDIATE 拿著寫入鎖)、attach::the_words_typed_come_back_from_the_models_copy。
  證明會擋:taught_turn 換回上一個 commit(2605445)的版本,帶附件的訊息「找不到」;拿掉沒記時間的
  照字找,更新前的回合「找不到」;拿掉不帶 prompt_at 的 insert 和讀法,回合一列都沒寫進去;放回去都過。
  verify-anybot 冷開照地圖寫的跑 replay.md 四步都過;另外用新的 upload 在手機選一個檔案(清單.txt)送
  「看這張」,假模型收到的是「看這張\n\n[附件「清單.txt」…]」,長按 › 教我做 存成技能「看這張」、說明
  「示範學會:看這張」、一步 echo 看過 >> seen.txt。
未驗證: 真的手機選檔案(用 DOM.setFileInputFiles 代替系統的檔案選擇器)和長按(用無頭 Chrome 的觸控事件);
  已經有舊 audit.db、而且裡面有更新前回合的真實資料夾——只用單元測試;ALTER 失敗的情況只在單元測試裡造出來;
  「網站地圖」照地圖寫的走不到(要真的模型)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 19:27:21 +08:00
王性驊 2605445564 fix: 「教我做」學的是聊天裡留著的那一次——稽核紀錄記下訊息的時間,重新產生後不再學到被換掉的那次
上一版用「訊息時間之後第一個開始的回合」找那一回合,但稽核紀錄沒存訊息自己的時間(還原時拿回合
開始的時間代替),而重新產生、重新傳送、重試是同一則訊息(同一個 at)再開一回合:最早的那次贏,
長按之後學到的是被換掉的第一次(審查者冷開重現:第一次 echo wrong、重新產生 echo right,教我做存了
echo wrong)。

- store:稽核紀錄的回合列多一欄 prompt_at(使用者那則訊息送出的時間);舊的 audit.db 開啟時
  ALTER TABLE 加上,舊列留 NULL(讀成 0,不會被當成任何一則訊息)。records() 拆成 turn_starts(只讀回合
  的第一行:說了什麼、什麼時候送的)和 turn_records(只讀選中的那一回合):原本是在畫面那條執行緒上、
  拿著稽核紀錄的鎖,把 30 天內每一步的參數都讀出來。
- memory:taught_turn 先選回合——有 at 就只認 prompt.at 剛好等於它的回合、取最後一個(聊天顯示的那一次),
  沒有就「找不到」,不再退回別的回合(插話的時間不會對上任何回合);沒帶 at 的舊手機頁面才取同樣的話
  開始的最近一回合。skillify 只把那一回合的步驟做成技能。
- 跟自動學(replay_steps)共用同一份「重播不做的步驟」(never_replayed):教我做原本會留下 use_skill、
  replay_skill、anybot_guide;computer_use_look、computer+action 是不存在的名字(工作紀錄記的是展開後的
  computer_use_*),換成真的 computer_use_show。
- appctl:learned() 自己換成主 Bot(home_of)。從 apply() 進來本來就已經換過,這是讓它不靠呼叫的人。
- 功能地圖 replay.md:多一步「重新產生之後教我做」(長按 › 教我做,存的是 echo right);Bot 讀得到的
  陷阱改寫:學的是那則訊息開始的、聊天裡留著的那一次,插話和 30 天以前的說找不到,舊手機頁面沒帶時間時
  學什麼;丟掉的步驟加上讀說明或技能、重播。自動測試列上新測試。

已驗證: 完整 cargo test(金鑰清空、DOCKER_HOST 指到不存在、ANYBOT_HF_BASE 連不到)全綠(675 過、46 ignored
  沒跑);cargo clippy --bin anybot --all-targets -- -D warnings 沒有警告;sh deploy/ci/lint-sh.sh 過。新測試
  appctl::after_regenerating_the_attempt_shown_is_learned、appctl::a_skill_learned_in_a_branch_is_the_main_bots、
  store::an_older_trail_learns_when_messages_were_sent;memory 的 the_message_pressed_is_the_turn_learned 改成
  重新產生和插話的情況、a_finished_turn_can_become_a_skill 加了 anybot_guide/use_skill/replay_skill、
  store 的 the_trail_keeps_the_story… 改讀 turn_starts/turn_records。證明會擋:兩個 appctl 測試放進上一個
  commit(4be6d3e)的程式碼跑都失敗(存了 echo wrong、主 Bot 沒拿到技能);把選回合改回「之後第一個、
  沒有就最近的」、把三個名字拿出共用清單,memory 兩個測試都失敗;拿掉 ALTER,遷移測試失敗(no such
  column: prompt_at);放回去都過。verify-anybot 冷開照地圖寫的跑 replay.md 四步:做五步學會、重播填空格、
  教我做(長按 › 選單)、重新產生之後教我做(手機按回答下面的「重新產生」,聊天只剩 echo right,存的
  技能 steps 是 echo right >> sign.txt;sign.txt 裡兩次都有,因為兩次都真的跑了)都過。
未驗證: 已經有舊 audit.db 的真實資料夾升級——只用單元測試建一份沒有 prompt_at 欄的表驗證;舊版手機頁面
  (不帶 at)只靠單元測試;「網站地圖」照地圖寫的走不到(要真的模型);真的手機的長按沒有測(用無頭
  Chrome 的觸控事件代替);garden.md 這輪沒有重跑(這輪沒動待改進)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 17:54:21 +08:00
王性驊 4be6d3e4d0 fix: 「教我做」讀 30 天的稽核紀錄,做完的回合也學得到;整理做法回報的問題進得了待改進
教我做(skillify)只讀那個 Bot 的工作紀錄(oplog),但一回合結束時工作紀錄就縮到只剩還在等的訊息
(通常整份刪掉)——長按的是自己早就做完的那則訊息,所以每次都回「那一回合沒有可重播的步驟」。
工作紀錄是給當掉後收尾用的,本來就只留進行中的那一回合;每一步的參數和結果另外照抄進 30 天的
稽核紀錄(oplog/audit.db,手機的稽核時間軸已經改讀它)。教我做要的正是「過去某一回合的步驟」,
所以改讀稽核紀錄,不是把工作紀錄留著。

整理做法(learn)在回答送出、這一回合 Done 之後才在背景跑(不讓使用者等),它回報的 AnyBot 自己的
問題(StreamEvent::Issues)卻排在「舊回合的零星事件一律丟掉」的檢查後面——紀錄寫了「Bot 回報了
2 個 AnyBot 自己的問題」,待改進還是空的。改成跟 Learned 一樣在那個檢查前面處理(事件的順序本來
就是 Done 在前,不能為了它讓使用者等整理做法)。

- store:records(bot) 把稽核紀錄裡 30 天內的回合和步驟還原成工作紀錄的格式(回合開頭帶使用者的話、
  每一步的參數和結果、回合結束排在步驟後面);KEEP_DAYS 公開給錯誤訊息用。
- appctl skillify:讀 store::records,稽核紀錄打不開才退回工作紀錄;把手機送的訊息時間 at 交下去。
- memory::skillify:
  - 學的是按的那則訊息開始的那一回合:同一句話可能做過好幾次(30 天內很常見),有 at 就取那個時間
    之後第一個開始的回合,沒有 at(或時鐘對不上)才取最近的。
  - 比對時兩邊都照手機 plain() 的規則整理(拿掉 * _ ` # >、連結只留字、換行併成空白)——手機送的是
    plain(m.text),原本訊息裡有 >、_ 或換行就對不上。技能的名字、說明、做法改用那一回合原本的字
    (併成一行),不用手機去過標記的字(teach_log.txt 不會變成 teachlog.txt)。
  - 回傳 Result,分開「找不到以「…」開始的那一回合(只找得到 30 天內、由一則訊息開始的回合;做事中途
    插的話不算)」和「沒有可重播的步驟」;「这件事」→「這件事」(整份 memory.rs 用 ICU Hans-Hant 掃過,
    只有這一個簡體字)。
- app drain_events:Issues 跟 Learned 一樣在回合結束後也收;記在主 Bot 名下(支線的算主 Bot 的)。
- 手機:教我做帶上訊息的 at;成功後呼叫的 again() 在那裡不是函式(全域的 again 是 loadChat 的旗標),
  按了會丟 TypeError,拿掉。
- verify-anybot:phone 多一個 long-press <css> [--text](觸控按住 0.8 秒),走得到長按的選單;
  SKILL.md、ctl 的用法一起寫。
- 功能地圖:replay.md 的「教我做」改走真的選單(長按 › 教我做),拿掉「走不到」那一步;陷阱補上學的是
  哪一回合、只找 30 天內、找不到時說什麼;garden.md、replay.md 的自動測試列上新測試。

已驗證: 完整 cargo test(金鑰清空、DOCKER_HOST 指到不存在、ANYBOT_HF_BASE 連不到)全綠(672 過、46 ignored
  沒跑);cargo clippy --bin anybot --all-targets -- -D warnings 沒有警告;sh deploy/ci/lint-sh.sh 過。新測試
  appctl::a_turn_that_has_ended_can_still_be_taught、memory::the_phones_plain_words_find_the_turn、
  memory::the_message_pressed_is_the_turn_learned、app::anybots_own_problems_found_after_the_turn_reach_the_list,
  store 的 the_trail_keeps_the_story… 加了 records、a_finished_turn_can_become_a_skill 加了「這件事」——把修正
  拿掉再跑都失敗(找不到那一回合、待改進是空的、簡體字、學到後來那一回合、說明變成去過標記的字),
  放回去都過。另外請一個乾淨脈絡的 Agent 照 replay.md、garden.md 審過 diff,它提的三點(同一句話學錯回合、
  技能的字被手機去掉標記、插話也說「30 天內」)都改了。verify-anybot 冷開照地圖寫的跑:replay.md 三步
  (做五步學會、重播填空格、教我做——長按 › 選單 › 「已存成技能」,那一回合已經做完、工作紀錄不在,技能
  steps 1、參數和說明都照原樣 echo 教 >> teach.txt;長按插話跳「找不到以「…」開始的那一回合…」)都過,修改前
  第三步是 HTTP 400;garden.md 沒事不報、/doctor 遮金鑰、待改進合併計次(browser_fill_contact 一條 count 2、
  bots 驗證小幫手,重開後還在)、版本都過,修改前第三步待改進是空的。
未驗證: garden.md 的「電腦版 設定 › 更新」要開桌面視窗(desktop-shot),沒跑;「有事的報告、當掉」和
  replay.md 的「網站地圖」照地圖寫的走不到(要明天 8:44、真的當掉、真的模型);garden.md 是在審查後那幾處
  修改之前的建置上跑的(那幾處只動 skillify 和手機的教我做,沒動待改進);真的手機的長按沒有測(用無頭
  Chrome 的觸控事件代替);超過 30 天的回合、別台裝置時鐘不準時的 at 只靠單元測試。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
2026-11-18 17:33:43 +08:00
王性驊 d23ca7628d chore: clippy 全部清乾淨,CI 有新警告就失敗;make lint
工程基礎計畫 E6。33 個警告改掉,行為不變(測試全過):
- 順序一樣、寫法更直接:sort_by(b.cmp(a)) → sort_by_key(Reverse)(三處,都是穩定排序);chunks_exact(4) → as_chunks::<4>()(拿掉一個 unwrap);用 checked_div 取代先判斷 total > 0;兩個一樣的分支合成一個條件;計數迴圈用 enumerate;單一運算式的立即呼叫閉包改成區塊;回傳 () 的函式不再包在 Ok() 裡。
- 型別取名:VoicesAnswer、Vocab、Group。system_prompt 的 11 個參數留著(每個是指示的不同部分),標 allow 並寫理由。
- 小的:多餘的 clone、format!、vec!、into、借用;3_600_000 的分組;文件註解的縮排和空行;新檔案明說不截斷。
- .gitea/workflows/ci.yml:clippy 改成 `--all-targets -- -D warnings`(原本只報告)。make lint 跑一樣的檢查。
- 不加 rust-toolchain.toml:AnyBot 是使用者自己建的,釘版本會逼每個人和 make update-server 多下載一套 Rust;CI 映像本來就釘 1.98.1。

已驗證:cargo test 560 全過;cargo clippy --bin anybot --all-targets -- -D warnings 在這台 Mac 過。
未驗證:只在 Linux 編譯的程式(x11.rs、wl.rs、portal.rs…)的 clippy:這台 Mac 看不到,第一次 CI 跑會檢查,若有警告會擋下來。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:18:12 +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
王性驊 3b8c4c3d3b Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等
問同事(ask_bot)
- A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A
- 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停
- message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定)

群組 @點名
- 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則)
- 電腦和手機的輸入框打 @ 會列出成員
- 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的

共用資源
- Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改)
- 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶
- teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能

修正
- 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著
- 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉)
- 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉
- 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著
- Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話
- 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 21:34:03 +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
王性驊 28784232a5 記憶: a page to see it, a few lines picked while typing, a local model
The memory had grown into a list carried whole, a top-14 recalled by a
trigram index and pasted into the system prompt with the clock, and a
page that broke its own layout. Nobody could see what went to the
model, the prompt cache missed every message, and 「記住」 kept saying
the same thing twice. Rebuilt per the spec (docs/memory.md):

- Three kinds in memory.db: 記得的事 (fact), 做過的事 (event, a line per
  finished turn), 整理過的 (rollup). Each keeps pinned, uses,
  last_used, deleted, superseded_by, span. state.json keeps the facts
  as the copy that syncs; the page reads SQLite.
- Search: jieba words ∪ CJK bigrams in an FTS5 unicode61 table
  (Traditional text goes through Simplified first), weighted share of
  query terms hit; plus local vectors, vec = clamp((cos−0.35)/0.35).
  score = max + 0.15×min, events ×0.9. ≥0.15 suggested, ≥0.5 ticked,
  ≥0.55 carried when nobody chose (3 at most).
- What the model gets: the system prompt has the time zone and the
  pinned memories only, the same every turn. Each person message gets
  〔送出時間〕 and 〔相關記憶〕 from Message.memories, built in
  group_history into a transient Message.context, so the beginning of
  a chat reads the same next turn (cache hits) and the event log,
  skills and audit see only what was typed. A memory already carried
  in view isn't carried again; each carry counts a use.
- Picks travel with the message: Cmd::Send / POST send / sync act
  "memories" (empty = none; absent = the brain chooses, once, saved).
- remember finds the like one (cos ≥ 0.85 or the same words) and asks
  for `replaces`; the old one is superseded, never carried. A fact
  forgotten and remembered again comes back. New search_memory
  (query, kind), with dates; read-only.
- Nightly on the brain, no model: events past 30 days fold into a line
  per week (「11/3–11/9 做過的事(14 件):整理照片 ×3…」, ≤400 chars,
  like with like by words or vectors), weeks past 180 days into months;
  the folded go to 最近刪除 for 30 days. Facts are never removed. The
  page offers duplicates, facts unused for half a year, and what can
  fold now.
- Local model: minishlab/potion-multilingual-128M through m2v.rs (same
  token ids as model2vec-rs on 13/13 sentences, cos ≥ 0.9999, without
  tokenizers' 1.1 GB). Converted while downloading: vocab.bin,
  table.i8 (int8 + row scales), dims.json, 137 MB kept of 530 MB;
  ANYBOT_HF_BASE picks a mirror (now passed into the server's brain
  container too). Loaded when first needed (34 ms), let go after 10
  idle minutes. The brain loads it; a screen only with a document
  folder set; hands and phones never. 設定 › 一般 › 語意搜尋:
  本機模型/Ollama/關閉; a new engine clears every vector.
- Three files, three connections: memory.db (backed up nightly, 7
  kept), docs.db (a cache), oplog/audit.db (30 days). An old audit.db
  hands its memories and documents over once and shrinks (a real one:
  172 MB → 16 KB). docs_search scans every chunk now, vectors cached
  in RAM (it stopped at 8000); FTS optimize + VACUUM daily (260 MB of
  tombstones over 31 MB of text).
- API: POST /api/memory (owner) and /api/sync/memory (mirror). Reads
  answer on the HTTP thread; writes go through phone_act("memory").
- Screens: a memory dialog (Bot menu 記憶…, Bot settings 打開記憶) with
  counts, live search, filters, suggestions, per-item kind/date/uses
  and pin/edit/forget/restore; chips above the composer 300 ms after
  typing stops, with a token estimate; 「帶了 N 條記憶」 under person
  messages. The phone has the same as a 記憶 tab, chips and tag.

Checked: make test passes (app 297, relay 16), with new tests for the
scores and thresholds, Traditional Chinese segmentation, remember's
dedupe and replaces, two turns sending the same beginning, no double
carry, weekly/monthly folding and the trash, and the audit.db move.
Brain idle 37 MB as before, ~230 MB with the model loaded; search on
the brain 0.2–0.5 ms, 7–44 ms from the phone page. A deadlock found on
the way (stats re-taking the lock) is fixed and tested.

Docs: docs/memory.md has the whole design; FEATURES.md, protocol,
architecture (zh/en), multi-device and install say what changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3SYw9JJ9dXwaNvYh4
2026-11-11 07:46:50 +08:00
AnyBot Dev f7eb5dbcab Meaning beside the words: local embeddings + a document shelf (P6, step 2)
- embed.rs: vectors from the person's own Ollama (/api/embed), model
  auto-found among installed ones (bge-m3, nomic-embed-text…), off by
  absence — no Ollama is a normal state: every search still answers
  with words, the toggle lives in 設定 › 一般
- memories grow a vec column; recall() is now hybrid: trigram FTS,
  two-character windows for Chinese, cosine over the shelf, merged by
  reciprocal rank — 「那篇講語法的筆記」 finds text that never says 筆記
- docindex.rs: the person's folders (their 文件 by default, add more in
  設定 › 一般), text-shaped files chunked into SQLite + FTS, refreshed
  by mtime, gone files leave; one background thread does it all — the
  turn never waits on embeddings
- one tool for it: search_documents {query, limit} — reads, no approval
- 251 tests: a real temp folder swept, answered, and swept again after
  deletion; offline Ollama tested as the normal state it is
2026-11-09 20:23:35 +08:00
AnyBot Dev bbd677b050 Memory, searched not carried: FTS index + event log (P6, step 1)
- store.rs grows a memories table + FTS5 (trigram) index: bot facts and
  the person's shared lines (bot 0), no cap — state.json's 200-item list
  stays the source that mirrors sync and the 設定 list; the index is its
  searchable superset, best-effort as always
- queries answer in Chinese: phrase hits (FTS), then words inside lines —
  CJK queries cut into two-character windows, lines scored by how many
  they contain (「有没有靠窗」 finds 「我喜歡靠窗的座位」)
- every finished turn writes one event line (ask → answer) nobody's
  asked to write: 「我上個月說的那個報表」 answers from months back
- the turn's prompt carries the 14 memories that answer *this* request
  (no index yet: the list itself, the old behavior); remember/forget and
  the UI's 忘記 keep the index in step with the list
- embedding (Ollama) and document indexing land on this same table next
2026-11-09 18:15:24 +08:00
AnyBot Dev bbbe494dae SQLite layer: the audit trail becomes queryable history (P4, step 1)
- src/store.rs: bundled SQLite (WAL) in the data folder; every oplog record
  is mirrored into an audit table — turns, model calls, tools with their
  arguments and end statuses, queued messages, stops
- side-car by design: state.json stays the app's truth (one struct, written
  atomically); the mirror is best-effort — an audit that never breaks a turn,
  and a timeline that answers for 30 days, not just for the running turn
- /api/bots/<id>/audit now reads the trail (phone's 稽核 tab gains history)
- retention: rows older than KEEP_DAYS are deleted on open
- groundwork for memory/RAG (P6) on the same layer; state.json itself moves
  in step 2 with the memory tables (the app keeps reading State as a struct)
2026-11-09 18:02:56 +08:00
AnyBot Dev 38707ccd72 wip: sqlite audit trail 2026-11-09 18:00:56 +08:00