|

Schedules

defineSchedule — let your agent act on its own on a recurring cron schedule.

Schedules are when an agent acts on its own — recurring jobs that fire without a user prompt. Each file in agent/schedules/ default-exports a schedule.

// agent/schedules/daily_digest.ts
import { defineSchedule } from "arcie/schedules";
 
export default defineSchedule({
  name: "daily_digest",
  cron: "0 9 * * *",        // every day at 09:00
  timezone: "America/New_York",
  async handler() {
    // compile and send the digest
  },
});

defineSchedule requires name, cron, and handler — omitting any throws Schedule must have name, cron, and handler.

ScheduleConfig

interface ScheduleConfig {
  name: string;
  cron: string;             // standard 5-field cron expression
  handler: () => void | Promise<void>;
  timezone?: string;        // IANA tz, e.g. "America/New_York"
}
FieldPurpose
nameIdentifier for the job (also the file name).
cronA standard cron expression, e.g. 0 9 * * *.
timezoneIANA timezone the cron is evaluated in. Defaults to the runtime's zone.
handlerThe work to run on each tick.