summaryrefslogtreecommitdiff
path: root/packages/core/src/config/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/config/config.ts')
-rw-r--r--packages/core/src/config/config.ts31
1 files changed, 24 insertions, 7 deletions
diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts
index 6caf39e8..a97f5536 100644
--- a/packages/core/src/config/config.ts
+++ b/packages/core/src/config/config.ts
@@ -6,7 +6,11 @@
import * as path from 'node:path';
import process from 'node:process';
-import { ContentGeneratorConfig } from '../core/contentGenerator.js';
+import {
+ AuthType,
+ ContentGeneratorConfig,
+ createContentGeneratorConfig,
+} from '../core/contentGenerator.js';
import { ToolRegistry } from '../tools/tool-registry.js';
import { LSTool } from '../tools/ls.js';
import { ReadFileTool } from '../tools/read-file.js';
@@ -80,7 +84,6 @@ export interface SandboxConfig {
export interface ConfigParameters {
sessionId: string;
- contentGeneratorConfig: ContentGeneratorConfig;
embeddingModel?: string;
sandbox?: SandboxConfig;
targetDir: string;
@@ -106,12 +109,13 @@ export interface ConfigParameters {
cwd: string;
fileDiscoveryService?: FileDiscoveryService;
bugCommand?: BugCommandSettings;
+ model: string;
}
export class Config {
private toolRegistry: Promise<ToolRegistry>;
private readonly sessionId: string;
- private readonly contentGeneratorConfig: ContentGeneratorConfig;
+ private contentGeneratorConfig!: ContentGeneratorConfig;
private readonly embeddingModel: string;
private readonly sandbox: SandboxConfig | undefined;
private readonly targetDir: string;
@@ -130,7 +134,7 @@ export class Config {
private readonly showMemoryUsage: boolean;
private readonly accessibility: AccessibilitySettings;
private readonly telemetrySettings: TelemetrySettings;
- private readonly geminiClient: GeminiClient;
+ private geminiClient!: GeminiClient;
private readonly fileFilteringRespectGitIgnore: boolean;
private fileDiscoveryService: FileDiscoveryService | null = null;
private gitService: GitService | undefined = undefined;
@@ -138,10 +142,10 @@ export class Config {
private readonly proxy: string | undefined;
private readonly cwd: string;
private readonly bugCommand: BugCommandSettings | undefined;
+ private readonly model: string;
constructor(params: ConfigParameters) {
this.sessionId = params.sessionId;
- this.contentGeneratorConfig = params.contentGeneratorConfig;
this.embeddingModel =
params.embeddingModel ?? DEFAULT_GEMINI_EMBEDDING_MODEL;
this.sandbox = params.sandbox;
@@ -174,12 +178,12 @@ export class Config {
this.cwd = params.cwd ?? process.cwd();
this.fileDiscoveryService = params.fileDiscoveryService ?? null;
this.bugCommand = params.bugCommand;
+ this.model = params.model;
if (params.contextFileName) {
setGeminiMdFilename(params.contextFileName);
}
- this.geminiClient = new GeminiClient(this);
this.toolRegistry = createToolRegistry(this);
if (this.telemetrySettings.enabled) {
@@ -187,6 +191,19 @@ export class Config {
}
}
+ async refreshAuth(authMethod: AuthType) {
+ const contentConfig = await createContentGeneratorConfig(
+ this.getModel(),
+ authMethod,
+ );
+
+ const gc = new GeminiClient(this);
+ await gc.initialize(contentConfig);
+
+ this.contentGeneratorConfig = contentConfig;
+ this.geminiClient = gc;
+ }
+
getSessionId(): string {
return this.sessionId;
}
@@ -196,7 +213,7 @@ export class Config {
}
getModel(): string {
- return this.contentGeneratorConfig.model;
+ return this.contentGeneratorConfig?.model || this.model;
}
getEmbeddingModel(): string {