tasks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalManager

func SetGlobalManager(manager *Manager)

SetGlobalManager sets the global task manager used by task tools.

Types

type Manager

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

Manager manages background task execution.

func GlobalManager

func GlobalManager() *Manager

GlobalManager returns the global task manager used by task tools.

func NewDefaultManager

func NewDefaultManager(client *engine.Engine, config *ManagerConfig) *Manager

NewDefaultManager creates and installs a global manager.

func NewManager

func NewManager(client *engine.Engine, config *ManagerConfig) *Manager

func (*Manager) CleanupTasks

func (m *Manager) CleanupTasks(maxAge time.Duration) int

CleanupTasks removes terminal tasks older than maxAge.

func (*Manager) CreateAgentTask

func (m *Manager) CreateAgentTask(ctx context.Context, prompt string, tools []tool.Tool) (*Task, error)

CreateAgentTask creates a new agent task.

func (*Manager) CreateBashTask

func (m *Manager) CreateBashTask(ctx context.Context, command string) (*Task, error)

CreateBashTask creates a new bash task.

func (*Manager) GetTask

func (m *Manager) GetTask(taskID TaskID) (*Task, error)

GetTask retrieves a task by ID.

func (*Manager) GetTaskStats

func (m *Manager) GetTaskStats() *TaskStats

GetTaskStats returns statistics about tasks.

func (*Manager) KillTask

func (m *Manager) KillTask(taskID TaskID) error

KillTask kills a running task.

func (*Manager) ListTasks

func (m *Manager) ListTasks() []*Task

ListTasks lists all tasks in stable order.

func (*Manager) ReadTaskOutput

func (m *Manager) ReadTaskOutput(taskID TaskID) (string, error)

ReadTaskOutput reads the output file for a task.

func (*Manager) ReadTaskOutputTail

func (m *Manager) ReadTaskOutputTail(taskID TaskID, maxLines int) (string, error)

ReadTaskOutputTail reads the tail of a task output file.

func (*Manager) SetCompletionCallback

func (m *Manager) SetCompletionCallback(cb TaskCompletionCallback)

SetCompletionCallback sets a callback that is called when any task completes

func (*Manager) WaitForTask

func (m *Manager) WaitForTask(ctx context.Context, taskID TaskID, timeout time.Duration) (*Task, error)

WaitForTask waits for a task to reach a terminal status.

func (*Manager) WatchTask

func (m *Manager) WatchTask(ctx context.Context, taskID TaskID) <-chan *Task

WatchTask watches a task for completion.

type ManagerConfig

type ManagerConfig struct {
	MaxConcurrentTasks int           `json:"max_concurrent_tasks"`
	TaskTimeout        time.Duration `json:"task_timeout"`
	OutputDir          string        `json:"output_dir"`
}

ManagerConfig represents the manager configuration.

func DefaultManagerConfig

func DefaultManagerConfig() *ManagerConfig

DefaultManagerConfig returns default manager configuration.

type Task

type Task struct {
	ID           TaskID          `json:"id"`
	Type         TaskType        `json:"type"`
	Status       TaskStatus      `json:"status"`
	Command      string          `json:"command,omitempty"`
	Prompt       string          `json:"prompt,omitempty"`
	SessionID    types.SessionID `json:"session_id,omitempty"`
	CreatedAt    time.Time       `json:"created_at"`
	StartedAt    *time.Time      `json:"started_at,omitempty"`
	CompletedAt  *time.Time      `json:"completed_at,omitempty"`
	Output       string          `json:"output,omitempty"`
	OutputFile   string          `json:"output_file,omitempty"`
	ExitCodeFile string          `json:"exit_code_file,omitempty"`
	Error        string          `json:"error,omitempty"`
	Progress     int             `json:"progress"`
	Description  string          `json:"description,omitempty"`
	ExitCode     *int            `json:"exit_code,omitempty"`
	PID          int             `json:"pid,omitempty"`
	// contains filtered or unexported fields
}

Task represents a background task.

type TaskCompletionCallback

type TaskCompletionCallback func(task *Task)

TaskCompletionCallback is called when a task completes.

type TaskID

type TaskID string

TaskID uniquely identifies a task.

type TaskStats

type TaskStats struct {
	Total     int `json:"total"`
	Pending   int `json:"pending"`
	Running   int `json:"running"`
	Completed int `json:"completed"`
	Failed    int `json:"failed"`
	Killed    int `json:"killed"`
}

TaskStats represents task statistics.

type TaskStatus

type TaskStatus string

TaskStatus represents the status of a task.

const (
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusRunning   TaskStatus = "running"
	TaskStatusCompleted TaskStatus = "completed"
	TaskStatusFailed    TaskStatus = "failed"
	TaskStatusKilled    TaskStatus = "killed"
)

type TaskType

type TaskType string

TaskType represents the type of task.

const (
	TaskTypeBash  TaskType = "bash"
	TaskTypeAgent TaskType = "agent"
)

Jump to

Keyboard shortcuts

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