No JSDoc comment in source yet.
API
@Component()
export class SchedulesRepo implements Schedules {
@Use() private readonly db!: Db;
find(projectId: string, agentId: string, name: string): ScheduleStateRow | null;
listByAgent(projectId: string, agentId: string): ScheduleStateRow[];
registerOrSync(args: {
projectId: string;
agentId: string;
name: string;
startAtMs: number;
defHash: string;
creatorUserId: string | null;
/** A person's save through the schedules route: the creator is written even when nothing changed. */
attested?: boolean;
}): { row: ScheduleStateRow; fresh: boolean };
markSlot(projectId: string, agentId: string, name: string, slotMs: number): void;
markFired(projectId: string, agentId: string, name: string, firedAt: string, oneShot: boolean): void;
markMissed(projectId: string, agentId: string, name: string): void;
markInvalid(projectId: string, agentId: string, name: string, reason: string): void;
delete(projectId: string, agentId: string, name: string): void;
deleteMissing(projectId: string, agentId: string, presentNames: string[]): string[];
deleteByAgent(projectId: string, agentId: string): void;
deleteByProject(projectId: string): void;
}Dependencies & Wiring
Extracted from class decoratorsMethods (11)
find
find(projectId: string, agentId: string, name: string): ScheduleStateRow | nullstringstringstringScheduleStateRow | nulllistByAgent
listByAgent(projectId: string, agentId: string): ScheduleStateRow[]stringstringScheduleStateRow[]registerOrSync
registerOrSync(args: { projectId: string; agentId: string; name: string; startAtMs: number; defHash: string; creatorUserId: string | null; attested?: boolean; }): { row: ScheduleStateRow; fresh: boolean }Register or sync a task's runtime state, returning the synced row plus a fresh
flag:
- Insert if it doesn't exist;
- A change to
start_atresets the trigger state (a new task instance); - Otherwise, a change to the file fingerprint only clears the disabled flag.
The creator is who vouches for the file as it stands — the person whose runs it drives
(the scheduler's driver). It is written on insert and on every change: the schedules
route passes the person who saved it with their own sign-in (null for the local API token)
and attested, which writes it even when nothing changed; reconciliation of a file found on
disk — written or edited by an Agent, or by hand — passes null, so a schedule nobody signed
for has no creator, and editing one a person saved takes theirs away.
fresh = this call was an insert or reset — the scheduler only establishes its
"missed, don't backfill" baseline at this moment; afterward, last_slot being NULL
only means "no scheduled time has been consumed yet", and it must fire normally once
reached.
{ projectId: string; agentId: string; name: string; startAtMs: number; defHash: string; creatorUserId: string | null; attested?: boolean; }{ row: ScheduleStateRow; fresh: boolean }markSlot
markSlot(projectId: string, agentId: string, name: string, slotMs: number): voidAdvance the consumed scheduled time (advances whether triggered or skipped; restarts don't re-trigger).
stringstringstringnumbervoidmarkFired
markFired(projectId: string, agentId: string, name: string, firedAt: string, oneShot: boolean): voidRecord an actual send (also sets fired_once for a one-shot task).
stringstringstringstringbooleanvoidmarkMissed
markMissed(projectId: string, agentId: string, name: string): voidMissed marker for a one-shot task (the scheduled time had already passed at startup/registration reconciliation; missed means not backfilled).
stringstringstringvoidmarkInvalid
markInvalid(projectId: string, agentId: string, name: string, reason: string): voidMark as disabled (e.g. the bound Session was deleted); cleared via registerOrSync after the file is modified.
stringstringstringstringvoiddelete
delete(projectId: string, agentId: string, name: string): voidDeleting the file removes the task: clears its runtime state.
stringstringstringvoiddeleteMissing
deleteMissing(projectId: string, agentId: string, presentNames: string[]): string[]Reconciliation cleanup: deletes state rows under this Agent that aren't in the current file list, returning the removed names.
stringstringstring[]string[]deleteByAgent
deleteByAgent(projectId: string, agentId: string): voidstringstringvoiddeleteByProject
deleteByProject(projectId: string): voidstringvoid