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{yn as e}from"./sdk-batch.js";import{v as t}from"./sdk-contracts.js";import{r as n}from"./success-text.js";import{n as r}from"./snapshot-runtime-capture-input.js";import{n as i}from"./validation.js";import{n as a}from"./runtime-admission.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];return t&&/^@e\d/i.test(t)?t:null}async function s(t){let n=await a({command:`type`,device:t.device,use:e,inspectFacts:t.inspectFacts,platformServices:t.platformServices,bindDevice:t.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await l(r,e,t)}}function c(e,n,r){let a=r.rejectRefTarget?o(e[0]):null;if(a)throw new t(`INVALID_ARGS`,`type does not accept a target ref like "${a}"`,{hint:`Use fill ${a} "text" to target that field, or press ${a} then type "text" to append.`});let s=e.join(` `);if(!s)throw new t(`INVALID_ARGS`,`type requires text`);return{text:s,delayMs:i(n.delayMs??0,`delay-ms`,0,1e4)}}async function l(e,{text:t,delayMs:r},i){let a=(await e.operations.typeText(u(t,r,i)))?.textEntryRoute;return{...a===void 0?{}:{textEntryRoute:a},text:t,delayMs:r,...n(`Typed ${Array.from(t).length} chars`)}}function u(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:r(n)}}export{c as n,s as r,l as t};