todo

package
v1.58.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNameCreateTodo  = "create_todo"
	ToolNameCreateTodos = "create_todos"
	ToolNameUpdateTodos = "update_todos"
	ToolNameListTodos   = "list_todos"
)

Variables

View Source
var NewSharedTodoTool = sync.OnceValue(func() *Tool { return NewTodoTool() })

Functions

This section is empty.

Types

type CreateTodoArgs

type CreateTodoArgs struct {
	Description string `json:"description" jsonschema:"Description of the todo item"`
}

type CreateTodoOutput

type CreateTodoOutput struct {
	Created  Todo   `json:"created" jsonschema:"The created todo item"`
	AllTodos []Todo `json:"all_todos" jsonschema:"Current state of all todo items"`
	Reminder string `json:"reminder,omitempty" jsonschema:"Reminder about incomplete todos that still need to be completed"`
}

type CreateTodosArgs

type CreateTodosArgs struct {
	Descriptions []string `json:"descriptions" jsonschema:"Descriptions of the todo items"`
}

type CreateTodosOutput

type CreateTodosOutput struct {
	Created  []Todo `json:"created" jsonschema:"List of created todo items"`
	AllTodos []Todo `json:"all_todos" jsonschema:"Current state of all todo items"`
	Reminder string `json:"reminder,omitempty" jsonschema:"Reminder about incomplete todos that still need to be completed"`
}

type ListTodosOutput

type ListTodosOutput struct {
	Todos    []Todo `json:"todos" jsonschema:"List of all current todo items"`
	Reminder string `json:"reminder,omitempty" jsonschema:"Reminder about incomplete todos that still need to be completed"`
}

type MemoryTodoStorage

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

MemoryTodoStorage is an in-memory, concurrency-safe implementation of Storage.

func NewMemoryTodoStorage

func NewMemoryTodoStorage() *MemoryTodoStorage

func (*MemoryTodoStorage) Add

func (s *MemoryTodoStorage) Add(_ context.Context, todo Todo)

func (*MemoryTodoStorage) All

func (s *MemoryTodoStorage) All(_ context.Context) []Todo

func (*MemoryTodoStorage) Clear

func (s *MemoryTodoStorage) Clear(_ context.Context)

func (*MemoryTodoStorage) FindByID

func (s *MemoryTodoStorage) FindByID(_ context.Context, id string) int

func (*MemoryTodoStorage) Len

func (*MemoryTodoStorage) Update

func (s *MemoryTodoStorage) Update(_ context.Context, index int, fn func(Todo) Todo)

type Option

type Option func(*Tool)

Option is a functional option for configuring a Tool.

func WithStorage

func WithStorage(storage Storage) Option

WithStorage sets a custom storage implementation for the Tool. The provided storage must not be nil.

type Storage

type Storage interface {
	// Add appends a new todo item.
	Add(ctx context.Context, todo Todo)
	// All returns a copy of all todo items.
	All(ctx context.Context) []Todo
	// Len returns the number of todo items.
	Len(ctx context.Context) int
	// FindByID returns the index of the todo with the given ID, or -1 if not found.
	FindByID(ctx context.Context, id string) int
	// Update modifies the todo at the given index using the provided function.
	Update(ctx context.Context, index int, fn func(Todo) Todo)
	// Clear removes all todo items.
	Clear(ctx context.Context)
}

Storage defines the storage layer for todo items.

type Todo

type Todo struct {
	ID          string `json:"id" jsonschema:"ID of the todo item"`
	Description string `json:"description" jsonschema:"Description of the todo item"`
	Status      string `json:"status" jsonschema:"Status of the todo item (pending, in-progress, completed)"`
}

type Tool

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

func NewTodoTool

func NewTodoTool(opts ...Option) *Tool

func (*Tool) Instructions

func (t *Tool) Instructions() string

func (*Tool) Tools

func (t *Tool) Tools(context.Context) ([]tools.Tool, error)

type Update

type Update struct {
	ID     string `json:"id" jsonschema:"ID of the todo item"`
	Status string `json:"status" jsonschema:"New status (pending, in-progress, completed)"`
}

type UpdateTodosArgs

type UpdateTodosArgs struct {
	Updates []Update `json:"updates" jsonschema:"List of todo updates"`
}

type UpdateTodosOutput

type UpdateTodosOutput struct {
	Updated  []Update `json:"updated,omitempty" jsonschema:"List of successfully updated todos"`
	NotFound []string `json:"not_found,omitempty" jsonschema:"IDs of todos that were not found"`
	AllTodos []Todo   `json:"all_todos" jsonschema:"Current state of all todo items"`
	Reminder string   `json:"reminder,omitempty" jsonschema:"Reminder about incomplete todos that still need to be completed"`
}

Jump to

Keyboard shortcuts

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