import { ConfigManager } from '../config/manager.js';
import type { RuntimeStore } from '../runtime/store/index.js';
import type { RuntimeEventBus } from '../runtime/events/index.js';
import type { AgentManager } from '../tools/agent/index.js';
import { type SchedulerCapacityReport } from './scheduler-capacity.js';
import { AutomationJobStore } from './store/jobs.js';
import { AutomationRunStore } from './store/runs.js';
import { AutomationDeliveryManager } from './delivery-manager.js';
import { RouteBindingManager } from '../channels/index.js';
import type { AutomationJob } from './jobs.js';
import type { AutomationRun, AutomationRunTelemetry } from './runs.js';
import type { AutomationSurfaceKind } from './types.js';
import { SharedSessionBroker } from '../control-plane/index.js';
import type { CreateAutomationJobInput, SpawnAutomationTaskInput, UpdateAutomationJobInput } from './manager-runtime-helpers.js';
import { type AutomationHeartbeatWake } from './manager-runtime-scheduling.js';
import type { FeatureFlagReader } from '../runtime/feature-flags/index.js';
export type { CreateAutomationJobInput, UpdateAutomationJobInput, SpawnAutomationTaskInput, } from './manager-runtime-helpers.js';
export type { AutomationHeartbeatWake } from './manager-runtime-scheduling.js';
interface AutomationManagerConfig {
    readonly jobStore?: AutomationJobStore | undefined;
    readonly runStore?: AutomationRunStore | undefined;
    readonly spawnTask?: ((input: SpawnAutomationTaskInput) => string) | undefined;
    readonly cancelTask?: ((agentId: string) => void) | undefined;
    readonly agentStatusProvider?: Pick<AgentManager, 'getStatus'> | undefined;
    readonly runtimeStore?: RuntimeStore | undefined;
    readonly runtimeBus?: RuntimeEventBus | undefined;
    readonly deliveryManager?: AutomationDeliveryManager | undefined;
    readonly configManager: ConfigManager;
    readonly routeBindings: RouteBindingManager;
    readonly sessionBroker: SharedSessionBroker;
    readonly defaultSurfaceKind?: AutomationSurfaceKind | undefined;
    readonly defaultSurfaceId?: string | undefined;
    readonly featureFlags?: FeatureFlagReader | undefined;
}
export interface AutomationHeartbeatResult {
    readonly processed: readonly AutomationRun[];
    readonly failed: readonly {
        readonly jobId: string;
        readonly error: string;
    }[];
    readonly pending: readonly AutomationHeartbeatWake[];
    readonly checkedAt: number;
}
export declare class AutomationManager {
    private readonly jobStore;
    private readonly runStore;
    private readonly spawnTask?;
    private readonly cancelTask?;
    private readonly agentStatusProvider?;
    private readonly configManager;
    private readonly routeBindings;
    private readonly sessionBroker;
    private readonly defaultSurfaceKind?;
    private readonly defaultSurfaceId?;
    private readonly jobs;
    private readonly runs;
    private readonly timers;
    private readonly retryTimers;
    private readonly heartbeatWakes;
    private deliveryManager;
    private readonly deliveryInFlight;
    private runtimeDispatch;
    private runtimeBus;
    private readonly featureFlags;
    private loaded;
    private running;
    private startPromise;
    private reconcileTimer;
    constructor(config: AutomationManagerConfig);
    private isEnabled;
    private requireEnabled;
    private requireSpawnTask;
    private requireCancelTask;
    private runtimeExecutionContext;
    private jobMutationContext;
    start(): Promise<void>;
    stop(): void;
    attachRuntime(config: {
        readonly runtimeStore?: RuntimeStore | null | undefined;
        readonly runtimeBus?: RuntimeEventBus | null | undefined;
        readonly deliveryManager?: AutomationDeliveryManager | null | undefined;
    }): void;
    listJobs(): AutomationJob[];
    listRuns(jobId?: string): AutomationRun[];
    listHeartbeatWakes(): AutomationHeartbeatWake[];
    getRun(runId: string): AutomationRun | undefined;
    getJob(jobId: string): AutomationJob | undefined;
    createJob(input: CreateAutomationJobInput): Promise<AutomationJob>;
    removeJob(jobId: string): Promise<boolean>;
    setEnabled(jobId: string, enabled: boolean): Promise<AutomationJob | null>;
    updateJob(jobId: string, patch: UpdateAutomationJobInput): Promise<AutomationJob | null>;
    runNow(jobId: string): Promise<AutomationRun>;
    triggerHeartbeat(_input?: {
        readonly source?: string;
    }): Promise<AutomationHeartbeatResult>;
    retryRun(runId: string): Promise<AutomationRun>;
    cancelRun(runId: string, reason?: string): Promise<AutomationRun | null>;
    recordExternalRunResult(runId: string, input: {
        readonly status: 'completed' | 'failed' | 'cancelled';
        readonly result?: unknown | undefined;
        readonly error?: string | undefined;
        readonly telemetry?: AutomationRunTelemetry | undefined;
        readonly metadata?: Record<string, unknown> | undefined;
    }): Promise<AutomationRun | null>;
    private load;
    private scheduleJob;
    private cancelTimer;
    private queueDueHeartbeatJobs;
    private advanceScheduledHeartbeatJob;
    private executeJob;
    private syncExecutionRoute;
    private applyFailureToJob;
    private reconcileActiveRuns;
    private saveJobs;
    private saveRuns;
    private maxConcurrentRuns;
    private activeRunCount;
    getSchedulerCapacity(): SchedulerCapacityReport;
    private pruneRunHistory;
    private scheduleFailureFollowUp;
    private maybeDeliverFailureNotice;
    private syncRuntimeSnapshot;
    private syncJobToRuntime;
    private syncRunToRuntime;
    private emitJobCreated;
    private emitJobUpdated;
    private emitJobAutoDisabled;
    private emitRunQueued;
    private emitRunStarted;
    private emitRunCompleted;
    private emitRunFailed;
    private maybeDeliverRun;
}
//# sourceMappingURL=manager-runtime.d.ts.map