agent-device 0.20.8 → 0.20.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -31
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.8.apk → agent-device-android-ime-helper-0.20.9.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.9.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.8.manifest.json → agent-device-android-ime-helper-0.20.9.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.8.apk → agent-device-android-snapshot-helper-0.20.9.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.8.manifest.json → agent-device-android-snapshot-helper-0.20.9.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +3 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +13 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +4 -112
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +9 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +90 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +46 -10
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/android-adb.d.ts +5 -5
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-lifecycle.js +6 -7
- package/dist/src/app-lifecycle2.js +2 -2
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state.js +2 -0
- package/dist/src/appearance.js +1 -0
- package/dist/src/apps.js +5 -5
- package/dist/src/artifacts.d.ts +1 -1
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -0
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/bounds.js +1 -0
- package/dist/src/byte-limit-stream.js +1 -0
- package/dist/src/cancel.js +1 -0
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +25 -20
- package/dist/src/cli.js +6 -6
- package/dist/src/client-metro.js +1 -1
- package/dist/src/command-catalog.js +1 -0
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-surface.js +1 -1
- package/dist/src/config.js +1 -0
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +3 -3
- package/dist/src/contracts.js +1 -1
- package/dist/src/debug-symbols.js +3 -3
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-input-state.js +1 -1
- package/dist/src/device-ready.js +1 -1
- package/dist/src/device2.js +2 -2
- package/dist/src/dispatch.js +1 -1
- package/dist/src/entities.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper-package-install.js +1 -0
- package/dist/src/helper.js +2 -2
- package/dist/src/host-process.js +1 -1
- package/dist/src/ime-lifecycle.js +2 -9
- package/dist/src/ime-recovery-marker.js +1 -0
- package/dist/src/index.d.ts +24 -15
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +4 -4
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/input-actions3.js +1 -1
- package/dist/src/install-artifact.js +1 -1
- package/dist/src/install-artifact2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-common.js +1 -0
- package/dist/src/interaction-runtime.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -0
- package/dist/src/interactor.js +2 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -0
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +4 -7
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/inventory.js +1 -1
- package/dist/src/keyed-lock.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +3 -1
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/location-coordinates.js +1 -0
- package/dist/src/logcat.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/observability.js +1 -0
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/perf.js +4 -0
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-network-web-transport.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -0
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +2 -0
- package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-web-host.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -0
- package/dist/src/plist.js +1 -1
- package/dist/src/png-resize.js +1 -0
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/prepare-kind.js +13 -13
- package/dist/src/process-lock.js +1 -1
- package/dist/src/project-runtime.js +1 -0
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/provider.js +1 -0
- package/dist/src/proxy.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-export-quality.js +1 -0
- package/dist/src/registry.js +29 -26
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay.js +1 -1
- package/dist/src/reporting.js +3 -3
- package/dist/src/rolldown-runtime.js +1 -0
- package/dist/src/runner-client.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runtime-transport.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +4 -3
- package/dist/src/runtime3.js +1 -3
- package/dist/src/runtime4.js +3 -1
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -0
- package/dist/src/runtime9.js +1 -0
- package/dist/src/scoped-provider.js +1 -0
- package/dist/src/screenshot-density.js +1 -0
- package/dist/src/screenshot-geometry.js +1 -0
- package/dist/src/screenshot-result.js +4 -4
- package/dist/src/screenshot.js +1 -1
- package/dist/src/sdk-android-adb.d.ts +20 -2
- package/dist/src/sdk-android-adb.js +3 -3
- package/dist/src/sdk-batch-runner.js +3 -3
- package/dist/src/sdk-contracts.d.ts +3 -3
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.js +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +19 -19
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/sdk.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session.js +1 -30
- package/dist/src/session2.js +28 -0
- package/dist/src/setting-state.js +1 -1
- package/dist/src/shared.js +1 -1
- package/dist/src/simctl.js +1 -0
- package/dist/src/simulator-state.js +1 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-session.js +1 -1
- package/dist/src/snapshot.js +8 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -0
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +1 -2
- package/dist/src/src3.js +2 -1
- package/dist/src/string-enum.js +1 -0
- package/dist/src/tool-provider.js +3 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/verdict.js +1 -0
- package/dist/src/verified-file.js +1 -0
- package/dist/src/version.js +1 -1
- package/dist/src/video.js +1 -1
- package/dist/src/web.js +1 -1
- package/package.json +8 -4
- package/server.json +3 -3
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.8.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.8.apk.sha256 +0 -1
- package/dist/src/interaction-touch-reference-frame.js +0 -1
- package/dist/src/notifications.js +0 -1
- package/dist/src/platform-runtime-toolchain-host.js +0 -1
- package/dist/src/text-surface.js +0 -1
- package/dist/src/tool-provider3.js +0 -1
package/dist/src/registry.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import{_ as e,n as t,t as n}from"./sdk-contracts.js";import{$ as r,C as i,Dt as a,Ft as o,It as s,J as c,Lt as ee,Nt as te,O as ne,Ot as re,Pt as ie,Q as ae,S as oe,Tt as se,V as ce,W as le,X as ue,Y as de,Z as fe,et as pe,g as me,k as he,kt as ge,lt as _e,mt as ve,p as ye,pt as be,tt as xe,w as Se}from"./version.js";import{Gn as l,Gt as Ce,Ht as we,Kt as Te,Qt as Ee,Ut as De,Xt as Oe,_ as ke,an as Ae,ct as je,d as Me,dn as Ne,f as Pe,g as Fe,i as Ie,m as Le,nr as Re,p as ze,qt as Be,r as Ve,sn as He,u as Ue,ut as We,yn as Ge,zn as Ke}from"./sdk-batch-runner.js";import{r as qe,t as Je}from"./sdk-device.js";import{$t as Ye,At as Xe,Bt as Ze,Ft as Qe,Lt as $e,Mt as et,Nt as tt,Pt as nt,Rt as rt,St as it,Ut as at,Vt as ot,Wt as st,Xt as u,Yt as ct,_t as lt,a as ut,c as dt,cn as ft,dn as pt,fn as mt,hn as ht,jt as gt,l as _t,ln as vt,mn as yt,n as bt,nn as xt,o as St,pn as Ct,qt as wt,r as Tt,t as Et,un as Dt,wn as Ot,xn as kt,xt as At,zt as jt}from"./prepare-kind.js";import{a as Mt}from"./sdk-remote-config.js";import{a as Nt,d as Pt,f as Ft,t as It}from"./device.js";const Lt=[{key:`count`,names:[`--count`],type:`int`,min:1,max:200,usageLabel:`--count <n>`,usageDescription:`Repeat count for press/swipe series`},{key:`pointerCount`,names:[`--pointer-count`],type:`int`,min:1,max:2,usageLabel:`--pointer-count <1|2>`,usageDescription:`Gesture pan: number of touch pointers (default 1)`},{key:`fps`,names:[`--fps`],type:`int`,min:1,max:120,usageLabel:`--fps <n>`,usageDescription:`Record: target frames per second (iOS physical device runner)`},{key:`quality`,names:[`--quality`],type:`string`,usageLabel:`--quality <medium|high>`,usageDescription:`Record: output quality preset; Android maps this to screenrecord bitrate, Apple targets use it for export/encoding. Legacy numeric values 5-7 map to medium; 8-10 map to high`},{key:`hideTouches`,names:[`--hide-touches`],type:`boolean`,usageLabel:`--hide-touches`,usageDescription:`Record: skip touch-overlay post-processing for faster raw benchmark videos`},{key:`recordingScope`,names:[`--scope`],type:`enum`,enumValues:Ye,usageLabel:`--scope <app|device|system>`,usageDescription:`Record: app requires an active app session; device/system records the whole screen`},{key:`intervalMs`,names:[`--interval-ms`],type:`int`,min:0,max:1e4,usageLabel:`--interval-ms <ms>`,usageDescription:`Delay between press iterations`},{key:`delayMs`,names:[`--delay-ms`],type:`int`,min:0,max:1e4,usageLabel:`--delay-ms <ms>`,usageDescription:`Delay between typed characters`},{key:`recordAs`,names:[`--record-as`],type:`string`,usageLabel:`--record-as <VAR>`,usageDescription:"Fill: send the live text but publish ${VAR} in an armed .ad recording"},{key:`durationMs`,names:[`--duration-ms`],type:`int`,min:0,max:1e4,usageLabel:`--duration-ms <ms>`,usageDescription:`Scroll: pace the gesture over this duration when supported`},{key:`holdMs`,names:[`--hold-ms`],type:`int`,min:0,max:1e4,usageLabel:`--hold-ms <ms>`,usageDescription:`Press hold duration for each iteration`},{key:`jitterPx`,names:[`--jitter-px`],type:`int`,min:0,max:100,usageLabel:`--jitter-px <n>`,usageDescription:`Deterministic coordinate jitter radius for press`},{key:`pixels`,names:[`--pixels`],type:`int`,min:1,max:1e5,usageLabel:`--pixels <n>`,usageDescription:`Scroll: explicit gesture distance in pixels`},{key:`doubleTap`,names:[`--double-tap`],type:`boolean`,usageLabel:`--double-tap`,usageDescription:`Use double-tap gesture per press iteration`},{key:`verify`,names:[`--verify`],type:`boolean`,usageLabel:`--verify`,usageDescription:`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot`},{key:`settle`,names:[`--settle`],type:`boolean`,usageLabel:`--settle`,usageDescription:`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response (best-effort; never fails the action)`},{key:`settleQuietMs`,names:[`--settle-quiet`],type:`int`,min:0,usageLabel:`--settle-quiet <ms>`,usageDescription:`Settle: quiet window the UI must hold to count as settled (default 500ms)`},{key:`clickButton`,names:[`--button`],type:`enum`,enumValues:[`primary`,`secondary`,`middle`],usageLabel:`--button primary|secondary|middle`,usageDescription:`Click: choose mouse button (middle reserved for future macOS support)`},{key:`backMode`,names:[`--in-app`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`in-app`,usageLabel:`--in-app`,usageDescription:`Back: use app-provided back UI when available`},{key:`backMode`,names:[`--system`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`system`,usageLabel:`--system`,usageDescription:`Back: use system back input or gesture when available`},{key:`pauseMs`,names:[`--pause-ms`],type:`int`,min:0,max:1e4,usageLabel:`--pause-ms <ms>`,usageDescription:`Delay between swipe iterations`},{key:`pattern`,names:[`--pattern`],type:`enum`,enumValues:[`one-way`,`ping-pong`],usageLabel:`--pattern one-way|ping-pong`,usageDescription:`Swipe repeat pattern`},{key:`verbose`,names:[`--debug`,`--verbose`,`-v`],type:`boolean`,usageLabel:`--debug, --verbose, -v`,usageDescription:`Enable debug diagnostics; test --verbose prints per-test step timings without debug logs`},{key:`cost`,names:[`--cost`],type:`boolean`,usageLabel:`--cost`,usageDescription:`Include per-command wall-clock latency (cost.wallClockMs) in the response`},{key:`responseLevel`,names:[`--level`],type:`enum`,enumValues:t,usageLabel:`--level digest|default|full`,usageDescription:`Response detail level: digest (token-cheap), default (today), or full. Default keeps the wire shape unchanged.`},{key:`json`,names:[`--json`],type:`boolean`,usageLabel:`--json`,usageDescription:`JSON output`},{key:`help`,names:[`--help`,`-h`],type:`boolean`,usageLabel:`--help, -h`,usageDescription:`Print help and exit`},{key:`version`,names:[`--version`,`-V`],type:`boolean`,usageLabel:`--version, -V`,usageDescription:`Print version and exit`},{key:`snapshotDiff`,names:[`--diff`],type:`boolean`,usageLabel:`--diff`,usageDescription:`Snapshot: show structural diff against the previous session baseline`},{key:`saveScript`,names:[`--save-script`],type:`booleanOrString`,usageLabel:`--save-script [path]`,usageDescription:`Arm evidence capture on open, publish the armed recording on close; close --save-script alone (without an armed open) is rejected — start with open --save-script, or use session save-script mid-session. Optional custom output path.`},{key:`networkInclude`,names:[`--include`],type:`enum`,enumValues:[`summary`,`headers`,`body`,`all`],usageLabel:`--include summary|headers|body|all`,usageDescription:`Network: include headers, bodies, or both in output`},{key:`shutdown`,names:[`--shutdown`],type:`boolean`,usageLabel:`--shutdown`,usageDescription:`close: shutdown associated simulator/emulator after ending session`},{key:`relaunch`,names:[`--relaunch`],type:`boolean`,usageLabel:`--relaunch`,usageDescription:`open: terminate app process before launching it`},{key:`foreground`,names:[`--foreground`],type:`boolean`,usageLabel:`--foreground`,usageDescription:`open: keep normal app/device selection and return an initial snapshot; without an app, resolve the sole running app on the sole booted iOS simulator`},{key:`restart`,names:[`--restart`],type:`boolean`,usageLabel:`--restart`,usageDescription:`logs clear: stop active stream, clear logs, then start streaming again`},{key:`retainPaths`,names:[`--retain-paths`],type:`boolean`,usageLabel:`--retain-paths`,usageDescription:`install-from-source: keep materialized artifact paths after install`},{key:`retentionMs`,names:[`--retention-ms`],type:`int`,min:1,usageLabel:`--retention-ms <ms>`,usageDescription:`install-from-source: retention TTL for materialized artifact paths`},{key:`noRecord`,names:[`--no-record`],type:`boolean`,usageLabel:`--no-record`,usageDescription:`Do not record this action`},{key:`record`,names:[`--record`],type:`boolean`,usageLabel:`--record`,usageDescription:`Force-record this action even though its command is observation-only and would otherwise be excluded from a repair-armed heal by default (mutually exclusive with --no-record)`}],Rt=[{key:`config`,names:[`--config`],type:`string`,usageLabel:`--config <path>`,usageDescription:`Load CLI defaults from a specific config file (required for connection/provider defaults outside user config)`},{key:`remoteConfig`,names:[`--remote-config`],type:`string`,usageLabel:`--remote-config <path>`,usageDescription:`Load remote host + Metro workflow settings from a specific profile file`},{key:`stateDir`,names:[`--state-dir`],type:`string`,usageLabel:`--state-dir <path>`,usageDescription:`Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)`},{key:`daemonBaseUrl`,names:[`--daemon-base-url`],type:`string`,usageLabel:`--daemon-base-url <url>`,usageDescription:`Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)`},{key:`daemonAuthToken`,names:[`--daemon-auth-token`],type:`string`,usageLabel:`--daemon-auth-token <token>`,usageDescription:`Remote HTTP daemon or proxy auth token (sent as request token and bearer header)`},{key:`daemonTransport`,names:[`--daemon-transport`],type:`enum`,enumValues:[`auto`,`socket`,`http`],usageLabel:`--daemon-transport auto|socket|http`,usageDescription:`Daemon client transport preference`},{key:`daemonServerMode`,names:[`--daemon-server-mode`],type:`enum`,enumValues:[`socket`,`http`,`dual`],usageLabel:`--daemon-server-mode socket|http|dual`,usageDescription:`Daemon server mode used when spawning daemon`},{key:`proxyHost`,names:[`--host`],type:`string`,usageLabel:`--host <host>`,usageDescription:`Proxy: host interface to bind (default: 127.0.0.1)`},{key:`proxyPort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`Proxy: TCP port to bind (default: 0, choose a free port)`},{key:`tenant`,names:[`--tenant`],type:`string`,usageLabel:`--tenant <id>`,usageDescription:`Tenant scope identifier for isolated daemon sessions`},{key:`sessionIsolation`,names:[`--session-isolation`],type:`enum`,enumValues:[`none`,`tenant`],usageLabel:`--session-isolation none|tenant`,usageDescription:`Session isolation strategy (tenant prefixes session namespace)`},{key:`runId`,names:[`--run-id`],type:`string`,usageLabel:`--run-id <id>`,usageDescription:`Run identifier used for tenant lease admission checks`},{key:`leaseId`,names:[`--lease-id`],type:`string`,usageLabel:`--lease-id <id>`,usageDescription:`Lease identifier bound to tenant/run admission scope`},{key:`leaseBackend`,names:[`--lease-backend`],type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`],usageLabel:`--lease-backend ios-simulator|ios-instance|android-instance`,usageDescription:`Lease backend for remote tenant connection admission`},{key:`provider`,names:[`--provider`],type:`string`,usageLabel:`--provider <name>`,usageDescription:`Cloud provider name for provider-scoped commands`},{key:`providerSessionId`,names:[`--provider-session`],type:`string`,usageLabel:`--provider-session <id>`,usageDescription:`Cloud provider session id or ARN`},{key:`providerApp`,names:[`--provider-app`],type:`string`,usageLabel:`--provider-app <ref-or-path>`,usageDescription:`Cloud provider app reference or local app path used when creating hosted WebDriver sessions`},{key:`providerOsVersion`,names:[`--provider-os-version`,`--os-version`],type:`string`,usageLabel:`--provider-os-version <version>`,usageDescription:`Hosted cloud provider OS version, for example 17 or 14.0`},{key:`providerProject`,names:[`--provider-project`],type:`string`,usageLabel:`--provider-project <name>`,usageDescription:`Hosted cloud provider project label`},{key:`providerBuild`,names:[`--provider-build`],type:`string`,usageLabel:`--provider-build <name>`,usageDescription:`Hosted cloud provider build label`},{key:`providerSessionName`,names:[`--provider-session-name`],type:`string`,usageLabel:`--provider-session-name <name>`,usageDescription:`Hosted cloud provider session label`},{key:`providerDeviceOrientation`,names:[`--provider-device-orientation`,`--device-orientation`],type:`enum`,enumValues:Mt,usageLabel:`--provider-device-orientation portrait|landscape`,usageDescription:`Screen orientation a hosted cloud provider session starts in. Set this rather than rotating after launch: a session that boots landscape renders login webviews landscape`},{key:`providerGeoLocation`,names:[`--provider-geo-location`,`--geo-location`],type:`string`,usageLabel:`--provider-geo-location <country>`,usageDescription:`Hosted cloud provider IP geolocation country code, for example US`},{key:`providerTimezone`,names:[`--provider-timezone`,`--timezone`],type:`string`,usageLabel:`--provider-timezone <zone>`,usageDescription:`Hosted cloud provider device time zone, for example New_York`},{key:`providerLanguage`,names:[`--provider-language`,`--language`],type:`string`,usageLabel:`--provider-language <language>`,usageDescription:`Hosted cloud provider app language, for example Fr`},{key:`providerLocale`,names:[`--provider-locale`,`--locale`],type:`string`,usageLabel:`--provider-locale <locale>`,usageDescription:`Hosted cloud provider device locale, for example Fr`},{key:`providerNetworkProfile`,names:[`--provider-network-profile`,`--network-profile`],type:`string`,usageLabel:`--provider-network-profile <profile>`,usageDescription:`Hosted cloud provider named network condition profile, for example 4g-lte-advanced-good. Mutually exclusive with --provider-custom-network`},{key:`providerCustomNetwork`,names:[`--provider-custom-network`,`--custom-network`],type:`string`,usageLabel:`--provider-custom-network <shape>`,usageDescription:`Hosted cloud provider custom network shape. Mutually exclusive with --provider-network-profile`},{key:`providerNoResignApp`,names:[`--provider-no-resign-app`],type:`boolean`,usageLabel:`--provider-no-resign-app`,usageDescription:`iOS only: keep an Enterprise-signed app as uploaded instead of letting the provider re-sign it, which strips entitlements such as push notifications`},{key:`awsProjectArn`,names:[`--aws-project-arn`],type:`string`,usageLabel:`--aws-project-arn <arn>`,usageDescription:`AWS Device Farm project ARN for hosted WebDriver sessions`},{key:`awsDeviceArn`,names:[`--aws-device-arn`],type:`string`,usageLabel:`--aws-device-arn <arn>`,usageDescription:`AWS Device Farm device ARN for hosted WebDriver sessions`},{key:`awsAppArn`,names:[`--aws-app-arn`],type:`string`,usageLabel:`--aws-app-arn <arn>`,usageDescription:`AWS Device Farm app ARN attached to hosted remote access sessions`},{key:`awsRegion`,names:[`--aws-region`],type:`string`,usageLabel:`--aws-region <region>`,usageDescription:`AWS region for Device Farm API calls`},{key:`awsInteractionMode`,names:[`--aws-interaction-mode`],type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`],usageLabel:`--aws-interaction-mode INTERACTIVE|NO_VIDEO|VIDEO_ONLY`,usageDescription:`AWS Device Farm remote access interaction mode`},{key:`force`,names:[`--force`,`--overwrite`],type:`boolean`,usageLabel:`--force, --overwrite`,usageDescription:`Force replacement of existing state (connect: replace an active connection; --save-script: overwrite an existing target instead of refusing)`},{key:`clean`,names:[`--clean`],type:`boolean`,usageLabel:`--clean`,usageDescription:`Daemon stop: remove retained runner processes and leases after stopping`},{key:`noLogin`,names:[`--no-login`],type:`boolean`,usageLabel:`--no-login`,usageDescription:`Connect: fail instead of starting implicit cloud login`},{key:`sessionLock`,names:[`--session-lock`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock reject|strip`,usageDescription:`Lock bound-session device routing for this CLI invocation and nested batch steps`}],zt=[{key:`platform`,names:[`--platform`],type:`enum`,enumValues:qe,usageLabel:`--platform ${qe.join(`|`)}`,usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:`target`,names:[`--target`],type:`enum`,enumValues:[`mobile`,`tv`,`desktop`],usageLabel:`--target mobile|tv|desktop`,usageDescription:`Device target class to match`},{key:`device`,names:[`--device`],type:`string`,usageLabel:`--device <name>`,usageDescription:`Device name to target`},{key:`udid`,names:[`--udid`],type:`string`,usageLabel:`--udid <udid>`,usageDescription:`iOS device UDID`},{key:`serial`,names:[`--serial`],type:`string`,usageLabel:`--serial <serial>`,usageDescription:`Android device or Vega VVD serial`},{key:`stale`,names:[`--stale`],type:`boolean`,usageLabel:`--stale`,usageDescription:`Device status: show only claims with a provably stale owner`},{key:`surface`,names:[`--surface`],type:`enum`,enumValues:wt,usageLabel:`--surface app|frontmost-app|desktop|menubar`,usageDescription:`macOS session surface for open (defaults to app)`},{key:`headless`,names:[`--headless`],type:`boolean`,usageLabel:`--headless`,usageDescription:`Boot: launch Android emulator without a GUI window`},{key:`targetApp`,names:[`--app`,`--target-app`],type:`string`,usageLabel:`--app <id-or-name>`,usageDescription:`Doctor: verify an installed target app without opening a session`},{key:`metroHost`,names:[`--metro-host`],type:`string`,usageLabel:`--metro-host <host>`,usageDescription:`Session-scoped Metro/debug host hint`},{key:`metroPort`,names:[`--metro-port`],type:`int`,min:1,max:65535,usageLabel:`--metro-port <port>`,usageDescription:`Session-scoped Metro/debug port hint; on an emulator/simulator the host defaults to the loopback alias, physical devices still need --metro-host`},{key:`metroProjectRoot`,names:[`--project-root`],type:`string`,usageLabel:`--project-root <path>`,usageDescription:`metro prepare: React Native project root (default: cwd)`},{key:`kind`,names:[`--kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`,...Qe],usageLabel:`--kind <kind>`,usageDescription:`Kind selector for commands that support it, such as metro prepare or perf artifact collectors`},{key:`perfTemplate`,names:[`--template`],type:`string`,usageLabel:`--template <name>`,usageDescription:`Perf xctrace template name, for example Time Profiler`},{key:`metroKind`,names:[`--metro-kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`],usageLabel:`--metro-kind auto|react-native|expo|repack`,usageDescription:`metro prepare: detect or force the React Native dev-server launcher kind`},{key:`metroPublicBaseUrl`,names:[`--public-base-url`],type:`string`,usageLabel:`--public-base-url <url>`,usageDescription:`metro prepare: public base URL used for direct dev-server bundle hints`},{key:`metroProxyBaseUrl`,names:[`--proxy-base-url`],type:`string`,usageLabel:`--proxy-base-url <url>`,usageDescription:`metro prepare: optional bridge origin for remote dev-server access`},{key:`metroBearerToken`,names:[`--bearer-token`],type:`string`,usageLabel:`--bearer-token <token>`,usageDescription:`metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)`},{key:`metroPreparePort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`metro prepare: local dev-server port (default: 8081)`},{key:`metroListenHost`,names:[`--listen-host`],type:`string`,usageLabel:`--listen-host <host>`,usageDescription:`metro prepare: host dev server listens on (default: 0.0.0.0)`},{key:`metroStatusHost`,names:[`--status-host`],type:`string`,usageLabel:`--status-host <host>`,usageDescription:`metro prepare: host used for local dev-server /status polling (default: 127.0.0.1)`},{key:`metroStartupTimeoutMs`,names:[`--startup-timeout-ms`],type:`int`,min:1,usageLabel:`--startup-timeout-ms <ms>`,usageDescription:`metro prepare: timeout while waiting for the dev server to become ready`},{key:`metroProbeTimeoutMs`,names:[`--probe-timeout-ms`],type:`int`,min:1,usageLabel:`--probe-timeout-ms <ms>`,usageDescription:`metro prepare: timeout for /status and proxy bridge calls`},{key:`metroRuntimeFile`,names:[`--runtime-file`],type:`string`,usageLabel:`--runtime-file <path>`,usageDescription:`metro prepare: optional file path to persist the JSON result`},{key:`metroNoReuseExisting`,names:[`--no-reuse-existing`],type:`boolean`,usageLabel:`--no-reuse-existing`,usageDescription:`metro prepare: always start a fresh Metro process`},{key:`metroNoInstallDeps`,names:[`--no-install-deps`],type:`boolean`,usageLabel:`--no-install-deps`,usageDescription:`metro prepare: skip package-manager install when node_modules is missing`},{key:`bundleUrl`,names:[`--bundle-url`],type:`string`,usageLabel:`--bundle-url <url>`,usageDescription:`Session-scoped bundle URL hint`},{key:`launchUrl`,names:[`--launch-url`],type:`string`,usageLabel:`--launch-url <url>`,usageDescription:`Session-scoped deep link / launch URL hint`},{key:`iosSimulatorDeviceSet`,names:[`--ios-simulator-device-set`],type:`string`,usageLabel:`--ios-simulator-device-set <path>`,usageDescription:`Scope iOS simulator discovery/commands to this simulator device set`},{key:`iosXctestrunFile`,names:[`--ios-xctestrun-file`],type:`string`,usageLabel:`--ios-xctestrun-file <path>`,usageDescription:`Use an externally built iOS XCTest runner .xctestrun artifact`},{key:`iosXctestDerivedDataPath`,names:[`--ios-xctest-derived-data-path`],type:`string`,usageLabel:`--ios-xctest-derived-data-path <path>`,usageDescription:`Derived data path for external iOS XCTest runner execution`},{key:`iosXctestEnvDir`,names:[`--ios-xctest-env-dir`],type:`string`,usageLabel:`--ios-xctest-env-dir <path>`,usageDescription:`Writable directory for per-session iOS XCTest runner env overlays`},{key:`deviceHub`,names:[`--device-hub`],type:`boolean`,usageLabel:`--device-hub`,usageDescription:`open: use Xcode Device Hub when surfacing Apple simulators`},{key:`testIme`,names:[`--test-ime`],type:`boolean`,usageLabel:`--test-ime`,usageDescription:`open: activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices)`},{key:`testIme`,names:[`--no-test-ime`],type:`boolean`,setValue:!1,usageLabel:`--no-test-ime`,usageDescription:`open: keep the real Android keyboard even on emulators (opt out of the headless test IME)`},{key:`androidDeviceAllowlist`,names:[`--android-device-allowlist`],type:`string`,usageLabel:`--android-device-allowlist <serials>`,usageDescription:`Comma/space separated Android serial allowlist for discovery/selection`},{key:`remote`,names:[`--remote`],type:`boolean`,usageLabel:`--remote`,usageDescription:`Doctor: check remote connection setup instead of local device inventory`},{key:`activity`,names:[`--activity`],type:`string`,usageLabel:`--activity <component>`,usageDescription:`Android app launch activity (package/Activity); not for URL opens`},{key:`launchConsole`,names:[`--launch-console`],type:`string`,usageLabel:`--launch-console <path>`,usageDescription:`open: capture the initial iOS simulator launch console window to a file`},{key:`launchArgs`,names:[`--launch-args`],type:`string`,multiple:!0,usageLabel:`--launch-args <arg>`,usageDescription:`open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag.`},{key:`header`,names:[`--header`],type:`string`,multiple:!0,usageLabel:`--header <name:value>`,usageDescription:`install-from-source: repeatable HTTP header for URL downloads`},{key:`githubActionsArtifact`,names:[`--github-actions-artifact`],type:`string`,usageLabel:`--github-actions-artifact <owner/repo:artifact>`,usageDescription:`install-from-source: GitHub Actions artifact resolved by a remote daemon`},{key:`installSource`,names:[],type:`string`},{key:`session`,names:[`--session`],type:`string`,usageLabel:`--session <name>`,usageDescription:`Named session`}],Bt=[{key:`replayUpdate`,names:[`--update`,`-u`],type:`boolean`,usageLabel:`--update, -u`,usageDescription:`Replay: retired as a rewrite (ADR 0012) — never edits the .ad file; every divergence already carries ranked selector suggestions, --update or not`},{key:`replayFrom`,names:[`--from`],type:`int`,min:1,usageLabel:`--from <n>`,usageDescription:`Replay: resume at 1-based plan step n, skipping 1..n-1 without executing them (requires --plan-digest; see a divergence report's resume field). replay only, not test`},{key:`replayPlanDigest`,names:[`--plan-digest`],type:`string`,usageLabel:`--plan-digest <sha256>`,usageDescription:`Replay: the plan digest a --from resume must match (from a prior divergence report); mismatch, edits, or include/platform-expansion changes fail INVALID_ARGS before any action`},{key:`replayKeepSession`,names:[`--keep-session`],type:`boolean`,usageLabel:`--keep-session`,usageDescription:`Replay: leave the session active by suppressing exactly an authored terminal close in a native .ad script; replay only, not test or Maestro YAML`},{key:`replayMaestro`,names:[`--maestro`],type:`boolean`,usageLabel:`--maestro`,usageDescription:`Replay: treat input as a supported Maestro YAML subset; unsupported syntax fails loudly. See agent-device help maestro for commands and boundaries`},{key:`replayEnv`,names:[`-e`,`--env`],type:`string`,multiple:!0,usageLabel:`-e KEY=VALUE, --env KEY=VALUE`,usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:`failFast`,names:[`--fail-fast`],type:`boolean`,usageLabel:`--fail-fast`,usageDescription:`Test: stop the suite after the first failing script; with sharding, each shard stops independently`},{key:`timeoutMs`,names:[`--timeout`],type:`int`,min:1,usageLabel:`--timeout <ms>`,usageDescription:`Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt. With --settle: the settle-wait deadline (default 10s)`},{key:`retries`,names:[`--retries`],type:`int`,min:0,max:3,usageLabel:`--retries <n>`,usageDescription:`Test: retry each failed script up to n additional times`},{key:`recordVideo`,names:[`--record-video`],type:`boolean`,usageLabel:`--record-video`,usageDescription:`Test: record each replay attempt to recording.mp4 in its attempt artifacts`},{key:`artifactsDir`,names:[`--artifacts-dir`],type:`string`,usageLabel:`--artifacts-dir <path>`,usageDescription:`Test: root directory for suite artifacts`},{key:`reporter`,names:[`--reporter`],type:`string`,multiple:!0,usageLabel:`--reporter <name-or-path>`,usageDescription:`Test: add a replay suite reporter; use default, junit:<path>, or a custom reporter path (repeatable)`},{key:`reportJunit`,names:[`--report-junit`],type:`string`,usageLabel:`--report-junit <path>`,usageDescription:`Test: compatibility alias for --reporter junit:<path>`},{key:`shardAll`,names:[`--shard-all`],type:`int`,min:1,usageLabel:`--shard-all <n>`,usageDescription:`Test: run the full suite on each of n devices; combine with --device id1,id2 for explicit connected devices; AD_SHARD_INDEX is zero-based`},{key:`shardSplit`,names:[`--shard-split`],type:`int`,min:1,usageLabel:`--shard-split <n>`,usageDescription:`Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based`},{key:`steps`,names:[`--steps`],type:`string`,usageLabel:`--steps <json>`,usageDescription:`Batch: JSON array of steps`},{key:`stepsFile`,names:[`--steps-file`],type:`string`,usageLabel:`--steps-file <path>`,usageDescription:`Batch: read steps JSON from file`},{key:`batchOnError`,names:[`--on-error`],type:`enum`,enumValues:[`stop`],usageLabel:`--on-error stop`,usageDescription:`Batch: stop when a step fails`},{key:`batchMaxSteps`,names:[`--max-steps`],type:`int`,min:1,max:1e3,usageLabel:`--max-steps <n>`,usageDescription:`Batch: maximum number of allowed steps`},{key:`appsFilter`,names:[`--all`],type:`enum`,enumValues:[`user-installed`,`all`],setValue:`all`,usageLabel:`--all`,usageDescription:`Apps: include system/OEM apps`},{key:`snapshotInteractiveOnly`,names:[`-i`],type:`boolean`,usageLabel:`-i`,usageDescription:`Snapshot: interactive elements only`},{key:`snapshotDepth`,names:[`--depth`,`-d`],type:`int`,min:0,usageLabel:`--depth, -d <depth>`,usageDescription:`Snapshot: limit snapshot depth`},{key:`snapshotScope`,names:[`--scope`,`-s`],type:`string`,usageLabel:`--scope, -s <scope>`,usageDescription:`Snapshot: scope snapshot to label/identifier`},{key:`snapshotRaw`,names:[`--raw`],type:`boolean`,usageLabel:`--raw`,usageDescription:`Snapshot: raw node output`},{key:`snapshotCustomActions`,names:[`--actions`],type:`boolean`,usageLabel:`--actions`,usageDescription:`Snapshot: name the affordances merged inside an element (iOS sim); not directly invokable — reach them via the detail screen, labeled children, or coordinates`},{key:`snapshotForceFull`,names:[`--force-full`],type:`boolean`,usageLabel:`--force-full`,usageDescription:`Snapshot: re-emit the full tree even when unchanged`},{key:`findFirst`,names:[`--first`],type:`boolean`,usageLabel:`--first`,usageDescription:`Find: pick the first match when ambiguous`},{key:`findLast`,names:[`--last`],type:`boolean`,usageLabel:`--last`,usageDescription:`Find: pick the last match when ambiguous`},{key:`out`,names:[`--out`],type:`string`,usageLabel:`--out <path>`,usageDescription:`Output path`},{key:`artifact`,names:[`--artifact`],type:`string`,usageLabel:`--artifact <path>`,usageDescription:`Debug symbols: Apple crash artifact path (.ips, .crash, or .log)`},{key:`dsym`,names:[`--dsym`],type:`string`,usageLabel:`--dsym <path>`,usageDescription:`Debug symbols: matching .dSYM bundle path`},{key:`searchPath`,names:[`--search-path`],type:`string`,usageLabel:`--search-path <dir>`,usageDescription:`Debug symbols: directory to scan for matching .dSYM bundles`},{key:`overlayRefs`,names:[`--overlay-refs`],type:`boolean`,usageLabel:`--overlay-refs`,usageDescription:`Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide`},...ge,{key:`baseline`,names:[`--baseline`,`-b`],type:`string`,usageLabel:`--baseline, -b <path>`,usageDescription:`Diff screenshot: path to baseline image file`},{key:`threshold`,names:[`--threshold`],type:`string`,usageLabel:`--threshold <0-1>`,usageDescription:`Diff screenshot: color distance threshold (default 0.1)`}],Vt=[...Rt,...zt,...Lt,...Bt],Ht=new Map;for(let e of Vt)for(let t of e.names)Ht.set(t,e);function Ut(e){return Ht.get(e)}function Wt(){return Vt}const Gt=new Set(Wt().map(e=>e.key));function Kt(e){let t=kt(e);return Re({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...Ot(t),provider:e.provider,providerSessionId:e.providerSessionId,providerApp:e.providerApp,providerOsVersion:e.providerOsVersion,providerProject:e.providerProject,providerBuild:e.providerBuild,providerSessionName:e.providerSessionName,providerDeviceOrientation:e.providerDeviceOrientation,providerGeoLocation:e.providerGeoLocation,providerTimezone:e.providerTimezone,providerLanguage:e.providerLanguage,providerLocale:e.providerLocale,providerNetworkProfile:e.providerNetworkProfile,providerCustomNetwork:e.providerCustomNetwork,providerNoResignApp:e.providerNoResignApp,awsProjectArn:e.awsProjectArn,awsDeviceArn:e.awsDeviceArn,awsAppArn:e.awsAppArn,awsRegion:e.awsRegion,awsInteractionMode:e.awsInteractionMode,sessionIsolation:e.sessionIsolation,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,surface:e.surface,activity:e.activity,launchConsole:e.launchConsole,launchArgs:e.launchArgs,relaunch:e.relaunch,shutdown:e.shutdown,saveScript:e.saveScript,deviceHub:e.deviceHub,testIme:e.testIme,noRecord:e.noRecord,recordAs:e.recordAs,record:e.record,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotCustomActions:e.customActions,snapshotForceFull:e.forceFull,...te(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,quality:e.quality,hideTouches:e.hideTouches,recordingScope:e.recordingScope,intervalMs:e.intervalMs,delayMs:e.delayMs,durationMs:e.durationMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,verify:e.verify,settle:e.settle,settleQuietMs:e.settleQuietMs,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,replayFrom:e.replayFrom,replayPlanDigest:e.replayPlanDigest,replayKeepSession:e.replayKeepSession,failFast:e.failFast,timeoutMs:e.timeoutMs,retries:e.retries,recordVideo:e.recordVideo,artifactsDir:e.artifactsDir,shardAll:e.shardAll,shardSplit:e.shardSplit,findFirst:e.findFirst,findLast:e.findLast,networkInclude:e.networkInclude,batchOnError:e.batchOnError,batchMaxSteps:e.batchMaxSteps,batchSteps:e.batchSteps,verbose:e.debug})}function qt(e,t){return{...Kt(e),...t}}function Jt(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!Gt.has(e))continue;let t=i[e];Yt(t)&&(r[e]=t)}return r}function Yt(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}const Xt=[`ref`,`selector`,`point`];function Zt(e,t=[]){return{type:`object`,properties:{...Rn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function Qt(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function $t(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function d(e){return{type:`string`,...e?{description:e}:{}}}function en(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function tn(e){return{type:`integer`,...e?{description:e}:{}}}function nn(e){return{type:`boolean`,...e?{description:e}:{}}}function rn(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function an(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function f(e){return{...e,required:!0}}function p(e){return S(d(e),y)}function on(t){return{schema:{type:`null`},required:!1,retired:!0,read:(n,r)=>{if(Object.hasOwn(n,r))throw new e(`INVALID_ARGS`,t)}}}function m(e,t={}){return S(en(e,t),(e,n)=>De(e,n,t))}function h(e,t={}){return S(Nn(e,t),(e,n)=>we(e,n,t))}function g(e){return S(nn(e),Tn)}function _(e,t){return S($t(e,t),(t,n)=>Dn(t,n,e))}function sn(e){return S(an(e),In)}function cn(e){return S(rn(e),Ln)}function v(e){return S(e,(e,t)=>e[t])}function ln(e,t){return S(e,t)}function un(){return S(zn(),(e,t)=>e[t]===void 0?void 0:bn(e,t))}function dn(){return S(Bn(),(e,t)=>e[t]===void 0?void 0:xn(e,t))}function fn(e){return S(Qt(e),(e,t)=>e[t]===void 0?void 0:Sn(e,t))}function pn(){return{depth:h(`Snapshot traversal depth.`,{min:0}),scope:p(`Snapshot scope selector used before resolution.`),raw:g(`Use raw snapshot data during selector resolution.`)}}function mn(){return{count:h(`Number of press/click repetitions.`,{min:1}),intervalMs:h(`Delay between repeated press/click actions.`,{min:0}),holdMs:h(`Hold duration for each action.`,{min:0}),jitterPx:h(`Randomization radius in pixels.`,{min:0}),doubleTap:g(`Request a double-tap action.`)}}function hn(e){return Zt(Pn(e),Fn(e))}function gn(t,n){let r=_n(t),i=Object.fromEntries(Object.entries(n).flatMap(([t,n])=>{let i=n.read(r,t);if(n.required&&i===void 0)throw new e(`INVALID_ARGS`,`Expected ${t} to be set.`);return i===void 0?[]:[[t,i]]})),a=vn(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return x({...a,...b(a),...i})}function _n(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}function vn(e,t={}){return{session:y(e,`session`),platform:Dn(e,`platform`,qe),deviceTarget:yn(e,t),device:y(e,`device`),udid:y(e,`udid`),serial:y(e,`serial`),iosSimulatorDeviceSet:y(e,`iosSimulatorDeviceSet`),iosXctestrunFile:y(e,`iosXctestrunFile`),iosXctestDerivedDataPath:y(e,`iosXctestDerivedDataPath`),iosXctestEnvDir:y(e,`iosXctestEnvDir`),androidDeviceAllowlist:y(e,`androidDeviceAllowlist`),noRecord:Tn(e,`noRecord`),daemonBaseUrl:y(e,`daemonBaseUrl`),daemonAuthToken:y(e,`daemonAuthToken`),tenant:y(e,`tenant`),runId:y(e,`runId`),leaseId:y(e,`leaseId`),cwd:y(e,`cwd`),debug:Tn(e,`debug`)}}function yn(t,n){let r=Dn(t,`deviceTarget`,Je);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=Dn(t,`target`,Je);if(r!==void 0&&i!==r)throw new e(`INVALID_ARGS`,`Expected target alias to match deviceTarget when both are set.`);return r??i}function bn(e,t){let n=Hn(e,t),r=En(n,`kind`,Xt);switch(r){case`ref`:return{kind:r,ref:Cn(n,`ref`),label:y(n,`label`)};case`selector`:return{kind:r,selector:Cn(n,`selector`)};case`point`:return{kind:r,x:wn(n,`x`),y:wn(n,`y`)}}}function xn(e,t){let n=Hn(e,t),r=En(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:Cn(n,`ref`),label:y(n,`label`)}:{kind:r,selector:Cn(n,`selector`)}}function Sn(e,t){let n=Hn(e,t);return{x:wn(n,`x`),y:wn(n,`y`)}}function Cn(t,n){let r=t[n];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}function y(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}}function wn(t,n){let r=t[n];if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}function Tn(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`boolean`)throw new e(`INVALID_ARGS`,`Expected ${n} to be a boolean.`);return r}}function En(t,n,r){let i=t[n];if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}function Dn(t,n,r){let i=t[n];if(i!==void 0){if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}}function b(e){return x({noRecord:e.noRecord,session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function On(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector};case`point`:return{x:e.x,y:e.y}}}function kn(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function An(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function jn(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function Mn(t,n,r){let i=new Set(n),a=Object.keys(t).filter(e=>!i.has(e));if(a.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${a.join(`, `)}.`)}function x(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function S(e,t){return{schema:e,required:!1,read:t}}function Nn(e,t){return{...tn(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Pn(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>!e.retired).map(([e,t])=>[e,t.schema]))}function Fn(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function In(t,n){let r=t[n];if(r!==void 0){if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be an object.`);return r}}function Ln(t,n){let r=t[n];if(r!==void 0){if(!Array.isArray(r)||r.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Expected ${n} to be an array of strings.`);return r}}function Rn(){return{session:{type:`string`,description:`Agent-device session name.`},platform:{type:`string`,enum:qe,description:`Platform selector used to resolve a device.`},deviceTarget:{type:`string`,enum:Je,description:`Device target form. Maps to the CLI --target flag.`},target:{type:`string`,enum:Je,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`},device:{type:`string`,description:`Device name selector.`},udid:{type:`string`,description:`iOS device UDID selector.`},serial:{type:`string`,description:`Android device or Vega VVD serial selector.`},iosSimulatorDeviceSet:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},iosXctestrunFile:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},iosXctestDerivedDataPath:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},iosXctestEnvDir:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},androidDeviceAllowlist:{type:`string`,description:`Android serial allowlist used for device resolution.`},daemonBaseUrl:{type:`string`,description:`Remote daemon base URL.`},daemonAuthToken:{type:`string`,description:`Remote daemon auth token.`},tenant:{type:`string`,description:`Remote tenant identifier.`},runId:{type:`string`,description:`Lease run identifier.`},leaseId:{type:`string`,description:`Existing lease identifier.`},cwd:{type:`string`,description:`Working directory for command execution.`},debug:{type:`boolean`,description:`Enable debug diagnostics.`}}}function zn(){return{oneOf:[...Vn(),{type:`object`,properties:{kind:{type:`string`,const:`point`},x:{type:`number`},y:{type:`number`}},required:[`kind`,`x`,`y`],additionalProperties:!1}],description:`UI target. This is separate from deviceTarget, which selects the device form.`}}function Bn(){return{oneOf:Vn(),description:`UI element target by snapshot ref or selector expression.`}}function Vn(){return[{type:`object`,properties:{kind:{type:`string`,const:`ref`},ref:{type:`string`,description:`Snapshot element ref such as @e12.`},label:{type:`string`,description:`Optional human label for the ref.`}},required:[`kind`,`ref`],additionalProperties:!1},{type:`object`,properties:{kind:{type:`string`,const:`selector`},selector:{type:`string`,description:`Agent-device selector expression.`}},required:[`kind`,`selector`],additionalProperties:!1}]}function Hn(t,n){let r=t[n];if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be an object.`);return r}function C(e,t){return n=>w(e,t?t(n):[],n)}function w(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Un(n)}}function Un(e){let t=Wn(e.deviceTarget??e.target);if(t===void 0&&e.target===void 0)return e;let{target:n,...r}=e;return t===void 0?r:{...r,target:t}}function Wn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function T(e){return x({noRecord:e.noRecord,session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist})}function Gn(e){return x({record:e.record})}function Kn(e){return{noRecord:e.noRecord,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function qn(e){return x({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Jn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function E(e){return x({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Yn(e){return x({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function Xn(e){if(`ref`in e&&e.ref!==void 0)return x({kind:`ref`,ref:e.ref,label:e.label});if(`selector`in e&&e.selector!==void 0)return{kind:`selector`,selector:e.selector};let t=e;return{kind:`point`,x:t.x,y:t.y}}function Zn(t){let n=$n(t);if(typeof n.ref==`string`)return[n.ref,...tr(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(er(n.x,`x`)),String(er(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function Qn(t){let n=$n(t);if(typeof n.ref==`string`)return[n.ref,...tr(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function $n(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected target object.`);let n=t,r=n.target;return r&&typeof r==`object`&&!Array.isArray(r)?r:n}function er(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function tr(e){return typeof e==`string`&&e.length>0?[e]:[]}function nr(t){let n=Te(t);if(!n.ok)throw new e(n.code,n.message);return`ref`in n?{ref:n.ref,label:or(t.slice(1))}:{selector:n.selector}}function rr(t){let n=Be(t);if(!n.ok)throw new e(n.code,n.message);return n.format}function ir(t,n={}){let r=Ge(t,n);if(!r)throw new e(`INVALID_ARGS`,Ce);return r}function ar(t,n){try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{}throw new e(`INVALID_ARGS`,`${n} must be a JSON object`)}function or(e){return e.join(` `).trim()||void 0}function D(...e){return new Set(e)}function O(e,t){return e!==void 0&&t.has(e)}function sr(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function cr(t,n){if(t===void 0)return;let r=Number(t);if(Number.isFinite(r))return r;throw new e(`INVALID_ARGS`,`${n} must be a finite number.`)}function k(e){return e===void 0?void 0:Number(e)}function A(e){return e===void 0?[]:[e]}function j(e){return e===void 0?[]:[String(e)]}function M(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function N(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function lr(e){return fr(e.description,e.cliDetail)}function ur(e){return fr(e.description,e.mcpDetail)}function dr(e,t){return{...e,description:t}}function fr(e,t){return t?`${e} ${t}`:e}function P(e){let t=dr(e.text,e.metadata.description),n=t.mcpDetail?{mcpDetail:t.mcpDetail}:{};return{...e,metadata:{...e.metadata,...n},definition:{...e.definition,...n},cliSchema:{...e.cliSchema,text:t}}}function F(e){let t={},n={},r={},i={},a={};for(let o of e.commands){I(t,`CLI schema`,o.name,o.cliSchema);let e=o.definition.projection?.clientMethod??o.clientMethod;e&&I(n,`client command method`,e,o.name),I(r,`CLI reader`,o.name,o.cliReader),o.daemonWriter&&I(i,`daemon writer`,o.name,o.daemonWriter),o.cliOutputFormatter&&I(a,`CLI output formatter`,o.name,o.cliOutputFormatter)}return{name:e.name,clientSurface:e.clientSurface,metadata:e.commands.map(e=>e.metadata),definitions:e.commands.map(e=>e.definition),clientCommandMethods:n,cliSchemas:t,cliReaders:r,daemonWriters:i,cliOutputFormatters:a}}function pr(e){let t={};for(let n of e)n.projection&&I(t,`command output schema`,n.name,n.projection.outputSchema);return t}function I(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function L(e){return e}function R(e,t,n){return{...e,run:t,invoke:async(n,r)=>await t(n,e.readInput(r)),...n?{projection:n}:{}}}function z(e){return({result:t})=>e(t)}const B=z(V);function V(e){return{data:e,text:ht(e)}}function mr(e,t){if(!(typeof e!=`string`||e.length===0)&&typeof t==`number`)return`@${e.startsWith(`@`)?e.slice(1):e}~s${t}`}function hr(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(_r(n));return{data:e,text:t.join(`
|
|
2
|
-
`)}}const gr={batch:z(hr)};function _r(e){let t=ht(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function vr(e=Ve){let t=yr(e);return L({name:`batch`,description:`Execute multiple commands in one daemon request`,inputSchema:hn(t),readInput:e=>xr(e,t)})}function yr(e){return{steps:f(ln({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:br(e)},(t,n)=>Sr(t[n],e))),onError:_([`stop`],`Batch failure policy.`),maxSteps:h(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:p(`Optional output path for command artifacts.`)}}function br(e){return{type:`object`,properties:{command:{type:`string`,enum:e,description:`Command name to run with structured input.`},input:{type:`object`,additionalProperties:!0,description:`Structured command input for the nested command. Use the matching MCP tool schema for this object.`},runtime:{type:`object`,additionalProperties:!0,description:`Optional per-step runtime payload.`}},required:[`command`,`input`],additionalProperties:!1}}function xr(t,n){let r=gn(t,n),i=r.maxSteps??100;if(!Me(i))throw new e(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(r.maxSteps)}`);return Ue(r.steps.length,i),{...r}}function Sr(t,n){if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected steps to be an array.`);return t.map((e,t)=>Cr(e,t+1,n))}function Cr(e,t,n){let r=Le(e,t);return Mn(r,[`command`,`input`,`runtime`],`Batch step ${t}`),{command:wr(r,t,n),input:ze(r,t),...Tr(r,t)}}function wr(t,n,r){if(r===Ve)return Ie(t.command,n);let i=t.command;if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected command to be one of: ${r.join(`, `)}.`);return i}function Tr(e,t){let n=Pe(e.runtime,t);return n===void 0?{}:{runtime:n}}function Er(e){return t=>w(u.batch,[],{...t,batchSteps:Dr(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}function Dr(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty steps array.`);return t.map((e,t)=>Or(e,t+1,n))}function Or(e,t,n){let r=Le(e,t),i=kr(r,t),a=ze(r,t),o=Pe(r.runtime,t),s=n(i,a,t);return{command:s.command,positionals:s.positionals,...s.input?{input:s.input}:{},flags:qt(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function kr(e,t){return Ie(e.command,t)}const Ar=vr(),jr=F({name:`batch`,clientSurface:!1,commands:[P({name:`batch`,text:{summary:`Run multiple commands`},metadata:Ar,definition:R(Ar,(e,t)=>e.batch.run(Mr(t))),cliSchema:{usageOverride:`batch [--steps <json> | --steps-file <path>]`,listUsageOverride:`batch --steps <json> | --steps-file <path>`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},cliReader:(e,t)=>({...T(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),cliOutputFormatter:gr.batch})]});function Mr(e){return{...b(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}function H(e,t,n){return L({name:e,description:t,inputSchema:hn(n),readInput:e=>gn(e,n)})}const Nr=`alert`,Pr=H(Nr,`Inspect, wait for, accept, or dismiss a platform alert. Use get before acting when the alert content matters; accept and dismiss change the active alert state.`,{action:_(ve),timeoutMs:h()}),Fr=P({name:Nr,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:Pr,definition:R(Pr,(e,t)=>e.command.alert(t)),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...T(t),...Lr(e)}),daemonWriter:C(u.alert,e=>Ir(e)),cliOutputFormatter:B});function Ir(e){return[e.action??`get`,...j(e.timeoutMs)]}function Lr(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return x({action:Rr(t[0]),timeoutMs:cr(t[1],`alert timeout`)})}function Rr(t){let n=t?.toLowerCase();if(n===void 0||n===`get`||n===`accept`||n===`dismiss`||n===`wait`)return n;throw new e(`INVALID_ARGS`,`alert action must be get, accept, dismiss, or wait.`)}function U(...e){return e}const zr=U(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),W=U(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Br=U(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Vr=U(`metroHost`,`metroPort`,`bundleUrl`),Hr=U(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Ur=U(`settle`,`settleQuietMs`,`timeoutMs`),Wr=U(`replayUpdate`,`replayEnv`),Gr=U(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`providerDeviceOrientation`,`providerGeoLocation`,`providerTimezone`,`providerLanguage`,`providerLocale`,`providerNetworkProfile`,`providerCustomNetwork`,`providerNoResignApp`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Kr=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),qr=`diff`,Jr=H(qr,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:f(v({type:`string`,const:`snapshot`})),out:p(),interactiveOnly:g(),depth:h(),scope:p(),raw:g()}),Yr=P({name:qr,text:{summary:`Diff snapshot or screenshot`,cliDetail:`Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`},metadata:Jr,definition:R(Jr,(e,t)=>e.capture.diff(t)),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,positionalArgs:[`kind`,`current?`],allowedFlags:[...zr,`baseline`,`threshold`,`out`,`overlayRefs`]},cliReader:(t,n)=>{if(t[0]!==`snapshot`)throw new e(`INVALID_ARGS`,`Only diff snapshot is available through this parser.`);return{...T(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:C(u.diff,e=>[N(e.kind,`diff requires kind`)])}),Xr=`screenshot`,Zr=H(Xr,`Capture a screenshot of the active app or web session. Choose the capture scope, density, size, or annotations through the corresponding input fields when needed.`,{path:p(`Output path.`),overlayRefs:g(),pixelDensity:h(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:g(),scale:m(`Screenshot scale factor.`,re),maxSize:on(se.migration.screenshot),stabilize:g(),normalizeStatusBar:g(),surface:_(wt)}),Qr=P({name:Xr,text:{summary:`Capture a screenshot`,cliDetail:`Web defaults to the viewport; use --fullscreen, --full, or -f for the entire page. iOS simulators default to 1x logical-point output; use --pixel-density to request a different screenshot density. macOS app sessions default to the app window; use --fullscreen for full desktop, --scale to downscale, --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops.`},metadata:Zr,definition:R(Zr,(e,t)=>e.capture.screenshot(t)),cliSchema:{positionalArgs:[`path?`],allowedFlags:a},cliReader:(e,t)=>({...T(t),path:e[0]??t.out,...o(t)}),daemonWriter:e=>(s(`screenshot`,e),ee(e),w(u.screenshot,A(e.path),{...e,...ie(e)}))}),$r=`settings`,ei=H($r,`Change supported operating-system settings, animation scales, appearance, or app permissions on the selected target. Platform support varies by setting and action.`,{setting:f(p()),state:f(p()),app:p(),latitude:m(),longitude:m(),permission:p(),mode:_([`full`,`limited`])}),ti=P({name:$r,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS. Mobile permission actions use the active session app.`},metadata:ei,definition:R(ei,(e,t)=>e.settings.update(t)),cliSchema:{usageOverride:me,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state`,`target?`,`mode?`]},cliReader:(e,t)=>ni(e,t),daemonWriter:C(u.settings,e=>ri(e))});function ni(t,n){let r=Kn(n),i=t[0],a=t[1];if(O(i,oi)&&O(a,si))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:ye(t[2],`latitude`),longitude:ye(t[3],`longitude`)};if(i===`appearance`&&O(a,ci)||O(i,li)&&O(a,ui)||i===`fingerprint`&&O(a,di))return{...r,setting:i,state:a};if(i===`permission`&&O(a,fi))return{...r,setting:i,state:a,permission:ii(t[2]),mode:ai(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function ri(e){return e.setting===`clear-app-state`?[e.setting,...A(e.app)]:e.setting===`location`&&e.state===`set`?[e.setting,e.state,String(e.latitude),String(e.longitude)]:e.setting===`permission`?[e.setting,e.state,e.permission,...A(e.mode)]:[e.setting,e.state]}function ii(t){if(O(t,pi))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function ai(t){if(t===void 0||t===`full`||t===`limited`)return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const oi=D(`wifi`,`airplane`,`location`,`animations`),si=D(`on`,`off`),ci=D(`light`,`dark`,`toggle`),li=D(`faceid`,`touchid`),ui=D(`match`,`nonmatch`,`enroll`,`unenroll`),di=D(`match`,`nonmatch`),fi=D(`grant`,`deny`,`reset`),pi=D(`camera`,`microphone`,`photos`,`contacts`,`contacts-limited`,`notifications`,`calendar`,`location`,`location-always`,`media-library`,`motion`,`reminders`,`siri`,`accessibility`,`screen-recording`,`input-monitoring`);function mi(e){if(!Array.isArray(e)||e.length===0)return e;let t=Ke(e);return e.map(e=>{let n=hi(e,t,e=>e.label),r=hi(e,t,e=>e.identifier),i=typeof e.label==`string`&&e.label.length>=24&&e.label===n,a=typeof e.identifier==`string`&&e.identifier.length>=24&&e.identifier===r;if(!i&&!a)return e;let o={...e};return i&&(delete o.label,o.inheritsLabel=!0),a&&(delete o.identifier,o.inheritsIdentifier=!0),o})}function hi(e,t,n){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0;for(;r;){let e=n(r);if(typeof e==`string`&&e.length>0)return e;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}}function gi(e){let t=yt(e.raw||!Array.isArray(e.result.nodes)?e.result:{...e.result,nodes:mi(e.result.nodes)});return{data:t,jsonData:vi(t),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:lt(t,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const _i={snapshot:({input:e,result:t})=>gi({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:B,alert:B};function vi(e){let{unchanged:t,...n}=e;return n}const yi=`snapshot`,bi=H(yi,`Capture the accessibility tree or compare it with the previous session baseline. Use the returned refs for subsequent semantic interactions and the diff option to verify UI changes.`,{interactiveOnly:g(),depth:h(),scope:p(),raw:g(),customActions:g(`Name the affordances an element merged away (iOS UIAccessibilityCustomAction, React Native accessibilityActions) — a card whose reply/options controls are not separate elements still lists them here. The names are for PLANNING, not invocation: there is no API to trigger them, so reach the affordance through the element detail screen, through the same control exposed as a labeled element elsewhere, or by coordinates from its rect. iOS simulator only; costs one accessibility round trip per merged element.`),forceFull:g(),timeoutMs:h(`Maximum wall-clock time for the snapshot command.`),noRecord:g(`Do not record this action.`),record:g(`Force-record this out-of-band observation into a repair-armed heal (mutually exclusive with noRecord). Authored replay steps are recorded automatically and never need this.`)}),xi=P({name:yi,text:{summary:`Capture or diff the accessibility tree`,cliDetail:`For iOS raw-coordinate fallback after a no-op ref press, inspect rects with snapshot -i --json, press the rect center, then verify with diff snapshot -i or snapshot --diff.`},metadata:bi,definition:R(bi,(e,t)=>e.capture.snapshot(t)),cliSchema:{usageOverride:`snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--actions] [--force-full] [--timeout <ms>]`,allowedFlags:[`snapshotDiff`,...zr,`snapshotCustomActions`,`snapshotForceFull`,`timeoutMs`,`record`]},cliReader:(e,t)=>({...T(t),...Gn(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,customActions:t.snapshotCustomActions,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),daemonWriter:C(u.snapshot),cliOutputFormatter:_i.snapshot}),Si=[`duration`,`text`,`ref`,`selector`,`stable`],Ci=`wait`,wi=H(Ci,`Wait for a duration, text, snapshot ref, selector, or stable UI. Use text, ref, or selector for a specific readiness condition; stable waits until the UI stays quiet for the requested window.`,{kind:_(Si),durationMs:h(),text:p(),ref:p(),selector:p(),stable:g(),quietMs:h(),timeoutMs:h(),depth:h(),scope:p(),raw:g()}),Ti=P({name:Ci,text:{summary:`Wait for a duration, text, selector, or stable UI`},metadata:wi,definition:R(wi,(e,t)=>e.command.wait(Ei(t))),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|stable [quietMs] [timeoutMs]`,positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...W]},cliReader:(e,t)=>Di(e,t),daemonWriter:C(u.wait,e=>Oi(e)),cliOutputFormatter:B});function Ei(e){Dn(e,`kind`,Si);let t={...e};return delete t.kind,t}function Di(t,n){let r=je(t);if(!r)throw new e(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...Kn(n),...Jn(n)};if(r.kind===`sleep`)return{...i,durationMs:r.durationMs};if(r.kind===`text`){if(!r.text)throw new e(`INVALID_ARGS`,`wait requires text.`);return{...i,text:r.text,...ki(r.timeoutMs)}}return r.kind===`ref`?{...i,ref:r.rawRef,...ki(r.timeoutMs)}:r.kind===`stable`?{...i,stable:!0,...Ai(r.quietMs),...ki(r.timeoutMs)}:{...i,selector:r.selectorExpression,...ki(r.timeoutMs)}}function Oi(t){if([t.durationMs===void 0?void 0:`durationMs`,t.text===void 0?void 0:`text`,t.ref===void 0?void 0:`ref`,t.selector===void 0?void 0:`selector`,t.stable===void 0?void 0:`stable`].filter(Boolean).length!==1)throw new e(`INVALID_ARGS`,`wait command requires exactly one of durationMs, text, ref, selector, or stable.`);if(t.durationMs!==void 0)return[String(t.durationMs)];let n=j(t.timeoutMs);if(t.text!==void 0)return[`text`,t.text,...n];if(t.ref!==void 0)return[t.ref,...n];if(t.stable!==void 0){let r=j(t.quietMs);if(r.length===0&&n.length>0)throw new e(`INVALID_ARGS`,`wait stable requires quietMs before timeoutMs.`);return[`stable`,...r,...n]}let r=t.selector;if(!We(r))throw new e(`INVALID_ARGS`,`Invalid wait selector: ${r}`);return[r,...n]}function ki(e){return e===null?{}:{timeoutMs:e}}function Ai(e){return e===null?{}:{quietMs:e}}const ji=F({name:`capture`,commands:[xi,Qr,Yr,Ti,Fr,ti]});function Mi(e){let t=[e.outPath,e.message];t.push(...Pi(e));for(let n of e.matchedImages)t.push(`Matched: ${n.name} ${n.uuid}${n.arch?` ${n.arch}`:``}`);for(let n of e.warnings??[])t.push(`Warning: ${n}`);return{data:e,text:t.join(`
|
|
3
|
-
`)}}const
|
|
4
|
-
`)}`}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}}function
|
|
7
|
-
`)}}function
|
|
1
|
+
import{_ as e,n as t,t as n}from"./sdk-contracts.js";import{D as r,E as i,O as a,T as o,_ as s,b as c,i as ee,k as te,t as ne,x as re,y as ie}from"./location-coordinates.js";import{Br as ae,Gt as oe,Hn as se,Jn as ce,Kn as le,Rn as ue,Un as de,Ut as fe,Vn as pe,c as me,d as he,dn as ge,er as _e,gr as ve,hn as ye,i as be,kr as l,l as xe,ln as Se,m as Ce,p as we,r as Te,s as Ee,u as De,zn as Oe}from"./sdk-batch-runner.js";import{r as ke,t as Ae}from"./sdk-device.js";import{Bt as je,Dt as Me,Ft as Ne,It as Pe,Kt as Fe,Lt as Ie,Nt as Le,Pt as Re,Rt as ze,Yt as Be,_t as Ve,a as He,c as Ue,ft as We,gt as Ge,l as Ke,n as qe,o as Je,r as Ye,t as Xe,zt as Ze}from"./prepare-kind.js";import{n as Qe}from"./recording-export-quality.js";import{A as $e,F as et,H as tt,K as nt,M as rt,N as it,O as at,P as ot,c as st,i as ct,j as lt,k as ut,l as dt,n as ft,q as pt,r as mt,w as ht,x as gt}from"./interaction.js";import{n as u,t as _t}from"./command-catalog.js";import{a as vt}from"./sdk-remote-config.js";import{t as yt}from"./session.js";import{a as bt,c as xt,d as St,f as Ct,h as wt,i as Tt,l as Et,m as Dt,n as Ot,o as kt,r as At,t as jt,u as Mt}from"./observability.js";import{a as Nt,d as Pt,f as Ft,t as It}from"./device.js";const Lt=[{key:`count`,names:[`--count`],type:`int`,min:1,max:200,usageLabel:`--count <n>`,usageDescription:`Repeat count for press/swipe series`},{key:`pointerCount`,names:[`--pointer-count`],type:`int`,min:1,max:2,usageLabel:`--pointer-count <1|2>`,usageDescription:`Gesture pan: number of touch pointers (default 1)`},{key:`fps`,names:[`--fps`],type:`int`,min:1,max:120,usageLabel:`--fps <n>`,usageDescription:`Record: target frames per second (iOS physical device runner)`},{key:`quality`,names:[`--quality`],type:`string`,usageLabel:`--quality <medium|high>`,usageDescription:`Record: output quality preset; Android maps this to screenrecord bitrate, Apple targets use it for export/encoding. Legacy numeric values 5-7 map to medium; 8-10 map to high`},{key:`hideTouches`,names:[`--hide-touches`],type:`boolean`,usageLabel:`--hide-touches`,usageDescription:`Record: skip touch-overlay post-processing for faster raw benchmark videos`},{key:`recordingScope`,names:[`--scope`],type:`enum`,enumValues:Me,usageLabel:`--scope <app|device|system>`,usageDescription:`Record: app requires an active app session; device/system records the whole screen`},{key:`intervalMs`,names:[`--interval-ms`],type:`int`,min:0,max:1e4,usageLabel:`--interval-ms <ms>`,usageDescription:`Delay between press iterations`},{key:`delayMs`,names:[`--delay-ms`],type:`int`,min:0,max:1e4,usageLabel:`--delay-ms <ms>`,usageDescription:`Delay between typed characters`},{key:`recordAs`,names:[`--record-as`],type:`string`,usageLabel:`--record-as <VAR>`,usageDescription:"Fill: send the live text but publish ${VAR} in an armed .ad recording"},{key:`durationMs`,names:[`--duration-ms`],type:`int`,min:0,max:1e4,usageLabel:`--duration-ms <ms>`,usageDescription:`Scroll: pace the gesture over this duration when supported`},{key:`holdMs`,names:[`--hold-ms`],type:`int`,min:0,max:1e4,usageLabel:`--hold-ms <ms>`,usageDescription:`Press hold duration for each iteration`},{key:`jitterPx`,names:[`--jitter-px`],type:`int`,min:0,max:100,usageLabel:`--jitter-px <n>`,usageDescription:`Deterministic coordinate jitter radius for press`},{key:`pixels`,names:[`--pixels`],type:`int`,min:1,max:1e5,usageLabel:`--pixels <n>`,usageDescription:`Scroll: explicit gesture distance in pixels`},{key:`doubleTap`,names:[`--double-tap`],type:`boolean`,usageLabel:`--double-tap`,usageDescription:`Use double-tap gesture per press iteration`},{key:`verify`,names:[`--verify`],type:`boolean`,usageLabel:`--verify`,usageDescription:`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot`},{key:`settle`,names:[`--settle`],type:`boolean`,usageLabel:`--settle`,usageDescription:`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response (best-effort; never fails the action)`},{key:`settleQuietMs`,names:[`--settle-quiet`],type:`int`,min:0,usageLabel:`--settle-quiet <ms>`,usageDescription:`Settle: quiet window the UI must hold to count as settled (default 500ms)`},{key:`clickButton`,names:[`--button`],type:`enum`,enumValues:[`primary`,`secondary`,`middle`],usageLabel:`--button primary|secondary|middle`,usageDescription:`Click: choose mouse button (middle reserved for future macOS support)`},{key:`backMode`,names:[`--in-app`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`in-app`,usageLabel:`--in-app`,usageDescription:`Back: use app-provided back UI when available`},{key:`backMode`,names:[`--system`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`system`,usageLabel:`--system`,usageDescription:`Back: use system back input or gesture when available`},{key:`pauseMs`,names:[`--pause-ms`],type:`int`,min:0,max:1e4,usageLabel:`--pause-ms <ms>`,usageDescription:`Delay between swipe iterations`},{key:`pattern`,names:[`--pattern`],type:`enum`,enumValues:[`one-way`,`ping-pong`],usageLabel:`--pattern one-way|ping-pong`,usageDescription:`Swipe repeat pattern`},{key:`verbose`,names:[`--debug`,`--verbose`,`-v`],type:`boolean`,usageLabel:`--debug, --verbose, -v`,usageDescription:`Enable debug diagnostics; test --verbose prints per-test step timings without debug logs`},{key:`cost`,names:[`--cost`],type:`boolean`,usageLabel:`--cost`,usageDescription:`Include per-command wall-clock latency (cost.wallClockMs) in the response`},{key:`responseLevel`,names:[`--level`],type:`enum`,enumValues:t,usageLabel:`--level digest|default|full`,usageDescription:`Response detail level: digest (token-cheap), default (today), or full. Default keeps the wire shape unchanged.`},{key:`json`,names:[`--json`],type:`boolean`,usageLabel:`--json`,usageDescription:`JSON output`},{key:`help`,names:[`--help`,`-h`],type:`boolean`,usageLabel:`--help, -h`,usageDescription:`Print help and exit`},{key:`version`,names:[`--version`,`-V`],type:`boolean`,usageLabel:`--version, -V`,usageDescription:`Print version and exit`},{key:`snapshotDiff`,names:[`--diff`],type:`boolean`,usageLabel:`--diff`,usageDescription:`Snapshot: show structural diff against the previous session baseline`},{key:`saveScript`,names:[`--save-script`],type:`booleanOrString`,usageLabel:`--save-script [path]`,usageDescription:`Arm evidence capture on open, publish the armed recording on close; close --save-script alone (without an armed open) is rejected — start with open --save-script, or use session save-script mid-session. Optional custom output path.`},{key:`networkInclude`,names:[`--include`],type:`enum`,enumValues:[`summary`,`headers`,`body`,`all`],usageLabel:`--include summary|headers|body|all`,usageDescription:`Network: include headers, bodies, or both in output`},{key:`shutdown`,names:[`--shutdown`],type:`boolean`,usageLabel:`--shutdown`,usageDescription:`close: shutdown associated simulator/emulator after ending session`},{key:`relaunch`,names:[`--relaunch`],type:`boolean`,usageLabel:`--relaunch`,usageDescription:`open: terminate app process before launching it`},{key:`foreground`,names:[`--foreground`],type:`boolean`,usageLabel:`--foreground`,usageDescription:`open: keep normal app/device selection and return an initial snapshot; without an app, resolve the sole running app on the sole booted iOS simulator`},{key:`restart`,names:[`--restart`],type:`boolean`,usageLabel:`--restart`,usageDescription:`logs clear: stop active stream, clear logs, then start streaming again`},{key:`retainPaths`,names:[`--retain-paths`],type:`boolean`,usageLabel:`--retain-paths`,usageDescription:`install-from-source: keep materialized artifact paths after install`},{key:`retentionMs`,names:[`--retention-ms`],type:`int`,min:1,usageLabel:`--retention-ms <ms>`,usageDescription:`install-from-source: retention TTL for materialized artifact paths`},{key:`noRecord`,names:[`--no-record`],type:`boolean`,usageLabel:`--no-record`,usageDescription:`Do not record this action`},{key:`record`,names:[`--record`],type:`boolean`,usageLabel:`--record`,usageDescription:`Force-record this action even though its command is observation-only and would otherwise be excluded from a repair-armed heal by default (mutually exclusive with --no-record)`}],Rt=[{key:`config`,names:[`--config`],type:`string`,usageLabel:`--config <path>`,usageDescription:`Load CLI defaults from a specific config file (required for connection/provider defaults outside user config)`},{key:`remoteConfig`,names:[`--remote-config`],type:`string`,usageLabel:`--remote-config <path>`,usageDescription:`Load remote host + Metro workflow settings from a specific profile file`},{key:`stateDir`,names:[`--state-dir`],type:`string`,usageLabel:`--state-dir <path>`,usageDescription:`Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)`},{key:`daemonBaseUrl`,names:[`--daemon-base-url`],type:`string`,usageLabel:`--daemon-base-url <url>`,usageDescription:`Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)`},{key:`daemonAuthToken`,names:[`--daemon-auth-token`],type:`string`,usageLabel:`--daemon-auth-token <token>`,usageDescription:`Remote HTTP daemon or proxy auth token (sent as request token and bearer header)`},{key:`daemonTransport`,names:[`--daemon-transport`],type:`enum`,enumValues:[`auto`,`socket`,`http`],usageLabel:`--daemon-transport auto|socket|http`,usageDescription:`Daemon client transport preference`},{key:`daemonServerMode`,names:[`--daemon-server-mode`],type:`enum`,enumValues:[`socket`,`http`,`dual`],usageLabel:`--daemon-server-mode socket|http|dual`,usageDescription:`Daemon server mode used when spawning daemon`},{key:`proxyHost`,names:[`--host`],type:`string`,usageLabel:`--host <host>`,usageDescription:`Proxy: host interface to bind (default: 127.0.0.1)`},{key:`proxyPort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`Proxy: TCP port to bind (default: 0, choose a free port)`},{key:`tenant`,names:[`--tenant`],type:`string`,usageLabel:`--tenant <id>`,usageDescription:`Tenant scope identifier for isolated daemon sessions`},{key:`sessionIsolation`,names:[`--session-isolation`],type:`enum`,enumValues:[`none`,`tenant`],usageLabel:`--session-isolation none|tenant`,usageDescription:`Session isolation strategy (tenant prefixes session namespace)`},{key:`runId`,names:[`--run-id`],type:`string`,usageLabel:`--run-id <id>`,usageDescription:`Run identifier used for tenant lease admission checks`},{key:`leaseId`,names:[`--lease-id`],type:`string`,usageLabel:`--lease-id <id>`,usageDescription:`Lease identifier bound to tenant/run admission scope`},{key:`leaseBackend`,names:[`--lease-backend`],type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`],usageLabel:`--lease-backend ios-simulator|ios-instance|android-instance`,usageDescription:`Lease backend for remote tenant connection admission`},{key:`provider`,names:[`--provider`],type:`string`,usageLabel:`--provider <name>`,usageDescription:`Cloud provider name for provider-scoped commands`},{key:`providerSessionId`,names:[`--provider-session`],type:`string`,usageLabel:`--provider-session <id>`,usageDescription:`Cloud provider session id or ARN`},{key:`providerApp`,names:[`--provider-app`],type:`string`,usageLabel:`--provider-app <ref-or-path>`,usageDescription:`Cloud provider app reference or local app path used when creating hosted WebDriver sessions`},{key:`providerOsVersion`,names:[`--provider-os-version`,`--os-version`],type:`string`,usageLabel:`--provider-os-version <version>`,usageDescription:`Hosted cloud provider OS version, for example 17 or 14.0`},{key:`providerProject`,names:[`--provider-project`],type:`string`,usageLabel:`--provider-project <name>`,usageDescription:`Hosted cloud provider project label`},{key:`providerBuild`,names:[`--provider-build`],type:`string`,usageLabel:`--provider-build <name>`,usageDescription:`Hosted cloud provider build label`},{key:`providerSessionName`,names:[`--provider-session-name`],type:`string`,usageLabel:`--provider-session-name <name>`,usageDescription:`Hosted cloud provider session label`},{key:`providerDeviceOrientation`,names:[`--provider-device-orientation`,`--device-orientation`],type:`enum`,enumValues:vt,usageLabel:`--provider-device-orientation portrait|landscape`,usageDescription:`Screen orientation a hosted cloud provider session starts in. Set this rather than rotating after launch: a session that boots landscape renders login webviews landscape`},{key:`providerGeoLocation`,names:[`--provider-geo-location`,`--geo-location`],type:`string`,usageLabel:`--provider-geo-location <country>`,usageDescription:`Hosted cloud provider IP geolocation country code, for example US`},{key:`providerTimezone`,names:[`--provider-timezone`,`--timezone`],type:`string`,usageLabel:`--provider-timezone <zone>`,usageDescription:`Hosted cloud provider device time zone, for example New_York`},{key:`providerLanguage`,names:[`--provider-language`,`--language`],type:`string`,usageLabel:`--provider-language <language>`,usageDescription:`Hosted cloud provider app language, for example Fr`},{key:`providerLocale`,names:[`--provider-locale`,`--locale`],type:`string`,usageLabel:`--provider-locale <locale>`,usageDescription:`Hosted cloud provider device locale, for example Fr`},{key:`providerNetworkProfile`,names:[`--provider-network-profile`,`--network-profile`],type:`string`,usageLabel:`--provider-network-profile <profile>`,usageDescription:`Hosted cloud provider named network condition profile, for example 4g-lte-advanced-good. Mutually exclusive with --provider-custom-network`},{key:`providerCustomNetwork`,names:[`--provider-custom-network`,`--custom-network`],type:`string`,usageLabel:`--provider-custom-network <shape>`,usageDescription:`Hosted cloud provider custom network shape. Mutually exclusive with --provider-network-profile`},{key:`providerNoResignApp`,names:[`--provider-no-resign-app`],type:`boolean`,usageLabel:`--provider-no-resign-app`,usageDescription:`iOS only: keep an Enterprise-signed app as uploaded instead of letting the provider re-sign it, which strips entitlements such as push notifications`},{key:`awsProjectArn`,names:[`--aws-project-arn`],type:`string`,usageLabel:`--aws-project-arn <arn>`,usageDescription:`AWS Device Farm project ARN for hosted WebDriver sessions`},{key:`awsDeviceArn`,names:[`--aws-device-arn`],type:`string`,usageLabel:`--aws-device-arn <arn>`,usageDescription:`AWS Device Farm device ARN for hosted WebDriver sessions`},{key:`awsAppArn`,names:[`--aws-app-arn`],type:`string`,usageLabel:`--aws-app-arn <arn>`,usageDescription:`AWS Device Farm app ARN attached to hosted remote access sessions`},{key:`awsRegion`,names:[`--aws-region`],type:`string`,usageLabel:`--aws-region <region>`,usageDescription:`AWS region for Device Farm API calls`},{key:`awsInteractionMode`,names:[`--aws-interaction-mode`],type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`],usageLabel:`--aws-interaction-mode INTERACTIVE|NO_VIDEO|VIDEO_ONLY`,usageDescription:`AWS Device Farm remote access interaction mode`},{key:`force`,names:[`--force`,`--overwrite`],type:`boolean`,usageLabel:`--force, --overwrite`,usageDescription:`Force replacement of existing state (connect: replace an active connection; --save-script: overwrite an existing target instead of refusing)`},{key:`clean`,names:[`--clean`],type:`boolean`,usageLabel:`--clean`,usageDescription:`Daemon stop: remove retained runner processes and leases after stopping`},{key:`noLogin`,names:[`--no-login`],type:`boolean`,usageLabel:`--no-login`,usageDescription:`Connect: fail instead of starting implicit cloud login`},{key:`sessionLock`,names:[`--session-lock`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock reject|strip`,usageDescription:`Lock bound-session device routing for this CLI invocation and nested batch steps`}],zt=[{key:`platform`,names:[`--platform`],type:`enum`,enumValues:ke,usageLabel:`--platform ${ke.join(`|`)}`,usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:`target`,names:[`--target`],type:`enum`,enumValues:[`mobile`,`tv`,`desktop`],usageLabel:`--target mobile|tv|desktop`,usageDescription:`Device target class to match`},{key:`device`,names:[`--device`],type:`string`,usageLabel:`--device <name>`,usageDescription:`Device name to target`},{key:`udid`,names:[`--udid`],type:`string`,usageLabel:`--udid <udid>`,usageDescription:`iOS device UDID`},{key:`serial`,names:[`--serial`],type:`string`,usageLabel:`--serial <serial>`,usageDescription:`Android device or Vega VVD serial`},{key:`stale`,names:[`--stale`],type:`boolean`,usageLabel:`--stale`,usageDescription:`Device status: show only claims with a provably stale owner`},{key:`surface`,names:[`--surface`],type:`enum`,enumValues:yt,usageLabel:`--surface app|frontmost-app|desktop|menubar`,usageDescription:`macOS session surface for open (defaults to app)`},{key:`headless`,names:[`--headless`],type:`boolean`,usageLabel:`--headless`,usageDescription:`Boot: launch Android emulator without a GUI window`},{key:`targetApp`,names:[`--app`,`--target-app`],type:`string`,usageLabel:`--app <id-or-name>`,usageDescription:`Doctor: verify an installed target app without opening a session`},{key:`metroHost`,names:[`--metro-host`],type:`string`,usageLabel:`--metro-host <host>`,usageDescription:`Session-scoped Metro/debug host hint`},{key:`metroPort`,names:[`--metro-port`],type:`int`,min:1,max:65535,usageLabel:`--metro-port <port>`,usageDescription:`Session-scoped Metro/debug port hint; on an emulator/simulator the host defaults to the loopback alias, physical devices still need --metro-host`},{key:`metroProjectRoot`,names:[`--project-root`],type:`string`,usageLabel:`--project-root <path>`,usageDescription:`metro prepare: React Native project root (default: cwd)`},{key:`kind`,names:[`--kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`,...kt],usageLabel:`--kind <kind>`,usageDescription:`Kind selector for commands that support it, such as metro prepare or perf artifact collectors`},{key:`perfTemplate`,names:[`--template`],type:`string`,usageLabel:`--template <name>`,usageDescription:`Perf xctrace template name, for example Time Profiler`},{key:`metroKind`,names:[`--metro-kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`],usageLabel:`--metro-kind auto|react-native|expo|repack`,usageDescription:`metro prepare: detect or force the React Native dev-server launcher kind`},{key:`metroPublicBaseUrl`,names:[`--public-base-url`],type:`string`,usageLabel:`--public-base-url <url>`,usageDescription:`metro prepare: public base URL used for direct dev-server bundle hints`},{key:`metroProxyBaseUrl`,names:[`--proxy-base-url`],type:`string`,usageLabel:`--proxy-base-url <url>`,usageDescription:`metro prepare: optional bridge origin for remote dev-server access`},{key:`metroBearerToken`,names:[`--bearer-token`],type:`string`,usageLabel:`--bearer-token <token>`,usageDescription:`metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)`},{key:`metroPreparePort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`metro prepare: local dev-server port (default: 8081)`},{key:`metroListenHost`,names:[`--listen-host`],type:`string`,usageLabel:`--listen-host <host>`,usageDescription:`metro prepare: host dev server listens on (default: 0.0.0.0)`},{key:`metroStatusHost`,names:[`--status-host`],type:`string`,usageLabel:`--status-host <host>`,usageDescription:`metro prepare: host used for local dev-server /status polling (default: 127.0.0.1)`},{key:`metroStartupTimeoutMs`,names:[`--startup-timeout-ms`],type:`int`,min:1,usageLabel:`--startup-timeout-ms <ms>`,usageDescription:`metro prepare: timeout while waiting for the dev server to become ready`},{key:`metroProbeTimeoutMs`,names:[`--probe-timeout-ms`],type:`int`,min:1,usageLabel:`--probe-timeout-ms <ms>`,usageDescription:`metro prepare: timeout for /status and proxy bridge calls`},{key:`metroRuntimeFile`,names:[`--runtime-file`],type:`string`,usageLabel:`--runtime-file <path>`,usageDescription:`metro prepare: optional file path to persist the JSON result`},{key:`metroNoReuseExisting`,names:[`--no-reuse-existing`],type:`boolean`,usageLabel:`--no-reuse-existing`,usageDescription:`metro prepare: always start a fresh Metro process`},{key:`metroNoInstallDeps`,names:[`--no-install-deps`],type:`boolean`,usageLabel:`--no-install-deps`,usageDescription:`metro prepare: skip package-manager install when node_modules is missing`},{key:`bundleUrl`,names:[`--bundle-url`],type:`string`,usageLabel:`--bundle-url <url>`,usageDescription:`Session-scoped bundle URL hint`},{key:`launchUrl`,names:[`--launch-url`],type:`string`,usageLabel:`--launch-url <url>`,usageDescription:`Session-scoped deep link / launch URL hint`},{key:`iosSimulatorDeviceSet`,names:[`--ios-simulator-device-set`],type:`string`,usageLabel:`--ios-simulator-device-set <path>`,usageDescription:`Scope iOS simulator discovery/commands to this simulator device set`},{key:`iosXctestrunFile`,names:[`--ios-xctestrun-file`],type:`string`,usageLabel:`--ios-xctestrun-file <path>`,usageDescription:`Use an externally built iOS XCTest runner .xctestrun artifact`},{key:`iosXctestDerivedDataPath`,names:[`--ios-xctest-derived-data-path`],type:`string`,usageLabel:`--ios-xctest-derived-data-path <path>`,usageDescription:`Derived data path for external iOS XCTest runner execution`},{key:`iosXctestEnvDir`,names:[`--ios-xctest-env-dir`],type:`string`,usageLabel:`--ios-xctest-env-dir <path>`,usageDescription:`Writable directory for per-session iOS XCTest runner env overlays`},{key:`deviceHub`,names:[`--device-hub`],type:`boolean`,usageLabel:`--device-hub`,usageDescription:`open: use Xcode Device Hub when surfacing Apple simulators`},{key:`testIme`,names:[`--test-ime`],type:`boolean`,usageLabel:`--test-ime`,usageDescription:`open: activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices)`},{key:`testIme`,names:[`--no-test-ime`],type:`boolean`,setValue:!1,usageLabel:`--no-test-ime`,usageDescription:`open: keep the real Android keyboard even on emulators (opt out of the headless test IME)`},{key:`androidDeviceAllowlist`,names:[`--android-device-allowlist`],type:`string`,usageLabel:`--android-device-allowlist <serials>`,usageDescription:`Comma/space separated Android serial allowlist for discovery/selection`},{key:`remote`,names:[`--remote`],type:`boolean`,usageLabel:`--remote`,usageDescription:`Doctor: check remote connection setup instead of local device inventory`},{key:`activity`,names:[`--activity`],type:`string`,usageLabel:`--activity <component>`,usageDescription:`Android app launch activity (package/Activity); not for URL opens`},{key:`launchConsole`,names:[`--launch-console`],type:`string`,usageLabel:`--launch-console <path>`,usageDescription:`open: capture the initial iOS simulator launch console window to a file`},{key:`launchArgs`,names:[`--launch-args`],type:`string`,multiple:!0,usageLabel:`--launch-args <arg>`,usageDescription:`open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag.`},{key:`header`,names:[`--header`],type:`string`,multiple:!0,usageLabel:`--header <name:value>`,usageDescription:`install-from-source: repeatable HTTP header for URL downloads`},{key:`githubActionsArtifact`,names:[`--github-actions-artifact`],type:`string`,usageLabel:`--github-actions-artifact <owner/repo:artifact>`,usageDescription:`install-from-source: GitHub Actions artifact resolved by a remote daemon`},{key:`installSource`,names:[],type:`string`},{key:`session`,names:[`--session`],type:`string`,usageLabel:`--session <name>`,usageDescription:`Named session`}],Bt=[{key:`replayUpdate`,names:[`--update`,`-u`],type:`boolean`,usageLabel:`--update, -u`,usageDescription:`Replay: retired as a rewrite (ADR 0012) — never edits the .ad file; every divergence already carries ranked selector suggestions, --update or not`},{key:`replayFrom`,names:[`--from`],type:`int`,min:1,usageLabel:`--from <n>`,usageDescription:`Replay: resume at 1-based plan step n, skipping 1..n-1 without executing them (requires --plan-digest; see a divergence report's resume field). replay only, not test`},{key:`replayPlanDigest`,names:[`--plan-digest`],type:`string`,usageLabel:`--plan-digest <sha256>`,usageDescription:`Replay: the plan digest a --from resume must match (from a prior divergence report); mismatch, edits, or include/platform-expansion changes fail INVALID_ARGS before any action`},{key:`replayKeepSession`,names:[`--keep-session`],type:`boolean`,usageLabel:`--keep-session`,usageDescription:`Replay: leave the session active by suppressing exactly an authored terminal close in a native .ad script; replay only, not test or Maestro YAML`},{key:`replayMaestro`,names:[`--maestro`],type:`boolean`,usageLabel:`--maestro`,usageDescription:`Replay: treat input as a supported Maestro YAML subset; unsupported syntax fails loudly. See agent-device help maestro for commands and boundaries`},{key:`replayEnv`,names:[`-e`,`--env`],type:`string`,multiple:!0,usageLabel:`-e KEY=VALUE, --env KEY=VALUE`,usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:`failFast`,names:[`--fail-fast`],type:`boolean`,usageLabel:`--fail-fast`,usageDescription:`Test: stop the suite after the first failing script; with sharding, each shard stops independently`},{key:`timeoutMs`,names:[`--timeout`],type:`int`,min:1,usageLabel:`--timeout <ms>`,usageDescription:`Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt. With --settle: the settle-wait deadline (default 10s)`},{key:`retries`,names:[`--retries`],type:`int`,min:0,max:3,usageLabel:`--retries <n>`,usageDescription:`Test: retry each failed script up to n additional times`},{key:`recordVideo`,names:[`--record-video`],type:`boolean`,usageLabel:`--record-video`,usageDescription:`Test: record each replay attempt to recording.mp4 in its attempt artifacts`},{key:`artifactsDir`,names:[`--artifacts-dir`],type:`string`,usageLabel:`--artifacts-dir <path>`,usageDescription:`Test: root directory for suite artifacts`},{key:`reporter`,names:[`--reporter`],type:`string`,multiple:!0,usageLabel:`--reporter <name-or-path>`,usageDescription:`Test: add a replay suite reporter; use default, junit:<path>, or a custom reporter path (repeatable)`},{key:`reportJunit`,names:[`--report-junit`],type:`string`,usageLabel:`--report-junit <path>`,usageDescription:`Test: compatibility alias for --reporter junit:<path>`},{key:`shardAll`,names:[`--shard-all`],type:`int`,min:1,usageLabel:`--shard-all <n>`,usageDescription:`Test: run the full suite on each of n devices; combine with --device id1,id2 for explicit connected devices; AD_SHARD_INDEX is zero-based`},{key:`shardSplit`,names:[`--shard-split`],type:`int`,min:1,usageLabel:`--shard-split <n>`,usageDescription:`Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based`},{key:`steps`,names:[`--steps`],type:`string`,usageLabel:`--steps <json>`,usageDescription:`Batch: JSON array of steps`},{key:`stepsFile`,names:[`--steps-file`],type:`string`,usageLabel:`--steps-file <path>`,usageDescription:`Batch: read steps JSON from file`},{key:`batchOnError`,names:[`--on-error`],type:`enum`,enumValues:[`stop`],usageLabel:`--on-error stop`,usageDescription:`Batch: stop when a step fails`},{key:`batchMaxSteps`,names:[`--max-steps`],type:`int`,min:1,max:1e3,usageLabel:`--max-steps <n>`,usageDescription:`Batch: maximum number of allowed steps`},{key:`appsFilter`,names:[`--all`],type:`enum`,enumValues:[`user-installed`,`all`],setValue:`all`,usageLabel:`--all`,usageDescription:`Apps: include system/OEM apps`},{key:`snapshotInteractiveOnly`,names:[`-i`],type:`boolean`,usageLabel:`-i`,usageDescription:`Snapshot: interactive elements only`},{key:`snapshotDepth`,names:[`--depth`,`-d`],type:`int`,min:0,usageLabel:`--depth, -d <depth>`,usageDescription:`Snapshot: limit snapshot depth`},{key:`snapshotScope`,names:[`--scope`,`-s`],type:`string`,usageLabel:`--scope, -s <scope>`,usageDescription:`Snapshot: scope snapshot to label/identifier`},{key:`snapshotRaw`,names:[`--raw`],type:`boolean`,usageLabel:`--raw`,usageDescription:`Snapshot: raw node output`},{key:`snapshotCustomActions`,names:[`--actions`],type:`boolean`,usageLabel:`--actions`,usageDescription:`Snapshot: name the affordances merged inside an element (iOS sim); not directly invokable — reach them via the detail screen, labeled children, or coordinates`},{key:`snapshotForceFull`,names:[`--force-full`],type:`boolean`,usageLabel:`--force-full`,usageDescription:`Snapshot: re-emit the full tree even when unchanged`},{key:`findFirst`,names:[`--first`],type:`boolean`,usageLabel:`--first`,usageDescription:`Find: pick the first match when ambiguous`},{key:`findLast`,names:[`--last`],type:`boolean`,usageLabel:`--last`,usageDescription:`Find: pick the last match when ambiguous`},{key:`out`,names:[`--out`],type:`string`,usageLabel:`--out <path>`,usageDescription:`Output path`},{key:`artifact`,names:[`--artifact`],type:`string`,usageLabel:`--artifact <path>`,usageDescription:`Debug symbols: Apple crash artifact path (.ips, .crash, or .log)`},{key:`dsym`,names:[`--dsym`],type:`string`,usageLabel:`--dsym <path>`,usageDescription:`Debug symbols: matching .dSYM bundle path`},{key:`searchPath`,names:[`--search-path`],type:`string`,usageLabel:`--search-path <dir>`,usageDescription:`Debug symbols: directory to scan for matching .dSYM bundles`},{key:`overlayRefs`,names:[`--overlay-refs`],type:`boolean`,usageLabel:`--overlay-refs`,usageDescription:`Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide`},...re,{key:`baseline`,names:[`--baseline`,`-b`],type:`string`,usageLabel:`--baseline, -b <path>`,usageDescription:`Diff screenshot: path to baseline image file`},{key:`threshold`,names:[`--threshold`],type:`string`,usageLabel:`--threshold <0-1>`,usageDescription:`Diff screenshot: color distance threshold (default 0.1)`}],Vt=[...Rt,...zt,...Lt,...Bt],Ht=new Map;for(let e of Vt)for(let t of e.names)Ht.set(t,e);function Ut(e){return Ht.get(e)}function Wt(){return Vt}const Gt=new Set(Wt().map(e=>e.key));function Kt(e){let t=Fe(e);return ae({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...Be(t),provider:e.provider,providerSessionId:e.providerSessionId,providerApp:e.providerApp,providerOsVersion:e.providerOsVersion,providerProject:e.providerProject,providerBuild:e.providerBuild,providerSessionName:e.providerSessionName,providerDeviceOrientation:e.providerDeviceOrientation,providerGeoLocation:e.providerGeoLocation,providerTimezone:e.providerTimezone,providerLanguage:e.providerLanguage,providerLocale:e.providerLocale,providerNetworkProfile:e.providerNetworkProfile,providerCustomNetwork:e.providerCustomNetwork,providerNoResignApp:e.providerNoResignApp,awsProjectArn:e.awsProjectArn,awsDeviceArn:e.awsDeviceArn,awsAppArn:e.awsAppArn,awsRegion:e.awsRegion,awsInteractionMode:e.awsInteractionMode,sessionIsolation:e.sessionIsolation,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,surface:e.surface,activity:e.activity,launchConsole:e.launchConsole,launchArgs:e.launchArgs,relaunch:e.relaunch,shutdown:e.shutdown,saveScript:e.saveScript,deviceHub:e.deviceHub,testIme:e.testIme,noRecord:e.noRecord,recordAs:e.recordAs,record:e.record,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotCustomActions:e.customActions,snapshotForceFull:e.forceFull,...o(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,quality:e.quality,hideTouches:e.hideTouches,recordingScope:e.recordingScope,intervalMs:e.intervalMs,delayMs:e.delayMs,durationMs:e.durationMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,verify:e.verify,settle:e.settle,settleQuietMs:e.settleQuietMs,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,replayFrom:e.replayFrom,replayPlanDigest:e.replayPlanDigest,replayKeepSession:e.replayKeepSession,failFast:e.failFast,timeoutMs:e.timeoutMs,retries:e.retries,recordVideo:e.recordVideo,artifactsDir:e.artifactsDir,shardAll:e.shardAll,shardSplit:e.shardSplit,findFirst:e.findFirst,findLast:e.findLast,networkInclude:e.networkInclude,batchOnError:e.batchOnError,batchMaxSteps:e.batchMaxSteps,batchSteps:e.batchSteps,verbose:e.debug})}function qt(e,t){return{...Kt(e),...t}}function Jt(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!Gt.has(e))continue;let t=i[e];Yt(t)&&(r[e]=t)}return r}function Yt(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}const Xt=[`ref`,`selector`,`point`];function Zt(e,t=[]){return{type:`object`,properties:{...Rn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function Qt(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function $t(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function d(e){return{type:`string`,...e?{description:e}:{}}}function en(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function tn(e){return{type:`integer`,...e?{description:e}:{}}}function nn(e){return{type:`boolean`,...e?{description:e}:{}}}function rn(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function an(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function f(e){return{...e,required:!0}}function p(e){return S(d(e),y)}function on(t){return{schema:{type:`null`},required:!1,retired:!0,read:(n,r)=>{if(Object.hasOwn(n,r))throw new e(`INVALID_ARGS`,t)}}}function m(e,t={}){return S(en(e,t),(e,n)=>Oe(e,n,t))}function h(e,t={}){return S(Nn(e,t),(e,n)=>ue(e,n,t))}function g(e){return S(nn(e),Tn)}function _(e,t){return S($t(e,t),(t,n)=>Dn(t,n,e))}function sn(e){return S(an(e),In)}function cn(e){return S(rn(e),Ln)}function v(e){return S(e,(e,t)=>e[t])}function ln(e,t){return S(e,t)}function un(){return S(zn(),(e,t)=>e[t]===void 0?void 0:bn(e,t))}function dn(){return S(Bn(),(e,t)=>e[t]===void 0?void 0:xn(e,t))}function fn(e){return S(Qt(e),(e,t)=>e[t]===void 0?void 0:Sn(e,t))}function pn(){return{depth:h(`Snapshot traversal depth.`,{min:0}),scope:p(`Snapshot scope selector used before resolution.`),raw:g(`Use raw snapshot data during selector resolution.`)}}function mn(){return{count:h(`Number of press/click repetitions.`,{min:1}),intervalMs:h(`Delay between repeated press/click actions.`,{min:0}),holdMs:h(`Hold duration for each action.`,{min:0}),jitterPx:h(`Randomization radius in pixels.`,{min:0}),doubleTap:g(`Request a double-tap action.`)}}function hn(e){return Zt(Pn(e),Fn(e))}function gn(t,n){let r=_n(t),i=Object.fromEntries(Object.entries(n).flatMap(([t,n])=>{let i=n.read(r,t);if(n.required&&i===void 0)throw new e(`INVALID_ARGS`,`Expected ${t} to be set.`);return i===void 0?[]:[[t,i]]})),a=vn(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return x({...a,...b(a),...i})}function _n(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}function vn(e,t={}){return{session:y(e,`session`),platform:Dn(e,`platform`,ke),deviceTarget:yn(e,t),device:y(e,`device`),udid:y(e,`udid`),serial:y(e,`serial`),iosSimulatorDeviceSet:y(e,`iosSimulatorDeviceSet`),iosXctestrunFile:y(e,`iosXctestrunFile`),iosXctestDerivedDataPath:y(e,`iosXctestDerivedDataPath`),iosXctestEnvDir:y(e,`iosXctestEnvDir`),androidDeviceAllowlist:y(e,`androidDeviceAllowlist`),noRecord:Tn(e,`noRecord`),daemonBaseUrl:y(e,`daemonBaseUrl`),daemonAuthToken:y(e,`daemonAuthToken`),tenant:y(e,`tenant`),runId:y(e,`runId`),leaseId:y(e,`leaseId`),cwd:y(e,`cwd`),debug:Tn(e,`debug`)}}function yn(t,n){let r=Dn(t,`deviceTarget`,Ae);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=Dn(t,`target`,Ae);if(r!==void 0&&i!==r)throw new e(`INVALID_ARGS`,`Expected target alias to match deviceTarget when both are set.`);return r??i}function bn(e,t){let n=Hn(e,t),r=En(n,`kind`,Xt);switch(r){case`ref`:return{kind:r,ref:Cn(n,`ref`),label:y(n,`label`)};case`selector`:return{kind:r,selector:Cn(n,`selector`)};case`point`:return{kind:r,x:wn(n,`x`),y:wn(n,`y`)}}}function xn(e,t){let n=Hn(e,t),r=En(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:Cn(n,`ref`),label:y(n,`label`)}:{kind:r,selector:Cn(n,`selector`)}}function Sn(e,t){let n=Hn(e,t);return{x:wn(n,`x`),y:wn(n,`y`)}}function Cn(t,n){let r=t[n];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}function y(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}}function wn(t,n){let r=t[n];if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}function Tn(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`boolean`)throw new e(`INVALID_ARGS`,`Expected ${n} to be a boolean.`);return r}}function En(t,n,r){let i=t[n];if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}function Dn(t,n,r){let i=t[n];if(i!==void 0){if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}}function b(e){return x({noRecord:e.noRecord,session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function On(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector};case`point`:return{x:e.x,y:e.y}}}function kn(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function An(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function jn(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function Mn(t,n,r){let i=new Set(n),a=Object.keys(t).filter(e=>!i.has(e));if(a.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${a.join(`, `)}.`)}function x(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function S(e,t){return{schema:e,required:!1,read:t}}function Nn(e,t){return{...tn(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Pn(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>!e.retired).map(([e,t])=>[e,t.schema]))}function Fn(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function In(t,n){let r=t[n];if(r!==void 0){if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be an object.`);return r}}function Ln(t,n){let r=t[n];if(r!==void 0){if(!Array.isArray(r)||r.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Expected ${n} to be an array of strings.`);return r}}function Rn(){return{session:{type:`string`,description:`Agent-device session name.`},platform:{type:`string`,enum:ke,description:`Platform selector used to resolve a device.`},deviceTarget:{type:`string`,enum:Ae,description:`Device target form. Maps to the CLI --target flag.`},target:{type:`string`,enum:Ae,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`},device:{type:`string`,description:`Device name selector.`},udid:{type:`string`,description:`iOS device UDID selector.`},serial:{type:`string`,description:`Android device or Vega VVD serial selector.`},iosSimulatorDeviceSet:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},iosXctestrunFile:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},iosXctestDerivedDataPath:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},iosXctestEnvDir:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},androidDeviceAllowlist:{type:`string`,description:`Android serial allowlist used for device resolution.`},daemonBaseUrl:{type:`string`,description:`Remote daemon base URL.`},daemonAuthToken:{type:`string`,description:`Remote daemon auth token.`},tenant:{type:`string`,description:`Remote tenant identifier.`},runId:{type:`string`,description:`Lease run identifier.`},leaseId:{type:`string`,description:`Existing lease identifier.`},cwd:{type:`string`,description:`Working directory for command execution.`},debug:{type:`boolean`,description:`Enable debug diagnostics.`}}}function zn(){return{oneOf:[...Vn(),{type:`object`,properties:{kind:{type:`string`,const:`point`},x:{type:`number`},y:{type:`number`}},required:[`kind`,`x`,`y`],additionalProperties:!1}],description:`UI target. This is separate from deviceTarget, which selects the device form.`}}function Bn(){return{oneOf:Vn(),description:`UI element target by snapshot ref or selector expression.`}}function Vn(){return[{type:`object`,properties:{kind:{type:`string`,const:`ref`},ref:{type:`string`,description:`Snapshot element ref such as @e12.`},label:{type:`string`,description:`Optional human label for the ref.`}},required:[`kind`,`ref`],additionalProperties:!1},{type:`object`,properties:{kind:{type:`string`,const:`selector`},selector:{type:`string`,description:`Agent-device selector expression.`}},required:[`kind`,`selector`],additionalProperties:!1}]}function Hn(t,n){let r=t[n];if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be an object.`);return r}function C(e,t){return n=>w(e,t?t(n):[],n)}function w(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Un(n)}}function Un(e){let t=Wn(e.deviceTarget??e.target);if(t===void 0&&e.target===void 0)return e;let{target:n,...r}=e;return t===void 0?r:{...r,target:t}}function Wn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function T(e){return x({noRecord:e.noRecord,session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist})}function Gn(e){return x({record:e.record})}function Kn(e){return{noRecord:e.noRecord,platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function qn(e){return x({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Jn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function Yn(e){return x({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Xn(e){return x({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function Zn(e){if(`ref`in e&&e.ref!==void 0)return x({kind:`ref`,ref:e.ref,label:e.label});if(`selector`in e&&e.selector!==void 0)return{kind:`selector`,selector:e.selector};let t=e;return{kind:`point`,x:t.x,y:t.y}}function Qn(t){let n=er(t);if(typeof n.ref==`string`)return[n.ref,...nr(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(tr(n.x,`x`)),String(tr(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function $n(t){let n=er(t);if(typeof n.ref==`string`)return[n.ref,...nr(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function er(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected target object.`);let n=t,r=n.target;return r&&typeof r==`object`&&!Array.isArray(r)?r:n}function tr(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function nr(e){return typeof e==`string`&&e.length>0?[e]:[]}function rr(t){let n=se(t);if(!n.ok)throw new e(n.code,n.message);return`ref`in n?{ref:n.ref,label:sr(t.slice(1))}:{selector:n.selector}}function ir(t){let n=de(t);if(!n.ok)throw new e(n.code,n.message);return n.format}function ar(t,n={}){let r=_e(t,n);if(!r)throw new e(`INVALID_ARGS`,pe);return r}function or(t,n){try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{}throw new e(`INVALID_ARGS`,`${n} must be a JSON object`)}function sr(e){return e.join(` `).trim()||void 0}function E(...e){return new Set(e)}function D(e,t){return e!==void 0&&t.has(e)}function cr(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function lr(t,n){if(t===void 0)return;let r=Number(t);if(Number.isFinite(r))return r;throw new e(`INVALID_ARGS`,`${n} must be a finite number.`)}function O(e){return e===void 0?void 0:Number(e)}function k(e){return e===void 0?[]:[e]}function A(e){return e===void 0?[]:[String(e)]}function j(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function M(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function ur(e){return pr(e.description,e.cliDetail)}function dr(e){return pr(e.description,e.mcpDetail)}function fr(e,t){return{...e,description:t}}function pr(e,t){return t?`${e} ${t}`:e}function N(e){let t=fr(e.text,e.metadata.description),n=t.mcpDetail?{mcpDetail:t.mcpDetail}:{};return{...e,metadata:{...e.metadata,...n},definition:{...e.definition,...n},cliSchema:{...e.cliSchema,text:t}}}function P(e){let t={},n={},r={},i={},a={};for(let o of e.commands){hr(t,`CLI schema`,o.name,o.cliSchema);let e=o.definition.projection?.clientMethod??o.clientMethod;e&&hr(n,`client command method`,e,o.name),hr(r,`CLI reader`,o.name,o.cliReader),o.daemonWriter&&hr(i,`daemon writer`,o.name,o.daemonWriter),o.cliOutputFormatter&&hr(a,`CLI output formatter`,o.name,o.cliOutputFormatter)}return{name:e.name,clientSurface:e.clientSurface,metadata:e.commands.map(e=>e.metadata),definitions:e.commands.map(e=>e.definition),clientCommandMethods:n,cliSchemas:t,cliReaders:r,daemonWriters:i,cliOutputFormatters:a}}function mr(e){let t={};for(let n of e)n.projection&&hr(t,`command output schema`,n.name,n.projection.outputSchema);return t}function hr(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function F(e){return e}function I(e,t,n){return{...e,run:t,invoke:async(n,r)=>await t(n,e.readInput(r)),...n?{projection:n}:{}}}function L(e){return({result:t})=>e(t)}const R=L(z);function z(e){return{data:e,text:je(e)}}function gr(e,t){if(!(typeof e!=`string`||e.length===0)&&typeof t==`number`)return`@${e.startsWith(`@`)?e.slice(1):e}~s${t}`}function _r(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(yr(n));return{data:e,text:t.join(`
|
|
2
|
+
`)}}const vr={batch:L(_r)};function yr(e){let t=je(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function br(e=Te){let t=xr(e);return F({name:`batch`,description:`Execute multiple commands in one daemon request`,inputSchema:hn(t),readInput:e=>Cr(e,t)})}function xr(e){return{steps:f(ln({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:Sr(e)},(t,n)=>wr(t[n],e))),onError:_([`stop`],`Batch failure policy.`),maxSteps:h(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:p(`Optional output path for command artifacts.`)}}function Sr(e){return{type:`object`,properties:{command:{type:`string`,enum:e,description:`Command name to run with structured input.`},input:{type:`object`,additionalProperties:!0,description:`Structured command input for the nested command. Use the matching MCP tool schema for this object.`},runtime:{type:`object`,additionalProperties:!0,description:`Optional per-step runtime payload.`}},required:[`command`,`input`],additionalProperties:!1}}function Cr(t,n){let r=gn(t,n),i=r.maxSteps??100;if(!me(i))throw new e(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(r.maxSteps)}`);return Ee(r.steps.length,i),{...r}}function wr(t,n){if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected steps to be an array.`);return t.map((e,t)=>Tr(e,t+1,n))}function Tr(e,t,n){let r=he(e,t);return Mn(r,[`command`,`input`,`runtime`],`Batch step ${t}`),{command:Er(r,t,n),input:De(r,t),...Dr(r,t)}}function Er(t,n,r){if(r===Te)return be(t.command,n);let i=t.command;if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected command to be one of: ${r.join(`, `)}.`);return i}function Dr(e,t){let n=xe(e.runtime,t);return n===void 0?{}:{runtime:n}}function Or(e){return t=>w(u.batch,[],{...t,batchSteps:kr(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}function kr(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty steps array.`);return t.map((e,t)=>Ar(e,t+1,n))}function Ar(e,t,n){let r=he(e,t),i=jr(r,t),a=De(r,t),o=xe(r.runtime,t),s=n(i,a,t);return{command:s.command,positionals:s.positionals,...s.input?{input:s.input}:{},flags:qt(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function jr(e,t){return be(e.command,t)}const Mr=br(),Nr=P({name:`batch`,clientSurface:!1,commands:[N({name:`batch`,text:{summary:`Run multiple commands`},metadata:Mr,definition:I(Mr,(e,t)=>e.batch.run(Pr(t))),cliSchema:{usageOverride:`batch [--steps <json> | --steps-file <path>]`,listUsageOverride:`batch --steps <json> | --steps-file <path>`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},cliReader:(e,t)=>({...T(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),cliOutputFormatter:vr.batch})]});function Pr(e){return{...b(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}function B(e,t,n){return F({name:e,description:t,inputSchema:hn(n),readInput:e=>gn(e,n)})}const Fr=`alert`,Ir=B(Fr,`Inspect, wait for, accept, or dismiss a platform alert. Use get before acting when the alert content matters; accept and dismiss change the active alert state.`,{action:_(pt),timeoutMs:h()}),Lr=N({name:Fr,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:Ir,definition:I(Ir,(e,t)=>e.command.alert(t)),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...T(t),...zr(e)}),daemonWriter:C(u.alert,e=>Rr(e)),cliOutputFormatter:R});function Rr(e){return[e.action??`get`,...A(e.timeoutMs)]}function zr(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return x({action:Br(t[0]),timeoutMs:lr(t[1],`alert timeout`)})}function Br(t){let n=t?.toLowerCase();if(n===void 0||n===`get`||n===`accept`||n===`dismiss`||n===`wait`)return n;throw new e(`INVALID_ARGS`,`alert action must be get, accept, dismiss, or wait.`)}function V(...e){return e}const Vr=V(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),H=V(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Hr=V(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Ur=V(`metroHost`,`metroPort`,`bundleUrl`),Wr=V(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Gr=V(`settle`,`settleQuietMs`,`timeoutMs`),Kr=V(`replayUpdate`,`replayEnv`),qr=V(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`providerDeviceOrientation`,`providerGeoLocation`,`providerTimezone`,`providerLanguage`,`providerLocale`,`providerNetworkProfile`,`providerCustomNetwork`,`providerNoResignApp`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Jr=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),Yr=`diff`,Xr=B(Yr,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:f(v({type:`string`,const:`snapshot`})),out:p(),interactiveOnly:g(),depth:h(),scope:p(),raw:g()}),Zr=N({name:Yr,text:{summary:`Diff snapshot or screenshot`,cliDetail:`Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`},metadata:Xr,definition:I(Xr,(e,t)=>e.capture.diff(t)),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,positionalArgs:[`kind`,`current?`],allowedFlags:[...Vr,`baseline`,`threshold`,`out`,`overlayRefs`]},cliReader:(t,n)=>{if(t[0]!==`snapshot`)throw new e(`INVALID_ARGS`,`Only diff snapshot is available through this parser.`);return{...T(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:C(u.diff,e=>[M(e.kind,`diff requires kind`)])}),Qr=`screenshot`,$r=B(Qr,`Capture a screenshot of the active app or web session. Choose the capture scope, density, size, or annotations through the corresponding input fields when needed.`,{path:p(`Output path.`),overlayRefs:g(),pixelDensity:h(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:g(),scale:m(`Screenshot scale factor.`,c),maxSize:on(s.migration.screenshot),stabilize:g(),normalizeStatusBar:g(),surface:_(yt)}),ei=N({name:Qr,text:{summary:`Capture a screenshot`,cliDetail:`Web defaults to the viewport; use --fullscreen, --full, or -f for the entire page. iOS simulators default to 1x logical-point output; use --pixel-density to request a different screenshot density. macOS app sessions default to the app window; use --fullscreen for full desktop, --scale to downscale, --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops.`},metadata:$r,definition:I($r,(e,t)=>e.capture.screenshot(t)),cliSchema:{positionalArgs:[`path?`],allowedFlags:ie},cliReader:(e,t)=>({...T(t),path:e[0]??t.out,...r(t)}),daemonWriter:e=>(a(`screenshot`,e),te(e),w(u.screenshot,k(e.path),{...e,...i(e)}))}),ti=`settings`,ni=B(ti,`Change supported operating-system settings, animation scales, appearance, or app permissions on the selected target. Platform support varies by setting and action.`,{setting:f(p()),state:f(p()),app:p(),latitude:m(),longitude:m(),permission:p(),mode:_([`full`,`limited`])}),ri=N({name:ti,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS. Mobile permission actions use the active session app.`},metadata:ni,definition:I(ni,(e,t)=>e.settings.update(t)),cliSchema:{usageOverride:ee,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state`,`target?`,`mode?`]},cliReader:(e,t)=>ii(e,t),daemonWriter:C(u.settings,e=>ai(e))});function ii(t,n){let r=Kn(n),i=t[0],a=t[1];if(D(i,ci)&&D(a,li))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:ne(t[2],`latitude`),longitude:ne(t[3],`longitude`)};if(i===`appearance`&&D(a,ui)||D(i,di)&&D(a,fi)||i===`fingerprint`&&D(a,pi))return{...r,setting:i,state:a};if(i===`permission`&&D(a,mi))return{...r,setting:i,state:a,permission:oi(t[2]),mode:si(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function ai(e){return e.setting===`clear-app-state`?[e.setting,...k(e.app)]:e.setting===`location`&&e.state===`set`?[e.setting,e.state,String(e.latitude),String(e.longitude)]:e.setting===`permission`?[e.setting,e.state,e.permission,...k(e.mode)]:[e.setting,e.state]}function oi(t){if(D(t,hi))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function si(t){if(t===void 0||t===`full`||t===`limited`)return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const ci=E(`wifi`,`airplane`,`location`,`animations`),li=E(`on`,`off`),ui=E(`light`,`dark`,`toggle`),di=E(`faceid`,`touchid`),fi=E(`match`,`nonmatch`,`enroll`,`unenroll`),pi=E(`match`,`nonmatch`),mi=E(`grant`,`deny`,`reset`),hi=E(`camera`,`microphone`,`photos`,`contacts`,`contacts-limited`,`notifications`,`calendar`,`location`,`location-always`,`media-library`,`motion`,`reminders`,`siri`,`accessibility`,`screen-recording`,`input-monitoring`);function gi(e){if(!Array.isArray(e)||e.length===0)return e;let t=ve(e);return e.map(e=>{let n=_i(e,t,e=>e.label),r=_i(e,t,e=>e.identifier),i=typeof e.label==`string`&&e.label.length>=24&&e.label===n,a=typeof e.identifier==`string`&&e.identifier.length>=24&&e.identifier===r;if(!i&&!a)return e;let o={...e};return i&&(delete o.label,o.inheritsLabel=!0),a&&(delete o.identifier,o.inheritsIdentifier=!0),o})}function _i(e,t,n){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0;for(;r;){let e=n(r);if(typeof e==`string`&&e.length>0)return e;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}}function vi(e){let t=Ze(e.raw||!Array.isArray(e.result.nodes)?e.result:{...e.result,nodes:gi(e.result.nodes)});return{data:t,jsonData:bi(t),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:We(t,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const yi={snapshot:({input:e,result:t})=>vi({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:R,alert:R};function bi(e){let{unchanged:t,...n}=e;return n}const xi=`snapshot`,Si=B(xi,`Capture the accessibility tree or compare it with the previous session baseline. Use the returned refs for subsequent semantic interactions and the diff option to verify UI changes.`,{interactiveOnly:g(),depth:h(),scope:p(),raw:g(),customActions:g(`Name the affordances an element merged away (iOS UIAccessibilityCustomAction, React Native accessibilityActions) — a card whose reply/options controls are not separate elements still lists them here. The names are for PLANNING, not invocation: there is no API to trigger them, so reach the affordance through the element detail screen, through the same control exposed as a labeled element elsewhere, or by coordinates from its rect. iOS simulator only; costs one accessibility round trip per merged element.`),forceFull:g(),timeoutMs:h(`Maximum wall-clock time for the snapshot command.`),noRecord:g(`Do not record this action.`),record:g(`Force-record this out-of-band observation into a repair-armed heal (mutually exclusive with noRecord). Authored replay steps are recorded automatically and never need this.`)}),Ci=N({name:xi,text:{summary:`Capture or diff the accessibility tree`,cliDetail:`For iOS raw-coordinate fallback after a no-op ref press, inspect rects with snapshot -i --json, press the rect center, then verify with diff snapshot -i or snapshot --diff.`},metadata:Si,definition:I(Si,(e,t)=>e.capture.snapshot(t)),cliSchema:{usageOverride:`snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--actions] [--force-full] [--timeout <ms>]`,allowedFlags:[`snapshotDiff`,...Vr,`snapshotCustomActions`,`snapshotForceFull`,`timeoutMs`,`record`]},cliReader:(e,t)=>({...T(t),...Gn(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,customActions:t.snapshotCustomActions,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),daemonWriter:C(u.snapshot),cliOutputFormatter:yi.snapshot}),wi=[`duration`,`text`,`ref`,`selector`,`stable`],Ti=`wait`,Ei=B(Ti,`Wait for a duration, text, snapshot ref, selector, or stable UI. Use text, ref, or selector for a specific readiness condition; stable waits until the UI stays quiet for the requested window.`,{kind:_(wi),durationMs:h(),text:p(),ref:p(),selector:p(),stable:g(),quietMs:h(),timeoutMs:h(),depth:h(),scope:p(),raw:g()}),Di=N({name:Ti,text:{summary:`Wait for a duration, text, selector, or stable UI`},metadata:Ei,definition:I(Ei,(e,t)=>e.command.wait(Oi(t))),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|stable [quietMs] [timeoutMs]`,positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...H]},cliReader:(e,t)=>ki(e,t),daemonWriter:C(u.wait,e=>Ai(e)),cliOutputFormatter:R});function Oi(e){Dn(e,`kind`,wi);let t={...e};return delete t.kind,t}function ki(t,n){let r=fe(t);if(!r)throw new e(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...Kn(n),...Jn(n)};if(r.kind===`sleep`)return{...i,durationMs:r.durationMs};if(r.kind===`text`){if(!r.text)throw new e(`INVALID_ARGS`,`wait requires text.`);return{...i,text:r.text,...ji(r.timeoutMs)}}return r.kind===`ref`?{...i,ref:r.rawRef,...ji(r.timeoutMs)}:r.kind===`stable`?{...i,stable:!0,...Mi(r.quietMs),...ji(r.timeoutMs)}:{...i,selector:r.selectorExpression,...ji(r.timeoutMs)}}function Ai(t){if([t.durationMs===void 0?void 0:`durationMs`,t.text===void 0?void 0:`text`,t.ref===void 0?void 0:`ref`,t.selector===void 0?void 0:`selector`,t.stable===void 0?void 0:`stable`].filter(Boolean).length!==1)throw new e(`INVALID_ARGS`,`wait command requires exactly one of durationMs, text, ref, selector, or stable.`);if(t.durationMs!==void 0)return[String(t.durationMs)];let n=A(t.timeoutMs);if(t.text!==void 0)return[`text`,t.text,...n];if(t.ref!==void 0)return[t.ref,...n];if(t.stable!==void 0){let r=A(t.quietMs);if(r.length===0&&n.length>0)throw new e(`INVALID_ARGS`,`wait stable requires quietMs before timeoutMs.`);return[`stable`,...r,...n]}let r=t.selector;if(!oe(r))throw new e(`INVALID_ARGS`,`Invalid wait selector: ${r}`);return[r,...n]}function ji(e){return e===null?{}:{timeoutMs:e}}function Mi(e){return e===null?{}:{quietMs:e}}const Ni=P({name:`capture`,commands:[Ci,ei,Zr,Di,Lr,ri]});function Pi(e){let t=[e.outPath,e.message];t.push(...Ii(e));for(let n of e.matchedImages)t.push(`Matched: ${n.name} ${n.uuid}${n.arch?` ${n.arch}`:``}`);for(let n of e.warnings??[])t.push(`Warning: ${n}`);return{data:e,text:t.join(`
|
|
3
|
+
`)}}const Fi={debug:L(Pi)};function Ii(e){let t=e.crash,n=[`Crash: ${t.appName??`unknown app`}${t.crashedThread===void 0?``:` thread ${t.crashedThread}`}`];t.bundleId&&n.push(`Bundle: ${t.bundleId}`),t.exceptionType&&n.push(`Exception: ${t.exceptionType}`),t.terminationReason&&n.push(`Termination: ${t.terminationReason}`);for(let e of t.topFrames)n.push(`Frame ${e.index}: ${e.image} ${e.symbol??e.address}`);for(let e of t.findings)n.push(`Finding: ${e}`);return n}const Li=`debug`,Ri=B(Li,`Symbolicate Apple crash artifacts with matching dSYM UUIDs. This debug namespace is intentionally narrow: use logs for app logs, network for HTTP evidence, perf for performance samples, record/trace for media and traces, and react-devtools for React Native profiles.`,{action:f(_([`symbols`])),artifact:f(p(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:p(`Path to a matching .dSYM bundle.`),searchPath:p(`Directory to scan for matching .dSYM bundles.`),out:p(`Output path for the symbolicated artifact.`)}),zi=P({name:`debugging`,commands:[N({name:Li,text:{summary:`Symbolicate Apple crash artifacts`},metadata:Ri,definition:I(Ri,(e,t)=>e.debug.symbols(t)),cliSchema:{usageOverride:`debug symbols --artifact <crash.ips|crash.log> (--dsym <App.dSYM> | --search-path <dir>) [--out <symbolicated>]`,listUsageOverride:`debug`,positionalArgs:[`symbols`],allowedFlags:[`artifact`,`dsym`,`searchPath`,`out`]},cliReader:(e,t)=>({...T(t),action:Bi(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:Fi.debug})]});function Bi(t){if(t===`symbols`)return t;throw new e(`INVALID_ARGS`,`debug supports only symbols; use logs, network, perf, record, trace, or react-devtools for other diagnostics`)}const Vi=()=>g(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),Hi=()=>({settle:g(`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response. Best-effort; never fails the action.`),settleQuietMs:h(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:h(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function U(e){return{...Ce(e)?{verify:Vi()}:{},...we(e)?Hi():{}}}function Ui(e){let t=[];return Ce(e)&&t.push(`verify`),we(e)&&t.push(...Gr),t}const Wi=[`click`,`focus`,`exists`,`list`,`getText`,`getAttrs`,`wait`,`fill`,`type`],Gi={click:`Activate a UI target by snapshot ref, selector, or coordinates. Prefer a ref or selector after a snapshot; use coordinates only when semantic targeting is unavailable. This can change app state; use settle or verify to confirm the result without a follow-up snapshot.`,press:`Short-press a UI target by snapshot ref, selector, or coordinates. Use longpress instead when the target requires a context-menu or hold gesture.`,fill:`Replace text in a UI input selected by snapshot ref, selector, or coordinates. Prefer refs or selectors after snapshot; use recordAs to keep sensitive text out of a recorded replay while sending it to the live app.`,longpress:`Hold a UI target by snapshot ref, selector, or coordinates to open a context menu or perform another hold gesture. Set durationMs when the default hold duration is unsuitable.`,swipe:`Quick coordinate fling with optional repeat pattern.`,focus:`Move input focus to explicit screen coordinates without entering text. Prefer semantic interactions when a snapshot ref or selector is available; use type or fill after focus.`,type:`Append text to the currently focused input. Use fill when the existing field value should be replaced, and focus first when no input is active.`,scroll:`Scroll in a direction, or toward the top/bottom edge of scrollable content.`,get:`Read text or accessibility attributes from a snapshot ref or selector without changing the app. Use format text for visible content or attrs for the element attribute map.`,is:`Check whether a selector satisfies a UI predicate such as visible, hidden, editable, selected, focused, or text. Use wait when the condition may appear asynchronously.`,find:`Find by text/label/value/role/id and run action`,gesture:`Perform a structured pan, fling, swipe, pinch, rotate, transform, or drag gesture. Select the gesture kind, then provide only the inputs that apply to that kind.`},Ki={target:f(un()),button:_(tt,`Pointer button for platforms that support mouse buttons.`),...pn(),...mn(),...U(`click`)},qi={target:f(un()),...pn(),...mn(),...U(`press`)},Ji={target:f(un()),text:f(p(`Text to enter into the target.`)),delayMs:h(`Delay between typed characters.`,{min:0}),recordAs:p("When script recording is armed, send text to the live app but publish it as ${VAR}. Use an uppercase replay variable name such as PASSWORD."),...pn(),...U(`fill`)},Yi={target:f(un()),durationMs:h(`Long press duration in milliseconds.`,{min:0}),...pn(),...U(`longpress`)},Xi={from:f(fn(`Swipe start point.`)),to:f(fn(`Swipe end point.`)),count:h(`Number of swipe repetitions.`,{min:1,max:200}),pauseMs:h(`Pause between repeated swipes.`,{min:0,max:ot}),pattern:_(it)},Zi={x:f(m(`X coordinate.`)),y:f(m(`Y coordinate.`))},Qi={text:f(p(`Text to type.`)),delayMs:h(`Delay between typed characters.`,{min:0})},$i={direction:f(_(rt)),amount:m(`Platform scroll amount.`),pixels:h(`Pixel scroll amount.`,{min:0}),durationMs:h(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:dt}),...U(`scroll`)},ea=()=>({noRecord:g(`Do not record this action.`),record:g(`Force-record this out-of-band observation into a repair-armed heal (mutually exclusive with noRecord). Authored replay steps are recorded automatically and never need this. On find, valid only for a read-only action.`)}),ta={format:f(_([`text`,`attrs`])),target:f(dn()),...pn(),...ea()},na={predicate:f(_([`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`])),selector:f(p()),value:p(),...pn(),...ea()},ra={locator:_(Se),query:f(p()),action:_(Wi),value:p(),timeoutMs:h(),first:g(),last:g(),depth:h(),raw:g(),...ea()},ia={kind:f(_(ut,`Gesture variant.`)),direction:_(lt,`Fling direction.`),preset:_(et,`Swipe preset.`),origin:fn(`Gesture origin point.`),delta:fn(`Movement delta for pan or transform gestures.`),distance:h(`Fling distance.`,{min:0}),scale:m(`Pinch or transform scale.`),degrees:m(`Rotation in degrees.`),durationMs:h(`Pan/transform duration.`,{min:16,max:1e4}),pointerCount:h(`Pan touch pointer count (1 or 2).`,{min:1,max:2}),source:p(`Drag source @ref or selector.`),destination:p(`Drag destination @ref or selector.`),sourceHoldMs:h(`Drag activation hold duration.`,{min:1,max:1e4}),moveMs:h(`Drag movement duration.`,{min:16,max:1e4}),destinationHoldMs:h(`Hold before releasing at the destination.`,{min:0,max:1e4})},aa=[F({name:`click`,description:Gi.click,inputSchema:hn(Ki),readInput:e=>gn(e,Ki)}),F({name:`press`,description:Gi.press,inputSchema:hn(qi),readInput:e=>gn(e,qi)}),F({name:`fill`,description:Gi.fill,inputSchema:hn(Ji),readInput:e=>gn(e,Ji)}),W(`longpress`,Yi),W(`swipe`,Xi),W(`focus`,Zi),W(`type`,Qi),W(`scroll`,$i),W(`get`,ta),W(`is`,na),W(`find`,ra),F({name:`gesture`,description:Gi.gesture,inputSchema:hn(ia),readInput:oa})];function oa(e){let t=_n(e);return{...vn(t),...$e(t)}}function W(e,t){return B(e,Gi[e],t)}const sa={gesture:la},ca={gesture:e=>{let t=oa(e);return w(u.gesture,[],e,x(t))}};function la(e,t){return{...T(t),...ht(e,t.pointerCount)}}const G={click:(e,t)=>({...T(t),...qn(t),...Xn(t),...Yn(t),target:Zn(Ke(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...T(t),...qn(t),...Xn(t),...Yn(t),target:Zn(Ke(e)),verify:t.verify}),longpress:(e,t)=>{let n=ua(e);return{...T(t),...qn(t),...Yn(t),target:Zn(n),durationMs:n.durationMs}},swipe:(e,t)=>({...T(t),...at(e,{count:t.count,pauseMs:t.pauseMs,pattern:t.pattern})}),focus:(e,t)=>({...T(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...T(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=Ue(e);return{...T(t),...qn(t),...Yn(t),target:Zn(n.target),text:n.text,delayMs:t.delayMs,recordAs:t.recordAs,verify:t.verify}},scroll:(e,t)=>({...T(t),...Yn(t),direction:ma(e[0]),amount:O(e[1]),pixels:t.pixels,durationMs:t.durationMs}),get:(e,t)=>({...T(t),...Gn(t),...qn(t),format:ir(e[0]),target:Zn(rr(e.slice(1)))})},K={click:e=>w(u.click,Qn(e),{...e,clickButton:e.button}),press:C(u.press,e=>Qn(e)),longpress:C(u.longPress,e=>da(e)),swipe:e=>(gt(e),w(u.swipe,[],e,{from:e.from,to:e.to,count:e.count,pauseMs:e.pauseMs,pattern:e.pattern})),focus:C(u.focus,e=>[String(e.x),String(e.y)]),type:C(u.type,e=>fa(e)),fill:C(u.fill,e=>pa(e)),scroll:C(u.scroll,e=>[M(e.direction,`scroll requires direction`),...A(e.amount)]),get:C(u.get,e=>[M(e.format,`get requires format`),...$n(e)])};function ua(e){let t=ha(e);return{...Ke(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function da(e){return[...Qn(e),...A(e.durationMs)]}function fa(e){return[e.text]}function pa(e){return[...Qn(e),e.text]}function ma(t){if(t===`up`||t===`down`||t===`left`||t===`right`||t===`top`||t===`bottom`)return t;throw new e(`INVALID_ARGS`,`Unknown direction: ${String(t)}`,{hint:`scroll takes a direction first, then an optional amount: scroll <up|down|left|right|top|bottom> [amount]. It takes no @ref or selector — scroll the whole viewport, then retry the target with a selector.`})}function ha(e){if(cr(e[0])&&cr(e[1]))return{target:e.slice(0,2),...e[2]===void 0?{}:{durationMs:Number(e[2])}};let t=e.at(-1);return e.length>1&&cr(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}const ga=L(e=>{let t=z(e);return{data:t.data,text:_a(t.text,e)}});function _a(e,t){let n=typeof t.warning==`string`?`\nWarning: ${t.warning}`:``;return`${e??``}${n}${va(t.settle)}`}function va(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Sa(t),...ya(t),...xa(t)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
|
|
4
|
+
`)}`}function ya(e){let t=e.diff,n=(t?.lines??[]).map(t=>`${t.kind===`removed`?`-`:`+`} ${ba(t,e.refsGeneration)}`);return t?.truncated&&n.push(`… changed lines truncated`),n}function ba(e,t){let n=e.text??``,r=gr(e.ref,t);if(!r||!e.ref)return n;let i=`@${e.ref}`;return n.startsWith(`${i} `)?`${r}${n.slice(i.length)}`:n}function xa(e){let t=e.tail??[];if(t.length===0)return[];let n=[`unchanged interactive (${t.length}):`];for(let r of t){let t=r.label?` "${r.label}"`:``,i=gr(r.ref,e.refsGeneration)??`@${r.ref??``}`;n.push(`= ${i} [${r.role??``}]${t}`)}return e.tailTruncated&&n.push(`… more interactive elements not shown, use snapshot -i`),n}function Sa(e){let t=e.settled===!0?`settled`:`not settled`,n=e.diff?.summary;return n?`${t} after ${e.waitedMs??0}ms: +${n.additions??0} -${n.removals??0} (~${n.unchanged??0} unchanged)`:`${t} after ${e.waitedMs??0}ms`}function Ca(e){let t=e.result;return e.format===`text`?{data:t,text:typeof t.text==`string`?t.text:``}:e.format===`attrs`?{data:t,text:JSON.stringify(t.node??{},null,2)}:ka(t)}function wa(e){let t=e,n=je(t);if(n)return{data:t,text:n};if(typeof t.text==`string`)return{data:t,text:t.text};if(Array.isArray(t.matches))return{data:t,text:Ta(t.matches,t.refsGeneration)};let r=gr(t.ref,t.refsGeneration);return r?{data:t,text:`Found: ${r}`}:typeof t.found==`boolean`?{data:t,text:`Found: ${t.found}`}:t.node?{data:t,text:JSON.stringify(t.node,null,2)}:ka(t)}function Ta(e,t){return[`${e.length} match${e.length===1?``:`es`}:`,...e.map(e=>Ea(e,t))].join(`
|
|
5
|
+
`)}function Ea(e,t){let n=e.ref??``,r=n.startsWith(`@`)?n.slice(1):n,i=gr(n,t)??`@${r}`,a=Ve(e.node?.type??`Element`),o=e.node?Ge(e.node,a):``;return`= ${i} [${a}]${o?` "${o}"`:``}`}function Da(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Oa(e){let t=e,n=t.ref??``,r=t.x,i=t.y;if(!n||typeof r!=`number`||typeof i!=`number`){let e=ka(t);return{data:e.data,text:_a(e.text,t)}}return{data:t,text:_a(`Tapped @${n} (${r}, ${i})`,t)}}const q={click:L(Oa),press:L(Oa),fill:ga,longpress:ga,scroll:ga,get:({input:e,result:t})=>Ca({result:t,format:e.format}),is:L(Da),find:L(wa)};function ka(e){return z(e)}const Aa={find:(e,t)=>Pa(e,t),is:(e,t)=>Fa(e,t)},ja={is:C(u.is,e=>Ma(e)),find:e=>w(u.find,Na(e),{...e,findFirst:e.first,findLast:e.last})};function Ma(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function Na(e){let t=e.locator&&e.locator!==`any`?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case`click`:case`focus`:case`exists`:case`list`:return e.action?[...t,e.action]:t;case`getText`:return[...t,`get`,`text`];case`getAttrs`:return[...t,`get`,`attrs`];case`wait`:return[...t,`wait`,...A(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function Pa(t,n){let r={...La(n),...Kn(n),...Gn(n),first:n.findFirst,last:n.findLast},i=Ia(t[0]),a=i!==void 0,o=a?t[1]:t[0],s=a?2:1,c=ye(t[s]);if(c===void 0)return{...r,locator:i,query:Ra(o)};if(c===`get`){let n=t[s+1];if(n===`text`)return{...r,locator:i,query:Ra(o),action:`getText`};if(n===`attrs`)return{...r,locator:i,query:Ra(o),action:`getAttrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...r,locator:i,query:Ra(o),action:`wait`,timeoutMs:O(t[s+1])};if(c===`fill`||c===`type`)return{...r,locator:i,query:Ra(o),action:c,value:t.slice(s+1).join(` `)};if(c===`click`||c===`focus`||c===`exists`||c===`list`)return{...r,locator:i,query:Ra(o),action:c};throw new e(`INVALID_ARGS`,`Unsupported find action: ${t[s]}`,{hint:ge})}function Fa(t,n){let r={...Jn(n),...Kn(n),...Gn(n)},i=ce(t),a=le(i[0]??``);if(!a.ok)throw new e(a.code,a.message,{hint:a.hint});let o=a.predicate,s=ar(i.slice(1),{preferTrailingValue:o===`text`});return o===`text`?{...r,predicate:o,selector:s.selectorExpression,value:s.rest.join(` `)}:{...r,predicate:o,selector:s.selectorExpression}}function Ia(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function La(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function Ra(t){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,`find requires query`);return t}const J={get:{usageOverride:`get text|attrs <@ref|selector>`,positionalArgs:[`subcommand`,`target`],allowsExtraPositionals:!0,allowedFlags:[...H,`record`]},find:{usageOverride:`find <locator|text> <action> [value] [--first|--last]`,positionalArgs:[`query`,`action`,`value?`],allowsExtraPositionals:!0,allowedFlags:[`snapshotDepth`,`snapshotRaw`,`findFirst`,`findLast`,`record`]},is:{positionalArgs:[`predicate`,`selector`,`value?`],allowsExtraPositionals:!0,allowedFlags:[...H,`record`]},click:{usageOverride:`click <x y|@ref|selector>`,positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...Wr,`clickButton`,...Ui(`click`),...H]},press:{usageOverride:`press <x y|@ref|selector>`,positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...Wr,...Ui(`press`),...H]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...Ui(`longpress`),...H]},swipe:{positionalArgs:[`x1`,`y1`,`x2`,`y2`],allowsExtraPositionals:!0,allowedFlags:[`count`,`pauseMs`,`pattern`]},gesture:{usageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform|drag> ...`,listUsageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform|drag> ...`,positionalArgs:[`pan|fling|swipe|pinch|rotate|transform|drag`,`args?`],allowsExtraPositionals:!0,allowedFlags:[`pointerCount`]},focus:{positionalArgs:[`x`,`y`]},type:{positionalArgs:[`text`],allowsExtraPositionals:!0,allowedFlags:[`delayMs`]},fill:{usageOverride:`fill <x> <y> <text> | fill <@ref|selector> <text>`,positionalArgs:[`targetOrX`,`yOrText`,`text?`],allowsExtraPositionals:!0,allowedFlags:[...H,`delayMs`,`recordAs`,...Ui(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount] [--pixels <n>] [--duration-ms <ms>] [--settle]`,positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`,...Ui(`scroll`)]}},za=I(Y(`click`),(e,t)=>e.interactions.click(Qa(t))),Ba=I(Y(`press`),(e,t)=>e.interactions.press($a(t))),Va=I(Y(`fill`),(e,t)=>e.interactions.fill(eo(t))),Ha=I(Y(`longpress`),(e,t)=>e.interactions.longPress(to(t))),Ua=I(Y(`swipe`),(e,t)=>e.interactions.swipe(t)),Wa=I(Y(`focus`),(e,t)=>e.interactions.focus(t)),Ga=I(Y(`type`),(e,t)=>e.interactions.type(t)),Ka=I(Y(`scroll`),(e,t)=>e.interactions.scroll(t)),qa=I(Y(`get`),(e,t)=>e.interactions.get(ro(t))),Ja=I(Y(`is`),(e,t)=>e.interactions.is(t)),Ya=I(Y(`find`),(e,t)=>e.interactions.find(t)),Xa=I(Y(`gesture`),async(e,t)=>{switch(t.kind){case`pan`:return await e.interactions.pan(io(t));case`fling`:return await e.interactions.fling(oo(t));case`swipe`:return await e.interactions.swipeGesture(so(t));case`pinch`:return await e.interactions.pinch(co(t));case`rotate`:return await e.interactions.rotateGesture(lo(t));case`transform`:return await e.interactions.transformGesture(uo(t));case`drag`:return await e.interactions.drag(ao(t))}}),Za=P({name:`interaction`,clientSurface:!1,commands:[N({name:`click`,text:{summary:`Click or tap a UI target`},metadata:Y(`click`),definition:za,cliSchema:J.click,cliReader:G.click,daemonWriter:K.click,cliOutputFormatter:q.click}),N({name:`press`,text:{summary:`Short-press a UI target`,cliDetail:`The hold duration is positional on longpress, not press --hold-ms.`},metadata:Y(`press`),definition:Ba,cliSchema:J.press,cliReader:G.press,daemonWriter:K.press,cliOutputFormatter:q.press}),N({name:`fill`,text:{summary:`Replace text in a UI input`},metadata:Y(`fill`),definition:Va,cliSchema:J.fill,cliReader:G.fill,daemonWriter:K.fill,cliOutputFormatter:q.fill}),N({name:`longpress`,text:{summary:`Hold a UI target to open a context menu`,cliDetail:`Duration is positional, for example longpress @e12 800 or longpress 300 500 800.`},metadata:Y(`longpress`),definition:Ha,cliSchema:J.longpress,cliReader:G.longpress,daemonWriter:K.longpress,cliOutputFormatter:q.longpress}),N({name:`swipe`,text:{summary:`Fling between coordinates`},metadata:Y(`swipe`),definition:Ua,cliSchema:J.swipe,cliReader:G.swipe,daemonWriter:K.swipe}),N({name:`focus`,text:{summary:`Focus input at screen coordinates`},metadata:Y(`focus`),definition:Wa,cliSchema:J.focus,cliReader:G.focus,daemonWriter:K.focus}),N({name:`type`,text:{summary:`Append text to the focused input`},metadata:Y(`type`),definition:Ga,cliSchema:J.type,cliReader:G.type,daemonWriter:K.type}),N({name:`scroll`,text:{summary:`Scroll in a direction or to an edge`},metadata:Y(`scroll`),definition:Ka,cliSchema:J.scroll,cliReader:G.scroll,daemonWriter:K.scroll,cliOutputFormatter:q.scroll}),N({name:`get`,text:{summary:`Read element text or attributes`},metadata:Y(`get`),definition:qa,cliSchema:J.get,cliReader:G.get,daemonWriter:K.get,cliOutputFormatter:q.get}),N({name:`is`,text:{summary:`Check a UI predicate on a selector`},metadata:Y(`is`),definition:Ja,cliSchema:J.is,cliReader:Aa.is,daemonWriter:ja.is,cliOutputFormatter:q.is}),N({name:`find`,text:{summary:`Find an element and act`},metadata:Y(`find`),definition:Ya,cliSchema:J.find,cliReader:Aa.find,daemonWriter:ja.find,cliOutputFormatter:q.find}),N({name:`gesture`,text:{summary:`Run pan, fling, swipe, pinch, rotate, transform, or drag gestures`,cliDetail:`Argument shapes: pan <x> <y> <dx> <dy> [durationMs], fling <up|down|left|right> <x> <y> [distance], swipe <left|right|left-edge|right-edge>, pinch <scale> [x] [y], rotate <degrees> [x] [y], transform <x> <y> <dx> <dy> <scale> <degrees> [durationMs], or drag <source-selector|pinned-ref> <destination-selector|pinned-ref> [sourceHoldMs] [moveMs] [destinationHoldMs]. For command plans, output only command lines. Android transform verification should use all app-observable effects, for example wait text "pan changed yes", wait text "pinch changed yes", and wait text "rotate changed yes", not exact transform values.`},metadata:Y(`gesture`),definition:Xa,cliSchema:J.gesture,cliReader:sa.gesture,daemonWriter:ca.gesture})]});function Y(e){let t=aa.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function Qa(e){return{...b(e),...On(e.target),...jn(e),...An(e),button:e.button,verify:e.verify,...no(e)}}function $a(e){return{...b(e),...On(e.target),...jn(e),...An(e),verify:e.verify,...no(e)}}function eo(e){return{...b(e),...On(e.target),...jn(e),text:e.text,delayMs:e.delayMs,recordAs:e.recordAs,verify:e.verify,...no(e)}}function to(e){return{...b(e),...On(e.target),...jn(e),durationMs:e.durationMs,...no(e)}}function no(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function ro(e){return{...b(e),...kn(e.target),...jn(e),format:e.format,record:e.record}}function io(e){return{...b(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,pointerCount:e.pointerCount,durationMs:e.durationMs}}function ao(e){return{...b(e),source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}}function oo(e){return{...b(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance}}function so(e){return{...b(e),preset:e.preset}}function co(e){return{...b(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function lo(e){return{...b(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y}}function uo(e){return{...b(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,scale:e.scale,degrees:e.degrees,durationMs:e.durationMs}}function fo(e){return{data:{devices:e.map(Ne)},text:e.map(Eo).join(`
|
|
6
|
+
`)}}function po(e){return{data:{device:Ne(e.device),availableCommands:e.availableCommands},text:[`${Eo(e.device)} supports ${e.availableCommands.length} commands:`,e.availableCommands.join(` `)].join(`
|
|
7
|
+
`)}}function mo(e){return{data:{apps:e.result},stderr:e.appsFilter===`all`?`Showing all apps, including system apps.
|
|
8
8
|
`:`Showing user-installed apps. Use --all to include system apps.
|
|
9
9
|
`,text:e.result.length>0?e.result.join(`
|
|
10
|
-
`):e.appsFilter===`all`?`No apps found.`:`No user-installed apps found.`}}function
|
|
11
|
-
`)||null}}function
|
|
12
|
-
`):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=
|
|
10
|
+
`):e.appsFilter===`all`?`No apps found.`:`No user-installed apps found.`}}function ho(e){if(`savedScript`in e)return{data:e,text:`Published script: ${e.savedScript}\nSession remains active: ${e.session}\nActions: ${e.actionCount}`};if(`stateDir`in e)return{data:e,text:e.stateDir};let t={sessions:e.sessions.map(ze)};return{data:t,text:JSON.stringify(t,null,2)}}function go(e){let t=Ie(e),n=[je(t)].filter(e=>!!e);typeof t.sessionStateDir==`string`&&n.push(`Session state: ${t.sessionStateDir}`);for(let t of e.warnings??[])n.push(`Warning: ${t}`);let r=_o(e.snapshot);return r&&(t.snapshot=r.jsonData??r.data,r.text&&n.push(r.text)),{data:t,...r?.stderr?{stderr:r.stderr}:{},text:n.join(`
|
|
11
|
+
`)||null}}function _o(e){return!e||!Array.isArray(e.nodes)?null:vi({result:e,interactiveOnly:!0})}function vo(e){return z(Le(e))}function yo(e){if(bo(e))return{data:e,text:e.artifacts.length>0?e.artifacts.map(Oo).join(`
|
|
12
|
+
`):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=ko(e);return n&&t.push(`Retry: ${n}`),{data:e,text:e.cloudArtifacts.length>0?e.cloudArtifacts.map(Do).join(`
|
|
13
13
|
`):t.join(`
|
|
14
|
-
`)}}function
|
|
15
|
-
`)}}const Z={boot:z(So),shutdown:z(Co),devices:z(uo),capabilities:z(fo),doctor:z(wo),apps:({input:e,result:t})=>po({result:t,appsFilter:e.appsFilter}),session:z(mo),artifacts:z(vo),open:z(ho),close:z(_o),install:z(bo),reinstall:z(bo),"install-from-source":z(xo),prepare:B,viewport:B};function To(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``;return`${e.name} (${e.platform}${t}${n})${r}`}function Eo(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Do(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Oo(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function ko(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const Ao=H(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:p(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:p(`Cloud provider session id or ARN.`)}),jo=P({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:Ao,definition:R(Ao,(e,t)=>e.sessions.artifacts(t)),cliSchema:{usageOverride:`artifacts [provider-session-id] [--provider <name>]`,positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...T(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:C(u.artifacts),cliOutputFormatter:Z.artifacts});function Mo(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i}=e;if(!(t===void 0&&n===void 0&&r===void 0&&i===void 0))return{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i}}function No(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=Mo({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const Po=H(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:_([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),Fo=H(`open`,`Boot the selected device when needed, then open an app, deep link, or URL in a session. Use the app or URL inputs to choose what becomes the foreground automation target.`,{app:p(`App name, bundle id, package, or URL.`),url:p(`Optional URL passed with an app shell.`),surface:_(wt,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:p(`Android activity name.`),launchConsole:p(`Launch console mode.`),launchArgs:cn(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:g(`Force relaunch.`),foreground:g(`Include an initial interactive snapshot in a fresh open response. With no app argument, discover the sole running app on the sole booted iOS simulator; ambiguous environments fail closed.`),saveScript:v({oneOf:[nn(),d()]}),force:g(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),deviceHub:g(`Use Xcode Device Hub when surfacing Apple simulators.`),testIme:g(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:g(`Do not record this action.`),metroHost:p(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:h(`Session-scoped Metro/debug port hint applied to the opened app. On an emulator/simulator the host defaults to the loopback alias (Android 10.0.2.2, iOS 127.0.0.1) when --metro-host is omitted; physical devices still require an explicit --metro-host.`,{min:1,max:65535}),bundleUrl:p(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:p(`Session-scoped launch URL hint applied to the opened app.`)}),Io=H(`close`,`Close the named app, or close the active session app when app is omitted. Use shutdown only when the selected simulator or emulator should also stop.`,{app:p(`Optional app to close.`),shutdown:g(`Shutdown the session/device where supported.`),saveScript:v({oneOf:[nn(),d()]}),force:g(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)}),Lo=R(Po,(e,t)=>e.apps.list(t)),Ro=R(Fo,(e,t)=>e.apps.open(zo(t)));function zo(e){return No(e)}const Bo=R(Io,(e,t)=>t.app?e.apps.close(t):e.sessions.close($o(t))),Vo={allowedFlags:[`appsFilter`],defaults:{appsFilter:Pt}},Ho={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`surface`,...Vr,`launchUrl`]},Uo={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},Wo=(e,t)=>({...T(t),appsFilter:Ft(t.appsFilter)}),Go=(e,t)=>({...T(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,foreground:t.foreground,saveScript:t.saveScript,force:t.force,deviceHub:t.deviceHub,testIme:t.testIme,noRecord:t.noRecord,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl}),Ko=(e,t)=>({...T(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),qo=C(u.apps),Jo=C(u.open,es),Yo=C(u.close,e=>A(e.app)),Xo=P({name:`apps`,text:{summary:`List installed apps`,cliDetail:`Defaults to user-installed apps; use --all to include system/OEM apps.`},metadata:Po,definition:Lo,cliSchema:Vo,cliReader:Wo,daemonWriter:qo,cliOutputFormatter:Z.apps}),Zo=P({name:`open`,text:{summary:`Open an app, deep link or URL, save replays`,cliDetail:`Use --platform to bind URL/deep-link opens to the target platform. For iOS simulator initial stdout/stderr, put --launch-console <path> on this open command, for example agent-device open "Agent Device Tester" --platform ios --launch-console artifacts/launch-console.log. Expo Go/dev-client shells accept host + URL, for example agent-device open "Expo Go" exp://127.0.0.1:8081 --platform ios. macOS also supports --surface app|frontmost-app|desktop|menubar. --metro-host/--metro-port/--bundle-url/--launch-url set this session's Metro/debug runtime hints as part of open itself (applied to the app's dev-server prefs and recorded as the session's dev-server binding), so a fresh session has them before its first reload instead of needing a throwaway reload-first call just to seed hints; a later plain metro reload in the same session reuses whichever of these were set. A fresh open without these flags clears any leftover binding from a previous same-name session; close also clears it.`,mcpDetail:`Metro and debug runtime hints given here are recorded as the session's dev-server binding, so a later reload reuses them; a fresh open without them clears any binding left by a previous same-name session.`},metadata:Fo,definition:Ro,cliSchema:Ho,cliReader:Go,daemonWriter:Jo,cliOutputFormatter:Z.open}),Qo=P({name:`close`,text:{summary:`Close an app or end the session`},metadata:Io,definition:Bo,cliSchema:Uo,cliReader:Ko,daemonWriter:Yo,cliOutputFormatter:Z.close});function $o(e){let{app:t,...n}=e;return n}function es(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const ts=H(`devices`,`List available devices and simulators that can be selected for automation. Use platform, device, udid, or serial inputs on later commands to target one result.`,{}),ns=H(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),rs=H(`boot`,`Boot or prepare the selected device or simulator so later commands can target it. The device is chosen through the device-selection inputs, not by naming it here.`,{headless:g(`Boot without showing simulator UI when supported.`)}),is=H(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),as=R(ts,(e,t)=>e.devices.list(t)),os=R(ns,(e,t)=>e.devices.capabilities(t)),ss=R(rs,(e,t)=>e.devices.boot(t)),cs=R(is,(e,t)=>e.devices.shutdown(t)),ls={allowedFlags:[`headless`]},us={},ds={},fs={},ps=(e,t)=>T(t),ms=(e,t)=>({...T(t),headless:t.headless}),hs=C(u.devices),gs=C(u.capabilities),_s=C(u.boot),vs=C(u.shutdown),ys=[P({name:`devices`,text:{summary:`List available devices and simulators`},metadata:ts,definition:as,cliSchema:us,cliReader:ps,daemonWriter:hs,cliOutputFormatter:Z.devices}),P({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:ns,definition:os,cliSchema:ds,cliReader:ps,daemonWriter:gs,cliOutputFormatter:Z.capabilities}),P({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:rs,definition:ss,cliSchema:ls,cliReader:ms,daemonWriter:_s,cliOutputFormatter:Z.boot}),P({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:is,definition:cs,cliSchema:fs,cliReader:ps,daemonWriter:vs,cliOutputFormatter:Z.shutdown})],bs=H(`doctor`,`Diagnose device, app, development-server, and React Native or Expo readiness issues. Returns compact evidence for local inventory, sessions, optional app discovery, toolchains, and server reachability.`,{targetApp:p(`Installed app package/bundle id or app name to verify without opening a session.`),remote:g(`Check remote connection setup instead of local device inventory.`)}),xs=P({name:`doctor`,text:{summary:`Diagnose device, app, dev-server, and RN/Expo readiness`,cliDetail:`Metro reachability is inferred from cwd/runtime. On iOS simulators it also warms the XCTest runner build cache in the background when missing. Pass --app to verify a target app on the one matching booted device without opening a session. Use --remote to check remote connection setup without probing local devices. Default output is compact; use --json for full checks and evidence.`,mcpDetail:`On iOS simulators it also warms the XCTest runner build cache in the background when missing, so run it before the first Apple snapshot or interaction of a session.`},metadata:bs,definition:R(bs,(e,t)=>e.command.doctor(t)),cliSchema:{usageOverride:`doctor [--platform ios|android|harmonyos|vega|macos|linux|web|apple] [--app <id-or-name>] [--remote]`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...T(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:C(u.doctor),cliOutputFormatter:Z.doctor});function Ss(t,n=`--github-actions-artifact`){let r=t.indexOf(`:`);if(r<=0||r===t.length-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:i,repo:a}=Ts(t.slice(0,r),n);return ws(i,a,t.slice(r+1),`${n} artifact`)}function Cs(t,n){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`${n} installSource must be an object.`);let r=t;if(Ds(r.type,`${n} installSource.type`)!==`github-actions-artifact`)throw new e(`INVALID_ARGS`,`${n} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=Ts(Ds(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return ws(i,a,r.artifact,`${n} installSource.artifact`)}function ws(e,t,n,r){return typeof n==`number`||ks(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:Os(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:Ds(n,r)}}function Ts(t,n){let r=t.indexOf(`/`);if(r<=0||r===t.length-1||t.indexOf(`/`,r+1)!==-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);let i={owner:t.slice(0,r).trim(),repo:t.slice(r+1).trim()};if(!i.owner||!i.repo)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);return i}function Es(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function Ds(t,n){let r=Es(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function Os(t,n){let r=typeof t==`number`?t:typeof t==`string`?Number(t):NaN;if(!Number.isInteger(r))throw new e(`INVALID_ARGS`,`${n} must be an integer.`);return r}function ks(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const As=H(`install`,`Install an app binary from a local path. Provide an app identifier with the path when the target needs explicit app selection; use reinstall to replace an already installed app.`,{app:p(`Optional app identifier hint.`),appPath:f(p(`Path to app binary.`))}),js=H(`reinstall`,`Replace an installed app with a binary from a local path. Use this when preserving the same app identity while installing a new build on the selected device.`,{app:f(p()),appPath:f(p(`Path to app binary.`))}),Ms=H(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:f(v(an(`Install source object.`))),retainPaths:g(),retentionMs:h()}),Ns=R(As,(e,t)=>e.apps.install(t)),Ps=R(js,(e,t)=>e.apps.reinstall(t)),Fs=R(Ms,(e,t)=>e.apps.installFromSource(t)),Is={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},Ls={positionalArgs:[`app`,`path`]},Rs={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,listUsageOverride:`install-from-source`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},zs=(e,t)=>Gs(e,t),Bs=(e,t)=>Ks(e,t),Vs=(e,t)=>({...T(t),source:Ys(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),Hs=C(u.install,e=>qs(e.app,e.appPath)),Us=C(u.reinstall,e=>Js(e.app,e.appPath)),Ws=[P({name:`install`,text:{summary:`Install an app binary from a path`},metadata:As,definition:Ns,cliSchema:Is,cliReader:zs,daemonWriter:Hs,cliOutputFormatter:Z.install}),P({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:js,definition:Ps,cliSchema:Ls,cliReader:Bs,daemonWriter:Us,cliOutputFormatter:Z.reinstall}),P({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:Ms,definition:Fs,cliSchema:Rs,cliReader:Vs,daemonWriter:e=>w(ct.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function Gs(e,t){let[n,r]=e,i=r!==void 0;return{...T(t),...i?{app:M(n,`install requires app`)}:{},appPath:M(i?r:n,`install requires path`)}}function Ks(e,t){return{...T(t),app:M(e[0],`reinstall requires app`),appPath:M(e[1],`reinstall requires path`)}}function qs(e,t){let n=N(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function Js(e,t){return[N(e,`missing first positional`),N(t,`missing second positional`)]}function Ys(t,n){let r=t[0]?.trim();if(t.length>1)throw new e(`INVALID_ARGS`,`install-from-source accepts either one <url> positional or --github-actions-artifact`);let i=n.githubActionsArtifact?Ss(n.githubActionsArtifact):void 0,a=n.installSource;if(+!!r+ +!!i+ +!!a!=1)throw new e(`INVALID_ARGS`,`install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource`);if(!r&&n.header&&n.header.length>0)throw new e(`INVALID_ARGS`,`install-from-source --header is only supported for URL sources`);return i||a||{kind:`url`,url:r,headers:Xs(n.header)}}function Xs(t){if(!t||t.length===0)return;let n={};for(let r of t){let t=r.indexOf(`:`);if(t<=0)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Expected "name:value".`);let i=r.slice(0,t).trim(),a=r.slice(t+1).trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Header name cannot be empty.`);n[i]=a}return n}const Zs=H(`prepare`,`Prepare platform helper infrastructure. ios-runner builds/reuses, starts, and health-checks the XCTest runner so later Apple snapshots and interactions do not pay first-use startup cost. In JSON output, top-level buildMs/connectMs/healthCheckMs are diagnostic fields and may overlap; use timing.additiveParts for additive wall-clock phase totals. In CI, run it after boot/install and before replay/test; if replay/test starts a separate daemon, stop the prepare daemon before replay/test so it does not keep the prepared runner lease. It is not a recovery step for "runner already owned by another agent-device daemon"; stop the owning daemon on the Mac with simulator access instead. Runner build/start output is written to the session runner.log; daemon.log is for daemon lifecycle/startup issues.`,{action:f(_([`ios-runner`])),timeoutMs:h(`Maximum wall-clock time for the prepare command.`)}),Qs=P({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:Zs,definition:R(Zs,(e,t)=>e.command.prepare(t)),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos [--timeout <ms>]`,listUsageOverride:`prepare`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...T(t),action:M(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:C(u.prepare,e=>[N(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),$s=H(`push`,`Deliver push notification payloads to an installed app.`,{app:f(p()),payload:f(v({oneOf:[d(),an()]}))}),ec=H(`trigger-app-event`,`Ask the app to handle an app-defined automation or test event, with an optional structured payload. Call this only for event names and payload shapes the app documents.`,{event:f(p(`Name of an app-defined automation or test event the app documents.`)),payload:fc(`Structured payload passed to the event, in the shape the app documents for it.`)}),tc=R($s,(e,t)=>e.apps.push(t)),nc=R(ec,(e,t)=>e.apps.triggerEvent(t)),rc={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},ic={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},ac=(e,t)=>({...T(t),app:M(e[0],`push requires bundleOrPackage`),payload:M(e[1],`push requires payloadOrJson`)}),oc=(e,t)=>({...T(t),event:M(e[0],`trigger-app-event requires event`),payload:e[1]?ar(e[1],`trigger-app-event payload`):void 0}),sc=C(u.push,e=>uc(e)),cc=C(u.triggerAppEvent,e=>dc(e)),lc=[P({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:$s,definition:tc,cliSchema:rc,cliReader:ac,daemonWriter:sc}),P({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:ec,definition:nc,cliSchema:ic,cliReader:oc,daemonWriter:cc})];function uc(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function dc(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function fc(e){return sn(e)}const pc=H(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:_([`list`,`state-dir`,`save-script`],`list shows active sessions; state-dir prints the daemon state directory; save-script publishes an armed recording without teardown.`),path:p(`Optional .ad output path for save-script.`),force:g(`Atomically replace an existing save-script target.`)}),mc=P({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:pc,definition:R(pc,async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return gc(a,n,r),a===`state-dir`?{stateDir:await e.sessions.stateDir(i)}:a===`save-script`?await e.sessions.saveScript({...i,path:n,force:r}):{sessions:await e.sessions.list(i)}}),cliSchema:{usageOverride:`session list | session state-dir | session save-script [path] [--force]`,listUsageOverride:`session`,positionalArgs:[`list|state-dir|save-script?`,`path?`],allowedFlags:[`force`]},cliReader:(e,t)=>({...T(t),action:hc(e[0]),path:e[1],force:t.force}),cliOutputFormatter:Z.session});function hc(t){let n=t??`list`;if(n===`list`||n===`state-dir`||n===`save-script`)return n;throw new e(`INVALID_ARGS`,`session only supports list, state-dir, or save-script`)}function gc(t,n,r){if(t!==`save-script`&&!(n===void 0&&r!==!0))throw new e(`INVALID_ARGS`,`session ${t} does not accept a path or --force; use session save-script [path] [--force] to publish a recording.`)}const _c=H(`viewport`,`Resize the active web viewport before taking snapshots or screenshots. Useful for fixed-layout or 100vh apps where changing the viewport reveals different content.`,{width:f(h(`Viewport width in CSS pixels.`,{min:1})),height:f(h(`Viewport height in CSS pixels.`,{min:1}))}),vc=P({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:_c,definition:R(_c,(e,t)=>e.command.viewport(t)),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...T(t),width:bt(e[0],`width`),height:bt(e[1],`height`)}),daemonWriter:C(u.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),yc=F({name:`management`,commands:[...ys,jo,xs,Qs,Xo,mc,Zo,Qo,vc,...Ws,...lc]});function bc(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const xc={metro:({input:e,result:t})=>bc({result:t,action:e.action})},Sc=`metro`,Cc=H(Sc,`Prepare a React Native development server or ask connected apps to reload, using the development server this session is bound to. Provide explicit runtime inputs only to override that binding for one call.`,{action:f(_([`prepare`,`reload`])),projectRoot:p(),kind:v(d()),publicBaseUrl:p(),proxyBaseUrl:p(),bearerToken:p(),bridgeScope:v({type:`object`,additionalProperties:!0}),launchUrl:p(),port:h(),listenHost:p(),statusHost:p(),startupTimeoutMs:h(),probeTimeoutMs:h(),reuseExisting:g(),installDependenciesIfNeeded:g(),runtimeFilePath:p(),logPath:p(),metroHost:p(),metroPort:h(),bundleUrl:p(),timeoutMs:h()}),wc=F({name:`metro`,commands:[P({name:Sc,text:{summary:`Prepare the dev server or reload apps`,cliDetail:`reload with no --metro-host/--metro-port/--bundle-url resolves against the dev server this session last bound via metro prepare or open's metro hint flags (falling back to localhost:8081 only when the session never bound one), so it never silently reloads a different project's server on the default port; pass an explicit flag to override the session hint for one call. The reload URL keeps the bound bundle URL mount prefix instead of collapsing to the host root, and when the server has no HTTP /reload route (Expo) the reload is broadcast over its /message websocket instead of trusting the app-page fallback. The binding is cleared when the session closes, and a fresh open without hint flags also clears any leftover binding from a previous same-name session. --kind expo (detected or forced) requests the virtual-entry bundle URL (.expo/.virtual-metro-entry.bundle) instead of index.bundle, since index.bundle 404s/500s against Expo dev servers in monorepos. Dependency install auto-detects the package manager from the nearest yarn.lock/pnpm-lock.yaml/bun.lock/bun.lockb/package-lock.json walking up from --project-root (bounded at the repo root), so Yarn/pnpm workspace monorepos with the lockfile at the repo root do not wrongly fall back to npm install (which fails on workspace: dependency specifiers); if install still fails, pass --no-install-deps when dependencies are already installed (for example via a monorepo root install).`,mcpDetail:`The binding is cleared when the session closes, and a fresh open without runtime hints also clears any leftover binding from a previous same-name session.`},metadata:Cc,definition:R(Cc,async(e,t)=>t.action===`prepare`?await e.metro.prepare(Tc(t)):await e.metro.reload(Dc(t))),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo|repack]
|
|
16
|
-
agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,listUsageOverride:`metro`,positionalArgs:[`prepare|reload`],allowedFlags:[...
|
|
17
|
-
`),stderr:
|
|
18
|
-
`),stderr:
|
|
19
|
-
`)}function
|
|
20
|
-
`):void 0}function
|
|
21
|
-
`)||void 0}const
|
|
22
|
-
`)}function
|
|
23
|
-
`)}
|
|
24
|
-
|
|
14
|
+
`)}}function bo(e){return`source`in e&&e.source===`daemon`}function xo(e){return z(Re(e))}function So(e){return z(Pe(e))}function Co(e){let t=e,n=t.platform??`unknown`;return{data:t,text:`Boot ready: ${t.device??t.id??`unknown`} (${n})`}}function wo(e){let t=e,n=t.platform??`unknown`,r=t.device??t.id??`unknown`,i=t.shutdown;return{data:t,text:`${i&&typeof i==`object`&&`success`in i&&i.success===!0?`Shutdown`:`Shutdown failed`}: ${r} (${n})`}}function To(e){let t=e,n=[`Doctor: ${typeof t.status==`string`?t.status:`unknown`}`],r=Ao(t.checks);if(Ye()){let e=typeof t.summary==`string`?t.summary:void 0;e&&n.push(e)}else if(r.length===0){let e=typeof t.summary==`string`?t.summary:`No blockers found.`;n.push(e)}else for(let e of r)n.push(Je(e)),n.push(...He(e));return{data:t,text:n.join(`
|
|
15
|
+
`)}}const X={boot:L(Co),shutdown:L(wo),devices:L(fo),capabilities:L(po),doctor:L(To),apps:({input:e,result:t})=>mo({result:t,appsFilter:e.appsFilter}),session:L(ho),artifacts:L(yo),open:L(go),close:L(vo),install:L(xo),reinstall:L(xo),"install-from-source":L(So),prepare:R,viewport:R};function Eo(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``;return`${e.name} (${e.platform}${t}${n})${r}`}function Do(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Oo(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function ko(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function Ao(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const jo=B(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:p(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:p(`Cloud provider session id or ARN.`)}),Mo=N({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:jo,definition:I(jo,(e,t)=>e.sessions.artifacts(t)),cliSchema:{usageOverride:`artifacts [provider-session-id] [--provider <name>]`,positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...T(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:C(u.artifacts),cliOutputFormatter:X.artifacts});function No(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i}=e;if(!(t===void 0&&n===void 0&&r===void 0&&i===void 0))return{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i}}function Po(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=No({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const Fo=B(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:_([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),Io=B(`open`,`Boot the selected device when needed, then open an app, deep link, or URL in a session. Use the app or URL inputs to choose what becomes the foreground automation target.`,{app:p(`App name, bundle id, package, or URL.`),url:p(`Optional URL passed with an app shell.`),surface:_(yt,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:p(`Android activity name.`),launchConsole:p(`Launch console mode.`),launchArgs:cn(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:g(`Force relaunch.`),foreground:g(`Include an initial interactive snapshot in a fresh open response. With no app argument, discover the sole running app on the sole booted iOS simulator; ambiguous environments fail closed.`),saveScript:v({oneOf:[nn(),d()]}),force:g(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),deviceHub:g(`Use Xcode Device Hub when surfacing Apple simulators.`),testIme:g(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:g(`Do not record this action.`),metroHost:p(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:h(`Session-scoped Metro/debug port hint applied to the opened app. On an emulator/simulator the host defaults to the loopback alias (Android 10.0.2.2, iOS 127.0.0.1) when --metro-host is omitted; physical devices still require an explicit --metro-host.`,{min:1,max:65535}),bundleUrl:p(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:p(`Session-scoped launch URL hint applied to the opened app.`)}),Lo=B(`close`,`Close the named app, or close the active session app when app is omitted. Use shutdown only when the selected simulator or emulator should also stop.`,{app:p(`Optional app to close.`),shutdown:g(`Shutdown the session/device where supported.`),saveScript:v({oneOf:[nn(),d()]}),force:g(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)}),Ro=I(Fo,(e,t)=>e.apps.list(t)),zo=I(Io,(e,t)=>e.apps.open(Bo(t)));function Bo(e){return Po(e)}const Vo=I(Lo,(e,t)=>t.app?e.apps.close(t):e.sessions.close(es(t))),Ho={allowedFlags:[`appsFilter`],defaults:{appsFilter:Pt}},Uo={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`surface`,...Ur,`launchUrl`]},Wo={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},Go=(e,t)=>({...T(t),appsFilter:Ft(t.appsFilter)}),Ko=(e,t)=>({...T(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,foreground:t.foreground,saveScript:t.saveScript,force:t.force,deviceHub:t.deviceHub,testIme:t.testIme,noRecord:t.noRecord,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl}),qo=(e,t)=>({...T(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),Jo=C(u.apps),Yo=C(u.open,ts),Xo=C(u.close,e=>k(e.app)),Zo=N({name:`apps`,text:{summary:`List installed apps`,cliDetail:`Defaults to user-installed apps; use --all to include system/OEM apps.`},metadata:Fo,definition:Ro,cliSchema:Ho,cliReader:Go,daemonWriter:Jo,cliOutputFormatter:X.apps}),Qo=N({name:`open`,text:{summary:`Open an app, deep link or URL, save replays`,cliDetail:`Use --platform to bind URL/deep-link opens to the target platform. For iOS simulator initial stdout/stderr, put --launch-console <path> on this open command, for example agent-device open "Agent Device Tester" --platform ios --launch-console artifacts/launch-console.log. Expo Go/dev-client shells accept host + URL, for example agent-device open "Expo Go" exp://127.0.0.1:8081 --platform ios. macOS also supports --surface app|frontmost-app|desktop|menubar. --metro-host/--metro-port/--bundle-url/--launch-url set this session's Metro/debug runtime hints as part of open itself (applied to the app's dev-server prefs and recorded as the session's dev-server binding), so a fresh session has them before its first reload instead of needing a throwaway reload-first call just to seed hints; a later plain metro reload in the same session reuses whichever of these were set. A fresh open without these flags clears any leftover binding from a previous same-name session; close also clears it.`,mcpDetail:`Metro and debug runtime hints given here are recorded as the session's dev-server binding, so a later reload reuses them; a fresh open without them clears any binding left by a previous same-name session.`},metadata:Io,definition:zo,cliSchema:Uo,cliReader:Ko,daemonWriter:Yo,cliOutputFormatter:X.open}),$o=N({name:`close`,text:{summary:`Close an app or end the session`},metadata:Lo,definition:Vo,cliSchema:Wo,cliReader:qo,daemonWriter:Xo,cliOutputFormatter:X.close});function es(e){let{app:t,...n}=e;return n}function ts(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const ns=B(`devices`,`List available devices and simulators that can be selected for automation. Use platform, device, udid, or serial inputs on later commands to target one result.`,{}),rs=B(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),is=B(`boot`,`Boot or prepare the selected device or simulator so later commands can target it. The device is chosen through the device-selection inputs, not by naming it here.`,{headless:g(`Boot without showing simulator UI when supported.`)}),as=B(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),os=I(ns,(e,t)=>e.devices.list(t)),ss=I(rs,(e,t)=>e.devices.capabilities(t)),cs=I(is,(e,t)=>e.devices.boot(t)),ls=I(as,(e,t)=>e.devices.shutdown(t)),us={allowedFlags:[`headless`]},ds={},fs={},ps={},ms=(e,t)=>T(t),hs=(e,t)=>({...T(t),headless:t.headless}),gs=C(u.devices),_s=C(u.capabilities),vs=C(u.boot),ys=C(u.shutdown),bs=[N({name:`devices`,text:{summary:`List available devices and simulators`},metadata:ns,definition:os,cliSchema:ds,cliReader:ms,daemonWriter:gs,cliOutputFormatter:X.devices}),N({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:rs,definition:ss,cliSchema:fs,cliReader:ms,daemonWriter:_s,cliOutputFormatter:X.capabilities}),N({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:is,definition:cs,cliSchema:us,cliReader:hs,daemonWriter:vs,cliOutputFormatter:X.boot}),N({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:as,definition:ls,cliSchema:ps,cliReader:ms,daemonWriter:ys,cliOutputFormatter:X.shutdown})],xs=B(`doctor`,`Diagnose device, app, development-server, and React Native or Expo readiness issues. Returns compact evidence for local inventory, sessions, optional app discovery, toolchains, and server reachability.`,{targetApp:p(`Installed app package/bundle id or app name to verify without opening a session.`),remote:g(`Check remote connection setup instead of local device inventory.`)}),Ss=N({name:`doctor`,text:{summary:`Diagnose device, app, dev-server, and RN/Expo readiness`,cliDetail:`Metro reachability is inferred from cwd/runtime. On iOS simulators it also warms the XCTest runner build cache in the background when missing. Pass --app to verify a target app on the one matching booted device without opening a session. Use --remote to check remote connection setup without probing local devices. Default output is compact; use --json for full checks and evidence.`,mcpDetail:`On iOS simulators it also warms the XCTest runner build cache in the background when missing, so run it before the first Apple snapshot or interaction of a session.`},metadata:xs,definition:I(xs,(e,t)=>e.command.doctor(t)),cliSchema:{usageOverride:`doctor [--platform ios|android|harmonyos|vega|macos|linux|web|apple] [--app <id-or-name>] [--remote]`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...T(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:C(u.doctor),cliOutputFormatter:X.doctor});function Cs(t,n=`--github-actions-artifact`){let r=t.indexOf(`:`);if(r<=0||r===t.length-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:i,repo:a}=Es(t.slice(0,r),n);return Ts(i,a,t.slice(r+1),`${n} artifact`)}function ws(t,n){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`${n} installSource must be an object.`);let r=t;if(Os(r.type,`${n} installSource.type`)!==`github-actions-artifact`)throw new e(`INVALID_ARGS`,`${n} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=Es(Os(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return Ts(i,a,r.artifact,`${n} installSource.artifact`)}function Ts(e,t,n,r){return typeof n==`number`||As(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:ks(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:Os(n,r)}}function Es(t,n){let r=t.indexOf(`/`);if(r<=0||r===t.length-1||t.indexOf(`/`,r+1)!==-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);let i={owner:t.slice(0,r).trim(),repo:t.slice(r+1).trim()};if(!i.owner||!i.repo)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);return i}function Ds(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function Os(t,n){let r=Ds(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function ks(t,n){let r=typeof t==`number`?t:typeof t==`string`?Number(t):NaN;if(!Number.isInteger(r))throw new e(`INVALID_ARGS`,`${n} must be an integer.`);return r}function As(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const js=B(`install`,`Install an app binary from a local path. Provide an app identifier with the path when the target needs explicit app selection; use reinstall to replace an already installed app.`,{app:p(`Optional app identifier hint.`),appPath:f(p(`Path to app binary.`))}),Ms=B(`reinstall`,`Replace an installed app with a binary from a local path. Use this when preserving the same app identity while installing a new build on the selected device.`,{app:f(p()),appPath:f(p(`Path to app binary.`))}),Ns=B(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:f(v(an(`Install source object.`))),retainPaths:g(),retentionMs:h()}),Ps=I(js,(e,t)=>e.apps.install(t)),Fs=I(Ms,(e,t)=>e.apps.reinstall(t)),Is=I(Ns,(e,t)=>e.apps.installFromSource(t)),Ls={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},Rs={positionalArgs:[`app`,`path`]},zs={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,listUsageOverride:`install-from-source`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},Bs=(e,t)=>Ks(e,t),Vs=(e,t)=>qs(e,t),Hs=(e,t)=>({...T(t),source:Xs(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),Us=C(u.install,e=>Js(e.app,e.appPath)),Ws=C(u.reinstall,e=>Ys(e.app,e.appPath)),Gs=[N({name:`install`,text:{summary:`Install an app binary from a path`},metadata:js,definition:Ps,cliSchema:Ls,cliReader:Bs,daemonWriter:Us,cliOutputFormatter:X.install}),N({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:Ms,definition:Fs,cliSchema:Rs,cliReader:Vs,daemonWriter:Ws,cliOutputFormatter:X.reinstall}),N({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:Ns,definition:Is,cliSchema:zs,cliReader:Hs,daemonWriter:e=>w(_t.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:X[`install-from-source`]})];function Ks(e,t){let[n,r]=e,i=r!==void 0;return{...T(t),...i?{app:j(n,`install requires app`)}:{},appPath:j(i?r:n,`install requires path`)}}function qs(e,t){return{...T(t),app:j(e[0],`reinstall requires app`),appPath:j(e[1],`reinstall requires path`)}}function Js(e,t){let n=M(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function Ys(e,t){return[M(e,`missing first positional`),M(t,`missing second positional`)]}function Xs(t,n){let r=t[0]?.trim();if(t.length>1)throw new e(`INVALID_ARGS`,`install-from-source accepts either one <url> positional or --github-actions-artifact`);let i=n.githubActionsArtifact?Cs(n.githubActionsArtifact):void 0,a=n.installSource;if(+!!r+ +!!i+ +!!a!=1)throw new e(`INVALID_ARGS`,`install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource`);if(!r&&n.header&&n.header.length>0)throw new e(`INVALID_ARGS`,`install-from-source --header is only supported for URL sources`);return i||a||{kind:`url`,url:r,headers:Zs(n.header)}}function Zs(t){if(!t||t.length===0)return;let n={};for(let r of t){let t=r.indexOf(`:`);if(t<=0)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Expected "name:value".`);let i=r.slice(0,t).trim(),a=r.slice(t+1).trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Header name cannot be empty.`);n[i]=a}return n}const Qs=B(`prepare`,`Prepare platform helper infrastructure. ios-runner builds/reuses, starts, and health-checks the XCTest runner so later Apple snapshots and interactions do not pay first-use startup cost. In JSON output, top-level buildMs/connectMs/healthCheckMs are diagnostic fields and may overlap; use timing.additiveParts for additive wall-clock phase totals. In CI, run it after boot/install and before replay/test; if replay/test starts a separate daemon, stop the prepare daemon before replay/test so it does not keep the prepared runner lease. It is not a recovery step for "runner already owned by another agent-device daemon"; stop the owning daemon on the Mac with simulator access instead. Runner build/start output is written to the session runner.log; daemon.log is for daemon lifecycle/startup issues.`,{action:f(_([`ios-runner`])),timeoutMs:h(`Maximum wall-clock time for the prepare command.`)}),$s=N({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:Qs,definition:I(Qs,(e,t)=>e.command.prepare(t)),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos [--timeout <ms>]`,listUsageOverride:`prepare`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...T(t),action:j(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:C(u.prepare,e=>[M(e.action,`prepare requires subcommand`)]),cliOutputFormatter:X.prepare}),ec=B(`push`,`Deliver push notification payloads to an installed app.`,{app:f(p()),payload:f(v({oneOf:[d(),an()]}))}),tc=B(`trigger-app-event`,`Ask the app to handle an app-defined automation or test event, with an optional structured payload. Call this only for event names and payload shapes the app documents.`,{event:f(p(`Name of an app-defined automation or test event the app documents.`)),payload:pc(`Structured payload passed to the event, in the shape the app documents for it.`)}),nc=I(ec,(e,t)=>e.apps.push(t)),rc=I(tc,(e,t)=>e.apps.triggerEvent(t)),ic={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},ac={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},oc=(e,t)=>({...T(t),app:j(e[0],`push requires bundleOrPackage`),payload:j(e[1],`push requires payloadOrJson`)}),sc=(e,t)=>({...T(t),event:j(e[0],`trigger-app-event requires event`),payload:e[1]?or(e[1],`trigger-app-event payload`):void 0}),cc=C(u.push,e=>dc(e)),lc=C(u.triggerAppEvent,e=>fc(e)),uc=[N({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:ec,definition:nc,cliSchema:ic,cliReader:oc,daemonWriter:cc}),N({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:tc,definition:rc,cliSchema:ac,cliReader:sc,daemonWriter:lc})];function dc(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function fc(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function pc(e){return sn(e)}const mc=B(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:_([`list`,`state-dir`,`save-script`],`list shows active sessions; state-dir prints the daemon state directory; save-script publishes an armed recording without teardown.`),path:p(`Optional .ad output path for save-script.`),force:g(`Atomically replace an existing save-script target.`)}),hc=N({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:mc,definition:I(mc,async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return _c(a,n,r),a===`state-dir`?{stateDir:await e.sessions.stateDir(i)}:a===`save-script`?await e.sessions.saveScript({...i,path:n,force:r}):{sessions:await e.sessions.list(i)}}),cliSchema:{usageOverride:`session list | session state-dir | session save-script [path] [--force]`,listUsageOverride:`session`,positionalArgs:[`list|state-dir|save-script?`,`path?`],allowedFlags:[`force`]},cliReader:(e,t)=>({...T(t),action:gc(e[0]),path:e[1],force:t.force}),cliOutputFormatter:X.session});function gc(t){let n=t??`list`;if(n===`list`||n===`state-dir`||n===`save-script`)return n;throw new e(`INVALID_ARGS`,`session only supports list, state-dir, or save-script`)}function _c(t,n,r){if(t!==`save-script`&&!(n===void 0&&r!==!0))throw new e(`INVALID_ARGS`,`session ${t} does not accept a path or --force; use session save-script [path] [--force] to publish a recording.`)}const vc=B(`viewport`,`Resize the active web viewport before taking snapshots or screenshots. Useful for fixed-layout or 100vh apps where changing the viewport reveals different content.`,{width:f(h(`Viewport width in CSS pixels.`,{min:1})),height:f(h(`Viewport height in CSS pixels.`,{min:1}))}),yc=N({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:vc,definition:I(vc,(e,t)=>e.command.viewport(t)),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...T(t),width:qe(e[0],`width`),height:qe(e[1],`height`)}),daemonWriter:C(u.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:X.viewport}),bc=P({name:`management`,commands:[...bs,Mo,Ss,$s,Zo,hc,Qo,$o,yc,...Gs,...uc]});function xc(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const Sc={metro:({input:e,result:t})=>xc({result:t,action:e.action})},Cc=`metro`,wc=B(Cc,`Prepare a React Native development server or ask connected apps to reload, using the development server this session is bound to. Provide explicit runtime inputs only to override that binding for one call.`,{action:f(_([`prepare`,`reload`])),projectRoot:p(),kind:v(d()),publicBaseUrl:p(),proxyBaseUrl:p(),bearerToken:p(),bridgeScope:v({type:`object`,additionalProperties:!0}),launchUrl:p(),port:h(),listenHost:p(),statusHost:p(),startupTimeoutMs:h(),probeTimeoutMs:h(),reuseExisting:g(),installDependenciesIfNeeded:g(),runtimeFilePath:p(),logPath:p(),metroHost:p(),metroPort:h(),bundleUrl:p(),timeoutMs:h()}),Tc=P({name:`metro`,commands:[N({name:Cc,text:{summary:`Prepare the dev server or reload apps`,cliDetail:`reload with no --metro-host/--metro-port/--bundle-url resolves against the dev server this session last bound via metro prepare or open's metro hint flags (falling back to localhost:8081 only when the session never bound one), so it never silently reloads a different project's server on the default port; pass an explicit flag to override the session hint for one call. The reload URL keeps the bound bundle URL mount prefix instead of collapsing to the host root, and when the server has no HTTP /reload route (Expo) the reload is broadcast over its /message websocket instead of trusting the app-page fallback. The binding is cleared when the session closes, and a fresh open without hint flags also clears any leftover binding from a previous same-name session. --kind expo (detected or forced) requests the virtual-entry bundle URL (.expo/.virtual-metro-entry.bundle) instead of index.bundle, since index.bundle 404s/500s against Expo dev servers in monorepos. Dependency install auto-detects the package manager from the nearest yarn.lock/pnpm-lock.yaml/bun.lock/bun.lockb/package-lock.json walking up from --project-root (bounded at the repo root), so Yarn/pnpm workspace monorepos with the lockfile at the repo root do not wrongly fall back to npm install (which fails on workspace: dependency specifiers); if install still fails, pass --no-install-deps when dependencies are already installed (for example via a monorepo root install).`,mcpDetail:`The binding is cleared when the session closes, and a fresh open without runtime hints also clears any leftover binding from a previous same-name session.`},metadata:wc,definition:I(wc,async(e,t)=>t.action===`prepare`?await e.metro.prepare(Ec(t)):await e.metro.reload(Oc(t))),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo|repack]
|
|
16
|
+
agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,listUsageOverride:`metro`,positionalArgs:[`prepare|reload`],allowedFlags:[...Ur,...Hr]},cliReader:(t,n)=>{let r=(t[0]??``).toLowerCase();if(r!==`prepare`&&r!==`reload`)throw new e(`INVALID_ARGS`,`metro requires a subcommand: prepare or reload`);if(r===`reload`)return{action:r,metroHost:n.metroHost,metroPort:n.metroPort,bundleUrl:n.bundleUrl,timeoutMs:n.metroProbeTimeoutMs};if(!n.metroPublicBaseUrl&&!n.metroProxyBaseUrl)throw new e(`INVALID_ARGS`,`metro prepare requires --public-base-url <url> or --proxy-base-url <url>.`);return{action:r,projectRoot:n.metroProjectRoot,kind:Xe(n.kind??n.metroKind),port:n.metroPreparePort,listenHost:n.metroListenHost,statusHost:n.metroStatusHost,publicBaseUrl:n.metroPublicBaseUrl,proxyBaseUrl:n.metroProxyBaseUrl,bearerToken:n.metroBearerToken,bridgeScope:n.tenant&&n.runId&&n.leaseId?{tenantId:n.tenant,runId:n.runId,leaseId:n.leaseId}:void 0,startupTimeoutMs:n.metroStartupTimeoutMs,probeTimeoutMs:n.metroProbeTimeoutMs,reuseExisting:n.metroNoReuseExisting?!1:void 0,installDependenciesIfNeeded:n.metroNoInstallDeps?!1:void 0,runtimeFilePath:n.metroRuntimeFile}},cliOutputFormatter:Sc.metro})]});function Ec(e){return{projectRoot:e.projectRoot,kind:e.kind,publicBaseUrl:e.publicBaseUrl,proxyBaseUrl:e.proxyBaseUrl,bearerToken:e.bearerToken,bridgeScope:e.bridgeScope??Dc(e),port:e.port,listenHost:e.listenHost,statusHost:e.statusHost,startupTimeoutMs:e.startupTimeoutMs,probeTimeoutMs:e.probeTimeoutMs,reuseExisting:e.reuseExisting,installDependenciesIfNeeded:e.installDependenciesIfNeeded,runtimeFilePath:e.runtimeFilePath}}function Dc(e){return e.tenant&&e.runId&&e.leaseId?{tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId}:void 0}function Oc(e){return{metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,timeoutMs:e.timeoutMs}}function kc(e,t){return e.includes(t)}function Ac(t,n,r={}){let i=n===void 0?void 0:r.normalize?.(n)??n;if(i!==void 0&&kc(t,i))return i;throw new e(`INVALID_ARGS`,(typeof r.message==`function`?r.message(n):r.message)??`Invalid value: ${n}. Use ${t.join(`|`)}.`)}const jc=[`started`,`stopped`,`marked`,`cleared`,`restarted`,`removedRotatedFiles`];function Mc(e){return{data:e,text:e.path,stderr:ol([il(e,[`active`,`state`,`backend`,`sizeBytes`]),Xc(e),e.hint,al(e.notes)])}}function Nc(e){let t=e.events??[];return{data:e,text:t.length>0?Lc(t):`No session events found.`,stderr:ol([il(e,[`path`,`cursor`,`nextCursor`,`limit`])])}}function Pc(e){let t=[],n=e.entries??[];if(e.path&&t.push(e.path),n.length===0)t.push(`No recent HTTP(s) entries found.`);else for(let e of n)t.push(...tl(e));return{data:e,text:t.join(`
|
|
17
|
+
`),stderr:ol([il(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),al(e.notes)])}}function Fc(e){return{data:e,text:[`Audio probe: ${String(e.state??`stopped`)} heard=${String(e.heard===!0)}`,Yc(`rmsDbfs`,e.rmsDbfs),Yc(`peakDbfs`,e.peakDbfs)].filter(e=>!!e).join(`
|
|
18
|
+
`),stderr:ol([il(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),al(e.notes)])}}const Ic={logs:L(Mc),events:L(Nc),network:L(Pc),audio:L(Fc)};function Lc(e){let t=e.map(Rc),n=Math.min(Math.max(...t.map(e=>e.label.length),5),32);return t.map(e=>zc(e,n)).join(`
|
|
19
|
+
`)}function Rc(e){return{timestamp:Bc(e.ts),label:Vc(e),summary:Hc(e)}}function zc(e,t){let n=e.label.padEnd(t),r=e.timestamp?`${e.timestamp} ${n}`:n.trimEnd();return e.summary?`${r} ${e.summary}`:r.trimEnd()}function Bc(e){return e?e.replace(`T`,` `):``}function Vc(e){let t=e.command??`command`;switch(e.kind){case`request.started`:return`start ${t}`;case`request.finished`:return Qc([e.status===`error`?`error`:`ok`,t,Jc(el(e.details?.durationMs))]);case`action.recorded`:return`action ${t}`;default:return Qc([e.kind??`event`,e.command])}}function Hc(e){let t=Uc(e.summary,e);return`${t}${Wc(e,t)}`.trim()}function Uc(e,t){let n=e?.trim()??``,r=t.command??``;return t.kind===`request.started`&&n===`Started ${r}`||t.kind===`request.finished`&&n===`Finished ${r}`?``:n}function Wc(e,t){if(e.kind!==`action.recorded`)return``;let n=e.details;if(!n)return``;let r=[Gc(n,t),qc(el(n.textLength))].filter(e=>!!e);return r.length>0?` (${r.join(`, `)})`:``}function Gc(e,t){let n=$c(e.ref)??$c(e.selector)??Kc(e);if(!(!n||t.includes(n)))return`target=${n}`}function Kc(e){let t=el(e.x),n=el(e.y);return t===void 0||n===void 0?void 0:`(${t}, ${n})`}function qc(e){return e===void 0?void 0:`text=${e} chars`}function Jc(e){return e===void 0?void 0:`${Math.round(e)}ms`}function Yc(e,t){if(!Array.isArray(t))return;let n=t.filter(e=>typeof e==`number`&&Number.isFinite(e));return n.length>0?`${e}: [${n.join(`, `)}]`:void 0}function Xc(e){return jc.map(t=>Zc(t,e[t])).filter(Boolean).join(` `)||void 0}function Zc(e,t){return t==null?``:`${e}=${t}`}function Qc(e){return e.filter(e=>!!e).join(` `)}function $c(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function el(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function tl(e){let t=e.method??`HTTP`,n=e.url??`<unknown-url>`,r=e.status===void 0?``:` status=${e.status}`,i=[`${e.timestamp?`${e.timestamp} `:``}${t} ${n}${r}${e.durationMs===void 0?``:` durationMs=${e.durationMs}`}`];return e.headers?rl(i,`headers`,e.headers):(nl(i,`request headers`,e.requestHeaders),nl(i,`response headers`,e.responseHeaders)),rl(i,`request`,e.requestBody),rl(i,`response`,e.responseBody),i}function nl(e,t,n){!n||Object.keys(n).length===0||e.push(` ${t}: ${JSON.stringify(n)}`)}function rl(e,t,n){n!==void 0&&e.push(` ${t}: ${n}`)}function il(e,t){return t.map(t=>e[t]!==void 0&&e[t]!==null?`${t}=${e[t]}`:``).filter(Boolean).join(` `)||void 0}function al(e){let t=e?.filter(e=>e.length>0)??[];return t.length>0?t.join(`
|
|
20
|
+
`):void 0}function ol(e){return e.filter(e=>!!e).join(`
|
|
21
|
+
`)||void 0}const sl=`logs`,cl=`events`,ll=`network`,ul=`audio`,dl=[`dump`,`log`],fl=[`probe`],pl=[`start`,`status`,`stop`],ml=B(sl,`Session app log info, start/stop streaming, diagnostics, and markers`,{action:_(wt),message:p(),restart:g()}),hl=B(cl,`Read the daemon-owned session event timeline as paged JSON-friendly entries`,{limit:h(),cursor:p()}),gl=B(ll,`Dump recent HTTP(s) traffic parsed from the session app log`,{action:_(dl),limit:h(),include:_(n)}),_l=B(ul,`Measure browser or host-rendered simulator/emulator audio as compact dBFS buckets. Start a probe before requesting its status or stopping it.`,{action:_(fl),probeAction:_(pl),durationMs:h(`Probe duration in milliseconds.`),bucketMs:h(`Audio level bucket size in milliseconds.`)}),vl=I(ml,(e,t)=>e.observability.logs(t)),yl=I(hl,(e,t)=>e.observability.events(t)),bl=I(gl,(e,t)=>e.observability.network(t)),xl=I(_l,(e,t)=>e.observability.audio(t)),Sl=P({name:`observability`,commands:[N({name:sl,text:{summary:`Manage session app logs`},metadata:ml,definition:vl,cliSchema:{usageOverride:`logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]`,positionalArgs:[`path|start|stop|clear|doctor|mark`,`message?`],allowsExtraPositionals:!0,allowedFlags:[`restart`]},cliReader:(e,t)=>({...T(t),action:Dl(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:C(sl,e=>Cl(e)),cliOutputFormatter:Ic.logs}),N({name:cl,text:{summary:`Read session event timeline`},metadata:hl,definition:yl,cliSchema:{usageOverride:`events [limit] [cursor]`,listUsageOverride:`events`,positionalArgs:[`limit?`,`cursor?`]},cliReader:(e,t)=>({...T(t),limit:e[0]?.trim()?O(e[0]):void 0,cursor:e[1]}),daemonWriter:e=>w(cl,wl(e),e),cliOutputFormatter:Ic.events}),N({name:ll,text:{summary:`Inspect HTTP(S) traffic from session logs`},metadata:gl,definition:bl,cliSchema:{usageOverride:`network dump [limit] [summary|headers|body|all] [--include summary|headers|body|all] | network log [limit] [summary|headers|body|all] [--include summary|headers|body|all]`,listUsageOverride:`network`,positionalArgs:[`dump|log`,`limit?`,`include?`],allowedFlags:[`networkInclude`]},cliReader:(e,t)=>({...T(t),action:Ol(e[0]),limit:O(e[1]),include:t.networkInclude??kl(e[2])}),daemonWriter:e=>w(ll,Tl(e),{...e,networkInclude:e.include}),cliOutputFormatter:Ic.network}),N({name:ul,text:{summary:`Probe audio levels`},metadata:_l,definition:xl,cliSchema:{usageOverride:`audio probe start [durationSeconds] [bucketMs] | audio probe status | audio probe stop`,listUsageOverride:`audio`,positionalArgs:[`probe`,`start|status|stop`,`durationSeconds?`,`bucketMs?`]},cliReader:(e,t)=>({...T(t),action:Al(e[0]),probeAction:jl(e[1]),durationMs:Ml(e[2]),bucketMs:O(e[3])}),daemonWriter:e=>w(ul,El(e),e),cliOutputFormatter:Ic.audio})]});function Cl(e){return[e.action??`path`,...k(e.message)]}function wl(e){return e.cursor===void 0?A(e.limit):[e.limit===void 0?``:String(e.limit),e.cursor]}function Tl(e){return[...e.action?[e.action]:[],...A(e.limit)]}function El(e){return[e.action??`probe`,e.probeAction??`status`,...A(e.durationMs),...A(e.bucketMs)]}function Dl(e){if(e!==void 0)return Ac(wt,e,{message:`logs requires path, start, stop, doctor, mark, or clear`})}function Ol(t){if(t!==void 0){if(t===`dump`||t===`log`)return t;throw new e(`INVALID_ARGS`,`network requires dump or log`)}}function kl(e){if(e!==void 0)return Ac(n,e,{message:`network include must be summary, headers, body, or all`})}function Al(e){if(e!==void 0)return Ac(fl,e,{message:`audio requires probe`})}function jl(e){if(e!==void 0)return Ac(pl,e,{message:`audio probe requires start, status, or stop`})}function Ml(e){let t=O(e);return t===void 0?void 0:Math.round(t*1e3)}function Nl(e){let t=e;return{data:t,text:Fl(t)}}const Pl={perf:L(Nl)};function Fl(e){return Yl(e)??Il(e)}function Il(e){let t=l(e.artifact)?e.artifact:void 0;return t?Jl(t):Ll(e,l(e.metrics)?e.metrics:void 0)}function Ll(e,t){return zl(e)&&l(t?.fps)&&l(t?.memory)?Bl(e,t):Rl(t)}function Rl(e){return l(e?.fps)?Kl(e):Gl(e)??`Memory: unavailable - missing memory metric`}function zl(e){return Array.isArray(e.warnings)&&e.warnings.some(e=>typeof e==`string`&&e.includes(`deprecated compatibility forms`))}function Bl(e,t){let n=Array.isArray(e.warnings)?e.warnings.find(e=>typeof e==`string`):void 0,r=Vl(t);return n?`${r}\nDeprecated: ${n}`:r}function Vl(e){let t=l(e.fps)?e.fps:void 0,n=Hl(e);if(!t)return Ul(n,`missing frame metric`);if(t.available===!1)return Ul(n,ou(t));let r=su(t);return r?ql(t,r):Ul(n,`missing dropped-frame summary`)}function Hl(e){let t=[Wl(l(e.cpu)?e.cpu:void 0),fu(l(e.memory)?e.memory:void 0)].filter(e=>!!e);return t.length>0?t.join(`, `):void 0}function Ul(e,t){return e?`Performance: ${e}`:au(t)}function Wl(e){if(e?.available!==!0)return;let t=Q(e.usagePercent);return t===void 0?void 0:`CPU ${pu(t)}`}function Gl(e){let t=l(e?.memory)?e.memory:void 0;if(!t)return;if(t.available===!1)return`Memory: unavailable - ${ou(t)}`;let n=fu(t);return n?`Performance: ${n}`:`Memory: unavailable - missing memory metric`}function Kl(e){let t=l(e?.fps)?e.fps:void 0;if(!t)return au(`missing frame metric`);if(t.available===!1)return au(ou(t));let n=su(t);return n?ql(t,n):au(`missing dropped-frame summary`)}function ql(e,t){let n=[`Frame health: ${t}`],r=uu(e);return r.length>0&&n.push(`Worst windows:`,...r),n.join(`
|
|
22
|
+
`)}function Jl(e){let t=typeof e.kind==`string`?e.kind:`memory`;if(e.available===!1)return`Memory artifact (${t}): unavailable - ${typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}`;let n=typeof e.path==`string`?e.path:void 0,r=Q(e.sizeBytes),i=r===void 0?``:` (${gu(r)})`;return n?`Memory artifact (${t}): ${n}${i}`:`Memory artifact (${t}): captured${i}`}function Yl(e){return e.kind===`xctrace`?Xl(e):eu(e)}function Xl(e){let t=typeof e.perf==`string`?e.perf:void 0,n=Ql(e);if(!t||!n||e.kind!==`xctrace`)return;let r=$l(n,typeof e.mode==`string`?e.mode:`capture`,t,e.template),i=Zl(e);return i.length>0?`${r}\nTop CPU self time:\n${i.join(`
|
|
23
|
+
`)}`:r}function Zl(e){let t=l(e.summary)?e.summary:void 0;return Array.isArray(t?.topFunctions)?t.topFunctions.slice(0,5).flatMap(e=>{if(!l(e))return[];let t=Z(e.symbol),n=Q(e.selfSamplePercent);if(!t||n===void 0)return[];let r=Z(e.binary);return[`- ${pu(n)} ${t}${r?` (${r})`:``}`]}):[]}function Ql(e){return typeof e.outPath==`string`?e.outPath:typeof e.reportPath==`string`?e.reportPath:void 0}function $l(e,t,n,r){let i=[e,`Perf ${t}: ${n}`];return typeof r==`string`&&i.push(`Template: ${r}`),i.join(`
|
|
24
|
+
`)}function eu(e){let t=tu(e);if(!t)return;let n=`Perf ${t.action}: ${t.kind} ${t.type}${nu(e)}${ru(e)}${iu(e)}`,r=Zl(e);return r.length>0?`${n}\nTop CPU self time:\n${r.join(`
|
|
25
|
+
`)}`:n}function tu(e){let t=Z(e.action),n=Z(e.kind),r=Z(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function nu(e){let t=Z(e.state);return t?` state=${t}`:``}function ru(e){let t=Z(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${gu(n)})`}`}function Z(e){return typeof e==`string`?e:void 0}function iu(e){let t=l(e.summary)?e.summary:void 0,n=l(t?.frameHealth)?t.frameHealth:void 0;if(!n||n.available!==!0)return``;let r=Q(n.droppedFramePercent),i=Q(n.droppedFrameCount),a=Q(n.totalFrameCount);return r===void 0||i===void 0||a===void 0?``:`\nTrace frame health: dropped ${pu(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function au(e){return`Frame health: unavailable - ${e}`}function ou(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function su(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(!(t===void 0||n===void 0))return[`dropped ${pu(t)}`,cu(n,Q(e.totalFrameCount)),lu(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function cu(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function lu(e){return e===void 0?``:`window ${mu(e)}`}function uu(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!l(e))return[];let t=du(e);return t?[t]:[]}):[]}function du(e){let t=Q(e.startOffsetMs),n=Q(e.endOffsetMs),r=Q(e.missedDeadlineFrameCount);if(t===void 0||n===void 0||r===void 0)return;let i=Q(e.worstFrameMs),a=i===void 0?``:`, worst ${mu(i)}`;return`- +${mu(t)}-+${mu(n)}: ${Math.round(r)} missed-deadline frames${a}`}function fu(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${hu(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function pu(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function mu(e){let t=Math.max(0,Math.round(e));if(t<1e3)return`${t}ms`;let n=Math.round(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60),i=n%60;return i>0?`${r}m ${i}s`:`${r}m`}function hu(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function gu(e){if(e<1024)return`${Math.round(e)}B`;let t=e/1024;if(t<1024)return`${t>=10?Math.round(t):t.toFixed(1)}KB`;let n=t/1024;return`${n>=10?Math.round(n):n.toFixed(1)}MB`}const _u=`perf`,vu=B(_u,`Collect frame health, memory diagnostics, and platform profiling artifacts with compact agent-readable summaries.`,{area:_(Tt),subject:_(Et),action:_(Ot),kind:_(kt),template:p(`xctrace template name, for example Time Profiler.`),out:p(`Output artifact path.`),tracePath:p(`Existing .trace path to report, defaults to the latest session trace.`)}),yu=P({name:`perf`,commands:[N({name:_u,text:{summary:`Check frames, memory, or native profiles`,cliDetail:`Use perf frames for bounded frame-health evidence and perf memory sample for a compact process-memory reading. Apple xctrace and Android Simpleperf/Perfetto captures keep raw artifacts on disk; report produces bounded agent-readable evidence. For React render internals, use agent-device react-devtools.`,mcpDetail:`For CPU profiles, start and stop write the raw artifact while report writes a compact summary; request the report when the task needs readable native CPU evidence. Profiling output is evidence only: compact state, artifact path, and size.`},metadata:vu,definition:I(vu,(e,t)=>e.observability.perf(t)),cliSchema:{usageOverride:`perf frames --json
|
|
25
26
|
agent-device perf memory sample --json
|
|
26
27
|
agent-device perf memory snapshot [--kind android-hprof|memgraph] [--out <path>]
|
|
27
28
|
agent-device perf cpu profile start --kind xctrace [--template <name>] --out <profile.trace>
|
|
@@ -31,9 +32,11 @@ import{_ as e,n as t,t as n}from"./sdk-contracts.js";import{$ as r,C as i,Dt as
|
|
|
31
32
|
agent-device perf cpu profile start --kind simpleperf --out <cpu.perf.data>
|
|
32
33
|
agent-device perf cpu profile stop --kind simpleperf
|
|
33
34
|
agent-device perf cpu profile report --kind simpleperf --out <cpu-report.json>
|
|
34
|
-
agent-device perf trace start|stop --kind perfetto [--out <path>]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`)}}
|
|
35
|
+
agent-device perf trace start|stop --kind perfetto [--out <path>]
|
|
36
|
+
|
|
37
|
+
Deprecated compatibility: perf, perf sample, perf metrics, and metrics return aggregate evidence. Prefer an explicit area.`,listUsageOverride:`perf`,positionalArgs:[`area?`,`subjectOrAction?`,`action?`],allowedFlags:[`kind`,`perfTemplate`,`out`]},cliReader:(e,t)=>({...T(t),...Su(e,{kind:Du(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:C(_u,e=>bu(e)),cliOutputFormatter:Pl.perf})]});function bu(e){let t=e.area??(e.action?`metrics`:void 0);return t===`cpu`?xu([...k(t),...k(e.subject),...k(e.action),...k(e.kind)],e):t===`trace`?xu([...k(t),...k(e.action),...k(e.kind)],e):[...k(t),...k(e.action)]}function xu(e,t){let n=[...e];return(t.template||t.out||t.tracePath)&&n.push(t.template??``),(t.out||t.tracePath)&&n.push(t.out??``),t.tracePath&&n.push(t.tracePath),n}function Su(e,t={}){if(e[0]!==void 0&&e[1]===void 0){let n=e[0].toLowerCase();if(Mt(n))return{action:n,kind:Eu(t.kind),out:t.out}}let n=Cu(e[0]);return n===`cpu`?{area:n,subject:Tu(e[1]),action:wu(e[2]),kind:Eu(t.kind),template:t.template,out:t.out}:n===`trace`?{area:n,action:wu(e[1]),kind:Eu(t.kind),template:t.template,out:t.out}:{area:n,action:wu(e[1]),kind:Eu(t.kind),out:t.out}}function Cu(t){let n=t?.toLowerCase();if(n===void 0||St(n))return n;throw new e(`INVALID_ARGS`,At)}function wu(t){if(t===void 0)return;let n=t.toLowerCase();if(Mt(n))return n;throw new e(`INVALID_ARGS`,jt)}function Tu(t){let n=t?.toLowerCase();if(n!==void 0&&Dt(n))return n;throw new e(`INVALID_ARGS`,xt)}function Eu(t){if(t===void 0)return;let n=t.toLowerCase();if(Ct(n))return n;throw new e(`INVALID_ARGS`,bt)}function Du(e){return typeof e==`string`?Eu(e):void 0}const Ou=`react-native`,ku=B(Ou,`Run supported React Native automation helpers. Use dismiss-overlay to close a visible development error overlay before continuing normal UI automation.`,{action:f(_([`dismiss-overlay`]))}),Au=P({name:`react-native`,commands:[N({name:Ou,text:{summary:`Run React Native automation helpers`},metadata:ku,definition:I(ku,(e,t)=>e.command.reactNative(t)),cliSchema:{usageOverride:`react-native dismiss-overlay`,listUsageOverride:`react-native dismiss-overlay`,positionalArgs:[`dismiss-overlay`]},cliReader:(e,t)=>({...T(t),action:ju(e[0])}),daemonWriter:C(Ou,e=>[M(e.action,`react-native requires action`)])})]});function ju(t){if(t===`dismiss-overlay`)return t;throw new e(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}function Mu(e){let t=e,n=typeof t.outPath==`string`?t.outPath:``,r=Fu(t);if(r.length<=1)return{data:t,text:Pu(t,n)};let i=[`Recording chunks:`];for(let e of r)i.push(` ${e.index}: ${e.path}`);return typeof t.telemetryPath==`string`&&i.push(`Telemetry: ${t.telemetryPath}`),typeof t.warning==`string`&&i.push(`Warning: ${t.warning}`),typeof t.overlayWarning==`string`&&i.push(`Overlay warning: ${t.overlayWarning}`),{data:t,text:i.join(`
|
|
38
|
+
`)}}const Nu={record:L(Mu)};function Pu(e,t){let n=[];return t&&n.push(t),typeof e.sessionStateDir==`string`&&n.push(`Session state: ${e.sessionStateDir}`),typeof e.warning==`string`&&n.push(`Warning: ${e.warning}`),typeof e.overlayWarning==`string`&&n.push(`Overlay warning: ${e.overlayWarning}`),n.join(`
|
|
39
|
+
`)}function Fu(e){let t=e.chunks;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.index!=`number`||typeof t.path!=`string`?[]:[{index:t.index,path:t.path}]}):[]}const Iu=`record`,Lu=`trace`,Ru=[`start`,`stop`],zu=B(Iu,`Start or stop a screen recording for the active app session or, where supported, the selected device. Long Android recordings can return multiple video artifacts; HarmonyOS supports whole-screen recording on physical devices.`,{action:f(_(Ru)),path:p(),fps:h(),maxSize:on(s.migration.record),quality:_(Qe),hideTouches:g(),recordingScope:_(Me)}),Bu=B(Lu,`Start or stop trace-log capture and return the resulting artifact when capture ends. Use the same artifact path for the matching start and stop requests when an explicit path is required.`,{action:f(_(Ru)),path:p()}),Vu=I(zu,(e,t)=>e.recording.record(t)),Hu=I(Bu,(e,t)=>e.recording.trace(t)),Uu={usageOverride:`record start [path] [--scope <app|device|system>] [--fps <n>] [--quality <medium|high>] [--hide-touches] | record stop`,listUsageOverride:`record start [path] | record stop`,positionalArgs:[`start|stop`,`path?`],allowedFlags:[`recordingScope`,`fps`,`quality`,`hideTouches`]},Wu={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,positionalArgs:[`start|stop`,`path?`]},Gu=(e,t)=>({...T(t),action:Qu(e[0],Iu),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),Ku=(e,t)=>({...T(t),action:Qu(e[0],Lu),path:e[1]}),qu=C(Iu,e=>Zu(e)),Ju=e=>(a(`record`,e),qu(e)),Yu=C(Lu,e=>Zu(e)),Xu=P({name:`recording`,commands:[N({name:Iu,text:{summary:`Start or stop screen recording`,cliDetail:`The default --scope app requires an active app session from open <app>; use --scope device/system to explicitly request whole-screen recording where the selected backend supports it. Android record start publishes a durable device manifest, recordings longer than the 180s adb screenrecord limit are returned as multiple MP4 chunks while the daemon stays alive, and daemon-restart recovery uses only manifest-owned chunks. HarmonyOS supports whole-screen recording on physical devices only: use --scope device/system; --fps, --quality, and --hide-touches are unsupported. Use --quality to choose medium or high export quality on supported backends.`},metadata:zu,definition:Vu,cliSchema:Uu,cliReader:Gu,daemonWriter:Ju,cliOutputFormatter:Nu.record}),N({name:Lu,text:{summary:`Start or stop trace capture`,cliDetail:`Pass that path as the same positional argument to start and stop.`},metadata:Bu,definition:Hu,cliSchema:Wu,cliReader:Ku,daemonWriter:Yu})]});function Zu(e){return[e.action,...k(e.path)]}function Qu(t,n){if(t===`start`||t===`stop`)return t;throw new e(`INVALID_ARGS`,`${n} requires start|stop`)}const $u=`replay`,ed=`test`,td=B($u,`Run a recorded automation script, including compatible Maestro YAML flows. A script without a terminal close leaves its session active for subsequent automation.`,{path:f(p()),update:g(),backend:p(),maestro:g(),env:cn(),metroHost:p(`Metro/debug host hint inherited by replay-opened sessions.`),metroPort:h(`Metro/debug port hint inherited by replay-opened sessions.`),bundleUrl:p(`Bundle URL hint inherited by replay-opened sessions.`),resumeFrom:h(),resumePlanDigest:p(),keepSession:g(`Leave the session active by suppressing exactly an authored terminal close in native .ad.`),timeoutMs:h(`Maximum wall-clock duration for the replay request.`),saveScript:v({oneOf:[nn(),d()]}),force:g()}),nd=B(ed,`Run one or more replay scripts as a serial test suite`,{paths:f(cn()),update:g(),backend:p(),maestro:g(),env:cn(),metroHost:p(`Metro/debug host hint inherited by each test session.`),metroPort:h(`Metro/debug port hint inherited by each test session.`),bundleUrl:p(`Bundle URL hint inherited by each test session.`),failFast:g(),timeoutMs:h(),retries:h(),recordVideo:g(),artifactsDir:p(),shardAll:h(),shardSplit:h()}),rd=I(td,(e,t)=>e.replay.run(Po(t))),id=I(nd,(e,t)=>e.replay.test(Po(t))),ad={usageOverride:`replay <path> | replay export <file.ad> [--out <path>]`,positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Kr,...Ur,`replayFrom`,`replayPlanDigest`,`replayKeepSession`,`timeoutMs`,`out`,`saveScript`,`force`],flagDescriptionOverrides:{saveScript:`Arm a repair transaction from this replay (ADR 0012): recording starts at step 1, and the healed script commits when the repair-armed session tears down (close, close --save-script, or idle-reap). Independent of the open/close authoring arm-on-open. Optional custom output path.`}},od={usageOverride:`test <path-or-glob>...`,listUsageOverride:`test <path-or-glob>...`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Kr,...Ur,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`]},sd=P({name:`replay`,commands:[N({name:$u,text:{summary:`Replay a recorded session or Maestro flow`,cliDetail:`For Maestro YAML compatibility flows, use replay <flow.yaml> --maestro and keep the target binding such as --platform ios on the replay command. A script with no terminal close leaves its session (and daemon) running until you close it or it idle-reaps — no different from a session opened interactively. For native .ad scripts, --keep-session suppresses exactly an authored terminal close so you can continue interactively.`},metadata:td,definition:rd,cliSchema:ad,cliReader:(e,t)=>({...T(t),path:j(e[0],`replay requires path`),update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,resumeFrom:t.replayFrom,resumePlanDigest:t.replayPlanDigest,keepSession:t.replayKeepSession,timeoutMs:t.timeoutMs,saveScript:t.saveScript,force:t.force}),daemonWriter:e=>w($u,[M(e.path,`replay requires path`)],{...e,replayUpdate:e.update,replayBackend:cd(e),replayEnv:e.env,replayShellEnv:ud(process.env),replayFrom:e.resumeFrom,replayPlanDigest:e.resumePlanDigest,replayKeepSession:e.keepSession,saveScript:e.saveScript})}),N({name:ed,text:{summary:`Run replay test suites`},metadata:nd,definition:id,cliSchema:od,cliReader:(e,t)=>({...T(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,shardAll:t.shardAll,shardSplit:t.shardSplit}),daemonWriter:e=>w(ed,e.paths??[],{...ld(e),replayUpdate:e.update,replayBackend:cd(e),replayEnv:e.env,replayShellEnv:ud(process.env)})})]});function cd(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function ld(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function ud(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}function dd(e){return e}const fd={back:dd({clientMethod:`back`,outputSchema:{type:`object`,properties:{action:{type:`string`,const:`back`},mode:{type:`string`,enum:nt},message:{type:`string`}},required:[`action`,`mode`,`message`]}}),home:dd({clientMethod:`home`,outputSchema:{type:`object`,properties:{action:{type:`string`,const:`home`},message:{type:`string`}},required:[`action`,`message`]}}),orientation:dd({clientMethod:`orientation`,outputSchema:{type:`object`,properties:{action:{type:`string`,const:`orientation`},orientation:{type:`string`,enum:It},message:{type:`string`}},required:[`action`,`orientation`,`message`]}}),"app-switcher":dd({clientMethod:`appSwitcher`,outputSchema:{type:`object`,properties:{action:{type:`string`,const:`app-switcher`},message:{type:`string`}},required:[`action`,`message`]}}),"tv-remote":dd({clientMethod:`tvRemote`,outputSchema:{type:`object`,properties:{action:{type:`string`,const:`tv-remote`},button:{type:`string`,enum:ft},durationMs:{type:`number`},message:{type:`string`}},required:[`action`,`button`,`message`]}})};function pd(e){return{data:e,text:gd(e)}}function md(e){if(e.platform===`android`&&e.action===`status`){let t=[`Keyboard visible: ${e.visible===!0?`yes`:`no`}`,`Input type: ${e.type??e.inputType??`unknown`}`,`Input owner: ${e.inputOwner??`unknown`}`];return e.inputMethodPackage&&t.push(`Input method: ${e.inputMethodPackage}`),e.focusedPackage&&t.push(`Focused package: ${e.focusedPackage}`),e.focusedResourceId&&t.push(`Focused resource: ${e.focusedResourceId}`),t.push(`Next action: ${_d(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
|
|
40
|
+
`)}}return z(e)}function hd(e){return e.action===`read`?{data:e,text:e.text}:z(e)}const $={appstate:L(pd),back:ga,home:R,orientation:R,"app-switcher":R,keyboard:L(md),clipboard:L(hd),"tv-remote":R};function gd(e){if(e.platform===`ios`){let t=[`Foreground app: ${e.appName??e.appBundleId??`unknown`}`];return e.appBundleId&&t.push(`Bundle: ${e.appBundleId}`),e.source&&t.push(`Source: ${e.source}`),t.join(`
|
|
38
41
|
`)}if(e.platform===`android`){let t=[`Foreground app: ${e.package??`unknown`}`];return e.activity&&t.push(`Activity: ${e.activity}`),t.join(`
|
|
39
|
-
`)}return null}function
|
|
42
|
+
`)}return null}function _d(e,t){return t===`ime`?`Focused input appears to be owned by the keyboard/IME; dismiss or change the IME before retrying text entry.`:e===!0?`Keyboard is visible and focused input appears app-owned; fill/type can proceed.`:`Keyboard is hidden; focus an app field before type, or use fill with a concrete target.`}const vd=`appstate`,yd=`back`,bd=`home`,xd=`orientation`,Sd=`app-switcher`,Cd=`keyboard`,wd=`clipboard`,Td=`tv-remote`,Ed=[`read`,`write`],Dd=[`status`,`dismiss`,`enter`,`return`],Od=B(vd,`Show foreground app/activity`,{}),kd=B(yd,`Navigate back in the app or through system navigation. Use in-app for the app navigation stack and system when the platform back behavior is required.`,{mode:_(nt),...U(yd)}),Ad=B(bd,`Send the selected device to its home screen. This leaves the app session open but moves the foreground away from the app.`,{}),jd=B(xd,`Set device orientation on iOS and Android`,{orientation:f(_(It))}),Md=B(Sd,`Open the device app switcher to inspect or change foreground apps. This changes the visible system UI and may move focus away from the current app.`,{}),Nd=B(Cd,`Inspect Android keyboard visibility/type or press/dismiss the device keyboard. To hide the keyboard, use keyboard dismiss. It taps the keyboard dismiss/hide key when one is exposed, verifies the keyboard closed, and reports UNSUPPORTED_OPERATION when no dismiss key exists — background taps are never attempted.`,{action:_(Dd)}),Pd=B(wd,`Read the current device clipboard text, or replace its contents with the given text.`,{action:f(_(Ed)),text:p()}),Fd=B(Td,`Press or long-press a TV remote or D-pad button on Android TV, tvOS, or Vega OS. Choose the button and optional hold duration through the input fields. The aliases ok, center, and enter all map to select.`,{button:f(_(ft)),durationMs:h(`Press duration in milliseconds. tvOS and Vega OS use the exact hold duration; Android TV maps any positive value to an ADB longpress (${st(`android`)}).`,{min:0})}),Id=I(Od,(e,t)=>e.command.appState(t)),Ld=I(kd,(e,t)=>e.command.back(t),fd.back),Rd=I(Ad,(e,t)=>e.command.home(t),fd.home),zd=I(jd,(e,t)=>e.command.orientation(t),fd.orientation),Bd=I(Md,(e,t)=>e.command.appSwitcher(t),fd[`app-switcher`]),Vd=I(Nd,(e,t)=>e.command.keyboard(t)),Hd=I(Pd,(e,t)=>e.command.clipboard(t)),Ud=I(Fd,(e,t)=>e.command.tvRemote(t),fd[`tv-remote`]),Wd={},Gd={usageOverride:`back [--in-app|--system] [--settle]`,allowedFlags:[`backMode`,...Ui(yd)]},Kd={},qd={},Jd={usageOverride:`orientation <portrait|portrait-upside-down|landscape-left|landscape-right>`,positionalArgs:[`orientation`]},Yd={usageOverride:`keyboard [status|get|dismiss|enter|return]`,positionalArgs:[`action?`]},Xd={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},Zd={usageOverride:`tv-remote [press|longpress] ${mt} [--duration-ms <ms>]`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},Qd=(e,t)=>T(t),$d=(e,t)=>T(t),ef=(e,t)=>T(t),tf=(e,t)=>({...T(t),...Yn(t),mode:t.backMode}),nf=(e,t)=>({...T(t),orientation:Nt(e[0])}),rf=(e,t)=>({...T(t),...yf(e)}),af=(e,t)=>({...T(t),...bf(e)}),of=(e,t)=>({...T(t),...xf(e,t.durationMs)}),sf=C(vd),cf=e=>w(yd,[],{...e,backMode:_f(e.mode)}),lf=C(bd),uf=C(xd,e=>[M(e.orientation,`orientation requires orientation`)]),df=C(Sd),ff=C(Cd,e=>k(e.action)),pf=C(wd,e=>vf(e)),mf=C(Td,e=>[M(e.button,`tv-remote requires button`)]),hf=P({name:`system`,commands:[N({name:vd,text:{summary:`Show the foreground app and activity`},metadata:Od,definition:Id,clientMethod:`appState`,cliSchema:Wd,cliReader:Qd,daemonWriter:sf,cliOutputFormatter:$.appstate}),N({name:yd,text:{summary:`Navigate back in the app or system`},metadata:kd,definition:Ld,cliSchema:Gd,cliReader:tf,daemonWriter:cf,cliOutputFormatter:$.back}),N({name:bd,text:{summary:`Go to the device home screen`},metadata:Ad,definition:Rd,cliSchema:Kd,cliReader:$d,daemonWriter:lf,cliOutputFormatter:$.home}),N({name:xd,text:{summary:`Set device orientation`},metadata:jd,definition:zd,cliSchema:Jd,cliReader:nf,daemonWriter:uf,cliOutputFormatter:$.orientation}),N({name:Sd,text:{summary:`Open the device app switcher`},metadata:Md,definition:Bd,cliSchema:qd,cliReader:ef,daemonWriter:df,cliOutputFormatter:$[`app-switcher`]}),N({name:Cd,text:{summary:`Inspect, press, or dismiss the device keyboard`},metadata:Nd,definition:Vd,clientMethod:`keyboard`,cliSchema:Yd,cliReader:rf,daemonWriter:ff,cliOutputFormatter:$.keyboard}),N({name:wd,text:{summary:`Read or write device clipboard text`},metadata:Pd,definition:Hd,clientMethod:`clipboard`,cliSchema:Xd,cliReader:af,daemonWriter:pf,cliOutputFormatter:$.clipboard}),N({name:Td,text:{summary:`Press a TV remote/D-pad button`,cliDetail:`longpress holds for 500ms by default; --duration-ms overrides the preset.`},metadata:Fd,definition:Ud,cliSchema:Zd,cliReader:of,daemonWriter:mf,cliOutputFormatter:$[`tv-remote`]})]}),gf=mr(hf.definitions);function _f(e){return e===`in-app`||e===`system`?e:void 0}function vf(e){return e.action===`read`?[`read`]:[`write`,e.text]}function yf(t){if(t.length>1)throw new e(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return x({action:Sf(t[0])})}function bf(t){let n=t[0]?.toLowerCase();if(n!==`read`&&n!==`write`)throw new e(`INVALID_ARGS`,`clipboard requires a subcommand: read or write.`);if(n===`read`){if(t.length!==1)throw new e(`INVALID_ARGS`,`clipboard read does not accept additional arguments.`);return{action:n}}if(t.length<2)throw new e(`INVALID_ARGS`,`clipboard write requires text.`);return{action:n,text:t.slice(1).join(` `)}}function xf(t,n){let r=t[0]?.toLowerCase(),i=r===`press`||r===`longpress`?t.slice(1):t;if(i.length!==1)throw new e(`INVALID_ARGS`,`tv-remote requires exactly one button: ${ft.join(`, `)}.`);let a=n??(r===`longpress`?500:void 0);return x({button:ct(i[0]),durationMs:a})}function Sf(t){let n=t?.toLowerCase();if(n===`get`)return`status`;if(n===void 0||n===`status`||n===`dismiss`||n===`enter`||n===`return`)return n;throw new e(`INVALID_ARGS`,`keyboard action must be status, get, dismiss, enter, or return.`)}const Cf=[Za,bc,Ni,hf,Au,sd,Sl,yu,zi,Xu,Tc,Nr];function wf(){return Cf.flatMap(e=>[...e.metadata])}function Tf(){return Cf.flatMap(e=>[...e.definitions])}function Ef(){return Af(`cliSchemas`)}function Df(){return Af(`cliReaders`)}function Of(){return Af(`daemonWriters`)}function kf(){return Af(`cliOutputFormatters`)}function Af(e){let t={};for(let n of Cf){let r=n[e];if(r)for(let[n,i]of Object.entries(r)){if(Object.hasOwn(t,n))throw Error(`Duplicate ${String(e)} command family entry: ${n}`);t[n]=i}}return t}export{Wt as S,an as _,Tf as a,Jt as b,hf as c,Jr as d,Hr as f,nn as g,dr as h,Of as i,ws as l,ur as m,Df as n,wf as o,Or as p,Ef as r,gf as s,kf as t,qr as u,d as v,Ut as x,qt as y};
|