agent-device 0.21.18 → 0.21.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.18.apk → agent-device-android-ime-helper-0.21.19.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.19.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.18.manifest.json → agent-device-android-ime-helper-0.21.19.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.18.apk → agent-device-android-snapshot-helper-0.21.19.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.19.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.18.manifest.json → agent-device-android-snapshot-helper-0.21.19.manifest.json} +6 -6
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +2 -2
- package/dist/src/adb-failure.js +2 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-log-runtime2.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/catalog.js +1 -1
- package/dist/src/cli-help.js +1 -1
- package/dist/src/cli.js +4 -4
- package/dist/src/client-types.d.ts +11 -4
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-tools.js +2 -2
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/diagnostics2.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions2.js +2 -2
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/mechanics.js +16 -17
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/observe-until.js +1 -0
- package/dist/src/overlay.js +2 -2
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-operation-builder.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/provider-device-admission.js +1 -0
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/registry.js +36 -36
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay.js +1 -1
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +3 -3
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-startup-transport.js +1 -1
- package/dist/src/runner-xctestrun.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-admission.js +1 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +2 -2
- package/dist/src/runtime2.js +1 -1
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +4 -4
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +1 -1
- package/dist/src/sdk-contracts.d.ts +16 -2
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +9 -0
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session2.js +5 -5
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/touch-runtime2.js +1 -0
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.18.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.18.apk.sha256 +0 -1
- package/dist/src/runner-command-traits.js +0 -1
package/dist/src/sdk-batch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{N as e,y as t}from"./sdk-contracts.js";import{g as n,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`],o={x:-Number.MAX_VALUE/2,y:-Number.MAX_VALUE/2,width:Number.MAX_VALUE,height:Number.MAX_VALUE};function s(e){return e.x===o.x&&e.y===o.y&&e.width===o.width&&e.height===o.height}function c(e){if(!e)return!1;let{x:t,y:n,width:r,height:i}=e;return![t,n,r,i].every(Number.isFinite)||!Number.isFinite(t+r)||!Number.isFinite(n+i)||r<=0||i<=0?!1:!s(e)}function l(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 u(e){return e.width*e.height}function d(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function ee(e,t,n){if(!e||!c(t))return!1;let r=t.x+t.width/2,i=t.y+t.height/2;return r>=n.x&&r<n.x+n.width&&i>=n.y&&i<n.y+n.height}function f(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 te(e,t){return ne(e.x,e.x+e.width,t.x,t.x+t.width)&&ne(e.y,e.y+e.height,t.y,t.y+t.height)}function ne(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function re(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function ie(e){return re(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function ae(e){return e?.trim().toLowerCase()||null}function oe(e,t){let n=ae(t);return n?[e.label,e.value,e.identifier].some(e=>(e??``).toLowerCase().includes(n)):!1}function se(e,t,n=()=>!0){if(!ae(t))return null;for(let[r,i]of e.entries()){if(!oe(i,t))continue;let a=i.depth??0,o=r+1;for(;o<e.length&&(e[o]?.depth??0)>a;)o+=1;let s={start:r,end:o};if(n(s))return s}return null}function ce(e,t=0){let n=new Map;for(let[t,r]of e.entries())n.set(r.index,t);return e.map((e,r)=>({...e,index:r,depth:Math.max(0,(e.depth??0)-t),parentIndex:typeof e.parentIndex==`number`?n.get(e.parentIndex):void 0}))}function p(e){return new Map(e.map(e=>[e.index,e]))}function le(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 ue(e,t,n){return le(e,t,p(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 de(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 fe(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function pe(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 me=Symbol(`SnapshotVisibility`);function he(e,t={}){let n,r,i=()=>(n||(n=p(e),t.onNodeMapBuilt?.()),n),a=()=>(r||(r=_e(e),t.onViewportRectsCollected?.()),r),o=n=>ye(e,n,a(),t.onContainingRectFallback),s=n=>{let r=Se(n,i(),e=>!!e.rect)?.rect;if(r)return r;let o=a();return o.length===0?null:ye(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||te(e.rect,t)},l=e=>e.rect?c(e)?xe(e.rect,o(e.rect)):!1:!0;return{[me]:!0,get nodeByIndex(){return i()},get viewportRects(){return a()},findAncestor(t,n){return le(e,t,i(),n)},isVisibleInEffectiveViewport:c,isVisibleOnScreen:l,resolveEffectiveViewport:s,resolveViewport:o}}function ge(e){let t=[e.type,e.role,e.subrole].map(e=>m(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function _e(e){return e.flatMap(e=>ge(e)&&c(e.rect)?[e.rect]:[])}function ve(e,t,n){return ye(e,t,n??_e(e))}function ye(e,n,r,i){let a=t(n),o=e=>d(e,a.x,a.y);return(f(r.filter(o))??f(r))||(i?.(),f(e.flatMap(e=>be(e.rect)&&o(e.rect)?[e.rect]:[])))}function be(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function xe(e,t){return!t||t.width<=0||t.height<=0||d(t,e.x+e.width/2,e.y+e.height/2)}function Se(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)&&ie(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function Ce(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&&c(e.rect):e.hittable===!0||c(e.rect)}function g(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function we(e,t){return de(e.type??``,t)&&e.enabled!==!1}const Te=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),Ee=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),_=new Set([...Te,...Ee]),De=[..._],Oe=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 ke(e){return Oe.has(e.trim().toLowerCase())}const Ae=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
|
|
2
|
-
`],[`r`,`\r`],[`t`,` `]]);function v(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Pe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Me(e))}}function y(e){try{return v(e)}catch{return null}}function b(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 je(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=Le(i).trim();return a?{key:r,value:a}:null}function x(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||!b(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&y(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 Me(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Fe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Ne)}}function Ne(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(!Ee.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(Ee.has(i)){let t=Be(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:Le(a)}}function Pe(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Ve(t,a)){i=Ie(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 Fe(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ve(t,e)){i=Ie(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 Ie(e,t){return e?e===t?null:e:t}function Le(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Re(t.slice(1,-1)):t}function Re(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=ze(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 ze(e){return Ae.get(e)??null}function Be(e){let t=Le(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ve(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function He(e){return a.includes(e)}const Ue=`is requires predicate: ${a.join(`|`)}`;function We(e){let t=e.toLowerCase();return He(t)?{ok:!0,predicate:t}:i(Ue,Ge)}const Ge=`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 Ke(e){if(He((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(He(n)&&y(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function qe(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=h(n),s=we(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):Ye(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 Je(t)}let ee=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:ee}}function Je(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Ye(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(c(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=Xe(e,t,n);return r?c(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function Xe(e,t,n){return t.findAncestor(e,e=>Ce(e,n)?e:null)}function Ze(e){let t=Ke(e),n=t[0]??``;return{predicate:n,split:x(t.slice(1),{preferTrailingValue:n===`text`})}}const Qe=`is requires a selector expression`,$e=`is text requires expected text value`;function et(e){let{predicate:t,split:n}=Ze([...e]),r=We(t);if(!r.ok)return r;if(!n)return i(Qe);let a=n.rest.join(` `).trim();return r.predicate===`text`&&!a?i($e):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 tt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:i(`get only supports text or attrs`)}function nt(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 rt(e){return e?{ok:!0,text:e}:i(`wait requires text`)}function it(e){return Array.from(new Set(e))}function at(e){return JSON.stringify(ot(e))}function ot(e){if(Array.isArray(e))return e.map(ot);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,ot(t[e])]))}function st(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 ct=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,lt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,ut=4096;function dt(e){return e.normalize(`NFC`)}function ft(e){if(e===void 0)return;let t=dt(e);return t.length>0?t:void 0}function pt(e){return dt(e)}function mt(e){if(e===void 0)return;let t=dt(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function S(e){return Buffer.byteLength(e,`utf8`)}function C(e,t){if(S(e)<=t)return e;let n=e.length;for(;n>0&&S(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 w(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(ht),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=gt(e.scrollRegion)),e.rect&&(t.rect=_t(e.rect)),t.verification=e.verification,t}function ht(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function gt(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 _t(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function vt(e){return JSON.stringify(w(e))}function yt(e){return`# agent-device:target-v1 ${vt(e)}`}function bt(e){return JSON.stringify({source:w(e.source),destination:w(e.destination)})}function xt(e){return`# agent-device:targets-v1 ${bt(e)}`}function St(e){let t=e.trim(),n=lt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Ct((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Ct(t){if(S(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:T(JSON.stringify(r.source)),destination:T(JSON.stringify(r.destination))}}function wt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=ct.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:T((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function T(t){if(S(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${ut}-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=Tt(r.role,`role`),a=Et(r.id,`id`),o=Dt(r.label,`label`),s=kt(r.ancestry),c=jt(r.sibling,`sibling`,0),l=jt(r.viewportOrder,`viewportOrder`,0),u=Mt(r.scrollRegion),d=Nt(r.rect),ee=Pt(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:ee}}function Tt(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 Ot(pt(t),n)}function Et(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=ft(t);return r===void 0?void 0:Ot(r,n)}function Dt(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=mt(t);return r===void 0?void 0:Ot(r,n)}function Ot(t,n){if(S(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function kt(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)=>At(e,t))}function At(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=Tt(r.role,`ancestry[${n}].role`),a=Dt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function jt(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 Mt(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=Tt(n.role,`scrollRegion.role`),i=Et(n.id,`id`),a=Dt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Nt(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:E(n.x,`rect.x`),y:E(n.y,`rect.y`),width:E(n.width,`rect.width`),height:E(n.height,`rect.height`)}}function E(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 Pt(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function Ft(e){let t=pt(m(e.type??``)),n=ft(e.identifier),r=mt(e.label);return{...n===void 0?{}:{id:C(n,256)},role:C(t,256),...r===void 0?{}:{label:C(r,256)}}}function It(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Lt(e,t){let n=0;for(let r of e)Ft(r).id===t&&(n+=1);return n}function Rt(e,t){if(e.id===void 0||Lt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function zt(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 Bt(e,t){return{documentOrder:e.index,sibling:zt(t,e)}}function Vt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Ht(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Ut(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Wt(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 Gt(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 Kt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function qt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Jt(e,t){for(let[n,r]of e.entries()){let e=t[n];if(qt(r,e))return[`ancestry[${n}]: recorded=${Kt(r)} observed=${Kt(e)}`]}return[]}function Yt(e,t,n={}){let r=[],i=m(e.type??``),a=Xt(e,n.nodes),o=O(e.label),s=O(e.value),c=O(h(e)),l=n.action===`fill`;a&&r.push(`id=${D(a)}`),i&&o&&r.push(l?`role=${D(i)} label=${D(o)} editable=true`:`role=${D(i)} label=${D(o)}`),o&&r.push(l?`label=${D(o)} editable=true`:`label=${D(o)}`),s&&r.push(l?`value=${D(s)} editable=true`:`value=${D(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${D(c)} editable=true`:`text=${D(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${D(i)} editable=true`);let u=it(r);return u.length===0&&i&&u.push(l?`role=${D(i)} editable=true`:`role=${D(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function Xt(e,t){let n=O(e.identifier);if(!n||!t)return n;let r=Ft(e).id;return r===void 0?n:Lt(t,r)>1?null:n}function D(e){return JSON.stringify(e)}function O(e){return e&&e.trim()||null}const Zt=[`any`,`text`,`label`,`value`,`role`,`id`],Qt=[`text`,`label`,`value`,`role`,`id`];function $t(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function en(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function tn(e,t,n,r={}){let i=A(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=nn(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 nn(e,t,n){switch(t){case`role`:return rn(e.type,n);case`label`:return k(e.label,n);case`value`:return k(e.value,n);case`id`:return k(e.identifier,n);default:return Math.max(k(e.label,n),k(e.value,n),k(e.identifier,n))}}function k(e,t){let n=A(e??``);return n?n===t?2:+!!n.includes(t):0}function rn(e,t){let n=an(e??``);return n?n===t?2:+!!n.includes(t):0}function A(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function an(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const on=`find requires a value`,sn=`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 cn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=dn([...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:on}}const ln=[`exists`,`list`,`click`,`focus`];function un(e){return ln.includes(e)}function dn(t){let n=`any`,r=0;Qt.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=$t(a[0]);if(un(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:fn(a[1])};if(o===`wait`){let e=mn(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:sn})}function fn(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 pn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:y(t)?t:null}function mn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function hn(e,t,n){return t.terms.every(t=>gn(e,t,n))}function gn(e,t,n){switch(t.key){case`id`:return j(e.identifier,String(t.value));case`role`:return j(m(e.type??``),String(t.value));case`label`:return j(e.label,String(t.value));case`value`:return j(e.value,String(t.value));case`text`:return j(h(e),String(t.value));case`appname`:return j(e.appName,String(t.value));case`windowtitle`:return j(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return we(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 j(e,t){return A(e??``)===A(t)}function _n(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=wn(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 vn(e,t,n){return _n(e,t,n).resolution}function yn(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:hn(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function bn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=On(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 xn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Sn(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 Cn(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 wn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=he(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||hn(l,t,n)&&(i+=1,a??=l,o.push(l),Tn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:En(o,s.best,c),candidates:o}}function Tn(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=kn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function En(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Dn(i,r,n).result>0)&&(r=i);return r?Dn(t,r,n).criterion:null}function Dn(e,t,n){let r=n(e);return r===n(t)?kn(e,t):{result:r?1:-1,criterion:`visible`}}function On(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||hn(a,t,n)&&(i+=1);return i}function kn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=An(e),a=An(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function An(e){return e.rect?e.rect.width*e.rect.height:1/0}const jn={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 Mn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Nn(e,t){let n=e===`is`?Ze([...t]).split:x([...t]);return n?y(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Pn(e){return{platform:e.platform,...Mn({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function Fn(e,t,n){let r=y(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=_n(t,r,Pn(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 In(e,t,n={}){return Yt(e,t,n)}function Ln(e,t,n){let r=y(e);if(!r)return;let i=vn(t,r,Pn(n));if(i)return{node:i.node,basis:zn(i.selector)}}function Rn(e){if(!e)return;let t=y(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 zn(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 Bn(e,t){let n=y(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Vn(n.selectors,r,i):Hn(n.selectors[0],r,new Set(t.booleanKeys),i)}function Vn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Un(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 Hn(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Un(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Wn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Un(e,t,n){return t.has(e)||n[e]!==void 0}function Wn(e,t,n){return t.has(e.key)&&typeof e.value===n}function Gn(e){let t=y(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 Kn(e,t){if(!t)return!1;let n=y(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 qn(e,t){return y(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Jn(e){return v(e).selectors.map(e=>e.raw)}function Yn(e){return y(e)!==null}function Xn(e){v(e)}function M(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Zn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Qn(e){let t=e[0];if(t===void 0)return null;let n=M(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=M(e.at(-1));return t===`text`?$n(e,r):t===`stable`?er(e):t===`absent`?tr(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:rr(e,r)}function $n(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function er(e){let t=e.slice(1),n=t.length>1?M(t[1]):null;return{kind:`stable`,quietMs:t.length>0?M(t[0]):null,timeoutMs:n}}function tr(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=x(n);return n.length>0&&r?.rest.length===0&&Yn(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:nr(n)}}function nr(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 rr(e,t){let n=t===null?e.slice():e.slice(0,-1),r=x(n);return r&&r.rest.length===0&&Yn(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:ir(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function ir(e,t){for(let t of e){let n=je(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:ar(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:or(t,e)}:e.some(e=>b(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:sr(e)}:null}function ar(e,t){let n=t.join(` `),r=ke(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${De.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function or(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 sr(e){let t=e.join(` `),n=e.filter(e=>!b(e)),r=e.filter(e=>b(e));if(n.length>0){let e=n[0],i=Zn.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 (${De.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 cr(e){let t=Qn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const lr=3e4,ur=24e4,dr=3e5,N={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},fr={budget:{source:`none`},envelopeMs:255e3,onTimeout:`reset-daemon`};function pr(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return mr(n,t.positionals??[])??hr(n,t.flags)??n.envelopeMs}function mr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:vr(e,n)}function hr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?_r(e,e.budget,t):e.budget.envelope===`margin`?gr(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function gr(e,t){let n=typeof t?.timeoutMs==`number`?vr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?yr({...e,envelopeMs:n},t.waitMs):n}function _r(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?yr(e,r):e.envelopeMs}function vr(e,t){return Math.max(e.envelopeMs,t+lr)}function yr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+lr)}const br={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function xr(e){if(e!==void 0)return br[e]}function P(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 Sr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function Cr(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 wr(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 F(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 Tr(e,t){return F(e)===F(t)}function Er(e,t){return e.available?t():{}}function Dr(e){if(!I(e.requesterId)||!I(e.identityIncarnationId)||!kr(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 Or(e){let t=Ar(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!I(n)||!I(r)||!kr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return Dr(i).token===e.token?i:null}function kr(e){return Number.isInteger(e)&&e>=0}function I(e){return typeof e==`string`&&e.trim().length>0}function Ar(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function jr(e,t){let n={},r={};for(let i of t.required){let t=Mr(e.facts.operations,i);if(n[i]=t,!t.available)throw Lr(i,t);r[i]=Fr(e.operations,i)}for(let i of t.preferred){let t=Mr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Fr(e.operations,i))}for(let i of t.conditional??[]){let t=Mr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Fr(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function Mr(e,t){let n=e[t];if(!Nr(n))throw P(`Runtime owner omitted the ${t} fact`);let r=Pr(n);if(r)return r;throw P(`Runtime owner returned an invalid ${t} fact`)}function Nr(e){return typeof e==`object`&&!!e&&`available`in e}function Pr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Ir(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 Fr(e,t){let n=e[t];if(typeof n!=`function`)throw P(`Runtime owner advertised ${t} without an implementation`);return n}function Ir(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-device-scope`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Lr(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function Rr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function zr(){return e=>{let t=Br(e.required,`required`),n=Br(e.preferred??[],`preferred`),r=Br(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 Br(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=zr(),Vr=L({required:[`bootTarget`]}),Hr=L({required:[`bootTargetHeadless`]}),Ur=L({required:[`ensureReady`,`listApps`]}),Wr=L({required:[`captureSnapshot`]}),Gr=L({required:[`setViewport`]}),Kr=L({required:[`focusPoint`]}),qr=L({required:[`typeText`]}),Jr=L({required:[`back`]}),Yr=L({required:[`home`]}),Xr=L({required:[`setOrientation`]}),Zr=L({required:[`setFoldPose`]}),Qr=L({required:[`tvRemote`]}),$r=L({required:[`keyboardStatus`]}),ei=L({required:[`keyboardDismiss`]}),ti=L({required:[`keyboardEnter`]}),ni=L({required:[`appSwitcher`]}),ri=L({required:[`actionButton`]}),ii=L({required:[`triggerAppEvent`]}),ai=L({required:[`setSetting`]}),oi=L({required:[`readSetting`]}),si=L({required:[`readAlert`]}),ci=L({required:[`awaitAlert`]}),li=L({required:[`acceptAlert`]}),ui=L({required:[`dismissAlert`]}),di=L({required:[`readClipboard`]}),fi=L({required:[`writeClipboard`]}),pi=L({required:[`perfFrames`]}),mi=L({required:[`perfMemorySample`]}),hi=L({required:[`perfMemorySnapshot`]}),gi=L({required:[`perfNativeCaptureStart`]}),_i=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),vi=L({required:[`perfProfileReport`]}),yi=Object.freeze([pi,mi,hi,gi,_i,vi]),R=L({required:[`tapPoint`]}),bi=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),xi=L({required:[`longPressPoint`]}),z=L({required:[`captureSnapshot`,`longPressPoint`]}),Si=L({required:[`hoverPoint`]}),Ci=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),wi=L({required:[`fillPoint`]}),Ti=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),Ei=Object.freeze([R,bi]),Di=Ei,Oi=Object.freeze([xi,z]),ki=Object.freeze([Si,Ci]),Ai=Object.freeze([wi,Ti]);function ji(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:bi}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:Ti}:{kind:`fill-point`,use:wi};case`longpress`:return t?{kind:`captured-long-press`,use:z}:{kind:`long-press-point`,use:xi};case`hover`:return t?{kind:`captured-hover`,use:Ci}:{kind:`hover-point`,use:Si}}}const Mi=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ni=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Pi=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Fi=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ii=L({required:[`gestureViewport`]}),Li=L({required:[`scrollDirection`],conditional:[`captureSnapshot`]}),Ri=L({required:[`scrollDirection`,`captureSnapshot`]}),zi=Object.freeze({plan:Mi,"directional-fling":Ni,"multi-touch":Pi,"target-authored-drag":Fi}),Bi=Object.freeze([Mi,Ni,Pi,Fi]),Vi=Object.freeze([Mi]),Hi=Object.freeze([Li,Ri]);function Ui(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Wi(e){return e.intent===`drag`?`target-authored-drag`:Ui(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function Gi(e){let t=Wi(e);switch(t){case`plan`:return B(t);case`directional-fling`:return B(t);case`multi-touch`:return B(t);case`target-authored-drag`:return B(t)}}function B(e){let t=zi[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function Ki(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Li}):Object.freeze({kind:`edge`,edge:e.edge,use:Ri}):Object.freeze({kind:`until`,until:e.until,use:Ri})}const qi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Ji=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Xi=L({required:[`captureSnapshot`]}),Zi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Qi=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),$i=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),ea=L({required:[`captureSnapshot`],conditional:[`findText`]}),ta=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),na=Object.freeze([Xi,Zi]),ra=Object.freeze([Qi,$i]),ia=L({required:[`captureSnapshot`,`focusPoint`]}),aa=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),oa=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),sa=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),ca=Object.freeze([Qi,$i,Xi,Zi,ia,aa,oa,sa]),la=Object.freeze([ea,ta]),ua=Object.freeze([Wr,qi,Ji,Yi]),V=Object.freeze({"capture-only":na,"element-text":ra,"wait-observation":la,"find-focus":Object.freeze([ia,aa]),"find-type":Object.freeze([oa,sa])});function da(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function fa(e){switch(e.intent){case`capture-only`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`element-text`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`wait-observation`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-focus`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-type`:return H(e.hasActiveApp,e.intent,V[e.intent])}}function H(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 pa(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:qi}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:Yi}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Wr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Ji})}const ma=L({required:[`captureScreenshot`]}),ha=L({required:[`captureScreenshot`,`captureSnapshot`]}),ga=Object.freeze([ma,ha]);function _a(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:ha}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:ha}):Object.freeze({kind:`capture`,use:ma})}const va=Object.freeze([Vr,Hr]),ya=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Vr}),ba=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Hr});function xa(e){return e.headless?ba:ya}const Sa=L({required:[`ensureReady`,`appState`]}),Ca=Object.freeze([Sa]),wa=L({required:[`shutdownTarget`]}),Ta=Object.freeze([di,fi]),Ea=Object.freeze([ai,oi]),Da=[`text-size`],Oa=Object.freeze({kind:`write`,use:ai});function ka(e){let t=Aa(e?.[0]);return e?.length!==1||t===void 0?Oa:Da.includes(t)?Object.freeze({kind:`read`,setting:t,use:oi}):Oa}function Aa(e){let t=e?.trim().toLowerCase();return Da.find(e=>e===t)}const ja=Object.freeze([si,ci,li,ui]),Ma=Object.freeze([$r,ei,ti]),Na=L({required:[`deployApp`]}),Pa=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),Fa=L({required:[`ensureReady`,`sendPushNotification`]}),Ia=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),La=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Ra=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),za=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Ba(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:za}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:La}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Ra}):Object.freeze({kind:`open`,use:Ia})}const Va=Object.freeze([Ia,La,Ra,za]),Ha=L({required:[`closeApplication`,`finalizeApplicationClose`]}),Ua=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),Wa=Object.freeze([Ha,Ua]),Ga=L({required:[`finalizeApplicationClose`]}),Ka=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),qa=L({required:[`prepareAppleRunner`]}),Ja=L({required:[`clearRuntimeHints`]}),Ya=L({required:[`configureProviderPortReverse`]}),Xa=Object.freeze([Ja,Ya]),U=L({required:[`appLogInspect`]}),Za=L({required:[`appLogInspect`,`appLogDoctor`]}),Qa=L({required:[`appLogInspect`,`appLogStart`]}),$a=L({required:[],preferred:[`appLogInspect`]}),eo=Object.freeze([U,Za,Qa]);function to(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:U});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:Qa});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:U});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Za});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:U});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:Qa}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:U});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const no=L({required:[`audioProbeStart`]}),ro=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),io=L({required:[`audioProbeQuery`]}),ao=Object.freeze([no,ro,io]);function oo(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:io});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:no});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const so=[`probe`],co=[`start`,`status`,`stop`];function lo(t){let n=(t?.[0]??`probe`).toLowerCase();if(!so.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!co.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${co.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:uo(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:uo(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function uo(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 fo=L({required:[`networkDump`]}),po=L({required:[],preferred:[`networkDump`]}),mo=[`dump`,`log`],ho=[`summary`,`headers`,`body`,`all`];function go(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!_o(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!vo(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:fo})}function _o(e){return mo.some(t=>t===e)}function vo(e){return ho.some(t=>t===e)}function yo(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,bo(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=>xo(t,e)));return Object.freeze({families:a,modules:o,get:e=>xo(t,e)})}function bo(e){return Object.freeze({...e})}function xo(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const So=Object.freeze({kind:`device-inventory`});function Co(e){if(typeof e!=`object`||!e)throw Ao();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&W(n,[`kind`]))&&!(t.kind===`host`&&W(n,[`kind`]))&&!(t.kind===`inventory`&&W(n,[`kind`,`use`])&&To(t.use))&&!(t.kind===`device-runtime`&&W(n,[`kind`,`use`])&&Eo(t.use))&&!(t.kind===`device-runtime`&&(W(n,[`kind`,`uses`])||W(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&wo(t.uses)))throw Ao()}function wo(e){if(!Array.isArray(e)||e.length===0||!e.every(Eo))return!1;let t=e.map(Rr);return new Set(t).size===t.length}function To(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&W(Object.keys(t).sort(),[`kind`])}function Eo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[Oo(t.required),Oo(t.preferred),Oo(t.conditional??[])];if(!Do(n))return!1;let r=n.flat();return new Set(r).size===r.length&&W(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function Do(e){return e.every(e=>e!==null&&ko(e))}function Oo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function ko(e){return new Set(e).size===e.length}function W(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Ao(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const jo=L({required:[`screenRecordingStart`]}),Mo=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),No=L({required:[]}),Po=L({required:[],preferred:[`screenRecordingStart`]}),Fo=Object.freeze([jo,Mo]);function Io(t){switch((t.action??``).toLowerCase()){case`start`:if(!Lo(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:jo});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:No}):Object.freeze({kind:`stop-recovery`,use:Mo});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function Lo(e){return e===`app`||e===`device`||e===`system`}function Ro(e){if(Co(e),e.kind!==`device-runtime`||!(`uses`in e))throw zo();let t=e.uses.map(Rr),n=Fo.map(Rr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw zo()}function zo(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Bo(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 Co(t),t}const G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},K={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Vo=()=>!0,Ho=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Uo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Wo=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,Go=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},Ko=new Set([`status`,`get`]),qo=e=>rs(e,Ko,`status`),Jo=new Set([`get`,`wait`]),Yo=e=>rs(e,Jo,`get`),Xo=e=>is(e,Ko,`status`),Zo=e=>is(e,Jo,`get`),Qo=e=>{try{return en(dn(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},$o=e=>is(e,new Set([`read`]),``),es=e=>ka(e.positionals).kind===`read`,ts=e=>es(e)?`observes-app`:`mutates-app`,ns=e=>es(e)?`preserve`:`may-invalidate`;function rs(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function is(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},as={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0},os={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...N,onTimeout:`preserve-daemon`},ss={...N,envelopeMs:18e4},cs={...N,onTimeout:`preserve-daemon`},ls={...cs,envelopeMs:33e4},us={...N,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},ds={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}}},fs={fields:{delayMs:{defaultValue:0}}};function X(e,t){return xr(e)===void 0?t:us}function Z(e){let t=xr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const ps={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Na},timeoutPolicy:ss,batchable:!0},ms=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>pa({customActions:t,hasActiveApp:e}).use)},hs=e=>{let t=_s(e);if(t===void 0||!gs(t))return ca;let n=da(t);return[!0,!1].map(e=>fa({hasActiveApp:e,intent:n}).use)};function gs(e){return en(e)||e===`focus`||e===`type`}function _s(e){if(e.positionals===void 0)return;let t=cn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const vs=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Vo},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:ls,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:cs,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:cs,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...K},timeoutPolicy:N,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:N,batchable:!1,platformExecution:q},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...K},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`inventory`,use:So}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...K},timeoutPolicy:N,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:Vo,...K},timeoutPolicy:N,batchable:!0,platformExecution:as},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:Go},platformExecution:{kind:`device-runtime`,uses:[Ur]},timeoutPolicy:N,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:va},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},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:wa},timeoutPolicy:N,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:Ca},timeoutPolicy:N,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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:yi}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:eo},timeoutPolicy:N,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...K},timeoutPolicy:N,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:fo},timeoutPolicy:N,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ao}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Uo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,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:Uo},timeoutPolicy:{...N,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Xa,Ii]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:$o,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ta}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Xo,daemon:{route:`session`,refFrameEffect:qo,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ma}},{name:`install`,...ps},{name:`reinstall`,...ps},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`,servesPublicCommand:`install-from-source`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Pa},timeoutPolicy:ss,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...K},timeoutPolicy:N,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:Fa},timeoutPolicy:N,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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ii]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Vo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Va}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:27e4,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:qa}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:N,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:Wo},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Wa}},{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:ua,selectUses:ms}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ua,selectUses:ms}},{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:cr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:la}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Zo,daemon:{route:`snapshot`,refFrameEffect:Yo},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ja}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:ts,daemon:{route:`snapshot`,refFrameEffect:ns},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ea}},{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:N,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:Ho},platformExecution:{kind:`device-runtime`,uses:Fo},timeoutPolicy:N,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Qo,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ca,selectUses:hs}},{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:ds,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ei}},{name:`fill`,...os,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:fs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ai}},{name:`longpress`,...os,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...us,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Oi}},{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:ki}},{name:`press`,...os,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:ds,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Di}},{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:[qr]}},{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:ra}},{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:na}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,N),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[Jr]}},{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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Bi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Yr]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Qr]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Xr]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...J,timeoutPolicy:fr,platformExecution:{kind:`device-runtime`,uses:[Zr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,N),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Hi}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Vi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Kr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ga}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Gr]}},{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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ni]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[ri]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Pa},timeoutPolicy:N,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:as},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:So}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:as}],ys=new Set([`public`,`local-cli`]),bs=new Set(vs.filter(e=>ys.has(Os(e))).map(e=>e.name)),Q=vs.map(e=>{let t=Bo(e);return e.name===`record`&&Ro(t),{...e,mcpExposed:Es(e),platformExecution:t}});function xs(e){return Q.filter(t=>Os(t)===e).map(e=>[ks(e),e.name])}function Ss(){return Q.filter(e=>Ds(e)).map(e=>e.name).sort()}function Cs(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 ws(){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 Ts(e){return bs.has(e)}function Es(e){return e.mcpExposed??bs.has(e.name)}function Ds(e){return e.mcpExposed&&Ts(e.name)}function Os(e){return e.catalog.group}function ks(e){return e.catalog.key??e.name}const As=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),js=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),Ms=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Ns(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Ps(e){return Ns(e)!==void 0}function Fs(e){return Ns(e)===`settle-and-verify`}function Is(e){return e===void 0?N:As.get(e)??N}function Ls(e){return e===void 0?`require-owner`:js.get(e)??`require-owner`}function Rs(e){if(e!==void 0)return Ms.get(e)}function zs(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Bs(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Vs(e){return $.get(e)?.targetIdentityVerification}function Hs(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Us(){return[...new Set(Array.from(Ms.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Ws={apps:{appsFilter:`user-installed`}};function Gs(e,t){if(!e||!Ts(e))return!1;let n=Ws[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 Ks(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function qs(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Js=qs(Q),Ys=new Set([`batch`,`replay`]),Xs=[`command`,`positionals`,`input`,`flags`,`runtime`],Zs=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],Qs=`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.`,$s=new Set(Js);function ec(e){return $s.has(e)}function tc(e){return typeof e==`string`?e.trim().toLowerCase():``}function nc(e){let t=tc(e);return ec(t)?t:void 0}function rc(t,n,r=Qs){let i=nc(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 ic(t,n){if(Ys.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{li as $,yt as $n,a as $r,F as $t,po as A,on as An,ge as Ar,_i as At,Ya as B,Ht as Bn,se as Br,ji as Bt,Rs as C,bn as Cn,y as Cr,ti as Ct,Po as D,_n as Dn,Se as Dr,pi as Dt,Io as E,vn as En,he as Er,Xr as Et,$a as F,$t as Fn,pe as Fr,_a as Ft,La as G,Wt as Gn,re as Gr,Qr as Gt,Ka as H,Jt as Hn,ae as Hr,ai as Ht,to as I,dn as In,m as Ir,Ki as It,Ba as J,Bt as Jn,c as Jr,Or as Jt,Ra as K,Ut as Kn,d as Kr,qr as Kt,Ja as L,pn as Ln,p as Lr,fa as Lt,ro as M,cn as Mn,h as Mr,vi as Mt,lo as N,tn as Nn,de as Nr,xa as Nt,Mo as O,Sn as On,xe as Or,mi as Ot,oo as P,en as Pn,fe as Pr,Gi as Pt,ri as Q,xt as Qn,l as Qr,Cr as Qt,Ha as R,Yt as Rn,ue as Rr,ka as Rt,zs as S,xn as Sn,x as Sr,ei as St,Vs as T,yn as Tn,g as Tr,xi as Tt,Ia as U,Gt as Un,ce as Ur,wa as Ut,Ga as V,Rt as Vn,oe as Vr,oi as Vt,za as W,It as Wn,ie as Wr,R as Wt,Pa as X,Vt as Xn,f as Xr,wr as Xt,Na as Y,zt as Yn,te as Yr,Sr as Yt,Fa as Z,ut as Zn,u as Zr,jr as Zt,Ss as _,Nn as _n,De as _r,Kr as _t,ic as a,pr as an,at as ar,ni as at,Bs as b,jn as bn,b as br,Yr as bt,nc as c,Yn as cn,$e as cr,Ti as ct,Q as d,Gn as dn,tt as dr,bi as dt,Tr as en,St as er,ui as et,Cs as f,qn as fn,et as fr,di as ft,xs as g,Rn as gn,Ke as gr,da as gt,Us as h,In as hn,qe as hr,wi as ht,Js as i,ur as in,S as ir,Sa as it,go as j,sn as jn,ve as jr,gi as jt,yo as k,Zt as kn,Ce as kr,hi as kt,Ks as l,Bn as ln,Qe as lr,Ci as lt,Fs as m,Xn as mn,We as mr,L as mt,Xs as n,P as nn,vt as nr,ci as nt,tc as o,Qn as on,st as or,Ur as ot,Ps as p,Kn as pn,rt as pr,fi as pt,qa as q,Ft as qn,ee as qr,Gr as qt,Zs as r,dr as rn,C as rr,ii as rt,rc as s,M as sn,it as sr,Jr as st,Qs as t,Er as tn,wt as tr,si as tt,Gs as u,Jn as un,nt as ur,z as ut,ws as v,Fn as vn,je as vr,Zr as vt,Is as w,Cn as wn,we as wr,$r as wt,Hs as x,Mn as xn,v as xr,Si as xt,Ls as y,Ln as yn,ke as yr,Ii as yt,Ua as z,O as zn,le as zr,pa as zt};
|
|
2
|
+
`],[`r`,`\r`],[`t`,` `]]);function v(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Pe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Me(e))}}function y(e){try{return v(e)}catch{return null}}function b(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 je(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=Le(i).trim();return a?{key:r,value:a}:null}function x(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||!b(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&y(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 Me(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Fe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Ne)}}function Ne(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(!Ee.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(Ee.has(i)){let t=Be(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:Le(a)}}function Pe(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Ve(t,a)){i=Ie(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 Fe(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ve(t,e)){i=Ie(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 Ie(e,t){return e?e===t?null:e:t}function Le(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Re(t.slice(1,-1)):t}function Re(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=ze(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 ze(e){return Ae.get(e)??null}function Be(e){let t=Le(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ve(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function He(e){return a.includes(e)}const Ue=`is requires predicate: ${a.join(`|`)}`;function We(e){let t=e.toLowerCase();return He(t)?{ok:!0,predicate:t}:i(Ue,Ge)}const Ge=`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 Ke(e){if(He((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(He(n)&&y(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function qe(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=h(n),s=we(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):Ye(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 Je(t)}let ee=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:ee}}function Je(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Ye(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(c(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=Xe(e,t,n);return r?c(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function Xe(e,t,n){return t.findAncestor(e,e=>Ce(e,n)?e:null)}function Ze(e){let t=Ke(e),n=t[0]??``;return{predicate:n,split:x(t.slice(1),{preferTrailingValue:n===`text`})}}const Qe=`is requires a selector expression`,$e=`is text requires expected text value`;function et(e){let{predicate:t,split:n}=Ze([...e]),r=We(t);if(!r.ok)return r;if(!n)return i(Qe);let a=n.rest.join(` `).trim();return r.predicate===`text`&&!a?i($e):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 tt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:i(`get only supports text or attrs`)}function nt(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 rt(e){return e?{ok:!0,text:e}:i(`wait requires text`)}function it(e){return Array.from(new Set(e))}function at(e){return JSON.stringify(ot(e))}function ot(e){if(Array.isArray(e))return e.map(ot);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,ot(t[e])]))}function st(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 ct=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,lt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,ut=4096;function dt(e){return e.normalize(`NFC`)}function ft(e){if(e===void 0)return;let t=dt(e);return t.length>0?t:void 0}function pt(e){return dt(e)}function mt(e){if(e===void 0)return;let t=dt(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function S(e){return Buffer.byteLength(e,`utf8`)}function C(e,t){if(S(e)<=t)return e;let n=e.length;for(;n>0&&S(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 ht(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(gt),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=_t(e.scrollRegion)),e.rect&&(t.rect=vt(e.rect)),t.verification=e.verification,t}function gt(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function _t(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 vt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function yt(e){return JSON.stringify(ht(e))}function bt(e){return`# agent-device:target-v1 ${yt(e)}`}function xt(e){return JSON.stringify({source:ht(e.source),destination:ht(e.destination)})}function St(e){return`# agent-device:targets-v1 ${xt(e)}`}function Ct(e){let t=e.trim(),n=lt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:wt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function wt(t){if(S(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:w(JSON.stringify(r.source)),destination:w(JSON.stringify(r.destination))}}function Tt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=ct.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:w((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function w(t){if(S(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${ut}-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=T(r.role,`role`),a=Et(r.id,`id`),o=Dt(r.label,`label`),s=kt(r.ancestry),c=jt(r.sibling,`sibling`,0),l=jt(r.viewportOrder,`viewportOrder`,0),u=Mt(r.scrollRegion),d=Nt(r.rect),ee=Pt(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:ee}}function T(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 Ot(pt(t),n)}function Et(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=ft(t);return r===void 0?void 0:Ot(r,n)}function Dt(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=mt(t);return r===void 0?void 0:Ot(r,n)}function Ot(t,n){if(S(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function kt(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)=>At(e,t))}function At(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=T(r.role,`ancestry[${n}].role`),a=Dt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function jt(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 Mt(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=T(n.role,`scrollRegion.role`),i=Et(n.id,`id`),a=Dt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Nt(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:E(n.x,`rect.x`),y:E(n.y,`rect.y`),width:E(n.width,`rect.width`),height:E(n.height,`rect.height`)}}function E(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 Pt(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function Ft(e){let t=pt(m(e.type??``)),n=ft(e.identifier),r=mt(e.label);return{...n===void 0?{}:{id:C(n,256)},role:C(t,256),...r===void 0?{}:{label:C(r,256)}}}function It(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Lt(e,t){let n=0;for(let r of e)Ft(r).id===t&&(n+=1);return n}function Rt(e,t){if(e.id===void 0||Lt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function zt(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 Bt(e,t){return{documentOrder:e.index,sibling:zt(t,e)}}function Vt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Ht(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Ut(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Wt(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 Gt(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 Kt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function qt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function Jt(e,t){for(let[n,r]of e.entries()){let e=t[n];if(qt(r,e))return[`ancestry[${n}]: recorded=${Kt(r)} observed=${Kt(e)}`]}return[]}function Yt(e,t,n={}){let r=[],i=m(e.type??``),a=Xt(e,n.nodes),o=O(e.label),s=O(e.value),c=O(h(e)),l=n.action===`fill`;a&&r.push(`id=${D(a)}`),i&&o&&r.push(l?`role=${D(i)} label=${D(o)} editable=true`:`role=${D(i)} label=${D(o)}`),o&&r.push(l?`label=${D(o)} editable=true`:`label=${D(o)}`),s&&r.push(l?`value=${D(s)} editable=true`:`value=${D(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${D(c)} editable=true`:`text=${D(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${D(i)} editable=true`);let u=it(r);return u.length===0&&i&&u.push(l?`role=${D(i)} editable=true`:`role=${D(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function Xt(e,t){let n=O(e.identifier);if(!n||!t)return n;let r=Ft(e).id;return r===void 0?n:Lt(t,r)>1?null:n}function D(e){return JSON.stringify(e)}function O(e){return e&&e.trim()||null}const Zt=[`any`,`text`,`label`,`value`,`role`,`id`],Qt=[`text`,`label`,`value`,`role`,`id`];function $t(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function en(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function tn(e,t,n,r={}){let i=A(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=nn(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 nn(e,t,n){switch(t){case`role`:return rn(e.type,n);case`label`:return k(e.label,n);case`value`:return k(e.value,n);case`id`:return k(e.identifier,n);default:return Math.max(k(e.label,n),k(e.value,n),k(e.identifier,n))}}function k(e,t){let n=A(e??``);return n?n===t?2:+!!n.includes(t):0}function rn(e,t){let n=an(e??``);return n?n===t?2:+!!n.includes(t):0}function A(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}function an(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replaceAll(/XCUIElementType/gi,``).toLowerCase(),t):``}const on=`find requires a value`,sn=`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 cn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=dn([...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:on}}const ln=[`exists`,`list`,`click`,`focus`];function un(e){return ln.includes(e)}function dn(t){let n=`any`,r=0;Qt.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=$t(a[0]);if(un(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:fn(a[1])};if(o===`wait`){let e=mn(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:sn})}function fn(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 pn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:y(t)?t:null}function mn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function hn(e,t,n){return t.terms.every(t=>gn(e,t,n))}function gn(e,t,n){switch(t.key){case`id`:return j(e.identifier,String(t.value));case`role`:return j(m(e.type??``),String(t.value));case`label`:return j(e.label,String(t.value));case`value`:return j(e.value,String(t.value));case`text`:return j(h(e),String(t.value));case`appname`:return j(e.appName,String(t.value));case`windowtitle`:return j(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return we(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 j(e,t){return A(e??``)===A(t)}function _n(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=wn(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 vn(e,t,n){return _n(e,t,n).resolution}function yn(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:hn(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function bn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=On(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 xn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Sn(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 Cn(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 wn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=he(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||hn(l,t,n)&&(i+=1,a??=l,o.push(l),Tn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:En(o,s.best,c),candidates:o}}function Tn(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=kn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function En(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Dn(i,r,n).result>0)&&(r=i);return r?Dn(t,r,n).criterion:null}function Dn(e,t,n){let r=n(e);return r===n(t)?kn(e,t):{result:r?1:-1,criterion:`visible`}}function On(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||hn(a,t,n)&&(i+=1);return i}function kn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=An(e),a=An(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function An(e){return e.rect?e.rect.width*e.rect.height:1/0}const jn={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 Mn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Nn(e,t){let n=e===`is`?Ze([...t]).split:x([...t]);return n?y(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Pn(e){return{platform:e.platform,...Mn({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function Fn(e,t,n){let r=y(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=_n(t,r,Pn(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 In(e,t,n={}){return Yt(e,t,n)}function Ln(e,t,n){let r=y(e);if(!r)return;let i=vn(t,r,Pn(n));if(i)return{node:i.node,basis:zn(i.selector)}}function Rn(e){if(!e)return;let t=y(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 zn(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 Bn(e,t){let n=y(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Vn(n.selectors,r,i):Hn(n.selectors[0],r,new Set(t.booleanKeys),i)}function Vn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Un(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 Hn(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Un(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Wn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Un(e,t,n){return t.has(e)||n[e]!==void 0}function Wn(e,t,n){return t.has(e.key)&&typeof e.value===n}function Gn(e){let t=y(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 Kn(e,t){if(!t)return!1;let n=y(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 qn(e,t){return y(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function Jn(e){return v(e).selectors.map(e=>e.raw)}function Yn(e){return y(e)!==null}function Xn(e){v(e)}function M(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const Zn=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function Qn(e){let t=e[0];if(t===void 0)return null;let n=M(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=M(e.at(-1));return t===`text`?$n(e,r):t===`stable`?er(e):t===`absent`?tr(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:rr(e,r)}function $n(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function er(e){let t=e.slice(1),n=t.length>1?M(t[1]):null;return{kind:`stable`,quietMs:t.length>0?M(t[0]):null,timeoutMs:n}}function tr(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=x(n);return n.length>0&&r?.rest.length===0&&Yn(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:nr(n)}}function nr(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 rr(e,t){let n=t===null?e.slice():e.slice(0,-1),r=x(n);return r&&r.rest.length===0&&Yn(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:ir(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function ir(e,t){for(let t of e){let n=je(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:ar(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:or(t,e)}:e.some(e=>b(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:sr(e)}:null}function ar(e,t){let n=t.join(` `),r=ke(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${De.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function or(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 sr(e){let t=e.join(` `),n=e.filter(e=>!b(e)),r=e.filter(e=>b(e));if(n.length>0){let e=n[0],i=Zn.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 (${De.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 cr(e){let t=Qn(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const lr=3e4,ur=24e4,dr=3e5,N={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},fr={budget:{source:`none`},envelopeMs:255e3,onTimeout:`reset-daemon`};function pr(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return(hr(n,t.positionals??[])??gr(n,t.flags)??n.envelopeMs)+mr(e,t.flags)}function mr(e,t){if(e.targetReadiness!==`budgeted`)return 0;let n=t?.readinessTimeoutMs;return typeof n!=`number`||!Number.isInteger(n)||n<=0?0:Math.min(n,2e3)}function hr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:yr(e,n)}function gr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?vr(e,e.budget,t):e.budget.envelope===`margin`?_r(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function _r(e,t){let n=typeof t?.timeoutMs==`number`?yr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?br({...e,envelopeMs:n},t.waitMs):n}function vr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?br(e,r):e.envelopeMs}function yr(e,t){return Math.max(e.envelopeMs,t+lr)}function br(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+lr)}const xr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function Sr(e){if(e!==void 0)return xr[e]}function P(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 Cr(e){if(!n(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function wr(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 Tr(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 F(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 Er(e,t){return F(e)===F(t)}function Dr(e,t){return e.available?t():{}}function Or(e){if(!I(e.requesterId)||!I(e.identityIncarnationId)||!Ar(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 kr(e){let t=jr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!I(n)||!I(r)||!Ar(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return Or(i).token===e.token?i:null}function Ar(e){return Number.isInteger(e)&&e>=0}function I(e){return typeof e==`string`&&e.trim().length>0}function jr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Mr(e,t){let n={},r={};for(let i of t.required){let t=Nr(e.facts.operations,i);if(n[i]=t,!t.available)throw Rr(i,t);r[i]=Ir(e.operations,i)}for(let i of t.preferred){let t=Nr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Ir(e.operations,i))}for(let i of t.conditional??[]){let t=Nr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Ir(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function Nr(e,t){let n=e[t];if(!Pr(n))throw P(`Runtime owner omitted the ${t} fact`);let r=Fr(n);if(r)return r;throw P(`Runtime owner returned an invalid ${t} fact`)}function Pr(e){return typeof e==`object`&&!!e&&`available`in e}function Fr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Lr(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 Ir(e,t){let n=e[t];if(typeof n!=`function`)throw P(`Runtime owner advertised ${t} without an implementation`);return n}function Lr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-device-scope`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Rr(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function zr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function Br(){return e=>{let t=Vr(e.required,`required`),n=Vr(e.preferred??[],`preferred`),r=Vr(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 Vr(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=Br(),Hr=L({required:[`bootTarget`]}),Ur=L({required:[`bootTargetHeadless`]}),Wr=L({required:[`ensureReady`,`listApps`]}),Gr=L({required:[`captureSnapshot`]}),Kr=L({required:[`setViewport`]}),qr=L({required:[`focusPoint`]}),Jr=L({required:[`typeText`]}),Yr=L({required:[`back`]}),Xr=L({required:[`home`]}),Zr=L({required:[`setOrientation`]}),Qr=L({required:[`setFoldPose`]}),$r=L({required:[`tvRemote`]}),ei=L({required:[`keyboardStatus`]}),ti=L({required:[`keyboardDismiss`]}),ni=L({required:[`keyboardEnter`]}),ri=L({required:[`appSwitcher`]}),ii=L({required:[`actionButton`]}),ai=L({required:[`triggerAppEvent`]}),oi=L({required:[`setSetting`]}),si=L({required:[`readSetting`]}),ci=L({required:[`readAlert`]}),li=L({required:[`awaitAlert`]}),ui=L({required:[`acceptAlert`]}),di=L({required:[`dismissAlert`]}),fi=L({required:[`readClipboard`]}),pi=L({required:[`writeClipboard`]}),mi=L({required:[`perfFrames`]}),hi=L({required:[`perfMemorySample`]}),gi=L({required:[`perfMemorySnapshot`]}),_i=L({required:[`perfNativeCaptureStart`]}),vi=L({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),yi=L({required:[`perfProfileReport`]}),bi=Object.freeze([mi,hi,gi,_i,vi,yi]),R=L({required:[`tapPoint`]}),z=L({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),xi=L({required:[`longPressPoint`]}),Si=L({required:[`captureSnapshot`,`longPressPoint`]}),Ci=L({required:[`hoverPoint`]}),wi=L({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),Ti=L({required:[`fillPoint`]}),Ei=L({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),Di=Object.freeze([R,z]),Oi=Di,ki=Object.freeze([xi,Si]),Ai=Object.freeze([Ci,wi]),ji=Object.freeze([Ti,Ei]);function Mi(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:z}:{kind:`tap-point`,use:R};case`fill`:return t?{kind:`captured-fill`,use:Ei}:{kind:`fill-point`,use:Ti};case`longpress`:return t?{kind:`captured-long-press`,use:Si}:{kind:`long-press-point`,use:xi};case`hover`:return t?{kind:`captured-hover`,use:wi}:{kind:`hover-point`,use:Ci}}}const Ni=L({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Pi=L({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Fi=L({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ii=L({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Li=L({required:[`gestureViewport`]}),Ri=L({required:[`scrollDirection`],conditional:[`captureSnapshot`]}),zi=L({required:[`scrollDirection`,`captureSnapshot`]}),Bi=Object.freeze({plan:Ni,"directional-fling":Pi,"multi-touch":Fi,"target-authored-drag":Ii}),Vi=Object.freeze([Ni,Pi,Fi,Ii]),Hi=Object.freeze([Ni]),Ui=Object.freeze([Ri,zi]);function Wi(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function Gi(e){return e.intent===`drag`?`target-authored-drag`:Wi(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function Ki(e){let t=Gi(e);switch(t){case`plan`:return B(t);case`directional-fling`:return B(t);case`multi-touch`:return B(t);case`target-authored-drag`:return B(t)}}function B(e){let t=Bi[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function qi(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Ri}):Object.freeze({kind:`edge`,edge:e.edge,use:zi}):Object.freeze({kind:`until`,until:e.until,use:zi})}const Ji=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),Yi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),Xi=L({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),Zi=L({required:[`captureSnapshot`]}),Qi=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),$i=L({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),ea=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),ta=L({required:[`captureSnapshot`],conditional:[`findText`]}),na=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),ra=Object.freeze([Zi,Qi]),ia=Object.freeze([$i,ea]),aa=L({required:[`captureSnapshot`,`focusPoint`]}),oa=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),sa=L({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),ca=L({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),la=Object.freeze([$i,ea,Zi,Qi,aa,oa,sa,ca]),ua=Object.freeze([ta,na]),da=Object.freeze([Gr,Ji,Yi,Xi]),V=Object.freeze({"capture-only":ra,"element-text":ia,"wait-observation":ua,"find-focus":Object.freeze([aa,oa]),"find-type":Object.freeze([sa,ca])});function fa(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function pa(e){switch(e.intent){case`capture-only`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`element-text`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`wait-observation`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-focus`:return H(e.hasActiveApp,e.intent,V[e.intent]);case`find-type`:return H(e.hasActiveApp,e.intent,V[e.intent])}}function H(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 ma(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:Ji}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:Xi}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Gr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:Yi})}const ha=L({required:[`captureScreenshot`]}),ga=L({required:[`captureScreenshot`,`captureSnapshot`]}),_a=Object.freeze([ha,ga]);function va(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:ga}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:ga}):Object.freeze({kind:`capture`,use:ha})}const ya=Object.freeze([Hr,Ur]),ba=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Hr}),xa=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Ur});function Sa(e){return e.headless?xa:ba}const Ca=L({required:[`ensureReady`,`appState`]}),wa=Object.freeze([Ca]),Ta=L({required:[`shutdownTarget`]}),Ea=Object.freeze([fi,pi]),Da=Object.freeze([oi,si]),Oa=[`text-size`],ka=Object.freeze({kind:`write`,use:oi});function Aa(e){let t=ja(e?.[0]);return e?.length!==1||t===void 0?ka:Oa.includes(t)?Object.freeze({kind:`read`,setting:t,use:si}):ka}function ja(e){let t=e?.trim().toLowerCase();return Oa.find(e=>e===t)}const Ma=Object.freeze([ci,li,ui,di]),Na=Object.freeze([ei,ti,ni]),Pa=L({required:[`deployApp`]}),Fa=L({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),Ia=L({required:[`ensureReady`,`sendPushNotification`]}),La=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Ra=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),za=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Ba=L({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Va(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Ba}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Ra}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:za}):Object.freeze({kind:`open`,use:La})}const Ha=Object.freeze([La,Ra,za,Ba]),Ua=L({required:[`closeApplication`,`finalizeApplicationClose`]}),Wa=L({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),Ga=Object.freeze([Ua,Wa]),Ka=L({required:[`finalizeApplicationClose`]}),qa=L({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Ja=L({required:[`prepareAppleRunner`]}),Ya=L({required:[`clearRuntimeHints`]}),Xa=L({required:[`configureProviderPortReverse`]}),Za=Object.freeze([Ya,Xa]),U=L({required:[`appLogInspect`]}),Qa=L({required:[`appLogInspect`,`appLogDoctor`]}),$a=L({required:[`appLogInspect`,`appLogStart`]}),eo=L({required:[],preferred:[`appLogInspect`]}),to=Object.freeze([U,Qa,$a]);function no(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:U});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:$a});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:U});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Qa});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:U});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:$a}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:U});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const ro=L({required:[`audioProbeStart`]}),io=L({required:[`audioProbeReattach`,`audioProbeCleanup`]}),ao=L({required:[`audioProbeQuery`]}),oo=Object.freeze([ro,io,ao]);function so(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:ao});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:ro});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const co=[`probe`],lo=[`start`,`status`,`stop`];function uo(t){let n=(t?.[0]??`probe`).toLowerCase();if(!co.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!lo.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${lo.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:fo(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:fo(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function fo(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 po=L({required:[`networkDump`]}),mo=L({required:[],preferred:[`networkDump`]}),ho=[`dump`,`log`],go=[`summary`,`headers`,`body`,`all`];function _o(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!vo(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!yo(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:po})}function vo(e){return ho.some(t=>t===e)}function yo(e){return go.some(t=>t===e)}function bo(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,xo(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=>So(t,e)));return Object.freeze({families:a,modules:o,get:e=>So(t,e)})}function xo(e){return Object.freeze({...e})}function So(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const Co=Object.freeze({kind:`device-inventory`});function wo(e){if(typeof e!=`object`||!e)throw jo();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&W(n,[`kind`]))&&!(t.kind===`host`&&W(n,[`kind`]))&&!(t.kind===`inventory`&&W(n,[`kind`,`use`])&&Eo(t.use))&&!(t.kind===`device-runtime`&&W(n,[`kind`,`use`])&&Do(t.use))&&!(t.kind===`device-runtime`&&(W(n,[`kind`,`uses`])||W(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&To(t.uses)))throw jo()}function To(e){if(!Array.isArray(e)||e.length===0||!e.every(Do))return!1;let t=e.map(zr);return new Set(t).size===t.length}function Eo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&W(Object.keys(t).sort(),[`kind`])}function Do(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[ko(t.required),ko(t.preferred),ko(t.conditional??[])];if(!Oo(n))return!1;let r=n.flat();return new Set(r).size===r.length&&W(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function Oo(e){return e.every(e=>e!==null&&Ao(e))}function ko(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Ao(e){return new Set(e).size===e.length}function W(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function jo(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const Mo=L({required:[`screenRecordingStart`]}),No=L({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Po=L({required:[]}),Fo=L({required:[],preferred:[`screenRecordingStart`]}),Io=Object.freeze([Mo,No]);function Lo(t){switch((t.action??``).toLowerCase()){case`start`:if(!Ro(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:Mo});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Po}):Object.freeze({kind:`stop-recovery`,use:No});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function Ro(e){return e===`app`||e===`device`||e===`system`}function zo(e){if(wo(e),e.kind!==`device-runtime`||!(`uses`in e))throw Bo();let t=e.uses.map(zr),n=Io.map(zr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw Bo()}function Bo(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Vo(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 wo(t),t}const G={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},K={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Ho=()=>!0,Uo=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Wo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Go=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,Ko=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},qo=new Set([`status`,`get`]),Jo=e=>is(e,qo,`status`),Yo=new Set([`get`,`wait`]),Xo=e=>is(e,Yo,`get`),Zo=e=>as(e,qo,`status`),Qo=e=>as(e,Yo,`get`),$o=e=>{try{return en(dn(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},es=e=>as(e,new Set([`read`]),``),ts=e=>Aa(e.positionals).kind===`read`,ns=e=>ts(e)?`observes-app`:`mutates-app`,rs=e=>ts(e)?`preserve`:`may-invalidate`;function is(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function as(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const q={kind:`none`},os={kind:`host`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0},ss={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...N,onTimeout:`preserve-daemon`},cs={...N,envelopeMs:18e4},ls={...N,onTimeout:`preserve-daemon`},us={...ls,envelopeMs:33e4},ds={...N,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},fs={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}}},ps={fields:{delayMs:{defaultValue:0}}};function X(e,t){return Sr(e)===void 0?t:ds}function Z(e){let t=Sr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const ms={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Pa},timeoutPolicy:cs,batchable:!0},hs=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>ma({customActions:t,hasActiveApp:e}).use)},gs=e=>{let t=vs(e);if(t===void 0||!_s(t))return la;let n=fa(t);return[!0,!1].map(e=>pa({hasActiveApp:e,intent:n}).use)};function _s(e){return en(e)||e===`focus`||e===`type`}function vs(e){if(e.positionals===void 0)return;let t=cn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const ys=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Ho},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:us,batchable:!1,platformExecution:q},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:ls,batchable:!1,platformExecution:q},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:ls,batchable:!1,platformExecution:q},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...G},timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...K},timeoutPolicy:N,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:N,batchable:!1,platformExecution:q},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...K},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`inventory`,use:Co}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...K},timeoutPolicy:N,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:Ho,...K},timeoutPolicy:N,batchable:!0,platformExecution:os},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:Ko},platformExecution:{kind:`device-runtime`,uses:[Wr]},timeoutPolicy:N,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:ya},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},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:Ta},timeoutPolicy:N,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:wa},timeoutPolicy:N,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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:bi}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:to},timeoutPolicy:N,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...K},timeoutPolicy:N,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:po},timeoutPolicy:N,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:oo}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Wo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,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:Wo},timeoutPolicy:{...N,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...Za,Li]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:es,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ea}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:Zo,daemon:{route:`session`,refFrameEffect:Jo,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Na}},{name:`install`,...ms},{name:`reinstall`,...ms},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`,servesPublicCommand:`install-from-source`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Fa},timeoutPolicy:cs,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...K},timeoutPolicy:N,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:Ia},timeoutPolicy:N,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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ai]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Ho,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ha}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:27e4,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Ja}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:N,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:Go},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ga}},{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:da,selectUses:hs}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:da,selectUses:hs}},{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:cr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ua}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:Qo,daemon:{route:`snapshot`,refFrameEffect:Xo},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ma}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:ns,daemon:{route:`snapshot`,refFrameEffect:rs},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Da}},{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:N,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:Uo},platformExecution:{kind:`device-runtime`,uses:Io},timeoutPolicy:N,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:q},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:$o,daemon:{route:`find`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:la,selectUses:gs}},{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`),targetReadiness:`budgeted`,responseDataTransform:fs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Di}},{name:`fill`,...ss,frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:ps,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ji}},{name:`longpress`,...ss,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...ds,envelopeMs:21e4},postActionObservation:Z(`longpress`),targetReadiness:`budgeted`,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ki}},{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:Ai}},{name:`press`,...ss,frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),targetReadiness:`budgeted`,responseDataTransform:fs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Oi}},{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:[Jr]}},{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:ia}},{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:ra}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`back`,N),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[Yr]}},{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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Vi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Xr]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[$r]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[Zr]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...J,timeoutPolicy:fr,platformExecution:{kind:`device-runtime`,uses:[Qr]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...J,timeoutPolicy:X(`scroll`,N),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Ui}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Hi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[qr]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:_a}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[Kr]}},{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:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ri]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...J,platformExecution:{kind:`device-runtime`,uses:[ii]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Fa},timeoutPolicy:N,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:os},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:q},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:Co}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:os}],bs=new Set([`public`,`local-cli`]),xs=new Set(ys.filter(e=>bs.has(ks(e))).map(e=>e.name)),Q=ys.map(e=>{let t=Vo(e);return e.name===`record`&&zo(t),{...e,mcpExposed:Ds(e),platformExecution:t}});function Ss(e){return Q.filter(t=>ks(t)===e).map(e=>[As(e),e.name])}function Cs(){return Q.filter(e=>Os(e)).map(e=>e.name).sort()}function ws(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 Ts(){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 Es(e){return xs.has(e)}function Ds(e){return e.mcpExposed??xs.has(e.name)}function Os(e){return e.mcpExposed&&Es(e.name)}function ks(e){return e.catalog.group}function As(e){return e.catalog.key??e.name}const js=new Map(Array.from($.values(),e=>[e.name,e.targetReadiness?{...e.timeoutPolicy,targetReadiness:e.targetReadiness}:e.timeoutPolicy])),Ms=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),Ns=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Ps(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Fs(e){return Ps(e)!==void 0}function Is(e){return e!==void 0&&$.get(e)?.targetReadiness===`budgeted`}function Ls(e){return Ps(e)===`settle-and-verify`}function Rs(e){return e===void 0?N:js.get(e)??N}function zs(e){return e===void 0?`require-owner`:Ms.get(e)??`require-owner`}function Bs(e){if(e!==void 0)return Ns.get(e)}function Vs(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Hs(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Us(e){return $.get(e)?.targetIdentityVerification}function Ws(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Gs(){return[...new Set(Array.from(Ns.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Ks={apps:{appsFilter:`user-installed`}};function qs(e,t){if(!e||!Es(e))return!1;let n=Ks[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 Js(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Ys(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Xs=Ys(Q),Zs=new Set([`batch`,`replay`]),Qs=[`command`,`positionals`,`input`,`flags`,`runtime`],$s=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],ec=`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.`,tc=new Set(Xs);function nc(e){return tc.has(e)}function rc(e){return typeof e==`string`?e.trim().toLowerCase():``}function ic(e){let t=rc(e);return nc(t)?t:void 0}function ac(t,n,r=ec){let i=ic(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 oc(t,n){if(Zs.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{ii as $,St as $n,l as $r,wr as $t,bo as A,Zt as An,Ce as Ar,gi as At,Wa as B,O as Bn,le as Br,ma as Bt,Vs as C,xn as Cn,x as Cr,ti as Ct,Lo as D,vn as Dn,he as Dr,Zr as Dt,Us as E,yn as En,g as Er,xi as Et,so as F,en as Fn,fe as Fr,Ki as Ft,Ba as G,It as Gn,ie as Gr,R as Gt,Ka as H,Rt as Hn,oe as Hr,si as Ht,eo as I,$t as In,pe as Ir,va as It,Ja as J,Ft as Jn,ee as Jr,Kr as Jt,Ra as K,Wt as Kn,re as Kr,$r as Kt,no as L,dn as Ln,m as Lr,qi as Lt,_o as M,sn as Mn,ve as Mr,_i as Mt,io as N,cn as Nn,h as Nr,yi as Nt,Fo as O,_n as On,Se as Or,mi as Ot,uo as P,tn as Pn,de as Pr,Sa as Pt,Ia as Q,ut as Qn,u as Qr,Mr as Qt,Ya as R,pn as Rn,p as Rr,pa as Rt,Ws as S,Mn as Sn,v as Sr,Ci as St,Rs as T,Cn as Tn,we as Tr,ei as Tt,qa as U,Jt as Un,ae as Ur,oi as Ut,Xa as V,Ht as Vn,se as Vr,Mi as Vt,La as W,Gt as Wn,ce as Wr,Ta as Wt,Pa as X,zt as Xn,te as Xr,Cr as Xt,Va as Y,Bt as Yn,c as Yr,kr as Yt,Fa as Z,Vt as Zn,f as Zr,Tr as Zt,Ss as _,Rn as _n,Ke as _r,fa as _t,oc as a,ur as an,S as ar,Ca as at,zs as b,Ln as bn,ke as br,Li as bt,ic as c,M as cn,it as cr,Yr as ct,Is as d,Jn as dn,nt as dr,Si as dt,a as ei,F as en,bt as er,ui as et,Q as f,Gn as fn,tt as fr,z as ft,Gs as g,In as gn,qe as gr,Ti as gt,Ls as h,Xn as hn,We as hr,L as ht,Xs as i,dr as in,C as ir,ai as it,mo as j,on as jn,ge as jr,vi as jt,No as k,Sn as kn,xe as kr,hi as kt,Js as l,Yn as ln,$e as lr,Ei as lt,Fs as m,Kn as mn,rt as mr,pi as mt,Qs as n,Dr as nn,Tt as nr,ci as nt,rc as o,pr as on,at as or,ri as ot,ws as p,qn as pn,et as pr,fi as pt,za as q,Ut as qn,d as qr,Jr as qt,$s as r,P as rn,yt as rr,li as rt,ac as s,Qn as sn,st as sr,Wr as st,ec as t,Er as tn,Ct as tr,di as tt,qs as u,Bn as un,Qe as ur,wi as ut,Cs as v,Nn as vn,De as vr,qr as vt,Bs as w,bn as wn,y as wr,ni as wt,Hs as x,jn as xn,b as xr,Xr as xt,Ts as y,Fn as yn,je as yr,Qr as yt,Ua as z,Yt as zn,ue as zr,Aa as zt};
|
|
@@ -21,6 +21,17 @@ type DiagnosticsRecordRef = {
|
|
|
21
21
|
session: string;
|
|
22
22
|
requestId: string;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Whether the operation a failed request asked for reached the device. `no`: it provably never
|
|
26
|
+
* did, so resending it is safe. `unknown`: it may have landed, so observe the device before
|
|
27
|
+
* resending. A failure without the field was classified by no producer. The producer rows live in
|
|
28
|
+
* `contracts/fixtures/dispatch-disclosure.json`.
|
|
29
|
+
*/
|
|
30
|
+
type DispatchDisclosure = 'no' | 'unknown';
|
|
31
|
+
/** The error details bag as it crosses the wire: free-form, with the typed keys a reader may rely on. */
|
|
32
|
+
type ErrorWireDetails = Record<string, unknown> & {
|
|
33
|
+
dispatched?: DispatchDisclosure;
|
|
34
|
+
};
|
|
24
35
|
type ErrorCause = {
|
|
25
36
|
message: string;
|
|
26
37
|
code?: string;
|
|
@@ -37,6 +48,8 @@ type ErrorCause = {
|
|
|
37
48
|
* rather than by hand.
|
|
38
49
|
* - `retriable` — typed retry signal hoisted to the wire error shape.
|
|
39
50
|
* - `reason` — machine-dispatchable sub-classification within a code.
|
|
51
|
+
* - `dispatched` — {@link DispatchDisclosure} set by the producer that proved it; kept in details on
|
|
52
|
+
* the wire and never defaulted.
|
|
40
53
|
*/
|
|
41
54
|
type AppErrorDetails = Record<string, unknown> & {
|
|
42
55
|
hint?: string;
|
|
@@ -51,6 +64,7 @@ type AppErrorDetails = Record<string, unknown> & {
|
|
|
51
64
|
stderr?: string;
|
|
52
65
|
exitCode?: number | null;
|
|
53
66
|
reason?: string;
|
|
67
|
+
dispatched?: DispatchDisclosure;
|
|
54
68
|
};
|
|
55
69
|
type NormalizedError = {
|
|
56
70
|
code: string;
|
|
@@ -81,7 +95,7 @@ type NormalizedError = {
|
|
|
81
95
|
*/
|
|
82
96
|
retriable?: boolean;
|
|
83
97
|
supportedOn?: string;
|
|
84
|
-
details?:
|
|
98
|
+
details?: ErrorWireDetails;
|
|
85
99
|
};
|
|
86
100
|
/**
|
|
87
101
|
* Error payload returned by the daemon transport. It is kept beside the local
|
|
@@ -104,7 +118,7 @@ type DaemonError = {
|
|
|
104
118
|
* being handed a path on a filesystem it cannot read.
|
|
105
119
|
*/
|
|
106
120
|
diagnosticsRecord?: DiagnosticsRecordRef;
|
|
107
|
-
details?:
|
|
121
|
+
details?: ErrorWireDetails;
|
|
108
122
|
/** Additive retry and platform-support signals; absent when not derivable. */
|
|
109
123
|
retriable?: boolean;
|
|
110
124
|
supportedOn?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";const t=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,n=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,r=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,i=/https?:\/\/[^\s"'<>]+/gi;function a(e){return s(e,new WeakSet)}function o(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.message==`string`&&t.message.length!==0)return a({message:t.message,...typeof t.code==`string`&&t.code.length>0?{code:t.code}:{}})}function s(e,n,r){if(e==null)return e;if(typeof e==`string`)return c(e,r);if(typeof e!=`object`)return e;if(n.has(e))return`[Circular]`;if(n.add(e),Array.isArray(e))return e.map(e=>s(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=s(a,n,r)}return i}function c(e,i){let a=e.trim();if(!a)return l(e);if(i&&t.test(i))return`[REDACTED]`;let o=u(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>f({key:t,separator:n,rawValue:r,offset:i,input:a})||d(r)?e:`${t}${n}[REDACTED]`),l(o)}function l(e){return e.length<=400?e:`${e.slice(0,386)}...<truncated>`}function u(e){return e.replace(i,e=>
|
|
2
|
-
`)){let e=t.trim();if(!e||re.some(t=>t.test(e)))continue;let n=e.replace(ie,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function N(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function P(e){if(!e||typeof e!=`object`)return;let{session:t,requestId:n}=e;if(typeof t==`string`&&typeof n==`string`&&t.length!==0&&n.length!==0)return{session:t,requestId:n}}function oe(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}const se=[`startupRuleMatched`,`startupHostDeadlineHit`];function ce(e){if(!e)return;let t={...e};for(let e of se)delete t[e];return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.logPathUnavailable,delete t.diagnosticsRecord,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const le={DEVICE_IN_USE:!0};function ue(e){return h.includes(e)}function F(e){return ue(e)?le[e]:void 0}function I(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}const L={interactiveOnly:`snapshotInteractiveOnly`,depth:`snapshotDepth`,scope:`snapshotScope`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,forceFull:`snapshotForceFull`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`},de=[`interactiveOnly`,`depth`,`scope`,`raw`,`customActions`,`forceFull`],fe=[`interactiveOnly`,`preferredBackend`,`depth`,`scope`,`raw`,`customActions`,`includeHiddenContentHints`],pe=[`depth`,`interactiveOnly`,`raw`,`scope`,`customActions`];function R(e,t){return Object.fromEntries(t.map(t=>[t,e?.[L[t]]]))}function me(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e?.[t];return n===void 0?[]:[[L[t],n]]}))}const z={application:`application`,navigationbar:`navigation-bar`,tabbar:`tab-bar`,button:`button`,imagebutton:`button`,link:`link`,cell:`cell`,statictext:`text`,checkedtextview:`text`,textbox:`text-field`,textfield:`text-field`,edittext:`text-field`,textarea:`text-view`,switch:`switch`,slider:`slider`,image:`image`,imageview:`image`,webview:`webview`,framelayout:`group`,linearlayout:`group`,relativelayout:`group`,constraintlayout:`group`,viewgroup:`group`,view:`group`,listview:`list`,recyclerview:`list`,collectionview:`collection`,searchfield:`search`,heading:`heading`,activityindicator:`activity-indicator`,progressindicator:`progress-indicator`,segmentedcontrol:`segmented-control`,group:`group`,window:`window`,checkbox:`checkbox`,radio:`radio`,menuitem:`menu-item`,toolbar:`toolbar`,scrollarea:`scroll-area`,scrollview:`scroll-area`,nestedscrollview:`scroll-area`,table:`table`};function he(e){return Object.prototype.hasOwnProperty.call(z,e)?z[e]:void 0}function B(e){let t=e,n=e.replaceAll(/XCUIElementType/gi,``).toLowerCase(),r=t.includes(`.`)&&(t.startsWith(`android.`)||t.startsWith(`androidx.`)||t.startsWith(`com.`));return n.includes(`.`)&&(n=n.replace(/^android\.widget\./,``).replace(/^android\.view\./,``).replace(/^android\.webkit\./,``).replace(/^androidx\./,``).replace(/^com\.google\.android\./,``).replace(/^com\.android\./,``),r&&n.includes(`.`)&&(n=n.slice(n.lastIndexOf(`.`)+1))),n===`textview`?r?`text`:`text-view`:he(n)||n||`element`}function ge(e){if(e===void 0||e.backend===void 0)return{};switch(e.backend){case`xctest`:return{backend:e.backend,producer:e.producer};case`android`:return{backend:e.backend,producer:e.producer};case`harmonyos-arkui`:return{backend:e.backend,producer:e.producer};case`macos-helper`:return{backend:e.backend,producer:e.producer};case`linux-atspi`:return{backend:e.backend,producer:e.producer};case`web`:return{backend:e.backend,producer:e.producer}}}function _e(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function ve(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}const ye=[`bundle_changed`,`stale_target`,`missing_after_wait`,`interaction_foreground_guard`];function be(e){return typeof e==`string`&&ye.includes(e)}const V=[`unknown`,`notRunning`,`runningBackgroundSuspended`,`runningBackground`,`runningForeground`];Object.freeze(V.filter(e=>e!==`runningForeground`));function xe(e){return typeof e==`string`&&V.includes(e)}function Se(e,t){return t.postGestureOutcome??=e.postGestureOutcome,t}function Ce(e){return e.map((e,t)=>({...e,ref:e.ref??`e${t+1}`,kind:B(e.type??`Element`)}))}const we=/^~s(\d+)$/,Te=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function H(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=we.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function Ee(e){let t=H(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function De(e,t){return e.find(e=>e.ref===t)??null}function Oe(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function ke(e){if(e)return R(e,pe)}function Ae(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const U=[`ios`,`android`,`harmonyos`];function je(e){return U.some(t=>t===e)}const W={ios:`ios-instance`,android:`android-instance`,harmonyos:`harmonyos-instance`};function Me(e){return e===void 0?void 0:W[e]}const Ne=new Map(Object.entries(W).flatMap(([e,t])=>t===void 0?[]:[[t,e]]));function Pe(e){return Ne.get(e)}const Fe=[`summary`,`headers`,`body`,`all`],Ie=[`digest`,`default`,`full`];function Le(e){return e!==void 0&&e!=="default"}function G(e,t,n,r){return{ok:!1,error:{code:e,message:t,...r?.hint?{hint:r.hint}:{},...r?.retriable===void 0?{}:{retriable:r.retriable},...n?{details:n}:{}}}}const K=`No active session. Run open first.`;function Re(){return G(`SESSION_NOT_FOUND`,K)}function q(e){return{parse(t){return e(t,`$`)}}}function J(e,t){throw Error(`${e}: ${t}`)}function Y(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&J(t,`Expected an object`),e}function X(e,t){return typeof e!=`string`&&J(t,`Expected a string`),e}function ze(e,t){return Number.isInteger(e)||J(t,`Expected an integer`),e}function Be(e,t){return Array.isArray(e)||J(t,`Expected an array`),e}function Z(e,t,n){let r=e[t];return r===void 0?void 0:X(r,`${n}.${t}`)}function Ve(e,t,n){let r=e[t];if(r!==void 0)return Be(r,`${n}.${t}`).map((e,r)=>X(e,`${n}.${t}[${String(r)}]`))}function He(e,t,n){let r=e[t];return r===void 0?void 0:ze(r,`${n}.${t}`)}function Q(e,t,n){let r=e[t];return r===void 0?void 0:Y(r,`${n}.${t}`)}function Ue(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&J(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const We=q((e,t)=>{let n=Y(e,t);return{platform:Ue(n,`platform`,U,t),metroHost:Z(n,`metroHost`,t),metroPort:He(n,`metroPort`,t),bundleUrl:Z(n,`bundleUrl`,t),launchUrl:Z(n,`launchUrl`,t)}});function Ge(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&J(`${t}.id`,`Expected a string, number, or null`),n}const $=q((e,t)=>{let n=Y(e,t);return{jsonrpc:Z(n,`jsonrpc`,t),id:Ge(n,t),method:Z(n,`method`,t),params:n.params}}),Ke=q((e,t)=>{let n=Y(e,t);return{token:Z(n,`token`,t),session:Z(n,`session`,t),command:Z(n,`command`,t),positionals:Ve(n,`positionals`,t),input:Q(n,`input`,t),flags:Q(n,`flags`,t),runtime:Q(n,`runtime`,t),meta:Q(n,`meta`,t)}});export{ge as A,T as B,xe as C,me as D,Ee as E,w as F,v as G,j as H,I,O as J,_ as K,D as L,ve as M,b as N,R as O,k as P,o as Q,m as R,Se as S,_e as T,M as U,E as V,P as W,g as X,x as Y,a as Z,Ce as _,We as a,De as b,je as c,Re as d,Pe as f,de as g,fe as h,Ke as i,H as j,ke as k,$ as l,Te as m,K as n,G as o,V as p,F as q,Ie as r,Le as s,Fe as t,Me as u,Oe as v,be as w,B as x,Ae as y,A as z};
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";const t=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,n=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,r=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,i=/https?:\/\/[^\s"'<>]+/gi;function a(e){return s(e,new WeakSet)}function o(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.message==`string`&&t.message.length!==0)return a({message:t.message,...typeof t.code==`string`&&t.code.length>0?{code:t.code}:{}})}function s(e,n,r){if(e==null)return e;if(typeof e==`string`)return c(e,r);if(typeof e!=`object`)return e;if(n.has(e))return`[Circular]`;if(n.add(e),Array.isArray(e))return e.map(e=>s(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=s(a,n,r)}return i}function c(e,i){let a=e.trim();if(!a)return l(e);if(i&&t.test(i))return`[REDACTED]`;let o=u(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>f({key:t,separator:n,rawValue:r,offset:i,input:a})||d(r)?e:`${t}${n}[REDACTED]`),l(o)}function l(e){return e.length<=400?e:`${e.slice(0,386)}...<truncated>`}function u(e){return e.replace(i,e=>ee(e)??e)}function d(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function f(e){if(e.key.toLowerCase()!==`token`||!e.separator.includes(`:`))return!1;try{return new URL(e.rawValue).pathname.replace(/\/+$/,``)===`/api-keys`&&/(?:^|\b)(?:service\/)?api\s+$/i.test(e.input.slice(0,e.offset))}catch{return!1}}function ee(e){try{let t=new URL(e);return t.search&&=`?REDACTED`,(t.username||t.password)&&(t.username=`REDACTED`,t.password=`REDACTED`),t.toString()}catch{return null}}var p=e({AppError:()=>y,KNOWN_APP_ERROR_CODES:()=>m,asAppError:()=>D,createRequestCanceledError:()=>C,defaultHintForCode:()=>P,detailsAfterDispatchedSteps:()=>I,discloseDispatch:()=>F,discloseDispatchAfterSteps:()=>L,discloseUnclassifiedDispatch:()=>R,errorMessage:()=>E,isAgentDeviceError:()=>O,isRequestCanceledDetails:()=>w,isRequestCanceledError:()=>T,normalizeAgentDeviceError:()=>k,normalizeError:()=>A,readDiagnosticsRecordRef:()=>M,readElementMatchCandidateRefs:()=>_,readErrorCandidateViews:()=>g,retriableForErrorCode:()=>N,summarizeCommandAttemptFailures:()=>ne,throwDaemonError:()=>b,toAppErrorCode:()=>h});const m=[`INVALID_ARGS`,`DEVICE_NOT_FOUND`,`DEVICE_IN_USE`,`TOOL_MISSING`,`APP_NOT_INSTALLED`,`UNSUPPORTED_PLATFORM`,`UNSUPPORTED_OPERATION`,`NOT_IMPLEMENTED`,`COMMAND_FAILED`,`SESSION_NOT_FOUND`,`UNAUTHORIZED`,`AMBIGUOUS_MATCH`,`REPLAY_DIVERGENCE`,`REPAIR_SESSION_EXPIRED`,`REPAIR_COMMIT_FAILED`,`UNKNOWN`];function h(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}function g(e){let t=v(e?.candidates),n=[];if(t.length>0){let r=typeof e?.matches==`number`?e.matches:t.length,i=typeof e?.refsGeneration==`number`?e.refsGeneration:void 0;n.push({kind:`element-match`,candidates:t,matches:r,...i===void 0?{}:{refsGeneration:i}})}let r=te(e?.devices);return r.length>0&&n.push({kind:`device`,devices:r}),n}function _(e){return v(e?.candidates).flatMap(e=>{let t=/^@(e\d+)(?:~s\d+)?(?:\s|$)/.exec(e);return t?.[1]?[t[1]]:[]})}function v(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function te(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}var y=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function b(e){throw new y(h(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,logPathUnavailable:e.logPathUnavailable,diagnosticsRecord:e.diagnosticsRecord,retriable:e.retriable,supportedOn:e.supportedOn},e.cause)}const x=`request_canceled`,S=`request canceled`;function C(e,t){return new y(`COMMAND_FAILED`,S,{hint:`The request was canceled intentionally (explicit cancel or client disconnect) — no retry is needed unless the cancellation was unintended.`,...e,reason:x},t)}function w(e){return e?.reason===x}function T(e){return!(e instanceof y)||e.code!==`COMMAND_FAILED`?!1:w(e.details)?!0:e.message===S}function E(e){return e instanceof Error?e.message:String(e)}function ne(e){return e.map(e=>({args:e.args.join(` `),exitCode:e.exitCode,stderr:e.stderr.slice(0,400)}))}function D(e,t=`UNKNOWN`){return e instanceof y?e:e instanceof Error?new y(t,e.message,void 0,e):new y(t,`Unknown error`,{err:e})}function O(e){return e instanceof y}function k(e,t={}){return A(e,t)}function A(e,t={}){let n=D(e),r=n.details?a(n.details):void 0,i=j(r,`diagnosticId`)??t.diagnosticId,s=j(r,`logPath`)??t.logPath,c=j(r,`logPathUnavailable`),l=M(r?.diagnosticsRecord)??t.diagnosticsRecord,u=j(r,`hint`)??P(n.code),d=ce(r,`retriable`)??N(n.code),f=j(r,`supportedOn`),ee=ue(r),p=ie(n.code,n.message,r),m=o(n.cause);return{code:n.code,message:p,...m===void 0?{}:{cause:m},hint:u,diagnosticId:i,logPath:s,...c===void 0?{}:{logPathUnavailable:c},...l===void 0?{}:{diagnosticsRecord:l},...d===void 0?{}:{retriable:d},...f===void 0?{}:{supportedOn:f},details:ee}}const re=/^\S+ exited with code -?\d+$/;function ie(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=se(typeof n?.stderr==`string`?n.stderr:``);return r?re.test(t)?r:t.includes(r)?t:`${t}: ${r}`:t}const ae=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i],oe=/^(?:(?:adb|xcrun|simctl):\s*)?(?:error:\s*)?/i;function se(e){for(let t of e.split(`
|
|
2
|
+
`)){let e=t.trim();if(!e||ae.some(t=>t.test(e)))continue;let n=e.replace(oe,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function j(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function M(e){if(!e||typeof e!=`object`)return;let{session:t,requestId:n}=e;if(typeof t==`string`&&typeof n==`string`&&t.length!==0&&n.length!==0)return{session:t,requestId:n}}function ce(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}const le=[`startupRuleMatched`,`startupHostDeadlineHit`];function ue(e){if(!e)return;let t={...e};for(let e of le)delete t[e];return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.logPathUnavailable,delete t.diagnosticsRecord,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const de={DEVICE_IN_USE:!0};function fe(e){return m.includes(e)}function N(e){return fe(e)?de[e]:void 0}function P(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}function F(e,t,n={}){return e.details={...e.details,...n,dispatched:t},e}function I(e,t){if(t===0)return e;let n=e?.dispatchedSteps;return{...e,dispatchedSteps:t+(typeof n==`number`?n:0),dispatched:`unknown`}}function L(e,t){return e instanceof y&&(e.details=I(e.details,t)),e}function R(e,t){return e.details?.dispatched===void 0?F(e,t):e}const z={interactiveOnly:`snapshotInteractiveOnly`,depth:`snapshotDepth`,scope:`snapshotScope`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,forceFull:`snapshotForceFull`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`},pe=[`interactiveOnly`,`depth`,`scope`,`raw`,`customActions`,`forceFull`],me=[`interactiveOnly`,`preferredBackend`,`depth`,`scope`,`raw`,`customActions`,`includeHiddenContentHints`],he=[`depth`,`interactiveOnly`,`raw`,`scope`,`customActions`];function B(e,t){return Object.fromEntries(t.map(t=>[t,e?.[z[t]]]))}function ge(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e?.[t];return n===void 0?[]:[[z[t],n]]}))}const V={application:`application`,navigationbar:`navigation-bar`,tabbar:`tab-bar`,button:`button`,imagebutton:`button`,link:`link`,cell:`cell`,statictext:`text`,checkedtextview:`text`,textbox:`text-field`,textfield:`text-field`,edittext:`text-field`,textarea:`text-view`,switch:`switch`,slider:`slider`,image:`image`,imageview:`image`,webview:`webview`,framelayout:`group`,linearlayout:`group`,relativelayout:`group`,constraintlayout:`group`,viewgroup:`group`,view:`group`,listview:`list`,recyclerview:`list`,collectionview:`collection`,searchfield:`search`,heading:`heading`,activityindicator:`activity-indicator`,progressindicator:`progress-indicator`,segmentedcontrol:`segmented-control`,group:`group`,window:`window`,checkbox:`checkbox`,radio:`radio`,menuitem:`menu-item`,toolbar:`toolbar`,scrollarea:`scroll-area`,scrollview:`scroll-area`,nestedscrollview:`scroll-area`,table:`table`};function _e(e){return Object.prototype.hasOwnProperty.call(V,e)?V[e]:void 0}function H(e){let t=e,n=e.replaceAll(/XCUIElementType/gi,``).toLowerCase(),r=t.includes(`.`)&&(t.startsWith(`android.`)||t.startsWith(`androidx.`)||t.startsWith(`com.`));return n.includes(`.`)&&(n=n.replace(/^android\.widget\./,``).replace(/^android\.view\./,``).replace(/^android\.webkit\./,``).replace(/^androidx\./,``).replace(/^com\.google\.android\./,``).replace(/^com\.android\./,``),r&&n.includes(`.`)&&(n=n.slice(n.lastIndexOf(`.`)+1))),n===`textview`?r?`text`:`text-view`:_e(n)||n||`element`}function ve(e){if(e===void 0||e.backend===void 0)return{};switch(e.backend){case`xctest`:return{backend:e.backend,producer:e.producer};case`android`:return{backend:e.backend,producer:e.producer};case`harmonyos-arkui`:return{backend:e.backend,producer:e.producer};case`macos-helper`:return{backend:e.backend,producer:e.producer};case`linux-atspi`:return{backend:e.backend,producer:e.producer};case`web`:return{backend:e.backend,producer:e.producer}}}function ye(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function be(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}const xe=[`bundle_changed`,`stale_target`,`missing_after_wait`,`interaction_foreground_guard`];function Se(e){return typeof e==`string`&&xe.includes(e)}const U=[`unknown`,`notRunning`,`runningBackgroundSuspended`,`runningBackground`,`runningForeground`];Object.freeze(U.filter(e=>e!==`runningForeground`));function Ce(e){return typeof e==`string`&&U.includes(e)}function we(e,t){return t.postGestureOutcome??=e.postGestureOutcome,t}function Te(e){return e.map((e,t)=>({...e,ref:e.ref??`e${t+1}`,kind:H(e.type??`Element`)}))}const Ee=/^~s(\d+)$/,De=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function W(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=Ee.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function Oe(e){let t=W(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function ke(e,t){return e.find(e=>e.ref===t)??null}function Ae(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function je(e){if(e)return B(e,he)}function Me(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const G=[`ios`,`android`,`harmonyos`];function Ne(e){return G.some(t=>t===e)}const K={ios:`ios-instance`,android:`android-instance`,harmonyos:`harmonyos-instance`};function Pe(e){return e===void 0?void 0:K[e]}const Fe=new Map(Object.entries(K).flatMap(([e,t])=>t===void 0?[]:[[t,e]]));function Ie(e){return Fe.get(e)}const Le=[`summary`,`headers`,`body`,`all`],Re=[`digest`,`default`,`full`];function ze(e){return e!==void 0&&e!=="default"}function q(e,t,n,r){return{ok:!1,error:{code:e,message:t,...r?.hint?{hint:r.hint}:{},...r?.retriable===void 0?{}:{retriable:r.retriable},...n?{details:n}:{}}}}const J=`No active session. Run open first.`;function Be(){return q(`SESSION_NOT_FOUND`,J)}function Y(e){return{parse(t){return e(t,`$`)}}}function X(e,t){throw Error(`${e}: ${t}`)}function Z(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&X(t,`Expected an object`),e}function Ve(e,t){return typeof e!=`string`&&X(t,`Expected a string`),e}function He(e,t){return Number.isInteger(e)||X(t,`Expected an integer`),e}function Ue(e,t){return Array.isArray(e)||X(t,`Expected an array`),e}function Q(e,t,n){let r=e[t];return r===void 0?void 0:Ve(r,`${n}.${t}`)}function We(e,t,n){let r=e[t];if(r!==void 0)return Ue(r,`${n}.${t}`).map((e,r)=>Ve(e,`${n}.${t}[${String(r)}]`))}function Ge(e,t,n){let r=e[t];return r===void 0?void 0:He(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:Z(r,`${n}.${t}`)}function Ke(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&X(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const qe=Y((e,t)=>{let n=Z(e,t);return{platform:Ke(n,`platform`,G,t),metroHost:Q(n,`metroHost`,t),metroPort:Ge(n,`metroPort`,t),bundleUrl:Q(n,`bundleUrl`,t),launchUrl:Q(n,`launchUrl`,t)}});function Je(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&X(`${t}.id`,`Expected a string, number, or null`),n}const Ye=Y((e,t)=>{let n=Z(e,t);return{jsonrpc:Q(n,`jsonrpc`,t),id:Je(n,t),method:Q(n,`method`,t),params:n.params}}),Xe=Y((e,t)=>{let n=Z(e,t);return{token:Q(n,`token`,t),session:Q(n,`session`,t),command:Q(n,`command`,t),positionals:We(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{b as $,ve as A,R as B,Ce as C,ge as D,Oe as E,C as F,T as G,p as H,P as I,M as J,k as K,I as L,be as M,y as N,B as O,D as P,ne as Q,F as R,we as S,ye as T,O as U,E as V,w as W,g as X,_ as Y,N as Z,Te as _,qe as a,ke as b,Ne as c,Be as d,h as et,Ie as f,pe as g,me as h,Xe as i,W as j,je as k,Ye as l,De as m,J as n,o as nt,q as o,U as p,A as q,Re as r,ze as s,Le as t,a as tt,Pe as u,Ae as v,Se as w,H as x,Me as y,L as z};
|
package/dist/src/sdk-finders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Pn as e}from"./sdk-batch.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
|
|
@@ -77,6 +77,14 @@ type ResolutionDisclosure = {
|
|
|
77
77
|
source: 'direct-ios';
|
|
78
78
|
kind: 'not-observed';
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* The wait a successful press/click/longpress spent before its target appeared. Reported only when
|
|
82
|
+
* more than one capture was needed, so its presence means the step would have failed without the wait.
|
|
83
|
+
*/
|
|
84
|
+
type ReadinessWaitEvidence = {
|
|
85
|
+
polls: number;
|
|
86
|
+
waitedMs: number;
|
|
87
|
+
};
|
|
80
88
|
/**
|
|
81
89
|
* A post-action capture that describes a DIFFERENT surface than the pre-action baseline (#2438): an
|
|
82
90
|
* in-place iOS system surface (a web sign-in or Apple Pay sheet, hosted out of the app's process)
|
|
@@ -215,6 +223,7 @@ type TouchResponseDataBase = {
|
|
|
215
223
|
evidence?: InteractionEvidence;
|
|
216
224
|
settle?: SettleObservation;
|
|
217
225
|
resolution?: ResolutionDisclosure;
|
|
226
|
+
readiness?: ReadinessWaitEvidence;
|
|
218
227
|
cost?: ResponseCost;
|
|
219
228
|
/** Direct iOS Maestro coordinate-fallback signals. */
|
|
220
229
|
maestroNonHittableCoordinateFallbackAllowed?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Tn as e}from"./sdk-batch.js";function t(t,n,r){return e(typeof t==`string`?t:t.raw,n,r)}export{t};
|
package/dist/src/selection.js
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{xn as t}from"./sdk-batch.js";var n=e({SELECTOR_PIPELINE_POLICIES:()=>i,readinessScheduleFor:()=>a});const r={defaultTimeoutMs:1e4,intervalMs:300},i={promotedTarget:{resolution:t.act,occlusion:`exclude-and-refuse`,offscreen:`refuse`,promotion:`hittable-ancestor`,poll:{maxTimeoutMs:2e3,intervalMs:200}},resolvedTarget:{resolution:t.act,occlusion:`exclude-and-refuse`,offscreen:`refuse`,promotion:`none`,poll:`none`},coveredDiagnosis:{resolution:t.actCoveredDiagnosis,occlusion:`refuse`,offscreen:`ignore`,promotion:`none`,poll:`none`},readText:{resolution:t.readText,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:`none`},readUnique:{resolution:t.readUnique,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:`none`},readAny:{resolution:t.readAny,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:`none`},findWait:{resolution:t.readAny,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:r},wait:{resolution:t.wait,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:r},readList:{resolution:t.readList,occlusion:`ignore`},findAct:{resolution:t.findAct,occlusion:`refuse`,offscreen:`ignore`,promotion:`hittable-ancestor-below-root`,poll:`none`},cropTarget:{resolution:t.cropTarget,occlusion:`ignore`,offscreen:`ignore`,promotion:`none`,poll:`none`}};function a(e,t){if(e!==`none`&&!(t===void 0||!Number.isInteger(t))&&!(t<=0))return{intervalMs:e.intervalMs,budgetMs:Math.min(t,e.maxTimeoutMs),budgetFrom:`first-capture`}}export{a as n,n as r,i as t};
|