react-native-ai-debugger 1.1.6 → 1.4.21

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 (144) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +371 -42
  3. package/build/__tests__/helpers/tap-test-helpers.d.ts +36 -0
  4. package/build/__tests__/helpers/tap-test-helpers.d.ts.map +1 -0
  5. package/build/__tests__/helpers/tap-test-helpers.js +130 -0
  6. package/build/__tests__/helpers/tap-test-helpers.js.map +1 -0
  7. package/build/__tests__/integration/connection-health.test.js +12 -6
  8. package/build/__tests__/integration/connection-health.test.js.map +1 -1
  9. package/build/__tests__/integration/execute-in-app.test.js +2 -1
  10. package/build/__tests__/integration/execute-in-app.test.js.map +1 -1
  11. package/build/__tests__/integration/tap-strategies.test.d.ts +2 -0
  12. package/build/__tests__/integration/tap-strategies.test.d.ts.map +1 -0
  13. package/build/__tests__/integration/tap-strategies.test.js +329 -0
  14. package/build/__tests__/integration/tap-strategies.test.js.map +1 -0
  15. package/build/__tests__/integration/tools.test.js +9 -10
  16. package/build/__tests__/integration/tools.test.js.map +1 -1
  17. package/build/__tests__/unit/burst.test.d.ts +2 -0
  18. package/build/__tests__/unit/burst.test.d.ts.map +1 -0
  19. package/build/__tests__/unit/burst.test.js +50 -0
  20. package/build/__tests__/unit/burst.test.js.map +1 -0
  21. package/build/__tests__/unit/connection-health.test.js +26 -16
  22. package/build/__tests__/unit/connection-health.test.js.map +1 -1
  23. package/build/__tests__/unit/fingerprint.test.d.ts +2 -0
  24. package/build/__tests__/unit/fingerprint.test.d.ts.map +1 -0
  25. package/build/__tests__/unit/fingerprint.test.js +89 -0
  26. package/build/__tests__/unit/fingerprint.test.js.map +1 -0
  27. package/build/__tests__/unit/imageBuffer.test.d.ts +2 -0
  28. package/build/__tests__/unit/imageBuffer.test.d.ts.map +1 -0
  29. package/build/__tests__/unit/imageBuffer.test.js +128 -0
  30. package/build/__tests__/unit/imageBuffer.test.js.map +1 -0
  31. package/build/__tests__/unit/logs.test.js +9 -0
  32. package/build/__tests__/unit/logs.test.js.map +1 -1
  33. package/build/__tests__/unit/networkInterceptor.test.d.ts +2 -0
  34. package/build/__tests__/unit/networkInterceptor.test.d.ts.map +1 -0
  35. package/build/__tests__/unit/networkInterceptor.test.js +104 -0
  36. package/build/__tests__/unit/networkInterceptor.test.js.map +1 -0
  37. package/build/__tests__/unit/screenshot-diff.test.d.ts +2 -0
  38. package/build/__tests__/unit/screenshot-diff.test.d.ts.map +1 -0
  39. package/build/__tests__/unit/screenshot-diff.test.js +97 -0
  40. package/build/__tests__/unit/screenshot-diff.test.js.map +1 -0
  41. package/build/__tests__/unit/tap.test.js +430 -25
  42. package/build/__tests__/unit/tap.test.js.map +1 -1
  43. package/build/core/android.d.ts.map +1 -1
  44. package/build/core/android.js +64 -29
  45. package/build/core/android.js.map +1 -1
  46. package/build/core/appDetection.d.ts +8 -0
  47. package/build/core/appDetection.d.ts.map +1 -0
  48. package/build/core/appDetection.js +91 -0
  49. package/build/core/appDetection.js.map +1 -0
  50. package/build/core/bundle.d.ts.map +1 -1
  51. package/build/core/bundle.js +15 -23
  52. package/build/core/bundle.js.map +1 -1
  53. package/build/core/config.d.ts +8 -0
  54. package/build/core/config.d.ts.map +1 -0
  55. package/build/core/config.js +27 -0
  56. package/build/core/config.js.map +1 -0
  57. package/build/core/connection.d.ts +47 -3
  58. package/build/core/connection.d.ts.map +1 -1
  59. package/build/core/connection.js +519 -124
  60. package/build/core/connection.js.map +1 -1
  61. package/build/core/executor.d.ts +57 -14
  62. package/build/core/executor.d.ts.map +1 -1
  63. package/build/core/executor.js +936 -208
  64. package/build/core/executor.js.map +1 -1
  65. package/build/core/fingerprint.d.ts +4 -0
  66. package/build/core/fingerprint.d.ts.map +1 -0
  67. package/build/core/fingerprint.js +47 -0
  68. package/build/core/fingerprint.js.map +1 -0
  69. package/build/core/guides.d.ts.map +1 -1
  70. package/build/core/guides.js +27 -3
  71. package/build/core/guides.js.map +1 -1
  72. package/build/core/httpServer.js.map +1 -1
  73. package/build/core/imageBuffer.d.ts +37 -0
  74. package/build/core/imageBuffer.d.ts.map +1 -0
  75. package/build/core/imageBuffer.js +58 -0
  76. package/build/core/imageBuffer.js.map +1 -0
  77. package/build/core/index.d.ts +21 -17
  78. package/build/core/index.d.ts.map +1 -1
  79. package/build/core/index.js +21 -19
  80. package/build/core/index.js.map +1 -1
  81. package/build/core/ios.d.ts +36 -7
  82. package/build/core/ios.d.ts.map +1 -1
  83. package/build/core/ios.js +553 -323
  84. package/build/core/ios.js.map +1 -1
  85. package/build/core/license.d.ts +38 -0
  86. package/build/core/license.d.ts.map +1 -0
  87. package/build/core/license.js +265 -0
  88. package/build/core/license.js.map +1 -0
  89. package/build/core/logbox.d.ts +51 -0
  90. package/build/core/logbox.d.ts.map +1 -0
  91. package/build/core/logbox.js +258 -0
  92. package/build/core/logbox.js.map +1 -0
  93. package/build/core/logs.d.ts +1 -0
  94. package/build/core/logs.d.ts.map +1 -1
  95. package/build/core/logs.js +5 -0
  96. package/build/core/logs.js.map +1 -1
  97. package/build/core/metro.d.ts +8 -0
  98. package/build/core/metro.d.ts.map +1 -1
  99. package/build/core/metro.js +28 -0
  100. package/build/core/metro.js.map +1 -1
  101. package/build/core/networkInterceptor.d.ts +29 -2
  102. package/build/core/networkInterceptor.d.ts.map +1 -1
  103. package/build/core/networkInterceptor.js +195 -191
  104. package/build/core/networkInterceptor.js.map +1 -1
  105. package/build/core/ocr.d.ts +8 -3
  106. package/build/core/ocr.d.ts.map +1 -1
  107. package/build/core/ocr.js +116 -15
  108. package/build/core/ocr.js.map +1 -1
  109. package/build/core/posthog.d.ts +5 -0
  110. package/build/core/posthog.d.ts.map +1 -0
  111. package/build/core/posthog.js +46 -0
  112. package/build/core/posthog.js.map +1 -0
  113. package/build/core/sdkBridge.d.ts +67 -0
  114. package/build/core/sdkBridge.d.ts.map +1 -0
  115. package/build/core/sdkBridge.js +148 -0
  116. package/build/core/sdkBridge.js.map +1 -0
  117. package/build/core/state.d.ts +25 -5
  118. package/build/core/state.d.ts.map +1 -1
  119. package/build/core/state.js +79 -10
  120. package/build/core/state.js.map +1 -1
  121. package/build/core/telemetry.d.ts +19 -1
  122. package/build/core/telemetry.d.ts.map +1 -1
  123. package/build/core/telemetry.js +163 -8
  124. package/build/core/telemetry.js.map +1 -1
  125. package/build/core/types.d.ts +11 -0
  126. package/build/core/types.d.ts.map +1 -1
  127. package/build/index.js +1302 -302
  128. package/build/index.js.map +1 -1
  129. package/build/pro/screenshot-diff.d.ts +10 -0
  130. package/build/pro/screenshot-diff.d.ts.map +1 -0
  131. package/build/pro/screenshot-diff.js +38 -0
  132. package/build/pro/screenshot-diff.js.map +1 -0
  133. package/build/pro/tap.d.ts +71 -2
  134. package/build/pro/tap.d.ts.map +1 -1
  135. package/build/pro/tap.js +797 -124
  136. package/build/pro/tap.js.map +1 -1
  137. package/build/tools/accountTools.d.ts +44 -0
  138. package/build/tools/accountTools.d.ts.map +1 -0
  139. package/build/tools/accountTools.js +217 -0
  140. package/build/tools/accountTools.js.map +1 -0
  141. package/package.json +9 -7
  142. package/build/core/httpServer.js +0 -2459
  143. package/build/core/httpServerProcess.js +0 -153
  144. package/build/httpServerStandalone.js +0 -31
package/LICENSE CHANGED
@@ -4,7 +4,7 @@ The code in this repository is dual-licensed:
4
4
  the MIT License (see below).
5
5
 
6
6
  2. Code in the src/pro/ directory is licensed under the
7
- react-native-ai-debugger Commercial License. A valid license key is
7
+ react-native-ai-devtools Commercial License. A valid license key is
8
8
  required for use. See src/pro/LICENSE for terms.
9
9
 
10
10
  ---
package/README.md CHANGED
@@ -1,54 +1,383 @@
1
- # ⚠️ react-native-ai-debugger has been renamed!
1
+ # React Native AI DevTools
2
2
 
3
- > **CRITICAL NOTICE:** This package has been renamed to `react-native-ai-devtools`.
3
+ An MCP server that gives AI assistants real-time access to a running React Native app. It bridges the gap between static code and live runtime, turning AI assistants from guessing machines into informed development partners.
4
4
 
5
- **This repository and NPM package will no longer receive updates.**
5
+ **Positioning:** This is not a debugger. This is not a QA tool. This is a Runtime AI Bridge — the missing layer between AI coding assistants and live mobile applications. Without it, your AI assistant is blind. With it, the AI sees everything happening in your app in real time.
6
6
 
7
- Please migrate to the new package and repository immediately.
7
+ ## Feedback & Feature Requests
8
8
 
9
- * **New NPM Package:** [react-native-ai-devtools](https://www.npmjs.com/package/react-native-ai-devtools)
10
- * **GitHub Repository:** [https://github.com/igorzheludkov/react-native-ai-devtools](https://github.com/igorzheludkov/react-native-ai-devtools)
9
+ Have an idea or found something that could be better? Head over to [GitHub Discussions](https://github.com/igorzheludkov/react-native-ai-devtools/discussions) to share feedback, request features, and vote on what gets built next.
11
10
 
12
- ## Migration Guide for Claude Code / Cursor
11
+ ## Features
13
12
 
14
- You must update your local MCP configuration files to use the new package name.
13
+ ### Runtime Interaction
15
14
 
16
- ### Claude Code
15
+ - **Console Log Capture** - Capture `console.log`, `warn`, `error`, `info`, `debug` with filtering and search
16
+ - **Network Request Tracking** - Monitor HTTP requests/responses with headers, timing, and body content. Install the optional [SDK](https://www.npmjs.com/package/react-native-ai-devtools-sdk) for full capture from app startup including request/response bodies
17
+ - **JavaScript Execution** - Run code directly in your app (REPL-style) and inspect results
18
+ - **Global State Debugging** - Discover and inspect Apollo Client, Redux stores, Expo Router, and custom globals
19
+ - **Bundle Error Detection** - Get Metro bundler errors and compilation issues with file locations
20
+
21
+ ### Device Control
22
+
23
+ - **iOS Simulator** - Screenshots, app management, URL handling, boot/terminate (via simctl)
24
+ - **Android Devices** - Screenshots, app install/launch, package management (via ADB)
25
+ - **Unified Tap** - Single `tap` tool with automatic fallback chain: fiber tree → accessibility → OCR → coordinates. Auto-detects platform, accepts pixels from screenshots. Returns post-tap screenshot and verifies visual change by default
26
+ - **UI Automation** - Swipe, long press, text input, and key events on both platforms
27
+ - **Accessibility Inspection** - Query UI hierarchy to find elements by text, label, or resource ID
28
+ - **OCR Text Extraction** - Extract visible text with tap-ready coordinates via Google Cloud Vision (works on any screen content)
29
+
30
+ ### Multi-Device Debugging
31
+
32
+ - **Connect All Devices** - `scan_metro` automatically discovers and connects to all Bridgeless targets on each Metro port
33
+ - **Device Targeting** - Every tool accepts an optional `device` parameter for targeting specific devices by name (case-insensitive substring match)
34
+ - **Per-Device Buffers** - Logs and network requests are captured separately per device for clean debugging
35
+ - **Cross-Platform Comparison** - Debug iOS and Android side-by-side, comparing logs, network traffic, and component trees
36
+
37
+ ### Under the Hood
38
+
39
+ - **Auto-Discovery** - Scans Metro on ports 8081, 8082, 19000-19002 automatically
40
+ - **Multi-Device Support** - Connects to all Bridgeless targets simultaneously, with per-device log and network buffers
41
+ - **Auto-Reconnection** - Exponential backoff (up to 8 attempts) when connection drops
42
+ - **Efficient Buffering** - Circular buffers: 500 logs, 200 network requests
43
+ - **Platform Support** - Expo SDK 54+ (Bridgeless) and React Native 0.70+ (Hermes)
44
+
45
+ ## Platform Setup
46
+
47
+ ### Android
48
+
49
+ Android works out of the box — all device control tools use ADB, which ships with Android Studio. Verify it's available:
50
+
51
+ ```bash
52
+ adb devices
53
+ ```
54
+
55
+ ### iOS Simulator — UI Automation Setup
56
+
57
+ iOS UI automation tools (tap, swipe, text input, accessibility queries) require a UI driver. Install one of the following:
58
+
59
+ **Option A: AXe CLI (experimental)**
60
+
61
+ [AXe](https://github.com/cameroncooke/AXe) is a standalone CLI for iOS simulator automation. No daemon required — single binary, simple setup.
62
+
63
+ ```bash
64
+ brew install cameroncooke/axe/axe
65
+ ```
66
+
67
+ Verify: `axe --version`
68
+
69
+ Add `env` to your MCP server configuration:
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "rn-debugger": {
75
+ "type": "stdio",
76
+ "command": "npx",
77
+ "args": ["react-native-ai-devtools"],
78
+ "env": { "IOS_DRIVER": "axe" }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ > **Note:** AXe text input only supports US keyboard layout characters.
85
+
86
+ **Option B: IDB**
87
+
88
+ [IDB (iOS Development Bridge)](https://github.com/facebook/idb) is a tool built by Meta for automating iOS Simulators. Requires a background daemon.
89
+
90
+ ```bash
91
+ brew install idb-companion
92
+ ```
93
+
94
+ Verify: `idb_companion --list 1`
95
+
96
+ IDB is the default driver — no `IOS_DRIVER` env var needed.
97
+
98
+ **What works without a UI driver:**
99
+
100
+ | Capability | Without IDB/AXe | With IDB/AXe |
101
+ | --------------------------------- | --------------- | ------------ |
102
+ | Screenshots | Yes (simctl) | Yes |
103
+ | App install/launch/terminate | Yes (simctl) | Yes |
104
+ | URL opening | Yes (simctl) | Yes |
105
+ | Boot simulator | Yes (simctl) | Yes |
106
+ | **Tap / swipe / gestures** | **No** | Yes |
107
+ | **Text input** | **No** | Yes |
108
+ | **Accessibility tree queries** | **No** | Yes |
109
+ | **Element finding / waiting** | **No** | Yes |
110
+ | **Hardware buttons (Home, Lock)** | **No** | Yes |
111
+
112
+ > **Troubleshooting**: If you see errors like `"IDB is not installed"` or `"AXe is not installed"` in tap results, install the appropriate driver with the commands above and retry.
113
+
114
+ ## Requirements
115
+
116
+ - Node.js 18+
117
+ - React Native app running with Metro bundler
118
+ - **iOS UI automation**: [Facebook IDB](https://fbidb.io/) (`brew install idb-companion`) or [AXe CLI](https://github.com/cameroncooke/AXe) (`brew install cameroncooke/axe/axe`) — required for tap, swipe, text input, accessibility on iOS Simulator
119
+ - **Optional for offline OCR fallback**: Python 3.6+ (only needed when cloud OCR is unavailable, see [OCR Setup](#ocr-text-extraction))
120
+
121
+ ## Claude Code Setup
122
+
123
+ No installation required - Claude Code uses `npx` to run the latest version automatically.
124
+
125
+ ### Global (all projects)
17
126
 
18
- If you installed globally:
19
127
  ```bash
20
- claude mcp remove rn-debugger
21
128
  claude mcp add rn-debugger --scope user -- npx react-native-ai-devtools
22
129
  ```
23
130
 
24
- If you installed per-project, edit your project's `.mcp.json` file:
25
- ```diff
26
- {
27
- "mcpServers": {
28
- "rn-debugger": {
29
- "type": "stdio",
30
- "command": "npx",
31
- - "args": ["react-native-ai-debugger"]
32
- + "args": ["react-native-ai-devtools"]
33
- }
34
- }
35
- }
36
- ```
37
-
38
- ### Cursor
39
-
40
- Edit your global `~/.cursor/mcp.json` or project-level `.cursor/mcp.json` file:
41
- ```diff
42
- {
43
- "mcpServers": {
44
- "rn-debugger": {
45
- "command": "npx",
46
- - "args": ["-y", "react-native-ai-debugger"]
47
- + "args": ["-y", "react-native-ai-devtools"]
48
- }
49
- }
50
- }
51
- ```
52
-
53
- ---
54
- *Created by Ihor Zheludkov*
131
+ ### Project-specific
132
+
133
+ ```bash
134
+ claude mcp add rn-debugger --scope project -- npx react-native-ai-devtools
135
+ ```
136
+
137
+ ### Manual Configuration
138
+
139
+ Add to `~/.claude.json` (user scope) or `.mcp.json` (project scope):
140
+
141
+ ```json
142
+ {
143
+ "mcpServers": {
144
+ "rn-debugger": {
145
+ "type": "stdio",
146
+ "command": "npx",
147
+ "args": ["react-native-ai-devtools"]
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ Restart Claude Code after adding the configuration.
154
+
155
+ ## VS Code Copilot Setup
156
+
157
+ Requires VS Code 1.102+ with Copilot ([docs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)).
158
+
159
+ **Via Command Palette**: `Cmd+Shift+P` → "MCP: Add Server"
160
+
161
+ **Manual config** - add to `.vscode/mcp.json`:
162
+
163
+ ```json
164
+ {
165
+ "servers": {
166
+ "rn-debugger": {
167
+ "type": "stdio",
168
+ "command": "npx",
169
+ "args": ["-y", "react-native-ai-devtools"]
170
+ }
171
+ }
172
+ }
173
+ ```
174
+
175
+ ## Cursor Setup
176
+
177
+ [Docs](https://docs.cursor.com/context/model-context-protocol)
178
+
179
+ **Via Command Palette**: `Cmd+Shift+P` → "View: Open MCP Settings"
180
+
181
+ **Manual config** - add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
182
+
183
+ ```json
184
+ {
185
+ "mcpServers": {
186
+ "rn-debugger": {
187
+ "command": "npx",
188
+ "args": ["-y", "react-native-ai-devtools"]
189
+ }
190
+ }
191
+ }
192
+ ```
193
+
194
+ ## Claude Code Skills
195
+
196
+ Pre-built skills for common debugging workflows — session setup, log inspection, network debugging, and more. See the [skills guide](docs/skills.md) for the full list and installation instructions.
197
+
198
+ ## Available Tools
199
+
200
+ See the [full tool reference](docs/tools.md) for all tools with descriptions. Key tools:
201
+
202
+ | Tool | Description |
203
+ | --------------------------------------- | ---------------------------------------------------------------------------------------- |
204
+ | `scan_metro` | **Start here** — scan for Metro servers and auto-connect |
205
+ | `get_logs` / `search_logs` | Capture and search console logs with filtering and summaries |
206
+ | `get_network_requests` | Monitor HTTP requests with method/status filtering |
207
+ | `get_screen_layout` | Screen map of visible components with positions, sizes, and text content |
208
+ | `tap` | **Unified tap** — auto-detects platform, tries fiber → accessibility → OCR → coordinates |
209
+ | `execute_in_app` | Run JS expressions in the app runtime (REPL-style) |
210
+ | `ios_screenshot` / `android_screenshot` | Take device screenshots |
211
+
212
+ ## Usage
213
+
214
+ 1. Start your React Native app:
215
+
216
+ ```bash
217
+ npm start
218
+ # or
219
+ expo start
220
+ ```
221
+
222
+ 2. In Claude Code, scan for Metro:
223
+
224
+ ```
225
+ Use scan_metro to find and connect to Metro
226
+ ```
227
+
228
+ 3. Get logs:
229
+ ```
230
+ Use get_logs to see recent console output
231
+ ```
232
+
233
+ ## Detailed Guides
234
+
235
+ | Guide | Description |
236
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
237
+ | [Console Logging](docs/logging.md) | `get_logs` parameters, filtering, summary mode, TONL format, token optimization |
238
+ | [Network Tracking](docs/network.md) | SDK setup for full capture, filtering, request details, statistics |
239
+ | [App Inspection](docs/app-inspection.md) | Debug globals (Apollo, Redux, Expo Router), `execute_in_app`, limitations |
240
+ | [Layout & Component Inspection](docs/layout-inspection.md) | `get_screen_layout`, component tree, `inspect_at_point`, `find_components` |
241
+ | [Device Interaction](docs/device-interaction.md) | Unified `tap`, platform-specific gestures, text input, key events |
242
+ | [OCR Text Extraction](docs/ocr.md) | Cloud Vision OCR, offline fallback, language config, workflows |
243
+ | [Claude Code Skills](docs/skills.md) | Pre-built skills for session setup, debugging, and automation |
244
+ | [Full Tool Reference](docs/tools.md) | Complete list of all 40+ tools with descriptions |
245
+
246
+ ## Supported React Native Versions
247
+
248
+ | Version | Architecture | Engine | Status |
249
+ | -------------- | --------------------- | ------------ | ------------------------------------------------ |
250
+ | Expo SDK 54+ | Bridgeless (New Arch) | Hermes | ✓ Fully supported |
251
+ | RN 0.76+ | Bridgeless (New Arch) | Hermes | ✓ Fully supported |
252
+ | RN 0.73 - 0.75 | Bridge (Old Arch) | Hermes | ✓ Fully supported (best network capture via CDP) |
253
+ | RN 0.70 - 0.72 | Bridge (Old Arch) | Hermes / JSC | ✓ Supported |
254
+ | RN < 0.70 | Bridge | JSC | Not tested |
255
+
256
+ ## How It Works
257
+
258
+ 1. Fetches device list from Metro's `/json` endpoint
259
+ 2. Connects to the main JS runtime via CDP (Chrome DevTools Protocol) WebSocket
260
+ 3. Enables `Runtime.enable` to receive `Runtime.consoleAPICalled` events
261
+ 4. Network capture via two paths:
262
+ - **With SDK**: Reads from the SDK's in-app buffer via `Runtime.evaluate` — captures all requests from startup with full headers and bodies
263
+ - **Without SDK**: Enables CDP `Network.enable` (on supported targets) or injects a JS fetch interceptor as fallback
264
+ 5. Stores logs and network requests in circular buffers for retrieval
265
+
266
+ ## Connection Management
267
+
268
+ ### Explicit Connection
269
+
270
+ The server does **not** auto-connect on startup. Call `scan_metro` to discover and connect to Metro servers. This prevents multiple MCP server instances (from parallel agent sessions) from competing for the single CDP WebSocket slot, which would cause connection thrashing and dropped tools.
271
+
272
+ ### Graceful Shutdown
273
+
274
+ When the MCP server process is terminated (`SIGINT`/`SIGTERM`), it closes all CDP WebSocket connections and cancels reconnection timers, freeing the CDP slot immediately for other sessions.
275
+
276
+ ### Reconnection on Disconnect
277
+
278
+ When the connection to Metro is lost (e.g., app restart, Metro restart, or network issues):
279
+
280
+ 1. The server automatically attempts to reconnect
281
+ 2. Uses exponential backoff: 500ms, 1s, 2s, 4s, 8s (up to 8 attempts)
282
+ 3. Re-fetches device list to handle new WebSocket URLs
283
+ 4. Preserves existing log and network buffers
284
+
285
+ ### Connection Gap Warnings
286
+
287
+ If there was a recent disconnect, `get_logs` and `get_network_requests` will include a warning:
288
+
289
+ ```
290
+ [WARNING] Connection was restored 5s ago. Some logs may have been missed during the 3s gap.
291
+ ```
292
+
293
+ ### Monitor Connection Health
294
+
295
+ Use `get_connection_status` to see detailed connection information:
296
+
297
+ ```
298
+ === Connection Status ===
299
+
300
+ --- React Native (Port 8081) ---
301
+ Status: CONNECTED
302
+ Connected since: 2:45:30 PM
303
+ Uptime: 5m 23s
304
+ Recent gaps: 1
305
+ - 2:43:15 PM (2s): Connection closed
306
+ ```
307
+
308
+ ## Troubleshooting
309
+
310
+ ### No devices found
311
+
312
+ - Make sure the app is running on a simulator/device
313
+ - Check that Metro bundler is running (`npm start`)
314
+
315
+ ### Wrong device connected
316
+
317
+ The server prioritizes devices in this order:
318
+
319
+ 1. React Native Bridgeless (SDK 54+)
320
+ 2. Hermes React Native
321
+ 3. Any React Native (excluding Reanimated/Experimental)
322
+
323
+ ### Logs not appearing
324
+
325
+ - Ensure the app is actively running (not just Metro)
326
+ - Try `clear_logs` then trigger some actions in the app
327
+ - Check `get_apps` to verify connection status
328
+
329
+ ## Telemetry & Data Collection
330
+
331
+ This package collects anonymous usage telemetry to help improve the product. No personal information is collected.
332
+
333
+ ### What is collected
334
+
335
+ | Data | Purpose |
336
+ | ----------------- | ---------------------------------------- |
337
+ | Tool names | Which MCP tools are used most |
338
+ | Success/failure | Error rates for reliability improvements |
339
+ | Duration (ms) | Performance monitoring |
340
+ | Session start/end | Retention analysis |
341
+ | Platform | macOS/Linux/Windows distribution |
342
+ | Server version | Adoption of new versions |
343
+
344
+ **Not collected**: No file paths, code content, network data, or personally identifiable information.
345
+
346
+ ### Auto-registration
347
+
348
+ On first tool use, the package automatically registers your installation with our backend. No account or login is required — the Tool works fully out of the box.
349
+
350
+ **Why we do this:** The product roadmap includes features that build on installation identity — project memory (your AI assistant gets smarter with every session by remembering navigation maps, element signatures, and debug patterns), cloud sync across machines, team collaboration with shared debugging context, and a Pro dashboard for managing installations and subscriptions. Auto-registration lays the groundwork so these features work seamlessly when they ship, without requiring a disruptive setup step later.
351
+
352
+ **What is sent:**
353
+
354
+ - A random installation ID (UUID)
355
+ - A device fingerprint (one-way SHA-256 hash — cannot be reversed to recover its components)
356
+ - Platform, hostname, OS version, and server version
357
+
358
+ **What is NOT sent:** No source code, file paths, console logs, network data, component names, or any content from your app. The fingerprint exists solely to prevent installation hijacking — it ties your installation to your physical machine so no one else can claim it.
359
+
360
+ Registration is fire-and-forget — it never blocks your work, fails silently if the network is unavailable, and can be disabled entirely (see Opt-out below). See [PRIVACY.md](./PRIVACY.md) for full details on data handling, storage, and your rights.
361
+
362
+ ### Opt-out
363
+
364
+ To disable telemetry and auto-registration, add `RN_DEBUGGER_TELEMETRY` to the `env` field in your MCP server configuration:
365
+
366
+ ```json
367
+ {
368
+ "mcpServers": {
369
+ "rn-debugger": {
370
+ "type": "stdio",
371
+ "command": "npx",
372
+ "args": ["react-native-ai-devtools"],
373
+ "env": { "RN_DEBUGGER_TELEMETRY": "false" }
374
+ }
375
+ }
376
+ }
377
+ ```
378
+
379
+ All debugging tools work normally with telemetry disabled. For the complete privacy policy, see [PRIVACY.md](./PRIVACY.md).
380
+
381
+ ## License
382
+
383
+ MIT
@@ -0,0 +1,36 @@
1
+ import type { TapResult } from "../../pro/tap.js";
2
+ export type Platform = "ios" | "android";
3
+ /**
4
+ * Detect which platform is available by checking for booted simulators/emulators.
5
+ * Returns the first available platform.
6
+ */
7
+ export declare function detectPlatform(): Promise<Platform>;
8
+ /**
9
+ * Connect to Metro and return the platform of the connected device.
10
+ */
11
+ export declare function connectToMetro(): Promise<Platform>;
12
+ /**
13
+ * Disconnect all apps and clean up state.
14
+ */
15
+ export declare function disconnectAll(): Promise<void>;
16
+ /**
17
+ * Read the test app's global state to verify a tap was registered.
18
+ * Returns { tapCount, lastTapped } or null if not available.
19
+ */
20
+ export declare function readTestState(): Promise<{
21
+ tapCount: number;
22
+ lastTapped: string;
23
+ } | null>;
24
+ /**
25
+ * Reset the test app's tap counter and last-tapped state.
26
+ */
27
+ export declare function resetTestState(): Promise<void>;
28
+ /**
29
+ * Assert that a tap result succeeded and the test app registered the tap on the expected element.
30
+ */
31
+ export declare function assertTapWorked(result: TapResult, expectedElement: string): Promise<void>;
32
+ /**
33
+ * Wait for a short duration (ms) to let UI settle.
34
+ */
35
+ export declare function sleep(ms: number): Promise<void>;
36
+ //# sourceMappingURL=tap-test-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tap-test-helpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/tap-test-helpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEzC;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAYxD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CA+BxD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBnD;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAU9F;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW/F;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
@@ -0,0 +1,130 @@
1
+ // src/__tests__/helpers/tap-test-helpers.ts
2
+ import { scanMetroPorts, fetchDevices, selectMainDevice } from "../../core/metro.js";
3
+ import { connectToDevice } from "../../core/connection.js";
4
+ import { executeInApp } from "../../core/executor.js";
5
+ import { connectedApps, pendingExecutions } from "../../core/state.js";
6
+ import { cancelAllReconnectionTimers, clearAllConnectionState } from "../../core/connectionState.js";
7
+ /**
8
+ * Detect which platform is available by checking for booted simulators/emulators.
9
+ * Returns the first available platform.
10
+ */
11
+ export async function detectPlatform() {
12
+ const { execSync } = await import("child_process");
13
+ try {
14
+ const result = execSync("xcrun simctl list devices booted 2>/dev/null", { encoding: "utf-8" });
15
+ if (result.includes("Booted"))
16
+ return "ios";
17
+ }
18
+ catch { /* no iOS */ }
19
+ try {
20
+ const result = execSync("adb devices 2>/dev/null", { encoding: "utf-8" });
21
+ const lines = result.trim().split("\n").filter(l => l.includes("device") && !l.includes("List"));
22
+ if (lines.length > 0)
23
+ return "android";
24
+ }
25
+ catch { /* no Android */ }
26
+ throw new Error("No booted iOS simulator or Android emulator found");
27
+ }
28
+ /**
29
+ * Connect to Metro and return the platform of the connected device.
30
+ */
31
+ export async function connectToMetro() {
32
+ const ports = await scanMetroPorts();
33
+ if (ports.length === 0) {
34
+ throw new Error("No Metro bundler found. Start Metro with the test app first.");
35
+ }
36
+ for (const port of ports) {
37
+ const devices = await fetchDevices(port);
38
+ const main = selectMainDevice(devices);
39
+ if (main) {
40
+ await connectToDevice(main, port, {
41
+ reconnectionConfig: {
42
+ enabled: false,
43
+ maxAttempts: 0,
44
+ initialDelayMs: 0,
45
+ maxDelayMs: 0,
46
+ backoffMultiplier: 1,
47
+ },
48
+ });
49
+ // connectToDevice resolves with a message string, not the map key.
50
+ // Wait briefly for the async platform detection (findSimulatorByName)
51
+ // to complete, then read the first connected app's platform.
52
+ await new Promise((resolve) => setTimeout(resolve, 2000));
53
+ for (const app of connectedApps.values()) {
54
+ if (app.platform)
55
+ return app.platform;
56
+ }
57
+ }
58
+ }
59
+ throw new Error("Connected to Metro but could not determine platform");
60
+ }
61
+ /**
62
+ * Disconnect all apps and clean up state.
63
+ */
64
+ export async function disconnectAll() {
65
+ const closePromises = [];
66
+ for (const [key, app] of connectedApps.entries()) {
67
+ closePromises.push(new Promise((resolve) => {
68
+ if (app.ws.readyState === app.ws.CLOSED) {
69
+ resolve();
70
+ }
71
+ else {
72
+ app.ws.on("close", () => resolve());
73
+ try {
74
+ app.ws.close();
75
+ }
76
+ catch {
77
+ resolve();
78
+ }
79
+ }
80
+ }));
81
+ connectedApps.delete(key);
82
+ }
83
+ await Promise.all(closePromises);
84
+ pendingExecutions.clear();
85
+ cancelAllReconnectionTimers();
86
+ clearAllConnectionState();
87
+ }
88
+ /**
89
+ * Read the test app's global state to verify a tap was registered.
90
+ * Returns { tapCount, lastTapped } or null if not available.
91
+ */
92
+ export async function readTestState() {
93
+ const result = await executeInApp("JSON.stringify({ tapCount: global.__TEST_STATE__?.tapCount ?? -1, lastTapped: global.__TEST_STATE__?.lastTapped ?? 'unknown' })");
94
+ if (!result.success || !result.result)
95
+ return null;
96
+ try {
97
+ return JSON.parse(result.result);
98
+ }
99
+ catch {
100
+ return null;
101
+ }
102
+ }
103
+ /**
104
+ * Reset the test app's tap counter and last-tapped state.
105
+ */
106
+ export async function resetTestState() {
107
+ await executeInApp("global.__TEST_STATE__?.reset?.()");
108
+ }
109
+ /**
110
+ * Assert that a tap result succeeded and the test app registered the tap on the expected element.
111
+ */
112
+ export async function assertTapWorked(result, expectedElement) {
113
+ if (!result.success) {
114
+ throw new Error(`Tap failed: ${result.error ?? result.suggestion ?? "unknown reason"}`);
115
+ }
116
+ const state = await readTestState();
117
+ if (!state) {
118
+ throw new Error("Could not read test app state via execute_in_app");
119
+ }
120
+ if (state.lastTapped !== expectedElement) {
121
+ throw new Error(`Expected lastTapped="${expectedElement}" but got "${state.lastTapped}"`);
122
+ }
123
+ }
124
+ /**
125
+ * Wait for a short duration (ms) to let UI settle.
126
+ */
127
+ export function sleep(ms) {
128
+ return new Promise((resolve) => setTimeout(resolve, ms));
129
+ }
130
+ //# sourceMappingURL=tap-test-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tap-test-helpers.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/tap-test-helpers.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAKrG;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IACnD,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,8CAA8C,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/F,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,KAAK,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACxB,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,Q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