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.

fix(host): report Cursor CLI and unified plan usage

Sean Ferguson3cf1cce15a81
diff --git a/docs/features/marketplace.md b/docs/features/marketplace.md
index 87aab2f3..ec06d7e4 100644
--- a/docs/features/marketplace.md
+++ b/docs/features/marketplace.md
@@ -50,6 +50,12 @@ The host asks the installed Codex CLI's app-server `account/rateLimits/read` met
The CLI must be signed in as the user running the host. Missing, rejected or unavailable account readings remove the Codex provider rather than reusing session-log snapshots. Windows whose reported reset has already passed are omitted. A signed-out host therefore does not keep showing an old percentage with “resets in 0m.” Sign in with `codex login --device-auth`, or use Extensions > Codex > Sign in. Existing client usage views render the same window shape without a protocol change.
+## Cursor usage
+
+Settings > Usage lists Cursor alongside every other provider the host reports. When no desktop login is available in the Cursor app's `state.vscdb`, the host reads the CLI's `accessToken` from its saved `auth.json`: `$XDG_CONFIG_HOME/cursor/auth.json` (normally `~/.config/cursor/auth.json`) on Linux, `%APPDATA%/Cursor/auth.json` on Windows, and `~/.cursor/auth.json` on macOS when the CLI uses file storage. A macOS CLI login stored only in Keychain still needs the desktop-app login for usage reporting.
+
+Every five minutes, the host calls `https://api2.cursor.sh/aiserver.v1.DashboardService/GetSandUsageStatus` with the saved bearer token. A unified plan (`isUnified: true`, including Super) reports one **Weekly** window from `usagePercent`, resetting at `nextResetTimestampUtc`. Missing usage is not converted to zero. The legacy `https://cursor.com/api/usage-summary` endpoint is read only for non-unified plans, retaining their Monthly, Auto and API readings. Its monthly fields can report zero for a unified plan even when the unified allowance is partly used, so they never supply a unified reading. The host sends the existing `usage` event and never logs or changes the credentials. Existing client views render the weekly window without a client or protocol change.
+
## WorkBuddy
WorkBuddy is a built-in agent that runs the CLI bundled inside the WorkBuddy desktop app (`WorkBuddy AI.app` from workbuddy.ai or `WorkBuddy.app` from codebuddy.cn on macOS; `%LOCALAPPDATA%\Programs\WorkBuddy AI` or `…\WorkBuddy` on Windows). The app ships only the lite bundle (`codebuddy-lite-wb.mjs`), so Codync sets `CODEBUDDY_FORCE_LITE_WB_BUNDLE=1` and starts `{bin} --serve --acp`. `--acp` alone loads a headless bundle the app does not include, and the process exits. `--serve` is what starts ACP; `--acp` selects its stdio transport (the HTTP banner on stdout is ignored). That file is also named `codebuddy`, so Codync does not take it from `PATH`: a `codebuddy` command there stays [CodeBuddy Code](https://www.npmjs.com/package/@tencent-ai/codebuddy-code). It is a Node script, so the agent list asks for Node.js (Codync's own when the computer has none). There is no installer in Codync, and no Linux build, so Linux doesn't list it. The app's login is encrypted for the app, so the CLI does not see it: a prompt with no token comes back as `stopReason: refusal` with the error in `_meta["codebuddy.ai/errorMessage"]`, which Codync reads as that error (`acp::codebuddy::prompt_result`): a sign-in card holding the message, or the bot's next agent. Its session opens signed out, so a check asks `_codebuddy.ai/getUserInfo` instead (only whether it names an account: the answer carries tokens). On `authenticate`, Codync opens the http(s) page from the `_codebuddy.ai/authUrl` notification. Select **WorkBuddy** and sign in from that card. It honors `CODEBUDDY_DISABLE_AUTO_MEMORY`, so a bot can keep WorkBuddy's own memory on the same way as CodeBuddy Code.
diff --git a/host/src/usage/cursor.rs b/host/src/usage/cursor.rs
index 11c26d7e..4a9ff7b1 100644
--- a/host/src/usage/cursor.rs
+++ b/host/src/usage/cursor.rs
@@ -1,48 +1,95 @@
-//! Cursor's usage summary. Cursor has no usage command: the token is the one
-//! the Cursor app saved in `state.vscdb`, and the summary is
-//! `GET https://cursor.com/api/usage-summary`. The token is never logged.
+//! Cursor's plan usage, using the app's `state.vscdb` or CLI's `auth.json` login.
+//! Unified plans use the dashboard service's weekly allowance. The website's
+//! usage summary reports only the legacy monthly pools. The token is never logged.
use base64::Engine as _;
use base64::engine::general_purpose::{URL_SAFE, URL_SAFE_NO_PAD};
use rusqlite::{Connection, OpenFlags};
use serde_json::Value;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::time::Duration;
use super::Window;
pub(super) async fn collect() -> Option<Vec<Window>> {
- let token = tokio::task::spawn_blocking(read_token).await.ok().flatten()?;
- let sub = jwt_sub(&token)?;
- let cookie = cookie(&sub, &token)?;
+ let token_result = tokio::task::spawn_blocking(read_token).await;
+ let token = token_result.ok().flatten()?;
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(15))
.redirect(reqwest::redirect::Policy::none())
.build()
.ok()?;
- let response = client
+
+ let status_request = client
+ .post("https://api2.cursor.sh/aiserver.v1.DashboardService/GetSandUsageStatus")
+ .bearer_auth(&token)
+ .header("Connect-Protocol-Version", "1")
+ .json(&serde_json::json!({}));
+ let status_result = read_response(status_request).await;
+ let status = status_result?;
+ if status["isUnified"].as_bool() == Some(true) {
+ return parse_unified(&status);
+ }
+
+ let sub = jwt_sub(&token)?;
+ let cookie = cookie(&sub, &token)?;
+ let summary_request = client
.get("https://cursor.com/api/usage-summary")
.header("Cookie", cookie)
- .header("Accept", "application/json")
- .send()
- .await
- .ok()?;
+ .header("Accept", "application/json");
+ let summary_result = read_response(summary_request).await;
+ let summary = summary_result?;
+ Some(parse(&summary))
+}
+
+async fn read_response(request: reqwest::RequestBuilder) -> Option<Value> {
+ let response_result = request.send().await;
+ let response = response_result.ok()?;
if !response.status().is_success() {
- tracing::debug!(status = %response.status(), "cursor usage summary was refused");
+ tracing::debug!(status = %response.status(), "cursor usage request was refused");
return None;
}
- let body: Value = response.json().await.ok()?;
- Some(parse(&body))
+ let body_result = response.json::<Value>().await;
+ body_result.ok()
+}
+
+fn parse_unified(status: &Value) -> Option<Vec<Window>> {
+ let percent = non_negative(status["usagePercent"].as_f64())?;
+ let resets = status["nextResetTimestampUtc"].as_str().and_then(iso_ms);
+ Some(vec![Window::new("weekly", "Weekly", percent, resets)])
}
-fn db_path() -> Option<PathBuf> {
- let path = dirs::config_dir()?.join("Cursor/User/globalStorage/state.vscdb");
- path.is_file().then_some(path)
+fn cli_auth_path() -> Option<PathBuf> {
+ #[cfg(target_os = "macos")]
+ return Some(dirs::home_dir()?.join(".cursor/auth.json"));
+ #[cfg(windows)]
+ return Some(dirs::config_dir()?.join("Cursor/auth.json"));
+ #[cfg(not(any(target_os = "macos", windows)))]
+ Some(dirs::config_dir()?.join("cursor/auth.json"))
}
fn read_token() -> Option<String> {
- let path = db_path()?;
- let conn = Connection::open_with_flags(&path, OpenFlags::SQLITE_OPEN_READ_ONLY).ok()?;
+ let cli_path = cli_auth_path();
+ let app_path = dirs::config_dir().map(|dir| dir.join("Cursor/User/globalStorage/state.vscdb"));
+ read_saved_token(cli_path.as_deref(), app_path.as_deref())
+}
+
+fn read_saved_token(cli_path: Option<&Path>, app_path: Option<&Path>) -> Option<String> {
+ // A stale CLI login must not hide an already-working desktop login.
+ app_path.and_then(read_app_token).or_else(|| read_cli_token(cli_path?))
+}
+
+fn read_cli_token(path: &Path) -> Option<String> {
+ let raw = std::fs::read_to_string(path).ok()?;
+ let auth: Value = serde_json::from_str(&raw).ok()?;
+ let token = token_text(auth["accessToken"].as_str()?);
+ let sub = jwt_sub(&token)?;
+ cookie(&sub, &token)?;
+ Some(token)
+}
+
+fn read_app_token(path: &Path) -> Option<String> {
+ let conn = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_ONLY).ok()?;
conn.busy_timeout(Duration::from_millis(200)).ok()?;
let raw =
conn.query_row("SELECT value FROM ItemTable WHERE key = 'cursorAuth/accessToken'", [], stored_text).ok()?;
@@ -129,6 +176,32 @@ mod tests {
use super::*;
use serde_json::json;
+ #[test]
+ fn a_unified_super_plan_reports_its_weekly_usage_and_actual_reset() {
+ let status = json!({
+ "isUnified": true,
+ "cursorPlanName": "Super",
+ "usagePercent": 46.030_076_118_571_69,
+ "nextResetTimestampUtc": "2026-10-27T23:30:44.854Z",
+ "billingCycleEnd": "2026-11-01T00:00:00.000Z",
+ "individualUsage": {"plan": {"totalPercentUsed": 0, "autoPercentUsed": 0, "apiPercentUsed": 0}}
+ });
+ let windows = parse_unified(&status).unwrap();
+ assert_eq!(windows.len(), 1, "a unified allowance is not three legacy pools");
+ assert_eq!((windows[0].id.as_str(), windows[0].label.as_str()), ("weekly", "Weekly"));
+ assert!((windows[0].percent - 46.030_076_118_571_69).abs() < 1e-9);
+ assert_eq!(windows[0].resets_at, Some(1_793_143_844_854));
+ }
+
+ #[test]
+ fn missing_unified_usage_is_not_reported_as_zero() {
+ for status in [json!({"isUnified": true}), json!({"usagePercent": -1}), json!({"usagePercent": "46%"})] {
+ assert_eq!(parse_unified(&status), None);
+ }
+ let windows = parse_unified(&json!({"usagePercent": 0})).unwrap();
+ assert!(windows[0].percent.abs() < f64::EPSILON, "an explicit zero is a valid reading");
+ }
+
#[test]
fn the_summary_keeps_each_percent_the_api_reports() {
let body = json!({
@@ -171,8 +244,7 @@ mod tests {
#[test]
fn a_database_value_is_the_saved_token() {
- let path = std::env::temp_dir().join(format!("codync-cursor-{}.db", std::process::id()));
- let _ = std::fs::remove_file(&path);
+ let path = std::env::temp_dir().join(format!("codync-cursor-{}.db", uuid::Uuid::new_v4()));
let conn = Connection::open(&path).unwrap();
conn.execute("CREATE TABLE ItemTable (key TEXT, value BLOB)", []).unwrap();
conn.execute(
@@ -181,11 +253,38 @@ mod tests {
)
.unwrap();
drop(conn);
- let conn = Connection::open_with_flags(&path, OpenFlags::SQLITE_OPEN_READ_ONLY).unwrap();
- let raw = conn
- .query_row("SELECT value FROM ItemTable WHERE key = 'cursorAuth/accessToken'", [], stored_text)
- .unwrap();
- let _ = std::fs::remove_file(&path);
- assert_eq!(token_text(&raw), "tok");
+ let cli_path = path.with_extension("json");
+ for raw in ["{", "{}", r#"{"accessToken":""}"#, r#"{"accessToken":"not-a-jwt"}"#] {
+ std::fs::write(&cli_path, raw).unwrap();
+ assert_eq!(read_saved_token(Some(&cli_path), Some(&path)).as_deref(), Some("tok"));
+ assert_eq!(read_saved_token(Some(&cli_path), None), None);
+ }
+ let token = test_token();
+ std::fs::write(&cli_path, json!({"accessToken": token}).to_string()).unwrap();
+ assert_eq!(read_saved_token(Some(&cli_path), Some(&path)).as_deref(), Some("tok"));
+ assert_eq!(read_saved_token(Some(&cli_path), None), Some(token));
+ std::fs::remove_file(&cli_path).unwrap();
+ assert_eq!(read_saved_token(Some(&cli_path), Some(&path)).as_deref(), Some("tok"));
+ std::fs::remove_file(&path).unwrap();
+ assert_eq!(read_saved_token(Some(&cli_path), Some(&path)), None);
+ assert!(!path.exists(), "reading an absent desktop database never creates one");
+ }
+
+ #[test]
+ fn a_cli_only_login_supplies_usage_credentials_without_changing_them() {
+ let path = std::env::temp_dir().join(format!("codync-cursor-{}.json", uuid::Uuid::new_v4()));
+ let token = test_token();
+ let raw = json!({"accessToken": token, "refreshToken": "leave-this-alone"}).to_string();
+ std::fs::write(&path, &raw).unwrap();
+ let saved = read_saved_token(Some(&path), None);
+ let after = std::fs::read_to_string(&path).unwrap();
+ std::fs::remove_file(&path).unwrap();
+ assert_eq!(saved, Some(token));
+ assert_eq!(after, raw);
+ }
+
+ fn test_token() -> String {
+ let payload = URL_SAFE_NO_PAD.encode(br#"{"sub":"user_cli"}"#);
+ format!("eyJhbGciOiJub25lIn0.{payload}.sig")
}
}
diff --git a/host/src/usage/mod.rs b/host/src/usage/mod.rs
index b768c7f2..af315e8f 100644
--- a/host/src/usage/mod.rs
+++ b/host/src/usage/mod.rs
@@ -6,9 +6,9 @@
//! `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.
+//! Cursor's saved CLI or app login reads the dashboard service's weekly unified
+//! allowance, or the website's usage summary for legacy monthly plans. These are
+//! the only provider requests, and the token is never logged.
mod amp;
mod antigravity;
diff --git a/web/content/docs/agents.mdx b/web/content/docs/agents.mdx
index 23963569..bf866f79 100644
--- a/web/content/docs/agents.mdx
+++ b/web/content/docs/agents.mdx
@@ -1,10 +1,12 @@
Every bot runs one coding agent on your computer. Codync drives agents through the [Agent Client Protocol](https://agentclientprotocol.com) (ACP), so it can run any agent that speaks it: the ones it knows by name, everything in the official [ACP registry](https://agentclientprotocol.com/registry), and any command you give it. Each bot picks its own agent, and different bots can use different ones.
-Codync uses the agents with the accounts they're already signed in to on your computer, such as Claude Code with your Claude plan or Codex with your ChatGPT plan. It never calls a provider's API with your login.
+Codync uses the agents with the accounts they're already signed in to on your computer, such as Claude Code with your Claude plan or Codex with your ChatGPT plan. Cursor's usage checks are the exception to reading usage locally; see [Privacy](/docs/privacy).
## Usage limits
-On desktop, open **Settings > Usage** to see the limits reported by your connected computers. The host refreshes usage every five minutes.
+On desktop, open **Settings > Usage** to see the limits reported by your connected computers, including Cursor. The host refreshes usage every five minutes. Unified Cursor plans, including Super, show one **Weekly** allowance with its next reset. Older Cursor plans retain their monthly usage readings.
+
+Cursor usage works with the CLI's saved sign-in file on Linux and Windows, or the Cursor desktop app's sign-in. On macOS, a CLI login stored only in Keychain needs the desktop app signed in too; CLI file storage also works. You do not need to install the Cursor desktop app on a Linux or Windows host just to report usage.
Codex needs its CLI installed and signed in on the computer. The host reads current account limits without starting a conversation or using a model. If the login stops working or the current limits are unavailable, old session-file readings are not shown. Sign in again from **Extensions** or run `codex login --device-auth` on that computer.
diff --git a/web/content/docs/privacy.mdx b/web/content/docs/privacy.mdx
index c01ffc63..6598db8b 100644
--- a/web/content/docs/privacy.mdx
+++ b/web/content/docs/privacy.mdx
@@ -5,7 +5,7 @@ Codync keeps your work on your computer. The phone and desktop apps are windows
- **Bots, conversations, routines and memory** are kept by the host in `~/.codync` on your computer. Your phone keeps a cache so the app opens quickly.
- **Agents run with their own logins.** Claude Code, Codex and the other agents use the sign-ins you set up on the computer. Your prompts go from the agent to its provider, as they would without Codync.
- **Secrets are encrypted.** Connector credentials, voice API keys and other keys you enter in Codync are stored encrypted on the computer. The encryption key is held by the system's credential store (Keychain on macOS, Secret Service on Linux, Credential Manager on Windows). They're never sent to Codync's cloud.
-- **Usage limits are read on your computer.** The host reads them from the agents installed there: Claude Code's usage command and status line, the Codex CLI's read-only current-account query, and the same kind of local report from oh-my-pi, Amp, Kiro, Kimi, Antigravity, OpenCode, Mistral Vibe and Junie. The Codex query does not start a conversation or model turn, and its CLI manages its own sign-in. Cursor is the exception. It has no local report, so the host reads the sign-in Cursor saved and asks cursor.com for the summary. That token is not logged, and Codync does not call any other provider's API with an agent's login. To read Claude Code's limits, `codync-host install` routes its status line through `codync-host statusline`; a status line you already had keeps working and is restored when you uninstall.
+- **Usage limits are read on your computer.** The host reads them from the agents installed there: Claude Code's usage command and status line, the Codex CLI's read-only current-account query, and the same kind of local report from oh-my-pi, Amp, Kiro, Kimi, Antigravity, OpenCode, Mistral Vibe and Junie. The Codex query does not start a conversation or model turn, and its CLI manages its own sign-in. Cursor is the exception. It has no local report, so the host reads the sign-in Cursor saved and asks Cursor's dashboard service for unified-plan usage, or cursor.com for a legacy-plan summary. That token is not logged, and Codync does not call any other provider's API with an agent's login. To read Claude Code's limits, `codync-host install` routes its status line through `codync-host statusline`; a status line you already had keeps working and is restored when you uninstall.
## The relay