feat(claude-code): role-based model mapping with display names and 1M flag

- Replace the four flat env inputs with a Sonnet/Opus/Haiku role table.
  Each row exposes ANTHROPIC_DEFAULT_*_MODEL plus a new display name
  field ANTHROPIC_DEFAULT_*_MODEL_NAME, and Sonnet/Opus gain a
  "Declare 1M" checkbox that toggles the [1M] suffix.
- Strip the [1M] context-capability marker before forwarding non-Copilot
  requests upstream. Copilot keeps its existing [1m]->-1m normalization.
- Claude Desktop import now consumes ANTHROPIC_DEFAULT_*_MODEL_NAME as
  label_override, closing the Claude Code -> Claude Desktop displayName
  pipeline; add_route's merge logic is shared between hashmap branches.
- Unify the [1M] marker as ONE_M_CONTEXT_MARKER across
  claude_desktop_config and proxy::model_mapper; rename the strip
  helper to strip_one_m_suffix_for_upstream.
- Collapse useModelState's seven duplicated useState initializers and
  the useEffect parse block into a single parseModelsFromConfig call.
- Add tests/hooks/useModelState.test.tsx and a Claude Desktop import
  test covering Kimi K2 -> label_override. i18n (en/ja/zh) updated.
This commit is contained in:
Jason
2026-05-13 17:06:05 +08:00
parent 84bac6dce6
commit 4b57f7e113
11 changed files with 550 additions and 169 deletions
+13 -2
View File
@@ -908,9 +908,20 @@
"haikuModelPlaceholder": "",
"modelHelper": "Optional: Specify default Claude model to use, leave blank to use system default.",
"modelMappingLabel": "Model Mapping",
"modelMappingHint": "Usually not needed if the provider natively serves Claude models. Only configure when you need to map requests to different model names.",
"modelMappingHint": "Display names only affect the /model menu; 1M is only a Claude Code context-capability declaration.",
"modelRoleLabel": "Model role",
"modelRoleSonnet": "Sonnet",
"modelRoleOpus": "Opus",
"modelRoleHaiku": "Haiku",
"modelDisplayNameLabel": "Display name",
"modelDisplayNamePlaceholder": "e.g. DeepSeek V4 Pro",
"requestModelLabel": "Requested model",
"modelOneMHeader": "Declare 1M",
"modelOneMLabel": "1M",
"fallbackModelLabel": "Default fallback model",
"fallbackModelHint": "Used only when a Claude Code request does not clearly map to Sonnet, Opus, or Haiku. Usually safe to leave blank.",
"quickSetModels": "Quick Set",
"quickSetSuccess": "Model name applied to all fields",
"quickSetSuccess": "Model name applied to all roles",
"advancedOptionsToggle": "Advanced Options",
"advancedOptionsHint": "Includes API format, auth field, and model mapping. Defaults work for most use cases.",
"categoryOfficial": "Official",
+13 -2
View File
@@ -908,9 +908,20 @@
"haikuModelPlaceholder": "",
"modelHelper": "任意: 既定で使いたい Claude モデルを指定。空欄ならシステム既定を使用します。",
"modelMappingLabel": "モデルマッピング",
"modelMappingHint": "プロバイダーが Claude モデルをネイティブ提供している場合、通常は設定不要です。リクエストを別のモデル名にマッピングする場合のみ設定してください。",
"modelMappingHint": "表示名は /model メニューだけに影響します。1M は Claude Code へのコンテキスト能力宣言です。",
"modelRoleLabel": "モデル役割",
"modelRoleSonnet": "Sonnet",
"modelRoleOpus": "Opus",
"modelRoleHaiku": "Haiku",
"modelDisplayNameLabel": "表示名",
"modelDisplayNamePlaceholder": "例: DeepSeek V4 Pro",
"requestModelLabel": "リクエストモデル",
"modelOneMHeader": "1M 対応を宣言",
"modelOneMLabel": "1M",
"fallbackModelLabel": "既定フォールバックモデル",
"fallbackModelHint": "Claude Code のリクエストが Sonnet、Opus、Haiku のいずれにも明確に対応しない場合のみ使われます。通常は空欄で構いません。",
"quickSetModels": "一括設定",
"quickSetSuccess": "モデル名をすべてのフィールドに適用しました",
"quickSetSuccess": "モデル名をすべての役割に適用しました",
"advancedOptionsToggle": "高級オプション",
"advancedOptionsHint": "API フォーマット、認証フィールド、モデルマッピングの設定を含みます。通常はデフォルトのままで問題ありません。",
"categoryOfficial": "公式",
+13 -2
View File
@@ -908,9 +908,20 @@
"haikuModelPlaceholder": "",
"modelHelper": "可选:指定默认使用的 Claude 模型,留空则使用系统默认。",
"modelMappingLabel": "模型映射",
"modelMappingHint": "如果供应商原生提供 Claude 系列模型,通常无需配置。仅在需要将请求映射到不同模型名称时填写。",
"modelMappingHint": "显示名称只影响 /model 菜单;1M 只是给 Claude Code 的上下文能力声明。",
"modelRoleLabel": "模型角色",
"modelRoleSonnet": "Sonnet",
"modelRoleOpus": "Opus",
"modelRoleHaiku": "Haiku",
"modelDisplayNameLabel": "显示名称",
"modelDisplayNamePlaceholder": "例如 DeepSeek V4 Pro",
"requestModelLabel": "实际请求模型",
"modelOneMHeader": "声明支持 1M",
"modelOneMLabel": "1M",
"fallbackModelLabel": "默认兜底模型",
"fallbackModelHint": "仅在 Claude Code 请求没有明确落到 Sonnet、Opus 或 Haiku 角色时使用;通常可以留空。",
"quickSetModels": "一键设置",
"quickSetSuccess": "已将模型名称应用到所有字段",
"quickSetSuccess": "已将模型名称应用到所有角色",
"advancedOptionsToggle": "高级选项",
"advancedOptionsHint": "包含 API 格式、认证字段、模型映射等配置。大多数场景下保持默认即可。",
"categoryOfficial": "官方",