Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(ios): send files and start voice calls in group chats
leepokai356700e84c33
diff --git a/apps/desktop/src/renderer/views/call/call-operator.ts b/apps/desktop/src/renderer/views/call/call-operator.tsindex ead247cf..51f88737 100644--- a/apps/desktop/src/renderer/views/call/call-operator.ts+++ b/apps/desktop/src/renderer/views/call/call-operator.ts@@ -1,4 +1,4 @@-import { isChat, type Entry } from '@shared/models'+import { isChat, isGroup, type Entry } from '@shared/models'import type { BotStore } from '../../store/bot-store'import { spokenText } from './voice'@@ -47,8 +47,11 @@ export class CallOperator {const bot = this.store.bots.get(this.botId)const name = bot?.name ?? 'the bot'const about = bot?.description ? ` (${bot.description})` : ''+ const who = bot && isGroup(bot)+ ? `the group chat ${name}${about} on the user's computer, where the bots ${this.store.members(bot).map((m) => m.name).join(', ')} answer in turn (a message that @-mentions one of them asks just that bot). The bots do all the actual work; you relay`+ : `${name}${about}, a coding agent running on the user's computer. ${name} does all the actual work; you relay`return [- `You are the voice on a phone call between the user and ${name}${about}, a coding agent running on the user's computer. ${name} does all the actual work; you relay.`,+ `You are the voice on a phone call between the user and ${who}.`,'- When the user asks for something to be done, changed, checked or answered about their code or computer, call send_to_bot with their request in their own words (keep details, names and code terms exactly). Don\'t do the work or invent results yourself.','- Use bot_status and recent_messages for "what are you doing?" or "what did it say?".','- Call answer_approval only after the user has clearly said which option to pick.',@@ -112,7 +115,7 @@ export class CallOperator {.filter(isChat).slice(-n).map((e) => ({- from: e.kind === 'user' ? 'user' : e.kind === 'agent' ? name : e.kind === 'permission' ? 'approval request' : 'notice',+ from: e.kind === 'user' ? 'user' : e.kind === 'agent' ? (e.data.author && this.store.bots.get(e.data.author)?.name) || name : e.kind === 'permission' ? 'approval request' : 'notice',text: spokenText(e.data.text ?? e.data.title ?? ''),}))return { messages }diff --git a/apps/desktop/src/renderer/views/call/voice-call.ts b/apps/desktop/src/renderer/views/call/voice-call.tsindex 390d0b52..451e1183 100644--- a/apps/desktop/src/renderer/views/call/voice-call.ts+++ b/apps/desktop/src/renderer/views/call/voice-call.ts@@ -1,4 +1,4 @@-import { needsInput } from '@shared/models'+import { isGroup, needsInput } from '@shared/models'import type { BotStore } from '../../store/bot-store'/**@@ -17,11 +17,24 @@ export function watchVoiceCall(store: BotStore, botId: string, handlers: { speakreturn bot ? needsInput(bot) : false})()+ // A group has no status of its own: its members' approvals arrive as cards.+ const cards = new Set(store.allEntries(botId).filter((e) => e.kind === 'permission').map((e) => e.id))+ const nameOf = (author?: string) => (author ? store.bots.get(author)?.name : undefined)+return store.subscribe(() => {+ const group = store.bots.get(botId)+ const inGroup = !!group && isGroup(group)for (const e of store.allEntries(botId)) {+ if (inGroup && e.kind === 'permission' && !cards.has(e.id)) {+ cards.add(e.id)+ if (e.data.status === 'pending' && e.rev > startRev) handlers.announce(`${nameOf(e.data.author) ?? 'A bot'} needs your approval in the chat.`)+ }if (!e.data.final || finals.has(e.id)) continuefinals.add(e.id)- if (e.kind === 'agent' && !e.threadId && e.rev > startRev && e.data.text) handlers.speak(e.data.text)+ if (e.kind !== 'agent' || e.threadId || e.rev <= startRev || !e.data.text) continue+ // In a group, a reply is said with its speaker's name.+ const speaker = inGroup ? nameOf(e.data.author) : undefined+ handlers.speak(speaker ? `${speaker}: ${e.data.text}` : e.data.text)}const bot = store.bots.get(botId)const now = bot ? needsInput(bot) : falsediff --git a/apps/desktop/src/renderer/views/thread/Composer.tsx b/apps/desktop/src/renderer/views/thread/Composer.tsxindex 13cd4735..68285950 100644--- a/apps/desktop/src/renderer/views/thread/Composer.tsx+++ b/apps/desktop/src/renderer/views/thread/Composer.tsx@@ -44,7 +44,7 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {const working = !!bot && isWorkingIn(bot, botId, thread)const empty = !draft.trim() && !files.lengthconst canSend = !empty && (store.connection.kind === 'online' || (store.canQueue && !files.length))- const canAttach = !!bot && !isGroup(bot)+ const canAttach = !!botconst placeholder = thread ? 'Reply…' : bot && isGroup(bot) ? `Message ${bot.name} · @ to ask one bot` : working ? `Queue a message for ${bot?.name ?? ''}` : `Ask ${bot?.name ?? ''}`diff --git a/apps/desktop/src/renderer/views/thread/ThreadView.tsx b/apps/desktop/src/renderer/views/thread/ThreadView.tsxindex 0bd58d1f..385e927e 100644--- a/apps/desktop/src/renderer/views/thread/ThreadView.tsx+++ b/apps/desktop/src/renderer/views/thread/ThreadView.tsx@@ -149,7 +149,7 @@ export function ThreadView({ botId }: { botId: string }) {) : (<ComposerbotId={botId}- onCall={!calling && bot && !isGroup(bot) ? () => setCalling(true) : null}+ onCall={!calling && bot ? () => setCalling(true) : null}onInterrupt={callSpeaking ? () => interruptCall.current?.() : null}/>)}diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/CallOperator.swift b/apps/ios/Kit/Sources/CodyncUI/Call/CallOperator.swiftindex 14874991..aacd3e97 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/CallOperator.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/CallOperator.swift@@ -13,9 +13,16 @@ struct CallOperator {let bot = model.bots[botId]let name = bot?.name ?? "the bot"let about = bot.map { $0.description.isEmpty ? "" : " (\($0.description))" } ?? ""+ let who = if let bot, bot.isGroup {+ "the group chat \(name)\(about) on the user's computer, where the bots "+ + model.members(of: bot).map(\.name).joined(separator: ", ")+ + " answer in turn (a message that @-mentions one of them asks just that bot). "+ + "The bots do all the actual work; you relay"+ } else {+ "\(name)\(about), a coding agent running on the user's computer. \(name) does all the actual work; you relay"+ }return """- You are the voice on a phone call between the user and \(name)\(about), a coding agent \- running on the user's computer. \(name) does all the actual work; you relay.+ You are the voice on a phone call between the user and \(who).- When the user asks for something to be done, changed, checked or answered about their \code or computer, call send_to_bot with their request in their own words (keep details, \names and code terms exactly). Don't do the work or invent results yourself.@@ -83,7 +90,7 @@ struct CallOperator {let messages = model.chat(botId).filter(\.isChat).suffix(min(max(count, 1), 20)).map { e -> [String: String] inlet from = switch e.kind {case "user": "user"- case "agent": name+ case "agent": e.data.author.flatMap { model.bots[$0]?.name } ?? namecase "permission": "approval request"default: "notice"}diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swiftindex 25ef44e2..b241fbe7 100644--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Sync.swift@@ -107,14 +107,18 @@ extension BotStore {if selection == id { selection = nil }onRosterChanged?()case let .entry(e):- let wasFinal = entries[e.botId]?.first(where: { $0.id == e.id })?.data.final == true+ let known = entries[e.botId]?.first(where: { $0.id == e.id })upsert(e)bump(e.rev)acknowledgeVisibleConversations(e.botId, entry: e)- if e.kind == "agent", e.threadId == nil, e.data.final == true, !wasFinal, let text = e.data.text {- for call in Array(voiceCalls.values) where call.botId == e.botId && e.rev > call.startRev {- call.speak(text)- }+ let calls = Array(voiceCalls.values).filter { $0.botId == e.botId && e.rev > $0.startRev }+ if e.kind == "agent", e.threadId == nil, e.data.final == true, known?.data.final != true, let text = e.data.text {+ calls.forEach { $0.speak(spokenReply(e, text)) }+ }+ // A group has no status of its own: its members' approvals arrive as cards.+ if e.kind == "permission", known == nil, e.data.status == "pending", bots[e.botId]?.isGroup == true {+ let name = e.data.author.flatMap { bots[$0]?.name } ?? "A bot"+ calls.forEach { $0.announce("\(name) needs your approval in the chat.") }}case let .usage(u):setUsage(u)@@ -140,6 +144,12 @@ extension BotStore {scheduleSave()}+ /// In a group, a reply is said with its speaker's name.+ private func spokenReply(_ e: Entry, _ text: String) -> String {+ guard bots[e.botId]?.isGroup == true, let name = e.data.author.flatMap({ bots[$0]?.name }) else { return text }+ return "\(name): \(text)"+ }+private func resetMirror() {composerDrafts = [:]persistComposerDrafts()diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swiftindex c8603a5f..08d50587 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift@@ -38,8 +38,7 @@ struct Composer: View {!isEmpty && (model.connection == .online || (model.canQueue && files.isEmpty))}- /// Groups have no folder of their own to put files in.- private var canAttach: Bool { bot?.isGroup == false }+ private var canAttach: Bool { bot != nil }private var placeholder: String {let name = bot?.name ?? ""diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swiftindex 4e85fe69..cfeb74af 100644--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift@@ -51,7 +51,7 @@ public struct ThreadView: View {.transition(.opacity)} else {Composer(botId: botId,- onCall: !calling && bot?.isGroup == false ? { calling = true } : nil,+ onCall: !calling && bot != nil ? { calling = true } : nil,onInterrupt: callSpeaking ? interruptCall : nil)}}diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex 6d2052ff..8731cc31 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -17,6 +17,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 新增「Team」小工具:用 2×2 角色格一眼看四個 bot,需要你的排在最前面。- Bots 小工具每一列右側直接顯示上色的狀態。- 新增控制中心按鈕:顯示最需要你的 bot,一點就打開。+- 群組聊天也能傳檔案和語音通話了:通話時會唸出是哪個 bot 在說話,成員需要你批准時也會提醒。### en-US@@ -28,3 +29,4 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- New Team widget: four bots as characters in a 2×2 grid, the ones that need you first.- Each row of the Bots widget shows its state in color.- New Control Center control: the bot that needs you most, one tap to open it.+- Group chats can now take files and voice calls: the call says which bot is speaking and tells you when one needs your approval.diff --git a/docs/features/groups-and-threads.md b/docs/features/groups-and-threads.mdindex 6634fef7..a2d9bd11 100644--- a/docs/features/groups-and-threads.md+++ b/docs/features/groups-and-threads.md@@ -56,6 +56,11 @@ replies itself.- A new message in the same lane, or Stop, ends a running room turn before its next speaker.- Tool calls, thoughts and permission cards of a member's group turn are written to thegroup (with `author`), not to the member's own chat. One "done" push per room turn.+- Files sent to a group are kept in the group's data folder (`~/.codync/bots/<group>/uploads`);+ each member's prompt lists their paths under the user's line.+- Voice calls work in a group: each final reply is read with its speaker's name, a member's+ pending permission card is announced (a group has no status of its own), and the realtime+ operator is told the room's members.## How a thread continues (`host/src/agent/bot/session.rs`)diff --git a/host/src/api/bots.rs b/host/src/api/bots.rsindex 147acf0a..169ab3ff 100644--- a/host/src/api/bots.rs+++ b/host/src/api/bots.rs@@ -97,7 +97,7 @@ pub(super) async fn call(hub: &Arc<Hub>, method: &str, b: Value) -> Result<Contr// One chunk of a file for a later `send` (`attachments`); base64 `data` at `offset`."upload" => {use base64::Engine as _;- let row = hub.store.bot(str_arg(&b, "botId")?)?.filter(|r| !r.deleted && !r.config.is_group());+ let row = hub.store.bot(str_arg(&b, "botId")?)?.filter(|r| !r.deleted);let root = crate::chat::uploads::root(&row.ok_or_else(|| anyhow!("unknown bot"))?.config);let (id, name) = (str_arg(&b, "uploadId")?.to_owned(), str_arg(&b, "name")?.to_owned());let data =@@ -112,7 +112,7 @@ pub(super) async fn call(hub: &Arc<Hub>, method: &str, b: Value) -> Result<Contr// A sent file, back in chunks (chat previews on other devices)."readUpload" => {use base64::Engine as _;- let row = hub.store.bot(str_arg(&b, "botId")?)?.filter(|r| !r.deleted && !r.config.is_group());+ let row = hub.store.bot(str_arg(&b, "botId")?)?.filter(|r| !r.deleted);let root = crate::chat::uploads::root(&row.ok_or_else(|| anyhow!("unknown bot"))?.config);let id = str_arg(&b, "uploadId")?.to_owned();let offset = b["offset"].as_u64().unwrap_or(0);@@ -150,9 +150,6 @@ pub(super) async fn call(hub: &Arc<Hub>, method: &str, b: Value) -> Result<Contrlet lane = Lane { chat: bot.to_owned(), thread };let (mut paths, mut attachments) = (Vec::new(), Vec::new());if !uploads.is_empty() {- if row.config.is_group() {- bail!("files can't be sent to a group");- }let root = crate::chat::uploads::root(&row.config);for id in uploads {let (path, meta) = crate::chat::uploads::resolve(&root, id)?;diff --git a/host/src/chat/group.rs b/host/src/chat/group.rsindex 5f883c79..341c840c 100644--- a/host/src/chat/group.rs+++ b/host/src/chat/group.rs@@ -240,11 +240,11 @@ fn member_prompt(hub: &Hub, group: &BotConfig, members: &[BotConfig], me: &BotCoif let Some(root) = lane.thread.as_deref().and_then(|r| hub.store.entry(r)) {header = format!("[Group chat: \"{}\", in a thread - with {peer_names}]", group.name);if seen == 0 {- lines.push(format!("(thread started on) {}", line(hub, &root, me)));+ lines.push(format!("(thread started on) {}", line(hub, group, &root, me)));}}for e in hub.store.messages_after(lane, seen, HISTORY_LINES)? {- lines.push(line(hub, &e, me));+ lines.push(line(hub, group, &e, me));}out.push(header);if lines.is_empty() {@@ -261,10 +261,18 @@ fn member_prompt(hub: &Hub, group: &BotConfig, members: &[BotConfig], me: &BotCoOk(out.join("\n"))}-fn line(hub: &Hub, e: &Entry, me: &BotConfig) -> String {+fn line(hub: &Hub, group: &BotConfig, e: &Entry, me: &BotConfig) -> String {let text = e.data["text"].as_str().unwrap_or_default();if e.kind == EntryKind::User.as_str() {- return format!("User: {text}");+ let root = crate::chat::uploads::root(group);+ let files: Vec<_> = e.data["attachments"]+ .as_array()+ .into_iter()+ .flatten()+ .filter_map(|a| crate::chat::uploads::path_of(&root, a))+ .collect();+ let files = if files.is_empty() { String::new() } else { crate::chat::uploads::prompt_suffix(&files) };+ return format!("User: {text}{files}");}let author = e.data["author"].as_str().unwrap_or_default();let text = crate::agent::acp::truncate(text, LINE_CHARS);diff --git a/host/src/chat/uploads.rs b/host/src/chat/uploads.rsindex bbcaea06..d560d705 100644--- a/host/src/chat/uploads.rs+++ b/host/src/chat/uploads.rs@@ -13,6 +13,7 @@ use std::path::{Path, PathBuf};pub const MAX_FILE: u64 = 100 * 1024 * 1024;/// Inside a personal workspace, so reading an upload needs no extra approval.+/// A group (no workspace) keeps its members' shared files in its data folder.pub fn root(cfg: &BotConfig) -> PathBuf {if workspace::is_managed(cfg) {Path::new(&cfg.cwd).join("uploads")@@ -70,6 +71,12 @@ pub fn resolve(root: &Path, upload: &str) -> Result<(PathBuf, Value)> {Ok((file.path(), json!({"id": upload, "name": name, "size": size})))}+/// Where a sent attachment (`{id, name}` chat metadata) lives, without touching the disk.+pub fn path_of(root: &Path, meta: &Value) -> Option<PathBuf> {+ let name = clean_name(meta["name"].as_str()?).ok()?;+ Some(dir(root, meta["id"].as_str()?).ok()?.join(name))+}+/// Up to `len` bytes of a finished upload from `offset`, and its full size.pub fn read(root: &Path, upload: &str, offset: u64, len: usize) -> Result<(Vec<u8>, u64)> {use std::io::{Read as _, Seek as _, SeekFrom};@@ -117,6 +124,7 @@ mod tests {assert_eq!(meta["name"], "a.txt");assert_eq!(read(root, &id, 6, 100).expect("read"), (b"world".to_vec(), 11));assert!(path.starts_with(root));+ assert_eq!(path_of(root, &done), Some(path));let _ = std::fs::remove_dir_all(root);}}diff --git a/host/src/tui/app/input.rs b/host/src/tui/app/input.rsindex a96e0102..0b939c32 100644--- a/host/src/tui/app/input.rs+++ b/host/src/tui/app/input.rs@@ -22,8 +22,8 @@ impl App {} else if let Some(key) = self.draft_key() {self.typing = true;self.focus = Focus::Chat;- // A file dragged onto the terminal pastes its path: attach it (groups have no folder for files).- match dropped_files(&s).filter(|_| self.bot().is_some_and(|b| !b.group)) {+ // A file dragged onto the terminal pastes its path: attach it.+ match dropped_files(&s) {Some(paths) => self.files.entry(key).or_default().extend(paths),None => self.drafts.entry(key).or_default().insert(&s),}