agent-device 0.21.11 → 0.21.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.11.apk → agent-device-android-ime-helper-0.21.12.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.12.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.11.manifest.json → agent-device-android-ime-helper-0.21.12.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.11.apk → agent-device-android-snapshot-helper-0.21.12.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.12.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.11.manifest.json → agent-device-android-snapshot-helper-0.21.12.manifest.json} +6 -6
  7. package/apple/fold-helper/Fold.m +97 -0
  8. package/apple/macos-helper/Package.swift +1 -8
  9. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +0 -2
  10. package/dist/src/back-mode.js +1 -1
  11. package/dist/src/cli-help.js +4 -2
  12. package/dist/src/client-types.d.ts +2 -4
  13. package/dist/src/device-input-state.d.ts +1 -1
  14. package/dist/src/device-rotation.js +1 -1
  15. package/dist/src/helper.js +2 -2
  16. package/dist/src/interactor.js +3 -3
  17. package/dist/src/internal/bin.js +1 -1
  18. package/dist/src/internal/daemon.js +2 -2
  19. package/dist/src/macos-facade.js +1 -1
  20. package/dist/src/provider-webdriver.js +1 -1
  21. package/dist/src/registry.js +35 -35
  22. package/dist/src/runtime4.js +4 -4
  23. package/dist/src/script.js +1 -1
  24. package/dist/src/sdk-batch.js +1 -1
  25. package/dist/src/sdk-selectors.d.ts +12 -1
  26. package/dist/src/simulator-facade.js +1 -1
  27. package/dist/src/simulator.js +1 -1
  28. package/package.json +2 -1
  29. package/server.json +2 -2
  30. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.11.apk.sha256 +0 -1
  31. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.11.apk.sha256 +0 -1
  32. package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubPose.swift +0 -47
  33. package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +0 -65
  34. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +0 -225
  35. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +0 -57
  36. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +0 -108
  37. package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubPoseTests.swift +0 -30
  38. package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +0 -65
@@ -1,2 +1,2 @@
1
1
  import{D as e,g as t}from"./sdk-contracts.js";import{m as n,n as r}from"./sdk-device.js";function i(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}const a=[`visible`,`hidden`,`exists`,`absent`,`editable`,`selected`,`focused`,`text`];function o(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function s(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function c(e){return e.width*e.height}function l(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function u(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function d(e,t){return f(e.x,e.x+e.width,t.x,t.x+t.width)&&f(e.y,e.y+e.height,t.y,t.y+t.height)}function f(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function ee(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function te(e){return ee(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function ne(e){return new Map(e.map(e=>[e.index,e]))}function p(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function re(e,t,n){return p(e,t,ne(e),e=>n(e)?e:null)}function m(e){let t=e.trim().replaceAll(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function ie(e,t){let n=m(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function ae(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function oe(e){if(typeof e!=`string`)return!1;let t=e.trim();return t?!/^(true|false)$/i.test(t):!1}function h(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}const se=Symbol(`SnapshotVisibility`);function ce(e,t={}){let n,r,i=()=>(n||(n=ne(e),t.onNodeMapBuilt?.()),n),a=()=>(r||(r=ue(e),t.onViewportRectsCollected?.()),r),o=n=>fe(e,n,a(),t.onContainingRectFallback),s=n=>{let r=he(n,i(),e=>!!e.rect)?.rect;if(r)return r;let o=a();return o.length===0?null:fe(e,n.rect??{x:0,y:0,width:0,height:0},o,t.onContainingRectFallback)},c=e=>{if(!e.rect)return!0;let t=s(e);return!t||d(e.rect,t)},l=e=>e.rect?c(e)?me(e.rect,o(e.rect)):!1:!0;return{[se]:!0,get nodeByIndex(){return i()},get viewportRects(){return a()},findAncestor(t,n){return p(e,t,i(),n)},isVisibleInEffectiveViewport:c,isVisibleOnScreen:l,resolveEffectiveViewport:s,resolveViewport:o}}function le(e){let t=[e.type,e.role,e.subrole].map(e=>m(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function ue(e){return e.flatMap(e=>le(e)&&o(e.rect)?[e.rect]:[])}function de(e,t,n){return fe(e,t,n??ue(e))}function fe(e,n,r,i){let a=t(n),o=e=>l(e,a.x,a.y);return(u(r.filter(o))??u(r))||(i?.(),u(e.flatMap(e=>pe(e.rect)&&o(e.rect)?[e.rect]:[])))}function pe(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function me(e,t){return!t||t.width<=0||t.height<=0||l(t,e.x+e.width/2,e.y+e.height/2)}function he(e,t,n=()=>!0){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&te(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function ge(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=m(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&o(e.rect):e.hittable===!0||o(e.rect)}function g(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function _e(e,t){return ie(e.type??``,t)&&e.enabled!==!1}const ve=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),ye=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),_=new Set([...ve,...ye]),v=[..._],be=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function xe(e){return be.has(e.trim().toLowerCase())}const Se=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
2
- `],[`r`,`\r`],[`t`,` `]]);function y(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Ee(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>we(e))}}function b(e){try{return y(e)}catch{return null}}function x(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return _.has(e)}return _.has(t.toLowerCase())}function Ce(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||_.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=ke(i).trim();return a?{key:r,value:a}:null}function S(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!x(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&b(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function we(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=De(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Te)}}function Te(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!ye.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!_.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(ye.has(i)){let t=Me(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:ke(a)}}function Ee(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Ne(t,a)){i=Oe(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function De(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ne(t,e)){i=Oe(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function Oe(e,t){return e?e===t?null:e:t}function ke(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Ae(t.slice(1,-1)):t}function Ae(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=je(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function je(e){return Se.get(e)??null}function Me(e){let t=ke(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ne(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Pe(e){return a.includes(e)}const Fe=`is requires predicate: ${a.join(`|`)}`;function Ie(e){let t=e.toLowerCase();return Pe(t)?{ok:!0,predicate:t}:i(Fe,Le)}const Le=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function Re(e){if(Pe((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(Pe(n)&&b(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function ze(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=h(n),s=_e(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):Ve(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break;default:return Be(t)}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function Be(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Ve(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(o(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=He(e,t,n);return r?o(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function He(e,t,n){return t.findAncestor(e,e=>ge(e,n)?e:null)}function Ue(e){let t=Re(e),n=t[0]??``;return{predicate:n,split:S(t.slice(1),{preferTrailingValue:n===`text`})}}const We=`is requires a selector expression`,Ge=`is text requires expected text value`;function Ke(e){let{predicate:t,split:n}=Ue([...e]),r=Ie(t);if(!r.ok)return r;if(!n)return i(We);let a=n.rest.join(` `).trim();return r.predicate===`text`&&!a?i(Ge):r.predicate!==`text`&&n.rest.length>0?i(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:a}}function qe(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:i(`get only supports text or attrs`)}function Je(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:i(`get requires @ref or selector expression`)}function Ye(e){return e?{ok:!0,text:e}:i(`wait requires text`)}function Xe(e){return Array.from(new Set(e))}function Ze(e){return JSON.stringify(Qe(e))}function Qe(e){if(Array.isArray(e))return e.map(Qe);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,Qe(t[e])]))}function $e(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t+=1;for(;n>t&&e[n-1]===`-`;)--n;return e.slice(t,n)}const et=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,tt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,nt=4096;function rt(e){return e.normalize(`NFC`)}function it(e){if(e===void 0)return;let t=rt(e);return t.length>0?t:void 0}function at(e){return rt(e)}function ot(e){if(e===void 0)return;let t=rt(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function C(e){return Buffer.byteLength(e,`utf8`)}function w(e,t){if(C(e)<=t)return e;let n=e.length;for(;n>0&&C(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function st(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(ct),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=lt(e.scrollRegion)),e.rect&&(t.rect=ut(e.rect)),t.verification=e.verification,t}function ct(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function lt(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function ut(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function dt(e){return JSON.stringify(st(e))}function ft(e){return`# agent-device:target-v1 ${dt(e)}`}function pt(e){return JSON.stringify({source:st(e.source),destination:st(e.destination)})}function mt(e){return`# agent-device:targets-v1 ${pt(e)}`}function ht(e){let t=e.trim(),n=tt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:gt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function gt(t){if(C(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:vt(JSON.stringify(r.source)),destination:vt(JSON.stringify(r.destination))}}function _t(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=et.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:vt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function vt(t){if(C(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${nt}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=yt(r.role,`role`),a=bt(r.id,`id`),o=xt(r.label,`label`),s=Ct(r.ancestry),c=Tt(r.sibling,`sibling`,0),l=Tt(r.viewportOrder,`viewportOrder`,0),u=Et(r.scrollRegion),d=Dt(r.rect),f=Ot(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function yt(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return St(at(t),n)}function bt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=it(t);return r===void 0?void 0:St(r,n)}function xt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=ot(t);return r===void 0?void 0:St(r,n)}function St(t,n){if(C(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Ct(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>wt(e,t))}function wt(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=yt(r.role,`ancestry[${n}].role`),a=xt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Tt(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function Et(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=yt(n.role,`scrollRegion.role`),i=bt(n.id,`id`),a=xt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Dt(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:T(n.x,`rect.x`),y:T(n.y,`rect.y`),width:T(n.width,`rect.width`),height:T(n.height,`rect.height`)}}function T(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function Ot(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function kt(e){let t=at(m(e.type??``)),n=it(e.identifier),r=ot(e.label);return{...n===void 0?{}:{id:w(n,256)},role:w(t,256),...r===void 0?{}:{label:w(r,256)}}}function At(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function jt(e,t){let n=0;for(let r of e)kt(r).id===t&&(n+=1);return n}function Mt(e,t){if(e.id===void 0||jt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Nt(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function Pt(e,t){return{documentOrder:e.index,sibling:Nt(t,e)}}function Ft(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function It(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Lt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Rt(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function zt(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Bt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Vt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Ht(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Vt(r,e))return[`ancestry[${n}]: recorded=${Bt(r)} observed=${Bt(e)}`]}return[]}function Ut(e,t,n={}){let r=[],i=m(e.type??``),a=Wt(e,n.nodes),o=D(e.label),s=D(e.value),c=D(h(e)),l=n.action===`fill`;a&&r.push(`id=${E(a)}`),i&&o&&r.push(l?`role=${E(i)} label=${E(o)} editable=true`:`role=${E(i)} label=${E(o)}`),o&&r.push(l?`label=${E(o)} editable=true`:`label=${E(o)}`),s&&r.push(l?`value=${E(s)} editable=true`:`value=${E(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${E(c)} editable=true`:`text=${E(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${E(i)} editable=true`);let u=Xe(r);return u.length===0&&i&&u.push(l?`role=${E(i)} editable=true`:`role=${E(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function Wt(e,t){let n=D(e.identifier);if(!n||!t)return n;let r=kt(e).id;return r===void 0?n:jt(t,r)>1?null:n}function E(e){return JSON.stringify(e)}function D(e){return e&&e.trim()||null}const Gt=[`any`,`text`,`label`,`value`,`role`,`id`],Kt=[`text`,`label`,`value`,`role`,`id`];function qt(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function Jt(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Yt(e,t,n,r={}){let i=k(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=Xt(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function Xt(e,t,n){switch(t){case`role`:return Zt(e.type,n);case`label`:return O(e.label,n);case`value`:return O(e.value,n);case`id`:return O(e.identifier,n);default:return Math.max(O(e.label,n),O(e.value,n),O(e.identifier,n))}}function O(e,t){let n=k(e??``);return n?n===t?2:+!!n.includes(t):0}function Zt(e,t){let n=Qt(e??``);return n?n===t?2:+!!n.includes(t):0}function k(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function Qt(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const $t=`find requires a value`,en=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function tn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=an([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:$t}}const nn=[`exists`,`list`,`click`,`focus`];function rn(e){return nn.includes(e)}function an(t){let n=`any`,r=0;Kt.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=qt(a[0]);if(rn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:on(a[1])};if(o===`wait`){let e=cn(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:en})}function on(t){let n=t?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}function sn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:b(t)?t:null}function cn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function ln(e,t,n){return t.terms.every(t=>un(e,t,n))}function un(e,t,n){switch(t.key){case`id`:return A(e.identifier,String(t.value));case`role`:return A(m(e.type??``),String(t.value));case`label`:return A(e.label,String(t.value));case`value`:return A(e.value,String(t.value));case`text`:return A(h(e),String(t.value));case`appname`:return A(e.appName,String(t.value));case`windowtitle`:return A(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return _e(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function A(e,t){return k(e??``)===k(t)}function dn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[],o=null;for(let[s,c]of t.selectors.entries()){let t=vn(e,c,n.platform,r);if(a.push({selector:c.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(o??={selector:c,selectorIndex:s,matchedNodes:t.candidates},i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.disambiguated,selector:c,selectorIndex:s,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}}return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.firstNode,selector:c,selectorIndex:s,matches:t.count,diagnostics:a}}}}return{resolution:null,matchedNodes:o?.matchedNodes??[],firstMatch:o}}function fn(e,t,n){return dn(e,t,n).resolution}function pn(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:ln(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function mn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Sn(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const hn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function gn(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function _n(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function vn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=ce(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||ln(l,t,n)&&(i+=1,a??=l,o.push(l),yn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:bn(o,s.best,c),candidates:o}}function yn(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Cn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function bn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||xn(i,r,n).result>0)&&(r=i);return r?xn(t,r,n).criterion:null}function xn(e,t,n){let r=n(e);return r===n(t)?Cn(e,t):{result:r?1:-1,criterion:`visible`}}function Sn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||ln(a,t,n)&&(i+=1);return i}function Cn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=wn(e),a=wn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function wn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Tn={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1},cropTarget:{ambiguity:`fail-closed`,requireRect:!0}};function En(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Dn(e,t){let n=e===`is`?Ue([...t]).split:S([...t]);return n?b(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function On(e){return{platform:e.platform,...En({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function kn(e,t,n){let r=b(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=dn(t,r,On(n));return i?{kind:`resolved`,winner:i.node,matchedNodes:a,matchCount:a.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}:{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function An(e,t,n={}){return Ut(e,t,n)}function jn(e,t,n){let r=b(e);if(!r)return;let i=fn(t,r,On(n));if(i)return{node:i.node,basis:Nn(i.selector)}}function Mn(e){if(!e)return;let t=b(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Nn(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}function Pn(e,t){let n=b(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Fn(n.selectors,r,i):In(n.selectors[0],r,new Set(t.booleanKeys),i)}function Fn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Ln(r.key,t,n)&&typeof r.value==`string`?r.value:void 0}),i=r[0];return i!==void 0&&r.every(e=>e===i)?i:null}function In(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Ln(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Rn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Ln(e,t,n){return t.has(e)||n[e]!==void 0}function Rn(e,t,n){return t.has(e.key)&&typeof e.value===n}function zn(e){let t=b(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function Bn(e,t){if(!t)return!1;let n=b(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function Vn(e,t){return b(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Hn(e){return y(e).selectors.map(e=>e.raw)}function Un(e){return b(e)!==null}function Wn(e){y(e)}function j(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Gn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Kn(e){let t=e[0];if(t===void 0)return null;let n=j(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=j(e.at(-1));return t===`text`?qn(e,r):t===`stable`?Jn(e):t===`absent`?Yn(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:Zn(e,r)}function qn(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function Jn(e){let t=e.slice(1),n=t.length>1?j(t[1]):null;return{kind:`stable`,quietMs:t.length>0?j(t[0]):null,timeoutMs:n}}function Yn(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=S(n);return n.length>0&&r?.rest.length===0&&Un(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:Xn(n)}}function Xn(e){let t=e.join(` `);return t.length>0?`wait absent requires one valid selector; received "${t}". Use wait absent '<selector>' [timeoutMs].`:`wait absent requires <selector> [timeoutMs].`}function Zn(e,t){let n=t===null?e.slice():e.slice(0,-1),r=S(n);return r&&r.rest.length===0&&Un(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:Qn(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function Qn(e,t){for(let t of e){let n=Ce(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:$n(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:er(t,e)}:e.some(e=>x(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:tr(e)}:null}function $n(e,t){let n=t.join(` `),r=xe(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${v.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function er(e,t){let n=t.join(` `);return`Selector ${e.selectorExpression} is followed by unexpected extra arguments: "${e.rest.join(` `)}". Selector values with spaces need quotes, e.g. label="Sign in". Use wait '<selector>' [timeoutMs], or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function tr(e){let t=e.join(` `),n=e.filter(e=>!x(e)),r=e.filter(e=>x(e));if(n.length>0){let e=n[0],i=Gn.has(e.toLowerCase())?` "${e}" describes a condition, not a selector key. Use the selector form: `+(e.toLowerCase()===`gone`||e.toLowerCase()===`disappears`?`wait absent '${r.join(` `)}' [timeoutMs] to wait for zero matches.`:`wait '${r.join(` `)}' [timeoutMs] to wait for it to appear.`):` "${e}" is not a recognized selector key (${v.join(`, `)}).`;return`"${t}" mixes plain word "${e}" with selector-shaped "${r.join(` `)}", so it is neither a valid selector nor safe as literal text.${i} Use wait '<selector>' [timeoutMs] for a selector, or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}return`"${t}" looks like a selector key but is not a valid selector expression. Use wait '<selector>' [timeoutMs], e.g. wait '${e[0]}="value"' [timeoutMs], or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}function nr(e){let t=Kn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const rr=24e4,ir=3e4,ar=3e5,M={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},or={budget:{source:`none`},envelopeMs:15e4,onTimeout:`reset-daemon`};function sr(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return cr(n,t.positionals??[])??lr(n,t.flags)??n.envelopeMs}function cr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:fr(e,n)}function lr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?dr(e,e.budget,t):e.budget.envelope===`margin`?ur(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function ur(e,t){let n=typeof t?.timeoutMs==`number`?fr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?pr({...e,envelopeMs:n},t.waitMs):n}function dr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?pr(e,r):e.envelopeMs}function fr(e,t){return Math.max(e.envelopeMs,t+ir)}function pr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+ir)}const mr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function hr(e){if(e!==void 0)return mr[e]}function N(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function gr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function _r(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function vr(e){let t=e.trim();if(t.length===0)throw TypeError(`Managed local runtime owner requires a non-empty allocator instance identity`);return Object.freeze({kind:`managed-local`,instance:t})}function P(e){switch(e.kind){case`local-family`:return`local:${e.family}`;case`managed-local`:return`managed:${JSON.stringify([e.instance])}`;case`provider-runtime`:return`provider:${JSON.stringify([e.provider,e.instance])}`}}function yr(e,t){return P(e)===P(t)}function br(e,t){return e.available?t():{}}function xr(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!Cr(e.requestGeneration))throw TypeError(`Managed binding fence requires non-empty requester and identity incarnation ids and a non-negative integer request generation`);return Object.freeze({token:JSON.stringify([e.requesterId,e.identityIncarnationId]),generation:e.requestGeneration})}function Sr(e){let t=wr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!Cr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return xr(i).token===e.token?i:null}function Cr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function wr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Tr(e,t){let n={},r={};for(let i of t.required){let t=I(e.facts.operations,i);if(n[i]=t,!t.available)throw Ar(i,t);r[i]=Or(e.operations,i)}for(let i of t.preferred){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Or(e.operations,i))}for(let i of t.conditional??[]){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Or(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function I(e,t){let n=e[t];if(!Er(n))throw N(`Runtime owner omitted the ${t} fact`);let r=Dr(n);if(r)return r;throw N(`Runtime owner returned an invalid ${t} fact`)}function Er(e){return typeof e==`object`&&!!e&&`available`in e}function Dr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&kr(e.reason)&&(e.hint===void 0||typeof e.hint==`string`))return Object.freeze({available:!1,reason:e.reason,...e.hint===void 0?{}:{hint:e.hint}})}function Or(e,t){let n=e[t];if(typeof n!=`function`)throw N(`Runtime owner advertised ${t} without an implementation`);return n}function kr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Ar(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function jr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function Mr(){return e=>{let t=Nr(e.required,`required`),n=Nr(e.preferred??[],`preferred`),r=Nr(e.conditional??[],`conditional`),i=[[`required`,t],[`preferred`,n],[`conditional`,r]];for(let e=0;e<i.length;e+=1){let t=i[e];if(t)for(let n of i.slice(e+1)){let e=n[1].find(e=>t[1].includes(e));if(e!==void 0)throw TypeError(`Runtime operation cannot be both ${t[0]} and ${n[0]}: ${e}`)}}return Object.freeze(r.length===0?{required:t,preferred:n}:{required:t,preferred:n,conditional:r})}}function Nr(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}const L=Mr(),Pr=L({required:[`bootTarget`]}),Fr=L({required:[`bootTargetHeadless`]}),Ir=L({required:[`ensureReady`,`listApps`]}),Lr=L({required:[`captureSnapshot`]}),Rr=L({required:[`setViewport`]}),zr=L({required:[`focusPoint`]}),Br=L({required:[`typeText`]}),Vr=L({required:[`back`]}),Hr=L({required:[`home`]}),Ur=L({required:[`setOrientation`]}),Wr=L({required:[`setFoldPose`]}),Gr=L({required:[`tvRemote`]}),Kr=L({required:[`keyboardStatus`]}),qr=L({required:[`keyboardDismiss`]}),Jr=L({required:[`keyboardEnter`]}),Yr=L({required:[`appSwitcher`]}),Xr=L({required:[`actionButton`]}),Zr=L({required:[`triggerAppEvent`]}),Qr=L({required:[`setSetting`]}),$r=L({required:[`readSetting`]}),ei=L({required:[`readAlert`]}),ti=L({required:[`awaitAlert`]}),ni=L({required:[`acceptAlert`]}),ri=L({required:[`dismissAlert`]}),ii=L({required:[`readClipboard`]}),ai=L({required:[`writeClipboard`]}),oi=L({required:[`perfFrames`]}),si=L({required:[`perfMemorySample`]}),ci=L({required:[`perfMemorySnapshot`]}),li=L({required:[`perfNativeCaptureStart`]}),ui=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),di=L({required:[`perfProfileReport`]}),fi=Object.freeze([oi,si,ci,li,ui,di]),R=L({required:[`tapPoint`]}),pi=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),mi=L({required:[`longPressPoint`]}),hi=L({required:[`captureSnapshot`,`longPressPoint`]}),gi=L({required:[`hoverPoint`]}),_i=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),vi=L({required:[`fillPoint`]}),yi=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),bi=Object.freeze([R,pi]),xi=bi,Si=Object.freeze([mi,hi]),Ci=Object.freeze([gi,_i]),wi=Object.freeze([vi,yi]);function Ti(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:pi}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:yi}:{kind:`fill-point`,use:vi};case`longpress`:return t?{kind:`captured-long-press`,use:hi}:{kind:`long-press-point`,use:mi};case`hover`:return t?{kind:`captured-hover`,use:_i}:{kind:`hover-point`,use:gi}}}const Ei=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Di=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Oi=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),ki=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ai=L({required:[`gestureViewport`]}),ji=L({required:[`scrollDirection`]}),Mi=L({required:[`scrollDirection`,`captureSnapshot`]}),Ni=Object.freeze({plan:Ei,"directional-fling":Di,"multi-touch":Oi,"target-authored-drag":ki}),Pi=Object.freeze([Ei,Di,Oi,ki]),Fi=Object.freeze([Ei]),Ii=Object.freeze([ji,Mi]);function Li(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Ri(e){return e.intent===`drag`?`target-authored-drag`:Li(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function zi(e){let t=Ri(e);switch(t){case`plan`:return z(t);case`directional-fling`:return z(t);case`multi-touch`:return z(t);case`target-authored-drag`:return z(t)}}function z(e){let t=Ni[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function Bi(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:ji}):Object.freeze({kind:`edge`,edge:e.edge,use:Mi}):Object.freeze({kind:`until`,until:e.until,use:Mi})}const Vi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Hi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Ui=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Wi=L({required:[`captureSnapshot`]}),Gi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Ki=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),qi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),Ji=L({required:[`captureSnapshot`],conditional:[`findText`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),Xi=Object.freeze([Wi,Gi]),Zi=Object.freeze([Ki,qi]),Qi=L({required:[`captureSnapshot`,`focusPoint`]}),$i=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),ea=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),ta=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),na=Object.freeze([Ki,qi,Wi,Gi,Qi,$i,ea,ta]),ra=Object.freeze([Ji,Yi]),ia=Object.freeze([Lr,Vi,Hi,Ui]),B=Object.freeze({"capture-only":Xi,"element-text":Zi,"wait-observation":ra,"find-focus":Object.freeze([Qi,$i]),"find-type":Object.freeze([ea,ta])});function aa(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function oa(e){switch(e.intent){case`capture-only`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`element-text`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`wait-observation`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`find-focus`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`find-type`:return V(e.hasActiveApp,e.intent,B[e.intent])}}function V(e,t,n){return Object.freeze(e?{kind:`selector-active-app`,intent:t,operation:`captureSnapshot`,use:n[0]}:{kind:`selector-without-active-app`,intent:t,operation:`captureSnapshotWithoutActiveApp`,use:n[1]})}function sa(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:Vi}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:Ui}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Lr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Hi})}const ca=L({required:[`captureScreenshot`]}),la=L({required:[`captureScreenshot`,`captureSnapshot`]}),ua=Object.freeze([ca,la]);function da(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:la}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:la}):Object.freeze({kind:`capture`,use:ca})}const fa=Object.freeze([Pr,Fr]),pa=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Pr}),ma=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Fr});function ha(e){return e.headless?ma:pa}const ga=L({required:[`ensureReady`,`appState`]}),_a=Object.freeze([ga]),va=L({required:[`shutdownTarget`]}),ya=Object.freeze([ii,ai]),ba=Object.freeze([Qr,$r]),xa=[`text-size`],Sa=Object.freeze({kind:`write`,use:Qr});function Ca(e){let t=wa(e?.[0]);return e?.length!==1||t===void 0?Sa:xa.includes(t)?Object.freeze({kind:`read`,setting:t,use:$r}):Sa}function wa(e){let t=e?.trim().toLowerCase();return xa.find(e=>e===t)}const Ta=Object.freeze([ei,ti,ni,ri]),Ea=Object.freeze([Kr,qr,Jr]),Da=L({required:[`deployApp`]}),Oa=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),ka=L({required:[`ensureReady`,`sendPushNotification`]}),Aa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),ja=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Ma=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Na=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Pa(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Na}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:ja}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Ma}):Object.freeze({kind:`open`,use:Aa})}const Fa=Object.freeze([Aa,ja,Ma,Na]),Ia=L({required:[`closeApplication`,`finalizeApplicationClose`]}),La=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),Ra=Object.freeze([Ia,La]),za=L({required:[`finalizeApplicationClose`]}),Ba=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Va=L({required:[`prepareAppleRunner`]}),Ha=L({required:[`clearRuntimeHints`]}),Ua=L({required:[`configureProviderPortReverse`]}),Wa=Object.freeze([Ha,Ua]),H=L({required:[`appLogInspect`]}),Ga=L({required:[`appLogInspect`,`appLogDoctor`]}),Ka=L({required:[`appLogInspect`,`appLogStart`]}),qa=L({required:[],preferred:[`appLogInspect`]}),Ja=Object.freeze([H,Ga,Ka]);function Ya(t){let n=(t.action??`path`).toLowerCase();if(t.restart&&n!==`clear`)throw new e(`INVALID_ARGS`,`logs --restart is only supported with logs clear`);switch(n){case`path`:return Object.freeze({kind:`path`,requiresAppSession:!1,use:H});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:Ka});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:H});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Ga});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:H});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:Ka}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:H});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const Xa=L({required:[`audioProbeStart`]}),Za=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),Qa=L({required:[`audioProbeQuery`]}),$a=Object.freeze([Xa,Za,Qa]);function eo(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:Qa});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:Xa});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const to=[`probe`],no=[`start`,`status`,`stop`];function ro(t){let n=(t?.[0]??`probe`).toLowerCase();if(!to.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!no.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${no.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:io(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:io(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function io(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,n.message);return r}const ao=L({required:[`networkDump`]}),oo=L({required:[],preferred:[`networkDump`]}),so=[`dump`,`log`],co=[`summary`,`headers`,`body`,`all`];function lo(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!uo(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!fo(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:ao})}function uo(e){return so.some(t=>t===e)}function fo(e){return co.some(t=>t===e)}function po(e){let t=new Map;for(let r of e){if(!n(r.family))throw TypeError(`Unknown platform family registration: ${String(r.family)}`);if(t.has(r.family))throw TypeError(`Duplicate platform family registration: ${r.family}`);t.set(r.family,mo(r))}let i=r.filter(e=>!t.has(e));if(i.length>0)throw TypeError(`Missing platform family registrations: ${i.join(`, `)}`);let a=Object.freeze([...r]),o=Object.freeze(a.map(e=>ho(t,e)));return Object.freeze({families:a,modules:o,get:e=>ho(t,e)})}function mo(e){return Object.freeze({...e})}function ho(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const go=Object.freeze({kind:`device-inventory`});function _o(e){if(typeof e!=`object`||!e)throw wo();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&U(n,[`kind`]))&&!(t.kind===`host`&&U(n,[`kind`]))&&!(t.kind===`inventory`&&U(n,[`kind`,`use`])&&yo(t.use))&&!(t.kind===`device-runtime`&&U(n,[`kind`,`use`])&&bo(t.use))&&!(t.kind===`device-runtime`&&(U(n,[`kind`,`uses`])||U(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&vo(t.uses)))throw wo()}function vo(e){if(!Array.isArray(e)||e.length===0||!e.every(bo))return!1;let t=e.map(jr);return new Set(t).size===t.length}function yo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&U(Object.keys(t).sort(),[`kind`])}function bo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[So(t.required),So(t.preferred),So(t.conditional??[])];if(!xo(n))return!1;let r=n.flat();return new Set(r).size===r.length&&U(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function xo(e){return e.every(e=>e!==null&&Co(e))}function So(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Co(e){return new Set(e).size===e.length}function U(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function wo(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const To=L({required:[`screenRecordingStart`]}),Eo=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Do=L({required:[]}),Oo=L({required:[],preferred:[`screenRecordingStart`]}),ko=Object.freeze([To,Eo]);function Ao(t){switch((t.action??``).toLowerCase()){case`start`:if(!jo(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:To});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Do}):Object.freeze({kind:`stop-recovery`,use:Eo});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function jo(e){return e===`app`||e===`device`||e===`system`}function Mo(e){if(_o(e),e.kind!==`device-runtime`||!(`uses`in e))throw No();let t=e.uses.map(jr),n=ko.map(jr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw No()}function No(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Po(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, host, inventory, or device-runtime); there is no registry-entry default`);return _o(t),t}const W={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Fo=()=>!0,Io=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Lo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Ro=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,zo=e=>{let t=e.flags?.leaseProvider;return e.flags?.leaseId===void 0&&typeof t==`string`&&(e.flags?.platform===`android`||e.flags?.platform===`ios`)?{kind:`provider-app-catalog`,provider:t}:void 0},Bo=new Set([`status`,`get`]),Vo=e=>Zo(e,Bo,`status`),Ho=new Set([`get`,`wait`]),Uo=e=>Zo(e,Ho,`get`),Wo=e=>K(e,Bo,`status`),Go=e=>K(e,Ho,`get`),Ko=e=>{try{return Jt(an(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},qo=e=>K(e,new Set([`read`]),``),Jo=e=>Ca(e.positionals).kind===`read`,Yo=e=>Jo(e)?`observes-app`:`mutates-app`,Xo=e=>Jo(e)?`preserve`:`may-invalidate`;function Zo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function K(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},Qo={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0},$o={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...M,onTimeout:`preserve-daemon`},es={...M,envelopeMs:18e4},ts={...M,onTimeout:`preserve-daemon`},ns={...ts,envelopeMs:33e4},rs={...M,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},is={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},as={fields:{delayMs:{defaultValue:0}}};function X(e,t){return hr(e)===void 0?t:rs}function Z(e){let t=hr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const os={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Da},timeoutPolicy:es,batchable:!0},ss=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>sa({customActions:t,hasActiveApp:e}).use)},cs=e=>{let t=us(e);if(t===void 0||!ls(t))return na;let n=aa(t);return[!0,!1].map(e=>oa({hasActiveApp:e,intent:n}).use)};function ls(e){return Jt(e)||e===`focus`||e===`type`}function us(e){if(e.positionals===void 0)return;let t=tn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const ds=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Fo},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ns,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ts,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ts,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session_save_script`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...G},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`inventory`,use:go}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...G},timeoutPolicy:M,batchable:!0,platformExecution:q},{name:`doctor`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:Fo,...G},timeoutPolicy:M,batchable:!0,platformExecution:Qo},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:zo},platformExecution:{kind:`device-runtime`,uses:[Ir]},timeoutPolicy:M,batchable:!0},{name:`boot`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:fa},timeoutPolicy:M,batchable:!0},{name:`shutdown`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:va},timeoutPolicy:M,batchable:!0},{name:`appstate`,deviceClaimPolicy:`observe`,catalog:{group:`public`,key:`appState`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:_a},timeoutPolicy:M,batchable:!0},{name:`perf`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:fi}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:Ja},timeoutPolicy:M,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`network`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:ao},timeoutPolicy:M,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:$a}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Lo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,budget:{source:`flag`}},batchable:!1,platformExecution:q},{name:`test`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Lo},timeoutPolicy:{...M,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Wa,Ai]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:qo,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ya}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Wo,daemon:{route:`session`,refFrameEffect:Vo,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ea}},{name:`install`,...os},{name:`reinstall`,...os},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Oa},timeoutPolicy:es,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`push`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:ka},timeoutPolicy:M,batchable:!0},{name:`trigger-app-event`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`triggerAppEvent`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Zr]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Fo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fa}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:rr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Va}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`close`,deviceClaimPolicy:`release-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0,sessionlessLeaseAdmissionExemption:Ro},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ra}},{name:`snapshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ia,selectUses:ss}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ia,selectUses:ss}},{name:`wait`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:nr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ra}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Go,daemon:{route:`snapshot`,refFrameEffect:Uo},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ta}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Yo,daemon:{route:`snapshot`,refFrameEffect:Xo},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ba}},{name:`react-native`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`reactNative`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[R]}},{name:`record`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:Io},platformExecution:{kind:`device-runtime`,uses:ko},timeoutPolicy:M,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Ko,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:na,selectUses:cs}},{name:`click`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:is,batchable:!0,platformExecution:{kind:`device-runtime`,uses:bi}},{name:`fill`,...$o,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:as,batchable:!0,platformExecution:{kind:`device-runtime`,uses:wi}},{name:`longpress`,...$o,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...rs,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Si}},{name:`hover`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`},timeoutPolicy:X(`hover`,Y),postActionObservation:Z(`hover`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ci}},{name:`press`,...$o,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:is,batchable:!0,platformExecution:{kind:`device-runtime`,uses:xi}},{name:`type`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Br]}},{name:`get`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Zi}},{name:`is`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Xi}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,M),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[Vr]}},{name:`gesture`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Pi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Hr]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Gr]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Ur]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...J,timeoutPolicy:or,platformExecution:{kind:`device-runtime`,uses:[Wr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,M),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Ii}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[zr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ua}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Rr]}},{name:`app-switcher`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`appSwitcher`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Yr]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Xr]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Oa},timeoutPolicy:M,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Qo},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:go}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Qo}],fs=new Set([`public`,`local-cli`]),ps=new Set(ds.filter(e=>fs.has(xs(e))).map(e=>e.name)),Q=ds.map(e=>{let t=Po(e);return e.name===`record`&&Mo(t),{...e,mcpExposed:ys(e),platformExecution:t}});function ms(e){return Q.filter(t=>xs(t)===e).map(e=>[Ss(e),e.name])}function hs(){return Q.filter(e=>bs(e)).map(e=>e.name).sort()}function gs(e){let t=Q.find(t=>t.name===e)?.platformExecution;if(t?.kind===`device-runtime`)return(`uses`in t?t.uses:[t.use]).map(e=>e.required)}function _s(){return Q.filter(e=>e.catalog.group===`public`&&e.platformExecution.kind===`device-runtime`).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function vs(e){return ps.has(e)}function ys(e){return e.mcpExposed??ps.has(e.name)}function bs(e){return e.mcpExposed&&vs(e.name)}function xs(e){return e.catalog.group}function Ss(e){return e.catalog.key??e.name}const Cs=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ws=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),Ts=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Es(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Ds(e){return Es(e)!==void 0}function Os(e){return Es(e)===`settle-and-verify`}function ks(e){return e===void 0?M:Cs.get(e)??M}function As(e){return e===void 0?`require-owner`:ws.get(e)??`require-owner`}function js(e){if(e!==void 0)return Ts.get(e)}function Ms(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Ns(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Ps(e){return $.get(e)?.targetIdentityVerification}function Fs(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Is(){return[...new Set(Array.from(Ts.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Ls={apps:{appsFilter:`user-installed`}};function Rs(e,t){if(!e||!vs(e))return!1;let n=Ls[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function zs(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Bs(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Vs=Bs(Q),Hs=new Set([`batch`,`replay`]),Us=[`command`,`positionals`,`input`,`flags`,`runtime`],Ws=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],Gs=`Session, daemon, connection, and host tooling commands are excluded from batch — they own lifecycle a batch cannot carry — and batch and replay never nest. Run an excluded command on its own; every other device command is available as a step.`,Ks=new Set(Vs);function qs(e){return Ks.has(e)}function Js(e){return typeof e==`string`?e.trim().toLowerCase():``}function Ys(e){let t=Js(e);return qs(t)?t:void 0}function Xs(t,n,r=Gs){let i=Ys(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function Zs(t,n){if(Hs.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{ni as $,ft as $n,P as $t,oo as A,$t as An,le as Ar,ui as At,Ua as B,It as Bn,te as Br,Ti as Bt,js as C,mn as Cn,b as Cr,Jr as Ct,Oo as D,dn as Dn,he as Dr,oi as Dt,Ao as E,fn as En,ce as Er,Ur as Et,qa as F,qt as Fn,oe as Fr,da as Ft,ja as G,Rt as Gn,u as Gr,Gr as Gt,Ba as H,Ht as Hn,l as Hr,Qr as Ht,Ya as I,an as In,m as Ir,Bi as It,Pa as J,Pt as Jn,a as Jr,Sr as Jt,Ma as K,Lt as Kn,c as Kr,Br as Kt,Ha as L,sn as Ln,ne as Lr,oa as Lt,Za as M,tn as Mn,h as Mr,di as Mt,ro as N,Yt as Nn,ie as Nr,ha as Nt,Eo as O,gn as On,me as Or,si as Ot,eo as P,Jt as Pn,ae as Pr,zi as Pt,Xr as Q,mt as Qn,_r as Qt,Ia as R,Ut as Rn,re as Rr,Ca as Rt,Ms as S,hn as Sn,S as Sr,qr as St,Ps as T,pn as Tn,g as Tr,mi as Tt,Aa as U,zt as Un,o as Ur,va as Ut,za as V,Mt as Vn,ee as Vr,$r as Vt,Na as W,At as Wn,d as Wr,R as Wt,Oa as X,Ft as Xn,vr as Xt,Da as Y,Nt as Yn,gr as Yt,ka as Z,nt as Zn,Tr as Zt,hs as _,Dn as _n,v as _r,zr as _t,Zs as a,sr as an,Ze as ar,Yr as at,Ns as b,Tn as bn,x as br,Hr as bt,Ys as c,Un as cn,Ge as cr,yi as ct,Q as d,zn as dn,qe as dr,pi as dt,yr as en,ht as er,ri as et,gs as f,Vn as fn,Ke as fr,ii as ft,ms as g,Mn as gn,Re as gr,aa as gt,Is as h,An as hn,ze as hr,vi as ht,Vs as i,rr as in,C as ir,ga as it,lo as j,en as jn,de as jr,li as jt,po as k,Gt as kn,ge as kr,ci as kt,zs as l,Pn as ln,We as lr,_i as lt,Os as m,Wn as mn,Ie as mr,L as mt,Us as n,N as nn,dt as nr,ti as nt,Js as o,Kn as on,$e as or,Ir as ot,Ds as p,Bn as pn,Ye as pr,ai as pt,Va as q,kt as qn,s as qr,Rr as qt,Ws as r,ar as rn,w as rr,Zr as rt,Xs as s,j as sn,Xe as sr,Vr as st,Gs as t,br as tn,_t as tr,ei as tt,Rs as u,Hn as un,Je as ur,hi as ut,_s as v,kn as vn,Ce as vr,Wr as vt,ks as w,_n as wn,_e as wr,Kr as wt,Fs as x,En as xn,y as xr,gi as xt,As as y,jn as yn,xe as yr,Ai as yt,La as z,D as zn,p as zr,sa as zt};
2
+ `],[`r`,`\r`],[`t`,` `]]);function y(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Ee(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>we(e))}}function b(e){try{return y(e)}catch{return null}}function x(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return _.has(e)}return _.has(t.toLowerCase())}function Ce(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||_.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=ke(i).trim();return a?{key:r,value:a}:null}function S(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!x(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&b(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function we(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=De(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Te)}}function Te(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!ye.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!_.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(ye.has(i)){let t=Me(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:ke(a)}}function Ee(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Ne(t,a)){i=Oe(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function De(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ne(t,e)){i=Oe(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function Oe(e,t){return e?e===t?null:e:t}function ke(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Ae(t.slice(1,-1)):t}function Ae(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=je(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function je(e){return Se.get(e)??null}function Me(e){let t=ke(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ne(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Pe(e){return a.includes(e)}const Fe=`is requires predicate: ${a.join(`|`)}`;function Ie(e){let t=e.toLowerCase();return Pe(t)?{ok:!0,predicate:t}:i(Fe,Le)}const Le=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function Re(e){if(Pe((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(Pe(n)&&b(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function ze(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=h(n),s=_e(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):Ve(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break;default:return Be(t)}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function Be(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Ve(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(o(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=He(e,t,n);return r?o(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function He(e,t,n){return t.findAncestor(e,e=>ge(e,n)?e:null)}function Ue(e){let t=Re(e),n=t[0]??``;return{predicate:n,split:S(t.slice(1),{preferTrailingValue:n===`text`})}}const We=`is requires a selector expression`,Ge=`is text requires expected text value`;function Ke(e){let{predicate:t,split:n}=Ue([...e]),r=Ie(t);if(!r.ok)return r;if(!n)return i(We);let a=n.rest.join(` `).trim();return r.predicate===`text`&&!a?i(Ge):r.predicate!==`text`&&n.rest.length>0?i(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:a}}function qe(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:i(`get only supports text or attrs`)}function Je(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:i(`get requires @ref or selector expression`)}function Ye(e){return e?{ok:!0,text:e}:i(`wait requires text`)}function Xe(e){return Array.from(new Set(e))}function Ze(e){return JSON.stringify(Qe(e))}function Qe(e){if(Array.isArray(e))return e.map(Qe);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,Qe(t[e])]))}function $e(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t+=1;for(;n>t&&e[n-1]===`-`;)--n;return e.slice(t,n)}const et=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,tt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,nt=4096;function rt(e){return e.normalize(`NFC`)}function it(e){if(e===void 0)return;let t=rt(e);return t.length>0?t:void 0}function at(e){return rt(e)}function ot(e){if(e===void 0)return;let t=rt(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function C(e){return Buffer.byteLength(e,`utf8`)}function w(e,t){if(C(e)<=t)return e;let n=e.length;for(;n>0&&C(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function st(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(ct),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=lt(e.scrollRegion)),e.rect&&(t.rect=ut(e.rect)),t.verification=e.verification,t}function ct(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function lt(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function ut(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function dt(e){return JSON.stringify(st(e))}function ft(e){return`# agent-device:target-v1 ${dt(e)}`}function pt(e){return JSON.stringify({source:st(e.source),destination:st(e.destination)})}function mt(e){return`# agent-device:targets-v1 ${pt(e)}`}function ht(e){let t=e.trim(),n=tt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:gt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function gt(t){if(C(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:vt(JSON.stringify(r.source)),destination:vt(JSON.stringify(r.destination))}}function _t(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=et.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:vt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function vt(t){if(C(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${nt}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=yt(r.role,`role`),a=bt(r.id,`id`),o=xt(r.label,`label`),s=Ct(r.ancestry),c=Tt(r.sibling,`sibling`,0),l=Tt(r.viewportOrder,`viewportOrder`,0),u=Et(r.scrollRegion),d=Dt(r.rect),f=Ot(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function yt(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return St(at(t),n)}function bt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=it(t);return r===void 0?void 0:St(r,n)}function xt(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=ot(t);return r===void 0?void 0:St(r,n)}function St(t,n){if(C(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Ct(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>wt(e,t))}function wt(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=yt(r.role,`ancestry[${n}].role`),a=xt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Tt(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function Et(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=yt(n.role,`scrollRegion.role`),i=bt(n.id,`id`),a=xt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Dt(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:T(n.x,`rect.x`),y:T(n.y,`rect.y`),width:T(n.width,`rect.width`),height:T(n.height,`rect.height`)}}function T(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function Ot(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function kt(e){let t=at(m(e.type??``)),n=it(e.identifier),r=ot(e.label);return{...n===void 0?{}:{id:w(n,256)},role:w(t,256),...r===void 0?{}:{label:w(r,256)}}}function At(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function jt(e,t){let n=0;for(let r of e)kt(r).id===t&&(n+=1);return n}function Mt(e,t){if(e.id===void 0||jt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Nt(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function Pt(e,t){return{documentOrder:e.index,sibling:Nt(t,e)}}function Ft(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function It(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Lt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Rt(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function zt(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Bt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Vt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Ht(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Vt(r,e))return[`ancestry[${n}]: recorded=${Bt(r)} observed=${Bt(e)}`]}return[]}function Ut(e,t,n={}){let r=[],i=m(e.type??``),a=Wt(e,n.nodes),o=D(e.label),s=D(e.value),c=D(h(e)),l=n.action===`fill`;a&&r.push(`id=${E(a)}`),i&&o&&r.push(l?`role=${E(i)} label=${E(o)} editable=true`:`role=${E(i)} label=${E(o)}`),o&&r.push(l?`label=${E(o)} editable=true`:`label=${E(o)}`),s&&r.push(l?`value=${E(s)} editable=true`:`value=${E(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${E(c)} editable=true`:`text=${E(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${E(i)} editable=true`);let u=Xe(r);return u.length===0&&i&&u.push(l?`role=${E(i)} editable=true`:`role=${E(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function Wt(e,t){let n=D(e.identifier);if(!n||!t)return n;let r=kt(e).id;return r===void 0?n:jt(t,r)>1?null:n}function E(e){return JSON.stringify(e)}function D(e){return e&&e.trim()||null}const Gt=[`any`,`text`,`label`,`value`,`role`,`id`],Kt=[`text`,`label`,`value`,`role`,`id`];function qt(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function Jt(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Yt(e,t,n,r={}){let i=k(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=Xt(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function Xt(e,t,n){switch(t){case`role`:return Zt(e.type,n);case`label`:return O(e.label,n);case`value`:return O(e.value,n);case`id`:return O(e.identifier,n);default:return Math.max(O(e.label,n),O(e.value,n),O(e.identifier,n))}}function O(e,t){let n=k(e??``);return n?n===t?2:+!!n.includes(t):0}function Zt(e,t){let n=Qt(e??``);return n?n===t?2:+!!n.includes(t):0}function k(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function Qt(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const $t=`find requires a value`,en=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function tn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=an([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:$t}}const nn=[`exists`,`list`,`click`,`focus`];function rn(e){return nn.includes(e)}function an(t){let n=`any`,r=0;Kt.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=qt(a[0]);if(rn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:on(a[1])};if(o===`wait`){let e=cn(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:en})}function on(t){let n=t?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}function sn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:b(t)?t:null}function cn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function ln(e,t,n){return t.terms.every(t=>un(e,t,n))}function un(e,t,n){switch(t.key){case`id`:return A(e.identifier,String(t.value));case`role`:return A(m(e.type??``),String(t.value));case`label`:return A(e.label,String(t.value));case`value`:return A(e.value,String(t.value));case`text`:return A(h(e),String(t.value));case`appname`:return A(e.appName,String(t.value));case`windowtitle`:return A(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return _e(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function A(e,t){return k(e??``)===k(t)}function dn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[],o=null;for(let[s,c]of t.selectors.entries()){let t=vn(e,c,n.platform,r);if(a.push({selector:c.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(o??={selector:c,selectorIndex:s,matchedNodes:t.candidates},i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.disambiguated,selector:c,selectorIndex:s,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}}return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.firstNode,selector:c,selectorIndex:s,matches:t.count,diagnostics:a}}}}return{resolution:null,matchedNodes:o?.matchedNodes??[],firstMatch:o}}function fn(e,t,n){return dn(e,t,n).resolution}function pn(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:ln(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function mn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Sn(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const hn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function gn(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function _n(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function vn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=ce(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||ln(l,t,n)&&(i+=1,a??=l,o.push(l),yn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:bn(o,s.best,c),candidates:o}}function yn(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Cn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function bn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||xn(i,r,n).result>0)&&(r=i);return r?xn(t,r,n).criterion:null}function xn(e,t,n){let r=n(e);return r===n(t)?Cn(e,t):{result:r?1:-1,criterion:`visible`}}function Sn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||ln(a,t,n)&&(i+=1);return i}function Cn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=wn(e),a=wn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function wn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Tn={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1},cropTarget:{ambiguity:`fail-closed`,requireRect:!0}};function En(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Dn(e,t){let n=e===`is`?Ue([...t]).split:S([...t]);return n?b(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function On(e){return{platform:e.platform,...En({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function kn(e,t,n){let r=b(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=dn(t,r,On(n));return i?{kind:`resolved`,winner:i.node,matchedNodes:a,matchCount:a.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}:{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function An(e,t,n={}){return Ut(e,t,n)}function jn(e,t,n){let r=b(e);if(!r)return;let i=fn(t,r,On(n));if(i)return{node:i.node,basis:Nn(i.selector)}}function Mn(e){if(!e)return;let t=b(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Nn(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}function Pn(e,t){let n=b(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Fn(n.selectors,r,i):In(n.selectors[0],r,new Set(t.booleanKeys),i)}function Fn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Ln(r.key,t,n)&&typeof r.value==`string`?r.value:void 0}),i=r[0];return i!==void 0&&r.every(e=>e===i)?i:null}function In(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Ln(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Rn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Ln(e,t,n){return t.has(e)||n[e]!==void 0}function Rn(e,t,n){return t.has(e.key)&&typeof e.value===n}function zn(e){let t=b(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function Bn(e,t){if(!t)return!1;let n=b(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function Vn(e,t){return b(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Hn(e){return y(e).selectors.map(e=>e.raw)}function Un(e){return b(e)!==null}function Wn(e){y(e)}function j(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Gn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Kn(e){let t=e[0];if(t===void 0)return null;let n=j(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=j(e.at(-1));return t===`text`?qn(e,r):t===`stable`?Jn(e):t===`absent`?Yn(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:Zn(e,r)}function qn(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function Jn(e){let t=e.slice(1),n=t.length>1?j(t[1]):null;return{kind:`stable`,quietMs:t.length>0?j(t[0]):null,timeoutMs:n}}function Yn(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=S(n);return n.length>0&&r?.rest.length===0&&Un(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:Xn(n)}}function Xn(e){let t=e.join(` `);return t.length>0?`wait absent requires one valid selector; received "${t}". Use wait absent '<selector>' [timeoutMs].`:`wait absent requires <selector> [timeoutMs].`}function Zn(e,t){let n=t===null?e.slice():e.slice(0,-1),r=S(n);return r&&r.rest.length===0&&Un(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:Qn(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function Qn(e,t){for(let t of e){let n=Ce(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:$n(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:er(t,e)}:e.some(e=>x(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:tr(e)}:null}function $n(e,t){let n=t.join(` `),r=xe(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${v.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function er(e,t){let n=t.join(` `);return`Selector ${e.selectorExpression} is followed by unexpected extra arguments: "${e.rest.join(` `)}". Selector values with spaces need quotes, e.g. label="Sign in". Use wait '<selector>' [timeoutMs], or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function tr(e){let t=e.join(` `),n=e.filter(e=>!x(e)),r=e.filter(e=>x(e));if(n.length>0){let e=n[0],i=Gn.has(e.toLowerCase())?` "${e}" describes a condition, not a selector key. Use the selector form: `+(e.toLowerCase()===`gone`||e.toLowerCase()===`disappears`?`wait absent '${r.join(` `)}' [timeoutMs] to wait for zero matches.`:`wait '${r.join(` `)}' [timeoutMs] to wait for it to appear.`):` "${e}" is not a recognized selector key (${v.join(`, `)}).`;return`"${t}" mixes plain word "${e}" with selector-shaped "${r.join(` `)}", so it is neither a valid selector nor safe as literal text.${i} Use wait '<selector>' [timeoutMs] for a selector, or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}return`"${t}" looks like a selector key but is not a valid selector expression. Use wait '<selector>' [timeoutMs], e.g. wait '${e[0]}="value"' [timeoutMs], or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}function nr(e){let t=Kn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const rr=24e4,ir=3e4,ar=3e5,M={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},or={budget:{source:`none`},envelopeMs:21e4,onTimeout:`reset-daemon`};function sr(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return cr(n,t.positionals??[])??lr(n,t.flags)??n.envelopeMs}function cr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:fr(e,n)}function lr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?dr(e,e.budget,t):e.budget.envelope===`margin`?ur(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function ur(e,t){let n=typeof t?.timeoutMs==`number`?fr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?pr({...e,envelopeMs:n},t.waitMs):n}function dr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?pr(e,r):e.envelopeMs}function fr(e,t){return Math.max(e.envelopeMs,t+ir)}function pr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+ir)}const mr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function hr(e){if(e!==void 0)return mr[e]}function N(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function gr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function _r(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function vr(e){let t=e.trim();if(t.length===0)throw TypeError(`Managed local runtime owner requires a non-empty allocator instance identity`);return Object.freeze({kind:`managed-local`,instance:t})}function P(e){switch(e.kind){case`local-family`:return`local:${e.family}`;case`managed-local`:return`managed:${JSON.stringify([e.instance])}`;case`provider-runtime`:return`provider:${JSON.stringify([e.provider,e.instance])}`}}function yr(e,t){return P(e)===P(t)}function br(e,t){return e.available?t():{}}function xr(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!Cr(e.requestGeneration))throw TypeError(`Managed binding fence requires non-empty requester and identity incarnation ids and a non-negative integer request generation`);return Object.freeze({token:JSON.stringify([e.requesterId,e.identityIncarnationId]),generation:e.requestGeneration})}function Sr(e){let t=wr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!Cr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return xr(i).token===e.token?i:null}function Cr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function wr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Tr(e,t){let n={},r={};for(let i of t.required){let t=I(e.facts.operations,i);if(n[i]=t,!t.available)throw Ar(i,t);r[i]=Or(e.operations,i)}for(let i of t.preferred){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Or(e.operations,i))}for(let i of t.conditional??[]){let t=I(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Or(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function I(e,t){let n=e[t];if(!Er(n))throw N(`Runtime owner omitted the ${t} fact`);let r=Dr(n);if(r)return r;throw N(`Runtime owner returned an invalid ${t} fact`)}function Er(e){return typeof e==`object`&&!!e&&`available`in e}function Dr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&kr(e.reason)&&(e.hint===void 0||typeof e.hint==`string`))return Object.freeze({available:!1,reason:e.reason,...e.hint===void 0?{}:{hint:e.hint}})}function Or(e,t){let n=e[t];if(typeof n!=`function`)throw N(`Runtime owner advertised ${t} without an implementation`);return n}function kr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Ar(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function jr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function Mr(){return e=>{let t=Nr(e.required,`required`),n=Nr(e.preferred??[],`preferred`),r=Nr(e.conditional??[],`conditional`),i=[[`required`,t],[`preferred`,n],[`conditional`,r]];for(let e=0;e<i.length;e+=1){let t=i[e];if(t)for(let n of i.slice(e+1)){let e=n[1].find(e=>t[1].includes(e));if(e!==void 0)throw TypeError(`Runtime operation cannot be both ${t[0]} and ${n[0]}: ${e}`)}}return Object.freeze(r.length===0?{required:t,preferred:n}:{required:t,preferred:n,conditional:r})}}function Nr(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}const L=Mr(),Pr=L({required:[`bootTarget`]}),Fr=L({required:[`bootTargetHeadless`]}),Ir=L({required:[`ensureReady`,`listApps`]}),Lr=L({required:[`captureSnapshot`]}),Rr=L({required:[`setViewport`]}),zr=L({required:[`focusPoint`]}),Br=L({required:[`typeText`]}),Vr=L({required:[`back`]}),Hr=L({required:[`home`]}),Ur=L({required:[`setOrientation`]}),Wr=L({required:[`setFoldPose`]}),Gr=L({required:[`tvRemote`]}),Kr=L({required:[`keyboardStatus`]}),qr=L({required:[`keyboardDismiss`]}),Jr=L({required:[`keyboardEnter`]}),Yr=L({required:[`appSwitcher`]}),Xr=L({required:[`actionButton`]}),Zr=L({required:[`triggerAppEvent`]}),Qr=L({required:[`setSetting`]}),$r=L({required:[`readSetting`]}),ei=L({required:[`readAlert`]}),ti=L({required:[`awaitAlert`]}),ni=L({required:[`acceptAlert`]}),ri=L({required:[`dismissAlert`]}),ii=L({required:[`readClipboard`]}),ai=L({required:[`writeClipboard`]}),oi=L({required:[`perfFrames`]}),si=L({required:[`perfMemorySample`]}),ci=L({required:[`perfMemorySnapshot`]}),li=L({required:[`perfNativeCaptureStart`]}),ui=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),di=L({required:[`perfProfileReport`]}),fi=Object.freeze([oi,si,ci,li,ui,di]),R=L({required:[`tapPoint`]}),pi=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),mi=L({required:[`longPressPoint`]}),hi=L({required:[`captureSnapshot`,`longPressPoint`]}),gi=L({required:[`hoverPoint`]}),_i=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),vi=L({required:[`fillPoint`]}),yi=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),bi=Object.freeze([R,pi]),xi=bi,Si=Object.freeze([mi,hi]),Ci=Object.freeze([gi,_i]),wi=Object.freeze([vi,yi]);function Ti(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:pi}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:yi}:{kind:`fill-point`,use:vi};case`longpress`:return t?{kind:`captured-long-press`,use:hi}:{kind:`long-press-point`,use:mi};case`hover`:return t?{kind:`captured-hover`,use:_i}:{kind:`hover-point`,use:gi}}}const Ei=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Di=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Oi=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),ki=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ai=L({required:[`gestureViewport`]}),ji=L({required:[`scrollDirection`]}),Mi=L({required:[`scrollDirection`,`captureSnapshot`]}),Ni=Object.freeze({plan:Ei,"directional-fling":Di,"multi-touch":Oi,"target-authored-drag":ki}),Pi=Object.freeze([Ei,Di,Oi,ki]),Fi=Object.freeze([Ei]),Ii=Object.freeze([ji,Mi]);function Li(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Ri(e){return e.intent===`drag`?`target-authored-drag`:Li(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function zi(e){let t=Ri(e);switch(t){case`plan`:return z(t);case`directional-fling`:return z(t);case`multi-touch`:return z(t);case`target-authored-drag`:return z(t)}}function z(e){let t=Ni[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function Bi(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:ji}):Object.freeze({kind:`edge`,edge:e.edge,use:Mi}):Object.freeze({kind:`until`,until:e.until,use:Mi})}const Vi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Hi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Ui=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Wi=L({required:[`captureSnapshot`]}),Gi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Ki=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),qi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),Ji=L({required:[`captureSnapshot`],conditional:[`findText`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),Xi=Object.freeze([Wi,Gi]),Zi=Object.freeze([Ki,qi]),Qi=L({required:[`captureSnapshot`,`focusPoint`]}),$i=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),ea=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),ta=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),na=Object.freeze([Ki,qi,Wi,Gi,Qi,$i,ea,ta]),ra=Object.freeze([Ji,Yi]),ia=Object.freeze([Lr,Vi,Hi,Ui]),B=Object.freeze({"capture-only":Xi,"element-text":Zi,"wait-observation":ra,"find-focus":Object.freeze([Qi,$i]),"find-type":Object.freeze([ea,ta])});function aa(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function oa(e){switch(e.intent){case`capture-only`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`element-text`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`wait-observation`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`find-focus`:return V(e.hasActiveApp,e.intent,B[e.intent]);case`find-type`:return V(e.hasActiveApp,e.intent,B[e.intent])}}function V(e,t,n){return Object.freeze(e?{kind:`selector-active-app`,intent:t,operation:`captureSnapshot`,use:n[0]}:{kind:`selector-without-active-app`,intent:t,operation:`captureSnapshotWithoutActiveApp`,use:n[1]})}function sa(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:Vi}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:Ui}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Lr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Hi})}const ca=L({required:[`captureScreenshot`]}),la=L({required:[`captureScreenshot`,`captureSnapshot`]}),ua=Object.freeze([ca,la]);function da(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:la}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:la}):Object.freeze({kind:`capture`,use:ca})}const fa=Object.freeze([Pr,Fr]),pa=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Pr}),ma=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Fr});function ha(e){return e.headless?ma:pa}const ga=L({required:[`ensureReady`,`appState`]}),_a=Object.freeze([ga]),va=L({required:[`shutdownTarget`]}),ya=Object.freeze([ii,ai]),ba=Object.freeze([Qr,$r]),xa=[`text-size`],Sa=Object.freeze({kind:`write`,use:Qr});function Ca(e){let t=wa(e?.[0]);return e?.length!==1||t===void 0?Sa:xa.includes(t)?Object.freeze({kind:`read`,setting:t,use:$r}):Sa}function wa(e){let t=e?.trim().toLowerCase();return xa.find(e=>e===t)}const Ta=Object.freeze([ei,ti,ni,ri]),Ea=Object.freeze([Kr,qr,Jr]),Da=L({required:[`deployApp`]}),Oa=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),ka=L({required:[`ensureReady`,`sendPushNotification`]}),Aa=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),ja=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Ma=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Na=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Pa(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Na}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:ja}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Ma}):Object.freeze({kind:`open`,use:Aa})}const Fa=Object.freeze([Aa,ja,Ma,Na]),Ia=L({required:[`closeApplication`,`finalizeApplicationClose`]}),La=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),Ra=Object.freeze([Ia,La]),za=L({required:[`finalizeApplicationClose`]}),Ba=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Va=L({required:[`prepareAppleRunner`]}),Ha=L({required:[`clearRuntimeHints`]}),Ua=L({required:[`configureProviderPortReverse`]}),Wa=Object.freeze([Ha,Ua]),H=L({required:[`appLogInspect`]}),Ga=L({required:[`appLogInspect`,`appLogDoctor`]}),Ka=L({required:[`appLogInspect`,`appLogStart`]}),qa=L({required:[],preferred:[`appLogInspect`]}),Ja=Object.freeze([H,Ga,Ka]);function Ya(t){let n=(t.action??`path`).toLowerCase();if(t.restart&&n!==`clear`)throw new e(`INVALID_ARGS`,`logs --restart is only supported with logs clear`);switch(n){case`path`:return Object.freeze({kind:`path`,requiresAppSession:!1,use:H});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:Ka});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:H});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Ga});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:H});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:Ka}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:H});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const Xa=L({required:[`audioProbeStart`]}),Za=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),Qa=L({required:[`audioProbeQuery`]}),$a=Object.freeze([Xa,Za,Qa]);function eo(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:Qa});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:Xa});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const to=[`probe`],no=[`start`,`status`,`stop`];function ro(t){let n=(t?.[0]??`probe`).toLowerCase();if(!to.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!no.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${no.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:io(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:io(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function io(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,n.message);return r}const ao=L({required:[`networkDump`]}),oo=L({required:[],preferred:[`networkDump`]}),so=[`dump`,`log`],co=[`summary`,`headers`,`body`,`all`];function lo(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!uo(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!fo(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:ao})}function uo(e){return so.some(t=>t===e)}function fo(e){return co.some(t=>t===e)}function po(e){let t=new Map;for(let r of e){if(!n(r.family))throw TypeError(`Unknown platform family registration: ${String(r.family)}`);if(t.has(r.family))throw TypeError(`Duplicate platform family registration: ${r.family}`);t.set(r.family,mo(r))}let i=r.filter(e=>!t.has(e));if(i.length>0)throw TypeError(`Missing platform family registrations: ${i.join(`, `)}`);let a=Object.freeze([...r]),o=Object.freeze(a.map(e=>ho(t,e)));return Object.freeze({families:a,modules:o,get:e=>ho(t,e)})}function mo(e){return Object.freeze({...e})}function ho(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const go=Object.freeze({kind:`device-inventory`});function _o(e){if(typeof e!=`object`||!e)throw wo();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&U(n,[`kind`]))&&!(t.kind===`host`&&U(n,[`kind`]))&&!(t.kind===`inventory`&&U(n,[`kind`,`use`])&&yo(t.use))&&!(t.kind===`device-runtime`&&U(n,[`kind`,`use`])&&bo(t.use))&&!(t.kind===`device-runtime`&&(U(n,[`kind`,`uses`])||U(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&vo(t.uses)))throw wo()}function vo(e){if(!Array.isArray(e)||e.length===0||!e.every(bo))return!1;let t=e.map(jr);return new Set(t).size===t.length}function yo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&U(Object.keys(t).sort(),[`kind`])}function bo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[So(t.required),So(t.preferred),So(t.conditional??[])];if(!xo(n))return!1;let r=n.flat();return new Set(r).size===r.length&&U(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function xo(e){return e.every(e=>e!==null&&Co(e))}function So(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Co(e){return new Set(e).size===e.length}function U(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function wo(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const To=L({required:[`screenRecordingStart`]}),Eo=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Do=L({required:[]}),Oo=L({required:[],preferred:[`screenRecordingStart`]}),ko=Object.freeze([To,Eo]);function Ao(t){switch((t.action??``).toLowerCase()){case`start`:if(!jo(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:To});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Do}):Object.freeze({kind:`stop-recovery`,use:Eo});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function jo(e){return e===`app`||e===`device`||e===`system`}function Mo(e){if(_o(e),e.kind!==`device-runtime`||!(`uses`in e))throw No();let t=e.uses.map(jr),n=ko.map(jr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw No()}function No(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Po(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, host, inventory, or device-runtime); there is no registry-entry default`);return _o(t),t}const W={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Fo=()=>!0,Io=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Lo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Ro=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,zo=e=>{let t=e.flags?.leaseProvider;return e.flags?.leaseId===void 0&&typeof t==`string`&&(e.flags?.platform===`android`||e.flags?.platform===`ios`)?{kind:`provider-app-catalog`,provider:t}:void 0},Bo=new Set([`status`,`get`]),Vo=e=>Zo(e,Bo,`status`),Ho=new Set([`get`,`wait`]),Uo=e=>Zo(e,Ho,`get`),Wo=e=>K(e,Bo,`status`),Go=e=>K(e,Ho,`get`),Ko=e=>{try{return Jt(an(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},qo=e=>K(e,new Set([`read`]),``),Jo=e=>Ca(e.positionals).kind===`read`,Yo=e=>Jo(e)?`observes-app`:`mutates-app`,Xo=e=>Jo(e)?`preserve`:`may-invalidate`;function Zo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function K(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},Qo={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0},$o={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...M,onTimeout:`preserve-daemon`},es={...M,envelopeMs:18e4},ts={...M,onTimeout:`preserve-daemon`},ns={...ts,envelopeMs:33e4},rs={...M,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},is={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},as={fields:{delayMs:{defaultValue:0}}};function X(e,t){return hr(e)===void 0?t:rs}function Z(e){let t=hr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const os={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Da},timeoutPolicy:es,batchable:!0},ss=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>sa({customActions:t,hasActiveApp:e}).use)},cs=e=>{let t=us(e);if(t===void 0||!ls(t))return na;let n=aa(t);return[!0,!1].map(e=>oa({hasActiveApp:e,intent:n}).use)};function ls(e){return Jt(e)||e===`focus`||e===`type`}function us(e){if(e.positionals===void 0)return;let t=tn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const ds=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Fo},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ns,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ts,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:ts,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...W},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session_save_script`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...G},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`inventory`,use:go}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...G},timeoutPolicy:M,batchable:!0,platformExecution:q},{name:`doctor`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:Fo,...G},timeoutPolicy:M,batchable:!0,platformExecution:Qo},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:zo},platformExecution:{kind:`device-runtime`,uses:[Ir]},timeoutPolicy:M,batchable:!0},{name:`boot`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:fa},timeoutPolicy:M,batchable:!0},{name:`shutdown`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:va},timeoutPolicy:M,batchable:!0},{name:`appstate`,deviceClaimPolicy:`observe`,catalog:{group:`public`,key:`appState`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:_a},timeoutPolicy:M,batchable:!0},{name:`perf`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:fi}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:Ja},timeoutPolicy:M,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`network`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:ao},timeoutPolicy:M,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:$a}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Lo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,budget:{source:`flag`}},batchable:!1,platformExecution:q},{name:`test`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Lo},timeoutPolicy:{...M,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Wa,Ai]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:qo,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ya}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Wo,daemon:{route:`session`,refFrameEffect:Vo,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ea}},{name:`install`,...os},{name:`reinstall`,...os},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Oa},timeoutPolicy:es,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...G},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`push`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:ka},timeoutPolicy:M,batchable:!0},{name:`trigger-app-event`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`triggerAppEvent`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Zr]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Fo,saveScriptFlagOwner:!0},timeoutPolicy:{...M,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fa}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:rr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Va}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`close`,deviceClaimPolicy:`release-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0,sessionlessLeaseAdmissionExemption:Ro},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ra}},{name:`snapshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ia,selectUses:ss}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ia,selectUses:ss}},{name:`wait`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:nr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ra}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Go,daemon:{route:`snapshot`,refFrameEffect:Uo},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ta}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Yo,daemon:{route:`snapshot`,refFrameEffect:Xo},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ba}},{name:`react-native`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`reactNative`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[R]}},{name:`record`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:Io},platformExecution:{kind:`device-runtime`,uses:ko},timeoutPolicy:M,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Ko,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:na,selectUses:cs}},{name:`click`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:is,batchable:!0,platformExecution:{kind:`device-runtime`,uses:bi}},{name:`fill`,...$o,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:as,batchable:!0,platformExecution:{kind:`device-runtime`,uses:wi}},{name:`longpress`,...$o,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...rs,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Si}},{name:`hover`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`},timeoutPolicy:X(`hover`,Y),postActionObservation:Z(`hover`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ci}},{name:`press`,...$o,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:is,batchable:!0,platformExecution:{kind:`device-runtime`,uses:xi}},{name:`type`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Br]}},{name:`get`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Zi}},{name:`is`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Xi}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,M),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[Vr]}},{name:`gesture`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Pi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Hr]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Gr]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Ur]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...J,timeoutPolicy:or,platformExecution:{kind:`device-runtime`,uses:[Wr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,M),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Ii}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[zr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ua}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Rr]}},{name:`app-switcher`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`appSwitcher`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:M,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[Yr]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Xr]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Oa},timeoutPolicy:M,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Qo},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:go}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:M,batchable:!1,mcpExposed:!1,platformExecution:Qo}],fs=new Set([`public`,`local-cli`]),ps=new Set(ds.filter(e=>fs.has(xs(e))).map(e=>e.name)),Q=ds.map(e=>{let t=Po(e);return e.name===`record`&&Mo(t),{...e,mcpExposed:ys(e),platformExecution:t}});function ms(e){return Q.filter(t=>xs(t)===e).map(e=>[Ss(e),e.name])}function hs(){return Q.filter(e=>bs(e)).map(e=>e.name).sort()}function gs(e){let t=Q.find(t=>t.name===e)?.platformExecution;if(t?.kind===`device-runtime`)return(`uses`in t?t.uses:[t.use]).map(e=>e.required)}function _s(){return Q.filter(e=>e.catalog.group===`public`&&e.platformExecution.kind===`device-runtime`).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function vs(e){return ps.has(e)}function ys(e){return e.mcpExposed??ps.has(e.name)}function bs(e){return e.mcpExposed&&vs(e.name)}function xs(e){return e.catalog.group}function Ss(e){return e.catalog.key??e.name}const Cs=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ws=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),Ts=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Es(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Ds(e){return Es(e)!==void 0}function Os(e){return Es(e)===`settle-and-verify`}function ks(e){return e===void 0?M:Cs.get(e)??M}function As(e){return e===void 0?`require-owner`:ws.get(e)??`require-owner`}function js(e){if(e!==void 0)return Ts.get(e)}function Ms(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Ns(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Ps(e){return $.get(e)?.targetIdentityVerification}function Fs(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Is(){return[...new Set(Array.from(Ts.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Ls={apps:{appsFilter:`user-installed`}};function Rs(e,t){if(!e||!vs(e))return!1;let n=Ls[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function zs(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Bs(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Vs=Bs(Q),Hs=new Set([`batch`,`replay`]),Us=[`command`,`positionals`,`input`,`flags`,`runtime`],Ws=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],Gs=`Session, daemon, connection, and host tooling commands are excluded from batch — they own lifecycle a batch cannot carry — and batch and replay never nest. Run an excluded command on its own; every other device command is available as a step.`,Ks=new Set(Vs);function qs(e){return Ks.has(e)}function Js(e){return typeof e==`string`?e.trim().toLowerCase():``}function Ys(e){let t=Js(e);return qs(t)?t:void 0}function Xs(t,n,r=Gs){let i=Ys(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function Zs(t,n){if(Hs.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{ni as $,ft as $n,P as $t,oo as A,$t as An,le as Ar,ui as At,Ua as B,It as Bn,te as Br,Ti as Bt,js as C,mn as Cn,b as Cr,Jr as Ct,Oo as D,dn as Dn,he as Dr,oi as Dt,Ao as E,fn as En,ce as Er,Ur as Et,qa as F,qt as Fn,oe as Fr,da as Ft,ja as G,Rt as Gn,u as Gr,Gr as Gt,Ba as H,Ht as Hn,l as Hr,Qr as Ht,Ya as I,an as In,m as Ir,Bi as It,Pa as J,Pt as Jn,a as Jr,Sr as Jt,Ma as K,Lt as Kn,c as Kr,Br as Kt,Ha as L,sn as Ln,ne as Lr,oa as Lt,Za as M,tn as Mn,h as Mr,di as Mt,ro as N,Yt as Nn,ie as Nr,ha as Nt,Eo as O,gn as On,me as Or,si as Ot,eo as P,Jt as Pn,ae as Pr,zi as Pt,Xr as Q,mt as Qn,_r as Qt,Ia as R,Ut as Rn,re as Rr,Ca as Rt,Ms as S,hn as Sn,S as Sr,qr as St,Ps as T,pn as Tn,g as Tr,mi as Tt,Aa as U,zt as Un,o as Ur,va as Ut,za as V,Mt as Vn,ee as Vr,$r as Vt,Na as W,At as Wn,d as Wr,R as Wt,Oa as X,Ft as Xn,vr as Xt,Da as Y,Nt as Yn,gr as Yt,ka as Z,nt as Zn,Tr as Zt,hs as _,Dn as _n,v as _r,zr as _t,Zs as a,sr as an,Ze as ar,Yr as at,Ns as b,Tn as bn,x as br,Hr as bt,Ys as c,Un as cn,Ge as cr,yi as ct,Q as d,zn as dn,qe as dr,pi as dt,yr as en,ht as er,ri as et,gs as f,Vn as fn,Ke as fr,ii as ft,ms as g,Mn as gn,Re as gr,aa as gt,Is as h,An as hn,ze as hr,vi as ht,Vs as i,rr as in,C as ir,ga as it,lo as j,en as jn,de as jr,li as jt,po as k,Gt as kn,ge as kr,ci as kt,zs as l,Pn as ln,We as lr,_i as lt,Os as m,Wn as mn,Ie as mr,L as mt,Us as n,N as nn,dt as nr,ti as nt,Js as o,Kn as on,$e as or,Ir as ot,Ds as p,Bn as pn,Ye as pr,ai as pt,Va as q,kt as qn,s as qr,Rr as qt,Ws as r,ar as rn,w as rr,Zr as rt,Xs as s,j as sn,Xe as sr,Vr as st,Gs as t,br as tn,_t as tr,ei as tt,Rs as u,Hn as un,Je as ur,hi as ut,_s as v,kn as vn,Ce as vr,Wr as vt,ks as w,_n as wn,_e as wr,Kr as wt,Fs as x,En as xn,y as xr,gi as xt,As as y,jn as yn,xe as yr,Ai as yt,La as z,D as zn,p as zr,sa as zt};
@@ -211,6 +211,17 @@ type DeviceRotation = (typeof DEVICE_ROTATIONS)[number];
211
211
  */
212
212
  declare const FOLD_POSES: readonly ['closed', 'half-open', 'open'];
213
213
  type FoldPose = (typeof FOLD_POSES)[number];
214
+ type FoldKeyframe = Readonly<{
215
+ atMs: number;
216
+ angle: number;
217
+ }>;
218
+ type SetFoldPoseInput = Readonly<{
219
+ pose: FoldPose;
220
+ keyframes?: never;
221
+ }> | Readonly<{
222
+ keyframes: readonly FoldKeyframe[];
223
+ pose?: never;
224
+ }>;
214
225
  //#endregion
215
226
  //#region packages/contracts/src/tv-remote.d.ts
216
227
  declare const TV_REMOTE_BUTTON_DEFINITIONS: {
@@ -1087,4 +1098,4 @@ declare function formatSelectorFailure(chain: SelectorChain | string, diagnostic
1087
1098
  unique?: boolean;
1088
1099
  }): string;
1089
1100
  //#endregion
1090
- export { GesturePointerCount as A, ClickButton as B, FoldPose as C, PermissionMode as D, PermissionAction as E, ScrollDirection as F, SessionSurface as G, FindLocator as H, ScrollInputDirection as I, SwipePattern as L, PointerTrajectory as M, PointerTrajectorySample as N, TextSizeCategory as O, SinglePointerGesturePlan as P, SwipePreset as R, DeviceRotation as S, MOBILE_PERMISSION_TARGETS as T, ScreenshotResultData as U, AndroidSnapshotBackendMetadata as V, SnapshotDiagnosticsSummary as W, HoverCommandResponseData as _, resolveSelectorChain as a, SettleObservation as b, isSelectorToken as c, Interactor as d, RunnerContext as f, FindCommandResponseData as g, FillCommandResponseData as h, findSelectorChainMatch as i, MultiTouchGesturePlan as j, BackMode as k, parseSelectorChain as l, ClickCommandResponseData as m, isNodeEditable as n, SelectorDiagnostics as o, ScrollCommandResult as p, isNodeVisible as r, SelectorChain as s, formatSelectorFailure as t, tryParseSelectorChain as u, LongPressCommandResponseData as v, MACOS_PERMISSION_TARGETS as w, TvRemoteButton as x, PressCommandResponseData as y, TransformGestureParams as z };
1101
+ export { BackMode as A, TransformGestureParams as B, FoldPose as C, PermissionAction as D, MOBILE_PERMISSION_TARGETS as E, SinglePointerGesturePlan as F, SnapshotDiagnosticsSummary as G, AndroidSnapshotBackendMetadata as H, ScrollDirection as I, SessionSurface as K, ScrollInputDirection as L, MultiTouchGesturePlan as M, PointerTrajectory as N, PermissionMode as O, PointerTrajectorySample as P, SwipePattern as R, DeviceRotation as S, MACOS_PERMISSION_TARGETS as T, FindLocator as U, ClickButton as V, ScreenshotResultData as W, HoverCommandResponseData as _, resolveSelectorChain as a, SettleObservation as b, isSelectorToken as c, Interactor as d, RunnerContext as f, FindCommandResponseData as g, FillCommandResponseData as h, findSelectorChainMatch as i, GesturePointerCount as j, TextSizeCategory as k, parseSelectorChain as l, ClickCommandResponseData as m, isNodeEditable as n, SelectorDiagnostics as o, ScrollCommandResult as p, isNodeVisible as r, SelectorChain as s, formatSelectorFailure as t, tryParseSelectorChain as u, LongPressCommandResponseData as v, SetFoldPoseInput as w, TvRemoteButton as x, PressCommandResponseData as y, SwipePreset as z };
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./simulator.js";export{n as ensureBootedSimulator,t as markSimulatorBooted,e as wasSimulatorRecentlyObservedBooted};
1
+ import{i as e,n as t,t as n}from"./simulator.js";export{n as ensureBootedSimulator,t as markSimulatorBooted,e as wasSimulatorRecentlyObservedBooted};
@@ -1 +1 @@
1
- import{D as e}from"./sdk-contracts.js";import{a as t,n}from"./exec.js";import"./command.js";import{i as r,n as i}from"./retry.js";import{t as a}from"./ttl-memo.js";import{n as o,t as s}from"./boot-diagnostics.js";import{t as c}from"./scoped-provider.js";import{l,r as u}from"./config.js";import{a as d,o as f}from"./tool-provider.js";import{t as p}from"./simctl.js";const m=[`Simulator`],h=[`Device Hub`,`Simulator`],g=c(void 0);async function _(e,t){return await g.run(e,t)}const v=a({ttlMs:5e3});function y(e){return`${e.id}|${e.simulatorSetPath??``}`}function b(e){return v.get(y(e))===!0}function x(e){v.set(y(e),!0)}function S(t,n){if(t.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`${n} is only supported on iOS simulators`)}async function C(e={}){let t=e.deviceHub?h:m,n=e.background?[`-g`,`-a`]:[`-a`];for(let r of t)if((await d(`open`,[...n,r],{allowFailure:!0,signal:e.signal,timeoutMs:1e4})).exitCode===0)return}async function w(a,c={}){if(a.kind!==`simulator`)return;c.signal?.throwIfAborted();let l=g.resolve();if(l){await l(a),c.signal?.throwIfAborted();return}if((b(a)?`Booted`:await T(a,c.signal))===`Booted`){x(a),c.focusExisting&&await C({background:c.deviceHub,deviceHub:c.deviceHub,signal:c.signal});return}c.onColdBootStart?.(a);let d=i.fromTimeoutMs(u),m,h;try{await r(async({deadline:r})=>{if(r?.isExpired())throw new e(`COMMAND_FAILED`,`iOS simulator boot deadline exceeded`,{timeoutMs:u});let i=Math.max(1e3,r?.remainingMs()??18e4);m=await f(p(a,[`boot`,a.id]),{allowFailure:!0,signal:c.signal,timeoutMs:i});let o=`${m.stdout}\n${m.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(m.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,n(m));h=await f(p(a,[`bootstatus`,a.id,`-b`]),{allowFailure:!0,signal:c.signal,timeoutMs:i}),t(h,`simctl bootstatus failed`);let l=await T(a,c.signal);if(l!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{state:l})},{maxAttempts:3,baseDelayMs:500,maxDelayMs:2e3,jitter:.2,shouldRetry:e=>{let t=o({error:e,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}});return t!==`IOS_BOOT_TIMEOUT`&&t!==`CI_RESOURCE_STARVATION_SUSPECTED`}},{deadline:d,phase:`boot`,signal:c.signal,classifyReason:e=>o({error:e,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}})})}catch(t){let n=o({error:t,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}});throw new e(`COMMAND_FAILED`,`iOS simulator failed to boot`,{platform:`ios`,deviceId:a.id,timeoutMs:u,elapsedMs:d.elapsedMs(),reason:n,hint:s(n),boot:m,bootstatus:h})}x(a),await C({deviceHub:c.deviceHub,signal:c.signal})}async function T(e,t){let n=p(e,[`list`,`devices`,`-j`]),r=await f(n,{allowFailure:!0,signal:t,timeoutMs:l});if(r.exitCode!==0)return null;try{let t=JSON.parse(r.stdout);for(let n of Object.values(t.devices??{})){let t=n.find(t=>t.udid===e.id);if(t)return t.state}return null}catch{return null}}export{b as a,S as i,x as n,_ as o,C as r,w as t};
1
+ import{D as e}from"./sdk-contracts.js";import{a as t,n}from"./exec.js";import"./command.js";import{i as r,n as i}from"./retry.js";import{t as a}from"./ttl-memo.js";import{n as o,t as s}from"./boot-diagnostics.js";import{t as c}from"./scoped-provider.js";import{l,r as u}from"./config.js";import{a as d,o as f}from"./tool-provider.js";import{t as p}from"./simctl.js";const m=[`Simulator`],h=[`Device Hub`,`Simulator`],g=c(void 0);async function _(e,t){return await g.run(e,t)}const v=a({ttlMs:5e3});function y(e){return`${e.id}|${e.simulatorSetPath??``}`}function b(e){return v.get(y(e))===!0}function x(e){v.set(y(e),!0)}function S(t,n){if(t.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`${n} is only supported on iOS simulators`)}async function C(e={}){let t=e.deviceHub?h:m,n=e.background?[`-g`,`-a`]:[`-a`];for(let r of t)if((await d(`open`,[...n,r],{allowFailure:!0,signal:e.signal,timeoutMs:1e4})).exitCode===0)return}async function w(a,c={}){if(a.kind!==`simulator`)return;c.signal?.throwIfAborted();let l=g.resolve();if(l){await l(a),c.signal?.throwIfAborted();return}if((b(a)?`Booted`:await T(a,c.signal))===`Booted`){x(a),c.focusExisting&&await C({background:c.deviceHub,deviceHub:c.deviceHub,signal:c.signal});return}c.onColdBootStart?.(a);let d=i.fromTimeoutMs(u),m,h;try{await r(async({deadline:r})=>{if(r?.isExpired())throw new e(`COMMAND_FAILED`,`iOS simulator boot deadline exceeded`,{timeoutMs:u});let i=Math.max(1e3,r?.remainingMs()??18e4);m=await f(p(a,[`boot`,a.id]),{allowFailure:!0,signal:c.signal,timeoutMs:i});let o=`${m.stdout}\n${m.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(m.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,n(m));h=await f(p(a,[`bootstatus`,a.id,`-b`]),{allowFailure:!0,signal:c.signal,timeoutMs:i}),t(h,`simctl bootstatus failed`);let l=await T(a,c.signal);if(l!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{state:l})},{maxAttempts:3,baseDelayMs:500,maxDelayMs:2e3,jitter:.2,shouldRetry:e=>{let t=o({error:e,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}});return t!==`IOS_BOOT_TIMEOUT`&&t!==`CI_RESOURCE_STARVATION_SUSPECTED`}},{deadline:d,phase:`boot`,signal:c.signal,classifyReason:e=>o({error:e,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}})})}catch(t){let n=o({error:t,stdout:h?.stdout??m?.stdout,stderr:h?.stderr??m?.stderr,context:{platform:`ios`,phase:`boot`}});throw new e(`COMMAND_FAILED`,`iOS simulator failed to boot`,{platform:`ios`,deviceId:a.id,timeoutMs:u,elapsedMs:d.elapsedMs(),reason:n,hint:s(n),boot:m,bootstatus:h})}x(a),await C({deviceHub:c.deviceHub,signal:c.signal})}async function T(e,t){let n=p(e,[`list`,`devices`,`-j`]),r=await f(n,{allowFailure:!0,signal:t,timeoutMs:l});if(r.exitCode!==0)return null;try{let t=JSON.parse(r.stdout);for(let n of Object.values(t.devices??{})){let t=n.find(t=>t.udid===e.id);if(t)return t.state}return null}catch{return null}}export{_ as a,b as i,x as n,S as r,w as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-device",
3
- "version": "0.21.11",
3
+ "version": "0.21.12",
4
4
  "description": "Mobile app automation and verification for AI coding agents. CLI, MCP server, and typed Node.js API for iOS, Android, HarmonyOS, TV, web, macOS, and Linux.",
5
5
  "mcpName": "io.github.callstack/agent-device",
6
6
  "license": "MIT",
@@ -214,6 +214,7 @@
214
214
  "apple/macos-helper",
215
215
  "!apple/macos-helper/**/.build",
216
216
  "apple/snapshot-bridge",
217
+ "apple/fold-helper",
217
218
  "android/snapshot-helper/dist",
218
219
  "!android/snapshot-helper/dist/*.idsig",
219
220
  "!android/snapshot-helper/README.md",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/callstack/agent-device",
8
8
  "source": "github"
9
9
  },
10
- "version": "0.21.11",
10
+ "version": "0.21.12",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "agent-device",
15
- "version": "0.21.11",
15
+ "version": "0.21.12",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -1 +0,0 @@
1
- 63beaf80513455a01906685716ad7a91169cb5632dc054e02d06047957490697 agent-device-android-ime-helper-0.21.11.apk
@@ -1 +0,0 @@
1
- 9201208584b56e121818bcfcf8db066d8f0f63309af27c34edccc0f9b16e9cfb agent-device-android-snapshot-helper-0.21.11.apk
@@ -1,47 +0,0 @@
1
- import Foundation
2
-
3
- /// The decisions the Device Hub pose press makes without a window server: which control a pose
4
- /// names, which window belongs to a device, and which sidebar row identifies it. They live apart
5
- /// from the helper executable so the tests can exercise them without an accessibility session.
6
-
7
- /// Device Hub's three pose presets for a foldable simulator, named as the helper's `--pose`
8
- /// argument spells them. Each maps to the accessibility description of its action-bar button.
9
- public enum DeviceHubPose: String, CaseIterable, Sendable {
10
- case closed
11
- case book
12
- case open
13
-
14
- public init?(argument: String) {
15
- self.init(rawValue: argument.lowercased())
16
- }
17
-
18
- /// The `AXDescription` Device Hub gives the button for this pose.
19
- public var controlDescription: String {
20
- switch self {
21
- case .closed: return "Closed"
22
- case .book: return "Book"
23
- case .open: return "Open"
24
- }
25
- }
26
- }
27
-
28
- /// Device Hub is launched through a trampoline, so LaunchServices registers it with no process
29
- /// identifier; the process table is matched on the executable path instead.
30
- public let deviceHubExecutableSuffix = "/DeviceHub.app/Contents/MacOS/DeviceHub"
31
-
32
- /// The separator Device Hub puts between the device name and the OS in a window title.
33
- public let deviceHubWindowTitleSeparator = " – "
34
-
35
- /// Device Hub titles a device window `<device name> – <OS> <version>`, so a window shows the
36
- /// device when its title is the name or the name followed by that exact separator. A bare
37
- /// space would also match a simulator whose name merely extends this one ("iPhone Duo Lab").
38
- public func deviceHubWindowShows(deviceName: String, title: String?) -> Bool {
39
- guard let title else { return false }
40
- return title == deviceName || title.hasPrefix(deviceName + deviceHubWindowTitleSeparator)
41
- }
42
-
43
- /// The accessibility identifier of the sidebar row for one simulator. The UDID is the one device
44
- /// identity Device Hub exposes that two simulators sharing a name cannot confuse.
45
- public func deviceHubDeviceRowIdentifier(udid: String) -> String {
46
- return "TableRow.Device.\(udid)"
47
- }
@@ -1,65 +0,0 @@
1
- import ApplicationServices
2
-
3
- package enum DeviceHubWindowRead {
4
- case available([AXUIElement])
5
- case failed(Int32)
6
- }
7
-
8
- package struct DeviceHubWindowCandidate {
9
- package let processID: Int32
10
- package let window: AXUIElement
11
- }
12
-
13
- package enum DeviceHubRowLookup {
14
- case identified(AXUIElement, restoreSidebar: Bool)
15
- case sidebarUnavailable
16
- case unconfirmed
17
- case timedOut
18
-
19
- package var diagnostic: String {
20
- switch self {
21
- case .identified: return "identified"
22
- case .sidebarUnavailable: return "sidebar-unavailable"
23
- case .unconfirmed: return "row-unconfirmed"
24
- case .timedOut: return "timed-out"
25
- }
26
- }
27
- }
28
-
29
- package struct DeviceHubWindowInventory {
30
- package private(set) var candidates: [DeviceHubWindowCandidate] = []
31
- package private(set) var emptyProcessIDs: [Int32] = []
32
- package private(set) var failures: [Int32: Int32] = [:]
33
- package private(set) var candidateOutcomes: [String] = []
34
- package private(set) var budgetExpired = false
35
-
36
- package init() {}
37
-
38
- package mutating func record(processID: Int32, read: DeviceHubWindowRead) {
39
- switch read {
40
- case .available(let windows):
41
- if windows.isEmpty { emptyProcessIDs.append(processID) }
42
- candidates.append(contentsOf: windows.map { DeviceHubWindowCandidate(processID: processID, window: $0) })
43
- case .failed(let status):
44
- failures[processID] = status
45
- }
46
- }
47
-
48
- package mutating func record(candidate: Int, outcome: DeviceHubRowLookup) {
49
- candidateOutcomes.append("\(candidates[candidate].processID):\(candidate):\(outcome.diagnostic)")
50
- }
51
-
52
- package mutating func expireBudget() { budgetExpired = true }
53
-
54
- package func processesToReopen(attempted: Set<Int32>) -> [Int32] {
55
- budgetExpired ? [] : emptyProcessIDs.filter { !attempted.contains($0) }
56
- }
57
-
58
- package func failureReason(reopenFailures: [Int32: String] = [:]) -> String {
59
- if !failures.isEmpty { return "device-hub-window-read-failed" }
60
- if budgetExpired { return "device-hub-discovery-timeout" }
61
- if !candidates.isEmpty { return "device-hub-identity-unconfirmed" }
62
- if let reason = reopenFailures.sorted(by: { $0.key < $1.key }).first?.value { return reason }
63
- return "device-hub-window-missing"
64
- }
65
- }