agent-device 0.21.8 → 0.21.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/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.8.apk → agent-device-android-ime-helper-0.21.9.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.9.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.8.manifest.json → agent-device-android-ime-helper-0.21.9.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.8.apk → agent-device-android-snapshot-helper-0.21.9.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.9.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.8.manifest.json → agent-device-android-snapshot-helper-0.21.9.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +65 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +45 -140
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +57 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +108 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +65 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +175 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +42 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +45 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +39 -734
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +20 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +63 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +13 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +25 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +5 -562
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +566 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +5 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +594 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +35 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +160 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +3 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-frames.swift +203 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +5 -0
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-device-client.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/artifact-paths.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +8 -7
- package/dist/src/cli.js +4 -4
- package/dist/src/client-types.d.ts +23 -5
- package/dist/src/command-tools.js +3 -3
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +2 -2
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/fold-runtime.js +1 -0
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-catalog.js +1 -1
- package/dist/src/interactor.js +4 -4
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +17 -17
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/mp4-duration.js +1 -0
- package/dist/src/multitouch-support.js +1 -1
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +2 -2
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +2 -2
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-crop-bytes.js +1 -1
- package/dist/src/png-encode.js +1 -0
- package/dist/src/png-size.js +1 -0
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/quality-warnings.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/recording-export-quality.js +1 -1
- package/dist/src/recording-scope.js +1 -0
- package/dist/src/recording.js +3 -0
- package/dist/src/registry.js +35 -35
- package/dist/src/replay.js +2 -2
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-contract.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-presentation.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime10.js +2 -1
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime4.js +5 -5
- 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 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-overlay-draw.js +1 -0
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +7 -5
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +44 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session2.js +3 -3
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/stop-sequence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.8.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.8.apk.sha256 +0 -1
package/dist/src/registry.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import{D as e,E as t,S as n,p as r,t as i,x as a,y as o}from"./sdk-contracts.js";import{d as s,f as c,i as ee,l as te,n as ne,p as re,t as ie,u as ae}from"./capture.js";import{O as oe,c as se,d as ce,f as le,g as l,l as ue,o as de,p as fe,s as pe,u as me}from"./sdk-batch-runner.js";import{t as he}from"./viewport.js";import{r as ge,t as _e}from"./sdk-device.js";import{i as ve,s as ye}from"./lease-scope.js";import{Ar as be,Dn as xe,Fr as Se,Kr as Ce,Nn as we,br as Te,cr as Ee,fr as De,i as Oe,in as ke,kn as Ae,lr as je,m as Me,mr as Ne,on as Pe,p as Fe,s as Ie,sr as Le}from"./sdk-batch.js";import{n as Re}from"./recording-export-quality.js";import{i as ze,r as Be,s as Ve,t as He}from"./back-mode.js";import{a as Ue,n as We,o as Ge,r as Ke,s as qe}from"./scroll-gesture.js";import{E as Je,T as Ye,b as Xe,v as Ze,w as Qe}from"./script.js";import{c as $e,n as et,o as tt,r as nt,s as rt,t as it}from"./format.js";import{n as u,t as at}from"./catalog.js";import{a as ot}from"./sdk-remote-config.js";import{t as st}from"./session.js";import{a as ct,c as lt,d as ut,f as dt,g as ft,h as pt,i as mt,l as ht,n as gt,o as _t,p as vt,s as yt,t as bt,u as xt}from"./observability.js";import{n as St,t as Ct}from"./success-text.js";import{a as d,i as wt,n as f,r as p}from"./output-common.js";import{t as Tt}from"./alert-contract.js";import{a as Et,c as Dt,i as Ot,l as kt,o as At,r as jt,t as Mt}from"./location-coordinates.js";import{t as Nt}from"./snapshot-quality-backend-capabilities.js";import{a as Pt,d as Ft,f as It,l as Lt,t as Rt,u as zt}from"./absence-observation-errors.js";import{t as Bt}from"./mobile-snapshot-semantics.js";import{t as Vt}from"./click-button.js";import{n as Ht}from"./scroll-command.js";import{n as Ut,t as Wt}from"./interaction-positionals.js";import{t as Gt}from"./app-inventory.js";import"./device.js";import{c as Kt,i as qt,l as Jt,r as Yt,t as Xt}from"./device-rotation.js";import"./app-inventory-contract.js";import{t as Zt}from"./prepare-kind.js";import{n as Qt,t as $t}from"./path-resolution.js";import"./file.js";import{n as en,r as tn,s as nn,t as rn}from"./tv-remote.js";import m from"node:path";import h from"node:fs";const an=[`path`,`start`,`stop`,`doctor`,`mark`,`clear`],on=new Set(Be().map(e=>e.key));function sn(e){let t=ve(e);return oe({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...ye(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,providerAppiumVersion:e.providerAppiumVersion,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,...a(e,r),...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,until:e.until,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,replayScriptSource:e.replayScriptSource,replayScriptSources:e.replayScriptSources,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 cn(e,t){return{...sn(e),...t}}function ln(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!on.has(e))continue;let t=i[e];un(t)&&(r[e]=t)}return r}function un(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function dn(e){return{kind:`operator`,source:e}}function fn(e,t){return`${e} is not accepted as a tool argument. ${pn(e,t)}`}function pn(e,t){if(`operatorPath`in t)return t.operatorPath;let n=`for the process serving these tools.`,r=(t.envFlagKeys??[e]).map(ot).join(` or `);return r===``?`Set ${e} in ~/.agent-device/config.json ${n}`:`Set the ${r} environment variable${t.operatorConfig?` (or ${e} in ~/.agent-device/config.json)`:``} ${n}`}function mn(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}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 gn(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 _n(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`string`)throw new e(`INVALID_ARGS`,`Expected ${n} to be a string.`);return r}}function g(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 vn(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 yn(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 bn(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 xn(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 Sn(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 Cn(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 wn(t,n,r,i){let a=new Set(n),o=Object.keys(t).filter(e=>!a.has(e));if(o.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${o.join(`, `)}.`,i===void 0?void 0:{hint:i})}function _(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}const Tn=dn({operatorConfig:!0}),En={session:{schema:{type:`string`,description:`Agent-device session name.`},read:e=>g(e,`session`),flagKey:`session`,flagIn:[`input`]},platform:{schema:{type:`string`,enum:ge,description:`Platform selector used to resolve a device.`},read:e=>xn(e,`platform`,ge),flagKey:`platform`,flagIn:[`input`,`selection`]},deviceTarget:{schema:{type:`string`,enum:_e,description:`Device target form. Maps to the CLI --target flag.`},read:Mn,clientKey:`target`,flagKey:`target`,flagIn:[`input`,`selection`]},target:{schema:{type:`string`,enum:_e,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`}},device:{schema:{type:`string`,description:`Device name selector (a UDID belongs in udid, a serial in serial).`},read:e=>g(e,`device`),flagKey:`device`,flagIn:[`input`,`selection`]},udid:{schema:{type:`string`,description:`Apple device or simulator UDID; the selector that pins one device when several share a name.`},read:e=>g(e,`udid`),flagKey:`udid`,flagIn:[`input`,`selection`]},serial:{schema:{type:`string`,description:`Android, HarmonyOS, or Vega VVD serial selector.`},read:e=>g(e,`serial`),flagKey:`serial`,flagIn:[`input`,`selection`]},iosSimulatorDeviceSet:{schema:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},read:e=>g(e,`iosSimulatorDeviceSet`),audience:dn({envFlagKeys:[],operatorConfig:!0}),flagKey:`iosSimulatorDeviceSet`,flagIn:[`input`,`selection`]},iosXctestrunFile:{schema:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},read:e=>g(e,`iosXctestrunFile`),audience:Tn,flagKey:`iosXctestrunFile`,flagIn:[`input`]},iosXctestDerivedDataPath:{schema:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},read:e=>g(e,`iosXctestDerivedDataPath`),audience:Tn,flagKey:`iosXctestDerivedDataPath`,flagIn:[`input`]},iosXctestEnvDir:{schema:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},read:e=>g(e,`iosXctestEnvDir`),audience:Tn,flagKey:`iosXctestEnvDir`,flagIn:[`input`]},androidDeviceAllowlist:{schema:{type:`string`,description:`Android serial allowlist used for device resolution.`},read:e=>g(e,`androidDeviceAllowlist`),flagKey:`androidDeviceAllowlist`,flagIn:[`input`,`selection`]},noRecord:{read:e=>yn(e,`noRecord`),flagKey:`noRecord`,flagIn:[`input`,`selection`]},daemonBaseUrl:{schema:{type:`string`,description:`Remote daemon base URL.`},read:e=>g(e,`daemonBaseUrl`),audience:Tn},daemonAuthToken:{schema:{type:`string`,description:`Remote daemon auth token.`},read:e=>g(e,`daemonAuthToken`),audience:Tn},tenant:{schema:{type:`string`,description:`Remote tenant identifier.`},read:e=>g(e,`tenant`)},runId:{schema:{type:`string`,description:`Lease run identifier.`},read:e=>g(e,`runId`)},leaseId:{schema:{type:`string`,description:`Existing lease identifier.`},read:e=>g(e,`leaseId`)},cwd:{schema:{type:`string`,description:`Working directory for command execution.`},read:e=>g(e,`cwd`),audience:dn({operatorPath:`Start the process serving these tools in the desired working directory, or pass absolute paths.`})},debug:{schema:{type:`boolean`,description:`Enable debug diagnostics.`},read:e=>yn(e,`debug`)}},Dn=Object.entries(En),On=Object.fromEntries(Dn.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function kn(){return Object.fromEntries(Dn.flatMap(([e,t])=>t.schema?[[e,t.schema]]:[]))}function An(e,t={}){let n={};for(let[r,i]of Dn)i.read&&(n[r]=i.read(e,t));return n}function v(e){let t={};for(let[n,r]of Dn)r.read&&(t[r.clientKey??n]=e[n]);return _(t)}function jn(e,t){let n={};for(let[r,i]of Dn){if(i.flagIn===void 0||!i.flagIn.includes(t))continue;let a=t===`selection`?i.clientKey??r:r;n[a]=e[i.flagKey]}return n}function Mn(t,n){let r=xn(t,`deviceTarget`,_e);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=xn(t,`target`,_e);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 y(e,t){return n=>b(e,t?t(n):[],n)}function b(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Nn(n)}}function Nn(e){let t=Pn(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 Pn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function x(e){return _(jn(e,`input`))}function Fn(e){return _({record:e.record})}function In(e){return jn(e,`selection`)}function Ln(e){return _({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Rn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function zn(e){return _({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Bn(e){return _({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function Vn(e){if(`ref`in e&&e.ref!==void 0)return _({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 Hn(t){let n=Wn(t);if(typeof n.ref==`string`)return[n.ref,...Kn(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(Gn(n.x,`x`)),String(Gn(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function Un(t){let n=Wn(t);if(typeof n.ref==`string`)return[n.ref,...Kn(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function Wn(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 Gn(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function Kn(e){return typeof e==`string`&&e.length>0?[e]:[]}function qn(t){let n=Ee(t);if(!n.ok)throw new e(n.code,n.message);return`ref`in n?{ref:n.ref,label:Zn(t.slice(1))}:{selector:n.selector}}function Jn(t){let n=je(t);if(!n.ok)throw new e(n.code,n.message);return n.format}function Yn(t,n={}){let r=Te(t,n);if(!r)throw new e(`INVALID_ARGS`,Le);return r}function Xn(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 Zn(e){return e.join(` `).trim()||void 0}function S(...e){return new Set(e)}function C(e,t){return e!==void 0&&t.has(e)}function Qn(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function $n(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 er(e){return e===void 0?void 0:Number(e)}function w(e){return e===void 0?[]:[e]}function T(e){return e===void 0?[]:[String(e)]}function E(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function D(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function tr(e){return ir(e.description,e.cliDetail)}function nr(e){return ir(e.description,e.mcpDetail)}function rr(e,t){return{...e,description:t}}function ir(e,t){return t?`${e} ${t}`:e}function ar(e){return e}const or=[`ref`,`selector`,`point`];function sr(e,t=[]){return{type:`object`,properties:{...kn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function cr(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function lr(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function ur(e){return{type:`string`,...e?{description:e}:{}}}function dr(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function fr(e){return{type:`integer`,...e?{description:e}:{}}}function pr(e){return{type:`boolean`,...e?{description:e}:{}}}function mr(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function hr(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function O(e){return{...e,required:!0}}function k(e,t={}){return I(ur(e),t.allowEmpty===!0?_n:g)}function gr(t){return{schema:{type:`null`},required:!1,audience:{kind:`retired`,message:t},read:(n,r)=>{if(Object.hasOwn(n,r))throw new e(`INVALID_ARGS`,t)}}}function _r(e,t){return{...e,audience:{kind:`operator`,source:t}}}function A(e,t={}){return I(dr(e,t),(e,n)=>fe(e,n,t))}function j(e,t={}){return I(Rr(e,t),(e,n)=>le(e,n,t))}function M(e){return I(pr(e),yn)}function vr(e){return br(yr(e))}function yr(e){let[t,...n]=ze(e).filter(e=>e.inputDescription!==void 0);if(!t)throw Error(`Flag ${e} declares no inputDescription; optionField cannot derive a field`);if(n.length>0)throw Error(`Flag ${e} declares inputDescription more than once`);return t}function br(e){let t=e.inputDescription,n={min:e.min,max:e.max};switch(e.type){case`boolean`:return M(t);case`int`:return j(t,n);case`number`:return A(t,n);case`string`:return k(t);case`enum`:return N(xr(e),t);case`booleanOrString`:throw Error(`Flag ${e.key} is booleanOrString; declare its field shape explicitly with jsonSchemaField`)}}function xr(e){let t=e.enumValues;if(!t)throw Error(`Flag ${e.key} is an enum with no enumValues`);return t}function N(e,t){return I(lr(e,t),(t,n)=>xn(t,n,e))}function Sr(e){return I(hr(e),Sn)}function Cr(e){return I(mr(e),Cn)}function P(e){return I(e,(e,t)=>e[t])}function wr(e,t){return I(e,t)}function Tr(){return I(Hr(),(e,t)=>e[t]===void 0?void 0:jr(e,t))}function Er(){return I(Ur(),(e,t)=>e[t]===void 0?void 0:Mr(e,t))}function Dr(e){return I(cr(e),(e,t)=>e[t]===void 0?void 0:Nr(e,t))}function F(){return{depth:j(`Snapshot traversal depth.`,{min:0}),scope:k(`Snapshot scope selector used before resolution.`),raw:M(`Use raw snapshot data during selector resolution.`)}}function Or(){return{count:j(`Number of press/click repetitions.`,{min:1}),intervalMs:j(`Delay between repeated press/click actions.`,{min:0}),holdMs:j(`Hold duration for each action.`,{min:0}),jitterPx:j(`Randomization radius in pixels.`,{min:0}),doubleTap:M(`Request a double-tap action.`)}}function kr(e){return sr(zr(e),Br(e))}function Ar(t,n){let r=mn(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=An(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return _({...a,...v(a),...i})}function jr(e,t){let n=hn(e,t),r=bn(n,`kind`,or);switch(r){case`ref`:return{kind:r,ref:gn(n,`ref`),label:g(n,`label`)};case`selector`:return{kind:r,selector:gn(n,`selector`)};case`point`:return{kind:r,x:vn(n,`x`),y:vn(n,`y`)}}}function Mr(e,t){let n=hn(e,t),r=bn(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:gn(n,`ref`),label:g(n,`label`)}:{kind:r,selector:gn(n,`selector`)}}function Nr(e,t){let n=hn(e,t);return{x:vn(n,`x`),y:vn(n,`y`)}}function Pr(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 Fr(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function Ir(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function Lr(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function I(e,t){return{schema:e,required:!1,read:t}}function Rr(e,t){return{...fr(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function zr(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.audience?.kind!==`retired`).map(([e,t])=>[e,t.schema]))}function Br(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function Vr(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]))}function Hr(){return{oneOf:[...Wr(),{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 Ur(){return{oneOf:Wr(),description:`UI element target by snapshot ref or selector expression.`}}function Wr(){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 L(e,t,n,r){return ar({name:e,description:t,inputSchema:kr(n),readInput:r?.readInput??(e=>Ar(e,n)),inputAudience:Vr(n),...r?.parseableOutput?{parseableOutput:!0}:{}})}function R(e){let t=rr(e.text,e.metadata.description),n=t.mcpDetail?{mcpDetail:t.mcpDetail}:{},r={...e.metadata,...n},i={name:r.name,description:r.description,inputSchema:r.inputSchema,...n,invoke:async(t,n)=>await e.run(t,r.readInput(n))};return{name:e.name,metadata:r,definition:i,cliSchema:{...e.cliSchema,text:t},cliReader:e.cliReader,daemonWriter:e.daemonWriter,cliOutputFormatter:e.cliOutputFormatter,text:t}}function Gr(e){return R({name:e.name,text:e.text,metadata:L(e.name,e.description,{}),run:e.run,cliSchema:{},cliReader:(e,t)=>x(t),daemonWriter:y(e.name),cliOutputFormatter:e.cliOutputFormatter})}function z(e){let t={},n={},r={},i={};for(let a of e.commands)Kr(t,`CLI schema`,a.name,a.cliSchema),Kr(n,`CLI reader`,a.name,a.cliReader),a.daemonWriter&&Kr(r,`daemon writer`,a.name,a.daemonWriter),a.cliOutputFormatter&&Kr(i,`CLI output formatter`,a.name,a.cliOutputFormatter);return{name:e.name,clientSurface:e.clientSurface,metadata:e.commands.map(e=>e.metadata),definitions:e.commands.map(e=>e.definition),cliSchemas:t,cliReaders:n,daemonWriters:r,cliOutputFormatters:i}}function Kr(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function qr(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
|
|
3
|
-
`)}`}const pi=z({name:`batch`,clientSurface:!1,commands:[R({name:`batch`,text:{summary:`Run multiple commands`,cliDetail:fi()},metadata:ci,run:(e,t)=>e.batch.run(mi(t)),cliSchema:li,cliReader:ui,cliOutputFormatter:Jr.batch})]});function mi(e){return{...v(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}const hi=`alert`,gi=R({name:hi,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:L(hi,`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. Each iOS XCTest execution activates once, then only observes. Inspect again after an unconfirmed action; never assume a timeout means nothing happened.`,{action:N(Tt),timeoutMs:j()}),run:(e,t)=>e.command.alert(t),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...x(t),...vi(e)}),daemonWriter:y(u.alert,e=>_i(e)),cliOutputFormatter:p});function _i(e){return[e.action??`get`,...T(e.timeoutMs)]}function vi(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return _({action:yi(t[0]),timeoutMs:$n(t[1],`alert timeout`)})}function yi(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 B(...e){return e}const bi=B(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),V=B(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),xi=B(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Si=B(`metroHost`,`metroPort`,`bundleUrl`),Ci=B(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),wi=B(`settle`,`settleQuietMs`,`timeoutMs`),Ti=B(`replayUpdate`,`replayEnv`),Ei=B(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`providerDeviceOrientation`,`providerGeoLocation`,`providerTimezone`,`providerAppiumVersion`,`providerLanguage`,`providerLocale`,`providerNetworkProfile`,`providerCustomNetwork`,`providerNoResignApp`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Di=new Set([`platform`,`device`,`udid`,`serial`,`session`]),Oi=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),ki=`diff`,Ai=R({name:ki,text:{summary:`Diff snapshot or screenshot`,cliDetail:`Screenshot --threshold is a per-pixel RGB tolerance: 0 requires exact colors and 1 ignores color differences; image dimensions must still match. Both screenshot inputs are decoded from their bytes, so a baseline or current image may be PNG or JPEG, and the diff image is always PNG. JPEG is lossy, so keep --threshold above 0 whenever either input is JPEG. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`},metadata:L(ki,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:O(P({type:`string`,const:`snapshot`})),out:k(),interactiveOnly:M(),depth:j(),scope:k(),raw:M()}),run:(e,t)=>e.capture.diff(t),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,usageFlags:[],positionalArgs:[`kind`,`current?`],allowedFlags:[...bi,`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{...x(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:y(u.diff,e=>[D(e.kind,`diff requires kind`)])}),ji=`screenshot`,Mi=R({name:ji,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, --crop-on <selector> to crop the capture to the frame the selector resolves on the same screen (currently iOS simulators and Android emulators), --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops.`},metadata:L(ji,`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:k(`Output path.`),cropOn:k(`Selector expression; the capture is cropped to the frame the selector resolves on the same screen.`),overlayRefs:M(),pixelDensity:j(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:M(),scale:A(`Screenshot scale factor.`,ee),maxSize:gr(ie.migration.screenshot),stabilize:M(),normalizeStatusBar:M(),surface:N(st)}),run:(e,t)=>e.capture.screenshot(t),cliSchema:{positionalArgs:[`path?`],allowedFlags:ne},cliReader:(e,t)=>({...x(t),path:e[0]??t.out,...s(t)}),daemonWriter:e=>(c(`screenshot`,e),re(e),b(u.screenshot,w(e.path),{...e,...ae(e)}))}),Ni=`settings`,Pi=L(Ni,`Change supported operating-system settings, animation scales, appearance, or app permissions on the selected target. Platform support varies by setting and action.`,{setting:O(k()),state:O(k()),app:k(),latitude:A(),longitude:A(),permission:k(),mode:N([...At])}),Fi={usageOverride:kt,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state`,`target?`,`mode?`]},Ii=(e,t)=>zi(e,t),Li=y(u.settings,e=>Bi(e)),Ri=R({name:Ni,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings ${Dt}; wifi|airplane|location|animations remain unsupported on macOS. Mobile permission actions use the active session app. On Android, deny|reset of a permission the app currently holds kills a running app; the response reports priorGrantState (granted|not_granted|unknown) and warns for granted and unknown, with open <app> --relaunch to restore it. Permission changes require a resolvable foreground user and fail without mutating if adb cannot report one. Android settings airplane on|off is applied by the connectivity service (Android 11+) and reports the airplaneMode that service holds; older builds fail without changing device state. settings reset-keychain clear is iOS-simulator-only and resets the whole simulator keychain, not just the selected app: simctl exposes no per-app keychain reset, so every app on that simulator loses its keychain-backed credentials (e.g. Firebase auth). clear-app-state does not touch the keychain, so a full fresh-install reset needs both; relaunch the app afterward to observe the signed-out state.`},metadata:Pi,run:(e,t)=>e.settings.update(t),cliSchema:Fi,cliReader:Ii,daemonWriter:Li,cliOutputFormatter:p});function zi(t,n){let r=In(n),i=t[0],a=t[1];if(C(i,Ui)&&C(a,Wi))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:Mt(t[2],`latitude`),longitude:Mt(t[3],`longitude`)};if(i===`appearance`&&C(a,Gi)||C(i,Ki)&&C(a,qi)||i===`fingerprint`&&C(a,Ji))return{...r,setting:i,state:a};if(i===`permission`&&C(a,Xi))return{...r,setting:i,state:a,permission:Vi(t[2]),mode:Hi(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}if(i===`reset-keychain`&&a===`clear`&&t.length===2)return{...r,setting:i,state:a};throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function Bi(e){return e.setting===`clear-app-state`?[e.setting,...w(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,...w(e.mode)]:[e.setting,e.state]}function Vi(t){if(C(t,Zi))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function Hi(t){if(t===void 0||C(t,Yi))return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const Ui=S(`wifi`,`airplane`,`location`,`animations`),Wi=S(`on`,`off`),Gi=S(`light`,`dark`,`toggle`),Ki=S(`faceid`,`touchid`),qi=S(`match`,`nonmatch`,`enroll`,`unenroll`),Ji=S(`match`,`nonmatch`),Yi=S(...At),Xi=S(...Et),Zi=S(...Ot,...jt);function Qi(e){if(!Array.isArray(e)||e.length===0)return e;let t=Se(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 ea(e){return e.width>0&&e.height>0}function ta(e,t){return!e||!t?!1:e.x>=t.x-2&&e.y>=t.y-2&&e.x+e.width<=t.x+t.width+2&&e.y+e.height<=t.y+t.height+2}function na(e,t){if(!e||!t)return!0;let n=e.y+e.height/2,r=t.y+t.height/2;return Math.abs(n-r)<=Math.max(e.height,t.height,1)}function ra(e){return typeof e.parentIndex!=`number`}function ia(e){let t=(e.type??``).toLowerCase(),n=(e.identifier??``).trim().toLowerCase();return t.includes(`edittext`)||t.includes(`textfield`)||n===`composer`}function aa(e){let t=(e.type??``).toLowerCase();return t.includes(`scroll`)||t.includes(`list`)||t.includes(`recyclerview`)}function H(e){let t=be(e);if(!t||t!==e.identifier?.trim()||!sa(t))return t;let n=(e.type??``).toLowerCase();return n.includes(`view`)||n.includes(`layout`)||n.includes(`image`)||n.includes(`list`)||n.includes(`recyclerview`)||n.includes(`collection`)?``:t}function oa(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||/^(true|false|\d+)$/.test(t)?null:t}function sa(e){return/^[\w.]+:id\/[\w.-]+$/i.test(e)}function ca(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=t.get(r.parentIndex);if(!e)return null;if(n(e))return e;r=e}return null}function la(e,t){let n=[],r=[t];for(;r.length>0;){let t=r.pop();for(let i of e)i.parentIndex===t&&(n.push(i),r.push(i.index))}return n}function ua(e,t,n){let r=[t];for(;r.length>0;){let t=r.pop();if(!n.has(t)){n.add(t);for(let i of e)i.parentIndex!==t||n.has(i.index)||r.push(i.index)}}}const da=[`button`,`switch`,`checkbox`,`radio`],fa=[`button`,`image`,`textview`,`view`];function pa(e,t,n){for(let r of e){if(t.has(r.index)||!ga(r))continue;let i=_a(la(e,r.index),r,t);if(i.label){n.set(r.index,{...r,...n.get(r.index),label:i.label});for(let n of i.removableIndexes)ua(e,n,t)}}}function ma(e,t,n){let r=new Map;for(let i of e){if(t.has(i.index)||!Ta(i))continue;let a=oa(H(i));if(!a)continue;let o=r.get(a);if(o&&Sa(o,i,t)){let s=Ca(e,o,i,t,n);r.set(a,s);continue}r.set(a,i)}}function ha(e,t){for(let n of e){if(t.has(n.index)||!ba(n))continue;let r=oa(H(n));if(!r)continue;let i=la(e,n.index).filter(e=>!t.has(e.index)&&xa(n,e,r));for(let n of i.filter(ya))ua(e,n.index,t);let a=i.filter(e=>!ya(e)),o=new Set(a.map(e=>oa(H(e))).filter(e=>!!e));if(!(a.length<2||o.size<2))for(let n of a)ua(e,n.index,t)}}function ga(e){return e.hittable===!0&&!ia(e)&&!!(e.rect&&ea(e.rect))&&H(e).trim().length===0}function _a(e,t,n){let r=[],i=[],a=new Set;for(let o of e){if(n.has(o.index)||!va(o,e)||!ta(o.rect,t.rect))continue;let s=H(o).trim().replaceAll(/\s+/g,` `),c=oa(s);i.push(o.index),!(!s||!c||a.has(c))&&(a.add(c),r.push(s))}return{label:r.join(`, `),removableIndexes:i}}function va(e,t){if(ya(e))return!0;let n=(e.type??``).toLowerCase();return e.hittable!==!0&&!ia(e)&&n.includes(`view`)&&H(e).trim().length>0&&!t.some(t=>t.parentIndex===e.index)}function ya(e){if(e.hittable===!0||ia(e))return!1;let t=(e.type??``).toLowerCase();return t.includes(`text`)||t.includes(`image`)||t.includes(`icon`)}function ba(e){return e.hittable===!0&&!ia(e)&&!!(e.rect&&ea(e.rect))&&!!oa(H(e))}function xa(e,t,n){if(!Ta(t)||!ta(t.rect,e.rect))return!1;let r=oa(H(t));return!!(r&&n!==r&&n.includes(r))}function Sa(e,t,n){return!n.has(e.index)&&na(e.rect,t.rect)&&(Aa(e,t)||ka(e,t))}function Ca(e,t,n,r,i){let a=Ea(t,n),o=a.index===t.index?n:t,s=(o.type??``).toLowerCase().includes(`image`)?`has image`:null,c=i.get(a.index)??a,ee=i.get(o.index)?.presentationHints??o.presentationHints;return i.set(a.index,{...c,presentationHints:wa(c.presentationHints,ee,s)}),ua(e,o.index,r),i.get(a.index)??a}function wa(e,t,n){return[...new Set([...Array.isArray(e)?e:[],...Array.isArray(t)?t:[],...n?[n]:[]])]}function Ta(e){if(!e.rect||!ea(e.rect)||ra(e)||ia(e))return!1;let t=(e.type??``).toLowerCase();return t===`text`||Oa(t,fa)}function Ea(e,t){let n=Da(e);return Da(t)>n?t:e}function Da(e){let t=(e.type??``).toLowerCase(),n=0;return Oa(t,da)?n+=100:t.includes(`image`)?n+=30:t.includes(`textview`)||t===`text`?n+=20:t.includes(`view`)&&(n+=10),e.hittable===!0&&(n+=20),e.enabled!==!1&&(n+=5),n}function Oa(e,t){return t.some(t=>e.includes(t))}function ka(e,t){let n=e.parentIndex===t.index?t:t.parentIndex===e.index?e:null,r=n?.index===e.index?t:n?.index===t.index?e:null;return!n||!r?!1:Ea(n,r).index===n.index}function Aa(e,t){return e.parentIndex===t.parentIndex?Math.abs(e.index-t.index)<=3:e.parentIndex===t.index||t.parentIndex===e.index?!1:Math.abs((e.depth??0)-(t.depth??0))<=1&&Math.abs(e.index-t.index)<=2}function ja(e,t,n){if(n.raw||!Ma(e))return{nodes:t,filteredCount:0};let r=Na(t);return{nodes:r,filteredCount:t.length-r.length}}function Ma(e){let t=e.androidSnapshot;return!t||typeof t!=`object`?!1:t.backend===`android-helper`}function Na(e){if(e.length===0)return e;let t=new Set,n=new Map,r=new Map(e.map(e=>[e.index,e]));return Pa(e,t),Fa(e,r,t,n),pa(e,t,n),ha(e,t),ma(e,t,n),e.filter(e=>!t.has(e.index)).map(e=>n.get(e.index)??e)}function Pa(e,t){for(let n of e)!n.rect||ea(n.rect)||ra(n)||ua(e,n.index,t)}function Fa(e,t,n,r){for(let i of e){if(n.has(i.index)||i.rect||ra(i))continue;let a=ca(i,t,aa);a&&La(r,a,Ia(i,e)),ua(e,i.index,n)}}function Ia(e,t){let n=t.filter(t=>t.parentIndex===e.parentIndex&&t.rect&&ea(t.rect)).map(e=>e.index);return n.length===0?null:e.index<Math.min(...n)?`above`:e.index>Math.max(...n)?`below`:null}function La(e,t,n){if(!n)return;let r=e.get(t.index)??t;e.set(t.index,{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n===`above`||void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n===`below`||void 0})}function Ra(e){if(e.length<20)return!1;let t=new Map;for(let n of e){let e=(n.type??``).toLowerCase(),r=za(be(n));if(!r)continue;let i=`${e}|${r}`,a=t.get(i)??[];a.push(n),t.set(i,a)}let n=0;for(let e of t.values())e.length<=1||!Va(e)||(n+=e.length);return n>=8}function za(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||Ba(t)?null:t}function Ba(e){return/\S+@\S+\.\S+/.test(e)}function Va(e){for(let t=0;t<e.length;t+=1)for(let n=t+1;n<e.length;n+=1)if(Ha(e[t]?.rect,e[n]?.rect))return!0;return!1}function Ha(e,t){if(!e||!t)return!0;let n=.5;return!(e.x+e.width<=t.x+n||t.x+t.width<=e.x+n||e.y+e.height<=t.y+n||t.y+t.height<=e.y+n)}function Ua(e,n={}){let r=e.nodes,i=Array.isArray(r)?r:[],a=o(e.backend)?e.backend:void 0,s=t(a),c=ja(e,i,n),ee=qa(e),te=no(e,i,n,c),ne=te.length>0?`${te.join(`
|
|
4
|
-
`)}\n`:``,
|
|
1
|
+
import{D as e,E as t,S as n,p as r,t as i,x as a,y as o}from"./sdk-contracts.js";import{d as s,f as c,i as l,l as ee,n as te,p as ne,t as re,u as ie}from"./capture.js";import{O as ae,c as oe,d as se,f as ce,g as u,l as le,o as ue,p as de,s as fe,u as pe}from"./sdk-batch-runner.js";import{t as me}from"./viewport.js";import{r as he,t as ge}from"./sdk-device.js";import{i as _e,s as ve}from"./lease-scope.js";import{Fn as ye,Jr as be,Lr as xe,Mr as Se,Sr as Ce,cn as we,dr as Te,gr as Ee,i as De,jn as Oe,kn as ke,lr as Ae,m as je,mr as Me,on as Ne,p as Pe,s as Fe,ur as Ie}from"./sdk-batch.js";import{n as Le}from"./recording-export-quality.js";import{t as Re}from"./recording-scope.js";import{a as ze,n as Be,o as Ve,r as He,s as Ue}from"./scroll-gesture.js";import{E as We,T as Ge,b as Ke,v as qe,w as Je}from"./script.js";import{c as Ye,n as Xe,o as Ze,r as Qe,s as $e,t as et}from"./format.js";import{n as d,t as tt}from"./catalog.js";import{i as nt,r as rt,t as it}from"./back-mode.js";import{a as at}from"./sdk-remote-config.js";import{t as ot}from"./session.js";import{a as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,l as mt,n as ht,o as gt,p as _t,s as vt,t as yt,u as bt}from"./observability.js";import{n as xt,t as St}from"./success-text.js";import{a as f,i as Ct,n as p,r as m}from"./output-common.js";import{t as wt}from"./alert-contract.js";import{a as Tt,i as Et,l as Dt,o as Ot,s as kt,t as At,u as jt,y as Mt}from"./location-coordinates.js";import{t as Nt}from"./snapshot-quality-backend-capabilities.js";import{a as Pt,d as Ft,f as It,l as Lt,t as Rt,u as zt}from"./absence-observation-errors.js";import{t as Bt}from"./mobile-snapshot-semantics.js";import{t as Vt}from"./click-button.js";import{n as Ht}from"./scroll-command.js";import{n as Ut,t as Wt}from"./interaction-positionals.js";import{t as Gt}from"./app-inventory.js";import"./device.js";import{c as Kt,i as qt,l as Jt,r as Yt,t as Xt}from"./device-rotation.js";import"./app-inventory-contract.js";import{t as Zt}from"./prepare-kind.js";import{n as Qt,t as $t}from"./path-resolution.js";import"./file.js";import{n as en,r as tn,s as nn,t as rn}from"./tv-remote.js";import h from"node:path";import an from"node:fs";const on=[`path`,`start`,`stop`,`doctor`,`mark`,`clear`],sn=new Set(rt().map(e=>e.key));function cn(e){let t=_e(e);return ae({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...ve(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,providerAppiumVersion:e.providerAppiumVersion,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,...a(e,r),...ee(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,until:e.until,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,replayScriptSource:e.replayScriptSource,replayScriptSources:e.replayScriptSources,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 ln(e,t){return{...cn(e),...t}}function un(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!sn.has(e))continue;let t=i[e];dn(t)&&(r[e]=t)}return r}function dn(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function fn(e){return{kind:`operator`,source:e}}function pn(e,t){return`${e} is not accepted as a tool argument. ${mn(e,t)}`}function mn(e,t){if(`operatorPath`in t)return t.operatorPath;let n=`for the process serving these tools.`,r=(t.envFlagKeys??[e]).map(at).join(` or `);return r===``?`Set ${e} in ~/.agent-device/config.json ${n}`:`Set the ${r} environment variable${t.operatorConfig?` (or ${e} in ~/.agent-device/config.json)`:``} ${n}`}function hn(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}function gn(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 _n(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 vn(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`string`)throw new e(`INVALID_ARGS`,`Expected ${n} to be a string.`);return r}}function g(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 yn(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 bn(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 xn(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 Sn(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 Cn(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 wn(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 Tn(t,n,r,i){let a=new Set(n),o=Object.keys(t).filter(e=>!a.has(e));if(o.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${o.join(`, `)}.`,i===void 0?void 0:{hint:i})}function _(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}const En=fn({operatorConfig:!0}),Dn={session:{schema:{type:`string`,description:`Agent-device session name.`},read:e=>g(e,`session`),flagKey:`session`,flagIn:[`input`]},platform:{schema:{type:`string`,enum:he,description:`Platform selector used to resolve a device.`},read:e=>Sn(e,`platform`,he),flagKey:`platform`,flagIn:[`input`,`selection`]},deviceTarget:{schema:{type:`string`,enum:ge,description:`Device target form. Maps to the CLI --target flag.`},read:Nn,clientKey:`target`,flagKey:`target`,flagIn:[`input`,`selection`]},target:{schema:{type:`string`,enum:ge,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`}},device:{schema:{type:`string`,description:`Device name selector (a UDID belongs in udid, a serial in serial).`},read:e=>g(e,`device`),flagKey:`device`,flagIn:[`input`,`selection`]},udid:{schema:{type:`string`,description:`Apple device or simulator UDID; the selector that pins one device when several share a name.`},read:e=>g(e,`udid`),flagKey:`udid`,flagIn:[`input`,`selection`]},serial:{schema:{type:`string`,description:`Android, HarmonyOS, or Vega VVD serial selector.`},read:e=>g(e,`serial`),flagKey:`serial`,flagIn:[`input`,`selection`]},iosSimulatorDeviceSet:{schema:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},read:e=>g(e,`iosSimulatorDeviceSet`),audience:fn({envFlagKeys:[],operatorConfig:!0}),flagKey:`iosSimulatorDeviceSet`,flagIn:[`input`,`selection`]},iosXctestrunFile:{schema:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},read:e=>g(e,`iosXctestrunFile`),audience:En,flagKey:`iosXctestrunFile`,flagIn:[`input`]},iosXctestDerivedDataPath:{schema:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},read:e=>g(e,`iosXctestDerivedDataPath`),audience:En,flagKey:`iosXctestDerivedDataPath`,flagIn:[`input`]},iosXctestEnvDir:{schema:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},read:e=>g(e,`iosXctestEnvDir`),audience:En,flagKey:`iosXctestEnvDir`,flagIn:[`input`]},androidDeviceAllowlist:{schema:{type:`string`,description:`Android serial allowlist used for device resolution.`},read:e=>g(e,`androidDeviceAllowlist`),flagKey:`androidDeviceAllowlist`,flagIn:[`input`,`selection`]},noRecord:{read:e=>bn(e,`noRecord`),flagKey:`noRecord`,flagIn:[`input`,`selection`]},daemonBaseUrl:{schema:{type:`string`,description:`Remote daemon base URL.`},read:e=>g(e,`daemonBaseUrl`),audience:En},daemonAuthToken:{schema:{type:`string`,description:`Remote daemon auth token.`},read:e=>g(e,`daemonAuthToken`),audience:En},tenant:{schema:{type:`string`,description:`Remote tenant identifier.`},read:e=>g(e,`tenant`)},runId:{schema:{type:`string`,description:`Lease run identifier.`},read:e=>g(e,`runId`)},leaseId:{schema:{type:`string`,description:`Existing lease identifier.`},read:e=>g(e,`leaseId`)},cwd:{schema:{type:`string`,description:`Working directory for command execution.`},read:e=>g(e,`cwd`),audience:fn({operatorPath:`Start the process serving these tools in the desired working directory, or pass absolute paths.`})},debug:{schema:{type:`boolean`,description:`Enable debug diagnostics.`},read:e=>bn(e,`debug`)}},On=Object.entries(Dn),kn=Object.fromEntries(On.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function An(){return Object.fromEntries(On.flatMap(([e,t])=>t.schema?[[e,t.schema]]:[]))}function jn(e,t={}){let n={};for(let[r,i]of On)i.read&&(n[r]=i.read(e,t));return n}function v(e){let t={};for(let[n,r]of On)r.read&&(t[r.clientKey??n]=e[n]);return _(t)}function Mn(e,t){let n={};for(let[r,i]of On){if(i.flagIn===void 0||!i.flagIn.includes(t))continue;let a=t===`selection`?i.clientKey??r:r;n[a]=e[i.flagKey]}return n}function Nn(t,n){let r=Sn(t,`deviceTarget`,ge);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=Sn(t,`target`,ge);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 y(e,t){return n=>b(e,t?t(n):[],n)}function b(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Pn(n)}}function Pn(e){let t=Fn(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 Fn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function x(e){return _(Mn(e,`input`))}function In(e){return _({record:e.record})}function Ln(e){return Mn(e,`selection`)}function Rn(e){return _({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function zn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function Bn(e){return _({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Vn(e){return _({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function Hn(e){if(`ref`in e&&e.ref!==void 0)return _({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 Un(t){let n=Gn(t);if(typeof n.ref==`string`)return[n.ref,...qn(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(Kn(n.x,`x`)),String(Kn(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function Wn(t){let n=Gn(t);if(typeof n.ref==`string`)return[n.ref,...qn(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function Gn(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 Kn(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function qn(e){return typeof e==`string`&&e.length>0?[e]:[]}function Jn(t){let n=Ie(t);if(!n.ok)throw new e(n.code,n.message);return`ref`in n?{ref:n.ref,label:Qn(t.slice(1))}:{selector:n.selector}}function Yn(t){let n=Te(t);if(!n.ok)throw new e(n.code,n.message);return n.format}function Xn(t,n={}){let r=Ce(t,n);if(!r)throw new e(`INVALID_ARGS`,Ae);return r}function Zn(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 Qn(e){return e.join(` `).trim()||void 0}function S(...e){return new Set(e)}function C(e,t){return e!==void 0&&t.has(e)}function $n(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function er(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 tr(e){return e===void 0?void 0:Number(e)}function w(e){return e===void 0?[]:[e]}function T(e){return e===void 0?[]:[String(e)]}function E(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function D(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function nr(e){return ar(e.description,e.cliDetail)}function rr(e){return ar(e.description,e.mcpDetail)}function ir(e,t){return{...e,description:t}}function ar(e,t){return t?`${e} ${t}`:e}function or(e){return e}const sr=[`ref`,`selector`,`point`];function cr(e,t=[]){return{type:`object`,properties:{...An(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function lr(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function ur(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function dr(e){return{type:`string`,...e?{description:e}:{}}}function fr(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function pr(e){return{type:`integer`,...e?{description:e}:{}}}function mr(e){return{type:`boolean`,...e?{description:e}:{}}}function hr(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function gr(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function O(e){return{...e,required:!0}}function k(e,t={}){return I(dr(e),t.allowEmpty===!0?vn:g)}function _r(t){return{schema:{type:`null`},required:!1,audience:{kind:`retired`,message:t},read:(n,r)=>{if(Object.hasOwn(n,r))throw new e(`INVALID_ARGS`,t)}}}function vr(e,t){return{...e,audience:{kind:`operator`,source:t}}}function A(e,t={}){return I(fr(e,t),(e,n)=>de(e,n,t))}function j(e,t={}){return I(zr(e,t),(e,n)=>ce(e,n,t))}function M(e){return I(mr(e),bn)}function yr(e){return xr(br(e))}function br(e){let[t,...n]=nt(e).filter(e=>e.inputDescription!==void 0);if(!t)throw Error(`Flag ${e} declares no inputDescription; optionField cannot derive a field`);if(n.length>0)throw Error(`Flag ${e} declares inputDescription more than once`);return t}function xr(e){let t=e.inputDescription,n={min:e.min,max:e.max};switch(e.type){case`boolean`:return M(t);case`int`:return j(t,n);case`number`:return A(t,n);case`string`:return k(t);case`enum`:return N(Sr(e),t);case`booleanOrString`:throw Error(`Flag ${e.key} is booleanOrString; declare its field shape explicitly with jsonSchemaField`)}}function Sr(e){let t=e.enumValues;if(!t)throw Error(`Flag ${e.key} is an enum with no enumValues`);return t}function N(e,t){return I(ur(e,t),(t,n)=>Sn(t,n,e))}function Cr(e){return I(gr(e),Cn)}function wr(e){return I(hr(e),wn)}function P(e){return I(e,(e,t)=>e[t])}function Tr(e,t){return I(e,t)}function Er(){return I(Ur(),(e,t)=>e[t]===void 0?void 0:Mr(e,t))}function Dr(){return I(Wr(),(e,t)=>e[t]===void 0?void 0:Nr(e,t))}function Or(e){return I(lr(e),(e,t)=>e[t]===void 0?void 0:Pr(e,t))}function F(){return{depth:j(`Snapshot traversal depth.`,{min:0}),scope:k(`Snapshot scope selector used before resolution.`),raw:M(`Use raw snapshot data during selector resolution.`)}}function kr(){return{count:j(`Number of press/click repetitions.`,{min:1}),intervalMs:j(`Delay between repeated press/click actions.`,{min:0}),holdMs:j(`Hold duration for each action.`,{min:0}),jitterPx:j(`Randomization radius in pixels.`,{min:0}),doubleTap:M(`Request a double-tap action.`)}}function Ar(e){return cr(Br(e),Vr(e))}function jr(t,n){let r=hn(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=jn(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return _({...a,...v(a),...i})}function Mr(e,t){let n=gn(e,t),r=xn(n,`kind`,sr);switch(r){case`ref`:return{kind:r,ref:_n(n,`ref`),label:g(n,`label`)};case`selector`:return{kind:r,selector:_n(n,`selector`)};case`point`:return{kind:r,x:yn(n,`x`),y:yn(n,`y`)}}}function Nr(e,t){let n=gn(e,t),r=xn(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:_n(n,`ref`),label:g(n,`label`)}:{kind:r,selector:_n(n,`selector`)}}function Pr(e,t){let n=gn(e,t);return{x:yn(n,`x`),y:yn(n,`y`)}}function Fr(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 Ir(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function Lr(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function Rr(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function I(e,t){return{schema:e,required:!1,read:t}}function zr(e,t){return{...pr(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Br(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.audience?.kind!==`retired`).map(([e,t])=>[e,t.schema]))}function Vr(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function Hr(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]))}function Ur(){return{oneOf:[...Gr(),{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 Wr(){return{oneOf:Gr(),description:`UI element target by snapshot ref or selector expression.`}}function Gr(){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 L(e,t,n,r){return or({name:e,description:t,inputSchema:Ar(n),readInput:r?.readInput??(e=>jr(e,n)),inputAudience:Hr(n),...r?.parseableOutput?{parseableOutput:!0}:{}})}function R(e){let t=ir(e.text,e.metadata.description),n=t.mcpDetail?{mcpDetail:t.mcpDetail}:{},r={...e.metadata,...n},i={name:r.name,description:r.description,inputSchema:r.inputSchema,...n,invoke:async(t,n)=>await e.run(t,r.readInput(n))};return{name:e.name,metadata:r,definition:i,cliSchema:{...e.cliSchema,text:t},cliReader:e.cliReader,daemonWriter:e.daemonWriter,cliOutputFormatter:e.cliOutputFormatter,text:t}}function Kr(e){return R({name:e.name,text:e.text,metadata:L(e.name,e.description,{}),run:e.run,cliSchema:{},cliReader:(e,t)=>x(t),daemonWriter:y(e.name),cliOutputFormatter:e.cliOutputFormatter})}function z(e){let t={},n={},r={},i={};for(let a of e.commands)qr(t,`CLI schema`,a.name,a.cliSchema),qr(n,`CLI reader`,a.name,a.cliReader),a.daemonWriter&&qr(r,`daemon writer`,a.name,a.daemonWriter),a.cliOutputFormatter&&qr(i,`CLI output formatter`,a.name,a.cliOutputFormatter);return{name:e.name,clientSurface:e.clientSurface,metadata:e.commands.map(e=>e.metadata),definitions:e.commands.map(e=>e.definition),cliSchemas:t,cliReaders:n,daemonWriters:r,cliOutputFormatters:i}}function qr(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function Jr(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(Xr(n));return{data:e,text:t.join(`
|
|
2
|
+
`)}}const Yr={batch:f(Jr)};function Xr(e){let t=St(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function Zr(e=De){let t=Qr(e);return L(`batch`,`Execute multiple commands in one daemon request.`,t,{readInput:e=>ei(e,t)})}function Qr(e){return{steps:O(Tr({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:$r(e)},(t,n)=>ti(t[n],e))),onError:N([`stop`],`Batch failure policy.`),maxSteps:j(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:k(`Optional output path for command artifacts.`)}}function $r(e){return{type:`object`,properties:{command:{type:`string`,enum:e,description:`Command name to run with structured input.`},input:{type:`object`,additionalProperties:!0,commandInputFor:`command`,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 ei(t,n){let r=jr(t,n),i=r.maxSteps??100;if(!oe(i))throw new e(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(r.maxSteps)}`);return fe(r.steps.length,i),{...r}}function ti(t,n){if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected steps to be an array.`);return t.map((e,t)=>ni(e,t+1,n))}function ni(e,t,n){let r=se(e,t);return Tn(r,[`command`,`input`,`runtime`],`Batch step ${t}`,ue),{command:ri(r,t,n),input:pe(r,t),...ii(r,t)}}function ri(t,n,r){if(r===De)return Fe(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 ii(e,t){let n=le(e.runtime,t);return n===void 0?{}:{runtime:n}}function ai(e){return async t=>b(d.batch,[],{...t,batchSteps:await oi(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}async function oi(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty steps array.`);let r=[];for(let[e,i]of t.entries())r.push(await si(i,e+1,n));return r}async function si(e,t,n){let r=se(e,t),i=ci(r,t),a=pe(r,t),o=le(r.runtime,t),s=await n(i,a,t);return{command:s.command,positionals:s.positionals,...s.input?{input:s.input}:{},flags:ln(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function ci(e,t){return Fe(e.command,t)}const li=Zr(),ui={usageOverride:`batch [--steps <json> | --steps-file <path>]`,usageFlags:[],listUsageOverride:`batch --steps <json> | --steps-file <path>`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},di=(e,t)=>({...x(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),fi=[{command:`snapshot`,input:{interactiveOnly:!0}},{command:`press`,input:{target:{kind:`ref`,ref:`@e12`},settle:!0}},{command:`fill`,input:{target:{kind:`selector`,selector:`id="field-email"`},text:`qa@example.com`}}];function pi(){return`${[`Each step is {"command":"<name>","input":{...}}, and input is that command's structured input object rather than its terminal spelling: a CLI positional becomes a named field (target, text, direction) and a CLI flag becomes a camelCase key (--settle -> "settle":true, -i -> "interactiveOnly":true). There is no positional step form; args, argv, positionals, and flags are not step fields. agent-device help <command> lists arguments in CLI spelling only. The examples below carry the structured spelling; over MCP, the command tool schema states it in full.`,`Steps run serially in one daemon request against the same session, in order. Mutating UI verbs are included (press, click, fill, longpress, scroll, back), which is where the round-trip saving is; --on-error stop halts at the first failing step.`,`Available through batch: ${[...De].sort().join(`, `)}.`,`Every other command is excluded: batch and replay never nest, and session, daemon, connection, and host tooling commands own lifecycle a batch request cannot carry. Run those on their own.`].join(` `)}\n\nExamples:\n${[` agent-device batch --steps '${JSON.stringify(fi)}'`,` agent-device batch --steps-file ./steps.json --json`].join(`
|
|
3
|
+
`)}`}const mi=z({name:`batch`,clientSurface:!1,commands:[R({name:`batch`,text:{summary:`Run multiple commands`,cliDetail:pi()},metadata:li,run:(e,t)=>e.batch.run(hi(t)),cliSchema:ui,cliReader:di,cliOutputFormatter:Yr.batch})]});function hi(e){return{...v(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}const gi=`alert`,_i=R({name:gi,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:L(gi,`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. Each iOS XCTest execution activates once, then only observes. Inspect again after an unconfirmed action; never assume a timeout means nothing happened.`,{action:N(wt),timeoutMs:j()}),run:(e,t)=>e.command.alert(t),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...x(t),...yi(e)}),daemonWriter:y(d.alert,e=>vi(e)),cliOutputFormatter:m});function vi(e){return[e.action??`get`,...T(e.timeoutMs)]}function yi(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return _({action:bi(t[0]),timeoutMs:er(t[1],`alert timeout`)})}function bi(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 B(...e){return e}const xi=B(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),V=B(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Si=B(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Ci=B(`metroHost`,`metroPort`,`bundleUrl`),wi=B(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Ti=B(`settle`,`settleQuietMs`,`timeoutMs`),Ei=B(`replayUpdate`,`replayEnv`),Di=B(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`providerDeviceOrientation`,`providerGeoLocation`,`providerTimezone`,`providerAppiumVersion`,`providerLanguage`,`providerLocale`,`providerNetworkProfile`,`providerCustomNetwork`,`providerNoResignApp`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Oi=new Set([`platform`,`device`,`udid`,`serial`,`session`]),ki=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),Ai=`diff`,ji=R({name:Ai,text:{summary:`Diff snapshot or screenshot`,cliDetail:`Screenshot --threshold is a per-pixel RGB tolerance: 0 requires exact colors and 1 ignores color differences; image dimensions must still match. Both screenshot inputs are decoded from their bytes, so a baseline or current image may be PNG or JPEG, and the diff image is always PNG. JPEG is lossy, so keep --threshold above 0 whenever either input is JPEG. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`},metadata:L(Ai,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:O(P({type:`string`,const:`snapshot`})),out:k(),interactiveOnly:M(),depth:j(),scope:k(),raw:M()}),run:(e,t)=>e.capture.diff(t),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,usageFlags:[],positionalArgs:[`kind`,`current?`],allowedFlags:[...xi,`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{...x(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:y(d.diff,e=>[D(e.kind,`diff requires kind`)])}),Mi=`screenshot`,Ni=R({name:Mi,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, --crop-on <selector> to crop the capture to the frame the selector resolves on the same screen (currently iOS simulators and Android emulators), --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops.`},metadata:L(Mi,`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:k(`Output path.`),cropOn:k(`Selector expression; the capture is cropped to the frame the selector resolves on the same screen.`),overlayRefs:M(),pixelDensity:j(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:M(),scale:A(`Screenshot scale factor.`,l),maxSize:_r(re.migration.screenshot),stabilize:M(),normalizeStatusBar:M(),surface:N(ot)}),run:(e,t)=>e.capture.screenshot(t),cliSchema:{positionalArgs:[`path?`],allowedFlags:te},cliReader:(e,t)=>({...x(t),path:e[0]??t.out,...s(t)}),daemonWriter:e=>(c(`screenshot`,e),ne(e),b(d.screenshot,w(e.path),{...e,...ie(e)}))}),Pi=`settings`,Fi=L(Pi,`Read or change supported operating-system settings, animation scales, appearance, or app permissions on the selected target. Platform support varies by setting and action.`,{setting:O(k()),state:k(),app:k(),latitude:A(),longitude:A(),permission:k(),mode:N([...kt])}),Ii={usageOverride:jt,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state?`,`target?`,`mode?`]},Li=(e,t)=>Bi(e,t),Ri=y(d.settings,e=>Vi(e)),zi=R({name:Pi,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings ${Dt}; wifi|airplane|location|animations|text-size remain unsupported on macOS. Mobile permission actions use the active session app. On Android, deny|reset of a permission the app currently holds kills a running app; the response reports priorGrantState (granted|not_granted|unknown) and warns for granted and unknown, with open <app> --relaunch to restore it. Permission changes require a resolvable foreground user and fail without mutating if adb cannot report one. Android settings airplane on|off is applied by the connectivity service (Android 11+) and reports the airplaneMode that service holds; older builds fail without changing device state. settings reset-keychain clear is iOS-simulator-only and resets the whole simulator keychain, not just the selected app: simctl exposes no per-app keychain reset, so every app on that simulator loses its keychain-backed credentials (e.g. Firebase auth). clear-app-state does not touch the keychain, so a full fresh-install reset needs both; relaunch the app afterward to observe the signed-out state. settings text-size reads the preferred text size the target holds and settings text-size <category> applies one, on iPhone and iPad simulators (simctl content size) and on Android targets (system font_scale); tvOS and visionOS simulators, physical Apple devices, and the macOS host refuse it. Android has no category ladder of its own, so the read names the nearest rung and reports the exact multiplier as platformValue; an already-running app adopts a changed size at its next configuration change, so relaunch the app under test to observe it.`},metadata:Fi,run:(e,t)=>e.settings.update(t),cliSchema:Ii,cliReader:Li,daemonWriter:Ri,cliOutputFormatter:m});function Bi(t,n){let r=Ln(n),i=t[0],a=t[1];if(C(i,Wi)&&C(a,Gi))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:At(t[2],`latitude`),longitude:At(t[3],`longitude`)};if(i===`appearance`&&C(a,Ki))return{...r,setting:i,state:a};if(i===`text-size`)return a===void 0?{...r,setting:i}:{...r,setting:i,state:Mt(a)};if(C(i,qi)&&C(a,Ji)||i===`fingerprint`&&C(a,Yi))return{...r,setting:i,state:a};if(i===`permission`&&C(a,Zi))return{...r,setting:i,state:a,permission:Hi(t[2]),mode:Ui(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}if(i===`reset-keychain`&&a===`clear`&&t.length===2)return{...r,setting:i,state:a};throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function Vi(e){return e.setting===`clear-app-state`?[e.setting,...w(e.app)]:e.setting===`text-size`?[e.setting,...w(e.state)]: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,...w(e.mode)]:[e.setting,e.state]}function Hi(t){if(C(t,Qi))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function Ui(t){if(t===void 0||C(t,Xi))return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const Wi=S(`wifi`,`airplane`,`location`,`animations`),Gi=S(`on`,`off`),Ki=S(`light`,`dark`,`toggle`),qi=S(`faceid`,`touchid`),Ji=S(`match`,`nonmatch`,`enroll`,`unenroll`),Yi=S(`match`,`nonmatch`),Xi=S(...kt),Zi=S(...Ot),Qi=S(...Tt,...Et);function $i(e){if(!Array.isArray(e)||e.length===0)return e;let t=xe(e);return e.map(e=>{let n=ea(e,t,e=>e.label),r=ea(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 ea(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 ta(e){return e.width>0&&e.height>0}function na(e,t){return!e||!t?!1:e.x>=t.x-2&&e.y>=t.y-2&&e.x+e.width<=t.x+t.width+2&&e.y+e.height<=t.y+t.height+2}function ra(e,t){if(!e||!t)return!0;let n=e.y+e.height/2,r=t.y+t.height/2;return Math.abs(n-r)<=Math.max(e.height,t.height,1)}function ia(e){return typeof e.parentIndex!=`number`}function aa(e){let t=(e.type??``).toLowerCase(),n=(e.identifier??``).trim().toLowerCase();return t.includes(`edittext`)||t.includes(`textfield`)||n===`composer`}function oa(e){let t=(e.type??``).toLowerCase();return t.includes(`scroll`)||t.includes(`list`)||t.includes(`recyclerview`)}function H(e){let t=Se(e);if(!t||t!==e.identifier?.trim()||!ca(t))return t;let n=(e.type??``).toLowerCase();return n.includes(`view`)||n.includes(`layout`)||n.includes(`image`)||n.includes(`list`)||n.includes(`recyclerview`)||n.includes(`collection`)?``:t}function sa(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||/^(true|false|\d+)$/.test(t)?null:t}function ca(e){return/^[\w.]+:id\/[\w.-]+$/i.test(e)}function la(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=t.get(r.parentIndex);if(!e)return null;if(n(e))return e;r=e}return null}function ua(e,t){let n=[],r=[t];for(;r.length>0;){let t=r.pop();for(let i of e)i.parentIndex===t&&(n.push(i),r.push(i.index))}return n}function da(e,t,n){let r=[t];for(;r.length>0;){let t=r.pop();if(!n.has(t)){n.add(t);for(let i of e)i.parentIndex!==t||n.has(i.index)||r.push(i.index)}}}const fa=[`button`,`switch`,`checkbox`,`radio`],pa=[`button`,`image`,`textview`,`view`];function ma(e,t,n){for(let r of e){if(t.has(r.index)||!_a(r))continue;let i=va(ua(e,r.index),r,t);if(i.label){n.set(r.index,{...r,...n.get(r.index),label:i.label});for(let n of i.removableIndexes)da(e,n,t)}}}function ha(e,t,n){let r=new Map;for(let i of e){if(t.has(i.index)||!Ea(i))continue;let a=sa(H(i));if(!a)continue;let o=r.get(a);if(o&&Ca(o,i,t)){let s=wa(e,o,i,t,n);r.set(a,s);continue}r.set(a,i)}}function ga(e,t){for(let n of e){if(t.has(n.index)||!xa(n))continue;let r=sa(H(n));if(!r)continue;let i=ua(e,n.index).filter(e=>!t.has(e.index)&&Sa(n,e,r));for(let n of i.filter(ba))da(e,n.index,t);let a=i.filter(e=>!ba(e)),o=new Set(a.map(e=>sa(H(e))).filter(e=>!!e));if(!(a.length<2||o.size<2))for(let n of a)da(e,n.index,t)}}function _a(e){return e.hittable===!0&&!aa(e)&&!!(e.rect&&ta(e.rect))&&H(e).trim().length===0}function va(e,t,n){let r=[],i=[],a=new Set;for(let o of e){if(n.has(o.index)||!ya(o,e)||!na(o.rect,t.rect))continue;let s=H(o).trim().replaceAll(/\s+/g,` `),c=sa(s);i.push(o.index),!(!s||!c||a.has(c))&&(a.add(c),r.push(s))}return{label:r.join(`, `),removableIndexes:i}}function ya(e,t){if(ba(e))return!0;let n=(e.type??``).toLowerCase();return e.hittable!==!0&&!aa(e)&&n.includes(`view`)&&H(e).trim().length>0&&!t.some(t=>t.parentIndex===e.index)}function ba(e){if(e.hittable===!0||aa(e))return!1;let t=(e.type??``).toLowerCase();return t.includes(`text`)||t.includes(`image`)||t.includes(`icon`)}function xa(e){return e.hittable===!0&&!aa(e)&&!!(e.rect&&ta(e.rect))&&!!sa(H(e))}function Sa(e,t,n){if(!Ea(t)||!na(t.rect,e.rect))return!1;let r=sa(H(t));return!!(r&&n!==r&&n.includes(r))}function Ca(e,t,n){return!n.has(e.index)&&ra(e.rect,t.rect)&&(ja(e,t)||Aa(e,t))}function wa(e,t,n,r,i){let a=Da(t,n),o=a.index===t.index?n:t,s=(o.type??``).toLowerCase().includes(`image`)?`has image`:null,c=i.get(a.index)??a,l=i.get(o.index)?.presentationHints??o.presentationHints;return i.set(a.index,{...c,presentationHints:Ta(c.presentationHints,l,s)}),da(e,o.index,r),i.get(a.index)??a}function Ta(e,t,n){return[...new Set([...Array.isArray(e)?e:[],...Array.isArray(t)?t:[],...n?[n]:[]])]}function Ea(e){if(!e.rect||!ta(e.rect)||ia(e)||aa(e))return!1;let t=(e.type??``).toLowerCase();return t===`text`||ka(t,pa)}function Da(e,t){let n=Oa(e);return Oa(t)>n?t:e}function Oa(e){let t=(e.type??``).toLowerCase(),n=0;return ka(t,fa)?n+=100:t.includes(`image`)?n+=30:t.includes(`textview`)||t===`text`?n+=20:t.includes(`view`)&&(n+=10),e.hittable===!0&&(n+=20),e.enabled!==!1&&(n+=5),n}function ka(e,t){return t.some(t=>e.includes(t))}function Aa(e,t){let n=e.parentIndex===t.index?t:t.parentIndex===e.index?e:null,r=n?.index===e.index?t:n?.index===t.index?e:null;return!n||!r?!1:Da(n,r).index===n.index}function ja(e,t){return e.parentIndex===t.parentIndex?Math.abs(e.index-t.index)<=3:e.parentIndex===t.index||t.parentIndex===e.index?!1:Math.abs((e.depth??0)-(t.depth??0))<=1&&Math.abs(e.index-t.index)<=2}function Ma(e,t,n){if(n.raw||!Na(e))return{nodes:t,filteredCount:0};let r=Pa(t);return{nodes:r,filteredCount:t.length-r.length}}function Na(e){let t=e.androidSnapshot;return!t||typeof t!=`object`?!1:t.backend===`android-helper`}function Pa(e){if(e.length===0)return e;let t=new Set,n=new Map,r=new Map(e.map(e=>[e.index,e]));return Fa(e,t),Ia(e,r,t,n),ma(e,t,n),ga(e,t),ha(e,t,n),e.filter(e=>!t.has(e.index)).map(e=>n.get(e.index)??e)}function Fa(e,t){for(let n of e)!n.rect||ta(n.rect)||ia(n)||da(e,n.index,t)}function Ia(e,t,n,r){for(let i of e){if(n.has(i.index)||i.rect||ia(i))continue;let a=la(i,t,oa);a&&Ra(r,a,La(i,e)),da(e,i.index,n)}}function La(e,t){let n=t.filter(t=>t.parentIndex===e.parentIndex&&t.rect&&ta(t.rect)).map(e=>e.index);return n.length===0?null:e.index<Math.min(...n)?`above`:e.index>Math.max(...n)?`below`:null}function Ra(e,t,n){if(!n)return;let r=e.get(t.index)??t;e.set(t.index,{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n===`above`||void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n===`below`||void 0})}function za(e){if(e.length<20)return!1;let t=new Map;for(let n of e){let e=(n.type??``).toLowerCase(),r=Ba(Se(n));if(!r)continue;let i=`${e}|${r}`,a=t.get(i)??[];a.push(n),t.set(i,a)}let n=0;for(let e of t.values())e.length<=1||!Ha(e)||(n+=e.length);return n>=8}function Ba(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||Va(t)?null:t}function Va(e){return/\S+@\S+\.\S+/.test(e)}function Ha(e){for(let t=0;t<e.length;t+=1)for(let n=t+1;n<e.length;n+=1)if(Ua(e[t]?.rect,e[n]?.rect))return!0;return!1}function Ua(e,t){if(!e||!t)return!0;let n=.5;return!(e.x+e.width<=t.x+n||t.x+t.width<=e.x+n||e.y+e.height<=t.y+n||t.y+t.height<=e.y+n)}function Wa(e,n={}){let r=e.nodes,i=Array.isArray(r)?r:[],a=o(e.backend)?e.backend:void 0,s=t(a),c=Ma(e,i,n),l=Ja(e),ee=ro(e,i,n,c),te=ee.length>0?`${ee.join(`
|
|
4
|
+
`)}\n`:``,ne=n.raw?null:Ga(e);if(ne)return`${l}${te}${Ka(ne)}\n`;let re=n.raw||!s?null:Bt(c.nodes),ie=!!e.truncated,ae=re?.nodes??i,oe=n.raw||!s?null:eo(e,re,ae.length,i.length,c.filteredCount),se=Ya(i.length,oe,ie);return i.length===0?`${l}${se}\n${te}`:n.raw?`${l}${se}\n${te}${Xa(i)}\n`:n.flatten?`${l}${se}\n${te}${Za(ae)}${$a(re)}\n`:`${l}${se}\n${te}${Qa(ae)}${$a(re)}\n`}function Ga(e){let t=e.unchanged;if(!t||typeof t!=`object`)return null;let n=t;return typeof n.ageMs!=`number`||typeof n.nodeCount!=`number`?null:{ageMs:n.ageMs,nodeCount:n.nodeCount,interactiveOnly:n.interactiveOnly===!0||void 0,scope:typeof n.scope==`string`?n.scope:void 0}}function Ka(e){let t=qa(e.ageMs);return e.scope?[`Scoped snapshot unchanged for scope "${e.scope}" since previous read ${t} ago.`,`Previous refs in this scope remain valid. Use find/get/is for a targeted query, or --force-full to re-emit.`].join(`
|
|
5
5
|
`):e.interactiveOnly?[`Interactive snapshot unchanged since previous read ${t} ago.`,`${e.nodeCount} visible nodes are unchanged. Previous @e refs are still valid. Use find/get/is for a targeted query, or --force-full to re-emit.`].join(`
|
|
6
6
|
`):[`Snapshot unchanged since previous read ${t} ago.`,`Refs from the previous snapshot are still valid. Use --force-full to re-emit the tree, or use find/get/is for a targeted query.`].join(`
|
|
7
|
-
`)}function
|
|
8
|
-
`)}\n`:``}function
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function
|
|
11
|
-
`)}function
|
|
12
|
-
`)}`:``}function
|
|
13
|
-
`)}}const Ro={debug:d(Lo)};function zo(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 Bo=`debug`,Vo=z({name:`debugging`,commands:[R({name:Bo,text:{summary:`Symbolicate Apple crash artifacts`},metadata:L(Bo,`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:O(N([`symbols`])),artifact:O(k(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:k(`Path to a matching .dSYM bundle.`),searchPath:k(`Directory to scan for matching .dSYM bundles.`),out:k(`Output path for the symbolicated artifact.`)}),run:(e,t)=>e.debug.symbols(t),cliSchema:{usageOverride:`debug symbols --artifact <crash.ips|crash.log> (--dsym <App.dSYM> | --search-path <dir>) [--out <symbolicated>]`,usageFlags:[],listUsageOverride:`debug`,positionalArgs:[`symbols`],allowedFlags:[`artifact`,`dsym`,`searchPath`,`out`]},cliReader:(e,t)=>({...x(t),action:Ho(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:Ro.debug})]});function Ho(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 Uo=()=>M(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),Wo=()=>({settle:M(`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:j(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:j(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function U(e){return{...Me(e)?{verify:Uo()}:{},...Fe(e)?Wo():{}}}function W(e){let t=[];return Me(e)&&t.push(`verify`),Fe(e)&&t.push(...wi),t}function Go(e,t){return Fe(e)?zn(t):{}}const Ko=[`click`,`focus`,`exists`,`list`,`getText`,`getAttrs`,`wait`,`fill`,`type`],qo={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. Pass an empty text to clear the field. 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.`,hover:`Move the pointer over a UI target by snapshot ref, selector, or coordinates without pressing, to reveal hover-gated UI such as row toolbars or menus. Web only; touch platforms have no hover state. Use settle to observe what the hover revealed without a follow-up snapshot.`,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. Set until to a selector to reach an off-screen target in one command rather than a scroll-and-check loop. The optional amount is the finger-path fraction of the viewport axis, honored up to 0.8 of it; directional scrolls reduce release momentum, while app scroll physics determine the final content offset. A visible keyboard shortens the swiped band instead of being dismissed; when too little is left, the command refuses with scroll_keyboard_occludes_surface.`,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, exists, absent, editable, selected, focused, or text. `absent` passes only when one readable, complete, unscoped, full-depth accessibility capture has zero matches. 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.`},Jo={target:O(Tr()),button:N(Vt,`Pointer button for platforms that support mouse buttons.`),...F(),...Or(),...U(`click`)},Yo={target:O(Tr()),...F(),...Or(),...U(`press`)},Xo={target:O(Tr()),text:O(k(`Text to enter into the target. Pass "" to clear it.`,{allowEmpty:!0})),delayMs:j(`Delay between typed characters.`,{min:0}),recordAs:k("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."),...F(),...U(`fill`)},Zo={target:O(Tr()),durationMs:j(`Long press duration in milliseconds.`,{min:0}),...F(),...U(`longpress`)},Qo={target:O(Tr()),...F(),...U(`hover`)},$o={from:O(Dr(`Swipe start point.`)),to:O(Dr(`Swipe end point.`)),count:j(`Number of swipe repetitions.`,{min:1,max:200}),pauseMs:j(`Pause between repeated swipes.`,{min:0,max:Ge}),pattern:N(Ue)},es={x:O(A(`X coordinate.`)),y:O(A(`Y coordinate.`))},ts={text:O(k(`Text to type.`)),delayMs:j(`Delay between typed characters.`,{min:0})},ns={direction:O(N(Ke)),amount:A(`Platform scroll amount.`),pixels:j(`Pixel scroll amount.`,{min:0}),until:k(`Repeat scroll passes until this selector is visible on screen, then stop. Not valid with the top/bottom edge directions, which carry their own stop condition.`),durationMs:j(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:Ht}),...U(`scroll`)},rs=()=>({noRecord:M(`Do not record this action.`),record:M(`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.`)}),is={format:O(N([`text`,`attrs`])),target:O(Er()),...F(),...rs()},as={predicate:O(N(Ce)),selector:O(k()),value:k(),...F(),...rs()},os={locator:N(xe),query:O(k()),action:N(Ko),value:k(void 0,{allowEmpty:!0}),timeoutMs:j(),first:M(),last:M(),depth:j(),raw:M(),...rs()},ss={kind:O(N(Ye,`Gesture variant.`)),direction:N(We,`Fling direction.`),preset:N(qe,`Swipe preset.`),origin:Dr(`Gesture origin point.`),delta:Dr(`Movement delta for pan or transform gestures.`),distance:j(`Fling distance.`,{min:0}),scale:A(`Pinch or transform scale.`),degrees:A(`Rotation in degrees.`),durationMs:j(`Pan/transform duration.`,{min:16,max:1e4}),pointerCount:j(`Pan touch pointer count (1 or 2).`,{min:1,max:2}),source:k(`Drag source @ref or selector.`),destination:k(`Drag destination @ref or selector.`),sourceHoldMs:j(`Drag activation hold duration.`,{min:1,max:1e4}),moveMs:j(`Drag movement duration.`,{min:16,max:1e4}),destinationHoldMs:j(`Hold before releasing at the destination.`,{min:0,max:1e4})},cs=[G(`click`,Jo),G(`press`,Yo),G(`fill`,Xo),G(`longpress`,Zo),G(`hover`,Qo),G(`swipe`,$o),G(`focus`,es),G(`type`,ts),G(`scroll`,ns),G(`get`,is,{parseableOutput:!0}),G(`is`,as),G(`find`,os,{parseableOutput:!0}),L(`gesture`,qo.gesture,ss,{readInput:ls})];function ls(e){let t=mn(e);return{...An(t),...Je(t)}}function G(e,t,n){return L(e,qo[e],t,n)}const us={gesture:fs},ds={gesture:e=>{let t=ls(e);return b(u.gesture,[],e,_(t))}};function fs(e,t){return{...x(t),...Xe(e,t.pointerCount)}}const K={click:(e,t)=>({...x(t),...Ln(t),...Bn(t),target:Vn(Ut(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...x(t),...Ln(t),...Bn(t),target:Vn(Ut(e)),verify:t.verify}),longpress:(e,t)=>{let n=ps(e);return{...x(t),...Ln(t),target:Vn(n),durationMs:n.durationMs}},hover:(e,t)=>({...x(t),...Ln(t),target:Vn(Ut(e))}),swipe:(e,t)=>({...x(t),...Qe(e,{count:t.count,pauseMs:t.pauseMs,pattern:t.pattern})}),focus:(e,t)=>({...x(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...x(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=Wt(e);return{...x(t),...Ln(t),target:Vn(n.target),text:n.text,delayMs:t.delayMs,recordAs:t.recordAs,verify:t.verify}},scroll:(e,t)=>({...x(t),direction:_s(e[0]),amount:er(e[1]),pixels:t.pixels,durationMs:t.durationMs,until:t.until}),get:(e,t)=>({...x(t),...Fn(t),...Ln(t),format:Jn(e[0]),target:Vn(qn(e.slice(1)))})},q={click:e=>b(u.click,Hn(e),{...e,clickButton:e.button}),press:y(u.press,e=>Hn(e)),longpress:y(u.longPress,e=>ms(e)),hover:y(u.hover,e=>Hn(e)),swipe:e=>(Ze(e),b(u.swipe,[],e,{from:e.from,to:e.to,count:e.count,pauseMs:e.pauseMs,pattern:e.pattern})),focus:y(u.focus,e=>[String(e.x),String(e.y)]),type:y(u.type,e=>hs(e)),fill:y(u.fill,e=>gs(e)),scroll:y(u.scroll,e=>[D(e.direction,`scroll requires direction`),...T(e.amount)]),get:y(u.get,e=>[D(e.format,`get requires format`),...Un(e)])};function ps(e){let t=vs(e);return{...Ut(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function ms(e){return[...Hn(e),...T(e.durationMs)]}function hs(e){return[e.text]}function gs(e){return[...Hn(e),e.text]}function _s(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 vs(e){if(Qn(e[0])&&Qn(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&&Qn(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function ys(e){return({input:t,result:n})=>{let r=e({input:t,result:n});return r instanceof Promise?r.then(bs):bs(r)}}function bs(e){return{data:e.data,text:Ss(e.text,e.data)}}function xs(e){let t={...e};for(let[n,r]of Object.entries(e))Fe(n)&&(t[n]=ys(r));return t}function Ss(e,t){return`${e??``}${Cs(t.settle)}`}function Cs(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Ds(t),...ws(t),...Es(t)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
|
|
14
|
-
`)}`}function
|
|
15
|
-
`)}function js(e,t){let n=e.ref??``,r=n.startsWith(`@`)?n.slice(1):n,i=wt(n,t)??`@${r}`,a=Ft(e.node?.type??`Element`),o=e.node?zt(e.node,a):``;return`= ${i} [${a}]${o?` "${o}"`:``}`}function Ms(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Ns(e){let t=e,n=t.ref??``,r=t.x,i=t.y;return!n||typeof r!=`number`||typeof i!=`number`?f(t):{data:t,text:`Tapped @${n} (${r}, ${i})`}}const J=xs({click:d(Ns),press:d(Ns),fill:p,longpress:p,hover:p,scroll:p,get:({input:e,result:t})=>Os({result:t,format:e.format===`attrs`?`attrs`:`text`}),is:d(Ms),find:d(ks)}),Ps={find:(e,t)=>Rs(e,t),is:(e,t)=>zs(e,t)},Fs={is:y(u.is,e=>Is(e)),find:e=>b(u.find,Ls(e),{...e,findFirst:e.first,findLast:e.last})};function Is(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function Ls(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`,...T(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function Rs(t,n){let r={...Us(n),...In(n),...Fn(n),first:n.findFirst,last:n.findLast},i=Hs(t[0]),a=i!==void 0,o=a?t[1]:t[0],s=a?2:1,c=we(t[s]);if(c===void 0)return{...r,locator:i,query:Ws(o)};if(c===`get`){let n=t[s+1];if(n===`text`)return{...r,locator:i,query:Ws(o),action:`getText`};if(n===`attrs`)return{...r,locator:i,query:Ws(o),action:`getAttrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...r,locator:i,query:Ws(o),action:`wait`,timeoutMs:er(t[s+1])};if(c===`fill`||c===`type`){let n=t.slice(s+1);if(n.length===0)throw new e(`INVALID_ARGS`,c===`fill`?`find fill requires text (use "" to clear the field)`:`find type requires text`);return{...r,locator:i,query:Ws(o),action:c,value:n.join(` `)}}if(c===`click`||c===`focus`||c===`exists`||c===`list`)return{...r,locator:i,query:Ws(o),action:c};throw new e(`INVALID_ARGS`,`Unsupported find action: ${t[s]}`,{hint:Ae})}function zs(t,n){let r={...Rn(n),...In(n),...Fn(n)},i=Ne(t),a=De(i[0]??``);if(!a.ok)throw new e(a.code,a.message,{hint:a.hint});let o=a.predicate;if(o===`absent`){let e=Bs(r);if(e)throw Vs(e)}let s=Yn(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 Bs(e){if(e.scope!==void 0)return`scope`;if(e.depth!==void 0)return`depth`}function Vs(t){return new e(`INVALID_ARGS`,t===`scope`?`is absent does not support --scope; it requires an unscoped capture`:`is absent does not support --depth; it requires a full-depth capture`,{command:`is`,predicate:`absent`,rejectedOption:t})}function Hs(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function Us(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function Ws(t){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,`find requires query`);return t}const Y={get:{usageOverride:`get text|attrs <@ref|selector>`,usageFlags:[],positionalArgs:[`subcommand`,`target`],allowsExtraPositionals:!0,allowedFlags:[...V,`record`]},find:{usageOverride:`find <locator|text> <action> [value] [--first|--last]`,usageFlags:[],positionalArgs:[`query`,`action`,`value?`],allowsExtraPositionals:!0,allowedFlags:[`snapshotDepth`,`snapshotRaw`,`findFirst`,`findLast`,`record`]},is:{positionalArgs:[`predicate`,`selector`,`value?`],allowsExtraPositionals:!0,allowedFlags:[...V,`record`]},click:{usageOverride:`click <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...Ci,`clickButton`,...W(`click`),...V]},press:{usageOverride:`press <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...Ci,...W(`press`),...V]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...W(`longpress`),...V]},hover:{usageOverride:`hover <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...W(`hover`),...V]},swipe:{positionalArgs:[`x1`,`y1`,`x2`,`y2`],allowsExtraPositionals:!0,allowedFlags:[`count`,`pauseMs`,`pattern`]},gesture:{usageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform|drag> ...`,usageFlags:[],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>`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrText`,`text?`],allowsExtraPositionals:!0,allowedFlags:[...V,`delayMs`,`recordAs`,...W(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount]`,usageFlags:[`until`,`pixels`,`durationMs`,`settle`],positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`,`until`,...W(`scroll`)]}},Gs=z({name:`interaction`,clientSurface:!1,commands:[R({name:`click`,text:{summary:`Click or tap a UI target`},metadata:X(`click`),run:(e,t)=>e.interactions.click(Ks(t)),cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),R({name:`press`,text:{summary:`Short-press a UI target`,cliDetail:`The hold duration is positional on longpress, not press --hold-ms.`},metadata:X(`press`),run:(e,t)=>e.interactions.press(qs(t)),cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),R({name:`fill`,text:{summary:`Replace text in a UI input`,cliDetail:`Every positional after an @ref is the replacement text, so fill @e57 good morning enters "good morning"; quote the text when the shell must preserve exact whitespace. Clear a field with an empty text argument: fill @e57 "" (the argument must be present — fill @e57 alone is a missing argument, not a clear). When visible label text also matches a non-input element, constrain the target with editable=true, for example fill 'label="Email" editable=true' "qa@example.com".`},metadata:X(`fill`),run:(e,t)=>e.interactions.fill(Js(t)),cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),R({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:X(`longpress`),run:(e,t)=>e.interactions.longPress(Ys(t)),cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),R({name:`hover`,text:{summary:`Hover the pointer over a UI target (web only)`,cliDetail:`The pointer stays where hover left it: read the revealed UI (--settle or snapshot -i) and act on it before another click or hover moves the pointer away.`},metadata:X(`hover`),run:(e,t)=>e.interactions.hover(Xs(t)),cliSchema:Y.hover,cliReader:K.hover,daemonWriter:q.hover,cliOutputFormatter:J.hover}),R({name:`swipe`,text:{summary:`Fling between coordinates`},metadata:X(`swipe`),run:(e,t)=>e.interactions.swipe(t),cliSchema:Y.swipe,cliReader:K.swipe,daemonWriter:q.swipe}),R({name:`focus`,text:{summary:`Focus input at screen coordinates`},metadata:X(`focus`),run:(e,t)=>e.interactions.focus(t),cliSchema:Y.focus,cliReader:K.focus,daemonWriter:q.focus}),R({name:`type`,text:{summary:`Append text to the focused input`},metadata:X(`type`),run:(e,t)=>e.interactions.type(t),cliSchema:Y.type,cliReader:K.type,daemonWriter:q.type}),R({name:`scroll`,text:{summary:`Scroll in a direction or to an edge`},metadata:X(`scroll`),run:(e,t)=>e.interactions.scroll(t),cliSchema:Y.scroll,cliReader:K.scroll,daemonWriter:q.scroll,cliOutputFormatter:J.scroll}),R({name:`get`,text:{summary:`Read element text or attributes`},metadata:X(`get`),run:(e,t)=>e.interactions.get(Qs(t)),cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),R({name:`is`,text:{summary:`Check a UI predicate on a selector`},metadata:X(`is`),run:(e,t)=>e.interactions.is(t),cliSchema:Y.is,cliReader:Ps.is,daemonWriter:Fs.is,cliOutputFormatter:J.is}),R({name:`find`,text:{summary:`Find an element and act`},metadata:X(`find`),run:(e,t)=>e.interactions.find(t),cliSchema:Y.find,cliReader:Ps.find,daemonWriter:Fs.find,cliOutputFormatter:J.find}),R({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:X(`gesture`),run:async(e,t)=>{switch(t.kind){case`pan`:return await e.interactions.pan($s(t));case`fling`:return await e.interactions.fling(tc(t));case`swipe`:return await e.interactions.swipeGesture(nc(t));case`pinch`:return await e.interactions.pinch(rc(t));case`rotate`:return await e.interactions.rotateGesture(ic(t));case`transform`:return await e.interactions.transformGesture(ac(t));case`drag`:return await e.interactions.drag(ec(t))}},cliSchema:Y.gesture,cliReader:us.gesture,daemonWriter:ds.gesture})]});function X(e){let t=cs.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function Ks(e){return{...v(e),...Pr(e.target),...Lr(e),...Ir(e),button:e.button,verify:e.verify,...Zs(e)}}function qs(e){return{...v(e),...Pr(e.target),...Lr(e),...Ir(e),verify:e.verify,...Zs(e)}}function Js(e){return{...v(e),...Pr(e.target),...Lr(e),text:e.text,delayMs:e.delayMs,recordAs:e.recordAs,verify:e.verify,...Zs(e)}}function Ys(e){return{...v(e),...Pr(e.target),...Lr(e),durationMs:e.durationMs,...Zs(e)}}function Xs(e){return{...v(e),...Pr(e.target),...Lr(e),...Zs(e)}}function Zs(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function Qs(e){return{...v(e),...Fr(e.target),...Lr(e),format:e.format,record:e.record}}function $s(e){return{...v(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,pointerCount:e.pointerCount,durationMs:e.durationMs}}function ec(e){return{...v(e),source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}}function tc(e){return{...v(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance}}function nc(e){return{...v(e),preset:e.preset}}function rc(e){return{...v(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function ic(e){return{...v(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y}}function ac(e){return{...v(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}}async function oc(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{devices:e.map(t)},text:e.map(bc).join(`
|
|
16
|
-
`)}}async function
|
|
17
|
-
`)}}function
|
|
7
|
+
`)}function qa(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(Math.round(e/100)/10).toFixed(1)}s`;let t=e/6e4;if(t<60)return`${(Math.round(t*10)/10).toFixed(1)}m`;let n=t/60;return`${(Math.round(n*10)/10).toFixed(1)}h`}function Ja(e){let t=typeof e.appName==`string`?e.appName:void 0,n=typeof e.appBundleId==`string`?e.appBundleId:void 0,r=[];return t&&r.push(`Page: ${t}`),n&&r.push(`App: ${n}`),r.length>0?`${r.join(`
|
|
8
|
+
`)}\n`:``}function Ya(e,t,n){let r=n?` (truncated)`:``;return t?.partial?t.totalNodeCount>t.visibleNodeCount?`Snapshot: ${t.visibleNodeCount} visible nodes (${t.totalNodeCount} total)${r}`:`Snapshot: ${t.visibleNodeCount} visible nodes${r}`:`Snapshot: ${e} nodes${r}`}function Xa(e){return e.map(e=>JSON.stringify(e)).join(`
|
|
9
|
+
`)}function Za(e){return po(e).join(`
|
|
10
|
+
`)}function Qa(e){return lo(Lt(e,{summarizeTextSurfaces:!0})).join(`
|
|
11
|
+
`)}function $a(e){return e&&e.summaryLines.length>0?`\n${e.summaryLines.join(`
|
|
12
|
+
`)}`:``}function eo(e,t,n,r,i=0){let a=to(e);if(i===0&&a)return a;let o=(t?.hiddenCount??0)+i,s=t?t.nodes.some(e=>e.hiddenContentAbove||e.hiddenContentBelow):!1;return o>0?{partial:!0,visibleNodeCount:n,totalNodeCount:Math.max(r,a?.totalNodeCount??r),reasons:no([...a?.reasons??[],`offscreen-nodes`])}:a||(s?{partial:!0,visibleNodeCount:n,totalNodeCount:n,reasons:[]}:null)}function to(e){let t=e.visibility;if(!t||typeof t!=`object`)return null;let n=t;return typeof n.partial!=`boolean`||typeof n.visibleNodeCount!=`number`||typeof n.totalNodeCount!=`number`||!Array.isArray(n.reasons)?null:{partial:n.partial,visibleNodeCount:n.visibleNodeCount,totalNodeCount:n.totalNodeCount,reasons:n.reasons.filter(e=>typeof e==`string`)}}function no(e){return[...new Set(e)]}function ro(e,t,n,r={nodes:t,filteredCount:0}){let i=[...co(e),...io(e)];if(ao(e)){let e=so(t,n);e&&i.push(e)}!n.raw&&r.filteredCount>0&&i.push(`Collapsed ${r.filteredCount} Android helper node${r.filteredCount===1?``:`s`} from the agent-facing text snapshot; use --raw or --json for the full hierarchy.`);let a=r.filteredCount>0?r.nodes:t;return!n.raw&&za(a)&&i.push(`Warning: possible repeated nav subtree detected.`),i}function io(e){let t=e.fallbackScreenshotPath;return typeof t==`string`&&t.length>0?[`Captured a screenshot of this screen automatically as visual truth: ${t}`]:[]}function ao(e){return!e.snapshotQuality&&!oo(e)}function oo(e){let t=e.snapshotDiagnostics;if(!t||typeof t!=`object`)return!1;let n=t.stats;return!!(n&&typeof n==`object`&&n.platform===`web`)}function so(e,t){if(t.scoped===!0||t.depthLimited===!0||e.length>3)return null;let n=e.length===1?`node`:`nodes`;return`Hint: sparse accessibility snapshot returned ${e.length} ${n}; snapshot state is invalid or unavailable for this screen. Use plain screenshot, not screenshot --overlay-refs, as visual truth. If screenshot shows the Home Screen or another app, run open for this app again first. Then navigate away with coordinates if needed and retry snapshot -i on the next screen.`}function co(e){return xt(e).filter(e=>e.length>0)}function lo(e){let t=[],n=[],r=new Map(e.map(e=>[e.node.index,e.node])),i=e=>{for(;n.length>0&&(!e||uo(e,n.at(-1),r));)t.push(...mo(n.pop(),`below`))};for(let r of e)i(r),t.push(r.text),t.push(...mo(r,`above`)),r.node.hiddenContentBelow&&n.push(r);return i(),t}function uo(e,t,n){return!fo(e.node,t.node,n)&&e.depth<=t.depth}function fo(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){if(r.parentIndex===t.index)return!0;let e=n.get(r.parentIndex);if(!e)return!1;r=e}return!1}function po(e){return Lt(e,{summarizeTextSurfaces:!0}).flatMap(e=>[It(e.node,0,!1,e.type,{summarizeTextSurfaces:!0}),...mo({...e,depth:0})])}function mo(e,t){let n=ho(e.type);if(!n)return[];let r=[];if(e.node.hiddenContentAbove&&t!==`below`&&r.push(`[content above ${n} hidden]`),e.node.hiddenContentBelow&&t!==`above`&&r.push(`[content below ${n} hidden]`),r.length===0)return[];let i=` `.repeat(e.depth+1);return r.map(e=>`${i}${e}`)}function ho(e){return e===`scroll-area`||e===`list`||e===`collection`||e===`table`?e:null}async function go(e){let{serializeSnapshotResult:t}=await import(`./result-serialization.js`).then(e=>e.t),n=t(e.raw||!Array.isArray(e.result.nodes)?e.result:{...e.result,nodes:$i(e.result.nodes)});return{data:n,jsonData:vo(n),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:Wa(n,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const _o={snapshot:async({input:e,result:t})=>await go({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:m,alert:m};function vo(e){let{unchanged:t,...n}=e;return n}const yo=`snapshot`,bo=Object.entries(Nt).map(([e,t])=>{let n=t.knownGaps.map(e=>`known gap ${e}`);return`${e}: hittable=${t.hittable}, regular-depth=${t.regularDepth}, deep-extension=${t.deepExtension}, depth-ladder=${t.depthLadder}${n.length>0?`, ${n.join(`, `)}`:``}`}).join(`; `),xo=L(yo,`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:M(),depth:j(),scope:k(),raw:M(),customActions:yr(`snapshotCustomActions`),forceFull:M(),timeoutMs:j(`Maximum wall-clock time for the snapshot command.`),noRecord:M(`Do not record this action.`),record:M(`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.`)}),So={allowedFlags:[`snapshotDiff`,...xi,`snapshotCustomActions`,`snapshotForceFull`,`timeoutMs`,`record`]},Co=(e,t)=>({...x(t),...In(t),...n(t,r),timeoutMs:t.timeoutMs}),wo=y(d.snapshot),To=R({name:yo,text:{summary:`Capture or diff the accessibility tree`,cliDetail:`Repeated equivalent unfiltered Android snapshots return a compact unchanged acknowledgement. Use --force-full to re-emit the tree; --json and --raw retain full output. 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. iOS backend capability contract: ${bo}.`},metadata:xo,run:(e,t)=>e.capture.snapshot(t),cliSchema:So,cliReader:Co,daemonWriter:wo,cliOutputFormatter:_o.snapshot}),Eo=[`duration`,`text`,`ref`,`selector`,`absent`,`stable`],Do=`wait`,Oo=R({name:Do,text:{summary:`Wait for a duration, text, selector, strict absence, or stable UI`},metadata:L(Do,`Wait for a duration, text, snapshot ref, selector to appear, selector to be strictly absent, or stable UI. Use the strict absence target when zero selector matches are required; stable waits until the UI stays quiet for the requested window.`,{kind:N(Eo),durationMs:j(),text:k(),ref:k(),selector:k(),absent:k(),stable:M(),quietMs:j(),timeoutMs:j(),depth:j(),scope:k(),raw:M()}),run:(e,t)=>e.command.wait(ko(t)),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|absent <selector> [timeoutMs]|stable [quietMs] [timeoutMs]`,usageFlags:[],positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...V]},cliReader:(e,t)=>Ao(e,t),daemonWriter:y(d.wait,e=>No(e)),cliOutputFormatter:m});function ko(e){Sn(e,`kind`,Eo);let t={...e};return delete t.kind,t}function Ao(t,n){let r=Ne(t);if(!r)throw new e(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], absent <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...Ln(n),...zn(n)};switch(r.kind){case`absent`:return jo(i,r);case`sleep`:return{...i,durationMs:r.durationMs};case`text`:return Mo(i,r);case`ref`:return{...i,ref:r.rawRef,...Po(r.timeoutMs)};case`stable`:return{...i,stable:!0,...Fo(r.quietMs),...Po(r.timeoutMs)};case`invalid`:throw new e(`INVALID_ARGS`,r.message);case`selector`:return{...i,selector:r.selectorExpression,...Po(r.timeoutMs)};default:return Io(r)}}function jo(e,t){let n=Pt(e);if(n)throw Rt(n,`wait`);return{...e,absent:t.selectorExpression,...Po(t.timeoutMs)}}function Mo(t,n){if(!n.text)throw new e(`INVALID_ARGS`,`wait requires text.`);return{...t,text:n.text,...Po(n.timeoutMs)}}function No(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.absent===void 0?void 0:`absent`,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, absent, or stable.`);if(t.durationMs!==void 0)return[String(t.durationMs)];let n=T(t.timeoutMs);if(t.text!==void 0)return[`text`,t.text,...n];if(t.ref!==void 0)return[t.ref,...n];if(t.absent!==void 0){let r=Pt(t);if(r)throw Rt(r,`wait`);if(!we(t.absent))throw new e(`INVALID_ARGS`,`Invalid wait absent selector: ${t.absent}`);return[`absent`,t.absent,...n]}if(t.stable!==void 0){let r=T(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 Po(e){return e===null?{}:{timeoutMs:e}}function Fo(e){return e===null?{}:{quietMs:e}}function Io(e){throw Error(`Unsupported wait positional target: ${String(e)}`)}const Lo=z({name:`capture`,commands:[To,Ni,ji,Oo,_i,zi]});function Ro(e){let t=[e.outPath,e.message];t.push(...Bo(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(`
|
|
13
|
+
`)}}const zo={debug:f(Ro)};function Bo(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 Vo=`debug`,Ho=z({name:`debugging`,commands:[R({name:Vo,text:{summary:`Symbolicate Apple crash artifacts`},metadata:L(Vo,`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:O(N([`symbols`])),artifact:O(k(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:k(`Path to a matching .dSYM bundle.`),searchPath:k(`Directory to scan for matching .dSYM bundles.`),out:k(`Output path for the symbolicated artifact.`)}),run:(e,t)=>e.debug.symbols(t),cliSchema:{usageOverride:`debug symbols --artifact <crash.ips|crash.log> (--dsym <App.dSYM> | --search-path <dir>) [--out <symbolicated>]`,usageFlags:[],listUsageOverride:`debug`,positionalArgs:[`symbols`],allowedFlags:[`artifact`,`dsym`,`searchPath`,`out`]},cliReader:(e,t)=>({...x(t),action:Uo(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:zo.debug})]});function Uo(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 Wo=()=>M(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),Go=()=>({settle:M(`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:j(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:j(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function U(e){return{...je(e)?{verify:Wo()}:{},...Pe(e)?Go():{}}}function W(e){let t=[];return je(e)&&t.push(`verify`),Pe(e)&&t.push(...Ti),t}function Ko(e,t){return Pe(e)?Bn(t):{}}const qo=[`click`,`focus`,`exists`,`list`,`getText`,`getAttrs`,`wait`,`fill`,`type`],Jo={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. Pass an empty text to clear the field. 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.`,hover:`Move the pointer over a UI target by snapshot ref, selector, or coordinates without pressing, to reveal hover-gated UI such as row toolbars or menus. Web only; touch platforms have no hover state. Use settle to observe what the hover revealed without a follow-up snapshot.`,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. Set until to a selector to reach an off-screen target in one command rather than a scroll-and-check loop. The optional amount is the finger-path fraction of the viewport axis, honored up to 0.8 of it; directional scrolls reduce release momentum, while app scroll physics determine the final content offset. A visible keyboard shortens the swiped band instead of being dismissed; when too little is left, the command refuses with scroll_keyboard_occludes_surface.`,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, exists, absent, editable, selected, focused, or text. `absent` passes only when one readable, complete, unscoped, full-depth accessibility capture has zero matches. 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.`},Yo={target:O(Er()),button:N(Vt,`Pointer button for platforms that support mouse buttons.`),...F(),...kr(),...U(`click`)},Xo={target:O(Er()),...F(),...kr(),...U(`press`)},Zo={target:O(Er()),text:O(k(`Text to enter into the target. Pass "" to clear it.`,{allowEmpty:!0})),delayMs:j(`Delay between typed characters.`,{min:0}),recordAs:k("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."),...F(),...U(`fill`)},Qo={target:O(Er()),durationMs:j(`Long press duration in milliseconds.`,{min:0}),...F(),...U(`longpress`)},$o={target:O(Er()),...F(),...U(`hover`)},es={from:O(Or(`Swipe start point.`)),to:O(Or(`Swipe end point.`)),count:j(`Number of swipe repetitions.`,{min:1,max:200}),pauseMs:j(`Pause between repeated swipes.`,{min:0,max:Ve}),pattern:N(ze)},ts={x:O(A(`X coordinate.`)),y:O(A(`Y coordinate.`))},ns={text:O(k(`Text to type.`)),delayMs:j(`Delay between typed characters.`,{min:0})},rs={direction:O(N(He)),amount:A(`Platform scroll amount.`),pixels:j(`Pixel scroll amount.`,{min:0}),until:k(`Repeat scroll passes until this selector is visible on screen, then stop. Not valid with the top/bottom edge directions, which carry their own stop condition.`),durationMs:j(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:Ht}),...U(`scroll`)},is=()=>({noRecord:M(`Do not record this action.`),record:M(`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.`)}),as={format:O(N([`text`,`attrs`])),target:O(Dr()),...F(),...is()},os={predicate:O(N(be)),selector:O(k()),value:k(),...F(),...is()},ss={locator:N(ke),query:O(k()),action:N(qo),value:k(void 0,{allowEmpty:!0}),timeoutMs:j(),first:M(),last:M(),depth:j(),raw:M(),...is()},cs={kind:O(N(Ge,`Gesture variant.`)),direction:N(Be,`Fling direction.`),preset:N(Ue,`Swipe preset.`),origin:Or(`Gesture origin point.`),delta:Or(`Movement delta for pan or transform gestures.`),distance:j(`Fling distance.`,{min:0}),scale:A(`Pinch or transform scale.`),degrees:A(`Rotation in degrees.`),durationMs:j(`Pan/transform duration.`,{min:16,max:1e4}),pointerCount:j(`Pan touch pointer count (1 or 2).`,{min:1,max:2}),source:k(`Drag source @ref or selector.`),destination:k(`Drag destination @ref or selector.`),sourceHoldMs:j(`Drag activation hold duration.`,{min:1,max:1e4}),moveMs:j(`Drag movement duration.`,{min:16,max:1e4}),destinationHoldMs:j(`Hold before releasing at the destination.`,{min:0,max:1e4})},ls=[G(`click`,Yo),G(`press`,Xo),G(`fill`,Zo),G(`longpress`,Qo),G(`hover`,$o),G(`swipe`,es),G(`focus`,ts),G(`type`,ns),G(`scroll`,rs),G(`get`,as,{parseableOutput:!0}),G(`is`,os),G(`find`,ss,{parseableOutput:!0}),L(`gesture`,Jo.gesture,cs,{readInput:us})];function us(e){let t=hn(e);return{...jn(t),...We(t)}}function G(e,t,n){return L(e,Jo[e],t,n)}const ds={gesture:ps},fs={gesture:e=>{let t=us(e);return b(d.gesture,[],e,_(t))}};function ps(e,t){return{...x(t),...Ke(e,t.pointerCount)}}const K={click:(e,t)=>({...x(t),...Rn(t),...Vn(t),target:Hn(Ut(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...x(t),...Rn(t),...Vn(t),target:Hn(Ut(e)),verify:t.verify}),longpress:(e,t)=>{let n=ms(e);return{...x(t),...Rn(t),target:Hn(n),durationMs:n.durationMs}},hover:(e,t)=>({...x(t),...Rn(t),target:Hn(Ut(e))}),swipe:(e,t)=>({...x(t),...Je(e,{count:t.count,pauseMs:t.pauseMs,pattern:t.pattern})}),focus:(e,t)=>({...x(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...x(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=Wt(e);return{...x(t),...Rn(t),target:Hn(n.target),text:n.text,delayMs:t.delayMs,recordAs:t.recordAs,verify:t.verify}},scroll:(e,t)=>({...x(t),direction:vs(e[0]),amount:tr(e[1]),pixels:t.pixels,durationMs:t.durationMs,until:t.until}),get:(e,t)=>({...x(t),...In(t),...Rn(t),format:Yn(e[0]),target:Hn(Jn(e.slice(1)))})},q={click:e=>b(d.click,Un(e),{...e,clickButton:e.button}),press:y(d.press,e=>Un(e)),longpress:y(d.longPress,e=>hs(e)),hover:y(d.hover,e=>Un(e)),swipe:e=>(qe(e),b(d.swipe,[],e,{from:e.from,to:e.to,count:e.count,pauseMs:e.pauseMs,pattern:e.pattern})),focus:y(d.focus,e=>[String(e.x),String(e.y)]),type:y(d.type,e=>gs(e)),fill:y(d.fill,e=>_s(e)),scroll:y(d.scroll,e=>[D(e.direction,`scroll requires direction`),...T(e.amount)]),get:y(d.get,e=>[D(e.format,`get requires format`),...Wn(e)])};function ms(e){let t=ys(e);return{...Ut(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function hs(e){return[...Un(e),...T(e.durationMs)]}function gs(e){return[e.text]}function _s(e){return[...Un(e),e.text]}function vs(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 ys(e){if($n(e[0])&&$n(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&&$n(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function bs(e){return({input:t,result:n})=>{let r=e({input:t,result:n});return r instanceof Promise?r.then(xs):xs(r)}}function xs(e){return{data:e.data,text:Cs(e.text,e.data)}}function Ss(e){let t={...e};for(let[n,r]of Object.entries(e))Pe(n)&&(t[n]=bs(r));return t}function Cs(e,t){return`${e??``}${ws(t.settle)}`}function ws(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Os(t),...Ts(t),...Ds(t)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
|
|
14
|
+
`)}`}function Ts(e){let t=e.diff,n=(t?.lines??[]).map(t=>`${t.kind===`removed`?`-`:`+`} ${Es(t,e.refsGeneration)}`);return t?.truncated&&n.push(`… changed lines truncated`),n}function Es(e,t){let n=e.text??``,r=Ct(e.ref,t);if(!r||!e.ref)return n;let i=`@${e.ref}`;return n.startsWith(`${i} `)?`${r}${n.slice(i.length)}`:n}function Ds(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=Ct(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 Os(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 ks(e){let t=e.result;return e.format===`attrs`?{data:t,text:JSON.stringify(t.node??{},null,2)}:{data:t,text:typeof t.text==`string`?t.text:``}}function As(e){let t=e,n=St(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:js(t.matches,t.refsGeneration)};let r=Ct(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)}:p(t)}function js(e,t){return[`${e.length} match${e.length===1?``:`es`}:`,...e.map(e=>Ms(e,t))].join(`
|
|
15
|
+
`)}function Ms(e,t){let n=e.ref??``,r=n.startsWith(`@`)?n.slice(1):n,i=Ct(n,t)??`@${r}`,a=Ft(e.node?.type??`Element`),o=e.node?zt(e.node,a):``;return`= ${i} [${a}]${o?` "${o}"`:``}`}function Ns(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Ps(e){let t=e,n=t.ref??``,r=t.x,i=t.y;return!n||typeof r!=`number`||typeof i!=`number`?p(t):{data:t,text:`Tapped @${n} (${r}, ${i})`}}const J=Ss({click:f(Ps),press:f(Ps),fill:m,longpress:m,hover:m,scroll:m,get:({input:e,result:t})=>ks({result:t,format:e.format===`attrs`?`attrs`:`text`}),is:f(Ns),find:f(As)}),Fs={find:(e,t)=>zs(e,t),is:(e,t)=>Bs(e,t)},Is={is:y(d.is,e=>Ls(e)),find:e=>b(d.find,Rs(e),{...e,findFirst:e.first,findLast:e.last})};function Ls(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function Rs(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`,...T(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function zs(t,n){let r={...Ws(n),...Ln(n),...In(n),first:n.findFirst,last:n.findLast},i=Us(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:Gs(o)};if(c===`get`){let n=t[s+1];if(n===`text`)return{...r,locator:i,query:Gs(o),action:`getText`};if(n===`attrs`)return{...r,locator:i,query:Gs(o),action:`getAttrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...r,locator:i,query:Gs(o),action:`wait`,timeoutMs:tr(t[s+1])};if(c===`fill`||c===`type`){let n=t.slice(s+1);if(n.length===0)throw new e(`INVALID_ARGS`,c===`fill`?`find fill requires text (use "" to clear the field)`:`find type requires text`);return{...r,locator:i,query:Gs(o),action:c,value:n.join(` `)}}if(c===`click`||c===`focus`||c===`exists`||c===`list`)return{...r,locator:i,query:Gs(o),action:c};throw new e(`INVALID_ARGS`,`Unsupported find action: ${t[s]}`,{hint:Oe})}function Bs(t,n){let r={...zn(n),...Ln(n),...In(n)},i=Ee(t),a=Me(i[0]??``);if(!a.ok)throw new e(a.code,a.message,{hint:a.hint});let o=a.predicate;if(o===`absent`){let e=Vs(r);if(e)throw Hs(e)}let s=Xn(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 Vs(e){if(e.scope!==void 0)return`scope`;if(e.depth!==void 0)return`depth`}function Hs(t){return new e(`INVALID_ARGS`,t===`scope`?`is absent does not support --scope; it requires an unscoped capture`:`is absent does not support --depth; it requires a full-depth capture`,{command:`is`,predicate:`absent`,rejectedOption:t})}function Us(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function Ws(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function Gs(t){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,`find requires query`);return t}const Y={get:{usageOverride:`get text|attrs <@ref|selector>`,usageFlags:[],positionalArgs:[`subcommand`,`target`],allowsExtraPositionals:!0,allowedFlags:[...V,`record`]},find:{usageOverride:`find <locator|text> <action> [value] [--first|--last]`,usageFlags:[],positionalArgs:[`query`,`action`,`value?`],allowsExtraPositionals:!0,allowedFlags:[`snapshotDepth`,`snapshotRaw`,`findFirst`,`findLast`,`record`]},is:{positionalArgs:[`predicate`,`selector`,`value?`],allowsExtraPositionals:!0,allowedFlags:[...V,`record`]},click:{usageOverride:`click <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...wi,`clickButton`,...W(`click`),...V]},press:{usageOverride:`press <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...wi,...W(`press`),...V]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...W(`longpress`),...V]},hover:{usageOverride:`hover <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...W(`hover`),...V]},swipe:{positionalArgs:[`x1`,`y1`,`x2`,`y2`],allowsExtraPositionals:!0,allowedFlags:[`count`,`pauseMs`,`pattern`]},gesture:{usageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform|drag> ...`,usageFlags:[],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>`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrText`,`text?`],allowsExtraPositionals:!0,allowedFlags:[...V,`delayMs`,`recordAs`,...W(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount]`,usageFlags:[`until`,`pixels`,`durationMs`,`settle`],positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`,`until`,...W(`scroll`)]}},Ks=z({name:`interaction`,clientSurface:!1,commands:[R({name:`click`,text:{summary:`Click or tap a UI target`},metadata:X(`click`),run:(e,t)=>e.interactions.click(qs(t)),cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),R({name:`press`,text:{summary:`Short-press a UI target`,cliDetail:`The hold duration is positional on longpress, not press --hold-ms.`},metadata:X(`press`),run:(e,t)=>e.interactions.press(Js(t)),cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),R({name:`fill`,text:{summary:`Replace text in a UI input`,cliDetail:`Every positional after an @ref is the replacement text, so fill @e57 good morning enters "good morning"; quote the text when the shell must preserve exact whitespace. Clear a field with an empty text argument: fill @e57 "" (the argument must be present — fill @e57 alone is a missing argument, not a clear). When visible label text also matches a non-input element, constrain the target with editable=true, for example fill 'label="Email" editable=true' "qa@example.com".`},metadata:X(`fill`),run:(e,t)=>e.interactions.fill(Ys(t)),cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),R({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:X(`longpress`),run:(e,t)=>e.interactions.longPress(Xs(t)),cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),R({name:`hover`,text:{summary:`Hover the pointer over a UI target (web only)`,cliDetail:`The pointer stays where hover left it: read the revealed UI (--settle or snapshot -i) and act on it before another click or hover moves the pointer away.`},metadata:X(`hover`),run:(e,t)=>e.interactions.hover(Zs(t)),cliSchema:Y.hover,cliReader:K.hover,daemonWriter:q.hover,cliOutputFormatter:J.hover}),R({name:`swipe`,text:{summary:`Fling between coordinates`},metadata:X(`swipe`),run:(e,t)=>e.interactions.swipe(t),cliSchema:Y.swipe,cliReader:K.swipe,daemonWriter:q.swipe}),R({name:`focus`,text:{summary:`Focus input at screen coordinates`},metadata:X(`focus`),run:(e,t)=>e.interactions.focus(t),cliSchema:Y.focus,cliReader:K.focus,daemonWriter:q.focus}),R({name:`type`,text:{summary:`Append text to the focused input`},metadata:X(`type`),run:(e,t)=>e.interactions.type(t),cliSchema:Y.type,cliReader:K.type,daemonWriter:q.type}),R({name:`scroll`,text:{summary:`Scroll in a direction or to an edge`},metadata:X(`scroll`),run:(e,t)=>e.interactions.scroll(t),cliSchema:Y.scroll,cliReader:K.scroll,daemonWriter:q.scroll,cliOutputFormatter:J.scroll}),R({name:`get`,text:{summary:`Read element text or attributes`},metadata:X(`get`),run:(e,t)=>e.interactions.get($s(t)),cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),R({name:`is`,text:{summary:`Check a UI predicate on a selector`},metadata:X(`is`),run:(e,t)=>e.interactions.is(t),cliSchema:Y.is,cliReader:Fs.is,daemonWriter:Is.is,cliOutputFormatter:J.is}),R({name:`find`,text:{summary:`Find an element and act`},metadata:X(`find`),run:(e,t)=>e.interactions.find(t),cliSchema:Y.find,cliReader:Fs.find,daemonWriter:Is.find,cliOutputFormatter:J.find}),R({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:X(`gesture`),run:async(e,t)=>{switch(t.kind){case`pan`:return await e.interactions.pan(ec(t));case`fling`:return await e.interactions.fling(nc(t));case`swipe`:return await e.interactions.swipeGesture(rc(t));case`pinch`:return await e.interactions.pinch(ic(t));case`rotate`:return await e.interactions.rotateGesture(ac(t));case`transform`:return await e.interactions.transformGesture(oc(t));case`drag`:return await e.interactions.drag(tc(t))}},cliSchema:Y.gesture,cliReader:ds.gesture,daemonWriter:fs.gesture})]});function X(e){let t=ls.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function qs(e){return{...v(e),...Fr(e.target),...Rr(e),...Lr(e),button:e.button,verify:e.verify,...Qs(e)}}function Js(e){return{...v(e),...Fr(e.target),...Rr(e),...Lr(e),verify:e.verify,...Qs(e)}}function Ys(e){return{...v(e),...Fr(e.target),...Rr(e),text:e.text,delayMs:e.delayMs,recordAs:e.recordAs,verify:e.verify,...Qs(e)}}function Xs(e){return{...v(e),...Fr(e.target),...Rr(e),durationMs:e.durationMs,...Qs(e)}}function Zs(e){return{...v(e),...Fr(e.target),...Rr(e),...Qs(e)}}function Qs(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function $s(e){return{...v(e),...Ir(e.target),...Rr(e),format:e.format,record:e.record}}function ec(e){return{...v(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,pointerCount:e.pointerCount,durationMs:e.durationMs}}function tc(e){return{...v(e),source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}}function nc(e){return{...v(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance}}function rc(e){return{...v(e),preset:e.preset}}function ic(e){return{...v(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function ac(e){return{...v(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y}}function oc(e){return{...v(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}}async function sc(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{devices:e.map(t)},text:e.map(xc).join(`
|
|
16
|
+
`)}}async function cc(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{device:t(e.device),availableCommands:e.availableCommands},text:[`${xc(e.device)} supports ${e.availableCommands.length} commands:`,e.availableCommands.join(` `)].join(`
|
|
17
|
+
`)}}function lc(e){return{data:{apps:e.result},stderr:e.appsFilter===`all`?`Showing all apps, including system apps.
|
|
18
18
|
`:`Showing user-installed apps or deferred provider app assets. Use --all to include system apps on a live device.
|
|
19
19
|
`,text:e.result.length>0?e.result.join(`
|
|
20
|
-
`):e.appsFilter===`all`?`No apps found.`:`No user apps or provider app assets found.`}}async function
|
|
21
|
-
`)||null}}async function
|
|
22
|
-
`):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=
|
|
20
|
+
`):e.appsFilter===`all`?`No apps found.`:`No user apps or provider app assets found.`}}async function uc(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{serializeSessionListEntry:t}=await import(`./result-serialization.js`).then(e=>e.t),n={sessions:e.sessions.map(t)};return{data:n,text:JSON.stringify(n,null,2)}}async function dc(e){let{serializeOpenResult:t}=await import(`./result-serialization.js`).then(e=>e.t),n=t(e),r=[St(n)].filter(e=>!!e);typeof n.sessionStateDir==`string`&&r.push(`Session state: ${n.sessionStateDir}`);for(let t of e.warnings??[])r.push(`Warning: ${t}`);let i=await fc(e.snapshot);return i&&(n.snapshot=i.jsonData??i.data,i.text&&r.push(i.text)),{data:n,...i?.stderr?{stderr:i.stderr}:{},text:r.join(`
|
|
21
|
+
`)||null}}async function fc(e){return!e||!Array.isArray(e.nodes)?null:await go({result:e,interactiveOnly:!0})}async function pc(e){let{serializeCloseResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return p(t(e))}function mc(e){if(hc(e))return{data:e,text:e.artifacts.length>0?e.artifacts.map(Cc).join(`
|
|
22
|
+
`):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=wc(e);return n&&t.push(`Retry: ${n}`),{data:e,text:e.cloudArtifacts.length>0?e.cloudArtifacts.map(Sc).join(`
|
|
23
23
|
`):t.join(`
|
|
24
|
-
`)}}function
|
|
25
|
-
`)}}const Z={boot:d(_c),shutdown:d(vc),devices:d(oc),capabilities:d(sc),doctor:({result:e,progress:t})=>yc(e,t),apps:({input:e,result:t})=>cc({result:t,appsFilter:e.appsFilter}),session:d(lc),artifacts:d(pc),open:d(uc),close:d(fc),install:d(hc),reinstall:d(hc),"install-from-source":d(gc),prepare:p,viewport:p};function bc(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``,i=e.claimedBy?` claimed by session "${e.claimedBy.session}" in ${e.claimedBy.workspace}`:``;return`${e.name} (${e.platform}${t}${n})${r}${i}`}function xc(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Sc(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Cc(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function wc(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const Tc=R({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:L(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:k(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:k(`Cloud provider session id or ARN.`)}),run:(e,t)=>e.sessions.artifacts(t),cliSchema:{usageOverride:`artifacts [provider-session-id]`,usageFlags:[`provider`],positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...x(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:y(u.artifacts),cliOutputFormatter:Z.artifacts});function Ec(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 Dc(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=Ec({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const Oc=L(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:N([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),kc=L(`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:k(`App name, bundle id, package, or URL.`),url:k(`Optional URL passed with an app shell.`),surface:N(st,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:k(`Android activity name.`),launchConsole:k(`Launch console mode.`),launchArgs:Cr(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:M(`Force relaunch.`),timeoutMs:j(`Startup budget in milliseconds. Bounds the Simulator boot wait, so a never-booted Simulator can finish its first-boot migration; omit for the default startup behavior.`,{min:1}),waitMs:vr(`waitMs`),foreground:vr(`foreground`),saveScript:P({oneOf:[pr(),ur()]}),force:M(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),deviceHub:M(`Use Xcode Device Hub when surfacing Apple simulators.`),testIme:M(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:M(`Do not record this action.`),metroHost:k(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:j(`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:k(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:k(`Session-scoped launch URL hint applied to the opened app.`)}),Ac=L(`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:k(`Optional app to close.`),shutdown:M(`Shutdown the session/device where supported.`),saveScript:P({oneOf:[pr(),ur()]}),force:M(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)});function jc(e){return Dc(e)}const Mc={allowedFlags:[`appsFilter`]},Nc={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`timeoutMs`,`waitMs`,`surface`,...Si,`launchUrl`]},Pc={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},Fc=(e,t)=>({...x(t),appsFilter:Gt(t.appsFilter)}),Ic=(e,t)=>({...x(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,timeoutMs:t.timeoutMs,waitMs:t.waitMs,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}),Lc=(e,t)=>({...x(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),Rc=y(u.apps),zc=y(u.open,Gc),Bc=y(u.close,e=>w(e.app)),Vc=R({name:`apps`,text:{summary:`List installed apps or deferred provider app assets`,cliDetail:`Before provider allocation, lists uploaded app assets when the selected provider exposes a catalog. On a live device, defaults to user-installed apps; use --all to include system/OEM apps.`},metadata:Oc,run:(e,t)=>e.apps.list(t),cliSchema:Mc,cliReader:Fc,daemonWriter:Rc,cliOutputFormatter:Z.apps}),Hc=R({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. A device another session is holding refuses at once; add --wait <ms> to block up to that budget for it and only then fail with DEVICE_IN_USE naming the owning session.`,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:kc,run:(e,t)=>e.apps.open(jc(t)),cliSchema:Nc,cliReader:Ic,daemonWriter:zc,cliOutputFormatter:Z.open}),Uc=R({name:`close`,text:{summary:`Close an app or end the session`},metadata:Ac,run:(e,t)=>t.app?e.apps.close(t):e.sessions.close(Wc(t)),cliSchema:Pc,cliReader:Lc,daemonWriter:Bc,cliOutputFormatter:Z.close});function Wc(e){let{app:t,...n}=e;return n}function Gc(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const Kc=L(`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.`,{}),qc=L(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),Jc=L(`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:M(`Boot without showing simulator UI when supported.`)}),Yc=L(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),Xc={allowedFlags:[`headless`]},Zc={},Qc={},$c={},el=(e,t)=>x(t),tl=(e,t)=>({...x(t),headless:t.headless}),nl=y(u.devices),rl=y(u.capabilities),il=y(u.boot),al=y(u.shutdown),ol=[R({name:`devices`,text:{summary:`List available devices and simulators`},metadata:Kc,run:(e,t)=>e.devices.list(t),cliSchema:Zc,cliReader:el,daemonWriter:nl,cliOutputFormatter:Z.devices}),R({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:qc,run:(e,t)=>e.devices.capabilities(t),cliSchema:Qc,cliReader:el,daemonWriter:rl,cliOutputFormatter:Z.capabilities}),R({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:Jc,run:(e,t)=>e.devices.boot(t),cliSchema:Xc,cliReader:tl,daemonWriter:il,cliOutputFormatter:Z.boot}),R({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:Yc,run:(e,t)=>e.devices.shutdown(t),cliSchema:$c,cliReader:el,daemonWriter:al,cliOutputFormatter:Z.shutdown})],sl=R({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:L(`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:k(`Installed app package/bundle id or app name to verify without opening a session.`),remote:M(`Check remote connection setup instead of local device inventory.`)}),run:(e,t)=>e.command.doctor(t),cliSchema:{usageOverride:`doctor [--platform ios|android|harmonyos|vega|macos|linux|web|apple]`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...x(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:y(u.doctor),cliOutputFormatter:Z.doctor});function cl(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}=dl(t.slice(0,r),n);return ul(i,a,t.slice(r+1),`${n} artifact`)}function ll(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(pl(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}=dl(pl(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return ul(i,a,r.artifact,`${n} installSource.artifact`)}function ul(e,t,n,r){return typeof n==`number`||hl(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:ml(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:pl(n,r)}}function dl(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 fl(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function pl(t,n){let r=fl(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function ml(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 hl(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const gl=L(`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:k(`Optional app identifier hint.`),appPath:O(k(`Path to app binary.`))}),_l=L(`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:O(k()),appPath:O(k(`Path to app binary.`))}),vl=L(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:O(P(hr(`Install source object.`))),retainPaths:M(),retentionMs:j()}),yl={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},bl={positionalArgs:[`app`,`path`]},xl={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,usageFlags:[],listUsageOverride:`install-from-source`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},Sl=(e,t)=>Ol(e,t),Cl=(e,t)=>kl(e,t),wl=(e,t)=>({...x(t),source:Ml(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),Tl=y(u.install,e=>Al(e.app,e.appPath)),El=y(u.reinstall,e=>jl(e.app,e.appPath)),Dl=[R({name:`install`,text:{summary:`Install an app binary from a path`},metadata:gl,run:(e,t)=>e.apps.install(t),cliSchema:yl,cliReader:Sl,daemonWriter:Tl,cliOutputFormatter:Z.install}),R({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:_l,run:(e,t)=>e.apps.reinstall(t),cliSchema:bl,cliReader:Cl,daemonWriter:El,cliOutputFormatter:Z.reinstall}),R({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:vl,run:(e,t)=>e.apps.installFromSource(t),cliSchema:xl,cliReader:wl,daemonWriter:e=>b(at.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function Ol(e,t){let[n,r]=e,i=r!==void 0;return{...x(t),...i?{app:E(n,`install requires app`)}:{},appPath:E(i?r:n,`install requires path`)}}function kl(e,t){return{...x(t),app:E(e[0],`reinstall requires app`),appPath:E(e[1],`reinstall requires path`)}}function Al(e,t){let n=D(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function jl(e,t){return[D(e,`missing first positional`),D(t,`missing second positional`)]}function Ml(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?cl(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:Nl(n.header)}}function Nl(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 Pl=R({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:L(`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:O(N([`ios-runner`])),timeoutMs:j(`Maximum wall-clock time for the prepare command.`)}),run:(e,t)=>e.command.prepare(t),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos`,listUsageOverride:`prepare`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...x(t),action:E(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:y(u.prepare,e=>[D(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),Fl=L(`push`,`Deliver push notification payloads to an installed app.`,{app:O(k()),payload:O(P({oneOf:[ur(),hr()]}))}),Il=L(`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:O(k(`Name of an app-defined automation or test event the app documents.`)),payload:Kl(`Structured payload passed to the event, in the shape the app documents for it.`)}),Ll={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},Rl={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},zl=(e,t)=>({...x(t),app:E(e[0],`push requires bundleOrPackage`),payload:E(e[1],`push requires payloadOrJson`)}),Bl=(e,t)=>({...x(t),event:E(e[0],`trigger-app-event requires event`),payload:e[1]?Xn(e[1],`trigger-app-event payload`):void 0}),Vl=y(u.push,e=>Wl(e)),Hl=y(u.triggerAppEvent,e=>Gl(e)),Ul=[R({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:Fl,run:(e,t)=>e.apps.push(t),cliSchema:Ll,cliReader:zl,daemonWriter:Vl}),R({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:Il,run:(e,t)=>e.apps.triggerEvent(t),cliSchema:Rl,cliReader:Bl,daemonWriter:Hl})];function Wl(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function Gl(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function Kl(e){return Sr(e)}const ql=R({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:L(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:N([`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:k(`Optional .ad output path for save-script.`),force:M(`Atomically replace an existing save-script target.`)}),run:async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return Yl(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]`,usageFlags:[],listUsageOverride:`session`,positionalArgs:[`list|state-dir|save-script?`,`path?`],allowedFlags:[`force`]},cliReader:(e,t)=>({...x(t),action:Jl(e[0]),path:e[1],force:t.force}),cliOutputFormatter:Z.session});function Jl(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 Yl(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 Xl=R({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:L(`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:O(j(`Viewport width in CSS pixels.`,{min:1})),height:O(j(`Viewport height in CSS pixels.`,{min:1}))}),run:(e,t)=>e.command.viewport(t),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...x(t),...he(e)}),daemonWriter:y(u.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),Zl=z({name:`management`,commands:[...ol,Tc,sl,Pl,Vc,ql,Hc,Uc,Xl,...Dl,...Ul]});function Ql(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const $l={metro:({input:e,result:t})=>Ql({result:t,action:e.action})},eu=`metro`,tu=z({name:`metro`,commands:[R({name:eu,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:L(eu,`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:O(N([`prepare`,`reload`])),projectRoot:k(),kind:P(ur()),publicBaseUrl:k(),proxyBaseUrl:_r(k(),{operatorPath:`Configure the remote proxy in the remote-config profile or operator config for the process serving these tools.`}),bearerToken:_r(k(),{envFlagKeys:[`metroBearerToken`,`daemonAuthToken`]}),bridgeScope:P({type:`object`,additionalProperties:!0}),launchUrl:k(),port:j(),listenHost:k(),statusHost:k(),startupTimeoutMs:j(),probeTimeoutMs:j(),reuseExisting:M(),installDependenciesIfNeeded:M(),runtimeFilePath:k(),logPath:k(),metroHost:k(),metroPort:j(),bundleUrl:k(),timeoutMs:j()}),run:async(e,t)=>t.action===`prepare`?await e.metro.prepare(nu(t)):await e.metro.reload(iu(t)),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo|repack]
|
|
26
|
-
agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,usageFlags:[],listUsageOverride:`metro`,positionalArgs:[`prepare|reload`],allowedFlags:[...Si
|
|
27
|
-
`),stderr:
|
|
28
|
-
`),stderr:
|
|
29
|
-
`)}function
|
|
30
|
-
`):void 0}function
|
|
31
|
-
`)||void 0}const
|
|
32
|
-
`)}function
|
|
33
|
-
`)}`:r}function
|
|
34
|
-
`)}function
|
|
35
|
-
`)}`:n}function
|
|
24
|
+
`)}}function hc(e){return`source`in e&&e.source===`daemon`}async function gc(e){let{serializeDeployResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return p(t(e))}async function _c(e){let{serializeInstallFromSourceResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return p(t(e))}function vc(e){let t=e,n=t.platform??`unknown`;return{data:t,text:`Boot ready: ${t.device??t.id??`unknown`} (${n})`}}function yc(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})`}}async function bc(e,t){let{formatDoctorCheckDetailLines:n,formatDoctorCheckSummaryLine:r}=await import(`./doctor-output.js`).then(e=>e.t),i=e,a=[`Doctor: ${typeof i.status==`string`?i.status:`unknown`}`],o=Tc(i.checks);if(t?.renderedToStderr){let e=typeof i.summary==`string`?i.summary:void 0;e&&a.push(e)}else if(o.length===0){let e=typeof i.summary==`string`?i.summary:`No blockers found.`;a.push(e)}else for(let e of o)a.push(r(e)),a.push(...n(e));return{data:i,text:a.join(`
|
|
25
|
+
`)}}const Z={boot:f(vc),shutdown:f(yc),devices:f(sc),capabilities:f(cc),doctor:({result:e,progress:t})=>bc(e,t),apps:({input:e,result:t})=>lc({result:t,appsFilter:e.appsFilter}),session:f(uc),artifacts:f(mc),open:f(dc),close:f(pc),install:f(gc),reinstall:f(gc),"install-from-source":f(_c),prepare:m,viewport:m};function xc(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``,i=e.claimedBy?` claimed by session "${e.claimedBy.session}" in ${e.claimedBy.workspace}`:``;return`${e.name} (${e.platform}${t}${n})${r}${i}`}function Sc(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Cc(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function wc(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function Tc(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const Ec=R({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:L(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:k(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:k(`Cloud provider session id or ARN.`)}),run:(e,t)=>e.sessions.artifacts(t),cliSchema:{usageOverride:`artifacts [provider-session-id]`,usageFlags:[`provider`],positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...x(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:y(d.artifacts),cliOutputFormatter:Z.artifacts});function Dc(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 Oc(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=Dc({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const kc=L(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:N([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),Ac=L(`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:k(`App name, bundle id, package, or URL.`),url:k(`Optional URL passed with an app shell.`),surface:N(ot,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:k(`Android activity name.`),launchConsole:k(`Launch console mode.`),launchArgs:wr(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:M(`Force relaunch.`),timeoutMs:j(`Startup budget in milliseconds. Bounds the Simulator boot wait, so a never-booted Simulator can finish its first-boot migration; omit for the default startup behavior.`,{min:1}),waitMs:yr(`waitMs`),foreground:yr(`foreground`),saveScript:P({oneOf:[mr(),dr()]}),force:M(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),deviceHub:M(`Use Xcode Device Hub when surfacing Apple simulators.`),testIme:M(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:M(`Do not record this action.`),metroHost:k(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:j(`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:k(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:k(`Session-scoped launch URL hint applied to the opened app.`)}),jc=L(`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:k(`Optional app to close.`),shutdown:M(`Shutdown the session/device where supported.`),saveScript:P({oneOf:[mr(),dr()]}),force:M(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)});function Mc(e){return Oc(e)}const Nc={allowedFlags:[`appsFilter`]},Pc={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`timeoutMs`,`waitMs`,`surface`,...Ci,`launchUrl`]},Fc={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},Ic=(e,t)=>({...x(t),appsFilter:Gt(t.appsFilter)}),Lc=(e,t)=>({...x(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,timeoutMs:t.timeoutMs,waitMs:t.waitMs,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}),Rc=(e,t)=>({...x(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),zc=y(d.apps),Bc=y(d.open,Kc),Vc=y(d.close,e=>w(e.app)),Hc=R({name:`apps`,text:{summary:`List installed apps or deferred provider app assets`,cliDetail:`Before provider allocation, lists uploaded app assets when the selected provider exposes a catalog. On a live device, defaults to user-installed apps; use --all to include system/OEM apps.`},metadata:kc,run:(e,t)=>e.apps.list(t),cliSchema:Nc,cliReader:Ic,daemonWriter:zc,cliOutputFormatter:Z.apps}),Uc=R({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. A device another session is holding refuses at once; add --wait <ms> to block up to that budget for it and only then fail with DEVICE_IN_USE naming the owning session.`,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:Ac,run:(e,t)=>e.apps.open(Mc(t)),cliSchema:Pc,cliReader:Lc,daemonWriter:Bc,cliOutputFormatter:Z.open}),Wc=R({name:`close`,text:{summary:`Close an app or end the session`},metadata:jc,run:(e,t)=>t.app?e.apps.close(t):e.sessions.close(Gc(t)),cliSchema:Fc,cliReader:Rc,daemonWriter:Vc,cliOutputFormatter:Z.close});function Gc(e){let{app:t,...n}=e;return n}function Kc(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const qc=L(`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.`,{}),Jc=L(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),Yc=L(`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:M(`Boot without showing simulator UI when supported.`)}),Xc=L(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),Zc={allowedFlags:[`headless`]},Qc={},$c={},el={},tl=(e,t)=>x(t),nl=(e,t)=>({...x(t),headless:t.headless}),rl=y(d.devices),il=y(d.capabilities),al=y(d.boot),ol=y(d.shutdown),sl=[R({name:`devices`,text:{summary:`List available devices and simulators`},metadata:qc,run:(e,t)=>e.devices.list(t),cliSchema:Qc,cliReader:tl,daemonWriter:rl,cliOutputFormatter:Z.devices}),R({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:Jc,run:(e,t)=>e.devices.capabilities(t),cliSchema:$c,cliReader:tl,daemonWriter:il,cliOutputFormatter:Z.capabilities}),R({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:Yc,run:(e,t)=>e.devices.boot(t),cliSchema:Zc,cliReader:nl,daemonWriter:al,cliOutputFormatter:Z.boot}),R({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:Xc,run:(e,t)=>e.devices.shutdown(t),cliSchema:el,cliReader:tl,daemonWriter:ol,cliOutputFormatter:Z.shutdown})],cl=R({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:L(`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:k(`Installed app package/bundle id or app name to verify without opening a session.`),remote:M(`Check remote connection setup instead of local device inventory.`)}),run:(e,t)=>e.command.doctor(t),cliSchema:{usageOverride:`doctor [--platform ios|android|harmonyos|vega|macos|linux|web|apple]`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...x(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:y(d.doctor),cliOutputFormatter:Z.doctor});function ll(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}=fl(t.slice(0,r),n);return dl(i,a,t.slice(r+1),`${n} artifact`)}function ul(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(ml(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}=fl(ml(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return dl(i,a,r.artifact,`${n} installSource.artifact`)}function dl(e,t,n,r){return typeof n==`number`||gl(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:hl(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:ml(n,r)}}function fl(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 pl(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function ml(t,n){let r=pl(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function hl(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 gl(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const _l=L(`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:k(`Optional app identifier hint.`),appPath:O(k(`Path to app binary.`))}),vl=L(`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:O(k()),appPath:O(k(`Path to app binary.`))}),yl=L(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:O(P(gr(`Install source object.`))),retainPaths:M(),retentionMs:j()}),bl={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},xl={positionalArgs:[`app`,`path`]},Sl={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,usageFlags:[],listUsageOverride:`install-from-source`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},Cl=(e,t)=>kl(e,t),wl=(e,t)=>Al(e,t),Tl=(e,t)=>({...x(t),source:Nl(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),El=y(d.install,e=>jl(e.app,e.appPath)),Dl=y(d.reinstall,e=>Ml(e.app,e.appPath)),Ol=[R({name:`install`,text:{summary:`Install an app binary from a path`},metadata:_l,run:(e,t)=>e.apps.install(t),cliSchema:bl,cliReader:Cl,daemonWriter:El,cliOutputFormatter:Z.install}),R({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:vl,run:(e,t)=>e.apps.reinstall(t),cliSchema:xl,cliReader:wl,daemonWriter:Dl,cliOutputFormatter:Z.reinstall}),R({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:yl,run:(e,t)=>e.apps.installFromSource(t),cliSchema:Sl,cliReader:Tl,daemonWriter:e=>b(tt.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function kl(e,t){let[n,r]=e,i=r!==void 0;return{...x(t),...i?{app:E(n,`install requires app`)}:{},appPath:E(i?r:n,`install requires path`)}}function Al(e,t){return{...x(t),app:E(e[0],`reinstall requires app`),appPath:E(e[1],`reinstall requires path`)}}function jl(e,t){let n=D(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function Ml(e,t){return[D(e,`missing first positional`),D(t,`missing second positional`)]}function Nl(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?ll(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:Pl(n.header)}}function Pl(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 Fl=R({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:L(`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:O(N([`ios-runner`])),timeoutMs:j(`Maximum wall-clock time for the prepare command.`)}),run:(e,t)=>e.command.prepare(t),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos`,listUsageOverride:`prepare`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...x(t),action:E(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:y(d.prepare,e=>[D(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),Il=L(`push`,`Deliver push notification payloads to an installed app.`,{app:O(k()),payload:O(P({oneOf:[dr(),gr()]}))}),Ll=L(`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:O(k(`Name of an app-defined automation or test event the app documents.`)),payload:ql(`Structured payload passed to the event, in the shape the app documents for it.`)}),Rl={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},zl={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},Bl=(e,t)=>({...x(t),app:E(e[0],`push requires bundleOrPackage`),payload:E(e[1],`push requires payloadOrJson`)}),Vl=(e,t)=>({...x(t),event:E(e[0],`trigger-app-event requires event`),payload:e[1]?Zn(e[1],`trigger-app-event payload`):void 0}),Hl=y(d.push,e=>Gl(e)),Ul=y(d.triggerAppEvent,e=>Kl(e)),Wl=[R({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:Il,run:(e,t)=>e.apps.push(t),cliSchema:Rl,cliReader:Bl,daemonWriter:Hl}),R({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:Ll,run:(e,t)=>e.apps.triggerEvent(t),cliSchema:zl,cliReader:Vl,daemonWriter:Ul})];function Gl(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function Kl(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function ql(e){return Cr(e)}const Jl=R({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:L(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:N([`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:k(`Optional .ad output path for save-script.`),force:M(`Atomically replace an existing save-script target.`)}),run:async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return Xl(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]`,usageFlags:[],listUsageOverride:`session`,positionalArgs:[`list|state-dir|save-script?`,`path?`],allowedFlags:[`force`]},cliReader:(e,t)=>({...x(t),action:Yl(e[0]),path:e[1],force:t.force}),cliOutputFormatter:Z.session});function Yl(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 Xl(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 Zl=R({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:L(`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:O(j(`Viewport width in CSS pixels.`,{min:1})),height:O(j(`Viewport height in CSS pixels.`,{min:1}))}),run:(e,t)=>e.command.viewport(t),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...x(t),...me(e)}),daemonWriter:y(d.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),Ql=z({name:`management`,commands:[...sl,Ec,cl,Fl,Hc,Jl,Uc,Wc,Zl,...Ol,...Wl]});function $l(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const eu={metro:({input:e,result:t})=>$l({result:t,action:e.action})},tu=`metro`,nu=z({name:`metro`,commands:[R({name:tu,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:L(tu,`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:O(N([`prepare`,`reload`])),projectRoot:k(),kind:P(dr()),publicBaseUrl:k(),proxyBaseUrl:vr(k(),{operatorPath:`Configure the remote proxy in the remote-config profile or operator config for the process serving these tools.`}),bearerToken:vr(k(),{envFlagKeys:[`metroBearerToken`,`daemonAuthToken`]}),bridgeScope:P({type:`object`,additionalProperties:!0}),launchUrl:k(),port:j(),listenHost:k(),statusHost:k(),startupTimeoutMs:j(),probeTimeoutMs:j(),reuseExisting:M(),installDependenciesIfNeeded:M(),runtimeFilePath:k(),logPath:k(),metroHost:k(),metroPort:j(),bundleUrl:k(),timeoutMs:j()}),run:async(e,t)=>t.action===`prepare`?await e.metro.prepare(ru(t)):await e.metro.reload(au(t)),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo|repack]
|
|
26
|
+
agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,usageFlags:[],listUsageOverride:`metro`,positionalArgs:[`prepare|reload`],allowedFlags:[...Ci,...Si]},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:Zt(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&&void 0,installDependenciesIfNeeded:!n.metroNoInstallDeps&&void 0,runtimeFilePath:n.metroRuntimeFile}},cliOutputFormatter:eu.metro})]});function ru(e){return{projectRoot:e.projectRoot,kind:e.kind,publicBaseUrl:e.publicBaseUrl,proxyBaseUrl:e.proxyBaseUrl,bearerToken:e.bearerToken,bridgeScope:e.bridgeScope??iu(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 iu(e){return e.tenant&&e.runId&&e.leaseId?{tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId}:void 0}function au(e){return{metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,timeoutMs:e.timeoutMs}}function ou(e,t){return e.includes(t)}function su(t,n,r={}){let i=n===void 0?void 0:r.normalize?.(n)??n;if(i!==void 0&&ou(t,i))return i;let a=typeof r.message==`function`?r.message(n):r.message;throw new e(`INVALID_ARGS`,a??`Invalid value: ${n}. Use ${t.join(`|`)}.`)}const cu=[`started`,`stopped`,`marked`,`cleared`,`restarted`,`removedRotatedFiles`];function lu(e){return{data:e,text:e.path,stderr:Lu([Fu(e,[`active`,`state`,`backend`,`sizeBytes`]),Du(e),e.hint,Iu(e.notes)])}}function uu(e){let t=e.events??[];return{data:e,text:t.length>0?mu(t):`No session events found.`,stderr:Lu([Fu(e,[`path`,`cursor`,`nextCursor`,`limit`])])}}function du(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(...Mu(e));return{data:e,text:t.join(`
|
|
27
|
+
`),stderr:Lu([Fu(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),Iu(e.notes)])}}function fu(e){return{data:e,text:[`Audio probe: ${String(e.state??`stopped`)} heard=${String(e.heard===!0)}`,Eu(`rmsDbfs`,e.rmsDbfs),Eu(`peakDbfs`,e.peakDbfs)].filter(e=>!!e).join(`
|
|
28
|
+
`),stderr:Lu([Fu(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),Iu(e.notes)])}}const pu={logs:f(lu),events:f(uu),network:f(du),audio:f(fu)};function mu(e){let t=e.map(hu),n=Math.min(Math.max(...t.map(e=>e.label.length),5),32);return t.map(e=>gu(e,n)).join(`
|
|
29
|
+
`)}function hu(e){return{timestamp:_u(e.ts),label:vu(e),summary:yu(e)}}function gu(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 _u(e){return e?e.replace(`T`,` `):``}function vu(e){let t=e.command??`command`;switch(e.kind){case`request.started`:return`start ${t}`;case`request.finished`:return ku([e.status===`error`?`error`:`ok`,t,Tu(ju(e.details?.durationMs))]);case`action.recorded`:return`action ${t}`;default:return ku([e.kind??`event`,e.command])}}function yu(e){let t=bu(e.summary,e);return`${t}${xu(e,t)}`.trim()}function bu(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 xu(e,t){if(e.kind!==`action.recorded`)return``;let n=e.details;if(!n)return``;let r=[Su(n,t),wu(ju(n.textLength))].filter(e=>!!e);return r.length>0?` (${r.join(`, `)})`:``}function Su(e,t){let n=Au(e.ref)??Au(e.selector)??Cu(e);if(!(!n||t.includes(n)))return`target=${n}`}function Cu(e){let t=ju(e.x),n=ju(e.y);return t===void 0||n===void 0?void 0:`(${t}, ${n})`}function wu(e){return e===void 0?void 0:`text=${e} chars`}function Tu(e){return e===void 0?void 0:`${Math.round(e)}ms`}function Eu(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 Du(e){return cu.map(t=>Ou(t,e[t])).filter(Boolean).join(` `)||void 0}function Ou(e,t){return t==null?``:`${e}=${t}`}function ku(e){return e.filter(e=>!!e).join(` `)}function Au(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function ju(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Mu(e){let t=e.method??`HTTP`,n=e.url??`<unknown-url>`,r=e.status===void 0?``:` status=${e.status}`,i=e.timestamp?`${e.timestamp} `:``,a=e.durationMs===void 0?``:` durationMs=${e.durationMs}`,o=[`${i}${t} ${n}${`pathUnavailable`in e&&e.pathUnavailable?` (request path not logged)`:``}${r}${a}`];return e.headers?Pu(o,`headers`,e.headers):(Nu(o,`request headers`,e.requestHeaders),Nu(o,`response headers`,e.responseHeaders)),Pu(o,`request`,e.requestBody),Pu(o,`response`,e.responseBody),o}function Nu(e,t,n){!n||Object.keys(n).length===0||e.push(` ${t}: ${JSON.stringify(n)}`)}function Pu(e,t,n){n!==void 0&&e.push(` ${t}: ${n}`)}function Fu(e,t){return t.map(t=>e[t]!==void 0&&e[t]!==null?`${t}=${e[t]}`:``).filter(Boolean).join(` `)||void 0}function Iu(e){let t=e?.filter(e=>e.length>0)??[];return t.length>0?t.join(`
|
|
30
|
+
`):void 0}function Lu(e){return e.filter(e=>!!e).join(`
|
|
31
|
+
`)||void 0}const Ru=`logs`,zu=`events`,Bu=`network`,Vu=`audio`,Hu=[`dump`,`log`],Uu=[`probe`],Wu=[`start`,`status`,`stop`],Gu=L(Ru,`Session app log info, start/stop streaming, diagnostics, and markers`,{action:N(on),message:k(),restart:M()}),Ku=L(zu,`Read the daemon-owned session event timeline as paged JSON-friendly entries`,{limit:j(),cursor:k()}),qu=L(Bu,`Dump recent HTTP(s) traffic parsed from the session app log`,{action:N(Hu),limit:j(),include:N(i)}),Ju=L(Vu,`Measure browser or host-rendered simulator/emulator audio as compact dBFS buckets. Start a probe before requesting its status or stopping it.`,{action:N(Uu),probeAction:N(Wu),durationMs:j(`Probe duration in milliseconds.`),bucketMs:j(`Audio level bucket size in milliseconds.`)}),Yu=z({name:`observability`,commands:[R({name:Ru,text:{summary:`Manage session app logs`},metadata:Gu,run:(e,t)=>e.observability.logs(t),cliSchema:{usageOverride:`logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]`,usageFlags:[],positionalArgs:[`path|start|stop|clear|doctor|mark`,`message?`],allowsExtraPositionals:!0,allowedFlags:[`restart`]},cliReader:(e,t)=>({...x(t),action:ed(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:y(Ru,e=>Xu(e)),cliOutputFormatter:pu.logs}),R({name:zu,text:{summary:`Read session event timeline`},metadata:Ku,run:(e,t)=>e.observability.events(t),cliSchema:{usageOverride:`events [limit] [cursor]`,listUsageOverride:`events`,positionalArgs:[`limit?`,`cursor?`]},cliReader:(e,t)=>({...x(t),limit:e[0]?.trim()?tr(e[0]):void 0,cursor:e[1]}),daemonWriter:e=>b(zu,Zu(e),e),cliOutputFormatter:pu.events}),R({name:Bu,text:{summary:`Inspect HTTP(S) traffic from session logs`},metadata:qu,run:(e,t)=>e.observability.network(t),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]`,usageFlags:[],listUsageOverride:`network`,positionalArgs:[`dump|log`,`limit?`,`include?`],allowedFlags:[`networkInclude`]},cliReader:(e,t)=>({...x(t),action:td(e[0]),limit:tr(e[1]),include:t.networkInclude??nd(e[2])}),daemonWriter:e=>b(Bu,Qu(e),{...e,networkInclude:e.include}),cliOutputFormatter:pu.network}),R({name:Vu,text:{summary:`Probe audio levels`},metadata:Ju,run:(e,t)=>e.observability.audio(t),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)=>({...x(t),action:rd(e[0]),probeAction:id(e[1]),durationMs:ad(e[2]),bucketMs:tr(e[3])}),daemonWriter:e=>b(Vu,$u(e),e),cliOutputFormatter:pu.audio})]});function Xu(e){return[e.action??`path`,...w(e.message)]}function Zu(e){return e.cursor===void 0?T(e.limit):[e.limit===void 0?``:String(e.limit),e.cursor]}function Qu(e){return[...e.action?[e.action]:[],...T(e.limit)]}function $u(e){return[e.action??`probe`,e.probeAction??`status`,...T(e.durationMs),...T(e.bucketMs)]}function ed(e){if(e!==void 0)return su(on,e,{message:`logs requires path, start, stop, doctor, mark, or clear`})}function td(t){if(t!==void 0){if(t===`dump`||t===`log`)return t;throw new e(`INVALID_ARGS`,`network requires dump or log`)}}function nd(e){if(e!==void 0)return su(i,e,{message:`network include must be summary, headers, body, or all`})}function rd(e){if(e!==void 0)return su(Uu,e,{message:`audio requires probe`})}function id(e){if(e!==void 0)return su(Wu,e,{message:`audio probe requires start, status, or stop`})}function ad(e){let t=tr(e);return t===void 0?void 0:Math.round(t*1e3)}function od(e){let t=e;return{data:t,text:cd(t)}}const sd={perf:f(od)};function cd(e){return hd(e)??ld(e)}function ld(e){let t=u(e.artifact)?e.artifact:void 0;return t?md(t):ud(u(e.metrics)?e.metrics:void 0)}function ud(e){return u(e?.fps)?fd(e):dd(e)??`Memory: unavailable - missing memory metric`}function dd(e){let t=u(e?.memory)?e.memory:void 0;if(!t)return;if(t.available===!1)return`Memory: unavailable - ${Dd(t)}`;let n=Nd(t);return n?`Performance: ${n}`:`Memory: unavailable - missing memory metric`}function fd(e){let t=u(e?.fps)?e.fps:void 0;if(!t)return Ed(`missing frame metric`);if(t.available===!1)return Ed(Dd(t));let n=Od(t);return n?pd(t,n):Ed(`missing dropped-frame summary`)}function pd(e,t){let n=[`Frame health: ${t}`],r=jd(e);return r.length>0&&n.push(`Worst windows:`,...r),n.join(`
|
|
32
|
+
`)}function md(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?``:` (${Ld(r)})`;return n?`Memory artifact (${t}): ${n}${i}`:`Memory artifact (${t}): captured${i}`}function hd(e){return e.kind===`xctrace`?gd(e):bd(e)}function gd(e){let t=typeof e.perf==`string`?e.perf:void 0,n=vd(e);if(!t||!n||e.kind!==`xctrace`)return;let r=yd(n,typeof e.mode==`string`?e.mode:`capture`,t,e.template),i=_d(e);return i.length>0?`${r}\nTop CPU self time:\n${i.join(`
|
|
33
|
+
`)}`:r}function _d(e){let t=u(e.summary)?e.summary:void 0;return Array.isArray(t?.topFunctions)?t.topFunctions.slice(0,5).flatMap(e=>{if(!u(e))return[];let t=wd(e.symbol),n=Q(e.selfSamplePercent);if(!t||n===void 0)return[];let r=wd(e.binary);return[`- ${Pd(n)} ${t}${r?` (${r})`:``}`]}):[]}function vd(e){return typeof e.outPath==`string`?e.outPath:typeof e.reportPath==`string`?e.reportPath:void 0}function yd(e,t,n,r){let i=[e,`Perf ${t}: ${n}`];return typeof r==`string`&&i.push(`Template: ${r}`),i.join(`
|
|
34
|
+
`)}function bd(e){let t=xd(e);if(!t)return;let n=`Perf ${t.action}: ${t.kind} ${t.type}${Sd(e)}${Cd(e)}${Td(e)}`,r=_d(e);return r.length>0?`${n}\nTop CPU self time:\n${r.join(`
|
|
35
|
+
`)}`:n}function xd(e){let t=wd(e.action),n=wd(e.kind),r=wd(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function Sd(e){let t=wd(e.state);return t?` state=${t}`:``}function Cd(e){let t=wd(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${Ld(n)})`}`}function wd(e){return typeof e==`string`?e:void 0}function Td(e){let t=u(e.summary)?e.summary:void 0,n=u(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 ${Pd(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function Ed(e){return`Frame health: unavailable - ${e}`}function Dd(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function Od(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(t!==void 0&&n!==void 0)return[`dropped ${Pd(t)}`,kd(n,Q(e.totalFrameCount)),Ad(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function kd(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function Ad(e){return e===void 0?``:`window ${Fd(e)}`}function jd(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!u(e))return[];let t=Md(e);return t?[t]:[]}):[]}function Md(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 ${Fd(i)}`;return`- +${Fd(t)}-+${Fd(n)}: ${Math.round(r)} missed-deadline frames${a}`}function Nd(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${Id(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Pd(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function Fd(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 Id(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function Ld(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 Rd=`perf`,zd=z({name:`perf`,commands:[R({name:Rd,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. On iOS simulators and macOS, process sampling and captures target the resolved app executable and exclude other copies with the same name. 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:L(Rd,`Collect frame health, memory diagnostics, and platform profiling artifacts with compact agent-readable summaries.`,{area:O(N(gt)),subject:N(bt),action:N(ht),kind:N(ct),template:k(`xctrace template name, for example Time Profiler.`),out:k(`Output artifact path.`),tracePath:k(`Existing .trace path to report, defaults to the latest session trace.`)}),run:(e,t)=>e.observability.perf(t),cliSchema:{usageOverride:`perf frames --json
|
|
36
36
|
agent-device perf memory sample --json
|
|
37
37
|
agent-device perf memory snapshot [--kind android-hprof|memgraph] [--out <path>]
|
|
38
38
|
agent-device perf cpu profile start --kind xctrace [--template <name>] --out <profile.trace>
|
|
@@ -44,9 +44,9 @@ import{D as e,E as t,S as n,p as r,t as i,x as a,y as o}from"./sdk-contracts.js"
|
|
|
44
44
|
agent-device perf cpu profile report --kind simpleperf --out <cpu-report.json>
|
|
45
45
|
agent-device perf trace start|stop --kind perfetto [--out <path>]
|
|
46
46
|
|
|
47
|
-
Aggregate perf was removed in 0.21. Use one of the explicit forms above.`,usageFlags:[],listUsageOverride:`perf`,positionalArgs:[`area`,`subjectOrAction?`,`action?`],allowedFlags:[`kind`,`perfTemplate`,`out`]},cliReader:(e,t)=>({...x(t),...
|
|
48
|
-
`)}}const
|
|
49
|
-
`)}function ef(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 tf=`record`,nf=`trace`,rf=[`start`,`stop`],af=L(tf,`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:O(N(rf)),path:k(),fps:j(),maxSize:gr(ie.migration.record),quality:N(Re),hideTouches:M(),recordingScope:N(Ve)},{parseableOutput:!0}),of=L(nf,`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:O(N(rf)),path:k()}),sf={usageOverride:`record start [path] [--scope <app|device|system>] [--fps <n>] [--quality <medium|high>] [--hide-touches] | record stop`,usageFlags:[],listUsageOverride:`record start [path] | record stop`,positionalArgs:[`start|stop`,`path?`],allowedFlags:[`recordingScope`,`fps`,`quality`,`hideTouches`]},cf={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,positionalArgs:[`start|stop`,`path?`]},lf=(e,t)=>({...x(t),action:gf(e[0],tf),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),uf=(e,t)=>({...x(t),action:gf(e[0],nf),path:e[1]}),df=y(tf,e=>hf(e)),ff=e=>(c(`record`,e),df(e)),pf=y(nf,e=>hf(e)),mf=z({name:`recording`,commands:[R({name:tf,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. Android screenrecord encodes a frame only when the screen changes, so a clip can end at the last frame the recorder encoded instead of at record stop; durationMs is host wall clock from record start until the export finished, and capturedDurationMs reports the video timeline when it can be measured, with a warning naming how much of the window that video covers. An Android manifest left by an unreachable recording is retired on the next start once its recorders are proven gone; one still owned refuses with non-retriable DEVICE_IN_USE and reason native_recovery_evidence_open naming the session to run record stop for, and a recorder that is still writing an artifact refuses with DEVICE_IN_USE and reason native_recording_artifact_claimed, which clears itself once that recorder ends at the 180s limit. 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. An iOS simulator host recording lock returns non-retriable DEVICE_IN_USE with reason apple_simulator_recording_busy. Stop the recording in its owning session; if a dead recorder left the host locked, ask the host operator to restart the CoreSimulator stream service. A record stop that cannot produce its export keeps what a retry reads back — on Android the device-side artifact and the native manifest — leaves the recording manifest of that session open, and returns its own error, so retry record stop in that session; only closing the session disposes them. Every stopped recording also reports what became of its recorder and of the file that recorder writes to: recorder is confirmed, or lost when the session holding it died, and nativePathDisposition is retirable while that file still owes a removal or retired once its removal was verified. Both are optional disclosures, not failures; ADR 0024 declares further states (unconfirmed, pending) for the steps that gain those probes, and no stop reports them yet.`},metadata:af,run:(e,t)=>e.recording.record(t),cliSchema:sf,cliReader:lf,daemonWriter:ff,cliOutputFormatter:Qd.record}),R({name:nf,text:{summary:`Start or stop trace capture`,cliDetail:`Pass that path as the same positional argument to start and stop.`},metadata:of,run:(e,t)=>e.recording.trace(t),cliSchema:cf,cliReader:uf,daemonWriter:pf})]});function hf(e){return[e.action,...w(e.path)]}function gf(t,n){if(t===`start`||t===`stop`)return t;throw new e(`INVALID_ARGS`,`${n} requires start|stop`)}const _f=2097152;async function vf(e){let t=Qt(e.inputPath,{cwd:e.cwd}),n=bf(t,e.inputPath);if(nt(t,e.replayBackend)!==`maestro`)return yf(t,{[t]:n},e.inputPath);let{collectMaestroFlowSources:r}=await import(`./src8.js`).then(e=>e.t);return yf(t,r({entryPath:t,entrySource:n,env:e.env,readSource:xf}),e.inputPath)}function yf(e,t,n){return Sf(t,n),{entry:e,files:t}}function bf(t,n){try{return h.readFileSync(t,`utf8`)}catch(r){throw new e(`INVALID_ARGS`,`replay script not found on this machine: ${n}`,{path:t,hint:`Replay scripts are read by the client and sent to the daemon, so the path must resolve where you ran the command.`},r instanceof Error?r:void 0)}}function xf(e){try{return h.readFileSync(e,`utf8`)}catch{return}}function Sf(t,n){let r=Object.values(t).reduce((e,t)=>e+Buffer.byteLength(t,`utf8`),0);if(!(r<=2097152))throw new e(`INVALID_ARGS`,`replay script sources for ${n} total ${r} bytes, over the ${_f}-byte limit; split the flow or drop unused runFlow includes.`,{limitBytes:_f,totalBytes:r})}const Cf=/[*?[\]{}]/;function wf(e){let t=e.replayBackend===`maestro`?new Set([`.yaml`,`.yml`,`.ad`]):new Set([`.ad`]),n=[],r=[];for(let i of e.inputs){let a=Tf(i,e.cwd,t);if(a.source===`file`){n.push(...a.paths);continue}r.push(a.source===`directory`?Af(a.paths):Of(a.paths))}return Af([...n,...r.flat()])}function Tf(t,n,r){let i=Qt(t,{cwd:n});if(h.existsSync(i)){let e=h.statSync(i);return e.isDirectory()?{paths:Df(i,r),source:`directory`}:e.isFile()?(Ef(t,i,r),{paths:[i],source:`file`}):{paths:[],source:`file`}}if(!jf(t))throw new e(`INVALID_ARGS`,`test input not found: ${t}`);return{source:`glob`,paths:h.globSync($t(t),{cwd:n}).map(e=>m.isAbsolute(e)?e:m.resolve(n,e)).filter(e=>r.has(m.extname(e).toLowerCase())&&Mf(e))}}function Ef(t,n,r){if(!r.has(m.extname(n).toLowerCase()))throw it(n)&&!r.has(`.yaml`)?new e(`INVALID_ARGS`,et(`test`,t)):new e(`INVALID_ARGS`,`test does not support this file type: ${t}`)}function Df(e,t){let n=[],r=h.opendirSync(e);try{let i;for(;(i=r.readSync())!==null;){let r=m.join(e,i.name);i.isDirectory()?n.push(...Df(r,t)):i.isFile()&&t.has(m.extname(i.name).toLowerCase())&&n.push(r)}}finally{r.closeSync()}return n}function Of(e){return e.map(e=>m.normalize(e)).sort((e,t)=>{let n=kf(e)-kf(t);return n===0?e.localeCompare(t):n})}function kf(e){return+(m.extname(e).toLowerCase()===`.ad`)}function Af(e){return[...new Set(e.map(e=>m.normalize(e)))]}function jf(e){return Cf.test(e)}function Mf(e){try{return h.statSync(e).isFile()}catch{return!1}}const Nf=`replay`,Pf=`test`,Ff=L(Nf,`Run a recorded automation script, including compatible Maestro YAML flows. A script without a terminal close leaves its session active for subsequent automation.`,{path:O(k()),update:M(),backend:k(),maestro:M(),env:Cr(),metroHost:k(`Metro/debug host hint inherited by replay-opened sessions.`),metroPort:j(`Metro/debug port hint inherited by replay-opened sessions.`),bundleUrl:k(`Bundle URL hint inherited by replay-opened sessions.`),resumeFrom:j(),resumePlanDigest:k(),keepSession:M(`Leave the session active by suppressing exactly an authored terminal close in native .ad.`),timeoutMs:j(`Maximum wall-clock duration for the replay request.`),saveScript:P({oneOf:[pr(),ur()]}),force:M()}),If=L(Pf,`Run one or more replay scripts as a serial test suite`,{paths:O(Cr()),update:M(),backend:k(),maestro:M(),env:Cr(),metroHost:k(`Metro/debug host hint inherited by each test session.`),metroPort:j(`Metro/debug port hint inherited by each test session.`),bundleUrl:k(`Bundle URL hint inherited by each test session.`),failFast:M(),timeoutMs:j(),retries:j(),recordVideo:M(),artifactsDir:k(),shardAll:j(),shardSplit:j()}),Lf={usageOverride:`replay <path> | replay export <file.ad> [--out <path>]`,usageFlags:[],positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ti,...Si,`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.`}},Rf={usageOverride:`test <path-or-glob>...`,usageFlags:[],listUsageOverride:`test <path-or-glob>...`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ti,...Si,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`]},zf=z({name:`replay`,commands:[R({name:Nf,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. replay export <file.ad> converts compatible actions to Maestro YAML locally, including app switches with explicit launchApp.appId targets, deep links (including tel: and mailto:) as openLink, and home as pressKey: Home.`},metadata:Ff,run:(e,t)=>e.replay.run(Dc(t)),cliSchema:Lf,cliReader:(e,t)=>({...x(t),path:E(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:async e=>{let t=D(e.path,`replay requires path`),n=Hf(e),r=Wf(process.env);return b(Nf,[t],{...e,replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:r,replayScriptSource:await vf({inputPath:t,cwd:Vf(e),replayBackend:n,env:Bf(e,r)}),replayFrom:e.resumeFrom,replayPlanDigest:e.resumePlanDigest,replayKeepSession:e.keepSession,saveScript:e.saveScript})},cliOutputFormatter:p}),R({name:Pf,text:{summary:`Run replay test suites`,cliDetail:`Relative globs are expanded on the caller from its working directory, whose name is treated literally. Quote glob inputs to defer expansion to test. Copied diagnostic artifacts receive numbered filenames when needed to preserve other artifacts, replay sources, timing traces, and attempt manifests. JUnit reports (--reporter junit:<path>) replace characters forbidden by XML 1.0 with U+FFFD and preserve legal Unicode and whitespace. JSON and other reporters retain the original suite values. Custom reporter getExitCode hooks must return an integer from 0 to 255 or undefined; the highest valid code wins and cannot lower a failing suite's exit code.`},metadata:If,run:(e,t)=>e.replay.test(Dc(t)),cliSchema:Rf,cliReader:(e,t)=>({...x(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:async e=>{let t=e.paths??[],n=Hf(e),r=Vf(e),i=Wf(process.env),a=Bf(e,i);return b(Pf,t,{...Uf(e),replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:i,replayScriptSources:await Promise.all(wf({inputs:t,cwd:r,replayBackend:n}).map(async e=>await vf({inputPath:e,cwd:r,replayBackend:n,env:a})))})}})]});function Bf(e,t){return{...tt(t),...rt($e(e.env))}}function Vf(e){return typeof e.cwd==`string`&&e.cwd.length>0?e.cwd:process.cwd()}function Hf(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function Uf(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function Wf(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}function Gf(e){return{data:e,text:Jf(e)}}function Kf(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: ${Yf(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
|
|
50
|
-
`)}}return
|
|
47
|
+
Aggregate perf was removed in 0.21. Use one of the explicit forms above.`,usageFlags:[],listUsageOverride:`perf`,positionalArgs:[`area`,`subjectOrAction?`,`action?`],allowedFlags:[`kind`,`perfTemplate`,`out`]},cliReader:(e,t)=>({...x(t),...Hd(e,{kind:Jd(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:y(Rd,e=>Bd(e)),cliOutputFormatter:sd.perf})]});function Bd(e){let t=e.area;return t===`cpu`?Vd([...w(t),...w(e.subject),...w(e.action),...w(e.kind)],e):t===`trace`?Vd([...w(t),...w(e.action),...w(e.kind)],e):[...w(t),...w(e.action)]}function Vd(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 Hd(e,t={}){let n=Wd(e[0]);if(n===`cpu`)return{area:n,subject:Kd(e[1]),action:Gd(e[2]),kind:qd(t.kind),template:t.template,out:t.out};if(n===`trace`)return{area:n,action:Gd(e[1]),kind:qd(t.kind),template:t.template,out:t.out};let r=Gd(e[1]),i=qd(t.kind);return Ud(n,r,i,t.out),{area:n,action:r,kind:i,out:t.out}}function Ud(t,n,r,i){if(t===`frames`){if(r!==void 0)throw new e(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(i!==void 0)throw new e(`INVALID_ARGS`,`--out is only supported with perf memory snapshot, perf cpu profile, or perf trace`)}if(t===`memory`){if(n!==`snapshot`&&r!==void 0)throw new e(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(n!==`snapshot`&&i!==void 0)throw new e(`INVALID_ARGS`,`--out is only supported with perf memory snapshot`)}}function Wd(t){let n=t?.toLowerCase();if(dt(n))throw new e(`INVALID_ARGS`,pt);if(ut(n))return n;throw new e(`INVALID_ARGS`,st)}function Gd(t){if(t===void 0)return;let n=t.toLowerCase();if(lt(n))return n;throw new e(`INVALID_ARGS`,yt)}function Kd(t){let n=t?.toLowerCase();if(n!==void 0&&ft(n))return n;throw new e(`INVALID_ARGS`,mt)}function qd(t){if(t===void 0)return;let n=t.toLowerCase();if(_t(n))return n;throw new e(`INVALID_ARGS`,vt)}function Jd(e){return typeof e==`string`?qd(e):void 0}const Yd=`react-native`,Xd=z({name:`react-native`,commands:[R({name:Yd,text:{summary:`Run React Native automation helpers`},metadata:L(Yd,`Run supported React Native automation helpers. Use dismiss-overlay to close a visible development error overlay before continuing normal UI automation.`,{action:O(N([`dismiss-overlay`]))}),run:(e,t)=>e.command.reactNative(t),cliSchema:{usageOverride:`react-native dismiss-overlay`,listUsageOverride:`react-native dismiss-overlay`,positionalArgs:[`dismiss-overlay`]},cliReader:(e,t)=>({...x(t),action:Zd(e[0])}),daemonWriter:y(Yd,e=>[D(e.action,`react-native requires action`)])})]});function Zd(t){if(t===`dismiss-overlay`)return t;throw new e(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}function Qd(e){let t=e,n=typeof t.outPath==`string`?t.outPath:``,r=tf(t);if(r.length<=1)return{data:t,text:ef(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(`
|
|
48
|
+
`)}}const $d={record:f(Qd)};function ef(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(`
|
|
49
|
+
`)}function tf(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 nf=`record`,rf=`trace`,af=[`start`,`stop`],of=L(nf,`Start or stop a screen recording for the active app session or, where supported, the selected device, or build a contact-sheet PNG from a recording already exported. Long Android recordings can return multiple video artifacts; HarmonyOS supports whole-screen recording on physical devices.`,{action:O(N(af)),path:k(),fps:j(),maxSize:_r(re.migration.record),quality:N(Le),hideTouches:M(),recordingScope:N(Re)},{parseableOutput:!0}),sf=L(rf,`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:O(N(af)),path:k()}),cf={start:[`recordingScope`,`fps`,`quality`,`hideTouches`],stop:[],"contact-sheet":[`out`]},lf={usageOverride:`record start [path] [--scope <app|device|system>] [--fps <n>] [--quality <medium|high>] [--hide-touches] | record stop | record contact-sheet <video.mp4> [--out <sheet.png>]`,usageFlags:[],listUsageOverride:`record start [path] | record stop | record contact-sheet <video>`,positionalArgs:[`start|stop|contact-sheet`,`path?`],allowedFlags:[...new Set(Object.values(cf).flat())],flagsByAction:cf},uf={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,positionalArgs:[`start|stop`,`path?`]},df=(e,t)=>({...x(t),action:vf(e[0],nf),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),ff=(e,t)=>({...x(t),action:vf(e[0],rf),path:e[1]}),pf=y(nf,e=>_f(e)),mf=e=>(c(`record`,e),pf(e)),hf=y(rf,e=>_f(e)),gf=z({name:`recording`,commands:[R({name:nf,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. Android screenrecord encodes a frame only when the screen changes, so a clip can end at the last frame the recorder encoded instead of at record stop; durationMs is host wall clock from record start until the export finished, and capturedDurationMs reports the video timeline when it can be measured, with a warning naming how much of the window that video covers. An Android manifest left by an unreachable recording is retired on the next start once its recorders are proven gone; one still owned refuses with non-retriable DEVICE_IN_USE and reason native_recovery_evidence_open naming the session to run record stop for, and a recorder that is still writing an artifact refuses with DEVICE_IN_USE and reason native_recording_artifact_claimed, which clears itself once that recorder ends at the 180s limit. 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. An iOS simulator host recording lock returns non-retriable DEVICE_IN_USE with reason apple_simulator_recording_busy. Stop the recording in its owning session; if a dead recorder left the host locked, ask the host operator to restart the CoreSimulator stream service. A record stop that cannot produce its export keeps what a retry reads back — on Android the device-side artifact and the native manifest — leaves the recording manifest of that session open, and returns its own error, so retry record stop in that session; only closing the session disposes them. Every stopped recording also reports what became of its recorder and of the file that recorder writes to: recorder is confirmed, or lost when the session holding it died, and nativePathDisposition is retirable while that file still owes a removal or retired once its removal was verified. Both are optional disclosures, not failures; ADR 0024 declares further states (unconfirmed, pending) for the steps that gain those probes, and no stop reports them yet. record contact-sheet <video.mp4> [--out <sheet.png>] is a local report over a file you already exported: it decodes frames out of that MP4 and writes one PNG holding the cells where the screen visibly changed, each labeled with its elapsed time on the clip timeline. It needs no session and no device, rebuilds any past recording, and works for every backend that exports MP4; a WebM recording is refused with reason contact_sheet_container_unsupported. The sample grid is bounded and spread across the whole clip, so it reports coverage rather than a review: a flash that opens and closes entirely between two sample times is not in the sheet, which is why the result also reports how many times it sampled and how many frames came back. Frame decoding is Apple AVFoundation tooling, so the command runs only on macOS hosts and refuses elsewhere with reason contact_sheet_unsupported_host.`},metadata:of,run:(e,t)=>e.recording.record(t),cliSchema:lf,cliReader:df,daemonWriter:mf,cliOutputFormatter:$d.record}),R({name:rf,text:{summary:`Start or stop trace capture`,cliDetail:`Pass that path as the same positional argument to start and stop.`},metadata:sf,run:(e,t)=>e.recording.trace(t),cliSchema:uf,cliReader:ff,daemonWriter:hf})]});function _f(e){return[e.action,...w(e.path)]}function vf(t,n){if(t===`start`||t===`stop`)return t;throw new e(`INVALID_ARGS`,`${n} requires start|stop`)}const yf=2097152;async function bf(e){let t=Qt(e.inputPath,{cwd:e.cwd}),n=Sf(t,e.inputPath);if(Qe(t,e.replayBackend)!==`maestro`)return xf(t,{[t]:n},e.inputPath);let{collectMaestroFlowSources:r}=await import(`./src8.js`).then(e=>e.t);return xf(t,r({entryPath:t,entrySource:n,env:e.env,readSource:Cf}),e.inputPath)}function xf(e,t,n){return wf(t,n),{entry:e,files:t}}function Sf(t,n){try{return an.readFileSync(t,`utf8`)}catch(r){throw new e(`INVALID_ARGS`,`replay script not found on this machine: ${n}`,{path:t,hint:`Replay scripts are read by the client and sent to the daemon, so the path must resolve where you ran the command.`},r instanceof Error?r:void 0)}}function Cf(e){try{return an.readFileSync(e,`utf8`)}catch{return}}function wf(t,n){let r=Object.values(t).reduce((e,t)=>e+Buffer.byteLength(t,`utf8`),0);if(!(r<=2097152))throw new e(`INVALID_ARGS`,`replay script sources for ${n} total ${r} bytes, over the ${yf}-byte limit; split the flow or drop unused runFlow includes.`,{limitBytes:yf,totalBytes:r})}const Tf=/[*?[\]{}]/;function Ef(e){let t=e.replayBackend===`maestro`?new Set([`.yaml`,`.yml`,`.ad`]):new Set([`.ad`]),n=[],r=[];for(let i of e.inputs){let a=Df(i,e.cwd,t);if(a.source===`file`){n.push(...a.paths);continue}r.push(a.source===`directory`?Mf(a.paths):Af(a.paths))}return Mf([...n,...r.flat()])}function Df(t,n,r){let i=Qt(t,{cwd:n});if(an.existsSync(i)){let e=an.statSync(i);return e.isDirectory()?{paths:kf(i,r),source:`directory`}:e.isFile()?(Of(t,i,r),{paths:[i],source:`file`}):{paths:[],source:`file`}}if(!Nf(t))throw new e(`INVALID_ARGS`,`test input not found: ${t}`);return{source:`glob`,paths:an.globSync($t(t),{cwd:n}).map(e=>h.isAbsolute(e)?e:h.resolve(n,e)).filter(e=>r.has(h.extname(e).toLowerCase())&&Pf(e))}}function Of(t,n,r){if(!r.has(h.extname(n).toLowerCase()))throw et(n)&&!r.has(`.yaml`)?new e(`INVALID_ARGS`,Xe(`test`,t)):new e(`INVALID_ARGS`,`test does not support this file type: ${t}`)}function kf(e,t){let n=[],r=an.opendirSync(e);try{let i;for(;(i=r.readSync())!==null;){let r=h.join(e,i.name);i.isDirectory()?n.push(...kf(r,t)):i.isFile()&&t.has(h.extname(i.name).toLowerCase())&&n.push(r)}}finally{r.closeSync()}return n}function Af(e){return e.map(e=>h.normalize(e)).sort((e,t)=>{let n=jf(e)-jf(t);return n===0?e.localeCompare(t):n})}function jf(e){return+(h.extname(e).toLowerCase()===`.ad`)}function Mf(e){return[...new Set(e.map(e=>h.normalize(e)))]}function Nf(e){return Tf.test(e)}function Pf(e){try{return an.statSync(e).isFile()}catch{return!1}}const Ff=`replay`,If=`test`,Lf=L(Ff,`Run a recorded automation script, including compatible Maestro YAML flows. A script without a terminal close leaves its session active for subsequent automation.`,{path:O(k()),update:M(),backend:k(),maestro:M(),env:wr(),metroHost:k(`Metro/debug host hint inherited by replay-opened sessions.`),metroPort:j(`Metro/debug port hint inherited by replay-opened sessions.`),bundleUrl:k(`Bundle URL hint inherited by replay-opened sessions.`),resumeFrom:j(),resumePlanDigest:k(),keepSession:M(`Leave the session active by suppressing exactly an authored terminal close in native .ad.`),timeoutMs:j(`Maximum wall-clock duration for the replay request.`),saveScript:P({oneOf:[mr(),dr()]}),force:M()}),Rf=L(If,`Run one or more replay scripts as a serial test suite`,{paths:O(wr()),update:M(),backend:k(),maestro:M(),env:wr(),metroHost:k(`Metro/debug host hint inherited by each test session.`),metroPort:j(`Metro/debug port hint inherited by each test session.`),bundleUrl:k(`Bundle URL hint inherited by each test session.`),failFast:M(),timeoutMs:j(),retries:j(),recordVideo:M(),artifactsDir:k(),shardAll:j(),shardSplit:j()}),zf={usageOverride:`replay <path> | replay export <file.ad> [--out <path>]`,usageFlags:[],positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ei,...Ci,`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.`}},Bf={usageOverride:`test <path-or-glob>...`,usageFlags:[],listUsageOverride:`test <path-or-glob>...`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ei,...Ci,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`]},Vf=z({name:`replay`,commands:[R({name:Ff,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. replay export <file.ad> converts compatible actions to Maestro YAML locally, including app switches with explicit launchApp.appId targets, deep links (including tel: and mailto:) as openLink, and home as pressKey: Home.`},metadata:Lf,run:(e,t)=>e.replay.run(Oc(t)),cliSchema:zf,cliReader:(e,t)=>({...x(t),path:E(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:async e=>{let t=D(e.path,`replay requires path`),n=Wf(e),r=Kf(process.env);return b(Ff,[t],{...e,replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:r,replayScriptSource:await bf({inputPath:t,cwd:Uf(e),replayBackend:n,env:Hf(e,r)}),replayFrom:e.resumeFrom,replayPlanDigest:e.resumePlanDigest,replayKeepSession:e.keepSession,saveScript:e.saveScript})},cliOutputFormatter:m}),R({name:If,text:{summary:`Run replay test suites`,cliDetail:`Relative globs are expanded on the caller from its working directory, whose name is treated literally. Quote glob inputs to defer expansion to test. Copied diagnostic artifacts receive numbered filenames when needed to preserve other artifacts, replay sources, timing traces, and attempt manifests. JUnit reports (--reporter junit:<path>) replace characters forbidden by XML 1.0 with U+FFFD and preserve legal Unicode and whitespace. JSON and other reporters retain the original suite values. Custom reporter getExitCode hooks must return an integer from 0 to 255 or undefined; the highest valid code wins and cannot lower a failing suite's exit code.`},metadata:Rf,run:(e,t)=>e.replay.test(Oc(t)),cliSchema:Bf,cliReader:(e,t)=>({...x(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:async e=>{let t=e.paths??[],n=Wf(e),r=Uf(e),i=Kf(process.env),a=Hf(e,i);return b(If,t,{...Gf(e),replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:i,replayScriptSources:await Promise.all(Ef({inputs:t,cwd:r,replayBackend:n}).map(async e=>await bf({inputPath:e,cwd:r,replayBackend:n,env:a})))})}})]});function Hf(e,t){return{...Ze(t),...$e(Ye(e.env))}}function Uf(e){return typeof e.cwd==`string`&&e.cwd.length>0?e.cwd:process.cwd()}function Wf(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function Gf(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function Kf(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}function qf(e){return{data:e,text:Xf(e)}}function Jf(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: ${Zf(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
|
|
50
|
+
`)}}return p(e)}function Yf(e){return e.action===`read`?{data:e,text:e.text}:p(e)}const $=Ss({appstate:f(qf),back:m,home:m,orientation:m,fold:m,"app-switcher":m,"action-button":m,keyboard:f(Jf),clipboard:f(Yf),"tv-remote":m});function Xf(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(`
|
|
51
51
|
`)}if(e.platform===`android`){let t=[`Foreground app: ${e.package??`unknown`}`];return e.activity&&t.push(`Activity: ${e.activity}`),t.join(`
|
|
52
|
-
`)}return null}function
|
|
52
|
+
`)}return null}function Zf(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 Qf=`back`,$f=`orientation`,ep=`fold`,tp=`keyboard`,np=`clipboard`,rp=`tv-remote`,ip=[`read`,`write`],ap=[`status`,`dismiss`,`enter`,`return`],op=L(Qf,`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:N(it),...U(Qf)}),sp=L($f,`Set device orientation on iOS and Android`,{orientation:O(N(Xt))}),cp=L(ep,`Fold or unfold a foldable iPhone simulator (iPhone Duo) into the closed, half-open, or open pose by pressing the pose control in Xcode Device Hub, then read the hinge angle back from CoreDevice to confirm it. A pose change moves the app to a different panel with a different point size, so every ref and coordinate from before it is stale: re-snapshot after this command. Taps, long presses, and scrolling target the app window on its current panel in closed, half-open, and open poses. Simulator-only; the device window must be open in Device Hub and the host needs Accessibility permission.`,{pose:O(N(Yt,`The hinge pose to reach: closed lights the outer panel; half-open (Device Hub Book) and open light the inner panel.`))}),lp=L(tp,`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:N(ap)}),up=L(np,`Read the current device clipboard text, or replace its contents with the given text. Android runs both through the clipboard service shell command, and a build that implements none (Android 16 does not) refuses with UNSUPPORTED_OPERATION rather than reporting an empty clipboard.`,{action:O(N(ip)),text:k()},{parseableOutput:!0}),dp=L(rp,`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:O(N(rn)),durationMs:j(`Press duration in milliseconds. tvOS and Vega OS use the exact hold duration; Android TV maps any positive value to an ADB longpress (${nn(`android`)}).`,{min:0})}),fp={usageOverride:`back [--in-app|--system] [--settle]`,usageFlags:[],allowedFlags:[`backMode`,...W(Qf)]},pp={usageOverride:`orientation <portrait|portrait-upside-down|landscape-left|landscape-right>`,positionalArgs:[`orientation`]},mp={usageOverride:`fold <${qt}>`,positionalArgs:[`pose`]},hp={usageOverride:`keyboard [status|get|dismiss|enter|return]`,positionalArgs:[`action?`]},gp={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},_p={usageOverride:`tv-remote [press|longpress] ${en}`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},vp=(e,t)=>({...x(t),mode:t.backMode}),yp=(e,t)=>({...x(t),orientation:Kt(e[0])}),bp=(e,t)=>({...x(t),pose:Jt(e[0])}),xp=(e,t)=>({...x(t),...Vp(e)}),Sp=(e,t)=>({...x(t),...Hp(e)}),Cp=(e,t)=>({...x(t),...Up(e,t.durationMs)}),wp=e=>b(Qf,[],{...e,backMode:zp(e.mode)}),Tp=y($f,e=>[D(e.orientation,`orientation requires orientation`)]),Ep=y(ep,e=>[D(e.pose,`fold requires pose`)]),Dp=y(tp,e=>w(e.action)),Op=y(np,e=>Bp(e)),kp=y(rp,e=>[D(e.button,`tv-remote requires button`)]),Ap=Kr({name:`appstate`,description:`Show foreground app/activity (Android; iOS answers per command)`,text:{summary:`Show the foreground app and activity`},run:(e,t)=>e.command.appState(t),cliOutputFormatter:$.appstate}),jp=R({name:Qf,text:{summary:`Navigate back in the app or system`},metadata:op,run:(e,t)=>e.command.back(t),cliSchema:fp,cliReader:vp,daemonWriter:wp,cliOutputFormatter:$.back}),Mp=Kr({name:`home`,description:`Send the selected device to its home screen. This leaves the app session open but moves the foreground away from the app.`,text:{summary:`Go to the device home screen`},run:(e,t)=>e.command.home(t),cliOutputFormatter:$.home}),Np=R({name:$f,text:{summary:`Set device orientation`},metadata:sp,run:(e,t)=>e.command.orientation(t),cliSchema:pp,cliReader:yp,daemonWriter:Tp,cliOutputFormatter:$.orientation}),Pp=R({name:ep,text:{summary:`Fold or unfold a foldable iPhone simulator`,cliDetail:`iPhone Duo simulators only. Presses the pose control in Xcode Device Hub and confirms the hinge angle through CoreDevice; refs and coordinates do not survive a pose change.`},metadata:cp,run:(e,t)=>e.command.fold(t),cliSchema:mp,cliReader:bp,daemonWriter:Ep,cliOutputFormatter:$.fold}),Fp=Kr({name:`app-switcher`,description:`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.`,text:{summary:`Open the device app switcher`},run:(e,t)=>e.command.appSwitcher(t),cliOutputFormatter:$[`app-switcher`]}),Ip=R({name:tp,text:{summary:`Inspect, press, or dismiss the device keyboard`},metadata:lp,run:(e,t)=>e.command.keyboard(t),cliSchema:hp,cliReader:xp,daemonWriter:Dp,cliOutputFormatter:$.keyboard}),Lp=R({name:np,text:{summary:`Read or write device clipboard text`},metadata:up,run:(e,t)=>e.command.clipboard(t),cliSchema:gp,cliReader:Sp,daemonWriter:Op,cliOutputFormatter:$.clipboard}),Rp=z({name:`system`,commands:[Ap,jp,Mp,Np,Pp,Fp,Kr({name:`action-button`,description:`Press the iPhone or iPad Action Button once. The press is dispatched without activating the session app and nothing is re-observed afterwards, so the app keeps the state the press found. What the system does with the press is not observed by this command: Simulators run no Shortcuts or App Intents, so delivery to an assigned Shortcut is verifiable only on a physical iPhone.`,text:{summary:`Press the iPhone or iPad Action Button`,cliDetail:`iPhone and iPad only. The runner asks the device for the button and reports unsupported when that model has none.`},run:(e,t)=>e.command.actionButton(t),cliOutputFormatter:$[`action-button`]}),Ip,Lp,R({name:rp,text:{summary:`Press a TV remote/D-pad button`,cliDetail:`longpress holds for 500ms by default; --duration-ms overrides the preset.`},metadata:dp,run:(e,t)=>e.command.tvRemote(t),cliSchema:_p,cliReader:Cp,daemonWriter:kp,cliOutputFormatter:$[`tv-remote`]})]});function zp(e){return e===`in-app`||e===`system`?e:void 0}function Bp(e){return e.action===`read`?[`read`]:[`write`,e.text]}function Vp(t){if(t.length>1)throw new e(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return _({action:Wp(t[0])})}function Hp(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 Up(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: ${rn.join(`, `)}.`);let a=n??(r===`longpress`?500:void 0);return _({button:tn(i[0]),durationMs:a})}function Wp(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 Gp=[Ks,Ql,Lo,Rp,Xd,Vf,Yu,zd,Ho,gf,nu,mi];function Kp(){return Gp.flatMap(e=>[...e.metadata])}function qp(){return Gp.flatMap(e=>[...e.definitions])}function Jp(){return Qp(`cliSchemas`)}function Yp(){return Qp(`cliReaders`)}function Xp(){return Qp(`daemonWriters`)}function Zp(){return Qp(`cliOutputFormatters`)}function Qp(e){let t={};for(let n of Gp){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{pn as C,fn as S,un as T,dr as _,qp as a,kn as b,Ko as c,Oi as d,ki as f,gr as g,mr as h,Xp as i,co as l,ai as m,Yp as n,Kp as o,Si as p,Jp as r,ul as s,Zp as t,Di as u,nr as v,ln as w,Tn as x,rr as y};
|