@53able/pi-agent-browser 0.3.0 → 0.4.1

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.
package/README.ja-JP.md CHANGED
@@ -66,6 +66,7 @@ pi install ./pi-agent-browser
66
66
  - `agent_browser_state` — saved state を save / load / list / show / rename / clear / clean する
67
67
  - `agent_browser_close` — browser session を閉じる
68
68
  - `agent_browser_handoff` — 2FA・CAPTCHA・本人確認のために一時停止し、人間に操作を戻す
69
+ - `agent_browser_login_handoff` — インタラクティブなログイン(Google、OAuth など)のための無人 browser を起動する
69
70
  - `agent_browser_commit` — 決済・削除・投稿・送信など、やり直しのきかない操作の確認ゲート
70
71
  - `agent_browser_doctor` — `agent-browser doctor` を実行する
71
72
 
@@ -160,14 +161,15 @@ https://example.com をブラウザ経由で読み、outputs/browser/example.md
160
161
 
161
162
  ## 人間への handoff(引き渡し)
162
163
 
163
- すべての操作を無人で任せるべきではありません。適切なタイミングで人間に操作を戻すためのツールが2つあります。
164
+ すべての操作を無人で任せるべきではありません。適切なタイミングで人間に操作を戻すためのツールが3つあります。
164
165
 
165
166
  - **安全な境界線** — `agent_browser_handoff` は、AI自身では対応できない・すべきでない操作(2FA/OTPの入力、CAPTCHA、本人確認)の直前でエージェントを一時停止させます。スクリーンショットで状況を記録したあと、実際のUIダイアログでブロックし、人間が「対応完了」または「中止」を選ぶまで待ちます。`agent_browser_read` / `agent_browser_snapshot` も簡易なキーワード検知を行い、こうしたチェックポイントらしき内容を出力に警告として付加します(この警告自体は停止ではなく、`agent_browser_handoff` を呼ぶきっかけとして扱ってください)。
167
+ - **インタラクティブなログイン** — `agent_browser_login_handoff` は、Google や OAuth など多くのプロバイダで sign-in がブロックされる問題を解決します。これは、agent-browser が使われた時点でオートメーション検出が起きるため、ログイン中に拒否されるというもの。このツールは CDP が接続されていない無人 Chrome プロセスを起動して人間が正常にログインできるようにし、ログイン成功後にその認証済みCookie/storageを取り出して、新しい通常のagent-browserセッションに読み込ませます。Google や OAuth の sign-in フローが期待されるタスクでは、`agent_browser_open` ではなく必ずこちらを使ってください。
166
168
  - **Commit前の停止** — `agent_browser_commit` は、決済・削除・投稿・送信といった「やり直しのきかない操作」専用の確認ゲートです。証跡を保存し、クリックの前に必ず人間の明示的な確認を求め、承認されない限りクリックは実行されません。対話的なUIが利用できない場合は、クリックせずにそのまま拒否します。こうした操作の最終確認クリックには `agent_browser_click` ではなく必ずこちらを使ってください。
167
169
 
168
- どちらのツールも対話的なセッション(TUI、またはUI対応のRPC)を必要とします。無人・headless実行では、黙って進めるのではなく拒否します。
170
+ 3つのツールすべてが対話的なセッション(TUI、またはUI対応のRPC)を必要とします。無人・headless実行では、黙って進めるのではなく拒否します。
169
171
 
170
- `agent_browser_open`は、各セッションが`headed: true`で起動されたかどうかも記録します。`agent_browser_handoff`が、headedで開かれていないセッションに対して呼ばれた場合、人間への警告に加えて、可視ウィンドウを開き直すための`agent_browser_open`の引数(セッション名、`headed: true`、`restore: true`、最後に開いていたURL)をそのまま提示します — どのコマンドを打ち直せばよいか推測する必要はありません。ログインや2FA、CAPTCHA、本人確認に差し掛かる可能性があるタスクでは、最初から`headed: true`で開くことを推奨します。一部の確認チャレンジは使い切り・期限付きのため、途中で開き直すとログインからやり直しになることがあります。
172
+ `agent_browser_open`は、各セッションが`headed: true`で起動されたかどうかを記録します。`agent_browser_handoff`が、headedで開かれていないセッションに対して呼ばれた場合、人間への警告に加えて、可視ウィンドウを開き直すための`agent_browser_open`の引数(セッション名、`headed: true`、`restore: true`、最後に開いていたURL)をそのまま提示します — どのコマンドを打ち直せばよいか推測する必要はありません。ログインや2FA、CAPTCHA、本人確認に差し掛かる可能性があるタスクでは、最初から`headed: true`で開くことを推奨します。一部の確認チャレンジは使い切り・期限付きのため、途中で開き直すとログインからやり直しになることがあります。`agent_browser_login_handoff`が作るセッションは常にheadlessです(使い捨てのログイン用ブラウザではなく、新規セッションのため)。見たい場合は`headed: true`で開き直してください。
171
173
 
172
174
  ## Troubleshooting
173
175
 
package/README.md CHANGED
@@ -66,6 +66,7 @@ pi install ./pi-agent-browser
66
66
  - `agent_browser_state` — save, load, list, show, rename, clear, or clean saved state
67
67
  - `agent_browser_close` — close a browser session
68
68
  - `agent_browser_handoff` — pause and hand control to a human for 2FA, CAPTCHA, or identity verification
69
+ - `agent_browser_login_handoff` — spawn an unattended browser for interactive login flows (Google, OAuth)
69
70
  - `agent_browser_commit` — confirmation gate for irreversible actions (payment, delete, publish, send)
70
71
  - `agent_browser_doctor` — run `agent-browser doctor`
71
72
 
@@ -160,14 +161,15 @@ Clear all saved states only when intentionally resetting everything:
160
161
 
161
162
  ## Human handoff
162
163
 
163
- Not every step should run unattended. Two tools hand control back to a human at the right moments:
164
+ Not every step should run unattended. Three tools hand control back to a human at the right moments:
164
165
 
165
166
  - **Safe boundaries** — `agent_browser_handoff` pauses the agent for steps it cannot or should not perform itself: 2FA/OTP entry, CAPTCHA, identity verification. It captures a screenshot for context, then blocks on a real confirmation dialog until a human resumes or aborts. `agent_browser_read` and `agent_browser_snapshot` also run a lightweight keyword scan and flag likely checkpoints in their output as a nudge to call this tool.
167
+ - **Interactive login flows** — `agent_browser_login_handoff` solves the problem that Google, OAuth, and similar providers block sign-in when agent-browser is used, because automation detection happens during the login step itself. This tool spawns an unattended Chrome process (with no CDP attached) so the human can log in normally, then captures the authenticated cookies/storage and loads them into a fresh, ordinary agent-browser session after login succeeds. Use this instead of `agent_browser_open` whenever a task is expected to hit an interactive Google or OAuth sign-in flow.
166
168
  - **Stop before commit** — `agent_browser_commit` is a dedicated gate for irreversible actions: payment, deletion, publishing, sending. It captures evidence, requires explicit human confirmation before clicking, and refuses outright (without clicking) if no interactive UI is available to ask. Use it instead of `agent_browser_click` for the final confirming step of any such action.
167
169
 
168
- Both tools require an interactive session (TUI or RPC with UI support); in headless/unattended runs they refuse rather than proceed silently.
170
+ All three tools require an interactive session (TUI or RPC with UI support); in headless/unattended runs they refuse rather than proceed silently.
169
171
 
170
- `agent_browser_open` also remembers whether each named session was launched with `headed: true`. If `agent_browser_handoff` is called for a session that was not opened headed, it automatically warns the human and includes the exact `agent_browser_open` arguments (session name, `headed: true`, `restore: true`, and the last known URL) needed to reopen a visible window — no more guessing which command to rerun. Prefer `headed: true` up front for any task that might hit a login, 2FA, CAPTCHA, or identity-verification step, since some challenges are single-use and reopening mid-flow may require restarting the login.
172
+ `agent_browser_open` remembers whether each named session was launched with `headed: true`. If `agent_browser_handoff` is called for a session that was not opened headed, it automatically warns the human and includes the exact `agent_browser_open` arguments (session name, `headed: true`, `restore: true`, and the last known URL) needed to reopen a visible window — no more guessing which command to rerun. Prefer `headed: true` up front for any task that might hit a login, 2FA, CAPTCHA, or identity-verification step, since some challenges are single-use and reopening mid-flow may require restarting the login. `agent_browser_login_handoff` always leaves the resulting session headless (it's a fresh session, not the disposable login browser), so reopen with `headed: true` if you need to see it.
171
173
 
172
174
  ## Troubleshooting
173
175
 
package/index.ts CHANGED
@@ -4,6 +4,7 @@ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { constants, existsSync } from "node:fs";
5
5
  import { join, resolve, basename } from "node:path";
6
6
  import { spawn } from "node:child_process";
7
+ import { createServer } from "node:net";
7
8
 
8
9
  const DEFAULT_TIMEOUT_MS = 120_000;
9
10
  const DEFAULT_MAX_PREVIEW_CHARS = 12_000;
@@ -200,6 +201,15 @@ const HandoffSchema = Type.Object(commonSchema({
200
201
  screenshot: optionalBoolean("Capture a screenshot for the human before waiting. Defaults to true."),
201
202
  }));
202
203
 
204
+ const LoginHandoffSchema = Type.Object({
205
+ url: Type.String({ description: "Login/app URL to open in a real, non-automated browser for the human to sign in." }),
206
+ session: optionalString("agent-browser session name to attach as after login completes. Defaults to the default session."),
207
+ reason: Type.String({ description: "Human-readable reason for the login handoff (e.g. 'Googleアカウントへのログインが必要です')." }),
208
+ executablePath: optionalString("Override path to a real Chrome executable. Auto-detected on macOS if omitted."),
209
+ profileDir: optionalString("Override persistent user-data-dir for the login browser. Defaults to a per-session directory reused across runs so re-running the same session reuses the same authenticated profile."),
210
+ timeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Tool execution timeout in milliseconds for the post-login attach step." })),
211
+ });
212
+
203
213
  const CommitSchema = Type.Object(commonSchema({
204
214
  selector: Type.String({ description: "Element ref from snapshot, such as @e2, or a CSS selector, for the irreversible action (e.g. final pay/post/delete button)." }),
205
215
  summary: Type.String({ description: "Plain-language description of what this click will do, e.g. '¥12,000 の決済を確定する' or 'この投稿を完全に削除する'." }),
@@ -235,6 +245,61 @@ async function findAgentBrowserBin(): Promise<string> {
235
245
  return "agent-browser";
236
246
  }
237
247
 
248
+ function findRealChromeExecutable(): string | undefined {
249
+ const macPath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
250
+ if (existsSync(macPath)) return macPath;
251
+ return undefined;
252
+ }
253
+
254
+ async function findFreePort(): Promise<number> {
255
+ return await new Promise((resolvePort, reject) => {
256
+ const server = createServer();
257
+ server.once("error", reject);
258
+ server.listen(0, "127.0.0.1", () => {
259
+ const address = server.address();
260
+ const port = typeof address === "object" && address ? address.port : undefined;
261
+ server.close(() => {
262
+ if (port) resolvePort(port);
263
+ else reject(new Error("Could not determine a free port."));
264
+ });
265
+ });
266
+ });
267
+ }
268
+
269
+ function abortableDelay(ms: number, signal?: AbortSignal): Promise<void> {
270
+ return new Promise((resolveDelay) => {
271
+ if (signal?.aborted) {
272
+ resolveDelay();
273
+ return;
274
+ }
275
+ const onAbort = () => {
276
+ clearTimeout(timer);
277
+ resolveDelay();
278
+ };
279
+ const timer = setTimeout(() => {
280
+ signal?.removeEventListener("abort", onAbort);
281
+ resolveDelay();
282
+ }, ms);
283
+ signal?.addEventListener("abort", onAbort, { once: true });
284
+ });
285
+ }
286
+
287
+ async function waitForDebugPort(port: number, timeoutMs = 8000, intervalMs = 300, signal?: AbortSignal): Promise<boolean> {
288
+ const deadline = Date.now() + timeoutMs;
289
+ while (Date.now() < deadline) {
290
+ if (signal?.aborted) return false;
291
+ try {
292
+ const res = await fetch(`http://127.0.0.1:${port}/json/version`);
293
+ if (res.ok) return true;
294
+ } catch {
295
+ // Not up yet; keep polling.
296
+ }
297
+ if (signal?.aborted) return false;
298
+ await abortableDelay(intervalMs, signal);
299
+ }
300
+ return false;
301
+ }
302
+
238
303
  function pushCommonArgs(args: string[], params: JsonObject): void {
239
304
  if (typeof params.session === "string" && params.session.trim()) {
240
305
  args.push("--session", params.session.trim());
@@ -696,6 +761,195 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
696
761
  },
697
762
  });
698
763
 
764
+ pi.registerTool({
765
+ name: "agent_browser_login_handoff",
766
+ label: "Agent Browser Login Handoff",
767
+ description: "Launch a real, non-CDP-attached Chrome for an interactive login (e.g. Google sign-in) that automation frameworks get blocked from. Once the human confirms login is complete, captures the authenticated cookies/storage and loads them into a fresh, ordinary agent-browser session. Blocks until the human confirms or aborts.",
768
+ promptSnippet: "Use agent_browser_login_handoff (not agent_browser_open) whenever a task requires an interactive Google/OAuth-style login.",
769
+ promptGuidelines: [
770
+ "Never attempt an interactive Google/OAuth-style login via agent_browser_open, agent_browser_click, or agent_browser_fill — those attach CDP immediately, and Google blocks sign-in for CDP-attached sessions regardless of profile or cookies.",
771
+ "Call this tool instead whenever a task is expected to require signing into a Google account or a similarly automation-hostile login flow.",
772
+ "After this tool reports success, take a fresh agent_browser_snapshot before continuing — do not assume page state.",
773
+ "If this tool reports no interactive UI, a decline, or a failure, stop the task and report back; do not retry via agent_browser_open.",
774
+ ],
775
+ parameters: LoginHandoffSchema,
776
+ async execute(_id, rawParams, signal, onUpdate, ctx) {
777
+ const params = rawParams as JsonObject;
778
+ const url = String(params.url);
779
+ const reason = String(params.reason);
780
+ const session = sessionKey(params);
781
+
782
+ const executablePath = typeof params.executablePath === "string" && params.executablePath.trim()
783
+ ? params.executablePath.trim()
784
+ : findRealChromeExecutable();
785
+
786
+ if (!executablePath) {
787
+ return {
788
+ content: [{
789
+ type: "text",
790
+ text: [
791
+ "Could not find a real Chrome executable for the login handoff.",
792
+ "Auto-detection only checks the default macOS install path (/Applications/Google Chrome.app/Contents/MacOS/Google Chrome).",
793
+ "Pass executablePath explicitly, or install Google Chrome, and retry. Do not fall back to agent-browser's bundled test browser — it will be blocked by Google the same way.",
794
+ ].join("\n"),
795
+ }],
796
+ details: { ok: false, command: "login-handoff", args: [], stdout: "", stderr: "no chrome executable found", exitCode: null, signal: null, durationMs: 0 },
797
+ terminate: true,
798
+ };
799
+ }
800
+
801
+ const profileDir = typeof params.profileDir === "string" && params.profileDir.trim()
802
+ ? params.profileDir.trim()
803
+ : join(ctx.cwd, SESSION_STATE_DIR, "login-profiles", session);
804
+ await mkdir(profileDir, { recursive: true });
805
+
806
+ const port = await findFreePort();
807
+
808
+ let spawnError: Error | undefined;
809
+ const child = spawn(executablePath, [
810
+ `--remote-debugging-port=${port}`,
811
+ `--user-data-dir=${profileDir}`,
812
+ "--no-first-run",
813
+ "--no-default-browser-check",
814
+ url,
815
+ ], { detached: true, stdio: "ignore" });
816
+ // Persistent handler: without this, an 'error' event (e.g. ENOENT for a bad
817
+ // executablePath) on this detached/unref'd child is unhandled and crashes the
818
+ // whole host process whenever it fires, even long after this tool call returns.
819
+ child.on("error", (error) => {
820
+ spawnError = error;
821
+ });
822
+ child.unref();
823
+
824
+ const debugPortWaitController = new AbortController();
825
+ const debugPortUp = spawnError ? false : await Promise.race([
826
+ waitForDebugPort(port, undefined, undefined, debugPortWaitController.signal),
827
+ new Promise<boolean>((resolveRace) => {
828
+ child.once("error", () => resolveRace(false));
829
+ }),
830
+ ]);
831
+ // Whichever branch lost the race must stop polling promptly instead of
832
+ // holding the event loop open for its own full timeout in the background.
833
+ debugPortWaitController.abort();
834
+ if (spawnError || !debugPortUp) {
835
+ try { child.kill(); } catch { /* best-effort */ }
836
+ return {
837
+ content: [{
838
+ type: "text",
839
+ text: [
840
+ spawnError
841
+ ? `Failed to launch the login browser: ${spawnError.message}`
842
+ : `Failed to confirm the login browser's debug port (127.0.0.1:${port}) came up in time.`,
843
+ `Attempted to launch: ${executablePath}`,
844
+ "The login browser was not confirmed usable; it has been asked to close. Stop and report back.",
845
+ ].join("\n"),
846
+ }],
847
+ details: { ok: false, command: "login-handoff", args: [executablePath, url], stdout: "", stderr: spawnError ? spawnError.message : "debug port did not come up", exitCode: null, signal: null, durationMs: 0 },
848
+ terminate: true,
849
+ };
850
+ }
851
+
852
+ if (!ctx.hasUI) {
853
+ try { child.kill(); } catch { /* best-effort */ }
854
+ return {
855
+ content: [{
856
+ type: "text",
857
+ text: [
858
+ "Login handoff required but no interactive UI is available in this run mode.",
859
+ `Reason: ${reason}`,
860
+ "The login browser has been closed. Stop this task now and ask the operator to rerun it interactively so the login can be completed.",
861
+ ].join("\n"),
862
+ }],
863
+ details: { ok: false, command: "login-handoff", args: [executablePath, url], stdout: "", stderr: "no interactive UI", exitCode: null, signal: null, durationMs: 0 },
864
+ terminate: true,
865
+ };
866
+ }
867
+
868
+ ctx.ui.notify(`Login handoff needed: ${reason}`, "warning");
869
+ ctx.ui.setStatus("agent-browser-login-handoff", `⏸ ログイン待機中 — ${reason}`);
870
+ let choice: string | undefined;
871
+ try {
872
+ choice = await ctx.ui.select(
873
+ `Login required: ${reason}`,
874
+ ["Resume - I completed the login", "Abort this task"],
875
+ );
876
+ } finally {
877
+ ctx.ui.setStatus("agent-browser-login-handoff", undefined);
878
+ }
879
+
880
+ if (choice !== "Resume - I completed the login") {
881
+ try { child.kill(); } catch { /* best-effort */ }
882
+ return {
883
+ content: [{
884
+ type: "text",
885
+ text: "Human aborted the task during login handoff. Stop and report back; do not retry automatically.",
886
+ }],
887
+ details: { ok: false, command: "login-handoff", args: [executablePath, url], stdout: choice ?? "", stderr: "", exitCode: 1, signal: null, durationMs: 0 },
888
+ terminate: true,
889
+ };
890
+ }
891
+
892
+ // Do NOT keep driving the live --cdp connection as the ongoing session: `agent-browser
893
+ // --cdp <port> ... open` (no url) opens a brand-new blank page/context in the connected
894
+ // browser rather than reusing the tab the human actually authenticated in, leaving the
895
+ // "attached" session on about:blank with no auth. Instead follow agent-browser's own
896
+ // documented pattern for this exact scenario (see its authentication.md "Import Auth
897
+ // from Your Browser" / "Two-Factor Authentication" sections): extract the authenticated
898
+ // cookies/storage from the login browser via `state save`, close the disposable login
899
+ // browser, then load that state into a normal, freshly-launched session via `--state`.
900
+ const authStatePath = join(profileDir, "auth-state.json");
901
+ const saveArgs = ["--cdp", String(port), "state", "save", authStatePath];
902
+ const saveResult = await runAgentBrowser(saveArgs, { signal, timeoutMs: params.timeoutMs as number | undefined, cwd: ctx.cwd, onUpdate });
903
+ try { child.kill(); } catch { /* best-effort; the login browser is disposable once we've extracted its auth state */ }
904
+
905
+ if (!saveResult.ok) {
906
+ return {
907
+ content: [{
908
+ type: "text",
909
+ text: [
910
+ "Login browser was confirmed by the human, but extracting its authenticated state via `state save` failed. Do not assume the session is usable.",
911
+ `Command: ${saveResult.command} ${saveResult.args.map((a) => JSON.stringify(a)).join(" ")}`,
912
+ ].join("\n"),
913
+ }],
914
+ details: { ...saveResult, artifactPaths: [] },
915
+ terminate: true,
916
+ };
917
+ }
918
+
919
+ const loadArgs = ["--session", session, "--restore", "--state", authStatePath, "open", url];
920
+ const result = await runAgentBrowser(loadArgs, { signal, timeoutMs: params.timeoutMs as number | undefined, cwd: ctx.cwd, onUpdate });
921
+
922
+ if (!result.ok) {
923
+ return {
924
+ content: [{
925
+ type: "text",
926
+ text: [
927
+ "Login state was captured from the human's browser, but loading it into a fresh agent-browser session failed. Do not assume the session is usable.",
928
+ `Command: ${result.command} ${result.args.map((a) => JSON.stringify(a)).join(" ")}`,
929
+ ].join("\n"),
930
+ }],
931
+ details: { ...result, artifactPaths: [] },
932
+ terminate: true,
933
+ };
934
+ }
935
+
936
+ await writeSessionState(ctx.cwd, session, { headed: false, lastUrl: url });
937
+
938
+ return {
939
+ content: [{
940
+ type: "text",
941
+ text: [
942
+ "Login handoff complete: the human's authenticated cookies/storage were captured and loaded into a fresh agent-browser session.",
943
+ `Session: ${session === DEFAULT_SESSION_KEY ? "(default)" : session}`,
944
+ "Take a fresh agent_browser_snapshot before continuing.",
945
+ ].join("\n"),
946
+ }],
947
+ details: { ...result, artifactPaths: [] },
948
+ terminate: true,
949
+ };
950
+ },
951
+ });
952
+
699
953
  pi.registerTool({
700
954
  name: "agent_browser_commit",
701
955
  label: "Agent Browser Commit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@53able/pi-agent-browser",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Typed Pi tools for browser automation, rendered-page context extraction, screenshots, and saved session state via agent-browser.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,6 +40,28 @@ Two tools exist so the agent stops and hands control back to a human instead of
40
40
 
41
41
  `agent_browser_open` records whether each named session was launched with `headed: true`. When `agent_browser_handoff` runs for a session that was not opened headed, it automatically prepends a warning naming the session and the exact `agent_browser_open` arguments (including the last known URL) needed to reopen it visibly, instead of leaving the human to guess. Prefer `headed: true` from the start for any task that might hit a login, 2FA, CAPTCHA, or identity-verification step — a human can only intervene through `agent_browser_handoff` if a visible window already exists. Note that some verification challenges are single-use or session-bound, so reopening may require restarting the login flow rather than resuming mid-challenge.
42
42
 
43
+ ### For interactive login flows (Google, OAuth, and similar)
44
+
45
+ `agent_browser_login_handoff` solves a specific problem: Google and similar OAuth providers block sign-in when `agent-browser open` is used, because agent-browser attaches a remote debugging protocol (CDP) session the instant Chrome launches, and Google detects this automation marker and rejects the login attempt regardless of profile, cookies, or executable.
46
+
47
+ This tool spawns a plain, un-instrumented Chrome process (not through `agent-browser open`) with a remote debugging port and a dedicated persistent profile, so no CDP client is attached while the human logs in. Chrome behaves like an ordinary browser to Google during sign-in. After the human confirms login is complete, the tool captures the authenticated cookies and storage from that browser (`agent-browser state save`), closes the disposable login browser, and loads that captured state into a fresh, ordinary agent-browser session (`agent-browser state load`) for all subsequent automated snapshot, read, and click operations. (An earlier version tried to keep driving the login browser live over CDP; that opened a disconnected blank tab instead of reusing the authenticated one, so state capture-and-load is used instead.)
48
+
49
+ **Important:** this is an architecture fix, not detection evasion. The tool does not hide webdriver flags or automation fingerprints — it simply avoids having a CDP session attached during the interactive login moment itself.
50
+
51
+ Use `agent_browser_login_handoff` instead of `agent_browser_open` for any task expected to hit an interactive Google, OAuth, or similar sign-in flow. Never try to push through such a login via `agent_browser_open` + click/fill — that's the exact failure mode this tool exists to avoid.
52
+
53
+ Example call:
54
+
55
+ ```json
56
+ {
57
+ "url": "https://myapp.com/login",
58
+ "session": "google-oauth-flow",
59
+ "reason": "User must complete Google OAuth sign-in for app access"
60
+ }
61
+ ```
62
+
63
+ After the human confirms login is complete, subsequent `agent_browser_open`, `agent_browser_snapshot`, `agent_browser_click`, and other calls with the same `session` name will reuse the authenticated browser state and operate normally. This new session runs headless by default (it is a fresh agent-browser session, not the disposable login browser, which is closed once its auth state is captured); reopen it with `headed: true` if you need to see it.
64
+
43
65
  ## Common examples
44
66
 
45
67
  Read a public page: