import { listAcpSessionEntries, readAcpSessionEntry } from "../acp/runtime/session-meta.js";
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
import type { DaoCoreConfig } from "../config/types.daocore.js";
import { isCronJobActive } from "../cron/active-jobs.js";
import { readCronRunLogEntriesSync, resolveCronRunLogPath } from "../cron/run-log.js";
import type { CronRunLogEntry } from "../cron/run-log.js";
import { loadCronStoreSync, resolveCronStorePath } from "../cron/store.js";
import type { CronStoreFile } from "../cron/types.js";
import { getAgentRunContext } from "../infra/agent-events.js";
import { getSessionBindingService } from "../infra/outbound/session-binding-service.js";
import { parseAgentSessionKey } from "../routing/session-key.js";
import { deriveSessionChatTypeFromKey } from "../sessions/session-chat-type-shared.js";
import { deleteTaskRecordById, ensureTaskRegistryReady, getTaskById, hasActiveTaskForChildSessionKey, listTaskRecords, markTaskLostById, markTaskTerminalById, maybeDeliverTaskTerminalUpdate, resolveTaskForLookupToken, setTaskCleanupAfterById } from "./runtime-internal.js";
import type { TaskAuditSummary } from "./task-registry.audit.js";
import type { TaskRecord, TaskRegistrySummary, TaskStatus } from "./task-registry.types.js";
type TaskRegistryMaintenanceRuntime = {
    listAcpSessionEntries: typeof listAcpSessionEntries;
    readAcpSessionEntry: typeof readAcpSessionEntry;
    closeAcpSession?: (params: {
        cfg: DaoCoreConfig;
        sessionKey: string;
        reason: string;
    }) => Promise<void>;
    listSessionBindingsBySession?: ReturnType<typeof getSessionBindingService>["listBySession"];
    unbindSessionBindings?: ReturnType<typeof getSessionBindingService>["unbind"];
    loadSessionStore: typeof loadSessionStore;
    resolveStorePath: typeof resolveStorePath;
    deriveSessionChatTypeFromKey?: typeof deriveSessionChatTypeFromKey;
    isCronJobActive: typeof isCronJobActive;
    getAgentRunContext: typeof getAgentRunContext;
    parseAgentSessionKey: typeof parseAgentSessionKey;
    hasActiveTaskForChildSessionKey: typeof hasActiveTaskForChildSessionKey;
    deleteTaskRecordById: typeof deleteTaskRecordById;
    ensureTaskRegistryReady: typeof ensureTaskRegistryReady;
    getTaskById: typeof getTaskById;
    listTaskRecords: typeof listTaskRecords;
    markTaskLostById: typeof markTaskLostById;
    markTaskTerminalById: typeof markTaskTerminalById;
    maybeDeliverTaskTerminalUpdate: typeof maybeDeliverTaskTerminalUpdate;
    resolveTaskForLookupToken: typeof resolveTaskForLookupToken;
    setTaskCleanupAfterById: typeof setTaskCleanupAfterById;
    isCronRuntimeAuthoritative: () => boolean;
    resolveCronStorePath: typeof resolveCronStorePath;
    loadCronStoreSync: typeof loadCronStoreSync;
    resolveCronRunLogPath: typeof resolveCronRunLogPath;
    readCronRunLogEntriesSync: typeof readCronRunLogEntriesSync;
};
export type TaskRegistryMaintenanceSummary = {
    reconciled: number;
    recovered: number;
    cleanupStamped: number;
    pruned: number;
};
export type TaskRegistryMaintenanceTaskDiagnostic = {
    taskId: string;
    runtime: TaskRecord["runtime"];
    status: TaskRecord["status"];
    decision: "retained" | "would_reconcile";
    reason: "active_cli_run" | "backing_session_missing" | "backing_session_present" | "cron_runtime_not_authoritative" | "lost_grace_pending" | "subagent_recovery_wedged";
    detail?: string;
    ageMs: number;
    childSessionKey?: string;
    runId?: string;
};
export type TaskRegistryMaintenanceDiagnostics = {
    staleRunningTasks: TaskRegistryMaintenanceTaskDiagnostic[];
};
type CronRecoveryContext = {
    storePath: string;
    store?: CronStoreFile | null;
    runLogsByJobId: Map<string, CronRunLogEntry[]>;
};
export declare function reconcileTaskRecordForOperatorInspection(task: TaskRecord, context?: CronRecoveryContext): TaskRecord;
export declare function reconcileInspectableTasks(): TaskRecord[];
export type ActiveTaskRestartBlocker = {
    taskId: string;
    status: Extract<TaskStatus, "running">;
    runtime: TaskRecord["runtime"];
    runId?: string;
    label?: string;
    title?: string;
};
export declare function getInspectableActiveTaskRestartBlockers(): ActiveTaskRestartBlocker[];
export declare function getInspectableTaskRegistrySummary(): TaskRegistrySummary;
export declare function getInspectableTaskAuditSummary(): TaskAuditSummary;
export declare function reconcileTaskLookupToken(token: string): TaskRecord | undefined;
export declare function previewTaskRegistryMaintenance(): TaskRegistryMaintenanceSummary;
export declare function getTaskRegistryMaintenanceDiagnostics(): TaskRegistryMaintenanceDiagnostics;
export declare function runTaskRegistryMaintenance(): Promise<TaskRegistryMaintenanceSummary>;
export declare function sweepTaskRegistry(): Promise<TaskRegistryMaintenanceSummary>;
export declare function startTaskRegistryMaintenance(): void;
export declare function stopTaskRegistryMaintenance(): void;
export declare const stopTaskRegistryMaintenanceForTests: typeof stopTaskRegistryMaintenance;
export declare function setTaskRegistryMaintenanceRuntimeForTests(runtime: TaskRegistryMaintenanceRuntime): void;
export declare function resetTaskRegistryMaintenanceRuntimeForTests(): void;
export declare function configureTaskRegistryMaintenance(options: {
    cronStorePath?: string;
    cronRuntimeAuthoritative?: boolean;
}): void;
export declare function getReconciledTaskById(taskId: string): TaskRecord | undefined;
export {};
