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.

1 lines • 1.74 kB
import{v as e}from"./sdk-contracts.js";import{n as t,t as n}from"./durable-resource.js";function r(e,t){let r=i(e),o,s=!1,c=()=>s,l=e=>(s=!0,o??=t.finish(r,e).catch(e=>{throw o=void 0,e}),o),u=()=>o?o.then(async e=>e.status===`completed`?{status:`cleaned`}:await t.forceCleanup(r),async()=>await t.forceCleanup(r)):t.forceCleanup(r);return Object.freeze({inspect:()=>r,appendGestureEvents:e=>{e.length===0||c()||(r=i({...r,gestureEvents:[...r.gestureEvents,...e]}))},setTouchReferenceFrame:e=>{c()||(r=i({...r,...e?{touchReferenceFrame:e}:{}}))},setRunnerSessionId:e=>{c()||e.trim().length===0||(r=i({...r,runnerSessionId:e}))},invalidate:e=>{c()||r.invalidatedReason||(r=i({...r,invalidatedReason:e}))},finish:l,...n(()=>(s=!0,u()),a)})}function i(e){return Object.freeze({...e,gestureEvents:Object.freeze([...e.gestureEvents])})}function a(n,r){if(!t(n))throw new e(`COMMAND_FAILED`,n.message??`Screen recording cleanup could not be confirmed`,{reason:n.reason,retriable:n.reason!==`ownership-fence-lost`,hint:n.reason===`ownership-fence-lost`?`Use the current recording owner or recovery record before retrying cleanup.`:`Keep the recovery record and retry cleanup through the exact runtime owner.`},r)}function o(e,t,n){let{stopObservation:r,nativePathDisposition:i,showTouches:a=e.showTouches}=n;return Object.freeze({status:`completed`,result:Object.freeze({backend:e.backend,outPath:e.outPath,...e.clientOutPath===void 0?{}:{clientOutPath:e.clientOutPath},startedAt:e.startedAt,completedAt:Date.now(),stopObservation:r,...i===void 0?{}:{nativePathDisposition:i},scope:e.scope,showTouches:a,recordOnlySession:e.recordOnlySession,...e.activeSessionApp===void 0?{}:{activeSessionApp:e.activeSessionApp},...t})})}export{r as n,o as t};