diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index e92f464fa27..c8fbdc7861f 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -1,3 +1,4 @@ + /** * @license * Copyright 2026 Google LLC @@ -2512,6 +2513,80 @@ describe('Config Quota & Preview Model Access', () => { }); }); + describe('getGemini31LaunchedSync', () => { + it('should return true if authType is USE_GEMINI', () => { + Object.defineProperty(config, 'contentGeneratorConfig', { + value: { authType: AuthType.USE_GEMINI }, + writable: true, + configurable: true, + }); + + expect(config.getGemini31LaunchedSync()).toBe(true); + }); + + it('should return true if userTier is STANDARD', () => { + Object.defineProperty(config, 'contentGeneratorConfig', { + value: { authType: AuthType.LOGIN_WITH_GOOGLE }, + writable: true, + configurable: true, + }); + + vi.mocked(getCodeAssistServer).mockReturnValue({ + userTier: UserTierId.STANDARD, + } as Partial as CodeAssistServer); + + expect(config.getGemini31LaunchedSync()).toBe(true); + }); + + it('should return true if experiment flag is true', () => { + Object.defineProperty(config, 'contentGeneratorConfig', { + value: { authType: AuthType.LOGIN_WITH_GOOGLE }, + writable: true, + configurable: true, + }); + + vi.mocked(getCodeAssistServer).mockReturnValue({ + userTier: UserTierId.FREE, + } as Partial as CodeAssistServer); + + Object.defineProperty(config, 'experiments', { + value: { + flags: { + [ExperimentFlags.GEMINI_3_1_PRO_LAUNCHED]: { boolValue: true }, + }, + }, + writable: true, + configurable: true, + }); + + expect(config.getGemini31LaunchedSync()).toBe(true); + }); + + it('should return false if authType is Google, userTier is FREE, and flag is false', () => { + Object.defineProperty(config, 'contentGeneratorConfig', { + value: { authType: AuthType.LOGIN_WITH_GOOGLE }, + writable: true, + configurable: true, + }); + + vi.mocked(getCodeAssistServer).mockReturnValue({ + userTier: UserTierId.FREE, + } as Partial as CodeAssistServer); + + Object.defineProperty(config, 'experiments', { + value: { + flags: { + [ExperimentFlags.GEMINI_3_1_PRO_LAUNCHED]: { boolValue: false }, + }, + }, + writable: true, + configurable: true, + }); + + expect(config.getGemini31LaunchedSync()).toBe(false); + }); +}); + describe('isPlanEnabled', () => { it('should return false by default', () => { const config = new Config(baseParams); diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 7297693b8e9..4215d29e657 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -108,10 +108,10 @@ import type { EventEmitter } from 'node:events'; import { PolicyEngine } from '../policy/policy-engine.js'; import { ApprovalMode, type PolicyEngineConfig } from '../policy/types.js'; import { HookSystem } from '../hooks/index.js'; -import type { +import { UserTierId, - RetrieveUserQuotaResponse, - AdminControlsSettings, + type RetrieveUserQuotaResponse, + type AdminControlsSettings, } from '../code_assist/types.js'; import type { HierarchicalMemory } from './memory.js'; import { getCodeAssistServer } from '../code_assist/codeAssist.js'; @@ -2383,6 +2383,12 @@ export class Config { ) { return true; } + + const codeAssistServer = getCodeAssistServer(this); + if (codeAssistServer?.userTier === UserTierId.STANDARD) { + return true; + } + return ( this.experiments?.flags[ExperimentFlags.GEMINI_3_1_PRO_LAUNCHED] ?.boolValue ?? false