工作流:照 OpenBot 工作流畫布的排版(它公開的程式沒有畫布,照截圖做),風格是 AnyBot 自己的。可以畫、加註解、執行,也可以在聊天裡用一般的話請 Bot 做和改——畫布開在那個 Bot 的聊天旁邊,看著它改。
- 畫布(側邊欄最上面一排的流程圖示):名稱選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除)、右上「聊天/執行紀錄/▷ 執行工作流」、拖曳縮放、工具列(選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點)、縮放列、小地圖。窄視窗時縮放列移到工具列上面,等你確認那條橫跨上方。 - 卡片:觸發器(手動/排程、下次執行、立即執行)、Bot 步驟、等你確認、檢查、交付、通知你;從卡片底下的點拉線,不能連回觸發器、不能繞圈。 - 執行(workflow_run.rs):照線走;Bot 步驟是那個 Bot 聊天裡的一則問題,最後的回答交給下一步;檢查回「通過」才繼續;等你確認發通知;一次只跑一個;排程到了自動跑;執行紀錄 20 次、版本歷史 30 版。 - 聊出來:新工具 `workflow`(appctl;list/show/create/edit/run/stop/delete,刪除先問),屬於「例行任務與工作流」能力。Bot 做的排成一欄(tidy),插在中間時後面的往下移,使用者自己排過的不重排;改到的卡片和便利貼亮 2.6 秒,跑出畫面就縮到看得到全部。聊天抽成 chat_column,放在畫布旁邊(視窗 ≥ 900),跟著側邊欄選的 Bot 換。 - 修掉的:拖曳的起點用按下的位置(之前從點拉線會搬走卡片);搜尋打開時游標進搜尋框;一個步驟問的是正忙的 Bot(就是叫它開始的那一輪)時,那一輪結束不算這一步的回答(之前整個執行馬上失敗「做完了但沒有寫結果」);「要繼续嗎」簡體字。 - 側邊欄多了工作流按鈕,所有檔案往左一格:library.md 的座標 120,30 → 76,30。 - ctl desktop-shot:手機直接連線只聽 127.0.0.1(ANYBOT_SHOT_REAL=1 的視窗以前會聽區網和 Tailscale,有密碼、截完就關)。 已驗證: cargo test 855 過(新:workflow:: 3 個——聊天裡建立排整齊、一步步改(插中間、分支、刪掉接起來、錯一個整次不留)、run/stop;app::workflow_run 的 a_bots_workflow_call_shows_beside_its_chat,拿掉修正時會失敗;layout_audit 工作流四景;theme 設計檢查——浮在畫布上的改用 kit::floating,便利貼的字用淺色主題的字色);clippy 沒有新的(bin 8)。全新 scratch 照 workflow.md 六步逐字跑過:手機聊天裡建立、修改、執行(第 1 步在 Bot 聊天裡問、檢查「通過」、停在等你確認),桌面截圖:畫布+旁邊的聊天、在旁邊的聊天打字畫布跟著亮起來並縮到看得到全部、自己貼便利貼打字、拉線、搜尋。版本數、state 的步驟和位置另外看過。 未驗證: 真的模型聽一般的話做出工作流(scratch 只能用假模型);「等你確認」的通知真的跳出來(要 AnyBot.app/手機帳號);按「繼續」之後交付、通知你那兩步在真資料上(截圖模式按了會在這台 Mac 跳通知,沒按;單元測試有走)。動到 appctl 的 needs_approval(刪工作流先問,跟刪例行任務一樣):照規定要你看過再發佈。手機還沒有畫布。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
|
|
@ -439,7 +439,8 @@ cmd_desktop_shot() {
|
||||||
local name=$1; shift
|
local name=$1; shift
|
||||||
if serve_alive; then die "--serve 開著:ANYBOT_SHOT_REAL=1 的圖要先 ctl stop(同一個資料夾)"; fi
|
if serve_alive; then die "--serve 開著:ANYBOT_SHOT_REAL=1 的圖要先 ctl stop(同一個資料夾)"; fi
|
||||||
mkdir -p "$RUN/desktop"
|
mkdir -p "$RUN/desktop"
|
||||||
"$SCRATCH_ENV" "$SCR" "$@" "$BIN" --screenshot "$RUN/desktop/$name.png" > "$RUN/desktop/$name.log" 2>&1
|
# (ANYBOT_SHOT_REAL=1 的視窗也會開手機直接連線:一樣只聽 127.0.0.1,不出現在區網和 Tailscale 上。)
|
||||||
|
"$SCRATCH_ENV" "$SCR" "ANYBOT_PHONE_BIND=127.0.0.1" "$@" "$BIN" --screenshot "$RUN/desktop/$name.png" > "$RUN/desktop/$name.log" 2>&1
|
||||||
[ -s "$RUN/desktop/$name.png" ] || die "沒有畫出圖($RUN/desktop/$name.log)"
|
[ -s "$RUN/desktop/$name.png" ] || die "沒有畫出圖($RUN/desktop/$name.log)"
|
||||||
echo "$RUN/desktop/$name.png"
|
echo "$RUN/desktop/$name.png"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
FEATURES.md
|
|
@ -1583,7 +1583,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
|
||||||
### 所有檔案(側邊欄的資料夾按鈕)
|
### 所有檔案(側邊欄的資料夾按鈕)
|
||||||
|
|
||||||
- 每個 Bot 交給你的、你傳給 Bot 的檔案,跨 Bot、跨對話放在一個視窗(照 OpenBot 檔案庫的排版)。從聊天(包括較早的對話)裡已經記下的附件來,不掃硬碟;同一個檔案只列一次,新的在前;視窗開著每 5 秒重讀。
|
- 每個 Bot 交給你的、你傳給 Bot 的檔案,跨 Bot、跨對話放在一個視窗(照 OpenBot 檔案庫的排版)。從聊天(包括較早的對話)裡已經記下的附件來,不掃硬碟;同一個檔案只列一次,新的在前;視窗開著每 5 秒重讀。
|
||||||
- 從哪裡開:側邊欄最上面一排第一個(資料夾圖示,任務按鈕左邊);左下角選單「所有檔案…」。截圖用 `ANYBOT_SHOT_VIEW=library`。
|
- 從哪裡開:側邊欄最上面一排第一個(資料夾圖示,工作流按鈕左邊);左下角選單「所有檔案…」。截圖用 `ANYBOT_SHOT_VIEW=library`。
|
||||||
- 左欄:搜尋檔名、「所有檔案」、「最近 7 天」、每個有檔案的 Bot(顏色點、數量)。上面種類分頁帶數量:全部、圖片、文件、程式碼、表格、影音、其他(沒有的不列)。右上「格子/清單」:格子是縮圖或副檔名+檔名+「Bot · 日期」,一排幾張撐滿寬度;清單是「Bot · 日期 · 大小」。視窗高度固定,切種類、看法不跳。
|
- 左欄:搜尋檔名、「所有檔案」、「最近 7 天」、每個有檔案的 Bot(顏色點、數量)。上面種類分頁帶數量:全部、圖片、文件、程式碼、表格、影音、其他(沒有的不列)。右上「格子/清單」:格子是縮圖或副檔名+檔名+「Bot · 日期」,一排幾張撐滿寬度;清單是「Bot · 日期 · 大小」。視窗高度固定,切種類、看法不跳。
|
||||||
- 檔案不在原處(刪掉或搬走):灰字、紅字「不見了」,點不開。其他點一下用 AnyBot 的檢視器打開(Markdown、表格、圖片、PDF、影音、程式碼;用其他 App 打開、下載)。
|
- 檔案不在原處(刪掉或搬走):灰字、紅字「不見了」,點不開。其他點一下用 AnyBot 的檢視器打開(Markdown、表格、圖片、PDF、影音、程式碼;用其他 App 打開、下載)。
|
||||||
- 螢幕電腦看的是從大腦抓過來的副本。手機還沒有(只有每個對話的「資料庫」)。功能地圖新的一區 library.md。
|
- 螢幕電腦看的是從大腦抓過來的副本。手機還沒有(只有每個對話的「資料庫」)。功能地圖新的一區 library.md。
|
||||||
|
|
@ -1931,6 +1931,18 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
|
||||||
- 第一次連上時只記住目前狀態,不會把以前的事件當成新的。AnyBot 開著時才會檢查。
|
- 第一次連上時只記住目前狀態,不會把以前的事件當成新的。AnyBot 開著時才會檢查。
|
||||||
- 「例行任務」視窗顯示「⚡ 觸發條件」和連線狀態(例如「已連上 GitHub,等待事件」或錯誤原因)。暫停的不會檢查。
|
- 「例行任務」視窗顯示「⚡ 觸發條件」和連線狀態(例如「已連上 GitHub,等待事件」或錯誤原因)。暫停的不會檢查。
|
||||||
|
|
||||||
|
### 工作流(側邊欄最上面一排的流程圖示)
|
||||||
|
|
||||||
|
照 OpenBot 工作流畫布的排版做的(它公開的程式裡沒有畫布,照截圖的樣子做),風格是 AnyBot 自己的;功能地圖 workflow.md。
|
||||||
|
|
||||||
|
- 一個工作流是一張畫布:觸發器(手動,或也照排程:每天、每週…,寫下次執行,有「立即執行」),接著用線連起來的卡片:Bot 步驟(哪個 Bot、要它做什麼)、等你確認、檢查(哪個 Bot、要做到什麼才通過)、交付(結果放進哪個 Bot 的聊天)、通知你(「{結果}」換成上一步結果的第一行)。從卡片底下的點拉到另一張就連線;不能連回觸發器、不能繞圈。
|
||||||
|
- 畫布:左上名稱和選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除);右上「聊天」「執行紀錄」「▷ 執行工作流/■ 停止」;拖曳空白處移動、⌘+滾輪或捏合縮放;下面工具列「選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點」;左下縮放、符合畫面、小地圖。點卡片在右邊改設定,Delete 刪掉選到的。
|
||||||
|
- 畫和註解:畫筆、便利貼(六色、寫誰貼的、雙擊改字)、形狀、文字,只給人看、不會執行。
|
||||||
|
- 執行:照線從觸發器往下(一張接到好幾張時上面的先、再左邊)。Bot 步驟是那個 Bot 聊天裡的一則「[工作流「名稱」第 k/n 步]…」加上一步的結果,它這一輪最後的回答交給下一步(它正忙就排在後面)。檢查回「通過」才往下。等你確認在畫布上方一條「繼續/停止」,並發通知。一次只跑一個,排程到了自動跑;卡片標完成、進行中、等你確認、失敗;執行紀錄留 20 次。
|
||||||
|
- 版本歷史:停手 20 秒、關畫布、每次執行前、Bot 每次改之前各留一版,最多 30 版,點一版就還原。
|
||||||
|
- 在聊天裡做:跟 Bot 用一般的話說要什麼流程(「每天早上 9 點去 Threads 找 5 則熱門育兒討論,整理好先問我,我說可以再傳給我」),Bot 用 `workflow` 工具建立、看、改(加步驟、改內容、刪步驟、連線、貼便利貼、整理排版)、執行、停止、刪除(刪除先問)。你看著那個 Bot 的聊天時,畫布自動開在聊天旁邊(視窗夠寬時),它改到的卡片和便利貼亮一下,跑出畫面就縮到看得到全部;Bot 做的排成一欄,插在中間時後面的往下移,你自己排過的不重排。旁邊的聊天跟著側邊欄選的 Bot 換。
|
||||||
|
- 手機沒有畫布:在聊天裡請 Bot 做、改、跑,它用文字說工作流的樣子;「等你確認」的通知會到手機,按「繼續」要在電腦上。螢幕電腦只能看。
|
||||||
|
|
||||||
## 26. Bot 可以直接操作 App 的功能
|
## 26. Bot 可以直接操作 App 的功能
|
||||||
|
|
||||||
你可以跟 Bot 說「每天早上 9 點幫我…」「把你換成 Claude」「切成深色模式」,它會自己操作 App。
|
你可以跟 Bot 說「每天早上 9 點幫我…」「把你換成 Claude」「切成深色模式」,它會自己操作 App。
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ Bot 讀得到的是開頭、子功能、使用者怎麼到、Bot 那一行和沒
|
||||||
|
|
||||||
### 自己會動
|
### 自己會動
|
||||||
- [routines](routines.md):排程與事件觸發、執行紀錄、完成條件、自動暫停。
|
- [routines](routines.md):排程與事件觸發、執行紀錄、完成條件、自動暫停。
|
||||||
|
- [workflow](workflow.md):工作流:畫布上的步驟(Bot 步驟、等你確認、檢查、交付、通知)、畫和便利貼、執行與紀錄、版本歷史;在聊天裡請 Bot 做和改,畫布開在聊天旁邊。
|
||||||
- [goal](goal.md):/goal:沒達成就繼續做、評審只看證據。
|
- [goal](goal.md):/goal:沒達成就繼續做、評審只看證據。
|
||||||
- [plan](plan.md):/plan:先查清楚、交計畫給你核准,核准後才動手、照步驟打勾。
|
- [plan](plan.md):/plan:先查清楚、交計畫給你核准,核准後才動手、照步驟打勾。
|
||||||
- [activity](activity.md):操作紀錄:每一輪誰發起、看了/寫了/執行了什麼、工具次數、失敗、花多久;電腦版右側「動態」、手機「稽核」。
|
- [activity](activity.md):操作紀錄:每一輪誰發起、看了/寫了/執行了什麼、工具次數、失敗、花多久;電腦版右側「動態」、手機「稽核」。
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
## 使用者怎麼到
|
## 使用者怎麼到
|
||||||
|
|
||||||
- 側邊欄最上面一排第一個(資料夾圖示,滑過寫「所有檔案」),在任務按鈕左邊。
|
- 側邊欄最上面一排第一個(資料夾圖示,滑過寫「所有檔案」),在工作流按鈕左邊。
|
||||||
- 左下角帳戶那一列的選單 ›「所有檔案…」。
|
- 左下角帳戶那一列的選單 ›「所有檔案…」。
|
||||||
- 只看這個對話的檔案:右側面板「資料庫」([deliver](deliver.md));手機在「對話詳細資訊 › 資料庫」。
|
- 只看這個對話的檔案:右側面板「資料庫」([deliver](deliver.md));手機在「對話詳細資訊 › 資料庫」。
|
||||||
|
|
||||||
|
|
@ -26,8 +26,8 @@
|
||||||
- 基本前提和「手機已登入」(README),開著 Bot 1 的聊天:`$CTL phone click '.row[data-bot="1"]'`。桌面的步驟要開視窗(`ABV_ALLOW_WINDOW=1`,先 `ctl stop`),座標照 1200×820。
|
- 基本前提和「手機已登入」(README),開著 Bot 1 的聊天:`$CTL phone click '.row[data-bot="1"]'`。桌面的步驟要開視窗(`ABV_ALLOW_WINDOW=1`,先 `ctl stop`),座標照 1200×820。
|
||||||
|
|
||||||
- **放七個檔案**(covers `library-gather`):從手機附上七個檔案送出,再刪掉其中一個存在 AnyBot 裡的那份。指令:`D=$(mktemp -d) && cp cat-1.png "$D/貓一.png" && cp cat-2.png "$D/貓二.png" && printf '# 發布計畫\n\n- 11/22 上線\n' > "$D/release-notes-v4.md" && printf '日期,用量\n11/20,3610\n' > "$D/用量.csv" && printf 'print("hello")\n' > "$D/hello.py" && printf 'x' > "$D/舊的.txt" && (cd "$D" && zip -q 封存.zip hello.py) && for f in 貓一.png 貓二.png release-notes-v4.md 用量.csv hello.py 舊的.txt 封存.zip; do $CTL phone upload '#file' "$D/$f" && $CTL phone wait-text "$f" --in '#chips' 20; done && $CTL phone send 這些檔案先放著 && $CTL phone wait-text 'FAKE-MODEL 回答:這些檔案先放著' --in '#msgs' && SCR=$(sed -n 's/^SCR=//p' target/verify-anybot/current/run.env) && rm -f "$(find "$SCR/data/attachments" -name '*舊的.txt' | head -1)" && $CTL api GET /api/bots/1 --jq '[.messages[].attachments[]?.name]'`。看到:API 列出七個檔名;舊的.txt 在 AnyBot 裡的那份刪掉了。
|
- **放七個檔案**(covers `library-gather`):從手機附上七個檔案送出,再刪掉其中一個存在 AnyBot 裡的那份。指令:`D=$(mktemp -d) && cp cat-1.png "$D/貓一.png" && cp cat-2.png "$D/貓二.png" && printf '# 發布計畫\n\n- 11/22 上線\n' > "$D/release-notes-v4.md" && printf '日期,用量\n11/20,3610\n' > "$D/用量.csv" && printf 'print("hello")\n' > "$D/hello.py" && printf 'x' > "$D/舊的.txt" && (cd "$D" && zip -q 封存.zip hello.py) && for f in 貓一.png 貓二.png release-notes-v4.md 用量.csv hello.py 舊的.txt 封存.zip; do $CTL phone upload '#file' "$D/$f" && $CTL phone wait-text "$f" --in '#chips' 20; done && $CTL phone send 這些檔案先放著 && $CTL phone wait-text 'FAKE-MODEL 回答:這些檔案先放著' --in '#msgs' && SCR=$(sed -n 's/^SCR=//p' target/verify-anybot/current/run.env) && rm -f "$(find "$SCR/data/attachments" -name '*舊的.txt' | head -1)" && $CTL api GET /api/bots/1 --jq '[.messages[].attachments[]?.name]'`。看到:API 列出七個檔名;舊的.txt 在 AnyBot 裡的那份刪掉了。
|
||||||
- **格子、分類、不見了**(covers `library-place`、`library-kinds`、`library-view`、`library-gone`):從側邊欄的資料夾按鈕打開。指令:`$CTL phone stop && $CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot library ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=520 'ANYBOT_SHOT_CLICK=120,30@440'`。看到:「所有檔案」視窗,左欄「所有檔案 7」「最近 7 天 7」、「Bot」下「驗證小幫手 7」;上面「全部 7、圖片 2、文件 2、程式碼 1、表格 1、其他 1」(沒有影音);三張一排撐滿,兩張貓是縮圖,其他寫 MD、CSV、PY、TXT、ZIP;舊的.txt 灰字、紅字「不見了(檔案已經刪掉或搬走)」。
|
- **格子、分類、不見了**(covers `library-place`、`library-kinds`、`library-view`、`library-gone`):從側邊欄的資料夾按鈕打開。指令:`$CTL phone stop && $CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot library ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=520 'ANYBOT_SHOT_CLICK=76,30@440'`。看到:「所有檔案」視窗,左欄「所有檔案 7」「最近 7 天 7」、「Bot」下「驗證小幫手 7」;上面「全部 7、圖片 2、文件 2、程式碼 1、表格 1、其他 1」(沒有影音);三張一排撐滿,兩張貓是縮圖,其他寫 MD、CSV、PY、TXT、ZIP;舊的.txt 灰字、紅字「不見了(檔案已經刪掉或搬走)」。
|
||||||
- **清單、打開**(covers `library-view`、`library-open`、`library-gone`):按「清單」,再按 release-notes-v4.md 那列。指令:`ABV_ALLOW_WINDOW=1 $CTL desktop-shot library-list ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=500 'ANYBOT_SHOT_CLICK=120,30@440;1033,127@470' && ABV_ALLOW_WINDOW=1 $CTL desktop-shot library-open ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=540 'ANYBOT_SHOT_CLICK=120,30@440;1033,127@470;450,267@500'`。看到:視窗沒有跳動;每列「名稱……驗證小幫手 · 今天 HH:MM · 31 B」,舊的.txt 右邊紅字「不見了」;release-notes-v4.md 在 AnyBot 的檢視器打開:「發布計畫」「11/22 上線」,右上「用其他 App 打開」、下載、關閉。帳戶選單的「所有檔案…」、搜尋、選某個 Bot:靠自動測試和版面檢查。
|
- **清單、打開**(covers `library-view`、`library-open`、`library-gone`):按「清單」,再按 release-notes-v4.md 那列。指令:`ABV_ALLOW_WINDOW=1 $CTL desktop-shot library-list ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=500 'ANYBOT_SHOT_CLICK=76,30@440;1033,127@470' && ABV_ALLOW_WINDOW=1 $CTL desktop-shot library-open ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=540 'ANYBOT_SHOT_CLICK=76,30@440;1033,127@470;450,267@500'`。看到:視窗沒有跳動;每列「名稱……驗證小幫手 · 今天 HH:MM · 31 B」,舊的.txt 右邊紅字「不見了」;release-notes-v4.md 在 AnyBot 的檢視器打開:「發布計畫」「11/22 上線」,右上「用其他 App 打開」、下載、關閉。帳戶選單的「所有檔案…」、搜尋、選某個 Bot:靠自動測試和版面檢查。
|
||||||
- 自動測試:`cargo test app::library_ui::`、`cargo test layout_audit::`(「所有檔案」這一景)。
|
- 自動測試:`cargo test app::library_ui::`、`cargo test layout_audit::`(「所有檔案」這一景)。
|
||||||
|
|
||||||
## 陷阱
|
## 陷阱
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
- `profile-editor` 「Bot 設定」:「Bot 資料」(「Bot 名稱」「Bot 描述」和大頭像,同一張卡);「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀平均排成兩列;10 種顏色和「自訂」同一列;按「自訂」出現一格一格的色盤——12 個色相各四種深淺加一列灰階,直接點,沒有滑桿——和「色碼」欄,打完整的 #rrggbb 才換色);「AI 供應商與模型」(見 [models](models.md));接著「電腦操作」「能力」「技能」「記憶」四張預設收起,各只有一行:名稱、目前怎麼設(例如「11 / 11 類」「會 8 / 8」「還沒有」)和 ▸,點了才展開;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot」(「?」說明:團隊成員看得到它的聊天、頁面和檔案)。
|
- `profile-editor` 「Bot 設定」:「Bot 資料」(「Bot 名稱」「Bot 描述」和大頭像,同一張卡);「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀平均排成兩列;10 種顏色和「自訂」同一列;按「自訂」出現一格一格的色盤——12 個色相各四種深淺加一列灰階,直接點,沒有滑桿——和「色碼」欄,打完整的 #rrggbb 才換色);「AI 供應商與模型」(見 [models](models.md));接著「電腦操作」「能力」「技能」「記憶」四張預設收起,各只有一行:名稱、目前怎麼設(例如「11 / 11 類」「會 8 / 8」「還沒有」)和 ▸,點了才展開;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot」(「?」說明:團隊成員看得到它的聊天、頁面和檔案)。
|
||||||
- `profile-roster` Soul 與指示只有它自己讀;描述、擅長、不找它做的事、會的技能、在哪幾台電腦做事會寫進其他 Bot 的同事名冊。
|
- `profile-roster` Soul 與指示只有它自己讀;描述、擅長、不找它做的事、會的技能、在哪幾台電腦做事會寫進其他 Bot 的同事名冊。
|
||||||
- `profile-abilities` 能力 11 類:「上網」「瀏覽器」「看螢幕與操作」「檔案與指令」「Mac App」「連接器」「電話、簡訊、X」「例行任務」「頁面」「和其他 Bot 合作」「管理 App」。沒勾的工具不提供給它,也不寫進說明。記憶、技能、問你問題、傳檔案到聊天、表情和卡片每個 Bot 都有。
|
- `profile-abilities` 能力 11 類:「上網」「瀏覽器」「看螢幕與操作」「檔案與指令」「Mac App」「連接器」「電話、簡訊、X」「例行任務與工作流」「頁面」「和其他 Bot 合作」「管理 App」。沒勾的工具不提供給它,也不寫進說明。記憶、技能、問你問題、傳檔案到聊天、表情和卡片每個 Bot 都有。
|
||||||
- `profile-self` Bot 自己讀(`my_profile`)和改(`update_my_profile`)自己的個人檔案、能力、技能、電腦、模型、頭像;改之前先跳確認卡片列出每一項,按允許才生效。
|
- `profile-self` Bot 自己讀(`my_profile`)和改(`update_my_profile`)自己的個人檔案、能力、技能、電腦、模型、頭像;改之前先跳確認卡片列出每一項,按允許才生效。
|
||||||
|
|
||||||
## 使用者怎麼到
|
## 使用者怎麼到
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
# 工作流
|
||||||
|
|
||||||
|
把好幾步串成一條流程,畫在畫布上:觸發器(手動,或也照排程)接著 Bot 步驟、等你確認、檢查、交付、通知你,每一步的結果交給下一步。可以自己在畫布上拉,也可以在聊天裡請 Bot 做、改、跑:畫布開在那個 Bot 的聊天旁邊,你看著它改。旁邊可以畫線、貼便利貼、寫字當註解(不會執行)。畫布只在電腦版。
|
||||||
|
|
||||||
|
## 子功能
|
||||||
|
|
||||||
|
- `workflow-canvas` 畫布:左上是名稱,按下去是選單(每個工作流和它的步驟數、新建工作流、版本歷史、重新命名、建立副本、刪除工作流);右上「聊天」(聊天放在旁邊或收起來)、「執行紀錄」、「▷ 執行工作流」(跑的時候變「■ 停止」)。點點底的畫布拖曳空白處移動、⌘+滾輪或捏合縮放;下面工具列「選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點」,左下「- 百分比 +|符合畫面|小地圖」。搜尋卡片和註解的字,Enter 跳到下一個。視窗窄時縮放列移到工具列上面。
|
||||||
|
- `workflow-nodes` 卡片:觸發器(手動,或每天、每週…的排程,寫「下次執行」,有「立即執行」)、Bot 步驟(哪個 Bot、要它做什麼)、等你確認(問你的話)、檢查(哪個 Bot、要做到什麼才通過)、交付(結果放進哪個 Bot 的聊天)、通知你(「{結果}」換成上一步結果的第一行)。從卡片底下的點拉到另一張卡就連線;不能連回觸發器、不能繞成一圈。點卡片在右邊改設定;Delete 刪掉選到的卡片或線(觸發器刪不掉)。
|
||||||
|
- `workflow-draw` 畫和註解:畫筆、便利貼(六種顏色,下面寫誰貼的,雙擊改字)、形狀、文字;點選後右邊換顏色、改文字、刪除。只是給人看,不會執行。
|
||||||
|
- `workflow-run` 執行:照線從觸發器往下走(一張接到好幾張時,上面的先,再左邊)。Bot 步驟是那個 Bot 聊天裡的一則訊息「[工作流「名稱」第 k/n 步]…」加上上一步的結果,它這一輪最後的回答就是這一步的結果;它正忙就排在後面,等它做完手上那一輪。檢查要回「通過」才往下,否則停下並寫原因。等你確認:畫布上方一條「等你確認:…」,「繼續」/「停止」,並發通知(電腦和手機)。交付把結果放進那個 Bot 的聊天;通知你發通知。一次只跑一個;排程到了自動跑。卡片上標完成、進行中、等你確認、失敗;「執行紀錄」留最近 20 次(誰開始的、每一步的結果、為什麼停)。
|
||||||
|
- `workflow-chat` 聊出來:在聊天裡請 Bot 做工作流,它用 `workflow` 工具建立、看、改(加步驟、改內容、刪步驟、連線、貼便利貼、整理排版)、執行、停止、刪除(刪除先問你)。你正看著那個 Bot 的聊天時,畫布自動開在聊天旁邊,跳到那個工作流,它改到的卡片和便利貼亮一下;跑出畫面就自動縮放到看得到全部。Bot 做的排成一欄,插在中間時後面的往下移;你自己排過的不重排。旁邊的聊天跟著側邊欄選的 Bot 換。
|
||||||
|
- `workflow-versions` 版本歷史:改完停手 20 秒、關掉畫布、每次執行前、Bot 每次改之前,各留一版(一樣的不重複留),最多 30 版;選單 › 版本歷史點一版就還原,還原前先留目前的樣子。
|
||||||
|
|
||||||
|
## 使用者怎麼到
|
||||||
|
|
||||||
|
- 側邊欄最上面一排第二個(流程圖示,滑過寫「工作流」),在所有檔案和任務中間;再按一次回到聊天。左上「‹ 聊天」也回到聊天。
|
||||||
|
- 在 Bot 的聊天裡說「幫我做一個…的工作流」:畫布開在聊天旁邊(視窗夠寬時;右上「聊天」收起或放回)。
|
||||||
|
- 手機沒有畫布:在聊天裡請 Bot 做、改、跑,它用文字說工作流長怎樣;「等你確認」的通知會到手機,但要在電腦上按「繼續」。
|
||||||
|
|
||||||
|
## 怎麼操作(verify-anybot)
|
||||||
|
|
||||||
|
- Bot:使用者要一套多步驟的流程(好幾步、好幾個 Bot、中間要確認或檢查),用 `workflow`:先 create 帶好 steps,之後一次一個 edit,每次用一句話說改了什麼;改不是自己剛做的先 show 看編號;解釋或提問就貼 notes。只是一件事照排程做,用 `create_routine`。
|
||||||
|
|
||||||
|
前提:
|
||||||
|
|
||||||
|
- 基本前提和「手機已登入」(README),開著 Bot 1 的聊天:`$CTL phone click '.row[data-bot="1"]'`。桌面的步驟要開視窗(`ABV_ALLOW_WINDOW=1`,先 `ctl stop`),座標照 1400×900。
|
||||||
|
|
||||||
|
- **聊天裡建立**(covers `workflow-chat`、`workflow-nodes`、`workflow-draw`):請 Bot 做一個早報工作流。指令:`$CTL phone send '幫我做早報工作流 [[call workflow {"action":"create","name":"Threads 早報","schedule":{"frequency":"daily","time":"09:00"},"steps":[{"kind":"step","prompt":"找 5 則熱門育兒討論,每則附連結"},{"kind":"check","condition":"每則都有連結"},{"kind":"approve","prompt":"要把早報傳給你嗎?"},{"kind":"notify","text":"早報好了:{結果}"}],"notes":[{"text":"週末改十點?","near":2}]}]]' && $CTL phone wait-text '已建立工作流 #1' --in '#msgs' 60 && $CTL phone shot workflow-create && $CTL state '.workflows[0] | {name, nodes: [.nodes[] | {id, t: .kind.type, x, y}], edges, notes: [.notes[] | {text, author, x, y}]}'`。看到:聊天裡「工作流」那一步完成,回答列出 #1 觸發器 → #2 … #5 和便利貼;state 裡五張卡 x 都是 0、y 每張差 190,線 1→2→3→4→5,便利貼在 #2 左邊、作者「驗證小幫手」。
|
||||||
|
- **聊天裡修改**(covers `workflow-chat`、`workflow-versions`):在「等你確認」後面插一步交付,再貼一張綠色便利貼。指令:`$CTL phone send '確認後也放到聊天 [[call workflow {"action":"edit","steps":[{"kind":"deliver","after":4}],"notes":[{"text":"交付會放進這個聊天","near":4,"color":"green"}]}]]' && $CTL phone wait-text '已修改工作流 #1' --in '#msgs' 60 && $CTL state '.workflows[0] | {order: [.edges[] | [.from, .to]], ys: [.nodes[] | [.id, .y]], versions: (.versions | length)}'`。看到:回答「新增 #7;加了 1 張便利貼」;線 4→7→5,#5 往下移到 950、#7 在 760;versions 是 1(改之前的樣子)。
|
||||||
|
- **聊天裡執行**(covers `workflow-run`、`workflow-chat`):檢查的回答指定成「通過」,請 Bot 跑一次。指令:`$CTL model-reply '步・檢查' '通過' && $CTL phone send '跑一次 [[call workflow {"action":"run"}]]' && $CTL phone wait-text '已開始執行「Threads 早報」' --in '#msgs' 60 && $CTL phone wait-text '[工作流「Threads 早報」第 1/5 步]' --in '#msgs' 60 && $CTL phone wait-text '步・檢查' --in '#msgs' 60 && $CTL wait-api /api/bots/1 '.messages[-1].text == "通過"' 60 && $CTL phone shot workflow-run`。看到:同一個聊天裡先是第 1/5 步的問題和 Bot 的回答,再是第 2/5 步・檢查和最後一則「通過」。
|
||||||
|
- **畫布在聊天旁邊**(covers `workflow-canvas`、`workflow-run`、`workflow-draw`):在電腦上打開畫布。指令:要開視窗——`$CTL phone stop && $CTL stop && $CTL state '.workflows[0].runs[-1] | {state, at, by, steps: [.steps[] | [.node, .state]]}' && ABV_ALLOW_WINDOW=1 $CTL desktop-shot workflow-beside ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_VIEW=workflow ANYBOT_SHOT_SIZE=1400x900 ANYBOT_SHOT_FRAMES=520`。看到:state 的 run 是 waiting、at 3、by「驗證小幫手」,#1–#3 done;左邊畫布「Threads 早報」,上方「等你確認:要把早報傳給你嗎? 繼續 停止」沒有蓋到卡片,觸發器、Bot 步驟、檢查標「完成」,等你確認是黃框;黃、綠便利貼在卡片左邊;右上「等你確認、執行紀錄、聊天、■ 停止」;右邊是驗證小幫手的聊天,最下面是「通過」。
|
||||||
|
- **在旁邊聊、畫布跟著變**(covers `workflow-chat`、`workflow-canvas`):在旁邊的聊天打字請它加一步。指令:要開視窗——`ABV_ALLOW_WINDOW=1 $CTL desktop-shot workflow-live ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_VIEW=workflow ANYBOT_SHOT_SIZE=1400x900 ANYBOT_SHOT_FRAMES=600 'ANYBOT_SHOT_CLICK=1180,847@525' 'ANYBOT_SHOT_TYPE=通知前先檢查格式 [[call workflow {"action":"edit","steps":[{"kind":"check","condition":"是條列清單","after":7}],"notes":[{"text":"這步是在聊天裡加的","near":7,"color":"blue"}]}]]@530' 'ANYBOT_SHOT_KEYS=Enter@540'`。看到:聊天裡「已修改工作流 #1…新增 #9」;畫布上交付下面多一張「檢查 是條列清單」、左邊一張藍色便利貼,兩個都有黃色光圈;通知你往下移,整個縮到看得到。
|
||||||
|
- **自己畫、拉線、搜尋**(covers `workflow-draw`、`workflow-nodes`、`workflow-canvas`):示範資料上貼便利貼打字、從交付底下的點拉線到通知你、搜尋「週末」。指令:要開視窗——`ABV_ALLOW_WINDOW=1 $CTL desktop-shot workflow-sticky ANYBOT_SHOT_VIEW=workflow ANYBOT_SHOT_SIZE=1400x900 ANYBOT_SHOT_FRAMES=44 'ANYBOT_SHOT_CLICK=720,860@20;450,600@26' 'ANYBOT_SHOT_TYPE=記得週末改時間@34' && ABV_ALLOW_WINDOW=1 $CTL desktop-shot workflow-link ANYBOT_SHOT_VIEW=workflow ANYBOT_SHOT_SIZE=1400x900 ANYBOT_SHOT_FRAMES=40 'ANYBOT_SHOT_DRAG=740,747>965,725@24' && ABV_ALLOW_WINDOW=1 $CTL desktop-shot workflow-search ANYBOT_SHOT_VIEW=workflow ANYBOT_SHOT_SIZE=1400x900 ANYBOT_SHOT_FRAMES=48 'ANYBOT_SHOT_CLICK=844,860@20' 'ANYBOT_SHOT_TYPE=週末@26' 'ANYBOT_SHOT_KEYS=Enter@32'`。看到:新的便利貼框著、裡面是「記得週末改時間」、作者 daniel,右邊便利貼的顏色和刪除;交付底下多一條線連到通知你(交付沒被拖走);搜尋框裡「週末」、旁邊「1/1」,畫面移到「週末改成十點」那張並選起來。版本歷史、選單、窄視窗:靠自動測試和版面檢查。
|
||||||
|
- 自動測試:`cargo test workflow`、`cargo test layout_audit::`(「工作流」四景)、`cargo test theme::`。
|
||||||
|
|
||||||
|
## 陷阱
|
||||||
|
|
||||||
|
- 沒接上觸發器的卡片不會執行;Bot 的回答會寫「沒接上觸發器的(不會執行)」。
|
||||||
|
- Bot 步驟用那個 Bot 自己的聊天:它正忙(例如就是它叫開始的那一輪),第一步排在後面,等那一輪結束才問。
|
||||||
|
- 檢查的回答要以「通過」或「不通過:原因」開頭,看不出來算失敗。
|
||||||
|
- 改正在跑的工作流:那次照開始時的步驟走,刪掉的步驟輪到時會停下來。
|
||||||
|
- 螢幕電腦只能看:工作流在大腦上改和跑。
|
||||||
|
- (驗證)有真資料的桌面截圖前 500 格左右是啟動畫面:`ANYBOT_SHOT_FRAMES` 至少 520。
|
||||||
|
- (驗證)假模型的回答不是「通過」開頭:跑到檢查之前先 `$CTL model-reply '步・檢查' '通過'`。
|
||||||
|
|
@ -176,7 +176,7 @@
|
||||||
- 動哪裡:`src/tools.rs` 的 `specs`(工具定義有鎖檔:`tool_specs_are_locked` 要刻意更新、要實機測試和你簽名)、`src/tasks.rs`。
|
- 動哪裡:`src/tools.rs` 的 `specs`(工具定義有鎖檔:`tool_specs_are_locked` 要刻意更新、要實機測試和你簽名)、`src/tasks.rs`。
|
||||||
- 做完:交接、逾時、重試、卡住四種情況各一個測試;任務頁看得到交接鏈。
|
- 做完:交接、逾時、重試、卡住四種情況各一個測試;任務頁看得到交接鏈。
|
||||||
|
|
||||||
**D4. 工作流存成資料**
|
**D4. 工作流存成資料**——11/21 做了第一步:工作流畫布(觸發器、Bot 步驟、等你確認、檢查、交付、通知你;畫筆、便利貼、形狀、文字;執行紀錄、版本歷史),存成結構(State.workflows),執行時照開始那一刻的順序走、每一步記結果;Bot 用 `workflow` 工具在聊天裡做和改,畫布開在聊天旁邊(功能地圖 workflow.md)。每一步的嘗試次數、「不確定有沒有送到」、例行任務/目標/計畫改用這個結構、手機上的畫布還沒做。
|
||||||
- 現況:例行任務(排程+觸發+**一段 prompt 文字**)、計畫(模型寫的步驟標題)、目標(第二個模型評)、追進度(檢查指令)是四個分開的東西,沒有一條存下來的流程。
|
- 現況:例行任務(排程+觸發+**一段 prompt 文字**)、計畫(模型寫的步驟標題)、目標(第二個模型評)、追進度(檢查指令)是四個分開的東西,沒有一條存下來的流程。
|
||||||
- 做什麼:流程存成結構,不靠 prompt 描述:觸發 → 計畫 → 步驟 → 允許 → 驗收 → 交付 → 通知。每次執行把當時的流程整份存下(之後改流程不影響已經在跑的)、
|
- 做什麼:流程存成結構,不靠 prompt 描述:觸發 → 計畫 → 步驟 → 允許 → 驗收 → 交付 → 通知。每次執行把當時的流程整份存下(之後改流程不影響已經在跑的)、
|
||||||
每一步記第幾次嘗試、輸入、輸出、結果;交付有「不確定有沒有送到」這個狀態(OpenBot 有);驗收步驟(OpenBot 沒有)。
|
每一步記第幾次嘗試、輸入、輸出、結果;交付有「不確定有沒有送到」這個狀態(OpenBot 有);驗收步驟(OpenBot 沒有)。
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-bell"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M10.268 21a2 2 0 0 0 3.464 0" />
|
||||||
|
<path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 468 B |
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-hand"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2" />
|
||||||
|
<path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" />
|
||||||
|
<path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" />
|
||||||
|
<path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 558 B |
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-map"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z" />
|
||||||
|
<path d="M15 5.764v15" />
|
||||||
|
<path d="M9 3.236v15" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 590 B |
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-mouse-pointer-2"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 442 B |
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-scan"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M3 7V5a2 2 0 0 1 2-2h2" />
|
||||||
|
<path d="M17 3h2a2 2 0 0 1 2 2v2" />
|
||||||
|
<path d="M21 17v2a2 2 0 0 1-2 2h-2" />
|
||||||
|
<path d="M7 21H5a2 2 0 0 1-2-2v-2" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 441 B |
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-send"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" />
|
||||||
|
<path d="m21.854 2.147-10.94 10.939" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 468 B |
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-sticky-note"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z" />
|
||||||
|
<path d="M15 3v5a1 1 0 0 0 1 1h5" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 458 B |
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-type"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<path d="M12 4v16" />
|
||||||
|
<path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" />
|
||||||
|
<path d="M9 20h6" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 385 B |
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- @license lucide-static v1.67.0 - ISC -->
|
||||||
|
<svg
|
||||||
|
class="lucide lucide-workflow"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
>
|
||||||
|
<rect width="8" height="8" x="3" y="3" rx="2" />
|
||||||
|
<path d="M7 11v4a2 2 0 0 0 2 2h4" />
|
||||||
|
<rect width="8" height="8" x="13" y="13" rx="2" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 430 B |
205
src/app.rs
|
|
@ -46,6 +46,8 @@ mod me_ui;
|
||||||
mod activity_ui;
|
mod activity_ui;
|
||||||
mod library_ui;
|
mod library_ui;
|
||||||
mod market_ui;
|
mod market_ui;
|
||||||
|
mod workflow_run;
|
||||||
|
mod workflow_ui;
|
||||||
mod settings_find;
|
mod settings_find;
|
||||||
mod memory_ui;
|
mod memory_ui;
|
||||||
mod goal_ui;
|
mod goal_ui;
|
||||||
|
|
@ -357,6 +359,8 @@ pub struct App {
|
||||||
lib: library_ui::LibraryUi,
|
lib: library_ui::LibraryUi,
|
||||||
/// 市集: connectors, skills and bot templates as cards (market_ui.rs).
|
/// 市集: connectors, skills and bot templates as cards (market_ui.rs).
|
||||||
market: market_ui::MarketUi,
|
market: market_ui::MarketUi,
|
||||||
|
/// 工作流: the canvas and the runs it drives (workflow_ui.rs, workflow_run.rs).
|
||||||
|
wf: workflow_ui::WfUi,
|
||||||
drop_last: String,
|
drop_last: String,
|
||||||
nightly_checked: Option<Instant>,
|
nightly_checked: Option<Instant>,
|
||||||
/// Files and pictures waiting to go with the next message.
|
/// Files and pictures waiting to go with the next message.
|
||||||
|
|
@ -629,6 +633,7 @@ impl App {
|
||||||
act: Default::default(),
|
act: Default::default(),
|
||||||
lib: Default::default(),
|
lib: Default::default(),
|
||||||
market: Default::default(),
|
market: Default::default(),
|
||||||
|
wf: Default::default(),
|
||||||
drop_last: String::new(),
|
drop_last: String::new(),
|
||||||
nightly_checked: None,
|
nightly_checked: None,
|
||||||
att: Default::default(),
|
att: Default::default(),
|
||||||
|
|
@ -757,6 +762,8 @@ impl App {
|
||||||
Ok("library") => app.lib.open = true,
|
Ok("library") => app.lib.open = true,
|
||||||
// 市集.
|
// 市集.
|
||||||
Ok("market") => app.market.open = true,
|
Ok("market") => app.market.open = true,
|
||||||
|
// 工作流: a sample on the canvas.
|
||||||
|
Ok("workflow") => app.wf_demo(),
|
||||||
// 在哪一台 (bottom left): signed in, a screen of 雲端大腦, another brain off. (An
|
// 在哪一台 (bottom left): signed in, a screen of 雲端大腦, another brain off. (An
|
||||||
// account server that refuses at once; the screen's copy in a temp folder.)
|
// account server that refuses at once; the screen's copy in a temp folder.)
|
||||||
Ok("whose") => {
|
Ok("whose") => {
|
||||||
|
|
@ -1405,6 +1412,8 @@ impl App {
|
||||||
Ok("library") => app.lib.open = true,
|
Ok("library") => app.lib.open = true,
|
||||||
// 市集.
|
// 市集.
|
||||||
Ok("market") => app.market.open = true,
|
Ok("market") => app.market.open = true,
|
||||||
|
// 工作流: the real ones on the canvas (the chat beside it).
|
||||||
|
Ok("workflow") => app.wf_open(),
|
||||||
Ok("computers") => {
|
Ok("computers") => {
|
||||||
app.show_settings = true;
|
app.show_settings = true;
|
||||||
app.settings_tab = SettingsTab::Computers;
|
app.settings_tab = SettingsTab::Computers;
|
||||||
|
|
@ -2367,6 +2376,8 @@ impl App {
|
||||||
/// Record how a turn ended (success / cancelled / error) and clear its live state.
|
/// Record how a turn ended (success / cancelled / error) and clear its live state.
|
||||||
fn settle(&mut self, bot_id: u64, outcome: TurnOutcome) {
|
fn settle(&mut self, bot_id: u64, outcome: TurnOutcome) {
|
||||||
self.note_routine_run(bot_id, outcome);
|
self.note_routine_run(bot_id, outcome);
|
||||||
|
// 工作流: a step this bot was working on has its result.
|
||||||
|
self.wf_turn_ended(bot_id, outcome);
|
||||||
// 問同事: the question this turn answered gets its answer; the ones it put to others are
|
// 問同事: the question this turn answered gets its answer; the ones it put to others are
|
||||||
// over (it can't wait any more).
|
// over (it can't wait any more).
|
||||||
self.ask_answered(bot_id, outcome);
|
self.ask_answered(bot_id, outcome);
|
||||||
|
|
@ -2607,6 +2618,7 @@ impl App {
|
||||||
self.last_tick = Instant::now();
|
self.last_tick = Instant::now();
|
||||||
self.tend_garden();
|
self.tend_garden();
|
||||||
self.tend_screens();
|
self.tend_screens();
|
||||||
|
self.tick_workflows(ctx);
|
||||||
self.resume_interrupted(ctx);
|
self.resume_interrupted(ctx);
|
||||||
let now = crate::routines::now();
|
let now = crate::routines::now();
|
||||||
let mut fire = vec![];
|
let mut fire = vec![];
|
||||||
|
|
@ -2676,6 +2688,11 @@ impl App {
|
||||||
self.ask_bot(ctx, bot_id, call);
|
self.ask_bot(ctx, bot_id, call);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 工作流: on the workflows, with the canvas beside the chat (workflow_run.rs).
|
||||||
|
if call.name == crate::workflow::TOOL {
|
||||||
|
self.workflow_tool(ctx, bot_id, call);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 管理連接器: answered once the connector has connected (or said why not).
|
// 管理連接器: answered once the connector has connected (or said why not).
|
||||||
if call.name == crate::mcp::MANAGE_TOOL {
|
if call.name == crate::mcp::MANAGE_TOOL {
|
||||||
self.manage_connectors(ctx, call);
|
self.manage_connectors(ctx, call);
|
||||||
|
|
@ -4067,100 +4084,119 @@ impl App {
|
||||||
|
|
||||||
fn main_pane(&mut self, root: &mut egui::Ui) {
|
fn main_pane(&mut self, root: &mut egui::Ui) {
|
||||||
let p = self.pal;
|
let p = self.pal;
|
||||||
let ctx = &root.ctx().clone();
|
// 工作流: the canvas where the chat is (workflow_ui.rs), with the chat beside it — what
|
||||||
|
// the person asks the bot there, they see change on the canvas.
|
||||||
|
if self.wf.open {
|
||||||
|
if self.wf_chat_beside(root.available_width()) {
|
||||||
|
let w = (root.available_width() * 0.36).clamp(340.0, 440.0);
|
||||||
|
egui::Panel::right("wf-chat").exact_size(w).resizable(false).frame(Frame::new().fill(p.pane)).show(root, |ui| {
|
||||||
|
let r = ui.max_rect();
|
||||||
|
ui.painter().vline(r.left(), r.y_range(), Stroke::new(1.0, p.border));
|
||||||
|
self.chat_column(ui);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
egui::CentralPanel::default().frame(Frame::new().fill(p.pane)).show(root, |ui| self.workflow_pane(ui));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(bot) = self.state.bot(self.state.selected).cloned() {
|
if let Some(bot) = self.state.bot(self.state.selected).cloned() {
|
||||||
self.bot_panel(root, &bot);
|
self.bot_panel(root, &bot);
|
||||||
}
|
}
|
||||||
egui::CentralPanel::default().frame(Frame::new().fill(p.pane)).show(root, |ui| {
|
egui::CentralPanel::default().frame(Frame::new().fill(p.pane)).show(root, |ui| self.chat_column(ui));
|
||||||
let id = self.state.selected;
|
}
|
||||||
if self.state.bots.is_empty() {
|
|
||||||
self.mirror_banner(ui);
|
/// The chat of the bot picked: its top, the messages, the input (in the middle, or beside
|
||||||
self.welcome(ui);
|
/// the 工作流 canvas).
|
||||||
return;
|
fn chat_column(&mut self, ui: &mut egui::Ui) {
|
||||||
}
|
let p = self.pal;
|
||||||
let Some(bot) = self.state.bot(id).cloned() else {
|
let ctx = &ui.ctx().clone();
|
||||||
ui.centered_and_justified(|ui| ui.label(RichText::new(t("未選取 Bot")).color(p.text3)));
|
let id = self.state.selected;
|
||||||
return;
|
if self.state.bots.is_empty() {
|
||||||
};
|
|
||||||
self.header(ui, &bot);
|
|
||||||
self.mirror_banner(ui);
|
self.mirror_banner(ui);
|
||||||
// The composer grows with a long draft: keep room for last frame's height.
|
self.welcome(ui);
|
||||||
let h_id = egui::Id::unique("composer-height");
|
return;
|
||||||
let composer_h: f32 = ui.data(|d| d.get_temp(h_id)).unwrap_or(116.0);
|
}
|
||||||
let avail = ui.available_height() - composer_h;
|
let Some(bot) = self.state.bot(id).cloned() else {
|
||||||
let w = ui.available_width();
|
ui.centered_and_justified(|ui| ui.label(RichText::new(t("未選取 Bot")).color(p.text3)));
|
||||||
let col_w = (w - 48.0).min(TRANSCRIPT_MAX_WIDTH);
|
return;
|
||||||
let pad = ((w - col_w) / 2.0).max(0.0);
|
};
|
||||||
let jumping = self.jump_bottom.is_some();
|
self.header(ui, &bot);
|
||||||
let out = egui::ScrollArea::vertical()
|
self.mirror_banner(ui);
|
||||||
.id_salt(("transcript", id))
|
// The composer grows with a long draft: keep room for last frame's height.
|
||||||
.auto_shrink([false, false])
|
let h_id = egui::Id::unique("composer-height");
|
||||||
.max_height(avail)
|
let composer_h: f32 = ui.data(|d| d.get_temp(h_id)).unwrap_or(116.0);
|
||||||
.stick_to_bottom(self.stick_bottom)
|
let avail = ui.available_height() - composer_h;
|
||||||
.show(ui, |ui| {
|
let w = ui.available_width();
|
||||||
ui.horizontal(|ui| {
|
let col_w = (w - 48.0).min(TRANSCRIPT_MAX_WIDTH);
|
||||||
ui.add_space(pad);
|
let pad = ((w - col_w) / 2.0).max(0.0);
|
||||||
ui.vertical(|ui| {
|
let jumping = self.jump_bottom.is_some();
|
||||||
ui.set_width(col_w);
|
let out = egui::ScrollArea::vertical()
|
||||||
// 訊息堆的呼吸:一则和下一则之间留足空白(天眼下的节奏:块与块
|
.id_salt(("transcript", id))
|
||||||
// 之间 14px,紧组内部才用 6~8)。
|
.auto_shrink([false, false])
|
||||||
ui.spacing_mut().item_spacing.y = if self.state.dense { 11.0 } else { 14.0 };
|
.max_height(avail)
|
||||||
ui.add_space(18.0);
|
.stick_to_bottom(self.stick_bottom)
|
||||||
if bot.messages.is_empty() {
|
.show(ui, |ui| {
|
||||||
self.empty_state(ui, &bot);
|
ui.horizontal(|ui| {
|
||||||
}
|
ui.add_space(pad);
|
||||||
let n = bot.messages.len();
|
ui.vertical(|ui| {
|
||||||
for (i, m) in bot.messages.iter().enumerate() {
|
ui.set_width(col_w);
|
||||||
let last = i + 1 == n;
|
// 訊息堆的呼吸:一则和下一则之间留足空白(天眼下的节奏:块与块
|
||||||
self.msg_index = i;
|
// 之间 14px,紧组内部才用 6~8)。
|
||||||
let top = ui.cursor().top();
|
ui.spacing_mut().item_spacing.y = if self.state.dense { 11.0 } else { 14.0 };
|
||||||
self.chat_message(ui, ctx, &bot, m, last);
|
ui.add_space(18.0);
|
||||||
// 搜尋 → 那則訊息: scroll to it and light it for a moment.
|
if bot.messages.is_empty() {
|
||||||
if let Some(g) = self.goto.filter(|g| g.is(bot.id, i, m.at)) {
|
self.empty_state(ui, &bot);
|
||||||
let rect = egui::Rect::from_min_max(egui::pos2(ui.min_rect().left() - 8.0, top - 4.0), egui::pos2(ui.min_rect().right() + 8.0, ui.cursor().top() - 4.0));
|
}
|
||||||
let age = g.since.elapsed().as_secs_f32();
|
let n = bot.messages.len();
|
||||||
if age < crate::find::GOTO_SCROLL_SECS {
|
for (i, m) in bot.messages.iter().enumerate() {
|
||||||
ui.scroll_to_rect(rect, Some(Align::Center));
|
let last = i + 1 == n;
|
||||||
}
|
self.msg_index = i;
|
||||||
let k = (1.0 - age / crate::find::GOTO_LIGHT_SECS).clamp(0.0, 1.0);
|
let top = ui.cursor().top();
|
||||||
ui.painter().rect_filled(rect, R_M, self.pal.attention.gamma_multiply(0.28 * k));
|
self.chat_message(ui, ctx, &bot, m, last);
|
||||||
if k > 0.0 {
|
// 搜尋 → 那則訊息: scroll to it and light it for a moment.
|
||||||
ui.ctx().request_repaint_after(anim_after(50));
|
if let Some(g) = self.goto.filter(|g| g.is(bot.id, i, m.at)) {
|
||||||
} else {
|
let rect = egui::Rect::from_min_max(egui::pos2(ui.min_rect().left() - 8.0, top - 4.0), egui::pos2(ui.min_rect().right() + 8.0, ui.cursor().top() - 4.0));
|
||||||
self.goto = None;
|
let age = g.since.elapsed().as_secs_f32();
|
||||||
}
|
if age < crate::find::GOTO_SCROLL_SECS {
|
||||||
|
ui.scroll_to_rect(rect, Some(Align::Center));
|
||||||
|
}
|
||||||
|
let k = (1.0 - age / crate::find::GOTO_LIGHT_SECS).clamp(0.0, 1.0);
|
||||||
|
ui.painter().rect_filled(rect, R_M, self.pal.attention.gamma_multiply(0.28 * k));
|
||||||
|
if k > 0.0 {
|
||||||
|
ui.ctx().request_repaint_after(anim_after(50));
|
||||||
|
} else {
|
||||||
|
self.goto = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.sending_bubbles(ui, &bot);
|
}
|
||||||
self.mirror_queue_bubbles(ui, &bot);
|
self.sending_bubbles(ui, &bot);
|
||||||
// (What it is doing, and a request, sit above the input: see composer.
|
self.mirror_queue_bubbles(ui, &bot);
|
||||||
// A hand-off keeps its card here, with the live screen; so does a
|
// (What it is doing, and a request, sit above the input: see composer.
|
||||||
// question — it scrolls with the chat instead of covering it.)
|
// A hand-off keeps its card here, with the live screen; so does a
|
||||||
self.approval_card(ui, ctx, &bot);
|
// question — it scrolls with the chat instead of covering it.)
|
||||||
ui.add_space(16.0);
|
self.approval_card(ui, ctx, &bot);
|
||||||
// Last in the content, so no code block's own scroll area takes it.
|
ui.add_space(16.0);
|
||||||
if jumping {
|
// Last in the content, so no code block's own scroll area takes it.
|
||||||
ui.scroll_to_cursor(Some(Align::BOTTOM));
|
if jumping {
|
||||||
}
|
ui.scroll_to_cursor(Some(Align::BOTTOM));
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let from_bottom = (out.content_size.y - out.inner_rect.height() - out.state.clamped_offset().y).max(0.0);
|
|
||||||
self.jump_bottom_button(ui, out.inner_rect, from_bottom);
|
|
||||||
let top = ui.cursor().top();
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
ui.add_space(pad);
|
|
||||||
ui.vertical(|ui| {
|
|
||||||
ui.set_width(col_w);
|
|
||||||
self.composer(ui, ctx, &bot);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
let used = ui.cursor().top() - top;
|
let from_bottom = (out.content_size.y - out.inner_rect.height() - out.state.clamped_offset().y).max(0.0);
|
||||||
if (used - composer_h).abs() > 0.5 {
|
self.jump_bottom_button(ui, out.inner_rect, from_bottom);
|
||||||
ui.data_mut(|d| d.insert_temp(h_id, used));
|
let top = ui.cursor().top();
|
||||||
ui.ctx().request_repaint();
|
ui.horizontal(|ui| {
|
||||||
}
|
ui.add_space(pad);
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.set_width(col_w);
|
||||||
|
self.composer(ui, ctx, &bot);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
let used = ui.cursor().top() - top;
|
||||||
|
if (used - composer_h).abs() > 0.5 {
|
||||||
|
ui.data_mut(|d| d.insert_temp(h_id, used));
|
||||||
|
ui.ctx().request_repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The top of the chat, like the original: no bar — the bot's name in a rounded pill in the
|
/// The top of the chat, like the original: no bar — the bot's name in a rounded pill in the
|
||||||
|
|
@ -7907,6 +7943,7 @@ fn system_prompt(b: &Bot, st: &State, computers: &[tools::Target], default_compu
|
||||||
let mut app: Vec<String> = Vec::new();
|
let mut app: Vec<String> = Vec::new();
|
||||||
if has(b, "routines") {
|
if has(b, "routines") {
|
||||||
app.push("- 使用者想定期或在某個時間做事(每天、每週一、每月一號、提醒我…),就用 create_routine 設成例行任務;時間照使用者的時區。查看、修改、暫停、刪除用 list_routines / update_routine / delete_routine。".into());
|
app.push("- 使用者想定期或在某個時間做事(每天、每週一、每月一號、提醒我…),就用 create_routine 設成例行任務;時間照使用者的時區。查看、修改、暫停、刪除用 list_routines / update_routine / delete_routine。".into());
|
||||||
|
app.push("- 使用者要一套多步驟的流程(好幾步、好幾個 Bot、中間要他確認或要檢查結果),或說「工作流」「流程」,就用 workflow 做在畫布上:使用者在聊天旁邊看著畫布跟著你改。先 create 把步驟放好,再一次一個 edit 調整,每次用一句話說改了什麼;改別人做的先 show 看編號;要解釋或提問就貼便利貼(notes)。".into());
|
||||||
}
|
}
|
||||||
if has(b, "admin") {
|
if has(b, "admin") {
|
||||||
app.push("- 換模型或供應商、改名字、建立新 Bot:update_bot / create_bot;看有哪些 Bot:list_bots。".into());
|
app.push("- 換模型或供應商、改名字、建立新 Bot:update_bot / create_bot;看有哪些 Bot:list_bots。".into());
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ fn doing(name: &str, args: &str, place: Option<&str>) -> String {
|
||||||
"ask_bot" => with("正在問另一個 Bot", s("bot")),
|
"ask_bot" => with("正在問另一個 Bot", s("bot")),
|
||||||
"teach_skill" => with("正在教技能給", s("bot")),
|
"teach_skill" => with("正在教技能給", s("bot")),
|
||||||
"list_routines" => "正在查看例行任務".into(),
|
"list_routines" => "正在查看例行任務".into(),
|
||||||
|
crate::workflow::TOOL => "正在改工作流".into(),
|
||||||
crate::tasks::TOOL => "正在查看任務".into(),
|
crate::tasks::TOOL => "正在查看任務".into(),
|
||||||
"create_routine" | "update_routine" | "delete_routine" => "正在安排例行任務".into(),
|
"create_routine" | "update_routine" | "delete_routine" => "正在安排例行任務".into(),
|
||||||
"run_routine_now" => "正在執行例行任務".into(),
|
"run_routine_now" => "正在執行例行任務".into(),
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,12 @@ pub(super) fn fold_title(ui: &mut egui::Ui, p: Palette, id: impl std::hash::Hash
|
||||||
open
|
open
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Something floating over a canvas (工作流: the toolbar, the zoom, the settings at the right,
|
||||||
|
/// the 等你確認 bar): the raised fill, a thin edge, large corners.
|
||||||
|
pub(super) fn floating<R>(ui: &mut egui::Ui, p: Palette, edge: Color32, margin: Margin, body: impl FnOnce(&mut egui::Ui) -> R) -> egui::InnerResponse<R> {
|
||||||
|
Frame::new().fill(p.elevated).stroke(Stroke::new(1.0, edge)).corner_radius(R_L).inner_margin(margin).show(ui, body)
|
||||||
|
}
|
||||||
|
|
||||||
/// The card of something waiting for you — an approval, a question, a step handed to you on a
|
/// The card of something waiting for you — an approval, a question, a step handed to you on a
|
||||||
/// computer: the one yellow (yellow means 「需要你」 everywhere), a soft tint and a thin edge.
|
/// computer: the one yellow (yellow means 「需要你」 everywhere), a soft tint and a thin edge.
|
||||||
/// One look for all three (the hand-off card used to be outlined in the accent and read as red).
|
/// One look for all three (the hand-off card used to be outlined in the accent and read as red).
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,41 @@ fn scenes() -> Vec<(&'static str, Open)> {
|
||||||
a.market.open = true;
|
a.market.open = true;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
// 工作流: the canvas waiting at its confirm; a step's side panel; the run log; a very long
|
||||||
|
// name with long words in every card.
|
||||||
|
("工作流", Box::new(|a: &mut App| a.wf_demo())),
|
||||||
|
(
|
||||||
|
"工作流 › 一個 Bot 步驟",
|
||||||
|
Box::new(|a: &mut App| {
|
||||||
|
a.wf_demo();
|
||||||
|
a.wf.selected = Some(2);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"工作流 › 執行紀錄",
|
||||||
|
Box::new(|a: &mut App| {
|
||||||
|
a.wf_demo();
|
||||||
|
a.wf.runs_open = true;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"工作流(很長的名字和內容)",
|
||||||
|
Box::new(|a: &mut App| {
|
||||||
|
a.wf_demo();
|
||||||
|
let w = &mut a.state.workflows[0];
|
||||||
|
w.name = "客戶服務部三樓每天早上九點要先看過的 Threads 育兒討論整理和週報".into();
|
||||||
|
for n in &mut w.nodes {
|
||||||
|
match &mut n.kind {
|
||||||
|
crate::workflow::NodeKind::Step { prompt, .. } => {
|
||||||
|
*prompt = "到 Threads 找今天熱門的五則育兒討論https://www.threads.net/search?q=%E8%82%B2%E5%85%92&serp_type=default,整理成清單,每則附連結和一句摘要,不要重複上週已經整理過的".into()
|
||||||
|
}
|
||||||
|
crate::workflow::NodeKind::Notify { text } => *text = "早報好了,請到聊天看完整的清單:{結果}".repeat(3),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.wf.selected = Some(4);
|
||||||
|
}),
|
||||||
|
),
|
||||||
// A screen of a brain: each page says at its top whose settings it holds (the longest
|
// A screen of a brain: each page says at its top whose settings it holds (the longest
|
||||||
// sentences are these two).
|
// sentences are these two).
|
||||||
("設定 › 一般(螢幕電腦)", screen_of_brain(SettingsTab::General)),
|
("設定 › 一般(螢幕電腦)", screen_of_brain(SettingsTab::General)),
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,14 @@ impl App {
|
||||||
}
|
}
|
||||||
// 任務: every bot's tasks and how each stands (tasks_ui.rs).
|
// 任務: every bot's tasks and how each stands (tasks_ui.rs).
|
||||||
self.tasks_button(ui);
|
self.tasks_button(ui);
|
||||||
|
// 工作流: the canvas (workflow_ui.rs); again closes it.
|
||||||
|
if pill_icon(ui, crate::icons::Icon::Workflow, p).on_hover_text(t("工作流")).clicked() {
|
||||||
|
if self.wf.open {
|
||||||
|
self.wf_close();
|
||||||
|
} else {
|
||||||
|
self.wf_open();
|
||||||
|
}
|
||||||
|
}
|
||||||
// 所有檔案: every file of every bot (library_ui.rs).
|
// 所有檔案: every file of every bot (library_ui.rs).
|
||||||
if pill_icon(ui, crate::icons::Icon::Folder, p).on_hover_text(t("所有檔案")).clicked() {
|
if pill_icon(ui, crate::icons::Icon::Folder, p).on_hover_text(t("所有檔案")).clicked() {
|
||||||
self.lib.open = true;
|
self.lib.open = true;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,528 @@
|
||||||
|
// 工作流 runs (workflow.rs has the shapes): a run goes node by node in the order fixed when it
|
||||||
|
// started. A bot step (and a 檢查) is a question in that bot's chat, as 問同事 asks one — the
|
||||||
|
// person sees it there and the bot works with its own model, tools and memories; when that
|
||||||
|
// turn ends its last words are the step's result, handed on to the next step. 等你確認 waits
|
||||||
|
// for the person (a notification says so); 交付 puts the result into a bot's chat; 通知你
|
||||||
|
// notifies. A step that fails stops the run, and says why. A scheduled trigger starts a run on
|
||||||
|
// time (checked with the routines, every second); a run that is on never starts twice.
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use crate::workflow::{NodeKind, RunState, StepState, check_message, check_passed, notify_text, step_message};
|
||||||
|
|
||||||
|
/// How long a 檢查 or a step's answer may be when kept as the step's result (the whole is in
|
||||||
|
/// the bot's chat).
|
||||||
|
const OUTPUT_KEPT: usize = crate::workflow::HANDED_ON_CHARS;
|
||||||
|
|
||||||
|
impl App {
|
||||||
|
/// Start a run of this workflow (by 「手動」 or 「定時」); false when one is on already.
|
||||||
|
pub(super) fn wf_start(&mut self, ctx: &egui::Context, wf: u64, by: &str) -> bool {
|
||||||
|
let now = crate::routines::now();
|
||||||
|
let Some(w) = self.state.workflows.iter_mut().find(|w| w.id == wf) else { return false };
|
||||||
|
if w.live_run().is_some() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// What was run is kept as a version (版本歷史 shows what each run ran).
|
||||||
|
w.keep_version(now);
|
||||||
|
w.start_run(by, now);
|
||||||
|
self.dirty = true;
|
||||||
|
self.wf_advance(ctx, wf);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stop this workflow's run (a bot working on its step is stopped too).
|
||||||
|
pub(super) fn wf_stop(&mut self, wf: u64) {
|
||||||
|
let now = crate::routines::now();
|
||||||
|
let mut busy = None;
|
||||||
|
if let Some(r) = self.state.workflows.iter_mut().find(|w| w.id == wf).and_then(|w| w.runs.iter_mut().rev().find(|r| r.live())) {
|
||||||
|
if let Some(s) = r.order.get(r.at).copied().and_then(|n| r.steps.iter_mut().find(|s| s.node == n)) {
|
||||||
|
if s.state == StepState::Running {
|
||||||
|
busy = Some(s.bot).filter(|b| *b != 0);
|
||||||
|
}
|
||||||
|
s.state = StepState::Failed;
|
||||||
|
}
|
||||||
|
r.state = RunState::Stopped;
|
||||||
|
r.ended = Some(now);
|
||||||
|
r.why = "你停止了這次執行".into();
|
||||||
|
}
|
||||||
|
if let Some(b) = busy {
|
||||||
|
if self.streams.contains_key(&b) {
|
||||||
|
self.stop(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 等你確認: the person's answer.
|
||||||
|
pub(super) fn wf_confirm(&mut self, ctx: &egui::Context, wf: u64, go: bool) {
|
||||||
|
let now = crate::routines::now();
|
||||||
|
let Some(r) = self.state.workflows.iter_mut().find(|w| w.id == wf).and_then(|w| w.runs.iter_mut().rev().find(|r| r.state == RunState::Waiting)) else { return };
|
||||||
|
let last = r.last_output();
|
||||||
|
let Some(s) = r.order.get(r.at).copied().and_then(|n| r.steps.iter_mut().find(|s| s.node == n)) else { return };
|
||||||
|
if go {
|
||||||
|
s.state = StepState::Done;
|
||||||
|
s.output = last;
|
||||||
|
r.at += 1;
|
||||||
|
r.state = RunState::Running;
|
||||||
|
} else {
|
||||||
|
s.state = StepState::Failed;
|
||||||
|
r.state = RunState::Stopped;
|
||||||
|
r.ended = Some(now);
|
||||||
|
r.why = "你在「等你確認」選了停止".into();
|
||||||
|
}
|
||||||
|
self.dirty = true;
|
||||||
|
self.wf_advance(ctx, wf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Go on with this workflow's run until a step has to wait (a bot working, the person).
|
||||||
|
pub(super) fn wf_advance(&mut self, ctx: &egui::Context, wf: u64) {
|
||||||
|
let now = crate::routines::now();
|
||||||
|
loop {
|
||||||
|
let Some(w) = self.state.workflows.iter().find(|w| w.id == wf) else { return };
|
||||||
|
let name = w.name.clone();
|
||||||
|
let Some(r) = w.runs.iter().rev().find(|r| r.state == RunState::Running) else { return };
|
||||||
|
let (run_id, k, of) = (r.id, r.at, r.order.len().saturating_sub(1));
|
||||||
|
let Some(node_id) = r.order.get(r.at).copied() else {
|
||||||
|
// Past the last step: done.
|
||||||
|
self.wf_run_mut(wf, run_id, |r| {
|
||||||
|
r.state = RunState::Done;
|
||||||
|
r.ended = Some(now);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let state = r.step_of(node_id).map(|s| s.state).unwrap_or(StepState::Waiting);
|
||||||
|
if state != StepState::Waiting {
|
||||||
|
// A step underway (a bot is on it): its end moves the run on.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let last = r.last_output();
|
||||||
|
let Some(kind) = w.node(node_id).map(|n| n.kind.clone()) else {
|
||||||
|
self.wf_fail(wf, run_id, node_id, "這一步已經被刪掉了");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
match kind {
|
||||||
|
NodeKind::Trigger { .. } => self.wf_done(wf, run_id, node_id, last),
|
||||||
|
NodeKind::Step { bot, prompt } => {
|
||||||
|
if prompt.trim().is_empty() {
|
||||||
|
self.wf_fail(wf, run_id, node_id, "這一步還沒寫要 Bot 做什麼");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let text = step_message(&name, k, of, &prompt, &last);
|
||||||
|
self.wf_ask(ctx, wf, run_id, node_id, bot, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NodeKind::Check { bot, condition } => {
|
||||||
|
if condition.trim().is_empty() {
|
||||||
|
self.wf_fail(wf, run_id, node_id, "檢查還沒寫要看什麼");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let text = check_message(&name, k, of, &condition, &last);
|
||||||
|
self.wf_ask(ctx, wf, run_id, node_id, bot, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NodeKind::Approve { prompt } => {
|
||||||
|
self.wf_run_mut(wf, run_id, |r| {
|
||||||
|
r.state = RunState::Waiting;
|
||||||
|
if let Some(s) = r.steps.iter_mut().find(|s| s.node == node_id) {
|
||||||
|
s.state = StepState::Running;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let words = if prompt.trim().is_empty() { "要繼續嗎?".to_string() } else { prompt.trim().to_string() };
|
||||||
|
let body = format!("等你確認:{words}");
|
||||||
|
if !self.headless && !self.demo {
|
||||||
|
notify::banner_for(&name, &body, true, None, None);
|
||||||
|
}
|
||||||
|
crate::remote::notify(crate::remote::Notice::Need, &name, &body, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NodeKind::Deliver { bot } => {
|
||||||
|
let selected = self.state.selected;
|
||||||
|
let Some(b) = self.state.bot_mut(bot) else {
|
||||||
|
self.wf_fail(wf, run_id, node_id, "要交付的 Bot 已經不在了");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let text = if last.trim().is_empty() { format!("工作流「{name}」跑完了(前面的步驟沒有結果)。") } else { format!("工作流「{name}」的結果:\n\n{last}") };
|
||||||
|
b.messages.push(Message { at: crate::model::now_ms(), ..Message::assistant(&text, &format!("工作流「{name}」")) });
|
||||||
|
if bot != selected {
|
||||||
|
b.unread = true;
|
||||||
|
}
|
||||||
|
self.save_now = true;
|
||||||
|
self.wf_done(wf, run_id, node_id, last);
|
||||||
|
}
|
||||||
|
NodeKind::Notify { text } => {
|
||||||
|
let words = notify_text(&text, &last);
|
||||||
|
if !self.headless && !self.demo {
|
||||||
|
notify::banner_for(&name, &words, true, None, None);
|
||||||
|
}
|
||||||
|
crate::remote::notify(crate::remote::Notice::Done, &name, &words, 0);
|
||||||
|
self.wf_done(wf, run_id, node_id, last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A question to a bot for this step; the step waits for that bot's turn to end.
|
||||||
|
fn wf_ask(&mut self, ctx: &egui::Context, wf: u64, run: u64, node: u64, bot: u64, text: String) {
|
||||||
|
if self.state.bot(bot).is_none() {
|
||||||
|
self.wf_fail(wf, run, node, "這一步選的 Bot 已經不在了");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let msg = Message { at: crate::model::now_ms(), ..Message::user(&text) };
|
||||||
|
let at = msg.at;
|
||||||
|
self.wf_run_mut(wf, run, |r| {
|
||||||
|
if let Some(s) = r.steps.iter_mut().find(|s| s.node == node) {
|
||||||
|
s.state = StepState::Running;
|
||||||
|
s.bot = bot;
|
||||||
|
s.asked_at = at;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// (A busy bot takes it when it is free: wake keeps it.)
|
||||||
|
self.wake(ctx, bot, msg);
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wf_run_mut(&mut self, wf: u64, run: u64, f: impl FnOnce(&mut crate::workflow::Run)) {
|
||||||
|
if let Some(r) = self.state.workflows.iter_mut().find(|w| w.id == wf).and_then(|w| w.runs.iter_mut().find(|r| r.id == run)) {
|
||||||
|
f(r);
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wf_done(&mut self, wf: u64, run: u64, node: u64, output: String) {
|
||||||
|
self.wf_run_mut(wf, run, |r| {
|
||||||
|
if let Some(s) = r.steps.iter_mut().find(|s| s.node == node) {
|
||||||
|
s.state = StepState::Done;
|
||||||
|
s.output = output;
|
||||||
|
}
|
||||||
|
r.at += 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wf_fail(&mut self, wf: u64, run: u64, node: u64, why: &str) {
|
||||||
|
let now = crate::routines::now();
|
||||||
|
self.wf_run_mut(wf, run, |r| {
|
||||||
|
if let Some(s) = r.steps.iter_mut().find(|s| s.node == node) {
|
||||||
|
s.state = StepState::Failed;
|
||||||
|
}
|
||||||
|
r.state = RunState::Failed;
|
||||||
|
r.ended = Some(now);
|
||||||
|
r.why = why.to_string();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A bot's turn ended: a workflow step it was working on gets its result (and the run goes
|
||||||
|
/// on at the next tick, which can start the next bot).
|
||||||
|
pub(super) fn wf_turn_ended(&mut self, bot: u64, outcome: TurnOutcome) {
|
||||||
|
let mut found: Vec<(u64, u64, u64, bool, i64)> = vec![];
|
||||||
|
for w in &self.state.workflows {
|
||||||
|
for r in w.runs.iter().filter(|r| r.state == RunState::Running) {
|
||||||
|
// (Only the turn on the step's question: asked of a bot that was busy — the bot
|
||||||
|
// that started the run, say — the question waits in line, and the turn that
|
||||||
|
// ends first isn't the answer.)
|
||||||
|
let asked = |at: i64| self.state.bot(bot).is_some_and(|b| b.messages.iter().any(|m| m.role == Role::User && m.at == at));
|
||||||
|
if let Some(s) = r.current().filter(|s| s.state == StepState::Running && s.bot == bot && asked(s.asked_at)) {
|
||||||
|
let check = matches!(w.node(s.node).map(|n| &n.kind), Some(NodeKind::Check { .. }));
|
||||||
|
found.push((w.id, r.id, s.node, check, s.asked_at));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (wf, run, node, check, asked_at) in found {
|
||||||
|
let (answer, ok) = self.wf_answer(bot, asked_at, outcome);
|
||||||
|
if !ok {
|
||||||
|
self.wf_fail(wf, run, node, &answer);
|
||||||
|
} else if check {
|
||||||
|
match check_passed(&answer) {
|
||||||
|
Ok(()) => {
|
||||||
|
// (A check hands on what it checked, not its 「通過」.)
|
||||||
|
let last = self.state.workflows.iter().find(|w| w.id == wf).and_then(|w| w.runs.iter().find(|r| r.id == run)).map(|r| r.last_output()).unwrap_or_default();
|
||||||
|
self.wf_done(wf, run, node, last);
|
||||||
|
}
|
||||||
|
Err(why) => self.wf_fail(wf, run, node, &format!("檢查沒通過:{why}")),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.wf_done(wf, run, node, answer);
|
||||||
|
}
|
||||||
|
self.wf.advance.push(wf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The bot's last words after the step's question (asked at `at`), or why there are none.
|
||||||
|
fn wf_answer(&self, bot: u64, at: i64, outcome: TurnOutcome) -> (String, bool) {
|
||||||
|
let Some(b) = self.state.bot(bot) else { return ("那個 Bot 已經不在了".into(), false) };
|
||||||
|
let from = b.messages.iter().rposition(|m| m.role == Role::User && m.at == at).map(|i| i + 1).unwrap_or(b.messages.len());
|
||||||
|
let last = b.messages[from..].iter().rev().find(|m| m.role == Role::Assistant && !m.note && !m.text.trim().is_empty());
|
||||||
|
match outcome {
|
||||||
|
TurnOutcome::Success => match last {
|
||||||
|
Some(m) => (m.text.trim().chars().take(OUTPUT_KEPT).collect(), true),
|
||||||
|
None => (format!("「{}」做完了,但沒有寫結果", b.name), false),
|
||||||
|
},
|
||||||
|
TurnOutcome::Cancelled => (format!("「{}」被停止了", b.name), false),
|
||||||
|
_ => (format!("「{}」沒有做完:{}", b.name, last.map(|m| m.text.trim().chars().take(200).collect::<String>()).unwrap_or_default()).trim().to_string(), false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The `workflow` tool: a bot makes, changes, runs or stops a workflow from its chat. The
|
||||||
|
/// change is on the brain's workflows; the canvas opens beside that bot's chat (when the
|
||||||
|
/// person is looking at it) with what changed lit up.
|
||||||
|
pub(super) fn workflow_tool(&mut self, ctx: &egui::Context, bot_id: u64, call: AppCall) {
|
||||||
|
let me = self.state.home_of(bot_id);
|
||||||
|
let v: serde_json::Value = serde_json::from_str(if call.args.trim().is_empty() { "{}" } else { &call.args }).unwrap_or(serde_json::Value::Null);
|
||||||
|
let bots: Vec<(u64, String)> = self.state.bots.iter().filter(|b| b.branch_of == 0).map(|b| (b.id, b.name.clone())).collect();
|
||||||
|
let tz = self.state.timezone.clone();
|
||||||
|
let showing = self.wf.open.then_some(self.wf.current);
|
||||||
|
let who = crate::workflow::Who { me, bots: &bots, timezone: &tz };
|
||||||
|
let (text, ok) = match crate::workflow::tool(&mut self.state.workflows, &who, &v, showing, crate::routines::now()) {
|
||||||
|
Err(e) => (e, false),
|
||||||
|
Ok(told) => {
|
||||||
|
let mut text = told.text;
|
||||||
|
let id = told.wf.unwrap_or(0);
|
||||||
|
let name = self.state.workflows.iter().find(|w| w.id == id).map(|w| w.name.clone()).unwrap_or_default();
|
||||||
|
if told.run {
|
||||||
|
let by = self.state.bot(me).map(|b| b.name.clone()).unwrap_or_else(|| "Bot".into());
|
||||||
|
text = if self.wf_start(ctx, id, &by) {
|
||||||
|
let first = self.state.workflows.iter().find(|w| w.id == id).and_then(|w| w.runs.last()).map(|r| format!("(現在:{})", crate::workflow::describe_run(r))).unwrap_or_default();
|
||||||
|
format!("已開始執行「{name}」{first}。每個 Bot 步驟會出現在那個 Bot 的聊天裡;跑完、失敗或等使用者確認時會通知他。")
|
||||||
|
} else {
|
||||||
|
format!("「{name}」已經在跑了")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if told.stop {
|
||||||
|
self.wf_stop(id);
|
||||||
|
}
|
||||||
|
if told.changed || told.run {
|
||||||
|
self.wf_show_change(bot_id, id, told.touched);
|
||||||
|
}
|
||||||
|
// Deleted: the canvas goes to another one (or back to the chat).
|
||||||
|
if !self.state.workflows.iter().any(|w| w.id == id) && self.wf.current == id {
|
||||||
|
match self.state.workflows.first().map(|w| w.id) {
|
||||||
|
Some(other) => self.wf.current = other,
|
||||||
|
None => self.wf.open = false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(text, true)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let _ = call.reply.send((text, ok));
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every second (with the routines): runs that can go on, and scheduled triggers that are due.
|
||||||
|
pub(super) fn tick_workflows(&mut self, ctx: &egui::Context) {
|
||||||
|
for wf in std::mem::take(&mut self.wf.advance) {
|
||||||
|
self.wf_advance(ctx, wf);
|
||||||
|
}
|
||||||
|
if self.mir.on {
|
||||||
|
// (A screen shows the brain's; the brain runs them.)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let now = crate::routines::now();
|
||||||
|
let mut due = vec![];
|
||||||
|
for w in self.state.workflows.iter_mut() {
|
||||||
|
let Some(s) = w.schedule().cloned() else {
|
||||||
|
w.next_run = None;
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
match w.next_run {
|
||||||
|
None => {
|
||||||
|
w.next_run = crate::routines::next_run(&s, w.created_at, now);
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
Some(t) if t <= now => {
|
||||||
|
w.next_run = crate::routines::next_run(&s, w.created_at, now);
|
||||||
|
self.dirty = true;
|
||||||
|
if w.live_run().is_none() {
|
||||||
|
due.push(w.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for wf in due {
|
||||||
|
self.wf_start(ctx, wf, "定時");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::workflow::{Node, Workflow};
|
||||||
|
|
||||||
|
fn app_with(nodes: Vec<(u64, NodeKind)>) -> (egui::Context, App, u64) {
|
||||||
|
let ctx = egui::Context::default();
|
||||||
|
let mut app = App::new(&ctx, Some(std::env::temp_dir().join("anybot-wf.png")));
|
||||||
|
// (No banners on the machine running the tests.)
|
||||||
|
app.headless = true;
|
||||||
|
let bot = app.state.bots[0].id;
|
||||||
|
// The bot is busy: what a step asks waits in line (no model is called here); the test
|
||||||
|
// plays the bot's turns.
|
||||||
|
app.streams.insert(
|
||||||
|
bot,
|
||||||
|
Live {
|
||||||
|
cancel: Arc::new(AtomicBool::new(false)),
|
||||||
|
started: Instant::now(),
|
||||||
|
last: Instant::now(),
|
||||||
|
produced: true,
|
||||||
|
status: None,
|
||||||
|
paused: false,
|
||||||
|
paused_at: None,
|
||||||
|
unattended: false,
|
||||||
|
steer: Default::default(),
|
||||||
|
direct: Arc::new(AtomicBool::new(false)),
|
||||||
|
turn_id: "t".into(),
|
||||||
|
turn: 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let mut w = Workflow::new(1, "早報", 0);
|
||||||
|
let mut prev = 1;
|
||||||
|
for (i, (id, kind)) in nodes.into_iter().enumerate() {
|
||||||
|
w.nodes.push(Node { id, kind, x: 0.0, y: 200.0 * (i as f32 + 1.0) });
|
||||||
|
assert!(w.connect(prev, id));
|
||||||
|
prev = id;
|
||||||
|
}
|
||||||
|
app.state.workflows.push(w);
|
||||||
|
(ctx, app, bot)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The bot's turn on what the workflow asked: the question goes in, the answer after it.
|
||||||
|
fn answer(app: &mut App, bot: u64, said: &str) -> String {
|
||||||
|
let i = app.waiting_wakes.iter().position(|(b, _)| *b == bot).expect("a question for the bot");
|
||||||
|
let (_, msg) = app.waiting_wakes.remove(i);
|
||||||
|
let asked = msg.text.clone();
|
||||||
|
let b = app.state.bot_mut(bot).unwrap();
|
||||||
|
b.messages.push(msg);
|
||||||
|
b.messages.push(Message::assistant(said, "m"));
|
||||||
|
app.wf_turn_ended(bot, TurnOutcome::Success);
|
||||||
|
asked
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(app: &App) -> crate::workflow::Run {
|
||||||
|
app.state.workflows[0].runs.last().cloned().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A run goes step by step: the bot is asked in its own chat, its last words are handed
|
||||||
|
/// on, a check that passes hands on what it checked, the result goes into the chat, and it
|
||||||
|
/// ends done. One run at a time.
|
||||||
|
#[test]
|
||||||
|
fn a_run_goes_step_by_step_through_the_bots_turns() {
|
||||||
|
// (Bot 0 here: the nodes are given the bot the test made just below.)
|
||||||
|
let (ctx, mut app, bot) =
|
||||||
|
app_with(vec![(2, NodeKind::Step { bot: 0, prompt: "查今天的新聞".into() }), (3, NodeKind::Check { bot: 0, condition: "至少三則".into() }), (4, NodeKind::Deliver { bot: 0 }), (5, NodeKind::Notify { text: "早報好了:{結果}".into() })]);
|
||||||
|
let app = &mut app;
|
||||||
|
for n in app.state.workflows[0].nodes.iter_mut() {
|
||||||
|
match &mut n.kind {
|
||||||
|
NodeKind::Step { bot: b, .. } | NodeKind::Check { bot: b, .. } | NodeKind::Deliver { bot: b } => *b = bot,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert!(app.wf_start(&ctx, 1, "手動"));
|
||||||
|
assert!(!app.wf_start(&ctx, 1, "手動"), "one run at a time");
|
||||||
|
let asked = answer(app, bot, "三則新聞:A、B、C");
|
||||||
|
assert!(asked.starts_with("[工作流「早報」第 1/4 步]查今天的新聞"), "{asked}");
|
||||||
|
app.tick_workflows(&ctx);
|
||||||
|
let asked = answer(app, bot, "通過");
|
||||||
|
assert!(asked.contains("至少三則") && asked.contains("三則新聞:A、B、C"), "{asked}");
|
||||||
|
app.tick_workflows(&ctx);
|
||||||
|
let r = run(app);
|
||||||
|
assert_eq!(r.state, RunState::Done, "{r:?}");
|
||||||
|
assert!(r.steps.iter().all(|s| s.state == StepState::Done), "{r:?}");
|
||||||
|
assert_eq!(r.step_of(3).map(|s| s.output.as_str()), Some("三則新聞:A、B、C"), "a check hands on what it checked");
|
||||||
|
let last = app.state.bot(bot).unwrap().messages.last().unwrap();
|
||||||
|
assert_eq!((last.text.as_str(), last.via.as_str()), ("工作流「早報」的結果:\n\n三則新聞:A、B、C", "工作流「早報」"));
|
||||||
|
// What was run is kept as a version.
|
||||||
|
assert_eq!(app.state.workflows[0].versions.len(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A check that doesn't pass stops the run and says why; a bot that fails too.
|
||||||
|
#[test]
|
||||||
|
fn a_failed_check_stops_the_run_and_says_why() {
|
||||||
|
let (ctx, mut app, bot) = app_with(vec![]);
|
||||||
|
let w = &mut app.state.workflows[0];
|
||||||
|
w.nodes.push(Node { id: 2, kind: NodeKind::Check { bot, condition: "至少三則".into() }, x: 0.0, y: 200.0 });
|
||||||
|
w.nodes.push(Node { id: 3, kind: NodeKind::Notify { text: "不該到這裡".into() }, x: 0.0, y: 400.0 });
|
||||||
|
assert!(w.connect(1, 2) && w.connect(2, 3));
|
||||||
|
app.wf_start(&ctx, 1, "手動");
|
||||||
|
answer(&mut app, bot, "不通過:只有兩則");
|
||||||
|
app.tick_workflows(&ctx);
|
||||||
|
let r = run(&app);
|
||||||
|
assert_eq!((r.state, r.why.as_str()), (RunState::Failed, "檢查沒通過:只有兩則"));
|
||||||
|
assert_eq!(r.step_of(3).map(|s| s.state), Some(StepState::Waiting), "nothing after it ran");
|
||||||
|
// Again, the bot's turn failing.
|
||||||
|
app.wf_start(&ctx, 1, "手動");
|
||||||
|
let i = app.waiting_wakes.iter().position(|(b, _)| *b == bot).unwrap();
|
||||||
|
let (_, msg) = app.waiting_wakes.remove(i);
|
||||||
|
app.state.bot_mut(bot).unwrap().messages.push(msg);
|
||||||
|
app.wf_turn_ended(bot, TurnOutcome::Error);
|
||||||
|
assert_eq!(run(&app).state, RunState::Failed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 等你確認 waits for the person: go on, or stop; 停止 stops a run that is on.
|
||||||
|
#[test]
|
||||||
|
fn a_confirm_waits_for_the_person() {
|
||||||
|
let (ctx, mut app, _) = app_with(vec![(2, NodeKind::Approve { prompt: "要發出去嗎?".into() }), (3, NodeKind::Notify { text: "發了".into() })]);
|
||||||
|
app.wf_start(&ctx, 1, "手動");
|
||||||
|
assert_eq!(run(&app).state, RunState::Waiting);
|
||||||
|
app.wf_confirm(&ctx, 1, true);
|
||||||
|
assert_eq!(run(&app).state, RunState::Done);
|
||||||
|
app.wf_start(&ctx, 1, "手動");
|
||||||
|
app.wf_confirm(&ctx, 1, false);
|
||||||
|
assert_eq!((run(&app).state, run(&app).why.as_str()), (RunState::Stopped, "你在「等你確認」選了停止"));
|
||||||
|
app.wf_start(&ctx, 1, "手動");
|
||||||
|
app.wf_stop(1);
|
||||||
|
assert_eq!(run(&app).state, RunState::Stopped);
|
||||||
|
assert!(app.wf_start(&ctx, 1, "手動"), "a stopped run doesn't block the next");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A scheduled trigger: its next time is worked out, and a run starts when it comes (by 定時).
|
||||||
|
#[test]
|
||||||
|
fn a_scheduled_trigger_starts_a_run_on_time() {
|
||||||
|
let (ctx, mut app, _) = app_with(vec![(2, NodeKind::Notify { text: "早安".into() })]);
|
||||||
|
let schedule: crate::routines::Schedule = serde_json::from_value(serde_json::json!({"frequency": "daily", "time": "09:00", "timezone": "Asia/Taipei"})).unwrap();
|
||||||
|
if let NodeKind::Trigger { schedule: s } = &mut app.state.workflows[0].nodes[0].kind {
|
||||||
|
*s = Some(schedule);
|
||||||
|
}
|
||||||
|
app.tick_workflows(&ctx);
|
||||||
|
let next = app.state.workflows[0].next_run.expect("a next time");
|
||||||
|
assert!(next > crate::routines::now() && app.state.workflows[0].runs.is_empty());
|
||||||
|
app.state.workflows[0].next_run = Some(crate::routines::now() - 1);
|
||||||
|
app.tick_workflows(&ctx);
|
||||||
|
let r = run(&app);
|
||||||
|
assert_eq!((r.by.as_str(), r.state), ("定時", RunState::Done));
|
||||||
|
assert!(app.state.workflows[0].next_run.unwrap() > crate::routines::now());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 聊出來的工作流: the bot's `workflow` call changes the brain's workflows; the person on
|
||||||
|
/// that chat sees the canvas open beside it, on that workflow, with what changed lit; run
|
||||||
|
/// starts it (its first step asks the bot, in line behind the turn it is in).
|
||||||
|
#[test]
|
||||||
|
fn a_bots_workflow_call_shows_beside_its_chat() {
|
||||||
|
let (ctx, mut app, bot) = app_with(vec![]);
|
||||||
|
app.state.selected = bot;
|
||||||
|
let call = |app: &mut App, args: serde_json::Value| {
|
||||||
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
|
app.workflow_tool(&ctx, bot, AppCall { call_id: "c".into(), name: crate::workflow::TOOL.into(), args: args.to_string(), reply: tx });
|
||||||
|
rx.try_recv().unwrap()
|
||||||
|
};
|
||||||
|
let (text, ok) = call(&mut app, serde_json::json!({"action": "create", "name": "週報", "steps": [{"prompt": "整理這週的進度"}]}));
|
||||||
|
assert!(ok && text.starts_with("已建立工作流 #2「週報」"), "{text}");
|
||||||
|
assert!(app.wf.open && app.wf.current == 2 && !app.wf.chat_hidden && app.wf.reveal, "the canvas beside the chat");
|
||||||
|
assert_eq!(app.wf.flash.as_ref().map(|f| (f.0, f.1.clone())), Some((2, vec![1, 2])));
|
||||||
|
assert!(app.wf_chat_beside(1200.0) && !app.wf_chat_beside(800.0));
|
||||||
|
// Not looking at that chat: nothing opens.
|
||||||
|
app.wf.open = false;
|
||||||
|
app.state.selected = 0;
|
||||||
|
let (_, ok) = call(&mut app, serde_json::json!({"action": "edit", "steps": [{"kind": "notify"}]}));
|
||||||
|
assert!(ok && !app.wf.open);
|
||||||
|
// Run: the first step waits for the bot's turn to end.
|
||||||
|
let (text, ok) = call(&mut app, serde_json::json!({"action": "run", "id": 2}));
|
||||||
|
assert!(ok && text.starts_with("已開始執行「週報」"), "{text}");
|
||||||
|
assert!(app.waiting_wakes.iter().any(|(b, m)| *b == bot && m.text.contains("[工作流「週報」第 1/2 步]整理這週的進度")));
|
||||||
|
// The turn that called run ends first: not the step's answer.
|
||||||
|
app.state.bot_mut(bot).unwrap().messages.push(Message::assistant("好,開始跑了", "m"));
|
||||||
|
app.wf_turn_ended(bot, TurnOutcome::Success);
|
||||||
|
assert_eq!(app.state.workflows[1].runs.last().map(|r| (r.state, r.at)), Some((RunState::Running, 1)), "still on its first step");
|
||||||
|
let (text, ok) = call(&mut app, serde_json::json!({"action": "run", "id": 2}));
|
||||||
|
assert!(!ok && text.contains("已經在跑了"), "{text}");
|
||||||
|
let (_, ok) = call(&mut app, serde_json::json!({"action": "stop", "id": 2}));
|
||||||
|
assert!(ok && app.state.workflows[1].runs.last().unwrap().state == RunState::Stopped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,12 +9,15 @@ use crate::model::{self, Bot, Message, State, Theme, Accent};
|
||||||
use crate::providers::{ProviderKind, ALL_PROVIDERS};
|
use crate::providers::{ProviderKind, ALL_PROVIDERS};
|
||||||
use crate::routines::{self, Routine, Schedule};
|
use crate::routines::{self, Routine, Schedule};
|
||||||
|
|
||||||
pub const NAMES: [&str; 33] = [
|
pub const NAMES: [&str; 34] = [
|
||||||
// 追進度: follow something long in the background (followup.rs; checks run on the brain).
|
// 追進度: follow something long in the background (followup.rs; checks run on the brain).
|
||||||
"follow_up",
|
"follow_up",
|
||||||
// 任務: the tasks and their states as AnyBot works them out (tasks.rs; read-only).
|
// 任務: the tasks and their states as AnyBot works them out (tasks.rs; read-only).
|
||||||
crate::tasks::TOOL,
|
crate::tasks::TOOL,
|
||||||
"list_routines", "create_routine", "update_routine", "delete_routine", "run_routine_now",
|
"list_routines", "create_routine", "update_routine", "delete_routine", "run_routine_now",
|
||||||
|
// 工作流: make, change and run the canvases of steps (the window runs it and shows the canvas
|
||||||
|
// beside the chat; workflow.rs).
|
||||||
|
crate::workflow::TOOL,
|
||||||
"list_bots", "create_bot", "update_bot", "message_bot", "list_computers", "update_settings",
|
"list_bots", "create_bot", "update_bot", "message_bot", "list_computers", "update_settings",
|
||||||
// 問同事: ask another bot and wait for its answer (the window runs its turn, see app/asks.rs);
|
// 問同事: ask another bot and wait for its answer (the window runs its turn, see app/asks.rs);
|
||||||
// 教技能: give a colleague a skill this bot has (the person says yes first).
|
// 教技能: give a colleague a skill this bot has (the person says yes first).
|
||||||
|
|
@ -40,6 +43,7 @@ pub fn is_app_tool(name: &str) -> bool {
|
||||||
pub fn label(name: &str) -> &'static str {
|
pub fn label(name: &str) -> &'static str {
|
||||||
match name {
|
match name {
|
||||||
"list_routines" => "查看例行任務",
|
"list_routines" => "查看例行任務",
|
||||||
|
crate::workflow::TOOL => "工作流",
|
||||||
crate::tasks::TOOL => "查看任務",
|
crate::tasks::TOOL => "查看任務",
|
||||||
crate::mcp::MANAGE_TOOL => "管理連接器",
|
crate::mcp::MANAGE_TOOL => "管理連接器",
|
||||||
crate::hooks::MANAGE_TOOL => "管理 hook",
|
crate::hooks::MANAGE_TOOL => "管理 hook",
|
||||||
|
|
@ -77,7 +81,7 @@ pub fn label(name: &str) -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule_schema() -> Value {
|
pub(crate) fn schedule_schema() -> Value {
|
||||||
json!({
|
json!({
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "When it repeats, in the person's words turned into fields.",
|
"description": "When it repeats, in the person's words turned into fields.",
|
||||||
|
|
@ -123,6 +127,7 @@ pub fn specs() -> Vec<Value> {
|
||||||
"id": {"type": "integer"}, "title": {"type": "string"}, "prompt": {"type": "string"}, "schedule": schedule_schema(), "trigger": crate::triggers::schema(), "paused": {"type": "boolean"}, "target_sends": target_sends_schema()}, "required": ["id"]}}),
|
"id": {"type": "integer"}, "title": {"type": "string"}, "prompt": {"type": "string"}, "schedule": schedule_schema(), "trigger": crate::triggers::schema(), "paused": {"type": "boolean"}, "target_sends": target_sends_schema()}, "required": ["id"]}}),
|
||||||
json!({"name": "delete_routine", "description": "Delete a routine. The person is asked first.", "parameters": {"type": "object", "properties": {"id": {"type": "integer"}}, "required": ["id"]}}),
|
json!({"name": "delete_routine", "description": "Delete a routine. The person is asked first.", "parameters": {"type": "object", "properties": {"id": {"type": "integer"}}, "required": ["id"]}}),
|
||||||
json!({"name": "run_routine_now", "description": "Run a routine once right away.", "parameters": {"type": "object", "properties": {"id": {"type": "integer"}}, "required": ["id"]}}),
|
json!({"name": "run_routine_now", "description": "Run a routine once right away.", "parameters": {"type": "object", "properties": {"id": {"type": "integer"}}, "required": ["id"]}}),
|
||||||
|
crate::workflow::spec(schedule_schema()),
|
||||||
json!({"name": "list_bots", "description": "List the person's bots with their provider, model and what they do.", "parameters": {"type": "object", "properties": {}}}),
|
json!({"name": "list_bots", "description": "List the person's bots with their provider, model and what they do.", "parameters": {"type": "object", "properties": {}}}),
|
||||||
json!({"name": "create_bot", "description": "Create a new bot, optionally from a template (a ready role and instructions).",
|
json!({"name": "create_bot", "description": "Create a new bot, optionally from a template (a ready role and instructions).",
|
||||||
"parameters": {"type": "object", "properties": {
|
"parameters": {"type": "object", "properties": {
|
||||||
|
|
@ -192,6 +197,20 @@ pub fn describe(name: &str, args: &str) -> String {
|
||||||
format!("{t} {when}").trim().to_string()
|
format!("{t} {when}").trim().to_string()
|
||||||
}
|
}
|
||||||
"delete_routine" | "run_routine_now" => format!("#{}", v.get("id").and_then(Value::as_u64).unwrap_or(0)),
|
"delete_routine" | "run_routine_now" => format!("#{}", v.get("id").and_then(Value::as_u64).unwrap_or(0)),
|
||||||
|
crate::workflow::TOOL => {
|
||||||
|
let what = match s("action").as_str() {
|
||||||
|
"list" => "看有哪些",
|
||||||
|
"show" => "看",
|
||||||
|
"create" => "建立",
|
||||||
|
"edit" => "修改",
|
||||||
|
"run" => "執行",
|
||||||
|
"stop" => "停止",
|
||||||
|
"delete" => "刪除",
|
||||||
|
_ => "",
|
||||||
|
};
|
||||||
|
let which = if s("name").is_empty() { v.get("id").and_then(Value::as_u64).map(|i| format!("#{i}")).unwrap_or_default() } else { format!("「{}」", s("name")) };
|
||||||
|
format!("{what} {which}").trim().to_string()
|
||||||
|
}
|
||||||
crate::mcp::MANAGE_TOOL => format!("{} {}", s("action"), s("name")).trim().to_string(),
|
crate::mcp::MANAGE_TOOL => format!("{} {}", s("action"), s("name")).trim().to_string(),
|
||||||
crate::hooks::MANAGE_TOOL => format!("{} {}", s("action"), s("event")).trim().to_string(),
|
crate::hooks::MANAGE_TOOL => format!("{} {}", s("action"), s("event")).trim().to_string(),
|
||||||
crate::chatgpt::TOOL => crate::chatgpt::describe(args),
|
crate::chatgpt::TOOL => crate::chatgpt::describe(args),
|
||||||
|
|
@ -256,6 +275,12 @@ pub fn needs_approval(name: &str, args: &str, state: &State) -> Option<String> {
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// 刪工作流: its steps, notes, versions and runs go with it.
|
||||||
|
if name == crate::workflow::TOOL && v["action"].as_str().is_some_and(|a| a.trim().eq_ignore_ascii_case("delete")) {
|
||||||
|
let w = v["id"].as_u64().and_then(|id| state.workflows.iter().find(|w| w.id == id)).or_else(|| state.workflows.iter().max_by_key(|w| w.updated_at));
|
||||||
|
let name = w.map(|w| format!("「{}」", w.name)).unwrap_or_else(|| "(找不到的那個)".into());
|
||||||
|
return Some(format!("刪除工作流{name}:它的步驟、便利貼、版本歷史和執行紀錄都會刪掉,無法復原。"));
|
||||||
|
}
|
||||||
if name == "delete_routine" {
|
if name == "delete_routine" {
|
||||||
let id = v.get("id").and_then(Value::as_u64).unwrap_or(0);
|
let id = v.get("id").and_then(Value::as_u64).unwrap_or(0);
|
||||||
let title = state.bots.iter().flat_map(|b| b.routines.iter()).find(|r| r.id == id).map(|r| r.title.clone()).unwrap_or_else(|| format!("#{id}"));
|
let title = state.bots.iter().flat_map(|b| b.routines.iter()).find(|r| r.id == id).map(|r| r.title.clone()).unwrap_or_else(|| format!("#{id}"));
|
||||||
|
|
@ -536,6 +561,18 @@ pub fn apply(state: &mut State, bot_id: u64, name: &str, args: &str) -> Outcome
|
||||||
"list_pages" => ok(crate::pages::list(&state.pages, bot_id, |id| state.bot(id).map(|b| b.name.clone()).unwrap_or_else(|| "已刪除的 Bot".into()))),
|
"list_pages" => ok(crate::pages::list(&state.pages, bot_id, |id| state.bot(id).map(|b| b.name.clone()).unwrap_or_else(|| "已刪除的 Bot".into()))),
|
||||||
// 任務 (the window answers it with what runs now: app/tasks_ui.rs; this is the chats alone).
|
// 任務 (the window answers it with what runs now: app/tasks_ui.rs; this is the chats alone).
|
||||||
crate::tasks::TOOL => ok(crate::tasks::answer(&crate::tasks::all(&state.bots, &crate::tasks::Live::default(), model::now_ms()), &state.bots, bot_id, &v, &state.timezone)),
|
crate::tasks::TOOL => ok(crate::tasks::answer(&crate::tasks::all(&state.bots, &crate::tasks::Live::default(), model::now_ms()), &state.bots, bot_id, &v, &state.timezone)),
|
||||||
|
// 工作流 (the window runs it — app/workflow_run.rs — with the canvas; here: the workflows
|
||||||
|
// alone, nothing started or stopped).
|
||||||
|
crate::workflow::TOOL => {
|
||||||
|
let bots: Vec<(u64, String)> = state.bots.iter().filter(|b| b.branch_of == 0).map(|b| (b.id, b.name.clone())).collect();
|
||||||
|
let tz = state.timezone.clone();
|
||||||
|
let who = crate::workflow::Who { me: bot_id, bots: &bots, timezone: &tz };
|
||||||
|
match crate::workflow::tool(&mut state.workflows, &who, &v, None, now) {
|
||||||
|
Ok(t) if t.run || t.stop => err("執行和停止要在開著的 AnyBot 上做".into()),
|
||||||
|
Ok(t) => ok(t.text),
|
||||||
|
Err(e) => err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
"list_routines" => {
|
"list_routines" => {
|
||||||
let Some(b) = state.bot(bot_id) else { return err("找不到這個 Bot".into()) };
|
let Some(b) = state.bot(bot_id) else { return err("找不到這個 Bot".into()) };
|
||||||
if b.routines.is_empty() {
|
if b.routines.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ pub const AREAS: &[Area] = &[
|
||||||
area!("pages", "頁面"),
|
area!("pages", "頁面"),
|
||||||
area!("pageview", "頁面的版面與圖表"),
|
area!("pageview", "頁面的版面與圖表"),
|
||||||
area!("routines", "例行任務"),
|
area!("routines", "例行任務"),
|
||||||
|
area!("workflow", "工作流"),
|
||||||
area!("goal", "目標(/goal)"),
|
area!("goal", "目標(/goal)"),
|
||||||
area!("plan", "計畫(/plan)"),
|
area!("plan", "計畫(/plan)"),
|
||||||
area!("tasks", "任務"),
|
area!("tasks", "任務"),
|
||||||
|
|
|
||||||
19
src/icons.rs
|
|
@ -86,6 +86,16 @@ pub enum Icon {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
Brain,
|
Brain,
|
||||||
Target,
|
Target,
|
||||||
|
// 工作流 (the canvas and its tools).
|
||||||
|
Workflow,
|
||||||
|
Hand,
|
||||||
|
Pointer,
|
||||||
|
StickyNote,
|
||||||
|
Square,
|
||||||
|
Type,
|
||||||
|
Map,
|
||||||
|
Scan,
|
||||||
|
Send,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Icon {
|
impl Icon {
|
||||||
|
|
@ -178,6 +188,15 @@ impl Icon {
|
||||||
Icon::Message => include_str!("../icons/lucide/message-circle.svg"),
|
Icon::Message => include_str!("../icons/lucide/message-circle.svg"),
|
||||||
Icon::Alarm => include_str!("../icons/lucide/alarm-clock.svg"),
|
Icon::Alarm => include_str!("../icons/lucide/alarm-clock.svg"),
|
||||||
Icon::Target => include_str!("../icons/lucide/target.svg"),
|
Icon::Target => include_str!("../icons/lucide/target.svg"),
|
||||||
|
Icon::Workflow => include_str!("../icons/lucide/workflow.svg"),
|
||||||
|
Icon::Hand => include_str!("../icons/lucide/hand.svg"),
|
||||||
|
Icon::Pointer => include_str!("../icons/lucide/mouse-pointer-2.svg"),
|
||||||
|
Icon::StickyNote => include_str!("../icons/lucide/sticky-note.svg"),
|
||||||
|
Icon::Square => include_str!("../icons/lucide/square.svg"),
|
||||||
|
Icon::Type => include_str!("../icons/lucide/type.svg"),
|
||||||
|
Icon::Map => include_str!("../icons/lucide/map.svg"),
|
||||||
|
Icon::Scan => include_str!("../icons/lucide/scan.svg"),
|
||||||
|
Icon::Send => include_str!("../icons/lucide/send.svg"),
|
||||||
Icon::CircleCheck => include_str!("../icons/lucide/circle-check.svg"),
|
Icon::CircleCheck => include_str!("../icons/lucide/circle-check.svg"),
|
||||||
Icon::CircleX => include_str!("../icons/lucide/circle-x.svg"),
|
Icon::CircleX => include_str!("../icons/lucide/circle-x.svg"),
|
||||||
Icon::Minus => include_str!("../icons/lucide/minus.svg"),
|
Icon::Minus => include_str!("../icons/lucide/minus.svg"),
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ mod providers;
|
||||||
mod publish;
|
mod publish;
|
||||||
mod remote;
|
mod remote;
|
||||||
mod routines;
|
mod routines;
|
||||||
|
mod workflow;
|
||||||
mod setup;
|
mod setup;
|
||||||
mod skills;
|
mod skills;
|
||||||
mod teach;
|
mod teach;
|
||||||
|
|
|
||||||
|
|
@ -866,6 +866,9 @@ pub struct State {
|
||||||
/// 頁面 the bots made and keep up to date.
|
/// 頁面 the bots made and keep up to date.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub pages: Vec<crate::pages::Page>,
|
pub pages: Vec<crate::pages::Page>,
|
||||||
|
/// 工作流: steps on a canvas, run in order (workflow.rs).
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub workflows: Vec<crate::workflow::Workflow>,
|
||||||
/// 待改進: AnyBot's own problems the bots ran into (garden.rs), for whoever fixes AnyBot.
|
/// 待改進: AnyBot's own problems the bots ran into (garden.rs), for whoever fixes AnyBot.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub improvements: Vec<crate::garden::Improvement>,
|
pub improvements: Vec<crate::garden::Improvement>,
|
||||||
|
|
@ -1447,6 +1450,7 @@ impl State {
|
||||||
branch_bots: vec![],
|
branch_bots: vec![],
|
||||||
skills_seeded: false,
|
skills_seeded: false,
|
||||||
pages: vec![],
|
pages: vec![],
|
||||||
|
workflows: vec![],
|
||||||
improvements: vec![],
|
improvements: vec![],
|
||||||
garden_reports: true,
|
garden_reports: true,
|
||||||
garden_daily: 0,
|
garden_daily: 0,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ pub const ABILITIES: [(&str, &str, &str); 11] = [
|
||||||
("mac_apps", "Mac App", "提醒事項、行事曆、聯絡人、備忘錄、郵件、訊息"),
|
("mac_apps", "Mac App", "提醒事項、行事曆、聯絡人、備忘錄、郵件、訊息"),
|
||||||
("connectors", "連接器", "你接上的 MCP 連接器"),
|
("connectors", "連接器", "你接上的 MCP 連接器"),
|
||||||
("phone", "電話、簡訊、X", "打電話、傳簡訊、在 X 發文"),
|
("phone", "電話、簡訊、X", "打電話、傳簡訊、在 X 發文"),
|
||||||
("routines", "例行任務", "設定和管理定時要做的事"),
|
("routines", "例行任務與工作流", "設定和管理定時要做的事、多步驟的工作流"),
|
||||||
("pages", "頁面", "寫和維護追蹤、報告頁面"),
|
("pages", "頁面", "寫和維護追蹤、報告頁面"),
|
||||||
("team", "和其他 Bot 合作", "把工作交給其他 Bot"),
|
("team", "和其他 Bot 合作", "把工作交給其他 Bot"),
|
||||||
("admin", "管理 App", "建立和修改 Bot、群組、技能,改 App 設定"),
|
("admin", "管理 App", "建立和修改 Bot、群組、技能,改 App 設定"),
|
||||||
|
|
@ -40,7 +40,7 @@ pub fn ability_of(tool: &str) -> Option<&'static str> {
|
||||||
t if crate::macapps::is_mac_tool(t) => "mac_apps",
|
t if crate::macapps::is_mac_tool(t) => "mac_apps",
|
||||||
t if crate::mcp::is_mcp_tool(t) || t == crate::mcp::FIND_TOOL || t == crate::mcp::USE_TOOL => "connectors",
|
t if crate::mcp::is_mcp_tool(t) || t == crate::mcp::FIND_TOOL || t == crate::mcp::USE_TOOL => "connectors",
|
||||||
"place_call" | "send_sms" | "post_to_x" => "phone",
|
"place_call" | "send_sms" | "post_to_x" => "phone",
|
||||||
"create_routine" | "update_routine" | "delete_routine" | "list_routines" | "run_routine_now" => "routines",
|
"create_routine" | "update_routine" | "delete_routine" | "list_routines" | "run_routine_now" | crate::workflow::TOOL => "routines",
|
||||||
"write_page" | "read_page" | "list_pages" => "pages",
|
"write_page" | "read_page" | "list_pages" => "pages",
|
||||||
"message_bot" | "ask_bot" | "teach_skill" | "list_bots" => "team",
|
"message_bot" | "ask_bot" | "teach_skill" | "list_bots" => "team",
|
||||||
"create_bot" | "update_bot" | "update_settings" | "create_group" | "move_to_group" | "rename_group" | "delete_group" | "delete_skill" | "skill_install" | crate::mcp::MANAGE_TOOL | crate::hooks::MANAGE_TOOL | crate::chatgpt::TOOL => "admin",
|
"create_bot" | "update_bot" | "update_settings" | "create_group" | "move_to_group" | "rename_group" | "delete_group" | "delete_skill" | "skill_install" | crate::mcp::MANAGE_TOOL | crate::hooks::MANAGE_TOOL | crate::chatgpt::TOOL => "admin",
|
||||||
|
|
|
||||||