Skip to content

Commit 8c46a0d

Browse files
feat: Allow auto-starting replays during browser creation and pool acquire
Stainless-Generated-From: 2dedcf550acbb3d29238c71dc117c2de12cac94b
1 parent 8bf86ae commit 8c46a0d

9 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎src/kernel/resources/browser_pools.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def create(
7878
proxy_id: str | Omit = omit,
7979
refresh_on_profile_update: bool | Omit = omit,
8080
region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit,
81+
start_replay: bool | Omit = omit,
8182
start_url: str | Omit = omit,
8283
stealth: bool | Omit = omit,
8384
telemetry: Optional[browser_pool_create_params.Telemetry] | Omit = omit,
@@ -146,6 +147,8 @@ def create(
146147
Region selection requires a Start-Up or Enterprise plan, defaults to us-east
147148
when omitted on create.
148149
150+
start_replay: Start replay recording automatically when a browser is acquired from this pool.
151+
149152
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
150153
Best-effort: failures to navigate do not fail pool fill. Only applied to
151154
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
@@ -205,6 +208,7 @@ def create(
205208
"proxy_id": proxy_id,
206209
"refresh_on_profile_update": refresh_on_profile_update,
207210
"region": region,
211+
"start_replay": start_replay,
208212
"start_url": start_url,
209213
"stealth": stealth,
210214
"telemetry": telemetry,
@@ -274,6 +278,7 @@ def update(
274278
proxy_id: str | Omit = omit,
275279
refresh_on_profile_update: bool | Omit = omit,
276280
size: int | Omit = omit,
281+
start_replay: bool | Omit = omit,
277282
start_url: str | Omit = omit,
278283
stealth: bool | Omit = omit,
279284
telemetry: Optional[browser_pool_update_params.Telemetry] | Omit = omit,
@@ -368,6 +373,9 @@ def update(
368373
maximum size is determined by your organization's pooled sessions limit (the sum
369374
of all pool sizes cannot exceed your limit).
370375
376+
start_replay: If provided, replaces whether replay recording starts automatically for future
377+
acquired browsers.
378+
371379
start_url: If provided, replaces the URL to navigate to when a new browser is warmed into
372380
the pool. Empty string clears the previously-set URL. Omit this field to leave
373381
it unchanged.
@@ -428,6 +436,7 @@ def update(
428436
"proxy_id": proxy_id,
429437
"refresh_on_profile_update": refresh_on_profile_update,
430438
"size": size,
439+
"start_replay": start_replay,
431440
"start_url": start_url,
432441
"stealth": stealth,
433442
"telemetry": telemetry,
@@ -564,6 +573,7 @@ def acquire(
564573
acquire_timeout_seconds: int | Omit = omit,
565574
name: str | Omit = omit,
566575
profile: BrowserProfile | Omit = omit,
576+
start_replay: bool | Omit = omit,
567577
start_url: str | Omit = omit,
568578
tags: TagsParam | Omit = omit,
569579
telemetry: Optional[browser_pool_acquire_params.Telemetry] | Omit = omit,
@@ -596,6 +606,9 @@ def acquire(
596606
specified, the matching profile will be loaded into the browser session.
597607
Profiles must be created beforehand.
598608
609+
start_replay: Start replay recording immediately for the acquired browser. Omit to use the
610+
pool's configured default.
611+
599612
start_url: Optional URL to navigate the acquired browser to. Overrides the pool's start_url
600613
for this acquire only. Best-effort: failures to navigate do not fail the
601614
acquire.
@@ -632,6 +645,7 @@ def acquire(
632645
"acquire_timeout_seconds": acquire_timeout_seconds,
633646
"name": name,
634647
"profile": profile,
648+
"start_replay": start_replay,
635649
"start_url": start_url,
636650
"tags": tags,
637651
"telemetry": telemetry,
@@ -787,6 +801,7 @@ async def create(
787801
proxy_id: str | Omit = omit,
788802
refresh_on_profile_update: bool | Omit = omit,
789803
region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit,
804+
start_replay: bool | Omit = omit,
790805
start_url: str | Omit = omit,
791806
stealth: bool | Omit = omit,
792807
telemetry: Optional[browser_pool_create_params.Telemetry] | Omit = omit,
@@ -855,6 +870,8 @@ async def create(
855870
Region selection requires a Start-Up or Enterprise plan, defaults to us-east
856871
when omitted on create.
857872
873+
start_replay: Start replay recording automatically when a browser is acquired from this pool.
874+
858875
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
859876
Best-effort: failures to navigate do not fail pool fill. Only applied to
860877
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
@@ -914,6 +931,7 @@ async def create(
914931
"proxy_id": proxy_id,
915932
"refresh_on_profile_update": refresh_on_profile_update,
916933
"region": region,
934+
"start_replay": start_replay,
917935
"start_url": start_url,
918936
"stealth": stealth,
919937
"telemetry": telemetry,
@@ -983,6 +1001,7 @@ async def update(
9831001
proxy_id: str | Omit = omit,
9841002
refresh_on_profile_update: bool | Omit = omit,
9851003
size: int | Omit = omit,
1004+
start_replay: bool | Omit = omit,
9861005
start_url: str | Omit = omit,
9871006
stealth: bool | Omit = omit,
9881007
telemetry: Optional[browser_pool_update_params.Telemetry] | Omit = omit,
@@ -1077,6 +1096,9 @@ async def update(
10771096
maximum size is determined by your organization's pooled sessions limit (the sum
10781097
of all pool sizes cannot exceed your limit).
10791098
1099+
start_replay: If provided, replaces whether replay recording starts automatically for future
1100+
acquired browsers.
1101+
10801102
start_url: If provided, replaces the URL to navigate to when a new browser is warmed into
10811103
the pool. Empty string clears the previously-set URL. Omit this field to leave
10821104
it unchanged.
@@ -1137,6 +1159,7 @@ async def update(
11371159
"proxy_id": proxy_id,
11381160
"refresh_on_profile_update": refresh_on_profile_update,
11391161
"size": size,
1162+
"start_replay": start_replay,
11401163
"start_url": start_url,
11411164
"stealth": stealth,
11421165
"telemetry": telemetry,
@@ -1273,6 +1296,7 @@ async def acquire(
12731296
acquire_timeout_seconds: int | Omit = omit,
12741297
name: str | Omit = omit,
12751298
profile: BrowserProfile | Omit = omit,
1299+
start_replay: bool | Omit = omit,
12761300
start_url: str | Omit = omit,
12771301
tags: TagsParam | Omit = omit,
12781302
telemetry: Optional[browser_pool_acquire_params.Telemetry] | Omit = omit,
@@ -1305,6 +1329,9 @@ async def acquire(
13051329
specified, the matching profile will be loaded into the browser session.
13061330
Profiles must be created beforehand.
13071331
1332+
start_replay: Start replay recording immediately for the acquired browser. Omit to use the
1333+
pool's configured default.
1334+
13081335
start_url: Optional URL to navigate the acquired browser to. Overrides the pool's start_url
13091336
for this acquire only. Best-effort: failures to navigate do not fail the
13101337
acquire.
@@ -1341,6 +1368,7 @@ async def acquire(
13411368
"acquire_timeout_seconds": acquire_timeout_seconds,
13421369
"name": name,
13431370
"profile": profile,
1371+
"start_replay": start_replay,
13441372
"start_url": start_url,
13451373
"tags": tags,
13461374
"telemetry": telemetry,

‎src/kernel/resources/browsers/browsers.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def create(
209209
proxy: BrowserProxyConfigParam | Omit = omit,
210210
proxy_id: str | Omit = omit,
211211
region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit,
212+
start_replay: bool | Omit = omit,
212213
start_url: str | Omit = omit,
213214
stealth: bool | Omit = omit,
214215
tags: TagsParam | Omit = omit,
@@ -285,6 +286,8 @@ def create(
285286
created. Region selection requires a Start-Up or Enterprise plan, defaults to
286287
us-east when omitted on create.
287288
289+
start_replay: Start replay recording as part of creating this browser session.
290+
288291
start_url: Optional URL to open when the browser session is created. Navigation is
289292
best-effort, so navigation failures do not prevent the session from being
290293
created.
@@ -360,6 +363,7 @@ def create(
360363
"proxy": proxy,
361364
"proxy_id": proxy_id,
362365
"region": region,
366+
"start_replay": start_replay,
363367
"start_url": start_url,
364368
"stealth": stealth,
365369
"tags": tags,
@@ -1070,6 +1074,7 @@ async def create(
10701074
proxy: BrowserProxyConfigParam | Omit = omit,
10711075
proxy_id: str | Omit = omit,
10721076
region: Literal["us-east", "us-west", "eu-west", "ap-southeast"] | Omit = omit,
1077+
start_replay: bool | Omit = omit,
10731078
start_url: str | Omit = omit,
10741079
stealth: bool | Omit = omit,
10751080
tags: TagsParam | Omit = omit,
@@ -1146,6 +1151,8 @@ async def create(
11461151
created. Region selection requires a Start-Up or Enterprise plan, defaults to
11471152
us-east when omitted on create.
11481153
1154+
start_replay: Start replay recording as part of creating this browser session.
1155+
11491156
start_url: Optional URL to open when the browser session is created. Navigation is
11501157
best-effort, so navigation failures do not prevent the session from being
11511158
created.
@@ -1221,6 +1228,7 @@ async def create(
12211228
"proxy": proxy,
12221229
"proxy_id": proxy_id,
12231230
"region": region,
1231+
"start_replay": start_replay,
12241232
"start_url": start_url,
12251233
"stealth": stealth,
12261234
"tags": tags,

‎src/kernel/types/browser_create_params.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class BrowserCreateParams(TypedDict, total=False):
132132
Enterprise plan, defaults to us-east when omitted on create.
133133
"""
134134

135+
start_replay: bool
136+
"""Start replay recording as part of creating this browser session."""
137+
135138
start_url: str
136139
"""Optional URL to open when the browser session is created.
137140

‎src/kernel/types/browser_pool.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class BrowserPoolConfig(BaseModel):
108108
creation, this defaults to true. Requires a profile to be set on the pool.
109109
"""
110110

111+
start_replay: Optional[bool] = None
112+
"""Start replay recording automatically when a browser is acquired from this pool."""
113+
111114
start_url: Optional[str] = None
112115
"""Optional URL to navigate to when a new browser is warmed into the pool.
113116

‎src/kernel/types/browser_pool_acquire_params.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class BrowserPoolAcquireParams(TypedDict, total=False):
4242
into the browser session. Profiles must be created beforehand.
4343
"""
4444

45+
start_replay: bool
46+
"""Start replay recording immediately for the acquired browser.
47+
48+
Omit to use the pool's configured default.
49+
"""
50+
4551
start_url: str
4652
"""Optional URL to navigate the acquired browser to.
4753

‎src/kernel/types/browser_pool_create_params.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class BrowserPoolCreateParams(TypedDict, total=False):
106106
Enterprise plan, defaults to us-east when omitted on create.
107107
"""
108108

109+
start_replay: bool
110+
"""Start replay recording automatically when a browser is acquired from this pool."""
111+
109112
start_url: str
110113
"""Optional URL to navigate to when a new browser is warmed into the pool.
111114

‎src/kernel/types/browser_pool_update_params.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
135135
sum of all pool sizes cannot exceed your limit).
136136
"""
137137

138+
start_replay: bool
139+
"""
140+
If provided, replaces whether replay recording starts automatically for future
141+
acquired browsers.
142+
"""
143+
138144
start_url: str
139145
"""
140146
If provided, replaces the URL to navigate to when a new browser is warmed into

‎tests/api_resources/test_browser_pools.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
6666
proxy_id="proxy_id",
6767
refresh_on_profile_update=True,
6868
region="us-east",
69+
start_replay=True,
6970
start_url="https://example.com",
7071
stealth=True,
7172
telemetry={
@@ -232,6 +233,7 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
232233
proxy_id="proxy_id",
233234
refresh_on_profile_update=True,
234235
size=10,
236+
start_replay=True,
235237
start_url="https://example.com",
236238
stealth=True,
237239
telemetry={
@@ -416,6 +418,7 @@ def test_method_acquire_with_all_params(self, client: Kernel) -> None:
416418
"name": "name",
417419
"save_changes": True,
418420
},
421+
start_replay=True,
419422
start_url="https://example.com",
420423
tags={
421424
"team": "backend",
@@ -635,6 +638,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
635638
proxy_id="proxy_id",
636639
refresh_on_profile_update=True,
637640
region="us-east",
641+
start_replay=True,
638642
start_url="https://example.com",
639643
stealth=True,
640644
telemetry={
@@ -801,6 +805,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
801805
proxy_id="proxy_id",
802806
refresh_on_profile_update=True,
803807
size=10,
808+
start_replay=True,
804809
start_url="https://example.com",
805810
stealth=True,
806811
telemetry={
@@ -985,6 +990,7 @@ async def test_method_acquire_with_all_params(self, async_client: AsyncKernel) -
985990
"name": "name",
986991
"save_changes": True,
987992
},
993+
start_replay=True,
988994
start_url="https://example.com",
989995
tags={
990996
"team": "backend",

‎tests/api_resources/test_browsers.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
7979
},
8080
proxy_id="proxy_id",
8181
region="us-east",
82+
start_replay=True,
8283
start_url="https://example.com",
8384
stealth=True,
8485
tags={
@@ -691,6 +692,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
691692
},
692693
proxy_id="proxy_id",
693694
region="us-east",
695+
start_replay=True,
694696
start_url="https://example.com",
695697
stealth=True,
696698
tags={

0 commit comments

Comments
 (0)