agent-device 0.21.22 → 0.21.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.22.apk → agent-device-android-ime-helper-0.21.24.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.24.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.22.manifest.json → agent-device-android-ime-helper-0.21.24.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.24.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.24.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.22.manifest.json → agent-device-android-snapshot-helper-0.21.24.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +12 -6
- package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/RectResponseTests.swift +21 -0
- package/apple/snapshot-bridge/README.md +9 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +56 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +14 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +29 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +34 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +19 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +3 -3
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb.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-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +3 -2
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/app-backend.js +1 -1
- package/dist/src/app-inventory.d.ts +4 -0
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state-runtime.d.ts +15 -0
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/aws-device-farm-connection.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/browserstack-connection.js +1 -0
- package/dist/src/browserstack-device-features.js +1 -0
- package/dist/src/browserstack.js +1 -0
- package/dist/src/cache.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +35 -19
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +3 -4
- package/dist/src/client-companion-tunnel.js +1 -0
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-options.js +3 -3
- package/dist/src/client-types.d.ts +7 -5
- package/dist/src/cloud-artifacts.d.ts +9 -2
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-tools.js +2 -2
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection-verification.js +1 -0
- package/dist/src/connection.js +5 -5
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-http.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-input-state.d.ts +2 -15
- package/dist/src/device-readiness-runtime.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +3 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/device3.js +1 -1
- package/dist/src/dispatch-resolve.js +3 -3
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/format.js +2 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +2 -5
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/human-control.js +1 -1
- package/dist/src/ime-rebind.js +1 -0
- package/dist/src/ime-settings-record.js +1 -0
- package/dist/src/ime-state.js +1 -0
- package/dist/src/index.d.ts +3 -3
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/instance-client.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.js +5 -5
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-client.js +4 -4
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun.d.ts +4 -555
- package/dist/src/load.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/log-stream.js +33 -0
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/manifest.js +1 -0
- package/dist/src/mechanics.js +16 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/node-http.js +1 -0
- package/dist/src/observation.js +1 -2
- package/dist/src/overlay.js +3 -3
- package/dist/src/owner-identity.js +3 -3
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- 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-screen-recording-process-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/plugin.js +1 -0
- package/dist/src/plugins/webdriver.d.ts +111 -0
- package/dist/src/plugins/webdriver.js +1 -0
- package/dist/src/plugins.d.ts +2 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/process-exit.js +1 -1
- package/dist/src/process.js +1 -1
- package/dist/src/provider-credential-fingerprint.js +1 -1
- package/dist/src/provider-device-admission.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +556 -0
- package/dist/src/provider-policy.js +1 -0
- package/dist/src/provider-profile-fields.js +1 -1
- package/dist/src/provider-webdriver.js +1 -2
- package/dist/src/providers.js +1 -1
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-devtools.js +2 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/registry.js +24 -24
- package/dist/src/remote-bridge.js +1 -0
- package/dist/src/remote-config-core.js +1 -0
- package/dist/src/remote-config.js +1 -1
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/remote-connection-state.js +1 -0
- 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/retry.js +1 -1
- package/dist/src/retry2.js +1 -0
- package/dist/src/runner-artifact-manifest.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -3
- package/dist/src/runner-cache-retention.js +1 -0
- package/dist/src/runner-cache-trim.js +1 -0
- package/dist/src/runner-client.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-device-set.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +1 -1
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-lease.js +1 -0
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-session-types.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-toolchain-probe.js +2 -0
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-deployment.js +1 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +1 -2
- package/dist/src/runtime11.js +2 -0
- package/dist/src/runtime2.js +2 -5
- package/dist/src/runtime3.js +5 -1
- package/dist/src/runtime4.js +1 -5
- package/dist/src/runtime5.js +5 -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-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-overlay-draw.js +1 -1
- package/dist/src/screenshot3.js +2 -2
- 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 +25 -33
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +4 -0
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-private-evidence.js +1 -0
- 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/src2.js +1 -1
- package/dist/src/src3.js +1 -1
- package/dist/src/src4.js +1 -1
- package/dist/src/src5.js +1 -1
- package/dist/src/src6.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +20 -20
- package/dist/src/store.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +1 -1
- package/package.json +24 -16
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.22.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.22.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.22.apk.sha256 +0 -1
- package/dist/src/capabilities.js +0 -1
- package/dist/src/compatibility-policy.js +0 -1
- package/dist/src/daemon-artifacts.js +0 -1
- package/dist/src/device-claim-rule.js +0 -1
- package/dist/src/human-control-contract.js +0 -1
- package/dist/src/prepare-kind.js +0 -1
- package/dist/src/provider-device-runtimes.js +0 -1
- package/dist/src/screen-recording-admission-ledger.js +0 -1
- package/dist/src/screenshot-runtime.js +0 -1
- package/dist/src/session-routing.js +0 -1
- package/dist/src/session-runtime-admission.js +0 -1
- package/dist/src/session-stream.js +0 -27
- package/dist/src/timeouts.js +0 -1
- package/dist/src/touch-reference-frame.js +0 -1
- package/dist/src/vars.js +0 -2
- package/dist/src/viewport.js +0 -1
package/dist/src/registry.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import{E as e,N as t,O as n,P as r,S as i,_ as a,k as o,m as s,n as c}from"./sdk-contracts.js";import{a as ee,d as te,f as ne,m as re,n as ie,p as ae,t as oe,u as se}from"./capture.js";import{A as ce,c as le,d as ue,f as de,h as fe,l as pe,m as me,s as he,u as ge,v as l}from"./sdk-batch-runner.js";import{t as _e}from"./viewport.js";import{a as ve,i as ye,n as be,t as xe}from"./sdk-device.js";import{a as Se,c as Ce}from"./lease-scope.js";import{An as we,Cr as Te,In as Ee,Mn as De,Nr as Oe,Rr as ke,_r as Ae,d as je,dr as Me,fr as Ne,h as Pe,hr as Fe,i as Ie,ln as Le,m as Re,ni as ze,s as Be,sn as Ve,ur as He}from"./sdk-batch.js";import{n as Ue}from"./recording-export-quality.js";import{t as We}from"./recording-scope.js";import{a as Ge,n as Ke,o as qe,r as Je,s as Ye}from"./scroll-gesture.js";import{E as Xe,T as Ze,b as Qe,v as $e,w as et}from"./script.js";import{a as tt,i as nt,r as rt}from"./vars.js";import{n as it,r as at,t as ot}from"./format.js";import{n as u,t as st}from"./catalog.js";import{i as ct,r as lt,t as ut}from"./back-mode.js";import{a as dt}from"./sdk-remote-config.js";import{t as ft}from"./session.js";import{a as pt,c as mt,d as ht,f as gt,g as _t,h as vt,i as yt,l as bt,n as xt,o as St,p as Ct,s as wt,t as Tt,u as Et}from"./observability.js";import{n as Dt,t as Ot}from"./success-text.js";import{a as d,i as kt,n as At,r as f}from"./output-common.js";import{t as jt}from"./alert-contract.js";import{a as Mt,i as Nt,l as Pt,o as Ft,s as It,t as Lt,u as Rt,x as zt}from"./settings.js";import{t as Bt}from"./location-coordinates.js";import{t as Vt}from"./snapshot-quality-backend-capabilities.js";import{f as Ht,m as Ut,p as Wt,r as Gt,s as Kt}from"./overlay.js";import{t as qt}from"./mobile-snapshot-semantics.js";import{t as Jt}from"./click-button.js";import{n as Yt}from"./scroll-command.js";import{n as Xt,t as Zt}from"./interaction-positionals.js";import{t as Qt}from"./app-inventory.js";import"./device.js";import{a as $t,f as en,i as tn,m as nn,o as rn,p as an,r as on,t as sn}from"./device-rotation.js";import"./app-inventory-contract.js";import{t as cn}from"./prepare-kind.js";import{n as ln,t as un}from"./path-resolution.js";import"./file.js";import{n as dn,r as fn,s as pn,t as mn}from"./tv-remote.js";import hn from"node:fs";import p from"node:path";const gn=[`path`,`start`,`stop`,`doctor`,`mark`,`clear`],_n=new Set(lt().map(e=>e.key));function vn(e){let t=Se(e);return ce({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...Ce(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,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,...n(e,a),...se(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,readinessTimeoutMs:e.readinessTimeoutMs,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 yn(e,t){return{...vn(e),...t}}function bn(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!_n.has(e))continue;let t=i[e];xn(t)&&(r[e]=t)}return r}function xn(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function Sn(e){return{kind:`operator`,source:e}}function Cn(e,t){return`${e} is not accepted as a tool argument. ${wn(e,t)}`}function wn(e,t){if(`operatorPath`in t)return t.operatorPath;let n=`for the process serving these tools.`,r=(t.envFlagKeys??[e]).map(dt).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 Tn(e){if(e==null)return{};if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`Expected object arguments.`);return e}function En(e,t){let n=e[t];if(!n||typeof n!=`object`||Array.isArray(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be an object.`);return n}function Dn(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw new r(`INVALID_ARGS`,`Expected ${t} to be a non-empty string.`);return n}function On(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw new r(`INVALID_ARGS`,`Expected ${t} to be a string.`);return n}}function m(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`||n.length===0)throw new r(`INVALID_ARGS`,`Expected ${t} to be a non-empty string.`);return n}}function kn(e,t){let n=e[t];if(typeof n!=`number`||!Number.isFinite(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be a finite number.`);return n}function An(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw new r(`INVALID_ARGS`,`Expected ${t} to be a boolean.`);return n}}function jn(e,t,n){let i=e[t];if(typeof i!=`string`||!n.includes(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be one of: ${n.join(`, `)}.`);return i}function Mn(e,t,n){let i=e[t];if(i!==void 0){if(typeof i!=`string`||!n.includes(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be one of: ${n.join(`, `)}.`);return i}}function Nn(e,t){let n=e[t];if(n!==void 0){if(!n||typeof n!=`object`||Array.isArray(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be an object.`);return n}}function Pn(e,t){let n=e[t];if(n!==void 0){if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))throw new r(`INVALID_ARGS`,`Expected ${t} to be an array of strings.`);return n}}function Fn(e,t,n,i){let a=new Set(t),o=Object.keys(e).filter(e=>!a.has(e));if(o.length>0)throw new r(`INVALID_ARGS`,`${n} has unknown field(s): ${o.join(`, `)}.`,i===void 0?void 0:{hint:i})}function h(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}const In=Sn({operatorConfig:!0}),Ln={session:{schema:{type:`string`,description:`Agent-device session name.`},read:e=>m(e,`session`),flagKey:`session`,flagIn:[`input`]},platform:{schema:{type:`string`,enum:ye,description:`Platform selector used to resolve a device.`},read:e=>Mn(e,`platform`,ye),flagKey:`platform`,flagIn:[`input`,`selection`]},deviceTarget:{schema:{type:`string`,enum:be,description:`Device target form. Maps to the CLI --target flag.`},read:Un,clientKey:`target`,flagKey:`target`,flagIn:[`input`,`selection`]},target:{schema:{type:`string`,enum:be,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=>m(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=>m(e,`udid`),flagKey:`udid`,flagIn:[`input`,`selection`]},serial:{schema:{type:`string`,description:`Android, HarmonyOS, or Vega VVD serial selector.`},read:e=>m(e,`serial`),flagKey:`serial`,flagIn:[`input`,`selection`]},iosSimulatorDeviceSet:{schema:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},read:e=>m(e,`iosSimulatorDeviceSet`),audience:Sn({envFlagKeys:[],operatorConfig:!0}),flagKey:`iosSimulatorDeviceSet`,flagIn:[`input`,`selection`]},iosXctestrunFile:{schema:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},read:e=>m(e,`iosXctestrunFile`),audience:In,flagKey:`iosXctestrunFile`,flagIn:[`input`]},iosXctestDerivedDataPath:{schema:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},read:e=>m(e,`iosXctestDerivedDataPath`),audience:In,flagKey:`iosXctestDerivedDataPath`,flagIn:[`input`]},iosXctestEnvDir:{schema:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},read:e=>m(e,`iosXctestEnvDir`),audience:In,flagKey:`iosXctestEnvDir`,flagIn:[`input`]},androidDeviceAllowlist:{schema:{type:`string`,description:`Android serial allowlist used for device resolution.`},read:e=>m(e,`androidDeviceAllowlist`),flagKey:`androidDeviceAllowlist`,flagIn:[`input`,`selection`]},noRecord:{read:e=>An(e,`noRecord`),flagKey:`noRecord`,flagIn:[`input`,`selection`]},readinessTimeoutMs:{read:Wn},daemonBaseUrl:{schema:{type:`string`,description:`Remote daemon base URL.`},read:e=>m(e,`daemonBaseUrl`),audience:In},daemonAuthToken:{schema:{type:`string`,description:`Remote daemon auth token.`},read:e=>m(e,`daemonAuthToken`),audience:In},tenant:{schema:{type:`string`,description:`Remote tenant identifier.`},read:e=>m(e,`tenant`)},runId:{schema:{type:`string`,description:`Lease run identifier.`},read:e=>m(e,`runId`)},leaseId:{schema:{type:`string`,description:`Existing lease identifier.`},read:e=>m(e,`leaseId`)},cwd:{schema:{type:`string`,description:`Working directory for command execution.`},read:e=>m(e,`cwd`),audience:Sn({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=>An(e,`debug`)}},Rn=Object.entries(Ln),zn=Object.fromEntries(Rn.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function Bn(){return Object.fromEntries(Rn.flatMap(([e,t])=>t.schema?[[e,t.schema]]:[]))}function Vn(e,t={}){let n={};for(let[r,i]of Rn)i.read&&(n[r]=i.read(e,t));return n}function g(e){let t={};for(let[n,r]of Rn)r.read&&(t[r.clientKey??n]=e[n]);return h(t)}function Hn(e,t){let n={};for(let[r,i]of Rn){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 Un(e,t){let n=Mn(e,`deviceTarget`,be);if(t.readTargetAlias===!1||e.target===void 0)return n;let i=Mn(e,`target`,be);if(n!==void 0&&i!==n)throw new r(`INVALID_ARGS`,`Expected target alias to match deviceTarget when both are set.`);return n??i}function Wn(e,t){if(!(t.readinessBudgetDeclared===!0||!Object.hasOwn(e,`readinessTimeoutMs`)))throw new r(`INVALID_ARGS`,`readinessTimeoutMs applies only to commands that wait for their target: press, click, and longpress.`)}function _(e,t){return n=>v(e,t?t(n):[],n)}function v(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Gn(n)}}function Gn(e){let t=Kn(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 Kn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function y(e){return h(Hn(e,`input`))}function qn(e){return h({record:e.record})}function Jn(e){return Hn(e,`selection`)}function Yn(e){return h({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Xn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function Zn(e){return h({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Qn(e){return h({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function $n(e){if(`ref`in e&&e.ref!==void 0)return h({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 er(e){let t=nr(e);if(typeof t.ref==`string`)return[t.ref,...ir(t.label)];if(typeof t.selector==`string`)return[t.selector];if(t.kind===`point`||t.x!==void 0||t.y!==void 0)return[String(rr(t.x,`x`)),String(rr(t.y,`y`))];throw new r(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function tr(e){let t=nr(e);if(typeof t.ref==`string`)return[t.ref,...ir(t.label)];if(typeof t.selector==`string`)return[t.selector];throw new r(`INVALID_ARGS`,`element command requires @ref or selector target`)}function nr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`Expected target object.`);let t=e,n=t.target;return n&&typeof n==`object`&&!Array.isArray(n)?n:t}function rr(e,t){if(typeof e!=`number`||!Number.isFinite(e))throw new r(`INVALID_ARGS`,`point target requires numeric ${t}.`);return e}function ir(e){return typeof e==`string`&&e.length>0?[e]:[]}function ar(e){let t=Me(e);if(!t.ok)throw new r(t.code,t.message);return`ref`in t?{ref:t.ref,label:lr(e.slice(1))}:{selector:t.selector}}function or(e){let t=Ne(e);if(!t.ok)throw new r(t.code,t.message);return t.format}function sr(e,t={}){let n=Te(e,t);if(!n)throw new r(`INVALID_ARGS`,He);return n}function cr(e,t){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}throw new r(`INVALID_ARGS`,`${t} must be a JSON object`)}function lr(e){return e.join(` `).trim()||void 0}function b(...e){return new Set(e)}function x(e,t){return e!==void 0&&t.has(e)}function ur(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function dr(e,t){if(e===void 0)return;let n=Number(e);if(Number.isFinite(n))return n;throw new r(`INVALID_ARGS`,`${t} must be a finite number.`)}function fr(e){return e===void 0?void 0:Number(e)}function S(e){return e===void 0?[]:[e]}function C(e){return e===void 0?[]:[String(e)]}function w(e,t){if(e===void 0||e===``)throw new r(`INVALID_ARGS`,t);return e}function T(e,t){if(typeof e!=`string`||e.length===0)throw new r(`INVALID_ARGS`,t);return e}function pr(e){return gr(e.description,e.cliDetail)}function mr(e){return gr(e.description,e.mcpDetail)}function hr(e,t){return{...e,description:t}}function gr(e,t){return t?`${e} ${t}`:e}function _r(e){return e}const vr=[`ref`,`selector`,`point`];function yr(e,t=[]){return{type:`object`,properties:{...Bn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function E(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}function br(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function D(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function O(e){return{type:`string`,const:e}}function k(e){return{type:`string`,...e?{description:e}:{}}}function xr(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function A(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Sr(e){return{type:`integer`,...e?{description:e}:{}}}function j(e){return{type:`boolean`,...e?{description:e}:{}}}function Cr(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function M(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function N(e){return{...e,required:!0}}function P(e,t={}){return B(k(e),t.allowEmpty===!0?On:m)}function wr(e){return{schema:{type:`null`},required:!1,audience:{kind:`retired`,message:e},read:(t,n)=>{if(Object.hasOwn(t,n))throw new r(`INVALID_ARGS`,e)}}}function Tr(e,t){return{...e,audience:{kind:`operator`,source:t}}}function F(e,t={}){return B(A(e,t),(e,n)=>fe(e,n,t))}function I(e,t={}){return B(qr(e,t),(e,n)=>me(e,n,t))}function L(e){return B(j(e),An)}function Er(e){return Or(Dr(e))}function Dr(e){let[t,...n]=ct(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 Or(e){let t=e.inputDescription,n={min:e.min,max:e.max};switch(e.type){case`boolean`:return L(t);case`int`:return I(t,n);case`number`:return F(t,n);case`string`:return P(t);case`enum`:return R(kr(e),t);case`booleanOrString`:throw Error(`Flag ${e.key} is booleanOrString; declare its field shape explicitly with jsonSchemaField`)}}function kr(e){let t=e.enumValues;if(!t)throw Error(`Flag ${e.key} is an enum with no enumValues`);return t}function R(e,t){return B(D(e,t),(t,n)=>Mn(t,n,e))}function Ar(e){return B(M(e),Nn)}function jr(e){return B(Cr(e),Pn)}function z(e){return B(e,(e,t)=>e[t])}function Mr(e,t){return B(e,t)}function Nr(){return B(Zr(),(e,t)=>e[t]===void 0?void 0:Br(e,t))}function Pr(){return B(Qr(),(e,t)=>e[t]===void 0?void 0:Vr(e,t))}function Fr(e){return B(br(e),(e,t)=>e[t]===void 0?void 0:Hr(e,t))}function Ir(){return{depth:I(`Snapshot traversal depth.`,{min:0}),scope:P(`Snapshot scope selector used before resolution.`),raw:L(`Use raw snapshot data during selector resolution.`)}}function Lr(){return{count:I(`Number of press/click repetitions.`,{min:1}),intervalMs:I(`Delay between repeated press/click actions.`,{min:0}),holdMs:I(`Hold duration for each action.`,{min:0}),jitterPx:I(`Randomization radius in pixels.`,{min:0}),doubleTap:L(`Request a double-tap action.`)}}function Rr(e){return yr(Jr(e),Yr(e))}function zr(e,t){let n=Tn(e),i=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let i=t.read(n,e);if(t.required&&i===void 0)throw new r(`INVALID_ARGS`,`Expected ${e} to be set.`);return i===void 0?[]:[[e,i]]})),a=Vn(n,{readTargetAlias:!Object.hasOwn(t,`target`),readinessBudgetDeclared:Object.hasOwn(t,`readinessTimeoutMs`)});return h({...a,...g(a),...i})}function Br(e,t){let n=En(e,t),r=jn(n,`kind`,vr);switch(r){case`ref`:return{kind:r,ref:Dn(n,`ref`),label:m(n,`label`)};case`selector`:return{kind:r,selector:Dn(n,`selector`)};case`point`:return{kind:r,x:kn(n,`x`),y:kn(n,`y`)}}}function Vr(e,t){let n=En(e,t),r=jn(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:Dn(n,`ref`),label:m(n,`label`)}:{kind:r,selector:Dn(n,`selector`)}}function Hr(e,t){let n=En(e,t);return{x:kn(n,`x`),y:kn(n,`y`)}}function Ur(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 Wr(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function Gr(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function Kr(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function B(e,t){return{schema:e,required:!1,read:t}}function qr(e,t){return{...Sr(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Jr(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.audience?.kind!==`retired`).map(([e,t])=>[e,t.schema]))}function Yr(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function Xr(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]))}function Zr(){return{oneOf:[...$r(),{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 Qr(){return{oneOf:$r(),description:`UI element target by snapshot ref or selector expression.`}}function $r(){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 V(e,t,n,r){return _r({name:e,description:t,inputSchema:Rr(n),readInput:r?.readInput??(e=>zr(e,n)),inputAudience:Xr(n),...r?.parseableOutput?{parseableOutput:!0}:{}})}function H(e){let t=hr(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 ei(e){return H({name:e.name,text:e.text,metadata:V(e.name,e.description,{}),run:e.run,cliSchema:{},cliReader:(e,t)=>y(t),daemonWriter:_(e.name),cliOutputFormatter:e.cliOutputFormatter})}function U(e){let t={},n={},r={},i={};for(let a of e.commands)ti(t,`CLI schema`,a.name,a.cliSchema),ti(n,`CLI reader`,a.name,a.cliReader),a.daemonWriter&&ti(r,`daemon writer`,a.name,a.daemonWriter),a.cliOutputFormatter&&ti(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 ti(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function ni(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(ii(n));return{data:e,text:t.join(`
|
|
2
|
-
`)}}const ri={batch:d(ni)};function ii(e){let t=
|
|
3
|
-
`)}`}const Si=U({name:`batch`,clientSurface:!1,commands:[H({name:`batch`,text:{summary:`Run multiple commands`,cliDetail:xi()},metadata:_i,run:(e,t)=>e.batch.run(Ci(t)),cliSchema:vi,cliReader:yi,cliOutputFormatter:ri.batch})]});function Ci(e){return{...g(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}const wi=`alert`,Ti=H({name:wi,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:V(wi,`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:R(jt),timeoutMs:I()}),run:(e,t)=>e.command.alert(t),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...y(t),...Di(e)}),daemonWriter:_(u.alert,e=>Ei(e)),cliOutputFormatter:f});function Ei(e){return[e.action??`get`,...C(e.timeoutMs)]}function Di(e){if(e.length>2)throw new r(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return h({action:Oi(e[0]),timeoutMs:dr(e[1],`alert timeout`)})}function Oi(e){let t=e?.toLowerCase();if(t===void 0||t===`get`||t===`accept`||t===`dismiss`||t===`wait`)return t;throw new r(`INVALID_ARGS`,`alert action must be get, accept, dismiss, or wait.`)}function W(...e){return e}const ki=W(`keyframes`),Ai=W(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),ji=W(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Mi=W(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Ni=W(`metroHost`,`metroPort`,`bundleUrl`),Pi=W(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Fi=W(`settle`,`settleQuietMs`,`timeoutMs`),Ii=W(`replayUpdate`,`replayEnv`),Li=W(`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`),Ri=new Set([`platform`,`device`,`udid`,`serial`,`session`]),zi=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),Bi=`diff`,Vi={diff:E({mode:O(`snapshot`),baselineInitialized:j(),summary:E({additions:A(),removals:A(),unchanged:A()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:E({kind:D([`added`,`removed`,`unchanged`]),text:k(),ref:k()},[`kind`,`text`])},warnings:Cr()},[`mode`,`baselineInitialized`,`summary`,`lines`])},Hi=H({name:Bi,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:V(Bi,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:N(z({type:`string`,const:`snapshot`})),out:P(),interactiveOnly:L(),depth:I(),scope:P(),raw:L()}),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:[...Ai,`baseline`,`threshold`,`out`,`overlayRefs`]},cliReader:(e,t)=>{if(e[0]!==`snapshot`)throw new r(`INVALID_ARGS`,`Only diff snapshot is available through this parser.`);return{...y(t),kind:`snapshot`,out:t.out,interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw}},daemonWriter:_(u.diff,e=>[T(e.kind,`diff requires kind`)])}),Ui=`screenshot`,Wi=H({name:Ui,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. On macOS, any --surface other than app (desktop, menubar, frontmost-app) always captures the main display and refuses an explicit --fullscreen. On single-display iOS simulators and Android devices, the result reports displayRotation, the rotation the display rendered the capture in, when the device returns a reading in time; otherwise the field is absent.`},metadata:V(Ui,`Capture a screenshot of the active app or web session. Choose the capture scope, density, size, or annotations through the corresponding input fields when needed.`,{path:P(`Output path.`),cropOn:P(`Selector expression; the capture is cropped to the frame the selector resolves on the same screen.`),overlayRefs:L(),pixelDensity:I(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:L(),scale:F(`Screenshot scale factor.`,ee),maxSize:wr(oe.migration.screenshot),stabilize:L(),normalizeStatusBar:L(),surface:R(ft)}),run:(e,t)=>e.capture.screenshot(t),cliSchema:{positionalArgs:[`path?`],allowedFlags:ie},cliReader:(e,t)=>({...y(t),path:e[0]??t.out,...ne(t)}),daemonWriter:e=>(ae(`screenshot`,e),re(e),v(u.screenshot,S(e.path),{...e,...te(e)}))}),Gi=`settings`,Ki=V(Gi,`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:N(P()),state:P(),app:P("App the change targets, by bundle id or package name: the app `clear-app-state` clears, or the app a `permission` change (or an iOS-simulator `location on|off` privacy change) lands on. An app named here needs no session and need not be running (Android `deny|reset` of a held permission does kill a running one); without it those changes use the session app, and a change that is device-wide refuses one with `setting_app_not_consumed` (`location set` on any target, the Android `location on|off` toggle, macOS permissions). The CLI consumes it only when this invocation passes it: an `AGENT_DEVICE_TARGET_APP` or config `targetApp` never retargets a settings mutation."),latitude:F(),longitude:F(),permission:P(),mode:R([...It])}),qi={usageOverride:Rt,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state?`,`target?`,`mode?`],allowedFlags:[`targetApp`],explicitOnlyFlags:[`targetApp`]},Ji=(e,t)=>{let n=Qi(e,t);return n.setting===`clear-app-state`||t.targetApp===void 0?n:{...n,app:t.targetApp}},Yi=e=>{let t=e,n=h({app:Xi(t)});return v(u.settings,ea(t),e,Object.keys(n).length===0?void 0:n)};function Xi(e){if(e.setting===`permission`||e.setting===`location`)return e.app}const Zi=H({name:Gi,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings ${Pt}; wifi|airplane|location|animations|text-size remain unsupported on macOS. Mobile permission actions default to the active session app; pass --app <id> (or the app input) to aim a permission change, or an iOS-simulator location on|off, at an installed app no session has opened; no app needs to be running, and the CLI consumes the app only when this invocation names it, never from AGENT_DEVICE_TARGET_APP or config targetApp. clear-app-state takes its app positionally or with --app, and refuses two different apps. A device-wide change refuses an app with setting_app_not_consumed: location set moves the device's own coordinates on every target, the Android location toggle writes the device's location_mode, and a macOS permission is a host-level TCC grant. 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:Ki,run:(e,t)=>e.settings.update(t),cliSchema:qi,cliReader:Ji,daemonWriter:Yi,cliOutputFormatter:f});function Qi(e,t){let n=Jn(t),i=e[0],a=e[1];if(x(i,ra)&&x(a,ia))return{...n,setting:i,state:a};if(i===`location`&&a===`set`)return{...n,setting:i,state:a,latitude:Bt(e[2],`latitude`),longitude:Bt(e[3],`longitude`)};if(i===`appearance`&&x(a,aa))return{...n,setting:i,state:a};if(i===`text-size`)return a===void 0?{...n,setting:i}:{...n,setting:i,state:zt(a)};if(x(i,oa)&&x(a,sa)||i===`fingerprint`&&x(a,ca))return{...n,setting:i,state:a};if(i===`permission`&&x(a,ua))return{...n,setting:i,state:a,permission:ta(e[2]),mode:na(e[3])};if(i===`clear-app-state`)return{...n,setting:i,state:`clear`,app:$i(e,t)};if(i===`reset-keychain`&&a===`clear`&&e.length===2)return{...n,setting:i,state:a};throw new r(`INVALID_ARGS`,`Invalid settings arguments.`)}function $i(e,t){let n=e[1]===`clear`?e[2]:e[1],i=t.targetApp;if(n!==void 0&&i!==void 0&&n!==i)throw new r(`INVALID_ARGS`,`settings clear-app-state names two apps: ${n} and ${i}. Name one.`);return n??i}function ea(e){return e.setting===`clear-app-state`?[e.setting,...S(e.app)]:e.setting===`text-size`?[e.setting,...S(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,...S(e.mode)]:[e.setting,e.state]}function ta(e){if(x(e,da))return e;throw new r(`INVALID_ARGS`,`settings permission requires a permission target.`)}function na(e){if(e===void 0||x(e,la))return e;throw new r(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const ra=b(`wifi`,`airplane`,`location`,`animations`),ia=b(`on`,`off`),aa=b(...Lt),oa=b(`faceid`,`touchid`),sa=b(`match`,`nonmatch`,`enroll`,`unenroll`),ca=b(`match`,`nonmatch`),la=b(...It),ua=b(...Ft),da=b(...Mt,...Nt);function fa(e){if(!Array.isArray(e)||e.length===0)return e;let t=ke(e);return e.map(e=>{let n=pa(e,t,e=>e.label),r=pa(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 pa(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 ma(e){return e.width>0&&e.height>0}function ha(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 ga(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 _a(e){return typeof e.parentIndex!=`number`}function va(e){let t=(e.type??``).toLowerCase(),n=(e.identifier??``).trim().toLowerCase();return t.includes(`edittext`)||t.includes(`textfield`)||n===`composer`}function ya(e){let t=(e.type??``).toLowerCase();return t.includes(`scroll`)||t.includes(`list`)||t.includes(`recyclerview`)}function ba(e){let t=Oe(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 xa(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 wa(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 Ta(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 Ea=[`button`,`switch`,`checkbox`,`radio`],Da=[`button`,`image`,`textview`,`view`];function Oa(e,t,n){for(let r of e){if(t.has(r.index)||!ja(r))continue;let i=Ma(wa(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)Ta(e,n,t)}}}function ka(e,t,n){let r=new Map;for(let i of e){if(t.has(i.index)||!Ba(i))continue;let a=xa(ba(i));if(!a)continue;let o=r.get(a);if(o&&La(o,i,t)){let s=Ra(e,o,i,t,n);r.set(a,s);continue}r.set(a,i)}}function Aa(e,t){for(let n of e){if(t.has(n.index)||!Fa(n))continue;let r=xa(ba(n));if(!r)continue;let i=wa(e,n.index).filter(e=>!t.has(e.index)&&Ia(n,e,r));for(let n of i.filter(Pa))Ta(e,n.index,t);let a=i.filter(e=>!Pa(e)),o=new Set(a.map(e=>xa(ba(e))).filter(e=>!!e));if(!(a.length<2||o.size<2))for(let n of a)Ta(e,n.index,t)}}function ja(e){return e.hittable===!0&&!va(e)&&!!(e.rect&&ma(e.rect))&&ba(e).trim().length===0}function Ma(e,t,n){let r=[],i=[],a=new Set;for(let o of e){if(n.has(o.index)||!Na(o,e)||!ha(o.rect,t.rect))continue;let s=ba(o).trim().replaceAll(/\s+/g,` `),c=xa(s);i.push(o.index),!(!s||!c||a.has(c))&&(a.add(c),r.push(s))}return{label:r.join(`, `),removableIndexes:i}}function Na(e,t){if(Pa(e))return!0;let n=(e.type??``).toLowerCase();return e.hittable!==!0&&!va(e)&&n.includes(`view`)&&ba(e).trim().length>0&&!t.some(t=>t.parentIndex===e.index)}function Pa(e){if(e.hittable===!0||va(e))return!1;let t=(e.type??``).toLowerCase();return t.includes(`text`)||t.includes(`image`)||t.includes(`icon`)}function Fa(e){return e.hittable===!0&&!va(e)&&!!(e.rect&&ma(e.rect))&&!!xa(ba(e))}function Ia(e,t,n){if(!Ba(t)||!ha(t.rect,e.rect))return!1;let r=xa(ba(t));return!!(r&&n!==r&&n.includes(r))}function La(e,t,n){return!n.has(e.index)&&ga(e.rect,t.rect)&&(Ga(e,t)||Wa(e,t))}function Ra(e,t,n,r,i){let a=Va(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:za(c.presentationHints,ee,s)}),Ta(e,o.index,r),i.get(a.index)??a}function za(e,t,n){return[...new Set([...Array.isArray(e)?e:[],...Array.isArray(t)?t:[],...n?[n]:[]])]}function Ba(e){if(!e.rect||!ma(e.rect)||_a(e)||va(e))return!1;let t=(e.type??``).toLowerCase();return t===`text`||Ua(t,Da)}function Va(e,t){let n=Ha(e);return Ha(t)>n?t:e}function Ha(e){let t=(e.type??``).toLowerCase(),n=0;return Ua(t,Ea)?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 Ua(e,t){return t.some(t=>e.includes(t))}function Wa(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:Va(n,r).index===n.index}function Ga(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 Ka(e,t,n){if(n.raw||!qa(e))return{nodes:t,filteredCount:0};let r=Ja(t);return{nodes:r,filteredCount:t.length-r.length}}function qa(e){let t=e.androidSnapshot;return!t||typeof t!=`object`?!1:t.backend===`android-helper`}function Ja(e){if(e.length===0)return e;let t=new Set,n=new Map,r=new Map(e.map(e=>[e.index,e]));return Ya(e,t),Xa(e,r,t,n),Oa(e,t,n),Aa(e,t),ka(e,t,n),e.filter(e=>!t.has(e.index)).map(e=>n.get(e.index)??e)}function Ya(e,t){for(let n of e)!n.rect||ma(n.rect)||_a(n)||Ta(e,n.index,t)}function Xa(e,t,n,r){for(let i of e){if(n.has(i.index)||i.rect||_a(i))continue;let a=Ca(i,t,ya);a&&Qa(r,a,Za(i,e)),Ta(e,i.index,n)}}function Za(e,t){let n=t.filter(t=>t.parentIndex===e.parentIndex&&t.rect&&ma(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 Qa(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 $a(e){if(e.length<20)return!1;let t=new Map;for(let n of e){let e=(n.type??``).toLowerCase(),r=eo(Oe(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||!no(e)||(n+=e.length);return n>=8}function eo(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||to(t)?null:t}function to(e){return/\S+@\S+\.\S+/.test(e)}function no(e){for(let t=0;t<e.length;t+=1)for(let n=t+1;n<e.length;n+=1)if(ro(e[t]?.rect,e[n]?.rect))return!0;return!1}function ro(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 io(n,r={}){let i=n.nodes,a=Array.isArray(i)?i:[],o=e(n.backend)?n.backend:void 0,s=t(o),c=Ka(n,a,r),ee=co(n),te=vo(n,a,r,c),ne=te.length>0?`${te.join(`
|
|
4
|
-
`)}\n`:``,re=r.raw?null:ao(n);if(re)return`${ee}${ne}${oo(re)}\n`;let ie=r.raw||!s?null:
|
|
1
|
+
import{E as e,N as t,O as n,P as r,S as i,_ as a,k as o,m as s,n as c}from"./sdk-contracts.js";import{a as ee,d as te,f as ne,m as re,n as ie,p as ae,t as oe,u as se}from"./capture.js";import{A as ce,c as le,d as ue,f as de,h as fe,l as pe,m as me,s as he,u as ge,v as l}from"./sdk-batch-runner.js";import{a as _e,i as ve,n as ye,t as be}from"./sdk-device.js";import{a as xe,c as Se}from"./lease-scope.js";import{Ln as Ce,Nn as we,Pr as Te,cn as Ee,d as De,dr as Oe,fr as ke,gr as Ae,h as je,i as Me,ii as Ne,jn as Pe,m as Fe,pr as Ie,s as Le,un as Re,vr as ze,wr as Be,zr as Ve}from"./sdk-batch.js";import{n as He}from"./recording-export-quality.js";import{t as Ue}from"./recording-scope.js";import{a as We,n as Ge,o as Ke,r as qe,s as Je}from"./scroll-gesture.js";import{E as Ye,T as Xe,b as Ze,v as Qe,w as $e}from"./script.js";import{c as et,n as tt,o as nt,r as rt,s as it,t as at}from"./format.js";import{n as u,t as ot}from"./catalog.js";import{i as st,r as ct,t as lt}from"./back-mode.js";import{a as ut}from"./sdk-remote-config.js";import{t as dt}from"./session.js";import{a as ft,c as pt,d as mt,f as ht,g as gt,h as _t,i as vt,l as yt,n as bt,o as xt,p as St,s as Ct,t as wt,u as Tt}from"./observability.js";import{n as Et,t as Dt}from"./success-text.js";import{a as d,i as Ot,n as kt,r as f}from"./output-common.js";import{t as At}from"./alert-contract.js";import{a as jt,i as Mt,l as Nt,o as Pt,s as Ft,t as It,u as Lt,x as Rt}from"./settings.js";import{t as zt}from"./location-coordinates.js";import{t as Bt}from"./snapshot-quality-backend-capabilities.js";import{f as Vt,h as Ht,p as Ut,r as Wt,s as Gt}from"./overlay.js";import{t as Kt}from"./mobile-snapshot-semantics.js";import{t as qt}from"./click-button.js";import{n as Jt}from"./scroll-command.js";import{n as Yt,t as Xt}from"./interaction-positionals.js";import{t as Zt}from"./app-inventory.js";import"./device.js";import{a as Qt,f as $t,i as en,m as tn,o as nn,p as rn,r as an,t as on}from"./device-rotation.js";import"./app-inventory-contract.js";import{n as sn,t as cn}from"./path-resolution.js";import"./file.js";import{n as ln,r as un,s as dn,t as fn}from"./tv-remote.js";import pn from"node:fs";import p from"node:path";function mn(e,t){let n=e===void 0?NaN:Number(e);if(!Number.isInteger(n)||n<1)throw new r(`INVALID_ARGS`,`viewport ${t} must be a positive integer`);return n}function hn(e){if(e.length!==2)throw new r(`INVALID_ARGS`,`viewport requires exactly two arguments: <width> <height>`);return{width:mn(e[0],`width`),height:mn(e[1],`height`)}}const gn=[`path`,`start`,`stop`,`doctor`,`mark`,`clear`],_n=new Set(ct().map(e=>e.key));function vn(e){let t=xe(e);return ce({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...Se(t),provider:e.provider,providerSessionId:e.providerSessionId,providerApp:e.providerApp,providerOsVersion:e.providerOsVersion,providerDeviceType:e.providerDeviceType,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,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,...n(e,a),...se(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,readinessTimeoutMs:e.readinessTimeoutMs,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 yn(e,t){return{...vn(e),...t}}function bn(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!_n.has(e))continue;let t=i[e];xn(t)&&(r[e]=t)}return r}function xn(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function Sn(e){return{kind:`operator`,source:e}}function Cn(e,t){return`${e} is not accepted as a tool argument. ${wn(e,t)}`}function wn(e,t){if(`operatorPath`in t)return t.operatorPath;let n=`for the process serving these tools.`,r=(t.envFlagKeys??[e]).map(ut).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 Tn(e){if(e==null)return{};if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`Expected object arguments.`);return e}function En(e,t){let n=e[t];if(!n||typeof n!=`object`||Array.isArray(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be an object.`);return n}function Dn(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw new r(`INVALID_ARGS`,`Expected ${t} to be a non-empty string.`);return n}function On(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw new r(`INVALID_ARGS`,`Expected ${t} to be a string.`);return n}}function m(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`||n.length===0)throw new r(`INVALID_ARGS`,`Expected ${t} to be a non-empty string.`);return n}}function kn(e,t){let n=e[t];if(typeof n!=`number`||!Number.isFinite(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be a finite number.`);return n}function An(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw new r(`INVALID_ARGS`,`Expected ${t} to be a boolean.`);return n}}function jn(e,t,n){let i=e[t];if(typeof i!=`string`||!n.includes(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be one of: ${n.join(`, `)}.`);return i}function Mn(e,t,n){let i=e[t];if(i!==void 0){if(typeof i!=`string`||!n.includes(i))throw new r(`INVALID_ARGS`,`Expected ${t} to be one of: ${n.join(`, `)}.`);return i}}function Nn(e,t){let n=e[t];if(n!==void 0){if(!n||typeof n!=`object`||Array.isArray(n))throw new r(`INVALID_ARGS`,`Expected ${t} to be an object.`);return n}}function Pn(e,t){let n=e[t];if(n!==void 0){if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))throw new r(`INVALID_ARGS`,`Expected ${t} to be an array of strings.`);return n}}function Fn(e,t,n,i){let a=new Set(t),o=Object.keys(e).filter(e=>!a.has(e));if(o.length>0)throw new r(`INVALID_ARGS`,`${n} has unknown field(s): ${o.join(`, `)}.`,i===void 0?void 0:{hint:i})}function h(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}const In=Sn({operatorConfig:!0}),Ln={session:{schema:{type:`string`,description:`Agent-device session name.`},read:e=>m(e,`session`),flagKey:`session`,flagIn:[`input`]},platform:{schema:{type:`string`,enum:ve,description:`Platform selector used to resolve a device.`},read:e=>Mn(e,`platform`,ve),flagKey:`platform`,flagIn:[`input`,`selection`]},deviceTarget:{schema:{type:`string`,enum:ye,description:`Device target form. Maps to the CLI --target flag.`},read:Un,clientKey:`target`,flagKey:`target`,flagIn:[`input`,`selection`]},target:{schema:{type:`string`,enum:ye,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=>m(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=>m(e,`udid`),flagKey:`udid`,flagIn:[`input`,`selection`]},serial:{schema:{type:`string`,description:`Android, HarmonyOS, or Vega VVD serial selector.`},read:e=>m(e,`serial`),flagKey:`serial`,flagIn:[`input`,`selection`]},iosSimulatorDeviceSet:{schema:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},read:e=>m(e,`iosSimulatorDeviceSet`),audience:Sn({envFlagKeys:[],operatorConfig:!0}),flagKey:`iosSimulatorDeviceSet`,flagIn:[`input`,`selection`]},iosXctestrunFile:{schema:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},read:e=>m(e,`iosXctestrunFile`),audience:In,flagKey:`iosXctestrunFile`,flagIn:[`input`]},iosXctestDerivedDataPath:{schema:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},read:e=>m(e,`iosXctestDerivedDataPath`),audience:In,flagKey:`iosXctestDerivedDataPath`,flagIn:[`input`]},iosXctestEnvDir:{schema:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},read:e=>m(e,`iosXctestEnvDir`),audience:In,flagKey:`iosXctestEnvDir`,flagIn:[`input`]},androidDeviceAllowlist:{schema:{type:`string`,description:`Android serial allowlist used for device resolution.`},read:e=>m(e,`androidDeviceAllowlist`),flagKey:`androidDeviceAllowlist`,flagIn:[`input`,`selection`]},noRecord:{read:e=>An(e,`noRecord`),flagKey:`noRecord`,flagIn:[`input`,`selection`]},readinessTimeoutMs:{read:Wn},daemonBaseUrl:{schema:{type:`string`,description:`Remote daemon base URL.`},read:e=>m(e,`daemonBaseUrl`),audience:In},daemonAuthToken:{schema:{type:`string`,description:`Remote daemon auth token.`},read:e=>m(e,`daemonAuthToken`),audience:In},tenant:{schema:{type:`string`,description:`Remote tenant identifier.`},read:e=>m(e,`tenant`)},runId:{schema:{type:`string`,description:`Lease run identifier.`},read:e=>m(e,`runId`)},leaseId:{schema:{type:`string`,description:`Existing lease identifier.`},read:e=>m(e,`leaseId`)},cwd:{schema:{type:`string`,description:`Working directory for command execution.`},read:e=>m(e,`cwd`),audience:Sn({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=>An(e,`debug`)}},Rn=Object.entries(Ln),zn=Object.fromEntries(Rn.flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]));function Bn(){return Object.fromEntries(Rn.flatMap(([e,t])=>t.schema?[[e,t.schema]]:[]))}function Vn(e,t={}){let n={};for(let[r,i]of Rn)i.read&&(n[r]=i.read(e,t));return n}function g(e){let t={};for(let[n,r]of Rn)r.read&&(t[r.clientKey??n]=e[n]);return h(t)}function Hn(e,t){let n={};for(let[r,i]of Rn){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 Un(e,t){let n=Mn(e,`deviceTarget`,ye);if(t.readTargetAlias===!1||e.target===void 0)return n;let i=Mn(e,`target`,ye);if(n!==void 0&&i!==n)throw new r(`INVALID_ARGS`,`Expected target alias to match deviceTarget when both are set.`);return n??i}function Wn(e,t){if(!(t.readinessBudgetDeclared===!0||!Object.hasOwn(e,`readinessTimeoutMs`)))throw new r(`INVALID_ARGS`,`readinessTimeoutMs applies only to commands that wait for their target: press, click, and longpress.`)}function _(e,t){return n=>v(e,t?t(n):[],n)}function v(e,t,n,r){return{command:e,positionals:t,...r?{input:r}:{},options:Gn(n)}}function Gn(e){let t=Kn(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 Kn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function y(e){return h(Hn(e,`input`))}function qn(e){return h({record:e.record})}function Jn(e){return Hn(e,`selection`)}function Yn(e){return h({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Xn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function Zn(e){return h({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Qn(e){return h({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function $n(e){if(`ref`in e&&e.ref!==void 0)return h({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 er(e){let t=nr(e);if(typeof t.ref==`string`)return[t.ref,...ir(t.label)];if(typeof t.selector==`string`)return[t.selector];if(t.kind===`point`||t.x!==void 0||t.y!==void 0)return[String(rr(t.x,`x`)),String(rr(t.y,`y`))];throw new r(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function tr(e){let t=nr(e);if(typeof t.ref==`string`)return[t.ref,...ir(t.label)];if(typeof t.selector==`string`)return[t.selector];throw new r(`INVALID_ARGS`,`element command requires @ref or selector target`)}function nr(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`Expected target object.`);let t=e,n=t.target;return n&&typeof n==`object`&&!Array.isArray(n)?n:t}function rr(e,t){if(typeof e!=`number`||!Number.isFinite(e))throw new r(`INVALID_ARGS`,`point target requires numeric ${t}.`);return e}function ir(e){return typeof e==`string`&&e.length>0?[e]:[]}function ar(e){let t=ke(e);if(!t.ok)throw new r(t.code,t.message);return`ref`in t?{ref:t.ref,label:lr(e.slice(1))}:{selector:t.selector}}function or(e){let t=Ie(e);if(!t.ok)throw new r(t.code,t.message);return t.format}function sr(e,t={}){let n=Be(e,t);if(!n)throw new r(`INVALID_ARGS`,Oe);return n}function cr(e,t){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}throw new r(`INVALID_ARGS`,`${t} must be a JSON object`)}function lr(e){return e.join(` `).trim()||void 0}function b(...e){return new Set(e)}function x(e,t){return e!==void 0&&t.has(e)}function ur(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function dr(e,t){if(e===void 0)return;let n=Number(e);if(Number.isFinite(n))return n;throw new r(`INVALID_ARGS`,`${t} must be a finite number.`)}function fr(e){return e===void 0?void 0:Number(e)}function S(e){return e===void 0?[]:[e]}function C(e){return e===void 0?[]:[String(e)]}function w(e,t){if(e===void 0||e===``)throw new r(`INVALID_ARGS`,t);return e}function T(e,t){if(typeof e!=`string`||e.length===0)throw new r(`INVALID_ARGS`,t);return e}function pr(e){return gr(e.description,e.cliDetail)}function mr(e){return gr(e.description,e.mcpDetail)}function hr(e,t){return{...e,description:t}}function gr(e,t){return t?`${e} ${t}`:e}function _r(e){return e}const vr=[`ref`,`selector`,`point`];function yr(e,t=[]){return{type:`object`,properties:{...Bn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function E(e,t=[],n){return{type:`object`,...n?{description:n}:{},properties:e,...t.length>0?{required:t}:{}}}function br(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function D(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function O(e){return{type:`string`,const:e}}function k(e){return{type:`string`,...e?{description:e}:{}}}function xr(e){return{type:[`string`,`null`],...e?{description:e}:{}}}function A(e,t={}){return{type:`number`,...e?{description:e}:{},...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Sr(e){return{type:`integer`,...e?{description:e}:{}}}function j(e){return{type:`boolean`,...e?{description:e}:{}}}function Cr(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function M(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function N(e){return{...e,required:!0}}function P(e,t={}){return B(k(e),t.allowEmpty===!0?On:m)}function wr(e){return{schema:{type:`null`},required:!1,audience:{kind:`retired`,message:e},read:(t,n)=>{if(Object.hasOwn(t,n))throw new r(`INVALID_ARGS`,e)}}}function Tr(e,t){return{...e,audience:{kind:`operator`,source:t}}}function F(e,t={}){return B(A(e,t),(e,n)=>fe(e,n,t))}function I(e,t={}){return B(qr(e,t),(e,n)=>me(e,n,t))}function L(e){return B(j(e),An)}function Er(e){return Or(Dr(e))}function Dr(e){let[t,...n]=st(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 Or(e){let t=e.inputDescription,n={min:e.min,max:e.max};switch(e.type){case`boolean`:return L(t);case`int`:return I(t,n);case`number`:return F(t,n);case`string`:return P(t);case`enum`:return R(kr(e),t);case`booleanOrString`:throw Error(`Flag ${e.key} is booleanOrString; declare its field shape explicitly with jsonSchemaField`)}}function kr(e){let t=e.enumValues;if(!t)throw Error(`Flag ${e.key} is an enum with no enumValues`);return t}function R(e,t){return B(D(e,t),(t,n)=>Mn(t,n,e))}function Ar(e){return B(M(e),Nn)}function jr(e){return B(Cr(e),Pn)}function z(e){return B(e,(e,t)=>e[t])}function Mr(e,t){return B(e,t)}function Nr(){return B(Zr(),(e,t)=>e[t]===void 0?void 0:Br(e,t))}function Pr(){return B(Qr(),(e,t)=>e[t]===void 0?void 0:Vr(e,t))}function Fr(e){return B(br(e),(e,t)=>e[t]===void 0?void 0:Hr(e,t))}function Ir(){return{depth:I(`Snapshot traversal depth.`,{min:0}),scope:P(`Snapshot scope selector used before resolution.`),raw:L(`Use raw snapshot data during selector resolution.`)}}function Lr(){return{count:I(`Number of press/click repetitions.`,{min:1}),intervalMs:I(`Delay between repeated press/click actions.`,{min:0}),holdMs:I(`Hold duration for each action.`,{min:0}),jitterPx:I(`Randomization radius in pixels.`,{min:0}),doubleTap:L(`Request a double-tap action.`)}}function Rr(e){return yr(Jr(e),Yr(e))}function zr(e,t){let n=Tn(e),i=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let i=t.read(n,e);if(t.required&&i===void 0)throw new r(`INVALID_ARGS`,`Expected ${e} to be set.`);return i===void 0?[]:[[e,i]]})),a=Vn(n,{readTargetAlias:!Object.hasOwn(t,`target`),readinessBudgetDeclared:Object.hasOwn(t,`readinessTimeoutMs`)});return h({...a,...g(a),...i})}function Br(e,t){let n=En(e,t),r=jn(n,`kind`,vr);switch(r){case`ref`:return{kind:r,ref:Dn(n,`ref`),label:m(n,`label`)};case`selector`:return{kind:r,selector:Dn(n,`selector`)};case`point`:return{kind:r,x:kn(n,`x`),y:kn(n,`y`)}}}function Vr(e,t){let n=En(e,t),r=jn(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:Dn(n,`ref`),label:m(n,`label`)}:{kind:r,selector:Dn(n,`selector`)}}function Hr(e,t){let n=En(e,t);return{x:kn(n,`x`),y:kn(n,`y`)}}function Ur(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 Wr(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function Gr(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function Kr(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function B(e,t){return{schema:e,required:!1,read:t}}function qr(e,t){return{...Sr(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function Jr(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e.audience?.kind!==`retired`).map(([e,t])=>[e,t.schema]))}function Yr(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function Xr(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t.audience?[[e,t.audience]]:[]))}function Zr(){return{oneOf:[...$r(),{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 Qr(){return{oneOf:$r(),description:`UI element target by snapshot ref or selector expression.`}}function $r(){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 V(e,t,n,r){return _r({name:e,description:t,inputSchema:Rr(n),readInput:r?.readInput??(e=>zr(e,n)),inputAudience:Xr(n),...r?.parseableOutput?{parseableOutput:!0}:{}})}function H(e){let t=hr(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 ei(e){return H({name:e.name,text:e.text,metadata:V(e.name,e.description,{}),run:e.run,cliSchema:{},cliReader:(e,t)=>y(t),daemonWriter:_(e.name),cliOutputFormatter:e.cliOutputFormatter})}function U(e){let t={},n={},r={},i={};for(let a of e.commands)ti(t,`CLI schema`,a.name,a.cliSchema),ti(n,`CLI reader`,a.name,a.cliReader),a.daemonWriter&&ti(r,`daemon writer`,a.name,a.daemonWriter),a.cliOutputFormatter&&ti(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 ti(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function ni(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(ii(n));return{data:e,text:t.join(`
|
|
2
|
+
`)}}const ri={batch:d(ni)};function ii(e){let t=Dt(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function ai(e=Me){let t=oi(e);return V(`batch`,`Execute multiple commands in one daemon request.`,t,{readInput:e=>ci(e,t)})}function oi(e){return{steps:N(Mr({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:si(e)},(t,n)=>li(t[n],e))),onError:R([`stop`],`Batch failure policy.`),maxSteps:I(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:P(`Optional output path for command artifacts.`)}}function si(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 ci(e,t){let n=zr(e,t),i=n.maxSteps??100;if(!pe(i))throw new r(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(n.maxSteps)}`);return le(n.steps.length,i),{...n}}function li(e,t){if(!Array.isArray(e))throw new r(`INVALID_ARGS`,`Expected steps to be an array.`);return e.map((e,n)=>ui(e,n+1,t))}function ui(e,t,n){let r=de(e,t);return Fn(r,[`command`,`input`,`runtime`],`Batch step ${t}`,he),{command:di(r,t,n),input:ue(r,t),...fi(r,t)}}function di(e,t,n){if(n===Me)return Le(e.command,t);let i=e.command;if(typeof i!=`string`||!n.includes(i))throw new r(`INVALID_ARGS`,`Expected command to be one of: ${n.join(`, `)}.`);return i}function fi(e,t){let n=ge(e.runtime,t);return n===void 0?{}:{runtime:n}}function pi(e){return async t=>v(u.batch,[],{...t,batchSteps:await mi(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}async function mi(e,t){if(!Array.isArray(e)||e.length===0)throw new r(`INVALID_ARGS`,`batch requires a non-empty steps array.`);let n=[];for(let[r,i]of e.entries())n.push(await hi(i,r+1,t));return n}async function hi(e,t,n){let r=de(e,t),i=gi(r,t),a=ue(r,t),o=ge(r.runtime,t),s=await n(i,a,t);return{command:s.command,positionals:s.positionals,...s.input?{input:s.input}:{},flags:yn(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function gi(e,t){return Le(e.command,t)}const _i=ai(),vi={usageOverride:`batch [--steps <json> | --steps-file <path>]`,usageFlags:[],listUsageOverride:`batch --steps <json> | --steps-file <path>`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},yi=(e,t)=>({...y(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),bi=[{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 xi(){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: ${[...Me].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(bi)}'`,` agent-device batch --steps-file ./steps.json --json`].join(`
|
|
3
|
+
`)}`}const Si=U({name:`batch`,clientSurface:!1,commands:[H({name:`batch`,text:{summary:`Run multiple commands`,cliDetail:xi()},metadata:_i,run:(e,t)=>e.batch.run(Ci(t)),cliSchema:vi,cliReader:yi,cliOutputFormatter:ri.batch})]});function Ci(e){return{...g(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}const wi=`alert`,Ti=H({name:wi,text:{summary:`Inspect, accept, or dismiss a platform alert`},metadata:V(wi,`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:R(At),timeoutMs:I()}),run:(e,t)=>e.command.alert(t),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...y(t),...Di(e)}),daemonWriter:_(u.alert,e=>Ei(e)),cliOutputFormatter:f});function Ei(e){return[e.action??`get`,...C(e.timeoutMs)]}function Di(e){if(e.length>2)throw new r(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return h({action:Oi(e[0]),timeoutMs:dr(e[1],`alert timeout`)})}function Oi(e){let t=e?.toLowerCase();if(t===void 0||t===`get`||t===`accept`||t===`dismiss`||t===`wait`)return t;throw new r(`INVALID_ARGS`,`alert action must be get, accept, dismiss, or wait.`)}function W(...e){return e}const ki=W(`keyframes`),Ai=W(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),ji=W(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Mi=W(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),Ni=W(`metroHost`,`metroPort`,`bundleUrl`),Pi=W(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Fi=W(`settle`,`settleQuietMs`,`timeoutMs`),Ii=W(`replayUpdate`,`replayEnv`),Li=W(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerDeviceType`,`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`),Ri=new Set([`platform`,`device`,`udid`,`serial`,`session`]),zi=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),Bi=`diff`,Vi={diff:E({mode:O(`snapshot`),baselineInitialized:j(),summary:E({additions:A(),removals:A(),unchanged:A()},[`additions`,`removals`,`unchanged`]),lines:{type:`array`,items:E({kind:D([`added`,`removed`,`unchanged`]),text:k(),ref:k()},[`kind`,`text`])},warnings:Cr()},[`mode`,`baselineInitialized`,`summary`,`lines`])},Hi=H({name:Bi,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:V(Bi,`Compare accessibility snapshots or screenshots to identify UI changes. Use snapshot comparisons for semantic tree changes and screenshot comparisons for pixel differences.`,{kind:N(z({type:`string`,const:`snapshot`})),out:P(),interactiveOnly:L(),depth:I(),scope:P(),raw:L()}),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:[...Ai,`baseline`,`threshold`,`out`,`overlayRefs`]},cliReader:(e,t)=>{if(e[0]!==`snapshot`)throw new r(`INVALID_ARGS`,`Only diff snapshot is available through this parser.`);return{...y(t),kind:`snapshot`,out:t.out,interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw}},daemonWriter:_(u.diff,e=>[T(e.kind,`diff requires kind`)])}),Ui=`screenshot`,Wi=H({name:Ui,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. On macOS, any --surface other than app (desktop, menubar, frontmost-app) always captures the main display and refuses an explicit --fullscreen. On single-display iOS simulators and Android devices, the result reports displayRotation, the rotation the display rendered the capture in, when the device returns a reading in time; otherwise the field is absent.`},metadata:V(Ui,`Capture a screenshot of the active app or web session. Choose the capture scope, density, size, or annotations through the corresponding input fields when needed.`,{path:P(`Output path.`),cropOn:P(`Selector expression; the capture is cropped to the frame the selector resolves on the same screen.`),overlayRefs:L(),pixelDensity:I(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:L(),scale:F(`Screenshot scale factor.`,ee),maxSize:wr(oe.migration.screenshot),stabilize:L(),normalizeStatusBar:L(),surface:R(dt)}),run:(e,t)=>e.capture.screenshot(t),cliSchema:{positionalArgs:[`path?`],allowedFlags:ie},cliReader:(e,t)=>({...y(t),path:e[0]??t.out,...ne(t)}),daemonWriter:e=>(ae(`screenshot`,e),re(e),v(u.screenshot,S(e.path),{...e,...te(e)}))}),Gi=`settings`,Ki=V(Gi,`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:N(P()),state:P(),app:P("App the change targets, by bundle id or package name: the app `clear-app-state` clears, or the app a `permission` change (or an iOS-simulator `location on|off` privacy change) lands on. An app named here needs no session and need not be running (Android `deny|reset` of a held permission does kill a running one); without it those changes use the session app, and a change that is device-wide refuses one with `setting_app_not_consumed` (`location set` on any target, the Android `location on|off` toggle, macOS permissions). The CLI consumes it only when this invocation passes it: an `AGENT_DEVICE_TARGET_APP` or config `targetApp` never retargets a settings mutation."),latitude:F(),longitude:F(),permission:P(),mode:R([...Ft])}),qi={usageOverride:Lt,listUsageOverride:`settings [area] [options]`,positionalArgs:[`setting`,`state?`,`target?`,`mode?`],allowedFlags:[`targetApp`],explicitOnlyFlags:[`targetApp`]},Ji=(e,t)=>{let n=Qi(e,t);return n.setting===`clear-app-state`||t.targetApp===void 0?n:{...n,app:t.targetApp}},Yi=e=>{let t=e,n=h({app:Xi(t)});return v(u.settings,ea(t),e,Object.keys(n).length===0?void 0:n)};function Xi(e){if(e.setting===`permission`||e.setting===`location`)return e.app}const Zi=H({name:Gi,text:{summary:`Change OS settings and app permissions`,cliDetail:`macOS supports only settings appearance <light|dark|toggle> and settings ${Nt}; wifi|airplane|location|animations|text-size remain unsupported on macOS. Mobile permission actions default to the active session app; pass --app <id> (or the app input) to aim a permission change, or an iOS-simulator location on|off, at an installed app no session has opened; no app needs to be running, and the CLI consumes the app only when this invocation names it, never from AGENT_DEVICE_TARGET_APP or config targetApp. clear-app-state takes its app positionally or with --app, and refuses two different apps. An installed app with no data container (a simulator-runtime system app such as com.apple.Preferences) refuses with app-no-data-container instead of scanning a path simctl never gave. A device-wide change refuses an app with setting_app_not_consumed: location set moves the device's own coordinates on every target, the Android location toggle writes the device's location_mode, and a macOS permission is a host-level TCC grant. 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:Ki,run:(e,t)=>e.settings.update(t),cliSchema:qi,cliReader:Ji,daemonWriter:Yi,cliOutputFormatter:f});function Qi(e,t){let n=Jn(t),i=e[0],a=e[1];if(x(i,ra)&&x(a,ia))return{...n,setting:i,state:a};if(i===`location`&&a===`set`)return{...n,setting:i,state:a,latitude:zt(e[2],`latitude`),longitude:zt(e[3],`longitude`)};if(i===`appearance`&&x(a,aa))return{...n,setting:i,state:a};if(i===`text-size`)return a===void 0?{...n,setting:i}:{...n,setting:i,state:Rt(a)};if(x(i,oa)&&x(a,sa)||i===`fingerprint`&&x(a,ca))return{...n,setting:i,state:a};if(i===`permission`&&x(a,ua))return{...n,setting:i,state:a,permission:ta(e[2]),mode:na(e[3])};if(i===`clear-app-state`)return{...n,setting:i,state:`clear`,app:$i(e,t)};if(i===`reset-keychain`&&a===`clear`&&e.length===2)return{...n,setting:i,state:a};throw new r(`INVALID_ARGS`,`Invalid settings arguments.`)}function $i(e,t){let n=e[1]===`clear`?e[2]:e[1],i=t.targetApp;if(n!==void 0&&i!==void 0&&n!==i)throw new r(`INVALID_ARGS`,`settings clear-app-state names two apps: ${n} and ${i}. Name one.`);return n??i}function ea(e){return e.setting===`clear-app-state`?[e.setting,...S(e.app)]:e.setting===`text-size`?[e.setting,...S(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,...S(e.mode)]:[e.setting,e.state]}function ta(e){if(x(e,da))return e;throw new r(`INVALID_ARGS`,`settings permission requires a permission target.`)}function na(e){if(e===void 0||x(e,la))return e;throw new r(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const ra=b(`wifi`,`airplane`,`location`,`animations`),ia=b(`on`,`off`),aa=b(...It),oa=b(`faceid`,`touchid`),sa=b(`match`,`nonmatch`,`enroll`,`unenroll`),ca=b(`match`,`nonmatch`),la=b(...Ft),ua=b(...Pt),da=b(...jt,...Mt);function fa(e){if(!Array.isArray(e)||e.length===0)return e;let t=Ve(e);return e.map(e=>{let n=pa(e,t,e=>e.label),r=pa(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 pa(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 ma(e){return e.width>0&&e.height>0}function ha(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 ga(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 _a(e){return typeof e.parentIndex!=`number`}function va(e){let t=(e.type??``).toLowerCase(),n=(e.identifier??``).trim().toLowerCase();return t.includes(`edittext`)||t.includes(`textfield`)||n===`composer`}function ya(e){let t=(e.type??``).toLowerCase();return t.includes(`scroll`)||t.includes(`list`)||t.includes(`recyclerview`)}function ba(e){let t=Te(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 xa(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 wa(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 Ta(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 Ea=[`button`,`switch`,`checkbox`,`radio`],Da=[`button`,`image`,`textview`,`view`];function Oa(e,t,n){for(let r of e){if(t.has(r.index)||!ja(r))continue;let i=Ma(wa(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)Ta(e,n,t)}}}function ka(e,t,n){let r=new Map;for(let i of e){if(t.has(i.index)||!Ba(i))continue;let a=xa(ba(i));if(!a)continue;let o=r.get(a);if(o&&La(o,i,t)){let s=Ra(e,o,i,t,n);r.set(a,s);continue}r.set(a,i)}}function Aa(e,t){for(let n of e){if(t.has(n.index)||!Fa(n))continue;let r=xa(ba(n));if(!r)continue;let i=wa(e,n.index).filter(e=>!t.has(e.index)&&Ia(n,e,r));for(let n of i.filter(Pa))Ta(e,n.index,t);let a=i.filter(e=>!Pa(e)),o=new Set(a.map(e=>xa(ba(e))).filter(e=>!!e));if(!(a.length<2||o.size<2))for(let n of a)Ta(e,n.index,t)}}function ja(e){return e.hittable===!0&&!va(e)&&!!(e.rect&&ma(e.rect))&&ba(e).trim().length===0}function Ma(e,t,n){let r=[],i=[],a=new Set;for(let o of e){if(n.has(o.index)||!Na(o,e)||!ha(o.rect,t.rect))continue;let s=ba(o).trim().replaceAll(/\s+/g,` `),c=xa(s);i.push(o.index),!(!s||!c||a.has(c))&&(a.add(c),r.push(s))}return{label:r.join(`, `),removableIndexes:i}}function Na(e,t){if(Pa(e))return!0;let n=(e.type??``).toLowerCase();return e.hittable!==!0&&!va(e)&&n.includes(`view`)&&ba(e).trim().length>0&&!t.some(t=>t.parentIndex===e.index)}function Pa(e){if(e.hittable===!0||va(e))return!1;let t=(e.type??``).toLowerCase();return t.includes(`text`)||t.includes(`image`)||t.includes(`icon`)}function Fa(e){return e.hittable===!0&&!va(e)&&!!(e.rect&&ma(e.rect))&&!!xa(ba(e))}function Ia(e,t,n){if(!Ba(t)||!ha(t.rect,e.rect))return!1;let r=xa(ba(t));return!!(r&&n!==r&&n.includes(r))}function La(e,t,n){return!n.has(e.index)&&ga(e.rect,t.rect)&&(Ga(e,t)||Wa(e,t))}function Ra(e,t,n,r,i){let a=Va(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:za(c.presentationHints,ee,s)}),Ta(e,o.index,r),i.get(a.index)??a}function za(e,t,n){return[...new Set([...Array.isArray(e)?e:[],...Array.isArray(t)?t:[],...n?[n]:[]])]}function Ba(e){if(!e.rect||!ma(e.rect)||_a(e)||va(e))return!1;let t=(e.type??``).toLowerCase();return t===`text`||Ua(t,Da)}function Va(e,t){let n=Ha(e);return Ha(t)>n?t:e}function Ha(e){let t=(e.type??``).toLowerCase(),n=0;return Ua(t,Ea)?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 Ua(e,t){return t.some(t=>e.includes(t))}function Wa(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:Va(n,r).index===n.index}function Ga(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 Ka(e,t,n){if(n.raw||!qa(e))return{nodes:t,filteredCount:0};let r=Ja(t);return{nodes:r,filteredCount:t.length-r.length}}function qa(e){let t=e.androidSnapshot;return!t||typeof t!=`object`?!1:t.backend===`android-helper`}function Ja(e){if(e.length===0)return e;let t=new Set,n=new Map,r=new Map(e.map(e=>[e.index,e]));return Ya(e,t),Xa(e,r,t,n),Oa(e,t,n),Aa(e,t),ka(e,t,n),e.filter(e=>!t.has(e.index)).map(e=>n.get(e.index)??e)}function Ya(e,t){for(let n of e)!n.rect||ma(n.rect)||_a(n)||Ta(e,n.index,t)}function Xa(e,t,n,r){for(let i of e){if(n.has(i.index)||i.rect||_a(i))continue;let a=Ca(i,t,ya);a&&Qa(r,a,Za(i,e)),Ta(e,i.index,n)}}function Za(e,t){let n=t.filter(t=>t.parentIndex===e.parentIndex&&t.rect&&ma(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 Qa(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 $a(e){if(e.length<20)return!1;let t=new Map;for(let n of e){let e=(n.type??``).toLowerCase(),r=eo(Te(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||!no(e)||(n+=e.length);return n>=8}function eo(e){let t=e.trim().replaceAll(/\s+/g,` `).toLowerCase();return!t||to(t)?null:t}function to(e){return/\S+@\S+\.\S+/.test(e)}function no(e){for(let t=0;t<e.length;t+=1)for(let n=t+1;n<e.length;n+=1)if(ro(e[t]?.rect,e[n]?.rect))return!0;return!1}function ro(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 io(n,r={}){let i=n.nodes,a=Array.isArray(i)?i:[],o=e(n.backend)?n.backend:void 0,s=t(o),c=Ka(n,a,r),ee=co(n),te=vo(n,a,r,c),ne=te.length>0?`${te.join(`
|
|
4
|
+
`)}\n`:``,re=r.raw?null:ao(n);if(re)return`${ee}${ne}${oo(re)}\n`;let ie=r.raw||!s?null:Kt(c.nodes),ae=!!n.truncated,oe=ie?.nodes??a,se=r.raw||!s?null:ho(n,ie,oe.length,a.length,c.filteredCount),ce=lo(a.length,se,ae);return a.length===0?`${ee}${ce}\n${ne}`:r.raw?`${ee}${ce}\n${ne}${uo(a)}\n`:r.flatten?`${ee}${ce}\n${ne}${fo(oe)}${mo(ie)}\n`:`${ee}${ce}\n${ne}${po(oe)}${mo(ie)}\n`}function ao(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 oo(e){let t=so(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
7
|
`)}function so(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 co(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
8
|
`)}\n`:``}function lo(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 uo(e){return e.map(e=>JSON.stringify(e)).join(`
|
|
9
9
|
`)}function fo(e){return Do(e).join(`
|
|
10
|
-
`)}function po(e){return wo(
|
|
10
|
+
`)}function po(e){return wo(Vt(e,{summarizeTextSurfaces:!0})).join(`
|
|
11
11
|
`)}function mo(e){return e&&e.summaryLines.length>0?`\n${e.summaryLines.join(`
|
|
12
|
-
`)}`:``}function ho(e,t,n,r,i=0){let a=go(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:_o([...a?.reasons??[],`offscreen-nodes`])}:a||(s?{partial:!0,visibleNodeCount:n,totalNodeCount:n,reasons:[]}:null)}function go(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 _o(e){return[...new Set(e)]}function vo(e,t,n,r={nodes:t,filteredCount:0}){let i=[...Co(e),...yo(e)];if(bo(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&&$a(a)&&i.push(`Warning: possible repeated nav subtree detected.`),i}function yo(e){let t=e.fallbackScreenshotPath;return typeof t==`string`&&t.length>0?[`Captured a screenshot of this screen automatically as visual truth: ${t}`]:[]}function bo(e){return!e.snapshotQuality&&!xo(e)}function xo(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
|
|
13
|
-
`)}}const es={debug:d($o)};function ts(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 ns=`debug`,rs=U({name:`debugging`,commands:[H({name:ns,text:{summary:`Symbolicate Apple crash artifacts`},metadata:V(ns,`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:N(R([`symbols`])),artifact:N(P(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:P(`Path to a matching .dSYM bundle.`),searchPath:P(`Directory to scan for matching .dSYM bundles.`),out:P(`Output path for the symbolicated artifact.`)}),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)=>({...y(t),action:is(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:es.debug})]});function is(e){if(e===`symbols`)return e;throw new r(`INVALID_ARGS`,`debug supports only symbols; use logs, network, perf, record, trace, or react-devtools for other diagnostics`)}const as=()=>L(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),os=()=>({settle:L(`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:I(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:I(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function ss(e){return{...Pe(e)?{verify:as()}:{},...Re(e)?os():{}}}function cs(e){let t=[];return Pe(e)&&t.push(`verify`),Re(e)&&t.push(...Fi),t}function ls(e,t){return Re(e)?Zn(t):{}}const us=[`click`,`focus`,`exists`,`list`,`getText`,`getAttrs`,`wait`,`fill`,`type`],ds={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. A directional scroll also reports the movement it observed as movement: moved, at-edge, unchanged, or unobserved when the two reads could not back a claim either way; an unchanged surface inside a container that still hides content in that direction refuses with scroll_no_progress rather than repeating the requested distance. The movement field is absent where a tier verifies per pass (top/bottom, until), where the runtime cannot read a screen, or where a settle observation or a replay already owns that observation.`,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, settled, 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. The role locator matches snapshot kind vocabulary (button, text, text-field, switch, ...); pre-reconciliation leaf spellings (statictext, edittext, textview) stay accepted on the nodes that carried them during a deprecation window.`,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.`};function fs(e){if(!je(e))throw Error(`${e} does not declare targetReadiness: 'budgeted'`);return{readinessTimeoutMs:Tr(I(`Operator-only: how long the command may poll for a target that does not exist yet, in milliseconds. Capped at the promotedTarget row's maxTimeoutMs; omitted takes the one-attempt resolution path.`,{min:1}),{operatorPath:`Pass readinessTimeoutMs directly as CLI/Node.js command input; it is not exposed to model-facing tools.`})}}const ps={target:N(Nr()),button:R(Jt,`Pointer button for platforms that support mouse buttons.`),...Ir(),...Lr(),...ss(`click`),...fs(`click`)},ms={target:N(Nr()),...Ir(),...Lr(),...ss(`press`),...fs(`press`)},hs={target:N(Nr()),text:N(P(`Text to enter into the target. Pass "" to clear it.`,{allowEmpty:!0})),delayMs:I(`Delay between typed characters.`,{min:0}),recordAs:P("When script recording is armed, send text to the live app but publish it as ${VAR}. Use an uppercase replay variable name such as PASSWORD."),...Ir(),...ss(`fill`)},gs={target:N(Nr()),durationMs:I(`Long press duration in milliseconds.`,{min:0}),...Ir(),...ss(`longpress`),...fs(`longpress`)},_s={target:N(Nr()),...Ir(),...ss(`hover`)},vs={from:N(Fr(`Swipe start point.`)),to:N(Fr(`Swipe end point.`)),count:I(`Number of swipe repetitions.`,{min:1,max:200}),pauseMs:I(`Pause between repeated swipes.`,{min:0,max:qe}),pattern:R(Ge)},ys={x:N(F(`X coordinate.`)),y:N(F(`Y coordinate.`))},bs={text:N(P(`Text to type.`)),delayMs:I(`Delay between typed characters.`,{min:0})},xs={direction:N(R(Je)),amount:F(`Platform scroll amount.`),pixels:I(`Pixel scroll amount.`,{min:0}),until:P(`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:I(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:Yt}),...ss(`scroll`)},Ss=()=>({noRecord:L(`Do not record this action.`),record:L(`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.`)}),Cs={format:N(R([`text`,`attrs`])),target:N(Pr()),...Ir(),...Ss()},ws={predicate:N(R(ze)),selector:N(P()),value:P(),...Ir(),...Ss()},Ts={locator:R(we),query:N(P()),action:R(us),value:P(void 0,{allowEmpty:!0}),timeoutMs:I(),first:L(),last:L(),depth:I(),raw:L(),...Ss()},Es={kind:N(R(Ze,`Gesture variant.`)),direction:R(Ke,`Fling direction.`),preset:R(Ye,`Swipe preset.`),origin:Fr(`Gesture origin point.`),delta:Fr(`Movement delta for pan or transform gestures.`),distance:I(`Fling distance.`,{min:0}),scale:F(`Pinch or transform scale.`),degrees:F(`Rotation in degrees.`),durationMs:I(`Pan/transform duration.`,{min:16,max:1e4}),pointerCount:I(`Pan touch pointer count (1 or 2).`,{min:1,max:2}),source:P(`Drag source @ref or selector.`),destination:P(`Drag destination @ref or selector.`),sourceHoldMs:I(`Drag activation hold duration.`,{min:1,max:1e4}),moveMs:I(`Drag movement duration.`,{min:16,max:1e4}),destinationHoldMs:I(`Hold before releasing at the destination.`,{min:0,max:1e4})},Ds=[G(`click`,ps),G(`press`,ms),G(`fill`,hs),G(`longpress`,gs),G(`hover`,_s),G(`swipe`,vs),G(`focus`,ys),G(`type`,bs),G(`scroll`,xs),G(`get`,Cs,{parseableOutput:!0}),G(`is`,ws),G(`find`,Ts,{parseableOutput:!0}),V(`gesture`,ds.gesture,Es,{readInput:Os})];function Os(e){let t=Tn(e);return{...Vn(t),...Xe(t)}}function G(e,t,n){return V(e,ds[e],t,n)}const ks={gesture:js},As={gesture:e=>{let t=Os(e);return v(u.gesture,[],e,h(t))}};function js(e,t){return{...y(t),...Qe(e,t.pointerCount)}}const K={click:(e,t)=>({...y(t),...Yn(t),...Qn(t),target:$n(Xt(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...y(t),...Yn(t),...Qn(t),target:$n(Xt(e)),verify:t.verify}),longpress:(e,t)=>{let n=Ms(e);return{...y(t),...Yn(t),target:$n(n),durationMs:n.durationMs}},hover:(e,t)=>({...y(t),...Yn(t),target:$n(Xt(e))}),swipe:(e,t)=>({...y(t),...et(e,{count:t.count,pauseMs:t.pauseMs,pattern:t.pattern})}),focus:(e,t)=>({...y(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...y(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=Zt(e);return{...y(t),...Yn(t),target:$n(n.target),text:n.text,delayMs:t.delayMs,recordAs:t.recordAs,verify:t.verify}},scroll:(e,t)=>({...y(t),direction:Is(e[0]),amount:fr(e[1]),pixels:t.pixels,durationMs:t.durationMs,until:t.until}),get:(e,t)=>({...y(t),...qn(t),...Yn(t),format:or(e[0]),target:$n(ar(e.slice(1)))})},q={click:e=>v(u.click,er(e),{...e,clickButton:e.button}),press:_(u.press,e=>er(e)),longpress:_(u.longPress,e=>Ns(e)),hover:_(u.hover,e=>er(e)),swipe:e=>($e(e),v(u.swipe,[],e,{from:e.from,to:e.to,count:e.count,pauseMs:e.pauseMs,pattern:e.pattern})),focus:_(u.focus,e=>[String(e.x),String(e.y)]),type:_(u.type,e=>Ps(e)),fill:_(u.fill,e=>Fs(e)),scroll:_(u.scroll,e=>[T(e.direction,`scroll requires direction`),...C(e.amount)]),get:_(u.get,e=>[T(e.format,`get requires format`),...tr(e)])};function Ms(e){let t=Ls(e);return{...Xt(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function Ns(e){return[...er(e),...C(e.durationMs)]}function Ps(e){return[e.text]}function Fs(e){return[...er(e),e.text]}function Is(e){if(e===`up`||e===`down`||e===`left`||e===`right`||e===`top`||e===`bottom`)return e;throw new r(`INVALID_ARGS`,`Unknown direction: ${String(e)}`,{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 Ls(e){if(ur(e[0])&&ur(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&&ur(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function Rs(e){return({input:t,result:n})=>{let r=e({input:t,result:n});return r instanceof Promise?r.then(zs):zs(r)}}function zs(e){return{data:e.data,text:Vs(e.text,e.data)}}function Bs(e){let t={...e};for(let[n,r]of Object.entries(e))Re(n)&&(t[n]=Rs(r));return t}function Vs(e,t){return`${e??``}${Hs(t.settle)}`}function Hs(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Ks(t),...Us(t),...Gs(t)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
|
|
14
|
-
`)}`}function Us(e){let t=e.diff,n=(t?.lines??[]).map(t=>`${t.kind===`removed`?`-`:`+`} ${Ws(t,e.refsGeneration)}`);return t?.truncated&&n.push(`… changed lines truncated`),n}function Ws(e,t){let n=e.text??``,r=
|
|
15
|
-
`)}function Xs(e,t){let n=e.ref??``,r=n.startsWith(`@`)?n.slice(1):n,a=kt(n,t)??`@${r}`,o=i(e.node?.type??`Element`),s=e.node?Wt(e.node,o):``;return`= ${a} [${o}]${s?` "${s}"`:``}`}function Zs(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Qs(e){let t=e,n=t.ref??``,r=t.x,i=t.y;return!n||typeof r!=`number`||typeof i!=`number`?At(t):{data:t,text:`Tapped @${n} (${r}, ${i})`}}const J=Bs({click:d(Qs),press:d(Qs),fill:f,longpress:f,hover:f,scroll:f,get:({input:e,result:t})=>qs({result:t,format:e.format===`attrs`?`attrs`:`text`}),is:d(Zs),find:d(Js)}),$s={find:(e,t)=>rc(e,t),is:(e,t)=>ic(e,t)},ec={is:_(u.is,e=>tc(e)),find:e=>v(u.find,nc(e),{...e,findFirst:e.first,findLast:e.last})};function tc(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function nc(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`,...C(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function rc(e,t){let n={...cc(t),...Jn(t),...qn(t),first:t.findFirst,last:t.findLast},i=sc(e[0]),a=i!==void 0,o=a?e[1]:e[0],s=a?2:1,c=Ee(e[s]);if(c===void 0)return{...n,locator:i,query:lc(o)};if(c===`get`){let t=e[s+1];if(t===`text`)return{...n,locator:i,query:lc(o),action:`getText`};if(t===`attrs`)return{...n,locator:i,query:lc(o),action:`getAttrs`};throw new r(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...n,locator:i,query:lc(o),action:`wait`,timeoutMs:fr(e[s+1])};if(c===`fill`||c===`type`){let t=e.slice(s+1);if(t.length===0)throw new r(`INVALID_ARGS`,c===`fill`?`find fill requires text (use "" to clear the field)`:`find type requires text`);return{...n,locator:i,query:lc(o),action:c,value:t.join(` `)}}if(c===`click`||c===`focus`||c===`exists`||c===`list`)return{...n,locator:i,query:lc(o),action:c};throw new r(`INVALID_ARGS`,`Unsupported find action: ${e[s]}`,{hint:De})}function ic(e,t){let n={...Xn(t),...Jn(t),...qn(t)},i=Ae(e),a=Fe(i[0]??``);if(!a.ok)throw new r(a.code,a.message,{hint:a.hint});let o=a.predicate;if(o===`absent`){let e=ac(n);if(e)throw oc(e)}let s=sr(i.slice(1),{preferTrailingValue:o===`text`});return o===`text`?{...n,predicate:o,selector:s.selectorExpression,value:s.rest.join(` `)}:{...n,predicate:o,selector:s.selectorExpression}}function ac(e){if(e.scope!==void 0)return`scope`;if(e.depth!==void 0)return`depth`}function oc(e){return new r(`INVALID_ARGS`,e===`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:e})}function sc(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function cc(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function lc(e){if(e===void 0||e===``)throw new r(`INVALID_ARGS`,`find requires query`);return e}const uc=E({from:k(`Surface the pre-action baseline described: a host bundle id, or app.`),to:k(`Surface the post-action capture describes: a host bundle id, or app.`),disclosure:k(`Agent-facing sentence explaining the surface transition.`)},[`from`,`to`,`disclosure`],`Present when an in-place system surface (web sign-in or Apple Pay sheet) was presented over the app, or left it.`),dc=E({foregroundApp:k(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:A(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:A(`Subset of nodeCount the platform reports as hittable.`),digest:k(`Order-independent digest of the post-action node multiset.`),changedFromBefore:j(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure. With surfaceChange present, no digest comparison is made: it reports that surface transition.`),surfaceChange:uc},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),fc=E({wallClockMs:A(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:A(`Number of real runner round-trips made while serving the request.`),nodeCount:A(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),pc=E({diagnosticRef:k(`Opaque non-@ diagnostic token. Never a snapshot ref: not issued via refsGeneration and cannot be pinned or reused as an @ref target. UTF-8 truncated to 256 bytes.`),role:k(`UTF-8 truncated to 256 bytes.`),label:k(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),mc={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[E({source:O(`runtime`),phase:O(`pre-action`),kind:O(`unique`)},[`source`,`phase`,`kind`]),E({source:O(`runtime`),phase:O(`pre-action`),kind:O(`disambiguated`),matchCount:A(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:pc,tiebreak:D([`visible`,`deepest`,`smallest-area`,`structural-equivalence`],`The comparison that decided the winner.`),alternatives:{type:`array`,description:`At most 5 losing candidates, document order. Present at default/full response levels and omitted in digest. The winner is never included.`,items:pc}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),E({source:O(`ref`),phase:O(`pre-action`),kind:O(`exact`)},[`source`,`phase`,`kind`]),E({source:O(`ref`),phase:O(`pre-action`),kind:O(`label-fallback`)},[`source`,`phase`,`kind`]),E({source:O(`direct-ios`),kind:O(`not-observed`)},[`source`,`kind`])]};function hc(e={}){let t=e.properties??{},n=e.required??[];return E({targetKind:D([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:A(`Resolved interaction x coordinate when available.`),y:A(`Resolved interaction y coordinate when available.`),referenceWidth:A(`Reference frame width for visualizing the interaction point.`),referenceHeight:A(`Reference frame height for visualizing the interaction point.`),ref:k(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:k(`Selector expression when the target was a selector.`),selectorChain:Cr(),refLabel:k(),targetHittable:j(),hint:k(),warning:k(),message:k(),evidence:dc,resolution:mc,cost:fc,maestroNonHittableCoordinateFallbackAllowed:j(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:j(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:O(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const gc=hc({properties:{evidence:dc,button:D([`secondary`,`middle`]),count:A(`Number of press/click repetitions.`),intervalMs:A(`Delay between repeated press/click actions.`),holdMs:A(`Hold duration for each action.`),jitterPx:A(`Randomization radius in pixels.`),doubleTap:j(`Whether the command requested a double-tap action.`)}}),_c={text:k(`Text submitted to the field.`),delayMs:A(`Delay between typed characters in milliseconds.`),evidence:dc},vc=E({resourceId:xr(`Identifier of the exact field that changed: Android resource id or Apple accessibility identifier.`),className:xr(`Type of the exact field that changed: Android class name or Apple element type.`),packageName:xr(`App that owns the exact field: Android package name or Apple bundle id.`),rect:E({x:A(),y:A(),width:A(),height:A()},[`x`,`y`,`width`,`height`],`Screen-space rectangle of the exact field that changed.`)},[`resourceId`,`className`,`packageName`,`rect`],`Target identity captured before fill and matched after fill.`),yc={press:gc,click:gc,fill:{type:`object`,description:`Fill response. Returns target-bound unconfirmed evidence when the exact field changed but its value cannot confirm the text: Android app-owned formatting, or an Apple field whose accessibility value does not echo the typed text.`,oneOf:[{...hc({properties:_c,required:[`text`]}),not:E({},[`verification`])},hc({properties:{..._c,verification:O(`unconfirmed`),requested:k(`Literal text requested by the fill command.`),before:xr(`Raw target text captured before the fill.`),after:xr(`Raw target text captured after the fill.`),target:vc},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:hc({properties:{durationMs:A(),gesture:O(`longpress`)}}),hover:hc({properties:{gesture:O(`hover`)}}),find:E({ref:k(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:A(`ADR 0014 ref frame epoch for read-only find actions.`),found:j(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:A(`Milliseconds waited for a read-only find condition.`),text:k(`Text value returned by find get_text.`),node:M(`Snapshot node for find get_attrs/get_text.`),matches:{type:`array`,description:`Every match for the read-only find list action (#1625): { ref, node } each.`,items:M(`One listed match with its snapshot ref and node.`)},locator:k(`Locator kind used for the find action.`),query:k(`Query argument used for the find action.`),x:A(`Resolved x coordinate for mutating find actions.`),y:A(`Resolved y coordinate for mutating find actions.`),message:k(`Diagnostic message for mutating find actions.`),cost:fc},[],`Daemon response data for the find command.`)},Y={get:{usageOverride:`get text|attrs <@ref|selector>`,usageFlags:[],positionalArgs:[`subcommand`,`target`],allowsExtraPositionals:!0,allowedFlags:[...ji,`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:[...ji,`record`]},click:{usageOverride:`click <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...Pi,`clickButton`,...cs(`click`),...ji]},press:{usageOverride:`press <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...Pi,...cs(`press`),...ji]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...cs(`longpress`),...ji]},hover:{usageOverride:`hover <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...cs(`hover`),...ji]},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:[...ji,`delayMs`,`recordAs`,...cs(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount]`,usageFlags:[`until`,`pixels`,`durationMs`,`settle`],positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`,`until`,...cs(`scroll`)]}},bc=U({name:`interaction`,clientSurface:!1,commands:[H({name:`click`,text:{summary:`Click or tap a UI target`},metadata:X(`click`),run:(e,t)=>e.interactions.click(xc(t)),cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),H({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(Sc(t)),cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),H({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(Cc(t)),cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),H({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(wc(t)),cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),H({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(Tc(t)),cliSchema:Y.hover,cliReader:K.hover,daemonWriter:q.hover,cliOutputFormatter:J.hover}),H({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}),H({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}),H({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}),H({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}),H({name:`get`,text:{summary:`Read element text or attributes`},metadata:X(`get`),run:(e,t)=>e.interactions.get(Dc(t)),cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),H({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:$s.is,daemonWriter:ec.is,cliOutputFormatter:J.is}),H({name:`find`,text:{summary:`Find an element and act`},metadata:X(`find`),run:(e,t)=>e.interactions.find(t),cliSchema:Y.find,cliReader:$s.find,daemonWriter:ec.find,cliOutputFormatter:J.find}),H({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(Oc(t));case`fling`:return await e.interactions.fling(Ac(t));case`swipe`:return await e.interactions.swipeGesture(jc(t));case`pinch`:return await e.interactions.pinch(Mc(t));case`rotate`:return await e.interactions.rotateGesture(Nc(t));case`transform`:return await e.interactions.transformGesture(Pc(t));case`drag`:return await e.interactions.drag(kc(t))}},cliSchema:Y.gesture,cliReader:ks.gesture,daemonWriter:As.gesture})]});function X(e){let t=Ds.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function xc(e){return{...g(e),...Ur(e.target),...Kr(e),...Gr(e),button:e.button,verify:e.verify,readinessTimeoutMs:e.readinessTimeoutMs,...Ec(e)}}function Sc(e){return{...g(e),...Ur(e.target),...Kr(e),...Gr(e),verify:e.verify,readinessTimeoutMs:e.readinessTimeoutMs,...Ec(e)}}function Cc(e){return{...g(e),...Ur(e.target),...Kr(e),text:e.text,delayMs:e.delayMs,recordAs:e.recordAs,verify:e.verify,...Ec(e)}}function wc(e){return{...g(e),...Ur(e.target),...Kr(e),durationMs:e.durationMs,readinessTimeoutMs:e.readinessTimeoutMs,...Ec(e)}}function Tc(e){return{...g(e),...Ur(e.target),...Kr(e),...Ec(e)}}function Ec(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function Dc(e){return{...g(e),...Wr(e.target),...Kr(e),format:e.format,record:e.record}}function Oc(e){return{...g(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,pointerCount:e.pointerCount,durationMs:e.durationMs}}function kc(e){return{...g(e),source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}}function Ac(e){return{...g(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance}}function jc(e){return{...g(e),preset:e.preset}}function Mc(e){return{...g(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function Nc(e){return{...g(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y}}function Pc(e){return{...g(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 Fc(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{devices:e.map(t)},text:e.map(Yc).join(`
|
|
12
|
+
`)}`:``}function ho(e,t,n,r,i=0){let a=go(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:_o([...a?.reasons??[],`offscreen-nodes`])}:a||(s?{partial:!0,visibleNodeCount:n,totalNodeCount:n,reasons:[]}:null)}function go(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 _o(e){return[...new Set(e)]}function vo(e,t,n,r={nodes:t,filteredCount:0}){let i=[...Co(e),...yo(e)];if(bo(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&&$a(a)&&i.push(`Warning: possible repeated nav subtree detected.`),i}function yo(e){let t=e.fallbackScreenshotPath;return typeof t==`string`&&t.length>0?[`Captured a screenshot of this screen automatically as visual truth: ${t}`]:[]}function bo(e){return!e.snapshotQuality&&!xo(e)}function xo(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 Et(e).filter(e=>e.length>0)}function wo(e){let t=[],n=[],r=new Map(e.map(e=>[e.node.index,e.node])),i=e=>{for(;n.length>0&&(!e||To(e,n.at(-1),r));)t.push(...Oo(n.pop(),`below`))};for(let r of e)i(r),t.push(r.text),t.push(...Oo(r,`above`)),r.node.hiddenContentBelow&&n.push(r);return i(),t}function To(e,t,n){return!Eo(e.node,t.node,n)&&e.depth<=t.depth}function Eo(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 Do(e){return Vt(e,{summarizeTextSurfaces:!0}).flatMap(e=>[Ht(e.node,0,!1,e.type,{summarizeTextSurfaces:!0}),...Oo({...e,depth:0})])}function Oo(e,t){let n=ko(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 ko(e){return e===`scroll-area`||e===`list`||e===`collection`||e===`table`?e:null}async function Ao(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:fa(e.result.nodes)});return{data:n,jsonData:Mo(n),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:io(n,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const jo={snapshot:async({input:e,result:t})=>await Ao({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:f,alert:f};function Mo(e){let{unchanged:t,...n}=e;return n}const No=`snapshot`,Po=Object.entries(Bt).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(`; `),Fo=V(No,`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:L(),depth:I(),scope:P(),raw:L(),customActions:Er(`snapshotCustomActions`),observeOnly:Er(`snapshotObserveOnly`),forceFull:L(),timeoutMs:I(`Maximum wall-clock time for the snapshot command.`),noRecord:L(`Do not record this action.`),record:L(`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.`)}),Io={allowedFlags:[`snapshotDiff`,...Ai,`snapshotCustomActions`,`snapshotObserveOnly`,`snapshotForceFull`,`timeoutMs`,`record`]},Lo=(e,t)=>({...y(t),...qn(t),...o(t,a),timeoutMs:t.timeoutMs}),Ro=_(u.snapshot),zo=H({name:No,text:{summary:`Capture or diff the accessibility tree`,cliDetail:`--observe-only is local iOS snapshot-only: an already-ready compatible runner reads the session app without activation or foreground repair, refuses unavailable observation, and reports XCUIApplication state rather than verified foreground ownership (#2696). Regular targetActivation disclosure stays unchanged (#2682, #2694). 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: ${Po}.`},metadata:Fo,run:(e,t)=>e.capture.snapshot(t),cliSchema:Io,cliReader:Lo,daemonWriter:Ro,cliOutputFormatter:jo.snapshot}),Bo=[`duration`,`text`,`ref`,`selector`,`absent`,`stable`],Vo=`wait`,Ho={wait:E({waitedMs:A(),kind:O(`selector`),text:k(),selector:k(),captures:A(),nodeCount:A(),hint:k(),warning:k()},[`waitedMs`])},Uo=H({name:Vo,text:{summary:`Wait for a duration, text, selector, strict absence, or stable UI`},metadata:V(Vo,`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:R(Bo),durationMs:I(),text:P(),ref:P(),selector:P(),absent:P(),stable:L(),quietMs:I(),timeoutMs:I(),depth:I(),scope:P(),raw:L()}),run:(e,t)=>e.command.wait(Wo(t)),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|absent <selector> [timeoutMs]|stable [quietMs] [timeoutMs]`,usageFlags:[],positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...ji]},cliReader:(e,t)=>Go(e,t),daemonWriter:_(u.wait,e=>Jo(e)),cliOutputFormatter:f});function Wo(e){Mn(e,`kind`,Bo);let t={...e};return delete t.kind,t}function Go(e,t){let n=Ee(e);if(!n)throw new r(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], absent <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...Jn(t),...Xn(t)};switch(n.kind){case`absent`:return Ko(i,n);case`sleep`:return{...i,durationMs:n.durationMs};case`text`:return qo(i,n);case`ref`:return{...i,ref:n.rawRef,...Yo(n.timeoutMs)};case`stable`:return{...i,stable:!0,...Xo(n.quietMs),...Yo(n.timeoutMs)};case`invalid`:throw new r(`INVALID_ARGS`,n.message);case`selector`:return{...i,selector:n.selectorExpression,...Yo(n.timeoutMs)};default:return Zo(n)}}function Ko(e,t){let n=Gt(e);if(n)throw Wt(n,`wait`);return{...e,absent:t.selectorExpression,...Yo(t.timeoutMs)}}function qo(e,t){if(!t.text)throw new r(`INVALID_ARGS`,`wait requires text.`);return{...e,text:t.text,...Yo(t.timeoutMs)}}function Jo(e){if([e.durationMs===void 0?void 0:`durationMs`,e.text===void 0?void 0:`text`,e.ref===void 0?void 0:`ref`,e.selector===void 0?void 0:`selector`,e.absent===void 0?void 0:`absent`,e.stable===void 0?void 0:`stable`].filter(Boolean).length!==1)throw new r(`INVALID_ARGS`,`wait command requires exactly one of durationMs, text, ref, selector, absent, or stable.`);if(e.durationMs!==void 0)return[String(e.durationMs)];let t=C(e.timeoutMs);if(e.text!==void 0)return[`text`,e.text,...t];if(e.ref!==void 0)return[e.ref,...t];if(e.absent!==void 0){let n=Gt(e);if(n)throw Wt(n,`wait`);if(!Re(e.absent))throw new r(`INVALID_ARGS`,`Invalid wait absent selector: ${e.absent}`);return[`absent`,e.absent,...t]}if(e.stable!==void 0){let n=C(e.quietMs);if(n.length===0&&t.length>0)throw new r(`INVALID_ARGS`,`wait stable requires quietMs before timeoutMs.`);return[`stable`,...n,...t]}let n=e.selector;if(!Re(n))throw new r(`INVALID_ARGS`,`Invalid wait selector: ${n}`);return[n,...t]}function Yo(e){return e===null?{}:{timeoutMs:e}}function Xo(e){return e===null?{}:{quietMs:e}}function Zo(e){throw Error(`Unsupported wait positional target: ${String(e)}`)}const Qo=U({name:`capture`,commands:[zo,Wi,Hi,Uo,Ti,Zi]});function $o(e){let t=[e.outPath,e.message];t.push(...ts(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 es={debug:d($o)};function ts(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 ns=`debug`,rs=U({name:`debugging`,commands:[H({name:ns,text:{summary:`Symbolicate Apple crash artifacts`},metadata:V(ns,`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:N(R([`symbols`])),artifact:N(P(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:P(`Path to a matching .dSYM bundle.`),searchPath:P(`Directory to scan for matching .dSYM bundles.`),out:P(`Output path for the symbolicated artifact.`)}),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)=>({...y(t),action:is(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:es.debug})]});function is(e){if(e===`symbols`)return e;throw new r(`INVALID_ARGS`,`debug supports only symbols; use logs, network, perf, record, trace, or react-devtools for other diagnostics`)}const as=()=>L(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),os=()=>({settle:L(`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:I(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:I(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function ss(e){return{...je(e)?{verify:as()}:{},...Fe(e)?os():{}}}function cs(e){let t=[];return je(e)&&t.push(`verify`),Fe(e)&&t.push(...Fi),t}function ls(e,t){return Fe(e)?Zn(t):{}}const us=[`click`,`focus`,`exists`,`list`,`getText`,`getAttrs`,`wait`,`fill`,`type`],ds={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. A directional scroll also reports the movement it observed as movement: moved, at-edge, unchanged, or unobserved when the two reads could not back a claim either way; an unchanged surface inside a container that still hides content in that direction refuses with scroll_no_progress rather than repeating the requested distance. The movement field is absent where a tier verifies per pass (top/bottom, until), where the runtime cannot read a screen, or where a settle observation or a replay already owns that observation.`,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, settled, 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. The role locator matches snapshot kind vocabulary (button, text, text-field, switch, ...); pre-reconciliation leaf spellings (statictext, edittext, textview) stay accepted on the nodes that carried them during a deprecation window.`,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.`};function fs(e){if(!De(e))throw Error(`${e} does not declare targetReadiness: 'budgeted'`);return{readinessTimeoutMs:Tr(I(`Operator-only: how long the command may poll for a target that does not exist yet, in milliseconds. Capped at the promotedTarget row's maxTimeoutMs; omitted takes the one-attempt resolution path.`,{min:1}),{operatorPath:`Pass readinessTimeoutMs directly as CLI/Node.js command input; it is not exposed to model-facing tools.`})}}const ps={target:N(Nr()),button:R(qt,`Pointer button for platforms that support mouse buttons.`),...Ir(),...Lr(),...ss(`click`),...fs(`click`)},ms={target:N(Nr()),...Ir(),...Lr(),...ss(`press`),...fs(`press`)},hs={target:N(Nr()),text:N(P(`Text to enter into the target. Pass "" to clear it.`,{allowEmpty:!0})),delayMs:I(`Delay between typed characters.`,{min:0}),recordAs:P("When script recording is armed, send text to the live app but publish it as ${VAR}. Use an uppercase replay variable name such as PASSWORD."),...Ir(),...ss(`fill`)},gs={target:N(Nr()),durationMs:I(`Long press duration in milliseconds.`,{min:0}),...Ir(),...ss(`longpress`),...fs(`longpress`)},_s={target:N(Nr()),...Ir(),...ss(`hover`)},vs={from:N(Fr(`Swipe start point.`)),to:N(Fr(`Swipe end point.`)),count:I(`Number of swipe repetitions.`,{min:1,max:200}),pauseMs:I(`Pause between repeated swipes.`,{min:0,max:Ke}),pattern:R(We)},ys={x:N(F(`X coordinate.`)),y:N(F(`Y coordinate.`))},bs={text:N(P(`Text to type.`)),delayMs:I(`Delay between typed characters.`,{min:0})},xs={direction:N(R(qe)),amount:F(`Platform scroll amount.`),pixels:I(`Pixel scroll amount.`,{min:0}),until:P(`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:I(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:Jt}),...ss(`scroll`)},Ss=()=>({noRecord:L(`Do not record this action.`),record:L(`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.`)}),Cs={format:N(R([`text`,`attrs`])),target:N(Pr()),...Ir(),...Ss()},ws={predicate:N(R(Ne)),selector:N(P()),value:P(),...Ir(),...Ss()},Ts={locator:R(Pe),query:N(P()),action:R(us),value:P(void 0,{allowEmpty:!0}),timeoutMs:I(),first:L(),last:L(),depth:I(),raw:L(),...Ss()},Es={kind:N(R(Xe,`Gesture variant.`)),direction:R(Ge,`Fling direction.`),preset:R(Je,`Swipe preset.`),origin:Fr(`Gesture origin point.`),delta:Fr(`Movement delta for pan or transform gestures.`),distance:I(`Fling distance.`,{min:0}),scale:F(`Pinch or transform scale.`),degrees:F(`Rotation in degrees.`),durationMs:I(`Pan/transform duration.`,{min:16,max:1e4}),pointerCount:I(`Pan touch pointer count (1 or 2).`,{min:1,max:2}),source:P(`Drag source @ref or selector.`),destination:P(`Drag destination @ref or selector.`),sourceHoldMs:I(`Drag activation hold duration.`,{min:1,max:1e4}),moveMs:I(`Drag movement duration.`,{min:16,max:1e4}),destinationHoldMs:I(`Hold before releasing at the destination.`,{min:0,max:1e4})},Ds=[G(`click`,ps),G(`press`,ms),G(`fill`,hs),G(`longpress`,gs),G(`hover`,_s),G(`swipe`,vs),G(`focus`,ys),G(`type`,bs),G(`scroll`,xs),G(`get`,Cs,{parseableOutput:!0}),G(`is`,ws),G(`find`,Ts,{parseableOutput:!0}),V(`gesture`,ds.gesture,Es,{readInput:Os})];function Os(e){let t=Tn(e);return{...Vn(t),...Ye(t)}}function G(e,t,n){return V(e,ds[e],t,n)}const ks={gesture:js},As={gesture:e=>{let t=Os(e);return v(u.gesture,[],e,h(t))}};function js(e,t){return{...y(t),...Ze(e,t.pointerCount)}}const K={click:(e,t)=>({...y(t),...Yn(t),...Qn(t),target:$n(Yt(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...y(t),...Yn(t),...Qn(t),target:$n(Yt(e)),verify:t.verify}),longpress:(e,t)=>{let n=Ms(e);return{...y(t),...Yn(t),target:$n(n),durationMs:n.durationMs}},hover:(e,t)=>({...y(t),...Yn(t),target:$n(Yt(e))}),swipe:(e,t)=>({...y(t),...$e(e,{count:t.count,pauseMs:t.pauseMs,pattern:t.pattern})}),focus:(e,t)=>({...y(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...y(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=Xt(e);return{...y(t),...Yn(t),target:$n(n.target),text:n.text,delayMs:t.delayMs,recordAs:t.recordAs,verify:t.verify}},scroll:(e,t)=>({...y(t),direction:Is(e[0]),amount:fr(e[1]),pixels:t.pixels,durationMs:t.durationMs,until:t.until}),get:(e,t)=>({...y(t),...qn(t),...Yn(t),format:or(e[0]),target:$n(ar(e.slice(1)))})},q={click:e=>v(u.click,er(e),{...e,clickButton:e.button}),press:_(u.press,e=>er(e)),longpress:_(u.longPress,e=>Ns(e)),hover:_(u.hover,e=>er(e)),swipe:e=>(Qe(e),v(u.swipe,[],e,{from:e.from,to:e.to,count:e.count,pauseMs:e.pauseMs,pattern:e.pattern})),focus:_(u.focus,e=>[String(e.x),String(e.y)]),type:_(u.type,e=>Ps(e)),fill:_(u.fill,e=>Fs(e)),scroll:_(u.scroll,e=>[T(e.direction,`scroll requires direction`),...C(e.amount)]),get:_(u.get,e=>[T(e.format,`get requires format`),...tr(e)])};function Ms(e){let t=Ls(e);return{...Yt(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function Ns(e){return[...er(e),...C(e.durationMs)]}function Ps(e){return[e.text]}function Fs(e){return[...er(e),e.text]}function Is(e){if(e===`up`||e===`down`||e===`left`||e===`right`||e===`top`||e===`bottom`)return e;throw new r(`INVALID_ARGS`,`Unknown direction: ${String(e)}`,{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 Ls(e){if(ur(e[0])&&ur(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&&ur(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function Rs(e){return({input:t,result:n})=>{let r=e({input:t,result:n});return r instanceof Promise?r.then(zs):zs(r)}}function zs(e){return{data:e.data,text:Vs(e.text,e.data)}}function Bs(e){let t={...e};for(let[n,r]of Object.entries(e))Fe(n)&&(t[n]=Rs(r));return t}function Vs(e,t){return`${e??``}${Hs(t.settle)}`}function Hs(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Ks(t),...Us(t),...Gs(t)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
|
|
14
|
+
`)}`}function Us(e){let t=e.diff,n=(t?.lines??[]).map(t=>`${t.kind===`removed`?`-`:`+`} ${Ws(t,e.refsGeneration)}`);return t?.truncated&&n.push(`… changed lines truncated`),n}function Ws(e,t){let n=e.text??``,r=Ot(e.ref,t);if(!r||!e.ref)return n;let i=`@${e.ref}`;return n.startsWith(`${i} `)?`${r}${n.slice(i.length)}`:n}function Gs(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=Ot(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 Ks(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 qs(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 Js(e){let t=e,n=Dt(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:Ys(t.matches,t.refsGeneration)};let r=Ot(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)}:kt(t)}function Ys(e,t){return[`${e.length} match${e.length===1?``:`es`}:`,...e.map(e=>Xs(e,t))].join(`
|
|
15
|
+
`)}function Xs(e,t){let n=e.ref??``,r=n.startsWith(`@`)?n.slice(1):n,a=Ot(n,t)??`@${r}`,o=i(e.node?.type??`Element`),s=e.node?Ut(e.node,o):``;return`= ${a} [${o}]${s?` "${s}"`:``}`}function Zs(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Qs(e){let t=e,n=t.ref??``,r=t.x,i=t.y;return!n||typeof r!=`number`||typeof i!=`number`?kt(t):{data:t,text:`Tapped @${n} (${r}, ${i})`}}const J=Bs({click:d(Qs),press:d(Qs),fill:f,longpress:f,hover:f,scroll:f,get:({input:e,result:t})=>qs({result:t,format:e.format===`attrs`?`attrs`:`text`}),is:d(Zs),find:d(Js)}),$s={find:(e,t)=>rc(e,t),is:(e,t)=>ic(e,t)},ec={is:_(u.is,e=>tc(e)),find:e=>v(u.find,nc(e),{...e,findFirst:e.first,findLast:e.last})};function tc(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function nc(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`,...C(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function rc(e,t){let n={...cc(t),...Jn(t),...qn(t),first:t.findFirst,last:t.findLast},i=sc(e[0]),a=i!==void 0,o=a?e[1]:e[0],s=a?2:1,c=Ce(e[s]);if(c===void 0)return{...n,locator:i,query:lc(o)};if(c===`get`){let t=e[s+1];if(t===`text`)return{...n,locator:i,query:lc(o),action:`getText`};if(t===`attrs`)return{...n,locator:i,query:lc(o),action:`getAttrs`};throw new r(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...n,locator:i,query:lc(o),action:`wait`,timeoutMs:fr(e[s+1])};if(c===`fill`||c===`type`){let t=e.slice(s+1);if(t.length===0)throw new r(`INVALID_ARGS`,c===`fill`?`find fill requires text (use "" to clear the field)`:`find type requires text`);return{...n,locator:i,query:lc(o),action:c,value:t.join(` `)}}if(c===`click`||c===`focus`||c===`exists`||c===`list`)return{...n,locator:i,query:lc(o),action:c};throw new r(`INVALID_ARGS`,`Unsupported find action: ${e[s]}`,{hint:we})}function ic(e,t){let n={...Xn(t),...Jn(t),...qn(t)},i=ze(e),a=Ae(i[0]??``);if(!a.ok)throw new r(a.code,a.message,{hint:a.hint});let o=a.predicate;if(o===`absent`){let e=ac(n);if(e)throw oc(e)}let s=sr(i.slice(1),{preferTrailingValue:o===`text`});return o===`text`?{...n,predicate:o,selector:s.selectorExpression,value:s.rest.join(` `)}:{...n,predicate:o,selector:s.selectorExpression}}function ac(e){if(e.scope!==void 0)return`scope`;if(e.depth!==void 0)return`depth`}function oc(e){return new r(`INVALID_ARGS`,e===`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:e})}function sc(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function cc(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function lc(e){if(e===void 0||e===``)throw new r(`INVALID_ARGS`,`find requires query`);return e}const uc=E({from:k(`Surface the pre-action baseline described: a host bundle id, or app.`),to:k(`Surface the post-action capture describes: a host bundle id, or app.`),disclosure:k(`Agent-facing sentence explaining the surface transition.`)},[`from`,`to`,`disclosure`],`Present when an in-place system surface (web sign-in or Apple Pay sheet) was presented over the app, or left it.`),dc=E({foregroundApp:k(`Foreground app bundle id or name, when the capture carries it.`),nodeCount:A(`Node count in the post-action interactive-only capture.`),interactiveNodeCount:A(`Subset of nodeCount the platform reports as hittable.`),digest:k(`Order-independent digest of the post-action node multiset.`),changedFromBefore:j(`Whether the post-action digest differs from the pre-action capture digest. false is evidence, not failure. With surfaceChange present, no digest comparison is made: it reports that surface transition.`),surfaceChange:uc},[`nodeCount`,`interactiveNodeCount`,`digest`,`changedFromBefore`]),fc=E({wallClockMs:A(`Total wall-clock time for the request in milliseconds.`),runnerRoundTrips:A(`Number of real runner round-trips made while serving the request.`),nodeCount:A(`Number of nodes in the original node tree when the response carries one.`)},[`wallClockMs`,`runnerRoundTrips`]),pc=E({diagnosticRef:k(`Opaque non-@ diagnostic token. Never a snapshot ref: not issued via refsGeneration and cannot be pinned or reused as an @ref target. UTF-8 truncated to 256 bytes.`),role:k(`UTF-8 truncated to 256 bytes.`),label:k(`UTF-8 truncated to 256 bytes.`)},[`diagnosticRef`]),mc={type:`object`,description:`Pre-action disclosure of how the acting path resolved its target. Absent when resolutionDisclosure is inapplicable for the path.`,oneOf:[E({source:O(`runtime`),phase:O(`pre-action`),kind:O(`unique`)},[`source`,`phase`,`kind`]),E({source:O(`runtime`),phase:O(`pre-action`),kind:O(`disambiguated`),matchCount:A(`Total matches resolveSelectorChain found before disambiguation.`),winnerDiagnostic:pc,tiebreak:D([`visible`,`deepest`,`smallest-area`,`structural-equivalence`],`The comparison that decided the winner.`),alternatives:{type:`array`,description:`At most 5 losing candidates, document order. Present at default/full response levels and omitted in digest. The winner is never included.`,items:pc}},[`source`,`phase`,`kind`,`matchCount`,`winnerDiagnostic`,`tiebreak`]),E({source:O(`ref`),phase:O(`pre-action`),kind:O(`exact`)},[`source`,`phase`,`kind`]),E({source:O(`ref`),phase:O(`pre-action`),kind:O(`label-fallback`)},[`source`,`phase`,`kind`]),E({source:O(`direct-ios`),kind:O(`not-observed`)},[`source`,`kind`])]};function hc(e={}){let t=e.properties??{},n=e.required??[];return E({targetKind:D([`point`,`ref`,`selector`],`Resolved interaction target kind.`),x:A(`Resolved interaction x coordinate when available.`),y:A(`Resolved interaction y coordinate when available.`),referenceWidth:A(`Reference frame width for visualizing the interaction point.`),referenceHeight:A(`Reference frame height for visualizing the interaction point.`),ref:k(`Snapshot ref without the @ prefix when the target was an @ref.`),selector:k(`Selector expression when the target was a selector.`),selectorChain:Cr(),refLabel:k(),targetHittable:j(),hint:k(),warning:k(),message:k(),evidence:dc,resolution:mc,cost:fc,maestroNonHittableCoordinateFallbackAllowed:j(`Whether the direct iOS Maestro coordinate fallback was allowed for this selector.`),maestroNonHittableCoordinateFallbackUsed:j(`Whether the direct iOS Maestro coordinate fallback was actually used.`),maestroFallbackReason:O(`non-hittable-coordinate`),...t},[`targetKind`,...n])}const gc=hc({properties:{evidence:dc,button:D([`secondary`,`middle`]),count:A(`Number of press/click repetitions.`),intervalMs:A(`Delay between repeated press/click actions.`),holdMs:A(`Hold duration for each action.`),jitterPx:A(`Randomization radius in pixels.`),doubleTap:j(`Whether the command requested a double-tap action.`)}}),_c={text:k(`Text submitted to the field.`),delayMs:A(`Delay between typed characters in milliseconds.`),evidence:dc},vc=E({resourceId:xr(`Identifier of the exact field that changed: Android resource id or Apple accessibility identifier.`),className:xr(`Type of the exact field that changed: Android class name or Apple element type.`),packageName:xr(`App that owns the exact field: Android package name or Apple bundle id.`),rect:E({x:A(),y:A(),width:A(),height:A()},[`x`,`y`,`width`,`height`],`Screen-space rectangle of the exact field that changed.`)},[`resourceId`,`className`,`packageName`,`rect`],`Target identity captured before fill and matched after fill.`),yc={press:gc,click:gc,fill:{type:`object`,description:`Fill response. Returns target-bound unconfirmed evidence when the exact field changed but its value cannot confirm the text: Android app-owned formatting, or an Apple field whose accessibility value does not echo the typed text.`,oneOf:[{...hc({properties:_c,required:[`text`]}),not:E({},[`verification`])},hc({properties:{..._c,verification:O(`unconfirmed`),requested:k(`Literal text requested by the fill command.`),before:xr(`Raw target text captured before the fill.`),after:xr(`Raw target text captured after the fill.`),target:vc},required:[`text`,`verification`,`requested`,`before`,`after`,`target`]})]},longpress:hc({properties:{durationMs:A(),gesture:O(`longpress`)}}),hover:hc({properties:{gesture:O(`hover`)}}),find:E({ref:k(`Snapshot ref without the @ prefix when the find action returns one.`),refsGeneration:A(`ADR 0014 ref frame epoch for read-only find actions.`),found:j(`Whether a wait/exists/read-only find satisfied its condition.`),waitedMs:A(`Milliseconds waited for a read-only find condition.`),text:k(`Text value returned by find get_text.`),node:M(`Snapshot node for find get_attrs/get_text.`),matches:{type:`array`,description:`Every match for the read-only find list action (#1625): { ref, node } each.`,items:M(`One listed match with its snapshot ref and node.`)},locator:k(`Locator kind used for the find action.`),query:k(`Query argument used for the find action.`),x:A(`Resolved x coordinate for mutating find actions.`),y:A(`Resolved y coordinate for mutating find actions.`),message:k(`Diagnostic message for mutating find actions.`),cost:fc},[],`Daemon response data for the find command.`)},Y={get:{usageOverride:`get text|attrs <@ref|selector>`,usageFlags:[],positionalArgs:[`subcommand`,`target`],allowsExtraPositionals:!0,allowedFlags:[...ji,`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:[...ji,`record`]},click:{usageOverride:`click <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...Pi,`clickButton`,...cs(`click`),...ji]},press:{usageOverride:`press <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...Pi,...cs(`press`),...ji]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,usageFlags:[],positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...cs(`longpress`),...ji]},hover:{usageOverride:`hover <x y|@ref|selector>`,usageFlags:[],positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...cs(`hover`),...ji]},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:[...ji,`delayMs`,`recordAs`,...cs(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount]`,usageFlags:[`until`,`pixels`,`durationMs`,`settle`],positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`,`until`,...cs(`scroll`)]}},bc=U({name:`interaction`,clientSurface:!1,commands:[H({name:`click`,text:{summary:`Click or tap a UI target`},metadata:X(`click`),run:(e,t)=>e.interactions.click(xc(t)),cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),H({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(Sc(t)),cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),H({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(Cc(t)),cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),H({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(wc(t)),cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),H({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(Tc(t)),cliSchema:Y.hover,cliReader:K.hover,daemonWriter:q.hover,cliOutputFormatter:J.hover}),H({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}),H({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}),H({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}),H({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}),H({name:`get`,text:{summary:`Read element text or attributes`},metadata:X(`get`),run:(e,t)=>e.interactions.get(Dc(t)),cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),H({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:$s.is,daemonWriter:ec.is,cliOutputFormatter:J.is}),H({name:`find`,text:{summary:`Find an element and act`},metadata:X(`find`),run:(e,t)=>e.interactions.find(t),cliSchema:Y.find,cliReader:$s.find,daemonWriter:ec.find,cliOutputFormatter:J.find}),H({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(Oc(t));case`fling`:return await e.interactions.fling(Ac(t));case`swipe`:return await e.interactions.swipeGesture(jc(t));case`pinch`:return await e.interactions.pinch(Mc(t));case`rotate`:return await e.interactions.rotateGesture(Nc(t));case`transform`:return await e.interactions.transformGesture(Pc(t));case`drag`:return await e.interactions.drag(kc(t))}},cliSchema:Y.gesture,cliReader:ks.gesture,daemonWriter:As.gesture})]});function X(e){let t=Ds.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function xc(e){return{...Sc(e),button:e.button}}function Sc(e){return{...g(e),...Ur(e.target),...Kr(e),...Gr(e),verify:e.verify,readinessTimeoutMs:e.readinessTimeoutMs,...Ec(e)}}function Cc(e){return{...g(e),...Ur(e.target),...Kr(e),text:e.text,delayMs:e.delayMs,recordAs:e.recordAs,verify:e.verify,...Ec(e)}}function wc(e){return{...g(e),...Ur(e.target),...Kr(e),durationMs:e.durationMs,readinessTimeoutMs:e.readinessTimeoutMs,...Ec(e)}}function Tc(e){return{...g(e),...Ur(e.target),...Kr(e),...Ec(e)}}function Ec(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function Dc(e){return{...g(e),...Wr(e.target),...Kr(e),format:e.format,record:e.record}}function Oc(e){return{...g(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,pointerCount:e.pointerCount,durationMs:e.durationMs}}function kc(e){return{...g(e),source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}}function Ac(e){return{...g(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance}}function jc(e){return{...g(e),preset:e.preset}}function Mc(e){return{...g(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function Nc(e){return{...g(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y}}function Pc(e){return{...g(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 Fc(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{devices:e.map(t)},text:e.map(Yc).join(`
|
|
16
16
|
`)}}async function Ic(e){let{serializeDevice:t}=await import(`./result-serialization.js`).then(e=>e.t);return{data:{device:t(e.device),availableCommands:e.availableCommands},text:[`${Yc(e.device)} supports ${e.availableCommands.length} commands:`,e.availableCommands.join(` `)].join(`
|
|
17
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 Rc(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 zc(e){let{serializeOpenResult:t}=await import(`./result-serialization.js`).then(e=>e.t),n=t(e),r=[
|
|
21
|
-
`)||null}}async function Bc(e){return!e||!Array.isArray(e.nodes)?null:await Ao({result:e,interactiveOnly:!0})}async function Vc(e){let{serializeCloseResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return
|
|
20
|
+
`):e.appsFilter===`all`?`No apps found.`:`No user apps or provider app assets found.`}}async function Rc(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 zc(e){let{serializeOpenResult:t}=await import(`./result-serialization.js`).then(e=>e.t),n=t(e),r=[Dt(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 Bc(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 Bc(e){return!e||!Array.isArray(e.nodes)?null:await Ao({result:e,interactiveOnly:!0})}async function Vc(e){let{serializeCloseResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return kt(t(e))}function Hc(e){if(Uc(e))return{data:e,text:e.artifacts.length>0?e.artifacts.map(Zc).join(`
|
|
22
22
|
`):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=Qc(e);return n&&t.push(`Retry: ${n}`),{data:e,text:e.cloudArtifacts.length>0?e.cloudArtifacts.map(Xc).join(`
|
|
23
23
|
`):t.join(`
|
|
24
|
-
`)}}function Uc(e){return`source`in e&&e.source===`daemon`}async function Wc(e){let{serializeDeployResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return
|
|
25
|
-
`)}}const Z={boot:d(Kc),shutdown:d(qc),devices:d(Fc),capabilities:d(Ic),doctor:({result:e,progress:t})=>Jc(e,t),apps:({input:e,result:t})=>Lc({result:t,appsFilter:e.appsFilter}),session:d(Rc),artifacts:d(Hc),open:d(zc),close:d(Vc),install:d(Wc),reinstall:d(Wc),"install-from-source":d(Gc),prepare:f,viewport:f};function Yc(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=e.model?` model=${JSON.stringify(e.model)}`:``,i=e.osVersion?` os=${e.osVersion}`:``,a=typeof e.booted==`boolean`?` booted=${e.booted}`:``,o=e.claimedBy?` claimed by session "${e.claimedBy.session}" in ${e.claimedBy.workspace}`:``;return`${e.name} (${e.platform}${t}${n}${r}${i})${a}${o}`}function Xc(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Zc(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Qc(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function $c(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const el=H({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:V(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:P(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:P(`Cloud provider session id or ARN.`)}),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)=>({...y(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:_(u.artifacts),cliOutputFormatter:Z.artifacts});function tl(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 nl(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=tl({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const rl=V(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:R([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),il=V(`open`,`Boot the selected device when needed, then open an app, deep link, or URL in a session. Use the app or URL inputs to choose what becomes the foreground automation target.`,{app:P(`App name, bundle id, package, or URL.`),url:P(`Optional URL passed with an app shell.`),surface:R(ft,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:P(`Android activity name.`),launchConsole:P(`Launch console mode.`),launchArgs:jr(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:L(`Force relaunch.`),timeoutMs:I(`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:Er(`waitMs`),foreground:Er(`foreground`),saveScript:z({oneOf:[j(),k()]}),force:L(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),testIme:L(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:L(`Do not record this action.`),metroHost:P(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:I(`Session-scoped Metro/debug port hint applied to the opened app. On an emulator/simulator the host defaults to the loopback alias (Android 10.0.2.2, iOS 127.0.0.1) when --metro-host is omitted; physical devices still require an explicit --metro-host.`,{min:1,max:65535}),bundleUrl:P(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:P(`Session-scoped launch URL hint applied to the opened app.`)}),al=V(`close`,`Close the named app, or close the active session app when app is omitted. Use shutdown only when the selected simulator or emulator should also stop.`,{app:P(`Optional app to close.`),shutdown:L(`Shutdown the session/device where supported.`),saveScript:z({oneOf:[j(),k()]}),force:L(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)});function ol(e){return nl(e)}const sl={allowedFlags:[`appsFilter`]},cl={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`timeoutMs`,`waitMs`,`surface`,...Ni,`launchUrl`]},ll={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},ul=(e,t)=>({...y(t),appsFilter:Qt(t.appsFilter)}),dl=(e,t)=>({...y(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,testIme:t.testIme,noRecord:t.noRecord,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl}),fl=(e,t)=>({...y(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),pl=_(u.apps),ml=_(u.open,bl),hl=_(u.close,e=>S(e.app)),gl=H({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:rl,run:(e,t)=>e.apps.list(t),cliSchema:sl,cliReader:ul,daemonWriter:pl,cliOutputFormatter:Z.apps}),_l=H({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. On an iOS simulator, when --launch-url raises an "Open in <App>?" prompt that keeps open from seeing the app, open accepts it if the URL scheme belongs to the session app (data.launchConfirmation: "accepted"); if the scheme belongs to another installed app, the prompt stays on screen and open fails with details.reason launch_confirmation_foreign_app; if no single installed app owns the scheme, the prompt stays on screen and open returns as usual. The prompt is read whenever open cannot see the app afterwards, including on a slow host where the app's target discovery fails on its own deadline. When an accept leaves the app provably not running, open hands the same URL over once more and reads again; still not running, it fails with details.reason launch_confirmation_unanswered. A recognized prompt still visible after a failed accept also fails with this reason, even if the app is running behind it; answer it with alert accept or alert dismiss. A simulator openurl that CoreSimulator never answers fails within 20s with details.reason ios-simulator-openurl-timeout. Only the English prompt title with Cancel and Open buttons is recognized, so on a Simulator set to another language the prompt stays on screen. A prompt that appears after open has already seen the app is not answered; use alert accept. 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:il,run:(e,t)=>e.apps.open(ol(t)),cliSchema:cl,cliReader:dl,daemonWriter:ml,cliOutputFormatter:Z.open}),vl=H({name:`close`,text:{summary:`Close an app or end the session`},metadata:al,run:(e,t)=>t.app?e.apps.close(t):e.sessions.close(yl(t)),cliSchema:ll,cliReader:fl,daemonWriter:hl,cliOutputFormatter:Z.close});function yl(e){let{app:t,...n}=e;return n}function bl(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const xl={platform:D(ve),target:D(be),device:k(`Human-readable device name.`),id:k(`Stable device id.`),kind:D(xe)},Sl=[`platform`,`target`,`device`,`id`,`kind`],Cl=E({success:j(),exitCode:A(),stdout:k(),stderr:k(),error:M(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]),wl={boot:E({...xl,booted:{type:`boolean`,const:!0}},[...Sl,`booted`]),shutdown:E({...xl,shutdown:Cl},[...Sl,`shutdown`])},Tl=V(`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.`,{}),El=V(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),Dl=V(`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:L(`Boot without showing simulator UI when supported.`),timeoutMs:I(`Startup budget in milliseconds. Bounds the boot wait, so a never-booted Simulator can finish its first-boot migration or a cold emulator its boot; omit for the default startup behavior.`,{min:1})}),Ol=V(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),kl={allowedFlags:[`headless`,`timeoutMs`]},Al={},jl={},Ml={},Nl=(e,t)=>y(t),Pl=(e,t)=>({...y(t),headless:t.headless,timeoutMs:t.timeoutMs}),Fl=_(u.devices),Il=_(u.capabilities),Ll=_(u.boot),Rl=_(u.shutdown),zl=[H({name:`devices`,text:{summary:`List available devices and simulators`},metadata:Tl,run:(e,t)=>e.devices.list(t),cliSchema:Al,cliReader:Nl,daemonWriter:Fl,cliOutputFormatter:Z.devices}),H({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:El,run:(e,t)=>e.devices.capabilities(t),cliSchema:jl,cliReader:Nl,daemonWriter:Il,cliOutputFormatter:Z.capabilities}),H({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:Dl,run:(e,t)=>e.devices.boot(t),cliSchema:kl,cliReader:Pl,daemonWriter:Ll,cliOutputFormatter:Z.boot}),H({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:Ol,run:(e,t)=>e.devices.shutdown(t),cliSchema:Ml,cliReader:Nl,daemonWriter:Rl,cliOutputFormatter:Z.shutdown})],Bl={doctor:E({status:D([`pass`,`warn`,`fail`,`info`]),summary:k(),kind:D([`auto`,`react-native`,`expo`,`repack`]),platform:k(),target:D(be),targetApp:k(),metro:E({host:k(),port:A()},[`host`,`port`]),checks:{type:`array`,items:E({id:k(),status:D([`pass`,`warn`,`fail`,`info`]),summary:k(),hint:k(),command:k(),evidence:M()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`])},Vl=H({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:V(`doctor`,`Diagnose device, app, development-server, and React Native or Expo readiness issues. Returns compact evidence for local inventory, sessions, optional app discovery, toolchains, and server reachability.`,{targetApp:P(`Installed app package/bundle id or app name to verify without opening a session.`),remote:L(`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)=>({...y(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:_(u.doctor),cliOutputFormatter:Z.doctor});function Hl(e,t=`--github-actions-artifact`){let n=e.indexOf(`:`);if(n<=0||n===e.length-1)throw new r(`INVALID_ARGS`,`${t} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:i,repo:a}=Gl(e.slice(0,n),t);return Wl(i,a,e.slice(n+1),`${t} artifact`)}function Ul(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`${t} installSource must be an object.`);let n=e;if(ql(n.type,`${t} installSource.type`)!==`github-actions-artifact`)throw new r(`INVALID_ARGS`,`${t} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=Gl(ql(n.repo,`${t} installSource.repo`),`${t} installSource.repo`);return Wl(i,a,n.artifact,`${t} installSource.artifact`)}function Wl(e,t,n,r){return typeof n==`number`||Yl(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:Jl(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:ql(n,r)}}function Gl(e,t){let n=e.indexOf(`/`);if(n<=0||n===e.length-1||e.indexOf(`/`,n+1)!==-1)throw new r(`INVALID_ARGS`,`${t} must use owner/repo.`);let i={owner:e.slice(0,n).trim(),repo:e.slice(n+1).trim()};if(!i.owner||!i.repo)throw new r(`INVALID_ARGS`,`${t} must use owner/repo.`);return i}function Kl(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function ql(e,t){let n=Kl(e);if(!n)throw new r(`INVALID_ARGS`,`${t} must be a non-empty string.`);return n}function Jl(e,t){let n=typeof e==`number`?e:typeof e==`string`?Number(e):NaN;if(!Number.isInteger(n))throw new r(`INVALID_ARGS`,`${t} must be an integer.`);return n}function Yl(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const Xl=V(`install`,`Install an app binary from a local path. Provide an app identifier with the path when the target needs explicit app selection; use reinstall to replace an already installed app.`,{app:P(`Optional app identifier hint.`),appPath:N(P(`Path to app binary.`))}),Zl=V(`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:N(P()),appPath:N(P(`Path to app binary.`))}),Ql=V(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:N(z(M(`Install source object.`))),retainPaths:L(),retentionMs:I()}),$l={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},eu={positionalArgs:[`app`,`path`]},tu={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`]},nu=(e,t)=>cu(e,t),ru=(e,t)=>lu(e,t),iu=(e,t)=>({...y(t),source:fu(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),au=_(u.install,e=>uu(e.app,e.appPath)),ou=_(u.reinstall,e=>du(e.app,e.appPath)),su=[H({name:`install`,text:{summary:`Install an app binary from a path`},metadata:Xl,run:(e,t)=>e.apps.install(t),cliSchema:$l,cliReader:nu,daemonWriter:au,cliOutputFormatter:Z.install}),H({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:Zl,run:(e,t)=>e.apps.reinstall(t),cliSchema:eu,cliReader:ru,daemonWriter:ou,cliOutputFormatter:Z.reinstall}),H({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:Ql,run:(e,t)=>e.apps.installFromSource(t),cliSchema:tu,cliReader:iu,daemonWriter:e=>v(st.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function cu(e,t){let[n,r]=e,i=r!==void 0;return{...y(t),...i?{app:w(n,`install requires app`)}:{},appPath:w(i?r:n,`install requires path`)}}function lu(e,t){return{...y(t),app:w(e[0],`reinstall requires app`),appPath:w(e[1],`reinstall requires path`)}}function uu(e,t){let n=T(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function du(e,t){return[T(e,`missing first positional`),T(t,`missing second positional`)]}function fu(e,t){let n=e[0]?.trim();if(e.length>1)throw new r(`INVALID_ARGS`,`install-from-source accepts either one <url> positional or --github-actions-artifact`);let i=t.githubActionsArtifact?Hl(t.githubActionsArtifact):void 0,a=t.installSource;if(+!!n+ +!!i+ +!!a!=1)throw new r(`INVALID_ARGS`,`install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource`);if(!n&&t.header&&t.header.length>0)throw new r(`INVALID_ARGS`,`install-from-source --header is only supported for URL sources`);if(i)return i;if(a)return a;if(!pu(n))throw new r(`INVALID_ARGS`,`install-from-source <url> must be an http(s) URL: ${n}`,{hint:`Install a local build with install <app> <path>.`});return{kind:`url`,url:n,headers:mu(t.header)}}function pu(e){let t=URL.parse(e)?.protocol;return t===`http:`||t===`https:`}function mu(e){if(!e||e.length===0)return;let t={};for(let n of e){let e=n.indexOf(`:`);if(e<=0)throw new r(`INVALID_ARGS`,`Invalid --header value "${n}". Expected "name:value".`);let i=n.slice(0,e).trim(),a=n.slice(e+1).trim();if(!i)throw new r(`INVALID_ARGS`,`Invalid --header value "${n}". Header name cannot be empty.`);t[i]=a}return t}const hu=[`ios-runner`],gu={prepare:E({action:O(`ios-runner`),platform:D(ve),deviceId:k(),deviceName:k(),kind:D(xe),durationMs:A(),runner:E({},[]),cache:D([`exact`,`miss`,`external`]),artifact:D([`valid`,`rebuilt`]),buildMs:A(),connectMs:A(),healthCheckMs:A(),xctestrunPath:k(),recoveryReason:k(),failureReason:k(),timing:E({totalMs:A(),additiveParts:E({buildMs:A(),connectAfterBuildMs:A(),healthCheckMs:A()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:E({connectMs:{type:`array`,items:O(`buildMs`)},healthCheckMs:{type:`array`,items:k()}},[`healthCheckMs`]),note:k()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:k()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`])},_u=H({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:V(`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:N(R(hu)),timeoutMs:I(`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)=>({...y(t),action:w(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:_(u.prepare,e=>[T(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),vu={push:{type:`object`,oneOf:[E({platform:O(`ios`),bundleId:k(),message:k()},[`platform`,`bundleId`,`message`]),E({platform:O(`android`),package:k(),action:k(),extrasCount:A(),message:k()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":E({event:k(),eventUrl:k(),transport:O(`deep-link`),message:k()},[`event`,`eventUrl`,`transport`,`message`])},yu=V(`push`,`Deliver push notification payloads to an installed app.`,{app:N(P()),payload:N(z({oneOf:[k(),M()]}))}),bu=V(`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:N(P(`Name of an app-defined automation or test event the app documents.`)),payload:Au(`Structured payload passed to the event, in the shape the app documents for it.`)}),xu={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},Su={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},Cu=(e,t)=>({...y(t),app:w(e[0],`push requires bundleOrPackage`),payload:w(e[1],`push requires payloadOrJson`)}),wu=(e,t)=>({...y(t),event:w(e[0],`trigger-app-event requires event`),payload:e[1]?cr(e[1],`trigger-app-event payload`):void 0}),Tu=_(u.push,e=>Ou(e)),Eu=_(u.triggerAppEvent,e=>ku(e)),Du=[H({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:yu,run:(e,t)=>e.apps.push(t),cliSchema:xu,cliReader:Cu,daemonWriter:Tu}),H({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:bu,run:(e,t)=>e.apps.triggerEvent(t),cliSchema:Su,cliReader:wu,daemonWriter:Eu})];function Ou(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function ku(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function Au(e){return Ar(e)}const ju=H({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:V(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:R([`list`,`state-dir`,`save-script`],`list shows active sessions; state-dir prints the daemon state directory; save-script publishes an armed recording without teardown.`),path:P(`Optional .ad output path for save-script.`),force:L(`Atomically replace an existing save-script target.`)}),run:async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return Nu(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)=>({...y(t),action:Mu(e[0]),path:e[1],force:t.force}),cliOutputFormatter:Z.session});function Mu(e){let t=e??`list`;if(t===`list`||t===`state-dir`||t===`save-script`)return t;throw new r(`INVALID_ARGS`,`session only supports list, state-dir, or save-script`)}function Nu(e,t,n){if(e!==`save-script`&&(t!==void 0||n===!0))throw new r(`INVALID_ARGS`,`session ${e} does not accept a path or --force; use session save-script [path] [--force] to publish a recording.`)}const Pu={viewport:E({width:A(),height:A(),message:k()},[`width`,`height`,`message`])},Fu=H({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:V(`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:N(I(`Viewport width in CSS pixels.`,{min:1})),height:N(I(`Viewport height in CSS pixels.`,{min:1}))}),run:(e,t)=>e.command.viewport(t),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...y(t),..._e(e)}),daemonWriter:_(u.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),Iu=U({name:`management`,commands:[...zl,el,Vl,_u,gl,ju,_l,vl,Fu,...su,...Du]});function Lu(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const Ru={metro:({input:e,result:t})=>Lu({result:t,action:e.action})},zu=`metro`,Bu=U({name:`metro`,commands:[H({name:zu,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:V(zu,`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:N(R([`prepare`,`reload`])),projectRoot:P(),kind:z(k()),publicBaseUrl:P(),proxyBaseUrl:Tr(P(),{operatorPath:`Configure the remote proxy in the remote-config profile or operator config for the process serving these tools.`}),bearerToken:Tr(P(),{envFlagKeys:[`metroBearerToken`,`daemonAuthToken`]}),bridgeScope:z({type:`object`,additionalProperties:!0}),launchUrl:P(),port:I(),listenHost:P(),statusHost:P(),startupTimeoutMs:I(),probeTimeoutMs:I(),reuseExisting:L(),installDependenciesIfNeeded:L(),runtimeFilePath:P(),logPath:P(),metroHost:P(),metroPort:I(),bundleUrl:P(),timeoutMs:I()}),run:async(e,t)=>t.action===`prepare`?await e.metro.prepare(Vu(t)):await e.metro.reload(Uu(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:[...Ni,...Mi]},cliReader:(e,t)=>{let n=(e[0]??``).toLowerCase();if(n!==`prepare`&&n!==`reload`)throw new r(`INVALID_ARGS`,`metro requires a subcommand: prepare or reload`);if(n===`reload`)return{action:n,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,timeoutMs:t.metroProbeTimeoutMs};if(!t.metroPublicBaseUrl&&!t.metroProxyBaseUrl)throw new r(`INVALID_ARGS`,`metro prepare requires --public-base-url <url> or --proxy-base-url <url>.`);return{action:n,projectRoot:t.metroProjectRoot,kind:
|
|
27
|
-
`),stderr:xd([yd(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),bd(e.notes)])}}function
|
|
28
|
-
`),stderr:xd([yd(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),bd(e.notes)])}}const
|
|
29
|
-
`)}function
|
|
24
|
+
`)}}function Uc(e){return`source`in e&&e.source===`daemon`}async function Wc(e){let{serializeDeployResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return kt(t(e))}async function Gc(e){let{serializeInstallFromSourceResult:t}=await import(`./result-serialization.js`).then(e=>e.t);return kt(t(e))}function Kc(e){let t=e,n=t.platform??`unknown`;return{data:t,text:`Boot ready: ${t.device??t.id??`unknown`} (${n})`}}function qc(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 Jc(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=$c(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:d(Kc),shutdown:d(qc),devices:d(Fc),capabilities:d(Ic),doctor:({result:e,progress:t})=>Jc(e,t),apps:({input:e,result:t})=>Lc({result:t,appsFilter:e.appsFilter}),session:d(Rc),artifacts:d(Hc),open:d(zc),close:d(Vc),install:d(Wc),reinstall:d(Wc),"install-from-source":d(Gc),prepare:f,viewport:f};function Yc(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=e.model?` model=${JSON.stringify(e.model)}`:``,i=e.osVersion?` os=${e.osVersion}`:``,a=typeof e.booted==`boolean`?` booted=${e.booted}`:``,o=e.claimedBy?` claimed by session "${e.claimedBy.session}" in ${e.claimedBy.workspace}`:``;return`${e.name} (${e.platform}${t}${n}${r}${i})${a}${o}`}function Xc(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Zc(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Qc(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function $c(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const el=H({name:`artifacts`,text:{summary:`List daemon or cloud provider session artifacts`},metadata:V(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:P(`Cloud provider name, for example browserstack, aws-device-farm, or testmu.`),providerSessionId:P(`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)=>({...y(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:_(u.artifacts),cliOutputFormatter:Z.artifacts});function tl(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 nl(e){let{metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i,...a}=e,o=tl({metroHost:t,metroPort:n,bundleUrl:r,launchUrl:i});return o?{...a,runtime:o}:a}const rl=V(`apps`,`List the apps installed on the selected device. Include system or OEM apps only when they are needed as automation targets.`,{appsFilter:R([`user-installed`,`all`],`Restrict the listing to user-installed apps, or include system and OEM apps.`)}),il=V(`open`,`Boot the selected device when needed, then open an app, deep link, or URL in a session. Use the app or URL inputs to choose what becomes the foreground automation target.`,{app:P(`App name, bundle id, package, or URL.`),url:P(`Optional URL passed with an app shell.`),surface:R(dt,`macOS presentation surface to open: the app itself, the frontmost app, the desktop, or the menu bar.`),activity:P(`Android activity name.`),launchConsole:P(`Launch console mode.`),launchArgs:jr(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:L(`Force relaunch.`),timeoutMs:I(`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:Er(`waitMs`),foreground:Er(`foreground`),saveScript:z({oneOf:[j(),k()]}),force:L(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`),testIme:L(`Activate the headless Android test IME for deterministic Unicode text entry (default on for emulators; opt-in on real devices).`),noRecord:L(`Do not record this action.`),metroHost:P(`Session-scoped Metro/debug host hint applied to the opened app.`),metroPort:I(`Session-scoped Metro/debug port hint applied to the opened app. On an emulator/simulator the host defaults to the loopback alias (Android 10.0.2.2, iOS 127.0.0.1) when --metro-host is omitted; physical devices still require an explicit --metro-host.`,{min:1,max:65535}),bundleUrl:P(`Session-scoped bundle URL hint applied to the opened app.`),launchUrl:P(`Session-scoped launch URL hint applied to the opened app.`)}),al=V(`close`,`Close the named app, or close the active session app when app is omitted. Use shutdown only when the selected simulator or emulator should also stop.`,{app:P(`Optional app to close.`),shutdown:L(`Shutdown the session/device where supported.`),saveScript:z({oneOf:[j(),k()]}),force:L(`Overwrite an existing --save-script target instead of refusing (alias: --overwrite).`)});function ol(e){return nl(e)}const sl={allowedFlags:[`appsFilter`]},cl={positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`testIme`,`saveScript`,`force`,`noRecord`,`relaunch`,`foreground`,`timeoutMs`,`waitMs`,`surface`,...Ni,`launchUrl`]},ll={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`force`,`shutdown`]},ul=(e,t)=>({...y(t),appsFilter:Zt(t.appsFilter)}),dl=(e,t)=>({...y(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,testIme:t.testIme,noRecord:t.noRecord,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl}),fl=(e,t)=>({...y(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript,force:t.force}),pl=_(u.apps),ml=_(u.open,bl),hl=_(u.close,e=>S(e.app)),gl=H({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:rl,run:(e,t)=>e.apps.list(t),cliSchema:sl,cliReader:ul,daemonWriter:pl,cliOutputFormatter:Z.apps}),_l=H({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. On an iOS simulator, when --launch-url raises an "Open in <App>?" prompt that keeps open from seeing the app, open accepts it if the URL scheme belongs to the session app (data.launchConfirmation: "accepted"); if the scheme belongs to another installed app, the prompt stays on screen and open fails with details.reason launch_confirmation_foreign_app; if no single installed app owns the scheme, the prompt stays on screen and open returns as usual. The prompt is read whenever open cannot see the app afterwards, including on a slow host where the app's target discovery fails on its own deadline. When an accept leaves the app provably not running, open hands the same URL over once more and reads again; still not running, it fails with details.reason launch_confirmation_unanswered. A recognized prompt still visible after a failed accept also fails with this reason, even if the app is running behind it; answer it with alert accept or alert dismiss. A simulator openurl that CoreSimulator never answers fails within 20s with details.reason ios-simulator-openurl-timeout. Only the English prompt title with Cancel and Open buttons is recognized, so on a Simulator set to another language the prompt stays on screen. A prompt that appears after open has already seen the app is not answered; use alert accept. 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:il,run:(e,t)=>e.apps.open(ol(t)),cliSchema:cl,cliReader:dl,daemonWriter:ml,cliOutputFormatter:Z.open}),vl=H({name:`close`,text:{summary:`Close an app or end the session`},metadata:al,run:(e,t)=>t.app?e.apps.close(t):e.sessions.close(yl(t)),cliSchema:ll,cliReader:fl,daemonWriter:hl,cliOutputFormatter:Z.close});function yl(e){let{app:t,...n}=e;return n}function bl(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const xl={platform:D(_e),target:D(ye),device:k(`Human-readable device name.`),id:k(`Stable device id.`),kind:D(be)},Sl=[`platform`,`target`,`device`,`id`,`kind`],Cl=E({success:j(),exitCode:A(),stdout:k(),stderr:k(),error:M(`Normalized error detail when shutdown failed.`)},[`success`,`exitCode`,`stdout`,`stderr`]),wl={boot:E({...xl,booted:{type:`boolean`,const:!0}},[...Sl,`booted`]),shutdown:E({...xl,shutdown:Cl},[...Sl,`shutdown`])},Tl=V(`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.`,{}),El=V(`capabilities`,`List the commands supported by the selected device or active session. Use device-selection inputs when checking support before a session is open.`,{}),Dl=V(`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:L(`Boot without showing simulator UI when supported.`),timeoutMs:I(`Startup budget in milliseconds. Bounds the boot wait, so a never-booted Simulator can finish its first-boot migration or a cold emulator its boot; omit for the default startup behavior.`,{min:1})}),Ol=V(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),kl={allowedFlags:[`headless`,`timeoutMs`]},Al={},jl={},Ml={},Nl=(e,t)=>y(t),Pl=(e,t)=>({...y(t),headless:t.headless,timeoutMs:t.timeoutMs}),Fl=_(u.devices),Il=_(u.capabilities),Ll=_(u.boot),Rl=_(u.shutdown),zl=[H({name:`devices`,text:{summary:`List available devices and simulators`},metadata:Tl,run:(e,t)=>e.devices.list(t),cliSchema:Al,cliReader:Nl,daemonWriter:Fl,cliOutputFormatter:Z.devices}),H({name:`capabilities`,text:{summary:`List supported commands for the selected device`,cliDetail:`Select an explicit target with --platform/--device/--udid/--serial.`},metadata:El,run:(e,t)=>e.devices.capabilities(t),cliSchema:jl,cliReader:Nl,daemonWriter:Il,cliOutputFormatter:Z.capabilities}),H({name:`boot`,text:{summary:`Boot target device/simulator`},metadata:Dl,run:(e,t)=>e.devices.boot(t),cliSchema:kl,cliReader:Pl,daemonWriter:Ll,cliOutputFormatter:Z.boot}),H({name:`shutdown`,text:{summary:`Shutdown target simulator/emulator`},metadata:Ol,run:(e,t)=>e.devices.shutdown(t),cliSchema:Ml,cliReader:Nl,daemonWriter:Rl,cliOutputFormatter:Z.shutdown})],Bl={doctor:E({status:D([`pass`,`warn`,`fail`,`info`]),summary:k(),kind:D([`auto`,`react-native`,`expo`,`repack`]),platform:k(),target:D(ye),targetApp:k(),metro:E({host:k(),port:A()},[`host`,`port`]),checks:{type:`array`,items:E({id:k(),status:D([`pass`,`warn`,`fail`,`info`]),summary:k(),hint:k(),command:k(),evidence:M()},[`id`,`status`,`summary`])}},[`status`,`summary`,`kind`,`checks`])},Vl=H({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:V(`doctor`,`Diagnose device, app, development-server, and React Native or Expo readiness issues. Returns compact evidence for local inventory, sessions, optional app discovery, toolchains, and server reachability.`,{targetApp:P(`Installed app package/bundle id or app name to verify without opening a session.`),remote:L(`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)=>({...y(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:_(u.doctor),cliOutputFormatter:Z.doctor});function Hl(e,t=`--github-actions-artifact`){let n=e.indexOf(`:`);if(n<=0||n===e.length-1)throw new r(`INVALID_ARGS`,`${t} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:i,repo:a}=Gl(e.slice(0,n),t);return Wl(i,a,e.slice(n+1),`${t} artifact`)}function Ul(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new r(`INVALID_ARGS`,`${t} installSource must be an object.`);let n=e;if(ql(n.type,`${t} installSource.type`)!==`github-actions-artifact`)throw new r(`INVALID_ARGS`,`${t} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=Gl(ql(n.repo,`${t} installSource.repo`),`${t} installSource.repo`);return Wl(i,a,n.artifact,`${t} installSource.artifact`)}function Wl(e,t,n,r){return typeof n==`number`||Yl(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:Jl(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:ql(n,r)}}function Gl(e,t){let n=e.indexOf(`/`);if(n<=0||n===e.length-1||e.indexOf(`/`,n+1)!==-1)throw new r(`INVALID_ARGS`,`${t} must use owner/repo.`);let i={owner:e.slice(0,n).trim(),repo:e.slice(n+1).trim()};if(!i.owner||!i.repo)throw new r(`INVALID_ARGS`,`${t} must use owner/repo.`);return i}function Kl(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function ql(e,t){let n=Kl(e);if(!n)throw new r(`INVALID_ARGS`,`${t} must be a non-empty string.`);return n}function Jl(e,t){let n=typeof e==`number`?e:typeof e==`string`?Number(e):NaN;if(!Number.isInteger(n))throw new r(`INVALID_ARGS`,`${t} must be an integer.`);return n}function Yl(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const Xl=V(`install`,`Install an app binary from a local path. Provide an app identifier with the path when the target needs explicit app selection; use reinstall to replace an already installed app.`,{app:P(`Optional app identifier hint.`),appPath:N(P(`Path to app binary.`))}),Zl=V(`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:N(P()),appPath:N(P(`Path to app binary.`))}),Ql=V(`install-from-source`,`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,{source:N(z(M(`Install source object.`))),retainPaths:L(),retentionMs:I()}),$l={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},eu={positionalArgs:[`app`,`path`]},tu={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`]},nu=(e,t)=>cu(e,t),ru=(e,t)=>lu(e,t),iu=(e,t)=>({...y(t),source:fu(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),au=_(u.install,e=>uu(e.app,e.appPath)),ou=_(u.reinstall,e=>du(e.app,e.appPath)),su=[H({name:`install`,text:{summary:`Install an app binary from a path`},metadata:Xl,run:(e,t)=>e.apps.install(t),cliSchema:$l,cliReader:nu,daemonWriter:au,cliOutputFormatter:Z.install}),H({name:`reinstall`,text:{summary:`Replace an installed app with a new build`},metadata:Zl,run:(e,t)=>e.apps.reinstall(t),cliSchema:eu,cliReader:ru,daemonWriter:ou,cliOutputFormatter:Z.reinstall}),H({name:`install-from-source`,text:{summary:`Install app builds from URLs or CI artifacts`},metadata:Ql,run:(e,t)=>e.apps.installFromSource(t),cliSchema:tu,cliReader:iu,daemonWriter:e=>v(ot.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function cu(e,t){let[n,r]=e,i=r!==void 0;return{...y(t),...i?{app:w(n,`install requires app`)}:{},appPath:w(i?r:n,`install requires path`)}}function lu(e,t){return{...y(t),app:w(e[0],`reinstall requires app`),appPath:w(e[1],`reinstall requires path`)}}function uu(e,t){let n=T(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function du(e,t){return[T(e,`missing first positional`),T(t,`missing second positional`)]}function fu(e,t){let n=e[0]?.trim();if(e.length>1)throw new r(`INVALID_ARGS`,`install-from-source accepts either one <url> positional or --github-actions-artifact`);let i=t.githubActionsArtifact?Hl(t.githubActionsArtifact):void 0,a=t.installSource;if(+!!n+ +!!i+ +!!a!=1)throw new r(`INVALID_ARGS`,`install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource`);if(!n&&t.header&&t.header.length>0)throw new r(`INVALID_ARGS`,`install-from-source --header is only supported for URL sources`);if(i)return i;if(a)return a;if(!pu(n))throw new r(`INVALID_ARGS`,`install-from-source <url> must be an http(s) URL: ${n}`,{hint:`Install a local build with install <app> <path>.`});return{kind:`url`,url:n,headers:mu(t.header)}}function pu(e){let t=URL.parse(e)?.protocol;return t===`http:`||t===`https:`}function mu(e){if(!e||e.length===0)return;let t={};for(let n of e){let e=n.indexOf(`:`);if(e<=0)throw new r(`INVALID_ARGS`,`Invalid --header value "${n}". Expected "name:value".`);let i=n.slice(0,e).trim(),a=n.slice(e+1).trim();if(!i)throw new r(`INVALID_ARGS`,`Invalid --header value "${n}". Header name cannot be empty.`);t[i]=a}return t}const hu=[`ios-runner`],gu={prepare:E({action:O(`ios-runner`),platform:D(_e),deviceId:k(),deviceName:k(),kind:D(be),durationMs:A(),runner:E({},[]),cache:D([`exact`,`miss`,`external`]),artifact:D([`valid`,`rebuilt`]),buildMs:A(),connectMs:A(),healthCheckMs:A(),xctestrunPath:k(),recoveryReason:k(),failureReason:k(),timing:E({totalMs:A(),additiveParts:E({buildMs:A(),connectAfterBuildMs:A(),healthCheckMs:A()},[`connectAfterBuildMs`,`healthCheckMs`]),containment:E({connectMs:{type:`array`,items:O(`buildMs`)},healthCheckMs:{type:`array`,items:k()}},[`healthCheckMs`]),note:k()},[`totalMs`,`additiveParts`,`containment`,`note`]),message:k()},[`action`,`platform`,`deviceId`,`deviceName`,`kind`,`durationMs`,`runner`,`connectMs`,`healthCheckMs`,`timing`,`message`])},_u=H({name:`prepare`,text:{summary:`Pre-warm platform helpers before automation`},metadata:V(`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:N(R(hu)),timeoutMs:I(`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)=>({...y(t),action:w(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:_(u.prepare,e=>[T(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),vu={push:{type:`object`,oneOf:[E({platform:O(`ios`),bundleId:k(),message:k()},[`platform`,`bundleId`,`message`]),E({platform:O(`android`),package:k(),action:k(),extrasCount:A(),message:k()},[`platform`,`package`,`action`,`extrasCount`,`message`])]},"trigger-app-event":E({event:k(),eventUrl:k(),transport:O(`deep-link`),message:k()},[`event`,`eventUrl`,`transport`,`message`])},yu=V(`push`,`Deliver push notification payloads to an installed app.`,{app:N(P()),payload:N(z({oneOf:[k(),M()]}))}),bu=V(`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:N(P(`Name of an app-defined automation or test event the app documents.`)),payload:Au(`Structured payload passed to the event, in the shape the app documents for it.`)}),xu={listUsageOverride:`push`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},Su={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,positionalArgs:[`event`,`payloadJson?`]},Cu=(e,t)=>({...y(t),app:w(e[0],`push requires bundleOrPackage`),payload:w(e[1],`push requires payloadOrJson`)}),wu=(e,t)=>({...y(t),event:w(e[0],`trigger-app-event requires event`),payload:e[1]?cr(e[1],`trigger-app-event payload`):void 0}),Tu=_(u.push,e=>Ou(e)),Eu=_(u.triggerAppEvent,e=>ku(e)),Du=[H({name:`push`,text:{summary:`Deliver a push notification payload`},metadata:yu,run:(e,t)=>e.apps.push(t),cliSchema:xu,cliReader:Cu,daemonWriter:Tu}),H({name:`trigger-app-event`,text:{summary:`Invoke an app-defined automation event`},metadata:bu,run:(e,t)=>e.apps.triggerEvent(t),cliSchema:Su,cliReader:wu,daemonWriter:Eu})];function Ou(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function ku(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function Au(e){return Ar(e)}const ju=H({name:`session`,text:{summary:`List sessions, show the state dir, or publish a script`},metadata:V(`session`,`List active sessions, print the effective daemon state directory, or publish an armed open-to-destination script without closing its session`,{action:R([`list`,`state-dir`,`save-script`],`list shows active sessions; state-dir prints the daemon state directory; save-script publishes an armed recording without teardown.`),path:P(`Optional .ad output path for save-script.`),force:L(`Atomically replace an existing save-script target.`)}),run:async(e,{action:t,path:n,force:r,...i})=>{let a=t??`list`;return Nu(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)=>({...y(t),action:Mu(e[0]),path:e[1],force:t.force}),cliOutputFormatter:Z.session});function Mu(e){let t=e??`list`;if(t===`list`||t===`state-dir`||t===`save-script`)return t;throw new r(`INVALID_ARGS`,`session only supports list, state-dir, or save-script`)}function Nu(e,t,n){if(e!==`save-script`&&(t!==void 0||n===!0))throw new r(`INVALID_ARGS`,`session ${e} does not accept a path or --force; use session save-script [path] [--force] to publish a recording.`)}const Pu={viewport:E({width:A(),height:A(),message:k()},[`width`,`height`,`message`])},Fu=H({name:`viewport`,text:{summary:`Resize the active web viewport for the current session`},metadata:V(`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:N(I(`Viewport width in CSS pixels.`,{min:1})),height:N(I(`Viewport height in CSS pixels.`,{min:1}))}),run:(e,t)=>e.command.viewport(t),cliSchema:{positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...y(t),...hn(e)}),daemonWriter:_(u.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),Iu=U({name:`management`,commands:[...zl,el,Vl,_u,gl,ju,_l,vl,Fu,...su,...Du]});function Lu(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const Ru={metro:({input:e,result:t})=>Lu({result:t,action:e.action})},zu=[`auto`,`react-native`,`expo`,`repack`];function Bu(e){if(e!==void 0){if(zu.includes(e))return e;throw new r(`INVALID_ARGS`,`metro prepare --kind must be auto, react-native, expo, or repack`)}}const Vu=`metro`,Hu=U({name:`metro`,commands:[H({name:Vu,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:V(Vu,`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:N(R([`prepare`,`reload`])),projectRoot:P(),kind:z(k()),publicBaseUrl:P(),proxyBaseUrl:Tr(P(),{operatorPath:`Configure the remote proxy in the remote-config profile or operator config for the process serving these tools.`}),bearerToken:Tr(P(),{envFlagKeys:[`metroBearerToken`,`daemonAuthToken`]}),bridgeScope:z({type:`object`,additionalProperties:!0}),launchUrl:P(),port:I(),listenHost:P(),statusHost:P(),startupTimeoutMs:I(),probeTimeoutMs:I(),reuseExisting:L(),installDependenciesIfNeeded:L(),runtimeFilePath:P(),logPath:P(),metroHost:P(),metroPort:I(),bundleUrl:P(),timeoutMs:I()}),run:async(e,t)=>t.action===`prepare`?await e.metro.prepare(Uu(t)):await e.metro.reload(Gu(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:[...Ni,...Mi]},cliReader:(e,t)=>{let n=(e[0]??``).toLowerCase();if(n!==`prepare`&&n!==`reload`)throw new r(`INVALID_ARGS`,`metro requires a subcommand: prepare or reload`);if(n===`reload`)return{action:n,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,timeoutMs:t.metroProbeTimeoutMs};if(!t.metroPublicBaseUrl&&!t.metroProxyBaseUrl)throw new r(`INVALID_ARGS`,`metro prepare requires --public-base-url <url> or --proxy-base-url <url>.`);return{action:n,projectRoot:t.metroProjectRoot,kind:Bu(t.kind??t.metroKind),port:t.metroPreparePort,listenHost:t.metroListenHost,statusHost:t.metroStatusHost,publicBaseUrl:t.metroPublicBaseUrl,proxyBaseUrl:t.metroProxyBaseUrl,bearerToken:t.metroBearerToken,bridgeScope:t.tenant&&t.runId&&t.leaseId?{tenantId:t.tenant,runId:t.runId,leaseId:t.leaseId}:void 0,startupTimeoutMs:t.metroStartupTimeoutMs,probeTimeoutMs:t.metroProbeTimeoutMs,reuseExisting:!t.metroNoReuseExisting&&void 0,installDependenciesIfNeeded:!t.metroNoInstallDeps&&void 0,runtimeFilePath:t.metroRuntimeFile}},cliOutputFormatter:Ru.metro})]});function Uu(e){return{projectRoot:e.projectRoot,kind:e.kind,publicBaseUrl:e.publicBaseUrl,proxyBaseUrl:e.proxyBaseUrl,bearerToken:e.bearerToken,bridgeScope:e.bridgeScope??Wu(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 Wu(e){return e.tenant&&e.runId&&e.leaseId?{tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId}:void 0}function Gu(e){return{metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,timeoutMs:e.timeoutMs}}function Ku(e,t){return e.includes(t)}function qu(e,t,n={}){let i=t===void 0?void 0:n.normalize?.(t)??t;if(i!==void 0&&Ku(e,i))return i;let a=typeof n.message==`function`?n.message(t):n.message;throw new r(`INVALID_ARGS`,a??`Invalid value: ${t}. Use ${e.join(`|`)}.`)}const Ju=[`started`,`stopped`,`marked`,`cleared`,`restarted`,`removedRotatedFiles`];function Yu(e){return{data:e,text:e.path,stderr:xd([yd(e,[`active`,`state`,`backend`,`sizeBytes`]),yd(e,Ju),e.hint,bd(e.notes)])}}function Xu(e){let t=e.events??[];return{data:e,text:t.length>0?ed(t):`No session events found.`,stderr:xd([yd(e,[`path`,`cursor`,`nextCursor`,`limit`])])}}function Zu(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(...gd(e));return{data:e,text:t.join(`
|
|
27
|
+
`),stderr:xd([yd(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),bd(e.notes)])}}function Qu(e){return{data:e,text:[`Audio probe: ${String(e.state??`stopped`)} heard=${String(e.heard===!0)}`,fd(`rmsDbfs`,e.rmsDbfs),fd(`peakDbfs`,e.peakDbfs)].filter(e=>!!e).join(`
|
|
28
|
+
`),stderr:xd([yd(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),bd(e.notes)])}}const $u={logs:d(Yu),events:d(Xu),network:d(Zu),audio:d(Qu)};function ed(e){let t=e.map(td),n=Math.min(Math.max(...t.map(e=>e.label.length),5),32);return t.map(e=>nd(e,n)).join(`
|
|
29
|
+
`)}function td(e){return{timestamp:rd(e.ts),label:id(e),summary:ad(e)}}function nd(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 rd(e){return e?e.replace(`T`,` `):``}function id(e){let t=e.command??`command`;switch(e.kind){case`request.started`:return`start ${t}`;case`request.finished`:return pd([e.status===`error`?`error`:`ok`,t,dd(hd(e.details?.durationMs))]);case`action.recorded`:return`action ${t}`;default:return pd([e.kind??`event`,e.command])}}function ad(e){let t=od(e.summary,e);return`${t}${sd(e,t)}`.trim()}function od(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 sd(e,t){if(e.kind!==`action.recorded`)return``;let n=e.details;if(!n)return``;let r=[cd(n,t),ud(hd(n.textLength))].filter(e=>!!e);return r.length>0?` (${r.join(`, `)})`:``}function cd(e,t){let n=md(e.ref)??md(e.selector)??ld(e);if(!(!n||t.includes(n)))return`target=${n}`}function ld(e){let t=hd(e.x),n=hd(e.y);return t===void 0||n===void 0?void 0:`(${t}, ${n})`}function ud(e){return e===void 0?void 0:`text=${e} chars`}function dd(e){return e===void 0?void 0:`${Math.round(e)}ms`}function fd(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 pd(e){return e.filter(e=>!!e).join(` `)}function md(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function hd(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function gd(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?vd(o,`headers`,e.headers):(_d(o,`request headers`,e.requestHeaders),_d(o,`response headers`,e.responseHeaders)),vd(o,`request`,e.requestBody),vd(o,`response`,e.responseBody),o}function _d(e,t,n){!n||Object.keys(n).length===0||e.push(` ${t}: ${JSON.stringify(n)}`)}function vd(e,t,n){n!==void 0&&e.push(` ${t}: ${n}`)}function yd(e,t){return t.map(t=>e[t]!==void 0&&e[t]!==null?`${t}=${e[t]}`:``).filter(Boolean).join(` `)||void 0}function bd(e){let t=e?.filter(e=>e.length>0)??[];return t.length>0?t.join(`
|
|
30
30
|
`):void 0}function xd(e){return e.filter(e=>!!e).join(`
|
|
31
|
-
`)||void 0}const Sd=`logs`,Cd=`events`,wd=`network`,Td=`audio`,Ed=[`dump`,`log`],Dd=[`probe`],Od=[`start`,`status`,`stop`],kd=V(Sd,`Session app log info, start/stop streaming, diagnostics, and markers`,{action:R(gn),message:P(),restart:L()}),Ad=V(Cd,`Read the daemon-owned session event timeline as paged JSON-friendly entries`,{limit:I(),cursor:P()}),jd=V(wd,`Dump recent HTTP(s) traffic parsed from the session app log`,{action:R(Ed),limit:I(),include:R(c)}),Md=V(Td,`Measure browser or host-rendered simulator/emulator audio as compact dBFS buckets. Start a probe before requesting its status or stopping it.`,{action:R(Dd),probeAction:R(Od),durationMs:I(`Probe duration in milliseconds.`),bucketMs:I(`Audio level bucket size in milliseconds.`)}),Nd=U({name:`observability`,commands:[H({name:Sd,text:{summary:`Manage session app logs`},metadata:kd,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)=>({...y(t),action:Rd(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:_(Sd,e=>Pd(e)),cliOutputFormatter
|
|
31
|
+
`)||void 0}const Sd=`logs`,Cd=`events`,wd=`network`,Td=`audio`,Ed=[`dump`,`log`],Dd=[`probe`],Od=[`start`,`status`,`stop`],kd=V(Sd,`Session app log info, start/stop streaming, diagnostics, and markers`,{action:R(gn),message:P(),restart:L()}),Ad=V(Cd,`Read the daemon-owned session event timeline as paged JSON-friendly entries`,{limit:I(),cursor:P()}),jd=V(wd,`Dump recent HTTP(s) traffic parsed from the session app log`,{action:R(Ed),limit:I(),include:R(c)}),Md=V(Td,`Measure browser or host-rendered simulator/emulator audio as compact dBFS buckets. Start a probe before requesting its status or stopping it.`,{action:R(Dd),probeAction:R(Od),durationMs:I(`Probe duration in milliseconds.`),bucketMs:I(`Audio level bucket size in milliseconds.`)}),Nd=U({name:`observability`,commands:[H({name:Sd,text:{summary:`Manage session app logs`},metadata:kd,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)=>({...y(t),action:Rd(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:_(Sd,e=>Pd(e)),cliOutputFormatter:$u.logs}),H({name:Cd,text:{summary:`Read session event timeline`},metadata:Ad,run:(e,t)=>e.observability.events(t),cliSchema:{usageOverride:`events [limit] [cursor]`,listUsageOverride:`events`,positionalArgs:[`limit?`,`cursor?`]},cliReader:(e,t)=>({...y(t),limit:e[0]?.trim()?fr(e[0]):void 0,cursor:e[1]}),daemonWriter:e=>v(Cd,Fd(e),e),cliOutputFormatter:$u.events}),H({name:wd,text:{summary:`Inspect HTTP(S) traffic from session logs`},metadata:jd,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)=>({...y(t),action:zd(e[0]),limit:fr(e[1]),include:t.networkInclude??Bd(e[2])}),daemonWriter:e=>v(wd,Id(e),{...e,networkInclude:e.include}),cliOutputFormatter:$u.network}),H({name:Td,text:{summary:`Probe audio levels`},metadata:Md,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)=>({...y(t),action:Vd(e[0]),probeAction:Hd(e[1]),durationMs:Ud(e[2]),bucketMs:fr(e[3])}),daemonWriter:e=>v(Td,Ld(e),e),cliOutputFormatter:$u.audio})]});function Pd(e){return[e.action??`path`,...S(e.message)]}function Fd(e){return e.cursor===void 0?C(e.limit):[e.limit===void 0?``:String(e.limit),e.cursor]}function Id(e){return[...e.action?[e.action]:[],...C(e.limit)]}function Ld(e){return[e.action??`probe`,e.probeAction??`status`,...C(e.durationMs),...C(e.bucketMs)]}function Rd(e){if(e!==void 0)return qu(gn,e,{message:`logs requires path, start, stop, doctor, mark, or clear`})}function zd(e){if(e!==void 0){if(e===`dump`||e===`log`)return e;throw new r(`INVALID_ARGS`,`network requires dump or log`)}}function Bd(e){if(e!==void 0)return qu(c,e,{message:`network include must be summary, headers, body, or all`})}function Vd(e){if(e!==void 0)return qu(Dd,e,{message:`audio requires probe`})}function Hd(e){if(e!==void 0)return qu(Od,e,{message:`audio probe requires start, status, or stop`})}function Ud(e){let t=fr(e);return t===void 0?void 0:Math.round(t*1e3)}function Wd(e){let t=e;return{data:t,text:Kd(t)}}const Gd={perf:d(Wd)};function Kd(e){return $d(e)??qd(e)}function qd(e){let t=l(e.artifact)?e.artifact:void 0;return t?Qd(t):Jd(l(e.metrics)?e.metrics:void 0)}function Jd(e){return l(e?.fps)?Xd(e):Yd(e)??`Memory: unavailable - missing memory metric`}function Yd(e){let t=l(e?.memory)?e.memory:void 0;if(!t)return;if(t.available===!1)return`Memory: unavailable - ${ff(t)}`;let n=vf(t);return n?`Performance: ${n}`:`Memory: unavailable - missing memory metric`}function Xd(e){let t=l(e?.fps)?e.fps:void 0;if(!t)return df(`missing frame metric`);if(t.available===!1)return df(ff(t));let n=pf(t);return n?Zd(t,n):df(`missing dropped-frame summary`)}function Zd(e,t){let n=[`Frame health: ${t}`],r=gf(e);return r.length>0&&n.push(`Worst windows:`,...r),n.join(`
|
|
32
32
|
`)}function Qd(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?``:` (${Sf(r)})`;return n?`Memory artifact (${t}): ${n}${i}`:`Memory artifact (${t}): captured${i}`}function $d(e){return e.kind===`xctrace`?ef(e):af(e)}function ef(e){let t=typeof e.perf==`string`?e.perf:void 0,n=nf(e);if(!t||!n||e.kind!==`xctrace`)return;let r=rf(n,typeof e.mode==`string`?e.mode:`capture`,t,e.template),i=tf(e);return i.length>0?`${r}\nTop CPU self time:\n${i.join(`
|
|
33
33
|
`)}`:r}function tf(e){let t=l(e.summary)?e.summary:void 0;return Array.isArray(t?.topFunctions)?t.topFunctions.slice(0,5).flatMap(e=>{if(!l(e))return[];let t=lf(e.symbol),n=Q(e.selfSamplePercent);if(!t||n===void 0)return[];let r=lf(e.binary);return[`- ${yf(n)} ${t}${r?` (${r})`:``}`]}):[]}function nf(e){return typeof e.outPath==`string`?e.outPath:typeof e.reportPath==`string`?e.reportPath:void 0}function rf(e,t,n,r){let i=[e,`Perf ${t}: ${n}`];return typeof r==`string`&&i.push(`Template: ${r}`),i.join(`
|
|
34
34
|
`)}function af(e){let t=of(e);if(!t)return;let n=`Perf ${t.action}: ${t.kind} ${t.type}${sf(e)}${cf(e)}${uf(e)}`,r=tf(e);return r.length>0?`${n}\nTop CPU self time:\n${r.join(`
|
|
35
|
-
`)}`:n}function of(e){let t=lf(e.action),n=lf(e.kind),r=lf(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function sf(e){let t=lf(e.state);return t?` state=${t}`:``}function cf(e){let t=lf(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${Sf(n)})`}`}function lf(e){return typeof e==`string`?e:void 0}function uf(e){let t=l(e.summary)?e.summary:void 0,n=l(t?.frameHealth)?t.frameHealth:void 0;if(!n||n.available!==!0)return``;let r=Q(n.droppedFramePercent),i=Q(n.droppedFrameCount),a=Q(n.totalFrameCount);return r===void 0||i===void 0||a===void 0?``:`\nTrace frame health: dropped ${yf(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function df(e){return`Frame health: unavailable - ${e}`}function ff(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function pf(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(t!==void 0&&n!==void 0)return[`dropped ${yf(t)}`,mf(n,Q(e.totalFrameCount)),hf(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function mf(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function hf(e){return e===void 0?``:`window ${bf(e)}`}function gf(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!l(e))return[];let t=_f(e);return t?[t]:[]}):[]}function _f(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 ${bf(i)}`;return`- +${bf(t)}-+${bf(n)}: ${Math.round(r)} missed-deadline frames${a}`}function vf(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${xf(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function yf(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function bf(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 xf(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function Sf(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 Cf=`perf`,wf=U({name:`perf`,commands:[H({name:Cf,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:V(Cf,`Collect frame health, memory diagnostics, and platform profiling artifacts with compact agent-readable summaries.`,{area:N(R(
|
|
35
|
+
`)}`:n}function of(e){let t=lf(e.action),n=lf(e.kind),r=lf(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function sf(e){let t=lf(e.state);return t?` state=${t}`:``}function cf(e){let t=lf(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${Sf(n)})`}`}function lf(e){return typeof e==`string`?e:void 0}function uf(e){let t=l(e.summary)?e.summary:void 0,n=l(t?.frameHealth)?t.frameHealth:void 0;if(!n||n.available!==!0)return``;let r=Q(n.droppedFramePercent),i=Q(n.droppedFrameCount),a=Q(n.totalFrameCount);return r===void 0||i===void 0||a===void 0?``:`\nTrace frame health: dropped ${yf(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function df(e){return`Frame health: unavailable - ${e}`}function ff(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function pf(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(t!==void 0&&n!==void 0)return[`dropped ${yf(t)}`,mf(n,Q(e.totalFrameCount)),hf(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function mf(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function hf(e){return e===void 0?``:`window ${bf(e)}`}function gf(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!l(e))return[];let t=_f(e);return t?[t]:[]}):[]}function _f(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 ${bf(i)}`;return`- +${bf(t)}-+${bf(n)}: ${Math.round(r)} missed-deadline frames${a}`}function vf(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${xf(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function yf(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function bf(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 xf(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function Sf(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 Cf=`perf`,wf=U({name:`perf`,commands:[H({name:Cf,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:V(Cf,`Collect frame health, memory diagnostics, and platform profiling artifacts with compact agent-readable summaries.`,{area:N(R(xt)),subject:R(Tt),action:R(bt),kind:R(pt),template:P(`xctrace template name, for example Time Profiler.`),out:P(`Output artifact path.`),tracePath:P(`Existing .trace path to report, defaults to the latest session trace.`)}),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,12 +44,12 @@ import{E as e,N as t,O as n,P as r,S as i,_ as a,k as o,m as s,n as c}from"./sdk
|
|
|
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)=>({...y(t),...Df(e,{kind:Nf(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:_(Cf,e=>Tf(e)),cliOutputFormatter:Gd.perf})]});function Tf(e){let t=e.area;return t===`cpu`?Ef([...S(t),...S(e.subject),...S(e.action),...S(e.kind)],e):t===`trace`?Ef([...S(t),...S(e.action),...S(e.kind)],e):[...S(t),...S(e.action)]}function Ef(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 Df(e,t={}){let n=kf(e[0]);if(n===`cpu`)return{area:n,subject:jf(e[1]),action:Af(e[2]),kind:Mf(t.kind),template:t.template,out:t.out};if(n===`trace`)return{area:n,action:Af(e[1]),kind:Mf(t.kind),template:t.template,out:t.out};let r=Af(e[1]),i=Mf(t.kind);return Of(n,r,i,t.out),{area:n,action:r,kind:i,out:t.out}}function Of(e,t,n,i){if(e===`frames`){if(n!==void 0)throw new r(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(i!==void 0)throw new r(`INVALID_ARGS`,`--out is only supported with perf memory snapshot, perf cpu profile, or perf trace`)}if(e===`memory`){if(t!==`snapshot`&&n!==void 0)throw new r(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(t!==`snapshot`&&i!==void 0)throw new r(`INVALID_ARGS`,`--out is only supported with perf memory snapshot`)}}function kf(e){let t=e?.toLowerCase();if(
|
|
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)=>({...y(t),...Df(e,{kind:Nf(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:_(Cf,e=>Tf(e)),cliOutputFormatter:Gd.perf})]});function Tf(e){let t=e.area;return t===`cpu`?Ef([...S(t),...S(e.subject),...S(e.action),...S(e.kind)],e):t===`trace`?Ef([...S(t),...S(e.action),...S(e.kind)],e):[...S(t),...S(e.action)]}function Ef(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 Df(e,t={}){let n=kf(e[0]);if(n===`cpu`)return{area:n,subject:jf(e[1]),action:Af(e[2]),kind:Mf(t.kind),template:t.template,out:t.out};if(n===`trace`)return{area:n,action:Af(e[1]),kind:Mf(t.kind),template:t.template,out:t.out};let r=Af(e[1]),i=Mf(t.kind);return Of(n,r,i,t.out),{area:n,action:r,kind:i,out:t.out}}function Of(e,t,n,i){if(e===`frames`){if(n!==void 0)throw new r(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(i!==void 0)throw new r(`INVALID_ARGS`,`--out is only supported with perf memory snapshot, perf cpu profile, or perf trace`)}if(e===`memory`){if(t!==`snapshot`&&n!==void 0)throw new r(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(t!==`snapshot`&&i!==void 0)throw new r(`INVALID_ARGS`,`--out is only supported with perf memory snapshot`)}}function kf(e){let t=e?.toLowerCase();if(gt(t))throw new r(`INVALID_ARGS`,vt);if(ht(t))return t;throw new r(`INVALID_ARGS`,ft)}function Af(e){if(e===void 0)return;let t=e.toLowerCase();if(mt(t))return t;throw new r(`INVALID_ARGS`,wt)}function jf(e){let t=e?.toLowerCase();if(t!==void 0&&_t(t))return t;throw new r(`INVALID_ARGS`,yt)}function Mf(e){if(e===void 0)return;let t=e.toLowerCase();if(St(t))return t;throw new r(`INVALID_ARGS`,Ct)}function Nf(e){return typeof e==`string`?Mf(e):void 0}const Pf=`react-native`,Ff=U({name:`react-native`,commands:[H({name:Pf,text:{summary:`Run React Native automation helpers`},metadata:V(Pf,`Run supported React Native automation helpers. Use dismiss-overlay to close a visible development error overlay before continuing normal UI automation.`,{action:N(R([`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)=>({...y(t),action:If(e[0])}),daemonWriter:_(Pf,e=>[T(e.action,`react-native requires action`)])})]});function If(e){if(e===`dismiss-overlay`)return e;throw new r(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}function Lf(e){let t=e,n=typeof t.outPath==`string`?t.outPath:``,r=Bf(t);if(r.length<=1)return{data:t,text:zf(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
48
|
`)}}const Rf={record:d(Lf)};function zf(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 Bf(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 Vf=`record`,Hf=`trace`,Uf=[`start`,`stop`],Wf=V(Vf,`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:N(R(Uf)),path:P(),fps:I(),maxSize:wr(oe.migration.record),quality:R(Ue),hideTouches:L(),recordingScope:R(We)},{parseableOutput:!0}),Gf=V(Hf,`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:N(R(Uf)),path:P()}),Kf={start:[`recordingScope`,`fps`,`quality`,`hideTouches`],stop:[],"contact-sheet":[`out`]},qf={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(Kf).flat())],flagsByAction:Kf},Jf={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,positionalArgs:[`start|stop`,`path?`]},Yf=(e,t)=>({...y(t),action:np(e[0],Vf),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),Xf=(e,t)=>({...y(t),action:np(e[0],Hf),path:e[1]}),Zf=_(Vf,e=>tp(e)),Qf=e=>(ae(`record`,e),Zf(e)),$f=_(Hf,e=>tp(e)),ep=U({name:`recording`,commands:[H({name:Vf,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. The touch overlay renders at most 30 frames a second, or at --fps when lower; a lower --fps makes record stop faster on a long recording, and an overlay export that runs past its budget returns the raw video with an overlayWarning. 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:Wf,run:(e,t)=>e.recording.record(t),cliSchema:qf,cliReader:Yf,daemonWriter:Qf,cliOutputFormatter:Rf.record}),H({name:Hf,text:{summary:`Start or stop trace capture`,cliDetail:`Pass that path as the same positional argument to start and stop.`},metadata:Gf,run:(e,t)=>e.recording.trace(t),cliSchema:Jf,cliReader:Xf,daemonWriter:$f})]});function tp(e){return[e.action,...S(e.path)]}function np(e,t){if(e===`start`||e===`stop`)return e;throw new r(`INVALID_ARGS`,`${t} requires start|stop`)}const rp=2097152;async function ip(e){let t=ln(e.inputPath,{cwd:e.cwd}),n=op(t,e.inputPath);if(at(t,e.replayBackend)!==`maestro`)return ap(t,{[t]:n},e.inputPath);let{collectMaestroFlowSources:r}=await import(`./src8.js`).then(e=>e.t);return ap(t,r({entryPath:t,entrySource:n,env:e.env,readSource:sp}),e.inputPath)}function ap(e,t,n){return cp(t,n),{entry:e,files:t}}function op(e,t){try{return hn.readFileSync(e,`utf8`)}catch(n){throw new r(`INVALID_ARGS`,`replay script not found on this machine: ${t}`,{path:e,hint:`Replay scripts are read by the client and sent to the daemon, so the path must resolve where you ran the command.`},n instanceof Error?n:void 0)}}function sp(e){try{return hn.readFileSync(e,`utf8`)}catch{return}}function cp(e,t){let n=Object.values(e).reduce((e,t)=>e+Buffer.byteLength(t,`utf8`),0);if(!(n<=2097152))throw new r(`INVALID_ARGS`,`replay script sources for ${t} total ${n} bytes, over the ${rp}-byte limit; split the flow or drop unused runFlow includes.`,{limitBytes:rp,totalBytes:n})}const lp=/[*?[\]{}]/;function up(e){let t=e.replayBackend===`maestro`?new Set([`.yaml`,`.yml`,`.ad`]):new Set([`.ad`]),n=[],r=[];for(let i of e.inputs){let a=dp(i,e.cwd,t);if(a.source===`file`){n.push(...a.paths);continue}r.push(a.source===`directory`?gp(a.paths):mp(a.paths))}return gp([...n,...r.flat()])}function dp(e,t,n){let i=ln(e,{cwd:t});if(hn.existsSync(i)){let t=hn.statSync(i);return t.isDirectory()?{paths:pp(i,n),source:`directory`}:t.isFile()?(fp(e,i,n),{paths:[i],source:`file`}):{paths:[],source:`file`}}if(!_p(e))throw new r(`INVALID_ARGS`,`test input not found: ${e}`);return{source:`glob`,paths:hn.globSync(un(e),{cwd:t}).map(e=>p.isAbsolute(e)?e:p.resolve(t,e)).filter(e=>n.has(p.extname(e).toLowerCase())&&vp(e))}}function fp(e,t,n){if(!n.has(p.extname(t).toLowerCase()))throw ot(t)&&!n.has(`.yaml`)?new r(`INVALID_ARGS`,it(`test`,e)):new r(`INVALID_ARGS`,`test does not support this file type: ${e}`)}function pp(e,t){let n=[],r=hn.opendirSync(e);try{let i;for(;(i=r.readSync())!==null;){let r=p.join(e,i.name);i.isDirectory()?n.push(...pp(r,t)):i.isFile()&&t.has(p.extname(i.name).toLowerCase())&&n.push(r)}}finally{r.closeSync()}return n}function mp(e){return e.map(e=>p.normalize(e)).sort((e,t)=>{let n=hp(e)-hp(t);return n===0?e.localeCompare(t):n})}function hp(e){return+(p.extname(e).toLowerCase()===`.ad`)}function gp(e){return[...new Set(e.map(e=>p.normalize(e)))]}function _p(e){return lp.test(e)}function vp(e){try{return hn.statSync(e).isFile()}catch{return!1}}const yp=`replay`,bp=`test`,xp=V(yp,`Run a recorded automation script, including compatible Maestro YAML flows. A script without a terminal close leaves its session active for subsequent automation.`,{path:N(P()),update:L(),backend:P(),maestro:L(),env:jr(),metroHost:P(`Metro/debug host hint inherited by replay-opened sessions.`),metroPort:I(`Metro/debug port hint inherited by replay-opened sessions.`),bundleUrl:P(`Bundle URL hint inherited by replay-opened sessions.`),resumeFrom:I(),resumePlanDigest:P(),keepSession:L(`Leave the session active by suppressing exactly an authored terminal close in native .ad.`),timeoutMs:I(`Maximum wall-clock duration for the replay request.`),saveScript:z({oneOf:[j(),k()]}),force:L(),testIme:L(`Activate the headless Android test IME for the sessions this replay opens (default on for emulators; opt-in on real devices).`)}),Sp=V(bp,`Run one or more replay scripts as a serial test suite`,{paths:N(jr()),update:L(),backend:P(),maestro:L(),env:jr(),metroHost:P(`Metro/debug host hint inherited by each test session.`),metroPort:I(`Metro/debug port hint inherited by each test session.`),bundleUrl:P(`Bundle URL hint inherited by each test session.`),failFast:L(),timeoutMs:I(),retries:I(),recordVideo:L(),artifactsDir:P(),shardAll:I(),shardSplit:I(),testIme:L(`Activate the headless Android test IME for the sessions each suite attempt opens (default on for emulators; opt-in on real devices).`)}),Cp={replay:E({replayed:A(),healed:A(),session:k(),sessionActive:j(`True iff the session is still active — the script had no terminal close.`),artifactPaths:Cr(),snapshotDiagnostics:M(),message:k()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:E({total:A(),executed:A(),passed:A(),failed:A(),skipped:A(),notRun:A(),durationMs:A(),failures:{type:`array`,items:M()},tests:{type:`array`,items:M()},snapshotDiagnostics:M()},[`total`,`executed`,`passed`,`failed`,`skipped`,`notRun`,`durationMs`,`failures`,`tests`])},wp={usageOverride:`replay <path> | replay export <file.ad> [--out <path>]`,usageFlags:[],positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ii,...Ni,`replayFrom`,`replayPlanDigest`,`replayKeepSession`,`timeoutMs`,`out`,`saveScript`,`force`,`testIme`],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.`}},Tp={usageOverride:`test <path-or-glob>...`,usageFlags:[],listUsageOverride:`test <path-or-glob>...`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ii,...Ni,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`,`testIme`]},Ep=U({name:`replay`,commands:[H({name:yp,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:xp,run:(e,t)=>e.replay.run(nl(t)),cliSchema:wp,cliReader:(e,t)=>({...y(t),path:w(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,testIme:t.testIme}),daemonWriter:async e=>{let t=T(e.path,`replay requires path`),n=kp(e),r=jp(process.env);return v(yp,[t],{...e,replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:r,replayScriptSource:await ip({inputPath:t,cwd:Op(e),replayBackend:n,env:Dp(e,r)}),replayFrom:e.resumeFrom,replayPlanDigest:e.resumePlanDigest,replayKeepSession:e.keepSession,saveScript:e.saveScript})},cliOutputFormatter:f}),H({name:bp,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:Sp,run:(e,t)=>e.replay.test(nl(t)),cliSchema:Tp,cliReader:(e,t)=>({...y(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,testIme:t.testIme}),daemonWriter:async e=>{let t=e.paths??[],n=kp(e),r=Op(e),i=jp(process.env),a=Dp(e,i);return v(bp,t,{...Ap(e),replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:i,replayScriptSources:await Promise.all(up({inputs:t,cwd:r,replayBackend:n}).map(async e=>await ip({inputPath:e,cwd:r,replayBackend:n,env:a})))})}})]});function Dp(e,t){return{...rt(t),...nt(tt(e.env))}}function Op(e){return typeof e.cwd==`string`&&e.cwd.length>0?e.cwd:process.cwd()}function kp(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function Ap(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function jp(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}function Mp(e){return{data:e,text:Fp(e)}}function Np(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: ${Lp(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
|
|
50
|
-
`)}}return
|
|
49
|
+
`)}function Bf(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 Vf=`record`,Hf=`trace`,Uf=[`start`,`stop`],Wf=V(Vf,`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:N(R(Uf)),path:P(),fps:I(),maxSize:wr(oe.migration.record),quality:R(He),hideTouches:L(),recordingScope:R(Ue)},{parseableOutput:!0}),Gf=V(Hf,`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:N(R(Uf)),path:P()}),Kf={start:[`recordingScope`,`fps`,`quality`,`hideTouches`],stop:[],"contact-sheet":[`out`]},qf={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(Kf).flat())],flagsByAction:Kf},Jf={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,positionalArgs:[`start|stop`,`path?`]},Yf=(e,t)=>({...y(t),action:np(e[0],Vf),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),Xf=(e,t)=>({...y(t),action:np(e[0],Hf),path:e[1]}),Zf=_(Vf,e=>tp(e)),Qf=e=>(ae(`record`,e),Zf(e)),$f=_(Hf,e=>tp(e)),ep=U({name:`recording`,commands:[H({name:Vf,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. The touch overlay renders at most 30 frames a second, or at --fps when lower; a lower --fps makes record stop faster on a long recording, and an overlay export that runs past its budget returns the raw video with an overlayWarning. 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:Wf,run:(e,t)=>e.recording.record(t),cliSchema:qf,cliReader:Yf,daemonWriter:Qf,cliOutputFormatter:Rf.record}),H({name:Hf,text:{summary:`Start or stop trace capture`,cliDetail:`Pass that path as the same positional argument to start and stop.`},metadata:Gf,run:(e,t)=>e.recording.trace(t),cliSchema:Jf,cliReader:Xf,daemonWriter:$f})]});function tp(e){return[e.action,...S(e.path)]}function np(e,t){if(e===`start`||e===`stop`)return e;throw new r(`INVALID_ARGS`,`${t} requires start|stop`)}const rp=2097152;async function ip(e){let t=sn(e.inputPath,{cwd:e.cwd}),n=op(t,e.inputPath);if(rt(t,e.replayBackend)!==`maestro`)return ap(t,{[t]:n},e.inputPath);let{collectMaestroFlowSources:r}=await import(`./src8.js`).then(e=>e.t);return ap(t,r({entryPath:t,entrySource:n,env:e.env,readSource:sp}),e.inputPath)}function ap(e,t,n){return cp(t,n),{entry:e,files:t}}function op(e,t){try{return pn.readFileSync(e,`utf8`)}catch(n){throw new r(`INVALID_ARGS`,`replay script not found on this machine: ${t}`,{path:e,hint:`Replay scripts are read by the client and sent to the daemon, so the path must resolve where you ran the command.`},n instanceof Error?n:void 0)}}function sp(e){try{return pn.readFileSync(e,`utf8`)}catch{return}}function cp(e,t){let n=Object.values(e).reduce((e,t)=>e+Buffer.byteLength(t,`utf8`),0);if(!(n<=2097152))throw new r(`INVALID_ARGS`,`replay script sources for ${t} total ${n} bytes, over the ${rp}-byte limit; split the flow or drop unused runFlow includes.`,{limitBytes:rp,totalBytes:n})}const lp=/[*?[\]{}]/;function up(e){let t=e.replayBackend===`maestro`?new Set([`.yaml`,`.yml`,`.ad`]):new Set([`.ad`]),n=[],r=[];for(let i of e.inputs){let a=dp(i,e.cwd,t);if(a.source===`file`){n.push(...a.paths);continue}r.push(a.source===`directory`?gp(a.paths):mp(a.paths))}return gp([...n,...r.flat()])}function dp(e,t,n){let i=sn(e,{cwd:t});if(pn.existsSync(i)){let t=pn.statSync(i);return t.isDirectory()?{paths:pp(i,n),source:`directory`}:t.isFile()?(fp(e,i,n),{paths:[i],source:`file`}):{paths:[],source:`file`}}if(!_p(e))throw new r(`INVALID_ARGS`,`test input not found: ${e}`);return{source:`glob`,paths:pn.globSync(cn(e),{cwd:t}).map(e=>p.isAbsolute(e)?e:p.resolve(t,e)).filter(e=>n.has(p.extname(e).toLowerCase())&&vp(e))}}function fp(e,t,n){if(!n.has(p.extname(t).toLowerCase()))throw at(t)&&!n.has(`.yaml`)?new r(`INVALID_ARGS`,tt(`test`,e)):new r(`INVALID_ARGS`,`test does not support this file type: ${e}`)}function pp(e,t){let n=[],r=pn.opendirSync(e);try{let i;for(;(i=r.readSync())!==null;){let r=p.join(e,i.name);i.isDirectory()?n.push(...pp(r,t)):i.isFile()&&t.has(p.extname(i.name).toLowerCase())&&n.push(r)}}finally{r.closeSync()}return n}function mp(e){return e.map(e=>p.normalize(e)).sort((e,t)=>{let n=hp(e)-hp(t);return n===0?e.localeCompare(t):n})}function hp(e){return+(p.extname(e).toLowerCase()===`.ad`)}function gp(e){return[...new Set(e.map(e=>p.normalize(e)))]}function _p(e){return lp.test(e)}function vp(e){try{return pn.statSync(e).isFile()}catch{return!1}}const yp=`replay`,bp=`test`,xp=V(yp,`Run a recorded automation script, including compatible Maestro YAML flows. A script without a terminal close leaves its session active for subsequent automation.`,{path:N(P()),update:L(),backend:P(),maestro:L(),env:jr(),metroHost:P(`Metro/debug host hint inherited by replay-opened sessions.`),metroPort:I(`Metro/debug port hint inherited by replay-opened sessions.`),bundleUrl:P(`Bundle URL hint inherited by replay-opened sessions.`),resumeFrom:I(),resumePlanDigest:P(),keepSession:L(`Leave the session active by suppressing exactly an authored terminal close in native .ad.`),timeoutMs:I(`Maximum wall-clock duration for the replay request.`),saveScript:z({oneOf:[j(),k()]}),force:L(),testIme:L(`Activate the headless Android test IME for the sessions this replay opens (default on for emulators; opt-in on real devices).`)}),Sp=V(bp,`Run one or more replay scripts as a serial test suite`,{paths:N(jr()),update:L(),backend:P(),maestro:L(),env:jr(),metroHost:P(`Metro/debug host hint inherited by each test session.`),metroPort:I(`Metro/debug port hint inherited by each test session.`),bundleUrl:P(`Bundle URL hint inherited by each test session.`),failFast:L(),timeoutMs:I(),retries:I(),recordVideo:L(),artifactsDir:P(),shardAll:I(),shardSplit:I(),testIme:L(`Activate the headless Android test IME for the sessions each suite attempt opens (default on for emulators; opt-in on real devices).`)}),Cp={replay:E({replayed:A(),healed:A(),session:k(),sessionActive:j(`True iff the session is still active — the script had no terminal close.`),artifactPaths:Cr(),snapshotDiagnostics:M(),message:k()},[`replayed`,`healed`,`session`,`sessionActive`,`artifactPaths`,`message`]),test:E({total:A(),executed:A(),passed:A(),failed:A(),skipped:A(),notRun:A(),durationMs:A(),failures:{type:`array`,items:M()},tests:{type:`array`,items:M()},snapshotDiagnostics:M()},[`total`,`executed`,`passed`,`failed`,`skipped`,`notRun`,`durationMs`,`failures`,`tests`])},wp={usageOverride:`replay <path> | replay export <file.ad> [--out <path>]`,usageFlags:[],positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ii,...Ni,`replayFrom`,`replayPlanDigest`,`replayKeepSession`,`timeoutMs`,`out`,`saveScript`,`force`,`testIme`],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.`}},Tp={usageOverride:`test <path-or-glob>...`,usageFlags:[],listUsageOverride:`test <path-or-glob>...`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Ii,...Ni,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`,`testIme`]},Ep=U({name:`replay`,commands:[H({name:yp,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:xp,run:(e,t)=>e.replay.run(nl(t)),cliSchema:wp,cliReader:(e,t)=>({...y(t),path:w(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,testIme:t.testIme}),daemonWriter:async e=>{let t=T(e.path,`replay requires path`),n=kp(e),r=jp(process.env);return v(yp,[t],{...e,replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:r,replayScriptSource:await ip({inputPath:t,cwd:Op(e),replayBackend:n,env:Dp(e,r)}),replayFrom:e.resumeFrom,replayPlanDigest:e.resumePlanDigest,replayKeepSession:e.keepSession,saveScript:e.saveScript})},cliOutputFormatter:f}),H({name:bp,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:Sp,run:(e,t)=>e.replay.test(nl(t)),cliSchema:Tp,cliReader:(e,t)=>({...y(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,testIme:t.testIme}),daemonWriter:async e=>{let t=e.paths??[],n=kp(e),r=Op(e),i=jp(process.env),a=Dp(e,i);return v(bp,t,{...Ap(e),replayUpdate:e.update,replayBackend:n,replayEnv:e.env,replayShellEnv:i,replayScriptSources:await Promise.all(up({inputs:t,cwd:r,replayBackend:n}).map(async e=>await ip({inputPath:e,cwd:r,replayBackend:n,env:a})))})}})]});function Dp(e,t){return{...nt(t),...it(et(e.env))}}function Op(e){return typeof e.cwd==`string`&&e.cwd.length>0?e.cwd:process.cwd()}function kp(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function Ap(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function jp(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}function Mp(e){return{data:e,text:Fp(e)}}function Np(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: ${Lp(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
|
|
50
|
+
`)}}return kt(e)}function Pp(e){return e.action===`read`?{data:e,text:e.text}:kt(e)}const $=Bs({appstate:d(Mp),back:f,home:f,orientation:f,fold:f,"app-switcher":f,"action-button":f,keyboard:d(Np),clipboard:d(Pp),"tv-remote":f});function Fp(e){if(e.platform===`ios`)return Ip(e);if(e.platform===`android`){let t=[`Foreground app: ${e.package??`unknown`}`];return e.activity&&t.push(`Activity: ${e.activity}`),t.join(`
|
|
51
51
|
`)}return null}function Ip(e){let t=[`Session app: ${e.appName??e.appBundleId??`unknown`}`];return e.appBundleId&&t.push(`Bundle: ${e.appBundleId}`),e.state&&t.push(`State: ${e.state}`),e.source&&t.push(`Source: ${e.source}`),t.join(`
|
|
52
|
-
`)}function Lp(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 Rp=`back`,zp=`orientation`,Bp=`fold`,Vp=`keyboard`,Hp=`clipboard`,Up=`tv-remote`,Wp=[`read`,`write`],Gp=[`status`,`dismiss`,`enter`,`return`],Kp={back:E({action:O(`back`),mode:D(
|
|
52
|
+
`)}function Lp(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 Rp=`back`,zp=`orientation`,Bp=`fold`,Vp=`keyboard`,Hp=`clipboard`,Up=`tv-remote`,Wp=[`read`,`write`],Gp=[`status`,`dismiss`,`enter`,`return`],Kp={back:E({action:O(`back`),mode:D(lt),message:k()},[`action`,`mode`,`message`]),home:E({action:O(`home`),message:k()},[`action`,`message`]),orientation:E({action:O(`orientation`),orientation:D(on),message:k(),confirmed:j(),warning:k()},[`action`,`orientation`,`message`]),"app-switcher":E({action:O(`app-switcher`),message:k()},[`action`,`message`]),fold:E({action:O(`fold`),pose:D(an),hingeAngleDegrees:A(`Hinge angle CoreDevice read back after the pose settled.`),screen:E({display:k(`CoreDevice name of the panel the device now lights.`),coordinateSpace:O(Qt),widthPt:A(`Panel width in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`),heightPt:A(`Panel height in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.`)},[`display`,`coordinateSpace`,`widthPt`,`heightPt`]),message:k()},[`action`,`pose`,`hingeAngleDegrees`,`message`]),"action-button":E({action:O(`action-button`),message:k()},[`action`,`message`]),"tv-remote":E({action:O(`tv-remote`),button:D(fn),durationMs:A(),message:k()},[`action`,`button`,`message`]),clipboard:{type:`object`,oneOf:[E({action:O(`read`),text:k()},[`action`,`text`]),E({action:O(`write`),textLength:A(),message:k()},[`action`,`textLength`,`message`])]},appstate:{type:`object`,oneOf:[E({platform:D([`ios`,`macos`]),appName:k(),appBundleId:k(),source:D([`session`,`runner`],`runner when a live runner read the session app state; session when the record alone answered.`),state:D(s,`The session app XCUIApplication state as a live runner reads it; absent with source session.`),surface:D(dt),device_udid:k(`iOS only — the session device UDID.`),ios_simulator_device_set:{type:[`string`,`null`],description:`iOS only — the simulator set path, or null when unknown.`}},[`platform`,`appName`,`source`,`surface`]),E({platform:O(`android`),package:k(),activity:k()},[`platform`,`package`,`activity`])]},keyboard:E({platform:D([`android`,`ios`]),action:D([`status`,`dismiss`,`enter`]),visible:j(),wasVisible:j(),dismissed:j(),attempts:A(),inputType:k(),type:D([`text`,`number`,`email`,`phone`,`password`,`datetime`,`unknown`]),inputMethodPackage:k(),focusedPackage:k(),focusedResourceId:k(),inputOwner:D([`app`,`ime`,`unknown`]),message:k()},[`platform`,`action`])},qp={hingeEvent:`simulator HID hinge event`,permissions:`Device Hub and host Accessibility permission are not required.`,unsupportedScope:`UNSUPPORTED_OPERATION and reason unsupported-device-scope`},Jp=`Fold or unfold a foldable iPhone simulator (iPhone Duo) into the closed, half-open, or open pose, or follow timestamped angle keyframes, by sending a ${qp.hingeEvent}, 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; requires the iOS simulator SDK; ${qp.permissions} A simulator scoped to a non-default simulator set is refused with ${qp.unsupportedScope}; run fold against a simulator in the default set.`,Yp={summary:`Foldable Apple devices: panels, pose, and which screen you are on`,body:`agent-device help foldable
|
|
53
53
|
|
|
54
54
|
A foldable Apple device (iPhone Duo) carries two integrated panels, which Apple calls the outer display and the inner display. Only one is lit at a time, and which one is lit is the device pose.
|
|
55
55
|
|
|
@@ -65,4 +65,4 @@ Changing the pose:
|
|
|
65
65
|
Timed motion: fold --keyframes '[{"atMs":0,"angle":0},{"atMs":5000,"angle":180}]'. Use 2–64 frames starting at 0ms, increasing integer timestamps up to 60000ms, and angles from 0 to 180. The last timestamp sets motion duration, excluding setup and verification. Equal angles hold; cancellation stops motion. See the fold examples in the command and Node API documentation for trajectories.
|
|
66
66
|
|
|
67
67
|
Requirements: an iOS simulator session on a foldable device and an Xcode toolchain with the iOS simulator SDK and foldable HID support (verified on Xcode 27.1). ${qp.permissions} The command runs a small helper through simctl spawn for the session UDID; the helper is built once per Fold.m source hash and Xcode toolchain, cached under ~/.agent-device/fold-helper, and rebuilt only when the source or the toolchain changes. Build or dispatch failures are reported without a UI fallback. The app under test reads the resulting pose as UIHinge.status.
|
|
68
|
-
If a task asserts behavior for more than one pose, fold to each pose and re-snapshot, and report which poses the run covered.`},Xp=V(Rp,`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:R(
|
|
68
|
+
If a task asserts behavior for more than one pose, fold to each pose and re-snapshot, and report which poses the run covered.`},Xp=V(Rp,`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:R(lt),...ss(Rp)}),Zp=V(zp,`Set device orientation on iOS and Android`,{orientation:N(R(on))}),Qp={pose:R(an,`Instant preset; mutually exclusive with keyframes.`),keyframes:z({type:`array`,minItems:2,maxItems:64,description:`Piecewise-linear hinge motion. Start at 0ms; strictly increasing timestamps, up to 60000ms. Repeated angles create holds. Mutually exclusive with pose.`,items:{type:`object`,required:[`atMs`,`angle`],additionalProperties:!1,properties:{atMs:{type:`integer`,minimum:0,maximum:nn},angle:{type:`number`,minimum:0,maximum:180}}}})},$p=V(Bp,Jp,Qp,{readInput:e=>{let{pose:t,keyframes:n,...r}=zr(e,Qp);return{...r,...rn({pose:t,keyframes:n})}}}),em={...$p,inputSchema:{...$p.inputSchema,oneOf:[{required:[`pose`],not:{required:[`keyframes`]}},{required:[`keyframes`],not:{required:[`pose`]}}]}},tm=V(Vp,`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:R(Gp)}),nm=V(Hp,`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:N(R(Wp)),text:P()},{parseableOutput:!0}),rm=V(Up,`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:N(R(fn)),durationMs:I(`Press duration in milliseconds. tvOS and Vega OS use the exact hold duration; Android TV maps any positive value to an ADB longpress (${dn(`android`)}).`,{min:0})}),im={usageOverride:`back [--in-app|--system] [--settle]`,usageFlags:[],allowedFlags:[`backMode`,...cs(Rp)]},am={usageOverride:`orientation <portrait|portrait-upside-down|landscape-left|landscape-right>`,positionalArgs:[`orientation`]},om={usageOverride:`fold [${en}]`,positionalArgs:[`pose?`],allowedFlags:ki},sm={usageOverride:`keyboard [status|get|dismiss|enter|return]`,positionalArgs:[`action?`]},cm={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},lm={usageOverride:`tv-remote [press|longpress] ${ln}`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},um=(e,t)=>({...y(t),mode:t.backMode}),dm=(e,t)=>({...y(t),orientation:$t(e[0])}),fm=(e,t)=>({...y(t),...rn({pose:e[0],keyframes:t.keyframes===void 0?void 0:tn(t.keyframes)})}),pm=(e,t)=>({...y(t),...Nm(e)}),mm=(e,t)=>({...y(t),...Pm(e)}),hm=(e,t)=>({...y(t),...Fm(e,t.durationMs)}),gm=e=>v(Rp,[],{...e,backMode:jm(e.mode)}),_m=_(zp,e=>[T(e.orientation,`orientation requires orientation`)]),vm=e=>{let t=rn(e);return v(Bp,t.pose?[t.pose]:[],{...e,keyframes:t.keyframes?JSON.stringify(t.keyframes):void 0})},ym=_(Vp,e=>S(e.action)),bm=_(Hp,e=>Mm(e)),xm=_(Up,e=>[T(e.button,`tv-remote requires button`)]),Sm=ei({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}),Cm=H({name:Rp,text:{summary:`Navigate back in the app or system`},metadata:Xp,run:(e,t)=>e.command.back(t),cliSchema:im,cliReader:um,daemonWriter:gm,cliOutputFormatter:$.back}),wm=ei({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}),Tm=H({name:zp,text:{summary:`Set device orientation`},metadata:Zp,run:(e,t)=>e.command.orientation(t),cliSchema:am,cliReader:dm,daemonWriter:_m,cliOutputFormatter:$.orientation}),Em=H({name:Bp,text:{summary:`Fold or unfold a foldable iPhone simulator`,cliDetail:`iPhone Duo simulators only. Sends a ${qp.hingeEvent} and confirms the hinge angle through CoreDevice; refs and coordinates do not survive a pose change.`},metadata:em,run:(e,t)=>e.command.fold(t),cliSchema:om,cliReader:fm,daemonWriter:vm,cliOutputFormatter:$.fold}),Dm=ei({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`]}),Om=H({name:Vp,text:{summary:`Inspect, press, or dismiss the device keyboard`},metadata:tm,run:(e,t)=>e.command.keyboard(t),cliSchema:sm,cliReader:pm,daemonWriter:ym,cliOutputFormatter:$.keyboard}),km=H({name:Hp,text:{summary:`Read or write device clipboard text`},metadata:nm,run:(e,t)=>e.command.clipboard(t),cliSchema:cm,cliReader:mm,daemonWriter:bm,cliOutputFormatter:$.clipboard}),Am=U({name:`system`,commands:[Sm,Cm,wm,Tm,Em,Dm,ei({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`]}),Om,km,H({name:Up,text:{summary:`Press a TV remote/D-pad button`,cliDetail:`longpress holds for 500ms by default; --duration-ms overrides the preset.`},metadata:rm,run:(e,t)=>e.command.tvRemote(t),cliSchema:lm,cliReader:hm,daemonWriter:xm,cliOutputFormatter:$[`tv-remote`]})]});function jm(e){return e===`in-app`||e===`system`?e:void 0}function Mm(e){return e.action===`read`?[`read`]:[`write`,e.text]}function Nm(e){if(e.length>1)throw new r(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return h({action:Im(e[0])})}function Pm(e){let t=e[0]?.toLowerCase();if(t!==`read`&&t!==`write`)throw new r(`INVALID_ARGS`,`clipboard requires a subcommand: read or write.`);if(t===`read`){if(e.length!==1)throw new r(`INVALID_ARGS`,`clipboard read does not accept additional arguments.`);return{action:t}}if(e.length<2)throw new r(`INVALID_ARGS`,`clipboard write requires text.`);return{action:t,text:e.slice(1).join(` `)}}function Fm(e,t){let n=e[0]?.toLowerCase(),i=n===`press`||n===`longpress`?e.slice(1):e;if(i.length!==1)throw new r(`INVALID_ARGS`,`tv-remote requires exactly one button: ${fn.join(`, `)}.`);let a=t??(n===`longpress`?500:void 0);return h({button:un(i[0]),durationMs:a})}function Im(e){let t=e?.toLowerCase();if(t===`get`)return`status`;if(t===void 0||t===`status`||t===`dismiss`||t===`enter`||t===`return`)return t;throw new r(`INVALID_ARGS`,`keyboard action must be status, get, dismiss, enter, or return.`)}const Lm=[bc,Iu,Qo,Am,Ff,Ep,Nd,wf,rs,ep,Hu,Si];function Rm(){return Lm.flatMap(e=>[...e.metadata])}function zm(){return Lm.flatMap(e=>[...e.definitions])}function Bm(){return Wm(`cliSchemas`)}function Vm(){return Wm(`cliReaders`)}function Hm(){return Wm(`daemonWriters`)}function Um(){return Wm(`cliOutputFormatters`)}function Wm(e){let t={};for(let n of Lm){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{D as A,Cn as B,Li as C,pi as D,Mi as E,pr as F,bn as H,mr as I,zn as L,A as M,E as N,j as O,k as P,Fn as R,Vi as S,zi as T,hn as U,yn as V,yc as _,zm as a,Ho as b,Yp as c,Pu as d,vu as f,wl as g,Bl as h,Hm as i,M as j,O as k,Cp as l,Ul as m,Vm as n,Rm as o,gu as p,Bm as r,Kp as s,Um as t,Bu as u,uc as v,Ri as w,Co as x,ls as y,Sn as z};
|