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.46 kB
JavaScript
import{c as e}from"./sdk-contracts.js";import{g as t}from"./sdk-batch-runner.js";import{t as n}from"./success-text.js";import{i as r}from"./src3.js";import{n as i}from"./cli-runner.js";import{a,s as o}from"./output-common.js";import{exitAfterFlush as s}from"./process-exit.js";import{n as c,t as l}from"./shared.js";async function u({command:n,positionals:r,flags:a,client:o,host:u,debug:p,replayTestReporterRuntime:m,commandProgress:h,leaseDevice:g}){let{result:_,cliOutput:v}=await i({client:o,command:n,positionals:r,flags:a,commandProgress:h,env:u.env}),y=n===`open`&&v&&g?f(v,g):v;if(e(a.responseLevel)){let e=n===`open`&&g&&t(_)?{..._,lease:{device:g}}:_;return await c(a,e,()=>JSON.stringify(e,null,2)),!0}if(y)await l(a,y);else{let e=await d(n,a,_,{debug:p,replayTestReporterRuntime:m});e!==0&&await s(e)}return!0}async function d(e,t,i,s={}){return e===`test`?import(`./reporting.js`).then(({renderReplayTestResponse:e})=>e({suite:i,debug:s.debug,verbose:t.verbose,json:t.json,reporter:t.reporter,reportJunit:t.reportJunit,reporterRuntime:s.replayTestReporterRuntime})):(await l(t,o({data:i,text:n(i)},i,a(r(e)))),0)}function f(e,n){let r={lease:{device:n}},i=`Leased device: ${[n.model,n.osVersion,n.imageTag,n.physical?`physical`:`virtual`].filter(e=>!!e).join(`, `)}`;return{...e,data:t(e.data)?{...e.data,...r}:e.data,...t(e.jsonData)?{jsonData:{...e.jsonData,...r}}:{},text:e.text?`${e.text}\n${i}`:i}}export{u as runGenericClientBackedCommand};