Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type Action
- type ActionParam
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type Error
- type ModelConfigParam
- type ModelConfigProvider
- type SessionActParams
- type SessionActParamsInputUnion
- type SessionActParamsOptions
- type SessionActParamsXStreamResponse
- type SessionActResponse
- type SessionEndResponse
- type SessionExecuteAgentParams
- type SessionExecuteAgentParamsAgentConfig
- type SessionExecuteAgentParamsAgentConfigModelUnion
- type SessionExecuteAgentParamsExecuteOptions
- type SessionExecuteAgentParamsXStreamResponse
- type SessionExecuteAgentResponse
- type SessionExtractParams
- type SessionExtractParamsOptions
- type SessionExtractParamsXStreamResponse
- type SessionExtractResponseExtraction
- type SessionExtractResponseUnion
- func (u SessionExtractResponseUnion) AsCustom() (v map[string]any)
- func (u SessionExtractResponseUnion) AsSessionExtractResponseExtraction() (v SessionExtractResponseExtraction)
- func (u SessionExtractResponseUnion) RawJSON() string
- func (r *SessionExtractResponseUnion) UnmarshalJSON(data []byte) error
- type SessionNavigateParams
- type SessionNavigateParamsOptions
- type SessionNavigateParamsXStreamResponse
- type SessionNavigateResponse
- type SessionObserveParams
- type SessionObserveParamsOptions
- type SessionObserveParamsXStreamResponse
- type SessionService
- func (r *SessionService) Act(ctx context.Context, sessionID string, params SessionActParams, ...) (res *SessionActResponse, err error)
- func (r *SessionService) End(ctx context.Context, sessionID string, opts ...option.RequestOption) (res *SessionEndResponse, err error)
- func (r *SessionService) ExecuteAgent(ctx context.Context, sessionID string, params SessionExecuteAgentParams, ...) (res *SessionExecuteAgentResponse, err error)
- func (r *SessionService) Extract(ctx context.Context, sessionID string, params SessionExtractParams, ...) (res *SessionExtractResponseUnion, err error)
- func (r *SessionService) Navigate(ctx context.Context, sessionID string, params SessionNavigateParams, ...) (res *SessionNavigateResponse, err error)
- func (r *SessionService) Observe(ctx context.Context, sessionID string, params SessionObserveParams, ...) (res *[]Action, err error)
- func (r *SessionService) Start(ctx context.Context, body SessionStartParams, opts ...option.RequestOption) (res *SessionStartResponse, err error)
- type SessionStartParams
- type SessionStartResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (STAGEHAND_API_KEY, STAGEHAND_BASE_URL). This should be used to initialize new clients.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type Action ¶
type Action struct {
// Arguments for the method
Arguments []string `json:"arguments,required"`
// Human-readable description of the action
Description string `json:"description,required"`
// Method to execute (e.g., "click", "fill")
Method string `json:"method,required"`
// CSS or XPath selector for the element
Selector string `json:"selector,required"`
// CDP backend node ID
BackendNodeID int64 `json:"backendNodeId"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Arguments respjson.Field
Description respjson.Field
Method respjson.Field
Selector respjson.Field
BackendNodeID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (Action) ToParam ¶
func (r Action) ToParam() ActionParam
ToParam converts this Action to a ActionParam.
Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ActionParam.Overrides()
func (*Action) UnmarshalJSON ¶
type ActionParam ¶
type ActionParam struct {
// Arguments for the method
Arguments []string `json:"arguments,omitzero,required"`
// Human-readable description of the action
Description string `json:"description,required"`
// Method to execute (e.g., "click", "fill")
Method string `json:"method,required"`
// CSS or XPath selector for the element
Selector string `json:"selector,required"`
// CDP backend node ID
BackendNodeID param.Opt[int64] `json:"backendNodeId,omitzero"`
// contains filtered or unexported fields
}
The properties Arguments, Description, Method, Selector are required.
func (ActionParam) MarshalJSON ¶
func (r ActionParam) MarshalJSON() (data []byte, err error)
func (*ActionParam) UnmarshalJSON ¶
func (r *ActionParam) UnmarshalJSON(data []byte) error
type Client ¶
type Client struct {
Options []option.RequestOption
Sessions SessionService
}
Client creates a struct with services and top level methods that help with interacting with the stagehand API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default option read from the environment (STAGEHAND_API_KEY, STAGEHAND_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type ModelConfigParam ¶
type ModelConfigParam struct {
// API key for the model provider
APIKey param.Opt[string] `json:"apiKey,omitzero"`
// Custom base URL for API
BaseURL param.Opt[string] `json:"baseURL,omitzero" format:"uri"`
// Model name
Model param.Opt[string] `json:"model,omitzero"`
// Any of "openai", "anthropic", "google".
Provider ModelConfigProvider `json:"provider,omitzero"`
// contains filtered or unexported fields
}
func (ModelConfigParam) MarshalJSON ¶
func (r ModelConfigParam) MarshalJSON() (data []byte, err error)
func (*ModelConfigParam) UnmarshalJSON ¶
func (r *ModelConfigParam) UnmarshalJSON(data []byte) error
type ModelConfigProvider ¶
type ModelConfigProvider string
const ( ModelConfigProviderOpenAI ModelConfigProvider = "openai" ModelConfigProviderAnthropic ModelConfigProvider = "anthropic" ModelConfigProviderGoogle ModelConfigProvider = "google" )
type SessionActParams ¶
type SessionActParams struct {
// Natural language instruction
Input SessionActParamsInputUnion `json:"input,omitzero,required"`
// Frame ID to act on (optional)
FrameID param.Opt[string] `json:"frameId,omitzero"`
Options SessionActParamsOptions `json:"options,omitzero"`
// Any of "true", "false".
XStreamResponse SessionActParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (SessionActParams) MarshalJSON ¶
func (r SessionActParams) MarshalJSON() (data []byte, err error)
func (*SessionActParams) UnmarshalJSON ¶
func (r *SessionActParams) UnmarshalJSON(data []byte) error
type SessionActParamsInputUnion ¶
type SessionActParamsInputUnion struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfAction *ActionParam `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func (SessionActParamsInputUnion) MarshalJSON ¶
func (u SessionActParamsInputUnion) MarshalJSON() ([]byte, error)
func (*SessionActParamsInputUnion) UnmarshalJSON ¶
func (u *SessionActParamsInputUnion) UnmarshalJSON(data []byte) error
type SessionActParamsOptions ¶
type SessionActParamsOptions struct {
// Timeout in milliseconds
Timeout param.Opt[int64] `json:"timeout,omitzero"`
Model ModelConfigParam `json:"model,omitzero"`
// Template variables for instruction
Variables map[string]string `json:"variables,omitzero"`
// contains filtered or unexported fields
}
func (SessionActParamsOptions) MarshalJSON ¶
func (r SessionActParamsOptions) MarshalJSON() (data []byte, err error)
func (*SessionActParamsOptions) UnmarshalJSON ¶
func (r *SessionActParamsOptions) UnmarshalJSON(data []byte) error
type SessionActParamsXStreamResponse ¶
type SessionActParamsXStreamResponse string
const ( SessionActParamsXStreamResponseTrue SessionActParamsXStreamResponse = "true" SessionActParamsXStreamResponseFalse SessionActParamsXStreamResponse = "false" )
type SessionActResponse ¶
type SessionActResponse struct {
// Actions that were executed
Actions []Action `json:"actions,required"`
// Result message
Message string `json:"message,required"`
// Whether the action succeeded
Success bool `json:"success,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Actions respjson.Field
Message respjson.Field
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SessionActResponse) RawJSON ¶
func (r SessionActResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionActResponse) UnmarshalJSON ¶
func (r *SessionActResponse) UnmarshalJSON(data []byte) error
type SessionEndResponse ¶
type SessionEndResponse struct {
Success bool `json:"success"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SessionEndResponse) RawJSON ¶
func (r SessionEndResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionEndResponse) UnmarshalJSON ¶
func (r *SessionEndResponse) UnmarshalJSON(data []byte) error
type SessionExecuteAgentParams ¶
type SessionExecuteAgentParams struct {
AgentConfig SessionExecuteAgentParamsAgentConfig `json:"agentConfig,omitzero,required"`
ExecuteOptions SessionExecuteAgentParamsExecuteOptions `json:"executeOptions,omitzero,required"`
FrameID param.Opt[string] `json:"frameId,omitzero"`
// Any of "true", "false".
XStreamResponse SessionExecuteAgentParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (SessionExecuteAgentParams) MarshalJSON ¶
func (r SessionExecuteAgentParams) MarshalJSON() (data []byte, err error)
func (*SessionExecuteAgentParams) UnmarshalJSON ¶
func (r *SessionExecuteAgentParams) UnmarshalJSON(data []byte) error
type SessionExecuteAgentParamsAgentConfig ¶
type SessionExecuteAgentParamsAgentConfig struct {
// Enable Computer Use Agent mode
Cua param.Opt[bool] `json:"cua,omitzero"`
SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
Model SessionExecuteAgentParamsAgentConfigModelUnion `json:"model,omitzero"`
// Any of "openai", "anthropic", "google".
Provider string `json:"provider,omitzero"`
// contains filtered or unexported fields
}
func (SessionExecuteAgentParamsAgentConfig) MarshalJSON ¶
func (r SessionExecuteAgentParamsAgentConfig) MarshalJSON() (data []byte, err error)
func (*SessionExecuteAgentParamsAgentConfig) UnmarshalJSON ¶
func (r *SessionExecuteAgentParamsAgentConfig) UnmarshalJSON(data []byte) error
type SessionExecuteAgentParamsAgentConfigModelUnion ¶
type SessionExecuteAgentParamsAgentConfigModelUnion struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfModelConfig *ModelConfigParam `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func (SessionExecuteAgentParamsAgentConfigModelUnion) MarshalJSON ¶
func (u SessionExecuteAgentParamsAgentConfigModelUnion) MarshalJSON() ([]byte, error)
func (*SessionExecuteAgentParamsAgentConfigModelUnion) UnmarshalJSON ¶
func (u *SessionExecuteAgentParamsAgentConfigModelUnion) UnmarshalJSON(data []byte) error
type SessionExecuteAgentParamsExecuteOptions ¶
type SessionExecuteAgentParamsExecuteOptions struct {
// Task for the agent to complete
Instruction string `json:"instruction,required"`
// Visually highlight the cursor during actions
HighlightCursor param.Opt[bool] `json:"highlightCursor,omitzero"`
// Maximum number of steps the agent can take
MaxSteps param.Opt[int64] `json:"maxSteps,omitzero"`
// contains filtered or unexported fields
}
The property Instruction is required.
func (SessionExecuteAgentParamsExecuteOptions) MarshalJSON ¶
func (r SessionExecuteAgentParamsExecuteOptions) MarshalJSON() (data []byte, err error)
func (*SessionExecuteAgentParamsExecuteOptions) UnmarshalJSON ¶
func (r *SessionExecuteAgentParamsExecuteOptions) UnmarshalJSON(data []byte) error
type SessionExecuteAgentParamsXStreamResponse ¶
type SessionExecuteAgentParamsXStreamResponse string
const ( SessionExecuteAgentParamsXStreamResponseTrue SessionExecuteAgentParamsXStreamResponse = "true" SessionExecuteAgentParamsXStreamResponseFalse SessionExecuteAgentParamsXStreamResponse = "false" )
type SessionExecuteAgentResponse ¶
type SessionExecuteAgentResponse struct {
// Final message from the agent
Message string `json:"message"`
// Steps taken by the agent
Steps []any `json:"steps"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Message respjson.Field
Steps respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SessionExecuteAgentResponse) RawJSON ¶
func (r SessionExecuteAgentResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionExecuteAgentResponse) UnmarshalJSON ¶
func (r *SessionExecuteAgentResponse) UnmarshalJSON(data []byte) error
type SessionExtractParams ¶
type SessionExtractParams struct {
// Frame ID to extract from
FrameID param.Opt[string] `json:"frameId,omitzero"`
// Natural language instruction for extraction
Instruction param.Opt[string] `json:"instruction,omitzero"`
Options SessionExtractParamsOptions `json:"options,omitzero"`
// JSON Schema for structured output
Schema map[string]any `json:"schema,omitzero"`
// Any of "true", "false".
XStreamResponse SessionExtractParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (SessionExtractParams) MarshalJSON ¶
func (r SessionExtractParams) MarshalJSON() (data []byte, err error)
func (*SessionExtractParams) UnmarshalJSON ¶
func (r *SessionExtractParams) UnmarshalJSON(data []byte) error
type SessionExtractParamsOptions ¶
type SessionExtractParamsOptions struct {
// Extract only from elements matching this selector
Selector param.Opt[string] `json:"selector,omitzero"`
Timeout param.Opt[int64] `json:"timeout,omitzero"`
Model ModelConfigParam `json:"model,omitzero"`
// contains filtered or unexported fields
}
func (SessionExtractParamsOptions) MarshalJSON ¶
func (r SessionExtractParamsOptions) MarshalJSON() (data []byte, err error)
func (*SessionExtractParamsOptions) UnmarshalJSON ¶
func (r *SessionExtractParamsOptions) UnmarshalJSON(data []byte) error
type SessionExtractParamsXStreamResponse ¶
type SessionExtractParamsXStreamResponse string
const ( SessionExtractParamsXStreamResponseTrue SessionExtractParamsXStreamResponse = "true" SessionExtractParamsXStreamResponseFalse SessionExtractParamsXStreamResponse = "false" )
type SessionExtractResponseExtraction ¶
type SessionExtractResponseExtraction struct {
Extraction string `json:"extraction"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Extraction respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Default extraction result
func (SessionExtractResponseExtraction) RawJSON ¶
func (r SessionExtractResponseExtraction) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionExtractResponseExtraction) UnmarshalJSON ¶
func (r *SessionExtractResponseExtraction) UnmarshalJSON(data []byte) error
type SessionExtractResponseUnion ¶
type SessionExtractResponseUnion struct {
// This field will be present if the value is a [any] instead of an object.
OfSessionExtractResponseCustomItem any `json:",inline"`
// This field is from variant [SessionExtractResponseExtraction].
Extraction string `json:"extraction"`
JSON struct {
OfSessionExtractResponseCustomItem respjson.Field
Extraction respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
SessionExtractResponseUnion contains all possible properties and values from SessionExtractResponseExtraction, [map[string]any].
Use the methods beginning with 'As' to cast the union to one of its variants.
If the underlying value is not a json object, one of the following properties will be valid: OfSessionExtractResponseCustomItem]
func (SessionExtractResponseUnion) AsCustom ¶
func (u SessionExtractResponseUnion) AsCustom() (v map[string]any)
func (SessionExtractResponseUnion) AsSessionExtractResponseExtraction ¶
func (u SessionExtractResponseUnion) AsSessionExtractResponseExtraction() (v SessionExtractResponseExtraction)
func (SessionExtractResponseUnion) RawJSON ¶
func (u SessionExtractResponseUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionExtractResponseUnion) UnmarshalJSON ¶
func (r *SessionExtractResponseUnion) UnmarshalJSON(data []byte) error
type SessionNavigateParams ¶
type SessionNavigateParams struct {
// URL to navigate to
XStreamResponse SessionNavigateParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (SessionNavigateParams) MarshalJSON ¶
func (r SessionNavigateParams) MarshalJSON() (data []byte, err error)
func (*SessionNavigateParams) UnmarshalJSON ¶
func (r *SessionNavigateParams) UnmarshalJSON(data []byte) error
type SessionNavigateParamsOptions ¶
type SessionNavigateParamsOptions struct {
//
// Any of "load", "domcontentloaded", "networkidle".
WaitUntil string `json:"waitUntil,omitzero"`
// contains filtered or unexported fields
}
func (SessionNavigateParamsOptions) MarshalJSON ¶
func (r SessionNavigateParamsOptions) MarshalJSON() (data []byte, err error)
func (*SessionNavigateParamsOptions) UnmarshalJSON ¶
func (r *SessionNavigateParamsOptions) UnmarshalJSON(data []byte) error
type SessionNavigateParamsXStreamResponse ¶
type SessionNavigateParamsXStreamResponse string
const ( )
type SessionNavigateResponse ¶
type SessionNavigateResponse struct {
JSON struct {
Ok respjson.Field
Status respjson.Field
URL respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Navigation response (may be null)
func (SessionNavigateResponse) RawJSON ¶
func (r SessionNavigateResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionNavigateResponse) UnmarshalJSON ¶
func (r *SessionNavigateResponse) UnmarshalJSON(data []byte) error
type SessionObserveParams ¶
type SessionObserveParams struct {
// Frame ID to observe
FrameID param.Opt[string] `json:"frameId,omitzero"`
// Natural language instruction to filter actions
Instruction param.Opt[string] `json:"instruction,omitzero"`
Options SessionObserveParamsOptions `json:"options,omitzero"`
// Any of "true", "false".
XStreamResponse SessionObserveParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (SessionObserveParams) MarshalJSON ¶
func (r SessionObserveParams) MarshalJSON() (data []byte, err error)
func (*SessionObserveParams) UnmarshalJSON ¶
func (r *SessionObserveParams) UnmarshalJSON(data []byte) error
type SessionObserveParamsOptions ¶
type SessionObserveParamsOptions struct {
// Observe only elements matching this selector
Selector param.Opt[string] `json:"selector,omitzero"`
Timeout param.Opt[int64] `json:"timeout,omitzero"`
Model ModelConfigParam `json:"model,omitzero"`
// contains filtered or unexported fields
}
func (SessionObserveParamsOptions) MarshalJSON ¶
func (r SessionObserveParamsOptions) MarshalJSON() (data []byte, err error)
func (*SessionObserveParamsOptions) UnmarshalJSON ¶
func (r *SessionObserveParamsOptions) UnmarshalJSON(data []byte) error
type SessionObserveParamsXStreamResponse ¶
type SessionObserveParamsXStreamResponse string
const ( SessionObserveParamsXStreamResponseTrue SessionObserveParamsXStreamResponse = "true" SessionObserveParamsXStreamResponseFalse SessionObserveParamsXStreamResponse = "false" )
type SessionService ¶
type SessionService struct {
Options []option.RequestOption
}
SessionService contains methods and other services that help with interacting with the stagehand API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSessionService method instead.
func NewSessionService ¶
func NewSessionService(opts ...option.RequestOption) (r SessionService)
NewSessionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*SessionService) Act ¶
func (r *SessionService) Act(ctx context.Context, sessionID string, params SessionActParams, opts ...option.RequestOption) (res *SessionActResponse, err error)
Performs a browser action based on natural language instruction or a specific action object returned by observe().
func (*SessionService) End ¶
func (r *SessionService) End(ctx context.Context, sessionID string, opts ...option.RequestOption) (res *SessionEndResponse, err error)
Closes the browser and cleans up all resources associated with the session.
func (*SessionService) ExecuteAgent ¶
func (r *SessionService) ExecuteAgent(ctx context.Context, sessionID string, params SessionExecuteAgentParams, opts ...option.RequestOption) (res *SessionExecuteAgentResponse, err error)
Runs an autonomous agent that can perform multiple actions to complete a complex task.
func (*SessionService) Extract ¶
func (r *SessionService) Extract(ctx context.Context, sessionID string, params SessionExtractParams, opts ...option.RequestOption) (res *SessionExtractResponseUnion, err error)
Extracts data from the current page using natural language instructions and optional JSON schema for structured output.
func (*SessionService) Navigate ¶
func (r *SessionService) Navigate(ctx context.Context, sessionID string, params SessionNavigateParams, opts ...option.RequestOption) (res *SessionNavigateResponse, err error)
Navigates the browser to the specified URL and waits for page load.
func (*SessionService) Observe ¶
func (r *SessionService) Observe(ctx context.Context, sessionID string, params SessionObserveParams, opts ...option.RequestOption) (res *[]Action, err error)
Returns a list of candidate actions that can be performed on the page, optionally filtered by natural language instruction.
func (*SessionService) Start ¶
func (r *SessionService) Start(ctx context.Context, body SessionStartParams, opts ...option.RequestOption) (res *SessionStartResponse, err error)
Initializes a new Stagehand session with a browser instance. Returns a session ID that must be used for all subsequent requests.
type SessionStartParams ¶
type SessionStartParams struct {
// API key for Browserbase Cloud
BrowserbaseAPIKey string `json:"BROWSERBASE_API_KEY,required"`
// Project ID for Browserbase
BrowserbaseProjectID string `json:"BROWSERBASE_PROJECT_ID,required"`
// Timeout in ms to wait for DOM to settle
DomSettleTimeout param.Opt[int64] `json:"domSettleTimeout,omitzero"`
// AI model to use for actions (must be prefixed with provider/)
Model param.Opt[string] `json:"model,omitzero"`
// Enable self-healing for failed actions
SelfHeal param.Opt[bool] `json:"selfHeal,omitzero"`
// Custom system prompt for AI actions
SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
// Logging verbosity level
Verbose param.Opt[int64] `json:"verbose,omitzero"`
// contains filtered or unexported fields
}
func (SessionStartParams) MarshalJSON ¶
func (r SessionStartParams) MarshalJSON() (data []byte, err error)
func (*SessionStartParams) UnmarshalJSON ¶
func (r *SessionStartParams) UnmarshalJSON(data []byte) error
type SessionStartResponse ¶
type SessionStartResponse struct {
// Whether the session is ready to use
Available bool `json:"available,required"`
// Unique identifier for the session
SessionID string `json:"sessionId,required" format:"uuid"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Available respjson.Field
SessionID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SessionStartResponse) RawJSON ¶
func (r SessionStartResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SessionStartResponse) UnmarshalJSON ¶
func (r *SessionStartResponse) UnmarshalJSON(data []byte) error
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
shared
|
|