Rename AuthType LOGIN_WITH_GOOGLE_PERSONAL -> LOGIN_WITH_GOOGLE (#2769)
This commit is contained in:
parent
0ca5c07135
commit
3587054d32
|
@ -9,7 +9,7 @@ import { loadEnvironment } from './config.js';
|
||||||
|
|
||||||
export const validateAuthMethod = (authMethod: string): string | null => {
|
export const validateAuthMethod = (authMethod: string): string | null => {
|
||||||
loadEnvironment();
|
loadEnvironment();
|
||||||
if (authMethod === AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (authMethod === AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,7 @@ export function AuthDialog({
|
||||||
initialErrorMessage || null,
|
initialErrorMessage || null,
|
||||||
);
|
);
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{ label: 'Login with Google', value: AuthType.LOGIN_WITH_GOOGLE },
|
||||||
label: 'Login with Google',
|
|
||||||
value: AuthType.LOGIN_WITH_GOOGLE_PERSONAL,
|
|
||||||
},
|
|
||||||
{ label: 'Gemini API Key (AI Studio)', value: AuthType.USE_GEMINI },
|
{ label: 'Gemini API Key (AI Studio)', value: AuthType.USE_GEMINI },
|
||||||
{ label: 'Vertex AI', value: AuthType.USE_VERTEX_AI },
|
{ label: 'Vertex AI', value: AuthType.USE_VERTEX_AI },
|
||||||
];
|
];
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ describe('useGeminiStream', () => {
|
||||||
it('should call parseAndFormatApiError with the correct authType on stream initialization failure', async () => {
|
it('should call parseAndFormatApiError with the correct authType on stream initialization failure', async () => {
|
||||||
// 1. Setup
|
// 1. Setup
|
||||||
const mockError = new Error('Rate limit exceeded');
|
const mockError = new Error('Rate limit exceeded');
|
||||||
const mockAuthType = AuthType.LOGIN_WITH_GOOGLE_PERSONAL;
|
const mockAuthType = AuthType.LOGIN_WITH_GOOGLE;
|
||||||
mockParseAndFormatApiError.mockClear();
|
mockParseAndFormatApiError.mockClear();
|
||||||
mockSendMessageStream.mockReturnValue(
|
mockSendMessageStream.mockReturnValue(
|
||||||
(async function* () {
|
(async function* () {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const PrivacyNoticeText = ({
|
||||||
return <GeminiPrivacyNotice onExit={onExit} />;
|
return <GeminiPrivacyNotice onExit={onExit} />;
|
||||||
case AuthType.USE_VERTEX_AI:
|
case AuthType.USE_VERTEX_AI:
|
||||||
return <CloudPaidPrivacyNotice onExit={onExit} />;
|
return <CloudPaidPrivacyNotice onExit={onExit} />;
|
||||||
case AuthType.LOGIN_WITH_GOOGLE_PERSONAL:
|
case AuthType.LOGIN_WITH_GOOGLE:
|
||||||
default:
|
default:
|
||||||
return <CloudFreePrivacyNotice config={config} onExit={onExit} />;
|
return <CloudFreePrivacyNotice config={config} onExit={onExit} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe('parseAndFormatApiError', () => {
|
||||||
'got status: 429 Too Many Requests. {"error":{"code":429,"message":"Rate limit exceeded","status":"RESOURCE_EXHAUSTED"}}';
|
'got status: 429 Too Many Requests. {"error":{"code":429,"message":"Rate limit exceeded","status":"RESOURCE_EXHAUSTED"}}';
|
||||||
const result = parseAndFormatApiError(
|
const result = parseAndFormatApiError(
|
||||||
errorMessage,
|
errorMessage,
|
||||||
AuthType.LOGIN_WITH_GOOGLE_PERSONAL,
|
AuthType.LOGIN_WITH_GOOGLE,
|
||||||
);
|
);
|
||||||
expect(result).toContain('[API Error: Rate limit exceeded');
|
expect(result).toContain('[API Error: Rate limit exceeded');
|
||||||
expect(result).toContain(enterpriseMessage);
|
expect(result).toContain(enterpriseMessage);
|
||||||
|
|
|
@ -45,7 +45,7 @@ function isStructuredError(error: unknown): error is StructuredError {
|
||||||
|
|
||||||
function getRateLimitMessage(authType?: AuthType): string {
|
function getRateLimitMessage(authType?: AuthType): string {
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case AuthType.LOGIN_WITH_GOOGLE_PERSONAL:
|
case AuthType.LOGIN_WITH_GOOGLE:
|
||||||
return RATE_LIMIT_ERROR_MESSAGE_GOOGLE;
|
return RATE_LIMIT_ERROR_MESSAGE_GOOGLE;
|
||||||
case AuthType.USE_GEMINI:
|
case AuthType.USE_GEMINI:
|
||||||
return RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI;
|
return RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI;
|
||||||
|
|
|
@ -13,7 +13,7 @@ export async function createCodeAssistContentGenerator(
|
||||||
httpOptions: HttpOptions,
|
httpOptions: HttpOptions,
|
||||||
authType: AuthType,
|
authType: AuthType,
|
||||||
): Promise<ContentGenerator> {
|
): Promise<ContentGenerator> {
|
||||||
if (authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
const authClient = await getOauthClient();
|
const authClient = await getOauthClient();
|
||||||
const projectId = await setupUser(authClient);
|
const projectId = await setupUser(authClient);
|
||||||
return new CodeAssistServer(authClient, projectId, httpOptions);
|
return new CodeAssistServer(authClient, projectId, httpOptions);
|
||||||
|
|
|
@ -491,7 +491,7 @@ export class GeminiClient {
|
||||||
*/
|
*/
|
||||||
private async handleFlashFallback(authType?: string): Promise<string | null> {
|
private async handleFlashFallback(authType?: string): Promise<string | null> {
|
||||||
// Only handle fallback for OAuth users
|
// Only handle fallback for OAuth users
|
||||||
if (authType !== AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (authType !== AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('contentGenerator', () => {
|
||||||
);
|
);
|
||||||
const generator = await createContentGenerator({
|
const generator = await createContentGenerator({
|
||||||
model: 'test-model',
|
model: 'test-model',
|
||||||
authType: AuthType.LOGIN_WITH_GOOGLE_PERSONAL,
|
authType: AuthType.LOGIN_WITH_GOOGLE,
|
||||||
});
|
});
|
||||||
expect(createCodeAssistContentGenerator).toHaveBeenCalled();
|
expect(createCodeAssistContentGenerator).toHaveBeenCalled();
|
||||||
expect(generator).toBe(mockGenerator);
|
expect(generator).toBe(mockGenerator);
|
||||||
|
|
|
@ -35,7 +35,7 @@ export interface ContentGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AuthType {
|
export enum AuthType {
|
||||||
LOGIN_WITH_GOOGLE_PERSONAL = 'oauth-personal',
|
LOGIN_WITH_GOOGLE = 'oauth-personal',
|
||||||
USE_GEMINI = 'gemini-api-key',
|
USE_GEMINI = 'gemini-api-key',
|
||||||
USE_VERTEX_AI = 'vertex-ai',
|
USE_VERTEX_AI = 'vertex-ai',
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ export async function createContentGeneratorConfig(
|
||||||
};
|
};
|
||||||
|
|
||||||
// if we are using google auth nothing else to validate for now
|
// if we are using google auth nothing else to validate for now
|
||||||
if (authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
return contentGeneratorConfig;
|
return contentGeneratorConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ export async function createContentGenerator(
|
||||||
'User-Agent': `GeminiCLI/${version} (${process.platform}; ${process.arch})`,
|
'User-Agent': `GeminiCLI/${version} (${process.platform}; ${process.arch})`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (config.authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (config.authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
return createCodeAssistContentGenerator(httpOptions, config.authType);
|
return createCodeAssistContentGenerator(httpOptions, config.authType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ export class GeminiChat {
|
||||||
*/
|
*/
|
||||||
private async handleFlashFallback(authType?: string): Promise<string | null> {
|
private async handleFlashFallback(authType?: string): Promise<string | null> {
|
||||||
// Only handle fallback for OAuth users
|
// Only handle fallback for OAuth users
|
||||||
if (authType !== AuthType.LOGIN_WITH_GOOGLE_PERSONAL) {
|
if (authType !== AuthType.LOGIN_WITH_GOOGLE) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,14 +78,14 @@ describe('Flash Fallback Integration', () => {
|
||||||
return status === 429;
|
return status === 429;
|
||||||
},
|
},
|
||||||
onPersistent429: mockFallbackHandler,
|
onPersistent429: mockFallbackHandler,
|
||||||
authType: AuthType.LOGIN_WITH_GOOGLE_PERSONAL,
|
authType: AuthType.LOGIN_WITH_GOOGLE,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verify fallback was triggered
|
// Verify fallback was triggered
|
||||||
expect(fallbackCalled).toBe(true);
|
expect(fallbackCalled).toBe(true);
|
||||||
expect(fallbackModel).toBe(DEFAULT_GEMINI_FLASH_MODEL);
|
expect(fallbackModel).toBe(DEFAULT_GEMINI_FLASH_MODEL);
|
||||||
expect(mockFallbackHandler).toHaveBeenCalledWith(
|
expect(mockFallbackHandler).toHaveBeenCalledWith(
|
||||||
AuthType.LOGIN_WITH_GOOGLE_PERSONAL,
|
AuthType.LOGIN_WITH_GOOGLE,
|
||||||
);
|
);
|
||||||
expect(result).toBe('success after fallback');
|
expect(result).toBe('success after fallback');
|
||||||
// Should have: 2 failures, then fallback triggered, then 1 success after retry reset
|
// Should have: 2 failures, then fallback triggered, then 1 success after retry reset
|
||||||
|
|
|
@ -97,7 +97,7 @@ export async function retryWithBackoff<T>(
|
||||||
if (
|
if (
|
||||||
consecutive429Count >= 2 &&
|
consecutive429Count >= 2 &&
|
||||||
onPersistent429 &&
|
onPersistent429 &&
|
||||||
authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL
|
authType === AuthType.LOGIN_WITH_GOOGLE
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const fallbackModel = await onPersistent429(authType);
|
const fallbackModel = await onPersistent429(authType);
|
||||||
|
|
Loading…
Reference in New Issue