export

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 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, tools []extension.RegisteredTool, cwd string, state *AgentState) (string, error)

ExportFromFileWithTools is ExportFromFile with the session's registered tools drawing their calls and results through their renderers, 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, tools []extension.RegisteredTool, cwd string, width int)

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.

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