Introduce ContentGeneratorConfig (#826)

This commit is contained in:
Tommaso Sciortino
2025-06-07 16:17:27 -07:00
committed by GitHub
parent e95a6086fc
commit 389907ce65
12 changed files with 156 additions and 141 deletions

View File

@@ -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<string, MCPServerConfig>;
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<ToolRegistry>;
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<string, MCPServerConfig> | 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;
}