openchrome-mcp 1.10.2 → 1.10.3

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.
Files changed (92) hide show
  1. package/README.md +46 -15
  2. package/assets/badges/mseep.png +0 -0
  3. package/dist/chrome/exit-classifier.d.ts +66 -0
  4. package/dist/chrome/exit-classifier.d.ts.map +1 -0
  5. package/dist/chrome/exit-classifier.js +97 -0
  6. package/dist/chrome/exit-classifier.js.map +1 -0
  7. package/dist/chrome/launch-mode-resolver.d.ts +78 -0
  8. package/dist/chrome/launch-mode-resolver.d.ts.map +1 -0
  9. package/dist/chrome/launch-mode-resolver.js +108 -0
  10. package/dist/chrome/launch-mode-resolver.js.map +1 -0
  11. package/dist/chrome/launcher.d.ts +40 -0
  12. package/dist/chrome/launcher.d.ts.map +1 -1
  13. package/dist/chrome/launcher.js +174 -15
  14. package/dist/chrome/launcher.js.map +1 -1
  15. package/dist/chrome/ownership-marker.d.ts +86 -0
  16. package/dist/chrome/ownership-marker.d.ts.map +1 -0
  17. package/dist/chrome/ownership-marker.js +329 -0
  18. package/dist/chrome/ownership-marker.js.map +1 -0
  19. package/dist/chrome/process-detector.d.ts +49 -0
  20. package/dist/chrome/process-detector.d.ts.map +1 -0
  21. package/dist/chrome/process-detector.js +241 -0
  22. package/dist/chrome/process-detector.js.map +1 -0
  23. package/dist/chrome/process-watchdog.d.ts.map +1 -1
  24. package/dist/chrome/process-watchdog.js +17 -1
  25. package/dist/chrome/process-watchdog.js.map +1 -1
  26. package/dist/cli/claude-cli.d.ts +23 -0
  27. package/dist/cli/claude-cli.js +31 -0
  28. package/dist/cli/claude-cli.js.map +1 -0
  29. package/dist/cli/claude-session.js +3 -2
  30. package/dist/cli/claude-session.js.map +1 -1
  31. package/dist/cli/index.js +46 -9
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/cli/mcp-client-config.d.ts +13 -1
  34. package/dist/cli/mcp-client-config.js +33 -2
  35. package/dist/cli/mcp-client-config.js.map +1 -1
  36. package/dist/config/global.d.ts +6 -1
  37. package/dist/config/global.d.ts.map +1 -1
  38. package/dist/config/global.js.map +1 -1
  39. package/dist/config/headless-resolver.d.ts +39 -0
  40. package/dist/config/headless-resolver.d.ts.map +1 -0
  41. package/dist/config/headless-resolver.js +55 -0
  42. package/dist/config/headless-resolver.js.map +1 -0
  43. package/dist/config/tool-tiers.d.ts.map +1 -1
  44. package/dist/config/tool-tiers.js +2 -1
  45. package/dist/config/tool-tiers.js.map +1 -1
  46. package/dist/index.js +53 -7
  47. package/dist/index.js.map +1 -1
  48. package/dist/mcp-server.d.ts.map +1 -1
  49. package/dist/mcp-server.js +21 -4
  50. package/dist/mcp-server.js.map +1 -1
  51. package/dist/tools/computer.d.ts.map +1 -1
  52. package/dist/tools/computer.js +31 -6
  53. package/dist/tools/computer.js.map +1 -1
  54. package/dist/tools/fill-form.d.ts.map +1 -1
  55. package/dist/tools/fill-form.js +122 -4
  56. package/dist/tools/fill-form.js.map +1 -1
  57. package/dist/tools/index.d.ts.map +1 -1
  58. package/dist/tools/index.js +4 -0
  59. package/dist/tools/index.js.map +1 -1
  60. package/dist/tools/login-detector.d.ts +87 -0
  61. package/dist/tools/login-detector.d.ts.map +1 -0
  62. package/dist/tools/login-detector.js +169 -0
  63. package/dist/tools/login-detector.js.map +1 -0
  64. package/dist/tools/navigate.d.ts.map +1 -1
  65. package/dist/tools/navigate.js +73 -22
  66. package/dist/tools/navigate.js.map +1 -1
  67. package/dist/tools/validate-page.d.ts +16 -0
  68. package/dist/tools/validate-page.d.ts.map +1 -0
  69. package/dist/tools/validate-page.js +309 -0
  70. package/dist/tools/validate-page.js.map +1 -0
  71. package/dist/tools/wait-for.js +2 -2
  72. package/dist/tools/wait-for.js.map +1 -1
  73. package/dist/transports/stdio.d.ts.map +1 -1
  74. package/dist/transports/stdio.js +15 -0
  75. package/dist/transports/stdio.js.map +1 -1
  76. package/dist/utils/pid-manager.d.ts +16 -0
  77. package/dist/utils/pid-manager.d.ts.map +1 -1
  78. package/dist/utils/pid-manager.js +88 -0
  79. package/dist/utils/pid-manager.js.map +1 -1
  80. package/dist/utils/session-resume-token.d.ts +53 -0
  81. package/dist/utils/session-resume-token.d.ts.map +1 -0
  82. package/dist/utils/session-resume-token.js +191 -0
  83. package/dist/utils/session-resume-token.js.map +1 -0
  84. package/dist/utils/sync-shutdown.d.ts +51 -0
  85. package/dist/utils/sync-shutdown.d.ts.map +1 -0
  86. package/dist/utils/sync-shutdown.js +112 -0
  87. package/dist/utils/sync-shutdown.js.map +1 -0
  88. package/dist/watchdog/health-endpoint.d.ts +5 -0
  89. package/dist/watchdog/health-endpoint.d.ts.map +1 -1
  90. package/dist/watchdog/health-endpoint.js +14 -2
  91. package/dist/watchdog/health-endpoint.js.map +1 -1
  92. package/package.json +1 -1
package/README.md CHANGED
@@ -14,6 +14,7 @@
14
14
  <a href="https://github.com/shaun0927/openchrome/releases/latest"><img src="https://img.shields.io/github/v/release/shaun0927/openchrome" alt="Latest Release"></a>
15
15
  <a href="https://github.com/shaun0927/openchrome/releases/latest"><img src="https://img.shields.io/github/release-date/shaun0927/openchrome" alt="Release Date"></a>
16
16
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT"></a>
17
+ <a href="https://mseep.ai/app/shaun0927-openchrome"><img src="assets/badges/mseep.png" alt="Listed on MseeP.ai" height="20"></a>
17
18
  </p>
18
19
 
19
20
  <p align="center">
@@ -208,6 +209,11 @@ npx openchrome-mcp setup
208
209
  npx openchrome-mcp setup --client codex
209
210
  ```
210
211
 
212
+ **OpenCode**
213
+ ```bash
214
+ npx openchrome-mcp setup --client opencode
215
+ ```
216
+
211
217
  One command. Configures the MCP server for the selected client.
212
218
  Restart your MCP client after setup completes.
213
219
 
@@ -244,6 +250,20 @@ claude mcp add openchrome -- npx -y openchrome-mcp@latest serve --auto-launch
244
250
  }
245
251
  ```
246
252
 
253
+
254
+ **OpenCode** (`~/.config/opencode/opencode.json`):
255
+ ```json
256
+ {
257
+ "$schema": "https://opencode.ai/config.json",
258
+ "mcp": {
259
+ "openchrome": {
260
+ "type": "local",
261
+ "command": ["npx", "--prefer-online", "-y", "openchrome-mcp@latest", "serve", "--auto-launch"]
262
+ }
263
+ }
264
+ }
265
+ ```
266
+
247
267
  **Cursor / Windsurf / Other stdio MCP clients:**
248
268
  ```json
249
269
  {
@@ -397,9 +417,11 @@ When a navigation is blocked by CDN/WAF systems (Akamai, Cloudflare, etc.), Open
397
417
  Tier 3 launches a real headed Chrome window with a genuine user-agent (`Chrome/...` instead of `HeadlessChrome/...`) and a different TLS fingerprint, bypassing binary-level detection that no JavaScript injection can fix.
398
418
 
399
419
  **Parameters:**
400
- - `autoFallback: false` — disable all automatic retry
401
- - `headed: true` — skip directly to Tier 3 (headed Chrome)
402
- - `stealth: true` — use stealth mode (Tier 2) explicitly
420
+ - `autoFallback: false` — disable automatic CDN/WAF retry. This does not log in for you or bypass normal authentication redirects.
421
+ - `headed: true` — skip directly to headed Chrome for user-visible login, 2FA, CAPTCHA, or sites that require a real browser window.
422
+ - `stealth: true` — use stealth mode (Tier 2) explicitly.
423
+
424
+ **Authentication note:** Auto-fallback is for detected CDN/WAF blocking. If a protected app redirects from the requested URL to a same-site login page, treat that as an authentication handoff: retry with `headed: true` and the same persistent profile, let the user complete login, then verify whether headless can reuse that profile state.
403
425
 
404
426
  **Environment:** Tier 3 requires a display (macOS/Windows desktop, or Linux with `$DISPLAY`). In server/container environments without a display, Tier 3 is gracefully skipped.
405
427
 
@@ -426,15 +448,22 @@ If client A opens five tabs and client B opens five tabs, all ten `tabId`s are d
426
448
 
427
449
  ### How do I handle sites that require interactive login (password, 2FA, CAPTCHA)?
428
450
 
429
- Two mechanisms, used together in practice:
451
+ Use two mechanisms, but keep their guarantees separate:
452
+
453
+ **1. Persistent-profile headless — reuse an already-authenticated profile.**
454
+ Point OpenChrome at a persistent `userDataDir` (+ optional `profileDirectory`) so cookies / `localStorage` / IndexedDB can survive across runs. If that persistent profile already contains a valid session, subsequent **headless** runs stay logged in until the site invalidates the session.
430
455
 
431
- **1. Persistent-profile headlesslog in once, automate forever.**
432
- Point OpenChrome at a persistent `userDataDir` (+ optional `profileDirectory`) and cookies / `localStorage` / IndexedDB survive across runs. After the first login, subsequent **headless** runs stay logged in until the site invalidates the session.
456
+ **2. Headed-by-default / headed fallback let the user complete an interactive step.**
457
+ Since #657 the launcher runs headed by default, so first-time login, 2FA, CAPTCHA, and WebAuthn can use a real visible window without extra flags. CI / Docker users opt into headless via `--headless` or `OPENCHROME_HEADLESS=1` after their persistent profile is bootstrapped. When a Tier-1/Tier-2 headless attempt is blocked by a CDN/WAF, OpenChrome can also lazy-launch a separate headed Chrome on a different debug port and register the headed page back into the same logical session.
433
458
 
434
- **2. Headed fallback for the initial login or WAF-blocked sites.**
435
- When a human action is genuinely required (first-time login, 2FA, CAPTCHA, WebAuthn) or when a Tier-1/Tier-2 headless attempt is blocked by a CDN/WAF, OpenChrome lazy-launches a separate headed Chrome on a different debug port. Cookies are sync'd from the real Chrome profile before launch, and the headed page is registered back into the same logical session so the surrounding workflow continues seamlessly.
459
+ **Important:** a headed tab being authenticated does not automatically prove that a new headless tab can reuse the session after the headed tab is closed. Sites differ in how they bind cookies, storage, browser fingerprints, and session freshness. Always verify the handoff by closing/restarting the headed path you plan to stop using and navigating headless to the protected URL with the same persistent profile.
436
460
 
437
- **Typical pattern:** bootstrap the login once via the headed path → the persistent profile carries the cookies → all subsequent automation runs headless without a window.
461
+ **Recommended flow:**
462
+ 1. Start with the persistent `userDataDir` / `profileDirectory` you intend to keep using.
463
+ 2. Navigate to the protected URL. If it resolves to `/login` or another auth page, do not keep retrying unauthenticated headless navigation.
464
+ 3. Use the visible headed window (default) or navigate with `headed: true` and the same profile context, then let the user complete login/2FA/CAPTCHA.
465
+ 4. Retry the protected URL with the same profile in the mode you intend to automate.
466
+ 5. If headless still lands on the login page, keep the headed tab open for that site or reconfigure persistence; do not assume the headed auth state transferred.
438
467
 
439
468
  ### Does OpenChrome steal focus with popup windows?
440
469
 
@@ -442,12 +471,12 @@ When a human action is genuinely required (first-time login, 2FA, CAPTCHA, WebAu
442
471
 
443
472
  The headed-browser focus-stealing pattern that users encounter with some MCP servers (cross-Space jumps on macOS, un-minimizable popups, per-tool-call window raises) comes from designs where the MCP drives a user-visible browser and creates OS windows as it works. OpenChrome is architected differently:
444
473
 
445
- - **Default mode is headless** — no window exists, so there is nothing to take focus.
446
474
  - **`tabs_create` opens a tab, not an OS window.** New tabs are created via CDP inside the already-running Chrome, and OpenChrome never calls `page.bringToFront()` anywhere in the codebase.
447
- - **The headed fallback is lazy and reused.** When it is needed, it launches **once** per server lifetime; every later navigation/tab runs inside that same instance. At worst you see one focus grab the very first time the fallback activates not one per action, never one per tab.
448
- - **The headed fallback is optional.** If persistent-profile headless is sufficient for your sites, you will never see a browser window.
475
+ - **No per-call window raises.** Each navigation/click/tool call runs against the existing window without `bringToFront()`, `focus()`, or any other stealing primitive. After the initial Chrome launch you keep working in your other apps without interruption.
476
+ - **One Chrome per server lifetime.** Auto-launch creates Chrome **once** at startup and reuses it for every later tool call no popup-per-action loop.
477
+ - **Headless opt-in available.** For CI/server use, `--headless` or `OPENCHROME_HEADLESS=1` runs without any window at all. The default is headed since #657 because headless mode is materially more prone to silent hangs and login failures on real-world sites.
449
478
 
450
- The only scenario in which a window appears at all is the first time the Tier-3 headed fallback activates in a given session.
479
+ The only scenario in which a focus grab can happen is the very first Chrome launch not one per tool call, never one per tab.
451
480
 
452
481
  ---
453
482
 
@@ -538,6 +567,7 @@ docker run openchrome
538
567
  | `OPENCHROME_PPID_WATCH` | Set to `0` to disable the parent-process watcher in stdio mode. Default: enabled. The watcher exits the server when its launching MCP-client parent dies, so abrupt parent termination (force-quit, `kill -9`, tmux teardown) does not orphan the openchrome process. HTTP and `both` transport modes ignore this flag — they remain daemon-capable. |
539
568
  | `OPENCHROME_PPID_WATCH_INTERVAL_MS` | Polling interval for the parent watcher in milliseconds. Default: `2000`. Clamped to `[500, 60000]`. |
540
569
  | `OPENCHROME_HEALTH_ENDPOINT` | Force-enable (`1`/`true`) or force-disable (`0`/`false`) the `/health` and `/metrics` HTTP listener. Default: on for `--transport http` / `both`, off for `--transport stdio`. Stdio-mode instances usually talk to a single MCP client over the pipe and do not need an external monitoring port; disabling it saves ~200-300 KB heap + one file descriptor per instance. Operators who run stdio under a supervisor can opt in with `OPENCHROME_HEALTH_ENDPOINT=1`; daemon-mode operators who run the health check externally can opt out with `OPENCHROME_HEALTH_ENDPOINT=0`. Invalid values (e.g. `yes`, `2`) fall through to the transport-mode default. |
570
+ | `OPENCHROME_HEADLESS` | Opt into headless Chrome from CI / Docker without `--headless`. Accepts `1`/`true`/`yes` (headless) or `0`/`false`/`no` (headed). Lower precedence than the CLI flag, higher than persisted config. Default since #657 is headed. |
541
571
 
542
572
  ### Individual flags
543
573
 
@@ -553,9 +583,10 @@ openchrome serve \
553
583
  | Flag | Default | Description |
554
584
  |------|---------|-------------|
555
585
  | `--auto-launch` | `false` | Auto-launch Chrome if not running |
586
+ | `--headless` | `false` | Run Chrome headless. Also: `OPENCHROME_HEADLESS=1`. Default since #657 is headed. |
556
587
  | `--headless-shell` | `false` | Use chrome-headless-shell binary |
557
- | `--visible` | `false` | Show Chrome window (disables headless) |
558
- | `--server-mode` | `false` | Compound flag for server deployment |
588
+ | `--visible` | (deprecated) | No-op alias for headed; the new default is headed since #657. Will be removed in a future release. |
589
+ | `--server-mode` | `false` | Compound flag for server deployment (forces `--headless` + auto-launch) |
559
590
 
560
591
  ---
561
592
 
Binary file
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Chrome exit classifier (#660).
3
+ *
4
+ * Distinguishes user-initiated close from a crash so the watchdog can stop
5
+ * silently re-launching Chrome that the user just told the OS to close.
6
+ *
7
+ * Inputs are the Node `exit` event fields plus how long Chrome was alive
8
+ * before the exit fired:
9
+ * - code — process exit code, or `null` if killed by a signal
10
+ * - signal — POSIX signal name, or `null` if exited normally
11
+ * - uptimeMs — wall time from spawn to exit
12
+ * - intentionalStop — set by the launcher when oc_stop / shutdown ran
13
+ *
14
+ * Anti-flap: Chrome cold-start typically takes 1-3 s. A "clean" exit within
15
+ * a few seconds overwhelmingly indicates a misconfigured launch (bad
16
+ * --user-data-dir, missing binary) rather than a deliberate user action.
17
+ * The threshold defaults to 5 s and is configurable via
18
+ * OPENCHROME_ANTIFLAP_SECONDS.
19
+ */
20
+ export type ExitClassification = 'intentional' | 'clean' | 'crash';
21
+ export interface ClassifyExitInput {
22
+ /** Process exit code (number) or null if killed by a signal. */
23
+ code: number | null;
24
+ /** Signal name (e.g. 'SIGTERM') or null. */
25
+ signal: NodeJS.Signals | null;
26
+ /** Milliseconds Chrome was alive before exit. */
27
+ uptimeMs: number;
28
+ /** True if openchrome itself initiated the stop (oc_stop or MCP shutdown). */
29
+ intentionalStop: boolean;
30
+ }
31
+ /**
32
+ * Read the anti-flap threshold (in milliseconds) from
33
+ * OPENCHROME_ANTIFLAP_SECONDS, with a 5-second default.
34
+ *
35
+ * `0` means "disable anti-flap entirely" (gemini medium review on #668).
36
+ * Negative / non-numeric values fall back to the default. Callers can
37
+ * pass an override for tests.
38
+ */
39
+ export declare function antiFlapMs(envValue?: string | undefined): number;
40
+ /**
41
+ * Read the watchdog quiesce duration (ms) from OPENCHROME_QUIESCE_MS.
42
+ * Default is 60 s. `0` disables quiesce entirely (gemini high review on #668).
43
+ */
44
+ export declare function quiesceMs(envValue?: string | undefined): number;
45
+ /**
46
+ * Classify a Chrome exit.
47
+ *
48
+ * Decision matrix (highest priority first):
49
+ * 1. intentionalStop=true → 'intentional'
50
+ * 2. uptimeMs < anti-flap → 'crash' (Chrome failed to start cleanly)
51
+ * 3. code===0 → 'clean' (user closed window normally)
52
+ * 4. SIGTERM / SIGINT → 'clean' (red dot / Cmd+Q / WM close)
53
+ * 5. otherwise → 'crash' (segfault, OOM, abort, …)
54
+ */
55
+ export declare function classifyExit(input: ClassifyExitInput, opts?: {
56
+ antiFlapMs?: number;
57
+ }): ExitClassification;
58
+ /**
59
+ * Should the watchdog rate-limit relaunches because Chrome has been
60
+ * crashing repeatedly? Returns true after `threshold` crashes inside
61
+ * `windowMs`.
62
+ *
63
+ * Pure function: caller provides the timestamps array.
64
+ */
65
+ export declare function shouldRateLimitRelaunch(recentCrashTimestampsMs: ReadonlyArray<number>, now?: number, windowMs?: number, threshold?: number): boolean;
66
+ //# sourceMappingURL=exit-classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-classifier.d.ts","sourceRoot":"","sources":["../../src/chrome/exit-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC9B,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,QAAQ,GAAE,MAAM,GAAG,SAAmD,GAAG,MAAM,CAKzG;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,GAAE,MAAM,GAAG,SAA6C,GAAG,MAAM,CAKlG;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,kBAAkB,CAiBpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,uBAAuB,EAAE,aAAa,CAAC,MAAM,CAAC,EAC9C,GAAG,GAAE,MAAmB,EACxB,QAAQ,GAAE,MAAe,EACzB,SAAS,GAAE,MAAU,GACpB,OAAO,CAMT"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /**
3
+ * Chrome exit classifier (#660).
4
+ *
5
+ * Distinguishes user-initiated close from a crash so the watchdog can stop
6
+ * silently re-launching Chrome that the user just told the OS to close.
7
+ *
8
+ * Inputs are the Node `exit` event fields plus how long Chrome was alive
9
+ * before the exit fired:
10
+ * - code — process exit code, or `null` if killed by a signal
11
+ * - signal — POSIX signal name, or `null` if exited normally
12
+ * - uptimeMs — wall time from spawn to exit
13
+ * - intentionalStop — set by the launcher when oc_stop / shutdown ran
14
+ *
15
+ * Anti-flap: Chrome cold-start typically takes 1-3 s. A "clean" exit within
16
+ * a few seconds overwhelmingly indicates a misconfigured launch (bad
17
+ * --user-data-dir, missing binary) rather than a deliberate user action.
18
+ * The threshold defaults to 5 s and is configurable via
19
+ * OPENCHROME_ANTIFLAP_SECONDS.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.antiFlapMs = antiFlapMs;
23
+ exports.quiesceMs = quiesceMs;
24
+ exports.classifyExit = classifyExit;
25
+ exports.shouldRateLimitRelaunch = shouldRateLimitRelaunch;
26
+ /**
27
+ * Read the anti-flap threshold (in milliseconds) from
28
+ * OPENCHROME_ANTIFLAP_SECONDS, with a 5-second default.
29
+ *
30
+ * `0` means "disable anti-flap entirely" (gemini medium review on #668).
31
+ * Negative / non-numeric values fall back to the default. Callers can
32
+ * pass an override for tests.
33
+ */
34
+ function antiFlapMs(envValue = process.env.OPENCHROME_ANTIFLAP_SECONDS) {
35
+ if (envValue === undefined || envValue === '')
36
+ return 5_000;
37
+ const parsed = parseInt(envValue, 10);
38
+ if (!Number.isFinite(parsed) || parsed < 0)
39
+ return 5_000;
40
+ return parsed * 1000;
41
+ }
42
+ /**
43
+ * Read the watchdog quiesce duration (ms) from OPENCHROME_QUIESCE_MS.
44
+ * Default is 60 s. `0` disables quiesce entirely (gemini high review on #668).
45
+ */
46
+ function quiesceMs(envValue = process.env.OPENCHROME_QUIESCE_MS) {
47
+ if (envValue === undefined || envValue === '')
48
+ return 60_000;
49
+ const parsed = parseInt(envValue, 10);
50
+ if (!Number.isFinite(parsed) || parsed < 0)
51
+ return 60_000;
52
+ return parsed;
53
+ }
54
+ /**
55
+ * Classify a Chrome exit.
56
+ *
57
+ * Decision matrix (highest priority first):
58
+ * 1. intentionalStop=true → 'intentional'
59
+ * 2. uptimeMs < anti-flap → 'crash' (Chrome failed to start cleanly)
60
+ * 3. code===0 → 'clean' (user closed window normally)
61
+ * 4. SIGTERM / SIGINT → 'clean' (red dot / Cmd+Q / WM close)
62
+ * 5. otherwise → 'crash' (segfault, OOM, abort, …)
63
+ */
64
+ function classifyExit(input, opts = {}) {
65
+ if (input.intentionalStop)
66
+ return 'intentional';
67
+ const flapMs = opts.antiFlapMs ?? antiFlapMs();
68
+ // Negative uptime can't physically happen but we still treat it as "no
69
+ // uptime info" rather than auto-crashing on clock-skew weirdness.
70
+ if (input.uptimeMs < flapMs)
71
+ return 'crash';
72
+ if (input.code === 0)
73
+ return 'clean';
74
+ // Signal-based clean exits (POSIX user close → SIGTERM, Ctrl+C → SIGINT).
75
+ // Node guarantees at least one of (code, signal) is non-null on the
76
+ // 'exit' event, so we don't re-handle the all-null case here.
77
+ const cleanSignals = ['SIGTERM', 'SIGINT'];
78
+ if (input.signal !== null && cleanSignals.includes(input.signal))
79
+ return 'clean';
80
+ return 'crash';
81
+ }
82
+ /**
83
+ * Should the watchdog rate-limit relaunches because Chrome has been
84
+ * crashing repeatedly? Returns true after `threshold` crashes inside
85
+ * `windowMs`.
86
+ *
87
+ * Pure function: caller provides the timestamps array.
88
+ */
89
+ function shouldRateLimitRelaunch(recentCrashTimestampsMs, now = Date.now(), windowMs = 60_000, threshold = 3) {
90
+ let count = 0;
91
+ for (const t of recentCrashTimestampsMs) {
92
+ if (now - t <= windowMs)
93
+ count++;
94
+ }
95
+ return count >= threshold;
96
+ }
97
+ //# sourceMappingURL=exit-classifier.js.map
@@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5C,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAErC,0EAA0E;IAC1E,oEAAoE;IACpE,8DAA8D;IAC9D,MAAM,YAAY,GAAkC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC1E,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,OAAO,CAAC;IAEjF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,uBAA8C,EAC9C,MAAc,IAAI,CAAC,GAAG,EAAE,EACxB,WAAmB,MAAM,EACzB,YAAoB,CAAC;IAErB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,uBAAuB,EAAE,CAAC;QACxC,IAAI,GAAG,GAAG,CAAC,IAAI,QAAQ;YAAE,KAAK,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,IAAI,SAAS,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Launch mode resolver (#659).
3
+ *
4
+ * Decides how openchrome should obtain a Chrome to drive when the user
5
+ * specifies a profile.
6
+ *
7
+ * Three modes:
8
+ *
9
+ * 'auto' — default; openchrome probes the configured remote-debugging
10
+ * port first and attaches if Chrome is already there;
11
+ * otherwise spawns its own Chrome. (Existing behavior — no
12
+ * change for users who don't set anything.)
13
+ *
14
+ * 'attach' — opt-in; openchrome MUST attach to an existing Chrome that
15
+ * the user pre-launched with `--remote-debugging-port`. If
16
+ * nothing is listening, the launcher returns a structured
17
+ * error (`AttachConsentRequiredError`) so the agent can
18
+ * surface a helpful next-step message instead of silently
19
+ * spawning a clean-room copy.
20
+ *
21
+ * 'isolated' — opt-in; openchrome ALWAYS spawns its own Chrome with the
22
+ * isolated `--user-data-dir` even if a Chrome is already
23
+ * listening on the debug port. Useful for clean-room
24
+ * scraping where you want a guaranteed fresh profile.
25
+ *
26
+ * Important policy decisions baked in here (see #659 PR description):
27
+ * 1. Default stays 'auto'. No behavior change for existing users.
28
+ * 2. We NEVER auto-restart the user's Chrome to enable a debug port.
29
+ * If the user wants attach mode, they must launch Chrome themselves
30
+ * with `--remote-debugging-port=NNNN`. The follow-up "automatic
31
+ * restart with consent" workflow is deferred to a separate issue.
32
+ * 3. When attach mode is on AND the port isn't listening, we surface a
33
+ * loud, structured error rather than silently falling back —
34
+ * otherwise the user would never realise their attach attempt
35
+ * didn't take.
36
+ */
37
+ export type LaunchMode = 'auto' | 'attach' | 'isolated';
38
+ export interface LaunchModeOptions {
39
+ /** Per-call override (highest priority). */
40
+ launchMode?: LaunchMode | string;
41
+ }
42
+ export interface LaunchModeEnv {
43
+ OPENCHROME_LAUNCH_MODE?: string;
44
+ }
45
+ export interface LaunchModeConfig {
46
+ chromeLaunchMode?: LaunchMode | string;
47
+ }
48
+ export declare class InvalidLaunchModeError extends Error {
49
+ constructor(value: string, source: 'cli' | 'env' | 'config');
50
+ }
51
+ /**
52
+ * Resolves the launch mode from CLI options, env, and config.
53
+ * Precedence (highest first):
54
+ * 1. options.launchMode (per-call override)
55
+ * 2. OPENCHROME_LAUNCH_MODE env var
56
+ * 3. globalConfig.chromeLaunchMode
57
+ * 4. 'auto' (default)
58
+ *
59
+ * Throws `InvalidLaunchModeError` for unrecognised values rather than
60
+ * silently coercing — surfaces typos in env vars and config files.
61
+ */
62
+ export declare function resolveLaunchMode(options?: LaunchModeOptions, env?: LaunchModeEnv, config?: LaunchModeConfig): LaunchMode;
63
+ /**
64
+ * Structured error: surface to the agent when attach is required but no
65
+ * Chrome is listening on the debug port. The agent's logs / tool output
66
+ * carry the helpful next steps so the user can react out-of-band.
67
+ *
68
+ * NOTE: openchrome runs as an MCP server over stdio with no human at the
69
+ * other end, so we cannot interactively prompt. The error message is the
70
+ * UX surface.
71
+ */
72
+ export declare class AttachConsentRequiredError extends Error {
73
+ readonly errorCode: "attach_consent_required";
74
+ readonly port: number;
75
+ readonly hint: string;
76
+ constructor(port: number);
77
+ }
78
+ //# sourceMappingURL=launch-mode-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-mode-resolver.d.ts","sourceRoot":"","sources":["../../src/chrome/launch-mode-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,UAAU,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACxC;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ;CAI5D;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,iBAAsB,EAC/B,GAAG,GAAE,aAAkB,EACvB,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAWZ;AAED;;;;;;;;GAQG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,SAAS,EAAG,yBAAyB,CAAU;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM;CAYzB"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /**
3
+ * Launch mode resolver (#659).
4
+ *
5
+ * Decides how openchrome should obtain a Chrome to drive when the user
6
+ * specifies a profile.
7
+ *
8
+ * Three modes:
9
+ *
10
+ * 'auto' — default; openchrome probes the configured remote-debugging
11
+ * port first and attaches if Chrome is already there;
12
+ * otherwise spawns its own Chrome. (Existing behavior — no
13
+ * change for users who don't set anything.)
14
+ *
15
+ * 'attach' — opt-in; openchrome MUST attach to an existing Chrome that
16
+ * the user pre-launched with `--remote-debugging-port`. If
17
+ * nothing is listening, the launcher returns a structured
18
+ * error (`AttachConsentRequiredError`) so the agent can
19
+ * surface a helpful next-step message instead of silently
20
+ * spawning a clean-room copy.
21
+ *
22
+ * 'isolated' — opt-in; openchrome ALWAYS spawns its own Chrome with the
23
+ * isolated `--user-data-dir` even if a Chrome is already
24
+ * listening on the debug port. Useful for clean-room
25
+ * scraping where you want a guaranteed fresh profile.
26
+ *
27
+ * Important policy decisions baked in here (see #659 PR description):
28
+ * 1. Default stays 'auto'. No behavior change for existing users.
29
+ * 2. We NEVER auto-restart the user's Chrome to enable a debug port.
30
+ * If the user wants attach mode, they must launch Chrome themselves
31
+ * with `--remote-debugging-port=NNNN`. The follow-up "automatic
32
+ * restart with consent" workflow is deferred to a separate issue.
33
+ * 3. When attach mode is on AND the port isn't listening, we surface a
34
+ * loud, structured error rather than silently falling back —
35
+ * otherwise the user would never realise their attach attempt
36
+ * didn't take.
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AttachConsentRequiredError = exports.InvalidLaunchModeError = void 0;
40
+ exports.resolveLaunchMode = resolveLaunchMode;
41
+ class InvalidLaunchModeError extends Error {
42
+ constructor(value, source) {
43
+ super(`Invalid launch mode "${value}" (from ${source}); expected 'auto' | 'attach' | 'isolated'.`);
44
+ this.name = 'InvalidLaunchModeError';
45
+ }
46
+ }
47
+ exports.InvalidLaunchModeError = InvalidLaunchModeError;
48
+ const VALID = new Set(['auto', 'attach', 'isolated']);
49
+ function parse(value, source) {
50
+ if (value === undefined)
51
+ return undefined;
52
+ const trimmed = value.trim();
53
+ if (trimmed === '')
54
+ return undefined;
55
+ const normalized = trimmed.toLowerCase();
56
+ if (!VALID.has(normalized)) {
57
+ throw new InvalidLaunchModeError(trimmed, source);
58
+ }
59
+ return normalized;
60
+ }
61
+ /**
62
+ * Resolves the launch mode from CLI options, env, and config.
63
+ * Precedence (highest first):
64
+ * 1. options.launchMode (per-call override)
65
+ * 2. OPENCHROME_LAUNCH_MODE env var
66
+ * 3. globalConfig.chromeLaunchMode
67
+ * 4. 'auto' (default)
68
+ *
69
+ * Throws `InvalidLaunchModeError` for unrecognised values rather than
70
+ * silently coercing — surfaces typos in env vars and config files.
71
+ */
72
+ function resolveLaunchMode(options = {}, env = {}, config = {}) {
73
+ const fromCli = parse(typeof options.launchMode === 'string' ? options.launchMode : undefined, 'cli');
74
+ if (fromCli)
75
+ return fromCli;
76
+ const fromEnv = parse(env.OPENCHROME_LAUNCH_MODE, 'env');
77
+ if (fromEnv)
78
+ return fromEnv;
79
+ const fromConfig = parse(typeof config.chromeLaunchMode === 'string' ? config.chromeLaunchMode : undefined, 'config');
80
+ if (fromConfig)
81
+ return fromConfig;
82
+ return 'auto';
83
+ }
84
+ /**
85
+ * Structured error: surface to the agent when attach is required but no
86
+ * Chrome is listening on the debug port. The agent's logs / tool output
87
+ * carry the helpful next steps so the user can react out-of-band.
88
+ *
89
+ * NOTE: openchrome runs as an MCP server over stdio with no human at the
90
+ * other end, so we cannot interactively prompt. The error message is the
91
+ * UX surface.
92
+ */
93
+ class AttachConsentRequiredError extends Error {
94
+ errorCode = 'attach_consent_required';
95
+ port;
96
+ hint;
97
+ constructor(port) {
98
+ const hint = `Set OPENCHROME_LAUNCH_MODE=auto (default) to spawn a fresh Chrome instead, ` +
99
+ `OR launch Chrome yourself with --remote-debugging-port=${port} so openchrome can attach to it. ` +
100
+ `openchrome will NOT close or restart your existing Chrome automatically.`;
101
+ super(`attach mode is enabled but no Chrome is listening on debug port ${port}. ${hint}`);
102
+ this.name = 'AttachConsentRequiredError';
103
+ this.port = port;
104
+ this.hint = hint;
105
+ }
106
+ }
107
+ exports.AttachConsentRequiredError = AttachConsentRequiredError;
108
+ //# sourceMappingURL=launch-mode-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-mode-resolver.js","sourceRoot":"","sources":["../../src/chrome/launch-mode-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAgDH,8CAeC;AA9CD,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,KAAa,EAAE,MAAgC;QACzD,KAAK,CAAC,wBAAwB,KAAK,WAAW,MAAM,6CAA6C,CAAC,CAAC;QACnG,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED,MAAM,KAAK,GAA4B,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAE/E,SAAS,KAAK,CAAC,KAAyB,EAAE,MAAgC;IACxE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAwB,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,UAAwB,CAAC;AAClC,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAC/B,UAA6B,EAAE,EAC/B,MAAqB,EAAE,EACvB,SAA2B,EAAE;IAE7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACtG,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACtH,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAa,0BAA2B,SAAQ,KAAK;IAC1C,SAAS,GAAG,yBAAkC,CAAC;IAC/C,IAAI,CAAS;IACb,IAAI,CAAS;IAEtB,YAAY,IAAY;QACtB,MAAM,IAAI,GACR,6EAA6E;YAC7E,0DAA0D,IAAI,mCAAmC;YACjG,0EAA0E,CAAC;QAC7E,KAAK,CACH,mEAAmE,IAAI,KAAK,IAAI,EAAE,CACnF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAjBD,gEAiBC"}
@@ -3,13 +3,34 @@
3
3
  */
4
4
  import { ChildProcess } from 'child_process';
5
5
  import type { ProfileType } from './profile-manager';
6
+ import { ExitClassification } from './exit-classifier';
6
7
  export type { ProfileType } from './profile-manager';
8
+ /**
9
+ * Lifecycle ownership of a Chrome process (#661).
10
+ * - 'isolated': openchrome spawned this Chrome and owns its lifecycle. Eligible for sync-kill on exit.
11
+ * - 'attach': we connected to a Chrome the user was already running. NEVER killed by openchrome.
12
+ *
13
+ * Distinct from `LaunchMode` (#659 — auto/attach/isolated launch *strategy*),
14
+ * exported below from launch-mode-resolver. To avoid the name shadow noted in
15
+ * gemini's review of #670, the runtime ownership tag is named `LifecycleMode`.
16
+ *
17
+ * Note: the field on `ChromeInstance` is still called `launchMode` for source
18
+ * compatibility with consumers like the watchdog and sync-shutdown that
19
+ * already reference it.
20
+ */
21
+ export type LifecycleMode = 'isolated' | 'attach';
22
+ /** @deprecated Use `LifecycleMode`. Retained for source compatibility. */
23
+ export type LaunchMode = LifecycleMode;
7
24
  export interface ChromeInstance {
8
25
  wsEndpoint: string;
9
26
  httpEndpoint: string;
10
27
  process?: ChildProcess;
11
28
  userDataDir?: string;
12
29
  profileType?: ProfileType;
30
+ /** Lifecycle ownership (#661). Defaults to 'isolated' for our spawn-based path. */
31
+ launchMode?: LifecycleMode;
32
+ /** Random per-launch UUID written into the ownership marker file. */
33
+ ownershipMarker?: string;
13
34
  }
14
35
  export interface LaunchOptions {
15
36
  port?: number;
@@ -26,6 +47,9 @@ export interface LaunchOptions {
26
47
  /** If true, restore Chrome's previous session tabs after crash (default: false).
27
48
  * Enable for long-running sessions where tab preservation matters. */
28
49
  restoreLastSession?: boolean;
50
+ /** #659 launch-mode override (per-call). One of: 'auto' | 'attach' | 'isolated'.
51
+ * Highest precedence; falls back to OPENCHROME_LAUNCH_MODE then config then 'auto'. */
52
+ launchMode?: 'auto' | 'attach' | 'isolated';
29
53
  }
30
54
  /**
31
55
  * Error thrown when the Chrome debug port fails to become available
@@ -75,7 +99,23 @@ export declare class ChromeLauncher {
75
99
  private currentProfileType;
76
100
  private profileState;
77
101
  private _intentionalStop;
102
+ /** ms timestamp of the most recent successful spawn, for #660 anti-flap. */
103
+ private _chromeStartedAt;
104
+ /** Most recent exit classification (#660). 'intentional' | 'clean' | 'crash'. */
105
+ private _lastExitClassification;
106
+ /** ms epoch until which the watchdog should skip relaunch (#660). 0 = no quiesce. */
107
+ private _quiesceUntil;
108
+ /** Crash timestamps for the watchdog rate-limit check (#660 Phase 3). */
109
+ private _recentCrashesMs;
78
110
  get intentionalStop(): boolean;
111
+ /** Last exit classification recorded by the spawn-side exit handler. */
112
+ get lastExitClassification(): ExitClassification | null;
113
+ /** Watchdog reads this; if `Date.now() < quiesceUntil` it skips relaunch. */
114
+ get quiesceUntil(): number;
115
+ /** Recent Chrome crash timestamps (last ~minute). */
116
+ get recentCrashesMs(): readonly number[];
117
+ /** Tools call this when they need Chrome — clears any pending quiesce. */
118
+ clearQuiesce(): void;
79
119
  constructor(port?: number);
80
120
  /**
81
121
  * Ensure Chrome with remote debugging is available
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/chrome/launcher.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAS,YAAY,EAA0B,MAAM,eAAe,CAAC;AAU5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0GAA0G;IAC1G,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4FAA4F;IAC5F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;2EACuE;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAoFD;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CA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