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