refactor(fingerprint): 移除请求头构建路径中的 per-key 指纹定制化注入

headers.py 删除 build_browser_fingerprint_headers / build_anthropic_extra_headers
函数及相关辅助,改为直接使用固定常量;PassthroughRequestBuilder 移除
Claude 格式的指纹注入步骤;Antigravity constants 移除 per-key 指纹
覆盖逻辑,统一使用进程级固定值。
This commit is contained in:
fawney19
2026-03-05 10:24:52 +08:00
parent 1ac59d4894
commit fdb50a065b
4 changed files with 9 additions and 106 deletions

View File

@@ -14,8 +14,6 @@ import uuid
# ============== API 端点 ==============
# 唯一定义在 core 层,此处 re-export 保持向后兼容
from src.core.provider_templates.fixed_providers import ANTIGRAVITY_PROD_URL as PROD_BASE_URL
from src.services.provider.fingerprint import resolve_platform_token
from src.services.provider.request_context import get_current_fingerprint
DAILY_BASE_URL = "https://daily-cloudcode-pa.googleapis.com"
SANDBOX_BASE_URL = "https://daily-cloudcode-pa.sandbox.googleapis.com"
@@ -114,43 +112,17 @@ URL_UNAVAILABLE_TTL_SECONDS = 300 # 5 分钟
_SESSION_ID = uuid.uuid4().hex # 每次进程启动生成一个固定 session ID
def _normalize_node_version(raw: str | None) -> str:
text = str(raw or "").strip()
if text.startswith(("v", "V")):
text = text[1:]
return text or "18.18.2"
def get_v1internal_extra_headers() -> dict[str, str]:
"""构建 v1internal 请求需要的额外 header对齐 AM upstream/client.rs"""
fp = get_current_fingerprint()
with _ua_lock:
version = _ua_version
user_agent = get_http_user_agent()
session_id = _SESSION_ID
node_version = "18.18.2"
if fp:
user_agent = _build_antigravity_http_user_agent(
platform_token=resolve_platform_token(
platform_info=fp.platform_info,
stainless_os=fp.stainless_os,
stainless_arch=fp.stainless_arch,
),
version=version,
chrome_version=fp.chrome_version or _FALLBACK_CHROME,
electron_version=fp.electron_version or _FALLBACK_ELECTRON,
)
session_id = fp.vscode_session_id or _SESSION_ID
node_version = _normalize_node_version(fp.node_version)
return {
"User-Agent": user_agent,
"User-Agent": get_http_user_agent(),
"x-client-name": "antigravity",
"x-client-version": version,
"x-vscode-sessionid": session_id,
"x-goog-api-client": f"gl-node/{node_version} fire/0.8.6 grpc/1.10.x",
"x-vscode-sessionid": _SESSION_ID,
"x-goog-api-client": "gl-node/18.18.2 fire/0.8.6 grpc/1.10.x",
}