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.07 kB
import{n as e}from"./app-inventory.js";import"./device.js";import{d as t}from"./adb-executor.js";import{n}from"./adb-failure.js";import{n as r}from"./app-deployment-resolution.js";import{a as i,s as a}from"./app-parsers.js";import{n as o}from"./launcher-categories.js";async function s(t,n={}){let i=await c(t,n.target??`auto`);return(e(n.filter)===`user-installed`?(await d(t)).filter(e=>i.has(e)):Array.from(i)).map(e=>({package:e,name:r(e)})).sort((e,t)=>e.package.localeCompare(t.package))}async function c(e,n){let r=(await Promise.all(o(n,{includeFallbackCategories:!0}).map(async n=>{let r=await t(e,l(n),{allowFailure:!0});return r.exitCode===0?u(r.stdout):[]}))).flat();return new Set(r)}function l(e){return[`cmd`,`package`,`query-activities`,`--brief`,`-a`,`android.intent.action.MAIN`,`-c`,e]}function u(e){return e.trim().length===0?[]:i(e)}async function d(e){let r=await t(e,[`pm`,`list`,`packages`,`-3`],{allowFailure:!0});if(r.exitCode!==0)throw n(`Failed to list Android user-installed apps`,r);return a(r.stdout)}export{s as listAndroidAppsWithAdb};