session

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package session provides persistence for agent conversations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	ID        string                   `json:"id"`
	Title     string                   `json:"title"`
	CreatedAt time.Time                `json:"created_at"`
	UpdatedAt time.Time                `json:"updated_at"`
	Messages  []anthropic.MessageParam `json:"messages"`
}

Session represents a saved conversation session.

func NewSession

func NewSession() (*Session, error)

NewSession creates a new session with a generated ID.

func (*Session) MessageCount

func (s *Session) MessageCount() int

MessageCount returns the number of messages in the session.

func (*Session) SetMessages

func (s *Session) SetMessages(messages []anthropic.MessageParam)

SetMessages replaces the session's messages.

func (*Session) SetTitle

func (s *Session) SetTitle(title string)

SetTitle sets the session title.

func (*Session) Summary

func (s *Session) Summary() Summary

Summary returns a Summary of the session without the full messages.

type Store

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

Store manages session persistence to the filesystem.

func NewStore

func NewStore(dir string) (*Store, error)

NewStore creates a new session store at the given directory. The directory will be created if it doesn't exist.

func StoreForWorkDir

func StoreForWorkDir(workDir string) (*Store, error)

StoreForWorkDir returns a Store using .milo/sessions in the given work directory.

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a session from disk.

func (*Store) List

func (s *Store) List() ([]Summary, error)

List returns summaries of all sessions, sorted by update time (newest first).

func (*Store) Load

func (s *Store) Load(id string) (*Session, error)

Load retrieves a session by ID.

func (*Store) MostRecent

func (s *Store) MostRecent() (*Session, error)

MostRecent returns the most recently updated session, or nil if no sessions exist.

func (*Store) Save

func (s *Store) Save(session *Session) error

Save persists a session to disk.

type Summary

type Summary struct {
	ID           string    `json:"id"`
	Title        string    `json:"title"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	MessageCount int       `json:"message_count"`
}

Summary contains metadata about a session for listing purposes.

Jump to

Keyboard shortcuts

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