Documentation
¶
Index ¶
- func DirSize(dir string) (int64, error)
- func Export(w io.Writer, session *Session, opts ExportOptions) error
- func ExportRawByID(dir, identifier string, w io.Writer) error
- func ExportSessionByID(dir, identifier string, w io.Writer, opts ExportOptions) error
- func FormatSession(w io.Writer, session *Session, opts FormatOptions)
- func FormatSessionList(w io.Writer, sessions []SessionSummary, days int)
- func FormatTailEntry(w io.Writer, line []byte)
- func GetSessionFilePath(dir, identifier string) (string, error)
- func IsNoSessionsError(err error) bool
- func ParseRawLines(filePath string) ([]json.RawMessage, error)
- func Tail(ctx context.Context, filePath string, w io.Writer, opts TailOptions) error
- func TailLatest(ctx context.Context, dir string, w io.Writer, opts TailOptions) error
- func WatchDir(ctx context.Context, dir string) (string, error)
- type Entry
- type EventEntry
- type ExportFormat
- type ExportOptions
- type FormatOptions
- type Message
- type NoSessionsError
- type Part
- type RequestData
- type RequestEntry
- type SearchOptions
- type SearchResult
- type Session
- type SessionSummary
- func FilterSessions(sessions []SessionSummary, opts SearchOptions) []SessionSummary
- func GetMostRecentSession(dir string) (*SessionSummary, error)
- func GetSessionByID(dir, id string) (*SessionSummary, error)
- func GetSessionByNumber(dir string, num int) (*SessionSummary, error)
- func ListSessions(dir string) ([]SessionSummary, error)
- func ResolveSession(dir, identifier string) (*SessionSummary, error)
- type TailOptions
- type TokenUsage
- type Tool
- type ToolCall
- type ToolChoice
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Export ¶
func Export(w io.Writer, session *Session, opts ExportOptions) error
Export exports a session in the specified format
func ExportRawByID ¶
ExportRawByID exports raw JSONL by session ID or number
func ExportSessionByID ¶
func ExportSessionByID(dir, identifier string, w io.Writer, opts ExportOptions) error
ExportSessionByID exports a session by ID or number
func FormatSession ¶
func FormatSession(w io.Writer, session *Session, opts FormatOptions)
FormatSession formats a full session for display
func FormatSessionList ¶
func FormatSessionList(w io.Writer, sessions []SessionSummary, days int)
FormatSessionList formats a list of sessions as a table
func FormatTailEntry ¶
FormatTailEntry formats a single entry for tail mode (compact)
func GetSessionFilePath ¶
GetSessionFilePath returns the file path for a session
func IsNoSessionsError ¶
IsNoSessionsError checks if an error is a NoSessionsError
func ParseRawLines ¶
func ParseRawLines(filePath string) ([]json.RawMessage, error)
ParseRawLines parses a session file and returns raw JSON lines
func TailLatest ¶
TailLatest tails the most recent session file
Types ¶
type Entry ¶
type Entry struct {
Timestamp time.Time
SessionID string
Type string // "request" or "event"
Raw json.RawMessage
}
Entry is the base type for all log entries
type EventEntry ¶
type EventEntry struct {
Timestamp time.Time
SessionID string
EventType string
Data map[string]any
}
EventEntry represents a logged LLM event
type ExportFormat ¶
type ExportFormat string
ExportFormat specifies the export format
const ( FormatJSON ExportFormat = "json" FormatMarkdown ExportFormat = "markdown" FormatRaw ExportFormat = "raw" )
type ExportOptions ¶
type ExportOptions struct {
Format ExportFormat
Redact bool // Redact sensitive content (API keys, file contents, paths)
}
ExportOptions controls export behavior
type FormatOptions ¶
type FormatOptions struct {
ShowTools bool // Highlight tool calls/results
RequestsOnly bool // Only show requests, not streaming events
NoColor bool // Disable colors
ShowTimestamp bool // Show timestamp for each entry
}
FormatOptions controls how session output is formatted
type NoSessionsError ¶
type NoSessionsError struct{}
NoSessionsError indicates no sessions were found
func (*NoSessionsError) Error ¶
func (e *NoSessionsError) Error() string
type Part ¶
type Part struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ReasoningContent string `json:"reasoning_content,omitempty"`
ReasoningItemID string `json:"reasoning_item_id,omitempty"`
ReasoningEncryptedContentLen int `json:"reasoning_encrypted_content_len,omitempty"`
ReasoningEncryptedContentHash string `json:"reasoning_encrypted_content_hash,omitempty"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
ToolResult *ToolResult `json:"tool_result,omitempty"`
}
Part represents a message part
type RequestData ¶
type RequestData struct {
SessionID string `json:"session_id,omitempty"`
Messages []Message `json:"messages"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice *ToolChoice `json:"tool_choice,omitempty"`
Search bool `json:"search,omitempty"`
ForceExternalSearch bool `json:"force_external_search,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"top_p,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
ReasoningReplayParts int `json:"reasoning_replay_parts,omitempty"`
ReasoningEncryptedParts int `json:"reasoning_encrypted_parts,omitempty"`
MaxTurns int `json:"max_turns,omitempty"`
}
RequestData contains the request details
type RequestEntry ¶
type RequestEntry struct {
Timestamp time.Time
SessionID string
Provider string
Model string
Request RequestData
}
RequestEntry represents a logged LLM request
type SearchOptions ¶
type SearchOptions struct {
Query string // Text query to search for
ToolName string // Filter by tool name
Provider string // Filter by provider
ErrorsOnly bool // Only show sessions/entries with errors
Days int // Only search sessions from last N days
}
SearchOptions controls search behavior
type SearchResult ¶
type SearchResult struct {
SessionID string
FilePath string
LineNum int
Timestamp time.Time
EntryType string // "request" or "event"
EventType string // For events: "text_delta", "tool_call", etc.
Match string // The matching content
Context string // Additional context
}
SearchResult represents a search match
func Search ¶
func Search(dir string, opts SearchOptions) ([]SearchResult, error)
Search searches across all sessions for matching entries
type Session ¶
type Session struct {
ID string
FilePath string
StartTime time.Time
EndTime time.Time
Provider string
Model string
Turns int // Number of request/response cycles
TotalTokens TokenUsage
HasErrors bool
Command string // CLI command that started the session
Args []string // CLI arguments
Cwd string // Working directory
Entries []any // RequestEntry or EventEntry
}
Session represents a debug session with metadata
func ParseSession ¶
ParseSession parses a full session file into a Session struct
type SessionSummary ¶
type SessionSummary struct {
ID string
FilePath string
StartTime time.Time
Provider string
Model string
Calls int // Number of LLM API calls
Input int // Input tokens
Output int // Output tokens
Cached int // Cached input tokens
HasErrors bool
FileSize int64
}
SessionSummary is a lightweight session info for listing
func FilterSessions ¶
func FilterSessions(sessions []SessionSummary, opts SearchOptions) []SessionSummary
FilterSessions filters sessions by various criteria
func GetMostRecentSession ¶
func GetMostRecentSession(dir string) (*SessionSummary, error)
GetMostRecentSession returns the most recent session
func GetSessionByID ¶
func GetSessionByID(dir, id string) (*SessionSummary, error)
GetSessionByID returns the session with the given ID
func GetSessionByNumber ¶
func GetSessionByNumber(dir string, num int) (*SessionSummary, error)
GetSessionByNumber returns the session at the given 1-based index (1 = most recent)
func ListSessions ¶
func ListSessions(dir string) ([]SessionSummary, error)
ListSessions returns summaries of all sessions in the debug log directory, sorted by start time (most recent first).
func ResolveSession ¶
func ResolveSession(dir, identifier string) (*SessionSummary, error)
ResolveSession resolves a session identifier (number or ID) to a session summary
type TailOptions ¶
type TailOptions struct {
Follow bool // Keep watching for new entries
}
TailOptions controls tail behavior
type TokenUsage ¶
TokenUsage tracks token consumption
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments"`
}
ToolCall is a simplified tool call for logging
type ToolChoice ¶
ToolChoice represents tool choice settings