Skip to content
Merged
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.4.0"
".": "0.5.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 11
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-64ccdff4ca5d73d79d89e817fe83ccfd3d529696df3e6818c3c75e586ae00801.yml
openapi_spec_hash: 21c7b8757fc0cc9415cda1bc06251de6
config_hash: b3fcacd707da56b21d31ce0baf4fb87d
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-4502c65bef0843a6ae96d23bba075433af6bab49b55b544b1522f63e7881c00c.yml
openapi_spec_hash: 3e67b77bbc8cd6155b8f66f3271f2643
config_hash: c6bab7ac8da570a5abbcfb19db119b6b
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.5.0 (2025-06-04)

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

### Features

* **api:** update via SDK Studio ([f0b66f8](https://github.com/onkernel/kernel-go-sdk/commit/f0b66f87541f4bc109f479906c3554bffb38c26f))
* **api:** update via SDK Studio ([d60d333](https://github.com/onkernel/kernel-go-sdk/commit/d60d3337306d90c8c51a54c6abeece2731dd4834))
* **client:** allow overriding unions ([51d877d](https://github.com/onkernel/kernel-go-sdk/commit/51d877d1ae7584b237fdb9238e97949b832c3cc8))


### Bug Fixes

* **client:** cast to raw message when converting to params ([de14358](https://github.com/onkernel/kernel-go-sdk/commit/de14358a78248e642c03bd669f9c361bf6b3c8ba))
* fix error ([7d27985](https://github.com/onkernel/kernel-go-sdk/commit/7d2798511671e285d41943c51c3ac8ebc6a7d6d6))


### Chores

* make go mod tidy continue on error ([91b5021](https://github.com/onkernel/kernel-go-sdk/commit/91b50217a8a08dd06ba64e05d025386d91d586c8))

## 0.4.0 (2025-05-28)

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

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

<!-- x-release-please-end -->
Expand Down
3 changes: 1 addition & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func NewAppService(opts ...option.RequestOption) (r AppService) {
return
}

// List application versions for the authenticated user. Optionally filter by app
// name and/or version label.
// List applications. Optionally filter by app name and/or version label.
func (r *AppService) List(ctx context.Context, query AppListParams, opts ...option.RequestOption) (res *[]AppListResponse, err error) {
opts = append(r.Options[:], opts...)
path := "apps"
Expand Down
2 changes: 1 addition & 1 deletion appdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewAppDeploymentService(opts ...option.RequestOption) (r AppDeploymentServi
return
}

// Deploy a new application
// Deploy a new application and associated actions to Kernel.
func (r *AppDeploymentService) New(ctx context.Context, body AppDeploymentNewParams, opts ...option.RequestOption) (res *AppDeploymentNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "deploy"
Expand Down
6 changes: 3 additions & 3 deletions appinvocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func NewAppInvocationService(opts ...option.RequestOption) (r AppInvocationServi
return
}

// Invoke an application
// Invoke an action.
func (r *AppInvocationService) New(ctx context.Context, body AppInvocationNewParams, opts ...option.RequestOption) (res *AppInvocationNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "invocations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}

// Get an app invocation by id
// Get details about an invocation's status and output.
func (r *AppInvocationService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *AppInvocationGetResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
Expand All @@ -55,7 +55,7 @@ func (r *AppInvocationService) Get(ctx context.Context, id string, opts ...optio
return
}

// Update invocation status or output
// Update an invocation's status or output.
func (r *AppInvocationService) Update(ctx context.Context, id string, body AppInvocationUpdateParams, opts ...option.RequestOption) (res *AppInvocationUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
Expand Down
16 changes: 10 additions & 6 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package kernel

import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -36,15 +37,15 @@ func NewBrowserService(opts ...option.RequestOption) (r BrowserService) {
return
}

// Create Browser Session
// Create a new browser session from within an action.
func (r *BrowserService) New(ctx context.Context, body BrowserNewParams, opts ...option.RequestOption) (res *BrowserNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "browsers"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}

// Get Browser Session by ID
// Get information about a browser session.
func (r *BrowserService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *BrowserGetResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
Expand All @@ -56,15 +57,15 @@ func (r *BrowserService) Get(ctx context.Context, id string, opts ...option.Requ
return
}

// List active browser sessions for the authenticated user
// List active browser sessions
func (r *BrowserService) List(ctx context.Context, opts ...option.RequestOption) (res *[]BrowserListResponse, err error) {
opts = append(r.Options[:], opts...)
path := "browsers"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}

// Delete a persistent browser session by persistent_id query parameter.
// Delete a persistent browser session by its persistent_id.
func (r *BrowserService) Delete(ctx context.Context, body BrowserDeleteParams, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
Expand All @@ -73,7 +74,7 @@ func (r *BrowserService) Delete(ctx context.Context, body BrowserDeleteParams, o
return
}

// Delete Browser Session by ID
// Delete a browser session by ID
func (r *BrowserService) DeleteByID(ctx context.Context, id string, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
Expand Down Expand Up @@ -110,7 +111,7 @@ func (r *BrowserPersistence) UnmarshalJSON(data []byte) error {
// be used at the last possible moment before sending a request. Test for this with
// BrowserPersistenceParam.Overrides()
func (r BrowserPersistence) ToParam() BrowserPersistenceParam {
return param.Override[BrowserPersistenceParam](r.RawJSON())
return param.Override[BrowserPersistenceParam](json.RawMessage(r.RawJSON()))
}

// Optional persistence configuration for the browser session.
Expand Down Expand Up @@ -211,6 +212,9 @@ func (r *BrowserListResponse) UnmarshalJSON(data []byte) error {
type BrowserNewParams struct {
// action invocation ID
InvocationID string `json:"invocation_id,required"`
// If true, launches the browser in stealth mode to reduce detection by anti-bot
// mechanisms.
Stealth param.Opt[bool] `json:"stealth,omitzero"`
// Optional persistence configuration for the browser session.
Persistence BrowserPersistenceParam `json:"persistence,omitzero"`
paramObj
Expand Down
1 change: 1 addition & 0 deletions browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestBrowserNewWithOptionalParams(t *testing.T) {
Persistence: kernel.BrowserPersistenceParam{
ID: "my-awesome-browser-for-user-1234",
},
Stealth: kernel.Bool(true),
})
if err != nil {
var apierr *kernel.Error
Expand Down
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.4.0" // x-release-please-version
const PackageVersion = "0.5.0" // x-release-please-version
10 changes: 7 additions & 3 deletions packages/param/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MarshalObject[T ParamStruct](f T, underlying any) ([]byte, error) {
// MarshalWithExtras is used to marshal a struct with additional properties.
//
// Stability for the API of MarshalWithExtras is not guaranteed.
func MarshalWithExtras[T ParamStruct](f T, underlying any, extras map[string]any) ([]byte, error) {
func MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[string]R) ([]byte, error) {
if f.null() {
return []byte("null"), nil
} else if len(extras) > 0 {
Expand All @@ -44,7 +44,8 @@ func MarshalWithExtras[T ParamStruct](f T, underlying any, extras map[string]any
return nil, err
}
for k, v := range extras {
if v == Omit {
var a any = v
if a == Omit {
// Errors when handling ForceOmitted are ignored.
if b, e := sjson.DeleteBytes(bytes, k); e == nil {
bytes = b
Expand All @@ -67,7 +68,7 @@ func MarshalWithExtras[T ParamStruct](f T, underlying any, extras map[string]any
// MarshalUnion uses a shimmed 'encoding/json' from Go 1.24, to support the 'omitzero' tag
//
// Stability for the API of MarshalUnion is not guaranteed.
func MarshalUnion[T any](variants ...any) ([]byte, error) {
func MarshalUnion[T ParamStruct](metadata T, variants ...any) ([]byte, error) {
nPresent := 0
presentIdx := -1
for i, variant := range variants {
Expand All @@ -77,6 +78,9 @@ func MarshalUnion[T any](variants ...any) ([]byte, error) {
}
}
if nPresent == 0 || presentIdx == -1 {
if ovr, ok := metadata.Overrides(); ok {
return shimjson.Marshal(ovr)
}
return []byte(`null`), nil
} else if nPresent > 1 {
return nil, &json.MarshalerError{
Expand Down
41 changes: 40 additions & 1 deletion packages/param/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ func TestExtraFieldsForceOmitted(t *testing.T) {
type UnionWithDates struct {
OfDate param.Opt[time.Time]
OfTime param.Opt[time.Time]
param.APIUnion
}

func (r UnionWithDates) MarshalJSON() (data []byte, err error) {
return param.MarshalUnion[UnionWithDates](param.EncodedAsDate(r.OfDate), r.OfTime)
return param.MarshalUnion(r, param.EncodedAsDate(r.OfDate), r.OfTime)
}

func TestUnionDateMarshal(t *testing.T) {
Expand Down Expand Up @@ -324,3 +325,41 @@ func TestOptionalInterfaceAssignability(t *testing.T) {

notOpt.implOpt() // silence the warning
}

type PrimitiveUnion struct {
OfString param.Opt[string]
OfInt param.Opt[int]
param.APIUnion
}

func (p PrimitiveUnion) MarshalJSON() (data []byte, err error) {
return param.MarshalUnion(p, p.OfString, p.OfInt)
}

func TestOverriddenUnion(t *testing.T) {
tests := map[string]struct {
value PrimitiveUnion
expected string
}{
"string": {
param.Override[PrimitiveUnion](json.RawMessage(`"hello"`)),
`"hello"`,
},
"int": {
param.Override[PrimitiveUnion](json.RawMessage(`42`)),
`42`,
},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
b, err := json.Marshal(test.value)
if err != nil {
t.Fatalf("didn't expect error %v, expected %s", err, test.expected)
}
if string(b) != test.expected {
t.Fatalf("expected %s, received %s", test.expected, string(b))
}
})
}
}
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fi

echo "==> Installing Go dependencies…"

go mod tidy
go mod tidy -e