Skip to content

Commit f4bf882

Browse files
committed
review 了一些东西
1 parent 2649e4a commit f4bf882

46 files changed

Lines changed: 516 additions & 219 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Android-APP/app/src/main/java/com/zcode/proxy/MainActivity.kt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private fun AppScreen(themeMode: ThemeMode, onThemeModeChange: (ThemeMode) -> Un
142142

143143
var reachable by remember { mutableStateOf(false) }
144144
var loggedIn by remember { mutableStateOf(false) }
145-
var provider by remember { mutableStateOf("bigmodel") }
145+
var provider by remember { mutableStateOf("zai") }
146146
var plan by remember { mutableStateOf("coding-plan") }
147147
var proxyPort by remember { mutableStateOf(0) }
148148
var proxyRunning by remember { mutableStateOf(false) }
@@ -718,7 +718,7 @@ private fun AccountCard(
718718
Spacer(Modifier.width(12.dp))
719719
Column(Modifier.weight(1f)) {
720720
Text(
721-
if (provider == "zai") "Z.AI 账号" else "智谱账号",
721+
if (provider == "zai") "Z.AI 账号" else "Z.AI 中国版账号",
722722
fontSize = 16.sp,
723723
fontWeight = FontWeight.SemiBold,
724724
color = cs.onSurface,
@@ -808,7 +808,7 @@ private fun AccessConfigCard(
808808
Text("服务商", fontSize = 13.sp, color = cs.onSurfaceVariant, modifier = Modifier.width(52.dp))
809809
SegChip("Z.AI", provider == "zai", enabled, modifier = Modifier.weight(1f), fill = true) { onProviderChange("zai") }
810810
Spacer(Modifier.width(8.dp))
811-
SegChip("智谱", provider == "bigmodel", enabled, modifier = Modifier.weight(1f), fill = true) { onProviderChange("bigmodel") }
811+
SegChip("中国版", provider == "zai_cn", enabled, modifier = Modifier.weight(1f), fill = true) { onProviderChange("zai_cn") }
812812
}
813813
Spacer(Modifier.height(14.dp))
814814
Row(verticalAlignment = Alignment.CenterVertically) {
@@ -1007,7 +1007,7 @@ private fun SettingsScreen(
10071007
}
10081008
Spacer(Modifier.height(12.dp))
10091009
CardBlock(title = "接入信息") {
1010-
SettingRow("服务商", if (provider == "zai") "Z.AI" else "智谱")
1010+
SettingRow("服务商", if (provider == "zai") "Z.AI" else "Z.AI 中国版")
10111011
SettingRow("套餐", plan)
10121012
SettingRow(
10131013
"状态",

‎Android-APP/app/src/main/java/com/zcode/proxy/NodeRunner.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class NodeRunner(private val context: Context) {
198198
port: 8080
199199
auth:
200200
mode: oauth
201-
provider: bigmodel
201+
provider: zai_cn
202202
plan: coding-plan
203203
""".trimIndent()
204204
}

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
- 📱 **安卓 App** —— 手机上启动/停止代理、看实时日志、切换服务商,出门在外也好用。
2626
- 💬 **自带网页聊天** —— 打开 `/webui` 就是一个本地 ChatGPT 风格聊天页,随手测试模型。
2727
- 🌙 **闲时通道 & 套餐秒抢**(可选)—— 错峰时段的免费额度通道、限量体验套餐自动领取,都是内置功能。
28-
- 🔌 **套餐内 MCP 聚合端点** —— ZCode 官方插件 MCP(天眼查 / Wind / 同花顺 iFinD…,134+ 工具)聚合到**单一** `/mcp` 端点(streamable HTTP,工具名 `{plugin}__{tool}` 命名空间化——客户端只配一个 MCP server 即可,需 coding-plan 登录,浏览器 `GET /mcp` 查看目录);自带网页聊天还能外挂你自己的 MCP 服务器给模型当工具用。
29-
- 🎨 **套餐内 Seed 系媒体接口** —— 生图(Seedream)、生视频(SeedDance 任务式)、语音识别 / 语音合成(Seed-ASR / Seed-Audio)以火山方舟同形状的 `/api/v3/*` REST 端点暴露在本机(默认开启,翻译到官方 ToolHub / video_edit 网关;需 coding-plan 登录,消耗套餐内额度,端点与体限详见 [`config.example.yaml`](config.example.yaml));另有 HappyHorse AI 视频与 3D 模型生成(hyper3d / meshy / hi3d)的任务式端点在同一前缀下(同走官方 ToolHub 网关,需 coding-plan 登录)。
28+
- 🔌 **套餐内 MCP 聚合端点** —— ZCode 官方插件 MCP(天眼查 / Wind / 同花顺 iFinD…,136 个工具)聚合到**单一** `/mcp` 端点(streamable HTTP,工具名 `{plugin}__{tool}` 命名空间化——客户端只配一个 MCP server 即可,需 coding-plan 登录,浏览器 `GET /mcp` 查看目录);自带网页聊天还能外挂你自己的 MCP 服务器给模型当工具用。
29+
- 🎨 **套餐内媒体生成(MCP 工具)** —— 生图(Seedream)、生视频(SeedDance)、HappyHorse AI 视频、3D 模型生成(Hyper3D / Meshy / Hi3D)共 13 个工具直接挂在 **`/mcp` 聚合端点**上(与官方插件同名同参,客户端配一个 MCP server 即得全部能力;需 coding-plan 登录,走官方 ToolHub 网关计费——实测**不占套餐 LLM 额度**,按 ToolHub/MaaS 计费);语音识别 / 语音合成(Seed-ASR / Seed-Audio)仍以 `/api/v3/*` REST 端点暴露(体限详见 [`config.example.yaml`](config.example.yaml))。
3030
- 🪟 **全平台** —— Windows / macOS / Linux 一份代码直接跑,也能编译成单文件程序或 Docker 部署。
3131

3232
## 🚀 一分钟上手

‎README_EN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Codex, Silly Tavern … can all use your plan quota directly.
2626
- 📱 **Android app** — start/stop the proxy, watch live logs and switch providers on your phone, handy when you're away.
2727
- 💬 **Web chat included** — open `/webui` for a local ChatGPT-style chat page to try out models.
2828
- 🌙 **Off-peak channel & plan grabber** (optional) — a free-quota channel for off-peak hours and automatic claiming of limited trial plans are both built in.
29-
- 🔌 **In-plan MCP aggregate endpoint** — official ZCode plugin MCPs (Tianyancha / Wind / iFinD…, 134+ tools) are merged behind a **single** `/mcp` endpoint (streamable HTTP, tools namespaced `{plugin}__{tool}` — clients configure just one MCP server; requires a coding-plan login, `GET /mcp` in a browser shows the catalogue); the built-in web chat can also attach your own MCP servers as tools for the model.
30-
- 🎨 **In-plan Seed media endpoints** — image generation (Seedream), video generation (SeedDance task-based), speech recognition / synthesis (Seed-ASR / Seed-Audio) are exposed as Volcano Ark-shaped `/api/v3/*` REST endpoints on the local proxy (on by default; translated to the official ToolHub / video_edit gateways — requires a coding-plan login and spends plan entitlements; endpoints and body limits are documented in [`config.example.yaml`](config.example.yaml)). Task-based generation faces for HappyHorse AI video and 3D models (hyper3d / meshy / hi3d) sit on the same prefix (official ToolHub gateway, coding-plan login required).
29+
- 🔌 **In-plan MCP aggregate endpoint** — official ZCode plugin MCPs (Tianyancha / Wind / iFinD…, 136 tools) are merged behind a **single** `/mcp` endpoint (streamable HTTP, tools namespaced `{plugin}__{tool}` — clients configure just one MCP server; requires a coding-plan login, `GET /mcp` in a browser shows the catalogue); the built-in web chat can also attach your own MCP servers as tools for the model.
30+
- 🎨 **In-plan media generation as MCP tools** — 13 tools covering image generation (Seedream), video generation (SeedDance), HappyHorse AI video, and 3D models (Hyper3D / Meshy / Hi3D) live directly on the **`/mcp` aggregate endpoint** (same names and schemas as the official plugins — one MCP server config gets you everything; requires a coding-plan login, billed through the official ToolHub gateway — verified to NOT spend the LLM plan quota, billed via ToolHub/MaaS instead). Speech recognition / synthesis (Seed-ASR / Seed-Audio) remain `/api/v3/*` REST endpoints (body limits in [`config.example.yaml`](config.example.yaml)).
3131
- 🪟 **Cross-platform** — Windows / macOS / Linux run from one codebase; can also be compiled into a single-file executable or deployed with Docker.
3232

3333
## 🚀 Quick Start

‎config.example.yaml‎

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# ── Section index ─────────────────────────────────────────────────────────
2+
# server · auth · provider/plan · providers · models · identity ·
3+
# clientIdentity · responses · mcp (plugin tools + media generation) ·
4+
# media (speech REST) · async · claim · endpointRouting · clientSigning ·
5+
# highspeed · logging
6+
#
7+
# Every key is optional — the loader applies built-in defaults for anything
8+
# omitted; env vars override YAML values (see each section).
9+
110
server:
211
port: 8080
312
host: "0.0.0.0"
@@ -13,7 +22,7 @@ auth:
1322
# ~/.zcode-proxy/credentials.json:
1423
# oauthCredentialsPath: "~/.zcode-proxy/credentials.json"
1524

16-
# Which upstream provider to use: "zai" or "bigmodel"
25+
# Which upstream provider family to use: "zai" or "zai_cn".
1726
provider: zai
1827

1928
# Which plan tier to use:
@@ -33,7 +42,9 @@ providers:
3342
zai:
3443
anthropicBase: "https://api.z.ai/api/anthropic"
3544
openaiBase: "https://api.z.ai/api/coding/paas/v4"
36-
bigmodel:
45+
# zai_cn rides the BigModel (open.bigmodel.cn) chain — a zai_cn login
46+
# surfaces the user's BigModel subscription.
47+
zai_cn:
3748
anthropicBase: "https://open.bigmodel.cn/api/anthropic"
3849
openaiBase: "https://open.bigmodel.cn/api/coding/paas/v4"
3950

@@ -111,32 +122,19 @@ mcp:
111122
# chatglm.site variant is the TEST env origin.
112123
upstreamOrigin: https://zcode.z.ai
113124

114-
# Media faces — Volcano-shaped REST endpoints (Seed family) plus ToolHub task
115-
# faces (HappyHorse / 3D), translated to the ToolHub / official video_edit MCP
116-
# upstreams (same identity headers as /mcp, coding-plan only — start-plan
117-
# gets 400 `plan_unsupported`):
118-
# POST /api/v3/images/generations (Seedream-shaped image gen)
119-
# POST /api/v3/contents/generations/tasks (SeedDance-shaped video tasks)
120-
# GET /api/v3/contents/generations/tasks/{id} (task polling; DELETE → 501)
125+
# Media faces — the GENERATION capabilities (Seedream image gen / SeedDance
126+
# video / HappyHorse AI video / 3D: hyper3d | meshy | hi3d) are MCP tools on
127+
# the /mcp endpoint (2026-11-22: the former /api/v3/* REST faces were removed;
128+
# configure /mcp in any MCP client and call them as {plugin}__{tool} — same
129+
# ToolHub upstream, coding-plan only). The SPEECH pair below stays REST:
121130
# POST /api/v3/auc/bigmodel/recognize/flash (Seed-ASR, sync blocking only;
122131
# submit/query → 501)
123132
# POST /api/v3/tts/create (Seed-Audio-shaped TTS)
124-
# Images: data: references must fit the 14 MiB request-body cap (a 10 MiB
125-
# image base64-encodes to ≈13.3 MiB); videos: data: audio ≤2 MiB inline; ASR
126-
# request body ≤45 MiB (the upstream nginx cap — chunk oversized audio
127-
# client-side, one flash request per piece); TTS body ≤1 MiB. Every
128-
# Seed-family call spends paid plan entitlements, so auth.proxyApiKey is
129-
# strongly recommended.
130-
# ToolHub task faces (same plane and coding-plan gate, task-shaped):
131-
# POST /api/v3/happyhorse/videos (+ GET .../{task_id})
132-
# (HappyHorse AI video; material images
133-
# are https-ONLY — data: is rejected; body
134-
# ≤4 MiB)
135-
# POST /api/v3/models3d/{vendor}/tasks (+ GET .../{task_id})
136-
# (3D generation: hyper3d | meshy | hi3d;
137-
# data: images allowed; body ≤108 MiB —
138-
# worst legal combo is meshy 4 × 20 MiB
139-
# decoded images ≈106.7 MiB after base64)
133+
# ASR request body ≤45 MiB (the upstream nginx cap — chunk oversized audio
134+
# client-side, one flash request per piece); TTS body ≤1 MiB. Every media
135+
# call spends paid plan entitlements (billed to ToolHub/MaaS, NOT the LLM
136+
# plan quota — verified 2026-11-20), so auth.proxyApiKey is strongly
137+
# recommended.
140138
# Env overrides: ZCODE_MEDIA_GATEWAY, ZCODE_MEDIA_GATEWAY_ORIGIN.
141139
media:
142140
enabled: true
@@ -176,16 +174,16 @@ async:
176174
# by planId, preview wins) — and auto-claims the highest-priority one
177175
# ({origin}/api/v1/zcode-plan/billing/claim) using the OAuth JWT plus an
178176
# Aliyun captcha token when the campaign config requires one (same solver as
179-
# start-plan). Weekend
180-
# campaigns are quota-limited first-come-first-served; claimed plans activate
181-
# at the campaign's `starts_at` and land as Start-Plan quota.
177+
# start-plan). Weekend campaigns are quota-limited first-come-first-served;
178+
# claimed plans activate at the campaign's `starts_at` and land as
179+
# Start-Plan quota.
182180
#
183181
# IMPORTANT: requires a logged-in credential (claim uses the JWT from
184182
# `auth login`), and identity.appVersion must be >= the campaign's minimum
185183
# client version or the server rejects with `ineligible` — an app_version
186184
# below the floor can also surface as a silently empty preview list
187185
# (measured floor 3.14.0 for the 2026-09 campaign; the built-in appVersion
188-
# "3.19.1" satisfies it).
186+
# tracks the mirrored desktop release and satisfies recent floors).
189187
#
190188
# Env overrides: ZCODE_CLAIM_ENABLED, ZCODE_CLAIM_AUTO, ZCODE_CLAIM_ORIGIN,
191189
# ZCODE_CLAIM_POLL_INTERVAL_MS.
@@ -237,14 +235,17 @@ clientSigning:
237235
# dedicated inference endpoint ({origin}/api/v1/highspeed/anthropic/v1/messages
238236
# — pinned by the official zcode-builtin provider rules, NOT the coding-plan
239237
# URL) and stay unsigned, exactly like the official client. The loop
240-
# self-extinguishes 5 minutes after
241-
# the last eligible request; account unavailability (503/3404) is
242-
# negative-cached 10min, HTTP 429 backs off 5s. task_id reuses the local
243-
# client-session affinity inference. Env override: ZCODE_HIGHSPEED_ENABLED=false.
238+
# self-extinguishes 5 minutes after the last eligible request; account
239+
# unavailability (503/3404) is negative-cached 10min, HTTP 429 backs off 5s.
240+
# Env override: ZCODE_HIGHSPEED_ENABLED=false.
244241
highspeed:
245242
enabled: true
246243
origin: "https://zcode.z.ai"
247244
models: ["glm-5.3", "glm-5.2", "glm-5.1"]
248245

246+
# Update check (env-only, no YAML keys): ZCODE_UPDATE_CHECK=off disables the
247+
# automatic startup check; ZCODE_UPDATE_SKIP=v4.7.6,v4.7.7 mutes specific
248+
# tags. The check never blocks the process and never throws.
249+
249250
logging:
250251
level: info

‎src/android/control.test.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function post(body: unknown, state: ControlState, ctx?: HandlerContext) {
3333

3434
describe("android control listener", () => {
3535
const baseState: ControlState = {
36-
provider: "bigmodel",
36+
provider: "zai_cn",
3737
plan: "coding-plan",
3838
proxyPort: 8080,
3939
};
@@ -48,7 +48,7 @@ describe("android control listener", () => {
4848
expect(result.body.ok).toBe(true);
4949
if (result.body.ok && "state" in result.body) {
5050
expect(result.body.state).toBe("running");
51-
expect(result.body.provider).toBe("bigmodel");
51+
expect(result.body.provider).toBe("zai_cn");
5252
expect(result.body.plan).toBe("coding-plan");
5353
expect(result.body.proxyPort).toBe(8080);
5454
}
@@ -113,7 +113,7 @@ describe("android control listener", () => {
113113

114114
it("deliverOAuthCode is retired (bigmodel auth-code flow deprecated) — unknown_cmd", async () => {
115115
const req = makeStubRequest({
116-
body: JSON.stringify({ cmd: "deliverOAuthCode", provider: "bigmodel", code: "x", state: "y" }),
116+
body: JSON.stringify({ cmd: "deliverOAuthCode", provider: "zai_cn", code: "x", state: "y" }),
117117
});
118118
const result = await handleControlRequestForTest(req, baseState);
119119
expect(result.status).toBe(200);
@@ -126,7 +126,7 @@ describe("android control listener", () => {
126126

127127
describe("android control listener — lifecycle commands", () => {
128128
const state: ControlState = {
129-
provider: "bigmodel",
129+
provider: "zai_cn",
130130
plan: "coding-plan",
131131
proxyPort: 0,
132132
};
@@ -178,7 +178,7 @@ describe("android control listener — lifecycle commands", () => {
178178

179179
describe("android control listener — setConfig", () => {
180180
it("updates provider and plan via hook and syncs state", async () => {
181-
const state: ControlState = { provider: "bigmodel", plan: "coding-plan", proxyPort: 0 };
181+
const state: ControlState = { provider: "zai_cn", plan: "coding-plan", proxyPort: 0 };
182182
const ctx: HandlerContext = {
183183
logBuffer: new LogBuffer(),
184184
onSetConfig: async (changes) => ({
@@ -199,14 +199,14 @@ describe("android control listener — setConfig", () => {
199199

200200
it("returns config_update_unavailable when hook missing", async () => {
201201
const state: ControlState = { provider: "zai", plan: "coding-plan", proxyPort: 0 };
202-
const result = await post({ cmd: "setConfig", provider: "bigmodel" }, state);
202+
const result = await post({ cmd: "setConfig", provider: "zai_cn" }, state);
203203
expect(result.body.ok).toBe(false);
204204
if (!result.body.ok) {
205205
expect(result.body.error).toBe("config_update_unavailable");
206206
}
207207
});
208208

209-
it("rejects provider zai_cn — a login flavor, never a config provider (official folding)", async () => {
209+
it("rejects the retired bigmodel config label (2026-11-22 surface is zai|zai_cn)", async () => {
210210
const state: ControlState = { provider: "zai", plan: "coding-plan", proxyPort: 0 };
211211
const applied: Array<{ provider?: string }> = [];
212212
const ctx: HandlerContext = {
@@ -216,7 +216,7 @@ describe("android control listener — setConfig", () => {
216216
return { ok: true, provider: changes.provider ?? state.provider, plan: changes.plan ?? state.plan };
217217
},
218218
};
219-
const result = await post({ cmd: "setConfig", provider: "zai_cn" }, state, ctx);
219+
const result = await post({ cmd: "setConfig", provider: "bigmodel" }, state, ctx);
220220
expect(result.body.ok).toBe(false);
221221
if (!result.body.ok) {
222222
expect(result.body.error).toBe("invalid_provider");
@@ -233,7 +233,7 @@ describe("android control listener — getLogs", () => {
233233
logBuffer.push("[INFO] line one");
234234
logBuffer.push("[INFO] line two");
235235
const ctx: HandlerContext = { logBuffer };
236-
const result = await post({ cmd: "getLogs" }, { provider: "bigmodel", plan: "coding-plan", proxyPort: 0 }, ctx);
236+
const result = await post({ cmd: "getLogs" }, { provider: "zai_cn", plan: "coding-plan", proxyPort: 0 }, ctx);
237237
expect(result.body.ok).toBe(true);
238238
if (result.body.ok && "lines" in result.body) {
239239
expect(result.body.lines).toEqual(["[INFO] line one", "[INFO] line two"]);
@@ -247,7 +247,7 @@ describe("android control listener — getLogs", () => {
247247
logBuffer.push("b");
248248
logBuffer.push("c");
249249
const ctx: HandlerContext = { logBuffer };
250-
const result = await post({ cmd: "getLogs", since: 1 }, { provider: "bigmodel", plan: "coding-plan", proxyPort: 0 }, ctx);
250+
const result = await post({ cmd: "getLogs", since: 1 }, { provider: "zai_cn", plan: "coding-plan", proxyPort: 0 }, ctx);
251251
expect(result.body.ok).toBe(true);
252252
if (result.body.ok && "lines" in result.body) {
253253
expect(result.body.lines).toEqual(["b", "c"]);
@@ -258,7 +258,7 @@ describe("android control listener — getLogs", () => {
258258
const logBuffer = new LogBuffer();
259259
logBuffer.push("only");
260260
const ctx: HandlerContext = { logBuffer };
261-
const result = await post({ cmd: "getLogs", since: 1 }, { provider: "bigmodel", plan: "coding-plan", proxyPort: 0 }, ctx);
261+
const result = await post({ cmd: "getLogs", since: 1 }, { provider: "zai_cn", plan: "coding-plan", proxyPort: 0 }, ctx);
262262
expect(result.body.ok).toBe(true);
263263
if (result.body.ok && "lines" in result.body) {
264264
expect(result.body.lines).toEqual([]);
@@ -267,9 +267,9 @@ describe("android control listener — getLogs", () => {
267267
});
268268

269269
describe("android control listener — quota", () => {
270-
const state: ControlState = { provider: "bigmodel", plan: "coding-plan", proxyPort: 0 };
270+
const state: ControlState = { provider: "zai_cn", plan: "coding-plan", proxyPort: 0 };
271271
const snapshot = {
272-
provider: "bigmodel",
272+
provider: "zai_cn",
273273
serverTime: 1759195200,
274274
jwt: null,
275275
balances: [],

0 commit comments

Comments
 (0)