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 • 908 B
JavaScript
import{createHash as e}from"node:crypto";const t=new WeakMap;function n(e,n){i(e)&&t.set(e,n)}function r(e){return i(e)?t.get(e):void 0}function i(e){return typeof e==`object`&&!!e||typeof e==`function`}function a(t){let n=Buffer.alloc(16);for(let e of t)s(n,o(e));return{digest:`ax1:${e(`sha256`).update(n).update(`\0`).update(String(t.length)).digest(`hex`).slice(0,16)}`,nodeCount:t.length}}function o(t){return e(`sha256`).update(t.type??``).update(`\0`).update(t.label??``).update(`\0`).update(t.identifier??``).digest().subarray(0,16)}function s(e,t){for(let n=0;n<e.length;n+=1)e[n]=(e[n]??0)^(t[n]??0)}function c(e){let{digest:t,nodeCount:n}=a(e),r=e.reduce((e,t)=>t.hittable===!1?e:e+1,0),i=l(e);return{digest:t,nodeCount:n,interactiveNodeCount:r,...i?{foregroundApp:i}:{}}}function l(e){for(let t of e)if(t.bundleId)return t.bundleId;for(let t of e)if(t.appName)return t.appName}export{n,r,c as t};