@browserbasehq/eve 0.1.0 → 0.2.0-alpha-82ef425ee115dbd63bbff930f9f171fe892d231a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -96
  3. package/dist/extension/_manifest.json +11 -7
  4. package/dist/extension/extension.d.ts +3 -3
  5. package/dist/extension/extension.mjs +4 -3
  6. package/dist/extension/instructions/browser.md +15 -9
  7. package/dist/extension/lib/core/facade/contract.d.ts +1095 -0
  8. package/dist/extension/lib/core/facade/contract.mjs +215 -0
  9. package/dist/extension/lib/core/facade/runtime.d.ts +113 -0
  10. package/dist/extension/lib/core/facade/runtime.mjs +2437 -0
  11. package/dist/extension/lib/core/facade/tools.d.ts +114 -0
  12. package/dist/extension/lib/core/facade/tools.mjs +401 -0
  13. package/dist/extension/lib/core/harness/redact.d.ts +1 -0
  14. package/dist/extension/lib/core/harness/redact.mjs +15 -0
  15. package/dist/extension/lib/session-release.d.ts +10 -0
  16. package/dist/extension/lib/session-release.mjs +34 -0
  17. package/dist/extension/lib/session.d.ts +54 -0
  18. package/dist/extension/lib/session.mjs +219 -0
  19. package/dist/extension/tools/run.d.ts +4 -0
  20. package/dist/extension/tools/run.mjs +28 -0
  21. package/dist/extension/tools/screenshot.d.ts +4 -0
  22. package/dist/extension/tools/screenshot.mjs +34 -0
  23. package/dist/extension/tools/snapshot.d.ts +4 -0
  24. package/dist/extension/tools/snapshot.mjs +18 -0
  25. package/dist/index.mjs +2 -1
  26. package/dist/tools/index.d.ts +3 -8
  27. package/dist/tools/index.mjs +6 -10
  28. package/package.json +45 -26
  29. package/dist/extension/lib/browserbase.d.ts +0 -2
  30. package/dist/extension/lib/browserbase.mjs +0 -11
  31. package/dist/extension/lib/disconnect.d.ts +0 -5
  32. package/dist/extension/lib/disconnect.mjs +0 -9
  33. package/dist/extension/lib/release-session.d.ts +0 -14
  34. package/dist/extension/lib/release-session.mjs +0 -38
  35. package/dist/extension/lib/session-lock.d.ts +0 -1
  36. package/dist/extension/lib/session-lock.mjs +0 -22
  37. package/dist/extension/lib/session-state.d.ts +0 -5
  38. package/dist/extension/lib/session-state.mjs +0 -11
  39. package/dist/extension/lib/stagehand.d.ts +0 -10
  40. package/dist/extension/lib/stagehand.mjs +0 -118
  41. package/dist/extension/tools/act.d.ts +0 -4
  42. package/dist/extension/tools/act.mjs +0 -16
  43. package/dist/extension/tools/agent.d.ts +0 -5
  44. package/dist/extension/tools/agent.mjs +0 -24
  45. package/dist/extension/tools/extract.d.ts +0 -5
  46. package/dist/extension/tools/extract.mjs +0 -21
  47. package/dist/extension/tools/fetch.d.ts +0 -9
  48. package/dist/extension/tools/fetch.mjs +0 -37
  49. package/dist/extension/tools/navigate.d.ts +0 -7
  50. package/dist/extension/tools/navigate.mjs +0 -23
  51. package/dist/extension/tools/observe.d.ts +0 -4
  52. package/dist/extension/tools/observe.mjs +0 -16
  53. package/dist/extension/tools/search.d.ts +0 -5
  54. package/dist/extension/tools/search.mjs +0 -22
  55. package/dist/extension/tools/session.d.ts +0 -9
  56. package/dist/extension/tools/session.mjs +0 -29
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Browserbase Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,117 +1,63 @@
1
- # Browserbase for Eve
1
+ # Eve + Stagehand facade (native tools)
2
2
 
3
- An [Eve extension](https://eve.dev/docs/extensions) that gives an agent
4
- Browserbase Search and Fetch plus a persistent Browserbase browser powered by
5
- [Stagehand](https://docs.stagehand.dev/). It exposes Stagehand's focused
6
- primitives (`act`, `observe`, and `extract`) plus navigation and autonomous agent
7
- tools.
3
+ This example gives an Eve agent the native tools `run`, `snapshot`, and `screenshot`. The tools
4
+ share a durable Stagehand session directly; no MCP connection or bridge process is required.
8
5
 
9
- ## Install
6
+ ## Setup
10
7
 
11
- ```bash
12
- pnpm add @browserbasehq/eve
13
- ```
14
-
15
- Add your credentials to the consuming Eve app:
8
+ Use Node.js 24 or later. From the repository root, build the integrations package before running
9
+ the example:
16
10
 
17
11
  ```bash
18
- BROWSERBASE_API_KEY=bb_live_...
12
+ pnpm exec turbo run build --filter @browserbasehq/stagehand-integrations
19
13
  ```
20
14
 
21
- ## Mount the extension
15
+ Configure the environment as needed:
22
16
 
23
- The filename under `agent/extensions/` becomes the tool namespace. Mounting the
24
- extension as `browserbase.ts` creates tools such as `browserbase__search`,
25
- `browserbase__fetch`, `browserbase__create_session`, and
26
- `browserbase__navigate`.
17
+ | Variable | Purpose |
18
+ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | `STAGEHAND_BROWSER` | Browser backend. Defaults to `browserbase` when `BROWSERBASE_API_KEY` is set, otherwise `local`. |
20
+ | `BROWSERBASE_API_KEY` | Browserbase API key; required when using the Browserbase backend. |
21
+ | `STAGEHAND_MODEL_NAME` | Optional Stagehand model name, such as `openai/gpt-5.6-luna`. |
22
+ | `STAGEHAND_MODEL_API_KEY` | Optional explicit API key for `STAGEHAND_MODEL_NAME`; otherwise the matching provider key is inferred when supported. |
23
+ | `STAGEHAND_EVE_SESSION_FILE` | Optional path used to persist the Browserbase session ID; defaults to a file in the system temporary directory. |
24
+ | `EVE_STAGEHAND_MODEL` | Eve agent model; defaults to `gpt-5.6-luna`. |
25
+ | `OPENAI_API_KEY` | OpenAI credential used by the Eve agent model and inferred for an OpenAI Stagehand model. |
26
+ | `GOOGLE_GENERATIVE_AI_API_KEY` / `GEMINI_API_KEY` / `GOOGLE_API_KEY` | Google credential inferred by Stagehand. If one is set without explicit Stagehand model configuration, the model defaults to `google/gemini-3.8-flash`. |
27
27
 
28
- ```ts
29
- // agent/extensions/browserbase.ts
30
- import browserbase from '@browserbasehq/eve';
31
-
32
- export default browserbase({
33
- apiKey: process.env.BROWSERBASE_API_KEY!,
34
- model: 'openai/gpt-5.4-mini',
35
- });
36
- ```
28
+ ## Run
37
29
 
38
- Start Eve and give the agent a browser task:
30
+ The tool contract tests need no network, browser, or API keys:
39
31
 
40
32
  ```bash
41
- pnpm exec eve dev
33
+ pnpm --filter @browserbasehq/stagehand-integrations-example-eve-facade test
34
+ pnpm --filter @browserbasehq/stagehand-integrations-example-eve-facade typecheck
42
35
  ```
43
36
 
44
- ```text
45
- Open https://news.ycombinator.com and extract the titles and URLs of the first
46
- five stories.
47
- ```
48
-
49
- The extension keeps the Browserbase session ID in Eve's durable per-session
50
- state. Each browser tool reconnects to that browser, performs one operation,
51
- and disconnects without terminating it. `browserbase__create_session` creates
52
- or reconnects the browser explicitly, and `browserbase__stop_session`
53
- terminates it.
54
-
55
- ## Tools
56
-
57
- | Tool | Purpose |
58
- | ---------------- | ------------------------------------------------------- |
59
- | `search` | Find relevant public web pages with Browserbase Search. |
60
- | `fetch` | Retrieve raw, markdown, or structured page content. |
61
- | `create_session` | Create or reconnect the Browserbase session. |
62
- | `stop_session` | Stop the Browserbase session and release resources. |
63
- | `navigate` | Open a URL in the current browser. |
64
- | `observe` | Find relevant elements and candidate actions. |
65
- | `act` | Perform one natural-language page interaction. |
66
- | `extract` | Return data validated against a supplied JSON Schema. |
67
- | `agent` | Run a multi-step autonomous Stagehand task. |
68
-
69
- Use Search → Fetch → browser as an escalation path: discover sources cheaply,
70
- retrieve straightforward content without a session, and create a browser only
71
- when the page requires JavaScript or interaction. Fetch supports Browserbase's
72
- `raw`, `markdown`, and schema-driven `json` formats.
73
-
74
- For predictable and efficient runs, use `create_session` → `navigate` →
75
- `observe` → `act` or `extract`, then `stop_session`. Reserve `agent` for
76
- workflows that need Stagehand to plan several steps on its own.
77
-
78
- ## Configuration
79
-
80
- | Option | Default | Description |
81
- | ----------------------- | --------------------- | --------------------------------------------------- |
82
- | `apiKey` | required | Browserbase API key for browsers and Model Gateway. |
83
- | `model` | `openai/gpt-5.4-mini` | Stagehand Model Gateway model identifier. |
84
- | `sessionTimeoutSeconds` | `900` | Session timeout, from 60 to 21,600 seconds. |
85
- | `proxies` | `false` | Enable Browserbase proxies for new sessions. |
86
-
87
- Stagehand runs through Browserbase Model Gateway, so consumers do not need an
88
- OpenAI or other model-provider API key. The Browserbase API key covers both the
89
- browser session and Stagehand inference.
90
-
91
- The extension uses Browserbase `keepAlive` sessions so it can reconnect across
92
- Eve workflow steps and Vercel function invocations. Parallel browser calls made
93
- inside one Eve workflow step are queued in that step's managed runtime; durable
94
- state reconnects later steps and invocations. Close the session after the task
95
- to avoid leaving billable browser time running. Keep-alive availability depends
96
- on your Browserbase plan.
97
-
98
- ## Build
37
+ For interactive use, set the browser and model credentials, then run:
99
38
 
100
39
  ```bash
101
- nvm use
102
- pnpm install
103
- pnpm check
40
+ pnpm --filter @browserbasehq/stagehand-integrations-example-eve-facade dev
104
41
  ```
105
42
 
106
- Eve requires Node.js 24 or newer. This directory's `.nvmrc` pins Node 24.16.0;
107
- run `nvm install 24.16.0` first if needed.
43
+ ## Security model
44
+
45
+ `run(code)` executes model-authored JavaScript in the extension service worker: it runs
46
+ browser-side, never in the host process. Browserbase is the recommended isolation boundary. The
47
+ Eve world process holds only the browser session handle; model-authored JavaScript does not execute
48
+ inside the world process.
49
+
50
+ ## Session lifecycle
108
51
 
109
- `eve extension build` writes the publishable extension and type declarations to
110
- `dist/`.
52
+ The example holds one shared browser session per Eve world process. Concurrent Eve sessions served
53
+ by the same process share pages, authentication, and other browser state, so this example is
54
+ intended for single-session use.
111
55
 
112
- ## Example agent
56
+ On Browserbase, the example creates a `keepAlive: true` session and persists its ID to a temporary
57
+ file. Set `STAGEHAND_EVE_SESSION_FILE` to override that path. Process restarts reattach to this
58
+ session instead of creating and stranding another one. While awaiting reuse, the session keeps
59
+ running and billing until it is reattached, released through the Browserbase dashboard or API, or
60
+ reaches the project timeout.
113
61
 
114
- The [`eve-example`](../../examples/integrations/vercel/eve-example/) directory
115
- contains a runnable Eve agent that mounts this package locally. It includes the
116
- agent instructions, environment template, and a Browserbase research prompt for
117
- a complete smoke test.
62
+ Errors from model-authored tool code do not reset the session. The browser session is recreated only
63
+ when its connection is unhealthy.
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "kind": "eve-extension",
3
- "formatVersion": 1,
4
- "builtWithEve": "0.25.3",
3
+ "formatVersion": 2,
4
+ "builtWithEve": "0.68.0",
5
+ "build": {
6
+ "externalDependencies": [
7
+ "@browserbasehq/sdk",
8
+ "@browserbasehq/stagehand"
9
+ ]
10
+ },
5
11
  "requires": {
6
12
  "extension": 1,
7
- "tool": 1,
8
- "dynamicTool": 1,
9
- "instructions": 1,
10
- "config": 1,
11
- "state": 1
13
+ "tool": 59,
14
+ "instructions": 2,
15
+ "config": 1
12
16
  }
13
17
  }
@@ -1,8 +1,8 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
3
- apiKey: z.ZodString;
3
+ apiKey: z.ZodOptional<z.ZodString>;
4
4
  model: z.ZodDefault<z.ZodString>;
5
5
  sessionTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
6
- proxies: z.ZodDefault<z.ZodBoolean>;
6
+ proxies: z.ZodOptional<z.ZodBoolean>;
7
7
  }, z.core.$strip>>;
8
8
  export default _default;
@@ -1,14 +1,15 @@
1
1
  import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
2
  import { dirname as __eveDirname } from "node:path";
3
3
  import { createRequire as __eveCreateRequire } from "node:module";
4
- __eveDirname(__eveFileURLToPath(import.meta.url));
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
5
6
  __eveCreateRequire(import.meta.url);
6
7
  import { defineExtension } from "eve/extension";
7
8
  import { z } from "zod";
8
9
  var extension_default = defineExtension({ config: z.object({
9
- apiKey: z.string().min(1),
10
+ apiKey: z.string().min(1).optional(),
10
11
  model: z.string().min(1).default("openai/gpt-5.4-mini"),
11
12
  sessionTimeoutSeconds: z.number().int().min(60).max(21600).default(900),
12
- proxies: z.boolean().default(false)
13
+ proxies: z.boolean().optional()
13
14
  }) });
14
15
  export { extension_default as default };
@@ -1,9 +1,15 @@
1
- Use Browserbase Search to discover relevant URLs and Browserbase Fetch for quick
2
- retrievals that do not need JavaScript or interaction. Escalate to a browser
3
- session when a page needs rendering or interaction: create a session, navigate,
4
- then use observe to plan, act for one interaction, and extract for structured
5
- results. Use agent only for genuinely multi-step work. Browser tools share one
6
- Browserbase session per Eve session. Parallel browser calls from the same Eve
7
- workflow step are queued within that step; later steps reconnect through durable
8
- state. Prefer calling tools sequentially, and stop the browser session when the
9
- task is complete.
1
+ Browser tool surface: Stagehand Playwright facade.
2
+ You control one persistent browser through exactly three tools:
3
+
4
+ - run: execute JavaScript against an initialized Playwright page, context, and browser (page.goto, page.locator(selector).click()/fill(), page.getByRole(...), page.evaluate(...), page.waitForURL(...), and the supported Playwright-shaped API). Use await directly and return JSON-serializable values so you can inspect progress. Alternatively, pass snapshot actions.
5
+ - snapshot: inspect the active page's accessibility tree and hydrate bracketed element IDs for run actions.
6
+ - screenshot: inspect the rendered page visually.
7
+
8
+ Pass run exactly one of code or actions; every action uses "op" and "id", never "kind" or "ref". Snapshot IDs are valid only for the latest snapshot of the active page; snapshot again after navigation or stale IDs. The first browser action should usually be: await page.goto(url, { waitUntil: 'domcontentloaded' }). Do not launch another browser or create a separate browser process.
9
+
10
+ Snapshot output displays IDs in brackets (for example, `[0-22]`), but action `id` values omit the
11
+ brackets (for example, `"0-22"`).
12
+
13
+ JavaScript passed to `run` receives Playwright-shaped `page`, `context`, and `browser` objects. Call
14
+ `await browser.close()` only after collecting the final result; Eve then releases the owned
15
+ Browserbase session and creates fresh resources on the next browser tool call.