artifact

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 14 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderTraceHTML

func RenderTraceHTML(entries []TraceEntry, sourcePath string) string

RenderTraceHTML produces a self-contained HTML viewer of a trace. No external deps; opens directly in a browser.

func WriteHAR

func WriteHAR(h *HAR, path string) error

WriteHAR persists the HAR JSON to path (0o600).

Types

type HAR

type HAR struct {
	Log HARLog `json:"log"`
}

HAR follows the HAR 1.2 specification (W3C Web Performance Working Group). It's intentionally minimal: we only populate what NetworkEntry knows about, leaving the optional fields (headers, cookies, content text) empty so parsers treat them as "not captured" rather than "empty".

func BuildHAR

func BuildHAR(entries []engine.NetworkEntry, pageURL, pageTitle, creatorVersion string) *HAR

BuildHAR constructs a HAR from the passive NetworkEntry slice collected by requestTracker. pageURL and pageTitle name the top-level page.

type HARContent

type HARContent struct {
	Size     int    `json:"size"`
	MimeType string `json:"mimeType"`
}

HARContent carries the payload summary (size, MIME).

type HARCreator

type HARCreator struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

HARCreator identifies the tool that recorded the trace.

type HAREntry

type HAREntry struct {
	PageRef         string      `json:"pageref,omitempty"`
	StartedDateTime string      `json:"startedDateTime"`
	Time            int64       `json:"time"`
	Request         HARRequest  `json:"request"`
	Response        HARResponse `json:"response"`
	Cache           struct{}    `json:"cache"`
	Timings         HARTimings  `json:"timings"`
}

HAREntry is one network request + response.

type HARLog

type HARLog struct {
	Version string     `json:"version"`
	Creator HARCreator `json:"creator"`
	Pages   []HARPage  `json:"pages"`
	Entries []HAREntry `json:"entries"`
}

HARLog is the top-level container.

type HARPage

type HARPage struct {
	StartedDateTime string `json:"startedDateTime"`
	ID              string `json:"id"`
	Title           string `json:"title"`
}

HARPage groups entries by the top-level navigation that produced them.

type HARRequest

type HARRequest struct {
	Method      string   `json:"method"`
	URL         string   `json:"url"`
	HTTPVersion string   `json:"httpVersion"`
	Headers     []string `json:"headers"`
	QueryString []string `json:"queryString"`
	HeadersSize int      `json:"headersSize"`
	BodySize    int      `json:"bodySize"`
}

HARRequest describes the outgoing request.

type HARResponse

type HARResponse struct {
	Status      int        `json:"status"`
	StatusText  string     `json:"statusText"`
	HTTPVersion string     `json:"httpVersion"`
	Headers     []string   `json:"headers"`
	Cookies     []string   `json:"cookies"`
	Content     HARContent `json:"content"`
	RedirectURL string     `json:"redirectURL"`
	HeadersSize int        `json:"headersSize"`
	BodySize    int        `json:"bodySize"`
}

HARResponse describes the incoming response.

type HARTimings

type HARTimings struct {
	Send    int   `json:"send"`
	Wait    int64 `json:"wait"`
	Receive int   `json:"receive"`
}

HARTimings models per-phase durations. We only know the total so we put it on "wait".

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder injects a JS listener into the page, coalesces typing, and emits JSONL ops to w. It uses Runtime.addBinding so the JS → Go channel is clean (no console-log pollution).

Call Start() once then either Wait() (blocks until done) or Stop().

func NewRecorder

func NewRecorder(page *rod.Page, w io.Writer, opts RecorderOpts) *Recorder

NewRecorder creates a recorder but does not start it.

func (*Recorder) Done

func (r *Recorder) Done() <-chan struct{}

Done returns a channel closed when the recorder stops.

func (*Recorder) Start

func (r *Recorder) Start() error

Start registers the CDP binding, injects the JS listener, and begins listening for user events. It is safe to call once.

func (*Recorder) Stop

func (r *Recorder) Stop()

Stop tears down the recorder and flushes any pending typed text.

type RecorderOp

type RecorderOp struct {
	Op   string         `json:"op"`
	Args map[string]any `json:"args"`
}

RecorderOp is a single user-action op, ready to be written as JSONL. The schema matches the agentRequest format consumed by `ghostchrome agent`.

type RecorderOpts

type RecorderOpts struct {
	IncludeScrolls bool
	IncludeHovers  bool
	StopOnNavigate bool // stop recording after first user-triggered navigation
}

RecorderOpts configures a Recorder session.

type TraceEntry

type TraceEntry struct {
	TS         int64          `json:"ts"`
	Op         string         `json:"op"`
	Args       map[string]any `json:"args,omitempty"`
	OK         bool           `json:"ok"`
	Outcome    string         `json:"outcome,omitempty"`
	DurationMs int64          `json:"duration_ms"`
	Summary    string         `json:"summary,omitempty"`
	Error      string         `json:"error,omitempty"`
	Shot       string         `json:"shot,omitempty"`
}

TraceEntry is one line of a ghostchrome MCP session trace (JSONL).

func ReadTrace

func ReadTrace(path string, limit int) ([]TraceEntry, error)

ReadTrace reads up to limit last entries from a JSONL trace file. limit <= 0 means all entries.

Jump to

Keyboard shortcuts

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