Documentation
¶
Index ¶
- func BuildTools(scheduler *Scheduler, defaultDeliverTo []string) []*agent.Tool
- type AgentRunner
- type ChannelSender
- type Delivery
- type EntStore
- func (s *EntStore) Create(ctx context.Context, job Job) error
- func (s *EntStore) Delete(ctx context.Context, id string) error
- func (s *EntStore) Get(ctx context.Context, id string) (*Job, error)
- func (s *EntStore) GetByName(ctx context.Context, name string) (*Job, error)
- func (s *EntStore) List(ctx context.Context) ([]Job, error)
- func (s *EntStore) ListAllHistory(ctx context.Context, limit int) ([]HistoryEntry, error)
- func (s *EntStore) ListEnabled(ctx context.Context) ([]Job, error)
- func (s *EntStore) ListHistory(ctx context.Context, jobID string, limit int) ([]HistoryEntry, error)
- func (s *EntStore) SaveHistory(ctx context.Context, entry HistoryEntry) error
- func (s *EntStore) Update(ctx context.Context, job Job) error
- func (s *EntStore) Upsert(ctx context.Context, job Job) (*Job, bool, error)
- type Executor
- type HistoryEntry
- type Job
- type JobResult
- type Scheduler
- func (s *Scheduler) AddJob(ctx context.Context, job Job) (bool, error)
- func (s *Scheduler) AllHistory(ctx context.Context, limit int) ([]HistoryEntry, error)
- func (s *Scheduler) History(ctx context.Context, jobID string, limit int) ([]HistoryEntry, error)
- func (s *Scheduler) ListJobs(ctx context.Context) ([]Job, error)
- func (s *Scheduler) PauseJob(ctx context.Context, id string) error
- func (s *Scheduler) RemoveJob(ctx context.Context, id string) error
- func (s *Scheduler) ResolveJobID(ctx context.Context, nameOrID string) (string, error)
- func (s *Scheduler) ResumeJob(ctx context.Context, id string) error
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Stop()
- type SchedulerConfig
- type Store
- type TypingIndicator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentRunner ¶
type AgentRunner interface {
Run(ctx context.Context, sessionKey string, prompt string) (string, error)
}
AgentRunner is the interface for executing agent turns. This avoids import cycles -- wiring.go will provide the concrete implementation.
type ChannelSender ¶
type ChannelSender interface {
SendMessage(ctx context.Context, channel string, message string) error
}
ChannelSender sends a message to a specific channel. This avoids import cycles -- wiring.go will provide the concrete implementation.
type Delivery ¶
type Delivery struct {
// contains filtered or unexported fields
}
Delivery handles dispatching job results to configured channels.
func NewDelivery ¶
func NewDelivery(sender ChannelSender, typing TypingIndicator, logger *zap.SugaredLogger) *Delivery
NewDelivery creates a new Delivery instance. If sender is nil, delivery will be a no-op (results are only stored in history).
func (*Delivery) DeliverStart ¶
DeliverStart sends a notification that a cron job has started execution.
type EntStore ¶
type EntStore struct {
// contains filtered or unexported fields
}
EntStore implements Store using the Ent ORM client.
func NewEntStore ¶
NewEntStore creates a new EntStore backed by the given Ent client.
func (*EntStore) ListAllHistory ¶
ListAllHistory returns execution history across all jobs, ordered by most recent first.
func (*EntStore) ListEnabled ¶
ListEnabled returns only enabled cron jobs.
func (*EntStore) ListHistory ¶
func (s *EntStore) ListHistory(ctx context.Context, jobID string, limit int) ([]HistoryEntry, error)
ListHistory returns execution history for a specific job, ordered by most recent first.
func (*EntStore) SaveHistory ¶
func (s *EntStore) SaveHistory(ctx context.Context, entry HistoryEntry) error
SaveHistory persists a job execution history entry.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs cron jobs by delegating to an AgentRunner and persisting results.
func NewExecutor ¶
func NewExecutor(runner AgentRunner, delivery *Delivery, store Store, logger *zap.SugaredLogger) *Executor
NewExecutor creates a new Executor.
type HistoryEntry ¶
type HistoryEntry struct {
ID string
JobID string
JobName string
Status string // "running" | "completed" | "failed"
Prompt string
Result string
ErrorMessage string
TokensUsed int
StartedAt time.Time
CompletedAt *time.Time
}
HistoryEntry represents a persisted execution record for a cron job.
type Job ¶
type Job struct {
ID string
Name string
ScheduleType string // "at" | "every" | "cron"
Schedule string
Prompt string
SessionMode string // "isolated" | "main"
DeliverTo []string
Timezone string
Enabled bool
Timeout time.Duration // per-job timeout (0 = use default)
LastRunAt *time.Time
NextRunAt *time.Time
CreatedAt time.Time
}
Job represents a scheduled cron job in the domain layer.
type JobResult ¶
type JobResult struct {
JobID string
JobName string
Response string
Error error
StartedAt time.Time
Duration time.Duration
}
JobResult holds the outcome of a single job execution.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron job registration, lifecycle, and concurrent execution.
func New ¶
func New(store Store, executor *Executor, cfg SchedulerConfig) *Scheduler
New creates a new Scheduler.
func (*Scheduler) AddJob ¶
AddJob creates or updates a job in the store and registers it with the scheduler. Returns true if an existing job was updated, false if a new one was created.
func (*Scheduler) AllHistory ¶
AllHistory returns execution history across all jobs.
func (*Scheduler) RemoveJob ¶
RemoveJob removes a job from the scheduler and deletes it from the store.
func (*Scheduler) ResolveJobID ¶ added in v0.6.0
ResolveJobID resolves a name-or-ID string to a job UUID. If the input is a valid UUID it is returned as-is; otherwise it is looked up by name via the store.
func (*Scheduler) ResumeJob ¶
ResumeJob re-enables a paused job and registers it with the scheduler.
type SchedulerConfig ¶ added in v0.6.0
type SchedulerConfig struct {
Timezone string
MaxJobs int
DefaultTimeout time.Duration
Logger *zap.SugaredLogger
}
SchedulerConfig holds optional configuration for the Scheduler.
type Store ¶
type Store interface {
Create(ctx context.Context, job Job) error
Get(ctx context.Context, id string) (*Job, error)
GetByName(ctx context.Context, name string) (*Job, error)
List(ctx context.Context) ([]Job, error)
ListEnabled(ctx context.Context) ([]Job, error)
Update(ctx context.Context, job Job) error
Upsert(ctx context.Context, job Job) (stored *Job, updated bool, err error)
Delete(ctx context.Context, id string) error
SaveHistory(ctx context.Context, entry HistoryEntry) error
ListHistory(ctx context.Context, jobID string, limit int) ([]HistoryEntry, error)
ListAllHistory(ctx context.Context, limit int) ([]HistoryEntry, error)
}
Store defines the persistence interface for cron jobs and their history.