Skip to content

Commit dbbb546

Browse files
feat(api): add browser ttls
1 parent 9542333 commit dbbb546

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 31
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e907afeabfeea49dedd783112ac3fd29267bc86f3d594f89ba9a2abf2bcbc9d8.yml
3-
openapi_spec_hash: 060ca6288c1a09b6d1bdf207a0011165
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-6f4aab5f0db80d6ce30ef40274eee347cce0a9465e7f1e5077f8f4a085251ddf.yml
3+
openapi_spec_hash: 8e83254243d1620b80a0dc8aa212ee0d
44
config_hash: f67e4b33b2fb30c1405ee2fff8096320

browser.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ func (r *BrowserPersistenceParam) UnmarshalJSON(data []byte) error {
138138
type BrowserNewResponse struct {
139139
// Websocket URL for Chrome DevTools Protocol connections to the browser session
140140
CdpWsURL string `json:"cdp_ws_url,required"`
141+
// Indicates whether the browser session is headless.
142+
Headless bool `json:"headless,required"`
141143
// Unique identifier for the browser session
142144
SessionID string `json:"session_id,required"`
145+
// Indicates whether the browser session is stealth.
146+
Stealth bool `json:"stealth,required"`
147+
// The number of seconds of inactivity before the browser session is terminated.
148+
TimeoutSeconds int64 `json:"timeout_seconds,required"`
143149
// Remote URL for live viewing the browser session. Only available for non-headless
144150
// browsers.
145151
BrowserLiveViewURL string `json:"browser_live_view_url"`
@@ -148,7 +154,10 @@ type BrowserNewResponse struct {
148154
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
149155
JSON struct {
150156
CdpWsURL respjson.Field
157+
Headless respjson.Field
151158
SessionID respjson.Field
159+
Stealth respjson.Field
160+
TimeoutSeconds respjson.Field
152161
BrowserLiveViewURL respjson.Field
153162
Persistence respjson.Field
154163
ExtraFields map[string]respjson.Field
@@ -165,8 +174,14 @@ func (r *BrowserNewResponse) UnmarshalJSON(data []byte) error {
165174
type BrowserGetResponse struct {
166175
// Websocket URL for Chrome DevTools Protocol connections to the browser session
167176
CdpWsURL string `json:"cdp_ws_url,required"`
177+
// Indicates whether the browser session is headless.
178+
Headless bool `json:"headless,required"`
168179
// Unique identifier for the browser session
169180
SessionID string `json:"session_id,required"`
181+
// Indicates whether the browser session is stealth.
182+
Stealth bool `json:"stealth,required"`
183+
// The number of seconds of inactivity before the browser session is terminated.
184+
TimeoutSeconds int64 `json:"timeout_seconds,required"`
170185
// Remote URL for live viewing the browser session. Only available for non-headless
171186
// browsers.
172187
BrowserLiveViewURL string `json:"browser_live_view_url"`
@@ -175,7 +190,10 @@ type BrowserGetResponse struct {
175190
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
176191
JSON struct {
177192
CdpWsURL respjson.Field
193+
Headless respjson.Field
178194
SessionID respjson.Field
195+
Stealth respjson.Field
196+
TimeoutSeconds respjson.Field
179197
BrowserLiveViewURL respjson.Field
180198
Persistence respjson.Field
181199
ExtraFields map[string]respjson.Field
@@ -192,8 +210,14 @@ func (r *BrowserGetResponse) UnmarshalJSON(data []byte) error {
192210
type BrowserListResponse struct {
193211
// Websocket URL for Chrome DevTools Protocol connections to the browser session
194212
CdpWsURL string `json:"cdp_ws_url,required"`
213+
// Indicates whether the browser session is headless.
214+
Headless bool `json:"headless,required"`
195215
// Unique identifier for the browser session
196216
SessionID string `json:"session_id,required"`
217+
// Indicates whether the browser session is stealth.
218+
Stealth bool `json:"stealth,required"`
219+
// The number of seconds of inactivity before the browser session is terminated.
220+
TimeoutSeconds int64 `json:"timeout_seconds,required"`
197221
// Remote URL for live viewing the browser session. Only available for non-headless
198222
// browsers.
199223
BrowserLiveViewURL string `json:"browser_live_view_url"`
@@ -202,7 +226,10 @@ type BrowserListResponse struct {
202226
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
203227
JSON struct {
204228
CdpWsURL respjson.Field
229+
Headless respjson.Field
205230
SessionID respjson.Field
231+
Stealth respjson.Field
232+
TimeoutSeconds respjson.Field
206233
BrowserLiveViewURL respjson.Field
207234
Persistence respjson.Field
208235
ExtraFields map[string]respjson.Field
@@ -225,6 +252,10 @@ type BrowserNewParams struct {
225252
// If true, launches the browser in stealth mode to reduce detection by anti-bot
226253
// mechanisms.
227254
Stealth param.Opt[bool] `json:"stealth,omitzero"`
255+
// The number of seconds of inactivity before the browser session is terminated.
256+
// Only applicable to non-persistent browsers. Activity includes CDP connections
257+
// and live view connections. Defaults to 60 seconds.
258+
TimeoutSeconds param.Opt[int64] `json:"timeout_seconds,omitzero"`
228259
// Optional persistence configuration for the browser session.
229260
Persistence BrowserPersistenceParam `json:"persistence,omitzero"`
230261
paramObj

browser_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func TestBrowserNewWithOptionalParams(t *testing.T) {
3232
Persistence: kernel.BrowserPersistenceParam{
3333
ID: "my-awesome-browser-for-user-1234",
3434
},
35-
Stealth: kernel.Bool(true),
35+
Stealth: kernel.Bool(true),
36+
TimeoutSeconds: kernel.Int(0),
3637
})
3738
if err != nil {
3839
var apierr *kernel.Error

0 commit comments

Comments
 (0)