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.74 kB
JavaScript
import{_t as e,yt as t}from"./sdk-io.js";import{i as n}from"./catalog.js";import{D as r}from"./src3.js";import{n as i}from"./flag-registry.js";import{n as a}from"./command-schema.js";const o=new Set([`config`,`remoteConfig`,`help`,`version`,`batchSteps`,`githubActionsArtifact`,`textStdin`]),s=new Set([`appsFilter`,`iosSimulatorDeviceSet`,`textStdin`,`osVersion`,`imageTag`,`deviceMode`,`deviceBaseline`,`physical`]),c=m(),l=new Map(c.map(e=>[e.key,e]));function u(e){return l.get(e)}function d(e){return c.filter(t=>t.configurable&&t.supportsCommand(e))}function f(e,t){return u(e)?.supportsCommand(t)??!1}function p(e,n,r,i){return t(_(e),n,r,i)}function m(){let t=new Map;for(let e of i()){let n=t.get(e.key);n?n.push(e):t.set(e.key,[e])}let c=new Map;for(let e of r)c.set(e,new Set([`*`]));for(let e of n()){let t=a(e);for(let n of[...t.allowedFlags??[],...t.supportedFlags??[]]){let t=c.get(n);t&&t.has(`*`)||(t?t.add(e):c.set(n,new Set([e])))}}return[...t.entries()].map(([t,n])=>({key:t,flagDefinitions:n,configurable:!o.has(t),env:{names:s.has(t)?[]:[e(t)]},supportsCommand(e){let n=c.get(t);return n?n.has(`*`)?!0:e?n.has(e):!1:!1}})).sort((e,t)=>h(e.key,t.key))}function h(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?e<t?-1:+(e>t):n<r?-1:1}function g(e){let t=e.flagDefinitions[0];if(!t)throw Error(`Missing flag definition for option ${e.key}`);return t}function _(e){let t=e.flagDefinitions.find(e=>e.setValue===void 0);if(t)return t;let n=g(e);if(n.type===`enum`){let t=n.enumValues??e.flagDefinitions.map(e=>e.setValue).filter(e=>e!==void 0);return{...n,setValue:void 0,enumValues:t}}return n}function v(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}export{p as a,f as i,d as n,u as r,v as t};