Skip to content

Commit 382e043

Browse files
committed
refactor(browser): update browser creation params
1 parent 8d6b8ce commit 382e043

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

templates/python/advanced-sample/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ async def test_captcha_solver(ctx: kernel.KernelContext) -> None:
2525
kernel_browser = client.browsers.create(
2626
invocation_id=ctx.invocation_id,
2727
stealth=True,
28-
persistence={"id": "captcha-solver"}
2928
)
3029

3130
async with async_playwright() as playwright:

templates/python/sample-app/main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,30 @@ async def get_page_title(ctx: kernel.KernelContext, input_data: PageTitleInput)
6666

6767

6868
"""
69-
Example app that instantiates a persisted Kernel browser that can be reused across invocations
69+
Example app that creates a long-running Kernel browser for manual testing
7070
Invoke this action to test Kernel browsers manually with our browser live view
71-
https://onkernel.com/docs/browsers/persistence
71+
https://onkernel.com/docs/browsers/live-view
7272
Args:
7373
ctx: Kernel context containing invocation information
7474
Returns:
7575
A dictionary containing the browser live view url
7676
Invoke this via CLI:
7777
kernel login # or: export KERNEL_API_KEY=<your_api_key>
7878
kernel deploy main.py # If you haven't already deployed this app
79-
kernel invoke python-basic create-persisted-browser
79+
kernel invoke python-basic create-browser-for-testing
8080
kernel logs python-basic -f # Open in separate tab
8181
"""
82-
class CreatePersistedBrowserOutput(TypedDict):
82+
class CreateBrowserForTestingOutput(TypedDict):
8383
browser_live_view_url: str
8484

85-
@app.action("create-persisted-browser")
86-
async def create_persisted_browser(ctx: kernel.KernelContext) -> CreatePersistedBrowserOutput:
85+
@app.action("create-browser-for-testing")
86+
async def create_browser_for_testing(ctx: kernel.KernelContext) -> CreateBrowserForTestingOutput:
8787
kernel_browser = client.browsers.create(
8888
invocation_id=ctx.invocation_id,
89-
persistence={"id": "persisted-browser"},
90-
stealth=True, # Turns on residential proxy & auto-CAPTCHA solver
89+
stealth=True,
90+
timeout_seconds=3600, # Keep browser alive for 1 hour
9191
)
9292

9393
return {
9494
"browser_live_view_url": kernel_browser.browser_live_view_url,
95-
}
95+
}

templates/typescript/advanced-sample/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ app.action("test-captcha-solver", async (ctx: KernelContext): Promise<void> => {
2424
const kernelBrowser = await kernel.browsers.create({
2525
invocation_id: ctx.invocation_id,
2626
stealth: true,
27-
persistence: {
28-
id: "captcha-solver",
29-
},
3027
});
3128
const browser = await chromium.connectOverCDP(kernelBrowser.cdp_ws_url);
3229

templates/typescript/sample-app/index.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,29 @@ app.action<PageTitleInput, PageTitleOutput>(
7676
);
7777

7878
/**
79-
* Example app that instantiates a persisted Kernel browser that can be reused across invocations
79+
* Example app that creates a long-running Kernel browser for manual testing
8080
* Invoke this action to test Kernel browsers manually with our browser live view
81-
* https://onkernel.com/docs/browsers/persistence
81+
* https://onkernel.com/docs/browsers/live-view
8282
* Args:
8383
* ctx: Kernel context containing invocation information
8484
* Returns:
8585
* A dictionary containing the browser live view url
8686
* Invoke this via CLI:
8787
* kernel login # or: export KERNEL_API_KEY=<your_api_key>
8888
* kernel deploy index.ts # If you haven't already deployed this app
89-
* kernel invoke ts-basic create-persisted-browser
89+
* kernel invoke ts-basic create-browser-for-testing
9090
* kernel logs ts-basic -f # Open in separate tab
9191
*/
92-
interface CreatePersistedBrowserOutput {
93-
browser_live_view_url: string;
92+
interface CreateBrowserForTestingOutput {
93+
browser_live_view_url?: string;
9494
}
9595
app.action(
96-
"create-persisted-browser",
97-
async (ctx: KernelContext): Promise<CreatePersistedBrowserOutput> => {
96+
"create-browser-for-testing",
97+
async (ctx: KernelContext): Promise<CreateBrowserForTestingOutput> => {
9898
const kernelBrowser = await kernel.browsers.create({
9999
invocation_id: ctx.invocation_id,
100-
persistence: {
101-
id: "persisted-browser",
102-
},
103-
stealth: true, // Turns on residential proxy & auto-CAPTCHA solver
100+
stealth: true,
101+
timeout_seconds: 3600, // Keep browser alive for 1 hour
104102
});
105103

106104
return {

0 commit comments

Comments
 (0)