logparser

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileParser

type FileParser struct {
	// contains filtered or unexported fields
}

FileParser incrementally parses a JSONL session file, tracking state across calls.

func NewFileParser

func NewFileParser() *FileParser

NewFileParser creates a new parser with empty state.

func (*FileParser) State

func (p *FileParser) State() SessionState

State returns the current accumulated state.

func (*FileParser) Update

func (p *FileParser) Update(reader FileReader, path string) (SessionState, error)

Update reads new data from the file and updates internal state.

func (*FileParser) UpdateBytes

func (p *FileParser) UpdateBytes(data []byte) (SessionState, error)

UpdateBytes parses raw JSONL bytes (for testing). Resets offset to 0 on first call.

type FileReader

type FileReader interface {
	ReadFrom(path string, offset int64) ([]byte, int64, error)
}

FileReader abstracts reading bytes from a file at a given offset.

type OSFileReader

type OSFileReader struct{}

OSFileReader implements FileReader using the real filesystem.

func (OSFileReader) ReadFrom

func (OSFileReader) ReadFrom(path string, offset int64) ([]byte, int64, error)

ReadFrom reads bytes from path starting at offset, returning data and new offset.

type SessionState

type SessionState struct {
	SessionID    string
	Cwd          string
	Slug         string
	StartedAt    time.Time
	LastActivity time.Time
	IsWorking    bool // true = Claude actively generating, false = idle/waiting
	Subagents    []Subagent
	Tasks        []Task
}

SessionState holds the parsed state for a single JSONL session file.

type Subagent

type Subagent struct {
	ToolUseID    string // tool_use id (e.g. "toolu_01AaZ...") for completion tracking
	Description  string // from input.description
	SubagentType string // "Explore", "Plan", etc.
	AgentID      string // from toolUseResult.agentId on completion
	StartedAt    time.Time
	CompletedAt  *time.Time // nil = still running
	DurationMs   int64      // from toolUseResult.totalDurationMs (0 if still running)
}

Subagent represents a spawned Agent tool_use and its lifecycle.

type Task

type Task struct {
	TaskID    string // from toolUseResult.task.id (TaskCreate result) or input.taskId (TaskUpdate)
	ToolUseID string // tool_use id of the TaskCreate — for mapping result → taskId
	Subject   string
	Status    string // "pending", "in_progress", "completed"
	CreatedAt time.Time
	UpdatedAt time.Time
}

Task represents a TaskCreate/TaskUpdate tool_use and its status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL