- 账单/用量查询:balance:kimi(Moonshot 开放平台余额)、NewAPI 中转站余额(accessToken+userId)、Kimi/智谱/MiniMax 套餐档位(5小时/7天) - managed:kimi-code 走 Kimi Code OAuth 登录凭据查询订阅用量,access token 过期自动 refresh 并写回凭据(单 flight 锁 + 写回前重读防 CLI 竞态) - 全屏「配置用量查询」页面:启用开关 / 自动检测 vs NewAPI 模板 / 超时与自动查询间隔 / 测试查询 - 供应商卡片紧凑用量行(切换使用左侧)+ 多档明细行;managed 供应商列表置顶(仅展示层) - 用量显示中英文适配(five_hour→5小时、weekly_limit→7天,Rust 错误串本地化映射) - 修复:usage_kinds serde rename 导致账单入口不显示;测试查询因 save 触发 loading 翻页卸载面板导致结果丢失(silent save)
130 lines
3.6 KiB
TypeScript
130 lines
3.6 KiB
TypeScript
export type Agent = "kimi_code" | "pi";
|
|
|
|
export type ProviderType =
|
|
| "kimi"
|
|
| "anthropic"
|
|
| "openai"
|
|
| "openai_responses"
|
|
| "google-genai"
|
|
| "vertexai";
|
|
|
|
export interface Provider {
|
|
name: string;
|
|
provider_type: ProviderType;
|
|
base_url: string | null;
|
|
api_key: string | null;
|
|
env: Record<string, string>;
|
|
/** Optional note / remark for the provider. */
|
|
note?: string | null;
|
|
/** Optional official website URL. */
|
|
official_url?: string | null;
|
|
/** Managed/OAuth providers skip credential validation. */
|
|
managed?: boolean;
|
|
/** Whether the provider is enabled/activated. */
|
|
enabled?: boolean;
|
|
/** Whether this provider is the currently active one for Kimi Code. */
|
|
active?: boolean;
|
|
/** Manually selected brand icon key (from extracted icons). */
|
|
icon?: string | null;
|
|
/** Custom icon color; falls back to icon metadata defaultColor. */
|
|
icon_color?: string | null;
|
|
/**
|
|
* Usage query kinds (e.g. "balance:deepseek", "plan:kimi_coding").
|
|
* Merged in by the Rust side on load (SQLite settings / base_url detect)
|
|
* and persisted back to SQLite on save; never written to config.toml.
|
|
*/
|
|
usageKinds?: string[];
|
|
/**
|
|
* Usage query configuration edited via the "配置用量查询" panel.
|
|
* Same persistence as usageKinds (SQLite settings, never config.toml).
|
|
*/
|
|
usageConfig?: UsageConfig;
|
|
/** Extra agent-specific provider fields preserved across edits. */
|
|
raw_other?: unknown;
|
|
}
|
|
|
|
export interface Model {
|
|
alias: string;
|
|
provider: string;
|
|
model: string;
|
|
max_context_size: number;
|
|
display_name: string | null;
|
|
/** Whether the model declares extended context / thinking support. */
|
|
supports_1m?: boolean;
|
|
/** Agent-specific capability flags (e.g. Kimi Code `capabilities`). */
|
|
capabilities?: string[];
|
|
/** Extra agent-specific model fields preserved across edits. */
|
|
raw_other?: unknown;
|
|
}
|
|
|
|
export interface Config {
|
|
default_model: string | null;
|
|
providers: Record<string, Provider>;
|
|
models: Record<string, Model>;
|
|
raw_other?: unknown;
|
|
}
|
|
|
|
/**
|
|
* Usage query configuration (mirrors the Rust `UsageConfig`, camelCase).
|
|
* "auto" = query kinds from usageKinds/host detect; "newapi" = query a
|
|
* NewAPI/OneAPI gateway with accessToken + userId.
|
|
*/
|
|
export interface UsageConfig {
|
|
enabled: boolean;
|
|
templateType: "auto" | "newapi";
|
|
baseUrl?: string;
|
|
/** NewAPI web-console access token (NOT the sk- inference key). */
|
|
accessToken?: string;
|
|
/** NewAPI user id, sent as the New-Api-User header. */
|
|
userId?: string;
|
|
/** Auto query interval in minutes; 0/undefined = manual refresh only. */
|
|
autoQueryIntervalMinutes?: number;
|
|
/** Per-request timeout in seconds; 0/undefined = default (8s). */
|
|
timeoutSeconds?: number;
|
|
}
|
|
|
|
/** A model discovered from a provider's API endpoint. */
|
|
export interface DiscoveredModel {
|
|
id: string;
|
|
display_name: string | null;
|
|
max_context_size: number | null;
|
|
}
|
|
|
|
export interface ThinkingConfig {
|
|
enabled?: boolean;
|
|
effort?: "low" | "medium" | "high" | "max";
|
|
keep?: "all" | false | 0 | "no" | "off" | "none" | null;
|
|
}
|
|
|
|
export interface LoopControlConfig {
|
|
max_retries_per_step?: number;
|
|
reserved_context_size?: number;
|
|
}
|
|
|
|
export interface BackgroundConfig {
|
|
max_running_tasks?: number;
|
|
keep_alive_on_exit?: boolean;
|
|
}
|
|
|
|
export interface PermissionRule {
|
|
decision?: "allow" | "deny" | "ask";
|
|
scope?: string;
|
|
pattern?: string;
|
|
reason?: string;
|
|
}
|
|
|
|
export interface Hook {
|
|
event?: string;
|
|
matcher?: string;
|
|
command?: string;
|
|
timeout?: number;
|
|
}
|
|
|
|
export interface AgentSettings {
|
|
thinking?: ThinkingConfig;
|
|
loop_control?: LoopControlConfig;
|
|
background?: BackgroundConfig;
|
|
permission?: { rules?: PermissionRule[] };
|
|
hooks?: Hook[];
|
|
}
|