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.01 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{a as t}from"./human-control-contract.js";import{d as n}from"./request.js";async function r(t){let{req:r,registry:s}=t,c=r.internal?.admittedLease;if(!c)throw new e(`UNAUTHORIZED`,`Human control requires an admitted remote lease.`);let l={kind:`lease`,leaseId:c.leaseId},u=r.positionals??[],[d,f=``,p=``]=u;switch(d){case`list`:return a(u,1),{ok:!0,data:{holds:s.listHumanControlHolds(l)}};case`put`:return a(u,3),{ok:!0,data:{hold:await s.putHumanControlHold(l,f,i(p),n(r.meta?.requestId)),state:`active`}};case`remove`:{a(u,2);let e=s.removeHumanControlHold(l,f);return{ok:!0,data:{released:!!e,...e?{hold:e}:{}}}}default:throw o()}}function i(n){let r;try{r=JSON.parse(n)}catch(t){throw new e(`INVALID_ARGS`,`Human-control payload must be valid JSON.`,void 0,t)}return t(r)}function a(e,t){if(e.length!==t)throw o()}function o(){return new e(`INVALID_ARGS`,`human_control requires list, put <id> <payload>, or remove <id>.`)}export{r as handleHumanControlCommand};