Documentation
¶
Overview ¶
Package session persists every hmm run as a JSONL file in weft's message wire format: line 1 is a session header, then one weft Message per line, then a final usage line. Resume feeds the stored messages back through weft.Messages; dangling tool calls from a crashed run are repaired by weft.Repair.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoSessions = errors.New("hmm: no saved sessions")
ErrNoSessions is returned by Newest when the store is empty.
Functions ¶
Types ¶
type Header ¶
type Header struct {
Type string `json:"type"` // "session"
ID string `json:"id"`
Provider string `json:"provider"`
Model string `json:"model"`
Created time.Time `json:"created"`
Cwd string `json:"cwd"`
}
Header is line 1 of a session file.
type Store ¶
type Store struct {
Dir string
}
Store writes and reads session files under Dir. The zero value is not usable; use New.
func New ¶
New returns the store rooted at $HMM_HOME/sessions (legacy $BOBINA_HOME), defaulting to ~/.local/share/hmm/sessions — falling back to the pre-rename ~/.local/share/bobina tree when only that exists, so old sessions stay readable.
func (Store) Create ¶
Create opens <id>.jsonl and writes the header line. Creation is exclusive: a colliding id is an error, never a truncate of the session already living under that name.
func (Store) Newest ¶
Newest returns the id of the most recently modified session file, preferring one whose recorded cwd matches cwd — with several terminals sharing the store, `hmm -c` continues the last chat from this directory, not the last chat anywhere. No match falls back to the global newest.
func (Store) Read ¶
Read loads a session by id, by <id>.jsonl, by path, or by a unique id prefix. An incomplete trailing line (a crashed run mid-write: the file does not end in a newline) is dropped — weft.Repair fills the gap when the transcript is fed back. Corrupt JSON mid-file is an error. The usage line is not returned.
type Usage ¶
type Usage struct {
Type string `json:"type"` // "usage"
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
Steps int `json:"steps"`
StopReason string `json:"stop_reason,omitempty"`
Error string `json:"error,omitempty"`
}
Usage is the final line of a session file. Error is set when the run failed; the messages above it are the partial transcript.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer appends to one session file. Every line is flushed as it is written, so a crash leaves at most an incomplete trailing line — which Read drops.