mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-04 00:42:14 +00:00
Merge pull request #5761 from Randark-JMT/feat/channel-monitor-quota-mode
feat(monitor): 渠道监控配额模式——关联账号展示用量/余额(重启 #5387)
This commit is contained in:
79 files changed
+4827
-166
No files matched your search
@@ -5,10 +5,57 @@
|
||||
|
||||
import { apiClient } from '../client'
|
||||
|
||||
export type Provider = 'openai' | 'anthropic' | 'gemini' | 'grok'
|
||||
export type Provider =
|
||||
| 'openai'
|
||||
| 'anthropic'
|
||||
| 'gemini'
|
||||
| 'grok'
|
||||
| 'antigravity'
|
||||
| 'kimi'
|
||||
| 'zhipu'
|
||||
| 'deepseek'
|
||||
export type MonitorStatus = 'operational' | 'degraded' | 'failed' | 'error'
|
||||
export type BodyOverrideMode = 'off' | 'merge' | 'replace'
|
||||
export type APIMode = 'chat_completions' | 'responses'
|
||||
/**
|
||||
* probe = LLM 探活(默认);quota = 仅查关联账号用量(零 LLM 成本);
|
||||
* quota_probe = 探活 + 配额快照挂主模型行。
|
||||
*/
|
||||
export type CheckMode = 'probe' | 'quota' | 'quota_probe'
|
||||
|
||||
/** 配额快照中的单个用量窗口(与后端 domain.MonitorQuotaTier 一致)。 */
|
||||
export interface MonitorQuotaTier {
|
||||
/** 5h | 7d | 7d-sonnet | 7d-fable | 30d | daily | weekly | total */
|
||||
window: string
|
||||
/** 同窗口多档时的机器标识(gemini shared/pro/flash、grok requests/tokens、antigravity 模型名) */
|
||||
label?: string
|
||||
used_percent: number
|
||||
used?: number
|
||||
limit?: number
|
||||
/** RFC3339;空表示无重置时间 */
|
||||
reset_at?: string
|
||||
}
|
||||
|
||||
export interface MonitorBalance {
|
||||
currency: string
|
||||
balance: number
|
||||
}
|
||||
|
||||
/** 归一化配额快照(与后端 domain.MonitorQuotaSnapshot 一致)。 */
|
||||
export interface MonitorQuotaSnapshot {
|
||||
/** usage | cn_quota | cn_balance */
|
||||
source: string
|
||||
success: boolean
|
||||
tiers?: MonitorQuotaTier[]
|
||||
balance?: number | null
|
||||
balances?: MonitorBalance[]
|
||||
currency?: string
|
||||
plan_level?: string
|
||||
/** 401/403 鉴权失败标记(推导为 failed 状态) */
|
||||
credential_invalid?: boolean
|
||||
error?: string
|
||||
fetched_at: string
|
||||
}
|
||||
|
||||
export interface ChannelMonitor {
|
||||
id: number
|
||||
@@ -47,6 +94,12 @@ export interface ChannelMonitor {
|
||||
extra_headers: Record<string, string>
|
||||
body_override_mode: BodyOverrideMode
|
||||
body_override: Record<string, unknown> | null
|
||||
/** 检测模式:probe(默认)/ quota / quota_probe */
|
||||
check_mode: CheckMode
|
||||
/** 配额模式关联的账号 ID;探活模式为 null */
|
||||
account_id: number | null
|
||||
/** 主模型最近一次配额快照(配额模式;无历史时为 null) */
|
||||
latest_quota?: MonitorQuotaSnapshot | null
|
||||
}
|
||||
|
||||
export interface ExtraModelStatus {
|
||||
@@ -75,8 +128,14 @@ export interface CreateParams {
|
||||
name: string
|
||||
provider: Provider
|
||||
api_mode?: APIMode
|
||||
/** 探活模式必填(base origin);quota 模式可留空 */
|
||||
endpoint: string
|
||||
/** 探活模式必填;quota 模式可留空 */
|
||||
api_key: string
|
||||
/** 缺省 probe;antigravity 仅支持 quota */
|
||||
check_mode?: CheckMode
|
||||
/** 配额模式必填:数据源账号(provider 需与账号平台一致) */
|
||||
account_id?: number | null
|
||||
primary_model: string
|
||||
extra_models?: string[]
|
||||
group_name?: string
|
||||
@@ -101,6 +160,8 @@ export interface CheckResult {
|
||||
ping_latency_ms: number | null
|
||||
message: string
|
||||
checked_at: string
|
||||
/** 配额模式(quota / quota_probe 主模型行)附带的配额快照 */
|
||||
quota?: MonitorQuotaSnapshot | null
|
||||
}
|
||||
|
||||
export interface RunNowResponse {
|
||||
@@ -115,6 +176,8 @@ export interface HistoryItem {
|
||||
ping_latency_ms: number | null
|
||||
message: string
|
||||
checked_at: string
|
||||
/** 配额快照(配额模式行;探活行为空) */
|
||||
quota?: MonitorQuotaSnapshot | null
|
||||
}
|
||||
|
||||
export interface HistoryParams {
|
||||
|
||||
@@ -718,6 +718,7 @@ export interface SystemSettings {
|
||||
channel_monitor_mode?: 'v1' | 'v2';
|
||||
channel_monitor_default_interval_seconds: number;
|
||||
channel_monitor_hide_throughput?: boolean;
|
||||
channel_monitor_show_quota?: boolean;
|
||||
|
||||
// Available Channels feature switch
|
||||
available_channels_enabled: boolean;
|
||||
@@ -1016,6 +1017,7 @@ export interface UpdateSettingsRequest {
|
||||
channel_monitor_mode?: 'v1' | 'v2';
|
||||
channel_monitor_default_interval_seconds?: number;
|
||||
channel_monitor_hide_throughput?: boolean;
|
||||
channel_monitor_show_quota?: boolean;
|
||||
|
||||
// Available Channels feature switch
|
||||
available_channels_enabled?: boolean;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { apiClient } from './client'
|
||||
import type { Provider, MonitorStatus } from './admin/channelMonitor'
|
||||
import type { MonitorQuotaSnapshot, Provider, MonitorStatus } from './admin/channelMonitor'
|
||||
|
||||
export type { Provider, MonitorStatus } from './admin/channelMonitor'
|
||||
|
||||
@@ -33,6 +33,11 @@ export interface UserMonitorView {
|
||||
availability_7d: number
|
||||
extra_models: UserMonitorExtraModel[]
|
||||
timeline: MonitorTimelinePoint[]
|
||||
/**
|
||||
* 主模型最近配额快照。仅当系统开启 channel_monitor_show_quota 时
|
||||
* 服务端才会下发(关闭时服务端已剥离,前端 flag 仅作纵深防御)。
|
||||
*/
|
||||
latest_quota?: MonitorQuotaSnapshot | null
|
||||
}
|
||||
|
||||
export interface UserMonitorListResponse {
|
||||
|
||||
Reference in new issue
Block a user