@kaeawc/auto-mobile 0.0.93 → 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.
- package/dist/build-info.json +12 -12
- package/dist/src/ble-peripheral.py +153 -0
- package/dist/src/{chunk-r6z1eztj.js → chunk-026y62r9.js} +11 -11
- package/dist/src/chunk-0jyfg947.js +4 -0
- package/dist/src/{chunk-8g1922rp.js → chunk-0zfpp1wh.js} +4 -4
- package/dist/src/{chunk-qf6nynk6.js → chunk-13qxf7ym.js} +5 -5
- package/dist/src/chunk-1scenrk7.js +4 -0
- package/dist/src/chunk-1vb5ph1k.js +4 -0
- package/dist/src/{chunk-710rxz9y.js → chunk-20g565q7.js} +3 -3
- package/dist/src/chunk-21h6dhdm.js +5 -0
- package/dist/src/chunk-25mfpthk.js +78 -0
- package/dist/src/{chunk-rbpdk7m0.js → chunk-2b39zyxc.js} +3 -3
- package/dist/src/chunk-2gzd6wbd.js +4 -0
- package/dist/src/{chunk-xgan0qqp.js → chunk-3dntffy9.js} +1 -1
- package/dist/src/chunk-3gfczcsn.js +4 -0
- package/dist/src/{chunk-dgrbdpb7.js → chunk-3h5jz1vb.js} +6 -6
- package/dist/src/{chunk-t6c8akcm.js → chunk-41zcy6b3.js} +3 -3
- package/dist/src/chunk-47n9m2de.js +4 -0
- package/dist/src/chunk-4vxeq0vd.js +58 -0
- package/dist/src/chunk-59dx6qaf.js +4 -0
- package/dist/src/chunk-5sdf9y92.js +4 -0
- package/dist/src/{chunk-58wzr3mt.js → chunk-5wk1t46v.js} +3 -3
- package/dist/src/{chunk-vy3bwm1d.js → chunk-661c50hh.js} +5 -5
- package/dist/src/chunk-68n6bjjd.js +21 -0
- package/dist/src/{chunk-v6pya0dm.js → chunk-69pmjdf2.js} +3 -3
- package/dist/src/{chunk-e98dqnc9.js → chunk-6hrj3jt6.js} +20 -20
- package/dist/src/{chunk-wbh8spm5.js → chunk-6myr26wx.js} +8 -8
- package/dist/src/chunk-6n96k09n.js +4 -0
- package/dist/src/chunk-6vwrbkre.js +4 -0
- package/dist/src/chunk-6wk0yrab.js +4 -0
- package/dist/src/chunk-6yhm9een.js +4 -0
- package/dist/src/{chunk-mjrps0ac.js → chunk-7k7gjg2t.js} +5 -5
- package/dist/src/chunk-7n5fz68h.js +4 -0
- package/dist/src/chunk-8cvnpnbp.js +4 -0
- package/dist/src/chunk-8kzv7rk7.js +4 -0
- package/dist/src/chunk-8nj68t1v.js +167 -0
- package/dist/src/{chunk-g7tmjbkt.js → chunk-96r3bpg7.js} +3 -3
- package/dist/src/chunk-97x887te.js +4 -0
- package/dist/src/{chunk-8ph29g99.js → chunk-99a6tbvd.js} +1 -1
- package/dist/src/chunk-9p5d2994.js +5 -0
- package/dist/src/{chunk-aabchzxk.js → chunk-9q265er0.js} +4 -4
- package/dist/src/{chunk-jh6vhqzx.js → chunk-9xgnrv5w.js} +3 -3
- package/dist/src/chunk-9xgsmshb.js +5 -0
- package/dist/src/chunk-a02d1wgv.js +4 -0
- package/dist/src/{chunk-ndt1ccxm.js → chunk-a9ps00a1.js} +10 -10
- package/dist/src/{chunk-5d2hft6c.js → chunk-aewdveet.js} +3 -3
- package/dist/src/{chunk-ycaj2sgf.js → chunk-b3tdtq7r.js} +6 -6
- package/dist/src/chunk-bn7jx7a2.js +4 -0
- package/dist/src/{chunk-3y6eykz9.js → chunk-bnyw27ja.js} +2 -2
- package/dist/src/{chunk-rqc9ap3x.js → chunk-bpwsg76p.js} +2 -2
- package/dist/src/chunk-bvranw3g.js +4 -0
- package/dist/src/chunk-c25a84zb.js +4 -0
- package/dist/src/chunk-c27yv1dx.js +5 -0
- package/dist/src/chunk-c3ewxm4x.js +5 -0
- package/dist/src/{chunk-rvvy1bte.js → chunk-cb1ga9rd.js} +5 -5
- package/dist/src/chunk-cn7fwy7k.js +4 -0
- package/dist/src/chunk-cnvy4a64.js +4 -0
- package/dist/src/{chunk-7rz9898k.js → chunk-cqhw4yr6.js} +3 -3
- package/dist/src/{chunk-g04bwyj3.js → chunk-ctmfshjc.js} +2 -2
- package/dist/src/chunk-ctwmhz13.js +4 -0
- package/dist/src/{chunk-waqwcjyn.js → chunk-d3jx9bz5.js} +2 -2
- package/dist/src/{chunk-ayp07wbb.js → chunk-d6rb08ga.js} +1 -1
- package/dist/src/chunk-ddqhj4eg.js +5 -0
- package/dist/src/{chunk-r7bpkgff.js → chunk-ddrhs1c3.js} +2 -2
- package/dist/src/chunk-dnjnh9p6.js +4 -0
- package/dist/src/{chunk-wyrkw6hw.js → chunk-dw5rwgya.js} +3 -3
- package/dist/src/{chunk-3xkpk44w.js → chunk-e0870khr.js} +3 -3
- package/dist/src/chunk-ea3k10kj.js +4 -0
- package/dist/src/chunk-emv82m1w.js +7 -0
- package/dist/src/chunk-f3m6pdnx.js +4 -0
- package/dist/src/chunk-f84z32cb.js +4 -0
- package/dist/src/chunk-fpczgf0z.js +4 -0
- package/dist/src/{chunk-2tqzq5qh.js → chunk-g2js4c2v.js} +18 -18
- package/dist/src/chunk-g3af2qbk.js +5 -0
- package/dist/src/{chunk-3qwrzxh0.js → chunk-gadtna7s.js} +6 -6
- package/dist/src/{chunk-ybbtagbt.js → chunk-gcyx407v.js} +3 -3
- package/dist/src/{chunk-bfw6125s.js → chunk-gfpntwc1.js} +3 -3
- package/dist/src/chunk-gmnm5e3e.js +4 -0
- package/dist/src/chunk-gp6vb5gf.js +4 -0
- package/dist/src/chunk-gppgy7pa.js +4 -0
- package/dist/src/chunk-hegfz0ae.js +5 -0
- package/dist/src/chunk-hpzxdp1k.js +17 -0
- package/dist/src/{chunk-qcxzr2my.js → chunk-j69g8b50.js} +3 -3
- package/dist/src/chunk-jvstjnqm.js +19 -0
- package/dist/src/chunk-jzqrv78s.js +4 -0
- package/dist/src/chunk-k2948b8d.js +4 -0
- package/dist/src/chunk-k4ftd40d.js +4 -0
- package/dist/src/{chunk-bxmsax22.js → chunk-kd9vfaxh.js} +3 -3
- package/dist/src/{chunk-s3jc6cwp.js → chunk-kdczmgwk.js} +3 -3
- package/dist/src/{chunk-t6bfvfkg.js → chunk-ke3wn14v.js} +1 -1
- package/dist/src/chunk-kh5n7m6w.js +4 -0
- package/dist/src/{chunk-6wt9rgjf.js → chunk-khejfph4.js} +3 -3
- package/dist/src/chunk-kny2xemh.js +4 -0
- package/dist/src/chunk-knyzw9md.js +4 -0
- package/dist/src/chunk-mbzpt2hp.js +4 -0
- package/dist/src/chunk-mm8rcxad.js +4 -0
- package/dist/src/chunk-nc4516tx.js +4 -0
- package/dist/src/{chunk-6bznss4t.js → chunk-ntfrqrqn.js} +5 -5
- package/dist/src/chunk-nz5h2j52.js +4 -0
- package/dist/src/chunk-p22s97qy.js +4 -0
- package/dist/src/chunk-p9kt1sgr.js +6 -0
- package/dist/src/{chunk-yb97j25b.js → chunk-pf282r5g.js} +4 -4
- package/dist/src/chunk-pnd4mrxy.js +4 -0
- package/dist/src/chunk-pqqteyj6.js +4 -0
- package/dist/src/{chunk-6xmss8er.js → chunk-qj1tbnv2.js} +6 -6
- package/dist/src/chunk-qnh9egwr.js +4 -0
- package/dist/src/chunk-qy3khhf8.js +8 -0
- package/dist/src/{chunk-z637nqg8.js → chunk-r0vp315h.js} +6 -6
- package/dist/src/chunk-r4j43b9s.js +237 -0
- package/dist/src/{chunk-1p7xf5kb.js → chunk-r54cxxze.js} +3 -3
- package/dist/src/{chunk-yf7ympyz.js → chunk-r6pvhj33.js} +92 -92
- package/dist/src/chunk-rb7aa5gr.js +54 -0
- package/dist/src/chunk-rdj50kb4.js +4 -0
- package/dist/src/chunk-rnd4vcas.js +4 -0
- package/dist/src/{chunk-w5b2jwk3.js → chunk-s3y3zfcx.js} +8 -8
- package/dist/src/chunk-s4g43k75.js +5 -0
- package/dist/src/chunk-sfqe223f.js +311 -0
- package/dist/src/{chunk-284ptqa4.js → chunk-sqdrxjw5.js} +5 -5
- package/dist/src/{chunk-zgja5f3p.js → chunk-t54k47em.js} +4 -4
- package/dist/src/{chunk-3sy6ahhz.js → chunk-tek4pnvv.js} +10 -10
- package/dist/src/chunk-tn74y7af.js +4 -0
- package/dist/src/{chunk-thbh3jew.js → chunk-tvq0nzam.js} +3 -3
- package/dist/src/{chunk-0jrrsnc9.js → chunk-tx4f0h9c.js} +4 -4
- package/dist/src/chunk-vdqag3fj.js +5 -0
- package/dist/src/chunk-vz5zzs57.js +4 -0
- package/dist/src/chunk-w4s2vfpj.js +4 -0
- package/dist/src/{chunk-4hw3665t.js → chunk-w5yypt53.js} +11 -11
- package/dist/src/{chunk-8037tzzj.js → chunk-w68v64vh.js} +3 -3
- package/dist/src/chunk-whwj0pdk.js +5 -0
- package/dist/src/chunk-wnmqt1dc.js +4 -0
- package/dist/src/{chunk-cyy71ggq.js → chunk-wpe46vsa.js} +3 -3
- package/dist/src/{chunk-w3vs79ex.js → chunk-wxdjeb4k.js} +19 -19
- package/dist/src/chunk-xcqzwf9j.js +247 -0
- package/dist/src/chunk-xezekwwn.js +5 -0
- package/dist/src/chunk-xf19m15s.js +4 -0
- package/dist/src/chunk-xghbxha4.js +4 -0
- package/dist/src/{chunk-00167wan.js → chunk-xn9m3xc2.js} +5 -5
- package/dist/src/{chunk-26k317v5.js → chunk-yqfz4vts.js} +3 -3
- package/dist/src/chunk-z8tvs8nk.js +5 -0
- package/dist/src/chunk-zm2rehqb.js +5 -0
- package/dist/src/chunk-zs6dqm35.js +4 -0
- package/dist/src/daemon/processEntry.js +2 -2
- package/dist/src/index.js +4 -4
- package/dist/src/runtime/bunRuntimeGuard.js +2 -2
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -2
- package/package.json +2 -2
- package/dist/src/chunk-0n6swkwg.js +0 -5
- package/dist/src/chunk-0qsy1qsx.js +0 -57
- package/dist/src/chunk-11m8wj8j.js +0 -237
- package/dist/src/chunk-23p5f095.js +0 -4
- package/dist/src/chunk-28re4xrg.js +0 -4
- package/dist/src/chunk-2f9rkmhx.js +0 -5
- package/dist/src/chunk-2fxdh48t.js +0 -4
- package/dist/src/chunk-2tbdrbt6.js +0 -4
- package/dist/src/chunk-32gvv9b4.js +0 -21
- package/dist/src/chunk-3f3t1x97.js +0 -8
- package/dist/src/chunk-3fspkbc7.js +0 -4
- package/dist/src/chunk-3vg455e6.js +0 -4
- package/dist/src/chunk-49bsqdx3.js +0 -4
- package/dist/src/chunk-5snsn9cf.js +0 -4
- package/dist/src/chunk-5tm9mn47.js +0 -54
- package/dist/src/chunk-5zc77a5t.js +0 -4
- package/dist/src/chunk-64j0majr.js +0 -19
- package/dist/src/chunk-65y8v4td.js +0 -17
- package/dist/src/chunk-6awz7vhq.js +0 -5
- package/dist/src/chunk-6ep7f5ge.js +0 -4
- package/dist/src/chunk-7cs2da62.js +0 -5
- package/dist/src/chunk-7g103b54.js +0 -4
- package/dist/src/chunk-7j5vj4pa.js +0 -4
- package/dist/src/chunk-7tw8x05v.js +0 -4
- package/dist/src/chunk-7zy586cb.js +0 -4
- package/dist/src/chunk-84nanf8s.js +0 -5
- package/dist/src/chunk-8gvwcv2p.js +0 -4
- package/dist/src/chunk-8thrmfat.js +0 -4
- package/dist/src/chunk-8zgzzs7k.js +0 -78
- package/dist/src/chunk-97b1zmaq.js +0 -4
- package/dist/src/chunk-9fth9ayh.js +0 -4
- package/dist/src/chunk-9j6anhjr.js +0 -4
- package/dist/src/chunk-bfjwqk8q.js +0 -4
- package/dist/src/chunk-bnhscm2n.js +0 -4
- package/dist/src/chunk-c1vs4g1n.js +0 -4
- package/dist/src/chunk-ct3e7yng.js +0 -4
- package/dist/src/chunk-ddzkz92z.js +0 -4
- package/dist/src/chunk-drdz8hee.js +0 -5
- package/dist/src/chunk-eersndy7.js +0 -5
- package/dist/src/chunk-eggq53ks.js +0 -4
- package/dist/src/chunk-f2dya7cs.js +0 -4
- package/dist/src/chunk-fbakd6cw.js +0 -4
- package/dist/src/chunk-fgb98zjj.js +0 -5
- package/dist/src/chunk-fmpad823.js +0 -5
- package/dist/src/chunk-g0xr8zw0.js +0 -4
- package/dist/src/chunk-g3rjs80x.js +0 -4
- package/dist/src/chunk-g78rtrfv.js +0 -4
- package/dist/src/chunk-gabgv3y5.js +0 -4
- package/dist/src/chunk-gmr45m8f.js +0 -4
- package/dist/src/chunk-gsyfebqj.js +0 -4
- package/dist/src/chunk-h5rpn9wr.js +0 -247
- package/dist/src/chunk-hb1x7v55.js +0 -4
- package/dist/src/chunk-hrfytkxh.js +0 -168
- package/dist/src/chunk-j4yjzbak.js +0 -4
- package/dist/src/chunk-jd6a5v6p.js +0 -5
- package/dist/src/chunk-kn5spq15.js +0 -4
- package/dist/src/chunk-m94qs0f0.js +0 -4
- package/dist/src/chunk-n03dmn5q.js +0 -5
- package/dist/src/chunk-n72qhwd9.js +0 -4
- package/dist/src/chunk-nr6y0n4y.js +0 -5
- package/dist/src/chunk-pcsen2vs.js +0 -4
- package/dist/src/chunk-ppfr0b8h.js +0 -4
- package/dist/src/chunk-q10bdnat.js +0 -4
- package/dist/src/chunk-q9xmq595.js +0 -4
- package/dist/src/chunk-qyqypn28.js +0 -5
- package/dist/src/chunk-r2epb56s.js +0 -4
- package/dist/src/chunk-r5bxavdx.js +0 -311
- package/dist/src/chunk-r8jf3d92.js +0 -4
- package/dist/src/chunk-rc0dbypm.js +0 -4
- package/dist/src/chunk-rhcty4ms.js +0 -4
- package/dist/src/chunk-rpvckv3p.js +0 -4
- package/dist/src/chunk-ry0mz41y.js +0 -4
- package/dist/src/chunk-sfv61xjb.js +0 -6
- package/dist/src/chunk-t7w8rctc.js +0 -4
- package/dist/src/chunk-v2wd4n3e.js +0 -5
- package/dist/src/chunk-w4zga19f.js +0 -4
- package/dist/src/chunk-w7hkv422.js +0 -5
- package/dist/src/chunk-xa73x2cx.js +0 -5
- package/dist/src/chunk-y2vs6jwg.js +0 -4
- package/dist/src/chunk-yattm52s.js +0 -4
- package/dist/src/chunk-yjawdzk8.js +0 -4
- package/dist/src/chunk-zs1sghs9.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Sm}from"./chunk-e98dqnc9.js";import{f,I}from"./chunk-58wzr3mt.js";import"./chunk-r5bxavdx.js";import{e}from"./chunk-z637nqg8.js";import{XX,Qi,sH,XM,aH,F,Ks,pi,_H,Pr,Hd,zl,QP,SI}from"./chunk-h5rpn9wr.js";import"./chunk-0qsy1qsx.js";import"./chunk-yf7ympyz.js";import{Cn}from"./chunk-5d2hft6c.js";import{n,Me,aP,Ne}from"./chunk-4hw3665t.js";import{fi,cQ,zq}from"./chunk-hrfytkxh.js";import"./chunk-0n6swkwg.js";import{uS,mN,RI,eA}from"./chunk-w5b2jwk3.js";import{p_,el,uh,Qq,Xs,Cr,Zy,ph,D0,rV,qQ,Qy}from"./chunk-64j0majr.js";import"./chunk-2f9rkmhx.js";import"./chunk-00167wan.js";import"./chunk-3xkpk44w.js";import"./chunk-7rz9898k.js";import"./chunk-65y8v4td.js";import{xr,kI}from"./chunk-dgrbdpb7.js";import"./chunk-0jrrsnc9.js";import"./chunk-84nanf8s.js";import"./chunk-jh6vhqzx.js";import"./chunk-3f3t1x97.js";import"./chunk-vy3bwm1d.js";import"./chunk-ycaj2sgf.js";import"./chunk-3qwrzxh0.js";import"./chunk-thbh3jew.js";import{rM,iM,Vb,Wb,KK}from"./chunk-jd6a5v6p.js";import"./chunk-26k317v5.js";import"./chunk-284ptqa4.js";import"./chunk-w7hkv422.js";import"./chunk-qyqypn28.js";import"./chunk-fgb98zjj.js";import"./chunk-rvvy1bte.js";import"./chunk-v6pya0dm.js";import{r,t,u}from"./chunk-rbpdk7m0.js";function N(){if(I(f.ACCEPTANCE_LIVE)!=="1")return;let o=I(f.ACCEPTANCE_DISCOVERY_ORDER),s=I(f.ACCEPTANCE_DISCOVERY_CAPABILITY);return(o==="forward"||o==="reverse")&&s?{order:o,capability:s}:void 0}function D(o,s,i){if(o.outcome!=="ready"||s!==void 0&&s!==o.sessionUuid)return;return{success:!1,error:{code:"broker_session_ended",message:`Broker session ${o.sessionUuid} for request ${o.requestId} ended (${i}). Device tools cannot acquire a generic replacement on this connection; the launcher must start a new broker request.`,requestId:o.requestId,sessionUuid:o.sessionUuid,reason:i,...fi(i),retryable:!1,nextAction:"relaunch_session_request"}}}function h(o,s){let i=RI(o),d=s&&i&&D(s,i.sessionUuid,i.reason??"unknown");return d?{content:[{type:"text",text:JSON.stringify(d)}],isError:!0}:o}function L(o,s){let i=D(o,s.sessionUuid,s.reason);return i?{content:[{type:"text",text:JSON.stringify(i)}],isError:!0}:void 0}function _(o,s){if(o instanceof Hd&&o.handover.code===pi)return;return o instanceof Pr&&s?L(s,o):void 0}function B(o,s){return s!==void 0&&o.getTerminalSessionRelease()?.sessionUuid===s.sessionUuid}function H(o){return o.sessions.length>0?[_H(o)]:[]}function M(o){if(o instanceof Hd)return o.toPayload();return eA({message:`Session ownership lost for ${o.sessionUuid}: ${o.reason}. `+uS,sessionUuid:o.sessionUuid,reason:o.reason,release:o.release})}function k(o){return JSON.stringify(M(o))}function U(o){return{content:[{type:"text",text:k(o)}],isError:!0}}function E(o){let s=M(o);return new Qi(-32603,k(o),s)}function P(o){return JSON.stringify(mN(o))}function J(o){return{content:[{type:"text",text:P(o)}],isError:!0}}function V(o){return{content:[{type:"text",text:JSON.stringify({error:{code:"ambiguous_session_selector",message:o.message,platform:o.platform,candidates:o.candidates,retryable:!1}})}],isError:!0}}function w(o){return new Qi(-32603,P(o),mN(o))}function j(o,s=!1){let i=p_(s),d={content:[{type:"text",text:JSON.stringify(i)}],structuredContent:i,isError:!0};return Wb(d,Vb(o,!1))}function Y(o){if(o instanceof el){let s=p_(o.requestMayHaveDispatched);return new Qi(-32603,JSON.stringify(s),s)}if(o instanceof xr){let s=kI(o);return new Qi(-32603,JSON.stringify(s),s)}return}function z(o){let s=kI(o);return{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function O(o){return{error:{code:o.failure.code,message:o.message,retryable:o.failure.retryable,retryAfterMs:o.failure.retryAfterMs,queueWaitMs:o.failure.queueWaitMs,remainingTimeoutMs:o.failure.remainingTimeoutMs}}}function W(o,s=!0){let i=O(o),d={content:[{type:"text",text:JSON.stringify(i)}],structuredContent:i,isError:!0};return Wb(d,Vb(s,!1))}function x(o){let s=O(o);return new Qi(-32603,JSON.stringify(s),s)}var C=-32602;function X(o){if(o===null||typeof o!=="object"||!("code"in o)||o.code!==C)return;let s=r(o).replace(`MCP error ${C}: `,"");return new Qi(C,s)}function b(o){let s=r(o),i=o instanceof Error?o.cause:void 0;if(i instanceof Qy)return`${s} (daemon connection closed before the response arrived while handling ${i.toolName})`;if(i instanceof Cr)return`${s} (request timed out after ${i.timeoutMs}ms while handling ${i.toolName})`;if(i instanceof Error&&(i.name==="AbortError"||i.name==="TimeoutError"))return`${s} (request ${i.name==="TimeoutError"?"timed out":"was aborted"})`;return s}function G(o){let s=Qq(o.failure);return{content:[{type:"text",text:JSON.stringify({error:{message:o.message,...s}})}],isError:!0}}async function K(o,s){try{for(let i of H(s))await o.server.sendLoggingMessage({level:"error",logger:"auto-mobile.liveness",data:i})}catch(i){e.warn("[ProxyServer] Failed to forward liveness handover notification",i)}}async function Q(o,s){try{await o.server.sendLoggingMessage({level:"info",logger:"auto-mobile.liveness",data:{code:"session_device_rebound",sessionUuid:s.sessionId,previousDeviceId:s.previousDeviceId,deviceId:s.deviceId,avdName:s.avdName,stableDeviceId:s.stableDeviceId,generation:s.generation}})}catch(i){e.warn("[ProxyServer] Failed to forward session-device rebound",i)}}async function Z(o,s){try{await o.server.notification({method:"notifications/resources/updated",params:{uri:s}})}catch(i){e.warn("[ProxyServer] Failed to forward resource update notification",i)}}function ee(o,s,i){if(o instanceof Pr)return e.warn(`[ProxyServer] Session ownership lost for ${o.sessionUuid}: ${o.reason}`),U(o);if(o instanceof zl)return e.warn(`[ProxyServer] No active device session (released: ${o.reason})`),J(o);if(o instanceof QP)return e.warn(`[ProxyServer] Ambiguous session selector: ${o.message}`),V(o);if(o instanceof el)return j(i,o.requestMayHaveDispatched);if(o instanceof xr)return z(o);if(o instanceof Xs)return W(o,i);if(o instanceof uh)return e.warn(`[ProxyServer] Device-control transport failure for ${o.failure.toolName} during ${o.failure.phase}`),G(o);return Ks(o,{toolName:s,source:"ProxyServer"})}function re(o){let s={...o?{[cQ]:{...o}}:{}};return Object.keys(s).length>0?{experimental:s}:{}}function oe(o){return{resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},logging:{},prompts:{},...re(o.session)}}function te(o,s){let i={success:!1,error:{code:"session_unavailable",message:`Tool ${s} is unavailable because session request ${o.requestId} is ${o.outcome}. Use the exact bound sessionUuid only after initialize reports ready.`,requestId:o.requestId,outcome:o.outcome,cleanupPending:o.cleanupPending,failure:o.failure??null}};return{isError:!0,content:[{type:"text",text:JSON.stringify(i)}]}}function se(o,s){o.server.setRequestHandler("tools/list",async()=>({tools:[]})),o.server.setRequestHandler("tools/call",async(i)=>te(s,i.params.name))}function ne(o,s){if(s&&s.outcome!=="ready")se(o,s)}async function ie(o,s,i,d){let{name:a,args:c,progressToken:p,extra:y}=s,g=Zy({envelope:y.envelope,meta:y._meta});if(!g){let m=await o.callTool(a,c,p,{onProgress:i,signal:y.signal});return h(m,d.session)}let l=await o.callTool(a,c,p,{onProgress:i,signal:y.signal,declaresTasks:g});return ph(l)?l:h(l,d.session)}var T=aP({taskId:n()}),ae=aP({taskId:n(),inputResponses:Ne(n(),Me()).optional()});function ce(o){let s=o!==null&&typeof o==="object"?Reflect.get(o,"jsonRpcError"):void 0;return rV(s)?qQ(s):o}function ue(o,s){let i=o.server;KK(i);let d=async(a,c,p)=>{if(!Zy({envelope:p.mcpReq.envelope,meta:p.mcpReq._meta}))throw D0();try{return await s.relayTaskMethod(a,c,!0,p.mcpReq.signal)}catch(y){throw p.mcpReq.signal.throwIfAborted(),ce(y)}};i.setRequestHandler("tasks/get",{params:T},async(a,c)=>d("tasks/get",{taskId:a.taskId},c)),i.setRequestHandler("tasks/update",{params:ae},async(a,c)=>{let p=c.mcpReq.inputResponses??a.inputResponses;return d("tasks/update",{taskId:a.taskId,...p!==void 0&&{inputResponses:p}},c)}),i.setRequestHandler("tasks/cancel",{params:T},async(a,c)=>d("tasks/cancel",{taskId:a.taskId},c))}function le(o,s){o.server.setRequestHandler("resources/list",async()=>{try{return{resources:await s.listAdvertisedResources()}}catch(i){if(i instanceof Pr)throw E(i);if(i instanceof zl)throw w(i);if(i instanceof Xs)throw x(i);throw e.error(`[ProxyServer] Failed to list resources: ${i}`),new t(`Failed to list resources from daemon: ${b(i)}`,{cause:i})}}),o.server.setRequestHandler("resources/templates/list",async()=>{try{return{resourceTemplates:await s.listAdvertisedResourceTemplates()}}catch(i){if(i instanceof Pr)throw E(i);if(i instanceof zl)throw w(i);if(i instanceof Xs)throw x(i);throw e.error(`[ProxyServer] Failed to list resource templates: ${i}`),new t(`Failed to list resource templates from daemon: ${b(i)}`,{cause:i})}}),o.server.setRequestHandler("resources/read",async(i,d)=>{let a=i.params.uri;if(!a)throw new t("Resource URI is missing in the request");if(sH(a)){let c=await aH(a);if(c)return c;throw new Sm(a)}e.info(`[ProxyServer] Forwarding resource read: ${a}`);try{let c=XX(o.server.getClientCapabilities());return await s.readResource(a,{signal:d.mcpReq.signal,...c!==void 0&&{_meta:c}})}catch(c){if(d.mcpReq.signal.throwIfAborted(),c instanceof Pr)throw E(c);if(c instanceof zl)throw w(c);if(c instanceof Xs)throw x(c);let p=Y(c);if(p)throw e.warn(`[ProxyServer] Resource read refused, retryable: ${a} - ${c}`),p;let y=X(c);if(y)throw e.warn(`[ProxyServer] Resource read rejected as invalid params: ${a}`),y;throw e.error(`[ProxyServer] Resource read failed: ${a} - ${c}`),new t(`Failed to read resource from daemon: ${b(c)}`,{cause:c})}})}function de(o){let s=N();return new SI({...o,...s?{acceptanceDiscovery:s}:{}})}function fe(o,s,i){return async({name:d,args:a,progressToken:c,progress:p,extra:y})=>{let g=i.get(d)??!1;e.info(`[ProxyServer] Forwarding tool call: ${d}`);let l=p?(m,v,R)=>{p(m,v,R)}:void 0;try{return await ie(o,{name:d,args:a,progressToken:c,extra:y},l,s)}catch(m){y.signal.throwIfAborted();let v=_(m,s.session);if(v)return v;return ee(m,d,g)}}}function Ye(o={}){let s=o.proxy??de(o.proxyConfig),i=new Map,d=0,a=rM({name:"AutoMobile",version:Cn()},oe(o));XM(a),s.onListChanged((l)=>{try{if(l==="tools")d+=1,i.clear(),a.sendToolListChanged();else a.sendResourceListChanged()}catch(m){e.warn(`[ProxyServer] Failed to forward ${l} list_changed notification: ${m}`)}});let c=s.onResourceUpdated((l)=>{Z(a,l)}),p=s.onLivenessHandover((l)=>{K(a,l)}),y=s.onSessionDeviceRebound((l)=>{Q(a,l)}),g=a.server.onclose;return a.server.onclose=()=>{c(),p(),y(),g?.(),s.close().catch((l)=>{e.warn("[ProxyServer] Failed to close daemon proxy",l)})},a.server.setRequestHandler("resources/subscribe",async(l)=>{try{return await s.subscribeResource(l.params.uri),{}}catch(m){throw u(m,"Failed to subscribe to daemon resource")}}),a.server.setRequestHandler("resources/unsubscribe",async(l)=>{try{return await s.unsubscribeResource(l.params.uri),{}}catch(m){throw u(m,"Failed to unsubscribe from daemon resource")}}),a.server.setRequestHandler("ping",async()=>({})),a.server.setRequestHandler("prompts/list",async()=>({prompts:[]})),a.server.setRequestHandler("tools/list",async()=>{try{if(B(s,o.session))return{tools:[]};let l=d,m=await s.listAdvertisedTools(),v=s.isConnected()?m:(()=>{let R=F.getAllTools({includeUnavailable:!0}),q=zq(process.env,new Set(F.getConfigurableToolNames()),o.proxyConfig?.daemonOptions?.enabledTools,o.proxyConfig?.daemonOptions?.disabledTools),A=new Map(R.map((S)=>[S.name,S.defaultEnabled]));return m.filter((S)=>q.get(S.name)??A.get(S.name)??!0)})();if(l===d){i.clear();for(let R of v)i.set(R.name,R.outputSchema!==void 0)}return{tools:v}}catch(l){if(l instanceof Pr)throw E(l);if(l instanceof zl)throw w(l);if(l instanceof Xs)throw x(l);throw e.error(`[ProxyServer] Failed to list tools: ${l}`),new t(`Failed to list tools from daemon: ${b(l)}`,{cause:l})}}),iM(a,{progressFailureMessage:"[ProxyServer] Failed to relay progress notification",execute:fe(s,o,i)},{ambiguousDeviceElicitation:o.ambiguousDeviceElicitation??{}}),le(a,s),ue(a,s),ne(a,o.session),{server:a,proxy:s}}export{de as createDaemonMcpProxy,Ye as createProxyMcpServer};
|
|
3
|
-
|
|
4
|
-
//# debugId=4BE6948B98D2173A64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{bt,oo,me,U,J,Ye,ni,le,o,P,dt,Rl,BB,xg,N,Mt,$t,pt,co,nt,K,Gi,Vt,ve,AR,md,Ri,ub,TR,Al,fr,BR,Ee,df,Zt,ja,_l,aO,B$,qs,qr,ir,lO,f9,Mu,Jk,Xk,uO,Wie,Zk,mO,eP,xt,ba,bd,lr,V$,W$,x,E,Ws}from"./chunk-r5bxavdx.js";import{Fr,i,Q,ht,xd,te,qt,e}from"./chunk-z637nqg8.js";import{sr,zi,vn,Cm,Dm,bn,Ao,OW,Tv,zC,UL,OT}from"./chunk-0qsy1qsx.js";import{E5,I5,Yc,cu,qee,fT,_5,gC,KF,Am,Tm,rp,du}from"./chunk-vy3bwm1d.js";import{vc,wv,lW,OC,Oe,Kt,At}from"./chunk-3xkpk44w.js";import{cs,yL,xC,vL,pte,d3,l3,iW,fte}from"./chunk-qyqypn28.js";import{ds,Ca,vr,Wi}from"./chunk-fgb98zjj.js";import{Vo,wc,Ma,rg,yi,ca,ng,Kte,Wo}from"./chunk-rvvy1bte.js";import{r,t,St}from"./chunk-rbpdk7m0.js";function he(n,s,a){if(!s)return[];let c=[...n.extractRootNodes(s),...n.extractWindowRootNodes(s,"topmost-first")],l=[];for(let u of c)n.traverseNode(u,(d)=>{if(!a(n.extractNodeProperties(d)))return;let p=n.parseNodeBounds(d);if(p)l.push(p)});return l}var yt=(n)=>n.scrollable==="true"||n.scrollable===!0;class dC{parser;constructor(n=new K){this.parser=n}findScrollableElements(n){return he(this.parser,n,yt)}}class R5{parser;constructor(n=new K){this.parser=n}findClickableElements(n){return he(this.parser,n,Rl)}}var lC=Object.freeze({partialMatch:!0,caseSensitive:!1}),Nee=Object.freeze({partialMatch:!1}),pv=Object.freeze({intentAction:"inspect"}),Fee=Object.freeze({intentAction:"focus-input",allowHintFallback:!0}),Lee=Object.freeze({intentAction:"focus-input"}),Bee=Object.freeze({intentAction:"inspect",selectionIntent:"toggle"}),$ee=Object.freeze({intentAction:"inspect",selectionIntent:"focus-input"}),Ce=Object.freeze({intentAction:"drag"});function uT(n){return{partialMatch:n,caseSensitive:!1}}var j=(n)=>bn(n)??"",uC=async(n,s)=>{let{observe:a,timer:c,maxWaitMs:l,pollIntervalMs:u,logPrefix:d,signal:p}=s;if(!n.viewHierarchy)return n;let m=c.now(),h=j(n.viewHierarchy),f=n;while(c.now()-m<l){p?.throwIfAborted();let w=await a();if(!w.viewHierarchy)break;let y=j(w.viewHierarchy);if(y===h)return e.info(`${d} Scroll settled after ${c.now()-m}ms idle check`),w;e.info(`${d} Scroll still settling (elapsed=${c.now()-m}ms), retrying in ${u}ms`),h=y,f=w,p?.throwIfAborted(),await c.sleep(u)}return e.info(`${d} Scroll idle check reached ${l}ms limit, proceeding`),f};class fe{device;selector;constructor(n,s){this.device=n;this.selector=s}buildScrollableCandidates(n){let s=[],a=new Set;for(let c of n){let l={elementId:c["resource-id"],text:c.text,contentDesc:c["content-desc"],className:c.class};if(!l.elementId&&!l.text&&!l.contentDesc&&!l.className)continue;let u=`${l.elementId??""}|${l.text??""}|${l.contentDesc??""}|${l.className??""}`;if(a.has(u))continue;a.add(u),s.push(l)}return s}resolveAutoTargetDecision({scrollables:n,candidates:s,observeResult:a,direction:c,includeSystemInsets:l}){if(n.length===0)return e.info("[SwipeOn] Mode: screen swipe (no scrollables found)"),{};let u=a?this.selector().getScreenBounds(a,{platform:te(this.device.platform,"swipeOn"),includeSystemInsets:l}):null,d=this.selector().selectAutoTargetScrollable(n,u,c);if(!d)return e.info(`[SwipeOn] Mode: screen swipe (scrollables found but none matched direction=${c})`),{warning:"Scrollable containers found but none matched the swipe direction; swiping the screen. Set autoTarget: false to force screen swipes.",scrollableCandidates:s};let p=BB(d);if(!p&&this.device.platform==="android")return e.info("[SwipeOn] Mode: element swipe (auto-target element has no usable identifier)"),{element:d,warning:"Auto-targeted scrollable container lacks a usable identifier; swiping within its bounds without container metadata.",scrollableCandidates:s};if(!p)return e.info("[SwipeOn] Mode: screen swipe (auto-target element has no usable identifier)"),{scrollFrame:l?void 0:d.bounds,warning:"Auto-targeted scrollable container lacks a usable identifier; swiping the screen. Provide container.elementId or container.text to target it explicitly.",scrollableCandidates:s};return e.info(`[SwipeOn] Mode: auto-target element swipe (container=${JSON.stringify(p)})`),{container:p,warning:`Auto-targeted scrollable container (${this.selector().describeContainer(p)}). Set autoTarget: false to force full-screen swipes.`,scrollableCandidates:s}}withAutoTargetDecision({result:n,decision:s}){if(!s.warning)return n;return{...n,warning:this.selector().mergeWarnings(n.warning,s.warning),scrollableCandidates:s.scrollableCandidates}}}function B(n,s){return n!==void 0&&(!s||!xd(n["visible-to-user"]))}var vt="[REDACTED]";function Te(n){return xt(n).trim().toLowerCase()}function gt(n,s){let a=Te(s),c=new Map;for(let{id:u}of n)c.set(u,(c.get(u)??0)+1);let l=n.filter((u)=>u.id!==""&&c.get(u.id)===1&&u.enabled&&u.visible&&[u.label,u.value===vt?void 0:u.value].some((d)=>d!==void 0&&Te(d)===a));return l.length===1?l[0]:null}function Ot(n){let s=n.enabled??(()=>N.isIosSdkObservationBridgeEnabled());return{async scroll(a,c,l){if(!s()||a.text===void 0)return null;if(UL(c.viewHierarchy).length!==1)return null;let u=await n.reader.snapshots(l),d=u.length===1?u[0]:void 0,p=d?.snapshot,m=p?gt(p.elements,a.text):null;if(!d||!p||!m)return null;let h={snapshotId:p.snapshotId,elementId:m.id};return fT(n.client(),{webViewId:d.webViewId,...h},{scrollIntoView:h},{verb:"scroll into view",signal:l})}}}function Et(n){return Ot({reader:OT(n),client:()=>x.getExistingInstance(n.deviceId)})}function ke(n,s){return n.platform==="ios"?s??Et(n):void 0}import{AsyncLocalStorage as Dt}from"async_hooks";var Pe=new Dt;function Z(n){return Pe.getStore()?n():Pe.run(!0,()=>Cm(n))}function ee(n){let s=oo()?.getDeadlineMs?.();return Math.max(0,Math.min(zi,s===void 0?zi:s-n.now()))}async function k(n,s,a,c){if(o(c),!n.viewHierarchy||n.viewHierarchy.hierarchy.error||Dm(n.viewHierarchy))return n;let l=ee(a);if(l>0)try{let u=await s(l);return o(c),xg(u)?{...u,viewHierarchy:void 0}:u}catch(u){if(o(c),u instanceof Ee||u instanceof Error&&u.name==="AbortError")throw u;e.warn(`[SwipeOn] Fresh hierarchy unavailable: ${r(u)}`,u)}return{...n,viewHierarchy:void 0}}var pC=600,qF=3000,mC=300,VF=2000,lw=100,pT=3000,Rt=100,It=ja,Ct=0.5;function Me(n,s,a){let c=n+s+a;return Math.max(Gi,c+It+c*Ct)}function re(n){return{success:!1,error:`Drag outcome is indeterminate: the request was dispatched but no result was confirmed (${n}). The gesture may have run. Do not retry automatically. Verify state first with observe.`}}function Fe(n){if(n===void 0||n.trim()!==n)return!0;return!(["Gesture display routing requires Android 11 (API 30)","Stale frame context for input/drag; observe a fresh frame before retrying","Stale frame context; observe a fresh frame before retrying","Failed to dispatch gesture"].includes(n)||/^displayId must be non-negative: -[1-9]\d*$/.test(n)||/^Non-finite gesture coordinate: (x1|y1|x2|y2)=(NaN|-?Infinity)\. Coordinates must be finite \(not NaN or Infinity\)\.$/.test(n))}var Tt=5000,kt=15000;class P5 extends Oe{lastRenderedObservation;selector;hierarchyCapture;geometry;accessibilityService;visionConfig;screenshotCapturer;visionAnalyzer;constructor(n,s=null,a=i,c={}){super(n,{adb:s,timer:a,displayFence:c});this.lastRenderedObservation=c.lastRenderedObservation,this.selector=c.selector??new vr(void 0,void 0,{platform:te(n.platform,"dragAndDrop"),iosMultiPanel:n.platform==="ios"&&(n.displays?.panels.length??0)>1}),this.hierarchyCapture=c.hierarchyCapture??vn(n,{timer:a,adbFactory:this.adbFactory}),this.geometry=new ir,this.accessibilityService=Ws(n,this.adbFactory),this.visionConfig=c.visionConfig??Am,this.screenshotCapturer=c.screenshotCapturer??new rp(n,this.adbFactory),this.visionAnalyzer=c.visionAnalyzer}async executeOnAndroidDisplay(n,s,a){let c=s.observation.viewHierarchy;if(!c)throw new t("Selected display has no view hierarchy");let{sourcePoint:l,targetPoint:u}=this.resolveTargetPoints(c,{...n,observation:s.observation}),d=this.getDragDurationMs(n),p=await Ma(this.accessibilityService,s.displayId);if(s.assertCurrent(),o(a),p){let m=this.getPressDurationMs(n),h=this.getHoldDurationMs(n),f=!1,w;try{w=await P(Promise.resolve().then(()=>(o(a),this.accessibilityService.requestDrag({x1:l.x,y1:l.y,x2:u.x,y2:u.y,pressDurationMs:m,dragDurationMs:d,holdDurationMs:h,timeoutMs:Me(m,d,h),signal:a,displayId:s.displayId===0?void 0:s.displayId,beforeSend:s.assertCurrent,onDispatch:()=>{f=!0}}))),a),o(a)}catch(y){if(o(a),!f)throw y;throw e.warn(`Drag outcome indeterminate: ${r(y)}`,y),new t(re(r(y)).error)}if(!w.success)throw new t(f&&Fe(w.error)?re(w.error??"unknown error").error:w.error??"Android drag failed")}else{if(n.pressDurationMs!==void 0||n.holdDurationMs!==void 0)throw new t(`pressDurationMs and holdDurationMs require the CtrlProxy gesture route on display ${s.displayId} (capability gesture_display_id_v1); adb draganddrop cannot express press or hold durations`);await wc(this.adb,`draganddrop ${l.x} ${l.y} ${u.x} ${u.y} ${Vo(d)}`,s.displayId,{signal:a,assertCurrent:s.assertCurrent})}return{success:!0,duration:d,distance:Math.hypot(u.x-l.x,u.y-l.y)}}async executeExplicitDisplay(n,s){if(n.display!==void 0)try{let a=await Wi(this.device,n.display,this.observeScreen,{adb:this.adb,lastRenderedObservation:this.lastRenderedObservation,signal:s,transitions:this.displayTransitionReader});if(this.device.platform==="android")return await this.observedInteraction(()=>this.executeOnAndroidDisplay(n,a,s),{...Kt.rawCoordinateGesture,display:a.followUpDisplay,previousObservation:a.observation,signal:s})}catch(a){if(o(s),a instanceof Error&&a.name==="AbortError")throw a;return e.warn(`dragAndDrop display routing failed: ${r(a)}`,a),Zt(this.failureResult(a,r(a)),a)}return}async execute(n,s,a){let{progress:c,signal:l}=Wo(s,a),u=this.device.platform==="ios"?me(l):l,d=await this.executeExplicitDisplay(n,u);if(d)return d;let p=J();if(p.serial("dragAndDrop"),this.device.platform!=="android"&&this.device.platform!=="ios")return p.end(),{success:!1,duration:0,distance:0,error:`dragAndDrop is not supported on ${this.device.platform}`};if(this.device.platform==="android"){let h=le.getInstance(this.device,{create:()=>this.adb});if(!await p.track("a11yAvailable",()=>h.isAvailable()))return p.end(),{success:!1,duration:0,distance:0,error:"dragAndDrop requires the Android accessibility service to be installed and enabled."}}let m=this.validateOptions(n);if(m)return p.end(),{success:!1,duration:0,distance:0,error:m};return this.executeObservedDrag(n,p,c,u)}async executeObservedDrag(n,s,a,c){try{let l=this.getPressDurationMs(n),u=this.getDragDurationMs(n),d=this.getHoldDurationMs(n),p,m=await this.observedInteraction(async(h,f)=>{o(c);let w=await this.resolveViewHierarchy(c);if(!w)return{success:!1,error:"Unable to get view hierarchy, cannot drag and drop"};let{sourcePoint:y,targetPoint:b}=this.resolveTargetPoints(w,{...n,observation:h});f?.assertCurrent();let S=await this.dispatchDrag({startX:y.x,startY:y.y,endX:b.x,endY:b.y,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,signal:c});if(this.device.platform==="ios"&&S.success)p=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();await this.timer.sleep(Rt);let v=Math.hypot(b.x-y.x,b.y-y.y);return{success:S.success,duration:u,distance:v,a11yTotalTimeMs:S.a11yTotalTimeMs,a11yGestureTimeMs:S.a11yGestureTimeMs,error:S.error}},{...Kt.selectorResolvedGesture,display:n.display,progress:a,perf:s,signal:c,observationTimestampProvider:()=>p,predictionContext:{toolName:"dragAndDrop",toolArgs:{source:n.source,target:n.target,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,platform:this.device.platform}}});return s.end(),o(c),{...m,duration:m.duration??this.getDragDurationMs(n),distance:m.distance??0}}catch(l){if(s.end(),e.warn(`Drag and drop failed: ${r(l)}`,l),o(c),l instanceof Ee||l instanceof fr)return Zt({success:!1,duration:0,distance:0},l);let u=r(l),d=`Failed to perform drag and drop: ${u}`;if(this.visionConfig.enabled){let p=this.isSourceResolutionError(u),m=p?n.source:n.target;if(m){let h={text:m.text,resourceId:m.elementId,description:p?"Source element for drag":"Target element for drop"},w=(await this.observeScreen.getMostRecentCachedObserveResult())?.viewHierarchy??null;d=await Tm(this.screenshotCapturer,w,h,{visionConfig:this.visionConfig,baseError:d,signal:c,visionAnalyzer:this.visionAnalyzer})}}return o(c),this.failureResult(l,d)}}failureResult(n,s){return{success:!1,duration:0,distance:0,error:s,...n instanceof t&&n.containerFailure?{containerFailure:n.containerFailure}:{}}}isSourceResolutionError(n){return n.startsWith("dragAndDrop source")||!n.startsWith("dragAndDrop target")&&n.toLowerCase().includes("source")}validateOptions(n){if(!n?.source||!n?.target)return"dragAndDrop requires source and target";if([n.source.text,n.source.elementId].filter(Boolean).length!==1)return"dragAndDrop source must specify exactly one of text or elementId";if([n.target.text,n.target.elementId].filter(Boolean).length!==1)return"dragAndDrop target must specify exactly one of text or elementId";if(!this.isDurationInRange(n.pressDurationMs,pC,qF))return`dragAndDrop pressDurationMs must be between ${pC}ms and ${qF}ms`;if(!this.isDurationInRange(n.dragDurationMs,mC,VF))return`dragAndDrop dragDurationMs must be between ${mC}ms and ${VF}ms`;if(!this.isDurationInRange(n.holdDurationMs,lw,pT))return`dragAndDrop holdDurationMs must be between ${lw}ms and ${pT}ms`;return null}resolveTargetPoints(n,s){let a={observationScreenSize:s.observation.screenSize,display:s.observation.viewHierarchy},c=Ri(n,s.layer),l=this.resolveTarget(c,{...s.source,screenSizeOptions:a},"source"),u=this.resolveTarget(c,{...s.target,screenSizeOptions:a},"target"),d=this.prototypeSafePoint(n,s.layer,l,"source"),p=this.prototypeSafePoint(n,s.layer,u,"target");return ub(n,s.layer,d,"drag from"),ub(n,s.layer,p,"drop"),{sourcePoint:d,targetPoint:p}}prototypeSafePoint(n,s,a,c){let l=this.geometry.getElementCenter(a);if(s!==void 0||this.device.platform==="ios")return l;let u=B$(n,a,a.bounds,l);if(!u)throw new t(`dragAndDrop ${c} is covered by an AutoMobile prototype window; hide or move the prototype, then retry.`);return u}get testHooks(){return{resolveTarget:this.resolveTarget.bind(this)}}resolveTarget(n,s,a){if([s.elementId,s.text].filter(Boolean).length!==1)throw new t(`dragAndDrop ${a} must specify exactly one of text or elementId`);let l;try{if(l=this.selectTargetElement(n,s),!l&&s.container)throw new t("Target not found within container")}catch(u){let d=ds(s,"any-container")?`dragAndDrop ${a}: `:"";throw new t(`${d}${r(u)}`,{cause:u})}if(!l){let u=s.elementId?"elementId":"text";throw new t(`dragAndDrop ${a} not found with ${u} '${s.elementId??s.text}'`)}return l}selectTargetElement(n,s){let a={...Ce,screenSizeOptions:s.screenSizeOptions,container:s.container,strategy:s.selectionStrategy};if(s.container&&!ds(s)&&this.selector.resolveContainer&&!this.selector.resolveContainer(n,s.container,s.selectionStrategy))throw new t(`Container level 1 not found: ${s.container.elementId??s.container.text}`,{containerFailure:{level:1,reason:"not-found",selector:s.container}});if(s.elementId)return this.selector.select(n,{elementId:s.elementId},a).element;let c=this.selector.select(n,{text:s.text??""},a);return c.matchedElement??c.element}async resolveViewHierarchy(n){let s=await this.hierarchyCapture.capture({freshness:"fresh",searchRaw:this.device.platform==="android"&&N.isRawElementSearchEnabled(),signal:n,timeoutMs:this.device.platform==="ios"?kt:Tt});if(this.device.platform==="ios")o(n);return s.hierarchy}getPressDurationMs(n){if(typeof n.pressDurationMs==="number")return n.pressDurationMs;return pC}getDragDurationMs(n){if(typeof n.dragDurationMs==="number")return n.dragDurationMs;return mC}getHoldDurationMs(n){if(typeof n.holdDurationMs==="number")return n.holdDurationMs;return lw}isDurationInRange(n,s,a){if(typeof n!=="number")return!0;return n>=s&&n<=a}dispatchDrag=(n)=>this.executeDrag(n);setDragDispatchForTesting(n){this.dispatchDrag=n}async executeDrag({startX:n,startY:s,endX:a,endY:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,signal:p}){o(p);let m=Me(l,u,d),h=!1,f=()=>{h=!0},w;try{let y=Promise.resolve().then(()=>(o(p),this.device.platform==="ios"?x.getInstance(this.device).requestDrag({x1:n,y1:s,x2:a,y2:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,timeoutMs:m,signal:p,onDispatch:f}):this.accessibilityService.requestDrag({x1:n,y1:s,x2:a,y2:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,timeoutMs:m,signal:p,onDispatch:f})));if(w=await P(y,p),o(p),!w.success&&h&&(this.device.platform==="ios"||Fe(w.error)))return re(w.error??"unknown error")}catch(y){if(o(p),!h)throw y;return e.warn(`Drag outcome indeterminate: ${r(y)}`,y),re(r(y))}if(w.success)return{success:!0,a11yTotalTimeMs:w.totalTimeMs,a11yGestureTimeMs:w.gestureTimeMs};return{success:!1,error:w.error??"Drag failed via CtrlProxy"}}}var ie=lw,_e=3,Ne=4,Pt=new ve;function ne(n,s){let a=n.endX-n.startX,c=n.endY-n.startY,u=Math.abs(a)>Math.abs(c)?s.right-s.left:s.bottom-s.top,d=Math.hypot(a,c),p=d>0?Math.min(1,Math.floor(u*0.75)/d):1;return{...n,endX:Math.round(n.startX+a*p),endY:Math.round(n.startY+c*p)}}function fC(n){return{up:"down",down:"up",left:"right",right:"left"}[n]}function oe(n,s){if(!n.viewHierarchy)return new Map;let a=Pt.project(n.viewHierarchy),c=a.find((d)=>d.element&&d.element["resource-id"]===s["resource-id"]&&Mt(d.element.bounds,s.bounds)),l=new Set,u=new Map;for(let d of a){if(d===c){l.add(d.index);continue}if(!c||d.parentIndex===void 0||!l.has(d.parentIndex))continue;l.add(d.index);let p=Ft(d,s.bounds);if(!p)continue;u.set(p,(u.get(p)??0)+1)}return u}function Ft(n,s){if(!n.bounds||n.categories.scrollable||!$t(n.bounds,s))return;if([n.properties.visible,n.properties["visible-to-user"]].some((u)=>u===!1||u==="false"))return;let{text:a,"content-desc":c,"ios-accessibility-label":l}=n.textSources;if(!a&&!c&&!l&&!n.nativeId)return;return JSON.stringify([n.nativeId,a,c,l])}function Be(n,s){let a=(c,l)=>[...c].filter(([u,d])=>d===1&&(l.get(u)??0)<=1).length;return a(n,s)>=Ne&&a(s,n)>=Ne}async function Ve(n){let s=n.observation,a=await n.keys(s);if(!Be(n.previousKeys,a))return s;for(let c=0;;c++){if(o(n.signal),c>0&&await n.hasTarget?.(s))return s;let l=c===0?a:await n.keys(s);if([...l.keys()].some((u)=>n.previousKeys.has(u)))return s;if(!Be(n.previousKeys,l))return e.debug("[SwipeOn] Recovery overlap evidence is sparse; continuing forward"),s;if(c>=_e||n.timer.now()>=n.deadline)return e.debug(`[SwipeOn] Overlap not restored after ${c} back-scrolls; continuing forward`),s;e.debug(`[SwipeOn] Zero visible child overlap; back-scroll ${c+1}/${_e}`),s=await n.backScroll(s)}}function _t(n,s){let a=s?.deviceInfo??n.requestDeviceInfo();if(s)s.deviceInfo=a;return a}function Nt(n,s){return n instanceof fr||n instanceof Ee&&!s}async function se(n){let{client:s,x1:a,y1:c,x2:l,y2:u,duration:d,signal:p,displayId:m,beforeSend:h}=n,f=()=>(o(p),h?.(),n.onFallback?.(),n.fallback()),w=(b)=>{n.onIndeterminate?.(b);let S=new fr(b);return Zt({success:!1,outcomeIndeterminate:!0,x1:a,y1:c,x2:l,y2:u,duration:d,error:S.message},S)},y=!1;try{o(p);let b=await _t(s,n.searchDragState);if(o(p),h?.(),!b.success||b.sdkInt===void 0||b.sdkInt<26)return f();let S=await s.requestDrag({x1:a,y1:c,x2:l,y2:u,pressDurationMs:0,dragDurationMs:d,holdDurationMs:ie,timeoutMs:5000,signal:p,displayId:m,beforeSend:h,onDispatch:()=>{y=!0,n.onDispatched?.()}});if(o(p),!S.success){if(!y)return f();return e.warn(`[SwipeOn] Search drag outcome indeterminate: ${S.error}`),w(S.error??"unknown error")}return{...S,x1:a,y1:c,x2:l,y2:u,duration:d}}catch(b){if(Nt(b,y))throw b;if(o(p),y)return e.warn(`[SwipeOn] Search drag outcome indeterminate: ${r(b)}`,b),w(b);return e.debug(`[SwipeOn] Precise search drag unavailable: ${r(b)}`,b),f()}}function Se(n,s){if(!n)return s;return{...n,container:Se(n.container,s)}}function Ge(n){if(!C(n.container)&&!L(n.lookFor))return"";let s=[];for(let a=Se(n.lookFor?.container,n.container);a;a=a.container)s.unshift(JSON.stringify(a.elementId??a.text));return s.length?` within container scope ${s.join(" > ")}`:""}function Bt(n){if(n.selectionStrategy==="unique")return!0;for(let s=n.container;s;s=s.container)if(s.selectionStrategy==="unique")return!0;return!1}function Gt(n,s){let a=s?n.find((l)=>l.element===s):void 0;if(!a)return{nodes:n,container:void 0};let c="swipe-resolved-scope";while(n.some((l)=>l.nativeId===c||l.nodeKey===c))c+="_";return{nodes:n.map((l)=>l===a?{...l,nodeKey:c}:l),container:{elementId:c}}}function C(n){return ds(n,"swipe-container-options")}function L(n){return ds(n,"swipe-look-for-options")}function $e({lookFor:n,container:s,containerElement:a,resolver:c,nodes:l,id:u}){if(!n.text&&!n.elementId)return null;let d=Gt(l,s&&!Bt(n)?a:void 0),p={...n,container:Se(n.container,d.container??s)},m=c.resolve({id:u,nodes:d.nodes},p,{action:"inspect"});if(bd(m.error)||m.error?.startsWith("Target not found"))return null;if(m.error)throw new t(m.error);return ba(m,p)?.element??null}class V extends Error{swipesDispatched;constructor(n,s){super(`${Ye} after ${n} swipe(s) were dispatched; the screen has scrolled. Observe before retrying.`,s);this.swipesDispatched=n;this.name="SwipeSearchCancelledError"}}var Ht=(n)=>n instanceof Error&&(n.message===Ye||n.name==="AbortError");function He(n,s,a){if(!s?.aborted||a.dispatched===0||bt(n)||!Ht(n))return n;return new V(a.dispatched,{cause:n})}var TV=Gi,hC=Gi-ja,WF=pT,zF=hC/1,kV=0,EV=0,uw=1,pw=hC;function W(n){if(n.durationMs!==void 0)return n.durationMs;if(n.duration!==void 0)return n.duration;return n.geometry.getSwipeDurationFromSpeed(n.speed)}function T(n){return n.boomerang?{apexPauseMs:n.apexPause??100,returnSpeed:n.returnSpeed??1}:void 0}function Le(n,s){return Math.max(1,Math.round(n/s))}function We(n,s){let a=Le(n,s);if(!Number.isFinite(n)||n<0||!Number.isFinite(s)||s<=EV||s>zF||!Number.isFinite(a)||a>hC)return`returnSpeed must be finite, > 0 and <= ${zF}, and produce a finite return duration <= ${hC}ms; increase returnSpeed or shorten the forward duration`;return null}function M(n){let s=We(n.forwardDuration,n.returnSpeed);if(s)throw new t(s);return Le(n.forwardDuration,n.returnSpeed)}function Lt(n,s){if(!Number.isFinite(n.apexPauseMs)||n.apexPauseMs<kV||n.apexPauseMs>WF)return`apexPause must be finite and >= 0 and <= ${WF}ms; shorten the apex pause`;let a=We(s,n.returnSpeed);if(a)return a;let c=M({forwardDuration:s,returnSpeed:n.returnSpeed});if(s+n.apexPauseMs+c>TV)return`boomerang duration must be <= ${TV}ms; shorten duration/apexPause or increase returnSpeed`;return null}function jF(n){let{durationMs:s}=n;if(s===void 0)return null;if(n.speed!==void 0)return"durationMs cannot be combined with speed; give one or the other";if(n.lookFor)return"durationMs cannot be used with lookFor; search swipes choose their own pace";if(!Number.isInteger(s)||s<uw||s>pw)return`durationMs must be an integer from ${uw} to ${pw} ms`;return null}function $h(n,s=W({...n,geometry:new ir})){let a=jF(n);if(a)return a;if(n.boomerang&&n.lookFor)return"boomerang cannot be used with lookFor";if(!n.boomerang&&(n.apexPause!==void 0||n.returnSpeed!==void 0))return"apexPause/returnSpeed require boomerang=true";let c=T(n);return c?Lt(c,s):null}var A5=4,IV=50,T5=0.5,Ue=0.7,Wt={left:"right",right:"left",top:"down",bottom:"up"};function Ut(n){let{edgeInset:s,at:a}=n;if(s!==void 0&&(!Number.isInteger(s)||s<0||s>IV))return`edgeInset must be an integer from 0 to ${IV}`;if(a!==void 0&&!(Number.isFinite(a)&&a>=0&&a<=1))return"at must be a finite number from 0 to 1";return null}function k5(n){if(n.fromEdge===void 0)return n.edgeInset!==void 0||n.at!==void 0?"edgeInset/at require fromEdge":null;if(n.container||n.lookFor||n.autoTarget===!0)return"fromEdge swipes the screen or panel edge; it cannot be combined with container, lookFor, or autoTarget=true";let s=Ut(n);if(s)return s;let a=Wt[n.fromEdge];if(n.direction!==a)return`fromEdge "${n.fromEdge}" swipes inward, so the finger direction must be "${a}"`;return null}function ae(n){return k5({...n,direction:Yc(n).direction??n.direction})}function we(n){let{edge:s,bounds:a}=n,c=n.inset??A5,l=n.at??T5,u=a.right-a.left,d=a.bottom-a.top,p=(S,v,O)=>Math.min(O,Math.max(v,S)),m=p(Math.round(a.left+l*u),a.left,a.right-1),h=p(Math.round(a.top+l*d),a.top,a.bottom-1),f=Math.round(u*Ue),w=Math.round(d*Ue),y=(S)=>p(S,a.left,a.right-1),b=(S)=>p(S,a.top,a.bottom-1);switch(s){case"left":return{x1:y(a.left+c),y1:h,x2:y(a.left+c+f),y2:h};case"right":return{x1:y(a.right-1-c),y1:h,x2:y(a.right-1-c-f),y2:h};case"top":return{x1:m,y1:b(a.top+c),x2:m,y2:b(a.top+c+w)};case"bottom":return{x1:m,y1:b(a.bottom-1-c),x2:m,y2:b(a.bottom-1-c-w)}}}function Xe(n,s,a){let{x1:c,y1:l,x2:u,y2:d}=we({edge:s,bounds:a,inset:n.edgeInset,at:n.at});return{startX:c,startY:l,endX:u,endY:d}}function Xt(n,s){if(!Number.isFinite(n)||!Number.isFinite(s))return;if(n<=0||s<=0)return;let a=n/(s/1000),c=Math.min(Math.max(a,100),1e4),l=Math.round(n/c*1000);if(Math.abs(l-s)<=1)return;return{effectiveDurationMs:l,warning:`durationMs ${s} was clamped on the iOS XCUICoordinate swipe route: velocity is limited to 100-10000 pt/s, so this ${Math.round(n)} pt swipe ran for about ${l} ms (effectiveDurationMs). The unpinned synthesized route honours the duration down to 50 ms.`}}function qe(n,s,a){let{swipeRoute:c,effectiveDurationMs:l}=a;if(c===void 0||l===void 0){let u=Xt(n,s);return u?{effectiveDurationMs:u.effectiveDurationMs,warnings:[u.warning]}:{}}if(Math.abs(l-s)<=1)return{dispatchRoute:c};return{dispatchRoute:c,effectiveDurationMs:l,warnings:[c==="xcuiCoordinate"?`durationMs ${s} was clamped on the iOS XCUICoordinate swipe route: velocity is limited to 100-10000 pt/s, so this swipe ran for about ${l} ms (effectiveDurationMs).`:`durationMs ${s} was adjusted on the iOS ${c} swipe route: the runner dispatched ${l} ms (effectiveDurationMs; the synthesized route floors the stroke at 50 ms).`]}}var Yt="durationMs was ignored: the TalkBack semantic scroll route (ACTION_SCROLL on the container) performs a discrete scroll with no timed stroke, so the reported duration is a nominal value. Use a container without a stable selector, or turn TalkBack off, to get a timed swipe.";function ze(n,s){return{success:!0,...n,duration:s?.duration||300,durationIgnored:!0,...s?.durationExplicit?{warnings:[Yt]}:{}}}function X(n){return n.durationMs===void 0?void 0:!0}function _V(n,s,a,c){if(c<=0)return n;let l=Math.hypot(a.x-s.x,a.y-s.y);return{...n,velocityPxPerSecond:Math.round(l/c*1000)}}function Ke(n,s){if(!n.success||n.durationIgnored||s.boomerang||s.lookFor)return n;if(![n.x1,n.y1,n.x2,n.y2].every(Number.isFinite))return n;return _V(n,{x:n.x1,y:n.y1},{x:n.x2,y:n.y2},n.effectiveDurationMs??n.duration)}var zt=["lookFor","focusTarget","autoTarget","includeSystemInsets","scrollMode","layer"];function jt(n,s){if(!s||n.warnings?.includes(s))return n;return{...n,warnings:[...n.warnings??[],s]}}function Qt({options:n,platform:s}){return zt.find((a)=>n[a]!==void 0&&(s!=="android"||a==="focusTarget"||a==="layer"))}function Jt(n,s,a){let c=a??{left:0,top:0,right:s.screenSize.width,bottom:s.screenSize.height};if(n.fromEdge)return we({edge:n.fromEdge,bounds:c,inset:n.edgeInset,at:n.at});let l=Math.round((c.left+c.right)/2),u=Math.round((c.top+c.bottom)/2),d=Math.round((c.right-c.left)*0.6)/2,p=Math.round((c.bottom-c.top)*0.6)/2;switch(n.direction){case"left":return{x1:l+d,y1:u,x2:l-d,y2:u};case"right":return{x1:l-d,y1:u,x2:l+d,y2:u};case"up":return{x1:l,y1:u+p,x2:l,y2:u-p};default:return{x1:l,y1:u-p,x2:l,y2:u+p}}}function be(n){return n instanceof t&&n.containerFailure?{containerFailure:n.containerFailure}:{}}class ye{ctx;constructor(n){this.ctx=n}async executeOnAndroidDisplay({options:n,target:s,signal:a,talkBack:c}){let l=s.observation;if(n.container||n.autoTarget===!0)l=await k(l,(D)=>this.ctx().observeScreen.execute({...vc,display:s.followUpDisplay,freshness:"fresh",timeoutMs:D,signal:a}),this.ctx().timer,a);let u=this.validateSelectedDisplayObservation({observation:l,target:s,includeSystemInsets:n.includeSystemInsets}),d=await this.ctx().androidXr(u,a),{options:p,decision:m}=this.selectedDisplayAutoTarget({androidXr:d,options:n,observation:u}),{x1:h,y1:f,x2:w,y2:y,targetType:b,warning:S}=this.resolveDisplaySwipeCoordinates({options:p,decision:m,observation:u,androidXr:d}),v=W({...p,geometry:this.ctx().geometry}),O=T(p);if(c.enabled){let D=await this.dispatchTalkBackDisplaySwipe({options:p,element:m.element,observation:u,coordinates:{x1:h,y1:f,x2:w,y2:y},duration:v,boomerang:O,target:s,signal:a});return this.ctx().autoTargeting.withAutoTargetDecision({result:{...D,targetType:b,warning:S},decision:m})}let R=await this.resolveDisplaySwipeRoute({options:p,target:s});await this.dispatchDisplaySwipeLeg({x1:h,y1:f,x2:w,y2:y,duration:v,target:s,observation:u,useCtrlProxy:R,signal:a});let g=v;if(O){let D=M({forwardDuration:v,returnSpeed:O.returnSpeed});g+=O.apexPauseMs+D;let A=await OC({timer:this.ctx().timer,apexPauseMs:O.apexPauseMs,signal:a,returnSwipe:()=>this.dispatchDisplayReturnLeg({x1:w,y1:y,x2:h,y2:f,duration:D,target:s,observation:u,useCtrlProxy:R,signal:a})});if(!A.success)return this.ctx().autoTargeting.withAutoTargetDecision({result:{...A,targetType:b,x1:h,y1:f,x2:w,y2:y,duration:g,warning:S},decision:m})}return this.ctx().autoTargeting.withAutoTargetDecision({result:{success:!0,targetType:b,x1:h,y1:f,x2:w,y2:y,duration:g,warning:S,...c.unknownWarning?{warnings:[c.unknownWarning]}:{}},decision:m})}async resolveDisplayTalkBack(n,s){let a=await this.ctx().accessibilityDetector.resolveTalkBackState(this.ctx().device.deviceId,this.ctx().adb,this.ctx().featureFlags);if(o(s),a!==!0)return{enabled:!1,unknownWarning:a===null?Ca:void 0};let c=rg(n.displayId,"scrolling");if(c)throw c;return{enabled:!0}}async dispatchTalkBackDisplaySwipe({options:n,element:s,observation:a,coordinates:c,duration:l,boomerang:u,target:d,signal:p}){let m=Yc(n);if(!m.direction)throw new t(m.error??"direction is required");d.assertCurrent();let{x1:h,y1:f,x2:w,y2:y}=c,b=await this.ctx().talkBackExecutor.executeSwipeGesture({x1:h,y1:f,x2:w,y2:y,direction:m.direction,containerElement:s??null,observation:a,gestureOptions:{displayFence:{assertCurrent:d.assertCurrent},duration:l,durationExplicit:X(n),scrollMode:n.scrollMode},perf:void 0,boomerang:u,signal:p});if(o(p),!b.success)throw new t(b.error??"TalkBack swipe failed");return b}resolveDisplaySwipeCoordinates({options:n,decision:s,observation:a,androidXr:c}){let l=xC(a,c);if(s.element&&a.viewHierarchy){let p=this.ctx().resolveContainerSwipeCoordinates({...n,direction:n.direction},a.viewHierarchy,s.element,a);return{x1:p.startX,y1:p.startY,x2:p.endX,y2:p.endY,targetType:"element",warning:vL(p.warning,l)}}let u=this.selectedDisplayContainerBounds(n,a);if(n.container&&!u)throw new t("Swipe container not found on selected display");let d=u?void 0:d3(a.backStack,c,n.fromEdge);return{...Jt(n,a,d??this.resolveDisplaySwipeBounds(n,a,u)),targetType:u?"element":"screen",...l?{warning:l}:{}}}resolveDisplaySwipeBounds(n,s,a){return n.includeSystemInsets===!1||n.autoTarget===!0&&!a&&n.includeSystemInsets!==!0?this.insetDisplaySwipeBounds({observation:s,bounds:a}):a}selectedDisplayAutoTarget({options:n,observation:s,androidXr:a}){if(n.autoTarget!==!0||n.container)return{options:n,decision:{}};let c=Yc(n);if(!c.direction)throw new t(c.error??"direction is required");let l=s.viewHierarchy?this.ctx().scrollables.findScrollableElements(s.viewHierarchy).filter((d)=>B(d,a)):[],u=this.ctx().autoTargeting.resolveAutoTargetDecision({scrollables:l,candidates:this.ctx().autoTargeting.buildScrollableCandidates(l),observeResult:s,direction:c.direction,includeSystemInsets:n.includeSystemInsets});return{options:{...n,direction:c.direction,container:u.container},decision:u}}async resolveDisplaySwipeRoute({options:n,target:s}){if(n.scrollMode==="adb")return!1;let a=await Ma(this.ctx().accessibilityService,s.displayId);if(n.scrollMode==="a11y"&&!a)throw new t(`scrollMode "a11y" requires CtrlProxy capability gesture_display_id_v1 for display "${s.observation.display.key}". Update CtrlProxy or use scrollMode "adb".`);return a}insetDisplaySwipeBounds({observation:n,bounds:s}){let a={observation:n,platform:te(this.ctx().device.platform,"swipeOn")},c=Mu(a)??n.screenSize;return Xk({...a,bounds:s??qs(c)})}validateSelectedDisplayObservation(n){let{observation:s,target:a,includeSystemInsets:c}=n;if(a.assertCurrent(),s.display.key!==a.observation.display.key)throw df(a.observation.display.generation,this.ctx().displayTransitionReader.identityRevision(this.ctx().device.deviceId),this.ctx().displayTransitionReader.currentObservedPanel(this.ctx().device.deviceId)?.key);if(c!==void 0&&s.insets?.available!==!0)throw new t(`includeSystemInsets is not supported with \`display\` for display "${a.observation.display.key}": per-display system insets are unavailable`);return s.insets?.available===!0?s:{...s,systemInsets:{top:0,right:0,bottom:0,left:0}}}async resolveSearchDisplaySwipeRoute({options:n,target:s,signal:a}){if(n.scrollMode==="a11y")return this.resolveDisplaySwipeRoute({options:n,target:s});try{return await this.resolveDisplaySwipeRoute({options:n,target:s})}catch(c){return o(a),e.debug("[SwipeOn] CtrlProxy display gesture capability unavailable",c),!1}}executeDisplayTalkBackSwipe(n){return n.onDispatched?.(),this.ctx().talkBackExecutor.executeSwipeGesture({x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,direction:n.direction,containerElement:null,observation:n.observation,gestureOptions:{displayFence:{assertCurrent:n.target.assertCurrent},duration:n.duration,scrollMode:n.options.scrollMode,searchDragState:n.searchDragState},perf:void 0,boomerang:void 0,signal:n.signal})}validatedObserveScreen(n,s){let a=this.ctx().observeScreen;return{execute:async(c)=>(s.assertCurrent(),n(await a.execute(c))),getMostRecentCachedObserveResult:a.getMostRecentCachedObserveResult.bind(a),appendRawViewHierarchy:a.appendRawViewHierarchy.bind(a),captureScreenshot:a.captureScreenshot?.bind(a),runAccessibilityAudit:a.runAccessibilityAudit?.bind(a),processRecomposition:a.processRecomposition?.bind(a),captureCacheGeneration:a.captureCacheGeneration?.bind(a),cacheObserveResult:a.cacheObserveResult?.bind(a)}}async searchOnAndroidDisplay({options:n,target:s,progress:a,signal:c,talkBack:l}){let u=Yc(n);if(u.error)throw new t(u.error);let d=await this.resolveSearchDisplaySwipeRoute({options:n,target:s,signal:c}),p=s.followUpDisplay,m=(b)=>this.validateSelectedDisplayObservation({observation:b,target:s,includeSystemInsets:n.includeSystemInsets}),h=this.validatedObserveScreen(m,s),f=!1,w=async(b)=>{try{return s.assertCurrent(),m(await this.ctx().observeScreen.execute({display:p,freshness:b?.freshness??"cached-ok",timeoutMs:b?.timeoutMs,skipScreenshot:!0,skipAccessibilityAudit:!0,signal:c}))}catch(S){throw this.ctx().rethrowObservationAbort(S,c),e.warn(`[SwipeOn] Display search read failed: ${r(S)}`,S),f?new fr(S):S}},y=await this.ctx().scrollUntilVisible.executeWithStrategy({options:{...n,direction:u.direction},progress:a,signal:c,strategy:{observe:w,swipe:async({previousObservation:b,searchDragState:S,onDispatched:v,...O})=>{let R=await this.ctx().visual.observedInteraction(async()=>{let g=async()=>(O.onSearchFallback?.(),await this.dispatchDisplaySwipeLeg({...O,observation:b,target:s,useCtrlProxy:!1,signal:c,onDispatched:v}),f=!0,{...O,success:!0});if(!l.enabled)yL(b,await this.ctx().androidXr(b,c));let D=await(l.enabled?this.executeDisplayTalkBackSwipe({...O,observation:b,direction:u.direction,options:n,target:s,searchDragState:S,signal:c,onDispatched:v}):d?se({...O,searchDragState:S,client:this.ctx().accessibilityService,signal:c,displayId:s.displayId===0?void 0:s.displayId,beforeSend:s.assertCurrent,fallback:g,onDispatched:v,onIndeterminate:(A)=>{throw new fr(A)}}):g());return f||=D.success,D},{changeExpected:!1,timeoutMs:At.brief,display:p,previousObservation:b,progress:a,signal:c,deferPostActionScreenshot:!0,postActionObserveScreen:h});return this.ctx().checkPostActionDisplay(R,()=>m(R.observation),c),{...O,targetType:"screen",success:R.success,error:R.error,outcomeIndeterminate:R.outcomeIndeterminate,observation:R.observation,staleDisplay:R.staleDisplay}}}});if(f)this.ctx().checkPostActionDisplay({},s.assertCurrent,c);else s.assertCurrent();return jt(y,l.unknownWarning)}async dispatchDisplayReturnLeg(n){let{x1:s,y1:a,x2:c,y2:l,duration:u,signal:d}=n;try{return await this.dispatchDisplaySwipeLeg(n),{success:!0,x1:s,y1:a,x2:c,y2:l,duration:u}}catch(p){if(o(d),bt(p)||p instanceof Ee)throw p;if(p instanceof Error&&p.name==="AbortError")throw p;return e.warn(`swipeOn display return leg failed: ${r(p)}`,p),{success:!1,error:r(p),x1:s,y1:a,x2:c,y2:l,duration:u}}}async dispatchDisplaySwipeLeg(n){let{x1:s,y1:a,x2:c,y2:l,duration:u,target:d,useCtrlProxy:p,signal:m,onDispatched:h}=n;if(d.assertCurrent(),o(m),yL(n.observation,await this.ctx().androidXr(n.observation,m)),p){let f=await this.ctx().accessibilityService.requestSwipe({x1:s,y1:a,x2:c,y2:l,duration:u,onDispatch:h,signal:m,displayId:d.displayId===0?void 0:d.displayId,beforeSend:d.assertCurrent});if(o(m),!f.success)throw new t(f.error??"Android swipe failed")}else await wc(this.ctx().adb,`swipe ${s} ${a} ${c} ${l} ${Vo(u)}`,d.displayId,{signal:m,assertCurrent:d.assertCurrent,onDispatch:h})}selectedDisplayContainerBounds(n,s){if(!n.container||!s.viewHierarchy)return;if(C(n.container))return this.ctx().scrollUntilVisible.resolveSwipeContainer(s.viewHierarchy,n.container).bounds;let a=this.ctx().scrollUntilVisible.resolveElement(s.viewHierarchy,n.container,"inspect",n.container.text!==void 0);return a&&n.direction?this.ctx().scrollUntilVisible.resolveSwipeTarget(s.viewHierarchy,a,n.direction).bounds:a?.bounds}async executeExplicitDisplay(n,s={}){let{progress:a,signal:c}=s;if(n.display!==void 0)try{let l=Qt({options:n,platform:this.ctx().device.platform});if(l)throw new t(BR(l));let u=$h(n,this.ctx().getDuration(n))??ae(n);if(u)throw new t(u);let d=await Wi(this.ctx().device,n.display,this.ctx().observeScreen,{adb:this.ctx().adb,lastRenderedObservation:this.ctx().lastRenderedObservation,signal:c,transitions:this.ctx().displayTransitionReader});if(o(c),this.ctx().device.platform==="android"){this.validateSelectedDisplayObservation({observation:d.observation,target:d,includeSystemInsets:n.includeSystemInsets});let p=await this.resolveDisplayTalkBack(d,c);return n.lookFor?await this.searchOnAndroidDisplay({options:n,target:d,progress:a,signal:c,talkBack:p}):await this.ctx().observedSwipeInteraction(()=>this.executeOnAndroidDisplay({options:n,target:d,signal:c,talkBack:p}),{changeExpected:!1,display:d.followUpDisplay,previousObservation:d.observation,signal:c},{boomerang:T(n)})}}catch(l){if(l instanceof V)throw l;if(lW(c,l),l instanceof Error&&l.name==="AbortError")throw l;return e.warn(`swipeOn display routing failed: ${r(l)}`,l),Zt({...this.ctx().createErrorResult(r(l)),...be(l)},l)}return}}function ge(n){return n.perf??new U}function er(n,s){return(n.dispatched??s)&&n.acknowledged!==!0||Al(n)}class mT extends Oe{constructor(n,s=null,a=i){super(n,{adb:s,timer:a});this.device=n}async swipe(n,s={},a={}){switch(o(a.signal),this.device.platform){case"android":return await this.executeAndroidSwipe(n,s,a);case"ios":return await this.executeiOSSwipe(n,s,a);default:throw St(this.device.platform,"execute gesture")}}async executeAndroidSwipe(n,s={},a={}){let{x1:c,y1:l,x2:u,y2:d}=n,{signal:p}=a,m=ge(a),h=s.duration??300,f=s.scrollMode||"adb";if(s.searchScroll){let w=s.searchScrollBounds?ne({startX:c,startY:l,endX:u,endY:d},s.searchScrollBounds):{startX:c,startY:l,endX:u,endY:d},y=new ir().getSwipeDurationFromSpeed("slow"),b=()=>this.executeAndroidSwipe({x1:w.startX,y1:w.startY,x2:w.endX,y2:w.endY},{duration:y,scrollMode:"adb",displayFence:s.displayFence},a);if(s.scrollMode==="adb")return b();return se({client:E.getInstance(this.device,this.adbFactory),x1:w.startX,y1:w.startY,x2:w.endX,y2:w.endY,duration:y,signal:p,searchDragState:s.searchDragState,onFallback:s.onSearchFallback,fallback:b,beforeSend:()=>s.displayFence?.assertCurrent()})}if(f==="a11y")return await this.executeA11ySwipe(n,h,{perf:m,signal:p,displayFence:s.displayFence});try{await m.track("adbInputSwipe",async()=>{o(p),s.displayFence?.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${c} ${l} ${u} ${d} ${Vo(h)}`,{signal:p})}),o(p)}catch(w){if(w instanceof Ee)throw w;return o(p),e.warn(`[SWIPE] ADB swipe failed: ${r(w)}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:h,error:r(w)}}return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:h}}async executeA11ySwipe(n,s,a={}){let{x1:c,y1:l,x2:u,y2:d}=n,{signal:p}=a,m=ge(a),h=wv(a),f=!1,w=(S)=>({success:!1,outcomeIndeterminate:!0,x1:c,y1:l,x2:u,y2:d,duration:s,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${S}). Do not retry automatically.`}),y,b="failure";try{o(p);let S=E.getInstance(this.device,this.adbFactory),v=await m.track("a11ySwipe",async()=>(o(p),h.assertCurrent(),await S.requestSwipe({x1:c,y1:l,x2:u,y2:d,duration:s,timeoutMs:5000,perf:m,onDispatch:()=>{f=!0}})));if(o(p),v.success)return e.info(`[SWIPE] A11y swipe successful: deviceTotal=${v.totalTimeMs}ms, gesture=${v.gestureTimeMs}ms`),{success:!0,x1:c,y1:l,x2:u,y2:d,duration:s,a11yTotalTimeMs:v.totalTimeMs,a11yGestureTimeMs:v.gestureTimeMs};if(f)return e.warn(`[SWIPE] A11y swipe outcome indeterminate: ${v.error}`),w(v.error??"unknown error");e.warn(`[SWIPE] A11y swipe failed: ${v.error}, falling back to ADB`),y=v.error}catch(S){if(S instanceof Ee)throw S;if(o(p),f)return e.warn(`[SWIPE] A11y swipe outcome indeterminate: ${S}`),w(`${S}`);e.warn(`[SWIPE] A11y swipe exception: ${S}, falling back to ADB`),y=r(S),b="exception"}try{await m.track("adbInputSwipeFallback",async()=>{o(p),h.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${c} ${l} ${u} ${d} ${Vo(s)}`,{signal:p})}),o(p)}catch(S){if(S instanceof Ee)throw S;return o(p),e.warn(`[SWIPE] ADB fallback failed after a11y ${b}: ${r(S)}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:y,error:`Accessibility swipe failed: ${y??"unknown error"}; ADB fallback failed: ${r(S)}`}}return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:y}}async executeiOSSwipe(n,s={},a={}){return await this.executeXCTestSwipe(n,s,a)}async executeXCTestSwipe(n,s={},a={}){let{x1:c,y1:l,x2:u,y2:d}=n,p=s.duration||300,{signal:m}=a,h=ge(a),f=s.displayFence;o(m);let w=x.getInstance(this.device),y=!1,b=(v)=>({success:!1,outcomeIndeterminate:!0,x1:c,y1:l,x2:u,y2:d,duration:p,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${v}). The swipe may have been applied. Do not retry automatically.`}),S;try{S=await h.track("xctestSwipe",async()=>(o(m),f?.assertCurrent(),await w.requestSwipe({x1:c,y1:l,x2:u,y2:d,duration:p,timeoutMs:Math.min(5000,s.timeoutMs??5000),perf:h,contextOptions:s.lockScreen===!0?{lockScreen:!0}:void 0,signal:m,onDispatch:()=>{y=!0}})))}catch(v){if(!y||v instanceof t)throw v;return e.warn(`[SWIPE] CtrlProxy iOS swipe outcome indeterminate: ${r(v)}`),b(r(v))}if(!S.success&&er(S,y))return e.warn(`[SWIPE] CtrlProxy iOS swipe outcome indeterminate: ${S.error}`),b(S.error??"unknown error");if(o(m),S.success){e.info(`[SWIPE] CtrlProxy iOS swipe successful: deviceTotal=${S.totalTimeMs}ms, gesture=${S.gestureTimeMs}ms`);let v=qe(Math.hypot(u-c,d-l),p,S);return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:p,a11yTotalTimeMs:S.totalTimeMs,a11yGestureTimeMs:S.gestureTimeMs,...v}}else return e.error(`[SWIPE] CtrlProxy iOS swipe failed: ${S.error}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:p,error:S.error}}async execute(n,s,a,c={}){let{durationMs:l=300,signal:u,displayFence:d}=typeof s==="object"?s:{durationMs:s,signal:a,displayFence:c.displayFence};switch(o(u),this.device.platform){case"android":return await this.executeAndroidGesture(n,l,u,{displayFence:d});case"ios":return await this.executeiOSGesture(n,l,u,{displayFence:d});default:throw St(this.device.platform,"execute gesture")}}async executeAndroidGesture(n,s,a,c={}){let l=c.displayFence;if(Array.isArray(n)&&n.length>0)if("finger"in n[0])throw Error("Multi-finger gestures not supported - use simple swipe instead");else{let u=n;if(u.length>=2){let d=u[0],p=u[u.length-1];o(a),l?.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${d.x} ${d.y} ${p.x} ${p.y} ${Vo(s)}`,{signal:a}),o(a)}}return{pathLength:n.length,duration:s,platform:"android"}}async executeiOSGesture(n,s,a,c={}){let l=c.displayFence;if(Array.isArray(n)&&n.length>0)if("finger"in n[0]){let u=n,d=this.resolveIOSMultiFingerSwipe(u);if(d)await this.executeIOSMultiFingerSwipe(d,s,a,l)}else{let u=n;if(u.length>=2)await this.executeIOSSingleFingerSwipe(u[0],u[u.length-1],s,{signal:a,fence:l})}return{pathLength:n.length,duration:s,platform:"ios"}}async executeIOSSingleFingerSwipe(n,s,a,{signal:c,fence:l}={}){o(c);let u=x.getInstance(this.device);l?.assertCurrent();let d=await u.requestSwipe({x1:n.x,y1:n.y,x2:s.x,y2:s.y,duration:a,signal:c});if(this.throwIfIosGestureUnconfirmed(d),o(c),!d.success)throw new t(`iOS gesture failed: ${d.error??"unknown error"}`)}async executeIOSMultiFingerSwipe(n,s,a,c){o(a);let l=x.getInstance(this.device);c?.assertCurrent();let u=await l.requestMultiFingerSwipe({x1:n.start.x,y1:n.start.y,x2:n.end.x,y2:n.end.y,fingerCount:n.fingerCount,duration:s,fingerSpacing:n.fingerSpacing,signal:a,beforeSend:()=>c?.assertCurrent()});if(this.throwIfIosGestureUnconfirmed(u),o(a),!u.success)throw new t(`iOS multi-finger gesture failed: ${u.error??"unknown error"}`)}throwIfIosGestureUnconfirmed(n){if(!n.success&&n.dispatched&&(n.acknowledged===!1||Al(n)))throw new t(`Gesture outcome is indeterminate: the request was dispatched but no result was confirmed (${n.error??"unknown error"}). The gesture may have been applied. Do not retry automatically. Observe before retrying.`)}resolveIOSMultiFingerSwipe(n){if(n.length===0)return null;for(let u=0;u<n.length;u++){let d=n[u].points;if(d.length<2)throw Error("iOS multi-finger gestures require at least two points per finger");if(d.length!==2)throw Error("iOS multi-finger gestures only support two-point swipes")}let s=n[0].points,a=s[0],c=s[1],l=n.length>1?n[1].points[0].x-a.x:0;for(let u=0;u<n.length;u++){let d=n[u].points,p=d[0],m=d[1],h=u*l;if(!this.sameCoordinate(p.y,a.y)||!this.sameCoordinate(m.y,c.y)||!this.sameCoordinate(p.x-a.x,h)||!this.sameCoordinate(m.x-c.x,h))throw Error("iOS multi-finger gestures only support horizontally spaced parallel swipes")}return{start:a,end:c,fingerCount:n.length,fingerSpacing:l}}sameCoordinate(n,s){return Math.abs(n-s)<0.001}}class G{geometry;elementParser;static OVERLAY_PADDING=8;static CANDIDATE_FRACTIONS=[0.5,0.25,0.75,0.15,0.85];constructor(n,s){this.geometry=n;this.elementParser=s}collectOverlayCandidates(n,s){let a=this.elementParser,c=a.extractWindowRootGroups(n,"topmost-first"),l=c.length>0?c:[a.extractRootNodes(n)],u=Math.max(1,l.length),d=[],p=new Set,m=s.bounds,h=this.resolveSelectedContainerNode(n,a,s,m),f=h?.node??null,w=this.collectContainerAncestors(h?.roots??null,a,f),y=this.findContainerWindowIndex(l,a,f);return l.forEach((b,S)=>{if(y!==null&&S>y)return;let v=u-S,O=0;for(let R of b){let g=!1,D=-1;a.traverseNode(R,(A,I)=>{if(p.has(A))return;p.add(A);let de=O++,H=a.extractNodeProperties(A);if(this.isContainerNode(A,H,f,{containerElement:s,containerBounds:m})){if(!g)g=!0,D=I;return}if(g&&I<=D)g=!1,D=-1;if(g||w.has(A))return;if(!this.isClickableNode(H))return;let F=a.parseNodeBounds(A);if(!F)return;let _=this.intersectBounds(m,F.bounds);if(!_)return;let z=pt(_);if(z<=0)return;d.push({bounds:F.bounds,overlapBounds:_,coverage:z,zOrder:{windowRank:v,nodeOrder:de}})})}}),d}computeSafeSwipeCoordinates(n,s,a){let c=n==="up"||n==="down",l=c?s.top:s.left,u=c?s.bottom:s.right,d=c?s.left:s.top,p=c?s.right:s.bottom,m=this.buildCandidateCoordinates(d,p),h=this.findBestSwipeCandidate(c,s,a,{candidates:m,primary:{start:l,end:u}});if(!h)return null;let f=c?{left:s.left,right:s.right,top:h.interval.start,bottom:h.interval.end}:{left:h.interval.start,right:h.interval.end,top:s.top,bottom:s.bottom},w=this.geometry.getSwipeWithinBounds(n,f),{startX:y,startY:b,endX:S,endY:v}=w;if(c)y=h.coordinate,S=h.coordinate;else b=h.coordinate,v=h.coordinate;y=co(y,f.left,f.right),S=co(S,f.left,f.right),b=co(b,f.top,f.bottom),v=co(v,f.top,f.bottom);let O=Math.max(1,u-l),R=Math.max(50,O*0.1),g=h.interval.length<R?`Swipe area reduced by overlaying elements; safe ${c?"height":"width"} is ${Math.round(h.interval.length)}px.`:void 0;return{startX:y,startY:b,endX:S,endY:v,warning:g}}findBestSwipeCandidate(n,s,a,{candidates:c,primary:l}){let u=null;for(let d of c){let p=n?this.getBlockedIntervalsForX(a,s,d):this.getBlockedIntervalsForY(a,s,d),m=this.findLargestGap(l.start,l.end,p);if(!m)continue;if(!u||m.length>u.interval.length)u={coordinate:d,interval:m}}return u}getBlockedIntervalsForX(n,s,a){let c=[];for(let l of n){let u=this.expandBounds(l,G.OVERLAY_PADDING);if(a<u.left||a>u.right)continue;let d=Math.max(s.top,u.top),p=Math.min(s.bottom,u.bottom);if(p>d)c.push({start:d,end:p,length:p-d})}return c}getBlockedIntervalsForY(n,s,a){let c=[];for(let l of n){let u=this.expandBounds(l,G.OVERLAY_PADDING);if(a<u.top||a>u.bottom)continue;let d=Math.max(s.left,u.left),p=Math.min(s.right,u.right);if(p>d)c.push({start:d,end:p,length:p-d})}return c}findLargestGap(n,s,a){let c=this.mergeIntervals(a),l=n,u=null;for(let d of c){if(d.start>l){let p={start:l,end:d.start,length:d.start-l};if(!u||p.length>u.length)u=p}l=Math.max(l,d.end)}if(l<s){let d={start:l,end:s,length:s-l};if(!u||d.length>u.length)u=d}return u}mergeIntervals(n){let s=n.filter((c)=>c.end>c.start).sort((c,l)=>c.start-l.start),a=[];for(let c of s){let l=a[a.length-1];if(!l||c.start>l.end){a.push({...c});continue}l.end=Math.max(l.end,c.end),l.length=l.end-l.start}return a}buildCandidateCoordinates(n,s){let a=s-n;if(a<=0)return[];let c=G.CANDIDATE_FRACTIONS.map((l)=>Math.floor(n+a*l));return Array.from(new Set(c.filter((l)=>l>=n&&l<=s)))}expandBounds(n,s){return{left:n.left-s,top:n.top-s,right:n.right+s,bottom:n.bottom+s}}intersectBounds(n,s){let a=Math.max(n.left,s.left),c=Math.min(n.right,s.right),l=Math.max(n.top,s.top),u=Math.min(n.bottom,s.bottom);if(c<=a||u<=l)return null;return{left:a,top:l,right:c,bottom:u}}collectContainerAncestors(n,s,a){let c=new Set;if(!a||!n)return c;let l=[],u=!1;for(let d of n)if(s.traverseNode(d,(p,m)=>{if(u)return;if(l.length=m,l[m]=p,p===a){for(let h of l.slice(0,m))c.add(h);u=!0}}),u)return c;return c}findContainerWindowIndex(n,s,a){if(!a||n.length<2)return null;let c=n.findIndex((l)=>l.some((u)=>this.treeContains(u,s,a)));return c===-1?null:c}treeContains(n,s,a){let c=!1;return s.traverseNode(n,(l)=>{if(l===a)c=!0}),c}isClickableNode(n){return dt(n.clickable)||dt(n.focusable)}resolveSelectedContainerNode(n,s,a,c){let l=s.extractRootNodes(n),u=this.findSelectorBoundsMatch(l,s,a,c);if(u.matchCount>0)return u.matchCount===1&&u.match?{node:u.match,roots:l}:null;let d=s.extractWindowRootGroups(n,"topmost-first");for(let p of d){let m=this.findSelectorBoundsMatch(p,s,a,c);if(m.matchCount>0)return m.matchCount===1&&m.match?{node:m.match,roots:p}:null}return null}findSelectorBoundsMatch(n,s,a,c){let l=null,u=0;for(let d of n)s.traverseNode(d,(p)=>{let m=s.extractNodeProperties(p);if(!this.matchesContainerSelector(p,m,a,c))return;let h=this.elementParser.parseBounds(qt(p));if(h===null||!Mt(h,c))return;u++,l=p});return{match:l,matchCount:u}}isContainerNode(n,s,a,{containerElement:c,containerBounds:l}){if(a&&n===a)return!0;return this.matchesContainerSelector(n,s,c,l)}matchesContainerSelector(n,s,a,c){let l=Vt(s),u=Boolean(a["resource-id"]),d=Boolean(a.text),p=Boolean(a["content-desc"]);if(u||d||p){if(u&&l.nativeId!==a["resource-id"])return!1;if(d&&l.textSources.text!==a.text)return!1;if(p&&l.textSources["content-desc"]!==a["content-desc"])return!1;return!0}let m=this.elementParser.parseBounds(qt(n));return m!==null&&Mt(m,c)}}class q{geometry;constructor(n=new ir){this.geometry=n}selectAutoTargetScrollable(n,s,a){let c=n.filter((d)=>this.matchesDirection(d,a));if(c.length===0)return null;let l=s?c.filter((d)=>!Mt(d.bounds,s)):c,u=l.length>0?l:c;if(s){let d=(s.left+s.right)/2,p=(s.top+s.bottom)/2,m=u.filter((h)=>this.geometry.isPointInElement(h,d,p));if(m.length>0)return m.reduce((h,f)=>pt(f.bounds)<pt(h.bounds)?f:h)}if(u.length>1){let d=a==="up"||a==="down",p=u.filter((m)=>{if(this.knownScrollAxis(m))return!0;let h=Math.abs(m.bounds.right-m.bounds.left),f=Math.abs(m.bounds.bottom-m.bounds.top);return d?f>=h:h>=f});if(p.length>0)return this.pickLargestScrollable(p)}return this.pickLargestScrollable(u)}pickLargestScrollable(n){if(n.length===0)return null;return n.reduce((s,a)=>{let c=pt(s.bounds);return pt(a.bounds)>c?a:s})}matchesDirection(n,s){let a=this.knownScrollAxis(n);return a===void 0||(s==="up"||s==="down")===(a==="vertical")}scrollsInDirection(n,s){return(ht(n.scrollable)||this.knownScrollAxis(n)!==void 0)&&this.matchesDirection(n,s)}knownScrollAxis(n){let s=typeof n.orientation==="string"?n.orientation.toLowerCase():void 0;if(s==="horizontal"||s==="vertical")return s;let a=n.class??n.className,c=typeof a==="string"?a.split(".").at(-1)??"":"";if(["HorizontalScrollView","ViewPager","ViewPager2","LazyRow"].includes(c))return"horizontal";if(["ScrollView","NestedScrollView","ListView","ExpandableListView","LazyColumn"].includes(c))return"vertical";return}getScreenBounds(n,s={}){let a=s.platform??qr(n.viewHierarchy)?.platform,c={observation:n,platform:a,includeSystemInsets:a==="ios"?s.includeSystemInsets:void 0},l=Mu(c);if(!l)return null;return qs(l,Jk(c))}describeContainer(n){if(!n)return"unknown";if(n.elementId)return`elementId="${n.elementId}"`;if(n.text)return`text="${n.text}"`;return"unknown"}mergeWarnings(...n){let s=n.filter((a)=>Boolean(a));if(s.length===0)return;return Array.from(new Set(s)).join(" ")}}function tr(n){return n==="up"||n==="left"?"scroll_forward":"scroll_backward"}class xe{device;executeGesture;accessibilityService;accessibilityDetector;adb;timer;featureFlags;androidXr;constructor({device:n,executeGesture:s,accessibilityService:a,accessibilityDetector:c,adb:l,timer:u,featureFlags:d,androidXr:p}){this.device=n,this.executeGesture=s,this.accessibilityService=a,this.accessibilityDetector=c,this.adb=l,this.timer=u,this.featureFlags=d,this.androidXr=p}async executeSwipeGesture({observation:n,x1:s,y1:a,x2:c,y2:l,direction:u,containerElement:d,gestureOptions:p,perf:m,boomerang:h,signal:f}){o(f);let w=Boolean(h);if(e.info(`[SwipeOn] executeSwipeGesture: direction=${u}, (${s},${a})\u2192(${c},${l}), duration=${p?.duration}ms, boomerang=${w}, container=${d?.["resource-id"]??"none"}`),this.device.platform!=="android"){if(w)return this.executeBoomerangGesture({x1:s,y1:a,x2:c,y2:l,gestureOptions:p,boomerang:h,perf:m,signal:f});return this.executeGesture.swipe({x1:s,y1:a,x2:c,y2:l},p,{perf:m,signal:f})}let y=await this.accessibilityDetector.resolveTalkBackState(this.device.deviceId,this.adb,this.featureFlags),b=y===!0,S=y===null?Ca:void 0;if(o(f),b){if(p?.searchDragState)p.searchDragState.pagingStep=!0;if(w)return e.info("[SwipeOn] TalkBack enabled, boomerang requested; announcing swipeable element"),this.announceSwipeable({x1:s,y1:a,x2:c,y2:l,containerElement:d,gestureOptions:p,perf:m,signal:f});return e.info("[SwipeOn] TalkBack enabled, using accessibility-aware swipe"),this.executeAndroidSwipeWithAccessibility({observation:n,x1:s,y1:a,x2:c,y2:l,direction:u,containerElement:d,gestureOptions:p,perf:m,signal:f})}else{if(await this.assertDisplayInputSupported(n,f),w){e.debug("[SwipeOn] TalkBack disabled, using boomerang swipe");let O=await this.executeBoomerangGesture({x1:s,y1:a,x2:c,y2:l,gestureOptions:p,boomerang:h,perf:m,signal:f});return du(O,S)}e.debug("[SwipeOn] TalkBack disabled, using standard swipe");let v=await this.executeGesture.swipe({x1:s,y1:a,x2:c,y2:l},p,{perf:m,signal:f});return du(v,S)}}async executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:u,perf:d=new U,signal:p}){let m=l?.duration??300,h=$h({boomerang:!0,apexPause:u.apexPauseMs,returnSpeed:u.returnSpeed},m);if(h)throw new t(h);let f=this.getReturnDuration(m,u.returnSpeed),w=m+u.apexPauseMs+f,y=this.buildGestureOptions(l,m),b=this.buildGestureOptions(l,f),S=await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},y,{perf:d,signal:p});if(!S.success)return o(p),S;let v=await OC({timer:this.timer,apexPauseMs:u.apexPauseMs,signal:p,returnSwipe:()=>this.executeGesture.swipe({x1:a,y1:c,x2:n,y2:s},b,{perf:d,signal:p})});if(!v.success)return{...v,x1:n,y1:s,x2:a,y2:c,duration:w};return{...S,x1:n,y1:s,x2:a,y2:c,duration:w,a11yTotalTimeMs:this.sumOptional(S.a11yTotalTimeMs,v.a11yTotalTimeMs),a11yGestureTimeMs:this.sumOptional(S.a11yGestureTimeMs,v.a11yGestureTimeMs),fallbackReason:S.fallbackReason??v.fallbackReason}}async announceSwipeable({x1:n,y1:s,x2:a,y2:c,containerElement:l,gestureOptions:u,perf:d=new U,signal:p}){let m=u?.duration??0,h=l?.["resource-id"];if(!h)return e.warn("[SwipeOn] Boomerang swipe in TalkBack mode requires a container element with a resource-id."),{success:!1,error:"Boomerang swipe in TalkBack mode requires a container element with a resource-id.",x1:n,y1:s,x2:a,y2:c,duration:m};o(p);let f=await this.accessibilityService.requestAction("focus",h,5000,{perf:d});if(o(p),!f.success){let w=f.error??"Failed to set accessibility focus for boomerang swipe.";return e.warn(`[SwipeOn] ${w}`),{success:!1,error:w,x1:n,y1:s,x2:a,y2:c,duration:m}}return{success:!0,x1:n,y1:s,x2:a,y2:c,duration:m}}async executeAndroidSwipeWithAccessibility({observation:n,x1:s,y1:a,x2:c,y2:l,direction:u,containerElement:d,gestureOptions:p,perf:m,signal:h}){let f=d&&yi(d);if(f){let S=await this.attemptAccessibilityScroll({x1:s,y1:a,x2:c,y2:l,direction:u,selector:f,gestureOptions:p,perf:m,signal:h});if(S)return S}else e.debug("[SwipeOn] No container with resource-id, skipping ACTION_SCROLL");await this.assertDisplayInputSupported(n,h),e.info("[SwipeOn] Using two-finger swipe gesture for TalkBack");let w=p?.duration||300,y=100;o(h),p?.displayFence?.assertCurrent();let b=await this.accessibilityService.requestTwoFingerSwipe({x1:s,y1:a,x2:c,y2:l,duration:w,offset:y,timeoutMs:5000,perf:m||new U});if(o(h),b.success)return{success:!0,x1:s,y1:a,x2:c,y2:l,duration:w};else throw new t(`Two-finger swipe failed: ${b.error||"Unknown error"}`)}async attemptAccessibilityScroll({x1:n,y1:s,x2:a,y2:c,direction:l,selector:u,gestureOptions:d,perf:p,signal:m}){let h=(b)=>({success:!1,x1:n,y1:s,x2:a,y2:c,duration:d?.duration||300,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${b}). Do not retry automatically.`}),f=tr(l),w=ca(u),y=await ng(u,{supportsNodeActionSelectors:()=>this.accessibilityService.supportsNodeActionSelectors(),getAccessibilityHierarchy:()=>this.accessibilityService.getAccessibilityHierarchy(void 0,{perf:p,skipWaitForFresh:!1,disableAllFiltering:!0})});if(y){e.info(`[SwipeOn] ${y}`);return}e.info(`[SwipeOn] Attempting ACTION_SCROLL (${f}) on container: ${JSON.stringify(u)}`);try{o(m);let b=w?await this.accessibilityService.requestNodeAction(f,u,{timeoutMs:5000,perf:p}):await this.accessibilityService.requestAction(f,u.resourceId,5000,{perf:p||new U});if(b.success)return e.info("[SwipeOn] ACTION_SCROLL succeeded"),ze({x1:n,y1:s,x2:a,y2:c},d);if(b.dispatched&&b.acknowledged!==!0)return e.warn(`[SwipeOn] ACTION_SCROLL outcome indeterminate: ${b.error}`),h(b.error??"unknown error");e.warn(`[SwipeOn] ACTION_SCROLL failed: ${b.error}, falling back to two-finger swipe`)}catch(b){if(b instanceof Ee)throw b;return o(m),e.warn(`[SwipeOn] ACTION_SCROLL outcome indeterminate: ${b}`),h(String(b))}return}async assertDisplayInputSupported(n,s){if(n&&this.androidXr)yL(n,await this.androidXr(n,s))}buildGestureOptions(n,s){return{...n??{},duration:s}}getReturnDuration(n,s){return M({forwardDuration:n,returnSpeed:s})}sumOptional(n,s){if(n===void 0&&s===void 0)return;return(n??0)+(s??0)}resolveBoomerangConfig(n){return T(n)}}class Y extends t{constructor(n){super(n);this.name="SwipeOutcomeIndeterminateError"}}var rr=3000,nr=_5;function or(n){return Math.min(Math.max(nr,n+rr),Fr)}function ar(n,s,a){let c=s.viewHierarchy;if(n.containerElement){let d=Tv(n.containerElement),p=d&&zC(c,d.elementId);if(!p)return null;if(n.boomerang)return"unsupported";let m={x:n.x1-n.x2,y:n.y1-n.y2};return{action:{scroll:{...p,delta:m}},verb:"scroll"}}let l=zC(c);if(!l)return null;if(n.boomerang)return"unsupported";return{action:{swipe:{observationIdentity:l.observationIdentity,start:{x:n.x1,y:n.y1},end:{x:n.x2,y:n.y2},durationMs:a}},verb:"swipe"}}var cr="durationMs was ignored: the app's SDK observation bridge scrolls the container by an offset with no timed stroke, so the reported duration is a nominal value.";function ur(n,s){return{...n,durationIgnored:!0,...s.gestureOptions?.durationExplicit?{warnings:[cr]}:{}}}class je{xctest;options;enabled;constructor(n,s){this.xctest=n;this.options=s;this.enabled=s.enabled??(()=>N.isIosSdkObservationBridgeEnabled())}async executeSwipeGesture(n){let s=Math.max(0,Math.round(n.gestureOptions?.duration??300)),a=this.enabled()&&n.sdkObservation?ar(n,n.sdkObservation,s):null;if(!a)return this.xctest.executeSwipeGesture(n);let c=a==="unsupported"?{backend:"xctest",fallbackReason:"unsupported"}:await this.dispatch(a,s,n);if(c.backend==="sdk"){let{x1:u,y1:d,x2:p,y2:m}=n,h={success:!0,x1:u,y1:d,x2:p,y2:m,duration:s,backend:"sdk"};return a!=="unsupported"&&a.verb==="scroll"?ur(h,n):h}return{...await this.xctest.executeSwipeGesture(n),backend:"xctest",fallbackReason:c.fallbackReason}}async dispatch(n,s,a){a.gestureOptions?.displayFence?.assertCurrent();let c=a.signal,l=this.options.client();if(!l)return{backend:"xctest",fallbackReason:"unavailable"};let u=await l.requestSdkActionForIos(n.action,{timeoutMs:or(s),signal:c});return gC(u,n.verb)}}function Qe(n,s){return new je(s,{client:()=>x.getExistingInstance(n.deviceId)})}var Je="AutoMobile could not determine the current VoiceOver state; used the default gesture. VoiceOver may be enabled.";class Ze{device;executeGesture;iosClient;iosVoiceOverDetector;timer;featureFlags;constructor({device:n,executeGesture:s,iosClient:a,iosVoiceOverDetector:c,timer:l,featureFlags:u}){this.device=n,this.executeGesture=s,this.iosClient=a,this.iosVoiceOverDetector=c,this.timer=l,this.featureFlags=u}async executeSwipeGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,perf:u=new U,boomerang:d,signal:p}){if(o(p),this.device.platform!=="ios"){if(d)return this.executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:d,perf:u,signal:p});return this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},l,{perf:u,signal:p})}let m=await this.iosVoiceOverDetector.resolveState(this.device.deviceId,this.iosClient,{featureFlags:this.featureFlags});if(o(p),m!==!0){let h=m===null?Je:void 0,f=d?await this.executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:d,perf:u,signal:p}):await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},l,{perf:u,signal:p});return du(f,h)}if(d)return this.voiceOverScrollFailure({x1:n,y1:s,x2:a,y2:c},l?.duration??300,"VoiceOver boomerang gestures are not supported because they require XCTest-synthesized touches, which do not reach VoiceOver");return this.voiceOverScrollFailure({x1:n,y1:s,x2:a,y2:c},l?.duration??300,"VoiceOver scrolling is not supported: CtrlProxy only provides XCTest-synthesized touches, which do not reach VoiceOver")}async executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:u,perf:d=new U,signal:p}){let m=l?.duration??300,h=$h({boomerang:!0,apexPause:u.apexPauseMs,returnSpeed:u.returnSpeed},m);if(h)throw new t(h);let f=M({forwardDuration:m,returnSpeed:u.returnSpeed}),w=m+u.apexPauseMs+f,y=this.buildGestureOptions(l,m),b=this.buildGestureOptions(l,f),S=await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},y,{perf:d,signal:p});if(!S.success)return o(p),S;let v=await OC({timer:this.timer,apexPauseMs:u.apexPauseMs,signal:p,returnSwipe:()=>this.executeGesture.swipe({x1:a,y1:c,x2:n,y2:s},b,{perf:d,signal:p})});if(!v.success)return{...v,x1:n,y1:s,x2:a,y2:c,duration:w};return{...S,x1:n,y1:s,x2:a,y2:c,duration:w}}voiceOverScrollFailure(n,s,a){let{x1:c,y1:l,x2:u,y2:d}=n;return{success:!1,error:a,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:"XCTest-synthesized touches do not reach VoiceOver; no gesture fallback is available"}}buildGestureOptions(n,s){return{...n??{},duration:s}}}function et(n){if(n.device.platform==="watchos")return{executeSwipeGesture:async()=>cu("VoiceOver swipe")};return Qe(n.device,new Ze({...n,iosClient:x.getInstance(n.device)}))}function tt(n){let s=n.error??"iOS lock-screen swipe failed";return n.outcomeIndeterminate===!0?new Y(s):new t(s)}function De(n){return n.success||n.outcomeIndeterminate===!0}var dr=150,pr=250;class Re{request;deps;host;perf;observe;observationFence;lastObservation;containerElement;lookForOptions;maxTime=0;maxSwipes=0;startTime=0;foundElement=null;scrollIteration=0;lastFingerprint="";unchangedScrollCount=0;maxUnchangedScrolls=2;reachedEnd=!1;movedSwipes=0;scopeDescription="";target="";accessibilityWarnings=new Set;isTalkBackEnabled=!1;searchDragState={};overlapRecoveryUsed=!1;interruptedDisplay;swipeWarning;lastAndroidSwipeError;reverseMode=!1;reverseDirection;reverseOptions;fallbackLogged=!1;webScroll;onSearchFallback=()=>{if(!this.fallbackLogged)e.debug("[SwipeOn] lookFor using slow ADB swipe fallback (600ms, at most 75% viewport)"),this.fallbackLogged=!0};constructor(n,s,a,c){this.request=n;this.deps=s;this.host=a;this.perf=c;this.observe=n.strategy?.observe??((l)=>s.observeScreen.execute({freshness:l?.freshness??"cached-ok",timeoutMs:l?.timeoutMs,skipScreenshot:!0,skipAccessibilityAudit:!0,signal:n.signal}))}async execute(){if(await this.initialize(),await this.initialSearch(),this.foundElement)return this.initialSuccess();if(await this.scrollWebElementIntoView(),this.foundElement)return this.initialSuccess();this.initializeLoop();while(this.deps.timer.now()-this.startTime<this.maxTime&&this.scrollIteration<this.maxSwipes&&!this.reachedEnd){let n=this.createStep(),s=await this.dispatchStep(n);if(s.kind==="interrupted")break;if(s.kind==="failed")return s.result;await this.settleAndSearch();let a=this.lastObservation,c=this.host.computeHierarchyFingerprint(a.viewHierarchy),l=this.foundElement?!1:await this.recoverAndSearch(n,s.failedAndroidSwipe),u=this.foundElement?this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy):await this.recheckStaleObservation(l);if(this.recordForwardMovement({observation:a,fingerprint:c},u,l,s.failedAndroidSwipe),this.foundElement)break;await this.finishIteration({recoveryAttempted:l,currentFingerprint:u,failedAndroidSwipe:s.failedAndroidSwipe,chromeStartWarning:n.chromeStartWarning})}return this.finish()}async initialize(){if(o(this.request.signal),e.info(`[SwipeOn] Starting scroll-until-visible: direction=${this.request.options.direction}, lookFor=${JSON.stringify(this.request.options.lookFor)}`),this.observationFence=this.request.strategy?void 0:this.deps.captureDisplayFence?.(),this.lastObservation=await this.perf.track("initialObserve",async()=>k(await this.observe(),(n)=>this.observe({freshness:"fresh",timeoutMs:n}),this.deps.timer,this.request.signal)),o(this.request.signal),!this.lastObservation.viewHierarchy||!this.lastObservation.screenSize)throw Error("Failed to get initial observation for scrolling until visible.");if(this.containerElement=await this.perf.track("findContainer",async()=>this.host.findScrollableContainer(this.request.options,this.lastObservation,this.request.strategy?await this.host.screenBoundsContainer({observation:this.lastObservation,includeSystemInsets:this.request.options.includeSystemInsets}):void 0)),e.info(`[SwipeOn] Using container: bounds=${JSON.stringify(this.containerElement.bounds)}, scrollable=${this.containerElement.scrollable}`),this.lookForOptions=this.host.resolveLookForOptions(this.request.options,this.containerElement,this.lastObservation),this.maxTime=this.request.options.lookFor.maxTime??15000,this.maxSwipes=this.request.options.lookFor.maxSwipes??Number.POSITIVE_INFINITY,this.startTime=this.deps.timer.now(),this.foundElement=null,this.scrollIteration=0,this.lastFingerprint=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy),this.unchangedScrollCount=0,this.maxUnchangedScrolls=this.request.options.lookFor.maxUnchangedSwipes??2,!Number.isInteger(this.maxUnchangedScrolls)||this.maxUnchangedScrolls<1)throw new t("lookFor.maxUnchangedSwipes must be a positive integer");this.scopeDescription=Ge(this.request.options),this.target=this.request.options.lookFor.text?`text "${this.request.options.lookFor.text}"`:`element with id "${this.request.options.lookFor.elementId}"`,e.info(`[SwipeOn] Looking for ${this.target} with maxTime=${this.maxTime}ms`),this.accessibilityWarnings=new Set,this.isTalkBackEnabled=await this.perf.track("checkTalkBack",async()=>{if(o(this.request.signal),this.request.strategy||this.deps.device.platform!=="android")return!1;let n=await this.deps.accessibilityDetector.resolveTalkBackState(this.deps.device.deviceId,this.deps.adb,this.deps.featureFlags);if(n===null)this.accessibilityWarnings.add(Ca);return n===!0})}recordForwardMovement(n,s,a,c){if(a)this.recordMovedSwipe(n.fingerprint,c,n.observation);else this.recordMovedSwipe(s,c,this.lastObservation)}recordMovedSwipe(n,s,a){if(!s&&a.freshness?.isFresh!==!1&&n&&this.lastFingerprint&&n!==this.lastFingerprint)this.movedSwipes++}async initialSearch(){if(this.foundElement=await this.perf.track("initialSearch",()=>this.host.findElementInHierarchy(this.request.options.lookFor,this.lastObservation.viewHierarchy,{container:this.request.options.container,containerElement:this.containerElement,layer:this.request.options.layer})),this.foundElement&&!this.host.isElementWithinContainer(this.foundElement,this.containerElement.bounds,this.lastObservation))e.info(`[SwipeOn] Found ${this.target} initially but it is outside container bounds (element center y=${Math.floor((this.foundElement.bounds.top+this.foundElement.bounds.bottom)/2)}, container=${JSON.stringify(this.containerElement.bounds)}), will scroll`),this.foundElement=null}async scrollWebElementIntoView(){let n=this.deps.webScrollIntoView;if(!n||!this.webScrollApplies())return;let s=await n.scroll(this.request.options.lookFor,this.lastObservation,this.request.signal);if(!s)return;if(s.backend==="xctest"){this.webScroll=s;return}await this.deps.timer.sleep(pr),o(this.request.signal);let a=ee(this.deps.timer);if(a<=0)return;try{this.lastObservation=await this.observe({freshness:"fresh",timeoutMs:a})}catch(c){if(o(this.request.signal),c instanceof Error&&c.name==="AbortError")throw c;e.warn(`[SwipeOn] Read after the page scrolled failed: ${r(c)}`,c);return}if(o(this.request.signal),await this.initialSearch(),this.foundElement)this.webScroll=s;else this.lastFingerprint=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy)}webScrollApplies(){let{container:n,layer:s,lookFor:a}=this.request.options;return!this.request.strategy&&this.deps.device.platform==="ios"&&n===void 0&&s===void 0&&!L(a)}webScrollFields(){if(!this.webScroll)return{};return this.webScroll.backend==="xctest"?{backend:"xctest",fallbackReason:this.webScroll.fallbackReason}:{backend:"sdk"}}async initialSuccess(){if(!this.foundElement)throw Error("Initial search did not find an element");if(e.info(`[SwipeOn] Element already visible at bounds=${JSON.stringify(this.foundElement.bounds)}, no scrolling needed`),this.isTalkBackEnabled&&this.request.options.focusTarget)o(this.request.signal),await this.host.setAccessibilityFocusOnElement(this.foundElement,this.perf);return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!0,targetType:"element",element:this.foundElement,found:!0,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{},scrollIterations:0,movedSwipes:0,elapsedMs:this.deps.timer.now()-this.startTime,...this.webScrollFields(),x1:0,y1:0,x2:0,y2:0,duration:0,observation:this.lastObservation}}initializeLoop(){this.searchDragState={},this.overlapRecoveryUsed=!1,this.reverseMode=!1,this.reverseDirection=fC(this.request.options.direction),this.reverseOptions={...this.lookForOptions,speed:"slow"}}createStep(){o(this.request.signal),this.scrollIteration++,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: elapsed=${this.deps.timer.now()-this.startTime}ms, reverseMode=${this.reverseMode}, unchangedScrollCount=${this.unchangedScrollCount}/${this.maxUnchangedScrolls}`);let n=this.host.resolveContainerSwipeCoordinates(this.request.options,this.lastObservation.viewHierarchy,this.containerElement,this.lastObservation);this.swipeWarning=n.warning??this.swipeWarning;let s=this.host.resolveReverseBounds(this.request.options,this.containerElement,this.lastObservation),a=oe(this.lastObservation,this.containerElement),c=this.reverseMode?this.host.computeHalfScreenReverseCoords(this.reverseDirection,s):this.deps.device.platform==="android"&&this.request.strategy?ne(n,s):n,l=this.reverseMode?this.reverseDirection:this.request.options.direction,u=this.deps.getDuration(this.reverseMode?this.reverseOptions:this.request.strategy&&this.deps.device.platform==="android"?{...this.lookForOptions,duration:void 0,speed:"slow"}:this.lookForOptions),{startX:d,startY:p,endX:m,endY:h}=c,f=uO({observation:this.lastObservation,platform:te(this.deps.device.platform,"swipeOn"),startX:Math.floor(d),startY:Math.floor(p)});return e.info(`[SwipeOn] Swipe: direction=${l}, coords=(${Math.floor(d)},${Math.floor(p)})\u2192(${Math.floor(m)},${Math.floor(h)}), duration=${u}ms`),{previousKeys:a,chromeStartWarning:f,dispatch:{coordinates:c,direction:l,duration:u,options:this.request.options,containerElement:this.containerElement,observation:this.lastObservation,observationFence:this.observationFence,strategy:this.request.strategy,scrollIteration:this.scrollIteration,perf:this.perf,progress:this.request.progress,signal:this.request.signal,onSearchFallback:this.onSearchFallback,searchDragState:this.searchDragState,swipes:this.request.swipes}}}async dispatchStep(n){this.searchDragState.pagingStep=!1;let s=await this.host.dispatchSearchSwipe(n.dispatch);o(this.request.signal);for(let l of s.warnings??[])this.accessibilityWarnings.add(l);if(s.observation?.viewHierarchy)this.lastObservation=s.observation;if(s.staleDisplay&&!s.outcomeIndeterminate)return this.interruptedDisplay=s.staleDisplay,this.foundElement=await this.host.matchInterruptedDisplaySearch(this.request.options,this.lastObservation,this.containerElement,this.interruptedDisplay),{kind:"interrupted"};let a=await this.validateIosSwipe(s);if(a)return{kind:"failed",result:a};let c=this.validateAndroidSwipe(s);if(!s.observation?.viewHierarchy)throw Error("Lost observation after swipe during scroll until visible.");return{kind:"continue",failedAndroidSwipe:c}}async validateIosSwipe(n){if(!n.success&&n.outcomeIndeterminate&&this.deps.device.platform==="ios")throw this.perf.end(),new t(`${n.error??"iOS scroll swipe outcome is indeterminate."} The scroll may have happened. Observe before retrying.`);if(!n.success&&this.deps.device.platform==="ios")return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{...n,targetType:"screen",found:!1,scrollIterations:this.scrollIteration,elapsedMs:this.deps.timer.now()-this.startTime};return}validateAndroidSwipe(n){let s=this.deps.device.platform==="android"&&!n.success;if(s){let a=n.error??"Android scroll swipe failed";if(n.outcomeIndeterminate)throw this.perf.end(),new t(`${a} The scroll may have happened. Observe before retrying.`);if(this.lastAndroidSwipeError!==void 0||!n.observation?.viewHierarchy)throw this.perf.end(),new t(`Scroll swipe failed: ${a}`);this.lastAndroidSwipeError=a,e.warn(`[SwipeOn] Scroll swipe failed; tolerating one rejection: ${a}`)}else this.lastAndroidSwipeError=void 0;return s}async settleAndSearch(){if(this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy)===this.lastFingerprint)e.warn(`[SwipeOn] iter=${this.scrollIteration} post-swipe fingerprint matches pre-swipe \u2014 `+"observation may be stale (cache hit) or swipe had no visible effect");let s=this.deps.timer.now()-this.startTime,a=Math.min(1500,Math.max(0,this.maxTime-s-300));if(a>100)this.lastObservation=await uC(this.lastObservation,{observe:this.observe,timer:this.deps.timer,maxWaitMs:a,pollIntervalMs:dr,logPrefix:"[SwipeOn]",signal:this.request.signal});this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement)}async recoverAndSearch(n,s){let a=!1;if(this.host.shouldGuardSearchStep({failedAndroidSwipe:s,reverseMode:this.reverseMode,overlapRecoveryUsed:this.overlapRecoveryUsed,searchDragState:this.searchDragState})){let c=await this.host.recoverSearchObservation({previousKeys:n.previousKeys,observe:this.observe,deadline:this.startTime+this.maxTime,dispatch:{...n.dispatch,observation:this.lastObservation},onRecovery:()=>{a=!0,this.overlapRecoveryUsed=!0}});this.lastObservation=c.observation,this.interruptedDisplay=c.staleDisplay}if(a)this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement);return a}async recheckStaleObservation(n){let s=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy);if(!n&&s===this.lastFingerprint&&this.lastObservation.freshness?.isFresh===!1)e.info(`[SwipeOn] Iteration ${this.scrollIteration}: stale unchanged observation; re-observing once before scroll-end decision`),this.lastObservation=await this.observe({freshness:"fresh",timeoutMs:ee(this.deps.timer)}),s=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy),this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement);return s}async finishIteration({recoveryAttempted:n,currentFingerprint:s,failedAndroidSwipe:a,chromeStartWarning:c}){let l=n||s!==this.lastFingerprint;if(e.info(`[SwipeOn] Iteration ${this.scrollIteration}: hierarchy ${l?"changed":"UNCHANGED"} (fingerprint[0:40]="${s.slice(0,40)}")`),this.containerElement=await this.host.findScrollableContainer(this.request.options,this.lastObservation,this.containerElement),!l&&c)throw this.perf.end(),new t(`${c} Cannot determine end of container from this swipe. Retry without includeSystemInsets.`);if(!a&&!l&&this.lastObservation.freshness?.isFresh!==!1&&!!s&&!!this.lastFingerprint){if(this.unchangedScrollCount++,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: unchanged count now ${this.unchangedScrollCount}/${this.maxUnchangedScrolls}`),this.unchangedScrollCount>=this.maxUnchangedScrolls)this.onDirectionExhausted()}else this.unchangedScrollCount=0;this.lastFingerprint=s,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: ${this.target} not yet found`)}onDirectionExhausted(){if(this.reverseMode){this.reachedEnd=!0;return}this.reverseMode=!0,this.unchangedScrollCount=0,e.info(`[SwipeOn] Reached end in forward direction without finding ${this.target}, switching to reverse half-screen recovery`)}async finish(){if(!this.foundElement){o(this.request.signal),this.perf.end();let n=this.deps.timer.now()-this.startTime;if(this.lastAndroidSwipeError!==void 0)throw new t(`Scroll swipe failed: ${this.lastAndroidSwipeError}`);if(this.reachedEnd){let s=`Scroll reached end of container in both directions (${this.request.options.direction} and ${this.reverseDirection}; no change after ${this.maxUnchangedScrolls} consecutive swipes each way). ${this.target} not found${this.scopeDescription}. ${this.movedSwipes} swipes moved the screen.`;return e.info(`[SwipeOn] ${s}`),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!1,error:s,targetType:"screen",found:!1,reachedEnd:!0,movedSwipes:this.movedSwipes,scrollIterations:this.scrollIteration,elapsedMs:n,observation:this.lastObservation,x1:0,y1:0,x2:0,y2:0,duration:0,warning:this.swipeWarning,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{}}}throw new t(`${this.target} not found${this.scopeDescription} after scrolling for ${n}ms (${this.scrollIteration} iterations, timeout=${this.maxTime}ms).`)}if(this.isTalkBackEnabled&&this.request.options.focusTarget)o(this.request.signal),await this.host.setAccessibilityFocusOnElement(this.foundElement,this.perf);return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!0,targetType:"element",element:this.foundElement,found:!0,scrollIterations:this.scrollIteration,movedSwipes:this.movedSwipes,elapsedMs:this.deps.timer.now()-this.startTime,...this.webScrollFields(),observation:this.lastObservation,x1:0,y1:0,x2:0,y2:0,duration:0,warning:this.swipeWarning,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{},...this.interruptedDisplay?{staleDisplay:this.interruptedDisplay}:{}}}}function rt(n,s){if(n===s)return[n];let a=Array.isArray(n.node)?n.node:n.node?[n.node]:[];for(let c of a){let l=rt(c,s);if(l)return[n,...l]}return}function it({hierarchy:n,element:s,direction:a,parser:c,scrollsInDirection:l}){let u=nt(s);if(!u||l(s,a))return s;let d=[...c.extractRootNodes(n),...c.extractWindowRootNodes(n,"topmost-first")];for(let p of d){let m=rt(p,u);if(!m)continue;for(let h of m.slice(0,-1).reverse()){let f=c.parseNodeBounds(h);if(f&&l(f,a))return f}return s}return s}var mr=48,ot=240,st=120;function hr({direction:n,bounds:s,screen:a}){let c=n==="up"||n==="down",l=c?s.bottom-s.top:s.right-s.left;if(l>=mr)return;let u=Math.floor((s.left+s.right)/2),d=Math.floor((s.top+s.bottom)/2),p=n==="up"||n==="left"?-ot:ot,m=qs(a),h=Math.floor(Math.max(m.left,Math.min(m.right,u+(c?0:p)))),f=Math.floor(Math.max(m.top,Math.min(m.bottom,d+(c?p:0)))),w=c?Math.abs(f-d):Math.abs(h-u),y=`Container is only ${l} pt along the swipe axis, so the swipe starts at its centre and travels ${w} pt in the swipe direction, like dragging a sheet grabber.`;return{startX:u,startY:d,endX:h,endY:f,warning:w<st?`${y} Screen bounds leave less than ${st} pt of travel; the drag may be too short.`:y}}function ce({geometry:n,overlayDetector:s,options:a,viewHierarchy:c,containerElement:l,observeResult:u,platform:d}){let p={observation:u,platform:d,includeSystemInsets:a.includeSystemInsets},m=Xk({...p,bounds:l.bounds}),h=(S)=>{let v=uO({...p,...S});return v?{...S,warning:[S.warning,v].filter(Boolean).join(" ")}:S};if((d??qr(u.viewHierarchy)?.platform)==="ios"){let S=hr({direction:a.direction,bounds:m,screen:Mu(p)??u.screenSize});if(S)return h(S)}let f=n.getSwipeWithinBounds(a.direction,m),w=s.collectOverlayCandidates(c,l);if(w.length===0)return h(f);let y=w.map((S)=>S.overlapBounds),b=s.computeSafeSwipeCoordinates(a.direction,m,y);if(!b)return h({...f,warning:"No unobstructed swipe area found; using container bounds."});return h(b)}var Sr=150,wr=10,br=1000;function yr(n,s){return s?n.filter((a)=>!xd(a.properties["visible-to-user"])):void 0}class ue{deps;static MAX_ATTEMPTS=5;searchable=new ve;parser=new K;autoTarget=new q;resolver;constructor(n){this.deps=n;this.resolver=n.resolver??new lr}swipePlatform(){return te(this.deps.device.platform,"swipeOn")}resolveSwipeTarget(n,s,a){return it({hierarchy:n,element:s,direction:a,parser:this.parser,scrollsInDirection:(c,l)=>this.autoTarget.scrollsInDirection(c,l)})}resolveNamedSwipeContainer(n,s){let a=this.resolveElement(n,s.container);return a&&this.resolveSwipeTarget(n,a,s.direction)}resolveElement(n,s,a="inspect",c=!1){let l=this.resolver.resolve({id:String(n.updatedAt??"swipe"),nodes:this.searchable.project(n)},s,{action:a});if(bd(l.error))return null;if(l.error)throw new t(l.error,{containerFailure:l.containerFailure});return c?ba(l,s)?.element??null:l.chosen?.element??null}resolveSwipeContainer(n,s){let a=this.resolver.resolve({id:String(n.updatedAt??"swipe"),nodes:this.searchable.project(n)},{container:s},{action:"inspect"});if(a.error)throw new t(a.error,{containerFailure:a.containerFailure});let c=a.scope?.element;if(!c)throw new t(`Container level 1 not found: ${s.elementId??s.text}`,{containerFailure:{level:1,reason:"not-found",selector:s}});return c}async execute(n,s,a,c){let{progress:l,perf:u=new U,signal:d}=Kte(s,a,c);return this.executeWithStrategy({options:n,progress:l,perf:u,signal:d})}async executeWithStrategy(n){let s={dispatched:0},a;try{let c=await Z(()=>new Re({...n,swipes:s},this.deps,{findScrollableContainer:(...l)=>this.findScrollableContainer(...l),screenBoundsContainer:(...l)=>this.screenBoundsContainer(...l),resolveLookForOptions:(...l)=>this.resolveLookForOptions(...l),computeHierarchyFingerprint:(...l)=>this.computeHierarchyFingerprint(...l),findElementInHierarchy:(...l)=>this.findElementInHierarchy(...l),isElementWithinContainer:(...l)=>this.isElementWithinContainer(...l),setAccessibilityFocusOnElement:(...l)=>this.setAccessibilityFocusOnElement(...l),resolveContainerSwipeCoordinates:(...l)=>this.resolveContainerSwipeCoordinates(...l),resolveReverseBounds:(...l)=>this.resolveReverseBounds(...l),computeHalfScreenReverseCoords:I5,dispatchSearchSwipe:(l)=>this.dispatchSearchSwipe(l,(u)=>{a=u}),matchInterruptedDisplaySearch:(...l)=>this.matchInterruptedDisplaySearch(...l),findVisibleSearchTarget:(...l)=>this.findVisibleSearchTarget(...l),shouldGuardSearchStep:(...l)=>this.shouldGuardSearchStep(...l),recoverSearchObservation:(...l)=>this.recoverSearchObservation(...l)},n.perf??new U).execute());return a?{...c,warning:vL(c.warning,a)}:c}catch(c){throw He(c,n.signal,s)}}resolveLookForOptions(n,s,a){let c=s.bounds.bottom-s.bounds.top,l=a.screenSize.height,u=c/l*100,d=n.speed;if(u>=80){if(!d||d==="fast")d="normal",e.info(`[SwipeOn] Container is ${u.toFixed(1)}% of screen height, limiting lookFor speed to "normal"`)}else if(!d||d==="normal"||d==="fast")d="slow",e.info(`[SwipeOn] Container is ${u.toFixed(1)}% of screen height, limiting lookFor speed to "slow"`);return{...n,speed:d}}shouldGuardSearchStep(n){return this.deps.device.platform==="android"&&!n.failedAndroidSwipe&&!n.reverseMode&&!n.overlapRecoveryUsed&&!n.searchDragState.pagingStep}async findVisibleSearchTarget(n,s,a){let c=await this.findScrollableContainer(n,s,a),l=await this.findElementInHierarchy(n.lookFor,s.viewHierarchy,{container:n.container,containerElement:c,layer:n.layer});return l&&this.isElementWithinContainer(l,c.bounds,s)?l:null}async recoverSearchObservation({previousKeys:n,dispatch:s,observe:a,deadline:c,onRecovery:l}){let{options:u,containerElement:d}=s,p;return{observation:await Ve({previousKeys:n,observation:s.observation,timer:this.deps.timer,deadline:c,signal:s.signal,hasTarget:async(h)=>Boolean(await this.findVisibleSearchTarget(u,h,d)),keys:async(h)=>oe(h,await this.findScrollableContainer(u,h,d)),backScroll:async(h)=>{l();let f=await this.performOverlapBackScroll({...s,observation:h},a,c);return p=f.staleDisplay,f.observation}}),staleDisplay:p}}async performOverlapBackScroll(n,s,a){let{options:c,observation:l,signal:u}=n,d=await this.findScrollableContainer(c,l,n.containerElement),p=fC(n.direction),m=await this.dispatchSearchSwipe({...n,coordinates:I5(p,this.resolveReverseBounds(c,d,l)),direction:p,duration:this.deps.getDuration({...c,speed:"slow"}),containerElement:d});if(o(u),m.outcomeIndeterminate)throw new t(m.error??"Recovery scroll outcome is indeterminate");if(m.staleDisplay)return await this.matchInterruptedDisplaySearch(c,m.observation,d,m.staleDisplay),{observation:m.observation,staleDisplay:m.staleDisplay};if(!m.success||!m.observation?.viewHierarchy)return e.debug("[SwipeOn] Overlap recovery unavailable; continuing forward",m.error),{observation:l};if(await this.findVisibleSearchTarget(c,m.observation,d))return{observation:m.observation};return{observation:await uC(m.observation,{observe:s,timer:this.deps.timer,maxWaitMs:Math.min(1500,Math.max(0,a-this.deps.timer.now())),pollIntervalMs:Sr,logPrefix:"[SwipeOn] overshoot",signal:u})}}async dispatchSearchSwipe(n,s=()=>{}){if(this.swipePlatform()==="android"){let a=await l3(n.observation,this.deps.androidXr);a&&s(a)}return this.dispatchPoseCheckedSearchSwipe(n)}async dispatchPoseCheckedSearchSwipe({coordinates:n,direction:s,duration:a,options:c,containerElement:l,observation:u,observationFence:d,strategy:p,scrollIteration:m,perf:h,progress:f,signal:w,onSearchFallback:y,searchDragState:b,swipes:S}){let{startX:v,startY:O,endX:R,endY:g}=n;TR(u.viewHierarchy,c.layer,[{x:Math.floor(v),y:Math.floor(O)}],"swipe");let D=a,A=s,I=u,de=this.deps.resolveBoomerangConfig(c),H={duration:D,scrollMode:c.scrollMode,searchScroll:this.deps.device.platform==="android",searchScrollBounds:this.resolveReverseBounds(c,l,u),onSearchFallback:y,searchDragState:b},F;if(p)o(w);let _=!1,z=()=>{if(!_)_=!0,S.dispatched++};return p?await p.swipe({x1:Math.floor(v),y1:Math.floor(O),x2:Math.floor(R),y2:Math.floor(g),duration:D,holdDurationMs:this.deps.device.platform==="android"?ie:void 0,onSearchFallback:y,searchDragState:b,previousObservation:I,onDispatched:z}):await this.deps.observedInteraction(async(Rr,wt)=>{H.displayFence={assertCurrent:()=>{d?.assertCurrent(),wt?.assertCurrent()}},o(w),S.dispatched++;let Ae=this.deps.device.platform==="ios"?this.deps.voiceOverExecutor:this.deps.talkBackExecutor;if(!Ae)throw Error("VoiceOver swipe runner is not configured for iOS scroll-until-visible");let pe=await Ae.executeSwipeGesture({observation:I,x1:Math.floor(v),y1:Math.floor(O),x2:Math.floor(R),y2:Math.floor(g),direction:A,containerElement:l,gestureOptions:H,perf:h,boomerang:de,signal:w});if(this.deps.device.platform==="ios"&&(pe.success||pe.outcomeIndeterminate))F=this.deps.timer.now(),x.getExistingInstance(this.deps.device.deviceId)?.invalidateCache();return pe},{...Kt.selectorResolvedGesture,timeoutMs:At.brief,progress:f,perf:h,signal:w,previousObservation:I,deferPostActionScreenshot:!0,observationTimestampProvider:()=>F,predictionContext:{toolName:"swipeOn",toolArgs:this.deps.buildPredictionArgs(c)}})}async matchInterruptedDisplaySearch(n,s,a,c){let l=await this.findElementInHierarchy(n.lookFor,s.viewHierarchy,{container:n.container,containerElement:a,layer:n.layer});if(l&&this.isElementWithinContainer(l,a.bounds,s))return l;throw new fr(new Ee(c))}async findTargetElement(n,s,a=0,c){o(c);let l=null;if(!n.container)throw new t("Container must be specified for element swipe");if(s=Ri(s,n.layer),!n.container.text&&!n.container.elementId)throw new t("Container must specify either text or elementId");if(C(n.container))return this.resolveSwipeContainer(s,n.container);if(l=this.resolveElement(s,n.container,"inspect",n.container.text!==void 0),!l&&a<ue.MAX_ATTEMPTS){let u=Q({initialDelayMs:wr,maxDelayMs:br}).delayForAttempt(a+1);await this.deps.timer.sleep(u),o(c);let d=await this.refreshContainerHierarchy(n.container,c);if(d)return e.info(`Retrying to find element after ${u}ms delay`),await this.findTargetElement(n,d,a+1,c)}if(!l)if(n.container.text)throw new t(`Element not found with provided text '${n.container.text}'`);else throw new t(`Element not found with provided elementId '${n.container.elementId}'`);return this.resolveSwipeTarget(s,l,n.direction)}async refreshContainerHierarchy(n,s){switch(this.deps.device.platform){case"android":let a={query:n.text||n.elementId||"",containerElementId:void 0};return await this.deps.accessibilityService.getAccessibilityHierarchy(a,{disableAllFiltering:N.isRawElementSearchEnabled()});case"ios":return(await this.deps.observeScreen.execute({freshness:"cached-ok",skipScreenshot:!0,skipAccessibilityAudit:!0,signal:s})).viewHierarchy;default:throw St(this.deps.device.platform,"scroll until visible")}}async findScrollableContainer(n,s,a){let c=await this.deps.androidXr(s),l=null,u=Ri(s.viewHierarchy,n.layer);if(n.container){if(C(n.container))return this.resolveSwipeContainer(u,n.container);if(n.container.elementId||n.container.text)l=this.resolveNamedSwipeContainer(u,n)}if(!l){let d=this.searchable.project(u);if(l=[...this.resolver.resolve({id:String(u.updatedAt??"swipe"),nodes:d,searchedNodes:yr(d,c)},{},{action:"scroll"}).candidates].sort((h,f)=>Number(h.rootGroup!==0)-Number(f.rootGroup!==0)).find((h)=>h.element)?.element??null,l)e.info("[SwipeOn] Found scrollable container automatically")}if(!l)e.info("[SwipeOn] No scrollable container found, using fallback bounds"),l=B(a,c)?a:await this.screenBoundsContainer({observation:s});return l}async screenBoundsContainer({observation:n,includeSystemInsets:s}){let a={observation:n,platform:this.swipePlatform(),includeSystemInsets:s},c=Mu(a)||{width:1080,height:1920},l=qs(c,Jk(a));return{bounds:await iW(n,this.deps.androidXr,l),scrollable:!0}}async findElementInHierarchy(n,s,{container:a,containerElement:c,layer:l}={}){if(!n.text&&!n.elementId)return null;if(s=Ri(s,l),!C(a)&&!L(n))return this.resolveElement(s,{...n,container:a},"inspect",!0);let u=C(a)?c:a?this.resolveElement(s,a):void 0;return $e({lookFor:n,container:C(a)||u?a:void 0,containerElement:u??void 0,resolver:this.resolver,nodes:this.searchable.project(s),id:String(s.updatedAt??"swipe")})}computeHierarchyFingerprint(n){return j(n)}async setAccessibilityFocusOnElement(n,s){try{await s.track("setAccessibilityFocus",async()=>{let a=n["resource-id"];if(!a){e.warn("[SwipeOn] Cannot set accessibility focus: element has no resource-id");return}await this.deps.accessibilityService.requestAction("focus",a,5000,{perf:s}),e.info(`[SwipeOn] Set accessibility focus on element: ${a}`)})}catch(a){e.warn(`[SwipeOn] Failed to set accessibility focus: ${a}`)}}isElementWithinContainer(n,s,a){let c=(n.bounds.top+n.bounds.bottom)/2,l=(n.bounds.left+n.bounds.right)/2,u=c>=s.top&&c<=s.bottom&&l>=s.left&&l<=s.right;return this.deps.device.platform==="ios"?this.isIosElementWithinContainer(n,s,a,u):u}isIosElementWithinContainer(n,s,a,c){let l=a.viewHierarchy,u=Mu({observation:a,platform:"ios"});if(!l||!u)return c;let d=new md().collect(l,"ios"),p=d&&mO(d,n),m=f9(l,{observationScreenSize:a.screenSize});if(!p&&!Object.values(m).some((I)=>I>0))return c;let h=qs(u,a.systemInsets??l.systemInsets),f={left:Math.max(s.left,h.left),top:Math.max(s.top,h.top),right:Math.min(s.right,h.right),bottom:Math.min(s.bottom,h.bottom)},w=lO({bounds:n.bounds,hierarchy:l,screen:u,elements:[n],forTapTarget:!0}).bounds;if(!w)return!1;let y=lO({bounds:f,hierarchy:l,screen:u,elements:[n]}).bounds;if(!y)return!1;let b={left:Math.max(w.left,y.left),top:Math.max(w.top,y.top),right:Math.min(w.right,y.right),bottom:Math.min(w.bottom,y.bottom)},{left:S,top:v,right:O,bottom:R}=b,g=p&&Zk(p,u).bounds,D=this.deps.geometry.getElementCenter({bounds:b});return(g?[eP([S,v,O,R],g),D]:[D]).some((I)=>I!==null&&Number.isInteger(I.x)&&Number.isInteger(I.y)&&this.deps.geometry.isPointInElement({bounds:b},I.x,I.y)&&I.x<O&&I.y<R&&!(g&&I.x>=g[0]&&I.x<g[2]&&I.y>=g[1]&&I.y<g[3]))}resolveReverseBounds(n,s,a){return Xk({observation:a,platform:this.swipePlatform(),includeSystemInsets:n.includeSystemInsets,bounds:s.bounds})}resolveContainerSwipeCoordinates(n,s,a,c){return ce({geometry:this.deps.geometry,overlayDetector:this.deps.overlayDetector,options:n,viewHierarchy:s,containerElement:a,observeResult:c,platform:this.swipePlatform()})}}function Ie(n,s){if(!n)return;let{bundleId:a,navigationRoute:c,navigationTitle:l,presentation:u,modalClass:d}=n.components;if(!c&&!l&&!u&&!d)return;return{kind:`${s}:${n.platform}:${n.source}`,key:JSON.stringify([a,c,l,u,d]),name:l??c??d??u??"",title:l}}function at(n){let s=n.activeWindow;if(!s?.appId||!s.activityName)return;return{kind:"window",key:JSON.stringify([s.appId,s.activityName]),name:s.activityName}}function gr(n){return Ie(AR(n.viewHierarchy,n.screenSize),"hierarchy")}function Or(n){return Ie(OW(n.viewHierarchy),"hierarchy")}function ct(n){return Ie(n.screenIdentity,"reported")}function Er(n,s,a){let c=a==="ios"?[gr,ct,at]:[ct,Or,at];for(let l of c){let u=l(n),d=l(s);if(u&&d&&u.kind===d.kind)return[u,d]}return}function lt(n){return n.trim().replace(/\s+/g," ").toLowerCase()}function xr(n,s){let a=lt(n),c=lt(s);if(!c)return!1;return a===c||a.startsWith(c)&&!/[\p{L}\p{N}]/u.test(a.charAt(c.length))}function Dr(n,s,a){if(!n.viewHierarchy)return;let c=_l(new ve().project(n.viewHierarchy));for(let l of aO(c,s)){let u=[l.displayedLabel,l.label,...l.textFields].find((d)=>typeof d==="string"&&xr(d,a));if(u)return u}return}function ut(n,s,a,c){if(!n||!s)return;let l=Er(n,s,c);if(!l)return;let[u,d]=l;if(u.key===d.key)return u.kind==="window"?void 0:{navigated:!1};let p=`"${u.name}" to "${d.name}"`,m=d.title?Dr(n,a,d.title):void 0;return{navigated:!0,warning:m?`Swipe navigated from ${p} instead of scrolling; the new screen is titled like the element under the start point ("${m}"), so the gesture likely registered as a tap. Observe and go back before retrying.`:`Swipe navigated from ${p} instead of scrolling. If you expected a scroll, observe before retrying.`}}function mt(n){let s=n?.screenIdentity;return s?.platform==="android"&&s.source==="sdk"?s.components.bundleId:void 0}async function ft(n,s,a,c){let{swipeEndedAtMs:l,source:u,reassess:d}=c,p=mt(a);if(n?.navigated!==!1||!u||!p||!s||mt(s)!==p||l===void 0)return n;let m=u.receivedAtMs(p);if(m!==void 0&&m>l)return n;let h=await u.awaitRouteAfter(p,l,300);if(!h)return;if(a)a.screenIdentity=h;return d()}class au extends Oe{skipCallerDisplayFence;stopAfterIosGestureFailure;iosLockScreenSwipe;iosGestureTimeoutMs;lastRenderedObservation;executeGesture;scrollables;geometry;accessibilityService;accessibilityDetector;featureFlags;overlayDetector;autoTargetSelector;autoTargeting;androidDisplay;talkBackExecutor;voiceOverExecutor;scrollUntilVisible;visionConfig;screenshotCapturer;visionAnalyzer;sdkRouteSourceOverride;androidXr;constructor(n,s=null,a={}){super(n,{adb:s,timer:a.timer,displayFence:a});cs(n.platform,"swipeOn"),this.skipCallerDisplayFence=a.skipCallerDisplayFence??!1,this.stopAfterIosGestureFailure=a.stopAfterIosGestureFailure??!1,this.iosLockScreenSwipe=a.iosLockScreenSwipe,this.iosGestureTimeoutMs=a.iosGestureTimeoutMs,this.lastRenderedObservation=a.lastRenderedObservation;let c=this.initializeGestureDependencies(n,s,a),l=a.featureFlags??sr.getInstance();if(this.featureFlags=l,this.visionConfig=a.visionConfig??Am,this.screenshotCapturer=a.screenshotCapturer??new rp(n,this.adbFactory),this.visionAnalyzer=a.visionAnalyzer,this.sdkRouteSourceOverride=a.sdkRouteSource,this.androidXr=fte(()=>this,a.xrDetector),a.observeScreen)this.observeScreen=a.observeScreen;this.overlayDetector=new G(this.geometry,c),this.autoTargetSelector=a.autoTargetSelector??new q,this.autoTargeting=new fe(n,()=>this.autoTargetSelector),this.androidDisplay=new ye(()=>({device:this.device,adb:this.adb,androidXr:this.androidXr,timer:this.timer,observeScreen:this.observeScreen,displayTransitionReader:this.displayTransitionReader,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,featureFlags:this.featureFlags,talkBackExecutor:this.talkBackExecutor,scrollUntilVisible:this.scrollUntilVisible,scrollables:this.scrollables,geometry:this.geometry,lastRenderedObservation:this.lastRenderedObservation,autoTargeting:this.autoTargeting,visual:this,getDuration:(u)=>this.getDuration(u),createErrorResult:(u)=>this.createErrorResult(u),observedSwipeInteraction:(u,d,p)=>this.observedSwipeInteraction(u,d,p),checkPostActionDisplay:(u,d,p)=>this.checkPostActionDisplay(u,d,p),rethrowObservationAbort:(u,d,p)=>this.rethrowObservationAbort(u,d,p),resolveContainerSwipeCoordinates:(u,d,p,m)=>this.resolveContainerSwipeCoordinates(u,d,p,m)})),this.talkBackExecutor=new xe({androidXr:this.androidXr,device:n,executeGesture:this.executeGesture,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,adb:this.adb,timer:this.timer,featureFlags:l}),this.voiceOverExecutor=a.voiceOverExecutor??et({device:n,executeGesture:this.executeGesture,iosVoiceOverDetector:a.iosVoiceOverDetector??Ao,timer:this.timer,featureFlags:l}),this.scrollUntilVisible=new ue({device:n,resolver:a.resolver,geometry:this.geometry,observeScreen:this.observeScreen,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,adb:this.adb,androidXr:this.androidXr,featureFlags:l,overlayDetector:this.overlayDetector,talkBackExecutor:this.talkBackExecutor,voiceOverExecutor:this.voiceOverExecutor,webScrollIntoView:ke(n,a.webScrollIntoView),timer:this.timer,getDuration:this.getDuration.bind(this),resolveBoomerangConfig:this.resolveBoomerangConfig.bind(this),buildPredictionArgs:this.buildPredictionArgs.bind(this),observedInteraction:this.observedInteraction.bind(this),captureDisplayFence:()=>this.captureDisplayFence(),captureTerminalObservationScreenshot:this.captureTerminalObservationScreenshot.bind(this)})}initializeGestureDependencies(n,s,a){this.executeGesture=a.executeGesture??new mT(n,s);let c=a.parser??new K;return this.scrollables=a.scrollables??new dC,this.geometry=a.geometry??new ir,this.accessibilityService=a.accessibilityService??Ws(n,this.adbFactory),this.accessibilityDetector=a.accessibilityDetector||ni,c}createErrorResult(n,s={}){return{success:!1,error:n,warning:s.warning,scrollableCandidates:s.scrollableCandidates,targetType:"screen",x1:0,y1:0,x2:0,y2:0,duration:0}}async getScrollableContext(n,s){o(n);let a=await this.observeScreen.getMostRecentCachedObserveResult(),c=V$(this.device.deviceId),l=c!==void 0||Oe.shouldRefetchCachedObservation(a);if(l||!a.viewHierarchy||a.viewHierarchy.hierarchy?.error)o(n),a=await this.observeScreen.execute({...vc,freshness:l?"fresh":"cached-ok",timeoutMs:zi,skipStaleWindowRecovery:!0,signal:n});if(a=await k(a,(m)=>this.observeScreen.execute({...vc,freshness:"fresh",timeoutMs:m,skipStaleWindowRecovery:!0,signal:n}),this.timer,n),!a.viewHierarchy||a.viewHierarchy.hierarchy?.error)return{scrollables:[],candidates:[],observeResult:a};if(xg(a))return{scrollables:[],candidates:[],observeResult:a};if(c!==void 0)W$(this.device.deviceId,c);let u=await this.androidXr(a,n),d=this.scrollables.findScrollableElements(Ri(a.viewHierarchy,s)).filter((m)=>B(m,u)),p=this.autoTargeting.buildScrollableCandidates(d);return{scrollables:d,candidates:p,observeResult:a}}async execute(n,s,a){let{progress:c,signal:l}=Wo(s,a);if(cs(this.device.platform,"swipeOn"),this.device.platform==="watchos")return qee(this.device.deviceId,n,l);let u=await Z(()=>this.executeWithReadScope(n,c,l));return Ke(u,n)}executeExplicitDisplay(n,s={}){return this.androidDisplay.executeExplicitDisplay(n,s)}async executeWithReadScope(n,s,a){o(a);let c=await this.executeExplicitDisplay(n,{progress:s,signal:a});if(c)return c;return this.executeLegacy(n,s,a)}async executeAutoTargetSwipe({options:n,progress:s,perf:a,signal:c}){let l=await this.getScrollableContext(c,n.layer),u=this.autoTargeting.resolveAutoTargetDecision({...l,direction:n.direction,includeSystemInsets:n.includeSystemInsets}),d=u.element&&l.observeResult?await this.executeElementSwipe(n,{progress:s,perf:a,signal:c,selected:{element:u.element,observation:l.observeResult}}):u.container?await this.executeElementSwipe({...n,container:u.container},{progress:s,perf:a,signal:c,selected:l.observeResult?{observation:l.observeResult}:void 0}):await this.executeScreenSwipe(n,s,a,{signal:c,within:u.scrollFrame});return this.autoTargeting.withAutoTargetDecision({result:d,decision:u})}async executeLegacy(n,s,a){let c=J();c.serial("swipeOn");let l=this.validateOptions(n);if(l)return c.end(),this.createErrorResult(l);let u=Yc(n);if(u.error)return c.end(),this.createErrorResult(u.error);let d={...n,direction:u.direction};e.info(`[SwipeOn] execute: direction=${d.direction}, lookFor=${JSON.stringify(d.lookFor)}, container=${JSON.stringify(d.container)}, speed=${d.speed}, autoTarget=${d.autoTarget}`);try{return await au.dispatchLegacySwipe(this,d,s,{perf:c,signal:a})}catch(p){if(c.end(),p instanceof V)throw p;if(lW(a,p),e.warn(`Swipe failed: ${r(p)}`,p),p instanceof Ee||p instanceof fr)return Zt(this.createErrorResult(p.message),p);let m=d.lookFor||d.container?await KF(this.device,au.legacyDebugSearchCriteria(d)):void 0;o(a);let f=`Failed to perform swipeOn: ${r(p)}`,w=au.legacyVisionSearchCriteria(this,d);if(w){o(a);let y=await this.observeScreen.getMostRecentCachedObserveResult(),b={visionConfig:this.visionConfig,visionAnalyzer:this.visionAnalyzer};f=await Tm(this.screenshotCapturer,y?.viewHierarchy??null,w,{...b,baseError:f})}return au.legacyFailureResult({action:this,normalizedOptions:d,perf:c,errorMsg:f,debugContext:m,cause:p})}}static legacyDebugSearchCriteria(n){return{text:n.lookFor?.text,resourceId:n.lookFor?.elementId||n.container?.elementId,container:n.container}}static legacyVisionSearchCriteria(n,s){if(n.visionConfig.enabled&&(s.lookFor||s.container)){let a=null;if(s.lookFor)a={text:s.lookFor.text,resourceId:s.lookFor.elementId,description:"Target element to scroll to"};else if(s.container)a={text:s.container.text,resourceId:s.container.elementId,description:"Container element for swiping"};return a}return null}static legacyFailureResult({action:n,normalizedOptions:s,perf:a,errorMsg:c,debugContext:l,cause:u}){let d=n.device.platform==="ios"?a.getTimings():null;return{success:!1,error:c,...u instanceof Y?{outcomeIndeterminate:!0}:{},...be(u),...d?{timing:d}:{},targetType:s.container?"element":"screen",x1:0,y1:0,x2:0,y2:0,duration:0,...l?{debug:{elementSearch:l}}:{}}}static dispatchLegacySwipe(n,s,a,{perf:c,signal:l}){if(s.lookFor)return e.info("[SwipeOn] Mode: scroll-until-visible"),n.scrollUntilVisible.execute(s,{progress:a,perf:c,signal:l});else if(!s.container){if(s.autoTarget===!1)return e.info("[SwipeOn] Mode: screen swipe (autoTarget disabled)"),n.executeScreenSwipe(s,a,c,{signal:l});return n.executeAutoTargetSwipe({options:s,progress:a,perf:c,signal:l})}else return e.info(`[SwipeOn] Mode: element swipe (explicit container=${JSON.stringify(s.container)})`),n.executeElementSwipe(s,{progress:a,perf:c,signal:l})}validateOptions(n){if(n.container){let s=[n.container.elementId,n.container.text].filter(Boolean).length;if(s===0)return"container must specify exactly one of elementId or text";if(s>1)return"container must specify exactly one of elementId or text"}if(n.lookFor){if([n.lookFor.elementId,n.lookFor.text].filter(Boolean).length!==1)return"lookFor must specify exactly one of elementId or text"}return $h(n,this.getDuration(n))??ae(n)}buildPredictionArgs(n){return{includeSystemInsets:n.includeSystemInsets,container:n.container,autoTarget:n.autoTarget,direction:n.direction,lookFor:n.lookFor,speed:n.speed,boomerang:n.boomerang,apexPause:n.apexPause,returnSpeed:n.returnSpeed,platform:this.device.platform}}async observedSwipeInteraction(n,s,a){let c=null,l,u=this.sdkRouteSource(),d=await this.observedInteraction(async(p,m)=>{c=p;let h=await pte(this.androidXr,n,p,m);return l=u?this.timer.now():void 0,h},{...s,observePartialApplication:!0});if(await this.annotateSwipeNavigation(d,c,l,u),this.device.platform!=="android")return d;if(d.effect=this.deriveInteractionEffect(c,d.observation),a.boomerang)return d;if(d.success&&d.effect?.screenChanged===!1&&d.effect.basis!=="insufficient observation data")d.warning=this.autoTargetSelector.mergeWarnings(d.warning,this.unchangedSwipeWarning(d,c));return d}sdkRouteSource(){if(this.device.platform!=="android")return;return this.sdkRouteSourceOverride??{receivedAtMs:(n)=>this.accessibilityService.getSdkScreenIdentityReceivedAtMs(n),awaitRouteAfter:(n,s,a)=>this.accessibilityService.awaitSdkScreenIdentityAfter(n,s,a)}}async annotateSwipeNavigation(n,s,a,c){if(!n.success)return;let l=()=>ut(s,n.observation,{x:n.x1,y:n.y1},te(this.device.platform,"swipeOn")),u=await ft(l(),s,n.observation,{swipeEndedAtMs:a,source:c,reassess:l});if(!u)return;if(n.navigated=u.navigated,u.warning)e.warn(`[SwipeOn] ${u.warning}`),n.warning=this.autoTargetSelector.mergeWarnings(n.warning,u.warning)}unchangedSwipeWarning(n,s){let a=s?.viewHierarchy?this.scrollables.findScrollableElements(s.viewHierarchy):[],c=n.element&&dt(n.element.scrollable)?[n.element,...a]:a;if(c.some((l)=>this.geometry.isPointInElement(l,n.x1,n.y1)))return"Swipe did not change the screen; the start point was inside the scrollable, which may already be at the end of the scrollable content.";return c.length>0?"Swipe did not change the screen; the start point was outside every scrollable region, so the gesture geometry may have prevented scrolling.":"Swipe did not change the screen; no scrollable region was found in the hierarchy."}async executeScreenSwipe(n,s,a=new U,{signal:c,within:l}={}){e.info(`[SwipeOn] Starting screen swipe: direction=${n.direction}`);let u,d=this.resolveBoomerangConfig(n);return this.observedSwipeInteraction(async(p,m)=>{o(c);let h={observation:p,platform:te(this.device.platform,"swipeOn"),includeSystemInsets:n.includeSystemInsets,includeFloatingBars:!n.fromEdge},f=Mu(h);if(!f)throw new t("Could not determine screen size");let w=await iW(p,this.androidXr,qs(f,Jk(h)),n.fromEdge),y=Wie(w,l,n.fromEdge),{startX:b,startY:S,endX:v,endY:O}=n.fromEdge?Xe(n,n.fromEdge,y):this.geometry.getSwipeWithinBounds(n.direction,y);E5(p.viewHierarchy,n.layer,b,S);let R=this.getDuration(n),g={displayFence:m,duration:R,scrollMode:n.scrollMode,durationExplicit:X(n),timeoutMs:this.iosGestureTimeoutMs?.(),lockScreen:this.iosLockScreenSwipe};if(g.timeoutMs!==void 0&&g.timeoutMs<=0)throw new t("iOS swipe budget exhausted before gesture dispatch");o(c);let D=await a.track("executeScreenSwipe",()=>this.device.platform==="ios"?this.voiceOverExecutor.executeSwipeGesture({x1:Math.floor(b),y1:Math.floor(S),x2:Math.floor(v),y2:Math.floor(O),direction:n.direction,containerElement:null,gestureOptions:g,perf:a,boomerang:d,signal:c,sdkObservation:n.fromEdge?void 0:p}):this.talkBackExecutor.executeSwipeGesture({observation:p,x1:Math.floor(b),y1:Math.floor(S),x2:Math.floor(v),y2:Math.floor(O),direction:n.direction,containerElement:null,gestureOptions:g,perf:a,boomerang:d,signal:c}));if(this.stopAfterIosGestureFailure&&this.device.platform==="ios"&&!D.success)throw tt(D);if(o(c),this.device.platform==="ios"&&De(D))u=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();return a.end(),{...D,targetType:"screen",warning:uO({...h,startX:Math.floor(b),startY:Math.floor(S)})}},{usesObservationForResolution:!1,changeExpected:!1,display:n.display,timeoutMs:At.brief,progress:s,perf:a,signal:c,skipCallerDisplayFence:this.skipCallerDisplayFence,observationTimestampProvider:()=>u,predictionContext:{toolName:"swipeOn",toolArgs:this.buildPredictionArgs(n)}},{boomerang:d})}async executeElementSwipe(n,{progress:s,perf:a=new U,signal:c,selected:l}={}){e.info(`[SwipeOn] Starting element swipe: direction=${n.direction}, container=${JSON.stringify(n.container)}`);let u,d=this.resolveBoomerangConfig(n);return this.observedSwipeInteraction(async(p,m)=>{o(c),p=await k(p,(D)=>this.observeScreen.execute({...vc,freshness:"fresh",timeoutMs:D,skipStaleWindowRecovery:!0,display:n.display,signal:c}),this.timer,c);let h=p.viewHierarchy;if(!h||h.hierarchy.error)throw new t("Unable to get view hierarchy, cannot swipe on element");let f=(l?.observation.viewHierarchy===h?l.element:void 0)??await a.track("findElement",()=>this.scrollUntilVisible.findTargetElement(n,h,0,c));o(c);let{startX:w,startY:y,endX:b,endY:S,warning:v}=this.resolveContainerSwipeCoordinates(n,h,f,p);E5(h,n.layer,w,y);let O=this.getDuration(n),R={displayFence:m,duration:O,scrollMode:n.scrollMode,durationExplicit:X(n)};o(c);let g=await a.track("executeElementSwipe",()=>this.device.platform==="ios"?this.voiceOverExecutor.executeSwipeGesture({x1:Math.floor(w),y1:Math.floor(y),x2:Math.floor(b),y2:Math.floor(S),direction:n.direction,containerElement:f??null,gestureOptions:R,perf:a,boomerang:d,signal:c,sdkObservation:p}):this.talkBackExecutor.executeSwipeGesture({observation:p,x1:Math.floor(w),y1:Math.floor(y),x2:Math.floor(b),y2:Math.floor(S),direction:n.direction,containerElement:f,gestureOptions:R,perf:a,boomerang:d,signal:c}));if(o(c),this.device.platform==="ios"&&De(g))u=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();return a.end(),{...g,targetType:"element",element:f,warning:v}},{previousObservation:l?.observation,resolvesTargetFromRead:!0,queryOptions:l||C(n.container)?void 0:{text:n.container?.text,elementId:n.container?.elementId,containerElementId:void 0},changeExpected:!1,display:n.display,timeoutMs:At.brief,progress:s,perf:a,signal:c,observationTimestampProvider:()=>u,predictionContext:{toolName:"swipeOn",toolArgs:this.buildPredictionArgs(n)}},{boomerang:d})}resolveContainerSwipeCoordinates(n,s,a,c){return ce({geometry:this.geometry,overlayDetector:this.overlayDetector,options:n,viewHierarchy:s,containerElement:a,observeResult:c,platform:te(this.device.platform,"swipeOn")})}getDuration(n){return W({...n,geometry:this.geometry})}resolveBoomerangConfig(n){return T(n)}}export{dC,R5,lC,Nee,pv,Fee,Lee,Bee,$ee,uT,uC,pC,qF,mC,VF,lw,pT,P5,fC,TV,hC,WF,zF,kV,EV,uw,pw,jF,$h,A5,IV,T5,k5,_V,mT,au};
|
|
3
|
-
|
|
4
|
-
//# debugId=59E4B53BA8E8466F64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ju,Hae}from"./chunk-dgrbdpb7.js";import"./chunk-65y8v4td.js";import"./chunk-0jrrsnc9.js";import"./chunk-hrfytkxh.js";import"./chunk-26k317v5.js";import"./chunk-64j0majr.js";import"./chunk-2f9rkmhx.js";import"./chunk-0n6swkwg.js";import"./chunk-00167wan.js";import"./chunk-284ptqa4.js";import"./chunk-e98dqnc9.js";import"./chunk-w7hkv422.js";import"./chunk-7rz9898k.js";import"./chunk-fgb98zjj.js";import"./chunk-3xkpk44w.js";import"./chunk-0qsy1qsx.js";import"./chunk-rvvy1bte.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{ju as DaemonManager,Hae as runDaemonCommand};
|
|
3
|
-
|
|
4
|
-
//# debugId=E18A666FBB800A4864756E2164756E21
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{f,I}from"./chunk-58wzr3mt.js";import{Yn}from"./chunk-yf7ympyz.js";var r=2,O=10,l=900000,_=[f.DEVICE_RECOVERY_ON_LOSS.name,f.DEVICE_RECOVERY_ON_LOSS.legacyName,f.ANDROID_REBOOT_ON_DEATH.name,f.ANDROID_REBOOT_ON_DEATH.legacyName];function i(e,n){for(let t of n)if(e[t]!==void 0)return e[t];return}function b5(e){let n=[],t=i(e,_),c=!1;if(t!==void 0){if(t==="1")c=!0;else if(t!=="0")n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_ON_LOSS value ${JSON.stringify(t)}; using 0.`)}let o=i(e,[f.DEVICE_RECOVERY_MAX_ATTEMPTS.name,f.DEVICE_RECOVERY_MAX_ATTEMPTS.legacyName]),s=r;if(o!==void 0)if(/^[1-9]\d*$/.test(o)){let a=Number(o);if(a<=O)s=a;else n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_MAX_ATTEMPTS value ${JSON.stringify(o)}; using ${r}.`)}else n.push(`Invalid AUTOMOBILE_DEVICE_RECOVERY_MAX_ATTEMPTS value ${JSON.stringify(o)}; using ${r}.`);return{policy:{onLoss:c,maxAttempts:s},warnings:n}}function Pee(){return b5(process.env).policy}function Aee(e=process.env){let n=i(e,[f.DEVICE_RECOVERY_WINDOW_MS.name,f.DEVICE_RECOVERY_WINDOW_MS.legacyName]);if(n!==void 0&&/^[1-9]\d*$/.test(n))return Number(n);return l}function AF(e=process.env){return i(e,_)!=="0"}var E=I(f.DEVICE_POOL_MATCHING),u=["LATEST","RANDOM","MINIMUM"],Lh=E&&u.includes(E)?E:"LATEST";function Tee(e=process.env){return I(f.DEVICE_POOL_AUTOLOCK,e)==="1"}function kee(){return Yn(f.DEVICE_POOL_TIMEOUT.name,f.DEVICE_POOL_TIMEOUT.legacyName,{fallback:60})*1000}
|
|
3
|
-
export{b5,Pee,Aee,AF,Lh,Tee,kee};
|
|
4
|
-
|
|
5
|
-
//# debugId=C392E7D3E891399D64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{OU,Le,qJ,VJ,WJ,kE,YK,EE,IE,JK,xf,zp,oM,sM,Cf,aM,_E,jp,kP,XK,ZK,cM,xE,dM,EP,MU,QK,eG,tG,rG}from"./chunk-11m8wj8j.js";import"./chunk-fgb98zjj.js";import"./chunk-3xkpk44w.js";import"./chunk-0qsy1qsx.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{kP as NotificationShadeNotOpenError,jp as TransientPreSwipeError,MU as captureNotificationDismissBaseline,xf as captureSystemTrayTerminalEvidence,rG as clearIosSystemTrayNotifications,eG as clearMatchingSystemTrayNotifications,oM as ensureSystemTrayClosed,zp as ensureSystemTrayOpen,xE as expandAndRematchIfCollapsed,Le as getSystemTrayDependencies,dM as isSwipeTargetIsolatedFromGroup,XK as listSystemTrayNotifications,ZK as listSystemTrayNotificationsForClear,sM as notificationNotFoundError,JK as observeSystemTrayAfterTap,cM as readActiveNotificationKeysForApp,tG as readClearAllTerminalObservation,VJ as resetSystemTrayDependencies,WJ as resolveAppLabel,OU as resolveNotificationGroupExpansionState,EE as resolveNotificationSwipeElement,YK as resolveNotificationTapElement,IE as resolveSystemTrayAwaitTimeout,kE as resolveUniqueTrayAppLabel,EP as retryTransientPreSwipe,qJ as setSystemTrayDependencies,_E as swipeElement,aM as tapElement,QK as verifyNotificationDismissed,Cf as waitForNotificationMatch};
|
|
3
|
-
|
|
4
|
-
//# debugId=5D69C93FA97431D364756E2164756E21
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$o,FS,Rt,ah,ch}from"./chunk-hrfytkxh.js";import{i,di,e}from"./chunk-z637nqg8.js";import{f}from"./chunk-58wzr3mt.js";import{cB,Uw,xz,ad,Su,bp,iR,Sp,Rg,$s,N,Pi}from"./chunk-r5bxavdx.js";import"./chunk-0n6swkwg.js";import{wI,Lr}from"./chunk-w5b2jwk3.js";import{B,Ht,Fi,ki}from"./chunk-yf7ympyz.js";import"./chunk-5d2hft6c.js";import"./chunk-0qsy1qsx.js";import"./chunk-4hw3665t.js";import"./chunk-3xkpk44w.js";import{eS,$P,QM,cH,F,ZP,Py,Ay,Ty,SI}from"./chunk-h5rpn9wr.js";import"./chunk-84nanf8s.js";import"./chunk-jh6vhqzx.js";import{he}from"./chunk-64j0majr.js";import"./chunk-e98dqnc9.js";import{ZQ}from"./chunk-2f9rkmhx.js";import"./chunk-00167wan.js";import"./chunk-7rz9898k.js";import"./chunk-0jrrsnc9.js";import"./chunk-3f3t1x97.js";import"./chunk-vy3bwm1d.js";import"./chunk-ycaj2sgf.js";import"./chunk-3qwrzxh0.js";import"./chunk-65y8v4td.js";import"./chunk-thbh3jew.js";import{zb,IM}from"./chunk-11m8wj8j.js";import"./chunk-7tw8x05v.js";import"./chunk-zgja5f3p.js";import"./chunk-6awz7vhq.js";import"./chunk-aabchzxk.js";import"./chunk-w3vs79ex.js";import"./chunk-v2wd4n3e.js";import"./chunk-g7tmjbkt.js";import"./chunk-qf6nynk6.js";import"./chunk-bfw6125s.js";import"./chunk-6xmss8er.js";import"./chunk-yb97j25b.js";import"./chunk-dgrbdpb7.js";import"./chunk-ybbtagbt.js";import"./chunk-26k317v5.js";import"./chunk-284ptqa4.js";import"./chunk-w7hkv422.js";import"./chunk-qyqypn28.js";import"./chunk-fgb98zjj.js";import"./chunk-rvvy1bte.js";import"./chunk-v6pya0dm.js";import{r,t}from"./chunk-rbpdk7m0.js";function x(n,o,s={}){let a=$P(n);if(a&&/Unknown tool\b/i.test(o))return a;let l=o.replace(/[.]+$/,""),c=s.buildSkew?" Try: auto-mobile --daemon restart":"";return`Error calling daemon: ${l}.${c}`}function T(){zb(),IM({daemonMode:!0,includeDoctor:!0,includeToolSelection:!1})}function E(n){try{return{parsed:!0,value:JSON.parse(n)}}catch(o){return e.debug(`[cli] value is not JSON, treating as a raw token: ${n} (${o})`),{parsed:!1,value:n}}}function _(n,o){let s=()=>E(n).value;if(o?.nullable&&n==="null")return null;switch(o?.type){case"string":case"enum":return ie(n);case"number":case"bigint":return se(n);case"boolean":if(n==="true")return!0;if(n==="false")return!1;return s();default:return s()}}function ie(n){let{parsed:o,value:s}=E(n);return o&&typeof s==="string"?s:n}function se(n){let{parsed:o,value:s}=E(n);return o&&typeof s==="number"&&Number.isFinite(s)?s:n}var k=new Set(["optional","nullable","default","readonly","catch","branded","lazy"]);function A(n){let o=n?._def?.typeName??n?._def?.type??"unknown";return String(o).replace(/^Zod/,"").toLowerCase()}function L(n){let o=n?._def;return o?.innerType??o?.type??o?.schema??null}function ae(n){let o=n?._def?.options;if(!Array.isArray(o))return!1;let s=o.map((d)=>U(d).type),a=s.some((d)=>d==="number"||d==="bigint"),c=o.filter((d,u)=>s[u]==="string").every((d)=>{let u=d;for(let p=0;p<10&&u;p++){let g=A(u);if(g==="literal")return typeof(u._def?.value??u._def?.values?.[0])==="string";if(!k.has(g))return!1;u=L(u)}return!1});if(a&&c)return!1;return s.includes("string")&&s.every((d)=>["string","number","boolean","bigint"].includes(d))}function U(n){let o=n,s=!1;for(let a=0;a<10&&o;a++){let l=A(o);if(l==="nullable")s=!0;if(l==="literal")return{type:typeof(o._def?.value??o._def?.values?.[0]),nullable:s};if(l==="union"&&ae(o))return{type:"string",nullable:s};if(!k.has(l))return{type:l,nullable:s};o=L(o)}return{type:"unknown",nullable:s}}function C(n){let o=n?._def;if(!o)return[];if(o.shape)return[o.shape];let s=o.options??o.out?._def?.options;if(Array.isArray(s))return s.flatMap((a)=>C(a));return o.out?C(o.out):[]}function M(n){T();let o=F.getRegisteredTool(n);if(!o)return null;let s=C(o.schema);if(s.length===0)return null;let a=new Map;for(let l of s)for(let[c,d]of Object.entries(l)){let u=U(d),p=a.get(c)??{types:new Set,nullable:!1};p.types.add(u.type),p.nullable=p.nullable||u.nullable,a.set(c,p)}return Object.fromEntries([...a.entries()].filter(([,l])=>l.types.size===1).map(([l,c])=>[l,{type:[...c.types][0],nullable:c.nullable}]))}import le from"fs";var ce=65536,ue="CliToolResult";function R(n,o){let s=o.maxBytes??ce,a;try{a=JSON.stringify(n,null,2)}catch(c){return v(o.tool,0,`result is not JSON-serializable: ${r(c)}`)}if(a===void 0)return v(o.tool,0,"tool returned a value with no JSON representation");let l=Buffer.byteLength(a,"utf8");if(l<=s)return a;if(!o.artifactWriter)return v(o.tool,l,"no tool-output directory is available to spill the payload to");try{let c=o.artifactWriter.writeJsonArtifact({tool:o.tool,payload:ue,data:n,serialized:a});return JSON.stringify({truncated:!1,bytes:l,artifact:{...c.artifact,resourceUri:void 0},note:`Tool output was ${l} bytes, over the ${s}-byte CLI inline limit. The complete JSON result is in artifact.path.`},null,2)}catch(c){return e.debug(`[cli] failed to spill oversized tool output: ${r(c)}`),v(o.tool,l,r(c))}}function v(n,o,s){return JSON.stringify({truncated:!0,tool:n,bytes:o,reason:s,recovery:"Re-run with AUTOMOBILE_TOOL_OUTPUTS_DIR set to a writable directory, or narrow the request (for example observe with a scope) so the result fits inline."},null,2)}var H={write:(n)=>W(1,n)},j={write:(n)=>W(2,n)},de={writeSync:(n,o,s,a)=>le.writeSync(n,o,s,a),sleepSync:(n)=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,n)}},fe=1000;function pe(n,o,s){let a=o+1;if(s.sleepSync(1),a>=fe)throw Error(`Zero-progress write to fd ${n} after ${a} attempts; refusing to spin`);return a}function W(n,o,s=de){let a=Buffer.from(o,"utf8"),l=0,c=0;while(l<a.length)try{let d=s.writeSync(n,a,l,a.length-l);if(d===0){c=pe(n,c,s);continue}c=0,l+=d}catch(d){let u=d.code;if(u==="EAGAIN"){s.sleepSync(1);continue}if(u==="EPIPE"){e.debug(`[cli] output stream closed before the write completed (fd ${n})`);return}throw d}}function me(n){if(!n||typeof n!=="object")return;let o=n,s=o.failure;if(s&&typeof s==="object")return s.code;let a=o.error;return o.code??(a&&typeof a==="object"?a.code:void 0)}function y(n){return n&&typeof n==="object"?n:void 0}function ge(n){return y(y(n)?.error)?.reason}function P(n){if(n<60000){let s=Math.round(n/1000*10)/10;return`${s} ${s===1?"second":"seconds"}`}let o=Math.round(n/60000*10)/10;return`${o} ${o===1?"minute":"minutes"}`}function ye(n){let o=y(y(n)?.error)?.idleTimeoutMs;return typeof o==="number"&&Number.isFinite(o)&&o>0?o:void 0}var Se=`(reads do not count), so its session UUID cannot be used again. Acquire a new session with getAndroid, getApple or startDevice. To keep a session across longer gaps, set ${f.CLI_SESSION_IDLE_TIMEOUT_MS.name} (milliseconds, at most ${P(Uw)}) in the environment of every --cli call.`;function be(n){let o=ye(n);return`Hint: this --cli session went longer than ${o===void 0?`its idle timeout (${P(cB)} by default)`:`its idle timeout of ${P(o)} (${o} ms)`} without a control call ${Se}`}function we(n){let o=y(n)?.candidates;if(!Array.isArray(o))return[];return o.flatMap((s)=>{let a=y(s);if(typeof a?.deviceId!=="string")return[];return[typeof a.platform==="string"?`${a.deviceId} (${a.platform})`:a.deviceId]})}function Te(n){let o=we(n);return`Hint: more than one device matches this call. Re-run with --deviceId <id> to pick one, or with --session-uuid <uuid> to use a device your session holds.${o.length>0?` Candidates: ${o.join(", ")}.`:""}`}var ve=new Map([[ad,"Hint: the device's previous session is still finishing its cleanup. Re-run the command after the retryAfterMs in the error has passed; nothing else needs to change."],[bp,"Hint: the device is being shut down. Re-run the command after the retryAfterMs in the error has passed, once the shutdown has finished."],[Sp,"Hint: this session is being released because its device is being shut down, so its session UUID cannot be used again. Retrying with the same --session-uuid will not succeed; acquire the device again under a new session instead."],[Rg,"Hint: the device's session is moving to another device. Re-run the command after the retryAfterMs in the error has passed, once the rebind has settled."],[iR,"Hint: the session no longer holds this device; it was rebound or released. Check who holds the device now with --daemon active-sessions before re-running the command."],[Su,"Hint: another AutoMobile daemon on this host is using the device. Re-run after it releases the device, or pass another deviceId."]]);function J(n,o){let s=me(n);if(s===$o&&ge(n)==="cli-idle-timeout")return be(n);if(s===FS)return Te(n);let a=typeof s==="string"?ve.get(s):void 0;if(a!==void 0)return a;if(s!==xz)return;if(Lr(o))return`Hint: another session holds the device, and ${o} cannot join it: acquisition tools mint their own session and the CLI ignores --session-uuid for them. If that session is yours, skip re-acquiring and pass --session-uuid <uuid> to your follow-up calls; to see who holds the device, run --daemon active-sessions (releasing a session that is not yours can break another agent's work); otherwise wait for the holder to release it.`;return`Hint: a device a session holds takes calls only from that session. Re-run with --session-uuid <uuid>, the sessionUuid that getAndroid, getApple or startDevice returned when the device was acquired, or wait for the holder to release it.${ZQ(o,"force")?" To stop it anyway, pass --force true.":""}`}import m from"fs";import q from"path";var Oe="tool-selection-profile",Ce=3000,Ee=50,_e=B.next(),Pe;function O(n){return q.join(di("cli",n),Oe)}function Ie(n){return`${O(n)}.lock`}async function I(n,o=process.env){let s=De(o,Pe??{});if(!await s.acquire())return!1;try{await n()}finally{s.release()}return!0}function De(n,o){let s=o.timer??i,a=Math.max(1,o.pollIntervalMs??Ee),l=o.timeoutMs??Ce,c=Ie(n),d=o.pid??process.pid,u=o.ownerToken??_e,p=s.now()+l;return{acquire:async()=>{try{for(;;){if(Fi(c,{pid:d,isProcessRunning:o.isProcessRunning,ownerGeneration:o.ownerGeneration??Ht,reclaimOwnPid:!0,ownerToken:u}))return!0;if(s.now()>=p)return!1;await s.sleep(Math.min(a,p-s.now()))}}catch(g){return e.debug(`Unable to acquire CLI tool-selection profile lock: ${r(g)}`),!1}},release:()=>{ki(c,d,u)}}}function h(n=process.env){try{let o=m.readFileSync(O(n),"utf8").trim();if(o.length===0)return;if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o)){e.debug("Ignoring persisted CLI tool-selection profile because the file content is not a valid UUID");return}return o}catch(o){e.debug(`Unable to load the persisted CLI tool-selection profile: ${r(o)}`);return}}function V(n=process.env){let o=O(n),s=q.dirname(o);try{if(m.accessSync(s,m.constants.W_OK),m.existsSync(o)){if(!m.statSync(o).isFile())throw Error("profile path is not a regular file");m.accessSync(o,m.constants.W_OK)}}catch(a){throw new t(`CLI tool-selection profile store is not writable: ${o}. Fix its permissions or set AUTOMOBILE_DATA_DIR/AUTO_MOBILE_DATA_DIR to a writable directory so the CLI can persist a stable tool-selection profile across invocations.`,{cause:a})}}function G(n,o=process.env){let s=n.trim();if(s.length===0)return;let a;try{let l=O(o);if(a=`${l}.${process.pid}.${B.next()}.tmp`,m.writeFileSync(a,s,{encoding:"utf8",mode:384}),process.platform!=="win32")m.chmodSync(a,384);if(m.renameSync(a,l),a=void 0,process.platform!=="win32")m.chmodSync(l,384)}catch(l){if(e.debug(`Unable to persist the CLI tool-selection profile: ${r(l)}`),a)try{m.unlinkSync(a)}catch(c){e.debug(`Unable to remove incomplete CLI tool-selection profile: ${r(c)}`)}}}function xe(n){let o=n/60000;return`${o} ${o===1?"minute":"minutes"}`}function Z(n){if(typeof n==="string"&&n.trim()==="")throw new t("--session-uuid requires a non-empty value")}function ke(n){let o=Pi(n[0]);if(o.flag!=="--session-uuid")return{sessionUuid:void 0,toolNameIndex:0};let s=o.inlineValue!==void 0,a=s?o.inlineValue:n[1],l=s?1:2;if(n.length<=l)throw new t("--session-uuid requires a value and a tool name");return Z(a),{sessionUuid:a,toolNameIndex:l}}function Ae(n){return K(n,M)}function z(n,o){return n&&Object.hasOwn(n,o)?n[o]:void 0}function K(n,o){if(n.length===0)throw new t("No tool name provided. Usage: --cli [--session-uuid <uuid>] <tool-name> [--param value ...]");let{sessionUuid:s,toolNameIndex:a}=ke(n),l=n[a],c=new Map,d=o(l);for(let u=a+1;u<n.length;u++){let p=n[u];if(!p.startsWith("--"))throw new t(`Invalid parameter format: ${p}. Parameters must start with --`);let{flag:g,inlineValue:D}=Pi(p),b=g.slice(2).replace(/-([a-z])/g,(Qe,re)=>re.toUpperCase());if(D!==void 0){c.set(b,_(D,z(d,b)));continue}let w=n[u+1],oe=w!==void 0&&/^---(?:\s|$)/.test(w);if(w===void 0||w.startsWith("--")&&!oe)c.set(b,!0);else u++,c.set(b,_(w,z(d,b)))}return Z(c.get("sessionUuid")),{toolName:l,sessionUuid:s,params:Object.fromEntries(c)}}var Le=(n)=>new SI(n);async function $e(n,o){if(o===Rt)return;if(F.getTool(o)?.hidden)return;let s=h();if(!s){await Me(n,o);return}await Ue(n,o,s)}async function Ue(n,o,s){let a;try{n.setToolSelectionProfileUuid?.(s),a=await n.callTool(Rt,{toolName:o,enabled:!0,sessionUuid:s})}catch(p){e.debug(`CLI pre-enable of ${o} did not apply: ${r(p)}`);return}let l=ah(a);if(!(a?.isError===!0||l===void 0||l!==s))return;if(n.setToolSelectionProfileUuid?.(void 0),e.debug(`CLI tool-selection profile ${s} is stale; re-minting a profile`),await I(async()=>{let p=h();if(p&&p!==s){if(await X(n,o,p))return;n.setToolSelectionProfileUuid?.(void 0)}await Q(n,o)}))return;let u=h();e.debug(`CLI pre-enable of ${o} skipped after a contended profile-lock timeout; ${u?"a profile is now persisted for the next invocation":"the next invocation will retry"}, and the tool call will surface any gate error.`)}async function Me(n,o){if(!await I(async()=>{let a=h();if(a){if(await X(n,o,a))return;n.setToolSelectionProfileUuid?.(void 0)}await Q(n,o)})){let a=h();e.debug(`CLI pre-enable of ${o} skipped after a contended profile-lock timeout; ${a?"a profile is now persisted for the next invocation":"the next invocation will retry"}, and the tool call will surface any gate error.`)}}async function X(n,o,s){try{n.setToolSelectionProfileUuid?.(s);let a=await n.callTool(Rt,{toolName:o,enabled:!0,sessionUuid:s}),l=ah(a);return a?.isError!==!0&&l!==void 0&&l===s}catch(a){return e.debug(`CLI pre-enable of ${o} did not apply: ${r(a)}`),!0}}async function Q(n,o){V();try{let s=await n.callTool(Rt,{toolName:o,enabled:!0}),a=ah(s);G(a??"")}catch(s){e.debug(`CLI pre-enable of ${o} did not apply: ${r(s)}`)}}async function Ne(n,o,s){let a=Le({daemonOptions:s,oneShotCli:!0,lifecycleNamespaceEnv:process.env});try{await $e(a,n);let l=await a.callTool(n,o);if(l===null)throw new t(`Daemon returned null result. This may indicate a daemon connectivity issue. Try: bunx ${$s()} --daemon restart`);return l}catch(l){if(l instanceof Py||l instanceof Ay||l instanceof Ty)throw new t(`Daemon preflight failed; no device operation started. ${l.message}`);if(l instanceof he)throw new t(`Daemon became unavailable during tool execution: ${l.message}. Try: auto-mobile --daemon restart`);if(l instanceof t)throw l;let c=r(l);throw new t(x(n,c,{buildSkew:l instanceof ZP&&l.buildMismatch}))}finally{if(n!=="listDevices")await a.adoptCliSessionLiveness();await a.close()}}function Re(){return`Usage: auto-mobile --cli doctor [options]
|
|
3
|
-
|
|
4
|
-
Status: status-only and read-only diagnostics.
|
|
5
|
-
|
|
6
|
-
Options:
|
|
7
|
-
--android Filter to Android checks
|
|
8
|
-
--ios Filter to iOS checks
|
|
9
|
-
--json Machine-readable JSON output
|
|
10
|
-
--help Print this help
|
|
11
|
-
|
|
12
|
-
The universal --session-uuid option is accepted and ignored.`}function ee(n){if(Object.hasOwn(n,"repair")||Object.hasOwn(n,"timeoutMs"))return"doctor is status-only; --repair and --timeout-ms were removed. Use --daemon restart to recover the daemon; --daemon diagnose only gathers further diagnostics.";let o=["android","ios","json","help","sessionUuid"],s=Object.keys(n).filter((a)=>!o.includes(a)).map((a)=>`--${a.replace(/[A-Z]/g,(l)=>`-${l.toLowerCase()}`)}`);if(s.length>0)return`Unknown doctor flags: ${s.join(", ")}. Supported flags: --android, --ios, --json, --help (the universal --session-uuid option is accepted and ignored).`;return}function Fe(n){let o=ee(n);if(o!==void 0)throw new t(o)}function rn(n){let o;try{o=K(n,()=>null)}catch(s){return e.debug(`CLI bootstrap routing kept the normal path: ${r(s)}`),!1}if(o.toolName!=="doctor")return!1;return ee(o.params)!==void 0||Boolean(o.params.help)}async function Be(n,o={}){if(Fe(n),n.help){(o.writeOutput??console.log)(Re());return}let s=await import("./chunk-23p5f095.js"),a=await(o.runDoctor??s.runDoctor)({android:n.android,ios:n.ios});if(n.json===!0)ne(a,"doctor");else(o.writeOutput??console.log)((o.formatConsoleOutput??s.formatConsoleOutput)(a,process.stdout.isTTY??!0));if(a.summary.failed>0)(o.exit??process.exit)(1);return}function te(n){let o=n;if(n&&typeof n==="object"&&"content"in n&&Array.isArray(n.content)){if(n.content.length>0&&n.content[0].type==="text")try{o=JSON.parse(n.content[0].text)}catch(s){e.debug(`CLI tool result is not JSON: ${r(s)}`),o=n}}return o}function He(n){return n?.isError===!0||te(n)?.success===!1}var je={stdout:H,stderr:j};function We(){try{return new QM({outputDirectory:N.getToolOutputsDir()??ch(),retention:cH})}catch(n){e.debug(`[cli] no tool-output artifact writer available: ${r(n)}`);return}}function ne(n,o){je.stdout.write(R(n,{tool:o,artifactWriter:We()})+`
|
|
13
|
-
`)}function Je(n){if(!n||typeof n!=="object")return n;let{message:o,nextAction:s}=n;if(typeof o!=="string")return n;return typeof s==="string"?`${o}
|
|
14
|
-
Next: ${s}`:o}function qe(n,o){ne(n,o);let s=te(n);if(He(n)){if(s&&typeof s==="object"&&s.error)console.error(Je(s.error));else if(n?.isError===!0&&Array.isArray(n.content)&&n.content[0]?.type==="text")console.error(n.content[0].text);Ve(s,o);let a=J(s,o);if(a)console.error(a);process.exit(1)}}function Ve(n,o){if(o==="executePlan"&&n&&typeof n==="object"&&typeof n.executedSteps==="number"&&typeof n.totalSteps==="number"){if(console.error(`Executed ${n.executedSteps} of ${n.totalSteps} steps`),n.failedStep)console.error(`Failed at step ${n.failedStep.stepIndex+1}: ${n.failedStep.tool}`),console.error(`Step error: ${n.failedStep.error}`)}}async function sn(n,o,s=console){try{if(n.length===0){T(),Y(s);return}if(n[0]==="help"||n[0]==="--help"||n[0]==="-h"){if(T(),n.length>1)Ge(n[1],s);else Y(s);return}let{toolName:a,sessionUuid:l,params:c}=Ae(n);if(l)if(Lr(a))e.debug(`Ignoring session UUID for acquisition tool ${a}: it mints its own`);else c.sessionUuid=l,e.debug(`Using session UUID: ${l}`);if(a==="doctor")return await Be(c);e.debug(`Executing tool via daemon: ${a}`);let d=await Ne(a,c,o);qe(d,a)}catch(a){if(a instanceof t)e.error(`CLI Error: ${a.message}`),console.error(`Error: ${a.message}`);else e.error(`Unexpected CLI Error: ${a}`),console.error(`Unexpected error: ${a}`);process.exit(1)}}function Y(n){let o=F.getAllTools(),s=$s();n.log(`
|
|
15
|
-
AutoMobile CLI - Android Device Automation
|
|
16
|
-
|
|
17
|
-
Usage:
|
|
18
|
-
bunx ${s} --cli [--session-uuid <uuid>] <tool-name> [--param value ...]
|
|
19
|
-
bunx ${s} --cli help [tool-name]
|
|
20
|
-
bunx ${s} --ios-templates build --runtime <identifier> --device-type <identifier>
|
|
21
|
-
bunx ${s} --ios-templates clean (--all | --stale | --runtime <identifier> [--device-type <identifier>]) [--force]
|
|
22
|
-
|
|
23
|
-
Examples:
|
|
24
|
-
bunx ${s} --cli listDeviceImages
|
|
25
|
-
bunx ${s} --cli observe
|
|
26
|
-
bunx ${s} --cli tapOn --selector '{"text":"Submit"}'
|
|
27
|
-
bunx ${s} --cli getAndroid --avd-name "pixel_7_api_34"
|
|
28
|
-
bunx ${s} --cli getApple --udid "SIMULATOR-UDID"
|
|
29
|
-
bunx ${s} --cli --session-uuid abc-123-uuid observe
|
|
30
|
-
bunx ${s} --cli --session-uuid $SESSION_UUID tapOn --selector '{"text":"Submit"}'
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
help [tool-name] Show help for a specific tool
|
|
34
|
-
--session-uuid <uuid> Associate tool execution with a session (optional).
|
|
35
|
-
The CLI omits it for acquisition tools
|
|
36
|
-
(${wI.join(", ")}), which mint
|
|
37
|
-
their own session. For other tools, an undeclared
|
|
38
|
-
sessionUuid is removed before strict validation.
|
|
39
|
-
|
|
40
|
-
Parameters:
|
|
41
|
-
Parameters are passed as --key value pairs
|
|
42
|
-
Values are converted using the tool's declared parameter type
|
|
43
|
-
Strings: --text 12345 stays the string "12345"
|
|
44
|
-
Boolean values: --flag true or --flag false
|
|
45
|
-
Numbers: --count 5
|
|
46
|
-
Objects: --options '{"key": "value"}'
|
|
47
|
-
Unknown tools or parameters fall back to JSON-if-possible, otherwise string
|
|
48
|
-
|
|
49
|
-
Session-based Execution:
|
|
50
|
-
When using --session-uuid, the tool will be executed on the device assigned to that session.
|
|
51
|
-
This allows multiple tool calls to target the same device in parallel.
|
|
52
|
-
A session acquired or used from the CLI is held on a wall-clock idle timeout
|
|
53
|
-
(${xe(cB)} by default; override with
|
|
54
|
-
AUTOMOBILE_CLI_SESSION_IDLE_TIMEOUT_MS) rather than the
|
|
55
|
-
heartbeat contract a long-running MCP connection keeps, so it survives the gap
|
|
56
|
-
between one-shot invocations. Every control call refreshes it; reads do not.
|
|
57
|
-
|
|
58
|
-
Device ownership:
|
|
59
|
-
A device a session holds takes control calls only from that session. A control
|
|
60
|
-
call without --session-uuid (or with another session's) on a held device is
|
|
61
|
-
refused with code device_owned_by_other_session. Pass the sessionUuid that
|
|
62
|
-
getAndroid, getApple or startDevice returned, or wait for the holder to release
|
|
63
|
-
the device. Reads need no session and are allowed on any device: observe, hitTest,
|
|
64
|
-
identifyInteractions, listApps, getDeviceState, a read-only sqlQuery, and the read
|
|
65
|
-
forms of keyboard, clipboard, displayConfig, accessibility and prototype. A read
|
|
66
|
-
never counts as use. killDevice and deleteDevice also accept --force true to stop
|
|
67
|
-
a held device.
|
|
68
|
-
`);let a=new Map,l=["setActiveDevice","listDevices","listDeviceImages","getAndroid","getApple","killDevice","checkRunningDevices"],c=["changeLocalization"];o.forEach((d)=>{let u="General";if(c.includes(d.name))u="System Configuration";else if(l.includes(d.name))u="Device Management";else if(d.name.includes("App")||d.name.includes("app"))u="App Management";else if(d.name.startsWith("assert"))u="Assertions";else if(d.name.includes("observe"))u="Observation";else if(d.name.includes("Plan")||d.name.includes("plan"))u="Plan Management";else u="Interactions";if(!a.has(u))a.set(u,[]);a.get(u).push(d)}),n.log(`
|
|
69
|
-
Available Tools:`),n.log("================"),a.forEach((d,u)=>{n.log(`
|
|
70
|
-
${u}:`),d.forEach((p)=>{n.log(` ${p.name.padEnd(25)} - ${p.description}`)})}),n.log(`
|
|
71
|
-
Total: ${o.length} tools available`),n.log(`
|
|
72
|
-
Use 'bunx ${s} --cli help <tool-name>' for detailed information about a specific tool.`)}function Ge(n,o){let s=$s(),a=F.getTool(n);if(!a){o.error(`Unknown tool: ${n}`),o.log(`
|
|
73
|
-
Use 'bunx ${s} --cli help' to see available tools.`);return}if(o.log(`
|
|
74
|
-
Tool: ${a.name}`),o.log("=".repeat(a.name.length+6)),o.log(`Description: ${a.description}`),a.supportsProgress)o.log("Supports: Progress notifications");o.log(`
|
|
75
|
-
Parameters:`),o.log(` Pass objects and arrays as JSON, e.g. --selector '{"text":"Submit"}'.`);try{let l=ze(a.schema);if(l)Object.entries(l).forEach(([c,d])=>{let u=Ye(d);if(o.log(` --${c} ${u.isOptional?"(optional)":"(required)"}`),o.log(` Type: ${u.typeName}`),u.description)o.log(` Description: ${u.description}`)});else o.log(" No parameters required")}catch(l){e.debug(`CLI parameter schema help unavailable: ${r(l)}`),o.log(" Could not parse parameter schema")}o.log(`
|
|
76
|
-
Example usage:`),o.log(` bunx ${s} --cli ${n} [parameters...]`)}function ze(n){let o=n?._def;if(!o)return;if(o.shape)return o.shape;if(o.type==="pipe"&&o.out?._def?.shape)return o.out._def.shape;return}function Ye(n){let o=Ze(n),s=o?n?._def?.innerType??n:n,a=s?._def?.typeName??s?._def?.type??"unknown",l=String(a).replace(/^Zod/,"").toLowerCase(),c=["union","intersection","object","record","array","enum","literal","nullable"].includes(l)?S(eS(s,{io:"input"})):l;return{isOptional:o,typeName:c,description:Ke(n,s)}}function Ze(n){return typeof n?.isOptional==="function"?n.isOptional():n?._def?.typeName==="ZodOptional"}function Ke(n,o){return n?.description??o?.description??o?._def?.description}function S(n){if(n.not&&Object.keys(n.not).length===0)return"never";if(n.allOf)return n.allOf.map((s)=>"("+S(s)+")").join(" & ");let o=n.anyOf??n.oneOf;if(o)return o.map((s)=>S(s)).join(" | ");if("const"in n)return JSON.stringify(n.const);if(n.enum)return n.enum.map((s)=>JSON.stringify(s)).join(" | ");if(n.type==="object")return Xe(n);if(n.type==="array")return"("+S(n.items??{})+")[] (JSON)";return n.type??"any"}function Xe(n){let o=Object.entries(n.properties??{}).map(([s,a])=>JSON.stringify(s)+(n.required?.includes(s)?"":"?")+": "+S(a));if(n.additionalProperties){let s=n.additionalProperties===!0?"any":S(n.additionalProperties);o.push("[key: string]: "+s)}return"JSON { "+o.join(", ")+" }"}export{rn as cliCommandSkipsServerBootstrap,sn as runCliCommand};
|
|
77
|
-
|
|
78
|
-
//# debugId=2FB750451BDE6B3764756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{G$,Oae,_e,TO,I9,_9,x9,C9,Dp}from"./chunk-yf7ympyz.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{Oae as DATABASE_STARTUP_MIGRATION_FAILURE,G$ as SQLITE_BUSY_TIMEOUT_MS,_9 as awaitInFlightMigrations,C9 as closeDatabase,TO as ensureMigrations,_e as getDatabase,Dp as getDatabasePath,I9 as getMigrationsError,x9 as refusedDatabaseAccessCountAfterShutdownClose};
|
|
3
|
-
|
|
4
|
-
//# debugId=BE0B78B7CD1A202A64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{e}from"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";import{Dp}from"./chunk-yf7ympyz.js";import"./chunk-hrfytkxh.js";import{Eo}from"./chunk-r5bxavdx.js";import"./chunk-0n6swkwg.js";import"./chunk-5d2hft6c.js";import"./chunk-64j0majr.js";import"./chunk-e98dqnc9.js";import"./chunk-4hw3665t.js";import"./chunk-2f9rkmhx.js";import"./chunk-00167wan.js";import"./chunk-0qsy1qsx.js";import"./chunk-3xkpk44w.js";import"./chunk-7rz9898k.js";import{ju}from"./chunk-dgrbdpb7.js";import"./chunk-65y8v4td.js";import"./chunk-0jrrsnc9.js";import"./chunk-26k317v5.js";import"./chunk-284ptqa4.js";import"./chunk-w7hkv422.js";import"./chunk-fgb98zjj.js";import"./chunk-rvvy1bte.js";import{r,t}from"./chunk-rbpdk7m0.js";import{realpathSync as p}from"fs";import{basename as h,dirname as g,resolve as f}from"path";function b(o){let n=f(o);try{return p(n)}catch(a){e.debug(`Direct-mode DB realpath unavailable: ${r(a)}`);try{return f(p(g(n)),h(n))}catch(D){return e.debug(`Direct-mode DB parent realpath unavailable: ${r(D)}`),n}}}function P(o,n){return o.filter((a)=>a.dbPath!==void 0&&b(a.dbPath)===n)}function _(o){let n=b(o.resolveDbPath()),a=o.findLiveDaemonDbOwners(),D=P(a,n);if(D.length>0){let i=D.map((c)=>c.pid).join(", ");throw new t(`A live AutoMobile daemon (pid ${i}) already owns the database at ${n}. Direct mode (--no-proxy/--direct) would open a second writer on the same SQLite file, causing SQLITE_BUSY stalls and competing migrations. Resolve this by either running without --no-proxy/--direct to share the daemon, stopping the daemon, or setting AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database for this direct-mode instance.`)}let d=a.filter((i)=>i.dbPath===void 0);if(d.length>0){let i=d.map((c)=>c.pid).join(", ");throw new t(`Cannot safely start direct mode (--no-proxy/--direct): a live AutoMobile daemon (pid ${i}) is running but its database path could not be determined (it may still be starting up, or is using a non-default PID file), so a collision on ${n} cannot be ruled out. Wait for the daemon to finish starting and retry, stop the daemon, or set AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database for this direct-mode instance.`)}}function I(o={}){let n=o.manager??new ju,a=o.readPidFileData??Eo;return{resolveDbPath:o.resolveDbPath??Dp,findLiveDaemonDbOwners:()=>{let d;try{d=n.findLiveDaemonProcesses()}catch(l){let u=r(l);throw e.warn(`Direct-mode guard: process-table scan failed; refusing direct mode because same-DB daemon ownership cannot be verified. ${u}`,l),new t(`Cannot verify daemon ownership before starting direct mode (--no-proxy/--direct): failed to inspect the process table (${u}). Retry, stop any running daemon, or set AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database.`)}if(d.length===0)return[];let i=[],c=new Set,s=a();if(s&&typeof s.pid==="number"&&s.dbPath!==void 0&&d.includes(s.pid))i.push({pid:s.pid,dbPath:s.dbPath}),c.add(s.pid);let m=d.filter((l)=>!c.has(l));if(m.length>0){e.debug(`Direct-mode guard: ${m.length} live daemon(s) could not be mapped to a DB path (starting up or non-default PID file); direct mode will refuse to be safe: ${m.join(", ")}`);for(let l of m)i.push({pid:l,dbPath:void 0})}return i}}}export{_ as assertDirectModeDbOwnership,I as createDefaultDirectModeGuardDeps};
|
|
3
|
-
|
|
4
|
-
//# debugId=7D8621E14FEED96164756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{RU,$K,UK,HK,qK}from"./chunk-1p7xf5kb.js";import"./chunk-yf7ympyz.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{RU as DEFAULT_APPEARANCE_APPLY_DEADLINE_MS,$K as startAppearanceSyncScheduler,UK as stopAppearanceSyncScheduler,qK as syncAppearanceForDevice,HK as triggerAppearanceSync};
|
|
3
|
-
|
|
4
|
-
//# debugId=456AD4BD49EDB3E564756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{au}from"./chunk-7tw8x05v.js";import"./chunk-vy3bwm1d.js";import"./chunk-qyqypn28.js";import"./chunk-fgb98zjj.js";import"./chunk-3xkpk44w.js";import"./chunk-0qsy1qsx.js";import"./chunk-rvvy1bte.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{au as SwipeOn};
|
|
3
|
-
|
|
4
|
-
//# debugId=85984FA8C02CAFDD64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{EK,IK,_K}from"./chunk-wyrkw6hw.js";import"./chunk-6xmss8er.js";import"./chunk-g7tmjbkt.js";import"./chunk-w5b2jwk3.js";import"./chunk-0n6swkwg.js";import"./chunk-00167wan.js";import"./chunk-ycaj2sgf.js";import"./chunk-7rz9898k.js";import"./chunk-qyqypn28.js";import"./chunk-fgb98zjj.js";import"./chunk-3xkpk44w.js";import"./chunk-0qsy1qsx.js";import"./chunk-rvvy1bte.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{EK as getDeviceGestureRecordingSocketPath,IK as startDeviceGestureRecordingSocketServer,_K as stopDeviceGestureRecordingSocketServer};
|
|
3
|
-
|
|
4
|
-
//# debugId=C14D5A150ED85CE364756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{kae,zK,_U}from"./chunk-sfv61xjb.js";import"./chunk-jd6a5v6p.js";import"./chunk-11m8wj8j.js";import"./chunk-6awz7vhq.js";import"./chunk-w3vs79ex.js";import"./chunk-6xmss8er.js";import"./chunk-g7tmjbkt.js";import"./chunk-qf6nynk6.js";import"./chunk-h5rpn9wr.js";import"./chunk-w5b2jwk3.js";import"./chunk-3qwrzxh0.js";import"./chunk-ybbtagbt.js";import"./chunk-v2wd4n3e.js";import"./chunk-dgrbdpb7.js";import"./chunk-65y8v4td.js";import"./chunk-0jrrsnc9.js";import"./chunk-hrfytkxh.js";import"./chunk-26k317v5.js";import"./chunk-64j0majr.js";import"./chunk-2f9rkmhx.js";import"./chunk-0n6swkwg.js";import"./chunk-00167wan.js";import"./chunk-284ptqa4.js";import"./chunk-yb97j25b.js";import"./chunk-e98dqnc9.js";import"./chunk-84nanf8s.js";import"./chunk-3f3t1x97.js";import"./chunk-w7hkv422.js";import"./chunk-thbh3jew.js";import"./chunk-7tw8x05v.js";import"./chunk-vy3bwm1d.js";import"./chunk-aabchzxk.js";import"./chunk-jh6vhqzx.js";import"./chunk-bfw6125s.js";import"./chunk-ycaj2sgf.js";import"./chunk-7rz9898k.js";import"./chunk-qyqypn28.js";import"./chunk-fgb98zjj.js";import"./chunk-3xkpk44w.js";import"./chunk-0qsy1qsx.js";import"./chunk-zgja5f3p.js";import"./chunk-rvvy1bte.js";import"./chunk-v6pya0dm.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{zK as createMcpServer,_U as refreshMcpResourceList,kae as registerMcpTools};
|
|
3
|
-
|
|
4
|
-
//# debugId=00DA1AFA9FD9C58864756E2164756E21
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{nd,Dw,Mv,ke}from"./chunk-r5bxavdx.js";var e=new Set([nd,ke.DEVICE_PORT,...Array.from({length:Mv-Dw+1},(o,r)=>Dw+r)]),TE=e;function FJ(o){e.add(o)}var t;function LJ(o){t=o}async function BJ(){await t?.stop("daemon")}
|
|
3
|
-
export{TE,FJ,LJ,BJ};
|
|
4
|
-
|
|
5
|
-
//# debugId=33B40AED66420F1B64756E2164756E21
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{i}from"./chunk-z637nqg8.js";import{Bt,az,Pn,mk}from"./chunk-r5bxavdx.js";import{Fc,fX}from"./chunk-qf6nynk6.js";var p={getConfig:Fc,updateConfig:fX};class o extends mk{constructor(n=Bt(az),s=i,t=p){super({socketPath:n,timer:s,serverName:"DeviceSnapshot",responseType:"device_snapshot_response",evictedKey:"evictedSnapshotNames",methodLabel:"device snapshot",getConfig:t.getConfig,updateConfig:async(r)=>{let{config:c,evictedSnapshotNames:a}=await t.updateConfig(r);return{config:c,evictedItems:a}}})}}var e=new Pn;function xK(){return e.instance?.getSocketPath()??Bt(az)}async function CK(){await e.start(()=>new o)}async function DK(){await e.stop()}
|
|
3
|
-
export{xK,CK,DK};
|
|
4
|
-
|
|
5
|
-
//# debugId=C1F98C3703F7AA7864756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{kv,To}from"./chunk-zgja5f3p.js";import"./chunk-rvvy1bte.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{To as Keyboard,kv as KeyboardOpenIndeterminateError};
|
|
3
|
-
|
|
4
|
-
//# debugId=1DA890034BDC566D64756E2164756E21
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{AK,TK,kK}from"./chunk-nr6y0n4y.js";import"./chunk-w3vs79ex.js";import"./chunk-g7tmjbkt.js";import"./chunk-v2wd4n3e.js";import"./chunk-284ptqa4.js";import"./chunk-0qsy1qsx.js";import"./chunk-v6pya0dm.js";import"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-4hw3665t.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{AK as getVideoRecordingSocketPath,TK as startVideoRecordingSocketServer,kK as stopVideoRecordingSocketServer};
|
|
3
|
-
|
|
4
|
-
//# debugId=A26057DA898086EC64756E2164756E21
|