@kaeawc/auto-mobile 0.0.92 → 0.0.94

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 (257) hide show
  1. package/dist/build-info.json +12 -12
  2. package/dist/schemas/test-plan.schema.json +370 -52
  3. package/dist/src/ble-peripheral.py +153 -0
  4. package/dist/src/{chunk-r14wwk37.js → chunk-026y62r9.js} +12 -12
  5. package/dist/src/chunk-0jyfg947.js +4 -0
  6. package/dist/src/{chunk-950qcq1e.js → chunk-0zfpp1wh.js} +4 -4
  7. package/dist/src/chunk-13qxf7ym.js +7 -0
  8. package/dist/src/chunk-1scenrk7.js +4 -0
  9. package/dist/src/chunk-1vb5ph1k.js +4 -0
  10. package/dist/src/chunk-20g565q7.js +5 -0
  11. package/dist/src/chunk-21h6dhdm.js +5 -0
  12. package/dist/src/{chunk-2e6s75qv.js → chunk-25mfpthk.js} +8 -8
  13. package/dist/src/{chunk-9rkfyt6q.js → chunk-2b39zyxc.js} +3 -3
  14. package/dist/src/chunk-2gzd6wbd.js +4 -0
  15. package/dist/src/{chunk-eka89q3k.js → chunk-3dntffy9.js} +1 -1
  16. package/dist/src/chunk-3gfczcsn.js +4 -0
  17. package/dist/src/chunk-3h5jz1vb.js +9 -0
  18. package/dist/src/chunk-41zcy6b3.js +5 -0
  19. package/dist/src/chunk-47n9m2de.js +4 -0
  20. package/dist/src/chunk-4vxeq0vd.js +58 -0
  21. package/dist/src/chunk-59dx6qaf.js +4 -0
  22. package/dist/src/chunk-5sdf9y92.js +4 -0
  23. package/dist/src/chunk-5wk1t46v.js +5 -0
  24. package/dist/src/chunk-661c50hh.js +17 -0
  25. package/dist/src/chunk-68n6bjjd.js +21 -0
  26. package/dist/src/{chunk-zg67wjkh.js → chunk-69pmjdf2.js} +3 -3
  27. package/dist/src/chunk-6hrj3jt6.js +145 -0
  28. package/dist/src/{chunk-b4cxdzwy.js → chunk-6myr26wx.js} +8 -8
  29. package/dist/src/chunk-6n96k09n.js +4 -0
  30. package/dist/src/chunk-6vwrbkre.js +4 -0
  31. package/dist/src/chunk-6wk0yrab.js +4 -0
  32. package/dist/src/chunk-6yhm9een.js +4 -0
  33. package/dist/src/chunk-7k7gjg2t.js +7 -0
  34. package/dist/src/chunk-7n5fz68h.js +4 -0
  35. package/dist/src/chunk-8cvnpnbp.js +4 -0
  36. package/dist/src/chunk-8kzv7rk7.js +4 -0
  37. package/dist/src/chunk-8nj68t1v.js +167 -0
  38. package/dist/src/{chunk-r20pe1nv.js → chunk-96r3bpg7.js} +3 -3
  39. package/dist/src/chunk-97x887te.js +4 -0
  40. package/dist/src/{chunk-sz1a7p43.js → chunk-99a6tbvd.js} +1 -1
  41. package/dist/src/chunk-9p5d2994.js +5 -0
  42. package/dist/src/{chunk-w7zsh13a.js → chunk-9q265er0.js} +4 -4
  43. package/dist/src/chunk-9xgnrv5w.js +5 -0
  44. package/dist/src/chunk-9xgsmshb.js +5 -0
  45. package/dist/src/chunk-a02d1wgv.js +4 -0
  46. package/dist/src/{chunk-km0dy5vc.js → chunk-a9ps00a1.js} +10 -10
  47. package/dist/src/chunk-aewdveet.js +5 -0
  48. package/dist/src/chunk-b3tdtq7r.js +9 -0
  49. package/dist/src/chunk-bn7jx7a2.js +4 -0
  50. package/dist/src/chunk-bnyw27ja.js +4 -0
  51. package/dist/src/{chunk-s1zq65ny.js → chunk-bpwsg76p.js} +2 -2
  52. package/dist/src/chunk-bvranw3g.js +4 -0
  53. package/dist/src/chunk-c25a84zb.js +4 -0
  54. package/dist/src/chunk-c27yv1dx.js +5 -0
  55. package/dist/src/chunk-c3ewxm4x.js +5 -0
  56. package/dist/src/chunk-cb1ga9rd.js +7 -0
  57. package/dist/src/chunk-cn7fwy7k.js +4 -0
  58. package/dist/src/chunk-cnvy4a64.js +4 -0
  59. package/dist/src/chunk-cqhw4yr6.js +5 -0
  60. package/dist/src/{chunk-v90es00d.js → chunk-ctmfshjc.js} +2 -2
  61. package/dist/src/chunk-ctwmhz13.js +4 -0
  62. package/dist/src/{chunk-qv2918jt.js → chunk-d3jx9bz5.js} +2 -2
  63. package/dist/src/{chunk-wry6skrm.js → chunk-d6rb08ga.js} +1 -1
  64. package/dist/src/chunk-ddqhj4eg.js +5 -0
  65. package/dist/src/{chunk-d57432wq.js → chunk-ddrhs1c3.js} +2 -2
  66. package/dist/src/chunk-dnjnh9p6.js +4 -0
  67. package/dist/src/{chunk-ajsrz473.js → chunk-dw5rwgya.js} +3 -3
  68. package/dist/src/chunk-e0870khr.js +5 -0
  69. package/dist/src/chunk-ea3k10kj.js +4 -0
  70. package/dist/src/chunk-emv82m1w.js +7 -0
  71. package/dist/src/chunk-f3m6pdnx.js +4 -0
  72. package/dist/src/chunk-f84z32cb.js +4 -0
  73. package/dist/src/chunk-fpczgf0z.js +4 -0
  74. package/dist/src/chunk-g2js4c2v.js +971 -0
  75. package/dist/src/chunk-g3af2qbk.js +5 -0
  76. package/dist/src/chunk-gadtna7s.js +11 -0
  77. package/dist/src/{chunk-c9nk1r78.js → chunk-gcyx407v.js} +3 -3
  78. package/dist/src/{chunk-jdqvcq0a.js → chunk-gfpntwc1.js} +3 -3
  79. package/dist/src/chunk-gmnm5e3e.js +4 -0
  80. package/dist/src/chunk-gp6vb5gf.js +4 -0
  81. package/dist/src/chunk-gppgy7pa.js +4 -0
  82. package/dist/src/chunk-hegfz0ae.js +5 -0
  83. package/dist/src/chunk-hpzxdp1k.js +17 -0
  84. package/dist/src/{chunk-2v7tw1nj.js → chunk-j69g8b50.js} +3 -3
  85. package/dist/src/chunk-jvstjnqm.js +19 -0
  86. package/dist/src/chunk-jzqrv78s.js +4 -0
  87. package/dist/src/chunk-k2948b8d.js +4 -0
  88. package/dist/src/chunk-k4ftd40d.js +4 -0
  89. package/dist/src/chunk-kd9vfaxh.js +5 -0
  90. package/dist/src/{chunk-34zxqcmq.js → chunk-kdczmgwk.js} +3 -3
  91. package/dist/src/chunk-ke3wn14v.js +4 -0
  92. package/dist/src/chunk-kh5n7m6w.js +4 -0
  93. package/dist/src/{chunk-0dfnyfkh.js → chunk-khejfph4.js} +3 -3
  94. package/dist/src/chunk-kny2xemh.js +4 -0
  95. package/dist/src/chunk-knyzw9md.js +4 -0
  96. package/dist/src/chunk-mbzpt2hp.js +4 -0
  97. package/dist/src/chunk-mm8rcxad.js +4 -0
  98. package/dist/src/chunk-nc4516tx.js +4 -0
  99. package/dist/src/{chunk-stfzjr9y.js → chunk-ntfrqrqn.js} +5 -5
  100. package/dist/src/chunk-nz5h2j52.js +4 -0
  101. package/dist/src/chunk-p22s97qy.js +4 -0
  102. package/dist/src/chunk-p9kt1sgr.js +6 -0
  103. package/dist/src/{chunk-9y5bcy28.js → chunk-pf282r5g.js} +4 -4
  104. package/dist/src/chunk-pnd4mrxy.js +4 -0
  105. package/dist/src/chunk-pqqteyj6.js +4 -0
  106. package/dist/src/chunk-qj1tbnv2.js +8 -0
  107. package/dist/src/chunk-qnh9egwr.js +4 -0
  108. package/dist/src/chunk-qy3khhf8.js +8 -0
  109. package/dist/src/chunk-r0vp315h.js +11 -0
  110. package/dist/src/chunk-r4j43b9s.js +237 -0
  111. package/dist/src/{chunk-4pfftt07.js → chunk-r54cxxze.js} +3 -3
  112. package/dist/src/chunk-r6pvhj33.js +325 -0
  113. package/dist/src/chunk-rb7aa5gr.js +54 -0
  114. package/dist/src/chunk-rdj50kb4.js +4 -0
  115. package/dist/src/chunk-rnd4vcas.js +4 -0
  116. package/dist/src/chunk-s3y3zfcx.js +14 -0
  117. package/dist/src/chunk-s4g43k75.js +5 -0
  118. package/dist/src/chunk-sfqe223f.js +311 -0
  119. package/dist/src/chunk-sqdrxjw5.js +7 -0
  120. package/dist/src/{chunk-0w1spptt.js → chunk-t54k47em.js} +4 -4
  121. package/dist/src/chunk-tek4pnvv.js +26 -0
  122. package/dist/src/chunk-tn74y7af.js +4 -0
  123. package/dist/src/chunk-tvq0nzam.js +5 -0
  124. package/dist/src/chunk-tx4f0h9c.js +6 -0
  125. package/dist/src/chunk-vdqag3fj.js +5 -0
  126. package/dist/src/chunk-vz5zzs57.js +4 -0
  127. package/dist/src/chunk-w4s2vfpj.js +4 -0
  128. package/dist/src/chunk-w5yypt53.js +42 -0
  129. package/dist/src/{chunk-r0f1q783.js → chunk-w68v64vh.js} +3 -3
  130. package/dist/src/chunk-whwj0pdk.js +5 -0
  131. package/dist/src/chunk-wnmqt1dc.js +4 -0
  132. package/dist/src/{chunk-8en08r7q.js → chunk-wpe46vsa.js} +3 -3
  133. package/dist/src/chunk-wxdjeb4k.js +27 -0
  134. package/dist/src/chunk-xcqzwf9j.js +247 -0
  135. package/dist/src/chunk-xezekwwn.js +5 -0
  136. package/dist/src/chunk-xf19m15s.js +4 -0
  137. package/dist/src/chunk-xghbxha4.js +4 -0
  138. package/dist/src/{chunk-jhnbfj19.js → chunk-xn9m3xc2.js} +5 -5
  139. package/dist/src/{chunk-a4k9rt7z.js → chunk-yqfz4vts.js} +3 -3
  140. package/dist/src/chunk-z8tvs8nk.js +5 -0
  141. package/dist/src/chunk-zm2rehqb.js +5 -0
  142. package/dist/src/chunk-zs6dqm35.js +4 -0
  143. package/dist/src/daemon/processEntry.js +2 -2
  144. package/dist/src/index.js +4 -4
  145. package/dist/src/runtime/bunRuntimeGuard.js +2 -2
  146. package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -2
  147. package/ios/CameraPosterInjection/Injection/CameraPosterInjection.m +466 -0
  148. package/package.json +4 -3
  149. package/schemas/test-plan.schema.json +370 -52
  150. package/dist/src/chunk-09442h7v.js +0 -4
  151. package/dist/src/chunk-0e4gm1kj.js +0 -5
  152. package/dist/src/chunk-0eb8576f.js +0 -4
  153. package/dist/src/chunk-0rjm4nx7.js +0 -5
  154. package/dist/src/chunk-1zmh2eak.js +0 -4
  155. package/dist/src/chunk-28k63ha3.js +0 -5
  156. package/dist/src/chunk-2d4wmp8b.js +0 -4
  157. package/dist/src/chunk-32jpxz2y.js +0 -323
  158. package/dist/src/chunk-3jmvqygr.js +0 -238
  159. package/dist/src/chunk-3swvfhqt.js +0 -5
  160. package/dist/src/chunk-44bt78m9.js +0 -5
  161. package/dist/src/chunk-488vt2bp.js +0 -4
  162. package/dist/src/chunk-4fgdhcwx.js +0 -5
  163. package/dist/src/chunk-4jp2se4w.js +0 -4
  164. package/dist/src/chunk-4vhr9e4t.js +0 -4
  165. package/dist/src/chunk-4xd6zs3y.js +0 -15
  166. package/dist/src/chunk-51567pg8.js +0 -4
  167. package/dist/src/chunk-5agqsfev.js +0 -4
  168. package/dist/src/chunk-5d706gmr.js +0 -4
  169. package/dist/src/chunk-5kd4rqk7.js +0 -5
  170. package/dist/src/chunk-61t538bm.js +0 -4
  171. package/dist/src/chunk-6d3mmqxt.js +0 -54
  172. package/dist/src/chunk-6hyt398x.js +0 -5
  173. package/dist/src/chunk-6mnr8kpm.js +0 -4
  174. package/dist/src/chunk-79q5xsdc.js +0 -42
  175. package/dist/src/chunk-7bdgand3.js +0 -4
  176. package/dist/src/chunk-84cp9dw5.js +0 -4
  177. package/dist/src/chunk-86f2h5ww.js +0 -5
  178. package/dist/src/chunk-8cghfzb2.js +0 -19
  179. package/dist/src/chunk-9tf2p9y9.js +0 -5
  180. package/dist/src/chunk-a2sc4jm0.js +0 -5
  181. package/dist/src/chunk-aa5ng3d1.js +0 -4
  182. package/dist/src/chunk-b3h0a6ca.js +0 -4
  183. package/dist/src/chunk-b6a737qt.js +0 -4
  184. package/dist/src/chunk-bn64x5z5.js +0 -5
  185. package/dist/src/chunk-bvh649za.js +0 -12
  186. package/dist/src/chunk-c9tyfg4j.js +0 -26
  187. package/dist/src/chunk-cfsdfqnm.js +0 -4
  188. package/dist/src/chunk-cxyf04jc.js +0 -7
  189. package/dist/src/chunk-da08tx5v.js +0 -4
  190. package/dist/src/chunk-f2tc08m2.js +0 -4
  191. package/dist/src/chunk-f8tnk179.js +0 -5
  192. package/dist/src/chunk-f9s1kkhx.js +0 -5
  193. package/dist/src/chunk-fbp8a4rx.js +0 -4
  194. package/dist/src/chunk-fd2z0sze.js +0 -4
  195. package/dist/src/chunk-fk927f4q.js +0 -54
  196. package/dist/src/chunk-fxmr3a0f.js +0 -4
  197. package/dist/src/chunk-gaqwhd44.js +0 -4
  198. package/dist/src/chunk-ggtd5x5a.js +0 -5
  199. package/dist/src/chunk-gndcfrm7.js +0 -4
  200. package/dist/src/chunk-h3n4adc6.js +0 -310
  201. package/dist/src/chunk-h5pjbb83.js +0 -4
  202. package/dist/src/chunk-hgnnh302.js +0 -4
  203. package/dist/src/chunk-hmke8nhx.js +0 -5
  204. package/dist/src/chunk-j2bx12hn.js +0 -4
  205. package/dist/src/chunk-j70y1a2g.js +0 -4
  206. package/dist/src/chunk-js1jpyxp.js +0 -6
  207. package/dist/src/chunk-kbjq0qvb.js +0 -4
  208. package/dist/src/chunk-kfwx57xd.js +0 -4
  209. package/dist/src/chunk-kzwctna2.js +0 -4
  210. package/dist/src/chunk-m9ehyehy.js +0 -4
  211. package/dist/src/chunk-mct91p1f.js +0 -4
  212. package/dist/src/chunk-mf9spd4g.js +0 -5
  213. package/dist/src/chunk-mgrcansb.js +0 -4
  214. package/dist/src/chunk-mqc1d0eb.js +0 -6
  215. package/dist/src/chunk-n1zmpk0z.js +0 -4
  216. package/dist/src/chunk-ncyjf63g.js +0 -4
  217. package/dist/src/chunk-nr64d21q.js +0 -973
  218. package/dist/src/chunk-nwm2pq5v.js +0 -168
  219. package/dist/src/chunk-pm06b05d.js +0 -9
  220. package/dist/src/chunk-q50s00ry.js +0 -4
  221. package/dist/src/chunk-qwye1958.js +0 -14
  222. package/dist/src/chunk-r8z9pfve.js +0 -5
  223. package/dist/src/chunk-rdpgkjf6.js +0 -4
  224. package/dist/src/chunk-rkr0dks9.js +0 -5
  225. package/dist/src/chunk-rn84t3sf.js +0 -11
  226. package/dist/src/chunk-s123kn7n.js +0 -4
  227. package/dist/src/chunk-s73qn3fx.js +0 -4
  228. package/dist/src/chunk-sjn0nj4p.js +0 -5
  229. package/dist/src/chunk-sns0c35v.js +0 -7
  230. package/dist/src/chunk-t4dr5c8v.js +0 -8
  231. package/dist/src/chunk-tc8k9c1j.js +0 -4
  232. package/dist/src/chunk-teznhase.js +0 -4
  233. package/dist/src/chunk-ty9xgmz4.js +0 -4
  234. package/dist/src/chunk-tyazf3sk.js +0 -145
  235. package/dist/src/chunk-v6npjrjm.js +0 -5
  236. package/dist/src/chunk-vbvtzkwz.js +0 -5
  237. package/dist/src/chunk-vefd8qee.js +0 -8
  238. package/dist/src/chunk-vs9r72ta.js +0 -17
  239. package/dist/src/chunk-w2mwa0jk.js +0 -4
  240. package/dist/src/chunk-w88k0bgr.js +0 -4
  241. package/dist/src/chunk-wzdt0enk.js +0 -4
  242. package/dist/src/chunk-xhhv854c.js +0 -4
  243. package/dist/src/chunk-y58270hd.js +0 -4
  244. package/dist/src/chunk-yk0hmbex.js +0 -4
  245. package/dist/src/chunk-ympy4fdz.js +0 -28
  246. package/dist/src/chunk-yw436axy.js +0 -4
  247. package/dist/src/chunk-z04jrpjy.js +0 -5
  248. package/dist/src/chunk-z2xznczw.js +0 -4
  249. package/dist/src/chunk-z4xnrgps.js +0 -4
  250. package/dist/src/chunk-z7csyszv.js +0 -4
  251. package/dist/src/chunk-z8t0v07j.js +0 -11
  252. package/dist/src/chunk-z916af47.js +0 -228
  253. package/dist/src/chunk-zcr8he8q.js +0 -5
  254. package/dist/src/chunk-zd9vmkzn.js +0 -9
  255. package/dist/src/chunk-zj939v0h.js +0 -5
  256. package/dist/src/chunk-zkdjwtc1.js +0 -4
  257. package/dist/src/chunk-zkv5kzt6.js +0 -4
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{i,zt,Q,e}from"./chunk-r0vp315h.js";import{Ni,w,St,me,U,ie,bne,v,vs,b,he,It,o,P,Kg,N,K,Cie,hr,Ee,Af,Lc,C9,Bl,hn,sU,aU,x,Ce,E}from"./chunk-sfqe223f.js";import{ML,Hm,ji,An,WL,pre,Uv,mre,zT,Qm,QW,GT,io,tB,iB,ai}from"./chunk-4vxeq0vd.js";import{r,t}from"./chunk-2b39zyxc.js";import{AsyncLocalStorage as ce}from"async_hooks";var Fv=Symbol("terminalScreenshotUnavailable"),O=new ce;async function w3(n,s,a=!0,c=!0){if(!a)return O.run(void 0,s);let d={pending:[],unavailable:[],signal:n,closed:!1,multiAction:!1,defer:c};return O.run(d,async()=>{let l=!1;try{let u=await s();return l=!0,u}finally{try{if(l)await SW();else d.pending=[]}finally{d.closed=!0}}})}function Ite(n,s,a,c=!0){return(d)=>()=>w3(n,d,!s&&a!=="observe",c)}function T(n,s){return n===s||!!n.observationId&&n.observationId===s.observationId&&n.deviceId===s.deviceId}async function Ru(){let n=O.getStore();if(!n||n.closed||n.pending.length===0)return;n.multiAction=!0,await SW()}function de(n,s){let a=O.getStore();if(!a)return!1;if(a.closed)return!0;if(a.multiAction)return!1;if(!n.observationId||!n.deviceId)return!1;if(!a.pending.some((c)=>T(c.observation,n)))a.pending.push({observation:n,capture:s});return!0}async function vW(n,s){let a=O.getStore();if(a&&!a.defer&&!a.closed&&!a.multiAction&&n.observationId&&n.deviceId)return await bW(n,s,a.signal),!0;return de(n,s)}function _te(n){return O.getStore()?.pending.some((s)=>T(s.observation,n))??!1}async function bW(n,s,a){n[Fv]=!0;let c=O.getStore(),d={observation:n};c?.unavailable.push(d);for(let l=0;l<2;l++){if(c?.closed||a?.aborted)return;n.screenshotCaptureAttempted=!0;try{if(await s(n,a),delete n[Fv],c)c.unavailable=c.unavailable.filter((u)=>!T(u.observation,n));if(n.accessibilityAudit!==void 0)delete n.accessibilityAuditSkipped;return}catch(u){d.error=u,delete n.screenshotPath,delete n.screenshotSource,delete n.screenshotCapturedAt,delete n.screenshotImageSize,delete n.screenshotExpiresAt,delete n.screenshotSettled,delete n.screenshotOrientation,delete n.screenshotPixelsPerNativeUnit,delete n.screenshotScaleProvenance,delete n.screenshotAgeMs,delete n.screenshotHierarchyLagMs,delete n.screenshotHierarchyMismatch,delete n.screenshotFormat,delete n.screenshotMimeType,delete n.screenshotImage,delete n.screenshotCaptureSource,delete n.observationScreenshotResourceUri,delete n.accessibilityAudit,e.warn(`[PostActionCapture] terminal screenshot failed: ${r(u)}`,u)}}}async function bp(n,s=n,a,c){let d=O.getStore(),l=d?.pending.findIndex((p)=>T(p.observation,n))??-1;if(!d||l<0)return!1;let[u]=d.pending.splice(l,1);return await bW(s,a??u.capture,d.signal??c),!0}async function SW(){let n=O.getStore();while(n&&n.pending.length>0)await bp(n.pending[0].observation)}function $C(n){return n[Fv]===!0||(O.getStore()?.unavailable.some((s)=>T(s.observation,n))??!1)}function xte(n){return O.getStore()?.unavailable.find((s)=>T(s.observation,n))?.error}function _(n,s,a){let c=n.observationHostTimestampProvider?.(),d=n.observationTimestampProvider?.()??(typeof c==="number"?c+a:void 0);if(typeof d!=="number"||Number.isNaN(d))return s;if(d>=s)return e.debug(`[BaseVisualChange] Using observation timestamp override: ${d}`),d;return e.debug(`[BaseVisualChange] Ignoring observation timestamp override (${d}) older than action start (${s})`),s}function H(n,s,a){if(s.platform!=="android"||a.skipUiStability||a.display!==void 0)return;return n.getCachedActiveWindow()}function V(n,s){if(n===void 0||!s?.appId)return;if(n===null)return s.appId;return n.appId!==s.appId||n.activityName!==s.activityName||n.layoutSeqSum!==s.layoutSeqSum?s.appId:void 0}async function le(n,s,a,c){if(a===void 0||s.display!==void 0)return;let d=await n.getCachedActiveWindow();if(V(a,d)||!s.foregroundAppMayChange||s.packageName)return d;try{return await n.getActive(!0,s.perf,{timeoutMs:Math.min(c,C9),signal:s.signal})}catch(l){return o(s.signal),e.warn(`[BaseVisualChange] Post-dispatch active window read failed; using cached window: ${r(l)}`,l),d}}async function L(n,s,a,{beforeWindow:c,timeoutMs:d}){let l=await le(n,s,c,d),u=V(c,l);if(u)return u;if(s.packageName)return s.packageName;let p=a?.viewHierarchy?.packageName;if(p)return e.info(`[BaseVisualChange] Using packageName from view hierarchy: ${p}`),p;if(s.display!==void 0)return;let f=(l===void 0?await n.getCachedActiveWindow():l)?.appId;if(f)e.info(`[BaseVisualChange] Using cached packageName: ${f}`);return f||void 0}var ue=10,pe=1000,fe=Q({initialDelayMs:50,multiplier:2,maxDelayMs:400});class k{adb;adbFactory;idle;timer;rotationPollBackoff;stabilityThresholdMs=60;pollIntervalMs=17;constructor(n,s=v,a=i,{hierarchyReader:c,rotationPollBackoff:d=fe}={}){this.rotationPollBackoff=d,this.adbFactory=s,this.adb=s.create(n),this.idle=new zT(n,this.adbFactory,a,c),this.timer=a}async waitForRotation(n,s=mre,a){let c=this.timer.now();for(let d=1;;d++){o(a);let l=await P(this.idle.getRotationStatus(n,c,s,{signal:a}),a);if(l.rotationComplete)return;if(!l.shouldContinue)throw Error(`Timeout waiting for rotation to ${n} after ${s}ms`);await P(this.timer.sleep(Math.min(this.rotationPollBackoff.delayForAttempt(d),Math.max(0,s-(this.timer.now()-c)))),a)}}async initializeUiStabilityTracking(n,s,a){let c=this.timer.now(),d=c,l=c+s;e.info(`[AwaitIdle] Starting UI stability wait for ${n} (timeout: ${s}ms, threshold: ${this.stabilityThresholdMs}ms)`);try{await vs(l,this.timer,a,(u,p)=>this.adb.executeCommand(`shell dumpsys gfxinfo ${b(n)} reset`,{timeoutMs:p,maxBuffer:ie,signal:u}))}catch(u){a?.throwIfAborted(),e.info(`[AwaitIdle] Failed to reset gfxinfo for ${n}: ${u}`)}return{startTime:c,lastNonIdleTime:d,prevMissedVsync:null,prevSlowUiThread:null,prevFrameDeadlineMissed:null,prevTotalFrames:null,firstGfxInfoLog:!0}}checkUiStabilityTimeout(n,s,a){let c=this.timer.now()-s,d=this.timer.now()-n,l=d>=this.stabilityThresholdMs,u=c<a;return{isStable:l,shouldContinue:u,stableTime:d,elapsedTime:c}}async processSingleUiStabilityCheck(n,s,a,c){let d=await this.idle.getUiStability(n,{missedVsync:s.prevMissedVsync,slowUiThread:s.prevSlowUiThread,frameDeadlineMissed:s.prevFrameDeadlineMissed,totalFrames:s.prevTotalFrames},s.firstGfxInfoLog,{perf:new U,timeoutMs:a,signal:c});return{updatedState:{prevMissedVsync:d.updatedPrevMissedVsync,prevSlowUiThread:d.updatedPrevSlowUiThread,prevFrameDeadlineMissed:d.updatedPrevFrameDeadlineMissed,prevTotalFrames:d.updatedPrevTotalFrames,firstGfxInfoLog:d.updatedFirstGfxInfoLog,lastNonIdleTime:d.shouldUpdateLastNonIdleTime?this.timer.now():s.lastNonIdleTime},...d.noFrameData?{noFrameData:!0}:{},...d.frameStatsUnavailable?{frameStatsUnavailable:!0}:{},shouldUpdateLastNonIdleTime:d.shouldUpdateLastNonIdleTime}}createNoFrameGraceCheck(n){let s=0,a=null;return(c,d)=>{if(d||this.timer.now()>=n)return!1;if(!c)return s=0,a=null,!1;if(s===0)a=this.timer.now();return s++,s>=ue&&a!==null&&this.timer.now()-a>=pe}}async waitForUiStabilityWithState(n,s,a,{perf:c=new U,signal:d}={}){return await this.idle.waitForQuietTreeStability(n,a.startTime,s,d)??this.waitForFrameStabilityWithState(n,s,a,{perf:c,signal:d})}async waitForFrameStabilityWithState(n,s,a,{perf:c,signal:d}){e.info(`[AwaitIdle] Continuing UI stability wait with existing state for package: ${n}`);let l=a,u=0,p=!1,f=a.startTime+s,m=this.createNoFrameGraceCheck(f),h={percentile50thMs:null,percentile90thMs:null,percentile95thMs:null,percentile99thMs:null,missedVsyncCount:null,slowUiThreadCount:null,frameDeadlineMissedCount:null};try{while(!0){let y=this.timer.now()-a.startTime;if(o(d),y>=s){e.info(`[AwaitIdle] Timeout waiting for UI stability after ${s}ms`);break}u++;let S=await c.track(`gfxinfoPoll_${u}`,async()=>vs(f,this.timer,d,(R,C)=>this.processSingleUiStabilityCheck(n,l,C,R)));if(l={...l,...S.updatedState},h.missedVsyncCount=l.prevMissedVsync,h.slowUiThreadCount=l.prevSlowUiThread,h.frameDeadlineMissedCount=l.prevFrameDeadlineMissed,m(S.noFrameData,S.frameStatsUnavailable)){e.info(`[AwaitIdle] Ending UI stability wait after the grace period without valid frame stats for ${n}`),h.idleEndReason="noFrameStats";break}let g=this.checkUiStabilityTimeout(l.lastNonIdleTime,a.startTime,s);if(e.info(`[AwaitIdle] Checking stability: ${g.elapsedTime}ms elapsed of ${s}ms timeout, stable for ${g.stableTime}ms/${this.stabilityThresholdMs}ms`),g.isStable){e.info(`[AwaitIdle] UI stable after ${g.elapsedTime}ms (stable for ${g.stableTime}ms)`),p=!0;break}if(!g.shouldContinue){e.info(`[AwaitIdle] Timeout waiting for UI stability after ${s}ms`);break}await this.timer.sleep(Math.min(this.pollIntervalMs,f-this.timer.now()))}}catch(y){d?.throwIfAborted(),e.error(`[AwaitIdle] Encountered an error while waiting for UI stability: ${y}`)}if(f>this.timer.now())try{let y=await c.track("finalGfxinfo",async()=>{let S=await vs(f,this.timer,d,(R,C)=>this.adb.executeCommand(`shell dumpsys gfxinfo ${b(n)}`,{timeoutMs:C,maxBuffer:ie,signal:R})),g=this.idle.parseMetrics(S.stdout);if(this.idle.validateFrameData(g))delete h.idleEndReason;return g});h.percentile50thMs=y.percentile50th,h.percentile90thMs=y.percentile90th,h.percentile95thMs=y.percentile95th,h.percentile99thMs=y.percentile99th,h.missedVsyncCount=y.missedVsync,h.slowUiThreadCount=y.slowUiThread,h.frameDeadlineMissedCount=y.frameDeadlineMissed}catch(y){d?.throwIfAborted(),e.warn(`[AwaitIdle] Failed to get final gfxinfo: ${y}`)}let A=this.timer.now()-a.startTime;return{packageName:n,...h,pollCount:u,stabilityWaitMs:A,isStable:p}}async waitForUiStability(n,s,a=new U,c){e.info(`[AwaitIdle] Waiting for UI stability for package: ${n} with timeoutMs: ${s}`);let d=await a.track("initUiStabilityTracking",async()=>this.initializeUiStabilityTracking(n,s,c));return this.waitForUiStabilityWithState(n,s,d,{perf:a,signal:c})}}function ve(n){let s=n.viewHierarchy?.hierarchy;return!!s&&typeof s==="object"&&!("error"in s)}function pl(n,s,a){if(a&&s.display?.key!==n.display?.key)return!1;if(!ve(s))return!1;let c=s.freshness;if(c?.isFresh===!1||c?.verified===!1)return!1;let d=hn(n.viewHierarchy);if(d===void 0)return!0;let l=hn(s.viewHierarchy);return l!==void 0&&l>=d}class M{elementParser=new K;historyRepository;navigationGraph;timer;constructor(n=new tB,s,a=i){this.historyRepository=n,this.navigationGraph=s,this.timer=a}async recordOutcomeForAction(n,s,a){if(!n?.predictions?.likelyActions||!s)return;let c=this.findMatchingPrediction(n.predictions.likelyActions,a.toolName,a.toolArgs);if(!c)return;let l=(a.navigationGraph??this.navigationGraph??he.getInstance()).getCurrentScreen();if(!l)return;let u=c.predictedElements??[],p=this.extractElementIdentifiers(s),f=this.calculateMatchScore(u,p,c.predictedScreen,l),m=this.isCorrectPrediction(c.predictedScreen,l,u,f),h=this.isPartialMatch(c.predictedScreen,l,f),A=this.resolveErrorType(c.predictedScreen,l,u,f),y=Lc.generateCacheKey(JSON.stringify({fromScreen:a.fromScreen,predictedScreen:c.predictedScreen,toolName:a.toolName,toolArgs:GT(a.toolArgs),timestamp:this.timer.now()}));try{await this.historyRepository.recordOutcome({appId:a.appId,predictionId:y,timestamp:this.timer.now(),fromScreen:a.fromScreen,predictedScreen:c.predictedScreen,actualScreen:l,toolName:a.toolName,toolArgs:a.toolArgs,predictedElements:u,foundElements:p,confidence:c.confidence??0.5,matchScore:f,correct:m,partialMatch:h,errorType:A})}catch(S){e.warn(`[PredictionAnalyzer] Failed to record outcome: ${S}`)}}findMatchingPrediction(n,s,a){let c=n.filter((d)=>d.action===s);if(c.length===0)return;for(let d of c){if(s==="tapOn"&&this.matchesTapOn(d,a))return d;if(s==="swipeOn"&&this.matchesSwipeOn(d,a))return d}return}matchesTapOn(n,s){let a=n.target,c=io(s.text),d=io(s.elementId??s.id),l=io(a.text),u=io(a.elementId),p=io(a.contentDesc);if(c&&(c===l||c===p))return!0;if(d&&d===u)return!0;return!1}matchesSwipeOn(n,s){let a=n.target,c=s.container??{},d=s.lookFor??{},l=this.matchesTarget(c,a.container),u=this.matchesTarget(d,a.lookFor);return l||u}matchesTarget(n,s){if(!s)return!1;let a=io(n.text),c=io(n.elementId),d=io(n.contentDesc),l=io(s.text),u=io(s.elementId),p=io(s.contentDesc);if(a&&(a===l||a===p))return!0;if(c&&c===u)return!0;if(d&&d===p)return!0;return!1}extractElementIdentifiers(n){if(!n.viewHierarchy)return[];let s=this.elementParser.flattenViewHierarchy(n.viewHierarchy),a=new Set;for(let{element:c}of s){if(c.text)a.add(c.text);if(c["resource-id"])a.add(c["resource-id"]);if(c["content-desc"])a.add(c["content-desc"])}return Array.from(a)}calculateMatchScore(n,s,a,c){if(a!==c)return 0;if(n.length===0)return 1;let d=new Set(n.map(io).filter((p)=>Boolean(p)));if(d.size===0)return 1;let l=new Set(s.map(io).filter((p)=>Boolean(p))),u=0;for(let p of d)if(l.has(p))u+=1;return u/d.size}isCorrectPrediction(n,s,a,c){if(n!==s)return!1;if(a.length===0)return!0;return c>=1}isPartialMatch(n,s,a){return n===s&&a>0&&a<1}resolveErrorType(n,s,a,c){if(n!==s)return"wrong_screen";if(a.length>0&&c<1)return"missing_elements";return}}class W{window;adb;deviceId;timer;formFactor;constructor(n){this.window=n.window,this.adb=n.adb,this.deviceId=n.deviceId,this.timer=n.timer,this.formFactor=n.formFactor}async verify(n={}){let s=await this.readForeground(n);if(!s)pre(this.deviceId);return s}async readForeground(n){let s=me(n.signal),{timeoutMs:a}=n,c=n.retryDelaysMs??[150,300],d=a!==void 0?this.timer.now()+a:void 0,l=()=>d===void 0?void 0:d-this.timer.now();for(let u=0;;u++){try{let m=await this.probeHomeForeground(s,l,n);if(m!=="not-home")return m==="verified"}catch(m){if(s?.aborted)throw m;e.warn(`[BaseVisualChange] Failed to read foreground app while verifying home press: ${r(m)}`,m)}let p=c[u],f=l();if(p===void 0||f!==void 0&&f<=p)return!1;await this.timer.sleep(p)}}async probeHomeForeground(n,s,a){if((s()??1)<=0)return"expired";let c=()=>({signal:n,timeoutMs:s()}),d=await this.window.getActive(!0,void 0,c());if((s()??1)<=0)return"expired";let{deviceId:l}=this;if(await Uv(d.appId,this.adb,l,{timer:this.timer,...c(),incarnationToken:Ni(l),formFactor:this.formFactor})&&(s()??1)>0)return a.onVerifiedForeground?.(d.appId),"verified";return"not-home"}}function be(n,s){let a=n.screenIdentity,c=s.screenIdentity;if(!a||!c||a.platform!==c.platform)return;let d=a.key!==c.key;return{screenChanged:d,basis:d?"screenIdentity changed":"screenIdentity unchanged"}}function G(n,s){let a=n.activeWindow,c=s.activeWindow;if(!z(a)||!z(c))return;let d=a.appId!==c.appId||a.activityName!==c.activityName;return{screenChanged:d,basis:d?"activeWindow changed":"activeWindow unchanged"}}function z(n){return Boolean(n?.appId&&n.activityName&&Number.isInteger(n.layoutSeqSum))}function ye(n,s){let a=An(n.viewHierarchy??null),c=An(s.viewHierarchy??null);if(!a||!c)return;let d=a!==c;return{screenChanged:d,basis:d?"viewHierarchy changed":"viewHierarchy unchanged"}}function q(n,s){if(!n||!s)return;let a=ye(n,s),c=[be(n,s),G(n,s),a].filter((l)=>l!==void 0);if(a&&!a.screenChanged)return c.find((l)=>!l.screenChanged)??a;let d=c.find((l)=>l.screenChanged);if(d)return d;return c[0]??{screenChanged:!1,basis:"insufficient observation data"}}var _L=[50,100,200,400],I=new Set(["tapAt","swipeAt","tapOn","tapAny","swipeOn","dragAndDrop","pinchOn","multiTouch","dragPath"]),ge=Object.freeze({assertCurrent:()=>{}}),wc={skipScreenshot:!0,skipAccessibilityAudit:!0};function Lv(n){return n?.displayFence??ge}function Y(n,s){return{renderedDisplayRevision:n.renderedDisplayRevision??s,displayTransitionReader:n.displayTransitions??Ce,renderedDisplayGeneration:n.renderedDisplayGeneration??j}}function j(n,s=w){let a=s.renderedDisplaySessions();if(!a)return;let c=a.getSessionForDevice(n);return c?a.getLastRenderedDisplayGeneration(c):void 0}function X(n,s=w){let a=s.renderedDisplaySessions();if(!a)return;let c=a.getSessionForDevice(n);return c?a.getLastRenderedDisplayRevision(c):void 0}var UC=4;function we(n){return n.platform==="ios"&&(n.displays?.panels.length??0)>1}function Re(n,s,a){return we(n)&&s.display===void 0&&I.has(s.predictionContext?.toolName??"")&&!a()}async function Z(n,s,{observer:a,transitions:c,callerStampIsStale:d=()=>!1,observeOptions:l={}}){if(!Re(n,s,d))return;let u=c.revision(n.deviceId);if(s.previousObservation?.displayRevision===u)return;let p=await a.getMostRecentCachedObserveResult();if(p.error===void 0&&p.displayRevision===u)return;return e.info(`[PANEL_GEOMETRY] Cached observation display revision ${p.displayRevision??"none"} != current ${u} on ${n.deviceId}; observing before ${s.predictionContext?.toolName}`),a.execute({...l,freshness:"fresh"})}class DT extends t{constructor(n){super("Cannot perform action without view hierarchy",n);this.name="MissingViewHierarchyError"}}function B(n){return n}function J(n,s,a,c){if(n.viewHierarchy?.hierarchy?.error)return!1;if(s>0&&!(n.freshness?.isFresh??!0))return!0;if(!a)return!1;let d=An(n.viewHierarchy);return!!c&&!!d&&c===d}function ee(n){return Boolean(n.viewHierarchy&&!n.viewHierarchy.hierarchy.error)}function re(n,s){let a=s>0?"Observation may be stale after interaction":"Observation may not reflect expected visual change";n.freshness=n.freshness?{...n.freshness,warning:a}:{isFresh:!1,warning:a},e.warn(`[BaseVisualChange] ${a}`)}function te(n,s){if(s!==null){if(n.success!==!1){if(n.success=s,!s)n.error="No visual change observed"}return}if(n&&"error"in n&&n.error!==void 0)n.success=!1;else if(n&&(!("success"in n)||n.success===void 0))n.success=!0}function ne(n,s,a){if(s)n.gfxMetrics=s;let c=a.isEnabled()?a.getTimings():void 0;if(c)n.perfTiming=c}function oe(n){if(n.secure===!0)return`${"Device is locked; this interaction likely did not reach the app under test."} The lock is secure (PIN/pattern/password) \u2014 ask the user to unlock the device before continuing.`;if(n.secure===!1)return`${"Device is locked; this interaction likely did not reach the app under test."} The lock is a swipe lock \u2014 dismiss the keyguard (e.g. swipe up) before continuing.`;return"Device is locked; this interaction likely did not reach the app under test. Unlock or dismiss the keyguard before continuing."}function se(n,s){if(!n)return;let a=s(),c=a.getCurrentAppId(),d=a.getCurrentScreen();if(!c||!d)return;return{appId:c,fromScreen:d,toolName:n.toolName,toolArgs:n.toolArgs,navigationGraph:a}}class D{timer;constructor(n){this.timer=n}async capturePostActionObservation(n,s,a,c){let d=s.perf??new U,l=zt(_L),u,p,f=async()=>{let m=await n.execute(s);if(s.display!==void 0)o(s.signal);if(s.display!==void 0&&pl(p??m,m,!0))p=m;return m};try{d.serial("finalObserve"),u=await f(),d.end();for(let m=0;m<UC&&a(u);m++){let h=l.delayForAttempt(m+1);e.info(`[BaseVisualChange] Observation appears stale/unchanged, retrying in ${h}ms (attempt ${m+1}/${UC})`),await this.timer.sleep(h),d.serial(`finalObserve_retry_${m+1}`),u=await f(),d.end()}}catch(m){return this.recoverPostActionObservation(m,p??u,s,c)}return{observation:u,readFailed:!1}}recoverPostActionObservation(n,s,a,c){if(a.display===void 0)throw n;if(o(a.signal),n instanceof Error&&n.name==="AbortError")throw n;if(s&&pl(s,s,!0))return this.notePostActionReadFailure(s,"observation retry",r(n),n);if(c.success===!1||c.skipped||c.wasAlreadyFocused)throw n;throw new hr(n)}notePostActionReadFailure(n,s,a,c){let d=`Post-action ${s} failed: ${a}; retaining the earlier observation`;return e.warn(`[BaseVisualChange] ${d}`,c),{observation:{...n,settled:!1,freshness:{...n.freshness,isFresh:n.freshness?.isFresh??!0,warning:[n.freshness?.warning,d].filter(Boolean).join("; ")}},readFailed:!0,...c instanceof Ee?{staleDisplay:c.details}:{}}}}var Ae="Boomerang partially applied: the forward swipe was delivered, so the content has moved. Observe before retrying; do not retry automatically.";function Se(n){return{...n,success:!1,error:`Boomerang partially applied: the forward swipe was delivered; the return swipe failed (${n.error??"unknown error"}). The content has moved. Observe before retrying; do not retry automatically.`,retryable:!1,partialApplication:!0}}function F(n){if(St(n)||n instanceof Ee)return n;let s=new t(`${r(n)}. ${Ae}`,{cause:n});return ae.add(s),s}var ae=new WeakSet;function wW(n,s){try{o(n)}catch(a){throw typeof s==="object"&&s!==null&&ae.has(s)?F(a):a}}async function HC(n){let{timer:s,apexPauseMs:a,signal:c,returnSwipe:d}=n;try{if(o(c),a>0)await P(s.sleep(a),c);o(c);let l=await d();return l.success?l:Se(l)}catch(l){throw F(l)}}class Oe{static shouldRefetchCachedObservation(n,s=!1){return s?n.freshness?.isFresh!==!0:n.freshness?.isFresh===!1}windowCacheInvalidator=new ai;actionClockSkewCache;navigationGraphResolver=QW;device;adb;adbFactory;awaitIdle;observeScreen;window;predictionAnalyzer;deferredPredictionOutcomes=new WeakMap;timer;displayTransitionReader;renderedDisplayGeneration;renderedDisplayRevision;shouldCapturePostActionScreenshot(){return Hm()==="settled"||!ML()||(It()?.hasSubscriberForDevice(this.device.deviceId)??!1)}constructor(n,{adb:s=v,timer:a=i,renderedDisplayRevision:c=X,displayFence:d={}}={}){this.actionClockSkewCache=Cie(a,d.actionClockSkewCache),this.device=n;let{adbFactory:l,adb:u}=Oe.resolveAdb(n,s);this.adbFactory=l,this.adb=u,this.awaitIdle=d.awaitIdle??new k(n,this.adbFactory,a),this.observeScreen=d.observeScreen??iB(n,this.adbFactory),this.window=d.window??new Bl(n,this.adbFactory,a),this.predictionAnalyzer=d.predictionAnalyzer??new M,this.timer=a;let p=Y(d,c);this.renderedDisplayRevision=p.renderedDisplayRevision,this.displayTransitionReader=p.displayTransitionReader,this.renderedDisplayGeneration=p.renderedDisplayGeneration}static resolveAdb(n,s){if(s&&typeof s.create==="function"){let a=s;return{adbFactory:a,adb:a.create(n)}}if(s){let a=s;return{adbFactory:{create:()=>a},adb:a}}return{adbFactory:v,adb:v.create(n)}}staleDisplay(n){return Af(n,this.displayTransitionReader.identityRevision(this.device.deviceId),this.displayTransitionReader.currentObservedPanel(this.device.deviceId)?.key)}captureDisplayFence(n){let s=this.device.deviceId,a=()=>this.device.platform==="ios"?this.displayTransitionReader.identityRevision(s):this.displayTransitionReader.revision(s),c=a(),d=n??this.renderedDisplayGeneration(s)??this.displayTransitionReader.identityRevision(s);return{assertCurrent:()=>{if(a()!==c)throw this.staleDisplay(d)}}}async observedInteraction(n,s){if(!s.observePartialApplication)return this.runObservedInteraction(n,s);let a=!1;try{return await this.runObservedInteraction(async(c,d)=>{let l=await n(c,d);return a=l?.success===!1&&l.partialApplication===!0,l},s)}catch(c){throw a&&s.signal?.aborted?F(c):c}}async runObservedInteraction(n,s){await Ru();let a=s.timeoutMs||12000,c=s.perf??new U;await Z(this.device,s,{observer:this.observeScreen,transitions:this.displayTransitionReader,callerStampIsStale:()=>this.callerDisplayStampIsStale(s),observeOptions:this.previousObserveOptions(s,c,"fresh")});let d=this.captureCallerFenceState(s);if(s.progress)await s.progress(0,100,"Preparing to execute action...");o(s.signal);let l=await this.resolvePreviousObservation(s,c,d),u=se(s.predictionContext,()=>this.navigationGraphResolver(this.device)),p=this.reconcileDisplayAfterRead(s,d,l),f=H(this.window,this.device,s),{actionStartTime:m,clockSkewMs:h}=await this.readActionClock(c),A=await this.runBlock(n,l,d,{options:s,stage:{perf:c,coordinateAction:p}});if(this.isUnconfirmedIosFailure(A,s))return c.end(),B(A);this.invalidateCtrlProxyCacheForDisplay(s);let y=_(s,m,h),S=await L(this.window,s,l,{beforeWindow:await f,timeoutMs:a}),g=await this.awaitUiStability(s,S,a,c),R=await this.takeObservation(A,l,{changeExpected:s.changeExpected,display:s.display,postActionObserveScreen:s.postActionObserveScreen,tolerancePercent:s.tolerancePercent??bne,queryOptions:s.queryOptions,gfxMetrics:g,perf:c,actionStartTime:s.overrideMinTimestamp??y,predictionContext:s.deferPredictionOutcome?void 0:u,signal:s.signal,deferPostActionScreenshot:s.deferPostActionScreenshot});if(s.deferPredictionOutcome&&u&&typeof R==="object")this.deferredPredictionOutcomes.set(R,async(C)=>{await this.predictionAnalyzer.recordOutcomeForAction(l,C,u)});if(s.display!==void 0)R.effect=this.deriveInteractionEffect(l,R.observation);return this.annotateDeviceLock(R,l),R}actionDisplayRevision(){return this.displayTransitionReader.identityRevision(this.device.deviceId)}captureCallerFenceState(n){let s=this.actionDisplayRevision(),a=this.renderedDisplayGeneration(this.device.deviceId)??s,c=n.resolvesTargetFromRead===!0&&n.display===void 0&&!n.skipPreviousObserve,d={displayRevision:s,fence:this.captureDisplayFence(),observedGeneration:a,reresolvesTarget:c,refreshForDisplayChange:!1};if(this.callerDisplayStampIsStale(n)){if(!c)throw this.staleDisplay(a);d.refreshForDisplayChange=!0}return d}callerDisplayStampIsStale(n){let s=this.renderedDisplayRevision(this.device.deviceId);if(n.skipCallerDisplayFence||!I.has(n.predictionContext?.toolName??"")||s===void 0)return!1;return this.device.platform==="ios"?!this.displayTransitionReader.sameIdentitySince(this.device.deviceId,s):s!==this.displayTransitionReader.revision(this.device.deviceId)}async resolvePreviousObservation(n,s,a){if(n.skipPreviousObserve)return e.info("[BaseVisualChange] Skipping previous observe (app was terminated/cleared)"),n.previousObservation??null;if(n.previousObservation)return n.previousObservation;let c=await this.readFreshPreviousObservation(n,s,a.refreshForDisplayChange);if(n.usesObservationForResolution!==!1&&Kg(c))throw new t(`Cannot resolve elements against a wrong-window hierarchy: ${c.freshness?.warning??"The refreshed observation still belongs to another window"}`);return c}async readFreshPreviousObservation(n,s,a){let c=n.usesObservationForResolution!==!1,d=c?sU(this.device.deviceId):void 0,l=a||d!==void 0,u={knownWrongWindow:d!==void 0},p;try{await n.progress?.(10,100,"Getting previous view hierarchy..."),p=await s.track("getPreviousObserve",()=>this.readCachedOrFreshPrevious(n,s,l,u))}catch(f){if(u.knownWrongWindow&&c)throw new DT({cause:f});e.warn(`Previous observation failed: ${r(f)}`,f),p=await this.readPreviousFallback(n,s)}return Oe.assertUsablePrevious(p,u.knownWrongWindow&&c),this.completeResolutionRead(p,d),p}static assertUsablePrevious(n,s){if(!n)throw new DT;if(s&&(!n.viewHierarchy||n.viewHierarchy.hierarchy.error))throw new DT}completeResolutionRead(n,s){if(s!==void 0&&!Kg(n))aU(this.device.deviceId,s)}readPreviousFallback(n,s){return s.track("getPreviousObserveFallback",()=>this.observeScreen.execute(this.previousObserveOptions(n,s,n.skipCallerDisplayFence?"fresh":"cached-ok")))}async readCachedOrFreshPrevious(n,s,a,c){let d=n.display?void 0:await this.observeScreen.getMostRecentCachedObserveResult();c.knownWrongWindow||=Kg(d);let l=Boolean(d?.viewHierarchy&&!d.viewHierarchy.hierarchy.error),u=a||l&&Oe.shouldRefetchCachedObservation(d);if(!l||u||Oe.shouldRefetchCachedObservation(d,n.skipCallerDisplayFence))return this.observeScreen.execute(this.previousObserveOptions(n,s,u||n.skipCallerDisplayFence?"fresh":"cached-ok"));return d}previousObserveOptions(n,s,a){return{...wc,freshness:a,timeoutMs:ji,skipStaleWindowRecovery:!0,display:n.display,queryOptions:n.queryOptions,perf:s,signal:n.signal}}reconcileDisplayAfterRead(n,s,a){let c=I.has(n.predictionContext?.toolName??""),d=()=>s.refreshForDisplayChange||this.actionDisplayRevision()!==s.displayRevision;if(s.reresolvesTarget&&d()&&a?.displayRevision!==void 0&&a.displayRevision===this.displayTransitionReader.revision(this.device.deviceId))s.displayRevision=this.actionDisplayRevision(),s.observedGeneration=this.displayTransitionReader.identityRevision(this.device.deviceId),s.fence=this.captureDisplayFence(s.observedGeneration),s.refreshForDisplayChange=!1;if(c&&d())throw this.staleDisplay(s.observedGeneration);return c}async readActionClock(n){return n.track("getActionStartTime",async()=>{let s=0;if(this.device.platform==="android"&&typeof this.adb.getDeviceTimestampMs==="function")s=await this.actionClockSkewCache.getSkewMs(this.device.deviceId,()=>typeof this.adb.getDeviceTimestampMsWithSource==="function"?this.adb.getDeviceTimestampMsWithSource():this.adb.getDeviceTimestampMs())??0;return{actionStartTime:this.timer.now()+s,clockSkewMs:s}})}runBlock(n,s,a,{options:c,stage:d}){let{perf:l,coordinateAction:u}=d;return l.track("executeBlock",async()=>{if(o(c.signal),u&&this.actionDisplayRevision()!==a.displayRevision)throw this.staleDisplay(a.observedGeneration);try{return await n(s,a.fence)}finally{if(c.foregroundAppMayChange)this.windowCacheInvalidator.invalidate(this.device,!0)}})}isUnconfirmedIosFailure(n,s){return this.device.platform==="ios"&&n?.success===!1&&n.retryable===!1&&!(s.observePartialApplication&&n.partialApplication===!0)}invalidateCtrlProxyCacheForDisplay(n){if(n.display===void 0)return;if(this.device.platform==="android")E.getExistingInstance(this.device.deviceId)?.invalidateCache();else if(this.device.platform==="ios")x.getExistingInstance(this.device.deviceId)?.invalidateCache();o(n.signal)}async awaitUiStability(n,s,a,c){if(n.skipUiStability)return e.info("[BaseVisualChange] Skipping UI stability tracking (skipUiStability=true)"),null;if(this.device.platform!=="android")return e.debug("[BaseVisualChange] Skipping UI stability tracking (gfxinfo is Android-only)"),null;if(!s)return null;e.info(`[BaseVisualChange] Starting UI stability initialization with package: ${s}`);let d=await c.track("initUiStability",async()=>this.awaitIdle.initializeUiStabilityTracking(s,a,n.signal)).catch((u)=>(o(n.signal),e.debug(`[BaseVisualChange] UI stability initialization failed: ${u}`),null));if(s.trim()==="")return null;c.serial("uiStability");let l=d!==null?await this.awaitIdle.waitForUiStabilityWithState(s,a,d,{perf:c,signal:n.signal}):await this.awaitIdle.waitForUiStability(s,a,c,n.signal);return c.end(),l}annotateDeviceLock(n,s){if(!n||this.device.platform!=="android")return;let a=s?.deviceLock;if(!a?.locked)return;delete n.deviceLockUnknown,n.deviceLock=a,n.deviceLockWarning=oe(a),e.warn(`[BaseVisualChange] ${n.deviceLockWarning}`)}async recordDeferredPredictionOutcome(n,s){if(!n||typeof n!=="object")return;let a=this.deferredPredictionOutcomes.get(n);if(!a)return;this.deferredPredictionOutcomes.delete(n),await a(s)}async captureTerminalObservationScreenshot(n,s=new U,a){if(!n)return;if(this.shouldCapturePostActionScreenshot()||N.isAccessibilityAuditEnabled()){if(this.observeScreen.captureScreenshot&&await vW(n,async(c,d)=>{await this.observeScreen.captureScreenshot?.(s,{signal:d??a,observation:c})}))return;await this.observeScreen.captureScreenshot?.(s,{signal:a,observation:n});return}await this.observeScreen.runAccessibilityAudit?.(n,s)}compareActiveWindow(n,s){return G(n,s)}deriveInteractionEffect(n,s){return q(n,s)}capturePostActionObservation(n,s,a,c){return new D(this.timer).capturePostActionObservation(n,s,a,c)}notePostActionReadFailure(n,s,a,c){return new D(this.timer).notePostActionReadFailure(n,s,a,c)}rethrowObservationAbort(n,s,a=!0){if(!a)return;if(o(s),n instanceof Error&&n.name==="AbortError")throw n}checkPostActionDisplay(n,s,a){try{return s?.(),!0}catch(c){if(o(a),c instanceof Error&&c.name==="AbortError")throw c;if(!n.observation||!pl(n.observation,n.observation,!0))throw new hr(c);let d=this.notePostActionReadFailure(n.observation,"display settle validation",r(c),c);return n.observation=d.observation,n.staleDisplay=d.staleDisplay??n.staleDisplay,!1}}async settleDisplayObservation(n,s,a){try{let c=await new Qm(s,this.timer).execute({...a,initialMinTimestampMs:hn(n.viewHierarchy),skipPerformanceAudit:!0,skipRecompositionTracking:!0});return o(a.signal),pl(n,c.observation,!0)?{observation:c.observation,readFailed:!1}:this.notePostActionReadFailure(n,"display settle","unusable settle capture",this.staleDisplay(n.display.generation??this.displayTransitionReader.identityRevision(this.device.deviceId)))}catch(c){if(o(a.signal),c instanceof Error&&c.name==="AbortError")throw c;return this.notePostActionReadFailure(n,"display settle",r(c),c)}}async finalizePostActionCapture(n,s){try{return await this.captureTerminalObservationScreenshot(n.observation,s.perf,s.signal),n}catch(a){if(s.display===void 0)throw a;this.rethrowObservationAbort(a,s.signal);let c=this.notePostActionReadFailure(n.observation,"terminal screenshot/audit",r(a),a);return{...c,staleDisplay:c.staleDisplay??n.staleDisplay}}}async refineCapture(n,s,a,c){let d=n;if(a.display!==void 0&&!d.readFailed&&ee(d.observation))d=await this.settleDisplayObservation(d.observation,s,{display:a.display,signal:a.signal});if(!a.deferPostActionScreenshot)d=await this.finalizePostActionCapture(d,{...a,perf:c});return d}async takeObservation(n,s,a){let c=a.perf??new U,d=a.postActionObserveScreen??this.observeScreen,l=a.actionStartTime??0,u=An(s?.viewHierarchy),p=(y)=>J(y,l,a.changeExpected,u),f=await this.capturePostActionObservation(d,{freshness:"fresh",display:a.display,queryOptions:a.queryOptions,perf:c,minTimestamp:l,signal:a.signal,...wc},p,n);if(!f.readFailed&&p(f.observation))re(f.observation,l);f=await this.refineCapture(f,d,a,c);let m=f.observation,h=n;if(f.staleDisplay)h.staleDisplay=f.staleDisplay;let A=a.changeExpected?WL(s?.viewHierarchy,m.viewHierarchy):null;if(te(h,A),ne(m,a.gfxMetrics,c),h.observation=m,a.predictionContext)await this.predictionAnalyzer.recordOutcomeForAction(s,m,a.predictionContext);return B(h)}async verifyAndroidHomeForeground(n={}){return new W({window:this.window,adb:this.adb,deviceId:this.device.deviceId,formFactor:this.device.formFactor,timer:this.timer}).verify(n)}}var jt={rawCoordinateGesture:{changeExpected:!1},selectorResolvedGesture:{changeExpected:!1,resolvesTargetFromRead:!0},noTreeResolution:{usesObservationForResolution:!1,changeExpected:!1},textEdit:{usesObservationForResolution:!1,changeExpected:!1,skipUiStability:!0},appLaunch:{changeExpected:!1,skipPreviousObserve:!0,deferPostActionScreenshot:!0}},Tt={immediate:100,brief:500,gesture:800,navigation:2000,systemUi:3000,lifecycle:5000,longGesture:8000,urlDispatch:12000};
3
+ export{Fv,w3,Ite,Ru,vW,_te,bW,bp,SW,$C,xte,pl,_L,wc,Lv,UC,DT,wW,HC,Oe,jt,Tt};
4
+
5
+ //# debugId=CC0F5389792EEF5364756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{Rw,BF,bc}from"./chunk-qy3khhf8.js";import"./chunk-c27yv1dx.js";import"./chunk-661c50hh.js";import"./chunk-b3tdtq7r.js";import"./chunk-cqhw4yr6.js";import"./chunk-vdqag3fj.js";import"./chunk-e0870khr.js";import"./chunk-4vxeq0vd.js";import"./chunk-9xgnrv5w.js";import"./chunk-cb1ga9rd.js";import"./chunk-sfqe223f.js";import"./chunk-r6pvhj33.js";import"./chunk-w5yypt53.js";import"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{bc as TapOnElement,Rw as tapFocusFailure,BF as tapResolvedLayer};
3
+
4
+ //# debugId=45AF5989A69E566964756E2164756E21
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import{B,kt,ti,Wn}from"./chunk-r6pvhj33.js";import{i,Ld,Se,Je,l,e}from"./chunk-r0vp315h.js";import{h,pt}from"./chunk-5wk1t46v.js";import{He,H,ee,nt,db,md,Cu,Oo,ke,b,Ug,un,Jn,Pr,XR}from"./chunk-sfqe223f.js";import{C3,To,La}from"./chunk-4vxeq0vd.js";import{ap,lu}from"./chunk-8nj68t1v.js";import{n,a,m,S,s,p}from"./chunk-w5yypt53.js";import{r,t,u}from"./chunk-2b39zyxc.js";import{access as ae}from"fs/promises";import{existsSync as K}from"fs";import{access as ne}from"fs/promises";import{dirname as T,join as R}from"path";import{fileURLToPath as oe}from"url";var k=R("ios","control-proxy","CtrlProxy.xcodeproj");async function Q(o,c={}){let d=c.access??ne,f=[Se(o),(c.launchDirectory??(()=>Ld()))(),(c.packageRoot??se)()].filter((g)=>typeof g==="string"&&g.length>0),y=[...new Set(f.map((g)=>R(g,k)))];for(let g of y)try{return await d(g),{found:!0,projectPath:g,checked:y}}catch(w){e.debug(`CtrlProxy project not at ${g}: ${r(w)}`)}return{found:!1,checked:y}}var C;function se(){if(C===void 0){let o=T(oe(import.meta.url));while(!K(R(o,"package.json"))&&T(o)!==o)o=T(o);C=K(R(o,"package.json"))?o:null}return C??void 0}var I="CtrlProxyWatch";class W{dependencies;builds=new nt;constructor(o){this.dependencies=o}async resolve(o){o?.throwIfAborted();let c=(this.dependencies.override??(()=>pt(h.WATCH_RUNNER_XCTESTRUN)))();if(c){let g=Se(c);return await(this.dependencies.access??ae)(g),g}let d=this.dependencies.builder,f=await d.getXctestrunPath("watchSimulator");if(f)return f;let y=d.getConfig();return await this.builds.run(y.derivedDataPath,async(g)=>await H(g,async()=>{let w=async()=>{g?.throwIfAborted();let v=await Q(y.projectRoot,{...this.dependencies.projectLocator,access:this.dependencies.access});if(!v.found)throw de(v.checked,y.derivedDataPath);let P=v.projectPath;await(this.dependencies.xcodebuild??new Jn).executeCommand(["build-for-testing","-project",P,"-scheme",I,"-destination","generic/platform=watchOS Simulator","-derivedDataPath",y.derivedDataPath,"CODE_SIGNING_ALLOWED=NO"],{signal:g,timeoutMs:120000});let x=await d.getXctestrunPath("watchSimulator");if(!x)throw new t(`No watchsimulator xctestrun found in ${y.derivedDataPath}/Build/Products after building ${I}; set ${h.WATCH_RUNNER_XCTESTRUN.name} to a prebuilt watch runner.`);return x};return d.runExclusiveOnDerivedData?await d.runExclusiveOnDerivedData(w):await w()}),o,{cancelWhenAllWaitersAbort:!0})}}function ce(o,c){return`xcodebuild build-for-testing -project ${o} -scheme ${I} -destination 'generic/platform=watchOS Simulator' -derivedDataPath ${c} CODE_SIGNING_ALLOWED=NO`}function de(o,c){return new t([`The ${I} watch runner is not built in ${c} and ${k} was not found at: ${o.join(", ")}.`,`From an AutoMobile checkout, set ${h.PROJECT_ROOT.name} to the checkout root and retry startDevice to build it automatically,`,`or build it yourself: ${ce(`<checkout>/${k}`,c)}.`,`The published package does not include the watch project; there, set ${h.WATCH_RUNNER_XCTESTRUN.name} to a prebuilt watch runner xctestrun.`].join(" "))}import le from"ws";var pe=(o)=>{let c=new le(o);return{send:(d)=>c.send(d),close:()=>c.close(),onMessage:(d)=>{c.on("message",(f)=>d(f.toString()))},onFailure:(d)=>{c.on("error",d),c.on("close",()=>d(Error("Watch runner disconnected; reconnect it.")))}}};class D{options;socket;pending=new Map;sequence=0;supported=new Set;ready;resolveReady;rejectReady;failure;constructor(o,c={}){this.options=c;this.ready=new Promise((d,f)=>{this.resolveReady=d,this.rejectReady=f}),this.ready.then(void 0,()=>{}),this.socket=(c.factory??pe)(o),this.socket.onMessage((d)=>this.receive(d)),this.socket.onFailure((d)=>this.fail(u(d,"Watch runner connection failed")))}isUsable(){return this.failure===void 0}fail(o){this.failure=o,this.rejectReady(o);for(let c of this.pending.values())c.reject(o);this.pending.clear()}receive(o){try{let c=JSON.parse(o);if(!c||typeof c!=="object"||!("type"in c))throw new t("Invalid watch runner response; reconnect it.");let d=c;if(d.type==="connected")this.connected(d);else this.reply(d)}catch(c){this.fail(u(c,"Invalid watch runner response")),this.socket.close()}}connected(o){if(o.platform!=="watchos"){this.fail(new La("Refusing runner: connected platform must be watchos.","invalid_runner_platform")),this.socket.close();return}this.supported=new Set(Array.isArray(o.supportedCommands)?o.supportedCommands.filter((c)=>typeof c==="string"):[]),this.resolveReady();return}reply(o){let c=typeof o.requestId==="string"?this.pending.get(o.requestId):void 0;if(!c)return;if(o.type==="error"||o.success===!1)c.reject(new La(String(o.error??"Watch command failed"),String(o.errorCode??"command_failed")));else if(o.type===(c.type==="hierarchy"?"hierarchy_update":`${c.type}_result`)&&o.success===!0)c.resolve(o.type==="face_result"?o.text??o.data:o.data)}async request(o,c,d){let f=this.options.timer??i,y=d?.timeoutMs??this.options.timeoutMs??5000,g=String(++this.sequence),w=new AbortController,v=c?AbortSignal.any([c,w.signal]):w.signal;try{return await l(async()=>{if(await this.ready,v.throwIfAborted(),this.failure)throw this.failure;if(!this.supported.has(o.type))throw new La(`The watch runner does not support ${o.type}.`,"unsupported_on_watchos");return new Promise((P,x)=>{this.pending.set(g,{type:o.type,resolve:P,reject:x}),this.socket.send(JSON.stringify({...o,requestId:g}))})},{timer:f,timeoutMs:y,signal:v,label:`Watch runner ${o.type}`})}finally{w.abort(),this.pending.delete(g)}}async hierarchy(o){let c=await this.request({type:"hierarchy"},o);if(!C3(c))throw new t("Invalid watch hierarchy; reconnect the runner.");return c}close(){this.fail(new t("Watch runner closed; reconnect it.")),this.socket.close()}}import{rm as ue}from"fs/promises";class N{dependencies;constructor(o){this.dependencies=o}async launch(o){if(!Number.isInteger(o.port)||o.port<1||o.port>65535)throw new t("Watch runner port must be an integer from 1 to 65535.");if(To.get(o.deviceId))throw new t("Watch runner is already connected.");o.signal?.throwIfAborted();let c=await this.dependencies.writeRunnerEnvironment(o.xctestrun,{AM_PORT:String(o.port)},`watch-${o.deviceId}`),d=!1,f=()=>{if(!d&&c!==o.xctestrun)d=!0,ue(c,{force:!0}).catch((y)=>{e.warn("Failed to remove watch runner xctestrun copy",y)})};try{return await this.launchPrepared({...o,xctestrun:c},f)}catch(y){throw f(),u(y,"Failed to launch watch runner")}}async launchPrepared(o,c){let d=this.dependencies.timer??i;o.signal?.throwIfAborted();let f=await(this.dependencies.xcodebuild??new Jn).startStreaming(["test-without-building","-xctestrun",o.xctestrun,"-destination",`platform=watchOS Simulator,id=${o.deviceId}`,"-only-testing:CtrlProxyWatchUITests/CtrlProxyWatchUITests/testRunService"],{env:{...globalThis.process.env,TEST_RUNNER_AM_PORT:String(o.port),...o.bundleId!==void 0?{TEST_RUNNER_AM_BUNDLE_ID:o.bundleId}:{}},stdio:"ignore",startupSignal:o.signal}),y={exited:!1,unregister:()=>{}},g=()=>{y.exited=!0,y.unregister(),y.client?.close(),c()},w=()=>{let v=!y.exited;if(g(),v)f.kill("SIGTERM")};f.once("exit",g),f.once("error",g);try{return await l(()=>this.waitForRunner(o,y),{timer:d,timeoutMs:60000,label:"Watch runner startup",onTimeout:w,signal:o.signal}),{stop:w}}catch(v){throw w(),u(v,"Failed to launch watch runner")}}async waitForRunner(o,c){let d=this.dependencies.timer??i;while(!c.exited){let f=(this.dependencies.connect??((y)=>new D(y,{timer:d})))(`ws://127.0.0.1:${o.port}/ws`);c.client=f;try{await f.hierarchy(o.signal)}catch(y){if(f.close(),c.exited||o.signal?.aborted||y instanceof La)throw u(y,"Watch runner exited during startup");e.debug("Watch runner not ready during startup",y),await d.sleep(100);continue}if(c.exited)break;o.signal?.throwIfAborted(),c.unregister=To.register(o.deviceId,f);return}throw new t("Watch runner exited before becoming ready; check the prebuilt test bundle.")}}class Z{dependencies;runners=new Map;observedSessions=new WeakSet;constructor(o){this.dependencies=o}async ensure(o){let c=await this.start(o);return this.attach(o)??c.runnerUnavailable}async start(o){let{deviceId:c,bundleId:d,sessions:f,signal:y}=o;return this.launchEntry({deviceId:c,bundleId:d,sessions:f,signal:y})}async launchEntry(o){let{deviceId:c,sessions:d}=o;if(d)this.observeSessions(d);if(To.get(c)?.isUsable())return{};if(this.stop(c),To.get(c))return{runnerUnavailable:`The watch runner for ${c} is disconnected and was not started by AutoMobile; restart it before trying again.`};let y={controller:new AbortController,bundleId:o.bundleId,ownerSession:o.ownerSession},g=He(o.signal,y.controller.signal);this.runners.set(c,y);try{let w=await this.dependencies.artifacts.resolve(g);g.throwIfAborted(),y.port=this.dependencies.ports.allocate(c);let v=await this.dependencies.launcher.launch({deviceId:c,bundleId:o.bundleId,xctestrun:w,port:y.port,signal:g});if(y.stop=v.stop,g.aborted||this.runners.get(c)!==y){if(this.runners.get(c)!==y)v.stop();throw new t("the watch session ended during runner startup")}return{stop:()=>{if(this.runners.get(c)===y)this.stop(c)}}}catch(w){if(this.runners.get(c)===y)this.stop(c);let v=r(w);return e.warn(`[WatchRunner] Runner unavailable for ${c}: ${v}`,w),{runnerUnavailable:v}}}async retarget(o){let c=this.runners.get(o.deviceId);if(!c)return;if(c.bundleId===o.bundleId&&To.get(o.deviceId)?.isUsable()===!0)return;let d=c.ownerSession;try{return this.stop(o.deviceId),(await this.launchEntry({...o,ownerSession:d})).runnerUnavailable}catch(f){let y=r(f);return e.warn(`[WatchRunner] Failed to retarget runner for ${o.deviceId}: ${y}`,f),y}}attach({deviceId:o,ownerSession:c,sessions:d}){if(this.observeSessions(d),!d.hasSession(c))return this.stop(o),"the watch session ended before runner startup";let f=this.runners.get(o);if(f)f.ownerSession=c;return}stop(o){let c=this.runners.get(o);if(!c)return;this.runners.delete(o),c.controller.abort(new t("Watch runner lifecycle ended"));try{c.stop?.()}catch(d){e.warn(`[WatchRunner] Failed to stop runner for ${o}`,d)}finally{if(c.port!==void 0)this.dependencies.ports.release(o,c.port)}}stopSession(o){for(let[c,d]of this.runners)if(d.ownerSession===o)this.stop(c)}stopAll(){for(let o of this.runners.keys())this.stop(o)}observeSessions(o){if(this.observedSessions.has(o))return;this.observedSessions.add(o),o.onSessionRelease((c)=>this.stopSession(c)),o.onSessionDeviceUnbound((c,d)=>{if(this.runners.get(d)?.ownerSession===c)this.stop(d)})}}var O;function fX(o){O=o}function L(){if(!O)throw new t("Watch runner builder has not been registered by the server.");return O()}var E;function Xf(){if(!E)E=new Z({artifacts:new W({builder:{getXctestrunPath:(o)=>L().getXctestrunPath(o),getConfig:()=>L().getConfig(),runExclusiveOnDerivedData:(o)=>{let c=L();return c.runExclusiveOnDerivedData?c.runExclusiveOnDerivedData(o):o()}}}),launcher:new N({writeRunnerEnvironment:(o,c,d)=>L().writeRunnerEnvironment(o,c,`${d}-${B.next()}`)}),ports:{allocate:(o)=>ke.allocate(`watch:${o}`,{reservedPorts:Oo}),release:(o,c)=>ke.releaseIfAllocated(`watch:${o}`,c)}}),process.once("exit",()=>E?.stopAll());return E}function hX(){E?.stopAll()}import{join as M}from"path";import{join as he}from"path";class _{options;timer;ownerToken;constructor(o){this.options=o;this.timer=o.timer??i,this.ownerToken=o.ownerToken??B.next()}async withLock(o,c){let d=he(o,this.options.fileName),f=this.timer.now()+this.options.timeoutMs;while(!ti(d,{ownerToken:this.ownerToken,ownerGeneration:kt})){if(this.timer.now()>=f)throw new t(`Timed out waiting for ${this.options.description} at ${d}. ${this.options.holderActivity}; retry, or remove the lock if no such process is running.`);await this.timer.sleep(this.options.pollMs??100)}try{return await c()}finally{Wn(d,process.pid,this.ownerToken)}}}var j=["bumble==0.0.236","grpcio==1.85.1","protobuf==7.36.2"],GM="Install Python 3.11 with venv support, ensure python3 is on the daemon's PATH, then retry blePeripheral start.",A=[3,11];function me(o){let c=/Python (\d+)\.(\d+)/.exec(o);return c?[Number(c[1]),Number(c[2])]:void 0}function fe([o,c]){return o>A[0]||o===A[0]&&c>=A[1]}var ye=300000;function ge(){return new _({fileName:"provision.lock",description:"the BLE Python environment lock",holderActivity:"Another AutoMobile process is installing the BLE Python environment",timeoutMs:ye,pollMs:250})}class F{deps;pending;lock;constructor(o){this.deps=o;this.lock=o.lock??ge()}ensure(){return this.pending??=this.provision().finally(()=>{this.pending=void 0}),this.pending}async provision(){let{files:o}=this.deps,c=(this.deps.directory??(()=>Je("ble-peripheral")))(),d=M(c,"venv"),f=M(d,(this.deps.platform??process.platform)==="win32"?"Scripts/python.exe":"bin/python3"),y=M(c,"pins.json"),g=JSON.stringify(j),w=async()=>o.existsSync(f)&&o.existsSync(y)&&await o.readFile(y)===g;try{if(await w())return f;return await this.assertSupportedPython(),await o.ensureDir(c),await this.lock.withLock(c,async()=>{if(await w())return f;return await this.install(d,f),await o.writeFile(y,g),f})}catch(v){throw u(v,`Could not prepare BLE Python environment at ${d}. ${GM}`)}}async install(o,c){let{commands:d}=this.deps;await d.executeCommand("python3",["-m","venv","--clear",o],{timeoutMs:60000});try{await d.executeCommand(c,["-I","-m","pip","install",...j],{timeoutMs:180000})}catch(f){throw new t(`BLE dependency installation failed. Check network access to PyPI and run ${b(c)} -I -m pip install ${j.join(" ")}, then retry start.`,{cause:f})}}async assertSupportedPython(){let o;try{let d=await this.deps.commands.executeCommand("python3",["--version"],{timeoutMs:1e4});o=`${d.stdout}
3
+ ${d.stderr}`}catch(d){throw new t(`python3 is unavailable. ${GM}`,{cause:d})}let c=me(o);if(!c||!fe(c))throw new t(`python3 reports ${c?c.join("."):"an unrecognized version"}; Bumble needs Python ${A.join(".")}+. ${GM}`)}}var we="Shared netsim: every emulator on this host can see this peripheral. Set AUTOMOBILE_EMULATOR_NETSIM_ISOLATION=true and relaunch the emulator for a private netsim.";function U(o,c,d){let f=c.transport==="android-netsim";return{handle:o,...c,...d,transportShared:f,...f?{warning:we}:{}}}var ve=256;class q{deps;peripherals=new Map;ended=new Set;closed=!1;constructor(o){this.deps=o}async run(o,c,d){if(!o)throw new t("blePeripheral requires a live device session. Acquire a session first.");if(this.closed||this.ended.has(o))throw new t("BLE session ended or daemon is shutting down; acquire a new session.");if(d?.throwIfAborted(),c.action==="start")return this.start(o,c,d);let f=this.peripherals.get(c.handle);if(!f||f.owner!==o||!f.config)throw new t("Unknown BLE handle for this session. Use a handle returned by this session's start.");if(c.action==="stop"){await f.sidecar.stop();let y=await f.sidecar.status();return this.peripherals.delete(c.handle),U(c.handle,f.config,y)}if(c.action==="notify")await f.sidecar.notify(c);return U(c.handle,f.config,await f.sidecar.status())}async start(o,c,d){let f=this.deps.ids.next(),y={owner:o,sidecar:this.deps.sidecars.create(),controller:new AbortController};this.peripherals.set(f,y);let g=()=>y.controller.abort(d?.reason);d?.addEventListener("abort",g,{once:!0});try{let w=await this.deps.environments.ensure();y.controller.signal.throwIfAborted();let v=await this.deps.transports.resolve(c.deviceId,c.transport);y.controller.signal.throwIfAborted();let P={name:c.name,address:c.address??"F0:F1:F2:F3:F4:F5",presets:c.presets,services:c.services,transport:v};y.config=P,await y.sidecar.start(w,P,y.controller.signal),y.controller.signal.throwIfAborted();let x=await y.sidecar.status();if(y.controller.signal.throwIfAborted(),!x.running)throw new t("BLE sidecar stopped during startup; check the transport and start again.");return U(f,P,x)}catch(w){try{await y.sidecar.stop(),this.peripherals.delete(f)}catch(v){y.cleanupFailed=!0,e.warn("BLE sidecar cleanup after a failed start did not complete",v)}throw u(w,"BLE peripheral start failed; check python3, Bumble dependencies and the netsim transport")}finally{d?.removeEventListener("abort",g)}}releaseSession(o){if(![...this.peripherals.values()].some((c)=>c.owner===o))return Promise.resolve();this.ended.add(o);for(let c of this.ended){if(this.ended.size<=ve)break;this.ended.delete(c)}return this.stopMatching((c)=>c.owner===o)}shutdown(){return this.closed=!0,this.stopMatching(()=>!0)}unbindSession(o){return this.stopMatching((c)=>c.owner===o)}async stopMatching(o){let c=[];for(let[y,g]of this.peripherals){if(!o(g))continue;g.controller.abort(new t("BLE owner released")),c.push(g.sidecar.stop().then(()=>{this.peripherals.delete(y)}))}let f=(await Promise.allSettled(c)).find((y)=>y.status==="rejected");if(f?.status==="rejected")throw u(f.reason,"Failed to kill a BLE sidecar; retry cleanup")}}var G=/^android-netsim(?::(?:localhost|127\.0\.0\.1):(\d{1,5}))?$/,X=n().regex(/^(?:[0-9a-f]{4}|[0-9a-f]{8}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i),te=s({value:n().max(1024),encoding:p(["utf8","hex"]).default("utf8")}).strict().refine((o)=>o.encoding!=="hex"||/^(?:[0-9a-f]{2})*$/i.test(o.value),"Hex values need pairs of hexadecimal digits"),Pe=s({action:p(["start","stop","notify","status"]),name:n().min(1).max(20).optional().describe("Advertised local name (at most 20 UTF-8 bytes)"),address:n().regex(/^(?:[0-9a-f]{2}:){5}[0-9a-f]{2}$/i).optional().describe("Default F0:F1:F2:F3:F4:F5; use distinct addresses for simultaneous peripherals"),presets:S(p(["battery","heartRate","custom"])).min(1).max(3).optional(),services:S(s({uuid:X,characteristics:S(s({uuid:X,properties:S(p(["read","notify"])).min(1).max(2),initialValue:te.optional()}).strict()).min(1).max(16)}).strict()).min(1).max(8).optional().describe("Required with the custom preset"),deviceId:n().min(1).optional().describe("Android emulator serial; defaults to the session's device"),transport:n().min(1).max(512).regex(G,"transport must be android-netsim or android-netsim:localhost:<port>").optional().describe("android-netsim or android-netsim:localhost:<port>; must match the netsim of the session's emulator"),handle:n().min(1).optional().describe("Session-owned handle returned by start; required for stop/notify/status"),characteristic:n().min(1).optional().describe("battery, heartRate, or a configured custom characteristic UUID"),level:a().int().min(0).max(100).optional(),bpm:a().int().min(0).max(65535).optional(),value:te.optional().describe("Custom notification bytes as UTF-8 or hex"),sessionUuid:n().min(1).optional().describe("Calling device session")}).strict();function xe(o,c){if(!o.name||!o.presets)c("start requires name and presets");if(o.name&&Buffer.byteLength(o.name)>20)c("name exceeds 20 UTF-8 bytes");if(o.presets?.includes("custom")!==Boolean(o.services))c("custom preset requires services, and services require the custom preset");if(o.presets&&new Set(o.presets).size!==o.presets.length)c("presets must be unique");let d=o.services?.flatMap((f)=>[f.uuid.toLowerCase(),...f.characteristics.map((y)=>y.uuid.toLowerCase())])??[];if(new Set(d).size!==d.length)c("custom service and characteristic UUIDs must be unique")}function Ee(o,c){if(!o.characteristic)c("notify requires characteristic");else if(o.characteristic==="battery"&&o.level===void 0)c("battery requires level (0-100)");else if(o.characteristic==="heartRate"&&o.bpm===void 0)c("heartRate requires bpm");else if(!["battery","heartRate"].includes(o.characteristic)&&(!X.safeParse(o.characteristic).success||!o.value))c("custom notifications require a characteristic UUID and value")}var gX=Pe.superRefine((o,c)=>{let d=(f)=>c.addIssue({code:"custom",message:f});if(o.action==="start")xe(o,d);else if(!o.handle)d(`${o.action} requires handle`);if(o.action==="notify")Ee(o,d)}),J=s({running:m(),advertising:m(),connected:S(n()),subscribed:S(n()),pythonReady:m(),bumbleReady:m()}),yX=J.extend({handle:n(),name:n(),address:n(),presets:S(p(["battery","heartRate","custom"])),transport:n(),transportShared:m().describe("True when transport is the host-wide netsim that every emulator can see"),warning:n().optional().describe("Present when transportShared is true")});function Re(o){let c=G.exec(o),d=c?.[1]===void 0?void 0:Number(c[1]);if(!c||d!==void 0&&(d<1||d>65535))throw new t("BLE transport must be android-netsim or android-netsim:localhost:<port> for this session's emulator.");return d===void 0?"android-netsim":`android-netsim:localhost:${d}`}class z{sources;constructor(o){this.sources=o}async resolve(o,c){let d=c===void 0?void 0:Re(c),f=await this.discover(o);if(d!==void 0&&d!==f)throw new t(`BLE transport ${c} does not belong to this session's emulator, which uses ${f}. Omit transport or pass ${f}.`);return f}async discover(o){if(!o)return"android-netsim";let c=db(o);if(c===void 0)throw new t("BLE netsim discovery requires an Android emulator serial. Use a session on an Android emulator (emulator-<port>).");let d=await this.sources.discovery.findByConsolePort(c),f=await this.sources.processes.read({});if(!f.value||f.incomplete)throw new t("Cannot resolve this emulator's private netsimd from the host process table. Retry once the emulator is running.");let y=f.value.filter((g)=>Cu(g)&&(d?g.pid===d.pid:md(g.command).port===c));if(y.length>1)throw new t("Ambiguous emulator identity; stop duplicate emulators on this console port and retry.");if(d&&y.length===0)throw new t("The advertised emulator could not be identified in the host process table; retry BLE start.");return this.assertConsolePort(y[0]?.command,c),this.transportFromArguments(y[0]?.command.split(/\s+/)??[])}assertConsolePort(o,c){if(!o)return;let d=md(o).port;if(d!==void 0&&d!==c)throw new t("Emulator advertisement and process console ports disagree; retry BLE discovery.")}transportFromArguments(o){let c=o.flatMap((y,g)=>y==="-packet-streamer-endpoint"?[o[g+1]??""]:y.startsWith("-packet-streamer-endpoint=")?[y.slice(26)]:[]);if(c.length===0)return"android-netsim";let d=c[0],f=/^(?:localhost|127\.0\.0\.1):(\d+)$/.exec(d);if(c.length!==1||!f||Number(f[1])<1||Number(f[1])>65535)throw new t("Unsupported emulator packet-streamer endpoint; restart the emulator with a localhost netsim endpoint.");return`android-netsim:localhost:${Number(f[1])}`}}import{existsSync as Be}from"fs";import{fileURLToPath as re}from"url";import{createInterface as Ie}from"readline";var Le=s({event:p(["ready","advertising","connected","disconnected","status","notified","stopped","error"]),id:a().int().optional(),message:n().optional(),status:J.optional()});function Ae(){let o=re(new URL("./sidecar/peripheral.py",import.meta.url));return Be(o)?o:re(new URL("./ble-peripheral.py",import.meta.url))}class Y{deps;tracker;lines;child;sequence=0;pending=new Map;snapshot={running:!1,advertising:!1,connected:[],subscribed:[],pythonReady:!1,bumbleReady:!1};ready;stopped=!1;constructor(o){this.deps=o}async start(o,c,d){if(d.throwIfAborted(),this.stopped)throw new t("BLE sidecar already stopped");let f=new Promise((g,w)=>{this.ready={resolve:g,reject:w}}),y=l(f,{timer:this.deps.timer,timeoutMs:15000,signal:d,label:"BLE sidecar startup"});try{this.attach(this.deps.spawner.spawn(o,["-I","-u",(this.deps.script??Ae)()],{stdio:["pipe","pipe","pipe"],windowsHide:!0})),this.write({...c,action:"start"}),await y}catch(g){throw this.fail(u(g,"BLE sidecar startup failed")),await y.catch((w)=>e.debug("BLE startup rejection joined",w)),u(g,"Could not start BLE sidecar; check the Python environment and netsim transport")}}attach(o){this.child=o;let c=[];if(this.tracker={process:o,stderr:c,...Ug(o,c,{maxStderrChars:4096})},this.tracker.exitPromise.then(()=>this.fail(new t(`BLE sidecar exited. ${c.join("").slice(-4096)} Check the netsim transport and restart the peripheral.`)),(d)=>this.fail(u(d,"BLE sidecar process failed"))),o.stdin?.on("error",(d)=>this.fail(u(d,"BLE sidecar stdin failed"))),!o.stdout||!o.stdin||!o.stderr)throw new t("BLE sidecar needs stdin/stdout/stderr pipes");this.lines=Ie({input:o.stdout}),this.lines.on("line",(d)=>this.receive(d)),this.lines.on("close",()=>this.fail(new t("BLE sidecar stdout closed; restart the peripheral"))),o.stdout.on("error",(d)=>this.fail(u(d,"BLE sidecar stdout failed")))}receive(o){if(this.stopped)return;try{if(o.length>65536)throw new t("BLE sidecar response exceeds 64 KiB");let c=Le.parse(JSON.parse(o));this.handleEvent(c)}catch(c){this.fail(u(c,"Invalid BLE sidecar JSON response"))}}handleEvent(o){if(o.status)this.snapshot=o.status;if(o.event==="error"){let c=new t(`BLE sidecar: ${o.message??"unknown error"}`);if(o.id===void 0)this.fail(c);else this.pending.get(o.id)?.reject(c)}else if(o.event==="ready"){if(!o.status?.running)throw new t("BLE ready event must report a running peripheral");this.ready?.resolve()}else if(o.id!==void 0)this.pending.get(o.id)?.resolve()}write(o){if(!this.child?.stdin||this.child.stdin.destroyed)throw new t("BLE sidecar stdin is unavailable; restart the peripheral");this.child.stdin.write(`${JSON.stringify(o)}
4
+ `)}async request(o,c={}){if(!this.snapshot.running||this.stopped)throw new t("BLE sidecar is stopped; start a new peripheral");let d=++this.sequence,f=new Promise((g,w)=>{this.pending.set(d,{resolve:g,reject:w})}),y=l(f,{timer:this.deps.timer,timeoutMs:1e4,label:`BLE ${o}`});try{this.write({action:o,id:d,...c}),await y}catch(g){throw this.pending.get(d)?.reject(u(g,`BLE ${o} failed`)),await y.catch((w)=>e.debug("BLE command rejection joined",w)),u(g,`BLE ${o} failed`)}finally{this.pending.delete(d)}}notify(o){return this.request("notify",o)}async status(){if(this.snapshot.running&&!this.stopped)await this.request("status");return this.snapshot}async stop(){if(this.snapshot.running&&!this.stopped)try{this.write({action:"stop",id:++this.sequence})}catch(o){e.warn("BLE stop command could not be written; killing the sidecar",o)}if(this.stopped=!0,this.fail(new t("BLE sidecar stopped")),this.tracker){if(this.child?.pid===void 0){await this.tracker.exitPromise.catch((o)=>e.debug("BLE process never spawned",o)),this.lines?.close();return}try{await un(this.tracker.process,this.tracker.exitPromise,{timer:this.deps.timer,timeoutMs:500,forceKillTimeoutMs:500,signal:"SIGKILL"})}catch(o){throw u(o,"Could not confirm BLE sidecar exit; retry stop")}this.lines?.close()}}fail(o){this.snapshot={...this.snapshot,running:!1,advertising:!1,connected:[],subscribed:[]},this.ready?.reject(o);for(let c of this.pending.values())c.reject(o);if(!this.stopped){this.stopped=!0;try{this.child?.kill("SIGKILL")}catch(c){e.warn("Failed to signal an unusable BLE sidecar",c)}}e.debug(o.message,o)}}var V=new ee,ie=new Pr,hS=new q({environments:new F({commands:V,files:ie}),transports:new z({processes:new lu(V,{timer:i,processTableSupported:process.platform!=="win32",procFs:process.platform==="linux"?ap:void 0}),discovery:new XR(ie)}),sidecars:{create:()=>new Y({spawner:V,timer:i})},ids:B});
5
+ export{fX,Xf,hX,GM,gX,yX,hS};
6
+
7
+ //# debugId=505B9BE862DDD53A64756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{GK,YK,JK}from"./chunk-dw5rwgya.js";import"./chunk-qj1tbnv2.js";import"./chunk-96r3bpg7.js";import"./chunk-s3y3zfcx.js";import"./chunk-z8tvs8nk.js";import"./chunk-xn9m3xc2.js";import"./chunk-b3tdtq7r.js";import"./chunk-cqhw4yr6.js";import"./chunk-vdqag3fj.js";import"./chunk-e0870khr.js";import"./chunk-4vxeq0vd.js";import"./chunk-9xgnrv5w.js";import"./chunk-cb1ga9rd.js";import"./chunk-sfqe223f.js";import"./chunk-r6pvhj33.js";import"./chunk-w5yypt53.js";import"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{GK as getDeviceGestureRecordingSocketPath,YK as startDeviceGestureRecordingSocketServer,JK as stopDeviceGestureRecordingSocketServer};
3
+
4
+ //# debugId=4B8F02F3900DE4C764756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{sce,pG,jU}from"./chunk-p9kt1sgr.js";import"./chunk-21h6dhdm.js";import"./chunk-r4j43b9s.js";import"./chunk-emv82m1w.js";import"./chunk-wxdjeb4k.js";import"./chunk-qj1tbnv2.js";import"./chunk-96r3bpg7.js";import"./chunk-13qxf7ym.js";import"./chunk-xcqzwf9j.js";import"./chunk-s3y3zfcx.js";import"./chunk-gadtna7s.js";import"./chunk-gcyx407v.js";import"./chunk-g3af2qbk.js";import"./chunk-3h5jz1vb.js";import"./chunk-hpzxdp1k.js";import"./chunk-tx4f0h9c.js";import"./chunk-8nj68t1v.js";import"./chunk-yqfz4vts.js";import"./chunk-jvstjnqm.js";import"./chunk-xezekwwn.js";import"./chunk-z8tvs8nk.js";import"./chunk-xn9m3xc2.js";import"./chunk-sqdrxjw5.js";import"./chunk-pf282r5g.js";import"./chunk-6hrj3jt6.js";import"./chunk-c3ewxm4x.js";import"./chunk-qy3khhf8.js";import"./chunk-c27yv1dx.js";import"./chunk-tvq0nzam.js";import"./chunk-8cvnpnbp.js";import"./chunk-661c50hh.js";import"./chunk-9q265er0.js";import"./chunk-gfpntwc1.js";import"./chunk-b3tdtq7r.js";import"./chunk-cqhw4yr6.js";import"./chunk-vdqag3fj.js";import"./chunk-e0870khr.js";import"./chunk-4vxeq0vd.js";import"./chunk-9xgnrv5w.js";import"./chunk-t54k47em.js";import"./chunk-cb1ga9rd.js";import"./chunk-69pmjdf2.js";import"./chunk-sfqe223f.js";import"./chunk-r6pvhj33.js";import"./chunk-w5yypt53.js";import"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{pG as createMcpServer,jU as refreshMcpResourceList,sce as registerMcpTools};
3
+
4
+ //# debugId=1BC15F4BAA6808D864756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{it}from"./chunk-sfqe223f.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{it as IosCtrlProxyBuilder};
3
+
4
+ //# debugId=9943A18F1B1E11A164756E2164756E21