feat(kimi-code): add experimental OS keychain credential storage - #3254
Open
7Sageer wants to merge 2 commits into
Open
feat(kimi-code): add experimental OS keychain credential storage#32547Sageer wants to merge 2 commits into
7Sageer wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: c566aa9 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 |
commit: |
Contributor
|
❌ Nix build failed Hash mismatch in
Please update |
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.
Related Issue
N/A — no tracking issue; the motivation is described below.
Problem
OAuth credentials (managed provider logins and MCP server grants) are stored as plaintext JSON files under
~/.kimi-code/credentials. File permissions (0600) are their only protection — anything running as the user can read long-lived refresh tokens, and secrets like these belong in the OS credential vault.What changed
Adds experimental OS keychain credential storage, opt-in via
KIMI_CODE_EXPERIMENTAL_KEYRING=1(withKIMI_DISABLE_KEYRING=1as a kill switch):packages/oauthstays pure TypeScript and gains aKeyringTokenStoragethat stores each token in the OS keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service) using the exact same wire payload as the file store. Backend selection is gated by the opt-in flag, the kill switch, backend registration, and a runtime capability probe; any keyring call that throws degrades the backend stickily to the file store, so a locked or disappearing keychain never breaks login state.apps/kimi-codeloads the@napi-rs/keyringnative binding at bootstrap and registers it as the backend, wired into the SEA native-asset pipeline and bundle checks; a load failure only warns and keeps the file store.packages/agent-core-v2gives the MCP OAuth grant store the same keychain-backed treatment, selected when a backend is registered and the gate opts in.The opt-in gate is temporary; flipping the default once the rollout is proven is a one-line follow-up.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.