Help us shape the future of Go! Take the 2026 Go Developer Survey

task

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("task not found")

ErrNotFound is returned when a task is not found.

View Source
var ErrTerminalState = errors.New("task is in terminal state")

ErrTerminalState is returned when a task is in a terminal state and cannot be modified.

Functions

This section is empty.

Types

type Registry

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

Registry is a thread-safe in-memory task registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty task registry.

func (*Registry) AppendOutput

func (r *Registry) AppendOutput(taskID string, output string) error

AppendOutput appends text to the task's output.

func (*Registry) AssignTeam

func (r *Registry) AssignTeam(taskID string, teamID string) error

AssignTeam associates a task with a team.

func (*Registry) Create

func (r *Registry) Create(prompt string, description *string) Task

Create creates a new task with the given prompt and optional description.

func (*Registry) CreateFromPacket

func (r *Registry) CreateFromPacket(packet TaskPacket) (Task, error)

CreateFromPacket creates a new task from a validated TaskPacket.

func (*Registry) Get

func (r *Registry) Get(taskID string) (Task, bool)

Get retrieves a task by ID. Returns (Task, true) if found.

func (*Registry) IsEmpty

func (r *Registry) IsEmpty() bool

IsEmpty returns true if the registry has no tasks.

func (*Registry) Len

func (r *Registry) Len() int

Len returns the number of tasks in the registry.

func (*Registry) List

func (r *Registry) List(statusFilter *TaskStatus) []Task

List returns all tasks, optionally filtered by status.

func (*Registry) Output

func (r *Registry) Output(taskID string) (string, error)

Output returns the accumulated output for a task.

func (*Registry) Remove

func (r *Registry) Remove(taskID string) *Task

Remove hard-deletes a task. Returns the removed task if it existed.

func (*Registry) SetStatus

func (r *Registry) SetStatus(taskID string, status TaskStatus) error

SetStatus updates the task's status unconditionally. Matching Rust: set_status() does not guard against terminal states, allowing recovery-driven status changes on completed/failed tasks.

func (*Registry) Stop

func (r *Registry) Stop(taskID string) (Task, error)

Stop marks a task as stopped. Returns ErrTerminalState if already terminal.

func (*Registry) Update

func (r *Registry) Update(taskID string, message string) (Task, error)

Update adds a user message to the task. Matching Rust: update() does not guard against terminal states.

type Task

type Task struct {
	TaskID      string        `json:"task_id"`
	Prompt      string        `json:"prompt"`
	Description *string       `json:"description,omitempty"`
	TaskPacket  *TaskPacket   `json:"task_packet,omitempty"`
	Status      TaskStatus    `json:"status"`
	CreatedAt   uint64        `json:"created_at"`
	UpdatedAt   uint64        `json:"updated_at"`
	Messages    []TaskMessage `json:"messages"`
	Output      string        `json:"output"`
	TeamID      *string       `json:"team_id,omitempty"`
}

Task represents a sub-agent task.

type TaskMessage

type TaskMessage struct {
	Role      string `json:"role"`
	Content   string `json:"content"`
	Timestamp uint64 `json:"timestamp"`
}

TaskMessage is a message associated with a task.

type TaskPacket

type TaskPacket struct {
	Objective         string   `json:"objective"`
	Scope             string   `json:"scope"`
	Repo              string   `json:"repo"`
	BranchPolicy      string   `json:"branch_policy"`
	AcceptanceTests   []string `json:"acceptance_tests"`
	CommitPolicy      string   `json:"commit_policy"`
	ReportingContract string   `json:"reporting_contract"`
	EscalationPolicy  string   `json:"escalation_policy"`
}

TaskPacket is a structured task specification.

func ValidatePacket

func ValidatePacket(p TaskPacket) (*TaskPacket, error)

ValidatePacket validates a TaskPacket and returns an error if any fields are empty.

type TaskPacketValidationError

type TaskPacketValidationError struct {
	Errors []string
}

TaskPacketValidationError accumulates validation errors.

func (*TaskPacketValidationError) Error

func (e *TaskPacketValidationError) Error() string

type TaskStatus

type TaskStatus int

TaskStatus represents the lifecycle state of a task.

const (
	StatusCreated TaskStatus = iota
	StatusRunning
	StatusCompleted
	StatusFailed
	StatusStopped
)

func (TaskStatus) IsTerminal

func (s TaskStatus) IsTerminal() bool

IsTerminal returns true if the status is a terminal state.

func (TaskStatus) MarshalJSON

func (s TaskStatus) MarshalJSON() ([]byte, error)

func (TaskStatus) String

func (s TaskStatus) String() string

func (*TaskStatus) UnmarshalJSON

func (s *TaskStatus) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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