From 414ec3c57eb4c025e8a46a89c2e7c7ec0eacf9d0 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:48:08 +0800 Subject: [PATCH] chore(release): publish Lite 2026.11.7 Bundle Core 0.90.0 and enable native Codex model discovery with hot reload, reversible adoption and translated catalog errors. Preserve protocol 58, store schema 28 and existing traffic/download fixes. --- README.md | 4 +- README.zh-CN.md | 2 +- package.json | 2 +- release-notes/2026.11.7.md | 7 + scripts/shots/core/en/status.json | 2 +- scripts/shots/core/zh/status.json | 2 +- src-tauri/Cargo.lock | 30 ++-- src-tauri/Cargo.toml | 14 +- src-tauri/crates/tw-adopt/src/clients.rs | 67 ++++++--- src-tauri/crates/tw-adopt/src/plan.rs | 7 +- src-tauri/crates/tw-adopt/tests/roundtrip.rs | 140 ++++++++++++++++++- src-tauri/src/clients/ops.rs | 8 +- src-tauri/src/clients/ops/tests.rs | 16 +++ src-tauri/tauri.conf.json | 2 +- src/i18n/core.zh.json | 2 + 15 files changed, 255 insertions(+), 50 deletions(-) create mode 100644 release-notes/2026.11.7.md diff --git a/README.md b/README.md index 557667ad..503e8a85 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,9 @@ before the client runs them. DeepSeek Harness are pointed at the gateway in one step, with the change previewed, the original file backed up and a restore always available; Cursor, Continue and Antigravity CLI come with instructions. Switching - upstreams then happens in the gateway alone. + upstreams then happens in the gateway alone. Codex uses a remote native model + catalog: model and alias changes appear on its next catalog refresh without + rewriting client configuration. Codex may cache the picker list. - **Protection against relays.** A relay sees every request in full and can rewrite every answer. Secrets & privacy swaps API keys, private keys, JWTs, connection-string passwords, Chinese resident ID numbers and bank card numbers diff --git a/README.zh-CN.md b/README.zh-CN.md index 2dc357af..0b951925 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -42,7 +42,7 @@ Claude Code、Codex 等 AI 客户端的本地网关,支持 macOS、Windows 与 ## 要点 -- **一次接入,随时切换。** Claude Code、Claude Desktop、Codex、opencode、Pi、oh-my-pi、Grok Build、Qwen Code、Hermes Agent、Zed、Aider 与 DeepSeek Harness 可一键指向网关,写入前预览改动、备份原文件,随时可以还原;Cursor、Continue 与 Antigravity CLI 提供配置说明。此后切换上游只在网关中完成。 +- **一次接入,随时切换。** Claude Code、Claude Desktop、Codex、opencode、Pi、oh-my-pi、Grok Build、Qwen Code、Hermes Agent、Zed、Aider 与 DeepSeek Harness 可一键指向网关,写入前预览改动、备份原文件,随时可以还原;Cursor、Continue 与 Antigravity CLI 提供配置说明。此后切换上游只在网关中完成。Codex 使用原生远程模型目录,模型和别名变更在下次目录刷新时生效,无需重写客户端配置;模型选择器可能保留客户端缓存。 - **防范中转站。** 中转站能看到请求的全部内容,也能改写每一次回答。「密钥与隐私」在请求发出前把 API 密钥、私钥、JWT、连接串口令、身份证号与银行卡号换成占位符,中转站拿不到原值。回答中若出现下载即执行、外发环境变量或凭据文件、读取私钥、写入开机启动项或定时任务之类的工具调用,「危险命令」会在客户端执行之前切断回答。「内容过滤」在请求发出前删除藏在不可见字符里的指令,可以直接拒绝提示注入,也可以删除或替换请求和模型回答中的指定词语。各项防护出厂处于「监控」状态,只记录并发出通知,逐项开启后生效;每条规则可单独设定动作。 - **上游互相对照。** 每个上游都与服务同一模型的其他上游对照:回答中的模型名与发出的不同、报告的输入明显偏多或偏少、提示缓存读取偏低,都会在上游列表的那一行标出,悬停可见证据与样本数。 - **扫描 MCP、技能与钩子。** 十三款客户端的 MCP 服务器并列显示并标出第三方服务器;客户端配置、技能、钩子与项目指令中的隐藏字符、提示注入、危险命令与过宽权限会被找出。 diff --git a/package.json b/package.json index 72f1b807..b18a4cc8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "thinkwatch-lite", "private": true, "description": "Desktop app for a local AI API gateway on macOS, Windows and Linux", - "version": "2026.11.6", + "version": "2026.11.7", "type": "module", "packageManager": "pnpm@11.13.0", "scripts": { diff --git a/release-notes/2026.11.7.md b/release-notes/2026.11.7.md new file mode 100644 index 00000000..e63f49dc --- /dev/null +++ b/release-notes/2026.11.7.md @@ -0,0 +1,7 @@ +Codex can now discover gateway models through a remote native catalog. Connect or reconnect Codex through Clients after upgrading, then restart Codex once to load the new connection settings. Subsequent model, alias and permission changes use the gateway's existing hot reload path and appear on the next catalog refresh without rewriting client configuration. + +Discovery uses gateway authentication and model permissions. Native upstream instructions and tools are preserved when available; ordinary upstreams use a conservative coding profile. The standard OpenAI models endpoint keeps its existing response shape. Codex can cache its picker list, so an already open client may need to refresh its catalog or restart before showing changes. + +Codex adoption configures discovery while preserving inactive profiles and restoring overridden fields when disconnected. Existing credentials are not copied into sidecar metadata. Manual setup instructions correctly show fields that need removing. + +This release bundles Core 0.90.0, including the native catalog and an update to patched bundled SQLite for RUSTSEC-2026-0459. The control-plane protocol remains 58 and the request-store schema remains 28. Existing settings, upstreams, request history and usage history are preserved. diff --git a/scripts/shots/core/en/status.json b/scripts/shots/core/en/status.json index dd3c8c2a..bfacdc96 100644 --- a/scripts/shots/core/en/status.json +++ b/scripts/shots/core/en/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.89.2" + "version": "0.90.0" } diff --git a/scripts/shots/core/zh/status.json b/scripts/shots/core/zh/status.json index dd3c8c2a..bfacdc96 100644 --- a/scripts/shots/core/zh/status.json +++ b/scripts/shots/core/zh/status.json @@ -16,5 +16,5 @@ "reachable": [] }, "uptime_secs": 0, - "version": "0.89.2" + "version": "0.90.0" } diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 38ddf42f..16d3c88d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4950,7 +4950,7 @@ dependencies = [ [[package]] name = "thinkwatch-lite" -version = "2026.11.6" +version = "2026.11.7" dependencies = [ "anyhow", "base64 0.22.1", @@ -5458,8 +5458,8 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "serde_json", @@ -5470,8 +5470,8 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "memchr", "serde", @@ -5480,8 +5480,8 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "aho-corasick", "base64 0.22.1", @@ -5502,8 +5502,8 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "serde_json", @@ -5529,8 +5529,8 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "serde", "ts-rs", @@ -5538,8 +5538,8 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "libc", "notify", @@ -5549,8 +5549,8 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.89.2" -source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.89.2#fa504eef35f256587b5de5660df7aa76d0cf8886" +version = "0.90.0" +source = "git+https://github.com/ThinkWatchProject/ThinkWatch-Core.git?tag=v0.90.0#d84fb38d3aae204ad3e256071596a62a2d543d1a" dependencies = [ "saphyr-parser", "thiserror 2.0.21", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a7013b88..9520e946 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thinkwatch-lite" -version = "2026.11.6" +version = "2026.11.7" edition = "2024" # **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust # 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和 @@ -26,12 +26,12 @@ license = "MIT" # twcore 二进制必须和这里编译进去的协议镜像来自同一个 core 版本 —— 打包脚本正是 # 从 tw-api 锁到的 tag 去取二进制的(见 scripts/fetch-core.sh)。 [workspace.dependencies] -tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } -tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.89.2" } +tw-api = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-types = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-yaml = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-guard = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-watch = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } +tw-link = { git = "https://github.com/ThinkWatchProject/ThinkWatch-Core.git", tag = "v0.90.0" } [lib] name = "thinkwatch_lite_lib" diff --git a/src-tauri/crates/tw-adopt/src/clients.rs b/src-tauri/crates/tw-adopt/src/clients.rs index 9f4a4298..0c9affdc 100644 --- a/src-tauri/crates/tw-adopt/src/clients.rs +++ b/src-tauri/crates/tw-adopt/src/clients.rs @@ -279,6 +279,8 @@ pub(crate) const NO_KEY: &str = "no-key"; #[derive(Debug, Clone)] pub struct Edit { pub path: Vec, + /// TOML has no null: a null edit removes this field while retaining its + /// original value for restoration. JSON/YAML nulls remain literal values. pub value: Val, /// 这个值是密钥。决定它进不进旁文件、要不要提示权限。 pub secret: bool, @@ -1028,16 +1030,9 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { // `POST /v1/responses`,`http_headers` 原样送达, // `experimental_bearer_token` 变成 `Authorization: Bearer`。 // - // **这里曾经有一条「Codex 不从网关取模型列表」的接管代价,删了。** - // 0.139.0 确实一个 GET 都没有,0.153.4 开始会先来一个 - // `GET /v1/models?client_version=…` —— 但它要的是 Codex 自己的目录 - // 格式(顶层 `models`),网关答的是 OpenAI 的 `data` 形状,它解码 - // 失败,只记一行日志。**而这不影响任何人用**:codex 的 - // `models-manager/models.json` 是 `include_str!` 编进二进制的,远端 - // 目录只是补充;模型名在内置表里就没有任何提示,不在就按兜底的 - // 272k 上下文跑。openai/codex 今天的 main 上还加了闸 —— 设了自定义 - // base_url 又没设 `model_catalog_url` 的 provider 直接跳过这次请求。 - // 一条不拦人、还在自己消失的事,不值得占接管对话框的一行。 + // The native remote catalog uses a separate endpoint: /v1/models keeps + // its standard OpenAI shape. Configure discovery once; later model and + // alias changes come from the live gateway, not config rewrites. "codex" => { let p = |k: &str| { vec![ @@ -1062,6 +1057,14 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { value: Val::s(gw.v1()), secret: false, }, + Edit { + path: p("model_catalog_url"), + value: Val::s(format!("{}/codex/models", gw.base.trim_end_matches('/'))), + secret: false, + }, + e(&["features", "api_key_model_discovery"], Val::Bool(true)), + e(&["model_catalog_json"], Val::Null), + e(&["model_providers", PROVIDER_ID, "env_key"], Val::Null), // `wire_api = "chat"` 已经被上游移除,只剩 responses Edit { path: p("wire_api"), @@ -1091,15 +1094,16 @@ pub fn edits(client: &Client, gw: &Gateway) -> Vec { secret: false, }, ]; - if let Some(k) = &gw.key { - // 名字带 experimental_,上游可能改。**改了也只是丢掉鉴权, - // 上面那个 http_headers 仍然认得出是谁发的。** - v.push(Edit { - path: p("experimental_bearer_token"), - value: Val::s(k), - secret: true, - }); - } + // API-key discovery needs an API key, even on a gateway that does + // not require authentication. A sentinel avoids falling back to + // the user's OpenAI credentials and enables remote discovery. + v.push(Edit { + path: p("experimental_bearer_token"), + value: Val::s(gw.key.as_deref().unwrap_or(NO_KEY)), + // The field's original value can still be a real credential. + // Keep it out of sidecars even when writing the sentinel. + secret: true, + }); v } // 写 v1 的写法:v1 和 v2 都认。已经有原生那一条的见 [`edits_for`] @@ -1208,6 +1212,31 @@ pub fn edits_for(client: &Client, gw: &Gateway, current: &str) -> Vec { "hermes-agent" => crate::hermes::edits(gw, current), "codex" => { let mut v = edits(client, gw); + // The selected default profile overrides root fields. Keep inactive + // profiles intact and restore these few fields on disconnect. + if let Ok(Some(Val::Str(profile))) = crate::toml::get(current, &["profile"]) { + let p = |field: &str| vec!["profiles".into(), profile.clone(), field.into()]; + v.push(Edit { + path: p("model_provider"), + value: Val::s(PROVIDER_ID), + secret: false, + }); + v.push(Edit { + path: p("model_catalog_json"), + value: Val::Null, + secret: false, + }); + v.push(Edit { + path: vec![ + "profiles".into(), + profile, + "features".into(), + "api_key_model_discovery".into(), + ], + value: Val::Bool(true), + secret: false, + }); + } v.extend(codex_detail_mode(current)); v } diff --git a/src-tauri/crates/tw-adopt/src/plan.rs b/src-tauri/crates/tw-adopt/src/plan.rs index 4d765d14..38064203 100644 --- a/src-tauri/crates/tw-adopt/src/plan.rs +++ b/src-tauri/crates/tw-adopt/src/plan.rs @@ -592,7 +592,12 @@ pub(crate) fn adopt_file( }, }; originals.push(Original::new(p, was)); - carries_secret |= secret; + carries_secret |= *secret && *value != Val::s(crate::clients::NO_KEY); + if fmt == Format::Toml && *value == Val::Null { + text = drop_(fmt, &text, &r, client)?; + targets.push(Target::Remove(p.clone())); + continue; + } // 已经是这个值了就不碰那一段字节:JSON 的数组和对象是重新排出来的, // 重排一遍会换掉原来的排版 —— 重复接管也就不再是空操作 let same = fmt == Format::Json diff --git a/src-tauri/crates/tw-adopt/tests/roundtrip.rs b/src-tauri/crates/tw-adopt/tests/roundtrip.rs index 30175867..11ff386e 100644 --- a/src-tauri/crates/tw-adopt/tests/roundtrip.rs +++ b/src-tauri/crates/tw-adopt/tests/roundtrip.rs @@ -324,7 +324,145 @@ fn adopting_codex_keeps_every_project_trust_and_mcp_server() { assert!(after.contains(r#"wire_api = "responses""#), "{after}"); assert!(after.contains("X-ThinkWatch-Client"), "{after}"); // 实测:不配 env_key 它也照发请求;env_key 指向没 export 的变量反而起不来 - assert!(!after.contains("env_key"), "不该写 env_key:{after}"); + assert_eq!( + tw_adopt::toml::get(&after, &["model_providers", "thinkwatch", "env_key"]).unwrap(), + None + ); +} + +#[test] +fn codex_uses_a_remote_catalog_without_persisting_the_model_list() { + let b = bed("codex", CODEX); + let c = client("codex"); + let p = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + apply(&c, &p, &b.backups).unwrap(); + let path = c.config_path(&b.home); + let after = read(&path); + let get = |p: &[&str]| tw_adopt::toml::get(&after, p).unwrap(); + assert_eq!( + get(&["model_providers", "thinkwatch", "model_catalog_url"]), + Some(tw_adopt::json::Val::s("http://127.0.0.1:8080/codex/models")) + ); + assert_eq!( + get(&["features", "api_key_model_discovery"]), + Some(tw_adopt::json::Val::Bool(true)) + ); + assert_eq!(get(&["model"]), Some(tw_adopt::json::Val::s("gpt-5.6-sol"))); + + let mut changed = gw(); + changed.models = vec!["brand-new-model".into()]; + let again = plan_adopt(&c, &b.home, &changed, &Around::default()).unwrap(); + assert!(again.is_noop(), "Model changes must not rewrite config"); + assert!(!after.contains("brand-new-model")); +} + +#[test] +fn codex_local_catalog_and_active_profile_are_reversibly_overridden() { + use tw_adopt::json::Val; + let seed = format!( + r#"profile = "work" +model_provider = "my-provider" +model_catalog_json = "/private/catalog.json" +{CODEX} +[features] +api_key_model_discovery = false +other_feature = true + +[profiles.work] +model_provider = "work-provider" +model_catalog_json = "/private/work-catalog.json" +model_reasoning_effort = "high" +[profiles.work.features] +api_key_model_discovery = false + +[profiles.personal] +model_provider = "personal-provider" +model_catalog_json = "/private/personal-catalog.json" +"# + ); + let b = bed("codex", &seed); + let c = client("codex"); + let path = c.config_path(&b.home); + let p = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + apply(&c, &p, &b.backups).unwrap(); + let after = read(&path); + let get = |p: &[&str]| tw_adopt::toml::get(&after, p).unwrap(); + assert_eq!(get(&["model_catalog_json"]), None); + assert_eq!(get(&["profiles", "work", "model_catalog_json"]), None); + assert_eq!( + get(&["profiles", "work", "model_provider"]), + Some(Val::s("thinkwatch")) + ); + assert_eq!( + get(&["profiles", "work", "features", "api_key_model_discovery"]), + Some(Val::Bool(true)) + ); + assert_eq!( + get(&["profiles", "work", "model_reasoning_effort"]), + Some(Val::s("high")) + ); + assert_eq!( + get(&["profiles", "personal", "model_catalog_json"]), + Some(Val::s("/private/personal-catalog.json")) + ); + let again = plan_adopt(&c, &b.home, &gw(), &Around::default()).unwrap(); + assert!(again.is_noop()); + apply(&c, &again, &b.backups).unwrap(); + let r = plan_restore(&c, &b.home).unwrap(); + apply_restore(&c, &r, &b.backups).unwrap(); + assert_eq!( + tw_adopt::toml::value(&read(&path)).unwrap().normalized(), + tw_adopt::toml::value(&restored_codex(&seed)) + .unwrap() + .normalized() + ); +} + +#[test] +fn codex_without_a_gateway_key_uses_a_non_secret_discovery_sentinel() { + let seed = format!( + "{CODEX}\n[model_providers.thinkwatch]\nenv_key = \"UNSET_ORIGINAL_PROVIDER_KEY\"\nexperimental_bearer_token = \"original-provider-credential\"\n" + ); + let b = bed("codex", &seed); + let c = client("codex"); + let mut gateway = gw(); + gateway.key = None; + let p = plan_adopt(&c, &b.home, &gateway, &Around::default()).unwrap(); + assert!(!p.carries_secret); + apply(&c, &p, &b.backups).unwrap(); + let sidecar = tw_adopt::sentinel::sidecar_path(&c.config_path(&b.home)); + assert!(!read(&sidecar).contains("original-provider-credential")); + assert_eq!( + tw_adopt::toml::get( + &read(&c.config_path(&b.home)), + &["model_providers", "thinkwatch", "env_key"] + ) + .unwrap(), + None + ); + assert_eq!( + tw_adopt::toml::get( + &read(&c.config_path(&b.home)), + &["model_providers", "thinkwatch", "experimental_bearer_token"] + ) + .unwrap(), + Some(tw_adopt::json::Val::s("no-key")) + ); + let r = plan_restore(&c, &b.home).unwrap(); + apply_restore(&c, &r, &b.backups).unwrap(); + let restored = read(&c.config_path(&b.home)); + assert_eq!( + tw_adopt::toml::get(&restored, &["model_providers", "thinkwatch", "env_key"]).unwrap(), + Some(tw_adopt::json::Val::s("UNSET_ORIGINAL_PROVIDER_KEY")) + ); + assert_eq!( + tw_adopt::toml::get( + &restored, + &["model_providers", "thinkwatch", "experimental_bearer_token"] + ) + .unwrap(), + Some(tw_adopt::json::Val::s("original-provider-credential")) + ); } #[test] diff --git a/src-tauri/src/clients/ops.rs b/src-tauri/src/clients/ops.rs index cc28dbe3..49d4cb87 100644 --- a/src-tauri/src/clients/ops.rs +++ b/src-tauri/src/clients/ops.rs @@ -240,7 +240,13 @@ fn setup_of(c: &Client, steps: Vec, gw: &clients::Gateway) -> wire::ManualS fields: clients::edits(c, gw) .iter() .chain(&clients::also_edits(c, gw)) - .map(|e| field(wire::FieldOp::Set, &e.path, Some(&e.value), e.secret)) + .map(|e| { + if c.format == clients::Format::Toml && e.value == tw_adopt::json::Val::Null { + field(wire::FieldOp::Remove, &e.path, None, e.secret) + } else { + field(wire::FieldOp::Set, &e.path, Some(&e.value), e.secret) + } + }) .collect(), endpoint: c.endpoint(gw), } diff --git a/src-tauri/src/clients/ops/tests.rs b/src-tauri/src/clients/ops/tests.rs index afde4401..fe16bed7 100644 --- a/src-tauri/src/clients/ops/tests.rs +++ b/src-tauri/src/clients/ops/tests.rs @@ -92,6 +92,22 @@ fn every_client_says_how_to_connect_it_by_hand_without_the_key() { ); let json = serde_json::to_string(&r).unwrap(); assert!(!json.contains("tw-d"), "{json}"); + let codex = r.clients.iter().find(|c| c.id == "codex").unwrap(); + let local = codex + .manual + .fields + .iter() + .find(|f| f.path == "model_catalog_json") + .unwrap(); + assert!(matches!(local.op, wire::FieldOp::Remove)); + assert!(local.value.is_none()); + assert!( + codex + .manual + .fields + .iter() + .any(|f| f.path == "model_providers.thinkwatch.model_catalog_url") + ); } #[test] diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 2636eb28..d66a02be 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ThinkWatch Lite", - "version": "2026.11.6", + "version": "2026.11.7", "identifier": "app.thinkwatch.lite", "build": { "beforeDevCommand": "pnpm dev", diff --git a/src/i18n/core.zh.json b/src/i18n/core.zh.json index 1241b88c..26e33ca3 100644 --- a/src/i18n/core.zh.json +++ b/src/i18n/core.zh.json @@ -399,6 +399,8 @@ "gw.chatgpt.token_status": "令牌端点返回 {status}:{body}", "gw.chatgpt.token_not_json": "令牌端点的响应不是 JSON。", "gw.chatgpt.token_missing": "令牌端点的响应中没有 {field}。", + "gw.codex_catalog.client_version": "Codex 模型目录需要且只能指定一个 major.minor.patch 格式的 client_version。", + "gw.codex_catalog.too_large": "Codex 模型目录超过 1 MiB,请减少此网关密钥可用的模型。", "// ── gw.models / gw.probe:获取模型清单、检查上游 ───────────────────": "", "gw.models.check_failed": "检查未通过。", "gw.models.no_endpoint": "上游没有提供模型清单的接口(HTTP {status})。",