AnyBot/src/app/profile_ui.rs

436 lines
25 KiB
Rust
Raw Normal View History

// Bot 設定 › 個人檔案: who the bot is (its soul and 指示 — one text —, what it is good at, what
// it leaves to others), what it may do (能力), the skills it has and the computers it may use;
// and the same from a chat: a bot looks at its own profile (my_profile) and changes it when the
// person asks (update_my_profile — shown to the person as a card first). The rules and the
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
// roster that go with them are in profile.rs.
use super::*;
/// The editor's skill list scrolls past this height.
const SKILL_LIST_MAX_H: f32 = 220.0;
impl App {
/// 個人檔案: soul 與指示 (one text), 擅長, 不找它做的事.
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
pub(super) fn profile_identity_card(&mut self, ui: &mut egui::Ui, b: &mut Bot) {
let p = self.pal;
setting_card(ui, p, |ui| {
setting_title(ui, "個人檔案", "Soul 與指示只有這個 Bot 自己讀:它是誰、怎麼說話做事、要守的規則,每次回答都照著做(關於你的事放在「記得的事」;回答的語言在 設定 › 一般 › 語言)。「擅長」和「不找它做的事」會出現在其他 Bot 的同事名冊裡,讓它們知道什麼事該交給誰。也可以直接在聊天裡請它改自己的設定(會先問你)。", p);
field_label(ui, "Soul 與指示(個性、說話和做事的方式、要守的規則)", p);
ui.add(egui::TextEdit::multiline(&mut b.instructions).hint_text(t("例如:我是細心的研究員,只相信官方來源;先講結論、再給證據,最多三段;不確定就說不確定,不硬猜。")).desired_rows(4).desired_width(f32::INFINITY));
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
field_label(ui, "擅長(什麼事找它)", p);
ui.add(egui::TextEdit::singleline(&mut b.strengths).hint_text(t("例如:FSD 新聞和法規進度、維護追蹤頁")).desired_width(f32::INFINITY));
field_label(ui, "不找它做的事", p);
ui.add(egui::TextEdit::singleline(&mut b.not_for).hint_text(t("例如:寫程式、操作別人的電腦")).desired_width(f32::INFINITY));
});
}
/// 能力: the tool families it has. Fewer is safer and cheaper: what it lacks isn't offered
/// (nor described) on any step.
pub(super) fn profile_abilities_card(&mut self, ui: &mut egui::Ui, b: &mut Bot) {
let p = self.pal;
setting_card(ui, p, |ui| {
let mut on: Vec<String> = b.abilities.clone().unwrap_or_else(|| crate::profile::ABILITIES.iter().map(|a| a.0.to_string()).collect());
design: 全畫面審查第一輪——修傳送按鈕破版、提示改灰、等你的卡片統一、允許卡片精簡、頁面卡片一張、Bot 設定進階收起 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視
2026-11-16 14:57:13 +00:00
let summary = format!("{} / {} {}", crate::profile::ABILITIES.iter().filter(|a| on.iter().any(|o| o == a.0)).count(), crate::profile::ABILITIES.len(), t("類"));
if !fold_title(ui, p, ("abilities", b.id), "能力", &summary, "這個 Bot 可以用哪幾類工具。沒勾的不會提供給它,也不會寫進它的說明:每一步都比較省 token,也比較安全。記憶、技能、問你問題、傳檔案到聊天每個 Bot 都有。") {
return;
}
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
let mut changed = false;
egui::Grid::new(("abilities", b.id)).num_columns(2).spacing([16.0, 4.0]).show(ui, |ui| {
for (i, (key, label, what)) in crate::profile::ABILITIES.iter().enumerate() {
let mut has = on.iter().any(|x| x == key);
if ui.checkbox(&mut has, t(label)).on_hover_text(t(what)).changed() {
changed = true;
if has {
on.push(key.to_string());
} else {
on.retain(|x| x != key);
}
}
if i % 2 == 1 {
ui.end_row();
}
}
});
if changed {
// All of them again: back to "everything", so families added later come too.
b.abilities = if crate::profile::ABILITIES.iter().all(|a| on.iter().any(|x| x == a.0)) { None } else { Some(on) };
}
let n = crate::profile::ABILITIES.iter().filter(|a| crate::profile::has(b, a.0)).count();
hint(ui, format!("{n} / {} 類", crate::profile::ABILITIES.len()), p);
});
}
/// 技能: the ones it has, out of the library (installed once, for all).
pub(super) fn profile_skills_card(&mut self, ui: &mut egui::Ui, b: &mut Bot) {
let p = self.pal;
let all: Vec<(String, String)> = self.state.skills.iter().filter(|k| k.enabled).map(|k| (k.name.clone(), k.description.clone())).collect();
if all.is_empty() {
return;
}
setting_card(ui, p, |ui| {
let mut mine: Vec<String> = b.skills.clone().unwrap_or_else(|| all.iter().map(|k| k.0.clone()).collect());
design: 全畫面審查第一輪——修傳送按鈕破版、提示改灰、等你的卡片統一、允許卡片精簡、頁面卡片一張、Bot 設定進階收起 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視
2026-11-16 14:57:13 +00:00
let summary = format!("{} {} / {}", t("會"), all.iter().filter(|k| mine.contains(&k.0)).count(), all.len());
if !fold_title(ui, p, ("skills", b.id), "技能", &summary, "從技能庫勾選這個 Bot 會的技能。它的說明裡只列這些,用到時才讀完整做法。它自己學會(存成)的技能會自動加進來。") {
return;
}
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
let mut changed = false;
ui.horizontal(|ui| {
let n = all.iter().filter(|k| mine.contains(&k.0)).count();
ui.label(RichText::new(format!("{} {n} / {}", t("會"), all.len())).size(FONT_SM).color(p.text2));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.small_button(t("全不選")).clicked() {
mine.clear();
changed = true;
}
if ui.small_button(t("全選")).clicked() {
mine = all.iter().map(|k| k.0.clone()).collect();
changed = true;
}
});
});
egui::ScrollArea::vertical().id_salt(("skills", b.id)).max_height(SKILL_LIST_MAX_H).auto_shrink([false, true]).show(ui, |ui| {
for (name, about) in &all {
let mut has = mine.contains(name);
let r = ui.checkbox(&mut has, name.as_str());
let r = if about.trim().is_empty() { r } else { r.on_hover_text(about.as_str()) };
if r.changed() {
changed = true;
if has {
mine.push(name.clone());
} else {
mine.retain(|x| x != name);
}
}
}
});
if changed {
// In the library's order, so its instructions read the same every turn.
let ordered: Vec<String> = all.iter().filter(|k| mine.contains(&k.0)).map(|k| k.0.clone()).collect();
b.skills = if ordered.len() == all.len() { None } else { Some(ordered) };
}
});
}
/// Every computer there is for this bot (name, what it is): a screen of a brain asks the brain.
pub(super) fn every_computer(&self, b: &Bot) -> Vec<(String, String)> {
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
if self.mir.on {
return self.mir.computers.get(&b.id).and_then(|c| c["all"].as_array().or(c["names"].as_array()).cloned()).unwrap_or_default().iter().filter_map(|x| Some((x["name"].as_str()?.to_string(), x["kind"].as_str().unwrap_or("").to_string()))).collect();
}
let t = self.all_targets_for(b);
let r = self.roles_for(b, &t);
t.iter().map(|x| (x.name.clone(), mirror_ui::computer_kind(x, &r).to_string())).collect()
}
/// 可以用的電腦: its own always; of the others, the ticked ones.
pub(super) fn profile_computers(&mut self, ui: &mut egui::Ui, b: &mut Bot) {
let p = self.pal;
let own = crate::model::own_computer_name(&b.name);
let all = self.every_computer(b);
if all.len() <= 1 {
return;
}
ui.add_space(6.0);
2026-11-16 14:07:07 +00:00
ui.label(RichText::new(t("可以用的電腦")).size(FONT_SM).color(p.text2));
Bot 個人檔案:soul、擅長、技能、能力、可用電腦、同事名冊;例行任務每輪開新對話(省 token) 每個 Bot 是獨立的個體(src/profile.rs、src/app/profile_ui.rs) - 新欄位:soul(只有自己讀,放在提示最前面)、擅長、不找它做的事、會的技能、能力、可以用的電腦 - 同事名冊:每個 Bot 的提示裡一行一個其他 Bot(簡介、擅長、不找它、在哪幾台電腦),不含別人的 soul 和記憶;順序固定,吃得到快取 - 能力 11 類(上網、瀏覽器、螢幕、檔案與指令、Mac App、連接器、電話簡訊 X、例行任務、頁面、 合作、管理 App):沒勾的工具不提供、規則不寫進提示;硬叫會被 agent 擋下並說該找誰 - 技能:說明只列自己會的,use_skill 只讀得到自己的;自己學會的自動算它的 - 可以用的電腦:自己的電腦一定可以;預設電腦不在名單時回到自己的電腦,不誤報「沒有連線」; 其他畫面也拿得到完整電腦清單來勾;匯出 Bot 不帶電腦名單和草稿 - 舊 Bot 全部勾選(None = 全部),行為不變 - 例行任務:每輪只從那則訊息讀起(Message::fresh),提醒先讀頁面/查記憶;聊天畫面不變, 使用者自己的下一則照樣看整段 - 順手修:角色說明結尾的「。」不再變成「。。」 - 實測(照建議勾能力):明日之星固定內容 ~21.7k → ~11.5k token、FSD ~25.5k → ~13.2k; 例行任務每輪歷史最多 ~70k → 幾百 連接器(MCP) - 實測三個連接器都能用(本機用 AnyBot 自己的 MCP client):time(get_current_time)、 fetch(讀 example.com)、SccMCP(82 個工具,唯讀的 system_status 查詢成功;超過 20 個走 find / use,搜尋得到) - 測試:有「連接器」能力的 Bot 拿得到(大的走 find/use、提示有說明),沒有的拿不到,硬叫三種 方式都被擋 - 測試用的假模型伺服器改成讀完整個請求再回,平行跑測試時不再偶發斷線 驗證:macOS cargo test 389 通過(連跑三次);Windows/Linux cargo check 通過 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 09:14:51 +00:00
let mut on: Vec<String> = b.computers.clone().unwrap_or_else(|| all.iter().map(|c| c.0.clone()).collect());
let mut changed = false;
ui.horizontal_wrapped(|ui| {
for (name, _) in &all {
let is_own = *name == own || all.first().is_some_and(|f| f.0 == *name);
let mut has = is_own || on.contains(name);
let r = ui.add_enabled(!is_own, egui::Checkbox::new(&mut has, name.as_str()));
let r = if is_own { r.on_disabled_hover_text(t("它自己的電腦一定可以用")) } else { r };
if r.changed() {
changed = true;
if has {
on.push(name.clone());
} else {
on.retain(|x| x != name);
}
}
}
});
if changed {
let others: Vec<String> = all.iter().skip(1).map(|c| c.0.clone()).collect();
let kept: Vec<String> = others.iter().filter(|n| on.contains(n)).cloned().collect();
b.computers = if kept.len() == others.len() { None } else { Some(kept) };
// The computer it works on by default must be one of them.
let chosen = b.default_computer.trim().to_string();
let allowed = chosen.is_empty() || chosen == crate::model::BOT_COMPUTER_NAME || chosen == own || b.computers.as_ref().is_none_or(|c| c.contains(&chosen));
if !allowed {
b.default_computer = crate::model::BOT_COMPUTER_NAME.to_string();
}
}
hint(ui, "沒勾的電腦,這個 Bot 看不到也不能用;同事名冊會寫它在哪幾台做事,交辦時才知道該找誰。", p);
}
}
/// One line of a setting's text for the approval card.
fn brief(text: &str) -> String {
let t: String = text.split_whitespace().collect::<Vec<_>>().join(" ");
if t.is_empty() {
"(空)".into()
} else if t.chars().count() > 60 {
format!("「{}…」", t.chars().take(60).collect::<String>())
} else {
format!("「{t}」")
}
}
impl App {
/// Who is talking in a conversation: the bot itself, or in a group the member speaking now.
pub(super) fn speaking_bot(&self, conv: u64) -> u64 {
self.state
.bot(conv)
.filter(|b| !b.members.is_empty())
.and_then(|b| b.messages.iter().rev().find(|m| m.role == Role::Assistant).map(|m| m.author))
.filter(|a| *a != 0)
.unwrap_or(conv)
}
/// my_profile: everything about the bot's own settings, in words.
pub(super) fn my_profile_text(&self, conv: u64) -> String {
let me = self.speaking_bot(conv);
let Some(b) = self.state.bot(me) else { return "找不到這個 Bot".into() };
let or_none = |t: &str| if t.trim().is_empty() { "(沒寫)".to_string() } else { t.trim().to_string() };
let mut out = vec![format!("你的個人檔案(「{}」):", b.name)];
out.push(format!("- 描述(其他 Bot 看得到):{}", or_none(&b.description)));
out.push(format!("- Soul 與指示(只有你自己讀):{}", or_none(&b.instructions)));
out.push(format!("- 擅長(其他 Bot 看得到):{}", or_none(&b.strengths)));
out.push(format!("- 不找你做的事(其他 Bot 看得到):{}", or_none(&b.not_for)));
type Ability = (&'static str, &'static str, &'static str);
let (on, off): (Vec<&Ability>, Vec<&Ability>) = crate::profile::ABILITIES.iter().partition(|a| crate::profile::has(b, a.0));
out.push(format!("- 能力(有):{}", on.iter().map(|a| format!("{}〔{}〕", a.1, a.0)).collect::<Vec<_>>().join("、")));
if !off.is_empty() {
out.push(format!("- 能力(沒有):{}", off.iter().map(|a| format!("{}〔{}〕", a.1, a.0)).collect::<Vec<_>>().join("、")));
}
let library: Vec<&str> = self.state.skills.iter().filter(|k| k.enabled).map(|k| k.name.as_str()).collect();
let (mine, rest): (Vec<&str>, Vec<&str>) = library.iter().partition(|n| crate::profile::has_skill(b, n));
out.push(format!("- 技能(會 {} 個):{}", mine.len(), if mine.is_empty() { "(沒有)".to_string() } else { mine.join("、") }));
if !rest.is_empty() {
out.push(format!("- 技能庫裡你還不會的:{}", rest.join("、")));
}
let every: Vec<String> = self.every_computer(b).into_iter().map(|c| c.0).collect();
let may: Vec<String> = self.targets_for(b).iter().map(|t| t.name.clone()).collect();
let roles = self.roles_for(b, &self.targets_for(b));
out.push(format!("- 可以用的電腦:{}(預設:{})", may.join("、"), Self::chosen_computer(b, &self.targets_for(b), &roles).0));
let not_yet: Vec<&String> = every.iter().filter(|c| !may.contains(c)).collect();
if !not_yet.is_empty() {
out.push(format!("- 沒開放給你的電腦:{}", not_yet.iter().map(|c| c.as_str()).collect::<Vec<_>>().join("、")));
}
let thinking = providers::EFFORTS.iter().find(|e| e.0 == b.thinking).map(|e| e.1).unwrap_or("自動");
let step = match b.step_model.trim() {
"" => "自動".to_string(),
"off" => "不用(每一步都用主模型)".to_string(),
m => m.to_string(),
};
out.push(format!("- 模型:{} · {};思考模式:{thinking};執行步驟用的模型:{step}", b.provider.label(), b.model));
out.push(format!("- 頭像:{} · {}", b.shape, b.color));
out.push("要改就用 update_my_profile(只帶要改的欄位);使用者會先看到確認卡片,按允許才生效。".into());
out.join("\n")
}
/// update_my_profile, worked out against the bot as it is now: the bot as it would be and the
/// changes in words (for the approval card) — or what is wrong with the request.
pub(super) fn profile_change(&self, conv: u64, args: &str) -> Result<(u64, Bot, Vec<String>), String> {
let me = self.speaking_bot(conv);
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
if self.state.bot(me).is_some_and(|b| b.branch_of != 0) {
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
return Err(appctl::BRANCH_NO_SETTINGS.into());
/btw 支線、送出先顯示;公測前的安全與資源修正(帳號盜用、灌爆、團隊權限、背景指令與連線的上限和清理) 支線與介面 - /btw:Bot 的分身帶著同一段對話和記憶平行做另一件事,做完回報到主聊天;主線在忙時先判斷會不會衝突,會就等主線做完 - 螢幕一次只給一輪工作操作(所有 Bot 適用) - 「/」只列指令,打字才找這個 Bot 自己的技能 - Bot 工作中送出的訊息立刻以淡色顯示(電腦、手機) - 支線修正:沒被讀到的回報照常進聊天、卡片顯示結果、可回答支線的問題、重新產生不吃掉卡片和回報 安全(中繼伺服器) - 大腦回傳的內容只放行安全類型並加沙箱;團隊改成邀請制;手機不照大腦說的類型開檔案 - 沒登入的請求最多 256 KB、接收中的上傳有總量上限、單一 IP 連線上限、常駐連線另計 - 登入次數加上每帳號上限並先計數再驗證;密碼雜湊同時最多 4 個 - 新增電腦要 15 分鐘內剛登入;可改密碼;註冊限速,有邀請碼時第一個帳號也要 - 發布的網站不能送表單和對外連線;Caddy 加安全標頭 安全(大腦) - 區網(明文)不能打開直接操作、加一律允許規則、加連接器;區網登入 30 天沒用失效 - 團隊成員只看得到勾選「團隊成員可以使用」的 Bot - 沒有角色的請求一律拒絕;環境變數的金鑰只送官方位址 資源 - 中繼:小變動每分鐘寫一次、回應有總時限、每台電腦呼叫上限、網站/登入/電腦/配對碼上限、資料檔壞掉不啟動 - App:伺服器回錯誤和連線秒斷時逐次退避;區網看螢幕偵測斷線 - 背景指令:刪 Bot 和支線結束時停掉、最多 24 個、結束 10 分鐘後移除、可用 stop 停掉 - 截圖在收起和歸檔時釋放;刪 Bot 時刪附件和對照表;每晚清稽核資料和暫存;手機圖片快取上限 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 15:36:34 +00:00
}
Bot 之間溝通:ask_bot 問同事並等回答、群組 @點名、共用頁面/「關於你」記憶/教技能;修正插話丟附件、Enter 核准失效等 問同事(ask_bot) - A 問 B 並等它回答:問題放進 B 自己的聊天,B 用自己的模型、工具、記憶和電腦做,最後的回覆交回 A - 最多轉 3 手、不能互等(避免卡死)、對方忙就排隊(10 分鐘逾時)、停止 A 時 B 也停 - message_bot 也加轉手上限;別的 Bot 叫的不算使用者的話(改不了自己的設定) 群組 @點名 - 「@名字」只叫被點到的成員回答;成員在回覆裡 @ 別人就接著說(一輪最多 8 則) - 電腦和手機的輸入框打 @ 會列出成員 - 修正:每個成員帶自己的記憶;成員回覆的每一步都記得是誰說的 共用資源 - Bot 可以讀其他 Bot 的頁面(只能讀,改要請作者改) - 共用的「關於你」記憶:每個 Bot 都帶著,記憶頁可切換查看、編輯;外人的訊息不帶 - teach_skill:把自己會的技能教給同事(先問你);同事名冊列出每個 Bot 會的技能 修正 - 插話(Bot 工作中傳訊息)會帶附件:聊天有檔案卡片,模型看得到圖片;當機復原也帶著 - 輸入框有焦點、框是空的時 Enter 允許待核准的步驟(原本被當成空白送出吃掉) - 大腦的螢幕連不到大腦時,引用、附件、記憶不會先被用掉 - 「還原上一個答案」存在 Bot 上:重開還在,連大腦的畫面和手機都能還原;停止的回合也留著 - Bot 忙時被叫醒(例行任務、message_bot、觸發器)改成排隊開自己的一輪,不再壓成純文字插話 - 停止時結果已回來的步驟標成完成;輸入法剛選字的那一格不送出 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3a7riWESpv471gDgC
2026-11-13 13:34:03 +00:00
// 同事之間: what another bot asked for isn't the person's word.
let started_by = self.state.bot(conv).and_then(|b| b.messages.iter().rev().find(|m| m.role == Role::User && !m.steer && !m.interrupted)).map(|m| m.from_bot).unwrap_or(0);
if started_by != 0 {
let who = self.state.bot(started_by).map(|b| b.name.clone()).unwrap_or_else(|| "另一個 Bot".into());
return Err(format!("沒有改:這一輪是「{who}」叫你做的,不是使用者本人。要改設定,請使用者自己跟你說。"));
}
let old = self.state.bot(me).cloned().ok_or("找不到這個 Bot")?;
let v: serde_json::Value = serde_json::from_str(if args.trim().is_empty() { "{}" } else { args }).map_err(|_| "設定的格式看不懂".to_string())?;
let text = |k: &str| v[k].as_str().map(|s| s.trim().to_string());
let list = |k: &str| -> Vec<String> { v[k].as_array().into_iter().flatten().filter_map(|x| x.as_str()).map(|x| x.trim().to_string()).filter(|x| !x.is_empty()).collect() };
let mut b = old.clone();
let mut lines: Vec<String> = vec![];
let mut set = |label: &str, slot: &mut String, new: Option<String>| {
if let Some(n) = new.filter(|n| n != slot.trim()) {
lines.push(format!("{label}:{} → {}", brief(slot), brief(&n)));
*slot = n;
}
};
if let Some(n) = text("name").filter(|n| !n.is_empty()) {
if self.state.bots.iter().any(|x| x.id != me && x.name == n) {
return Err(format!("已經有叫「{n}」的 Bot 了"));
}
set("名稱", &mut b.name, Some(n));
}
set("描述", &mut b.description, text("description"));
set("Soul 與指示", &mut b.instructions, text("soul").or_else(|| text("instructions")));
set("擅長", &mut b.strengths, text("strengths"));
set("不找它做的事", &mut b.not_for, text("not_for"));
// 能力
let (on, off) = (list("abilities_on"), list("abilities_off"));
if !on.is_empty() || !off.is_empty() {
let mut keys: Vec<String> = crate::profile::ABILITIES.iter().map(|a| a.0).filter(|k| crate::profile::has(&old, k)).map(String::from).collect();
for w in &on {
let k = crate::profile::ability_key(w).ok_or_else(|| format!("沒有「{w}」這個能力(可以用:{})", crate::profile::ABILITIES.iter().map(|a| a.0).collect::<Vec<_>>().join("、")))?;
if !keys.iter().any(|x| x == k) {
keys.push(k.to_string());
lines.push(format!("能力:打開「{}」", crate::profile::label(k)));
}
}
for w in &off {
let k = crate::profile::ability_key(w).ok_or_else(|| format!("沒有「{w}」這個能力"))?;
if keys.iter().any(|x| x == k) {
keys.retain(|x| x != k);
lines.push(format!("能力:關掉「{}」", crate::profile::label(k)));
}
}
b.abilities = if crate::profile::ABILITIES.iter().all(|a| keys.iter().any(|x| x == a.0)) { None } else { Some(crate::profile::ABILITIES.iter().map(|a| a.0.to_string()).filter(|k| keys.contains(k)).collect()) };
}
// 技能
let (add, remove) = (list("skills_add"), list("skills_remove"));
if !add.is_empty() || !remove.is_empty() {
let library: Vec<String> = self.state.skills.iter().filter(|k| k.enabled).map(|k| k.name.clone()).collect();
let mut mine: Vec<String> = library.iter().filter(|n| crate::profile::has_skill(&old, n)).cloned().collect();
for n in &add {
let k = library.iter().find(|x| x.eq_ignore_ascii_case(n)).ok_or_else(|| format!("技能庫裡沒有「{n}」"))?;
if !mine.contains(k) {
mine.push(k.clone());
lines.push(format!("技能:學會「{k}」"));
}
}
for n in &remove {
if let Some(k) = mine.iter().find(|x| x.eq_ignore_ascii_case(n)).cloned() {
mine.retain(|x| *x != k);
lines.push(format!("技能:不再用「{k}」"));
}
}
let ordered: Vec<String> = library.iter().filter(|n| mine.contains(n)).cloned().collect();
b.skills = if ordered.len() == library.len() { None } else { Some(ordered) };
}
// 可以用的電腦
let own = crate::model::own_computer_name(&old.name);
let (add, remove) = (list("computers_add"), list("computers_remove"));
if !add.is_empty() || !remove.is_empty() {
let every: Vec<String> = self.every_computer(&old).into_iter().map(|c| c.0).filter(|n| *n != own).collect();
let mut may: Vec<String> = every.iter().filter(|n| old.computers.as_ref().is_none_or(|c| c.contains(n))).cloned().collect();
for n in &add {
let c = every.iter().find(|x| x.eq_ignore_ascii_case(n)).ok_or_else(|| format!("沒有「{n}」這台電腦(有:{})", every.join("、")))?;
if !may.contains(c) {
may.push(c.clone());
lines.push(format!("電腦:可以用「{c}」"));
}
}
for n in &remove {
if n == &own {
return Err("你自己的電腦一定可以用,不能拿掉".into());
}
if let Some(c) = may.iter().find(|x| x.eq_ignore_ascii_case(n)).cloned() {
may.retain(|x| *x != c);
lines.push(format!("電腦:不再用「{c}」"));
}
}
b.computers = if every.iter().all(|c| may.contains(c)) { None } else { Some(every.iter().filter(|c| may.contains(c)).cloned().collect()) };
}
if let Some(c) = text("default_computer").filter(|c| !c.is_empty()) {
let may: Vec<String> = self.targets_for(&b).iter().map(|t| t.name.clone()).collect();
let c = may.iter().find(|x| x.eq_ignore_ascii_case(&c)).cloned().ok_or_else(|| format!("「{c}」不是你可以用的電腦(可以用:{})", may.join("、")))?;
let keep = Self::computer_to_keep(&b, &c);
if keep != b.default_computer {
lines.push(format!("預設電腦:→「{c}」"));
b.default_computer = keep;
}
}
if let Some(c) = &b.computers {
// A default it may no longer use goes back to its own computer.
let d = b.default_computer.trim().to_string();
if !d.is_empty() && d != crate::model::BOT_COMPUTER_NAME && d != own && !c.contains(&d) {
b.default_computer = crate::model::BOT_COMPUTER_NAME.to_string();
lines.push("預設電腦:→ 它自己的電腦".into());
}
}
// 模型
if let Some(p) = text("provider").filter(|p| !p.is_empty()) {
let k = crate::appctl::provider_of(&p).or_else(|| crate::providers::ALL_PROVIDERS.iter().copied().find(|x| x.label() == p)).ok_or_else(|| format!("沒有「{p}」這個供應商"))?;
if k != b.provider {
lines.push(format!("AI 供應商:{} → {}", b.provider.label(), k.label()));
b.provider = k;
if text("model").is_none() {
b.model = k.suggested_model().into();
}
}
}
if let Some(m) = text("model").filter(|m| !m.is_empty() && *m != b.model) {
lines.push(format!("模型:{} → {m}", b.model));
b.model = m;
}
if let Some(t) = text("thinking") {
let t = if matches!(t.as_str(), "auto" | "自動") { String::new() } else { t };
if !providers::EFFORTS.iter().any(|e| e.0 == t) {
return Err("思考模式只有:\"\"(自動)、low、medium、high".into());
}
if t != b.thinking {
let name = |x: &str| providers::EFFORTS.iter().find(|e| e.0 == x).map(|e| e.1).unwrap_or("自動").to_string();
lines.push(format!("思考模式:{} → {}", name(&b.thinking), name(&t)));
b.thinking = t;
}
}
if let Some(m) = text("step_model").filter(|m| *m != b.step_model) {
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
// In the editor's words: "" is 自動, "off" is 不分開 (the card read 「(空) → 「off」」).
let name = |x: &str| match x.trim() {
"" => "自動".to_string(),
"off" => "不分開".to_string(),
m => m.to_string(),
};
lines.push(format!("執行步驟用的模型:{} → {}", name(&b.step_model), name(&m)));
b.step_model = m;
}
if let Some(c) = text("color").filter(|c| *c != b.color) {
let ok = crate::avatar::COLORS.iter().any(|x| x.0 == c) || (c.starts_with('#') && c.len() == 7 && c[1..].chars().all(|ch| ch.is_ascii_hexdigit()));
if !ok {
return Err(format!("沒有「{c}」這個顏色"));
}
lines.push(format!("頭像顏色:{} → {c}", b.color));
b.color = c;
}
if let Some(sh) = text("shape").filter(|sh| *sh != b.shape) {
if !crate::avatar::SHAPES.contains(&sh.as_str()) {
return Err(format!("沒有「{sh}」這個頭像形狀"));
}
lines.push(format!("頭像形狀:{} → {sh}", b.shape));
b.shape = sh;
}
if lines.is_empty() {
return Err("沒有要改的設定(和現在一樣)。先用 my_profile 看現在的設定。".into());
}
Ok((me, b, lines))
}
/// update_my_profile after the person said yes: worked out again against the bot as it is now
/// (it kept talking meanwhile) and only its settings taken over.
pub(super) fn apply_profile_change(&mut self, conv: u64, args: &str) -> appctl::Outcome {
let done = |text: String, ok: bool| appctl::Outcome { text, ok, wake: vec![], theme_changed: false, page: None };
match self.profile_change(conv, args) {
Err(e) => done(e, false),
Ok((me, new, lines)) => {
if let Some(b) = self.state.bot_mut(me) {
b.name = new.name;
b.description = new.description;
b.instructions = new.instructions;
b.strengths = new.strengths;
b.not_for = new.not_for;
b.abilities = new.abilities;
b.skills = new.skills;
b.computers = new.computers;
b.default_computer = new.default_computer;
b.provider = new.provider;
b.model = new.model;
b.thinking = new.thinking;
b.step_model = new.step_model;
b.color = new.color;
b.shape = new.shape;
}
self.mark();
done(format!("已更新你的設定(能力、技能、模型從下一則訊息起生效):\n- {}", lines.join("\n- ")), true)
}
}
}
}