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 • 2.01 kB
import{v as e}from"./sdk-contracts.js";import{a as t}from"./sdk-batch-runner.js";import{et as n}from"./sdk-io.js";import{c as r}from"./tv-remote.js";import"./command.js";import{i}from"./tool-provider3.js";import{t as a}from"./unsupported-interactor.js";const o={allowFailure:!0,timeoutMs:3e4};async function s(e,t){n(await i().launchApp(e.id,t,o),`Failed to launch Vega app ${t}`,{appName:t,deviceId:e.id})}async function c(e){n(await i().checkConnected(e.id,o),`Vega device is not connected`,{deviceId:e.id})}async function l(e,t){n(await i().terminateApp(e.id,t,o),`Failed to terminate Vega app ${t}`,{appName:t,deviceId:e.id})}async function u(e,t,a){let o=r(t);n(await i().pressRemote(e.id,o,a,{allowFailure:!0,timeoutMs:1e4+(a??0)}),`Failed to press Vega TV remote ${t}`,{button:t,deviceId:e.id})}const d=[{matches:(e,n)=>t(e)||!!n?.url,message:`Vega open does not support URLs or deep links.`,hint:`Use open <component-id> with an installed Vega app component ID.`},{matches:(e,t)=>!!t?.activity,message:`Vega open does not support Android activity selection.`,hint:`Remove --activity and use the Vega component ID as the open target.`},{matches:(e,t)=>!!t?.launchConsole,message:`Vega open does not support launch-console output.`,hint:`Remove --launch-console and open the Vega component ID directly.`},{matches:(e,t)=>!!t?.terminateRunningApp,message:`Vega open does not support terminating the running app before launch.`,hint:`Close the Vega component explicitly before opening it again.`},{matches:(e,t)=>!!t?.launchArgs?.length,message:`Vega open does not support launch arguments.`,hint:`Remove --launch-arg values and open the Vega component ID directly.`}];function f(e,t){return{...a(`Vega OS`),open:async(t,n)=>{p(t,n),await s(e,t)},openDevice:()=>c(e),close:t=>l(e,t),back:()=>u(e,`back`),home:()=>u(e,`home`),tvRemote:(t,n)=>u(e,t,n)}}function p(t,n){let r=d.find(({matches:e})=>e(t,n));if(r)throw new e(`UNSUPPORTED_OPERATION`,r.message,{hint:r.hint})}export{f as createVegaInteractor};