Bot 感知得到工作流:你在畫布旁邊打的每一則都帶著「開著工作流「X」(#id)的畫布」,說明裡列出有哪些工作流,並寫明工作流只能用 workflow 做。

查 nobledesktop 上的「水哥哥」(大腦和手腳都已經是 bbf5b4b,能力全開,那一輪的工具清單裡有 workflow):
- 11:29(UTC)使用者說「我在工作流的版面了,你幫我寫」時大腦還是舊版(11:54 才更新),它真的沒有工具,就寫成頁面「海巡工作流」+例行任務,並說「我寫不進去那個畫布」。
- 更新後它照自己先前的說法,沒再看工具清單;查 anybot_guide 時讀的是 settings、chat、routines,三區都沒提工作流(log 裡它自己的檢討也這樣寫)。它也不知道使用者開著哪個畫布。

改的:
- Message 多一個 seen:你在畫布旁邊打字時,視窗把「工作流「X」(#id,N 個步驟)的畫布,就在你的聊天旁邊——看和改它用 workflow(id N)」記在那則訊息上,模型在〔送出時間〕後面讀到〔使用者送出這則時開著:…〕。螢幕電腦也帶得過去(Job::Send 的 seen → /api/sync/act 的 send → Cmd::Send 的 seen);手機、團隊成員的訊息不帶。
- 說明(system prompt):「工作流只能用 workflow 建立和修改,不要用頁面或例行任務代替;這一輪的工具清單有 workflow 就做得到,之前在這個聊天說過做不到的,以現在為準」,並列出目前的工作流(最多 12 個:#id「名稱」(N 個步驟,排程))。
- 功能地圖:routines、pages 的陷阱各加一條「要的是工作流畫布 → workflow」,workflow 寫上 Bot 知道哪個畫布開著。

已驗證: cargo test 863 過(新:a_message_says_which_canvas_is_open、the_instructions_know_the_workflows);scratch 真資料:建一個工作流、打開畫布、在旁邊的聊天打「畫布上這個你看得到嗎」,假模型收到的那則後面是〔使用者送出這則時開著:工作流「海巡」(#1,1 個步驟)的畫布,就在你的聊天旁邊——看和改它用 workflow(id 1)〕;clippy 沒有新的。layout_audit 在一次全部跑時失敗過一次、再跑兩次都過(不穩,沒找到原因)。
未驗證: 真的 grok-4.7 收到這些後會不會用 workflow——要 nobledesktop 的大腦和你的螢幕都更新到這一版。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
This commit is contained in:
王性驊 2026-11-21 20:13:50 +08:00
parent bbf5b4b147
commit 6f67439164
12 changed files with 87 additions and 13 deletions

View File

@ -39,6 +39,7 @@ Bot 把要追蹤、整理、比較的事寫成一頁,之後一直更新同一
## 陷阱
- 使用者要的「工作流」「流程」是 AnyBot 的工作流畫布(`workflow`,[workflow](workflow.md)),不是頁面:頁面上的 steps 只是一張清單,不會跑、也不會出現在畫布上。
- 只能改自己做的頁面:帶別人頁面的 id 會被擋下(請它改,或不帶 id 自己做一頁);帶一個找不到的 id 會說找不到頁面,不會另開新的。
- 同一個 Bot 用同樣的標題寫(不分大小寫、不管空白),會換掉那一頁,不是另開一頁。
- content 是整頁內容,不是要加上去的那一段:更新時要給完整的新版本。只改種類、摘要、結論這些時不帶 content,內容就不會被換掉。

View File

@ -37,6 +37,7 @@ Bot 照排程(每天、每週、每月、只一次)或某件事發生時(P
## 陷阱
- 要好幾步串起來(好幾個 Bot、中間要你確認、要檢查結果),或使用者說「工作流」「流程」「畫布」:用 `workflow` 做在工作流畫布上([workflow](workflow.md)),不是例行任務;例行任務是一個 Bot 照排程做一件事。
- 沒人在看的一輪(例行任務、事件觸發、訊息管道和團隊成員的訊息)遇到模型忙碌或連不上,最多試 8 次、每次最多等 30 秒(加減兩成,避免大家同一秒再問);有人在看的一輪照舊試 3 次就停,讓你按重試。
- 送出幾則看系統的計數和送出證據,不看 Bot 的回報:Bot 說「完成 5 則」可能只送出 3 則。
- 加這些紀錄之前跑過的,沒有執行紀錄;`list_routines` 會說「查不到」,不是「沒跑過」。

View File

@ -8,7 +8,7 @@
- `workflow-nodes` 卡片:觸發器(手動,或每天、每週…的排程,寫「下次執行」,有「立即執行」)、Bot 步驟(哪個 Bot、要它做什麼)、等你確認(問你的話)、檢查(哪個 Bot、要做到什麼才通過)、交付(結果放進哪個 Bot 的聊天)、通知你(「{結果}」換成上一步結果的第一行)。從卡片底下的點拉到另一張卡就連線;不能連回觸發器、不能繞成一圈。點卡片在右邊改設定;Delete 刪掉選到的卡片或線(觸發器刪不掉)。
- `workflow-draw` 畫和註解:畫筆、便利貼(六種顏色,下面寫誰貼的,雙擊改字)、形狀、文字;點選後右邊換顏色、改文字、刪除。只是給人看,不會執行。
- `workflow-run` 執行:照線從觸發器往下走(一張接到好幾張時,上面的先,再左邊)。Bot 步驟是那個 Bot 聊天裡的一則訊息「[工作流「名稱」第 k/n 步]…」加上上一步的結果,它這一輪最後的回答就是這一步的結果;它正忙就排在後面,等它做完手上那一輪。檢查要回「通過」才往下,否則停下並寫原因。等你確認:畫布上方一條「等你確認:…」,「繼續」/「停止」,並發通知(電腦和手機)。交付把結果放進那個 Bot 的聊天(它正在回答時,等這一輪結束才放);通知你發通知。一次只跑一個;排程到了自動跑。停止時,還排在 Bot 後面的那一步問題直接拿掉,不會停掉 Bot 手上別的事。卡片上標完成、進行中、等你確認、失敗;「執行紀錄」留最近 20 次(誰開始的、每一步的結果、為什麼停)。
- `workflow-chat` 聊出來:在聊天裡請 Bot 做工作流,它用 `workflow` 工具建立、看、改(加步驟、改內容、刪步驟、連線、貼便利貼、整理排版)、執行、停止、刪除(刪除先問你)。你正看著那個 Bot 的聊天時(只有它),畫布自動開在聊天旁邊,跳到那個工作流,它改到的卡片和便利貼亮一下;跑出畫面就自動縮放到看得到全部。Bot 做的排成一欄,插在中間時後面的往下移;你自己排過的不重排。要刪除時,允許卡片寫的就是會刪的那一個(沒指定時是畫布上開著的)。旁邊的聊天跟著側邊欄選的 Bot 換。
- `workflow-chat` 聊出來:在聊天裡請 Bot 做工作流,它用 `workflow` 工具建立、看、改(加步驟、改內容、刪步驟、連線、貼便利貼、整理排版)、執行、停止、刪除(刪除先問你)。你正看著那個 Bot 的聊天時(只有它),畫布自動開在聊天旁邊,跳到那個工作流,它改到的卡片和便利貼亮一下;跑出畫面就自動縮放到看得到全部。Bot 做的排成一欄,插在中間時後面的往下移;你自己排過的不重排。要刪除時,允許卡片寫的就是會刪的那一個(沒指定時是畫布上開著的)。旁邊的聊天跟著側邊欄選的 Bot 換。Bot 知道有哪些工作流(說明裡列著),你在畫布旁邊打的每一則都帶著「開著工作流「X」(#1)的畫布」,所以「這個」「畫布上」它知道是哪一個。
- `workflow-versions` 版本歷史:改完停手 20 秒、關掉畫布、每次執行前、Bot 每次改之前,各留一版(一樣的不重複留),最多 30 版;選單 › 版本歷史點一版就還原,還原前先留目前的樣子。
## 使用者怎麼到

View File

@ -1673,7 +1673,8 @@ impl App {
self.queue_steer(bot_id, text.trim().to_string(), attachments);
return;
}
let m = person_message(&self.state, bot_id, text.trim(), attachments, picks);
let mut m = person_message(&self.state, bot_id, text.trim(), attachments, picks);
m.seen = self.wf_seen();
if let Some(b) = self.state.bot_mut(bot_id) {
b.messages.push(m);
}
@ -8067,7 +8068,13 @@ fn system_prompt(b: &Bot, st: &State, computers: &[tools::Target], default_compu
let mut app: Vec<String> = Vec::new();
if has(b, "routines") {
app.push("- 使用者想定期或在某個時間做事(每天、每週一、每月一號、提醒我…),就用 create_routine 設成例行任務;時間照使用者的時區。查看、修改、暫停、刪除用 list_routines / update_routine / delete_routine。".into());
app.push("- 使用者要一套多步驟的流程(好幾步、好幾個 Bot、中間要他確認或要檢查結果),或說「工作流」「流程」,就用 workflow 做在畫布上:使用者在聊天旁邊看著畫布跟著你改。先 create 把步驟放好,再一次一個 edit 調整,每次用一句話說改了什麼;改別人做的先 show 看編號;要解釋或提問就貼便利貼(notes)。".into());
app.push("- 使用者要一套多步驟的流程(好幾步、好幾個 Bot、中間要他確認或要檢查結果),或說「工作流」「流程」「畫布」,就用 workflow 做在 AnyBot 的工作流畫布上:使用者在聊天旁邊看著畫布跟著你改。工作流只能用 workflow 建立和修改,不要用頁面(write_page)或例行任務代替;這一輪的工具清單有 workflow 就做得到,之前在這個聊天說過做不到的,以現在為準。先 create 把步驟放好,再一次一個 edit 調整,每次用一句話說改了什麼;改別人做的先 show 看編號;要解釋或提問就貼便利貼(notes)。".into());
// (The workflows there are, so 「我的工作流」「畫布上那個」 mean something; the person's
// message says which one is open beside the chat.)
if !st.workflows.is_empty() {
let list: Vec<String> = st.workflows.iter().take(12).map(|w| format!("#{}「{}」({} 個步驟{})", w.id, w.name, w.step_count(), w.schedule().map(|s| format!(",{}", crate::routines::describe(s))).unwrap_or_default())).collect();
app.push(format!("- 目前的工作流:{}。", list.join("、")));
}
}
if has(b, "admin") {
app.push("- 換模型或供應商、改名字、建立新 Bot:update_bot / create_bot;看有哪些 Bot:list_bots。".into());
@ -8781,6 +8788,22 @@ mod tests {
assert!(sys.contains("不要說他已經看到,以 send_file 結果後面的〔交付狀態〕為準"));
}
/// The instructions name the workflows there are and say the canvas is made with the
/// `workflow` tool — not a page or a routine, even after the chat said it couldn't.
#[test]
fn the_instructions_know_the_workflows() {
let mut st = State::demo();
let none: Vec<String> = vec![];
let sys = super::system_prompt(&st.bots[0].clone(), &st, &[], "", &tools::Roles::default(), None, &[], false, true, &none, &[]);
assert!(sys.contains("工作流只能用 workflow 建立和修改") && !sys.contains("目前的工作流"), "none yet: no list");
let mut w = crate::workflow::Workflow::new(1, "海巡", 0);
w.nodes.push(crate::workflow::Node { id: 2, kind: crate::workflow::NodeKind::Notify { text: "好了".into() }, x: 0.0, y: 190.0 });
w.connect(1, 2);
st.workflows.push(w);
let sys = super::system_prompt(&st.bots[0].clone(), &st, &[], "", &tools::Roles::default(), None, &[], false, true, &none, &[]);
assert!(sys.contains("目前的工作流:#1「海巡」(1 個步驟)。"), "{sys}");
}
/// The model's cache holds only when what was sent last turn comes back word for word: the
/// instructions don't change with the clock or the message, and each message of the person's
/// reads the same (its time and memories come from what it keeps).

View File

@ -475,6 +475,9 @@ pub(super) enum Job {
memories: Option<Vec<String>>,
#[serde(default)]
typed: bool,
/// What was open beside the chat when it was typed (a workflow's canvas), for the model.
#[serde(default, skip_serializing_if = "String::is_empty")]
seen: String,
/// Where the brain keeps the files already sent up (the first of `atts`, in order): a
/// try again sends only the rest — a big file over a slow line was sent whole every time.
#[serde(default)]
@ -604,7 +607,7 @@ fn arrived_in(msgs: &[Message], text: &str, atts: &[crate::attach::Attachment],
fn try_job(s: &crate::remote::Settings, client: &str, job: &mut Job) -> Result<Value, (bool, String)> {
match job {
Job::Edit { seq, ops } => remote::sync_try(s, "/edit", &[], json!({"ops": ops, "client": client, "seq": seq}).to_string().as_bytes(), 20),
Job::Send { bot, id, text, atts, memories, uploaded, .. } => {
Job::Send { bot, id, text, atts, memories, uploaded, seen, .. } => {
// (One file that can't go keeps the whole message here — words without their file
// would be a different message.)
for a in atts.iter().skip(uploaded.len()) {
@ -619,6 +622,9 @@ fn try_job(s: &crate::remote::Settings, client: &str, job: &mut Job) -> Result<V
if let Some(m) = memories {
body["memories"] = json!(m);
}
if !seen.is_empty() {
body["seen"] = json!(seen);
}
remote::sync_try(s, "/act", &[], body.to_string().as_bytes(), 20)
}
}
@ -2265,7 +2271,8 @@ impl App {
return true;
}
let id = act_id(&self.mir.client);
self.mirror_queue(Job::Send { bot, id, text, atts, memories, typed, uploaded: vec![] });
let seen = self.wf_seen();
self.mirror_queue(Job::Send { bot, id, text, atts, memories, typed, seen, uploaded: vec![] });
true
}
@ -2615,7 +2622,7 @@ mod tests {
let now = crate::model::now_ms();
let long_ago = now - ASK_BEFORE_AGAIN_MS - 5 * 60_000;
for (n, text) in ["到了的", "沒到的"].into_iter().enumerate() {
screen.mirror_queue(Job::Send { bot: id, id: format!("x-{n}"), text: text.into(), atts: vec![], memories: None, typed: true, uploaded: vec![] });
screen.mirror_queue(Job::Send { bot: id, id: format!("x-{n}"), text: text.into(), atts: vec![], memories: None, typed: true, seen: String::new(), uploaded: vec![] });
let mut q = screen.mir.queue.lock().unwrap();
(q.items[n].first, q.items[n].tried) = (long_ago, now - 60_000);
}
@ -2646,7 +2653,7 @@ mod tests {
#[test]
fn a_job_that_never_goes_while_the_brain_answers_is_given_up() {
let q = Mutex::new(Outq::default());
let job = Job::Send { bot: 1, id: "big".into(), text: "看這個".into(), atts: vec![], memories: None, typed: true, uploaded: vec![] };
let job = Job::Send { bot: 1, id: "big".into(), text: "看這個".into(), atts: vec![], memories: None, typed: true, seen: String::new(), uploaded: vec![] };
q.lock().unwrap().items.push(Queued { job, at: 0, tried: 0, first: 0, trying: false, check: false });
let tries = std::cell::Cell::new(0u32);
let up = std::cell::Cell::new(true);
@ -2663,7 +2670,7 @@ mod tests {
assert_eq!(tries.get(), 10 + GIVE_UP_AFTER, "the line's failures before it was out of reach don't count");
assert!(q.lock().unwrap().items.is_empty());
// Files already up aren't sent again on the next try.
let mut sent = Job::Send { bot: 1, id: "f".into(), text: String::new(), atts: vec![crate::attach::Attachment { name: "a.png".into(), path: "/nonexistent/a.png".into(), image: true, bytes: 1, ..Default::default() }], memories: None, typed: true, uploaded: vec!["/brain/a.png".into()] };
let mut sent = Job::Send { bot: 1, id: "f".into(), text: String::new(), atts: vec![crate::attach::Attachment { name: "a.png".into(), path: "/nonexistent/a.png".into(), image: true, bytes: 1, ..Default::default() }], memories: None, typed: true, seen: String::new(), uploaded: vec!["/brain/a.png".into()] };
let s = crate::remote::Settings::default();
let r = try_job(&s, "c", &mut sent);
assert!(r.is_err_and(|(_, e)| !e.contains("讀不到")), "the file here wasn't read again");

View File

@ -521,7 +521,7 @@ impl App {
_ => {}
}
}
Cmd::Send { bot, text, attachments, from, memories, member } => {
Cmd::Send { bot, text, attachments, from, memories, member, seen } => {
if self.state.bot(bot).is_none() {
return;
}
@ -585,6 +585,9 @@ impl App {
}
let mut m = super::person_message(&self.state, bot, &text, atts, if member { Some(vec![]) } else { memories });
m.untrusted_sender = member;
if !member {
m.seen = seen;
}
if let Some(b) = self.state.bot_mut(bot) {
b.messages.push(m);
}

View File

@ -273,7 +273,7 @@ impl App {
a
});
match stored {
Ok(a) => self.remote_cmd(ctx, Cmd::Send { bot, text: MEETING_ASK.into(), attachments: vec![a.path], from: String::new(), memories: None, member: false }),
Ok(a) => self.remote_cmd(ctx, Cmd::Send { bot, text: MEETING_ASK.into(), attachments: vec![a.path], from: String::new(), memories: None, member: false, seen: String::new() }),
// Said in the chat: the person may be at another screen, or the phone.
Err(e) => {
if let Some(b) = self.state.bot_mut(bot) {

View File

@ -734,4 +734,21 @@ mod tests {
app.wf_show_change(bot, 99, vec![]);
assert_eq!(app.wf.current, 1);
}
/// The person's message says which canvas is open beside the chat (the model reads it after
/// the words); with the canvas closed or the chat put away, nothing.
#[test]
fn a_message_says_which_canvas_is_open() {
let (_ctx, mut app, bot) = app_with(vec![(2, NodeKind::Step { bot: 0, prompt: "查".into() })]);
assert_eq!(app.wf_seen(), "");
app.state.selected = bot;
app.wf.open = true;
app.wf.current = 1;
let seen = app.wf_seen();
assert!(seen.starts_with("工作流「早報」(#1,1 個步驟)的畫布") && seen.contains("workflow(id 1)"), "{seen}");
let m = Message { seen: seen.clone(), at: 0, ..Message::user("幫我加一步") };
assert!(crate::memory::context_of(&m, "Asia/Taipei").contains(&format!("〔使用者送出這則時開著:{seen}〕")));
app.wf.chat_hidden = true;
assert_eq!(app.wf_seen(), "");
}
}

View File

@ -184,6 +184,15 @@ impl App {
!self.wf.chat_hidden && width >= CHAT_BESIDE_FROM && self.state.bot(self.state.selected).is_some()
}
/// What the bot is told the person has open beside its chat when they send (empty: no canvas).
pub(super) fn wf_seen(&self) -> String {
if !self.wf.open || self.wf.chat_hidden {
return String::new();
}
let Some(w) = self.state.workflows.iter().find(|w| w.id == self.wf.current) else { return String::new() };
format!("工作流「{}」(#{},{} 個步驟)的畫布,就在你的聊天旁邊——看和改它用 workflow(id {})", w.name, w.id, w.step_count(), w.id)
}
/// A bot changed this workflow from its chat: the person looking at that chat (or at the
/// canvas) sees the canvas beside it, on that workflow, with what changed lit up.
pub(super) fn wf_show_change(&mut self, bot_id: u64, wf: u64, touched: Vec<u64>) {

View File

@ -689,6 +689,12 @@ pub fn context_of(m: &crate::model::Message, timezone: &str) -> String {
s.push_str(&format!("〔送出時間:{}({wd}){}〕", t.format("%Y-%m-%d"), t.format("%H:%M")));
}
}
if !m.seen.trim().is_empty() {
if !s.is_empty() {
s.push('\n');
}
s.push_str(&format!("〔使用者送出這則時開著:{}〕", m.seen.trim()));
}
if !m.memories.is_empty() {
if !s.is_empty() {
s.push('\n');

View File

@ -97,6 +97,10 @@ pub struct Message {
/// `memories` is decided (picked by the person, or chosen once): don't choose again.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub memories_set: bool,
/// What the person had open beside the chat when they sent it (「工作流「早報」(#1)的畫布」):
/// the model reads it after the words, so 「這個」「畫布上」 mean something.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub seen: String,
/// 目標 (/goal): the goal this message works toward — the person's 「/goal …」, or AnyBot's
/// 「還沒達成」 that starts the next turn. The model reads it after the words (goal::context_line).
#[serde(default, skip_serializing_if = "String::is_empty")]

View File

@ -194,7 +194,9 @@ pub enum Cmd {
/// `from`: the account computer the person typed it on (empty: the phone, or this one).
/// `memories`: what the person picked under the composer (None: they didn't; the brain chooses).
/// `member`: sent by a team `member` (not owner/admin).
Send { bot: u64, text: String, attachments: Vec<String>, from: String, memories: Option<Vec<String>>, member: bool },
/// `seen`: what the person had open beside the chat on the computer they typed on (a
/// workflow's canvas), for the model.
Send { bot: u64, text: String, attachments: Vec<String>, from: String, memories: Option<Vec<String>>, member: bool, seen: String },
Stop { bot: u64 },
/// (`text`: the answers of a 問題卡.)
/// `call`: the key of the card it answers (on_new_approval gives each card one; the phone's
@ -963,7 +965,7 @@ pub fn handle(req: Req, via_relay: bool) -> Resp {
if !first_delivery(bot, b["id"].as_str().unwrap_or("")) {
return Resp::json(&json!({"ok": true, "again": true}));
}
Cmd::Send { bot, text, attachments, from: String::new(), memories: if role == "owner" { picks_of(&b) } else { Some(vec![]) }, member }
Cmd::Send { bot, text, attachments, from: String::new(), memories: if role == "owner" { picks_of(&b) } else { Some(vec![]) }, member, seen: String::new() }
}
"stop" => Cmd::Stop { bot },
"answer" => Cmd::Answer { bot, answer: b["answer"].as_str().unwrap_or("reject").to_string(), text: b["text"].as_str().unwrap_or("").to_string(), call: b["call"].as_str().unwrap_or("").to_string(), notice: b["from"].as_str() == Some("notice"), screen: false },
@ -1129,6 +1131,7 @@ pub fn handle(req: Req, via_relay: bool) -> Resp {
from: req.header("x-anybot-from").to_string(),
memories: picks_of(&b),
member: false,
seen: b["seen"].as_str().unwrap_or("").chars().take(300).collect(),
},
"stop" => Cmd::Stop { bot },
"answer" => Cmd::Answer { bot, answer: b["answer"].as_str().unwrap_or("reject").to_string(), text: b["text"].as_str().unwrap_or("").to_string(), call: b["call"].as_str().unwrap_or("").to_string(), notice: b["from"].as_str() == Some("notice"), screen: true },
@ -4350,7 +4353,7 @@ mod tests {
assert_eq!(handle(send, false).status, 200);
let cmds = hub().take_cmds();
assert!(cmds.iter().any(|c| matches!(c, Cmd::DeviceAdded(d) if d.name == "iPhone")));
assert!(cmds.contains(&Cmd::Send { bot: 1, text: "你好".into(), attachments: vec![], from: String::new(), memories: Some(vec![]), member: false }) || cmds.contains(&Cmd::Send { bot: 1, text: "你好".into(), attachments: vec![], from: String::new(), memories: None, member: false }));
assert!(cmds.contains(&Cmd::Send { bot: 1, text: "你好".into(), attachments: vec![], from: String::new(), memories: Some(vec![]), member: false, seen: String::new() }) || cmds.contains(&Cmd::Send { bot: 1, text: "你好".into(), attachments: vec![], from: String::new(), memories: None, member: false, seen: String::new() }));
// 「/always-approve」 typed on a direct connection is the 直接操作 switch in other words:
// refused, nothing queued (it turned 直接操作 and 一律放行 on); status and off go through,
// and so does the owner through the account.