feat(会员): 模型列表返回可用与不可用分桶

- shared-contracts 新增 llm_catalog.rs:LlmModelsResponse/LlmModelSummary/LlmUnavailableModel/LlmModelUnavailableReason(plan_required/disabled/unknown),未停用优先于档位的 disabled 语义留给域层
- AgcAgentMode/AgcModelProtocol 从 module-runtime 迁入 shared-contracts(前后端 + ts-rs 单一真源),module-runtime re-export 保持路径可用
- 整个目录 DTO 与枚举走 ts-rs,生成到 packages/shared/src/contracts/generated,revision 标 number
- module-runtime 新增 AgcModelCatalog::unavailable_models_for(access):保持目录顺序,停用优先于档位不足,补单测
- api-server public_model_catalog 产出 models + unavailableModels 两桶,重写 model_catalog_tests
This commit is contained in:
2026-10-03 18:03:20 +08:00
parent 35a54d19e2
commit e89420053a
12 changed files with 393 additions and 124 deletions
+6
View File
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* 客户端启动的执行器。与线协议正交。
*/
export type AgcAgentMode = "codex" | "cc";
@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* 上游线协议,与执行器正交。
*
* `openai_responses` / `openai_chat` 走 `/api/llm/v1/responses` 与
* `/api/llm/v1/chat/completions`;`anthropic` 走独立的
* `/api/llm/anthropic/{*path}`。
*/
export type AgcModelProtocol = "openai_responses" | "openai_chat" | "anthropic";
@@ -0,0 +1,16 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AgcAgentMode } from "./AgcAgentMode";
import type { AgcModelProtocol } from "./AgcModelProtocol";
/**
* 本档可用的一条模型摘要。不包含上游真实模型名。
*/
export type LlmModelSummary = { displayName: string, id: string,
/**
* 执行器;旧服务端缺字段时按 `codex` 兼容。
*/
agentMode: AgcAgentMode,
/**
* 上游线协议;旧服务端缺字段时按 `openai_responses` 兼容。
*/
protocol: AgcModelProtocol, };
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* 模型对当前账号不可用的原因。
*
* `Unknown` 是前向兜底:后端将来新增取值时旧客户端不会解析失败。
*/
export type LlmModelUnavailableReason = "plan_required" | "disabled" | "unknown";
@@ -0,0 +1,20 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { LlmModelSummary } from "./LlmModelSummary";
import type { LlmUnavailableModel } from "./LlmUnavailableModel";
/**
* `GET /api/llm/models` 的响应。
*/
export type LlmModelsResponse = { defaultModelId: string,
/**
* 本档可用,保持目录顺序。
*/
models: Array<LlmModelSummary>,
/**
* 目录里其余全部,保持目录顺序;旧服务端缺字段时为空。
*/
unavailableModels: Array<LlmUnavailableModel>,
/**
* 模型目录版本;ts-rs 默认把 `u64` 映射成 `bigint`,前端消费 `number`。
*/
revision: number, };
@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AgcAgentMode } from "./AgcAgentMode";
import type { AgcModelProtocol } from "./AgcModelProtocol";
import type { LlmModelUnavailableReason } from "./LlmModelUnavailableReason";
/**
* 目录里存在、但当前账号不可用的一条模型。字段与 [`LlmModelSummary`] 对齐,另带原因。
*/
export type LlmUnavailableModel = { displayName: string, id: string, agentMode: AgcAgentMode, protocol: AgcModelProtocol, reason: LlmModelUnavailableReason, };