history

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFTS

func CheckFTS() bool

CheckFTS verifies if the FTS5 extension is loaded and working

func ParseQuery

func ParseQuery(input string) string

ParseQuery converts user input into FTS5 syntax Supports: "phrase search", user:term, ai:term

Types

type ChatMessage

type ChatMessage struct {
	UUID    string   `json:"uuid"`
	Role    string   `json:"role"`
	Content string   `json:"content"`
	Images  []string `json:"images,omitempty"`
}

ChatMessage matches the internal Message struct

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles dual-write history (JSONL + SQLite)

func New

func New(dbPath, jsonlPath string) (*Manager, error)

New creates a new history manager

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) EnsureMigrated

func (m *Manager) EnsureMigrated()

EnsureMigrated checks if DB is empty and if so, imports from JSONL

func (*Manager) GetSessionMessages

func (m *Manager) GetSessionMessages(uuid string) ([]ChatMessage, error)

func (*Manager) ListRecentSessions

func (m *Manager) ListRecentSessions(limit int) ([]SessionSummary, error)

func (*Manager) ResolveSessionUUID

func (m *Manager) ResolveSessionUUID(partial string) (string, error)

ResolveSessionUUID finds the full UUID given a prefix or full string

func (*Manager) SaveMessage

func (m *Manager) SaveMessage(data MessageEvent) error

func (*Manager) SaveSessionStart

func (m *Manager) SaveSessionStart(data SessionStartEvent) error

func (*Manager) SaveShellEvent

func (m *Manager) SaveShellEvent(data ShellEvent) error

func (*Manager) Search

func (m *Manager) Search(query string) ([]SearchResult, error)

func (*Manager) UpdateSessionModel added in v0.6.0

func (m *Manager) UpdateSessionModel(uuid, model string) error

UpdateSessionModel updates the model name for an existing session in the database

type MessageEvent

type MessageEvent struct {
	ID      string      `json:"uuid"`
	SID     string      `json:"sid"`
	TS      int64       `json:"ts"`
	Message ChatMessage `json:"msg"`
}

MessageEvent represents the JSON structure logged for each message

type SearchResult

type SearchResult struct {
	SessionUUID string
	Timestamp   time.Time
	Role        string
	Content     string
	Preview     string
}

SearchResult represents a hit from the FTS index

type SessionStartEvent

type SessionStartEvent struct {
	SID                string      `json:"sid"`
	TS                 int64       `json:"ts"`
	UserMsg            string      `json:"user_msg"`
	SystemPrompt       string      `json:"system_prompt"`
	Model              string      `json:"model"`
	Seed               int         `json:"seed"`
	Temperature        *float64    `json:"temperature,omitempty"`
	APIBase            string      `json:"api_base"`
	MaxTokens          int         `json:"max_tokens"`
	JSONMode           bool        `json:"json_mode"`
	StopSequences      interface{} `json:"stop_sequences"`
	ExtraParams        string      `json:"extra_params"`
	JsonSchema         string      `json:"json_schema"`
	ReasoningEffort    string      `json:"reasoning_effort,omitempty"`
	ReasoningMaxTokens int         `json:"reasoning_max_tokens,omitempty"`
	ReasoningExclude   bool        `json:"reasoning_exclude,omitempty"`
}

SessionStartEvent represents the JSON structure logged when a chat starts

type SessionSummary

type SessionSummary struct {
	UUID      string
	Timestamp time.Time
	Summary   string
	Model     string
}

SessionSummary represents a resume-able session

type ShellEvent

type ShellEvent struct {
	Type    string `json:"type"`
	Query   string `json:"query"`
	History string `json:"history_snippet"`
}

ShellEvent represents session interception events

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL