Repository navigation
Conversation
Advertise the quota_provider capability and serve quota.identifier, quota.describe, and quota.fetch so CLIProxyAPI v7.2.159+ (including v8) reports OpenCode Go credentials as quota-capable and serves their rolling, weekly, and monthly windows through /v0/management/quota/fetch. The quota RPC method names and wire shapes are declared locally, so the SDK stays on v7.2.138 and the plugin keeps reporting schema version 3. Older hosts ignore the unknown capability and keep loading the plugin. The separate quota page stays for hosts and Management Center builds without generic plugin quota rendering. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Cap quota upstream lookups at 30 seconds for both the native provider and the separate page, since the default request timeout is minutes long. Assert schema version 3 literally and check the fetch wire keys, so an SDK bump that breaks older hosts fails the tests. Add the native quota provider to the release notes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
OpenCode Go's rolling limit spans five hours. Reporting it as 5h lets Management Center label and order it like other five-hour windows. Document the v8 Management API quota route as well. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Owner
Author
|
Honestly, no strong case. I just wanted native quota on my instance before the v8 transition, and staying on the v7 SDK was the quickest way there. Feel free to close this in favor of #10. If useful for #10: the 30s cap on quota lookups, and labeling the rolling window Thanks for the project, by the way. I use it every day. |
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
OpenCode Go credentials now report quota through CLIProxyAPI's native quota API. The plugin keeps the v7.2.138 SDK, so #10's v8 requirement does not apply here.
quota_providerand servesquota.identifier,quota.describe, andquota.fetch.quota.resetreturnsunsupported.attributes.api_key), never a config default. It reuses the existing upstream/usagecall and error redaction.OpenCode Gogroup, withremainingFraction = (100 - percent) / 100. The rolling window is reported as5h, since OpenCode Go documents it as a five-hour window; this lets Management Center label and order it like other five-hour limits. Absent windows are skipped and percentages are clamped to 0–100.OpenCode Go Quotapage stays.RELEASE_NOTES.mdandREADME.mddescribe the native provider.POST /v0/management/quota/fetchand, on the v8 Management API,POST /v8/management/plugins/opencode-go-cliproxyapi/quotaserve OpenCode Go quota.auth-filesreportssupports_quota: true. The separate page still works.Screenshot from a live CLIProxyAPI v8.0.13 instance running this branch with a real OpenCode Go key, rendered by a forked Management Center build with generic plugin quota support. Official Management Center does not render plugin quota yet.
Why one build loads on both v7 and v8
schema_versionis newer than its own (resp.SchemaVersion > pluginabi.SchemaVersionininternal/pluginhost/rpc_client.go). An SDK at v7.2.159+ or v8 reports schema 6, which v7.2.138–v7.2.158 hosts refuse.internal/plugin/native_quota.go. Those shapes match between v7.2.159 and v8 main, apart from the optionalsummaryfield, which this PR leaves unset.quota_provideris a field in the plugin's own capabilities struct. Hosts older than v7.2.159 decode capabilities withoutDisallowUnknownFieldsand ignore it.Why the separate page stays
Management Center has a fixed set of quota adapters and does not render plugin quota providers yet. Generic plugin rendering is still open in router-for-me/Cli-Proxy-API-Management-Center#432. Removing the page now would leave no UI for OpenCode Go quota, so it can go in a follow-up once Management Center supports plugin quota.
Known limitation
The plugin does not forward the host's
host_callback_idtohost.http.do. Cancelling a management request therefore leaves the upstream call running until the 30 second cap. The executor and the separate quota page share this throughHostBridge, so forwarding the callback ID belongs in its own change.Relation to #10
This covers the native quota part of #10 without the v8 bump. The readable account names from #10 don't depend on it and can land separately.
Cross-review
A second model, Codex
gpt-6-astra, reviewed the branch read-only. It checked the plugin against the CLIProxyAPI source atv7.2.138,v7.2.159, and v8 main.Findings and how they were handled
It confirmed these with no blocking issues:
attributes.api_keyfor auths that the plugin parses.Goplan, error redaction, and config locking are correct.It reported two findings, both confirmed:
host_callback_idand runs oncontext.Background(), and the old 5 minute default was the only bound. Fixed in part: lookups are now capped at 30 seconds. Forwarding the callback ID is left for a separate change (see Known limitation).pluginabi.SchemaVersion, so moving to schema 6 would still pass. Fixed: the test pinsschema_versionto3and checks the fetch response's raw wire keys.Validation
go vet ./...andgo test -tags debug ./...pass, and the-tags debugc-shared build succeeds. End-to-end runs against locally built v8 and v7.2.138 hosts behaved as the table above describes. A live v8.0.13 instance with a real key returned all three windows through both the v0 and v8 routes.Test and end-to-end details
New tests in
internal/plugin/native_quota_test.gocover:The end-to-end runs used the darwin/arm64 C-shared build and a mock
/usageupstream.GET /v0/management/quota/providerslistsopencode-go, andauth-filesshowssupports_quota: true, quota_provider: "opencode-go".POST /v0/management/quota/fetchreturns the three buckets, and the legacyquota-usageroute still returns 200./v0/management/quota/providersreturns 404 because that host has no native quota API.🤖 Generated with Claude Code