Versions in this module Expand all Collapse all v0 v0.2.0 Jul 14, 2026 Changes in this version + func CalculateTotalTokens(inputTokens, outputTokens int) int + func Clamp(value, min, max int) int + func ClampFloat64(value, min, max float64) float64 + func CloneInput(input map[string]any) map[string]any + func CloneMap[K comparable, V any](input map[K]V) map[K]V + func CloneSlice[T any](input []T) []T + func CountTokensInText(text string) int + func DirIsInGitRepo(cwd string) bool + func EstimateImageTokens() int + func FindCanonicalGitRoot(startDir string) string + func FindGitRoot(startDir string) string + func GetCachedBranch(root string) string + func GetCachedDefaultBranch(root string) string + func GetCachedHead(root string) string + func GetCachedRemoteUrl(root string) string + func GetGitExe() string + func GetIsGit(dir string) bool + func IsAtGitRoot(cwd string) bool + func IsValidToolName(name string) bool + func ReadGitHead(gitDir string) (string, bool) + func ResolveGitDir(startDir string) string + func SanitizePathComponent(path string) string + func ValidateMessageID(id string) error + func ValidateModelIdentifier(model string) error + func ValidateSessionID(id string) error + func ValidateTurnID(id string) error + type Context struct + Branch string + Head string + IsGit bool + IsWorktree bool + Root string + func Detect(dir string) *Context + type ContextManager struct + func NewContextManager() *ContextManager + func (m *ContextManager) CalculateCompactionTarget(contextWindow types.ContextWindow, systemPrompt string, ...) int + func (m *ContextManager) CalculateMessageTokens(msg types.Message) int + func (m *ContextManager) CalculateMessagesTokens(messages []types.Message) int + func (m *ContextManager) CalculateRemainingTokens(contextWindow types.ContextWindow, systemPrompt string, ...) int + func (m *ContextManager) CalculateSystemPromptTokens(systemPrompt string) int + func (m *ContextManager) EstimateRequestTokens(systemPrompt string, messages []types.Message) int + func (m *ContextManager) ShouldCompact(contextWindow types.ContextWindow, systemPrompt string, ...) bool + type LRUCache struct + func (c *LRUCache) Get(key string) (string, bool) + func (c *LRUCache) Set(key string, root string, found bool) + type PathValidator struct + AllowedDirectories []string + func NewPathValidator(allowedDirs []string) *PathValidator + func (v *PathValidator) ValidatePath(path string) error + type TokenEstimator struct + CharactersPerToken float64 + func NewTokenEstimator() *TokenEstimator + func (e *TokenEstimator) EstimateMessageTokens(role string, content string) int + func (e *TokenEstimator) EstimateTokens(text string) int + func (e *TokenEstimator) EstimateToolResultTokens(result string) int + func (e *TokenEstimator) EstimateToolUseTokens(toolName string, input map[string]any) int