Documentation
¶
Index ¶
- Constants
- type CronHandler
- func (c *CronHandler) AddJob(job *Job) error
- func (c *CronHandler) GetJob(id string) (*Job, bool)
- func (c *CronHandler) GetStatus() map[string]interface{}
- func (c *CronHandler) IsRunning() bool
- func (c *CronHandler) ListJobs() []*Job
- func (c *CronHandler) RemoveJob(id string) error
- func (c *CronHandler) RunJob(id string) error
- func (c *CronHandler) SetAgentTurnCallback(cb func(string, string, string) (string, error))
- func (c *CronHandler) SetBroadcastCallback(cb func(string, string, string) error)
- func (c *CronHandler) SetSystemEventCallback(cb func(string))
- func (c *CronHandler) Start()
- func (c *CronHandler) Stop()
- func (c *CronHandler) UpdateJob(id string, updates map[string]interface{}) (*Job, error)
- type Delivery
- type Job
- type JobStore
- func (js *JobStore) Add(job *Job) error
- func (js *JobStore) CalculateNextRun(job *Job) int64
- func (js *JobStore) Get(id string) (*Job, bool)
- func (js *JobStore) GetDueJobs() []*Job
- func (js *JobStore) List() []*Job
- func (js *JobStore) Remove(id string) error
- func (js *JobStore) Update(id string, updates map[string]interface{}) (*Job, error)
- type Payload
- type Schedule
Constants ¶
const ( ScheduleKindAt = "at" ScheduleKindEvery = "every" ScheduleKindCron = "cron" )
Schedule kinds
const ( SessionTargetMain = "main" SessionTargetIsolated = "isolated" )
Session targets
const ( WakeModeNow = "now" WakeModeNextHeartbeat = "next-heartbeat" )
Wake modes
const ( DeliveryModeAnnounce = "announce" DeliveryModeNone = "none" )
Delivery modes
const ( PayloadKindSystemEvent = "systemEvent" PayloadKindAgentTurn = "agentTurn" )
Payload kinds
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CronHandler ¶
type CronHandler struct {
// contains filtered or unexported fields
}
CronHandler manages the cron system
func NewCronHandler ¶
func NewCronHandler(storePath string) *CronHandler
NewCronHandler creates a new cron handler
func (*CronHandler) GetJob ¶
func (c *CronHandler) GetJob(id string) (*Job, bool)
GetJob returns a job by ID
func (*CronHandler) GetStatus ¶
func (c *CronHandler) GetStatus() map[string]interface{}
GetStatus returns the cron status
func (*CronHandler) IsRunning ¶
func (c *CronHandler) IsRunning() bool
IsRunning returns whether the cron is running
func (*CronHandler) RemoveJob ¶
func (c *CronHandler) RemoveJob(id string) error
RemoveJob removes a job
func (*CronHandler) RunJob ¶
func (c *CronHandler) RunJob(id string) error
RunJob immediately runs a job
func (*CronHandler) SetAgentTurnCallback ¶
SetAgentTurnCallback sets the callback for agent turns
func (*CronHandler) SetBroadcastCallback ¶
func (c *CronHandler) SetBroadcastCallback(cb func(string, string, string) error)
SetBroadcastCallback sets the callback for broadcasting
func (*CronHandler) SetSystemEventCallback ¶
func (c *CronHandler) SetSystemEventCallback(cb func(string))
SetSystemEventCallback sets the callback for system events
type Delivery ¶
type Delivery struct {
Mode string `json:"mode"` // "announce", "none"
Channel string `json:"channel,omitempty"` // "telegram", "discord", etc.
To string `json:"to,omitempty"` // channel-specific target
BestEffort bool `json:"bestEffort"`
}
Delivery defines how to deliver job output
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
AgentID string `json:"agentId,omitempty"` // specific agent or empty for default
Enabled bool `json:"enabled"`
Schedule Schedule `json:"schedule"`
SessionTarget string `json:"sessionTarget"` // "main" or "isolated"
WakeMode string `json:"wakeMode"` // "now" or "next-heartbeat"
Payload Payload `json:"payload"`
Delivery *Delivery `json:"delivery,omitempty"`
DeleteAfterRun bool `json:"deleteAfterRun"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// State
State struct {
NextRunAtMs int64 `json:"nextRunAtMs"`
LastRunAtMs int64 `json:"lastRunAtMs"`
LastStatus string `json:"lastStatus"` // "ok", "error", "skipped"
LastDurationMs int64 `json:"lastDurationMs"`
ConsecutiveErrors int `json:"consecutiveErrors"`
} `json:"state"`
}
Job represents a scheduled job
func CreateJobFromMap ¶
CreateJobFromMap creates a Job from a map (for API calls)
type JobStore ¶
type JobStore struct {
// contains filtered or unexported fields
}
JobStore manages cron jobs
func (*JobStore) CalculateNextRun ¶
CalculateNextRun calculates the next run time for a job
func (*JobStore) GetDueJobs ¶
GetDueJobs returns jobs that are due to run
type Payload ¶
type Payload struct {
Kind string `json:"kind"` // "systemEvent", "agentTurn"
Text string `json:"text,omitempty"` // for systemEvent
Message string `json:"message,omitempty"` // for agentTurn
Model string `json:"model,omitempty"`
Thinking string `json:"thinking,omitempty"`
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
}
Payload defines what the job should do
type Schedule ¶
type Schedule struct {
Kind string `json:"kind"` // "at", "every", "cron"
At string `json:"at,omitempty"` // ISO 8601 timestamp
EveryMs int64 `json:"everyMs,omitempty"` // milliseconds
Expr string `json:"expr,omitempty"` // cron expression
Tz string `json:"tz,omitempty"` // timezone
}
Schedule defines when a job should run