memory

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package memory persists AI conversations and assembles context windows.

Index

Constants

View Source
const DefaultTitle = "New conversation"

DefaultTitle is shown until the first successful automatic or manual title.

Variables

This section is empty.

Functions

func CanAutoTitle added in v0.1.1

func CanAutoTitle(c models.AIConversation) bool

CanAutoTitle reports whether the conversation still owns the initial title slot.

Types

type MessagePage

type MessagePage struct {
	Messages    []models.AIMessage `json:"messages"`
	LoadedCount int                `json:"loadedCount"`
	TotalCount  int                `json:"totalCount"`
	HasMore     bool               `json:"hasMore"`
}

MessagePage is one UI window of conversation messages.

type Store

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

Store is the conversation persistence and context-assembly surface.

func (*Store) AppendAssistant

func (s *Store) AppendAssistant(ctx context.Context, convID, content, reasoning string, calls []models.AIToolCallRecord, truncated bool) error

AppendAssistant stores a finalized assistant message.

func (*Store) AppendUser

func (s *Store) AppendUser(ctx context.Context, convID, content string) error

func (*Store) Create

func (s *Store) Create(ctx context.Context, ownerID, connID, providerID, model string) (models.AIConversation, error)

Create starts a new conversation owned by the user on a connection.

func (*Store) Delete

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

Delete removes an owned conversation and its messages.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ownerID, id string) (models.AIConversation, error)

Get returns an owned conversation (others are hidden as not-found).

func (*Store) History

func (s *Store) History(ctx context.Context, convID string, tokenBudget int) (summary string, msgs []engine.Message, err error)

History returns compacted older turns plus recent messages within tokenBudget.

func (*Store) List

func (s *Store) List(ctx context.Context, ownerID, connID string) ([]models.AIConversation, error)

List returns the user's conversations for a connection (newest first).

func (*Store) Messages

func (s *Store) Messages(ctx context.Context, ownerID, id string) ([]models.AIMessage, error)

Messages returns a conversation's full ordered message history.

func (*Store) MessagesPage

func (s *Store) MessagesPage(ctx context.Context, ownerID, convID string, limit, loadedCount int) (MessagePage, error)

MessagesPage returns one page of an owned conversation's history.

func (*Store) RefreshSummary added in v0.1.1

func (s *Store) RefreshSummary(ctx context.Context, convID string) error

RefreshSummary folds newly aged-out messages into the persisted Summary, advancing the watermark so each message is compacted exactly once.

func (*Store) Rename

func (s *Store) Rename(ctx context.Context, ownerID, id, title string) (models.AIConversation, error)

Rename sets a user-provided title.

func (*Store) SetAutoTitle

func (s *Store) SetAutoTitle(ctx context.Context, convID, title string)

SetAutoTitle sets a system-generated title, leaving a user-set title untouched.

func (*Store) SetProvider added in v0.1.1

func (s *Store) SetProvider(ctx context.Context, convID, providerID, model string)

SetProvider records the provider and model a conversation last ran with.

Jump to

Keyboard shortcuts

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