automation

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultTickInterval = 30 * time.Second
	DefaultTimezone     = "UTC"
)

Variables

View Source
var ErrDuplicateFire = errors.New("duplicate automation fire")

Functions

This section is empty.

Types

type CreateJobInput

type CreateJobInput struct {
	Kind            JobKind
	SessionID       string
	Client          string
	ExternalKey     string
	Title           string
	Timezone        string
	ScheduleMode    ScheduleMode
	RunAt           *time.Time
	IntervalSeconds int
	CronExpr        string
	Prompt          string
}

type CreateJobRequest

type CreateJobRequest struct {
	Kind            JobKind      `json:"kind"`
	SessionID       string       `json:"session_id"`
	Client          string       `json:"client,omitempty"`
	ExternalKey     string       `json:"external_key,omitempty"`
	Title           string       `json:"title,omitempty"`
	Timezone        string       `json:"timezone,omitempty"`
	ScheduleMode    ScheduleMode `json:"schedule_mode"`
	RunAt           string       `json:"run_at,omitempty"`
	IntervalSeconds int          `json:"interval_seconds,omitempty"`
	CronExpr        string       `json:"cron_expr,omitempty"`
	Prompt          string       `json:"prompt"`
}

func NewCreateJobRequest

func NewCreateJobRequest(input CreateJobInput) CreateJobRequest

func (CreateJobRequest) CreateInput

func (request CreateJobRequest) CreateInput() (CreateJobInput, error)

type DeliveryCreator

type DeliveryCreator interface {
	CreateClientDelivery(ctx context.Context, delivery core.ClientDelivery) (core.ClientDelivery, error)
}

type Fire

type Fire struct {
	ID           string     `json:"id"`
	JobID        string     `json:"job_id"`
	ScheduledFor time.Time  `json:"scheduled_for"`
	Status       FireStatus `json:"status"`
	ResultState  string     `json:"result_state,omitempty"`
	RunID        string     `json:"run_id,omitempty"`
	Error        string     `json:"error,omitempty"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	FinishedAt   *time.Time `json:"finished_at,omitempty"`
}

type FireResponse

type FireResponse struct {
	Fire Fire `json:"fire"`
}

type FireStatus

type FireStatus string
const (
	FireStatusPending   FireStatus = "pending"
	FireStatusRunning   FireStatus = "running"
	FireStatusCompleted FireStatus = "completed"
	FireStatusFailed    FireStatus = "failed"
	FireStatusSkipped   FireStatus = "skipped"
)

type Job

type Job struct {
	ID               string       `json:"id"`
	Kind             JobKind      `json:"kind"`
	Status           JobStatus    `json:"status"`
	SessionID        string       `json:"session_id"`
	Client           string       `json:"client,omitempty"`
	ExternalKey      string       `json:"external_key,omitempty"`
	Title            string       `json:"title,omitempty"`
	Timezone         string       `json:"timezone"`
	ScheduleMode     ScheduleMode `json:"schedule_mode"`
	RunAt            *time.Time   `json:"run_at,omitempty"`
	IntervalSeconds  int          `json:"interval_seconds,omitempty"`
	CronExpr         string       `json:"cron_expr,omitempty"`
	NextDueAt        *time.Time   `json:"next_due_at,omitempty"`
	LastScheduledFor *time.Time   `json:"last_scheduled_for,omitempty"`
	Prompt           string       `json:"prompt"`
	CreatedAt        time.Time    `json:"created_at"`
	UpdatedAt        time.Time    `json:"updated_at"`
	DeletedAt        *time.Time   `json:"deleted_at,omitempty"`
}

type JobFilter

type JobFilter struct {
	IncludeDeleted bool
	Status         JobStatus
	SessionID      string
	Limit          int
}

type JobKind

type JobKind string
const (
	JobKindReminder JobKind = "reminder"
	JobKindAITask   JobKind = "ai_task"
)

type JobResponse

type JobResponse struct {
	Job Job `json:"job"`
}

type JobStatus

type JobStatus string
const (
	JobStatusActive    JobStatus = "active"
	JobStatusPaused    JobStatus = "paused"
	JobStatusCompleted JobStatus = "completed"
	JobStatusDeleted   JobStatus = "deleted"
)

type JobsResponse

type JobsResponse struct {
	Jobs []Job `json:"jobs"`
}

type ReminderTool

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

func NewReminderTool

func NewReminderTool(service *Service) *ReminderTool

func (*ReminderTool) Execute

func (t *ReminderTool) Execute(ctx context.Context, call tools.Call) (tools.Result, error)

func (*ReminderTool) Spec

func (t *ReminderTool) Spec() tools.Spec

type RunGetter

type RunGetter interface {
	GetRun(ctx context.Context, runID string) (core.Run, error)
}

type Runner

type Runner interface {
	AcceptTriggeredRun(ctx context.Context, input core.HandleTriggeredRunInput) (core.AcceptRunResult, error)
}

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(path string) (*SQLiteStore, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) CreateAutomationFire

func (s *SQLiteStore) CreateAutomationFire(ctx context.Context, fire Fire) error

func (*SQLiteStore) CreateAutomationJob

func (s *SQLiteStore) CreateAutomationJob(ctx context.Context, job Job) error

func (*SQLiteStore) GetAutomationFireBySchedule

func (s *SQLiteStore) GetAutomationFireBySchedule(ctx context.Context, jobID string, scheduledFor time.Time) (Fire, error)

func (*SQLiteStore) GetAutomationJob

func (s *SQLiteStore) GetAutomationJob(ctx context.Context, jobID string) (Job, error)

func (*SQLiteStore) ListAutomationJobs

func (s *SQLiteStore) ListAutomationJobs(ctx context.Context, filter JobFilter) ([]Job, error)

func (*SQLiteStore) UpdateAutomationFire

func (s *SQLiteStore) UpdateAutomationFire(ctx context.Context, fire Fire) error

func (*SQLiteStore) UpdateAutomationJob

func (s *SQLiteStore) UpdateAutomationJob(ctx context.Context, job Job) error

type ScheduleMode

type ScheduleMode string
const (
	ScheduleModeOnce     ScheduleMode = "once"
	ScheduleModeInterval ScheduleMode = "interval"
	ScheduleModeCron     ScheduleMode = "cron"
)

type ScheduledAITaskTool

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

func NewScheduledAITaskTool

func NewScheduledAITaskTool(service *Service) *ScheduledAITaskTool

func (*ScheduledAITaskTool) Execute

func (t *ScheduledAITaskTool) Execute(ctx context.Context, call tools.Call) (tools.Result, error)

func (*ScheduledAITaskTool) Spec

func (t *ScheduledAITaskTool) Spec() tools.Spec

type Service

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

func NewService

func NewService(store Store, runner Runner, timezone string) *Service

func (*Service) CompleteJob

func (s *Service) CompleteJob(ctx context.Context, jobID string) (Job, error)

func (*Service) CreateJob

func (s *Service) CreateJob(ctx context.Context, input CreateJobInput) (Job, error)

func (*Service) CreateJobForRun

func (s *Service) CreateJobForRun(ctx context.Context, runID string, input CreateJobInput) (Job, error)

func (*Service) DeleteJob

func (s *Service) DeleteJob(ctx context.Context, jobID string) (Job, error)

func (*Service) GetJob

func (s *Service) GetJob(ctx context.Context, jobID string) (Job, error)

func (*Service) ListJobs

func (s *Service) ListJobs(ctx context.Context, filter JobFilter) ([]Job, error)

func (*Service) PauseJob

func (s *Service) PauseJob(ctx context.Context, jobID string) (Job, error)

func (*Service) ResumeJob

func (s *Service) ResumeJob(ctx context.Context, jobID string) (Job, error)

func (*Service) Run

func (s *Service) Run(ctx context.Context)

func (*Service) RunNow

func (s *Service) RunNow(ctx context.Context, jobID string) (Fire, error)

func (*Service) Tick

func (s *Service) Tick(ctx context.Context) error

func (*Service) WithClock

func (s *Service) WithClock(now func() time.Time) *Service

func (*Service) WithDeliveryTargets added in v0.1.10

func (s *Service) WithDeliveryTargets(targets []core.ClientDeliveryTarget) *Service

func (*Service) WithTickInterval

func (s *Service) WithTickInterval(interval time.Duration) *Service

type Store

type Store interface {
	CreateAutomationJob(ctx context.Context, job Job) error
	GetAutomationJob(ctx context.Context, jobID string) (Job, error)
	ListAutomationJobs(ctx context.Context, filter JobFilter) ([]Job, error)
	UpdateAutomationJob(ctx context.Context, job Job) error
	CreateAutomationFire(ctx context.Context, fire Fire) error
	GetAutomationFireBySchedule(ctx context.Context, jobID string, scheduledFor time.Time) (Fire, error)
	UpdateAutomationFire(ctx context.Context, fire Fire) error
}

Jump to

Keyboard shortcuts

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