import { Agent, Repository, MountMode as DBMountMode } from '../database/index.js';
/**
 * Resolve the directory for an agent, cascading through resolution strategies.
 * Handles both staff (persistent) and temp (ephemeral) agents.
 *
 * Resolution order:
 * 1. Check agent's worktree_path from DB (most reliable)
 * 2. Check ephemeral directory if agent type is ephemeral
 * 3. Check both directories on disk as fallback
 * 4. Fall back to staff path (caller handles missing dir error)
 */
export declare function resolveAgentDir(workspaceInfo: WorkspaceInfo, agentName: string): string;
/**
 * Format a list of agents for display in error messages.
 * Truncates long lists to avoid overwhelming output.
 */
export declare function formatAgentList(agents: {
    name: string;
}[], maxShow?: number): string;
export interface AgentStatus {
    name: string;
    exists: boolean;
    branch?: string;
    assignedTickets: string[];
    completedTickets: string[];
    repositories: {
        name: string;
        status: string;
        commitsAhead: number;
    }[];
}
export interface WorkspaceInfo {
    path: string;
    type: 'hq' | 'workspace';
    workspaceName: string;
    hasPMO: boolean;
    agents: Agent[];
    repositories: Repository[];
    agentsPath: string;
    /** Active theme ID (if any) */
    activeThemeId: string | null;
    /** Directory name for persistent agents (e.g., 'staff', 'garage', 'portfolio') */
    persistentAgentsDir: string;
    /** Directory name for ephemeral agents (e.g., 'temp', 'pit', 'incubator') */
    ephemeralAgentsDir: string;
}
/**
 * Find workspace root and return workspace information.
 *
 * Search priority:
 * 1. PRLT_HQ_PATH environment variable (ONLY when DEVCONTAINER=true or PRLT_TEST_ENV=true)
 * 2. Current directory tree for HQ with workspace.db
 *
 * NOTE: PRLT_HQ_PATH is ignored on host machines to support multiple agents
 * working in different workspaces simultaneously.
 */
export declare function getWorkspaceInfo(): WorkspaceInfo;
/**
 * Validate agent name
 */
export { isValidAgentName } from '../themes.js';
/**
 * Get suggested agent names (not yet added to workspace)
 */
export declare function getAvailableAgentSuggestions(workspaceInfo: WorkspaceInfo): string[];
/**
 * Interactive agent selection - prompts user for agent names
 */
export declare function selectAgentsInteractively(workspaceInfo: WorkspaceInfo, message?: string): Promise<string[]>;
/**
 * Interactive selection from existing agents
 */
export declare function selectExistingAgentsInteractively(workspaceInfo: WorkspaceInfo, message?: string): Promise<string[]>;
/**
 * Get detailed status for a specific agent
 */
export declare function getAgentStatus(workspaceInfo: WorkspaceInfo, agentName: string): AgentStatus;
/**
 * Get status for all agents
 */
export declare function getAllAgentsStatus(workspaceInfo: WorkspaceInfo): AgentStatus[];
/**
 * Validate agent names (must be valid format)
 */
export declare function validateAgentNames(agentNames: string[]): {
    valid: string[];
    invalid: string[];
};
export type MountMode = DBMountMode;
export interface AddAgentOptions {
    skipDevcontainer?: boolean;
    themeId?: string;
    mountMode?: DBMountMode;
}
/**
 * Create agent worktrees and update database
 */
export declare function addAgentsToWorkspace(workspaceInfo: WorkspaceInfo, agentNames: string[], options?: AddAgentOptions): Promise<string[]>;
/**
 * Remove agents and clean up worktrees
 */
export declare function removeAgentsFromWorkspace(workspaceInfo: WorkspaceInfo, agentNames: string[]): Promise<{
    removed: string[];
    failed: string[];
}>;
export interface EphemeralAgentOptions {
    themeId?: string;
    skipDevcontainer?: boolean;
    /**
     * Optional logger for conflict messages (e.g., when a tmux session or directory already exists)
     */
    log?: (message: string) => void;
    /** Mount mode: 'worktree' = git worktree (default), 'clone' = independent clone */
    mountMode?: DBMountMode;
}
export interface EphemeralAgentResult {
    name: string;
    baseName: string;
    worktreePath: string;
    agent: Agent;
}
/**
 * Create an ephemeral agent on-demand for a spawn operation.
 * Creates worktree in agents/temp/{name}/
 *
 * Concurrency-safe: if the generated name collides at the DB level
 * (e.g. a parallel process inserted the same name first), we clean up
 * the on-disk artifacts, regenerate a name, and retry up to
 * EPHEMERAL_CREATE_MAX_RETRIES times.
 */
export declare function createEphemeralAgent(workspaceInfo: WorkspaceInfo, options?: EphemeralAgentOptions): Promise<EphemeralAgentResult>;
/**
 * Check if a tmux session exists for a given name
 */
export declare function tmuxSessionExists(sessionName: string): boolean;
/**
 * Get list of active tmux sessions that match our pattern
 * Pattern: {ticketId}-{action}-{agent}
 */
export declare function getActiveTmuxSessions(): Array<{
    name: string;
    ticketId: string;
    agent: string;
}>;
/**
 * Check if there's an active tmux session for a specific ticket
 */
export declare function getTicketTmuxSession(ticketId: string): {
    sessionName: string;
    agent: string;
} | null;
/**
 * Kill a tmux session by name
 */
export declare function killTmuxSession(sessionName: string): boolean;
export interface CleanupOptions {
    /** Logger for status messages */
    log?: (message: string) => void;
    /** If true, only show what would be cleaned without doing it */
    dryRun?: boolean;
    /** If true, skip git safety checks and force cleanup */
    force?: boolean;
    /** If true, push unpushed commits before cleanup */
    pushFirst?: boolean;
}
export interface WorktreeGitStatus {
    worktreePath: string;
    repoName: string;
    branch: string;
    hasUncommittedChanges: boolean;
    uncommittedFiles: string[];
    hasUnpushedCommits: boolean;
    unpushedCount: number;
}
export interface AgentGitStatus {
    agentName: string;
    worktrees: WorktreeGitStatus[];
    hasUnsavedWork: boolean;
}
export interface CleanupResult {
    agent: string;
    success: boolean;
    tmuxSessionsKilled: string[];
    containersRemoved: string[];
    directoriesRemoved: string[];
    errors: string[];
    /** Git status if cleanup was blocked due to unsaved work */
    gitStatus?: AgentGitStatus;
    /** Whether cleanup was blocked due to unsaved work */
    blockedByGit?: boolean;
}
/**
 * Get tmux sessions associated with an agent
 */
export declare function getAgentTmuxSessions(agentName: string): string[];
export interface ExistingWorktreeInfo {
    agentName: string;
    agentDir: string;
    worktreePath: string;
    branch: string;
}
/**
 * Find an existing worktree that has a specific branch checked out.
 * Used to detect dead agents whose worktrees still hold a branch,
 * allowing worktree reuse instead of creating a fresh agent.
 *
 * Returns null if no worktree has the branch, or if the agent is still alive.
 */
export declare function findWorktreeForBranch(workspaceInfo: WorkspaceInfo, branch: string): ExistingWorktreeInfo | null;
/**
 * Check git status for all worktrees in an agent directory.
 * Returns info about uncommitted changes and unpushed commits.
 */
export declare function getAgentGitStatus(workspaceInfo: WorkspaceInfo, agentName: string): AgentGitStatus;
/**
 * Commit and push all work in an agent's worktrees.
 * - Stages all uncommitted changes (git add -A)
 * - Commits with a WIP message if there are staged changes
 * - Pushes all commits to remote
 * Returns true if all operations succeeded.
 */
export declare function pushAgentWork(workspaceInfo: WorkspaceInfo, agentName: string, log?: (message: string) => void): boolean;
/**
 * Clean up a single agent - removes resources but keeps DB record (marked as cleaned)
 */
export declare function cleanupAgent(workspaceInfo: WorkspaceInfo, agentName: string, options?: CleanupOptions): Promise<CleanupResult>;
/**
 * Get agents that can be cleaned up (active ephemeral agents with no running work)
 */
export declare function getCleanableAgents(workspaceInfo: WorkspaceInfo, checkRunning?: boolean): Agent[];
