Documentation
¶
Index ¶
- func RecoverBotChallenge(ctx RecoveryContext) (bool, error)
- func RecoverDialogAccept(ctx RecoveryContext) (bool, error)
- func RecoverNetworkSettle(ctx RecoveryContext) (bool, error)
- func RecoverStaleRef(ctx RecoveryContext) (bool, error)
- func RecoveryChain(ctx RecoveryContext, hooks []RecoveryHook) (retry bool, err error)
- type Observation
- type RecoveryContext
- type RecoveryHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecoverBotChallenge ¶
func RecoverBotChallenge(ctx RecoveryContext) (bool, error)
RecoverBotChallenge handles DataDome 403 / Cloudflare 503 bot-challenge pages. It waits up to 10s for the challenge to resolve, then signals retry.
func RecoverDialogAccept ¶
func RecoverDialogAccept(ctx RecoveryContext) (bool, error)
RecoverDialogAccept handles the case where a JS dialog is blocking the page. It accepts the dialog and signals retry=true so the op can be retried.
func RecoverNetworkSettle ¶
func RecoverNetworkSettle(ctx RecoveryContext) (bool, error)
RecoverNetworkSettle handles transient network timeouts by waiting 2s for the network to become idle, then signalling retry.
func RecoverStaleRef ¶
func RecoverStaleRef(ctx RecoveryContext) (bool, error)
RecoverStaleRef handles ErrStaleRef. Per the spec: it must NEVER silently remap refs. Instead it returns retry=false with an informative error so the agent can decide to run an explicit re-extract op.
func RecoveryChain ¶
func RecoveryChain(ctx RecoveryContext, hooks []RecoveryHook) (retry bool, err error)
RecoveryChain runs hooks in order until one returns retry=true or all are exhausted. Returns (true, nil) if a hook signalled recovery, (false, nil) if no hook could help, or (false, err) if a hook returned an error.
Types ¶
type Observation ¶
type Observation struct {
// ConsoleErrors holds runtime errors or uncaught exceptions observed during
// the op (kind=error from the Observer).
ConsoleErrors []engine.ObserverEvent `json:"console_errors,omitempty"`
// NetworkFailed holds network requests that failed (4xx/5xx or transport
// error) during the op.
NetworkFailed []engine.ObserverEvent `json:"network_failed,omitempty"`
// A11yDiff is the compact text diff of the a11y tree between before and
// after the op (FormatDiff output). Empty when there is no change.
A11yDiff string `json:"a11y_diff,omitempty"`
// Dialog is the text of a pending JS dialog detected on the page ("alert
// open: <message>"). Empty when no dialog is open.
Dialog string `json:"dialog,omitempty"`
// CaptchaHint is set when a bot-challenge page is detected
// ("datadome", "cloudflare", or a generic "captcha").
CaptchaHint string `json:"captcha_hint,omitempty"`
// URL is the current page URL at the time the observation was built.
URL string `json:"url,omitempty"`
}
Observation is the structured feedback packet returned after each agent op. All fields are omitempty so an empty observation serialises to `{}`.
func BuildObservation ¶
func BuildObservation(page *rod.Page, before, after *engine.PageSnapshot, events []engine.ObserverEvent) Observation
BuildObservation constructs an Observation from the observer events that occurred during a single op, the a11y snapshots taken before and after, and the current page state.
before may be nil (first op, no prior snapshot). after may be nil if the op failed before extraction. events is the slice from Observer.Drain().
func BuildObservationOpts ¶
func BuildObservationOpts(page *rod.Page, before, after *engine.PageSnapshot, events []engine.ObserverEvent, scanCaptcha bool) Observation
BuildObservationOpts is BuildObservation with an explicit captcha-scan flag. scanCaptcha=false skips page.HTML() so warm clicks do not pay a full document dump.
type RecoveryContext ¶
type RecoveryContext struct {
// Page is the active Rod page.
Page *rod.Page
// Err is the error returned by the original op.
Err error
// OpName is the JSONL op name for logging (e.g. "click", "navigate").
OpName string
}
RecoveryContext carries the inputs available to a RecoveryHook.
type RecoveryHook ¶
type RecoveryHook func(ctx RecoveryContext) (retry bool, err error)
RecoveryHook is a function that inspects the failure context and optionally performs a repair action.
Return values:
- retry=true: the hook resolved the issue; the caller should retry the op.
- retry=false, err=nil: the hook ran but did not fix anything; try next hook.
- retry=false, err=non-nil: the hook itself failed with a new error; abort.
func DefaultRecoveryHooks ¶
func DefaultRecoveryHooks() []RecoveryHook
DefaultRecoveryHooks returns the standard set of hooks in priority order:
- RecoverDialogAccept — dialogs block everything
- RecoverBotChallenge — captcha/CF interstitial
- RecoverNetworkSettle — transient timeout
- RecoverStaleRef — stale ref is last (never silently remaps)