Skip to content

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.

Merge dev into feat/codync-network

leepokai09de46466612
diff --cc apps/android/WhatsNew.md
index eab83ddf,4641d396..b948318f
--- a/apps/android/WhatsNew.md
+++ b/apps/android/WhatsNew.md
@@@ -7,6 -7,16 +7,26 @@@ released version's section; a version w
else a generic "Bug fixes and improvements" line. Delete old sections.
-->
++## 2.28.0
++
++### zh-Hant
++- 電腦連成網路後,Bot 可以請其他電腦上的 Bot 幫忙。
++- 可以從 ChatGPT 或 Claude 透過聯結器請你的 Bot 做事。
++
++### en-US
++- Bots can ask bots on your other computers once they share a network.
++- ChatGPT or Claude can give your bots tasks through the Codync connector.
++
+ ## 2.27.0
+
+ ### zh-Hant
+ - 擴充套件的列表改回往下捲動,聯結器捲到底會自動載入更多。點項目只看詳情,按「Add」才加入。
+ - 用量也會顯示這台電腦上其他 agent 的額度。Cursor 會用本機登入向 cursor.com 查詢。
+
+ ### en-US
+ - Extensions lists scroll again; connectors load more at the end. Tapping one only opens it; Add adds it.
+ - Adds other agents' limits. Cursor asks cursor.com.
+
## 2.26.2
### zh-Hant
diff --cc apps/ios/WhatsNew.md
index b69ce88a,03000893..18e57f54
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@@ -6,6 -6,22 +6,32 @@@ any left). tools/asc-submit.py reads th
a version without one gets a generic "Bug fixes and improvements" line. Delete old sections.
-->
++## 2.28.0
++
++### zh-Hant
++- 你的電腦連成一個網路後(在電腦上執行 codync-host network),Bot 可以請其他電腦上的 Bot 幫忙;聊天裡會寫出對方 Bot 和它在哪台電腦。
++- 可以把 Codync 加進 ChatGPT 或 Claude 當聯結器,從那裡請你的 Bot 做事;Bot 的聊天會顯示「Message from Cloud assistant」。
++
++### en-US
++- Once your computers share a network (codync-host network on each), a bot can ask a bot on another computer; the chat names that bot and its computer.
++- Add Codync to ChatGPT or Claude as a connector to give your bots tasks from there; the bot's chat shows Message from Cloud assistant.
++
+ ## 2.27.0
+
+ ### zh-Hant
+ - 此版本起需要 iOS 26 或更新版本。
+ - 修正送出文字、清空或替換聊天草稿時可能閃退的問題。
+ - 擴充套件的列表改回往下捲動,不再分頁;聯結器捲到底會自動從 MCP Registry 載入更多。
+ - 點聯結器或智慧體只會打開詳情,要按「Add」或「Set up」才會加入或下載。
+ - 用量也會顯示這台電腦上其他 agent 的額度,包括 oh-my-pi、Amp、Kiro、Kimi、Antigravity、OpenCode、Mistral Vibe 和 Junie。Cursor 會用本機已登入的帳號向 cursor.com 查詢用量。
+
+ ### en-US
+ - This version requires iOS 26 or later.
+ - Fixed a possible crash when sending text or clearing or replacing a chat draft.
+ - Extensions lists scroll again instead of paging; connectors load more from the MCP Registry as you reach the end.
+ - Tapping a connector or agent only opens its details; nothing is added or downloaded until you press Add or Set up.
+ - Usage limits now include the other agents installed on your computer: oh-my-pi, Amp, Kiro, Kimi, Antigravity, OpenCode, Mistral Vibe and Junie. Cursor asks cursor.com with the sign-in saved on that computer.
+
## 2.26.2
### zh-Hant
diff --cc host/Cargo.lock
index 8e764a16,7e050452..b0fc7351
--- a/host/Cargo.lock
+++ b/host/Cargo.lock
@@@ -698,18 -584,9 +698,18 @@@ version = "0.5.4
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
+[[package]]
+name = "cobs"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
+dependencies = [
+ "thiserror 2.0.21",
+]
+
[[package]]
name = "codync-host"
- version = "2.26.2"
+ version = "2.27.0"
dependencies = [
"anyhow",
"axum",
diff --cc host/Cargo.toml
index 7bb649b7,673afb57..21e5964f
--- a/host/Cargo.toml
+++ b/host/Cargo.toml
@@@ -1,9 -1,9 +1,9 @@@
[package]
name = "codync-host"
- version = "2.26.2"
+ version = "2.27.0"
edition = "2024"
-# let-chains (`if let … && let …`) need 1.88.
-rust-version = "1.88"
+# iroh (codync-network) needs 1.91.
+rust-version = "1.91"
default-run = "codync-host"
description = "Runs your coding-agent bots and serves the Codync apps"
license = "Apache-2.0"
diff --cc host/src/usage/claude.rs
index 00000000,9129efa6..5911ea27
mode 000000,100644..100644
--- a/host/src/usage/claude.rs
+++ b/host/src/usage/claude.rs
@@@ -1,0 -1,112 +1,112 @@@
+ //! Claude plan windows: the CLI's `/usage` report, the status-line hook, and
+ //! the ACP adapter's rate-limit event.
+
+ use serde_json::Value;
+
+ use super::Window;
+
+ /// `claude -p /usage`: Claude Code's own local usage report, no model call.
+ pub(super) async fn collect() -> Option<Vec<Window>> {
+ let bin = super::command::program("claude")?;
+ let out = tokio::time::timeout(
- std::time::Duration::from_secs(60),
++ std::time::Duration::from_mins(1),
+ tokio::process::Command::new(bin)
+ .args(["-p", "/usage", "--output-format", "json", "--no-session-persistence"])
+ .current_dir(dirs::home_dir()?)
+ .stdin(std::process::Stdio::null())
+ .kill_on_drop(true)
+ .output(),
+ )
+ .await
+ .ok()?
+ .ok()?;
+ let v: Value = serde_json::from_slice(&out.stdout).ok()?;
+ let windows = parse_claude_usage(v["result"].as_str()?);
+ (!windows.is_empty()).then_some(windows)
+ }
+
+ /// Lines like `Current week (all models): 53% used · resets Sep 26 at 12pm (Asia/Taipei)`.
+ pub fn parse_claude_usage(text: &str) -> Vec<Window> {
+ text.lines()
+ .filter_map(|line| {
+ let (name, rest) = line.trim().split_once(": ")?;
+ let percent: f64 = rest.split_once("% used")?.0.trim().parse().ok()?;
+ let resets = rest.split_once("resets ").map(|(_, r)| r.trim().to_owned());
+ let (id, label) = match name {
+ "Current session" => ("five_hour".to_owned(), "5-hour".to_owned()),
+ "Current week (all models)" => ("seven_day".to_owned(), "Weekly".to_owned()),
+ n => {
+ let model = n.strip_prefix("Current week (")?.strip_suffix(')')?;
+ (format!("seven_day_{}", model.to_lowercase()), format!("Weekly · {model}"))
+ }
+ };
+ Some(Window { resets_text: resets, ..Window::new(id, label, percent, None) })
+ })
+ .collect()
+ }
+
+ /// `POST /ingest/statusline` body: Claude Code's statusline JSON.
+ pub fn ingest_statusline(hub: &crate::hub::Hub, body: &Value) {
+ let rl = &body["rate_limits"];
+ let windows: Vec<Window> = [("five_hour", "5-hour"), ("seven_day", "Weekly")]
+ .into_iter()
+ .filter_map(|(key, label)| {
+ let percent = rl[key]["used_percentage"].as_f64()?;
+ Some(Window::new(key, label, percent, rl[key]["resets_at"].as_i64().map(|s| s.saturating_mul(1000))))
+ })
+ .collect();
+ if !windows.is_empty() {
+ super::merge(hub, "claude", "Claude", "statusline", windows);
+ }
+ }
+
+ /// Claude ACP adapter: `usage_update._meta["_claude/rateLimit"]` (the SDK's `SDKRateLimitInfo`).
+ pub fn ingest_claude_rate_limit(hub: &crate::hub::Hub, info: &Value) {
+ if let Some(w) = claude_window(info) {
+ super::merge(hub, "claude", "Claude", "agent", vec![w]);
+ }
+ }
+
+ fn claude_window(info: &Value) -> Option<Window> {
+ let kind = info["rateLimitType"].as_str()?;
+ let label = match kind {
+ "five_hour" => "5-hour",
+ "seven_day" => "Weekly",
+ "seven_day_opus" => "Weekly · Opus",
+ "seven_day_sonnet" => "Weekly · Sonnet",
+ _ => return None,
+ };
+ let u = info["utilization"].as_f64()?;
+ // The SDK reports a 0–1 fraction (from the unified rate-limit headers).
+ let percent = if u <= 1.0 { u * 100.0 } else { u };
+ // Seconds, but accept milliseconds too.
+ let resets = info["resetsAt"].as_i64().map(|t| if t > 100_000_000_000 { t } else { t.saturating_mul(1000) });
+ Some(Window::new(kind, label, percent, resets))
+ }
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+ use serde_json::json;
+
+ #[test]
+ fn parses_claude_usage_report() {
+ let w = parse_claude_usage(
+ "You are currently using your subscription\n\nCurrent session: 11% used · resets Sep 25 at 5am (Asia/Taipei)\nCurrent week (all models): 53% used · resets Sep 26 at 12pm (Asia/Taipei)\nCurrent week (Fable): 83% used · resets Sep 26 at 12pm (Asia/Taipei)\n\nLast 24h · 794 requests",
+ );
+ assert_eq!(w.len(), 3);
+ assert_eq!(w[0].id, "five_hour");
+ assert!((w[0].percent - 11.0).abs() < f64::EPSILON);
+ assert_eq!(w[0].resets_text.as_deref(), Some("Sep 25 at 5am (Asia/Taipei)"));
+ assert_eq!(w[2].label, "Weekly · Fable");
+ }
+
+ #[test]
+ fn claude_rate_limit_fraction_becomes_percent() {
+ let w = claude_window(&json!({"rateLimitType": "five_hour", "utilization": 0.42, "resetsAt": 1_790_000_000}))
+ .unwrap();
+ assert!((w.percent - 42.0).abs() < 1e-9);
+ assert_eq!(w.resets_at, Some(1_790_000_000_000));
+ assert!(claude_window(&json!({"rateLimitType": "overage", "utilization": 0.1})).is_none());
+ }
+ }
diff --cc host/src/usage/mod.rs
index 00000000,48b8708f..3f7f75e1
mode 000000,100644..100644
--- a/host/src/usage/mod.rs
+++ b/host/src/usage/mod.rs
@@@ -1,0 -1,251 +1,251 @@@
+ //! Subscription usage, read on the host.
+ //!
+ //! Claude: `claude -p /usage`, the status line, and the ACP rate-limit event.
+ //! Codex: the newest rollout's `rate_limits`. The other agents Codync runs are
+ //! read the same way when they can report locally: `omp usage`, `amp usage`,
+ //! `kiro-cli /usage`, a `kimi` screen, Antigravity's language server, OpenCode's
+ //! database, Vibe's session logs, and the `JetBrains` IDE quota file.
+ //!
+ //! Cursor has no local report. The host reads the token the Cursor app saved
+ //! and asks `cursor.com/api/usage-summary`. That is the only provider call, and
+ //! the token is never logged.
+
+ mod amp;
+ mod antigravity;
+ mod claude;
+ mod codex;
+ mod command;
+ mod cursor;
+ mod junie;
+ mod kimi;
+ mod kiro;
+ mod omp;
+ mod opencode;
+ mod vibe;
+
+ pub use claude::{ingest_claude_rate_limit, ingest_statusline};
+
+ use crate::LockExt;
+ use crate::hub::Hub;
+ use serde::Serialize;
+ use std::sync::Arc;
+ use std::time::Duration;
+
-const POLL_EVERY: Duration = Duration::from_secs(5 * 60);
++const POLL_EVERY: Duration = Duration::from_mins(5);
+ /// Usage of a plan above which background work (dreaming, the lead's check-ins) waits.
+ const HEADROOM_PERCENT: f64 = 75.0;
+
+ /// Usage of harness `backend`'s plan above [`HEADROOM_PERCENT`] in any window.
+ /// A note (today's tokens, a dollar balance) is not a plan window.
+ pub fn near_limit(hub: &Hub, backend: &str) -> bool {
+ hub.usage.locked().providers.iter().filter(|p| p.id == backend).any(|p| over_headroom(&p.windows))
+ }
+
+ fn over_headroom(windows: &[Window]) -> bool {
+ windows.iter().any(|w| w.text.is_none() && w.percent > HEADROOM_PERCENT)
+ }
+
+ /// Everything the apps show about limits (wire shape of the `usage` event).
+ #[derive(Serialize, Clone, Debug, Default, PartialEq)]
+ pub struct Usage {
+ pub providers: Vec<Provider>,
+ }
+
+ #[derive(Serialize, Clone, Debug, PartialEq)]
+ #[serde(rename_all = "camelCase")]
+ pub struct Provider {
+ pub id: &'static str,
+ pub name: &'static str,
+ pub windows: Vec<Window>,
+ /// Where the numbers came from: `claude` (CLI), `statusline`, `agent`, `sessions`,
+ /// or a short phrase for the other agents.
+ pub source: &'static str,
+ pub updated_at: i64,
+ }
+
+ #[derive(Serialize, Clone, Debug, PartialEq)]
+ #[serde(rename_all = "camelCase")]
+ pub struct Window {
+ pub id: String,
+ pub label: String,
+ /// Share of the cap already used, 0–100. Zero when [`Self::text`] is set.
+ pub percent: f64,
+ /// Epoch milliseconds, when known.
+ pub resets_at: Option<i64>,
+ /// Human text when only that is known ("Sep 26 at 12pm (Asia/Taipei)").
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub resets_text: Option<String>,
+ /// A reading that isn't a share of a cap ("$4.20", "1.2M tokens", "Unlimited").
+ /// Clients show this instead of the percent, and it never counts as the tightest limit.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub text: Option<String>,
+ }
+
+ impl Window {
+ fn new(id: impl Into<String>, label: impl Into<String>, percent: f64, resets_at: Option<i64>) -> Self {
+ Self { id: id.into(), label: label.into(), percent, resets_at, resets_text: None, text: None }
+ }
+
+ /// A row with no bar: today's tokens, an uncapped balance, an unlimited plan.
+ fn note(id: impl Into<String>, label: impl Into<String>, text: impl Into<String>) -> Self {
+ Self { text: Some(text.into()), ..Self::new(id, label, 0.0, None) }
+ }
+ }
+
+ impl Usage {
+ /// One window at a time, for Claude's status line and rate-limit events.
+ /// The provider's other windows stay.
+ fn merge(&mut self, id: &'static str, name: &'static str, source: &'static str, new: Vec<Window>) {
+ let mut windows = self.providers.iter().find(|p| p.id == id).map(|p| p.windows.clone()).unwrap_or_default();
+ windows.retain(|w| !new.iter().any(|n| n.id == w.id));
+ windows.extend(new);
+ windows.sort_by(|a, b| a.id.cmp(&b.id));
+ self.providers.retain(|p| p.id != id);
+ self.providers.push(Provider { id, name, windows, source, updated_at: crate::store::now_ms() });
+ self.providers.sort_by_key(|p| p.id);
+ }
+
+ /// A probe's full reading. Windows it no longer reports are dropped, and an
+ /// empty reading removes the provider.
+ fn replace(&mut self, id: &'static str, name: &'static str, source: &'static str, new: Vec<Window>) {
+ self.providers.retain(|p| p.id != id);
+ if new.is_empty() {
+ return;
+ }
+ let mut windows = new;
+ windows.sort_by(|a, b| a.id.cmp(&b.id));
+ self.providers.push(Provider { id, name, windows, source, updated_at: crate::store::now_ms() });
+ self.providers.sort_by_key(|p| p.id);
+ }
+ }
+
+ pub(super) fn merge(hub: &Hub, id: &'static str, name: &'static str, source: &'static str, windows: Vec<Window>) {
+ let mut usage = hub.usage.locked().clone();
+ usage.merge(id, name, source, windows);
+ hub.set_usage(usage);
+ }
+
+ pub async fn poll(hub: Arc<Hub>) {
+ loop {
+ refresh(&hub).await;
+ tokio::time::sleep(POLL_EVERY).await;
+ }
+ }
+
+ pub async fn refresh(hub: &Hub) {
+ let (
+ codex,
+ claude,
+ omp_windows,
+ amp_windows,
+ kiro_windows,
+ kimi_windows,
+ antigravity,
+ opencode,
+ vibe_notes,
+ junie,
+ cursor_windows,
+ ) = tokio::join!(
+ tokio::task::spawn_blocking(codex::collect),
+ claude::collect(),
+ omp::collect(),
+ amp::collect(),
+ kiro::collect(),
+ tokio::task::spawn_blocking(kimi::collect),
+ antigravity::collect(),
+ tokio::task::spawn_blocking(opencode::collect),
+ tokio::task::spawn_blocking(vibe::collect),
+ tokio::task::spawn_blocking(junie::collect),
+ cursor::collect(),
+ );
+ apply(hub, joined(codex), "codex", "Codex", "sessions");
+ apply(hub, claude, "claude", "Claude", "claude");
+ apply(hub, omp_windows, "omp", "oh-my-pi", "omp usage");
+ apply(hub, amp_windows, "amp", "Amp", "amp usage");
+ apply(hub, kiro_windows, "kiro", "Kiro CLI", "kiro-cli");
+ apply(hub, joined(kimi_windows), "kimi", "Kimi Code", "kimi");
+ apply(hub, antigravity, "antigravity", "Google Antigravity", "antigravity");
+ apply(hub, joined(opencode), "opencode", "OpenCode", "opencode database");
+ apply(hub, joined(vibe_notes), "vibe", "Mistral Vibe", "vibe logs");
+ apply(hub, joined(junie), "junie", "Junie", "JetBrains IDE");
+ apply(hub, cursor_windows, "cursor", "Cursor", "Cursor");
+ }
+
+ fn joined(result: Result<Option<Vec<Window>>, tokio::task::JoinError>) -> Option<Vec<Window>> {
+ result.ok().flatten()
+ }
+
+ pub(super) fn finite_i64(n: f64) -> Option<i64> {
+ if !n.is_finite() {
+ return None;
+ }
+ let rounded = n.round();
+ #[allow(clippy::cast_precision_loss)]
+ let (min, max) = (i64::MIN as f64, i64::MAX as f64);
+ if !(min..=max).contains(&rounded) {
+ return None;
+ }
+ #[allow(clippy::cast_possible_truncation)]
+ Some(rounded as i64)
+ }
+
+ fn apply(hub: &Hub, windows: Option<Vec<Window>>, id: &'static str, name: &'static str, source: &'static str) {
+ let Some(windows) = windows else { return };
+ let mut usage = hub.usage.locked().clone();
+ usage.replace(id, name, source, windows);
+ hub.set_usage(usage);
+ }
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+ use serde_json::Value;
+
+ #[test]
+ fn merge_replaces_only_matching_windows() {
+ let mut u = Usage::default();
+ u.merge(
+ "claude",
+ "Claude",
+ "claude",
+ vec![Window::new("five_hour", "5-hour", 10.0, None), Window::new("seven_day", "Weekly", 50.0, None)],
+ );
+ u.merge("claude", "Claude", "statusline", vec![Window::new("five_hour", "5-hour", 12.0, None)]);
+ let c = &u.providers[0];
+ assert_eq!((c.windows.len(), c.source), (2, "statusline"));
+ assert!((c.windows[0].percent - 12.0).abs() < f64::EPSILON, "five_hour updated");
+ assert_eq!(serde_json::to_value(&u).unwrap()["providers"][0]["windows"][1]["resetsAt"], Value::Null);
+ }
+
+ #[test]
+ fn a_full_reading_drops_windows_the_probe_no_longer_reports() {
+ let mut u = Usage::default();
+ u.replace(
+ "cursor",
+ "Cursor",
+ "Cursor",
+ vec![Window::new("monthly", "Monthly", 40.0, None), Window::note("on_demand", "On-Demand", "$1")],
+ );
+ u.replace("cursor", "Cursor", "Cursor", vec![Window::note("unlimited", "Monthly", "Unlimited")]);
+ assert_eq!(u.providers[0].windows.len(), 1);
+ assert_eq!(u.providers[0].windows[0].id, "unlimited");
+ u.replace("cursor", "Cursor", "Cursor", Vec::new());
+ assert_eq!(u.providers, []);
+ }
+
+ #[test]
+ fn a_note_is_not_serialized_as_a_missing_percent() {
+ let window = Window::note("cost", "Cost today", "$1.50");
+ let value = serde_json::to_value(&window).unwrap();
+ assert_eq!(value["text"], "$1.50");
+ assert_eq!(value["percent"], 0.0);
+ assert!(value.get("resetsText").is_none());
+ }
+
+ #[test]
+ fn a_note_does_not_count_as_the_plan_running_out() {
+ let note = Window { percent: 99.0, ..Window::note("cost", "Cost today", "$9") };
+ assert!(!over_headroom(&[note]));
+ assert!(over_headroom(&[Window::new("five_hour", "5-hour", 80.0, None)]));
+ }
+ }