A local-first multi-agent app development platform, built on PenguinHarness
feat(core,docs): 模型库加入智谱官方的免费档 GLM-4.7 Flash
lmliheng437ade9a0431
diff --git a/FORK-PROGRESS.md b/FORK-PROGRESS.mdindex a8fdafe8..e084b0db 100644--- a/FORK-PROGRESS.md+++ b/FORK-PROGRESS.md@@ -2289,3 +2289,49 @@ access 那几段)、包名(`@lmliheng/` vs 上游的 `@prismshadow/`)、2. 有第二台 Linux 机器时,把「安装 → 使用 → 跨机建会话 → 插件/模型同步」端到端跑一次。3. Windows 侧要么等上游把「Windows 上的会话」做进 main,要么自己评估成本(比前两项都大)。4. 公司模式跑在别的机器上(`feat/company-remote-machines`)放在最后:它建立在上面这些之上。++## 模型库加入智谱官方的 GLM-4.7 Flash(2026-10-07,用户点单)++用户只给了一页文档(`docs.bigmodel.cn/cn/guide/models/free/glm-4.7-flash`)和一句「模型库添加智谱官方+4.7 flash」。落点就是内置模型库(`MODEL_CATALOG`)里直连 Z.AI(GLM)那一组——它就是这个分组,+`apiKeyUrl` 指的正是智谱开放平台的密钥页。++### 事实(都从两个官方页面读的,2026-10-07)++- id 是 `glm-4.7-flash`;**文本进、文本出**;上下文窗口 **200K**,输出上限 **128K**;支持思考模式、+ 流式输出、Function Calling、上下文缓存、MCP。+- **免费**:Z.AI 的价格页(`docs.z.ai/guides/overview/pricing`)四项(输入、缓存命中、缓存存储、输出)+ 全写 `Free`;智谱开放平台把它列在自己的免费模型页里。+- 它比 GLM-5 系列**更早**,不是更小:Z.AI 的发布记录里 GLM-4.7 是 2025-12-22、GLM-4.7-Flash 是+ 2026-01-19、GLM-5 是 2026-02-12。所以它排在 zhipu 分组的最末,而不是最前。++### 改了什么++- `packages/core/src/state/model-catalog.ts`:zhipu 组末尾加一条 —— `glm-4.7-flash` /+ **GLM-4.7 Flash** / `contextWindow: 200000` / `pricing: usd(0, 0, 0)` / `supportsVision: false` /+ `clientType: "glm-5.3"`;文件头的「数据核对日期」补上 2026-10-07 这一条。+- **为什么必须固定客户端**:AgentHub 0.4.15 只在路由标记(`client_type`,没有就用 id 本身)里含+ `glm-5` 时才把模型交给统一的 GLM 客户端,而 `glm-4.7-flash` 带的是 `glm-4.7`。这不是推断——直接拿+ 仓库里真装的 agenthub 构造 `AutoLLMClient` 试过:不固定 → 抛+ `glm-4.7-flash is not supported. Supported client types: …`;`clientType: "glm-5.3"` → 拿到+ `GLM5_3Client`。**端点则不固定**:Z.AI 与智谱开放平台用同一个 id 服务这个模型,走哪边由+ `ZAI_BASE_URL` 决定(与 `deepseek-flash`、MiniMax M3 那两条「只固定客户端」的写法一致)。+- 测试 `packages/core/test/model-catalog.test.ts`:zhipu 组的 id 顺序钉子里加 `glm-4.7-flash`;$0 条目的+ 白名单加上它(与自建 vLLM、`:free` 同一处理——成本按 0 计、卡片显示免费徽标,而不是「未计价」);+ 「直连分组不固定 client_type」的循环排除这一条,并单独钉住它的 pin、窗口、vision 与三档 0 价;+ 两处「不自动路由的厂商条目只有两个」的注释改成三个。+- 文档 `packages/docs/content/models.{zh,en}.md`:预置模型清单加上它,并新增一条「智谱的免费档」说明。+- 变更日志照 5.7 的习惯写了中英双份 `changelog/unreleased/2026-10-07-glm-4-7-flash{,zh}.md`。++### 验证(都实跑过)++- core **1359 通过 · 5 跳过**、server **182 文件 / 2625 通过 · 4 跳过**、web **236 / 2899 · 2 跳过**+ (含拿真目录跑的 `catalog-sync`)、docs 62、cli 506、ui 1003、ui-gallery 131,**0 失败**。+- `pnpm lint` 0 警告 0 错误(2054 文件)、`pnpm format:check` 干净、`pnpm typecheck` 八包全过。+- 路由那一条是**真跑依赖**得到的结论(上面那次 `AutoLLMClient` 构造),不是照着注释推的。++### 现网与之后++7364 那份跑的是 v0.3.1 的已装构建,**没有**这一条;模型页的 Z.AI 分组不允许手工加条目+(`isAddableGroup` 只认 custom / vLLM / 自定义分组),所以要它出现在界面上得起一次新构建,之后用模型页的+**同步预置**把它带进既有 Project。本轮按纪律没有碰那份安装。diff --git a/changelog/unreleased/2026-10-07-glm-4-7-flash.md b/changelog/unreleased/2026-10-07-glm-4-7-flash.mdnew file mode 100644index 00000000..fa2a481c--- /dev/null+++ b/changelog/unreleased/2026-10-07-glm-4-7-flash.md@@ -0,0 +1,35 @@+# Model catalog: Zhipu's free GLM-4.7 Flash++- **Date:** 2026-10-07+- **Type:** feature+- **Scope:** `model-catalog`, `docs`++[中文版](2026-10-07-glm-4-7-flash.zh.md)++The built-in catalog gains one row in the direct Z.AI (GLM) group: **GLM-4.7 Flash**+(`glm-4.7-flash`), Zhipu's own free tier. Read 2026-10-07 from Z.AI's price list+(docs.z.ai/guides/overview/pricing), which lists it `Free` on all four of its buckets, and from+智谱开放平台's free-model page (docs.bigmodel.cn/cn/guide/models/free/glm-4.7-flash).++## The row++- 200,000-token context window with a 128K output cap, text in and text out, thinking mode,+ streaming, function calling, context caching and MCP — as both platforms document it.+- Priced at a genuine $0, the treatment the self-hosted vLLM rows and the `:free` gateway rows+ already get: the cost center bills its usage at 0 and the model card shows the free badge,+ rather than the "unpriced" mark an absent price means.+- The row pins the GLM client and no endpoint. AgentHub hands a model to its unified GLM client+ only when the routing token — `client_type`, or the id itself — contains `glm-5`, and this id+ carries `glm-4.7`; unrouted, AutoLLMClient rejects it outright. The pin follows the two rows+ that already need one (`deepseek-flash`, MiniMax M3). `ZAI_BASE_URL` still decides which+ platform is billed, since Z.AI and 智谱开放平台 serve the same id.+- It sits below the GLM-5 rows because it is older, not because it is smaller: Z.AI's release+ notes date GLM-4.7-Flash to 2026-01-19 and GLM-5 to 2026-02-12, with GLM-4.7 on 2025-12-22.++## Existing Projects++Presets are copied into a Project when it is created; the models page's **Sync presets** brings+this row into an existing one. A Project that already carries a hand-added `glm-4.7-flash` keeps+its own base URL, key and output cap — a sync touches catalog facts only, and never overwrites+those. The models page's Z.AI group is documented in `packages/docs/content/models.{zh,en}.md`,+which now lists the row and explains the free tier.diff --git a/changelog/unreleased/2026-10-07-glm-4-7-flash.zh.md b/changelog/unreleased/2026-10-07-glm-4-7-flash.zh.mdnew file mode 100644index 00000000..fca06b36--- /dev/null+++ b/changelog/unreleased/2026-10-07-glm-4-7-flash.zh.md@@ -0,0 +1,31 @@+# 模型库新增智谱官方免费档 GLM-4.7 Flash++- **Date:** 2026-10-07+- **Type:** feature+- **Scope:** `model-catalog`, `docs`++[English](2026-10-07-glm-4-7-flash.md)++内置模型库的直连 Z.AI(GLM)分组新增一条:**GLM-4.7 Flash**(`glm-4.7-flash`),智谱自己的免费档。+2026-10-07 读取自 Z.AI 的价格页(docs.z.ai/guides/overview/pricing,四项均标 `Free`)与智谱开放平台的+免费模型页(docs.bigmodel.cn/cn/guide/models/free/glm-4.7-flash)。++## 这条条目++- 上下文窗口 200,000 Token、输出上限 128K,文本进文本出;思考模式、流式输出、Function Calling、+ 上下文缓存与 MCP 都支持——两个平台的文档都是这么写的。+- 价格记作真正的 $0,与自建 vLLM 条目、`:free` 网关条目同一处理:成本中心把它的用量按 0 计费,+ 模型卡片显示免费徽标,而不是价格缺席所代表的「未计价」。+- 这一条固定了 GLM 客户端、不固定端点。AgentHub 只在路由标记(`client_type` 或 id 本身)含+ `glm-5` 时才把模型交给统一的 GLM 客户端,而这个 id 带的是 `glm-4.7`;不固定就会被 AutoLLMClient+ 直接拒收。这个写法与另外两条同样需要的条目一致(`deepseek-flash`、MiniMax M3)。走哪个平台仍由+ `ZAI_BASE_URL` 决定——Z.AI 与智谱开放平台用同一个 id 提供服务。+- 它排在 GLM-5 各行之下是因为更早、不是更小:Z.AI 的发布记录把 GLM-4.7-Flash 记在 2026-01-19,+ GLM-5 记在 2026-02-12,GLM-4.7 记在 2025-12-22。++## 既有 Project++预置条目在创建 Project 时复制进去;模型页的**同步预置**会把这条补进既有 Project。如果某个 Project 已经+自己加过 `glm-4.7-flash`,它的 base URL、密钥与输出上限都保持原样——同步只动目录能作主的那部分事实,+从不覆盖这些。模型页的 Z.AI 分组见 `packages/docs/content/models.{zh,en}.md`,那里已列出该条目并说明了+免费档。diff --git a/packages/core/src/state/model-catalog.ts b/packages/core/src/state/model-catalog.tsindex 69aa4cdb..9cc98002 100644--- a/packages/core/src/state/model-catalog.ts+++ b/packages/core/src/state/model-catalog.ts@@ -21,7 +21,9 @@* groups' line-ups with their peak/off-peak DeepSeek rows: 2026-09-16; the OpenCode Go group:* 2026-09-18 — per each provider's docs; and the ModelScope group, whose preset ids were read* from public model pages and endpoint listings — their windows, vision flags and prices are- * NOT verified and say so on the rows themselves: 2026-09-18 and 2026-09-20).+ * NOT verified and say so on the rows themselves: 2026-09-18 and 2026-09-20; and the direct+ * Z.AI glm-4.7-flash row, the group's free tier, read from Z.AI's price list and+ * 智谱开放平台's free-model page: 2026-10-07).* Docs: packages/docs/content/models.{zh,en}.md (site path /docs/models) documents the* provider groups and credential resolution described here.*@@ -2727,6 +2729,33 @@ export const MODEL_CATALOG: ModelCatalogEntry[] = [pricing: usd(0.2, 1, 3.2),supportsVision: false,},+ {+ // Zhipu's free tier, and the group's only $0 row: Z.AI's price list+ // (docs.z.ai/guides/overview/pricing) reads `Free` on all four of its buckets, and+ // 智谱开放平台 files the model under its own free-model list+ // (docs.bigmodel.cn/cn/guide/models/free/glm-4.7-flash) — both read 2026-10-07. Text in,+ // text out; 200K context with a 128K output cap; thinking mode, streaming, function+ // calling, context caching and MCP.+ //+ // It sits below the 5.x rows because it is older, not because it is smaller: Z.AI's+ // released-notes page dates GLM-4.7-Flash to 2026-01-19 and GLM-5 to 2026-02-12, and the+ // whole GLM-5 line follows it. The same page calls it the free-tier version of GLM-4.7+ // (2025-12-22).+ //+ // The id cannot be auto-routed. AgentHub 0.4.15 hands a model to its unified GLM client+ // only when the routing token — client_type, or the id itself — contains `glm-5`, and+ // this one carries `glm-4.7`; unrouted, AutoLLMClient rejects it outright. So the row+ // pins the client, exactly as the DeepSeek `deepseek-flash` and MiniMax M3 rows pin+ // theirs, and it pins no endpoint: the GLM client's own default is Z.AI's, and a+ // 智谱开放平台 key reaches the same model on the same id through ZAI_BASE_URL.+ modelId: "glm-4.7-flash",+ displayName: "GLM-4.7 Flash",+ provider: "zhipu",+ contextWindow: 200000,+ pricing: usd(0, 0, 0),+ supportsVision: false,+ clientType: "glm-5.3",+ },// -- Moonshot (Kimi) (official CNY pricing) --{modelId: "kimi-k3",diff --git a/packages/core/test/model-catalog.test.ts b/packages/core/test/model-catalog.test.tsindex dac57421..0598b2ff 100644--- a/packages/core/test/model-catalog.test.ts+++ b/packages/core/test/model-catalog.test.ts@@ -389,14 +389,17 @@ describe("model-catalog", () => {m.modelId.endsWith(":free") ||m.modelId === "openrouter/free" ||m.modelId === "Atria-Dawn-Preview" ||- m.modelId === "dots-3-note-preview"+ m.modelId === "dots-3-note-preview" ||+ m.modelId === "glm-4.7-flash") {// Self-hosted vLLM and the free-tier gateway rows share one treatment: a genuine $0// price (not "unknown"), so costs compute to 0 and the free badge shows. Nobody bills// per token for either — a vLLM deployment costs its operator hardware, which no// catalog rate expresses. Atria Dawn Preview has no published price yet and is// recorded at $0 until the vendor prices it; TokenDance's dots-3-note-preview is the- // one free row of its group.+ // one free row of its group, and GLM-4.7-Flash is Zhipu's own free tier — both+ // platforms' price lists read `Free` (or file it under the free models) on every+ // bucket, so the zero is the vendor's, not a placeholder.expect(m.pricing, m.modelId).toBeDefined();expect([m.pricing!.cache_read, m.pricing!.cache_write, m.pricing!.output]).toEqual([0, 0, 0,@@ -1058,12 +1061,29 @@ describe("model-catalog", () => {// These groups' ids are auto-routed by AgentHub, so they carry neither client_type nor a// preset base URL — the opposite of the gateway groups above.for (const id of ["google", "anthropic", "zhipu", "moonshot"]) {- for (const m of MODEL_CATALOG.filter((e) => e.provider === id)) {+ for (const m of MODEL_CATALOG.filter(+ (e) => e.provider === id && e.modelId !== "glm-4.7-flash",+ )) {expect(m.clientType, m.modelId).toBeUndefined();expect(m.baseUrl, m.modelId).toBeUndefined();}}- // The DeepSeek group is the exception, and only for one row: AgentHub 0.4.11 routes+ // Z.AI's free GLM-4.7-Flash is the one pinned row of those four groups, and for the+ // same reason as DeepSeek's below: AgentHub 0.4.15 hands a model to its unified GLM+ // client on the `glm-5` substring alone, which `glm-4.7-flash` does not carry. The pin+ // is the client's name and no endpoint — the id is served by both platforms, so the+ // group's ZAI_BASE_URL decides which one is billed. Free on every bucket, text-only,+ // 200K context with a 128K output cap (Z.AI's price list and 智谱开放平台's free-model+ // page, both read 2026-10-07).+ const glm47f = catalogEntryFor("zhipu", "glm-4.7-flash")!;+ expect([glm47f.clientType, glm47f.baseUrl]).toEqual(["glm-5.3", undefined]);+ expect([glm47f.contextWindow, glm47f.supportsVision]).toEqual([200000, false]);+ expect([+ glm47f.pricing!.cache_read,+ glm47f.pricing!.cache_write,+ glm47f.pricing!.output,+ ]).toEqual([0, 0, 0]);+ // The DeepSeek group is the other exception, and only for one row: AgentHub 0.4.11 routes// DeepSeek on the `deepseek-v4` substring alone, which the released `deepseek-flash`// does not carry, so that row pins the client and inlines the vendor endpoint. Every// other row in the group still auto-routes on its own spelling, and the pin comes off@@ -1081,7 +1101,9 @@ describe("model-catalog", () => {expect(m.baseUrl, m.modelId).toBeUndefined();}// Dictionary order by tier with newer versions of a tier first (same rule the OpenRouter- // block follows for the identical Claude line-up).+ // block follows for the identical Claude line-up). The GLM-4.7 line comes last because+ // it is older than every GLM-5 row, not because it is smaller: Z.AI dates+ // GLM-4.7-Flash to 2026-01-19 and GLM-5 to 2026-02-12.expect(MODEL_CATALOG.filter((m) => m.provider === "google").map((m) => m.modelId)).toEqual(["gemini-3.8-flash","gemini-3.7-flash",@@ -1098,6 +1120,7 @@ describe("model-catalog", () => {"glm-5.2","glm-5.1","glm-5",+ "glm-4.7-flash",]);// Gemini 3.6 / 3.7 / 3.8 Flash: Google halves all three of them through 2026-12-31, and// all six of their rows — direct and on OpenRouter — store Google's list price and@@ -1594,7 +1617,8 @@ describe("resolveModelEnv (PRN-021: env fallback resolved by AgentHub routing ruexpect(unroutableVendorModel("deepseek", "qwen/qwen3.8-flash-next")).toBe(true);expect(unroutableVendorModel("deepseek", "deepseek-v4-pro")).toBe(false);// The same id becomes routable the moment the entry pins the protocol itself, which is- // what the two vendor presets whose own ids do not route rely on.+ // what the three vendor presets whose own ids do not route rely on (deepseek-flash,+ // MiniMax M3 and zhipu's glm-4.7-flash).expect(unroutableVendorModel("deepseek", "deepseek-flash")).toBe(true);expect(unroutableVendorModel("deepseek", "deepseek-flash", "deepseek-v4")).toBe(false);// Every other group decides the protocol without consulting the id.diff --git a/packages/docs/content/models.en.md b/packages/docs/content/models.en.mdindex 1f6cdd60..2ae023b4 100644--- a/packages/docs/content/models.en.md+++ b/packages/docs/content/models.en.md@@ -500,7 +500,7 @@ The preset catalog includes, among others:- `gemini-3.8-flash`- `claude-opus-5` / `claude-opus-4-8` / `claude-sonnet-5`- `gpt-6-astra` / `gpt-5.6` / `gpt-5.5`-- `glm-5.3` / `glm-5.3-flash`+- `glm-5.3` / `glm-5.3-flash` / `glm-4.7-flash` (Z.AI's free tier)- `kimi-k3`- `qwen3.8-max` / `qwen3.8-flash`- `seed-2.1-pro` / `seed-2.1-turbo` / `seed-evolving`@@ -514,6 +514,7 @@ The list is not exhaustive.- **OpenAI twice.** The whole OpenAI line-up is listed twice: directly (your own OpenAI key, list prices) and on OpenRouter as `openai/<id>` (the gateway's rates, which follow its running promotions).- **GLM-5.3 Flash six times.** It appears directly as `glm-5.3-flash`, under the same id on TokenDance and OpenCode Go, and as OpenRouter's `z-ai/glm-5.3-flash`, Fireworks AI's `accounts/fireworks/models/glm-5p3-flash` and Qwen pay-as-you-go's `ZHIPU/GLM-5.3-Flash`. Every row accepts images: AgentHub's GLM client forwards image parts for this one GLM id, every other GLM id refuses them, and the gateway rows go through the generic OpenAI-compatible clients, which carry images for any id. What the rows do not share is the price: each records what its own seller charges, so they disagree while a promotion runs.- **OpenRouter free tier.** The catalog carries the `:free` model variant `nvidia/nemotron-3-ultra-550b-a55b:free` and the `openrouter/free` unified Free Models Router. They cost nothing, but OpenRouter's free-tier rate limits and data policy apply.+- **Zhipu's free tier.** `glm-4.7-flash` is the Z.AI group's one $0 row: Z.AI's price list reads `Free` on all four of its buckets, and 智谱开放平台 files the model under its free-model list. Text in, text out, 200K context with a 128K output cap. Its id carries none of the `glm-5` substring AgentHub routes GLM on, so the row pins the GLM client the way `deepseek-flash` and MiniMax M3 pin theirs; it pins no endpoint, since both platforms serve the same id — `ZAI_BASE_URL` picks which one is billed. It sits below the GLM-5 rows because it is older: Z.AI dates GLM-4.7-Flash to 2026-01-19 and GLM-5 to 2026-02-12.### Prices and promotionsdiff --git a/packages/docs/content/models.zh.md b/packages/docs/content/models.zh.mdindex 8a4173c3..a4ae2af3 100644--- a/packages/docs/content/models.zh.md+++ b/packages/docs/content/models.zh.md@@ -499,7 +499,7 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /- `gemini-3.8-flash`- `claude-opus-5` / `claude-opus-4-8` / `claude-sonnet-5`- `gpt-6-astra` / `gpt-5.6` / `gpt-5.5`-- `glm-5.3` / `glm-5.3-flash`+- `glm-5.3` / `glm-5.3-flash` / `glm-4.7-flash`(智谱官方免费档)- `kimi-k3`- `qwen3.8-max` / `qwen3.8-flash`- `seed-2.1-pro` / `seed-2.1-turbo` / `seed-evolving`@@ -513,6 +513,7 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /- **OpenAI 出现两次。** OpenAI 全系模型出现了两遍:一次直连(用你自己的 OpenAI key,官方牌价),一次在 OpenRouter 上以 `openai/<id>` 形式(网关费率,随其当前促销活动浮动)。- **GLM-5.3 Flash 出现六次。** 分别是直连的 `glm-5.3-flash`、TokenDance 与 OpenCode Go 上的同名条目,以及 OpenRouter 的 `z-ai/glm-5.3-flash`、Fireworks AI 的 `accounts/fireworks/models/glm-5p3-flash` 和 Qwen 按量付费的 `ZHIPU/GLM-5.3-Flash`。每一条都接受图像:AgentHub 的 GLM 客户端只对这一个 GLM id 转发图像内容,其他所有 GLM id 都拒收图像;各网关条目走通用的 OpenAI 兼容客户端,对任何 id 都会携带图像。各条不一致的是价格:每条记录的都是自己卖家收取的价格,所以促销期间彼此不同。- **OpenRouter 免费档。** 目录收录了 `:free` 变体 `nvidia/nemotron-3-ultra-550b-a55b:free`,以及 `openrouter/free` 这个统一的免费模型路由(Free Models Router)。它们不花钱,但 OpenRouter 免费档的限流和数据政策仍然适用。+- **智谱的免费档。** `glm-4.7-flash` 是 Z.AI 分组里唯一的 $0 条目:Z.AI 的价格页四项都写 `Free`,智谱开放平台也把它列在免费模型里。文本输入、文本输出,200K 上下文、128K 输出上限。它的 id 不含 AgentHub 路由 GLM 所需的 `glm-5` 子串,所以这一条像 `deepseek-flash` 与 MiniMax M3 一样固定了 GLM 客户端;端点不固定——两个平台用同一个 id 提供服务,走哪个由 `ZAI_BASE_URL` 决定。它排在 GLM-5 各行之下是因为更早:Z.AI 的发布记录把 GLM-4.7-Flash 记在 2026-01-19,GLM-5 记在 2026-02-12。### 价格与促销