@kaeawc/auto-mobile 0.0.92 → 0.0.93
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/schemas/test-plan.schema.json +370 -52
- package/dist/src/{chunk-jhnbfj19.js → chunk-00167wan.js} +5 -5
- package/dist/src/chunk-0jrrsnc9.js +6 -0
- package/dist/src/chunk-0n6swkwg.js +5 -0
- package/dist/src/chunk-0qsy1qsx.js +57 -0
- package/dist/src/chunk-11m8wj8j.js +237 -0
- package/dist/src/{chunk-4pfftt07.js → chunk-1p7xf5kb.js} +3 -3
- package/dist/src/chunk-23p5f095.js +4 -0
- package/dist/src/{chunk-a4k9rt7z.js → chunk-26k317v5.js} +3 -3
- package/dist/src/chunk-284ptqa4.js +7 -0
- package/dist/src/chunk-28re4xrg.js +4 -0
- package/dist/src/chunk-2f9rkmhx.js +5 -0
- package/dist/src/chunk-2fxdh48t.js +4 -0
- package/dist/src/chunk-2tbdrbt6.js +4 -0
- package/dist/src/chunk-2tqzq5qh.js +971 -0
- package/dist/src/chunk-32gvv9b4.js +21 -0
- package/dist/src/chunk-3f3t1x97.js +8 -0
- package/dist/src/chunk-3fspkbc7.js +4 -0
- package/dist/src/chunk-3qwrzxh0.js +11 -0
- package/dist/src/chunk-3sy6ahhz.js +26 -0
- package/dist/src/chunk-3vg455e6.js +4 -0
- package/dist/src/chunk-3xkpk44w.js +5 -0
- package/dist/src/chunk-3y6eykz9.js +4 -0
- package/dist/src/chunk-49bsqdx3.js +4 -0
- package/dist/src/chunk-4hw3665t.js +42 -0
- package/dist/src/chunk-58wzr3mt.js +5 -0
- package/dist/src/chunk-5d2hft6c.js +5 -0
- package/dist/src/chunk-5snsn9cf.js +4 -0
- package/dist/src/chunk-5tm9mn47.js +54 -0
- package/dist/src/chunk-5zc77a5t.js +4 -0
- package/dist/src/chunk-64j0majr.js +19 -0
- package/dist/src/chunk-65y8v4td.js +17 -0
- package/dist/src/chunk-6awz7vhq.js +5 -0
- package/dist/src/{chunk-stfzjr9y.js → chunk-6bznss4t.js} +5 -5
- package/dist/src/chunk-6ep7f5ge.js +4 -0
- package/dist/src/{chunk-0dfnyfkh.js → chunk-6wt9rgjf.js} +3 -3
- package/dist/src/chunk-6xmss8er.js +8 -0
- package/dist/src/chunk-710rxz9y.js +5 -0
- package/dist/src/chunk-7cs2da62.js +5 -0
- package/dist/src/chunk-7g103b54.js +4 -0
- package/dist/src/chunk-7j5vj4pa.js +4 -0
- package/dist/src/chunk-7rz9898k.js +5 -0
- package/dist/src/chunk-7tw8x05v.js +4 -0
- package/dist/src/chunk-7zy586cb.js +4 -0
- package/dist/src/{chunk-r0f1q783.js → chunk-8037tzzj.js} +3 -3
- package/dist/src/chunk-84nanf8s.js +5 -0
- package/dist/src/{chunk-950qcq1e.js → chunk-8g1922rp.js} +4 -4
- package/dist/src/chunk-8gvwcv2p.js +4 -0
- package/dist/src/{chunk-sz1a7p43.js → chunk-8ph29g99.js} +1 -1
- package/dist/src/chunk-8thrmfat.js +4 -0
- package/dist/src/chunk-8zgzzs7k.js +78 -0
- package/dist/src/chunk-97b1zmaq.js +4 -0
- package/dist/src/chunk-9fth9ayh.js +4 -0
- package/dist/src/chunk-9j6anhjr.js +4 -0
- package/dist/src/{chunk-w7zsh13a.js → chunk-aabchzxk.js} +4 -4
- package/dist/src/{chunk-wry6skrm.js → chunk-ayp07wbb.js} +1 -1
- package/dist/src/chunk-bfjwqk8q.js +4 -0
- package/dist/src/{chunk-jdqvcq0a.js → chunk-bfw6125s.js} +3 -3
- package/dist/src/chunk-bnhscm2n.js +4 -0
- package/dist/src/chunk-bxmsax22.js +5 -0
- package/dist/src/chunk-c1vs4g1n.js +4 -0
- package/dist/src/chunk-ct3e7yng.js +4 -0
- package/dist/src/{chunk-8en08r7q.js → chunk-cyy71ggq.js} +3 -3
- package/dist/src/chunk-ddzkz92z.js +4 -0
- package/dist/src/chunk-dgrbdpb7.js +9 -0
- package/dist/src/chunk-drdz8hee.js +5 -0
- package/dist/src/chunk-e98dqnc9.js +145 -0
- package/dist/src/chunk-eersndy7.js +5 -0
- package/dist/src/chunk-eggq53ks.js +4 -0
- package/dist/src/chunk-f2dya7cs.js +4 -0
- package/dist/src/chunk-fbakd6cw.js +4 -0
- package/dist/src/chunk-fgb98zjj.js +5 -0
- package/dist/src/chunk-fmpad823.js +5 -0
- package/dist/src/{chunk-v90es00d.js → chunk-g04bwyj3.js} +2 -2
- package/dist/src/chunk-g0xr8zw0.js +4 -0
- package/dist/src/chunk-g3rjs80x.js +4 -0
- package/dist/src/chunk-g78rtrfv.js +4 -0
- package/dist/src/{chunk-r20pe1nv.js → chunk-g7tmjbkt.js} +3 -3
- package/dist/src/chunk-gabgv3y5.js +4 -0
- package/dist/src/chunk-gmr45m8f.js +4 -0
- package/dist/src/chunk-gsyfebqj.js +4 -0
- package/dist/src/chunk-h5rpn9wr.js +247 -0
- package/dist/src/chunk-hb1x7v55.js +4 -0
- package/dist/src/chunk-hrfytkxh.js +168 -0
- package/dist/src/chunk-j4yjzbak.js +4 -0
- package/dist/src/chunk-jd6a5v6p.js +5 -0
- package/dist/src/chunk-jh6vhqzx.js +5 -0
- package/dist/src/chunk-kn5spq15.js +4 -0
- package/dist/src/{chunk-w2mwa0jk.js → chunk-m94qs0f0.js} +2 -2
- package/dist/src/chunk-mjrps0ac.js +7 -0
- package/dist/src/chunk-n03dmn5q.js +5 -0
- package/dist/src/chunk-n72qhwd9.js +4 -0
- package/dist/src/{chunk-km0dy5vc.js → chunk-ndt1ccxm.js} +9 -9
- package/dist/src/chunk-nr6y0n4y.js +5 -0
- package/dist/src/chunk-pcsen2vs.js +4 -0
- package/dist/src/chunk-ppfr0b8h.js +4 -0
- package/dist/src/chunk-q10bdnat.js +4 -0
- package/dist/src/chunk-q9xmq595.js +4 -0
- package/dist/src/{chunk-2v7tw1nj.js → chunk-qcxzr2my.js} +3 -3
- package/dist/src/chunk-qf6nynk6.js +7 -0
- package/dist/src/chunk-qyqypn28.js +5 -0
- package/dist/src/chunk-r2epb56s.js +4 -0
- package/dist/src/chunk-r5bxavdx.js +311 -0
- package/dist/src/{chunk-r14wwk37.js → chunk-r6z1eztj.js} +12 -12
- package/dist/src/{chunk-d57432wq.js → chunk-r7bpkgff.js} +2 -2
- package/dist/src/chunk-r8jf3d92.js +4 -0
- package/dist/src/{chunk-9rkfyt6q.js → chunk-rbpdk7m0.js} +3 -3
- package/dist/src/chunk-rc0dbypm.js +4 -0
- package/dist/src/chunk-rhcty4ms.js +4 -0
- package/dist/src/chunk-rpvckv3p.js +4 -0
- package/dist/src/{chunk-s1zq65ny.js → chunk-rqc9ap3x.js} +2 -2
- package/dist/src/chunk-rvvy1bte.js +7 -0
- package/dist/src/chunk-ry0mz41y.js +4 -0
- package/dist/src/{chunk-34zxqcmq.js → chunk-s3jc6cwp.js} +3 -3
- package/dist/src/chunk-sfv61xjb.js +6 -0
- package/dist/src/chunk-t6bfvfkg.js +4 -0
- package/dist/src/chunk-t6c8akcm.js +5 -0
- package/dist/src/chunk-t7w8rctc.js +4 -0
- package/dist/src/chunk-thbh3jew.js +5 -0
- package/dist/src/chunk-v2wd4n3e.js +5 -0
- package/dist/src/{chunk-zg67wjkh.js → chunk-v6pya0dm.js} +3 -3
- package/dist/src/chunk-vy3bwm1d.js +17 -0
- package/dist/src/chunk-w3vs79ex.js +27 -0
- package/dist/src/chunk-w4zga19f.js +4 -0
- package/dist/src/chunk-w5b2jwk3.js +14 -0
- package/dist/src/chunk-w7hkv422.js +5 -0
- package/dist/src/{chunk-qv2918jt.js → chunk-waqwcjyn.js} +2 -2
- package/dist/src/{chunk-b4cxdzwy.js → chunk-wbh8spm5.js} +7 -7
- package/dist/src/{chunk-ajsrz473.js → chunk-wyrkw6hw.js} +3 -3
- package/dist/src/chunk-xa73x2cx.js +5 -0
- package/dist/src/{chunk-eka89q3k.js → chunk-xgan0qqp.js} +1 -1
- package/dist/src/chunk-y2vs6jwg.js +4 -0
- package/dist/src/chunk-yattm52s.js +4 -0
- package/dist/src/{chunk-9y5bcy28.js → chunk-yb97j25b.js} +4 -4
- package/dist/src/{chunk-c9nk1r78.js → chunk-ybbtagbt.js} +3 -3
- package/dist/src/chunk-ycaj2sgf.js +9 -0
- package/dist/src/chunk-yf7ympyz.js +325 -0
- package/dist/src/chunk-yjawdzk8.js +4 -0
- package/dist/src/chunk-z637nqg8.js +11 -0
- package/dist/src/{chunk-0w1spptt.js → chunk-zgja5f3p.js} +4 -4
- package/dist/src/chunk-zs1sghs9.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/ios/CameraPosterInjection/Injection/CameraPosterInjection.m +466 -0
- package/package.json +3 -2
- package/schemas/test-plan.schema.json +370 -52
- package/dist/src/chunk-09442h7v.js +0 -4
- package/dist/src/chunk-0e4gm1kj.js +0 -5
- package/dist/src/chunk-0eb8576f.js +0 -4
- package/dist/src/chunk-0rjm4nx7.js +0 -5
- package/dist/src/chunk-1zmh2eak.js +0 -4
- package/dist/src/chunk-28k63ha3.js +0 -5
- package/dist/src/chunk-2d4wmp8b.js +0 -4
- package/dist/src/chunk-2e6s75qv.js +0 -78
- package/dist/src/chunk-32jpxz2y.js +0 -323
- package/dist/src/chunk-3jmvqygr.js +0 -238
- package/dist/src/chunk-3swvfhqt.js +0 -5
- package/dist/src/chunk-44bt78m9.js +0 -5
- package/dist/src/chunk-488vt2bp.js +0 -4
- package/dist/src/chunk-4fgdhcwx.js +0 -5
- package/dist/src/chunk-4jp2se4w.js +0 -4
- package/dist/src/chunk-4vhr9e4t.js +0 -4
- package/dist/src/chunk-4xd6zs3y.js +0 -15
- package/dist/src/chunk-51567pg8.js +0 -4
- package/dist/src/chunk-5agqsfev.js +0 -4
- package/dist/src/chunk-5d706gmr.js +0 -4
- package/dist/src/chunk-5kd4rqk7.js +0 -5
- package/dist/src/chunk-61t538bm.js +0 -4
- package/dist/src/chunk-6d3mmqxt.js +0 -54
- package/dist/src/chunk-6hyt398x.js +0 -5
- package/dist/src/chunk-6mnr8kpm.js +0 -4
- package/dist/src/chunk-79q5xsdc.js +0 -42
- package/dist/src/chunk-7bdgand3.js +0 -4
- package/dist/src/chunk-84cp9dw5.js +0 -4
- package/dist/src/chunk-86f2h5ww.js +0 -5
- package/dist/src/chunk-8cghfzb2.js +0 -19
- package/dist/src/chunk-9tf2p9y9.js +0 -5
- package/dist/src/chunk-a2sc4jm0.js +0 -5
- package/dist/src/chunk-aa5ng3d1.js +0 -4
- package/dist/src/chunk-b3h0a6ca.js +0 -4
- package/dist/src/chunk-b6a737qt.js +0 -4
- package/dist/src/chunk-bn64x5z5.js +0 -5
- package/dist/src/chunk-bvh649za.js +0 -12
- package/dist/src/chunk-c9tyfg4j.js +0 -26
- package/dist/src/chunk-cfsdfqnm.js +0 -4
- package/dist/src/chunk-cxyf04jc.js +0 -7
- package/dist/src/chunk-da08tx5v.js +0 -4
- package/dist/src/chunk-f2tc08m2.js +0 -4
- package/dist/src/chunk-f8tnk179.js +0 -5
- package/dist/src/chunk-f9s1kkhx.js +0 -5
- package/dist/src/chunk-fbp8a4rx.js +0 -4
- package/dist/src/chunk-fd2z0sze.js +0 -4
- package/dist/src/chunk-fk927f4q.js +0 -54
- package/dist/src/chunk-fxmr3a0f.js +0 -4
- package/dist/src/chunk-gaqwhd44.js +0 -4
- package/dist/src/chunk-ggtd5x5a.js +0 -5
- package/dist/src/chunk-gndcfrm7.js +0 -4
- package/dist/src/chunk-h3n4adc6.js +0 -310
- package/dist/src/chunk-h5pjbb83.js +0 -4
- package/dist/src/chunk-hgnnh302.js +0 -4
- package/dist/src/chunk-hmke8nhx.js +0 -5
- package/dist/src/chunk-j2bx12hn.js +0 -4
- package/dist/src/chunk-j70y1a2g.js +0 -4
- package/dist/src/chunk-js1jpyxp.js +0 -6
- package/dist/src/chunk-kbjq0qvb.js +0 -4
- package/dist/src/chunk-kfwx57xd.js +0 -4
- package/dist/src/chunk-kzwctna2.js +0 -4
- package/dist/src/chunk-m9ehyehy.js +0 -4
- package/dist/src/chunk-mct91p1f.js +0 -4
- package/dist/src/chunk-mf9spd4g.js +0 -5
- package/dist/src/chunk-mgrcansb.js +0 -4
- package/dist/src/chunk-mqc1d0eb.js +0 -6
- package/dist/src/chunk-n1zmpk0z.js +0 -4
- package/dist/src/chunk-ncyjf63g.js +0 -4
- package/dist/src/chunk-nr64d21q.js +0 -973
- package/dist/src/chunk-nwm2pq5v.js +0 -168
- package/dist/src/chunk-pm06b05d.js +0 -9
- package/dist/src/chunk-q50s00ry.js +0 -4
- package/dist/src/chunk-qwye1958.js +0 -14
- package/dist/src/chunk-r8z9pfve.js +0 -5
- package/dist/src/chunk-rdpgkjf6.js +0 -4
- package/dist/src/chunk-rkr0dks9.js +0 -5
- package/dist/src/chunk-rn84t3sf.js +0 -11
- package/dist/src/chunk-s123kn7n.js +0 -4
- package/dist/src/chunk-s73qn3fx.js +0 -4
- package/dist/src/chunk-sjn0nj4p.js +0 -5
- package/dist/src/chunk-sns0c35v.js +0 -7
- package/dist/src/chunk-t4dr5c8v.js +0 -8
- package/dist/src/chunk-tc8k9c1j.js +0 -4
- package/dist/src/chunk-teznhase.js +0 -4
- package/dist/src/chunk-ty9xgmz4.js +0 -4
- package/dist/src/chunk-tyazf3sk.js +0 -145
- package/dist/src/chunk-v6npjrjm.js +0 -5
- package/dist/src/chunk-vbvtzkwz.js +0 -5
- package/dist/src/chunk-vefd8qee.js +0 -8
- package/dist/src/chunk-vs9r72ta.js +0 -17
- package/dist/src/chunk-w88k0bgr.js +0 -4
- package/dist/src/chunk-wzdt0enk.js +0 -4
- package/dist/src/chunk-xhhv854c.js +0 -4
- package/dist/src/chunk-y58270hd.js +0 -4
- package/dist/src/chunk-yk0hmbex.js +0 -4
- package/dist/src/chunk-ympy4fdz.js +0 -28
- package/dist/src/chunk-yw436axy.js +0 -4
- package/dist/src/chunk-z04jrpjy.js +0 -5
- package/dist/src/chunk-z2xznczw.js +0 -4
- package/dist/src/chunk-z4xnrgps.js +0 -4
- package/dist/src/chunk-z7csyszv.js +0 -4
- package/dist/src/chunk-z8t0v07j.js +0 -11
- package/dist/src/chunk-z916af47.js +0 -228
- package/dist/src/chunk-zcr8he8q.js +0 -5
- package/dist/src/chunk-zd9vmkzn.js +0 -9
- package/dist/src/chunk-zj939v0h.js +0 -5
- package/dist/src/chunk-zkdjwtc1.js +0 -4
- package/dist/src/chunk-zkv5kzt6.js +0 -4
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);if(t[t.length-1]==="")t.pop();return t}function gt(s,t){return/^[\x20-\x7E]+$/.test(t)&&!/[\\^#]/.test(t)&&!(s==="unzip"&&t.startsWith("-"))}function bt(s,t,e){let r=Le(t),n=Le(e);if(r.length!==n.length)throw new
|
|
2
|
+
import{q5,hv,gv,yt,MV,V5}from"./chunk-8thrmfat.js";import{D,d,Z,gw,yw,tt,ta,Ot,Z5,cL,ST}from"./chunk-fmpad823.js";import*as _ from"fs/promises";import*as te from"fs";import*as b from"path";import*as Ne from"child_process";import*as st from"crypto";import*as ot from"readline";function T(s){let{name:t,inputSchema:e,description:r,run:n,...i}=s;if(e.type!=="object")throw Error(`JSON schema for tool "${t}" must be an object, but got ${e.type}`);return{...i,type:"custom",name:t,input_schema:e,description:r,run:n,parse:(o)=>o}}var L=gv.promises,G=448,mt=384;function ie(s,t){let e=yt.relative(s,t);return e===""||!e.startsWith(".."+yt.sep)&&e!==".."&&!yt.isAbsolute(e)}async function we(s,t){for(let e of s)if(ie(await H(yt.resolve(e)),t))return e;return}var ut=40;function K(s){let t=s?.code;return typeof t==="string"?t:void 0}async function H(s){let t=[],e=s,r=0;for(;;){let n;try{n=await L.realpath(e)}catch(i){let o;try{o=(await L.lstat(e)).isSymbolicLink()}catch(a){let c=K(a);if(c!=="ENOENT"&&c!=="ENOTDIR")throw a;let f=yt.dirname(e);if(f===e)throw a;t.push(yt.basename(e)),e=f;continue}if(!o)throw i;if(++r>ut)throw Object.assign(Error("too many levels of symbolic links"),{code:"ELOOP"});e=yt.resolve(yt.dirname(e),await L.readlink(e));continue}return t.length?yt.join(n,...t.reverse()):n}}async function Te(s,t,e){let r=e?.allowedRoots??[],n=await H(yt.resolve(s)),i;try{i=await H(yt.resolve(n,t))}catch(a){throw new Ot(U(a,`path ${JSON.stringify(t)}`))}if(ie(n,i)||await we(r,i)!==void 0)return i;let o=r.length?"the session's working directory and its other permitted directories":"the session's working directory";throw new Ot(`path ${JSON.stringify(t)} is outside ${o}`)}async function _e(s,t){let e=yt.dirname(s),r=yt.join(e,`.tmp-${process.pid}-${hv.randomUUID()}`),n=await L.stat(s).then((o)=>o.mode&511,()=>{return}),i;try{if(i=await L.open(r,"wx",mt),n!==void 0)await i.chmod(n);await i.writeFile(t,"utf-8"),await i.sync(),await i.close(),i=void 0,await L.rename(r,s)}catch(o){if(i)await i.close().catch(()=>{});throw await L.unlink(r).catch(()=>{}),o}}function U(s,t){let e=K(s);switch(e){case"ENOENT":return`${t}: no such file or directory`;case"EACCES":case"EPERM":return`${t}: permission denied`;case"ENOTDIR":return`${t}: not a directory`;case"EISDIR":return`${t}: is a directory`;case"ELOOP":return`${t}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${t}: file name too long`;case"ENOSPC":return`${t}: no space left on device`;case"EMFILE":case"ENFILE":return`${t}: too many open files`;default:return`${t}: ${e!==void 0?`i/o error (${e})`:"i/o error"}`}}var M=gv.promises,pt=V5.promisify(q5.execFile);async function wt(s){let{client:t,sessionId:e}=s;if(!t)return async()=>{};let r=tt(t),n=s.session;if(!n){if(e===void 0)return async()=>{};r.warn("AgentToolContext.sessionId is deprecated and costs an extra session fetch; fetch the session once and set `session` instead",{component:"agent-tool-context"}),n=await t.beta.sessions.retrieve(e)}let i=yt.resolve(s.workdir,"skills"),o=[];for(let a of n.agent.skills)try{let c=await t.beta.skills.versions.retrieve(a.version,{skill_id:a.skill_id}),f=yt.basename(c.name.trim());if(f===""||f==="."||f==="..")f=a.skill_id;let l=yt.resolve(i,f);if(l!==i&&!l.startsWith(i+yt.sep)){r.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:c.name});continue}let h=await t.beta.skills.versions.download(c.id,{skill_id:a.skill_id});await M.rm(l,{recursive:!0,force:!0}),await M.mkdir(l,{recursive:!0,mode:G}),o.push(l),await Ae(h,l),r.info("downloaded skill",{component:"agent-tool-context",skill_id:a.skill_id,version:c.id,dest:l})}catch(c){r.warn("failed to download skill",{component:"agent-tool-context",skill_id:a.skill_id,error:String(c)})}return async()=>{for(let a of o)await M.rm(a,{recursive:!0,force:!0}).catch((c)=>{r.warn("failed to clean up skill",{component:"agent-tool-context",dest:a,error:String(c)})})}}function _t(s){for(let t of s){let e=t.trim();if(!e)continue;if(yt.isAbsolute(e)||e.split(/[\\/]/).includes(".."))throw new Z(`refusing to extract unsafe archive member: ${e}`)}}var ge="skill archive listing is inconsistent; refusing to extract",St={unzip:new Set(["-","d","?"]),tar:new Set(["-","d","C"])};function Le(s){let t=s.split(`
|
|
3
|
+
`);if(t[t.length-1]==="")t.pop();return t}function gt(s,t){return/^[\x20-\x7E]+$/.test(t)&&!/[\\^#]/.test(t)&&!(s==="unzip"&&t.startsWith("-"))}function bt(s,t,e){let r=Le(t),n=Le(e);if(r.length!==n.length)throw new Z(ge);let i=[],o=[];return r.forEach((a,c)=>{if(St[s].has(n[c].charAt(0))){i.push(a);return}if(!gt(s,a))throw new Z(`refusing to extract archive: cannot safely exclude member ${JSON.stringify(a)}`);o.push(a)}),{plain:i,special:o}}async function $e(s){for(let t of await M.readdir(s,{withFileTypes:!0}))if(t.isDirectory())await $e(yt.join(s,t.name));else if(!t.isFile())throw new Z(ge)}async function Se(s,t){try{let{stdout:e}=await pt(s,t);return e}catch(e){if(K(e)==="ENOENT")throw new Z(`skill extraction requires the \`${s}\` command, but it was not found on PATH`);throw e}}function Et(s){let t,e=!1;for(let r of s){let n=r.trim().split("/").filter((o)=>o!==""&&o!==".");if(n.length===0)continue;let i=n[0];if(t===void 0)t=i;else if(i!==t)return"";if(n.length>1)e=!0}return t!==void 0&&e?t:""}async function Ae(s,t){let e=yt.join(t,`.skill-archive-${process.pid}-${Date.now()}`);if(!s.body)throw new Z("skill download response had no body");await MV.promises.pipeline(MV.Readable.fromWeb(s.body),gv.createWriteStream(e));let r=yt.join(yt.dirname(t),`.skill-stage-${process.pid}-${Date.now()}`),n=yt.join(yt.dirname(t),`.skill-exclude-${process.pid}-${Date.now()}`);try{let i=await vt(e,4),o=i.length>=4&&i[0]===80&&i[1]===75&&i[2]===3&&i[3]===4,a=o?"unzip":"tar",c=await Se(a,o?["-Z1",e]:["-tf",e]),f=await Se(a,o?["-Z","--h","--t",e]:["-tvf",e]),{plain:l,special:h}=bt(a,c,f);_t([...l,...h]);let y=Et(l);if(await M.mkdir(r,{recursive:!0,mode:G}),l.length>0)await Se(a,await Mt(a,e,r,h,n));await $e(r);let S=y?yt.join(r,y):r,N=await M.readdir(S).catch((E)=>{throw K(E)==="ENOENT"?new Z(ge):E});for(let E of N)await M.rename(yt.join(S,E),yt.join(t,E))}finally{await M.rm(e,{force:!0}),await M.rm(n,{force:!0}),await M.rm(r,{recursive:!0,force:!0})}}async function Mt(s,t,e,r,n){let i=r.map((o)=>o.replace(/[*?[\\]/g,"\\$&"));if(s==="unzip")return["-oq",t,"-d",e,...i.length>0?["-x",...i]:[]];if(i.length===0)return["-xf",t,"-C",e];return await M.writeFile(n,i.join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`,{flag:"wx",mode:384}),["-xf",t,"-C",e,"-X",n]}async function
|
|
6
|
-
${s}`,"utf-8").digest("hex")}var Wt=30000,Ut=100,jt=20,Bt=16,Yt=32,qt=8,zt=50;class A extends
|
|
7
|
-
${e.memoryStoreId}`);for await(let[r,n]of d(this,u,"m",fe).call(this,e.memoryStoreId,"full"))if(await d(this,u,"m",Ie).call(this,e,r,n.content??""))e.baseline.set(r,n.content_sha256)},qe=async function(e,r,n,i,o){let a=e.baseline.get(r);if(i!==void 0)e.pendingDeletes.delete(r);if(!n){if(i===void 0){e.pendingDeletes.delete(r);return}if(a!==void 0){if(i===a){let y=await d(this,u,"m",ze).call(this,e,r,a);if(y===void 0)return;if(y===a)return a;i=y}if(e.readOnly)d(this,m,"f").warn("memory deleted remotely but edited locally; keeping the file, which a read-only store cannot push",{path:r,memory_store_id:e.memoryStoreId});else if(e.refusedShas.get(r)!==i)d(this,m,"f").info("memory deleted remotely but edited locally; re-creating it from the file",{path:r,memory_store_id:e.memoryStoreId})}if(e.readOnly)return;if(e.refusedShas.get(r)===i)return;return await d(this,u,"m",he).call(this,e,r,i,void 0)}let c=n.content_sha256,f=c!==a,l=i!==void 0&&i!==a&&i!==c,h=!e.readOnly&&l;if(i===void 0&&a!==void 0){if(f)d(this,m,"f").warn("memory deleted locally but changed remotely; restoring the remote version",{path:r,memory_store_id:e.memoryStoreId}),e.pendingDeletes.delete(r),o.push([r,n]);return a}if(f){if(i===c)return c;if(l)d(this,m,"f").warn("memory changed both locally and remotely; keeping the remote version",{path:r,memory_store_id:e.memoryStoreId});return o.push([r,n]),a}if(h){if(e.refusedShas.get(r)===i)return c;return await d(this,u,"m",he).call(this,e,r,i,n)??c}return c},ze=async function(e,r,n){let i;try{i=await e.files.hashFile(r)}catch(o){if(!(o instanceof p)&&!Y(o))throw o;return n}if(i===null)return;if(i!==n)return i;try{await e.files.remove(r)}catch(o){if(!(o instanceof p)&&!Y(o))throw o;return d(this,m,"f").warn("failed to remove memory deleted remotely",{path:r,memory_store_id:e.memoryStoreId,error:String(o)}),n}return},Ie=async function(e,r,n){try{await e.files.put(r,n)}catch(i){if(!(i instanceof p)&&!Y(i))throw i;return d(this,m,"f").warn("failed to write memory",{path:r,memory_store_id:e.memoryStoreId,error:String(i)}),!1}return!0},He=async function(e,r){if(r.length===0)return;let n=async(a,c)=>{let f;try{f=await d(this,k,"f").beta.memoryStores.memories.retrieve(c.id,{memory_store_id:e.memoryStoreId,view:"full"})}catch(l){if(
|
|
8
|
-
`),ee=102400,Xt=2000,Jt=200;class ct extends
|
|
5
|
+
`,{flag:"wx",mode:384}),["-xf",t,"-C",e,"-X",n]}async function vt(s,t){let e=await M.open(s,"r");try{let r=Buffer.alloc(t),{bytesRead:n}=await e.read(r,0,t,0);return r.subarray(0,n)}finally{await e.close()}}var w=gv.promises,j=gv.constants,Fe=448,kt=384,It=448,Ee=j.O_NOFOLLOW??0,Rt=j.O_NONBLOCK??0,p=(()=>{class s extends Error{constructor(t,e){super(`path ${JSON.stringify(e)} ${t}`);this.name="FileStoreError",this.reason=t,this.relPath=e}}return s.ESCAPES_ROOT="escapes the store root",s.IS_A_SYMLINK="is a symlink",s.NOT_A_FILE="is not a regular file",s.NOT_A_DIRECTORY="is not a directory",s.NOT_UTF8="is not valid utf-8",s.MOVE_DESTINATION_EXISTS="already exists",s})();function Oe(s){return s.startsWith("/")&&!s.split("/").includes("..")}var be=(()=>{class s{constructor(t,e,r=!1){this.hashes=new Map,this.rootPath=t,this.removedOnDispose=e,this.decoder=r?new TextDecoder("utf-8",{fatal:!0}):void 0}static async open(t,e){if(!Nt())throw Error("FileStore requires O_NOFOLLOW support on this platform");let r=!1;try{await w.lstat(t)}catch(n){if(n.code!=="ENOENT")throw n;r=!0}return new s(yt.resolve(t),r,e?.utf8??!1)}async createRoot(){await Tt(this.rootPath)}root(){return{path:this.rootPath,removedOnDispose:this.removedOnDispose}}async dispose(){if(!this.removedOnDispose)return;await w.rm(this.rootPath,{recursive:!0,force:!0})}async put(t,e,r){let n=t.replace(/\\/g,"/");if(n.endsWith("/")||n.endsWith("/.")||n===""||n===".")throw new p(p.NOT_A_FILE,t);let i=this.resolveUnderRoot(t),o=typeof e==="string"?gw(e):e;this.requireUtf8(t,o),await xe(this.rootPath,yt.dirname(i)),await Lt(i,o,r?.executable??!1)}async get(t){let e=this.resolveUnderRoot(t),r;try{r=await Pe(t,e)}catch(i){if(i.code==="ENOENT")return null;throw i}let n;try{let i=await r.readFile();n=new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}finally{await r.close()}return this.requireUtf8(t,n),n}async ls(t="/"){let e=this.resolveUnderRoot(t);return new Set((await De(this.rootPath,t,e)).map(([r])=>r))}async findSymlinks(t="/"){let e=this.resolveUnderRoot(t);return At(this.rootPath,t,e)}async hashtree(t="/"){let e=this.resolveUnderRoot(t),r=se.nowNs(),n=Object.create(null);for(let[i,o]of await De(this.rootPath,t,e)){let a=await this.hashViaCache(i,o,r);if(a!==null)n[i]=a}return n}async hashFile(t){let e=this.resolveUnderRoot(t),r;try{r=await w.lstat(e,{bigint:!0})}catch(i){if(i.code==="ENOENT")return null;throw i}if(r.isSymbolicLink())throw new p(p.IS_A_SYMLINK,t);if(!r.isFile())throw new p(p.NOT_A_FILE,t);let n=yt.relative(this.rootPath,e).split(yt.sep).join("/");return this.hashViaCache(n,e,se.nowNs())}async move(t,e){let r=this.resolveUnderRoot(t),n=this.resolveUnderRoot(e);if(r===this.rootPath||n===this.rootPath)return;if(await w.stat(n).then(()=>!0,()=>!1))throw new p(p.MOVE_DESTINATION_EXISTS,e);await xe(this.rootPath,yt.dirname(n)),await w.rename(r,n)}async remove(t){let e=this.resolveUnderRoot(t);if(e===this.rootPath)return;let r;try{r=await w.lstat(e,{bigint:!0})}catch(n){if(n.code==="ENOENT")return;throw n}if(r.isDirectory())await w.rm(e,{recursive:!0,force:!0});else try{await w.unlink(e)}catch(n){if(n.code!=="ENOENT")throw n}}resolveUnderRoot(t){let e=t.replace(/\\/g,"/").replace(/^\/+/,""),r=e.split("/").filter((n)=>n!==""&&n!==".");if(yt.posix.isAbsolute(e)||r.includes(".."))throw new p(p.ESCAPES_ROOT,t);return r.length===0?this.rootPath:yt.join(this.rootPath,...r)}requireUtf8(t,e){if(!this.decoder)return;try{this.decoder.decode(e)}catch{throw new p(p.NOT_UTF8,t)}}async hashViaCache(t,e,r){let n;try{n=await w.lstat(e,{bigint:!0})}catch(a){if(a.code==="ENOENT")return null;throw a}if(!n.isFile())return null;let i=this.hashes.get(t),o;if(i!==void 0&&Dt(i,n))o=i.sha;else try{o=await se.hashFile(e)}catch(a){let c=a.code;if(c==="ENOENT"||a instanceof p)return null;if(c==="ELOOP"||c==="EMLINK")return null;throw a}if(Ct(n,r))this.hashes.set(t,{mtimeNs:n.mtimeNs,ctimeNs:n.ctimeNs,size:n.size,sha:o});return o}}return s.isPathLegal=Oe,s})();function Nt(){return Ee!==0}async function Tt(s){let t=[],e=s;for(;;){try{await w.stat(e);break}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR"&&i!=="ELOOP")throw n}t.push(e);let r=yt.dirname(e);if(r===e)break;e=r}for(let r of t.reverse())try{await w.mkdir(r,{mode:Fe})}catch(n){if(n.code!=="EEXIST")throw n}}async function xe(s,t){let e=yt.relative(s,t);if(e==="")return;let r=s;for(let n of e.split(yt.sep)){r=yt.join(r,n);try{await w.mkdir(r,{mode:Fe})}catch(i){if(i.code!=="EEXIST")throw i}}}async function Lt(s,t,e){let r=e?It:kt,n=yt.join(yt.dirname(s),`.fs-${hv.randomBytes(8).toString("hex")}.tmp`),i;try{i=await w.open(n,j.O_WRONLY|j.O_CREAT|j.O_EXCL|Ee,r),await i.writeFile(t),await i.close(),i=void 0,await w.rename(n,s)}catch(o){if(i)await i.close().catch(()=>{});throw await w.unlink(n).catch(()=>{}),o}}async function Pe(s,t){let e;try{e=await w.open(t,j.O_RDONLY|Ee|Rt)}catch(r){let n=r.code;if(n==="ELOOP"||n==="EMLINK")throw new p(p.IS_A_SYMLINK,s);throw r}try{if(!(await e.stat()).isFile())throw new p(p.NOT_A_FILE,s)}catch(r){throw await e.close().catch(()=>{}),r}return e}async function $t(s){let t=hv.createHash("sha256"),e=await Pe(yt.basename(s),s),r=new Uint8Array(1048576);try{for(;;){let{bytesRead:n}=await e.read(r,0,r.length);if(n===0)break;t.update(r.subarray(0,n))}}finally{await e.close()}return t.digest("hex")}async function De(s,t,e){if(!await xt(t,e))return[];let r=[];return await We(e,(n,i)=>{if(i.isFile())r.push([yt.relative(s,n).split(yt.sep).join("/"),n])}),r.sort(),r}async function At(s,t,e){let r=(o)=>yt.relative(s,o).split(yt.sep).join("/"),n;try{n=await w.lstat(e,{bigint:!0})}catch(o){let a=o.code;if(a==="ENOENT"||a==="ENOTDIR")return new Set;throw o}if(n.isSymbolicLink())return new Set([r(e)]);if(!n.isDirectory())throw new p(p.NOT_A_DIRECTORY,t);let i=new Set;return await We(e,(o,a)=>{if(a.isSymbolicLink())i.add(r(o))}),i}async function xt(s,t){let e;try{e=await w.lstat(t,{bigint:!0})}catch(r){let n=r.code;if(n==="ENOENT"||n==="ENOTDIR")return!1;throw r}if(!e.isDirectory())throw new p(p.NOT_A_DIRECTORY,s);return!0}async function We(s,t){let e=[s];while(e.length){let r=e.pop(),n;try{n=await w.readdir(r,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")continue;throw i}for(let i of n){let o=yt.join(r,i.name);if(t(o,i),i.isDirectory()&&!i.isSymbolicLink())e.push(o)}}}function Dt(s,t){return t.mtimeNs===s.mtimeNs&&t.ctimeNs===s.ctimeNs&&t.size===s.size}function Ct(s,t){return(s.mtimeNs>s.ctimeNs?s.mtimeNs:s.ctimeNs)<t-se.timestampTrustMarginNs}var Ft=2000000000n,se={hashFile:$t,timestampTrustMarginNs:Ft,nowNs:()=>BigInt(Date.now())*1000000n},Ue=be,Ce=Symbol.asyncDispose;if(Ce)Object.defineProperty(be.prototype,Ce,{value:be.prototype.dispose,configurable:!0,writable:!0});var u,k,oe,V,ae,m,B,ce,I,je,le,Be,Ye,Me,ve,ke,qe,ze,Ie,He,Ge,fe,he,Ke,Ve,Pt=30000,q=".anthropic-memory-store",Je=1;function Xe(s){return hv.createHash("sha256").update(`version ${Je}
|
|
6
|
+
${s}`,"utf-8").digest("hex")}var Wt=30000,Ut=100,jt=20,Bt=16,Yt=32,qt=8,zt=50;class A extends Z{constructor(s,t){super(s);if(this.name="SessionMemoryError",t!==void 0)this.cause=t}}class Ze{constructor(s,t,e){this.mode=s,this.cap=t,this.waiveWindow=e,this.attempted=0,this.capped=0,this.suppressed=0}takeSlot(){if(this.attempted>=this.cap)return this.capped++,!1;return this.attempted++,!0}}var Ht=(()=>{class s{constructor(t,e){u.add(this),k.set(this,void 0),oe.set(this,void 0),V.set(this,void 0),ae.set(this,void 0),m.set(this,void 0),B.set(this,void 0),ce.set(this,!1),I.set(this,[]),D(this,k,t,"f"),D(this,oe,e.workdir,"f"),D(this,V,e.syncIntervalMs??Z5,"f"),cL(d(this,V,"f"),"syncIntervalMs"),D(this,ae,e.syncDeletions??"enabled","f"),D(this,m,tt(t),"f"),D(this,B,Date.now(),"f")}get roots(){return d(this,I,"f").map((t)=>t.files.root().path)}get readOnlyRoots(){return d(this,I,"f").filter((t)=>t.readOnly).map((t)=>t.files.root().path)}async download(t){for(let e of t.resources){if(e.type!=="memory_store")continue;let r=d(this,u,"m",je).call(this,e),n;try{if(n={memoryStoreId:e.memory_store_id,files:await Ue.open(r,{utf8:!0}),readOnly:e.access==="read_only",baseline:new Map,refusedShas:new Map,pendingDeletes:new Map,sentShas:new Map},!n.files.root().removedOnDispose)throw new A(`something already exists at the memory store's path: ${r} (memory_store_id=${e.memory_store_id}); it must not exist when the session starts`);try{await n.files.createRoot()}catch(i){if(!Y(i))throw i;throw new A(`cannot create the memory store's folder: ${r} (memory_store_id=${e.memory_store_id}): ${i}; the worker host must make this mount path writable`,i)}await d(this,u,"m",ke).call(this,n),d(this,m,"f").info("downloaded memories",{count:n.baseline.size,memory_store_id:n.memoryStoreId,dest:n.files.root().path}),d(this,I,"f").push(n)}catch(i){if(n)await n.files.dispose().catch(()=>{});if(i instanceof A)throw i;throw new A(`failed to download memory store memory_store_id=${e.memory_store_id}: ${i}`,i)}}D(this,B,Date.now(),"f")}async finish(){if(d(this,ce,"f"))throw new Z("finish() was already called: it is the session's last sync and runs once");D(this,ce,!0,"f"),await this.syncAll(!0)}async syncAll(t){await Promise.all(d(this,I,"f").map((e)=>d(this,u,"m",Be).call(this,e,t))),D(this,B,Date.now(),"f")}async syncIfDue(){if(Date.now()-d(this,B,"f")<d(this,V,"f"))return;await this.syncAll(!1)}async flushWrites(t){await Promise.all(d(this,I,"f").map((e)=>d(this,u,"m",Ye).call(this,e,t)))}async dispose(){for(let t of d(this,I,"f")){let e=t.files.root();try{let r=await d(this,u,"m",le).call(this,t);if(!r.markerOk&&Object.keys(r.files).length>0){d(this,m,"f").warn(`${r.distrustReason}; leaving the memory store folder on disk`,{root:e.path,memory_store_id:t.memoryStoreId});continue}await t.files.dispose()}catch(r){if(!(r instanceof p)&&!Y(r))throw r;d(this,m,"f").warn("failed to remove the memory store folder",{root:t.files.root().path,memory_store_id:t.memoryStoreId,error:String(r)});continue}if(e.removedOnDispose)d(this,m,"f").info("removed memory store dir",{dest:e.path,memory_store_id:t.memoryStoreId})}}}return k=new WeakMap,oe=new WeakMap,V=new WeakMap,ae=new WeakMap,m=new WeakMap,B=new WeakMap,ce=new WeakMap,I=new WeakMap,u=new WeakSet,je=function(e){if(e.mount_path){if(!Oe(e.mount_path))throw new A(`memory store mount_path is not a clean absolute path: ${JSON.stringify(e.mount_path)} (memory_store_id=${e.memory_store_id})`);return e.mount_path}return yt.join(d(this,oe,"f"),"memory",e.name||e.memory_store_id)},le=async function(e){let r=await e.files.hashtree(),n=r[q];if(delete r[q],n===Xe(e.memoryStoreId))return{files:r,markerOk:!0,distrustReason:null};return{files:r,markerOk:!1,distrustReason:n!==void 0?"the marker file does not match this store":"the marker file is gone"}},Be=async function(e,r){try{let n=await d(this,u,"m",le).call(this,e),i=n.files;if(!n.markerOk){if(Object.keys(i).length>0){d(this,m,"f").warn(`${n.distrustReason}; leaving the memory store folder as found and not syncing`,{root:e.files.root().path,memory_store_id:e.memoryStoreId});return}await d(this,u,"m",Me).call(this,e,"the folder or its marker is gone");return}let o=new Map;for await(let[h,y]of d(this,u,"m",fe).call(this,e.memoryStoreId))o.set(h,y);if(d(this,u,"m",ve).call(this,e,o),Object.keys(i).length===0&&e.baseline.size>1){await d(this,u,"m",Me).call(this,e,"every memory file is gone at once");return}let a=new Ze(d(this,ae,"f"),Math.max(qt,Math.min(zt,Math.floor(e.baseline.size/4))),r),c=[],f=new Map,l=[...new Set([...o.keys(),...Object.keys(i),...e.baseline.keys()])].sort();for(let h of l){let y=o.get(h),S=i[h],N=e.baseline.get(h),E;if(S===void 0&&N!==void 0&&y!==void 0&&y.content_sha256===N&&!e.readOnly)E=await d(this,u,"m",Ke).call(this,e,h,y,N,a);else E=await d(this,u,"m",qe).call(this,e,h,y,S,c);if(E!==void 0)f.set(h,E)}if(e.baseline=f,await d(this,u,"m",He).call(this,e,c),a.suppressed>0)d(this,m,"f").debug("remote deletes are disabled; locally deleted memories stay on the server",{count:a.suppressed,memory_store_id:e.memoryStoreId});if(a.capped>0)d(this,m,"f").warn(`delete cap reached: ${a.mode==="log_only"?"would send":"sent"} ${a.attempted} deletes, held ${a.capped} for later syncs`,{memory_store_id:e.memoryStoreId})}catch(n){d(this,m,"f").warn("memory sync failed",{memory_store_id:e.memoryStoreId,error:String(n)})}},Ye=async function(e,r){let n=new Map,i=new Set,o=async()=>{if(e.readOnly)return;let a=await d(this,u,"m",le).call(this,e);if(!a.markerOk){d(this,m,"f").warn(`${a.distrustReason}; not uploading anything from the memory store folder`,{root:e.files.root().path,memory_store_id:e.memoryStoreId});return}for(let[l,h]of Object.entries(a.files))if((h!==e.baseline.get(l)||e.sentShas.has(l))&&e.refusedShas.get(l)!==h)n.set(l,h),i.add(l);if(n.size===0||r?.aborted)return;let c=new Map;for await(let[l,h]of d(this,u,"m",fe).call(this,e.memoryStoreId)){if(r?.aborted)return;c.set(l,h)}d(this,u,"m",ve).call(this,e,c);let f=[];for(let l of[...n.keys()].sort()){let h=n.get(l),y=e.baseline.get(l),S=c.get(l);if(h===y){i.delete(l);continue}if(S!==void 0&&S.content_sha256===h){e.baseline.set(l,S.content_sha256),i.delete(l);continue}if(S!==void 0&&S.content_sha256!==y){d(this,m,"f").warn("memory changed both locally and remotely; the flush leaves the remote version",{path:l,memory_store_id:e.memoryStoreId}),i.delete(l);continue}f.push([l,h,S])}await d(this,u,"m",Ge).call(this,e,f,i,r)};try{if(await Gt(o(),r),r?.aborted&&i.size>0)d(this,m,"f").warn(`memory flush cut off part-way; ${i.size} of ${n.size} changed files had not finished uploading`,{memory_store_id:e.memoryStoreId})}catch(a){d(this,m,"f").warn("memory flush failed",{memory_store_id:e.memoryStoreId,error:String(a)})}},Me=async function(e,r){d(this,m,"f").warn(`${r}; re-downloading the memory store folder instead of syncing`,{root:e.files.root().path,memory_store_id:e.memoryStoreId}),await e.files.createRoot(),await d(this,u,"m",ke).call(this,e)},ve=function(e,r){for(let[n,i]of e.sentShas)if(r.get(n)?.content_sha256===i)e.baseline.set(n,i);e.sentShas.clear()},ke=async function(e){e.baseline=new Map,e.sentShas.clear(),e.pendingDeletes.clear(),await e.files.put(q,`version ${Je}
|
|
7
|
+
${e.memoryStoreId}`);for await(let[r,n]of d(this,u,"m",fe).call(this,e.memoryStoreId,"full"))if(await d(this,u,"m",Ie).call(this,e,r,n.content??""))e.baseline.set(r,n.content_sha256)},qe=async function(e,r,n,i,o){let a=e.baseline.get(r);if(i!==void 0)e.pendingDeletes.delete(r);if(!n){if(i===void 0){e.pendingDeletes.delete(r);return}if(a!==void 0){if(i===a){let y=await d(this,u,"m",ze).call(this,e,r,a);if(y===void 0)return;if(y===a)return a;i=y}if(e.readOnly)d(this,m,"f").warn("memory deleted remotely but edited locally; keeping the file, which a read-only store cannot push",{path:r,memory_store_id:e.memoryStoreId});else if(e.refusedShas.get(r)!==i)d(this,m,"f").info("memory deleted remotely but edited locally; re-creating it from the file",{path:r,memory_store_id:e.memoryStoreId})}if(e.readOnly)return;if(e.refusedShas.get(r)===i)return;return await d(this,u,"m",he).call(this,e,r,i,void 0)}let c=n.content_sha256,f=c!==a,l=i!==void 0&&i!==a&&i!==c,h=!e.readOnly&&l;if(i===void 0&&a!==void 0){if(f)d(this,m,"f").warn("memory deleted locally but changed remotely; restoring the remote version",{path:r,memory_store_id:e.memoryStoreId}),e.pendingDeletes.delete(r),o.push([r,n]);return a}if(f){if(i===c)return c;if(l)d(this,m,"f").warn("memory changed both locally and remotely; keeping the remote version",{path:r,memory_store_id:e.memoryStoreId});return o.push([r,n]),a}if(h){if(e.refusedShas.get(r)===i)return c;return await d(this,u,"m",he).call(this,e,r,i,n)??c}return c},ze=async function(e,r,n){let i;try{i=await e.files.hashFile(r)}catch(o){if(!(o instanceof p)&&!Y(o))throw o;return n}if(i===null)return;if(i!==n)return i;try{await e.files.remove(r)}catch(o){if(!(o instanceof p)&&!Y(o))throw o;return d(this,m,"f").warn("failed to remove memory deleted remotely",{path:r,memory_store_id:e.memoryStoreId,error:String(o)}),n}return},Ie=async function(e,r,n){try{await e.files.put(r,n)}catch(i){if(!(i instanceof p)&&!Y(i))throw i;return d(this,m,"f").warn("failed to write memory",{path:r,memory_store_id:e.memoryStoreId,error:String(i)}),!1}return!0},He=async function(e,r){if(r.length===0)return;let n=async(a,c)=>{let f;try{f=await d(this,k,"f").beta.memoryStores.memories.retrieve(c.id,{memory_store_id:e.memoryStoreId,view:"full"})}catch(l){if(ta(l,404))return;d(this,m,"f").warn("failed to fetch memory content",{path:a,memory_store_id:e.memoryStoreId,error:String(l)});return}if(await d(this,u,"m",Ie).call(this,e,a,f.content??""))e.baseline.set(a,f.content_sha256)},i=r[Symbol.iterator](),o=async()=>{for(let[a,c]of i)await n(a,c)};await Promise.all(Array.from({length:Math.min(Bt,r.length)},o))},Ge=async function(e,r,n,i){let o=r[Symbol.iterator](),a=async()=>{for(let[c,f,l]of o){if(i?.aborted)return;let h=await d(this,u,"m",he).call(this,e,c,f,l);if(n.delete(c),h!==void 0)e.baseline.set(c,h)}};await Promise.all(Array.from({length:Math.min(Yt,r.length)},a))},fe=async function*(e,r="basic"){let n=r==="basic"?Ut:jt;for await(let i of d(this,k,"f").beta.memoryStores.memories.list(e,{view:r,limit:n})){if(i.type!=="memory")continue;let o=i.path.replace(/^\/+/,"");if(o===q){d(this,m,"f").warn("the server listed the reserved marker path; skipping",{path:i.path,memory_store_id:e});continue}yield[o,i]}},he=async function t(e,r,n,i){try{let o=await e.files.get(r);if(o===null)return;let a=yw(o);e.sentShas.set(r,hv.createHash("sha256").update(a,"utf-8").digest("hex"));let c=i?await d(this,k,"f").beta.memoryStores.memories.update(i.id,{memory_store_id:e.memoryStoreId,content:a,precondition:{type:"content_sha256",content_sha256:i.content_sha256}}):await d(this,k,"f").beta.memoryStores.memories.create(e.memoryStoreId,{path:"/"+r,content:a});return e.refusedShas.delete(r),e.sentShas.delete(r),c.content_sha256}catch(o){if(i&&ta(o,404))return await d(this,u,"m",t).call(this,e,r,n,void 0);let a=o instanceof p||ta(o,400)||ta(o,413);if(i&&ta(o,409))d(this,m,"f").warn("memory changed both locally and remotely; the upload was refused and the local edit loses",{path:r,memory_store_id:e.memoryStoreId});else if(a&&n!==void 0)e.refusedShas.set(r,n),d(this,m,"f").warn("the server rejected this memory file, so it stays un-synced until its content changes",{path:r,memory_store_id:e.memoryStoreId,rejection:String(o)});else d(this,m,"f").warn("failed to upload memory",{path:r,memory_store_id:e.memoryStoreId,error:String(o)});return}},Ke=async function(e,r,n,i,o){if(o.mode==="disabled")return o.suppressed++,i;let a=e.pendingDeletes.get(r);if(a===void 0)a=Date.now(),e.pendingDeletes.set(r,a);if(!o.waiveWindow&&Date.now()-a<Wt)return i;let c,f;try{c=await e.files.hashFile(q)===Xe(e.memoryStoreId),f=await e.files.hashFile(r)===null}catch(h){if(!(h instanceof p)&&!Y(h))throw h;c=f=!1}if(!c)return i;if(!f)return e.pendingDeletes.delete(r),i;if(!o.takeSlot())return i;if(o.mode==="log_only")return d(this,m,"f").info("log-only: sync would delete this memory on the server",{path:r,memory_store_id:e.memoryStoreId}),i;let l=await d(this,u,"m",Ve).call(this,e,r,n,i);if(l===void 0)e.pendingDeletes.delete(r);return l},Ve=async function(e,r,n,i){try{await d(this,k,"f").beta.memoryStores.memories.delete(n.id,{memory_store_id:e.memoryStoreId,expected_content_sha256:i})}catch(o){if(ta(o,404))return;if(ta(o,409)||ta(o,412))d(this,m,"f").warn("memory deleted locally but changed remotely; keeping the remote version",{path:r,memory_store_id:e.memoryStoreId});else d(this,m,"f").warn("failed to delete memory",{path:r,memory_store_id:e.memoryStoreId,error:String(o)});return i}d(this,m,"f").info("propagated local deletion",{path:r,memory_store_id:e.memoryStoreId});return},s})();function Y(s){return typeof s==="object"&&s!==null&&typeof s.code==="string"}async function Gt(s,t){if(!t){await s;return}let e,r=new Promise((n)=>{if(e=n,t.aborted)n()});t.addEventListener("abort",e,{once:!0});try{await Promise.race([s,r])}finally{t.removeEventListener("abort",e)}}var de,g,O,X,x,v,Re,me,J,ue,pe,C,F,z,P,Q,R,Qe,et,rt=102400,at=120000,Kt=262144,Vt=65536,nt=Buffer.from(`
|
|
8
|
+
`),ee=102400,Xt=2000,Jt=200;class ct extends Z{constructor(s){super(`bash command timed out after ${s}ms`);this.name="BashTimeoutError",this.timeoutMs=s}}var Zt=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Qt=_.glob;function lt(s){return s===void 0?Kt:s}function W(s){if(s===void 0)return;throw new Z("The `unrestrictedPaths` option you passed to the agent toolset (AgentToolContext) is no longer supported. The toolset's file tools (read, write, edit, glob, grep) are now always confined to the working directory plus the directories listed in `allowedRoots`. Remove `unrestrictedPaths` from your context; to let the file tools reach any other directory, add it to `allowedRoots`.")}function qr(s){return[rr(s),nr(s),or(s),ar(s),lr(s),fr(s)]}async function re(s,t){return W(s.unrestrictedPaths),Te(s.workdir,t,{allowedRoots:s.allowedRoots??[]})}function ft(s,t){return we(s.readOnlyRoots??[],t)}function er(){let s={};for(let[t,e]of Object.entries(process.env)){if(t.startsWith("ANTHROPIC_"))continue;s[t]=e}return s}var tr=(()=>{class s{constructor(t,e=er()){de.add(this),g.set(this,void 0),O.set(this,""),X.set(this,!1),x.set(this,!1),v.set(this,null),D(this,g,Ne.spawn("/bin/bash",["--noprofile","--norc"],{cwd:t,env:{...e,PS1:"",PS2:"",TERM:"dumb"},stdio:["pipe","pipe","pipe"],detached:!0}),"f"),d(this,g,"f").stdout.setEncoding("utf8"),d(this,g,"f").stderr.setEncoding("utf8"),d(this,g,"f").stdout.on("data",(r)=>d(this,de,"m",Re).call(this,r)),d(this,g,"f").stderr.on("data",(r)=>d(this,de,"m",Re).call(this,r)),d(this,g,"f").once("close",()=>{D(this,x,!0,"f");let r=d(this,v,"f");D(this,v,null,"f"),r?.resolve()})}get closed(){return d(this,x,"f")}async exec(t,e={}){if(d(this,x,"f"))throw new Z("bash session terminated");let r=e.timeoutMs??at,n=e.signal;n?.throwIfAborted(),D(this,O,"","f"),D(this,X,!1,"f");let i=`__ANT_CMD_${st.randomUUID()}_DONE__`,o=`${i.slice(0,8)}''${i.slice(8)}`,a=`{ ${t}
|
|
9
9
|
} </dev/null 2>&1; printf '\\n${o}%d\\n' $?
|
|
10
|
-
`;if(d(this,g,"f").stdin.write(a),d(this,O,"f").indexOf(i)<0){let{promise:S,resolve:N}=
|
|
11
|
-
${y}`;return{output:y,exitCode:h}}close(){if(d(this,x,"f"))return;
|
|
10
|
+
`;if(d(this,g,"f").stdin.write(a),d(this,O,"f").indexOf(i)<0){let{promise:S,resolve:N}=ST();D(this,v,{sentinel:i,resolve:N},"f");let E,ne;try{await Promise.race([S,new Promise((dt,ye)=>{E=setTimeout(()=>ye(new ct(r)),r)}),new Promise((dt,ye)=>{if(!n)return;ne=()=>ye(n.reason),n.addEventListener("abort",ne,{once:!0})})])}finally{if(E)clearTimeout(E);if(ne&&n)n.removeEventListener("abort",ne);D(this,v,null,"f")}}let c=d(this,O,"f").indexOf(i);if(c<0)throw new Z("bash session terminated");let l=d(this,O,"f").slice(c+i.length).match(/^(-?\d+)/),h=l?parseInt(l[1],10):-1,y=d(this,O,"f").slice(0,c).replace(Zt,"").replace(/\n+$/,"");if(d(this,X,"f"))y=`[output truncated]
|
|
11
|
+
${y}`;return{output:y,exitCode:h}}close(){if(d(this,x,"f"))return;D(this,x,!0,"f");let t=d(this,v,"f");D(this,v,null,"f"),t?.resolve(),d(this,g,"f").stdout.destroy(),d(this,g,"f").stderr.destroy(),d(this,g,"f").stdin.destroy();try{process.kill(-d(this,g,"f").pid,"SIGKILL")}catch{d(this,g,"f").kill("SIGKILL")}d(this,g,"f").unref()}}return g=new WeakMap,O=new WeakMap,X=new WeakMap,x=new WeakMap,v=new WeakMap,de=new WeakSet,Re=function(e){if(D(this,O,d(this,O,"f")+e,"f"),d(this,O,"f").length>rt)D(this,O,d(this,O,"f").slice(d(this,O,"f").length-rt),"f"),D(this,X,!0,"f");if(d(this,v,"f")&&d(this,O,"f").indexOf(d(this,v,"f").sentinel)>=0){let r=d(this,v,"f");D(this,v,null,"f"),r.resolve()}},s})();function rr(s){W(s.unrestrictedPaths);let t,e=Promise.resolve();return T({name:"bash",description:"Run a bash command in a persistent shell. State (cwd, env vars) persists across calls.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to run"},restart:{type:"boolean",description:"Restart the persistent shell before running"},timeout_ms:{type:"integer",description:"Per-call timeout in milliseconds"}}},run:async({command:r,restart:n,timeout_ms:i},o)=>{let a=e,c=ST();e=c.promise;try{await a}catch{}try{if(n)t?.close(),t=void 0;if(!r){if(n)return"bash session restarted";throw new Ot("bash: command is required")}t??(t=new tr(s.workdir,s.env));try{let{output:f,exitCode:l}=await t.exec(r,{timeoutMs:i??at,signal:o?.signal});if(l!==0)throw new Ot(f||`exit ${l}`);return f}catch(f){if(f instanceof Ot)throw f;throw t.close(),t=void 0,new Ot(`bash: ${f instanceof Error?f.message:String(f)}`)}}finally{c.resolve()}},close:()=>{t?.close(),t=void 0}})}function nr(s){return W(s.unrestrictedPaths),T({name:"read",description:"Read a UTF-8 text file relative to the workdir.",inputSchema:{type:"object",properties:{file_path:{type:"string"},view_range:{type:"array",items:{type:"integer"},description:"[start_line, end_line] 1-indexed inclusive"}},required:["file_path"]},run:async({file_path:t,view_range:e})=>{if(!t)throw new Ot("read: file_path is required");let r=await re(s,t);if(e?.length&&e.length!==2)throw new Ot("read: view_range must be [start_line, end_line]");let n;try{let l=await _.stat(r);if(!l.isFile())throw new Ot(`read: ${t} is not a regular file`);let h=lt(s.maxFileBytes);if(h!==null&&l.size>h){if(!e?.length)throw new Ot(`read: ${t} is ${l.size} bytes, exceeds ${h}-byte limit. Use the view_range parameter to read specific line ranges, e.g. view_range: [1, 500].`);let[y,S]=e;return await ir(r,t,y,S,h)}n=await _.readFile(r,"utf8")}catch(l){if(l instanceof Ot)throw l;throw new Ot(`read: ${U(l,t)}`)}if(!e?.length)return n;let[i,o]=e,a=n.split(`
|
|
12
12
|
`),c=Math.max(0,i-1),f=o>0?o:a.length;return a.slice(c,f).join(`
|
|
13
|
-
`)}})}async function ir(s,t,e,r,n){let i=new sr(t,e,r,n);if(i.rangeIsEmpty())return"";let o=te.createReadStream(s,{highWaterMark:Vt});try{for await(let a of o)if(i.collectFrom(a),i.rangeIsCollected())break}finally{o.destroy()}return i.text()}var sr=(()=>{class s{constructor(t,e,r,n){me.add(this),
|
|
14
|
-
`)}})}function fr(s){return W(s.unrestrictedPaths),T({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:t,path:e},r)=>{if(!t)throw new
|
|
15
|
-
[output truncated at ${ee} bytes]`);if(l===0)return n(a);if(l===1)return n("no matches");i(new
|
|
13
|
+
`)}})}async function ir(s,t,e,r,n){let i=new sr(t,e,r,n);if(i.rangeIsEmpty())return"";let o=te.createReadStream(s,{highWaterMark:Vt});try{for await(let a of o)if(i.collectFrom(a),i.rangeIsCollected())break}finally{o.destroy()}return i.text()}var sr=(()=>{class s{constructor(t,e,r,n){me.add(this),J.set(this,void 0),ue.set(this,void 0),pe.set(this,void 0),C.set(this,void 0),F.set(this,void 0),z.set(this,void 0),P.set(this,0),Q.set(this,[]),R.set(this,0),D(this,J,t,"f"),D(this,ue,e,"f"),D(this,pe,r,"f"),D(this,C,Math.max(0,e-1),"f"),D(this,F,r>0?r:1/0,"f"),D(this,z,n,"f")}rangeIsEmpty(){return d(this,F,"f")<=d(this,C,"f")}rangeIsCollected(){return d(this,P,"f")>=d(this,F,"f")}collectFrom(t){var e;let r=0;while(r<t.length&&!this.rangeIsCollected()){let n=t.indexOf(10,r),i=n<0?t.length:n;if(d(this,P,"f")>=d(this,C,"f"))d(this,me,"m",Qe).call(this,t.subarray(r,i),n>=0);if(n<0)break;D(this,P,(e=d(this,P,"f"),e++,e),"f"),r=n+1}}text(){return Buffer.concat(d(this,Q,"f"),d(this,R,"f")).toString("utf8")}}return J=new WeakMap,ue=new WeakMap,pe=new WeakMap,C=new WeakMap,F=new WeakMap,z=new WeakMap,P=new WeakMap,Q=new WeakMap,R=new WeakMap,me=new WeakSet,Qe=function(e,r){if(d(this,Q,"f").push(e),D(this,R,d(this,R,"f")+e.length,"f"),r&&d(this,P,"f")+1<d(this,F,"f"))d(this,Q,"f").push(nt),D(this,R,d(this,R,"f")+nt.length,"f");if(d(this,R,"f")>d(this,z,"f"))throw d(this,me,"m",et).call(this)},et=function(){if(d(this,F,"f")-d(this,C,"f")===1)return new Ot(`read: line ${d(this,C,"f")+1} of ${d(this,J,"f")} alone exceeds ${d(this,z,"f")}-byte limit. The read tool cannot return part of a line, so view_range cannot narrow this further.`);return new Ot(`read: view_range [${d(this,ue,"f")}, ${d(this,pe,"f")}] of ${d(this,J,"f")} exceeds ${d(this,z,"f")}-byte limit. Narrow the view_range to read a smaller portion.`)},s})();function or(s){return W(s.unrestrictedPaths),T({name:"write",description:"Write a UTF-8 text file relative to the workdir, creating parent directories as needed.",inputSchema:{type:"object",properties:{file_path:{type:"string"},content:{type:"string"}},required:["file_path","content"]},run:async({file_path:t,content:e})=>{if(!t)throw new Ot("write: file_path is required");let r=await re(s,t),n=await ft(s,r);if(n!==void 0)throw new Ot(`write: ${t} is inside read-only directory ${n}`);try{await _.mkdir(b.dirname(r),{recursive:!0,mode:G}),await _e(r,e??"")}catch(i){throw new Ot(`write: ${U(i,t)}`)}return`wrote ${Buffer.byteLength(e??"")} bytes to ${t}`}})}function ar(s){return W(s.unrestrictedPaths),T({name:"edit",description:"Replace old_string with new_string in a file. old_string must be unique unless replace_all.",inputSchema:{type:"object",properties:{file_path:{type:"string"},old_string:{type:"string"},new_string:{type:"string"},replace_all:{type:"boolean"}},required:["file_path","old_string","new_string"]},run:async({file_path:t,old_string:e,new_string:r,replace_all:n})=>{if(!t)throw new Ot("edit: file_path is required");if(!e)throw new Ot("edit: old_string is required");let i=await re(s,t),o=await ft(s,i);if(o!==void 0)throw new Ot(`edit: ${t} is inside read-only directory ${o}`);let a;try{let l=await _.stat(i);if(!l.isFile())throw new Ot(`edit: ${t} is not a regular file`);let h=lt(s.maxFileBytes);if(h!==null&&l.size>h)throw new Ot(`edit: ${t} is ${l.size} bytes, exceeds ${h}-byte limit. The edit tool loads the whole file and cannot modify a file this large.`);a=await _.readFile(i,"utf8")}catch(l){if(l instanceof Ot)throw l;throw new Ot(`edit: ${U(l,t)}`)}let c=a.split(e).length-1;if(c===0)throw new Ot(`edit: old_string not found in ${t}`);let f;if(n)f=a.split(e).join(r);else{if(c>1)throw new Ot(`edit: old_string appears ${c} times in ${t} (must be unique)`);f=a.replace(e,()=>r)}try{await _e(i,f)}catch(l){throw new Ot(`edit: write: ${U(l,t)}`)}return`edited ${t} (${n?c:1} replacement(s))`}})}function cr(s){return s.split(/[\\/{},]/).includes("..")}function lr(s){return W(s.unrestrictedPaths),T({name:"glob",description:"Match files under the workdir against a glob pattern. Results are mtime-sorted, newest first.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string",description:"Directory to search in. Defaults to the workdir."}},required:["pattern"]},run:async({pattern:t,path:e})=>{if(!t)throw new Ot("glob: pattern is required");if(b.isAbsolute(t))throw new Ot("glob: absolute pattern not permitted; pass a relative pattern (and optionally path)");if(cr(t))throw new Ot('glob: ".." is not permitted in the pattern');let r=e?await re(s,e):b.resolve(s.workdir),n=e?r:await H(r),i=[],o=ht;try{for await(let a of Qt(t,{cwd:r,withFileTypes:!0,exclude:(c)=>c.name===".git"||c.name==="node_modules"})){if(o--<=0)break;if(!a.isFile())continue;let c=b.join(a.parentPath,a.name),f;try{f=await _.realpath(c)}catch{continue}if(!ie(n,f))continue;let l=0;try{l=(await _.stat(c)).mtimeMs}catch{}i.push({path:c,mtime:l})}}catch(a){throw new Ot(`glob: ${a instanceof Error?a.message:String(a)}`)}if(i.length===0)return"no matches";return i.sort((a,c)=>c.mtime-a.mtime),i.slice(0,Jt).map((a)=>a.path).join(`
|
|
14
|
+
`)}})}function fr(s){return W(s.unrestrictedPaths),T({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:t,path:e},r)=>{if(!t)throw new Ot("grep: pattern is required");let n=b.resolve(s.workdir);if(e)n=await re(s,e);let i=await pr();return i?hr(i,t,n,r?.signal):dr(t,n,r?.signal)}})}function hr(s,t,e,r){return new Promise((n,i)=>{let o=Ne.spawn(s,["-n","--no-heading","-e",t,"--",e],{...r?{signal:r}:{}}),a="",c="",f=!1;o.stdout.on("data",(l)=>{if(f)return;if(a+=l,a.length>ee)f=!0,a=a.slice(0,ee),o.kill("SIGKILL")}),o.stderr.on("data",(l)=>c+=l),o.on("close",(l)=>{if(r?.aborted)return i(new Ot("grep: aborted"));if(f)return n(a+`
|
|
15
|
+
[output truncated at ${ee} bytes]`);if(l===0)return n(a);if(l===1)return n("no matches");i(new Ot(`grep: rg failed: ${c||`exit ${l}`}`))}),o.on("error",(l)=>{if(r?.aborted)return i(new Ot("grep: aborted"));i(new Ot(`grep: rg failed: ${l.message}`))})})}async function dr(s,t,e){let r;try{r=new RegExp(s)}catch(c){throw new Ot(`grep: invalid regex: ${c instanceof Error?c.message:String(c)}`)}let n=[],i=ee,o=(c)=>{if(i-=c.length+1,i<0)return n.push(`[output truncated at ${ee} bytes]`),!1;return n.push(c),!0};if((await _.stat(t).catch(()=>null))?.isFile())await it(t,r,o);else await ur(t,"",(c)=>it(b.join(t,c),r,o),e);if(e?.aborted)throw new Ot("grep: aborted");if(n.length===0)return"no matches";return n.join(`
|
|
16
16
|
`)}async function it(s,t,e){let r=te.createReadStream(s,{encoding:"utf8"}),n=ot.createInterface({input:r,crlfDelay:1/0}),i=0;try{for await(let o of n){if(i++,o.length>Xt)continue;if(t.test(o)&&!e(`${s}:${i}:${o}`))return!1}}catch{}finally{r.destroy()}return!0}var mr=40,ht=50000;async function ur(s,t,e,r){let n=ht;async function i(o,a){if(a>mr)return!0;if(r?.aborted)return!1;let c;try{c=await _.readdir(b.join(s,o),{withFileTypes:!0})}catch{return!0}for(let f of c){if(f.name===".git"||f.name==="node_modules")continue;if(n--<=0)return!1;if(r?.aborted)return!1;let l=o?b.join(o,f.name):f.name;if(f.isDirectory()){if(!await i(l,a+1))return!1}else if(f.isFile()){if(await e(l)===!1)return!1}}return!0}await i(t,0)}async function pr(){let s=(process.env.PATH??"").split(b.delimiter);for(let t of s){let e=b.join(t,"rg");try{return await _.access(e,te.constants.X_OK),e}catch{}}return null}export{Pt as MEMORY_FLUSH_TIMEOUT_MS,A as SessionMemoryError,Ht as SessionMemoryStores,qr as betaAgentToolset20260401,wt as setupSkills};
|
|
17
17
|
|
|
18
|
-
//# debugId=
|
|
18
|
+
//# debugId=54CFC9BC3E44F65264756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{B}from"./chunk-yf7ympyz.js";import{Qe,e}from"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";import{mkdir as d,readFile as m,rename as c,rm as y,stat as u,writeFile as a}from"fs/promises";import{dirname as l,join as f}from"path";var n=420;class w{ids;constructor(r=B){this.ids=r}defaultDir(){return Qe("prototype-web")}async kind(r){try{let t=await u(r);if(t.isFile())return"file";return t.isDirectory()?"directory":"other"}catch(t){e.debug(`prototype web export: stat ${r} failed`,t);return}}async read(r){return await m(r)}async write(r,t,p){let i=l(r);if(await d(i,{recursive:!0}),p.exclusive){await a(r,t,{flag:"wx",mode:n});return}let o=f(i,`.automobile-export-${this.ids.next()}.tmp`);try{await a(o,t,{flag:"wx",mode:n}),await c(o,r)}catch(s){throw await x(o),s}}}async function x(r){try{await y(r,{force:!0})}catch(t){e.debug(`prototype web export: removing ${r} failed`,t)}}export{w as NodePrototypeWebExportFiles};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=4486D2F41D84CC9064756E2164756E21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`).slice(0,3).join(" \u2190 "),i="cause"in n&&n.cause!==void 0?
|
|
2
|
+
import{Bl}from"./chunk-qcxzr2my.js";function Vp(n){if(n instanceof Error){let e=[n.name,n.message].filter(Boolean).join(": "),o=n.stack?.split(`
|
|
3
|
+
`).slice(0,3).join(" \u2190 "),i="cause"in n&&n.cause!==void 0?Vp(n.cause):"";return[e||"Error",o,i?`cause=${i}`:""].filter(Boolean).join(" | ")}if(n===null||n===void 0)return String(n);if(typeof n==="object"){if(Object.keys(n).length===0)return`${Object.prototype.toString.call(n)} (no enumerable keys)`;return Bl(()=>JSON.stringify(n),()=>Object.prototype.toString.call(n))}return String(n)}function r(n){return Bl(()=>{if(n instanceof Error)return n.message;return String(n)},()=>Bl(()=>Object.prototype.toString.call(n),()=>"Unknown error"))}class t extends Error{constructor(n,e){super(n,e);let o=e?.containerFailure??(e?.cause instanceof t?e.cause.containerFailure:void 0);if(o)this.containerFailure=o}}function u(n,e){if(n instanceof t)return n;let o=r(n);return new t(`${e}: ${o}`,{cause:n})}function St(n,e){return new t(`${e} is not supported on platform '${n}'. Supported platforms: android, ios.`)}export{Vp,r,t,u,St};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=2CDDC28B24467EFA64756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{FK,LK,BK}from"./chunk-8037tzzj.js";import"./chunk-0qsy1qsx.js";import"./chunk-yf7ympyz.js";import"./chunk-5d2hft6c.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{FK as getWebRtcStreamSocketPath,LK as startWebRtcStreamSocketServer,BK as stopWebRtcStreamSocketServer};
|
|
3
|
+
|
|
4
|
+
//# debugId=CAC25E13C7E1957064756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qa,gE,Ef,bJ,SJ,wJ,e}from"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{Qa as LogLevel,bJ as isStructuredLoggingEnabled,wJ as logSinkStalledWithin,e as logger,SJ as registerLogRetentionNamespaceSource,gE as resolveAutomobileLogFormat,Ef as resolveAutomobileLogSink};
|
|
3
|
+
|
|
4
|
+
//# debugId=005DA513A1964C5964756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-58wzr3mt.js";import"./chunk-z637nqg8.js";import"./chunk-4hw3665t.js";import{GK}from"./chunk-6bznss4t.js";import{t}from"./chunk-rbpdk7m0.js";import{createHash as l}from"crypto";import s from"path";function m(e){let r=e._meta??{},{frame:n,revision:o,variants:i,rendererVersion:p}=r;if(typeof n!=="string"||typeof o!=="number"||!Array.isArray(i)||typeof p!=="string"||typeof e.text!=="string")throw new t(`The prototype web page for ${e.uri} came back without its HTML or metadata; nothing was written.`);return{frame:n,revision:o,variants:i.map(String),rendererVersion:p}}var b=(e)=>l("sha256").update(e).digest("hex");function w(e,r,n){return`${GK(e.variant??e.id)}-${r.frame}-r${r.revision}-${n.slice(0,12)}.html`}async function g(e,r,n){let o=e.outputPath;if(o===void 0)return s.join(r.defaultDir(),n);if(!s.isAbsolute(o))throw new t(`outputPath "${o}" is not absolute: give an absolute file or directory path, or omit outputPath to write under ${r.defaultDir()}.`);let i=await r.kind(o);if(i==="directory"||/[\\/]$/.test(o))return s.join(o,n);if(i==="other")throw new t(`outputPath "${o}" exists and is not a regular file or directory; choose another outputPath.`);if(s.extname(o).toLowerCase()!==".html")throw new t(`outputPath "${o}" is neither an .html file nor a directory: end a file path in .html, or end a directory path in "${s.sep}" (or name an existing directory) to write ${n} there.`);return o}function f(e){return new t(`${e} already exists with different content; pass overwrite: true to replace it, or choose another outputPath. Nothing was written.`)}var P=new Set(["EACCES","EPERM","EROFS","ENOENT","ENOTDIR","EISDIR"]);function x(e,r){let n=e?.code;if(n==="EEXIST")return f(r);let o=n!==void 0&&P.has(n)?` (${n})`:"",i=e instanceof Error?`: ${e.message}`:"";return new t(`Cannot write the prototype web page to ${r}${o}${i}. Choose a writable outputPath, or omit it to write under the AutoMobile data directory.`)}async function E(e,r,n,o){if(await e.kind(r)==="file"&&!o){let i=await e.read(r);if(Buffer.from(i).equals(Buffer.from(n)))return;throw f(r)}try{await e.write(r,n,{exclusive:!o})}catch(i){throw x(i,r)}}async function I(e,r){let{id:n,frame:o,revision:i,variant:p,mcpSessionId:h}=e,d=await r.readWeb({id:n,frame:o,revision:i,variant:p,mcpSessionId:h}),a=m(d),u=Buffer.from(d.text,"utf8"),y=b(u),c=await g(e,r.files,w(e,a,y));return await E(r.files,c,u,e.overwrite===!0),{path:c,sha256:y,bytes:u.length,frame:a.frame,revision:a.revision,variants:a.variants,rendererVersion:a.rendererVersion}}export{I as exportPrototypeWeb};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=23C894C0998E1DF164756E2164756E21
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{i,e}from"./chunk-z637nqg8.js";import{bt,oo,me,$a,o,P,_g,wi,K,Ss,ve,Al,Ee,Hr,Ab,kb,E}from"./chunk-r5bxavdx.js";import{r,t}from"./chunk-rbpdk7m0.js";function Q(n){return n?.startsWith("Element not found with ")===!0}function Y(n,a){return n&&!Q(a)}async function MT(n){if(Y(n.advertised,n.error))return!0;if(!n.advertised||!n.needsNodeSelector)return!1;return!await z(n.selected,n.readHierarchy)}async function z(n,a){let s=await q(a);return Qh(s)&&V(n,s)}async function O(n,a,s){let c;try{c=await a()}catch(d){if(d instanceof Ee)throw d;return e.warn(`[TalkBack] Cannot verify resource-id uniqueness: ${r(d)}`,d),`Unable to verify uniqueness of resource-id "${n}"; using coordinate fallback.`}if(!Qh(c))return`Unable to verify uniqueness of resource-id "${n}" in an incomplete hierarchy; using coordinate fallback.`;let l=new ve().project(c).filter((d)=>Ss(d.nativeId,n));J(l,s);let u=new Set(l.map((d)=>d.source)).size;if(u!==1)return u>1?`Selected resource-id "${n}" is shared by ${u} elements; using coordinate fallback.`:`Resource-id "${n}" is absent from the current hierarchy; using coordinate fallback.`;return}function J(n,a){if(!a)return;if(!n.some((c)=>["text","content-desc"].every((u)=>!a[u]||c.properties[u]===a[u])&&(!a.bounds||c.bounds!==void 0&&wi(c.bounds,a.bounds,0))))throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.")}async function F(n,a,s={}){if(ee(n,s))return{element:n,hierarchy:null};let c=s.hierarchy??await q(a);if(!Qh(c)&&!L(s))return{element:n,hierarchy:c};if(!c||c.hierarchy.error)throw new t("Cannot confirm the selected element because the accessibility hierarchy is unavailable. Observe again and check that the accessibility service is running.");return Z(n,c,s)}function Z(n,a,s){let c=V(n,a);if((!s.hierarchy||!c)&&s.reResolve){let l=te(s.reResolve,a);if(!l)throw new t("Selected element moved or is gone; the original selector no longer resolves. Observe again before tapping.");if(!_(n,l))throw new t("Selected element moved; the original selector now resolves to a different element. Observe again before tapping.");if(!l.bounds)throw new t("Selected element moved and has no current bounds. Observe again before tapping.");return s.onResolvedElement?.(l),{element:l,hierarchy:a}}if(!c)throw new t("Selected element moved or is gone from the current hierarchy. Observe again before tapping.");return{element:n,hierarchy:a}}function _(n,a){return["text","content-desc","resource-id","test-tag","unique-id","collection-row-index","collection-column-index"].every((s)=>n[s]===void 0||n[s]===a[s])}function Qh(n){return!!n&&!n.hierarchy.error&&!n.ctrlProxyIncomplete&&!n.truncationReasons?.length&&!n.windows?.some((a)=>a.truncationReasons?.length)}async function q(n){try{return await n()}catch(a){if(a instanceof Ee)throw a;return e.warn(`[TalkBack] Cannot confirm selected target: ${r(a)}`,a),null}}function V(n,a){return new ve().project(a).some((s)=>_(n,s.properties)&&(!n.bounds||!!s.bounds&&wi(s.bounds,n.bounds,0)))}function L(n){return!!(n.hierarchy||n.reResolve)}function ee(n,a){return!L(a)&&(!n["resource-id"]||!!n["test-tag"]||!!n["unique-id"])}function te(n,a){try{return n(a)}catch(s){if(s instanceof Ee)throw s;throw new t("Selected element moved or is gone; the original selector cannot resolve unambiguously in the newer hierarchy. Observe again before tapping.",{cause:s})}}function Vo(n){return n>0?Math.max(1,Math.round(n)):Math.round(n)}function re(n,a){return`shell input touchscreen${a===void 0?"":` -d ${a}`} ${n}`}class BW extends t{}function KC(n,a){let s=[a.stdout,a.stderr].filter(Boolean).join(`
|
|
3
|
+
`);if(/(?:^|\r?\n)(?:Unknown command:|Error:|Usage: input\b)/.test(s))throw new BW(`Android command failed: ${n}: ${s.trim()}`)}async function wc(n,a,s,c={}){let{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p}=c;await _3(n,re(a,s),{signal:l,assertCurrent:u,timeoutMs:d,onDispatch:p})}async function _3(n,a,s={}){let{signal:c,assertCurrent:l,timeoutMs:u,onDispatch:d}=s;if(!l)d?.();let p=l?await n.execute(["shell",a.slice(6)],{signal:c,timeoutMs:u,beforeDispatch:async()=>{l(),d?.()}}):await n.executeCommand(a,{timeoutMs:u,signal:c});KC(a,p)}async function Ma(n,a){return a===void 0||a===0||await n.supportsCommand?.("gesture_display_id_v1")===!0}var Na=500,eg=1e4,Bm=60000,NT=1000,H=200;function Fa(n){return typeof n==="string"&&n.toLowerCase().includes("stale frame context")}var ne=10,oe=50;function Tw(n,a){if(n.action==="longPress")return n.durationMs??1000;return a==="android"?ne:oe}var ie=300,ae=250;function se(n){return`The two taps started ${n} ms apart, too close to or beyond Android's ${ie} ms double-tap timeout, so the app may not register a double tap. Update CtrlProxy so the double tap is sent as one device-timed gesture.`}async function x3(n,a,s){let c=H-(n.now()-a);if(c>0)await P(n.sleep(c),s.signal);o(s.signal);let l=n.now()-a;if(l>ae){let u=se(l);e.warn(`[doubleTap] ${u}`),s.onWarning?.(u)}}async function C3(n,a){let{signal:s}=a,c=n;if(typeof c.requestDoubleTapCoordinates!=="function")return!1;o(s);let l=!1,u=await c.requestDoubleTapCoordinates(a.x,a.y,()=>{l=!0},{frameContext:a.frameContext,displayId:a.displayId,signal:s,beforeSend:a.assertCurrent});if(u.success)a.onTapDelivered?.(),a.onTapDelivered?.();if(o(s),u.success)return!0;return ce(u,{dispatched:l,frameContext:a.frameContext})}function ce(n,a){let{error:s}=n;if(a.frameContext!==void 0&&Fa(s))throw new t(s??"Stale frame context; observe a fresh frame before retrying");if(a.dispatched){if(n.acknowledged===!0)throw new t(`Double tap was rejected by CtrlProxy: ${s??"unknown error"}`);throw new t(`Double tap outcome is indeterminate: the gesture was dispatched but no result was confirmed (${s??"unknown error"}). Do not retry automatically.`)}return e.debug(`[doubleTap] single-gesture double tap not used (${s??"unknown error"}); sending two taps`),!1}async function tg(n){let{timer:a,signal:s}=n;if(n.client&&await C3(n.client,{...n.point,frameContext:n.frameContext,displayId:n.displayId,signal:s,assertCurrent:n.assertCurrent,onTapDelivered:n.onTapDelivered}))return;let c=a.now();await n.tap(!1),await x3(a,c,{signal:s,onWarning:n.onWarning}),n.assertCurrent?.(),await n.tap(!0)}function rg(n,a="coordinate activation"){if(n===void 0||n===0)return;return new t(`TalkBack ${a} cannot target display ${n}; no gesture was dispatched.`)}class GC extends t{}function jte(n){return!(n instanceof GC)}function Sn(n){return new GC(`Tap outcome is indeterminate: the request was dispatched but no result was confirmed (${n??"unknown error"}). Do not retry automatically.`)}async function kw(n,a,s,{durationMs:c,options:l={}}){let{x:u,y:d}=s,{frameContext:p,signal:m,assertCurrent:f,onTapDelivered:g}=l;o(m);let b=!1,y=()=>{b=!0},h=Ab(c),v=await n.requestTapCoordinates({x:u,y:d,duration:c,timeoutMs:h,frameContext:p,onDispatch:y,signal:m,beforeSend:f});if(v.success)g?.();if(o(m),v.success)return;if(p!==void 0&&Fa(v.error))throw new t(v.error??"Stale frame context; observe a fresh frame before retrying");if(b)throw Sn(v.error);e.warn(`[TapOnElement] dispatchGesture tap failed (${v.error}), falling back to ADB input`),await wc(a,c>=Na?`swipe ${u} ${d} ${u} ${d} ${Vo(c)}`:`tap ${u} ${d}`,void 0,{signal:m,assertCurrent:f,timeoutMs:c>=Na?Hr(c):void 0}),g?.(),o(m)}async function Ew(n,a,{durationMs:s,frameContext:c,options:l={}}){return U(n,a,{durationMs:s,frameContext:c,options:l})}async function Iw(n,a,{durationMs:s=50,frameContext:c,options:l={}}={}){return U(n,a,{durationMs:s,frameContext:c,options:{...l,failureLabel:"double tap",doubleTap:!0}})}async function U(n,a,{durationMs:s,frameContext:c,options:l}){let{x:u,y:d}=a,{failureLabel:p="tap",signal:m,doubleTap:f=!1}=l;if(f)o(m,!0);let g=l.timeoutMs??Ab(s),b=!1,y=()=>{b=!0},h;try{h=f?await n.requestDoubleTapCoordinates(u,d,g,{frameContext:c,signal:m,onDispatch:y}):await n.requestTapCoordinates({x:u,y:d,duration:s,timeoutMs:g,frameContext:c,signal:m,onDispatch:y})}catch(v){if(le(v,b,m))throw e.warn(`[coordinateTapDispatch] iOS ${p} transport failed`,v),Sn(r(v));throw v}if(h.success)return;if(ue(h,b))throw e.warn(`[coordinateTapDispatch] iOS ${p} at (${u}, ${d}) unconfirmed after ${g}ms: ${h.error??"no error"}; the runner may stay busy until its XCUITest gesture returns`),Sn(h.error);throw new t(`CtrlProxy iOS ${p} failed: ${h.error}`)}function le(n,a,s){return a&&!(n instanceof t)&&n!==s?.reason}function ue(n,a){if(Al(n))return!0;return(n.dispatched??a)&&n.acknowledged!==!0&&!Fa(n.error)}function de(n,a,s){if(n.success||n.focusCompleted)s.onDispatched();if(!n.success)return;if(a==="doubleTap")s.onDispatched();for(let c of n.warnings??[])s.onWarning?.(c)}function pe(n,a){let{target:s,signal:c,talkBack:l}=a,u={assertCurrent:()=>{o(c),s.assertCurrent()}};return async({x:d,y:p})=>{u.assertCurrent();let m=n.action,f=m==="longPress"?n.duration??800:50,g=m==="tap"?await l.strategy.executePreciseTap(d,p,l.driver,u):await l.strategy.executeCoordinateFallback({x:d,y:p},m,f,{driver:l.driver,fenceOptions:{displayFence:u}});if(de(g,m,a),o(c),!g.success)throw new t(`TalkBack coordinate tap failed: ${g.error??"activation was not confirmed"}${g.focusCompleted?" Focus touch was delivered; activation failed. Do not retry automatically.":""}`)}}async function WL(n,a,s,c){let{target:l,signal:u,timer:d=i}=c,p=c.talkBack?rg(l.displayId):void 0;if(p)throw p;if(c.talkBack)return pe(s,{...c,talkBack:c.talkBack});let m=await Ma(n,l.displayId),f=async({x:g,y:b},y)=>{o(u),l.assertCurrent();let h=s.action==="longPress"?s.duration??800:10;if(m){let v=!1,k=()=>{v=!0},w=await n.requestTapCoordinates({x:g,y:b,duration:h,timeoutMs:Ab(h),onDispatch:k,signal:u,displayId:l.displayId===0?void 0:l.displayId,beforeSend:l.assertCurrent});if(w.success)y();if(o(u),w.success)return;if(v)throw Sn(w.error);if(Fa(w.error))throw new t(w.error??"Stale frame context");e.warn(`[androidDisplayTapDispatch] dispatchGesture tap failed (${w.error}), falling back to ADB input`)}await wc(a,s.action==="longPress"?`swipe ${g} ${b} ${g} ${b} ${Vo(h)}`:`tap ${g} ${b}`,l.displayId,{signal:u,assertCurrent:l.assertCurrent,timeoutMs:s.action==="longPress"?Hr(h):void 0}),y(),o(u)};return async(g)=>{let b=0,y=()=>{b++,c.onDispatched()};try{if(s.action==="doubleTap")await tg({client:m?n:void 0,point:g,displayId:l.displayId===0?void 0:l.displayId,timer:d,signal:u,assertCurrent:l.assertCurrent,onTapDelivered:y,onWarning:c.onWarning,tap:()=>f(g,y)});else await f(g,y)}catch(h){if(s.action==="doubleTap"&&b===1)throw Sn(`${r(h)}. Double tap partially applied: one tap was delivered; the second tap was not confirmed`);throw h}}}function C(n){return typeof n==="string"&&n.length>0?n:void 0}function j(n){return typeof n==="number"&&Number.isInteger(n)?n:void 0}function yi(n){let a={resourceId:C(n["resource-id"]),testTag:C(n["test-tag"]),uniqueId:C(n["unique-id"])},s=j(n["collection-row-index"]),c=j(n["collection-column-index"]),l=a.resourceId!==void 0||a.testTag!==void 0||a.uniqueId!==void 0;if(l&&s!==void 0&&c!==void 0)a.collectionRow=s,a.collectionColumn=c;return l?a:void 0}function ca(n){return n.testTag!==void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0}function G(n,a){let{testTag:s,resourceId:c}=n;if(s===void 0||n.uniqueId!==void 0||n.collectionRow!==void 0||n.collectionColumn!==void 0)return;let l=a.filter((u)=>u["test-tag"]===s&&(c===void 0||u["resource-id"]===c)).length;return l>1?`test tag "${s}" is shared by ${l} elements, so it does not identify the target`:void 0}async function ng(n,a,s){if(ca(n))return await a.supportsNodeActionSelectors()?void 0:"Runner does not support stable node selectors";return O(n.resourceId,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s)}class D{textMatcher;constructor(n=new kb){this.textMatcher=n}findTargetIndex(n,a,s={}){return this.resolveTargetCandidate(n,a,s)?.index??null}findCurrentFocusIndex(n,a){if(!n||a.length===0)return null;let s=a.indexOf(n);if(s>=0)return s;let c=this.getResourceId(n);if(c)return this.findIndexByValue(a,n,(p)=>this.getResourceId(p),{value:c});let l=this.getTestTag(n);if(l)return this.findIndexByValue(a,n,(p)=>this.getTestTag(p),{value:l});let u=this.getContentDesc(n);if(u)return this.findIndexByValue(a,n,(p)=>this.getContentDesc(p),{value:u,caseInsensitive:!0});let d=this.getText(n);if(d)return this.findIndexByValue(a,n,(p)=>this.getText(p),{value:d,caseInsensitive:!0});if(n.bounds){let p=n.bounds,m=a.findIndex((f)=>f.bounds&&f.bounds.left===p.left&&f.bounds.top===p.top&&f.bounds.right===p.right&&f.bounds.bottom===p.bottom);return m===-1?null:m}return null}matchesSelector(n,a,s={}){let c=this.getResourceId(n),l=this.getContentDesc(n),u=this.getTestTag(n),d=this.getText(n);if(a.resourceId&&a.resourceId!==c)return!1;if(a.testTag&&a.testTag!==u)return!1;if(a.text){let p=this.createTextMatcher(a.text,s);if(!(p(d)||p(l)))return!1}if(a.contentDesc){if(!this.createTextMatcher(a.contentDesc,s)(l))return!1}return!0}matchesFocusedTarget(n,a,s){let c=this.resolveTargetCandidate(a,s);if(!c)return!1;let l={partialMatch:c.partialMatch};if(!this.matchesSelector(n,s,l))return!1;if(c.matchCount===1)return!0;return n===c.element||c.element.bounds!==void 0&&this.boundsMatch(n,c.element.bounds)}createTextMatcher(n,a){let s=a.partialMatch??!1,c=a.caseSensitive??!1;return this.textMatcher.createTextMatcher(n,s,c)}findMatches(n,a,s){return n.flatMap((c,l)=>this.matchesSelector(c,a,s)?[{element:c,index:l}]:[])}resolveTargetCandidate(n,a,s={}){let c=this.findMatches(n,a,{...s,partialMatch:!1}),l=c.length===0&&s.partialMatch!==!1,u=l?this.findMatches(n,a,{...s,partialMatch:!0}):c;if(u.length===0)return null;return{...this.selectTargetCandidate(u,a),matchCount:u.length,partialMatch:l}}selectTargetCandidate(n,a){if(n.length===1)return n[0];if(!a.bounds)return this.firstVisibleOrFirst(n);return n.find(({element:c})=>this.boundsMatch(c,a.bounds))??this.nearestBoundsMatch(n,a.bounds)}firstVisibleOrFirst(n){return n.find(({element:a})=>this.isVisible(a))??n[0]}nearestBoundsMatch(n,a){let s,c=Number.POSITIVE_INFINITY;for(let l of n){if(!l.element.bounds)continue;let u=this.boundsDistance(l.element.bounds,a);if(u<c)s=l,c=u}return s??this.firstVisibleOrFirst(n)}findIndexByValue(n,a,s,{value:c,caseInsensitive:l=!1}){let u=l?c.toLowerCase():c,d=n.flatMap((m,f)=>{let g=s(m);if(!g)return[];return(l?g.toLowerCase():g)===u?[{element:m,index:f}]:[]});if(d.length===1)return d[0].index;let p=a.bounds;if(!p)return null;return d.find(({element:m})=>this.boundsMatch(m,p))?.index??null}getResourceId(n){let a=n["resource-id"]??n.resourceId;return typeof a==="string"&&a.length>0?a:void 0}getContentDesc(n){let a=n["content-desc"]??n.contentDesc;return typeof a==="string"&&a.length>0?a:void 0}getTestTag(n){let a=n["test-tag"]??n.testTag;return typeof a==="string"&&a.length>0?a:void 0}getText(n){return typeof n.text==="string"&&n.text.length>0?n.text:void 0}isVisible(n){if(!n.bounds)return!1;let a=n.bounds.right-n.bounds.left,s=n.bounds.bottom-n.bounds.top;return a>0&&s>0}boundsMatch(n,a){if(!n.bounds)return!1;return n.bounds.left===a.left&&n.bounds.top===a.top&&n.bounds.right===a.right&&n.bounds.bottom===a.bottom}boundsDistance(n,a){let s=(n.left+n.right)/2,c=(n.top+n.bottom)/2,l=(a.left+a.right)/2,u=(a.top+a.bottom)/2;return(s-l)**2+(c-u)**2}}class x{detectPlatform(n){if(!n)return e.warn("[DeviceDetection] Empty device ID provided, defaulting to Android"),"android";let a=/^emulator-\d+$/;if($a(n))return e.info(`[DeviceDetection] Detected iOS device: ${n}`),"ios";if(a.test(n))return e.info(`[DeviceDetection] Detected Android emulator: ${n}`),"android";return e.info(`[DeviceDetection] Device ID pattern suggests Android device: ${n}`),"android"}isiOSDevice(n){return this.detectPlatform(n)==="ios"}isAndroidDevice(n){return this.detectPlatform(n)==="android"}static detectPlatform=(n)=>new x().detectPlatform(n);static isiOSDevice=(n)=>new x().isiOSDevice(n);static isAndroidDevice=(n)=>new x().isAndroidDevice(n)}class S extends Error{}class T extends t{}class I{accessibilityService;constructor(n){this.accessibilityService=n}async getAccessibilityHierarchy(){return this.accessibilityService.getAccessibilityHierarchy(void 0,{skipWaitForFresh:!1,disableAllFiltering:!0})}async requestTraversalOrder(){return this.accessibilityService.requestTraversalOrder()}async requestCurrentFocus(){return this.accessibilityService.requestCurrentFocus()}async requestAction(n,a,s){return this.accessibilityService.requestAction(n,a,void 0,{signal:s})}async requestNodeAction(n,a,s){return this.accessibilityService.requestNodeAction(n,a,{signal:s})}async supportsNodeActionSelectors(){return this.accessibilityService.supportsNodeActionSelectors()}}class B{createDriver(n){return new I(E.getInstance(n))}}var fe="Request time budget exhausted during focus navigation.";function M(n,a){if(n instanceof S||bt(n)||a<=0)return n;let s=r(n);return new S(`${s.endsWith(".")?s:`${s}.`} Focus navigation partially applied: ${a} accessibility-focus request${a===1?"":"s"} already moved the TalkBack cursor and the target was not activated. Observe before retrying; do not retry automatically.`,{cause:n})}function R(n,a,s){try{o(n)}catch(l){throw M(l,s)}let c=oo()?.getDeadlineMs?.();if(c!==void 0&&a.now()>=c)throw M(Error(fe),s)}function ge(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}function W(n){return n.map(ge).sort().join(`
|
|
4
|
+
`)}class N{static DEFAULT_FOCUS_SETTLE_MS=100;static FOCUS_READBACK_BOUND_MS=500;matcher;timer;driverFactory;deviceResolver;constructor(n={}){this.matcher=n.matcher??new D,this.timer=n.timer??i,this.driverFactory=n.driverFactory??new B,this.deviceResolver=n.deviceResolver??this.resolveDevice}async navigateToElement(n,a,s={}){let c=me(s.signal),l={focusRequests:0};try{return await this.runNavigation(n,a,{...s,signal:c,onFocusRequested:()=>{l.focusRequests+=1,s.onFocusRequested?.()}},l)}catch(u){throw c?.aborted?M(u,l.focusRequests):u}}async runNavigation(n,a,s,c){let{signal:l}=s,u=this.deviceResolver(n);if(u.platform!=="android")throw new t("TalkBack focus navigation is only supported on Android devices.");let d=this.driverFactory.createDriver(u);R(l,this.timer,c.focusRequests);let p=await this.verifyNavigationState(d,a,!1,l);if(s.onFocusObserved?.(p.currentFocus,p.orderedElements),p.reachedTarget)return!0;let m=p.targetIndex===null?void 0:p.orderedElements[p.targetIndex];if(!m)throw new T(`Target not found in the accessibility traversal (${this.describeSelector(a)}). Use observe to inspect elements and the diagnostics returned by tapOn/waitFor failures.`+this.describeTraversalTruncation(p));await this.requestFocus(d,m,p.orderedElements,{options:s,progress:c});let f=await this.readCursorAfterFocusRequest(d,a,s,c.focusRequests);if(s.onFocusObserved?.(f.currentFocus,f.orderedElements),f.reachedTarget)return!0;throw this.unreachedTargetError(p,f,a)}async readCursorAfterFocusRequest(n,a,s,c){let{signal:l}=s,u=Math.max(0,s.focusSettleMs??N.DEFAULT_FOCUS_SETTLE_MS),d=u>0?Math.max(1,Math.ceil(N.FOCUS_READBACK_BOUND_MS/u)):1,p;for(let m=1;;m+=1){if(u>0)await P(this.timer.sleep(u),l);if(R(l,this.timer,c),p=await this.verifyNavigationState(n,a,!0,l),p.reachedTarget||m>=d)return p}}async requestFocus(n,a,s,{options:c,progress:l}){let{signal:u}=c,d=yi(a);if(!d)throw new T("The target has no resource-id, test tag or unique id, so the TalkBack cursor cannot be moved onto it without a touch gesture.");let p=G(d,s)??await ng(d,n,a);if(p)throw new T(`The TalkBack cursor cannot be moved onto the target: ${p}.`);R(u,this.timer,l.focusRequests),c.displayFence?.assertCurrent(),c.onFocusRequested?.();let m=await P(ca(d)?n.requestNodeAction("focus",d,u):n.requestAction("focus",d.resourceId,u),u);if(!m.success)throw new t(`Could not move the TalkBack cursor onto the target: ${m.error??"ACTION_ACCESSIBILITY_FOCUS failed"}. No tap was sent.`)}unreachedTargetError(n,a,s){let c=this.describeSelector(s);if(W(n.orderedElements)!==W(a.orderedElements))return new t(`The screen changed while moving the TalkBack cursor onto the target (${c}), and the cursor is not on it. No tap was sent. Observe the new screen and resolve the target again.`);let l=a.currentFocus?this.describeFocus(a.currentFocus):"no element has accessibility focus";return new t(`The TalkBack cursor did not move onto the target (${c}) after the focus request; ${l}. No tap was sent. Observe before retrying.`)}resolveDevice(n){let a=x.detectPlatform(n);return{name:n,deviceId:n,platform:a}}async verifyNavigationState(n,a,s,c){let l=await P(n.requestTraversalOrder(),c);if(l.error){let f=`Failed to get traversal order: ${l.error}`;throw s?new t(`${f}. The focus request may have moved the cursor; no tap was sent.`):new T(f)}let u=l.elements??[],d=this.matcher.findTargetIndex(u,a),p=null;if(l.focusedIndex!==null&&l.focusedIndex!==void 0)p=u[l.focusedIndex]??null;if(!p){let f=await P(n.requestCurrentFocus(),c);if(f.error)e.warn(`[FocusNavigation] Failed to get current focus: ${f.error}`);else p=f.focusedElement??null}let m=p?this.matcher.matchesFocusedTarget(p,u,a):!1;return{orderedElements:u,currentFocus:p,targetIndex:d,reachedTarget:m,truncationReasons:l.truncationReasons}}describeTraversalTruncation(n){return n.truncationReasons?.includes("max_children")?" the accessibility traversal was truncated (max_children); the target may be beyond the cap.":""}describeFocus(n){let a=n.text||n["content-desc"]||n["resource-id"];return a?`focus is on "${a}"`:"focus is on another element"}describeSelector(n){let a=[];if(n.resourceId)a.push(`resourceId="${n.resourceId}"`);if(n.text)a.push(`text="${n.text}"`);if(n.contentDesc)a.push(`contentDesc="${n.contentDesc}"`);if(n.testTag)a.push(`testTag="${n.testTag}"`);return a.length>0?a.join(", "):"unknown selector"}}var he=500,$W="TalkBack activation is unconfirmed: the coordinate gesture completed, but the element may only have received accessibility focus. Observe the result before retrying.";function be(n,a){return Array.isArray(n.actions)&&n.actions.includes(a)}class Iv{matcher;executor;timer;constructor(n={}){this.matcher=n.matcher??new D,this.executor=n.executor??new N({matcher:this.matcher,timer:n.timer,driverFactory:n.driverFactory}),this.timer=n.timer??i}async executeTap(n,a,s,{fence:c,signal:l}={}){let u={reachable:!1,traversalOrder:[],focusTrapDetected:!1},d=a?.["resource-id"],p=a.text,m=a["content-desc"];if(!d&&!p&&!m)return{success:!1,method:"focus-navigation",error:"Element has no resource-id, text, or content-desc for navigation",screenReaderNavigation:u};let f=this.createFocusSelector({resourceId:d,elementText:p,elementContentDesc:m,bounds:a.bounds}),g=me(l),b=0,y=[];try{if(!await this.executor.navigateToElement(n,f,{displayFence:c,signal:g,onFocusObserved:(w,X)=>{y=[...X],this.appendTraversalFocus(u,w)},onFocusRequested:()=>{b+=1}}))throw new t("Focus navigation did not reach target element")}catch(k){if(k instanceof T)return e.warn(`[TalkBackTapStrategy] Focus navigation unavailable: ${k.message}`,k),{success:!1,method:"focus-navigation",error:k.message,screenReaderNavigation:u};throw k}u.reachable=!0,e.info("[TalkBackTapStrategy] Focus navigation successful, activating element");let h=()=>R(g,this.timer,b);return h(),{...await this.activateElement(a,s,{fence:c,orderedElements:y,assertLive:h}),screenReaderNavigation:u}}createFocusSelector({resourceId:n,elementText:a,elementContentDesc:s,bounds:c}){return{...n?{resourceId:n}:{},...a?{text:a}:{},...s?{contentDesc:s}:{},bounds:c}}appendTraversalFocus(n,a){if(!a)return;let s=n.traversalOrder.at(-1);if(!s||this.focusSignature(s)!==this.focusSignature(a))n.traversalOrder.push(a)}focusSignature(n){let a=n.bounds;return[n["resource-id"]??"",n["content-desc"]??"",n.text??"",a?`${a.left},${a.top},${a.right},${a.bottom}`:""].join("|")}async executeDirectActivation(n,a,s={}){let c=await F(n,()=>a.getAccessibilityHierarchy?.()??Promise.resolve(null),s),l=c.element!==n?{element:c.element}:{};n=c.element;let u={supportsNodeActionSelectors:()=>a.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>c.hierarchy},d=yi(n);if(!d)return{success:!1,...l,method:"accessibility-action",error:"Element has no stable selector for direct accessibility activation"};let p=await ng(d,u,n);if(p)return{success:!1,...l,method:"accessibility-action",error:p};let m=ca(d)?await a.requestNodeAction("click",d):await a.requestAction("click",d.resourceId);if(m.success)return e.info("[TalkBackTapStrategy] Direct activation via ACTION_CLICK succeeded"),{success:!0,...l,method:"accessibility-action"};if(m.dispatched&&m.acknowledged!==!0)throw Sn(m.error);return{success:!1,...l,method:"accessibility-action",error:m.error??"ACTION_CLICK failed"}}async executeCoordinateFallback(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=a==="longPress"?s:50;if(a==="doubleTap"){p?.assertCurrent();let g=await this.dispatchDriverTap(c,u,d,{durationMs:m,doubleTap:!0});if(!g.success)return{success:!1,method:"coordinate-fallback",error:`Double tap failed: ${g.error}`,unsupportedCapability:g.unsupportedCapability,completedTaps:0};return{success:!0,method:"coordinate-fallback",completedTaps:2,warnings:[$W]}}p?.assertCurrent();let f=await this.dispatchDriverTap(c,u,d,{durationMs:m});if(!f.success)return{success:!1,method:"coordinate-fallback",error:f.error};if(a==="tap")return{success:!1,method:"coordinate-fallback",error:"A single coordinate touch only moves TalkBack focus and does not activate the element"};return{success:!0,method:"coordinate-fallback"}}async executePreciseTap(n,a,s,c){c?.assertCurrent();let l=await this.dispatchDriverTap(s,n,a,{durationMs:50});if(!l.success)return{success:!1,method:"coordinate-fallback",error:`Focus tap failed: ${l.error}`,focusCompleted:!1,completedTaps:0};return await this.timer.sleep(he),{...await this.executeCoordinateFallback({x:n,y:a},"doubleTap",50,{driver:s,fenceOptions:{displayFence:c}}),focusCompleted:!0}}async executeLongPress(n,a,s,{driver:c,fenceOptions:l={}}){let{x:u,y:d}=n,p=l.displayFence,m=await F(s,()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null),l);if(m.element!==s){let y=m.element.bounds;u=Math.round((y.left+y.right)/2),d=Math.round((y.top+y.bottom)/2)}let f=m.element!==s?{element:m.element}:{};s=m.element;let g={supportsNodeActionSelectors:()=>c.supportsNodeActionSelectors(),getAccessibilityHierarchy:async()=>m.hierarchy},b=yi(s);if(b){let y=await ng(b,g,s);if(y)return e.info(`[TalkBackTapStrategy] ${y}`),{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f};let h=ca(b)?await c.requestNodeAction("long_click",b):await c.requestAction("long_click",b.resourceId);if(h.success)return e.info("[TalkBackTapStrategy] Long press via ACTION_LONG_CLICK succeeded"),{success:!0,...f,method:"accessibility-action"};if(h.dispatched&&h.acknowledged!==!0)throw Sn(h.error);if(await MT({advertised:be(s,"long_click"),error:h.error,needsNodeSelector:ca(b),selected:s,readHierarchy:()=>c.getAccessibilityHierarchy?.()??Promise.resolve(null)}))return{success:!1,...f,method:"accessibility-action",error:h.error??"ACTION_LONG_CLICK failed",semanticActionFailure:!0};e.warn(`[TalkBackTapStrategy] ACTION_LONG_CLICK failed (${h.error}), falling back to coordinate gesture`)}return{...await this.executeCoordinateFallback({x:u,y:d},"longPress",a,{driver:c,fenceOptions:{displayFence:p}}),...f}}async activateElement(n,a,{fence:s={assertCurrent:()=>{}},orderedElements:c,assertLive:l}){let u=n["resource-id"],d=await this.resolveActivationCenter(n,a,c),p=50;if(l(),!d){if(u){e.warn("[TalkBackTapStrategy] Activation target has no bounds; using ACTION_CLICK fallback");let f=await this.executeDirectActivation(n,a);if(f.success)return{success:!0,method:"accessibility-action"};return{success:!1,method:"focus-navigation",error:`Activation failed: target has no bounds and ACTION_CLICK failed (${f.error??"unknown"})`}}return{success:!1,method:"focus-navigation",error:"Activation failed: target has no bounds and no resource-id for ACTION_CLICK"}}s.assertCurrent();let m=await this.dispatchDriverTap(a,d.x,d.y,{durationMs:50,doubleTap:!0});if(!m.success){if(l(),u){if(e.warn("[TalkBackTapStrategy] Double-tap activation failed, trying ACTION_CLICK fallback"),!(await this.executeDirectActivation(n,a)).success)return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap and ACTION_CLICK both failed",unsupportedCapability:m.unsupportedCapability};return{success:!0,method:"accessibility-action"}}return{success:!1,method:"focus-navigation",error:"Activation failed: double-tap failed",unsupportedCapability:m.unsupportedCapability}}return e.info("[TalkBackTapStrategy] Element activation gesture sent via focus navigation"),{success:!0,method:"focus-navigation",warnings:[$W]}}async dispatchDriverTap(n,a,s,{durationMs:c,doubleTap:l=!1}){let u=!1,d;try{let p=()=>{u=!0};d=l?await n.requestDoubleTapCoordinates(a,s,p):await n.requestTapCoordinates({x:a,y:s,duration:c,onDispatch:p})}catch(p){if(u)throw Sn(r(p));if(p instanceof Ee||p instanceof t)throw p;return e.warn(`[TalkBackTapStrategy] Coordinate tap failed before dispatch: ${r(p)}`,p),{success:!1,totalTimeMs:0,error:r(p)}}if(!d.success&&u)throw Sn(d.error);return d}getElementCenter(n){if(!n.bounds)return null;return{x:Math.round((n.bounds.left+n.bounds.right)/2),y:Math.round((n.bounds.top+n.bounds.bottom)/2)}}async resolveActivationCenter(n,a,s){try{let c=await a.requestCurrentFocus(),l=c.focusedElement;if(l?.bounds&&!c.error){let u=this.createFocusSelector({resourceId:C(n["resource-id"]),elementText:C(n.text),elementContentDesc:C(n["content-desc"]),bounds:n.bounds}),d=await this.activationTraversal(a,s,u);if(this.matcher.matchesFocusedTarget(l,d,u))return this.getElementCenter(l);throw new t("TalkBack focus no longer matches the selected activation target.")}}catch(c){if(c instanceof t)throw c;e.debug(`[TalkBackTapStrategy] Could not read current focus for activation: ${c}`)}return this.getElementCenter(n)}async activationTraversal(n,a,s){let c;try{c=await n.requestTraversalOrder()}catch(d){if(d instanceof Ee)throw d;e.warn(`[TalkBackTapStrategy] Could not refresh activation traversal: ${r(d)}`,d)}if(!c?.error&&c?.elements?.length)return c.elements;let l=a.filter((d)=>this.matcher.matchesSelector(d,s));if((l.length?l:a.filter((d)=>this.matcher.matchesSelector(d,s,{partialMatch:!0}))).length===1)return a;throw new t("Cannot verify the selected TalkBack activation target: fresh traversal is unavailable or empty.")}}function Kte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,perf:a,signal:s}}function Gte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,deadlineMs:s?.requestDeadlineMs}}function Yte(n,a,s){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a,planContext:s}}function zL(n){return n===void 0?void 0:{requestDeadlineMs:n}}function ye(n){return typeof n==="object"&&n!==null&&"aborted"in n}function ig(n){if(n===void 0||ye(n))return{signal:n};return n}function Wo(n,a){if(typeof n==="object"&&n!==null)return n;return{progress:n,signal:a}}var A=(n)=>n===!0||n==="true";function La(n){return A(n.focused)||A(n.isFocused)||A(n["has-keyboard-focus"])||A(n["accessibility-focused"])||A(n.accessibilityFocused)}class YC{parser;constructor(n=new K){this.parser=n}findFocusedTextInput(n){let a=[this.parser.extractRootNodes(n),...this.parser.extractWindowRootGroups(n,"topmost-first")];for(let s of a){let c=this.findInRoots(s);if(c)return c}return null}findInRoots(n){for(let a of n){let s=null;if(this.parser.traverseNode(a,(c)=>{if(s)return;let l=this.parser.extractNodeProperties(c),u=l.class||l.className;if(A(l.focused)&&u&&_g.some((d)=>u.includes(d)))s=this.parser.parseNodeBounds(c)}),s)return s}return null}}
|
|
5
|
+
export{MT,Qh,Vo,BW,KC,wc,_3,Ma,Na,eg,Bm,NT,Fa,Tw,x3,C3,tg,rg,GC,jte,Sn,kw,Ew,Iw,WL,yi,ca,ng,$W,Iv,Kte,Gte,Yte,zL,ig,Wo,La,YC};
|
|
6
|
+
|
|
7
|
+
//# debugId=CA49E5AC96D9324364756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{LD,_p,hj,Dk,Ok,oi}from"./chunk-r5bxavdx.js";import"./chunk-yf7ympyz.js";import"./chunk-z637nqg8.js";import"./chunk-58wzr3mt.js";export{oi as AndroidEmulatorClient,Dk as AndroidEmulatorUnavailableError,Ok as AndroidOfflineProbeError,_p as boundedEmulatorOutputTail,hj as emulatorLaunchOutputSource,LD as resetAndroidInventoryEnrichmentCache};
|
|
3
|
+
|
|
4
|
+
//# debugId=60207B94FFFD472F64756E2164756E21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Zi,Y,dt,M,Ot,rd,oB,tR,ul,jo,_,k}from"./chunk-h3n4adc6.js";import{e}from"./chunk-z8t0v07j.js";import{De,wt}from"./chunk-4fgdhcwx.js";import{bo,VF,tv}from"./chunk-0w1spptt.js";import{nc}from"./chunk-vefd8qee.js";import{Fy,zl}from"./chunk-4xd6zs3y.js";import{fh,J0,X0}from"./chunk-0rjm4nx7.js";import{r,yt}from"./chunk-9rkfyt6q.js";function A(t){return t.success&&t.focusVerified===!0}function g(t,n){let s=t.matchedText??n.text??n.textAny?.[0]??n.elementId??n.testTag;return s?JSON.stringify(s):"for the selector"}var I=(t)=>({focus:async(n,s)=>{let i=await new nc(t).execute({...n,action:"focus"},{signal:s});return{success:i.success,error:i.error,focusVerified:i.focusVerified===!0,matchedId:i.selectedElement?.resourceId,matchedText:i.selectedElement?.text}}});function u(t,n){if(n?.retryable!==!1)t?.throwIfAborted()}async function w(t,n,s){if(!n)return;let i;try{let d=await t.requestImeAction(n);if(u(s),!d.success)i=d.error||"unknown error"}catch(d){u(s),i=r(d)||"unknown error"}if(i===void 0)return;return e.warn(`[InputText] CtrlProxy iOS IME action '${n}' failed: ${i}`),tv(n,i)}async function v({device:t,observeScreen:n,timer:s},i,d,o){u(o);let p=Date.now();e.debug(`[InputText] iOS begin textLength=${i.length} imeAction=${d??"none"}`);let c=_.getInstance(t),a=await fh({observer:n,timer:s,signal:o});u(o);let l=jo(),y=await c.requestSetText(i,{...l===void 0?{}:{deadlineMs:l},timeoutMs:ul(i,l===void 0?void 0:l-s.now()),abortSignal:o});if(!y.success)return u(o,y),e.error(`[InputText] CtrlProxy iOS setText failed: ${y.error} totalMs=${Date.now()-p}`),{success:!1,text:i,error:await X0(y.error,i,a,{observer:n,timer:s,signal:o}),...y.retryable===!1?{retryable:!1}:{},method:"a11y"};e.debug(`[InputText] iOS setText ok totalMs=${Date.now()-p}`);let f=await J0(i,a,{observer:n,timer:s,signal:o});if(!f.success)return{success:!1,text:i,error:f.error,method:"a11y"};let m=await w(c,d,o);if(m!==void 0)return{success:!1,text:i,method:"a11y",error:m};return{success:!0,text:i,imeAction:d,method:"a11y",...f.warning?{warnings:[f.warning]}:{}}}function E(t,n){for(let s of n)if(s.length>0&&t.includes(s))return"eventAll";return}var S=100,F=(t,n)=>{let s=new bo(t,{adbFactory:n});return{close:(i)=>s.execute("close",i)}};function K(t={},n={}){return{...t,dismissKeyboard:t.dismissKeyboard??!1,signal:n.signal}}class cq extends De{androidApiLevel;targetFocuser;keyboardCloserFactory;constructor(t,n=null,s={}){super(t,{adb:n,timer:s.timer,displayFence:s});this.device=t,this.keyboardCloserFactory=s.keyboardCloserFactory??F,this.targetFocuser=(s.targetFocuserFactory??I)(t)}get testHooks(){return{executeAndroidTextInput:(t,n)=>this.executeAndroidTextInput(t,n),executeKeyEventPlan:(t,n)=>this.executeKeyEventPlan(t,n),executeiOSTextInput:(t,n,s)=>v(this.iosTextDeps(),t,n,s)}}iosTextDeps(){return{device:this.device,observeScreen:this.observeScreen,timer:this.timer}}async execute(t,n,s){Fy(this.device.platform,"text input");let{imeAction:i,dismissKeyboard:d,mode:o,selector:p,signal:c}=K(n,s),a=Y();if(a.serial("inputText"),t===void 0||t===null)return a.end(),{success:!1,text:"",error:"No text provided",method:"a11y"};let l=o??"a11y";if(this.device.platform==="android"&&o===void 0){let m=E(t,M.getEventAllMarkers());if(m)l=m,e.debug("[InputText] auto-promoted a11y -> eventAll (text matched a configured event-all marker)")}let y={};if(p){u(c);let m=await this.targetFocuser.focus(p,c);if(!A(m))return a.end(),{success:!1,text:t,error:m.error??`Failed to confirm focus on editable input ${g(m,p)} before typing`,method:this.device.platform==="android"?l:"a11y"};y={matchedId:m.matchedId,matchedText:m.matchedText}}u(c);let f=await this.observedInteraction(async()=>{try{switch(u(c),this.device.platform){case"android":return await a.track("androidTextInput",()=>this.executeAndroidTextInput(t,{imeAction:i,dismissKeyboard:d,mode:l,signal:c}));case"ios":return await a.track("iOSTextInput",()=>v(this.iosTextDeps(),t,i,c));default:throw a.end(),yt(this.device.platform,"input text")}}catch(m){u(c),a.end();let x=r(m);return e.warn(`[InputText] text input failed (mode=${l}): ${x}`,m),{success:!1,text:t,error:`Failed to send text input: ${x}`,method:this.device.platform==="android"?l:"a11y"}}},{usesObservationForResolution:!1,changeExpected:!0,tolerancePercent:0,timeoutMs:wt.lifecycle,perf:a,signal:c,skipUiStability:!0});return u(c,f),{...f,...y}}async executeAndroidTextInput(t,n={}){let{imeAction:s,dismissKeyboard:i=!1,mode:d="a11y",signal:o}=n;if(u(o),d==="eventLast")return this.executeAndroidEventLastTextInput(t,s,i,o);if(d==="eventAll")return this.executeAndroidEventAllTextInput(t,s,i,o);if(d==="append")return this.executeAndroidAppendTextInput(t,{imeAction:s,dismissKeyboard:i,signal:o});let p=k.getInstance(this.device,this.adbFactory),c=await this.withTextDispatch(()=>p.requestSetText(t));if(u(o),c.success){if(e.info(`[InputText] Text input via accessibility service: ${c.totalTimeMs}ms`),s)await this.executeImeAction(s,o);let a=i?await this.dismissKeyboardEpilogue(o):{};return{success:!0,text:t,imeAction:s,method:"a11y",...a}}return e.warn(`[InputText] Accessibility service setText failed: ${c.error}`),{success:!1,text:t,error:`Accessibility service setText failed: ${c.error}`,method:"a11y"}}async a11yFallback(t,n){return{...await this.executeAndroidTextInput(t,{...n,mode:"a11y"}),method:"a11y"}}async executeAndroidEventLastTextInput(t,n,s=!1,i){u(i);let d=this.findLastPrintableAsciiNonWhitespace(t);if(!d)return e.info("[InputText] eventLast requested but no printable non-whitespace ASCII character was found; using a11y"),this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let{index:o,char:p}=d,c=t.slice(0,o),a=t.slice(o+1),l=await this.getAsciiKeyEventPlan(p,void 0,i);if(u(i),!l)return e.info(`[InputText] eventLast could not map ASCII character ${JSON.stringify(p)} to a key event; using a11y`),this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let y=k.getInstance(this.device,this.adbFactory),f=await this.withTextDispatch(()=>y.requestSetText(c));if(u(i),!f.success)return this.setTextFailure(t,{stage:"eventLast prefix",phase:"before real key event",cause:f.error,method:"eventLast"});if(await this.executeKeyEventPlan(l,{signal:i}),a.length>0){let x=await this.withTextDispatch(()=>y.requestSetText(t));if(u(i),!x.success)return this.setTextFailure(t,{stage:"eventLast final",phase:"after real key event",cause:x.error,method:"eventLast"})}if(n)await this.executeImeAction(n,i);let m=s?await this.dismissKeyboardEpilogue(i):{};return{success:!0,text:t,imeAction:n,method:"eventLast",...m}}async executeAndroidEventAllTextInput(t,n,s=!1,i){u(i);let d=Array.from(t);if(!await this.hasAsciiKeyEventPlan(d,i))return this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let o=k.getInstance(this.device,this.adbFactory),p=await this.withTextDispatch(()=>o.requestSetText(""));if(u(i),!p.success)return this.setTextFailure(t,{stage:"eventAll initial clear",phase:"before eventAll input",cause:p.error,method:"eventAll"});let c=await this.sendAndroidEventAllCharacters(t,d,o,i);if(c)return c;if(s){let l=await this.withTextDispatch(()=>o.requestSetText(t));if(u(i),!l.success)return this.setTextFailure(t,{stage:"eventAll final",phase:"after eventAll input",cause:l.error,method:"eventAll"})}if(n)await this.executeImeAction(n,i);let a=s?await this.dismissKeyboardEpilogue(i):{};return{success:!0,text:t,imeAction:n,method:"eventAll",...a}}async sendAndroidEventAllCharacters(t,n,s,i){let d="";for(let o=0;o<n.length;o++){u(i);let p=n[o]??"",c=await this.getAsciiKeyEventPlan(p,void 0,i);if(c){await this.executeKeyEventPlan(c,{signal:i}),d+=p;continue}let a=p;while(o+1<n.length&&!await this.getAsciiKeyEventPlan(n[o+1]??"",void 0,i))u(i),o++,a+=n[o]??"";d+=a;let l=await this.withTextDispatch(()=>s.requestSetText(d));if(u(i),!l.success)return this.setTextFailure(t,{stage:"eventAll unsupported text run",phase:"during eventAll input",cause:l.error,method:"eventAll"})}return}async appendText(t,n={}){return this.executeAndroidAppendTextInput(t,n)}async executeAndroidAppendTextInput(t,n={}){let{imeAction:s,timeoutMs:i,beforeKeyEvents:d,signal:o,onDispatch:p}=n;u(o);let c=this.createBudget(i),a=await this.planAppendKeyEvents(t,c,i,o);if(a.error)return this.appendFailure(t,a.error,0);let l=await this.typeAppendKeyEvents(a.plans,{remaining:c,timeoutMs:i},{beforeKeyEvents:d,signal:o,onDispatch:p});if(l.error)return this.appendFailure(t,l.error,l.charsSent,l.failureSource);if(s)await this.executeImeAction(s,o);let y=n.dismissKeyboard?await this.dismissKeyboardEpilogue(o):{};return{success:!0,text:t,imeAction:s,method:"append",charsSent:l.charsSent,...y}}async planAppendKeyEvents(t,n,s,i){u(i);let d=Array.from(t),o=d.some((a)=>oB(a)),p=!1;if(o){let a=n();if(a!==void 0&&a<=0)return{plans:[],error:this.appendBudgetExceeded(s,"resolving key events")};p=await this.supportsAndroidInputKeyCombination(a,i)}let c=[];for(let a of d){let l=tR(a,p);if(!l)return{plans:c,error:`append cannot type ${JSON.stringify(a)} with Android key events`};c.push(l)}return{plans:c}}async typeAppendKeyEvents(t,n,s){let{remaining:i,timeoutMs:d}=n,{beforeKeyEvents:o,signal:p,onDispatch:c}=s,a=0;for(let l of t){u(p);let y=i();if(y!==void 0&&y<=0)return{charsSent:a,error:this.appendBudgetExceeded(d,"typing")};let f,m,x=a===0?async(T)=>{try{let h=await o?.(T);if(u(p),h&&!h.success)f=h.error??"Frame context is stale or unavailable; observe a fresh frame before retrying",m=h.failureSource}catch(h){f=`append frame context validation failed: ${r(h)}`}let b=i();if(f===void 0&&b!==void 0&&b<=0)f=this.appendBudgetExceeded(d,"typing");if(f)throw Error(f);u(p),c?.()}:void 0;try{await this.executeKeyEventPlan(l,{timeoutMs:y,noRetry:!0,beforeDispatch:x,signal:p})}catch(T){if(u(p),f)return{charsSent:a,error:f,...m!==void 0?{failureSource:m}:{}};let b=r(T);return e.warn(`[InputText] append key event failed after ${a} char(s): ${b}`,T),{...T instanceof dt?{}:{charsSent:a},error:`append key event failed: ${b}`}}a+=1}return{charsSent:a}}async dismissKeyboardEpilogue(t){let n;try{n=await this.keyboardCloserFactory(this.device,this.adbFactory).close(t)}catch(i){u(t);let d=r(i);return e.warn(`[InputText] keyboard dismissal threw: ${d}`,i),zl({keyboardDismissed:!1},`keyboard dismissal failed: ${d}`)}if(u(t),n.success)return{keyboardDismissed:!0};let s=n.error??n.message??"unknown error";return zl({keyboardDismissed:!1},`keyboard dismissal failed: ${s}`)}createBudget(t){if(t===void 0)return()=>{return};let n=this.timer.now()+t;return()=>n-this.timer.now()}appendBudgetExceeded(t,n){return`append exceeded its ${t}ms budget while ${n}`}appendFailure(t,n,s,i){return{success:!1,text:t,error:n,method:"append",...s!==void 0?{charsSent:s}:{},...i!==void 0?{failureSource:i}:{}}}setTextFailure(t,n){let{stage:s,phase:i,cause:d,method:o}=n;return e.warn(`[InputText] ${s} setText failed: ${d}`),{success:!1,text:t,error:`Accessibility service setText failed ${i}: ${d}`,method:o}}findLastPrintableAsciiNonWhitespace(t){for(let n=t.length-1;n>=0;n--){let s=t[n];if(!s)continue;let i=s.charCodeAt(0);if(i>=33&&i<=126&&!/\s/.test(s))return{index:n,char:s}}return null}async hasAsciiKeyEventPlan(t,n){for(let s of t)if(await this.getAsciiKeyEventPlan(s,void 0,n))return!0;return!1}async getAsciiKeyEventPlan(t,n,s){u(s);let i=await this.supportsAndroidInputKeyCombination(n,s);return u(s),tR(t,i)}async supportsAndroidInputKeyCombination(t,n){let s=await this.getAndroidApiLevel(t,n);return s!==null&&s>=rd}async getAndroidApiLevel(t,n){if(u(n),this.androidApiLevel!==void 0)return this.androidApiLevel;let s=await Ot(this.adb,t,this.timer);if(u(n),s===null)return null;return this.androidApiLevel=s,s}async withTextDispatch(t){let s=Zi()?.textState?.dispatched();try{return await t()}finally{s?.(!0)}}async executeKeyEventPlan(t,n={}){let{timeoutMs:s,noRetry:i=!1,beforeDispatch:d,signal:o}=n;for(let[p,c]of t.commands.entries()){u(o);let a=c.startsWith("shell input text ")?await this.getAndroidApiLevel(s,o):null;await this.withTextDispatch(()=>{let l={timeoutMs:s,noRetry:i,beforeDispatch:p===0?d:void 0,signal:o,waitForProcessSettlementAfterAbort:!0};return c.startsWith("shell input text ")?VF(this.adb,this.timer,c,{...l,apiLevel:a,textLength:t.textLength??1}):this.adb.execute(c.split(" "),l)}),u(o)}}async executeImeAction(t,n){let i={done:"KEYCODE_ENTER",next:"KEYCODE_TAB",search:"KEYCODE_SEARCH",send:"KEYCODE_ENTER",go:"KEYCODE_ENTER",previous:"KEYCODE_SHIFT_LEFT KEYCODE_TAB"}[t];if(i)if(u(n),await this.timer.sleep(S),u(n),i.includes(" ")){let d=i.split(" ");for(let o of d)u(n),await this.withTextDispatch(()=>this.adb.executeCommand(`shell input keyevent ${o}`,{signal:n,waitForProcessSettlementAfterAbort:!0})),u(n)}else await this.withTextDispatch(()=>this.adb.executeCommand(`shell input keyevent ${i}`,{signal:n,waitForProcessSettlementAfterAbort:!0})),u(n)}}
|
|
3
|
-
export{
|
|
2
|
+
import{e}from"./chunk-z637nqg8.js";import{oo,J,mt,N,Ut,gd,o$,OR,El,es,x,E}from"./chunk-r5bxavdx.js";import{mv,du}from"./chunk-vy3bwm1d.js";import{Oe,At}from"./chunk-3xkpk44w.js";import{To,VL,Ev}from"./chunk-zgja5f3p.js";import{gc}from"./chunk-3f3t1x97.js";import{Bh,BF,$F}from"./chunk-thbh3jew.js";import{r,St}from"./chunk-rbpdk7m0.js";function g(t){return t.success&&t.focusVerified===!0}function I(t,n){let s=t.matchedText??n.text??n.textAny?.[0]??n.elementId??n.testTag;return s?JSON.stringify(s):"for the selector"}var w=(t)=>({focus:async(n,s)=>{let i=await new gc(t).execute({...n,action:"focus"},{signal:s});return{success:i.success,error:i.error,focusVerified:i.focusVerified===!0,matchedId:i.selectedElement?.resourceId,matchedText:i.selectedElement?.text}}});function u(t,n){if(n?.retryable!==!1)t?.throwIfAborted()}async function F(t,n,s){if(!n)return;let i;try{let d=await t.requestImeAction(n);if(u(s),!d.success)i=d.error||"unknown error"}catch(d){u(s),i=r(d)||"unknown error"}if(i===void 0)return;return e.warn(`[InputText] CtrlProxy iOS IME action '${n}' failed: ${i}`),Ev(n,i)}async function A({device:t,observeScreen:n,timer:s},i,d,o){u(o);let p=Date.now();e.debug(`[InputText] iOS begin textLength=${i.length} imeAction=${d??"none"}`);let c=x.getInstance(t),a=await Bh({observer:n,timer:s,signal:o});u(o);let l=es(),y=await c.requestSetText(i,{...l===void 0?{}:{deadlineMs:l},timeoutMs:El(i,l===void 0?void 0:l-s.now()),abortSignal:o});if(!y.success)return u(o,y),e.error(`[InputText] CtrlProxy iOS setText failed: ${y.error} totalMs=${Date.now()-p}`),{success:!1,text:i,error:await $F(y.error,i,a,{observer:n,timer:s,signal:o}),...y.retryable===!1?{retryable:!1}:{},method:"a11y"};e.debug(`[InputText] iOS setText ok totalMs=${Date.now()-p}`);let f=await BF(i,a,{observer:n,timer:s,signal:o});if(!f.success)return{success:!1,text:i,error:f.error,method:"a11y"};let m=await F(c,d,o);if(m!==void 0)return{success:!1,text:i,method:"a11y",error:m};return{success:!0,text:i,imeAction:d,method:"a11y",...f.warning?{warnings:[f.warning]}:{}}}function S(t,n){for(let s of n)if(s.length>0&&t.includes(s))return"eventAll";return}var K=100,P=(t,n)=>{let s=new To(t,{adbFactory:n});return{close:(i)=>s.execute("close",i)}};function C(t={},n={}){return{...t,dismissKeyboard:t.dismissKeyboard??!1,signal:n.signal}}class vV extends Oe{androidApiLevel;targetFocuser;keyboardCloserFactory;constructor(t,n=null,s={}){super(t,{adb:n,timer:s.timer,displayFence:s});this.device=t,this.keyboardCloserFactory=s.keyboardCloserFactory??P,this.targetFocuser=(s.targetFocuserFactory??w)(t)}get testHooks(){return{executeAndroidTextInput:(t,n)=>this.executeAndroidTextInput(t,n),executeKeyEventPlan:(t,n)=>this.executeKeyEventPlan(t,n),executeiOSTextInput:(t,n,s)=>A(this.iosTextDeps(),t,n,s)}}iosTextDeps(){return{device:this.device,observeScreen:this.observeScreen,timer:this.timer}}async execute(t,n,s){mv(this.device.platform,"text input");let{imeAction:i,dismissKeyboard:d,mode:o,selector:p,signal:c}=C(n,s),a=J();if(a.serial("inputText"),t===void 0||t===null)return a.end(),{success:!1,text:"",error:"No text provided",method:"a11y"};let l=o??"a11y";if(this.device.platform==="android"&&o===void 0){let m=S(t,N.getEventAllMarkers());if(m)l=m,e.debug("[InputText] auto-promoted a11y -> eventAll (text matched a configured event-all marker)")}let y={};if(p){u(c);let m=await this.targetFocuser.focus(p,c);if(!g(m))return a.end(),{success:!1,text:t,error:m.error??`Failed to confirm focus on editable input ${I(m,p)} before typing`,method:this.device.platform==="android"?l:"a11y"};y={matchedId:m.matchedId,matchedText:m.matchedText}}u(c);let f=await this.observedInteraction(async()=>{try{switch(u(c),this.device.platform){case"android":return await a.track("androidTextInput",()=>this.executeAndroidTextInput(t,{imeAction:i,dismissKeyboard:d,mode:l,signal:c}));case"ios":return await a.track("iOSTextInput",()=>A(this.iosTextDeps(),t,i,c));default:throw a.end(),St(this.device.platform,"input text")}}catch(m){u(c),a.end();let h=r(m);return e.warn(`[InputText] text input failed (mode=${l}): ${h}`,m),{success:!1,text:t,error:`Failed to send text input: ${h}`,method:this.device.platform==="android"?l:"a11y"}}},{usesObservationForResolution:!1,changeExpected:!0,tolerancePercent:0,timeoutMs:At.lifecycle,perf:a,signal:c,skipUiStability:!0});return u(c,f),{...f,...y}}async executeAndroidTextInput(t,n={}){let{imeAction:s,dismissKeyboard:i=!1,mode:d="a11y",signal:o}=n;if(u(o),d==="eventLast")return this.executeAndroidEventLastTextInput(t,s,i,o);if(d==="eventAll")return this.executeAndroidEventAllTextInput(t,s,i,o);if(d==="append")return this.executeAndroidAppendTextInput(t,{imeAction:s,dismissKeyboard:i,signal:o});let p=E.getInstance(this.device,this.adbFactory),c=await this.withTextDispatch(()=>p.requestSetText(t));if(u(o),c.success){if(e.info(`[InputText] Text input via accessibility service: ${c.totalTimeMs}ms`),s)await this.executeImeAction(s,o);let a=i?await this.dismissKeyboardEpilogue(o):{};return{success:!0,text:t,imeAction:s,method:"a11y",...a}}return e.warn(`[InputText] Accessibility service setText failed: ${c.error}`),{success:!1,text:t,error:`Accessibility service setText failed: ${c.error}`,method:"a11y"}}async a11yFallback(t,n){return{...await this.executeAndroidTextInput(t,{...n,mode:"a11y"}),method:"a11y"}}async executeAndroidEventLastTextInput(t,n,s=!1,i){u(i);let d=this.findLastPrintableAsciiNonWhitespace(t);if(!d)return e.info("[InputText] eventLast requested but no printable non-whitespace ASCII character was found; using a11y"),this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let{index:o,char:p}=d,c=t.slice(0,o),a=t.slice(o+1),l=await this.getAsciiKeyEventPlan(p,void 0,i);if(u(i),!l)return e.info(`[InputText] eventLast could not map ASCII character ${JSON.stringify(p)} to a key event; using a11y`),this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let y=E.getInstance(this.device,this.adbFactory),f=await this.withTextDispatch(()=>y.requestSetText(c));if(u(i),!f.success)return this.setTextFailure(t,{stage:"eventLast prefix",phase:"before real key event",cause:f.error,method:"eventLast"});if(await this.executeKeyEventPlan(l,{signal:i}),a.length>0){let h=await this.withTextDispatch(()=>y.requestSetText(t));if(u(i),!h.success)return this.setTextFailure(t,{stage:"eventLast final",phase:"after real key event",cause:h.error,method:"eventLast"})}if(n)await this.executeImeAction(n,i);let m=s?await this.dismissKeyboardEpilogue(i):{};return{success:!0,text:t,imeAction:n,method:"eventLast",...m}}async executeAndroidEventAllTextInput(t,n,s=!1,i){u(i);let d=Array.from(t);if(!await this.hasAsciiKeyEventPlan(d,i))return this.a11yFallback(t,{imeAction:n,dismissKeyboard:s,signal:i});let o=E.getInstance(this.device,this.adbFactory),p=await this.withTextDispatch(()=>o.requestSetText(""));if(u(i),!p.success)return this.setTextFailure(t,{stage:"eventAll initial clear",phase:"before eventAll input",cause:p.error,method:"eventAll"});let c=await this.sendAndroidEventAllCharacters(t,d,o,i);if(c)return c;if(s){let l=await this.withTextDispatch(()=>o.requestSetText(t));if(u(i),!l.success)return this.setTextFailure(t,{stage:"eventAll final",phase:"after eventAll input",cause:l.error,method:"eventAll"})}if(n)await this.executeImeAction(n,i);let a=s?await this.dismissKeyboardEpilogue(i):{};return{success:!0,text:t,imeAction:n,method:"eventAll",...a}}async sendAndroidEventAllCharacters(t,n,s,i){let d="";for(let o=0;o<n.length;o++){u(i);let p=n[o]??"",c=await this.getAsciiKeyEventPlan(p,void 0,i);if(c){await this.executeKeyEventPlan(c,{signal:i}),d+=p;continue}let a=p;while(o+1<n.length&&!await this.getAsciiKeyEventPlan(n[o+1]??"",void 0,i))u(i),o++,a+=n[o]??"";d+=a;let l=await this.withTextDispatch(()=>s.requestSetText(d));if(u(i),!l.success)return this.setTextFailure(t,{stage:"eventAll unsupported text run",phase:"during eventAll input",cause:l.error,method:"eventAll"})}return}async appendText(t,n={}){return this.executeAndroidAppendTextInput(t,n)}async executeAndroidAppendTextInput(t,n={}){let{imeAction:s,timeoutMs:i,beforeKeyEvents:d,signal:o,onDispatch:p}=n;u(o);let c=this.createBudget(i),a=await this.planAppendKeyEvents(t,c,i,o);if(a.error)return this.appendFailure(t,a.error,0);let l=await this.typeAppendKeyEvents(a.plans,{remaining:c,timeoutMs:i},{beforeKeyEvents:d,signal:o,onDispatch:p});if(l.error)return this.appendFailure(t,l.error,l.charsSent,l.failureSource);if(s)await this.executeImeAction(s,o);let y=n.dismissKeyboard?await this.dismissKeyboardEpilogue(o):{};return{success:!0,text:t,imeAction:s,method:"append",charsSent:l.charsSent,...y}}async planAppendKeyEvents(t,n,s,i){u(i);let d=Array.from(t),o=d.some((a)=>o$(a)),p=!1;if(o){let a=n();if(a!==void 0&&a<=0)return{plans:[],error:this.appendBudgetExceeded(s,"resolving key events")};p=await this.supportsAndroidInputKeyCombination(a,i)}let c=[];for(let a of d){let l=OR(a,p);if(!l)return{plans:c,error:`append cannot type ${JSON.stringify(a)} with Android key events`};c.push(l)}return{plans:c}}async typeAppendKeyEvents(t,n,s){let{remaining:i,timeoutMs:d}=n,{beforeKeyEvents:o,signal:p,onDispatch:c}=s,a=0;for(let l of t){u(p);let y=i();if(y!==void 0&&y<=0)return{charsSent:a,error:this.appendBudgetExceeded(d,"typing")};let f,m,h=a===0?async(b)=>{try{let T=await o?.(b);if(u(p),T&&!T.success)f=T.error??"Frame context is stale or unavailable; observe a fresh frame before retrying",m=T.failureSource}catch(T){f=`append frame context validation failed: ${r(T)}`}let v=i();if(f===void 0&&v!==void 0&&v<=0)f=this.appendBudgetExceeded(d,"typing");if(f)throw Error(f);u(p),c?.()}:void 0;try{await this.executeKeyEventPlan(l,{timeoutMs:y,noRetry:!0,beforeDispatch:h,signal:p})}catch(b){if(u(p),f)return{charsSent:a,error:f,...m!==void 0?{failureSource:m}:{}};let v=r(b);return e.warn(`[InputText] append key event failed after ${a} char(s): ${v}`,b),{...b instanceof mt?{}:{charsSent:a},error:`append key event failed: ${v}`}}a+=1}return{charsSent:a}}async dismissKeyboardEpilogue(t){let n;try{n=await this.keyboardCloserFactory(this.device,this.adbFactory).close(t)}catch(i){u(t);let d=r(i);return e.warn(`[InputText] keyboard dismissal threw: ${d}`,i),du({keyboardDismissed:!1},`keyboard dismissal failed: ${d}`)}if(u(t),n.success)return{keyboardDismissed:!0};let s=n.error??n.message??"unknown error";return du({keyboardDismissed:!1},`keyboard dismissal failed: ${s}`)}createBudget(t){if(t===void 0)return()=>{return};let n=this.timer.now()+t;return()=>n-this.timer.now()}appendBudgetExceeded(t,n){return`append exceeded its ${t}ms budget while ${n}`}appendFailure(t,n,s,i){return{success:!1,text:t,error:n,method:"append",...s!==void 0?{charsSent:s}:{},...i!==void 0?{failureSource:i}:{}}}setTextFailure(t,n){let{stage:s,phase:i,cause:d,method:o}=n;return e.warn(`[InputText] ${s} setText failed: ${d}`),{success:!1,text:t,error:`Accessibility service setText failed ${i}: ${d}`,method:o}}findLastPrintableAsciiNonWhitespace(t){for(let n=t.length-1;n>=0;n--){let s=t[n];if(!s)continue;let i=s.charCodeAt(0);if(i>=33&&i<=126&&!/\s/.test(s))return{index:n,char:s}}return null}async hasAsciiKeyEventPlan(t,n){for(let s of t)if(await this.getAsciiKeyEventPlan(s,void 0,n))return!0;return!1}async getAsciiKeyEventPlan(t,n,s){u(s);let i=await this.supportsAndroidInputKeyCombination(n,s);return u(s),OR(t,i)}async supportsAndroidInputKeyCombination(t,n){let s=await this.getAndroidApiLevel(t,n);return s!==null&&s>=gd}async getAndroidApiLevel(t,n){if(u(n),this.androidApiLevel!==void 0)return this.androidApiLevel;let s=await Ut(this.adb,t,this.timer);if(u(n),s===null)return null;return this.androidApiLevel=s,s}async withTextDispatch(t){let s=oo()?.textState?.dispatched();try{return await t()}finally{s?.(!0)}}async executeKeyEventPlan(t,n={}){let{timeoutMs:s,noRetry:i=!1,beforeDispatch:d,signal:o}=n;for(let[p,c]of t.commands.entries()){u(o);let a=c.startsWith("shell input text ")?await this.getAndroidApiLevel(s,o):null;await this.withTextDispatch(()=>{let l={timeoutMs:s,noRetry:i,beforeDispatch:p===0?d:void 0,signal:o,waitForProcessSettlementAfterAbort:!0};return c.startsWith("shell input text ")?VL(this.adb,this.timer,c,{...l,apiLevel:a,textLength:t.textLength??1}):this.adb.execute(c.split(" "),l)}),u(o)}}async executeImeAction(t,n){let i={done:"KEYCODE_ENTER",next:"KEYCODE_TAB",search:"KEYCODE_SEARCH",send:"KEYCODE_ENTER",go:"KEYCODE_ENTER",previous:"KEYCODE_SHIFT_LEFT KEYCODE_TAB"}[t];if(i)if(u(n),await this.timer.sleep(K),u(n),i.includes(" ")){let d=i.split(" ");for(let o of d)u(n),await this.withTextDispatch(()=>this.adb.executeCommand(`shell input keyevent ${o}`,{signal:n,waitForProcessSettlementAfterAbort:!0})),u(n)}else await this.withTextDispatch(()=>this.adb.executeCommand(`shell input keyevent ${i}`,{signal:n,waitForProcessSettlementAfterAbort:!0})),u(n)}}
|
|
3
|
+
export{vV};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=5A7B27BB859BF9AF64756E2164756E21
|