import { type ProfileDeclaration } from './registry.js';
import { type BrowserProfile, type ConnectionKey } from './types.js';
import type { BrowserProfileConfig } from '../types.js';
export type DeviceProbeResult = {
    reachable: true;
    os?: string;
} | {
    reachable: false;
    reason: string;
};
export type DeviceProbe = (device: string) => DeviceProbeResult;
export interface ResolvedBrowserTarget {
    name: string;
    kind: 'identity' | 'fungible';
    /** Device the daemon will talk to. */
    device: string;
    local: boolean;
    key: ConnectionKey;
    /** `cdp:` locally, `ssh:` when tunnelling to a declaring device. */
    target: string;
    profile: BrowserProfile;
    /**
     * Human line when the daemon picked a remote device. Command output
     * surfaces this so the caller knows WHERE the browser actually lives.
     */
    picked?: string;
}
/** Fork only fungible Electron profiles; identity-bearing ones share one connection. */
export declare function shouldForkProfile(kind: 'identity' | 'fungible', conn: {
    electron?: boolean;
    tasks: {
        size: number;
    };
}): boolean;
export declare function profileFromDeclaration(name: string, declaration: ProfileDeclaration): BrowserProfile;
/** Runtime key: profile name plus the resolved device. Drops `@endpoint-N`. */
export declare function profileConnectionKey(profileName: string, device: string): ConnectionKey;
/** Declared names that look like `query` — used in the undeclared error. */
export declare function similarProfileNames(query: string, names: string[]): string[];
export declare function undeclaredProfileError(name: string): Error;
export declare function unreachableDeclaringDevicesError(name: string, devices: string[], failures: string[]): Error;
export declare function sshEndpointForDeclaration(device: string, config: BrowserProfileConfig, endpointName?: string, os?: string): string;
/**
 * Decide where `name` connects. Never claims a central leftover. Never
 * falls back to a local browser when the name is declared elsewhere.
 */
export declare function resolveBrowserTarget(name: string, opts?: {
    endpointName?: string;
    here?: string;
    probe?: DeviceProbe;
}): ResolvedBrowserTarget;
/**
 * Rename a leftover `<name>@endpoint-N` runtime dir to the new
 * `<name>@<device>` key so logins in chrome-data are not orphaned.
 *
 * Only when exactly one legacy dir exists and the destination does not —
 * several endpoint dirs stay put so a multi-endpoint profile is not merged.
 */
/**
 * Adopt a leftover `@endpoint-N` runtime dir onto the new key ONLY for a
 * local connect. Doing this for a tunnel key would rename this machine's
 * pre-T2 logged-out chrome-data onto `comet-local@zion`, and connectProfile
 * would then attach localhost CDP instead of tunnelling.
 */
export declare function adoptLegacyRuntimeIfLocal(local: boolean, profileName: string, newKey: ConnectionKey, runtimeRoot: string): void;
export declare function migrateLegacyRuntimeDir(profileName: string, newKey: ConnectionKey, runtimeRoot: string): void;
/** True when a live key is a leftover `@endpoint-N` key of `profileName`. */
export declare function isLegacyEndpointKey(key: string, profileName: string): boolean;
