stagehand

package module
v0.0.0-...-a466766 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 29 Imported by: 0

README

Stagehand is the SDK for browser agents.
Read the Docs

MIT License Discord Community

Ask DeepWiki

Stagehand Go SDK

What is Stagehand?

Stagehand is the SDK for browser agents. Playwright was built for testing, Stagehand is built for agents. Use familiar APIs, self-healing actions, and network-level security across TypeScript, Python, and Go.

Why Stagehand?

Stagehand gives browser agents an interface built for how they actually work. It combines familiar Playwright-style APIs with self-healing actions, agent-optimized page context, and native support for complex DOM structures like out-of-process iframes and closed Shadow DOMs.

Agents use fewer tokens, recover when websites change, and complete tasks more reliably. With a complete browser driver across TypeScript, Python, and Go, Stagehand delivers the flexibility of AI without sacrificing the speed, control, determinism, reliability, and observability required in production.

For the full overview, examples, and contributing guide, see the main README.

Navigation

Navigation methods return the main-document response when the browser performs a network request:

response, err := page.Goto(ctx, "https://example.com", nil)
if err != nil {
	return err
}
if response != nil {
	body, err := response.Body(ctx)
	if err != nil {
		return err
	}
	fmt.Println(response.Status(), string(body))
}

Reload, GoBack, and GoForward use the same (*Response, error) pattern. A successful navigation without a main-document network response returns (nil, nil). Response bodies and complete headers are retrieved lazily while the Stagehand session remains open.

Extraction

Define the output as a Go type and call the package-level generic function. Stagehand derives the JSON Schema from the type and returns decoded data with the usual result metadata:

type story struct {
	Title  string `json:"title"`
	Points int    `json:"points"`
}

type stories struct {
	Stories []story `json:"stories"`
}

result, err := stagehand.Extract[stories](ctx, sh, "Extract the top 5 stories", nil)
if err != nil {
	return err
}
fmt.Println(result.Data.Stories)

Fields omitted with json:",omitempty" are optional in the generated schema. Add constraints such as jsonschema:"format=uri" or jsonschema:"description=the displayed price" when the Go type alone is not specific enough.

Examples

Run the flat examples directly from the repository:

go -C packages/sdk-go run examples/act.go
go -C packages/sdk-go run examples/extract.go

Documentation

Overview

Package stagehand provides typed access to the Stagehand V4 protocol.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCDPClientClosed is returned after the CDP transport is closed.
	ErrCDPClientClosed = errors.New("stagehand CDP client is closed")
	// ErrCDPConnectionClosed is returned when the browser closes the WebSocket.
	ErrCDPConnectionClosed = errors.New("stagehand CDP connection closed")
)
View Source
var (
	// ErrNotInitialized is returned when an operation needs an initialized client.
	ErrNotInitialized = errors.New("stagehand is unavailable; create a new instance with stagehand.Create")
)
View Source
var (
	ErrRPCClientClosed = errors.New("stagehand RPC client is closed")
)

Functions

func EvaluateAs

func EvaluateAs[T any](ctx context.Context, page *Page, expression string) (T, error)

EvaluateAs decodes an Evaluate result into a caller-selected Go type.

func WebMCPOutputAs

func WebMCPOutputAs[T any](response WebMCPToolResponse) (T, error)

WebMCPOutputAs decodes a terminal response's JSON output into a caller-selected Go type.

Types

type ActInstructionValue

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

ActInstructionValue is either a natural-language instruction or an observed action.

func ActInstruction

func ActInstruction(value string) ActInstructionValue

ActInstruction constructs a natural-language act instruction.

func ObservedAction

func ObservedAction(value Action) ActInstructionValue

ObservedAction constructs an act instruction from an action returned by Observe.

func (ActInstructionValue) AsAction

func (value ActInstructionValue) AsAction() (Action, bool)

AsAction returns the observed-action variant, if present.

func (ActInstructionValue) AsInstruction

func (value ActInstructionValue) AsInstruction() (string, bool)

AsInstruction returns the instruction variant, if present.

func (ActInstructionValue) MarshalJSON

func (value ActInstructionValue) MarshalJSON() ([]byte, error)

func (*ActInstructionValue) UnmarshalJSON

func (value *ActInstructionValue) UnmarshalJSON(data []byte) error

type ActOptions

type ActOptions struct {
	// Cache corresponds to the JSON schema field "cache".
	Cache *Caching `json:"cache,omitempty,omitzero"`

	// Locators for elements and subtrees that should be excluded from action planning
	IgnoreLocators []Locator `json:"ignore_locators,omitempty,omitzero"`

	// Serializable element locator for the action target
	Locator *Locator `json:"locator,omitempty,omitzero"`

	// Complete model configuration for this call; when omitted, the initialized
	// Stagehand model is used, or Browserbase selects one automatically when no
	// initialized model exists
	Model *ModelConfig `json:"model,omitempty,omitzero"`

	// Timeout in ms for the action
	Timeout *float64 `json:"timeout,omitempty,omitzero"`

	// Variables to substitute in the action instruction. Accepts flat primitives or {
	// value, description? } objects.
	Variables Variables `json:"variables,omitempty,omitzero"`
}

func (ActOptions) MarshalJSON

func (options ActOptions) MarshalJSON() ([]byte, error)

type ActResult

type ActResult struct {
	// Data corresponds to the JSON schema field "data".
	Data ActResultData `json:"data"`

	// Metadata corresponds to the JSON schema field "metadata".
	Metadata StagehandResultMetadata `json:"metadata"`
}

type ActResultData

type ActResultData struct {
	// Description of the action that was performed
	ActionDescription string `json:"action_description"`

	// List of actions that were executed
	Actions []Action `json:"actions"`

	// Human-readable result message
	Message string `json:"message"`

	// Whether the action completed successfully
	Success bool `json:"success"`
}

type Action

type Action struct {
	// Arguments to pass to the method
	Arguments []string `json:"arguments,omitempty,omitzero"`

	// Human-readable description of the action
	Description string `json:"description"`

	// The method to execute (click, fill, etc.)
	Method *string `json:"method,omitempty,omitzero"`

	// CSS selector or XPath for the element
	Selector string `json:"selector"`
}

Action object returned by observe and used by act

type AnthropicModelName

type AnthropicModelName string

type Browser

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

Browser is a factory-created browser whose Stagehand extension is ready.

func ConnectBrowserbase

func ConnectBrowserbase(ctx context.Context, options BrowserbaseConnectOptions) (*Browser, error)

ConnectBrowserbase connects an existing Browserbase session.

func ConnectLocalBrowser

func ConnectLocalBrowser(ctx context.Context, options LocalBrowserConnectOptions) (*Browser, error)

ConnectLocalBrowser connects an existing local browser and its Stagehand extension.

func LaunchBrowserbase

func LaunchBrowserbase(ctx context.Context, options BrowserbaseLaunchOptions) (*Browser, error)

LaunchBrowserbase launches and connects a Browserbase session.

func LaunchLocalBrowser

func LaunchLocalBrowser(ctx context.Context, options *LocalBrowserLaunchOptions) (*Browser, error)

LaunchLocalBrowser launches a local browser and connects its Stagehand extension.

func (*Browser) Close

func (browser *Browser) Close(ctx context.Context) error

Close tears down the browser-owned resources once and memoizes the result. A nil context is treated as context.Background.

func (*Browser) Closed

func (browser *Browser) Closed() bool

Closed reports whether browser teardown has been requested.

func (*Browser) Context

func (browser *Browser) Context() (*BrowserContext, error)

Context returns the Stagehand context attached to this browser.

func (*Browser) Origin

func (browser *Browser) Origin() BrowserOrigin

Origin returns whether the browser was launched or connected.

func (*Browser) Provider

func (browser *Browser) Provider() BrowserProvider

Provider returns the browser provider.

func (*Browser) SessionID

func (browser *Browser) SessionID() string

SessionID returns the Browserbase session id backing this browser, or an empty string for local browsers.

type BrowserClipboard

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

BrowserClipboard exposes context clipboard operations.

func (*BrowserClipboard) Clear

func (c *BrowserClipboard) Clear(ctx context.Context, options *ClipboardOptions) error

Clear clears the clipboard.

func (*BrowserClipboard) Copy

func (c *BrowserClipboard) Copy(ctx context.Context, options *ClipboardOptions) error

Copy copies the current selection.

func (*BrowserClipboard) Cut

func (c *BrowserClipboard) Cut(ctx context.Context, options *ClipboardOptions) error

Cut cuts the current selection.

func (*BrowserClipboard) Paste

Paste pastes the clipboard into the active element.

func (*BrowserClipboard) ReadText

func (c *BrowserClipboard) ReadText(ctx context.Context, options *ClipboardOptions) (string, error)

ReadText returns the current clipboard text.

func (*BrowserClipboard) WriteText

func (c *BrowserClipboard) WriteText(ctx context.Context, text string, options *ClipboardOptions) error

WriteText replaces the current clipboard text.

type BrowserContext

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

BrowserContext exposes browser-wide protocol operations.

func (*BrowserContext) ActivePage

func (c *BrowserContext) ActivePage(ctx context.Context) (*Page, error)

ActivePage returns the active page, or nil when no page is active.

func (*BrowserContext) AddCookies

func (c *BrowserContext) AddCookies(ctx context.Context, cookies []CookieParam) error

AddCookies adds cookies to the context.

func (*BrowserContext) AddInitScript

func (c *BrowserContext) AddInitScript(ctx context.Context, source string) error

AddInitScript installs JavaScript source in every new page.

func (*BrowserContext) ClearCookies

func (c *BrowserContext) ClearCookies(ctx context.Context, options *ClearCookieOptions) error

ClearCookies clears cookies matching the generated wire options.

func (*BrowserContext) Clipboard

func (c *BrowserContext) Clipboard() *BrowserClipboard

Clipboard returns the context clipboard helper.

func (*BrowserContext) Close

func (c *BrowserContext) Close(ctx context.Context) error

Close closes the remote browser context.

func (*BrowserContext) Cookies

func (c *BrowserContext) Cookies(ctx context.Context, urls *StringList) ([]Cookie, error)

Cookies returns cookies, optionally filtered by URL.

func (*BrowserContext) GetDomainPolicy

func (c *BrowserContext) GetDomainPolicy(ctx context.Context) (*DomainPolicy, error)

GetDomainPolicy returns the current domain policy.

func (*BrowserContext) NewPage

func (c *BrowserContext) NewPage(ctx context.Context, url ...string) (*Page, error)

NewPage creates a page, optionally navigating it to the provided URL.

func (*BrowserContext) Pages

func (c *BrowserContext) Pages(ctx context.Context) ([]*Page, error)

Pages lists every page in the context.

func (*BrowserContext) SetActivePage

func (c *BrowserContext) SetActivePage(ctx context.Context, page *Page) error

SetActivePage makes page the context's active page.

func (*BrowserContext) SetDomainPolicy

func (c *BrowserContext) SetDomainPolicy(ctx context.Context, policy *DomainPolicy) error

SetDomainPolicy changes the current domain policy.

func (*BrowserContext) SetExtraHTTPHeaders

func (c *BrowserContext) SetExtraHTTPHeaders(
	ctx context.Context,
	headers ContextSetExtraHTTPHeadersParamsHeaders,
) error

SetExtraHTTPHeaders sets context-wide request headers.

type BrowserOrigin

type BrowserOrigin string

BrowserOrigin identifies whether a browser was launched or connected.

const (
	// BrowserOriginLaunched identifies a browser launched by this SDK.
	BrowserOriginLaunched BrowserOrigin = "launched"
	// BrowserOriginConnected identifies an existing browser connection.
	BrowserOriginConnected BrowserOrigin = "connected"
)

type BrowserProvider

type BrowserProvider string

BrowserProvider identifies the service providing a browser.

const (
	// BrowserProviderLocal identifies a locally running browser.
	BrowserProviderLocal BrowserProvider = "local"
	// BrowserProviderBrowserbase identifies a Browserbase browser.
	BrowserProviderBrowserbase BrowserProvider = "browserbase"
)

type BrowserSessionMetadata

type BrowserSessionMetadata struct {
	// Region corresponds to the JSON schema field "region".
	Region *BrowserbaseRegion `json:"region,omitempty,omitzero"`

	// SessionID corresponds to the JSON schema field "session_id".
	SessionID string `json:"session_id"`
}

type BrowserbaseAPIError

type BrowserbaseAPIError struct {
	Method     string
	Path       string
	StatusCode int
	RequestID  string
	Body       string
}

BrowserbaseAPIError is a non-successful response from the Browserbase API.

func (*BrowserbaseAPIError) Error

func (err *BrowserbaseAPIError) Error() string

type BrowserbaseBrowserSettings

type BrowserbaseBrowserSettings struct {
	// AdvancedStealth corresponds to the JSON schema field "advanced_stealth".
	AdvancedStealth *bool `json:"advanced_stealth,omitempty,omitzero"`

	// BlockAds corresponds to the JSON schema field "block_ads".
	BlockAds *bool `json:"block_ads,omitempty,omitzero"`

	// CaptchaImageSelector corresponds to the JSON schema field
	// "captcha_image_selector".
	CaptchaImageSelector *string `json:"captcha_image_selector,omitempty,omitzero"`

	// CaptchaInputSelector corresponds to the JSON schema field
	// "captcha_input_selector".
	CaptchaInputSelector *string `json:"captcha_input_selector,omitempty,omitzero"`

	// Context corresponds to the JSON schema field "context".
	Context *BrowserbaseContext `json:"context,omitempty,omitzero"`

	// ExtensionID corresponds to the JSON schema field "extension_id".
	ExtensionID *string `json:"extension_id,omitempty,omitzero"`

	// Fingerprint corresponds to the JSON schema field "fingerprint".
	Fingerprint *BrowserbaseFingerprint `json:"fingerprint,omitempty,omitzero"`

	// LogSession corresponds to the JSON schema field "log_session".
	LogSession *bool `json:"log_session,omitempty,omitzero"`

	// OS corresponds to the JSON schema field "os".
	OS *BrowserbaseBrowserSettingsOS `json:"os,omitempty,omitzero"`

	// RecordSession corresponds to the JSON schema field "record_session".
	RecordSession *bool `json:"record_session,omitempty,omitzero"`

	// SolveCaptchas corresponds to the JSON schema field "solve_captchas".
	SolveCaptchas *bool `json:"solve_captchas,omitempty,omitzero"`

	// Verified corresponds to the JSON schema field "verified".
	Verified *bool `json:"verified,omitempty,omitzero"`

	// Viewport corresponds to the JSON schema field "viewport".
	Viewport *BrowserbaseViewport `json:"viewport,omitempty,omitzero"`
}

type BrowserbaseBrowserSettingsOS

type BrowserbaseBrowserSettingsOS string
const BrowserbaseBrowserSettingsOSLinux BrowserbaseBrowserSettingsOS = "linux"
const BrowserbaseBrowserSettingsOSMac BrowserbaseBrowserSettingsOS = "mac"
const BrowserbaseBrowserSettingsOSMobile BrowserbaseBrowserSettingsOS = "mobile"
const BrowserbaseBrowserSettingsOSTablet BrowserbaseBrowserSettingsOS = "tablet"
const BrowserbaseBrowserSettingsOSWindows BrowserbaseBrowserSettingsOS = "windows"

type BrowserbaseConnectOptions

type BrowserbaseConnectOptions struct {
	APIKey      string
	BaseURL     string
	SessionID   string
	ExtensionID string
}

BrowserbaseConnectOptions configures a connection to an existing Browserbase session.

type BrowserbaseContext

type BrowserbaseContext struct {
	// ID corresponds to the JSON schema field "id".
	ID string `json:"id"`

	// Persist corresponds to the JSON schema field "persist".
	Persist *bool `json:"persist,omitempty,omitzero"`
}

type BrowserbaseFingerprint

type BrowserbaseFingerprint struct {
	// Browsers corresponds to the JSON schema field "browsers".
	Browsers []BrowserbaseFingerprintBrowsersElem `json:"browsers,omitempty,omitzero"`

	// Devices corresponds to the JSON schema field "devices".
	Devices []BrowserbaseFingerprintDevicesElem `json:"devices,omitempty,omitzero"`

	// HTTPVersion corresponds to the JSON schema field "http_version".
	HTTPVersion *BrowserbaseFingerprintHTTPVersion `json:"http_version,omitempty,omitzero"`

	// Locales corresponds to the JSON schema field "locales".
	Locales []string `json:"locales,omitempty,omitzero"`

	// OperatingSystems corresponds to the JSON schema field "operating_systems".
	OperatingSystems []BrowserbaseFingerprintOperatingSystemsElem `json:"operating_systems,omitempty,omitzero"`

	// Screen corresponds to the JSON schema field "screen".
	Screen *BrowserbaseFingerprintScreen `json:"screen,omitempty,omitzero"`
}

type BrowserbaseFingerprintBrowsersElem

type BrowserbaseFingerprintBrowsersElem string
const BrowserbaseFingerprintBrowsersElemChrome BrowserbaseFingerprintBrowsersElem = "chrome"
const BrowserbaseFingerprintBrowsersElemEdge BrowserbaseFingerprintBrowsersElem = "edge"
const BrowserbaseFingerprintBrowsersElemFirefox BrowserbaseFingerprintBrowsersElem = "firefox"
const BrowserbaseFingerprintBrowsersElemSafari BrowserbaseFingerprintBrowsersElem = "safari"

type BrowserbaseFingerprintDevicesElem

type BrowserbaseFingerprintDevicesElem string
const BrowserbaseFingerprintDevicesElemDesktop BrowserbaseFingerprintDevicesElem = "desktop"
const BrowserbaseFingerprintDevicesElemMobile BrowserbaseFingerprintDevicesElem = "mobile"

type BrowserbaseFingerprintHTTPVersion

type BrowserbaseFingerprintHTTPVersion string
const BrowserbaseFingerprintHTTPVersionA1 BrowserbaseFingerprintHTTPVersion = "1"
const BrowserbaseFingerprintHTTPVersionA2 BrowserbaseFingerprintHTTPVersion = "2"

type BrowserbaseFingerprintOperatingSystemsElem

type BrowserbaseFingerprintOperatingSystemsElem string
const BrowserbaseFingerprintOperatingSystemsElemAndroid BrowserbaseFingerprintOperatingSystemsElem = "android"
const BrowserbaseFingerprintOperatingSystemsElemIOS BrowserbaseFingerprintOperatingSystemsElem = "ios"
const BrowserbaseFingerprintOperatingSystemsElemLinux BrowserbaseFingerprintOperatingSystemsElem = "linux"
const BrowserbaseFingerprintOperatingSystemsElemMacos BrowserbaseFingerprintOperatingSystemsElem = "macos"
const BrowserbaseFingerprintOperatingSystemsElemWindows BrowserbaseFingerprintOperatingSystemsElem = "windows"

type BrowserbaseFingerprintScreen

type BrowserbaseFingerprintScreen struct {
	// MaxHeight corresponds to the JSON schema field "max_height".
	MaxHeight *float64 `json:"max_height,omitempty,omitzero"`

	// MaxWidth corresponds to the JSON schema field "max_width".
	MaxWidth *float64 `json:"max_width,omitempty,omitzero"`

	// MinHeight corresponds to the JSON schema field "min_height".
	MinHeight *float64 `json:"min_height,omitempty,omitzero"`

	// MinWidth corresponds to the JSON schema field "min_width".
	MinWidth *float64 `json:"min_width,omitempty,omitzero"`
}

type BrowserbaseLaunchOptions

type BrowserbaseLaunchOptions struct {
	APIKey          string
	BaseURL         string
	BrowserSettings *BrowserbaseBrowserSettings
	ExtensionID     *string
	KeepAlive       *bool
	Proxies         *BrowserbaseProxies
	Region          *BrowserbaseRegion
	Timeout         *float64
	UserMetadata    map[string]json.RawMessage
}

BrowserbaseLaunchOptions configures a newly launched Browserbase session.

type BrowserbaseProxies

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

BrowserbaseProxies is either the Browserbase proxy toggle or an explicit proxy configuration list.

func BrowserbaseProxyEnabled

func BrowserbaseProxyEnabled(enabled bool) BrowserbaseProxies

BrowserbaseProxyEnabled constructs the boolean proxy form.

func BrowserbaseProxyList

func BrowserbaseProxyList(values ...ProxyConfig) BrowserbaseProxies

BrowserbaseProxyList constructs the explicit proxy-list form.

func (BrowserbaseProxies) AsEnabled

func (value BrowserbaseProxies) AsEnabled() (bool, bool)

AsEnabled returns the boolean variant, if present.

func (BrowserbaseProxies) AsList

func (value BrowserbaseProxies) AsList() ([]ProxyConfig, bool)

AsList returns a copy of the proxy-list variant, if present.

func (BrowserbaseProxies) MarshalJSON

func (value BrowserbaseProxies) MarshalJSON() ([]byte, error)

func (*BrowserbaseProxies) UnmarshalJSON

func (value *BrowserbaseProxies) UnmarshalJSON(data []byte) error

type BrowserbaseProxyConfig

type BrowserbaseProxyConfig struct {
	// DomainPattern corresponds to the JSON schema field "domain_pattern".
	DomainPattern *string `json:"domain_pattern,omitempty,omitzero"`

	// Geolocation corresponds to the JSON schema field "geolocation".
	Geolocation *BrowserbaseProxyGeolocation `json:"geolocation,omitempty,omitzero"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type BrowserbaseProxyGeolocation

type BrowserbaseProxyGeolocation struct {
	// City corresponds to the JSON schema field "city".
	City *string `json:"city,omitempty,omitzero"`

	// Country corresponds to the JSON schema field "country".
	Country string `json:"country"`

	// State corresponds to the JSON schema field "state".
	State *string `json:"state,omitempty,omitzero"`
}

type BrowserbaseRegion

type BrowserbaseRegion string
const BrowserbaseRegionAPSoutheast1 BrowserbaseRegion = "ap-southeast-1"
const BrowserbaseRegionEUCentral1 BrowserbaseRegion = "eu-central-1"
const BrowserbaseRegionUSEast1 BrowserbaseRegion = "us-east-1"
const BrowserbaseRegionUSWest2 BrowserbaseRegion = "us-west-2"

type BrowserbaseSessionCreateParams

type BrowserbaseSessionCreateParams struct {
	// BrowserSettings corresponds to the JSON schema field "browser_settings".
	BrowserSettings *BrowserbaseBrowserSettings `json:"browser_settings,omitempty,omitzero"`

	// ExtensionID corresponds to the JSON schema field "extension_id".
	ExtensionID *string `json:"extension_id,omitempty,omitzero"`

	// KeepAlive corresponds to the JSON schema field "keep_alive".
	KeepAlive *bool `json:"keep_alive,omitempty,omitzero"`

	// Proxies corresponds to the JSON schema field "proxies".
	Proxies *BrowserbaseProxies `json:"proxies,omitempty,omitzero"`

	// Region corresponds to the JSON schema field "region".
	Region *BrowserbaseRegion `json:"region,omitempty,omitzero"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *float64 `json:"timeout,omitempty,omitzero"`

	// UserMetadata corresponds to the JSON schema field "user_metadata".
	UserMetadata map[string]json.RawMessage `json:"user_metadata,omitempty,omitzero"`
}

type BrowserbaseViewport

type BrowserbaseViewport struct {
	// Height corresponds to the JSON schema field "height".
	Height *float64 `json:"height,omitempty,omitzero"`

	// Width corresponds to the JSON schema field "width".
	Width *float64 `json:"width,omitempty,omitzero"`
}

type CDPSubscription

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

CDPSubscription is a page-scoped console event listener registration.

func (*CDPSubscription) Close

func (s *CDPSubscription) Close(ctx context.Context) error

Close removes the listener locally and from the Stagehand runtime.

type CacheMetadata

type CacheMetadata struct {
	// Times this cache key has been seen, including this request; compare with
	// threshold to see how close the key is to being served
	Count *int `json:"count,omitempty,omitzero"`

	// Why the cache did not serve this request; misses only. Reported by the server:
	// "not_found", "threshold", "empty_array", "timeout", "error", "bypass",
	// "screenshot", "not_enabled", "no_cache_key". Reported locally: "read_failed"
	// (the cache request itself failed) and "replay_failed" (a cached value was found
	// but could not be applied)
	MissReason *string `json:"miss_reason,omitempty,omitzero"`

	// Whether server-side caching served this result, computed it, or was not
	// consulted
	Status CacheStatus `json:"status"`

	// Hit-count threshold in effect for this key
	Threshold *int `json:"threshold,omitempty,omitzero"`

	// LLM tokens avoided by serving this request from cache; hits only
	TokensSaved *CacheTokenSavings `json:"tokens_saved,omitempty,omitzero"`
}

type CacheOptions

type CacheOptions struct {
	Threshold *int `json:"threshold,omitempty"`
}

CacheOptions enables caching with an optional positive hit-count threshold.

type CacheStatus

type CacheStatus string
const CacheStatusDISABLED CacheStatus = "DISABLED"
const CacheStatusHIT CacheStatus = "HIT"
const CacheStatusMISS CacheStatus = "MISS"

type CacheTokenSavings

type CacheTokenSavings struct {
	// InputTokens corresponds to the JSON schema field "input_tokens".
	InputTokens int `json:"input_tokens,omitempty,omitzero"`

	// OutputTokens corresponds to the JSON schema field "output_tokens".
	OutputTokens int `json:"output_tokens,omitempty,omitzero"`

	// TotalTokens corresponds to the JSON schema field "total_tokens".
	TotalTokens int `json:"total_tokens,omitempty,omitzero"`
}

type Caching

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

Caching is either a boolean cache toggle or a cache options object.

func CacheEnabled

func CacheEnabled(enabled bool) Caching

CacheEnabled constructs a boolean caching configuration.

func CacheWithOptions

func CacheWithOptions(options CacheOptions) Caching

CacheWithOptions constructs an object caching configuration.

func CacheWithThreshold

func CacheWithThreshold(threshold int) Caching

CacheWithThreshold enables caching with the given positive hit-count threshold.

func (Caching) AsBool

func (value Caching) AsBool() (bool, bool)

AsBool returns the boolean variant, if present.

func (Caching) AsOptions

func (value Caching) AsOptions() (CacheOptions, bool)

AsOptions returns the options variant, if present.

func (Caching) MarshalJSON

func (value Caching) MarshalJSON() ([]byte, error)

func (*Caching) UnmarshalJSON

func (value *Caching) UnmarshalJSON(data []byte) error

type CallbackBatchOptions

type CallbackBatchOptions struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID *string `json:"page_id,omitempty,omitzero"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout int `json:"timeout,omitempty,omitzero"`
}

type CallbackBatchParams

type CallbackBatchParams struct {
	// CallbackSource corresponds to the JSON schema field "callback_source".
	CallbackSource string `json:"callback_source"`

	// Input corresponds to the JSON schema field "input".
	Input json.RawMessage `json:"input,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options CallbackBatchOptions `json:"options"`
}

type CallbackBatchResult

type CallbackBatchResult struct {
	// Value corresponds to the JSON schema field "value".
	Value json.RawMessage `json:"value,omitempty,omitzero"`
}

type CerebrasModelName

type CerebrasModelName string

type ClearCookieOptions

type ClearCookieOptions struct {
	// Domain corresponds to the JSON schema field "domain".
	Domain *CookieFilter `json:"domain,omitempty,omitzero"`

	// Name corresponds to the JSON schema field "name".
	Name *CookieFilter `json:"name,omitempty,omitzero"`

	// Path corresponds to the JSON schema field "path".
	Path *CookieFilter `json:"path,omitempty,omitzero"`
}

type ClientModelReference

type ClientModelReference struct {
	// Source corresponds to the JSON schema field "source".
	Source string `json:"source"`
}

type ClipboardOptions

type ClipboardOptions struct {
	Page *Page
}

ClipboardOptions optionally scopes a clipboard operation to one page.

type ClipboardPasteOptions

type ClipboardPasteOptions struct {
	Page     *Page
	Shortcut *ContextClipboardPasteParamsShortcut
}

ClipboardPasteOptions optionally scopes paste and selects its shortcut.

type ContextActivePageResult

type ContextActivePageResult = *PageRef

ContextActivePageResult is either the active page or JSON null.

type ContextAddCookiesParams

type ContextAddCookiesParams struct {
	// Cookies corresponds to the JSON schema field "cookies".
	Cookies []CookieParam `json:"cookies"`
}

type ContextAddInitScriptParams

type ContextAddInitScriptParams struct {
	// Source corresponds to the JSON schema field "source".
	Source string `json:"source"`
}

type ContextClearCookiesParams

type ContextClearCookiesParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *ClearCookieOptions `json:"options,omitempty,omitzero"`
}

type ContextClipboardPasteParams

type ContextClipboardPasteParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID *string `json:"page_id,omitempty,omitzero"`

	// Shortcut corresponds to the JSON schema field "shortcut".
	Shortcut *ContextClipboardPasteParamsShortcut `json:"shortcut,omitempty,omitzero"`
}

type ContextClipboardPasteParamsShortcut

type ContextClipboardPasteParamsShortcut string
const ContextClipboardPasteParamsShortcutControlOrMetaV ContextClipboardPasteParamsShortcut = "ControlOrMeta+V"
const ContextClipboardPasteParamsShortcutControlV ContextClipboardPasteParamsShortcut = "Control+V"
const ContextClipboardPasteParamsShortcutMetaV ContextClipboardPasteParamsShortcut = "Meta+V"

type ContextClipboardReadTextResult

type ContextClipboardReadTextResult string

type ContextClipboardTarget

type ContextClipboardTarget struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID *string `json:"page_id,omitempty,omitzero"`
}

type ContextClipboardWriteTextParams

type ContextClipboardWriteTextParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID *string `json:"page_id,omitempty,omitzero"`

	// Text corresponds to the JSON schema field "text".
	Text string `json:"text"`
}

type ContextCloseResult

type ContextCloseResult struct {
	// Closed corresponds to the JSON schema field "closed".
	Closed bool `json:"closed"`
}

type ContextCookiesParams

type ContextCookiesParams struct {
	// Urls corresponds to the JSON schema field "urls".
	Urls *StringList `json:"urls,omitempty,omitzero"`
}

type ContextCookiesResult

type ContextCookiesResult []Cookie

type ContextGetDomainPolicyResult

type ContextGetDomainPolicyResult = *DomainPolicy

ContextGetDomainPolicyResult is either the current domain policy or JSON null.

type ContextNewPageParams

type ContextNewPageParams struct {
	// URL corresponds to the JSON schema field "url".
	URL *string `json:"url,omitempty,omitzero"`
}

type ContextPagesResult

type ContextPagesResult []PageRef

type ContextSetActivePageParams

type ContextSetActivePageParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type ContextSetDomainPolicyParams

type ContextSetDomainPolicyParams struct {
	// Policy corresponds to the JSON schema field "policy".
	Policy *DomainPolicy `json:"policy"`
}

type ContextSetExtraHTTPHeadersParams

type ContextSetExtraHTTPHeadersParams struct {
	// Headers corresponds to the JSON schema field "headers".
	Headers ContextSetExtraHTTPHeadersParamsHeaders `json:"headers"`
}

type ContextSetExtraHTTPHeadersParamsHeaders

type ContextSetExtraHTTPHeadersParamsHeaders map[string]string

type ContextVoidResult

type ContextVoidResult struct {
	// Ok corresponds to the JSON schema field "ok".
	Ok bool `json:"ok"`
}
type Cookie struct {
	// Domain corresponds to the JSON schema field "domain".
	Domain string `json:"domain"`

	// Expires corresponds to the JSON schema field "expires".
	Expires float64 `json:"expires"`

	// HTTPOnly corresponds to the JSON schema field "http_only".
	HTTPOnly bool `json:"http_only"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Path corresponds to the JSON schema field "path".
	Path string `json:"path"`

	// SameSite corresponds to the JSON schema field "same_site".
	SameSite CookieSameSite `json:"same_site"`

	// Secure corresponds to the JSON schema field "secure".
	Secure bool `json:"secure"`

	// Value corresponds to the JSON schema field "value".
	Value string `json:"value"`
}

type CookieFilter

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

CookieFilter is either an exact string or a regular-expression object.

func ExactCookie

func ExactCookie(value string) CookieFilter

ExactCookie constructs an exact string cookie filter.

func RegexCookie

func RegexCookie(value CookieRegex) CookieFilter

RegexCookie constructs a regular-expression cookie filter.

func (CookieFilter) AsExact

func (value CookieFilter) AsExact() (string, bool)

AsExact returns the exact string variant, if present.

func (CookieFilter) AsRegex

func (value CookieFilter) AsRegex() (CookieRegex, bool)

AsRegex returns the regular-expression variant, if present.

func (CookieFilter) MarshalJSON

func (value CookieFilter) MarshalJSON() ([]byte, error)

func (*CookieFilter) UnmarshalJSON

func (value *CookieFilter) UnmarshalJSON(data []byte) error

type CookieParam

type CookieParam struct {
	// Domain corresponds to the JSON schema field "domain".
	Domain *string `json:"domain,omitempty,omitzero"`

	// Expires corresponds to the JSON schema field "expires".
	Expires *float64 `json:"expires,omitempty,omitzero"`

	// HTTPOnly corresponds to the JSON schema field "http_only".
	HTTPOnly *bool `json:"http_only,omitempty,omitzero"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Path corresponds to the JSON schema field "path".
	Path *string `json:"path,omitempty,omitzero"`

	// SameSite corresponds to the JSON schema field "same_site".
	SameSite *CookieParamSameSite `json:"same_site,omitempty,omitzero"`

	// Secure corresponds to the JSON schema field "secure".
	Secure *bool `json:"secure,omitempty,omitzero"`

	// URL corresponds to the JSON schema field "url".
	URL *string `json:"url,omitempty,omitzero"`

	// Value corresponds to the JSON schema field "value".
	Value string `json:"value"`
}

type CookieParamSameSite

type CookieParamSameSite string
const CookieParamSameSiteLax CookieParamSameSite = "Lax"
const CookieParamSameSiteNone CookieParamSameSite = "None"
const CookieParamSameSiteStrict CookieParamSameSite = "Strict"

type CookieRegex

type CookieRegex struct {
	// Flags corresponds to the JSON schema field "flags".
	Flags *string `json:"flags,omitempty,omitzero"`

	// Source corresponds to the JSON schema field "source".
	Source string `json:"source"`
}

type CookieSameSite

type CookieSameSite string
const CookieSameSiteLax CookieSameSite = "Lax"
const CookieSameSiteNone CookieSameSite = "None"
const CookieSameSiteStrict CookieSameSite = "Strict"

type CreateOptions

type CreateOptions struct {
	Browser            *Browser
	APIKey             *string
	APIURL             *string
	Cache              *Caching
	DOMSettleTimeoutMs *int
	Model              *ModelConfig
	Generate           LLMGenerateFunc
	Logging            *StagehandClientLoggingConfig
	SelfHeal           *bool
	SystemPrompt       *string
	Telemetry          TelemetryConfig
}

CreateOptions configures Stagehand over a factory-created Browser handle.

type DescribedVariableValue

type DescribedVariableValue struct {
	// Description corresponds to the JSON schema field "description".
	Description *string `json:"description,omitempty,omitzero"`

	// Value corresponds to the JSON schema field "value".
	Value VariablePrimitive `json:"value"`
}

type DomainPolicy

type DomainPolicy struct {
	// AllowedDomains corresponds to the JSON schema field "allowed_domains".
	AllowedDomains []string `json:"allowed_domains,omitempty,omitzero"`

	// BlockedDomains corresponds to the JSON schema field "blocked_domains".
	BlockedDomains []string `json:"blocked_domains,omitempty,omitzero"`
}

type EmptyParams

type EmptyParams struct{}

EmptyParams is the request body for methods that take no parameters.

type ExperimentalBatchOptions

type ExperimentalBatchOptions struct {
	Timeout time.Duration
	Page    *Page
}

ExperimentalBatchOptions controls a trusted JavaScript callback running in the extension worker.

type ExternalProxyConfig

type ExternalProxyConfig struct {
	// DomainPattern corresponds to the JSON schema field "domain_pattern".
	DomainPattern *string `json:"domain_pattern,omitempty,omitzero"`

	// Password corresponds to the JSON schema field "password".
	Password *string `json:"password,omitempty,omitzero"`

	// Server corresponds to the JSON schema field "server".
	Server string `json:"server"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`

	// Username corresponds to the JSON schema field "username".
	Username *string `json:"username,omitempty,omitzero"`
}

type ExtractOptions

type ExtractOptions struct {
	// Cache corresponds to the JSON schema field "cache".
	Cache *Caching `json:"cache,omitempty,omitzero"`

	// Locators for elements and subtrees that should be excluded from extraction
	IgnoreLocators []Locator `json:"ignore_locators,omitempty,omitzero"`

	// Locator that scopes extraction to a specific element
	Locator *Locator `json:"locator,omitempty,omitzero"`

	// Complete model configuration for this call; when omitted, the initialized
	// Stagehand model is used, or Browserbase selects one automatically when no
	// initialized model exists
	Model *ModelConfig `json:"model,omitempty,omitzero"`

	// When true, include a screenshot of the current viewport in the extraction LLM
	// call. Defaults to false.
	Screenshot *bool `json:"screenshot,omitempty,omitzero"`

	// Timeout in ms for the extraction
	Timeout *float64 `json:"timeout,omitempty,omitzero"`
}

func (ExtractOptions) MarshalJSON

func (options ExtractOptions) MarshalJSON() ([]byte, error)

type ExtractResult

type ExtractResult struct {
	// Data corresponds to the JSON schema field "data".
	Data json.RawMessage `json:"data"`

	// Metadata corresponds to the JSON schema field "metadata".
	Metadata StagehandResultMetadata `json:"metadata"`
}

type FileInput

type FileInput struct {
	Path         string
	Name         string
	MIMEType     string
	Buffer       []byte
	LastModified *int64
}

FileInput describes either a local file path or an in-memory file payload. Use FilePath or FileData to construct one.

func FileData

func FileData(name string, mimeType string, buffer []byte) FileInput

FileData creates an in-memory upload payload.

func FilePath

func FilePath(path string) FileInput

FilePath creates an upload from a path on the SDK caller's filesystem.

type GoogleModelName

type GoogleModelName string

type GroqModelName

type GroqModelName string

type IgnoreDefaultArgs

type IgnoreDefaultArgs struct {
	All  bool
	Args []string
}

IgnoreDefaultArgs selects which of Stagehand's default Chrome arguments to omit. All takes precedence over Args.

type ImplementationInfo

type ImplementationInfo struct {
	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Version corresponds to the JSON schema field "version".
	Version string `json:"version"`
}

type InputFilePayload

type InputFilePayload struct {
	// Data corresponds to the JSON schema field "data".
	Data string `json:"data"`

	// LastModified corresponds to the JSON schema field "last_modified".
	LastModified *int64 `json:"last_modified,omitempty,omitzero"`

	// MIMEType corresponds to the JSON schema field "mime_type".
	MIMEType *string `json:"mime_type,omitempty,omitzero"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`
}

type LLMAnnotations

type LLMAnnotations struct {
	// Audience corresponds to the JSON schema field "audience".
	Audience []LLMRole `json:"audience,omitempty,omitzero"`

	// LastModified corresponds to the JSON schema field "last_modified".
	LastModified *string `json:"last_modified,omitempty,omitzero"`

	// Priority corresponds to the JSON schema field "priority".
	Priority *float64 `json:"priority,omitempty,omitzero"`
}

type LLMClientTool

type LLMClientTool struct {
	// Annotations corresponds to the JSON schema field "annotations".
	Annotations *LLMToolAnnotations `json:"annotations,omitempty,omitzero"`

	// Description corresponds to the JSON schema field "description".
	Description *string `json:"description,omitempty,omitzero"`

	// Execution corresponds to the JSON schema field "execution".
	Execution *LLMToolExecution `json:"execution,omitempty,omitzero"`

	// Icons corresponds to the JSON schema field "icons".
	Icons []LLMToolIcon `json:"icons,omitempty,omitzero"`

	// InputSchema corresponds to the JSON schema field "input_schema".
	InputSchema LLMToolJSON `json:"input_schema"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// OutputSchema corresponds to the JSON schema field "output_schema".
	OutputSchema *LLMToolJSON `json:"output_schema,omitempty,omitzero"`

	// Title corresponds to the JSON schema field "title".
	Title *string `json:"title,omitempty,omitzero"`
}

type LLMGenerateFunc

type LLMGenerateFunc func(context.Context, LLMGenerateParams) (LLMGenerateResult, error)

LLMGenerateFunc lets the service worker delegate generation to caller code.

type LLMGenerateParams

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

LLMGenerateParams is either a structured-output or message-output request.

func MessageGenerateParams

func MessageGenerateParams(value LLMMessageGenerateParams) LLMGenerateParams

MessageGenerateParams constructs a message-output request and sets the optional response-format discriminator when present.

func StructuredGenerateParams

func StructuredGenerateParams(value LLMStructuredGenerateParams) LLMGenerateParams

StructuredGenerateParams constructs a structured-output request and sets the response-format discriminator.

func (LLMGenerateParams) AsMessage

func (value LLMGenerateParams) AsMessage() (LLMMessageGenerateParams, bool)

AsMessage returns the message-output variant, if present.

func (LLMGenerateParams) AsStructured

func (value LLMGenerateParams) AsStructured() (LLMStructuredGenerateParams, bool)

AsStructured returns the structured-output variant, if present.

func (LLMGenerateParams) MarshalJSON

func (value LLMGenerateParams) MarshalJSON() ([]byte, error)

func (*LLMGenerateParams) UnmarshalJSON

func (value *LLMGenerateParams) UnmarshalJSON(data []byte) error

type LLMGenerateResult

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

LLMGenerateResult is either a message or structured-output result.

func MessageGenerateResult

func MessageGenerateResult(value LLMMessageGenerateResult) LLMGenerateResult

MessageGenerateResult constructs a message result and sets its discriminator.

func StructuredGenerateResult

func StructuredGenerateResult(value LLMStructuredGenerateResult) LLMGenerateResult

StructuredGenerateResult constructs a structured result and sets its discriminator.

func (LLMGenerateResult) AsMessage

func (value LLMGenerateResult) AsMessage() (LLMMessageGenerateResult, bool)

AsMessage returns the message variant, if present.

func (LLMGenerateResult) AsStructured

func (value LLMGenerateResult) AsStructured() (LLMStructuredGenerateResult, bool)

AsStructured returns the structured variant, if present.

func (LLMGenerateResult) MarshalJSON

func (value LLMGenerateResult) MarshalJSON() ([]byte, error)

func (*LLMGenerateResult) UnmarshalJSON

func (value *LLMGenerateResult) UnmarshalJSON(data []byte) error

type LLMImageContent

type LLMImageContent struct {
	// Annotations corresponds to the JSON schema field "annotations".
	Annotations *LLMAnnotations `json:"annotations,omitempty,omitzero"`

	// Data corresponds to the JSON schema field "data".
	Data string `json:"data"`

	// MIMEType corresponds to the JSON schema field "mime_type".
	MIMEType string `json:"mime_type"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMJSONSchemaResponseFormat

type LLMJSONSchemaResponseFormat struct {
	// Description corresponds to the JSON schema field "description".
	Description *string `json:"description,omitempty,omitzero"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Schema corresponds to the JSON schema field "schema".
	Schema json.RawMessage `json:"schema"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMMessage

type LLMMessage struct {
	// Content corresponds to the JSON schema field "content".
	Content LLMMessageContent `json:"content"`

	// Role corresponds to the JSON schema field "role".
	Role LLMRole `json:"role"`
}

type LLMMessageContent

type LLMMessageContent []LLMMessageContentBlock

LLMMessageContent accepts a single JSON content block or an array of blocks and always marshals as an array.

func (LLMMessageContent) MarshalJSON

func (content LLMMessageContent) MarshalJSON() ([]byte, error)

func (*LLMMessageContent) UnmarshalJSON

func (content *LLMMessageContent) UnmarshalJSON(data []byte) error

type LLMMessageContentBlock

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

LLMMessageContentBlock is one text, image, tool-use, or tool-result block.

func ImageContentBlock

func ImageContentBlock(value LLMImageContent) LLMMessageContentBlock

ImageContentBlock constructs an image content block and sets its discriminator.

func TextContentBlock

func TextContentBlock(value LLMTextContent) LLMMessageContentBlock

TextContentBlock constructs a text content block and sets its discriminator.

func ToolResultContentBlock

func ToolResultContentBlock(value LLMToolResultContent) LLMMessageContentBlock

ToolResultContentBlock constructs a tool-result block and sets its discriminator.

func ToolUseContentBlock

func ToolUseContentBlock(value LLMToolUseContent) LLMMessageContentBlock

ToolUseContentBlock constructs a tool-use block and sets its discriminator.

func (LLMMessageContentBlock) AsImage

func (value LLMMessageContentBlock) AsImage() (LLMImageContent, bool)

AsImage returns the image variant, if present.

func (LLMMessageContentBlock) AsText

func (value LLMMessageContentBlock) AsText() (LLMTextContent, bool)

AsText returns the text variant, if present.

func (LLMMessageContentBlock) AsToolResult

func (value LLMMessageContentBlock) AsToolResult() (LLMToolResultContent, bool)

AsToolResult returns the tool-result variant, if present.

func (LLMMessageContentBlock) AsToolUse

func (value LLMMessageContentBlock) AsToolUse() (LLMToolUseContent, bool)

AsToolUse returns the tool-use variant, if present.

func (LLMMessageContentBlock) MarshalJSON

func (value LLMMessageContentBlock) MarshalJSON() ([]byte, error)

func (*LLMMessageContentBlock) UnmarshalJSON

func (value *LLMMessageContentBlock) UnmarshalJSON(data []byte) error

type LLMMessageGenerateParams

type LLMMessageGenerateParams struct {
	// Messages corresponds to the JSON schema field "messages".
	Messages []LLMMessage `json:"messages"`

	// ResponseFormat corresponds to the JSON schema field "response_format".
	ResponseFormat *LLMTextResponseFormat `json:"response_format,omitempty,omitzero"`

	// StopSequences corresponds to the JSON schema field "stop_sequences".
	StopSequences []string `json:"stop_sequences,omitempty,omitzero"`

	// SystemPrompt corresponds to the JSON schema field "system_prompt".
	SystemPrompt *string `json:"system_prompt,omitempty,omitzero"`

	// Temperature corresponds to the JSON schema field "temperature".
	Temperature *float64 `json:"temperature,omitempty,omitzero"`

	// ToolChoice corresponds to the JSON schema field "tool_choice".
	ToolChoice *LLMToolChoice `json:"tool_choice,omitempty,omitzero"`

	// Tools corresponds to the JSON schema field "tools".
	Tools []LLMClientTool `json:"tools,omitempty,omitzero"`
}

type LLMMessageGenerateResult

type LLMMessageGenerateResult struct {
	Role         LLMRole           `json:"role"`
	Content      LLMMessageContent `json:"content"`
	StopReason   *string           `json:"stop_reason,omitempty"`
	Usage        *LLMUsage         `json:"usage,omitempty"`
	OutputFormat string            `json:"output_format"`
}

LLMMessageGenerateResult is a strict text-format result.

func (LLMMessageGenerateResult) MarshalJSON

func (value LLMMessageGenerateResult) MarshalJSON() ([]byte, error)

func (*LLMMessageGenerateResult) UnmarshalJSON

func (value *LLMMessageGenerateResult) UnmarshalJSON(data []byte) error

type LLMRole

type LLMRole string
const LLMRoleAssistant LLMRole = "assistant"
const LLMRoleUser LLMRole = "user"

type LLMStructuredGenerateParams

type LLMStructuredGenerateParams struct {
	// Messages corresponds to the JSON schema field "messages".
	Messages []LLMMessage `json:"messages"`

	// ResponseFormat corresponds to the JSON schema field "response_format".
	ResponseFormat LLMJSONSchemaResponseFormat `json:"response_format"`

	// StopSequences corresponds to the JSON schema field "stop_sequences".
	StopSequences []string `json:"stop_sequences,omitempty,omitzero"`

	// SystemPrompt corresponds to the JSON schema field "system_prompt".
	SystemPrompt *string `json:"system_prompt,omitempty,omitzero"`

	// Temperature corresponds to the JSON schema field "temperature".
	Temperature *float64 `json:"temperature,omitempty,omitzero"`
}

type LLMStructuredGenerateResult

type LLMStructuredGenerateResult struct {
	Role              LLMRole           `json:"role"`
	Content           LLMMessageContent `json:"content"`
	StopReason        *string           `json:"stop_reason,omitempty"`
	Usage             *LLMUsage         `json:"usage,omitempty"`
	OutputFormat      string            `json:"output_format"`
	StructuredContent json.RawMessage   `json:"structured_content"`
}

LLMStructuredGenerateResult is a strict JSON-schema-format result.

func (LLMStructuredGenerateResult) MarshalJSON

func (value LLMStructuredGenerateResult) MarshalJSON() ([]byte, error)

func (*LLMStructuredGenerateResult) UnmarshalJSON

func (value *LLMStructuredGenerateResult) UnmarshalJSON(data []byte) error

type LLMTextContent

type LLMTextContent struct {
	// Annotations corresponds to the JSON schema field "annotations".
	Annotations *LLMAnnotations `json:"annotations,omitempty,omitzero"`

	// Text corresponds to the JSON schema field "text".
	Text string `json:"text"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMTextResponseFormat

type LLMTextResponseFormat struct {
	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMToolAnnotations

type LLMToolAnnotations struct {
	// DestructiveHint corresponds to the JSON schema field "destructive_hint".
	DestructiveHint *bool `json:"destructive_hint,omitempty,omitzero"`

	// IdempotentHint corresponds to the JSON schema field "idempotent_hint".
	IdempotentHint *bool `json:"idempotent_hint,omitempty,omitzero"`

	// OpenWorldHint corresponds to the JSON schema field "open_world_hint".
	OpenWorldHint *bool `json:"open_world_hint,omitempty,omitzero"`

	// ReadOnlyHint corresponds to the JSON schema field "read_only_hint".
	ReadOnlyHint *bool `json:"read_only_hint,omitempty,omitzero"`

	// Title corresponds to the JSON schema field "title".
	Title *string `json:"title,omitempty,omitzero"`
}

type LLMToolChoice

type LLMToolChoice struct {
	// Mode corresponds to the JSON schema field "mode".
	Mode *LLMToolChoiceMode `json:"mode,omitempty,omitzero"`
}

type LLMToolChoiceMode

type LLMToolChoiceMode string
const LLMToolChoiceModeAuto LLMToolChoiceMode = "auto"
const LLMToolChoiceModeNone LLMToolChoiceMode = "none"
const LLMToolChoiceModeRequired LLMToolChoiceMode = "required"

type LLMToolExecution

type LLMToolExecution struct {
	// TaskSupport corresponds to the JSON schema field "task_support".
	TaskSupport *LLMToolExecutionTaskSupport `json:"task_support,omitempty,omitzero"`
}

type LLMToolExecutionTaskSupport

type LLMToolExecutionTaskSupport string
const LLMToolExecutionTaskSupportForbidden LLMToolExecutionTaskSupport = "forbidden"
const LLMToolExecutionTaskSupportOptional LLMToolExecutionTaskSupport = "optional"
const LLMToolExecutionTaskSupportRequired LLMToolExecutionTaskSupport = "required"

type LLMToolIcon

type LLMToolIcon struct {
	// MIMEType corresponds to the JSON schema field "mime_type".
	MIMEType *string `json:"mime_type,omitempty,omitzero"`

	// Sizes corresponds to the JSON schema field "sizes".
	Sizes []string `json:"sizes,omitempty,omitzero"`

	// Src corresponds to the JSON schema field "src".
	Src string `json:"src"`

	// Theme corresponds to the JSON schema field "theme".
	Theme *LLMToolIconTheme `json:"theme,omitempty,omitzero"`
}

type LLMToolIconTheme

type LLMToolIconTheme string
const LLMToolIconThemeDark LLMToolIconTheme = "dark"
const LLMToolIconThemeLight LLMToolIconTheme = "light"

type LLMToolJSON

type LLMToolJSON struct {
	// Schema corresponds to the JSON schema field "$schema".
	Schema *string `json:"$schema,omitempty,omitzero"`

	// Properties corresponds to the JSON schema field "properties".
	Properties LLMToolJSONProperties `json:"properties,omitempty,omitzero"`

	// Required corresponds to the JSON schema field "required".
	Required []string `json:"required,omitempty,omitzero"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMToolJSONProperties

type LLMToolJSONProperties map[string]map[string]json.RawMessage

type LLMToolResultContent

type LLMToolResultContent struct {
	// Content corresponds to the JSON schema field "content".
	Content []LLMToolResultContentBlock `json:"content"`

	// IsError corresponds to the JSON schema field "is_error".
	IsError *bool `json:"is_error,omitempty,omitzero"`

	// StructuredContent corresponds to the JSON schema field "structured_content".
	StructuredContent LLMToolResultContentStructuredContent `json:"structured_content,omitempty,omitzero"`

	// ToolUseID corresponds to the JSON schema field "tool_use_id".
	ToolUseID string `json:"tool_use_id"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMToolResultContentBlock

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

LLMToolResultContentBlock is a text or image tool-result block.

func ToolResultImageBlock

func ToolResultImageBlock(value LLMImageContent) LLMToolResultContentBlock

ToolResultImageBlock constructs an image tool-result block.

func ToolResultTextBlock

func ToolResultTextBlock(value LLMTextContent) LLMToolResultContentBlock

ToolResultTextBlock constructs a text tool-result block.

func (LLMToolResultContentBlock) AsImage

func (value LLMToolResultContentBlock) AsImage() (LLMImageContent, bool)

AsImage returns the image variant, if present.

func (LLMToolResultContentBlock) AsText

func (value LLMToolResultContentBlock) AsText() (LLMTextContent, bool)

AsText returns the text variant, if present.

func (LLMToolResultContentBlock) MarshalJSON

func (value LLMToolResultContentBlock) MarshalJSON() ([]byte, error)

func (*LLMToolResultContentBlock) UnmarshalJSON

func (value *LLMToolResultContentBlock) UnmarshalJSON(data []byte) error

type LLMToolResultContentStructuredContent

type LLMToolResultContentStructuredContent map[string]json.RawMessage

type LLMToolUseContent

type LLMToolUseContent struct {
	// ID corresponds to the JSON schema field "id".
	ID string `json:"id"`

	// Input corresponds to the JSON schema field "input".
	Input LLMToolUseContentInput `json:"input"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type LLMToolUseContentInput

type LLMToolUseContentInput map[string]json.RawMessage

type LLMUsage

type LLMUsage struct {
	// CachedInputTokens corresponds to the JSON schema field "cached_input_tokens".
	CachedInputTokens *int `json:"cached_input_tokens,omitempty,omitzero"`

	// InputTokens corresponds to the JSON schema field "input_tokens".
	InputTokens int `json:"input_tokens"`

	// OutputTokens corresponds to the JSON schema field "output_tokens".
	OutputTokens int `json:"output_tokens"`

	// ReasoningTokens corresponds to the JSON schema field "reasoning_tokens".
	ReasoningTokens *int `json:"reasoning_tokens,omitempty,omitzero"`

	// TotalTokens corresponds to the JSON schema field "total_tokens".
	TotalTokens int `json:"total_tokens"`
}

type LoadState

type LoadState string

LoadState identifies the browser lifecycle event to wait for.

const (
	LoadStateDOMContentLoaded LoadState = "domcontentloaded"
	LoadStateLoad             LoadState = "load"
	LoadStateNetworkIdle      LoadState = "networkidle"
)

type LocalBrowserConnectOptions

type LocalBrowserConnectOptions struct {
	CDPURL      string
	ExtensionID string
}

LocalBrowserConnectOptions configures a connection to an existing local browser.

type LocalBrowserLaunchOptions

type LocalBrowserLaunchOptions struct {
	Args                []string
	ExecutablePath      string
	Port                int
	UserDataDir         string
	PreserveUserDataDir bool
	Headless            bool
	Devtools            bool
	ChromiumSandbox     *bool
	IgnoreDefaultArgs   *IgnoreDefaultArgs
	Proxy               *LocalProxyConfig
	Locale              string
	Viewport            *LocalViewport
	DeviceScaleFactor   *float64
	HasTouch            bool
	IgnoreHTTPSErrors   bool
	DownloadsPath       string
	AcceptDownloads     *bool
	// KeepAlive transfers ownership of the launched browser lifetime to the caller.
	// Browser.Close leaves the process running and does not remove a temporary
	// user data directory.
	KeepAlive bool
}

LocalBrowserLaunchOptions configures a Chromium process launched by the SDK.

type LocalProxyConfig

type LocalProxyConfig struct {
	Server   string
	Bypass   string
	Username string
	Password string
}

LocalProxyConfig configures an upstream proxy for a local browser.

type LocalViewport

type LocalViewport struct {
	Width  int
	Height int
}

LocalViewport configures the initial local browser viewport.

type Locator

type Locator struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorCentroidResult

type LocatorCentroidResult struct {
	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type LocatorClickOptions

type LocatorClickOptions struct {
	// Button corresponds to the JSON schema field "button".
	Button *MouseButton `json:"button,omitempty,omitzero"`

	// ClickCount corresponds to the JSON schema field "click_count".
	ClickCount *int `json:"click_count,omitempty,omitzero"`
}

type LocatorClickParams

type LocatorClickParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options *LocatorClickOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorClickResult

type LocatorClickResult struct {
	// Clicked corresponds to the JSON schema field "clicked".
	Clicked bool `json:"clicked"`
}

type LocatorCountResult

type LocatorCountResult int

type LocatorDescriptor

type LocatorDescriptor struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorFillParams

type LocatorFillParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`

	// Value corresponds to the JSON schema field "value".
	Value string `json:"value"`
}

type LocatorFillResult

type LocatorFillResult struct {
	// Filled corresponds to the JSON schema field "filled".
	Filled bool `json:"filled"`
}

type LocatorHighlightOptions

type LocatorHighlightOptions struct {
	// BorderColor corresponds to the JSON schema field "border_color".
	BorderColor *RgbaColor `json:"border_color,omitempty,omitzero"`

	// ContentColor corresponds to the JSON schema field "content_color".
	ContentColor *RgbaColor `json:"content_color,omitempty,omitzero"`

	// DurationMs corresponds to the JSON schema field "duration_ms".
	DurationMs *int `json:"duration_ms,omitempty,omitzero"`
}

type LocatorHighlightParams

type LocatorHighlightParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options *LocatorHighlightOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorHighlightResult

type LocatorHighlightResult struct {
	// Highlighted corresponds to the JSON schema field "highlighted".
	Highlighted bool `json:"highlighted"`
}

type LocatorHoverResult

type LocatorHoverResult struct {
	// Hovered corresponds to the JSON schema field "hovered".
	Hovered bool `json:"hovered"`
}

type LocatorInnerHTMLResult

type LocatorInnerHTMLResult string

type LocatorInnerTextResult

type LocatorInnerTextResult string

type LocatorInputValueResult

type LocatorInputValueResult string

type LocatorIsCheckedResult

type LocatorIsCheckedResult bool

type LocatorIsVisibleResult

type LocatorIsVisibleResult bool

type LocatorScrollToParams

type LocatorScrollToParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Percent corresponds to the JSON schema field "percent".
	Percent ScrollPercent `json:"percent"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorScrollToResult

type LocatorScrollToResult struct {
	// Scrolled corresponds to the JSON schema field "scrolled".
	Scrolled bool `json:"scrolled"`
}

type LocatorSelectOptionParams

type LocatorSelectOptionParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`

	// Values corresponds to the JSON schema field "values".
	Values StringList `json:"values"`
}

type LocatorSelectOptionResult

type LocatorSelectOptionResult []string

type LocatorSendClickEventOptions

type LocatorSendClickEventOptions struct {
	// Bubbles corresponds to the JSON schema field "bubbles".
	Bubbles *bool `json:"bubbles,omitempty,omitzero"`

	// Cancelable corresponds to the JSON schema field "cancelable".
	Cancelable *bool `json:"cancelable,omitempty,omitzero"`

	// Composed corresponds to the JSON schema field "composed".
	Composed *bool `json:"composed,omitempty,omitzero"`

	// Detail corresponds to the JSON schema field "detail".
	Detail *float64 `json:"detail,omitempty,omitzero"`
}

type LocatorSendClickEventParams

type LocatorSendClickEventParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options *LocatorSendClickEventOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorSendClickEventResult

type LocatorSendClickEventResult struct {
	// Clicked corresponds to the JSON schema field "clicked".
	Clicked bool `json:"clicked"`
}

type LocatorSetInputFilesParams

type LocatorSetInputFilesParams struct {
	// Files corresponds to the JSON schema field "files".
	Files []InputFilePayload `json:"files"`

	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type LocatorSetInputFilesResult

type LocatorSetInputFilesResult struct {
	// Set corresponds to the JSON schema field "set".
	Set bool `json:"set"`
}

type LocatorTextContentResult

type LocatorTextContentResult string

type LocatorTypeOptions

type LocatorTypeOptions struct {
	// Delay corresponds to the JSON schema field "delay".
	Delay *float64 `json:"delay,omitempty,omitzero"`
}

type LocatorTypeParams

type LocatorTypeParams struct {
	// Nth corresponds to the JSON schema field "nth".
	Nth *int `json:"nth,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options *LocatorTypeOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`

	// Text corresponds to the JSON schema field "text".
	Text string `json:"text"`
}

type LocatorTypeResult

type LocatorTypeResult struct {
	// Typed corresponds to the JSON schema field "typed".
	Typed bool `json:"typed"`
}

type ModelConfig

type ModelConfig struct {
	// API key for the model provider
	APIKey *string `json:"api_key,omitempty,omitzero"`

	// Custom headers sent with every request to the model provider
	Headers ModelConfigHeaders `json:"headers,omitempty,omitzero"`

	// ModelName corresponds to the JSON schema field "model_name".
	ModelName ModelName `json:"model_name"`
}

type ModelConfigHeaders

type ModelConfigHeaders map[string]string

Custom headers sent with every request to the model provider

type ModelName

type ModelName string

ModelName is a provider-prefixed model name accepted by Stagehand.

The protocol describes these values with provider-specific regular expressions rather than a closed enum, so values are validated by the server rather than enumerated in Go.

type MouseButton

type MouseButton string
const MouseButtonLeft MouseButton = "left"
const MouseButtonMiddle MouseButton = "middle"
const MouseButtonRight MouseButton = "right"
type NavigationFinishedError struct {
	// Message corresponds to the JSON schema field "message".
	Message string `json:"message"`
}
type NavigationHeader struct {
	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Value corresponds to the JSON schema field "value".
	Value string `json:"value"`
}
type NavigationResponseDescriptor struct {
	// FromServiceWorker corresponds to the JSON schema field "from_service_worker".
	FromServiceWorker bool `json:"from_service_worker"`

	// Headers corresponds to the JSON schema field "headers".
	Headers NavigationResponseDescriptorHeaders `json:"headers"`

	// ResponseID corresponds to the JSON schema field "response_id".
	ResponseID string `json:"response_id"`

	// Status corresponds to the JSON schema field "status".
	Status int `json:"status"`

	// StatusText corresponds to the JSON schema field "status_text".
	StatusText string `json:"status_text"`

	// URL corresponds to the JSON schema field "url".
	URL string `json:"url"`
}
type NavigationResponseDescriptorHeaders map[string]string
type NavigationSecurityDetails struct {
	// Issuer corresponds to the JSON schema field "issuer".
	Issuer string `json:"issuer"`

	// Protocol corresponds to the JSON schema field "protocol".
	Protocol string `json:"protocol"`

	// SubjectName corresponds to the JSON schema field "subject_name".
	SubjectName string `json:"subject_name"`

	// ValidFrom corresponds to the JSON schema field "valid_from".
	ValidFrom float64 `json:"valid_from"`

	// ValidTo corresponds to the JSON schema field "valid_to".
	ValidTo float64 `json:"valid_to"`
}
type NavigationServerAddr struct {
	// IPAddress corresponds to the JSON schema field "ip_address".
	IPAddress string `json:"ip_address"`

	// Port corresponds to the JSON schema field "port".
	Port int `json:"port"`
}

type ObserveOptions

type ObserveOptions struct {
	// Cache corresponds to the JSON schema field "cache".
	Cache *Caching `json:"cache,omitempty,omitzero"`

	// Locators for elements and subtrees that should be excluded from observation
	IgnoreLocators []Locator `json:"ignore_locators,omitempty,omitzero"`

	// Locator that scopes observation to a specific element
	Locator *Locator `json:"locator,omitempty,omitzero"`

	// Complete model configuration for this call; when omitted, the initialized
	// Stagehand model is used, or Browserbase selects one automatically when no
	// initialized model exists
	Model *ModelConfig `json:"model,omitempty,omitzero"`

	// Timeout in ms for the observation
	Timeout *float64 `json:"timeout,omitempty,omitzero"`

	// Variables whose names are exposed to the model so observe() returns
	// %variableName% placeholders in suggested action arguments instead of literal
	// values. Accepts flat primitives or { value, description? } objects.
	Variables Variables `json:"variables,omitempty,omitzero"`
}

func (ObserveOptions) MarshalJSON

func (options ObserveOptions) MarshalJSON() ([]byte, error)

type ObserveResult

type ObserveResult struct {
	// Data corresponds to the JSON schema field "data".
	Data []Action `json:"data"`

	// Metadata corresponds to the JSON schema field "metadata".
	Metadata StagehandResultMetadata `json:"metadata"`
}

type OpenAIModelName

type OpenAIModelName string

type Page

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

Page is a thin wrapper around a generated PageRef.

func (*Page) AddInitScript

func (p *Page) AddInitScript(ctx context.Context, source string) error

AddInitScript installs JavaScript source in the page.

func (*Page) Click

func (p *Page) Click(
	ctx context.Context,
	x float64,
	y float64,
	options *PageClickOptions,
) error

Click clicks browser coordinates.

func (*Page) Close

func (p *Page) Close(ctx context.Context) error

Close closes the page.

func (*Page) DragAndDrop

func (p *Page) DragAndDrop(
	ctx context.Context,
	fromX float64,
	fromY float64,
	toX float64,
	toY float64,
	options *PageDragAndDropOptions,
) error

DragAndDrop drags between browser coordinates.

func (*Page) Evaluate

func (p *Page) Evaluate(ctx context.Context, expression string) (json.RawMessage, error)

Evaluate evaluates JavaScript source and returns its JSON value.

func (*Page) GoBack

func (p *Page) GoBack(ctx context.Context, options *PageNavigationOptions) (*Response, error)

GoBack navigates backward, refreshes the page reference, and returns its network response.

func (*Page) GoForward

func (p *Page) GoForward(
	ctx context.Context,
	options *PageNavigationOptions,
) (*Response, error)

GoForward navigates forward, refreshes the page reference, and returns its network response.

func (*Page) Goto

func (p *Page) Goto(
	ctx context.Context,
	url string,
	options *PageNavigationOptions,
) (*Response, error)

Goto navigates the page, refreshes its protocol reference, and returns its network response.

func (*Page) Hover

func (p *Page) Hover(
	ctx context.Context,
	x float64,
	y float64,
) error

Hover hovers browser coordinates.

func (*Page) KeyPress

func (p *Page) KeyPress(ctx context.Context, key string, options *PageKeyPressOptions) error

KeyPress presses a keyboard key at the current focus.

func (*Page) Locator

func (p *Page) Locator(selector string) *PageLocator

Locator creates a page-scoped selector wrapper.

func (*Page) On

func (p *Page) On(
	ctx context.Context,
	event PageEventName,
	listener func(PageCDPEvent),
) (*CDPSubscription, error)

On subscribes to console events for this page and its OOPIF sessions.

func (*Page) PageID

func (p *Page) PageID() string

PageID returns the stable protocol page identifier.

func (*Page) Ref

func (p *Page) Ref() PageRef

Ref returns the page's latest generated protocol reference.

func (*Page) Reload

func (p *Page) Reload(ctx context.Context, options *PageReloadOptions) (*Response, error)

Reload reloads the page, refreshes its protocol reference, and returns its network response.

func (*Page) Screenshot

func (p *Page) Screenshot(ctx context.Context, options *ScreenshotOptions) ([]byte, error)

Screenshot captures the page and decodes the protocol's base64 payload.

func (*Page) Scroll

func (p *Page) Scroll(
	ctx context.Context,
	x float64,
	y float64,
	deltaX float64,
	deltaY float64,
) error

Scroll scrolls at browser coordinates.

func (*Page) SetExtraHTTPHeaders

func (p *Page) SetExtraHTTPHeaders(
	ctx context.Context,
	headers PageSetExtraHTTPHeadersParamsHeaders,
) error

SetExtraHTTPHeaders sets page-specific request headers.

func (*Page) SetViewportSize

func (p *Page) SetViewportSize(
	ctx context.Context,
	width int,
	height int,
	options *PageSetViewportSizeOptions,
) error

SetViewportSize changes the page viewport.

func (*Page) Snapshot

func (p *Page) Snapshot(ctx context.Context, options *PageSnapshotOptions) (SnapshotResult, error)

Snapshot returns the generated accessibility snapshot result.

func (*Page) Title

func (p *Page) Title(ctx context.Context) (string, error)

Title returns the page title.

func (*Page) Tools

func (p *Page) Tools(
	ctx context.Context,
	options *WebMCPToolsOptions,
) ([]*WebMCPTool, error)

Tools returns a fresh snapshot of the WebMCP tools registered by the page.

func (*Page) Type

func (p *Page) Type(ctx context.Context, value string, options *PageTypeOptions) error

Type enters text at the current focus.

func (*Page) URL

func (p *Page) URL(ctx context.Context) (string, error)

URL returns the page URL.

func (*Page) WaitForLoadState

func (p *Page) WaitForLoadState(
	ctx context.Context,
	state LoadState,
	timeoutMs *int,
) error

WaitForLoadState waits for a generated LoadState value.

func (*Page) WaitForSelector

func (p *Page) WaitForSelector(
	ctx context.Context,
	selector string,
	options *PageWaitForSelectorOptions,
) (bool, error)

WaitForSelector waits for a selector and reports whether it matched.

func (*Page) WaitForTimeout

func (p *Page) WaitForTimeout(ctx context.Context, ms int) error

WaitForTimeout waits for the requested number of milliseconds.

type PageAddInitScriptParams

type PageAddInitScriptParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Source corresponds to the JSON schema field "source".
	Source string `json:"source"`
}

type PageCDPEvent

type PageCDPEvent struct {
	// Method corresponds to the JSON schema field "method".
	Method string `json:"method"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Params corresponds to the JSON schema field "params".
	Params PageCDPEventParams `json:"params"`

	// SessionID corresponds to the JSON schema field "session_id".
	SessionID string `json:"session_id"`

	// TargetID corresponds to the JSON schema field "target_id".
	TargetID string `json:"target_id"`
}

type PageCDPEventNotification

type PageCDPEventNotification struct {
	// Event corresponds to the JSON schema field "event".
	Event PageCDPEvent `json:"event"`

	// SubscriptionID corresponds to the JSON schema field "subscription_id".
	SubscriptionID string `json:"subscription_id"`
}

type PageCDPEventParams

type PageCDPEventParams map[string]json.RawMessage

type PageClickOptions

type PageClickOptions struct {
	// Button corresponds to the JSON schema field "button".
	Button *MouseButton `json:"button,omitempty,omitzero"`

	// ClickCount corresponds to the JSON schema field "click_count".
	ClickCount *int `json:"click_count,omitempty,omitzero"`
}

type PageClickParams

type PageClickParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageClickOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type PageCloseResult

type PageCloseResult struct {
	// Closed corresponds to the JSON schema field "closed".
	Closed bool `json:"closed"`
}

type PageDragAndDropOptions

type PageDragAndDropOptions struct {
	// Button corresponds to the JSON schema field "button".
	Button *MouseButton `json:"button,omitempty,omitzero"`

	// Delay corresponds to the JSON schema field "delay".
	Delay *float64 `json:"delay,omitempty,omitzero"`

	// Route corresponds to the JSON schema field "route".
	Route []PageDragAndDropRoutePoint `json:"route,omitempty,omitzero"`

	// Steps corresponds to the JSON schema field "steps".
	Steps *int `json:"steps,omitempty,omitzero"`
}

type PageDragAndDropParams

type PageDragAndDropParams struct {
	// FromX corresponds to the JSON schema field "from_x".
	FromX float64 `json:"from_x"`

	// FromY corresponds to the JSON schema field "from_y".
	FromY float64 `json:"from_y"`

	// Options corresponds to the JSON schema field "options".
	Options *PageDragAndDropOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// ToX corresponds to the JSON schema field "to_x".
	ToX float64 `json:"to_x"`

	// ToY corresponds to the JSON schema field "to_y".
	ToY float64 `json:"to_y"`
}

type PageDragAndDropRoutePoint

type PageDragAndDropRoutePoint struct {
	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type PageEvaluateParams

type PageEvaluateParams struct {
	// Expression corresponds to the JSON schema field "expression".
	Expression string `json:"expression"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageEvaluateResult

type PageEvaluateResult struct {
	// Value corresponds to the JSON schema field "value".
	Value json.RawMessage `json:"value"`
}

type PageEventName

type PageEventName string
const PageEventNameConsole PageEventName = "console"

type PageGoBackParams

type PageGoBackParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageNavigationOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageGoForwardParams

type PageGoForwardParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageNavigationOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageGotoParams

type PageGotoParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageNavigationOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// URL corresponds to the JSON schema field "url".
	URL string `json:"url"`
}

type PageHoverParams

type PageHoverParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type PageIDParams

type PageIDParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageKeyPressOptions

type PageKeyPressOptions struct {
	// Delay corresponds to the JSON schema field "delay".
	Delay *float64 `json:"delay,omitempty,omitzero"`
}

type PageKeyPressParams

type PageKeyPressParams struct {
	// Key corresponds to the JSON schema field "key".
	Key string `json:"key"`

	// Options corresponds to the JSON schema field "options".
	Options *PageKeyPressOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageLocator

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

PageLocator is the client wrapper named Locator in the TypeScript and Python SDKs. The Go protocol already exports a different generated Locator value.

func (*PageLocator) Centroid

Centroid returns the matching element's center coordinates.

func (*PageLocator) Click

func (l *PageLocator) Click(ctx context.Context, options *LocatorClickOptions) error

Click clicks the matching element.

func (*PageLocator) Count

func (l *PageLocator) Count(ctx context.Context) (int, error)

Count returns the number of matching elements.

func (*PageLocator) Descriptor

func (l *PageLocator) Descriptor() LocatorDescriptor

Descriptor returns the generated wire descriptor.

func (*PageLocator) Fill

func (l *PageLocator) Fill(ctx context.Context, value string) error

Fill replaces the matching input's value.

func (*PageLocator) First

func (l *PageLocator) First() *PageLocator

First returns a locator restricted to the first match.

func (*PageLocator) Highlight

func (l *PageLocator) Highlight(ctx context.Context, options *LocatorHighlightOptions) error

Highlight highlights the matching element.

func (*PageLocator) Hover

func (l *PageLocator) Hover(ctx context.Context) error

Hover hovers the matching element.

func (*PageLocator) InnerHTML

func (l *PageLocator) InnerHTML(ctx context.Context) (string, error)

InnerHTML returns the matching element's HTML.

func (*PageLocator) InnerText

func (l *PageLocator) InnerText(ctx context.Context) (string, error)

InnerText returns the matching element's rendered text.

func (*PageLocator) InputValue

func (l *PageLocator) InputValue(ctx context.Context) (string, error)

InputValue returns the matching input's value.

func (*PageLocator) IsChecked

func (l *PageLocator) IsChecked(ctx context.Context) (bool, error)

IsChecked reports whether the matching control is checked.

func (*PageLocator) IsVisible

func (l *PageLocator) IsVisible(ctx context.Context) (bool, error)

IsVisible reports whether the matching element is visible.

func (*PageLocator) Nth

func (l *PageLocator) Nth(index int) (*PageLocator, error)

Nth returns a locator restricted to one zero-based match. It returns an error when index is negative.

func (*PageLocator) ScrollTo

func (l *PageLocator) ScrollTo(ctx context.Context, percent ScrollPercent) error

ScrollTo scrolls the matching element to a generated percentage value.

func (*PageLocator) SelectOption

func (l *PageLocator) SelectOption(ctx context.Context, values StringList) ([]string, error)

SelectOption selects values in the matching element.

func (*PageLocator) SendClickEvent

func (l *PageLocator) SendClickEvent(
	ctx context.Context,
	options *LocatorSendClickEventOptions,
) error

SendClickEvent sends a click event to the matching element.

func (*PageLocator) SetInputFiles

func (l *PageLocator) SetInputFiles(ctx context.Context, files ...FileInput) error

SetInputFiles sets files on the matching <input type="file"> element. Calling it without files clears the current selection.

func (*PageLocator) TextContent

func (l *PageLocator) TextContent(ctx context.Context) (string, error)

TextContent returns the matching element's text content.

func (*PageLocator) Type

func (l *PageLocator) Type(ctx context.Context, text string, options *LocatorTypeOptions) error

Type enters text into the matching element.

type PageNavigationOptions struct {
	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *int `json:"timeout,omitempty,omitzero"`

	// WaitUntil corresponds to the JSON schema field "wait_until".
	WaitUntil *LoadState `json:"wait_until,omitempty,omitzero"`
}
type PageNavigationResult struct {
	// Page corresponds to the JSON schema field "page".
	Page PageRef `json:"page"`

	// Response corresponds to the JSON schema field "response".
	Response *NavigationResponseDescriptor `json:"response"`
}

type PageOffParams

type PageOffParams struct {
	// SubscriptionID corresponds to the JSON schema field "subscription_id".
	SubscriptionID string `json:"subscription_id"`
}

type PageOnParams

type PageOnParams struct {
	// Event corresponds to the JSON schema field "event".
	Event PageEventName `json:"event"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// SubscriptionID corresponds to the JSON schema field "subscription_id".
	SubscriptionID string `json:"subscription_id"`
}

type PageRef

type PageRef struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Title corresponds to the JSON schema field "title".
	Title *string `json:"title,omitempty,omitzero"`

	// URL corresponds to the JSON schema field "url".
	URL *string `json:"url,omitempty,omitzero"`
}

type PageReloadOptions

type PageReloadOptions struct {
	// IgnoreCache corresponds to the JSON schema field "ignore_cache".
	IgnoreCache *bool `json:"ignore_cache,omitempty,omitzero"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *int `json:"timeout,omitempty,omitzero"`

	// WaitUntil corresponds to the JSON schema field "wait_until".
	WaitUntil *LoadState `json:"wait_until,omitempty,omitzero"`
}

type PageReloadParams

type PageReloadParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageReloadOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageScreenshotClip

type PageScreenshotClip struct {
	// Height corresponds to the JSON schema field "height".
	Height float64 `json:"height"`

	// Width corresponds to the JSON schema field "width".
	Width float64 `json:"width"`

	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type PageScreenshotOptions

type PageScreenshotOptions struct {
	// Animations corresponds to the JSON schema field "animations".
	Animations *PageScreenshotOptionsAnimations `json:"animations,omitempty,omitzero"`

	// Caret corresponds to the JSON schema field "caret".
	Caret *PageScreenshotOptionsCaret `json:"caret,omitempty,omitzero"`

	// Clip corresponds to the JSON schema field "clip".
	Clip *PageScreenshotClip `json:"clip,omitempty,omitzero"`

	// FullPage corresponds to the JSON schema field "full_page".
	FullPage *bool `json:"full_page,omitempty,omitzero"`

	// Mask corresponds to the JSON schema field "mask".
	Mask []LocatorDescriptor `json:"mask,omitempty,omitzero"`

	// MaskColor corresponds to the JSON schema field "mask_color".
	MaskColor *string `json:"mask_color,omitempty,omitzero"`

	// OmitBackground corresponds to the JSON schema field "omit_background".
	OmitBackground *bool `json:"omit_background,omitempty,omitzero"`

	// Quality corresponds to the JSON schema field "quality".
	Quality *int `json:"quality,omitempty,omitzero"`

	// Scale corresponds to the JSON schema field "scale".
	Scale *PageScreenshotOptionsScale `json:"scale,omitempty,omitzero"`

	// Style corresponds to the JSON schema field "style".
	Style *string `json:"style,omitempty,omitzero"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *float64 `json:"timeout,omitempty,omitzero"`

	// Type corresponds to the JSON schema field "type".
	Type *PageScreenshotOptionsType `json:"type,omitempty,omitzero"`
}

type PageScreenshotOptionsAnimations

type PageScreenshotOptionsAnimations string
const PageScreenshotOptionsAnimationsAllow PageScreenshotOptionsAnimations = "allow"
const PageScreenshotOptionsAnimationsDisabled PageScreenshotOptionsAnimations = "disabled"

type PageScreenshotOptionsCaret

type PageScreenshotOptionsCaret string
const PageScreenshotOptionsCaretHide PageScreenshotOptionsCaret = "hide"
const PageScreenshotOptionsCaretInitial PageScreenshotOptionsCaret = "initial"

type PageScreenshotOptionsScale

type PageScreenshotOptionsScale string
const PageScreenshotOptionsScaleCSS PageScreenshotOptionsScale = "css"
const PageScreenshotOptionsScaleDevice PageScreenshotOptionsScale = "device"

type PageScreenshotOptionsType

type PageScreenshotOptionsType string
const PageScreenshotOptionsTypeJPEG PageScreenshotOptionsType = "jpeg"
const PageScreenshotOptionsTypePNG PageScreenshotOptionsType = "png"

type PageScreenshotParams

type PageScreenshotParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageScreenshotOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageScreenshotResult

type PageScreenshotResult struct {
	// Data corresponds to the JSON schema field "data".
	Data string `json:"data"`

	// Type corresponds to the JSON schema field "type".
	Type PageScreenshotResultType `json:"type"`
}

type PageScreenshotResultType

type PageScreenshotResultType string
const PageScreenshotResultTypeJPEG PageScreenshotResultType = "jpeg"
const PageScreenshotResultTypePNG PageScreenshotResultType = "png"

type PageScrollParams

type PageScrollParams struct {
	// DeltaX corresponds to the JSON schema field "delta_x".
	DeltaX float64 `json:"delta_x"`

	// DeltaY corresponds to the JSON schema field "delta_y".
	DeltaY float64 `json:"delta_y"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// X corresponds to the JSON schema field "x".
	X float64 `json:"x"`

	// Y corresponds to the JSON schema field "y".
	Y float64 `json:"y"`
}

type PageSetExtraHTTPHeadersParams

type PageSetExtraHTTPHeadersParams struct {
	// Headers corresponds to the JSON schema field "headers".
	Headers PageSetExtraHTTPHeadersParamsHeaders `json:"headers"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageSetExtraHTTPHeadersParamsHeaders

type PageSetExtraHTTPHeadersParamsHeaders map[string]string

type PageSetViewportSizeOptions

type PageSetViewportSizeOptions struct {
	// DeviceScaleFactor corresponds to the JSON schema field "device_scale_factor".
	DeviceScaleFactor *float64 `json:"device_scale_factor,omitempty,omitzero"`
}

type PageSetViewportSizeParams

type PageSetViewportSizeParams struct {
	// Height corresponds to the JSON schema field "height".
	Height int `json:"height"`

	// Options corresponds to the JSON schema field "options".
	Options *PageSetViewportSizeOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Width corresponds to the JSON schema field "width".
	Width int `json:"width"`
}

type PageSnapshotOptions

type PageSnapshotOptions struct {
	// IncludeIframes corresponds to the JSON schema field "include_iframes".
	IncludeIframes *bool `json:"include_iframes,omitempty,omitzero"`
}

type PageSnapshotParams

type PageSnapshotParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageSnapshotOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageTitleResult

type PageTitleResult string

type PageTypeOptions

type PageTypeOptions struct {
	// Delay corresponds to the JSON schema field "delay".
	Delay *float64 `json:"delay,omitempty,omitzero"`

	// WithMistakes corresponds to the JSON schema field "with_mistakes".
	WithMistakes *bool `json:"with_mistakes,omitempty,omitzero"`
}

type PageTypeParams

type PageTypeParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageTypeOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Text corresponds to the JSON schema field "text".
	Text string `json:"text"`
}

type PageURLResult

type PageURLResult string

type PageVoidResult

type PageVoidResult struct {
	// Ok corresponds to the JSON schema field "ok".
	Ok bool `json:"ok"`
}

type PageWaitForLoadStateParams

type PageWaitForLoadStateParams struct {
	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// State corresponds to the JSON schema field "state".
	State LoadState `json:"state"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *int `json:"timeout,omitempty,omitzero"`
}

type PageWaitForSelectorOptions

type PageWaitForSelectorOptions struct {
	// PierceShadow corresponds to the JSON schema field "pierce_shadow".
	PierceShadow *bool `json:"pierce_shadow,omitempty,omitzero"`

	// State corresponds to the JSON schema field "state".
	State *PageWaitForSelectorOptionsState `json:"state,omitempty,omitzero"`

	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *int `json:"timeout,omitempty,omitzero"`
}

type PageWaitForSelectorOptionsState

type PageWaitForSelectorOptionsState string
const PageWaitForSelectorOptionsStateAttached PageWaitForSelectorOptionsState = "attached"
const PageWaitForSelectorOptionsStateDetached PageWaitForSelectorOptionsState = "detached"
const PageWaitForSelectorOptionsStateHidden PageWaitForSelectorOptionsState = "hidden"
const PageWaitForSelectorOptionsStateVisible PageWaitForSelectorOptionsState = "visible"

type PageWaitForSelectorParams

type PageWaitForSelectorParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *PageWaitForSelectorOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Selector corresponds to the JSON schema field "selector".
	Selector string `json:"selector"`
}

type PageWaitForSelectorResult

type PageWaitForSelectorResult struct {
	// Matched corresponds to the JSON schema field "matched".
	Matched bool `json:"matched"`
}

type PageWaitForTimeoutParams

type PageWaitForTimeoutParams struct {
	// Ms corresponds to the JSON schema field "ms".
	Ms int `json:"ms"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageWebMCPCancelInvocationParams

type PageWebMCPCancelInvocationParams struct {
	// InvocationID corresponds to the JSON schema field "invocation_id".
	InvocationID string `json:"invocation_id"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageWebMCPInvocationResultParams

type PageWebMCPInvocationResultParams struct {
	// InvocationID corresponds to the JSON schema field "invocation_id".
	InvocationID string `json:"invocation_id"`

	// Options corresponds to the JSON schema field "options".
	Options *WebMCPResultOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageWebMCPInvokeToolParams

type PageWebMCPInvokeToolParams struct {
	// FrameID corresponds to the JSON schema field "frame_id".
	FrameID string `json:"frame_id"`

	// Input corresponds to the JSON schema field "input".
	Input PageWebMCPInvokeToolParamsInput `json:"input,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// ToolName corresponds to the JSON schema field "tool_name".
	ToolName string `json:"tool_name"`
}

type PageWebMCPInvokeToolParamsInput

type PageWebMCPInvokeToolParamsInput map[string]json.RawMessage

type PageWebMCPToolsParams

type PageWebMCPToolsParams struct {
	// Options corresponds to the JSON schema field "options".
	Options *WebMCPToolsOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type PageWebMCPToolsResult

type PageWebMCPToolsResult struct {
	// Tools corresponds to the JSON schema field "tools".
	Tools []WebMCPToolDescriptor `json:"tools"`
}

type ProxyConfig

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

ProxyConfig is either a Browserbase-managed or external proxy.

func BrowserbaseProxy

func BrowserbaseProxy(value BrowserbaseProxyConfig) ProxyConfig

BrowserbaseProxy constructs a Browserbase-managed proxy configuration.

func ExternalProxy

func ExternalProxy(value ExternalProxyConfig) ProxyConfig

ExternalProxy constructs an external proxy configuration.

func (ProxyConfig) AsBrowserbase

func (value ProxyConfig) AsBrowserbase() (BrowserbaseProxyConfig, bool)

AsBrowserbase returns the Browserbase variant, if present.

func (ProxyConfig) AsExternal

func (value ProxyConfig) AsExternal() (ExternalProxyConfig, bool)

AsExternal returns the external variant, if present.

func (ProxyConfig) MarshalJSON

func (value ProxyConfig) MarshalJSON() ([]byte, error)

func (*ProxyConfig) UnmarshalJSON

func (value *ProxyConfig) UnmarshalJSON(data []byte) error

type RPCError

type RPCError struct {
	Code    int
	Message string
	Data    json.RawMessage
}

RPCError is a JSON-RPC error returned by the Stagehand worker.

func (*RPCError) Error

func (e *RPCError) Error() string

type Response

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

Response is a lazy wrapper around a navigation response descriptor.

func (*Response) AllHeaders

func (r *Response) AllHeaders(ctx context.Context) (map[string]string, error)

AllHeaders retrieves all response headers, including extra-info headers.

func (*Response) Body

func (r *Response) Body(ctx context.Context) ([]byte, error)

Body retrieves and decodes the raw response body.

func (*Response) Finished

func (r *Response) Finished(ctx context.Context) error

Finished waits for the response to finish and returns its loading error, if any.

func (*Response) FromServiceWorker

func (r *Response) FromServiceWorker() bool

FromServiceWorker reports whether a service worker produced the response.

func (*Response) HeaderValue

func (r *Response) HeaderValue(ctx context.Context, name string) (string, bool, error)

HeaderValue retrieves all matching header values and joins them with a comma.

func (*Response) HeaderValues

func (r *Response) HeaderValues(ctx context.Context, name string) ([]string, error)

HeaderValues retrieves separate values for a case-insensitive header name.

func (*Response) Headers

func (r *Response) Headers() map[string]string

Headers returns a copy of the normalized provisional response headers.

func (*Response) HeadersArray

func (r *Response) HeadersArray(ctx context.Context) ([]NavigationHeader, error)

HeadersArray retrieves ordered response headers while preserving duplicates.

func (*Response) JSON

func (r *Response) JSON(ctx context.Context, destination any) error

JSON decodes the response body into destination.

func (*Response) OK

func (r *Response) OK() bool

OK reports whether the response status is in the 2xx range.

func (*Response) SecurityDetails

func (r *Response) SecurityDetails(ctx context.Context) (*NavigationSecurityDetails, error)

SecurityDetails retrieves TLS details when they are available.

func (*Response) ServerAddr

func (r *Response) ServerAddr(ctx context.Context) (*NavigationServerAddr, error)

ServerAddr retrieves the server address when it is available.

func (*Response) Status

func (r *Response) Status() int

Status returns the HTTP response status code.

func (*Response) StatusText

func (r *Response) StatusText() string

StatusText returns the HTTP response status text.

func (*Response) Text

func (r *Response) Text(ctx context.Context) (string, error)

Text retrieves the response body as UTF-8 text.

func (*Response) URL

func (r *Response) URL() string

URL returns the final response URL.

type ResponseAllHeadersResult

type ResponseAllHeadersResult struct {
	// Headers corresponds to the JSON schema field "headers".
	Headers ResponseAllHeadersResultHeaders `json:"headers"`
}

type ResponseAllHeadersResultHeaders

type ResponseAllHeadersResultHeaders map[string]string

type ResponseBodyResult

type ResponseBodyResult struct {
	// Base64Encoded corresponds to the JSON schema field "base64_encoded".
	Base64Encoded bool `json:"base64_encoded"`

	// Body corresponds to the JSON schema field "body".
	Body string `json:"body"`
}

type ResponseFinishedResult

type ResponseFinishedResult struct {
	// Error corresponds to the JSON schema field "error".
	Error *NavigationFinishedError `json:"error"`
}

type ResponseHeadersArrayResult

type ResponseHeadersArrayResult struct {
	// Headers corresponds to the JSON schema field "headers".
	Headers []NavigationHeader `json:"headers"`
}

type ResponseIDParams

type ResponseIDParams struct {
	// ResponseID corresponds to the JSON schema field "response_id".
	ResponseID string `json:"response_id"`
}

type ResponseSecurityDetailsResult

type ResponseSecurityDetailsResult struct {
	// Value corresponds to the JSON schema field "value".
	Value *NavigationSecurityDetails `json:"value"`
}

type ResponseServerAddrResult

type ResponseServerAddrResult struct {
	// Value corresponds to the JSON schema field "value".
	Value *NavigationServerAddr `json:"value"`
}

type RgbaColor

type RgbaColor struct {
	// A corresponds to the JSON schema field "a".
	A *float64 `json:"a,omitempty,omitzero"`

	// B corresponds to the JSON schema field "b".
	B float64 `json:"b"`

	// G corresponds to the JSON schema field "g".
	G float64 `json:"g"`

	// R corresponds to the JSON schema field "r".
	R float64 `json:"r"`
}

type ScreenshotOptions

type ScreenshotOptions struct {
	Animations     *PageScreenshotOptionsAnimations
	Caret          *PageScreenshotOptionsCaret
	Clip           *PageScreenshotClip
	FullPage       *bool
	Mask           []*PageLocator
	MaskColor      *string
	OmitBackground *bool
	Quality        *int
	Scale          *PageScreenshotOptionsScale
	Style          *string
	Timeout        *float64
	Type           *PageScreenshotOptionsType
}

ScreenshotOptions configures page screenshot capture. PageLocator wrappers never cross the JSON-RPC boundary.

type ScrollPercent

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

ScrollPercent is either a numeric scroll percentage or a server-supported string value.

func NamedScrollPercent

func NamedScrollPercent(value string) ScrollPercent

NamedScrollPercent constructs a string scroll percentage.

func NumericScrollPercent

func NumericScrollPercent(value float64) ScrollPercent

NumericScrollPercent constructs a numeric scroll percentage.

func (ScrollPercent) AsNumber

func (value ScrollPercent) AsNumber() (float64, bool)

AsNumber returns the numeric variant, if present.

func (ScrollPercent) AsString

func (value ScrollPercent) AsString() (string, bool)

AsString returns the string variant, if present.

func (ScrollPercent) MarshalJSON

func (value ScrollPercent) MarshalJSON() ([]byte, error)

func (*ScrollPercent) UnmarshalJSON

func (value *ScrollPercent) UnmarshalJSON(data []byte) error

type SnapshotResult

type SnapshotResult struct {
	// FormattedTree corresponds to the JSON schema field "formatted_tree".
	FormattedTree string `json:"formatted_tree"`

	// URLMap corresponds to the JSON schema field "url_map".
	URLMap SnapshotResultURLMap `json:"url_map"`

	// XPathMap corresponds to the JSON schema field "xpath_map".
	XPathMap SnapshotResultXPathMap `json:"xpath_map"`
}

type SnapshotResultURLMap

type SnapshotResultURLMap map[string]string

type SnapshotResultXPathMap

type SnapshotResultXPathMap map[string]string

type Stagehand

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

Stagehand is the root SDK client.

func Create

func Create(ctx context.Context, options CreateOptions) (*Stagehand, error)

Create attaches Stagehand to a factory-created Browser handle.

func (*Stagehand) Act

func (s *Stagehand) Act(
	ctx context.Context,
	instruction ActInstructionValue,
	options *StagehandClientActOptions,
) (ActResult, error)

Act performs an AI-guided action on the selected or active page.

func (*Stagehand) Browser

func (s *Stagehand) Browser() *Browser

Browser returns the factory-created browser handle attached to Stagehand.

func (*Stagehand) Close

func (s *Stagehand) Close(ctx context.Context) error

Close releases the remote Stagehand context without touching the Browser handle.

func (*Stagehand) ExperimentalBatch

func (s *Stagehand) ExperimentalBatch(
	ctx context.Context,
	source string,
	input any,
	result any,
	options ExperimentalBatchOptions,
) error

ExperimentalBatch runs trusted JavaScript against the worker-local public Stagehand object model.

func (*Stagehand) Initialized

func (s *Stagehand) Initialized() bool

Initialized reports whether Create completed successfully and the client remains open.

func (*Stagehand) Metrics

func (s *Stagehand) Metrics(ctx context.Context) (StagehandMetrics, error)

Metrics returns aggregate Stagehand operation metrics.

func (*Stagehand) Observe

func (s *Stagehand) Observe(
	ctx context.Context,
	instruction *string,
	options *StagehandClientObserveOptions,
) (ObserveResult, error)

Observe finds actions on the selected or active page.

type StagehandActParams

type StagehandActParams struct {
	// Instruction corresponds to the JSON schema field "instruction".
	Instruction ActInstructionValue `json:"instruction"`

	// Options corresponds to the JSON schema field "options".
	Options *ActOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type StagehandClientActOptions

type StagehandClientActOptions struct {
	Page           *Page
	Cache          *Caching
	Model          *ModelConfig
	Timeout        *float64
	Variables      Variables
	Locator        *PageLocator
	IgnoreLocators []*PageLocator
}

StagehandClientActOptions configures act calls. Page and PageLocator wrappers never cross the JSON-RPC boundary.

type StagehandClientExtractOptions

type StagehandClientExtractOptions struct {
	Page           *Page
	Cache          *Caching
	Model          *ModelConfig
	Screenshot     *bool
	Timeout        *float64
	Locator        *PageLocator
	IgnoreLocators []*PageLocator
}

StagehandClientExtractOptions configures extract calls. Page and PageLocator wrappers never cross the JSON-RPC boundary.

type StagehandClientLogFormat

type StagehandClientLogFormat string

StagehandClientLogFormat controls terminal rendering of runtime logs.

const (
	StagehandClientLogFormatPretty StagehandClientLogFormat = "pretty"
	StagehandClientLogFormatJSON   StagehandClientLogFormat = "json"
)

type StagehandClientLogLevel

type StagehandClientLogLevel string

StagehandClientLogLevel controls which runtime log notifications the SDK emits.

const (
	StagehandClientLogLevelOff   StagehandClientLogLevel = "off"
	StagehandClientLogLevelError StagehandClientLogLevel = "error"
	StagehandClientLogLevelWarn  StagehandClientLogLevel = "warn"
	StagehandClientLogLevelInfo  StagehandClientLogLevel = "info"
	StagehandClientLogLevelDebug StagehandClientLogLevel = "debug"
)

type StagehandClientLoggingConfig

type StagehandClientLoggingConfig struct {
	Level  StagehandClientLogLevel
	Format StagehandClientLogFormat
	OnLog  func(StagehandLog)
}

StagehandClientLoggingConfig controls client-side handling of runtime log notifications.

type StagehandClientObserveOptions

type StagehandClientObserveOptions struct {
	Page           *Page
	Cache          *Caching
	Model          *ModelConfig
	Timeout        *float64
	Variables      Variables
	Locator        *PageLocator
	IgnoreLocators []*PageLocator
}

StagehandClientObserveOptions configures observe calls. Page and PageLocator wrappers never cross the JSON-RPC boundary.

type StagehandCloseResult

type StagehandCloseResult struct {
	// Closed corresponds to the JSON schema field "closed".
	Closed bool `json:"closed"`
}

type StagehandExtractParams

type StagehandExtractParams struct {
	// Instruction corresponds to the JSON schema field "instruction".
	Instruction string `json:"instruction"`

	// Options corresponds to the JSON schema field "options".
	Options *ExtractOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`

	// Schema corresponds to the JSON schema field "schema".
	Schema json.RawMessage `json:"schema,omitempty,omitzero"`
}

type StagehandInitModel

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

StagehandInitModel is either a server model configuration or a reference to a model supplied by the client.

func ClientModel

func ClientModel() StagehandInitModel

ClientModel constructs a client-provided init model.

func ServerModel

func ServerModel(value ModelConfig) StagehandInitModel

ServerModel constructs a server-side init model.

func (StagehandInitModel) AsClientModel

func (value StagehandInitModel) AsClientModel() (ClientModelReference, bool)

AsClientModel returns the client model variant, if present.

func (StagehandInitModel) AsServerModel

func (value StagehandInitModel) AsServerModel() (ModelConfig, bool)

AsServerModel returns the server model variant, if present.

func (StagehandInitModel) MarshalJSON

func (value StagehandInitModel) MarshalJSON() ([]byte, error)

func (*StagehandInitModel) UnmarshalJSON

func (value *StagehandInitModel) UnmarshalJSON(data []byte) error

type StagehandInitParams

type StagehandInitParams struct {
	// APIKey corresponds to the JSON schema field "api_key".
	APIKey *string `json:"api_key,omitempty,omitzero"`

	// Stagehand API base URL override for managed services such as Model Gateway and
	// server-side caching
	APIURL *string `json:"api_url,omitempty,omitzero"`

	// Browser corresponds to the JSON schema field "browser".
	Browser *BrowserSessionMetadata `json:"browser,omitempty,omitzero"`

	// BrowserCDPURL corresponds to the JSON schema field "browser_cdp_url".
	BrowserCDPURL *string `json:"browser_cdp_url,omitempty,omitzero"`

	// Cache corresponds to the JSON schema field "cache".
	Cache *Caching `json:"cache,omitempty,omitzero"`

	// ClientInfo corresponds to the JSON schema field "client_info".
	ClientInfo ImplementationInfo `json:"client_info"`

	// DOMSettleTimeoutMs corresponds to the JSON schema field
	// "dom_settle_timeout_ms".
	DOMSettleTimeoutMs *int `json:"dom_settle_timeout_ms,omitempty,omitzero"`

	// LogLevel corresponds to the JSON schema field "log_level".
	LogLevel StagehandInitParamsLogLevel `json:"log_level,omitempty,omitzero"`

	// Model corresponds to the JSON schema field "model".
	Model *StagehandInitModel `json:"model,omitempty,omitzero"`

	// ProtocolVersion corresponds to the JSON schema field "protocol_version".
	ProtocolVersion string `json:"protocol_version"`

	// SelfHeal corresponds to the JSON schema field "self_heal".
	SelfHeal *bool `json:"self_heal,omitempty,omitzero"`

	// SystemPrompt corresponds to the JSON schema field "system_prompt".
	SystemPrompt *string `json:"system_prompt,omitempty,omitzero"`

	// Telemetry corresponds to the JSON schema field "telemetry".
	Telemetry TelemetryConfig `json:"telemetry,omitempty,omitzero"`
}

type StagehandInitParamsLogLevel

type StagehandInitParamsLogLevel string
const StagehandInitParamsLogLevelDebug StagehandInitParamsLogLevel = "debug"
const StagehandInitParamsLogLevelError StagehandInitParamsLogLevel = "error"
const StagehandInitParamsLogLevelInfo StagehandInitParamsLogLevel = "info"
const StagehandInitParamsLogLevelOff StagehandInitParamsLogLevel = "off"
const StagehandInitParamsLogLevelWarn StagehandInitParamsLogLevel = "warn"

type StagehandInitResult

type StagehandInitResult struct {
	// Initialized corresponds to the JSON schema field "initialized".
	Initialized bool `json:"initialized"`

	// Pages corresponds to the JSON schema field "pages".
	Pages []PageRef `json:"pages"`
}

type StagehandLog

type StagehandLog struct {
	// Data corresponds to the JSON schema field "data".
	Data StagehandLogData `json:"data"`

	// Level corresponds to the JSON schema field "level".
	Level StagehandLogLevel `json:"level"`

	// Message corresponds to the JSON schema field "message".
	Message string `json:"message"`
}

type StagehandLogData

type StagehandLogData map[string]json.RawMessage

type StagehandLogLevel

type StagehandLogLevel string
const StagehandLogLevelDebug StagehandLogLevel = "debug"
const StagehandLogLevelError StagehandLogLevel = "error"
const StagehandLogLevelInfo StagehandLogLevel = "info"
const StagehandLogLevelWarn StagehandLogLevel = "warn"

type StagehandMetrics

type StagehandMetrics struct {
	// ActCachedInputTokens corresponds to the JSON schema field
	// "act_cached_input_tokens".
	ActCachedInputTokens float64 `json:"act_cached_input_tokens"`

	// ActCompletionTokens corresponds to the JSON schema field
	// "act_completion_tokens".
	ActCompletionTokens float64 `json:"act_completion_tokens"`

	// ActInferenceTimeMs corresponds to the JSON schema field
	// "act_inference_time_ms".
	ActInferenceTimeMs float64 `json:"act_inference_time_ms"`

	// ActPromptTokens corresponds to the JSON schema field "act_prompt_tokens".
	ActPromptTokens float64 `json:"act_prompt_tokens"`

	// ActReasoningTokens corresponds to the JSON schema field "act_reasoning_tokens".
	ActReasoningTokens float64 `json:"act_reasoning_tokens"`

	// ExtractCachedInputTokens corresponds to the JSON schema field
	// "extract_cached_input_tokens".
	ExtractCachedInputTokens float64 `json:"extract_cached_input_tokens"`

	// ExtractCompletionTokens corresponds to the JSON schema field
	// "extract_completion_tokens".
	ExtractCompletionTokens float64 `json:"extract_completion_tokens"`

	// ExtractInferenceTimeMs corresponds to the JSON schema field
	// "extract_inference_time_ms".
	ExtractInferenceTimeMs float64 `json:"extract_inference_time_ms"`

	// ExtractPromptTokens corresponds to the JSON schema field
	// "extract_prompt_tokens".
	ExtractPromptTokens float64 `json:"extract_prompt_tokens"`

	// ExtractReasoningTokens corresponds to the JSON schema field
	// "extract_reasoning_tokens".
	ExtractReasoningTokens float64 `json:"extract_reasoning_tokens"`

	// ObserveCachedInputTokens corresponds to the JSON schema field
	// "observe_cached_input_tokens".
	ObserveCachedInputTokens float64 `json:"observe_cached_input_tokens"`

	// ObserveCompletionTokens corresponds to the JSON schema field
	// "observe_completion_tokens".
	ObserveCompletionTokens float64 `json:"observe_completion_tokens"`

	// ObserveInferenceTimeMs corresponds to the JSON schema field
	// "observe_inference_time_ms".
	ObserveInferenceTimeMs float64 `json:"observe_inference_time_ms"`

	// ObservePromptTokens corresponds to the JSON schema field
	// "observe_prompt_tokens".
	ObservePromptTokens float64 `json:"observe_prompt_tokens"`

	// ObserveReasoningTokens corresponds to the JSON schema field
	// "observe_reasoning_tokens".
	ObserveReasoningTokens float64 `json:"observe_reasoning_tokens"`

	// TotalCachedInputTokens corresponds to the JSON schema field
	// "total_cached_input_tokens".
	TotalCachedInputTokens float64 `json:"total_cached_input_tokens"`

	// TotalCompletionTokens corresponds to the JSON schema field
	// "total_completion_tokens".
	TotalCompletionTokens float64 `json:"total_completion_tokens"`

	// TotalInferenceTimeMs corresponds to the JSON schema field
	// "total_inference_time_ms".
	TotalInferenceTimeMs float64 `json:"total_inference_time_ms"`

	// TotalPromptTokens corresponds to the JSON schema field "total_prompt_tokens".
	TotalPromptTokens float64 `json:"total_prompt_tokens"`

	// TotalReasoningTokens corresponds to the JSON schema field
	// "total_reasoning_tokens".
	TotalReasoningTokens float64 `json:"total_reasoning_tokens"`
}

type StagehandObserveParams

type StagehandObserveParams struct {
	// Instruction corresponds to the JSON schema field "instruction".
	Instruction *string `json:"instruction,omitempty,omitzero"`

	// Options corresponds to the JSON schema field "options".
	Options *ObserveOptions `json:"options,omitempty,omitzero"`

	// PageID corresponds to the JSON schema field "page_id".
	PageID string `json:"page_id"`
}

type StagehandResultMetadata

type StagehandResultMetadata struct {
	// Action ID for tracking
	ActionID *string `json:"action_id,omitempty,omitzero"`

	// Cache observability for this result; status is DISABLED when no cache lookup
	// ran
	Cache CacheMetadata `json:"cache"`

	// Aggregate LLM usage for this operation; zeroed when the operation did not run
	// inference
	Usage StagehandResultUsage `json:"usage"`
}

type StagehandResultUsage

type StagehandResultUsage struct {
	// Cached input tokens used by all LLM calls made for this operation
	CachedInputTokens int `json:"cached_input_tokens,omitempty,omitzero"`

	// Total time spent waiting for LLM inference during this operation
	InferenceTimeMs int `json:"inference_time_ms,omitempty,omitzero"`

	// Input tokens consumed by all LLM calls made for this operation
	InputTokens int `json:"input_tokens,omitempty,omitzero"`

	// Output tokens consumed by all LLM calls made for this operation
	OutputTokens int `json:"output_tokens,omitempty,omitzero"`

	// Reasoning tokens consumed by all LLM calls made for this operation
	ReasoningTokens int `json:"reasoning_tokens,omitempty,omitzero"`
}

Aggregate LLM usage for one Stagehand operation

type StringList

type StringList []string

StringList accepts either a single JSON string or an array of strings and always marshals as an array.

func (StringList) MarshalJSON

func (values StringList) MarshalJSON() ([]byte, error)

func (*StringList) UnmarshalJSON

func (values *StringList) UnmarshalJSON(data []byte) error

type TelemetryConfig

type TelemetryConfig struct {
	// Traces corresponds to the JSON schema field "traces".
	Traces TelemetryTraces `json:"traces"`
}

type TelemetryTraces

type TelemetryTraces struct {
	// Endpoint corresponds to the JSON schema field "endpoint".
	Endpoint string `json:"endpoint"`

	// Headers corresponds to the JSON schema field "headers".
	Headers TelemetryTracesHeaders `json:"headers,omitempty,omitzero"`
}

type TelemetryTracesHeaders

type TelemetryTracesHeaders map[string]string

type TypedExtractResult

type TypedExtractResult[T any] struct {
	Data     T                       `json:"data"`
	Metadata StagehandResultMetadata `json:"metadata"`
}

TypedExtractResult contains caller-decoded extract data and its protocol metadata.

func Extract

func Extract[T any](
	ctx context.Context,
	client *Stagehand,
	instruction string,
	options *StagehandClientExtractOptions,
) (TypedExtractResult[T], error)

Extract derives a JSON Schema from T, extracts matching data from the selected or active page, and decodes the result into T.

type VariablePrimitive

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

VariablePrimitive is a string, number, or boolean variable value.

func BoolVariable

func BoolVariable(value bool) VariablePrimitive

BoolVariable constructs a boolean variable primitive.

func NumberVariable

func NumberVariable(value float64) VariablePrimitive

NumberVariable constructs a numeric variable primitive.

func StringVariable

func StringVariable(value string) VariablePrimitive

StringVariable constructs a string variable primitive.

func (VariablePrimitive) AsBool

func (value VariablePrimitive) AsBool() (bool, bool)

AsBool returns the boolean variant, if present.

func (VariablePrimitive) AsNumber

func (value VariablePrimitive) AsNumber() (float64, bool)

AsNumber returns the number variant, if present.

func (VariablePrimitive) AsString

func (value VariablePrimitive) AsString() (string, bool)

AsString returns the string variant, if present.

func (VariablePrimitive) MarshalJSON

func (value VariablePrimitive) MarshalJSON() ([]byte, error)

func (*VariablePrimitive) UnmarshalJSON

func (value *VariablePrimitive) UnmarshalJSON(data []byte) error

type VariableValue

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

VariableValue is either a primitive or a described variable.

func DescribedVariable

func DescribedVariable(value DescribedVariableValue) VariableValue

DescribedVariable constructs a described variable value.

func PrimitiveVariable

func PrimitiveVariable(value VariablePrimitive) VariableValue

PrimitiveVariable constructs a primitive variable value.

func (VariableValue) AsDescribed

func (value VariableValue) AsDescribed() (DescribedVariableValue, bool)

AsDescribed returns the described variant, if present.

func (VariableValue) AsPrimitive

func (value VariableValue) AsPrimitive() (VariablePrimitive, bool)

AsPrimitive returns the primitive variant, if present.

func (VariableValue) MarshalJSON

func (value VariableValue) MarshalJSON() ([]byte, error)

func (*VariableValue) UnmarshalJSON

func (value *VariableValue) UnmarshalJSON(data []byte) error

type Variables

type Variables map[string]VariableValue

type WebMCPAnnotation

type WebMCPAnnotation struct {
	// Autosubmit corresponds to the JSON schema field "autosubmit".
	Autosubmit *bool `json:"autosubmit,omitempty,omitzero"`

	// ReadOnly corresponds to the JSON schema field "read_only".
	ReadOnly *bool `json:"read_only,omitempty,omitzero"`

	// UntrustedContent corresponds to the JSON schema field "untrusted_content".
	UntrustedContent *bool `json:"untrusted_content,omitempty,omitzero"`
}

type WebMCPInput

type WebMCPInput map[string]any

WebMCPInput is JSON input passed to a page-provided WebMCP tool.

type WebMCPInvocation

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

WebMCPInvocation is a page-bound handle for an invocation accepted by Chrome.

func (*WebMCPInvocation) Cancel

func (i *WebMCPInvocation) Cancel(ctx context.Context) error

Cancel requests cancellation without changing the invocation's terminal result locally.

func (*WebMCPInvocation) Descriptor

Descriptor returns the generated wire descriptor for the invocation.

func (*WebMCPInvocation) Result

Result waits for Chrome's authoritative terminal invocation response. Successful waits are cached; context and RPC failures can be retried.

type WebMCPInvocationDescriptor

type WebMCPInvocationDescriptor struct {
	// FrameID corresponds to the JSON schema field "frame_id".
	FrameID string `json:"frame_id"`

	// Input corresponds to the JSON schema field "input".
	Input WebMCPInvocationDescriptorInput `json:"input"`

	// InvocationID corresponds to the JSON schema field "invocation_id".
	InvocationID string `json:"invocation_id"`

	// ToolName corresponds to the JSON schema field "tool_name".
	ToolName string `json:"tool_name"`
}

type WebMCPInvocationDescriptorInput

type WebMCPInvocationDescriptorInput map[string]json.RawMessage

type WebMCPInvocationStatus

type WebMCPInvocationStatus string
const WebMCPInvocationStatusCanceled WebMCPInvocationStatus = "Canceled"
const WebMCPInvocationStatusCompleted WebMCPInvocationStatus = "Completed"
const WebMCPInvocationStatusError WebMCPInvocationStatus = "Error"

type WebMCPRemoteObject

type WebMCPRemoteObject map[string]json.RawMessage

type WebMCPResultOptions

type WebMCPResultOptions struct {
	// Timeout corresponds to the JSON schema field "timeout".
	Timeout *float64 `json:"timeout,omitempty,omitzero"`
}

type WebMCPTool

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

WebMCPTool is a page-bound wrapper around a discovered WebMCP tool.

func (*WebMCPTool) Descriptor

func (t *WebMCPTool) Descriptor() WebMCPToolDescriptor

Descriptor returns the generated wire descriptor for the tool.

func (*WebMCPTool) Invoke

func (t *WebMCPTool) Invoke(
	ctx context.Context,
	input WebMCPInput,
) (*WebMCPInvocation, error)

Invoke invokes the tool using the page, frame, and name it already owns. A nil input is sent as an empty JSON object.

type WebMCPToolDescriptor

type WebMCPToolDescriptor struct {
	// Annotations corresponds to the JSON schema field "annotations".
	Annotations *WebMCPAnnotation `json:"annotations,omitempty,omitzero"`

	// BackendNodeID corresponds to the JSON schema field "backend_node_id".
	BackendNodeID *int `json:"backend_node_id,omitempty,omitzero"`

	// Description corresponds to the JSON schema field "description".
	Description string `json:"description"`

	// FrameID corresponds to the JSON schema field "frame_id".
	FrameID string `json:"frame_id"`

	// InputSchema corresponds to the JSON schema field "input_schema".
	InputSchema WebMCPToolDescriptorInputSchema `json:"input_schema,omitempty,omitzero"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`
}

type WebMCPToolDescriptorInputSchema

type WebMCPToolDescriptorInputSchema map[string]json.RawMessage

type WebMCPToolResponse

type WebMCPToolResponse struct {
	// ErrorText corresponds to the JSON schema field "error_text".
	ErrorText *string `json:"error_text,omitempty,omitzero"`

	// Exception corresponds to the JSON schema field "exception".
	Exception WebMCPRemoteObject `json:"exception,omitempty,omitzero"`

	// InvocationID corresponds to the JSON schema field "invocation_id".
	InvocationID string `json:"invocation_id"`

	// Output corresponds to the JSON schema field "output".
	Output json.RawMessage `json:"output,omitempty,omitzero"`

	// Status corresponds to the JSON schema field "status".
	Status WebMCPInvocationStatus `json:"status"`
}

type WebMCPToolsOptions

type WebMCPToolsOptions struct {
	// Timeout corresponds to the JSON schema field "timeout".
	Timeout float64 `json:"timeout,omitempty,omitzero"`
}

Directories

Path Synopsis
internal
extensionassets
Package extensionassets exposes the Stagehand extension bundled into the Go module.
Package extensionassets exposes the Stagehand extension bundled into the Go module.
extensionpack command
Command extensionpack synchronizes the deterministic extension build into the Go module, where go:embed can include it for consumers.
Command extensionpack synchronizes the deterministic extension build into the Go module, where go:embed can include it for consumers.

Jump to

Keyboard shortcuts

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