Documentation
¶
Overview ¶
Package schedule defines the calendar-scheduling capability: a durable set of cron jobs that a platform fires and a tool can edit. Splitting it this way is what lets the agent schedule its own follow-up work without knowing who runs it.
Index ¶
Constants ¶
const ( SourceConfig = "config" SourceAgent = "agent" )
Job sources. Config jobs are owned by the preset and re-synced on every start; agent jobs are created at runtime and survive restarts untouched.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Job ¶
type Job struct {
ID string `json:"id"`
Cron string `json:"cron"`
Prompt string `json:"prompt,omitempty"`
// Script is a workspace-relative bash script. When set, the job runs the
// script directly instead of starting an agent turn.
Script string `json:"script,omitempty"`
Source string `json:"source"`
// Disabled jobs stay in the registry but never fire.
Disabled bool `json:"disabled,omitempty"`
// LastRun anchors the schedule. A new job is stamped at creation time so its
// first fire is the next real boundary rather than immediately.
LastRun time.Time `json:"lastRun,omitzero"`
// Note is free-form context the agent can leave for its future self.
Note string `json:"note,omitempty"`
}
Job is one scheduled task.
type Registry ¶
type Registry interface {
List(ctx context.Context) ([]Job, error)
// Add stores a job, assigning an ID when the given one is empty. It returns
// the stored job.
Add(ctx context.Context, job Job) (Job, error)
// Remove deletes a job by ID, reporting whether it existed.
Remove(ctx context.Context, id string) (bool, error)
// SyncSource replaces every job with the given source, leaving other sources
// alone. Used to reconcile config-declared jobs on startup.
SyncSource(ctx context.Context, source string, jobs []Job) error
// Due returns the enabled jobs whose next fire time has arrived, and stamps
// them as run at now. Missed boundaries are skipped rather than backfilled.
Due(ctx context.Context, now time.Time) ([]Job, error)
}
Registry is the durable job set. Implementations must be safe for concurrent use: the firing platform and the agent's tool touch it from different goroutines.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is a parsed cron expression. Times are interpreted in the location of whatever time.Time it is asked about, so a schedule built from local time behaves like an OS crontab entry.
func ParseCron ¶
ParseCron parses a 5-field cron expression: minute hour day-of-month month day-of-week. Each field accepts `*`, a number, `a-b`, comma-separated lists, and `*/n` or `a-b/n` steps. The @hourly/@daily/@weekly/@monthly/@yearly shorthands are also accepted.