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
- Variables
- func Completed(t *sessionsv1.Transcript) bool
- func DefaultName(id, format string) string
- func Entry(conversations []any, model string, completed bool, at time.Time) *jsonx.Object
- func Exports(profileDir string) string
- func FileMask(text string) string
- func FileName(s *sessionsv1.Session, format string) string
- func HTML(transcripts []*sessionsv1.Transcript) ([]byte, error)
- func JSONL(transcripts []*sessionsv1.Transcript) ([]byte, error)
- func Kept(messages []*sessionsv1.Message) []*sessionsv1.Message
- func ManifestLine(head *sessionsv1.Session, lineage []string, format, path string, count int, ...) ([]byte, error)
- func Mask(value any, mask func(text string) string) any
- func Memory(segments []*sessionsv1.Transcript, format string, at time.Time) ([]byte, int)
- func Merge(segments []*sessionsv1.Transcript) *sessionsv1.Transcript
- func Private(ctx context.Context, client *http.Client, folder, repo, token, endpoint string) error
- func PromptsJSONL(transcripts []*sessionsv1.Transcript) ([]byte, int, error)
- func PromptsMarkdown(transcripts []*sessionsv1.Transcript) []byte
- func Redact(transcripts []*sessionsv1.Transcript) []*sessionsv1.Transcript
- func Restore(data []byte) ([]*sessionsv1.Transcript, error)
- func Role(m *sessionsv1.Message) string
- func Run(ctx context.Context, service Service, r Request, out Out) error
- func Scratchpad(text string) string
- func Stamp(at time.Time) string
- func Token(lookup func(name string) string) string
- func Tools(registry *tools.Registry, cfg *config.Config, t *sessionsv1.Transcript) []map[string]any
- func Trace(t *sessionsv1.Transcript, mask func(text string) string) ([]byte, error)
- func Trajectory(t *sessionsv1.Transcript, definitions []map[string]any) ([]any, error)
- func Upload(ctx context.Context, s Sending) (string, sessions.Tone, error)
- func Verify(data []byte, id string, count int) error
- type Out
- type Request
- type Sending
- type Service
- type Uploaded
Constants ¶
const ( FormatJSONL = "jsonl" FormatMD = "md" FormatQMD = "qmd" FormatHTML = "html" FormatTrace = "trace" FormatTrajectory = "trajectory" )
Formats an export writes, by name
const ( TraceDataset = "icebath-traces" TrajectoryDataset = "icebath-trajectories" )
Datasets of the person's Hugging Face account uploads go to: traces of sessions, and trajectories
const ( TurnSystem = "system" TurnHuman = "human" TurnGPT = "gpt" TurnTool = "tool" )
Names of the turns of a trajectory, by who speaks
Variables ¶
var Formats = []string{FormatMD, FormatJSONL, FormatHTML, FormatQMD, FormatTrace, FormatTrajectory}
Formats in the order they are offered
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 ¶
Name a single session's file takes: its id with only letters, digits, dashes and underscores
func Entry ¶
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 ¶
Folder the exports of a profile go to when none is named, inside the folder of the profile
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 ¶
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 ¶
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 Scratchpad ¶
Text with every scratchpad tag written as a think tag
func Stamp ¶
Time as a trajectory is stamped: the local time, its microseconds only when there are any
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]
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 Service ¶
type Service interface {
Export(context.Context, *sessionsv1.ExportRequest) (*sessionsv1.ExportResponse, error)
Prune(context.Context, *sessionsv1.PruneRequest) (*sessionsv1.PruneResponse, error)
List(context.Context, *sessionsv1.ListRequest) (*sessionsv1.ListResponse, error)
Delete(context.Context, *sessionsv1.DeleteRequest) (*sessionsv1.DeleteResponse, error)
}
Calls of the session service an export makes
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