feat(gemini): add Gemini provider integration (#202)

* feat(gemini): add Gemini provider integration

- Add gemini_config.rs module for .env file parsing
- Extend AppType enum to support Gemini
- Implement GeminiConfigEditor and GeminiFormFields components
- Add GeminiIcon with standardized 1024x1024 viewBox
- Add Gemini provider presets configuration
- Update i18n translations for Gemini support
- Extend ProviderService and McpService for Gemini

* fix(gemini): resolve TypeScript errors, add i18n support, and fix MCP logic

**Critical Fixes:**
- Fix TS2741 errors in tests/msw/state.ts by adding missing Gemini type definitions
- Fix ProviderCard.extractApiUrl to support GOOGLE_GEMINI_BASE_URL display
- Add missing apps.gemini i18n keys (zh/en) for proper app name display
- Fix MCP service Gemini cross-app duplication logic to prevent self-copy

**Technical Details:**
- tests/msw/state.ts: Add gemini default providers, current ID, and MCP config
- ProviderCard.tsx: Check both ANTHROPIC_BASE_URL and GOOGLE_GEMINI_BASE_URL
- services/mcp.rs: Skip Gemini in sync_other_side logic with unreachable!() guards
- Run pnpm format to auto-fix code style issues

**Verification:**
-  pnpm typecheck passes
-  pnpm format completed

* feat(gemini): enhance authentication and config parsing

- Add strict and lenient .env parsing modes
- Implement PackyCode partner authentication detection
- Support Google OAuth official authentication
- Auto-configure security.auth.selectedType for PackyCode
- Add comprehensive test coverage for all auth types
- Update i18n for OAuth hints and Gemini config

---------

Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
YoVinchen
2025-11-12 10:47:34 +08:00
committed by GitHub
parent 32a2ba5ef6
commit 8a05e7bd3d
46 changed files with 2522 additions and 276 deletions
+7 -1
View File
@@ -54,7 +54,8 @@ impl McpService {
// 修复:sync_other_side=true 时,先将 MCP 复制到另一侧,然后强制同步
// 这才是"同步到另一侧"的正确语义:将 MCP 跨应用复制
if sync_other_side {
if sync_other_side && app != AppType::Gemini {
// Gemini 暂不支持跨应用复制,直接跳过
// 获取当前 MCP 条目的克隆(刚刚插入的,不可能失败)
let current_entry = cfg
.mcp_for(&app)
@@ -67,6 +68,7 @@ impl McpService {
let other_app = match app {
AppType::Claude => AppType::Codex,
AppType::Codex => AppType::Claude,
AppType::Gemini => unreachable!("Gemini 已在外层 if 中跳过"),
};
cfg.mcp_for_mut(&other_app)
@@ -77,6 +79,7 @@ impl McpService {
match app {
AppType::Claude => sync_codex = true,
AppType::Codex => sync_claude = true,
AppType::Gemini => unreachable!("Gemini 已在外层 if 中跳过"),
}
}
@@ -118,6 +121,7 @@ impl McpService {
match app {
AppType::Claude => mcp::sync_enabled_to_claude(&snapshot)?,
AppType::Codex => mcp::sync_enabled_to_codex(&snapshot)?,
AppType::Gemini => {}, // Gemini 暂不支持 MCP 同步
}
}
}
@@ -144,6 +148,7 @@ impl McpService {
match app {
AppType::Claude => mcp::sync_enabled_to_claude(&snapshot)?,
AppType::Codex => mcp::sync_enabled_to_codex(&snapshot)?,
AppType::Gemini => {}, // Gemini 暂不支持 MCP 同步
}
}
}
@@ -163,6 +168,7 @@ impl McpService {
match app {
AppType::Claude => mcp::sync_enabled_to_claude(&snapshot)?,
AppType::Codex => mcp::sync_enabled_to_codex(&snapshot)?,
AppType::Gemini => {}, // Gemini 暂不支持 MCP 同步
}
Ok(())
}