diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b8dda9b..554e34b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.29.0" + ".": "0.30.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 470e498..710d8bd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 97 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-46c8320dcd9f8fc596f469ef0dd1aafaca591ab36cf2a6f8a7297dc9136bdc71.yml -openapi_spec_hash: 1be1e6589cd94c581b241720e01a65bc -config_hash: b470456b217bb9502f5212311d395a6f +configured_endpoints: 98 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ccbe854895eb34a9562e33979f5f43cd6ad1f529d5924ee56e56f0c94dcf0454.yml +openapi_spec_hash: 2fa4ecbe742fc46fdde481188c1d885e +config_hash: dd218aae3f852dff79e77febc2077b8e diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e71c79..59f7eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.30.0 (2026-02-03) + +Full Changelog: [v0.29.0...v0.30.0](https://github.com/kernel/kernel-go-sdk/compare/v0.29.0...v0.30.0) + +### Features + +* Neil/kernel 872 templates v3 ([9a6a1bf](https://github.com/kernel/kernel-go-sdk/commit/9a6a1bf18929ef26c9fe7259dbd59682532d4bdc)) + ## 0.29.0 (2026-01-29) Full Changelog: [v0.28.0...v0.29.0](https://github.com/kernel/kernel-go-sdk/compare/v0.28.0...v0.29.0) diff --git a/README.md b/README.md index e8139cf..2438978 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Or to pin the version: ```sh -go get -u 'github.com/kernel/kernel-go-sdk@v0.29.0' +go get -u 'github.com/kernel/kernel-go-sdk@v0.30.0' ``` diff --git a/api.md b/api.md index c9d3ba0..95e03e0 100644 --- a/api.md +++ b/api.md @@ -53,6 +53,7 @@ Response Types: - kernel.InvocationUpdateResponse - kernel.InvocationListResponse - kernel.InvocationFollowResponseUnion +- kernel.InvocationListBrowsersResponse Methods: @@ -62,6 +63,7 @@ Methods: - client.Invocations.List(ctx context.Context, query kernel.InvocationListParams) (\*pagination.OffsetPagination[kernel.InvocationListResponse], error) - client.Invocations.DeleteBrowsers(ctx context.Context, id string) error - client.Invocations.Follow(ctx context.Context, id string, query kernel.InvocationFollowParams) (\*kernel.InvocationFollowResponseUnion, error) +- client.Invocations.ListBrowsers(ctx context.Context, id string) (\*kernel.InvocationListBrowsersResponse, error) # Browsers diff --git a/internal/version.go b/internal/version.go index ecc4b71..7d5879c 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.29.0" // x-release-please-version +const PackageVersion = "0.30.0" // x-release-please-version diff --git a/invocation.go b/invocation.go index ca37ce5..aa23a19 100644 --- a/invocation.go +++ b/invocation.go @@ -133,6 +133,18 @@ func (r *InvocationService) FollowStreaming(ctx context.Context, id string, quer return ssestream.NewStream[InvocationFollowResponseUnion](ssestream.NewDecoder(raw), err) } +// Returns all active browser sessions created within the specified invocation. +func (r *InvocationService) ListBrowsers(ctx context.Context, id string, opts ...option.RequestOption) (res *InvocationListBrowsersResponse, err error) { + opts = slices.Concat(r.Options, opts) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("invocations/%s/browsers", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + // An event representing the current state of an invocation. type InvocationStateEvent struct { // Event type identifier (always "invocation_state"). @@ -507,6 +519,85 @@ func (r *InvocationFollowResponseUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type InvocationListBrowsersResponse struct { + Browsers []InvocationListBrowsersResponseBrowser `json:"browsers,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Browsers respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InvocationListBrowsersResponse) RawJSON() string { return r.JSON.raw } +func (r *InvocationListBrowsersResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type InvocationListBrowsersResponseBrowser struct { + // Websocket URL for Chrome DevTools Protocol connections to the browser session + CdpWsURL string `json:"cdp_ws_url,required"` + // When the browser session was created. + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + // Whether the browser session is running in headless mode. + Headless bool `json:"headless,required"` + // Unique identifier for the browser session + SessionID string `json:"session_id,required"` + // Whether the browser session is running in stealth mode. + Stealth bool `json:"stealth,required"` + // The number of seconds of inactivity before the browser session is terminated. + TimeoutSeconds int64 `json:"timeout_seconds,required"` + // Remote URL for live viewing the browser session. Only available for non-headless + // browsers. + BrowserLiveViewURL string `json:"browser_live_view_url"` + // When the browser session was soft-deleted. Only present for deleted sessions. + DeletedAt time.Time `json:"deleted_at" format:"date-time"` + // Whether the browser session is running in kiosk mode. + KioskMode bool `json:"kiosk_mode"` + // DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead. + // + // Deprecated: deprecated + Persistence BrowserPersistence `json:"persistence"` + // Browser profile metadata. + Profile Profile `json:"profile"` + // ID of the proxy associated with this browser session, if any. + ProxyID string `json:"proxy_id"` + // Initial browser window size in pixels with optional refresh rate. If omitted, + // image defaults apply (1920x1080@25). Only specific viewport configurations are + // supported. The server will reject unsupported combinations. Supported + // resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, 1440x900@25, + // 1280x800@60, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will + // be automatically determined from the width and height if they match a supported + // configuration exactly. Note: Higher resolutions may affect the responsiveness of + // live view browser + Viewport shared.BrowserViewport `json:"viewport"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CdpWsURL respjson.Field + CreatedAt respjson.Field + Headless respjson.Field + SessionID respjson.Field + Stealth respjson.Field + TimeoutSeconds respjson.Field + BrowserLiveViewURL respjson.Field + DeletedAt respjson.Field + KioskMode respjson.Field + Persistence respjson.Field + Profile respjson.Field + ProxyID respjson.Field + Viewport respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InvocationListBrowsersResponseBrowser) RawJSON() string { return r.JSON.raw } +func (r *InvocationListBrowsersResponseBrowser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + type InvocationNewParams struct { // Name of the action to invoke ActionName string `json:"action_name,required"` diff --git a/invocation_test.go b/invocation_test.go index a506506..23f1600 100644 --- a/invocation_test.go +++ b/invocation_test.go @@ -150,3 +150,26 @@ func TestInvocationDeleteBrowsers(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestInvocationListBrowsers(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.Invocations.ListBrowsers(context.TODO(), "id") + 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()) + } +}