all repos — sz-chrome-remote-cdp @ 9e9bf2a3badb59d0ce5bdb47c4e9d09ffb259e69

pi-browser-harness, patched to drive a Chrome on another host over CDP, with castle_cdp_search web search

src/cdp/attach.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
import { map, type Result } from "../util/result";
import type { CdpError } from "./errors";
import type { CdpSession } from "./session";

/** Target.attachToTarget, unwrapped to the new session id. */
export const attachTo = async (
  session: CdpSession,
  targetId: string,
): Promise<Result<string, CdpError>> =>
  map(
    await session.callBrowser("Target.attachToTarget", { targetId, flatten: true }),
    (d) => d.sessionId,
  );