Skip to content

Commit 1ae8cf8

Browse files
committed
Reduced advertised models
1 parent e025baa commit 1ae8cf8

14 files changed

Lines changed: 148 additions & 83 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@
6969
# macOS / Linux
7070
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
7171
export ANTHROPIC_AUTH_TOKEN=sk-1234
72-
export ANTHROPIC_MODEL=glm-4.7
72+
export ANTHROPIC_MODEL=glm-5.3
7373
claude
7474
```
7575

7676
```powershell
7777
# Windows PowerShell
7878
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:8080"
7979
$env:ANTHROPIC_AUTH_TOKEN = "sk-1234"
80-
$env:ANTHROPIC_MODEL = "glm-4.7"
80+
$env:ANTHROPIC_MODEL = "glm-5.3"
8181
claude
8282
```
8383

@@ -110,7 +110,7 @@ env_key = "ZCODE_API_KEY" # 任意非空值即可,除非你设置了代理
110110
|--------|-----|
111111
| API 地址 (Base URL) | `http://127.0.0.1:8080/v1` |
112112
| API Key | 你的代理密钥(没设就随便填) |
113-
| 模型 | `glm-4.7`、`glm-5.3`、`glm-4.6v` 等,见下方模型表 |
113+
| 模型 | `glm-5.3`、`glm-5.3-flash`、`glm-4.6v` 等,见下方模型表 |
114114

115115
Anthropic 格式的工具(如某些 Claude 客户端)地址填 `http://127.0.0.1:8080`,路径 `/v1/messages` 代理会自动接。
116116

@@ -231,19 +231,12 @@ ssh -N -L 8090:127.0.0.1:8090 user@host
231231

232232
## 🧮 可用模型
233233

234-
代理会把下面这些模型挂在 `/v1/models` 上(模型列表只是展示,其他模型名也会照常转发):
234+
列表仅供展示:
235235

236236
| 模型 | 上下文 | 最大输出 |
237237
|------|--------|----------|
238-
| `glm-4.5-air` | 131K | 96K |
239-
| `glm-4.6` | 200K | 131K |
240-
| `glm-4.6v`(视觉) | 131K | 32K |
241-
| `glm-4.7` | 200K | 131K |
242-
| `glm-5` / `glm-5-turbo` | 200K | 64K |
243-
| `glm-5v-turbo`(视觉) | 200K | 131K |
244-
| `glm-5.1` | 200K | 64K |
245-
| `glm-5.2` | 1M | 128K |
246-
| `glm-5.3` / `glm-5.3-flash` | 1M | 128K |
238+
| `glm-5.3` | 1M | 128K |
239+
| `glm-5.3-flash`(视觉) | 1M | 128K |
247240

248241
## ❓ 常见问题
249242

‎README_EN.md‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ About the "API Key": if you've set `auth.proxyApiKey` in the config (or the envi
7070
# macOS / Linux
7171
export ANTHROPIC_BASE_URL=http://127.0.0.1:8080
7272
export ANTHROPIC_AUTH_TOKEN=sk-1234
73-
export ANTHROPIC_MODEL=glm-4.7
73+
export ANTHROPIC_MODEL=glm-5.3
7474
claude
7575
```
7676

7777
```powershell
7878
# Windows PowerShell
7979
$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:8080"
8080
$env:ANTHROPIC_AUTH_TOKEN = "sk-1234"
81-
$env:ANTHROPIC_MODEL = "glm-4.7"
81+
$env:ANTHROPIC_MODEL = "glm-5.3"
8282
claude
8383
```
8484

@@ -111,7 +111,7 @@ In your tool's "Custom Provider" section, fill in:
111111
|--------|-----|
112112
| API address (Base URL) | `http://127.0.0.1:8080/v1` |
113113
| API Key | Your proxy key (anything, if unset) |
114-
| Model | `glm-4.7`, `glm-5.3`, `glm-4.6v`, etc. — see the model table below |
114+
| Model | `glm-5.3`, `glm-5.3-flash`, `glm-4.6v`, etc. — see the model table below |
115115

116116
Anthropic-format tools (e.g. some Claude clients) should use `http://127.0.0.1:8080` as the address; the proxy handles the `/v1/messages` path automatically.
117117

@@ -232,19 +232,12 @@ and open `http://127.0.0.1:8090`. With host networking the proxy port is the hos
232232

233233
## 🧮 Available Models
234234

235-
The proxy lists the models below under `/v1/models` (the list is for display only — any other model name is still forwarded as-is):
235+
The table below is for reference only:
236236

237237
| Model | Context | Max Output |
238238
|------|--------|----------|
239-
| `glm-4.5-air` | 131K | 96K |
240-
| `glm-4.6` | 200K | 131K |
241-
| `glm-4.6v` (vision) | 131K | 32K |
242-
| `glm-4.7` | 200K | 131K |
243-
| `glm-5` / `glm-5-turbo` | 200K | 64K |
244-
| `glm-5v-turbo` (vision) | 200K | 131K |
245-
| `glm-5.1` | 200K | 64K |
246-
| `glm-5.2` | 1M | 128K |
247-
| `glm-5.3` / `glm-5.3-flash` | 1M | 128K |
239+
| `glm-5.3` | 1M | 128K |
240+
| `glm-5.3-flash` (vision) | 1M | 128K |
248241

249242
## ❓ FAQ
250243

‎config.example.yaml‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@ providers:
2929
anthropicBase: "https://open.bigmodel.cn/api/anthropic"
3030
openaiBase: "https://open.bigmodel.cn/api/coding/paas/v4"
3131

32-
defaultModel: glm-4.6
32+
# Default model used when a client request omits `model`.
33+
defaultModel: glm-5.3
3334

35+
# Informational model list surfaced in the TUI / startup output; any other
36+
# model id still forwards upstream (no whitelist enforcement).
3437
models:
35-
- glm-4.5-air
36-
- glm-4.6
37-
- glm-4.6v
38-
- glm-4.7
39-
- glm-5
40-
- glm-5-turbo
41-
- glm-5v-turbo
42-
- glm-5.1
43-
- glm-5.2
4438
- glm-5.3
4539
- glm-5.3-flash
4640

‎src/android/AGENTS.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# src/android/ — loopback 控制协议(Kotlin 对端)
2+
3+
> 维护基线:2026-10-20,工作区基于 e025baa(4.8.2)。Kotlin 侧见 Android-APP/AGENTS.md。
4+
5+
## FILES
6+
| 文件 | 角色 |
7+
|---|---|
8+
| control.ts | `dispatch` 10 命令表 + `createControlDispatcher` 状态机 + `startControlListener` node:http 监听 + `LogBuffer` |
9+
| control.test.ts | 协议回归 |
10+
11+
## 契约
12+
- 双消费者:index.ts `android` 模式起监听(`ZCODE_CONTROL_PORT`);server/panel.ts **进程内**复用 `createControlDispatcher`(浏览器对 loopback POST `/api/control`——无第二控制端口)。
13+
- 命令面:start/stop/status/logs(since 游标增量)/quota(双平面快照)/login/logout/provider/plan/update——**无 shutdown**(Kotlin ControlClient 不发;面板 shutdown 走自身命令链,先应答再 50ms grace)。
14+
- 错误语义:HTTP 200 带内 `{ok:false, error}`(Kotlin 端不检非 200 状态码)。
15+
- **监听永不绑非回环**:bind 恒 127.0.0.1 + 每请求 remoteAddress 复查(双保险,根 ANTI-PATTERNS)。
16+
- quota 命令直连 routes-quota 双平面;上游 billing 限频——仅手动/进屏触发,永不定时轮询。
17+
18+
## WHERE TO LOOK
19+
| 任务 | 位置 |
20+
|---|---|
21+
| 加/改命令 | control.ts `dispatch` 表 + Android-APP ControlClient.kt **同步改**(跨仓契约) |
22+
| 面板命令接线 | server/panel.ts(token 门控先于 dispatcher) |
23+
| 日志游标 | control.ts `LogBuffer`(环形 + since cursor) |

‎src/config/loader.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ logging:
120120
expect(cfg.server.port).toBe(8080);
121121
expect(cfg.server.host).toBe("0.0.0.0");
122122
expect(cfg.provider).toBe("zai");
123-
expect(cfg.defaultModel).toBe("glm-4.6");
123+
expect(cfg.defaultModel).toBe("glm-5.3");
124+
expect(cfg.models).toEqual(["glm-5.3", "glm-5.3-flash"]);
124125
expect(cfg.logging.level).toBe("info");
125126
expect(cfg.providers.zai.anthropicBase).toBe("https://api.z.ai/api/anthropic");
126127
expect(cfg.providers.bigmodel.openaiBase).toBe("https://open.bigmodel.cn/api/coding/paas/v4");

‎src/config/loader.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const DEFAULTS = {
3636
HOST: "0.0.0.0",
3737
PROVIDER: "zai" as const,
3838
PLAN: "coding-plan" as const,
39-
DEFAULT_MODEL: "glm-4.6",
39+
DEFAULT_MODEL: "glm-5.3",
40+
MODELS: ["glm-5.3", "glm-5.3-flash"],
4041
LOG_LEVEL: "info" as const,
4142
ZAI_ANTHROPIC_BASE: "https://api.z.ai/api/anthropic",
4243
ZAI_OPENAI_BASE: "https://api.z.ai/api/coding/paas/v4",
@@ -122,7 +123,7 @@ export function loadConfig(path: string): ProxyConfig {
122123

123124
// --- models ---
124125
const defaultModel = typeof parsed?.defaultModel === "string" ? parsed.defaultModel : DEFAULTS.DEFAULT_MODEL;
125-
const models = Array.isArray(parsed?.models) ? parsed.models : [defaultModel];
126+
const models = Array.isArray(parsed?.models) ? parsed.models : [...DEFAULTS.MODELS];
126127

127128
// --- logging ---
128129
const logLevel = resolveLogLevel(parsed?.logging?.level);

‎src/config/template.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,12 @@ providers:
3838
anthropicBase: "https://open.bigmodel.cn/api/anthropic"
3939
openaiBase: "https://open.bigmodel.cn/api/coding/paas/v4"
4040
41-
defaultModel: glm-4.6
41+
# Default model used when a client request omits \`model\`.
42+
defaultModel: glm-5.3
4243
44+
# Informational model list surfaced in the TUI / startup output; any other
45+
# model id still forwards upstream (no whitelist enforcement).
4346
models:
44-
- glm-4.5-air
45-
- glm-4.6
46-
- glm-4.6v
47-
- glm-4.7
48-
- glm-5
49-
- glm-5-turbo
50-
- glm-5v-turbo
51-
- glm-5.1
52-
- glm-5.2
5347
- glm-5.3
5448
- glm-5.3-flash
5549

‎src/provider/AGENTS.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# src/provider/ — 服务商与模型目录
2+
3+
> 维护基线:2026-10-20,工作区基于 e025baa(4.8.2);含未提交的广告面/默认值改动。溯源证据见 `_reverse/NOTEPAD.md`。
4+
5+
## FILES
6+
| 文件 | 角色 |
7+
|---|---|
8+
| models.ts | 钉死目录 `MODELS`(11 型,spec 对齐 3.11.2 逆向 catalog)+ 广告子集 `ADVERTISED_MODELS` |
9+
| providers.ts | zai/bigmodel 端点定义(anthropic/openai base、bizHost) |
10+
| reasoning.ts | GLM-5.3 effort 契约:eligibility、budget 配对与钳制 |
11+
| types.ts | `ProviderId` / `ProviderDef` / `ModelDef` |
12+
13+
## 契约(改错即全线回归)
14+
- **MODELS ≠ 广告面**:`MODELS` 供 translator 钳制 maxOutputTokens / reasoning 判定(未广告模型仍照常转发、仍需 spec);`/v1/models`(含 `client_version=pi` 富目录)与 webui 只出 `ADVERTISED_MODELS`(2026-10-20 起 = glm-5.3 + glm-5.3-flash)。裁 MODELS 前先看 translator/openai-to-anthropic.ts 的 find/some 消费。
15+
- **vision 是显式字段**(`ModelDef.vision`),不是 id 含 "v" 启发式——glm-5.3-flash 无 v 但多模态;routes-openai 的 `input_modalities` 与 webui `isVisionModel(/v|flash/)` 都依赖该标志,改一处要三处对齐。
16+
- effort 必须配对 budget_tokens;`"none"`→`"low"`(不可关);预算按模型 maxOutputTokens 钳制。
17+
- 目录序:当前代默认对领先,其余新→旧——纯呈现层排序,消费方全按 id 查找,序不参与行为。
18+
- **换广告对/默认模型需四处同步**:`ADVERTISED_MODEL_IDS`(models.ts)、webui `KNOWN_MODELS`、config `DEFAULTS.DEFAULT_MODEL`+`DEFAULTS.MODELS`(loader.ts)、config.example.yaml + template.ts(双编辑契约)。
19+
20+
## WHERE TO LOOK
21+
| 任务 | 位置 |
22+
|---|---|
23+
| 新模型上架 | models.ts(spec 钉逆向 catalog)+ providers.test.ts 顺序断言 |
24+
| 换广告面 | models.ts `ADVERTISED_MODEL_IDS` + server/webui.txt `KNOWN_MODELS` |
25+
| 默认模型 | config/loader.ts `DEFAULTS`(DEFAULT_MODEL / MODELS) |
26+
| effort/thinking 预算 | reasoning.ts + translator/openai-to-anthropic.ts(applyAnthropicThinkingCompat) |
27+
28+
## ANTI-PATTERNS
29+
- 永不为"精简"裁 MODELS 全目录(translator 依赖未广告模型的 spec)。
30+
- 永不复活 id-含-"v" 视觉启发式(flash 反例已实锤)。
31+
- spec 数值(contextWindow/maxOutputTokens)钉自逆向 catalog,勿凭印象填。

‎src/provider/models.ts‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,31 @@ import type { ModelDef } from "./types.js";
1313
export const MODELS: ModelDef[] = [
1414
// Specs synced to ZCode 3.11.2 `_reverse/models_catalog.json` (zai/bigmodel
1515
// entries are identical): contextWindow + maxOutputTokens per model.
16-
{ id: "glm-4.5-air", name: "GLM 4.5 Air", contextWindow: 131_072, maxOutputTokens: 98_304, reasoning: true },
17-
{ id: "glm-4.6", name: "GLM 4.6", contextWindow: 200_000, maxOutputTokens: 131_072, reasoning: true },
18-
{ id: "glm-4.6v", name: "GLM 4.6V", contextWindow: 131_072, maxOutputTokens: 32_768 },
19-
{ id: "glm-4.7", name: "GLM 4.7", contextWindow: 200_000, maxOutputTokens: 131_072, reasoning: true },
20-
{ id: "glm-5", name: "GLM 5", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
21-
{ id: "glm-5-turbo", name: "GLM 5 Turbo", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
22-
{ id: "glm-5v-turbo", name: "GLM 5V Turbo", contextWindow: 200_000, maxOutputTokens: 131_072 },
23-
{ id: "glm-5.1", name: "GLM 5.1", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
24-
// glm-5.2 is absent from the 3.11.2 catalog (kept for forwarding compatibility).
25-
{ id: "glm-5.2", name: "GLM 5.2", contextWindow: 1_000_000, maxOutputTokens: 128_000, reasoning: true },
16+
// Order is a deliberate deviation from the upstream catalog: current-gen
17+
// defaults lead the advertised list; consumers are id-keyed, not positional.
2618
{ id: "glm-5.3", name: "GLM 5.3", contextWindow: 1_000_000, maxOutputTokens: 128_000, reasoning: true },
2719
// start-plan gateway serves the -flash variant (used by claimed trial plans
2820
// like the weekend package); advertised so client-side discovery lists it.
29-
{ id: "glm-5.3-flash", name: "GLM 5.3 Flash", contextWindow: 1_000_000, maxOutputTokens: 128_000, reasoning: true },
21+
// Multimodal (text + image input).
22+
{ id: "glm-5.3-flash", name: "GLM 5.3 Flash", contextWindow: 1_000_000, maxOutputTokens: 128_000, reasoning: true, vision: true },
23+
// glm-5.2 is absent from the 3.11.2 catalog (kept for forwarding compatibility).
24+
{ id: "glm-5.2", name: "GLM 5.2", contextWindow: 1_000_000, maxOutputTokens: 128_000, reasoning: true },
25+
{ id: "glm-5.1", name: "GLM 5.1", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
26+
{ id: "glm-5", name: "GLM 5", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
27+
{ id: "glm-5-turbo", name: "GLM 5 Turbo", contextWindow: 200_000, maxOutputTokens: 64_000, reasoning: true },
28+
{ id: "glm-5v-turbo", name: "GLM 5V Turbo", contextWindow: 200_000, maxOutputTokens: 131_072, vision: true },
29+
{ id: "glm-4.7", name: "GLM 4.7", contextWindow: 200_000, maxOutputTokens: 131_072, reasoning: true },
30+
{ id: "glm-4.6", name: "GLM 4.6", contextWindow: 200_000, maxOutputTokens: 131_072, reasoning: true },
31+
{ id: "glm-4.6v", name: "GLM 4.6V", contextWindow: 131_072, maxOutputTokens: 32_768, vision: true },
32+
{ id: "glm-4.5-air", name: "GLM 4.5 Air", contextWindow: 131_072, maxOutputTokens: 98_304, reasoning: true },
3033
];
34+
35+
/**
36+
* Models advertised via `/v1/models` and the webui picker — a deliberate
37+
* subset of MODELS. Do not trim MODELS itself to match: the translator still
38+
* needs the full catalog for maxOutputTokens clamps and reasoning detection
39+
* on unadvertised (but forwardable) models.
40+
*/
41+
export const ADVERTISED_MODEL_IDS: readonly string[] = ["glm-5.3", "glm-5.3-flash"];
42+
43+
export const ADVERTISED_MODELS: ModelDef[] = MODELS.filter((m) => ADVERTISED_MODEL_IDS.includes(m.id));

‎src/provider/providers.test.ts‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { describe, it, expect } from "bun:test";
55
import { getProvider, ZAI_PROVIDER, BIGMODEL_PROVIDER } from "./providers.js";
6-
import { MODELS } from "./models.js";
6+
import { MODELS, ADVERTISED_MODELS } from "./models.js";
77

88
describe("providers", () => {
99
it("getProvider returns Z.AI definition", () => {
@@ -39,10 +39,11 @@ describe("models", () => {
3939
it("MODELS contains exactly the 11 pinned coding-plan models", () => {
4040
expect(MODELS).toHaveLength(11);
4141
const ids = MODELS.map((m) => m.id);
42+
// Current-gen defaults lead the advertised list; the rest newest→oldest.
4243
expect(ids).toEqual([
43-
"glm-4.5-air", "glm-4.6", "glm-4.6v", "glm-4.7",
44-
"glm-5", "glm-5-turbo", "glm-5v-turbo", "glm-5.1", "glm-5.2", "glm-5.3",
45-
"glm-5.3-flash",
44+
"glm-5.3", "glm-5.3-flash", "glm-5.2", "glm-5.1", "glm-5",
45+
"glm-5-turbo", "glm-5v-turbo", "glm-4.7", "glm-4.6", "glm-4.6v",
46+
"glm-4.5-air",
4647
]);
4748
});
4849

@@ -81,11 +82,28 @@ describe("models", () => {
8182
expect(glm53f!.contextWindow).toBe(1_000_000);
8283
});
8384

85+
it("vision flag: flash + v-suffixed models, glm-5.3 text-only", () => {
86+
const v = (id: string) => MODELS.find((m) => m.id === id)?.vision;
87+
expect(v("glm-5.3-flash")).toBe(true);
88+
expect(v("glm-5v-turbo")).toBe(true);
89+
expect(v("glm-4.6v")).toBe(true);
90+
expect(v("glm-5.3")).toBeUndefined();
91+
expect(v("glm-5.2")).toBeUndefined();
92+
});
93+
8494
it("includes key GLM models", () => {
8595
const ids = MODELS.map((m) => m.id);
8696
expect(ids).toContain("glm-4.6");
8797
expect(ids).toContain("glm-5.2");
8898
expect(ids).toContain("glm-5.3");
8999
expect(ids).toContain("glm-5v-turbo");
90100
});
101+
102+
it("advertises exactly the glm-5.3 pair via ADVERTISED_MODELS", () => {
103+
expect(ADVERTISED_MODELS.map((m) => m.id)).toEqual(["glm-5.3", "glm-5.3-flash"]);
104+
// Every advertised entry is backed by a full catalog entry (spec parity).
105+
for (const m of ADVERTISED_MODELS) {
106+
expect(MODELS.find((e) => e.id === m.id)).toBe(m);
107+
}
108+
});
91109
});

0 commit comments

Comments
 (0)