Documentation
¶
Index ¶
- Constants
- type ChatFunc
- type CronTool
- type Decision
- type HeartbeatConfig
- type Job
- type OnJobFunc
- type Schedule
- type Service
- func (s *Service) AddJob(name, message string, sched Schedule, sessionMode string) (Job, error)
- func (s *Service) ListJobs() []Job
- func (s *Service) RemoveJob(id string) error
- func (s *Service) ScheduleEvery(ctx context.Context, every string, fn TaskFunc) error
- func (s *Service) SetHeartbeat(cfg HeartbeatConfig, chat ChatFunc, notifier channel.Notifier)
- func (s *Service) SetOnJob(fn OnJobFunc)
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) StartEphemeral(ctx context.Context) error
- func (s *Service) StartHeartbeat(ctx context.Context, every string) error
- func (s *Service) Stop() error
- type TaskFunc
Constants ¶
const ( // SessionReuse reuses the same session across job executions (default). SessionReuse = "reuse" // SessionNew creates a fresh session for each execution. SessionNew = "new" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CronTool ¶
type CronTool struct {
// contains filtered or unexported fields
}
CronTool exposes cron management as an agent tool.
func (*CronTool) Definition ¶
func (t *CronTool) Definition() ai.ToolDefinition
Definition returns the tool definition for the LLM.
type HeartbeatConfig ¶
HeartbeatConfig holds heartbeat-specific settings.
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
Schedule Schedule `json:"schedule"`
Message string `json:"message"`
SessionMode string `json:"session_mode"` // "reuse" (default) or "new"
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
}
Job is the persisted job definition.
type Schedule ¶
type Schedule struct {
Cron string `json:"cron,omitempty"` // "0 9 * * 1-5"
Every string `json:"every,omitempty"` // "30m", "2h"
At string `json:"at,omitempty"` // RFC3339: "2024-01-15T14:30:00+08:00"
}
Schedule defines when a job runs. Exactly one field must be set.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages cron jobs backed by gocron/v2 with JSON persistence.
func (*Service) AddJob ¶
AddJob creates, persists, and schedules a new job. sessionMode controls session reuse: "reuse" (default) or "new".
func (*Service) ScheduleEvery ¶
ScheduleEvery registers a non-persisted recurring task on the existing scheduler.
func (*Service) SetHeartbeat ¶
func (s *Service) SetHeartbeat(cfg HeartbeatConfig, chat ChatFunc, notifier channel.Notifier)
SetHeartbeat configures the heartbeat on the cron service.
func (*Service) StartEphemeral ¶
StartEphemeral starts the shared scheduler without loading persisted cron jobs. Use this when the scheduler is only needed for internal tasks such as heartbeat.
func (*Service) StartHeartbeat ¶
StartHeartbeat schedules the heartbeat poll on the shared scheduler.