Help us shape the future of Go! Take the 2026 Go Developer Survey

todo

package
v1.133.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CreateToolSet added in v1.60.0

func CreateToolSet(toolset latest.Toolset) (tools.ToolSet, error)

CreateToolSet is used by the tools registry.

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(*ToolSet)

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 ToolSet added in v1.60.0

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

func New added in v1.60.0

func New(opts ...Option) *ToolSet

func (*ToolSet) Instructions added in v1.60.0

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools added in v1.60.0

func (t *ToolSet) 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