Skip to content

Commit 387045c

Browse files
feat: browser_pools: add start_url config (KERNEL-1217 PR 2)
1 parent aa45d8f commit 387045c

6 files changed

Lines changed: 54 additions & 2 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: 112
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-b51c72a040c8dfea9c0693de6631feabfffe42922d5feb60b4ac0ee5c83bb8f4.yml
3-
openapi_spec_hash: 8b671cfe4debe8d9ad7c39ba5b0eaf6d
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-7d2d29d7598105d50e5118e0bc5ac654361a92cb95555705dbd1d236848e1456.yml
3+
openapi_spec_hash: 10002eae793e08f81932239bbc72b503
44
config_hash: 08d55086449943a8fec212b870061a3f

browser.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ type BrowserNewResponse struct {
328328
Profile Profile `json:"profile"`
329329
// ID of the proxy associated with this browser session, if any.
330330
ProxyID string `json:"proxy_id"`
331+
// URL the session was asked to navigate to on creation, if any. Recorded for
332+
// debugging — navigation is best-effort and may have failed.
333+
StartURL string `json:"start_url"`
331334
// Session usage metrics.
332335
Usage BrowserUsage `json:"usage"`
333336
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -361,6 +364,7 @@ type BrowserNewResponse struct {
361364
Pool respjson.Field
362365
Profile respjson.Field
363366
ProxyID respjson.Field
367+
StartURL respjson.Field
364368
Usage respjson.Field
365369
Viewport respjson.Field
366370
ExtraFields map[string]respjson.Field
@@ -411,6 +415,9 @@ type BrowserGetResponse struct {
411415
Profile Profile `json:"profile"`
412416
// ID of the proxy associated with this browser session, if any.
413417
ProxyID string `json:"proxy_id"`
418+
// URL the session was asked to navigate to on creation, if any. Recorded for
419+
// debugging — navigation is best-effort and may have failed.
420+
StartURL string `json:"start_url"`
414421
// Session usage metrics.
415422
Usage BrowserUsage `json:"usage"`
416423
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -444,6 +451,7 @@ type BrowserGetResponse struct {
444451
Pool respjson.Field
445452
Profile respjson.Field
446453
ProxyID respjson.Field
454+
StartURL respjson.Field
447455
Usage respjson.Field
448456
Viewport respjson.Field
449457
ExtraFields map[string]respjson.Field
@@ -494,6 +502,9 @@ type BrowserUpdateResponse struct {
494502
Profile Profile `json:"profile"`
495503
// ID of the proxy associated with this browser session, if any.
496504
ProxyID string `json:"proxy_id"`
505+
// URL the session was asked to navigate to on creation, if any. Recorded for
506+
// debugging — navigation is best-effort and may have failed.
507+
StartURL string `json:"start_url"`
497508
// Session usage metrics.
498509
Usage BrowserUsage `json:"usage"`
499510
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -527,6 +538,7 @@ type BrowserUpdateResponse struct {
527538
Pool respjson.Field
528539
Profile respjson.Field
529540
ProxyID respjson.Field
541+
StartURL respjson.Field
530542
Usage respjson.Field
531543
Viewport respjson.Field
532544
ExtraFields map[string]respjson.Field
@@ -577,6 +589,9 @@ type BrowserListResponse struct {
577589
Profile Profile `json:"profile"`
578590
// ID of the proxy associated with this browser session, if any.
579591
ProxyID string `json:"proxy_id"`
592+
// URL the session was asked to navigate to on creation, if any. Recorded for
593+
// debugging — navigation is best-effort and may have failed.
594+
StartURL string `json:"start_url"`
580595
// Session usage metrics.
581596
Usage BrowserUsage `json:"usage"`
582597
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -610,6 +625,7 @@ type BrowserListResponse struct {
610625
Pool respjson.Field
611626
Profile respjson.Field
612627
ProxyID respjson.Field
628+
StartURL respjson.Field
613629
Usage respjson.Field
614630
Viewport respjson.Field
615631
ExtraFields map[string]respjson.Field
@@ -665,6 +681,12 @@ type BrowserNewParams struct {
665681
// Optional proxy to associate to the browser session. Must reference a proxy
666682
// belonging to the caller's org.
667683
ProxyID param.Opt[string] `json:"proxy_id,omitzero"`
684+
// Optional URL to navigate to immediately after the browser is created.
685+
// Best-effort: failures to navigate do not fail browser creation. Any pre-existing
686+
// tabs are reduced to a single tab which is then navigated. Accepts any URL
687+
// Chromium can resolve, including chrome:// pages. Ignored when reusing an
688+
// existing persistent session.
689+
StartURL param.Opt[string] `json:"start_url,omitzero"`
668690
// If true, launches the browser in stealth mode to reduce detection by anti-bot
669691
// mechanisms.
670692
Stealth param.Opt[bool] `json:"stealth,omitzero"`

browser_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func TestBrowserNewWithOptionalParams(t *testing.T) {
4747
SaveChanges: kernel.Bool(true),
4848
},
4949
ProxyID: kernel.String("proxy_id"),
50+
StartURL: kernel.String("https://example.com"),
5051
Stealth: kernel.Bool(true),
5152
TimeoutSeconds: kernel.Int(10),
5253
Viewport: shared.BrowserViewportParam{

browserpool.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ type BrowserPoolBrowserPoolConfig struct {
196196
// Optional proxy to associate to the browser session. Must reference a proxy
197197
// belonging to the caller's org.
198198
ProxyID string `json:"proxy_id"`
199+
// Optional URL to navigate to when a new browser is warmed into the pool.
200+
// Best-effort: failures to navigate do not fail pool fill. Only applied to
201+
// newly-warmed browsers — browsers reused via release/acquire keep whatever URL
202+
// the previous lease left them on. Accepts any URL Chromium can resolve, including
203+
// chrome:// pages.
204+
StartURL string `json:"start_url"`
199205
// If true, launches the browser in stealth mode to reduce detection by anti-bot
200206
// mechanisms.
201207
Stealth bool `json:"stealth"`
@@ -226,6 +232,7 @@ type BrowserPoolBrowserPoolConfig struct {
226232
Name respjson.Field
227233
Profile respjson.Field
228234
ProxyID respjson.Field
235+
StartURL respjson.Field
229236
Stealth respjson.Field
230237
TimeoutSeconds respjson.Field
231238
Viewport respjson.Field
@@ -277,6 +284,9 @@ type BrowserPoolAcquireResponse struct {
277284
Profile Profile `json:"profile"`
278285
// ID of the proxy associated with this browser session, if any.
279286
ProxyID string `json:"proxy_id"`
287+
// URL the session was asked to navigate to on creation, if any. Recorded for
288+
// debugging — navigation is best-effort and may have failed.
289+
StartURL string `json:"start_url"`
280290
// Session usage metrics.
281291
Usage BrowserUsage `json:"usage"`
282292
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -310,6 +320,7 @@ type BrowserPoolAcquireResponse struct {
310320
Pool respjson.Field
311321
Profile respjson.Field
312322
ProxyID respjson.Field
323+
StartURL respjson.Field
313324
Usage respjson.Field
314325
Viewport respjson.Field
315326
ExtraFields map[string]respjson.Field
@@ -340,6 +351,12 @@ type BrowserPoolNewParams struct {
340351
// Optional proxy to associate to the browser session. Must reference a proxy
341352
// belonging to the caller's org.
342353
ProxyID param.Opt[string] `json:"proxy_id,omitzero"`
354+
// Optional URL to navigate to when a new browser is warmed into the pool.
355+
// Best-effort: failures to navigate do not fail pool fill. Only applied to
356+
// newly-warmed browsers — browsers reused via release/acquire keep whatever URL
357+
// the previous lease left them on. Accepts any URL Chromium can resolve, including
358+
// chrome:// pages.
359+
StartURL param.Opt[string] `json:"start_url,omitzero"`
343360
// If true, launches the browser in stealth mode to reduce detection by anti-bot
344361
// mechanisms.
345362
Stealth param.Opt[bool] `json:"stealth,omitzero"`
@@ -401,6 +418,12 @@ type BrowserPoolUpdateParams struct {
401418
// Optional proxy to associate to the browser session. Must reference a proxy
402419
// belonging to the caller's org.
403420
ProxyID param.Opt[string] `json:"proxy_id,omitzero"`
421+
// Optional URL to navigate to when a new browser is warmed into the pool.
422+
// Best-effort: failures to navigate do not fail pool fill. Only applied to
423+
// newly-warmed browsers — browsers reused via release/acquire keep whatever URL
424+
// the previous lease left them on. Accepts any URL Chromium can resolve, including
425+
// chrome:// pages.
426+
StartURL param.Opt[string] `json:"start_url,omitzero"`
404427
// If true, launches the browser in stealth mode to reduce detection by anti-bot
405428
// mechanisms.
406429
Stealth param.Opt[bool] `json:"stealth,omitzero"`

browserpool_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestBrowserPoolNewWithOptionalParams(t *testing.T) {
4646
SaveChanges: kernel.Bool(true),
4747
},
4848
ProxyID: kernel.String("proxy_id"),
49+
StartURL: kernel.String("https://example.com"),
4950
Stealth: kernel.Bool(true),
5051
TimeoutSeconds: kernel.Int(60),
5152
Viewport: shared.BrowserViewportParam{
@@ -122,6 +123,7 @@ func TestBrowserPoolUpdateWithOptionalParams(t *testing.T) {
122123
SaveChanges: kernel.Bool(true),
123124
},
124125
ProxyID: kernel.String("proxy_id"),
126+
StartURL: kernel.String("https://example.com"),
125127
Stealth: kernel.Bool(true),
126128
TimeoutSeconds: kernel.Int(60),
127129
Viewport: shared.BrowserViewportParam{

invocation.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ type InvocationListBrowsersResponseBrowser struct {
574574
Profile Profile `json:"profile"`
575575
// ID of the proxy associated with this browser session, if any.
576576
ProxyID string `json:"proxy_id"`
577+
// URL the session was asked to navigate to on creation, if any. Recorded for
578+
// debugging — navigation is best-effort and may have failed.
579+
StartURL string `json:"start_url"`
577580
// Session usage metrics.
578581
Usage BrowserUsage `json:"usage"`
579582
// Initial browser window size in pixels with optional refresh rate. If omitted,
@@ -607,6 +610,7 @@ type InvocationListBrowsersResponseBrowser struct {
607610
Pool respjson.Field
608611
Profile respjson.Field
609612
ProxyID respjson.Field
613+
StartURL respjson.Field
610614
Usage respjson.Field
611615
Viewport respjson.Field
612616
ExtraFields map[string]respjson.Field

0 commit comments

Comments
 (0)