Skip to content

Commit 57af2e1

Browse files
refactor(browser): remove persistence option UI
1 parent 7dbb070 commit 57af2e1

File tree

11 files changed

+96
-76
lines changed

11 files changed

+96
-76
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 74
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-003e9afa15f0765009d2c7d34e8eb62268d818e628e3c84361b21138e30cc423.yml
3-
openapi_spec_hash: c1b8309f60385bf2b02d245363ca47c1
4-
config_hash: a4124701ae0a474e580d7416adbcfb00
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-cbef7e4fef29ad40af5c767aceb762ee68811c2287f255c05d2ee44a9a9247a2.yml
3+
openapi_spec_hash: 467e61e072773ec9f2d49c7dd3de8c2f
4+
config_hash: 6dbe88d2ba9df1ec46cedbfdb7d00000

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ client = Kernel(
3535
)
3636

3737
browser = client.browsers.create(
38-
persistence={"id": "browser-for-user-1234"},
38+
stealth=True,
3939
)
4040
print(browser.session_id)
4141
```
@@ -63,7 +63,7 @@ client = AsyncKernel(
6363

6464
async def main() -> None:
6565
browser = await client.browsers.create(
66-
persistence={"id": "browser-for-user-1234"},
66+
stealth=True,
6767
)
6868
print(browser.session_id)
6969

@@ -99,7 +99,7 @@ async def main() -> None:
9999
http_client=DefaultAioHttpClient(),
100100
) as client:
101101
browser = await client.browsers.create(
102-
persistence={"id": "browser-for-user-1234"},
102+
stealth=True,
103103
)
104104
print(browser.session_id)
105105

@@ -242,7 +242,7 @@ client = Kernel()
242242

243243
try:
244244
client.browsers.create(
245-
persistence={"id": "browser-for-user-1234"},
245+
stealth=True,
246246
)
247247
except kernel.APIConnectionError as e:
248248
print("The server could not be reached")
@@ -287,7 +287,7 @@ client = Kernel(
287287

288288
# Or, configure per-request:
289289
client.with_options(max_retries=5).browsers.create(
290-
persistence={"id": "browser-for-user-1234"},
290+
stealth=True,
291291
)
292292
```
293293

@@ -312,7 +312,7 @@ client = Kernel(
312312

313313
# Override per-request:
314314
client.with_options(timeout=5.0).browsers.create(
315-
persistence={"id": "browser-for-user-1234"},
315+
stealth=True,
316316
)
317317
```
318318

@@ -355,9 +355,7 @@ from kernel import Kernel
355355

356356
client = Kernel()
357357
response = client.browsers.with_raw_response.create(
358-
persistence={
359-
"id": "browser-for-user-1234"
360-
},
358+
stealth=True,
361359
)
362360
print(response.headers.get('X-My-Header'))
363361

@@ -377,7 +375,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
377375

378376
```python
379377
with client.browsers.with_streaming_response.create(
380-
persistence={"id": "browser-for-user-1234"},
378+
stealth=True,
381379
) as response:
382380
print(response.headers.get("X-My-Header"))
383381

src/kernel/resources/browsers/browsers.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import typing_extensions
56
from typing import Mapping, Iterable, cast
67

78
import httpx
@@ -161,7 +162,7 @@ def create(
161162
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
162163
view.
163164
164-
persistence: Optional persistence configuration for the browser session.
165+
persistence: DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead.
165166
166167
profile: Profile selection for the browser session. Provide either id or name. If
167168
specified, the matching profile will be loaded into the browser session.
@@ -174,11 +175,10 @@ def create(
174175
mechanisms.
175176
176177
timeout_seconds: The number of seconds of inactivity before the browser session is terminated.
177-
Only applicable to non-persistent browsers. Activity includes CDP connections
178-
and live view connections. Defaults to 60 seconds. Minimum allowed is 10
179-
seconds. Maximum allowed is 259200 (72 hours). We check for inactivity every 5
180-
seconds, so the actual timeout behavior you will see is +/- 5 seconds around the
181-
specified value.
178+
Activity includes CDP connections and live view connections. Defaults to 60
179+
seconds. Minimum allowed is 10 seconds. Maximum allowed is 259200 (72 hours). We
180+
check for inactivity every 5 seconds, so the actual timeout behavior you will
181+
see is +/- 5 seconds around the specified value.
182182
183183
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
184184
image defaults apply (commonly 1024x768@60). Only specific viewport
@@ -307,6 +307,7 @@ def list(
307307
model=BrowserListResponse,
308308
)
309309

310+
@typing_extensions.deprecated("deprecated")
310311
def delete(
311312
self,
312313
*,
@@ -318,8 +319,10 @@ def delete(
318319
extra_body: Body | None = None,
319320
timeout: float | httpx.Timeout | None | NotGiven = not_given,
320321
) -> None:
321-
"""
322-
Delete a persistent browser session by its persistent_id.
322+
"""DEPRECATED: Use DELETE /browsers/{id} instead.
323+
324+
Delete a persistent browser
325+
session by its persistent_id.
323326
324327
Args:
325328
persistent_id: Persistent browser identifier
@@ -504,7 +507,7 @@ async def create(
504507
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
505508
view.
506509
507-
persistence: Optional persistence configuration for the browser session.
510+
persistence: DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead.
508511
509512
profile: Profile selection for the browser session. Provide either id or name. If
510513
specified, the matching profile will be loaded into the browser session.
@@ -517,11 +520,10 @@ async def create(
517520
mechanisms.
518521
519522
timeout_seconds: The number of seconds of inactivity before the browser session is terminated.
520-
Only applicable to non-persistent browsers. Activity includes CDP connections
521-
and live view connections. Defaults to 60 seconds. Minimum allowed is 10
522-
seconds. Maximum allowed is 259200 (72 hours). We check for inactivity every 5
523-
seconds, so the actual timeout behavior you will see is +/- 5 seconds around the
524-
specified value.
523+
Activity includes CDP connections and live view connections. Defaults to 60
524+
seconds. Minimum allowed is 10 seconds. Maximum allowed is 259200 (72 hours). We
525+
check for inactivity every 5 seconds, so the actual timeout behavior you will
526+
see is +/- 5 seconds around the specified value.
525527
526528
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
527529
image defaults apply (commonly 1024x768@60). Only specific viewport
@@ -650,6 +652,7 @@ def list(
650652
model=BrowserListResponse,
651653
)
652654

655+
@typing_extensions.deprecated("deprecated")
653656
async def delete(
654657
self,
655658
*,
@@ -661,8 +664,10 @@ async def delete(
661664
extra_body: Body | None = None,
662665
timeout: float | httpx.Timeout | None | NotGiven = not_given,
663666
) -> None:
664-
"""
665-
Delete a persistent browser session by its persistent_id.
667+
"""DEPRECATED: Use DELETE /browsers/{id} instead.
668+
669+
Delete a persistent browser
670+
session by its persistent_id.
666671
667672
Args:
668673
persistent_id: Persistent browser identifier
@@ -784,8 +789,10 @@ def __init__(self, browsers: BrowsersResource) -> None:
784789
self.list = to_raw_response_wrapper(
785790
browsers.list,
786791
)
787-
self.delete = to_raw_response_wrapper(
788-
browsers.delete,
792+
self.delete = ( # pyright: ignore[reportDeprecated]
793+
to_raw_response_wrapper(
794+
browsers.delete, # pyright: ignore[reportDeprecated],
795+
)
789796
)
790797
self.delete_by_id = to_raw_response_wrapper(
791798
browsers.delete_by_id,
@@ -832,8 +839,10 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None:
832839
self.list = async_to_raw_response_wrapper(
833840
browsers.list,
834841
)
835-
self.delete = async_to_raw_response_wrapper(
836-
browsers.delete,
842+
self.delete = ( # pyright: ignore[reportDeprecated]
843+
async_to_raw_response_wrapper(
844+
browsers.delete, # pyright: ignore[reportDeprecated],
845+
)
837846
)
838847
self.delete_by_id = async_to_raw_response_wrapper(
839848
browsers.delete_by_id,
@@ -880,8 +889,10 @@ def __init__(self, browsers: BrowsersResource) -> None:
880889
self.list = to_streamed_response_wrapper(
881890
browsers.list,
882891
)
883-
self.delete = to_streamed_response_wrapper(
884-
browsers.delete,
892+
self.delete = ( # pyright: ignore[reportDeprecated]
893+
to_streamed_response_wrapper(
894+
browsers.delete, # pyright: ignore[reportDeprecated],
895+
)
885896
)
886897
self.delete_by_id = to_streamed_response_wrapper(
887898
browsers.delete_by_id,
@@ -928,8 +939,10 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None:
928939
self.list = async_to_streamed_response_wrapper(
929940
browsers.list,
930941
)
931-
self.delete = async_to_streamed_response_wrapper(
932-
browsers.delete,
942+
self.delete = ( # pyright: ignore[reportDeprecated]
943+
async_to_streamed_response_wrapper(
944+
browsers.delete, # pyright: ignore[reportDeprecated],
945+
)
933946
)
934947
self.delete_by_id = async_to_streamed_response_wrapper(
935948
browsers.delete_by_id,

src/kernel/types/browser_create_params.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BrowserCreateParams(TypedDict, total=False):
3636
"""
3737

3838
persistence: BrowserPersistenceParam
39-
"""Optional persistence configuration for the browser session."""
39+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
4040

4141
profile: BrowserProfile
4242
"""Profile selection for the browser session.
@@ -60,11 +60,10 @@ class BrowserCreateParams(TypedDict, total=False):
6060
timeout_seconds: int
6161
"""The number of seconds of inactivity before the browser session is terminated.
6262
63-
Only applicable to non-persistent browsers. Activity includes CDP connections
64-
and live view connections. Defaults to 60 seconds. Minimum allowed is 10
65-
seconds. Maximum allowed is 259200 (72 hours). We check for inactivity every 5
66-
seconds, so the actual timeout behavior you will see is +/- 5 seconds around the
67-
specified value.
63+
Activity includes CDP connections and live view connections. Defaults to 60
64+
seconds. Minimum allowed is 10 seconds. Maximum allowed is 259200 (72 hours). We
65+
check for inactivity every 5 seconds, so the actual timeout behavior you will
66+
see is +/- 5 seconds around the specified value.
6867
"""
6968

7069
viewport: BrowserViewport

src/kernel/types/browser_create_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BrowserCreateResponse(BaseModel):
4343
"""Whether the browser session is running in kiosk mode."""
4444

4545
persistence: Optional[BrowserPersistence] = None
46-
"""Optional persistence configuration for the browser session."""
46+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
4747

4848
profile: Optional[Profile] = None
4949
"""Browser profile metadata."""

src/kernel/types/browser_list_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BrowserListResponse(BaseModel):
4343
"""Whether the browser session is running in kiosk mode."""
4444

4545
persistence: Optional[BrowserPersistence] = None
46-
"""Optional persistence configuration for the browser session."""
46+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
4747

4848
profile: Optional[Profile] = None
4949
"""Browser profile metadata."""

src/kernel/types/browser_persistence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
class BrowserPersistence(BaseModel):
99
id: str
10-
"""Unique identifier for the persistent browser session."""
10+
"""DEPRECATED: Unique identifier for the persistent browser session."""

src/kernel/types/browser_persistence_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
class BrowserPersistenceParam(TypedDict, total=False):
1111
id: Required[str]
12-
"""Unique identifier for the persistent browser session."""
12+
"""DEPRECATED: Unique identifier for the persistent browser session."""

src/kernel/types/browser_pool_acquire_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BrowserPoolAcquireResponse(BaseModel):
4343
"""Whether the browser session is running in kiosk mode."""
4444

4545
persistence: Optional[BrowserPersistence] = None
46-
"""Optional persistence configuration for the browser session."""
46+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
4747

4848
profile: Optional[Profile] = None
4949
"""Browser profile metadata."""

src/kernel/types/browser_retrieve_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BrowserRetrieveResponse(BaseModel):
4343
"""Whether the browser session is running in kiosk mode."""
4444

4545
persistence: Optional[BrowserPersistence] = None
46-
"""Optional persistence configuration for the browser session."""
46+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
4747

4848
profile: Optional[Profile] = None
4949
"""Browser profile metadata."""

0 commit comments

Comments
 (0)