A local-first multi-agent app development platform, built on PenguinHarness
fix(web,server,cli,core): a vendor group carries built-in models only (#843)
Yaowei Zhengb9f395a26b6f
diff --git a/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.md b/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.mdnew file mode 100644index 00000000..328333a6--- /dev/null+++ b/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.md@@ -0,0 +1,66 @@+# Backward compatibility++- **Date:** 2026-09-21+- **Type:** process+- **Scope:** `server`, `cli`, `web`, `core`+- **PR:** [#843](https://github.com/Prism-Shadow/penguin-harness/pull/843)+- **Breaking:** yes — a models PUT, or `penguin config model add`, that writes a model id a first-party vendor group cannot route is refused (`400 model_not_routable` / exit code 1); entries already stored keep working and are never rewritten++[中文版](2026-09-21-backward-compatibility-vendor-groups.zh.md)++[A first-party vendor group carries built-in models+only](2026-09-21-vendor-group-presets-only.md) closes a configuration that could be written but+never started. One thing outlives the release: the entries already written that way.++## The old shape: a vendor-group entry with no protocol and an id nothing routes++A `.project_config.toml` may hold a `[[models]]` entry whose `provider` is a first-party vendor+group, whose `client_type` is absent, and whose `model_id` matches none of AgentHub's routing+rules. Such an entry was accepted by the Web App's add dialog and by `penguin config model add`+up to this release. It has never been able to serve a request: AgentHub raises+`<id> is not supported` at client construction.++Chosen: **tolerate it, indefinitely, and mark it.** The models page replaces the whole table on+every save, so refusing a stored row would have made one legacy entry block every later edit of+every other row — the setting a user would go there to fix among them. The refusal therefore+applies only to an entry a request introduces: one already stored under the same+`(provider, model_id)` key passes through untouched, and a key change (a different id, or a move+into a vendor group) is judged as a new entry, because that is the act of writing it there.++**A user is not required to do anything.** The entry stays where it is and keeps failing at+request time exactly as before. The models page marks such a row on its card and offers **move to+a custom group**, which opens the config dialog with the row already moved, where a protocol is+picked or detected — that is the one action that makes the model usable, and it is optional.++## The other old shape: a built-in model saved before its protocol pin++A preset row carries whatever the catalog said when the Project was written. `deepseek-flash` is+the live case: AgentHub routes DeepSeek on the `deepseek-v4` substring, which the released V4.1+Flash id does not carry, so the catalog row pins `client_type = "deepseek-v4"` — and a Project+written before that pin holds `deepseek/deepseek-flash` with no protocol at all. That row is+unroutable by the same rule, and it is the Project's default model.++Nothing refuses it either (it is already stored), and the fix is not a move: **sync presets**+writes the catalog's pin back over the entry. The page tells those two rows apart by whether the+catalog holds that exact `(provider, model_id)` pair and offers the matching action, so a built-in+model is never advised into a custom group. The preset-sync badge already pointed at the same+merge; this only names the consequence on the row itself.++`penguin config model add` follows the same split: naming an entry that already exists updates it,+including one in this shape; naming a new one in a vendor group with an unroutable id is refused+before anything is written.++## Nothing is scheduled for removal++This is a validation rule rather than a shim: there is no second code path reading an old format,+and nothing here expires. The one thing that would change the rule is AgentHub widening its own+routing, which `resolveModelEnv` mirrors — a row that starts routing simply stops being marked.++## Compatibility++Upgrading asks nothing of anyone. Configurations written before this release load and save as they+did; an entry a vendor group cannot route keeps its place in the table and now says so on the page.+What changes is what may be written from here on: a models PUT introducing such an entry answers+`400 model_not_routable`, and `penguin config model add` refuses with exit code 1 — scripts that+add a model of their own to a vendor group move it to a custom group, or pass `--client-type` to+name the protocol it speaks.diff --git a/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.zh.md b/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.zh.mdnew file mode 100644index 00000000..dedea04a--- /dev/null+++ b/changelog/unreleased/2026-09-21-backward-compatibility-vendor-groups.zh.md@@ -0,0 +1,54 @@+# 向后兼容++- **Date:** 2026-09-21+- **Type:** process+- **Scope:** `server`, `cli`, `web`, `core`+- **PR:** [#843](https://github.com/Prism-Shadow/penguin-harness/pull/843)+- **Breaking:** yes — 模型表 PUT 与 `penguin config model add` 若要把一方厂商分组无法路由的模型 id 写进去,一律拒绝(`400 model_not_routable` / 退出码 1);已存的条目照常工作,也从不被改写++[English](2026-09-21-backward-compatibility-vendor-groups.md)++[一方厂商分组只承载内置模型](2026-09-21-vendor-group-presets-only.zh.md)关闭了一种写得进去、却从来跑不+起来的配置。跨版本存活的只有一样:已经这样写下的条目。++## 旧形态:厂商分组里没有协议、id 又无处可路由的条目++`.project_config.toml` 里可能存在这样一条 `[[models]]`:`provider` 是一方厂商分组,没有 `client_type`,+`model_id` 又不匹配 AgentHub 的任何一条路由规则。直到本版本之前,Web App 的新增弹窗与+`penguin config model add` 都接受它。它从来没能服务过任何一次请求:AgentHub 在构造客户端时就抛出+`<id> is not supported`。++选择:**长期容忍,并把它标出来。** 模型配置页每次保存都整表替换,如果连已存的行也拒绝,一条遗留条目就会+卡住其余每一行后续的每一次编辑——包括用户正要去那里修的那项设置。因此拒绝只针对请求新引入的条目:按同一+`(provider, model_id)` 键已存在的条目原样放行;改键(换 id,或移入厂商分组)按新条目判定,因为那正是「把+它写进去」这个动作本身。++**用户无需做任何事。** 条目留在原处,与此前完全一样在请求时失败。模型配置页会在这样的卡片上给出标记,并+提供**移到自定义分组**:点开即是已完成迁移的配置弹窗,在那里选择或检测协议——这是唯一能让该模型可用的操作,+且完全可选。++## 另一种旧形态:在协议被钉住之前保存的内置模型++预置行带的是写入该 Project 时目录的说法。`deepseek-flash` 就是现成的例子:AgentHub 只按 `deepseek-v4`+这个子串路由 DeepSeek,而发布出来的 V4.1 Flash id 并不含它,因此目录行钉了+`client_type = "deepseek-v4"`——在该钉住之前写下的 Project,`deepseek/deepseek-flash` 这一行一个协议都+没有。按同一条规则,这一行无法路由,而它正是该 Project 的默认模型。++它同样不会被拒绝(本就已存),而且出路不是迁移:**同步预置**会把目录的协议写回该条目。页面按目录是否持有+这一对 `(provider, model_id)` 区分两类行,给出各自对应的操作,绝不把内置模型劝进自定义分组。预置同步的角标+本就指向同一套合并,这里只是把后果落到行自身上。++`penguin config model add` 采用同一分界:点名一个已存在的条目即更新它,这种形态的条目也不例外;在厂商分组+下点名一个 id 无法路由的新条目,则在写入任何内容之前被拒绝。++## 没有任何计划中的删除项++这是一条校验规则,不是垫片:没有第二条读取旧格式的代码路径,这里也没有任何东西带有效期。唯一会改变该规则+的是 AgentHub 自己放宽路由,而 `resolveModelEnv` 镜像的正是它——某一行一旦开始可路由,标记自然消失。++## 兼容性++升级不对任何人提出要求。本版本之前写下的配置照常读取与保存;厂商分组无法路由的条目继续留在表里,现在会在页+面上直说这件事。变的是此后允许写入什么:引入这类条目的模型表 PUT 返回 `400 model_not_routable`,+`penguin config model add` 以退出码 1 拒绝——把自己的模型加进厂商分组的脚本,改为加进自定义分组,或用+`--client-type` 点名该模型所用的协议。diff --git a/changelog/unreleased/2026-09-21-vendor-group-presets-only.md b/changelog/unreleased/2026-09-21-vendor-group-presets-only.mdnew file mode 100644index 00000000..e583ae12--- /dev/null+++ b/changelog/unreleased/2026-09-21-vendor-group-presets-only.md@@ -0,0 +1,61 @@+# A first-party vendor group carries built-in models only++- **Date:** 2026-09-21+- **Type:** fix+- **Scope:** `web`, `server`, `cli`, `core`+- **PR:** [#843](https://github.com/Prism-Shadow/penguin-harness/pull/843)++[中文版](2026-09-21-vendor-group-presets-only.zh.md)++Configuring a model of one's own inside a first-party vendor group — DeepSeek, Google, OpenAI,+Anthropic, Z.AI, Moonshot, MiniMax, Penguin Go — produced an entry that could not start. Those+groups persist no `client_type`, so AgentHub places each entry by the spelling of the upstream+model id alone, and an id outside its routing rules was answered at request time with AgentHub's+own sentence: `qwen/qwen3.8-flash-next is not supported. Supported client types: minimax-m3,+gemini-3.8, …`. The connectivity test relayed that sentence verbatim, and the dialog offered no+way out of it. The groups now carry the built-in catalog and nothing else, and the ways into that+state were closed.++## The predicate++`isVendorGroup` (core, `packages/core/src/state/model-catalog.ts`) answers "is this a group that+routes by model id alone?" for the whole app: a group the catalog knows, that is not `custom`,+carries no gateway base URL and pins no protocol of its own. `unroutableVendorModel` pairs it with+`resolveModelEnv`, which already mirrors AutoLLMClient's routing rules branch for branch, to answer+"would this entry be unplaceable?" — no surface matches on the upstream message text.++## The models page++- The add-model entry point was dropped from every vendor group header. Custom, user-defined and+ gateway groups keep theirs, and the page's other group actions — the bulk API key, the speed+ test, the console link — are unchanged everywhere. The add dialog's vendor-group title and+ protocol note went with it, along with the base URL the Penguin Go add pre-filled.+- A row whose id does not route now carries a warning on its card, and the way out follows what+ the catalog knows about that exact `(provider, model_id)` pair (`unroutableFix`): a pair the+ catalog holds is a built-in model saved before the catalog pinned the protocol its id needs, and+ is offered **sync presets**, the page header's own merge; a pair the catalog does not hold was+ added by hand and is offered **move to a custom group**, which opens the config dialog with the+ row already moved, where the protocol can be picked from the base URL field's suffix menu or+ detected from the endpoint. The config dialog's own inline warning makes the same split, so one+ row never reads two ways.+- The connectivity test on such an entry reports what is wrong and which of the two fixes applies,+ instead of relaying AgentHub's sentence. The upstream text goes to the browser console, so a+ developer reading a report still has it.++## The models PUT and the CLI++`PUT /api/projects/:projectId/models` refuses an entry the request introduces into a vendor group+under an unroutable id, with `400 model_not_routable` and a message naming the entry and the way+out; the Web App localizes it by code. An entry already stored under that key is written back+untouched — see [backward compatibility](2026-09-21-backward-compatibility-vendor-groups.md).++`penguin config model add` writes the config file directly rather than through that route, so it+refuses the same configuration (exit code 1, nothing written) when the entry is new. An entry that+already exists is updated as before, and an explicit `--client-type` — or a catalog row that pins+one, as MiniMax M3 and the direct `deepseek-flash` do — makes the id routable and is accepted.++## The catalog's own guard++"A built-in model must satisfy id routing" became a rule of the catalog, so it is pinned by a test+beside the catalog's other invariants: every `MODEL_CATALOG` row in a vendor group resolves through+`resolveModelEnv`, by its pinned `client_type` or by its id.diff --git a/changelog/unreleased/2026-09-21-vendor-group-presets-only.zh.md b/changelog/unreleased/2026-09-21-vendor-group-presets-only.zh.mdnew file mode 100644index 00000000..2aa2826b--- /dev/null+++ b/changelog/unreleased/2026-09-21-vendor-group-presets-only.zh.md@@ -0,0 +1,49 @@+# 一方厂商分组只承载内置模型++- **Date:** 2026-09-21+- **Type:** fix+- **Scope:** `web`, `server`, `cli`, `core`+- **PR:** [#843](https://github.com/Prism-Shadow/penguin-harness/pull/843)++[English](2026-09-21-vendor-group-presets-only.md)++在一方厂商分组——DeepSeek、Google、OpenAI、Anthropic、Z.AI、Moonshot、MiniMax、Penguin Go——里配置+自己的模型,得到的是一个跑不起来的条目。这些分组不落 `client_type`,AgentHub 只按上游模型 id 的写法+为每个条目选择客户端;超出其路由规则的 id 到发起请求时才由 AgentHub 自己回答:`qwen/qwen3.8-flash-next+is not supported. Supported client types: minimax-m3, gemini-3.8, …`。连通性测试把这句话原样转述,+弹窗也没给出任何出路。现在这些分组只承载内置目录,写入该状态的入口一并关闭。++## 判据++`isVendorGroup`(core,`packages/core/src/state/model-catalog.ts`)为全应用回答「这个分组是否只按模型+id 路由」:目录认识、不是 `custom`、没有网关 base URL、也不钉自己的协议。`unroutableVendorModel` 把它+与 `resolveModelEnv` 配在一起——后者本就逐分支镜像 AutoLLMClient 的路由规则——回答「这个条目会不会无法+落到任何客户端」;没有任何一处按上游报文的文本做匹配。++## 模型配置页++- 每个厂商分组的组头去掉了新增模型入口。custom、自建分组与网关分组保留各自的入口;页面其余的分组操作+ ——批量 API key、测速、控制台外链——在所有分组上都不变。新增弹窗中厂商分组专用的标题与协议提示一并移除,+ Penguin Go 新增时预填 base URL 的分支同理。+- 条目若 id 无法路由,卡片上给出警示,出路按目录是否认识这一对 `(provider, model_id)` 分流+ (`unroutableFix`):目录认识的,是在目录为其 id 钉下协议之前保存的内置模型,给出**同步预置**——即页头+ 那套合并;目录不认识的,是手工加进来的,给出**移到自定义分组**:点开配置弹窗时该条目已完成迁移,协议可+ 从 base URL 输入框的后缀菜单里选,也可按端点检测。配置弹窗内联的警示按同一口径分流,同一行不会出现两种+ 说法。+- 对这类条目做连通性测试,改为说明问题所在与两种出路中适用的那一种,不再转述 AgentHub 那句话;上游原文+ 写入浏览器控制台,开发者查报告时仍拿得到。++## 模型表 PUT 与 CLI++`PUT /api/projects/:projectId/models` 拒绝本次请求新引入、且 id 无法路由的厂商分组条目,返回+`400 model_not_routable`,报文点名该条目与出路,Web App 按 error code 本地化。已按该键存在的条目原样写回+——见[向后兼容](2026-09-21-backward-compatibility-vendor-groups.zh.md)。++`penguin config model add` 直接写配置文件、不经过该路由,因此对新条目以同样的口径拒绝(退出码 1,不写入+任何内容)。已存在的条目照旧更新;显式 `--client-type`——或如 MiniMax M3 与直连 `deepseek-flash` 那样由+目录行钉住协议——即让该 id 可路由,照常接受。++## 目录自身的守卫++「内置模型必须满足按 id 路由」成为目录的一条规则,因此与目录其他不变量并列钉进测试:厂商分组下的每一条+`MODEL_CATALOG` 记录都能经 `resolveModelEnv` 解析——按其钉住的 `client_type`,或按其 id。diff --git a/packages/cli/src/commands/config.ts b/packages/cli/src/commands/config.tsindex 2d3179ea..beb736a8 100644--- a/packages/cli/src/commands/config.ts+++ b/packages/cli/src/commands/config.ts@@ -21,7 +21,9 @@* (provider, model_id) pair when one pins them, and otherwise default according to the* group's semantics (not set for first-party vendors; the protocol a group pins where it* pins one, and otherwise openai-chat for custom / self-hosted groups / gateways, with the- * gateway's endpoint base URL pre-filled). For `model default` / `model vision`, core+ * gateway's endpoint base URL pre-filled); adding a NEW entry to a first-party vendor group+ * under a model id AgentHub cannot route is refused, since nothing there would carry a+ * protocol for it. For `model default` / `model vision`, core* validation raises an error when the reference is not* found in models; `model remove` reports the same condition itself, since removal is* idempotent in core, and clears the default / vision pointers that named the removed entry.@@ -46,6 +48,7 @@ import {fastModeProtocol,formatModelRef,getModel,+ isVendorGroup,loadAgentVault,loadProjectConfig,providerClientType,@@ -56,6 +59,7 @@ import {setDefaultModel,setVaultEntry,setVisionModel,+ unroutableVendorModel,} from "@prismshadow/penguin-core";import { parseApprovalAnswer } from "../approval.js";import { resolveRootOption } from "../root-option.js";@@ -172,8 +176,10 @@ export function registerConfigCommand(program: Command, t: Messages): void {// normalizes the deprecated bare "openai" alias.)const pInfo = providerInfo(provider);const catalogEntry = catalogEntryFor(provider, modelId);- const openAiDefault =- pInfo === undefined || pInfo.id === "custom" || pInfo.gatewayBaseUrl !== undefined;+ // Every group but a vendor one ends up on the compatible client when nothing above has+ // answered: a group-level pin is consumed first, so the two groups that carry one never+ // reach this term at all.+ const openAiDefault = !isVendorGroup(provider);const groupClientType = providerClientType(provider);const defaultClientType =catalogEntry?.clientType ?? groupClientType ?? (openAiDefault ? "openai-chat" : undefined);@@ -181,6 +187,20 @@ export function registerConfigCommand(program: Command, t: Messages): void {const clientType: string | undefined =opts.clientType ?? (!existed ? defaultClientType : undefined);const baseUrl: string | undefined = opts.baseUrl ?? (!existed ? defaultBaseUrl : undefined);+ // This command writes the config file directly rather than through the server's models+ // route, so the rule that route enforces is enforced again here — otherwise the door+ // the Web App closed is still open from the shell, and an agent following the+ // "add models with AI" prompt walks straight through it. A first-party vendor group+ // persists no client_type, so AgentHub places its entries by the model id alone; an id+ // it cannot place is refused before anything is written. Judged on the protocol the+ // entry would actually be saved with, so a preset that pins one (MiniMax M3, the direct+ // `deepseek-flash`) and an explicit --client-type both pass. An entry that is already+ // stored is left alone: updating it is not the act that put it there.+ if (!existed && unroutableVendorModel(provider, modelId, clientType)) {+ process.stderr.write(`${t.error(t.modelNotRoutable(formatModelRef(ref)))}\n`);+ process.exitCode = 1;+ return;+ }// Only collect explicitly given price fields, letting addModel merge them with the existing pricing per-field.const pricing: Partial<ModelPricing> = {};if (opts.priceCacheRead !== undefined) pricing.cache_read = opts.priceCacheRead;diff --git a/packages/cli/src/i18n.ts b/packages/cli/src/i18n.tsindex 16ded44c..6812ff64 100644--- a/packages/cli/src/i18n.ts+++ b/packages/cli/src/i18n.ts@@ -939,6 +939,8 @@ export interface Messages {modelRemoved(model: string, defaultModel: string | undefined): string;/** `model remove` on a pair the Project config doesn't have. */modelNotConfigured(model: string): string;+ /** `model add` refused: a new entry in a first-party vendor group under a model id AgentHub cannot route. */+ modelNotRoutable(model: string): string;/** Follows modelRemoved when the removed entry was also the vision model. */visionModelCleared(): string;modelListTitle(): string;@@ -1893,6 +1895,10 @@ const en: Messages = {visionModelSet: (model) => `Vision model set to ${model}.`,modelRemoved: (model, def) => `Removed model ${model}. Default model: ${def ?? "(unset)"}`,modelNotConfigured: (model) => `Model ${model} is not in the Project config.`,+ modelNotRoutable: (model) =>+ `Model ${model} cannot be routed: a vendor group carries built-in models only. ` ++ `Add it under a custom group (--provider custom) with --client-type and --base-url, ` ++ `or pass --client-type to pin the protocol this model speaks.`,visionModelCleared: () => "It was also the vision model; that setting is now unset.",modelListTitle: () => "Configured models:",modelListEmpty: () => "No models configured yet. Add one with `penguin config model add`.",@@ -2764,6 +2770,10 @@ const zh: Messages = {visionModelSet: (model) => `视觉模型已设为 ${model}。`,modelRemoved: (model, def) => `已删除模型 ${model}。当前默认模型:${def ?? "(未设置)"}`,modelNotConfigured: (model) => `模型 ${model} 不在当前 Project 配置中。`,+ modelNotRoutable: (model) =>+ `模型 ${model} 无法路由:厂商分组只承载内置模型。` ++ `请改用自定义分组(--provider custom)并附上 --client-type 与 --base-url,` ++ `或用 --client-type 指定该模型所用的协议。`,visionModelCleared: () => "它同时是视觉模型,该设置已一并清空。",modelListTitle: () => "已配置的模型:",modelListEmpty: () => "尚未配置任何模型。用 `penguin config model add` 添加。",diff --git a/packages/cli/test/config-model.test.ts b/packages/cli/test/config-model.test.tsindex 5d21d175..476f922e 100644--- a/packages/cli/test/config-model.test.ts+++ b/packages/cli/test/config-model.test.ts@@ -187,11 +187,13 @@ describe("penguin config model add/list (--root plus provider / model_id storedtmpRoot,]);await runModel(["add", "--model-id", "in-house-1", "--provider", "mylab", "--root", tmpRoot]);- // A non-catalog id under a first-party vendor group: client_type is not set (AgentHub auto-routes by upstream id).+ // A non-catalog id under a first-party vendor group: client_type is not set (AgentHub+ // auto-routes by upstream id). The id has to be one that routing places — the group+ // carries nothing else that could name a protocol for it (see the refusal test below).await runModel(["add","--model-id",- "my-fine-tune",+ "deepseek-v4-my-tune","--provider","deepseek","--root",@@ -229,12 +231,100 @@ describe("penguin config model add/list (--root plus provider / model_id storedparsed.models.find((m) => m.provider === p && m.model_id === id)!;expect(by("custom", "my-openai-proxy").client_type).toBe("openai-chat");expect(by("mylab", "in-house-1").client_type).toBe("openai-chat");- expect(by("deepseek", "my-fine-tune").client_type).toBeUndefined();+ expect(by("deepseek", "deepseek-v4-my-tune").client_type).toBeUndefined();expect(by("openrouter", "acme/some-model").client_type).toBe("openai-responses");expect(by("openrouter", "acme/some-model").base_url).toBe("https://openrouter.ai/api/v1");expect(by("mylab", "special-1").client_type).toBe("verbatim-type");});+ it("refuses a NEW vendor-group entry whose id AgentHub cannot route, and leaves the config untouched", async () => {+ // The Web App no longer offers an add entry point on a vendor group at all; this command+ // writes the same file without passing through the server, so it has to refuse the same+ // configuration rather than leave a second way into it.+ const stored = async (p: string, id: string) => {+ const parsed = parseToml(+ await fs.readFile(projectConfigPath(tmpRoot, DEFAULT_PROJECT_ID), "utf8"),+ ) as { models: Array<Record<string, unknown>> };+ return parsed.models.find((m) => m.provider === p && m.model_id === id);+ };+ // One accepted add first, so there is a config file on disk for the refusal to leave alone.+ await runModel(["add", "--model-id", "seed", "--provider", "custom", "--root", tmpRoot]);+ const refused = await runModel([+ "add",+ "--model-id",+ "qwen/qwen3.8-flash-next",+ "--provider",+ "deepseek",+ "--root",+ tmpRoot,+ ]);+ expect(refused.code).toBe(1);+ expect(refused.err).toContain("cannot be routed");+ expect(refused.err).toContain("custom group");+ expect(await stored("deepseek", "qwen/qwen3.8-flash-next")).toBeUndefined();++ // The same id is fine wherever the group itself answers the protocol question.+ const custom = await runModel([+ "add",+ "--model-id",+ "qwen/qwen3.8-flash-next",+ "--provider",+ "custom",+ "--base-url",+ "https://gateway.example/v1",+ "--root",+ tmpRoot,+ ]);+ expect(custom.code).toBe(0);++ // And inside a vendor group once the entry names its own protocol, which is what the two+ // presets whose ids do not route rely on.+ const pinned = await runModel([+ "add",+ "--model-id",+ "qwen/qwen3.8-flash-next",+ "--provider",+ "deepseek",+ "--client-type",+ "openai-chat",+ "--root",+ tmpRoot,+ ]);+ expect(pinned.code).toBe(0);+ const entry = await stored("deepseek", "qwen/qwen3.8-flash-next");+ expect(entry?.client_type).toBe("openai-chat");+ });++ it("an entry already stored in a vendor group still updates, however its id routes", async () => {+ // Grandfathering, the same rule the models PUT applies: a row written before this rule+ // existed keeps every other operation working, so no legacy entry is left unmaintainable.+ const file = projectConfigPath(tmpRoot, DEFAULT_PROJECT_ID);+ await runModel(["add", "--model-id", "seed", "--provider", "custom", "--root", tmpRoot]);+ await fs.appendFile(+ file,+ '\n[[models]]\nprovider = "deepseek"\nmodel_id = "legacy-fine-tune"\n',+ "utf8",+ );++ const update = await runModel([+ "add",+ "--model-id",+ "legacy-fine-tune",+ "--provider",+ "deepseek",+ "--context-window",+ "65536",+ "--root",+ tmpRoot,+ ]);+ expect(update.code).toBe(0);+ const parsed = parseToml(await fs.readFile(file, "utf8")) as {+ models: Array<Record<string, unknown>>;+ };+ const entry = parsed.models.find((m) => m.model_id === "legacy-fine-tune");+ expect(entry?.context_window).toBe(65536);+ });+it("a new entry naming a catalog row inherits that row's pinned client_type and base_url; --client-type still wins", async () => {// deepseek-flash is a direct-vendor preset that pins the deepseek-v4 client and the// vendor endpoint, because AgentHub routes DeepSeek on a substring the bare id lacks.diff --git a/packages/core/src/state/model-catalog.ts b/packages/core/src/state/model-catalog.tsindex c864468c..ca313466 100644--- a/packages/core/src/state/model-catalog.ts+++ b/packages/core/src/state/model-catalog.ts@@ -2529,6 +2529,55 @@ export function providerClientType(providerId: string): string | undefined {return providerInfo(providerId)?.clientType;}+/**+ * A first-party vendor group: one this catalog knows, that is not `custom`, carries no+ * gateway endpoint and pins no protocol of its own — DeepSeek, Google, OpenAI, Anthropic,+ * Z.AI, Moonshot, MiniMax, and the Penguin Go relay.+ *+ * What distinguishes it is that nothing in it decides a protocol: its entries persist no+ * `client_type`, so AgentHub places every one of them by the spelling of the upstream model+ * id alone. That makes the group's contents a closed set — the ids this catalog ships, plus+ * the few whose preset pins a protocol because their own id would not route — and an id+ * outside it cannot be started at all, whatever else is configured on the entry. Every+ * surface that has to answer "may a model be added here, and is this one routable?" reads+ * the group's shape through this one predicate rather than re-deriving it: the models page's+ * group actions and its config dialog, the models PUT, and the CLI's `config model add`.+ *+ * Every other group answers the protocol question by itself and therefore takes any id the+ * endpoint serves: `custom` and user-defined groups detect or pick it, a gateway inherits its+ * preset's, and a group-level pin (OpenRouter, vLLM) hands it to every entry.+ */+export function isVendorGroup(providerId: string): boolean {+ const info = providerInfo(providerId);+ return (+ info !== undefined &&+ info.id !== "custom" &&+ info.gatewayBaseUrl === undefined &&+ info.clientType === undefined+ );+}++/**+ * Whether this entry would be written into a vendor group with an id AgentHub cannot place+ * — the configuration that produces `"<id> is not supported. Supported client types: …"` on+ * the first request, and nothing before it.+ *+ * `resolveModelEnv` is the authority: it mirrors AutoLLMClient's routing rules branch for+ * branch and returns undefined on exactly the ids that client rejects. A blank id is not a+ * routing failure — the entry is still being typed, and the required-field validation is+ * what has something to say about it.+ */+export function unroutableVendorModel(+ provider: string,+ modelId: string,+ clientType?: string,+): boolean {+ const id = modelId.trim();+ if (id === "" || !isVendorGroup(provider)) return false;+ const pinned = clientType?.trim();+ return resolveModelEnv(id, pinned === "" ? undefined : pinned) === undefined;+}+/** Env var fallback for a single model (the var names AgentHub's client actually reads when api_key / base_url is blank). */export interface ModelEnvInfo {envKey: string;diff --git a/packages/core/test/model-catalog.test.ts b/packages/core/test/model-catalog.test.tsindex 9b189f62..c7237839 100644--- a/packages/core/test/model-catalog.test.ts+++ b/packages/core/test/model-catalog.test.ts@@ -22,8 +22,10 @@ import {providerClientType,providerInfo,fastModeProtocol,+ isVendorGroup,resolveModelEnv,resolveProviderModelEnv,+ unroutableVendorModel,} from "../src/state/index.js";describe("model-catalog", () => {@@ -1404,6 +1406,54 @@ describe("resolveModelEnv (PRN-021: env fallback resolved by AgentHub routing ru}});+ it("catalog invariant: every built-in row in a vendor group is routable, by its pinned protocol or by its id", () => {+ const vendorRows = MODEL_CATALOG.filter((m) => isVendorGroup(m.provider));+ // A guard is only a guard if it is looking at something: the vendor groups are where+ // ids alone decide routing, and they hold a large part of the catalog.+ expect(vendorRows.length).toBeGreaterThan(20);+ for (const m of vendorRows) {+ expect(+ unroutableVendorModel(m.provider, m.modelId, m.clientType),+ `${m.provider}/${m.modelId}`,+ ).toBe(false);+ }+ });++ it("unroutableVendorModel judges only the groups that route by id, and only once an id is typed", () => {+ // A vendor group: nothing carries a protocol, so the id has to be one AgentHub places.+ expect(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.+ 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.+ expect(unroutableVendorModel("custom", "qwen/qwen3.8-flash-next")).toBe(false);+ expect(unroutableVendorModel("openrouter", "qwen/qwen3.8-flash-next")).toBe(false);+ expect(unroutableVendorModel("tokendance", "qwen/qwen3.8-flash-next")).toBe(false);+ expect(unroutableVendorModel("vllm", "qwen/qwen3.8-flash-next")).toBe(false);+ expect(unroutableVendorModel("my-own-group", "qwen/qwen3.8-flash-next")).toBe(false);+ // An entry still being typed is not a routing failure.+ expect(unroutableVendorModel("deepseek", "")).toBe(false);+ expect(unroutableVendorModel("deepseek", " ")).toBe(false);+ });++ it("isVendorGroup: catalog-known, not custom, no gateway endpoint and no group-level protocol pin", () => {+ const vendors = ["deepseek", "google", "openai", "anthropic", "zhipu", "moonshot", "minimax"];+ for (const id of vendors) {+ expect(isVendorGroup(id), id).toBe(true);+ }+ // The Penguin Go relay pins its protocol per row rather than per group, so a model added+ // there by hand would be routed by its id exactly as in any other vendor group.+ expect(isVendorGroup("penguin-go")).toBe(true);+ // Gateways carry an endpoint, two groups pin a protocol, and custom / user-defined+ // groups exist precisely so the protocol can be chosen.+ for (const id of ["tokendance", "openrouter", "fireworks", "siliconflow", "vllm", "custom"]) {+ expect(isVendorGroup(id), id).toBe(false);+ }+ expect(isVendorGroup("my-own-group")).toBe(false);+ });+it("modelHomepageUrl: gateway per-model pages, vendor docs fallback, none for custom groups", () => {// Gateway URL patterns work for user-added ids in those groups too (not catalog-gated).expect(modelHomepageUrl("openrouter", "anthropic/claude-fable-5")).toBe(diff --git a/packages/server/src/services/project-config-service.ts b/packages/server/src/services/project-config-service.tsindex 12893320..a7639f23 100644--- a/packages/server/src/services/project-config-service.ts+++ b/packages/server/src/services/project-config-service.ts@@ -51,7 +51,7 @@ import {resolveProviderModelEnv,userText,} from "@prismshadow/penguin-core";-import { providerInfo } from "@prismshadow/penguin-core/model-catalog";+import { providerInfo, unroutableVendorModel } from "@prismshadow/penguin-core/model-catalog";import type {PluginTables,CommandPolicyRule,@@ -81,6 +81,7 @@ import type {ModelVisionDetectResponse,} from "../api/types.js";import { badRequest } from "../http/validate.js";+import { HttpError } from "../http/errors.js";import { cacheable } from "../internal/mtime-gate.js";import type {PlatformCatalogPricing,@@ -1298,6 +1299,10 @@ export class ProjectConfigService implements ProjectConfigStore {* `discount` is stored (null clears it); an omitted one keeps the stored promotion unless* the entry renames the row or changes its pricing; a row left out of the table takes its* promotion with it. A `discount` outside (0, 1) rejects the request before any write.+ *+ * An entry the request adds to a first-party vendor group under a model id AgentHub cannot+ * route is rejected as well (`model_not_routable`); one already stored under that key is+ * written as it stands. See the loop below for why the two differ.*/async updateModels(projectId: string, req: ModelsUpdateRequest): Promise<ModelsResponse> {return this.withProviderCredentialLock(projectId, MODELSCOPE_PROVIDER_ID, () =>@@ -1322,6 +1327,26 @@ export class ProjectConfigService implements ProjectConfigStore {(model) => model.provider === MODELSCOPE_PROVIDER_ID,);+ // A vendor group carries the built-in catalog and nothing else: its entries persist no+ // client_type, so AgentHub places each one by the spelling of the model id alone, and an+ // id it cannot place fails at request time with a sentence listing client types the user+ // never chose. Refused here, while the request can still be sent somewhere that works.+ //+ // Only an entry this request introduces is judged. The models page replaces the whole+ // table on every save, so an id written before this rule existed would otherwise block+ // every later edit of every other row; such a row is left exactly as it is, and the page+ // marks it. A key change is a different entry — moving a model into a vendor group, or+ // renaming one inside it, is the act of writing it there — so it is judged like a new one.+ for (const entry of req.models) {+ if (!unroutableVendorModel(entry.provider, entry.modelId, entry.clientType)) continue;+ if (prevModels.some((m) => entryMatches(m, entry.provider, entry.modelId))) continue;+ throw new HttpError(+ 400,+ "model_not_routable",+ `Model ${showRef(entry.provider, entry.modelId)} cannot be routed: a vendor group carries built-in models only. Add it under a custom group, where its protocol can be picked or detected.`,+ );+ }+const seen = new Set<string>();const nextModels: RawTable[] = [];let keepModelScopeGroup = false;diff --git a/packages/server/test/models.test.ts b/packages/server/test/models.test.tsindex b19b0d1d..22dd48c5 100644--- a/packages/server/test/models.test.ts+++ b/packages/server/test/models.test.ts@@ -21,6 +21,7 @@ import {userText,} from "@prismshadow/penguin-core";import type {+ ErrorBody,ModelsResponse,ModelTestResponse,ModelVisionDetectResponse,@@ -302,6 +303,90 @@ describe("models preset & catalog enrichment", () => {expect(noProvider.status).toBe(400);});+ it("PUT refuses an id a vendor group cannot route when the request introduces it, and carries a stored one through", async () => {+ const cfgFile = path.join(t.root, projectId, ".project_config.toml");+ // A row in the shape a vendor-group add used to produce: no client_type, and an id+ // AgentHub places nowhere, so it fails at request time with its "is not supported"+ // sentence. Rows like this exist in configs written before the rule below.+ await writeFile(+ cfgFile,+ ["[[models]]", 'provider = "deepseek"', 'model_id = "qwen/qwen3.8-flash-next"'].join("\n"),+ "utf8",+ );++ // Already stored: the whole-table PUT writes it back untouched. The models page sends the+ // entire table on every save, so refusing it here would make one legacy row block every+ // later edit of every other row.+ const kept = await api.put(url(), {+ models: [+ { provider: "deepseek", modelId: "qwen/qwen3.8-flash-next", contextWindow: 65536 },+ { provider: "custom", modelId: "mine", clientType: "openai-chat" },+ ],+ });+ expect(kept.status).toBe(200);+ const keptBody = (await kept.json()) as ModelsResponse;+ expect(pick(keptBody, "deepseek", "qwen/qwen3.8-flash-next").contextWindow).toBe(65536);++ // New in this request: refused, by a code the frontend can localize and a message naming+ // the entry and the way out.+ const added = await api.put(url(), {+ models: [+ { provider: "deepseek", modelId: "qwen/qwen3.8-flash-next" },+ { provider: "deepseek", modelId: "another-fine-tune" },+ ],+ });+ expect(added.status).toBe(400);+ const error = ((await added.json()) as ErrorBody).error;+ expect(error.code).toBe("model_not_routable");+ expect(error.message).toContain("another-fine-tune");+ expect(error.message).toContain("custom group");++ // A changed id is a different entry, so the rename is judged like a new one.+ const renamed = await api.put(url(), {+ models: [+ {+ provider: "deepseek",+ modelId: "qwen/qwen3.8-flash-next-preview",+ renamedFrom: { provider: "deepseek", modelId: "qwen/qwen3.8-flash-next" },+ },+ ],+ });+ expect(renamed.status).toBe(400);+ expect(((await renamed.json()) as ErrorBody).error.code).toBe("model_not_routable");++ // So is moving a model into a vendor group: the group is the half of the key that changed.+ const moved = await api.put(url(), {+ models: [+ { provider: "deepseek", modelId: "qwen/qwen3.8-flash-next" },+ {+ provider: "deepseek",+ modelId: "mine",+ renamedFrom: { provider: "custom", modelId: "mine" },+ },+ ],+ });+ expect(moved.status).toBe(400);++ // Nothing above was written: the stored table is still the one the accepted PUT left.+ const stored = (await (await api.get(url())).json()) as ModelsResponse;+ const expected = ["custom\0mine", "deepseek\0qwen/qwen3.8-flash-next"];+ expect(stored.models.map(pairKey).sort()).toEqual(expected.sort());++ // The same id is accepted wherever the group answers the protocol question itself.+ const custom = await api.put(url(), {+ models: [+ { provider: "deepseek", modelId: "qwen/qwen3.8-flash-next" },+ {+ provider: "custom",+ modelId: "qwen/qwen3.8-flash-next",+ clientType: "openai-chat",+ baseUrl: "https://gateway.example/v1",+ },+ ],+ });+ expect(custom.status).toBe(200);+ });+it('a config stored before the AgentHub 0.4.2 rename (client_type = "openai") keeps working: GET reports the canonical openai-chat', async () => {// Simulate an existing user config written by an older harness version: the deprecated// bare "openai" spelling on disk. Reading must not error and must report the canonicaldiff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsxindex e6e0ba25..fed90443 100644--- a/packages/web/src/features/models/models-page.tsx+++ b/packages/web/src/features/models/models-page.tsx@@ -79,15 +79,16 @@ import { EmptyState } from "../../components/ui/empty-state";import { formatDateTime, humanizeTokens } from "../../lib/format";import {MODEL_PROVIDERS,- PENGUIN_GO_BASE_URL,PENGUIN_GO_PROVIDER_ID,canonicalClientType,catalogEntryFor,fastModeProtocol,+ isVendorGroup,modelHomepageUrl,providerClientType,providerInfo,resolveProviderModelEnv,+ unroutableVendorModel,} from "@prismshadow/penguin-core/model-catalog";import type {FastModeProtocol,@@ -442,6 +443,34 @@ function isPreset(row: RowState): boolean {);}+/**+ * What to tell the owner of an entry its vendor group cannot route — `null` when there is+ * nothing wrong with it. The two answers are different advice, and giving the wrong one is+ * worse than giving none:+ *+ * - `"sync"` — the catalog knows this exact `(provider, model_id)` pair, so this is a+ * built-in model whose stored entry predates the protocol the catalog now pins for it+ * (`deepseek-flash` is the live example: AgentHub routes DeepSeek on a substring its+ * released id no longer carries, so the preset pins `deepseek-v4`, and a Project written+ * before that pin holds the row without it). Syncing presets writes the pin back. Telling+ * this owner to move a built-in model into a custom group would send them away from the+ * one action that fixes it.+ * - `"custom"` — the catalog does not know it, so it was added by hand into a group that+ * carries built-in models only, and it belongs under a custom group where a protocol can+ * be picked or detected.+ *+ * Judged on the CURRENT reference rather than the identity as loaded (isPreset): an id the+ * user has just retyped is not the catalog's row any more, and a sync would not touch it.+ */+export function unroutableFix(+ provider: string,+ modelId: string,+ clientType: string,+): "sync" | "custom" | null {+ if (!unroutableVendorModel(provider, modelId, clientType)) return null;+ return catalogEntryFor(provider, modelId.trim()) !== undefined ? "sync" : "custom";+}+/*** Whether this row already has (or will have, after this edit) an API key: the shared* hasConfiguredKey rule — a stored key or an env fallback the server proved is set — plus the two@@ -732,6 +761,13 @@ export function ModelsPage() {const [visionModel, setVisionModel] = useState<ModelRefDto | undefined>(undefined);/** Edit target: paired reference of an existing row. */const [editing, setEditing] = useState<ModelRefDto | null>(null);+ /**+ * Whether the dialog about to open should already have moved its row into the custom+ * group: set by a card's "move to custom group" action, which is a shortcut into the+ * config dialog rather than a write of its own — the move needs a protocol and a base URL,+ * and the dialog is where those are picked and confirmed.+ */+ const [editingMovedToCustom, setEditingMovedToCustom] = useState(false);/** Target group (provider id) for adding a model: taken from the group header entry point, falling back to custom when empty. */const [addingTo, setAddingTo] = useState<string | null>(null);const [query, setQuery] = useState("");@@ -1314,11 +1350,16 @@ export function ModelsPage() {<span className="hidden @3xl:inline">{S.models.platformSync}</span></Button>)}- {isOwner && (- // Add-model entry point: present on every group header (including- // custom), new models belong to that group. Narrow rows never hide a- // group action — they drop its label and keep the icon (same pattern- // for every action in this row), so the button stays reachable.+ {isOwner && !isVendorGroup(group.provider.id) && (+ // Add-model entry point: on every group header whose group decides a+ // protocol — custom, user-defined, and the gateways. A vendor group+ // carries the built-in catalog and nothing else: it persists no+ // client_type, so AgentHub places its entries by the model id alone+ // and anything outside the catalog's ids cannot start. The way to add+ // a model of one's own is a custom group, which has a protocol to+ // pick. Narrow rows never hide a group action — they drop its label+ // and keep the icon (same pattern for every action in this row), so+ // the button stays reachable.<Buttonsize="sm"variant="ghost"@@ -1467,7 +1508,19 @@ export function ModelsPage() {speed={speedResults.get(refMapKey(row.provider, row.modelId))}usedTokens={usedTokens.get(refMapKey(row.provider, row.modelId))}hourTick={hourTick}- onOpen={() => setEditing(rowRef(row))}+ onOpen={() => {+ setEditingMovedToCustom(false);+ setEditing(rowRef(row));+ }}+ onMoveToCustom={+ isOwner+ ? () => {+ setEditingMovedToCustom(true);+ setEditing(rowRef(row));+ }+ : undefined+ }+ onSyncPresets={isOwner ? () => void syncPresets() : undefined}/>)))}@@ -1700,6 +1753,7 @@ export function ModelsPage() {projectId={projectId}row={addingTo !== null ? null : (editingRow ?? null)}addProvider={addingTo ?? "custom"}+ movedToCustom={editingMovedToCustom}existingRefs={rows.map(rowRef)}detectedEnvKeys={envKeysDetected}currency={currency}@@ -1708,11 +1762,25 @@ export function ModelsPage() {isVisionModel={editingRow !== undefined && sameModelRef(rowRef(editingRow), visionModel)}onClose={() => {setEditing(null);+ setEditingMovedToCustom(false);setAddingTo(null);}}+ // The sync rewrites the very row this dialog was seeded from, so the dialog goes+ // first and the merge runs against the table, not around an open form.+ onSyncPresets={+ isOwner+ ? () => {+ setEditing(null);+ setEditingMovedToCustom(false);+ setAddingTo(null);+ void syncPresets();+ }+ : undefined+ }onSubmit={(next, action) => {const isNew = addingTo !== null;setEditing(null);+ setEditingMovedToCustom(false);setAddingTo(null);if (action === "remove") {// Filter by the **identity as loaded**: rows / pointers are both keyed by the@@ -2064,10 +2132,11 @@ function AddGroupDialog({/*** Card: display name + lifetime Token spend + status badges; context / pricing / key status folded* into one line of small text; group speed-test results (TTFT / TPS, tone-colored) ride the- * title row's right edge. The whole card is clickable (the model homepage link lives in the- * config dialog).+ * title row's right edge. All three lines are one click target opening the config dialog (the+ * model homepage link lives in there); a row whose model id its group cannot route adds a+ * warning strip below them, which carries its own action and therefore its own click target.*/-function ModelCard({+export function ModelCard({row,currency,isDefault,@@ -2076,6 +2145,8 @@ function ModelCard({usedTokens,hourTick,onOpen,+ onMoveToCustom,+ onSyncPresets,}: {row: RowState;currency: Currency;@@ -2087,7 +2158,19 @@ function ModelCard({/** Bumped on the hour (see useHourTick): the cue to re-read a time-of-day price. */hourTick: number;onOpen: () => void;+ /** Opens the config dialog with this row already moved to the custom group; absent for a member, who cannot write the config. */+ onMoveToCustom?: () => void;+ /** Runs the header's "sync presets" merge, which writes back a built-in model's missing protocol pin; absent for a member. */+ onSyncPresets?: () => void;}) {+ /**+ * A stored entry that sits in a vendor group under an id AgentHub cannot place, and which+ * of the two fixes it needs. Saving one is refused now, so this can only be a row that+ * predates that rule — it stays in the config untouched, and the card is where its owner+ * finds out, because every other sign of it arrives as a failed request minutes into a+ * conversation.+ */+ const fix = unroutableFix(row.provider, row.modelId, row.clientType);const priced = row.cacheRead || row.cacheWrite || row.output;/*** What is taken off this row's list price right now: its running promotion, its live@@ -2177,58 +2260,86 @@ function ModelCard({)) : null;return (- <button- type="button"- onClick={onOpen}- className="flex w-full flex-col gap-1 rounded-md border border-gray-200 px-3 py-2.5 text-left transition-colors duration-150 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-800 dark:hover:border-gray-700 dark:hover:bg-gray-800/40"- >- {/* 1. What the model is called — the name alone. The upstream id used to share this row,- but it is a detail you go looking for rather than one you scan by, and it is a click- away in the config dialog; the width it was taking now belongs to the name. */}- <span className="flex w-full min-w-0 items-baseline gap-2">- <span className="min-w-0 flex-1 truncate text-[13px] font-medium">- {modelLabelOf(row.displayName, row.modelId)}- </span>- {/* What this model has spent over its whole life, on the row's right edge. Recessive by- design — grey and a size below the meta line: it is context for a name you are- scanning past, not a figure the page is about. A model that has never run shows- nothing rather than a zero, which would read as a measurement instead of an- absence. */}- {usedTokens !== undefined && usedTokens > 0 && (- <span- className="shrink-0 text-[10px] tabular-nums text-gray-400 dark:text-gray-500"- title={S.models.usedTokensTitle}- >- {S.models.usedTokens(humanizeTokens(usedTokens))}- </span>- )}- </span>- {/* 2. Every standing mark, on one row of its own (see `tags`). The row is rendered even- when empty: most models carry no mark at all, and letting it collapse would leave the- grid ragged — cards in the same row of a two-column grid stretch to the tallest, so an- absent line shows up as uneven padding rather than as a shorter card. Its height is- the tags' own, so a card with marks and a card without are exactly as tall. */}- <span className="flex min-h-[17px] w-full flex-wrap items-center gap-1">- {tags.map((tag) => (- <span key={tag.key} title={tag.title} className={`${TAG_SHAPE} ${tag.className}`}>- {tag.label}+ // The card is a box holding the button rather than being one: the routing warning below+ // carries an action of its own, and buttons cannot nest (the group header solves the same+ // problem the same way). overflow-hidden lets the warning strip fill the rounded corners.+ <div className="flex w-full flex-col overflow-hidden rounded-md border border-gray-200 transition-colors duration-150 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-800 dark:hover:border-gray-700 dark:hover:bg-gray-800/40">+ <button+ type="button"+ onClick={onOpen}+ className="flex w-full flex-1 flex-col gap-1 px-3 py-2.5 text-left"+ >+ {/* 1. What the model is called — the name alone. The upstream id used to share this row,+ but it is a detail you go looking for rather than one you scan by, and it is a click+ away in the config dialog; the width it was taking now belongs to the name. */}+ <span className="flex w-full min-w-0 items-baseline gap-2">+ <span className="min-w-0 flex-1 truncate text-[13px] font-medium">+ {modelLabelOf(row.displayName, row.modelId)}</span>- ))}- </span>- {/* 3. Meta line: the truncating text takes the flexible space; speed badges keep their own- non-shrinking slot on the right so the numbers never wrap or get pushed out. */}- <span className="flex w-full items-center gap-1.5">- <span className="min-w-0 flex-1 truncate text-[11px] text-gray-400 dark:text-gray-500">- {meta.map((part, i) => (- <Fragment key={i}>- {i > 0 && " · "}- {part}- </Fragment>+ {/* What this model has spent over its whole life, on the row's right edge. Recessive by+ design — grey and a size below the meta line: it is context for a name you are+ scanning past, not a figure the page is about. A model that has never run shows+ nothing rather than a zero, which would read as a measurement instead of an+ absence. */}+ {usedTokens !== undefined && usedTokens > 0 && (+ <span+ className="shrink-0 text-[10px] tabular-nums text-gray-400 dark:text-gray-500"+ title={S.models.usedTokensTitle}+ >+ {S.models.usedTokens(humanizeTokens(usedTokens))}+ </span>+ )}+ </span>+ {/* 2. Every standing mark, on one row of its own (see `tags`). The row is rendered even+ when empty: most models carry no mark at all, and letting it collapse would leave the+ grid ragged — cards in the same row of a two-column grid stretch to the tallest, so an+ absent line shows up as uneven padding rather than as a shorter card. Its height is+ the tags' own, so a card with marks and a card without are exactly as tall. */}+ <span className="flex min-h-[17px] w-full flex-wrap items-center gap-1">+ {tags.map((tag) => (+ <span key={tag.key} title={tag.title} className={`${TAG_SHAPE} ${tag.className}`}>+ {tag.label}+ </span>))}</span>- {speedBadges}- </span>- </button>+ {/* 3. Meta line: the truncating text takes the flexible space; speed badges keep their own+ non-shrinking slot on the right so the numbers never wrap or get pushed out. */}+ <span className="flex w-full items-center gap-1.5">+ <span className="min-w-0 flex-1 truncate text-[11px] text-gray-400 dark:text-gray-500">+ {meta.map((part, i) => (+ <Fragment key={i}>+ {i > 0 && " · "}+ {part}+ </Fragment>+ ))}+ </span>+ {speedBadges}+ </span>+ </button>+ {/* The routing warning and its way out, which differ by what the catalog knows (see+ unroutableFix). Both actions run a flow the page already has — the header's preset+ sync, or the move the config dialog's own button performs — so the owner lands where+ the problem is fixed rather than on a second explanation. */}+ {fix !== null && (+ <div+ className={`flex items-center justify-between gap-2 border-t px-3 py-2 text-[11px] ${toneStrip.attention}`}+ >+ <span className="min-w-0">+ {fix === "sync" ? S.models.vendorRowStalePin : S.models.vendorRowUnroutable}+ </span>+ {fix === "sync" && onSyncPresets && (+ <Button size="sm" className="shrink-0" onClick={onSyncPresets}>+ {S.models.syncCatalog}+ </Button>+ )}+ {fix === "custom" && onMoveToCustom && (+ <Button size="sm" className="shrink-0" onClick={onMoveToCustom}>+ {S.models.moveToCustomGroup}+ </Button>+ )}+ </div>+ )}+ </div>);}@@ -2296,6 +2407,7 @@ function ModelDialog({projectId,row,addProvider,+ movedToCustom,existingRefs,detectedEnvKeys,currency,@@ -2303,12 +2415,15 @@ function ModelDialog({isDefault,isVisionModel,onClose,+ onSyncPresets,onSubmit,}: {projectId: string;row: RowState | null;/** Target group for add mode (row is null): the group of the header entry point / falls back to custom when empty. */addProvider: string;+ /** Edit mode: open with the row already moved into the custom group (a card's "move to custom group" action). */+ movedToCustom: boolean;existingRefs: ModelRefDto[];/** Env-fallback variables the server reported a value for (see detectedEnvKeys): the only ones the key hint may promise. */detectedEnvKeys: ReadonlySet<string>;@@ -2317,6 +2432,8 @@ function ModelDialog({isDefault: boolean;isVisionModel: boolean;onClose: () => void;+ /** Closes the dialog and runs the header's "sync presets" merge; absent for a member, who cannot write the config. */+ onSyncPresets?: () => void;onSubmit: (row: RowState, action: DialogAction) => void;}) {// Pricing input is displayed/entered in the current currency; converted back to USD storage on submit (RowState always stores USD).@@ -2327,45 +2444,50 @@ function ModelDialog({cacheRead: usdToInput(row.cacheRead, currency),cacheWrite: usdToInput(row.cacheWrite, currency),output: usdToInput(row.output, currency),+ // Opened from a card's "move to custom group": the same edit the dialog's own button+ // makes, applied before the form is first painted so the user arrives at the protocol+ // control instead of having to find the move again in here.+ ...(movedToCustom+ ? {+ provider: "custom",+ clientType: clientTypeAfterProviderChange("custom", row.clientType),+ }+ : {}),};}// New model: protocol follows group semantics — a group that pins one (OpenRouter,- // vLLM) hands it to the new entry outright; a first-party vendor group doesn't persist- // client_type (AgentHub auto-routes by upstream id, with env fallback resolved live from- // the id); custom / user-defined groups and the remaining gateways use a fixed- // openai-chat protocol (env fallback OPENAI_*), and gateways additionally pre-fill their- // endpoint base URL. provider keeps the entry point's original value (a user-defined- // group must not collapse into custom), stored as a separate field from model_id, with- // no concatenation on save.+ // vLLM) hands it to the new entry outright; custom / user-defined groups and the+ // remaining gateways use a fixed openai-chat protocol (env fallback OPENAI_*), and+ // gateways additionally pre-fill their endpoint base URL. provider keeps the entry+ // point's original value (a user-defined group must not collapse into custom), stored as+ // a separate field from model_id, with no concatenation on save.+ //+ // A first-party vendor group cannot be reached here at all: it carries the built-in+ // catalog and nothing else, so no entry point opens this dialog on one (the group+ // headers drop the action, the empty state opens custom, and a new group's name may not+ // collide with a built-in id).const info = providerInfo(addProvider);const pinnedClientType = providerClientType(addProvider);- const vendorAdd =- info !== undefined &&- info.id !== "custom" &&- info.gatewayBaseUrl === undefined &&- pinnedClientType === undefined;return {provider: addProvider,modelId: "",original: null,// A new custom model claims no vision support until it is detected or switched on by- // hand (per maintainer). Vendor and gateway adds keep the old optimistic default:- // their ids are catalog-known, so the capability is already established for them.+ // hand (per maintainer). A gateway add keeps the old optimistic default: its ids are+ // catalog-known, so the capability is already established for them.vision: !isCustomLikeGroup(addProvider),contextWindow: "",maxTokens: "",fastMode: false,// No protocol is preselected for a custom / user-defined group: it is detected from- // the endpoint (on demand, or on save while still unset) or picked by hand. Vendor- // groups auto-route by model id; a gateway takes the protocol its group pins, or the- // preset Chat Completions pin where the group pins nothing.- clientType:- pinnedClientType ?? (vendorAdd || isCustomLikeGroup(addProvider) ? "" : "openai-chat"),+ // the endpoint (on demand, or on save while still unset) or picked by hand. A gateway+ // takes the protocol its group pins, or the preset Chat Completions pin where the group+ // pins nothing.+ clientType: pinnedClientType ?? (isCustomLikeGroup(addProvider) ? "" : "openai-chat"),cacheRead: "",cacheWrite: "",output: "",- baseUrl:- addProvider === PENGUIN_GO_PROVIDER_ID ? PENGUIN_GO_BASE_URL : (info?.gatewayBaseUrl ?? ""),+ baseUrl: info?.gatewayBaseUrl ?? "",originalBaseUrl: "",apiKeyInput: "",clearApiKey: false,@@ -2440,6 +2562,25 @@ function ModelDialog({});};+ /**+ * What a failed probe says. An entry its group cannot place fails upstream with AgentHub's+ * own sentence — the id, then the list of client types it does support — which names an+ * internal vocabulary and leaves the reader to infer what to do about it. That case gets a+ * message naming the problem and the fix its own shape calls for (unroutableFix); every+ * other failure still relays the upstream text, which is what makes a wrong key or a wrong+ * endpoint diagnosable. The relayed sentence is not lost either way: it goes to the console,+ * where a developer looking into a report can still read it.+ */+ const reportTestFailure = (message: string) => {+ const fix = unroutableFix(form.provider, form.modelId, form.clientType);+ if (fix === null) {+ toastError(S.models.testFailed(message));+ return;+ }+ console.warn(`[models] ${form.provider}/${form.modelId.trim()}: ${message}`);+ toastError(fix === "sync" ? S.models.testStalePin : S.models.testNotRoutable);+ };+/*** Connectivity test: POST /models/test, sending the paired reference (provider, modelId)* in the request body (no URL-encoding concerns), along with the form's not-yet-saved@@ -2472,9 +2613,9 @@ function ModelDialog({body.fastMode = form.fastMode;const res = await api.testModel(projectId, body);if (res.ok) toastSuccess(S.models.testOk(res.latencyMs ?? 0));- else toastError(S.models.testFailed(res.message ?? ""));+ else reportTestFailure(res.message ?? "");} catch (e) {- toastError(S.models.testFailed(apiErrorText(e)));+ reportTestFailure(apiErrorText(e));} finally {setTesting(false);}@@ -2821,20 +2962,13 @@ function ModelDialog({// vLLM); undefined for every group that leaves the protocol to auto-routing, a gateway// preset, or detection.const pinnedGroupClientType = providerClientType(form.provider);- // First-party provider group (built-in, non-gateway, non-custom, no group-level pin):- // adding goes through auto-routing — show a hint when the id can't be routed- // (doesn't block saving: the routing table evolves with the AgentHub- // version, so it's judged at runtime).- const vendorGroup =- dialogProvider !== undefined &&- dialogProvider.id !== "custom" &&- dialogProvider.gatewayBaseUrl === undefined &&- pinnedGroupClientType === undefined;- const autoRouteMiss =- vendorGroup &&- !form.clientType.trim() &&- form.modelId.trim() !== "" &&- liveEnvKey === undefined;+ // An id this entry's group cannot place, and which fix it needs (see unroutableFix). The+ // save is refused by the server for a new or rekeyed entry, so the warning and its way out+ // are shown before the attempt; a row that was already stored keeps saving and carries the+ // same warning on its card.+ const routingFix = unroutableFix(form.provider, form.modelId, form.clientType);+ const routingFixMessage =+ routingFix === "sync" ? S.models.vendorRowStalePin : S.models.autoRouteNone;/** Identity section: upstream model id (renamable; "get model id" link next* to the label) + display name and group side by side (both editable;@@ -2874,24 +3008,37 @@ function ModelDialog({/>{fieldErrors.modelId && <FieldError>{fieldErrors.modelId}</FieldError>}</label>- {autoRouteMiss && (+ {routingFix !== null && (<divrole="alert"className={`flex items-center justify-between gap-3 rounded-md border px-2.5 py-2 text-xs ${toneStrip.attention}`}>- <span>{S.models.autoRouteNone}</span>- <Button- size="sm"- className="shrink-0"- onClick={() =>- set({- provider: "custom",- clientType: clientTypeAfterProviderChange("custom", form.clientType),- })- }- >- {S.models.useCustomGroup}- </Button>+ {/* A built-in model whose stored entry lost its protocol pin needs the preset sync,+ not a move: the same split the card makes, so the two places the owner can read+ about one row never give opposite advice. */}+ <span>{routingFixMessage}</span>+ {/* Syncing rewrites the table this form was seeded from, so the dialog closes on the+ way (the page's own handler does that); nothing typed here is worth keeping for a+ row whose protocol is about to be restored from the catalog. */}+ {routingFix === "sync" && onSyncPresets && (+ <Button size="sm" className="shrink-0" onClick={onSyncPresets}>+ {S.models.syncCatalog}+ </Button>+ )}+ {routingFix === "custom" && (+ <Button+ size="sm"+ className="shrink-0"+ onClick={() =>+ set({+ provider: "custom",+ clientType: clientTypeAfterProviderChange("custom", form.clientType),+ })+ }+ >+ {S.models.useCustomGroup}+ </Button>+ )}</div>)}<div className="grid grid-cols-2 gap-2">@@ -2968,12 +3115,10 @@ function ModelDialog({opentitle={isNew- ? vendorGroup- ? S.models.addTitleVendor- : customLikeGroup- ? // Custom / user-defined groups no longer pin one protocol (detection + selector), so the title drops the "(OpenAI protocol)" suffix gateways keep.- S.models.addTitleCustom- : S.models.addTitle+ ? customLikeGroup+ ? // Custom / user-defined groups no longer pin one protocol (detection + selector), so the title drops the "(OpenAI protocol)" suffix gateways keep.+ S.models.addTitleCustom+ : S.models.addTitle: S.models.editTitle}onClose={onClose}@@ -3088,15 +3233,13 @@ function ModelDialog({{isNew && (<><p className="text-xs text-gray-500 dark:text-gray-400">- {vendorGroup && dialogProvider- ? S.models.vendorProtocolHint(dialogProvider.label)- : pinnedGroupClientType !== undefined- ? dialogProvider?.gatewayBaseUrl !== undefined- ? S.models.addProtocolHintPinnedGateway(pinnedGroupClientType)- : S.models.addProtocolHintPinned(pinnedGroupClientType)- : customLikeGroup- ? S.models.addProtocolHintDetect- : S.models.addProtocolHint}+ {pinnedGroupClientType !== undefined+ ? dialogProvider?.gatewayBaseUrl !== undefined+ ? S.models.addProtocolHintPinnedGateway(pinnedGroupClientType)+ : S.models.addProtocolHintPinned(pinnedGroupClientType)+ : customLikeGroup+ ? S.models.addProtocolHintDetect+ : S.models.addProtocolHint}</p>{identityFields}</>diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex e9278032..fc970381 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -1219,11 +1219,8 @@ export const en: Strings = {addToGroup: "Add model",editTitle: "Model settings",addTitle: "Add model (OpenAI protocol)",- addTitleVendor: "Add model",addProtocolHint:"New models use the OpenAI Chat Completions protocol; set the base URL to a compatible endpoint",- vendorProtocolHint: (vendor: string): string =>- `Only ${vendor}'s official API protocol is supported; use a custom model group for OpenAI-compatible endpoints.`,addProtocolHintPinned: (protocol: string): string =>`Models in this group always use the ${protocol} protocol; set the base URL to your own server`,addProtocolHintPinnedGateway: (protocol: string): string =>@@ -1231,6 +1228,25 @@ export const en: Strings = {autoRouteNone:"This model ID cannot be routed with the current provider protocol. If it uses an OpenAI-compatible endpoint, move it to Custom.",useCustomGroup: "Move to Custom",+ /** Warning on a hand-added vendor-group row whose model id AgentHub cannot route (such a row can no longer be created, only inherited). */+ vendorRowUnroutable:+ "This model ID cannot be routed and will fail at request time: a vendor group carries built-in models only.",+ /** The way out offered beside that warning: opens the config dialog with the row already in the custom group. */+ moveToCustomGroup: "Move to a custom group",+ /**+ * Warning on a built-in row saved before the catalog pinned the protocol its id needs:+ * re-merging the catalog repairs it, and a move would be the wrong advice. It never+ * quotes the sync button's own label — a member sees this sentence with no button beside+ * it, and the owner who does have one reads the label right there.+ */+ vendorRowStalePin:+ "This built-in model's entry predates the protocol the catalog now pins for it, so it cannot be routed; re-syncing the built-in catalog restores that pin.",+ /** Connectivity test on a hand-added row: replaces the upstream "is not supported" sentence, which names client types the user has no way to act on. */+ testNotRoutable:+ "Failed: this model ID cannot be routed. A vendor group carries built-in models only — move it to a custom group and pick or detect its protocol.",+ /** Connectivity test on a built-in row missing its pin: the same split the card makes, so the two never give opposite advice. */+ testStalePin:+ "Failed: this built-in model's entry predates the protocol the catalog now pins for it, so it cannot be routed. Re-syncing the built-in catalog restores that pin; it does not belong in a custom group.",addGroup: "Add group",addGroupTitle: "Add group",addGroupDesc:@@ -4556,6 +4572,8 @@ Scenarios:"This import would overwrite or delete memories. Confirm it to continue.",schedule_exists: "A scheduled task with this name already exists.",schedule_not_found: "This scheduled task no longer exists.",+ model_not_routable:+ "This model ID cannot be routed by a vendor group's protocol. Vendor groups carry built-in models only — add the model under a custom group and pick or detect its protocol.",unknown_skill: "This skill is not in the selected directory.",unknown_plugin: "This plugin is not in the plugin library.",goal_plugin_not_installed:diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 6f92fff4..4137ae53 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -1251,11 +1251,7 @@ export const zh = {addToGroup: "添加模型",editTitle: "模型配置",addTitle: "新增模型(OpenAI 协议)",- addTitleVendor: "新增模型",addProtocolHint: "新增模型走 OpenAI Chat Completions 兼容协议,base URL 填其兼容端点",- /** Add-dialog note for preset direct-vendor groups (fed the provider label): states whose protocol the group speaks — the in-field suffix on the base URL shows which path. */- vendorProtocolHint: (vendor: string): string =>- `仅支持 ${vendor} 官方接口协议,OpenAI 兼容接口请使用自定义模型分组`,/** Add-dialog note for a group that pins one protocol on every entry (fed the client type): the protocol is not a choice here, and the endpoint is the user's own. */addProtocolHintPinned: (protocol: string): string =>`本分组的模型固定使用 ${protocol} 协议,base URL 填你自己的服务地址`,@@ -1264,6 +1260,24 @@ export const zh = {`本分组的模型固定使用 ${protocol} 协议,base URL 已预填网关端点`,autoRouteNone: "该模型 ID 无法按当前厂商协议识别;若使用 OpenAI 兼容接口,可转为自定义模型。",useCustomGroup: "转为自定义模型",+ /** Warning on a hand-added vendor-group row whose model id AgentHub cannot route (such a row can no longer be created, only inherited). */+ vendorRowUnroutable: "该模型 ID 无法路由,运行时会失败:厂商分组只承载内置模型。",+ /** The way out offered beside that warning: opens the config dialog with the row already in the custom group. */+ moveToCustomGroup: "移到自定义分组",+ /**+ * Warning on a built-in row saved before the catalog pinned the protocol its id needs:+ * re-merging the catalog repairs it, and a move would be the wrong advice. It never+ * quotes the sync button's own label — a member sees this sentence with no button beside+ * it, and the owner who does have one reads the label right there.+ */+ vendorRowStalePin:+ "该内置模型的条目早于目录为它钉下的协议,当前无法路由;重新同步内置目录即可补回。",+ /** Connectivity test on a hand-added row: replaces the upstream "is not supported" sentence, which names client types the user has no way to act on. */+ testNotRoutable:+ "连通失败:该模型 ID 无法路由。厂商分组只承载内置模型;把它移到自定义分组,并选择或检测其接口协议。",+ /** Connectivity test on a built-in row missing its pin: the same split the card makes, so the two never give opposite advice. */+ testStalePin:+ "连通失败:该内置模型的条目早于目录为它钉下的协议,当前无法路由。重新同步内置目录即可补回该协议,它不属于自定义分组。",addGroup: "新增分组",addGroupTitle: "新增分组",addGroupDesc:@@ -4562,6 +4576,8 @@ Benchmark:memory_import_confirm_required: "本次导入会覆盖或删除已有记忆,请确认后继续。",schedule_exists: "已存在同名定时任务。",schedule_not_found: "该定时任务已不存在。",+ model_not_routable:+ "该模型 ID 无法按厂商分组的协议路由。厂商分组只承载内置模型;请在自定义分组中添加该模型,并选择或检测其接口协议。",unknown_skill: "所选目录下没有这个技能。",unknown_plugin: "该插件不在插件库中。",goal_plugin_not_installed:diff --git a/packages/web/test/vendor-group-models.test.ts b/packages/web/test/vendor-group-models.test.tsnew file mode 100644index 00000000..6ac460be--- /dev/null+++ b/packages/web/test/vendor-group-models.test.ts@@ -0,0 +1,201 @@+/**+ * A vendor group carries the built-in catalog and nothing else.+ *+ * Its entries persist no `client_type`, so AgentHub places each one by the spelling of the+ * model id alone; an id it cannot place is a model that never starts. The page therefore+ * offers no add-model entry point on such a group, and marks a row that cannot route — with+ * the fix that row's own shape calls for, since a built-in model whose stored entry lost its+ * protocol pin must not be told to move into a custom group.+ *+ * vitest runs node-only here, so the card is rendered to static markup and the group header —+ * which lives inside the page component and needs a fetch, a Project and localStorage — is+ * checked against the source of its own render condition.+ */+import { readFileSync } from "node:fs";+import { dirname, resolve } from "node:path";+import { fileURLToPath } from "node:url";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it } from "vitest";+import { isVendorGroup, unroutableVendorModel } from "@prismshadow/penguin-core/model-catalog";+import { ModelCard, unroutableFix } from "../src/features/models/models-page";+import type { RowState } from "../src/features/models/models-page";+import { S, zh } from "../src/lib/strings";+import { en } from "../src/lib/strings-en";++const noop = () => {};++const row = (patch: Partial<RowState>): RowState => ({+ provider: "deepseek",+ modelId: "deepseek-v4-pro",+ original: null,+ vision: true,+ contextWindow: "128000",+ maxTokens: "",+ fastMode: false,+ clientType: "",+ cacheRead: "",+ cacheWrite: "",+ output: "",+ baseUrl: "",+ originalBaseUrl: "",+ apiKeyInput: "",+ clearApiKey: false,+ ...patch,+});++/** Owner by default: both ways out are offered, so a test asserting one is absent means it. */+const render = (patch: Partial<RowState>, owner = true) =>+ renderToStaticMarkup(+ createElement(ModelCard, {+ row: row(patch),+ currency: "USD" as const,+ isDefault: false,+ isVisionModel: false,+ hourTick: 0,+ onOpen: noop,+ onMoveToCustom: owner ? noop : undefined,+ onSyncPresets: owner ? noop : undefined,+ }),+ );++/** In the catalog, and unroutable without the pin the catalog carries for it. */+const PRESET_MISSING_PIN = { modelId: "deepseek-flash" };+/** Not in the catalog: added by hand into a group that routes by id. */+const HAND_ADDED = { modelId: "qwen/qwen3.8-flash-next" };++describe("unroutableFix", () => {+ it("sends a built-in model to the preset sync, never to a custom group", () => {+ // deepseek-flash is the live case: AgentHub routes DeepSeek on a substring the released+ // id no longer carries, so the catalog pins deepseek-v4 — a Project written before that+ // pin holds the row without it.+ expect(unroutableFix("deepseek", "deepseek-flash", "")).toBe("sync");+ // With the pin the catalog carries today there is nothing wrong with the row at all.+ expect(unroutableFix("deepseek", "deepseek-flash", "deepseek-v4")).toBeNull();+ });++ it("sends a hand-added id to a custom group", () => {+ expect(unroutableFix("deepseek", "qwen/qwen3.8-flash-next", "")).toBe("custom");+ });++ it("judges the id currently in the field, not the one the row was loaded with", () => {+ // Retyping a preset's id makes it a different model; a sync would not touch it, so the+ // advice has to change with the field.+ expect(unroutableFix("deepseek", "deepseek-flash-0731", "")).toBe("custom");+ });++ it("has nothing to say about a routable row, a blank id, or a group that picks its protocol", () => {+ expect(unroutableFix("deepseek", "deepseek-v4-pro", "")).toBeNull();+ expect(unroutableFix("deepseek", " ", "")).toBeNull();+ expect(unroutableFix("custom", "qwen/qwen3.8-flash-next", "openai-chat")).toBeNull();+ expect(unroutableFix("openrouter", "qwen/qwen3.8-flash-next", "")).toBeNull();+ expect(unroutableFix("my-own-group", "qwen/qwen3.8-flash-next", "")).toBeNull();+ });+});++describe("a card for a row its vendor group cannot route", () => {+ it("tells a built-in model's owner to sync presets, and offers that action", () => {+ const html = render(PRESET_MISSING_PIN);+ expect(html).toContain(S.models.vendorRowStalePin);+ expect(html).toContain(S.models.syncCatalog);+ // The wrong advice for this row: it is a built-in model, and it stays where it is.+ expect(html).not.toContain(S.models.moveToCustomGroup);+ expect(html).not.toContain(S.models.vendorRowUnroutable);+ });++ it("tells a hand-added model's owner to move it, and offers that action", () => {+ const html = render(HAND_ADDED);+ expect(html).toContain(S.models.vendorRowUnroutable);+ expect(html).toContain(S.models.moveToCustomGroup);+ expect(html).not.toContain(S.models.vendorRowStalePin);+ expect(html).not.toContain(S.models.syncCatalog);+ });++ it("still warns a member in both cases, who has no config write and so is offered no action", () => {+ const preset = render(PRESET_MISSING_PIN, false);+ expect(preset).toContain(S.models.vendorRowStalePin);+ expect(preset).not.toContain(S.models.syncCatalog);+ const handAdded = render(HAND_ADDED, false);+ expect(handAdded).toContain(S.models.vendorRowUnroutable);+ expect(handAdded).not.toContain(S.models.moveToCustomGroup);+ });++ it("leaves a routable row, and every row outside a vendor group, unmarked", () => {+ // Routable by its own id, and routable by the protocol its own preset pins.+ const byId = render({ modelId: "deepseek-v4-pro" });+ const byPin = render({ modelId: "deepseek-flash", clientType: "deepseek-v4" });+ // The same unplaceable id in a group that decides the protocol itself.+ const inCustom = render({+ provider: "custom",+ modelId: "qwen/qwen3.8-flash-next",+ clientType: "openai-chat",+ });+ for (const html of [byId, byPin, inCustom]) {+ expect(html).not.toContain(S.models.vendorRowUnroutable);+ expect(html).not.toContain(S.models.vendorRowStalePin);+ }+ });+});++describe("the ways the page can open the add-model dialog", () => {+ const source = readFileSync(+ resolve(dirname(fileURLToPath(import.meta.url)), "../src/features/models/models-page.tsx"),+ "utf8",+ );+ /** Every call that OPENS add mode (setAddingTo(null) closes it and is not one of these). */+ const openers = [...source.matchAll(/setAddingTo\((?!null\))([^)]*)\)/g)].map((m) => m[1]);++ it("are exactly three, none of which can name a vendor group", () => {+ // A fourth would be a new way into the state this change closed, so it has to be read+ // here rather than discovered as a bug report. The three: the "no models at all" empty+ // state, which opens custom; the group header, guarded by the predicate; and a+ // brand-new group, whose name is rejected when it collides with a built-in id.+ expect(openers).toEqual(['"custom"', "group.provider.id", "name"]);+ expect(source).toContain("{isOwner && !isVendorGroup(group.provider.id) && (");+ expect(source).toContain("MODEL_PROVIDERS.some((p) => p.id === trimmed)");+ });++ it("leave the page's other group actions unguarded (only adding a model is closed off)", () => {+ // A vendor group still takes a bulk API key, a speed test and its console link — the rule+ // is about what may be written into the group, not about reaching it.+ expect(source).toContain("onClick={() => setGroupKeyFor(group.provider.id)}");+ expect(source).toContain("onClick={() => setSpeedFor(group.provider.id)}");+ });+});++describe("the predicate the page reads", () => {+ it("names the groups that route by model id alone", () => {+ expect(isVendorGroup("deepseek")).toBe(true);+ expect(isVendorGroup("custom")).toBe(false);+ expect(isVendorGroup("openrouter")).toBe(false);+ expect(unroutableVendorModel("deepseek", "qwen/qwen3.8-flash-next")).toBe(true);+ expect(unroutableVendorModel("custom", "qwen/qwen3.8-flash-next")).toBe(false);+ });+});++describe("copy", () => {+ it("carries both fixes in both dictionaries, and keeps them apart", () => {+ for (const dict of [zh, en]) {+ const m = dict.models;+ expect(m.vendorRowUnroutable).not.toBe(m.vendorRowStalePin);+ expect(m.testNotRoutable).not.toBe(m.testStalePin);+ // Neither message quotes the sync button's own label. The warning is shown to members+ // too, who have no such button, and the owner who does have one reads it right beside+ // the sentence. Checked per dictionary because a card only ever renders the active one.+ expect(m.vendorRowStalePin).not.toContain(m.syncCatalog);+ expect(m.testStalePin).not.toContain(m.syncCatalog);+ for (const text of [+ m.vendorRowUnroutable,+ m.vendorRowStalePin,+ m.moveToCustomGroup,+ m.testNotRoutable,+ m.testStalePin,+ // The server's refusal is localized by code, not by relaying its English message.+ dict.errors.byCode.model_not_routable,+ ]) {+ expect(text.length).toBeGreaterThan(0);+ }+ }+ expect(zh.models.moveToCustomGroup).not.toBe(en.models.moveToCustomGroup);+ });+});