Documentation
¶
Index ¶
- Constants
- func ExtractAgentIDsFromMessage(message map[string]interface{}) []string
- func FindSessionByID(partialID string) (fullID string, transcriptPath string, err error)
- func IsValidAgentID(s string) bool
- func ReadHookInputFrom(r io.Reader) (*types.HookInput, error)
- func SanitizeText(input string) string
- type ExtractionResult
- type SessionInfo
- type SummaryLink
Constants ¶
const ( // MinAgentIDLength is the minimum length of an agent ID string MinAgentIDLength = 6 // UUIDLength is the expected length of UUID strings (with hyphens) UUIDLength = 36 )
const MaxLinesForExtraction = 50
MaxLinesForExtraction limits how many lines we read when extracting metadata. Summaries and first user messages typically appear in the first few lines.
const MaxMetadataFieldSize = 8 * 1024 // 8KB
MaxMetadataFieldSize is the backend-imposed limit for metadata fields like first_user_message. The server rejects metadata fields larger than this value. Messages are truncated to half this (4KB) to leave headroom in chunk uploads. If the backend limit changes, this constant must be updated accordingly.
Variables ¶
This section is empty.
Functions ¶
func ExtractAgentIDsFromMessage ¶
ExtractAgentIDsFromMessage extracts agent IDs from a parsed JSONL message. It checks both root-level toolUseResult.agentId and nested content blocks.
func FindSessionByID ¶
FindSessionByID finds a session transcript by full or partial ID Returns the full session ID and transcript path
func IsValidAgentID ¶
IsValidAgentID checks if a string is a valid agent ID. Agent IDs are 6+ characters matching [a-zA-Z0-9_-]+. This covers all observed formats:
- Pure hex (7-17+ chars): "a0074ac", "a3eaf63159a07953f"
- Compact: "acompact-2aaa241e456ebc94"
- Prompt suggestion: "aprompt_suggestion-ba74af"
- Legacy 8-char hex: "abcd1234"
func ReadHookInputFrom ¶
ReadHookInputFrom reads and parses hook data from the given reader. It delegates to types.ReadHookInput and additionally validates that transcript_path is non-empty (required by SessionStart/SessionEnd hooks).
func SanitizeText ¶
SanitizeText removes HTML tags, decodes HTML entities, and normalizes whitespace.
Types ¶
type ExtractionResult ¶
type ExtractionResult struct {
Summary string // Local summary for current session (no leafUuid)
FirstUserMessage string // First user message content
SummaryLinks []SummaryLink // Summaries with leafUuid (for linking to previous sessions)
}
ExtractionResult holds extracted metadata from transcript lines.
func ExtractMetadataFromLines ¶
func ExtractMetadataFromLines(lines []string) ExtractionResult
ExtractMetadataFromLines extracts summary and first user message from transcript lines. Unlike ExtractSessionMetadata, this processes lines already in memory (from a chunk).
For summaries:
- Summaries with leafUuid are collected in SummaryLinks (for linking to previous sessions)
- Summaries without leafUuid are local to current session (last one wins)
For user messages:
- First user message encountered sets FirstUserMessage
func ExtractSessionMetadata ¶
func ExtractSessionMetadata(transcriptPath string) ExtractionResult
ExtractSessionMetadata reads a transcript file and extracts summary and first user message. It reads up to MaxLinesForExtraction lines and delegates to ExtractMetadataFromLines.
type SessionInfo ¶
type SessionInfo struct {
SessionID string
TranscriptPath string
ProjectPath string // Relative path from projects dir
ModTime time.Time
SizeBytes int64
Summary string // First summary after first user message
FirstUserMessage string // First user message content
}
SessionInfo holds metadata about a discovered session
func ScanAllSessions ¶
func ScanAllSessions() ([]SessionInfo, error)
ScanAllSessions finds all session transcript files in ~/.claude/projects/ Returns sessions sorted by modification time (oldest first)
type SummaryLink ¶
SummaryLink represents a summary that links to a previous session via leafUuid.