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.01 kB
import{v as e}from"./sdk-contracts.js";import{r as t,t as n}from"./runtime-transport-hints.js";const r=8081,i=`.expo/.virtual-metro-entry.bundle`;function a(t,n){if(t==null||t===``)return n;let r=/^\d+$/.test(String(t).trim())?Number(String(t).trim()):NaN;if(!Number.isInteger(r)||r<1||r>65535)throw new e(`INVALID_ARGS`,`Invalid Metro port: ${String(t)}. Use 1-65535.`);return r}function o(i){let o=t(i.bundleUrl),s=o??i.runtime?.bundleUrl,c=n({bundleUrl:s,metroHost:t(i.metroHost)??(o?void 0:t(i.runtime?.metroHost))??(s?void 0:`localhost`),metroPort:i.metroPort===void 0?o?void 0:i.runtime?.metroPort??(s?void 0:r):a(i.metroPort,r)});if(!c)throw new e(`INVALID_ARGS`,`Unable to resolve Metro host and port for reload.`);return c}function s(e){let t=o(e),n=t.pathname.replace(/\/+$/,``),r=new URL(t);r.pathname=`${n}/reload`;let i=new URL(t);return i.protocol=t.protocol===`https:`?`wss:`:`ws:`,i.pathname=`${n}/message`,{reloadUrl:r.toString(),messageSocketUrl:i.toString()}}export{o as i,a as n,s as r,i as t};