Help us shape the future of Go! Take the 2026 Go Developer Survey

export

package
v0.32.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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
}

--------------------------------------------------------------------------- Public types --------------------------------------------------------------------------- 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.

type ToolCallSource

type ToolCallSource struct {
	Name      string
	Arguments string // raw JSON or string
	Result    string // raw JSON or string
	Timestamp time.Time
}

ToolCallSource records a single tool invocation by the assistant.

type ToolResultSource

type ToolResultSource struct {
	ToolCallName string
	Content      string
	Timestamp    time.Time
}

ToolResultSource records the result of a tool call (role=="tool").

Jump to

Keyboard shortcuts

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