tasks

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionParams

type ActionParams struct {
	Action  string // cancel, approve, reject, respond
	Message string // reason or response message
}

ActionParams holds parameters for task action handling.

type Config

type Config struct {
	Queries        *sqlc.Queries
	Notifier       notify.Notifier
	Memory         memory.Provider
	RunnerFactory  RunnerFactoryFn
	MaxConcurrency int // 0 = default 5
}

Config holds construction parameters for Service.

type CreateTaskParams

type CreateTaskParams struct {
	Title          string
	Description    string
	Priority       string
	AgentID        string
	UserID         string
	Deps           []string
	SchedulerJobID string
	SchedulerRunID string
}

CreateTaskParams holds parameters for creating a new task.

type RunnerFactoryFn

type RunnerFactoryFn func(agentID string) (agent.NewRunnerFunc, bool)

RunnerFactoryFn resolves a runner factory for a given agent ID. Returns false if the agent has no pool (task will be skipped).

type Service

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

Service manages task lifecycle: creation, dispatching workers, and actions.

func New

func New(cfg Config) *Service

New creates a Service from cfg.

func (*Service) CreateTask

func (s *Service) CreateTask(ctx context.Context, params CreateTaskParams) (sqlc.AgentTask, error)

CreateTask inserts a new task. The scheduler Tick dispatches it.

func (*Service) DeleteTask

func (s *Service) DeleteTask(ctx context.Context, id string, userID string) error

DeleteTask deletes a task (cancels running worker if present).

func (*Service) GetTask

func (s *Service) GetTask(ctx context.Context, id string, userID string) (sqlc.AgentTask, error)

GetTask returns a single task by ID.

func (*Service) HandleAction

func (s *Service) HandleAction(ctx context.Context, id string, userID string, action ActionParams) (sqlc.AgentTask, error)

HandleAction processes approve/reject/respond/cancel actions on a task.

func (*Service) ListTaskEvents

func (s *Service) ListTaskEvents(ctx context.Context, taskID string) ([]sqlc.AgentTaskEvent, error)

ListTaskEvents returns all events for a task ordered by creation time.

func (*Service) ListTasks

func (s *Service) ListTasks(ctx context.Context, userID, agentID, status string) ([]sqlc.AgentTask, error)

ListTasks returns tasks for a specific agent, filtered by status.

func (*Service) Start

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

Start initialises the service: resets stale running tasks to pending on startup. The caller is responsible for scheduling Tick on a recurring interval.

func (*Service) Stop

func (s *Service) Stop()

Stop cancels the service context and waits for all running workers to finish.

func (*Service) Tick

func (s *Service) Tick()

Tick is called by the external scheduler on a recurring interval. It performs three sweeps in order: notify, dep-failure check, dispatch.

func (*Service) UpdateTask

func (s *Service) UpdateTask(ctx context.Context, id string, userID string, update UpdateTaskParams) (sqlc.AgentTask, error)

UpdateTask updates mutable task fields (title, description, priority, agent_id).

type TaskControlTool

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

TaskControlTool is injected into task sessions. Its Execute method performs DB transitions directly.

func (*TaskControlTool) Definition

func (t *TaskControlTool) Definition() tools.Definition

func (*TaskControlTool) Execute

func (t *TaskControlTool) Execute(ctx context.Context, args map[string]any) (string, error)

type UpdateTaskParams

type UpdateTaskParams struct {
	Title       string
	Description string
	Priority    string
	AgentID     string
}

UpdateTaskParams holds parameters for updating task metadata.

Jump to

Keyboard shortcuts

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