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 • 4.83 kB
import{An as e,jn as t,wn as n}from"./sdk-batch.js";import{v as r}from"./sdk-contracts.js";import{n as i,t as a}from"./application-lifecycle-runtime.js";import{i as o}from"./touch-runtime.js";import{r as s}from"./gesture-admission.js";import{A as c,C as l,D as u,F as d,R as f,V as p,W as m,_ as h,j as g,p as _}from"./tv-remote-runtime.js";import{a as v,i as y}from"./screenshot-runtime2.js";import{r as b}from"./application-lifecycle-interaction.js";import{t as x}from"./local-interactor-operation-set.js";import{r as S}from"./platform-runtime-unavailable.js";const C=Object.freeze({available:!0}),w=n(`linux`),T=t(`unsupported-platform-leaf`),E=t(`unsupported-device-kind`),D=t(`unsupported-device-kind`,`focus is supported only for the Linux desktop device.`),O=t(`unsupported-device-kind`,`type is supported only for the Linux desktop device.`),k=t(`unsupported-device-kind`,`Gestures are supported only for the Linux desktop device.`),A=t(`unsupported-device-kind`,`scroll is supported only for the Linux desktop device.`),j=t(`unsupported-platform-leaf`),M=t(`unsupported-platform-leaf`),N=t(`unsupported-platform-leaf`,s),P=t(`unsupported-platform-leaf`),F=t(`unsupported-platform-leaf`,`Runtime hints are supported only for local iOS-family simulators and Android devices.`),I=t(`unsupported-platform-leaf`,`Apple runner preparation is supported only for Apple targets.`),L=t(`unsupported-provider-mode`,`Port reverse is supported only by an owning provider runtime.`),R=t(`unsupported-device-kind`,`open is supported only for the Linux desktop device.`),z=t(`unsupported-device-kind`,`close is supported only for the Linux desktop device.`),B=t(`unsupported-device-kind`,`snapshot is supported only for the Linux desktop device.`),V=t(`unsupported-device-kind`,`screenshot is supported only for the Linux desktop device.`),H=t(`unsupported-platform-leaf`,`Re-run without --actions, or target an iOS simulator.`),U=t(`unsupported-device-kind`,`back is supported only for the Linux desktop device.`),W=t(`unsupported-device-kind`,`home is supported only for the Linux desktop device.`),G=t(`unsupported-device-kind`,`clipboard is supported only for the Linux desktop device.`),K=T,q=t(`unsupported-platform-leaf`,`audio is supported for web browser sessions, macOS sessions, iOS simulators, and Android emulators on macOS hosts`);function J(t){return Object.freeze({owner:w,ownsDevice:e=>e.platform===`linux`,inspectFacts:async e=>X(e),bind:async n=>{if(n.intent.kind===`exact-owner`&&!e(n.intent.owner,w))throw new r(`UNSUPPORTED_OPERATION`,`Linux runtime owner identity does not match`);if(n.device.platform!==`linux`)throw new r(`UNSUPPORTED_PLATFORM`,`Linux runtime cannot bind this device`);let a=X(n.device),o=b({owner:`Linux`,openTargetIdentity:`app-name`,host:t.localInteractors,device:n.device,signal:n.scope.signal});return Object.freeze({device:n.device,owner:w,facts:a,operations:Object.freeze({...i(o,a.operations),...a.operations.captureSnapshot.available?$(t,n):{},...Y(t,n,a)}),[Symbol.asyncDispose]:async()=>void 0})},shutdown:async()=>void 0})}function Y(e,t,n){let r={device:t.device,signal:t.scope.signal,resolveInteractor:e.localInteractors.resolve};return x({...r,facts:n.operations,captureCapabilities:y(`a Linux target captures through its desktop tools`),pause:async n=>await e.clock.sleep(n,t.scope.signal)})}function X(e){let t=e.kind===`device`?C:R,n=e.kind===`device`?C:z,r=S(e,w,{appLog:T,network:T,screenshot:V,snapshot:B,viewport:T,focus:D,gesture:k,scroll:A,typeText:O,touch:D,elementText:E,back:U,orientation:K,tvRemote:K,clipboard:G,systemButton:K,fold:K,telephony:K,triggerAppEvent:K,settings:K,readAlert:K,awaitAlert:K,acceptAlert:K,dismissAlert:K,keyboard:K,audioProbeCapture:q,audioProbeQuery:q,perf:K,readiness:T,lifecycle:a({resolveOpenTarget:t,prepareApplicationOpen:t,openApplication:t,applyRuntimeHints:F,clearRuntimeHints:F,closeApplication:n,finalizeApplicationClose:n,prepareAppleRunner:I,configureProviderPortReverse:L})});return Object.freeze({device:r.device,operations:{...r.operations,...g({capture:Z(e,B),customActions:H,withoutActiveApp:Z(e,B)}),...v({capture:Z(e,V)}),...p({focus:Z(e,D)}),...f({unsupported:k,plan:Z(e,k),directionalFling:j,multiTouch:M,targetAuthoredDrag:N,viewport:P}),...d({scroll:Z(e,A)}),...u({type:Z(e,O)}),...Q(e),...m({readTextAtPoint:Z(e,E)}),...l({back:Z(e,U)}),...h({unsupported:K,home:Z(e,W)}),..._({unsupported:G,read:Z(e,G),write:Z(e,G)})}})}function Z(e,t){return e.kind===`device`?C:t}function Q(e){let t=e.kind===`device`?C:D;return o({unsupported:T,tap:t,longPress:t,fill:t})}function $(e,t){let n=async n=>await e.snapshot.captureSurface(t.device,n.options,c(t.scope.signal,n));return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}export{J as createLinuxPlatformRuntime};