You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 55e37cc
Browse filesBrowse the repository at this point in the historyBrowse files
Rewrite the Stagehand integration guide for v4: a CLI-template quick start
and a step-by-step path for adding Kernel to an existing v4 project. v4 runs
as a Chrome extension, so the guide covers loading it onto the running Kernel
browser and connecting with localBrowser.connect (no extensionId). Also
update the file I/O download example and the CLI template reference for v4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: browsers/file-io.mdx
+80-71Lines changed: 80 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,32 +246,34 @@ if __name__ == "__main__":
246
246
247
247
</CodeGroup>
248
248
249
-
### Stagehand v3
249
+
### Stagehand
250
250
251
-
When using Stagehand with Kernel browsers, you need to configure the download behavior in the `localBrowserLaunchOptions`:
252
-
253
-
```typescript
254
-
const stagehand =newStagehand({
255
-
env: "LOCAL",
256
-
verbose: 1,
257
-
localBrowserLaunchOptions: {
258
-
cdpUrl: kernelBrowser.cdp_ws_url,
259
-
downloadsPath: DOWNLOAD_DIR, // Specify where downloads should be saved
260
-
acceptDownloads: true, // Enable downloads
261
-
},
262
-
});
263
-
```
251
+
Stagehand v4 connects to the running Kernel browser (see the [Stagehand integration guide](/integrations/stagehand) for the full setup). A user-initiated download — e.g. clicking a download link — is saved to the browser's default download directory, `/home/kernel/Downloads`, which you retrieve with Kernel's File I/O APIs. No download-specific launch configuration is required.
Copy file name to clipboardExpand all lines: integrations/stagehand.mdx
+97-43Lines changed: 97 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,85 +5,139 @@ title: "Stagehand"
5
5
[Stagehand](https://github.com/browserbase/stagehand) is an open source AI browser automation framework. It lets developers choose what to write in code vs. natural language. By integrating with Kernel, you can run Stagehand automations with cloud-hosted browsers.
6
6
7
7
<Note>
8
-
This guide is compatible with Stagehand SDK v3. If you're using an earlier version, please refer to the [Stagehand migration guide](https://docs.stagehand.dev/v3/migrations/v2) or upgrade to v3.
8
+
This guide targets Stagehand SDK v4. Stagehand v4 runs as a Chrome extension alongside the browser rather than driving it purely over CDP, so a remote Kernel browser needs the extension loaded into it (covered below). If you're on an earlier version, see the [Stagehand migration guide](https://docs.stagehand.dev).
9
9
</Note>
10
10
11
-
## Adding Kernel to existing Stagehand implementations
11
+
## Quick start with the Stagehand template
12
12
13
-
If you already have a Stagehand (v3) implementation, you can easily switch to using Kernel's cloud browsers by updating your browser configuration.
13
+
The fastest way to run Stagehand on Kernel is our app template, which comes pre-wired for v4:
See the [deploy](/apps/deploy) and [invoke](/apps/invoke) guides for more.
41
+
42
+
## Adding Kernel to an existing Stagehand v4 project
43
+
44
+
If you already have a Stagehand v4 implementation, switch it to Kernel's cloud browsers with the steps below.
14
45
15
46
### 1. Install the Kernel SDK
16
47
17
48
```bash
18
49
npm install @onkernel/sdk
19
50
```
20
51
21
-
### 2. Initialize Kernel and create a browser
52
+
Stagehand v4 requires `zod` v4 for its schema types (it pins `zod@4.4.3`). If your project is on zod v3, upgrade it.
22
53
23
-
Importthelibrariesandcreateacloudbrowsersession:
54
+
### 2. Load the Stagehand extension onto the Kernel browser
55
+
56
+
Stagehand v4 runs as a Chrome extension. When `localBrowser.connect` is called without an `extensionId`, Stagehand loads the extension into the running browser over CDP (`Extensions.loadUnpacked`), reading it from a path on the **browser's** filesystem. Mirror the extension — shipped inside the `@browserbasehq/stagehand` package — onto the running Kernel browser at that exact path first:
Alternatively, you can use our Kernel app template that includes a pre-configured Stagehand integration:
127
+
Stagehand v4 only closes browsers it launched, so close the connection and delete the Kernel browser yourself. Nest the cleanup so a failed `close()` never skips deleting the browser:
0 commit comments