Documentation
¶
Overview ¶
Package session stores resumable SuperCode conversations as local JSON.
Index ¶
- Constants
- Variables
- type Checkpoint
- type Event
- type Metadata
- type RepairReport
- type Session
- type Store
- func (s *Store) Append(id, eventType string, payload any) error
- func (s *Store) Archive(id string) (Session, error)
- func (s *Store) Commit(value Session) error
- func (s *Store) Delete(id string) error
- func (s *Store) Events(id string) ([]Event, error)
- func (s *Store) Fork(id string) (Session, error)
- func (s *Store) Latest(workspace string) (Session, error)
- func (s *Store) List(workspace string, limit int) ([]Session, error)
- func (s *Store) ListAll(workspace string, limit int, includeArchived bool) ([]Session, error)
- func (s *Store) ListMetadata(workspace, query string, limit int, includeArchived bool) (items []Metadata, warnings []string, err error)
- func (s *Store) Load(id string) (Session, error)
- func (s *Store) New(workspace, model string) (Session, error)
- func (s *Store) Rename(id, title string) (Session, error)
- func (s *Store) Repair() (RepairReport, error)
- func (s *Store) Save(value Session) error
- func (s *Store) Search(workspace, query string, limit int, includeArchived bool) ([]Session, error)
Constants ¶
const CurrentVersion = 4
Variables ¶
var ErrSessionConflict = errors.New("session changed in another process")
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
BaseMessageCount int `json:"base_message_count,omitempty"`
BaseRevision uint64 `json:"base_revision,omitempty"`
Revision uint64 `json:"revision,omitempty"`
Replace bool `json:"replace,omitempty"`
Messages []provider.Message `json:"messages"`
Plan taskstate.Plan `json:"plan,omitempty"`
Goal *taskstate.Goal `json:"goal,omitempty"`
Agents json.RawMessage `json:"agents,omitempty"`
Title string `json:"title,omitempty"`
Mode string `json:"mode,omitempty"`
}
type Event ¶
type Event struct {
Sequence uint64 `json:"sequence,omitempty"`
Revision uint64 `json:"revision,omitempty"`
At time.Time `json:"at"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload,omitempty"`
}
Event is an append-only record used for diagnostics and crash recovery.
type Metadata ¶
type Metadata struct {
ID string
ParentID string
Title string
Workspace string
Model string
SearchText string
UpdatedAt time.Time
ArchivedAt *time.Time
MessageCount int
}
Metadata is the lightweight session-picker/search representation. It never hydrates messages or image assets; Load resolves the selected session.
type RepairReport ¶
type Session ¶
type Session struct {
Version int `json:"version,omitempty"`
ID string `json:"id"`
ParentID string `json:"parent_id,omitempty"`
Title string `json:"title,omitempty"`
Workspace string `json:"workspace"`
Model string `json:"model"`
Mode string `json:"mode,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision uint64 `json:"revision,omitempty"`
LastEventSequence uint64 `json:"last_event_sequence,omitempty"`
Messages []provider.Message `json:"messages"`
Plan taskstate.Plan `json:"plan,omitempty"`
Goal *taskstate.Goal `json:"goal,omitempty"`
Agents json.RawMessage `json:"agents,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Commit ¶
Commit durably records a completed turn without rewriting the full session history every time. A full snapshot is written on the first commit and then periodically; intervening commits append only the new messages and update the lightweight search index. Load replays those deltas after the snapshot.
func (*Store) ListAll ¶
ListAll is the session picker backend when archived threads should be shown.
func (*Store) ListMetadata ¶
func (s *Store) ListMetadata(workspace, query string, limit int, includeArchived bool) (items []Metadata, warnings []string, err error)
ListMetadata performs index-only filtering and sorting. warnings contains corrupt snapshot names skipped by an automatic repair.
func (*Store) Repair ¶
func (s *Store) Repair() (RepairReport, error)
Repair rebuilds index.json from authoritative snapshots plus every newer recovery event. Invalid sessions are reported and left untouched.