tasks

package
v0.37.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 7 Imported by: 0

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