mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-10 10:00:53 -07:00
feat(core): multi-registry architecture and tool filtering for subagents (#22712)
This commit is contained in:
@@ -100,6 +100,7 @@ vi.mock('../tools/mcp-client-manager.js', () => ({
|
||||
McpClientManager: vi.fn().mockImplementation(() => ({
|
||||
startConfiguredMcpServers: vi.fn(),
|
||||
getMcpInstructions: vi.fn().mockReturnValue('MCP Instructions'),
|
||||
setMainRegistries: vi.fn(),
|
||||
})),
|
||||
}));
|
||||
|
||||
@@ -370,6 +371,7 @@ describe('Server Config (config.ts)', () => {
|
||||
mcpStarted = true;
|
||||
}),
|
||||
getMcpInstructions: vi.fn(),
|
||||
setMainRegistries: vi.fn(),
|
||||
}) as Partial<McpClientManager> as McpClientManager,
|
||||
);
|
||||
|
||||
@@ -403,6 +405,7 @@ describe('Server Config (config.ts)', () => {
|
||||
mcpStarted = true;
|
||||
}),
|
||||
getMcpInstructions: vi.fn(),
|
||||
setMainRegistries: vi.fn(),
|
||||
}) as Partial<McpClientManager> as McpClientManager,
|
||||
);
|
||||
|
||||
|
||||
@@ -523,6 +523,7 @@ export interface ConfigParameters {
|
||||
question?: string;
|
||||
|
||||
coreTools?: string[];
|
||||
mainAgentTools?: string[];
|
||||
/** @deprecated Use Policy Engine instead */
|
||||
allowedTools?: string[];
|
||||
/** @deprecated Use Policy Engine instead */
|
||||
@@ -678,6 +679,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
readonly enableConseca: boolean;
|
||||
|
||||
private readonly coreTools: string[] | undefined;
|
||||
private readonly mainAgentTools: string[] | undefined;
|
||||
/** @deprecated Use Policy Engine instead */
|
||||
private readonly allowedTools: string[] | undefined;
|
||||
/** @deprecated Use Policy Engine instead */
|
||||
@@ -891,6 +893,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
this.question = params.question;
|
||||
|
||||
this.coreTools = params.coreTools;
|
||||
this.mainAgentTools = params.mainAgentTools;
|
||||
this.allowedTools = params.allowedTools;
|
||||
this.excludeTools = params.excludeTools;
|
||||
this.toolDiscoveryCommand = params.toolDiscoveryCommand;
|
||||
@@ -1238,10 +1241,14 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
discoverToolsHandle?.end();
|
||||
this.mcpClientManager = new McpClientManager(
|
||||
this.clientVersion,
|
||||
this._toolRegistry,
|
||||
this,
|
||||
this.eventEmitter,
|
||||
);
|
||||
this.mcpClientManager.setMainRegistries({
|
||||
toolRegistry: this._toolRegistry,
|
||||
promptRegistry: this.promptRegistry,
|
||||
resourceRegistry: this.resourceRegistry,
|
||||
});
|
||||
// We do not await this promise so that the CLI can start up even if
|
||||
// MCP servers are slow to connect.
|
||||
this.mcpInitializationPromise = Promise.allSettled([
|
||||
@@ -1898,6 +1905,10 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
return this.coreTools;
|
||||
}
|
||||
|
||||
getMainAgentTools(): string[] | undefined {
|
||||
return this.mainAgentTools;
|
||||
}
|
||||
|
||||
getAllowedTools(): string[] | undefined {
|
||||
return this.allowedTools;
|
||||
}
|
||||
@@ -3054,7 +3065,11 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
}
|
||||
|
||||
async createToolRegistry(): Promise<ToolRegistry> {
|
||||
const registry = new ToolRegistry(this, this.messageBus);
|
||||
const registry = new ToolRegistry(
|
||||
this,
|
||||
this.messageBus,
|
||||
/* isMainRegistry= */ true,
|
||||
);
|
||||
|
||||
// helper to create & register core tools that are enabled
|
||||
const maybeRegister = (
|
||||
|
||||
Reference in New Issue
Block a user