/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type { ContentGenerator, ContentGeneratorConfig } from '../core/contentGenerator.js'; import { AuthType } from '../core/contentGenerator.js'; import { PromptRegistry } from '../prompts/prompt-registry.js'; import { ToolRegistry } from '../tools/tool-registry.js'; import { GeminiClient } from '../core/client.js'; import { BaseLlmClient } from '../core/baseLlmClient.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import { GitService } from '../services/gitService.js'; import type { TelemetryTarget } from '../telemetry/index.js'; import { DEFAULT_GEMINI_FLASH_MODEL } from './models.js'; import type { MCPOAuthConfig } from '../mcp/oauth-provider.js'; import type { FileSystemService } from '../services/fileSystemService.js'; import type { FallbackModelHandler } from '../fallback/types.js'; import { ModelRouterService } from '../routing/modelRouterService.js'; import { OutputFormat } from '../output/types.js'; export type { MCPOAuthConfig, AnyToolInvocation }; import type { AnyToolInvocation } from '../tools/tools.js'; import { WorkspaceContext } from '../utils/workspaceContext.js'; import { Storage } from './storage.js'; import type { ShellExecutionConfig } from '../services/shellExecutionService.js'; import { FileExclusions } from '../utils/ignorePatterns.js'; import type { EventEmitter } from 'node:events'; import { MessageBus } from '../confirmation-bus/message-bus.js'; import { PolicyEngine } from '../policy/policy-engine.js'; import type { PolicyEngineConfig } from '../policy/types.js'; import type { UserTierId } from '../code_assist/types.js'; import { AgentRegistry } from '../agents/registry.js'; export declare enum ApprovalMode { DEFAULT = "default", AUTO_EDIT = "autoEdit", YOLO = "yolo" } export interface AccessibilitySettings { disableLoadingPhrases?: boolean; screenReader?: boolean; } export interface BugCommandSettings { urlTemplate: string; } export interface SummarizeToolOutputSettings { tokenBudget?: number; } export interface TelemetrySettings { enabled?: boolean; target?: TelemetryTarget; otlpEndpoint?: string; otlpProtocol?: 'grpc' | 'http'; logPrompts?: boolean; outfile?: string; useCollector?: boolean; } export interface OutputSettings { format?: OutputFormat; } export interface CodebaseInvestigatorSettings { enabled?: boolean; maxNumTurns?: number; maxTimeMinutes?: number; thinkingBudget?: number; model?: string; } /** * All information required in CLI to handle an extension. Defined in Core so * that the collection of loaded, active, and inactive extensions can be passed * around on the config object though Core does not use this information * directly. */ export interface GeminiCLIExtension { name: string; version: string; isActive: boolean; path: string; installMetadata?: ExtensionInstallMetadata; mcpServers?: Record; contextFiles: string[]; excludeTools?: string[]; id: string; hooks?: { [K in HookEventName]?: HookDefinition[]; }; } export interface ExtensionInstallMetadata { source: string; type: 'git' | 'local' | 'link' | 'github-release'; releaseTag?: string; ref?: string; autoUpdate?: boolean; allowPreRelease?: boolean; } import type { FileFilteringOptions } from './constants.js'; import { DEFAULT_FILE_FILTERING_OPTIONS, DEFAULT_MEMORY_FILE_FILTERING_OPTIONS } from './constants.js'; import { type ExtensionLoader } from '../utils/extensionLoader.js'; export type { FileFilteringOptions }; export { DEFAULT_FILE_FILTERING_OPTIONS, DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, }; export declare const DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD = 4000000; export declare const DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES = 1000; export declare class MCPServerConfig { readonly command?: string | undefined; readonly args?: string[] | undefined; readonly env?: Record | undefined; readonly cwd?: string | undefined; readonly url?: string | undefined; readonly httpUrl?: string | undefined; readonly headers?: Record | undefined; readonly tcp?: string | undefined; readonly timeout?: number | undefined; readonly trust?: boolean | undefined; readonly description?: string | undefined; readonly includeTools?: string[] | undefined; readonly excludeTools?: string[] | undefined; readonly extension?: GeminiCLIExtension | undefined; readonly oauth?: MCPOAuthConfig | undefined; readonly authProviderType?: AuthProviderType | undefined; readonly targetAudience?: string | undefined; readonly targetServiceAccount?: string | undefined; constructor(command?: string | undefined, args?: string[] | undefined, env?: Record | undefined, cwd?: string | undefined, url?: string | undefined, httpUrl?: string | undefined, headers?: Record | undefined, tcp?: string | undefined, timeout?: number | undefined, trust?: boolean | undefined, description?: string | undefined, includeTools?: string[] | undefined, excludeTools?: string[] | undefined, extension?: GeminiCLIExtension | undefined, oauth?: MCPOAuthConfig | undefined, authProviderType?: AuthProviderType | undefined, targetAudience?: string | undefined, targetServiceAccount?: string | undefined); } export declare enum AuthProviderType { DYNAMIC_DISCOVERY = "dynamic_discovery", GOOGLE_CREDENTIALS = "google_credentials", SERVICE_ACCOUNT_IMPERSONATION = "service_account_impersonation" } export interface SandboxConfig { command: 'docker' | 'podman' | 'sandbox-exec'; image: string; } /** * Event names for the hook system */ export declare enum HookEventName { BeforeTool = "BeforeTool", AfterTool = "AfterTool", BeforeAgent = "BeforeAgent", Notification = "Notification", AfterAgent = "AfterAgent", SessionStart = "SessionStart", SessionEnd = "SessionEnd", PreCompress = "PreCompress", BeforeModel = "BeforeModel", AfterModel = "AfterModel", BeforeToolSelection = "BeforeToolSelection" } /** * Hook configuration entry */ export interface CommandHookConfig { type: HookType.Command; command: string; timeout?: number; } export type HookConfig = CommandHookConfig; /** * Hook definition with matcher */ export interface HookDefinition { matcher?: string; sequential?: boolean; hooks: HookConfig[]; } /** * Hook implementation types */ export declare enum HookType { Command = "command" } export interface ConfigParameters { sessionId: string; embeddingModel?: string; sandbox?: SandboxConfig; targetDir: string; debugMode: boolean; question?: string; coreTools?: string[]; allowedTools?: string[]; excludeTools?: string[]; toolDiscoveryCommand?: string; toolCallCommand?: string; mcpServerCommand?: string; mcpServers?: Record; userMemory?: string; geminiMdFileCount?: number; geminiMdFilePaths?: string[]; approvalMode?: ApprovalMode; showMemoryUsage?: boolean; contextFileName?: string | string[]; accessibility?: AccessibilitySettings; telemetry?: TelemetrySettings; usageStatisticsEnabled?: boolean; fileFiltering?: { respectGitIgnore?: boolean; respectGeminiIgnore?: boolean; enableRecursiveFileSearch?: boolean; disableFuzzySearch?: boolean; }; checkpointing?: boolean; proxy?: string; cwd: string; fileDiscoveryService?: FileDiscoveryService; includeDirectories?: string[]; bugCommand?: BugCommandSettings; model: string; maxSessionTurns?: number; experimentalZedIntegration?: boolean; listExtensions?: boolean; extensionLoader?: ExtensionLoader; enabledExtensions?: string[]; enableExtensionReloading?: boolean; blockedMcpServers?: Array<{ name: string; extensionName: string; }>; noBrowser?: boolean; summarizeToolOutput?: Record; folderTrust?: boolean; ideMode?: boolean; loadMemoryFromIncludeDirectories?: boolean; compressionThreshold?: number; interactive?: boolean; trustedFolder?: boolean; useRipgrep?: boolean; enableInteractiveShell?: boolean; skipNextSpeakerCheck?: boolean; shellExecutionConfig?: ShellExecutionConfig; extensionManagement?: boolean; enablePromptCompletion?: boolean; truncateToolOutputThreshold?: number; truncateToolOutputLines?: number; enableToolOutputTruncation?: boolean; eventEmitter?: EventEmitter; useSmartEdit?: boolean; useWriteTodos?: boolean; policyEngineConfig?: PolicyEngineConfig; output?: OutputSettings; useModelRouter?: boolean; enableMessageBusIntegration?: boolean; disableModelRouterForAuth?: AuthType[]; codebaseInvestigatorSettings?: CodebaseInvestigatorSettings; continueOnFailedApiCall?: boolean; retryFetchErrors?: boolean; enableShellOutputEfficiency?: boolean; fakeResponses?: string; recordResponses?: string; ptyInfo?: string; disableYoloMode?: boolean; enableHooks?: boolean; hooks?: { [K in HookEventName]?: HookDefinition[]; }; } export declare class Config { private toolRegistry; private promptRegistry; private agentRegistry; private readonly sessionId; private fileSystemService; private contentGeneratorConfig; private contentGenerator; private readonly embeddingModel; private readonly sandbox; private readonly targetDir; private workspaceContext; private readonly debugMode; private readonly question; private readonly coreTools; private readonly allowedTools; private readonly excludeTools; private readonly toolDiscoveryCommand; private readonly toolCallCommand; private readonly mcpServerCommand; private mcpServers; private userMemory; private geminiMdFileCount; private geminiMdFilePaths; private approvalMode; private readonly showMemoryUsage; private readonly accessibility; private readonly telemetrySettings; private readonly usageStatisticsEnabled; private geminiClient; private baseLlmClient; private modelRouterService; private readonly fileFiltering; private fileDiscoveryService; private gitService; private readonly proxy; private readonly cwd; private readonly bugCommand; private model; private readonly noBrowser; private readonly folderTrust; private ideMode; private inFallbackMode; private readonly maxSessionTurns; private readonly listExtensions; private readonly _extensionLoader; private readonly _enabledExtensions; private readonly enableExtensionReloading; private readonly _blockedMcpServers; fallbackModelHandler?: FallbackModelHandler; private quotaErrorOccurred; private readonly summarizeToolOutput; private readonly experimentalZedIntegration; private readonly loadMemoryFromIncludeDirectories; private readonly compressionThreshold; private readonly interactive; private readonly ptyInfo; private readonly trustedFolder; private readonly useRipgrep; private readonly enableInteractiveShell; private readonly skipNextSpeakerCheck; private shellExecutionConfig; private readonly extensionManagement; private readonly enablePromptCompletion; private readonly truncateToolOutputThreshold; private readonly truncateToolOutputLines; private readonly enableToolOutputTruncation; private initialized; readonly storage: Storage; private readonly fileExclusions; private readonly eventEmitter?; private readonly useSmartEdit; private readonly useWriteTodos; private readonly messageBus; private readonly policyEngine; private readonly outputSettings; private useModelRouter; private readonly initialUseModelRouter; private readonly disableModelRouterForAuth?; private readonly enableMessageBusIntegration; private readonly codebaseInvestigatorSettings; private readonly continueOnFailedApiCall; private readonly retryFetchErrors; private readonly enableShellOutputEfficiency; readonly fakeResponses?: string; readonly recordResponses?: string; private readonly disableYoloMode; private readonly enableHooks; private readonly hooks; constructor(params: ConfigParameters); /** * Must only be called once, throws if called again. */ initialize(): Promise; getContentGenerator(): ContentGenerator; refreshAuth(authMethod: AuthType): Promise; getUserTier(): UserTierId | undefined; /** * Provides access to the BaseLlmClient for stateless LLM operations. */ getBaseLlmClient(): BaseLlmClient; getSessionId(): string; shouldLoadMemoryFromIncludeDirectories(): boolean; getContentGeneratorConfig(): ContentGeneratorConfig; getModel(): string; setModel(newModel: string): void; isInFallbackMode(): boolean; setFallbackMode(active: boolean): void; setFallbackModelHandler(handler: FallbackModelHandler): void; getMaxSessionTurns(): number; setQuotaErrorOccurred(value: boolean): void; getQuotaErrorOccurred(): boolean; getEmbeddingModel(): string; getSandbox(): SandboxConfig | undefined; isRestrictiveSandbox(): boolean; getTargetDir(): string; getProjectRoot(): string; getWorkspaceContext(): WorkspaceContext; getAgentRegistry(): AgentRegistry; getToolRegistry(): ToolRegistry; getPromptRegistry(): PromptRegistry; getDebugMode(): boolean; getQuestion(): string | undefined; getCoreTools(): string[] | undefined; getAllowedTools(): string[] | undefined; getExcludeTools(): string[] | undefined; getToolDiscoveryCommand(): string | undefined; getToolCallCommand(): string | undefined; getMcpServerCommand(): string | undefined; getMcpServers(): Record | undefined; setMcpServers(mcpServers: Record): void; getUserMemory(): string; setUserMemory(newUserMemory: string): void; getGeminiMdFileCount(): number; setGeminiMdFileCount(count: number): void; getGeminiMdFilePaths(): string[]; setGeminiMdFilePaths(paths: string[]): void; getApprovalMode(): ApprovalMode; setApprovalMode(mode: ApprovalMode): void; isYoloModeDisabled(): boolean; getShowMemoryUsage(): boolean; getAccessibility(): AccessibilitySettings; getTelemetryEnabled(): boolean; getTelemetryLogPromptsEnabled(): boolean; getTelemetryOtlpEndpoint(): string; getTelemetryOtlpProtocol(): 'grpc' | 'http'; getTelemetryTarget(): TelemetryTarget; getTelemetryOutfile(): string | undefined; getTelemetryUseCollector(): boolean; getGeminiClient(): GeminiClient; getModelRouterService(): ModelRouterService; getEnableRecursiveFileSearch(): boolean; getFileFilteringDisableFuzzySearch(): boolean; getFileFilteringRespectGitIgnore(): boolean; getFileFilteringRespectGeminiIgnore(): boolean; getFileFilteringOptions(): FileFilteringOptions; /** * Gets custom file exclusion patterns from configuration. * TODO: This is a placeholder implementation. In the future, this could * read from settings files, CLI arguments, or environment variables. */ getCustomExcludes(): string[]; getCheckpointingEnabled(): boolean; getProxy(): string | undefined; getWorkingDir(): string; getBugCommand(): BugCommandSettings | undefined; getFileService(): FileDiscoveryService; getUsageStatisticsEnabled(): boolean; getExperimentalZedIntegration(): boolean; getListExtensions(): boolean; getExtensionManagement(): boolean; getExtensions(): GeminiCLIExtension[]; getExtensionLoader(): ExtensionLoader; getEnabledExtensions(): string[]; getEnableExtensionReloading(): boolean; getBlockedMcpServers(): Array<{ name: string; extensionName: string; }>; getNoBrowser(): boolean; isBrowserLaunchSuppressed(): boolean; getSummarizeToolOutputConfig(): Record | undefined; getIdeMode(): boolean; /** * Returns 'true' if the folder trust feature is enabled. */ getFolderTrust(): boolean; /** * Returns 'true' if the workspace is considered "trusted". * 'false' for untrusted. */ isTrustedFolder(): boolean; setIdeMode(value: boolean): void; /** * Get the current FileSystemService */ getFileSystemService(): FileSystemService; /** * Set a custom FileSystemService */ setFileSystemService(fileSystemService: FileSystemService): void; getCompressionThreshold(): number | undefined; isInteractiveShellEnabled(): boolean; isInteractive(): boolean; getUseRipgrep(): boolean; getEnableInteractiveShell(): boolean; getSkipNextSpeakerCheck(): boolean; getContinueOnFailedApiCall(): boolean; getRetryFetchErrors(): boolean; getEnableShellOutputEfficiency(): boolean; getShellExecutionConfig(): ShellExecutionConfig; setShellExecutionConfig(config: ShellExecutionConfig): void; getScreenReader(): boolean; getEnablePromptCompletion(): boolean; getEnableToolOutputTruncation(): boolean; getTruncateToolOutputThreshold(): number; getTruncateToolOutputLines(): number; getUseSmartEdit(): boolean; getUseWriteTodos(): boolean; getOutputFormat(): OutputFormat; getUseModelRouter(): boolean; getGitService(): Promise; getFileExclusions(): FileExclusions; getMessageBus(): MessageBus; getPolicyEngine(): PolicyEngine; getEnableMessageBusIntegration(): boolean; getEnableHooks(): boolean; getCodebaseInvestigatorSettings(): CodebaseInvestigatorSettings; createToolRegistry(): Promise; /** * Get hooks configuration */ getHooks(): { [K in HookEventName]?: HookDefinition[]; } | undefined; } export { DEFAULT_GEMINI_FLASH_MODEL };