stagehand

package module
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

README

Stagehand Go API Library

Go Reference

The Stagehand Go library provides convenient access to the Stagehand REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/browserbase/stagehand-go" // imported as stagehand
)

Or to pin the version:

go get -u 'github.com/browserbase/stagehand-go@v0.13.1'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/browserbase/stagehand-go"
	"github.com/browserbase/stagehand-go/option"
)

func main() {
	client := stagehand.NewClient(
		option.WithBrowserbaseAPIKey("My Browserbase API Key"),       // defaults to os.LookupEnv("BROWSERBASE_API_KEY")
		option.WithBrowserbaseProjectID("My Browserbase Project ID"), // defaults to os.LookupEnv("BROWSERBASE_PROJECT_ID")
		option.WithModelAPIKey("My Model API Key"),                   // defaults to os.LookupEnv("MODEL_API_KEY")
	)
	response, err := client.Sessions.Act(
		context.TODO(),
		"00000000-your-session-id-000000000000",
		stagehand.SessionActParams{
			Input: stagehand.SessionActParamsInputUnion{
				OfString: stagehand.String("click the first link on the page"),
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", response.Data)
}

Request fields

The stagehand library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, stagehand.String(string), stagehand.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := stagehand.ExampleParams{
	ID:   "id_xxx",                // required property
	Name: stagehand.String("..."), // optional property

	Point: stagehand.Point{
		X: 0,                // required field will serialize as 0
		Y: stagehand.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: stagehand.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[stagehand.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := stagehand.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Sessions.Start(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *stagehand.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
	ModelName: "openai/gpt-5-nano",
})
if err != nil {
	var apierr *stagehand.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v1/sessions/start": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Sessions.Start(
	ctx,
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper stagehand.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := stagehand.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Sessions.Start(
	context.TODO(),
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
response, err := client.Sessions.Start(
	context.TODO(),
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: stagehand.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := stagehand.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (BROWSERBASE_API_KEY, MODEL_API_KEY, BROWSERBASE_PROJECT_ID, STAGEHAND_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type Action

type Action struct {
	// Human-readable description of the action
	Description string `json:"description,required"`
	// CSS selector or XPath for the element
	Selector string `json:"selector,required"`
	// Arguments to pass to the method
	Arguments []string `json:"arguments"`
	// The method to execute (click, fill, etc.)
	Method string `json:"method"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description respjson.Field
		Selector    respjson.Field
		Arguments   respjson.Field
		Method      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Action object returned by observe and used by act

func (Action) RawJSON

func (r Action) RawJSON() string

Returns the unmodified JSON received from the API

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

func (r *Action) UnmarshalJSON(data []byte) error

type ActionParam

type ActionParam struct {
	// Human-readable description of the action
	Description string `json:"description,required"`
	// CSS selector or XPath for the element
	Selector string `json:"selector,required"`
	// The method to execute (click, fill, etc.)
	Method param.Opt[string] `json:"method,omitzero"`
	// Arguments to pass to the method
	Arguments []string `json:"arguments,omitzero"`
	// contains filtered or unexported fields
}

Action object returned by observe and used by act

The properties Description, 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 (BROWSERBASE_API_KEY, MODEL_API_KEY, BROWSERBASE_PROJECT_ID, 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.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Error

type Error = apierror.Error

type ModelConfigModelConfigObjectParam added in v0.11.0

type ModelConfigModelConfigObjectParam struct {
	// Model name string without prefix (e.g., 'gpt-5-nano', 'claude-4.5-opus')
	ModelName string `json:"modelName,required"`
	// API key for the model provider
	APIKey param.Opt[string] `json:"apiKey,omitzero"`
	// Base URL for the model provider
	BaseURL param.Opt[string] `json:"baseURL,omitzero" format:"uri"`
	// contains filtered or unexported fields
}

The property ModelName is required.

func (ModelConfigModelConfigObjectParam) MarshalJSON added in v0.11.0

func (r ModelConfigModelConfigObjectParam) MarshalJSON() (data []byte, err error)

func (*ModelConfigModelConfigObjectParam) UnmarshalJSON added in v0.11.0

func (r *ModelConfigModelConfigObjectParam) UnmarshalJSON(data []byte) error

type ModelConfigUnionParam added in v0.9.0

type ModelConfigUnionParam struct {
	OfString                       param.Opt[string]                  `json:",omitzero,inline"`
	OfModelConfigModelConfigObject *ModelConfigModelConfigObjectParam `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 ModelConfigParamOfModelConfigModelConfigObject added in v0.11.0

func ModelConfigParamOfModelConfigModelConfigObject(modelName string) ModelConfigUnionParam

func (ModelConfigUnionParam) MarshalJSON added in v0.9.0

func (u ModelConfigUnionParam) MarshalJSON() ([]byte, error)

func (*ModelConfigUnionParam) UnmarshalJSON added in v0.9.0

func (u *ModelConfigUnionParam) UnmarshalJSON(data []byte) error

type SessionActParams

type SessionActParams struct {
	// Natural language instruction or Action object
	Input SessionActParamsInputUnion `json:"input,omitzero,required"`
	// Target frame ID for the action
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time]    `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	Options SessionActParamsOptions `json:"options,omitzero"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionActParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// 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 ms for the action
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model name string with provider prefix (e.g., 'openai/gpt-5-nano',
	// 'anthropic/claude-4.5-opus')
	Model ModelConfigUnionParam `json:"model,omitzero"`
	// Variables to substitute in the action 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 SessionActParamsXLanguage added in v0.9.0

type SessionActParamsXLanguage string

Client SDK language

const (
	SessionActParamsXLanguageTypescript SessionActParamsXLanguage = "typescript"
	SessionActParamsXLanguagePython     SessionActParamsXLanguage = "python"
	SessionActParamsXLanguagePlayground SessionActParamsXLanguage = "playground"
)

type SessionActParamsXStreamResponse

type SessionActParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionActParamsXStreamResponseTrue  SessionActParamsXStreamResponse = "true"
	SessionActParamsXStreamResponseFalse SessionActParamsXStreamResponse = "false"
)

type SessionActResponse

type SessionActResponse struct {
	Data SessionActResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        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 SessionActResponseData added in v0.9.0

type SessionActResponseData struct {
	Result SessionActResponseDataResult `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionActResponseData) RawJSON added in v0.9.0

func (r SessionActResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionActResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionActResponseData) UnmarshalJSON(data []byte) error

type SessionActResponseDataResult added in v0.9.0

type SessionActResponseDataResult struct {
	// Description of the action that was performed
	ActionDescription string `json:"actionDescription,required"`
	// List of actions that were executed
	Actions []Action `json:"actions,required"`
	// Human-readable result message
	Message string `json:"message,required"`
	// Whether the action completed successfully
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ActionDescription respjson.Field
		Actions           respjson.Field
		Message           respjson.Field
		Success           respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionActResponseDataResult) RawJSON added in v0.9.0

Returns the unmodified JSON received from the API

func (*SessionActResponseDataResult) UnmarshalJSON added in v0.9.0

func (r *SessionActResponseDataResult) UnmarshalJSON(data []byte) error

type SessionEndParams added in v0.5.0

type SessionEndParams struct {
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time] `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionEndParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionEndParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

type SessionEndParamsXLanguage added in v0.9.0

type SessionEndParamsXLanguage string

Client SDK language

const (
	SessionEndParamsXLanguageTypescript SessionEndParamsXLanguage = "typescript"
	SessionEndParamsXLanguagePython     SessionEndParamsXLanguage = "python"
	SessionEndParamsXLanguagePlayground SessionEndParamsXLanguage = "playground"
)

type SessionEndParamsXStreamResponse added in v0.9.0

type SessionEndParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionEndParamsXStreamResponseTrue  SessionEndParamsXStreamResponse = "true"
	SessionEndParamsXStreamResponseFalse SessionEndParamsXStreamResponse = "false"
)

type SessionEndResponse

type SessionEndResponse struct {
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// 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 SessionExecuteParams added in v0.9.0

type SessionExecuteParams struct {
	AgentConfig    SessionExecuteParamsAgentConfig    `json:"agentConfig,omitzero,required"`
	ExecuteOptions SessionExecuteParamsExecuteOptions `json:"executeOptions,omitzero,required"`
	// Target frame ID for the agent
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time] `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionExecuteParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionExecuteParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionExecuteParams) MarshalJSON added in v0.9.0

func (r SessionExecuteParams) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParams) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteParams) UnmarshalJSON(data []byte) error

type SessionExecuteParamsAgentConfig added in v0.9.0

type SessionExecuteParamsAgentConfig struct {
	// Enable Computer Use Agent mode
	Cua param.Opt[bool] `json:"cua,omitzero"`
	// Custom system prompt for the agent
	SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
	// Model name string with provider prefix (e.g., 'openai/gpt-5-nano',
	// 'anthropic/claude-4.5-opus')
	Model ModelConfigUnionParam `json:"model,omitzero"`
	// contains filtered or unexported fields
}

func (SessionExecuteParamsAgentConfig) MarshalJSON added in v0.9.0

func (r SessionExecuteParamsAgentConfig) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParamsAgentConfig) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteParamsAgentConfig) UnmarshalJSON(data []byte) error

type SessionExecuteParamsExecuteOptions added in v0.9.0

type SessionExecuteParamsExecuteOptions struct {
	// Natural language instruction for the agent
	Instruction string `json:"instruction,required"`
	// Whether to visually highlight the cursor during execution
	HighlightCursor param.Opt[bool] `json:"highlightCursor,omitzero"`
	// Maximum number of steps the agent can take
	MaxSteps param.Opt[float64] `json:"maxSteps,omitzero"`
	// contains filtered or unexported fields
}

The property Instruction is required.

func (SessionExecuteParamsExecuteOptions) MarshalJSON added in v0.9.0

func (r SessionExecuteParamsExecuteOptions) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParamsExecuteOptions) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteParamsExecuteOptions) UnmarshalJSON(data []byte) error

type SessionExecuteParamsXLanguage added in v0.9.0

type SessionExecuteParamsXLanguage string

Client SDK language

const (
	SessionExecuteParamsXLanguageTypescript SessionExecuteParamsXLanguage = "typescript"
	SessionExecuteParamsXLanguagePython     SessionExecuteParamsXLanguage = "python"
	SessionExecuteParamsXLanguagePlayground SessionExecuteParamsXLanguage = "playground"
)

type SessionExecuteParamsXStreamResponse added in v0.9.0

type SessionExecuteParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionExecuteParamsXStreamResponseTrue  SessionExecuteParamsXStreamResponse = "true"
	SessionExecuteParamsXStreamResponseFalse SessionExecuteParamsXStreamResponse = "false"
)

type SessionExecuteResponse added in v0.9.0

type SessionExecuteResponse struct {
	Data SessionExecuteResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponse) RawJSON added in v0.9.0

func (r SessionExecuteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExecuteResponse) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteResponse) UnmarshalJSON(data []byte) error

type SessionExecuteResponseData added in v0.9.0

type SessionExecuteResponseData struct {
	Result SessionExecuteResponseDataResult `json:"result,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseData) RawJSON added in v0.9.0

func (r SessionExecuteResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteResponseData) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResult added in v0.9.0

type SessionExecuteResponseDataResult struct {
	Actions []SessionExecuteResponseDataResultAction `json:"actions,required"`
	// Whether the agent finished its task
	Completed bool `json:"completed,required"`
	// Summary of what the agent accomplished
	Message string `json:"message,required"`
	// Whether the agent completed successfully
	Success  bool                                  `json:"success,required"`
	Metadata map[string]any                        `json:"metadata"`
	Usage    SessionExecuteResponseDataResultUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Actions     respjson.Field
		Completed   respjson.Field
		Message     respjson.Field
		Success     respjson.Field
		Metadata    respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResult) RawJSON added in v0.9.0

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResult) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteResponseDataResult) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResultAction added in v0.9.0

type SessionExecuteResponseDataResultAction struct {
	// Type of action taken
	Type        string `json:"type,required"`
	Action      string `json:"action"`
	Instruction string `json:"instruction"`
	PageText    string `json:"pageText"`
	PageURL     string `json:"pageUrl"`
	// Agent's reasoning for taking this action
	Reasoning     string `json:"reasoning"`
	TaskCompleted bool   `json:"taskCompleted"`
	// Time taken for this action in ms
	TimeMs      float64        `json:"timeMs"`
	ExtraFields map[string]any `json:",extras"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type          respjson.Field
		Action        respjson.Field
		Instruction   respjson.Field
		PageText      respjson.Field
		PageURL       respjson.Field
		Reasoning     respjson.Field
		TaskCompleted respjson.Field
		TimeMs        respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResultAction) RawJSON added in v0.9.0

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResultAction) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteResponseDataResultAction) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResultUsage added in v0.9.0

type SessionExecuteResponseDataResultUsage struct {
	InferenceTimeMs   float64 `json:"inference_time_ms,required"`
	InputTokens       float64 `json:"input_tokens,required"`
	OutputTokens      float64 `json:"output_tokens,required"`
	CachedInputTokens float64 `json:"cached_input_tokens"`
	ReasoningTokens   float64 `json:"reasoning_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InferenceTimeMs   respjson.Field
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		CachedInputTokens respjson.Field
		ReasoningTokens   respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResultUsage) RawJSON added in v0.9.0

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResultUsage) UnmarshalJSON added in v0.9.0

func (r *SessionExecuteResponseDataResultUsage) UnmarshalJSON(data []byte) error

type SessionExtractParams

type SessionExtractParams struct {
	// Target frame ID for the extraction
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Natural language instruction for what to extract
	Instruction param.Opt[string] `json:"instruction,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time]        `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	Options SessionExtractParamsOptions `json:"options,omitzero"`
	// JSON Schema defining the structure of data to extract
	Schema map[string]any `json:"schema,omitzero"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionExtractParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// 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 {
	// CSS selector to scope extraction to a specific element
	Selector param.Opt[string] `json:"selector,omitzero"`
	// Timeout in ms for the extraction
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model name string with provider prefix (e.g., 'openai/gpt-5-nano',
	// 'anthropic/claude-4.5-opus')
	Model ModelConfigUnionParam `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 SessionExtractParamsXLanguage added in v0.9.0

type SessionExtractParamsXLanguage string

Client SDK language

const (
	SessionExtractParamsXLanguageTypescript SessionExtractParamsXLanguage = "typescript"
	SessionExtractParamsXLanguagePython     SessionExtractParamsXLanguage = "python"
	SessionExtractParamsXLanguagePlayground SessionExtractParamsXLanguage = "playground"
)

type SessionExtractParamsXStreamResponse

type SessionExtractParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionExtractParamsXStreamResponseTrue  SessionExtractParamsXStreamResponse = "true"
	SessionExtractParamsXStreamResponseFalse SessionExtractParamsXStreamResponse = "false"
)

type SessionExtractResponse added in v0.5.0

type SessionExtractResponse struct {
	Data SessionExtractResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExtractResponse) RawJSON added in v0.9.0

func (r SessionExtractResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExtractResponse) UnmarshalJSON added in v0.9.0

func (r *SessionExtractResponse) UnmarshalJSON(data []byte) error

type SessionExtractResponseData added in v0.9.0

type SessionExtractResponseData struct {
	// Extracted data matching the requested schema
	Result any `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExtractResponseData) RawJSON added in v0.9.0

func (r SessionExtractResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExtractResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionExtractResponseData) UnmarshalJSON(data []byte) error

type SessionNavigateParams

type SessionNavigateParams struct {
	// URL to navigate to
	URL string `json:"url,required"`
	// Target frame ID for the navigation
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Whether to stream the response via SSE
	StreamResponse param.Opt[bool] `json:"streamResponse,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time]         `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	Options SessionNavigateParamsOptions `json:"options,omitzero"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionNavigateParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	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 {
	// Referer header to send with the request
	Referer param.Opt[string] `json:"referer,omitzero"`
	// Timeout in ms for the navigation
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// When to consider navigation complete
	//
	// 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 SessionNavigateParamsXLanguage added in v0.9.0

type SessionNavigateParamsXLanguage string

Client SDK language

const (
	SessionNavigateParamsXLanguageTypescript SessionNavigateParamsXLanguage = "typescript"
	SessionNavigateParamsXLanguagePython     SessionNavigateParamsXLanguage = "python"
	SessionNavigateParamsXLanguagePlayground SessionNavigateParamsXLanguage = "playground"
)

type SessionNavigateParamsXStreamResponse

type SessionNavigateParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionNavigateParamsXStreamResponseTrue  SessionNavigateParamsXStreamResponse = "true"
	SessionNavigateParamsXStreamResponseFalse SessionNavigateParamsXStreamResponse = "false"
)

type SessionNavigateResponse

type SessionNavigateResponse struct {
	Data SessionNavigateResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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 SessionNavigateResponseData added in v0.9.0

type SessionNavigateResponseData struct {
	// Navigation response (Playwright Response object or null)
	Result any `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionNavigateResponseData) RawJSON added in v0.9.0

func (r SessionNavigateResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionNavigateResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionNavigateResponseData) UnmarshalJSON(data []byte) error

type SessionObserveParams

type SessionObserveParams struct {
	// Target frame ID for the observation
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Natural language instruction for what actions to find
	Instruction param.Opt[string] `json:"instruction,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt param.Opt[time.Time]        `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	Options SessionObserveParamsOptions `json:"options,omitzero"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionObserveParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// 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 {
	// CSS selector to scope observation to a specific element
	Selector param.Opt[string] `json:"selector,omitzero"`
	// Timeout in ms for the observation
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model name string with provider prefix (e.g., 'openai/gpt-5-nano',
	// 'anthropic/claude-4.5-opus')
	Model ModelConfigUnionParam `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 SessionObserveParamsXLanguage added in v0.9.0

type SessionObserveParamsXLanguage string

Client SDK language

const (
	SessionObserveParamsXLanguageTypescript SessionObserveParamsXLanguage = "typescript"
	SessionObserveParamsXLanguagePython     SessionObserveParamsXLanguage = "python"
	SessionObserveParamsXLanguagePlayground SessionObserveParamsXLanguage = "playground"
)

type SessionObserveParamsXStreamResponse

type SessionObserveParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionObserveParamsXStreamResponseTrue  SessionObserveParamsXStreamResponse = "true"
	SessionObserveParamsXStreamResponseFalse SessionObserveParamsXStreamResponse = "false"
)

type SessionObserveResponse added in v0.5.0

type SessionObserveResponse struct {
	Data SessionObserveResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionObserveResponse) RawJSON added in v0.9.0

func (r SessionObserveResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionObserveResponse) UnmarshalJSON added in v0.9.0

func (r *SessionObserveResponse) UnmarshalJSON(data []byte) error

type SessionObserveResponseData added in v0.9.0

type SessionObserveResponseData struct {
	Result []Action `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionObserveResponseData) RawJSON added in v0.9.0

func (r SessionObserveResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionObserveResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionObserveResponseData) UnmarshalJSON(data []byte) error

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, id string, params SessionActParams, opts ...option.RequestOption) (res *SessionActResponse, err error)

Executes a browser action using natural language instructions or a predefined Action object.

func (*SessionService) ActStreaming added in v0.13.0

func (r *SessionService) ActStreaming(ctx context.Context, id string, params SessionActParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Executes a browser action using natural language instructions or a predefined Action object.

func (*SessionService) End

Terminates the browser session and releases all associated resources.

func (*SessionService) Execute added in v0.9.0

Runs an autonomous AI agent that can perform complex multi-step browser tasks.

func (*SessionService) ExecuteStreaming added in v0.13.0

func (r *SessionService) ExecuteStreaming(ctx context.Context, id string, params SessionExecuteParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Runs an autonomous AI agent that can perform complex multi-step browser tasks.

func (*SessionService) Extract

Extracts structured data from the current page using AI-powered analysis.

func (*SessionService) ExtractStreaming added in v0.13.0

func (r *SessionService) ExtractStreaming(ctx context.Context, id string, params SessionExtractParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Extracts structured data from the current page using AI-powered analysis.

func (*SessionService) Navigate

Navigates the browser to the specified URL.

func (*SessionService) Observe

Identifies and returns available actions on the current page that match the given instruction.

func (*SessionService) ObserveStreaming added in v0.13.0

func (r *SessionService) ObserveStreaming(ctx context.Context, id string, params SessionObserveParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Identifies and returns available actions on the current page that match the given instruction.

func (*SessionService) Start

Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations.

type SessionStartParams

type SessionStartParams struct {
	// Model name to use for AI operations
	ModelName string `json:"modelName,required"`
	// Timeout in ms for act operations
	ActTimeoutMs param.Opt[float64] `json:"actTimeoutMs,omitzero"`
	// Existing Browserbase session ID to resume
	BrowserbaseSessionID param.Opt[string] `json:"browserbaseSessionID,omitzero"`
	DebugDom             param.Opt[bool]   `json:"debugDom,omitzero"`
	// Timeout in ms to wait for DOM to settle
	DomSettleTimeoutMs param.Opt[float64] `json:"domSettleTimeoutMs,omitzero"`
	Experimental       param.Opt[bool]    `json:"experimental,omitzero"`
	// Enable self-healing for failed actions
	SelfHeal param.Opt[bool] `json:"selfHeal,omitzero"`
	// Custom system prompt for AI operations
	SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
	// Logging verbosity level (0=quiet, 1=normal, 2=debug)
	Verbose              param.Opt[int64] `json:"verbose,omitzero"`
	WaitForCaptchaSolves param.Opt[bool]  `json:"waitForCaptchaSolves,omitzero"`
	// Version of the Stagehand SDK
	XSDKVersion param.Opt[string] `header:"x-sdk-version,omitzero" json:"-"`
	// ISO timestamp when request was sent
	XSentAt                        param.Opt[time.Time]                             `header:"x-sent-at,omitzero" format:"date-time" json:"-"`
	Browser                        SessionStartParamsBrowser                        `json:"browser,omitzero"`
	BrowserbaseSessionCreateParams SessionStartParamsBrowserbaseSessionCreateParams `json:"browserbaseSessionCreateParams,omitzero"`
	// Client SDK language
	//
	// Any of "typescript", "python", "playground".
	XLanguage SessionStartParamsXLanguage `header:"x-language,omitzero" json:"-"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionStartParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// 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 SessionStartParamsBrowser added in v0.9.0

type SessionStartParamsBrowser struct {
	// Chrome DevTools Protocol URL for connecting to existing browser
	CdpURL        param.Opt[string]                      `json:"cdpUrl,omitzero"`
	LaunchOptions SessionStartParamsBrowserLaunchOptions `json:"launchOptions,omitzero"`
	// Browser type to use
	//
	// Any of "local", "browserbase".
	Type string `json:"type,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowser) MarshalJSON added in v0.9.0

func (r SessionStartParamsBrowser) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowser) UnmarshalJSON added in v0.9.0

func (r *SessionStartParamsBrowser) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptions added in v0.9.0

type SessionStartParamsBrowserLaunchOptions struct {
	AcceptDownloads     param.Opt[bool]                                              `json:"acceptDownloads,omitzero"`
	CdpURL              param.Opt[string]                                            `json:"cdpUrl,omitzero"`
	ChromiumSandbox     param.Opt[bool]                                              `json:"chromiumSandbox,omitzero"`
	ConnectTimeoutMs    param.Opt[float64]                                           `json:"connectTimeoutMs,omitzero"`
	DeviceScaleFactor   param.Opt[float64]                                           `json:"deviceScaleFactor,omitzero"`
	Devtools            param.Opt[bool]                                              `json:"devtools,omitzero"`
	DownloadsPath       param.Opt[string]                                            `json:"downloadsPath,omitzero"`
	ExecutablePath      param.Opt[string]                                            `json:"executablePath,omitzero"`
	HasTouch            param.Opt[bool]                                              `json:"hasTouch,omitzero"`
	Headless            param.Opt[bool]                                              `json:"headless,omitzero"`
	IgnoreHTTPSErrors   param.Opt[bool]                                              `json:"ignoreHTTPSErrors,omitzero"`
	Locale              param.Opt[string]                                            `json:"locale,omitzero"`
	PreserveUserDataDir param.Opt[bool]                                              `json:"preserveUserDataDir,omitzero"`
	UserDataDir         param.Opt[string]                                            `json:"userDataDir,omitzero"`
	Args                []string                                                     `json:"args,omitzero"`
	IgnoreDefaultArgs   SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion `json:"ignoreDefaultArgs,omitzero"`
	Proxy               SessionStartParamsBrowserLaunchOptionsProxy                  `json:"proxy,omitzero"`
	Viewport            SessionStartParamsBrowserLaunchOptionsViewport               `json:"viewport,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserLaunchOptions) MarshalJSON added in v0.9.0

func (r SessionStartParamsBrowserLaunchOptions) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptions) UnmarshalJSON added in v0.9.0

func (r *SessionStartParamsBrowserLaunchOptions) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion added in v0.9.0

type SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion struct {
	OfBool        param.Opt[bool] `json:",omitzero,inline"`
	OfStringArray []string        `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 (SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserLaunchOptionsProxy added in v0.9.0

type SessionStartParamsBrowserLaunchOptionsProxy struct {
	Server   string            `json:"server,required"`
	Bypass   param.Opt[string] `json:"bypass,omitzero"`
	Password param.Opt[string] `json:"password,omitzero"`
	Username param.Opt[string] `json:"username,omitzero"`
	// contains filtered or unexported fields
}

The property Server is required.

func (SessionStartParamsBrowserLaunchOptionsProxy) MarshalJSON added in v0.9.0

func (r SessionStartParamsBrowserLaunchOptionsProxy) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptionsProxy) UnmarshalJSON added in v0.9.0

func (r *SessionStartParamsBrowserLaunchOptionsProxy) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptionsViewport added in v0.9.0

type SessionStartParamsBrowserLaunchOptionsViewport struct {
	Height float64 `json:"height,required"`
	Width  float64 `json:"width,required"`
	// contains filtered or unexported fields
}

The properties Height, Width are required.

func (SessionStartParamsBrowserLaunchOptionsViewport) MarshalJSON added in v0.9.0

func (r SessionStartParamsBrowserLaunchOptionsViewport) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptionsViewport) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParams added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParams struct {
	ExtensionID     param.Opt[string]                                               `json:"extensionId,omitzero"`
	KeepAlive       param.Opt[bool]                                                 `json:"keepAlive,omitzero"`
	ProjectID       param.Opt[string]                                               `json:"projectId,omitzero"`
	Timeout         param.Opt[float64]                                              `json:"timeout,omitzero"`
	BrowserSettings SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings `json:"browserSettings,omitzero"`
	Proxies         SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion    `json:"proxies,omitzero"`
	// Any of "us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1".
	Region       string         `json:"region,omitzero"`
	UserMetadata map[string]any `json:"userMetadata,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParams) MarshalJSON added in v0.9.0

func (r SessionStartParamsBrowserbaseSessionCreateParams) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserbaseSessionCreateParams) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings struct {
	AdvancedStealth param.Opt[bool]                                                            `json:"advancedStealth,omitzero"`
	BlockAds        param.Opt[bool]                                                            `json:"blockAds,omitzero"`
	ExtensionID     param.Opt[string]                                                          `json:"extensionId,omitzero"`
	LogSession      param.Opt[bool]                                                            `json:"logSession,omitzero"`
	RecordSession   param.Opt[bool]                                                            `json:"recordSession,omitzero"`
	SolveCaptchas   param.Opt[bool]                                                            `json:"solveCaptchas,omitzero"`
	Context         SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext     `json:"context,omitzero"`
	Fingerprint     SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint `json:"fingerprint,omitzero"`
	Viewport        SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport    `json:"viewport,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext struct {
	ID      string          `json:"id,required"`
	Persist param.Opt[bool] `json:"persist,omitzero"`
	// contains filtered or unexported fields
}

The property ID is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint struct {
	// Any of "chrome", "edge", "firefox", "safari".
	Browsers []string `json:"browsers,omitzero"`
	// Any of "desktop", "mobile".
	Devices []string `json:"devices,omitzero"`
	// Any of "1", "2".
	HTTPVersion string   `json:"httpVersion,omitzero"`
	Locales     []string `json:"locales,omitzero"`
	// Any of "android", "ios", "linux", "macos", "windows".
	OperatingSystems []string                                                                         `json:"operatingSystems,omitzero"`
	Screen           SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen `json:"screen,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen struct {
	MaxHeight param.Opt[float64] `json:"maxHeight,omitzero"`
	MaxWidth  param.Opt[float64] `json:"maxWidth,omitzero"`
	MinHeight param.Opt[float64] `json:"minHeight,omitzero"`
	MinWidth  param.Opt[float64] `json:"minWidth,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport struct {
	Height param.Opt[float64] `json:"height,omitzero"`
	Width  param.Opt[float64] `json:"width,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport) UnmarshalJSON added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase struct {
	DomainPattern param.Opt[string]                                                                                `json:"domainPattern,omitzero"`
	Geolocation   SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation `json:"geolocation,omitzero"`
	// This field can be elided, and will marshal its zero value as "browserbase".
	Type constant.Browserbase `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase) MarshalJSON added in v0.12.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase) UnmarshalJSON added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation struct {
	Country string            `json:"country,required"`
	City    param.Opt[string] `json:"city,omitzero"`
	State   param.Opt[string] `json:"state,omitzero"`
	// contains filtered or unexported fields
}

The property Country is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation) MarshalJSON added in v0.12.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation) UnmarshalJSON added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal struct {
	Server        string            `json:"server,required"`
	DomainPattern param.Opt[string] `json:"domainPattern,omitzero"`
	Password      param.Opt[string] `json:"password,omitzero"`
	Username      param.Opt[string] `json:"username,omitzero"`
	// This field can be elided, and will marshal its zero value as "external".
	Type constant.External `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Server, Type are required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal) MarshalJSON added in v0.12.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal) UnmarshalJSON added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion struct {
	OfBrowserbase *SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase `json:",omitzero,inline"`
	OfExternal    *SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal    `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 (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetDomainPattern added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetGeolocation added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetPassword added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetServer added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetType added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetUsername added in v0.12.0

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) MarshalJSON added in v0.12.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) UnmarshalJSON added in v0.12.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion added in v0.9.0

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion struct {
	OfBool            param.Opt[bool]                                                                   `json:",omitzero,inline"`
	OfProxyConfigList []SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion `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 (SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion) MarshalJSON added in v0.9.0

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion) UnmarshalJSON added in v0.9.0

type SessionStartParamsXLanguage added in v0.9.0

type SessionStartParamsXLanguage string

Client SDK language

const (
	SessionStartParamsXLanguageTypescript SessionStartParamsXLanguage = "typescript"
	SessionStartParamsXLanguagePython     SessionStartParamsXLanguage = "python"
	SessionStartParamsXLanguagePlayground SessionStartParamsXLanguage = "playground"
)

type SessionStartParamsXStreamResponse added in v0.9.0

type SessionStartParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionStartParamsXStreamResponseTrue  SessionStartParamsXStreamResponse = "true"
	SessionStartParamsXStreamResponseFalse SessionStartParamsXStreamResponse = "false"
)

type SessionStartResponse

type SessionStartResponse struct {
	Data SessionStartResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     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

type SessionStartResponseData added in v0.9.0

type SessionStartResponseData struct {
	Available bool `json:"available,required"`
	// CDP WebSocket URL for connecting to the Browserbase cloud browser
	ConnectURL string `json:"connectUrl,required"`
	// Unique Browserbase session identifier
	SessionID string `json:"sessionId,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Available   respjson.Field
		ConnectURL  respjson.Field
		SessionID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionStartResponseData) RawJSON added in v0.9.0

func (r SessionStartResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionStartResponseData) UnmarshalJSON added in v0.9.0

func (r *SessionStartResponseData) UnmarshalJSON(data []byte) error

type StreamEvent added in v0.13.0

type StreamEvent struct {
	// Unique identifier for this event
	ID   string               `json:"id,required" format:"uuid"`
	Data StreamEventDataUnion `json:"data,required"`
	// Type of stream event - system events or log messages
	//
	// Any of "system", "log".
	Type StreamEventType `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Data        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Server-Sent Event emitted during streaming responses. Events are sent as `data: <JSON>\n\n`.

func (StreamEvent) RawJSON added in v0.13.0

func (r StreamEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*StreamEvent) UnmarshalJSON added in v0.13.0

func (r *StreamEvent) UnmarshalJSON(data []byte) error

type StreamEventDataStreamEventLogDataOutput added in v0.13.0

type StreamEventDataStreamEventLogDataOutput struct {
	// Log message from the operation
	Message string           `json:"message,required"`
	Status  constant.Running `json:"status,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StreamEventDataStreamEventLogDataOutput) RawJSON added in v0.13.0

Returns the unmodified JSON received from the API

func (*StreamEventDataStreamEventLogDataOutput) UnmarshalJSON added in v0.13.0

func (r *StreamEventDataStreamEventLogDataOutput) UnmarshalJSON(data []byte) error

type StreamEventDataStreamEventSystemDataOutput added in v0.13.0

type StreamEventDataStreamEventSystemDataOutput struct {
	// Current status of the streaming operation
	//
	// Any of "starting", "connected", "running", "finished", "error".
	Status string `json:"status,required"`
	// Error message (present when status is 'error')
	Error string `json:"error"`
	// Operation result (present when status is 'finished')
	Result any `json:"result"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		Error       respjson.Field
		Result      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StreamEventDataStreamEventSystemDataOutput) RawJSON added in v0.13.0

Returns the unmodified JSON received from the API

func (*StreamEventDataStreamEventSystemDataOutput) UnmarshalJSON added in v0.13.0

func (r *StreamEventDataStreamEventSystemDataOutput) UnmarshalJSON(data []byte) error

type StreamEventDataUnion added in v0.13.0

type StreamEventDataUnion struct {
	Status string `json:"status"`
	// This field is from variant [StreamEventDataStreamEventSystemDataOutput].
	Error string `json:"error"`
	// This field is from variant [StreamEventDataStreamEventSystemDataOutput].
	Result any `json:"result"`
	// This field is from variant [StreamEventDataStreamEventLogDataOutput].
	Message string `json:"message"`
	JSON    struct {
		Status  respjson.Field
		Error   respjson.Field
		Result  respjson.Field
		Message respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

StreamEventDataUnion contains all possible properties and values from StreamEventDataStreamEventSystemDataOutput, StreamEventDataStreamEventLogDataOutput.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (StreamEventDataUnion) AsStreamEventDataStreamEventLogDataOutput added in v0.13.0

func (u StreamEventDataUnion) AsStreamEventDataStreamEventLogDataOutput() (v StreamEventDataStreamEventLogDataOutput)

func (StreamEventDataUnion) AsStreamEventDataStreamEventSystemDataOutput added in v0.13.0

func (u StreamEventDataUnion) AsStreamEventDataStreamEventSystemDataOutput() (v StreamEventDataStreamEventSystemDataOutput)

func (StreamEventDataUnion) RawJSON added in v0.13.0

func (u StreamEventDataUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*StreamEventDataUnion) UnmarshalJSON added in v0.13.0

func (r *StreamEventDataUnion) UnmarshalJSON(data []byte) error

type StreamEventType added in v0.13.0

type StreamEventType string

Type of stream event - system events or log messages

const (
	StreamEventTypeSystem StreamEventType = "system"
	StreamEventTypeLog    StreamEventType = "log"
)

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

Jump to

Keyboard shortcuts

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