Skip to main content

Module explain

Module explain 

Source
Expand description

lobe explain — AI-driven analysis of a captured session.

Reads a CaptureSessionExport JSON file, preprocesses it into a compact summary, and calls the Anthropic Messages API with a USE-method prompt. Returns the rendered markdown report as a String.

Key setup: reads ANTHROPIC_API_KEY from the process environment. If unset, explain_session returns a TloxError::MissingApiKey error which the CLI layer converts to a friendly onboarding message.

Structs§

ErrorsBlock
ExplainOptions
ExplainResult
PhaseMedians
RouteAggregate
SampleRequest
SessionMeta
SessionSummary
StatusCodeCount

Enums§

ExplainModel
Which Claude model powers the analysis. Haiku is the default because the task is structured USE-method application over a preprocessed payload, not open-ended reasoning — Haiku handles it well at a fraction of the cost.

Functions§

estimate_input_tokens
Estimate input tokens for cost warning. Very rough — 4 chars per token.
explain_session
Top-level entry point. Reads env, loads session, builds prompt, calls Anthropic, returns the markdown report.
load_session
Load a session export from disk. Errors carry the underlying I/O or parse failure so the CLI can print an actionable message.
read_api_key
Read the API key from environment. Empty string counts as missing.
summarize_session