import type { GitLogFn, GitPolicy } from './git-core'; import type { IndexRecoveryApi, IndexRecoveryRecord } from './index-recovery'; export interface PrepareRunGitOptions { taskId: string; /** Agent display id used for the commit identity (worker convention: id slice). */ agentName: string; /** Project id - reads per-project git options from the bridge config. */ projectId?: string | null; /** Readable branch naming: / (falls back to tasks/). */ projectSlug?: string; taskTitle?: string; /** * Explicit branch name for the run (IMP-743). When set it wins over the * branchForTask() derivation so the hub-assigned name (worktree OR shared * folder) is used verbatim - this is what group chainMode relies on. */ branchName?: string; /** * The branch this task already DELIVERED on (2026-12), recorded by the bridge * after a guarded rename to a name an agent proposed. Sits below `branchName` * (an explicit assignment always wins) and above the title derivation - a * retry must continue the delivered branch, not re-derive a clean one. */ deliveryBranch?: string; /** * chainMode base branch: when creating a FRESH branch, start it here so the * task builds on the previous group task's work. Existing task branches * (retries) win over this. Ignored when the branch already exists. */ baseBranch?: string | null; /** * Project-wide base branch from TeamShare settings (2026-12). Sits between * the chain base and the independent default - see `startPointFor`. */ configuredBase?: string | null; /** * Independent task (ungrouped / first-of-chain): when no chain * `baseBranch` is given, start the fresh branch from the repository's * default branch (freshly fetched) instead of whatever HEAD happens to be. * This keeps sibling tasks in a shared folder from inheriting each other's * commits - the shared-folder equivalent of a worktree cut from `main`. * Ignored when `baseBranch` is set or the branch already exists. */ independentBase?: boolean; /** * IMP-914 per-project git automation level. 'none' skips the whole * pipeline (no branch, no commit); other values branch normally and are * enforced again in finalizeRunGit. */ policy?: GitPolicy; /** * true = give the run its own branch (plain runs + build mode); * false = legacy behavior, work on whatever branch is checked out * (orchestrator workers - the backend owns those branches/worktrees). */ branch: boolean; /** * When true, allow commits directly on the default/main branch. * Default false — agents should never commit to main; only worktrees * should produce commits. Set by the --allow-main-commit flag on * standalone run commands. */ allowMainBranchCommit?: boolean; log: GitLogFn; /** * Optional comment surface: prepare posts `[git-index-recovered]` / * `[git-index-blocked]` when a checkout failure is recovered (or * escalated) here. Supplied by the git-cycle entry points. */ api?: IndexRecoveryApi | null; } export interface PreparedGit { active: boolean; /** Why git was downgraded ('not-a-git-repo' / 'disabled') - empty when active. */ skipReason?: string; /** Branch the run works on (undefined = current branch / fresh repo). */ branch?: string; /** Short sha the branch was created from (when branching happened). */ createdFrom?: string; /** True when the working directory is on the default branch (main/master). */ onDefaultBranch?: boolean; /** * Blocked-index recoveries attempted during prepare (unmerged paths from a * previous run's conflicted pop). `prepareRunGitAsync` posts one audit * comment per record; the run's brief surfaces them too. */ indexRecoveries?: IndexRecoveryRecord[]; /** Per-repo preparation results (populated when multiple repos are found). */ repos?: Array<{ gitRoot: string; active: boolean; branch?: string; createdFrom?: string; onDefaultBranch?: boolean; }>; } /** How long the pipeline waits for a busy workspace before degrading. */ export declare const GIT_LOCK_WAIT_MS: number; /** * Pre-run phase under an exclusive repo lock (IMP-950). Branch checkouts * are invisible-but-destructive to concurrent sessions in the same tree - * serialize them. Falls back to the unlocked path on lock timeout (with a * report note), never throws. */ export declare function prepareRunGitAsync(cwd: string, opts: PrepareRunGitOptions & { lockWaitMs?: number; }): Promise; /** * Legacy synchronous entry point - kept for callers outside session flows. * No arbitration; prefer {@link prepareRunGitAsync}. */ export declare function prepareRunGit(cwd: string, opts: PrepareRunGitOptions): PreparedGit;