Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.15.0"
".": "0.16.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 64
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e21f0324774a1762bc2bba0da3a8a6b0d0e74720d7a1c83dec813f9e027fcf58.yml
openapi_spec_hash: f1b636abfd6cb8e7c2ba7ffb8e53b9ba
config_hash: 09a2df23048cb16689c9a390d9e5bc47
configured_endpoints: 65
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ecf484375ede1edd7754779ad8beeebd4ba9118152fe6cd65772dc7245a19dee.yml
openapi_spec_hash: b1f3f05005f75cbf5b82299459e2aa9b
config_hash: 3ded7a0ed77b1bfd68eabc6763521fe8
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.16.0 (2025-10-27)

Full Changelog: [v0.15.0...v0.16.0](https://github.com/onkernel/kernel-go-sdk/compare/v0.15.0...v0.16.0)

### Features

* ad hoc playwright code exec AP| ([8589fb2](https://github.com/onkernel/kernel-go-sdk/commit/8589fb22265ec8ad4c5a02b7a485c78e8a5f45da))

## 0.15.0 (2025-10-17)

Full Changelog: [v0.14.2...v0.15.0](https://github.com/onkernel/kernel-go-sdk/compare/v0.14.2...v0.15.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/onkernel/kernel-go-sdk@v0.15.0'
go get -u 'github.com/onkernel/kernel-go-sdk@v0.16.0'
```

<!-- x-release-please-end -->
Expand Down
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ Methods:
- <code title="post /browsers/{id}/computer/scroll">client.Browsers.Computer.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserComputerService.Scroll">Scroll</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserComputerScrollParams">BrowserComputerScrollParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="post /browsers/{id}/computer/type">client.Browsers.Computer.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserComputerService.TypeText">TypeText</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserComputerTypeTextParams">BrowserComputerTypeTextParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>

## Playwright

Response Types:

- <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserPlaywrightExecuteResponse">BrowserPlaywrightExecuteResponse</a>

Methods:

- <code title="post /browsers/{id}/playwright/execute">client.Browsers.Playwright.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserPlaywrightService.Execute">Execute</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserPlaywrightExecuteParams">BrowserPlaywrightExecuteParams</a>) (<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/onkernel/kernel-go-sdk#BrowserPlaywrightExecuteResponse">BrowserPlaywrightExecuteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Profiles

Methods:
Expand Down
14 changes: 8 additions & 6 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ import (
// automatically. You should not instantiate this service directly, and instead use
// the [NewBrowserService] method instead.
type BrowserService struct {
Options []option.RequestOption
Replays BrowserReplayService
Fs BrowserFService
Process BrowserProcessService
Logs BrowserLogService
Computer BrowserComputerService
Options []option.RequestOption
Replays BrowserReplayService
Fs BrowserFService
Process BrowserProcessService
Logs BrowserLogService
Computer BrowserComputerService
Playwright BrowserPlaywrightService
}

// NewBrowserService generates a new service that applies the given options to each
Expand All @@ -50,6 +51,7 @@ func NewBrowserService(opts ...option.RequestOption) (r BrowserService) {
r.Process = NewBrowserProcessService(opts...)
r.Logs = NewBrowserLogService(opts...)
r.Computer = NewBrowserComputerService(opts...)
r.Playwright = NewBrowserPlaywrightService(opts...)
return
}

Expand Down
101 changes: 101 additions & 0 deletions browserplaywright.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package kernel

import (
"context"
"errors"
"fmt"
"net/http"
"slices"

"github.com/onkernel/kernel-go-sdk/internal/apijson"
"github.com/onkernel/kernel-go-sdk/internal/requestconfig"
"github.com/onkernel/kernel-go-sdk/option"
"github.com/onkernel/kernel-go-sdk/packages/param"
"github.com/onkernel/kernel-go-sdk/packages/respjson"
)

// BrowserPlaywrightService contains methods and other services that help with
// interacting with the kernel 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 [NewBrowserPlaywrightService] method instead.
type BrowserPlaywrightService struct {
Options []option.RequestOption
}

// NewBrowserPlaywrightService 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 NewBrowserPlaywrightService(opts ...option.RequestOption) (r BrowserPlaywrightService) {
r = BrowserPlaywrightService{}
r.Options = opts
return
}

// Execute arbitrary Playwright code in a fresh execution context against the
// browser. The code runs in the same VM as the browser, minimizing latency and
// maximizing throughput. It has access to 'page', 'context', and 'browser'
// variables. It can `return` a value, and this value is returned in the response.
func (r *BrowserPlaywrightService) Execute(ctx context.Context, id string, body BrowserPlaywrightExecuteParams, opts ...option.RequestOption) (res *BrowserPlaywrightExecuteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("browsers/%s/playwright/execute", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}

// Result of Playwright code execution
type BrowserPlaywrightExecuteResponse struct {
// Whether the code executed successfully
Success bool `json:"success,required"`
// Error message if execution failed
Error string `json:"error"`
// The value returned by the code (if any)
Result any `json:"result"`
// Standard error from the execution
Stderr string `json:"stderr"`
// Standard output from the execution
Stdout string `json:"stdout"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
Error respjson.Field
Result respjson.Field
Stderr respjson.Field
Stdout respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BrowserPlaywrightExecuteResponse) RawJSON() string { return r.JSON.raw }
func (r *BrowserPlaywrightExecuteResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type BrowserPlaywrightExecuteParams struct {
// TypeScript/JavaScript code to execute. The code has access to 'page', 'context',
// and 'browser' variables. It runs within a function, so you can use a return
// statement at the end to return a value. This value is returned as the `result`
// property in the response. Example: "await page.goto('https://example.com');
// return await page.title();"
Code string `json:"code,required"`
// Maximum execution time in seconds. Default is 60.
TimeoutSec param.Opt[int64] `json:"timeout_sec,omitzero"`
paramObj
}

func (r BrowserPlaywrightExecuteParams) MarshalJSON() (data []byte, err error) {
type shadow BrowserPlaywrightExecuteParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *BrowserPlaywrightExecuteParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
44 changes: 44 additions & 0 deletions browserplaywright_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package kernel_test

import (
"context"
"errors"
"os"
"testing"

"github.com/onkernel/kernel-go-sdk"
"github.com/onkernel/kernel-go-sdk/internal/testutil"
"github.com/onkernel/kernel-go-sdk/option"
)

func TestBrowserPlaywrightExecuteWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := kernel.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Browsers.Playwright.Execute(
context.TODO(),
"id",
kernel.BrowserPlaywrightExecuteParams{
Code: "code",
TimeoutSec: kernel.Int(1),
},
)
if err != nil {
var apierr *kernel.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.15.0" // x-release-please-version
const PackageVersion = "0.16.0" // x-release-please-version