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.47 kB
import{S as e,v as t}from"./sdk-contracts.js";import{n,t as r}from"./absence-observation.js";import{t as i}from"./interaction-error.js";function a(e,r=`is`){return new t(`INVALID_ARGS`,n(e,r),{command:r,predicate:`absent`,rejectedOption:e})}function o(e,n,a=`is`){let o=`firstMatch`in n?n.firstMatch:void 0,s={command:a,reason:i.predicateFailed,predicate:`absent`,selector:e,matches:n.matches,observation:n.kind,...o?{firstMatch:o}:{},...n.kind===`sparse`?{snapshotQuality:n.quality}:{},...n.kind===`truncated`?{truncated:!0}:{}};if(n.kind===`present`){let r=n.matches>1;return new t(`COMMAND_FAILED`,`${a} absent failed for selector ${e}: ${n.matches} match${r?`es`:``} found`,{...s,...r?{hint:`Refine the selector to match no elements.`}:{}})}return new t(`COMMAND_FAILED`,`${a} absent could not prove absence for selector ${e}: ${r[n.kind]}`,{...s,hint:`Retry after the accessibility capture is complete.`})}function s(n,r,a=`is`){let o=e(r),s=typeof o.details?.reason==`string`?o.details.reason:typeof o.details?.androidSnapshotHelperFailureReason==`string`?o.details.androidSnapshotHelperFailureReason:void 0;return new t(`COMMAND_FAILED`,`${a} absent could not prove absence for selector ${n}: capture was unreadable`,{command:a,reason:i.predicateFailed,predicate:`absent`,selector:n,matches:0,observation:`unreadable`,captureErrorCode:o.code,...s?{captureErrorReason:s}:{},hint:`Retry after the accessibility capture is readable.`},o)}export{o as n,s as r,a as t};