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.57 kB
JavaScript
import{v as e}from"./sdk-contracts.js";const t=1e3;function n(t){if(t)throw new e(`UNAUTHORIZED`,`Limrun uploaded apps are unavailable on the public daemon HTTP surface.`)}async function r(e,n,r){r?.throwIfAborted();let i=await e.assets.list({limit:t},{signal:r});r?.throwIfAborted();let a=[];for(let e of i){let t=o(e,n);t&&a.push(t)}return a.sort((e,t)=>e.name.localeCompare(t.name))}async function i(n,r,i,a){a?.throwIfAborted();let s=await n.assets.list({limit:t,nameFilter:i},{signal:a});a?.throwIfAborted();let c=s.filter(e=>e.name===i).map(e=>o(e,r)).filter(e=>e!==void 0);if(c.length<=1)return c[0];throw new e(`COMMAND_FAILED`,`Limrun returned multiple uploaded apps named ${i}.`,{app:i,platform:r,assetIds:c.map(e=>e.id)})}function a(e,t){let n=l(e.replace(/\.(?:tar\.gz|tgz|tar|zip|ipa|apk)$/i,``).replace(/\.app$/i,``));if(n.length<5)return;let r=t.map(e=>({app:e,keys:c(e)})).filter(({keys:e})=>e.includes(n));return r.length===1?r[0]?.app.id:void 0}function o(e,t){if(e.md5&&s(e)===t)return{id:e.id,name:e.name}}function s(e){if(e.os===`android`||e.os===`ios`)return e.os;let t=e.name.toLowerCase();if(t.endsWith(`.apk`))return`android`;if(t.endsWith(`.ipa`)||t.endsWith(`.zip`)||t.endsWith(`.tar`)||t.endsWith(`.tar.gz`)||t.endsWith(`.tgz`))return`ios`}function c(e){let t=e.id.split(/[.:/]/).at(-1);return[e.id,t,e.name].filter(e=>typeof e==`string`).map(l)}function l(e){return e.toLowerCase().replaceAll(/[^a-z0-9]+/g,``)}export{n as assertLimrunUploadedAppAccess,r as listLimrunAppAssets,a as resolveInstalledAppIdForAsset,i as resolveLimrunAppAsset};