automation

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 16 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

This section is empty.

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
	ClientCapabilities core.ClientCapabilities
	DeliveryAddress    json.RawMessage
	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"`
	ClientCapabilities core.ClientCapabilities `json:"client_capabilities,omitempty"`
	DeliveryAddress    json.RawMessage         `json:"delivery_address,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 Fire

type Fire struct {
	ID           string     `json:"id"`
	JobID        string     `json:"job_id"`
	ScheduledFor time.Time  `json:"scheduled_for"`
	Status       FireStatus `json:"status"`
	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 (
	FireStatusRunning   FireStatus = "running"
	FireStatusCompleted FireStatus = "completed"
	FireStatusFailed    FireStatus = "failed"
)

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"`
	// ClientCapabilities and DeliveryAddress are how the client takes the
	// job's results; a client that receives deliveries gets each one there.
	ClientCapabilities core.ClientCapabilities `json:"client_capabilities,omitempty"`
	DeliveryAddress    json.RawMessage         `json:"delivery_address,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
	// DueBy keeps the jobs due at or before it.
	DueBy time.Time
	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 Runner

type Runner interface {
	AcceptTriggeredRun(ctx context.Context, input core.HandleTriggeredRunInput) (core.AcceptRunResult, error)
	GetRun(ctx context.Context, runID string) (core.Run, error)
	CreateClientDelivery(ctx context.Context, delivery core.ClientDelivery) (core.ClientDelivery, error)
	ListClientDeliveries(ctx context.Context, filter core.ClientDeliveryFilter) ([]core.ClientDelivery, error)
}

Runner is what automation needs of core: it starts the job runs, reads the run a job is created from and queues the deliveries of results.

type SQLiteStore

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

SQLiteStore keeps jobs and fires in the store's database.

func NewSQLiteStore

func NewSQLiteStore(db *sql.DB) *SQLiteStore

NewSQLiteStore uses the store's connection; the tables are in its schema.

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) Preview added in v0.2.0

Preview validates the schedule before the user is asked.

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) *Service

func (*Service) CompleteJob

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

func (*Service) Configure added in v0.2.1

func (s *Service) Configure(settings Settings)

Configure applies the settings; it is safe while jobs fire.

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)

CreateJobForRun creates a job for the session, client and delivery address of the run that asks for it.

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

type Settings added in v0.2.1

type Settings struct {
	Timezone string
	Targets  []core.ClientDeliveryTarget
}

Settings are automation's settings from setup.json: the timezone of jobs created without one and the targets every job's results also go to.

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