task

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTaskService

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

DBTaskService is a DB-backed implementation of the Task Service.

func NewDBTaskService

func NewDBTaskService(db *sql.DB) *DBTaskService

func (*DBTaskService) CreateTask

func (s *DBTaskService) CreateTask(ctx context.Context, title, sessionID string, steps []Step) (*Task, error)

func (*DBTaskService) GetTask

func (s *DBTaskService) GetTask(ctx context.Context, id string) (*Task, error)

func (*DBTaskService) ListTasks

func (s *DBTaskService) ListTasks(ctx context.Context) ([]Task, error)

func (*DBTaskService) UpdateStep

func (s *DBTaskService) UpdateStep(ctx context.Context, taskID string, stepIndex int, newStatus StepStatus, output string, errMsg string) error

type InMemoryTaskService

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

InMemoryTaskService is a thread-safe in-memory implementation of Service.

func NewInMemoryTaskService

func NewInMemoryTaskService() *InMemoryTaskService

NewInMemoryTaskService creates a new in-memory task service.

func (*InMemoryTaskService) CreateTask

func (s *InMemoryTaskService) CreateTask(title, sessionID string, steps []Step) (*Task, error)

CreateTask creates a new task with the given title, session and steps.

func (*InMemoryTaskService) GetTask

func (s *InMemoryTaskService) GetTask(id string) (*Task, error)

GetTask retrieves a task by ID.

func (*InMemoryTaskService) ListTasks

func (s *InMemoryTaskService) ListTasks() ([]Task, error)

ListTasks returns all tasks.

func (*InMemoryTaskService) UpdateStep

func (s *InMemoryTaskService) UpdateStep(taskID string, stepIndex int, newStatus StepStatus, output string, errMsg string) error

UpdateStep updates a specific step within a task.

type Service

type Service interface {
	// CreateTask creates a new task with the given title, session and steps.
	CreateTask(title, sessionID string, steps []Step) (*Task, error)
	// GetTask retrieves a task by ID.
	GetTask(id string) (*Task, error)
	// UpdateStep updates a specific step within a task.
	UpdateStep(taskID string, stepIndex int, newStatus StepStatus, output string, err string) error
	// ListTasks returns all tasks.
	ListTasks() ([]Task, error)
}

Service defines the contract for a task planning and execution service.

type Step

type Step struct {
	ID          string     // unique step identifier
	Description string     // what this step does
	Type        string     // "freeform" or "structured"
	Status      StepStatus // current status
	RetryCount  int        // how many retries have occurred
	Output      string     // textual output from execution
	Error       string     // error message if failed
}

Step describes a single actionable unit within a Task.

type StepStatus

type StepStatus string

StepStatus represents the status of an individual task step.

const (
	StepPending   StepStatus = "pending"
	StepRunning   StepStatus = "running"
	StepCompleted StepStatus = "completed"
	StepFailed    StepStatus = "failed"
)

type Task

type Task struct {
	ID               string // unique task identifier
	SessionID        string // session this task belongs to
	Title            string // human-readable title
	Status           TaskStatus
	CurrentStepIndex int       // index of the currently active step
	Steps            []Step    // ordered list of steps
	CreatedAt        time.Time // creation timestamp
	UpdatedAt        time.Time // last update timestamp
}

Task represents a multi-step plan that agents can execute.

type TaskStatus

type TaskStatus string

TaskStatus represents the high-level status of a multi-step task.

const (
	TaskPending   TaskStatus = "pending"
	TaskRunning   TaskStatus = "running"
	TaskCompleted TaskStatus = "completed"
	TaskFailed    TaskStatus = "failed"
)

Jump to

Keyboard shortcuts

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