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.36 kB
import{cn as e}from"./sdk-batch.js";import{St as t}from"./sdk-io.js";import"./diagnostics.js";import{n}from"./snapshot-runtime-binding.js";import{t as r}from"./session-runtime-admission.js";async function i(r){let i=e({hasActiveApp:r.session.appBundleId!==void 0,intent:`capture-only`}),c=await a(r,i);if(c===void 0)return{kind:`retryable`};if(!c.admitted)return o({command:r.command,operation:c.operation,reason:c.fact.reason});t({level:`info`,phase:`observation_capture_admitted`,data:{command:r.command,plan:i.kind,deviceId:r.session.device.id}});try{let e=await n({admission:c,bindDevice:r.bindDevice,platformServices:r.platformServices});return t({level:`info`,phase:`observation_capture_bound`,data:{command:r.command,plan:i.kind,deviceId:r.session.device.id}}),{kind:`captured`,capture:e}}catch(e){return s({command:r.command,failure:`bind-failed`,error:e})}}async function a(e,t){try{return await r({device:e.session.device,plan:t,inspectFacts:e.inspectFacts})}catch(t){s({command:e.command,failure:`admission-probe-failed`,error:t});return}}function o(e){return t({level:`warn`,phase:`observation_capture_unavailable`,data:{...e,outcome:`refused`}}),{kind:`refused`}}function s(e){return t({level:`warn`,phase:`observation_capture_unavailable`,data:{command:e.command,outcome:e.failure,errorName:e.error?.name}}),{kind:`retryable`}}export{i as t};