export { PaseoConfigRawSchema, PaseoLifecycleCommandRawSchema, PaseoScriptEntryRawSchema, PaseoWorktreeConfigRawSchema, PaseoConfigSchema, type PaseoConfig, type PaseoConfigRaw, } from "@kong-link/protocol/paseo-config-schema";
import { type PaseoConfig } from "@kong-link/protocol/paseo-config-schema";
export { slugify, validateBranchSlug } from "@kong-link/protocol/branch-slug";
export interface WorktreeConfig {
    branchName: string;
    worktreePath: string;
}
export interface WorktreeRuntimeEnv {
    [key: string]: string;
    PASEO_SOURCE_CHECKOUT_PATH: string;
    PASEO_ROOT_PATH: string;
    PASEO_WORKTREE_PATH: string;
    PASEO_BRANCH_NAME: string;
    PASEO_WORKTREE_PORT: string;
}
export interface WorktreeSetupCommandResult {
    command: string;
    cwd: string;
    stdout: string;
    stderr: string;
    exitCode: number | null;
    durationMs: number;
}
export type WorktreeSetupCommandProgressEvent = {
    type: "command_started";
    index: number;
    total: number;
    command: string;
    cwd: string;
} | {
    type: "output";
    index: number;
    total: number;
    command: string;
    cwd: string;
    stream: "stdout" | "stderr";
    chunk: string;
} | {
    type: "command_completed";
    index: number;
    total: number;
    command: string;
    cwd: string;
    exitCode: number | null;
    durationMs: number;
    stdout: string;
    stderr: string;
};
export interface WorktreeTerminalConfig {
    name?: string;
    command: string;
}
export interface PlainScriptConfig {
    type?: undefined;
    command: string;
    port?: undefined;
}
export interface ServiceScriptConfig {
    type: "service";
    command: string;
    port?: number;
}
export type ScriptConfig = PlainScriptConfig | ServiceScriptConfig;
export declare function isServiceScript(config: ScriptConfig): config is ServiceScriptConfig;
export declare class WorktreeSetupError extends Error {
    readonly results: WorktreeSetupCommandResult[];
    constructor(message: string, results: WorktreeSetupCommandResult[]);
}
export type WorktreeTeardownCommandResult = WorktreeSetupCommandResult;
export declare class WorktreeTeardownError extends Error {
    readonly results: WorktreeTeardownCommandResult[];
    constructor(message: string, results: WorktreeTeardownCommandResult[]);
}
export interface PaseoWorktreeInfo {
    path: string;
    createdAt: string;
    branchName?: string;
    head?: string;
}
export interface PaseoWorktreeOwnership {
    allowed: boolean;
    repoRoot?: string;
    worktreeRoot?: string;
    worktreePath?: string;
}
export interface WorktreeRootOptions {
    paseoHome?: string;
    worktreesRoot?: string;
}
export type WorktreeSource = {
    kind: "branch-off";
    baseBranch: string;
    branchName: string;
} | {
    kind: "checkout-branch";
    branchName: string;
} | {
    kind: "checkout-github-pr";
    githubPrNumber: number;
    headRef: string;
    baseRefName: string;
    localBranchName?: string;
    pushRemoteUrl?: string;
};
export interface CreateWorktreeOptions {
    cwd: string;
    worktreeSlug: string;
    source: WorktreeSource;
    runSetup: boolean;
    paseoHome?: string;
    worktreesRoot?: string;
}
interface ResolveExistingWorktreeForSlugOptions {
    slug: string;
    repoRoot: string;
    paseoHome?: string;
    worktreesRoot?: string;
}
export declare class BranchAlreadyCheckedOutError extends Error {
    readonly branchName: string;
    constructor(branchName: string);
}
export declare class UnknownBranchError extends Error {
    readonly branchName: string;
    readonly cwd: string;
    constructor(params: {
        branchName: string;
        cwd: string;
    });
}
export type ReadPaseoConfigResult = {
    ok: true;
    config: PaseoConfig | null;
} | {
    ok: false;
    configPath: string;
    error: unknown;
};
export declare function readPaseoConfig(repoRoot: string): ReadPaseoConfigResult;
export declare function paseoConfigParseError(failure: {
    configPath: string;
    error: unknown;
}): Error;
export declare function getWorktreeSetupCommands(repoRoot: string): string[];
export declare function getWorktreeTeardownCommands(repoRoot: string): string[];
export declare function getWorktreeTerminalSpecs(repoRoot: string): WorktreeTerminalConfig[];
export declare function getScriptConfigs(config: PaseoConfig | null): Map<string, ScriptConfig>;
export declare function processCarriageReturns(text: string): string;
export declare function runWorktreeSetupCommands(options: {
    worktreePath: string;
    branchName: string;
    cleanupOnFailure: boolean;
    repoRootPath?: string;
    runtimeEnv?: WorktreeRuntimeEnv;
    onEvent?: (event: WorktreeSetupCommandProgressEvent) => void;
}): Promise<WorktreeSetupCommandResult[]>;
export declare function resolveWorktreeRuntimeEnv(options: {
    worktreePath: string;
    branchName?: string;
    repoRootPath?: string;
}): Promise<WorktreeRuntimeEnv>;
export declare function runWorktreeTeardownCommands(options: {
    worktreePath: string;
    branchName?: string;
    repoRootPath?: string;
}): Promise<WorktreeTeardownCommandResult[]>;
/**
 * Get the git common directory (shared across worktrees) for a given cwd.
 * This is where refs, objects, etc. are stored.
 */
export declare function getGitCommonDir(cwd: string): Promise<string>;
export declare function deriveWorktreeProjectHash(cwd: string): Promise<string>;
export declare function resolvePaseoWorktreesBaseRoot(options?: WorktreeRootOptions): string;
export declare function getPaseoWorktreesRoot(cwd: string, paseoHome?: string, worktreesRoot?: string): Promise<string>;
export declare function computeWorktreePath(cwd: string, slug: string, paseoHome?: string, worktreesRoot?: string): Promise<string>;
export declare function isPaseoOwnedWorktreeCwd(cwd: string, options?: WorktreeRootOptions): Promise<PaseoWorktreeOwnership>;
export declare function listPaseoWorktrees({ cwd, paseoHome, worktreesRoot, }: {
    cwd: string;
    paseoHome?: string;
    worktreesRoot?: string;
}): Promise<PaseoWorktreeInfo[]>;
export declare function resolveExistingWorktreeForSlug({ slug, repoRoot, paseoHome, worktreesRoot, }: ResolveExistingWorktreeForSlugOptions): Promise<WorktreeConfig | null>;
export declare function resolvePaseoWorktreeRootForCwd(cwd: string, options?: WorktreeRootOptions): Promise<{
    repoRoot: string;
    worktreeRoot: string;
    worktreePath: string;
} | null>;
export declare function deletePaseoWorktree({ cwd, worktreePath, worktreeSlug, worktreesRoot, paseoHome, worktreesBaseRoot, }: {
    cwd: string | null;
    worktreePath?: string;
    worktreeSlug?: string;
    worktreesRoot?: string;
    paseoHome?: string;
    worktreesBaseRoot?: string;
}): Promise<void>;
/**
 * Create a git worktree with proper naming conventions
 */
export declare const createWorktree: ({ cwd, source, worktreeSlug, runSetup, paseoHome, worktreesRoot, }: CreateWorktreeOptions) => Promise<WorktreeConfig>;
//# sourceMappingURL=worktree.d.ts.map