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.81 kB
JavaScript
const e=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function t(t){let n=u(t.packageName),r=(t.resourceId??``).toLowerCase(),i=u(t.activeInputMethodPackage);if(n&&i&&n===i)return{inputMethodOwned:!0,source:`active-input-method`};if(i&&r.startsWith(`${i}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(n&&e.has(n))return{inputMethodOwned:!0,source:`known-ime-package`};for(let t of e)if(r.startsWith(`${t}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function n(e,n,r){return t({packageName:e,resourceId:n,activeInputMethodPackage:r}).inputMethodOwned}function r(e){return t(e).inputMethodOwned}function i(e){return r({packageName:e.bundleId,resourceId:e.identifier})}function a(t){let n=u(t);return!!(n&&e.has(n))}function o(t){let n=(t??``).toLowerCase();for(let t of e)if(n.startsWith(`${t}:id/`))return!0;return!1}function s(e,t,r){return!e&&!t?`unknown`:n(e,t,r)?`ime`:`app`}function c(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=l(e.match(t)?.[1]);if(n)return n}}function l(e){let t=(e??``).trim();if(t)return u((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function u(e){return(e??``).trim().toLowerCase()||void 0}const d=new Set([`UIKeyboardDockItemButton`,`UIAccessibilityElementKBKey`]),f=new Set([`TUIPredictionViewCell`]),p=new Set([`UIKeyboardLayoutStar`,`TUIPredictionView`]),m=new Set([`_UIRemoteKeyboardPlaceholderView`,`TUISystemInputAssistantView`,`TUISystemInputAssistantPageView`]);function h(e,t){return e.role!==void 0&&t.has(e.role)}export{s as a,r as c,c as d,d as i,a as l,f as n,h as o,p as r,i as s,m as t,o as u};