import type { AgentRegistryEntry, AgentMessage, WorkClaim, WorkAnnouncement, WorkOverlap, CollaborationSuggestion, DeployAction, CoordinationStatus, AgentStatus, MessageChannel, ClaimType, WorkIntentType, DeployActionType, DeployStatus, MessagePayload } from '../types/coordination.js';
export interface CoordinationServiceConfig {
    dbPath?: string;
    sessionId?: string;
    heartbeatIntervalMs?: number;
    claimExpiryMs?: number;
}
export declare class CoordinationService {
    private db;
    private dbPath;
    private sessionId;
    private heartbeatIntervalMs;
    private claimExpiryMs;
    constructor(config?: CoordinationServiceConfig);
    /**
     * Register an agent. Pass `id` to register under a stable, caller-chosen
     * identifier so other agents can address it directly (announce/send/heartbeat
     * all require a known id); omit it for an auto-generated UUID. Re-registering
     * an existing id is idempotent — it reactivates the agent and refreshes its
     * metadata rather than failing on the primary-key conflict.
     */
    register(name: string, capabilities?: string[], worktreeBranch?: string, id?: string): string;
    heartbeat(agentId: string): void;
    updateStatus(agentId: string, status: AgentStatus, currentTask?: string): void;
    deregister(agentId: string): void;
    getAgent(agentId: string): AgentRegistryEntry | null;
    getActiveAgents(): AgentRegistryEntry[];
    cleanupStaleAgents(): number;
    cleanupStaleAgentsByTime(hours?: number): number;
    private cleanupAgentsOlderThan;
    claimResource(agentId: string, resource: string, claimType?: ClaimType): boolean;
    releaseResource(agentId: string, resource: string): void;
    releaseAllClaims(agentId: string): void;
    isResourceClaimed(resource: string): string | null;
    getResourceClaims(resource: string): WorkClaim[];
    getAgentClaims(agentId: string): WorkClaim[];
    /**
     * Announce intent to work on a resource. Does NOT lock - just informs other agents.
     * Returns overlap info if other agents are also working on related resources.
     */
    announceWork(agentId: string, resource: string, intentType: WorkIntentType, options?: {
        description?: string;
        filesAffected?: string[];
        estimatedMinutes?: number;
    }): {
        announcement: WorkAnnouncement;
        overlaps: WorkOverlap[];
        suggestions: CollaborationSuggestion[];
    };
    /**
     * Mark work as complete on a resource.
     */
    completeWork(agentId: string, resource: string): void;
    /**
     * Flush all pending deploy actions via the DeployBatcher.
     * Called automatically during session cleanup / pre-compact.
     */
    flushDeploys(options?: {
        dryRun?: boolean;
    }): Promise<{
        executed: number;
        failed: number;
    }>;
    /**
     * Get all active work announcements (not completed).
     */
    getActiveWork(): WorkAnnouncement[];
    /**
     * Get work announcements for a specific resource.
     */
    getWorkOnResource(resource: string): WorkAnnouncement[];
    /**
     * Detect overlapping work that might cause merge conflicts.
     */
    detectOverlaps(resource: string, excludeAgentId?: string): WorkOverlap[];
    private assessConflictRisk;
    private generateOverlapSuggestion;
    /**
     * Generate collaboration suggestions based on overlaps.
     */
    generateCollaborationSuggestions(agentId: string, _resource: string, overlaps: WorkOverlap[]): CollaborationSuggestion[];
    private suggestMergeOrder;
    broadcast(fromAgent: string, channel: MessageChannel, payload: MessagePayload, priority?: number): void;
    send(fromAgent: string, toAgent: string, payload: MessagePayload, priority?: number): void;
    private sendMessage;
    receive(agentId: string, channel?: MessageChannel, markAsRead?: boolean): AgentMessage[];
    getPendingMessages(agentId: string): number;
    queueDeploy(agentId: string, actionType: DeployActionType, target: string, payload?: Record<string, unknown>, options?: {
        priority?: number;
        executeAfter?: Date;
        dependencies?: string[];
    }): number;
    getPendingDeploys(): DeployAction[];
    getReadyDeploys(): DeployAction[];
    updateDeployStatus(deployId: number, status: DeployStatus, batchId?: string): void;
    getStatus(): CoordinationStatus;
    cleanup(): void;
    private ensureAgentIsRegistered;
}
//# sourceMappingURL=service.d.ts.map