Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperbrowser/agent",
"version": "1.0.4",
"version": "1.0.5",
"description": "Hyperbrowsers Web Agent",
"author": "",
"main": "dist/index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@anthropic-ai/sdk": "^0.69.0",
"@google/genai": "^1.28.0",
"@hyperbrowser/sdk": "^0.46.0",
"@hyperbrowser/sdk": "0.78.0",
"@inquirer/prompts": "^7.4.1",
"@modelcontextprotocol/sdk": "^1.9.0",
"@types/crypto-js": "^4.2.2",
Expand Down
13 changes: 10 additions & 3 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,16 @@ export class HyperAgent<T extends BrowserProviders = "Local"> {
public async initBrowser(): Promise<Browser> {
if (!this.browser) {
this.browser = await this.browserProvider.start();
this.context = await this.browser.newContext({
viewport: null,
});
if (
this.browserProviderType === "Hyperbrowser" &&
this.browser.contexts().length > 0
) {
this.context = this.browser.contexts()[0];
Comment thread
cursor[bot] marked this conversation as resolved.
} else {
this.context = await this.browser.newContext({
viewport: null,
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Init script not applied to existing Hyperbrowser pages

When reusing an existing Hyperbrowser context, addInitScript is called after the context may already have pages open. Since addInitScript only affects pages created after it's called, existing pages won't have the event listener tracking script that sets data-has-interactive-listener attributes. This causes the agent to fail identifying interactive elements on pre-existing pages in Hyperbrowser sessions, while working correctly for Local provider where contexts are always newly created.

Fix in Cursor Fix in Web


// Inject script to track event listeners
await this.context.addInitScript(() => {
Expand Down
24 changes: 17 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.3.tgz#c2b9d2e374ee62c586d3adbea87199b1d7a7a6ba"
integrity sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==

"@hyperbrowser/sdk@^0.46.0":
version "0.46.0"
resolved "https://registry.yarnpkg.com/@hyperbrowser/sdk/-/sdk-0.46.0.tgz#1937b2855342661f2dca6535792bd022858d1e8a"
integrity sha512-LItlKUdaKeTIwYu1DeHNAuA88ZbAGoX4yLUsmSQd2jEanHuYb2qW5ELQJPggyQpUO9KG9KIFK9yaf+XJsA+krQ==
"@hyperbrowser/sdk@0.78.0":
version "0.78.0"
resolved "https://registry.yarnpkg.com/@hyperbrowser/sdk/-/sdk-0.78.0.tgz#6c0824962932e7fc328cbad79858b55eb71aab25"
integrity sha512-w0sthsK0fI41ZLpYPeWcJllf2YVtoL1icAzm3t4mbsHDvDom1lF4uuDXCGyDUjXHnhXe8chqlrLnECUF8h2CQQ==
dependencies:
form-data "^4.0.1"
node-fetch "2.7.0"
zod "^3.24.1"
zod-to-json-schema "^3.24.1"
zod "^4.1.12"
zod-to-json-schema "^3.25.0"

"@inquirer/ansi@^1.0.1":
version "1.0.1"
Expand Down Expand Up @@ -3289,11 +3289,21 @@ zod-to-json-schema@^3.20.0, zod-to-json-schema@^3.24.1:
resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz#5920f020c4d2647edfbb954fa036082b92c9e12d"
integrity sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==

zod@^3.22.0, zod@^3.23.8, zod@^3.24.1:
zod-to-json-schema@^3.25.0:
version "3.25.0"
resolved "https://registry.yarnpkg.com/zod-to-json-schema/-/zod-to-json-schema-3.25.0.tgz#df504c957c4fb0feff467c74d03e6aab0b013e1c"
integrity sha512-HvWtU2UG41LALjajJrML6uQejQhNJx+JBO9IflpSja4R03iNWfKXrj6W2h7ljuLyc1nKS+9yDyL/9tD1U/yBnQ==

zod@^3.22.0, zod@^3.23.8:
version "3.25.76"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.76.tgz#26841c3f6fd22a6a2760e7ccb719179768471e34"
integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==

zod@^4.1.12:
version "4.1.13"
resolved "https://registry.yarnpkg.com/zod/-/zod-4.1.13.tgz#93699a8afe937ba96badbb0ce8be6033c0a4b6b1"
integrity sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==

zod@^4.1.8:
version "4.1.12"
resolved "https://registry.yarnpkg.com/zod/-/zod-4.1.12.tgz#64f1ea53d00eab91853195653b5af9eee68970f0"
Expand Down