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 • 2.64 kB
import{v as e}from"./sdk-contracts.js";import{S as t,V as n,y as r}from"./sdk-device.js";import{o as i}from"./session.js";import{n as a}from"./gesture-admission.js";import{o}from"./tool-provider.js";function s(e,n,r){return{screenMask:t(e)&&n.captureBackend!==`runner`&&o().simulatorScreenshotBackend!==`runner`,captureBackends:r===void 0?[`runner`]:[],captureBackendRefusal:`the macOS helper captures this surface`}}const c=new Set(`deployApp.materializeAppSource.deployMaterializedApp.uninstallApp.ensureReady.bootTarget.shutdownTarget.resolveOpenTarget.prepareApplicationOpen.openApplication.closeApplication.finalizeApplicationClose.prepareAppleRunner.appState.captureSnapshot.findText.querySelector.readTextAtPoint.focusPoint.tapPoint.tapElementSelector.longPressPoint.fillPoint.typeText.performGesturePlan.performDirectionalFlingPlan.gestureViewport.scrollDirection.back.home.actionButton.captureScreenshot`.split(`.`)),l={appSwitcher:`The watchOS App Switcher opens on a Digital Crown double-click, which XCUITest cannot press.`,setOrientation:`watchOS has no device orientation.`},u=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`watchOS is supported on simulators only. A physical Apple Watch reaches the Mac only through its paired iPhone.`});function d(e){return Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:l[e]??`watchOS simulators support only watch interactions: app lifecycle, snapshot, press, swipe, scroll (the Digital Crown), back, home, typing, and screenshots.`})}function f(e,t){return e.appleOs===`watchos`?Object.fromEntries(Object.entries(t).map(([t,n])=>e.kind===`simulator`?[t,c.has(t)||!n.available?n:d(t)]:[t,u])):t}function p(e,t,n){return e.appleOs===`watchos`?Object.fromEntries(Object.entries(n).filter(([e])=>t[e]?.available!==!1)):n}const m={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android, iOS, and iPadOS.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android, iOS, and iPadOS.`,watchos:`watchOS apps have no multi-touch gestures: the SDK has no pinch or rotate gesture, and two-finger pan belongs to the Zoom accessibility feature. Use swipe, gesture pan, or scroll (the Digital Crown).`};function h(e,t){if(!r(e.platform))throw g(t,e.platform);let i=n(e);if(i!==`ios`&&i!==`ipados`)throw g(t,a[i],m[i])}function g(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function _(e){return i(t=>e[t])}export{p as a,f as i,m as n,s as o,h as r,_ as t};