/**
 * CLIProxy Service Manager
 *
 * Manages CLIProxyAPI as a background service for the CCS dashboard.
 * Ensures the proxy is running when needed for:
 * - Control Panel integration (management.html)
 * - Stats fetching
 * - OAuth flows
 *
 * Unlike cliproxy-executor.ts which runs proxy per-session,
 * this module manages a persistent background instance.
 */
import { ensureCLIProxyBinary } from './binary-manager';
import { configNeedsRegeneration } from './config/config-generator';
import { detectRunningProxy } from './proxy/proxy-detector';
import { withStartupLock } from './services/startup-lock';
import { type RefreshResult } from './auth/token-refresh-worker';
export interface ServiceStartResult {
    started: boolean;
    alreadyRunning: boolean;
    port: number;
    configRegenerated?: boolean;
    error?: string;
}
/**
 * Test-only seams for ensureCliproxyService. Production callers omit this and
 * get the real implementations. Tests inject stubs to avoid bun's
 * `mock.module()`, which is process-wide and leaks across test files.
 */
export interface EnsureCliproxyServiceDeps {
    ensureBinaryFn?: typeof ensureCLIProxyBinary;
    detectRunningProxyFn?: typeof detectRunningProxy;
    configNeedsRegenerationFn?: typeof configNeedsRegeneration;
    withStartupLockFn?: typeof withStartupLock;
}
/**
 * Ensure CLIProxy service is running
 *
 * If proxy is already running, returns immediately.
 * If not, spawns a new background instance.
 *
 * @param port CLIProxy port (default: 8317)
 * @param verbose Show debug output
 * @param deps Test-only dependency overrides (see EnsureCliproxyServiceDeps)
 * @returns Result indicating success and whether it was already running
 */
export declare function ensureCliproxyService(port?: number, verbose?: boolean, deps?: EnsureCliproxyServiceDeps): Promise<ServiceStartResult>;
/**
 * Stop the managed CLIProxy service
 */
export declare function stopCliproxyService(): boolean;
/**
 * Get service status
 */
export declare function getServiceStatus(port?: number): Promise<{
    running: boolean;
    managedByUs: boolean;
    port: number;
}>;
/**
 * Check if token refresh worker is running
 */
export declare function isTokenRefreshWorkerRunning(): boolean;
/**
 * Get token refresh worker status
 */
export declare function getTokenRefreshStatus(): {
    running: boolean;
    lastResults: RefreshResult[] | null;
};
//# sourceMappingURL=service-manager.d.ts.map