Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.5",
"version": "1.0.6",
"description": "Hyperbrowsers Web Agent",
"author": "",
"main": "dist/index.js",
Expand Down Expand Up @@ -38,7 +38,7 @@
],
"dependencies": {
"@anthropic-ai/sdk": "^0.69.0",
"@google/genai": "^1.28.0",
"@google/genai": "^1.30.0",
"@hyperbrowser/sdk": "0.78.0",
"@inquirer/prompts": "^7.4.1",
"@modelcontextprotocol/sdk": "^1.9.0",
Expand Down
37 changes: 37 additions & 0 deletions src/cdp/frame-context-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,38 @@ export class FrameContextManager {
}

removeFrame(frameId: string): void {
// 1. Clean execution contexts
const contextId = this.frameExecutionContexts.get(frameId);
if (contextId !== undefined) {
this.executionContextToFrame.delete(contextId);
this.frameExecutionContexts.delete(frameId);
}

const waiters = this.executionContextWaiters.get(frameId);
if (waiters) {
for (const waiter of waiters) {
if (waiter.timeoutId) clearTimeout(waiter.timeoutId);
waiter.resolve(undefined);
}
this.executionContextWaiters.delete(frameId);
}

// 2. Clean session listeners
const session = this.sessions.get(frameId);
if (session) {
const listeners = this.sessionListeners.get(session);
if (listeners) {
for (const { event, handler } of listeners) {
session.off?.(event, handler);
}
this.sessionListeners.delete(session);
}
}
Comment thread
cursor[bot] marked this conversation as resolved.

// 3. Clean OOPIF set
this.oopifFrameIds.delete(frameId);

// 4. Remove from graph and sessions
this.graph.removeFrame(frameId);
this.sessions.delete(frameId);
}
Expand Down Expand Up @@ -388,7 +420,11 @@ export class FrameContextManager {
this.log(
`[FrameContext] Frame ${frame.url()} is detached, removing cached record`
);
const frameId = cachedRecord.frameId;
this.removeCachedPlaywrightFrame(frame);
if (frameId) {
this.removeFrame(frameId);
}
return null;
}
cachedRecord.url = frame.url();
Expand Down Expand Up @@ -439,6 +475,7 @@ export class FrameContextManager {
};
const detachHandler = (): void => {
this.removeCachedPlaywrightFrame(frame);
this.removeFrame(frameId);
oopifSession?.off?.("Detached", detachHandler);
};
record.detachHandler = detachHandler;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@
"@eslint/core" "^0.16.0"
levn "^0.4.1"

"@google/genai@^1.28.0":
version "1.28.0"
resolved "https://registry.yarnpkg.com/@google/genai/-/genai-1.28.0.tgz#0d0563ccf9cac3021a3deffc08549ef4a8d975f8"
integrity sha512-0pfZ1EWQsM9kINsL+mFKJvpzM6NRHS9t360S1MzKq4JtIwTj/RbsPpC/K5wpKiPy9PC+J+bsz/9gvaL51++KrA==
"@google/genai@^1.30.0":
version "1.30.0"
resolved "https://registry.yarnpkg.com/@google/genai/-/genai-1.30.0.tgz#11fc12ab64e7e7c559b41835a5c237b3dfcd1348"
integrity sha512-3MRcgczBFbUat1wIlZoLJ0vCCfXgm7Qxjh59cZi2X08RgWLtm9hKOspzp7TOg1TV2e26/MLxR2GR5yD5GmBV2w==
dependencies:
google-auth-library "^10.3.0"
ws "^8.18.0"
Expand Down