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.32 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{et as t}from"./sdk-io.js";import"./command.js";import{n}from"./vega-executable.js";const r=`VirtualDevice`;function i(e){return{discover:async(t,n)=>await o(e,n)}}function a(e){return u(e).some(l)?[{platform:`vega`,id:r,name:`Vega Virtual Device (${r})`,kind:`emulator`,target:`tv`,booted:!0}]:[]}async function o(t,n){let r=await s(t);if(!r)throw new e(`TOOL_MISSING`,`Vega CLI not found in PATH`,{hint:`Install Vega Developer Tools, source ~/vega/env, and retry devices.`});let i=await t.commands.run({executable:r,args:[`device`,`list`],allowFailure:!0,timeoutMs:1e4},n.signal);c(i);let o=a(i.stdout),l=u(i.stdout);if(o.length===0&&l.length>0)throw new e(`DEVICE_NOT_FOUND`,`Vega CLI found devices, but no supported Vega Virtual Device is running.`,{listedSerials:l,hint:`Start the Vega Virtual Device, then retry with --platform vega --target tv.`});return o}async function s(e){return await n({which:t=>e.commands.which(t),isExecutableFile:t=>e.files.isExecutable(t),homeDirectory:e.homeDirectory})}function c(e){t(e,`Failed to list Vega devices`)}function l(e){return e.toLowerCase()===`virtualdevice`}function u(e){let t=new Set;for(let n of e.split(/\r?\n/)){let e=/^\s*([^\s:]+)\s*:\s*\S/.exec(n)?.[1]?.trim();e&&t.add(e)}return[...t]}export{i as createVegaInventory};