Documentation
¶
Overview ¶
Package history keeps the AI conversations of each host, to look back on and carry on. A conversation holds what its pane showed and, for the built-in agent, the messages it sends the model; both may hold terminal output and command results, so every file is sealed by the keychain's master key. Each host has a folder: an index of its conversations, the newest first, and a file for each.
Index ¶
Constants ¶
const ( MaxPerHost = 100 MaxSize = 4 << 20 )
MaxPerHost is how many conversations a host keeps: saving one more drops the oldest. MaxSize is the most a conversation's file holds; a longer one keeps its latest items.
Variables ¶
var ErrNotFound = errors.New("history: conversation not found")
ErrNotFound is a conversation that is not kept.
Functions ¶
Types ¶
type Conversation ¶
type Conversation struct {
ID string `json:"id"`
Host string `json:"host"`
Title string `json:"title"`
Agent string `json:"agent,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Effort string `json:"effort,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Items []Item `json:"items"`
// Messages are the built-in agent's, without its system prompt; nil
// for an external agent, which keeps its own.
Messages []llm.Message `json:"messages,omitempty"`
}
Conversation is one conversation of a host.
type Item ¶
type Item struct {
Kind string `json:"kind"`
Text string `json:"text,omitempty"`
Files []File `json:"files,omitempty"`
Tool *agent.ToolCard `json:"tool,omitempty"`
}
Item is one entry of the timeline: a question (user), an answer (text), thinking (think), a tool call (tool) or an error (err).
type Sealer ¶
type Sealer interface {
Seal(purpose string, plain, aad []byte) ([]byte, error)
Unseal(purpose string, sealed, aad []byte) ([]byte, error)
}
Sealer seals the store's files; *keychain.Keychain is one.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the conversations under a folder.
func (*Store) DeleteHost ¶
DeleteHost forgets every conversation of host.
func (*Store) Load ¶
func (st *Store) Load(host, id string) (Conversation, error)
Load is host's conversation id.
func (*Store) Save ¶
func (st *Store) Save(c Conversation) error
Save keeps c, first in its host's index, and drops the conversations past MaxPerHost.
type Summary ¶
type Summary struct {
ID string `json:"id"`
Title string `json:"title"`
Agent string `json:"agent,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
Summary is a conversation as the index lists it.