actions

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBootstrapAkamaiUnvalidated = errors.New("bootstrap: _abck cookie captured but still in unvalidated state; re-run with --headful and move the mouse / click during the wait window")

ErrBootstrapAkamaiUnvalidated is returned when Akamai's _abck cookie was set but its value never reached the validated state (`~-1~` marker). This happens when the bootstrap runs headless, or headful but the user never moved the mouse / clicked during the wait window — Akamai's sensor keeps the cookie in "still collecting telemetry" state forever. Remedy: rerun with Headless=false and interact with the window during the wait.

View Source
var ErrBootstrapTimeout = errors.New("bootstrap timed out waiting for required cookies")

ErrBootstrapTimeout is returned when required_cookies never appear before the deadline. The partial cookie set may still be useful for debugging; call BootstrapSession with Headless=false to watch what the browser is doing if this keeps firing.

View Source
var ErrNoChromiumBrowser = errors.New("hermai requires a Chromium-based browser (Google Chrome, Microsoft Edge, Chromium, Brave, Arc, Opera, or Vivaldi). Install one and retry, or set HERMAI_BROWSER to the binary path")

ErrNoChromiumBrowser is surfaced when bootstrap runs on a host that has no Chromium-based browser installed anywhere we can find it. Never triggers rod's bundled-Chromium download.

Functions

This section is empty.

Types

type BootstrapRequest added in v0.1.5

type BootstrapRequest struct {
	// Site is the registry key, e.g. "tiktok.com". Used for storage path.
	Site string
	// BootstrapURL is the warm-up URL the browser navigates to first.
	BootstrapURL string
	// RequiredCookies is the list of cookie names the caller expects to see
	// set after navigation. Bootstrap keeps waiting (up to Timeout) until all
	// of them are present, so TLS-clients can replay with a valid session.
	RequiredCookies []string
	// Timeout caps the whole navigate + wait operation. Defaults to 45s.
	Timeout time.Duration
	// BrowserPath overrides the Chrome binary if set; otherwise rod picks.
	BrowserPath string
	// Headless runs Chrome without a visible window. Default true. Some
	// sites detect classic headless more aggressively — flip to false for
	// the toughest targets at the cost of a visible Chrome window.
	Headless bool
	// StorageDir is the parent directory where per-site cookie jars live.
	// Typically ~/.hermai/sessions. BootstrapSession writes to
	// {StorageDir}/{Site}/cookies.json.
	StorageDir string
	// PersistentProfileDir is the Chrome user-data-dir to reuse across
	// bootstraps. Empty defaults to ~/.hermai/chrome-profile. Reusing the
	// same dir makes the browser look like a returning user to anti-bot
	// sensors (accumulated TLS tickets, history, IndexedDB). Tests pass a
	// temp dir to isolate state.
	PersistentProfileDir string
}

BootstrapRequest describes a session bootstrap: which URL to warm, what cookies must appear, and where to save the result.

type BootstrapResult added in v0.1.5

type BootstrapResult struct {
	Site              string
	CookieCount       int
	RequiredFound     []string // which required_cookies were actually set
	RequiredMiss      []string // required_cookies that never appeared
	AkamaiUnvalidated bool     // _abck was present but never reached ~-1~ validated state
	StoragePath       string   // absolute path to the saved cookies.json
	Duration          time.Duration
}

BootstrapResult summarizes a successful bootstrap.

func BootstrapSession added in v0.1.5

func BootstrapSession(ctx context.Context, req BootstrapRequest) (*BootstrapResult, error)

BootstrapSession warms a browser page at req.BootstrapURL, waits for the cookies named in req.RequiredCookies to appear, then dumps every cookie scoped to the target domain to {StorageDir}/{Site}/cookies.json. The cookie file is the handoff surface: other Hermai CLI commands (and any Go/Python client) can read it and attach the cookies to their own HTTPS requests via a Chrome-TLS client.

This is the entry point for the `hermai session bootstrap <site>` flow. It models the same shape as browserClearance() in clearance.go but with a named site key, explicit required-cookie wait, and persistent storage.

type Catalog

type Catalog struct {
	Domain   string          `json:"domain"`
	URL      string          `json:"url"`
	Source   string          `json:"source"`
	Coverage string          `json:"coverage,omitempty"`
	Actions  []schema.Action `json:"actions"`
}

Catalog is the action-first, agent-facing surface for a URL.

func BuildCatalog

func BuildCatalog(ctx context.Context, c cache.Service, targetURL string, opts DiscoverOptions) (*Catalog, error)

BuildCatalog compiles actions from cached API schemas and the live public page.

type ClearanceResult

type ClearanceResult struct {
	Cookies map[string]string // name → value
	Source  string            // "cache", "bootstrap", or "browser"
}

ClearanceResult holds cookies obtained through bootstrap or browser clearance.

type CookieFile added in v0.1.5

type CookieFile struct {
	Site     string            `json:"site"`
	SavedAt  time.Time         `json:"saved_at"`
	Domain   string            `json:"domain"`
	Cookies  map[string]string `json:"cookies"`
	Required []string          `json:"required_cookies,omitempty"`
}

CookieFile is the persistence format for session cookies. Values are kept on the user's disk only; they never leave the local machine.

func LoadCookieFile added in v0.1.5

func LoadCookieFile(storageDir, site string) (*CookieFile, error)

LoadCookieFile reads a previously-stored cookie jar for a site. Returns nil, nil if the file doesn't exist (i.e. the site has never been bootstrapped). Intended for hermai-cli commands that want to attach a warm session to their HTTPS requests.

type DiscoverOptions

type DiscoverOptions struct {
	ProxyURL string
	Insecure bool
}

DiscoverOptions configures browserless action discovery.

type ExecutionResult

type ExecutionResult struct {
	URL         string          `json:"url"`
	Action      string          `json:"action"`
	Kind        string          `json:"kind"`
	Transport   string          `json:"transport"`
	Source      string          `json:"source"`
	Content     any             `json:"content,omitempty"`
	Data        any             `json:"data,omitempty"`
	NextActions []schema.Action `json:"next_actions,omitempty"`
	Metadata    Metadata        `json:"metadata"`
}

ExecutionResult is returned by browserless action execution.

func ExecuteAction

func ExecuteAction(ctx context.Context, targetURL string, action schema.Action, params map[string]string, opts HTTPOptions) (*ExecutionResult, error)

ExecuteAction executes one browserless action.

type HTTPOptions

type HTTPOptions struct {
	ProxyURL        string
	Insecure        bool
	Stealth         bool // use TLS+HTTP/2 fingerprinting (Chrome profile)
	HeaderOverrides map[string]string
	BrowserPath     string        // path to Chromium binary for anti-bot fallback (empty = auto-detect)
	NoBrowser       bool          // disable browser anti-bot fallback entirely
	CacheDir        string        // schema cache dir for persisting clearance cookies
	Cache           cache.Service // optional pre-built cache (takes precedence over CacheDir)
}

HTTPOptions configures browserless HTTP execution.

type Metadata

type Metadata struct {
	StatusCode     int   `json:"status_code"`
	TotalLatencyMs int64 `json:"total_latency_ms"`
}

Metadata captures browserless execution details.

Jump to

Keyboard shortcuts

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