Documentation
¶
Index ¶
- func DefaultDir() (string, error)
- func ExportSessionMarkdown(ses *Session) string
- type JSONLStore
- func (s *JSONLStore) AppendMessage(ses *Session, msg provider.Message) error
- func (s *JSONLStore) CleanupOlderThan(before time.Time) (int, error)
- func (s *JSONLStore) Delete(id string) error
- func (s *JSONLStore) Dir() string
- func (s *JSONLStore) EnsureMeta(ses *Session) error
- func (s *JSONLStore) ExportMarkdown(id string) (string, error)
- func (s *JSONLStore) List() ([]*Session, error)
- func (s *JSONLStore) Load(id string) (*Session, error)
- func (s *JSONLStore) Save(ses *Session) error
- type Session
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDir ¶
DefaultDir returns the default session directory.
func ExportSessionMarkdown ¶
ExportSessionMarkdown renders a Session to markdown.
Types ¶
type JSONLStore ¶
type JSONLStore struct {
// contains filtered or unexported fields
}
JSONLStore implements Store using JSONL files.
func NewDefaultStore ¶
func NewDefaultStore() (*JSONLStore, error)
NewDefaultStore creates a store in the default directory.
func NewJSONLStore ¶
func NewJSONLStore(dir string) (*JSONLStore, error)
NewJSONLStore creates a store rooted at dir (creates dir if needed).
func (*JSONLStore) AppendMessage ¶
func (s *JSONLStore) AppendMessage(ses *Session, msg provider.Message) error
AppendMessage atomically appends a single message to the session's JSONL file. This is more efficient than Save() for incremental updates.
func (*JSONLStore) CleanupOlderThan ¶
func (s *JSONLStore) CleanupOlderThan(before time.Time) (int, error)
CleanupOlderThan removes sessions older than the given time. Returns count removed.
func (*JSONLStore) Delete ¶
func (s *JSONLStore) Delete(id string) error
Delete removes a session file and its index entry.
func (*JSONLStore) EnsureMeta ¶
func (s *JSONLStore) EnsureMeta(ses *Session) error
EnsureMeta writes the meta record if the session file doesn't exist yet.
func (*JSONLStore) ExportMarkdown ¶
func (s *JSONLStore) ExportMarkdown(id string) (string, error)
ExportMarkdown renders a session as a markdown document.
func (*JSONLStore) List ¶
func (s *JSONLStore) List() ([]*Session, error)
List returns all sessions sorted by UpdatedAt descending (uses index for speed).
func (*JSONLStore) Load ¶
func (s *JSONLStore) Load(id string) (*Session, error)
Load reads a session from its JSONL file.
func (*JSONLStore) Save ¶
func (s *JSONLStore) Save(ses *Session) error
Save writes the full session as a JSONL file (atomic).
type Session ¶
type Session struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Title string `json:"title"`
Vendor string `json:"vendor"`
Endpoint string `json:"endpoint"`
Model string `json:"model"`
Messages []provider.Message `json:"messages,omitempty"`
// Cost data stored as opaque JSON to avoid circular dependency with cost package.
CostJSON []byte `json:"cost,omitempty"`
}
Session represents a single conversation session.
func NewSession ¶
NewSession creates a new Session with a generated ID.
type Store ¶
type Store interface {
// Save persists the current state of a session (atomic write).
Save(s *Session) error
// Load retrieves a session by ID.
Load(id string) (*Session, error)
// List returns all sessions, sorted by UpdatedAt descending.
List() ([]*Session, error)
// Delete removes a session by ID.
Delete(id string) error
// ExportMarkdown renders a session as a markdown document.
ExportMarkdown(id string) (string, error)
// CleanupOlderThan removes sessions whose UpdatedAt is before the given time.
CleanupOlderThan(before time.Time) (int, error)
}
Store is the interface for session persistence.