tasks

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tasks provides a standalone task tracking system. It can be used independently by an agent session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTool

func NewTool(store *Store) core.Tool

NewTool returns the tasks tool backed by the given store.

Types

type State

type State struct {
	Tasks      []Task `json:"tasks"`
	NextTaskID int    `json:"next_task_id"`
}

State is the serializable snapshot of the task store.

func StateFromMetadata

func StateFromMetadata(meta map[string]any) (State, bool)

StateFromMetadata decodes task state from session metadata. It returns false when the metadata has no valid task snapshot.

type Store

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

Store manages tasks with thread-safe access.

func NewStore

func NewStore() *Store

NewStore creates an empty task store.

func (*Store) Create

func (s *Store) Create(title, description string, dependsOn []int) Task

Create adds a new task. Returns the created task.

func (*Store) Get

func (s *Store) Get(id int) (Task, bool)

Get returns a copy of a task by ID. Returns (Task{}, false) if not found.

func (*Store) MarkDone

func (s *Store) MarkDone(id int) bool

MarkDone marks a task as done. Returns false if not found.

func (*Store) MarkDoneErr

func (s *Store) MarkDoneErr(id int) error

MarkDoneErr marks a task as done. Returns an error if the task is not found.

func (*Store) Progress

func (s *Store) Progress() (done, total int)

Progress returns (done, total) task counts.

func (*Store) Reset

func (s *Store) Reset()

Reset clears all tasks.

func (*Store) RestoreFromMetadata

func (s *Store) RestoreFromMetadata(meta map[string]any)

RestoreFromMetadata loads task state from session.Metadata.

func (*Store) RestoreState

func (s *Store) RestoreState(st State)

RestoreState loads state from a saved snapshot.

func (*Store) SaveState

func (s *Store) SaveState() State

SaveState returns the serializable state for session persistence.

func (*Store) SaveToMetadata

func (s *Store) SaveToMetadata() map[string]any

SaveToMetadata serializes task state for session.Metadata.

func (*Store) Tasks

func (s *Store) Tasks() []Task

Tasks returns a copy of the current task list.

func (*Store) Update

func (s *Store) Update(id int, title, description *string, dependsOn *[]int) bool

Update modifies a task's fields. Returns false if not found.

type Task

type Task struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Status      string `json:"status"` // "pending", "in_progress", "done"
	DependsOn   []int  `json:"depends_on,omitempty"`
	CreatedAt   int64  `json:"created_at,omitempty"`   // unix millis
	CompletedAt int64  `json:"completed_at,omitempty"` // unix millis
}

Task tracks a unit of work.

Jump to

Keyboard shortcuts

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