schedule

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCron added in v0.1.3

func NewCron(cfg CronConfig, deps CronDeps) (capschedule.Runtime, error)

NewCron registers schedule/cron: Resident calendar scheduler over a shared job registry.

Best practices:

  • Point tool/schedule at the same registry instance, or agent jobs never fire.
  • Script jobs need workspace and shell deps; prompt jobs only need the registry.
  • Missed boundaries are skipped, not backfilled.

func NewFile

func NewFile(cfg FileConfig, deps FileDeps) (schedule.Registry, error)

NewFile registers schedule/file: Durable cron job table, shared by schedule/cron and tool/schedule.

Best practices:

  • Point schedule/cron and tool/schedule at one instance, or the agent will schedule jobs nothing fires.
  • Jobs carry a source: config jobs are reconciled against the preset on every start, agent jobs are left alone.
  • Writes go through a temp file and rename, so a process killed mid-write leaves no truncated table.

func NewMulti added in v0.1.10

func NewMulti(cfg MultiConfig, deps MultiDeps) (schedule.Registry, error)

NewMulti registers schedule/multi: One shared schedule.json with per-channel list/remove filtering.

Types

type Cron added in v0.1.3

type Cron struct {
	// contains filtered or unexported fields
}

Cron watches a shared registry and submits due jobs as inbound turns.

func (*Cron) SetClockForTest added in v0.1.3

func (c *Cron) SetClockForTest(now func() time.Time, wait func(context.Context, time.Duration) error)

SetClockForTest replaces the clock and wait so cron behaviour can be asserted without real waiting. Test-only.

func (*Cron) Start added in v0.1.3

func (c *Cron) Start(ctx context.Context, submit capschedule.SubmitFunc) error

func (*Cron) Stop added in v0.1.3

func (c *Cron) Stop(context.Context) error

type CronConfig added in v0.1.3

type CronConfig struct {
	// Jobs are reconciled into the registry on every start with source=config.
	Jobs []CronJobSpec `json:"jobs"`
	// SessionMode is stateless (default), reuse, or fixed.
	SessionMode string `json:"sessionMode"`
	// SessionID is the id prefix used for inbound turns.
	SessionID string `json:"sessionId"`
	// PollSeconds is the idle backoff when no jobs are scheduled.
	// Defaults to 30.
	PollSeconds int `json:"pollSeconds"`
	// MissedGraceSeconds is how long a missed one-shot job is still fired.
	// Older one-shots are marked stale instead of backfilled. Defaults to 300.
	MissedGraceSeconds int `json:"missedGraceSeconds"`
}

type CronDeps added in v0.1.3

type CronDeps struct {
	Schedule  capschedule.Registry `json:"schedule"`
	Workspace workspace.Service    `json:"workspace,omitempty"`
	Shell     shell.Executor       `json:"shell,omitempty"`
}

type CronJobSpec added in v0.1.3

type CronJobSpec struct {
	ID     string `json:"id"`
	Cron   string `json:"cron"`
	Prompt string `json:"prompt,omitempty"`
	Script string `json:"script,omitempty"`
	Note   string `json:"note,omitempty"`
}

CronJobSpec is one config-declared cron job. Prompt and script are mutually exclusive; script runs without an agent turn.

type FileConfig

type FileConfig struct {
	// Path is JSON file holding the jobs, resolved through the workspace.
	Path string `json:"path"`
}

type FileDeps

type FileDeps struct {
	Workspace workspace.Service `json:"workspace"`
}

type MultiConfig added in v0.1.10

type MultiConfig struct {
	// Path is the shared schedule file, default global:schedules/schedule.json.
	Path string `json:"path"`
}

type MultiDeps added in v0.1.10

type MultiDeps struct {
	Workspace workspace.Service `json:"workspace"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL