/**
 * Settings Service
 *
 * Server-side key-value settings persisted to SQLite.
 * Used for workspace-wide configuration that needs to be accessible server-side,
 * such as default executable paths for agent providers.
 *
 * Settings are stored in the `settings` table as JSON-encoded values.
 */
import type { StorageBackend } from '@stoneforge/storage';
/**
 * A setting stored in the database
 */
export interface Setting {
    key: string;
    value: unknown;
    updatedAt: string;
}
/**
 * Agent defaults configuration
 */
export interface ServerAgentDefaults {
    /** Provider name → executable path (e.g. { claude: '/usr/local/bin/claude-dev' }) */
    defaultExecutablePaths: Record<string, string>;
    /** Ordered list of executable names/paths for rate limit fallback. When one hits its limit, the next available is used. */
    fallbackChain?: string[];
}
/**
 * Sync direction for external sync
 */
export type SyncDirection = 'push' | 'pull' | 'bidirectional';
/**
 * Provider configuration stored in settings (SQLite, NOT git-tracked)
 */
export interface ProviderConfig {
    /** Provider name (e.g. 'github', 'linear') */
    provider: string;
    /** Authentication token */
    token?: string;
    /** API base URL (for self-hosted instances) */
    apiBaseUrl?: string;
    /** Default project/repo for this provider */
    defaultProject?: string;
}
/**
 * External sync settings stored in SQLite (tokens, cursors, runtime state)
 */
export interface ExternalSyncSettings {
    /** Provider configurations keyed by provider name */
    providers: Record<string, ProviderConfig>;
    /** Sync cursors keyed by provider+project+adapterType */
    syncCursors: Record<string, string>;
    /** Poll interval in milliseconds */
    pollIntervalMs: number;
    /** Default sync direction */
    defaultDirection: SyncDirection;
}
/**
 * Well-known setting keys
 */
export declare const SETTING_KEYS: {
    readonly AGENT_DEFAULTS: "agentDefaults";
    readonly RATE_LIMITS: "rateLimits";
    readonly EXTERNAL_SYNC: "externalSync";
};
export interface SettingsService {
    /**
     * Get a setting by key
     */
    getSetting(key: string): Setting | undefined;
    /**
     * Set a setting (upsert)
     */
    setSetting(key: string, value: unknown): Setting;
    /**
     * Delete a setting by key
     * @returns true if the setting existed and was deleted
     */
    deleteSetting(key: string): boolean;
    /**
     * Get agent defaults (convenience method)
     */
    getAgentDefaults(): ServerAgentDefaults;
    /**
     * Update agent defaults (convenience method)
     */
    setAgentDefaults(defaults: ServerAgentDefaults): ServerAgentDefaults;
    /**
     * Get external sync settings (convenience method)
     */
    getExternalSyncSettings(): ExternalSyncSettings;
    /**
     * Update external sync settings (convenience method)
     */
    setExternalSyncSettings(settings: ExternalSyncSettings): ExternalSyncSettings;
    /**
     * Get a specific provider's configuration
     */
    getProviderConfig(provider: string): ProviderConfig | undefined;
    /**
     * Set a specific provider's configuration
     */
    setProviderConfig(provider: string, config: ProviderConfig): ProviderConfig;
}
export declare function createSettingsService(storage: StorageBackend): SettingsService;
//# sourceMappingURL=settings-service.d.ts.map