From c88082515dcd9c0df1328b85420e97d7286ad428 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 22:01:47 +0530 Subject: refactor: attach and windowId become session methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cdp/attach.ts and cdp/window.ts were a module each for a single `map(await session.callBrowser(...))` one-liner that took the session as its first argument — two files, two imports and two names for what the session can expose itself. They are now session.attach(targetId) and session.windowId(targetId). session.ts also repeated `targetId ? tabs.get(targetId) : undefined` eight times; that is now currentTab(). Co-Authored-By: Claude Opus 5 (1M context) --- src/domains/navigate.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/domains') diff --git a/src/domains/navigate.ts b/src/domains/navigate.ts index 17e25a6..151a742 100644 --- a/src/domains/navigate.ts +++ b/src/domains/navigate.ts @@ -4,7 +4,6 @@ import { type Result, err, ok } from "../util/result"; import { defineBrowserTool, type ToolErr, type ToolOk } from "../util/tool"; import { applyTruncation } from "../util/truncate"; import { safeJs } from "../util/js-template"; -import { attachTo } from "../cdp/attach"; import { ensureHarnessWindow, openHarnessTab } from "../cdp/target-factory"; import { cdpCall, cdpCallBrowser, cdpCallOnTarget, evalJs } from "./cdp-call"; @@ -107,7 +106,7 @@ export const openUrlsTool = defineBrowserTool({ const settled = await Promise.all( created.filter((t) => t.ok).map(async (tab): Promise => { try { - const attached = await attachTo(client.session(), tab.targetId); + const attached = await client.session().attach(tab.targetId); if (!attached.success) return { ...tab, ok: false, error: attached.error.message }; const sid = attached.data; const enabled = await cdpCallOnTarget(client, "Page.enable", {}, sid); -- cgit v1.2.3