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.
6 lines • 1 kB
JavaScript
import{n as e,t}from"./success-text.js";function n(e){return({result:t})=>e(t)}const r=n(i);function i(e){return{data:e,text:t(e)}}function a(t){return[...typeof t.warning==`string`&&t.warning.trim()!==``?[t.warning]:[],...e(t)].map(e=>l(e)).filter(e=>e.length>0)}function o(e,t){let n=e??``,r=a(t).filter(e=>!n.includes(e)).map(e=>`Warning: ${e}`);return r.length===0?e??null:[...n===``?[]:[n],...r].join(`
`)}function s(e){return e.parseableOutput===!0?`stderr`:`text`}function c(e,t,n){let r=t??{};if(n===`text`)return{...e,text:o(e.text,r)};let i=`${e.text??``}\n${e.stderr??``}`,s=a(r).filter(e=>!i.includes(e)).map(e=>`Warning: ${e}`);if(s.length===0)return e;let c=e.stderr??``;return{...e,stderr:`${c}${c===``||c.endsWith(`
`)?``:`
`}${s.join(`
`)}\n`}}function l(e){return e.replaceAll(/\s+/g,e=>e.includes(`
`)?` `:e)}function u(e,t){if(typeof e==`string`&&e.length!==0&&typeof t==`number`)return`@${e.startsWith(`@`)?e.slice(1):e}~s${t}`}export{s as a,u as i,i as n,n as o,r,c as s,l as t};