Documentation
¶
Overview ¶
Package sqlite opens Hermes Agent's database, state.db, and reads its rows as the hermes package's types: sessions, messages, system_prompts, session_model_usage and async_delegations. It is one of the packages of this module that import a database driver, modernc.org/sqlite, a SQLite written in Go, so the hermes package and hermes/convert stay without one: hermes/convert takes OpenStore in its Options.
The database is never opened in place: Open reads a private copy of it and its write-ahead log, which internal/sqlite makes and checks against Hermes writing to it while it copies, as opencode/sqlite does OpenCode's. Hermes keeps state.db in WAL mode and writes to it from every process of a profile, the gateway's included.
Index ¶
- Variables
- func Fixture(path, script string) (io.Closer, error)
- func OpenStore(path string) (hermes.Database, error)
- func Probe(path string) bool
- func RemoveCopies()
- type DB
- func (d *DB) Close() error
- func (d *DB) Delegations() ([]*hermes.Delegation, error)
- func (d *DB) Messages(sessionID string) ([]*hermes.Message, error)
- func (d *DB) ModelUsage(sessionID string) ([]hermes.Columns, error)
- func (d *DB) Name() string
- func (d *DB) Orphans(map[string]bool) ([]*hermes.Stray, error)
- func (d *DB) Sessions() ([]*hermes.Session, []*hermes.Stray, error)
- func (d *DB) SystemPrompt(hash string) (string, bool)
- func (d *DB) Units() (int, error)
- func (d *DB) Version() (int, bool)
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("the database kept changing while it was copied; Hermes may be running, try again when it is idle")
ErrBusy is returned by Open when the database kept changing while it was copied: Hermes is writing to it.
var ErrNotHermes = errors.New("the database holds no sessions and messages tables of Hermes' (sessions with source and started_at, messages with session_id, role and timestamp)")
ErrNotHermes is returned by Open for a database without Hermes' sessions and messages tables.
Functions ¶
func Fixture ¶
Fixture builds a database at path from SQL text, for tests: the fixtures of this module are SQL text, never database files.
func Probe ¶
Probe reports whether the file at path is a Hermes database, reading its schema without copying it: the file is opened immutable, which takes no lock and writes nothing beside it, and reads what has been checkpointed into it. A database whose schema is still only in its write-ahead log, as one a running Hermes created may be, is read from a copy instead.
func RemoveCopies ¶
func RemoveCopies()
RemoveCopies removes the copy of every database open, for a program interrupted while it reads one.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a copy of a Hermes database, open for reading. It implements hermes.Store. A DB is not safe for concurrent use.
func (*DB) Delegations ¶
func (d *DB) Delegations() ([]*hermes.Delegation, error)
Delegations reads async_delegations.
func (*DB) ModelUsage ¶
ModelUsage reads a session's rows of session_model_usage.
func (*DB) Orphans ¶
Orphans lists the rows of messages whose session has no row in sessions, or a row that cannot be read. known is not read: every row of a session is read with it.
func (*DB) SystemPrompt ¶
SystemPrompt reads a prompt of system_prompts.