export

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Ports packages/coding-agent/src/core/export-html/ansi-to-html.ts

Package export provides HTML session export.

Ports packages/coding-agent/src/core/export-html/index.ts using embedded pinned templates and vendor assets.

Ports packages/coding-agent/src/core/export-html/tool-renderer.ts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportFromFile

func ExportFromFile(inputPath, outputPath string) (string, error)

ExportFromFile reads a session JSONL file and writes the upstream-style HTML export.

func ExportFromFileWithTools

func ExportFromFileWithTools(inputPath, outputPath string, getToolRenderers func(name string) *extension.ToolRenderers, cwd string, state *AgentState) (string, error)

ExportFromFileWithTools is ExportFromFile with tool calls and results drawn through the renderers getToolRenderers returns, as upstream AgentSession.exportToHtml passes a tool renderer. A non-nil state is the live agent state upstream passes to exportSessionToHtml, which embeds its systemPrompt and tools; nil is upstream exportFromFile (CLI --export), whose session data carries neither.

func RenderCustomTools

func RenderCustomTools(data *SessionData, getToolRenderers func(name string) *extension.ToolRenderers, cwd string, width int)

RenderCustomTools draws the session's tool calls and results with getToolRenderers, as upstream's tool HTML renderer draws them with the renderers ToolHtmlRendererDeps.getToolRenderers returns.

func ToHTML

func ToHTML(data SessionData) string

ToHTML converts session data to Pi's self-contained HTML, with a base64 JSON.stringify payload and first-match template substitution.

func ToolRenderersOf

func ToolRenderersOf(tools []extension.RegisteredTool) func(name string) *extension.ToolRenderers

ToolRenderersOf returns the renderers of the registered tools by name, or nil for another tool.

Types

type AgentState

type AgentState struct {
	SystemPrompt string
	Tools        []ToolSchema
}

AgentState is the live agent state upstream exportSessionToHtml receives as its state argument: state.systemPrompt and state.tools.

type SessionData

type SessionData struct {
	Header        json.RawMessage           `json:"header"`
	Entries       []json.RawMessage         `json:"entries"`
	LeafID        *string                   `json:"leafId"`
	SystemPrompt  *string                   `json:"systemPrompt,omitempty"`
	Tools         []ToolSchema              `json:"tools,omitzero"`
	RenderedTools map[string]map[string]any `json:"renderedTools,omitempty"`
}

SessionData mirrors upstream export-html's payload shape. Header and Entries use json.RawMessage to preserve the original JSONL key ordering. Go's map[string]any sorts keys alphabetically on Marshal, but upstream JS preserves insertion order. Using RawMessage ensures the base64-encoded session data in the HTML is byte-identical to upstream.

func FromJSONL

func FromJSONL(data []byte) (SessionData, error)

FromJSONL converts raw session JSONL bytes into export SessionData. Uses json.RawMessage to preserve the original key ordering from the JSONL.

type ToolSchema

type ToolSchema struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters,omitempty"`
}

ToolSchema is one tool in the export's session data: upstream Pick<ToolDefinition, "name" | "description" | "parameters">.

Jump to

Keyboard shortcuts

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