feat: add multi-provider OAuth support for Claude and Gemini CLI

This commit is contained in:
ciat-777
2026-03-17 13:36:44 +08:00
parent 4e3dc92083
commit d8e44eb805
53 changed files with 3618 additions and 719 deletions
+5 -1
View File
@@ -1,7 +1,11 @@
import { BasePlatformAdapter, type BalanceInfo, type CheckinResult, type UserInfo } from './base.js';
function normalizeBaseUrl(baseUrl: string): string {
return (baseUrl || '').replace(/\/+$/, '');
let normalized = (baseUrl || '').trim();
while (normalized.endsWith('/')) {
normalized = normalized.slice(0, -1);
}
return normalized;
}
export class CodexAdapter extends BasePlatformAdapter {
+1 -1
View File
@@ -42,7 +42,7 @@ function resolveGeminiNativeModelsUrl(baseUrl: string, apiToken: string): string
}
export class GeminiAdapter extends BasePlatformAdapter {
readonly platformName = 'gemini';
readonly platformName: string = 'gemini';
async detect(url: string): Promise<boolean> {
const normalized = (url || '').toLowerCase();
@@ -0,0 +1,10 @@
import { GeminiAdapter } from './gemini.js';
export class GeminiCliAdapter extends GeminiAdapter {
override readonly platformName = 'gemini-cli';
override async detect(url: string): Promise<boolean> {
const normalized = (url || '').toLowerCase();
return normalized.includes('cloudcode-pa.googleapis.com');
}
}
+4
View File
@@ -10,6 +10,7 @@ import { OpenAiAdapter } from './openai.js';
import { CodexAdapter } from './codex.js';
import { ClaudeAdapter } from './claude.js';
import { GeminiAdapter } from './gemini.js';
import { GeminiCliAdapter } from './geminiCli.js';
import { CliProxyApiAdapter } from './cliproxyapi.js';
import { detectPlatformByTitle } from './titleHint.js';
@@ -19,6 +20,7 @@ const adapters: PlatformAdapter[] = [
new CodexAdapter(),
new ClaudeAdapter(),
new GeminiAdapter(),
new GeminiCliAdapter(),
new CliProxyApiAdapter(),
new AnyRouterAdapter(),
new DoneHubAdapter(),
@@ -57,6 +59,7 @@ const platformAliases: Record<string, string> = {
anthropic: 'claude',
claude: 'claude',
gemini: 'gemini',
'gemini-cli': 'gemini-cli',
google: 'gemini',
// CLIProxyAPI aliases
cliproxyapi: 'cliproxyapi',
@@ -97,6 +100,7 @@ function detectPlatformByUrlHint(url: string): string | undefined {
) {
return 'gemini';
}
if (normalized.includes('cloudcode-pa.googleapis.com')) return 'gemini-cli';
// NewAPI-family forks and common aliases.
if (normalized.includes('anyrouter')) return 'anyrouter';