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.41 kB
import{v as e}from"./sdk-contracts.js";const t={apiKey:`LIMRUN_API_KEY`,region:`LIMRUN_REGION`},n={ios:[`LIM_IOS_INSTANCE_URL`,`LIM_IOS_INSTANCE_TOKEN`],android:[`LIM_ANDROID_INSTANCE_URL`,`LIM_ANDROID_INSTANCE_TOKEN`,`LIM_ANDROID_INSTANCE_ADB_URL`]},r=[...Object.values(t),...n.ios,...n.android],i=new Map([[`ios-instance`,`ios`],[`android-instance`,`android`]]);function a(e){return e===void 0?void 0:i.get(e)}function o(){let e=Object.values(t);return{variables:r,byBackend:Object.fromEntries([...i].map(([t,r])=>[t,[...e,...n[r]]]))}}function s(e){return n[e]}function c(e){let r=u(e,t.apiKey),i=u(e,t.region),a=[`1`,`true`].includes(e.LIMRUN_KEEP_ALIVE?.trim().toLowerCase()??``),o=l(e,n.ios),s=l(e,n.android);if(!r&&!o&&!s)return;let c={ios:o&&{apiUrl:o.LIM_IOS_INSTANCE_URL,token:o.LIM_IOS_INSTANCE_TOKEN},android:s&&{apiUrl:s.LIM_ANDROID_INSTANCE_URL,token:s.LIM_ANDROID_INSTANCE_TOKEN,adbUrl:s.LIM_ANDROID_INSTANCE_ADB_URL}};return{apiKey:r,region:i,keepAlive:a,instances:o||s?c:void 0}}function l(t,n){let r=n.map(e=>[e,u(t,e)]);if(r.every(([,e])=>e===void 0))return;let i=r.filter(([,e])=>e===void 0).map(([e])=>e);if(i.length>0)throw new e(`INVALID_ARGS`,`Limrun instance access is missing ${i.join(`, `)}.`,{hint:`Set ${n.join(`, `)} together from the instance status, or unset them all.`});return Object.fromEntries(r)}function u(e,t){return e[t]?.trim()||void 0}export{c as i,s as n,a as r,o as t};