import type { MoveAnswer } from "../../core/session-move/move-ledger.ts";
import type { RpcCommand } from "./rpc-host-command-types.ts";
import type { RpcSessionPresence } from "./rpc-host-response-types.ts";
import type { RpcSessionState } from "./rpc-session-state-types.ts";
/** What a caller sends and hears for a repository identity; `rootCommits` is mutable as it arrives off the wire. */
export interface RpcRepositoryIdentity {
    rootCommits: string[];
    originUrl?: string;
}
/** Capability: the host answers `move_session` (senpi#3676). */
export declare const MOVE_SESSION_CAPABILITY = "move_session";
/** Capability: `move_session` answers op `revoke`, which seals a copy this host imported (senpi#4003). */
export declare const MOVE_SESSION_REVOKE_CAPABILITY = "move_session_revoke";
/** Capability: `move_session` answers op `copy`, which copies a session into a new one under a given id (senpi#5889). */
export declare const MOVE_SESSION_COPY_CAPABILITY = "move_session_copy";
/** Capability: `export` takes `inline` and answers `inline_files` for a bundle under the cap (senpi#6267). */
export declare const MOVE_SESSION_EXPORT_INLINE_CAPABILITY = "move_session_export_inline";
/** Capability: `import` takes `files`, an inline bundle, in place of `bundleDir` (senpi#6267). */
export declare const MOVE_SESSION_IMPORT_FILES_CAPABILITY = "move_session_import_files";
/** Capability: `import` takes `sessionDir`, the folder the session lands in (senpi#6267). */
export declare const MOVE_SESSION_IMPORT_SESSION_DIR_CAPABILITY = "move_session_import_session_dir";
/** Capability: `import` takes `open` and answers the opened session beside the import (senpi#6267). */
export declare const MOVE_SESSION_IMPORT_OPEN_CAPABILITY = "move_session_import_open";
/** The most raw bytes, over every file with the manifest, a bundle may hold to travel inline (senpi#6267). */
export declare const MOVE_INLINE_MAX_BYTES: number;
/** The most files an inline bundle may list. */
export declare const MOVE_INLINE_MAX_FILES = 1024;
/** Capability: the inline cap in bytes, as `move_session_inline_max_bytes:<n>`, so a caller can read it (senpi#6267). */
export declare const MOVE_SESSION_INLINE_MAX_BYTES_CAPABILITY = "move_session_inline_max_bytes:1048576";
/** Capability: `move_session` answers op `identity`, in both its forms, without releasing anything (senpi#6435). */
export declare const MOVE_SESSION_IDENTITY_CAPABILITY = "move_session_identity";
/** Capability: op `prepare` checks `cwd` against `repository`, and the import lands only there (senpi#6435). */
export declare const MOVE_SESSION_PREPARE_REPOSITORY_CAPABILITY = "move_session_prepare_repository";
/**
 * Capability: `status` for an accepted move, and a `move_fenced` refusal of a move already accepted here (an `import`
 * into another folder, a `prepare` for another folder), answer where it landed (senpi#6436).
 */
export declare const MOVE_SESSION_STATUS_LANDED_PATH_CAPABILITY = "move_session_status_landed_path";
/**
 * Capability: where an accepted move landed is answered with `writable`, and with `sealed_by` when the copy there is
 * read-only (senpi#6473).
 */
export declare const MOVE_SESSION_STATUS_WRITABLE_CAPABILITY = "move_session_status_writable";
/**
 * Capability: `status` takes `landing`, the place the move would have landed, and answers from the session file there
 * before it answers from its record. A move that landed and whose record was lost then answers `accepted`.
 */
export declare const MOVE_SESSION_STATUS_LANDING_CAPABILITY = "move_session_status_landing";
/** A `move_session` request whose fields do not parse (op, move id, paths, answer). */
export declare const RPC_ERROR_INVALID_MOVE_REQUEST = "invalid_move_request";
/** `export` of a session this host still has open: release it with `release_session` reason `move` first. */
export declare const RPC_ERROR_SESSION_OPEN_HERE = "session_open_here";
/** `export` of a session file that is not sealed for this move by a `release_session` reason `move`. */
export declare const RPC_ERROR_MOVE_NOT_RELEASED = "move_not_released";
/** A move step that failed for a reason with no code of its own; `errorData.detail` says what happened. */
export declare const RPC_ERROR_MOVE_FAILED = "move_failed";
/**
 * Drives one step of moving a session between devices. The transport carries bundles and answers between hosts; every
 * decision about the session file is taken here. Sender: `export` (after `release_session` reason `move`) and
 * `finish`. Receiver: `prepare`, `cancel`, `import`, `status`, and `revoke` once the sender took the session back. Either
 * side: `copy`, a new writable session from one that is read-only here.
 */
export type RpcMoveSessionCommand = {
    id?: string;
    type: "move_session";
} & ({
    op: "prepare";
    moveId: string;
    cwd?: string;
    repository?: RpcRepositoryIdentity;
} | {
    op: "identity";
    sessionPath: string;
} | {
    op: "identity";
    cwd: string;
} | {
    op: "cancel";
    moveId: string;
} | {
    op: "status";
    moveId: string;
    sessionPath?: string;
    landing?: RpcMoveStatusLanding;
} | {
    op: "export";
    sessionPath: string;
    moveId: string;
    target: string;
    droppedUserMessages?: string[];
    /** Answer the bundle's files as `inline_files` when they fit `inlineMaxBytes` (at most, and by default, the cap). */
    inline?: true;
    inlineMaxBytes?: number;
} | {
    op: "import";
    cwd: string;
    from?: string;
    /** The bundle: the folder `export` named, or the `inline_files` it answered. Exactly one of the two. */
    bundleDir?: string;
    files?: RpcMoveInlineFile[];
    /** The folder the session lands in; this host's session folder for `cwd` when omitted. */
    sessionDir?: string;
    /** Open the landed session on this connection: `true`, or the `open_session` fields to open it with. */
    open?: true | RpcMoveImportOpen;
} | {
    op: "finish";
    sessionPath: string;
    moveId: string;
    answer: MoveAnswer;
} | {
    op: "revoke";
    sessionPath: string;
    moveId: string;
} | {
    op: "copy";
    sessionPath: string;
    sessionId: string;
    sessionDir?: string;
});
/** One file of an inline bundle: its `/`-separated path in the bundle, the sha256 of its bytes, and the bytes. */
export interface RpcMoveInlineFile {
    path: string;
    sha256: string;
    base64: string;
}
/** The `open_session` fields an `import` may open the landed session with; the import itself names the session file. */
export type RpcMoveImportOpen = Omit<Extract<RpcCommand, {
    type: "open_session";
}>, "id" | "type" | "sessionPath" | "cwd" | "admissionId">;
/**
 * `import`'s data. With `open`, the opened session's `open_session` data sits at the same keys beside it; when the
 * landed session could not be opened, `open_error` carries the failed open's error fields and the import still stands.
 */
export type RpcMoveImportData = {
    session_id: string;
    session_path: string;
    sessionId?: string;
    state?: RpcSessionState;
    attached?: boolean;
    presence?: RpcSessionPresence;
    open_error?: RpcMoveOpenError;
};
export interface RpcMoveOpenError {
    error: string;
    errorCode?: string;
    errorData?: unknown;
}
/**
 * Where a move would have landed, as a `status` may name it in place of `sessionPath`: the folder the import was
 * given, the session file name the bundle's manifest carries, and the session folder the import named, if it named one.
 */
export interface RpcMoveStatusLanding {
    cwd: string;
    sessionFileName: string;
    sessionDir?: string;
}
/**
 * The move that made a landed copy read-only here, as the ownership rule reads it from the file: a later move that
 * released the session (`moving` until it ends, then `moved`), or the landed move's own revoke (`moved`, with `target`
 * the device the session went back to).
 */
export interface RpcMoveSealedBy {
    move_id: string;
    state: "moving" | "moved";
    /**
     * The device the sealing release named. Absent when it named none: the destination is not known here, and a caller
     * shows that as another device, as the `session_moved_away` refusal words it. Never the empty string.
     */
    target?: string;
}
/**
 * Where an accepted move landed: the session file its record names, with the id and the folder that file's header
 * names, and whether that copy can still be written here (`sealed_by` beside `writable: false`, senpi#6473).
 * `landed_file: "gone"` when no file is there or the file there no longer records the move.
 */
export type RpcMoveLanded = ({
    session_path: string;
    session_id: string;
    cwd: string;
} & ({
    writable: true;
} | {
    writable: false;
    sealed_by: RpcMoveSealedBy;
})) | {
    landed_file: "gone";
};
/**
 * The receiver's record of a move as a client sees it; `expires_at` while it waits for the bundle, and where it landed
 * beside `accepted` (absent when the record names no landing target).
 */
export type RpcMoveRecord = MoveAnswer | (Extract<MoveAnswer, {
    state: "accepted";
}> & RpcMoveLanded) | {
    state: "ready";
    expires_at: string;
};
export type RpcMoveSessionData = RpcMoveRecord | {
    move_id: string;
    session_id: string;
    bundle_dir: string;
    files: number;
    inline_files?: RpcMoveInlineFile[];
} | RpcMoveImportData | {
    repository?: RpcRepositoryIdentity;
} | {
    ownership: "writable" | "moving" | "moved";
};
export interface RpcMoveSessionResponse {
    id?: string;
    type: "response";
    command: "move_session";
    success: true;
    data: RpcMoveSessionData;
}
//# sourceMappingURL=session-move-wire.d.ts.map