Documentation
¶
Index ¶
- func CountToolsAfterPosition(tools []ToolUse, position int) int
- func CountToolsByNames(tools []ToolUse, names []string) int
- func ExtractRecentText(messages []Message, count int) string
- func ExtractTextFromMessages(messages []Message) []string
- func ExtractToolInput(messages []Message, toolName string) map[string]interface{}
- func FindToolPosition(tools []ToolUse, name string) int
- func GetLastAssistantTimestamp(messages []Message) string
- func GetLastTool(tools []ToolUse) string
- func GetLastUserTimestamp(messages []Message) string
- func HasAnyActiveTool(tools []ToolUse, activeTools []string) bool
- func HasRecentApiError(messages []Message) bool
- type Content
- type Message
- func FilterMessagesAfterTimestamp(messages []Message, afterTimestamp string) []Message
- func GetLastApiErrorMessages(messages []Message, count int) []Message
- func GetLastAssistantMessages(messages []Message, count int) []Message
- func Parse(r io.Reader) ([]Message, error)
- func ParseFile(path string) ([]Message, error)
- type MessageContent
- type ToolUse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountToolsAfterPosition ¶
CountToolsAfterPosition counts how many tools were used after a given position
func CountToolsByNames ¶
CountToolsByNames counts tools matching any of the given names
func ExtractRecentText ¶
ExtractRecentText extracts concatenated text from last N assistant messages
func ExtractTextFromMessages ¶
ExtractTextFromMessages extracts all text content from messages
func ExtractToolInput ¶
ExtractToolInput extracts the input parameters from a specific tool use Returns empty map if tool not found
func FindToolPosition ¶
FindToolPosition finds the position of a tool by name (last occurrence) Returns -1 if not found
func GetLastAssistantTimestamp ¶
GetLastAssistantTimestamp returns the timestamp of the last assistant message
func GetLastTool ¶
GetLastTool returns the last tool used, or empty string if none
func GetLastUserTimestamp ¶
GetLastUserTimestamp returns the timestamp of the last user message with text content Includes both string content (normal user messages) and array content with type="text" (interrupted tool use) Excludes tool_result messages
func HasAnyActiveTool ¶
HasAnyActiveTool checks if any active tool was used
func HasRecentApiError ¶
HasRecentApiError checks if there are API error messages after the last user message
Types ¶
type Content ¶
type Content struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Text string `json:"text,omitempty"`
Input map[string]interface{} `json:"input,omitempty"`
}
Content represents a content block in a message
func FindLastToolUse ¶
FindLastToolUse finds the last occurrence of a specific tool use in messages Returns nil if not found
type Message ¶
type Message struct {
ParentUUID string `json:"parentUuid"`
Type string `json:"type"`
Message MessageContent `json:"message"`
Timestamp string `json:"timestamp"`
IsApiErrorMessage bool `json:"isApiErrorMessage,omitempty"`
Error string `json:"error,omitempty"`
}
Message represents a Claude Code transcript message
func FilterMessagesAfterTimestamp ¶
FilterMessagesAfterTimestamp filters messages that occurred after given timestamp Returns only assistant messages after the timestamp This is used to filter messages to only those in the current response (after last user message)
func GetLastApiErrorMessages ¶
GetLastApiErrorMessages returns the last N messages with isApiErrorMessage=true
func GetLastAssistantMessages ¶
GetLastAssistantMessages returns the last N assistant messages
type MessageContent ¶
type MessageContent struct {
Role string `json:"role"`
Content []Content `json:"-"` // Array content (tool_result, assistant messages)
ContentString string `json:"-"` // String content (user text messages)
}
MessageContent represents the content of a message Content can be either a string (user text messages) or an array (tool results, assistant messages)
func (MessageContent) MarshalJSON ¶
func (m MessageContent) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for MessageContent Outputs content as string if ContentString is set, otherwise as array
func (*MessageContent) UnmarshalJSON ¶
func (m *MessageContent) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for MessageContent Handles both string content (user text messages) and array content (tool results, assistant messages)