From e8ee7b4ecfaeddf6804b9e7aeeb2916a4e2ee4b6 Mon Sep 17 00:00:00 2001 From: dalamudx Date: Tue, 29 Sep 2026 18:47:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(claude-code):=20=E5=8D=87=E7=BA=A7=E4=BC=AA?= =?UTF-8?q?=E8=A3=85=E7=9A=84=20Claude=20Code=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B0=202.1.284?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上游按模型校验 Claude Code 最低版本,claude-opus-5-5 要求 >= 2.1.280, 而 profile 里写死的 2.1.161 会被拒绝(claude_code_version_too_old, 400), 且 Aether 会统一改写 UA,真实 Claude Code 客户端也会受影响。 将 cli_version 升级为 2.1.284,并同步 stainless 包版本 (0.112.1) 与 node 运行时版本 (v26.3.0),保持指纹一致;相关测试断言同步更新。 --- .../src/tests/ai_execute/stream_provider.rs | 2 +- .../tests/ai_execute/sync/claude/claude_code.rs | 4 ++-- .../transport/src/claude_code/fingerprint.rs | 16 ++++++++-------- .../transport/src/claude_code/mimicry.rs | 14 +++++++------- .../transport/src/claude_code/profile.rs | 12 ++++++------ .../transport/src/claude_code/request.rs | 8 ++++---- .../transport/src/same_format_provider/mod.rs | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/apps/aether-gateway/src/tests/ai_execute/stream_provider.rs b/apps/aether-gateway/src/tests/ai_execute/stream_provider.rs index 3f5963bc1..27c72990b 100644 --- a/apps/aether-gateway/src/tests/ai_execute/stream_provider.rs +++ b/apps/aether-gateway/src/tests/ai_execute/stream_provider.rs @@ -1585,7 +1585,7 @@ async fn gateway_executes_claude_code_cli_stream_via_local_decision_gate_with_lo ); assert_eq!( seen_execution_runtime_request.user_agent, - "claude-cli/2.1.161 (external, cli)" + "claude-cli/2.1.284 (external, cli)" ); assert_eq!( seen_execution_runtime_request.endpoint_tag, diff --git a/apps/aether-gateway/src/tests/ai_execute/sync/claude/claude_code.rs b/apps/aether-gateway/src/tests/ai_execute/sync/claude/claude_code.rs index 4665f0b51..cf62688b4 100644 --- a/apps/aether-gateway/src/tests/ai_execute/sync/claude/claude_code.rs +++ b/apps/aether-gateway/src/tests/ai_execute/sync/claude/claude_code.rs @@ -567,11 +567,11 @@ async fn gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_loca assert_eq!(seen_execution_runtime_request.x_stainless_helper_method, ""); assert_eq!( seen_execution_runtime_request.x_stainless_package_version, - "0.94.0" + "0.112.1" ); assert_eq!( seen_execution_runtime_request.user_agent, - "claude-cli/2.1.161 (external, cli)" + "claude-cli/2.1.284 (external, cli)" ); assert_eq!( seen_execution_runtime_request.endpoint_tag, diff --git a/crates/aether-provider/transport/src/claude_code/fingerprint.rs b/crates/aether-provider/transport/src/claude_code/fingerprint.rs index c72e58e93..6796cdb9d 100644 --- a/crates/aether-provider/transport/src/claude_code/fingerprint.rs +++ b/crates/aether-provider/transport/src/claude_code/fingerprint.rs @@ -117,11 +117,11 @@ mod tests { let map = header_fingerprint_from_fingerprint(&fp).expect("header fingerprint"); assert_eq!(map["identity_profile_version"], "2026-04"); - assert_eq!(map["cli_version"], "2.1.161"); - assert_eq!(map["billing_cli_version"], "2.1.161"); - assert_eq!(map["stainless_package_version"], "0.94.0"); - assert_eq!(map["stainless_runtime_version"], "v24.3.0"); - assert_eq!(map["user_agent"], "claude-cli/2.1.161 (external, cli)"); + assert_eq!(map["cli_version"], "2.1.284"); + assert_eq!(map["billing_cli_version"], "2.1.284"); + assert_eq!(map["stainless_package_version"], "0.112.1"); + assert_eq!(map["stainless_runtime_version"], "v26.3.0"); + assert_eq!(map["user_agent"], "claude-cli/2.1.284 (external, cli)"); assert_eq!( fp["transport_profile"]["extra"]["claude_code_identity_profile_version"], "2026-04" @@ -144,9 +144,9 @@ mod tests { let sanitized = sanitize_fingerprint(&raw, "test-key"); let map = header_fingerprint_from_fingerprint(&sanitized).expect("header fingerprint"); - assert_eq!(map["stainless_package_version"], "0.94.0"); - assert_eq!(map["stainless_runtime_version"], "v24.3.0"); - assert_eq!(map["user_agent"], "claude-cli/2.1.161 (external, cli)"); + assert_eq!(map["stainless_package_version"], "0.112.1"); + assert_eq!(map["stainless_runtime_version"], "v26.3.0"); + assert_eq!(map["user_agent"], "claude-cli/2.1.284 (external, cli)"); assert_eq!(map["vscode_session_id"], "existing-session"); } diff --git a/crates/aether-provider/transport/src/claude_code/mimicry.rs b/crates/aether-provider/transport/src/claude_code/mimicry.rs index 0c24cf0eb..4ead9b97a 100644 --- a/crates/aether-provider/transport/src/claude_code/mimicry.rs +++ b/crates/aether-provider/transport/src/claude_code/mimicry.rs @@ -479,7 +479,7 @@ mod tests { let system = body["system"].as_array().unwrap(); assert_eq!(system.len(), 3); let billing = system[0]["text"].as_str().unwrap(); - assert!(billing.starts_with("x-anthropic-billing-header: cc_version=2.1.161.")); + assert!(billing.starts_with("x-anthropic-billing-header: cc_version=2.1.284.")); assert!(billing.ends_with("; cc_entrypoint=cli;")); assert!(system[0].get("cache_control").is_none()); assert_eq!(system[1]["text"], CLAUDE_CODE_SYSTEM_PROMPT); @@ -505,22 +505,22 @@ mod tests { fn fingerprint_uses_original_first_user_text_not_migrated_instructions() { let mut body = pi_body(); apply_claude_code_body_mimicry(&mut body, CONTEXT); - let expected = claude_code_fingerprint("hello world, please help", "2.1.161"); + let expected = claude_code_fingerprint("hello world, please help", "2.1.284"); assert!(body["system"][0]["text"] .as_str() .unwrap() - .contains(&format!("cc_version=2.1.161.{expected};"))); + .contains(&format!("cc_version=2.1.284.{expected};"))); } #[test] fn fingerprint_is_three_hex_chars_and_pads_short_text_with_zero() { - let fp = claude_code_fingerprint("", "2.1.161"); + let fp = claude_code_fingerprint("", "2.1.284"); assert_eq!(fp.len(), 3); assert!(fp.chars().all(|c| c.is_ascii_hexdigit())); - assert_eq!(fp, claude_code_fingerprint("abc", "2.1.161")); + assert_eq!(fp, claude_code_fingerprint("abc", "2.1.284")); assert_ne!( - claude_code_fingerprint("0123456789012345678901234", "2.1.161"), - claude_code_fingerprint("", "2.1.161") + claude_code_fingerprint("0123456789012345678901234", "2.1.284"), + claude_code_fingerprint("", "2.1.284") ); } diff --git a/crates/aether-provider/transport/src/claude_code/profile.rs b/crates/aether-provider/transport/src/claude_code/profile.rs index 45d15d340..8778ea8a2 100644 --- a/crates/aether-provider/transport/src/claude_code/profile.rs +++ b/crates/aether-provider/transport/src/claude_code/profile.rs @@ -82,13 +82,13 @@ pub const CLAUDE_CODE_TRANSPORT_IDENTITY_2026_04: ClaudeCodeTransportIdentityPro version: ClaudeCodeTransportIdentityProfileVersion::V2026_04, transport_profile_id: "claude_code_nodejs", anthropic_version: "2023-06-01", - cli_version: "2.1.161", + cli_version: "2.1.284", stainless_lang: "js", - stainless_package_version: "0.94.0", + stainless_package_version: "0.112.1", stainless_os: "Linux", stainless_arch: "arm64", stainless_runtime: "node", - stainless_runtime_version: "v24.3.0", + stainless_runtime_version: "v26.3.0", stainless_retry_count: "0", stainless_timeout: "600", message_required_betas: MESSAGE_BETAS_2026_04, @@ -286,14 +286,14 @@ mod tests { let profile = *current_claude_code_transport_identity_profile(); assert_eq!(profile.version().as_str(), "2026-04"); - assert_eq!(profile.cli_version(), "2.1.161"); + assert_eq!(profile.cli_version(), "2.1.284"); assert_eq!(profile.billing_cli_version(), profile.cli_version()); assert_eq!( profile.user_agent(), format!("claude-cli/{} (external, cli)", profile.cli_version()) ); - assert_eq!(profile.stainless_package_version(), "0.94.0"); - assert_eq!(profile.stainless_runtime_version(), "v24.3.0"); + assert_eq!(profile.stainless_package_version(), "0.112.1"); + assert_eq!(profile.stainless_runtime_version(), "v26.3.0"); } #[test] diff --git a/crates/aether-provider/transport/src/claude_code/request.rs b/crates/aether-provider/transport/src/claude_code/request.rs index 8e07352c7..8e2e15c6d 100644 --- a/crates/aether-provider/transport/src/claude_code/request.rs +++ b/crates/aether-provider/transport/src/claude_code/request.rs @@ -252,11 +252,11 @@ mod tests { assert_eq!(built.get("x-app").map(String::as_str), Some("cli")); assert_eq!( built.get("x-stainless-package-version").map(String::as_str), - Some("0.94.0") + Some("0.112.1") ); assert_eq!( built.get("x-stainless-runtime-version").map(String::as_str), - Some("v24.3.0") + Some("v26.3.0") ); assert_eq!( built.get("x-stainless-timeout").map(String::as_str), @@ -264,7 +264,7 @@ mod tests { ); assert_eq!( built.get("user-agent").map(String::as_str), - Some("claude-cli/2.1.161 (external, cli)") + Some("claude-cli/2.1.284 (external, cli)") ); assert_eq!( built.get("authorization").map(String::as_str), @@ -367,7 +367,7 @@ mod tests { assert_eq!( body["system"][0]["text"], - "x-anthropic-billing-header: cc_version=2.1.161.abc; cc_entrypoint=cli;" + "x-anthropic-billing-header: cc_version=2.1.284.abc; cc_entrypoint=cli;" ); } } diff --git a/crates/aether-provider/transport/src/same_format_provider/mod.rs b/crates/aether-provider/transport/src/same_format_provider/mod.rs index d84b3d519..3f3fa6358 100644 --- a/crates/aether-provider/transport/src/same_format_provider/mod.rs +++ b/crates/aether-provider/transport/src/same_format_provider/mod.rs @@ -1189,7 +1189,7 @@ mod tests { ); assert_eq!( build_body(compat_behavior)["system"][0]["text"], - "x-anthropic-billing-header: cc_version=2.1.161.abc; cc_entrypoint=cli;" + "x-anthropic-billing-header: cc_version=2.1.284.abc; cc_entrypoint=cli;" ); let mut legacy = sample_transport("claude_code");