Repository navigation
Conversation
Problem: - The agents panel tracks per-subscription usage, but OpenRouter has no tab. - OpenRouter is the account behind every non-Anthropic, non-Codex backend (opencode, pi via openai-completions, ori), so its spend stays invisible and the widget stays silent for those users (omacom#8270). What this adds: - New collector bin/omarchy-agent-usage-openrouter, printing the shared record contract; picked up automatically by omarchy-agent-usage-update with no panel changes. - Token history in two tiers, selected by key type instead of a setting: - Any API key: local opencode sessions (machine-local, with prompt counts, like claude and codex). - Management key: account-global /activity billing API (with scope account and no prompt counts, like fireworks). - Live prepaid balance from /credits plus a draining key-limit meter from /key on keys that carry a limit. - Docs: collector table row plus "OpenRouter balance and history" section in the agents README, providers default in manifest.json. - Test: test/shell.d/agent-usage-openrouter-scanner-test.sh. Why related work is not enough: - Merged omacom#7709 (Ori as default agent) wires only the ori launcher (ori code) and ships no usage collector, so the panel still shows nothing for OpenRouter spend. - Open omacom#8270 (pi on OpenRouter invisible) describes the symptom; this adds the missing account tab rather than pi attribution. - Open omacom#10330 (dedicated pi collector) counts pi transcripts per backend locally, with no account balance and no cross-client history, which is what /activity provides here. - Open omacom#8649 (Grok/OMP collectors) and closed omacom#6899 (Hermes collector) cover other harnesses and report no OpenRouter credits. Why there is no OpenCode provider tab: - Every opencode-provider row bills to cost zero: free and included models with no billing API, no key limits, and no ledger, so the tab could only count tokens while its meters stayed empty. - Its model ids are unstable aliases (e.g. big-pickle, hy3-free), which would rot the tokens-by-model breakdown. - A harness is not a billing account: the same tokens already surface under Codex and OpenRouter tabs, so a harness tab would double-count spend no sync scope could resolve. Validation: - test/shell.d/agent-usage-openrouter-scanner-test.sh: 15 assertions green. - Existing suites green: agent-usage-update, agents-panel, plugin-validate, manifest-entrypoints. - git diff --check clean; live run verified (balance plus today tokens in the panel). Built with Muse Spark 1.3 (Meta) in OpenCode against the OpenRouter API.
Contributor
|
Thank you! Brought in with your authorship in #14039, reindented to two spaces, with timeouts falling back to local stats and the last key-limit meter, and a management key alone now enough for history and balance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The agents panel tracks per-subscription usage, but OpenRouter has no tab: the account behind every non-Anthropic, non-Codex backend (opencode, pi via openai-completions, ori) stays invisible, and the widget stays silent for those users (#8270).
This adds
bin/omarchy-agent-usage-openrouter, which prints the shared record contract and is picked up automatically byomarchy-agent-usage-update- no panel changes needed.What it does
OPENROUTER_MANAGEMENT_KEYormanagementKeyin~/.config/omarchy/agents/openrouter.json): account-global/activitybilling API covering every machine and client (withscope: accountand no prompt counts, like fireworks). A 403 falls back to tier 1 silently.GET /api/v1/credits(non-estimated ledger), plus a draining key-limit meter fromGET /api/v1/key.manifest.json.test/shell.d/agent-usage-openrouter-scanner-test.sh(15 assertions).Why related work is not enough
ori code) and ships no usage collector, so the panel still shows nothing for OpenRouter spend./activityprovides here.Why there is no OpenCode provider tab
Validation
git diff --checkclean; live run verified (balance plus today tokens in the panel).Built with Muse Spark 1.3 (Meta) in OpenCode against the OpenRouter API.