Enable Gemini CLI to reuse user's auth in Cloud Shell (#3070)

This commit is contained in:
Marat Boshernitsan
2025-07-07 15:02:13 -07:00
committed by GitHub
parent 357546a2aa
commit 48c2aa296a
10 changed files with 211 additions and 32 deletions

View File

@@ -103,14 +103,21 @@ export async function main() {
const extensions = loadExtensions(workspaceRoot);
const config = await loadCliConfig(settings.merged, extensions, sessionId);
// set default fallback to gemini api key
// this has to go after load cli because that's where the env is set
if (!settings.merged.selectedAuthType && process.env.GEMINI_API_KEY) {
settings.setValue(
SettingScope.User,
'selectedAuthType',
AuthType.USE_GEMINI,
);
// Set a default auth type if one isn't set for a couple of known cases.
if (!settings.merged.selectedAuthType) {
if (process.env.GEMINI_API_KEY) {
settings.setValue(
SettingScope.User,
'selectedAuthType',
AuthType.USE_GEMINI,
);
} else if (process.env.CLOUD_SHELL === 'true') {
settings.setValue(
SettingScope.User,
'selectedAuthType',
AuthType.CLOUD_SHELL,
);
}
}
setMaxSizedBoxDebugging(config.getDebugMode());