Documentation
¶
Overview ¶
Package export provides functions to render Sprout session data as Markdown, HTML, or JSON documents. All three formats accept a SessionSource (the minimal structured view of a session) and an ExportOptions block to control what gets included.
Content is optionally redacted through pkg/secretdetect before any rendering happens so that secrets never leak into exported files.
Index ¶
- func Export(w io.Writer, s SessionSource, format ExportFormat, opts ExportOptions) error
- func ExportHTML(w io.Writer, s SessionSource, opts ExportOptions) error
- func ExportJSON(w io.Writer, s SessionSource, opts ExportOptions) error
- func ExportMarkdown(w io.Writer, s SessionSource, opts ExportOptions) error
- type ExportFormat
- type ExportOptions
- type MessageSource
- type SessionSource
- type ToolCallSource
- type ToolResultSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Export ¶
func Export(w io.Writer, s SessionSource, format ExportFormat, opts ExportOptions) error
Export dispatches to the appropriate format-specific exporter.
func ExportHTML ¶
func ExportHTML(w io.Writer, s SessionSource, opts ExportOptions) error
ExportHTML writes a self-contained HTML document with embedded CSS.
func ExportJSON ¶
func ExportJSON(w io.Writer, s SessionSource, opts ExportOptions) error
ExportJSON writes a lossless JSON encoding of s.
func ExportMarkdown ¶
func ExportMarkdown(w io.Writer, s SessionSource, opts ExportOptions) error
ExportMarkdown writes a Markdown rendering of s to w.
Types ¶
type ExportFormat ¶
type ExportFormat string
ExportFormat selects an output format.
const ( FormatMarkdown ExportFormat = "markdown" FormatHTML ExportFormat = "html" FormatJSON ExportFormat = "json" )
type ExportOptions ¶
type ExportOptions struct {
IncludeToolCalls bool // include tool calls/results blocks in the output
IncludeCost bool // include cost/tokens in the rendered output
RedactSecrets bool // apply pkg/secretdetect redaction before rendering (default true)
PrettyPrintJSON bool // pretty-print JSON output (default true)
Timezone *time.Location // for date formatting; nil = UTC
}
ExportOptions controls an export operation.
type MessageSource ¶
type MessageSource struct {
Role string // "user" | "assistant" | "system" | "tool"
Content string
Timestamp time.Time
ToolCalls []ToolCallSource // optional, for assistant messages
ToolResult *ToolResultSource // optional, set if Role=="tool"
Cost float64 // optional, per-message cost
Tokens int // optional, per-message tokens
}
MessageSource is a single message in the session.
type SessionSource ¶
type SessionSource struct {
ID string `json:"session_id"`
Name string `json:"name"`
WorkingDirectory string `json:"working_directory"`
StartedAt time.Time `json:"started_at"`
LastUpdated time.Time `json:"last_updated"`
Provider string `json:"provider"`
Model string `json:"model"`
TotalCost float64 `json:"total_cost"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
Messages []MessageSource `json:"messages"`
}
SessionSource is the minimal data needed to export a session.