githubcomtzafoncomputergo

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 15 Imported by: 0

README

Computer Go API Library

Go Reference

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

It is generated with Stainless.

MCP Server

Use the Computer MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

Add to Cursor Install in VS Code

Note: You may need to set environment variables in your MCP client.

Installation

import (
	"github.com/tzafon/computer-go" // imported as githubcomtzafoncomputergo
)

Or to pin the version:

go get -u 'github.com/tzafon/[email protected]'

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/tzafon/computer-go"
	"github.com/tzafon/computer-go/option"
)

func main() {
	client := githubcomtzafoncomputergo.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("TZAFON_API_KEY")
	)
	computerResponses, err := client.Computers.List(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", computerResponses)
}

Request fields

The githubcomtzafoncomputergo 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, githubcomtzafoncomputergo.String(string), githubcomtzafoncomputergo.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 := githubcomtzafoncomputergo.ExampleParams{
	ID:   "id_xxx",                                // required property
	Name: githubcomtzafoncomputergo.String("..."), // optional property

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

	Origin: githubcomtzafoncomputergo.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[githubcomtzafoncomputergo.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 := githubcomtzafoncomputergo.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Computers.List(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 *githubcomtzafoncomputergo.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.Computers.List(context.TODO())
if err != nil {
	var apierr *githubcomtzafoncomputergo.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 "/computers": 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.Computers.List(
	ctx,
	// 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 githubcomtzafoncomputergo.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 := githubcomtzafoncomputergo.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Computers.List(context.TODO(), 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
computerResponses, err := client.Computers.List(context.TODO(), option.WithResponseInto(&response))
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", computerResponses)

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: githubcomtzafoncomputergo.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 := githubcomtzafoncomputergo.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 (TZAFON_API_KEY, COMPUTER_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 ActionResult

type ActionResult struct {
	ErrorMessage  string                              `json:"error_message"`
	ExecutedTabID string                              `json:"executed_tab_id"`
	PageContext   V2GoBackendInternalTypesPageContext `json:"page_context"`
	RequestID     string                              `json:"request_id"`
	Result        map[string]any                      `json:"result"`
	Status        string                              `json:"status"`
	Timestamp     string                              `json:"timestamp"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorMessage  respjson.Field
		ExecutedTabID respjson.Field
		PageContext   respjson.Field
		RequestID     respjson.Field
		Result        respjson.Field
		Status        respjson.Field
		Timestamp     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ActionResult) RawJSON

func (r ActionResult) RawJSON() string

Returns the unmodified JSON received from the API

func (*ActionResult) UnmarshalJSON

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

type Client

type Client struct {
	Options   []option.RequestOption
	Computers ComputerService
}

Client creates a struct with services and top level methods that help with interacting with the computer 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 (TZAFON_API_KEY, COMPUTER_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 ComputerCaptureScreenshotParams

type ComputerCaptureScreenshotParams struct {
	Base64 param.Opt[bool]   `json:"base64,omitzero"`
	TabID  param.Opt[string] `json:"tab_id,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerCaptureScreenshotParams) MarshalJSON

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

func (*ComputerCaptureScreenshotParams) UnmarshalJSON

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

type ComputerChangeProxyParams

type ComputerChangeProxyParams struct {
	ProxyURL param.Opt[string] `json:"proxy_url,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerChangeProxyParams) MarshalJSON

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

func (*ComputerChangeProxyParams) UnmarshalJSON

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

type ComputerClickParams

type ComputerClickParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerClickParams) MarshalJSON

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

func (*ComputerClickParams) UnmarshalJSON

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

type ComputerDebugParams

type ComputerDebugParams struct {
	Command         param.Opt[string] `json:"command,omitzero"`
	MaxOutputLength param.Opt[int64]  `json:"max_output_length,omitzero"`
	TabID           param.Opt[string] `json:"tab_id,omitzero"`
	TimeoutSeconds  param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerDebugParams) MarshalJSON

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

func (*ComputerDebugParams) UnmarshalJSON

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

type ComputerDoubleClickParams

type ComputerDoubleClickParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerDoubleClickParams) MarshalJSON

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

func (*ComputerDoubleClickParams) UnmarshalJSON

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

type ComputerDragParams

type ComputerDragParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X1    param.Opt[float64] `json:"x1,omitzero"`
	X2    param.Opt[float64] `json:"x2,omitzero"`
	Y1    param.Opt[float64] `json:"y1,omitzero"`
	Y2    param.Opt[float64] `json:"y2,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerDragParams) MarshalJSON

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

func (*ComputerDragParams) UnmarshalJSON

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

type ComputerExecExecuteParams

type ComputerExecExecuteParams struct {
	Command        param.Opt[string] `json:"command,omitzero"`
	Cwd            param.Opt[string] `json:"cwd,omitzero"`
	TimeoutSeconds param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	Env            map[string]string `json:"env,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecExecuteParams) MarshalJSON

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

func (*ComputerExecExecuteParams) UnmarshalJSON

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

type ComputerExecExecuteResponse

type ComputerExecExecuteResponse struct {
	// for exit
	Code int64 `json:"code"`
	// for stdout/stderr
	Data string `json:"data"`
	// for error
	Message string `json:"message"`
	// "stdout", "stderr", "exit", "error"
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Data        respjson.Field
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ComputerExecExecuteResponse) RawJSON

func (r ComputerExecExecuteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ComputerExecExecuteResponse) UnmarshalJSON

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

type ComputerExecExecuteSyncParams

type ComputerExecExecuteSyncParams struct {
	Command        param.Opt[string] `json:"command,omitzero"`
	Cwd            param.Opt[string] `json:"cwd,omitzero"`
	TimeoutSeconds param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	Env            map[string]string `json:"env,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecExecuteSyncParams) MarshalJSON

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

func (*ComputerExecExecuteSyncParams) UnmarshalJSON

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

type ComputerExecExecuteSyncResponse

type ComputerExecExecuteSyncResponse struct {
	ExitCode int64  `json:"exit_code"`
	Stderr   string `json:"stderr"`
	Stdout   string `json:"stdout"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ExitCode    respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ComputerExecExecuteSyncResponse) RawJSON

Returns the unmodified JSON received from the API

func (*ComputerExecExecuteSyncResponse) UnmarshalJSON

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

type ComputerExecService

type ComputerExecService struct {
	Options []option.RequestOption
}

ComputerExecService contains methods and other services that help with interacting with the computer 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 NewComputerExecService method instead.

func NewComputerExecService

func NewComputerExecService(opts ...option.RequestOption) (r ComputerExecService)

NewComputerExecService 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 (*ComputerExecService) ExecuteStreaming

Execute a shell command with real-time streaming output as NDJSON. Each line is a JSON object with type (stdout/stderr/exit/error).

func (*ComputerExecService) ExecuteSync

Execute a shell command and wait for completion, returning buffered stdout/stderr.

type ComputerExecuteActionParams

type ComputerExecuteActionParams struct {
	Action ComputerExecuteActionParamsAction `json:"action,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteActionParams) MarshalJSON

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

func (*ComputerExecuteActionParams) UnmarshalJSON

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

type ComputerExecuteActionParamsAction

type ComputerExecuteActionParamsAction struct {
	// For get_html_content
	AutoDetectEncoding param.Opt[bool] `json:"auto_detect_encoding,omitzero"`
	// For screenshot
	Base64 param.Opt[bool]   `json:"base64,omitzero"`
	Button param.Opt[string] `json:"button,omitzero"`
	// For scrolling
	Dx     param.Opt[float64] `json:"dx,omitzero"`
	Dy     param.Opt[float64] `json:"dy,omitzero"`
	Height param.Opt[int64]   `json:"height,omitzero"`
	// Include page context in response
	IncludeContext param.Opt[bool] `json:"include_context,omitzero"`
	// For key_down/key_up
	Key      param.Opt[string] `json:"key,omitzero"`
	Ms       param.Opt[int64]  `json:"ms,omitzero"`
	ProxyURL param.Opt[string] `json:"proxy_url,omitzero"`
	// RequestId is used for correlating streaming output to the originating request.
	// Set on ActionRequest, not individual action types.
	RequestID   param.Opt[string]  `json:"request_id,omitzero"`
	ScaleFactor param.Opt[float64] `json:"scale_factor,omitzero"`
	// For tab management (browser sessions only)
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	Text  param.Opt[string] `json:"text,omitzero"`
	// click|double_click|right_click|drag|type|keypress|scroll|wait|screenshot|go_to_url|debug|get_html_content|set_viewport|list_tabs|new_tab|switch_tab|close_tab|key_down|key_up|mouse_down|mouse_up
	Type param.Opt[string] `json:"type,omitzero"`
	URL  param.Opt[string] `json:"url,omitzero"`
	// For set_viewport
	Width param.Opt[int64]   `json:"width,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	// For dragging/scrolling
	X1 param.Opt[float64] `json:"x1,omitzero"`
	// For dragging
	X2    param.Opt[float64]                     `json:"x2,omitzero"`
	Y     param.Opt[float64]                     `json:"y,omitzero"`
	Y1    param.Opt[float64]                     `json:"y1,omitzero"`
	Y2    param.Opt[float64]                     `json:"y2,omitzero"`
	Debug ComputerExecuteActionParamsActionDebug `json:"debug,omitzero"`
	Keys  []string                               `json:"keys,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteActionParamsAction) MarshalJSON

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

func (*ComputerExecuteActionParamsAction) UnmarshalJSON

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

type ComputerExecuteActionParamsActionDebug

type ComputerExecuteActionParamsActionDebug struct {
	Command         param.Opt[string] `json:"command,omitzero"`
	Cwd             param.Opt[string] `json:"cwd,omitzero"`
	MaxOutputLength param.Opt[int64]  `json:"max_output_length,omitzero"`
	RequestID       param.Opt[string] `json:"request_id,omitzero"`
	Stream          param.Opt[bool]   `json:"stream,omitzero"`
	TimeoutSeconds  param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	Env             map[string]string `json:"env,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteActionParamsActionDebug) MarshalJSON

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

func (*ComputerExecuteActionParamsActionDebug) UnmarshalJSON

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

type ComputerExecuteBatchParams

type ComputerExecuteBatchParams struct {
	Actions []ComputerExecuteBatchParamsAction `json:"actions,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteBatchParams) MarshalJSON

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

func (*ComputerExecuteBatchParams) UnmarshalJSON

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

type ComputerExecuteBatchParamsAction

type ComputerExecuteBatchParamsAction struct {
	// For get_html_content
	AutoDetectEncoding param.Opt[bool] `json:"auto_detect_encoding,omitzero"`
	// For screenshot
	Base64 param.Opt[bool]   `json:"base64,omitzero"`
	Button param.Opt[string] `json:"button,omitzero"`
	// For scrolling
	Dx     param.Opt[float64] `json:"dx,omitzero"`
	Dy     param.Opt[float64] `json:"dy,omitzero"`
	Height param.Opt[int64]   `json:"height,omitzero"`
	// Include page context in response
	IncludeContext param.Opt[bool] `json:"include_context,omitzero"`
	// For key_down/key_up
	Key      param.Opt[string] `json:"key,omitzero"`
	Ms       param.Opt[int64]  `json:"ms,omitzero"`
	ProxyURL param.Opt[string] `json:"proxy_url,omitzero"`
	// RequestId is used for correlating streaming output to the originating request.
	// Set on ActionRequest, not individual action types.
	RequestID   param.Opt[string]  `json:"request_id,omitzero"`
	ScaleFactor param.Opt[float64] `json:"scale_factor,omitzero"`
	// For tab management (browser sessions only)
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	Text  param.Opt[string] `json:"text,omitzero"`
	// click|double_click|right_click|drag|type|keypress|scroll|wait|screenshot|go_to_url|debug|get_html_content|set_viewport|list_tabs|new_tab|switch_tab|close_tab|key_down|key_up|mouse_down|mouse_up
	Type param.Opt[string] `json:"type,omitzero"`
	URL  param.Opt[string] `json:"url,omitzero"`
	// For set_viewport
	Width param.Opt[int64]   `json:"width,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	// For dragging/scrolling
	X1 param.Opt[float64] `json:"x1,omitzero"`
	// For dragging
	X2    param.Opt[float64]                    `json:"x2,omitzero"`
	Y     param.Opt[float64]                    `json:"y,omitzero"`
	Y1    param.Opt[float64]                    `json:"y1,omitzero"`
	Y2    param.Opt[float64]                    `json:"y2,omitzero"`
	Debug ComputerExecuteBatchParamsActionDebug `json:"debug,omitzero"`
	Keys  []string                              `json:"keys,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteBatchParamsAction) MarshalJSON

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

func (*ComputerExecuteBatchParamsAction) UnmarshalJSON

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

type ComputerExecuteBatchParamsActionDebug

type ComputerExecuteBatchParamsActionDebug struct {
	Command         param.Opt[string] `json:"command,omitzero"`
	Cwd             param.Opt[string] `json:"cwd,omitzero"`
	MaxOutputLength param.Opt[int64]  `json:"max_output_length,omitzero"`
	RequestID       param.Opt[string] `json:"request_id,omitzero"`
	Stream          param.Opt[bool]   `json:"stream,omitzero"`
	TimeoutSeconds  param.Opt[int64]  `json:"timeout_seconds,omitzero"`
	Env             map[string]string `json:"env,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerExecuteBatchParamsActionDebug) MarshalJSON

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

func (*ComputerExecuteBatchParamsActionDebug) UnmarshalJSON

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

type ComputerExecuteBatchResponse

type ComputerExecuteBatchResponse map[string]any

type ComputerGetHTMLParams

type ComputerGetHTMLParams struct {
	AutoDetectEncoding param.Opt[bool]   `json:"auto_detect_encoding,omitzero"`
	TabID              param.Opt[string] `json:"tab_id,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerGetHTMLParams) MarshalJSON

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

func (*ComputerGetHTMLParams) UnmarshalJSON

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

type ComputerGetStatusResponse

type ComputerGetStatusResponse struct {
	ID                       string `json:"id"`
	AutoKill                 bool   `json:"auto_kill"`
	CreatedAt                string `json:"created_at"`
	ExpiresAt                string `json:"expires_at"`
	IdleExpiresAt            string `json:"idle_expires_at"`
	InactivityTimeoutSeconds int64  `json:"inactivity_timeout_seconds"`
	LastActivityAt           string `json:"last_activity_at"`
	MaxLifetimeSeconds       int64  `json:"max_lifetime_seconds"`
	Status                   string `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                       respjson.Field
		AutoKill                 respjson.Field
		CreatedAt                respjson.Field
		ExpiresAt                respjson.Field
		IdleExpiresAt            respjson.Field
		InactivityTimeoutSeconds respjson.Field
		LastActivityAt           respjson.Field
		MaxLifetimeSeconds       respjson.Field
		Status                   respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ComputerGetStatusResponse) RawJSON

func (r ComputerGetStatusResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ComputerGetStatusResponse) UnmarshalJSON

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

type ComputerKeepAliveResponse

type ComputerKeepAliveResponse map[string]any

type ComputerKeyDownParams

type ComputerKeyDownParams struct {
	Key   param.Opt[string] `json:"key,omitzero"`
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerKeyDownParams) MarshalJSON

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

func (*ComputerKeyDownParams) UnmarshalJSON

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

type ComputerKeyUpParams

type ComputerKeyUpParams struct {
	Key   param.Opt[string] `json:"key,omitzero"`
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerKeyUpParams) MarshalJSON

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

func (*ComputerKeyUpParams) UnmarshalJSON

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

type ComputerMouseDownParams

type ComputerMouseDownParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerMouseDownParams) MarshalJSON

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

func (*ComputerMouseDownParams) UnmarshalJSON

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

type ComputerMouseUpParams

type ComputerMouseUpParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerMouseUpParams) MarshalJSON

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

func (*ComputerMouseUpParams) UnmarshalJSON

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

type ComputerNavigateParams

type ComputerNavigateParams struct {
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	URL   param.Opt[string] `json:"url,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerNavigateParams) MarshalJSON

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

func (*ComputerNavigateParams) UnmarshalJSON

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

type ComputerNewParams

type ComputerNewParams struct {
	// If true (default), kill session after inactivity
	AutoKill  param.Opt[bool]   `json:"auto_kill,omitzero"`
	ContextID param.Opt[string] `json:"context_id,omitzero"`
	// Idle timeout before auto-kill
	InactivityTimeoutSeconds param.Opt[int64] `json:"inactivity_timeout_seconds,omitzero"`
	// "browser" (default) or "desktop"
	Kind           param.Opt[string]        `json:"kind,omitzero"`
	TimeoutSeconds param.Opt[int64]         `json:"timeout_seconds,omitzero"`
	Display        ComputerNewParamsDisplay `json:"display,omitzero"`
	Stealth        any                      `json:"stealth,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerNewParams) MarshalJSON

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

func (*ComputerNewParams) UnmarshalJSON

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

type ComputerNewParamsDisplay

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

func (ComputerNewParamsDisplay) MarshalJSON

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

func (*ComputerNewParamsDisplay) UnmarshalJSON

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

type ComputerPressHotkeyParams

type ComputerPressHotkeyParams struct {
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	Keys  []string          `json:"keys,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerPressHotkeyParams) MarshalJSON

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

func (*ComputerPressHotkeyParams) UnmarshalJSON

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

type ComputerResponse

type ComputerResponse struct {
	ID                       string            `json:"id"`
	AutoKill                 bool              `json:"auto_kill"`
	CreatedAt                string            `json:"created_at"`
	Endpoints                map[string]string `json:"endpoints"`
	ExpiresAt                string            `json:"expires_at"`
	IdleExpiresAt            string            `json:"idle_expires_at"`
	InactivityTimeoutSeconds int64             `json:"inactivity_timeout_seconds"`
	Kind                     string            `json:"kind"`
	LastActivityAt           string            `json:"last_activity_at"`
	MaxLifetimeSeconds       int64             `json:"max_lifetime_seconds"`
	Status                   string            `json:"status"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                       respjson.Field
		AutoKill                 respjson.Field
		CreatedAt                respjson.Field
		Endpoints                respjson.Field
		ExpiresAt                respjson.Field
		IdleExpiresAt            respjson.Field
		InactivityTimeoutSeconds respjson.Field
		Kind                     respjson.Field
		LastActivityAt           respjson.Field
		MaxLifetimeSeconds       respjson.Field
		Status                   respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ComputerResponse) RawJSON

func (r ComputerResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ComputerResponse) UnmarshalJSON

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

type ComputerRightClickParams

type ComputerRightClickParams struct {
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerRightClickParams) MarshalJSON

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

func (*ComputerRightClickParams) UnmarshalJSON

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

type ComputerScrollViewportParams

type ComputerScrollViewportParams struct {
	Dx    param.Opt[float64] `json:"dx,omitzero"`
	Dy    param.Opt[float64] `json:"dy,omitzero"`
	TabID param.Opt[string]  `json:"tab_id,omitzero"`
	X     param.Opt[float64] `json:"x,omitzero"`
	Y     param.Opt[float64] `json:"y,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerScrollViewportParams) MarshalJSON

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

func (*ComputerScrollViewportParams) UnmarshalJSON

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

type ComputerService

type ComputerService struct {
	Options []option.RequestOption
	Tabs    ComputerTabService
	Exec    ComputerExecService
}

ComputerService contains methods and other services that help with interacting with the computer 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 NewComputerService method instead.

func NewComputerService

func NewComputerService(opts ...option.RequestOption) (r ComputerService)

NewComputerService 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 (*ComputerService) CaptureScreenshot

func (r *ComputerService) CaptureScreenshot(ctx context.Context, id string, body ComputerCaptureScreenshotParams, opts ...option.RequestOption) (res *ActionResult, err error)

Take a screenshot of the current browser viewport, optionally as base64. Optionally specify tab_id (browser sessions only)

func (*ComputerService) ChangeProxy

func (r *ComputerService) ChangeProxy(ctx context.Context, id string, body ComputerChangeProxyParams, opts ...option.RequestOption) (res *ActionResult, err error)

Change the proxy settings for the browser session

func (*ComputerService) Click

func (r *ComputerService) Click(ctx context.Context, id string, body ComputerClickParams, opts ...option.RequestOption) (res *ActionResult, err error)

Perform a left mouse click at the specified x,y coordinates. Coordinates are screenshot pixel positions - send exactly what you see in the screenshot/screencast image. If target is at pixel (500, 300) in the image, send x=500, y=300. Optionally specify tab_id (browser sessions only)

func (*ComputerService) ConnectWebsocket

func (r *ComputerService) ConnectWebsocket(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Establish WebSocket for real-time bidirectional communication

func (*ComputerService) Debug

func (r *ComputerService) Debug(ctx context.Context, id string, body ComputerDebugParams, opts ...option.RequestOption) (res *ActionResult, err error)

Execute a shell command with optional timeout and output length limits. Optionally specify tab_id (browser sessions only). Deprecated: use /exec or /exec/sync instead.

func (*ComputerService) DoubleClick

func (r *ComputerService) DoubleClick(ctx context.Context, id string, body ComputerDoubleClickParams, opts ...option.RequestOption) (res *ActionResult, err error)

Perform a double mouse click at the specified x,y coordinates. Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) Drag

func (r *ComputerService) Drag(ctx context.Context, id string, body ComputerDragParams, opts ...option.RequestOption) (res *ActionResult, err error)

Perform a click-and-drag action from (x1,y1) to (x2,y2). Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) ExecuteAction

func (r *ComputerService) ExecuteAction(ctx context.Context, id string, body ComputerExecuteActionParams, opts ...option.RequestOption) (res *ActionResult, err error)

Execute a single action such as screenshot, click, type, navigate, scroll, debug, set_viewport, get_html_content or other computer use actions

func (*ComputerService) ExecuteBatch

Execute a batch of actions in sequence, stopping on first error

func (*ComputerService) Get

func (r *ComputerService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *ComputerResponse, err error)

Get the current status and metadata of a computer instance

func (*ComputerService) GetHTML

func (r *ComputerService) GetHTML(ctx context.Context, id string, body ComputerGetHTMLParams, opts ...option.RequestOption) (res *ActionResult, err error)

Get the HTML content of the current browser page. Optionally specify tab_id (browser sessions only)

func (*ComputerService) GetStatus

func (r *ComputerService) GetStatus(ctx context.Context, id string, opts ...option.RequestOption) (res *ComputerGetStatusResponse, err error)

Get current TTLs and last activity metadata for a computer session

func (*ComputerService) KeepAlive

func (r *ComputerService) KeepAlive(ctx context.Context, id string, opts ...option.RequestOption) (res *ComputerKeepAliveResponse, err error)

Extend the timeout for a computer session and verify it is still running

func (*ComputerService) KeyDown

func (r *ComputerService) KeyDown(ctx context.Context, id string, body ComputerKeyDownParams, opts ...option.RequestOption) (res *ActionResult, err error)

Press and hold a keyboard key. Use with key_up for complex interactions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) KeyUp

func (r *ComputerService) KeyUp(ctx context.Context, id string, body ComputerKeyUpParams, opts ...option.RequestOption) (res *ActionResult, err error)

Release a keyboard key that was previously pressed with key_down. Optionally specify tab_id (browser sessions only)

func (*ComputerService) List

func (r *ComputerService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ComputerResponse, err error)

List all active computers for the user's organization

func (*ComputerService) MouseDown

func (r *ComputerService) MouseDown(ctx context.Context, id string, body ComputerMouseDownParams, opts ...option.RequestOption) (res *ActionResult, err error)

Press and hold the left mouse button at the specified x,y coordinates. Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) MouseUp

func (r *ComputerService) MouseUp(ctx context.Context, id string, body ComputerMouseUpParams, opts ...option.RequestOption) (res *ActionResult, err error)

Release the left mouse button at the specified x,y coordinates. Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) Navigate

func (r *ComputerService) Navigate(ctx context.Context, id string, body ComputerNavigateParams, opts ...option.RequestOption) (res *ActionResult, err error)

Navigate the browser to a specified URL. Optionally specify tab_id to navigate a specific tab (browser sessions only)

func (*ComputerService) New

Create a new automation session. Set kind to "browser" for web automation or "desktop" for OS-level automation. Defaults to "browser" if not specified. timeout_seconds controls max lifetime, inactivity_timeout_seconds controls idle timeout, and auto_kill disables only the idle timeout (max lifetime still applies).

func (*ComputerService) PressHotkey

func (r *ComputerService) PressHotkey(ctx context.Context, id string, body ComputerPressHotkeyParams, opts ...option.RequestOption) (res *ActionResult, err error)

Press a combination of keys (e.g., ["Control", "c"] for copy). Optionally specify tab_id (browser sessions only)

func (*ComputerService) RightClick

func (r *ComputerService) RightClick(ctx context.Context, id string, body ComputerRightClickParams, opts ...option.RequestOption) (res *ActionResult, err error)

Perform a right mouse click at the specified x,y coordinates. Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) ScrollViewport

func (r *ComputerService) ScrollViewport(ctx context.Context, id string, body ComputerScrollViewportParams, opts ...option.RequestOption) (res *ActionResult, err error)

Scroll at the specified x,y position by delta dx,dy. Coordinates are screenshot pixel positions. Optionally specify tab_id (browser sessions only)

func (*ComputerService) SetViewport

func (r *ComputerService) SetViewport(ctx context.Context, id string, body ComputerSetViewportParams, opts ...option.RequestOption) (res *ActionResult, err error)

Change the browser viewport dimensions and scale factor. Optionally specify tab_id (browser sessions only)

func (*ComputerService) StreamEvents

func (r *ComputerService) StreamEvents(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Stream real-time events using Server-Sent Events (SSE)

func (*ComputerService) StreamScreencast

func (r *ComputerService) StreamScreencast(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Stream only screencast frames (base64 JPEG images) using Server-Sent Events (SSE) for live browser viewing

func (*ComputerService) Terminate

func (r *ComputerService) Terminate(ctx context.Context, id string, opts ...option.RequestOption) (err error)

Terminate and clean up a computer instance, stopping the session and recording metrics

func (*ComputerService) TypeText

func (r *ComputerService) TypeText(ctx context.Context, id string, body ComputerTypeTextParams, opts ...option.RequestOption) (res *ActionResult, err error)

Type text into the currently focused element in the browser. Optionally specify tab_id (browser sessions only)

type ComputerSetViewportParams

type ComputerSetViewportParams struct {
	Height      param.Opt[int64]   `json:"height,omitzero"`
	ScaleFactor param.Opt[float64] `json:"scale_factor,omitzero"`
	TabID       param.Opt[string]  `json:"tab_id,omitzero"`
	Width       param.Opt[int64]   `json:"width,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerSetViewportParams) MarshalJSON

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

func (*ComputerSetViewportParams) UnmarshalJSON

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

type ComputerTabDeleteParams

type ComputerTabDeleteParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type ComputerTabNewParams

type ComputerTabNewParams struct {
	URL param.Opt[string] `json:"url,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerTabNewParams) MarshalJSON

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

func (*ComputerTabNewParams) UnmarshalJSON

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

type ComputerTabService

type ComputerTabService struct {
	Options []option.RequestOption
}

ComputerTabService contains methods and other services that help with interacting with the computer 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 NewComputerTabService method instead.

func NewComputerTabService

func NewComputerTabService(opts ...option.RequestOption) (r ComputerTabService)

NewComputerTabService 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 (*ComputerTabService) Delete

func (r *ComputerTabService) Delete(ctx context.Context, tabID string, body ComputerTabDeleteParams, opts ...option.RequestOption) (res *ActionResult, err error)

Close a specific tab by ID. Cannot close the last remaining tab (browser sessions only). Tab IDs come from ListTabs.

func (*ComputerTabService) List

func (r *ComputerTabService) List(ctx context.Context, id string, opts ...option.RequestOption) (res *ActionResult, err error)

Get a list of open tabs with IDs, URLs, titles, and main tab status (browser sessions only). Includes external CDP pages (e.g., Playwright). Excludes devtools:// and chrome:// tabs. Results may be eventually consistent for newly created tabs.

func (*ComputerTabService) New

Create a new tab, optionally navigating to a URL. The new tab becomes the main tab (browser sessions only).

func (*ComputerTabService) Switch

func (r *ComputerTabService) Switch(ctx context.Context, tabID string, body ComputerTabSwitchParams, opts ...option.RequestOption) (res *ActionResult, err error)

Switch the main/active tab to a different tab by ID (browser sessions only). Tab IDs come from ListTabs.

type ComputerTabSwitchParams

type ComputerTabSwitchParams struct {
	ID string `path:"id,required" json:"-"`
	// contains filtered or unexported fields
}

type ComputerTypeTextParams

type ComputerTypeTextParams struct {
	TabID param.Opt[string] `json:"tab_id,omitzero"`
	Text  param.Opt[string] `json:"text,omitzero"`
	// contains filtered or unexported fields
}

func (ComputerTypeTextParams) MarshalJSON

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

func (*ComputerTypeTextParams) UnmarshalJSON

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

type Error

type Error = apierror.Error

type V2GoBackendInternalTypesPageContext

type V2GoBackendInternalTypesPageContext struct {
	DeviceScaleFactor float64 `json:"device_scale_factor"`
	IsMainTab         bool    `json:"is_main_tab"`
	PageHeight        int64   `json:"page_height"`
	PageWidth         int64   `json:"page_width"`
	ScrollX           float64 `json:"scroll_x"`
	ScrollY           float64 `json:"scroll_y"`
	TabID             string  `json:"tab_id"`
	Title             string  `json:"title"`
	URL               string  `json:"url"`
	ViewportHeight    int64   `json:"viewport_height"`
	ViewportWidth     int64   `json:"viewport_width"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		DeviceScaleFactor respjson.Field
		IsMainTab         respjson.Field
		PageHeight        respjson.Field
		PageWidth         respjson.Field
		ScrollX           respjson.Field
		ScrollY           respjson.Field
		TabID             respjson.Field
		Title             respjson.Field
		URL               respjson.Field
		ViewportHeight    respjson.Field
		ViewportWidth     respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (V2GoBackendInternalTypesPageContext) RawJSON

Returns the unmodified JSON received from the API

func (*V2GoBackendInternalTypesPageContext) UnmarshalJSON

func (r *V2GoBackendInternalTypesPageContext) 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

Jump to

Keyboard shortcuts

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