Skip to content

openagents_sdk::schedules

The account's scheduled prompts (/v1/schedules, #11177). The site keeps one list per account; each computer runs its own entries, so no server clock starts work. The app host uses this for Foreman's check-ins (#11965); Coder keeps its own copy of the same records.

ItemWhat it does
Schedule structOne scheduled prompt, or the record that it was deleted.
Schedules structA client for the scheduled prompts on one account.
new_id fnA fresh schedule id.
MAX_EVERY_SECS constThe longest interval the site keeps.
MAX_PROMPT_BYTES constThe longest prompt the site keeps.
MIN_EVERY_SECS constThe shortest and longest interval the site keeps.
PREFIX constEvery id starts with this (a Coder background rule's id).

Schedule

pub struct Schedule {
    pub id: String,
    pub computer: String,
    pub prompt: Option<String>,
    pub days: Vec<u8>,
    pub time: Option<String>,
    pub every_secs: Option<u64>,
    pub chat: Option<String>,
    pub chat_title: Option<String>,
    pub workspace: Option<String>,
    pub paused: bool,
    pub updated: u64,
    pub deleted: bool,
}

One scheduled prompt, or the record that it was deleted. Either a time of day on chosen days or an interval. chat names the conversation it posts into; unset means a new run.

Schedule::valid

pub fn valid(&self) -> bool

Whether the site would keep this record as sent.

Schedules

pub struct Schedules<'a> {}

A client for the scheduled prompts on one account.

Schedules::list

pub async fn list(&self, cancel: &CancellationToken) -> Result<Vec<Schedule>, Error>

Every live scheduled prompt on the account, newest first.

Calls GET /v1/schedules

Schedules::sync

pub async fn sync(
    &self,
    computer: &str,
    changed: &[Schedule],
    cancel: &CancellationToken,
) -> Result<Vec<Schedule>, Error>

Send computer's changed records (a newer updated wins, a deletion wins a tie) and receive that computer's whole list, deletions included.

Calls POST /v1/schedules/sync

new_id

pub fn new_id() -> Result<String, Error>

A fresh schedule id.

MAX_EVERY_SECS

pub const MAX_EVERY_SECS: u64 = 30 * 24 * 3600;

The longest interval the site keeps.

MAX_PROMPT_BYTES

pub const MAX_PROMPT_BYTES: usize = 4000;

The longest prompt the site keeps.

MIN_EVERY_SECS

pub const MIN_EVERY_SECS: u64 = 60;

The shortest and longest interval the site keeps.

PREFIX

pub const PREFIX: &str = "prompt-";

Every id starts with this (a Coder background rule's id).