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.61 kB
import{f as e}from"./sdk-batch.js";import{h as t,s as n}from"./snapshot-runtime-capture-input.js";import{r,t as i}from"./snapshot-baseline.js";import{i as a,r as o}from"./interaction-ref-policy.js";import{s}from"./runtime-session.js";import{captureSnapshotForSession as c,createInteractionRuntime as l}from"./interaction.js";import{t as u}from"./observation-capture.js";async function d(n){if(!e(n.command))return{};let s=a(n.command,n.flags);if(s)return{response:s};let c=o(n.flags);if(!c)return{};let{presentedSurface:l,...u}=r(t(n.session)),d=await i({frame:u,candidates:[f(n.session.snapshot)]});return{observe:async()=>await p(n,c,d)}}function f(e){let t=r(e);if(!e||!n(e))return t;let{presentedSurface:i,...a}=t;return a}async function p(e,t,n){let r=await m(e);if(!r)return;let i=await r.interactions.settleObservation({...t,baseline:n,session:e.sessionName,requestId:e.req.meta?.requestId});if(e.sessionRef&&!e.sessionStore.resolveCurrent(e.sessionRef))return;let a=s(e.sessionRef,e.sessionStore,i);return a===void 0?i:{...i,refsGeneration:a}}async function m(e){try{let t=await u({command:e.req.command,session:e.session,inspectFacts:e.inspectFacts,platformServices:e.platformServices,bindDevice:e.bindDevice});return await l({createCommandSurface:e.createCommandSurface,req:e.req,sessionName:e.sessionName,sessionRef:e.sessionRef,logPath:e.logPath,sessionStore:e.sessionStore,contextFromFlags:e.contextFromFlags,platformServices:e.platformServices,captureSnapshotForSession:c,settleObservationCapture:t.kind===`captured`?t.capture:void 0})}catch{return}}export{d as planGenericSettleObservation};