mobile-debug-mcp 0.34.0 → 0.35.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 (432) 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/.github/copilot-instructions.md +14 -36
  11. package/.github/workflows/ci.yml +4 -4
  12. package/AGENTS.md +12 -3
  13. package/CONTRIBUTING.md +79 -0
  14. package/README.md +156 -129
  15. package/agent-plugin/.claude-plugin/plugin.json +2 -2
  16. package/agent-plugin/.codex-plugin/plugin.json +1 -1
  17. package/agent-plugin/.cursor-plugin/plugin.json +2 -2
  18. package/agent-plugin/.mcp.json +1 -1
  19. package/agent-plugin/README.md +16 -6
  20. package/agent-plugin/mcp.json +1 -1
  21. package/agent-plugin/plugin.json +1 -1
  22. package/agent-plugin/skills/mobile-debug-mcp/SKILL.md +27 -2
  23. package/dist/contracts/execution-controls.js +24 -0
  24. package/dist/contracts/selector.js +8 -0
  25. package/dist/contracts/target.js +15 -0
  26. package/dist/contracts/ui.js +1 -0
  27. package/dist/debugger/android.js +2 -1
  28. package/dist/debugger/diagnostics.js +54 -0
  29. package/dist/debugger/protocol.js +33 -0
  30. package/dist/debugger/sessions.js +104 -62
  31. package/dist/debugger/worker.js +53 -42
  32. package/dist/interact/adjustment/adjustment-context.js +41 -0
  33. package/dist/interact/adjustment/adjustment-gestures.js +55 -0
  34. package/dist/interact/adjustment/adjustment-plan.js +18 -0
  35. package/dist/interact/adjustment/adjustment-resolution.js +127 -0
  36. package/dist/interact/adjustment/adjustment-result.js +19 -0
  37. package/dist/interact/adjustment/adjustment-semantic.js +64 -0
  38. package/dist/interact/adjustment/adjustment-verification.js +35 -0
  39. package/dist/interact/adjustment/adjustment.js +52 -0
  40. package/dist/interact/adjustment/control-geometry.js +87 -0
  41. package/dist/interact/adjustment/control-values.js +136 -0
  42. package/dist/interact/adjustment/slider-labels.js +84 -0
  43. package/dist/interact/assertions/screen-assertion.js +37 -0
  44. package/dist/interact/assertions/state-assertion-context.js +35 -0
  45. package/dist/interact/assertions/state-assertion.js +76 -0
  46. package/dist/interact/assertions/state-comparison.js +141 -0
  47. package/dist/interact/assertions/visibility-assertion.js +34 -0
  48. package/dist/interact/conditional-action.js +12 -7
  49. package/dist/interact/index.js +65 -3090
  50. package/dist/interact/input-service.js +1 -0
  51. package/dist/interact/interaction-trace.js +21 -0
  52. package/dist/interact/model.js +1 -0
  53. package/dist/interact/observation.js +1 -0
  54. package/dist/interact/targeting/candidate-ancestor.js +58 -0
  55. package/dist/interact/targeting/candidate-result.js +23 -0
  56. package/dist/interact/targeting/candidate-scoring.js +50 -0
  57. package/dist/interact/targeting/element-helpers.js +216 -0
  58. package/dist/interact/targeting/find-element.js +65 -0
  59. package/dist/interact/targeting/nearby-control.js +56 -0
  60. package/dist/interact/targeting/resolved-elements.js +21 -0
  61. package/dist/interact/targeting/tap-target.js +17 -0
  62. package/dist/interact/targeting/target-scope.js +104 -0
  63. package/dist/interact/waits/legacy-log-wait.js +38 -0
  64. package/dist/interact/waits/legacy-wait-observations.js +103 -0
  65. package/dist/interact/waits/legacy-wait-state.js +34 -0
  66. package/dist/interact/waits/legacy-wait.js +48 -0
  67. package/dist/interact/waits/screen-wait.js +49 -0
  68. package/dist/interact/waits/ui-change-helpers.js +157 -0
  69. package/dist/interact/waits/ui-change-state.js +18 -0
  70. package/dist/interact/waits/ui-change-wait.js +77 -0
  71. package/dist/interact/waits/ui-wait-condition.js +56 -0
  72. package/dist/interact/waits/ui-wait-state.js +38 -0
  73. package/dist/interact/waits/ui-wait.js +106 -0
  74. package/dist/manage/android.js +55 -51
  75. package/dist/manage/index.js +38 -75
  76. package/dist/manage/ios/build-types.js +1 -0
  77. package/dist/manage/ios/build.js +210 -0
  78. package/dist/manage/ios/project-discovery.js +29 -0
  79. package/dist/manage/ios/scheme.js +18 -0
  80. package/dist/manage/ios.js +42 -256
  81. package/dist/observe/android/context.js +1 -0
  82. package/dist/observe/android/current-screen.js +55 -0
  83. package/dist/observe/android/fingerprint.js +13 -0
  84. package/dist/observe/android/log-stream.js +132 -0
  85. package/dist/observe/android/logs.js +107 -0
  86. package/dist/observe/android/screenshot.js +70 -0
  87. package/dist/observe/android/ui-tree.js +107 -0
  88. package/dist/observe/android.js +16 -520
  89. package/dist/observe/evidence.js +114 -75
  90. package/dist/observe/index.js +16 -263
  91. package/dist/observe/ios/context.js +16 -0
  92. package/dist/observe/ios/fingerprint.js +12 -0
  93. package/dist/observe/ios/log-stream.js +105 -0
  94. package/dist/observe/ios/logs.js +168 -0
  95. package/dist/observe/ios/screenshot.js +22 -0
  96. package/dist/observe/ios/ui-elements.js +241 -0
  97. package/dist/observe/ios/ui-tree.js +137 -0
  98. package/dist/observe/ios.js +17 -715
  99. package/dist/observe/logs/model.js +1 -0
  100. package/dist/{network → observe/network}/index.js +2 -2
  101. package/dist/observe/readiness-service.js +4 -2
  102. package/dist/observe/readiness.js +29 -10
  103. package/dist/observe/screenshot-encoding.js +41 -0
  104. package/dist/observe/snapshot-collection.js +79 -0
  105. package/dist/observe/snapshot-logs.js +30 -0
  106. package/dist/observe/snapshot-metadata.js +43 -31
  107. package/dist/observe/snapshot-semantic.js +115 -0
  108. package/dist/observe/system-trace.js +22 -13
  109. package/dist/runtime/action-results.js +270 -0
  110. package/dist/runtime/clock.js +4 -0
  111. package/dist/server/common.js +1 -256
  112. package/dist/server/definitions/assert.js +162 -0
  113. package/dist/server/definitions/diagnostic.js +118 -0
  114. package/dist/server/definitions/input.js +274 -0
  115. package/dist/server/definitions/manage.js +194 -0
  116. package/dist/server/definitions/observe.js +149 -0
  117. package/dist/server/definitions/target.js +138 -0
  118. package/dist/server/definitions/wait.js +105 -0
  119. package/dist/server/handlers/action-execution.js +163 -0
  120. package/dist/server/handlers/correlation.js +23 -0
  121. package/dist/server/{debugger-handlers.js → handlers/debugger-handlers.js} +22 -12
  122. package/dist/server/handlers/debugger-response.js +9 -0
  123. package/dist/server/handlers/diagnostic.js +69 -0
  124. package/dist/server/handlers/handler-types.js +1 -0
  125. package/dist/server/handlers/input.js +154 -0
  126. package/dist/server/handlers/interact.js +113 -0
  127. package/dist/server/handlers/journey-assertions.js +35 -0
  128. package/dist/server/handlers/journey.js +147 -0
  129. package/dist/server/handlers/manage.js +119 -0
  130. package/dist/server/handlers/observe.js +95 -0
  131. package/dist/server/handlers/payload.js +4 -0
  132. package/dist/server/handlers/tool-handlers.js +160 -0
  133. package/dist/server/schemas/condition-schema.js +2 -0
  134. package/dist/server/{debugger-schema.js → schemas/debugger-schema.js} +11 -6
  135. package/dist/server/{journey-schema.js → schemas/journey-schema.js} +7 -22
  136. package/dist/server/tool-definitions.js +58 -1135
  137. package/dist/server-core.js +2 -2
  138. package/dist/system/android-status.js +101 -0
  139. package/dist/system/android.js +37 -27
  140. package/dist/system/index.js +13 -439
  141. package/dist/system/ios-status.js +132 -0
  142. package/dist/system/ios.js +11 -8
  143. package/dist/system/model.js +1 -0
  144. package/dist/system/probes.js +105 -0
  145. package/dist/system/status-summary.js +43 -0
  146. package/dist/system/unsupported-status.js +52 -0
  147. package/dist/utils/android/commands.js +89 -0
  148. package/dist/utils/android/gradle.js +139 -0
  149. package/dist/utils/android/logs.js +103 -0
  150. package/dist/utils/android/ui-tree.js +233 -0
  151. package/dist/utils/android/utils.js +6 -564
  152. package/dist/utils/cli/idb/idb-helper.js +4 -6
  153. package/dist/utils/cli/idb/install-idb.js +13 -9
  154. package/dist/utils/cli/ios/preflight-ios.js +42 -38
  155. package/dist/utils/ios/utils.js +45 -46
  156. package/dist/utils/java.js +65 -49
  157. package/dist/utils/resolve-device.js +4 -2
  158. package/dist/utils/ui/index.js +26 -26
  159. package/docs/CHANGELOG.md +44 -0
  160. package/docs/README.md +38 -0
  161. package/docs/benchmarks/README.md +18 -0
  162. package/docs/benchmarks/interaction-latency/README.md +14 -0
  163. package/docs/benchmarks/interaction-latency/final.md +4 -1
  164. package/docs/benchmarks/interaction-latency/ios-validation.md +2 -0
  165. package/docs/benchmarks/ui-tree-performance/README.md +24 -16
  166. package/docs/benchmarks/ui-tree-performance/comparison.md +11 -10
  167. package/docs/code-structure.md +118 -0
  168. package/docs/specs/001-state-verification/spec.md +16 -14
  169. package/docs/specs/002-richer-element-identity/spec.md +12 -10
  170. package/docs/specs/003-wait-and-synchronization-reliability/spec.md +12 -10
  171. package/docs/specs/004-action-verification-routing/spec.md +3 -3
  172. package/docs/specs/005-unified-action-execution-and-verification-model/spec.md +2 -0
  173. package/docs/specs/006-runtime-action-instrumentation-and-binding-layer/spec.md +2 -0
  174. package/docs/specs/007-actionability-resolution-and-executable-target-selection/spec.md +3 -1
  175. package/docs/specs/008-adjustable-control-support-and-semantic-value-manipulation/spec.md +3 -4
  176. package/docs/specs/009-semantic-control-modeling-for-custom-and-composite-controls/spec.md +2 -0
  177. package/docs/specs/010-verification-stabilization-and-temporal-convergence/spec.md +2 -2
  178. package/docs/specs/011-recovery-and-replanning-for-failed-or-ambiguous-interaction-flows/spec.md +2 -2
  179. package/docs/specs/011.1-recovery-contract-types-and-runtime-wiring-spec/spec.md +2 -0
  180. package/docs/specs/012-action-trace-and-xecution-observability/spec.md +2 -3
  181. package/docs/specs/013-wait-and-synchronization-reliability/spec.md +19 -19
  182. package/docs/specs/014-actionability-resolution/spec.md +20 -18
  183. package/docs/specs/015-adjustable-control-support/spec.md +17 -15
  184. package/docs/specs/016-environment-tools/spec.md +20 -20
  185. package/docs/specs/018-interaction-latency-and-batched-journeys/spec.md +2 -0
  186. package/docs/specs/019-ui-tree-observation-performance/spec.md +3 -1
  187. package/docs/specs/020-conditional-actions/intent.md +5 -3
  188. package/docs/specs/020-conditional-actions/plan.md +8 -9
  189. package/docs/specs/020-conditional-actions/spec.md +4 -2
  190. package/docs/specs/021-app-readiness-signals/intent.md +4 -2
  191. package/docs/specs/021-app-readiness-signals/plan.md +7 -6
  192. package/docs/specs/021-app-readiness-signals/spec.md +3 -1
  193. package/docs/specs/022-correlated-evidence/intent.md +4 -4
  194. package/docs/specs/022-correlated-evidence/plan.md +10 -11
  195. package/docs/specs/022-correlated-evidence/spec.md +3 -1
  196. package/docs/specs/023-android-system-traces/intent.md +3 -2
  197. package/docs/specs/023-android-system-traces/plan.md +5 -7
  198. package/docs/specs/023-android-system-traces/spec.md +3 -1
  199. package/docs/specs/024-android-heap-dump-capture/intent.md +3 -1
  200. package/docs/specs/025-android-runtime-debugger/intent.md +4 -3
  201. package/docs/specs/025-android-runtime-debugger/plan.md +3 -1
  202. package/docs/specs/025-android-runtime-debugger/spec.md +4 -3
  203. package/docs/specs/026-code-structure-and-quality-gates/health-plan.md +88 -0
  204. package/docs/specs/026-code-structure-and-quality-gates/intent.md +47 -0
  205. package/docs/specs/026-code-structure-and-quality-gates/plan.md +191 -0
  206. package/docs/specs/026-code-structure-and-quality-gates/spec.md +138 -0
  207. package/docs/specs/026-code-structure-and-quality-gates/verification-final.json +200 -0
  208. package/docs/specs/026-code-structure-and-quality-gates/verification-thin-facade.json +154 -0
  209. package/docs/specs/026-code-structure-and-quality-gates/verification.json +136 -0
  210. package/docs/specs/027-debugger-failure-diagnostics/intent.md +43 -0
  211. package/docs/specs/027-debugger-failure-diagnostics/plan.md +86 -0
  212. package/docs/specs/027-debugger-failure-diagnostics/spec.md +133 -0
  213. package/docs/specs/028-compact-debugger-responses/intent.md +41 -0
  214. package/docs/specs/028-compact-debugger-responses/plan.md +112 -0
  215. package/docs/specs/028-compact-debugger-responses/spec.md +108 -0
  216. package/docs/specs/029-kotlin-locals-validation/report.md +119 -0
  217. package/docs/specs/030-android-coroutine-validation/evidence.json +475 -0
  218. package/docs/specs/030-android-coroutine-validation/intent.md +47 -0
  219. package/docs/specs/030-android-coroutine-validation/plan.md +147 -0
  220. package/docs/specs/030-android-coroutine-validation/report.md +240 -0
  221. package/docs/specs/030-android-coroutine-validation/spec.md +107 -0
  222. package/docs/tools/TOOLS.md +31 -18
  223. package/docs/tools/{evidence.md → correlated-evidence.md} +9 -1
  224. package/docs/tools/debugger.md +76 -0
  225. package/docs/tools/interact.md +42 -20
  226. package/docs/tools/manage.md +25 -44
  227. package/docs/tools/observe.md +55 -23
  228. package/docs/tools/system-traces.md +9 -1
  229. package/docs/tools/system.md +12 -5
  230. package/package.json +11 -8
  231. package/scripts/architecture-graph.mjs +69 -0
  232. package/scripts/check-architecture.mjs +47 -0
  233. package/scripts/code-quality-baseline.json +1 -0
  234. package/scripts/code-quality.mjs +161 -0
  235. package/src/contracts/execution-controls.ts +26 -0
  236. package/src/contracts/selector.ts +17 -0
  237. package/src/contracts/target.ts +19 -0
  238. package/src/contracts/ui.ts +94 -0
  239. package/src/debugger/android.ts +2 -1
  240. package/src/debugger/diagnostics.ts +43 -0
  241. package/src/debugger/guard.ts +6 -1
  242. package/{worker → src/debugger/java}/DebuggerWorker.java +9 -3
  243. package/src/debugger/protocol.ts +37 -0
  244. package/src/debugger/sessions.ts +314 -155
  245. package/src/debugger/worker.ts +51 -38
  246. package/src/interact/adjustment/adjustment-context.ts +83 -0
  247. package/src/interact/adjustment/adjustment-gestures.ts +48 -0
  248. package/src/interact/adjustment/adjustment-plan.ts +23 -0
  249. package/src/interact/adjustment/adjustment-resolution.ts +104 -0
  250. package/src/interact/adjustment/adjustment-result.ts +34 -0
  251. package/src/interact/adjustment/adjustment-semantic.ts +53 -0
  252. package/src/interact/adjustment/adjustment-verification.ts +60 -0
  253. package/src/interact/adjustment/adjustment.ts +49 -0
  254. package/src/interact/adjustment/control-geometry.ts +120 -0
  255. package/src/interact/adjustment/control-values.ts +141 -0
  256. package/src/interact/adjustment/slider-labels.ts +84 -0
  257. package/src/interact/assertions/screen-assertion.ts +39 -0
  258. package/src/interact/assertions/state-assertion-context.ts +48 -0
  259. package/src/interact/assertions/state-assertion.ts +64 -0
  260. package/src/interact/assertions/state-comparison.ts +168 -0
  261. package/src/interact/assertions/visibility-assertion.ts +41 -0
  262. package/src/interact/conditional-action.ts +18 -12
  263. package/src/interact/index.ts +76 -3492
  264. package/src/interact/input-service.ts +11 -0
  265. package/src/interact/interaction-trace.ts +36 -0
  266. package/src/interact/model.ts +109 -0
  267. package/src/interact/observation.ts +7 -0
  268. package/src/interact/targeting/candidate-ancestor.ts +49 -0
  269. package/src/interact/targeting/candidate-result.ts +24 -0
  270. package/src/interact/targeting/candidate-scoring.ts +42 -0
  271. package/src/interact/targeting/element-helpers.ts +243 -0
  272. package/src/interact/targeting/find-element.ts +47 -0
  273. package/src/interact/targeting/nearby-control.ts +46 -0
  274. package/src/interact/targeting/resolved-elements.ts +20 -0
  275. package/src/interact/targeting/tap-target.ts +22 -0
  276. package/src/interact/targeting/target-scope.ts +121 -0
  277. package/src/interact/waits/legacy-log-wait.ts +30 -0
  278. package/src/interact/waits/legacy-wait-observations.ts +55 -0
  279. package/src/interact/waits/legacy-wait-state.ts +48 -0
  280. package/src/interact/waits/legacy-wait.ts +34 -0
  281. package/src/interact/waits/screen-wait.ts +37 -0
  282. package/src/interact/waits/ui-change-helpers.ts +184 -0
  283. package/src/interact/waits/ui-change-state.ts +26 -0
  284. package/src/interact/waits/ui-change-wait.ts +59 -0
  285. package/src/interact/waits/ui-wait-condition.ts +52 -0
  286. package/src/interact/waits/ui-wait-state.ts +55 -0
  287. package/src/interact/waits/ui-wait.ts +84 -0
  288. package/src/manage/android.ts +56 -50
  289. package/src/manage/index.ts +63 -93
  290. package/src/manage/ios/build-types.ts +14 -0
  291. package/src/manage/ios/build.ts +230 -0
  292. package/src/manage/ios/project-discovery.ts +26 -0
  293. package/src/manage/ios/scheme.ts +16 -0
  294. package/src/manage/ios.ts +65 -298
  295. package/src/observe/android/context.ts +1 -0
  296. package/src/observe/android/current-screen.ts +63 -0
  297. package/src/observe/android/fingerprint.ts +13 -0
  298. package/src/observe/android/log-stream.ts +127 -0
  299. package/src/observe/android/logs.ts +110 -0
  300. package/src/observe/android/screenshot.ts +79 -0
  301. package/src/observe/android/ui-tree.ts +113 -0
  302. package/src/observe/android.ts +17 -531
  303. package/src/observe/evidence.ts +122 -70
  304. package/src/observe/index.ts +24 -286
  305. package/src/observe/ios/context.ts +22 -0
  306. package/src/observe/ios/fingerprint.ts +12 -0
  307. package/src/observe/ios/log-stream.ts +103 -0
  308. package/src/observe/ios/logs.ts +179 -0
  309. package/src/observe/ios/screenshot.ts +26 -0
  310. package/src/observe/ios/ui-elements.ts +266 -0
  311. package/src/observe/ios/ui-tree.ts +143 -0
  312. package/src/observe/ios.ts +18 -749
  313. package/src/observe/logs/model.ts +11 -0
  314. package/src/{network → observe/network}/index.ts +2 -2
  315. package/src/observe/readiness-service.ts +5 -3
  316. package/src/observe/readiness.ts +39 -18
  317. package/src/observe/screenshot-encoding.ts +32 -0
  318. package/src/observe/snapshot-collection.ts +69 -0
  319. package/src/observe/snapshot-logs.ts +26 -0
  320. package/src/observe/snapshot-metadata.ts +51 -31
  321. package/src/observe/snapshot-semantic.ts +153 -0
  322. package/src/observe/system-trace.ts +24 -15
  323. package/src/runtime/action-results.ts +376 -0
  324. package/src/runtime/clock.ts +9 -0
  325. package/src/server/common.ts +9 -359
  326. package/src/server/definitions/assert.ts +164 -0
  327. package/src/server/definitions/diagnostic.ts +120 -0
  328. package/src/server/definitions/input.ts +276 -0
  329. package/src/server/definitions/manage.ts +196 -0
  330. package/src/server/definitions/observe.ts +151 -0
  331. package/src/server/definitions/target.ts +140 -0
  332. package/src/server/definitions/wait.ts +107 -0
  333. package/src/server/handlers/action-execution.ts +164 -0
  334. package/src/server/handlers/correlation.ts +20 -0
  335. package/src/server/handlers/debugger-handlers.ts +39 -0
  336. package/src/server/handlers/debugger-response.ts +7 -0
  337. package/src/server/handlers/diagnostic.ts +79 -0
  338. package/src/server/handlers/handler-types.ts +7 -0
  339. package/src/server/handlers/input.ts +173 -0
  340. package/src/server/handlers/interact.ts +135 -0
  341. package/src/server/handlers/journey-assertions.ts +39 -0
  342. package/src/server/handlers/journey.ts +132 -0
  343. package/src/server/handlers/manage.ts +141 -0
  344. package/src/server/handlers/observe.ts +116 -0
  345. package/src/server/handlers/payload.ts +36 -0
  346. package/src/server/handlers/tool-handlers.ts +159 -0
  347. package/src/server/schemas/condition-schema.ts +2 -0
  348. package/src/server/{debugger-schema.ts → schemas/debugger-schema.ts} +13 -7
  349. package/src/server/{journey-schema.ts → schemas/journey-schema.ts} +7 -22
  350. package/src/server/{system-trace-schema.ts → schemas/system-trace-schema.ts} +3 -3
  351. package/src/server/tool-definitions.ts +67 -1143
  352. package/src/server-core.ts +2 -2
  353. package/src/server.ts +1 -1
  354. package/src/system/android-status.ts +124 -0
  355. package/src/system/android.ts +33 -21
  356. package/src/system/index.ts +21 -525
  357. package/src/system/ios-status.ts +147 -0
  358. package/src/system/ios.ts +14 -10
  359. package/src/system/model.ts +41 -0
  360. package/src/system/probes.ts +114 -0
  361. package/src/system/status-summary.ts +47 -0
  362. package/src/system/unsupported-status.ts +55 -0
  363. package/src/types.ts +16 -106
  364. package/src/utils/android/commands.ts +81 -0
  365. package/src/utils/android/gradle.ts +132 -0
  366. package/src/utils/android/logs.ts +103 -0
  367. package/src/utils/android/ui-tree.ts +239 -0
  368. package/src/utils/android/utils.ts +16 -556
  369. package/src/utils/cli/idb/check-idb.ts +4 -4
  370. package/src/utils/cli/idb/idb-helper.ts +6 -8
  371. package/src/utils/cli/idb/install-idb.ts +15 -9
  372. package/src/utils/cli/ios/preflight-ios.ts +39 -31
  373. package/src/utils/cli/ios/run-ios-ui-tree-tap.ts +4 -4
  374. package/src/utils/ios/utils.ts +57 -61
  375. package/src/utils/java.ts +62 -43
  376. package/src/utils/resolve-device.ts +9 -6
  377. package/src/utils/ui/index.ts +28 -28
  378. package/test/device/automated/debugger/coroutine-lifecycle.ts +27 -0
  379. package/test/device/automated/debugger/coroutine-support.ts +140 -0
  380. package/test/device/automated/debugger/coroutine.android.test.ts +169 -0
  381. package/test/device/automated/debugger/kotlin.android.test.ts +127 -0
  382. package/test/device/automated/debugger/runtime.android.test.ts +19 -3
  383. package/test/device/automated/interact/interaction.android.test.ts +56 -0
  384. package/test/device/automated/observe/system-trace.smoke.ts +1 -1
  385. package/test/device/manual/interact/modul8_selector_tap.manual.ts +1 -1
  386. package/test/fixtures/contracts/tool-definitions.json +3536 -0
  387. package/test/fixtures/coroutine-app/MainActivity.kt +100 -0
  388. package/test/fixtures/coroutine-app/README.md +48 -0
  389. package/test/fixtures/coroutine-app/build.ts +35 -0
  390. package/test/fixtures/debugger-app/MainActivity.java +21 -0
  391. package/test/fixtures/debugger-app/MainActivity.kt +32 -0
  392. package/test/fixtures/debugger-app/README.md +52 -0
  393. package/test/fixtures/debugger-app/build.ts +25 -15
  394. package/test/fixtures/latency-journey-app/README.md +2 -0
  395. package/test/fixtures/readiness-app/README.md +2 -0
  396. package/test/unit/debugger/coroutine-lifecycle.test.ts +43 -0
  397. package/test/unit/debugger/diagnostic-sessions.test.ts +67 -0
  398. package/test/unit/debugger/diagnostics.test.ts +80 -0
  399. package/test/unit/debugger/guards.test.ts +4 -0
  400. package/test/unit/debugger/preparation.test.ts +32 -0
  401. package/test/unit/debugger/protocol.test.ts +15 -0
  402. package/test/unit/debugger/sessions.test.ts +1 -1
  403. package/test/unit/interact/adjustment_service.test.ts +42 -0
  404. package/test/unit/interact/adjustment_verification.test.ts +35 -0
  405. package/test/unit/interact/clock_dependencies.test.ts +63 -0
  406. package/test/unit/interact/element_helpers.test.ts +19 -0
  407. package/test/unit/interact/legacy_wait_service.test.ts +17 -0
  408. package/test/unit/interact/state_comparison.test.ts +20 -0
  409. package/test/unit/interact/target_scope.test.ts +35 -0
  410. package/test/unit/network/get_network_activity.test.ts +1 -1
  411. package/test/unit/observe/screenshot-encoding.test.ts +30 -0
  412. package/test/unit/observe/snapshot-logs.test.ts +14 -0
  413. package/test/unit/quality/architecture.test.ts +60 -0
  414. package/test/unit/quality/code-quality.test.ts +58 -0
  415. package/test/unit/quality/interaction_boundaries.test.ts +24 -0
  416. package/test/unit/server/conditional_actions.test.ts +1 -1
  417. package/test/unit/server/conditional_schema.test.ts +2 -2
  418. package/test/unit/server/debugger-response.test.ts +63 -0
  419. package/test/unit/server/tool_definitions_parity.test.ts +8 -0
  420. package/dist/server/tool-handlers.js +0 -1000
  421. package/docs/ROADMAP.md +0 -646
  422. package/docs/benchmarks/ui-tree-performance/bridge-probe.json +0 -29
  423. package/docs/benchmarks/ui-tree-performance/initial-baseline.json +0 -59560
  424. package/docs/specs/baseline-spec-v0.md +0 -312
  425. package/docs/specs/mcp-tooling-spec-v1.md +0 -446
  426. package/src/server/debugger-handlers.ts +0 -29
  427. package/src/server/tool-handlers.ts +0 -1008
  428. /package/dist/{server/condition-schema.js → contracts/condition.js} +0 -0
  429. /package/dist/server/{readiness-schema.js → schemas/readiness-schema.js} +0 -0
  430. /package/dist/server/{system-trace-schema.js → schemas/system-trace-schema.js} +0 -0
  431. /package/src/{server/condition-schema.ts → contracts/condition.ts} +0 -0
  432. /package/src/server/{readiness-schema.ts → schemas/readiness-schema.ts} +0 -0
@@ -1,1150 +1,73 @@
1
- import { debuggerTools } from './debugger-schema.js'
2
- import { systemTraceTools } from './system-trace-schema.js'
3
- import { journeyStepsJson } from './journey-schema.js'
4
- import { conditionalTools, expectedStateJson } from './condition-schema.js'
5
- import { readinessPropertiesJson } from './readiness-schema.js'
6
-
7
- export const toolDefinitions: any[] = [
8
- ...debuggerTools,
9
- ...systemTraceTools,
10
- ...['get_app_readiness', 'wait_for_app_ready'].map(name => ({
1
+ import { verificationModeJson, responseModeJson } from '../contracts/execution-controls.js'
2
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js'
3
+ import { manageTools } from './definitions/manage.js'
4
+ import { observeTools } from './definitions/observe.js'
5
+ import { diagnosticTools } from './definitions/diagnostic.js'
6
+ import { waitTools } from './definitions/wait.js'
7
+ import { assertTools } from './definitions/assert.js'
8
+ import { targetTools } from './definitions/target.js'
9
+ import { inputTools } from './definitions/input.js'
10
+ import { debuggerTools } from './schemas/debugger-schema.js'
11
+ import { systemTraceTools } from './schemas/system-trace-schema.js'
12
+ import { journeyStepsJson } from './schemas/journey-schema.js'
13
+ import { conditionalTools, expectedStateJson } from './schemas/condition-schema.js'
14
+ import { readinessPropertiesJson } from './schemas/readiness-schema.js'
15
+
16
+ const baseTools = new Map([...manageTools, ...observeTools, ...diagnosticTools, ...waitTools, ...assertTools, ...targetTools, ...inputTools].map(tool => [tool.name, tool]))
17
+ const baseOrder = [
18
+ "start_app",
19
+ "terminate_app",
20
+ "restart_app",
21
+ "reset_app_data",
22
+ "install_app",
23
+ "build_app",
24
+ "get_logs",
25
+ "list_devices",
26
+ "get_system_status",
27
+ "capture_screenshot",
28
+ "capture_debug_snapshot",
29
+ "start_log_stream",
30
+ "read_log_stream",
31
+ "stop_log_stream",
32
+ "get_ui_tree",
33
+ "get_current_screen",
34
+ "get_screen_fingerprint",
35
+ "wait_for_screen_change",
36
+ "wait_for_ui_change",
37
+ "expect_screen",
38
+ "expect_element_visible",
39
+ "expect_state",
40
+ "adjust_control",
41
+ "wait_for_ui",
42
+ "find_element",
43
+ "tap",
44
+ "tap_element",
45
+ "swipe",
46
+ "scroll_to_element",
47
+ "type_text",
48
+ "press_back",
49
+ "classify_action_outcome",
50
+ "run_journey",
51
+ "get_network_activity"
52
+ ]
53
+ export const toolDefinitions: Tool[] = [
54
+ ...debuggerTools,
55
+ ...systemTraceTools,
56
+ ...['get_app_readiness', 'wait_for_app_ready'].map(name => ({
11
57
  name,
12
58
  description: `${name === 'get_app_readiness' ? 'Observe readiness with at most two fresh UI-tree samples.' : 'Wait within a single bounded budget for settled UI evidence.'} Reports loading, transitioning, settled or unknown with evidence and limitations. Managed Android debugger pauses are reported from debugger evidence; unresponsive detection remains unsupported. Settled normalized foreground UI is not proof of app identity, responsiveness or backend completion.`,
13
- inputSchema: { type: 'object', additionalProperties: false, required: ['platform'], properties: {
59
+ inputSchema: { type: 'object' as const, additionalProperties: false, required: ['platform'], properties: {
14
60
  ...readinessPropertiesJson,
15
61
  timeoutMs: { ...readinessPropertiesJson.timeoutMs, default: name === 'get_app_readiness' ? 15000 : 30000 },
16
62
  ...(name === 'wait_for_app_ready' ? { pollIntervalMs: { type: 'integer', minimum: 100, maximum: 1000, default: 500 } } : {})
17
63
  } }
18
64
  })),
19
- {
20
- name: 'start_app',
21
- description: `Purpose:
22
- Launch a mobile app on Android or iOS.
23
-
24
- Inputs:
25
- - platform
26
- - appId
27
- - deviceId (optional)
28
-
29
- Output Structure:
30
- - action_id, timestamp (ISO 8601), action_type
31
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
32
- - source_module: runtime source of the action envelope
33
- - target.selector = { appId }
34
- - success = true when launch was dispatched successfully
35
- - failure_code/retryable when launch dispatch fails
36
- - ui_fingerprint_before/ui_fingerprint_after when available
37
-
38
- Recommended Usage:
39
- 1. Define the expected landing screen when it is known
40
- 2. Call start_app
41
- 3. If needed, wait for transition using wait_for_*
42
- 4. Verify with expect_screen
43
- 5. If verification fails, retry once or capture a snapshot
44
-
45
- Verification Guidance:
46
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
47
- - expect_screen is the authoritative verification step when the landing screen is known
48
- - Do not treat timing or screen change alone as final verification
49
-
50
- Failure Handling:
51
- - TIMEOUT → retry once
52
- - UNKNOWN → inspect snapshot/logs before retrying`,
53
- inputSchema: {
54
- type: 'object',
55
- properties: {
56
- platform: {
57
- type: 'string',
58
- enum: ['android', 'ios']
59
- },
60
- appId: {
61
- type: 'string',
62
- description: 'Android package name or iOS bundle id'
63
- },
64
- deviceId: {
65
- type: 'string',
66
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
67
- },
68
- verificationMode: { type: 'string', enum: ['none', 'light', 'full'], default: 'full' },
69
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'debug' },
70
- actionTimeoutMs: { type: 'number', minimum: 100, maximum: 30000 },
71
- verificationTimeoutMs: { type: 'number', minimum: 100, maximum: 60000 }
72
- },
73
- required: ['platform', 'appId']
74
- }
75
- },
76
- {
77
- name: 'terminate_app',
78
- description: 'Terminate a mobile app on Android or iOS simulator',
79
- inputSchema: {
80
- type: 'object',
81
- properties: {
82
- platform: {
83
- type: 'string',
84
- enum: ['android', 'ios']
85
- },
86
- appId: {
87
- type: 'string',
88
- description: 'Android package name or iOS bundle id'
89
- },
90
- deviceId: {
91
- type: 'string',
92
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
93
- }
94
- },
95
- required: ['platform', 'appId']
96
- }
97
- },
98
- {
99
- name: 'restart_app',
100
- description: `Purpose:
101
- Restart a mobile app on Android or iOS.
102
-
103
- Inputs:
104
- - platform
105
- - appId
106
- - deviceId (optional)
107
-
108
- Output Structure:
109
- - action_id, timestamp (ISO 8601), action_type
110
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
111
- - source_module: runtime source of the action envelope
112
- - target.selector = { appId }
113
- - success = true when the restart command completed
114
- - failure_code/retryable when restart dispatch fails
115
- - ui_fingerprint_before/ui_fingerprint_after when available
116
-
117
- Recommended Usage:
118
- 1. Define the expected landing screen when it is known
119
- 2. Call restart_app
120
- 3. If needed, wait for transition using wait_for_*
121
- 4. Verify with expect_screen
122
- 5. If verification fails, retry once or capture a snapshot
123
-
124
- Verification Guidance:
125
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
126
- - expect_screen is the authoritative verification step when the reopened screen is known
127
- - Do not treat timing or screen change alone as final verification
128
-
129
- Failure Handling:
130
- - TIMEOUT → retry once
131
- - UNKNOWN → inspect snapshot/logs before retrying`,
132
- inputSchema: {
133
- type: 'object',
134
- properties: {
135
- platform: {
136
- type: 'string',
137
- enum: ['android', 'ios']
138
- },
139
- appId: {
140
- type: 'string',
141
- description: 'Android package name or iOS bundle id'
142
- },
143
- deviceId: {
144
- type: 'string',
145
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
146
- }
147
- },
148
- required: ['platform', 'appId']
149
- }
150
- },
151
- {
152
- name: 'reset_app_data',
153
- description: 'Reset app data (clear storage) for a mobile app on Android or iOS simulator',
154
- inputSchema: {
155
- type: 'object',
156
- properties: {
157
- platform: {
158
- type: 'string',
159
- enum: ['android', 'ios']
160
- },
161
- appId: {
162
- type: 'string',
163
- description: 'Android package name or iOS bundle id'
164
- },
165
- deviceId: {
166
- type: 'string',
167
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
168
- }
169
- },
170
- required: ['platform', 'appId']
171
- }
172
- },
173
- {
174
- name: 'install_app',
175
- description: 'Install an app on Android or iOS. Accepts a built binary (apk/.ipa/.app) or a project directory to build then install. platform and projectType are required.',
176
- inputSchema: {
177
- type: 'object',
178
- properties: {
179
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Platform to install to (required).' },
180
- projectType: { type: 'string', enum: ['native', 'kmp', 'react-native', 'flutter'], description: 'Project type to guide build/install tool selection (required).' },
181
- appPath: { type: 'string', description: 'Path to APK, .app, .ipa, or project directory' },
182
- deviceId: { type: 'string', description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.' }
183
- },
184
- required: ['platform', 'projectType', 'appPath']
185
- }
186
- },
187
- {
188
- name: 'build_app',
189
- description: 'Build a project for Android or iOS and return the built artifact path. Does not install. platform and projectType are required.',
190
- inputSchema: {
191
- type: 'object',
192
- properties: {
193
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Platform to build for (required).' },
194
- projectType: { type: 'string', enum: ['native', 'kmp', 'react-native', 'flutter'], description: 'Project type to guide build tool selection (required).' },
195
- projectPath: { type: 'string', description: 'Path to project directory (contains gradlew or xcodeproj/xcworkspace)' },
196
- variant: { type: 'string', description: 'Optional build variant (e.g., Debug/Release)' }
197
- },
198
- required: ['platform', 'projectType', 'projectPath']
199
- }
200
- },
201
- {
202
- name: 'get_logs',
203
- description: 'Get recent logs from Android or iOS simulator. Returns device metadata and structured logs suitable for AI consumption.',
204
- inputSchema: {
205
- type: 'object',
206
- properties: {
207
- platform: {
208
- type: 'string',
209
- enum: ['android', 'ios']
210
- },
211
- appId: {
212
- type: 'string',
213
- description: 'Filter by Android package name or iOS bundle id'
214
- },
215
- deviceId: {
216
- type: 'string',
217
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
218
- },
219
- pid: { type: 'number', description: 'Filter by process id' },
220
- tag: { type: 'string', description: 'Filter by tag (Android) or subsystem/category (iOS)' },
221
- level: { type: 'string', description: 'Log level filter (VERBOSE, DEBUG, INFO, WARN, ERROR)' },
222
- contains: { type: 'string', description: 'Substring to match in log message' },
223
- since_seconds: { type: 'number', description: 'Only return logs from the last N seconds' },
224
- limit: { type: 'number', description: 'Override default number of returned lines' },
225
- lines: {
226
- type: 'number',
227
- description: 'Legacy - number of log lines (android only)'
228
- }
229
- },
230
- required: ['platform']
231
- }
232
- },
233
- {
234
- name: 'list_devices',
235
- description: 'List connected devices and their metadata (android + ios).',
236
- inputSchema: {
237
- type: 'object',
238
- properties: {
239
- platform: { type: 'string', enum: ['android', 'ios'] }
240
- }
241
- }
242
- },
243
- {
244
- name: 'get_system_status',
245
- description: 'Quick healthcheck of local mobile debugging environment (adb, devices, logs, env, iOS).',
246
- inputSchema: { type: 'object', properties: {} }
247
- },
248
- {
249
- name: 'capture_screenshot',
250
- description: 'Capture a screenshot from an Android device or iOS simulator. Returns device metadata and the screenshot image.',
251
- inputSchema: {
252
- type: 'object',
253
- properties: {
254
- platform: {
255
- type: 'string',
256
- enum: ['android', 'ios']
257
- },
258
- deviceId: {
259
- type: 'string',
260
- description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.'
261
- }
262
- },
263
- required: ['platform']
264
- }
265
- },
266
- {
267
- name: 'capture_debug_snapshot',
268
- description: 'Capture a complete debug snapshot (raw observation layer plus optional derived semantic layer). Returns structured JSON with snapshot_revision, captured_at_ms, snapshot_delta, and loading_state when detectable.',
269
- inputSchema: {
270
- type: 'object',
271
- properties: {
272
- reason: { type: 'string', description: 'Optional reason for snapshot' },
273
- includeLogs: { type: 'boolean', description: 'Whether to include logs', default: true },
274
- includeScreenshot: { type: 'boolean', description: 'Whether to collect screenshot bytes', default: true },
275
- logLines: { type: 'number', description: 'Maximum number of log lines to include', default: 200 },
276
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
277
- appId: { type: 'string', description: 'Optional appId to scope logs (package/bundle id)' },
278
- deviceId: { type: 'string', description: 'Optional device serial/udid' },
279
- sessionId: { type: 'string', description: 'Optional log stream session id to prefer' }
280
- }
281
- }
282
- },
283
- {
284
- name: 'start_log_stream',
285
- description: 'Start streaming logs for a target application on Android or iOS. For Android this uses adb logcat --pid=<pid>; for iOS it streams `xcrun simctl spawn <device> log stream` with a predicate.',
286
- inputSchema: {
287
- type: 'object',
288
- properties: {
289
- platform: { type: 'string', enum: ['android', 'ios'], default: 'android' },
290
- packageName: { type: 'string', description: 'Android package name or iOS bundle id' },
291
- level: { type: 'string', enum: ['error', 'warn', 'info', 'debug'], default: 'error' },
292
- deviceId: { type: 'string', description: 'Device Serial (Android) or UDID (iOS). Defaults to connected/booted device.' },
293
- sessionId: { type: 'string', description: 'Session identifier for the log stream' }
294
- },
295
- required: ['packageName']
296
- }
297
- },
298
- {
299
- name: 'read_log_stream',
300
- description: 'Read accumulated log stream entries for the active session.',
301
- inputSchema: {
302
- type: 'object',
303
- properties: {
304
- sessionId: { type: 'string' }
305
- }
306
- }
307
- },
308
- {
309
- name: 'stop_log_stream',
310
- description: 'Stop an active log stream for the session.',
311
- inputSchema: {
312
- type: 'object',
313
- properties: {
314
- sessionId: { type: 'string' }
315
- }
316
- }
317
- },
318
- {
319
- name: 'get_ui_tree',
320
- description: 'Get the current UI hierarchy from an Android device or iOS simulator. Returns a structured JSON representation of the screen content with snapshot metadata and incremental delta signals when available.',
321
- inputSchema: {
322
- type: 'object',
323
- properties: {
324
- platform: {
325
- type: 'string',
326
- enum: ['android', 'ios'],
327
- description: 'Platform to get UI tree for'
328
- },
329
- deviceId: {
330
- type: 'string',
331
- description: 'Device Serial (Android) or UDID (iOS). Defaults to connected/booted device.'
332
- },
333
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'debug' },
334
- sinceSnapshotRevision: { type: 'number', minimum: 1 }
335
- },
336
- required: ['platform']
337
- }
338
- },
339
- {
340
- name: 'get_current_screen',
341
- description: 'Get the currently visible activity on an Android device. Returns package and activity name.',
342
- inputSchema: {
343
- type: 'object',
344
- properties: {
345
- deviceId: {
346
- type: 'string',
347
- description: 'Device Serial (Android). Defaults to connected/booted device.'
348
- }
349
- }
350
- }
351
- },
352
- {
353
- name: 'get_screen_fingerprint',
354
- description: 'Generate a stable fingerprint representing the current visible screen (activity + visible UI elements).',
355
- inputSchema: {
356
- type: 'object',
357
- properties: {
358
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override (android|ios)' },
359
- deviceId: { type: 'string', description: 'Optional device id/udid to target' }
360
- }
361
- }
362
- },
363
- {
364
- name: 'wait_for_screen_change',
365
- description: `Purpose:
366
- Detect that a screen transition has occurred by waiting for the current fingerprint to differ from a previous fingerprint.
367
-
368
- Capabilities:
369
- - Synchronization for uncertain navigation timing
370
- - Detection that something changed on screen
371
-
372
- Constraints:
373
- - Does not verify correctness of the resulting state
374
- - Must not be used alone to confirm action success when an applicable expect_* tool exists
375
- - For backend/API activity without a visible UI change, pass the runtime action_type into classify_action_outcome and collect network evidence only if the result remains ambiguous
376
-
377
- Recommended Usage:
378
- 1. Capture or define the expected outcome
379
- 2. Call an action tool
380
- 3. Use wait_for_screen_change when transition timing is uncertain
381
- 4. Follow with expect_screen when the expected destination is known`,
382
- inputSchema: {
383
- type: 'object',
384
- properties: {
385
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override (android|ios)' },
386
- previousFingerprint: { type: 'string', description: 'The fingerprint to compare against (required)' },
387
- timeoutMs: { type: 'number', description: 'Timeout in ms to wait for change (default 5000)', default: 5000 },
388
- pollIntervalMs: { type: 'number', description: 'Polling interval in ms (default 300)', default: 300 },
389
- deviceId: { type: 'string', description: 'Optional device id/udid to target' }
390
- },
391
- required: ['previousFingerprint']
392
- }
393
- },
394
- {
395
- name: 'wait_for_ui_change',
396
- description: `Purpose:
397
- Wait for a non-navigation UI mutation or in-place update to become stable.
398
-
399
- Inputs:
400
- - expected_change (optional): hierarchy_diff, text_change, or state_change
401
- - timeout_ms (optional)
402
- - stability_window_ms (optional)
403
- - scope (optional): screen or subtree
404
- - target (optional): element_id when scope=subtree
405
-
406
- Guidance:
407
- - Prefer wait_for_screen_change for navigation transitions.
408
- - Prefer wait_for_ui_change for in-place mutations and non-navigation updates.
409
- - Use the returned snapshot_revision as the observed synchronization point when available.
410
- - Scoped waits return scope-aware stability metadata and a lightweight change summary.
411
-
412
- Failure Handling:
413
- - TIMEOUT means the UI did not change in a stable way within the allotted time.`,
414
- inputSchema: {
415
- type: 'object',
416
- properties: {
417
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override (android|ios)' },
418
- deviceId: { type: 'string', description: 'Optional device id/udid to target' },
419
- expected_change: { type: 'string', enum: ['hierarchy_diff', 'text_change', 'state_change'], description: 'Optional type of UI change to wait for' },
420
- scope: { type: 'string', enum: ['screen', 'subtree'], default: 'screen', description: 'Synchronization scope for the wait' },
421
- target: { type: 'string', description: 'Target element_id when scope is subtree' },
422
- timeout_ms: { type: 'number', description: 'Timeout in ms to wait for change (default 60000)', default: 60000 },
423
- stability_window_ms: { type: 'number', description: 'How long the change must remain stable before success (default 300)', default: 300 }
424
- }
425
- }
426
- },
427
- {
428
- name: 'expect_screen',
429
- description: `Purpose:
430
- Deterministically verify that the intended navigation outcome of an action has occurred.
431
-
432
- Inputs:
433
- - fingerprint: preferred exact-match screen fingerprint
434
- - screen: exact semantic screen identifier when a fingerprint is not available
435
-
436
- Output Structure:
437
- - success: true when the expected screen matches the observed screen
438
- - observed_screen: current fingerprint and screen identifier
439
- - expected_screen: the expected fingerprint and/or screen identifier
440
- - confidence: 1 for an exact match, otherwise 0
441
-
442
- Recommended Usage:
443
- 1. Define the expected screen before executing the action
444
- 2. Resolve the target element or screen state
445
- 3. Call an action tool such as tap_element
446
- 4. If needed, wait for transition using wait_for_*
447
- 5. Call expect_screen as the final verification step
448
- 6. If success=false, treat the outcome as unverified and follow the action tool retry guidance
449
-
450
- Verification Guidance:
451
- - Primary and authoritative verification tool for navigation outcomes
452
- - Prefer fingerprint whenever you have one
453
- - Use screen only as a fallback exact match against known identifiers
454
- - Works best when the expected screen identifier is known ahead of time
455
- - If the expected screen is not already known, capture or define it before executing the action
456
-
457
- Constraints:
458
- - Returns structured binary success/failure only
459
- - Must not rely on natural-language interpretation or reasoning
460
-
461
- Failure Handling:
462
- - success=false means the expected screen was not reached; retry or recover using the action tool's failure strategy`,
463
- inputSchema: {
464
- type: 'object',
465
- properties: {
466
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override (android|ios)' },
467
- fingerprint: { type: 'string', description: 'Expected screen fingerprint. Preferred verification mechanism.' },
468
- screen: { type: 'string', description: 'Expected exact screen identifier when no fingerprint is available.' },
469
- deviceId: { type: 'string', description: 'Optional device id/udid to target' }
470
- }
471
- }
472
- },
473
- {
474
- name: 'expect_element_visible',
475
- description: `Purpose:
476
- Deterministically verify that the intended UI outcome of an action has occurred by confirming a target element is visible.
477
-
478
- Inputs:
479
- - selector: required selector used to resolve the target element
480
- - element_id: optional previously resolved element identifier used only as context
481
-
482
- Output Structure:
483
- - success: true when the element is visible
484
- - selector: selector used for verification
485
- - element_id: resolved element identifier when available
486
- - element: minimal resolved element info when visible
487
- - failure_code: TIMEOUT or UNKNOWN when verification fails
488
- - retryable: true when failure_code=TIMEOUT
489
-
490
- Recommended Usage:
491
- 1. Define the expected element state before executing the action
492
- 2. Resolve the target element or triggering control
493
- 3. Call an action tool such as tap_element
494
- 4. If needed, wait for UI availability using wait_for_*
495
- 5. Call expect_element_visible as the final verification step
496
- 6. If success=false, follow the action tool retry guidance
497
-
498
- Verification Guidance:
499
- - Primary and authoritative verification tool for expected element appearance or visibility
500
- - Use this when the screen should stay the same but the UI should reveal or update a specific element
501
- - selector is the primary input; element_id is an optional optimization only
502
- - The tool resolves the selector internally when needed
503
-
504
- Constraints:
505
- - Returns structured binary success/failure only
506
- - Must not rely on natural-language interpretation or reasoning
507
-
508
- Failure Handling:
509
- - TIMEOUT → retry verification once or retry the action after re-resolving
510
- - UNKNOWN → capture a snapshot and stop`,
511
- inputSchema: {
512
- type: 'object',
513
- properties: {
514
- selector: {
515
- type: 'object',
516
- properties: {
517
- text: { type: 'string' },
518
- resource_id: { type: 'string' },
519
- accessibility_id: { type: 'string' },
520
- contains: { type: 'boolean', default: false }
521
- }
522
- },
523
- element_id: { type: 'string', description: 'Optional previously resolved element identifier.' },
524
- timeout_ms: { type: 'number', default: 5000 },
525
- poll_interval_ms: { type: 'number', default: 300 },
526
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
527
- deviceId: { type: 'string', description: 'Optional device serial/udid' }
528
- },
529
- required: ['selector']
530
- }
531
- },
532
- {
533
- name: 'expect_state',
534
- description: `Purpose:
535
- Verify a readable UI state property on the currently visible element.
536
-
537
- Inputs:
538
- - selector or element_id
539
- - property
540
- - expected
541
- - platform/deviceId (optional)
542
-
543
- Supported properties:
544
- - checked, selected, focused, expanded, enabled, text_value, value, raw_value
545
-
546
- Verification Guidance:
547
- - Use this when the UI element is visible but its state must also be confirmed
548
- - Prefer the canonical property names above
549
- - The tool compares the normalized readable state and returns the observed value when available
550
-
551
- Constraints:
552
- - Returns structured success/failure only
553
- - Does not infer a state when the property is unavailable
554
-
555
- Failure Handling:
556
- - ELEMENT_NOT_FOUND → re-resolve the element or wait for UI stabilization
557
- - UNKNOWN → capture a snapshot and stop`,
558
- inputSchema: {
559
- type: 'object',
560
- properties: {
561
- selector: {
562
- type: 'object',
563
- properties: {
564
- text: { type: 'string' },
565
- resource_id: { type: 'string' },
566
- accessibility_id: { type: 'string' },
567
- contains: { type: 'boolean', default: false }
568
- }
569
- },
570
- element_id: { type: 'string', description: 'Optional previously resolved element identifier.' },
571
- property: { type: 'string', description: 'Readable state property to verify.' },
572
- expected: {
573
- description: 'Expected normalized state value.',
574
- oneOf: [
575
- { type: 'boolean' },
576
- { type: 'number' },
577
- { type: 'string' },
578
- { type: 'object' }
579
- ]
580
- },
581
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
582
- deviceId: { type: 'string', description: 'Optional device serial/udid' }
583
- },
584
- required: ['property', 'expected']
585
- }
586
- },
587
- {
588
- name: 'adjust_control',
589
- description: `Purpose:
590
- Adjust a numeric control value with verification.
591
-
592
- This is the initial adjustable-control surface for slider-like controls and other controls that expose a numeric value or value_range.
593
-
594
- Inputs:
595
- - exactly one of selector or element_id
596
- - property (defaults to "value")
597
- - targetValue
598
- - tolerance (optional; discrete default is 0, continuous default is max(step / 2, 1% of range) when omitted)
599
- - maxAttempts (optional; defaults to 5)
600
- - platform/deviceId (optional)
601
-
602
- Output Structure:
603
- - action_id, timestamp (ISO 8601), action_type
604
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
605
- - source_module: runtime source of the action envelope
606
- - target_state / actual_state / within_tolerance / converged / attempts / adjustment_mode
607
- - target.selector = original selector or element handle
608
- - success = true when the control converges within tolerance
609
-
610
- Verification Guidance:
611
- - Prefer direct platform adjustment when the runtime exposes it; then verified increment/decrement actions; use coordinate fallback only as degraded mode
612
- - Use expect_state for the control value readback
613
- - Do not use derived semantic metadata as proof of success
614
-
615
- Failure Handling:
616
- - ELEMENT_NOT_FOUND → re-resolve the control
617
- - ELEMENT_NOT_INTERACTABLE → the control cannot be adjusted through the current runtime
618
- - CONTROL_CONVERGENCE_FAILED → the control did not converge within bounded retries or the requested value is out of range
619
- - UNKNOWN → capture a snapshot and stop`,
620
- inputSchema: {
621
- type: 'object',
622
- properties: {
623
- selector: {
624
- type: 'object',
625
- properties: {
626
- text: { type: 'string' },
627
- resource_id: { type: 'string' },
628
- accessibility_id: { type: 'string' },
629
- contains: { type: 'boolean', default: false }
630
- }
631
- },
632
- element_id: { type: 'string', description: 'Optional previously resolved element identifier.' },
633
- property: { type: 'string', description: 'Readable numeric state property to adjust.', default: 'value' },
634
- targetValue: { type: 'number', description: 'Target numeric value.' },
635
- tolerance: { type: 'number', description: 'Accepted numeric tolerance around the target value. Defaults are derived from the readable control domain.' },
636
- maxAttempts: { type: 'number', description: 'Maximum adjustment attempts.', default: 5 },
637
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
638
- deviceId: { type: 'string', description: 'Optional device serial/udid' }
639
- },
640
- required: ['targetValue'],
641
- oneOf: [
642
- { required: ['selector'] },
643
- { required: ['element_id'] }
644
- ]
645
- }
646
- },
647
- {
648
- name: 'wait_for_ui',
649
- description: `Purpose:
650
- Resolve elements and/or detect that a UI transition or availability condition has occurred.
651
-
652
- Capabilities:
653
- - Deterministic element resolution
654
- - Synchronization when element timing or availability is uncertain
655
-
656
- Constraints:
657
- - Does not verify correctness of the resulting state
658
- - Must not be used alone to confirm action success when an applicable expect_* tool exists
659
-
660
- Recommended Usage:
661
- 1. Use wait_for_ui to resolve an element before acting or to wait for UI readiness
662
- 2. Call the action tool
663
- 3. If the expected outcome is known, follow with expect_* as final verification`,
664
- inputSchema: {
665
- type: 'object',
666
- properties: {
667
- selector: {
668
- type: 'object',
669
- properties: {
670
- text: { type: 'string' },
671
- resource_id: { type: 'string' },
672
- accessibility_id: { type: 'string' },
673
- contains: { type: 'boolean', description: 'When true, perform substring matching', default: false }
674
- }
675
- },
676
- condition: { type: 'string', enum: ['exists', 'not_exists', 'visible', 'clickable'], default: 'exists' },
677
- timeout_ms: { type: 'number', default: 60000 },
678
- poll_interval_ms: { type: 'number', default: 300 },
679
- match: { type: 'object', properties: { index: { type: 'number' } } },
680
- retry: { type: 'object', properties: { max_attempts: { type: 'number', default: 1 }, backoff_ms: { type: 'number', default: 0 } } },
681
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
682
- deviceId: { type: 'string', description: 'Optional device serial/udid' }
683
- }
684
- }
685
- },
686
- {
687
- name: 'find_element',
688
- description: `Find a UI element by semantic query (text, content-desc, resource-id, class).
689
-
690
- Returns the best match plus resolution metadata when available, including confidence, selection reason, and fallback alternates.`,
691
- inputSchema: {
692
- type: 'object',
693
- properties: {
694
- query: { type: 'string', description: 'Search query (text or label)' },
695
- exact: { type: 'boolean', description: 'Require exact match (true/false)', default: false },
696
- timeoutMs: { type: 'number', description: 'Timeout in ms to keep searching', default: 3000 },
697
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Optional platform override' },
698
- deviceId: { type: 'string', description: 'Optional device serial/udid' }
699
- },
700
- required: ['query']
701
- }
702
- },
703
- {
704
- name: 'tap',
705
- description: `Purpose:
706
- Dispatch a tap at specific screen coordinates.
707
-
708
- Inputs:
709
- - x, y coordinates
710
- - platform (optional)
711
- - deviceId (optional)
712
-
713
- Output Structure:
714
- - action_id, timestamp (ISO 8601), action_type
715
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
716
- - source_module: runtime source of the action envelope
717
- - target.selector = { x, y }
718
- - success = true when the tap was dispatched
719
- - failure_code/retryable when dispatch fails
720
- - ui_fingerprint_before/ui_fingerprint_after when available
721
-
722
- Recommended Usage:
723
- 1. Resolve coordinates deterministically
724
- 2. Call tap
725
- 3. If needed, wait for transition using wait_for_*
726
- 4. Verify with expect_screen or expect_element_visible depending on the intended outcome
727
-
728
- Verification Guidance:
729
- - Prefer tap_element over tap when an element can be resolved
730
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
731
- - Use expect_screen for navigation and expect_element_visible for local UI changes
732
- - Do not use wait_for_* alone as final verification when an applicable expect_* tool exists
733
-
734
- Failure Handling:
735
- - TIMEOUT → retry once
736
- - UNKNOWN → capture a snapshot and stop`,
737
- inputSchema: {
738
- type: 'object',
739
- properties: {
740
- platform: {
741
- type: 'string',
742
- enum: ['android', 'ios'],
743
- description: 'Platform to tap on'
744
- },
745
- x: {
746
- type: 'number',
747
- description: 'X coordinate'
748
- },
749
- y: {
750
- type: 'number',
751
- description: 'Y coordinate'
752
- },
753
- deviceId: {
754
- type: 'string',
755
- description: 'Device Serial/UDID. Defaults to connected/booted device.'
756
- },
757
- verificationMode: { type: 'string', enum: ['none', 'light', 'full'], default: 'full' },
758
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'debug' },
759
- actionTimeoutMs: { type: 'number', minimum: 100, maximum: 30000 },
760
- verificationTimeoutMs: { type: 'number', minimum: 100, maximum: 60000 }
761
- },
762
- required: ['x', 'y']
763
- }
764
- },
765
- {
766
- name: 'tap_element',
767
- description: `Purpose:
768
- Tap a previously resolved UI element using its elementId.
769
-
770
- Inputs:
771
- - elementId: a resolved UI element identifier returned by wait_for_ui
772
-
773
- Output Structure:
774
- - action_id: unique timestamp-based action identifier
775
- - timestamp: ISO 8601 timestamp for the action attempt
776
- - action_type: "tap_element"
777
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
778
- - source_module: runtime source of the action envelope
779
- - target.selector: original target handle ({ elementId })
780
- - target.resolved: minimal resolved element info used for the tap
781
- - success: true when the tap was dispatched
782
- - failure_code: present when success=false
783
- - retryable: present when failure_code exists
784
- - ui_fingerprint_before/ui_fingerprint_after: optional fingerprints captured around the action
785
-
786
- Recommended Usage:
787
- 1. Resolve the target with wait_for_ui or another deterministic resolver
788
- 2. Call tap_element
789
- 3. If needed, wait for transition using wait_for_*
790
- 4. Verify outcome using expect_*
791
- - use expect_screen when navigation is expected
792
- - use expect_element_visible when the UI change is local
793
- 5. If verification fails, inspect failure_code and follow the retry strategy below
794
-
795
- Verification Guidance:
796
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
797
- - Prefer expect_screen for navigation or modal transitions
798
- - Prefer expect_element_visible when the tap should reveal or update a specific element
799
- - wait_for_* may be used for resolution and synchronization, but not as the final verification step when an applicable expect_* tool exists
800
- - Do not treat tap_element.success as outcome success; it only means the tap was executed
801
-
802
- Failure Handling:
803
- - STALE_REFERENCE → re-resolve the element, then retry
804
- - ELEMENT_NOT_INTERACTABLE → wait or refine the target, then retry
805
- - UNKNOWN → capture a snapshot and stop
806
-
807
- This tool reports execution success only. Verification must be done with a separate expect_* tool.`,
808
- inputSchema: {
809
- type: 'object',
810
- properties: {
811
- elementId: {
812
- type: 'string',
813
- description: 'A unique element identifier returned by wait_for_ui'
814
- },
815
- selector: { type: 'object', properties: { text: { type: 'string' }, resource_id: { type: 'string' }, accessibility_id: { type: 'string' }, contains: { type: 'boolean' } } },
816
- waitFor: { type: 'object', properties: { condition: { type: 'string', enum: ['exists', 'visible', 'clickable'] }, timeoutMs: { type: 'number', minimum: 100, maximum: 10000 }, pollIntervalMs: { type: 'number', minimum: 50, maximum: 1000 }, match: { type: 'object', properties: { index: { type: 'number' } } } } },
817
- platform: { type: 'string', enum: ['android', 'ios'] },
818
- deviceId: { type: 'string' },
819
- verificationMode: { type: 'string', enum: ['none', 'light', 'full'], default: 'full' },
820
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'debug' }
821
- }
822
- }
823
- },
824
- {
825
- name: 'swipe',
826
- description: `Purpose:
827
- Dispatch a swipe gesture on Android or iOS.
828
-
829
- Inputs:
830
- - start and end coordinates
831
- - duration
832
- - platform/deviceId (optional)
833
-
834
- Output Structure:
835
- - action_id, timestamp (ISO 8601), action_type
836
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
837
- - source_module: runtime source of the action envelope
838
- - target.selector = { x1, y1, x2, y2, duration }
839
- - success = true when the swipe was dispatched
840
- - failure_code/retryable when dispatch fails
841
- - ui_fingerprint_before/ui_fingerprint_after when available
842
-
843
- Recommended Usage:
844
- 1. Determine swipe coordinates
845
- 2. Call swipe
846
- 3. If needed, wait for transition using wait_for_*
847
- 4. Verify with expect_screen or expect_element_visible when a deterministic outcome is expected
848
-
849
- Verification Guidance:
850
- - Swipe outcomes are less predictable; choose the most specific verifier available for the intended effect
851
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
852
- - Do not use wait_for_* alone as final verification when an applicable expect_* tool exists
853
-
854
- Failure Handling:
855
- - TIMEOUT → retry once
856
- - UNKNOWN → capture a snapshot and stop`,
857
- inputSchema: {
858
- type: 'object',
859
- properties: {
860
- platform: {
861
- type: 'string',
862
- enum: ['android', 'ios'],
863
- description: 'Platform to swipe on (android or ios)'
864
- },
865
- x1: { type: 'number', description: 'Start X coordinate' },
866
- y1: { type: 'number', description: 'Start Y coordinate' },
867
- x2: { type: 'number', description: 'End X coordinate' },
868
- y2: { type: 'number', description: 'End Y coordinate' },
869
- duration: { type: 'number', description: 'Duration in ms' },
870
- deviceId: {
871
- type: 'string',
872
- description: 'Device Serial/UDID. Defaults to connected/booted device.'
873
- }
874
- },
875
- required: ['x1', 'y1', 'x2', 'y2', 'duration']
876
- }
877
- },
878
- {
879
- name: 'scroll_to_element',
880
- description: `Purpose:
881
- Scroll until a target element becomes visible.
882
-
883
- Inputs:
884
- - platform
885
- - selector
886
- - direction, maxScrolls, scrollAmount, deviceId (optional)
887
-
888
- Output Structure:
889
- - action_id, timestamp (ISO 8601), action_type
890
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
891
- - source_module: runtime source of the action envelope
892
- - target.selector = original selector
893
- - target.resolved = minimal resolved element info when found
894
- - success = true when scrolling produced a visible target element
895
- - failure_code/retryable when the target was not reached
896
- - ui_fingerprint_before/ui_fingerprint_after when available
897
-
898
- Recommended Usage:
899
- 1. Resolve the target selector
900
- 2. Call scroll_to_element
901
- 3. If needed, wait for UI stabilization using wait_for_*
902
- 4. Verify with expect_element_visible when the expected element visibility is known
903
- 5. If success=false, follow failure handling before retrying
904
-
905
- Verification Guidance:
906
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
907
- - Use expect_element_visible when you need an explicit post-scroll confirmation
908
- - Do not use wait_for_* alone as final verification when an applicable expect_* tool exists
909
-
910
- Failure Handling:
911
- - NAVIGATION_NO_CHANGE → adjust scroll direction or stop
912
- - TIMEOUT → retry with refined selector or larger scroll budget
913
- - UNKNOWN → capture a snapshot and stop`,
914
- inputSchema: {
915
- type: 'object',
916
- properties: {
917
- platform: { type: 'string', enum: ['android', 'ios'], description: 'Platform to operate on (required)' },
918
- selector: {
919
- type: 'object',
920
- properties: {
921
- text: { type: 'string' },
922
- resourceId: { type: 'string' },
923
- contentDesc: { type: 'string' },
924
- className: { type: 'string' }
925
- }
926
- },
927
- direction: { type: 'string', enum: ['down', 'up'], default: 'down' },
928
- maxScrolls: { type: 'number', default: 10 },
929
- scrollAmount: { type: 'number', default: 0.7 },
930
- deviceId: { type: 'string', description: 'Device UDID (iOS) or Serial (Android). Defaults to booted/connected.' }
931
- },
932
- required: ['platform', 'selector']
933
- }
934
- },
935
- {
936
- name: 'type_text',
937
- description: `Purpose:
938
- Type text into the currently focused Android input field.
939
-
940
- Inputs:
941
- - text
942
- - platform/deviceId (optional)
943
-
944
- Output Structure:
945
- - action_id, timestamp (ISO 8601), action_type
946
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
947
- - source_module: runtime source of the action envelope
948
- - target.selector = { text }
949
- - success = true when text input was dispatched
950
- - failure_code/retryable when dispatch fails
951
- - ui_fingerprint_before/ui_fingerprint_after when available
952
-
953
- Recommended Usage:
954
- 1. Resolve or focus the target input first
955
- 2. Call type_text
956
- 3. If needed, wait for UI stabilization using wait_for_*
957
- 4. Verify with expect_element_visible or expect_screen, depending on the intended outcome
958
-
959
- Verification Guidance:
960
- - Prefer verifying the next expected element or screen state instead of inferring success from the text action alone
961
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
962
- - Do not use wait_for_* alone as final verification when an applicable expect_* tool exists
963
-
964
- Failure Handling:
965
- - TIMEOUT → retry once
966
- - UNKNOWN → re-focus the input or capture a snapshot`,
967
- inputSchema: {
968
- type: 'object',
969
- properties: {
970
- platform: {
971
- type: 'string',
972
- enum: ['android'],
973
- description: 'Platform to type on (currently only android supported)'
974
- },
975
- text: {
976
- type: 'string',
977
- description: 'The text to type'
978
- },
979
- deviceId: {
980
- type: 'string',
981
- description: 'Device Serial/UDID. Defaults to connected/booted device.'
982
- }
983
- },
984
- required: ['text']
985
- }
986
- },
987
- {
988
- name: 'press_back',
989
- description: `Purpose:
990
- Dispatch the Android Back action.
991
-
992
- Inputs:
993
- - platform/deviceId (optional)
994
-
995
- Output Structure:
996
- - action_id, timestamp (ISO 8601), action_type
997
- - lifecycle_state: post-dispatch lifecycle state (pending_verification or failed)
998
- - source_module: runtime source of the action envelope
999
- - target.selector = { key: "back" }
1000
- - success = true when the back action was dispatched
1001
- - failure_code/retryable when dispatch fails
1002
- - ui_fingerprint_before/ui_fingerprint_after when available
1003
-
1004
- Recommended Usage:
1005
- 1. Call press_back
1006
- 2. If needed, wait for transition using wait_for_*
1007
- 3. Verify with expect_screen when a known destination is expected
1008
- 4. If verification fails, retry once or recover explicitly
1009
-
1010
- Verification Guidance:
1011
- - Back outcomes can vary by screen, so verify against the intended destination when possible
1012
- - Follow RESOLVE → ACT → WAIT (if needed) → EXPECT
1013
- - Do not use wait_for_* alone as final verification when an applicable expect_* tool exists
1014
-
1015
- Failure Handling:
1016
- - TIMEOUT → retry once
1017
- - UNKNOWN → capture a snapshot and stop`,
1018
- inputSchema: {
1019
- type: 'object',
1020
- properties: {
1021
- platform: {
1022
- type: 'string',
1023
- enum: ['android'],
1024
- description: 'Platform (currently only android supported)'
1025
- },
1026
- deviceId: {
1027
- type: 'string',
1028
- description: 'Device Serial/UDID. Defaults to connected/booted device.'
1029
- }
1030
- }
1031
- }
1032
- },
1033
- {
1034
- name: 'classify_action_outcome',
1035
- description: `Classify the outcome of the most recent action into exactly one of: success, no_op, backend_failure, ui_failure, unknown.
1036
-
1037
- Use the runtime action result's \`action_type\` as \`actionType\` so the classifier can distinguish local-state actions from side-effect actions.
1038
- Use this when the intended outcome is not already fully verified by the UI signal alone.
1039
- For backend/API activity, compare get_screen_fingerprint before and after the action and call get_network_activity immediately after the action if the outcome is still ambiguous.
1040
-
1041
- HOW TO GATHER INPUTS before calling:
1042
- 1. Call wait_for_screen_change or compare get_screen_fingerprint before/after — set uiChanged accordingly.
1043
- 2. If you checked for a specific element with wait_for_ui, set expectedElementVisible.
1044
- 3. Pass actionType from the action response when available.
1045
- 4. Only provide networkRequests if you already collected them or want to classify a side-effect action with backend evidence.
1046
-
1047
- RULES (applied in order — stop at first match):
1048
- 1. If uiChanged=true OR expectedElementVisible=true → outcome=success
1049
- 2. If actionType is missing → outcome=unknown
1050
- 3. If any request has status=failure or retryable → outcome=backend_failure
1051
- 4. If actionType maps to a local-state action → outcome=no_op; prefer state-based verification and avoid default network fallback
1052
- 5. If actionType maps to a side-effect action and no networkRequests were supplied → outcome=unknown
1053
- 6. If no requests returned → outcome=no_op
1054
- 7. If all requests succeeded → outcome=ui_failure
1055
- 8. Otherwise → outcome=unknown
1056
-
1057
- BEHAVIOUR after outcome:
1058
- - success → continue
1059
- - no_op → retry with richer state verification or re-resolve the element
1060
- - backend_failure → stop and report the failing endpoint
1061
- - ui_failure → stop and report failure
1062
- - unknown → take one recovery step (e.g. capture_debug_snapshot), then stop`,
1063
- inputSchema: {
1064
- type: 'object',
1065
- properties: {
1066
- uiChanged: {
1067
- type: 'boolean',
1068
- description: 'true if the screen fingerprint or activity changed after the action. Use wait_for_screen_change or compare get_screen_fingerprint before and after.'
1069
- },
1070
- expectedElementVisible: {
1071
- type: 'boolean',
1072
- description: 'true if the element you expected to appear is now visible (from wait_for_ui). Omit if you did not check for a specific element.'
1073
- },
1074
- actionType: {
1075
- type: 'string',
1076
- description: 'The runtime action_type from the action response (for example tap, tap_element, swipe, type_text, press_back, start_app).'
1077
- },
1078
- networkRequests: {
1079
- type: 'array',
1080
- description: 'Optional network evidence collected after the action. Use it when the expected outcome is backend/API activity or when the UI signal is ambiguous.',
1081
- items: {
1082
- type: 'object',
1083
- properties: {
1084
- endpoint: { type: 'string', description: 'Request endpoint or full URL' },
1085
- status: { type: 'string', enum: ['success', 'failure', 'retryable'], description: 'Outcome of the request' }
1086
- },
1087
- required: ['endpoint', 'status']
1088
- }
1089
- },
1090
- hasLogErrors: {
1091
- type: 'boolean',
1092
- description: 'true if structured log errors were observed (e.g. from read_log_stream). Optional — include if you have already read logs.'
1093
- }
1094
- },
1095
- required: ['uiChanged']
1096
- }
1097
- },
1098
- {
1099
- name: 'run_journey',
1100
- description: 'Run an ordered, bounded sequence of start_app, tap, wait, and deterministic assertion steps against one device. Stops after the first failed step.',
1101
- inputSchema: {
1102
- type: 'object',
1103
- properties: {
1104
- platform: { type: 'string', enum: ['android', 'ios'] },
1105
- deviceId: { type: 'string' },
1106
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'compact' },
1107
- steps: { type: 'array', minItems: 1, maxItems: 50, items: { type: 'object', properties: { id: { type: 'string' }, type: { type: 'string', enum: ['start_app', 'tap', 'wait', 'assert'] } }, required: ['id', 'type'] } }
1108
- },
1109
- required: ['platform', 'steps']
1110
- }
1111
- },
1112
- {
1113
- name: 'get_network_activity',
1114
- description: `Returns structured network events captured from platform logs since the last action.
1115
-
1116
- Call this immediately after an action when you want backend evidence for a side-effect flow, only if the result is still ambiguous.
1117
- Do not call more than once per action.
1118
-
1119
- Events are filtered to significant (non-background) requests only.
1120
- Each event includes endpoint, method, statusCode, networkError, status, and durationMs.
1121
-
1122
- status values:
1123
- - success: HTTP 2xx or request detected with no error signal
1124
- - failure: HTTP 4xx
1125
- - retryable: HTTP 5xx, network error (timeout, dns_error, tls_error, etc.)
1126
-
1127
- Returns { requests: [], count: 0 } when no credible network signals are found.`,
1128
- inputSchema: {
1129
- type: 'object',
1130
- properties: {
1131
- platform: {
1132
- type: 'string',
1133
- enum: ['android', 'ios'],
1134
- description: 'Platform to read network logs from'
1135
- },
1136
- deviceId: {
1137
- type: 'string',
1138
- description: 'Device Serial (Android) or UDID (iOS). Defaults to connected/booted device.'
1139
- }
1140
- },
1141
- required: ['platform']
1142
- }
1143
- }
65
+ ...baseOrder.map(name => baseTools.get(name)!)
1144
66
  ]
1145
67
 
1146
68
  // Keep the additive execution controls consistent across all action tools.
1147
69
  for (const tool of toolDefinitions) {
70
+ tool.inputSchema.properties ??= {}
1148
71
  if (['wait_for_ui', 'wait_for_ui_change'].includes(tool.name)) {
1149
72
  tool.inputSchema.properties.requireReady = { type: 'boolean', default: false }
1150
73
  tool.description += '\nSet requireReady=true to require both the existing predicate and settled UI readiness, using the same fresh samples and one timeout budget. The readiness summary explains uncertainty. Default predicate semantics are unchanged.'
@@ -1154,7 +77,7 @@ for (const tool of toolDefinitions) {
1154
77
  if (conditionalTools.has(tool.name)) {
1155
78
  tool.inputSchema.properties.expectedState = expectedStateJson
1156
79
  tool.inputSchema.properties.platform ??= { type: 'string', enum: ['android'] }
1157
- tool.inputSchema.allOf = [...(tool.inputSchema.allOf ?? []), {
80
+ tool.inputSchema.allOf = [...(Array.isArray(tool.inputSchema.allOf) ? tool.inputSchema.allOf : []), {
1158
81
  if: { required: ['expectedState'] },
1159
82
  then: { required: ['platform', 'deviceId'], properties: {
1160
83
  platform: { enum: ['type_text', 'press_back'].includes(tool.name) ? ['android'] : ['android', 'ios'] },
@@ -1163,12 +86,12 @@ for (const tool of toolDefinitions) {
1163
86
  }]
1164
87
  tool.description += '\n\nConditional input: optionally supply expectedState { snapshotSessionId, snapshotRevision, timeoutMs? } from a successful get_ui_tree on the same explicit platform/deviceId. A fresh normalized UI-tree check runs immediately before input, even with verification disabled. PRECONDITION_FAILED or PRECONDITION_UNAVAILABLE means no input was dispatched; inspect condition evidence and re-observe before deciding what to do next. Compact failures include the fresh UI tree. This is not atomic with OS input delivery.'
1165
88
  } else {
1166
- tool.inputSchema.allOf = [...(tool.inputSchema.allOf ?? []), { not: { required: ['expectedState'] } }]
89
+ tool.inputSchema.allOf = [...(Array.isArray(tool.inputSchema.allOf) ? tool.inputSchema.allOf : []), { not: { required: ['expectedState'] } }]
1167
90
  }
1168
91
  if (['start_app', 'restart_app', 'tap', 'tap_element', 'swipe', 'scroll_to_element', 'type_text', 'press_back'].includes(tool.name)) {
1169
92
  Object.assign(tool.inputSchema.properties, {
1170
- verificationMode: { type: 'string', enum: ['none', 'light', 'full'], default: 'full' },
1171
- responseMode: { type: 'string', enum: ['compact', 'debug'], default: 'debug' },
93
+ verificationMode: { ...verificationModeJson, default: 'full' },
94
+ responseMode: { ...responseModeJson, default: 'debug' },
1172
95
  actionTimeoutMs: { type: 'integer', description: 'Dispatch budget in milliseconds, clamped to 100–30000.' },
1173
96
  verificationTimeoutMs: { type: 'integer', description: 'Light observation budget in milliseconds, clamped to 100–60000.' }
1174
97
  })
@@ -1178,8 +101,8 @@ for (const tool of toolDefinitions) {
1178
101
  steps: journeyStepsJson,
1179
102
  systemTraceId: { type: 'string', format: 'uuid', description: 'Explicit active same-device system trace. Invalid references prevent all journey input. Capture lifetime is controlled separately.' },
1180
103
  captureOnFailure: { type: 'boolean', default: false },
1181
- defaults: { type: 'object', additionalProperties: false, properties: {
1182
- verificationMode: { type: 'string', enum: ['none', 'light', 'full'] },
104
+ defaults: { type: 'object' as const, additionalProperties: false, properties: {
105
+ verificationMode: verificationModeJson,
1183
106
  actionTimeoutMs: { type: 'integer' }, verificationTimeoutMs: { type: 'integer' }
1184
107
  } }
1185
108
  })
@@ -1187,9 +110,10 @@ for (const tool of toolDefinitions) {
1187
110
 
1188
111
  // Correlation is explicit; an omitted reference creates an independent observation.
1189
112
  for (const tool of toolDefinitions) {
113
+ tool.inputSchema.properties ??= {}
1190
114
  if (['capture_screenshot', 'get_ui_tree', 'get_screen_fingerprint', 'capture_debug_snapshot', 'get_logs', 'read_log_stream'].includes(tool.name)) {
1191
115
  Object.assign(tool.inputSchema.properties, { actionRef: {
1192
- type: 'object', additionalProperties: false, required: ['sessionId', 'actionId'], properties: {
116
+ type: 'object' as const, additionalProperties: false, required: ['sessionId', 'actionId'], properties: {
1193
117
  sessionId: { type: 'string', minLength: 1, maxLength: 128 },
1194
118
  actionId: { type: 'string', minLength: 1, maxLength: 128 }
1195
119
  }