mobile-debug-mcp 0.34.0 → 0.36.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 (500) hide show
  1. package/.agents/skills/mcp-builder/SKILL.md +44 -64
  2. package/.agents/skills/mcp-builder/references/build-flags.md +44 -43
  3. package/.agents/skills/mcp-builder/references/diagnostics-schema.md +4 -1
  4. package/.agents/skills/mcp-builder/references/toolchain-details.md +49 -62
  5. package/.agents/skills/spec-review/references/spec-review-checklist.md +7 -0
  6. package/.agents/skills/test-authoring/SKILL.md +7 -6
  7. package/.agents/skills/test-authoring/references/repo-test-layout.md +3 -1
  8. package/.agents/skills/test-authoring/references/test-authoring-workflow.md +16 -7
  9. package/.agents/skills/test-authoring/references/test-quality-checklist.md +2 -1
  10. package/.cursor-plugin/marketplace.json +1 -1
  11. package/.github/copilot-instructions.md +14 -36
  12. package/.github/workflows/ci.yml +4 -4
  13. package/AGENTS.md +12 -3
  14. package/CONTRIBUTING.md +79 -0
  15. package/README.md +218 -129
  16. package/agent-plugin/.antigravity-plugin/README.md +48 -0
  17. package/agent-plugin/.antigravity-plugin/plugin.json +18 -0
  18. package/agent-plugin/.claude-plugin/plugin.json +2 -2
  19. package/agent-plugin/.codex-plugin/plugin.json +1 -1
  20. package/agent-plugin/.cursor-plugin/plugin.json +2 -2
  21. package/agent-plugin/.mcp.json +1 -1
  22. package/agent-plugin/README.md +50 -11
  23. package/agent-plugin/cursor/.cursor-plugin/plugin.json +23 -0
  24. package/agent-plugin/cursor/LICENSE +201 -0
  25. package/agent-plugin/cursor/README.md +9 -0
  26. package/agent-plugin/cursor/skills/mobile-debug-mcp/SKILL.md +253 -0
  27. package/agent-plugin/mcp.json +1 -1
  28. package/agent-plugin/mcp_config.json +13 -0
  29. package/agent-plugin/plugin.json +1 -1
  30. package/agent-plugin/skills/mobile-debug-mcp/SKILL.md +62 -17
  31. package/dist/contracts/execution-controls.js +24 -0
  32. package/dist/contracts/selector.js +8 -0
  33. package/dist/contracts/target.js +15 -0
  34. package/dist/contracts/ui.js +1 -0
  35. package/dist/debugger/android.js +2 -1
  36. package/dist/debugger/diagnostics.js +54 -0
  37. package/dist/debugger/guard.js +4 -4
  38. package/dist/debugger/ios-worker.js +62 -0
  39. package/dist/debugger/ios.js +57 -0
  40. package/dist/debugger/protocol.js +33 -0
  41. package/dist/debugger/sessions.js +133 -74
  42. package/dist/debugger/worker.js +59 -46
  43. package/dist/interact/adjustment/adjustment-context.js +41 -0
  44. package/dist/interact/adjustment/adjustment-gestures.js +55 -0
  45. package/dist/interact/adjustment/adjustment-plan.js +18 -0
  46. package/dist/interact/adjustment/adjustment-resolution.js +127 -0
  47. package/dist/interact/adjustment/adjustment-result.js +19 -0
  48. package/dist/interact/adjustment/adjustment-semantic.js +64 -0
  49. package/dist/interact/adjustment/adjustment-verification.js +35 -0
  50. package/dist/interact/adjustment/adjustment.js +52 -0
  51. package/dist/interact/adjustment/control-geometry.js +87 -0
  52. package/dist/interact/adjustment/control-values.js +136 -0
  53. package/dist/interact/adjustment/slider-labels.js +84 -0
  54. package/dist/interact/assertions/screen-assertion.js +37 -0
  55. package/dist/interact/assertions/state-assertion-context.js +35 -0
  56. package/dist/interact/assertions/state-assertion.js +76 -0
  57. package/dist/interact/assertions/state-comparison.js +141 -0
  58. package/dist/interact/assertions/visibility-assertion.js +34 -0
  59. package/dist/interact/conditional-action.js +12 -7
  60. package/dist/interact/index.js +77 -3092
  61. package/dist/interact/input-service.js +1 -0
  62. package/dist/interact/interaction-trace.js +21 -0
  63. package/dist/interact/model.js +1 -0
  64. package/dist/interact/observation.js +1 -0
  65. package/dist/interact/targeting/candidate-ancestor.js +58 -0
  66. package/dist/interact/targeting/candidate-result.js +23 -0
  67. package/dist/interact/targeting/candidate-scoring.js +50 -0
  68. package/dist/interact/targeting/element-helpers.js +216 -0
  69. package/dist/interact/targeting/find-element.js +65 -0
  70. package/dist/interact/targeting/nearby-control.js +56 -0
  71. package/dist/interact/targeting/resolved-elements.js +21 -0
  72. package/dist/interact/targeting/tap-target.js +17 -0
  73. package/dist/interact/targeting/target-scope.js +104 -0
  74. package/dist/interact/waits/legacy-log-wait.js +38 -0
  75. package/dist/interact/waits/legacy-wait-observations.js +103 -0
  76. package/dist/interact/waits/legacy-wait-state.js +34 -0
  77. package/dist/interact/waits/legacy-wait.js +48 -0
  78. package/dist/interact/waits/screen-wait.js +49 -0
  79. package/dist/interact/waits/ui-change-helpers.js +157 -0
  80. package/dist/interact/waits/ui-change-state.js +18 -0
  81. package/dist/interact/waits/ui-change-wait.js +77 -0
  82. package/dist/interact/waits/ui-wait-condition.js +56 -0
  83. package/dist/interact/waits/ui-wait-state.js +38 -0
  84. package/dist/interact/waits/ui-wait.js +106 -0
  85. package/dist/manage/android.js +55 -51
  86. package/dist/manage/index.js +38 -75
  87. package/dist/manage/ios/build-types.js +1 -0
  88. package/dist/manage/ios/build.js +210 -0
  89. package/dist/manage/ios/project-discovery.js +29 -0
  90. package/dist/manage/ios/scheme.js +18 -0
  91. package/dist/manage/ios.js +44 -256
  92. package/dist/observe/android/context.js +1 -0
  93. package/dist/observe/android/current-screen.js +55 -0
  94. package/dist/observe/android/fingerprint.js +13 -0
  95. package/dist/observe/android/log-stream.js +132 -0
  96. package/dist/observe/android/logs.js +107 -0
  97. package/dist/observe/android/screenshot.js +70 -0
  98. package/dist/observe/android/ui-tree.js +107 -0
  99. package/dist/observe/android.js +16 -520
  100. package/dist/observe/evidence.js +114 -75
  101. package/dist/observe/index.js +16 -263
  102. package/dist/observe/ios/context.js +16 -0
  103. package/dist/observe/ios/fingerprint.js +12 -0
  104. package/dist/observe/ios/log-stream.js +105 -0
  105. package/dist/observe/ios/logs.js +168 -0
  106. package/dist/observe/ios/screenshot.js +22 -0
  107. package/dist/observe/ios/ui-elements.js +241 -0
  108. package/dist/observe/ios/ui-tree.js +137 -0
  109. package/dist/observe/ios-trace/artifact.js +63 -0
  110. package/dist/observe/ios-trace/capabilities.js +86 -0
  111. package/dist/observe/ios-trace/native.js +93 -0
  112. package/dist/observe/ios-trace/notification.js +35 -0
  113. package/dist/observe/ios-trace/process.js +98 -0
  114. package/dist/observe/ios-trace/sessions.js +244 -0
  115. package/dist/observe/ios.js +17 -715
  116. package/dist/observe/logs/model.js +1 -0
  117. package/dist/{network → observe/network}/index.js +2 -2
  118. package/dist/observe/readiness-service.js +5 -3
  119. package/dist/observe/readiness.js +33 -14
  120. package/dist/observe/screenshot-encoding.js +41 -0
  121. package/dist/observe/snapshot-collection.js +79 -0
  122. package/dist/observe/snapshot-logs.js +30 -0
  123. package/dist/observe/snapshot-metadata.js +43 -31
  124. package/dist/observe/snapshot-semantic.js +115 -0
  125. package/dist/observe/system-trace-error.js +7 -0
  126. package/dist/observe/system-trace-router.js +81 -0
  127. package/dist/observe/system-trace.js +26 -21
  128. package/dist/runtime/action-results.js +270 -0
  129. package/dist/runtime/clock.js +4 -0
  130. package/dist/server/common.js +1 -256
  131. package/dist/server/definitions/assert.js +162 -0
  132. package/dist/server/definitions/diagnostic.js +118 -0
  133. package/dist/server/definitions/input.js +274 -0
  134. package/dist/server/definitions/manage.js +194 -0
  135. package/dist/server/definitions/observe.js +149 -0
  136. package/dist/server/definitions/target.js +138 -0
  137. package/dist/server/definitions/wait.js +105 -0
  138. package/dist/server/handlers/action-execution.js +163 -0
  139. package/dist/server/handlers/correlation.js +23 -0
  140. package/dist/server/handlers/debugger-handlers.js +67 -0
  141. package/dist/server/handlers/debugger-response.js +9 -0
  142. package/dist/server/handlers/diagnostic.js +77 -0
  143. package/dist/server/handlers/handler-types.js +1 -0
  144. package/dist/server/handlers/input.js +154 -0
  145. package/dist/server/handlers/interact.js +113 -0
  146. package/dist/server/handlers/journey-assertions.js +35 -0
  147. package/dist/server/handlers/journey.js +147 -0
  148. package/dist/server/handlers/manage.js +119 -0
  149. package/dist/server/handlers/observe.js +95 -0
  150. package/dist/server/handlers/payload.js +4 -0
  151. package/dist/server/handlers/tool-handlers.js +170 -0
  152. package/dist/server/schemas/condition-schema.js +2 -0
  153. package/dist/server/{debugger-schema.js → schemas/debugger-schema.js} +20 -12
  154. package/dist/server/{journey-schema.js → schemas/journey-schema.js} +7 -22
  155. package/dist/server/schemas/system-trace-schema.js +22 -0
  156. package/dist/server/tool-definitions.js +58 -1135
  157. package/dist/server-core.js +2 -2
  158. package/dist/server.js +4 -4
  159. package/dist/system/android-status.js +101 -0
  160. package/dist/system/android.js +37 -27
  161. package/dist/system/index.js +13 -439
  162. package/dist/system/ios-status.js +132 -0
  163. package/dist/system/ios.js +11 -8
  164. package/dist/system/model.js +1 -0
  165. package/dist/system/probes.js +105 -0
  166. package/dist/system/status-summary.js +43 -0
  167. package/dist/system/unsupported-status.js +52 -0
  168. package/dist/utils/android/commands.js +89 -0
  169. package/dist/utils/android/gradle.js +139 -0
  170. package/dist/utils/android/logs.js +103 -0
  171. package/dist/utils/android/ui-tree.js +233 -0
  172. package/dist/utils/android/utils.js +6 -564
  173. package/dist/utils/cli/idb/idb-helper.js +4 -6
  174. package/dist/utils/cli/idb/install-idb.js +13 -9
  175. package/dist/utils/cli/ios/preflight-ios.js +42 -38
  176. package/dist/utils/ios/utils.js +48 -46
  177. package/dist/utils/java.js +65 -49
  178. package/dist/utils/resolve-device.js +4 -2
  179. package/dist/utils/ui/index.js +26 -26
  180. package/docs/CHANGELOG.md +67 -1
  181. package/docs/README.md +38 -0
  182. package/docs/agent-plugin-installation-verification.md +39 -0
  183. package/docs/benchmarks/README.md +18 -0
  184. package/docs/benchmarks/interaction-latency/README.md +14 -0
  185. package/docs/benchmarks/interaction-latency/final.md +4 -1
  186. package/docs/benchmarks/interaction-latency/ios-validation.md +2 -0
  187. package/docs/benchmarks/ui-tree-performance/README.md +24 -16
  188. package/docs/benchmarks/ui-tree-performance/comparison.md +11 -10
  189. package/docs/code-structure.md +120 -0
  190. package/docs/specs/001-state-verification/spec.md +16 -14
  191. package/docs/specs/002-richer-element-identity/spec.md +12 -10
  192. package/docs/specs/003-wait-and-synchronization-reliability/spec.md +12 -10
  193. package/docs/specs/004-action-verification-routing/spec.md +3 -3
  194. package/docs/specs/005-unified-action-execution-and-verification-model/spec.md +2 -0
  195. package/docs/specs/006-runtime-action-instrumentation-and-binding-layer/spec.md +2 -0
  196. package/docs/specs/007-actionability-resolution-and-executable-target-selection/spec.md +3 -1
  197. package/docs/specs/008-adjustable-control-support-and-semantic-value-manipulation/spec.md +3 -4
  198. package/docs/specs/009-semantic-control-modeling-for-custom-and-composite-controls/spec.md +2 -0
  199. package/docs/specs/010-verification-stabilization-and-temporal-convergence/spec.md +2 -2
  200. package/docs/specs/011-recovery-and-replanning-for-failed-or-ambiguous-interaction-flows/spec.md +2 -2
  201. package/docs/specs/011.1-recovery-contract-types-and-runtime-wiring-spec/spec.md +2 -0
  202. package/docs/specs/012-action-trace-and-xecution-observability/spec.md +2 -3
  203. package/docs/specs/013-wait-and-synchronization-reliability/spec.md +19 -19
  204. package/docs/specs/014-actionability-resolution/spec.md +20 -18
  205. package/docs/specs/015-adjustable-control-support/spec.md +17 -15
  206. package/docs/specs/016-environment-tools/spec.md +20 -20
  207. package/docs/specs/018-interaction-latency-and-batched-journeys/spec.md +2 -0
  208. package/docs/specs/019-ui-tree-observation-performance/spec.md +3 -1
  209. package/docs/specs/020-conditional-actions/intent.md +5 -3
  210. package/docs/specs/020-conditional-actions/plan.md +8 -9
  211. package/docs/specs/020-conditional-actions/spec.md +4 -2
  212. package/docs/specs/021-app-readiness-signals/intent.md +4 -2
  213. package/docs/specs/021-app-readiness-signals/plan.md +7 -6
  214. package/docs/specs/021-app-readiness-signals/spec.md +3 -1
  215. package/docs/specs/022-correlated-evidence/intent.md +4 -4
  216. package/docs/specs/022-correlated-evidence/plan.md +10 -11
  217. package/docs/specs/022-correlated-evidence/spec.md +3 -1
  218. package/docs/specs/023-android-system-traces/intent.md +3 -2
  219. package/docs/specs/023-android-system-traces/plan.md +5 -7
  220. package/docs/specs/023-android-system-traces/spec.md +3 -1
  221. package/docs/specs/024-android-heap-dump-capture/intent.md +3 -1
  222. package/docs/specs/025-android-runtime-debugger/intent.md +4 -3
  223. package/docs/specs/025-android-runtime-debugger/plan.md +3 -1
  224. package/docs/specs/025-android-runtime-debugger/spec.md +4 -3
  225. package/docs/specs/026-code-structure-and-quality-gates/health-plan.md +88 -0
  226. package/docs/specs/026-code-structure-and-quality-gates/intent.md +47 -0
  227. package/docs/specs/026-code-structure-and-quality-gates/plan.md +191 -0
  228. package/docs/specs/026-code-structure-and-quality-gates/spec.md +138 -0
  229. package/docs/specs/026-code-structure-and-quality-gates/verification-final.json +200 -0
  230. package/docs/specs/026-code-structure-and-quality-gates/verification-thin-facade.json +154 -0
  231. package/docs/specs/026-code-structure-and-quality-gates/verification.json +136 -0
  232. package/docs/specs/027-debugger-failure-diagnostics/intent.md +43 -0
  233. package/docs/specs/027-debugger-failure-diagnostics/plan.md +86 -0
  234. package/docs/specs/027-debugger-failure-diagnostics/spec.md +133 -0
  235. package/docs/specs/028-compact-debugger-responses/intent.md +41 -0
  236. package/docs/specs/028-compact-debugger-responses/plan.md +112 -0
  237. package/docs/specs/028-compact-debugger-responses/spec.md +108 -0
  238. package/docs/specs/029-kotlin-locals-validation/report.md +119 -0
  239. package/docs/specs/030-android-coroutine-validation/evidence.json +475 -0
  240. package/docs/specs/030-android-coroutine-validation/intent.md +47 -0
  241. package/docs/specs/030-android-coroutine-validation/plan.md +147 -0
  242. package/docs/specs/030-android-coroutine-validation/report.md +240 -0
  243. package/docs/specs/030-android-coroutine-validation/spec.md +107 -0
  244. package/docs/specs/031-ios-system-traces/intent.md +38 -0
  245. package/docs/specs/031-ios-system-traces/investigation.md +92 -0
  246. package/docs/specs/031-ios-system-traces/late-run-failure-evidence.json +32 -0
  247. package/docs/specs/031-ios-system-traces/plan.md +138 -0
  248. package/docs/specs/031-ios-system-traces/pr102-monitor-evidence.json +22 -0
  249. package/docs/specs/031-ios-system-traces/simulator-evidence.json +47 -0
  250. package/docs/specs/031-ios-system-traces/spec.md +135 -0
  251. package/docs/specs/032-ios-runtime-debugger/evidence.json +176 -0
  252. package/docs/specs/032-ios-runtime-debugger/intent.md +38 -0
  253. package/docs/specs/032-ios-runtime-debugger/plan.md +95 -0
  254. package/docs/specs/032-ios-runtime-debugger/report.md +205 -0
  255. package/docs/specs/032-ios-runtime-debugger/spec.md +153 -0
  256. package/docs/tools/TOOLS.md +31 -18
  257. package/docs/tools/{evidence.md → correlated-evidence.md} +9 -1
  258. package/docs/tools/debugger.md +120 -4
  259. package/docs/tools/interact.md +42 -20
  260. package/docs/tools/manage.md +25 -44
  261. package/docs/tools/observe.md +55 -23
  262. package/docs/tools/system-traces.md +89 -14
  263. package/docs/tools/system.md +12 -5
  264. package/package.json +12 -8
  265. package/scripts/agent-plugin.mjs +55 -5
  266. package/scripts/architecture-graph.mjs +69 -0
  267. package/scripts/check-architecture.mjs +47 -0
  268. package/scripts/code-quality-baseline.json +1 -0
  269. package/scripts/code-quality.mjs +161 -0
  270. package/src/contracts/execution-controls.ts +26 -0
  271. package/src/contracts/selector.ts +17 -0
  272. package/src/contracts/target.ts +19 -0
  273. package/src/contracts/ui.ts +94 -0
  274. package/src/debugger/android.ts +3 -2
  275. package/src/debugger/diagnostics.ts +43 -0
  276. package/src/debugger/guard.ts +10 -5
  277. package/src/debugger/ios-worker.ts +49 -0
  278. package/src/debugger/ios.ts +45 -0
  279. package/{worker → src/debugger/java}/DebuggerWorker.java +9 -3
  280. package/src/debugger/lldb/breakpoints.py +51 -0
  281. package/src/debugger/lldb/inspection.py +109 -0
  282. package/src/debugger/lldb/worker.py +203 -0
  283. package/src/debugger/protocol.ts +37 -0
  284. package/src/debugger/sessions.ts +326 -155
  285. package/src/debugger/worker.ts +57 -41
  286. package/src/interact/adjustment/adjustment-context.ts +83 -0
  287. package/src/interact/adjustment/adjustment-gestures.ts +48 -0
  288. package/src/interact/adjustment/adjustment-plan.ts +23 -0
  289. package/src/interact/adjustment/adjustment-resolution.ts +104 -0
  290. package/src/interact/adjustment/adjustment-result.ts +34 -0
  291. package/src/interact/adjustment/adjustment-semantic.ts +53 -0
  292. package/src/interact/adjustment/adjustment-verification.ts +60 -0
  293. package/src/interact/adjustment/adjustment.ts +49 -0
  294. package/src/interact/adjustment/control-geometry.ts +120 -0
  295. package/src/interact/adjustment/control-values.ts +141 -0
  296. package/src/interact/adjustment/slider-labels.ts +84 -0
  297. package/src/interact/assertions/screen-assertion.ts +39 -0
  298. package/src/interact/assertions/state-assertion-context.ts +48 -0
  299. package/src/interact/assertions/state-assertion.ts +64 -0
  300. package/src/interact/assertions/state-comparison.ts +168 -0
  301. package/src/interact/assertions/visibility-assertion.ts +41 -0
  302. package/src/interact/conditional-action.ts +18 -12
  303. package/src/interact/index.ts +89 -3494
  304. package/src/interact/input-service.ts +11 -0
  305. package/src/interact/interaction-trace.ts +36 -0
  306. package/src/interact/model.ts +109 -0
  307. package/src/interact/observation.ts +7 -0
  308. package/src/interact/targeting/candidate-ancestor.ts +49 -0
  309. package/src/interact/targeting/candidate-result.ts +24 -0
  310. package/src/interact/targeting/candidate-scoring.ts +42 -0
  311. package/src/interact/targeting/element-helpers.ts +243 -0
  312. package/src/interact/targeting/find-element.ts +47 -0
  313. package/src/interact/targeting/nearby-control.ts +46 -0
  314. package/src/interact/targeting/resolved-elements.ts +20 -0
  315. package/src/interact/targeting/tap-target.ts +22 -0
  316. package/src/interact/targeting/target-scope.ts +121 -0
  317. package/src/interact/waits/legacy-log-wait.ts +30 -0
  318. package/src/interact/waits/legacy-wait-observations.ts +55 -0
  319. package/src/interact/waits/legacy-wait-state.ts +48 -0
  320. package/src/interact/waits/legacy-wait.ts +34 -0
  321. package/src/interact/waits/screen-wait.ts +37 -0
  322. package/src/interact/waits/ui-change-helpers.ts +184 -0
  323. package/src/interact/waits/ui-change-state.ts +26 -0
  324. package/src/interact/waits/ui-change-wait.ts +59 -0
  325. package/src/interact/waits/ui-wait-condition.ts +52 -0
  326. package/src/interact/waits/ui-wait-state.ts +55 -0
  327. package/src/interact/waits/ui-wait.ts +84 -0
  328. package/src/manage/android.ts +56 -50
  329. package/src/manage/index.ts +63 -93
  330. package/src/manage/ios/build-types.ts +14 -0
  331. package/src/manage/ios/build.ts +230 -0
  332. package/src/manage/ios/project-discovery.ts +26 -0
  333. package/src/manage/ios/scheme.ts +16 -0
  334. package/src/manage/ios.ts +67 -298
  335. package/src/observe/android/context.ts +1 -0
  336. package/src/observe/android/current-screen.ts +63 -0
  337. package/src/observe/android/fingerprint.ts +13 -0
  338. package/src/observe/android/log-stream.ts +127 -0
  339. package/src/observe/android/logs.ts +110 -0
  340. package/src/observe/android/screenshot.ts +79 -0
  341. package/src/observe/android/ui-tree.ts +113 -0
  342. package/src/observe/android.ts +17 -531
  343. package/src/observe/evidence.ts +122 -70
  344. package/src/observe/index.ts +24 -286
  345. package/src/observe/ios/context.ts +22 -0
  346. package/src/observe/ios/fingerprint.ts +12 -0
  347. package/src/observe/ios/log-stream.ts +103 -0
  348. package/src/observe/ios/logs.ts +179 -0
  349. package/src/observe/ios/screenshot.ts +26 -0
  350. package/src/observe/ios/ui-elements.ts +266 -0
  351. package/src/observe/ios/ui-tree.ts +143 -0
  352. package/src/observe/ios-trace/artifact.ts +55 -0
  353. package/src/observe/ios-trace/capabilities.ts +74 -0
  354. package/src/observe/ios-trace/native.ts +72 -0
  355. package/src/observe/ios-trace/notification.ts +30 -0
  356. package/src/observe/ios-trace/process.ts +82 -0
  357. package/src/observe/ios-trace/sessions.ts +204 -0
  358. package/src/observe/ios.ts +18 -749
  359. package/src/observe/logs/model.ts +11 -0
  360. package/src/{network → observe/network}/index.ts +2 -2
  361. package/src/observe/readiness-service.ts +6 -4
  362. package/src/observe/readiness.ts +42 -21
  363. package/src/observe/screenshot-encoding.ts +32 -0
  364. package/src/observe/snapshot-collection.ts +69 -0
  365. package/src/observe/snapshot-logs.ts +26 -0
  366. package/src/observe/snapshot-metadata.ts +51 -31
  367. package/src/observe/snapshot-semantic.ts +153 -0
  368. package/src/observe/system-trace-error.ts +3 -0
  369. package/src/observe/system-trace-router.ts +61 -0
  370. package/src/observe/system-trace.ts +28 -19
  371. package/src/runtime/action-results.ts +376 -0
  372. package/src/runtime/clock.ts +9 -0
  373. package/src/server/common.ts +9 -359
  374. package/src/server/definitions/assert.ts +164 -0
  375. package/src/server/definitions/diagnostic.ts +120 -0
  376. package/src/server/definitions/input.ts +276 -0
  377. package/src/server/definitions/manage.ts +196 -0
  378. package/src/server/definitions/observe.ts +151 -0
  379. package/src/server/definitions/target.ts +140 -0
  380. package/src/server/definitions/wait.ts +107 -0
  381. package/src/server/handlers/action-execution.ts +164 -0
  382. package/src/server/handlers/correlation.ts +20 -0
  383. package/src/server/handlers/debugger-handlers.ts +58 -0
  384. package/src/server/handlers/debugger-response.ts +7 -0
  385. package/src/server/handlers/diagnostic.ts +86 -0
  386. package/src/server/handlers/handler-types.ts +7 -0
  387. package/src/server/handlers/input.ts +173 -0
  388. package/src/server/handlers/interact.ts +135 -0
  389. package/src/server/handlers/journey-assertions.ts +39 -0
  390. package/src/server/handlers/journey.ts +132 -0
  391. package/src/server/handlers/manage.ts +141 -0
  392. package/src/server/handlers/observe.ts +116 -0
  393. package/src/server/handlers/payload.ts +36 -0
  394. package/src/server/handlers/tool-handlers.ts +170 -0
  395. package/src/server/schemas/condition-schema.ts +2 -0
  396. package/src/server/schemas/debugger-schema.ts +46 -0
  397. package/src/server/{journey-schema.ts → schemas/journey-schema.ts} +7 -22
  398. package/src/server/schemas/system-trace-schema.ts +23 -0
  399. package/src/server/tool-definitions.ts +67 -1143
  400. package/src/server-core.ts +2 -2
  401. package/src/server.ts +4 -4
  402. package/src/system/android-status.ts +124 -0
  403. package/src/system/android.ts +33 -21
  404. package/src/system/index.ts +21 -525
  405. package/src/system/ios-status.ts +147 -0
  406. package/src/system/ios.ts +14 -10
  407. package/src/system/model.ts +41 -0
  408. package/src/system/probes.ts +114 -0
  409. package/src/system/status-summary.ts +47 -0
  410. package/src/system/unsupported-status.ts +55 -0
  411. package/src/types.ts +16 -106
  412. package/src/utils/android/commands.ts +81 -0
  413. package/src/utils/android/gradle.ts +132 -0
  414. package/src/utils/android/logs.ts +103 -0
  415. package/src/utils/android/ui-tree.ts +239 -0
  416. package/src/utils/android/utils.ts +16 -556
  417. package/src/utils/cli/idb/check-idb.ts +4 -4
  418. package/src/utils/cli/idb/idb-helper.ts +6 -8
  419. package/src/utils/cli/idb/install-idb.ts +15 -9
  420. package/src/utils/cli/ios/preflight-ios.ts +39 -31
  421. package/src/utils/cli/ios/run-ios-ui-tree-tap.ts +4 -4
  422. package/src/utils/ios/utils.ts +60 -61
  423. package/src/utils/java.ts +62 -43
  424. package/src/utils/resolve-device.ts +9 -6
  425. package/src/utils/ui/index.ts +28 -28
  426. package/test/device/automated/debugger/coroutine-lifecycle.ts +27 -0
  427. package/test/device/automated/debugger/coroutine-support.ts +140 -0
  428. package/test/device/automated/debugger/coroutine.android.test.ts +169 -0
  429. package/test/device/automated/debugger/kotlin.android.test.ts +127 -0
  430. package/test/device/automated/debugger/runtime.android.test.ts +19 -3
  431. package/test/device/automated/debugger/runtime.ios.test.ts +221 -0
  432. package/test/device/automated/interact/interaction.android.test.ts +56 -0
  433. package/test/device/automated/observe/ios-system-trace.smoke.ts +119 -0
  434. package/test/device/automated/observe/system-trace.smoke.ts +1 -1
  435. package/test/device/manual/interact/modul8_selector_tap.manual.ts +1 -1
  436. package/test/fixtures/contracts/tool-definitions.json +3696 -0
  437. package/test/fixtures/coroutine-app/MainActivity.kt +100 -0
  438. package/test/fixtures/coroutine-app/README.md +48 -0
  439. package/test/fixtures/coroutine-app/build.ts +35 -0
  440. package/test/fixtures/debugger-app/MainActivity.java +21 -0
  441. package/test/fixtures/debugger-app/MainActivity.kt +32 -0
  442. package/test/fixtures/debugger-app/README.md +52 -0
  443. package/test/fixtures/debugger-app/build.ts +25 -15
  444. package/test/fixtures/ios-debugger-app/Main.swift +95 -0
  445. package/test/fixtures/ios-debugger-app/README.md +27 -0
  446. package/test/fixtures/ios-debugger-app/build.ts +21 -0
  447. package/test/fixtures/latency-journey-app/README.md +2 -0
  448. package/test/fixtures/readiness-app/README.md +2 -0
  449. package/test/helpers/ios-trace-shutdown.ts +29 -0
  450. package/test/unit/debugger/coroutine-lifecycle.test.ts +43 -0
  451. package/test/unit/debugger/diagnostic-sessions.test.ts +67 -0
  452. package/test/unit/debugger/diagnostics.test.ts +80 -0
  453. package/test/unit/debugger/guards.test.ts +4 -0
  454. package/test/unit/debugger/handle-guards.test.ts +88 -0
  455. package/test/unit/debugger/ios-preparation.test.ts +57 -0
  456. package/test/unit/debugger/ios.test.ts +104 -0
  457. package/test/unit/debugger/lldb-worker.py +166 -0
  458. package/test/unit/debugger/lldb-worker.test.ts +10 -0
  459. package/test/unit/debugger/preparation.test.ts +32 -0
  460. package/test/unit/debugger/protocol.test.ts +15 -0
  461. package/test/unit/debugger/sessions.test.ts +1 -1
  462. package/test/unit/interact/adjustment_service.test.ts +42 -0
  463. package/test/unit/interact/adjustment_verification.test.ts +35 -0
  464. package/test/unit/interact/clock_dependencies.test.ts +63 -0
  465. package/test/unit/interact/element_helpers.test.ts +19 -0
  466. package/test/unit/interact/legacy_wait_service.test.ts +17 -0
  467. package/test/unit/interact/state_comparison.test.ts +20 -0
  468. package/test/unit/interact/target_scope.test.ts +35 -0
  469. package/test/unit/network/get_network_activity.test.ts +1 -1
  470. package/test/unit/observe/ios-trace-native.test.ts +90 -0
  471. package/test/unit/observe/ios-trace-sessions.test.ts +131 -0
  472. package/test/unit/observe/readiness.test.ts +1 -1
  473. package/test/unit/observe/screenshot-encoding.test.ts +30 -0
  474. package/test/unit/observe/snapshot-logs.test.ts +14 -0
  475. package/test/unit/observe/system-trace-router.test.ts +49 -0
  476. package/test/unit/quality/agent-plugin-export.test.ts +38 -0
  477. package/test/unit/quality/architecture.test.ts +60 -0
  478. package/test/unit/quality/code-quality.test.ts +58 -0
  479. package/test/unit/quality/interaction_boundaries.test.ts +24 -0
  480. package/test/unit/server/conditional_actions.test.ts +1 -1
  481. package/test/unit/server/conditional_schema.test.ts +2 -2
  482. package/test/unit/server/debugger-response.test.ts +63 -0
  483. package/test/unit/server/system-trace.test.ts +12 -3
  484. package/test/unit/server/tool_definitions_parity.test.ts +8 -0
  485. package/dist/server/debugger-handlers.js +0 -38
  486. package/dist/server/system-trace-schema.js +0 -17
  487. package/dist/server/tool-handlers.js +0 -1000
  488. package/docs/ROADMAP.md +0 -646
  489. package/docs/benchmarks/ui-tree-performance/bridge-probe.json +0 -29
  490. package/docs/benchmarks/ui-tree-performance/initial-baseline.json +0 -59560
  491. package/docs/specs/baseline-spec-v0.md +0 -312
  492. package/docs/specs/mcp-tooling-spec-v1.md +0 -446
  493. package/src/server/debugger-handlers.ts +0 -29
  494. package/src/server/debugger-schema.ts +0 -37
  495. package/src/server/system-trace-schema.ts +0 -17
  496. package/src/server/tool-handlers.ts +0 -1008
  497. /package/dist/{server/condition-schema.js → contracts/condition.js} +0 -0
  498. /package/dist/server/{readiness-schema.js → schemas/readiness-schema.js} +0 -0
  499. /package/src/{server/condition-schema.ts → contracts/condition.ts} +0 -0
  500. /package/src/server/{readiness-schema.ts → schemas/readiness-schema.ts} +0 -0
@@ -1,23 +1,23 @@
1
- # Interact (UI actions, waits, and verification)
1
+ # Interaction
2
2
 
3
- This document covers deterministic UI resolution, actions, waits, and outcome verification.
3
+ [Documentation](../README.md) · [Tool reference](TOOLS.md)
4
4
 
5
- ## Verification pattern
5
+ Use these tools to select UI targets, perform actions, wait for transitions, and
6
+ verify the resulting state. See [interaction principles](TOOLS.md#interaction-principles)
7
+ for the distinction between execution, synchronization, and verification.
6
8
 
7
- For mutation actions, the intended agent loop is:
9
+ ## On this page
8
10
 
9
- **RESOLVE -> ACT -> WAIT (if needed) -> EXPECT**
11
+ - Find a target: [find_element](#find_element), [wait_for_ui](#wait_for_ui).
12
+ - Act on it: [basic input](#tap--swipe--type_text--press_back), [tap_element](#tap_element), [scroll_to_element](#scroll_to_element), [adjust_control](#adjust_control).
13
+ - Wait for change: [screen changes](#wait_for_screen_change), [UI changes](#wait_for_ui_change), [readiness-aware waits](#readiness-aware-waits).
14
+ - Verify the outcome: [screen](#expect_screen), [visible element](#expect_element_visible), [control state](#expect_state).
15
+ - Control execution: [conditional actions](#conditional-actions), [verification modes and journeys](#interaction-execution-controls-rfc-018).
16
+ - Investigate failures: [outcome classification and network activity](#classify_action_outcome--get_network_activity), [evidence correlation](correlated-evidence.md).
10
17
 
11
- Role split:
12
-
13
- - `wait_for_*` = resolution and synchronization
14
- - `expect_*` = final outcome verification
15
-
16
- Important:
17
-
18
- - `wait_for_*` tools must not be used as the final verification of action success when an applicable `expect_*` tool exists.
19
- - action tools report execution success, not outcome correctness.
20
- - `classify_action_outcome` should receive the runtime `action_type` when you want routing to distinguish local-state and side-effect actions.
18
+ When classifying a result, pass the runtime `action_type` to
19
+ `classify_action_outcome` so local-state changes and backend side effects can be
20
+ distinguished.
21
21
 
22
22
  ## Conditional actions
23
23
 
@@ -125,7 +125,7 @@ Example response:
125
125
  "target": { "selector": { "x": 100, "y": 200 }, "resolved": null },
126
126
  "success": true,
127
127
  "trace": {
128
- "action_id": "tap_element_1710000000002_3",
128
+ "action_id": "tap_1710000000000_1",
129
129
  "steps": [
130
130
  {
131
131
  "stage": "resolve",
@@ -292,6 +292,8 @@ Notes:
292
292
  - initial support is for slider-like controls that expose `value_range` or readable numeric value state
293
293
  - `expect_state` is the verification surface used to read back the resulting value
294
294
  - direct target placement is preferred; drag fallback is treated as degraded mode
295
+ - `maxAttempts` defaults to 5; omitted tolerance is 0 for discrete controls, or
296
+ the larger of half a step and 1% of the range for continuous controls
295
297
  - the tool returns `target_state`, `actual_state`, `within_tolerance`, `converged`, `attempts`, and `adjustment_mode`
296
298
 
297
299
  Input example:
@@ -458,7 +460,10 @@ Notes:
458
460
 
459
461
  ## tap_element
460
462
 
461
- Tap a previously resolved UI element using its `elementId`.
463
+ Tap a previously resolved `elementId`, or provide a `selector` to resolve and tap
464
+ in one call. Supply exactly one of these targets. Selector calls can use
465
+ `waitFor`; handle-based calls cannot. See [execution controls](#interaction-execution-controls-rfc-018)
466
+ for lookup budgets and selector options.
462
467
 
463
468
  Input:
464
469
 
@@ -734,8 +739,25 @@ the journey; remaining steps report `not_run`. Journey responses default to comp
734
739
  `defaults` supplies execution controls; step verification overrides the default.
735
740
  `captureOnFailure: true` includes a screenshot-free failure snapshot in debug mode.
736
741
 
737
- See [RFC 018](../specs/018-interaction-latency-and-batched-journeys/spec.md) for
738
- contracts and the device acceptance criteria.
742
+ Example `run_journey` request:
743
+
744
+ ```json
745
+ {
746
+ "platform": "android",
747
+ "deviceId": "emulator-5554",
748
+ "steps": [
749
+ { "id": "open-settings", "type": "tap", "selector": { "text": "Settings" } },
750
+ { "id": "verify-account", "type": "assert", "timeoutMs": 15000,
751
+ "assertion": { "kind": "element_visible", "selector": { "text": "Account" } } }
752
+ ]
753
+ }
754
+ ```
755
+
756
+ Replace the labels with elements from your own UI. Journey timeouts use camelCase
757
+ (`timeoutMs`, `pollIntervalMs`), unlike standalone UI wait/assertion fields
758
+ (`timeout_ms`, `poll_interval_ms`). See
759
+ [RFC 018](../specs/018-interaction-latency-and-batched-journeys/spec.md) for design
760
+ history and device acceptance criteria.
739
761
 
740
762
  ## Readiness-aware waits
741
763
 
@@ -768,4 +790,4 @@ for supported states and limits.
768
790
  ## Correlated evidence
769
791
 
770
792
  Actions and journeys expose identifiers and phase timestamps for linking later
771
- observations. See [correlated evidence](evidence.md) for scope and limitations.
793
+ observations. See [evidence correlation](correlated-evidence.md) for scope and limitations.
@@ -1,16 +1,21 @@
1
- # Manage (build & device management)
1
+ # App management
2
2
 
3
- This document covers tools that perform project builds, device selection, installation, and app lifecycle operations.
3
+ [Documentation](../README.md) · [Tool reference](TOOLS.md)
4
4
 
5
- For app launch and restart flows, agents should use:
5
+ Use these tools to select a device, build and install an app, and control its
6
+ lifecycle.
6
7
 
7
- **ACT -> WAIT (if needed) -> EXPECT**
8
+ After `start_app` or `restart_app`, [inspect the resulting UI](observe.md) and
9
+ [assert the expected screen or element](interact.md#expect_screen). If the app
10
+ is still loading, use a [readiness check](observe.md#app-readiness) or an
11
+ appropriate [UI wait](interact.md#wait_for_ui) before continuing.
8
12
 
9
- For example:
13
+ ## On this page
10
14
 
11
- 1. `start_app` or `restart_app`
12
- 2. optional `wait_for_screen_change`
13
- 3. `expect_screen` when the expected landing screen is known
15
+ - [List devices](#list_devices).
16
+ - [Build an app](#build_app).
17
+ - [Install an existing artifact](#install_app).
18
+ - [Launch, stop, restart, or reset an app](#start_app--terminate_app--restart_app--reset_app_data).
14
19
 
15
20
  ## list_devices
16
21
  Enumerate connected Android devices and iOS simulators.
@@ -51,50 +56,21 @@ Notes:
51
56
  - Requires `platform`, `projectType`, and `projectPath`.
52
57
  - Android builds prefer the project `gradlew` when present.
53
58
  - iOS builds honor environment-based Xcode destination and derived-data settings where configured.
54
- - Android setup typically needs `ADB_PATH` or `ANDROID_SDK_ROOT`/`ANDROID_HOME`, plus `GRADLE_JAVA_HOME` or `JAVA_HOME` for Gradle-backed builds.
59
+ - Standard toolchains are discovered automatically. Use [path overrides](../../README.md#environment-setup) when discovery needs help. Gradle-backed builds require a suitable Java installation.
55
60
  - iOS setup typically needs `XCRUN_PATH` and `MCP_IDB_PATH` or `IDB_PATH` when `idb` is not on `PATH`.
56
61
 
57
62
  ---
58
63
 
59
- ## build_and_install (buildAndInstallHandler)
60
- Orchestrates build then install and returns streamed NDJSON events plus a final result object.
61
-
62
- This is a documented repository helper, not part of the main public MCP tool list in `toolDefinitions`.
63
-
64
- Input:
65
-
66
- ```json
67
- { "projectPath": "/path/to/project", "platform": "android", "deviceId": "emulator-5554", "projectType": "kmp" }
68
- ```
69
-
70
- NDJSON events (example stream):
71
-
72
- ```json
73
- {"type":"build","status":"started","platform":"android"}
74
- {"type":"build","status":"finished","artifactPath":"/path/to/app.apk"}
75
- {"type":"install","status":"started","artifactPath":"/path/to/app.apk","deviceId":"emulator-5554"}
76
- {"type":"install","status":"finished","artifactPath":"/path/to/app.apk","device":{"platform":"android","id":"emulator-5554"}}
77
- ```
78
-
79
- Final result:
80
-
81
- ```json
82
- { "success": true, "artifactPath": "/path/to/app.apk", "device": { "platform": "android", "id": "emulator-5554" }, "output": "Performing Streamed Install\nSuccess" }
83
- ```
84
-
85
- Notes:
86
- - If `projectType` === `kmp`, the handler prefers Android by default. Set `platform` explicitly to override.
87
- - If `MCP_DISABLE_AUTODETECT=1`, callers MUST provide `platform` or `projectType`.
88
-
89
- ---
90
-
91
64
  ## install_app
92
- Install an app onto a connected device or simulator.
65
+ Install a built artifact, or build and install from a project directory.
66
+ `platform`, `projectType`, and `appPath` are required. `projectType` is one of
67
+ `native`, `kmp`, `react-native`, or `flutter`; acceptance of a project type does
68
+ not establish tested support for every framework.
93
69
 
94
70
  Input:
95
71
 
96
72
  ```json
97
- { "platform": "android", "appPath": "/path/to/app.apk", "deviceId": "emulator-5554" }
73
+ { "platform": "android", "projectType": "native", "appPath": "/path/to/app.apk", "deviceId": "emulator-5554" }
98
74
  ```
99
75
 
100
76
  Response:
@@ -155,4 +131,9 @@ Notes:
155
131
  - Use `details.observed_app` as the quick decision signal for what the tool actually saw after launch.
156
132
  - Android launch feedback usually includes package/activity matching; iOS launch feedback includes launch output and PID when available.
157
133
  - When the landing screen is known, use `expect_screen` as the final verification step.
158
- - If launch timing is uncertain, insert `wait_for_screen_change` before `expect_screen`.
134
+ - If launch timing is uncertain, use a UI wait or readiness check before the final assertion.
135
+
136
+ `terminate_app`, `restart_app`, and `reset_app_data` also require `platform` and
137
+ `appId`, with optional `deviceId`. Resetting app data removes application state;
138
+ use it only when a clean app state is intended. Execution controls apply to
139
+ `start_app` and `restart_app`; see [verification modes](interact.md#interaction-execution-controls-rfc-018).
@@ -1,31 +1,33 @@
1
- # Observe (logs, screenshots, UI trees)
1
+ # Observation
2
2
 
3
- Tools that retrieve device state, logs, screenshots, fingerprints, and UI hierarchies.
3
+ [Documentation](../README.md) · [Tool reference](TOOLS.md)
4
4
 
5
- These tools are primarily for:
5
+ Use observations to understand the current UI and investigate unexpected behaviour.
6
+ Screenshots show layout; UI trees expose labels, identifiers, and control state.
7
+ Logs and debug snapshots provide context when the UI does not explain a failure.
8
+ Use [interaction assertions](interact.md#expect_element_visible) to establish an
9
+ expected outcome.
6
10
 
7
- - building context before an action
8
- - supporting synchronization
9
- - diagnostics when verification fails
11
+ ## On this page
10
12
 
11
- They are **not** the primary success signal when an applicable `expect_*` tool exists.
13
+ - Inspect the UI: [screenshot](#capture_screenshot), [UI tree](#get_ui_tree), [current screen](#get_current_screen), [fingerprint](#get_screen_fingerprint).
14
+ - Investigate a failure: [logs](#get_logs), [debug snapshot](#capture_debug_snapshot), [log streams](#start_log_stream--read_log_stream--stop_log_stream).
15
+ - Check whether the UI has settled: [app readiness](#app-readiness).
12
16
 
13
- Covered observations support optional `actionRef` and return acquisition/freshness
14
- metadata; see [correlated evidence](evidence.md).
15
-
16
- Android performance investigations can use [system traces](system-traces.md)
17
- to bracket a journey and retrieve a local Perfetto artifact.
17
+ To connect an observation to a specific action, use [evidence
18
+ correlation](correlated-evidence.md). For Android performance questions, collect a
19
+ [system trace](system-traces.md) around the interaction.
18
20
 
19
21
  ## get_logs
20
22
 
21
- Fetch recent logs as structured entries optimized for AI agents.
23
+ Fetch recent logs as structured entries for diagnosis.
22
24
 
23
25
  Use logs as a debugging aid only. Prefer `expect_*` for verification, and use logs after verification fails or when an error is suspected.
24
26
 
25
27
  Input (example):
26
28
 
27
29
  ```json
28
- { "platform": "android|ios", "appId": "com.example.app", "deviceId": "emulator-5554", "pid": 1234, "tag": "MyTag", "level": "ERROR", "contains": "timeout", "since_seconds": 60, "limit": 50 }
30
+ { "platform": "android", "appId": "com.example.app", "deviceId": "emulator-5554", "pid": 1234, "tag": "MyTag", "level": "ERROR", "contains": "timeout", "since_seconds": 60, "limit": 50 }
29
31
  ```
30
32
 
31
33
  Defaults:
@@ -86,10 +88,10 @@ Input:
86
88
  { "platform": "android", "deviceId": "emulator-5554" }
87
89
  ```
88
90
 
89
- Response (example):
91
+ Response (selected fields):
90
92
 
91
93
  ```json
92
- { "device": { "platform": "android", "id": "emulator-5554" }, "screen": "", "resolution": { "width": 1080, "height": 2400 }, "snapshot_revision": 12, "captured_at_ms": 1710000000123, "loading_state": { "active": true, "signal": "spinner", "source": "ui_tree" }, "elements": [ { "text": "Sign in", "type": "android.widget.Button", "resourceId": "com.example:id/signin", "clickable": true, "bounds": [0,0,100,50], "state": { "enabled": true }, "stable_id": "com.example:id/signin", "role": "button", "test_tag": "com.example:id/signin", "selector": { "value": "com.example:id/signin", "confidence": { "score": 1, "reason": "resource_id" } }, "semantic": { "is_clickable": true, "is_container": false } } ] }
94
+ { "device": { "platform": "android", "id": "emulator-5554" }, "screen": "", "resolution": { "width": 1080, "height": 2400 }, "snapshot_session_id": "example-server-session", "snapshot_revision": 12, "captured_at_ms": 1710000000123, "loading_state": { "active": true, "signal": "spinner", "source": "ui_tree" }, "elements": [ { "text": "Sign in", "type": "android.widget.Button", "resourceId": "com.example:id/signin", "clickable": true, "bounds": [0,0,100,50], "state": { "enabled": true }, "stable_id": "com.example:id/signin", "role": "button", "test_tag": "com.example:id/signin", "selector": { "value": "com.example:id/signin", "confidence": { "score": 1, "reason": "resource_id" } }, "semantic": { "is_clickable": true, "is_container": false } } ] }
93
95
  ```
94
96
 
95
97
  Notes:
@@ -133,8 +135,9 @@ Input:
133
135
  {
134
136
  "reason": "optional string describing why snapshot is taken",
135
137
  "includeLogs": true,
138
+ "includeScreenshot": true,
136
139
  "logLines": 200,
137
- "platform": "android | ios",
140
+ "platform": "android",
138
141
  "appId": "optional package/bundle id to scope logs",
139
142
  "deviceId": "optional device serial/udid",
140
143
  "sessionId": "optional log stream session id to prefer"
@@ -152,17 +155,17 @@ Behavior:
152
155
  - `semantic` is optional, derived from `raw`, and intended for planning only.
153
156
  - `raw` now includes `snapshot_revision`, `captured_at_ms`, and `loading_state` when detectable.
154
157
 
155
- Response (example):
158
+ Response (selected fields):
156
159
 
157
160
  ```json
158
161
  {
159
162
  "raw": {
160
- "timestamp": 1710000000,
163
+ "timestamp": 1710000000000,
161
164
  "reason": "Crash after tapping checkout",
162
165
  "activity": "CheckoutActivity",
163
166
  "fingerprint": "abc123",
164
167
  "screenshot": "<base64 PNG string>",
165
- "ui_tree": { ... },
168
+ "ui_tree": { "elements": [] },
166
169
  "logs": [ { "timestamp": "2024-03-09T12:00:00.000Z", "level": "ERROR", "tag": "CheckoutViewModel", "pid": 1234, "message": "NullPointerException at CheckoutViewModel" } ]
167
170
  },
168
171
  "semantic": {
@@ -214,12 +217,41 @@ Guidance:
214
217
  ---
215
218
 
216
219
  ## start_log_stream / read_log_stream / stop_log_stream
217
- Start a background adb logcat stream and retrieve parsed NDJSON entries.
220
+ Start an app-scoped background stream on Android (`adb logcat`) or an iOS
221
+ simulator (`xcrun simctl ... log stream`). Start with `start_log_stream`:
222
+
223
+ ```json
224
+ {
225
+ "platform": "android",
226
+ "deviceId": "emulator-5554",
227
+ "packageName": "com.example.app",
228
+ "sessionId": "app-diagnostics",
229
+ "level": "error"
230
+ }
231
+ ```
232
+
233
+ `packageName` is required and is also used for an iOS bundle ID. `platform`
234
+ defaults to Android. Android accepts `level`: `error` (default), `warn`, `info`,
235
+ or `debug`. The iOS adapter does not use that level argument. Omitted session IDs
236
+ use `default`; supply an explicit ID to keep diagnostic streams distinct.
237
+
238
+ Pass the same session ID to `read_log_stream` and, when finished,
239
+ `stop_log_stream`:
240
+
241
+ ```json
242
+ { "sessionId": "app-diagnostics" }
243
+ ```
244
+
245
+ Use distinct session IDs across platforms: when an ID exists only on iOS, read
246
+ and stop select iOS; otherwise they select Android. Reads retain the stream's device scope.
247
+ `read_log_stream` also accepts the optional [action reference](correlated-evidence.md)
248
+ for evidence correlation. A read returns accumulated entries and any available
249
+ crash summary; reading does not itself stop the background stream.
218
250
 
219
- read_log_stream response example:
251
+ Example read response (selected fields):
220
252
 
221
253
  ```json
222
- { "entries": [ { "timestamp": "2026-03-20T...Z", "level": "ERROR", "tag": "AppTag", "pid": 1234, "message": "FATAL EXCEPTION" } ], "crash_summary": { "crash_detected": true } }
254
+ { "entries": [ { "timestamp": "2026-03-20T12:00:00Z", "level": "ERROR", "tag": "AppTag", "pid": 1234, "message": "FATAL EXCEPTION" } ], "crash_summary": { "crash_detected": true } }
223
255
  ```
224
256
 
225
257
  ## App readiness
@@ -1,7 +1,10 @@
1
- # Android system traces
1
+ # System traces for Android and iOS
2
+
3
+ [Documentation](../README.md) · [Tool reference](TOOLS.md)
2
4
 
3
5
  Use system traces to collect scheduling and system annotations around a slow
4
- interaction. Capture is optional, device-wide and Android-only; it does not
6
+ interaction. Capture is optional; Android uses device-wide Perfetto and iOS simulators use
7
+ app-attached Instruments Time Profiler. It does not
5
8
  automatically diagnose performance problems. No root or Android CLI installation
6
9
  is required. The device must provide Perfetto (Android API 29+), authorised ADB,
7
10
  tracing services, required sched/input categories, readable process identity,
@@ -9,14 +12,14 @@ base64 decoding and writable `/data/misc/perfetto-traces` storage.
9
12
 
10
13
  ## Tools
11
14
 
12
- All inputs reject unknown fields. `platform` is `android` or `ios`; iOS is
13
- unsupported and never starts capture. Optional `deviceId` uses existing device
14
- resolution; supplying one is recommended when multiple devices are connected.
15
+ All inputs reject unknown fields. `platform` is `android` or `ios`. Android's
16
+ optional `deviceId` uses existing device resolution. iOS requires an explicit
17
+ booted simulator UDID, plus `appId` for start; it never records the Mac host.
15
18
 
16
19
  | Tool | Arguments | Result |
17
20
  | --- | --- | --- |
18
- | `get_system_trace_capabilities` | `platform`, `deviceId?` | `supported`, `backend`, resolved `device`, prerequisite booleans, reasons, enabled sources, unavailable categories, limitations. No recording. |
19
- | `start_system_trace` | `platform`, `deviceId?`, `durationMs?` | Owned recording session after data-source acknowledgement. Duration is an integer 1,000–120,000 ms, default 30,000. |
21
+ | `get_system_trace_capabilities` | `platform`, `deviceId?`, `appId?`, `template?` | Common: `supported`, `backend`, resolved `device`, reasons and limitations. Android: prerequisite booleans, `enabled_sources`, `unavailable_categories`. iOS: prerequisites as `available`/`missing`/`unknown`, `discovered_templates`, `templates`, `app`, `xcode_version`, `recovery`. No recording. |
22
+ | `start_system_trace` | `platform`, `deviceId?`, `durationMs?`, `appId?`, `template?` | Owned recording session after native readiness acknowledgement. Duration is an integer 1,000–120,000 ms, default 30,000. |
20
23
  | `get_system_trace_status` | `traceId` | Reconcile process/deadline and finalise ended recording. |
21
24
  | `stop_system_trace` | `traceId` | Gracefully stop and retrieve local artifact; retry transfer/cleanup after failure. |
22
25
  | `cancel_system_trace` | `traceId` | Stop and discard partial files. Already retrieved artifacts remain local. |
@@ -24,10 +27,10 @@ resolution; supplying one is recommended when multiple devices are connected.
24
27
  Trace control IDs are UUIDs and cannot redirect to another device. One capture
25
28
  per device and four pending sessions per server are allowed. Pending failed
26
29
  cleanup reserves its slot until resolved. Terminal records with complete cleanup
27
- expire after 10 minutes or eviction beyond 100 records. Server restart invalidates
30
+ expire after 10 minutes or eviction beyond 100 records per backend (the router retains at most 100 completed IDs). Server restart invalidates
28
31
  IDs. Repeated terminal operations return the stored outcome.
29
32
 
30
- ## Agent workflow and interpretation
33
+ ## Capture workflow
31
34
 
32
35
  Trace a reproducible slow or stalled interaction when existing UI timing/state
33
36
  and logs leave a performance question unresolved. Check tool discovery first:
@@ -87,12 +90,13 @@ proof of causality; host intervals are not aligned with device trace clocks.
87
90
  ## Session response and failures
88
91
 
89
92
  JSON responses contain `trace_id`, process-scoped `session_id`, `device`,
90
- `backend:"perfetto"`, `state` (starting/recording/stopping/completed/cancelled/failed),
93
+ `backend:"perfetto"` (Android) or `"xctrace"` (iOS), `state` (starting/recording/stopping/completed/cancelled/failed),
91
94
  nullable `reason` and `completion_reason`, host UTC capture bounds, nullable
92
- `artifact`, `cleanup`, `correlation_ids`, `enabled_sources`, and
93
- `unavailable_categories`. Capture bounds include command/acknowledgement latency.
95
+ `artifact`, `cleanup`, and `correlation_ids`. Android additionally returns
96
+ `enabled_sources` and `unavailable_categories`. Capture bounds include command/acknowledgement latency.
94
97
 
95
- `artifact` contains absolute `path`, `format:"perfetto"` and `size_bytes`.
98
+ Android `artifact` contains absolute `path`, `format:"perfetto"` and `size_bytes`;
99
+ see the iOS section below for Instruments artifact and session fields.
96
100
  `cleanup` contains `status` (pending/complete/failed) and `remaining_resources`.
97
101
  Errors preserve known session metadata and set MCP `isError`. Argument/unknown-ID
98
102
  errors return `{error:{tool,code,message}}` without a session. Codes include
@@ -103,7 +107,7 @@ Capability failures return ordinary `supported:false` responses with reasons.
103
107
  Read state/cleanup independently: a successful artifact transfer can still have
104
108
  failed device-file cleanup. Retry stop/status, or cancel to discard failed output.
105
109
 
106
- ## Limits and privacy
110
+ ## Android limits and privacy
107
111
 
108
112
  The fixed preset requests sched, freq, idle, am, wm, gfx, view and input categories,
109
113
  a 16 MiB ring buffer and a 32 MiB maximum output. Missing optional categories are
@@ -124,3 +128,74 @@ shutdown attempts owned cleanup for up to 10 seconds. A server crash can leave
124
128
  a uniquely named bounded device file for manual removal; restart performs no
125
129
  broad cleanup sweep. Device suspend can extend Perfetto's own monotonic duration
126
130
  limit; the server timer bounds wall-clock lifetime while the server is running.
131
+
132
+ ## iOS simulator Instruments capture
133
+
134
+ Requires macOS, full Xcode with Instruments and clang, a booted simulator visible
135
+ in both `simctl` and `xctrace list devices`, and an already running development
136
+ app. Journey input also needs a compatible idb companion; capability discovery
137
+ for capture does not establish HID input support. The initial verified target is iPhone 17 Pro simulator / iOS 26.4.1 with
138
+ Xcode 27.2. Physical-device capture is unsupported and unrun. Tool installation,
139
+ OS profiling permissions and pairing/security changes are user actions.
140
+
141
+ ```json
142
+ {"platform":"ios","deviceId":"<simulator-UDID>","appId":"<bundle-id>","template":"Time Profiler","durationMs":60000}
143
+ ```
144
+
145
+ Use this target with capabilities and start, then bracket a `run_journey` on the
146
+ same simulator using the returned `systemTraceId`, and stop/cancel as above.
147
+ Omitting `template` defaults to Time Profiler. `appId` and `template` are rejected
148
+ on Android. Capabilities do not start capture; permissions and symbols remain
149
+ `unknown` until separately established. Installed templates are listed separately
150
+ from support: System Trace scheduling coverage is unverified, Animation Hitches
151
+ reported unsupported on the tested simulator, and Hangs is bundled within Time
152
+ Profiler rather than a selectable standalone template. No silent substitution.
153
+
154
+ The server resolves the bundle to an exact current executable/PID, pins the UDID,
155
+ and waits for a uniquely named Darwin recording-start notification before
156
+ returning `recording`. It compiles a small private listener with Xcode clang in
157
+ the owned temporary directory. A failed/uncertain start cleans up and returns a
158
+ failure, not an automatic retry. Errors such as `APP_NOT_RUNNING`,
159
+ `PROFILING_PERMISSION_REQUIRED`, `READINESS_TIMEOUT` and `TARGET_DISCONNECTED`
160
+ include bounded recovery guidance; raw recorder output is not returned.
161
+
162
+ Only the session-owned recorder is signalled; cleanup never terminates the app.
163
+ iOS readiness has a 35-second budget, stop/finalisation 30 seconds and artifact
164
+ validation 30 seconds. Recording is bounded by native duration and server
165
+ monitoring. Monitoring retains the pinned app identity and tolerates two consecutive
166
+ non-definitive command failures, resetting after a successful poll. The third
167
+ fails capture with its bounded reason (`COMMAND_FAILED`, `ACTION_TIMEOUT`, or
168
+ `TRACE_MONITOR_FAILED` for an unclassified failure). Storage limits, changed app
169
+ identity and a missing running app fail immediately. Expiry and recorder exit
170
+ are still checked after a tolerated poll failure. Shutdown attempts cancellation under an overall ten-second budget.
171
+ Failed export can be retried using stop/status without starting another recording;
172
+ cancel removes owned partial files. Completed artifacts remain for user deletion.
173
+
174
+ The `.trace` result may be a bundle/directory. `artifact` adds
175
+ `format:"instruments"`, `kind`, recursive `size_bytes`, and
176
+ `validation:{readable,schema,sample_rows}`. Validation checks a readable TOC,
177
+ matching target UUID/PID/template, `time-sample` schema and exported sample data.
178
+ Zero rows mean no CPU sample evidence. Warnings are preserved as bounded
179
+ classifications. This establishes readable capture, not successful symbolication,
180
+ working hang detection or root-cause diagnosis. Do not treat a saved failed trace
181
+ as a successful recording.
182
+
183
+ Results also include `app_id`, `pid`, `executable`, `template`,
184
+ `recording_ready_at_ms`, `warnings` and `clock_alignment:"unknown"`. The profiled
185
+ app stays pinned even if the journey navigates elsewhere; linked IDs do not prove
186
+ that other apps are captured. Start/stop during a linked journey reports partial
187
+ coverage. Host capture bounds include startup/finalisation uncertainty.
188
+
189
+ At least 1 GiB free output space is required before recording. The server checks
190
+ a 256 MiB recursive size threshold each second; this is a soft limit and can be
191
+ overshot during polling/finalisation. Oversized output fails and is discarded.
192
+ Final bundles reject symlinks and use restricted file/directory permissions.
193
+ Even app-attached capture may include sensitive system metadata, paths, symbols,
194
+ logs and signposts. Keep artifacts local and delete them when finished; no upload,
195
+ base64 response, permission bypass or restart-wide cleanup sweep occurs.
196
+
197
+ ## Related guides
198
+
199
+ - [Interaction](interact.md#interaction-execution-controls-rfc-018): run the journey being measured.
200
+ - [Evidence correlation](correlated-evidence.md): interpret action and observation timing.
201
+ - [Runtime debugger](debugger.md): inspect paused application state.
@@ -1,6 +1,11 @@
1
- # System (environment & health checks)
1
+ # Environment diagnostics
2
2
 
3
- Tools that provide a lightweight view of the local mobile debugging environment and surface issues early so agents can decide whether to proceed.
3
+ [Documentation](../README.md) · [Tool reference](TOOLS.md)
4
+
5
+ Check local toolchains and connected devices before building, installing, or
6
+ interacting with an app. If discovery cannot find a tool, configure the relevant
7
+ [path override](../../README.md#environment-setup), then check again. Once the
8
+ required platform is available, continue with [device selection](manage.md#list_devices).
4
9
 
5
10
  ## get_system_status
6
11
  A fast, non-throwing healthcheck that inspects key dependencies and connections required for mobile debugging.
@@ -11,7 +16,7 @@ Input:
11
16
  {}
12
17
  ```
13
18
 
14
- Response (example):
19
+ Response (selected fields):
15
20
 
16
21
  ```json
17
22
  {
@@ -63,13 +68,15 @@ Behavior notes:
63
68
  - Always returns structured JSON and never throws; any failures are surfaced in the `issues` array.
64
69
  - `status` gives a quick overall gate: `ready`, `degraded`, or `blocked`.
65
70
  - `summary.android`, `summary.ios`, and `summary.gradle` provide the fastest path to the actual blocker category.
66
- - Designed to be fast (<~1s probes where possible); startup callers may prefer a `fastMode` variant that only checks existence.
71
+ - The public tool accepts an empty input object; it exposes no `fastMode` option.
72
+ - Probes are best-effort and can take longer when native tooling is slow.
67
73
  - Useful to call at the start of an agent session to gate subsequent actions.
68
74
 
69
75
  Usage guidance:
70
76
  - Call before build/install flows to avoid wasted build attempts on misconfigured systems.
71
77
  - Call early in a session when device or toolchain availability is uncertain.
72
- - If `success: false`, attempt recovery steps or report issues to the user.
78
+ - `success: false` can reflect issues on a platform you are not using. Inspect the
79
+ relevant platform status and blockers before deciding whether to proceed.
73
80
 
74
81
  Recommended setup patterns:
75
82
  - Default: let the server discover tools automatically from standard locations and call `get_system_status` first to confirm what is available.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-debug-mcp",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "MCP server for mobile app debugging (Android + iOS), with focus on security and reliability",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,29 +17,33 @@
17
17
  "test:integration": "npm run test:device",
18
18
  "test:device": "npm run build && tsx test/device/index.ts",
19
19
  "test": "npm run test:unit",
20
- "lint": "eslint src test --quiet",
21
- "lint:fix": "eslint src test --fix",
20
+ "lint": "eslint src test --quiet && npm run check:quality && npm run check:architecture",
21
+ "lint:fix": "eslint src test --fix && npm run check:quality && npm run check:architecture",
22
+ "package:antigravity": "node scripts/agent-plugin.mjs --export-antigravity",
22
23
  "sync:agent-plugin": "node scripts/agent-plugin.mjs --sync",
24
+ "check:quality": "node scripts/code-quality.mjs",
25
+ "check:architecture": "node scripts/check-architecture.mjs",
23
26
  "check:agent-plugin": "node scripts/agent-plugin.mjs --check",
24
27
  "verify": "npm run lint && npm run build && npm run test:unit && npm run check:agent-plugin"
25
28
  },
26
-
27
29
  "engines": {
28
- "node": ">=18"
30
+ "node": ">=22"
29
31
  },
30
32
  "dependencies": {
31
33
  "@modelcontextprotocol/sdk": "^1.0.0",
32
34
  "fast-xml-parser": "^5.5.1",
33
- "zod": "^3.22.4",
34
- "sharp": "^0.32.1"
35
+ "sharp": "^0.35.5",
36
+ "zod": "^4.6.7"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@types/node": "^25.4.0",
38
40
  "@typescript-eslint/eslint-plugin": "^8.57.1",
39
41
  "@typescript-eslint/parser": "^8.57.1",
42
+ "archunit": "2.5.4",
40
43
  "eslint": "^9.39.4",
41
44
  "eslint-plugin-unused-imports": "^4.4.1",
42
- "tsx": "^4.21.0",
45
+ "minimist": "^1.2.8",
46
+ "tsx": "^4.23.15",
43
47
  "typescript": "^5.9.3"
44
48
  }
45
49
  }