@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
73 lines (72 loc) • 2.9 kB
TypeScript
import { type ScheduleLauncher, type ScheduleRun, type SchedulePushSender, type ScheduleStatus } from "./schedule-format.js";
export * from "./schedule-format.js";
export * from "./schedule-launch.js";
export * from "./schedule-watch.js";
export declare class Scheduler {
private readonly now;
private readonly store;
private readonly launch;
private readonly runsFile;
private readonly computer;
/** Every name this computer answers to; a schedule names one of them. */
private readonly names;
private readonly locateProject;
private readonly push?;
private readonly log;
private readonly revisionWaitMs;
private serial;
private ticking;
private readonly dispatching;
/** Runs this process launched; any other open run was left by an earlier Hook. */
private readonly own;
private recovered;
/** When the scheduler last looked for due work; a health read shows it. */
lastTickAt?: Date;
constructor(options: {
now: () => Date;
store: string;
launch: ScheduleLauncher;
runsFile: string;
computer?: string | (() => string);
/** Further names this computer answers to, such as its Hook computer id. */
aliases?: string[];
locateProject?: (project: string) => Promise<string | undefined>;
push?: SchedulePushSender;
log?: (message: string) => void;
/** How long Run now waits for the store to catch up with the revision the app saw (default 30 s). */
revisionWaitMs?: number;
});
private projectDirectories;
private projectDirectory;
private exclusive;
private owns;
statuses(): Promise<{
computer: string;
timeZone: string;
schedules: ScheduleStatus[];
}>;
history(filters?: {
project?: string;
id?: string;
limit?: number;
}): Promise<ScheduleRun[]>;
launchNow(projectName: string, id: string, onlyIfDue?: boolean, expectedUpdatedAt?: string): Promise<ScheduleRun[]>;
/** An edit made on another computer reaches this one with the store's sync. A Run now right after it waits for the
* schedule to arrive (or catch up) rather than failing; a copy newer than the app's, or none after the wait, is
* left to `prepareAndLaunch`'s revision check. */
private awaitRevision;
private prepareAndLaunch;
private updateRun;
private finishRun;
private recordBlockedStartup;
private notifyRun;
/**
* Settles the runs an earlier Hook process left open (a restart or crash
* mid-run). Each is followed to its real end where the launcher can, and
* otherwise failed with the reason, since an open run blocks its schedule
* for good. Runs once, on the first tick, with a launcher that can resume.
*/
recoverOpenRuns(): Promise<void>;
tick(): Promise<void>;
close(): void;
}