session

package
v0.104.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("session store is closed")
View Source
var ErrNotFound = errors.New("session not found")

Functions

func FindTranscript added in v0.103.0

func FindTranscript(root, id string) (string, error)

Types

type Compaction

type Compaction struct {
	Seq       int      `json:"seq"`
	Cutoff    int      `json:"cutoff"`
	Summary   string   `json:"summary"`
	Model     string   `json:"model"`
	Usage     ai.Usage `json:"usage"`
	DropPrior bool     `json:"drop_prior,omitempty"`
	Fresh     bool     `json:"fresh,omitempty"`
}

type History added in v0.103.0

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

func (*History) Boundary added in v0.103.0

func (h *History) Boundary(cut int) (int, error)

func (*History) Compact added in v0.103.0

func (h *History) Compact(summary string, cutoff int, model string, usage ai.Usage) error

func (*History) NewContext added in v0.104.0

func (h *History) NewContext(cutoff int) error

func (*History) Observe added in v0.103.0

func (h *History) Observe(msgs []ai.Message) error

func (*History) Sequence added in v0.103.0

func (h *History) Sequence(index int) (int, bool)

type Meta

type Meta struct {
	ID              string   `json:"id"`
	Title           string   `json:"title"`
	Model           string   `json:"model"`
	Provider        string   `json:"provider"`
	CWD             string   `json:"cwd"`
	Goal            string   `json:"goal"`
	ForkedFrom      string   `json:"forked_from"`
	ForkSeq         int      `json:"fork_seq"`
	Tags            []string `json:"tags"`
	Pinned          bool     `json:"pinned"`
	Archived        bool     `json:"archived"`
	Effort          string   `json:"effort"`
	UsageIn         int      `json:"usage_in"`
	UsageCached     int      `json:"usage_cached"`
	UsageOut        int      `json:"usage_out"`
	UsageCacheWrite int      `json:"usage_cache_write,omitempty"`

	SubUsage   map[string]ai.Usage `json:"sub_usage"`
	ModelUsage map[string]ai.Usage `json:"model_usage,omitempty"`
	UpdatedAt  time.Time           `json:"updated_at"`

	TaskID string `json:"task_id"`
}

func (Meta) UsageSummary added in v0.103.0

func (m Meta) UsageSummary(msgs []ai.Message) ai.UsageSummary

type Page added in v0.103.0

type Page struct {
	Sessions []Meta
	Next     *PageCursor
}

type PageCursor added in v0.103.0

type PageCursor struct {
	UpdatedAt time.Time `json:"updatedAt"`
	ID        string    `json:"id"`
}

func (PageCursor) Valid added in v0.103.0

func (c PageCursor) Valid() bool

type PageOptions added in v0.103.0

type PageOptions struct {
	CWD   *string
	After *PageCursor
	Limit int
}

type Schedule

type Schedule struct {
	ID       int       `json:"id"`
	Schedule string    `json:"schedule"`
	Prompt   string    `json:"prompt"`
	Anchor   time.Time `json:"anchor"`
	LastFire time.Time `json:"last_fire"`
}

type Store

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

func Open

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

func OpenHome added in v0.103.0

func OpenHome(home string) (*Store, error)

func OpenProjectHome added in v0.103.0

func OpenProjectHome(home string) (*Store, error)

func (*Store) AddSchedule

func (s *Store) AddSchedule(sessionID, schedule, prompt string, anchor time.Time) (id int, err error)

func (*Store) ClearMessages

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

func (*Store) ClearSnapshots

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

func (*Store) Close

func (s *Store) Close() error

func (*Store) Compactions

func (s *Store) Compactions(id string) []Compaction

func (*Store) Create

func (s *Store) Create(cwd, model, provider string) (id string, err error)

func (*Store) Delete added in v0.103.0

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

func (*Store) DeleteCompaction

func (s *Store) DeleteCompaction(id string, seq int) error

func (*Store) DeleteFrom

func (s *Store) DeleteFrom(id string, from int) error

func (*Store) DeleteSchedule

func (s *Store) DeleteSchedule(sessionID string, id int) error

func (*Store) Fork

func (s *Store) Fork(srcID string, uptoSeq int, title string) (id string, err error)

func (*Store) ForkTitle

func (s *Store) ForkTitle(base string) (title string, err error)

func (*Store) ForksOf

func (s *Store) ForksOf(id string) (out []Meta, err error)

func (*Store) History added in v0.103.0

func (s *Store) History(id string, initial []ai.Message) (*History, []ai.Message, error)

func (*Store) LastExchange

func (s *Store) LastExchange(id string) (user, assistant string)

func (*Store) LatestInDir

func (s *Store) LatestInDir(dir string) (meta Meta, err error)

func (*Store) ListPage added in v0.103.0

func (s *Store) ListPage(ctx context.Context, options PageOptions) (Page, error)

func (*Store) Load

func (s *Store) Load(idOrPrefix string) (meta Meta, msgs []ai.Message, err error)

func (*Store) LoadTasks

func (s *Store) LoadTasks(id string) ([]Task, error)

func (*Store) MarkFired

func (s *Store) MarkFired(sessionID string, id int, at time.Time) error

func (*Store) RawMessages

func (s *Store) RawMessages(id string) []ai.Message

func (*Store) Recent

func (s *Store) Recent(n int) (out []Meta, err error)

func (*Store) RecordCompaction

func (s *Store) RecordCompaction(id string, cutoff int, summary, model string, usage ai.Usage) error

func (*Store) Save

func (s *Store) Save(id string, from int, msgs []ai.Message, model, provider string) error

func (*Store) SaveHistory added in v0.103.0

func (s *Store) SaveHistory(id string, h *History, msgs []ai.Message, model, provider string) error

func (*Store) SaveHistoryWithUsage added in v0.103.0

func (s *Store) SaveHistoryWithUsage(id string, h *History, msgs []ai.Message, model, provider string, usage ai.UsageSummary) error

func (*Store) SaveSubagentTranscript

func (s *Store) SaveSubagentTranscript(parentID, taskID string, msgs []ai.Message, model, provider string) (string, error)

func (*Store) SaveTask

func (s *Store) SaveTask(id string, t Task) error

func (*Store) Schedules

func (s *Store) Schedules(id string) []Schedule

func (*Store) Search added in v0.103.0

func (s *Store) Search(query string, includeArchived bool) (out []Meta, err error)

func (*Store) SessionsDir added in v0.103.0

func (s *Store) SessionsDir() string

func (*Store) SetArchived added in v0.103.0

func (s *Store) SetArchived(id string, archived bool) error

func (*Store) SetEffort

func (s *Store) SetEffort(id, effort string) error

func (*Store) SetGoal

func (s *Store) SetGoal(id, goal string) error

func (*Store) SetPinned

func (s *Store) SetPinned(id string, pinned bool) error

func (*Store) SetSnapshot

func (s *Store) SetSnapshot(id string, seq int, ref string) error

func (*Store) SetTags

func (s *Store) SetTags(id string, tags []string) error

func (*Store) SetTitle

func (s *Store) SetTitle(id, title string) error

func (*Store) SetTodos

func (s *Store) SetTodos(id, todos string) error

func (*Store) SetUsage

func (s *Store) SetUsage(id string, usage ai.UsageSummary) error

func (*Store) SnapshotReferenced added in v0.103.0

func (s *Store) SnapshotReferenced(ref string) (bool, error)

func (*Store) Snapshots

func (s *Store) Snapshots(id string) map[int]string

func (*Store) SubagentTranscript

func (s *Store) SubagentTranscript(parentID, taskID string) ([]ai.Message, error)

func (*Store) Todos

func (s *Store) Todos(id string) string

func (*Store) TranscriptPath added in v0.103.0

func (s *Store) TranscriptPath(id string) string

func (*Store) TruncateHistory added in v0.103.0

func (s *Store) TruncateHistory(id string, h *History, cut int) error

func (*Store) UndoCompaction added in v0.103.0

func (s *Store) UndoCompaction(id string, initial []ai.Message) (*History, []ai.Message, error)

func (*Store) UserHistory

func (s *Store) UserHistory(limit int) (out []string, err error)

type Task

type Task struct {
	ID          string    `json:"id"`
	Description string    `json:"description"`
	Prompt      string    `json:"prompt"`
	Status      string    `json:"status"`
	Report      string    `json:"report"`
	StartedAt   time.Time `json:"started_at"`
	EndedAt     time.Time `json:"ended_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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