refactor: move Kimi for Coding provider to SDK#281
Conversation
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1feb1a23a4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| private async buildAuth(force: boolean): Promise<ProviderRequestAuth> { | ||
| const apiKey = await this.toolkit.ensureFresh(KIMI_CODE_PROVIDER_NAME, { force }); |
There was a problem hiding this comment.
Preserve login-required errors from OAuth refresh
When the user has no stored token or the refresh token is revoked, KimiOAuthToolkit.ensureFresh throws OAuthError/OAuthUnauthorizedError; letting that escape here means Agent error normalization classifies the failed prompt as internal rather than auth.login_required, so SDK callers using this provider won't get the login-required code that existing ProviderManager-based OAuth paths provide. Wrap ensureFresh failures (and any blank token) in KimiError(ErrorCodes.AUTH_LOGIN_REQUIRED, ...) before returning auth.
Useful? React with 👍 / 👎.
| return { | ||
| providerName: 'kimi-for-coding', | ||
| provider, | ||
| modelCapabilities: UNKNOWN_CAPABILITY, |
There was a problem hiding this comment.
Preserve Kimi for Coding capabilities
When SDK callers use this provider directly, returning UNKNOWN_CAPABILITY leaves max_context_tokens at 0 and all modality flags false. The agent's compaction strategy treats maxSize <= 0 as never compact, and ToolManager only registers ReadMediaFile when image/video caps are true, so this regresses long-session compaction and media-file support compared with the managed Kimi Code config that declares Kimi for Coding's context length and capabilities.
Useful? React with 👍 / 👎.
Related Issue
No linked issue. The problem is described below.
Problem
KimiForCodingProvideris SDK-specific because it wires Kimi Code OAuth credentials, Kimi Code request headers, and the managed Kimi Code base URL into aModelProvider. Keeping that implementation underagent-corecrosses the package boundary and makes core carry SDK/OAuth-specific provider construction.What changed
KimiForCodingProviderinpackages/node-sdk/src/kimi-code-model-provider.ts.KimiForCodingProviderandKimiForCodingProviderOptionsfrom the SDK entry point.ResolvedRuntimeProviderfrom theagent-corepublic entry point so the SDK provider can implement the publicModelProvidercontract without importing from an internal source path.Validation
pnpm --filter @moonshot-ai/kimi-code-sdk run typecheckpnpm --filter @moonshot-ai/agent-core run typecheckpnpm --filter @moonshot-ai/kimi-code-sdk run buildChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.