Documentation
¶
Index ¶
- type Event
- type Session
- type Store
- func (s *Store) AppendEvent(sessionID string, eventType, payloadJSON string, tokens int) (*Event, error)
- func (s *Store) CleanupReplayDuplicates(sessionID string) (int, error)
- func (s *Store) Close() error
- func (s *Store) CreateSession(sessionID, projectPath string) error
- func (s *Store) DeleteAllSessions() (int, error)
- func (s *Store) DeleteSession(sessionID string) (int, error)
- func (s *Store) GetSessionEvents(sessionID string) ([]Event, error)
- func (s *Store) GetSessionMode(sessionID string) (string, error)
- func (s *Store) ListSessions() ([]Session, error)
- func (s *Store) ListSessionsByProjectPath(projectPath string) ([]Session, error)
- func (s *Store) UpdateSessionMode(sessionID, mode string) error
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 (*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 ¶
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) CreateSession ¶
CreateSession initializes a new session row.
func (*Store) DeleteAllSessions ¶
DeleteAllSessions permanently removes every session and all events from the database. Returns the number of events removed.
func (*Store) DeleteSession ¶
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 ¶
GetSessionEvents fetches all visible events for a session.
func (*Store) GetSessionMode ¶
GetSessionMode returns the last persisted engine mode for a session, or "" when the session row is missing (callers treat "" as BUILDER).
func (*Store) ListSessions ¶
ListSessions retrieves all sessions from the SQLite database.
func (*Store) ListSessionsByProjectPath ¶
ListSessionsByProjectPath retrieves sessions created in specific directory path.
func (*Store) UpdateSessionMode ¶
UpdateSessionMode persists the active engine mode for a session so a later resume (`-c` or /sessions) continues in the same mode.