mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 01:25:33 +08:00
cd161f4401
Grok CLI's official OAuth mode cannot be routed through the local proxy
(empty config is the mode switch, so there is no injection point), which
left official-mode usage invisible. Add session_usage_grokbuild to
import usage from ~/.grok/sessions updates.jsonl:
- Only turn_completed events carry usage; each event is the independent
per-turn total (accumulated across inference loops within one prompt),
so events are imported at face value. Do not reintroduce differencing
of adjacent events: counters reset every turn and differencing would
massively under-record.
- Cost priority: reported costUsdTicks (1 tick = 1e-10 USD) wins when
complete, because the backfill only repairs rows with total <= 0 and
can never correct a positive mispriced value; local pricing fills the
breakdown and raises a drift warning above max(1% of reported, 1e-6).
costIsPartial marks the reported value a lower bound: prefer a full
local recompute when the model is priced, else record the lower bound.
- Idempotency key grok_session:{session}:{prompt_id}:{model} anchors on
the upstream per-turn UUID (index fallback only when prompt_id is
empty), so rewind truncation cannot shift keys and double count;
orphan rows from truncated turns are kept since the tokens were spent.
- Anti double-count vs proxy takeover: 10min settle window plus a
time-window guard over recent grokbuild proxy activity; guarded skips
never mark files as synced.
- Seed grok-4.5-build pricing 2/6/0.30, back-derived from exact
costUsdTicks samples (cache read bills at 0.30, not the listed 0.50).
- Map _grok_session to a friendly provider display name and refresh the
takeover-capability comment in services/proxy.rs.
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
pub mod balance;
|
|
pub mod codex_oauth_models;
|
|
pub mod coding_plan;
|
|
pub mod config;
|
|
pub mod env_checker;
|
|
pub mod env_manager;
|
|
pub mod mcp;
|
|
pub mod model_fetch;
|
|
pub mod omo;
|
|
pub mod profile;
|
|
pub mod prompt;
|
|
pub mod provider;
|
|
pub mod proxy;
|
|
pub mod s3;
|
|
pub mod s3_auto_sync;
|
|
pub mod s3_sync;
|
|
pub mod session_usage;
|
|
pub mod session_usage_codex;
|
|
pub mod session_usage_gemini;
|
|
pub mod session_usage_grokbuild;
|
|
pub mod session_usage_opencode;
|
|
pub mod skill;
|
|
pub mod speedtest;
|
|
pub mod sql_helpers;
|
|
pub mod stream_check;
|
|
pub mod subscription;
|
|
pub mod subscription_grok;
|
|
pub mod sync_protocol;
|
|
pub mod usage_cache;
|
|
pub mod usage_stats;
|
|
pub mod webdav;
|
|
pub mod webdav_auto_sync;
|
|
pub mod webdav_sync;
|
|
|
|
pub use config::ConfigService;
|
|
pub use mcp::McpService;
|
|
pub use omo::OmoService;
|
|
pub use prompt::PromptService;
|
|
pub use provider::{ProviderService, ProviderSortUpdate, SwitchResult};
|
|
pub use proxy::ProxyService;
|
|
#[allow(unused_imports)]
|
|
pub use skill::{DiscoverableSkill, Skill, SkillRepo, SkillService};
|
|
pub use speedtest::{EndpointLatency, SpeedtestService};
|
|
pub use usage_cache::UsageCache;
|
|
#[allow(unused_imports)]
|
|
pub use usage_stats::{
|
|
DailyStats, LogFilters, ModelStats, PaginatedLogs, ProviderLimitStatus, ProviderStats,
|
|
RequestLogDetail, UsageSummary, UsageSummaryByApp,
|
|
};
|