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.

2 lines • 1.48 kB
import{v as e}from"./sdk-contracts.js";import{h as t}from"./daemon-resolution.js";import{o as n,r}from"./daemon-registration.js";import{i}from"./plugin-inventory.js";import{n as a,t as o}from"./store.js";import{n as s}from"./shared.js";import{n as c}from"./builtin-provider-ids.js";const l=async({positionals:l,flags:u})=>{let[d=`list`,f,p]=l;if(p||![`add`,`update`,`remove`,`list`].includes(d)||(d===`list`?f!==void 0:!f))throw new e(`INVALID_ARGS`,`Use plugins list, add <package[@version]>, update <package>, or remove <package>`);d!==`list`&&f&&await o(d,f,process.env,c);let m=await a(process.env,c),h=n(t(u.stateDir)),g=i(h.plugins),_=g.filter(({state:e})=>e===`failed`),v={plugins:m,...h.state===`running`?{daemon:{pid:h.pid,stateDir:h.stateDir,plugins:g}}:{},...r(h)?{daemonRecord:h.state}:{},restartRequired:d!==`list`};return await s(u,v,()=>[...m.map(e=>e.compatible?`${e.name}@${e.version} (${e.provider})`:e.name===void 0?`Plugin config unavailable: ${e.error?.message}`:`${e.name}: unavailable; run plugins update ${e.name} or plugins remove ${e.name}`),...d===`list`?[]:[`Restart the local daemon after closing active sessions to use the changed plugin set.`],...m.length===0?[`No provider plugins installed.`]:[],...r(h)?[`The daemon record for ${h.stateDir} is ${h.state}, so its providers are unknown.`]:[],..._.map(e=>`The running daemon did not register ${e.package??e.provider??e.source}: ${e.error?.message}`)].join(` `)),!0};export{l as pluginsCommand};