Typed Client
Use createAgentDeviceClient() when you want to drive the daemon from application code instead of shelling out to the CLI.
For remote Metro-backed flows, import the reusable Node APIs instead of spawning the agent-device binary. The CLI uses the same helpers internally.
Public subpath API exposed for Node consumers:
agent-device/io- artifact adapter types, file input refs, and file output refs
agent-device/metroprepareRemoteMetro(options)ensureMetroTunnel(options)reloadRemoteMetro(options)stopMetroTunnel(options)buildIosRuntimeHints(baseUrl)buildAndroidRuntimeHints(baseUrl)- types:
PrepareRemoteMetroOptions,PrepareRemoteMetroResult,EnsureMetroTunnelOptions,EnsureMetroTunnelResult,ReloadRemoteMetroOptions,ReloadRemoteMetroResult,StopMetroTunnelOptions,MetroRuntimeHints,MetroBridgeResult
agent-device/batchrunBatch(req, sessionName, invoke)validateAndNormalizeBatchSteps(steps, maxSteps)buildBatchStepFlags(parentFlags, stepFlags)DEFAULT_BATCH_MAX_STEPSBATCH_BLOCKED_COMMANDSINHERITED_PARENT_FLAG_KEYS- types:
BatchInvoke,BatchRequest,BatchStep,BatchStepResult,NormalizedBatchStep
agent-device/remote-configresolveRemoteConfigPath(options)resolveRemoteConfigProfile(options)- types:
RemoteConfigProfile,RemoteConfigProfileOptions,ResolvedRemoteConfigProfile
agent-device/contracts- types:
SessionRuntimeHints,DaemonInstallSource,DaemonLockPolicy,DaemonRequestMeta,DaemonRequest,DaemonArtifact,DaemonResponseData,DaemonError,DaemonResponse
- types:
agent-device/selectorsparseSelectorChain(expression)tryParseSelectorChain(expression)resolveSelectorChain(nodes, chain, options)findSelectorChainMatch(nodes, chain, options)formatSelectorFailure(chain, diagnostics, options)isNodeVisible(node)isSelectorToken(token)isNodeEditable(node, platform)- types:
Selector,SelectorChain,SelectorDiagnostics,SelectorResolution,SnapshotNode
agent-device/findersfindBestMatchesByLocator(nodes, locator, query, requireRectOrOptions)normalizeRole(value)normalizeText(value)parseFindArgs(args)- types:
FindLocator,FindMatchOptions,SnapshotNode
agent-device/install-sourceARCHIVE_EXTENSIONSisBlockedIpAddress(address)isBlockedSourceHostname(hostname)isTrustedInstallSourceUrl(sourceUrl)materializeInstallablePath(options)validateDownloadSourceUrl(url)- types:
MaterializeInstallSource,MaterializedInstallable
agent-device/artifactsresolveAndroidArchivePackageName(archivePath)
agent-device/android-snapshot-helperensureAndroidSnapshotHelper(options)captureAndroidSnapshotWithHelper(options)parseAndroidSnapshotHelperOutput(output)parseAndroidSnapshotHelperXml(xml, metadata?, options?, maxNodes?)prepareAndroidSnapshotHelperArtifactFromManifestUrl(options)verifyAndroidSnapshotHelperArtifact(artifact)- types:
AndroidAdbExecutor,AndroidSnapshotHelperArtifact,AndroidSnapshotHelperManifest,AndroidSnapshotHelperOutput,AndroidSnapshotHelperParsedSnapshot
agent-device/android-adbcreateAndroidPortReverseManager(provider)createLocalAndroidAdbProvider(device)captureAndroidLogcatWithAdb(executor, options?)streamAndroidLogcatWithAdb(provider, options?)readAndroidClipboardWithAdb(executor)/writeAndroidClipboardWithAdb(executor, text)getAndroidKeyboardStatusWithAdb(executor)/dismissAndroidKeyboardWithAdb(executor)openAndroidAppWithAdb(executor, packageName, options?)forceStopAndroidAppWithAdb(executor, packageName)resolveAndroidLaunchComponentWithAdb(executor, packageName, categories?)listAndroidAppsWithAdb(executor, options?)getAndroidAppStateWithAdb(executor)- types:
AndroidAdbProvider,AndroidAdbExecutor,AndroidAdbExecutorOptions,AndroidAdbExecutorResult,AndroidAdbProcess,AndroidAdbSpawner,AndroidPortReverseProvider
The contracts, selectors, finders, install-source, android-adb, artifacts, batch, metro, remote-config, and io subpaths are the supported Node entry points. The former compatibility subpaths agent-device/android-apps and agent-device/daemon, plus hosted-runtime subpaths agent-device/commands, agent-device/backend, agent-device/testing/conformance, and agent-device/observability, are no longer published.
Basic usage
Android snapshot helper providers
Remote Android providers should import agent-device/android-snapshot-helper and inject their own
ADB-shaped executor. The executor receives arguments after adb, so local callers may wrap
adb -s <serial>, while cloud providers can route the same operations through an ADB tunnel.
Helper captures report metadata.captureMode as interactive-windows when Android returns
interactive window roots, or active-window when the helper falls back to
getRootInActiveWindow(). metadata.windowCount is the number of serialized roots.
Android ADB providers
Use agent-device/android-adb when a bridge owns Android device access but wants upstream command
behavior for ADB-shaped operations. Executors receive arguments after adb; local callers can use
createLocalAndroidAdbProvider(device), while remote bridges can route the same argument arrays
through an abstract provider backed by an ADB tunnel, websocket API, or another remote transport.
The provider contract covers normal stdout/stderr commands, binary stdout, stdin, timeout/signal cancellation, optional long-running spawn support for logcat-style streams, and optional reverse support for port mappings. Public helpers accept an executor/provider directly and do not expose the daemon's scoped adb interception internals.
streamAndroidLogcatWithAdb(provider, options?) requires provider.spawn; exec-only providers can
use captureAndroidLogcatWithAdb(executor, options?).
Providers can also expose reverse for first-class port reverse ownership. Plain executors do not
advertise reverse support automatically; call createAndroidPortReverseManager(providerOrExecutor)
only when the provider supports adb reverse argument semantics. The manager makes duplicate setup
idempotent for the same owner and rejects conflicting owners for the same local endpoint.
Command methods
Use client.command.<method>() for command-level device actions. It uses the same daemon transport path as the higher-level client methods, including session metadata, tenant/run/lease fields, normalized daemon errors, and remote artifact handling.
Results are daemon-shaped objects with typed known fields, so command semantics stay aligned with the CLI.
Supported command methods:
waitappStatebackhomerotateappSwitcherkeyboardclipboardalert
Additional CLI-backed methods are exposed on their domain groups with typed option objects so Node consumers do not need to build raw daemon requests:
client.devices.boot()client.apps.push()client.apps.triggerEvent()client.capture.diff()client.interactions.click(),press(),longPress(),swipe(),focus(),type(),fill(),scroll(),pinch(),get(),is(),find()client.replay.run()andclient.replay.test()client.batch.run()client.observability.perf(),logs(), andnetwork()client.recording.record()andclient.recording.trace()client.settings.update()
client.observability.perf() returns daemon-shaped JSON so local and remote transports expose the same metrics payload. On Android and supported Apple targets, data.metrics.fps.droppedFramePercent is the primary frame-smoothness value. Android derives it from the current adb shell dumpsys gfxinfo <package> framestats window; connected iOS devices derive it from xcrun xctrace Animation Hitches for the active app process. Frame samples include windowStartedAt, windowEndedAt, and worstWindows so agents can correlate dropped-frame clusters with logs, network entries, and their own session actions. A successful Android read resets Android frame stats; open <app> resets the Android frame window too, so agents can call perf, perform a transition or gesture, then call perf again to inspect that focused window. iOS simulator and macOS app sessions report frame health as unavailable rather than inventing FPS or dropped-frame values.
client.recording.record({ action: 'start', path, quality: 5 }) starts a smaller 50% resolution video; omit quality to keep native/current resolution.
Batch orchestration for custom transports
Use agent-device/batch when a bridge or in-process runner receives daemon-shaped requests but owns command dispatch itself. The helper keeps validation, inherited flags, serial execution, partial results, and error envelopes aligned with the daemon batch command.
Android installFromSource()
On Android, a successful installFromSource() response returns enough app identity to relaunch the installed app:
packageNamelaunchTarget
If the daemon cannot determine installed app identity, the request fails instead of returning an empty success payload.
URL source rules
installFromSource() URL sources are intentionally limited:
- Private and loopback hosts are blocked by default.
- Archive-backed URL installs are only supported for trusted artifact services, currently GitHub Actions and EAS.
- For existing reachable artifact URLs, use
source: { kind: 'url', url: ... }. - For local artifacts, use
source: { kind: 'path', path: ... }or the CLIinstall/reinstallcommands. - For compatible remote daemons that resolve CI artifacts server-side, pass a GitHub Actions artifact source:
Remote daemons may also support { kind: 'github-actions-artifact', owner, repo, artifactName } or { kind: 'github-actions-artifact', owner, repo, runId, artifactName }. The local client preserves these payloads and does not perform GitHub authentication or artifact download.
Direct Android .apk and .aab URL sources can still resolve package identity from the downloaded install artifact. Trusted GitHub Actions and EAS archive URLs may contain one installable .apk, .aab, .ipa, or iOS .app tar archive.
Remote Metro helpers
Use agent-device/remote-config for profile loading and path resolution, agent-device/metro for Metro preparation, reload, and tunnel lifecycle, and agent-device/contracts when a server consumer needs daemon request or runtime contract types. For bridged remote Metro, proxyBaseUrl is the bridge origin and publicBaseUrl is optional; the bridge descriptor supplies cloud iOS wildcard HTTPS hints and Android runtime-route hints. reloadRemoteMetro() calls Metro's /reload endpoint, matching the terminal r reload path for connected React Native apps.
Selector helpers
Use agent-device/selectors when a remote daemon or bridge needs to parse and match selector expressions without deep-importing daemon internals. Matching is platform-aware because role normalization and editability checks differ by backend.
