diff --git a/FEATURES.md b/FEATURES.md index 8990ca7..5c5bca1 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -138,7 +138,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。 - 找的範圍:每個 Bot 目前的對話和「過去的對話」裡,你和 Bot 說的話,以及附加檔案的檔名(標「檔案:」)。工具的結果和摘要不找(讀過一次的網頁會把別的都蓋掉)。不分大小寫。 - 每一筆兩行:Bot 的名字(在過去的對話裡的加「· 過去的對話」)和時間(「剛剛」「昨天 09:33」「11/3」),下面是那句話裡相符處前後的一行,你說的前面加「你:」。最新的在最上面,最多列 40 筆,超過會提示多打幾個字。 - 點一筆:打開那個 Bot,聊天捲到那則訊息,並用黃色亮一下(約 1.8 秒淡掉)。在過去的對話裡的,會先把那段對話換回來(目前的對話收進「過去的對話」最上面);那個 Bot 正在工作時不換,改提示「「(名字)」正在工作。等它做完,再打開過去的對話。」 -- 連到別台大腦的電腦上也能用(找的是大腦的聊天)。手機版還沒有。 +- 連到別台大腦的電腦上也能用(找的是大腦的聊天)。手機一樣有(擁有者):首頁放大鏡打字,相符的 Bot 在上,下面「聊天裡」列訊息和檔名(含過去的對話);點一筆打開那個聊天,捲到那則訊息亮一下(太早、手機沒留的會說);過去的對話先問要不要換回來。 ### 任務(2026-11-20) @@ -1589,6 +1589,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) - **活動**:一年的熱度格子(53 週,一週一欄、週日在上),依最忙那天分四級深淺,沒有用量只有訊息的那天照訊息算;滑過看「2026年11月20日:3,610 token、12 則訊息」。圖例旁邊一行「最活躍:11月20日・3,610 token」。 - **用量**:7 天/30 天/90 天/一年。一個大數字 token(滑過看新讀、寫、快取讀到),下面一行呼叫次數、花費——只算模型服務自己回報的(例如 OpenRouter),沒回報的寫「未定價」(部分有部分沒有:「US$0.97(另有 694 次呼叫未定價)」),不是 0 元;每天一條長條(滑過看數字,那條變深);再用「依模型/依 Bot」切換:依模型是一條彩色比例條,下面每個模型一列(服務的圖案、色點、名字、token・百分比),依 Bot 每列是頭像、名字、細長條、token・百分比(前 8 名,發布前檢查、目標檢查各自一列,刪掉的 Bot 寫「Bot 9(已刪除)」)。 - 都從已經有的紀錄算(`usage/YYYY-MM.jsonl` 和每則訊息的時間),不另外存;用大腦的時區切日子;打開時在背景算,一分鐘內再看不重算。螢幕電腦向大腦要(`api/sync/stats`),手機用 `api/stats`(擁有者才有)。 +- 手機:設定 ›「個人資料與用量」(擁有者才有),同一套:四個大數字一條、一年的熱度點(點一下看那天)、用量的期間切換、大數字、每天的長條、依模型(彩色比例條)/依 Bot(頭像和長條)。 ### 所有檔案(側邊欄的資料夾按鈕) @@ -2320,6 +2321,8 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) - 保險庫:只說明,不傳任何密碼到手機; - 手機與帳號:直接連線的手機清單,可以登出別支手機; - 更新:版本和有沒有新版。 + - 個人資料與用量:見「個人資料與用量」。 +- 手機補上的(以前只有電腦有):搜尋聊天裡的訊息和檔名;Bot 設定的「執行步驟用的模型」「思考模式」;釘選的 Bot 在 ⋯ ›「更多…」往前、往後移,分區的 ⋯「往上移/往下移」;「匯出 Bot 檔案(.anybot)」「匯出文字記錄(.md)」「匯入 Bot 檔案」(iPhone 跳分享選單,可以存到「檔案」或 AirDrop);每個 Bot 各自的草稿(切換 Bot、關掉頁面都留著,存在這支手機);程式碼塊右上的「複製」;頁面 ⋯ 的「存成檔案(.md)」。 - 看電腦畫面: - 「Bot 的電腦」每秒更新一次畫面;在休眠時按「叫醒」。 - 「這台 Mac」要先在設定裡打開才會出現。 diff --git a/docs/feature-map/bots.md b/docs/feature-map/bots.md index 716a430..29aa51a 100644 --- a/docs/feature-map/bots.md +++ b/docs/feature-map/bots.md @@ -6,8 +6,8 @@ - `bots-sidebar` 側邊欄:最上面是主要 Bot(大頭像),接著是釘選的格子(把 Bot 拖進去就釘選,格子裡可以拖曳排序),再來是各分區和「未分區」(分區見 [team](team.md))。每一列第二行是「正在工作…」「需要你允許」「等你回答」「等你處理」,或最後一則訊息。選中的 Bot 整列淺底(比滑過深一階),左邊沒有色條。 - `bots-moods` 頭像的表情:側邊欄、釘選格子、右側面板和任務卡上的 Bot 頭像跟輸入框上方那張臉一樣看狀態——等你允許或回答時往上看你;上網時眼睛左右掃,看畫面時往右上看,寫字時往下看,想事情或讀回來的結果時往左上看,其他步驟慢慢左右讀;做事時微微呼吸(2.6 秒一次);上一輪失敗是兩條平的眼睛,剛做完笑兩秒;閒著時眼睛跟著滑鼠。做事時一個樣子至少停 1.4 秒,步驟換得快也不會一直閃。設定 › 一般 › 更多外觀設定 ›「頭像動態」選「減少」(「自動」在畫面用 CPU 畫的電腦上也是)只換表情、不動([appearance](appearance.md))。 -- `bots-search` 搜尋「搜尋 Bot 和訊息」:上面列名字或描述相符的 Bot,下面「訊息」列你和 Bot 說過的話和附件檔名(含過去的對話,最多 40 筆),點一筆就捲到那則訊息。按 🔍 或 ⌘F 打開時游標在搜尋框;之後點輸入框打字,字就留在輸入框(搜尋框開著也不會把游標搶回去)。 -- `bots-menu` Bot 選單:「釘選」/「取消釘選」、「移至」、「標示為已讀」/「標示為未讀」、「設為主要 Bot」、「編輯 Bot…」、「記憶…」、「開始新對話」、「過去的對話」、「分享與匯出」(「匯出 Bot(分享給別人)…」「匯出文字記錄…」「匯入 Bot…」「複製對話 ID」)、「重新啟動這個 Bot」、「清除聊天記錄」、「刪除」。 +- `bots-search` 搜尋「搜尋 Bot 和訊息」:上面列名字或描述相符的 Bot,下面「訊息」列你和 Bot 說過的話和附件檔名(含過去的對話,最多 40 筆),點一筆就捲到那則訊息。手機一樣:Bot 在上,下面「聊天裡」列訊息和檔名(擁有者),點一筆打開那個聊天、捲到那則亮一下,過去的對話先問要不要換回來。按 🔍 或 ⌘F 打開時游標在搜尋框;之後點輸入框打字,字就留在輸入框(搜尋框開著也不會把游標搶回去)。 +- `bots-menu` Bot 選單:「釘選」/「取消釘選」、「移至」、「標示為已讀」/「標示為未讀」、「設為主要 Bot」、「編輯 Bot…」、「記憶…」、「開始新對話」、「過去的對話」、「分享與匯出」(「匯出 Bot(分享給別人)…」「匯出文字記錄…」「匯入 Bot…」「複製對話 ID」)、「重新啟動這個 Bot」、「清除聊天記錄」、「刪除」。手機:⋯ ›「更多…」有「釘選裡往前移/往後移」「匯出 Bot 檔案(.anybot)」,聊天的 ⋯ 有「匯出文字記錄(.md)」,首頁 + 有「匯入 Bot 檔案」,分區的 ⋯ 有「往上移/往下移」。 - `bots-create` 建立:「新增 Bot」,或「從範本建立」(研究助理、寫作夥伴、電腦助手、客服助理、開發助手)。新 Bot 沿用目前選中 Bot 的供應商和模型,電腦工具關著。 - `bots-chat` 在聊天裡請 Bot:列出所有 Bot(`list_bots`)、建 Bot(`create_bot`,不用問)、改名稱等(`update_bot`,先跳確認卡片)。 @@ -29,6 +29,7 @@ - **建 Bot**(covers `bots-create`):+ ›「建立 Bot」打名字;再從範本建一個。指令:`$CTL phone click '[data-back]' && $CTL phone click '#b-newbot' && $CTL phone click '#sheet-in .opt' --text '建立 Bot' && $CTL phone type '#ask-in' '研究員' && $CTL phone click '#ask-ok' && $CTL phone wait-text 研究員 --in '#isl-name' && $CTL phone click '[data-back]' && $CTL phone click '#b-newbot' && $CTL phone click '#sheet-in .opt' --text 從範本建立 && $CTL phone wait-text 開發助手 --in '#sheet-in' && $CTL phone click '#sheet-in .opt' --text 寫作夥伴 && $CTL phone wait-text 寫作夥伴 --in '#isl-name' && $CTL state '[.bots[] | {id, name, provider, model, tools_enabled}]'`。看到:範本有研究助理、寫作夥伴、電腦助手、客服助理、開發助手;建好就打開它的聊天;兩個新 Bot 都是 Custom · fake-model,tools_enabled false。 - **Bot 自己建、列出**(covers `bots-chat`):指令:`$CTL phone click '[data-back]' && $CTL phone click '.row[data-bot="1"]' && $CTL phone send '建 [[call create_bot {"template":"研究助理"}]]' && $CTL wait-api '/api/state?since=0' '.bots | length == 4' && $CTL phone send '列出 [[call list_bots {}]]' && $CTL wait-api /api/bots/1 '[.messages[].tools[]? | select(.name == "list_bots" and .status == "done")] | length == 1' && $CTL api GET /api/bots/1 --jq '[.messages[].tools[]? | select(.name == "list_bots") | .result]'`。看到:沒跳卡片就建好研究助理;清單一行一個 Bot(供應商 · 模型,主要 Bot 標出來、「就是你」)。 - **搜尋**(covers `bots-search`):首頁放大鏡打「研究」。指令:`$CTL phone click '[data-back]' && $CTL phone click '#b-search' && $CTL phone type '#search' '研究' && $CTL phone wait-gone '.row[data-bot="1"]' && $CTL phone wait '.row[data-bot="2"]' && $CTL phone shot bots-search && $CTL phone click '#b-search-x' && $CTL phone wait '.row[data-bot="1"]'`。看到:只剩名字或描述含「研究」的(研究員、研究助理);✕ 清掉回到全部。 +- **手機搜尋聊天裡、排序、匯出**(covers `bots-search`、`bots-menu`):指令:`$CTL phone click '.row[data-bot="1"]' && $CTL phone send '週末想去台南玩' && $CTL phone wait-text '台南' --in '#msgs' && $CTL phone click '[data-back]' && $CTL phone click '#b-search' && $CTL phone type '#search' '台南' && $CTL phone wait '[data-hit="0"]' && $CTL phone click '[data-hit="0"]' && $CTL phone wait '#msgs .lit' && $CTL phone click '#b-chatmore' && $CTL phone click '#sheet-in .opt' --text '匯出文字記錄' && $CTL phone wait-text '已存成' --in '#toast'`。看到:「聊天裡」兩筆(你的話和回答),點了打開聊天、那則亮一下;「已存成「… 對話.md」」。 - **選單**(covers `bots-menu`、`bots-sidebar`):研究員那列「⋯」› 釘選、「更多…」› 標示為未讀;寫作夥伴 ›「刪除 Bot」。指令:`$CTL phone click '[data-botmenu="2"]' && $CTL phone click '#sheet-in .opt' --text 釘選 && $CTL phone wait-text '已釘選的 Bot' --in '#home' && $CTL phone click '[data-botmenu="2"]' && $CTL phone click '#sheet-in .opt' --text 更多 && $CTL phone click '#sheet-in .opt' --text 標示為未讀 && $CTL wait-api '/api/state?since=0' '.bots[] | select(.name == "研究員") | .pinned and .unread' && $CTL phone click '[data-botmenu="3"]' && $CTL phone click '#sheet-in .opt' --text '刪除 Bot' && $CTL phone wait-text '此操作無法復原' --in '#sheet-in' && $CTL phone click '#sheet-in .opt' --text 刪除 && $CTL wait-api '/api/state?since=0' '[.bots[].name] | index("寫作夥伴") == null' && $CTL phone shot bots-menu`。看到:研究員移到「已釘選的 Bot」、有未讀的點;刪除先問「這會刪除它和它的聊天記錄。此操作無法復原。」,刪掉後清單和大腦都沒有它。 - **重開還在**(covers `bots-create`、`bots-sidebar`):指令:`$CTL restart && $CTL phone open --listed && $CTL phone wait-text '已釘選的 Bot' --in '#home' && $CTL state '[.bots[] | {name, pinned}]'`。看到:小幫手二號、研究員(還是釘選)、研究助理都還在。 - **桌面**(covers `bots-sidebar`、`bots-search`、`bots-menu`、`bots-create`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot bots-find ANYBOT_SHOT_VIEW=find ANYBOT_SHOT_FIND=台南`。看到:搜尋下面「訊息」列說過的話(含過去的對話);選中那列淺底、沒有色條;釘選格子的拖曳、桌面的選單項目(分享與匯出…)、「建立 Bot」視窗(填 Soul 與指示、擅長,名字或模型空白按不下去)靠自動測試。 diff --git a/docs/feature-map/pages.md b/docs/feature-map/pages.md index 118880c..d1e63c9 100644 --- a/docs/feature-map/pages.md +++ b/docs/feature-map/pages.md @@ -17,7 +17,7 @@ Bot 把要追蹤、整理、比較的事寫成一頁,之後一直更新同一 - 回覆裡的 [標題](page:ID) 連結,和回覆下面的頁面卡片(電腦版一張精簡卡:頁面圖示、標題一次、一行它說什麼——更新過的是「已更新:改了什麼」,否則是現況那句——和一行灰字「種類 · 頁面 · 時間 · 第 N 版」;手機是標題、幾行預覽和「頁面 · 時間 · 已更新」):點一下打開。一個回覆裡每一頁只出一張卡,在最後存那一頁的步驟下面(被退回再存、或存了又更新,都不會重複);沒存成的(別的 Bot 的頁面被擋、被退回那一次)不出卡。 - 右側面板的「資料庫」分頁,最上面的「頁面」:這個 Bot 的頁面,最近改過的在前面。 - 打開的頁面下方左邊「版本紀錄」(看舊版時有「回到最新版」)和「刪除」(按兩次),右邊「複製」(Markdown)、「存成檔案」(存成 .md 到「下載」)、「完成」。 -- 手機:首頁上面一排的「頁面」列出所有頁面;聊天裡的頁面卡片;打開的頁面的「⋯」有「複製 Markdown」「其他版本」,一條細線下面才是「刪除頁面」。 +- 手機:首頁上面一排的「頁面」列出所有頁面;聊天裡的頁面卡片;打開的頁面的「⋯」有「複製 Markdown」「存成檔案(.md)」「其他版本」,一條細線下面才是「刪除頁面」。 ## 怎麼操作(verify-anybot) diff --git a/docs/feature-map/phone.md b/docs/feature-map/phone.md index 67aaec6..5e93af0 100644 --- a/docs/feature-map/phone.md +++ b/docs/feature-map/phone.md @@ -4,13 +4,13 @@ ## 子功能 -- `phone-pages` 頁面:Bot 清單(分區、工作中/等你)、聊天(附檔、拍照、語音輸入、插話、停止;叫醒 Bot 的訊息上方標是什麼叫醒的:目標、例行任務、觸發、訊息管道、來自其他 Bot、監看)、允許請求卡片(「一律允許」「允許一次」、「這輪都准」(智慧模式,一直開著;它是主按鈕)、「拒絕」、「全部允許,之後直接操作」;卡片太高時卡在內面自己捲,輸入框不會被頂出螢幕)、問題卡、「需要處理」與接管、Bot 設定、例行任務(詳細頁有最近幾次執行和送出證據)、頁面、記憶、檔案預覽、Bot 的電腦畫面、設定(一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新,能改的比電腦少;開著的設定頁跟著電腦那邊的改變重讀,不用重新整理;直接連線只能收緊、不能放寬,見 [autonomy](autonomy.md))、傳送到其他裝置。智慧模式一直開著,輸入列沒有它的晶片。 +- `phone-pages` 頁面:Bot 清單(分區、工作中/等你)、聊天(附檔、拍照、語音輸入、插話、停止;叫醒 Bot 的訊息上方標是什麼叫醒的;各 Bot 自己的草稿;程式碼塊的「複製」)、允許請求卡片(「一律允許」「允許一次」、「這輪都准」(智慧模式,一直開著;它是主按鈕)、「拒絕」、「全部允許,之後直接操作」;卡片太高時卡在內面自己捲,輸入框不會被頂出螢幕)、問題卡、「需要處理」與接管、Bot 設定、例行任務(詳細頁有最近幾次執行和送出證據)、頁面、記憶、檔案預覽、Bot 的電腦畫面、設定(一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新,能改的比電腦少;開著的設定頁跟著電腦那邊的改變重讀,不用重新整理;直接連線只能收緊、不能放寬,見 [autonomy](autonomy.md))、傳送到其他裝置。智慧模式一直開著,輸入列沒有它的晶片。 - `phone-cards` 手機上的卡(允許、需要處理、問題卡)只答它畫出來的那一張:那張已經在電腦或另一支手機上回答、被停止、或換成下一張時,按了不算,聊天裡寫「手機上的回答沒有用上…」;開了很久沒重新整理的舊頁面也一樣。螢幕電腦上的卡也是;比大腦舊的螢幕電腦答不了任何卡,要在那台 設定 › 更新 換新版(重新整理沒用)。支線的卡沒用上時,寫在主線的聊天。 - `phone-look` 長相(和電腦版同一份設計規格:字級、間距、圓角都是同一組數字):Bot 的回答不放在泡泡裡,像文件一樣直接排在畫面上,跟介面同一種字(iPhone 是 SF Pro 加蘋方)、16px、行距寬;裡面的表格只有橫向細線、數字欄靠右,提示框([!NOTE] 等)同一種淡底、只有圖示依種類上色,程式碼是淡底圓角塊。標題用半粗體。手機沒有字型選項。 - `phone-colors` 顏色跟電腦版一樣:電腦上 設定 › 一般 › 外觀 的主題(淺色/深色/跟隨系統)、底色、強調色、對比,手機照著穿;手機自己的「外觀」可以選「跟著電腦」(預設)、「跟著手機」、「淺色」、「深色」。狀態列的顏色跟著畫面。舊版的電腦沒送顏色時,手機用內建的「紙」。 - `phone-claude` 像 Claude 的手機 App:上面一條簡單的標題列(Bot 名稱,第二行是它在做什麼或用哪個模型),輸入框是底部一張圓角卡片,回答下面只有時間和複製/重新產生/⋯;按鈕和點的地方至少 44px;清單每列的說明只有一行(太長以 … 結尾);顏色少,強調色只用在連結、選取和新訊息的點。 - `phone-net` 網路慢或斷線都不擋操作:存過這台電腦的資料,打開 App 就用上次的內容進去,不等網路,連上後只補變了的;浮著提示「離線中:顯示的是上次的內容」,拿到就消失。只有第一次(還沒有這台的資料)停在連線畫面:打開 App 時的頭像留在正中間呼吸、外圈漾開,不顯示文字(讀螢幕軟體唸「正在連線」;減少動態時不動),第一份狀態到手才進去。用帳號連、那台不在線上時留在它上次的內容裡,不換到別台。進去之後斷線:浮「連線中斷,正在重新連線…」,自己重試,回到前景或網路恢復時立刻重連。設定、詳細、例行任務先畫手上有的,背景讀新的;要改的先讀到最新的。傳訊息不等網路:按下就出現在聊天裡;連不上標「等連線後送出(點一下拿回來)」,存手機排隊(關 App 也還在),連上後照順序自己送、不限時間,同一則只送一次;點一下連同附件拿回輸入框;連不上時選的附件也排隊。大腦拒收的才標「沒送出,點一下拿回來重送」。從通知打開時按的允許/拒絕等連上才送。只傳有變的部分、文字壓縮;Bot 回答中手機每秒最多更新一次聊天(見 [chat](chat.md) 的開聊天分頁)。頁面和圖示存在手機上:打開直接用,背景問一次換版沒;換了,還在連線畫面就重新載入,已進去就等退到背景、手上沒東西(沒打字、附件、排隊、錄音、選單)才換;重新整理一定先問伺服器。上次的狀態、看過的聊天(合計最多 12 個)、詳細資料、設定、排隊的訊息每台電腦各自存在這個網址的儲存空間,登出(或登入失效)全部清掉。 -- `phone-app` 像 App 一樣:加入主畫面後全螢幕、沒有網址列(瀏海、動態島、底部手勢條、橫放都避開);首頁會提示「把 AnyBot 裝成 App」(Android 直接安裝,iPhone 教你加入主畫面,可以關掉);換畫面會左右滑動;iPhone 主畫面 App 從左邊緣往右滑回上一頁。 +- `phone-app` 像 App 一樣:加入主畫面後全螢幕、沒有網址列(避開瀏海和手勢條);首頁會提示「把 AnyBot 裝成 App」(Android 直接安裝,iPhone 教你加入主畫面,可以關掉);換畫面會左右滑動;iPhone 主畫面 App 從左邊緣往右滑回上一頁。 ## 使用者怎麼到 diff --git a/docs/feature-map/profile.md b/docs/feature-map/profile.md index 52ba8ad..d9d5e65 100644 --- a/docs/feature-map/profile.md +++ b/docs/feature-map/profile.md @@ -13,7 +13,7 @@ - Bot 選單(右鍵側邊欄的 Bot,或聊天右上角「更多」)›「編輯 Bot…」;或在右側面板點 Bot 的大頭像。視窗第一張卡是「Bot 資料」(頭像、名稱、描述),和下面的卡片同一種排版。 - 在聊天裡請 Bot 改自己(「把你的檔案與指令能力關掉」)。 -- 手機:聊天標題 › 對話詳細資訊 › 右上角「Bot 設定」,沒有自訂色盤([phone](phone.md))。 +- 手機:聊天標題 › 對話詳細資訊 › 右上角「Bot 設定」,沒有自訂色盤([phone](phone.md));「AI 與電腦」有「執行步驟用的模型」(自動/不分開/同一家的其他模型)和「思考模式」(自動、快速、平衡、深入),跟電腦一樣。 ## 怎麼操作(verify-anybot) diff --git a/docs/feature-map/settings.md b/docs/feature-map/settings.md index f7b04cf..1d0d28c 100644 --- a/docs/feature-map/settings.md +++ b/docs/feature-map/settings.md @@ -11,7 +11,7 @@ - Bot:時區,例行任務和提醒用([routines](routines.md))。 - 帳戶:「登入」或「管理帳戶」打開「手機與帳號」頁;資料放在哪。 - `settings-whose` 左下角(你的名字):名字下面一行寫 Bot 在哪一台——「這台電腦」,或「大腦「名字」」(綠點連得到、灰點連不到)。點一下開「Bot 在哪一台」選單:「這台電腦(這台的名字)」、帳號裡每台可以當大腦的電腦(現在用的打勾,離線的灰、不能點),點一下就換——跟「手機與帳號」頁大腦那一欄的「改用它當大腦」「改回用這台自己的 Bot」一樣([account](account.md));沒登入帳號多一行「登入帳號,才能換到別台大腦…」;分隔線下「所有檔案…」([library](library.md))、「個人資料與用量…」、「設定…」(⌘, 也可以)。 -- `settings-me` 「個人資料」:名字、過去一年有幾個活躍日;一條沒有框的數字列——Token・一年(不算快取命中)、訊息・一年、連續使用(今天還沒用不算斷)、最長連續,細節在滑過;「活動」一年的熱度格子(一週一欄、越忙顏色越深,滑過看日期、token、訊息數),旁邊一行「最活躍:日期・token」;「用量」選 7 天/30 天/90 天/一年:一個大數字 token(滑過看新讀、寫、快取讀到)、呼叫次數和花費(模型服務回報的,沒回報寫「未定價」,不是 0 元)、每天一條長條,再切「依模型」(一條彩色比例條,每個模型有服務的圖案)或「依 Bot」(頭像和長條),各寫 token 和百分比。左下角選單也有「個人資料與用量…」。螢幕電腦上算的是大腦的(向大腦要);手機和螢幕的路是 `api/stats`、`api/sync/stats`(擁有者才有)。 +- `settings-me` 「個人資料」:名字、過去一年有幾個活躍日;一條沒有框的數字列——Token・一年(不算快取命中)、訊息・一年、連續使用(今天還沒用不算斷)、最長連續,細節在滑過;「活動」一年的熱度格子(一週一欄、越忙顏色越深,滑過看日期、token、訊息數),旁邊一行「最活躍:日期・token」;「用量」選 7 天/30 天/90 天/一年:一個大數字 token(滑過看新讀、寫、快取讀到)、呼叫次數和花費(模型服務回報的,沒回報寫「未定價」,不是 0 元)、每天一條長條,再切「依模型」(一條彩色比例條,每個模型有服務的圖案)或「依 Bot」(頭像和長條),各寫 token 和百分比。左下角選單也有「個人資料與用量…」。手機 設定 ›「個人資料與用量」同一套(擁有者才有)。螢幕電腦上算的是大腦的(向大腦要);手機和螢幕的路是 `api/stats`、`api/sync/stats`(擁有者才有)。 - `settings-search` 「搜尋設定…」(左欄最上面):打字時頁面清單換成符合的設定(最多 12 個),標題開頭相符的在前,再來標題包含的,再來所在區塊或別的說法(「深色」找到「主題」、「billing」找到「用量」;模型供應商用名字找);每個下面寫在哪(「一般 › Bot」)。點一個或按 Enter 拿第一個:換到那一頁(整合的小分頁、市集、收起來的「更多外觀設定」會跟著打開)、捲到那一列,外框用強調色亮一下(約 2 秒淡掉);Esc 清空。 - `settings-account` 「手機與帳號」頁(從 一般 › 帳戶 進去,[account](account.md)):「AnyBot 帳號」(登入、備份、還原)、大腦和「加一台電腦」([computers](computers.md))、「同一個網路直接連」、「手機可以做什麼」、「直接連線的裝置」、「分享給團隊」([team](team.md))、「帳號裡的電腦」。 - `settings-models` 「模型」:先是每家 AI 供應商一塊圖塊(自己的圖案、名字、「可以用」或「還沒設定」、雲端/本機),點一塊進去、上面「‹ 模型」回來;裡面是 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([models](models.md));本機或區網的供應商多「看不到圖時,請雲端模型看截圖和附件」(預設關,[chat](chat.md))。「ChatGPT 方案」沒有金鑰和網址欄,改成「ChatGPT 帳號」:登入狀態、「使用 ChatGPT 繼續」「登出」「換帳號」「打開登入頁」「管理用量」;連到別台大腦時多一格貼回登入網址和「完成登入」。 diff --git a/mobile/index.html b/mobile/index.html index 21e1318..3b0b2e4 100644 --- a/mobile/index.html +++ b/mobile/index.html @@ -165,6 +165,9 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)} .tk-a :is(h2,h3,h4){font-size:var(--fs-ui);margin:.8em 0 .3em} :is(.bub,.page,.tk-a) code{font-family:var(--mono);font-size:var(--fs-small);background:var(--hover);padding:1px 5px;border-radius:var(--r-s)} :is(.bub,.page,.tk-a) pre{margin:0 0 .75em;padding:var(--sp-3) var(--sp-4);border-radius:var(--r-m);background:var(--hover);overflow-x:auto;font:var(--fs-small)/1.55 var(--mono)} +/* 複製程式碼: a small button on each code block (the whole message's 複製 is in its menu). */ +pre.cb{position:relative} +pre.cb .cpy{position:absolute;top:4px;right:4px;width:30px;height:30px;border-radius:var(--r-s);display:grid;place-items:center;color:var(--text3);background:var(--elev);opacity:.85} :is(.bub,.page,.tk-a) pre code{background:none;padding:0;border-radius:0;font:inherit} :is(.bub,.page,.tk-a) blockquote{margin:0 0 .75em;padding-left:var(--sp-3);border-left:2px solid var(--line);color:var(--text2)} :is(.bub,.page,.tk-a) hr{border:0;border-top:1px solid var(--line);margin:var(--sp-5) 0} @@ -577,6 +580,28 @@ textarea.field{min-height:96px;line-height:1.5} .tools .btn.once{background:color-mix(in srgb,var(--accent) 18%,transparent);color:var(--accent-ink)} .tools .btn.lock{background:var(--accent);color:var(--on-color)} .tools .btn.on{background:var(--primary);color:var(--on-primary)} +/* 個人資料與用量: one strip of big numbers, the year's dots, a big number and bars. */ +.me-figs{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;margin:var(--sp-3) var(--sp-4) 0;padding:var(--sp-3) var(--sp-2);background:var(--elev);border-radius:var(--r-l)} +.me-figs div{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:0} +.me-figs b{font-size:var(--fs-h3);font-weight:600;white-space:nowrap} +.me-figs span{font-size:var(--fs-caption);color:var(--text3);white-space:nowrap} +.me-card{margin:0 var(--sp-4);padding:var(--sp-3) var(--sp-4);background:var(--elev);border-radius:var(--r-l)} +.me-heat{width:100%;height:auto;display:block} +.me-note{font-size:var(--fs-caption);color:var(--text3);margin-top:var(--sp-2);line-height:1.5} +.me-seg{display:flex;gap:2px;padding:3px;background:var(--active);border-radius:999px;margin:var(--sp-1) 0 var(--sp-3)} +.me-seg button{flex:1;height:30px;border-radius:999px;font-size:var(--fs-small);color:var(--text2)} +.me-seg button.on{background:var(--elev);color:var(--text);font-weight:600} +.me-hero{font-size:var(--fs-small);color:var(--text3)} +.me-hero b{font-size:var(--fs-h1);font-weight:600;color:var(--text);margin-right:4px} +.me-bars{width:100%;height:84px;display:block;margin:var(--sp-3) 0 var(--sp-4);border-bottom:1px solid var(--grid)} +.me-split{display:flex;height:10px;border-radius:999px;overflow:hidden;background:var(--hover);margin-bottom:var(--sp-2)} +.me-split i{display:block;height:100%} +.me-row{display:flex;align-items:center;gap:10px;min-height:36px} +.me-dot{width:8px;height:8px;border-radius:50%;flex:none} +.me-av{width:22px;height:22px;flex:none;display:grid}.me-av svg{width:22px;height:22px} +.me-name{flex:1;min-width:0;font-size:var(--fs-small);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} +.me-bar{width:70px;height:6px;border-radius:999px;background:var(--hover);overflow:hidden;flex:none}.me-bar i{display:block;height:100%;background:var(--accent)} +.me-n{font-size:var(--fs-small);color:var(--text2);white-space:nowrap} /* 虛擬觸控板 over this Mac's screen: a layer that takes the fingers, and the pointer drawn on it. */ .stagewrap{flex:1;min-height:0;position:relative;display:flex} .pad{position:absolute;inset:0;display:none;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none} @@ -1419,7 +1444,7 @@ function mergeState(prev, v) { } function apply(v) { S.bots = v.bots || []; S.approvals = v.approvals || []; S.hostName = v.host || ""; S.mac = !!v.mac; - S.box = v.box || ""; S.boxOn = !!v.box_available; S.pages = v.pages || []; S.tasks = v.tasks || []; S.models = v.models || []; S.sections = v.sections || null; S.role = v.role || "owner"; + S.box = v.box || ""; S.boxOn = !!v.box_available; S.pages = v.pages || []; S.tasks = v.tasks || []; S.models = v.models || []; S.sections = v.sections || null; S.pinOrder = v.pin_order || null; S.role = v.role || "owner"; S.voice = v.voice || {}; micShown(); appBadge(); // The computer's 外觀 (an older brain sends neither: the built-in look stays). if (v.palettes) applyPalette(v.palettes); @@ -1467,8 +1492,43 @@ function apply(v) { // ---------- home: the sidebar ---------- $("b-search").innerHTML = ic("search", 20); $("b-newbot").innerHTML = ic("plus", 22); $("search-ic").innerHTML = ic("search", 16); $("b-search-x").innerHTML = ic("x", 16); $("b-search").onclick = () => { $("searchbox").classList.add("on"); $("search").focus(); }; -$("b-search-x").onclick = () => { $("search").value = ""; S.search = ""; $("searchbox").classList.remove("on"); renderHome(); }; -$("search").oninput = () => { S.search = $("search").value.trim().toLowerCase(); renderHome(); }; +$("b-search-x").onclick = () => { $("search").value = ""; S.search = ""; S.hits = null; $("searchbox").classList.remove("on"); renderHome(); }; +// 搜尋 finds bots by name, and (the owner's) words in every chat — past conversations and file +// names too — as on the computer: a tap opens that chat at that message. +let searchTimer = 0, searchSeq = 0; +$("search").oninput = () => { + S.search = $("search").value.trim().toLowerCase(); + S.hits = null; clearTimeout(searchTimer); + if (S.search && owner()) searchTimer = setTimeout(searchChats, 300); + renderHome(); +}; +async function searchChats() { + const q = S.search, seq = ++searchSeq; + const v = await act("search", {q: $("search").value.trim()}, false); + if (seq !== searchSeq || q !== S.search) return; + S.hits = v || {hits: [], more: false}; + renderHome(); +} +function hitsHtml() { + if (!S.search || !S.hits) return ""; + const hits = S.hits.hits || []; + if (!hits.length) return `
聊天裡也沒有找到
`; + return `
${ic("message", 13)}聊天裡 ${hits.length}${S.hits.more ? "+" : ""}
${hits.map((h, i) => { + const b = bot(h.bot) || {}; + const where = h.thread != null ? `過去的對話` : ""; + const what = (h.file ? "📎 " + h.file + " " : "") + (h.snippet || ""); + return `
${avatarSvg(b.shape, b.color)}
${esc(h.bot_name || b.name || "")}${where}
${esc(what)}
${ago(h.at)}
`; + }).join("")}
`; +} +async function openHit(i) { + const h = ((S.hits || {}).hits || [])[i]; + if (!h) return; + if (h.thread != null) { + if (!await confirmSheet("回到這段對話?", `「${h.thread_title || "對話"}」會換回來,現在的對話留在「過去的對話」裡。`, "回到這段對話", false)) return; + try { await api(base() + `api/bots/${h.bot}/restore`, {json: {index: h.thread}}); } catch (e) { toast(e.message); return; } + } + go("chat", {bot: h.bot, at: h.at}); +} function botState(b) { const waiting = S.approvals.find((a) => a.bot === b.id); if (waiting) return {cls: "wait", dot: "wait", text: waiting.kind === "question" ? "等你回答:" + waiting.reason : "等你處理:" + (waiting.kind === "handoff" ? waiting.reason : waiting.title)}; @@ -1502,10 +1562,16 @@ function renderHome() { $("b-newbot").style.display = isOwner() ? "" : "none"; $("quick").querySelectorAll("[data-q]").forEach((b) => b.onclick = () => go("list", {kind: b.dataset.q})); if (!S.bots.length) { $("home").innerHTML = `
還沒有 Bot。按右上角的 + 建立第一個。
`; return; } - if (!bots.length) { $("home").innerHTML = `
沒有相符的 Bot
`; return; } + if (!bots.length) { + $("home").innerHTML = (q && S.hits && (S.hits.hits || []).length ? "" : `
${q && owner() && !S.hits ? "找找看聊天裡…" : "沒有相符的 Bot"}
`) + hitsHtml(); + $("home").querySelectorAll("[data-hit]").forEach((r) => r.onclick = () => openHit(+r.dataset.hit)); + return; + } // The sidebar's sections: 主要 Bot, 已釘選的 Bot, the person's own sections, then Bot. const primary = bots.filter((b) => b.primary); - const pinned = bots.filter((b) => !b.primary && b.pinned); + // (In the desktop's order, which the owner can change from a bot's ⋯ › 更多.) + const pinAt = (b) => { const i = (S.pinOrder || []).indexOf(b.id); return i < 0 ? 1e9 : i; }; + const pinned = bots.filter((b) => !b.primary && b.pinned).sort((a, b) => pinAt(a) - pinAt(b)); const rest = bots.filter((b) => !b.primary && !b.pinned); // The desktop's 分區 in its order (null = 未分區), empty ones too. const order = S.sections || [...new Set(rest.map((b) => b.folder).filter(Boolean)), null]; @@ -1517,7 +1583,8 @@ function renderHome() { if (f == null) h += sec(folders.length ? "未分區" : "Bot", "", rest.filter((b) => !folders.includes(b.folder)), folders.length ? "loose" : ""); else h += sec(f, "folder", rest.filter((b) => b.folder === f), "f:" + f, isOwner() ? `` : "", !q); } - $("home").innerHTML = h + `
`; + $("home").innerHTML = h + hitsHtml() + `
`; + $("home").querySelectorAll("[data-hit]").forEach((r) => r.onclick = () => openHit(+r.dataset.hit)); $("home").querySelectorAll(".row[data-bot]").forEach((r) => { r.onclick = (e) => { if (e.target.closest("[data-botmenu]")) return; go("chat", {bot: +r.dataset.bot}); }; let t = null; r.addEventListener("touchstart", () => { t = setTimeout(() => { t = "long"; botMenu(+r.dataset.bot); }, 520); }, {passive: true}); @@ -1529,6 +1596,8 @@ function renderHome() { e.stopPropagation(); const f = b.dataset.fmenu; sheet(f, [ + {icon: "arrow-up", label: "往上移", on: () => act("section_move", {folder: f, by: -1}, false)}, + {icon: "arrow-down", label: "往下移", on: () => act("section_move", {folder: f, by: 1}, false)}, {icon: "pen", label: "重新命名分區", on: async () => { const n = await ask("分區名稱", f); if (n && n !== f) app("rename_group", {group: f, new_name: n}); }}, {icon: "trash", label: "刪除分區", danger: true, on: async () => { if (await confirmSheet(`刪除分區「${f}」?`, "裡面的 Bot 會移到未分區,不會刪除任何 Bot。", "刪除分區")) app("delete_group", {group: f}); }}, ]); @@ -1546,6 +1615,13 @@ function botMenu(id) { // 團隊: whether teammates may use this bot (they see its chat, pages and files). if (isOwner() && !b.members) more.push({icon: "users", label: b.team ? "不再分享給團隊成員" : "分享給團隊成員", on: () => act("bot", {bot: id, key: "team", value: !b.team}, b.team ? "團隊成員看不到這個 Bot 了" : "團隊成員現在可以使用這個 Bot")}); if (!b.primary && isOwner()) more.push({icon: "star", label: "設為主要 Bot", on: () => act("bot", {bot: id, key: "primary", value: true}, "已設為主要 Bot")}); + // 已釘選的 Bot in another order (the desktop drags them; here one step at a time). + const pins = (S.pinOrder || []).filter((x) => { const y = bot(x); return y && y.pinned && !y.primary; }); + const at = pins.indexOf(id); + if (isOwner() && b.pinned && at > 0) more.push({icon: "arrow-up", label: "釘選裡往前移", on: () => act("bot", {bot: id, key: "pin_at", value: at - 1}, false)}); + if (isOwner() && b.pinned && at >= 0 && at < pins.length - 1) more.push({icon: "arrow-down", label: "釘選裡往後移", on: () => act("bot", {bot: id, key: "pin_at", value: at + 1}, false)}); + // 分享: the bot as a file (another AnyBot imports it), or this chat as Markdown. + if (isOwner()) more.push({icon: "share", label: "匯出 Bot 檔案(.anybot)", on: () => exportAs("export_bot", id)}); more.push({icon: "refresh", label: "重新啟動這個 Bot", on: () => act("restart_bot", {bot: id})}); items.push({icon: "ellipsis", label: "更多…", on: () => sheet(b.name, more)}); if (isOwner()) items.push({sep: true}, {icon: "trash", label: "刪除 Bot", danger: true, on: () => deleteBot(b)}); @@ -1573,8 +1649,36 @@ $("b-newbot").onclick = async () => { {icon: "sparkles", label: "從範本建立", on: templates}, {icon: "users", label: "建立群組聊天", on: groupChat}, {icon: "folder", label: "新增分區", on: async () => { const n = await ask("新增分區", "", "例如:文宣組"); if (n) app("create_group", {name: n}); }}, + {icon: "download", label: "匯入 Bot 檔案(.anybot)", on: importBot}, ]); }; +// A file the brain made (a bot, a transcript): saved on the phone — the share sheet where there +// is one (iPhone: 儲存到檔案, AirDrop…), else a download. +async function exportAs(what, id) { + const v = await act(what, {bot: id}, false); + if (!v || !v.content) return; + const file = new File([v.content], v.filename || "AnyBot.txt", {type: what === "export_bot" ? "application/json" : "text/markdown"}); + try { if (navigator.canShare && navigator.canShare({files: [file]})) { await navigator.share({files: [file]}); return; } } catch (e) { if (e.name === "AbortError") return; } + const a = document.createElement("a"); a.href = URL.createObjectURL(file); a.download = file.name; document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(a.href), 4000); + toast("已存成「" + file.name + "」"); +} +async function saveText(text, name) { + const file = new File([text], name, {type: "text/markdown"}); + try { if (navigator.canShare && navigator.canShare({files: [file]})) { await navigator.share({files: [file]}); return; } } catch (e) { if (e.name === "AbortError") return; } + const a = document.createElement("a"); a.href = URL.createObjectURL(file); a.download = name; document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(a.href), 4000); + toast("已存成「" + name + "」"); +} +function importBot() { + const pick = document.createElement("input"); pick.type = "file"; pick.accept = ".anybot,application/json"; + pick.onchange = async () => { + const f = pick.files && pick.files[0]; if (!f) return; + const v = await act("import_bot", {content: await f.text()}, false); + if (v && v.ok !== false) { toast(v.text || "已匯入"); newBotDone(v); } + }; + pick.click(); +} function newBotDone(v) { if (v && v.bot) setTimeout(() => go("chat", {bot: v.bot}), 400); } async function templates() { if (!S.settings) await loadSettings(); @@ -1707,9 +1811,23 @@ function keepChat(id, msgs, sig) { CHATS.delete(k); CHATS.set(k, was && was.sig === sig && Date.now() - (was.t || 0) <= 3600000 ? was : c); while (CHATS.size > 12) { const old = CHATS.keys().next().value; CHATS.delete(old); KEEP.del("chat:" + old); } } +// What was typed and not sent stays with its bot, as on the computer: switching bots, or closing +// the page, does not lose it (kept on this phone, per AnyBot). +const draftKey = () => "anybot.drafts:" + (S.host || "lan"); +function drafts() { try { return JSON.parse(localStorage.getItem(draftKey()) || "{}"); } catch (_) { return {}; } } +function keepDraft(id, text) { + if (!id) return; + const d = drafts(); + if (text && text.trim()) d[id] = text; else delete d[id]; + try { localStorage.setItem(draftKey(), JSON.stringify(d)); } catch (_) {} +} function openChat(id, at) { S.jumpAt = at || 0; if (S.open !== id) { + // (The box by id: this can run before the script below has named it.) + const box = $("input"); + keepDraft(S.open, box.value); + box.value = drafts()[id] || ""; box.style.height = "auto"; setTimeout(() => box.dispatchEvent(new Event("input")), 0); keepChat(S.open, S.msgs, S.chatSig); S.msgs = []; S.pending = []; S.quote = null; S.unfold = {}; S.openSteps = {}; S.chatSig = ""; S.prevShown = 0; S.prevFirst = ""; MODE_OPEN = ""; $("msgs").innerHTML = ""; const kept = CHATS.get(chatKey(id)); @@ -1758,7 +1876,7 @@ async function loadChat(jump) { loading = false; if (again) { again = false; loadChat(); } // 任務 → a message older than what the phone keeps of the chat: the chat stays at its end. - else if (S.jumpAt && S.chatLoaded && S.open === id && !jumpTo()) { S.jumpAt = 0; toast("那件事開頭的訊息太早了,手機上只留最近的訊息"); } + else if (S.jumpAt && S.chatLoaded && S.open === id && !jumpTo()) { S.jumpAt = 0; toast("那則訊息太早了,手機上只留最近的訊息"); } } // 載入更早:開頁只拿最新 30 條,這裡一次往回補 60 條(序號去重,接在上方)——從大腦上整段聊天拿, // 不只手機那份最新的。按了一定有回應:載入中、補上了、或「已是對話最開頭」(按鈕收起來)。 @@ -2194,6 +2312,7 @@ function selectSheet(i, m) { el.scrollTop = 0; } async function copyText(t) { try { await navigator.clipboard.writeText(t || ""); toast("已複製"); } catch (_) { toast("這支手機不讓網頁複製"); } } +document.addEventListener("click", (e) => { const b = e.target.closest("[data-copycode]"); if (!b) return; e.stopPropagation(); copyText((b.parentElement.querySelector("code") || {}).textContent || ""); }, true); const QUICK = ["👍", "❤️", "😂", "🎉", "👀", "🙏", "👌", "🔥"]; function msgMenu(i) { const m = S.msgs[i]; if (!m) return; @@ -2349,6 +2468,7 @@ function renderQuote() { if (q) $("q-x").onclick = () => { S.quote = null; renderQuote(); }; } const input = $("input"); +input.addEventListener("input", () => { clearTimeout(S.draftTimer); S.draftTimer = setTimeout(() => keepDraft(S.open, input.value), 400); }); input.addEventListener("input", () => { input.style.height = "auto"; input.style.height = Math.min(input.scrollHeight, 140) + "px"; $("composer").classList.toggle("tall", input.scrollHeight > 40); renderSendBtn(); @@ -2493,7 +2613,7 @@ async function send() { memReset(); // (A command takes no file that isn't up yet: those stay above the input for the next message.) const had = S.pending; S.pending = quiet ? S.pending.filter((p) => p.blob) : []; - input.value = ""; input.style.height = "auto"; $("composer").classList.remove("tall"); renderChips(); renderSlash(); + input.value = ""; keepDraft(S.open, ""); input.style.height = "auto"; $("composer").classList.remove("tall"); renderChips(); renderSlash(); // A command (not words for the chat): sent now, or said that it couldn't be (its words and files back). if (quiet) { try { await deliver(base() + `api/bots/${S.open}/send`, {text, attachments}); loadChat(); } catch (e) { toast(e.message); if (!input.value) { input.value = text; input.dispatchEvent(new Event("input")); } S.pending = [...had.filter((p) => !S.pending.includes(p)), ...S.pending]; renderChips(); } return; } // 先顯示: in the chat at once, network or not; it goes when the line is there (kept on this @@ -2660,6 +2780,7 @@ $("b-chatmore").onclick = () => { {icon: "info", label: "對話詳細資訊", on: () => go("details", {bot: b.id})}, {icon: "history", label: "過去的對話", x: String((b.threads || []).length || ""), on: () => threads(b)}, {icon: "copy", label: "複製整段對話", on: () => copyText(S.msgs.filter((m) => m.text && !m.summary).map((m) => (m.role === "user" ? "我:" : b.name + ":") + m.text).join("\n\n"))}, + {icon: "download", label: "匯出文字記錄(.md)", on: () => exportAs("export_transcript", b.id)}, ]; if (owner()) items.splice(1, 0, {icon: "refresh", label: "重新產生上一個回答", on: regen}); if (isOwner()) items.push({icon: "settings", label: "Bot 設定", on: () => go("botset", {bot: b.id})}); @@ -3063,7 +3184,11 @@ async function renderBotset(id) { h += ticks("可以用的電腦", "may_use", (d.may_use || []).length > 1 ? d.may_use : [], "它自己的電腦一定可以用。"); } h += `
頭像
${(st.shapes || []).map((s) => ``).join("")}
${(st.colors || []).map((c) => ``).join("")}
`; - h += group("AI 與電腦", item({icon: "sparkles", k: "模型", v: b.via || b.model, r: b.runs || "", tap: 1, data: 'data-e="model"'}) + item({icon: "monitor", k: "做事的電腦", r: b.computer || "", tap: 1, data: 'data-e="comp"'}) + item({icon: "terminal", k: "電腦操作", v: S.settings && S.settings.direct_mode ? "直接操作開著:照樣可以用電腦(關掉直接操作才照這裡)" : "關掉時,用電腦前會先問你", sw: d.tools_enabled !== false, swdata: 'data-sw="tools"', disabled: !isOwner()}) + item({icon: "brain", k: "模型可讀長度", r: (CTX.find((c) => c[0] === d.context_tokens) || [0, Math.round((d.context_tokens || 0) / 1000) + "K"])[1], tap: 1, data: 'data-e="ctx"'})); + // (As on the computer's Bot 設定: who carries out the planned steps, and how long it thinks.) + const EFFORTS = [["", "自動(模型自己決定)"], ["low", "快速(想得少,回得快)"], ["medium", "平衡"], ["high", "深入(想得久,較慢)"]]; + const stepShown = !d.step_model ? "自動" : d.step_model === "off" ? "不分開" : d.step_model; + const extra = isOwner() ? item({icon: "zap", k: "執行步驟用的模型", v: "想計畫和確認用上面的模型;照計畫做的步驟交給這個比較快的", r: stepShown, tap: 1, data: 'data-e="step"'}) + item({icon: "lightbulb", k: "思考模式", r: (EFFORTS.find((e) => e[0] === (d.thinking || "")) || EFFORTS[0])[1].replace(/(.*)/, ""), tap: 1, data: 'data-e="think"'}) : ""; + h += group("AI 與電腦", item({icon: "sparkles", k: "模型", v: b.via || b.model, r: b.runs || "", tap: 1, data: 'data-e="model"'}) + extra + item({icon: "monitor", k: "做事的電腦", r: b.computer || "", tap: 1, data: 'data-e="comp"'}) + item({icon: "terminal", k: "電腦操作", v: S.settings && S.settings.direct_mode ? "直接操作開著:照樣可以用電腦(關掉直接操作才照這裡)" : "關掉時,用電腦前會先問你", sw: d.tools_enabled !== false, swdata: 'data-sw="tools"', disabled: !isOwner()}) + item({icon: "brain", k: "模型可讀長度", r: (CTX.find((c) => c[0] === d.context_tokens) || [0, Math.round((d.context_tokens || 0) / 1000) + "K"])[1], tap: 1, data: 'data-e="ctx"'})); if (isOwner()) h += group("已設定「一律允許」", (d.allow_rules || []).map((r) => `
${ic("shield", 17)}
${esc(r)}
`).join("") || `
還沒有。在核准時選「一律允許」就會記在這裡。
`); h += group("整理", item({icon: "pin", k: "釘選", sw: !!d.pinned, swdata: 'data-sw="pinned"'}) + item({icon: "star", k: "主要 Bot", v: d.primary ? "這是主要 Bot" : "", sw: !!d.primary, swdata: 'data-sw="primary"', disabled: !!d.primary}) + item({icon: "folder", k: "分區", r: d.folder || "未分區", tap: 1, data: 'data-e="folder"'})); if ((d.demos || []).length) h += group("示範教學", d.demos.map((x) => item({icon: "eye", k: x.name, v: `${x.steps} 個步驟 · ${x.created}`})).join("") + `
示範要在那台電腦上錄;Bot 在對話裡會照著做。
`); @@ -3103,6 +3228,13 @@ async function renderBotset(id) { else if (k === "not_for") { const n = await ask("不找它做的事", d.not_for || "", "例如:不寫程式、不碰帳務", true); if (n != null && n !== (d.not_for || "") && await act("bot", {bot: id, key: "not_for", value: n}, "已更新")) refresh(); } else if (k === "model") modelSheet(b); else if (k === "comp") pickComputer(b, d); + else if (k === "think") sheet("思考模式", [{group: "想得越久越仔細,也越慢、越花額度"}].concat(EFFORTS.map(([v, l]) => ({label: l, check: v === (d.thinking || ""), on: async () => { if (await act("bot", {bot: id, key: "thinking", value: v}, "已更新")) refresh(); }})))); + else if (k === "step") { + const models = ((S.models || []).find((p) => p.provider === b.provider) || {}).models || []; + const pick = (v, ok) => async () => { if (await act("bot", {bot: id, key: "step_model", value: v}, ok)) refresh(); }; + sheet("執行步驟用的模型", [{label: "自動", check: !d.step_model, on: pick("", "已改成自動")}, {label: "不分開(每一步都用上面的模型)", check: d.step_model === "off", on: pick("off", "已改成不分開")}] + .concat(models.filter((m) => m !== b.model).map((m) => ({label: m, check: d.step_model === m, on: pick(m, "步驟改用 " + m)})))); + } else if (k === "ctx") sheet("模型可讀長度", CTX.map(([n, l]) => ({label: l + " 個 token", check: n === d.context_tokens, on: async () => { if (await act("bot", {bot: id, key: "context", value: n}, "已更新")) refresh(); }}))); else if (k === "folder") moveToFolder(b); else if (k === "restart") act("restart_bot", {bot: id}); @@ -3139,7 +3271,7 @@ async function settingsChanged() { } let listTimer = null; function stopListTimer() { clearInterval(listTimer); listTimer = null; } -const TITLES = {tasks: "任務", routines: "例行任務", pages: "頁面", computers: "電腦", settings: "設定", general: "一般", models: "模型", perms: "權限", integrations: "整合", vault: "保險庫", account: "手機與帳號", updates: "更新"}; +const TITLES = {tasks: "任務", routines: "例行任務", pages: "頁面", computers: "電腦", settings: "設定", general: "一般", me: "個人資料與用量", models: "模型", perms: "權限", integrations: "整合", vault: "保險庫", account: "手機與帳號", updates: "更新"}; async function renderList(arg) { const kind = arg.kind; $("list-title").textContent = TITLES[kind] || ""; @@ -3149,6 +3281,7 @@ async function renderList(arg) { if (kind === "tasks") return listTasks(el); if (kind === "routines") return listRoutines(el); if (kind === "pages") return listPages(el); + if (kind === "me") return listMe(el); if (SETTINGS_PAGES.includes(kind)) { // (Drawn from what this phone has at once; read again behind it when it may be old.) if (!S.settings) { el.innerHTML = `
載入中…
`; await loadSettings(); } @@ -3159,6 +3292,58 @@ async function renderList(arg) { if (["computers", "integrations"].includes(kind)) listTimer = setInterval(async () => { await loadSettings(); if (cur().v === "list" && cur().arg.kind === kind) drawSettings(kind, true); }, 4000); } } +// ---------- 個人資料與用量(設定)---------- +// The year in figures, a heat map of its days, and 用量 by period — as on the computer +// (設定 › 個人資料): big numbers and bars instead of lines of words; the fine print in a tap. +const ME = {span: "30", by: "model", data: null, at: 0}; +const wan = (n) => { n = n || 0; return n < 1e4 ? n.toLocaleString("en-US") : n < 1e7 ? (n / 1e4).toFixed(1).replace(/\.0$/, "") + "萬" : n < 1e8 ? Math.round(n / 1e4).toLocaleString("en-US") + "萬" : (n / 1e8).toFixed(2).replace(/\.00$/, "") + "億"; }; +const costWords = (micros, unpriced, calls) => !micros ? "未定價" : "US$" + (micros / 1e6).toFixed(2) + (unpriced > 0 && unpriced < calls ? `(另有 ${unpriced} 次呼叫未定價)` : ""); +const shortDate = (d) => { const [, m, dd] = (d || "").split("-"); return m ? `${+m}月${+dd}日` : d || ""; }; +async function listMe(el) { + if (ME.data) drawMe(el); else el.innerHTML = `
正在算過去一年的用量…
`; + if (ME.data && Date.now() - ME.at < 60000) return; + try { ME.data = await api(base() + "api/stats"); ME.at = Date.now(); } + catch (e) { if (!ME.data) { el.innerHTML = `
讀不到用量:${esc(e.message)}
`; return; } } + if (cur().v === "list" && cur().arg.kind === "me") drawMe(el); +} +function drawMe(el) { + const d = ME.data || {}; + const figs = [[wan(d.tokens_year), "Token・一年"], [wan(d.messages_year), "訊息・一年"], [(d.streak_now || 0) + " 天", "連續使用"], [(d.streak_best || 0) + " 天", "最長連續"]]; + let h = `
${figs.map(([v, l]) => `
${esc(v)}${esc(l)}
`).join("")}
`; + // The year: a dot a day, a column a week (Sunday on top), deeper the busier. + const days = d.days || [], off = d.weekday_first || 0, weeks = Math.ceil((days.length + off) / 7) || 1; + const cell = 7, W = weeks * cell, H = 7 * cell; + const lv = ["var(--hover)", "color-mix(in srgb,var(--accent) 30%,transparent)", "color-mix(in srgb,var(--accent) 50%,transparent)", "color-mix(in srgb,var(--accent) 75%,transparent)", "var(--accent)"]; + const dots = days.map((x, i) => { const k = i + off; return `${esc(shortDate(x[0]))}:${wan(x[1])} token、${x[2]} 則訊息`; }).join(""); + const busy = d.busiest && d.busiest.date ? `最活躍:${shortDate(d.busiest.date)}・${wan(d.busiest.tokens)} token` : ""; + h += `
活動
${dots}
過去一年有 ${d.active_days || 0} 個活躍日${busy ? "・" + esc(busy) : ""}
`; + // 用量: the period's big number, a bar a day, then by model or by bot. + const u = (d.periods || {})[ME.span] || {}; + const seg = (list, cur, key) => `
${list.map(([v, l]) => ``).join("")}
`; + h += `
用量
${seg([["7", "7 天"], ["30", "30 天"], ["90", "90 天"], ["365", "一年"]], ME.span, "mespan")}`; + h += `
${wan(u.tokens)} token
${wan(u.calls)} 次呼叫・花費 ${esc(costWords(u.cost_micros, u.unpriced, u.calls))}・新讀 ${wan((u.input || 0) + (u.cache_write || 0))}、寫 ${wan(u.output)}、快取 ${wan(u.cache_read)}
`; + const daily = u.daily || [], max = Math.max(1, ...daily.map((x) => x[1] || 0)), bw = 100 / Math.max(1, daily.length); + h += `${daily.map((x, i) => x[1] ? `${esc(shortDate(x[0]))}:${wan(x[1])} token` : "").join("")}`; + const rows = (u[ME.by === "bot" ? "by_bot" : "by_model"] || []).slice(0, 8); + const total = Math.max(1, rows.reduce((n, r) => n + (r.tokens || 0), 0)); + const cat = (i) => `var(--cat${(i % 6) + 1})`; + h += seg([["model", "依模型"], ["bot", "依 Bot"]], ME.by, "meby"); + if (!rows.length) h += `
這段時間沒有用量紀錄
`; + else { + if (ME.by === "model") h += `
${rows.map((r, i) => ``).join("")}
`; + const top = Math.max(1, rows[0].tokens || 0); + h += rows.map((r, i) => { + const b = ME.by === "bot" ? S.bots.find((x) => x.name === r.name) : null; + const mark = ME.by === "bot" ? `${b ? avatarSvg(b.shape, b.color) : ""}` : ``; + const bar = ME.by === "bot" ? `` : ""; + return `
${mark}${esc(r.name)}${bar}${wan(r.tokens)}・${Math.round((r.tokens || 0) / total * 100)}%
`; + }).join(""); + } + h += `
`; + el.innerHTML = h; + el.querySelectorAll("[data-mespan]").forEach((b) => b.onclick = () => { ME.span = b.dataset.mespan; drawMe(el); }); + el.querySelectorAll("[data-meby]").forEach((b) => b.onclick = () => { ME.by = b.dataset.meby; drawMe(el); }); +} // ---------- 任務 ---------- // Every bot's tasks as the brain works them out — from the steps, the turn's end, the follow-ups, // the goal checks and whether a device showed the files, never from what a bot says. They come @@ -3197,7 +3382,9 @@ function listTasks(el) { // 任務 → 那則訊息: the chat at where the task began, lit a moment (once that message is here). function jumpTo() { if (!S.jumpAt || S.view !== "chat") return false; - const i = S.msgs.findIndex((m) => m.at === S.jumpAt && m.role === "user"); + // (A task opens at the person's opening message; a search hit may be any message.) + let i = S.msgs.findIndex((m) => m.at === S.jumpAt && m.role === "user"); + if (i < 0) i = S.msgs.findIndex((m) => m.at === S.jumpAt); const el = i < 0 ? null : document.querySelector(`#msgs [data-msg="${i}"]`); if (!el) return false; S.jumpAt = 0; @@ -3246,7 +3433,7 @@ function drawSettings(kind, quiet) { let h = ""; if (kind === "settings") { h += group("", [ - ["general", "settings", "一般", "外觀、時區、通知總開關"], ["models", "sparkles", "模型", "可以用的 AI 服務"], ["perms", "shield", "權限", st.direct_mode ? "直接操作:開" : "Bot 做事前的規則"], + ["general", "settings", "一般", "外觀、時區、通知總開關"], ...(isOwner() ? [["me", "activity", "個人資料與用量", ""]] : []), ["models", "sparkles", "模型", "可以用的 AI 服務"], ["perms", "shield", "權限", st.direct_mode ? "直接操作:開" : "Bot 做事前的規則"], ["integrations", "plug", "整合", "訊息管道、連接器、技能"], ["computers", "monitor", "電腦", "Bot 的電腦和你帳號裡的電腦"], ["vault", "lock", "保險庫", "密碼和卡號"], ["account", "smartphone", "手機與帳號", "登入的手機、這支手機的通知"], ["updates", "download", "更新", st.version || ""], ].map(([k, i, n, v]) => item({icon: i, k: n, r: k === "updates" ? v : "", tap: 1, data: `data-go="${k}"`})).join("")); @@ -3566,7 +3753,7 @@ function pageToc(root) { } $("b-pagemore").onclick = () => { const v = S.pageData; if (!v) return; - const items = [{icon: "copy", label: "複製 Markdown", on: () => copyText(v.body)}]; + const items = [{icon: "copy", label: "複製 Markdown", on: () => copyText(v.body)}, {icon: "download", label: "存成檔案(.md)", on: () => saveText(v.body, (v.title || "頁面").replace(/[\\/:*?"<>|]/g, "_") + ".md")}]; if ((v.versions || []).length) items.push({icon: "history", label: "其他版本", on: () => sheet("版本", [{label: `第 ${v.latest} 版(最新)`, check: v.revision === v.latest, on: () => openPage(v.id)}, ...v.versions.map((x) => ({label: `第 ${x.revision} 版`, x: x.at, check: v.revision === x.revision, on: () => openPage(v.id, x.revision)}))])}); if (isOwner()) items.push({sep: true}, {icon: "trash", label: "刪除頁面", danger: true, on: async () => { if (await confirmSheet(`刪除「${v.title}」?`, "", "刪除") && await act("delete_page", {id: v.id}, "已刪除頁面")) back(); }}); sheet(v.title, items); @@ -4008,7 +4195,7 @@ function pageMd(text, id, rev) { }); if (items.length) { out.push(``); continue; } } - out.push(`
${esc(body.join("\n"))}
`); continue; + out.push(`
${esc(body.join("\n"))}
`); continue; } const h = t.match(/^(#{1,6})\s+(.*)$/); if (h) { const n = Math.min(h[1].length + 1, 4); out.push(`${inl(h[2])}`); i++; continue; }