Documentation
¶
Index ¶
- Constants
- func AppendMessage(path string, msg Message) error
- func BuildCompactionSummary(messages []Message) string
- func BuildCompactionSummaryWithOptions(messages []Message, opts CompactionSummaryOptions) string
- func EstimateTokens(messages []Message) int
- func RewriteMessages(path string, messages []Message) error
- type CompactOptions
- type CompactResult
- type CompactionSummaryOptions
- type HistorySnapshot
- type Message
- type Session
- type Store
- func (s *Store) Create(title string) (Session, error)
- func (s *Store) CreateWithOptions(title string, kind string, hidden bool) (Session, error)
- func (s *Store) Delete(id string) error
- func (s *Store) EnsureMain() (Session, error)
- func (s *Store) EnsureWorker(projectID string) (Session, error)
- func (s *Store) Get(id string) (Session, error)
- func (s *Store) Latest() (Session, error)
- func (s *Store) LatestAll() (Session, error)
- func (s *Store) List() ([]Session, error)
- func (s *Store) ListAll() ([]Session, error)
- func (s *Store) SetProjectID(id string, projectID string) error
- func (s *Store) SetTitle(id string, title string) error
- func (s *Store) Touch(id string, updatedAt time.Time) error
- func (s *Store) TranscriptPath(id string) string
- func (s *Store) WorkspaceDir() string
Constants ¶
const ( DefaultKeepRecentMessages = 20 MinKeepRecentMessages = 5 MaxKeepRecentMessages = 200 DefaultKeepRecentTokens = 12000 MinKeepRecentTokens = 1 MaxKeepRecentTokens = 64000 DefaultKeepRecentFraction = 0.30 MinKeepRecentFraction = 0.05 MaxKeepRecentFraction = 0.90 )
Variables ¶
This section is empty.
Functions ¶
func AppendMessage ¶
AppendMessage appends a single message as one JSON line to the JSONL file at path.
func BuildCompactionSummary ¶
func BuildCompactionSummaryWithOptions ¶ added in v0.10.2
func BuildCompactionSummaryWithOptions(messages []Message, opts CompactionSummaryOptions) string
func EstimateTokens ¶
func RewriteMessages ¶
RewriteMessages replaces the transcript contents with the provided messages.
Types ¶
type CompactOptions ¶
type CompactResult ¶
type CompactResult struct {
Compacted bool
OriginalCount int
FinalCount int
CompactedCount int
Summary string
}
func CompactTranscript ¶
func CompactTranscriptWithOptions ¶
func CompactTranscriptWithOptions(path string, keepRecent int, now time.Time, opts CompactOptions) (CompactResult, error)
type CompactionSummaryOptions ¶ added in v0.10.2
type CompactionSummaryOptions struct {
FocusInstructions string
}
type HistorySnapshot ¶
HistorySnapshot captures the portion of transcript loaded into model context.
func LoadHistorySnapshot ¶
func LoadHistorySnapshot(path string, maxTokens int) (HistorySnapshot, error)
LoadHistorySnapshot reads transcript history and returns the loaded messages together with token and compaction-boundary metadata.
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Timestamp time.Time `json:"timestamp"`
ToolName string `json:"tool_name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolArgs string `json:"tool_args,omitempty"`
}
Message represents a single chat message in a session transcript. Tool fields are optional (omitempty) for backward compatibility with existing transcripts.
func LoadHistory ¶
LoadHistory reads messages from a JSONL file, returning only the most recent messages that fit within the given token budget. Tokens are estimated as len(content)/4. Messages are returned in chronological order (oldest first). Returns an empty slice if the file does not exist.
func ReadMessages ¶
ReadMessages reads all messages from a JSONL file. Returns an empty slice if the file does not exist or is empty.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}