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 • 1.84 kB
import{ft as e,h as t}from"../sdk-io.js";import"../command.js";async function n(e,t,n){try{await r(e,t,n)}catch(e){n.stderr(`${e instanceof Error?e.message:String(e)}\n`),await(await t.processExit()).exitAfterFlush(1)}}async function r(e,t,n){if(e.length===0)return await i(t,n);if(c(e))return await a(t,n);let r=u(e);if(r!==void 0)return await o(r,e,t,n);let d=l(e);if(d)return await(await t.mcp()).runAgentDeviceMcpServer(d);await s(e,t)}async function i(e,t){t.stdout(`${(await e.help()).buildUsageText()}\n`),await(await e.processExit()).exitAfterFlush(1)}async function a(e,t){t.stdout(`${t.bundledVersion??(await e.version()).readVersion()}\n`)}async function o(e,t,n,r){let i=await n.help(),a=e===null?`${i.buildUsageText()}\n`:i.resolveHelpTargetUsageText(e);if(a===null)return await s(t,n);r.stdout(a)}async function s(e,t){await(await t.cli()).runCliProcess(e)}function c(e){return e.length===1&&(e[0]===`--version`||e[0]===`-V`)}function l(e){if(e[0]===`mcp`){if(e.length===1)return{structured:!1};if(e.length===2&&e[1]===`--structured`)return{structured:!0}}}function u(e){let[t,n]=e;if(e.length===1)return t===`help`||d(t)?null:void 0;if(e.length===2)return t===`help`?n:d(n)?t:void 0}function d(e){return e===`--help`||e===`-h`}const f=t(process);n(process.argv.slice(2),{help:()=>import(`../cli-help.js`).then(e=>e.n),cli:async()=>{let{runCliProcess:e}=await import(`../process-entry.js`);return{runCliProcess:t=>e(t,f)}},mcp:async()=>{let{runAgentDeviceMcpServer:t}=await import(`../server.js`);return{runAgentDeviceMcpServer:async n=>await e({host:f,requestEnv:void 0},async()=>await t(n))}},version:()=>import(`../version.js`).then(e=>e.t),processExit:()=>import(`../process-exit.js`)},{bundledVersion:`0.21.41`,stdout:e=>{process.stdout.write(e)},stderr:e=>{process.stderr.write(e)}}).catch(()=>process.exit(1));export{};