agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
1 lines • 1.56 kB
JavaScript
const e=1500,t=1e4,n=25e3,r=2e3,i=2147483647,a=`alert-wait-window-too-long`,o=`ALERT_NOT_FOUND`,s=`alert-not-found`,c=`ALERT_BUTTON_NOT_FOUND`,l=`ALERT_UNRESOLVED`,u=`alert-window-expired`,d=`alert-wait-timeout`,f=[/^allow while using (?:the )?app$/i,/^while using the app$/i,/^allow all$/i,/^always allow$/i,/^allow all the time$/i,/^allow notifications$/i,/^allow$/i,/^ok$/i,/^yes$/i,/^continue$/i,/^save$/i,/^confirm/i,/^turn on$/i,/^open settings$/i,/^done$/i,/^open$/i,/^allow once$/i,/^only this time$/i],p=[/^cancel$/i,/^deny$/i,/^don.?t allow$/i,/^not now$/i,/^no$/i,/^dismiss$/i,/^close$/i,/^close app$/i,/^later$/i,/^skip$/i,/^ask app not to track$/i,/^keep browsing$/i],m={accept:f,dismiss:p};function h(e){let t=e.trim();return f.some(e=>e.test(t))?`accept`:p.some(e=>e.test(t))?`dismiss`:`neutral`}function g(e,t){let n=m[t].findIndex(t=>t.test(e.trim()));return n===-1?null:n}function _(e,t,n){let r=e.filter(e=>e.role===t);if(r.length===1)return r[0]??null;if(r.length===0)return null;let i=r.map(e=>{let r=n?.(e)??null;return{button:e,rank:r??g(e.label,t),source:r===null?`label`:`backend`}});if(i.some(e=>e.rank===null)||i.some(e=>e.source!==i[0]?.source))return null;i.sort((e,t)=>(e.rank??0)-(t.rank??0));let[a,o]=i;return!a||o&&o.rank===a.rank?null:a.button}const v=`alert_button_undecided`,y=`alert_capture_undecided`,b=[`get`,`accept`,`dismiss`,`wait`];function x(e){let t=e.toLowerCase();return b.find(e=>e===t)}export{x as _,y as a,o as c,d,a as f,h as g,i as h,v as i,n as l,t as m,r as n,e as o,u as p,c as r,s,b as t,l as u,_ as v};