Documentation
¶
Index ¶
- Variables
- type CreateJobInput
- type CreateJobRequest
- type Fire
- type FireResponse
- type FireStatus
- type Job
- type JobFilter
- type JobKind
- type JobResponse
- type JobStatus
- type JobsResponse
- type ReminderTool
- type Runner
- type SQLiteStore
- func (s *SQLiteStore) CreateAutomationFire(ctx context.Context, fire Fire) error
- func (s *SQLiteStore) CreateAutomationJob(ctx context.Context, job Job) error
- func (s *SQLiteStore) GetAutomationFireBySchedule(ctx context.Context, jobID string, scheduledFor time.Time) (Fire, error)
- func (s *SQLiteStore) GetAutomationJob(ctx context.Context, jobID string) (Job, error)
- func (s *SQLiteStore) ListAutomationJobs(ctx context.Context, filter JobFilter) ([]Job, error)
- func (s *SQLiteStore) UpdateAutomationFire(ctx context.Context, fire Fire) error
- func (s *SQLiteStore) UpdateAutomationJob(ctx context.Context, job Job) error
- type ScheduleMode
- type ScheduledAITaskTool
- type Service
- func (s *Service) CompleteJob(ctx context.Context, jobID string) (Job, error)
- func (s *Service) Configure(settings Settings)
- func (s *Service) CreateJob(ctx context.Context, input CreateJobInput) (Job, error)
- func (s *Service) CreateJobForRun(ctx context.Context, runID string, input CreateJobInput) (Job, error)
- func (s *Service) DeleteJob(ctx context.Context, jobID string) (Job, error)
- func (s *Service) GetJob(ctx context.Context, jobID string) (Job, error)
- func (s *Service) ListJobs(ctx context.Context, filter JobFilter) ([]Job, error)
- func (s *Service) PauseJob(ctx context.Context, jobID string) (Job, error)
- func (s *Service) ResumeJob(ctx context.Context, jobID string) (Job, error)
- func (s *Service) Run(ctx context.Context)
- func (s *Service) RunNow(ctx context.Context, jobID string) (Fire, error)
- func (s *Service) Tick(ctx context.Context) error
- func (s *Service) WithClock(now func() time.Time) *Service
- type Settings
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateFire = errors.New("duplicate automation fire")
Functions ¶
This section is empty.
Types ¶
type CreateJobInput ¶
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 JobResponse ¶
type JobResponse struct {
Job Job `json:"job"`
}
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) 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 (*SQLiteStore) GetAutomationJob ¶
func (*SQLiteStore) ListAutomationJobs ¶
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) Preview ¶ added in v0.2.0
func (t *ScheduledAITaskTool) Preview(_ context.Context, call tools.Call) (tools.ApprovalRequest, error)
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 (*Service) CompleteJob ¶
func (*Service) Configure ¶ added in v0.2.1
Configure applies the settings; it is safe while jobs fire.
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.
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
}