import type { Database } from "bun:sqlite";
import type { Agent, AgentConflictError, RegisterAgentInput } from "../types/index.js";
import { InvalidAgentNameError, normalizeGeneratedAgentNames, suggestAgentNames } from "./agent-names.js";
export { InvalidAgentNameError, normalizeGeneratedAgentNames, suggestAgentNames };
/**
 * Auto-release stale agents: clears session_id for agents whose last_seen_at
 * is beyond the active window. Enabled via TODOS_AGENT_AUTO_RELEASE=true.
 */
export declare function autoReleaseStaleAgents(db?: Database): number;
/**
 * Returns names from the pool that are not currently held by an active agent.
 * Active = last_seen_at within the configured stale window.
 */
export declare function getAvailableNamesFromPool(pool: string[], db: Database): string[];
/**
 * Register an agent. Returns the agent or a conflict descriptor.
 *
 * Conflict rules:
 *  - Name free → create, bind session_id if provided
 *  - Name taken, same session_id → heartbeat, return agent ✓
 *  - Name taken, different session_id, agent ACTIVE → CONFLICT error (unless force: true)
 *  - Name taken, different session_id, agent STALE → takeover, update session_id
 *  - Name taken, no session_id provided, agent ACTIVE with session → CONFLICT error (tightened)
 *  - Name taken, no session_id provided, agent has no session or is stale → heartbeat + return
 *  - force: true → skip active-agent check and take over regardless
 */
export declare function registerAgent(input: RegisterAgentInput, db?: Database): Agent | AgentConflictError;
export declare function isAgentConflict(result: Agent | AgentConflictError): result is AgentConflictError;
/**
 * Release an agent — explicit logout. Clears session_id and sets last_seen_at to epoch
 * so the name is immediately available for other agents.
 *
 * If session_id is provided, only release if it matches (prevents other sessions from
 * releasing your agent).
 */
export declare function releaseAgent(id: string, session_id?: string, db?: Database): boolean;
export declare function getAgent(id: string, db?: Database): Agent | null;
export declare function getAgentByName(name: string, db?: Database): Agent | null;
export declare function listAgents(opts?: {
    include_archived?: boolean;
} | Database, db?: Database): Agent[];
export declare function updateAgentActivity(id: string, db?: Database): void;
export declare function updateAgent(id: string, input: {
    name?: string;
    description?: string;
    role?: string;
    title?: string;
    level?: string;
    permissions?: string[];
    capabilities?: string[];
    reports_to?: string | null;
    org_id?: string | null;
    metadata?: Record<string, unknown>;
}, db?: Database): Agent;
/** Soft-delete: archives the agent instead of removing it. Tasks referencing this agent are preserved. */
export declare function deleteAgent(id: string, db?: Database): boolean;
/** Archive an agent (soft delete). */
export declare function archiveAgent(id: string, db?: Database): Agent | null;
/** Restore an archived agent. */
export declare function unarchiveAgent(id: string, db?: Database): Agent | null;
/** Get direct reports of an agent. */
export declare function getDirectReports(agentId: string, db?: Database): Agent[];
/** Get the full org tree starting from top-level agents (reports_to IS NULL). */
export declare function getOrgChart(db?: Database): OrgNode[];
export interface OrgNode {
    agent: Agent;
    reports: OrgNode[];
}
/**
 * Match agent capabilities against required capabilities (task tags).
 * Returns a score from 0.0 (no match) to 1.0 (perfect match).
 */
export declare function matchCapabilities(agentCapabilities: string[], requiredCapabilities: string[]): number;
/**
 * Get agents that match the given capabilities, sorted by match score.
 */
export declare function getCapableAgents(capabilities: string[], opts?: {
    min_score?: number;
    limit?: number;
}, db?: Database): {
    agent: Agent;
    score: number;
}[];
//# sourceMappingURL=agents.d.ts.map