| |
| |
| |
| |
| |
|
|
| import type { |
| OpenDialogActionReturn, |
| SlashCommand, |
| LogoutActionReturn, |
| } from './types.js'; |
| import { CommandKind } from './types.js'; |
| import { clearCachedCredentialFile } from '@google/gemini-cli-core'; |
| import { SettingScope } from '../../config/settings.js'; |
|
|
| const authLoginCommand: SlashCommand = { |
| name: 'signin', |
| altNames: ['login'], |
| description: 'Sign in or change the authentication method', |
| kind: CommandKind.BUILT_IN, |
| autoExecute: true, |
| action: (_context, _args): OpenDialogActionReturn => ({ |
| type: 'dialog', |
| dialog: 'auth', |
| }), |
| }; |
|
|
| const authLogoutCommand: SlashCommand = { |
| name: 'signout', |
| altNames: ['logout'], |
| description: 'Sign out and clear all cached credentials', |
| kind: CommandKind.BUILT_IN, |
| action: async (context, _args): Promise<LogoutActionReturn> => { |
| await clearCachedCredentialFile(); |
| |
| context.services.settings.setValue( |
| SettingScope.User, |
| 'security.auth.selectedType', |
| undefined, |
| ); |
| |
| context.services.agentContext?.geminiClient.stripThoughtsFromHistory(); |
| |
| return { |
| type: 'logout', |
| }; |
| }, |
| }; |
|
|
| export const authCommand: SlashCommand = { |
| name: 'auth', |
| description: 'Manage authentication', |
| kind: CommandKind.BUILT_IN, |
| subCommands: [authLoginCommand, authLogoutCommand], |
| action: (context, args) => |
| |
| authLoginCommand.action!(context, args), |
| }; |
|
|