import type { CheckpointOwnerRegistry } from "./checkpoint-owners.js"; import type { DiscoveredRepository, FileCheckpointUnavailableReason, GitCheckpoint, GitRepository, GitRunner, PendingGitCheckpoint, SnapshotIndexLease } from "./types.js"; /** Single spelling of the retained-history ref namespace. Takes an * already-hashed session (`checkpointNamespace(sessionId)`), never a raw id. */ export declare const HISTORY_REF_ROOT = "refs/omp-undo-redo/history/"; export declare function historyRefPrefix(sessionHash: string): string; export declare function releaseAllPersistentSnapshotIndices(): Promise; export declare function checkpointNamespace(sessionId: string): string; /** Env binding a runner to `repository`'s snapshot store. Private-Git runs * every command inside the private repo; Git mode keeps the user's * repository (HEAD, config, ignore rules), writes objects to the store and * reads the user's through `GIT_ALTERNATE_OBJECT_DIRECTORIES`, so snapshot * objects never enter the user's object store. */ export declare function snapshotRunnerEnv(repository: GitRepository): Record; /** Env for commands run inside the store: snapshot refs, and its `gc`, * which must read the objects a Git-mode store borrows. */ export declare function storeEnv(repository: GitRepository): Record; export type RepositoryResolution = { repository: DiscoveredRepository; } | { reason: "git_unavailable" | "not_repository" | "repository_unresolvable"; }; export declare function resolveRepository(git: GitRunner): Promise; type SnapshotResult = { hash: string; tree: string; snapshotIndexLease?: SnapshotIndexLease; } | { reason: "invalid_head" | "snapshot_failed"; }; export declare function createSnapshotCommit(git: GitRunner, message: string, retainIndex?: boolean): Promise; interface RefRelease { repository: GitRepository; ref: string; expectedHash: string; } export declare function releaseRefs(gitForRepository: (repository: GitRepository) => GitRunner, refs: readonly RefRelease[]): Promise; export declare function releaseCheckpoints(gitForRepository: (repository: GitRepository) => GitRunner, checkpoints: readonly GitCheckpoint[]): Promise; export declare function releaseCheckpoint(git: GitRunner, checkpoint: GitCheckpoint): Promise; /** `keepIndex`: hand the run's index lease back to the idle pool instead of * deleting it. Only for a run that finished with the lease consistent (its * index matches a real worktree read), e.g. a before-snapshot discarded for * timing reasons; the next reuse re-reads the worktree and checks the baseline. */ export declare function releasePendingCheckpoint(git: GitRunner, pending: Pick, keepIndex?: boolean): Promise; export type PrepareBeforeTurnResult = { status: "git"; checkpoint: PendingGitCheckpoint; } | { status: "session_only"; reason: FileCheckpointUnavailableReason; }; export type FinishAfterTurnResult = { status: "git"; checkpoint: GitCheckpoint; } | { status: "session_only"; reason: FileCheckpointUnavailableReason; }; /** `known`: the store-bound repository `git` was created for. Callers holding * the backend pass it, which spares a `rev-parse` per turn and lets a host * runner factory that wraps runners without re-exposing `runner.env` still * capture. Without it the repository is resolved from `git`. */ export declare function prepareBeforeTurn(git: GitRunner, sessionId: string, ownerRegistry?: CheckpointOwnerRegistry, known?: GitRepository): Promise; export declare function finishAfterTurn(git: GitRunner, before: Pick, parentLeafId: string | null, leafId: string | null): Promise; export declare function retainCheckpointForResume(git: GitRunner, sessionId: string, checkpoint: GitCheckpoint): Promise; /** `nestedRepositories`: repositories whose contents the restore could not * touch, relative to the worktree root (see `nestedRepositoriesOutside`). */ export type CheckpointApplyResult = { status: "applied"; nestedRepositories: string[]; } | { status: "conflict" | "failed"; }; /** Restores `targetHash`'s content over a worktree that currently matches * `sourceHash`, via a patch instead of a checkout so the index is untouched. * Nested repositories are outside every snapshot: an `applied` result lists * them so the caller never reports their contents as restored. */ export declare function applyCheckpoint(git: GitRunner, sourceHash: string, targetHash: string): Promise; export {};