Login picker: offer all three platforms like the official CLI
The unauthenticated welcome screen previously offered only 'Login with
Kimi Code'. It now lists every interactive platform the shell
advertises, matching the official kimi-cli picker:
Kimi Code (OAuth)
Moonshot Open Platform (API key · moonshot.cn)
Moonshot Open Platform (API key · moonshot.ai)
Quit
- Shell: new ACP auth methods moonshot-cn / moonshot-ai (advertised
after kimi-code; the BYOK first-position invariant holds).
authenticate(moonshot-*) reloads keys from env>config, fails with an
actionable message when none is configured, validates the key against
GET {base}/models (401 → 'invalid API key' naming the console), then
swaps the fresh config in, triggers the model sync, and reports
auth_mode api_key so the pager treats it like other API-key logins.
Never session-based; keys never logged.
- Config: save_platform_api_key persists [platforms.<id>].api_key via an
atomic mode-preserving write under the config lock; refuses OAuth
platforms, blank keys, and unparseable files.
- TUI: the Pending welcome renders the picker rows from the advertised
methods (arrows/Enter/mouse; 'l' keeps selecting the OAuth row).
Choosing a Moonshot row opens a masked paste box ('Paste your Moonshot
API key (from platform.moonshot.cn)'); Esc returns to the picker,
Enter persists the key and authenticates in one sequential effect;
failures return to the picker with the error line, success lands on
the normal welcome. Startup eager-auth is unchanged: a key already in
the environment authenticates exactly as before, and single-method
shells keep the historical auto-device-flow.
Gates: workspace check/clippy 0/0; shell 4870 + tui 6620 lib tests
green; headless probe advertises [kimi-code, moonshot-cn, moonshot-ai]
for a fresh user and xai.api_key-first with a key configured.
This commit is contained in:
@@ -569,6 +569,15 @@ pub enum Action {
|
||||
CancelLogin,
|
||||
/// User submitted a manually-pasted auth token (loopback mode).
|
||||
SubmitAuthCode(String),
|
||||
/// User selected a Moonshot row on the welcome login picker: switch the
|
||||
/// welcome screen into API-key entry for that platform.
|
||||
BeginPlatformKeyEntry(crate::app::app_view::PlatformLogin),
|
||||
/// Esc from the API-key entry box: return to the login picker.
|
||||
CancelPlatformKeyEntry,
|
||||
/// User submitted a pasted Moonshot API key: persist it to
|
||||
/// `[platforms.<id>]` in config.toml, then authenticate with the
|
||||
/// platform's method id. The key must never be logged.
|
||||
SubmitPlatformApiKey(String),
|
||||
/// Copy the auth URL to the clipboard during authentication.
|
||||
CopyAuthUrl,
|
||||
/// Show the raw auth URL with mouse capture disabled for manual copy.
|
||||
@@ -1611,6 +1620,14 @@ pub enum Effect {
|
||||
PollAuthUrl { request_seq: u64 },
|
||||
/// Submit a manually-pasted auth code (ext request).
|
||||
SubmitAuthCode { request_seq: u64, code: String },
|
||||
/// Persist a Moonshot API key to `[platforms.<id>]` in config.toml, then
|
||||
/// send AuthenticateRequest with the platform's method id. SECURITY: the
|
||||
/// key must never appear in logs or errors.
|
||||
PersistPlatformApiKeyAndAuthenticate {
|
||||
request_seq: u64,
|
||||
target: crate::app::app_view::PlatformLogin,
|
||||
key: String,
|
||||
},
|
||||
/// Fetch MCP server list from the shell (kigi/mcp/list).
|
||||
FetchMcpsList {
|
||||
agent_id: AgentId,
|
||||
|
||||
Reference in New Issue
Block a user