feat: Antigravity 和 Codex 服务支持

- 新增 Antigravity 服务:签名缓存、URL 可用性检测、信封处理
- 新增 Codex 服务:信封处理、元数据收集器
- 重构 provider transport 支持新的服务架构
- 新增 stream_bridge 和 upstream_stream_bridge 处理流式响应
- 优化 OAuth 工具函数
- 添加相关测试用例
This commit is contained in:
fawney19
2026-02-05 15:57:52 +08:00
parent ed2ff5c1d7
commit 440721368f
44 changed files with 3498 additions and 134 deletions

View File

@@ -0,0 +1,38 @@
from __future__ import annotations
from unittest.mock import AsyncMock, patch
import pytest
from src.core.provider_oauth_utils import enrich_auth_config
@pytest.mark.asyncio
async def test_enrich_auth_config_antigravity_adds_project_id_and_email() -> None:
auth_config: dict[str, object] = {}
token_response: dict[str, object] = {}
with (
patch("src.core.provider_oauth_utils.fetch_google_email", AsyncMock(return_value="u@example.com")),
patch(
"src.services.antigravity.client.load_code_assist",
AsyncMock(
return_value={
"cloudaicompanionProject": "project-1",
"currentTier": {"tierType": "PAID"},
}
),
),
):
out = await enrich_auth_config(
provider_type="antigravity",
auth_config=auth_config, # in-place
token_response=token_response,
access_token="tok",
proxy_config=None,
)
assert out["email"] == "u@example.com"
assert out["project_id"] == "project-1"
assert out["tier"] == "PAID"