From 389907ce6537bd8caeb10b3d4dacaa8ece059500 Mon Sep 17 00:00:00 2001 From: Tommaso Sciortino Date: Sat, 7 Jun 2025 16:17:27 -0700 Subject: Introduce ContentGeneratorConfig (#826) --- packages/core/src/config/config.ts | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'packages/core/src/config/config.ts') diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 7d25c1bb..b8f4d41f 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -9,6 +9,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import process from 'node:process'; import * as os from 'node:os'; +import { ContentGeneratorConfig } from '../core/contentGenerator.js'; import { ToolRegistry } from '../tools/tool-registry.js'; import { CodeParserTool } from '../tools/code_parser.js'; // Added CodeParserTool import { LSTool } from '../tools/ls.js'; @@ -17,7 +18,6 @@ import { GrepTool } from '../tools/grep.js'; import { GlobTool } from '../tools/glob.js'; import { EditTool } from '../tools/edit.js'; import { ShellTool } from '../tools/shell.js'; - import { WebFetchTool } from '../tools/web-fetch.js'; import { ReadManyFilesTool } from '../tools/read-many-files.js'; import { MemoryTool, setGeminiMdFilename } from '../tools/memoryTool.js'; @@ -55,8 +55,7 @@ export class MCPServerConfig { } export interface ConfigParameters { - apiKey: string; - model: string; + contentGeneratorConfig: ContentGeneratorConfig; embeddingModel: string; sandbox: boolean | string; targetDir: string; @@ -68,11 +67,9 @@ export interface ConfigParameters { toolCallCommand?: string; mcpServerCommand?: string; mcpServers?: Record; - userAgent: string; userMemory?: string; geminiMdFileCount?: number; approvalMode?: ApprovalMode; - vertexai?: boolean; showMemoryUsage?: boolean; contextFileName?: string; geminiIgnorePatterns?: string[]; @@ -85,8 +82,7 @@ export interface ConfigParameters { export class Config { private toolRegistry: Promise; - private readonly apiKey: string; - private readonly model: string; + private readonly contentGeneratorConfig: ContentGeneratorConfig; private readonly embeddingModel: string; private readonly sandbox: boolean | string; private readonly targetDir: string; @@ -98,11 +94,9 @@ export class Config { private readonly toolCallCommand: string | undefined; private readonly mcpServerCommand: string | undefined; private readonly mcpServers: Record | undefined; - private readonly userAgent: string; private userMemory: string; private geminiMdFileCount: number; private approvalMode: ApprovalMode; - private readonly vertexai: boolean | undefined; private readonly showMemoryUsage: boolean; private readonly accessibility: AccessibilitySettings; private readonly telemetry: boolean; @@ -115,8 +109,7 @@ export class Config { private fileDiscoveryService: FileDiscoveryService | null = null; constructor(params: ConfigParameters) { - this.apiKey = params.apiKey; - this.model = params.model; + this.contentGeneratorConfig = params.contentGeneratorConfig; this.embeddingModel = params.embeddingModel; this.sandbox = params.sandbox; this.targetDir = path.resolve(params.targetDir); @@ -128,11 +121,9 @@ export class Config { this.toolCallCommand = params.toolCallCommand; this.mcpServerCommand = params.mcpServerCommand; this.mcpServers = params.mcpServers; - this.userAgent = params.userAgent ?? 'GeminiCLI/unknown'; this.userMemory = params.userMemory ?? ''; this.geminiMdFileCount = params.geminiMdFileCount ?? 0; this.approvalMode = params.approvalMode ?? ApprovalMode.DEFAULT; - this.vertexai = params.vertexai; this.showMemoryUsage = params.showMemoryUsage ?? false; this.accessibility = params.accessibility ?? {}; this.telemetry = params.telemetry ?? false; @@ -160,12 +151,12 @@ export class Config { } } - getApiKey(): string { - return this.apiKey; + getContentGeneratorConfig(): ContentGeneratorConfig { + return this.contentGeneratorConfig; } getModel(): string { - return this.model; + return this.contentGeneratorConfig.model; } getEmbeddingModel(): string { @@ -215,10 +206,6 @@ export class Config { return this.mcpServers; } - getUserAgent(): string { - return this.userAgent; - } - getUserMemory(): string { return this.userMemory; } @@ -243,10 +230,6 @@ export class Config { this.approvalMode = mode; } - getVertexAI(): boolean | undefined { - return this.vertexai; - } - getShowMemoryUsage(): boolean { return this.showMemoryUsage; } -- cgit v1.2.3