AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
// 訊息管道 in the window: the settings page, turning incoming messages into turns, and posting
|
|
|
|
|
|
// the bot's answer back when the turn ends.
|
|
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
use crate::channels::{self, Channel, Incoming, Kind, ReplyTo};
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
use std::collections::VecDeque;
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
|
|
|
|
|
|
pub struct ChannelUi {
|
|
|
|
|
|
pub tx: Sender<Incoming>,
|
|
|
|
|
|
pub rx: Receiver<Incoming>,
|
|
|
|
|
|
/// Where each bot's current answer goes back to.
|
|
|
|
|
|
pub replies: HashMap<u64, Vec<ReplyTo>>,
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
/// Messages that came while their bot was busy: each waits for a turn of its own.
|
|
|
|
|
|
waiting: VecDeque<Incoming>,
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
new_kind: Kind,
|
|
|
|
|
|
new_name: String,
|
|
|
|
|
|
new_token: String,
|
|
|
|
|
|
new_target: String,
|
|
|
|
|
|
new_bot: u64,
|
|
|
|
|
|
pub note: Arc<Mutex<String>>,
|
|
|
|
|
|
started: bool,
|
|
|
|
|
|
trig_tx: Sender<crate::triggers::Fired>,
|
|
|
|
|
|
trig_rx: Receiver<crate::triggers::Fired>,
|
|
|
|
|
|
/// What the running watchers were started with (restart when it changes).
|
|
|
|
|
|
trig_sig: String,
|
|
|
|
|
|
new_client: String,
|
|
|
|
|
|
new_tenant: String,
|
|
|
|
|
|
/// Teams sign-in: the code to show, and the refresh token when done.
|
|
|
|
|
|
ms_login: Arc<Mutex<(String, Option<String>)>>,
|
|
|
|
|
|
mcp_sig: String,
|
The phone page does what the desktop does, laid out like it
A new mobile/index.html in the desktop's (and Grok Bot's) shape: the sidebar
with its sections and folders, the chat with steps, thinking, reactions, quotes
and the approval card, 對話詳細資訊, Bot 設定, routines, pages, computers and
設定. Each action goes to the desktop's own code on the app's thread
(api/act/<what> -> App::phone_act): appctl, set_pinned, restart_bot,
toggle_reaction, box_task, channels_restart and the rest. No new rules.
Keys, channel tokens and the vault never reach the phone; a model key can only
be written. Admins keep what the phone always let them do; making, changing or
deleting bots, routines, memories, pages, folders and settings stays the
owner's. The state the phone polls now carries the sidebar's section order.
Checked by using it on a preview brain: routines, memories, templates, folders,
keys, signing another phone out, approvals and a chat with a fake model.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-06 19:05:12 +00:00
|
|
|
|
pub(super) mcp_errors: Arc<Mutex<Vec<(String, String)>>>,
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
mcp_busy: Arc<AtomicBool>,
|
|
|
|
|
|
new_mcp: (String, String, String, String),
|
|
|
|
|
|
/// 連接器市集 was asked for (scroll it into view once).
|
|
|
|
|
|
pub focus_market: bool,
|
2026-11-11 08:19:06 +00:00
|
|
|
|
skill_src: String,
|
|
|
|
|
|
skill_open: Option<String>,
|
|
|
|
|
|
skill_busy: Arc<AtomicBool>,
|
|
|
|
|
|
skill_reload: Arc<AtomicBool>,
|
|
|
|
|
|
skill_note: Arc<Mutex<Option<(bool, String)>>>,
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for ChannelUi {
|
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
|
let (tx, rx) = channel();
|
|
|
|
|
|
let (trig_tx, trig_rx) = channel();
|
2026-11-11 08:19:06 +00:00
|
|
|
|
ChannelUi { tx, rx, replies: HashMap::new(), waiting: VecDeque::new(), new_kind: Kind::Telegram, new_name: String::new(), new_token: String::new(), new_target: String::new(), new_bot: 0, note: Default::default(), started: false, trig_tx, trig_rx, trig_sig: String::new(), new_client: String::new(), new_tenant: String::new(), ms_login: Default::default(), mcp_sig: String::new(), mcp_errors: Default::default(), mcp_busy: Default::default(), new_mcp: Default::default(), focus_market: false, skill_src: String::new(), skill_open: None, skill_busy: Default::default(), skill_reload: Default::default(), skill_note: Default::default() }
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
/// The waiting messages whose turn can start now: the oldest one of each bot that is free, in
|
|
|
|
|
|
/// the order they came. The rest stay, in order.
|
|
|
|
|
|
fn ready_messages(waiting: &mut VecDeque<Incoming>, busy: impl Fn(u64) -> bool) -> Vec<Incoming> {
|
|
|
|
|
|
let (mut ready, mut later): (Vec<Incoming>, VecDeque<Incoming>) = (vec![], VecDeque::new());
|
|
|
|
|
|
while let Some(m) = waiting.pop_front() {
|
|
|
|
|
|
if busy(m.bot_id) || ready.iter().chain(later.iter()).any(|w| w.bot_id == m.bot_id) {
|
|
|
|
|
|
later.push_back(m);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ready.push(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
*waiting = later;
|
|
|
|
|
|
ready
|
|
|
|
|
|
}
|
|
|
|
|
|
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
impl App {
|
|
|
|
|
|
pub(super) fn channels_restart(&mut self, ctx: &egui::Context) {
|
|
|
|
|
|
if self.demo {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let c = ctx.clone();
|
|
|
|
|
|
channels::restart(self.state.channels.clone(), self.ch.tx.clone(), Arc::new(move || c.request_repaint()));
|
|
|
|
|
|
self.ch.started = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Event-triggered routines: (re)start their watchers when they change, and run them when they fire.
|
|
|
|
|
|
fn triggers_poll(&mut self, ctx: &egui::Context) {
|
|
|
|
|
|
let watches: Vec<crate::triggers::Watch> = self
|
|
|
|
|
|
.state
|
|
|
|
|
|
.bots
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.flat_map(|b| b.routines.iter().filter(|r| !r.paused).filter_map(move |r| r.trigger.clone().map(|t| crate::triggers::Watch { bot_id: b.id, routine_id: r.id, trigger: t })))
|
|
|
|
|
|
.collect();
|
|
|
|
|
|
let sig = watches.iter().map(|w| format!("{}:{}:{:?}", w.bot_id, w.routine_id, w.trigger)).collect::<Vec<_>>().join("|");
|
|
|
|
|
|
if sig != self.ch.trig_sig {
|
|
|
|
|
|
self.ch.trig_sig = sig;
|
|
|
|
|
|
let slack = self.state.channels.iter().find(|c| c.kind == Kind::Slack && !c.token.trim().is_empty()).map(|c| c.token.clone()).unwrap_or_default();
|
|
|
|
|
|
let c = ctx.clone();
|
|
|
|
|
|
crate::triggers::restart(watches, slack, self.ch.trig_tx.clone(), Arc::new(move || c.request_repaint()));
|
|
|
|
|
|
}
|
|
|
|
|
|
while let Ok(f) = self.ch.trig_rx.try_recv() {
|
|
|
|
|
|
let Some(b) = self.state.bot_mut(f.bot_id) else { continue };
|
|
|
|
|
|
let Some(r) = b.routines.iter_mut().find(|r| r.id == f.routine_id) else { continue };
|
|
|
|
|
|
if r.paused {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
r.last_run = Some(crate::routines::now());
|
|
|
|
|
|
let text = format!("[觸發]例行任務「{}」被觸發:{}\n要做的事:{}", r.title, f.what, r.prompt);
|
|
|
|
|
|
self.wake(ctx, f.bot_id, Message { wake: true, ..Message::user(&text) });
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// New messages from Slack / Discord / Telegram wake their bot.
|
|
|
|
|
|
pub(super) fn channels_poll(&mut self, ctx: &egui::Context) {
|
|
|
|
|
|
if !self.ch.started {
|
|
|
|
|
|
self.channels_restart(ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
self.triggers_poll(ctx);
|
|
|
|
|
|
self.mcp_poll(ctx);
|
|
|
|
|
|
// Microsoft rotates refresh tokens: keep the newest.
|
|
|
|
|
|
let rotated: Vec<(u64, String)> = crate::teams::rotated().lock().unwrap().iter().map(|(k, v)| (*k, v.clone())).collect();
|
|
|
|
|
|
for (id, tok) in rotated {
|
|
|
|
|
|
if let Some(c) = self.state.channels.iter_mut().find(|c| c.id == id && c.token != tok) {
|
|
|
|
|
|
c.token = tok;
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
while let Ok(m) = self.ch.rx.try_recv() {
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
self.ch.waiting.push_back(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
self.ch.waiting.retain(|m| self.state.bot(m.bot_id).is_some());
|
|
|
|
|
|
// A message from a channel gets a turn of its own, when its bot is free. It used to be
|
|
|
|
|
|
// dropped into whatever turn was running, and that turn's answer (to the person's own
|
|
|
|
|
|
// question at the desk, say) was what went out to the channel.
|
|
|
|
|
|
let mut waiting = std::mem::take(&mut self.ch.waiting);
|
|
|
|
|
|
let ready = ready_messages(&mut waiting, |id| {
|
|
|
|
|
|
self.streams.contains_key(&id)
|
|
|
|
|
|
|| self.ch.replies.contains_key(&id)
|
|
|
|
|
|
|| self.group_next.contains(&id)
|
|
|
|
|
|
|| self.pending_turns.iter().any(|(b, _)| *b == id)
|
|
|
|
|
|
|| self.group_queue.get(&id).is_some_and(|q| !q.is_empty())
|
|
|
|
|
|
});
|
|
|
|
|
|
self.ch.waiting = waiting;
|
|
|
|
|
|
for m in ready {
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
let text = format!("[訊息管道]{}「{}」的 {}:{}", m.reply.kind.label(), m.reply.channel_name, m.from, m.text);
|
|
|
|
|
|
self.ch.replies.entry(m.bot_id).or_default().push(m.reply.clone());
|
|
|
|
|
|
self.wake(ctx, m.bot_id, Message { wake: true, ..Message::user(&text) });
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
// No turn started (a group with nobody in it): nothing will answer, so no later
|
|
|
|
|
|
// turn's answer may go there either. (A screen's turns run on its brain.)
|
|
|
|
|
|
if !self.streams.contains_key(&m.bot_id) && !self.mir.on {
|
|
|
|
|
|
self.ch.replies.remove(&m.bot_id);
|
|
|
|
|
|
}
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
if !self.ch.waiting.is_empty() {
|
|
|
|
|
|
ctx.request_repaint_after(std::time::Duration::from_millis(500));
|
|
|
|
|
|
}
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The turn ended: send its answer back where the message came from.
|
|
|
|
|
|
pub(super) fn channels_settled(&mut self, bot_id: u64, outcome: TurnOutcome) {
|
|
|
|
|
|
let Some(targets) = self.ch.replies.remove(&bot_id) else { return };
|
|
|
|
|
|
let answer = match outcome {
|
|
|
|
|
|
TurnOutcome::Success => self.state.bot(bot_id).and_then(|b| b.messages.iter().rev().find(|m| m.role == Role::Assistant && !m.text.trim().is_empty() && !m.error)).map(|m| m.text.clone()),
|
|
|
|
|
|
TurnOutcome::Error => Some("抱歉,這次沒有完成,請再試一次。".to_string()),
|
|
|
|
|
|
TurnOutcome::Cancelled => None,
|
|
|
|
|
|
};
|
|
|
|
|
|
let Some(answer) = answer else { return };
|
|
|
|
|
|
let note = self.ch.note.clone();
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
for t in targets {
|
|
|
|
|
|
if let Err(e) = channels::reply(&t, &answer) {
|
|
|
|
|
|
*note.lock().unwrap() = format!("回覆到 {}「{}」失敗:{e}", t.kind.label(), t.channel_name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn channels_page(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
|
|
|
|
|
|
let p = self.pal;
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "訊息管道", "讓 Bot 在 Slack、Discord、Telegram、Microsoft Teams、Mac 的「訊息」或「郵件」回覆別人。收到訊息時 Bot 會像收到你的訊息一樣開始工作,做完後把回答傳回去(Slack 回在討論串,Discord 和 Telegram 引用原訊息)。AnyBot 開著時才會收訊息。", p);
|
|
|
|
|
|
hint(ui, "Microsoft Teams 用你自己的 Microsoft 帳號登入(裝置碼),不需要公開網址;Bot 會以你的身分在聊天或頻道裡回覆。", p);
|
|
|
|
|
|
});
|
|
|
|
|
|
let mut remove = None;
|
|
|
|
|
|
let mut changed = false;
|
|
|
|
|
|
let statuses = channels::statuses().lock().unwrap().clone();
|
|
|
|
|
|
let bots: Vec<(u64, String)> = self.state.bots.iter().map(|b| (b.id, b.name.clone())).collect();
|
|
|
|
|
|
for (i, c) in self.state.channels.iter_mut().enumerate() {
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.label(RichText::new(c.kind.label()).size(FONT_XS).color(p.text2));
|
|
|
|
|
|
ui.label(RichText::new(&c.name).strong().size(FONT_BASE));
|
|
|
|
|
|
let st = statuses.get(&c.id);
|
|
|
|
|
|
let (col, text) = match st {
|
|
|
|
|
|
_ if !c.enabled => (p.text3, "已暫停".to_string()),
|
|
|
|
|
|
Some(s) if s.ok => (Color32::from_rgb(0x14, 0xc3, 0x70), format!("{}{}", s.note, if s.received > 0 { format!("(收到 {} 則)", s.received) } else { String::new() })),
|
|
|
|
|
|
Some(s) => (p.danger, s.note.clone()),
|
|
|
|
|
|
None => (p.text3, "連線中…".into()),
|
|
|
|
|
|
};
|
|
|
|
|
|
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
|
|
|
|
|
|
ui.painter().circle_filled(r.center(), 4.0, col);
|
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(text).size(11.5).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
|
|
|
|
|
if ui.add(egui::Button::new(RichText::new(t("移除")).size(12.0).color(p.danger)).frame(false)).clicked() {
|
|
|
|
|
|
remove = Some(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if ui.checkbox(&mut c.enabled, t("開啟")).changed() {
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
let bot = bots.iter().find(|b| b.0 == c.bot_id).map(|b| b.1.clone()).unwrap_or_else(|| "(Bot 已刪除)".into());
|
Clippy is clean on macOS and Linux, for the app and the relay
Every warning `cargo clippy --all-targets` gave (50 on macOS, 8 more only on
Linux, 1 in the relay), fixed without changing what anything does:
- long types get a name (Peer, Members, Imported, Joining, Mention, Stream…);
- the two big enum variants are boxed (the vault's login plan, joining an
account);
- a test now waits for the copy it relaunched (it left a zombie behind);
- a hint's format had a dead `if` whose two branches were both "";
- the rest is what clippy suggests: sort_by_key, as_chunks, is_none_or,
is_multiple_of, while let, from_ref, next_back, struct init, no casts to
the same type.
Checked: cargo test (177 macOS, 181 Linux), relay tests (11), remote_e2e
28/28, and the live Linux test (X11; Wayland clicks, keys, Chinese typing,
scroll and screenshots).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-07 02:10:28 +00:00
|
|
|
|
hint(ui, format!("由「{bot}」回覆 · {}", if c.target.is_empty() { "任何聊天".to_string() } else { c.target.clone() }), p);
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(i) = remove {
|
|
|
|
|
|
self.state.channels.remove(i);
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
// ── 新增 ──
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "新增管道", "", p);
|
|
|
|
|
|
// Wraps onto a second line in a narrow window instead of widening the dialog.
|
|
|
|
|
|
ui.horizontal_wrapped(|ui| {
|
|
|
|
|
|
for k in [Kind::Telegram, Kind::Slack, Kind::Discord, Kind::Teams, Kind::IMessage, Kind::Email, Kind::Sms, Kind::X] {
|
|
|
|
|
|
if ui.selectable_label(self.ch.new_kind == k, k.label()).clicked() && self.ch.new_kind != k {
|
|
|
|
|
|
self.ch.new_kind = k;
|
|
|
|
|
|
self.ch.new_token.clear();
|
|
|
|
|
|
self.ch.new_target.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
let k = self.ch.new_kind;
|
|
|
|
|
|
if self.ch.new_bot == 0 || !bots.iter().any(|b| b.0 == self.ch.new_bot) {
|
|
|
|
|
|
self.ch.new_bot = self.state.selected;
|
|
|
|
|
|
}
|
|
|
|
|
|
form_row(ui, "名稱", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(&mut self.ch.new_name).hint_text(t("例如 客服群")).desired_width(ui.available_width()));
|
|
|
|
|
|
});
|
|
|
|
|
|
form_row(ui, "回覆的 Bot", p, |ui| {
|
|
|
|
|
|
let cur = bots.iter().find(|b| b.0 == self.ch.new_bot).map(|b| b.1.clone()).unwrap_or_default();
|
|
|
|
|
|
egui::ComboBox::from_id_salt("channel-bot").selected_text(cur).show_ui(ui, |ui| {
|
|
|
|
|
|
for (id, name) in &bots {
|
|
|
|
|
|
ui.selectable_value(&mut self.ch.new_bot, *id, name);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
if k == Kind::Teams {
|
|
|
|
|
|
form_row(ui, "應用程式 ID", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(&mut self.ch.new_client).hint_text(t("Entra 應用程式(用戶端)ID")).desired_width(ui.available_width()).font(egui::TextStyle::Monospace));
|
|
|
|
|
|
});
|
|
|
|
|
|
form_row(ui, "租用戶", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(&mut self.ch.new_tenant).hint_text(t("留空 = 公司或學校帳號")).desired_width(ui.available_width()).font(egui::TextStyle::Monospace));
|
|
|
|
|
|
});
|
|
|
|
|
|
hint(ui, k.token_hint(), p);
|
|
|
|
|
|
// A finished sign-in fills the token.
|
|
|
|
|
|
if let Some(tok) = self.ch.ms_login.lock().unwrap().1.take() {
|
|
|
|
|
|
self.ch.new_token = tok;
|
|
|
|
|
|
}
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
let signed = !self.ch.new_token.is_empty();
|
|
|
|
|
|
if ui.add_enabled(!self.ch.new_client.trim().is_empty(), secondary_button(if signed { "重新登入 Microsoft" } else { "登入 Microsoft" })).clicked() {
|
|
|
|
|
|
let (client, tenant, slot, c) = (self.ch.new_client.clone(), self.ch.new_tenant.clone(), self.ch.ms_login.clone(), ctx.clone());
|
|
|
|
|
|
slot.lock().unwrap().0 = "正在取得登入代碼…".into();
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
match crate::teams::device_code(&client, &tenant) {
|
|
|
|
|
|
Ok((code, url, device, interval)) => {
|
|
|
|
|
|
slot.lock().unwrap().0 = format!("在打開的網頁輸入代碼:{code}({url})");
|
|
|
|
|
|
crate::preview::open_with_system(&url);
|
|
|
|
|
|
c.request_repaint();
|
|
|
|
|
|
let r = crate::teams::wait_for_login(&client, &tenant, &device, interval, std::time::Duration::from_secs(900));
|
|
|
|
|
|
let mut s = slot.lock().unwrap();
|
|
|
|
|
|
match r {
|
|
|
|
|
|
Ok(t) => {
|
|
|
|
|
|
s.0 = "已登入 Microsoft。".into();
|
|
|
|
|
|
s.1 = Some(t);
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => s.0 = e,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => slot.lock().unwrap().0 = format!("拿不到登入代碼:{e}"),
|
|
|
|
|
|
}
|
|
|
|
|
|
c.request_repaint();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
let msg = self.ch.ms_login.lock().unwrap().0.clone();
|
|
|
|
|
|
if !msg.is_empty() {
|
|
|
|
|
|
ui.label(RichText::new(msg).size(FONT_XS).color(p.text2));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else if matches!(k, Kind::IMessage | Kind::Email) {
|
|
|
|
|
|
hint(ui, k.token_hint(), p);
|
|
|
|
|
|
self.ch.new_token = "local".into();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
form_row(ui, "Token", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(&mut self.ch.new_token).password(true).hint_text(t("貼上 Bot Token")).desired_width(ui.available_width()));
|
|
|
|
|
|
});
|
|
|
|
|
|
hint(ui, k.token_hint(), p);
|
|
|
|
|
|
}
|
|
|
|
|
|
form_row(ui, match k { Kind::Telegram => "聊天 ID", Kind::Teams => "聊天或頻道", Kind::IMessage => "對象", Kind::Email => "信箱", Kind::Sms => "你的號碼", Kind::X => "(不用填)", _ => "頻道 ID" }, p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(&mut self.ch.new_target).hint_text(k.target_hint()).desired_width(ui.available_width()).font(egui::TextStyle::Monospace));
|
|
|
|
|
|
});
|
|
|
|
|
|
let needs_target = !matches!(k, Kind::Telegram | Kind::IMessage | Kind::Email | Kind::X);
|
|
|
|
|
|
let ok = !self.ch.new_token.trim().is_empty() && (!needs_target || !self.ch.new_target.trim().is_empty());
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
if k != Kind::Teams && ui.add_enabled(!self.ch.new_token.trim().is_empty(), secondary_button(if matches!(k, Kind::IMessage | Kind::Email) { "測試" } else { "測試 Token" })).clicked() {
|
|
|
|
|
|
let (kind, token, note) = (k, self.ch.new_token.clone(), self.ch.note.clone());
|
|
|
|
|
|
*note.lock().unwrap() = "測試中…".into();
|
|
|
|
|
|
let c = ctx.clone();
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
*note.lock().unwrap() = channels::test(kind, &token).unwrap_or_else(|e| e);
|
|
|
|
|
|
c.request_repaint();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if ui.add_enabled(ok, primary_button("新增", p)).clicked() {
|
|
|
|
|
|
let id = self.state.next_channel_id.max(1);
|
|
|
|
|
|
self.state.next_channel_id = id + 1;
|
|
|
|
|
|
let name = if self.ch.new_name.trim().is_empty() { k.label().to_string() } else { self.ch.new_name.trim().to_string() };
|
|
|
|
|
|
self.state.channels.push(Channel { id, kind: k, name, bot_id: self.ch.new_bot, token: self.ch.new_token.trim().into(), target: self.ch.new_target.trim().into(), enabled: true, client_id: self.ch.new_client.trim().into(), tenant: self.ch.new_tenant.trim().into() });
|
|
|
|
|
|
self.ch.new_client.clear();
|
|
|
|
|
|
self.ch.new_tenant.clear();
|
|
|
|
|
|
self.ch.new_name.clear();
|
|
|
|
|
|
self.ch.new_token.clear();
|
|
|
|
|
|
self.ch.new_target.clear();
|
|
|
|
|
|
changed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
let note = self.ch.note.lock().unwrap().clone();
|
|
|
|
|
|
if !note.is_empty() {
|
|
|
|
|
|
ui.label(RichText::new(note).size(FONT_XS).color(p.text2));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if changed {
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
self.channels_restart(ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------- 連接器 (MCP) ----------
|
|
|
|
|
|
|
|
|
|
|
|
impl App {
|
|
|
|
|
|
/// Connect the configured MCP servers when they change (in the background).
|
|
|
|
|
|
fn mcp_poll(&mut self, ctx: &egui::Context) {
|
|
|
|
|
|
let sig = serde_json::to_string(&self.state.mcp_servers).unwrap_or_default();
|
|
|
|
|
|
if sig == self.ch.mcp_sig || self.ch.mcp_busy.load(Ordering::SeqCst) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
self.ch.mcp_sig = sig;
|
|
|
|
|
|
let servers = self.state.mcp_servers.clone();
|
|
|
|
|
|
let (errs, busy, c) = (self.ch.mcp_errors.clone(), self.ch.mcp_busy.clone(), ctx.clone());
|
|
|
|
|
|
busy.store(true, Ordering::SeqCst);
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
*errs.lock().unwrap() = crate::mcp::sync(&servers);
|
|
|
|
|
|
busy.store(false, Ordering::SeqCst);
|
|
|
|
|
|
c.request_repaint();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) fn connectors_page(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
|
|
|
|
|
|
let p = self.pal;
|
|
|
|
|
|
let before = serde_json::to_string(&self.state.mcp_servers).unwrap_or_default();
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "連接器(MCP)", "接上 Model Context Protocol 伺服器,Bot 就能用它的工具(例如 GitHub、Notion、資料庫、你公司的內部系統)。每個連接器第一次被使用時會先問你。", p);
|
|
|
|
|
|
hint(ui, "本機伺服器填指令(例如 npx -y @modelcontextprotocol/server-filesystem ~/Documents);遠端伺服器填網址(Streamable HTTP),需要時加上 Authorization 標頭。", p);
|
|
|
|
|
|
});
|
|
|
|
|
|
let status = crate::mcp::status();
|
|
|
|
|
|
let errors = self.ch.mcp_errors.lock().unwrap().clone();
|
|
|
|
|
|
let busy = self.ch.mcp_busy.load(Ordering::SeqCst);
|
|
|
|
|
|
let mut remove = None;
|
|
|
|
|
|
for (i, s) in self.state.mcp_servers.iter_mut().enumerate() {
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.label(RichText::new(&s.name).strong().size(FONT_BASE));
|
|
|
|
|
|
let (col, text) = match (s.enabled, status.get(&s.name), errors.iter().find(|e| e.0 == s.name)) {
|
|
|
|
|
|
(false, _, _) => (p.text3, "已關閉".to_string()),
|
|
|
|
|
|
(_, Some(n), _) => (Color32::from_rgb(0x14, 0xc3, 0x70), format!("已連上,{n} 個工具")),
|
|
|
|
|
|
(_, _, Some(e)) => (p.danger, e.1.clone()),
|
|
|
|
|
|
_ if busy => (p.text3, "連線中…".to_string()),
|
|
|
|
|
|
_ => (p.text3, "未連線".to_string()),
|
|
|
|
|
|
};
|
|
|
|
|
|
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
|
|
|
|
|
|
ui.painter().circle_filled(r.center(), 4.0, col);
|
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(text).size(11.5).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
|
|
|
|
|
if ui.add(egui::Button::new(RichText::new(t("移除")).size(12.0).color(p.danger)).frame(false)).clicked() {
|
|
|
|
|
|
remove = Some(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
ui.checkbox(&mut s.enabled, t("開啟"));
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
let what = if s.url.is_empty() { format!("{} {}", s.command, s.args.join(" ")) } else { s.url.clone() };
|
|
|
|
|
|
ui.label(RichText::new(what).monospace().size(11.5).color(p.text3));
|
|
|
|
|
|
field_label(ui, "給 Bot 的使用說明(選填)", p);
|
|
|
|
|
|
ui.add(egui::TextEdit::multiline(&mut s.instructions).desired_rows(1).desired_width(f32::INFINITY).hint_text(t("例如:查詢客戶資料時先用 search_customers")));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(i) = remove {
|
|
|
|
|
|
self.state.mcp_servers.remove(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
let tools = crate::mcp::tools();
|
|
|
|
|
|
if !tools.is_empty() {
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "可以用的工具", "", p);
|
|
|
|
|
|
for t in tools.iter().take(60) {
|
|
|
|
|
|
ui.label(RichText::new(format!("{} · {}", t.server, t.name)).size(FONT_XS).color(p.text2)).on_hover_text(&t.description);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-11-11 08:19:06 +00:00
|
|
|
|
if self.ch.skill_reload.swap(false, Ordering::SeqCst) {
|
|
|
|
|
|
crate::memory::merge_skill_files(&mut self.state.skills);
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
let skill_busy = self.ch.skill_busy.load(Ordering::SeqCst);
|
|
|
|
|
|
let start_skill_install = |src: String, busy: &Arc<AtomicBool>, reload: &Arc<AtomicBool>, note: &Arc<Mutex<Option<(bool, String)>>>, ctx: &egui::Context| {
|
|
|
|
|
|
if busy.swap(true, Ordering::SeqCst) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
*note.lock().unwrap() = None;
|
|
|
|
|
|
let (busy2, reload2, note2, ctx2) = (busy.clone(), reload.clone(), note.clone(), ctx.clone());
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
let res = crate::skills::install_from_source(&src);
|
|
|
|
|
|
match res {
|
|
|
|
|
|
Ok(name) => {
|
|
|
|
|
|
reload2.store(true, Ordering::SeqCst);
|
|
|
|
|
|
*note2.lock().unwrap() = Some((true, format!("已安裝技能「{name}」")));
|
|
|
|
|
|
}
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
*note2.lock().unwrap() = Some((false, e));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
busy2.store(false, Ordering::SeqCst);
|
|
|
|
|
|
ctx2.request_repaint();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
setting_card(ui, p, |ui| {
|
2026-11-11 08:19:06 +00:00
|
|
|
|
setting_title(ui, "技能", "所有 Bot 共用的專業指南與標準作業流程(相容 Agent Skills SKILL.md 規格,支援隨附 scripts/ 與 references/)。開啟的技能會列在 Bot 的目錄中,需要時自動載入。", p);
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
if self.state.skills.is_empty() {
|
2026-11-11 08:19:06 +00:00
|
|
|
|
hint(ui, "還沒有技能。可從下方「技能市集」一鍵加入。", p);
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
let mut remove = None;
|
2026-11-11 08:19:06 +00:00
|
|
|
|
let mut dirty_toggle = false;
|
|
|
|
|
|
for (i, k) in self.state.skills.iter_mut().enumerate() {
|
|
|
|
|
|
let is_open = self.ch.skill_open.as_deref() == Some(k.name.as_str());
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
ui.horizontal(|ui| {
|
2026-11-11 08:19:06 +00:00
|
|
|
|
let name_col = if k.enabled { p.text } else { p.text3 };
|
|
|
|
|
|
ui.label(RichText::new(&k.name).strong().size(FONT_SM).color(name_col)).on_hover_text(&k.description);
|
|
|
|
|
|
if !k.resources.is_empty() {
|
|
|
|
|
|
ui.label(RichText::new(format!("{} 檔", k.resources.len())).size(11.0).color(p.accent));
|
|
|
|
|
|
}
|
|
|
|
|
|
if !k.steps.is_empty() {
|
|
|
|
|
|
ui.label(RichText::new(format!("可重播 {} 步", k.steps.len())).size(11.0).color(p.text3));
|
|
|
|
|
|
}
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
ui.add(egui::Label::new(RichText::new(&k.description).size(FONT_XS).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
2026-11-11 08:19:06 +00:00
|
|
|
|
if ui.add(egui::Button::new(RichText::new(t("刪除")).size(12.0).color(p.danger)).frame(false)).clicked() {
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
remove = Some(i);
|
|
|
|
|
|
}
|
2026-11-11 08:19:06 +00:00
|
|
|
|
if ui.add(egui::Button::new(RichText::new(t(if is_open { "收起" } else { "檢視" })).size(12.0).color(p.text2)).frame(false)).clicked() {
|
|
|
|
|
|
self.ch.skill_open = if is_open { None } else { Some(k.name.clone()) };
|
|
|
|
|
|
}
|
|
|
|
|
|
if ui.checkbox(&mut k.enabled, t("開啟")).changed() {
|
|
|
|
|
|
dirty_toggle = true;
|
|
|
|
|
|
}
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
});
|
2026-11-11 08:19:06 +00:00
|
|
|
|
if is_open {
|
|
|
|
|
|
egui::Frame::new()
|
|
|
|
|
|
.fill(p.pane)
|
|
|
|
|
|
.stroke(Stroke::new(1.0, p.border))
|
|
|
|
|
|
.corner_radius(8)
|
|
|
|
|
|
.inner_margin(Margin::symmetric(10, 8))
|
|
|
|
|
|
.show(ui, |ui| {
|
|
|
|
|
|
if !k.resources.is_empty() {
|
|
|
|
|
|
ui.label(RichText::new(format!("隨附檔案:{}", k.resources.join("、"))).monospace().size(11.0).color(p.text2));
|
|
|
|
|
|
ui.add_space(4.0);
|
|
|
|
|
|
}
|
|
|
|
|
|
let preview: String = k.instructions.chars().take(1800).collect();
|
|
|
|
|
|
ui.label(RichText::new(preview).size(FONT_XS).color(p.text2));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if dirty_toggle {
|
|
|
|
|
|
self.dirty = true;
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
if let Some(i) = remove {
|
2026-11-11 08:19:06 +00:00
|
|
|
|
let gone = self.state.skills.remove(i);
|
|
|
|
|
|
crate::memory::remove_skill_files(&gone.name);
|
|
|
|
|
|
if self.ch.skill_open.as_deref() == Some(gone.name.as_str()) {
|
|
|
|
|
|
self.ch.skill_open = None;
|
|
|
|
|
|
}
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-11-11 08:19:06 +00:00
|
|
|
|
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "技能市集", "內建繁體中文核心技能包離線即裝即用;也可從 Anthropic 官方 anthropics/skills 儲存庫或任意 GitHub 技能資料夾一鍵安裝。", p);
|
|
|
|
|
|
field_label(ui, "內建技能包", p);
|
|
|
|
|
|
let mut add_builtin = None;
|
|
|
|
|
|
for b in crate::skills::BUILTIN_SKILLS {
|
|
|
|
|
|
let added = self.state.skills.iter().any(|s| s.name == b.slug);
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.label(RichText::new(b.slug).strong().size(FONT_SM));
|
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(format!("{} — {}", b.title, b.summary)).size(FONT_XS).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
|
|
|
|
|
if added {
|
|
|
|
|
|
ui.label(RichText::new(t("已加入")).size(12.0).color(p.text3));
|
|
|
|
|
|
} else if ui.add(secondary_button("加入")).clicked() {
|
|
|
|
|
|
add_builtin = Some(b.slug);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if let Some(slug) = add_builtin {
|
|
|
|
|
|
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)),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui.add_space(6.0);
|
|
|
|
|
|
field_label(ui, "Anthropic 開源技能精選(GitHub: anthropics/skills)", p);
|
|
|
|
|
|
for r in crate::skills::REMOTE_MARKET {
|
|
|
|
|
|
let added = self.state.skills.iter().any(|s| s.name == r.name);
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.label(RichText::new(r.name).strong().size(FONT_SM));
|
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(r.summary).size(FONT_XS).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
|
|
|
|
|
if added {
|
|
|
|
|
|
ui.label(RichText::new(t("已加入")).size(12.0).color(p.text3));
|
|
|
|
|
|
} else if ui.add_enabled(!skill_busy, secondary_button("安裝")).clicked() {
|
|
|
|
|
|
start_skill_install(r.source.to_string(), &self.ch.skill_busy, &self.ch.skill_reload, &self.ch.skill_note, ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui.add_space(8.0);
|
|
|
|
|
|
field_label(ui, "從 GitHub、網址或本機資料夾安裝技能", p);
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
let btn_w = 72.0;
|
|
|
|
|
|
let w = (ui.available_width() - btn_w - 8.0).max(120.0);
|
|
|
|
|
|
let resp = ui.add(
|
|
|
|
|
|
egui::TextEdit::singleline(&mut self.ch.skill_src)
|
|
|
|
|
|
.hint_text(t("https://github.com/anthropics/skills/tree/main/skills/… 或本機路徑"))
|
|
|
|
|
|
.desired_width(w)
|
|
|
|
|
|
.font(egui::TextStyle::Monospace),
|
|
|
|
|
|
);
|
|
|
|
|
|
let can_install = !skill_busy && !self.ch.skill_src.trim().is_empty();
|
|
|
|
|
|
let enter = resp.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
|
|
|
|
|
|
if ui.add_enabled(can_install, primary_button("安裝", p)).clicked() || (can_install && enter) {
|
|
|
|
|
|
let src = std::mem::take(&mut self.ch.skill_src);
|
|
|
|
|
|
start_skill_install(src, &self.ch.skill_busy, &self.ch.skill_reload, &self.ch.skill_note, ctx);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if skill_busy {
|
|
|
|
|
|
ui.label(RichText::new(t("正在下載並安裝技能套件…")).size(FONT_XS).color(p.text3));
|
|
|
|
|
|
} else if let Some((ok, msg)) = self.ch.skill_note.lock().unwrap().clone() {
|
|
|
|
|
|
ui.label(RichText::new(msg).size(FONT_XS).color(if ok { Color32::from_rgb(0x14, 0xc3, 0x70) } else { p.danger }));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
// 外掛市集: common connectors, one click away (ones needing a key fill the form below).
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
if std::mem::take(&mut self.ch.focus_market) {
|
|
|
|
|
|
ui.scroll_to_cursor(Some(Align::TOP));
|
|
|
|
|
|
}
|
|
|
|
|
|
setting_title(ui, "連接器市集", "常用的連接器,按「加入」就能用。需要金鑰的會填好下面的表單,補上金鑰再按「新增」。本機的需要先裝 Node.js(npx)或 uv(uvx)。", p);
|
|
|
|
|
|
for (name, desc, cmd, needs) in crate::mcp::MARKET {
|
|
|
|
|
|
let added = self.state.mcp_servers.iter().any(|s| s.name == name);
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.label(RichText::new(name).strong().size(FONT_SM));
|
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(desc).size(FONT_XS).color(p.text3)).truncate());
|
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
|
|
|
|
|
if added {
|
|
|
|
|
|
ui.label(RichText::new(t("已加入")).size(12.0).color(p.text3));
|
|
|
|
|
|
} else if ui.add(secondary_button("加入")).clicked() {
|
|
|
|
|
|
if needs.is_empty() {
|
|
|
|
|
|
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() });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
setting_card(ui, p, |ui| {
|
|
|
|
|
|
setting_title(ui, "新增連接器", "", p);
|
|
|
|
|
|
let (name, cmd, env, headers) = &mut self.ch.new_mcp;
|
|
|
|
|
|
form_row(ui, "名稱", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(name).hint_text(t("例如 github")).desired_width(ui.available_width()));
|
|
|
|
|
|
});
|
|
|
|
|
|
form_row(ui, "指令或網址", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(cmd).hint_text(t("npx -y @modelcontextprotocol/server-github 或 https://…/mcp")).desired_width(ui.available_width()).font(egui::TextStyle::Monospace));
|
|
|
|
|
|
});
|
|
|
|
|
|
form_row(ui, "環境變數", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(env).hint_text(t("GITHUB_TOKEN=…(多個用空白分開,本機伺服器用)")).password(true).desired_width(ui.available_width()));
|
|
|
|
|
|
});
|
|
|
|
|
|
form_row(ui, "標頭", p, |ui| {
|
|
|
|
|
|
ui.add(egui::TextEdit::singleline(headers).hint_text(t("Authorization: Bearer …(遠端伺服器用)")).password(true).desired_width(ui.available_width()));
|
|
|
|
|
|
});
|
|
|
|
|
|
let ok = !name.trim().is_empty() && !cmd.trim().is_empty() && !self.state.mcp_servers.iter().any(|s| s.name == name.trim());
|
|
|
|
|
|
if ui.add_enabled(ok, primary_button("新增", p)).clicked() {
|
|
|
|
|
|
let c = cmd.trim().to_string();
|
|
|
|
|
|
let is_url = c.starts_with("http://") || c.starts_with("https://");
|
|
|
|
|
|
let parts: Vec<String> = c.split_whitespace().map(String::from).collect();
|
|
|
|
|
|
let envs = env.split_whitespace().filter_map(|kv| kv.split_once('=')).map(|(k, v)| (k.to_string(), v.to_string())).collect();
|
|
|
|
|
|
let hdrs = headers.split_once(':').map(|(k, v)| std::iter::once((k.trim().to_string(), v.trim().to_string())).collect()).unwrap_or_default();
|
|
|
|
|
|
self.state.mcp_servers.push(crate::mcp::Server {
|
|
|
|
|
|
name: name.trim().into(),
|
|
|
|
|
|
command: if is_url { String::new() } else { parts.first().cloned().unwrap_or_default() },
|
|
|
|
|
|
args: if is_url { vec![] } else { parts.into_iter().skip(1).collect() },
|
|
|
|
|
|
env: envs,
|
|
|
|
|
|
url: if is_url { c } else { String::new() },
|
|
|
|
|
|
headers: hdrs,
|
|
|
|
|
|
enabled: true,
|
|
|
|
|
|
instructions: String::new(),
|
|
|
|
|
|
});
|
|
|
|
|
|
self.ch.new_mcp = Default::default();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
let _ = ctx;
|
|
|
|
|
|
if serde_json::to_string(&self.state.mcp_servers).unwrap_or_default() != before {
|
|
|
|
|
|
self.dirty = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
mod tests {
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
/// A message from a channel never joins a turn that is running: it waits for its own.
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn a_channel_message_waits_for_a_turn_of_its_own() {
|
|
|
|
|
|
let msg = |bot_id: u64, text: &str| Incoming { bot_id, from: "ann".into(), text: text.into(), reply: ReplyTo { kind: Kind::Telegram, token: String::new(), target: "1".into(), thread: String::new(), channel_name: "c".into() } };
|
|
|
|
|
|
let texts = |v: &[Incoming]| v.iter().map(|m| m.text.clone()).collect::<Vec<_>>();
|
|
|
|
|
|
let mut waiting: VecDeque<Incoming> = [msg(1, "a"), msg(2, "b"), msg(1, "c"), msg(3, "d")].into();
|
|
|
|
|
|
// Bot 2 is in the middle of the person's own question: its message stays.
|
|
|
|
|
|
let ready = ready_messages(&mut waiting, |id| id == 2);
|
|
|
|
|
|
assert_eq!(texts(&ready), ["a", "d"]);
|
|
|
|
|
|
assert_eq!(texts(&waiting.iter().cloned().collect::<Vec<_>>()), ["b", "c"]);
|
|
|
|
|
|
// Later, everyone is free: one message each, the oldest first.
|
|
|
|
|
|
let ready = ready_messages(&mut waiting, |_| false);
|
|
|
|
|
|
assert_eq!(texts(&ready), ["b", "c"]);
|
|
|
|
|
|
assert!(waiting.is_empty());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|