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.34 kB
import{kn as e}from"./sdk-batch.js";import{s as t,v as n}from"./sdk-contracts.js";import{n as r}from"./request-runtime-binding.js";function i(e){return e===`owner-capability-missing`}function a(e,n){return t(`UNSUPPORTED_OPERATION`,`${e} is not supported on this device`,{reason:n.reason},n.hint?{hint:n.hint}:void 0)}async function o(t){let n=await l(t.inspectFacts)(t.device);for(let r of t.required){let i=n.operations[r],o=t.subject===void 0?i:e(i,t.subject);if(!o.available)return{type:`response`,response:t.unavailableResponse?t.unavailableResponse(o):a(t.command,o)}}return{type:`admitted`,bind:u(t.bindDevice)}}async function s(e){let t=await o({...e,required:e.use.required});if(t.type===`response`)return t;let n=await t.bind(e.device,e.use);return e.readinessScope&&await r(n,e.platformServices,e.readinessScope),{type:`runtime`,runtime:n}}async function c(e,t){let n=await s(e);if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,execute:async({dispatchContext:e})=>await t(r,e)}}function l(e){if(e)return e;throw new n(`COMMAND_FAILED`,`Device runtime facts inspection is unavailable.`,{reason:`runtime-gateway-missing`})}function u(e){if(e)return e;throw new n(`COMMAND_FAILED`,`Device runtime binding is unavailable.`,{reason:`runtime-gateway-missing`})}export{a,c as i,s as n,i as r,o as t};