memory

package
v0.3.15 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package memory defines injectable boundaries for memory/default and related plugins.

memory/default (*plugins/memory.Service) implements Service, Tool, Capture, Reader, Staging, and CommitObserverRegistrar (learning/default registers CommitObserver in New).

tool/memory requires cap/memory.Tool (typically memory.default). prompt/section/memory requires cap/memory.Reader. hook/background-review requires cap/memory.Capture (typically memory.default).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOutcome

type AddOutcome string

AddOutcome describes how a write changed memory.md.

const (
	AddOutcomeAdded     AddOutcome = "added"
	AddOutcomeDuplicate AddOutcome = "duplicate"
	AddOutcomeReplaced  AddOutcome = "replaced"
	AddOutcomeRemoved   AddOutcome = "removed"
)

type Capture

type Capture interface {
	CaptureMemoryAdd(ctx context.Context, text, source string) (string, error)
	CaptureMemoryReplace(ctx context.Context, oldText, content, source string) (string, error)
	CaptureMemoryRemove(ctx context.Context, oldText string) (string, error)
}

Capture applies learn_capture memory actions during background review.

type CommitObserver

type CommitObserver interface {
	OnMemoryCommitted(ctx context.Context, text, source string, outcome AddOutcome)
}

CommitObserver is notified after memory.md commits (e.g. learning records dreaming signals).

type CommitObserverRegistrar

type CommitObserverRegistrar interface {
	RegisterCommitObserver(CommitObserver)
}

CommitObserverRegistrar is implemented by memory/default for post-build wiring without config cycles.

type MemoryEntry

type MemoryEntry struct {
	Content string
	Meta    string
}

MemoryEntry is one §-delimited block in memory.md.

type MemoryToolInput

type MemoryToolInput struct {
	Action  string `json:"action" jsonschema:"add, replace, or remove"`
	Content string `json:"content,omitempty" jsonschema:"Entry text for add or replace. Required for add and replace."`
	OldText string `` /* 133-byte string literal not displayed */
}

MemoryToolInput is the main-agent memory tool schema.

type MemoryToolOutput

type MemoryToolOutput struct {
	Success        bool     `json:"success"`
	Message        string   `json:"message,omitempty"`
	Error          string   `json:"error,omitempty"`
	CurrentEntries []string `json:"current_entries,omitempty"`
	Usage          string   `json:"usage,omitempty"`
}

MemoryToolOutput is returned to the model as JSON.

type Reader

type Reader interface {
	LoadEntries(ctx context.Context) ([]MemoryEntry, int, int, error)
	PromptBody(ctx context.Context) (string, error)
}

Reader loads memory for prompt injection and display.

type Service

type Service interface {
	Tool
	Reader
	Capture
	Staging
	Disabled() bool
	// BackgroundReviewRequiresStaging is true when review memory_add should stage instead of writing memory.md.
	BackgroundReviewRequiresStaging(ctx context.Context) bool
	// ResolveRel resolves a path under configured memoryRoot (for dreaming/review sidecars).
	ResolveRel(ctx context.Context, parts ...string) (string, error)
}

Service is the default memory/default plugin surface.

type StagedEntry

type StagedEntry struct {
	ID      string
	Source  string
	Content string
	Action  string
	OldText string
}

StagedEntry is one pending memory write.

type Staging

type Staging interface {
	ListStaged(ctx context.Context) ([]StagedEntry, error)
	ApproveStaged(ctx context.Context, id string) (string, error)
	RejectStaged(ctx context.Context, id string) (string, error)
}

Staging lists and resolves staged memory awaiting approval.

type Tool

type Tool interface {
	MemoryTool(ctx context.Context, in MemoryToolInput) (MemoryToolOutput, error)
}

Tool is the main-agent personal memory tool.

Jump to

Keyboard shortcuts

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