Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConversationMessage ¶
type ConversationMessage struct {
Role string // "user" or "assistant"
Text string // first text block, truncated to 300 chars
Timestamp time.Time
}
ConversationMessage holds a single human-readable message from the conversation.
type DesktopMeta ¶
type DesktopMeta struct {
Title string
DesktopID string // Desktop's own session ID (distinct from cliSessionId)
PermissionMode string
IsArchived bool
CreatedAt time.Time
}
DesktopMeta holds metadata from Claude Desktop's session JSON files.
type Session ¶
type Session struct {
// Identity
SessionID string
JSONLPath string
// Runtime
CWD string // working directory
Version string // agent version
Model string // model being used
GitBranch string
IsSidechain bool // true = sub-agent spawned by another session
// Git / worktree
IsWorktree bool
MainRepo string // main repo path if worktree
// Status
Status SessionStatus
CurrentTool string // name of tool currently executing, if any
LastActivity time.Time // timestamp of last JSONL entry
LastSummaryAt time.Time // timestamp of last compaction summary entry
TotalMessages int
RecentTools []ToolCall // last N tool calls
// Conversation preview
RecentMessages []ConversationMessage // last 10 human-readable messages
// Last file written/edited
LastFileWrite string // absolute path of most recent Write/Edit/NotebookEdit
LastFileWriteAt time.Time // timestamp of that tool call
// Counts
UserMessages int
AssistantMessages int
// Activity timeline (for sparkline)
EntryTimestamps []time.Time
// Cost tracking
CostUSD float64 // cumulative cost from JSONL entries
InputTokens int
OutputTokens int
CacheCreationTokens int
CacheReadTokens int
// Agent identity
Agent string // "claude" or "pi" — which coding agent produced this session
Name string // session display name (from pi session_info or custom)
// Desktop metadata (non-nil if session was started via Claude Desktop)
Desktop *DesktopMeta
}
Session holds all observable information about a coding agent instance.
type SessionCache ¶
type SessionCache struct {
// contains filtered or unexported fields
}
SessionCache caches parsed JSONL sessions keyed by file path. On subsequent calls, only files whose mtime changed are re-parsed. Shared by all agent providers (Claude, pi, etc.).
func NewSessionCache ¶
func NewSessionCache() *SessionCache
NewSessionCache creates an empty session cache.
func (*SessionCache) GetIncremental ¶
GetIncremental returns the cached session and byte offset for incremental parsing. If the file is unchanged, returns (session, 0, mtime) — a full cache hit. If the file has changed and a previous entry exists, returns (session, offset, mtime) where session is a Clone of the previous state and offset is the byte position to resume from. If no previous entry exists, returns (nil, 0, mtime) — a full miss.
func (*SessionCache) Prune ¶
func (c *SessionCache) Prune(seen map[string]struct{})
Prune removes cache entries for files no longer present in the seen set.
type SessionStatus ¶
type SessionStatus int
SessionStatus represents the current activity of a coding agent session.
const ( StatusUnknown SessionStatus = iota StatusWaitingForUser // Agent responded, awaiting human input StatusThinking // Agent is generating a response StatusExecutingTool // Agent invoked a tool, waiting for result StatusProcessingResult // Tool result received, agent is thinking StatusIdle // Session file exists but process not running )
func (SessionStatus) String ¶
func (s SessionStatus) String() string