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 • 601 B
import{_r as e,br as t,vr as n}from"./sdk-batch.js";function r(e){let t=new Map;for(let n of e)t.set(n.index,n);return t}function i(e,n,r){let i=[],a=new Set([e.index]),o=e;for(;i.length<r;){if(typeof o.parentIndex!=`number`)return{chain:i,broken:!1};let e=n.get(o.parentIndex);if(!e||a.has(e.index))return{chain:i,broken:!0};a.add(e.index);let r=t(e);i.push({role:r.role,...r.label===void 0?{}:{label:r.label}}),o=e}return{chain:i,broken:!1}}function a(r,a,o,s){return r.filter(r=>{if(!n(t(r),o))return!1;let c=i(r,a,Math.max(s.length,1));return!c.broken&&e(c.chain,s)})}export{r as n,a as r,i as t};