/**
 * Shared versioned directory upgrade logic for kici-admin upgrade commands.
 *
 * Implements the versioned directory layout:
 * - Extract new version alongside old versions
 * - Update symlink (Unix) or service registration (Windows) atomically
 * - Preserve old versions for rollback
 * - Optional cleanup of old versions
 */
import { type ResolvedInstance, type ServiceManager, type ServicePlatform } from '../../service/index.js';
import type { ServiceConfig } from '../../service/types.js';
/** Component types that can be upgraded. */
type UpgradeComponent = 'orchestrator' | 'agent';
/** Options for the versioned upgrade command. */
interface VersionedUpgradeOptions {
    platform?: ServicePlatform;
    /**
     * Service name. No default — targeting flows through {@link resolveInstance}
     * which consumes `name`, `instanceDir`, or the CWD manifest in priority order.
     */
    name?: string;
    /** Deploy folder of the instance to upgrade. */
    instanceDir?: string;
    from?: string;
    url?: string;
    version?: string;
    yes?: boolean;
    cleanup?: boolean;
    rollback?: boolean;
    force?: boolean;
}
/**
 * Resolved upgrade target: the manifest-backed ServiceConfig the upgrade
 * flow operates on, the manifest's installBase (NOT re-derived from name),
 * and the underlying resolved instance for downstream writes.
 */
export interface UpgradeTarget {
    config: ServiceConfig;
    installBase: string;
    resolvedInstance: ResolvedInstance;
}
/**
 * Resolve the upgrade target via the folder-anchored model and build the
 * ServiceConfig + installBase the rest of the upgrade flow needs.
 *
 * Priority chain (delegated to {@link resolveInstance}):
 *   1. `opts.instanceDir` — read manifest at that path.
 *   2. `opts.name`        — match against listInstances() output.
 *   3. CWD manifest       — read `./.kici-<component>.json`.
 *   4. otherwise          — refuse with a candidate-list error.
 *
 * The returned `installBase` comes from the manifest, NEVER re-derived from
 * the service name. Instances installed with a non-default base must
 * continue to resolve to that base on upgrade.
 */
export declare function resolveUpgradeTarget(args: {
    component: UpgradeComponent;
    opts: {
        instanceDir?: string;
        name?: string;
    };
    manager: ServiceManager;
    isUserLevel: boolean;
    kiciRoot: string;
}): Promise<UpgradeTarget>;
/**
 * Install base for a KiCI component instance.
 *
 * Name-scoped so that two instances of the same component (e.g. an org's
 * dogfood orchestrator and an E2E test orchestrator) own independent
 * versioned trees and symlinks. Per-platform bases:
 *   - systemd / compose: /opt/kici/<name>/
 *   - launchd:           /usr/local/kici/<name>/
 *   - windows:           C:\Program Files\KiCI\<name>\
 */
export declare function getInstallBase(platform: ServicePlatform, name: string): string;
/**
 * Perform a versioned directory upgrade for a KiCI component.
 *
 * Flow:
 * 1. Parse upgrade source (--from archive or --url)
 * 2. Determine install base by platform
 * 3. Extract new versioned directory
 * 4. Stop service
 * 5. Update symlink (Unix) or service registration (Windows)
 * 6. Start service
 */
export declare function performVersionedUpgrade(component: UpgradeComponent, opts: VersionedUpgradeOptions): Promise<void>;
export {};
//# sourceMappingURL=versioned-upgrade.d.ts.map