mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
Refactor: Migrate CLI appEvents to Core coreEvents (#15737)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user