Repository navigation
Add a Kimi usage collector to the agents panel - #7274
Conversation
omarchy-agent-usage-kimi prints the Kimi for Coding quota as a usage record: the weekly quota and per-window limits (such as the 5-hour session) from api.kimi.com's usage monitor, the same payload the CLI's /usage command renders. The bearer token comes from KIMI_API_KEY when set, otherwise from the kimi-code sign-in under KIMI_CODE_HOME (default ~/.kimi-code), falling back to the legacy kimi-cli store. Expired tokens are refreshed the way the CLI does, under flock, with the rotated single-use refresh token persisted back so the CLI keeps working from the same file. Tokens only leave the machine for kimi.com over HTTPS and redirects are refused. The panel gains the tab through the existing collector discovery; the manifest enables the provider by default.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new “Kimi” provider to the agents usage panel by introducing a Kimi usage collector, wiring it into the agents plugin manifest, and documenting + testing its auth/limits behavior.
Changes:
- Added
omarchy-agent-usage-kimiPython collector that reads/refreshes Kimi credentials and prints a display-ready JSON record. - Added an end-to-end-ish shell test validating auth precedence, token refresh rotation, endpoint trust rules, and limit rendering.
- Updated agents plugin manifest + docs to list/enable the new
kimiprovider.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/shell.d/agent-usage-kimi-test.sh | Adds regression coverage for Kimi collector auth, refresh, trust, and limits formatting. |
| shell/plugins/agents/manifest.json | Enables the new kimi provider and updates description text. |
| shell/plugins/agents/README.md | Documents Kimi provider behavior and credential lookup/refresh rules. |
| manual/17-ai.md | Updates user-facing manual to include Kimi among supported agents. |
| bin/omarchy-agent-usage-kimi | Introduces the Kimi usage collector implementation (auth, refresh, trust, limits). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Confirmed the credential resolution against the official docs: Kimi Code CLI stores all runtime data, including OAuth credentials, under |
Co-Authored-By: GPT-6 in Codex <[email protected]>
Read all current quota windows, isolate explicit homes, coordinate single-use refresh tokens with the current directory lease or legacy flock, and publish rotated credentials privately after flushing them. Restrict credential destinations and redact service errors. Keep last-known limits visible on failed probes and distinguish quota from local history. Co-Authored-By: GPT-6 in Codex <[email protected]> Co-Authored-By: Codex Medium (GPT-6.1-sol) <[email protected]>
Bind cached limits to the token actually used for the request, and carry last-good quota across a refresh only when this collector verifies the same-account grant. This prevents concurrent sign-in from assigning one account’s limits to another and preserves stale meters after successful rotation followed by an outage. Label the code-specific monthly allowance through the panel’s existing scoped-meter contract. Co-Authored-By: GPT-6 in Codex <[email protected]> Co-Authored-By: Codex Medium (GPT-6.1-sol) <[email protected]>
Reread credentials after the HTTP exchange so a sign-in or logout completed while the request was in flight is preserved. Use the new account’s fresh credentials or report the changed sign-in rather than restoring an older account. Validate the complete rotated token pair before publishing it, matching the current CLI grant contract. Co-Authored-By: GPT-6 in Codex <[email protected]>
|
Pushed fa3681f. The branch applies cleanly to current GPT-6 in Codex verified the change on disposable Omarchy ISO workers without credentials. All 25 Kimi checks passed, along with updater and panel checks. Restoring the reviewed prior implementations reproduced unsafe refresh destinations, cross-home credential fallback, incompatible locking, insecure token writes, missing quotas, disappearing error state, misleading API-key guidance, cache rotation/account races, and sign-in/logout being overwritten. Kimi's exact native lock-library version was exercised in both directions, including a slow refresh protected by its heartbeat. The live panel was inspected with synthetic quota and outage responses: scoped monthly limits render, and failed probes retain measured limits with their age and error guidance. The protocol was checked against the official quota parser and refresh manager. The final Codex Medium (GPT-6.1-sol) contributed verified authentication and cache findings and reviewed the final published head with no remaining actionable issues. Independence of its final agreement is not guaranteed. Authenticated production Kimi API behavior was not exercised. The PR description reflects the final implementation; this is awaiting the maintainer's decision. |
Kimi can be selected as Omarchy's coding agent, but its account limits are missing from the agents panel. Add a discovered
omarchy-agent-usage-kimicollector and enable Kimi alongside the existing providers. The panel shows the current CLI's session, weekly, and monthly quotas, with the code-specific monthly allowance using its existing scoped meter. Legacy quota responses remain supported. The record contains account limits without local token or prompt statistics.Authentication uses
KIMI_API_KEYor the CLI's saved sign-in. An explicitKIMI_CODE_HOMEstays isolated; default installs prefer~/.kimi-codeand can fall back to the legacy~/.kimistore. Refresh coordinates with the current CLI's renewable directory lock or the legacy file lock, rereads credentials after acquisition, and privately flushes and atomically publishes the rotated token pair. Refresh fails when its lock cannot be acquired. A sign-in or logout completed during the refresh request takes precedence over publishing its result. Credentials are sent only to trusted Kimi HTTPS hosts, redirects are refused, and service error bodies cannot publish tokens.Failed probes retain measured limits with their original timestamp and stale status. Cached quotas are bound to the token, home, and endpoint used by the request; verified refreshes carry the same account's previous result forward.
--forcebypasses one-minute probe reuse. Invalid overriding API keys receive guidance to update or unset the key. The plugin README and manual describe the quota-only provider.No separate issue is closed.