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 { AutomationCheckinEvaluator } from './checkin-execution.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 | 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; /** * The live provider registry, when the caller has one wired up. Enables * bare model id resolution for job `model`/`fallbackModels` fields * (unique -> auto-qualify; ambiguous/unknown -> a rich error naming real * candidates). Omitted callers keep the prior format-only validation. */ readonly providerRegistry?: Pick | 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 providerRegistry?; private readonly jobs; private readonly runs; private readonly timers; private readonly retryTimers; private readonly heartbeatWakes; private deliveryManager; private readonly deliveryInFlight; private checkinEvaluator?; private runtimeDispatch; private runtimeBus; private readonly featureFlags; private loaded; private running; private startPromise; private reconcileTimer; private readonly warnedDeliveryGapJobs; constructor(config: AutomationManagerConfig); private isEnabled; private requireEnabled; private requireSpawnTask; private requireCancelTask; private runtimeExecutionContext; private jobMutationContext; start(): Promise; stop(): void; /** * Attach the check-in evaluator that runs when a `kind: 'checkin'` job fires. * Called once by the CheckinService after construction (the service needs the * manager to schedule the check-in job, so the manager cannot depend on it at * construction). Idempotent-ish: the last attached evaluator wins. */ attachCheckinEvaluator(evaluator: AutomationCheckinEvaluator): 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; removeJob(jobId: string): Promise; setEnabled(jobId: string, enabled: boolean): Promise; updateJob(jobId: string, patch: UpdateAutomationJobInput): Promise; runNow(jobId: string): Promise; triggerHeartbeat(_input?: { readonly source?: string; }): Promise; retryRun(runId: string): Promise; cancelRun(runId: string, reason?: string): Promise; recordExternalRunResult(runId: string, input: { readonly status: 'completed' | 'failed' | 'cancelled'; readonly result?: unknown | undefined; readonly error?: string | undefined; readonly telemetry?: AutomationRunTelemetry | undefined; readonly metadata?: Record | undefined; }): Promise; private load; private scheduleJob; private recordMissedRun; /** * Reconcile every live job's schedule against the wall clock: mint a `missed` * run for any occurrence that slipped past the catch-up window, and (re)arm * each timer. Runs at daemon boot and on the reachability heartbeat so drift * renders as recorded outcomes, not a user chore. Idempotent per occurrence. */ reconcileSchedules(): void; 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