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.86 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{t}from"./post-gesture-stability.js";import{n}from"./ios-system-surface.js";import{n as r}from"./android-system-surface-disclosure.js";import{t as i}from"./command-policy.js";import{t as a}from"./ios-target-activation.js";function o(t,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} ${r} not create temporary files`)}}}function s(e,t={}){return{artifacts:o(e,t),policy:i()}}function c(e,t){return e===void 0?t:(e.targetActivation??=t.targetActivation,e.postGestureOutcome??=t.postGestureOutcome,t)}function l(e,t){let i=t?.iosSystemSurfaceBundleId?n(t.iosSystemSurfaceBundleId):r(t);return i?p(e,i,`warning`):e}function u(e,t,n,r){if(!n)return e;let i=p(e,r(n),`warnings`);return i.ok?{...i,data:{...i.data,[t]:n}}:{...i,error:{...i.error,details:{...i.error.details,[t]:n}}}}function d(e,t){return u(e,`targetActivation`,t?.targetActivation,a)}function f(e){let{response:n,consumedTree:r,captureProof:i}=e;return d(u(l(n,r),`postGestureOutcome`,r?.postGestureOutcome,t),i)}function p(e,t,n){if(m(e,t))return e;if(!e.ok){let n=e.error.hint??e.error.details?.hint;return{...e,error:{...e.error,hint:h(n,t)}}}return n===`warnings`?{...e,data:{...e.data,warnings:[...g(e.data?.warnings),t]}}:{...e,data:{...e.data,warning:h(e.data?.warning,t)}}}function m(e,t){return(e.ok?[e.data?.warning,...g(e.data?.warnings)]:[e.error.hint]).some(e=>typeof e==`string`&&e.includes(t))}function h(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}function g(e){return Array.isArray(e)?e.filter(e=>e!==void 0):[]}export{s as i,f as n,d as r,c as t};