@@ -188,60 +188,62 @@ export interface ConfigParameters {
188188export class Config {
189189 private toolRegistry ! : ToolRegistry ;
190190 private promptRegistry ! : PromptRegistry ;
191- private readonly sessionId : string ;
191+ private sessionId : string ;
192192 private contentGeneratorConfig ! : ContentGeneratorConfig ;
193- private readonly embeddingModel : string ;
194- private readonly sandbox : SandboxConfig | undefined ;
195- private readonly targetDir : string ;
196- private readonly debugMode : boolean ;
197- private readonly question : string | undefined ;
198- private readonly fullContext : boolean ;
199- private readonly coreTools : string [ ] | undefined ;
200- private readonly excludeTools : string [ ] | undefined ;
201- private readonly toolDiscoveryCommand : string | undefined ;
202- private readonly toolCallCommand : string | undefined ;
203- private readonly mcpServerCommand : string | undefined ;
204- private readonly mcpServers : Record < string , MCPServerConfig > | undefined ;
193+ private embeddingModel : string ;
194+ private sandbox : SandboxConfig | undefined ;
195+ private targetDir : string ;
196+ private debugMode : boolean ;
197+ private question : string | undefined ;
198+ private fullContext : boolean ;
199+ private coreTools : string [ ] | undefined ;
200+ private excludeTools : string [ ] | undefined ;
201+ private toolDiscoveryCommand : string | undefined ;
202+ private toolCallCommand : string | undefined ;
203+ private mcpServerCommand : string | undefined ;
204+ private mcpServers : Record < string , MCPServerConfig > | undefined ;
205205 private userMemory : string ;
206206 private geminiMdFileCount : number ;
207207 private approvalMode : ApprovalMode ;
208- private readonly showMemoryUsage : boolean ;
209- private readonly accessibility : AccessibilitySettings ;
210- private readonly telemetrySettings : TelemetrySettings ;
211- private readonly usageStatisticsEnabled : boolean ;
208+ private showMemoryUsage : boolean ;
209+ private accessibility : AccessibilitySettings ;
210+ private telemetrySettings : TelemetrySettings ;
211+ private usageStatisticsEnabled : boolean ;
212212 private geminiClient ! : GeminiClient ;
213- private readonly fileFiltering : {
213+ private fileFiltering : {
214214 respectGitIgnore : boolean ;
215215 respectGeminiIgnore : boolean ;
216216 enableRecursiveFileSearch : boolean ;
217217 } ;
218218 private fileDiscoveryService : FileDiscoveryService | null = null ;
219219 private gitService : GitService | undefined = undefined ;
220- private readonly checkpointing : boolean ;
221- private readonly proxy : string | undefined ;
222- private readonly cwd : string ;
223- private readonly bugCommand : BugCommandSettings | undefined ;
224- private readonly model : string ;
225- private readonly extensionContextFilePaths : string [ ] ;
226- private readonly noBrowser : boolean ;
227- private readonly ideMode : boolean ;
228- private readonly ideClient : IdeClient | undefined ;
220+ private checkpointing : boolean ;
221+ private proxy : string | undefined ;
222+ private cwd : string ;
223+ private bugCommand : BugCommandSettings | undefined ;
224+ private model : string ;
225+ private extensionContextFilePaths : string [ ] ;
226+ private noBrowser : boolean ;
227+ private ideMode : boolean ;
228+ private ideClient : IdeClient | undefined ;
229229 private modelSwitchedDuringSession : boolean = false ;
230- private readonly maxSessionTurns : number ;
231- private readonly listExtensions : boolean ;
232- private readonly _extensions : GeminiCLIExtension [ ] ;
233- private readonly _blockedMcpServers : Array < {
230+ private maxSessionTurns : number ;
231+ private listExtensions : boolean ;
232+ private _extensions : GeminiCLIExtension [ ] ;
233+ private _blockedMcpServers : Array < {
234234 name : string ;
235235 extensionName : string ;
236236 } > ;
237237 flashFallbackHandler ?: FlashFallbackHandler ;
238238 private quotaErrorOccurred : boolean = false ;
239- private readonly summarizeToolOutput :
239+ private summarizeToolOutput :
240240 | Record < string , SummarizeToolOutputSettings >
241241 | undefined ;
242- private readonly experimentalAcp : boolean = false ;
242+ private experimentalAcp : boolean = false ;
243+ private _params : ConfigParameters ;
243244
244245 constructor ( params : ConfigParameters ) {
246+ this . _params = params ;
245247 this . sessionId = params . sessionId ;
246248 this . embeddingModel =
247249 params . embeddingModel ?? DEFAULT_GEMINI_EMBEDDING_MODEL ;
@@ -310,6 +312,68 @@ export class Config {
310312 }
311313 }
312314
315+ async refresh ( ) {
316+ // Re-run initialization logic.
317+ await this . initialize ( ) ;
318+ // After re-initializing, the tool registry will be updated.
319+ // We need to update the gemini client with the new tools.
320+ await this . geminiClient . setTools ( ) ;
321+ }
322+
323+ update ( params : ConfigParameters ) {
324+ this . _params = params ;
325+ // Re-assign all properties from the new params.
326+ this . sessionId = params . sessionId ;
327+ this . embeddingModel =
328+ params . embeddingModel ?? DEFAULT_GEMINI_EMBEDDING_MODEL ;
329+ this . sandbox = params . sandbox ;
330+ this . targetDir = path . resolve ( params . targetDir ) ;
331+ this . debugMode = params . debugMode ;
332+ this . question = params . question ;
333+ this . fullContext = params . fullContext ?? false ;
334+ this . coreTools = params . coreTools ;
335+ this . excludeTools = params . excludeTools ;
336+ this . toolDiscoveryCommand = params . toolDiscoveryCommand ;
337+ this . toolCallCommand = params . toolCallCommand ;
338+ this . mcpServerCommand = params . mcpServerCommand ;
339+ this . mcpServers = params . mcpServers ;
340+ this . userMemory = params . userMemory ?? '' ;
341+ this . geminiMdFileCount = params . geminiMdFileCount ?? 0 ;
342+ this . approvalMode = params . approvalMode ?? ApprovalMode . DEFAULT ;
343+ this . showMemoryUsage = params . showMemoryUsage ?? false ;
344+ this . accessibility = params . accessibility ?? { } ;
345+ this . telemetrySettings = {
346+ enabled : params . telemetry ?. enabled ?? false ,
347+ target : params . telemetry ?. target ?? DEFAULT_TELEMETRY_TARGET ,
348+ otlpEndpoint : params . telemetry ?. otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT ,
349+ logPrompts : params . telemetry ?. logPrompts ?? true ,
350+ outfile : params . telemetry ?. outfile ,
351+ } ;
352+ this . usageStatisticsEnabled = params . usageStatisticsEnabled ?? true ;
353+ this . fileFiltering = {
354+ respectGitIgnore : params . fileFiltering ?. respectGitIgnore ?? true ,
355+ respectGeminiIgnore : params . fileFiltering ?. respectGeminiIgnore ?? true ,
356+ enableRecursiveFileSearch :
357+ params . fileFiltering ?. enableRecursiveFileSearch ?? true ,
358+ } ;
359+ this . checkpointing = params . checkpointing ?? false ;
360+ this . proxy = params . proxy ;
361+ this . cwd = params . cwd ?? process . cwd ( ) ;
362+ this . fileDiscoveryService = params . fileDiscoveryService ?? null ;
363+ this . bugCommand = params . bugCommand ;
364+ this . model = params . model ;
365+ this . extensionContextFilePaths = params . extensionContextFilePaths ?? [ ] ;
366+ this . maxSessionTurns = params . maxSessionTurns ?? - 1 ;
367+ this . experimentalAcp = params . experimentalAcp ?? false ;
368+ this . listExtensions = params . listExtensions ?? false ;
369+ this . _extensions = params . extensions ?? [ ] ;
370+ this . _blockedMcpServers = params . blockedMcpServers ?? [ ] ;
371+ this . noBrowser = params . noBrowser ?? false ;
372+ this . summarizeToolOutput = params . summarizeToolOutput ;
373+ this . ideMode = params . ideMode ?? false ;
374+ this . ideClient = params . ideClient ;
375+ }
376+
313377 async initialize ( ) : Promise < void > {
314378 // Initialize centralized FileDiscoveryService
315379 this . getFileService ( ) ;
0 commit comments