session

package
v0.0.0-...-f56615f Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package session stores resumable SuperCode conversations as local JSON.

Index

Constants

View Source
const CurrentVersion = 4

Variables

View Source
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 RepairReport struct {
	Scanned int      `json:"scanned"`
	Indexed int      `json:"indexed"`
	Invalid []string `json:"invalid,omitempty"`
}

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 NewStore

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

func (*Store) Append

func (s *Store) Append(id, eventType string, payload any) error

Append writes and fsyncs one event without rewriting the session snapshot.

func (*Store) Archive

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

func (*Store) Commit

func (s *Store) Commit(value Session) error

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) Delete

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

func (*Store) Events

func (s *Store) Events(id string) ([]Event, error)

func (*Store) Fork

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

func (*Store) Latest

func (s *Store) Latest(workspace string) (Session, error)

func (*Store) List

func (s *Store) List(workspace string, limit int) ([]Session, error)

func (*Store) ListAll

func (s *Store) ListAll(workspace string, limit int, includeArchived bool) ([]Session, error)

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) Load

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

func (*Store) New

func (s *Store) New(workspace, model string) (Session, error)

func (*Store) Rename

func (s *Store) Rename(id, title string) (Session, error)

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.

func (*Store) Save

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

func (*Store) Search

func (s *Store) Search(workspace, query string, limit int, includeArchived bool) ([]Session, error)

Search uses the file-backed index and includes message text in addition to title, ID, model, and workspace metadata.

Jump to

Keyboard shortcuts

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