/**
 * Agent Spawner
 *
 * Shared logic for spawning agent executions.
 * Used by `work start`, `work spawn`, and `work watch` commands.
 */
import Database from 'better-sqlite3';
import { SQLiteStorage } from '../pmo/storage-sqlite.js';
import { WorkspaceInfo } from '../agents/commands.js';
import { ExecutionStorage } from './storage.js';
import { isDockerRunning, isGitHubTokenAvailable, isDevcontainerCliInstalled } from './runners.js';
import { DisplayMode, SessionManager, ExecutorType, ExecutionEnvironment, ExecutionConfig } from './types.js';
import { Ticket } from '../pmo/types.js';
export type AgentStrategy = 'round-robin' | 'least-busy' | 'random';
export interface SpawnOptions {
    /** Environment to run in */
    environment?: ExecutionEnvironment;
    /** Display mode for output */
    displayMode?: DisplayMode;
    /** Session manager for container environments (tmux runs inside container) */
    sessionManager?: SessionManager;
    /** Executor to use */
    executor?: ExecutorType;
    /** Skip permission prompts (danger mode) */
    skipPermissions?: boolean;
    /** Explicitly allow running on host (bypasses sandbox) */
    runOnHost?: boolean;
    /** Create PR when work is ready */
    createPR?: boolean;
    /** Execution config (terminal app, shell, etc.) */
    executionConfig?: ExecutionConfig;
    /** Logging callback */
    log?: (msg: string) => void;
    /** Skip GitHub remote check */
    skipRemoteCheck?: boolean;
}
export interface SpawnResult {
    success: boolean;
    executionId?: string;
    ticketId?: string;
    agentName?: string;
    error?: string;
}
export interface BatchSpawnResult {
    spawned: SpawnResult[];
    skipped: Array<{
        ticketId: string;
        reason: string;
    }>;
    failed: SpawnResult[];
}
interface AgentWithExecutionCount {
    name: string;
    runningCount: number;
    totalCount: number;
}
/**
 * Get all agents with their execution counts.
 */
export declare function getAgentsWithCounts(workspaceInfo: WorkspaceInfo, executionStorage: ExecutionStorage): AgentWithExecutionCount[];
/**
 * Get staff agents that are not currently running any executions.
 * Only considers persistent (staff) agents with status='active'.
 * Cleans up stale executions before checking availability (TKT-604).
 */
export declare function getAvailableAgents(workspaceInfo: WorkspaceInfo, executionStorage: ExecutionStorage): string[];
/**
 * Select an agent using the specified strategy.
 */
export declare function selectAgent(strategy: AgentStrategy, availableAgents: string[], executionStorage: ExecutionStorage, roundRobinState?: {
    lastIndex: number;
}): string | null;
/**
 * Spawn an agent to work on a ticket.
 * This is the core spawning logic extracted from `work start`.
 */
export declare function spawnAgentForTicket(ticket: Ticket, agentName: string, storage: SQLiteStorage, executionStorage: ExecutionStorage, workspaceInfo: WorkspaceInfo, db: Database.Database, pmoPath: string, options?: SpawnOptions): Promise<SpawnResult>;
/**
 * Spawn agents for all tickets in a column.
 */
export declare function spawnForColumn(projectId: string, columnName: string, storage: SQLiteStorage, executionStorage: ExecutionStorage, workspaceInfo: WorkspaceInfo, db: Database.Database, pmoPath: string, options?: {
    strategy?: AgentStrategy;
    specificAgent?: string;
    limit?: number;
    dryRun?: boolean;
    ticketIds?: string[];
    log?: (msg: string) => void;
} & SpawnOptions): Promise<BatchSpawnResult>;
export { isDockerRunning, isGitHubTokenAvailable, isDevcontainerCliInstalled };
