tasks

package
v0.3.36 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTaskID

func GenerateTaskID(ty Type) string

GenerateTaskID creates a random task ID with a type prefix. Prefixes: b=bash, a=agent, r=remote, t=team, d=dream, w=workflow, m=monitor

func IsTerminal

func IsTerminal(s Status) bool

IsTerminal returns true if the task will not transition further.

Types

type Event

type Event struct {
	Timestamp time.Time      `json:"timestamp"`
	Type      string         `json:"type"` // "thought", "tool_call", "observation", "error"
	Content   string         `json:"content"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

Event captures a discrete event in the task's history.

type Handle

type Handle struct {
	TaskID  string
	Cleanup func()
}

Handle is a reference to a running task.

type Registry

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

Registry holds all known task implementations.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty task registry.

func (*Registry) Get

func (r *Registry) Get(ty Type) (Task, bool)

Get looks up a task by type.

func (*Registry) Register

func (r *Registry) Register(t Task)

Register adds a task implementation.

type StateBase

type StateBase struct {
	ID            string
	Type          Type
	Status        Status
	Description   string
	ToolUseID     string
	StartTime     int64
	EndTime       int64
	TotalPausedMs int64
	OutputFile    string
	OutputOffset  int64
	Notified      bool
	Events        []Event
}

StateBase is common to all task implementations.

func CreateStateBase

func CreateStateBase(id string, ty Type, description string, toolUseID string) StateBase

CreateStateBase initializes common task state.

func (*StateBase) AddEvent

func (s *StateBase) AddEvent(eventType, content string, metadata map[string]any)

AddEvent records a new event into the task's state.

type Status

type Status string

Status is the lifecycle state of a task.

const (
	StatusPending   Status = "pending"
	StatusRunning   Status = "running"
	StatusCompleted Status = "completed"
	StatusFailed    Status = "failed"
	StatusKilled    Status = "killed"
)

type Task

type Task interface {
	Name() string
	Type() Type
	Kill(taskID string) error
}

Task is the interface for all task kinds. Mirrors Claude Code's Task pattern: each task type knows how to spawn and kill.

type Type

type Type string

Type identifies the kind of task.

const (
	TypeLocalShell  Type = "local_bash"
	TypeLocalAgent  Type = "local_agent"
	TypeRemoteAgent Type = "remote_agent"
	TypeInProcess   Type = "in_process_teammate"
	TypeDream       Type = "dream"
	TypeWorkflow    Type = "local_workflow"
	TypeMonitorMCP  Type = "monitor_mcp"
)

Jump to

Keyboard shortcuts

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