Files
CC-Switch/src/config/userAgentPresets.ts
T
Jason 596019505f feat(provider-form): custom User-Agent presets dropdown in advanced settings
Polish the provider-level User-Agent override UI on the Claude and Codex forms.

- Add a shared CustomUserAgentField (label + input + preset dropdown + live
  validation) so both forms stay in sync.
- Provide curated UA presets (Claude Code / Kilo Code families that pass
  coding-plan UA whitelists per #3671); the first is Claude Code's real
  `claude-cli/x (external, cli)` format. Whitelists gate on the name prefix,
  not the version, so static values stay valid across upgrades.
- Expose presets via a dropdown to the right of the input (z-[200] so it
  renders above the dialog layers) instead of inline chips.
- Move the field into the existing advanced/reasoning collapsibles.
- userAgent.ts mirrors the backend byte rule (reject only control chars;
  non-ASCII is allowed) for a non-blocking inline hint.
- i18n for all four locales (zh/en/ja/zh-TW).
2026-06-11 08:29:29 +08:00

21 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 自定义 User-Agent 预设。
*
* 取值来自 PR #3671 对 Kimi Coding Planapi.kimi.com/codingUA 白名单的 curl 实测:
* `claude-cli/*`、`claude-code/*`、`Kilo-Code/*` 可通过;`codex-cli`、`kimi-cli` 会被 403。
* 白名单只校验 UA 名称前缀、不看版本号,因此用静态值即可,版本不会因 Claude Code 升级而失效。
*
* 第一条是官方 Claude Code CLI 实际发送的完整格式(参见 `stream_check.rs` 里检测用的
* `claude-cli/2.1.2 (external, cli)`),最贴近真实客户端、最稳过严格的 UA 校验;其余为简短变体。
*
* 这些预设主要用于"非白名单 Coding AgentCodex/Gemini/Hermes/OpenClaw 等)想接入受 UA
* 限制的上游"的场景——把转发请求伪装成已在白名单内的客户端。是否使用由用户显式选择。
*/
export const USER_AGENT_PRESETS: readonly string[] = [
"claude-cli/2.1.161 (external, cli)",
"claude-cli/2.1.161",
"claude-code/1.0.0",
"claude-code/0.1.0",
"Kilo-Code/1.0",
];