fix: show external Codex usage without inflating OpenCode Zen#119
fix: show external Codex usage without inflating OpenCode Zen#119Daltonganger wants to merge 3 commits intoopgginc:mainfrom
Conversation
…le /v1 URL injection Agent-Logs-Url: https://github.com/Daltonganger/opencode-bar/sessions/2672ff4d-23d5-4e27-9d06-5c3ec83b03b4 Co-authored-by: Daltonganger <17501732+Daltonganger@users.noreply.github.com>
✅ AI Code Review Completed
Review posted successfully — APPROVED with 6 minor inline comments. Reviewed with |
There was a problem hiding this comment.
Review: fix: show external Codex usage without inflating OpenCode Zen
Solid contribution from an external contributor. This PR does three things well:
-
Self-service
/v1/usageendpoint for API-key Codex accounts — clean routing logic with proper URL path rewriting, flexible decoding for mixed API response shapes, and a sensible partition of base vs spark limits. TheSelfServiceLimitdecoder is defensive and handles all the weird type coercion this project's APIs love to throw. Good stuff. -
OpenCode Zen cost deduction — removing
openai/*model costs from the pay-as-you-go total when OpenCode routes through an external Codex LB prevents double-counting. The proportionalavgCostPerDayadjustment is mathematically sound. -
OpenAI API key auth flow — reading
openaiAPIKeyfrom bothauth.json(asAPIKeystruct) and~/.codex/auth.json(as rawOPENAI_API_KEYstring) expands auth coverage cleanly.
Tests are thorough — URL rewriting, self-service payload mapping, missing limits, and the OpenCode Zen exclusion logic all have focused test cases. CI is green across build, lint, and test.
A few minor things to consider below, but nothing blocking.
Reviewed with anthropic/claude-opus-4-6
The bot will automatically re-review when new commits are pushed to this branch. You can also request a review by mentioning @op-gg-ai-devops in a comment. Examples:
@op-gg-ai-devops review typos@op-gg-ai-devops focus on security@op-gg-ai-devops check the URL rewriting logic
❌ AI Code Review CancelledNewer commit detected or workflow was manually cancelled. 📋 View Logs | 🤖 Model: |
Summary
/v1/usagesupport for external OpenAI API-key Codex accounts and map the returned limits into Codex quota dataopenai/*spend as pay-as-you-go when OpenCode routes OpenAI throughprovider.openai.options.baseURLTesting
make lint-swiftxcodebuild -project "CopilotMonitor.xcodeproj" -scheme "CopilotMonitor" -configuration Debug build -quiet