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.27 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{g as t}from"./sdk-batch-runner.js";import{m as n}from"./file.js";import{i as r}from"./manifest.js";import i from"node:fs";import a from"node:path";function o(r){let a=n(r);try{let n=JSON.parse(i.readFileSync(a,`utf8`));if(!t(n)||n.plugins!==void 0&&!t(n.plugins))throw new e(`INVALID_ARGS`,`Plugin config must contain an object`);return n}catch(t){if(t.code===`ENOENT`)return{};throw t instanceof SyntaxError?new e(`INVALID_ARGS`,`Invalid plugin JSON: ${a}`,{},t):t}}function s(n,r){if(!d(n)||!t(r)||typeof r.installation!=`string`||!/^[a-f0-9-]{36}$/.test(r.installation)||r.version!==void 0&&!f(r.version)||r.options!==void 0&&!t(r.options))throw new e(`INVALID_ARGS`,`Invalid plugin selection: ${n}`)}function c(e){return a.dirname(n(e))}function l(e,t,n){return a.join(e,`plugins`,n,`node_modules`,t)}function u(e){let t=c(e),n;try{n=Object.entries(o(e).plugins??{})}catch{return[]}return n.flatMap(([e,n])=>{try{s(e,n);let i=r(l(t,e,n.installation));return i.name===e?[i]:[]}catch{return[]}})}function d(e){return/^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(e)}function f(e){return typeof e==`string`&&/^[a-zA-Z0-9*^~<>=| .+-]+$/.test(e)&&e.trim().length>0}export{c as a,o as i,f as n,s as o,u as r,l as t};