/** * LLM provider configuration persistence and runtime resolution. * * {@link LlmConfigManager} reads/writes the `~/.npm-safe/llm.json` file. The * configuration is optional: when no API key is configured and no supported * environment variable is present, LLM scanning is silently disabled and the * rest of the engine keeps working normally. * * API keys are stored in plain text at the configured path. The file is created * with `0o600` permissions when possible (best effort on Windows). */ import { LlmProviderType } from './provider.js'; import type { LlmScanProvider } from './provider.js'; /** Persisted LLM configuration. */ export interface LlmConfig { /** Whether LLM scanning is enabled. */ readonly enabled: boolean; /** Backend provider. */ readonly provider: LlmProviderType; /** API key (optional; environment variable fallback is supported). */ readonly apiKey?: string; /** Base URL of the LLM API endpoint. */ readonly baseUrl?: string; /** Model identifier to use. */ readonly model?: string; /** Request timeout in milliseconds. */ readonly timeoutMs?: number; /** Maximum README characters to send to the model. */ readonly maxInputChars?: number; /** Anthropic maximum response tokens. */ readonly maxTokens?: number; } /** Runtime status of the LLM integration, safe to display. */ export interface LlmStatus { /** Whether LLM scanning is enabled. */ readonly enabled: boolean; /** Backend provider. */ readonly provider: LlmProviderType; /** Whether an API key is available (from config or env). */ readonly configured: boolean; /** Model identifier in use, if any. */ readonly model?: string; /** Base URL in use, if any. */ readonly baseUrl?: string; /** Masked API key (e.g. `"sk-****1234"`), or `undefined`. */ readonly apiKey?: string; /** Maximum response tokens, if set. */ readonly maxTokens?: number; /** Maximum input characters, if set. */ readonly maxInputChars?: number; } /** Returns the default path for the LLM configuration file. */ export declare function getDefaultLlmConfigPath(): string; /** * Loads, mutates, and persists LLM provider configuration. * * Thread-safe per instance; concurrent instances may race on the file, which is * acceptable for a single-user desktop tool. */ export declare class LlmConfigManager { private readonly filePath; private config; constructor(filePath?: string); /** Load (or initialize) the config file. */ private load; /** Persist the current configuration to disk. */ private save; /** Normalize a partial config into a full config with defaults. */ private normalize; /** Returns the current persisted config, including the raw API key. */ getConfig(): LlmConfig; /** Returns a masked status view suitable for display. */ getStatus(): LlmStatus; /** Update the persisted config. */ setConfig(update: Partial): void; /** * Resolve the effective API key, preferring the persisted config and falling * back to a provider-specific environment variable. */ private resolveApiKey; /** Resolve the effective base URL. */ private resolveBaseUrl; /** Resolve the effective model. */ private resolveModel; /** * Create a configured {@link LlmScanProvider} if LLM scanning is enabled and * an API key is available; otherwise return `undefined`. */ createProvider(): LlmScanProvider | undefined; /** * Test whether the current configuration can connect to the provider. * * Returns `false` when the provider is not configured or disabled. */ testConnection(): Promise; } //# sourceMappingURL=llm-config.d.ts.map