import { type Clock } from "./clock.js"; import type { RoostEvent } from "./events.js"; import type { DispatchArgs } from "./protocol.js"; /** The jobs: sessions and commands the daemon runs. */ export interface SchedulesJobsPort { /** Starts a run (its record carries the schedule's name). */ dispatch(launch: DispatchArgs, extra: { schedule: string; }): Promise<{ id: string; name: string; }>; /** Whether a run's job is still working (or starting, or about to restart); a finished one with its worker up, idle, is not. */ stillRunning(id: string | undefined): boolean; /** The daemon is going down: a tick starts nothing. */ shuttingDown(): boolean; } /** The file the schedules live in (the daemon's writes atomically under the roost's home). */ export interface SchedulesStore { read(): unknown; write(v: unknown): void; } export interface SchedulesSpan { setAttributes(a: Record): void; } export interface SchedulesDeps { jobs: SchedulesJobsPort; store: SchedulesStore; record(e: Omit): void; log(level: "info" | "warn" | "error", msg: string, extra?: Record): void; /** Wraps a run in a telemetry span. */ span(name: string, attrs: Record, fn: (span: SchedulesSpan) => Promise): Promise; isDir(path: string): boolean; clock?: Clock; /** How often the tick looks (default 15 s). */ tickMs?: number; } export type ScheduleOp = "schedules" | "schedule-add" | "schedule-rm" | "schedule-pause" | "schedule-run"; export declare const SCHEDULE_OPS: readonly ScheduleOp[]; export interface Schedules { /** An op on the schedules (args as the socket brings them). */ op(name: ScheduleOp, args: any): Promise; /** Runs that fell due while the service was off (one now, or the next), then the tick. */ start(): void; /** Clears the tick. */ stop(): void; } export declare function createSchedules(deps: SchedulesDeps): Schedules;