mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 18:59:50 +08:00
feat(claude-code): 增加动态 CLI 客户端画像并按官方发布刷新版本
- 将 Claude Code 传输身份拆分为带版本的静态模板(Stainless/运行时/beta 策略)与动态 CLI 画像(cli_version / User-Agent),请求按快照读取保证 UA 与 billing cc_version 一致 - 将 codex_profile 泛化为 cli_client_profile,Codex 与 Claude Code 共享发布校验、缓存恢复、防回退与每日刷新逻辑 - Claude Code 跟随 npm latest,要求 8 个平台包版本与主包一致;支持 AETHER_CLAUDE_CODE_CLIENT_PROFILE_REFRESH 与 AETHER_CLAUDE_CODE_CLIENT_VERSION - 新增定时任务 maintenance.claude_code.client.profile,启动时与 Codex 画像并发预热 - 额度查询 User-Agent 改用动态画像,移除硬编码 CLAUDE_CODE_USAGE_USER_AGENT
This commit is contained in:
@@ -49,7 +49,7 @@ pub fn build_claude_code_passthrough_headers(
|
||||
out.insert("anthropic-beta".to_string(), incoming_beta_values.join(","));
|
||||
}
|
||||
|
||||
let profile = *current_claude_code_transport_identity_profile();
|
||||
let profile = current_claude_code_transport_identity_profile();
|
||||
profile.apply_fixed_headers(&mut out, stream);
|
||||
profile.apply_beta_policy(&mut out, None);
|
||||
|
||||
@@ -57,15 +57,15 @@ pub fn build_claude_code_passthrough_headers(
|
||||
}
|
||||
|
||||
pub fn sanitize_claude_code_request_body(body: &mut Value) {
|
||||
let profile = *current_claude_code_transport_identity_profile();
|
||||
let profile = current_claude_code_transport_identity_profile();
|
||||
let beta_header = profile.merge_beta_tokens(None, None);
|
||||
sanitize_claude_code_request_body_for_beta_header(body, &beta_header, profile);
|
||||
sanitize_claude_code_request_body_for_beta_header(body, &beta_header, &profile);
|
||||
}
|
||||
|
||||
pub fn sanitize_claude_code_request_body_for_beta_header(
|
||||
body: &mut Value,
|
||||
beta_header: &str,
|
||||
profile: ClaudeCodeTransportIdentityProfile,
|
||||
profile: &ClaudeCodeTransportIdentityProfile,
|
||||
) {
|
||||
let Some(body_object) = body.as_object_mut() else {
|
||||
return;
|
||||
@@ -303,7 +303,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn context_management_body_is_gated_by_the_matching_beta_token() {
|
||||
let profile = *current_claude_code_transport_identity_profile();
|
||||
let profile = current_claude_code_transport_identity_profile();
|
||||
let original = json!({
|
||||
"context_management": {
|
||||
"edits": [{"type":"clear_thinking_20251015", "keep":"all"}]
|
||||
@@ -315,7 +315,7 @@ mod tests {
|
||||
sanitize_claude_code_request_body_for_beta_header(
|
||||
&mut without_beta,
|
||||
"oauth-2025-04-20",
|
||||
profile,
|
||||
&profile,
|
||||
);
|
||||
assert!(without_beta.get("context_management").is_none());
|
||||
|
||||
@@ -323,7 +323,7 @@ mod tests {
|
||||
sanitize_claude_code_request_body_for_beta_header(
|
||||
&mut with_beta,
|
||||
"oauth-2025-04-20, context-management-2025-06-27",
|
||||
profile,
|
||||
&profile,
|
||||
);
|
||||
assert_eq!(with_beta, original);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user