Documentation
¶
Index ¶
- Variables
- func BuildDispatchText(action Action) (string, error)
- func NextRunAt(from time.Time, schedule Schedule) time.Time
- func ShouldEscalateInternalWorkflowFailure(task Task) bool
- func ValidateTask(task Task) error
- type Action
- type ActionType
- type Actor
- type Engine
- func (e *Engine) RegisterSystemTask(name string, interval time.Duration, run SystemTaskFunc) error
- func (e *Engine) Run(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 LLMRunner
- type ManageMode
- type Route
- type Schedule
- type ScheduleType
- type Scope
- type ScopeKind
- type Sender
- type SessionActivityChecker
- 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) GetTask(taskID string) (Task, error)
- func (s *Store) ListTasks(scope Scope, statusFilter string, limit int) ([]Task, 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) RecordTaskSignal(taskID string, at time.Time, kind, message string, pause bool) error
- func (s *Store) RecordTaskSourceMessageID(taskID, messageID string) error
- func (s *Store) ResetRunningTasks() error
- func (s *Store) UnclaimTask(taskID string) error
- type SystemTaskFunc
- type Task
- type TaskStatus
- type UserTaskCompletionHook
Constants ¶
This section is empty.
Variables ¶
var (
ErrTaskNotFound = errors.New("automation task not found")
)
Functions ¶
func BuildDispatchText ¶
func ShouldEscalateInternalWorkflowFailure ¶ added in v0.6.36
func ValidateTask ¶
Types ¶
type Action ¶
type Action struct {
Type ActionType `json:"type"`
Text string `json:"text"`
Prompt string `json:"prompt,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Profile string `json:"profile,omitempty"`
StateKey string `json:"state_key,omitempty"`
SessionKey string `json:"session_key,omitempty"`
ResumeThreadID string `json:"resume_thread_id,omitempty"`
SourceMessageID string `json:"source_message_id,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Variant string `json:"variant,omitempty"`
Personality string `json:"personality,omitempty"`
PromptPrefix string `json:"prompt_prefix,omitempty"`
WorkspaceDir string `json:"workspace_dir,omitempty"`
MentionUserIDs []string `json:"mention_user_ids,omitempty"`
}
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) RegisterSystemTask ¶
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 LLMRunner ¶
type LLMRunner interface {
Run(ctx context.Context, req agentbridge.RunRequest) (agentbridge.RunResult, error)
}
type ManageMode ¶
type ManageMode string
const ( ManageModeCreatorOnly ManageMode = "creator_only" ManageModeScopeAll ManageMode = "scope_all" )
type Schedule ¶
type Schedule struct {
Type ScheduleType `json:"type"`
EverySeconds int `json:"every_seconds"`
CronExpr string `json:"cron_expr,omitempty"`
}
type ScheduleType ¶
type ScheduleType string
const ( ScheduleTypeInterval ScheduleType = "interval" ScheduleTypeCron ScheduleType = "cron" )
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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) ClaimDueTasks ¶
func (*Store) RecordTaskResult ¶
func (*Store) RecordTaskResumeThreadID ¶ added in v0.6.48
func (*Store) RecordTaskSignal ¶ added in v0.5.23
func (*Store) RecordTaskSourceMessageID ¶ added in v0.6.49
RecordTaskSourceMessageID persists the first sent message ID as the thread anchor for subsequent runs. It only writes if source_message_id is not yet set, making it safe to call on every successful run.
func (*Store) ResetRunningTasks ¶
func (*Store) UnclaimTask ¶ added in v0.6.62
UnclaimTask reverts a prior ClaimDueTasks claim for the given task. It sets Running=false, decrements RunCount (if positive), and resets NextRunAt to zero so the task becomes immediately eligible on the next scheduling tick. This is used when the engine skips execution because the target session is busy, without recording a run result. NOTE: Implemented via updateSnapshot (not PatchTask) to bypass the auto-recompute of NextRunAt that PatchTask applies to active tasks.
type SystemTaskFunc ¶
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Scope Scope `json:"scope"`
Route Route `json:"route"`
Creator Actor `json:"creator"`
ManageMode ManageMode `json:"manage_mode"`
Schedule Schedule `json:"schedule"`
Action Action `json:"action"`
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"`
LastSignalKind string `json:"last_signal_kind,omitempty"`
LastSignalMessage string `json:"last_signal_message,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)