cloak

package
v2026.909.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("CloakBrowser is unavailable")

Functions

This section is empty.

Types

type Browser

type Browser interface {
	NewTab(context.Context, string) (string, error)
	Navigate(context.Context, string, string, string) (Navigation, error)
	Snapshot(context.Context, string, string, SnapshotOptions) (Snapshot, error)
	CloseTab(context.Context, string, string) error
	Close() error
}

type Client

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

func NewClient

func NewClient(options Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CloseTab

func (c *Client) CloseTab(ctx context.Context, tabID, intent string) error

func (*Client) Navigate

func (c *Client) Navigate(ctx context.Context, tabID, rawURL, intent string) (Navigation, error)

func (*Client) NewTab

func (c *Client) NewTab(ctx context.Context, intent string) (string, error)

func (*Client) Snapshot

func (c *Client) Snapshot(ctx context.Context, tabID, intent string, options SnapshotOptions) (Snapshot, error)
type Link struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet,omitempty"`
}
type Navigation struct {
	TabID       string `json:"tabID"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Status      int    `json:"status"`
	ContentType string `json:"contentType"`
}

type Options

type Options struct {
	InstallDir string
	CacheDir   string
	NodePath   string
	Stderr     io.Writer
}

type ParsedSnapshot

type ParsedSnapshot struct {
	Title string
	Text  string
	Links []Link
}

ParsedSnapshot is the DOM-derived part of a browser snapshot. It is kept separate from Snapshot because the Node sidecar only transports HTML; Go owns the interpretation of that HTML.

func ParseSnapshotHTML

func ParseSnapshotHTML(rawHTML, rawBaseURL string) ParsedSnapshot

ParseSnapshotHTML extracts the useful snapshot content in Go. Keeping this function on the package surface also lets host-level tests exercise the exact parser used by Client without starting a browser process.

type Snapshot

type Snapshot struct {
	TabID       string `json:"tabID"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Status      int    `json:"status"`
	ContentType string `json:"contentType"`
	Text        string `json:"text"`
	HTML        string `json:"html"`
	Links       []Link `json:"links"`
	Truncated   bool   `json:"truncated"`
}

type SnapshotOptions

type SnapshotOptions struct {
	MaxCharacters int
	IncludeHTML   bool
}

Jump to

Keyboard shortcuts

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