F3: Kimi inference pipeline + full grok cloud-surface excision

Sampler / inference (PRD F3):
- kimi_compat.rs: single adaptation point for the Kimi chat/completions
  dialect (thinking-field mapping, model_id stripping, empty-content
  tool-call message fix, stream_options.include_usage), with kimi-cli
  source citations
- Rate-limit handling reworked for Kimi/Moonshot semantics; UA kigi/{version}
- /models replaces the xAI models-v2 endpoint everywhere; idle model
  refresh carries X-Msh-* device headers only (X-XAI-Token-Auth and
  x-grok-client-mode/CLIENT_MODE_HEADER machinery deleted)

Cloud-surface excision (PRD §5, zero-egress):
- remote/ conversations lane, cli-chat-proxy-types crate, prod/ dir,
  share command, credit bar: deleted (single local session lane;
  paginate() replaces merge_and_paginate)
- Subscription/tier gate stack deleted end-to-end: AppView
  gate/tier/team/ZDR fields, app/subscription.rs watch loop,
  dispatch/billing.rs paywall + SuperGrok upsell, free-usage-exhausted
  chain, tier-restricted commands, GateInfo, RemoteSettings gate fields,
  SettingsUpdateNotification gate fields
- /privacy + coding-data-sharing setting deleted (backed by a dead xAI
  RPC; Kigi is zero-egress — nothing to share or retain remotely)

Auth UX correctness (user-reported):
- Device-flow fixtures now mirror the live Kimi payload shape
  (https://www.kimi.com/code/authorize_device?user_code=..., verified
  against auth.kimi.com); the fabricated auth.kimi.com/device?code=...
  URLs are gone
- open_browser_detached is a no-op under cfg(test): unit tests drove
  wiremock fixture URLs into the real browser (root cause of the
  "garbage mock link" ABCD-1234 tabs)
- Welcome/pager-minimal rebrand: Grok Build -> Kigi, grok.com ->
  kimi.com, "Sign in to Grok" -> "Sign in to Kimi"
This commit is contained in:
2026-07-17 16:05:51 -04:00
parent fe1f885bb3
commit ea0ce9d15f
231 changed files with 4730 additions and 26358 deletions
+7 -113
View File
@@ -56,10 +56,6 @@ pub enum Action {
ExitSession,
/// Exit session without double-press confirmation (e.g., from command palette).
ExitSessionConfirmed,
/// Open grok.com in the browser for SuperGrok subscription upsell.
OpenSupergrokUrl,
/// Re-check subscription status via the shell's `x.ai/auth/check_subscription`.
CheckSubscription,
/// Open an arbitrary URL in the system browser (with scheme validation).
OpenUrl(String),
/// Open grok.com managed connectors, appending session teamId when set.
@@ -587,8 +583,6 @@ pub enum Action {
TrustFolder,
/// A spawned task completed.
TaskComplete(TaskResult),
/// Share the current session via URL.
ShareSession,
/// Show session info (ID, cwd, model, context usage) instantly.
ShowSessionInfo,
/// Show release notes in a modal.
@@ -602,7 +596,7 @@ pub enum Action {
},
/// Show detailed context usage (progress bar, token breakdown, stats).
ShowContextInfo,
/// Show credit usage via /usage command.
/// Show Kimi usage/quota via the /usage command.
ShowUsage,
/// Commit a read-only list of the queued prompts as a system block
/// (`/queue`). The surface minimal mode uses in place of the `QueuePane`.
@@ -663,11 +657,6 @@ pub enum Action {
TriggerDeepSearch,
/// Force an immediate deep content search, skipping the debounce.
ForceDeepSearch,
/// Show privacy and data retention status.
ShowPrivacyInfo,
SetCodingDataSharing {
opted_in: bool,
},
/// `/fork` slash command: parsed args produced by
/// [`crate::slash::commands::fork::parse_fork_args`]. The dispatcher
/// resolves the worktree question (via flag or the local
@@ -1698,11 +1687,6 @@ pub enum Effect {
tool_name: String,
enabled: bool,
},
/// Share the current session via URL.
ShareSession {
agent_id: AgentId,
session_id: acp::SessionId,
},
/// Fetch and display session info via x.ai/session/info.
ShowSessionInfo {
agent_id: AgentId,
@@ -1777,19 +1761,6 @@ pub enum Effect {
},
/// Log out via `x.ai/auth/logout` (shell clears auth.json + in-memory state).
Logout,
/// Re-check subscription status via `x.ai/auth/check_subscription`.
/// `verify` scopes the result to a deferred-gate verification (see
/// [`crate::app::subscription`]); `None` for generic checks.
CheckSubscription { verify: Option<u64> },
/// One-shot subscription re-check triggered by a credit-limit 403.
/// If the tier changed, the stashed prompt is retried instead of
/// showing the upsell modal.
CreditLimitRecheck { agent_id: AgentId },
/// Schedule a 5s timer that fires `TaskResult::PaywallCheckTick`.
SchedulePaywallCheck,
/// Schedule `TaskResult::GateVerifyTimeout { generation }` after
/// [`crate::app::subscription::GATE_VERIFY_TIMEOUT`].
ScheduleGateVerifyTimeout { generation: u64 },
/// Log out then authenticate sequentially in one task.
SwitchAccount {
request_seq: u64,
@@ -1808,13 +1779,6 @@ pub enum Effect {
UnregisterActiveSession { session_id: acp::SessionId },
/// Quit the application.
Quit,
/// Toggle coding data sharing via ACP.
SetCodingDataSharing {
agent_id: AgentId,
opted_in: bool,
/// Pre-toggle value to revert to on failure.
rollback_to_opted_in: bool,
},
/// Rename the current session.
RenameSession {
agent_id: AgentId,
@@ -1871,16 +1835,9 @@ pub enum Effect {
target_prompt_index: usize,
mode: crate::views::rewind::RewindMode,
},
/// Fetch billing/credit usage from the agent's `x.ai/billing` extension.
/// When `silent` is true the result updates `credit_balance` without
/// pushing a system message into scrollback (used for automatic refreshes
/// on session init and after each turn).
FetchBilling { agent_id: AgentId, silent: bool },
/// Fetch billing data at the app level (no agent required).
/// Used on startup to populate the welcome-screen credit warning.
FetchAppBilling,
/// Re-fetch remote settings to check subscription gate.
RefreshGate,
/// Fetch Kimi usage/quota rows from the agent's `x.ai/billing`
/// extension (`GET {base}/usages` shell-side) for the `/usage` view.
FetchUsage { agent_id: AgentId },
/// Spawn a debounce sleep task for shell suggestions. `agent_id` rides
/// to the expiry so the fetch is built from the arming agent, not
/// whatever view is active when the timer fires.
@@ -2019,9 +1976,6 @@ pub enum TaskResult {
/// Session list fetched for the welcome screen picker.
SessionListLoaded {
sessions: Vec<crate::app::app_view::SessionPickerEntry>,
/// Degraded conversations lane (`_meta["x.ai/partial"]`), surfaced
/// as an actionable picker notice instead of a silent empty list.
partial: Option<crate::app::effects::ConversationsPartial>,
/// Echo of [`Effect::FetchSessionList::seq`]; stale results are dropped.
seq: u64,
/// Echo of [`Effect::FetchSessionList::query`]. `Some` marks the
@@ -2256,16 +2210,6 @@ pub enum TaskResult {
agent_id: AgentId,
result: Result<(), String>,
},
/// Share session completed successfully.
ShareSessionComplete {
agent_id: AgentId,
share_url: String,
},
/// Share session failed.
ShareSessionFailed {
agent_id: AgentId,
error: String,
},
/// Session info fetched successfully.
SessionInfoComplete {
agent_id: AgentId,
@@ -2277,17 +2221,6 @@ pub enum TaskResult {
agent_id: AgentId,
error: String,
},
/// Coding data sharing preference updated.
CodingDataSharingUpdated {
agent_id: AgentId,
opted_in: bool,
},
/// Coding data sharing update failed.
CodingDataSharingFailed {
agent_id: AgentId,
error: String,
rollback_to_opted_in: bool,
},
/// Session rename completed successfully.
RenameSessionComplete {
agent_id: AgentId,
@@ -2405,25 +2338,6 @@ pub enum TaskResult {
},
/// Shell acknowledged logout (auth cleared).
LogoutComplete,
/// Shell responded to `x.ai/auth/check_subscription`. `verify` echoes
/// the generation from `Effect::CheckSubscription` for deferred-gate
/// verifications.
CheckSubscriptionComplete {
verify: Option<u64>,
meta: Option<serde_json::Value>,
},
/// Result of the credit-limit subscription re-check. If the tier
/// changed the stashed prompt is retried; otherwise the upsell is shown.
CreditLimitRecheckComplete {
agent_id: AgentId,
meta: Option<serde_json::Value>,
},
/// 5s paywall check timer fired -- time to send another check.
PaywallCheckTick,
/// The deferred-gate verification window expired.
GateVerifyTimeout {
generation: u64,
},
/// The 2-second "copied!" display timer expired.
AuthCopiedTimeout,
DeepSearchResults {
@@ -2470,30 +2384,10 @@ pub enum TaskResult {
agent_id: AgentId,
error: String,
},
/// Billing data fetched from the agent.
BillingFetched {
/// Kimi usage/quota rows fetched for the `/usage` view.
UsageFetched {
agent_id: AgentId,
balance: Option<crate::views::credit_bar::CreditBalance>,
/// When true, update `credit_balance` silently (no scrollback message).
silent: bool,
/// Subscription tier piggybacked from remote settings.
subscription_tier: Option<String>,
/// Auto top-up rule fetch result; `Unchanged` keeps any cached rule.
autotopup: crate::views::credit_bar::AutoTopupFetch,
},
/// App-level billing data (welcome screen).
AppBillingFetched {
balance: Option<crate::views::credit_bar::CreditBalance>,
autotopup: crate::views::credit_bar::AutoTopupFetch,
},
GateRefreshed {
settings: Option<kigi_shell::util::config::RemoteSettings>,
},
BillingError {
agent_id: AgentId,
error: String,
/// When true, swallow the error silently (background refresh).
silent: bool,
result: Result<Vec<kigi_shell::extensions::billing::UsageRow>, String>,
},
/// Debounce timer for shell suggestions expired. Routed by the arming
/// `agent_id`.