mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-04 08:43:20 +00:00
merge: sync contrib/routed-codex-model-catalog with upstream v0.1.182
Keep catalog membership on schedulable accounts and intersect advertised capabilities across all active group members that map an alias. Preserve upstream plugin, service-tier, and models-list body-limit changes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
311 files changed
+19415
-1286
No files matched your search
@@ -33,6 +33,7 @@ export interface ChannelTimePricingPeriod {
|
||||
|
||||
export interface ChannelTimePricing {
|
||||
timezone: string
|
||||
weekdays_only?: boolean
|
||||
periods: ChannelTimePricingPeriod[]
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import affiliatesAPI from './affiliates'
|
||||
import riskControlAPI from './riskControl'
|
||||
import adminComplianceAPI from './compliance'
|
||||
import auditAPI from './audit'
|
||||
import pluginsAPI from './plugins'
|
||||
|
||||
/**
|
||||
* Unified admin API object for convenient access
|
||||
@@ -71,7 +72,8 @@ export const adminAPI = {
|
||||
affiliates: affiliatesAPI,
|
||||
riskControl: riskControlAPI,
|
||||
compliance: adminComplianceAPI,
|
||||
audit: auditAPI
|
||||
audit: auditAPI,
|
||||
plugins: pluginsAPI
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -106,7 +108,8 @@ export {
|
||||
affiliatesAPI,
|
||||
riskControlAPI,
|
||||
adminComplianceAPI,
|
||||
auditAPI
|
||||
auditAPI,
|
||||
pluginsAPI
|
||||
}
|
||||
|
||||
export default adminAPI
|
||||
@@ -118,3 +121,9 @@ export type { ErrorPassthroughRule, CreateRuleRequest, UpdateRuleRequest } from
|
||||
export type { BackupAgentHealth, DataManagementConfig } from './dataManagement'
|
||||
export type { TLSFingerprintProfile, CreateProfileRequest, UpdateProfileRequest } from './tlsFingerprintProfile'
|
||||
export type { ContentModerationConfig, ContentModerationLog, ModerationMode } from './riskControl'
|
||||
export type {
|
||||
PluginInstallation,
|
||||
PluginCompatibility,
|
||||
PluginUISession,
|
||||
PluginTestResult
|
||||
} from './plugins'
|
||||
@@ -0,0 +1,156 @@
|
||||
import { apiClient } from '../client'
|
||||
|
||||
export interface PluginCapability {
|
||||
id: string
|
||||
platform: string
|
||||
account_type: string
|
||||
}
|
||||
|
||||
export interface PluginRequirements {
|
||||
sub2api: string
|
||||
recommended_sub2api_version?: string
|
||||
tested_sub2api_versions?: string[]
|
||||
plugin_protocol: number
|
||||
transport_api: number
|
||||
ui_bridge: number
|
||||
}
|
||||
|
||||
export interface PluginManifest {
|
||||
schema_version: number
|
||||
id: string
|
||||
name: string
|
||||
version: string
|
||||
description?: string
|
||||
author?: string
|
||||
requires: PluginRequirements
|
||||
capabilities: PluginCapability[]
|
||||
ui: { entrypoint: string }
|
||||
}
|
||||
|
||||
export interface PluginCompatibility {
|
||||
compatible: boolean
|
||||
tested: boolean
|
||||
status: 'compatible' | 'untested' | 'incompatible'
|
||||
message: string
|
||||
current_sub2api_version: string
|
||||
required_sub2api_version: string
|
||||
recommended_sub2api_version: string
|
||||
plugin_protocol: number
|
||||
transport_api: number
|
||||
ui_bridge: number
|
||||
}
|
||||
|
||||
export interface PluginBinding {
|
||||
id: number
|
||||
plugin_id: number
|
||||
capability: string
|
||||
platform: string
|
||||
account_type: string
|
||||
enabled: boolean
|
||||
rollout_percent: number
|
||||
}
|
||||
|
||||
export interface PluginInstallation {
|
||||
id: number
|
||||
plugin_key: string
|
||||
name: string
|
||||
version: string
|
||||
description: string
|
||||
author: string
|
||||
manifest: PluginManifest
|
||||
binary_sha256: string
|
||||
signature_status: 'trusted' | 'unsigned'
|
||||
state: 'disabled' | 'starting' | 'enabled' | 'error' | 'incompatible'
|
||||
last_error: string
|
||||
installed_at: string
|
||||
enabled_at?: string
|
||||
updated_at: string
|
||||
bindings: PluginBinding[]
|
||||
compatibility: PluginCompatibility
|
||||
runtime_healthy: boolean
|
||||
runtime_message: string
|
||||
}
|
||||
|
||||
export interface PluginTestResult {
|
||||
success: boolean
|
||||
message: string
|
||||
latency_ms: number
|
||||
}
|
||||
|
||||
export interface PluginUISession {
|
||||
url: string
|
||||
bridge_token: string
|
||||
ui_bridge_version: number
|
||||
expires_at: string
|
||||
}
|
||||
|
||||
export async function list(): Promise<PluginInstallation[]> {
|
||||
const { data } = await apiClient.get<PluginInstallation[]>('/admin/plugins')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function upload(file: File): Promise<PluginInstallation> {
|
||||
const form = new FormData()
|
||||
form.append('plugin', file)
|
||||
const { data } = await apiClient.post<PluginInstallation>('/admin/plugins/upload', form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120000
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
export async function enable(
|
||||
id: number,
|
||||
rolloutPercent: number,
|
||||
acceptUntested: boolean
|
||||
): Promise<PluginInstallation> {
|
||||
const { data } = await apiClient.post<PluginInstallation>(`/admin/plugins/${id}/enable`, {
|
||||
rollout_percent: rolloutPercent,
|
||||
accept_untested: acceptUntested
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
export async function disable(id: number): Promise<PluginInstallation> {
|
||||
const { data } = await apiClient.post<PluginInstallation>(`/admin/plugins/${id}/disable`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function remove(id: number): Promise<void> {
|
||||
await apiClient.delete(`/admin/plugins/${id}`)
|
||||
}
|
||||
|
||||
export async function getConfig(id: number): Promise<Record<string, unknown>> {
|
||||
const { data } = await apiClient.get<Record<string, unknown>>(`/admin/plugins/${id}/config`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function saveConfig(
|
||||
id: number,
|
||||
config: Record<string, unknown>
|
||||
): Promise<Record<string, unknown>> {
|
||||
const { data } = await apiClient.put<Record<string, unknown>>(`/admin/plugins/${id}/config`, config)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function test(id: number): Promise<PluginTestResult> {
|
||||
const { data } = await apiClient.post<PluginTestResult>(`/admin/plugins/${id}/test`)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function createUISession(id: number): Promise<PluginUISession> {
|
||||
const { data } = await apiClient.post<PluginUISession>(`/admin/plugins/${id}/ui-session`)
|
||||
return data
|
||||
}
|
||||
|
||||
export default {
|
||||
list,
|
||||
upload,
|
||||
enable,
|
||||
disable,
|
||||
remove,
|
||||
getConfig,
|
||||
saveConfig,
|
||||
test,
|
||||
createUISession
|
||||
}
|
||||
@@ -727,6 +727,7 @@ export interface SystemSettings {
|
||||
model_plaza_enabled: boolean;
|
||||
model_plaza_require_auth: boolean;
|
||||
model_plaza_description: string;
|
||||
plugin_management_enabled: boolean;
|
||||
|
||||
// Affiliate (邀请返利) feature switch
|
||||
affiliate_enabled: boolean;
|
||||
@@ -1026,6 +1027,7 @@ export interface UpdateSettingsRequest {
|
||||
model_plaza_enabled?: boolean;
|
||||
model_plaza_require_auth?: boolean;
|
||||
model_plaza_description?: string;
|
||||
plugin_management_enabled?: boolean;
|
||||
|
||||
// Affiliate (邀请返利) feature switch
|
||||
affiliate_enabled?: boolean;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
import { apiClient } from './client'
|
||||
import type { UserSupportedModelPricing } from './channels'
|
||||
import type { UserPricingInterval, UserSupportedModelPricing } from './channels'
|
||||
|
||||
/** LiteLLM 官方参考价(USD per token,字段缺失 = 官方数据未覆盖)。 */
|
||||
/** 官方参考价(USD per token,与计费目录同源;字段缺失 = 目录未覆盖)。 */
|
||||
export interface PlazaOfficialPricing {
|
||||
input_price: number | null
|
||||
output_price: number | null
|
||||
@@ -16,13 +16,43 @@ export interface PlazaOfficialPricing {
|
||||
/** 1h 缓存写入(LiteLLM cache_creation_above_1hr),多数模型缺失。 */
|
||||
cache_write_1h_price?: number | null
|
||||
cache_read_price: number | null
|
||||
/** 官方长上下文阶梯(多档模型才有),不受分组开关影响。 */
|
||||
intervals?: UserPricingInterval[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 多档时的计价基准:
|
||||
* - whole_request:整单按所在档单价计价(目录阶梯、渠道区间);
|
||||
* - marginal:仅超出阈值的部分按该档单价计价(平台旧规则)。
|
||||
*/
|
||||
export type PlazaLongContextBasis = 'whole_request' | 'marginal'
|
||||
|
||||
/** 分时倍率时段:配置时区当天 [start_time, end_time) 内整单实付乘 multiplier。 */
|
||||
export interface PlazaTimePricingPeriod {
|
||||
start_time: string
|
||||
end_time: string
|
||||
multiplier: number
|
||||
}
|
||||
|
||||
/** 计费会生效的分时倍率(仅倍率 ≠ 1 的时段,已按开始时间升序)。 */
|
||||
export interface PlazaTimePricing {
|
||||
/** IANA 时区名,如 Asia/Shanghai。 */
|
||||
timezone: string
|
||||
/** true 时时段仅周一至周五生效,周末整天按标准价计费。 */
|
||||
weekdays_only?: boolean
|
||||
periods: PlazaTimePricingPeriod[]
|
||||
}
|
||||
|
||||
export interface PlazaModel {
|
||||
name: string
|
||||
platform: string
|
||||
/** 实收口径的展示定价:多档时 intervals 为各档绝对单价(已由计费服务折算);均为标准时段价。 */
|
||||
pricing: UserSupportedModelPricing | null
|
||||
official_pricing: PlazaOfficialPricing | null
|
||||
/** 仅多档模型返回。 */
|
||||
long_context_basis?: PlazaLongContextBasis
|
||||
/** 仅配置了分时倍率的模型返回。 */
|
||||
time_pricing?: PlazaTimePricing
|
||||
}
|
||||
|
||||
export interface ModelPlazaGroup {
|
||||
@@ -43,6 +73,8 @@ export interface ModelPlazaGroup {
|
||||
/** 生图独立倍率:true 时图片计费模型的实付倍率取 image_rate_multiplier,不取分组/专属倍率。 */
|
||||
image_rate_independent: boolean
|
||||
image_rate_multiplier: number
|
||||
/** 分组是否启用长上下文阶梯计费;false 时实付列只展示最低档,官方阶梯仅供参考。 */
|
||||
long_context_pricing_enabled: boolean
|
||||
models: PlazaModel[]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user