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.54 kB
JavaScript
import{r as e}from"./rolldown-runtime.js";import{g as t}from"./sdk-batch-runner.js";var n=e({NO_PLUGIN_CREDENTIALS:()=>r,pluginCredentialVariables:()=>i,readPluginInventory:()=>a});const r=Object.freeze({variables:Object.freeze([]),byBackend:Object.freeze({})});function i(e,t,n){let r=e.find(e=>e.provider===t);if(r?.state!==`active`)return;let{variables:i,byBackend:a}=r.credentials;return(n!==void 0&&Object.hasOwn(a,n)?a[n]:void 0)??i}function a(e){return Array.isArray(e)?e.flatMap(e=>o(e)??[]):[]}function o(e){if(!t(e)||!c(e.source))return;let n=s(e.credentials);if(!n)return;let r={...typeof e.provider==`string`?{provider:e.provider}:{},source:e.source,...typeof e.package==`string`?{package:e.package}:{},...typeof e.version==`string`?{version:e.version}:{},credentials:n};if(e.state===`active`)return{...r,state:`active`};let i=u(e.error);return e.state===`failed`&&i?{...r,state:`failed`,error:i}:void 0}function s(e){if(!t(e))return;let n=l(e.variables),r=e.byBackend===void 0?{}:e.byBackend;if(!n||!t(r))return;let i=Object.entries(r).map(([e,t])=>[e,l(t)]);if(!i.some(([,e])=>e===void 0))return{variables:n,byBackend:Object.fromEntries(i)}}function c(e){return e===`builtin`||e===`store`||e===`embedder`}function l(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:void 0}function u(e){if(!(!t(e)||typeof e.code!=`string`||typeof e.message!=`string`))return{code:e.code,message:e.message,...typeof e.reason==`string`?{reason:e.reason}:{},...typeof e.hint==`string`?{hint:e.hint}:{}}}export{a as i,i as n,n as r,r as t};