export

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 42 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package export writes sessions out: a JSONL backup, Markdown and QMD transcripts that verify themselves, a browsable HTML page, the prompts the user sent, and Claude Code JSONL traces

Index

Constants

View Source
const (
	FormatJSONL      = "jsonl"
	FormatMD         = "md"
	FormatQMD        = "qmd"
	FormatHTML       = "html"
	FormatTrace      = "trace"
	FormatTrajectory = "trajectory"
)

Formats an export writes, by name

View Source
const (
	TraceDataset      = "icebath-traces"
	TrajectoryDataset = "icebath-trajectories"
)

Datasets of the person's Hugging Face account uploads go to: traces of sessions, and trajectories

View Source
const (
	TurnSystem = "system"
	TurnHuman  = "human"
	TurnGPT    = "gpt"
	TurnTool   = "tool"
)

Names of the turns of a trajectory, by who speaks

Variables

Formats in the order they are offered

View Source
var TokenVariables = []string{"HF_TOKEN", "HUGGINGFACE_HUB_TOKEN", "HUGGING_FACE_HUB_TOKEN", "HUGGINGFACE_TOKEN"}

Variables a Hugging Face token is kept in, the first the one icebath keeps it as

Functions

func Completed

func Completed(t *sessionsv1.Transcript) bool

Whether the session's last turn ended in an answer: its last message is a reply of the agent that calls no tool and did not fail

func DefaultName

func DefaultName(id, format string) string

Name a single session's file takes: its id with only letters, digits, dashes and underscores

func Entry

func Entry(conversations []any, model string, completed bool, at time.Time) *jsonx.Object

Line of a file of trajectories: the turns, when it was written, the model and whether its last turn ended in an answer

func Exports

func Exports(profileDir string) string

Folder the exports of a profile go to when none is named, inside the folder of the profile

func FileMask

func FileMask(text string) string

Masks secrets as a file of trajectories keeps them, whatever any other setting says

func FileName

func FileName(s *sessionsv1.Session, format string) string

File name of a session's Markdown or QMD export: its id and a slug of its title

func HTML

func HTML(transcripts []*sessionsv1.Transcript) ([]byte, error)

Page that shows the sessions, one view each with a sidebar to pick and search them when there are several; works offline, its script allowed only by the nonce the page carries

func JSONL

func JSONL(transcripts []*sessionsv1.Transcript) ([]byte, error)

JSONL backup: one line per session with every message it holds

func Kept

func Kept(messages []*sessionsv1.Message) []*sessionsv1.Message

Messages a person reads of a stored transcript: those taken back by an undo left out

func ManifestLine

func ManifestLine(head *sessionsv1.Session, lineage []string, format, path string, count int, data []byte, at time.Time) ([]byte, error)

Line the manifest of an export folder gets for one file

func Mask

func Mask(value any, mask func(text string) string) any

Every text of a trajectory value masked by mask, the JSON of tool_call and tool_response blocks read first and masked field by field, so a mark never breaks a quote or a brace of it

func Memory

func Memory(segments []*sessionsv1.Transcript, format string, at time.Time) ([]byte, int)

Markdown or QMD export of a session, or of its compression lineage oldest first, that carries a digest of itself; and how many messages it holds

func Merge

func Merge(segments []*sessionsv1.Transcript) *sessionsv1.Transcript

One transcript of a compression chain, oldest first: the newest session with the messages of every one in order, and the tools it was offered last

func Private

func Private(ctx context.Context, client *http.Client, folder, repo, token, endpoint string) error

Makes the dataset of the person's private, and the uploads the exports folder remembers of it private too

func PromptsJSONL

func PromptsJSONL(transcripts []*sessionsv1.Transcript) ([]byte, int, error)

Prompts the user sent, one JSON line each, and how many

func PromptsMarkdown

func PromptsMarkdown(transcripts []*sessionsv1.Transcript) []byte

Prompts the user sent as Markdown sections, session by session

func Redact

func Redact(transcripts []*sessionsv1.Transcript) []*sessionsv1.Transcript

Transcripts with every text in them masked of secrets: messages, titles, prompts, directories and settings

func Restore

func Restore(data []byte) ([]*sessionsv1.Transcript, error)

Sessions of a JSONL backup JSONL writes, each whole with its messages and system prompt, the sessions each continues before it; an error names the first line that is no session of a backup

func Role

func Role(m *sessionsv1.Message) string

Role of a message as exports name it

func Run

func Run(ctx context.Context, service Service, r Request, out Out) error

Writes the sessions the request names in its format, saying what it wrote

func Scratchpad

func Scratchpad(text string) string

Text with every scratchpad tag written as a think tag

func Stamp

func Stamp(at time.Time) string

Time as a trajectory is stamped: the local time, its microseconds only when there are any

func Token

func Token(lookup func(name string) string) string

Hugging Face token of an environment, the first of its variables set; empty for none

func Tools

func Tools(registry *tools.Registry, cfg *config.Config, t *sessionsv1.Transcript) []map[string]any

Definitions of the tools the session was offered with its system prompt, as a provider is sent them, for the settings of the session; none for a session that was offered none or never sent a prompt

func Trace

func Trace(t *sessionsv1.Transcript, mask func(text string) string) ([]byte, error)

Session as Claude Code JSONL, which the Hugging Face Agent Trace Viewer reads: one line per message the model saw, each pointing at the one before. Its secrets are masked by mask, kept for nil

func Trajectory

func Trajectory(t *sessionsv1.Transcript, definitions []map[string]any) ([]any, error)

The session as the ShareGPT turns training sets read: the function calling prompt with the tools, then a human turn for each message of the person, a gpt turn for each of the agent with its reasoning in think tags and its calls in tool_call tags, and one tool turn holding the results of the calls that follow each, in tool_response tags. The person's pictures stand as [screenshot]

func Upload

func Upload(ctx context.Context, s Sending) (string, sessions.Tone, error)

Account of an upload the person reads, its link on success: the data as the file at the path of the person's dataset of the name, a dataset made for it private unless public, committed with the summary; remembered in the exports folder with whether the dataset is public

func Verify

func Verify(data []byte, id string, count int) error

Why a written Markdown or QMD export is not whole, nil when it is: its digest matches its body, and it names the session and count it should

Types

type Out

type Out interface {
	Line(text string, tone sessions.Tone)
	Print(data []byte) error
	Preview(filter *sessionsv1.Filter, matches []*sessionsv1.Session)
}

Where an export reports: its lines, the bytes it prints for an output of -, and the sessions a dry run would write

type Request

type Request struct {
	Format string
	// One session by id, else the sessions the filter matches, else every session of the profile
	ID     string
	Filter *sessionsv1.Filter
	// Profile whose sessions are written, which every filter takes
	Profile string
	// Only the messages you wrote, for jsonl and md
	Prompts bool
	// API keys, tokens and passwords hidden, which a trace does unless Raw is set
	Redact bool
	Raw    bool
	// With md, qmd and trajectory, the sessions one continues written into its file
	Lineage bool
	// With trace and trajectory, the newest session asked for sent to the person's Hugging Face dataset instead of a file, public when asked,
	// with the token given
	Upload, Public bool
	Token          string
	// Values of the profile's secrets, masked wherever they stand in what is uploaded
	Known []string
	// Tools whose definitions head a trajectory, as each session was offered them, and the settings they are defined under
	Tools  *tools.Registry
	Config *config.Config
	// Address of the Hugging Face it goes to, huggingface.co for none, and the client that reaches it
	Endpoint string
	Client   *http.Client
	// With md and qmd of one session, the session deleted once its file checks out, and a file there replaced
	DeleteAfter, Force bool
	// File or folder to write, the bytes printed for -, Folder for none
	Output string
	// Folder of the exports of the profile, where an export goes when it names no output
	Folder string
	// Only says what would be written
	DryRun bool
}

What an export writes: which sessions of which profile, in what format, where, and what it does around that

type Sending

type Sending struct {
	// Name of the dataset, the path of the file in it, and what its commit says
	Dataset, Path, Summary string
	Data                   []byte
	// A dataset made for it is public, private otherwise
	Public bool
	// Token that may write, the Hugging Face of the endpoint, huggingface.co for none, and the client that reaches it
	Token, Endpoint string
	Client          *http.Client
	// Exports folder of the profile, where the upload is remembered; none when empty
	Folder string
}

One file sent to a dataset of the person's Hugging Face account

type Uploaded

type Uploaded struct {
	// Dataset as owner/name, the path of the file in it, whether the dataset is public, and when
	Repo   string    `json:"repo"`
	Path   string    `json:"path"`
	Public bool      `json:"public"`
	At     time.Time `json:"at"`
	// Hugging Face it went to
	Endpoint string `json:"endpoint"`
}

One upload to a dataset of the person's, as the exports folder of the profile remembers it

func Uploads

func Uploads(folder string) []Uploaded

Uploads the exports folder remembers, oldest first

Jump to

Keyboard shortcuts

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