agent-device 0.19.0 → 0.19.1

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.
Files changed (84) hide show
  1. package/README.md +5 -1
  2. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.19.0.apk → agent-device-android-multitouch-helper-0.19.1.apk} +0 -0
  3. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.1.apk.sha256 +1 -0
  4. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.19.0.manifest.json → agent-device-android-multitouch-helper-0.19.1.manifest.json} +4 -4
  5. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.19.0.apk → agent-device-android-snapshot-helper-0.19.1.apk} +0 -0
  6. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.1.apk.sha256 +1 -0
  7. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.19.0.manifest.json → agent-device-android-snapshot-helper-0.19.1.manifest.json} +6 -6
  8. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +24 -7
  9. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +506 -119
  10. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +153 -48
  11. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +172 -0
  12. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +76 -5
  13. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +60 -52
  14. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +159 -56
  15. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +142 -0
  16. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +16 -14
  17. package/dist/src/android-adb.d.ts +1 -2
  18. package/dist/src/android-adb.js +1 -1
  19. package/dist/src/android-input-ownership.js +6 -0
  20. package/dist/src/android.js +1 -1
  21. package/dist/src/app-lifecycle.js +3 -3
  22. package/dist/src/apple-runner-options.js +1 -1
  23. package/dist/src/apps.js +5 -5
  24. package/dist/src/cli-help.js +131 -34
  25. package/dist/src/cli-runner.js +1 -1
  26. package/dist/src/cli.js +11 -11
  27. package/dist/src/client.js +2 -2
  28. package/dist/src/command-metadata.js +1 -1
  29. package/dist/src/command-schema.js +3 -3
  30. package/dist/src/device-input-state.js +2 -2
  31. package/dist/src/devices2.js +1 -1
  32. package/dist/src/find.js +1 -1
  33. package/dist/src/generic.js +1 -1
  34. package/dist/src/index.d.ts +199 -20
  35. package/dist/src/input-actions.js +3 -3
  36. package/dist/src/interaction-snapshot.js +1 -1
  37. package/dist/src/interaction.js +1 -1
  38. package/dist/src/interactor.js +2 -2
  39. package/dist/src/internal/bin.js +1 -1
  40. package/dist/src/internal/daemon.js +17 -15
  41. package/dist/src/lease.js +1 -1
  42. package/dist/src/linux.js +1 -1
  43. package/dist/src/metro.d.ts +0 -1
  44. package/dist/src/notifications.js +1 -1
  45. package/dist/src/points.js +1 -1
  46. package/dist/src/project-runtime.js +1 -1
  47. package/dist/src/providers.js +1 -1
  48. package/dist/src/react-native.js +1 -1
  49. package/dist/src/record-trace-recording.js +2 -2
  50. package/dist/src/record-trace.js +1 -1
  51. package/dist/src/registry.js +24 -23
  52. package/dist/src/reporting.js +3 -3
  53. package/dist/src/runner-client.js +1 -1
  54. package/dist/src/runtime.js +2 -2
  55. package/dist/src/sdk-android-adb.d.ts +2 -2
  56. package/dist/src/sdk-batch-runner.d.ts +0 -1
  57. package/dist/src/sdk-batch.js +2 -2
  58. package/dist/src/sdk-finders.d.ts +1 -2
  59. package/dist/src/sdk-finders.js +1 -1
  60. package/dist/src/sdk-io.d.ts +0 -1
  61. package/dist/src/sdk-remote-config.d.ts +1 -2
  62. package/dist/src/sdk-remote-config.js +1 -1
  63. package/dist/src/sdk-selectors.js +1 -1
  64. package/dist/src/selector-runtime.js +1 -1
  65. package/dist/src/selectors.d.ts +0 -1
  66. package/dist/src/selectors.js +1 -1
  67. package/dist/src/selectors2.js +1 -1
  68. package/dist/src/server.js +3 -3
  69. package/dist/src/session.js +10 -10
  70. package/dist/src/simctl.js +1 -1
  71. package/dist/src/simulator.js +1 -1
  72. package/dist/src/snapshot-diagnostics.js +2 -2
  73. package/dist/src/snapshot-helper.js +4 -4
  74. package/dist/src/snapshot-quality.js +1 -1
  75. package/dist/src/snapshot2.js +2 -2
  76. package/dist/src/tv-remote.js +14 -0
  77. package/dist/src/web.js +1 -1
  78. package/package.json +5 -4
  79. package/server.json +2 -2
  80. package/skills/agent-device/SKILL.md +8 -7
  81. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.0.apk.sha256 +0 -1
  82. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.0.apk.sha256 +0 -1
  83. package/dist/src/device-rotation.js +0 -14
  84. package/dist/src/logcat.js +0 -6
@@ -1,24 +1,25 @@
1
- import{F as e,d as t,f as n,g as r,l as i,n as a,s as o,t as s}from"./sdk-contracts.js";import{C as c,d as ee,h as te,o as ne,r as re,u as ie,v as ae,w as l,x as oe,y as se}from"./sdk-batch.js";import{$ as ce,$t as le,An as ue,At as de,Bt as fe,Dt as pe,Ft as me,In as he,Jt as ge,Lt as _e,Mt as ve,Nt as ye,Pt as be,Q as xe,Qt as Se,Rt as Ce,Ut as we,Vt as Te,Wt as Ee,Yt as De,Z as Oe,c as ke,en as Ae,hn as je,i as Me,in as Ne,jn as Pe,jt as Fe,kn as Ie,kt as Le,l as Re,ln as ze,mn as Be,mt as Ve,n as He,nn as Ue,o as We,pn as Ge,qt as Ke,rn as qe,s as Je,t as Ye,tn as Xe,u as Ze,un as Qe,ut as $e,vt as et,wn as tt,wt as nt,xn as rt,xt as it,zt as at}from"./device-rotation.js";import{R as ot,n as st,o as ct,r as lt}from"./sdk-selectors.js";import{_ as ut,a as dt,b as ft,c as pt,f as mt,g as ht,h as gt,i as _t,l as u,m as d,o as vt,p as yt,r as bt,s as xt,v as St}from"./sdk-batch-runner.js";import{n as Ct}from"./sdk-finders.js";import{n as wt,t as Tt}from"./sdk-app-inventory.js";let Et=!1;function Dt(){Et=!0}function Ot(){let e=Et;return Et=!1,e}const kt=[`ref`,`selector`,`point`];function At(e,t=[]){return{type:`object`,properties:{...gn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function jt(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function Mt(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function Nt(e){return{type:`string`,...e?{description:e}:{}}}function Pt(e){return{type:`number`,...e?{description:e}:{}}}function Ft(e){return{type:`integer`,...e?{description:e}:{}}}function It(e){return{type:`boolean`,...e?{description:e}:{}}}function Lt(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function Rt(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function f(e){return{...e,required:!0}}function p(e){return T(Nt(e),b)}function m(e){return T(Pt(e),tn)}function h(e,t={}){return T(dn(e,t),(e,n)=>S(e,n,t))}function g(e){return T(It(e),nn)}function _(e,t){return T(Mt(e,t),(t,n)=>an(t,n,e))}function zt(e){return T(Rt(e),mn)}function Bt(e){return T(Lt(e),hn)}function v(e){return T(e,(e,t)=>e[t])}function Vt(e,t){return T(e,t)}function Ht(){return T(_n(),(e,t)=>e[t]===void 0?void 0:Qt(e,t))}function Ut(){return T(vn(),(e,t)=>e[t]===void 0?void 0:$t(e,t))}function Wt(e){return T(jt(e),(e,t)=>e[t]===void 0?void 0:y(e,t))}function Gt(){return{depth:h(`Snapshot traversal depth.`,{min:0}),scope:p(`Snapshot scope selector used before resolution.`),raw:g(`Use raw snapshot data during selector resolution.`)}}function Kt(){return{count:h(`Number of press/click repetitions.`,{min:1}),intervalMs:h(`Delay between repeated press/click actions.`,{min:0}),holdMs:h(`Hold duration for each action.`,{min:0}),jitterPx:h(`Randomization radius in pixels.`,{min:0}),doubleTap:g(`Request a double-tap action.`)}}function qt(e){return At(fn(e),pn(e))}function Jt(t,n){let r=Yt(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=Xt(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return w({...a,...C(a),...i})}function Yt(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}function Xt(e,t={}){return{session:b(e,`session`),platform:an(e,`platform`,i),deviceTarget:Zt(e,t),device:b(e,`device`),udid:b(e,`udid`),serial:b(e,`serial`),iosSimulatorDeviceSet:b(e,`iosSimulatorDeviceSet`),iosXctestrunFile:b(e,`iosXctestrunFile`),iosXctestDerivedDataPath:b(e,`iosXctestDerivedDataPath`),iosXctestEnvDir:b(e,`iosXctestEnvDir`),androidDeviceAllowlist:b(e,`androidDeviceAllowlist`),daemonBaseUrl:b(e,`daemonBaseUrl`),daemonAuthToken:b(e,`daemonAuthToken`),tenant:b(e,`tenant`),runId:b(e,`runId`),leaseId:b(e,`leaseId`),cwd:b(e,`cwd`),debug:nn(e,`debug`)}}function Zt(t,n){let r=an(t,`deviceTarget`,o);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=an(t,`target`,o);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 Qt(e,t){let n=bn(e,t),r=rn(n,`kind`,kt);switch(r){case`ref`:return{kind:r,ref:en(n,`ref`),label:b(n,`label`)};case`selector`:return{kind:r,selector:en(n,`selector`)};case`point`:return{kind:r,x:x(n,`x`),y:x(n,`y`)}}}function $t(e,t){let n=bn(e,t),r=rn(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:en(n,`ref`),label:b(n,`label`)}:{kind:r,selector:en(n,`selector`)}}function y(e,t){let n=bn(e,t);return{x:x(n,`x`),y:x(n,`y`)}}function en(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 b(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 x(t,n){let r=t[n];if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}function tn(t,n){let r=t[n];if(r!==void 0){if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}}function S(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function nn(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 rn(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 an(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 C(e){return w({session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function on(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector};case`point`:return{x:e.x,y:e.y}}}function sn(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function cn(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function ln(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function un(t,n,r){let i=new Set(n),a=Object.keys(t).filter(e=>!i.has(e));if(a.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${a.join(`, `)}.`)}function w(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function T(e,t){return{schema:e,required:!1,read:t}}function dn(e,t){return{...Ft(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function fn(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.schema]))}function pn(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function mn(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 hn(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 gn(){return{session:{type:`string`,description:`Agent-device session name.`},platform:{type:`string`,enum:i,description:`Platform selector used to resolve a device.`},deviceTarget:{type:`string`,enum:o,description:`Device target form. Maps to the CLI --target flag.`},target:{type:`string`,enum:o,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`},device:{type:`string`,description:`Device name selector.`},udid:{type:`string`,description:`iOS device UDID selector.`},serial:{type:`string`,description:`Android serial selector.`},iosSimulatorDeviceSet:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},iosXctestrunFile:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},iosXctestDerivedDataPath:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},iosXctestEnvDir:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},androidDeviceAllowlist:{type:`string`,description:`Android serial allowlist used for device resolution.`},daemonBaseUrl:{type:`string`,description:`Remote daemon base URL.`},daemonAuthToken:{type:`string`,description:`Remote daemon auth token.`},tenant:{type:`string`,description:`Remote tenant identifier.`},runId:{type:`string`,description:`Lease run identifier.`},leaseId:{type:`string`,description:`Existing lease identifier.`},cwd:{type:`string`,description:`Working directory for command execution.`},debug:{type:`boolean`,description:`Enable debug diagnostics.`}}}function _n(){return{oneOf:[...yn(),{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 vn(){return{oneOf:yn(),description:`UI element target by snapshot ref or selector expression.`}}function yn(){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 bn(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 E(e,t){return n=>D(e,t?t(n):[],n)}function D(e,t,n){return{command:e,positionals:t,options:xn(n)}}function xn(e){let t=Sn(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 Sn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function O(e){return w({session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist})}function Cn(e){return{platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function wn(e){return w({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function Tn(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function En(e){return w({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Dn(e){return w({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function On(e){if(`ref`in e&&e.ref!==void 0)return w({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 kn(t){let n=jn(t);if(typeof n.ref==`string`)return[n.ref,...Nn(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(Mn(n.x,`x`)),String(Mn(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function An(t){let n=jn(t);if(typeof n.ref==`string`)return[n.ref,...Nn(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function jn(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 Mn(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function Nn(e){return typeof e==`string`&&e.length>0?[e]:[]}function Pn(t){if(t[0]?.startsWith(`@`))return{ref:t[0],label:Rn(t.slice(1))};let n=t.join(` `).trim();if(!n)throw new e(`INVALID_ARGS`,`get requires @ref or selector expression`);return{selector:n}}function Fn(t){if(t===`text`||t===`attrs`)return t;throw new e(`INVALID_ARGS`,`get only supports text or attrs`)}function In(t,n={}){let r=ae(t,n);if(!r)throw new e(`INVALID_ARGS`,`is requires a selector expression`);return r}function Ln(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 Rn(e){return e.join(` `).trim()||void 0}function k(...e){return new Set(e)}function A(e,t){return e!==void 0&&t.has(e)}function zn(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function Bn(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 j(e){return e===void 0?void 0:Number(e)}function M(e){return e===void 0?[]:[e]}function N(e){return e===void 0?[]:[String(e)]}function P(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function F(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function I(e){return e}function L(e){let t={},n={},r={},i={};for(let a of e.commands){if(a.cliSchema&&Vn(t,`CLI schema`,a.name,a.cliSchema),Vn(n,`CLI reader`,a.name,a.cliReader),a.daemonWriter&&Vn(r,`daemon writer`,a.name,a.daemonWriter),a.extraDaemonWriters)for(let[e,t]of Object.entries(a.extraDaemonWriters))Vn(r,`daemon writer`,e,t);a.cliOutputFormatter&&Vn(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 Vn(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function Hn(e){return e}function R(e,t){return{...e,run:t,invoke:async(n,r)=>await t(n,e.readInput(r))}}function z(e){return({result:t})=>e(t)}const B=z(V);function V(e){return{data:e,text:je(e)}}function Un(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(Gn(n));return{data:e,text:t.join(`
2
- `)}}const Wn={batch:z(Un)};function Gn(e){let t=je(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function Kn(e=re){let t=qn(e);return Hn({name:`batch`,description:`Run multiple structured command steps in one daemon request.`,inputSchema:qt(t),readInput:e=>Yn(e,t)})}function qn(e){return{steps:f(Vt({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:Jn(e)},(t,n)=>Xn(t[n],e))),onError:_([`stop`],`Batch failure policy.`),maxSteps:h(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:p(`Optional output path for command artifacts.`)}}function Jn(e){return{type:`object`,properties:{command:{type:`string`,enum:e,description:`Command name to run with structured input.`},input:{type:`object`,additionalProperties:!0,description:`Structured command input for the nested command. Use the matching MCP tool schema for this object.`},runtime:{type:`object`,additionalProperties:!0,description:`Optional per-step runtime payload.`}},required:[`command`,`input`],additionalProperties:!1}}function Yn(t,n){let r=Jt(t,n),i=r.maxSteps??100;if(!_t(i))throw new e(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(r.maxSteps)}`);return bt(r.steps.length,i),{...r}}function Xn(t,n){if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected steps to be an array.`);return t.map((e,t)=>Zn(e,t+1,n))}function Zn(e,t,n){let r=xt(e,t);return un(r,[`command`,`input`,`runtime`],`Batch step ${t}`),{command:Qn(r,t,n),input:vt(r,t),...$n(r,t)}}function Qn(t,n,r){if(r===re)return ne(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 $n(e,t){let n=dt(e.runtime,t);return n===void 0?{}:{runtime:n}}function er(e,t){let n=d(e,`bundleId`),r=d(e,`package`);return{app:St(e,`app`),appPath:St(e,`appPath`),platform:ut(e,`platform`),appId:n??r,bundleId:n,package:r,identifiers:ge({session:t,bundleId:n,packageName:r})}}function tr(t,n){let r=d(t,`bundleId`),i=d(t,`packageName`),a=r??i??d(t,`appId`),o=d(t,`launchTarget`)??i??r??a;if(!o)throw new e(`COMMAND_FAILED`,`Daemon response is missing "launchTarget".`,{response:t});return{appName:d(t,`appName`),appId:a,bundleId:r,packageName:i,launchTarget:o,installablePath:d(t,`installablePath`),archivePath:d(t,`archivePath`),materializationId:d(t,`materializationId`),materializationExpiresAt:d(t,`materializationExpiresAt`),identifiers:ge({session:n,bundleId:r,packageName:i,appId:a})}}function nr(e){return{released:e.released===!0,materializationId:St(e,`materializationId`),identifiers:{}}}function rr(e){let{record:t,platform:r,id:i,name:a,target:o}=or(e,`name`),s=ar(t);return{platform:r,target:o,kind:gt(t,`kind`),id:i,name:a,booted:typeof t.booted==`boolean`?t.booted:void 0,...n(r)&&s?{appleOs:s}:{},identifiers:De(r,i,a),...sr(r,i)}}function ir(e){let{record:t,platform:n,id:r,name:i,target:a}=or(e,`name`),o=St(t,`device`),s=ar(t),c={session:i,...De(n,r,o)};return{name:i,createdAt:ht(t,`createdAt`),sessionStateDir:d(t,`sessionStateDir`),runnerLogPath:d(t,`runnerLogPath`),device:{platform:n,target:a,id:r,name:o,...s?{appleOs:s}:{},identifiers:c,...sr(n,r,yt(t,`ios_simulator_device_set`))},identifiers:c}}function ar(e){let n=e.appleOs;return t(n)?n:void 0}function or(e,t){let n=pt(e);return{record:n,platform:ut(n,`platform`),id:St(n,`id`),name:St(n,t),target:mt(n,`target`)}}function sr(e,t,n){return{ios:e===`ios`?{udid:t,...n===void 0?{}:{simulatorSetPath:n}}:void 0,android:e===`android`?{serial:t}:void 0}}function cr(e){if(!u(e))return;let t=e.platform,n=d(e,`metroHost`),r=typeof e.metroPort==`number`?e.metroPort:void 0,i=d(e,`bundleUrl`),a=d(e,`launchUrl`);return{platform:t===`ios`||t===`android`?t:void 0,metroHost:n,metroPort:r,bundleUrl:i,launchUrl:a}}function lr(e){let t=e.platform,n=d(e,`id`),i=d(e,`device`);if(!(!r(t)||!n||!i))return{platform:t,target:mt(e,`target`),id:n,name:i,identifiers:De(t,n,i),ios:t===`ios`?{udid:d(e,`device_udid`)??n,simulatorSetPath:yt(e,`ios_simulator_device_set`)}:void 0,android:t===`android`?{serial:d(e,`serial`)??n}:void 0}}function ur(e){if(u(e)&&!(typeof e.durationMs!=`number`||typeof e.measuredAt!=`string`||typeof e.method!=`string`))return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:d(e,`appTarget`),appBundleId:d(e,`appBundleId`)}}function dr(e){if(!u(e)||typeof e.success!=`boolean`||typeof e.exitCode!=`number`||typeof e.stdout!=`string`||typeof e.stderr!=`string`)return;let t=fr(e.error);return{success:e.success,exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,...t?{error:t}:{}}}function fr(e){if(u(e)&&!(typeof e.code!=`string`||typeof e.message!=`string`))return{code:e.code,message:e.message,...typeof e.hint==`string`?{hint:e.hint}:{},...typeof e.diagnosticId==`string`?{diagnosticId:e.diagnosticId}:{},...typeof e.logPath==`string`?{logPath:e.logPath}:{},...u(e.details)?{details:e.details}:{}}}function pr(e){return Array.isArray(e)?e:[]}function mr(e){let t=rt(e);return ft({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...tt(t),provider:e.provider,providerSessionId:e.providerSessionId,providerApp:e.providerApp,providerOsVersion:e.providerOsVersion,providerProject:e.providerProject,providerBuild:e.providerBuild,providerSessionName:e.providerSessionName,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,noRecord:e.noRecord,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotForceFull:e.forceFull,...Ge(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,screenshotMaxSize:e.maxSize,quality:e.quality,hideTouches:e.hideTouches,intervalMs:e.intervalMs,delayMs:e.delayMs,durationMs:e.durationMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,verify:e.verify,settle:e.settle,settleQuietMs:e.settleQuietMs,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,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 hr(e){let t=rt(e);return ft({requestId:e.requestId,cwd:e.cwd,sessionExplicit:e.session!==void 0,debug:e.debug,includeCost:e.cost,responseLevel:e.responseLevel,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,...Ie(t),sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function gr(e){return e??`default`}function H(...e){return e}const _r=H(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),U=H(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),vr=H(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),yr=H(`metroHost`,`metroPort`,`bundleUrl`),br=H(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),xr=H(`settle`,`settleQuietMs`,`timeoutMs`),Sr=H(`replayUpdate`,`replayEnv`),Cr=[{key:`config`,names:[`--config`],type:`string`,usageLabel:`--config <path>`,usageDescription:`Load CLI defaults from a specific config file`},{key:`remoteConfig`,names:[`--remote-config`],type:`string`,usageLabel:`--remote-config <path>`,usageDescription:`Load remote host + Metro workflow settings from a specific profile file`},{key:`stateDir`,names:[`--state-dir`],type:`string`,usageLabel:`--state-dir <path>`,usageDescription:`Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)`},{key:`daemonBaseUrl`,names:[`--daemon-base-url`],type:`string`,usageLabel:`--daemon-base-url <url>`,usageDescription:`Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)`},{key:`daemonAuthToken`,names:[`--daemon-auth-token`],type:`string`,usageLabel:`--daemon-auth-token <token>`,usageDescription:`Remote HTTP daemon or proxy auth token (sent as request token and bearer header)`},{key:`daemonTransport`,names:[`--daemon-transport`],type:`enum`,enumValues:[`auto`,`socket`,`http`],usageLabel:`--daemon-transport auto|socket|http`,usageDescription:`Daemon client transport preference`},{key:`daemonServerMode`,names:[`--daemon-server-mode`],type:`enum`,enumValues:[`socket`,`http`,`dual`],usageLabel:`--daemon-server-mode socket|http|dual`,usageDescription:`Daemon server mode used when spawning daemon`},{key:`proxyHost`,names:[`--host`],type:`string`,usageLabel:`--host <host>`,usageDescription:`Proxy: host interface to bind (default: 127.0.0.1)`},{key:`proxyPort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`Proxy: TCP port to bind (default: 0, choose a free port)`},{key:`tenant`,names:[`--tenant`],type:`string`,usageLabel:`--tenant <id>`,usageDescription:`Tenant scope identifier for isolated daemon sessions`},{key:`sessionIsolation`,names:[`--session-isolation`],type:`enum`,enumValues:[`none`,`tenant`],usageLabel:`--session-isolation none|tenant`,usageDescription:`Session isolation strategy (tenant prefixes session namespace)`},{key:`runId`,names:[`--run-id`],type:`string`,usageLabel:`--run-id <id>`,usageDescription:`Run identifier used for tenant lease admission checks`},{key:`leaseId`,names:[`--lease-id`],type:`string`,usageLabel:`--lease-id <id>`,usageDescription:`Lease identifier bound to tenant/run admission scope`},{key:`leaseBackend`,names:[`--lease-backend`],type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`],usageLabel:`--lease-backend ios-simulator|ios-instance|android-instance`,usageDescription:`Lease backend for remote tenant connection admission`},{key:`provider`,names:[`--provider`],type:`string`,usageLabel:`--provider <name>`,usageDescription:`Cloud provider name for provider-scoped commands`},{key:`providerSessionId`,names:[`--provider-session`],type:`string`,usageLabel:`--provider-session <id>`,usageDescription:`Cloud provider session id or ARN`},{key:`providerApp`,names:[`--provider-app`],type:`string`,usageLabel:`--provider-app <ref-or-path>`,usageDescription:`Cloud provider app reference or local app path used when creating hosted WebDriver sessions`},{key:`providerOsVersion`,names:[`--provider-os-version`,`--os-version`],type:`string`,usageLabel:`--provider-os-version <version>`,usageDescription:`Hosted cloud provider OS version, for example 17 or 14.0`},{key:`providerProject`,names:[`--provider-project`],type:`string`,usageLabel:`--provider-project <name>`,usageDescription:`Hosted cloud provider project label`},{key:`providerBuild`,names:[`--provider-build`],type:`string`,usageLabel:`--provider-build <name>`,usageDescription:`Hosted cloud provider build label`},{key:`providerSessionName`,names:[`--provider-session-name`],type:`string`,usageLabel:`--provider-session-name <name>`,usageDescription:`Hosted cloud provider session label`},{key:`awsProjectArn`,names:[`--aws-project-arn`],type:`string`,usageLabel:`--aws-project-arn <arn>`,usageDescription:`AWS Device Farm project ARN for hosted WebDriver sessions`},{key:`awsDeviceArn`,names:[`--aws-device-arn`],type:`string`,usageLabel:`--aws-device-arn <arn>`,usageDescription:`AWS Device Farm device ARN for hosted WebDriver sessions`},{key:`awsAppArn`,names:[`--aws-app-arn`],type:`string`,usageLabel:`--aws-app-arn <arn>`,usageDescription:`AWS Device Farm app ARN attached to hosted remote access sessions`},{key:`awsRegion`,names:[`--aws-region`],type:`string`,usageLabel:`--aws-region <region>`,usageDescription:`AWS region for Device Farm API calls`},{key:`awsInteractionMode`,names:[`--aws-interaction-mode`],type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`],usageLabel:`--aws-interaction-mode INTERACTIVE|NO_VIDEO|VIDEO_ONLY`,usageDescription:`AWS Device Farm remote access interaction mode`},{key:`force`,names:[`--force`],type:`boolean`,usageLabel:`--force`,usageDescription:`Force connection state replacement when reconnecting`},{key:`noLogin`,names:[`--no-login`],type:`boolean`,usageLabel:`--no-login`,usageDescription:`Connect: fail instead of starting implicit cloud login`},{key:`sessionLock`,names:[`--session-lock`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock reject|strip`,usageDescription:`Lock bound-session device routing for this CLI invocation and nested batch steps`},{key:`sessionLocked`,names:[`--session-locked`],type:`boolean`,usageLabel:`--session-locked`,usageDescription:`Deprecated alias for --session-lock reject`},{key:`sessionLockConflicts`,names:[`--session-lock-conflicts`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock-conflicts reject|strip`,usageDescription:`Deprecated alias for --session-lock`},{key:`platform`,names:[`--platform`],type:`enum`,enumValues:i,usageLabel:`--platform ${i.join(`|`)}`,usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:`target`,names:[`--target`],type:`enum`,enumValues:[`mobile`,`tv`,`desktop`],usageLabel:`--target mobile|tv|desktop`,usageDescription:`Device target class to match`},{key:`device`,names:[`--device`],type:`string`,usageLabel:`--device <name>`,usageDescription:`Device name to target`},{key:`udid`,names:[`--udid`],type:`string`,usageLabel:`--udid <udid>`,usageDescription:`iOS device UDID`},{key:`serial`,names:[`--serial`],type:`string`,usageLabel:`--serial <serial>`,usageDescription:`Android device serial`},{key:`surface`,names:[`--surface`],type:`enum`,enumValues:Ee,usageLabel:`--surface app|frontmost-app|desktop|menubar`,usageDescription:`macOS session surface for open (defaults to app)`},{key:`headless`,names:[`--headless`],type:`boolean`,usageLabel:`--headless`,usageDescription:`Boot: launch Android emulator without a GUI window`},{key:`targetApp`,names:[`--app`,`--target-app`],type:`string`,usageLabel:`--app <id-or-name>`,usageDescription:`Doctor: verify an installed target app without opening a session`},{key:`metroHost`,names:[`--metro-host`],type:`string`,usageLabel:`--metro-host <host>`,usageDescription:`Session-scoped Metro/debug host hint`},{key:`metroPort`,names:[`--metro-port`],type:`int`,min:1,max:65535,usageLabel:`--metro-port <port>`,usageDescription:`Session-scoped Metro/debug port hint`},{key:`metroProjectRoot`,names:[`--project-root`],type:`string`,usageLabel:`--project-root <path>`,usageDescription:`metro prepare: React Native project root (default: cwd)`},{key:`kind`,names:[`--kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,...me],usageLabel:`--kind <kind>`,usageDescription:`Kind selector for commands that support it, such as metro prepare or perf artifact collectors`},{key:`perfTemplate`,names:[`--template`],type:`string`,usageLabel:`--template <name>`,usageDescription:`Perf xctrace template name, for example Time Profiler`},{key:`metroKind`,names:[`--metro-kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`],usageLabel:`--metro-kind auto|react-native|expo`,usageDescription:`metro prepare: detect or force the Metro launcher kind`},{key:`metroPublicBaseUrl`,names:[`--public-base-url`],type:`string`,usageLabel:`--public-base-url <url>`,usageDescription:`metro prepare: public base URL used for direct bundle hints`},{key:`metroProxyBaseUrl`,names:[`--proxy-base-url`],type:`string`,usageLabel:`--proxy-base-url <url>`,usageDescription:`metro prepare: optional bridge origin for remote Metro access`},{key:`metroBearerToken`,names:[`--bearer-token`],type:`string`,usageLabel:`--bearer-token <token>`,usageDescription:`metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)`},{key:`metroPreparePort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`metro prepare: local Metro port (default: 8081)`},{key:`metroListenHost`,names:[`--listen-host`],type:`string`,usageLabel:`--listen-host <host>`,usageDescription:`metro prepare: host Metro listens on (default: 0.0.0.0)`},{key:`metroStatusHost`,names:[`--status-host`],type:`string`,usageLabel:`--status-host <host>`,usageDescription:`metro prepare: host used for local /status polling (default: 127.0.0.1)`},{key:`metroStartupTimeoutMs`,names:[`--startup-timeout-ms`],type:`int`,min:1,usageLabel:`--startup-timeout-ms <ms>`,usageDescription:`metro prepare: timeout while waiting for Metro to become ready`},{key:`metroProbeTimeoutMs`,names:[`--probe-timeout-ms`],type:`int`,min:1,usageLabel:`--probe-timeout-ms <ms>`,usageDescription:`metro prepare: timeout for /status and proxy bridge calls`},{key:`metroRuntimeFile`,names:[`--runtime-file`],type:`string`,usageLabel:`--runtime-file <path>`,usageDescription:`metro prepare: optional file path to persist the JSON result`},{key:`metroNoReuseExisting`,names:[`--no-reuse-existing`],type:`boolean`,usageLabel:`--no-reuse-existing`,usageDescription:`metro prepare: always start a fresh Metro process`},{key:`metroNoInstallDeps`,names:[`--no-install-deps`],type:`boolean`,usageLabel:`--no-install-deps`,usageDescription:`metro prepare: skip package-manager install when node_modules is missing`},{key:`bundleUrl`,names:[`--bundle-url`],type:`string`,usageLabel:`--bundle-url <url>`,usageDescription:`Session-scoped bundle URL hint`},{key:`launchUrl`,names:[`--launch-url`],type:`string`,usageLabel:`--launch-url <url>`,usageDescription:`Session-scoped deep link / launch URL hint`},{key:`iosSimulatorDeviceSet`,names:[`--ios-simulator-device-set`],type:`string`,usageLabel:`--ios-simulator-device-set <path>`,usageDescription:`Scope iOS simulator discovery/commands to this simulator device set`},{key:`iosXctestrunFile`,names:[`--ios-xctestrun-file`],type:`string`,usageLabel:`--ios-xctestrun-file <path>`,usageDescription:`Use an externally built iOS XCTest runner .xctestrun artifact`},{key:`iosXctestDerivedDataPath`,names:[`--ios-xctest-derived-data-path`],type:`string`,usageLabel:`--ios-xctest-derived-data-path <path>`,usageDescription:`Derived data path for external iOS XCTest runner execution`},{key:`iosXctestEnvDir`,names:[`--ios-xctest-env-dir`],type:`string`,usageLabel:`--ios-xctest-env-dir <path>`,usageDescription:`Writable directory for per-session iOS XCTest runner env overlays`},{key:`deviceHub`,names:[`--device-hub`],type:`boolean`,usageLabel:`--device-hub`,usageDescription:`open: use Xcode Device Hub when surfacing Apple simulators`},{key:`androidDeviceAllowlist`,names:[`--android-device-allowlist`],type:`string`,usageLabel:`--android-device-allowlist <serials>`,usageDescription:`Comma/space separated Android serial allowlist for discovery/selection`},{key:`remote`,names:[`--remote`],type:`boolean`,usageLabel:`--remote`,usageDescription:`Doctor: check remote connection setup instead of local device inventory`},{key:`activity`,names:[`--activity`],type:`string`,usageLabel:`--activity <component>`,usageDescription:`Android app launch activity (package/Activity); not for URL opens`},{key:`launchConsole`,names:[`--launch-console`],type:`string`,usageLabel:`--launch-console <path>`,usageDescription:`open: capture the initial iOS simulator launch console window to a file`},{key:`launchArgs`,names:[`--launch-args`],type:`string`,multiple:!0,usageLabel:`--launch-args <arg>`,usageDescription:`open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag.`},{key:`header`,names:[`--header`],type:`string`,multiple:!0,usageLabel:`--header <name:value>`,usageDescription:`install-from-source: repeatable HTTP header for URL downloads`},{key:`githubActionsArtifact`,names:[`--github-actions-artifact`],type:`string`,usageLabel:`--github-actions-artifact <owner/repo:artifact>`,usageDescription:`install-from-source: GitHub Actions artifact resolved by a remote daemon`},{key:`installSource`,names:[],type:`string`},{key:`session`,names:[`--session`],type:`string`,usageLabel:`--session <name>`,usageDescription:`Named session`},{key:`count`,names:[`--count`],type:`int`,min:1,max:200,usageLabel:`--count <n>`,usageDescription:`Repeat count for press/swipe series`},{key:`fps`,names:[`--fps`],type:`int`,min:1,max:120,usageLabel:`--fps <n>`,usageDescription:`Record: target frames per second (iOS physical device runner)`},{key:`quality`,names:[`--quality`],type:`string`,usageLabel:`--quality <medium|high>`,usageDescription:`Record: output quality preset; Android maps this to screenrecord bitrate, Apple targets use it for export/encoding. Legacy numeric values 5-7 map to medium; 8-10 map to high`},{key:`hideTouches`,names:[`--hide-touches`],type:`boolean`,usageLabel:`--hide-touches`,usageDescription:`Record: skip touch-overlay post-processing for faster raw benchmark videos`},{key:`intervalMs`,names:[`--interval-ms`],type:`int`,min:0,max:1e4,usageLabel:`--interval-ms <ms>`,usageDescription:`Delay between press iterations`},{key:`delayMs`,names:[`--delay-ms`],type:`int`,min:0,max:1e4,usageLabel:`--delay-ms <ms>`,usageDescription:`Delay between typed characters`},{key:`durationMs`,names:[`--duration-ms`],type:`int`,min:0,max:1e4,usageLabel:`--duration-ms <ms>`,usageDescription:`Scroll: pace the gesture over this duration when supported`},{key:`holdMs`,names:[`--hold-ms`],type:`int`,min:0,max:1e4,usageLabel:`--hold-ms <ms>`,usageDescription:`Press hold duration for each iteration`},{key:`jitterPx`,names:[`--jitter-px`],type:`int`,min:0,max:100,usageLabel:`--jitter-px <n>`,usageDescription:`Deterministic coordinate jitter radius for press`},{key:`pixels`,names:[`--pixels`],type:`int`,min:1,max:1e5,usageLabel:`--pixels <n>`,usageDescription:`Scroll: explicit gesture distance in pixels`},{key:`doubleTap`,names:[`--double-tap`],type:`boolean`,usageLabel:`--double-tap`,usageDescription:`Use double-tap gesture per press iteration`},{key:`verify`,names:[`--verify`],type:`boolean`,usageLabel:`--verify`,usageDescription:`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot`},{key:`settle`,names:[`--settle`],type:`boolean`,usageLabel:`--settle`,usageDescription:`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response (best-effort; never fails the action)`},{key:`settleQuietMs`,names:[`--settle-quiet`],type:`int`,min:0,usageLabel:`--settle-quiet <ms>`,usageDescription:`Settle: quiet window the UI must hold to count as settled (default 500ms)`},{key:`clickButton`,names:[`--button`],type:`enum`,enumValues:[`primary`,`secondary`,`middle`],usageLabel:`--button primary|secondary|middle`,usageDescription:`Click: choose mouse button (middle reserved for future macOS support)`},{key:`backMode`,names:[`--in-app`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`in-app`,usageLabel:`--in-app`,usageDescription:`Back: use app-provided back UI when available`},{key:`backMode`,names:[`--system`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`system`,usageLabel:`--system`,usageDescription:`Back: use system back input or gesture when available`},{key:`pauseMs`,names:[`--pause-ms`],type:`int`,min:0,max:1e4,usageLabel:`--pause-ms <ms>`,usageDescription:`Delay between swipe iterations`},{key:`pattern`,names:[`--pattern`],type:`enum`,enumValues:[`one-way`,`ping-pong`],usageLabel:`--pattern one-way|ping-pong`,usageDescription:`Swipe repeat pattern`},{key:`verbose`,names:[`--debug`,`--verbose`,`-v`],type:`boolean`,usageLabel:`--debug, --verbose, -v`,usageDescription:`Enable debug diagnostics; test --verbose prints per-test step timings without debug logs`},{key:`cost`,names:[`--cost`],type:`boolean`,usageLabel:`--cost`,usageDescription:`Include per-command wall-clock latency (cost.wallClockMs) in the response`},{key:`responseLevel`,names:[`--level`],type:`enum`,enumValues:a,usageLabel:`--level digest|default|full`,usageDescription:`Response detail level: digest (token-cheap), default (today), or full. Default keeps the wire shape unchanged.`},{key:`json`,names:[`--json`],type:`boolean`,usageLabel:`--json`,usageDescription:`JSON output`},{key:`help`,names:[`--help`,`-h`],type:`boolean`,usageLabel:`--help, -h`,usageDescription:`Print help and exit`},{key:`version`,names:[`--version`,`-V`],type:`boolean`,usageLabel:`--version, -V`,usageDescription:`Print version and exit`},{key:`snapshotDiff`,names:[`--diff`],type:`boolean`,usageLabel:`--diff`,usageDescription:`Snapshot: show structural diff against the previous session baseline`},{key:`saveScript`,names:[`--save-script`],type:`booleanOrString`,usageLabel:`--save-script [path]`,usageDescription:`Save session script (.ad) on close; optional custom output path`},{key:`networkInclude`,names:[`--include`],type:`enum`,enumValues:[`summary`,`headers`,`body`,`all`],usageLabel:`--include summary|headers|body|all`,usageDescription:`Network: include headers, bodies, or both in output`},{key:`shutdown`,names:[`--shutdown`],type:`boolean`,usageLabel:`--shutdown`,usageDescription:`close: shutdown associated simulator/emulator after ending session`},{key:`relaunch`,names:[`--relaunch`],type:`boolean`,usageLabel:`--relaunch`,usageDescription:`open: terminate app process before launching it`},{key:`restart`,names:[`--restart`],type:`boolean`,usageLabel:`--restart`,usageDescription:`logs clear: stop active stream, clear logs, then start streaming again`},{key:`retainPaths`,names:[`--retain-paths`],type:`boolean`,usageLabel:`--retain-paths`,usageDescription:`install-from-source: keep materialized artifact paths after install`},{key:`retentionMs`,names:[`--retention-ms`],type:`int`,min:1,usageLabel:`--retention-ms <ms>`,usageDescription:`install-from-source: retention TTL for materialized artifact paths`},{key:`noRecord`,names:[`--no-record`],type:`boolean`,usageLabel:`--no-record`,usageDescription:`Do not record this action`},{key:`replayUpdate`,names:[`--update`,`-u`],type:`boolean`,usageLabel:`--update, -u`,usageDescription:`Replay: update selectors and rewrite replay file in place`},{key:`replayMaestro`,names:[`--maestro`],type:`boolean`,usageLabel:`--maestro`,usageDescription:`Replay: treat input as a Maestro YAML compatibility flow. ${Le()} Unsupported syntax fails loudly with a link to ${pe}`},{key:`replayExportFormat`,names:[`--format`],type:`enum`,enumValues:[`maestro`],usageLabel:`--format maestro`,usageDescription:`Replay export: output format`},{key:`replayEnv`,names:[`-e`,`--env`],type:`string`,multiple:!0,usageLabel:`-e KEY=VALUE, --env KEY=VALUE`,usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:`failFast`,names:[`--fail-fast`],type:`boolean`,usageLabel:`--fail-fast`,usageDescription:`Test: stop the suite after the first failing script; with sharding, each shard stops independently`},{key:`timeoutMs`,names:[`--timeout`],type:`int`,min:1,usageLabel:`--timeout <ms>`,usageDescription:`Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt. With --settle: the settle-wait deadline (default 10s)`},{key:`retries`,names:[`--retries`],type:`int`,min:0,max:3,usageLabel:`--retries <n>`,usageDescription:`Test: retry each failed script up to n additional times`},{key:`recordVideo`,names:[`--record-video`],type:`boolean`,usageLabel:`--record-video`,usageDescription:`Test: record each replay attempt to recording.mp4 in its attempt artifacts`},{key:`artifactsDir`,names:[`--artifacts-dir`],type:`string`,usageLabel:`--artifacts-dir <path>`,usageDescription:`Test: root directory for suite artifacts`},{key:`reporter`,names:[`--reporter`],type:`string`,multiple:!0,usageLabel:`--reporter <name-or-path>`,usageDescription:`Test: add a replay suite reporter; use default, junit:<path>, or a custom reporter path (repeatable)`},{key:`reportJunit`,names:[`--report-junit`],type:`string`,usageLabel:`--report-junit <path>`,usageDescription:`Test: compatibility alias for --reporter junit:<path>`},{key:`shardAll`,names:[`--shard-all`],type:`int`,min:1,usageLabel:`--shard-all <n>`,usageDescription:`Test: run the full suite on each of n devices; combine with --device id1,id2 for explicit connected devices; AD_SHARD_INDEX is zero-based`},{key:`shardSplit`,names:[`--shard-split`],type:`int`,min:1,usageLabel:`--shard-split <n>`,usageDescription:`Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based`},{key:`steps`,names:[`--steps`],type:`string`,usageLabel:`--steps <json>`,usageDescription:`Batch: JSON array of steps`},{key:`stepsFile`,names:[`--steps-file`],type:`string`,usageLabel:`--steps-file <path>`,usageDescription:`Batch: read steps JSON from file`},{key:`batchOnError`,names:[`--on-error`],type:`enum`,enumValues:[`stop`],usageLabel:`--on-error stop`,usageDescription:`Batch: stop when a step fails`},{key:`batchMaxSteps`,names:[`--max-steps`],type:`int`,min:1,max:1e3,usageLabel:`--max-steps <n>`,usageDescription:`Batch: maximum number of allowed steps`},{key:`appsFilter`,names:[`--all`],type:`enum`,enumValues:[`user-installed`,`all`],setValue:`all`,usageLabel:`--all`,usageDescription:`Apps: include system/OEM apps`},{key:`snapshotInteractiveOnly`,names:[`-i`],type:`boolean`,usageLabel:`-i`,usageDescription:`Snapshot: interactive elements only`},{key:`snapshotDepth`,names:[`--depth`,`-d`],type:`int`,min:0,usageLabel:`--depth, -d <depth>`,usageDescription:`Snapshot: limit snapshot depth`},{key:`snapshotScope`,names:[`--scope`,`-s`],type:`string`,usageLabel:`--scope, -s <scope>`,usageDescription:`Snapshot: scope snapshot to label/identifier`},{key:`snapshotRaw`,names:[`--raw`],type:`boolean`,usageLabel:`--raw`,usageDescription:`Snapshot: raw node output`},{key:`snapshotForceFull`,names:[`--force-full`],type:`boolean`,usageLabel:`--force-full`,usageDescription:`Snapshot: re-emit the full tree even when unchanged`},{key:`findFirst`,names:[`--first`],type:`boolean`,usageLabel:`--first`,usageDescription:`Find: pick the first match when ambiguous`},{key:`findLast`,names:[`--last`],type:`boolean`,usageLabel:`--last`,usageDescription:`Find: pick the last match when ambiguous`},{key:`out`,names:[`--out`],type:`string`,usageLabel:`--out <path>`,usageDescription:`Output path`},{key:`artifact`,names:[`--artifact`],type:`string`,usageLabel:`--artifact <path>`,usageDescription:`Debug symbols: Apple crash artifact path (.ips, .crash, or .log)`},{key:`dsym`,names:[`--dsym`],type:`string`,usageLabel:`--dsym <path>`,usageDescription:`Debug symbols: matching .dSYM bundle path`},{key:`searchPath`,names:[`--search-path`],type:`string`,usageLabel:`--search-path <dir>`,usageDescription:`Debug symbols: directory to scan for matching .dSYM bundles`},{key:`overlayRefs`,names:[`--overlay-refs`],type:`boolean`,usageLabel:`--overlay-refs`,usageDescription:`Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide`},...Qe,{key:`baseline`,names:[`--baseline`,`-b`],type:`string`,usageLabel:`--baseline, -b <path>`,usageDescription:`Diff screenshot: path to baseline image file`},{key:`threshold`,names:[`--threshold`],type:`string`,usageLabel:`--threshold <0-1>`,usageDescription:`Diff screenshot: color distance threshold (default 0.1)`}],wr=H(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`sessionLocked`,`sessionLockConflicts`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Tr=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),Er=new Map;for(let e of Cr)for(let t of e.names)Er.set(t,e);function Dr(e){return Er.get(e)}function Or(){return Cr}const kr=new Set(Or().map(e=>e.key));function Ar(e,t){return{...mr(e),...t}}function jr(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!kr.has(e))continue;let t=i[e];Mr(t)&&(r[e]=t)}return r}function Mr(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function Nr(e){return t=>D(l.batch,[],{...t,batchSteps:Pr(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}function Pr(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty steps array.`);return t.map((e,t)=>Fr(e,t+1,n))}function Fr(e,t,n){let r=xt(e,t),i=Ir(r,t),a=vt(r,t),o=dt(r.runtime,t),s=n(i,a,t);return{command:s.command,positionals:s.positionals,flags:Ar(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function Ir(e,t){return ne(e.command,t)}const Lr=Kn(),Rr=L({name:`batch`,clientSurface:!1,commands:[I({name:`batch`,metadata:Lr,definition:R(Lr,(e,t)=>e.batch.run(zr(t))),cliSchema:{usageOverride:`batch [--steps <json> | --steps-file <path>]`,listUsageOverride:`batch --steps <json> | --steps-file <path>`,helpDescription:`Execute multiple commands in one daemon request`,summary:`Run multiple commands`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},cliReader:(e,t)=>({...O(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),cliOutputFormatter:Wn.batch})]});function zr(e){return{...C(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}function W(e,t,n){return Hn({name:e,description:t,inputSchema:qt(n),readInput:e=>Jt(e,n)})}const Br=`alert`,Vr=W(Br,`Inspect or handle platform alerts.`,{action:_(nt),timeoutMs:h()}),Hr=I({name:Br,metadata:Vr,definition:R(Vr,(e,t)=>e.command.alert(t)),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...O(t),...Wr(e)}),daemonWriter:E(l.alert,e=>Ur(e)),cliOutputFormatter:B});function Ur(e){return[e.action??`get`,...N(e.timeoutMs)]}function Wr(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return w({action:Gr(t[0]),timeoutMs:Bn(t[1],`alert timeout`)})}function Gr(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.`)}const Kr=`diff`,qr=W(Kr,`Diff accessibility snapshots.`,{kind:f(v({type:`string`,const:`snapshot`})),out:p(),interactiveOnly:g(),depth:h(),scope:p(),raw:g()}),Jr=I({name:Kr,metadata:qr,definition:R(qr,(e,t)=>e.capture.diff(t)),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,helpDescription:`Diff accessibility snapshot or compare screenshots pixel-by-pixel. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`,summary:`Diff snapshot or screenshot`,positionalArgs:[`kind`,`current?`],allowedFlags:[..._r,`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{...O(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:E(l.diff,e=>[F(e.kind,`diff requires kind`)])}),Yr=`screenshot`,Xr=W(Yr,`Capture a screenshot.`,{path:p(`Output path.`),overlayRefs:g(),fullscreen:g(),maxSize:h(),stabilize:g(),normalizeStatusBar:g(),surface:_(Ee)}),Zr=I({name:Yr,metadata:Xr,definition:R(Xr,(e,t)=>e.capture.screenshot(t)),cliSchema:{helpDescription:`Capture screenshot (web defaults to the viewport; use --fullscreen, --full, or -f for the entire page. macOS app sessions default to the app window; use --fullscreen for full desktop, --max-size to downscale, --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops)`,summary:`Capture screenshot with optional web full-page, desktop, downscale, or ref overlay modes`,positionalArgs:[`path?`],allowedFlags:ze},cliReader:(e,t)=>({...O(t),path:e[0]??t.out,...Be(t)}),daemonWriter:e=>D(l.screenshot,M(e.path),{...e,...Ge(e)})}),Qr=`settings`,$r=W(Qr,`Change OS settings and app permissions.`,{setting:f(p()),state:f(p()),app:p(),latitude:m(),longitude:m(),permission:p(),mode:_([`full`,`limited`])}),ei=I({name:Qr,metadata:$r,definition:R($r,(e,t)=>e.settings.update(t)),cliSchema:{usageOverride:it,listUsageOverride:`settings [area] [options]`,helpDescription:`Toggle OS settings, animation scales, appearance, and app permissions (macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS; mobile permission actions use the active session app)`,summary:`Change OS settings and app permissions`,positionalArgs:[`setting`,`state`,`target?`,`mode?`]},cliReader:(e,t)=>ti(e,t),daemonWriter:E(l.settings,e=>ni(e))});function ti(t,n){let r=Cn(n),i=t[0],a=t[1];if(A(i,ai)&&A(a,oi))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:et(t[2],`latitude`),longitude:et(t[3],`longitude`)};if(i===`appearance`&&A(a,si)||A(i,ci)&&A(a,li)||i===`fingerprint`&&A(a,ui))return{...r,setting:i,state:a};if(i===`permission`&&A(a,di))return{...r,setting:i,state:a,permission:ri(t[2]),mode:ii(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function ni(e){return e.setting===`clear-app-state`?[e.setting,...M(e.app)]:e.setting===`location`&&e.state===`set`?[e.setting,e.state,String(e.latitude),String(e.longitude)]:e.setting===`permission`?[e.setting,e.state,e.permission,...M(e.mode)]:[e.setting,e.state]}function ri(t){if(A(t,fi))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function ii(t){if(t===void 0||t===`full`||t===`limited`)return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const ai=k(`wifi`,`airplane`,`location`,`animations`),oi=k(`on`,`off`),si=k(`light`,`dark`,`toggle`),ci=k(`faceid`,`touchid`),li=k(`match`,`nonmatch`,`enroll`,`unenroll`),ui=k(`match`,`nonmatch`),di=k(`grant`,`deny`,`reset`),fi=k(`camera`,`microphone`,`photos`,`contacts`,`contacts-limited`,`notifications`,`calendar`,`location`,`location-always`,`media-library`,`motion`,`reminders`,`siri`,`accessibility`,`screen-recording`,`input-monitoring`);function pi(e){if(!Array.isArray(e)||e.length===0)return e;let t=ot(e);return e.map(e=>{let n=mi(e,t,e=>e.label),r=mi(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 mi(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 hi(e){let t=Ne(e.raw||!Array.isArray(e.result.nodes)?e.result:{...e.result,nodes:pi(e.result.nodes)});return{data:t,jsonData:_i(t),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:he(t,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const gi={snapshot:({input:e,result:t})=>hi({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:B,alert:B};function _i(e){let{unchanged:t,...n}=e;return n}const vi=`snapshot`,yi=W(vi,`Capture an accessibility snapshot.`,{interactiveOnly:g(),depth:h(),scope:p(),raw:g(),forceFull:g(),timeoutMs:h(`Maximum wall-clock time for the snapshot command.`)}),bi=I({name:vi,metadata:yi,definition:R(yi,(e,t)=>e.capture.snapshot(t)),cliSchema:{usageOverride:`snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--force-full] [--timeout <ms>]`,helpDescription:`Capture accessibility tree or diff against the previous session baseline. 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.`,summary:`Capture accessibility tree or diff against the previous session baseline`,allowedFlags:[`snapshotDiff`,..._r,`snapshotForceFull`,`timeoutMs`]},cliReader:(e,t)=>({...O(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),daemonWriter:E(l.snapshot),cliOutputFormatter:gi.snapshot}),xi=[`duration`,`text`,`ref`,`selector`,`stable`],Si=`wait`,Ci=W(Si,`Wait for duration, text, ref, selector, or stable UI.`,{kind:_(xi),durationMs:h(),text:p(),ref:p(),selector:p(),stable:g(),quietMs:h(),timeoutMs:h(),depth:h(),scope:p(),raw:g()}),wi=I({name:Si,metadata:Ci,definition:R(Ci,(e,t)=>e.command.wait(Ti(t))),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|stable [quietMs] [timeoutMs]`,positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...U]},cliReader:(e,t)=>Ei(e,t),daemonWriter:E(l.wait,e=>Di(e)),cliOutputFormatter:B});function Ti(e){an(e,`kind`,xi);let t={...e};return delete t.kind,t}function Ei(t,n){let r=te(t);if(!r)throw new e(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...Cn(n),...Tn(n)};if(r.kind===`sleep`)return{...i,durationMs:r.durationMs};if(r.kind===`text`){if(!r.text)throw new e(`INVALID_ARGS`,`wait requires text.`);return{...i,text:r.text,...Oi(r.timeoutMs)}}return r.kind===`ref`?{...i,ref:r.rawRef,...Oi(r.timeoutMs)}:r.kind===`stable`?{...i,stable:!0,...ki(r.quietMs),...Oi(r.timeoutMs)}:{...i,selector:r.selectorExpression,...Oi(r.timeoutMs)}}function Di(t){if([t.durationMs===void 0?void 0:`durationMs`,t.text===void 0?void 0:`text`,t.ref===void 0?void 0:`ref`,t.selector===void 0?void 0:`selector`,t.stable===void 0?void 0:`stable`].filter(Boolean).length!==1)throw new e(`INVALID_ARGS`,`wait command requires exactly one of durationMs, text, ref, selector, or stable.`);if(t.durationMs!==void 0)return[String(t.durationMs)];let n=N(t.timeoutMs);if(t.text!==void 0)return[`text`,t.text,...n];if(t.ref!==void 0)return[t.ref,...n];if(t.stable!==void 0){let r=N(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(!se(r))throw new e(`INVALID_ARGS`,`Invalid wait selector: ${r}`);return[r,...n]}function Oi(e){return e===null?{}:{timeoutMs:e}}function ki(e){return e===null?{}:{quietMs:e}}const Ai=L({name:`capture`,commands:[bi,Zr,Jr,wi,Hr,ei]});function ji(e){let t=[e.outPath,e.message];t.push(...Ni(e));for(let n of e.matchedImages)t.push(`Matched: ${n.name} ${n.uuid}${n.arch?` ${n.arch}`:``}`);for(let n of e.warnings??[])t.push(`Warning: ${n}`);return{data:e,text:t.join(`
3
- `)}}const Mi={debug:z(ji)};function Ni(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 Pi=`debug`,Fi=W(Pi,`Symbolicate crash artifacts with matching debug symbols.`,{action:f(_([`symbols`])),artifact:f(p(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:p(`Path to a matching .dSYM bundle.`),searchPath:p(`Directory to scan for matching .dSYM bundles.`),out:p(`Output path for the symbolicated artifact.`)}),Ii=L({name:`debugging`,commands:[I({name:Pi,metadata:Fi,definition:R(Fi,(e,t)=>e.debug.symbols(t)),cliSchema:{usageOverride:`debug symbols --artifact <crash.ips|crash.log> (--dsym <App.dSYM> | --search-path <dir>) [--out <symbolicated>]`,listUsageOverride:`debug`,helpDescription:`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.`,summary:`Symbolicate Apple crash artifacts with dSYMs; use logs/network/perf for other diagnostics`,positionalArgs:[`symbols`],allowedFlags:[`artifact`,`dsym`,`searchPath`,`out`]},cliReader:(e,t)=>({...O(t),action:Li(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:Mi.debug})]});function Li(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 Ri=[`click`,`focus`,`exists`,`getText`,`getAttrs`,`wait`,`fill`,`type`],zi={click:`Click or tap a semantic UI target by ref, selector, or point.`,press:`Press a semantic UI target by ref, selector, or point.`,fill:`Fill text into a semantic UI target by ref, selector, or point.`,longpress:`Long press by ref, selector, or point.`,swipe:`Swipe between two points.`,focus:`Focus input at coordinates.`,type:`Type text in the focused field.`,scroll:`Scroll in a direction or to an edge.`,get:`Get element text or attributes.`,is:`Assert UI state.`,find:`Find an element and optionally act on it.`,gesture:`Run a structured gesture.`},Bi=()=>g(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),Vi=()=>({settle:g(`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response. Best-effort; never fails the action.`),settleQuietMs:h(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:h(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function Hi(e){return{...ee(e)?{verify:Bi()}:{},...ie(e)?Vi():{}}}const Ui={target:f(Ht()),button:_(Ve,`Pointer button for platforms that support mouse buttons.`),...Gt(),...Kt(),...Hi(`click`)},Wi={target:f(Ht()),...Gt(),...Kt(),...Hi(`press`)},Gi={target:f(Ht()),text:f(p(`Text to enter into the target.`)),delayMs:h(`Delay between typed characters.`,{min:0}),...Gt(),...Hi(`fill`)},Ki={target:f(Ht()),durationMs:h(`Long press duration in milliseconds.`,{min:0}),...Gt(),...Hi(`longpress`)},qi={from:f(Wt(`Swipe start point.`)),to:f(Wt(`Swipe end point.`)),durationMs:h(`Swipe duration in milliseconds.`,{min:0}),count:h(`Number of swipe repetitions.`,{min:1}),pauseMs:h(`Pause between repeated swipes.`,{min:0}),pattern:_(xe)},Ji={x:f(m(`X coordinate.`)),y:f(m(`Y coordinate.`))},Yi={text:f(p(`Text to type.`)),delayMs:h(`Delay between typed characters.`,{min:0})},Xi={direction:f(_(Ze)),amount:m(`Platform scroll amount.`),pixels:h(`Pixel scroll amount.`,{min:0}),durationMs:h(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:$e})},Zi={format:f(_([`text`,`attrs`])),target:f(Ut()),...Gt()},Qi={predicate:f(_([`visible`,`hidden`,`exists`,`editable`,`selected`,`text`])),selector:f(p()),value:p(),...Gt()},$i={locator:_(Ct),query:f(p()),action:_(Ri),value:p(),timeoutMs:h(),first:g(),last:g(),depth:h(),raw:g()},ea={kind:f(_(oe,`Gesture variant.`)),direction:_(Oe,`Fling direction.`),preset:_(ce,`Swipe preset.`),origin:Wt(`Gesture origin point.`),delta:Wt(`Movement delta for pan or transform gestures.`),distance:h(`Fling distance.`,{min:0}),scale:m(`Pinch or transform scale.`),degrees:m(`Rotation in degrees.`),velocity:h(`Rotate gesture velocity.`,{min:0}),durationMs:h(`Gesture duration in milliseconds.`,{min:0})},ta=[Hn({name:`click`,description:zi.click,inputSchema:qt(Ui),readInput:e=>Jt(e,Ui)}),Hn({name:`press`,description:zi.press,inputSchema:qt(Wi),readInput:e=>Jt(e,Wi)}),Hn({name:`fill`,description:zi.fill,inputSchema:qt(Gi),readInput:e=>Jt(e,Gi)}),G(`longpress`,Ki),G(`swipe`,qi),G(`focus`,Ji),G(`type`,Yi),G(`scroll`,Xi),G(`get`,Zi),G(`is`,Qi),G(`find`,$i),Hn({name:`gesture`,description:zi.gesture,inputSchema:qt(ea),readInput:na})];function na(e){let t=Yt(e),n=Xt(t),r=rn(t,`kind`,oe);return r===`pan`?{...n,kind:r,origin:y(t,`origin`),delta:y(t,`delta`),durationMs:S(t,`durationMs`,{min:0})}:r===`fling`?{...n,kind:r,direction:rn(t,`direction`,Oe),origin:y(t,`origin`),distance:S(t,`distance`,{min:0}),durationMs:S(t,`durationMs`,{min:0})}:r===`swipe`?{...n,kind:r,preset:rn(t,`preset`,ce),durationMs:S(t,`durationMs`,{min:0})}:r===`pinch`?{...n,kind:r,scale:x(t,`scale`),origin:ra(t,`origin`)}:r===`rotate`?{...n,kind:r,degrees:x(t,`degrees`),origin:ra(t,`origin`),velocity:S(t,`velocity`,{min:0})}:{...n,kind:r,origin:y(t,`origin`),delta:y(t,`delta`),scale:x(t,`scale`),degrees:x(t,`degrees`),durationMs:S(t,`durationMs`,{min:0})}}function G(e,t){return W(e,zi[e],t)}function ra(e,t){return e[t]===void 0?void 0:y(e,t)}const ia={gesture:pa},aa={gesture:E(l.gesture,oa),"gesture-pan":E(l.gesture,ca),"gesture-fling":E(l.gesture,e=>la(e)),"gesture-swipe":E(l.gesture,sa),"gesture-pinch":E(l.gesture,ua),"gesture-rotate":E(l.gesture,e=>da(e)),"gesture-transform":E(l.gesture,fa)};function oa(t){switch(t.kind){case`pan`:return[`pan`,String(t.origin?.x),String(t.origin?.y),String(t.delta?.x),String(t.delta?.y),...N(t.durationMs)];case`fling`:return[`fling`,F(t.direction,`gesture fling requires direction`),String(t.origin?.x),String(t.origin?.y),...N(t.distance),...N(t.durationMs)];case`swipe`:return sa(t);case`pinch`:return[`pinch`,String(t.scale),...N(t.origin?.x),...N(t.origin?.y)];case`rotate`:return[`rotate`,String(t.degrees),...N(t.origin?.x),...N(t.origin?.y),...N(t.velocity)];case`transform`:return[`transform`,String(t.origin?.x),String(t.origin?.y),String(t.delta?.x),String(t.delta?.y),String(t.scale),String(t.degrees),...N(t.durationMs)];default:throw new e(`INVALID_ARGS`,`gesture requires pan, fling, swipe, pinch, rotate, or transform`)}}function sa(e){return[`swipe`,F(e.preset,`gesture swipe requires preset`),...N(e.durationMs)]}function ca(e){return[`pan`,String(e.x),String(e.y),String(e.dx),String(e.dy),...N(e.durationMs)]}function la(e){let t=e.durationMs===void 0?e.distance:e.distance??180;return[`fling`,e.direction,String(e.x),String(e.y),...N(t),...N(e.durationMs)]}function ua(e){return[`pinch`,String(e.scale),...N(e.x),...N(e.y)]}function da(e){ma(e);let t=e.x===void 0||e.y===void 0?[]:[String(e.x),String(e.y)];return[`rotate`,String(e.degrees),...t,...N(e.velocity)]}function fa(e){return[`transform`,String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...N(e.durationMs)]}function pa(t,n){let r=t[0],i=t.slice(1),a=O(n);switch(r){case`pan`:return{...a,kind:r,origin:{x:Number(i[0]),y:Number(i[1])},delta:{x:Number(i[2]),y:Number(i[3])},durationMs:j(i[4])};case`fling`:return{...a,kind:r,direction:i[0],origin:{x:Number(i[1]),y:Number(i[2])},distance:j(i[3]),durationMs:j(i[4])};case`swipe`:return{...a,kind:r,preset:i[0],durationMs:j(i[1])};case`pinch`:return{...a,kind:r,scale:Number(i[0]),origin:i[1]===void 0||i[2]===void 0?void 0:{x:Number(i[1]),y:Number(i[2])}};case`rotate`:return{...a,kind:r,degrees:Number(i[0]),origin:i[1]===void 0||i[2]===void 0?void 0:{x:Number(i[1]),y:Number(i[2])},velocity:j(i[3])};case`transform`:return{...a,kind:r,origin:{x:Number(i[0]),y:Number(i[1])},delta:{x:Number(i[2]),y:Number(i[3])},scale:Number(i[4]),degrees:Number(i[5]),durationMs:j(i[6])};default:throw new e(`INVALID_ARGS`,`gesture requires pan, fling, swipe, pinch, rotate, or transform`)}}function ma(t){if(t.x===void 0&&t.y!==void 0||t.x!==void 0&&t.y===void 0)throw new e(`INVALID_ARGS`,`gesture rotate center requires both x and y`)}const K={click:(e,t)=>({...O(t),...wn(t),...Dn(t),...En(t),target:On(Re(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...O(t),...wn(t),...Dn(t),...En(t),target:On(Re(e)),verify:t.verify}),longpress:(e,t)=>{let n=ha(e);return{...O(t),...wn(t),...En(t),target:On(n),durationMs:n.durationMs}},swipe:(e,t)=>({...O(t),from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},durationMs:j(e[4]),count:t.count,pauseMs:t.pauseMs,pattern:t.pattern}),focus:(e,t)=>({...O(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...O(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=ke(e);return{...O(t),...wn(t),...En(t),target:On(n.target),text:n.text,delayMs:t.delayMs,verify:t.verify}},scroll:(e,t)=>({...O(t),direction:ba(e[0]),amount:j(e[1]),pixels:t.pixels,durationMs:t.durationMs}),get:(e,t)=>({...O(t),...wn(t),format:Fn(e[0]),target:On(Pn(e.slice(1)))})},q={click:e=>D(l.click,kn(e),{...e,clickButton:e.button}),press:E(l.press,e=>kn(e)),longpress:E(l.longPress,e=>ga(e)),swipe:E(l.swipe,ya),focus:E(l.focus,e=>[String(e.x),String(e.y)]),type:E(l.type,e=>_a(e)),fill:E(l.fill,e=>va(e)),scroll:E(l.scroll,e=>[F(e.direction,`scroll requires direction`),...N(e.amount)]),get:E(l.get,e=>[F(e.format,`get requires format`),...An(e)])};function ha(e){let t=xa(e);return{...Re(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function ga(e){return[...kn(e),...N(e.durationMs)]}function _a(e){return[e.text]}function va(e){return[...kn(e),e.text]}function ya(e){return[String(e.from?.x),String(e.from?.y),String(e.to?.x),String(e.to?.y),...N(e.durationMs)]}function ba(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)}`)}function xa(e){if(zn(e[0])&&zn(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&&zn(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function Sa(e){let t=e.result;return e.format===`text`?{data:t,text:typeof t.text==`string`?t.text:``}:e.format===`attrs`?{data:t,text:JSON.stringify(t.node??{},null,2)}:ja(t)}function Ca(e){let t=e,n=je(t);return n?{data:t,text:n}:typeof t.text==`string`?{data:t,text:t.text}:typeof t.found==`boolean`?{data:t,text:`Found: ${t.found}`}:t.node?{data:t,text:JSON.stringify(t.node,null,2)}:ja(t)}function wa(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Ta(e){let t=e,n=t.ref??``,r=t.x,i=t.y;if(!n||typeof r!=`number`||typeof i!=`number`){let e=ja(t);return{data:e.data,text:Da(e.text,t.settle)}}return{data:t,text:Da(`Tapped @${n} (${r}, ${i})`,t.settle)}}function Ea(e){let t=e,n=ja(t);return{data:n.data,text:Da(n.text,t.settle)}}function Da(e,t){return`${e??``}${Oa(t)}`}function Oa(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Aa(t),...ka(t.diff)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
4
- `)}`}function ka(e){let t=(e?.lines??[]).map(e=>`${e.kind===`removed`?`-`:`+`} ${e.text??``}`);return e?.truncated&&t.push(`… changed lines truncated`),t}function Aa(e){let t=e.settled===!0?`settled`:`not settled`,n=e.diff?.summary,r=n?` +${n.additions??0} -${n.removals??0} (~${n.unchanged??0} unchanged)`:``;return`${t} after ${e.waitedMs??0}ms:${r}`}const J={click:z(Ta),press:z(Ta),fill:z(Ea),longpress:z(Ea),get:({input:e,result:t})=>Sa({result:t,format:e.format}),is:z(wa),find:z(Ca)};function ja(e){return V(e)}const Ma={find:(e,t)=>Ia(e,t),is:(e,t)=>La(e,t)},Na={is:E(l.is,e=>Pa(e)),find:e=>D(l.find,Fa(e),{...e,findFirst:e.first,findLast:e.last})};function Pa(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function Fa(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`:return e.action?[...t,e.action]:t;case`getText`:return[...t,`get`,`text`];case`getAttrs`:return[...t,`get`,`attrs`];case`wait`:return[...t,`wait`,...N(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function Ia(t,n){let r={...za(n),...Cn(n),first:n.findFirst,last:n.findLast},i=Ra(t[0]),a=i!==void 0,o=a?t[1]:t[0],s=a?2:1,c=t[s];if(c===void 0)return{...r,locator:i,query:Ba(o)};if(c===`get`){let n=t[s+1];if(n===`text`)return{...r,locator:i,query:Ba(o),action:`getText`};if(n===`attrs`)return{...r,locator:i,query:Ba(o),action:`getAttrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...r,locator:i,query:Ba(o),action:`wait`,timeoutMs:j(t[s+1])};if(c===`fill`||c===`type`)return{...r,locator:i,query:Ba(o),action:c,value:t.slice(s+1).join(` `)};if(c===`click`||c===`focus`||c===`exists`)return{...r,locator:i,query:Ba(o),action:c};throw new e(`INVALID_ARGS`,`Unsupported find action: ${c}`)}function La(t,n){let r={...Tn(n),...Cn(n)},i=ct(t),a=i[0];if(a!==`text`&&a!==`visible`&&a!==`hidden`&&a!==`exists`&&a!==`editable`&&a!==`selected`)throw new e(`INVALID_ARGS`,st,{hint:lt});let o=In(i.slice(1),{preferTrailingValue:a===`text`});return a===`text`?{...r,predicate:a,selector:o.selectorExpression,value:o.rest.join(` `)}:{...r,predicate:a,selector:o.selectorExpression}}function Ra(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function za(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function Ba(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>`,positionalArgs:[`subcommand`,`target`],allowedFlags:[...U]},find:{usageOverride:`find <locator|text> <action> [value] [--first|--last]`,helpDescription:`Find by text/label/value/role/id and run action`,summary:`Find an element and act`,positionalArgs:[`query`,`action`,`value?`],allowsExtraPositionals:!0,allowedFlags:[`snapshotDepth`,`snapshotRaw`,`findFirst`,`findLast`]},is:{positionalArgs:[`predicate`,`selector`,`value?`],allowsExtraPositionals:!0,allowedFlags:[...U]},click:{usageOverride:`click <x y|@ref|selector>`,positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...br,`clickButton`,...Ua(`click`),...U]},press:{usageOverride:`press <x y|@ref|selector>`,helpDescription:`Short press a semantic UI target by ref, selector, or point. For native context menus or hold gestures, use longpress <target> <durationMs> instead of press --hold-ms.`,positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...br,...Ua(`press`),...U]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,helpDescription:`Open native context menus or long-press targets by ref, selector, or point. Duration is positional, for example longpress @e12 800 or longpress 300 500 800.`,positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...Ua(`longpress`),...U]},swipe:{helpDescription:`Swipe coordinates with optional repeat pattern`,positionalArgs:[`x1`,`y1`,`x2`,`y2`,`durationMs?`],allowedFlags:[`count`,`pauseMs`,`pattern`]},gesture:{usageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform> ...`,listUsageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform> ...`,helpDescription:`Run touch gestures: pan <x> <y> <dx> <dy> [durationMs], fling <up|down|left|right> <x> <y> [distance] [durationMs], swipe <left|right|left-edge|right-edge> [durationMs], pinch <scale> [x] [y], rotate <degrees> [x] [y] [velocity], or transform <x> <y> <dx> <dy> <scale> <degrees> [durationMs]. 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.`,summary:`Run pan, fling, swipe, pinch, rotate, or transform gestures`,positionalArgs:[`pan|fling|swipe|pinch|rotate|transform`,`args?`],allowsExtraPositionals:!0},focus:{positionalArgs:[`x`,`y`]},type:{positionalArgs:[`text`],allowsExtraPositionals:!0,allowedFlags:[`delayMs`]},fill:{usageOverride:`fill <x> <y> <text> | fill <@ref|selector> <text>`,positionalArgs:[`targetOrX`,`yOrText`,`text?`],allowsExtraPositionals:!0,allowedFlags:[...U,`delayMs`,...Ua(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount] [--pixels <n>] [--duration-ms <ms>]`,helpDescription:`Scroll in a direction, or toward the top/bottom edge of scrollable content.`,summary:`Scroll in a direction or to an edge`,positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`]}},{gesture:Va,...Ha}=aa;function Ua(e){let t=[];return ee(e)&&t.push(`verify`),ie(e)&&t.push(...xr),t}const Wa=R(X(`click`),(e,t)=>e.interactions.click(ro(t))),Ga=R(X(`press`),(e,t)=>e.interactions.press(io(t))),Ka=R(X(`fill`),(e,t)=>e.interactions.fill(ao(t))),qa=R(X(`longpress`),(e,t)=>e.interactions.longPress(oo(t))),Ja=R(X(`swipe`),(e,t)=>e.interactions.swipe(t)),Ya=R(X(`focus`),(e,t)=>e.interactions.focus(t)),Xa=R(X(`type`),(e,t)=>e.interactions.type(t)),Za=R(X(`scroll`),(e,t)=>e.interactions.scroll(t)),Qa=R(X(`get`),(e,t)=>e.interactions.get(co(t))),$a=R(X(`is`),(e,t)=>e.interactions.is(t)),eo=R(X(`find`),(e,t)=>e.interactions.find(t)),to=R(X(`gesture`),async(e,t)=>{switch(t.kind){case`pan`:return await e.interactions.pan(lo(t));case`fling`:return await e.interactions.fling(uo(t));case`swipe`:return await e.interactions.swipeGesture(fo(t));case`pinch`:return await e.interactions.pinch(po(t));case`rotate`:return await e.interactions.rotateGesture(mo(t));case`transform`:return await e.interactions.transformGesture(ho(t))}}),no=L({name:`interaction`,clientSurface:!1,commands:[I({name:`click`,metadata:X(`click`),definition:Wa,cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),I({name:`press`,metadata:X(`press`),definition:Ga,cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),I({name:`fill`,metadata:X(`fill`),definition:Ka,cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),I({name:`longpress`,metadata:X(`longpress`),definition:qa,cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),I({name:`swipe`,metadata:X(`swipe`),definition:Ja,cliSchema:Y.swipe,cliReader:K.swipe,daemonWriter:q.swipe}),I({name:`focus`,metadata:X(`focus`),definition:Ya,cliSchema:Y.focus,cliReader:K.focus,daemonWriter:q.focus}),I({name:`type`,metadata:X(`type`),definition:Xa,cliSchema:Y.type,cliReader:K.type,daemonWriter:q.type}),I({name:`scroll`,metadata:X(`scroll`),definition:Za,cliSchema:Y.scroll,cliReader:K.scroll,daemonWriter:q.scroll}),I({name:`get`,metadata:X(`get`),definition:Qa,cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),I({name:`is`,metadata:X(`is`),definition:$a,cliSchema:Y.is,cliReader:Ma.is,daemonWriter:Na.is,cliOutputFormatter:J.is}),I({name:`find`,metadata:X(`find`),definition:eo,cliSchema:Y.find,cliReader:Ma.find,daemonWriter:Na.find,cliOutputFormatter:J.find}),I({name:`gesture`,metadata:X(`gesture`),definition:to,cliSchema:Y.gesture,cliReader:ia.gesture,daemonWriter:aa.gesture,extraDaemonWriters:Ha})]});function X(e){let t=ta.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function ro(e){return{...C(e),...on(e.target),...ln(e),...cn(e),button:e.button,verify:e.verify,...so(e)}}function io(e){return{...C(e),...on(e.target),...ln(e),...cn(e),verify:e.verify,...so(e)}}function ao(e){return{...C(e),...on(e.target),...ln(e),text:e.text,delayMs:e.delayMs,verify:e.verify,...so(e)}}function oo(e){return{...C(e),...on(e.target),...ln(e),durationMs:e.durationMs,...so(e)}}function so(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function co(e){return{...C(e),...sn(e.target),...ln(e),format:e.format}}function lo(e){return{...C(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,durationMs:e.durationMs}}function uo(e){return{...C(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance,durationMs:e.durationMs}}function fo(e){return{...C(e),preset:e.preset,durationMs:e.durationMs}}function po(e){return{...C(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function mo(e){return{...C(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y,velocity:e.velocity}}function ho(e){return{...C(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,scale:e.scale,degrees:e.degrees,durationMs:e.durationMs}}function go(e){return{data:{devices:e.map(Ae)},text:e.map(ko).join(`
5
- `)}}function _o(e){return{data:{device:Ae(e.device),availableCommands:e.availableCommands},text:[`${ko(e.device)} supports ${e.availableCommands.length} commands:`,e.availableCommands.join(` `)].join(`
6
- `)}}function vo(e){return{data:{apps:e.result},stderr:e.appsFilter===`all`?`Showing all apps, including system apps.
1
+ import{F as e,d as t,f as n,g as r,l as i,n as a,s as o,t as s}from"./sdk-contracts.js";import{S as c,d as ee,o as te,r as ne,u as re,v as ie,x as ae}from"./sdk-batch.js";import{At as oe,Bt as se,Cn as ce,Dt as le,Ft as ue,Gt as de,It as fe,Kt as pe,Ln as me,Lt as he,Mn as ge,Nt as _e,Qn as l,Qt as ve,Rn as ye,Rt as be,Sn as xe,Ut as Se,Vt as Ce,Wn as we,Wt as Te,Xt as Ee,Yn as De,Yt as Oe,Zn as ke,_n as Ae,at as je,bt as Me,c as Ne,cn as Pe,dn as Fe,f as Ie,fn as Le,g as Re,gt as ze,h as Be,it as Ve,kn as He,ln as Ue,m as We,n as Ge,nn as Ke,o as qe,on as Je,p as Ye,qt as Xe,r as Ze,rn as Qe,rt as $e,s as et,sn as tt,t as nt,tn as rt,u as it,un as at,vn as ot,wt as st,xn as ct,zn as lt,zt as ut}from"./tv-remote.js";import{R as dt,n as ft,o as pt,r as mt}from"./sdk-selectors.js";import{_ as ht,a as gt,b as _t,c as vt,f as yt,g as bt,h as xt,i as St,l as u,m as d,o as Ct,p as wt,r as Tt,s as Et,v as Dt}from"./sdk-batch-runner.js";import{n as Ot}from"./sdk-finders.js";import{n as kt,t as At}from"./sdk-app-inventory.js";let jt=!1;function Mt(){jt=!0}function Nt(){let e=jt;return jt=!1,e}const Pt=[`ref`,`selector`,`point`];function Ft(e,t=[]){return{type:`object`,properties:{...xn(),...e},...t.length>0?{required:t}:{},additionalProperties:!1}}function It(e){return{type:`object`,description:e,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`],additionalProperties:!1}}function Lt(e,t){return{type:`string`,enum:e,...t?{description:t}:{}}}function Rt(e){return{type:`string`,...e?{description:e}:{}}}function zt(e){return{type:`number`,...e?{description:e}:{}}}function Bt(e){return{type:`integer`,...e?{description:e}:{}}}function Vt(e){return{type:`boolean`,...e?{description:e}:{}}}function Ht(e){return{type:`array`,items:{type:`string`},...e?{description:e}:{}}}function Ut(e){return{type:`object`,additionalProperties:!0,...e?{description:e}:{}}}function f(e){return{...e,required:!0}}function p(e){return T(Rt(e),b)}function m(e){return T(zt(e),sn)}function h(e,t={}){return T(gn(e,t),(e,n)=>S(e,n,t))}function g(e){return T(Vt(e),cn)}function _(e,t){return T(Lt(e,t),(t,n)=>un(t,n,e))}function Wt(e){return T(Ut(e),yn)}function Gt(e){return T(Ht(e),bn)}function v(e){return T(e,(e,t)=>e[t])}function Kt(e,t){return T(e,t)}function qt(){return T(Sn(),(e,t)=>e[t]===void 0?void 0:rn(e,t))}function Jt(){return T(Cn(),(e,t)=>e[t]===void 0?void 0:an(e,t))}function Yt(e){return T(It(e),(e,t)=>e[t]===void 0?void 0:y(e,t))}function Xt(){return{depth:h(`Snapshot traversal depth.`,{min:0}),scope:p(`Snapshot scope selector used before resolution.`),raw:g(`Use raw snapshot data during selector resolution.`)}}function Zt(){return{count:h(`Number of press/click repetitions.`,{min:1}),intervalMs:h(`Delay between repeated press/click actions.`,{min:0}),holdMs:h(`Hold duration for each action.`,{min:0}),jitterPx:h(`Randomization radius in pixels.`,{min:0}),doubleTap:g(`Request a double-tap action.`)}}function Qt(e){return Ft(_n(e),vn(e))}function $t(t,n){let r=en(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=tn(r,{readTargetAlias:!Object.hasOwn(n,`target`)});return w({...a,...C(a),...i})}function en(t){if(t==null)return{};if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object arguments.`);return t}function tn(e,t={}){return{session:b(e,`session`),platform:un(e,`platform`,i),deviceTarget:nn(e,t),device:b(e,`device`),udid:b(e,`udid`),serial:b(e,`serial`),iosSimulatorDeviceSet:b(e,`iosSimulatorDeviceSet`),iosXctestrunFile:b(e,`iosXctestrunFile`),iosXctestDerivedDataPath:b(e,`iosXctestDerivedDataPath`),iosXctestEnvDir:b(e,`iosXctestEnvDir`),androidDeviceAllowlist:b(e,`androidDeviceAllowlist`),daemonBaseUrl:b(e,`daemonBaseUrl`),daemonAuthToken:b(e,`daemonAuthToken`),tenant:b(e,`tenant`),runId:b(e,`runId`),leaseId:b(e,`leaseId`),cwd:b(e,`cwd`),debug:cn(e,`debug`)}}function nn(t,n){let r=un(t,`deviceTarget`,o);if(n.readTargetAlias===!1||t.target===void 0)return r;let i=un(t,`target`,o);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 rn(e,t){let n=Tn(e,t),r=ln(n,`kind`,Pt);switch(r){case`ref`:return{kind:r,ref:on(n,`ref`),label:b(n,`label`)};case`selector`:return{kind:r,selector:on(n,`selector`)};case`point`:return{kind:r,x:x(n,`x`),y:x(n,`y`)}}}function an(e,t){let n=Tn(e,t),r=ln(n,`kind`,[`ref`,`selector`]);return r===`ref`?{kind:r,ref:on(n,`ref`),label:b(n,`label`)}:{kind:r,selector:on(n,`selector`)}}function y(e,t){let n=Tn(e,t);return{x:x(n,`x`),y:x(n,`y`)}}function on(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 b(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 x(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!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}}function S(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function cn(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 ln(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 un(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 C(e){return w({session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function dn(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 fn(e){switch(e.kind){case`ref`:return{ref:e.ref,label:e.label};case`selector`:return{selector:e.selector}}}function pn(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function mn(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function hn(t,n,r){let i=new Set(n),a=Object.keys(t).filter(e=>!i.has(e));if(a.length>0)throw new e(`INVALID_ARGS`,`${r} has unknown field(s): ${a.join(`, `)}.`)}function w(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function T(e,t){return{schema:e,required:!1,read:t}}function gn(e,t){return{...Bt(e),...t.min===void 0?{}:{minimum:t.min},...t.max===void 0?{}:{maximum:t.max}}}function _n(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.schema]))}function vn(e){return Object.entries(e).flatMap(([e,t])=>t.required?[e]:[])}function yn(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 bn(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 xn(){return{session:{type:`string`,description:`Agent-device session name.`},platform:{type:`string`,enum:i,description:`Platform selector used to resolve a device.`},deviceTarget:{type:`string`,enum:o,description:`Device target form. Maps to the CLI --target flag.`},target:{type:`string`,enum:o,description:`Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element.`},device:{type:`string`,description:`Device name selector.`},udid:{type:`string`,description:`iOS device UDID selector.`},serial:{type:`string`,description:`Android serial selector.`},iosSimulatorDeviceSet:{type:`string`,description:`iOS simulator device-set path used for device resolution.`},iosXctestrunFile:{type:`string`,description:`Externally built iOS XCTest runner .xctestrun artifact path.`},iosXctestDerivedDataPath:{type:`string`,description:`Derived data path for external iOS XCTest runner execution.`},iosXctestEnvDir:{type:`string`,description:`Writable directory for iOS XCTest runner env overlays.`},androidDeviceAllowlist:{type:`string`,description:`Android serial allowlist used for device resolution.`},daemonBaseUrl:{type:`string`,description:`Remote daemon base URL.`},daemonAuthToken:{type:`string`,description:`Remote daemon auth token.`},tenant:{type:`string`,description:`Remote tenant identifier.`},runId:{type:`string`,description:`Lease run identifier.`},leaseId:{type:`string`,description:`Existing lease identifier.`},cwd:{type:`string`,description:`Working directory for command execution.`},debug:{type:`boolean`,description:`Enable debug diagnostics.`}}}function Sn(){return{oneOf:[...wn(),{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 Cn(){return{oneOf:wn(),description:`UI element target by snapshot ref or selector expression.`}}function wn(){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 Tn(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 E(e,t){return n=>D(e,t?t(n):[],n)}function D(e,t,n){return{command:e,positionals:t,options:En(n)}}function En(e){let t=Dn(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 Dn(e){return e===`mobile`||e===`tv`||e===`desktop`?e:void 0}function O(e){return w({session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,androidDeviceAllowlist:e.androidDeviceAllowlist})}function On(e){return{platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function kn(e){return w({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function An(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function jn(e){return w({settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs})}function Mn(e){return w({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function Nn(e){if(`ref`in e&&e.ref!==void 0)return w({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 Pn(t){let n=In(t);if(typeof n.ref==`string`)return[n.ref,...Rn(n.label)];if(typeof n.selector==`string`)return[n.selector];if(n.kind===`point`||n.x!==void 0||n.y!==void 0)return[String(Ln(n.x,`x`)),String(Ln(n.y,`y`))];throw new e(`INVALID_ARGS`,`interaction requires @ref, selector, or point target`)}function Fn(t){let n=In(t);if(typeof n.ref==`string`)return[n.ref,...Rn(n.label)];if(typeof n.selector==`string`)return[n.selector];throw new e(`INVALID_ARGS`,`element command requires @ref or selector target`)}function In(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 Ln(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`point target requires numeric ${n}.`);return t}function Rn(e){return typeof e==`string`&&e.length>0?[e]:[]}function zn(t){if(t[0]?.startsWith(`@`))return{ref:t[0],label:Un(t.slice(1))};let n=t.join(` `).trim();if(!n)throw new e(`INVALID_ARGS`,`get requires @ref or selector expression`);return{selector:n}}function Bn(t){if(t===`text`||t===`attrs`)return t;throw new e(`INVALID_ARGS`,`get only supports text or attrs`)}function Vn(t,n={}){let r=ae(t,n);if(!r)throw new e(`INVALID_ARGS`,`is requires a selector expression`);return r}function Hn(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 Un(e){return e.join(` `).trim()||void 0}function k(...e){return new Set(e)}function A(e,t){return e!==void 0&&t.has(e)}function Wn(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function Gn(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 j(e){return e===void 0?void 0:Number(e)}function M(e){return e===void 0?[]:[e]}function N(e){return e===void 0?[]:[String(e)]}function P(t,n){if(t===void 0||t===``)throw new e(`INVALID_ARGS`,n);return t}function F(t,n){if(typeof t!=`string`||t.length===0)throw new e(`INVALID_ARGS`,n);return t}function I(e){return e}function L(e){let t={},n={},r={},i={},a={};for(let o of e.commands){if(o.cliSchema&&Kn(t,`CLI schema`,o.name,o.cliSchema),o.clientMethod&&Kn(n,`client command method`,o.clientMethod,o.name),Kn(r,`CLI reader`,o.name,o.cliReader),o.daemonWriter&&Kn(i,`daemon writer`,o.name,o.daemonWriter),o.extraDaemonWriters)for(let[e,t]of Object.entries(o.extraDaemonWriters))Kn(i,`daemon writer`,e,t);o.cliOutputFormatter&&Kn(a,`CLI output formatter`,o.name,o.cliOutputFormatter)}return{name:e.name,clientSurface:e.clientSurface,metadata:e.commands.map(e=>e.metadata),definitions:e.commands.map(e=>e.definition),clientCommandMethods:n,cliSchemas:t,cliReaders:r,daemonWriters:i,cliOutputFormatters:a}}function Kn(e,t,n,r){if(Object.hasOwn(e,n))throw Error(`Duplicate command family ${t}: ${n}`);e[n]=r}function qn(e){return e}function R(e,t){return{...e,run:t,invoke:async(n,r)=>await t(n,e.readInput(r))}}function z(e){return({result:t})=>e(t)}const B=z(V);function V(e){return{data:e,text:ce(e)}}function Jn(e){let t=[`Batch completed: ${e.executed}/${e.total} steps in ${e.totalDurationMs}ms`];for(let n of e.results)t.push(Xn(n));return{data:e,text:t.join(`
2
+ `)}}const Yn={batch:z(Jn)};function Xn(e){let t=ce(e.data)??e.command;return`${e.step}. OK ${t} (${e.durationMs}ms)`}function Zn(e=ne){let t=Qn(e);return qn({name:`batch`,description:`Run multiple structured command steps in one daemon request.`,inputSchema:Qt(t),readInput:e=>er(e,t)})}function Qn(e){return{steps:f(Kt({type:`array`,description:`Structured batch steps. Each step uses a command name and the same input object as that command tool.`,items:$n(e)},(t,n)=>tr(t[n],e))),onError:_([`stop`],`Batch failure policy.`),maxSteps:h(`Maximum number of steps accepted for this batch.`,{min:1,max:1e3}),out:p(`Optional output path for command artifacts.`)}}function $n(e){return{type:`object`,properties:{command:{type:`string`,enum:e,description:`Command name to run with structured input.`},input:{type:`object`,additionalProperties:!0,description:`Structured command input for the nested command. Use the matching MCP tool schema for this object.`},runtime:{type:`object`,additionalProperties:!0,description:`Optional per-step runtime payload.`}},required:[`command`,`input`],additionalProperties:!1}}function er(t,n){let r=$t(t,n),i=r.maxSteps??100;if(!St(i))throw new e(`INVALID_ARGS`,`Invalid batch maxSteps: ${String(r.maxSteps)}`);return Tt(r.steps.length,i),{...r}}function tr(t,n){if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected steps to be an array.`);return t.map((e,t)=>nr(e,t+1,n))}function nr(e,t,n){let r=Et(e,t);return hn(r,[`command`,`input`,`runtime`],`Batch step ${t}`),{command:rr(r,t,n),input:Ct(r,t),...ir(r,t)}}function rr(t,n,r){if(r===ne)return te(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 ir(e,t){let n=gt(e.runtime,t);return n===void 0?{}:{runtime:n}}function ar(e,t){let n=d(e,`bundleId`),r=d(e,`package`);return{app:Dt(e,`app`),appPath:Dt(e,`appPath`),platform:ht(e,`platform`),appId:n??r,bundleId:n,package:r,identifiers:Ke({session:t,bundleId:n,packageName:r})}}function or(t,n){let r=d(t,`bundleId`),i=d(t,`packageName`),a=r??i??d(t,`appId`),o=d(t,`launchTarget`)??i??r??a;if(!o)throw new e(`COMMAND_FAILED`,`Daemon response is missing "launchTarget".`,{response:t});return{appName:d(t,`appName`),appId:a,bundleId:r,packageName:i,launchTarget:o,installablePath:d(t,`installablePath`),archivePath:d(t,`archivePath`),materializationId:d(t,`materializationId`),materializationExpiresAt:d(t,`materializationExpiresAt`),identifiers:Ke({session:n,bundleId:r,packageName:i,appId:a})}}function sr(e){return{released:e.released===!0,materializationId:Dt(e,`materializationId`),identifiers:{}}}function cr(e){let{record:t,platform:r,id:i,name:a,target:o}=dr(e,`name`),s=ur(t);return{platform:r,target:o,kind:xt(t,`kind`),id:i,name:a,booted:typeof t.booted==`boolean`?t.booted:void 0,...n(r)&&s?{appleOs:s}:{},identifiers:Qe(r,i,a),...fr(r,i)}}function lr(e){let{record:t,platform:n,id:r,name:i,target:a}=dr(e,`name`),o=Dt(t,`device`),s=ur(t),c={session:i,...Qe(n,r,o)};return{name:i,createdAt:bt(t,`createdAt`),sessionStateDir:d(t,`sessionStateDir`),runnerLogPath:d(t,`runnerLogPath`),device:{platform:n,target:a,id:r,name:o,...s?{appleOs:s}:{},identifiers:c,...fr(n,r,wt(t,`ios_simulator_device_set`))},identifiers:c}}function ur(e){let n=e.appleOs;return t(n)?n:void 0}function dr(e,t){let n=vt(e);return{record:n,platform:ht(n,`platform`),id:Dt(n,`id`),name:Dt(n,t),target:yt(n,`target`)}}function fr(e,t,n){return{ios:e===`ios`?{udid:t,...n===void 0?{}:{simulatorSetPath:n}}:void 0,android:e===`android`?{serial:t}:void 0}}function pr(e){if(!u(e))return;let t=e.platform,n=d(e,`metroHost`),r=typeof e.metroPort==`number`?e.metroPort:void 0,i=d(e,`bundleUrl`),a=d(e,`launchUrl`);return{platform:t===`ios`||t===`android`?t:void 0,metroHost:n,metroPort:r,bundleUrl:i,launchUrl:a}}function mr(e){let t=e.platform,n=d(e,`id`),i=d(e,`device`);if(!(!r(t)||!n||!i))return{platform:t,target:yt(e,`target`),id:n,name:i,identifiers:Qe(t,n,i),ios:t===`ios`?{udid:d(e,`device_udid`)??n,simulatorSetPath:wt(e,`ios_simulator_device_set`)}:void 0,android:t===`android`?{serial:d(e,`serial`)??n}:void 0}}function hr(e){if(u(e)&&!(typeof e.durationMs!=`number`||typeof e.measuredAt!=`string`||typeof e.method!=`string`))return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:d(e,`appTarget`),appBundleId:d(e,`appBundleId`)}}function gr(e){if(!u(e)||typeof e.success!=`boolean`||typeof e.exitCode!=`number`||typeof e.stdout!=`string`||typeof e.stderr!=`string`)return;let t=_r(e.error);return{success:e.success,exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,...t?{error:t}:{}}}function _r(e){if(u(e)&&!(typeof e.code!=`string`||typeof e.message!=`string`))return{code:e.code,message:e.message,...typeof e.hint==`string`?{hint:e.hint}:{},...typeof e.diagnosticId==`string`?{diagnosticId:e.diagnosticId}:{},...typeof e.logPath==`string`?{logPath:e.logPath}:{},...u(e.details)?{details:e.details}:{}}}function vr(e){return Array.isArray(e)?e:[]}function yr(e){let t=He(e);return _t({stateDir:e.stateDir,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,daemonTransport:e.daemonTransport,daemonServerMode:e.daemonServerMode,...ge(t),provider:e.provider,providerSessionId:e.providerSessionId,providerApp:e.providerApp,providerOsVersion:e.providerOsVersion,providerProject:e.providerProject,providerBuild:e.providerBuild,providerSessionName:e.providerSessionName,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,noRecord:e.noRecord,backMode:e.backMode,metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,launchUrl:e.launchUrl,snapshotInteractiveOnly:e.interactiveOnly,snapshotDepth:e.depth,snapshotScope:e.scope,snapshotRaw:e.raw,snapshotForceFull:e.forceFull,...ct(e),appsFilter:e.appsFilter,kind:e.kind,out:e.out,count:e.count,fps:e.fps,screenshotMaxSize:e.maxSize,quality:e.quality,hideTouches:e.hideTouches,recordingScope:e.recordingScope,intervalMs:e.intervalMs,delayMs:e.delayMs,durationMs:e.durationMs,holdMs:e.holdMs,jitterPx:e.jitterPx,pixels:e.pixels,doubleTap:e.doubleTap,verify:e.verify,settle:e.settle,settleQuietMs:e.settleQuietMs,clickButton:e.clickButton,pauseMs:e.pauseMs,pattern:e.pattern,headless:e.headless,restart:e.restart,replayUpdate:e.replayUpdate,replayBackend:e.replayBackend,replayEnv:e.replayEnv,replayShellEnv:e.replayShellEnv,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 br(e){let t=He(e);return _t({requestId:e.requestId,cwd:e.cwd,sessionExplicit:e.session!==void 0,debug:e.debug,includeCost:e.cost,responseLevel:e.responseLevel,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,...me(t),sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function xr(e){return e??`default`}function H(...e){return e}const Sr=H(`snapshotInteractiveOnly`,`snapshotDepth`,`snapshotScope`,`snapshotRaw`),U=H(`snapshotDepth`,`snapshotScope`,`snapshotRaw`),Cr=H(`metroProjectRoot`,`kind`,`metroKind`,`metroPublicBaseUrl`,`metroProxyBaseUrl`,`metroBearerToken`,`metroPreparePort`,`metroListenHost`,`metroStatusHost`,`metroStartupTimeoutMs`,`metroProbeTimeoutMs`,`metroRuntimeFile`,`metroNoReuseExisting`,`metroNoInstallDeps`),wr=H(`metroHost`,`metroPort`,`bundleUrl`),Tr=H(`count`,`intervalMs`,`holdMs`,`jitterPx`,`doubleTap`),Er=H(`settle`,`settleQuietMs`,`timeoutMs`),Dr=H(`replayUpdate`,`replayEnv`),Or=[{key:`config`,names:[`--config`],type:`string`,usageLabel:`--config <path>`,usageDescription:`Load CLI defaults from a specific config file`},{key:`remoteConfig`,names:[`--remote-config`],type:`string`,usageLabel:`--remote-config <path>`,usageDescription:`Load remote host + Metro workflow settings from a specific profile file`},{key:`stateDir`,names:[`--state-dir`],type:`string`,usageLabel:`--state-dir <path>`,usageDescription:`Daemon state directory (defaults to ~/.agent-device for packages, or a worktree-scoped dev dir from source)`},{key:`daemonBaseUrl`,names:[`--daemon-base-url`],type:`string`,usageLabel:`--daemon-base-url <url>`,usageDescription:`Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)`},{key:`daemonAuthToken`,names:[`--daemon-auth-token`],type:`string`,usageLabel:`--daemon-auth-token <token>`,usageDescription:`Remote HTTP daemon or proxy auth token (sent as request token and bearer header)`},{key:`daemonTransport`,names:[`--daemon-transport`],type:`enum`,enumValues:[`auto`,`socket`,`http`],usageLabel:`--daemon-transport auto|socket|http`,usageDescription:`Daemon client transport preference`},{key:`daemonServerMode`,names:[`--daemon-server-mode`],type:`enum`,enumValues:[`socket`,`http`,`dual`],usageLabel:`--daemon-server-mode socket|http|dual`,usageDescription:`Daemon server mode used when spawning daemon`},{key:`proxyHost`,names:[`--host`],type:`string`,usageLabel:`--host <host>`,usageDescription:`Proxy: host interface to bind (default: 127.0.0.1)`},{key:`proxyPort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`Proxy: TCP port to bind (default: 0, choose a free port)`},{key:`tenant`,names:[`--tenant`],type:`string`,usageLabel:`--tenant <id>`,usageDescription:`Tenant scope identifier for isolated daemon sessions`},{key:`sessionIsolation`,names:[`--session-isolation`],type:`enum`,enumValues:[`none`,`tenant`],usageLabel:`--session-isolation none|tenant`,usageDescription:`Session isolation strategy (tenant prefixes session namespace)`},{key:`runId`,names:[`--run-id`],type:`string`,usageLabel:`--run-id <id>`,usageDescription:`Run identifier used for tenant lease admission checks`},{key:`leaseId`,names:[`--lease-id`],type:`string`,usageLabel:`--lease-id <id>`,usageDescription:`Lease identifier bound to tenant/run admission scope`},{key:`leaseBackend`,names:[`--lease-backend`],type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`],usageLabel:`--lease-backend ios-simulator|ios-instance|android-instance`,usageDescription:`Lease backend for remote tenant connection admission`},{key:`provider`,names:[`--provider`],type:`string`,usageLabel:`--provider <name>`,usageDescription:`Cloud provider name for provider-scoped commands`},{key:`providerSessionId`,names:[`--provider-session`],type:`string`,usageLabel:`--provider-session <id>`,usageDescription:`Cloud provider session id or ARN`},{key:`providerApp`,names:[`--provider-app`],type:`string`,usageLabel:`--provider-app <ref-or-path>`,usageDescription:`Cloud provider app reference or local app path used when creating hosted WebDriver sessions`},{key:`providerOsVersion`,names:[`--provider-os-version`,`--os-version`],type:`string`,usageLabel:`--provider-os-version <version>`,usageDescription:`Hosted cloud provider OS version, for example 17 or 14.0`},{key:`providerProject`,names:[`--provider-project`],type:`string`,usageLabel:`--provider-project <name>`,usageDescription:`Hosted cloud provider project label`},{key:`providerBuild`,names:[`--provider-build`],type:`string`,usageLabel:`--provider-build <name>`,usageDescription:`Hosted cloud provider build label`},{key:`providerSessionName`,names:[`--provider-session-name`],type:`string`,usageLabel:`--provider-session-name <name>`,usageDescription:`Hosted cloud provider session label`},{key:`awsProjectArn`,names:[`--aws-project-arn`],type:`string`,usageLabel:`--aws-project-arn <arn>`,usageDescription:`AWS Device Farm project ARN for hosted WebDriver sessions`},{key:`awsDeviceArn`,names:[`--aws-device-arn`],type:`string`,usageLabel:`--aws-device-arn <arn>`,usageDescription:`AWS Device Farm device ARN for hosted WebDriver sessions`},{key:`awsAppArn`,names:[`--aws-app-arn`],type:`string`,usageLabel:`--aws-app-arn <arn>`,usageDescription:`AWS Device Farm app ARN attached to hosted remote access sessions`},{key:`awsRegion`,names:[`--aws-region`],type:`string`,usageLabel:`--aws-region <region>`,usageDescription:`AWS region for Device Farm API calls`},{key:`awsInteractionMode`,names:[`--aws-interaction-mode`],type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`],usageLabel:`--aws-interaction-mode INTERACTIVE|NO_VIDEO|VIDEO_ONLY`,usageDescription:`AWS Device Farm remote access interaction mode`},{key:`force`,names:[`--force`],type:`boolean`,usageLabel:`--force`,usageDescription:`Force connection state replacement when reconnecting`},{key:`noLogin`,names:[`--no-login`],type:`boolean`,usageLabel:`--no-login`,usageDescription:`Connect: fail instead of starting implicit cloud login`},{key:`sessionLock`,names:[`--session-lock`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock reject|strip`,usageDescription:`Lock bound-session device routing for this CLI invocation and nested batch steps`},{key:`sessionLocked`,names:[`--session-locked`],type:`boolean`,usageLabel:`--session-locked`,usageDescription:`Deprecated alias for --session-lock reject`},{key:`sessionLockConflicts`,names:[`--session-lock-conflicts`],type:`enum`,enumValues:[`reject`,`strip`],usageLabel:`--session-lock-conflicts reject|strip`,usageDescription:`Deprecated alias for --session-lock`},{key:`platform`,names:[`--platform`],type:`enum`,enumValues:i,usageLabel:`--platform ${i.join(`|`)}`,usageDescription:"Platform to target (`apple` aliases the Apple automation backend)"},{key:`target`,names:[`--target`],type:`enum`,enumValues:[`mobile`,`tv`,`desktop`],usageLabel:`--target mobile|tv|desktop`,usageDescription:`Device target class to match`},{key:`device`,names:[`--device`],type:`string`,usageLabel:`--device <name>`,usageDescription:`Device name to target`},{key:`udid`,names:[`--udid`],type:`string`,usageLabel:`--udid <udid>`,usageDescription:`iOS device UDID`},{key:`serial`,names:[`--serial`],type:`string`,usageLabel:`--serial <serial>`,usageDescription:`Android device serial`},{key:`surface`,names:[`--surface`],type:`enum`,enumValues:ve,usageLabel:`--surface app|frontmost-app|desktop|menubar`,usageDescription:`macOS session surface for open (defaults to app)`},{key:`headless`,names:[`--headless`],type:`boolean`,usageLabel:`--headless`,usageDescription:`Boot: launch Android emulator without a GUI window`},{key:`targetApp`,names:[`--app`,`--target-app`],type:`string`,usageLabel:`--app <id-or-name>`,usageDescription:`Doctor: verify an installed target app without opening a session`},{key:`metroHost`,names:[`--metro-host`],type:`string`,usageLabel:`--metro-host <host>`,usageDescription:`Session-scoped Metro/debug host hint`},{key:`metroPort`,names:[`--metro-port`],type:`int`,min:1,max:65535,usageLabel:`--metro-port <port>`,usageDescription:`Session-scoped Metro/debug port hint`},{key:`metroProjectRoot`,names:[`--project-root`],type:`string`,usageLabel:`--project-root <path>`,usageDescription:`metro prepare: React Native project root (default: cwd)`},{key:`kind`,names:[`--kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`,...Ce],usageLabel:`--kind <kind>`,usageDescription:`Kind selector for commands that support it, such as metro prepare or perf artifact collectors`},{key:`perfTemplate`,names:[`--template`],type:`string`,usageLabel:`--template <name>`,usageDescription:`Perf xctrace template name, for example Time Profiler`},{key:`metroKind`,names:[`--metro-kind`],type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`],usageLabel:`--metro-kind auto|react-native|expo|repack`,usageDescription:`metro prepare: detect or force the React Native dev-server launcher kind`},{key:`metroPublicBaseUrl`,names:[`--public-base-url`],type:`string`,usageLabel:`--public-base-url <url>`,usageDescription:`metro prepare: public base URL used for direct dev-server bundle hints`},{key:`metroProxyBaseUrl`,names:[`--proxy-base-url`],type:`string`,usageLabel:`--proxy-base-url <url>`,usageDescription:`metro prepare: optional bridge origin for remote dev-server access`},{key:`metroBearerToken`,names:[`--bearer-token`],type:`string`,usageLabel:`--bearer-token <token>`,usageDescription:`metro prepare: host bridge bearer token (or AGENT_DEVICE_METRO_BEARER_TOKEN; falls back to AGENT_DEVICE_DAEMON_AUTH_TOKEN)`},{key:`metroPreparePort`,names:[`--port`],type:`int`,min:1,max:65535,usageLabel:`--port <port>`,usageDescription:`metro prepare: local dev-server port (default: 8081)`},{key:`metroListenHost`,names:[`--listen-host`],type:`string`,usageLabel:`--listen-host <host>`,usageDescription:`metro prepare: host dev server listens on (default: 0.0.0.0)`},{key:`metroStatusHost`,names:[`--status-host`],type:`string`,usageLabel:`--status-host <host>`,usageDescription:`metro prepare: host used for local dev-server /status polling (default: 127.0.0.1)`},{key:`metroStartupTimeoutMs`,names:[`--startup-timeout-ms`],type:`int`,min:1,usageLabel:`--startup-timeout-ms <ms>`,usageDescription:`metro prepare: timeout while waiting for the dev server to become ready`},{key:`metroProbeTimeoutMs`,names:[`--probe-timeout-ms`],type:`int`,min:1,usageLabel:`--probe-timeout-ms <ms>`,usageDescription:`metro prepare: timeout for /status and proxy bridge calls`},{key:`metroRuntimeFile`,names:[`--runtime-file`],type:`string`,usageLabel:`--runtime-file <path>`,usageDescription:`metro prepare: optional file path to persist the JSON result`},{key:`metroNoReuseExisting`,names:[`--no-reuse-existing`],type:`boolean`,usageLabel:`--no-reuse-existing`,usageDescription:`metro prepare: always start a fresh Metro process`},{key:`metroNoInstallDeps`,names:[`--no-install-deps`],type:`boolean`,usageLabel:`--no-install-deps`,usageDescription:`metro prepare: skip package-manager install when node_modules is missing`},{key:`bundleUrl`,names:[`--bundle-url`],type:`string`,usageLabel:`--bundle-url <url>`,usageDescription:`Session-scoped bundle URL hint`},{key:`launchUrl`,names:[`--launch-url`],type:`string`,usageLabel:`--launch-url <url>`,usageDescription:`Session-scoped deep link / launch URL hint`},{key:`iosSimulatorDeviceSet`,names:[`--ios-simulator-device-set`],type:`string`,usageLabel:`--ios-simulator-device-set <path>`,usageDescription:`Scope iOS simulator discovery/commands to this simulator device set`},{key:`iosXctestrunFile`,names:[`--ios-xctestrun-file`],type:`string`,usageLabel:`--ios-xctestrun-file <path>`,usageDescription:`Use an externally built iOS XCTest runner .xctestrun artifact`},{key:`iosXctestDerivedDataPath`,names:[`--ios-xctest-derived-data-path`],type:`string`,usageLabel:`--ios-xctest-derived-data-path <path>`,usageDescription:`Derived data path for external iOS XCTest runner execution`},{key:`iosXctestEnvDir`,names:[`--ios-xctest-env-dir`],type:`string`,usageLabel:`--ios-xctest-env-dir <path>`,usageDescription:`Writable directory for per-session iOS XCTest runner env overlays`},{key:`deviceHub`,names:[`--device-hub`],type:`boolean`,usageLabel:`--device-hub`,usageDescription:`open: use Xcode Device Hub when surfacing Apple simulators`},{key:`androidDeviceAllowlist`,names:[`--android-device-allowlist`],type:`string`,usageLabel:`--android-device-allowlist <serials>`,usageDescription:`Comma/space separated Android serial allowlist for discovery/selection`},{key:`remote`,names:[`--remote`],type:`boolean`,usageLabel:`--remote`,usageDescription:`Doctor: check remote connection setup instead of local device inventory`},{key:`activity`,names:[`--activity`],type:`string`,usageLabel:`--activity <component>`,usageDescription:`Android app launch activity (package/Activity); not for URL opens`},{key:`launchConsole`,names:[`--launch-console`],type:`string`,usageLabel:`--launch-console <path>`,usageDescription:`open: capture the initial iOS simulator launch console window to a file`},{key:`launchArgs`,names:[`--launch-args`],type:`string`,multiple:!0,usageLabel:`--launch-args <arg>`,usageDescription:`open: repeatable launch argument forwarded verbatim to the platform launch command (iOS app process args; Android adb shell am start args). Linux and macOS reject the flag.`},{key:`header`,names:[`--header`],type:`string`,multiple:!0,usageLabel:`--header <name:value>`,usageDescription:`install-from-source: repeatable HTTP header for URL downloads`},{key:`githubActionsArtifact`,names:[`--github-actions-artifact`],type:`string`,usageLabel:`--github-actions-artifact <owner/repo:artifact>`,usageDescription:`install-from-source: GitHub Actions artifact resolved by a remote daemon`},{key:`installSource`,names:[],type:`string`},{key:`session`,names:[`--session`],type:`string`,usageLabel:`--session <name>`,usageDescription:`Named session`},{key:`count`,names:[`--count`],type:`int`,min:1,max:200,usageLabel:`--count <n>`,usageDescription:`Repeat count for press/swipe series`},{key:`fps`,names:[`--fps`],type:`int`,min:1,max:120,usageLabel:`--fps <n>`,usageDescription:`Record: target frames per second (iOS physical device runner)`},{key:`quality`,names:[`--quality`],type:`string`,usageLabel:`--quality <medium|high>`,usageDescription:`Record: output quality preset; Android maps this to screenrecord bitrate, Apple targets use it for export/encoding. Legacy numeric values 5-7 map to medium; 8-10 map to high`},{key:`hideTouches`,names:[`--hide-touches`],type:`boolean`,usageLabel:`--hide-touches`,usageDescription:`Record: skip touch-overlay post-processing for faster raw benchmark videos`},{key:`recordingScope`,names:[`--scope`],type:`enum`,enumValues:Ee,usageLabel:`--scope <app|device|system>`,usageDescription:`Record: app requires an active app session; device/system records the whole screen`},{key:`intervalMs`,names:[`--interval-ms`],type:`int`,min:0,max:1e4,usageLabel:`--interval-ms <ms>`,usageDescription:`Delay between press iterations`},{key:`delayMs`,names:[`--delay-ms`],type:`int`,min:0,max:1e4,usageLabel:`--delay-ms <ms>`,usageDescription:`Delay between typed characters`},{key:`durationMs`,names:[`--duration-ms`],type:`int`,min:0,max:1e4,usageLabel:`--duration-ms <ms>`,usageDescription:`Scroll: pace the gesture over this duration when supported`},{key:`holdMs`,names:[`--hold-ms`],type:`int`,min:0,max:1e4,usageLabel:`--hold-ms <ms>`,usageDescription:`Press hold duration for each iteration`},{key:`jitterPx`,names:[`--jitter-px`],type:`int`,min:0,max:100,usageLabel:`--jitter-px <n>`,usageDescription:`Deterministic coordinate jitter radius for press`},{key:`pixels`,names:[`--pixels`],type:`int`,min:1,max:1e5,usageLabel:`--pixels <n>`,usageDescription:`Scroll: explicit gesture distance in pixels`},{key:`doubleTap`,names:[`--double-tap`],type:`boolean`,usageLabel:`--double-tap`,usageDescription:`Use double-tap gesture per press iteration`},{key:`verify`,names:[`--verify`],type:`boolean`,usageLabel:`--verify`,usageDescription:`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot`},{key:`settle`,names:[`--settle`],type:`boolean`,usageLabel:`--settle`,usageDescription:`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response (best-effort; never fails the action)`},{key:`settleQuietMs`,names:[`--settle-quiet`],type:`int`,min:0,usageLabel:`--settle-quiet <ms>`,usageDescription:`Settle: quiet window the UI must hold to count as settled (default 500ms)`},{key:`clickButton`,names:[`--button`],type:`enum`,enumValues:[`primary`,`secondary`,`middle`],usageLabel:`--button primary|secondary|middle`,usageDescription:`Click: choose mouse button (middle reserved for future macOS support)`},{key:`backMode`,names:[`--in-app`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`in-app`,usageLabel:`--in-app`,usageDescription:`Back: use app-provided back UI when available`},{key:`backMode`,names:[`--system`],type:`enum`,enumValues:[`in-app`,`system`],setValue:`system`,usageLabel:`--system`,usageDescription:`Back: use system back input or gesture when available`},{key:`pauseMs`,names:[`--pause-ms`],type:`int`,min:0,max:1e4,usageLabel:`--pause-ms <ms>`,usageDescription:`Delay between swipe iterations`},{key:`pattern`,names:[`--pattern`],type:`enum`,enumValues:[`one-way`,`ping-pong`],usageLabel:`--pattern one-way|ping-pong`,usageDescription:`Swipe repeat pattern`},{key:`verbose`,names:[`--debug`,`--verbose`,`-v`],type:`boolean`,usageLabel:`--debug, --verbose, -v`,usageDescription:`Enable debug diagnostics; test --verbose prints per-test step timings without debug logs`},{key:`cost`,names:[`--cost`],type:`boolean`,usageLabel:`--cost`,usageDescription:`Include per-command wall-clock latency (cost.wallClockMs) in the response`},{key:`responseLevel`,names:[`--level`],type:`enum`,enumValues:a,usageLabel:`--level digest|default|full`,usageDescription:`Response detail level: digest (token-cheap), default (today), or full. Default keeps the wire shape unchanged.`},{key:`json`,names:[`--json`],type:`boolean`,usageLabel:`--json`,usageDescription:`JSON output`},{key:`help`,names:[`--help`,`-h`],type:`boolean`,usageLabel:`--help, -h`,usageDescription:`Print help and exit`},{key:`version`,names:[`--version`,`-V`],type:`boolean`,usageLabel:`--version, -V`,usageDescription:`Print version and exit`},{key:`snapshotDiff`,names:[`--diff`],type:`boolean`,usageLabel:`--diff`,usageDescription:`Snapshot: show structural diff against the previous session baseline`},{key:`saveScript`,names:[`--save-script`],type:`booleanOrString`,usageLabel:`--save-script [path]`,usageDescription:`Save session script (.ad) on close; optional custom output path`},{key:`networkInclude`,names:[`--include`],type:`enum`,enumValues:[`summary`,`headers`,`body`,`all`],usageLabel:`--include summary|headers|body|all`,usageDescription:`Network: include headers, bodies, or both in output`},{key:`shutdown`,names:[`--shutdown`],type:`boolean`,usageLabel:`--shutdown`,usageDescription:`close: shutdown associated simulator/emulator after ending session`},{key:`relaunch`,names:[`--relaunch`],type:`boolean`,usageLabel:`--relaunch`,usageDescription:`open: terminate app process before launching it`},{key:`restart`,names:[`--restart`],type:`boolean`,usageLabel:`--restart`,usageDescription:`logs clear: stop active stream, clear logs, then start streaming again`},{key:`retainPaths`,names:[`--retain-paths`],type:`boolean`,usageLabel:`--retain-paths`,usageDescription:`install-from-source: keep materialized artifact paths after install`},{key:`retentionMs`,names:[`--retention-ms`],type:`int`,min:1,usageLabel:`--retention-ms <ms>`,usageDescription:`install-from-source: retention TTL for materialized artifact paths`},{key:`noRecord`,names:[`--no-record`],type:`boolean`,usageLabel:`--no-record`,usageDescription:`Do not record this action`},{key:`replayUpdate`,names:[`--update`,`-u`],type:`boolean`,usageLabel:`--update, -u`,usageDescription:`Replay: update selectors and rewrite replay file in place`},{key:`replayMaestro`,names:[`--maestro`],type:`boolean`,usageLabel:`--maestro`,usageDescription:`Replay: treat input as a Maestro YAML compatibility flow. ${ue()} Unsupported syntax fails loudly with a link to ${_e}`},{key:`replayExportFormat`,names:[`--format`],type:`enum`,enumValues:[`maestro`],usageLabel:`--format maestro`,usageDescription:`Replay export: output format`},{key:`replayEnv`,names:[`-e`,`--env`],type:`string`,multiple:!0,usageLabel:`-e KEY=VALUE, --env KEY=VALUE`,usageDescription:"Replay/Test: inject or override a ${KEY} variable for the script (repeatable)"},{key:`failFast`,names:[`--fail-fast`],type:`boolean`,usageLabel:`--fail-fast`,usageDescription:`Test: stop the suite after the first failing script; with sharding, each shard stops independently`},{key:`timeoutMs`,names:[`--timeout`],type:`int`,min:1,usageLabel:`--timeout <ms>`,usageDescription:`Prepare/Replay/Snapshot/Test: maximum wall-clock time for the command or attempt. With --settle: the settle-wait deadline (default 10s)`},{key:`retries`,names:[`--retries`],type:`int`,min:0,max:3,usageLabel:`--retries <n>`,usageDescription:`Test: retry each failed script up to n additional times`},{key:`recordVideo`,names:[`--record-video`],type:`boolean`,usageLabel:`--record-video`,usageDescription:`Test: record each replay attempt to recording.mp4 in its attempt artifacts`},{key:`artifactsDir`,names:[`--artifacts-dir`],type:`string`,usageLabel:`--artifacts-dir <path>`,usageDescription:`Test: root directory for suite artifacts`},{key:`reporter`,names:[`--reporter`],type:`string`,multiple:!0,usageLabel:`--reporter <name-or-path>`,usageDescription:`Test: add a replay suite reporter; use default, junit:<path>, or a custom reporter path (repeatable)`},{key:`reportJunit`,names:[`--report-junit`],type:`string`,usageLabel:`--report-junit <path>`,usageDescription:`Test: compatibility alias for --reporter junit:<path>`},{key:`shardAll`,names:[`--shard-all`],type:`int`,min:1,usageLabel:`--shard-all <n>`,usageDescription:`Test: run the full suite on each of n devices; combine with --device id1,id2 for explicit connected devices; AD_SHARD_INDEX is zero-based`},{key:`shardSplit`,names:[`--shard-split`],type:`int`,min:1,usageLabel:`--shard-split <n>`,usageDescription:`Test: split runnable suite entries across n devices; AD_SHARD_INDEX is zero-based`},{key:`steps`,names:[`--steps`],type:`string`,usageLabel:`--steps <json>`,usageDescription:`Batch: JSON array of steps`},{key:`stepsFile`,names:[`--steps-file`],type:`string`,usageLabel:`--steps-file <path>`,usageDescription:`Batch: read steps JSON from file`},{key:`batchOnError`,names:[`--on-error`],type:`enum`,enumValues:[`stop`],usageLabel:`--on-error stop`,usageDescription:`Batch: stop when a step fails`},{key:`batchMaxSteps`,names:[`--max-steps`],type:`int`,min:1,max:1e3,usageLabel:`--max-steps <n>`,usageDescription:`Batch: maximum number of allowed steps`},{key:`appsFilter`,names:[`--all`],type:`enum`,enumValues:[`user-installed`,`all`],setValue:`all`,usageLabel:`--all`,usageDescription:`Apps: include system/OEM apps`},{key:`snapshotInteractiveOnly`,names:[`-i`],type:`boolean`,usageLabel:`-i`,usageDescription:`Snapshot: interactive elements only`},{key:`snapshotDepth`,names:[`--depth`,`-d`],type:`int`,min:0,usageLabel:`--depth, -d <depth>`,usageDescription:`Snapshot: limit snapshot depth`},{key:`snapshotScope`,names:[`--scope`,`-s`],type:`string`,usageLabel:`--scope, -s <scope>`,usageDescription:`Snapshot: scope snapshot to label/identifier`},{key:`snapshotRaw`,names:[`--raw`],type:`boolean`,usageLabel:`--raw`,usageDescription:`Snapshot: raw node output`},{key:`snapshotForceFull`,names:[`--force-full`],type:`boolean`,usageLabel:`--force-full`,usageDescription:`Snapshot: re-emit the full tree even when unchanged`},{key:`findFirst`,names:[`--first`],type:`boolean`,usageLabel:`--first`,usageDescription:`Find: pick the first match when ambiguous`},{key:`findLast`,names:[`--last`],type:`boolean`,usageLabel:`--last`,usageDescription:`Find: pick the last match when ambiguous`},{key:`out`,names:[`--out`],type:`string`,usageLabel:`--out <path>`,usageDescription:`Output path`},{key:`artifact`,names:[`--artifact`],type:`string`,usageLabel:`--artifact <path>`,usageDescription:`Debug symbols: Apple crash artifact path (.ips, .crash, or .log)`},{key:`dsym`,names:[`--dsym`],type:`string`,usageLabel:`--dsym <path>`,usageDescription:`Debug symbols: matching .dSYM bundle path`},{key:`searchPath`,names:[`--search-path`],type:`string`,usageLabel:`--search-path <dir>`,usageDescription:`Debug symbols: directory to scan for matching .dSYM bundles`},{key:`overlayRefs`,names:[`--overlay-refs`],type:`boolean`,usageLabel:`--overlay-refs`,usageDescription:`Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide`},...ot,{key:`baseline`,names:[`--baseline`,`-b`],type:`string`,usageLabel:`--baseline, -b <path>`,usageDescription:`Diff screenshot: path to baseline image file`},{key:`threshold`,names:[`--threshold`],type:`string`,usageLabel:`--threshold <0-1>`,usageDescription:`Diff screenshot: color distance threshold (default 0.1)`}],kr=H(`remoteConfig`,`stateDir`,`daemonBaseUrl`,`daemonAuthToken`,`daemonTransport`,`daemonServerMode`,`tenant`,`sessionIsolation`,`runId`,`leaseId`,`leaseBackend`,`sessionLock`,`sessionLocked`,`sessionLockConflicts`,`platform`,`target`,`device`,`providerApp`,`providerOsVersion`,`providerProject`,`providerBuild`,`providerSessionName`,`awsProjectArn`,`awsDeviceArn`,`awsAppArn`,`awsRegion`,`awsInteractionMode`,`udid`,`serial`,`iosSimulatorDeviceSet`,`iosXctestrunFile`,`iosXctestDerivedDataPath`,`iosXctestEnvDir`,`androidDeviceAllowlist`,`session`,`noRecord`),Ar=new Set([`json`,`config`,`help`,`version`,`verbose`,`cost`,`responseLevel`]),jr=new Map;for(let e of Or)for(let t of e.names)jr.set(t,e);function Mr(e){return jr.get(e)}function Nr(){return Or}const Pr=new Set(Nr().map(e=>e.key));function Fr(e,t){return{...yr(e),...t}}function Ir(e,t){let n=e.inputSchema.properties;if(!n)return{};let r={},i=t;for(let e of Object.keys(n)){if(!Pr.has(e))continue;let t=i[e];Lr(t)&&(r[e]=t)}return r}function Lr(e){return typeof e==`boolean`||typeof e==`number`||typeof e==`string`}function Rr(e){return t=>D(l.batch,[],{...t,batchSteps:zr(t.steps,e),batchOnError:t.onError,batchMaxSteps:t.maxSteps})}function zr(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty steps array.`);return t.map((e,t)=>Br(e,t+1,n))}function Br(e,t,n){let r=Et(e,t),i=Vr(r,t),a=Ct(r,t),o=gt(r.runtime,t),s=n(i,a,t);return{command:s.command,positionals:s.positionals,flags:Fr(s.options,s.metadataFlags),runtime:o??s.options.runtime}}function Vr(e,t){return te(e.command,t)}const Hr=Zn(),Ur=L({name:`batch`,clientSurface:!1,commands:[I({name:`batch`,metadata:Hr,definition:R(Hr,(e,t)=>e.batch.run(Wr(t))),cliSchema:{usageOverride:`batch [--steps <json> | --steps-file <path>]`,listUsageOverride:`batch --steps <json> | --steps-file <path>`,helpDescription:`Execute multiple commands in one daemon request`,summary:`Run multiple commands`,allowedFlags:[`steps`,`stepsFile`,`batchOnError`,`batchMaxSteps`,`out`]},cliReader:(e,t)=>({...O(t),steps:t.batchSteps??[],onError:t.batchOnError,maxSteps:t.batchMaxSteps,out:t.out}),cliOutputFormatter:Yn.batch})]});function Wr(e){return{...C(e),steps:e.steps,onError:e.onError,maxSteps:e.maxSteps,out:e.out}}function W(e,t,n){return qn({name:e,description:t,inputSchema:Qt(n),readInput:e=>$t(e,n)})}const Gr=`alert`,Kr=W(Gr,`Inspect or handle platform alerts.`,{action:_(oe),timeoutMs:h()}),qr=I({name:Gr,metadata:Kr,definition:R(Kr,(e,t)=>e.command.alert(t)),cliSchema:{usageOverride:`alert [get|accept|dismiss|wait] [timeout]`,positionalArgs:[`action?`,`timeout?`]},cliReader:(e,t)=>({...O(t),...Yr(e)}),daemonWriter:E(l.alert,e=>Jr(e)),cliOutputFormatter:B});function Jr(e){return[e.action??`get`,...N(e.timeoutMs)]}function Yr(t){if(t.length>2)throw new e(`INVALID_ARGS`,`alert accepts at most action and timeout arguments.`);return w({action:Xr(t[0]),timeoutMs:Gn(t[1],`alert timeout`)})}function Xr(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.`)}const Zr=`diff`,Qr=W(Zr,`Diff accessibility snapshots.`,{kind:f(v({type:`string`,const:`snapshot`})),out:p(),interactiveOnly:g(),depth:h(),scope:p(),raw:g()}),$r=I({name:Zr,metadata:Qr,definition:R(Qr,(e,t)=>e.capture.diff(t)),cliSchema:{usageOverride:`diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]`,helpDescription:`Diff accessibility snapshot or compare screenshots pixel-by-pixel. Live iOS simulator screenshot diffs normalize status-bar chrome by default; use screenshot --normalize-status-bar when capturing reusable baselines.`,summary:`Diff snapshot or screenshot`,positionalArgs:[`kind`,`current?`],allowedFlags:[...Sr,`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{...O(n),kind:`snapshot`,out:n.out,interactiveOnly:n.snapshotInteractiveOnly,depth:n.snapshotDepth,scope:n.snapshotScope,raw:n.snapshotRaw}},daemonWriter:E(l.diff,e=>[F(e.kind,`diff requires kind`)])}),ei=`screenshot`,ti=W(ei,`Capture a screenshot.`,{path:p(`Output path.`),overlayRefs:g(),pixelDensity:h(`Output screenshot pixel density in pixels per logical point.`,{min:1}),fullscreen:g(),maxSize:h(),stabilize:g(),normalizeStatusBar:g(),surface:_(ve)}),ni=I({name:ei,metadata:ti,definition:R(ti,(e,t)=>e.capture.screenshot(t)),cliSchema:{helpDescription:`Capture screenshot (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, --max-size to downscale, --overlay-refs to annotate current refs, --normalize-status-bar for deterministic iOS simulator chrome, or --no-stabilize for low-latency Android capture loops)`,summary:`Capture screenshot with optional density, full-page, desktop, downscale, or ref overlay modes`,positionalArgs:[`path?`],allowedFlags:Ae},cliReader:(e,t)=>({...O(t),path:e[0]??t.out,...xe(t)}),daemonWriter:e=>D(l.screenshot,M(e.path),{...e,...ct(e)})}),ri=`settings`,ii=W(ri,`Change OS settings and app permissions.`,{setting:f(p()),state:f(p()),app:p(),latitude:m(),longitude:m(),permission:p(),mode:_([`full`,`limited`])}),ai=I({name:ri,metadata:ii,definition:R(ii,(e,t)=>e.settings.update(t)),cliSchema:{usageOverride:le,listUsageOverride:`settings [area] [options]`,helpDescription:`Toggle OS settings, animation scales, appearance, and app permissions (macOS supports only settings appearance <light|dark|toggle> and settings permission <grant|reset> <accessibility|screen-recording|input-monitoring>; wifi|airplane|location|animations remain unsupported on macOS; mobile permission actions use the active session app)`,summary:`Change OS settings and app permissions`,positionalArgs:[`setting`,`state`,`target?`,`mode?`]},cliReader:(e,t)=>oi(e,t),daemonWriter:E(l.settings,e=>si(e))});function oi(t,n){let r=On(n),i=t[0],a=t[1];if(A(i,ui)&&A(a,di))return{...r,setting:i,state:a};if(i===`location`&&a===`set`)return{...r,setting:i,state:a,latitude:st(t[2],`latitude`),longitude:st(t[3],`longitude`)};if(i===`appearance`&&A(a,fi)||A(i,pi)&&A(a,mi)||i===`fingerprint`&&A(a,hi))return{...r,setting:i,state:a};if(i===`permission`&&A(a,gi))return{...r,setting:i,state:a,permission:ci(t[2]),mode:li(t[3])};if(i===`clear-app-state`){let e=a===`clear`?t[2]:a;return{...r,setting:i,state:`clear`,app:e}}throw new e(`INVALID_ARGS`,`Invalid settings arguments.`)}function si(e){return e.setting===`clear-app-state`?[e.setting,...M(e.app)]:e.setting===`location`&&e.state===`set`?[e.setting,e.state,String(e.latitude),String(e.longitude)]:e.setting===`permission`?[e.setting,e.state,e.permission,...M(e.mode)]:[e.setting,e.state]}function ci(t){if(A(t,_i))return t;throw new e(`INVALID_ARGS`,`settings permission requires a permission target.`)}function li(t){if(t===void 0||t===`full`||t===`limited`)return t;throw new e(`INVALID_ARGS`,`settings permission mode must be full or limited.`)}const ui=k(`wifi`,`airplane`,`location`,`animations`),di=k(`on`,`off`),fi=k(`light`,`dark`,`toggle`),pi=k(`faceid`,`touchid`),mi=k(`match`,`nonmatch`,`enroll`,`unenroll`),hi=k(`match`,`nonmatch`),gi=k(`grant`,`deny`,`reset`),_i=k(`camera`,`microphone`,`photos`,`contacts`,`contacts-limited`,`notifications`,`calendar`,`location`,`location-always`,`media-library`,`motion`,`reminders`,`siri`,`accessibility`,`screen-recording`,`input-monitoring`);function vi(e){if(!Array.isArray(e)||e.length===0)return e;let t=dt(e);return e.map(e=>{let n=yi(e,t,e=>e.label),r=yi(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 yi(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 bi(e){let t=Le(e.raw||!Array.isArray(e.result.nodes)?e.result:{...e.result,nodes:vi(e.result.nodes)});return{data:t,jsonData:Si(t),stderr:e.result.snapshotDiagnostics?.warning?`${e.result.snapshotDiagnostics.warning}\n`:void 0,text:we(t,{raw:e.raw,flatten:e.interactiveOnly,scoped:typeof e.scope==`string`&&e.scope.trim().length>0,depthLimited:typeof e.depth==`number`})}}const xi={snapshot:({input:e,result:t})=>bi({result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}),wait:B,alert:B};function Si(e){let{unchanged:t,...n}=e;return n}const Ci=`snapshot`,wi=W(Ci,`Capture an accessibility snapshot.`,{interactiveOnly:g(),depth:h(),scope:p(),raw:g(),forceFull:g(),timeoutMs:h(`Maximum wall-clock time for the snapshot command.`)}),Ti=I({name:Ci,metadata:wi,definition:R(wi,(e,t)=>e.capture.snapshot(t)),cliSchema:{usageOverride:`snapshot [--diff] [-i] [-d <depth>] [-s <scope>] [--raw] [--force-full] [--timeout <ms>]`,helpDescription:`Capture accessibility tree or diff against the previous session baseline. 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.`,summary:`Capture accessibility tree or diff against the previous session baseline`,allowedFlags:[`snapshotDiff`,...Sr,`snapshotForceFull`,`timeoutMs`]},cliReader:(e,t)=>({...O(t),interactiveOnly:t.snapshotInteractiveOnly,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),daemonWriter:E(l.snapshot),cliOutputFormatter:xi.snapshot}),Ei=[`duration`,`text`,`ref`,`selector`,`stable`],Di=`wait`,Oi=W(Di,`Wait for duration, text, ref, selector, or stable UI.`,{kind:_(Ei),durationMs:h(),text:p(),ref:p(),selector:p(),stable:g(),quietMs:h(),timeoutMs:h(),depth:h(),scope:p(),raw:g()}),ki=I({name:Di,metadata:Oi,definition:R(Oi,(e,t)=>e.command.wait(Ai(t))),cliSchema:{usageOverride:`wait <ms>|text <text>|@ref|<selector>|stable [quietMs] [timeoutMs]`,positionalArgs:[`durationOrSelector`,`timeoutMs?`],allowsExtraPositionals:!0,allowedFlags:[...U]},cliReader:(e,t)=>ji(e,t),daemonWriter:E(l.wait,e=>Mi(e)),cliOutputFormatter:B});function Ai(e){un(e,`kind`,Ei);let t={...e};return delete t.kind,t}function ji(t,n){let r=ie(t);if(!r)throw new e(`INVALID_ARGS`,`wait requires <ms>, text <text>, @ref, <selector> [timeoutMs], or stable [quietMs] [timeoutMs].`);let i={...On(n),...An(n)};if(r.kind===`sleep`)return{...i,durationMs:r.durationMs};if(r.kind===`text`){if(!r.text)throw new e(`INVALID_ARGS`,`wait requires text.`);return{...i,text:r.text,...Ni(r.timeoutMs)}}return r.kind===`ref`?{...i,ref:r.rawRef,...Ni(r.timeoutMs)}:r.kind===`stable`?{...i,stable:!0,...Pi(r.quietMs),...Ni(r.timeoutMs)}:{...i,selector:r.selectorExpression,...Ni(r.timeoutMs)}}function Mi(t){if([t.durationMs===void 0?void 0:`durationMs`,t.text===void 0?void 0:`text`,t.ref===void 0?void 0:`ref`,t.selector===void 0?void 0:`selector`,t.stable===void 0?void 0:`stable`].filter(Boolean).length!==1)throw new e(`INVALID_ARGS`,`wait command requires exactly one of durationMs, text, ref, selector, or stable.`);if(t.durationMs!==void 0)return[String(t.durationMs)];let n=N(t.timeoutMs);if(t.text!==void 0)return[`text`,t.text,...n];if(t.ref!==void 0)return[t.ref,...n];if(t.stable!==void 0){let r=N(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(!c(r))throw new e(`INVALID_ARGS`,`Invalid wait selector: ${r}`);return[r,...n]}function Ni(e){return e===null?{}:{timeoutMs:e}}function Pi(e){return e===null?{}:{quietMs:e}}const Fi=L({name:`capture`,commands:[Ti,ni,$r,ki,qr,ai]});function Ii(e){let t=[e.outPath,e.message];t.push(...Ri(e));for(let n of e.matchedImages)t.push(`Matched: ${n.name} ${n.uuid}${n.arch?` ${n.arch}`:``}`);for(let n of e.warnings??[])t.push(`Warning: ${n}`);return{data:e,text:t.join(`
3
+ `)}}const Li={debug:z(Ii)};function Ri(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 zi=`debug`,Bi=W(zi,`Symbolicate crash artifacts with matching debug symbols.`,{action:f(_([`symbols`])),artifact:f(p(`Apple crash artifact path (.ips, .crash, or .log).`)),dsym:p(`Path to a matching .dSYM bundle.`),searchPath:p(`Directory to scan for matching .dSYM bundles.`),out:p(`Output path for the symbolicated artifact.`)}),Vi=L({name:`debugging`,commands:[I({name:zi,metadata:Bi,definition:R(Bi,(e,t)=>e.debug.symbols(t)),cliSchema:{usageOverride:`debug symbols --artifact <crash.ips|crash.log> (--dsym <App.dSYM> | --search-path <dir>) [--out <symbolicated>]`,listUsageOverride:`debug`,helpDescription:`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.`,summary:`Symbolicate Apple crash artifacts with dSYMs; use logs/network/perf for other diagnostics`,positionalArgs:[`symbols`],allowedFlags:[`artifact`,`dsym`,`searchPath`,`out`]},cliReader:(e,t)=>({...O(t),action:Hi(e[0]),artifact:t.artifact,dsym:t.dsym,searchPath:t.searchPath,out:t.out}),cliOutputFormatter:Li.debug})]});function Hi(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 Ui=[`click`,`focus`,`exists`,`getText`,`getAttrs`,`wait`,`fill`,`type`],Wi={click:`Click or tap a semantic UI target by ref, selector, or point.`,press:`Press a semantic UI target by ref, selector, or point.`,fill:`Replace text in a semantic UI target by ref, selector, or point.`,longpress:`Long press by ref, selector, or point.`,swipe:`Swipe between two points.`,focus:`Focus input at coordinates.`,type:`Append text to the focused field.`,scroll:`Scroll in a direction or to an edge.`,get:`Get element text or attributes.`,is:`Assert UI state.`,find:`Find an element and optionally act on it.`,gesture:`Run a structured gesture.`},Gi=()=>g(`Capture cheap post-action evidence (AX digest, node counts, changedFromBefore) instead of a follow-up snapshot.`),Ki=()=>({settle:g(`After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response. Best-effort; never fails the action.`),settleQuietMs:h(`Settle: quiet window in milliseconds (default 500).`,{min:0}),timeoutMs:h(`Settle: wait deadline in milliseconds (default 10000).`,{min:1})});function qi(e){return{...ee(e)?{verify:Gi()}:{},...re(e)?Ki():{}}}const Ji={target:f(qt()),button:_(Me,`Pointer button for platforms that support mouse buttons.`),...Xt(),...Zt(),...qi(`click`)},Yi={target:f(qt()),...Xt(),...Zt(),...qi(`press`)},Xi={target:f(qt()),text:f(p(`Text to enter into the target.`)),delayMs:h(`Delay between typed characters.`,{min:0}),...Xt(),...qi(`fill`)},Zi={target:f(qt()),durationMs:h(`Long press duration in milliseconds.`,{min:0}),...Xt(),...qi(`longpress`)},Qi={from:f(Yt(`Swipe start point.`)),to:f(Yt(`Swipe end point.`)),durationMs:h(`Swipe duration in milliseconds.`,{min:0}),count:h(`Number of swipe repetitions.`,{min:1}),pauseMs:h(`Pause between repeated swipes.`,{min:0}),pattern:_(Ve)},$i={x:f(m(`X coordinate.`)),y:f(m(`Y coordinate.`))},ea={text:f(p(`Text to type.`)),delayMs:h(`Delay between typed characters.`,{min:0})},ta={direction:f(_(Re)),amount:m(`Platform scroll amount.`),pixels:h(`Pixel scroll amount.`,{min:0}),durationMs:h(`Scroll duration in milliseconds when the backend supports pacing.`,{min:0,max:ze})},na={format:f(_([`text`,`attrs`])),target:f(Jt()),...Xt()},ra={predicate:f(_([`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`])),selector:f(p()),value:p(),...Xt()},ia={locator:_(Ot),query:f(p()),action:_(Ui),value:p(),timeoutMs:h(),first:g(),last:g(),depth:h(),raw:g()},aa={kind:f(_(De,`Gesture variant.`)),direction:_($e,`Fling direction.`),preset:_(je,`Swipe preset.`),origin:Yt(`Gesture origin point.`),delta:Yt(`Movement delta for pan or transform gestures.`),distance:h(`Fling distance.`,{min:0}),scale:m(`Pinch or transform scale.`),degrees:m(`Rotation in degrees.`),velocity:h(`Rotate gesture velocity.`,{min:0}),durationMs:h(`Gesture duration in milliseconds.`,{min:0})},oa=[qn({name:`click`,description:Wi.click,inputSchema:Qt(Ji),readInput:e=>$t(e,Ji)}),qn({name:`press`,description:Wi.press,inputSchema:Qt(Yi),readInput:e=>$t(e,Yi)}),qn({name:`fill`,description:Wi.fill,inputSchema:Qt(Xi),readInput:e=>$t(e,Xi)}),G(`longpress`,Zi),G(`swipe`,Qi),G(`focus`,$i),G(`type`,ea),G(`scroll`,ta),G(`get`,na),G(`is`,ra),G(`find`,ia),qn({name:`gesture`,description:Wi.gesture,inputSchema:Qt(aa),readInput:sa})];function sa(e){let t=en(e),n=tn(t),r=ln(t,`kind`,De);return r===`pan`?{...n,kind:r,origin:y(t,`origin`),delta:y(t,`delta`),durationMs:S(t,`durationMs`,{min:0})}:r===`fling`?{...n,kind:r,direction:ln(t,`direction`,$e),origin:y(t,`origin`),distance:S(t,`distance`,{min:0}),durationMs:S(t,`durationMs`,{min:0})}:r===`swipe`?{...n,kind:r,preset:ln(t,`preset`,je),durationMs:S(t,`durationMs`,{min:0})}:r===`pinch`?{...n,kind:r,scale:x(t,`scale`),origin:ca(t,`origin`)}:r===`rotate`?{...n,kind:r,degrees:x(t,`degrees`),origin:ca(t,`origin`),velocity:S(t,`velocity`,{min:0})}:{...n,kind:r,origin:y(t,`origin`),delta:y(t,`delta`),scale:x(t,`scale`),degrees:x(t,`degrees`),durationMs:S(t,`durationMs`,{min:0})}}function G(e,t){return W(e,Wi[e],t)}function ca(e,t){return e[t]===void 0?void 0:y(e,t)}const la={gesture:va},ua={gesture:E(l.gesture,da),"gesture-pan":E(l.gesture,pa),"gesture-fling":E(l.gesture,e=>ma(e)),"gesture-swipe":E(l.gesture,fa),"gesture-pinch":E(l.gesture,ha),"gesture-rotate":E(l.gesture,e=>ga(e)),"gesture-transform":E(l.gesture,_a)};function da(t){switch(t.kind){case`pan`:return[`pan`,String(t.origin?.x),String(t.origin?.y),String(t.delta?.x),String(t.delta?.y),...N(t.durationMs)];case`fling`:return[`fling`,F(t.direction,`gesture fling requires direction`),String(t.origin?.x),String(t.origin?.y),...N(t.distance),...N(t.durationMs)];case`swipe`:return fa(t);case`pinch`:return[`pinch`,String(t.scale),...N(t.origin?.x),...N(t.origin?.y)];case`rotate`:return[`rotate`,String(t.degrees),...N(t.origin?.x),...N(t.origin?.y),...N(t.velocity)];case`transform`:return[`transform`,String(t.origin?.x),String(t.origin?.y),String(t.delta?.x),String(t.delta?.y),String(t.scale),String(t.degrees),...N(t.durationMs)];default:throw new e(`INVALID_ARGS`,`gesture requires pan, fling, swipe, pinch, rotate, or transform`)}}function fa(e){return[`swipe`,F(e.preset,`gesture swipe requires preset`),...N(e.durationMs)]}function pa(e){return[`pan`,String(e.x),String(e.y),String(e.dx),String(e.dy),...N(e.durationMs)]}function ma(e){let t=e.durationMs===void 0?e.distance:e.distance??180;return[`fling`,e.direction,String(e.x),String(e.y),...N(t),...N(e.durationMs)]}function ha(e){return[`pinch`,String(e.scale),...N(e.x),...N(e.y)]}function ga(e){ya(e);let t=e.x===void 0||e.y===void 0?[]:[String(e.x),String(e.y)];return[`rotate`,String(e.degrees),...t,...N(e.velocity)]}function _a(e){return[`transform`,String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...N(e.durationMs)]}function va(t,n){let r=t[0],i=t.slice(1),a=O(n);switch(r){case`pan`:return{...a,kind:r,origin:{x:Number(i[0]),y:Number(i[1])},delta:{x:Number(i[2]),y:Number(i[3])},durationMs:j(i[4])};case`fling`:return{...a,kind:r,direction:i[0],origin:{x:Number(i[1]),y:Number(i[2])},distance:j(i[3]),durationMs:j(i[4])};case`swipe`:return{...a,kind:r,preset:i[0],durationMs:j(i[1])};case`pinch`:return{...a,kind:r,scale:Number(i[0]),origin:i[1]===void 0||i[2]===void 0?void 0:{x:Number(i[1]),y:Number(i[2])}};case`rotate`:return{...a,kind:r,degrees:Number(i[0]),origin:i[1]===void 0||i[2]===void 0?void 0:{x:Number(i[1]),y:Number(i[2])},velocity:j(i[3])};case`transform`:return{...a,kind:r,origin:{x:Number(i[0]),y:Number(i[1])},delta:{x:Number(i[2]),y:Number(i[3])},scale:Number(i[4]),degrees:Number(i[5]),durationMs:j(i[6])};default:throw new e(`INVALID_ARGS`,`gesture requires pan, fling, swipe, pinch, rotate, or transform`)}}function ya(t){if(t.x===void 0&&t.y!==void 0||t.x!==void 0&&t.y===void 0)throw new e(`INVALID_ARGS`,`gesture rotate center requires both x and y`)}const K={click:(e,t)=>({...O(t),...kn(t),...Mn(t),...jn(t),target:Nn(Be(e)),button:t.clickButton,verify:t.verify}),press:(e,t)=>({...O(t),...kn(t),...Mn(t),...jn(t),target:Nn(Be(e)),verify:t.verify}),longpress:(e,t)=>{let n=ba(e);return{...O(t),...kn(t),...jn(t),target:Nn(n),durationMs:n.durationMs}},swipe:(e,t)=>({...O(t),from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},durationMs:j(e[4]),count:t.count,pauseMs:t.pauseMs,pattern:t.pattern}),focus:(e,t)=>({...O(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...O(t),text:e.join(` `),delayMs:t.delayMs}),fill:(e,t)=>{let n=We(e);return{...O(t),...kn(t),...jn(t),target:Nn(n.target),text:n.text,delayMs:t.delayMs,verify:t.verify}},scroll:(e,t)=>({...O(t),direction:Ta(e[0]),amount:j(e[1]),pixels:t.pixels,durationMs:t.durationMs}),get:(e,t)=>({...O(t),...kn(t),format:Bn(e[0]),target:Nn(zn(e.slice(1)))})},q={click:e=>D(l.click,Pn(e),{...e,clickButton:e.button}),press:E(l.press,e=>Pn(e)),longpress:E(l.longPress,e=>xa(e)),swipe:E(l.swipe,wa),focus:E(l.focus,e=>[String(e.x),String(e.y)]),type:E(l.type,e=>Sa(e)),fill:E(l.fill,e=>Ca(e)),scroll:E(l.scroll,e=>[F(e.direction,`scroll requires direction`),...N(e.amount)]),get:E(l.get,e=>[F(e.format,`get requires format`),...Fn(e)])};function ba(e){let t=Ea(e);return{...Be(t.target),...t.durationMs===void 0?{}:{durationMs:t.durationMs}}}function xa(e){return[...Pn(e),...N(e.durationMs)]}function Sa(e){return[e.text]}function Ca(e){return[...Pn(e),e.text]}function wa(e){return[String(e.from?.x),String(e.from?.y),String(e.to?.x),String(e.to?.y),...N(e.durationMs)]}function Ta(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)}`)}function Ea(e){if(Wn(e[0])&&Wn(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&&Wn(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}function Da(e){let t=e.result;return e.format===`text`?{data:t,text:typeof t.text==`string`?t.text:``}:e.format===`attrs`?{data:t,text:JSON.stringify(t.node??{},null,2)}:Ia(t)}function Oa(e){let t=e,n=ce(t);return n?{data:t,text:n}:typeof t.text==`string`?{data:t,text:t.text}:typeof t.found==`boolean`?{data:t,text:`Found: ${t.found}`}:t.node?{data:t,text:JSON.stringify(t.node,null,2)}:Ia(t)}function ka(e){let t=e;return{data:t,text:`Passed: is ${t.predicate??`assertion`}`}}function Aa(e){let t=e,n=t.ref??``,r=t.x,i=t.y;if(!n||typeof r!=`number`||typeof i!=`number`){let e=Ia(t);return{data:e.data,text:Ma(e.text,t.settle)}}return{data:t,text:Ma(`Tapped @${n} (${r}, ${i})`,t.settle)}}function ja(e){let t=e,n=Ia(t);return{data:n.data,text:Ma(n.text,t.settle)}}function Ma(e,t){return`${e??``}${Na(t)}`}function Na(e){if(!e||typeof e!=`object`)return``;let t=e,n=[Fa(t),...Pa(t.diff)];return t.hint&&n.push(`hint: ${t.hint}`),`\n${n.join(`
4
+ `)}`}function Pa(e){let t=(e?.lines??[]).map(e=>`${e.kind===`removed`?`-`:`+`} ${e.text??``}`);return e?.truncated&&t.push(`… changed lines truncated`),t}function Fa(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`}const J={click:z(Aa),press:z(Aa),fill:z(ja),longpress:z(ja),get:({input:e,result:t})=>Da({result:t,format:e.format}),is:z(ka),find:z(Oa)};function Ia(e){return V(e)}const La={find:(e,t)=>Va(e,t),is:(e,t)=>Ha(e,t)},Ra={is:E(l.is,e=>za(e)),find:e=>D(l.find,Ba(e),{...e,findFirst:e.first,findLast:e.last})};function za(e){return[e.predicate,e.selector,...e.predicate===`text`?[e.value]:[]]}function Ba(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`:return e.action?[...t,e.action]:t;case`getText`:return[...t,`get`,`text`];case`getAttrs`:return[...t,`get`,`attrs`];case`wait`:return[...t,`wait`,...N(e.timeoutMs)];case`fill`:case`type`:return[...t,e.action,e.value]}}function Va(t,n){let r={...Wa(n),...On(n),first:n.findFirst,last:n.findLast},i=Ua(t[0]),a=i!==void 0,o=a?t[1]:t[0],s=a?2:1,c=t[s];if(c===void 0)return{...r,locator:i,query:Ga(o)};if(c===`get`){let n=t[s+1];if(n===`text`)return{...r,locator:i,query:Ga(o),action:`getText`};if(n===`attrs`)return{...r,locator:i,query:Ga(o),action:`getAttrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(c===`wait`)return{...r,locator:i,query:Ga(o),action:`wait`,timeoutMs:j(t[s+1])};if(c===`fill`||c===`type`)return{...r,locator:i,query:Ga(o),action:c,value:t.slice(s+1).join(` `)};if(c===`click`||c===`focus`||c===`exists`)return{...r,locator:i,query:Ga(o),action:c};throw new e(`INVALID_ARGS`,`Unsupported find action: ${c}`)}function Ha(t,n){let r={...An(n),...On(n)},i=pt(t),a=i[0];if(a!==`text`&&a!==`visible`&&a!==`hidden`&&a!==`exists`&&a!==`editable`&&a!==`selected`&&a!==`focused`)throw new e(`INVALID_ARGS`,ft,{hint:mt});let o=Vn(i.slice(1),{preferTrailingValue:a===`text`});return a===`text`?{...r,predicate:a,selector:o.selectorExpression,value:o.rest.join(` `)}:{...r,predicate:a,selector:o.selectorExpression}}function Ua(e){if(e===`text`||e===`label`||e===`value`||e===`role`||e===`id`)return e}function Wa(e){return{depth:e.snapshotDepth,raw:e.snapshotRaw}}function Ga(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>`,positionalArgs:[`subcommand`,`target`],allowedFlags:[...U]},find:{usageOverride:`find <locator|text> <action> [value] [--first|--last]`,helpDescription:`Find by text/label/value/role/id and run action`,summary:`Find an element and act`,positionalArgs:[`query`,`action`,`value?`],allowsExtraPositionals:!0,allowedFlags:[`snapshotDepth`,`snapshotRaw`,`findFirst`,`findLast`]},is:{positionalArgs:[`predicate`,`selector`,`value?`],allowsExtraPositionals:!0,allowedFlags:[...U]},click:{usageOverride:`click <x y|@ref|selector>`,positionalArgs:[`target`],allowsExtraPositionals:!0,allowedFlags:[...Tr,`clickButton`,...Ja(`click`),...U]},press:{usageOverride:`press <x y|@ref|selector>`,helpDescription:`Short press a semantic UI target by ref, selector, or point. For native context menus or hold gestures, use longpress <target> <durationMs> instead of press --hold-ms.`,positionalArgs:[`targetOrX`,`y?`],allowsExtraPositionals:!0,allowedFlags:[...Tr,...Ja(`press`),...U]},longpress:{usageOverride:`longpress <x y|@ref|selector> [durationMs]`,helpDescription:`Open native context menus or long-press targets by ref, selector, or point. Duration is positional, for example longpress @e12 800 or longpress 300 500 800.`,positionalArgs:[`targetOrX`,`yOrDurationMs?`,`durationMs?`],allowsExtraPositionals:!0,allowedFlags:[...Ja(`longpress`),...U]},swipe:{helpDescription:`Swipe coordinates with optional repeat pattern`,positionalArgs:[`x1`,`y1`,`x2`,`y2`,`durationMs?`],allowedFlags:[`count`,`pauseMs`,`pattern`]},gesture:{usageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform> ...`,listUsageOverride:`gesture <pan|fling|swipe|pinch|rotate|transform> ...`,helpDescription:`Run touch gestures: pan <x> <y> <dx> <dy> [durationMs], fling <up|down|left|right> <x> <y> [distance] [durationMs], swipe <left|right|left-edge|right-edge> [durationMs], pinch <scale> [x] [y], rotate <degrees> [x] [y] [velocity], or transform <x> <y> <dx> <dy> <scale> <degrees> [durationMs]. 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.`,summary:`Run pan, fling, swipe, pinch, rotate, or transform gestures`,positionalArgs:[`pan|fling|swipe|pinch|rotate|transform`,`args?`],allowsExtraPositionals:!0},focus:{positionalArgs:[`x`,`y`]},type:{positionalArgs:[`text`],allowsExtraPositionals:!0,allowedFlags:[`delayMs`]},fill:{usageOverride:`fill <x> <y> <text> | fill <@ref|selector> <text>`,positionalArgs:[`targetOrX`,`yOrText`,`text?`],allowsExtraPositionals:!0,allowedFlags:[...U,`delayMs`,...Ja(`fill`)]},scroll:{usageOverride:`scroll <direction|top|bottom> [amount] [--pixels <n>] [--duration-ms <ms>]`,helpDescription:`Scroll in a direction, or toward the top/bottom edge of scrollable content.`,summary:`Scroll in a direction or to an edge`,positionalArgs:[`directionOrEdge`,`amount?`],allowedFlags:[`pixels`,`durationMs`]}},{gesture:Ka,...qa}=ua;function Ja(e){let t=[];return ee(e)&&t.push(`verify`),re(e)&&t.push(...Er),t}const Ya=R(X(`click`),(e,t)=>e.interactions.click(co(t))),Xa=R(X(`press`),(e,t)=>e.interactions.press(lo(t))),Za=R(X(`fill`),(e,t)=>e.interactions.fill(uo(t))),Qa=R(X(`longpress`),(e,t)=>e.interactions.longPress(fo(t))),$a=R(X(`swipe`),(e,t)=>e.interactions.swipe(t)),eo=R(X(`focus`),(e,t)=>e.interactions.focus(t)),to=R(X(`type`),(e,t)=>e.interactions.type(t)),no=R(X(`scroll`),(e,t)=>e.interactions.scroll(t)),ro=R(X(`get`),(e,t)=>e.interactions.get(mo(t))),io=R(X(`is`),(e,t)=>e.interactions.is(t)),ao=R(X(`find`),(e,t)=>e.interactions.find(t)),oo=R(X(`gesture`),async(e,t)=>{switch(t.kind){case`pan`:return await e.interactions.pan(ho(t));case`fling`:return await e.interactions.fling(go(t));case`swipe`:return await e.interactions.swipeGesture(_o(t));case`pinch`:return await e.interactions.pinch(vo(t));case`rotate`:return await e.interactions.rotateGesture(yo(t));case`transform`:return await e.interactions.transformGesture(bo(t))}}),so=L({name:`interaction`,clientSurface:!1,commands:[I({name:`click`,metadata:X(`click`),definition:Ya,cliSchema:Y.click,cliReader:K.click,daemonWriter:q.click,cliOutputFormatter:J.click}),I({name:`press`,metadata:X(`press`),definition:Xa,cliSchema:Y.press,cliReader:K.press,daemonWriter:q.press,cliOutputFormatter:J.press}),I({name:`fill`,metadata:X(`fill`),definition:Za,cliSchema:Y.fill,cliReader:K.fill,daemonWriter:q.fill,cliOutputFormatter:J.fill}),I({name:`longpress`,metadata:X(`longpress`),definition:Qa,cliSchema:Y.longpress,cliReader:K.longpress,daemonWriter:q.longpress,cliOutputFormatter:J.longpress}),I({name:`swipe`,metadata:X(`swipe`),definition:$a,cliSchema:Y.swipe,cliReader:K.swipe,daemonWriter:q.swipe}),I({name:`focus`,metadata:X(`focus`),definition:eo,cliSchema:Y.focus,cliReader:K.focus,daemonWriter:q.focus}),I({name:`type`,metadata:X(`type`),definition:to,cliSchema:Y.type,cliReader:K.type,daemonWriter:q.type}),I({name:`scroll`,metadata:X(`scroll`),definition:no,cliSchema:Y.scroll,cliReader:K.scroll,daemonWriter:q.scroll}),I({name:`get`,metadata:X(`get`),definition:ro,cliSchema:Y.get,cliReader:K.get,daemonWriter:q.get,cliOutputFormatter:J.get}),I({name:`is`,metadata:X(`is`),definition:io,cliSchema:Y.is,cliReader:La.is,daemonWriter:Ra.is,cliOutputFormatter:J.is}),I({name:`find`,metadata:X(`find`),definition:ao,cliSchema:Y.find,cliReader:La.find,daemonWriter:Ra.find,cliOutputFormatter:J.find}),I({name:`gesture`,metadata:X(`gesture`),definition:oo,cliSchema:Y.gesture,cliReader:la.gesture,daemonWriter:ua.gesture,extraDaemonWriters:qa})]});function X(e){let t=oa.find(t=>t.name===e);if(!t)throw Error(`Missing interaction command metadata for ${e}`);return t}function co(e){return{...C(e),...dn(e.target),...mn(e),...pn(e),button:e.button,verify:e.verify,...po(e)}}function lo(e){return{...C(e),...dn(e.target),...mn(e),...pn(e),verify:e.verify,...po(e)}}function uo(e){return{...C(e),...dn(e.target),...mn(e),text:e.text,delayMs:e.delayMs,verify:e.verify,...po(e)}}function fo(e){return{...C(e),...dn(e.target),...mn(e),durationMs:e.durationMs,...po(e)}}function po(e){return{settle:e.settle,settleQuietMs:e.settleQuietMs,timeoutMs:e.timeoutMs}}function mo(e){return{...C(e),...fn(e.target),...mn(e),format:e.format}}function ho(e){return{...C(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,durationMs:e.durationMs}}function go(e){return{...C(e),direction:e.direction,x:e.origin.x,y:e.origin.y,distance:e.distance,durationMs:e.durationMs}}function _o(e){return{...C(e),preset:e.preset,durationMs:e.durationMs}}function vo(e){return{...C(e),scale:e.scale,x:e.origin?.x,y:e.origin?.y}}function yo(e){return{...C(e),degrees:e.degrees,x:e.origin?.x,y:e.origin?.y,velocity:e.velocity}}function bo(e){return{...C(e),x:e.origin.x,y:e.origin.y,dx:e.delta.x,dy:e.delta.y,scale:e.scale,degrees:e.degrees,durationMs:e.durationMs}}function xo(e){return{data:{devices:e.map(Pe)},text:e.map(Po).join(`
5
+ `)}}function So(e){return{data:{device:Pe(e.device),availableCommands:e.availableCommands},text:[`${Po(e.device)} supports ${e.availableCommands.length} commands:`,e.availableCommands.join(` `)].join(`
6
+ `)}}function Co(e){return{data:{apps:e.result},stderr:e.appsFilter===`all`?`Showing all apps, including system apps.
7
7
  `:`Showing user-installed apps. Use --all to include system apps.
8
8
  `,text:e.result.length>0?e.result.join(`
9
- `):e.appsFilter===`all`?`No apps found.`:`No user-installed apps found.`}}function yo(e){if(`stateDir`in e)return{data:e,text:e.stateDir};let t={sessions:e.sessions.map(qe)};return{data:t,text:JSON.stringify(t,null,2)}}function bo(e){let t=Ue(e),n=[je(t)].filter(e=>!!e);return typeof t.sessionStateDir==`string`&&n.push(`Session state: ${t.sessionStateDir}`),{data:t,text:n.join(`
10
- `)||null}}function xo(e){return V(Se(e))}function So(e){if(Co(e))return{data:e,text:e.artifacts.length>0?e.artifacts.map(jo).join(`
11
- `):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=Mo(e);return n&&t.push(`Retry: ${n}`),{data:e,text:e.cloudArtifacts.length>0?e.cloudArtifacts.map(Ao).join(`
9
+ `):e.appsFilter===`all`?`No apps found.`:`No user-installed apps found.`}}function wo(e){if(`stateDir`in e)return{data:e,text:e.stateDir};let t={sessions:e.sessions.map(Fe)};return{data:t,text:JSON.stringify(t,null,2)}}function To(e){let t=at(e),n=[ce(t)].filter(e=>!!e);return typeof t.sessionStateDir==`string`&&n.push(`Session state: ${t.sessionStateDir}`),{data:t,text:n.join(`
10
+ `)||null}}function Eo(e){return V(Je(e))}function Do(e){if(Oo(e))return{data:e,text:e.artifacts.length>0?e.artifacts.map(Io).join(`
11
+ `):e.message??`No daemon artifacts available.`};let t=[e.message??`No cloud artifacts available for ${e.provider}.`],n=Lo(e);return n&&t.push(`Retry: ${n}`),{data:e,text:e.cloudArtifacts.length>0?e.cloudArtifacts.map(Fo).join(`
12
12
  `):t.join(`
13
- `)}}function Co(e){return`source`in e&&e.source===`daemon`}function wo(e){return V(le(e))}function To(e){return V(Xe(e))}function Eo(e){let t=e,n=t.platform??`unknown`;return{data:t,text:`Boot ready: ${t.device??t.id??`unknown`} (${n})`}}function Do(e){let t=e,n=t.platform??`unknown`,r=t.device??t.id??`unknown`,i=t.shutdown;return{data:t,text:`${i&&typeof i==`object`&&`success`in i&&i.success===!0?`Shutdown`:`Shutdown failed`}: ${r} (${n})`}}function Oo(e){let t=e,n=[`Doctor: ${typeof t.status==`string`?t.status:`unknown`}`],r=No(t.checks);if(Ot()){let e=typeof t.summary==`string`?t.summary:void 0;e&&n.push(e)}else if(r.length===0){let e=typeof t.summary==`string`?t.summary:`No blockers found.`;n.push(e)}else for(let e of r)n.push(Pe(e)),n.push(...ue(e));return{data:t,text:n.join(`
14
- `)}}const Z={boot:z(Eo),shutdown:z(Do),devices:z(go),capabilities:z(_o),doctor:z(Oo),apps:({input:e,result:t})=>vo({result:t,appsFilter:e.appsFilter}),session:z(yo),artifacts:z(So),open:z(bo),close:z(xo),install:z(wo),reinstall:z(wo),"install-from-source":z(To),prepare:B,viewport:B};function ko(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``;return`${e.name} (${e.platform}${t}${n})${r}`}function Ao(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function jo(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Mo(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function No(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const Po=W(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:p(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:p(`Cloud provider session id or ARN.`)}),Fo=I({name:`artifacts`,metadata:Po,definition:R(Po,(e,t)=>e.sessions.artifacts(t)),cliSchema:{summary:`List daemon or cloud provider session artifacts`,usageOverride:`artifacts [provider-session-id] [--provider <name>]`,positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...O(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:E(l.artifacts),cliOutputFormatter:Z.artifacts}),Io=W(`apps`,`List installed apps.`,{appsFilter:_([`user-installed`,`all`])}),Lo=W(`open`,`Open an app, deep link, URL, or platform surface.`,{app:p(`App name, bundle id, package, or URL.`),url:p(`Optional URL passed with an app shell.`),surface:_(Ee),activity:p(`Android activity name.`),launchConsole:p(`Launch console mode.`),launchArgs:Bt(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:g(`Force relaunch.`),saveScript:v({oneOf:[It(),Nt()]}),deviceHub:g(`Use Xcode Device Hub when surfacing Apple simulators.`),noRecord:g(`Do not record this action.`)}),Ro=W(`close`,`Close an app or end the active session.`,{app:p(`Optional app to close.`),shutdown:g(`Shutdown the session/device where supported.`),saveScript:v({oneOf:[It(),Nt()]})}),zo=R(Io,(e,t)=>e.apps.list(t)),Bo=R(Lo,(e,t)=>e.apps.open(t)),Vo=R(Ro,(e,t)=>t.app?e.apps.close(t):e.sessions.close(es(t))),Ho={helpDescription:`List user-installed apps; use --all to include system/OEM apps`,summary:`List installed apps`,allowedFlags:[`appsFilter`],defaults:{appsFilter:Tt}},Uo={helpDescription:`Boot device/simulator; optionally launch app or deep link URL. 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.`,summary:`Open an app, deep link or URL, save replays`,positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`saveScript`,`noRecord`,`relaunch`,`surface`]},Wo={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`shutdown`]},Go=(e,t)=>({...O(t),appsFilter:wt(t.appsFilter)}),Ko=(e,t)=>({...O(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,deviceHub:t.deviceHub,noRecord:t.noRecord}),qo=(e,t)=>({...O(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),Jo=E(l.apps),Yo=E(l.open,ts),Xo=E(l.close,e=>M(e.app)),Zo=I({name:`apps`,metadata:Io,definition:zo,cliSchema:Ho,cliReader:Go,daemonWriter:Jo,cliOutputFormatter:Z.apps}),Qo=I({name:`open`,metadata:Lo,definition:Bo,cliSchema:Uo,cliReader:Ko,daemonWriter:Yo,cliOutputFormatter:Z.open}),$o=I({name:`close`,metadata:Ro,definition:Vo,cliSchema:Wo,cliReader:qo,daemonWriter:Xo,cliOutputFormatter:Z.close});function es(e){let{app:t,...n}=e;return n}function ts(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const ns=W(`devices`,`List available devices.`,{}),rs=W(`capabilities`,`List commands supported by the selected device.`,{}),is=W(`boot`,`Boot or prepare a selected device without using CLI positional arguments.`,{headless:g(`Boot without showing simulator UI when supported.`)}),as=W(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),os=R(ns,(e,t)=>e.devices.list(t)),ss=R(rs,(e,t)=>e.devices.capabilities(t)),cs=R(is,(e,t)=>e.devices.boot(t)),ls=R(as,(e,t)=>e.devices.shutdown(t)),us={summary:`Boot target device/simulator`,allowedFlags:[`headless`]},ds={summary:`List supported commands for the selected device`,helpDescription:`List command names supported by the selected session device or explicit --platform/--device/--udid/--serial target.`},fs={summary:`Shutdown target simulator/emulator`},ps=(e,t)=>O(t),ms=(e,t)=>({...O(t),headless:t.headless}),hs=E(l.devices),gs=E(l.capabilities),_s=E(l.boot),vs=E(l.shutdown),ys=[I({name:`devices`,metadata:ns,definition:os,cliReader:ps,daemonWriter:hs,cliOutputFormatter:Z.devices}),I({name:`capabilities`,metadata:rs,definition:ss,cliSchema:ds,cliReader:ps,daemonWriter:gs,cliOutputFormatter:Z.capabilities}),I({name:`boot`,metadata:is,definition:cs,cliSchema:us,cliReader:ms,daemonWriter:_s,cliOutputFormatter:Z.boot}),I({name:`shutdown`,metadata:as,definition:ls,cliSchema:fs,cliReader:ps,daemonWriter:vs,cliOutputFormatter:Z.shutdown})],bs=W(`doctor`,`Diagnose device, app, Metro, and React Native readiness before a run.`,{targetApp:p(`Installed app package/bundle id or app name to verify without opening a session.`),remote:g(`Check remote connection setup instead of local device inventory.`)}),xs=I({name:`doctor`,metadata:bs,definition:R(bs,(e,t)=>e.command.doctor(t)),cliSchema:{usageOverride:`doctor [--platform ios|android|macos|linux|web|apple] [--app <id-or-name>] [--remote]`,helpDescription:`Preflight for QA and dogfood runs. Reports local device inventory, active sessions, optional app discovery, scoped toolchain info, and Metro reachability inferred from cwd/runtime. On iOS simulators it also warms the XCTest runner build cache in the background when missing, so the first open on a fresh machine skips the runner build — run doctor first on new setups. 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.`,summary:`Preflight device, app, Metro, and RN/Expo readiness`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...O(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:E(l.doctor),cliOutputFormatter:Z.doctor});function Ss(t,n=`--github-actions-artifact`){let r=t.indexOf(`:`);if(r<=0||r===t.length-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:i,repo:a}=Ts(t.slice(0,r),n);return ws(i,a,t.slice(r+1),`${n} artifact`)}function Cs(t,n){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`${n} installSource must be an object.`);let r=t;if(Ds(r.type,`${n} installSource.type`)!==`github-actions-artifact`)throw new e(`INVALID_ARGS`,`${n} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=Ts(Ds(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return ws(i,a,r.artifact,`${n} installSource.artifact`)}function ws(e,t,n,r){return typeof n==`number`||ks(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:Os(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:Ds(n,r)}}function Ts(t,n){let r=t.indexOf(`/`);if(r<=0||r===t.length-1||t.indexOf(`/`,r+1)!==-1)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);let i={owner:t.slice(0,r).trim(),repo:t.slice(r+1).trim()};if(!i.owner||!i.repo)throw new e(`INVALID_ARGS`,`${n} must use owner/repo.`);return i}function Es(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function Ds(t,n){let r=Es(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function Os(t,n){let r=typeof t==`number`?t:typeof t==`string`?Number(t):NaN;if(!Number.isInteger(r))throw new e(`INVALID_ARGS`,`${n} must be an integer.`);return r}function ks(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const As=W(`install`,`Install an app binary.`,{app:p(`Optional app identifier hint.`),appPath:f(p(`Path to app binary.`))}),js=W(`reinstall`,`Reinstall an app binary.`,{app:f(p()),appPath:f(p(`Path to app binary.`))}),Ms=W(`install-from-source`,`Install an app from a structured source.`,{source:f(v(Rt(`Install source object.`))),retainPaths:g(),retentionMs:h()}),Ns=R(As,(e,t)=>e.apps.install(t)),Ps=R(js,(e,t)=>e.apps.reinstall(t)),Fs=R(Ms,(e,t)=>e.apps.installFromSource(t)),Is={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},Ls={positionalArgs:[`app`,`path`]},Rs={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,listUsageOverride:`install-from-source`,helpDescription:`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,summary:`Install app builds from URLs, remote source specs, or CI artifacts`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},zs=(e,t)=>Gs(e,t),Bs=(e,t)=>Ks(e,t),Vs=(e,t)=>({...O(t),source:Ys(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),Hs=E(l.install,e=>qs(e.app,e.appPath)),Us=E(l.reinstall,e=>Js(e.app,e.appPath)),Ws=[I({name:`install`,metadata:As,definition:Ns,cliSchema:Is,cliReader:zs,daemonWriter:Hs,cliOutputFormatter:Z.install}),I({name:`reinstall`,metadata:js,definition:Ps,cliSchema:Ls,cliReader:Bs,daemonWriter:Us,cliOutputFormatter:Z.reinstall}),I({name:`install-from-source`,metadata:Ms,definition:Fs,cliSchema:Rs,cliReader:Vs,daemonWriter:e=>D(c.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function Gs(e,t){let[n,r]=e,i=r!==void 0;return{...O(t),...i?{app:P(n,`install requires app`)}:{},appPath:P(i?r:n,`install requires path`)}}function Ks(e,t){return{...O(t),app:P(e[0],`reinstall requires app`),appPath:P(e[1],`reinstall requires path`)}}function qs(e,t){let n=F(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function Js(e,t){return[F(e,`missing first positional`),F(t,`missing second positional`)]}function Ys(t,n){let r=t[0]?.trim();if(t.length>1)throw new e(`INVALID_ARGS`,`install-from-source accepts either one <url> positional or --github-actions-artifact`);let i=n.githubActionsArtifact?Ss(n.githubActionsArtifact):void 0,a=n.installSource;if(+!!r+ +!!i+ +!!a!=1)throw new e(`INVALID_ARGS`,`install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource`);if(!r&&n.header&&n.header.length>0)throw new e(`INVALID_ARGS`,`install-from-source --header is only supported for URL sources`);return i||a||{kind:`url`,url:r,headers:Xs(n.header)}}function Xs(t){if(!t||t.length===0)return;let n={};for(let r of t){let t=r.indexOf(`:`);if(t<=0)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Expected "name:value".`);let i=r.slice(0,t).trim(),a=r.slice(t+1).trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid --header value "${r}". Header name cannot be empty.`);n[i]=a}return n}const Zs=W(`prepare`,`Prepare platform helper infrastructure.`,{action:f(_([`ios-runner`])),timeoutMs:h(`Maximum wall-clock time for the prepare command.`)}),Qs=I({name:`prepare`,metadata:Zs,definition:R(Zs,(e,t)=>e.command.prepare(t)),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos [--timeout <ms>]`,listUsageOverride:`prepare`,helpDescription:`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.`,summary:`Pre-warm platform helpers, especially the iOS/macOS XCTest runner before Apple automation`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...O(t),action:P(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:E(l.prepare,e=>[F(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),$s=W(`push`,`Deliver a push payload.`,{app:f(p()),payload:f(v({oneOf:[Nt(),Rt()]}))}),ec=W(`trigger-app-event`,`Trigger an app-defined event.`,{event:f(p()),payload:zt()}),tc=R($s,(e,t)=>e.apps.push(t)),nc=R(ec,(e,t)=>e.apps.triggerEvent(t)),rc={listUsageOverride:`push`,helpDescription:`Deliver push notification payloads to an installed app.`,summary:`Deliver push notification payloads to an installed app`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},ic={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,helpDescription:`Invoke app-defined automation or test events with an optional structured payload.`,summary:`Invoke app-defined automation/test events with optional structured payloads`,positionalArgs:[`event`,`payloadJson?`]},ac=(e,t)=>({...O(t),app:P(e[0],`push requires bundleOrPackage`),payload:P(e[1],`push requires payloadOrJson`)}),oc=(e,t)=>({...O(t),event:P(e[0],`trigger-app-event requires event`),payload:e[1]?Ln(e[1],`trigger-app-event payload`):void 0}),sc=E(l.push,e=>uc(e)),cc=E(l.triggerAppEvent,e=>dc(e)),lc=[I({name:`push`,metadata:$s,definition:tc,cliSchema:rc,cliReader:ac,daemonWriter:sc}),I({name:`trigger-app-event`,metadata:ec,definition:nc,cliSchema:ic,cliReader:oc,daemonWriter:cc})];function uc(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function dc(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}const fc=W(`session`,`List active sessions or print daemon state directory.`,{action:_([`list`,`state-dir`],`list shows active sessions; state-dir prints the resolved daemon state directory without contacting the daemon.`)}),pc=I({name:`session`,metadata:fc,definition:R(fc,async(e,{action:t,...n})=>t===`state-dir`?{stateDir:await e.sessions.stateDir(n)}:{sessions:await e.sessions.list(n)}),cliSchema:{usageOverride:`session list | session state-dir`,listUsageOverride:`session`,helpDescription:`List active sessions or print the effective daemon state directory`,positionalArgs:[`list|state-dir?`]},cliReader:(e,t)=>({...O(t),action:mc(e[0])}),cliOutputFormatter:Z.session});function mc(t){let n=t??`list`;if(n===`list`||n===`state-dir`)return n;throw new e(`INVALID_ARGS`,`session only supports list or state-dir`)}const hc=W(`viewport`,`Resize the active web viewport.`,{width:f(h(`Viewport width in CSS pixels.`,{min:1})),height:f(h(`Viewport height in CSS pixels.`,{min:1}))}),gc=I({name:`viewport`,metadata:hc,definition:R(hc,(e,t)=>e.command.viewport(t)),cliSchema:{helpDescription:`Resize the active web viewport before taking snapshots or screenshots. Useful for fixed-layout or 100vh apps where changing the viewport reveals different content.`,summary:`Resize the active web viewport for the current session`,positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...O(t),width:Je(e[0],`width`),height:Je(e[1],`height`)}),daemonWriter:E(l.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),_c=L({name:`management`,commands:[...ys,Fo,xs,Qs,Zo,pc,Qo,$o,gc,...Ws,...lc]});function vc(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const yc={metro:({input:e,result:t})=>vc({result:t,action:e.action})},bc=`metro`,xc=W(bc,`Prepare Metro runtime or reload React Native apps.`,{action:f(_([`prepare`,`reload`])),projectRoot:p(),kind:v(Nt()),publicBaseUrl:p(),proxyBaseUrl:p(),bearerToken:p(),bridgeScope:v({type:`object`,additionalProperties:!0}),launchUrl:p(),port:h(),listenHost:p(),statusHost:p(),startupTimeoutMs:h(),probeTimeoutMs:h(),reuseExisting:g(),installDependenciesIfNeeded:g(),runtimeFilePath:p(),logPath:p(),metroHost:p(),metroPort:h(),bundleUrl:p(),timeoutMs:h()}),Sc=L({name:`metro`,commands:[I({name:bc,metadata:xc,definition:R(xc,async(e,t)=>t.action===`prepare`?await e.metro.prepare(Cc(t)):await e.metro.reload(Tc(t))),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo]
15
- agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,listUsageOverride:`metro`,helpDescription:`Prepare a local Metro runtime or ask Metro to reload connected React Native apps`,summary:`Prepare Metro reachability for React Native/Expo apps or trigger app reloads`,positionalArgs:[`prepare|reload`],allowedFlags:[...yr,...vr]},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:Ec(n.kind??n.metroKind),port:n.metroPreparePort,listenHost:n.metroListenHost,statusHost:n.metroStatusHost,publicBaseUrl:n.metroPublicBaseUrl,proxyBaseUrl:n.metroProxyBaseUrl,bearerToken:n.metroBearerToken,bridgeScope:n.tenant&&n.runId&&n.leaseId?{tenantId:n.tenant,runId:n.runId,leaseId:n.leaseId}:void 0,startupTimeoutMs:n.metroStartupTimeoutMs,probeTimeoutMs:n.metroProbeTimeoutMs,reuseExisting:n.metroNoReuseExisting?!1:void 0,installDependenciesIfNeeded:n.metroNoInstallDeps?!1:void 0,runtimeFilePath:n.metroRuntimeFile}},cliOutputFormatter:yc.metro})]});function Cc(e){return{projectRoot:e.projectRoot,kind:e.kind,publicBaseUrl:e.publicBaseUrl,proxyBaseUrl:e.proxyBaseUrl,bearerToken:e.bearerToken,bridgeScope:e.bridgeScope??wc(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 wc(e){return e.tenant&&e.runId&&e.leaseId?{tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId}:void 0}function Tc(e){return{metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,timeoutMs:e.timeoutMs}}function Ec(t){if(t!==void 0){if(t===`auto`||t===`react-native`||t===`expo`)return t;throw new e(`INVALID_ARGS`,`metro prepare --kind must be auto, react-native, or expo`)}}const Dc=[`started`,`stopped`,`marked`,`cleared`,`restarted`,`removedRotatedFiles`];function Oc(e){return{data:e,text:e.path,stderr:Bc([Rc(e,[`active`,`state`,`backend`,`sizeBytes`]),Nc(e),e.hint,zc(e.notes)])}}function kc(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(...Fc(e));return{data:e,text:t.join(`
16
- `),stderr:Bc([Rc(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),zc(e.notes)])}}function Ac(e){return{data:e,text:[`Audio probe: ${String(e.state??`stopped`)} heard=${String(e.heard===!0)}`,Mc(`rmsDbfs`,e.rmsDbfs),Mc(`peakDbfs`,e.peakDbfs)].filter(e=>!!e).join(`
17
- `),stderr:Bc([Rc(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),zc(e.notes)])}}const jc={logs:z(Oc),network:z(kc),audio:z(Ac)};function Mc(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 Nc(e){return Dc.map(t=>Pc(t,e[t])).filter(Boolean).join(` `)||void 0}function Pc(e,t){return t==null?``:`${e}=${t}`}function Fc(e){let t=e.method??`HTTP`,n=e.url??`<unknown-url>`,r=e.status===void 0?``:` status=${e.status}`,i=[`${e.timestamp?`${e.timestamp} `:``}${t} ${n}${r}${e.durationMs===void 0?``:` durationMs=${e.durationMs}`}`];return e.headers?Lc(i,`headers`,e.headers):(Ic(i,`request headers`,e.requestHeaders),Ic(i,`response headers`,e.responseHeaders)),Lc(i,`request`,e.requestBody),Lc(i,`response`,e.responseBody),i}function Ic(e,t,n){!n||Object.keys(n).length===0||e.push(` ${t}: ${JSON.stringify(n)}`)}function Lc(e,t,n){n!==void 0&&e.push(` ${t}: ${n}`)}function Rc(e,t){return t.map(t=>e[t]!==void 0&&e[t]!==null?`${t}=${e[t]}`:``).filter(Boolean).join(` `)||void 0}function zc(e){let t=e?.filter(e=>e.length>0)??[];return t.length>0?t.join(`
18
- `):void 0}function Bc(e){return e.filter(e=>!!e).join(`
19
- `)||void 0}const Vc=`logs`,Hc=`network`,Uc=`audio`,Wc=[`dump`,`log`],Gc=[`probe`],Kc=[`start`,`status`,`stop`],qc=W(Vc,`Manage session app logs.`,{action:_(We),message:p(),restart:g()}),Jc=W(Hc,`Show recent HTTP traffic.`,{action:_(Wc),limit:h(),include:_(s)}),Yc=W(Uc,`Probe audio levels.`,{action:_(Gc),probeAction:_(Kc),durationMs:h(`Probe duration in milliseconds.`),bucketMs:h(`Audio level bucket size in milliseconds.`)}),Xc=R(qc,(e,t)=>e.observability.logs(t)),Zc=R(Jc,(e,t)=>e.observability.network(t)),Qc=R(Yc,(e,t)=>e.observability.audio(t)),$c=L({name:`observability`,commands:[I({name:Vc,metadata:qc,definition:Xc,cliSchema:{usageOverride:`logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]`,helpDescription:`Session app log info, start/stop streaming, diagnostics, and markers`,summary:`Manage session app logs`,positionalArgs:[`path|start|stop|clear|doctor|mark`,`message?`],allowsExtraPositionals:!0,allowedFlags:[`restart`]},cliReader:(e,t)=>({...O(t),action:rl(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:E(Vc,e=>el(e)),cliOutputFormatter:jc.logs}),I({name:Hc,metadata:Jc,definition:Zc,cliSchema:{usageOverride:`network dump [limit] [summary|headers|body|all] [--include summary|headers|body|all] | network log [limit] [summary|headers|body|all] [--include summary|headers|body|all]`,listUsageOverride:`network`,helpDescription:`Dump recent HTTP(s) traffic parsed from the session app log`,summary:`Inspect HTTP(S) traffic parsed from session app logs, including summaries, headers, and bodies`,positionalArgs:[`dump|log`,`limit?`,`include?`],allowedFlags:[`networkInclude`]},cliReader:(e,t)=>({...O(t),action:il(e[0]),limit:j(e[1]),include:t.networkInclude??al(e[2])}),daemonWriter:e=>D(Hc,tl(e),{...e,networkInclude:e.include}),cliOutputFormatter:jc.network}),I({name:Uc,metadata:Yc,definition:Qc,cliSchema:{usageOverride:`audio probe start [durationSeconds] [bucketMs] | audio probe status | audio probe stop`,listUsageOverride:`audio`,helpDescription:`Probe browser or host-rendered simulator/emulator audio as compact dBFS buckets`,summary:`Probe audio levels`,positionalArgs:[`probe`,`start|status|stop`,`durationSeconds?`,`bucketMs?`]},cliReader:(e,t)=>({...O(t),action:ol(e[0]),probeAction:sl(e[1]),durationMs:cl(e[2]),bucketMs:j(e[3])}),daemonWriter:e=>D(Uc,nl(e),e),cliOutputFormatter:jc.audio})]});function el(e){return[e.action??`path`,...M(e.message)]}function tl(e){return[...e.action?[e.action]:[],...N(e.limit)]}function nl(e){return[e.action??`probe`,e.probeAction??`status`,...N(e.durationMs),...N(e.bucketMs)]}function rl(e){if(e!==void 0)return Ke(We,e,{message:`logs requires path, start, stop, doctor, mark, or clear`})}function il(t){if(t!==void 0){if(t===`dump`||t===`log`)return t;throw new e(`INVALID_ARGS`,`network requires dump or log`)}}function al(e){if(e!==void 0)return Ke(s,e,{message:`network include must be summary, headers, body, or all`})}function ol(e){if(e!==void 0)return Ke(Gc,e,{message:`audio requires probe`})}function sl(e){if(e!==void 0)return Ke(Kc,e,{message:`audio probe requires start, status, or stop`})}function cl(e){let t=j(e);return t===void 0?void 0:Math.round(t*1e3)}function ll(e){let t=e;return{data:t,text:dl(t)}}const ul={perf:z(ll)};function dl(e){let t=hl(e);if(t)return t;let n=u(e.artifact)?e.artifact:void 0;return n?ml(n):fl(u(e.metrics)?e.metrics:void 0)}function fl(e){let t=u(e?.fps)?e.fps:void 0,n=Ml(e);if(!t)return Tl(n,`missing frame metric`);if(t.available===!1)return Tl(n,El(t));let r=Dl(t);return r?pl(t,r):Tl(n,`missing dropped-frame summary`)}function pl(e,t){let n=[`Frame health: ${t}`],r=Al(e);return r.length>0&&n.push(`Worst windows:`,...r),n.join(`
20
- `)}function ml(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?``:` (${Rl(r)})`;return n?`Memory artifact (${t}): ${n}${i}`:`Memory artifact (${t}): captured${i}`}function hl(e){return e.kind===`xctrace`?gl(e):yl(e)}function gl(e){let t=typeof e.perf==`string`?e.perf:void 0,n=_l(e);if(!(!t||!n||e.kind!==`xctrace`))return vl(n,typeof e.mode==`string`?e.mode:`capture`,t,e.template)}function _l(e){return typeof e.outPath==`string`?e.outPath:typeof e.reportPath==`string`?e.reportPath:void 0}function vl(e,t,n,r){let i=[e,`Perf ${t}: ${n}`];return typeof r==`string`&&i.push(`Template: ${r}`),i.join(`
21
- `)}function yl(e){let t=bl(e);if(t)return`Perf ${t.action}: ${t.kind} ${t.type}${xl(e)}${Sl(e)}${wl(e)}`}function bl(e){let t=Cl(e.action),n=Cl(e.kind),r=Cl(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function xl(e){let t=Cl(e.state);return t?` state=${t}`:``}function Sl(e){let t=Cl(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${Rl(n)})`}`}function Cl(e){return typeof e==`string`?e:void 0}function wl(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 ${Fl(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function Tl(e,t){return e?`Performance: ${e}`:`Frame health: unavailable - ${t}`}function El(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function Dl(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(!(t===void 0||n===void 0))return[`dropped ${Fl(t)}`,Ol(n,Q(e.totalFrameCount)),kl(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function Ol(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function kl(e){return e===void 0?``:`window ${Il(e)}`}function Al(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!u(e))return[];let t=jl(e);return t?[t]:[]}):[]}function jl(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 ${Il(i)}`;return`- +${Il(t)}-+${Il(n)}: ${Math.round(r)} missed-deadline frames${a}`}function Ml(e){let t=u(e?.cpu)?e.cpu:void 0,n=u(e?.memory)?e.memory:void 0,r=[Nl(t),Pl(n)].filter(e=>!!e);return r.length>0?r.join(`, `):void 0}function Nl(e){if(e?.available!==!0)return;let t=Q(e.usagePercent);return t===void 0?void 0:`CPU ${Fl(t)}`}function Pl(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${Ll(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Fl(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function Il(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 Ll(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function Rl(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 zl=`perf`,Bl=W(zl,`Show session performance, frame health, and memory diagnostics.`,{area:_(ye),subject:_(Ce),action:_(Fe),kind:_(me),template:p(`xctrace template name, for example Time Profiler.`),out:p(`Output artifact path.`),tracePath:p(`Existing .trace path to report, defaults to the latest session trace.`)}),Vl=L({name:`perf`,commands:[I({name:zl,metadata:Bl,definition:R(Bl,(e,t)=>e.observability.perf(t)),cliSchema:{usageOverride:`perf metrics --json
13
+ `)}}function Oo(e){return`source`in e&&e.source===`daemon`}function ko(e){return V(tt(e))}function Ao(e){return V(Ue(e))}function jo(e){let t=e,n=t.platform??`unknown`;return{data:t,text:`Boot ready: ${t.device??t.id??`unknown`} (${n})`}}function Mo(e){let t=e,n=t.platform??`unknown`,r=t.device??t.id??`unknown`,i=t.shutdown;return{data:t,text:`${i&&typeof i==`object`&&`success`in i&&i.success===!0?`Shutdown`:`Shutdown failed`}: ${r} (${n})`}}function No(e){let t=e,n=[`Doctor: ${typeof t.status==`string`?t.status:`unknown`}`],r=Ro(t.checks);if(Nt()){let e=typeof t.summary==`string`?t.summary:void 0;e&&n.push(e)}else if(r.length===0){let e=typeof t.summary==`string`?t.summary:`No blockers found.`;n.push(e)}else for(let e of r)n.push(lt(e)),n.push(...ye(e));return{data:t,text:n.join(`
14
+ `)}}const Z={boot:z(jo),shutdown:z(Mo),devices:z(xo),capabilities:z(So),doctor:z(No),apps:({input:e,result:t})=>Co({result:t,appsFilter:e.appsFilter}),session:z(wo),artifacts:z(Do),open:z(To),close:z(Eo),install:z(ko),reinstall:z(ko),"install-from-source":z(Ao),prepare:B,viewport:B};function Po(e){let t=e.kind?` ${e.kind}`:``,n=e.target?` target=${e.target}`:``,r=typeof e.booted==`boolean`?` booted=${e.booted}`:``;return`${e.name} (${e.platform}${t}${n})${r}`}function Fo(e){let t=e.url?` ${e.url}`:``,n=e.availability?` ${e.availability}`:``;return`${e.kind}: ${e.name}${n}${t}`}function Io(e){let t=e.artifactType?` (${e.artifactType})`:``;return`${e.filename}${t}: ${e.mimeType} ${e.sizeBytes} bytes id=${e.id}`}function Lo(e){if(e.providerSessionId)return`agent-device artifacts ${e.providerSessionId} --provider ${e.provider} --json`}function Ro(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}const zo=W(`artifacts`,`List daemon or cloud provider artifacts for an active or completed session.`,{provider:p(`Cloud provider name, for example browserstack or aws-device-farm.`),providerSessionId:p(`Cloud provider session id or ARN.`)}),Bo=I({name:`artifacts`,metadata:zo,definition:R(zo,(e,t)=>e.sessions.artifacts(t)),cliSchema:{summary:`List daemon or cloud provider session artifacts`,usageOverride:`artifacts [provider-session-id] [--provider <name>]`,positionalArgs:[`provider-session-id?`],allowedFlags:[`provider`,`providerSessionId`]},cliReader:(e,t)=>({...O(t),provider:t.provider,providerSessionId:e[0]??t.providerSessionId}),daemonWriter:E(l.artifacts),cliOutputFormatter:Z.artifacts}),Vo=W(`apps`,`List installed apps.`,{appsFilter:_([`user-installed`,`all`])}),Ho=W(`open`,`Open an app, deep link, URL, or platform surface.`,{app:p(`App name, bundle id, package, or URL.`),url:p(`Optional URL passed with an app shell.`),surface:_(ve),activity:p(`Android activity name.`),launchConsole:p(`Launch console mode.`),launchArgs:Gt(`Launch arguments forwarded verbatim to the platform launch command.`),relaunch:g(`Force relaunch.`),saveScript:v({oneOf:[Vt(),Rt()]}),deviceHub:g(`Use Xcode Device Hub when surfacing Apple simulators.`),noRecord:g(`Do not record this action.`)}),Uo=W(`close`,`Close an app or end the active session.`,{app:p(`Optional app to close.`),shutdown:g(`Shutdown the session/device where supported.`),saveScript:v({oneOf:[Vt(),Rt()]})}),Wo=R(Vo,(e,t)=>e.apps.list(t)),Go=R(Ho,(e,t)=>e.apps.open(t)),Ko=R(Uo,(e,t)=>t.app?e.apps.close(t):e.sessions.close(as(t))),qo={helpDescription:`List user-installed apps; use --all to include system/OEM apps`,summary:`List installed apps`,allowedFlags:[`appsFilter`],defaults:{appsFilter:At}},Jo={helpDescription:`Boot device/simulator; optionally launch app or deep link URL. 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.`,summary:`Open an app, deep link or URL, save replays`,positionalArgs:[`appOrUrl?`,`url?`],allowedFlags:[`activity`,`launchConsole`,`launchArgs`,`deviceHub`,`saveScript`,`noRecord`,`relaunch`,`surface`]},Yo={positionalArgs:[`app?`],allowedFlags:[`saveScript`,`shutdown`]},Xo=(e,t)=>({...O(t),appsFilter:kt(t.appsFilter)}),Zo=(e,t)=>({...O(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,deviceHub:t.deviceHub,noRecord:t.noRecord}),Qo=(e,t)=>({...O(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),$o=E(l.apps),es=E(l.open,os),ts=E(l.close,e=>M(e.app)),ns=I({name:`apps`,metadata:Vo,definition:Wo,cliSchema:qo,cliReader:Xo,daemonWriter:$o,cliOutputFormatter:Z.apps}),rs=I({name:`open`,metadata:Ho,definition:Go,cliSchema:Jo,cliReader:Zo,daemonWriter:es,cliOutputFormatter:Z.open}),is=I({name:`close`,metadata:Uo,definition:Ko,cliSchema:Yo,cliReader:Qo,daemonWriter:ts,cliOutputFormatter:Z.close});function as(e){let{app:t,...n}=e;return n}function os(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}const ss=W(`devices`,`List available devices.`,{}),cs=W(`capabilities`,`List commands supported by the selected device.`,{}),ls=W(`boot`,`Boot or prepare a selected device without using CLI positional arguments.`,{headless:g(`Boot without showing simulator UI when supported.`)}),us=W(`shutdown`,`Shutdown a selected simulator or emulator.`,{}),ds=R(ss,(e,t)=>e.devices.list(t)),fs=R(cs,(e,t)=>e.devices.capabilities(t)),ps=R(ls,(e,t)=>e.devices.boot(t)),ms=R(us,(e,t)=>e.devices.shutdown(t)),hs={summary:`Boot target device/simulator`,allowedFlags:[`headless`]},gs={summary:`List supported commands for the selected device`,helpDescription:`List command names supported by the selected session device or explicit --platform/--device/--udid/--serial target.`},_s={summary:`Shutdown target simulator/emulator`},vs=(e,t)=>O(t),ys=(e,t)=>({...O(t),headless:t.headless}),bs=E(l.devices),xs=E(l.capabilities),Ss=E(l.boot),Cs=E(l.shutdown),ws=[I({name:`devices`,metadata:ss,definition:ds,cliReader:vs,daemonWriter:bs,cliOutputFormatter:Z.devices}),I({name:`capabilities`,metadata:cs,definition:fs,cliSchema:gs,cliReader:vs,daemonWriter:xs,cliOutputFormatter:Z.capabilities}),I({name:`boot`,metadata:ls,definition:ps,cliSchema:hs,cliReader:ys,daemonWriter:Ss,cliOutputFormatter:Z.boot}),I({name:`shutdown`,metadata:us,definition:ms,cliSchema:_s,cliReader:vs,daemonWriter:Cs,cliOutputFormatter:Z.shutdown})],Ts=W(`doctor`,`Diagnose device, app, Metro, and React Native setup/readiness issues.`,{targetApp:p(`Installed app package/bundle id or app name to verify without opening a session.`),remote:g(`Check remote connection setup instead of local device inventory.`)}),Es=I({name:`doctor`,metadata:Ts,definition:R(Ts,(e,t)=>e.command.doctor(t)),cliSchema:{usageOverride:`doctor [--platform ios|android|macos|linux|web|apple] [--app <id-or-name>] [--remote]`,helpDescription:`Setup and recovery diagnostic for device, app, dev-server, and RN/Expo readiness issues. Reports local device inventory, active sessions, optional app discovery, scoped toolchain info, and Metro reachability 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.`,summary:`Diagnose device, app, dev-server, and RN/Expo readiness`,allowedFlags:[`targetApp`,`remote`]},cliReader:(e,t)=>({...O(t),targetApp:t.targetApp,remote:t.remote}),daemonWriter:E(l.doctor),cliOutputFormatter:Z.doctor});function Ds(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}=As(t.slice(0,r),n);return ks(i,a,t.slice(r+1),`${n} artifact`)}function Os(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(Ms(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}=As(Ms(r.repo,`${n} installSource.repo`),`${n} installSource.repo`);return ks(i,a,r.artifact,`${n} installSource.artifact`)}function ks(e,t,n,r){return typeof n==`number`||Ps(n)?{kind:`github-actions-artifact`,owner:e,repo:t,artifactId:Ns(n,r)}:{kind:`github-actions-artifact`,owner:e,repo:t,artifactName:Ms(n,r)}}function As(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 js(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function Ms(t,n){let r=js(t);if(!r)throw new e(`INVALID_ARGS`,`${n} must be a non-empty string.`);return r}function Ns(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 Ps(e){return typeof e==`string`&&/^\d+$/.test(e.trim())}const Fs=W(`install`,`Install an app binary.`,{app:p(`Optional app identifier hint.`),appPath:f(p(`Path to app binary.`))}),Is=W(`reinstall`,`Reinstall an app binary.`,{app:f(p()),appPath:f(p(`Path to app binary.`))}),Ls=W(`install-from-source`,`Install an app from a structured source.`,{source:f(v(Ut(`Install source object.`))),retainPaths:g(),retentionMs:h()}),Rs=R(Fs,(e,t)=>e.apps.install(t)),zs=R(Is,(e,t)=>e.apps.reinstall(t)),Bs=R(Ls,(e,t)=>e.apps.installFromSource(t)),Vs={usageOverride:`install <path> | install <app> <path>`,listUsageOverride:`install <path>`,positionalArgs:[`appOrPath`,`path?`]},Hs={positionalArgs:[`app`,`path`]},Us={usageOverride:`install-from-source <url> | install-from-source --github-actions-artifact <owner/repo:artifact>`,listUsageOverride:`install-from-source`,helpDescription:`Install app builds from URLs, remote source specs, or CI artifacts resolved by a remote daemon.`,summary:`Install app builds from URLs, remote source specs, or CI artifacts`,positionalArgs:[`url?`],allowedFlags:[`header`,`githubActionsArtifact`,`installSource`,`retainPaths`,`retentionMs`]},Ws=(e,t)=>Xs(e,t),Gs=(e,t)=>Zs(e,t),Ks=(e,t)=>({...O(t),source:ec(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),qs=E(l.install,e=>Qs(e.app,e.appPath)),Js=E(l.reinstall,e=>$s(e.app,e.appPath)),Ys=[I({name:`install`,metadata:Fs,definition:Rs,cliSchema:Vs,cliReader:Ws,daemonWriter:qs,cliOutputFormatter:Z.install}),I({name:`reinstall`,metadata:Is,definition:zs,cliSchema:Hs,cliReader:Gs,daemonWriter:Js,cliOutputFormatter:Z.reinstall}),I({name:`install-from-source`,metadata:Ls,definition:Bs,cliSchema:Us,cliReader:Ks,daemonWriter:e=>D(ke.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),cliOutputFormatter:Z[`install-from-source`]})];function Xs(e,t){let[n,r]=e,i=r!==void 0;return{...O(t),...i?{app:P(n,`install requires app`)}:{},appPath:P(i?r:n,`install requires path`)}}function Zs(e,t){return{...O(t),app:P(e[0],`reinstall requires app`),appPath:P(e[1],`reinstall requires path`)}}function Qs(e,t){let n=F(t,`missing app path`);return typeof e==`string`&&e.length>0?[e,n]:[n]}function $s(e,t){return[F(e,`missing first positional`),F(t,`missing second positional`)]}function ec(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?Ds(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:tc(n.header)}}function tc(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 nc=W(`prepare`,`Prepare platform helper infrastructure.`,{action:f(_([`ios-runner`])),timeoutMs:h(`Maximum wall-clock time for the prepare command.`)}),rc=I({name:`prepare`,metadata:nc,definition:R(nc,(e,t)=>e.command.prepare(t)),cliSchema:{usageOverride:`prepare ios-runner --platform ios|macos [--timeout <ms>]`,listUsageOverride:`prepare`,helpDescription:`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.`,summary:`Pre-warm platform helpers, especially the iOS/macOS XCTest runner before Apple automation`,positionalArgs:[`ios-runner`],allowedFlags:[`timeoutMs`]},cliReader:(e,t)=>({...O(t),action:P(e[0],`prepare requires subcommand`),timeoutMs:t.timeoutMs}),daemonWriter:E(l.prepare,e=>[F(e.action,`prepare requires subcommand`)]),cliOutputFormatter:Z.prepare}),ic=W(`push`,`Deliver a push payload.`,{app:f(p()),payload:f(v({oneOf:[Rt(),Ut()]}))}),ac=W(`trigger-app-event`,`Trigger an app-defined event.`,{event:f(p()),payload:_c()}),oc=R(ic,(e,t)=>e.apps.push(t)),sc=R(ac,(e,t)=>e.apps.triggerEvent(t)),cc={listUsageOverride:`push`,helpDescription:`Deliver push notification payloads to an installed app.`,summary:`Deliver push notification payloads to an installed app`,positionalArgs:[`bundleOrPackage`,`payloadOrJson`]},lc={usageOverride:`trigger-app-event <event> [payloadJson]`,listUsageOverride:`trigger-app-event`,helpDescription:`Invoke app-defined automation or test events with an optional structured payload.`,summary:`Invoke app-defined automation/test events with optional structured payloads`,positionalArgs:[`event`,`payloadJson?`]},uc=(e,t)=>({...O(t),app:P(e[0],`push requires bundleOrPackage`),payload:P(e[1],`push requires payloadOrJson`)}),dc=(e,t)=>({...O(t),event:P(e[0],`trigger-app-event requires event`),payload:e[1]?Hn(e[1],`trigger-app-event payload`):void 0}),fc=E(l.push,e=>hc(e)),pc=E(l.triggerAppEvent,e=>gc(e)),mc=[I({name:`push`,metadata:ic,definition:oc,cliSchema:cc,cliReader:uc,daemonWriter:fc}),I({name:`trigger-app-event`,metadata:ac,definition:sc,cliSchema:lc,cliReader:dc,daemonWriter:pc})];function hc(e){return[e.app,typeof e.payload==`string`?e.payload:JSON.stringify(e.payload)]}function gc(e){return[e.event,...e.payload?[JSON.stringify(e.payload)]:[]]}function _c(){return Wt()}const vc=W(`session`,`List active sessions or print daemon state directory.`,{action:_([`list`,`state-dir`],`list shows active sessions; state-dir prints the resolved daemon state directory without contacting the daemon.`)}),yc=I({name:`session`,metadata:vc,definition:R(vc,async(e,{action:t,...n})=>t===`state-dir`?{stateDir:await e.sessions.stateDir(n)}:{sessions:await e.sessions.list(n)}),cliSchema:{usageOverride:`session list | session state-dir`,listUsageOverride:`session`,helpDescription:`List active sessions or print the effective daemon state directory`,positionalArgs:[`list|state-dir?`]},cliReader:(e,t)=>({...O(t),action:bc(e[0])}),cliOutputFormatter:Z.session});function bc(t){let n=t??`list`;if(n===`list`||n===`state-dir`)return n;throw new e(`INVALID_ARGS`,`session only supports list or state-dir`)}const xc=W(`viewport`,`Resize the active web viewport.`,{width:f(h(`Viewport width in CSS pixels.`,{min:1})),height:f(h(`Viewport height in CSS pixels.`,{min:1}))}),Sc=I({name:`viewport`,metadata:xc,definition:R(xc,(e,t)=>e.command.viewport(t)),cliSchema:{helpDescription:`Resize the active web viewport before taking snapshots or screenshots. Useful for fixed-layout or 100vh apps where changing the viewport reveals different content.`,summary:`Resize the active web viewport for the current session`,positionalArgs:[`width`,`height`]},cliReader:(e,t)=>({...O(t),width:Ye(e[0],`width`),height:Ye(e[1],`height`)}),daemonWriter:E(l.viewport,e=>{let{width:t,height:n}=e;return[String(t),String(n)]}),cliOutputFormatter:Z.viewport}),Cc=L({name:`management`,commands:[...ws,Bo,Es,rc,ns,yc,rs,is,Sc,...Ys,...mc]});function wc(e){return{data:e.result,text:e.action===`reload`?`Reloaded React Native apps via ${e.result.reloadUrl}`:JSON.stringify(e.result,null,2)}}const Tc={metro:({input:e,result:t})=>wc({result:t,action:e.action})},Ec=[`auto`,`react-native`,`expo`,`repack`];function Dc(t){if(t!==void 0){if(Ec.includes(t))return t;throw new e(`INVALID_ARGS`,`metro prepare --kind must be auto, react-native, expo, or repack`)}}const Oc=`metro`,kc=W(Oc,`Prepare React Native dev-server runtime or reload apps.`,{action:f(_([`prepare`,`reload`])),projectRoot:p(),kind:v(Rt()),publicBaseUrl:p(),proxyBaseUrl:p(),bearerToken:p(),bridgeScope:v({type:`object`,additionalProperties:!0}),launchUrl:p(),port:h(),listenHost:p(),statusHost:p(),startupTimeoutMs:h(),probeTimeoutMs:h(),reuseExisting:g(),installDependenciesIfNeeded:g(),runtimeFilePath:p(),logPath:p(),metroHost:p(),metroPort:h(),bundleUrl:p(),timeoutMs:h()}),Ac=L({name:`metro`,commands:[I({name:Oc,metadata:kc,definition:R(kc,async(e,t)=>t.action===`prepare`?await e.metro.prepare(jc(t)):await e.metro.reload(Nc(t))),cliSchema:{usageOverride:`metro prepare (--public-base-url <url> | --proxy-base-url <url>) [--project-root <path>] [--port <port>] [--kind auto|react-native|expo|repack]
15
+ agent-device metro reload [--metro-host <host>] [--metro-port <port>] [--bundle-url <url>]`,listUsageOverride:`metro`,helpDescription:`Prepare a local React Native dev-server runtime or ask connected apps to reload`,summary:`Prepare Metro/Re.Pack reachability for React Native/Expo apps or trigger app reloads`,positionalArgs:[`prepare|reload`],allowedFlags:[...wr,...Cr]},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:Dc(n.kind??n.metroKind),port:n.metroPreparePort,listenHost:n.metroListenHost,statusHost:n.metroStatusHost,publicBaseUrl:n.metroPublicBaseUrl,proxyBaseUrl:n.metroProxyBaseUrl,bearerToken:n.metroBearerToken,bridgeScope:n.tenant&&n.runId&&n.leaseId?{tenantId:n.tenant,runId:n.runId,leaseId:n.leaseId}:void 0,startupTimeoutMs:n.metroStartupTimeoutMs,probeTimeoutMs:n.metroProbeTimeoutMs,reuseExisting:n.metroNoReuseExisting?!1:void 0,installDependenciesIfNeeded:n.metroNoInstallDeps?!1:void 0,runtimeFilePath:n.metroRuntimeFile}},cliOutputFormatter:Tc.metro})]});function jc(e){return{projectRoot:e.projectRoot,kind:e.kind,publicBaseUrl:e.publicBaseUrl,proxyBaseUrl:e.proxyBaseUrl,bearerToken:e.bearerToken,bridgeScope:e.bridgeScope??Mc(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 Mc(e){return e.tenant&&e.runId&&e.leaseId?{tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId}:void 0}function Nc(e){return{metroHost:e.metroHost,metroPort:e.metroPort,bundleUrl:e.bundleUrl,timeoutMs:e.timeoutMs}}const Pc=[`started`,`stopped`,`marked`,`cleared`,`restarted`,`removedRotatedFiles`];function Fc(e){return{data:e,text:e.path,stderr:ll([sl(e,[`active`,`state`,`backend`,`sizeBytes`]),$c(e),e.hint,cl(e.notes)])}}function Ic(e){let t=e.events??[];return{data:e,text:t.length>0?Bc(t):`No session events found.`,stderr:ll([sl(e,[`path`,`cursor`,`nextCursor`,`limit`])])}}function Lc(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(...il(e));return{data:e,text:t.join(`
16
+ `),stderr:ll([sl(e,[`active`,`state`,`backend`,`include`,`scannedLines`,`matchedLines`]),cl(e.notes)])}}function Rc(e){return{data:e,text:[`Audio probe: ${String(e.state??`stopped`)} heard=${String(e.heard===!0)}`,Qc(`rmsDbfs`,e.rmsDbfs),Qc(`peakDbfs`,e.peakDbfs)].filter(e=>!!e).join(`
17
+ `),stderr:ll([sl(e,[`active`,`backend`,`source`,`durationMs`,`elapsedMs`,`bucketMs`,`sampleCount`,`sourceCount`,`mediaElementCount`]),cl(e.notes)])}}const zc={logs:z(Fc),events:z(Ic),network:z(Lc),audio:z(Rc)};function Bc(e){let t=e.map(Vc),n=Math.min(Math.max(...t.map(e=>e.label.length),5),32);return t.map(e=>Hc(e,n)).join(`
18
+ `)}function Vc(e){return{timestamp:Uc(e.ts),label:Wc(e),summary:Gc(e)}}function Hc(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 Uc(e){return e?e.replace(`T`,` `):``}function Wc(e){let t=e.command??`command`;switch(e.kind){case`request.started`:return`start ${t}`;case`request.finished`:return tl([e.status===`error`?`error`:`ok`,t,Zc(rl(e.details?.durationMs))]);case`action.recorded`:return`action ${t}`;default:return tl([e.kind??`event`,e.command])}}function Gc(e){let t=Kc(e.summary,e);return`${t}${qc(e,t)}`.trim()}function Kc(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 qc(e,t){if(e.kind!==`action.recorded`)return``;let n=e.details;if(!n)return``;let r=[Jc(n,t),Xc(rl(n.textLength))].filter(e=>!!e);return r.length>0?` (${r.join(`, `)})`:``}function Jc(e,t){let n=nl(e.ref)??nl(e.selector)??Yc(e);if(!(!n||t.includes(n)))return`target=${n}`}function Yc(e){let t=rl(e.x),n=rl(e.y);return t===void 0||n===void 0?void 0:`(${t}, ${n})`}function Xc(e){return e===void 0?void 0:`text=${e} chars`}function Zc(e){return e===void 0?void 0:`${Math.round(e)}ms`}function Qc(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 $c(e){return Pc.map(t=>el(t,e[t])).filter(Boolean).join(` `)||void 0}function el(e,t){return t==null?``:`${e}=${t}`}function tl(e){return e.filter(e=>!!e).join(` `)}function nl(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function rl(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function il(e){let t=e.method??`HTTP`,n=e.url??`<unknown-url>`,r=e.status===void 0?``:` status=${e.status}`,i=[`${e.timestamp?`${e.timestamp} `:``}${t} ${n}${r}${e.durationMs===void 0?``:` durationMs=${e.durationMs}`}`];return e.headers?ol(i,`headers`,e.headers):(al(i,`request headers`,e.requestHeaders),al(i,`response headers`,e.responseHeaders)),ol(i,`request`,e.requestBody),ol(i,`response`,e.responseBody),i}function al(e,t,n){!n||Object.keys(n).length===0||e.push(` ${t}: ${JSON.stringify(n)}`)}function ol(e,t,n){n!==void 0&&e.push(` ${t}: ${n}`)}function sl(e,t){return t.map(t=>e[t]!==void 0&&e[t]!==null?`${t}=${e[t]}`:``).filter(Boolean).join(` `)||void 0}function cl(e){let t=e?.filter(e=>e.length>0)??[];return t.length>0?t.join(`
19
+ `):void 0}function ll(e){return e.filter(e=>!!e).join(`
20
+ `)||void 0}const ul=`logs`,dl=`events`,fl=`network`,pl=`audio`,ml=[`dump`,`log`],hl=[`probe`],gl=[`start`,`status`,`stop`],_l=W(ul,`Manage session app logs.`,{action:_(Ie),message:p(),restart:g()}),vl=W(dl,`Read the session event timeline.`,{limit:h(),cursor:p()}),yl=W(fl,`Show recent HTTP traffic.`,{action:_(ml),limit:h(),include:_(s)}),bl=W(pl,`Probe audio levels.`,{action:_(hl),probeAction:_(gl),durationMs:h(`Probe duration in milliseconds.`),bucketMs:h(`Audio level bucket size in milliseconds.`)}),xl=R(_l,(e,t)=>e.observability.logs(t)),Sl=R(vl,(e,t)=>e.observability.events(t)),Cl=R(yl,(e,t)=>e.observability.network(t)),wl=R(bl,(e,t)=>e.observability.audio(t)),Tl=L({name:`observability`,commands:[I({name:ul,metadata:_l,definition:xl,cliSchema:{usageOverride:`logs path | logs start | logs stop | logs clear [--restart] | logs doctor | logs mark [message...]`,helpDescription:`Session app log info, start/stop streaming, diagnostics, and markers`,summary:`Manage session app logs`,positionalArgs:[`path|start|stop|clear|doctor|mark`,`message?`],allowsExtraPositionals:!0,allowedFlags:[`restart`]},cliReader:(e,t)=>({...O(t),action:Al(e[0]),message:e.slice(1).join(` `)||void 0,restart:t.restart}),daemonWriter:E(ul,e=>El(e)),cliOutputFormatter:zc.logs}),I({name:dl,metadata:vl,definition:Sl,cliSchema:{usageOverride:`events [limit] [cursor]`,listUsageOverride:`events`,helpDescription:`Read the daemon-owned session event timeline as paged JSON-friendly entries`,summary:`Read session event timeline`,positionalArgs:[`limit?`,`cursor?`]},cliReader:(e,t)=>({...O(t),limit:e[0]?.trim()?j(e[0]):void 0,cursor:e[1]}),daemonWriter:e=>D(dl,Dl(e),e),cliOutputFormatter:zc.events}),I({name:fl,metadata:yl,definition:Cl,cliSchema:{usageOverride:`network dump [limit] [summary|headers|body|all] [--include summary|headers|body|all] | network log [limit] [summary|headers|body|all] [--include summary|headers|body|all]`,listUsageOverride:`network`,helpDescription:`Dump recent HTTP(s) traffic parsed from the session app log`,summary:`Inspect HTTP(S) traffic parsed from session app logs, including summaries, headers, and bodies`,positionalArgs:[`dump|log`,`limit?`,`include?`],allowedFlags:[`networkInclude`]},cliReader:(e,t)=>({...O(t),action:jl(e[0]),limit:j(e[1]),include:t.networkInclude??Ml(e[2])}),daemonWriter:e=>D(fl,Ol(e),{...e,networkInclude:e.include}),cliOutputFormatter:zc.network}),I({name:pl,metadata:bl,definition:wl,cliSchema:{usageOverride:`audio probe start [durationSeconds] [bucketMs] | audio probe status | audio probe stop`,listUsageOverride:`audio`,helpDescription:`Probe browser or host-rendered simulator/emulator audio as compact dBFS buckets`,summary:`Probe audio levels`,positionalArgs:[`probe`,`start|status|stop`,`durationSeconds?`,`bucketMs?`]},cliReader:(e,t)=>({...O(t),action:Nl(e[0]),probeAction:Pl(e[1]),durationMs:Fl(e[2]),bucketMs:j(e[3])}),daemonWriter:e=>D(pl,kl(e),e),cliOutputFormatter:zc.audio})]});function El(e){return[e.action??`path`,...M(e.message)]}function Dl(e){return e.cursor===void 0?N(e.limit):[e.limit===void 0?``:String(e.limit),e.cursor]}function Ol(e){return[...e.action?[e.action]:[],...N(e.limit)]}function kl(e){return[e.action??`probe`,e.probeAction??`status`,...N(e.durationMs),...N(e.bucketMs)]}function Al(e){if(e!==void 0)return rt(Ie,e,{message:`logs requires path, start, stop, doctor, mark, or clear`})}function jl(t){if(t!==void 0){if(t===`dump`||t===`log`)return t;throw new e(`INVALID_ARGS`,`network requires dump or log`)}}function Ml(e){if(e!==void 0)return rt(s,e,{message:`network include must be summary, headers, body, or all`})}function Nl(e){if(e!==void 0)return rt(hl,e,{message:`audio requires probe`})}function Pl(e){if(e!==void 0)return rt(gl,e,{message:`audio probe requires start, status, or stop`})}function Fl(e){let t=j(e);return t===void 0?void 0:Math.round(t*1e3)}function Il(e){let t=e;return{data:t,text:Rl(t)}}const Ll={perf:z(Il)};function Rl(e){let t=Hl(e);if(t)return t;let n=u(e.artifact)?e.artifact:void 0;return n?Vl(n):zl(u(e.metrics)?e.metrics:void 0)}function zl(e){let t=u(e?.fps)?e.fps:void 0,n=au(e);if(!t)return Ql(n,`missing frame metric`);if(t.available===!1)return Ql(n,$l(t));let r=eu(t);return r?Bl(t,r):Ql(n,`missing dropped-frame summary`)}function Bl(e,t){let n=[`Frame health: ${t}`],r=ru(e);return r.length>0&&n.push(`Worst windows:`,...r),n.join(`
21
+ `)}function Vl(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?``:` (${du(r)})`;return n?`Memory artifact (${t}): ${n}${i}`:`Memory artifact (${t}): captured${i}`}function Hl(e){return e.kind===`xctrace`?Ul(e):Kl(e)}function Ul(e){let t=typeof e.perf==`string`?e.perf:void 0,n=Wl(e);if(!(!t||!n||e.kind!==`xctrace`))return Gl(n,typeof e.mode==`string`?e.mode:`capture`,t,e.template)}function Wl(e){return typeof e.outPath==`string`?e.outPath:typeof e.reportPath==`string`?e.reportPath:void 0}function Gl(e,t,n,r){let i=[e,`Perf ${t}: ${n}`];return typeof r==`string`&&i.push(`Template: ${r}`),i.join(`
22
+ `)}function Kl(e){let t=ql(e);if(t)return`Perf ${t.action}: ${t.kind} ${t.type}${Jl(e)}${Yl(e)}${Zl(e)}`}function ql(e){let t=Xl(e.action),n=Xl(e.kind),r=Xl(e.type);return t&&n&&r?{action:t,kind:n,type:r}:void 0}function Jl(e){let t=Xl(e.state);return t?` state=${t}`:``}function Yl(e){let t=Xl(e.outPath);if(!t)return``;let n=Q(e.sizeBytes);return`\n${t}${n===void 0?``:` (${du(n)})`}`}function Xl(e){return typeof e==`string`?e:void 0}function Zl(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 ${cu(r)} (${Math.round(i)}/${Math.round(a)} frames)`}function Ql(e,t){return e?`Performance: ${e}`:`Frame health: unavailable - ${t}`}function $l(e){return typeof e.reason==`string`&&e.reason.length>0?e.reason:`not available`}function eu(e){let t=Q(e.droppedFramePercent),n=Q(e.droppedFrameCount);if(!(t===void 0||n===void 0))return[`dropped ${cu(t)}`,tu(n,Q(e.totalFrameCount)),nu(Q(e.sampleWindowMs))].filter(Boolean).join(` `)}function tu(e,t){return t===void 0?`(${Math.round(e)} dropped frames)`:`(${Math.round(e)}/${Math.round(t)} frames)`}function nu(e){return e===void 0?``:`window ${lu(e)}`}function ru(e){return Array.isArray(e.worstWindows)?e.worstWindows.flatMap(e=>{if(!u(e))return[];let t=iu(e);return t?[t]:[]}):[]}function iu(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 ${lu(i)}`;return`- +${lu(t)}-+${lu(n)}: ${Math.round(r)} missed-deadline frames${a}`}function au(e){let t=u(e?.cpu)?e.cpu:void 0,n=u(e?.memory)?e.memory:void 0,r=[ou(t),su(n)].filter(e=>!!e);return r.length>0?r.join(`, `):void 0}function ou(e){if(e?.available!==!0)return;let t=Q(e.usagePercent);return t===void 0?void 0:`CPU ${cu(t)}`}function su(e){if(e?.available!==!0)return;let t=Q(e.residentMemoryKb)??Q(e.totalPssKb)??Q(e.totalRssKb);return t===void 0?void 0:`memory ${uu(t)}`}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function cu(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function lu(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 uu(e){let t=e/1024;return`${t>=10?Math.round(t):t.toFixed(1)}MB`}function du(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 fu=`perf`,pu=W(fu,`Show session performance, frame health, and memory diagnostics.`,{area:_(ut),subject:_(Te),action:_(he),kind:_(Ce),template:p(`xctrace template name, for example Time Profiler.`),out:p(`Output artifact path.`),tracePath:p(`Existing .trace path to report, defaults to the latest session trace.`)}),mu=L({name:`perf`,commands:[I({name:fu,metadata:pu,definition:R(pu,(e,t)=>e.observability.perf(t)),cliSchema:{usageOverride:`perf metrics --json
22
23
  agent-device perf frames --json
23
24
  agent-device perf memory sample --json
24
25
  agent-device perf memory snapshot [--kind android-hprof|memgraph] [--out <path>]
@@ -29,9 +30,9 @@ import{F as e,d as t,f as n,g as r,l as i,n as a,s as o,t as s}from"./sdk-contra
29
30
  agent-device perf cpu profile start --kind simpleperf --out <cpu.perf.data>
30
31
  agent-device perf cpu profile stop --kind simpleperf
31
32
  agent-device perf cpu profile report --kind simpleperf --out <cpu-report.json>
32
- agent-device perf trace start|stop --kind perfetto [--out <path>]`,listUsageOverride:`perf`,helpDescription:`Show session performance metrics, focused frame/jank health, memory diagnostics artifacts, Apple xctrace artifacts, or Android native Simpleperf/Perfetto artifacts. Prefer explicit perf metrics --json for first-pass startup/CPU/memory data. For CPU profiles, start/stop write the raw artifact and report writes a compact .json summary; include report after simpleperf stop when the task needs agent-readable native CPU evidence. Bare perf and metrics remain aliases. Native perf output is agent evidence: compact state, artifact path, and size only; raw profiles/traces stay on disk.`,summary:`Check runtime metrics, frames, memory, CPU profiles, or native trace artifacts`,positionalArgs:[`area?`,`subjectOrAction?`,`action?`],allowedFlags:[`kind`,`perfTemplate`,`out`]},cliReader:(e,t)=>({...O(t),...Wl(e,{kind:Yl(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:E(zl,e=>Hl(e)),cliOutputFormatter:ul.perf})]});function Hl(e){let t=e.area??(e.action?`metrics`:void 0);return t===`cpu`?Ul([...M(t),...M(e.subject),...M(e.action),...M(e.kind)],e):t===`trace`?Ul([...M(t),...M(e.action),...M(e.kind)],e):[...M(t),...M(e.action)]}function Ul(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 Wl(e,t={}){if(e[0]!==void 0&&e[1]===void 0){let n=Kl(e[0],{allowUndefined:!0});if(n)return{action:n,kind:Jl(t.kind),out:t.out}}let n=Gl(e[0]);return n===`cpu`?{area:n,subject:ql(e[1]),action:Kl(e[2]),kind:Jl(t.kind),template:t.template,out:t.out}:n===`trace`?{area:n,action:Kl(e[1]),kind:Jl(t.kind),template:t.template,out:t.out}:{area:n,action:Kl(e[1]),kind:Jl(t.kind),out:t.out}}function Gl(t){if(t===void 0)return;let n=t.toLowerCase();if(fe(n))return n;throw new e(`INVALID_ARGS`,ve)}function Kl(t,n={}){if(t===void 0)return;let r=t.toLowerCase();if(at(r))return r;if(!n.allowUndefined)throw new e(`INVALID_ARGS`,de)}function ql(t){let n=t?.toLowerCase();if(n!==void 0&&we(n))return n;throw new e(`INVALID_ARGS`,_e)}function Jl(t){if(t===void 0)return;let n=t.toLowerCase();if(Te(n))return n;throw new e(`INVALID_ARGS`,be)}function Yl(e){return typeof e==`string`?Jl(e):void 0}const Xl=`react-native`,Zl=W(Xl,`Run supported React Native app automation helpers.`,{action:f(_([`dismiss-overlay`]))}),Ql=L({name:`react-native`,commands:[I({name:Xl,metadata:Zl,definition:R(Zl,(e,t)=>e.command.reactNative(t)),cliSchema:{usageOverride:`react-native dismiss-overlay`,listUsageOverride:`react-native dismiss-overlay`,positionalArgs:[`dismiss-overlay`]},cliReader:(e,t)=>({...O(t),action:$l(e[0])}),daemonWriter:E(Xl,e=>[F(e.action,`react-native requires action`)])})]});function $l(t){if(t===`dismiss-overlay`)return t;throw new e(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}function eu(e){let t=e,n=typeof t.outPath==`string`?t.outPath:``,r=ru(t);if(r.length<=1)return{data:t,text:nu(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(`
33
- `)}}const tu={record:z(eu)};function nu(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(`
34
- `)}function ru(e){let t=e.chunks;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.index!=`number`||typeof t.path!=`string`?[]:[{index:t.index,path:t.path}]}):[]}const iu=`record`,au=`trace`,ou=[`start`,`stop`],su=W(iu,`Start or stop screen recording.`,{action:f(_(ou)),path:p(),fps:h(),maxSize:h(),quality:_(Me),hideTouches:g()}),cu=W(au,`Start or stop trace capture.`,{action:f(_(ou)),path:p()}),lu=R(su,(e,t)=>e.recording.record(t)),uu=R(cu,(e,t)=>e.recording.trace(t)),du={usageOverride:`record start [path] [--fps <n>] [--max-size <px>] [--quality <medium|high>] [--hide-touches] | record stop`,listUsageOverride:`record start [path] | record stop`,helpDescription:`Start/stop screen recording; 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. Use --max-size to limit dimensions and --quality to choose medium or high export quality`,summary:`Start or stop screen recording`,positionalArgs:[`start|stop`,`path?`],allowedFlags:[`fps`,`screenshotMaxSize`,`quality`,`hideTouches`]},fu={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,helpDescription:`Start/stop trace log capture; when an artifact path is requested, pass the same positional path to start and stop`,summary:`Start or stop trace capture`,positionalArgs:[`start|stop`,`path?`]},pu=(e,t)=>({...O(t),action:yu(e[0],iu),path:e[1],fps:t.fps,maxSize:t.screenshotMaxSize,quality:t.quality,hideTouches:t.hideTouches}),mu=(e,t)=>({...O(t),action:yu(e[0],au),path:e[1]}),hu=E(iu,e=>vu(e)),gu=E(au,e=>vu(e)),_u=L({name:`recording`,commands:[I({name:iu,metadata:su,definition:lu,cliSchema:du,cliReader:pu,daemonWriter:hu,cliOutputFormatter:tu.record}),I({name:au,metadata:cu,definition:uu,cliSchema:fu,cliReader:mu,daemonWriter:gu})]});function vu(e){return[e.action,...M(e.path)]}function yu(t,n){if(t===`start`||t===`stop`)return t;throw new e(`INVALID_ARGS`,`${n} requires start|stop`)}const bu=`replay`,xu=`test`,Su=`Replay a recorded session.`,Cu=W(bu,Su,{path:f(p()),update:g(),backend:p(),maestro:g(),env:Bt()}),wu=W(xu,`Run one or more replay scripts.`,{paths:f(Bt()),update:g(),backend:p(),maestro:g(),env:Bt(),failFast:g(),timeoutMs:h(),retries:h(),recordVideo:g(),artifactsDir:p(),shardAll:h(),shardSplit:h()}),Tu=R(Cu,(e,t)=>e.replay.run(t)),Eu=R(wu,(e,t)=>e.replay.test(t)),Du={usageOverride:`replay <path> | replay export <file.ad> [--format maestro] [--out <path>]`,helpDescription:`Replay a recorded session. For Maestro YAML compatibility flows, use replay <flow.yaml> --maestro and keep the target binding such as --platform ios on the replay command.`,summary:Su,positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,`replayExportFormat`,...Sr,`timeoutMs`,`out`]},Ou={usageOverride:`test <path-or-glob>...`,listUsageOverride:`test <path-or-glob>...`,helpDescription:`Run one or more replay scripts as a serial test suite`,summary:`Run replay test suites`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Sr,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`]},ku=L({name:`replay`,commands:[I({name:bu,metadata:Cu,definition:Tu,cliSchema:Du,cliReader:(e,t)=>({...O(t),path:P(e[0],`replay requires path`),update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv}),daemonWriter:e=>D(bu,[F(e.path,`replay requires path`)],{...e,replayUpdate:e.update,replayBackend:Au(e),replayEnv:e.env,replayShellEnv:Mu(process.env)})}),I({name:xu,metadata:wu,definition:Eu,cliSchema:Ou,cliReader:(e,t)=>({...O(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,shardAll:t.shardAll,shardSplit:t.shardSplit}),daemonWriter:e=>D(xu,e.paths??[],{...ju(e),replayUpdate:e.update,replayBackend:Au(e),replayEnv:e.env,replayShellEnv:Mu(process.env)})})]});function Au(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function ju(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function Mu(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}const Nu=[`in-app`,`system`];function Pu(e){return{data:e,text:Lu(e)}}function Fu(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: ${Ru(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
35
- `)}}return V(e)}function Iu(e){return e.action===`read`?{data:e,text:e.text}:V(e)}const $={appstate:z(Pu),back:B,home:B,rotate:B,"app-switcher":B,keyboard:z(Fu),clipboard:z(Iu)};function Lu(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(`
33
+ agent-device perf trace start|stop --kind perfetto [--out <path>]`,listUsageOverride:`perf`,helpDescription:`Show session performance metrics, focused frame/jank health, memory diagnostics artifacts, Apple xctrace artifacts, or Android native Simpleperf/Perfetto artifacts. Prefer explicit perf metrics --json for first-pass startup/CPU/memory data. For CPU profiles, start/stop write the raw artifact and report writes a compact .json summary; include report after simpleperf stop when the task needs agent-readable native CPU evidence. Bare perf and metrics remain aliases. Native perf output is agent evidence: compact state, artifact path, and size only; raw profiles/traces stay on disk.`,summary:`Check runtime metrics, frames, memory, CPU profiles, or native trace artifacts`,positionalArgs:[`area?`,`subjectOrAction?`,`action?`],allowedFlags:[`kind`,`perfTemplate`,`out`]},cliReader:(e,t)=>({...O(t),..._u(e,{kind:Su(t.kind),template:t.perfTemplate,out:t.out})}),daemonWriter:E(fu,e=>hu(e)),cliOutputFormatter:Ll.perf})]});function hu(e){let t=e.area??(e.action?`metrics`:void 0);return t===`cpu`?gu([...M(t),...M(e.subject),...M(e.action),...M(e.kind)],e):t===`trace`?gu([...M(t),...M(e.action),...M(e.kind)],e):[...M(t),...M(e.action)]}function gu(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 _u(e,t={}){if(e[0]!==void 0&&e[1]===void 0){let n=yu(e[0],{allowUndefined:!0});if(n)return{action:n,kind:xu(t.kind),out:t.out}}let n=vu(e[0]);return n===`cpu`?{area:n,subject:bu(e[1]),action:yu(e[2]),kind:xu(t.kind),template:t.template,out:t.out}:n===`trace`?{area:n,action:yu(e[1]),kind:xu(t.kind),template:t.template,out:t.out}:{area:n,action:yu(e[1]),kind:xu(t.kind),out:t.out}}function vu(t){if(t===void 0)return;let n=t.toLowerCase();if(pe(n))return n;throw new e(`INVALID_ARGS`,be)}function yu(t,n={}){if(t===void 0)return;let r=t.toLowerCase();if(de(r))return r;if(!n.allowUndefined)throw new e(`INVALID_ARGS`,fe)}function bu(t){let n=t?.toLowerCase();if(n!==void 0&&Oe(n))return n;throw new e(`INVALID_ARGS`,Se)}function xu(t){if(t===void 0)return;let n=t.toLowerCase();if(Xe(n))return n;throw new e(`INVALID_ARGS`,se)}function Su(e){return typeof e==`string`?xu(e):void 0}const Cu=`react-native`,wu=W(Cu,`Run supported React Native app automation helpers.`,{action:f(_([`dismiss-overlay`]))}),Tu=L({name:`react-native`,commands:[I({name:Cu,metadata:wu,definition:R(wu,(e,t)=>e.command.reactNative(t)),cliSchema:{usageOverride:`react-native dismiss-overlay`,listUsageOverride:`react-native dismiss-overlay`,positionalArgs:[`dismiss-overlay`]},cliReader:(e,t)=>({...O(t),action:Eu(e[0])}),daemonWriter:E(Cu,e=>[F(e.action,`react-native requires action`)])})]});function Eu(t){if(t===`dismiss-overlay`)return t;throw new e(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}function Du(e){let t=e,n=typeof t.outPath==`string`?t.outPath:``,r=Au(t);if(r.length<=1)return{data:t,text:ku(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(`
34
+ `)}}const Ou={record:z(Du)};function ku(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(`
35
+ `)}function Au(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 ju=`record`,Mu=`trace`,Nu=[`start`,`stop`],Pu=W(ju,`Start or stop screen recording.`,{action:f(_(Nu)),path:p(),fps:h(),maxSize:h(),quality:_(it),hideTouches:g(),recordingScope:_(Ee)}),Fu=W(Mu,`Start or stop trace capture.`,{action:f(_(Nu)),path:p()}),Iu=R(Pu,(e,t)=>e.recording.record(t)),Lu=R(Fu,(e,t)=>e.recording.trace(t)),Ru={usageOverride:`record start [path] [--scope <app|device|system>] [--fps <n>] [--max-size <px>] [--quality <medium|high>] [--hide-touches] | record stop`,listUsageOverride:`record start [path] | record stop`,helpDescription:`Start/stop screen recording. 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. Use --max-size to limit dimensions and --quality to choose medium or high export quality`,summary:`Start or stop screen recording`,positionalArgs:[`start|stop`,`path?`],allowedFlags:[`recordingScope`,`fps`,`screenshotMaxSize`,`quality`,`hideTouches`]},zu={usageOverride:`trace start <path> | trace stop <path>`,listUsageOverride:`trace start <path> | trace stop <path>`,helpDescription:`Start/stop trace log capture; when an artifact path is requested, pass the same positional path to start and stop`,summary:`Start or stop trace capture`,positionalArgs:[`start|stop`,`path?`]},Bu=(e,t)=>({...O(t),action:Ku(e[0],ju),path:e[1],fps:t.fps,maxSize:t.screenshotMaxSize,quality:t.quality,hideTouches:t.hideTouches,recordingScope:t.recordingScope}),Vu=(e,t)=>({...O(t),action:Ku(e[0],Mu),path:e[1]}),Hu=E(ju,e=>Gu(e)),Uu=E(Mu,e=>Gu(e)),Wu=L({name:`recording`,commands:[I({name:ju,metadata:Pu,definition:Iu,cliSchema:Ru,cliReader:Bu,daemonWriter:Hu,cliOutputFormatter:Ou.record}),I({name:Mu,metadata:Fu,definition:Lu,cliSchema:zu,cliReader:Vu,daemonWriter:Uu})]});function Gu(e){return[e.action,...M(e.path)]}function Ku(t,n){if(t===`start`||t===`stop`)return t;throw new e(`INVALID_ARGS`,`${n} requires start|stop`)}const qu=`replay`,Ju=`test`,Yu=`Replay a recorded session.`,Xu=W(qu,Yu,{path:f(p()),update:g(),backend:p(),maestro:g(),env:Gt()}),Zu=W(Ju,`Run one or more replay scripts.`,{paths:f(Gt()),update:g(),backend:p(),maestro:g(),env:Gt(),failFast:g(),timeoutMs:h(),retries:h(),recordVideo:g(),artifactsDir:p(),shardAll:h(),shardSplit:h()}),Qu=R(Xu,(e,t)=>e.replay.run(t)),$u=R(Zu,(e,t)=>e.replay.test(t)),ed={usageOverride:`replay <path> | replay export <file.ad> [--format maestro] [--out <path>]`,helpDescription:`Replay a recorded session. For Maestro YAML compatibility flows, use replay <flow.yaml> --maestro and keep the target binding such as --platform ios on the replay command.`,summary:Yu,positionalArgs:[`path`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,`replayExportFormat`,...Dr,`timeoutMs`,`out`]},td={usageOverride:`test <path-or-glob>...`,listUsageOverride:`test <path-or-glob>...`,helpDescription:`Run one or more replay scripts as a serial test suite`,summary:`Run replay test suites`,positionalArgs:[`pathOrGlob`],allowsExtraPositionals:!0,allowedFlags:[`replayMaestro`,...Dr,`failFast`,`timeoutMs`,`retries`,`recordVideo`,`artifactsDir`,`reporter`,`reportJunit`,`shardAll`,`shardSplit`]},nd=L({name:`replay`,commands:[I({name:qu,metadata:Xu,definition:Qu,cliSchema:ed,cliReader:(e,t)=>({...O(t),path:P(e[0],`replay requires path`),update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv}),daemonWriter:e=>D(qu,[F(e.path,`replay requires path`)],{...e,replayUpdate:e.update,replayBackend:rd(e),replayEnv:e.env,replayShellEnv:ad(process.env)})}),I({name:Ju,metadata:Zu,definition:$u,cliSchema:td,cliReader:(e,t)=>({...O(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?`maestro`:void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,shardAll:t.shardAll,shardSplit:t.shardSplit}),daemonWriter:e=>D(Ju,e.paths??[],{...id(e),replayUpdate:e.update,replayBackend:rd(e),replayEnv:e.env,replayShellEnv:ad(process.env)})})]});function rd(e){return e.backend??(e.maestro===!0?`maestro`:void 0)}function id(e){let t={...e};return delete t.reporter,delete t.reportJunit,t}function ad(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&n.startsWith(`AD_VAR_`)&&(t[n]=r);return t}const od=[`in-app`,`system`];function sd(e){return{data:e,text:ud(e)}}function cd(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: ${dd(e.visible,e.inputOwner)}`),{data:e,text:t.join(`
36
+ `)}}return V(e)}function ld(e){return e.action===`read`?{data:e,text:e.text}:V(e)}const $={appstate:z(sd),back:B,home:B,rotate:B,"app-switcher":B,keyboard:z(cd),clipboard:z(ld),"tv-remote":B};function ud(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(`
36
37
  `)}if(e.platform===`android`){let t=[`Foreground app: ${e.package??`unknown`}`];return e.activity&&t.push(`Activity: ${e.activity}`),t.join(`
37
- `)}return null}function Ru(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 zu=`appstate`,Bu=`back`,Vu=`home`,Hu=`rotate`,Uu=`app-switcher`,Wu=`keyboard`,Gu=`clipboard`,Ku=[`read`,`write`],qu=[`status`,`dismiss`],Ju=W(zu,`Show foreground app or activity.`,{}),Yu=W(Bu,`Navigate back.`,{mode:_(Nu)}),Xu=W(Vu,`Go to the home screen.`,{}),Zu=W(Hu,`Rotate device orientation.`,{orientation:f(_(Ye))}),Qu=W(Uu,`Open the app switcher.`,{}),$u=W(Wu,`Inspect or dismiss the keyboard.`,{action:_(qu)}),ed=W(Gu,`Read or write clipboard text.`,{action:f(_(Ku)),text:p()}),td=R(Ju,(e,t)=>e.command.appState(t)),nd=R(Yu,(e,t)=>e.command.back(t)),rd=R(Xu,(e,t)=>e.command.home(t)),id=R(Zu,(e,t)=>e.command.rotate(t)),ad=R(Qu,(e,t)=>e.command.appSwitcher(t)),od=R($u,(e,t)=>e.command.keyboard(t)),sd=R(ed,(e,t)=>e.command.clipboard(t)),cd={helpDescription:`Show foreground app/activity`},ld={usageOverride:`back [--in-app|--system]`,allowedFlags:[`backMode`]},ud={usageOverride:`rotate <portrait|portrait-upside-down|landscape-left|landscape-right>`,helpDescription:`Rotate device orientation on iOS and Android`,positionalArgs:[`orientation`]},dd={usageOverride:`keyboard [status|get|dismiss|enter|return]`,helpDescription:`Inspect Android keyboard visibility/type or press/dismiss the device keyboard. To hide the keyboard, use keyboard dismiss. It taps safe controls like Done when available, verifies the keyboard closed, and reports UNSUPPORTED_OPERATION when no safe control is available.`,summary:`Inspect, press, or dismiss the device keyboard`,positionalArgs:[`action?`]},fd={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,helpDescription:`Read or write device clipboard text`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},pd=(e,t)=>O(t),md=(e,t)=>O(t),hd=(e,t)=>O(t),gd=(e,t)=>({...O(t),mode:t.backMode}),_d=(e,t)=>({...O(t),orientation:He(e[0])}),vd=(e,t)=>({...O(t),...Ad(e)}),yd=(e,t)=>({...O(t),...jd(e)}),bd=E(zu),xd=e=>D(Bu,[],{...e,backMode:Od(e.mode)}),Sd=E(Vu),Cd=E(Hu,e=>[F(e.orientation,`rotate requires orientation`)]),wd=E(Uu),Td=E(Wu,e=>M(e.action)),Ed=E(Gu,e=>kd(e)),Dd=L({name:`system`,commands:[I({name:zu,metadata:Ju,definition:td,cliSchema:cd,cliReader:pd,daemonWriter:bd,cliOutputFormatter:$.appstate}),I({name:Bu,metadata:Yu,definition:nd,cliSchema:ld,cliReader:gd,daemonWriter:xd,cliOutputFormatter:$.back}),I({name:Vu,metadata:Xu,definition:rd,cliReader:md,daemonWriter:Sd,cliOutputFormatter:$.home}),I({name:Hu,metadata:Zu,definition:id,cliSchema:ud,cliReader:_d,daemonWriter:Cd,cliOutputFormatter:$.rotate}),I({name:Uu,metadata:Qu,definition:ad,cliReader:hd,daemonWriter:wd,cliOutputFormatter:$[`app-switcher`]}),I({name:Wu,metadata:$u,definition:od,cliSchema:dd,cliReader:vd,daemonWriter:Td,cliOutputFormatter:$.keyboard}),I({name:Gu,metadata:ed,definition:sd,cliSchema:fd,cliReader:yd,daemonWriter:Ed,cliOutputFormatter:$.clipboard})]});function Od(e){return e===`in-app`||e===`system`?e:void 0}function kd(e){return e.action===`read`?[`read`]:[`write`,e.text]}function Ad(t){if(t.length>1)throw new e(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return w({action:Md(t[0])})}function jd(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 Md(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 Nd=[no,_c,Ai,Dd,Ql,ku,$c,Vl,Ii,_u,Sc,Rr];function Pd(){return Nd.flatMap(e=>[...e.metadata])}function Fd(){return Nd.flatMap(e=>[...e.definitions])}function Id(){return Bd(`cliSchemas`)}function Ld(){return Bd(`cliReaders`)}function Rd(){return Bd(`daemonWriters`)}function zd(){return Bd(`cliOutputFormatters`)}function Bd(e){let t={};for(let n of Nd){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{Rt as A,cr as C,pr as D,dr as E,Dt as M,gr as O,lr as S,ur as T,hr as _,Fd as a,tr as b,Cs as c,jr as d,wr as f,Or as g,Dr as h,Rd as i,Nt as j,It as k,Nr as l,vr as m,Ld as n,Pd as o,Tr as p,Id as r,Nu as s,zd as t,Ar as u,er as v,ir as w,nr as x,rr as y};
38
+ `)}return null}function dd(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 fd=`appstate`,pd=`back`,md=`home`,hd=`rotate`,gd=`app-switcher`,_d=`keyboard`,vd=`clipboard`,yd=`tv-remote`,bd=[`read`,`write`],xd=[`status`,`dismiss`],Sd=W(fd,`Show foreground app or activity.`,{}),Cd=W(pd,`Navigate back.`,{mode:_(od)}),wd=W(md,`Go to the home screen.`,{}),Td=W(hd,`Rotate device orientation.`,{orientation:f(_(et))}),Ed=W(gd,`Open the app switcher.`,{}),Dd=W(_d,`Inspect or dismiss the keyboard.`,{action:_(xd)}),Od=W(vd,`Read or write clipboard text.`,{action:f(_(bd)),text:p()}),kd=W(yd,`Press a TV remote/D-pad button.`,{button:f(_(nt)),durationMs:h(`Press duration in milliseconds. tvOS uses the exact hold duration; Android TV maps any positive value to an ADB longpress (${qe(`android`)}).`,{min:0})}),Ad=R(Sd,(e,t)=>e.command.appState(t)),jd=R(Cd,(e,t)=>e.command.back(t)),Md=R(wd,(e,t)=>e.command.home(t)),Nd=R(Td,(e,t)=>e.command.rotate(t)),Pd=R(Ed,(e,t)=>e.command.appSwitcher(t)),Fd=R(Dd,(e,t)=>e.command.keyboard(t)),Id=R(Od,(e,t)=>e.command.clipboard(t)),Ld=R(kd,(e,t)=>e.command.tvRemote(t)),Rd={helpDescription:`Show foreground app/activity`},zd={usageOverride:`back [--in-app|--system]`,allowedFlags:[`backMode`]},Bd={usageOverride:`rotate <portrait|portrait-upside-down|landscape-left|landscape-right>`,helpDescription:`Rotate device orientation on iOS and Android`,positionalArgs:[`orientation`]},Vd={usageOverride:`keyboard [status|get|dismiss|enter|return]`,helpDescription:`Inspect Android keyboard visibility/type or press/dismiss the device keyboard. To hide the keyboard, use keyboard dismiss. It taps safe controls like Done when available, verifies the keyboard closed, and reports UNSUPPORTED_OPERATION when no safe control is available.`,summary:`Inspect, press, or dismiss the device keyboard`,positionalArgs:[`action?`]},Hd={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,helpDescription:`Read or write device clipboard text`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},Ud={usageOverride:`tv-remote [press|longpress] ${Ge} [--duration-ms <ms>]`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,helpDescription:`Press a TV remote/D-pad button on Android TV or tvOS. Use longpress for a 500ms held remote button; --duration-ms overrides the preset. Aliases ok, center, and enter map to select.`,summary:`Press a TV remote/D-pad button`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},Wd=(e,t)=>O(t),Gd=(e,t)=>O(t),Kd=(e,t)=>O(t),qd=(e,t)=>({...O(t),mode:t.backMode}),Jd=(e,t)=>({...O(t),orientation:Ne(e[0])}),Yd=(e,t)=>({...O(t),...uf(e)}),Xd=(e,t)=>({...O(t),...df(e)}),Zd=(e,t)=>({...O(t),...ff(e,t.durationMs)}),Qd=E(fd),$d=e=>D(pd,[],{...e,backMode:cf(e.mode)}),ef=E(md),tf=E(hd,e=>[F(e.orientation,`rotate requires orientation`)]),nf=E(gd),rf=E(_d,e=>M(e.action)),af=E(vd,e=>lf(e)),of=E(yd,e=>[F(e.button,`tv-remote requires button`)]),sf=L({name:`system`,commands:[I({name:fd,metadata:Sd,definition:Ad,clientMethod:`appState`,cliSchema:Rd,cliReader:Wd,daemonWriter:Qd,cliOutputFormatter:$.appstate}),I({name:pd,metadata:Cd,definition:jd,clientMethod:`back`,cliSchema:zd,cliReader:qd,daemonWriter:$d,cliOutputFormatter:$.back}),I({name:md,metadata:wd,definition:Md,clientMethod:`home`,cliReader:Gd,daemonWriter:ef,cliOutputFormatter:$.home}),I({name:hd,metadata:Td,definition:Nd,clientMethod:`rotate`,cliSchema:Bd,cliReader:Jd,daemonWriter:tf,cliOutputFormatter:$.rotate}),I({name:gd,metadata:Ed,definition:Pd,clientMethod:`appSwitcher`,cliReader:Kd,daemonWriter:nf,cliOutputFormatter:$[`app-switcher`]}),I({name:_d,metadata:Dd,definition:Fd,clientMethod:`keyboard`,cliSchema:Vd,cliReader:Yd,daemonWriter:rf,cliOutputFormatter:$.keyboard}),I({name:vd,metadata:Od,definition:Id,clientMethod:`clipboard`,cliSchema:Hd,cliReader:Xd,daemonWriter:af,cliOutputFormatter:$.clipboard}),I({name:yd,metadata:kd,definition:Ld,clientMethod:`tvRemote`,cliSchema:Ud,cliReader:Zd,daemonWriter:of,cliOutputFormatter:$[`tv-remote`]})]});function cf(e){return e===`in-app`||e===`system`?e:void 0}function lf(e){return e.action===`read`?[`read`]:[`write`,e.text]}function uf(t){if(t.length>1)throw new e(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return w({action:pf(t[0])})}function df(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 ff(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: ${nt.join(`, `)}.`);let a=n??(r===`longpress`?500:void 0);return w({button:Ze(i[0]),durationMs:a})}function pf(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 mf=[so,Cc,Fi,sf,Tu,nd,Tl,mu,Vi,Wu,Ac,Ur];function hf(){return mf.flatMap(e=>[...e.metadata])}function gf(){return mf.flatMap(e=>[...e.definitions])}function _f(){return xf(`cliSchemas`)}function vf(){return xf(`cliReaders`)}function yf(){return xf(`daemonWriters`)}function bf(){return xf(`cliOutputFormatters`)}function xf(e){let t={};for(let n of mf){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{xr as A,sr as C,hr as D,lr as E,Ut as M,Rt as N,gr as O,Mt as P,or as S,pr as T,Mr as _,gf as a,ar as b,od as c,Rr as d,Fr as f,Cr as g,Ar as h,yf as i,Vt as j,vr as k,Dc as l,kr as m,vf as n,hf as o,Ir as p,_f as r,sf as s,bf as t,Os as u,Nr as v,mr as w,cr as x,br as y};