Documentation
¶
Overview ¶
Package processor transforms log entries into hierarchical structures.
Index ¶
- func EstimateTokens(text string) int
- 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 MessageHandler
- type ProcessingState
- type SidechainContext
- type SidechainProcessor
- type TaskMatchContext
- type TokenProcessor
- type ToolCallContext
- type ToolCallMatcher
- type ToolProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens approximates token count using word-based heuristics.
func ProcessAssistantMessage ¶
ProcessAssistantMessage extracts content and tool calls from assistant messages.
func ProcessEntries ¶
func ProcessEntries(entries []models.LogEntry) []*models.ProcessedEntry
ProcessEntries builds a hierarchical structure from flat log entries.
func ProcessToolUse ¶
ProcessToolUse processes a tool invocation and formats its display.
func ProcessUserMessage ¶
ProcessUserMessage extracts content from user messages.
Types ¶
type HierarchyBuilder ¶
type HierarchyBuilder struct{}
HierarchyBuilder builds conversation hierarchy 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
type MessageHandler ¶
MessageHandler processes specific message types.
type ProcessingState ¶
type ProcessingState struct {
Entries []*models.ProcessedEntry
ToolCallMap map[string]*ToolCallContext
ParentChildMap map[string][]string
Index int
}
ProcessingState holds all state during entry processing.
type SidechainContext ¶
type SidechainContext struct {
RootToolCallID string
Entries []*models.ProcessedEntry
}
SidechainContext tracks Task tool sidechain conversations.
type SidechainProcessor ¶
type SidechainProcessor struct{}
SidechainProcessor handles Task tool sidechain conversation processing.
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 context for Task tool sidechain matching.
type TokenProcessor ¶
type TokenProcessor struct{}
TokenProcessor calculates and tracks token usage.
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
}
ToolCallContext tracks pending tool calls awaiting results.
type ToolCallMatcher ¶
type ToolCallMatcher struct {
}
ToolCallMatcher matches 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 uses a 5-minute window to prevent false matches in long conversations.
type ToolProcessor ¶
type ToolProcessor struct {
// contains filtered or unexported fields
}
ToolProcessor formats and processes tool calls.
func GetToolProcessor ¶
func GetToolProcessor() *ToolProcessor
GetToolProcessor returns the singleton tool processor.
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