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"
56 lines
2.1 KiB
Rust
56 lines
2.1 KiB
Rust
//! kigi-sampler - Actor-based sampling layer for the Kimi inference APIs.
|
|
//!
|
|
//! This crate extracts the HTTP streaming + retry logic out of
|
|
//! `kigi-shell`'s session actor into a standalone, reusable
|
|
//! component built on the same actor pattern as `kigi-hunk-tracker`.
|
|
//!
|
|
//! ## Layered API
|
|
//!
|
|
//! - **Layer 1**: [`client::SamplingClient`] returns raw chunk streams.
|
|
//! - **Layer 2**: [`stream`] transforms raw streams into [`SamplingEvent`]s.
|
|
//! - **Layer 3**: [`SamplerHandle`] manages concurrent requests with retry,
|
|
//! cancellation, and event-based coordination via the actor.
|
|
//!
|
|
//! The type skeleton, the pure retry / metrics / client logic, the
|
|
//! Layer-2 stream transforms ([`stream_chat_completions`],
|
|
//! [`stream_responses`], [`stream_messages`], [`collect_response`]),
|
|
//! and the actor with its per-request task tie these layers together.
|
|
|
|
pub mod actor;
|
|
pub mod attribution;
|
|
pub mod client;
|
|
pub mod commands;
|
|
pub mod config;
|
|
pub mod doom_loop;
|
|
pub mod events;
|
|
pub mod handle;
|
|
mod kimi_compat;
|
|
pub mod metrics;
|
|
pub mod retry;
|
|
pub mod sampling_log;
|
|
mod shared_http;
|
|
pub mod stream;
|
|
pub mod types;
|
|
|
|
// Public re-exports — the API surface consumers see.
|
|
pub use actor::SamplerActor;
|
|
pub use attribution::{
|
|
Auth401AttributionCallback, SENT_BEARER_PREFIX_LEN, SamplingConsumer, SharedAttributionCallback,
|
|
};
|
|
pub use client::{ApiBackend, SamplingClient, user_agent_string_for};
|
|
pub use config::{
|
|
AuthScheme, BearerResolver, HeaderInjector, OriginClientInfo, RetryPolicy, SamplerConfig,
|
|
SharedBearerResolver, SharedHeaderInjector,
|
|
};
|
|
pub use doom_loop::DoomLoopSignalCollector;
|
|
pub use events::{SamplingChannel, SamplingErrorInfo, SamplingErrorKind, SamplingEvent};
|
|
pub use handle::SamplerHandle;
|
|
pub use metrics::{InferenceLatencyStats, compute_percentiles};
|
|
pub use retry::{
|
|
DEFAULT_MAX_RETRIES, RATE_LIMIT_RETRY_THRESHOLD, RetryDecision, classify_error,
|
|
format_sampling_error, resolve_max_retries, retry_backoff_with_jitter,
|
|
};
|
|
pub use sampling_log::AuthInfo;
|
|
pub use stream::{collect_response, stream_chat_completions, stream_messages, stream_responses};
|
|
pub use types::RequestId;
|