diff --git a/.release-please-manifest.json b/.release-please-manifest.json index da59f99..2aca35a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.0" + ".": "0.5.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index be606c6..d654666 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5ee11..ce46874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 2221887..0e2dd3d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Or to pin the 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' ``` diff --git a/app.go b/app.go index c3d26dc..6e6f185 100644 --- a/app.go +++ b/app.go @@ -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" diff --git a/appdeployment.go b/appdeployment.go index c565687..373e942 100644 --- a/appdeployment.go +++ b/appdeployment.go @@ -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" diff --git a/appinvocation.go b/appinvocation.go index 48e4c44..18663be 100644 --- a/appinvocation.go +++ b/appinvocation.go @@ -35,7 +35,7 @@ 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" @@ -43,7 +43,7 @@ func (r *AppInvocationService) New(ctx context.Context, body AppInvocationNewPar 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 == "" { @@ -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 == "" { diff --git a/browser.go b/browser.go index c0254da..bbcc1f5 100644 --- a/browser.go +++ b/browser.go @@ -4,6 +4,7 @@ package kernel import ( "context" + "encoding/json" "errors" "fmt" "net/http" @@ -36,7 +37,7 @@ 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" @@ -44,7 +45,7 @@ func (r *BrowserService) New(ctx context.Context, body BrowserNewParams, 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 == "" { @@ -56,7 +57,7 @@ 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" @@ -64,7 +65,7 @@ func (r *BrowserService) List(ctx context.Context, opts ...option.RequestOption) 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...) @@ -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...) @@ -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. @@ -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 diff --git a/browser_test.go b/browser_test.go index 8646234..91c6038 100644 --- a/browser_test.go +++ b/browser_test.go @@ -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 diff --git a/internal/version.go b/internal/version.go index 5c62cac..67c4d40 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.4.0" // x-release-please-version +const PackageVersion = "0.5.0" // x-release-please-version diff --git a/packages/param/encoder.go b/packages/param/encoder.go index ba1821c..4ecb57b 100644 --- a/packages/param/encoder.go +++ b/packages/param/encoder.go @@ -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 { @@ -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 @@ -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 { @@ -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{ diff --git a/packages/param/encoder_test.go b/packages/param/encoder_test.go index ec87450..c94cfc6 100644 --- a/packages/param/encoder_test.go +++ b/packages/param/encoder_test.go @@ -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) { @@ -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)) + } + }) + } +} diff --git a/scripts/bootstrap b/scripts/bootstrap index 99810d3..d6ac165 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -13,4 +13,4 @@ fi echo "==> Installing Go dependencies…" -go mod tidy +go mod tidy -e