Documentation
¶
Overview ¶
Package session provides conversation persistence with save, resume, and fork capabilities.
Index ¶
- Variables
- type ListResult
- type Manager
- func (m *Manager) ActiveID() string
- func (m *Manager) ActiveTitle() string
- func (m *Manager) Find(prefix string) (string, error)
- func (m *Manager) Fork()
- func (m *Manager) List() (ListResult, error)
- func (m *Manager) ListDisplay() (string, error)
- func (m *Manager) Resume(id string) (*Session, error)
- func (m *Manager) Save(title string, meta Meta, msgs message.Messages, todos *todo.List) (*Session, error)
- func (m *Manager) SetName(name string) error
- type Meta
- type Session
- type Store
- func (s *Store) Exists(id string) bool
- func (s *Store) Find(prefix string) (string, error)
- func (s *Store) List() (ListResult, error)
- func (s *Store) Load(id string) (*Session, error)
- func (s *Store) Path(id string) file.File
- func (s *Store) Read(f file.File) (*Session, error)
- func (s *Store) Rename(oldID, newID string) error
- func (s *Store) Save(session *Session) error
- type Summary
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("session not found")
ErrNotFound is returned by Find when no session matches the given prefix.
Functions ¶
This section is empty.
Types ¶
type ListResult ¶
ListResult holds session summaries and any warnings encountered during listing.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager orchestrates session save, resume, and fork operations.
func NewManager ¶
NewManager creates a Manager backed by the given Store.
func (*Manager) ActiveID ¶
ActiveID returns the ID of the active session, or the pending name, or empty string.
func (*Manager) ActiveTitle ¶
ActiveTitle returns the title of the current active session, or empty string.
func (*Manager) Fork ¶
func (m *Manager) Fork()
Fork clears the active session so the next Save creates a new one.
func (*Manager) List ¶
func (m *Manager) List() (ListResult, error)
List returns all stored session summaries along with any warnings about corrupt or unreadable session files.
func (*Manager) ListDisplay ¶
ListDisplay returns a formatted string of all sessions for display.
type Meta ¶
type Meta struct {
Agent string `json:"agent"`
Mode string `json:"mode"`
Think string `json:"think"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
Verbose bool `json:"verbose,omitempty"`
LoadedTools []string `json:"loaded_tools,omitempty"`
ReadBeforePolicy *tool.ReadBeforePolicy `json:"read_before_policy,omitempty"`
// Runtime toggles
Sandbox bool `json:"sandbox,omitempty"`
// Session-scoped state
SessionApprovals map[string]bool `json:"session_approvals,omitempty"`
Stats *stats.Stats `json:"stats,omitempty"`
CumulativeUsage *usage.Usage `json:"cumulative_usage,omitempty"`
}
Meta captures the assistant state at the time of save.
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 message.Messages `json:"messages"`
Meta Meta `json:"meta"`
Todos *todo.List `json:"todos,omitempty"`
}
Session is a complete conversation snapshot.
func (Session) FirstUserContent ¶
FirstUserContent returns the content of the first real user message, or empty string. Excludes internal types (DisplayOnly, Bookmark, Metadata).
func (Session) IsUUID ¶
IsUUID reports whether the session ID is a UUID (as opposed to a user-chosen name).
func (Session) ShortDisplay ¶
ShortDisplay returns a brief session identifier. Custom names are shown in full; UUIDs are truncated to 8 characters.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles JSON file-based session persistence.
func (*Store) Find ¶
Find resolves a session ID prefix to a full session ID. Returns an error if zero or multiple sessions match.
func (*Store) List ¶
func (s *Store) List() (ListResult, error)
List returns summaries of all sessions, sorted newest first. Corrupt or unreadable session files are reported as warnings rather than causing the entire listing to fail.
type Summary ¶
type Summary struct {
ID string `json:"id"`
Title string `json:"title"`
UpdatedAt time.Time `json:"updated_at"`
FirstUserMessage string `json:"first_user_message"`
}
Summary is a lightweight listing entry for a session.
func (Summary) IsUUID ¶
IsUUID reports whether the session ID is a UUID (as opposed to a user-chosen name).
func (Summary) PickerDescription ¶
PickerDescription returns secondary text for a picker item. Shows a humanized relative time and the short session ID.
func (Summary) PickerLabel ¶
PickerLabel returns the main display text for a picker item. Shows the title if set, otherwise falls back to a truncated first user message.