journal

package
v0.13.0-go Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package journal provides per-session memory of key actions extracted from assistant responses, enabling context recall when users ask about earlier work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxEntries           int
	MaxAgeMs             int64
	MaxEventsPerResponse int
}

Config controls journal behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Entry

type Entry struct {
	Timestamp int64 // unix millis
	Action    string
	Model     string
}

Entry is a single recorded action.

type SessionJournal

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

SessionJournal stores per-session action journals.

func New

func New(cfg Config) *SessionJournal

New creates a SessionJournal with the given config.

func (*SessionJournal) Clear

func (sj *SessionJournal) Clear(sessionID string)

Clear removes the journal for a specific session.

func (*SessionJournal) ClearAll

func (sj *SessionJournal) ClearAll()

ClearAll removes all journals.

func (*SessionJournal) ExtractEvents

func (sj *SessionJournal) ExtractEvents(content string) []string

ExtractEvents scans assistant response content for action patterns.

func (*SessionJournal) Format

func (sj *SessionJournal) Format(sessionID string) string

Format renders the session journal as a block for system message injection.

func (*SessionJournal) GetEntries

func (sj *SessionJournal) GetEntries(sessionID string) []Entry

GetEntries returns raw journal entries for a session.

func (*SessionJournal) GetStats

func (sj *SessionJournal) GetStats() Stats

GetStats returns aggregate statistics about the journal store.

func (*SessionJournal) NeedsContext

func (sj *SessionJournal) NeedsContext(lastUserMessage string) bool

NeedsContext returns true if the user message triggers session history recall.

func (*SessionJournal) Record

func (sj *SessionJournal) Record(sessionID string, events []string, model string)

Record adds extracted events to the session journal, trimming by maxAge and maxEntries.

type Stats

type Stats struct {
	Sessions     int `json:"sessions"`
	TotalEntries int `json:"totalEntries"`
}

Stats holds journal-level statistics.

Jump to

Keyboard shortcuts

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