memory

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 11 Imported by: 0 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 memory keeps the persistent notes native runs see at their start: entries the agent or the owner wrote and suggestions waiting for approval.

Index

Constants

View Source
const DefaultLimit = 20

DefaultLimit is how many entries a listing and the prompt hold.

Variables

View Source
var ErrInvalidInput = errors.New("invalid memory input")

ErrInvalidInput reports an entry or filter memory refuses.

Functions

func NewTool

func NewTool(service *Service) tools.Executor

NewTool is the memory tool: models list entries and suggest changes, which ask the user.

Types

type Entry

type Entry struct {
	ID         string `json:"id"`
	Scope      Scope  `json:"scope"`
	Key        string `json:"key,omitempty"`
	Content    string `json:"content"`
	WorkingDir string `json:"working_dir,omitempty"`
	// Pending marks a suggestion of a session review that waits for the
	// owner's approval; runs see only approved entries.
	Pending   bool      `json:"pending,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Filter

type Filter struct {
	Scope      Scope
	WorkingDir string
	Pending    bool
	Limit      int
}

Filter selects approved entries, or with Pending the suggestions.

type Scope

type Scope string
const (
	ScopeGlobal  Scope = "global"
	ScopeUser    Scope = "user"
	ScopeProject Scope = "project"
)

func ParseScope

func ParseScope(value string) (Scope, error)

ParseScope reads a scope in any case; empty is global.

type Service

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

Service checks and stamps entries before the store keeps them.

func New

func New(store Store, now func() time.Time) *Service

New keeps memory in store; a nil now is time.Now.

func (*Service) Approve

func (s *Service) Approve(ctx context.Context, id string) (Entry, error)

Approve turns a suggested entry into one that runs see.

func (*Service) Create

func (s *Service) Create(ctx context.Context, entry Entry) (Entry, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

func (*Service) List

func (s *Service) List(ctx context.Context, filter Filter) ([]Entry, error)

List lists the entries filter selects, of every scope when it names none.

func (*Service) PromptContext

func (s *Service) PromptContext(ctx context.Context, workingDir string) (string, error)

PromptContext is the memory section of the prompt of a run in workingDir; empty without entries.

func (*Service) Update

func (s *Service) Update(ctx context.Context, entry Entry) (Entry, error)

Update replaces the fields entry sets of the entry with its ID.

type Store

type Store interface {
	CreateMemory(ctx context.Context, entry Entry) error
	UpdateMemory(ctx context.Context, entry Entry) error
	DeleteMemory(ctx context.Context, id string) error
	GetMemory(ctx context.Context, id string) (Entry, error)
	ListMemories(ctx context.Context, filter Filter) ([]Entry, error)
}

Jump to

Keyboard shortcuts

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