CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-google--gemini-cli-core

Gemini CLI Core - Core functionality library for the open-source AI agent that brings the power of Gemini directly into your terminal.

Overall
score

87%

Evaluation87%

1.01x

Agent success when using this tile

Overview
Eval results
Files

configuration.mddocs/

Configuration and Setup

Configuration management for Gemini CLI Core applications, providing centralized settings, authentication methods, storage management, and extensibility options.

Capabilities

Config Class

Main configuration management class that handles all application settings, authentication, and behavior configuration.

/**
 * Main configuration management class for Gemini CLI Core applications
 */
class Config {
  constructor(parameters: ConfigParameters);

  // Initialization
  async initialize(): Promise<void>;

  // Authentication
  async refreshAuth(authMethod: AuthType): Promise<void>;
  getUserTier(): UserTierId | undefined;

  // Content generation
  getContentGenerator(): ContentGenerator;
  getContentGeneratorConfig(): ContentGeneratorConfig;

  // Model configuration
  getModel(): string;
  setModel(newModel: string): void;

  // Session management
  getSessionId(): string;
  getMaxSessionTurns(): number;

  // Tool approval settings
  getApprovalMode(): ApprovalMode;
  setApprovalMode(mode: ApprovalMode): void;

  // Extension management
  getExtensions(): GeminiCLIExtension[];

  // Telemetry settings
  getTelemetryEnabled(): boolean;
  getTelemetryLogPromptsEnabled(): boolean;
  getTelemetryTarget(): TelemetryTarget;
  getTelemetryOtlpEndpoint(): string;
  getTelemetryOutfile(): string | undefined;

  // File filtering options
  getFileFilteringOptions(): FileFilteringOptions;
  getFileFilteringRespectGitIgnore(): boolean;
  getFileFilteringRespectGeminiIgnore(): boolean;
  getEnableRecursiveFileSearch(): boolean;
  getFileFilteringDisableFuzzySearch(): boolean;

  // Directory and workspace
  getTargetDir(): string;
  getProjectRoot(): string;
  getWorkspaceContext(): WorkspaceContext;
  getWorkingDir(): string;

  // Tool management
  getToolRegistry(): ToolRegistry;
  getCoreTools(): string[] | undefined;
  getAllowedTools(): string[] | undefined;
  getExcludeTools(): string[] | undefined;

  // Memory management
  getUserMemory(): string;
  setUserMemory(newUserMemory: string): void;
  getGeminiMdFileCount(): number;
  setGeminiMdFileCount(count: number): void;
  shouldLoadMemoryFromIncludeDirectories(): boolean;

  // MCP server configuration
  getMcpServers(): Record<string, MCPServerConfig> | undefined;
  getMcpServerCommand(): string | undefined;
  getBlockedMcpServers(): Array<{ name: string; extensionName: string }>;

  // Services
  getFileService(): FileDiscoveryService;
  getFileSystemService(): FileSystemService;
  setFileSystemService(fileSystemService: FileSystemService): void;

  // Client instances
  getGeminiClient(): GeminiClient;
  getBaseLlmClient(): BaseLlmClient;

  // Git service
  async getGitService(): Promise<GitService>;
  async createToolRegistry(): Promise<ToolRegistry>;

  // Prompt registry
  getPromptRegistry(): PromptRegistry;

  // Feature flags and settings
  getDebugMode(): boolean;
  getFullContext(): boolean;
  getCheckpointingEnabled(): boolean;
  getAccessibility(): AccessibilitySettings;
  getShowMemoryUsage(): boolean;
  getUsageStatisticsEnabled(): boolean;
  getNoBrowser(): boolean;
  isBrowserLaunchSuppressed(): boolean;
  getIdeMode(): boolean;
  setIdeMode(value: boolean): void;
  getFolderTrustFeature(): boolean;
  getFolderTrust(): boolean;
  isTrustedFolder(): boolean;
  isInteractive(): boolean;
  getUseRipgrep(): boolean;
  getShouldUseNodePtyShell(): boolean;
  getSkipNextSpeakerCheck(): boolean;
  getScreenReader(): boolean;
  getEnablePromptCompletion(): boolean;
  getEnableToolOutputTruncation(): boolean;
  getTruncateToolOutputThreshold(): number;
  getTruncateToolOutputLines(): number;
  getUseSmartEdit(): boolean;

  // Fallback mode
  isInFallbackMode(): boolean;
  setFallbackMode(active: boolean): void;
  setFallbackModelHandler(handler: FallbackModelHandler): void;
  setQuotaErrorOccurred(value: boolean): void;
  getQuotaErrorOccurred(): boolean;

  // Additional methods
  getEmbeddingModel(): string;
  getSandbox(): SandboxConfig | undefined;
  isRestrictiveSandbox(): boolean;
  getQuestion(): string | undefined;
  getToolDiscoveryCommand(): string | undefined;
  getToolCallCommand(): string | undefined;
  getChatCompression(): ChatCompressionSettings | undefined;
  getProxy(): string | undefined;
  getBugCommand(): BugCommandSettings | undefined;
  getExtensionContextFilePaths(): string[];
  getCustomExcludes(): string[];
  getFileExclusions(): FileExclusions;
}

interface ConfigParameters {
  sessionId: string;
  targetDir: string;
  debugMode: boolean;
  cwd: string;
  model: string;
  embeddingModel?: string;
  sandbox?: SandboxConfig;
  question?: string;
  fullContext?: boolean;
  coreTools?: string[];
  allowedTools?: string[];
  excludeTools?: string[];
  toolDiscoveryCommand?: string;
  toolCallCommand?: string;
  mcpServerCommand?: string;
  mcpServers?: Record<string, MCPServerConfig>;
  userMemory?: string;
  geminiMdFileCount?: number;
  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;
  fileDiscoveryService?: FileDiscoveryService;
  includeDirectories?: string[];
  bugCommand?: BugCommandSettings;
  extensionContextFilePaths?: string[];
  maxSessionTurns?: number;
  experimentalZedIntegration?: boolean;
  listExtensions?: boolean;
  extensions?: GeminiCLIExtension[];
  blockedMcpServers?: Array<{ name: string; extensionName: string }>;
  noBrowser?: boolean;
  summarizeToolOutput?: Record<string, SummarizeToolOutputSettings>;
  folderTrustFeature?: boolean;
  folderTrust?: boolean;
  ideMode?: boolean;
  loadMemoryFromIncludeDirectories?: boolean;
  chatCompression?: ChatCompressionSettings;
  interactive?: boolean;
  trustedFolder?: boolean;
  useRipgrep?: boolean;
  shouldUseNodePtyShell?: boolean;
  skipNextSpeakerCheck?: boolean;
  extensionManagement?: boolean;
  enablePromptCompletion?: boolean;
  truncateToolOutputThreshold?: number;
  truncateToolOutputLines?: number;
  enableToolOutputTruncation?: boolean;
  eventEmitter?: EventEmitter;
  useSmartEdit?: boolean;
}

Authentication Types

Enumeration of supported authentication methods for different deployment scenarios.

/**
 * Authentication provider types for content generation
 */
enum AuthType {
  /** OAuth personal authentication with Google */
  LOGIN_WITH_GOOGLE = 'oauth-personal',
  /** Direct Gemini API key authentication */
  USE_GEMINI = 'gemini-api-key',
  /** Vertex AI service authentication */
  USE_VERTEX_AI = 'vertex-ai',
  /** Google Cloud Shell built-in authentication */
  CLOUD_SHELL = 'cloud-shell'
}

enum AuthProviderType {
  /** Dynamic OAuth discovery */
  DYNAMIC_DISCOVERY = 'DYNAMIC_DISCOVERY',
  /** Google credentials provider */
  GOOGLE_CREDENTIALS = 'GOOGLE_CREDENTIALS'
}

Approval Modes

Tool execution approval modes that control how tools are confirmed before execution.

/**
 * Tool execution approval modes
 */
enum ApprovalMode {
  /** Default approval mode - prompt for confirmation */
  DEFAULT = 'default',
  /** Auto-approve edit operations */
  AUTO_EDIT = 'autoEdit',
  /** Auto-approve all operations (proceed without confirmation) */
  YOLO = 'yolo'
}

Storage Management

File system storage management for application data, settings, and temporary files.

/**
 * File system storage management for application data and settings
 */
class Storage {
  constructor(projectRoot?: string);
  
  // Global storage paths (static methods)
  static getGlobalGeminiDir(): string;
  static getMcpOAuthTokensPath(): string;
  static getGlobalSettingsPath(): string;
  static getInstallationIdPath(): string;
  static getGoogleAccountsPath(): string;
  static getUserCommandsDir(): string;
  static getGlobalMemoryFilePath(): string;
  static getGlobalTempDir(): string;
  static getGlobalBinDir(): string;
  static getOAuthCredsPath(): string;
  
  // Project-specific storage paths (instance methods)
  getGeminiDir(): string;
  getProjectTempDir(): string;
  ensureProjectTempDirExists(): void;
  getProjectRoot(): string;
  getHistoryDir(): string;
  getWorkspaceSettingsPath(): string;
  getProjectCommandsDir(): string;
  getProjectTempCheckpointsDir(): string;
  getExtensionsDir(): string;
  getExtensionsConfigPath(): string;
  getHistoryFilePath(): string;
}

MCP Server Configuration

Configuration for Model Context Protocol servers and their integration settings.

/**
 * Configuration for MCP (Model Context Protocol) servers
 */
class MCPServerConfig {
  constructor(
    command?: string,
    args?: string[],
    env?: Record<string, string>,
    cwd?: string,
    url?: string,
    httpUrl?: string,
    headers?: Record<string, string>,
    tcp?: string,
    timeout?: number,
    trust?: boolean
  );
}

interface MCPOAuthConfig {
  authorizationUrl: string;
  tokenUrl: string;
  clientId: string;
  scopes?: string[];
}

Configuration Interfaces

Detailed configuration interfaces for various application aspects.

/**
 * Accessibility configuration settings
 */
interface AccessibilitySettings {
  enableHighContrast?: boolean;
  enableLargeText?: boolean;
  enableScreenReader?: boolean;
}

/**
 * Bug reporting command settings
 */
interface BugCommandSettings {
  enabled: boolean;
  includeLogs?: boolean;
  includeConfig?: boolean;
}

/**
 * Chat compression configuration
 */
interface ChatCompressionSettings {
  enabled: boolean;
  threshold: number;
  targetSize: number;
}

/**
 * File filtering options for content discovery
 */
interface FileFilteringOptions {
  excludePatterns?: string[];
  includePatterns?: string[];
  maxFileSize?: number;
  excludeHidden?: boolean;
  respectGitIgnore?: boolean;
  respectGeminiIgnore?: boolean;
}

/**
 * Extension metadata and configuration
 */
interface GeminiCLIExtension {
  name: string;
  version: string;
  description?: string;
  author?: string;
  main: string;
  enabled: boolean;
  config?: Record<string, any>;
}

/**
 * Sandbox configuration for secure execution
 */
interface SandboxConfig {
  enabled: boolean;
  allowedCommands?: string[];
  restrictedPaths?: string[];
  timeoutMs?: number;
}

/**
 * Tool output summarization settings
 */
interface SummarizeToolOutputSettings {
  enabled: boolean;
  threshold: number;
  maxLength: number;
}

/**
 * Telemetry configuration settings
 */
interface TelemetrySettings {
  enabled: boolean;
  endpoint?: string;
  apiKey?: string;
  sampleRate?: number;
  includeErrorReports?: boolean;
}

Constants and Defaults

Default values and constants used throughout the configuration system.

/**
 * Default Gemini Flash model identifier
 */
const DEFAULT_GEMINI_FLASH_MODEL: string;

/**
 * Default file filtering configuration
 */
const DEFAULT_FILE_FILTERING_OPTIONS: FileFilteringOptions;

/**
 * Default memory file filtering options
 */
const DEFAULT_MEMORY_FILE_FILTERING_OPTIONS: FileFilteringOptions;

/**
 * Default tool output truncation threshold in characters
 */
const DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD: number;

/**
 * Default tool output truncation lines
 */
const DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES: number;

/**
 * Local gemini directory name
 */
const GEMINI_DIR: string;

/**
 * Google accounts file name
 */
const GOOGLE_ACCOUNTS_FILENAME: string;

/**
 * OAuth credentials file name
 */
const OAUTH_FILE: string;

Additional Type Definitions

Core types used throughout the configuration system.

/**
 * Content generator interface for AI model interactions
 */
interface ContentGenerator {
  generateContent(request: GenerateContentRequest): Promise<GenerateContentResponse>;
  generateContentStream(request: GenerateContentRequest): AsyncGenerator<GenerateContentResponse>;
  countTokens(request: CountTokensRequest): Promise<CountTokensResponse>;
  embedContent(request: EmbedContentRequest): Promise<EmbedContentResponse>;
}

/**
 * Configuration for content generators
 */
interface ContentGeneratorConfig {
  model: string;
  apiKey?: string;
  authType?: AuthType;
  projectId?: string;
  location?: string;
}

/**
 * Workspace context management for project awareness
 */
class WorkspaceContext {
  constructor(initialDirectories?: Set<string>);

  addDirectory(directory: string): void;
  removeDirectory(directory: string): void;
  getDirectories(): Set<string>;
  hasDirectory(directory: string): boolean;
  addListener(listener: () => void): void;
  removeListener(listener: () => void): void;
  clear(): void;
}

/**
 * Tool registry for managing available tools
 */
class ToolRegistry {
  constructor();

  addTool(tool: AnyDeclarativeTool): void;
  getTool(name: string): AnyDeclarativeTool | undefined;
  getTools(): AnyDeclarativeTool[];
  getFunctionDeclarations(): FunctionDeclaration[];
  removeTool(name: string): void;
  clear(): void;
}

/**
 * Base LLM client for model interactions
 */
class BaseLlmClient {
  constructor(config: Config);

  // Core client methods would be defined here
}

/**
 * File exclusion pattern management
 */
class FileExclusions {
  constructor();

  addExclusion(pattern: string): void;
  removeExclusion(pattern: string): void;
  isExcluded(filePath: string): boolean;
  getExclusions(): string[];
  clear(): void;
}

/**
 * Fallback model handler function type
 */
type FallbackModelHandler = (error: Error, currentModel: string) => Promise<string | null>;

Usage Examples:

import { Config, AuthType, ApprovalMode, Storage } from '@google/gemini-cli-core';

// Basic configuration
const config = new Config({
  model: 'gemini-1.5-flash',
  apiKey: process.env.GEMINI_API_KEY,
  approvalMode: ApprovalMode.AUTO_EDIT
});

// Advanced configuration with filtering and telemetry
const advancedConfig = new Config({
  model: 'gemini-1.5-pro',
  fileFilteringOptions: {
    excludePatterns: ['*.log', 'node_modules/**'],
    maxFileSize: 1024 * 1024, // 1MB
    respectGitIgnore: true
  },
  telemetrySettings: {
    enabled: true,
    sampleRate: 0.1
  },
  chatCompressionSettings: {
    enabled: true,
    threshold: 32000,
    targetSize: 16000
  }
});

// Storage management
const storage = new Storage('/path/to/project');
const geminiDir = storage.getGeminiDir();
const historyPath = storage.getHistoryFilePath();

// Global storage paths
const globalSettings = Storage.getGlobalSettingsPath();
const tempDir = Storage.getGlobalTempDir();

Install with Tessl CLI

npx tessl i tessl/npm-google--gemini-cli-core

docs

configuration.md

core-ai.md

ide-integration.md

index.md

mcp-oauth.md

services.md

telemetry.md

tools.md

utilities.md

tile.json