Anchorage API reference
    Preparing search index...

    The D1 schedules domain: workflow + agent schedule rows and their trigger history. Mirrors core's SchedulesStorage contract exactly (the abstract methods mastra.schedules drives + the scheduler tick reads), so a host that composes it into createD1Storage({ domains }) gets D1-durable schedules with no adapter change.

    Hierarchy

    • SchedulesStorage
      • D1SchedulesStorage
    Index

    Constructors

    Methods

    • Insert a new schedule row. Throws if a row with the same id already exists. Returns the stored row.

      Parameters

      • schedule: Schedule

      Returns Promise<Schedule>

    • Get a single schedule by id. Returns null if not found.

      Parameters

      • id: string

      Returns Promise<Schedule | null>

    • Initialize the storage domain. This should create any necessary tables/collections. Default implementation is a no-op - override in adapters that need initialization.

      Returns Promise<void>

    • List schedules whose nextFireAt <= now and whose status === 'active'. Used by the scheduler tick loop.

      Parameters

      • now: number
      • Optionallimit: number

      Returns Promise<Schedule[]>

    • List schedules matching the filter (no pagination — schedule counts are expected to stay small).

      Parameters

      • Optionalfilter: ScheduleFilter

      Returns Promise<Schedule[]>

    • List trigger history for a schedule, newest first.

      Parameters

      • scheduleId: string
      • Optionalopts: ScheduleTriggerListOptions

      Returns Promise<ScheduleTrigger[]>

    • Append an entry to a schedule's trigger history.

      Parameters

      • trigger: ScheduleTrigger

      Returns Promise<void>

    • Partial update of a schedule row.

      Parameters

      • id: string
      • patch: ScheduleUpdate

      Returns Promise<Schedule>

    • Compare-and-swap update of nextFireAt. Used by the scheduler to claim a fire before publishing — only one tick across many processes will succeed.

      Returns true if the row's nextFireAt matched expectedNextFireAt and was advanced to newNextFireAt. Returns false if another instance already advanced it (meaning the caller should skip publishing).

      Parameters

      • id: string
      • expectedNextFireAt: number
      • newNextFireAt: number
      • lastFireAt: number
      • lastRunId: string

      Returns Promise<boolean>