/**
 * Remote secrets — read and use `agents secrets` bundles that live on another
 * host over the same SSH path that `agents secrets export --device` uses.
 *
 * Browse streams remote stdout verbatim; use resolves a bundle to an env map
 * and injects it ephemerally without persisting it locally.
 */
import { type SshExecResult } from '../ssh-exec.js';
export declare const REMOTE_TIMEOUT_MS = 30000;
export interface RemoteSecretsRawOptions {
    tty?: boolean;
    input?: string;
    osLookupName?: string;
    secret?: boolean;
    timeoutMs?: number;
}
/**
 * SSH options for secret-carrying transport. Pins the managed host key and
 * disables multiplex so no reusable control socket lingers for other invocations.
 */
export declare function credentialTransportSshOpts(target: string): {
    hostKeyOpts: string[];
    multiplex: false;
};
/** Refuse durable credential transfer until the destination SSH key is pinned. */
export declare function assertCredentialTransportHostPinned(target: string, pinned?: boolean): void;
/**
 * Trust boundary for a remote-resolved env map. A peer's export output is
 * untrusted input that could reshape this process once merged into the env, so
 * block dangerous override classes here for every consumer:
 * loader/interpreter vars, GIT_*, *_PROXY, and *_BASE_URL.
 */
export declare function isDangerousRemoteEnvKey(name: string): boolean;
/**
 * Resolve a `--device` value to an ssh target string for the remote-secrets
 * path. Delegates to the same resolver `run --device` uses; on a miss, treats
 * the value as a raw ssh target and validates it.
 */
export declare function resolveHostSshTarget(nameOrAlias: string): Promise<string>;
/**
 * Merge `--host` / `--hosts` (and their `--device` / `--devices` aliases) into
 * an ordered, de-duplicated list. Empty when none is set.
 */
export declare function parseHostsOption(opts: {
    host?: string;
    hosts?: string;
    device?: string;
    devices?: string;
}): string[];
/**
 * Split a `bundle@host` reference. No `@` → a local bundle. Bundle names can't
 * contain `@`, so the FIRST `@` separates bundle from ssh target; the target
 * itself may be `user@host` (e.g. `r2.backups@muqsit@box`).
 */
export declare function splitBundleRef(ref: string): {
    bundle: string;
    host?: string;
};
/**
 * Run `agents secrets <args>` on a remote host over ssh and return the raw
 * result. Used by browse commands; `tty` forces `-tt` so remote passphrase
 * prompts can surface.
 */
export declare function remoteSecretsRaw(target: string, args: string[], opts?: RemoteSecretsRawOptions): SshExecResult;
/** Async, kill-bounded inverse of {@link remoteSecretsRaw} for daemon callers. */
export declare function remoteSecretsRawAsync(target: string, args: string[], opts?: RemoteSecretsRawOptions): Promise<SshExecResult>;
/**
 * Run a remote `agents secrets <args>` foreground with local stdio inherited,
 * so the remote sees a real TTY and its passphrase prompt surfaces and reads
 * keystrokes. Output streams to the terminal; only the exit code is returned.
 */
export declare function remoteSecretsStream(target: string, args: string[], opts?: {
    osLookupName?: string;
}): number;
/**
 * Resolve a remote bundle to a plaintext env map by driving the remote's
 * `agents secrets export <bundle> --plaintext --format json`. Values cross over
 * ssh stdout, parsed in memory, never persisted.
 *
 * The remote unlocks the bundle with its own credentials; this machine does NOT
 * forward its passphrase because the remote bundle is encrypted with the
 * remote's passphrase.
 */
export declare function remoteResolveEnv(target: string, bundle: string, opts?: {
    osLookupName?: string;
}): Promise<Record<string, string>>;
/**
 * Outcome of a post-push read-back verification.
 *   - `ok`              — the pushed keys materialized readably.
 *   - `locked-keychain` — read-back gave the specific locked-keychain signal.
 *   - `error`           — a different failure (SSH, timeout, etc.).
 */
export type RemoteKeychainWriteVerification = {
    ok: true;
} | {
    ok: false;
    kind: 'locked-keychain';
    reason: string;
} | {
    ok: false;
    kind: 'error';
    reason: string;
};
/**
 * Decide whether a keychain-backed push to a remote actually persisted its
 * secret value items by reading the bundle back the same way a later resolve
 * will. Catches the silent failure where headless SSH writes metadata but not
 * readable value items to a locked macOS login keychain.
 */
export declare function evaluateKeychainWriteVerification(pushedKeys: string[], readBack: {
    ok: true;
    keys: string[];
} | {
    ok: false;
    stderr: string;
}): RemoteKeychainWriteVerification;
/**
 * Actionable error message for a failed keychain-over-SSH push. Names the cause
 * (locked remote login keychain) and steers to the two real fixes.
 */
export declare function keychainWriteFailureMessage(host: string, bundle: string, reason: string): string;
/**
 * Read a bundle back from a remote over SSH and confirm the pushed keys
 * materialized. Drives the marker-gated json transport but keeps only KEY NAMES;
 * plaintext values are discarded immediately. Returns a verification verdict.
 */
export declare function verifyRemoteKeychainPush(target: string, bundle: string, pushedKeys: string[], opts?: {
    osLookupName?: string;
    secret?: boolean;
    timeoutMs?: number;
}): RemoteKeychainWriteVerification;
/** Async, kill-bounded read-back verification for daemon-originated pushes. */
export declare function verifyRemoteKeychainPushAsync(target: string, bundle: string, pushedKeys: string[], opts?: {
    osLookupName?: string;
    secret?: boolean;
    timeoutMs?: number;
}): Promise<RemoteKeychainWriteVerification>;
/**
 * `bash -lc` command + stdin payload for a file-backed remote import.
 *
 * The file store is passphrase-free: the remote auto-provisions its own machine-
 * local key, so reads are headless. AGENTS_SECRETS_PASSPHRASE must NOT be
 * forwarded (PHNX-2371): a remote keyed to a secret its daemon does not hold
 * reports "Imported N key(s)" then fails every later decrypt.
 */
export declare function buildRemoteFileImportCommand(bundle: string, dotenv: string, opts?: {
    force?: boolean;
    policyNever?: boolean;
}): {
    remoteCmd: string;
    input: string;
};
