mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-03 02:31:51 +08:00
feat: anthropic SDK header matching + request profile
This commit is contained in:
@@ -13,6 +13,7 @@ pub const DEFAULT_ANTHROPIC_VERSION: &str = "2023-06-01";
|
||||
pub const DEFAULT_APP_NAME: &str = "claude-code";
|
||||
pub const DEFAULT_RUNTIME: &str = "rust";
|
||||
pub const DEFAULT_AGENTIC_BETA: &str = "claude-code-20250219";
|
||||
pub const DEFAULT_PROMPT_CACHING_SCOPE_BETA: &str = "prompt-caching-scope-2026-01-05";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ClientIdentity {
|
||||
@@ -65,7 +66,10 @@ impl AnthropicRequestProfile {
|
||||
Self {
|
||||
anthropic_version: DEFAULT_ANTHROPIC_VERSION.to_string(),
|
||||
client_identity,
|
||||
betas: vec![DEFAULT_AGENTIC_BETA.to_string()],
|
||||
betas: vec![
|
||||
DEFAULT_AGENTIC_BETA.to_string(),
|
||||
DEFAULT_PROMPT_CACHING_SCOPE_BETA.to_string(),
|
||||
],
|
||||
extra_body: Map::new(),
|
||||
}
|
||||
}
|
||||
@@ -445,7 +449,8 @@ mod tests {
|
||||
("user-agent".to_string(), "claude-code/1.2.3".to_string()),
|
||||
(
|
||||
"anthropic-beta".to_string(),
|
||||
"claude-code-20250219,tools-2026-04-01".to_string(),
|
||||
"claude-code-20250219,prompt-caching-scope-2026-01-05,tools-2026-04-01"
|
||||
.to_string(),
|
||||
),
|
||||
]
|
||||
);
|
||||
@@ -459,7 +464,11 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
body["betas"],
|
||||
serde_json::json!(["claude-code-20250219", "tools-2026-04-01"])
|
||||
serde_json::json!([
|
||||
"claude-code-20250219",
|
||||
"prompt-caching-scope-2026-01-05",
|
||||
"tools-2026-04-01"
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user