Documentation
¶
Index ¶
- Variables
- func NextRunAt(from time.Time, schedule Schedule) time.Time
- func SetGoalTemplates(cont, timeout string)
- func ValidateGoal(goal GoalTask) error
- func ValidateTask(task Task) error
- type Actor
- type Engine
- func (e *Engine) ExecuteGoal(ctx context.Context, scope Scope) error
- func (e *Engine) RegisterSystemTask(name string, interval time.Duration, run SystemTaskFunc) error
- func (e *Engine) Run(ctx context.Context)
- func (e *Engine) RunWatchdogOnce(ctx context.Context)
- func (e *Engine) SetLLMRunner(runner LLMRunner)
- func (e *Engine) SetRunEnv(env map[string]string)
- func (e *Engine) SetSessionActivityChecker(checker SessionActivityChecker)
- func (e *Engine) SetUserTaskCompletionHook(hook UserTaskCompletionHook)
- func (e *Engine) SetUserTaskTimeout(timeout time.Duration)
- type GoalStatus
- type GoalTask
- type LLMRunner
- type ManageMode
- type Route
- type Schedule
- type Scope
- type ScopeKind
- type Sender
- type SessionActivityChecker
- type SessionActivityGate
- type SessionThreadProvider
- type Snapshot
- type Store
- func (s *Store) ClaimDueTasks(at time.Time, limit int) ([]Task, error)
- func (s *Store) CreateTask(task Task) (Task, error)
- func (s *Store) DeleteGoal(scope Scope) error
- func (s *Store) GetGoal(scope Scope) (GoalTask, error)
- func (s *Store) GetTask(taskID string) (Task, error)
- func (s *Store) ListGoals(filterStatus GoalStatus) ([]GoalTask, error)
- func (s *Store) ListTasks(scope Scope, statusFilter string, limit int) ([]Task, error)
- func (s *Store) PatchGoal(scope Scope, mutate func(goal *GoalTask) error) (GoalTask, error)
- func (s *Store) PatchTask(taskID string, mutate func(task *Task) error) (Task, error)
- func (s *Store) Path() string
- func (s *Store) RecordTaskResult(taskID string, at time.Time, runErr error) error
- func (s *Store) RecordTaskResumeThreadID(taskID, nextThreadID string) error
- func (s *Store) RecordTaskSourceMessageID(taskID, messageID string) error
- func (s *Store) ReplaceGoal(goal GoalTask) (GoalTask, error)
- func (s *Store) ResetRunningGoals() error
- func (s *Store) ResetRunningTasks() error
- func (s *Store) ScanWatchdogAlerts(at time.Time, overdueGrace, runningGrace time.Duration) ([]TaskWatchdogAlert, error)
- func (s *Store) UnclaimTask(taskID string) error
- type SystemTaskFunc
- type Task
- type TaskStatus
- type TaskWatchdogAlert
- type TaskWatchdogAlertKind
- type UserTaskCompletionHook
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrGoalNotFound = errors.New("goal not found")
)
View Source
var (
ErrTaskNotFound = errors.New("automation task not found")
)
Functions ¶
func SetGoalTemplates ¶ added in v0.6.95
func SetGoalTemplates(cont, timeout string)
func ValidateGoal ¶ added in v0.6.95
func ValidateTask ¶
Types ¶
type Actor ¶
type Actor struct {
UserID string `json:"user_id,omitempty"`
OpenID string `json:"open_id,omitempty"`
Name string `json:"name,omitempty"`
}
func (Actor) PreferredID ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) ExecuteGoal ¶ added in v0.6.95
func (*Engine) RegisterSystemTask ¶
func (*Engine) RunWatchdogOnce ¶ added in v0.6.76
func (*Engine) SetLLMRunner ¶
func (*Engine) SetSessionActivityChecker ¶ added in v0.6.62
func (e *Engine) SetSessionActivityChecker(checker SessionActivityChecker)
func (*Engine) SetUserTaskCompletionHook ¶ added in v0.6.0
func (e *Engine) SetUserTaskCompletionHook(hook UserTaskCompletionHook)
func (*Engine) SetUserTaskTimeout ¶
type GoalStatus ¶ added in v0.6.95
type GoalStatus string
const ( GoalStatusActive GoalStatus = "active" GoalStatusPaused GoalStatus = "paused" GoalStatusComplete GoalStatus = "complete" GoalStatusTimeout GoalStatus = "timeout" GoalStatusWaitingForSession GoalStatus = "waiting_for_session" )
func (GoalStatus) IsTerminal ¶ added in v0.6.95
func (s GoalStatus) IsTerminal() bool
type GoalTask ¶ added in v0.6.95
type GoalTask struct {
ID string `json:"id"`
Objective string `json:"objective"`
Status GoalStatus `json:"status"`
DeadlineAt time.Time `json:"deadline_at"`
ThreadID string `json:"thread_id,omitempty"`
Scope Scope `json:"scope"`
Route Route `json:"route"`
Creator Actor `json:"creator"`
SessionKey string `json:"session_key,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision int64 `json:"revision"`
Running bool `json:"running,omitempty"`
}
func NormalizeGoal ¶ added in v0.6.95
type ManageMode ¶
type ManageMode string
const ( ManageModeCreatorOnly ManageMode = "creator_only" ManageModeScopeAll ManageMode = "scope_all" )
type Sender ¶ added in v0.3.20
type Sender = messaging.AutomationSender
type SessionActivityChecker ¶ added in v0.6.62
SessionActivityChecker checks whether a session is currently processing a user message. The automation engine uses this to skip task execution when the target session is busy, avoiding interruption of user conversations.
type SessionActivityGate ¶ added in v0.6.80
type SessionActivityGate interface {
SessionActivityChecker
TryAcquireSession(sessionKey string, cancel context.CancelCauseFunc) bool
ReleaseSession(sessionKey string)
}
SessionActivityGate extends SessionActivityChecker with the ability to register an automation task run as an active session entry, so that:
- subsequent IsSessionActive checks (including from other ticks) see the session as busy
- incoming user messages can interrupt the task via the provided cancel function (using the same version-based interruption mechanism used for user-initiated LLM runs)
type SessionThreadProvider ¶ added in v0.6.110
SessionThreadProvider is an optional interface that SessionActivityChecker implementors can also implement to expose the current backend thread ID for a session. The goal engine uses this to transition GoalStatusWaitingForSession goals to Active once a session obtains a ThreadID.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) ClaimDueTasks ¶
func (*Store) DeleteGoal ¶ added in v0.6.95
func (*Store) ListGoals ¶ added in v0.6.107
func (s *Store) ListGoals(filterStatus GoalStatus) ([]GoalTask, error)
func (*Store) RecordTaskResult ¶
func (*Store) RecordTaskResumeThreadID ¶ added in v0.6.48
func (*Store) RecordTaskSourceMessageID ¶ added in v0.6.49
func (*Store) ReplaceGoal ¶ added in v0.6.95
func (*Store) ResetRunningGoals ¶ added in v0.6.107
func (*Store) ResetRunningTasks ¶
func (*Store) ScanWatchdogAlerts ¶ added in v0.6.76
func (*Store) UnclaimTask ¶ added in v0.6.62
type SystemTaskFunc ¶
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Prompt string `json:"prompt"`
Fresh bool `json:"fresh,omitempty"`
Schedule Schedule `json:"schedule"`
Scope Scope `json:"scope"`
Route Route `json:"route"`
Creator Actor `json:"creator"`
ManageMode ManageMode `json:"manage_mode"`
SessionKey string `json:"session_key,omitempty"`
ResumeThreadID string `json:"resume_thread_id,omitempty"`
SourceMessageID string `json:"source_message_id,omitempty"`
Status TaskStatus `json:"status"`
MaxRuns int `json:"max_runs,omitempty"`
RunCount int `json:"run_count,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
NextRunAt time.Time `json:"next_run_at"`
LastRunAt time.Time `json:"last_run_at,omitempty"`
DeletedAt time.Time `json:"deleted_at,omitempty"`
Running bool `json:"running,omitempty"`
LastResult string `json:"last_result,omitempty"`
ConsecutiveFailures int `json:"consecutive_failures,omitempty"`
Revision int64 `json:"revision"`
}
func NormalizeTask ¶
type TaskStatus ¶
type TaskStatus string
const ( TaskStatusActive TaskStatus = "active" TaskStatusPaused TaskStatus = "paused" TaskStatusDeleted TaskStatus = "deleted" )
func ParseStatusFilter ¶
func ParseStatusFilter(raw string) (TaskStatus, bool, error)
type TaskWatchdogAlert ¶ added in v0.6.76
type TaskWatchdogAlertKind ¶ added in v0.6.76
type TaskWatchdogAlertKind string
const ( TaskWatchdogAlertOverdue TaskWatchdogAlertKind = "overdue" TaskWatchdogAlertStuck TaskWatchdogAlertKind = "stuck" )
type UserTaskCompletionHook ¶ added in v0.6.0
Click to show internal directories.
Click to hide internal directories.