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