UNPKG

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 • 600 B
function e(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=t.get(r.parentIndex);if(!e)return null;if(n(e))return e;r=e}return null}function t(e){let t=new Map;for(let n of e){let e=t.get(n.parentIndex);e?e.push(n):t.set(n.parentIndex,[n])}return t}function n(e,t){let n=[],r=new Set([t]),i=[t];for(;i.length>0;){let t=i.pop();for(let a of e.get(t)??[])r.has(a.index)||(r.add(a.index),n.push(a),i.push(a.index))}return n}function r(e,t,n){let r=[t];for(;r.length>0;){let t=r.pop();if(!n.has(t)){n.add(t);for(let i of e.get(t)??[])n.has(i.index)||r.push(i.index)}}}export{r as i,n,e as r,t};