feat(acp): report Kimi account usage - #2716
Conversation
🦋 Changeset detectedLatest commit: 65f1dce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65f1dceda6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| DEFAULT_MODE_ID, | ||
| ); | ||
| this.scheduleAvailableCommandsUpdate(session.id); | ||
| void acpSession.emitUsageReport(); |
There was a problem hiding this comment.
Add account usage reporting to the default ACP server
The new reporting is wired only into @moonshot-ai/acp-adapter, but apps/kimi-code/src/cli/sub/acp.ts:40-44 routes ordinary kimi acp invocations to @moonshot-ai/acp-server; this adapter is used only when KIMI_CODE_LEGACY_FLAG is enabled. The default server's emitUsageUpdate() still sends context fields without _meta.kimiCode, so nearly all users will not receive the advertised account usage. Implement the metadata and opening update in packages/acp-server as well, or route the default command through this implementation.
Useful? React with 👍 / 👎.
| const billingMode = | ||
| providerId === 'managed:kimi-code' && provider?.oauth !== undefined | ||
| ? 'coding_plan' | ||
| : typeof provider?.apiKey === 'string' && provider.apiKey.length > 0 | ||
| ? 'api_key' |
There was a problem hiding this comment.
Recognize API keys supplied through the provider env table
In the legacy adapter, a Kimi provider configured with [providers.<name>.env] KIMI_API_KEY = "..." is valid and is resolved by providerValue(provider.apiKey, provider.env, 'KIMI_API_KEY') in packages/agent-core/src/session/provider-manager.ts, but this classification checks only provider.apiKey. For that supported configuration the session is actually API-key billed while _meta.kimiCode is omitted entirely; resolve the credential using the same precedence without serializing its value.
Useful? React with 👍 / 👎.
Related Issue
Resolve #2483
Problem
Kimi Code 的 ACP 目前只传输对话和工具事件,没有把 Coding Plan 的额度窗口或 API Key 计费模式暴露给客户端。客户端因此无法在账号状态区域展示真实用量,也无法区分 Coding Plan 与 API Usage Billing。
What changed
usage_updateused/size上下文字段,并在_meta.kimiCode中附加coding_plan/api_key计费模式@moonshot-ai/kimi-code添加 patch changeset验证:
vitest run packages/acp-adapter/test:37 个测试文件、328 个测试通过tsc -p packages/acp-adapter/tsconfig.json --noEmitpnpm --filter @moonshot-ai/kimi-code run buildChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.