Refactor: Centralize GeminiClient in Config (#693)

Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
Scott Densmore
2025-06-02 14:55:51 -07:00
committed by GitHub
parent 1dcf0a4cbd
commit e428707e07
4 changed files with 79 additions and 50 deletions

View File

@@ -21,6 +21,7 @@ import { WebFetchTool } from '../tools/web-fetch.js';
import { ReadManyFilesTool } from '../tools/read-many-files.js';
import { MemoryTool, setGeminiMdFilename } from '../tools/memoryTool.js';
import { WebSearchTool } from '../tools/web-search.js';
import { GeminiClient } from '../core/client.js';
import { GEMINI_CONFIG_DIR as GEMINI_DIR } from '../tools/memoryTool.js';
export enum ApprovalMode {
@@ -86,6 +87,7 @@ export class Config {
private approvalMode: ApprovalMode;
private readonly vertexai: boolean | undefined;
private readonly showMemoryUsage: boolean;
private readonly geminiClient: GeminiClient;
constructor(params: ConfigParameters) {
this.apiKey = params.apiKey;
@@ -112,6 +114,7 @@ export class Config {
}
this.toolRegistry = createToolRegistry(this);
this.geminiClient = new GeminiClient(this);
}
getApiKey(): string {
@@ -200,6 +203,10 @@ export class Config {
getShowMemoryUsage(): boolean {
return this.showMemoryUsage;
}
getGeminiClient(): GeminiClient {
return this.geminiClient;
}
}
function findEnvFile(startDir: string): string | null {