Documentation
¶
Index ¶
- Constants
- func EstimateTokens(text string) int
- func GetBoolValue(m map[string]interface{}, key string) bool
- func GetStringValue(m map[string]interface{}, key string) string
- func ProcessAssistantMessage(msg map[string]interface{}, cwd string) (string, []models.ToolCall)
- func ProcessEntries(entries []models.LogEntry) []*models.ProcessedEntry
- func ProcessToolUse(toolUse map[string]interface{}) models.ToolCall
- func ProcessUserMessage(msg map[string]interface{}) string
- type HierarchyBuilder
- type MatchingOptions
- type MessageHandler
- type ProcessingState
- type SidechainContext
- type SidechainProcessor
- type TaskMatchContext
- type TokenProcessor
- type ToolCallContext
- type ToolCallMatcher
- type ToolProcessor
Constants ¶
const ( ToolNameTask = "Task" ToolNameBash = "Bash" ToolNameEdit = "Edit" ToolNameMultiEdit = "MultiEdit" ToolNameWrite = "Write" ToolNameRead = "Read" ToolNameTodoWrite = "TodoWrite" )
Tool names
const ( TypeUser = "user" TypeAssistant = "assistant" TypeMessage = "message" TypeToolUse = "tool_use" TypeToolResult = "tool_result" )
Entry types
const ( RoleUser = "user" RoleAssistant = "assistant" )
Roles
const ( ContentTypeText = "text" ContentTypeToolUse = "tool_use" ContentTypeToolResult = "tool_result" )
Content types
const ( TagCommandName = "command-name" TagCommandArgs = "command-args" TagCommandStdout = "local-command-stdout" )
XML tags for command parsing
const ( BashOutputCollapseThreshold = 20 ShortUUIDLength = 8 MinTextLengthForPrefixMatch = 20 )
UI and formatting constants
const ( DefaultBufferSize = 64 * 1024 // 64KB buffer MaxLineSize = 10 * 1024 * 1024 // 10MB max line size )
Parser constants
const (
HTMLBuilderInitialCapacity = 100
)
Builder constants
const (
ThousandSeparatorThreshold = 1000
)
Number formatting constants
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens provides a simple approximation of token count This uses a rough heuristic: ~4 characters per token for English text For more accurate counting, you would need to use the actual tokenizer
func GetBoolValue ¶
GetBoolValue extracts a bool value from a map
func GetStringValue ¶
GetStringValue extracts a string value from a map
func ProcessAssistantMessage ¶
ProcessAssistantMessage processes assistant messages and returns raw content and tool calls
func ProcessEntries ¶
func ProcessEntries(entries []models.LogEntry) []*models.ProcessedEntry
ProcessEntries processes raw log entries into a structured format
func ProcessToolUse ¶
ProcessToolUse processes a tool use message and returns a ToolCall This function delegates to the global ToolProcessor for consistency
func ProcessUserMessage ¶
ProcessUserMessage processes user messages and returns raw content
Types ¶
type HierarchyBuilder ¶
type HierarchyBuilder struct{}
HierarchyBuilder builds parent-child relationships and calculates depths
func NewHierarchyBuilder ¶
func NewHierarchyBuilder() *HierarchyBuilder
NewHierarchyBuilder creates a new hierarchy builder
func (*HierarchyBuilder) BuildHierarchy ¶
func (h *HierarchyBuilder) BuildHierarchy(entries []*models.ProcessedEntry) error
BuildHierarchy builds the hierarchy and sets depths for all entries
func (*HierarchyBuilder) BuildParentChildMap ¶
func (h *HierarchyBuilder) BuildParentChildMap(entries []*models.ProcessedEntry) map[string][]string
BuildParentChildMap builds a map of parent UUIDs to child UUIDs
type MatchingOptions ¶
MatchingOptions controls how tool calls are matched
type MessageHandler ¶
MessageHandler defines a function for processing specific message types
type ProcessingState ¶
type ProcessingState struct {
Entries []*models.ProcessedEntry
ToolCallMap map[string]*ToolCallContext
ParentChildMap map[string][]string
RootParent string
Index int
}
ProcessingState holds all state during entry processing
type SidechainContext ¶
type SidechainContext struct {
RootToolCallID string
StartIndex int
EndIndex int
Entries []*models.ProcessedEntry
}
SidechainContext tracks active sidechain conversations
type SidechainProcessor ¶
type SidechainProcessor struct{}
SidechainProcessor handles processing of sidechain conversations
func NewSidechainProcessor ¶
func NewSidechainProcessor() *SidechainProcessor
NewSidechainProcessor creates a new sidechain processor
func (*SidechainProcessor) ProcessSidechains ¶
func (s *SidechainProcessor) ProcessSidechains(entries []*models.ProcessedEntry, originalEntries []models.LogEntry, entryMap map[string]*models.ProcessedEntry) error
ProcessSidechains processes sidechain conversations and matches them with Task tool calls
type TaskMatchContext ¶
type TaskMatchContext struct {
ToolCall *models.ToolCall
Entry *models.LogEntry
OriginalEntries []models.LogEntry
SidechainRoots []*models.ProcessedEntry
EntryMap map[string]*models.ProcessedEntry
MatchedSidechains map[string]bool
}
TaskMatchContext holds the context for matching Task tools with sidechains
type TokenProcessor ¶
type TokenProcessor struct{}
TokenProcessor handles token counting logic
func NewTokenProcessor ¶
func NewTokenProcessor() *TokenProcessor
NewTokenProcessor creates a new token processor
func (*TokenProcessor) ProcessTokens ¶
func (tp *TokenProcessor) ProcessTokens(processed *models.ProcessedEntry, msg map[string]interface{})
ProcessTokens extracts and calculates token counts for an entry
type ToolCallContext ¶
type ToolCallContext struct {
Entry *models.ProcessedEntry
ToolCall *models.ToolCall
CallTime time.Time
ParentID string
IsComplete bool
}
ToolCallContext tracks pending tool calls
type ToolCallMatcher ¶
type ToolCallMatcher struct {
// contains filtered or unexported fields
}
ToolCallMatcher handles matching tool calls with their results
func NewToolCallMatcher ¶
func NewToolCallMatcher() *ToolCallMatcher
NewToolCallMatcher creates a new tool call matcher
func (*ToolCallMatcher) FilterRootEntries ¶
func (m *ToolCallMatcher) FilterRootEntries(entries []*models.ProcessedEntry) []*models.ProcessedEntry
FilterRootEntries filters entries to only include root conversation entries
func (*ToolCallMatcher) MatchToolCalls ¶
func (m *ToolCallMatcher) MatchToolCalls(entries []*models.ProcessedEntry) error
MatchToolCalls matches tool calls with their results
type ToolProcessor ¶
type ToolProcessor struct {
// contains filtered or unexported fields
}
ToolProcessor handles all tool-related processing
func GetToolProcessor ¶
func GetToolProcessor() *ToolProcessor
GetToolProcessor returns the global tool processor instance
func (*ToolProcessor) ProcessToolCall ¶
func (tp *ToolProcessor) ProcessToolCall(toolCall *models.ToolCall)
ProcessToolCall processes a tool call, applying formatting and extracting metadata
func (*ToolProcessor) ProcessToolUseWithRegistry ¶
func (tp *ToolProcessor) ProcessToolUseWithRegistry(toolUse map[string]interface{}) models.ToolCall
ProcessToolUseWithRegistry processes a tool use message and returns a ToolCall This replaces the standalone ProcessToolUse function