AnyBot/src/routines.rs

787 lines
38 KiB
Rust
Raw Normal View History

// Routines: tasks a bot repeats on a schedule. The schedule has the same shape as the original's
// (index.eager-app @1508626, `Prt` / `Irt`): frequency daily|weekly|monthly|yearly, an interval,
// weekdays MO..SU (`yA`), a day of the month or "the Nth weekday", a month, a time "HH:MM" and a
// time zone. Descriptions use the original's zh-TW wording (ids UdWx3W, orHQyz, W+dYrs, Y8bJts,
// kToBIG, kfbKQI, h3xQKP, ni0dzI, 1HiPWu, hlCyZb, kGmiCr, GGSF1N, gjpnJh, jjNxA6).
記憶: 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-10 23:46:50 +00:00
use chrono::{Datelike, Duration, NaiveDate, NaiveTime, TimeZone, Utc, Weekday};
use chrono_tz::Tz;
use serde::{Deserialize, Serialize};
/// The original's weekday order (`yA=["MO","TU","WE","TH","FR","SA","SU"]`).
pub const WEEKDAYS: [&str; 7] = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
pub const WORKWEEK: [&str; 5] = ["MO", "TU", "WE", "TH", "FR"];
const WEEKDAY_ZH: [&str; 7] = ["週一", "週二", "週三", "週四", "週五", "週六", "週日"];
const WEEKDAY_ZH_LONG: [&str; 7] = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"];
/// How far ahead to look for the next run (estimated).
const SEARCH_DAYS: i64 = 366 * 5;
#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum Frequency {
/// 每 N 分鐘 (counted from when it was made).
Minutely,
/// 每小時 / 每 N 小時, at the minute of `time`.
Hourly,
Daily,
Weekly,
Monthly,
Yearly,
}
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct WeekdayOfMonth {
/// 1..=4, or -1 for the last one.
pub week: i32,
pub day: String,
}
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Schedule {
pub frequency: Frequency,
#[serde(default = "one")]
pub interval: u32,
#[serde(default, rename = "daysOfWeek", skip_serializing_if = "Vec::is_empty")]
pub days_of_week: Vec<String>,
#[serde(default, rename = "monthDay", skip_serializing_if = "Option::is_none")]
pub month_day: Option<u32>,
#[serde(default, rename = "weekdayOfMonth", skip_serializing_if = "Option::is_none")]
pub weekday_of_month: Option<WeekdayOfMonth>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub month: Option<u32>,
/// "HH:MM", 24-hour.
pub time: String,
pub timezone: String,
/// 僅一次: runs once, then stops.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub once: bool,
/// 「左右」: a flexible time, anywhere in ±FLEX_MINUTES (the original's flexible mode).
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub flexible: bool,
}
/// How far a flexible ("左右") time may move either way (estimated; the original has a window).
pub const FLEX_MINUTES: i64 = 15;
/// Shortest repeat for 每 N 分鐘 (estimated).
pub const MIN_MINUTES: u32 = 5;
fn one() -> u32 {
1
}
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Routine {
pub id: u64,
pub title: String,
/// What the bot is asked to do each time.
pub prompt: String,
pub schedule: Schedule,
#[serde(default)]
pub paused: bool,
/// Seconds since 1970 (UTC).
#[serde(default)]
pub created_at: i64,
#[serde(default)]
pub last_run: Option<i64>,
#[serde(default)]
pub next_run: Option<i64>,
/// Which computer to work on ("" = the bot's default).
#[serde(default)]
pub computer: String,
/// Run when something happens instead of on the schedule.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub trigger: Option<crate::triggers::Trigger>,
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
/// How its latest runs went, oldest first (at most RUNS_KEPT): what the person and the bot
/// look at to know whether it works — it used to keep only when it last started.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub runs: Vec<RoutineRun>,
/// Why AnyBot paused it (failed PAUSE_AFTER_FAILURES times in a row); empty when the person did.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub paused_why: String,
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
/// 完成條件: how many sends a run is to make (0: none). The system counts them (not the
/// bot): no send past it, a run that ends short of it failed, and a run that makes none for
/// two check-ins in a row is stopped.
#[serde(default, skip_serializing_if = "is_zero_u32")]
pub target_sends: u32,
}
fn is_zero_u32(n: &u32) -> bool {
*n == 0
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
/// How one run went.
#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[serde(rename_all = "lowercase")]
pub enum RunOutcome {
Running,
Succeeded,
Failed,
/// The person (or the 15-minute approval watchdog's stop) ended it.
Stopped,
/// AnyBot closed while it ran: part of it may be done.
Interrupted,
}
/// One run of a routine.
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct RoutineRun {
/// Seconds since 1970 (UTC).
pub started: i64,
#[serde(default)]
pub ended: i64,
pub outcome: RunOutcome,
/// Why it failed or stopped; for a run that went through, the first words of its report.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub note: String,
/// Steps it took, and how many of them failed or were refused.
#[serde(default)]
pub steps: u32,
#[serde(default)]
pub failed_steps: u32,
/// Steps that sent something out and went through (evidence::sends): the system's count,
/// beside whatever the report says.
#[serde(default)]
pub sent: u32,
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
/// What went out and where, as the system saw it (「回覆 <post> → <reply's address>」): the
/// evidence, at most SENDS_KEPT.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub sends: Vec<String>,
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
/// Run by hand (立即執行), not by its time or its event: not on 日程.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub by_hand: bool,
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
/// Evidence lines kept per run.
pub const SENDS_KEPT: usize = 30;
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
/// Runs kept per routine (Grok Bot keeps 20 run records per routine).
pub const RUNS_KEPT: usize = 20;
/// Failed runs in a row after which AnyBot pauses the routine and says why (noodle: "If an item
/// has failed 2+ times in recent_history, deschedule or split it").
pub const PAUSE_AFTER_FAILURES: usize = 2;
/// What an interrupted run says.
const INTERRUPTED_NOTE: &str = "AnyBot 在執行中被關掉,可能做到一半";
impl Routine {
/// A run begins.
pub fn run_started(&mut self, at: i64) {
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
self.runs.push(RoutineRun { started: at, ended: 0, outcome: RunOutcome::Running, note: String::new(), steps: 0, failed_steps: 0, sent: 0, sends: vec![], by_hand: false });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
let extra = self.runs.len().saturating_sub(RUNS_KEPT);
self.runs.drain(..extra);
}
/// The run in progress ended. True when that makes PAUSE_AFTER_FAILURES failures in a row:
/// the routine is then paused, with the reason kept for the person.
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
pub fn run_ended(&mut self, at: i64, outcome: RunOutcome, note: &str, tally: &crate::evidence::Tally) -> bool {
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
let note = note.trim().to_string();
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
let (steps, failed_steps, sent) = (tally.steps, tally.failed, tally.sent);
// 完成條件: a run that says it is done but sent fewer than it was to (by the system's
// count) didn't make it.
let (outcome, note) = if self.target_sends > 0 && outcome == RunOutcome::Succeeded && sent < self.target_sends {
(RunOutcome::Failed, format!("只送出 {sent}/{} 則(系統計數){}", self.target_sends, if note.is_empty() { String::new() } else { format!(":{note}") }))
} else {
(outcome, note)
};
let sends: Vec<String> = tally.sends.iter().take(SENDS_KEPT).cloned().collect();
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
match self.runs.iter_mut().rev().find(|r| r.outcome == RunOutcome::Running) {
Some(r) => {
r.ended = at;
r.outcome = outcome;
r.note = note.clone();
r.steps = steps;
r.failed_steps = failed_steps;
r.sent = sent;
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
r.sends = sends;
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
// (Started before runs were kept, or by a path that didn't note the start.)
None => {
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
self.runs.push(RoutineRun { started: at, ended: at, outcome, note: note.clone(), steps, failed_steps, sent, sends, by_hand: false });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
let extra = self.runs.len().saturating_sub(RUNS_KEPT);
self.runs.drain(..extra);
}
}
let failed_in_a_row = self.runs.iter().rev().take_while(|r| r.outcome == RunOutcome::Failed).count();
if outcome == RunOutcome::Failed && failed_in_a_row >= PAUSE_AFTER_FAILURES && !self.paused {
self.paused = true;
self.paused_why = format!("連續 {failed_in_a_row} 次失敗,AnyBot 先暫停了。最近一次:{note}");
return true;
}
false
}
/// Runs AnyBot was closed during (found when it starts again).
pub fn mark_interrupted(&mut self) {
for r in self.runs.iter_mut().filter(|r| r.outcome == RunOutcome::Running) {
r.outcome = RunOutcome::Interrupted;
r.note = INTERRUPTED_NOTE.into();
}
}
/// The latest finished run, when it didn't go through (what the next run is told about).
pub fn last_trouble(&self) -> Option<&RoutineRun> {
self.runs.iter().rev().find(|r| r.outcome != RunOutcome::Running).filter(|r| matches!(r.outcome, RunOutcome::Failed | RunOutcome::Interrupted))
}
}
/// What a turn that just ended says about the routine run it was. None when the turn wasn't a
/// routine's.
pub struct TurnResult {
pub routine: u64,
pub outcome: RunOutcome,
pub note: String,
pub tally: crate::evidence::Tally,
}
pub fn turn_result(msgs: &[crate::model::Message], outcome: crate::model::TurnOutcome) -> Option<TurnResult> {
use crate::model::{Role, TurnOutcome};
let start = msgs.iter().rposition(|m| m.role == Role::User && !m.steer)?;
let routine = msgs[start].routine;
if routine == 0 {
return None;
}
let turn = &msgs[start..];
let tally = crate::evidence::tally(turn);
// A report's first real line (not a heading), short.
let line = |t: &str| -> String { t.lines().map(str::trim).find(|l| !l.is_empty() && !l.starts_with('#')).unwrap_or("").chars().take(120).collect() };
let (run, note) = match outcome {
TurnOutcome::Success => (RunOutcome::Succeeded, turn.iter().rev().find(|m| m.role == Role::Assistant && !m.note && !m.text.trim().is_empty()).map(|m| line(&m.text)).unwrap_or_default()),
TurnOutcome::Error => (RunOutcome::Failed, turn.iter().rev().find(|m| m.error).map(|m| line(&m.text)).filter(|l| !l.is_empty()).unwrap_or_else(|| "出錯了".into())),
TurnOutcome::Cancelled => (RunOutcome::Stopped, "被停止".into()),
};
Some(TurnResult { routine, outcome: run, note, tally })
}
/// One run in a line: 「11/14 17:00 失敗(35 分鐘,87 步,12 步沒成功):原因」.
pub fn describe_run(r: &RoutineRun, timezone: &str) -> String {
let tz = tz_of(timezone);
let when = Utc.timestamp_opt(r.started, 0).single().map(|t| t.with_timezone(&tz).format("%m/%d %H:%M").to_string()).unwrap_or_default();
let word = match r.outcome {
RunOutcome::Running => "執行中",
RunOutcome::Succeeded => "完成",
RunOutcome::Failed => "失敗",
RunOutcome::Stopped => "被停止",
RunOutcome::Interrupted => "中斷",
};
let mut facts = vec![];
if r.ended > r.started {
let mins = (r.ended - r.started + 59) / 60;
facts.push(format!("{mins} 分鐘"));
}
if r.steps > 0 {
facts.push(if r.failed_steps > 0 { format!("{} 步,{} 步沒成功", r.steps, r.failed_steps) } else { format!("{} 步", r.steps) });
}
if r.sent > 0 {
facts.push(format!("系統記到送出 {} 次", r.sent));
}
let facts = if facts.is_empty() { String::new() } else { format!("({})", facts.join(",")) };
let note = if r.note.is_empty() { String::new() } else { format!(":{}", r.note) };
format!("{when} {word}{facts}{note}")
}
pub fn local_timezone() -> String {
iana_time_zone::get_timezone().unwrap_or_else(|_| "Asia/Taipei".into())
}
/// The person's time zone (their setting), for times shown to them by an AnyBot whose own clock
/// may be elsewhere: a brain on a server runs in UTC, and a page 「更新於 今天 01:03」 meant 09:03.
static PERSON_TZ: std::sync::Mutex<String> = std::sync::Mutex::new(String::new());
/// A zone that only says where the computer is, not where the person is (a server's UTC).
pub fn is_server_default_zone(tz: &str) -> bool {
matches!(tz.trim(), "" | "UTC" | "Etc/UTC" | "Etc/Universal" | "Universal" | "Zulu" | "GMT" | "Etc/GMT")
}
pub fn set_person_timezone(tz: &str) {
*PERSON_TZ.lock().unwrap_or_else(|e| e.into_inner()) = tz.to_string();
}
pub fn person_tz() -> Tz {
tz_of(&PERSON_TZ.lock().unwrap_or_else(|e| e.into_inner()))
}
記憶: 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-10 23:46:50 +00:00
pub fn tz_of(name: &str) -> Tz {
name.parse::<Tz>().or_else(|_| local_timezone().parse::<Tz>()).unwrap_or(chrono_tz::Asia::Taipei)
}
fn weekday_code(w: Weekday) -> &'static str {
WEEKDAYS[w.num_days_from_monday() as usize]
}
fn weekday_index(code: &str) -> Option<usize> {
WEEKDAYS.iter().position(|w| w.eq_ignore_ascii_case(code))
}
pub fn parse_time(s: &str) -> Option<NaiveTime> {
NaiveTime::parse_from_str(s.trim(), "%H:%M").ok()
}
/// Check a schedule a model wrote, and tidy it.
pub fn validate(mut s: Schedule) -> Result<Schedule, String> {
if s.interval == 0 {
s.interval = 1;
}
if parse_time(&s.time).is_none() {
return Err(format!("時間「{}」看不懂,請用 24 小時制的 HH:MM,例如 09:00", s.time));
}
if s.timezone.trim().is_empty() || s.timezone.parse::<Tz>().is_err() {
s.timezone = local_timezone();
}
s.days_of_week = s.days_of_week.iter().filter_map(|d| weekday_index(d).map(|i| WEEKDAYS[i].to_string())).collect();
s.days_of_week.sort_by_key(|d| weekday_index(d));
s.days_of_week.dedup();
if s.frequency == Frequency::Minutely && s.interval < MIN_MINUTES {
return Err(format!("每 N 分鐘最少 {MIN_MINUTES} 分鐘"));
}
// Keep the "next run" maths (which searches interval-sized steps) bounded, and absurd
// intervals out: a huge hourly interval used to spin the UI thread for minutes on create.
let cap: u32 = match s.frequency {
Frequency::Minutely => 7 * 24 * 60,
Frequency::Hourly => 31 * 24,
Frequency::Daily => 366,
Frequency::Weekly => 53,
Frequency::Monthly => 120,
Frequency::Yearly => 10,
};
if s.interval > cap {
return Err(format!("間隔太大(這種頻率最多每 {cap} 單位一次)"));
}
if s.frequency == Frequency::Yearly {
let (m, d) = (s.month.unwrap_or(1), s.month_day.unwrap_or(1));
// 2 月 31 日永遠不會來:這個排程建立即失效,當初卻毫無警告。
if chrono::NaiveDate::from_ymd_opt(2024, m, d).is_none() {
return Err(format!("每年 {m} 月 {d} 日不存在,無法排入"));
}
}
match s.frequency {
Frequency::Weekly if s.days_of_week.is_empty() => return Err("每週的例行任務要指定星期幾(daysOfWeek,例如 [\"MO\",\"WE\"])".into()),
Frequency::Monthly if s.month_day.is_none() && s.weekday_of_month.is_none() => s.month_day = Some(1),
Frequency::Yearly if s.month.is_none() => s.month = Some(1),
_ => {}
}
if let Some(d) = s.month_day {
if !(1..=31).contains(&d) {
return Err("每月的日期要在 1 到 31 之間".into());
}
}
Ok(s)
}
/// "每週的週一、週三 09:00" in the original's wording.
pub fn describe(s: &Schedule) -> String {
let n = s.interval.max(1);
if s.frequency == Frequency::Minutely {
return format!("每 {n} 分鐘{}", if s.once { "(僅一次)" } else { "" });
}
if s.frequency == Frequency::Hourly {
let minute = parse_time(&s.time).map(|t| chrono::Timelike::minute(&t)).unwrap_or(0);
let base = if n > 1 { format!("每 {n} 小時") } else { "每小時".into() };
return format!("{base}的 {minute:02} 分{}{}", if s.flexible { "左右" } else { "" }, if s.once { "(僅一次)" } else { "" });
}
let unit = match s.frequency {
Frequency::Minutely | Frequency::Hourly => unreachable!(),
Frequency::Daily => "天",
Frequency::Weekly => "週",
Frequency::Monthly => "個月",
Frequency::Yearly => "年",
};
let duration = format!("{n} {unit}");
let repeats = match s.frequency {
Frequency::Minutely | Frequency::Hourly => unreachable!(),
Frequency::Daily => if n > 1 { format!("每{duration}") } else { "每天".into() },
Frequency::Weekly => {
let all_work = s.days_of_week.len() == WORKWEEK.len() && WORKWEEK.iter().all(|w| s.days_of_week.iter().any(|d| d == w));
if n == 1 && all_work {
"每個工作日".into()
} else {
let names: Vec<&str> = s.days_of_week.iter().filter_map(|d| weekday_index(d)).map(|i| WEEKDAY_ZH[i]).collect();
let names = names.join("、");
if n > 1 { format!("每{duration}的{names}") } else { format!("每週的{names}") }
}
}
Frequency::Monthly => match &s.weekday_of_month {
None => {
let d = s.month_day.unwrap_or(1);
if n > 1 { format!("每{duration}的{d}日") } else { format!("每月{d}日") }
}
Some(w) => {
let week = if w.week < 0 { "最後一個".to_string() } else { format!("第{}個", w.week) };
let day = weekday_index(&w.day).map(|i| WEEKDAY_ZH_LONG[i]).unwrap_or("");
if n > 1 { format!("每{duration}的{week}{day}") } else { format!("每月的{week}{day}") }
}
},
Frequency::Yearly => {
let date = format!("{}月{}日", s.month.unwrap_or(1), s.month_day.unwrap_or(1));
if n > 1 { format!("每{duration}的{date}") } else { format!("每年{date}") }
}
};
let sentence = format!("{}{repeats} {}{}", if s.once { "僅一次:" } else { "" }, s.time, if s.flexible { "左右" } else { "" });
if s.timezone == local_timezone() { sentence } else { format!("{sentence}({})", s.timezone) }
}
fn months_between(a: NaiveDate, b: NaiveDate) -> i64 {
(b.year() as i64 - a.year() as i64) * 12 + b.month() as i64 - a.month() as i64
}
fn nth_weekday_matches(d: NaiveDate, w: &WeekdayOfMonth) -> bool {
let Some(i) = weekday_index(&w.day) else { return false };
if d.weekday().num_days_from_monday() as usize != i {
return false;
}
if w.week < 0 {
(d + Duration::days(7)).month() != d.month()
} else {
((d.day() - 1) / 7 + 1) as i32 == w.week
}
}
fn day_matches(s: &Schedule, anchor: NaiveDate, d: NaiveDate) -> bool {
let n = s.interval.max(1) as i64;
match s.frequency {
Frequency::Minutely | Frequency::Hourly => true,
Frequency::Daily => (d - anchor).num_days().rem_euclid(n) == 0,
Frequency::Weekly => {
let week0 = anchor - Duration::days(anchor.weekday().num_days_from_monday() as i64);
let weeks = (d - week0).num_days().div_euclid(7);
weeks.rem_euclid(n) == 0 && s.days_of_week.iter().any(|w| w == weekday_code(d.weekday()))
}
Frequency::Monthly => {
months_between(anchor, d).rem_euclid(n) == 0
&& match &s.weekday_of_month {
Some(w) => nth_weekday_matches(d, w),
// A day past the month's end runs on its last day.
None => {
let want = s.month_day.unwrap_or(1);
let last = (d + Duration::days(1)).month() != d.month();
d.day() == want || (last && d.day() < want)
}
}
}
Frequency::Yearly => {
(d.year() - anchor.year()) as i64 % n == 0 && d.month() == s.month.unwrap_or(1) && d.day() == s.month_day.unwrap_or(1)
}
}
}
/// The first run strictly after `after`, counting intervals from `created`. A flexible time moves
/// by a steady amount within ±FLEX_MINUTES; a one-time schedule has no run after its first.
pub fn next_run(s: &Schedule, created: i64, after: i64) -> Option<i64> {
if s.once {
let first = exact_next(s, created, created - 1)?;
// A one-time run is never flexed: flexing its only moment into the past made the task
// born already-late and it died silently (next_run = None).
return (first > after).then_some(first);
}
// Look a little earlier so a time pulled forward by "左右" isn't skipped.
let pad = if s.flexible { FLEX_MINUTES * 60 } else { 0 };
let mut from = after - pad;
for _ in 0..4 {
let t = exact_next(s, created, from)?;
let f = flex(s, created, t);
if f > after {
return Some(f);
}
from = t;
}
None
}
fn flex(s: &Schedule, created: i64, t: i64) -> i64 {
if !s.flexible {
return t;
}
// A steady shift per run (same routine + same slot → same moment).
let h = (created as u64 ^ (t as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15)).wrapping_mul(0xBF58_476D_1CE4_E5B9) >> 33;
t + (h % (2 * FLEX_MINUTES as u64 * 60 + 1)) as i64 - FLEX_MINUTES * 60
}
fn exact_next(s: &Schedule, created: i64, after: i64) -> Option<i64> {
let n = s.interval.max(1) as i64;
if s.frequency == Frequency::Minutely {
let step = n * 60;
let k = ((after - created).div_euclid(step) + 1).max(1);
return Some(created + k * step);
}
if s.frequency == Frequency::Hourly {
let minute = parse_time(&s.time).map(|t| chrono::Timelike::minute(&t) as i64).unwrap_or(0);
安全、修正: 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
// Count hours in the schedule's own local wall clock (using each candidate hour's own
// UTC offset rather than `created`'s fixed offset, so +05:30/+05:45 AND DST transitions
// stay aligned to the local clock).
let tz = tz_of(&s.timezone);
安全、修正: 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 created_local = Utc.timestamp_opt(created, 0).single()?.with_timezone(&tz).naive_local();
let created_slot = created_local.date().and_hms_opt(chrono::Timelike::hour(&created_local), 0, 0)?;
let after_local = Utc.timestamp_opt(after, 0).single()?.with_timezone(&tz).naive_local();
let start_slot = after_local.date().and_hms_opt(chrono::Timelike::hour(&after_local), 0, 0)?;
for step in 0..(n * 3 + 4) {
let slot = start_slot + Duration::hours(step);
if (slot - created_slot).num_hours().rem_euclid(n) != 0 {
continue;
}
let local = slot + Duration::minutes(minute);
let at = match tz.from_local_datetime(&local) {
chrono::LocalResult::Single(at) => at,
chrono::LocalResult::Ambiguous(at, _) => at,
chrono::LocalResult::None => match tz.from_local_datetime(&(local + Duration::hours(1))).earliest() {
Some(at) => at,
None => continue,
},
};
let ts = at.timestamp();
if ts > after {
return Some(ts);
}
}
return None;
}
let tz = tz_of(&s.timezone);
let time = parse_time(&s.time)?;
let anchor = Utc.timestamp_opt(created, 0).single()?.with_timezone(&tz).date_naive();
let start = Utc.timestamp_opt(after, 0).single()?.with_timezone(&tz).date_naive();
for i in 0..SEARCH_DAYS {
let d = start + Duration::days(i);
if !day_matches(s, anchor, d) {
continue;
}
// Skipped or doubled clock times (summer time): a doubled time takes its first
// occurrence; a skipped one (spring-forward) runs just after the gap, not never.
let local = d.and_time(time);
let at = match tz.from_local_datetime(&local) {
chrono::LocalResult::Single(at) => at,
chrono::LocalResult::Ambiguous(at, _) => at,
chrono::LocalResult::None => match tz.from_local_datetime(&(local + Duration::hours(1))).earliest() {
Some(at) => at,
None => continue,
},
};
let ts = at.timestamp();
if ts > after {
return Some(ts);
}
}
None
}
/// "今天 09:00", "明天 09:00" or "11月5日 09:00" in the routine's time zone.
pub fn describe_when(ts: i64, timezone: &str) -> String {
let tz = tz_of(timezone);
let Some(t) = Utc.timestamp_opt(ts, 0).single().map(|t| t.with_timezone(&tz)) else { return String::new() };
let today = Utc::now().with_timezone(&tz).date_naive();
let day = match (t.date_naive() - today).num_days() {
0 => "今天".to_string(),
1 => "明天".to_string(),
_ => format!("{}月{}日", t.month(), t.day()),
};
format!("{day} {}", t.format("%H:%M"))
}
pub fn now() -> i64 {
Utc::now().timestamp()
}
#[cfg(test)]
mod tests {
#[test]
fn a_servers_utc_is_not_the_persons_zone() {
assert!(super::is_server_default_zone("Etc/UTC") && super::is_server_default_zone("") && super::is_server_default_zone("UTC"));
assert!(!super::is_server_default_zone("Asia/Taipei") && !super::is_server_default_zone("Europe/London"));
}
use super::*;
fn ts(y: i32, m: u32, d: u32, h: u32, mi: u32) -> i64 {
chrono_tz::Asia::Taipei.with_ymd_and_hms(y, m, d, h, mi, 0).unwrap().timestamp()
}
/// Drop the "(Asia/Taipei)" a computer in another timezone adds.
fn here(s: String) -> String {
s.trim_end_matches("(Asia/Taipei)").to_string()
}
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
fn routine() -> Routine {
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
Routine { id: 7, title: "貓咪海巡".into(), prompt: "找 15 篇貼文".into(), schedule: sched(Frequency::Daily), paused: false, created_at: 0, last_run: None, next_run: None, computer: String::new(), trigger: None, runs: vec![], paused_why: String::new(), target_sends: 0 }
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
#[test]
fn two_failures_in_a_row_pause_a_routine_and_say_why() {
let mut r = routine();
r.run_started(100);
assert_eq!(r.runs[0].outcome, RunOutcome::Running);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
assert!(!r.run_ended(160, RunOutcome::Failed, "對話太長了", &crate::evidence::Tally { steps: 12, failed: 3, sent: 0, sends: vec![] }));
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
assert_eq!(r.runs[0], RoutineRun { started: 100, ended: 160, outcome: RunOutcome::Failed, note: "對話太長了".into(), steps: 12, failed_steps: 3, sent: 0, sends: vec![], by_hand: false });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
// A success in between: the count starts again.
r.run_started(200);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
r.run_ended(260, RunOutcome::Succeeded, "送出 15 則", &crate::evidence::Tally { steps: 80, failed: 2, sent: 0, sends: vec![] });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
r.run_started(300);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
assert!(!r.run_ended(360, RunOutcome::Failed, "找不到回覆框", &crate::evidence::Tally { steps: 5, failed: 5, sent: 0, sends: vec![] }));
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
// The person stopping it, or AnyBot closing, isn't the routine failing.
r.run_started(400);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
r.run_ended(460, RunOutcome::Stopped, "被停止", &crate::evidence::Tally { steps: 2, failed: 0, sent: 0, sends: vec![] });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
assert!(!r.paused);
r.run_started(500);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
assert!(!r.run_ended(560, RunOutcome::Failed, "找不到回覆框", &crate::evidence::Tally { steps: 5, failed: 5, sent: 0, sends: vec![] }) && !r.paused, "a stop came between");
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
r.run_started(600);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
assert!(r.run_ended(660, RunOutcome::Failed, "登入過期", &crate::evidence::Tally { steps: 3, failed: 3, sent: 0, sends: vec![] }));
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
assert!(r.paused && r.paused_why.contains("連續 2 次失敗") && r.paused_why.contains("登入過期"), "{}", r.paused_why);
// Already paused: no second notice.
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
assert!(!r.run_ended(700, RunOutcome::Failed, "x", &crate::evidence::Tally { steps: 0, failed: 0, sent: 0, sends: vec![] }));
}
#[test]
fn a_run_short_of_its_completion_condition_failed_whatever_it_says() {
let mut r = Routine { target_sends: 5, ..routine() };
let sends = |n: u32| crate::evidence::Tally { steps: 40, failed: 0, sent: n, sends: (0..n).map(|i| format!("回覆 https://www.threads.com/@a/post/X{i} → https://www.threads.com/@me/post/Y{i}")).collect() };
r.run_started(100);
r.run_ended(160, RunOutcome::Succeeded, "已完成 5 則回覆", &sends(3));
let run = &r.runs[0];
assert_eq!(run.outcome, RunOutcome::Failed);
assert_eq!(run.note, "只送出 3/5 則(系統計數):已完成 5 則回覆");
assert_eq!(run.sends.len(), 3, "the evidence is kept");
r.run_started(200);
r.run_ended(260, RunOutcome::Succeeded, "好了", &sends(5));
assert_eq!(r.runs[1].outcome, RunOutcome::Succeeded);
// No condition: what the turn said.
let mut free = routine();
free.run_started(100);
free.run_ended(160, RunOutcome::Succeeded, "好了", &sends(0));
assert_eq!(free.runs[0].outcome, RunOutcome::Succeeded);
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
#[test]
fn runs_are_kept_twenty_at_most_and_a_cut_off_one_is_interrupted() {
let mut r = routine();
for i in 0..25 {
r.run_started(i * 100);
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
r.run_ended(i * 100 + 10, RunOutcome::Succeeded, "", &crate::evidence::Tally { steps: 1, failed: 0, sent: 0, sends: vec![] });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
}
assert_eq!(r.runs.len(), RUNS_KEPT);
assert_eq!(r.runs[0].started, 500, "the oldest went");
r.run_started(9_000);
r.mark_interrupted();
assert_eq!(r.runs.last().unwrap().outcome, RunOutcome::Interrupted);
assert_eq!(r.last_trouble().unwrap().outcome, RunOutcome::Interrupted);
// A run that ends with no start on record is still kept.
let mut fresh = routine();
feat: 發布關卡——已送帳本、發布前檢查、送出後讀頁面留證據、例行任務完成條件、重播可填空格 1. 已送帳本(publish.rs):Bot 用 AnyBot 瀏覽器送出前,系統先讀頁面,看是哪個帳號、回哪一篇(回覆對話框或文章裡的貼文網址、或頁面本身);同一帳號回過同一篇就擋下(記 60 天),頁面看不出回哪篇時只擋 24 小時內同頁同字。搜尋框按 Enter 不算送出。瀏覽器新增 sent 動作,直接從帳本列出帳號回過誰,不必每輪讀完網站的回覆頁 2. 發布前檢查:送出前請另一家供應商的快速模型照基本規則(簡體字、AI 腔、不該公開的內容)、這一輪讀過的技能與自訂規則檢查,沒過就不送並說原因;固定不變的放在系統提示最前面方便快取,同一段字一輪只問一次;設定可關、可加規則 3. 送出後的證據:系統重讀頁面,確認文字出現、輸入框清空,抓出留言自己的網址;寫進 Message.sent(頁面文字偽造不了),送出計數、例行任務紀錄、/goal 評審、手機頁面都以它為準;框裡還留著字就記為沒有送出 4. 完成條件:例行任務可設 target_sends,系統自己數:到數就不准再送,結束時不到算失敗,連續兩輪(50 步)沒有新的送出就停下;喚醒訊息與進展檢查都說明目前計數 5. 重播空格:自動學技能時把每次不同的內容(留言、貼文網址)存成 {{名稱}},replay_skill 用 values 填這次的內容,缺哪格就說哪格 6. 間隔從真正送出那一刻算起;送出後確認最多等 8 秒,框清空 4 秒仍沒看到就先記「還沒確認」 Mac 480 個測試通過;送出前後讀頁面在 Brave、Firefox 實機測試通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:48:13 +00:00
fresh.run_ended(50, RunOutcome::Succeeded, "好了", &crate::evidence::Tally { steps: 4, failed: 0, sent: 0, sends: vec![] });
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
assert_eq!(fresh.runs.len(), 1);
assert!(fresh.last_trouble().is_none());
}
#[test]
fn a_turn_tells_how_its_routine_run_went() {
use crate::model::{Message, Role, ToolCall, ToolStatus, TurnOutcome};
let call = |id: &str, st: ToolStatus| ToolCall { id: id.into(), name: "browser_click".into(), args: "{}".into(), status: st };
let wake = Message { wake: true, routine: 7, ..Message::user("[例行任務]「貓咪海巡」時間到了") };
let mut msgs = vec![Message::user("昨天的事"), Message::assistant("好", ""), wake];
msgs.push(Message { tool_calls: vec![call("a", ToolStatus::Done), call("b", ToolStatus::Failed)], ..Message::assistant("", "") });
msgs.push(Message { steer: true, ..Message::user("順便看一下私訊") });
msgs.push(Message { tool_calls: vec![call("c", ToolStatus::Denied)], ..Message::assistant("", "") });
msgs.push(Message::assistant("## 回報\n\n送出 12 則,跳過 3 則。\n細節…", ""));
let got = turn_result(&msgs, TurnOutcome::Success).unwrap();
assert_eq!((got.routine, got.outcome, got.note.as_str(), got.tally.steps, got.tally.failed), (7, RunOutcome::Succeeded, "送出 12 則,跳過 3 則。", 3, 2));
let mut err = msgs.clone();
err.push(Message { error: true, ..Message::assistant("對話太長了,超過這個模型能讀的長度。\n(Prompt is 178553 tokens)", "") });
assert_eq!(turn_result(&err, TurnOutcome::Error).unwrap().note, "對話太長了,超過這個模型能讀的長度。");
assert_eq!(turn_result(&msgs, TurnOutcome::Cancelled).unwrap().outcome, RunOutcome::Stopped);
// The person's own turn is no routine's.
msgs.push(Message::user("謝謝"));
msgs.push(Message::assistant("不客氣", ""));
assert!(turn_result(&msgs, TurnOutcome::Success).is_none());
assert_eq!(msgs.iter().filter(|m| m.role == Role::User).count(), 4);
}
#[test]
fn a_run_reads_in_one_line() {
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
let r = RoutineRun { started: ts(2026, 11, 14, 17, 0), ended: ts(2026, 11, 14, 17, 35), outcome: RunOutcome::Failed, note: "找不到回覆框".into(), steps: 87, failed_steps: 12, sent: 0, sends: vec![], by_hand: false };
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
assert_eq!(describe_run(&r, "Asia/Taipei"), "11/14 17:00 失敗(35 分鐘,87 步,12 步沒成功):找不到回覆框");
// The system's own count of sends, beside the report's words.
let posted = RoutineRun { outcome: RunOutcome::Succeeded, note: "送出 2 則".into(), sent: 1, ..r.clone() };
assert_eq!(describe_run(&posted, "Asia/Taipei"), "11/14 17:00 完成(35 分鐘,87 步,12 步沒成功,系統記到送出 1 次):送出 2 則");
日程不再「才按完就有」:日程只放排程和事件自己跑的;按了沒步驟的工作流不再假裝「完成」;工作流問 Bot 的話不再像你自己打的;日程和工作流頁面簡化。 你說的幻覺,查到四個來源: 1. 只有觸發器的工作流(像剛新建的「未命名工作流」),一按「執行工作流」就馬上記一次「✓ 完成」——什麼都沒做,日程、執行紀錄、Bot 看到的「最近一次:完成」全是假的。現在不跑,說「這個工作流還沒有步驟,沒有執行:先在觸發器下面加一步…」(排程和事件到了也不跑);以前留下的空執行、試跑一步都不算「最近一次」。 2. 你手動按的(執行工作流、立即執行、請 Bot 跑的、試跑一步)一按就出現在日程上,看起來像排好的事。現在日程只放「定時」「觸發」自己跑的;手動的在執行紀錄。例行任務的執行多記一個 by_hand。 3. 例行任務「立即執行」跟 Bot 說「時間到了」——不是時間到,是你叫的。現在是「「名稱」現在就執行(使用者叫的,不是排定的時間):…」(電腦、手機、Bot 的 run_routine_now 都是)。 4. 工作流問 Bot 的話在聊天裡是你的泡泡、靠右,看起來像你自己打的,還整段附上上一步的結果。現在上面一行小標「工作流「名稱」第 k/n 步」、淡色泡泡,結果只顯示前三行(滑過看全文;檢查的「結果:」也是)。手機一樣。其他不是你打的(例行任務、觸發、別的 Bot)也改成淡色泡泡。 簡化: - 日程「即將執行」每個例行任務、工作流只一行(以前一個每天跑的占滿六行)。 - 日程右上的「時間以 Asia/Taipei 為準」只在時區跟這台電腦不同時才寫。 - 工作流右上拿掉「等你確認」「執行中…」(上面那條有「繼續/停止」,■ 停止 已經說了在跑)。 已驗證: cargo test 876 過(新:a_workflow_with_no_steps_does_not_run、what_was_run_by_hand_is_not_on_the_calendar、a_workflows_question_is_tagged_and_short);有兩次整套跑時各有一個不相干的測試失敗(remote 的 state_for、手機頁面綁連接埠),單獨跑和第三次整套都過,是本來就會偶爾失敗的;clippy 8 個沒變。scratch:workflow.md 聊天裡建立、修改、執行三步過,桌面截圖畫布+旁邊聊天(小標、淡色泡泡);schedule.md 四步過(今天沒有立即執行的那次、即將執行每個一行、日看法「這一天沒有排定的事」、卡片和暫停、state paused);routines.md 手機四步在新的 scratch 照貼全過(立即執行、兩次失敗暫停、送到了——假模型照「現在就執行」比對得到),state 裡立即執行的 by_hand 都是 true。 未驗證: 手機頁面上的工作流小標(手機沒有開工作流的步驟;改了 wakeTag,有測試檢查兩邊一致);你那台的真資料(要更新 App 和 nobledesktop 的大腦才看得到)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 14:03:18 +00:00
let going = RoutineRun { started: ts(2026, 11, 14, 9, 0), ended: 0, outcome: RunOutcome::Running, note: String::new(), steps: 0, failed_steps: 0, sent: 0, sends: vec![], by_hand: false };
feat: 借鏡 pstack/Grok Bot——例行任務執行紀錄、完成看證據、教訓分流、園丁報告、減少操作步驟、網站地圖 1. 例行任務執行紀錄:每次執行記開始/結束、完成/失敗/被停止/中斷、步數與失敗步數、原因,保留最近 20 次(Grok Bot 官方規格);上次失敗或中斷的原因帶進下一次;連續失敗 2 次自動暫停並說明原因;設定頁、手機詳細頁、list_routines 都看得到,沒有紀錄時說「查不到」不說「沒跑過」 2. 完成看證據:evidence.rs 從步驟算出實際成功送出幾次,寫進例行任務紀錄;/goal 評審的摘錄把 Bot 的話標成「不是證據」並附系統統計,對不上以系統為準;評審優先用另一家供應商的模型,失敗退回原本的 3. 教訓分流:自動學技能時,AnyBot 自己的工具問題寫進 tool_issues → 「待改進」清單(同一工具合併計次),不寫進技能;設定 › 更新可看可清除 4. 園丁報告(garden.rs):平日 8:44 掃過去一天的失敗、走冤枉路的執行、自動暫停與重複出現的待改進;週一 8:49 列出失敗多或太耗時的例行任務;沒事不報,可在設定關掉 5. 減少步驟:browser type 多行文字一次放進欄位(先試貼上事件、檢查沒進再用 insertText,Firefox 也行)並回報欄位內容;點進輸入框回「游標已在…」不再說「沒有變化」;元素編號在同一頁重讀時不變;wait 的 after_send 從上次送出算間隔 6. 網站地圖:學技能時同一網站的操作知識整理進「<網站> 網站地圖」(功能/怎麼到/怎麼操作/陷阱),做事的技能只寫特有規則 Mac 465、Linux 469 個測試通過;多行輸入與編號實機測試在 Brave、Firefox 通過。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:52:44 +00:00
assert_eq!(describe_run(&going, "Asia/Taipei"), "11/14 09:00 執行中");
}
fn sched(f: Frequency) -> Schedule {
Schedule { frequency: f, interval: 1, days_of_week: vec![], month_day: None, weekday_of_month: None, month: None, time: "09:00".into(), timezone: "Asia/Taipei".into(), once: false, flexible: false }
}
#[test]
fn hourly_minutes_once_and_flexible() {
let mut h = sched(Frequency::Hourly);
h.time = "00:15".into();
assert_eq!(next_run(&h, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 20)), Some(ts(2026, 11, 3, 9, 15)));
h.interval = 3;
assert_eq!(next_run(&h, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 20)), Some(ts(2026, 11, 3, 11, 15)));
assert_eq!(describe(&h), "每 3 小時的 15 分");
安全、修正: 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
// Across DST (America/New_York: EST UTC-5 in Jan, EDT UTC-4 in Jul), an hourly schedule stays aligned to wall-clock minutes and hours.
let mut ny = Schedule { interval: 2, time: "00:15".into(), timezone: "America/New_York".into(), ..sched(Frequency::Hourly) };
let jan = chrono_tz::America::New_York.with_ymd_and_hms(2026, 1, 10, 8, 0, 0).unwrap().timestamp();
let jul = chrono_tz::America::New_York.with_ymd_and_hms(2026, 7, 10, 8, 20, 0).unwrap().timestamp();
let next_jul = next_run(&ny, jan, jul).unwrap();
let ny_dt = Utc.timestamp_opt(next_jul, 0).unwrap().with_timezone(&chrono_tz::America::New_York);
assert_eq!(chrono::Timelike::minute(&ny_dt), 15);
ny.timezone = "Australia/Lord_Howe".into(); // 30-minute DST shift!
let lh_jan = chrono_tz::Australia::Lord_Howe.with_ymd_and_hms(2026, 1, 10, 8, 0, 0).unwrap().timestamp();
let lh_jul = chrono_tz::Australia::Lord_Howe.with_ymd_and_hms(2026, 7, 10, 8, 20, 0).unwrap().timestamp();
let next_lh = next_run(&ny, lh_jan, lh_jul).unwrap();
assert_eq!(chrono::Timelike::minute(&Utc.timestamp_opt(next_lh, 0).unwrap().with_timezone(&chrono_tz::Australia::Lord_Howe)), 15);
let mut m = sched(Frequency::Minutely);
m.interval = 30;
assert_eq!(next_run(&m, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 31)), Some(ts(2026, 11, 3, 9, 0)));
m.interval = 2;
assert!(validate(m).is_err());
let mut o = sched(Frequency::Daily);
o.once = true;
assert_eq!(next_run(&o, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(ts(2026, 11, 3, 9, 0)));
assert_eq!(next_run(&o, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 9, 0)), None);
let mut f = sched(Frequency::Daily);
f.flexible = true;
let t = next_run(&f, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)).unwrap();
assert!((t - ts(2026, 11, 3, 9, 0)).abs() <= FLEX_MINUTES * 60);
assert_eq!(next_run(&f, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(t));
assert!(here(describe(&f)).ends_with("09:00左右"));
let t2 = next_run(&f, ts(2026, 11, 3, 8, 0), t).unwrap();
assert!(t2 > t && (t2 - ts(2026, 11, 4, 9, 0)).abs() <= FLEX_MINUTES * 60);
}
#[test]
fn daily_and_weekly() {
let s = sched(Frequency::Daily);
// 2026-11-03 is a Tuesday.
assert_eq!(next_run(&s, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(ts(2026, 11, 3, 9, 0)));
assert_eq!(next_run(&s, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 9, 0)), Some(ts(2026, 11, 4, 9, 0)));
let mut w = sched(Frequency::Weekly);
w.days_of_week = vec!["MO".into(), "FR".into()];
assert_eq!(next_run(&w, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(ts(2026, 11, 6, 9, 0)));
w.interval = 2;
assert_eq!(next_run(&w, ts(2026, 11, 3, 8, 0), ts(2026, 11, 7, 8, 0)), Some(ts(2026, 11, 16, 9, 0)));
assert_eq!(here(describe(&w)), "每2 週的週一、週五 09:00");
w.interval = 1;
w.days_of_week = WORKWEEK.iter().map(|s| s.to_string()).collect();
assert_eq!(here(describe(&w)), "每個工作日 09:00");
}
#[test]
fn monthly_rules() {
let mut m = sched(Frequency::Monthly);
m.month_day = Some(31);
// November has 30 days: runs on the 30th.
assert_eq!(next_run(&m, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(ts(2026, 11, 30, 9, 0)));
m.month_day = None;
m.weekday_of_month = Some(WeekdayOfMonth { week: -1, day: "FR".into() });
assert_eq!(next_run(&m, ts(2026, 11, 3, 8, 0), ts(2026, 11, 3, 8, 0)), Some(ts(2026, 11, 27, 9, 0)));
assert_eq!(here(describe(&m)), "每月的最後一個星期五 09:00");
}
#[test]
fn validation() {
let mut w = sched(Frequency::Weekly);
assert!(validate(w.clone()).is_err());
w.days_of_week = vec!["fr".into(), "MO".into(), "MO".into()];
w.time = "7:30".into();
let v = validate(w).unwrap();
assert_eq!(v.days_of_week, vec!["MO", "FR"]);
let mut bad = sched(Frequency::Daily);
bad.time = "noon".into();
assert!(validate(bad).is_err());
}
}