/**
 * Settings manager — two-tier (global + project) JSON settings with file locking.
 *
 * Global settings live at ~/.shortcut/agent/settings.json.
 * Project settings live at <cwd>/.shortcut/settings.json and override globals.
 * Both are deep-merged at read time; writes go to the appropriate scope.
 *
 * Tracks which fields were modified in-session so saves only touch those
 * keys, preserving hand-edits in unrelated parts of the file.
 */
import type { Transport } from '../ai/types.js';
import type { RuntimeErrorRecoverySettings } from '../contracts/agent-settings.js';
import type { RuntimeFilesystemApprovalGrant } from '../core/permission-policy.js';
import { type RuntimePermissioningSettings } from './permissions/settings.js';
/** Display labels for the approval mode (footer + /settings). */
export declare const APPROVAL_MODE: {
    readonly ASK: "Ask before spreadsheet changes";
    readonly AUTO: "Auto-approve spreadsheet changes";
};
export interface RetrySettings {
    enabled?: boolean;
    maxRetries?: number;
    baseDelayMs?: number;
    maxDelayMs?: number;
}
export interface BudgetContinuationSettings {
    enabled?: boolean;
    budgetTokens?: number;
    windDownPct?: number;
    minTokensPerContinuation?: number;
    stuckWindow?: number;
    maxTurns?: number;
    maxToolUses?: number;
}
export interface ToolSummariesSettings {
    enabled?: boolean;
}
export interface DurableMemorySettings {
    enabled?: boolean;
}
export interface TerminalSettings {
    showImages?: boolean;
    clearOnShrink?: boolean;
}
export interface ImageSettings {
    autoResize?: boolean;
    blockImages?: boolean;
}
export interface MarkdownSettings {
    codeBlockIndent?: string;
}
/** Metadata for a configured external connection (secrets stored in OS keychain). */
export interface ConnectionMetadata {
    fields: string[];
}
export type ConnectionsSettings = Record<string, ConnectionMetadata>;
export interface SandboxSettings {
    mode?: 'enabled' | 'disabled';
    readPaths?: string[];
    writePaths?: string[];
    network?: 'none' | 'proxy' | 'full';
    allowedDomains?: string[];
}
export interface RemoteControlSettings {
    enabled?: boolean;
    provider?: 'whatsapp';
}
export interface McpOAuthSettings {
    credentialsStoreMode?: 'file' | 'keychain' | 'auto';
    callbackPort?: number;
    callbackUrl?: string;
}
/** Concrete sandbox defaults — always called at runtime so paths resolve correctly. */
export declare function getDefaultSandboxSettings(): Required<SandboxSettings>;
export type TransportSetting = Transport;
/**
 * Package source for npm/git packages.
 * - String form: load all resources from the package
 * - Object form: filter which resources to load
 */
export type PackageSource = string | {
    source: string;
    extensions?: string[];
    skills?: string[];
    prompts?: string[];
    themes?: string[];
};
/** The full settings schema — persisted as JSON in global and project settings files. */
export interface Settings {
    permissioning?: RuntimePermissioningSettings;
    workspaces?: string[];
    filesystemApprovals?: RuntimeFilesystemApprovalGrant[];
    lastChangelogVersion?: string;
    defaultProvider?: string;
    defaultModel?: string;
    defaultThinkingLevel?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
    transport?: TransportSetting;
    steeringMode?: 'all' | 'one-at-a-time';
    followUpMode?: 'all' | 'one-at-a-time';
    theme?: string;
    retry?: RetrySettings;
    hideThinkingBlock?: boolean;
    shellPath?: string;
    quietStartup?: boolean;
    shellCommandPrefix?: string;
    collapseChangelog?: boolean;
    packages?: PackageSource[];
    extensions?: string[];
    skills?: string[];
    disabledSkills?: string[];
    prompts?: string[];
    themes?: string[];
    enableSkillCommands?: boolean;
    terminal?: TerminalSettings;
    images?: ImageSettings;
    doubleEscapeAction?: 'fork' | 'tree' | 'none';
    editorPaddingX?: number;
    autocompleteMaxVisible?: number;
    showHardwareCursor?: boolean;
    markdown?: MarkdownSettings;
    sandbox?: SandboxSettings;
    newSheet?: boolean;
    autoApprove?: boolean;
    telemetry?: boolean;
    devMode?: boolean;
    connections?: ConnectionsSettings;
    showCacheTokens?: boolean;
    budgetContinuation?: BudgetContinuationSettings;
    toolSummaries?: ToolSummariesSettings;
    durableMemory?: DurableMemorySettings;
    modelFallback?: {
        enabled?: boolean;
        fallbackModel?: string;
        stripThinking?: boolean;
    };
    remoteControl?: RemoteControlSettings;
    mcpOAuth?: McpOAuthSettings;
}
export type SettingsScope = 'global' | 'project';
export interface SettingsStorage {
    withLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void;
}
export interface SettingsError {
    scope: SettingsScope;
    error: Error;
}
/** File-backed settings storage with proper-lockfile concurrency control. */
export declare class FileSettingsStorage implements SettingsStorage {
    private globalSettingsPath;
    private projectSettingsPath;
    constructor(cwd?: string, agentDir?: string);
    withLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void;
}
/** In-memory settings storage for tests — no file I/O. */
export declare class InMemorySettingsStorage implements SettingsStorage {
    private global;
    private project;
    withLock(scope: SettingsScope, fn: (current: string | undefined) => string | undefined): void;
}
/**
 * Manages merged global + project settings with scoped persistence.
 *
 * Read accessors return the deep-merged view. Write accessors update the
 * appropriate scope (global or project), mark the field dirty, and enqueue
 * a file-locked write that only touches modified keys.
 */
export declare class SettingsManager {
    private storage;
    private globalSettings;
    private projectSettings;
    private settings;
    private dangerouslySkipRuntimePermissionsOverride;
    private dangerouslySkipSpreadsheetPermissionsOverride;
    private modifiedFields;
    private modifiedNestedFields;
    private modifiedProjectFields;
    private modifiedProjectNestedFields;
    private globalSettingsLoadError;
    private projectSettingsLoadError;
    private writeQueue;
    private errors;
    private constructor();
    /** Create a SettingsManager that loads from files */
    static create(cwd?: string, agentDir?: string): SettingsManager;
    /** Create a SettingsManager from an arbitrary storage backend */
    static fromStorage(storage: SettingsStorage): SettingsManager;
    /** Create an in-memory SettingsManager (no file I/O) */
    static inMemory(settings?: Partial<Settings>): SettingsManager;
    private static loadFromStorage;
    private static tryLoadFromStorage;
    /** Migrate old settings format to new format */
    private static migrateSettings;
    getEffectivePermissioningSettings(): RuntimePermissioningSettings;
    getGlobalSettings(): Settings;
    getProjectSettings(): Settings;
    reload(): void;
    /** Apply additional overrides on top of current settings */
    applyOverrides(overrides: Partial<Settings>): void;
    /** Mark a global field as modified during this session */
    private markModified;
    /** Mark a project field as modified during this session */
    private markProjectModified;
    private recordError;
    private clearModifiedScope;
    private enqueueWrite;
    private cloneModifiedNestedFields;
    private persistScopedSettings;
    private save;
    private saveProjectSettings;
    flush(): Promise<void>;
    drainErrors(): SettingsError[];
    getLastChangelogVersion(): string | undefined;
    setLastChangelogVersion(version: string): void;
    getDefaultProvider(): string | undefined;
    getDefaultModel(): string | undefined;
    setDefaultProvider(provider: string): void;
    setDefaultModel(modelId: string): void;
    setDefaultModelAndProvider(provider: string, modelId: string): void;
    getSteeringMode(): 'all' | 'one-at-a-time';
    getFollowUpMode(): 'all' | 'one-at-a-time';
    getTheme(): string | undefined;
    setTheme(theme: string): void;
    getDefaultThinkingLevel(): 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | undefined;
    setDefaultThinkingLevel(level: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'): void;
    getTransport(): TransportSetting;
    getRetryEnabled(): boolean;
    setRetryEnabled(enabled: boolean): void;
    getRetrySettings(): {
        enabled: boolean;
        maxRetries: number;
        baseDelayMs: number;
        maxDelayMs: number;
    };
    getErrorRecoverySettings(): RuntimeErrorRecoverySettings;
    getBudgetContinuationSettings(): {
        enabled: boolean;
        budgetTokens: number;
        windDownPct: number;
        minTokensPerContinuation: number;
        stuckWindow: number;
        maxTurns: number;
        maxToolUses: number;
    };
    getHideThinkingBlock(): boolean;
    setHideThinkingBlock(hide: boolean): void;
    getShellPath(): string | undefined;
    setShellPath(path: string | undefined): void;
    getQuietStartup(): boolean;
    setQuietStartup(quiet: boolean): void;
    getShellCommandPrefix(): string | undefined;
    setShellCommandPrefix(prefix: string | undefined): void;
    getCollapseChangelog(): boolean;
    setCollapseChangelog(collapse: boolean): void;
    getPackages(): PackageSource[];
    setPackages(packages: PackageSource[]): void;
    setProjectPackages(packages: PackageSource[]): void;
    getExtensionPaths(): string[];
    setExtensionPaths(paths: string[]): void;
    setProjectExtensionPaths(paths: string[]): void;
    getSkillPaths(): string[];
    setSkillPaths(paths: string[]): void;
    setProjectSkillPaths(paths: string[]): void;
    getDisabledSkills(): string[];
    setDisabledSkills(names: string[]): void;
    isSkillDisabled(name: string): boolean;
    disableSkill(name: string): void;
    enableSkill(name: string): void;
    getPromptTemplatePaths(): string[];
    setPromptTemplatePaths(paths: string[]): void;
    setProjectPromptTemplatePaths(paths: string[]): void;
    getThemePaths(): string[];
    setThemePaths(paths: string[]): void;
    setProjectThemePaths(paths: string[]): void;
    getEnableSkillCommands(): boolean;
    getShowImages(): boolean;
    setShowImages(show: boolean): void;
    getClearOnShrink(): boolean;
    getImageAutoResize(): boolean;
    getBlockImages(): boolean;
    getDoubleEscapeAction(): 'tree' | 'none';
    getShowHardwareCursor(): boolean;
    getEditorPaddingX(): number;
    getAutocompleteMaxVisible(): number;
    getCodeBlockIndent(): string;
    getNewSheet(): boolean;
    setNewSheet(enabled: boolean): void;
    getSandboxSettings(): SandboxSettings;
    getWorkspaceRoots(): string[];
    setWorkspaceRoots(paths: string[]): void;
    getFilesystemApprovals(): RuntimeFilesystemApprovalGrant[];
    addFilesystemApproval(grant: RuntimeFilesystemApprovalGrant): void;
    removeFilesystemApproval(grant: RuntimeFilesystemApprovalGrant): void;
    getSandboxMode(): 'enabled' | 'disabled';
    /** Ensure globalSettings.sandbox exists with full defaults. */
    private ensureSandboxDefaults;
    setSandboxMode(mode: 'enabled' | 'disabled'): void;
    getSandboxNetworkMode(): 'none' | 'proxy' | 'full';
    setSandboxNetworkMode(mode: 'none' | 'proxy' | 'full'): void;
    getSandboxAllowedDomains(): string[];
    setSandboxAllowedDomains(domains: string[]): void;
    addSandboxAllowedDomain(domain: string): void;
    setSandboxReadPaths(paths: string[]): void;
    setSandboxWritePaths(paths: string[]): void;
    resetSandboxToDefaults(): void;
    /** Get the persistent default (what new sessions start with). */
    getAutoApproveDefault(): boolean;
    /** Get the session-start default after applying non-persistent CLI overrides. */
    getSessionAutoApproveDefault(): boolean;
    getDangerouslySkipRuntimePermissions(): boolean;
    getDangerouslySkipSpreadsheetPermissions(): boolean;
    setDangerouslySkipRuntimePermissionsOverride(enabled: boolean | undefined): void;
    setDangerouslySkipSpreadsheetPermissionsOverride(enabled: boolean | undefined): void;
    setDangerouslySkipRuntimePermissions(enabled: boolean): void;
    /** Persist the default used to initialize new session approval state. */
    setAutoApproveDefault(autoApprove: boolean): void;
    /** Whether session traces and ClickHouse logs are uploaded. Default: true. */
    getTelemetry(): boolean;
    setTelemetry(enabled: boolean): void;
    /** Whether dev mode is enabled (AGENTS.md, dev resources, verbose logging). Default: false. */
    getDevMode(): boolean;
    setDevMode(enabled: boolean): void;
    /** Get all connection metadata (names, types, field names — no secrets). */
    getConnections(): ConnectionsSettings;
    /** Get metadata for a single connection. */
    getConnection(name: string): ConnectionMetadata | undefined;
    /** Get all connection names. */
    getConnectionNames(): string[];
    /** Set metadata for a connection (secrets go to OS keychain, not here). */
    setConnection(name: string, metadata: ConnectionMetadata): void;
    /** Whether to show cache read/write tokens (R/W) in footer. Default: false. */
    getShowCacheTokens(): boolean;
    setShowCacheTokens(enabled: boolean): void;
    getToolSummariesEnabled(): boolean;
    setToolSummariesEnabled(enabled: boolean): void;
    getDurableMemoryEnabled(): boolean;
    getRemoteControlEnabled(): boolean;
    getRemoteControlProvider(): RemoteControlSettings['provider'];
    getMcpOAuthSettings(): Required<McpOAuthSettings>;
    setMcpOAuthSettings(settings: McpOAuthSettings): void;
    setRemoteControl(config: RemoteControlSettings): void;
    setDurableMemoryEnabled(enabled: boolean): void;
    /** Remove a connection's metadata. */
    removeConnection(name: string): void;
}
//# sourceMappingURL=settings-manager.d.ts.map