engine

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthRequired   = errors.New("hermai: page requires authentication")
	ErrAnalysisFailed = errors.New("hermai: LLM failed to extract schema")
	ErrNoEndpoints    = errors.New("hermai: no API endpoints discovered")
)

Functions

This section is empty.

Types

type Engine

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

Engine is the core orchestrator that wires together cache, browser, analyzer, and fetcher to produce structured data from any URL.

func New

New creates a new Engine with the given service dependencies.

func (*Engine) Close

func (e *Engine) Close() error

Close releases resources held by the engine, specifically the browser. Waits for background goroutines to complete (with timeout) before closing.

func (*Engine) Fetch

func (e *Engine) Fetch(ctx context.Context, targetURL string, opts FetchOpts) (*fetcher.Result, error)

Fetch retrieves structured data from the target URL. Cache-first with priority: API schema > CSS selectors > discovery pipeline.

func (*Engine) WaitBackground

func (e *Engine) WaitBackground()

WaitBackground blocks until all background goroutines (API discovery, CSS selector analysis) have completed. Call this after Fetch returns to ensure cache is populated before process exit.

func (*Engine) WithLogger

func (e *Engine) WithLogger(l *log.Logger) *Engine

WithLogger sets the engine's logger. Must be called before Fetch.

type FetchOpts

type FetchOpts struct {
	ProxyURL            string
	Raw                 bool
	HeaderOverrides     map[string]string
	RetryOnBrokenSchema bool
	BrowserPath         string
	BrowserTimeout      time.Duration
	WaitAfterLoad       time.Duration
	NoBrowser           bool     // skip browser, use probe + LLM only
	NoCache             bool     // skip cache read/write, always fresh discovery
	Insecure            bool     // skip TLS certificate verification
	CatalogMode         bool     // continue enriching API coverage for catalog output
	Stealth             bool     // use TLS+HTTP/2 fingerprinting (set automatically from cached schema)
	Cookies             []string // name=value cookies to inject into browser session
	OnSchemaDiscovered  func(SchemaDiscovery)
}

FetchOpts configures the behavior of an engine fetch operation.

type SchemaDiscovery

type SchemaDiscovery struct {
	SchemaID   string
	SchemaType string
	Async      bool
}

SchemaDiscovery describes a brand-new schema persisted during a fetch.

Jump to

Keyboard shortcuts

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