import { type PushReadinessDecision, type WorktreeCheckoutDecision } from './dispatch-preflight.js'; import { type CloneWirePolicy } from './repo-credential.js'; export type WorktreeMode = 'per_ticket' | 'shared'; export declare const DEFAULT_WORKTREE_MODE: WorktreeMode; export declare const SHARED_SLOT_PREFIX = "shared-"; export declare function sharedSlotName(i: number): string; export declare function isSharedSlotSeg(seg: string): boolean; export interface PoolSlotLease { slot: string; ticketId: string; role?: string; active: boolean; leasedAt: string; releasedAt?: string; branch?: string | null; } export interface PoolRegistry { version: number; slots: Record; } export interface TerminalTicketCleanupReport { removedWorktrees: number; removedLocalBranches: string[]; removedRemoteBranches: string[]; remainingBranches: string[]; heldReasons: string[]; benignHolds: string[]; benignHeldBranches: string[]; } export declare function worktreesRootFor(baseWorkingDir: string): string; export declare function runWorkspaceRootFor(baseWorkingDir: string): string; export declare function actionWorkspaceRootFor(baseWorkingDir: string): string; export declare function chatWorkspaceRootFor(baseWorkingDir: string): string; export declare function orchestrationWorkspaceRootFor(baseWorkingDir: string): string; export interface WorktreeInfo { path: string; head: string | null; branch: string | null; detached: boolean; } export type WorktreeState = 'allocated' | 'idle' | 'orphaned'; export interface WorktreeSnapshotEntry { path: string; slot: string; mode: WorktreeMode; ticketId: string | null; branch: string | null; state: WorktreeState; live: boolean; } export interface RunWorkspaceSnapshotEntry { path: string; kind: 'action' | 'chat' | 'orchestration'; leaf: string; lastUsedAt: string | null; live: boolean; } export interface ResolveCwdArgs { baseWorkingDir: string; ticketId: string; role: string; mode?: WorktreeMode; poolSize?: number; bootstrapRepo?: { resourceId?: string; url: string; branch?: string; credential?: { username?: string; token: string; } | null; clonePolicy?: CloneWirePolicy | null; } | null; } export interface ResolveCwdResult { cwd: string; isWorktree: boolean; reused?: boolean; reason?: string; detail?: string; worktreePath?: string; workSubpath?: string; mode?: WorktreeMode; repositoryContext?: TicketRepositoryContext; } export interface TicketRepositoryContext { resourceId: string; cwd: string; baseBranch: string; baseSha: string; currentSha?: string; workingBranch: string | null; dirty: boolean; ahead: number; behind: number; resumed: boolean; remoteUrl?: string; defaultBranch?: string; fetchedSha?: string; currentShaFailure?: string; credentialAvailable?: boolean | null; credentialFailure?: string | null; } export declare function worktreeSlug(ticketId: string, mode?: WorktreeMode): string; export declare class WorktreeManager { #private; constructor(opts?: { provisionLockTimeoutMs?: number; provisionLockStaleMs?: number; provisionLockHeartbeatMs?: number; terminalCleanupHooks?: { removeWorktree?: (repo: string, worktreePath: string) => Promise | boolean; beforeRemoteDelete?: (branch: string) => Promise | void; beforeLocalDelete?: (branch: string) => Promise | void; }; }); listWorktrees(baseWorkingDir: string): Promise; prune(baseWorkingDir: string): Promise; resolveCwd(args: ResolveCwdArgs): Promise; verifyPushReadiness(cwd: string, remoteUrl?: string): Promise; verifyCheckout(cwd: string, expectedUrl?: string): Promise; reconcilePoolLeases(opts: { baseWorkingDir: string; liveTicketIds: Set; }): Promise; snapshotWorktrees(opts: { baseWorkingDir: string; liveTicketIds: Set; }): Promise; removeTicketWorktrees(opts: { baseWorkingDir: string; ticketId: string; repositoryResourceId?: string; }): Promise; cleanupTerminalTicketGit(opts: { baseWorkingDir: string; ticketId: string; baseBranch?: string; repositoryResourceId?: string; }): Promise; removeTicketRunWorkspace(opts: { baseWorkingDir: string; ticketId: string; }): Promise; sweep(opts: { baseWorkingDir: string; activeKeys: Set; }): Promise; snapshotRunWorkspaces(baseWorkingDir: string): Promise; sweepRunWorkspaces(baseWorkingDir: string): Promise; }