Refactor: Migrate CLI appEvents to Core coreEvents (#15737)

This commit is contained in:
Adib234
2026-01-23 11:45:46 -05:00
committed by GitHub
parent 0b7d26c9e3
commit 488d5fc439
13 changed files with 90 additions and 93 deletions

View File

@@ -20,8 +20,10 @@ import {
getErrorMessage,
MCPOAuthTokenStorage,
mcpServerRequiresOAuth,
CoreEvent,
coreEvents,
} from '@google/gemini-cli-core';
import { appEvents, AppEvent } from '../../utils/events.js';
import { MessageType, type HistoryItemMcpStatus } from '../types.js';
import {
McpServerEnablementManager,
@@ -100,8 +102,7 @@ const authCommand: SlashCommand = {
context.ui.addItem({ type: 'info', text: message });
};
appEvents.on(AppEvent.OauthDisplayMessage, displayListener);
coreEvents.on(CoreEvent.OauthDisplayMessage, displayListener);
try {
context.ui.addItem({
type: 'info',
@@ -118,12 +119,7 @@ const authCommand: SlashCommand = {
const mcpServerUrl = server.httpUrl || server.url;
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
await authProvider.authenticate(
serverName,
oauthConfig,
mcpServerUrl,
appEvents,
);
await authProvider.authenticate(serverName, oauthConfig, mcpServerUrl);
context.ui.addItem({
type: 'info',
@@ -160,7 +156,7 @@ const authCommand: SlashCommand = {
content: `Failed to authenticate with MCP server '${serverName}': ${getErrorMessage(error)}`,
};
} finally {
appEvents.removeListener(AppEvent.OauthDisplayMessage, displayListener);
coreEvents.removeListener(CoreEvent.OauthDisplayMessage, displayListener);
}
},
completion: async (context: CommandContext, partialArg: string) => {