Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultExternalizeThreshold = 100 * 1024
DefaultExternalizeThreshold is the threshold (100 KB) above which raw content is externalized to transient SQLite FTS5 storage instead of returning it to the LLM prompt.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens calculates an approximate token count based on typical byte/character ratios (~4 chars/token).
func ShouldExternalize ¶
ShouldExternalize checks if a text's byte length meets or exceeds the threshold.
Types ¶
type SearchResult ¶
type SearchResult struct {
Snippet string `json:"snippet"`
Rank float64 `json:"rank"`
ByteStart int `json:"byte_start"`
ByteEnd int `json:"byte_end"`
}
SearchResult represents a snippet match from a transient payload FTS5 search.
type Store ¶
type Store interface {
Save(ctx context.Context, p *TransientPayload) error
Get(ctx context.Context, id string) (*TransientPayload, error)
Search(ctx context.Context, id string, query string, limit int) ([]SearchResult, error)
PurgeSession(ctx context.Context, sessionID string) error
Stats(ctx context.Context, sessionID string) (totalSavedTokens int, totalBytes int, count int, err error)
}
Store defines persistence operations for transient payloads.
type TransientPayload ¶
type TransientPayload struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Project string `json:"project"`
SourceTool string `json:"source_tool"`
ContentType string `json:"content_type"`
ByteCount int `json:"byte_count"`
TokensSaved int `json:"tokens_saved"`
Snippet string `json:"snippet"`
Content string `json:"content,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
TransientPayload represents an externalized payload stored in SQLite.
func NewTransientPayload ¶
func NewTransientPayload(sessionID, project, sourceTool, content string) *TransientPayload
NewTransientPayload constructs a TransientPayload, generating an ID and creating a compact snippet.
Click to show internal directories.
Click to hide internal directories.