Store session history, preferences, and dated records in one database per home. Commit complete turns, checkpoint tool batches, and compact history by prefix. Add memory search and writes, with previews for ambiguous corrections. Review conversations in the background and support SQLite backup and restore.
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package session
|
|
|
|
import "github.com/sipeed/picoclaw/pkg/providers"
|
|
|
|
// SessionStore defines the persistence operations used by the agent loop.
|
|
// The SQLite store handles durable sessions. Subturns can use an in-memory store.
|
|
//
|
|
// Write methods (Add*, Set*, Truncate*) are fire-and-forget: they do not
|
|
// return errors. Implementations should log failures internally. This
|
|
// matches the original SessionManager contract that the agent loop relies on.
|
|
type SessionStore interface {
|
|
// AddMessage appends a simple role/content message to the session.
|
|
AddMessage(sessionKey, role, content string)
|
|
// AddFullMessage appends a complete message including tool calls.
|
|
AddFullMessage(sessionKey string, msg providers.Message)
|
|
// GetHistory returns the full message history for the session.
|
|
GetHistory(key string) []providers.Message
|
|
// GetSummary returns the conversation summary, or "" if none.
|
|
GetSummary(key string) string
|
|
// SetSummary replaces the conversation summary.
|
|
SetSummary(key, summary string)
|
|
// SetHistory replaces the full message history.
|
|
SetHistory(key string, history []providers.Message)
|
|
// TruncateHistory keeps only the last keepLast messages.
|
|
TruncateHistory(key string, keepLast int)
|
|
// Save persists any pending state to durable storage.
|
|
Save(key string) error
|
|
// ListSessions returns all known session keys.
|
|
ListSessions() []string
|
|
// Close releases resources held by the store.
|
|
Close() error
|
|
}
|