claude-chrome-parallel 2.1.0

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -0
  3. package/dist/cdp/client.d.ts +120 -0
  4. package/dist/cdp/client.d.ts.map +1 -0
  5. package/dist/cdp/client.js +345 -0
  6. package/dist/cdp/client.js.map +1 -0
  7. package/dist/chrome/launcher.d.ts +42 -0
  8. package/dist/chrome/launcher.d.ts.map +1 -0
  9. package/dist/chrome/launcher.js +256 -0
  10. package/dist/chrome/launcher.js.map +1 -0
  11. package/dist/cli/claude-session.d.ts +11 -0
  12. package/dist/cli/claude-session.js +349 -0
  13. package/dist/cli/claude-session.js.map +1 -0
  14. package/dist/cli/index.d.ts +14 -0
  15. package/dist/cli/index.js +562 -0
  16. package/dist/cli/index.js.map +1 -0
  17. package/dist/cli/install.d.ts +16 -0
  18. package/dist/cli/install.js +185 -0
  19. package/dist/cli/install.js.map +1 -0
  20. package/dist/cli/uninstall.d.ts +7 -0
  21. package/dist/cli/uninstall.js +126 -0
  22. package/dist/cli/uninstall.js.map +1 -0
  23. package/dist/config/config-recovery.d.ts +69 -0
  24. package/dist/config/config-recovery.d.ts.map +1 -0
  25. package/dist/config/config-recovery.js +302 -0
  26. package/dist/config/config-recovery.js.map +1 -0
  27. package/dist/config/index.d.ts +6 -0
  28. package/dist/config/index.d.ts.map +1 -0
  29. package/dist/config/index.js +22 -0
  30. package/dist/config/index.js.map +1 -0
  31. package/dist/config/session-isolator.d.ts +76 -0
  32. package/dist/config/session-isolator.d.ts.map +1 -0
  33. package/dist/config/session-isolator.js +268 -0
  34. package/dist/config/session-isolator.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +118 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/master/index.d.ts +18 -0
  40. package/dist/master/index.d.ts.map +1 -0
  41. package/dist/master/index.js +75 -0
  42. package/dist/master/index.js.map +1 -0
  43. package/dist/master/ipc-server.d.ts +21 -0
  44. package/dist/master/ipc-server.d.ts.map +1 -0
  45. package/dist/master/ipc-server.js +175 -0
  46. package/dist/master/ipc-server.js.map +1 -0
  47. package/dist/master/request-handler.d.ts +17 -0
  48. package/dist/master/request-handler.d.ts.map +1 -0
  49. package/dist/master/request-handler.js +134 -0
  50. package/dist/master/request-handler.js.map +1 -0
  51. package/dist/master/session-registry.d.ts +120 -0
  52. package/dist/master/session-registry.d.ts.map +1 -0
  53. package/dist/master/session-registry.js +247 -0
  54. package/dist/master/session-registry.js.map +1 -0
  55. package/dist/mcp-server.d.ts +69 -0
  56. package/dist/mcp-server.d.ts.map +1 -0
  57. package/dist/mcp-server.js +301 -0
  58. package/dist/mcp-server.js.map +1 -0
  59. package/dist/session-manager.d.ts +107 -0
  60. package/dist/session-manager.d.ts.map +1 -0
  61. package/dist/session-manager.js +322 -0
  62. package/dist/session-manager.js.map +1 -0
  63. package/dist/shared/ipc-constants.d.ts +16 -0
  64. package/dist/shared/ipc-constants.d.ts.map +1 -0
  65. package/dist/shared/ipc-constants.js +66 -0
  66. package/dist/shared/ipc-constants.js.map +1 -0
  67. package/dist/shared/ipc-protocol.d.ts +33 -0
  68. package/dist/shared/ipc-protocol.d.ts.map +1 -0
  69. package/dist/shared/ipc-protocol.js +20 -0
  70. package/dist/shared/ipc-protocol.js.map +1 -0
  71. package/dist/tools/computer.d.ts +6 -0
  72. package/dist/tools/computer.d.ts.map +1 -0
  73. package/dist/tools/computer.js +426 -0
  74. package/dist/tools/computer.js.map +1 -0
  75. package/dist/tools/find.d.ts +6 -0
  76. package/dist/tools/find.d.ts.map +1 -0
  77. package/dist/tools/find.js +242 -0
  78. package/dist/tools/find.js.map +1 -0
  79. package/dist/tools/form-input.d.ts +6 -0
  80. package/dist/tools/form-input.d.ts.map +1 -0
  81. package/dist/tools/form-input.js +181 -0
  82. package/dist/tools/form-input.js.map +1 -0
  83. package/dist/tools/index.d.ts +6 -0
  84. package/dist/tools/index.d.ts.map +1 -0
  85. package/dist/tools/index.js +26 -0
  86. package/dist/tools/index.js.map +1 -0
  87. package/dist/tools/javascript.d.ts +6 -0
  88. package/dist/tools/javascript.d.ts.map +1 -0
  89. package/dist/tools/javascript.js +134 -0
  90. package/dist/tools/javascript.js.map +1 -0
  91. package/dist/tools/navigate.d.ts +6 -0
  92. package/dist/tools/navigate.d.ts.map +1 -0
  93. package/dist/tools/navigate.js +155 -0
  94. package/dist/tools/navigate.js.map +1 -0
  95. package/dist/tools/read-page.d.ts +6 -0
  96. package/dist/tools/read-page.d.ts.map +1 -0
  97. package/dist/tools/read-page.js +182 -0
  98. package/dist/tools/read-page.js.map +1 -0
  99. package/dist/tools/tabs-context.d.ts +6 -0
  100. package/dist/tools/tabs-context.d.ts.map +1 -0
  101. package/dist/tools/tabs-context.js +73 -0
  102. package/dist/tools/tabs-context.js.map +1 -0
  103. package/dist/tools/tabs-create.d.ts +6 -0
  104. package/dist/tools/tabs-create.d.ts.map +1 -0
  105. package/dist/tools/tabs-create.js +49 -0
  106. package/dist/tools/tabs-create.js.map +1 -0
  107. package/dist/types/index.d.ts +3 -0
  108. package/dist/types/index.d.ts.map +1 -0
  109. package/dist/types/index.js +19 -0
  110. package/dist/types/index.js.map +1 -0
  111. package/dist/types/mcp.d.ts +54 -0
  112. package/dist/types/mcp.d.ts.map +1 -0
  113. package/dist/types/mcp.js +14 -0
  114. package/dist/types/mcp.js.map +1 -0
  115. package/dist/types/session.d.ts +28 -0
  116. package/dist/types/session.d.ts.map +1 -0
  117. package/dist/types/session.js +6 -0
  118. package/dist/types/session.js.map +1 -0
  119. package/dist/utils/atomic-file.d.ts +50 -0
  120. package/dist/utils/atomic-file.d.ts.map +1 -0
  121. package/dist/utils/atomic-file.js +217 -0
  122. package/dist/utils/atomic-file.js.map +1 -0
  123. package/dist/utils/index.d.ts +6 -0
  124. package/dist/utils/index.d.ts.map +1 -0
  125. package/dist/utils/index.js +22 -0
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/json-validator.d.ts +40 -0
  128. package/dist/utils/json-validator.d.ts.map +1 -0
  129. package/dist/utils/json-validator.js +295 -0
  130. package/dist/utils/json-validator.js.map +1 -0
  131. package/dist/utils/ref-id-manager.d.ts +26 -0
  132. package/dist/utils/ref-id-manager.d.ts.map +1 -0
  133. package/dist/utils/ref-id-manager.js +81 -0
  134. package/dist/utils/ref-id-manager.js.map +1 -0
  135. package/dist/utils/request-queue.d.ts +37 -0
  136. package/dist/utils/request-queue.d.ts.map +1 -0
  137. package/dist/utils/request-queue.js +110 -0
  138. package/dist/utils/request-queue.js.map +1 -0
  139. package/dist/worker/auto-master.d.ts +24 -0
  140. package/dist/worker/auto-master.d.ts.map +1 -0
  141. package/dist/worker/auto-master.js +135 -0
  142. package/dist/worker/auto-master.js.map +1 -0
  143. package/dist/worker/index.d.ts +25 -0
  144. package/dist/worker/index.d.ts.map +1 -0
  145. package/dist/worker/index.js +93 -0
  146. package/dist/worker/index.js.map +1 -0
  147. package/dist/worker/ipc-client.d.ts +26 -0
  148. package/dist/worker/ipc-client.d.ts.map +1 -0
  149. package/dist/worker/ipc-client.js +211 -0
  150. package/dist/worker/ipc-client.js.map +1 -0
  151. package/dist/worker/remote-session-manager.d.ts +114 -0
  152. package/dist/worker/remote-session-manager.d.ts.map +1 -0
  153. package/dist/worker/remote-session-manager.js +151 -0
  154. package/dist/worker/remote-session-manager.js.map +1 -0
  155. package/dist/worker/tools.d.ts +7 -0
  156. package/dist/worker/tools.d.ts.map +1 -0
  157. package/dist/worker/tools.js +340 -0
  158. package/dist/worker/tools.js.map +1 -0
  159. package/dist/worker/worker-mcp-server.d.ts +70 -0
  160. package/dist/worker/worker-mcp-server.d.ts.map +1 -0
  161. package/dist/worker/worker-mcp-server.js +295 -0
  162. package/dist/worker/worker-mcp-server.js.map +1 -0
  163. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,353 @@
1
+ # Claude Chrome Parallel
2
+
3
+ > **Run multiple Claude Code sessions safely - no more "Detached" errors or config corruption.**
4
+
5
+ [![npm version](https://badge.fury.io/js/claude-chrome-parallel.svg)](https://www.npmjs.com/package/claude-chrome-parallel)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - **Session Isolation**: Prevents `.claude.json` corruption when running multiple Claude instances
11
+ - **Browser Automation**: Independent CDP connections for parallel browser control
12
+ - **Auto Recovery**: Detects and recovers corrupted config files
13
+
14
+ ---
15
+
16
+ ## Problem 1: Config File Corruption
17
+
18
+ When running **multiple Claude Code instances** simultaneously, they compete to write to `~/.claude.json`, causing corruption:
19
+
20
+ ```
21
+ Terminal 1: claude ──┐
22
+ ├──► ~/.claude.json ← Race condition!
23
+ Terminal 2: claude ──┘
24
+
25
+ Result: {"key":"value"}{"key":"value"} ← Two JSON objects concatenated = CORRUPT
26
+ ```
27
+
28
+ **Symptoms:**
29
+ - Claude Code crashes on startup
30
+ - "Unexpected token" JSON parse errors
31
+ - Lost settings and preferences
32
+
33
+ ## Solution: Session Isolation
34
+
35
+ ```bash
36
+ # Instead of running claude directly...
37
+ claude-chrome-parallel launch
38
+
39
+ # Each session gets isolated config
40
+ Terminal 1: claude-chrome-parallel launch ──► ~/.claude-chrome-parallel/sessions/abc123/.claude.json
41
+ Terminal 2: claude-chrome-parallel launch ──► ~/.claude-chrome-parallel/sessions/def456/.claude.json
42
+ ```
43
+
44
+ **All your existing flags work:**
45
+
46
+ ```bash
47
+ claude-chrome-parallel launch --dangerously-skip-permissions
48
+ claude-chrome-parallel launch --resume abc123
49
+ claude-chrome-parallel launch -p "Fix the bug"
50
+ claude-chrome-parallel launch --model opus --resume
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Problem 2: Browser "Detached" Errors
56
+
57
+ When using browser automation with multiple sessions:
58
+
59
+ ```
60
+ Error: Detached while handling command
61
+ ```
62
+
63
+ The Chrome extension uses **shared internal state** - when Session A takes a screenshot, Session B's connection breaks.
64
+
65
+ ## Solution: Independent CDP Connections
66
+
67
+ ```
68
+ Claude Code 1 ──► puppeteer process 1 ──► CDP connection 1 ──┐
69
+ ├──► Chrome
70
+ Claude Code 2 ──► puppeteer process 2 ──► CDP connection 2 ──┘
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Installation
76
+
77
+ ### Prerequisites
78
+
79
+ - Node.js 18+
80
+ - Google Chrome (for browser automation)
81
+
82
+ ### Install
83
+
84
+ ```bash
85
+ # From npm
86
+ npm install -g claude-chrome-parallel
87
+
88
+ # Or from GitHub
89
+ npm install -g github:shaun0927/claude-chrome-parallel
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Usage
95
+
96
+ ### Session Isolation (Recommended for Multiple Instances)
97
+
98
+ ```bash
99
+ # Start Claude Code with isolated config
100
+ claude-chrome-parallel launch
101
+
102
+ # Pass any claude flags
103
+ claude-chrome-parallel launch --dangerously-skip-permissions
104
+ claude-chrome-parallel launch --resume <session-id>
105
+ claude-chrome-parallel launch -p "Your prompt here"
106
+
107
+ # Sync changes back to original config on exit
108
+ claude-chrome-parallel launch --sync-back
109
+
110
+ # Keep session directory for debugging
111
+ claude-chrome-parallel launch --keep-session
112
+ ```
113
+
114
+ ### Standalone Wrapper (Alternative)
115
+
116
+ ```bash
117
+ # Simpler command
118
+ claude-session
119
+
120
+ # With arguments
121
+ claude-session "Fix the authentication bug"
122
+ claude-session --list # List active sessions
123
+ claude-session --cleanup # Clean up stale sessions
124
+ claude-session --recover # Recover corrupted config
125
+ ```
126
+
127
+ ### Recovery Commands
128
+
129
+ ```bash
130
+ # Check config health
131
+ claude-chrome-parallel doctor
132
+
133
+ # Auto-recover corrupted .claude.json
134
+ claude-chrome-parallel recover
135
+
136
+ # List available backups
137
+ claude-chrome-parallel recover --list-backups
138
+
139
+ # Restore from specific backup
140
+ claude-chrome-parallel recover --backup ".claude.json.2024-01-15T10-30-00-000Z.bak"
141
+
142
+ # Force create new empty config
143
+ claude-chrome-parallel recover --force-new
144
+
145
+ # Clean up old sessions and backups
146
+ claude-chrome-parallel cleanup
147
+ claude-chrome-parallel cleanup --max-age 12 # Sessions older than 12 hours
148
+ claude-chrome-parallel cleanup --keep-backups 5 # Keep only 5 most recent backups
149
+ ```
150
+
151
+ ### Browser Automation (MCP Server)
152
+
153
+ Add to `~/.claude.json`:
154
+
155
+ ```json
156
+ {
157
+ "mcpServers": {
158
+ "chrome-parallel": {
159
+ "command": "claude-chrome-parallel",
160
+ "args": ["serve"]
161
+ }
162
+ }
163
+ }
164
+ ```
165
+
166
+ Then use in Claude Code:
167
+
168
+ ```
169
+ You: Take a screenshot of https://github.com
170
+
171
+ Claude: [Uses chrome-parallel tools automatically]
172
+ ```
173
+
174
+ **Run multiple sessions with browser automation:**
175
+
176
+ ```bash
177
+ # Terminal 1
178
+ claude-chrome-parallel launch
179
+ > Take a screenshot of github.com
180
+
181
+ # Terminal 2 (simultaneously!)
182
+ claude-chrome-parallel launch
183
+ > Take a screenshot of google.com
184
+ ```
185
+
186
+ Both work without conflicts!
187
+
188
+ ---
189
+
190
+ ## CLI Reference
191
+
192
+ | Command | Description |
193
+ |---------|-------------|
194
+ | `launch [args...]` | Start Claude with isolated config |
195
+ | `recover` | Recover corrupted .claude.json |
196
+ | `cleanup` | Clean up stale sessions and backups |
197
+ | `doctor` | Check installation and config health |
198
+ | `serve` | Start MCP server for browser automation |
199
+ | `install` | Install browser extension and native host |
200
+ | `uninstall` | Remove extension and native host |
201
+
202
+ ### Launch Options
203
+
204
+ | Option | Description |
205
+ |--------|-------------|
206
+ | `--sync-back` | Sync config changes back to original on exit |
207
+ | `--keep-session` | Keep session directory after exit (debugging) |
208
+
209
+ ### Recover Options
210
+
211
+ | Option | Description |
212
+ |--------|-------------|
213
+ | `--list-backups` | List available backup files |
214
+ | `--backup <name>` | Restore from specific backup |
215
+ | `--force-new` | Create new empty config (loses all data) |
216
+
217
+ ### Cleanup Options
218
+
219
+ | Option | Description |
220
+ |--------|-------------|
221
+ | `--max-age <hours>` | Max session age in hours (default: 24) |
222
+ | `--keep-backups <n>` | Number of backups to keep (default: 10) |
223
+
224
+ ---
225
+
226
+ ## Browser Automation Tools
227
+
228
+ | Tool | Description |
229
+ |------|-------------|
230
+ | `navigate` | Navigate to URL or use history |
231
+ | `tabs_context_mcp` | Get available tabs |
232
+ | `tabs_create_mcp` | Create new tab |
233
+ | `computer` | Screenshots, mouse/keyboard, scrolling |
234
+ | `read_page` | Read accessibility tree |
235
+ | `find` | Find elements by description |
236
+ | `form_input` | Fill form fields |
237
+ | `javascript_tool` | Execute JavaScript |
238
+
239
+ ---
240
+
241
+ ## How It Works
242
+
243
+ ### Session Isolation
244
+
245
+ ```
246
+ Before (Dangerous):
247
+ ┌─────────────────────────────────────────────┐
248
+ │ Terminal 1: claude ──┐ │
249
+ │ ├─► ~/.claude.json │ ← Race condition!
250
+ │ Terminal 2: claude ──┘ │
251
+ └─────────────────────────────────────────────┘
252
+
253
+ After (Safe):
254
+ ┌─────────────────────────────────────────────┐
255
+ │ Terminal 1: launch ─► sessions/abc/.claude.json │
256
+ │ │ ← No conflict!
257
+ │ Terminal 2: launch ─► sessions/def/.claude.json │
258
+ └─────────────────────────────────────────────┘
259
+ ```
260
+
261
+ The `launch` command:
262
+ 1. Creates a unique session directory
263
+ 2. Copies existing `.claude.json` (if valid)
264
+ 3. Sets `HOME` environment variable to session directory
265
+ 4. Runs `claude` with all your arguments
266
+ 5. Cleans up session on exit
267
+
268
+ ### Browser Automation
269
+
270
+ Chrome's DevTools Protocol natively supports multiple connections:
271
+
272
+ ```
273
+ Process 1 ─► CDP Connection 1 ─┐
274
+ ├─► Chrome (port 9222)
275
+ Process 2 ─► CDP Connection 2 ─┘
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Troubleshooting
281
+
282
+ ### Config Corruption
283
+
284
+ ```bash
285
+ # Check health
286
+ claude-chrome-parallel doctor
287
+
288
+ # If corrupted, recover
289
+ claude-chrome-parallel recover
290
+ ```
291
+
292
+ ### Chrome Not Connecting
293
+
294
+ ```bash
295
+ # Check status
296
+ claude-chrome-parallel check
297
+
298
+ # Manually start Chrome with debugging
299
+ chrome --remote-debugging-port=9222
300
+ ```
301
+
302
+ ### Tools Not Appearing
303
+
304
+ 1. Check MCP config in `~/.claude.json`
305
+ 2. Restart Claude Code
306
+ 3. Run `/mcp` to verify `chrome-parallel` is listed
307
+
308
+ ---
309
+
310
+ ## Development
311
+
312
+ ```bash
313
+ git clone https://github.com/shaun0927/claude-chrome-parallel.git
314
+ cd claude-chrome-parallel
315
+
316
+ npm install
317
+ npm run build
318
+
319
+ # Test locally
320
+ npm install -g .
321
+ ```
322
+
323
+ ---
324
+
325
+ ## Comparison
326
+
327
+ | Feature | Plain `claude` | `claude-chrome-parallel launch` |
328
+ |---------|----------------|--------------------------------|
329
+ | Multiple instances | Config corruption risk | Safe (isolated) |
330
+ | Browser automation | Detached errors | Works perfectly |
331
+ | Auto backup | | Config backed up |
332
+ | Recovery tools | | Built-in |
333
+
334
+ ---
335
+
336
+ ## License
337
+
338
+ MIT License - see [LICENSE](LICENSE) for details.
339
+
340
+ ## Disclaimer
341
+
342
+ > **This is an unofficial, community-maintained project.**
343
+ > Not affiliated with or endorsed by Anthropic.
344
+ >
345
+ > "Claude" is a trademark of Anthropic. This project provides
346
+ > tooling to enhance the Claude Code experience but is not
347
+ > an official Anthropic product.
348
+
349
+ ## Acknowledgments
350
+
351
+ - [Anthropic](https://anthropic.com) for Claude and the MCP protocol
352
+ - [Claude Code](https://github.com/anthropics/claude-code) for the CLI
353
+ - [Puppeteer](https://pptr.dev/) for browser automation
@@ -0,0 +1,120 @@
1
+ /**
2
+ * CDP Client - Wrapper around puppeteer-core for Chrome DevTools Protocol
3
+ */
4
+ import { Browser, Page, Target, CDPSession } from 'puppeteer-core';
5
+ export interface CDPClientOptions {
6
+ port?: number;
7
+ maxReconnectAttempts?: number;
8
+ reconnectDelayMs?: number;
9
+ heartbeatIntervalMs?: number;
10
+ }
11
+ export type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
12
+ export interface ConnectionEvent {
13
+ type: 'connected' | 'disconnected' | 'reconnecting' | 'reconnect_failed';
14
+ timestamp: number;
15
+ attempt?: number;
16
+ error?: string;
17
+ }
18
+ export declare class CDPClient {
19
+ private browser;
20
+ private sessions;
21
+ private port;
22
+ private maxReconnectAttempts;
23
+ private reconnectDelayMs;
24
+ private heartbeatIntervalMs;
25
+ private heartbeatTimer;
26
+ private connectionState;
27
+ private eventListeners;
28
+ private reconnectAttempts;
29
+ constructor(options?: CDPClientOptions);
30
+ /**
31
+ * Get current connection state
32
+ */
33
+ getConnectionState(): ConnectionState;
34
+ /**
35
+ * Add connection event listener
36
+ */
37
+ addConnectionListener(listener: (event: ConnectionEvent) => void): void;
38
+ /**
39
+ * Remove connection event listener
40
+ */
41
+ removeConnectionListener(listener: (event: ConnectionEvent) => void): void;
42
+ /**
43
+ * Emit connection event
44
+ */
45
+ private emitConnectionEvent;
46
+ /**
47
+ * Start heartbeat monitoring
48
+ */
49
+ private startHeartbeat;
50
+ /**
51
+ * Stop heartbeat monitoring
52
+ */
53
+ private stopHeartbeat;
54
+ /**
55
+ * Check connection health
56
+ */
57
+ private checkConnection;
58
+ /**
59
+ * Handle disconnection with automatic reconnection
60
+ */
61
+ private handleDisconnect;
62
+ /**
63
+ * Internal connect logic
64
+ */
65
+ private connectInternal;
66
+ /**
67
+ * Connect to Chrome instance
68
+ */
69
+ connect(): Promise<void>;
70
+ /**
71
+ * Force reconnect by disconnecting and reconnecting
72
+ */
73
+ forceReconnect(): Promise<void>;
74
+ /**
75
+ * Disconnect from Chrome
76
+ */
77
+ disconnect(): Promise<void>;
78
+ /**
79
+ * Get browser instance
80
+ */
81
+ getBrowser(): Browser;
82
+ /**
83
+ * Create a new page
84
+ */
85
+ createPage(url?: string): Promise<Page>;
86
+ /**
87
+ * Get all page targets
88
+ */
89
+ getPages(): Promise<Page[]>;
90
+ /**
91
+ * Get page by target ID
92
+ */
93
+ getPageByTargetId(targetId: string): Promise<Page | null>;
94
+ /**
95
+ * Get CDP session for a page
96
+ */
97
+ getCDPSession(page: Page): Promise<CDPSession>;
98
+ /**
99
+ * Execute CDP command on a page
100
+ */
101
+ send<T = unknown>(page: Page, method: string, params?: Record<string, unknown>): Promise<T>;
102
+ /**
103
+ * Get all targets
104
+ */
105
+ getTargets(): Target[];
106
+ /**
107
+ * Find target by ID
108
+ */
109
+ findTarget(targetId: string): Target | undefined;
110
+ /**
111
+ * Close a page by target ID
112
+ */
113
+ closePage(targetId: string): Promise<void>;
114
+ /**
115
+ * Check if connected
116
+ */
117
+ isConnected(): boolean;
118
+ }
119
+ export declare function getCDPClient(options?: CDPClientOptions): CDPClient;
120
+ //# sourceMappingURL=client.d.ts.map
@@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