Skip to main content

Module modelstudio

Module modelstudio 

Source
Expand description

Alibaba Cloud Model Studio — Token Plan usage over the console gateway the official bl CLI uses (bl auth login --console). A local-login vendor: the credential is the CLI’s own ~/.bailian/config.json console token (read-only, never written; AK/SK refresh is out of scope).

Reports two ratio windows — a 5-hour and a weekly — with epoch-ms reset instants, dispatched per region×site through the gateway matrix in types.rs. Cache is scoped by a fingerprint of the access token, so a re-login never inherits the previous session’s figures, and the token itself never persists anywhere but the CLI’s file.

Re-exports§

pub use fetch::FetchOutcome;
pub use fetch::fetch_snapshot_with;

Modules§

creds
Read the official bl CLI’s own console-login file — read-only, never written. ~/.bailian/config.json (flat snake_case JSON) holds the console Bearer token the CLI stored after bl auth login --console:
fetch
Fetch Model Studio Token Plan usage from the console gateway, with the bl CLI’s own console session (creds.rs). Cache/stale/error-fallback shape mirrors grokbot::fetch: fresh cache short-circuits; on failure, fall back to cache + mark stale. The cache is scoped by a fingerprint of the access token — a re-login selects another console session, so a cache written for one must never be shown for another, and the token itself is never persisted.
types
Wire types for the Alibaba Cloud Model Studio Token Plan console gateway, reconstructed from the official bl CLI (packages/core/src/console/gateway.ts).
vendor
Model Studio renderer — bar text + bordered Pango tooltip. A dual-window vendor (the Codex/Kimi shape): a 5-hour and a weekly window, each with its own percent and reset, either of which the account may not report. An absent window is rendered absent — never as 0%, which would invent an exhaustion the wire never claimed (it may even mean unlimited).

Constants§

APP_DIR_NAME
The bl CLI’s own config directory, under $HOME.
CONFIG_DIR_ENV
Environment override for the whole directory (tilde-expanded).
CONFIG_FILE_NAME
The console-login file inside it.

Functions§

config_path
The config file path against the real environment.
config_path_in
The config file path with every input injected — the test seam, so no test resolves a real $HOME or branches on the ambient environment. Precedence matches the CLI: an explicit [modelstudio] config_dir, then BAILIAN_CONFIG_DIR, then ~/.bailian.
resolve_credentials
Resolve the console session: the CLI’s file, read-only.