Skip to content

Add a DeepSeek usage collector for the agents panel - #10683

Closed
aholbreich wants to merge 2 commits into
omacom:quattrofrom
aholbreich:deepseek-usage-collector
Closed

aholbreich wants to merge 2 commits into
omacom:quattrofrom
aholbreich:deepseek-usage-collector

Conversation

@aholbreich

@aholbreich aholbreich commented Sep 7, 2026 •

Copy link
Copy Markdown

What

Adds an omarchy-agent-usage-deepseek collector so the agents panel gains a DeepSeek tab, next to Claude, Codex, and Fireworks.

The collector follows the existing contract: it prints one display-ready JSON record; the panel already discovers any record in the usage directory, so no plugin or update-runner change is needed.

Why

DeepSeek usage runs through pi/openCode today, and every existing collector drops it: the Codex collector scans pi/omp sessions but filters strictly for openai-codex, and Claude's scans only Anthropic. Machines that use a DeepSeek key therefore see no DeepSeek entry in the panel at all.

Details

  • Local stats from pi/omp session files whose assistant messages ran on the deepseek provider, plus opencode sessions on a deepseek provider (the same guarded SQL scan the Codex collector uses).
  • Token accounting matches pi's own totals (input + output + cacheRead + cacheWrite; the separate reasoning field is left out, exactly like the Codex collector's pi path).
  • Balance: DeepSeek billing is prepaid, so the record queries GET https://api.deepseek.com/user/balance for the live credit balance (analogous to the Fireworks prepaid ledger). The optional fundedAmount in ~/.config/omarchy/agents/deepseek.json adds the funded-versus-spent estimate line; without it the panel shows the live remaining credit only.
  • Key discovery: DEEPSEEK_API_KEY, then ~/.pi/agent/auth.json, then opencode's auth.json.
  • A DeepSeek mark (shell/plugins/agents/assets/deepseek.svg, brand blue, works on dark and light surfaces) and a README row documenting the collector.

Testing

  • New test file test/shell.d/agent-usage-deepseek-scanner-test.sh (11 assertions): pi/omp session filtering and aggregation, opencode database scan, balance math from fundedAmount, balance omission on endpoint failure, live balance response parsing, and the /user/balance request shape with the bearer key.
  • ./test/shell runs the new file green. Four files fail in this environment for pre-existing reasons unrelated to this change: config-test.sh and unowned-system-paths-test.sh need an omarchy-pkgs checkout (OMARCHY_PKGS_PATH), snapper-test.sh needs the same, and locate-test.sh hits a UTF-8 decode error on this machine.
  • ./test/cli passes.
  • Verified on a real machine: the collector reproduces the pi DeepSeek session usage and the live balance, and the panel renders the new tab (hero "PREPAID", balance, 7-day chart, per-model rows).

@aholbreich

Copy link
Copy Markdown
Author

Rebased onto the latest quattro (5b91db5). Focused scanner tests pass; ready for review.

aholbreich and others added 2 commits September 27, 2026 16:32
pi and opencode now feed one accumulator, so a day active in both is one
active day instead of two. A failed balance lookup lands in the record's
status text the way Fireworks reports it, and a machine without a DeepSeek
key no longer logs a line to the shell on every refresh. Lists deepseek in
the plugin's provider defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aholbreich
aholbreich force-pushed the deepseek-usage-collector branch from a81a2a2 to 4a2a102 Compare September 27, 2026 14:55
@aholbreich

Copy link
Copy Markdown
Author

Rebased on current quattro and did a cleanup pass:

  • pi and opencode now feed one accumulator, so a day with usage in both counts as one active day (it was counted twice before)
  • a failed balance call ends up in the record like it does for Fireworks, instead of on stderr
  • machines without a DeepSeek key no longer log a line on every refresh
  • deepseek is listed in the manifest's provider defaults

All agents plugin tests pass. The only failures I get in ./test/cli and ./test/shell also fail on plain quattro here (vscode theme test, missing omarchy-pkgs checkout).

@dhh

dhh commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thank you! Brought in with your authorship in #14039. The record now only appears on machines with a DeepSeek key, and the test no longer reaches the real API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants