Files
Moltbot/src/cron/service.ts
Tak Hoffman 77c3b142a9 Web UI: add full cron edit parity, all-jobs run history, and compact filters (openclaw#24155) thanks @Takhoffman
Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Takhoffman <781889+Takhoffman@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
2026-02-22 23:05:42 -06:00

57 lines
1.4 KiB
TypeScript

import * as ops from "./service/ops.js";
import { type CronServiceDeps, createCronServiceState } from "./service/state.js";
import type { CronJob, CronJobCreate, CronJobPatch } from "./types.js";
export type { CronEvent, CronServiceDeps } from "./service/state.js";
export class CronService {
private readonly state;
constructor(deps: CronServiceDeps) {
this.state = createCronServiceState(deps);
}
async start() {
await ops.start(this.state);
}
stop() {
ops.stop(this.state);
}
async status() {
return await ops.status(this.state);
}
async list(opts?: { includeDisabled?: boolean }) {
return await ops.list(this.state, opts);
}
async listPage(opts?: ops.CronListPageOptions) {
return await ops.listPage(this.state, opts);
}
async add(input: CronJobCreate) {
return await ops.add(this.state, input);
}
async update(id: string, patch: CronJobPatch) {
return await ops.update(this.state, id, patch);
}
async remove(id: string) {
return await ops.remove(this.state, id);
}
async run(id: string, mode?: "due" | "force") {
return await ops.run(this.state, id, mode);
}
getJob(id: string): CronJob | undefined {
return this.state.store?.jobs.find((job) => job.id === id);
}
wake(opts: { mode: "now" | "next-heartbeat"; text: string }) {
return ops.wakeNow(this.state, opts);
}
}