Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	ID          int64      `json:"id"`
	SessionID   string     `json:"session_id"`
	Seq         int        `json:"seq"`
	Type        string     `json:"type"` // 'user_msg' | 'reasoning' | 'tool_call' | 'tool_result' | 'compaction_summary' | 'assistant_msg'
	PayloadJSON string     `json:"payload_json"`
	Tokens      int        `json:"tokens"`
	CreatedAt   time.Time  `json:"created_at"`
	HiddenAt    *time.Time `json:"hidden_at,omitempty"`
}

Event represents an append-only log entry in the events table.

type Session

type Session struct {
	ID          string    `json:"id"`
	CreatedAt   time.Time `json:"created_at"`
	ProjectPath string    `json:"project_path"`
	Status      string    `json:"status"`
	Mode        string    `json:"mode,omitempty"` // last active engine mode ("BUILDER"/"PLANNER"/"MINER")
}

Session represents a single chat/agent session.

type Store

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

Store manages SQLite database persistence for sessions and events.

func NewStore

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

NewStore opens or creates the SQLite database at default path.

func (*Store) AppendEvent

func (s *Store) AppendEvent(sessionID string, eventType, payloadJSON string, tokens int) (*Event, error)

AppendEvent appends a new event into the immutable event log.

func (*Store) CleanupReplayDuplicates

func (s *Store) CleanupReplayDuplicates(sessionID string) (int, error)

CleanupReplayDuplicates removes events that were duplicated by old resume logic (which re-persisted the whole log on every `-c`). It detects the smallest prefix that the full event list repeats exactly, keeps only that prefix, and deletes the repeated tail. Returns the number of events removed.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) CreateSession

func (s *Store) CreateSession(sessionID, projectPath string) error

CreateSession initializes a new session row.

func (*Store) DeleteAllSessions

func (s *Store) DeleteAllSessions() (int, error)

DeleteAllSessions permanently removes every session and all events from the database. Returns the number of events removed.

func (*Store) DeleteSession

func (s *Store) DeleteSession(sessionID string) (int, error)

DeleteSession permanently removes a session and all of its events from the database (the events table has no ON DELETE CASCADE, so events are deleted first). Returns the number of events removed.

func (*Store) GetSessionEvents

func (s *Store) GetSessionEvents(sessionID string) ([]Event, error)

GetSessionEvents fetches all visible events for a session.

func (*Store) GetSessionMode

func (s *Store) GetSessionMode(sessionID string) (string, error)

GetSessionMode returns the last persisted engine mode for a session, or "" when the session row is missing (callers treat "" as BUILDER).

func (*Store) ListSessions

func (s *Store) ListSessions() ([]Session, error)

ListSessions retrieves all sessions from the SQLite database.

func (*Store) ListSessionsByProjectPath

func (s *Store) ListSessionsByProjectPath(projectPath string) ([]Session, error)

ListSessionsByProjectPath retrieves sessions created in specific directory path.

func (*Store) UpdateSessionMode

func (s *Store) UpdateSessionMode(sessionID, mode string) error

UpdateSessionMode persists the active engine mode for a session so a later resume (`-c` or /sessions) continues in the same mode.

Jump to

Keyboard shortcuts

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