市集(計畫 C1,照 OpenBot 市集的排版):側邊欄左下角的格子圖示打開「市集」視窗(以前直接跳到 設定 › 整合 › 連接器 › 瀏覽市集)。左欄「搜尋市集」、三個分頁「連接器」(8)「技能」(內建 8+Anthropic 開源 8)「Bot 範本」(5),下面「已安裝」列加入的連接器(綠點、關掉灰點、有問題紅點寫「有問題」)和技能(最多 8 個,多的「還有 N」),點一列打開設定裡它自己的頁。右邊那類一句說明;沒在搜尋時先一排三張「精選」(還沒加入的排前面),再來「全部」卡片,至少 300 寬、一排放得下幾張就幾張:圖示(連接器名字第一個字、技能星星、範本是那個頭像)、名字、誰的(官方/內建/Anthropic/範本,要金鑰的多「要金鑰」)、一行說明,右上一顆按鈕——連接器「加入」(要金鑰的打開設定裡填好的「新增連接器」)、內建技能「加入」、Anthropic 技能「安裝」(背景裝、一次一個,結果綠字或紅字寫在說明下面)、範本「建立」(建好 Bot、打開 Bot 設定);已經有的灰字「已加入」。

按鈕和 設定 › 整合 走同一段程式:從 channels_ui 抽出 mcp_market_add、skill_add_builtin,skill_install 改成 pub(super)。卡片的按鈕放在子 Ui 裡(ui.put 會推動這一排的游標,卡片間距變兩倍、最右邊一張被切掉,截圖看到後改的);卡片區的高度照欄位剩下的算(說明下面多一行結果時不會超出對話框)。圖示顏色用 Bot 的顏色表(avatar::color),不新增調色盤外的顏色。layout_audit 多一景「市集」;截圖多 ANYBOT_SHOT_VIEW=market。

已驗證: cargo test 836 過(theme 的設計檢查、featuremap::、layout_audit:: 含「市集」);clippy 維持 12;scratch 桌面截圖(示範資料):點側邊欄左下角格子圖示打開市集,連接器 8/技能 16/Bot 範本 5,精選三張、全部兩欄不被切;技能分頁精選是還沒加入的(看報快摘、每日打卡、螢幕報表存檔),按「看報快摘」的加入 → 綠字「已加入技能「看報快摘」」、已安裝多「還有 1」、精選換成下一個;Bot 範本按開發助手的「建立」→ 側邊欄多開發助手、Bot 設定打開(名稱、描述、Soul 與指示都填好)。
未驗證: 連接器的「加入」(會跑 npx/uvx 從 npm、PyPI 下載,scratch 不對外連);Anthropic 技能的「安裝」(要連 GitHub);螢幕電腦上從市集加(走 mirror_skill 和大腦,scratch 沒有第二台);詳細頁、試試看、權限、危險區、安裝數、技能鎖檔、手機版還沒做。

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 14:46:53 +08:00
parent efaedb9821
commit 4bdc1267d2
9 changed files with 441 additions and 29 deletions

View File

@ -1588,6 +1588,12 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- 檔案不在原處(刪掉或搬走):灰字、紅字「不見了」,點不開。其他點一下用 AnyBot 的檢視器打開(Markdown、表格、圖片、PDF、影音、程式碼;用其他 App 打開、下載)。 - 檔案不在原處(刪掉或搬走):灰字、紅字「不見了」,點不開。其他點一下用 AnyBot 的檢視器打開(Markdown、表格、圖片、PDF、影音、程式碼;用其他 App 打開、下載)。
- 螢幕電腦看的是從大腦抓過來的副本。手機還沒有(只有每個對話的「資料庫」)。功能地圖新的一區 library.md。 - 螢幕電腦看的是從大腦抓過來的副本。手機還沒有(只有每個對話的「資料庫」)。功能地圖新的一區 library.md。
### 市集(側邊欄左下角的格子圖示)
- 一個視窗看能加給 Bot 的東西(計畫 C1,照 OpenBot 市集的排版):左欄「搜尋市集」、三個分頁「連接器」(8)「技能」(內建 8+Anthropic 開源 8)「Bot 範本」(5),下面「已安裝」列加入的連接器(綠點、關掉灰點、有問題紅點)和技能(最多 8 個,多的寫「還有 N」),點一列打開設定裡它自己的頁。
- 右邊:那類一句說明;沒在搜尋時先一排三張「精選」(還沒加入的排前面),再來「全部」卡片(至少 300 寬,一排放得下幾張就幾張):圖示(連接器是名字第一個字、技能是星星、範本是那個頭像)、名字、誰的(官方/內建/Anthropic/範本,要金鑰的多寫「要金鑰」)、一行說明,右上按鈕:連接器「加入」(要金鑰的打開設定裡填好的「新增連接器」)、內建技能「加入」、Anthropic 技能「安裝」(背景裝,一次一個,結果寫在說明下面)、範本「建立」(建好、打開 Bot 設定);已經有的寫灰字「已加入」。
- 按鈕做的事和設定 › 整合 的一樣(同一段程式:`mcp_market_add`、`skill_add_builtin`、`skill_install`)。以前側邊欄這顆按鈕直接到 設定 › 整合 › 連接器 › 瀏覽市集。詳細頁(試試看、權限、危險區)、安裝數、技能的鎖檔還沒做。截圖用 `ANYBOT_SHOT_VIEW=market`。
### 頭像的表情(側邊欄、釘選、右側面板、任務卡) ### 頭像的表情(側邊欄、釘選、右側面板、任務卡)
- 輸入框上方那張臉本來就看狀態換表情;現在其他地方的 Bot 頭像也一樣(計畫 C2):等你允許或回答時往上看你;上網時眼睛左右掃、看畫面時往右上看、寫字時往下看、想事情或讀結果時往左上看、其他步驟慢慢左右讀;做事時微微呼吸(2.6 秒一次、3%,從腳往上);上一輪失敗是兩條平的眼睛(以前側邊欄看不出失敗),剛做完笑兩秒;閒著時跟著滑鼠。做事時一個樣子至少停 1.4 秒。 - 輸入框上方那張臉本來就看狀態換表情;現在其他地方的 Bot 頭像也一樣(計畫 C2):等你允許或回答時往上看你;上網時眼睛左右掃、看畫面時往右上看、寫字時往下看、想事情或讀結果時往左上看、其他步驟慢慢左右讀;做事時微微呼吸(2.6 秒一次、3%,從腳往上);上一輪失敗是兩條平的眼睛(以前側邊欄看不出失敗),剛做完笑兩秒;閒著時跟著滑鼠。做事時一個樣子至少停 1.4 秒。

View File

@ -10,11 +10,13 @@
- `market-add` 「新增連接器」是它自己的頁(同樣的欄位,名稱在上、框在下),按「新增」後直接到新連接器的頁看它連線。 - `market-add` 「新增連接器」是它自己的頁(同樣的欄位,名稱在上、框在下),按「新增」後直接到新連接器的頁看它連線。
- `market-builtin` 「瀏覽市集」頁的「連接器市集」:8 個常用的(files、memory、thinking、fetch、git、time、playwright、github),按「加入」就能用;要金鑰的(github)打開填好的「新增連接器」頁,補上 Token 再按「新增」。 - `market-builtin` 「瀏覽市集」頁的「連接器市集」:8 個常用的(files、memory、thinking、fetch、git、time、playwright、github),按「加入」就能用;要金鑰的(github)打開填好的「新增連接器」頁,補上 Token 再按「新增」。
- `market-registry` 同一頁的「公用市集(官方 MCP Registry)」:搜尋用網址連的連接器,按「加入」打開填好的「新增連接器」頁;還有「{…}」沒換成你的值時按不下「新增」。 - `market-registry` 同一頁的「公用市集(官方 MCP Registry)」:搜尋用網址連的連接器,按「加入」打開填好的「新增連接器」頁;還有「{…}」沒換成你的值時按不下「新增」。
- `market-window` 「市集」視窗(照 OpenBot 市集的排版,側邊欄左下角的格子圖示):左欄「搜尋市集」、三個分頁「連接器」「技能」「Bot 範本」(各帶數量),下面「已安裝」列加入的連接器(綠點、關掉的灰點、有問題的紅點寫「有問題」)和技能(最多 8 個,多的寫「還有 N」)。右邊那類的一句說明,沒在搜尋時先一排三張「精選」(還沒加入的排前面),再來「全部」的卡片(一排放得下幾張就幾張,至少 300 寬):圖示、名字、誰的(官方、內建、Anthropic、範本;要金鑰的多寫「要金鑰」)、一行說明,右上一顆按鈕——連接器「加入」(要金鑰的打開設定裡填好的「新增連接器」)、內建技能「加入」、Anthropic 技能「安裝」(在背景裝,一次一個,說明下面寫結果)、範本「建立」(建好 Bot、打開 Bot 設定);已經有的寫灰字「已加入」。點「已安裝」的一列打開設定裡它自己的頁。
- `market-phone` 手機:設定 ›「整合」列出連接器(開關、重新連線、移除),還有「從公用市集加入」(只有擁有者能用;直接連線(同一個網路)加不了——新連接器等於讓 Bot 多一批能叫的工具,要用帳號連線或在電腦上加)。 - `market-phone` 手機:設定 ›「整合」列出連接器(開關、重新連線、移除),還有「從公用市集加入」(只有擁有者能用;直接連線(同一個網路)加不了——新連接器等於讓 Bot 多一批能叫的工具,要用帳號連線或在電腦上加)。
## 使用者怎麼到 ## 使用者怎麼到
- 設定 ›「整合」›「連接器」分頁:「已加入」清單;「瀏覽市集」(連接器市集、公用市集)和「新增連接器」各是一頁。側邊欄的連接器市集圖示直接到「瀏覽市集」頁。 - 設定 ›「整合」›「連接器」分頁:「已加入」清單;「瀏覽市集」(連接器市集、公用市集)和「新增連接器」各是一頁。
- 「市集」視窗:側邊欄左下角的格子圖示(滑過寫「市集:連接器、技能、Bot 範本」)。
- 手機:帳戶選單 › 設定 ›「整合」的「連接器(MCP)」。 - 手機:帳戶選單 › 設定 ›「整合」的「連接器(MCP)」。
## 怎麼操作(verify-anybot) ## 怎麼操作(verify-anybot)
@ -30,6 +32,7 @@
- **手機不能改名、區網加不了**(covers `market-rename`、`market-phone`、`market-registry`):送手機頁面會送的兩個請求:改名,和公用市集選好後的「加入」。指令:`$CTL api --expect 403 POST /api/act/mcp '{"name":"far","rename":"near"}' && $CTL api --expect 403 POST /api/act/mcp '{"add":{"name":"x","url":"https://x.example/mcp"}}' && $CTL api GET /api/settings --jq '[.mcp[].name]'`。看到:「連接器的名稱只能在電腦上的 AnyBot 改」;加入回「這會放寬 Bot 能做的事:同一個網路直接連的裝置只能收緊、不能放寬…」;清單還是只有 far。 - **手機不能改名、區網加不了**(covers `market-rename`、`market-phone`、`market-registry`):送手機頁面會送的兩個請求:改名,和公用市集選好後的「加入」。指令:`$CTL api --expect 403 POST /api/act/mcp '{"name":"far","rename":"near"}' && $CTL api --expect 403 POST /api/act/mcp '{"add":{"name":"x","url":"https://x.example/mcp"}}' && $CTL api GET /api/settings --jq '[.mcp[].name]'`。看到:「連接器的名稱只能在電腦上的 AnyBot 改」;加入回「這會放寬 Bot 能做的事:同一個網路直接連的裝置只能收緊、不能放寬…」;清單還是只有 far。
- **手機移除**(covers `market-phone`):按垃圾桶 ›「移除」。指令:`$CTL phone click '[data-mcprm="far"]' && $CTL phone click '#sheet-in .opt' --text 移除 && $CTL phone wait-text 還沒有連接器 --in '#list' && $CTL api GET /api/settings --jq '.mcp'`。看到:先問「移除這個連接器?」;之後寫「還沒有連接器」,大腦那邊是空的。 - **手機移除**(covers `market-phone`):按垃圾桶 ›「移除」。指令:`$CTL phone click '[data-mcprm="far"]' && $CTL phone click '#sheet-in .opt' --text 移除 && $CTL phone wait-text 還沒有連接器 --in '#list' && $CTL api GET /api/settings --jq '.mcp'`。看到:先問「移除這個連接器?」;之後寫「還沒有連接器」,大腦那邊是空的。
- **桌面的四個頁**(covers `market-list`、`market-item`、`market-add`、`market-builtin`、`market-registry`、`market-rename`):指令:要開視窗——`$CTL stop && (for pg in list 0 add market; do ABV_ALLOW_WINDOW=1 $CTL desktop-shot market-$pg ANYBOT_SHOT_VIEW=channels ANYBOT_SHOT_SUB=1 ANYBOT_SHOT_MCP_PAGE=$pg ANYBOT_SHOT_MCP_TOOLS=12 || exit 1; done)`(示範資料:github、files 兩個)。看到:清單一列一個;github 自己的頁有「工具(12)」「搜尋工具」、欄位卡和紅字移除;「新增連接器」頁;「瀏覽市集」的 8 個和公用市集的搜尋框。打字改名、Enter/Esc 靠自動測試。 - **桌面的四個頁**(covers `market-list`、`market-item`、`market-add`、`market-builtin`、`market-registry`、`market-rename`):指令:要開視窗——`$CTL stop && (for pg in list 0 add market; do ABV_ALLOW_WINDOW=1 $CTL desktop-shot market-$pg ANYBOT_SHOT_VIEW=channels ANYBOT_SHOT_SUB=1 ANYBOT_SHOT_MCP_PAGE=$pg ANYBOT_SHOT_MCP_TOOLS=12 || exit 1; done)`(示範資料:github、files 兩個)。看到:清單一列一個;github 自己的頁有「工具(12)」「搜尋工具」、欄位卡和紅字移除;「新增連接器」頁;「瀏覽市集」的 8 個和公用市集的搜尋框。打字改名、Enter/Esc 靠自動測試。
- **市集視窗**(covers `market-window`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot market-win ANYBOT_SHOT_SIZE=1200x820 ANYBOT_SHOT_FRAMES=40 'ANYBOT_SHOT_CLICK=254,788@20'`;再用 `ANYBOT_SHOT_VIEW=market` 點「技能」(`234,191@20`)、點「技能」再點第一張精選的「加入」(`234,191@20;551,230@30`,`ANYBOT_SHOT_FRAMES=50`)、點「Bot 範本」再點開發助手的「建立」(`234,221@20;667,627@30`)。看到:連接器 8、技能 16、Bot 範本 5;精選三張、全部兩欄;技能精選是還沒加入的(看報快摘、每日打卡、螢幕報表存檔),按了寫綠字「已加入技能「看報快摘」」、已安裝多「還有 1」;建立後側邊欄多「開發助手」、Bot 設定打開。連接器的「加入」要網路(npx/uvx),走不到。
- **加入市集的、公用市集搜尋**(covers `market-builtin`、`market-registry`):指令:走不到——要網路(npm、PyPI、官方 MCP Registry)和 Node.js、uv;scratch 不對外連。看到:最接近的真路是上面的 403、[connectors](connectors.md) 的本機伺服器和 `cargo test mcp::`(`the_registry_lists_what_can_be_reached_by_address`)。 - **加入市集的、公用市集搜尋**(covers `market-builtin`、`market-registry`):指令:走不到——要網路(npm、PyPI、官方 MCP Registry)和 Node.js、uv;scratch 不對外連。看到:最接近的真路是上面的 403、[connectors](connectors.md) 的本機伺服器和 `cargo test mcp::`(`the_registry_lists_what_can_be_reached_by_address`)。
- 自動測試:`cargo test mcp::`、`cargo test a_connector_is_renamed_when_done`、`cargo test layout_audit::`;實機(要網路、Node.js、uv):`cargo test --release -- --ignored marketplace`、`cargo test registry_search_live -- --ignored`。 - 自動測試:`cargo test mcp::`、`cargo test a_connector_is_renamed_when_done`、`cargo test layout_audit::`;實機(要網路、Node.js、uv):`cargo test --release -- --ignored marketplace`、`cargo test registry_search_live -- --ignored`。

View File

@ -35,7 +35,7 @@
## 使用者怎麼到 ## 使用者怎麼到
- 設定視窗:⌘,;或側邊欄左下角你的名字(滑過寫「設定(⌘,)」)。右側面板「新增至 Slack」直接到「整合」,側邊欄的連接器市集圖示到 整合 › 連接器。 - 設定視窗:⌘,;或側邊欄左下角你的名字(滑過寫「設定(⌘,)」)。右側面板「新增至 Slack」直接到「整合」;側邊欄左下角的格子圖示打開「市集」視窗([market](market.md))。
- Bot 設定:側邊欄對 Bot 按右鍵,或聊天上方的「⋯」,選「編輯 Bot…」;或在右側面板點 Bot 的大頭像。 - Bot 設定:側邊欄對 Bot 按右鍵,或聊天上方的「⋯」,選「編輯 Bot…」;或在右側面板點 Bot 的大頭像。
- 手機:設定頁有一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新(沒有語音),能改的比較少([phone](phone.md))。 - 手機:設定頁有一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新(沒有語音),能改的比較少([phone](phone.md))。

View File

@ -116,7 +116,7 @@
## C. 介面(學排版) ## C. 介面(學排版)
**C1. 市集**:三個分頁(應用/Bot/技能);左欄是分頁+「已安裝」清單(要處理的標警示);卡片一列 320 px 起跳的格子: **C1. 市集**(11/21 做了:「市集」視窗——三個分頁、已安裝(有問題標紅)、精選三張、300 寬起跳的卡片格子、加入/安裝/建立/已加入;詳細頁、試試看、權限、危險區、安裝數、技能鎖檔、手機版還沒做):三個分頁(應用/Bot/技能);左欄是分頁+「已安裝」清單(要處理的標警示);卡片一列 320 px 起跳的格子:
(現況:沒有獨立的市集頁,市集在 設定 › 整合 下面,一列一列的名字+說明+「加入」,沒有卡片、圖示、分類、安裝數,裝好之前看不到詳細頁,連接器/技能/訊息管道各自分開,裝好的沒有版本和更新。) (現況:沒有獨立的市集頁,市集在 設定 › 整合 下面,一列一列的名字+說明+「加入」,沒有卡片、圖示、分類、安裝數,裝好之前看不到詳細頁,連接器/技能/訊息管道各自分開,裝好的沒有版本和更新。)
圖示、名字、驗證標記、一句話、右邊一顆動作鈕(連接/加入/已加入/打開);精選一排 3 張大卡; 圖示、名字、驗證標記、一句話、右邊一顆動作鈕(連接/加入/已加入/打開);精選一排 3 張大卡;
詳細頁由上而下:標題列(狀態+動作)→ 錯誤/警告 → 「試試看」範例句(點了直接帶進聊天)→ 連線與權限 → 資訊 → 危險區。 詳細頁由上而下:標題列(狀態+動作)→ 錯誤/警告 → 「試試看」範例句(點了直接帶進聊天)→ 連線與權限 → 資訊 → 危險區。

View File

@ -45,6 +45,7 @@ mod tasks_ui;
mod me_ui; mod me_ui;
mod activity_ui; mod activity_ui;
mod library_ui; mod library_ui;
mod market_ui;
mod settings_find; mod settings_find;
mod memory_ui; mod memory_ui;
mod goal_ui; mod goal_ui;
@ -354,6 +355,8 @@ pub struct App {
me: me_ui::MeUi, me: me_ui::MeUi,
act: activity_ui::ActivityUi, act: activity_ui::ActivityUi,
lib: library_ui::LibraryUi, lib: library_ui::LibraryUi,
/// 市集: connectors, skills and bot templates as cards (market_ui.rs).
market: market_ui::MarketUi,
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.
@ -625,6 +628,7 @@ impl App {
me: Default::default(), me: Default::default(),
act: Default::default(), act: Default::default(),
lib: Default::default(), lib: Default::default(),
market: Default::default(),
drop_last: String::new(), drop_last: String::new(),
nightly_checked: None, nightly_checked: None,
att: Default::default(), att: Default::default(),
@ -751,6 +755,8 @@ impl App {
Ok("chat") => app.state.selected = 1, Ok("chat") => app.state.selected = 1,
// 所有檔案. // 所有檔案.
Ok("library") => app.lib.open = true, Ok("library") => app.lib.open = true,
// 市集.
Ok("market") => app.market.open = true,
// 在哪一台 (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") => {
@ -1397,6 +1403,8 @@ impl App {
app.settings_tab = SettingsTab::Remote; app.settings_tab = SettingsTab::Remote;
} }
Ok("library") => app.lib.open = true, Ok("library") => app.lib.open = true,
// 市集.
Ok("market") => app.market.open = true,
Ok("computers") => { Ok("computers") => {
app.show_settings = true; app.show_settings = true;
app.settings_tab = SettingsTab::Computers; app.settings_tab = SettingsTab::Computers;
@ -7281,6 +7289,7 @@ impl eframe::App for App {
self.drops_page(ctx); self.drops_page(ctx);
self.tasks_window(ctx); self.tasks_window(ctx);
self.library_window(ctx); self.library_window(ctx);
self.market_window(ctx);
self.settings(ctx); self.settings(ctx);
} }
self.delete_dialog(ctx); self.delete_dialog(ctx);

View File

@ -73,9 +73,9 @@ pub struct ChannelUi {
skill_q: String, skill_q: String,
/// The skill whose 「刪除」 was pressed once: it asks 「確定刪除」 before it goes (with its folder). /// The skill whose 「刪除」 was pressed once: it asks 「確定刪除」 before it goes (with its folder).
skill_confirm: Option<String>, skill_confirm: Option<String>,
skill_busy: Arc<AtomicBool>, pub(super) skill_busy: Arc<AtomicBool>,
skill_reload: Arc<AtomicBool>, skill_reload: Arc<AtomicBool>,
skill_note: Arc<Mutex<Option<(bool, String)>>>, pub(super) skill_note: Arc<Mutex<Option<(bool, String)>>>,
/// The last skill request came from the 技能 list (a delete): its answer shows there. /// The last skill request came from the 技能 list (a delete): its answer shows there.
skill_note_list: bool, skill_note_list: bool,
} }
@ -1068,12 +1068,7 @@ impl App {
if added { if added {
ui.label(RichText::new(t("已加入")).size(FONT_XS).color(p.text3)); ui.label(RichText::new(t("已加入")).size(FONT_XS).color(p.text3));
} else if ui.add(secondary_button("加入")).clicked() { } else if ui.add(secondary_button("加入")).clicked() {
if needs.is_empty() { self.mcp_market_add(name, cmd, needs);
self.state.mcp_servers.push(crate::mcp::market_server(name, cmd));
} else {
self.ch.new_mcp = (name.to_string(), cmd.to_string(), if cmd.starts_with("http") { String::new() } else { needs.to_string() }, if cmd.starts_with("http") { needs.to_string() } else { String::new() });
self.ch.mcp_page = Page::Add;
}
} }
}, },
|ui| { |ui| {
@ -1280,18 +1275,7 @@ impl App {
} }
}); });
if let Some(slug) = add_builtin { if let Some(slug) = add_builtin {
self.ch.skill_note_list = false; self.skill_add_builtin(slug);
if self.mir.on {
self.mirror_skill(serde_json::json!({"builtin": slug}), self.ch.skill_note.clone(), self.ch.skill_busy.clone());
} else {
match crate::skills::install_builtin(slug, &mut self.state.skills) {
Ok(name) => {
*self.ch.skill_note.lock().unwrap() = Some((true, format!("已加入技能「{name}」")));
self.dirty = true;
}
Err(e) => *self.ch.skill_note.lock().unwrap() = Some((false, e)),
}
}
} }
section(ui, "Anthropic 開源技能", p); section(ui, "Anthropic 開源技能", p);
@ -1452,7 +1436,37 @@ impl App {
/// Install a skill from an address or a folder. On a screen the brain does it — it fetches /// Install a skill from an address or a folder. On a screen the brain does it — it fetches
/// an address itself, and a folder on this computer goes up whole — since the bots read skills /// an address itself, and a folder on this computer goes up whole — since the bots read skills
/// from the brain's disk. Otherwise it is fetched in the background and the list reloads. /// from the brain's disk. Otherwise it is fetched in the background and the list reloads.
fn skill_install(&mut self, src: String, ctx: &egui::Context) { /// 連接器市集's 加入 (here and in the 市集 window): one that needs nothing is added; one that
/// needs a key or a login opens 新增連接器 filled in — true then.
pub(super) fn mcp_market_add(&mut self, name: &str, cmd: &str, needs: &str) -> bool {
if needs.is_empty() {
self.state.mcp_servers.push(crate::mcp::market_server(name, cmd));
self.dirty = true;
return false;
}
let remote = cmd.starts_with("http");
self.ch.new_mcp = (name.to_string(), cmd.to_string(), if remote { String::new() } else { needs.to_string() }, if remote { needs.to_string() } else { String::new() });
self.ch.mcp_page = Page::Add;
true
}
/// 內建技能包's 加入 (here and in the 市集 window); on a screen the brain adds it.
pub(super) fn skill_add_builtin(&mut self, slug: &str) {
self.ch.skill_note_list = false;
if self.mir.on {
self.mirror_skill(serde_json::json!({"builtin": slug}), self.ch.skill_note.clone(), self.ch.skill_busy.clone());
} else {
match crate::skills::install_builtin(slug, &mut self.state.skills) {
Ok(name) => {
*self.ch.skill_note.lock().unwrap() = Some((true, format!("已加入技能「{name}」")));
self.dirty = true;
}
Err(e) => *self.ch.skill_note.lock().unwrap() = Some((false, e)),
}
}
}
pub(super) fn skill_install(&mut self, src: String, ctx: &egui::Context) {
self.ch.skill_note_list = false; self.ch.skill_note_list = false;
let (busy, note) = (self.ch.skill_busy.clone(), self.ch.skill_note.clone()); let (busy, note) = (self.ch.skill_busy.clone(), self.ch.skill_note.clone());
let src = src.trim().to_string(); let src = src.trim().to_string();

View File

@ -167,6 +167,12 @@ fn scenes() -> Vec<(&'static str, Open)> {
a.lib.open = true; a.lib.open = true;
}), }),
), ),
(
"市集",
Box::new(|a: &mut App| {
a.market.open = true;
}),
),
// 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)),

376
src/app/market_ui.rs Normal file
View File

@ -0,0 +1,376 @@
// 市集 (plan C1, laid out like OpenBot's marketplace): one window for what can be added to the
// bots — 連接器 (MCP), 技能, Bot 範本 — as cards: a tile, the name, whose it is, one line of what
// it does, and one button at the right (加入/安裝/建立, or a grey 已加入). A row of three larger
// 精選 cards comes first while nothing is searched. The left column has a search, the three kinds
// with their counts and what is already added (a connector with a problem in red), each opening
// its own page in 設定. The buttons do what the settings pages' do (channels_ui): a connector
// that needs a key opens 新增連接器 filled in; a skill from GitHub installs in the background
// (how it went shows above the cards); a template makes the bot and opens its editor.
use super::channels_ui::Page;
use super::*;
use crate::icons::Icon;
#[derive(Default)]
pub(super) struct MarketUi {
pub open: bool,
kind: Kind,
query: String,
}
#[derive(Default, Clone, Copy, PartialEq)]
enum Kind {
#[default]
Connectors,
Skills,
Bots,
}
const KINDS: [(Kind, &str, &str); 3] = [
(Kind::Connectors, "連接器", "讓 Bot 用別的服務的工具:檔案、網頁、GitHub…(MCP)"),
(Kind::Skills, "技能", "做某件事的做法,所有 Bot 共用:要用時才讀完整的(SKILL.md)"),
(Kind::Bots, "Bot 範本", "照範本建一個新的 Bot:名字、指示、頭像都先填好,之後可以改"),
];
#[derive(Clone)]
enum Act {
Mcp(usize),
Builtin(&'static str),
Remote(&'static str),
Template(usize),
}
#[derive(Clone)]
enum Tile {
Letter(Color32),
Icon(Icon, Color32),
Face(&'static str, &'static str),
}
#[derive(Clone)]
struct Card {
name: String,
by: &'static str,
tag: &'static str,
about: String,
tile: Tile,
added: bool,
button: &'static str,
act: Act,
}
/// The tiles' colours: one per name, from the bots' own.
fn tile_colour(name: &str) -> Color32 {
let h = name.bytes().fold(7u32, |a, b| a.wrapping_mul(31).wrapping_add(b as u32));
crate::avatar::color(crate::avatar::COLORS[1 + (h as usize % (crate::avatar::COLORS.len() - 1))].0)
}
const CARD_MIN_W: f32 = 300.0;
const CARD_H: f32 = 92.0;
const TALL_H: f32 = 132.0;
impl App {
fn market_cards(&self, kind: Kind) -> Vec<Card> {
match kind {
Kind::Connectors => crate::mcp::MARKET
.iter()
.enumerate()
.map(|(i, (name, desc, _, needs))| Card {
name: name.to_string(),
by: "官方",
tag: if needs.is_empty() { "" } else { "要金鑰" },
about: desc.to_string(),
tile: Tile::Letter(tile_colour(name)),
added: self.state.mcp_servers.iter().any(|s| s.name == *name),
button: "加入",
act: Act::Mcp(i),
})
.collect(),
Kind::Skills => {
let mut v: Vec<Card> = crate::skills::BUILTIN_SKILLS
.iter()
.map(|b| Card {
name: b.slug.to_string(),
by: "內建",
tag: "",
about: if b.title == b.slug { b.summary.to_string() } else { format!("{} — {}", b.title, b.summary) },
tile: Tile::Icon(Icon::Sparkle, tile_colour(b.slug)),
added: self.state.skills.iter().any(|s| s.name == b.slug),
button: "加入",
act: Act::Builtin(b.slug),
})
.collect();
v.extend(crate::skills::REMOTE_MARKET.iter().map(|r| Card {
name: r.name.to_string(),
by: "Anthropic",
tag: "",
about: r.summary.trim_start_matches("Anthropic 官方:").to_string(),
tile: Tile::Icon(Icon::Sparkle, tile_colour(r.name)),
added: self.state.skills.iter().any(|s| s.name == r.name),
button: "安裝",
act: Act::Remote(r.source),
}));
v
}
Kind::Bots => crate::memory::TEMPLATES
.iter()
.enumerate()
.map(|(i, tp)| Card { name: tp.name.to_string(), by: "範本", tag: "", about: tp.description.to_string(), tile: Tile::Face(tp.shape, tp.color), added: false, button: "建立", act: Act::Template(i) })
.collect(),
}
}
/// The window.
pub(super) fn market_window(&mut self, ctx: &egui::Context) {
if !self.market.open {
return;
}
let p = self.pal;
let body_h = dialog_max_height(ctx) - 48.0;
let q = self.market.query.trim().to_lowercase();
let matches = |c: &Card| q.is_empty() || c.name.to_lowercase().contains(&q) || c.about.to_lowercase().contains(&q);
let counts: Vec<usize> = KINDS.iter().map(|(k, _, _)| self.market_cards(*k).iter().filter(|c| matches(c)).count()).collect();
let cards: Vec<Card> = self.market_cards(self.market.kind).into_iter().filter(|c| matches(c)).collect();
let errors: Vec<String> = self.ch.mcp_errors.lock().map(|e| e.iter().map(|(n, _)| n.clone()).collect()).unwrap_or_default();
let skill_busy = self.ch.skill_busy.load(Ordering::SeqCst);
let note = self.ch.skill_note.lock().ok().and_then(|n| n.clone());
let mut act: Option<Act> = None;
let mut go: Option<(u8, Page)> = None;
let closed = dialog(ctx, "market", "市集", 960.0, true, p, |ui| {
Frame::new().inner_margin(Margin { left: 16, right: 0, top: 10, bottom: 0 }).show(ui, |ui| {
ui.horizontal_top(|ui| {
// Left: the search, the kinds, what is added.
ui.vertical(|ui| {
ui.set_width(200.0);
ui.add(egui::TextEdit::singleline(&mut self.market.query).hint_text(t("搜尋市集")).desired_width(196.0));
ui.add_space(8.0);
for (i, (k, label, _)) in KINDS.iter().enumerate() {
let (rect, r) = ui.allocate_exact_size(vec2(196.0, 30.0), egui::Sense::click());
let on = self.market.kind == *k;
if on || r.hovered() {
ui.painter().rect_filled(rect, R_M, if on { p.active } else { p.hover });
}
ui.painter().text(rect.left_center() + vec2(10.0, 0.0), egui::Align2::LEFT_CENTER, t(label), egui::FontId::proportional(FONT_SM), p.text);
ui.painter().text(rect.right_center() - vec2(10.0, 0.0), egui::Align2::RIGHT_CENTER, counts[i].to_string(), egui::FontId::proportional(FONT_XS), p.text3);
if r.on_hover_cursor(egui::CursorIcon::PointingHand).clicked() {
self.market.kind = *k;
}
}
ui.add_space(12.0);
ui.label(RichText::new(t("已安裝")).size(FONT_XS).color(p.text3));
ui.add_space(2.0);
let row = |ui: &mut egui::Ui, name: &str, dot: Color32, sub: &str| {
let (rect, r) = ui.allocate_exact_size(vec2(196.0, 26.0), egui::Sense::click());
if r.hovered() {
ui.painter().rect_filled(rect, R_M, p.hover);
}
ui.painter().circle_filled(rect.left_center() + vec2(14.0, 0.0), 4.0, dot);
let name = super::sidebar_ui::shorten_width(ui, name, 120.0, FONT_SM);
ui.painter().text(rect.left_center() + vec2(26.0, 0.0), egui::Align2::LEFT_CENTER, name, egui::FontId::proportional(FONT_SM), p.text);
ui.painter().text(rect.right_center() - vec2(10.0, 0.0), egui::Align2::RIGHT_CENTER, t(sub), egui::FontId::proportional(FONT_XS), p.text3);
r.on_hover_cursor(egui::CursorIcon::PointingHand).clicked()
};
let mut shown = 0;
for s in &self.state.mcp_servers {
let bad = errors.contains(&s.name);
if row(
ui,
&s.name,
if bad {
p.danger
} else if s.enabled {
p.up
} else {
p.text3
},
if bad { "有問題" } else { "連接器" },
) {
go = Some((1, Page::Item(s.name.clone())));
}
shown += 1;
}
for s in self.state.skills.iter().take(8) {
if row(ui, &s.name, p.text3, "技能") {
go = Some((2, Page::Item(s.name.clone())));
}
shown += 1;
}
if self.state.skills.len() > 8 {
let more = format!("{} {}", t("還有"), self.state.skills.len() - 8);
if row(ui, &more, Color32::TRANSPARENT, "技能") {
go = Some((2, Page::List));
}
}
if shown == 0 {
hint(ui, "還沒有加入任何東西", p);
}
});
ui.add_space(12.0);
// Right: what this kind is, then the cards. (Given its height: a column in a row
// only gets the row's.)
ui.allocate_ui_with_layout(vec2(ui.available_width(), body_h - 20.0), Layout::top_down(Align::Min), |ui| {
ui.set_min_height(body_h - 20.0);
let (_, label, about) = KINDS.iter().find(|(k, _, _)| *k == self.market.kind).copied().unwrap_or(KINDS[0]);
Frame::new().inner_margin(Margin { left: 20, right: 20, top: 0, bottom: 0 }).show(ui, |ui| {
ui.label(RichText::new(t(label)).size(FONT_H3).family(crate::bold()).color(p.text));
ui.label(RichText::new(t(about)).size(FONT_SM).color(p.text2));
if self.market.kind == Kind::Skills {
if skill_busy {
ui.label(RichText::new(t("正在安裝技能…")).size(FONT_SM).color(p.text2));
} else if let Some((ok, words)) = &note {
ui.label(RichText::new(words).size(FONT_SM).color(if *ok { p.up } else { p.danger }));
}
}
});
// The cards get the rest of the column (the note above can add a line).
let rest = (ui.available_height() - 12.0).max(120.0);
dialog_body(ui, "market-body", rest, |ui| {
if cards.is_empty() {
hint(ui, "沒有符合的項目", p);
return;
}
let avail = ui.available_width();
if q.is_empty() && cards.len() > 3 {
ui.label(RichText::new(t("精選")).size(FONT_SM).family(crate::bold()).color(p.text2));
ui.add_space(4.0);
let w = ((avail - 20.0) / 3.0).floor();
// What isn't added yet first: nothing to do on a 已加入 one.
let mut featured: Vec<&Card> = cards.iter().filter(|c| !c.added).chain(cards.iter().filter(|c| c.added)).collect();
featured.truncate(3);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 10.0;
for c in featured {
if self.market_card(ui, c, w, true, skill_busy) {
act = Some(c.act.clone());
}
}
});
ui.add_space(14.0);
ui.label(RichText::new(t("全部")).size(FONT_SM).family(crate::bold()).color(p.text2));
ui.add_space(4.0);
}
let cols = ((avail + 10.0) / (CARD_MIN_W + 10.0)).floor().max(1.0) as usize;
let w = ((avail - 10.0 * (cols - 1) as f32) / cols as f32).floor();
for chunk in cards.chunks(cols) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 10.0;
for c in chunk {
if self.market_card(ui, c, w, false, skill_busy) {
act = Some(c.act.clone());
}
}
});
ui.add_space(10.0);
}
});
});
});
});
});
if let Some(a) = act {
self.market_act(ctx, a);
}
if let Some((sub, page)) = go {
self.market.open = false;
self.show_settings = true;
self.settings_tab = SettingsTab::Channels;
self.ch.sub = sub;
if sub == 1 {
self.ch.mcp_page = page;
} else {
self.ch.skill_page = page;
}
}
if closed {
self.market.open = false;
}
}
/// What a card's button does.
fn market_act(&mut self, ctx: &egui::Context, a: Act) {
match a {
Act::Mcp(i) => {
let (name, _, cmd, needs) = crate::mcp::MARKET[i];
// One that needs a key: its form, in 設定, filled in.
if self.mcp_market_add(name, cmd, needs) {
self.market.open = false;
self.show_settings = true;
self.settings_tab = SettingsTab::Channels;
self.ch.sub = 1;
}
}
Act::Builtin(slug) => self.skill_add_builtin(slug),
Act::Remote(src) => self.skill_install(src.to_string(), ctx),
Act::Template(i) => {
let tp = &crate::memory::TEMPLATES[i];
let id = self.state.next_id;
let sel = self.state.selected;
let _ = crate::appctl::apply(&mut self.state, sel, "create_bot", &serde_json::json!({"template": tp.name}).to_string());
if self.state.bot(id).is_some() {
self.state.selected = id;
self.edit_bot = self.state.bot(id).cloned().map(|b| (b, false));
self.market.open = false;
}
self.mark();
}
}
}
/// One card; true when its button was pressed. `tall`: a 精選 one — the tile on top, two lines
/// of what it does.
fn market_card(&mut self, ui: &mut egui::Ui, c: &Card, w: f32, tall: bool, busy: bool) -> bool {
let p = self.pal;
let h = if tall { TALL_H } else { CARD_H };
let (rect, _) = ui.allocate_exact_size(vec2(w, h), egui::Sense::hover());
ui.painter().rect_filled(rect, R_L, p.elevated);
ui.painter().rect_stroke(rect, R_L, Stroke::new(1.0, p.border), egui::StrokeKind::Inside);
let pad = 14.0;
let tile = egui::Rect::from_min_size(rect.min + vec2(pad, pad), vec2(40.0, 40.0));
match &c.tile {
Tile::Letter(col) | Tile::Icon(_, col) => {
ui.painter().rect_filled(tile, R_M, col.gamma_multiply(0.16));
if let Tile::Icon(icon, _) = &c.tile {
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(tile.center(), vec2(20.0, 20.0)), *icon, *col);
} else {
let letter: String = c.name.chars().next().map(|ch| ch.to_uppercase().collect()).unwrap_or_default();
ui.painter().text(tile.center(), egui::Align2::CENTER_CENTER, letter, egui::FontId::new(FONT_H3, crate::bold()), *col);
}
}
Tile::Face(shape, colour) => crate::avatar::paint(ui.painter(), tile, shape, crate::avatar::color(colour)),
}
// The button, top right.
let btn = egui::Rect::from_min_size(egui::pos2(rect.right() - pad - 64.0, rect.top() + pad + 5.0), vec2(64.0, 30.0));
let mut pressed = false;
if c.added {
ui.painter().text(btn.center(), egui::Align2::CENTER_CENTER, t("已加入"), egui::FontId::proportional(FONT_XS), p.text3);
} else {
// (One skill installs at a time.)
let enabled = !(busy && matches!(c.act, Act::Remote(_)));
// (In a child: `put` would move the row's cursor and push the next card away.)
let mut at = ui.new_child(egui::UiBuilder::new().max_rect(btn).layout(Layout::centered_and_justified(egui::Direction::TopDown)));
pressed = at.add_enabled(enabled, secondary_button(c.button)).on_disabled_hover_text(t("正在安裝另一個技能")).clicked();
}
// Name and whose: beside the tile (a compact card), under it (a tall one).
let (x, y) = if tall { (rect.left() + pad, tile.bottom() + 8.0) } else { (tile.right() + 12.0, rect.top() + pad + 2.0) };
let name_w = if tall { w - 2.0 * pad } else { btn.left() - 10.0 - x };
let name = super::sidebar_ui::shorten_width(ui, &c.name, name_w, FONT_BASE);
let name_g = ui.painter().layout_no_wrap(name, egui::FontId::new(FONT_BASE, crate::bold()), p.text);
let name_end = x + name_g.size().x;
ui.painter().galley(egui::pos2(x, y), name_g, p.text);
let by = if c.tag.is_empty() { t(c.by) } else { format!("{} · {}", t(c.by), t(c.tag)) };
if tall {
ui.painter().text(egui::pos2(name_end + 8.0, y + 3.0), egui::Align2::LEFT_TOP, by, egui::FontId::proportional(FONT_XS), p.text3);
} else {
ui.painter().text(egui::pos2(x, y + 22.0), egui::Align2::LEFT_TOP, by, egui::FontId::proportional(FONT_XS), p.text3);
}
// What it does: one line under the tile (compact), two under the name (tall).
let about_y = if tall { y + 24.0 } else { tile.bottom() + 10.0 };
let mut job = egui::text::LayoutJob::simple(c.about.clone(), egui::FontId::proportional(FONT_SM), p.text2, w - 2.0 * pad);
job.wrap = egui::text::TextWrapping { max_width: w - 2.0 * pad, max_rows: if tall { 2 } else { 1 }, break_anywhere: true, overflow_character: Some('…') };
let g = ui.painter().layout_job(job);
ui.painter().galley(egui::pos2(rect.left() + pad, about_y), g, p.text2);
// Everything it says, under the pointer.
ui.interact(rect, egui::Id::unique(("market-card", &c.name)), egui::Sense::hover()).on_hover_text(format!("{}\n{}", c.name, c.about));
pressed
}
}

View File

@ -288,11 +288,9 @@ impl App {
if pill_icon(ui, crate::icons::Icon::Upload, p).on_hover_text(t("傳送檔案或文字到其他裝置")).clicked() { if pill_icon(ui, crate::icons::Icon::Upload, p).on_hover_text(t("傳送檔案或文字到其他裝置")).clicked() {
self.open_drops(); self.open_drops();
} }
if pill_icon(ui, crate::icons::Icon::Apps, p).on_hover_text(t("連接器市集")).clicked() { // 市集: connectors, skills and bot templates (market_ui.rs).
self.show_settings = true; if pill_icon(ui, crate::icons::Icon::Apps, p).on_hover_text(t("市集:連接器、技能、Bot 範本")).clicked() {
self.settings_tab = SettingsTab::Channels; self.market.open = true;
self.ch.mcp_page = super::channels_ui::Page::Market;
self.ch.sub = 1;
} }
}); });
// A newer build is in place: one row across the sidebar, never wider — with the // A newer build is in place: one row across the sidebar, never wider — with the