agent-device 0.20.7 → 0.20.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -31
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.7.apk → agent-device-android-ime-helper-0.20.9.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.9.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.7.manifest.json → agent-device-android-ime-helper-0.20.9.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.7.apk → agent-device-android-snapshot-helper-0.20.9.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.9.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.7.manifest.json → agent-device-android-snapshot-helper-0.20.9.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +3 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +13 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +4 -112
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +5 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +9 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +90 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +4 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +46 -10
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/android-adb.d.ts +5 -5
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-lifecycle.js +6 -7
- package/dist/src/app-lifecycle2.js +2 -2
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state.js +2 -0
- package/dist/src/appearance.js +1 -0
- package/dist/src/apps.js +5 -5
- package/dist/src/artifacts.d.ts +1 -1
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -0
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/bounds.js +1 -0
- package/dist/src/byte-limit-stream.js +1 -0
- package/dist/src/cancel.js +1 -0
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +25 -20
- package/dist/src/cli.js +6 -6
- package/dist/src/client-metro.js +1 -1
- package/dist/src/command-catalog.js +1 -0
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-surface.js +1 -1
- package/dist/src/config.js +1 -0
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +3 -3
- package/dist/src/contracts.js +1 -1
- package/dist/src/debug-symbols.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-input-state.js +1 -1
- package/dist/src/device-ready.js +1 -0
- package/dist/src/device2.js +2 -2
- package/dist/src/dispatch.js +1 -0
- package/dist/src/entities.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/generic.js +1 -1
- package/dist/src/handler-utils.js +1 -0
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/hdc.js +1 -0
- package/dist/src/helper-package-install.js +1 -0
- package/dist/src/helper.js +2 -2
- package/dist/src/host-process.js +3 -2
- package/dist/src/ime-lifecycle.js +2 -9
- package/dist/src/ime-recovery-marker.js +1 -0
- package/dist/src/index.d.ts +35 -26
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +3 -3
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/input-actions3.js +1 -1
- package/dist/src/install-artifact.js +1 -1
- package/dist/src/install-artifact2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-common.js +1 -0
- package/dist/src/interaction-runtime.js +1 -1
- package/dist/src/interaction-snapshot.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -0
- package/dist/src/interactor.js +2 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -0
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +4 -29
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/inventory.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/keyed-lock.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +3 -1
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/location-coordinates.js +1 -0
- package/dist/src/logcat.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/observability.js +1 -0
- package/dist/src/output-path.js +1 -0
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/perf.js +4 -0
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -0
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +2 -0
- package/dist/src/platform-runtime-screen-recording-android-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-apple-transport.js +1 -0
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-output-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-web-host.js +1 -0
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -0
- package/dist/src/plist.js +1 -1
- package/dist/src/png-resize.js +1 -0
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/prepare-kind.js +13 -13
- package/dist/src/process-lock.js +1 -1
- package/dist/src/project-runtime.js +1 -0
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/provider.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 -0
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-export-quality.js +1 -0
- package/dist/src/recording-telemetry.js +1 -0
- package/dist/src/registry.js +29 -26
- package/dist/src/replay.js +2 -2
- package/dist/src/reporting.js +3 -3
- package/dist/src/rolldown-runtime.js +1 -0
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runtime-transport.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +4 -3
- package/dist/src/runtime3.js +1 -3
- package/dist/src/runtime4.js +3 -1
- 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 -0
- package/dist/src/runtime9.js +1 -0
- package/dist/src/scoped-provider.js +1 -0
- package/dist/src/screenshot-density.js +1 -0
- package/dist/src/screenshot-geometry.js +1 -0
- package/dist/src/screenshot-result.js +4 -4
- package/dist/src/screenshot.js +1 -1
- package/dist/src/sdk-android-adb.d.ts +20 -2
- package/dist/src/sdk-android-adb.js +4 -4
- package/dist/src/sdk-batch-runner.js +3 -3
- package/dist/src/sdk-contracts.d.ts +3 -3
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.js +1 -1
- package/dist/src/sdk-selectors.d.ts +24 -20
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/sdk.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session.js +1 -30
- package/dist/src/session2.js +28 -0
- package/dist/src/setting-state.js +1 -1
- package/dist/src/shared.js +1 -1
- package/dist/src/simctl.js +1 -0
- package/dist/src/simulator-state.js +1 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-session.js +1 -1
- package/dist/src/snapshot.js +8 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -0
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +1 -2
- package/dist/src/src3.js +2 -1
- package/dist/src/string-enum.js +1 -0
- package/dist/src/tool-provider.js +3 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/verdict.js +1 -0
- package/dist/src/verified-file.js +1 -0
- package/dist/src/version.js +1 -1
- package/dist/src/video.js +23 -0
- package/package.json +8 -6
- package/server.json +3 -3
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.7.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.7.apk.sha256 +0 -1
- package/dist/src/context.js +0 -1
- package/dist/src/interaction-touch-reference-frame.js +0 -1
- package/dist/src/notifications.js +0 -1
- package/dist/src/platform-runtime-toolchain-host.js +0 -1
- package/dist/src/runner-provider.js +0 -1
- package/dist/src/text-surface.js +0 -1
- package/dist/src/tool-provider3.js +0 -1
- package/skills/agent-device/SKILL.md +0 -20
- package/skills/dogfood/SKILL.md +0 -27
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{_ as e,a as t,i as n,u as r,v as i}from"./sdk-contracts.js";import{
|
|
2
|
-
`).map(e=>e.trim()).filter(e=>e.length>0)}function
|
|
3
|
-
`],[`r`,`\r`],[`t`,` `]]);function x(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Ze(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Ye(e))}}function S(e){try{return x(e)}catch{return null}}function Ke(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 b.has(e)}return b.has(t.toLowerCase())}function qe(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||b.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=et(i).trim();return a?{key:r,value:a}:null}function Je(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||!Ke(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&S(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 Ye(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Qe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Xe)}}function Xe(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(!Ve.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(!b.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(Ve.has(i)){let t=rt(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:et(a)}}function Ze(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!it(t,a)){i=$e(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 Qe(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!it(t,e)){i=$e(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 $e(e,t){return e?e===t?null:e:t}function et(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?tt(t.slice(1,-1)):t}function tt(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=nt(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 nt(e){return Ge.get(e)??null}function rt(e){let t=et(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function it(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}const at=[`any`,`text`,`label`,`value`,`role`,`id`],ot=[`text`,`label`,`value`,`role`,`id`];function st(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function ct(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function lt(e,t,n,r={}){let i=w(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=ut(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 ut(e,t,n){switch(t){case`role`:return dt(e.type,n);case`label`:return C(e.label,n);case`value`:return C(e.value,n);case`id`:return C(e.identifier,n);default:return Math.max(C(e.label,n),C(e.value,n),C(e.identifier,n))}}function C(e,t){let n=w(e??``);return n?n===t?2:+!!n.includes(t):0}function dt(e,t){let n=ft(e??``);return n?n===t?2:+!!n.includes(t):0}function w(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function ft(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const pt=`find requires a value`,mt=`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 ht(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=vt([...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:pt}}const gt=[`exists`,`list`,`click`,`focus`];function _t(e){return gt.includes(e)}function vt(t){let n=`any`,r=0;ot.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=st(a[0]);if(_t(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:yt(a[1])};if(o===`wait`){let e=xt(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`)return{locator:n,query:i,action:o,value:a.slice(1).join(` `)};throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:mt})}function yt(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 bt(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:S(t)?t:null}function xt(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function T(e,t,n){return t.terms.every(t=>St(e,t,n))}function St(e,t,n){switch(t.key){case`id`:return E(e.identifier,String(t.value));case`role`:return E(v(e.type??``),String(t.value));case`label`:return E(e.label,String(t.value));case`value`:return E(e.value,String(t.value));case`text`:return E(ke(e),String(t.value));case`appname`:return E(e.appName,String(t.value));case`windowtitle`:return E(e.windowTitle,String(t.value));case`visible`:return y(e)===!!t.value;case`hidden`:return!y(e)==!!t.value;case`editable`:return ze(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 E(e,t){return w(e??``)===w(t)}function D(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=Dt(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function O(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:T(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function Ct(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=jt(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 wt=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Tt(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 Et(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 Dt(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=h(e),Pe(t,e,c));for(let c of e)r&&!c.rect||T(c,t,n)&&(i+=1,a??=c,o.push(c),Ot(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:kt(o,s.best,l),candidates:o}}function Ot(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=Mt(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function kt(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||At(i,r,n).result>0)&&(r=i);return r?At(t,r,n).criterion:null}function At(e,t,n){let r=n(e);return r===n(t)?Mt(e,t):{result:r?1:-1,criterion:`visible`}}function jt(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||T(a,t,n)&&(i+=1);return i}function Mt(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Nt(e),a=Nt(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Nt(e){return e.rect?e.rect.width*e.rect.height:1/0}function Pt(e,t,n,r){let i={...r,requireRect:n.requireRect};if(n.ambiguity===`reject-candidates`){let n=O(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:n.matchedNodes.length>1?{kind:`ambiguous`,selector:n.selector.raw,selectorIndex:n.selectorIndex,matchedNodes:n.matchedNodes}:Ft(n)}if(n.ambiguity===`first-match`){let n=O(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:Ft(n)}let a=D(e,t,{...i,requireUnique:!0,disambiguateAmbiguous:n.ambiguity===`disambiguate`});if(a)return{kind:`resolved`,resolution:a,matchedNodes:O(e,t,i)?.matchedNodes??[a.node]};let o=O(e,t,i);return!o||o.matchedNodes.length===0?{kind:`none`}:{kind:`ambiguous`,selector:o.selector.raw,selectorIndex:o.selectorIndex,matchedNodes:o.matchedNodes}}function Ft(e){let t=e.matchedNodes[0];return t?{kind:`resolved`,matchedNodes:e.matchedNodes,resolution:{node:t,selector:e.selector,selectorIndex:e.selectorIndex,matches:e.matchedNodes.length,diagnostics:[{selector:e.selector.raw,matches:e.matchedNodes.length}]}}:{kind:`none`}}function k(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function It(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function Lt(e){let t=e.toLowerCase();return It(t)?{ok:!0,predicate:t}:k(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,Rt)}const Rt=`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 zt(e){if(It((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(It(n)&&S(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function Bt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=ke(n),s=ze(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?y(n):Vt(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}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function Vt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(g(e.rect))return Ht(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=Ut(e,t,n);return r?g(r.rect)?Ht(r,t):n!==`android`&&r.hittable===!0:!1}function Ht(e,t){return Ne(e,t)}function Ut(e,t,n){return Se(t,e,h(t),e=>Re(e,n)?e:null)}function Wt(e){let t=zt(e),n=t[0]??``;return{predicate:n,split:Je(t.slice(1),{preferTrailingValue:n===`text`})}}const Gt=`is requires a selector expression`,Kt=`is text requires expected text value`;function qt(e){let{predicate:t,split:n}=Wt([...e]),r=Lt(t);if(!r.ok)return r;if(!n)return k(Gt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?k(Kt):r.predicate!==`text`&&n.rest.length>0?k(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function Jt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:k(`get only supports text or attrs`)}function Yt(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}:k(`get requires @ref or selector expression`)}function Xt(e){return e?{ok:!0,text:e}:k(`wait requires text`)}function Zt(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function Qt(t,n,r={}){let i=t[n];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);if(r.min!==void 0&&i<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&i>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return i}}const $t=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,en=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,tn=4096;function nn(e){return e.normalize(`NFC`)}function rn(e){if(e===void 0)return;let t=nn(e);return t.length>0?t:void 0}function an(e){return nn(e)}function on(e){if(e===void 0)return;let t=nn(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function A(e){return Buffer.byteLength(e,`utf8`)}function sn(e,t){if(A(e)<=t)return e;let n=e.length;for(;n>0&&A(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 cn(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(ln),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=un(e.scrollRegion)),e.rect&&(t.rect=dn(e.rect)),t.verification=e.verification,t}function ln(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function un(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 dn(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function fn(e){return JSON.stringify(cn(e))}function pn(e){return`# agent-device:target-v1 ${fn(e)}`}function mn(e){return JSON.stringify({source:cn(e.source),destination:cn(e.destination)})}function hn(e){return`# agent-device:targets-v1 ${mn(e)}`}function gn(e){let t=e.trim(),n=en.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:_n((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function _n(t){if(A(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:yn(JSON.stringify(r.source)),destination:yn(JSON.stringify(r.destination))}}function vn(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=$t.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:yn((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function yn(t){if(A(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${tn}-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=bn(r.role,`role`),a=xn(r.id,`id`),o=Sn(r.label,`label`),s=wn(r.ancestry),c=En(r.sibling,`sibling`,0),l=En(r.viewportOrder,`viewportOrder`,0),u=Dn(r.scrollRegion),d=On(r.rect),f=kn(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function bn(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 Cn(an(t),n)}function xn(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=rn(t);return r===void 0?void 0:Cn(r,n)}function Sn(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=on(t);return r===void 0?void 0:Cn(r,n)}function Cn(t,n){if(A(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function wn(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)=>Tn(e,t))}function Tn(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=bn(r.role,`ancestry[${n}].role`),a=Sn(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function En(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 Dn(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=bn(n.role,`scrollRegion.role`),i=xn(n.id,`id`),a=Sn(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function On(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:j(n.x,`rect.x`),y:j(n.y,`rect.y`),width:j(n.width,`rect.width`),height:j(n.height,`rect.height`)}}function j(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 kn(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function An(e){let t=an(v(e.type??``)),n=rn(e.identifier),r=on(e.label);return{...n===void 0?{}:{id:sn(n,256)},role:sn(t,256),...r===void 0?{}:{label:sn(r,256)}}}function jn(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Mn(e,t){let n=0;for(let r of e)An(r).id===t&&(n+=1);return n}function Nn(e,t){if(e.id===void 0||Mn(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Pn(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 Fn(e,t){return{documentOrder:e.index,sibling:Pn(t,e)}}function In(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Ln(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Rn(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function zn(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 Bn(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 Vn(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Hn(e,t){return!t||t.role!==e.role?!0:e.label!==void 0&&t.label!==e.label}function Un(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Hn(r,e))return[`ancestry[${n}]: recorded=${Vn(r)} observed=${Vn(e)}`]}return[]}function Wn(e,t,n={}){let r=[],i=v(e.type??``),a=Gn(e,n.nodes),o=N(e.label),s=N(e.value),c=N(ke(e)),l=n.action===`fill`;a&&r.push(`id=${M(a)}`),i&&o&&r.push(l?`role=${M(i)} label=${M(o)} editable=true`:`role=${M(i)} label=${M(o)}`),o&&r.push(l?`label=${M(o)} editable=true`:`label=${M(o)}`),s&&r.push(l?`value=${M(s)} editable=true`:`value=${M(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${M(c)} editable=true`:`text=${M(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${M(i)} editable=true`);let u=Kn(r);return u.length===0&&i&&u.push(l?`role=${M(i)} editable=true`:`role=${M(i)}`),u.length===0&&y(e)&&u.push(`visible=true`),u}function Gn(e,t){let n=N(e.identifier);if(!n||!t)return n;let r=An(e).id;return r===void 0?n:Mn(t,r)>1?null:n}function Kn(e){return Array.from(new Set(e))}function M(e){return JSON.stringify(e)}function N(e){return e&&e.trim()||null}function qn(e,t){let n=e===`is`?Wt([...t]).split:Je([...t]);return n?S(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Jn(e,t,n){let r=S(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let i=D(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i){let e=t.filter(e=>n.requireRect&&!e.rect?!1:T(e,i.selector,n.platform));return{kind:`resolved`,winner:i.node,matchedNodes:e,matchCount:e.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}}let a=O(t,r,{platform:n.platform,requireRect:n.requireRect})?.matchedNodes??[];return{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function Yn(e,t,n={}){return Wn(e,t,n)}function Xn(e,t,n){let r=S(e);if(!r)return;let i=D(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i)return{node:i.node,basis:Qn(i.selector)}}function Zn(e){if(!e)return;let t=S(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 Qn(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`}const $n={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}};function er(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function tr(e,t){let n=S(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys);return n.selectors.length>1?nr(n.selectors,r):rr(n.selectors[0],r,new Set(t.booleanKeys))}function nr(e,t){let n=e.map(e=>{let n=e.terms.length===1?e.terms[0]:void 0;return n&&t.has(n.key)&&typeof n.value==`string`?n.value:void 0}),r=n[0];return r!==void 0&&n.every(e=>e===r)?r:null}function rr(e,t,n){if(!e)return null;let r={},i=0;for(let a of e.terms){if(ir(a,t,`string`))i+=1;else if(!ir(a,n,`boolean`))return null;r[a.key]=a.value}return i<=1&&Object.keys(r).length>0?r:null}function ir(e,t,n){return t.has(e.key)&&typeof e.value===n}function ar(e){let t=S(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 or(e,t){if(!t)return!1;let n=S(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 sr(e){return x(e).selectors.map(e=>e.raw)}function cr(e){return S(e)!==null}function lr(e,t,n){let r=Ct(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function ur(e,t,n){let r=O(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function dr(e,t,n){let r=D(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function fr(e,t,n,r){let i=Pt(e,x(t),n,r);return i.kind===`resolved`?{...i,resolution:{...i.resolution,selector:i.resolution.selector.raw}}:i}function P(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function pr(e){let t=e[0];if(t===void 0)return null;let n=P(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=P(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?P(t[1]):null;return{kind:`stable`,quietMs:t.length>0?P(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=Je(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&cr(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function mr(e){let t=pr(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const hr=24e4,F={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},gr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,scroll:`settle`,back:`settle`};function _r(e){if(e!==void 0)return gr[e]}const I=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function vr(e){let t=L(e.packageName),n=(e.resourceId??``).toLowerCase(),r=L(e.activeInputMethodPackage);if(t&&r&&t===r)return{inputMethodOwned:!0,source:`active-input-method`};if(r&&n.startsWith(`${r}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(t&&I.has(t))return{inputMethodOwned:!0,source:`known-ime-package`};for(let e of I)if(n.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function yr(e,t,n){return vr({packageName:e,resourceId:t,activeInputMethodPackage:n}).inputMethodOwned}function br(e){return vr(e).inputMethodOwned}function xr(e){let t=L(e);return!!(t&&I.has(t))}function Sr(e){let t=(e??``).toLowerCase();for(let e of I)if(t.startsWith(`${e}:id/`))return!0;return!1}function Cr(e,t,n){return!e&&!t?`unknown`:yr(e,t,n)?`ime`:`app`}function wr(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=Tr(e.match(t)?.[1]);if(n)return n}}function Tr(e){let t=(e??``).trim();if(t)return L((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function L(e){return(e??``).trim().toLowerCase()||void 0}const Er=`com.android.systemui`;function Dr(e){let t=e??``;if(!t.startsWith(`com.android.systemui:id/`))return!1;let n=t.slice(`${Er}:id/`.length);return/(^|_)(status_bar|navigation_bar)(_|$)/.test(n)}function Or(e){return`systemChrome`in e&&e.systemChrome===!0}function kr(e){if(!Or(e))return e;let{systemChrome:t,...n}=e;return n}function Ar(e){return e.some(Or)?e.map(kr):e}const jr={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},Mr={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android and the iOS simulator only.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android and the iOS simulator only.`};function Nr(t,n){if(!l(t.platform))throw Pr(n,t.platform);let r=u(t);if(!((r===`ios`||r===`ipados`)&&t.kind===`simulator`))throw r===`ios`||r===`ipados`?new e(`UNSUPPORTED_OPERATION`,`gesture ${n} is not supported on physical iOS devices`,{hint:`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`}):Pr(n,jr[r],Mr[r])}function Pr(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function Fr(e){let t=e.state??`stopped`;return{audio:`probe`,state:t,active:t===`running`,heard:!1,source:e.source,backend:e.backend,durationMs:e.durationMs,elapsedMs:e.elapsedMs??0,bucketMs:e.bucketMs,sampleCount:0,mediaElementCount:e.mediaElementCount,sourceCount:e.sourceCount??0,rmsDbfs:[],peakDbfs:[],reason:e.reason,notes:e.notes}}function Ir(e,t){let n=Br(e),r=Lr(n),i=Rr(n.rmsDbfs),a=Rr(n.peakDbfs),o=[...zr(n.notes)??[],...t.notes??[]];return{audio:`probe`,state:r,active:r===`running`&&Vr(n.active,t.activeFallback??!0),heard:n.heard===!0,source:t.source,backend:Hr(n.backend)??t.backend,durationMs:R(n.durationMs,t.durationMs),elapsedMs:R(n.elapsedMs,t.elapsedMs),bucketMs:R(n.bucketMs,t.bucketMs),sampleCount:R(n.sampleCount,i.length),mediaElementCount:t.mediaElementCount===void 0?Ur(n.mediaElementCount):R(n.mediaElementCount,t.mediaElementCount),sourceCount:R(n.sourceCount,t.sourceCount??0),rmsDbfs:i,peakDbfs:a,startedAt:Hr(n.startedAt),stoppedAt:Hr(n.stoppedAt),reason:Hr(n.reason),notes:o.length>0?o:void 0}}function Lr(e){return e.state===`running`?`running`:`stopped`}function R(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Rr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)typeof n==`number`&&Number.isFinite(n)&&t.push(n);return t}function zr(e){if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}function Br(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Vr(e,t){return typeof e==`boolean`?e:t}function Hr(e){return typeof e==`string`?e:void 0}function Ur(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Wr(e){return process.platform===`darwin`&&(s(e)||a(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}function Gr(e){return e.platform===`web`||Wr(e)}function Kr(e){if(typeof e!=`object`||!e)throw ei();let t=e,n=Object.keys(t).sort();if(!(t.kind===`legacy`&&z(n,[`kind`]))&&!(t.kind===`inventory`&&z(n,[`kind`,`use`])&&Yr(t.use))&&!(t.kind===`device-runtime`&&z(n,[`kind`,`use`])&&Xr(t.use))&&!(t.kind===`device-runtime`&&z(n,[`kind`,`uses`])&&qr(t.uses)))throw ei()}function qr(e){if(!Array.isArray(e)||e.length===0||!e.every(Xr))return!1;let t=e.map(Jr);return new Set(t).size===t.length}function Jr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function Yr(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&z(Object.keys(t).sort(),[`kind`])}function Xr(e){if(typeof e!=`object`||!e)return!1;let t=e,n=Zr(t.required),r=Zr(t.preferred);return!n||!r||!Qr(n)||!Qr(r)||!$r(n,r)?!1:z(Object.keys(t).sort(),[`preferred`,`required`])}function Zr(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Qr(e){return new Set(e).size===e.length}function $r(e,t){let n=new Set(e);return t.every(e=>!n.has(e))}function z(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function ei(){return TypeError(`Command platform execution must declare exactly one of legacy, inventory, or device-runtime`)}var ti=class{#e=[];#t=`open`;get disposed(){return this.#t===`disposed`}defer(e){this.#n(),this.#e.push(e)}use(e){return this.defer(async()=>await e[Symbol.asyncDispose]()),e}async[Symbol.asyncDispose](){if(this.#t===`disposed`)return;if(this.#t===`disposing`)throw TypeError(`Async cleanup stack disposal is already in progress`);this.#t=`disposing`;let e=[];for(;this.#e.length>0;){let t=this.#e.pop();if(t)try{await t()}catch(t){e.push(t)}}if(this.#t=`disposed`,e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Multiple asynchronous cleanups failed`)}#n(){if(this.#t!==`open`)throw TypeError(`Cannot register cleanup after disposal has begun`)}},ni=class{#e;#t=`pending`;constructor(e){this.#e=e}get pending(){return this.#t===`pending`}transfer(){if(this.#t!==`pending`)throw TypeError(`Cannot transfer handle in ${this.#t} state`);return this.#t=`transferred`,this.#e}async[Symbol.asyncDispose](){this.#t===`pending`&&(this.#t=`disposed`,await this.#e[Symbol.asyncDispose]())}};function ri(){return e=>{let t=ii(e.required,`required`),n=ii(e.preferred??[],`preferred`),r=n.find(e=>t.includes(e));if(r!==void 0)throw TypeError(`Runtime operation cannot be both required and preferred: ${r}`);return Object.freeze({required:t,preferred:n})}}function ii(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}function ai(e){if(!o(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function oi(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 si(e){return e.kind===`local-family`?`local:${e.family}`:`provider:${JSON.stringify([e.provider,e.instance])}`}function ci(e,t){return si(e)===si(t)}function li(e,t){let n={},r={};for(let i of t.required){let t=ui(e.facts.operations,i);if(n[i]=t,!t.available)throw hi(i,t);r[i]=pi(e.operations,i)}for(let i of t.preferred){let t=ui(e.facts.operations,i);n[i]=t,t.available&&(r[i]=pi(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function ui(e,t){let n=e[t];if(!di(n))throw gi(`Runtime owner omitted the ${t} fact`);let r=fi(n);if(r)return r;throw gi(`Runtime owner returned an invalid ${t} fact`)}function di(e){return typeof e==`object`&&!!e&&`available`in e}function fi(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&mi(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 pi(e,t){let n=e[t];if(typeof n!=`function`)throw gi(`Runtime owner advertised ${t} without an implementation`);return n}function mi(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function hi(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function gi(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 _i(e){return e.status===`cleaned`||e.status===`already-missing`}const vi=`app-log`,yi=ri(),bi=yi({required:[`networkDump`]}),xi=yi({required:[],preferred:[`networkDump`]}),Si=[`dump`,`log`],Ci=[`summary`,`headers`,`body`,`all`];function wi(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!Ti(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!Ei(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:bi})}function Ti(e){return Si.some(t=>t===e)}function Ei(e){return Ci.some(t=>t===e)}const Di=ri(),B=Di({required:[`appLogInspect`]}),Oi=Di({required:[`appLogInspect`,`appLogDoctor`]}),ki=Di({required:[`appLogInspect`,`appLogStart`]}),Ai=Di({required:[],preferred:[`appLogInspect`]}),ji=Object.freeze([B,Oi,ki]);function Mi(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:B});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:ki});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:B});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Oi});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:B});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:ki}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:B});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}function Ni(e){let t=new Map;for(let n of e){if(!o(n.family))throw TypeError(`Unknown platform family registration: ${String(n.family)}`);if(t.has(n.family))throw TypeError(`Duplicate platform family registration: ${n.family}`);t.set(n.family,Pi(n))}let n=c.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let r=Object.freeze([...c]),i=Object.freeze(r.map(e=>Fi(t,e)));return Object.freeze({families:r,modules:i,get:e=>Fi(t,e)})}function Pi(e){return Object.freeze({...e})}function Fi(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const Ii=Object.freeze({kind:`device-inventory`}),Li={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},V={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Ri=()=>!0,zi=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Bi=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Vi=new Set([`status`,`get`]),Hi=e=>Ji(e,Vi,`status`),Ui=new Set([`get`,`wait`]),Wi=e=>Ji(e,Ui,`get`),Gi=e=>Yi(e,Vi,`status`),Ki=e=>Yi(e,Ui,`get`),qi=e=>{try{return ct(vt(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function Ji(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function Yi(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const H={simulator:!0,device:!0},U={emulator:!0,device:!0,unknown:!0},W={emulator:!0},G={device:!0},K={},q={apple:H,android:U,linux:G},Xi={...q,vega:W},Zi={apple:H,android:U,linux:K},Qi={apple:H,android:U,linux:K},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},Y={...F,onTimeout:`preserve-daemon`},$i={...F,envelopeMs:18e4},ea={...F,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},ta={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}}},na={fields:{delayMs:{defaultValue:0}}};function X(e,t){return _r(e)===void 0?t:ea}function Z(e){let t=_r(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const ra=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...V},timeoutPolicy:F,batchable:!1},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:F,batchable:!1},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...V},timeoutPolicy:F,batchable:!0,platformExecution:{kind:`inventory`,use:Ii}},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...V},timeoutPolicy:F,batchable:!0},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:Ri,...V},timeoutPolicy:F,batchable:!0},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},capability:Zi,timeoutPolicy:F,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:{simulator:!0},android:{emulator:!0},linux:K},timeoutPolicy:F,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:ji},timeoutPolicy:F,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...V},timeoutPolicy:F,batchable:!1},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:bi},timeoutPolicy:F,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:H,android:{emulator:!0},linux:K},timeoutPolicy:F,batchable:!0},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Bi,saveScriptFlagOwner:!0},timeoutPolicy:{...F,budget:{source:`flag`}},batchable:!1},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Bi},timeoutPolicy:{...F,envelopeMs:`unbounded`},batchable:!0},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:F,batchable:!1},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:Gi,daemon:{route:`session`,refFrameEffect:Hi,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Qi,timeoutPolicy:$i,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Qi,timeoutPolicy:$i,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:$i,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...V},timeoutPolicy:F,batchable:!1},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{simulator:!0},android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Ri,saveScriptFlagOwner:!0},dispatch:{},capability:Xi,timeoutPolicy:F,batchable:!0},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},capability:{apple:H,android:{},linux:K},timeoutPolicy:{budget:{source:`flag`},envelopeMs:hr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:F,batchable:!1},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0},dispatch:{},capability:Xi,timeoutPolicy:F,batchable:!0},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:q,timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:F,batchable:!0},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:mr}},batchable:!0},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:Ki,daemon:{route:`snapshot`,refFrameEffect:Wi},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:zi},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:F,batchable:!0},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:qi,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:q,timeoutPolicy:Y,batchable:!0},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:ta,batchable:!0},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:na,batchable:!0},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:{...ea,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:ta,batchable:!0},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:q,timeoutPolicy:X(`type`,Y),batchable:!0},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:X(`get`,Y),batchable:!0},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:F,batchable:!1},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:X(`is`,Y),batchable:!0},{name:`back`,catalog:{group:`public`},...J,capability:{...J.capability,vega:W},timeoutPolicy:X(`back`,F),postActionObservation:Z(`back`)},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:q,timeoutPolicy:F,batchable:!0},{name:`home`,catalog:{group:`public`},...J,capability:{...J.capability,vega:W}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,vega:W,linux:K},timeoutPolicy:F,batchable:!0},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`scroll`,catalog:{group:`public`},...J,timeoutPolicy:X(`scroll`,F),postActionObservation:Z(`scroll`)},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},{name:`focus`,catalog:{group:`public`},...J},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:q,timeoutPolicy:F,batchable:!0},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{},android:{},linux:K},timeoutPolicy:F,batchable:!1},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,capability:Qi,timeoutPolicy:F,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1}],ia=new Set([`public`,`local-cli`]),aa=new Set(ra.filter(e=>ia.has(da(e))).map(e=>e.name)),Q=ra.map(e=>{let t=`platformExecution`in e?e.platformExecution:{kind:`legacy`};return Kr(t),{...e,mcpExposed:la(e),platformExecution:t}});function oa(e){return Q.filter(t=>da(t)===e).map(e=>[fa(e),e.name])}function sa(){return Q.filter(e=>ua(e)).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function ca(e){return aa.has(e)}function la(e){return e.mcpExposed??aa.has(e.name)}function ua(e){return e.mcpExposed&&ca(e.name)}function da(e){return e.catalog.group}function fa(e){return e.catalog.key??e.name}const pa=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ma=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function ha(e){if(e!==void 0)return $.get(e)?.postActionObservation}function ga(e){return ha(e)!==void 0}function _a(e){return ha(e)===`settle-and-verify`}function va(e){return e===void 0?F:pa.get(e)??F}function ya(e){if(e!==void 0)return ma.get(e)}function ba(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function xa(e){return $.get(e)?.targetIdentityVerification}function Sa(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Ca(){return[...new Set(Array.from(ma.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function wa(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function Ta(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function Ea(t,n){if(!d(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function Da(t,n){let r=t.input;if(!d(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function Oa(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function ka(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function Aa(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function ja(e,t){let n=e?.trim();if(n)return n;if(Aa(t))return`com.apple.mobilesafari`}function Ma(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Na(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function Pa(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Fa=Pa(Q),Ia=new Set([`batch`,`replay`]),La=[`command`,`positionals`,`input`,`flags`,`runtime`],Ra=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],za=new Set(Fa);function Ba(e){return za.has(e)}function Va(e){return typeof e==`string`?e.trim().toLowerCase():``}function Ha(t,n){let r=Va(t);if(Ba(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function Ua(t,n){if(Ia.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const Wa=new Set(La);async function Ga(e,t,n){let r=Qa(e.flags),a=r?.batchOnError??`stop`;if(a!==`stop`)return $a(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=r?.batchMaxSteps??100;if(!wa(o))return $a(`INVALID_ARGS`,`Invalid batch max-steps: ${String(r?.batchMaxSteps)}`);try{let i=Ka(r?.batchSteps,o),a=Date.now(),s=[];for(let[r,a]of i.entries()){let o=await Za(e,t,a,n,r+1,r===i.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:r,total:i.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:i.length,executed:i.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=i(e);return $a(t.code,t.message,t.details)}}function Ka(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);Ta(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!m(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!Wa.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=Va(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(Ua(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!m(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!m(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:Oa(i.runtime,n+1)})}return r}function qa(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return Ja(Qa(e),a)}function Ja(e,t){let n=Qa(e)??{},r=t;for(let e of Ra)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function Ya(e,n){return t(e)?n?e:`digest`:e}function Xa(e,t){let n=e?.responseLevel,r=Ya(n,t);return r===n?e:{...e,responseLevel:r}}async function Za(e,t,n,r,i,a){let o=Date.now(),s=qa(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:Xa(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function Qa(e){return e}function $a(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{br as $,ne as $n,wt as $t,wi as A,Oe as An,Rn as At,ni as B,xe as Bn,fn as Bt,ya as C,Ne as Cn,N as Ct,Ai as D,Ae as Dn,Bn as Dt,Ni as E,Re as En,Un as Et,oi as F,_ as Fn,tn as Ft,Nr as G,ue as Gn,Gt,Wr as H,_e as Hn,Zt as Ht,si as I,we as In,hn as It,Dr as J,ie as Jn,qt as Jt,Er as K,le as Kn,Yt as Kt,ri as L,Ce as Ln,pn as Lt,_i as M,Te as Mn,Fn as Mt,ai as N,g as Nn,Pn as Nt,Mi as O,Ie as On,jn as Ot,li as P,Ee as Pn,In as Pt,vr as Q,oe as Qn,zt as Qt,ci as R,h as Rn,gn as Rt,ba as S,Le as Sn,Wn as St,xa as T,Fe as Tn,Nn as Tt,Fr as U,ge as Un,Qt as Ut,Gr as V,be as Vn,A as Vt,Ir as W,m as Wn,Kt as Wt,kr as X,se as Xn,Lt as Xt,Ar as Y,re as Yn,Xt as Yt,Cr as Z,ae as Zn,Bt as Zt,_a as _,x as _n,Yn as _t,Na as a,pt as an,P as at,sa as b,ze as bn,Jn as bt,Aa as c,lt as cn,ur as ct,wa as d,vt as dn,ar as dt,Ct as en,ye as er,xr as et,Oa as f,bt as fn,dr as ft,ga as g,Ke as gn,er as gt,Q as h,We as hn,$n as ht,Ha as i,at as in,pr as it,vi as j,v as jn,An as jt,xi as k,je as kn,zn as kt,ja as l,ct as ln,tr as lt,Ea as m,qe as mn,or as mt,Ga as n,D as nn,d as nr,wr as nt,Ma as o,mt as on,lr as ot,Da as p,He as pn,fr as pt,Or as q,ce as qn,Jt as qt,Fa as r,Tt as rn,hr as rt,ka as s,ht as sn,cr as st,Ja as t,Et as tn,ve as tr,Sr as tt,Ta as u,st as un,sr as ut,Ca as v,Je as vn,Zn as vt,va as w,Pe as wn,Ln as wt,Sa as x,y as xn,Xn as xt,oa as y,S as yn,qn as yt,ti as z,Se as zn,vn as zt};
|
|
1
|
+
import{_ as e,a as t,i as n,u as r,v as i}from"./sdk-contracts.js";import{T as a,c as o,d as s,l as c,n as l,s as u,x as d}from"./sdk-device.js";function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ee(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function te(e,t,n){return n(e[t])}function ne(e,t,n){let r=e[t];return r===null?null:n(r)}function re(e,t){return ee(e,t,fe,`Daemon response is missing "${t}".`)}function ie(e,t){return te(e,t,fe)}function ae(e,t){return ne(e,t,fe)}function oe(e,t){return ee(e,t,pe,`Daemon response is missing numeric "${t}".`)}function se(e,t){return ee(e,t,me,`Daemon response has invalid "${t}".`)}function ce(e,t){return ee(e,t,he,`Daemon response has invalid "${t}".`)}function le(e,t){return te(e,t,ge)??`mobile`}function ue(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`),r=p(e,`width`),i=p(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function de(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function p(e,t){let n=e[t];return typeof n==`number`?n:void 0}function fe(e){return typeof e==`string`&&e.length>0?e:void 0}function pe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function me(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`harmonyos`||e===`vega`||e===`linux`||e===`web`?e:void 0}function he(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function ge(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function _e(t){if(!m(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ve(e){return m(e)?e:void 0}function ye(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function be(e){return e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function h(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function g(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function xe(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 Se(e){return e.width*e.height}function Ce(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function _(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 we(e,t){return Te(e.x,e.x+e.width,t.x,t.x+t.width)&&Te(e.y,e.y+e.height,t.y,t.y+t.height)}function Te(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Ee(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function De(e){return Ee(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function v(e){return new Map(e.map(e=>[e.index,e]))}function Oe(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 ke(e,t,n){return Oe(e,t,v(e),e=>n(e)?e:null)}function y(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function Ae(e,t){let n=y(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 je(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function Me(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function Ne(e){let t=[e.type,e.role,e.subrole].map(e=>y(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function Pe(e,t){let n=r(t),i=e.flatMap(e=>Fe(e.rect)?[{node:e,rect:e.rect}]:[]),a=i.filter(e=>Ne(e.node)).map(e=>e.rect),o=e=>Ce(e,n.x,n.y);return _(a.filter(o))??_(a)??_(i.map(e=>e.rect).filter(o))}function Fe(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function Ie(e,t,n=v(t)){if(!e.rect)return!0;let r=ze(e,t,n);return r?we(e.rect,r):!0}function Le(e,t,n=v(t)){if(!e.rect)return!0;if(!Ie(e,t,n))return!1;let r=Pe(t,e.rect);return Re(e.rect,r)}function Re(e,t){return!t||t.width<=0||t.height<=0?!0:Ce(t,e.x+e.width/2,e.y+e.height/2)}function ze(e,t,n=v(t)){return Be(e,n,e=>!!e.rect)?.rect||Pe(t,e.rect??{x:0,y:0,width:0,height:0})}function Be(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)&&De(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function Ve(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=y(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&&g(e.rect):e.hittable===!0||g(e.rect)}function b(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function He(e,t){return Ae(e.type??``,t)&&e.enabled!==!1}const Ue=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),We=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),x=new Set([...Ue,...We]),Ge=[...x],Ke=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 qe(e){return Ke.has(e.trim().toLowerCase())}const Je=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
|
|
3
|
+
`],[`r`,`\r`],[`t`,` `]]);function Ye(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=tt(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>$e(e))}}function S(e){try{return Ye(e)}catch{return null}}function Xe(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 x.has(e)}return x.has(t.toLowerCase())}function Ze(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||x.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=it(i).trim();return a?{key:r,value:a}:null}function Qe(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||!Xe(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&S(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 $e(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=nt(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(et)}}function et(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(!We.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(!x.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(We.has(i)){let t=st(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:it(a)}}function tt(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!ct(t,a)){i=rt(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 nt(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!ct(t,e)){i=rt(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 rt(e,t){return e?e===t?null:e:t}function it(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?at(t.slice(1,-1)):t}function at(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=ot(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 ot(e){return Je.get(e)??null}function st(e){let t=it(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function ct(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function lt(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function ut(e){let t=e.toLowerCase();return lt(t)?{ok:!0,predicate:t}:h(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,dt)}const dt=`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 ft(e){if(lt((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(lt(n)&&S(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function pt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=Me(n),s=He(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?b(n):mt(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}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function mt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(g(e.rect))return ht(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=gt(e,t,n);return r?g(r.rect)?ht(r,t):n!==`android`&&r.hittable===!0:!1}function ht(e,t){return Ie(e,t)}function gt(e,t,n){return Oe(t,e,v(t),e=>Ve(e,n)?e:null)}function _t(e){let t=ft(e),n=t[0]??``;return{predicate:n,split:Qe(t.slice(1),{preferTrailingValue:n===`text`})}}const vt=`is requires a selector expression`,yt=`is text requires expected text value`;function bt(e){let{predicate:t,split:n}=_t([...e]),r=ut(t);if(!r.ok)return r;if(!n)return h(vt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?h(yt):r.predicate!==`text`&&n.rest.length>0?h(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function xt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:h(`get only supports text or attrs`)}function St(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}:h(`get requires @ref or selector expression`)}function Ct(e){return e?{ok:!0,text:e}:h(`wait requires text`)}function wt(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function Tt(t,n,r={}){let i=t[n];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);if(r.min!==void 0&&i<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&i>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return i}}const Et=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,Dt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,Ot=4096;function kt(e){return e.normalize(`NFC`)}function At(e){if(e===void 0)return;let t=kt(e);return t.length>0?t:void 0}function jt(e){return kt(e)}function Mt(e){if(e===void 0)return;let t=kt(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function C(e){return Buffer.byteLength(e,`utf8`)}function Nt(e,t){if(C(e)<=t)return e;let n=e.length;for(;n>0&&C(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function Pt(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(Ft),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=It(e.scrollRegion)),e.rect&&(t.rect=Lt(e.rect)),t.verification=e.verification,t}function Ft(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function It(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 Lt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function Rt(e){return JSON.stringify(Pt(e))}function zt(e){return`# agent-device:target-v1 ${Rt(e)}`}function Bt(e){return JSON.stringify({source:Pt(e.source),destination:Pt(e.destination)})}function Vt(e){return`# agent-device:targets-v1 ${Bt(e)}`}function Ht(e){let t=e.trim(),n=Dt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Ut((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Ut(t){if(C(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:Gt(JSON.stringify(r.source)),destination:Gt(JSON.stringify(r.destination))}}function Wt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=Et.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Gt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Gt(t){if(C(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${Ot}-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=Kt(r.role,`role`),a=qt(r.id,`id`),o=Jt(r.label,`label`),s=Xt(r.ancestry),c=Qt(r.sibling,`sibling`,0),l=Qt(r.viewportOrder,`viewportOrder`,0),u=$t(r.scrollRegion),d=en(r.rect),f=nn(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function Kt(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 Yt(jt(t),n)}function qt(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=At(t);return r===void 0?void 0:Yt(r,n)}function Jt(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:Yt(r,n)}function Yt(t,n){if(C(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Xt(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)=>Zt(e,t))}function Zt(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=Kt(r.role,`ancestry[${n}].role`),a=Jt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Qt(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 $t(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=Kt(n.role,`scrollRegion.role`),i=qt(n.id,`id`),a=Jt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function en(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:tn(n.x,`rect.x`),y:tn(n.y,`rect.y`),width:tn(n.width,`rect.width`),height:tn(n.height,`rect.height`)}}function tn(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 nn(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function rn(e){let t=jt(y(e.type??``)),n=At(e.identifier),r=Mt(e.label);return{...n===void 0?{}:{id:Nt(n,256)},role:Nt(t,256),...r===void 0?{}:{label:Nt(r,256)}}}function an(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function on(e,t){let n=0;for(let r of e)rn(r).id===t&&(n+=1);return n}function sn(e,t){if(e.id===void 0||on(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function cn(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 ln(e,t){return{documentOrder:e.index,sibling:cn(t,e)}}function un(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function dn(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function fn(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function pn(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 mn(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 hn(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function gn(e,t){return!t||t.role!==e.role?!0:e.label!==void 0&&t.label!==e.label}function _n(e,t){for(let[n,r]of e.entries()){let e=t[n];if(gn(r,e))return[`ancestry[${n}]: recorded=${hn(r)} observed=${hn(e)}`]}return[]}function vn(e,t,n={}){let r=[],i=y(e.type??``),a=yn(e,n.nodes),o=T(e.label),s=T(e.value),c=T(Me(e)),l=n.action===`fill`;a&&r.push(`id=${w(a)}`),i&&o&&r.push(l?`role=${w(i)} label=${w(o)} editable=true`:`role=${w(i)} label=${w(o)}`),o&&r.push(l?`label=${w(o)} editable=true`:`label=${w(o)}`),s&&r.push(l?`value=${w(s)} editable=true`:`value=${w(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${w(c)} editable=true`:`text=${w(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${w(i)} editable=true`);let u=bn(r);return u.length===0&&i&&u.push(l?`role=${w(i)} editable=true`:`role=${w(i)}`),u.length===0&&b(e)&&u.push(`visible=true`),u}function yn(e,t){let n=T(e.identifier);if(!n||!t)return n;let r=rn(e).id;return r===void 0?n:on(t,r)>1?null:n}function bn(e){return Array.from(new Set(e))}function w(e){return JSON.stringify(e)}function T(e){return e&&e.trim()||null}const xn=[`any`,`text`,`label`,`value`,`role`,`id`],Sn=[`text`,`label`,`value`,`role`,`id`];function Cn(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function wn(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function Tn(e,t,n,r={}){let i=D(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=En(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 En(e,t,n){switch(t){case`role`:return Dn(e.type,n);case`label`:return E(e.label,n);case`value`:return E(e.value,n);case`id`:return E(e.identifier,n);default:return Math.max(E(e.label,n),E(e.value,n),E(e.identifier,n))}}function E(e,t){let n=D(e??``);return n?n===t?2:+!!n.includes(t):0}function Dn(e,t){let n=On(e??``);return n?n===t?2:+!!n.includes(t):0}function D(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function On(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const kn=`find requires a value`,An=`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 jn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=Pn([...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:kn}}const Mn=[`exists`,`list`,`click`,`focus`];function Nn(e){return Mn.includes(e)}function Pn(t){let n=`any`,r=0;Sn.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=Cn(a[0]);if(Nn(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=Ln(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`)return{locator:n,query:i,action:o,value:a.slice(1).join(` `)};throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:An})}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 In(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:S(t)?t:null}function Ln(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function O(e,t,n){return t.terms.every(t=>Rn(e,t,n))}function Rn(e,t,n){switch(t.key){case`id`:return k(e.identifier,String(t.value));case`role`:return k(y(e.type??``),String(t.value));case`label`:return k(e.label,String(t.value));case`value`:return k(e.value,String(t.value));case`text`:return k(Me(e),String(t.value));case`appname`:return k(e.appName,String(t.value));case`windowtitle`:return k(e.windowTitle,String(t.value));case`visible`:return b(e)===!!t.value;case`hidden`:return!b(e)==!!t.value;case`editable`:return He(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 k(e,t){return D(e??``)===D(t)}function zn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=Gn(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function Bn(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:O(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function Vn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Yn(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const Hn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Un(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 Wn(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 Gn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=v(e),Le(t,e,c));for(let c of e)r&&!c.rect||O(c,t,n)&&(i+=1,a??=c,o.push(c),Kn(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:qn(o,s.best,l),candidates:o}}function Kn(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=Xn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function qn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Jn(i,r,n).result>0)&&(r=i);return r?Jn(t,r,n).criterion:null}function Jn(e,t,n){let r=n(e);return r===n(t)?Xn(e,t):{result:r?1:-1,criterion:`visible`}}function Yn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||O(a,t,n)&&(i+=1);return i}function Xn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Zn(e),a=Zn(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Zn(e){return e.rect?e.rect.width*e.rect.height:1/0}const Qn={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}};function $n(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function er(e,t){let n=e===`is`?_t([...t]).split:Qe([...t]);return n?S(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function tr(e){return{platform:e.platform,...$n({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function nr(e,t,n){let r=S(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let i=zn(t,r,tr(n));if(i){let e=t.filter(e=>n.requireRect&&!e.rect?!1:O(e,i.selector,n.platform));return{kind:`resolved`,winner:i.node,matchedNodes:e,matchCount:e.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}}let a=Bn(t,r,{platform:n.platform,requireRect:n.requireRect})?.matchedNodes??[];return{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function rr(e,t,n={}){return vn(e,t,n)}function ir(e,t,n){let r=S(e);if(!r)return;let i=zn(t,r,tr(n));if(i)return{node:i.node,basis:or(i.selector)}}function ar(e){if(!e)return;let t=S(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 or(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 sr(e,t){let n=S(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys);return n.selectors.length>1?cr(n.selectors,r):lr(n.selectors[0],r,new Set(t.booleanKeys))}function cr(e,t){let n=e.map(e=>{let n=e.terms.length===1?e.terms[0]:void 0;return n&&t.has(n.key)&&typeof n.value==`string`?n.value:void 0}),r=n[0];return r!==void 0&&n.every(e=>e===r)?r:null}function lr(e,t,n){if(!e)return null;let r={},i=0;for(let a of e.terms){if(ur(a,t,`string`))i+=1;else if(!ur(a,n,`boolean`))return null;r[a.key]=a.value}return i<=1&&Object.keys(r).length>0?r:null}function ur(e,t,n){return t.has(e.key)&&typeof e.value===n}function dr(e){let t=S(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 fr(e,t){if(!t)return!1;let n=S(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 pr(e){return Ye(e).selectors.map(e=>e.raw)}function mr(e){return S(e)!==null}function A(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function hr(e){let t=e[0];if(t===void 0)return null;let n=A(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=A(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?A(t[1]):null;return{kind:`stable`,quietMs:t.length>0?A(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=Qe(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&mr(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function gr(e){let t=hr(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const _r=24e4,j={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},vr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,scroll:`settle`,back:`settle`};function yr(e){if(e!==void 0)return vr[e]}const br=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function xr(e){let t=M(e.packageName),n=(e.resourceId??``).toLowerCase(),r=M(e.activeInputMethodPackage);if(t&&r&&t===r)return{inputMethodOwned:!0,source:`active-input-method`};if(r&&n.startsWith(`${r}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(t&&br.has(t))return{inputMethodOwned:!0,source:`known-ime-package`};for(let e of br)if(n.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function Sr(e,t,n){return xr({packageName:e,resourceId:t,activeInputMethodPackage:n}).inputMethodOwned}function Cr(e){return xr(e).inputMethodOwned}function wr(e){return Cr({packageName:e.bundleId,resourceId:e.identifier})}function Tr(e){let t=M(e);return!!(t&&br.has(t))}function Er(e){let t=(e??``).toLowerCase();for(let e of br)if(t.startsWith(`${e}:id/`))return!0;return!1}function Dr(e,t,n){return!e&&!t?`unknown`:Sr(e,t,n)?`ime`:`app`}function Or(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=kr(e.match(t)?.[1]);if(n)return n}}function kr(e){let t=(e??``).trim();if(t)return M((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function M(e){return(e??``).trim().toLowerCase()||void 0}const Ar=new Set([`empty-helper-output`,`system-window-only`,`content-poor-app-window`]);function jr(e){return typeof e==`string`&&Ar.has(e)}function Mr(e){if(!e||typeof e!=`object`)return!1;let t=e.details?.androidSnapshotHelperFailureReason;return jr(t)}const Nr=`com.android.systemui`;function Pr(e){let t=e??``;if(!t.startsWith(`com.android.systemui:id/`))return!1;let n=t.slice(`${Nr}:id/`.length);return/(^|_)(status_bar|navigation_bar)(_|$)/.test(n)}function Fr(e){return`systemChrome`in e&&e.systemChrome===!0}function Ir(e){if(!Fr(e))return e;let{systemChrome:t,...n}=e;return n}function Lr(e){return e.some(Fr)?e.map(Ir):e}const Rr={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},zr={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android and the iOS simulator only.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android and the iOS simulator only.`};function Br(t,n){if(!u(t.platform))throw Vr(n,t.platform);let r=d(t);if(!((r===`ios`||r===`ipados`)&&t.kind===`simulator`))throw r===`ios`||r===`ipados`?new e(`UNSUPPORTED_OPERATION`,`gesture ${n} is not supported on physical iOS devices`,{hint:`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`}):Vr(n,Rr[r],zr[r])}function Vr(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function Hr(e){let t=e.state??`stopped`;return{audio:`probe`,state:t,active:t===`running`,heard:!1,source:e.source,backend:e.backend,durationMs:e.durationMs,elapsedMs:e.elapsedMs??0,bucketMs:e.bucketMs,sampleCount:0,mediaElementCount:e.mediaElementCount,sourceCount:e.sourceCount??0,rmsDbfs:[],peakDbfs:[],reason:e.reason,notes:e.notes}}function Ur(e,t){let n=qr(e),r=Wr(n),i=Gr(n.rmsDbfs),a=Gr(n.peakDbfs),o=[...Kr(n.notes)??[],...t.notes??[]];return{audio:`probe`,state:r,active:r===`running`&&Jr(n.active,t.activeFallback??!0),heard:n.heard===!0,source:t.source,backend:P(n.backend)??t.backend,durationMs:N(n.durationMs,t.durationMs),elapsedMs:N(n.elapsedMs,t.elapsedMs),bucketMs:N(n.bucketMs,t.bucketMs),sampleCount:N(n.sampleCount,i.length),mediaElementCount:t.mediaElementCount===void 0?Yr(n.mediaElementCount):N(n.mediaElementCount,t.mediaElementCount),sourceCount:N(n.sourceCount,t.sourceCount??0),rmsDbfs:i,peakDbfs:a,startedAt:P(n.startedAt),stoppedAt:P(n.stoppedAt),reason:P(n.reason),notes:o.length>0?o:void 0}}function Wr(e){return e.state===`running`?`running`:`stopped`}function N(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Gr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)typeof n==`number`&&Number.isFinite(n)&&t.push(n);return t}function Kr(e){if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}function qr(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Jr(e,t){return typeof e==`boolean`?e:t}function P(e){return typeof e==`string`?e:void 0}function Yr(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Xr(e){return process.platform===`darwin`&&(c(e)||o(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}function Zr(e){return e.platform===`web`||Xr(e)}function Qr(e){if(!s(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function $r(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function ei(e){return e.kind===`local-family`?`local:${e.family}`:`provider:${JSON.stringify([e.provider,e.instance])}`}function ti(e,t){return ei(e)===ei(t)}function ni(e,t){let n={},r={};for(let i of t.required){let t=ri(e.facts.operations,i);if(n[i]=t,!t.available)throw ci(i,t);r[i]=oi(e.operations,i)}for(let i of t.preferred){let t=ri(e.facts.operations,i);n[i]=t,t.available&&(r[i]=oi(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function ri(e,t){let n=e[t];if(!ii(n))throw li(`Runtime owner omitted the ${t} fact`);let r=ai(n);if(r)return r;throw li(`Runtime owner returned an invalid ${t} fact`)}function ii(e){return typeof e==`object`&&!!e&&`available`in e}function ai(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&si(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 oi(e,t){let n=e[t];if(typeof n!=`function`)throw li(`Runtime owner advertised ${t} without an implementation`);return n}function si(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function ci(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function li(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 ui(){return e=>{let t=di(e.required,`required`),n=di(e.preferred??[],`preferred`),r=n.find(e=>t.includes(e));if(r!==void 0)throw TypeError(`Runtime operation cannot be both required and preferred: ${r}`);return Object.freeze({required:t,preferred:n})}}function di(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 F=ui(),fi=F({required:[`bootTarget`]}),pi=F({required:[`bootTargetHeadless`]}),mi=F({required:[`ensureReady`,`listApps`]}),hi=Object.freeze([fi,pi]),gi=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:fi}),_i=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:pi});function vi(e){return e.headless?_i:gi}const yi=F({required:[`ensureReady`,`appState`]}),bi=Object.freeze([yi]),xi=F({required:[`shutdownTarget`]}),Si=F({required:[`deployApp`]}),Ci=F({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),wi=F({required:[`ensureReady`,`sendPushNotification`]});function Ti(e){if(typeof e!=`object`||!e)throw Ni();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&I(n,[`kind`]))&&!(t.kind===`legacy`&&I(n,[`kind`]))&&!(t.kind===`inventory`&&I(n,[`kind`,`use`])&&Oi(t.use))&&!(t.kind===`device-runtime`&&I(n,[`kind`,`use`])&&ki(t.use))&&!(t.kind===`device-runtime`&&I(n,[`kind`,`uses`])&&Ei(t.uses)))throw Ni()}function Ei(e){if(!Array.isArray(e)||e.length===0||!e.every(ki))return!1;let t=e.map(Di);return new Set(t).size===t.length}function Di(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function Oi(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&I(Object.keys(t).sort(),[`kind`])}function ki(e){if(typeof e!=`object`||!e)return!1;let t=e,n=Ai(t.required),r=Ai(t.preferred);return!n||!r||!ji(n)||!ji(r)||!Mi(n,r)?!1:I(Object.keys(t).sort(),[`preferred`,`required`])}function Ai(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function ji(e){return new Set(e).size===e.length}function Mi(e,t){let n=new Set(e);return t.every(e=>!n.has(e))}function I(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Ni(){return TypeError(`Command platform execution must declare exactly one of none, legacy, inventory, or device-runtime`)}var Pi=class{#e=[];#t=`open`;get disposed(){return this.#t===`disposed`}defer(e){this.#n(),this.#e.push(e)}use(e){return this.defer(async()=>await e[Symbol.asyncDispose]()),e}async[Symbol.asyncDispose](){if(this.#t===`disposed`)return;if(this.#t===`disposing`)throw TypeError(`Async cleanup stack disposal is already in progress`);this.#t=`disposing`;let e=[];for(;this.#e.length>0;){let t=this.#e.pop();if(t)try{await t()}catch(t){e.push(t)}}if(this.#t=`disposed`,e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Multiple asynchronous cleanups failed`)}#n(){if(this.#t!==`open`)throw TypeError(`Cannot register cleanup after disposal has begun`)}},Fi=class{#e;#t=`pending`;constructor(e){this.#e=e}get pending(){return this.#t===`pending`}transfer(){if(this.#t!==`pending`)throw TypeError(`Cannot transfer handle in ${this.#t} state`);return this.#t=`transferred`,this.#e}async[Symbol.asyncDispose](){this.#t===`pending`&&(this.#t=`disposed`,await this.#e[Symbol.asyncDispose]())}};const L=new Map;async function Ii(e,t){let n=L.get(e);if(n){await n;return}let r,i=new Promise(e=>{r=e});L.set(e,i);try{await t()}finally{L.get(e)===i&&L.delete(e),r()}}async function Li(e){await L.get(e)}const Ri=[`metroHost`,`metroPort`,`bundleUrl`];function zi(e){return Ri.some(t=>e[t]!==void 0)}const Bi=[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`,`closeApplication`,`finalizeApplicationClose`,`prepareAppleRunner`,`configureProviderPortReverse`];function Vi(e){return Object.freeze({resolveOpenTarget:e.resolveOpenTarget,prepareApplicationOpen:e.prepareApplicationOpen,openApplication:e.openApplication,applyRuntimeHints:e.applyRuntimeHints,clearRuntimeHints:e.clearRuntimeHints,closeApplication:e.closeApplication,finalizeApplicationClose:e.finalizeApplicationClose,prepareAppleRunner:e.prepareAppleRunner,configureProviderPortReverse:e.configureProviderPortReverse})}function Hi(e,t){return Object.freeze(Object.fromEntries(Bi.flatMap(n=>t[n].available?[[n,e[n]]]:[])))}function Ui(e,t,n){return Object.freeze({device:e,owner:t,facts:Wi(e,t,n),operations:Object.freeze({}),[Symbol.asyncDispose]:async()=>void 0})}function Wi(e,t,n){let{appLog:r,apps:i,appDeployment:o,appState:s,network:c,screenRecording:l,readiness:u,shutdown:d,lifecycle:f}=Gi(n);return Object.freeze({device:{...a(e),providerMode:t.kind===`local-family`?`local`:`provider-runtime`},operations:{appLogInspect:r,appLogDoctor:r,appLogStart:r,appLogReattach:r,appLogCleanup:r,listApps:i,deployApp:o,materializeAppSource:o,deployMaterializedApp:o,sendPushNotification:o,appState:s,networkDump:c,screenRecordingStart:l,screenRecordingReattach:l,screenRecordingCleanup:l,ensureReady:u,bootTarget:u,bootTargetHeadless:u,shutdownTarget:d,...f}})}function Gi(e){return Object.freeze({appLog:Object.freeze({...e.appLog}),apps:Object.freeze({...e.apps??e.network}),appDeployment:Object.freeze({...e.appDeployment??e.network}),appState:Object.freeze({...e.appState??e.network}),network:Object.freeze({...e.network}),screenRecording:Object.freeze({...e.screenRecording??e.network}),readiness:Object.freeze({...e.readiness??e.network}),shutdown:Object.freeze({...e.shutdown??e.network}),lifecycle:Vi(e.lifecycle)})}function Ki(e){return e.status===`cleaned`||e.status===`already-missing`}const qi=`app-log`,Ji=`screen-recording`,Yi=F({required:[`screenRecordingStart`]}),Xi=F({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Zi=F({required:[]}),Qi=F({required:[],preferred:[`screenRecordingStart`]}),$i=Object.freeze([Yi,Xi]);function ea(t){switch((t.action??``).toLowerCase()){case`start`:if(!ta(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:Yi});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Zi}):Object.freeze({kind:`stop-recovery`,use:Xi});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function ta(e){return e===`app`||e===`device`||e===`system`}function na(e){if(Ti(e),e.kind!==`device-runtime`||!(`uses`in e))throw ia();let t=e.uses.map(ra),n=$i.map(ra),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw ia()}function ra(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function ia(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}const aa=F({required:[`networkDump`]}),oa=F({required:[],preferred:[`networkDump`]}),sa=[`dump`,`log`],ca=[`summary`,`headers`,`body`,`all`];function la(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!ua(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!da(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:aa})}function ua(e){return sa.some(t=>t===e)}function da(e){return ca.some(t=>t===e)}function R(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function fa(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function pa(e,t){let n=e?.trim();if(n)return n;if(fa(t))return`com.apple.mobilesafari`}const ma=`--launch-console is supported only for iOS simulator app launches`,ha=`--launch-console requires a direct app launch and cannot be used with URL opens`;function ga(e,t,n){return{requestId:e.requestId,signal:n,appBundleId:t,verbose:e.verbose,logPath:e.logPath,traceLogPath:e.traceLogPath,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext}}function _a(t){let{device:n,signal:r,ownership:i}=t;return Object.freeze({device:n,signal:r,resolveInteractor:async(a,o)=>{let s=ga(a,o,r);if(i===`local`)return await t.resolveLocalInteractor(n,s);let c=i.resolveInteractor(s);if(c)return c;throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned application lifecycle operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:n.id})}})}function va(e){return _a({device:e.device,signal:e.signal,resolveLocalInteractor:e.resolveInteractor,ownership:`local`})}function ya(e){return _a({device:e.device,signal:e.signal,ownership:{kind:`provider`,resolveInteractor:e.resolveInteractor}})}async function ba(e){let{device:t,positionals:n,execution:r}=e;xa(n);let i=n[0],a=n[1];if(!i){await Sa(e);return}if(Ca(t,r),a!==void 0){await wa(e,i,a);return}await Ta(e,i)}function xa(t){if(t.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`)}async function Sa(t){if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(t.execution.launchArgs&&t.execution.launchArgs.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);await t.interactor.openDevice()}function Ca(t,n){if(n.launchConsole&&(!o(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,ma);if(t.platform===`linux`&&n.launchArgs&&n.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`)}async function wa(t,n,r){if(R(n))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!R(r))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,ha);await t.interactor.open(n,{activity:t.execution.activity,appBundleId:t.appBundleId,launchArgs:t.execution.launchArgs?[...t.execution.launchArgs]:void 0,terminateRunningApp:t.terminateRunningApp,url:r})}async function Ta(t,n){let{execution:r,interactor:i}=t;if(r.launchConsole&&R(n))throw new e(`INVALID_ARGS`,ha);if(r.clearAppState){if(R(n))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await i.setSetting(`clear-app-state`,`clear`,n)}await i.open(n,{activity:r.activity,appBundleId:t.appBundleId,launchConsole:r.launchConsole,launchArgs:r.launchArgs?[...r.launchArgs]:void 0,terminateRunningApp:t.terminateRunningApp})}function Ea(t){let{binding:n}=t,r=async()=>{throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for ${t.owner}.`)};return Object.freeze({resolveOpenTarget:async e=>ka(t.openTargetIdentity,e),prepareApplicationOpen:async()=>void 0,openApplication:async e=>await Da(t,e),applyRuntimeHints:r,clearRuntimeHints:r,closeApplication:async e=>{await Aa({device:n.device,interactor:await n.resolveInteractor(e.execution,e.appBundleId),positionals:e.positionals})},finalizeApplicationClose:async()=>({}),prepareAppleRunner:r,configureProviderPortReverse:t.configureProviderPortReverse??r})}async function Da(e,t){let{binding:n}=e,r=await n.resolveInteractor(t.execution,t.appBundleId);e.closeBeforeRelaunch&&t.relaunch&&t.target!==void 0&&await Aa({device:n.device,interactor:r,positionals:[t.appBundleId??t.target]}),await ba({device:n.device,interactor:r,positionals:t.positionals,appBundleId:t.appBundleId,execution:t.execution});let i=Oa(t);return i&&await ba({device:n.device,interactor:r,positionals:[i],appBundleId:t.appBundleId,execution:{...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0}}),{appBundleId:t.appBundleId,timing:{}}}function Oa(e){let t=e.runtimeLaunchUrl?.trim(),n=e.positionals.length===1?e.positionals[0]?.trim():void 0;if(!(!t||!n||R(n)))return t}function ka(e,t){let n=t.target;if(e===`app-name`)return Object.freeze(n===void 0?{}:{appName:n});let r=n?.trim(),i=r&&r.includes(`.`)&&!R(r)?r:t.currentAppBundleId;return Object.freeze({...i===void 0?{}:{appBundleId:i},...n===void 0?{}:{appName:n}})}async function Aa(e){let{device:t,interactor:n,positionals:r}=e,i=r[0];if(!i){t.platform===`web`&&await n.close(``);return}await n.close(i)}const ja=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Ma=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Na=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Pa=F({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Fa(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Pa}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Ma}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Na}):Object.freeze({kind:`open`,use:ja})}const Ia=Object.freeze([ja,Ma,Na,Pa]),La=F({required:[`closeApplication`,`finalizeApplicationClose`]}),Ra=F({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),za=Object.freeze([La,Ra]),Ba=F({required:[`finalizeApplicationClose`]}),Va=F({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),Ha=F({required:[`prepareAppleRunner`]}),Ua=F({required:[`clearRuntimeHints`]}),Wa=F({required:[`configureProviderPortReverse`]}),Ga=Object.freeze([Ua,Wa]),z=F({required:[`appLogInspect`]}),Ka=F({required:[`appLogInspect`,`appLogDoctor`]}),qa=F({required:[`appLogInspect`,`appLogStart`]}),Ja=F({required:[],preferred:[`appLogInspect`]}),Ya=Object.freeze([z,Ka,qa]);function Xa(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:z});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:qa});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:z});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Ka});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:z});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:qa}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:z});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}function Za(e){let t=new Map;for(let n of e){if(!s(n.family))throw TypeError(`Unknown platform family registration: ${String(n.family)}`);if(t.has(n.family))throw TypeError(`Duplicate platform family registration: ${n.family}`);t.set(n.family,Qa(n))}let n=l.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let r=Object.freeze([...l]),i=Object.freeze(r.map(e=>$a(t,e)));return Object.freeze({families:r,modules:i,get:e=>$a(t,e)})}function Qa(e){return Object.freeze({...e})}function $a(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const eo=Object.freeze({kind:`device-inventory`});function to(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, legacy, inventory, or device-runtime); there is no registry-entry default`);if(Ti(t),t.kind===`none`&&e.capability!==void 0)throw TypeError(`Command descriptor "${e.name}" declares platformExecution none but keeps a capability bucket; a command with platform admission is not platform-free`);return t}const no={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},B={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},ro=()=>!0,io=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,ao=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),oo=new Set([`status`,`get`]),so=e=>mo(e,oo,`status`),co=new Set([`get`,`wait`]),lo=e=>mo(e,co,`get`),uo=e=>ho(e,oo,`status`),fo=e=>ho(e,co,`get`),po=e=>{try{return wn(Pn(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function mo(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function ho(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const V={simulator:!0,device:!0},H={emulator:!0,device:!0,unknown:!0},go={emulator:!0},U={device:!0},W={},G={apple:V,android:H,linux:U},K={kind:`none`},q={kind:`legacy`},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0},Y={...j,onTimeout:`preserve-daemon`},_o={...j,envelopeMs:18e4},vo={...j,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},yo={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}}},bo={fields:{delayMs:{defaultValue:0}}};function X(e,t){return yr(e)===void 0?t:vo}function Z(e){let t=yr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const xo=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...no},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...B},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...B},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`inventory`,use:eo}},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...B},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:ro,...B},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},platformExecution:{kind:`device-runtime`,uses:[mi]},timeoutPolicy:j,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:hi},timeoutPolicy:j,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:xi},timeoutPolicy:j,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:bi},timeoutPolicy:j,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:Ya},timeoutPolicy:j,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...B},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:aa},timeoutPolicy:j,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:{emulator:!0},linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:ao,saveScriptFlagOwner:!0},timeoutPolicy:{...j,budget:{source:`flag`}},batchable:!1,platformExecution:q},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:ao},timeoutPolicy:{...j,envelopeMs:`unbounded`},batchable:!0,platformExecution:q},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:j,batchable:!1,platformExecution:{kind:`device-runtime`,uses:Ga}},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:uo,daemon:{route:`session`,refFrameEffect:so,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Si},timeoutPolicy:_o,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Si},timeoutPolicy:_o,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ci},timeoutPolicy:_o,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...B},timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:wi},timeoutPolicy:j,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:ro,saveScriptFlagOwner:!0},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ia}},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`},envelopeMs:_r,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:Ha}},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0},timeoutPolicy:j,batchable:!0,platformExecution:{kind:`device-runtime`,uses:za}},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:G,timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:q},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:gr}},batchable:!0,platformExecution:q},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:fo,daemon:{route:`snapshot`,refFrameEffect:lo},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:io},platformExecution:{kind:`device-runtime`,uses:$i},timeoutPolicy:j,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:po,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:G,timeoutPolicy:Y,batchable:!0,platformExecution:q},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:yo,batchable:!0,platformExecution:q},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:bo,batchable:!0,platformExecution:q},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:{...vo,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0,platformExecution:q},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:U},timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:yo,batchable:!0,platformExecution:q},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:G,timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:q},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:q},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:G,timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:q},{name:`back`,catalog:{group:`public`},...J,capability:{...J.capability,vega:go},timeoutPolicy:X(`back`,j),postActionObservation:Z(`back`),platformExecution:q},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`home`,catalog:{group:`public`},...J,capability:{...J.capability,vega:go},platformExecution:q},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,vega:go,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`scroll`,catalog:{group:`public`},...J,timeoutPolicy:X(`scroll`,j),postActionObservation:Z(`scroll`),platformExecution:q},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:U},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`focus`,catalog:{group:`public`},...J,platformExecution:q},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:G,timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{},android:{},linux:W},timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:j,batchable:!0,platformExecution:q},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Ci},timeoutPolicy:j,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:q},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,platformExecution:K},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:j,batchable:!1,mcpExposed:!1,platformExecution:q}],So=new Set([`public`,`local-cli`]),Co=new Set(xo.filter(e=>So.has(ko(e))).map(e=>e.name)),Q=xo.map(e=>{let t=to(e);return e.name===`record`&&na(t),{...e,mcpExposed:Do(e),platformExecution:t}});function wo(e){return Q.filter(t=>ko(t)===e).map(e=>[Ao(e),e.name])}function To(){return Q.filter(e=>Oo(e)).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function Eo(e){return Co.has(e)}function Do(e){return e.mcpExposed??Co.has(e.name)}function Oo(e){return e.mcpExposed&&Eo(e.name)}function ko(e){return e.catalog.group}function Ao(e){return e.catalog.key??e.name}const jo=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),Mo=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function No(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Po(e){return No(e)!==void 0}function Fo(e){return No(e)===`settle-and-verify`}function Io(e){return e===void 0?j:jo.get(e)??j}function Lo(e){if(e!==void 0)return Mo.get(e)}function Ro(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function zo(e){return $.get(e)?.targetIdentityVerification}function Bo(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Vo(){return[...new Set(Array.from(Mo.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function Ho(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function Uo(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function Wo(t,n){if(!f(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function Go(t,n){let r=t.input;if(!f(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function Ko(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function qo(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Jo(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function Yo(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Xo=Yo(Q),Zo=new Set([`batch`,`replay`]),Qo=[`command`,`positionals`,`input`,`flags`,`runtime`],$o=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],es=new Set(Xo);function ts(e){return es.has(e)}function ns(e){return typeof e==`string`?e.trim().toLowerCase():``}function rs(t,n){let r=ns(t);if(ts(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function is(t,n){if(Zo.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const as=new Set(Qo);async function os(e,t,n){let r=ps(e.flags),a=r?.batchOnError??`stop`;if(a!==`stop`)return ms(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=r?.batchMaxSteps??100;if(!Ho(o))return ms(`INVALID_ARGS`,`Invalid batch max-steps: ${String(r?.batchMaxSteps)}`);try{let i=ss(r?.batchSteps,o),a=Date.now(),s=[];for(let[r,a]of i.entries()){let o=await fs(e,t,a,n,r+1,r===i.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,...o.error.retriable===void 0?{}:{retriable:o.error.retriable},...o.error.supportedOn===void 0?{}:{supportedOn:o.error.supportedOn},details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:r,total:i.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:i.length,executed:i.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=i(e);return ms(t.code,t.message,t.details)}}function ss(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);Uo(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!m(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!as.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=ns(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(is(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!m(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!m(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:Ko(i.runtime,n+1)})}return r}function cs(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return ls(ps(e),a)}function ls(e,t){let n=ps(e)??{},r=t;for(let e of $o)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function us(e,n){return t(e)?n?e:`digest`:e}function ds(e,t){let n=e?.responseLevel,r=us(n,t);return r===n?e:{...e,responseLevel:r}}async function fs(e,t,n,r,i,a){let o=Date.now(),s=cs(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:ds(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function ps(e){return e}function ms(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{Xi as $,Ye as $n,nr as $t,Ba as A,un as An,de as Ar,Nr as At,ya as B,yt as Bn,ye as Br,Er as Bt,Za as C,mn as Cn,we as Cr,ei as Ct,La as D,rn as Dn,ve as Dr,Hr as Dt,Ua as E,fn as En,xe as Er,Xr as Et,Na as F,Wt as Fn,ce as Fr,Mr as Ft,ma as G,Ct as Gn,mr as Gt,Aa as H,St as Hn,_r as Ht,Ha as I,Rt as In,oe as Ir,Dr as It,pa as J,ft as Jn,dr as Jt,R as K,ut as Kn,sr as Kt,Fa as L,C as Ln,se as Lr,wr as Lt,ja as M,Vt as Mn,le as Mr,Pr as Mt,Pa as N,zt as Nn,ae as Nr,Lr as Nt,Ra as O,ln as On,_e as Or,Ur as Ot,Ma as P,Ht as Pn,ie as Pr,Ir as Pt,Qi as Q,Xe as Qn,er as Qt,Ea as R,wt as Rn,re as Rr,Cr as Rt,zo as S,_n as Sn,g as Sr,$r as St,Xa as T,pn as Tn,Se as Tr,Zr as Tt,ba as U,xt as Un,hr as Ut,Oa as V,vt as Vn,f as Vr,Or as Vt,ha as W,bt as Wn,A as Wt,la as X,Ze as Xn,rr as Xt,oa as Y,Ge as Yn,fr as Yt,ea as Z,qe as Zn,ar as Zt,To as _,In as _n,ke as _r,F as _t,Jo as a,Wn as an,Ie as ar,Vi as at,Lo as b,dn as bn,Ee as br,Qr as bt,Ho as c,Un as cn,Ve as cr,Ii as ct,Wo as d,An as dn,Pe as dr,Fi as dt,ir as en,Qe as er,Ji as et,Q as f,jn as fn,Me as fr,Si as ft,wo as g,Pn as gn,v as gr,mi as gt,Vo as h,Cn as hn,y as hr,yi as ht,rs as i,Vn as in,Be as ir,Wi as it,Va as j,Ot as jn,ue as jr,Fr as jt,Wa as k,cn as kn,m as kr,Br as kt,Ko as l,xn as ln,Ne as lr,Li as lt,Fo as m,wn as mn,je as mr,wi as mt,os as n,$n as nn,He as nr,Ki as nt,qo as o,Bn as on,Le as or,Hi as ot,Po as p,Tn as pn,Ae as pr,Ci as pt,fa as q,pt as qn,pr as qt,Xo as r,Hn as rn,b as rr,Ui as rt,Uo as s,zn as sn,Re as sr,zi as st,ls as t,Qn as tn,S as tr,qi as tt,Go as u,kn as un,ze as ur,Pi as ut,Bo as v,vn,Oe as vr,vi as vt,Ja as w,an as wn,_ as wr,ti as wt,Io as x,sn as xn,Ce as xr,ni as xt,Ro as y,T as yn,De as yr,xi as yt,va as z,Tt as zn,be as zr,Tr as zt};
|
|
@@ -29,8 +29,8 @@ type DeviceInfo = {
|
|
|
29
29
|
* The daemon renders it; it never re-derives degradation from node shapes.
|
|
30
30
|
*
|
|
31
31
|
* Defined here (the foundational snapshot type module) rather than in
|
|
32
|
-
* snapshot-quality.ts so SnapshotNode can reference it without a cyclic import;
|
|
33
|
-
* snapshot-quality.ts
|
|
32
|
+
* snapshot-quality/verdict.ts so SnapshotNode can reference it without a cyclic import;
|
|
33
|
+
* snapshot-quality/verdict.ts owns the validation logic.
|
|
34
34
|
*/
|
|
35
35
|
/**
|
|
36
36
|
* Which capture STRATEGY produced a snapshot, within one platform's plan —
|
|
@@ -146,7 +146,7 @@ type SnapshotState = {
|
|
|
146
146
|
/**
|
|
147
147
|
* Android: the capture is an occluding system surface (notification shade, quick settings)
|
|
148
148
|
* rather than app content. Consumers that surface this tree to the agent must disclose the
|
|
149
|
-
* occlusion (see
|
|
149
|
+
* occlusion (see core/android-system-surface-disclosure.ts).
|
|
150
150
|
*/
|
|
151
151
|
systemSurfaceOnly?: boolean;
|
|
152
152
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
2
|
-
`)){let e=t.trim();if(!e||
|
|
1
|
+
import{n 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 o(e,new WeakSet)}function o(e,n,r){if(e==null)return e;if(typeof e==`string`)return s(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=>o(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=o(a,n,r)}return i}function s(e,i){let a=e.trim();if(!a)return e;if(i&&t.test(i))return`[REDACTED]`;let o=c(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>u({key:t,separator:n,rawValue:r,offset:i,input:a})||l(r)?e:`${t}${n}[REDACTED]`),o===a?a.length>400?`${a.slice(0,200)}...<truncated>`:a:o}function c(e){return e.replace(i,e=>d(e)??e)}function l(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function u(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)):!1}catch{return!1}}function d(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 f=e({AppError:()=>h,KNOWN_APP_ERROR_CODES:()=>p,asAppError:()=>_,defaultHintForCode:()=>j,isAgentDeviceError:()=>v,normalizeAgentDeviceError:()=>y,normalizeError:()=>b,retriableForErrorCode:()=>A,throwDaemonError:()=>g,toAppErrorCode:()=>m});const p=[`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 m(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}var h=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function g(e){throw new h(m(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,retriable:e.retriable,supportedOn:e.supportedOn})}function _(e,t=`UNKNOWN`){return e instanceof h?e:e instanceof Error?new h(t,e.message,void 0,e):new h(t,`Unknown error`,{err:e})}function v(e){return e instanceof h}function y(e,t={}){return b(e,t)}function b(e,t={}){let n=_(e),r=n.details?a(n.details):void 0,i=T(r,`diagnosticId`)??t.diagnosticId,o=T(r,`logPath`)??t.logPath,s=T(r,`hint`)??j(n.code),c=E(r,`retriable`)??A(n.code),l=T(r,`supportedOn`),u=D(r),d=ee(n.code,n.message,r);return{code:n.code,message:d,hint:s,diagnosticId:i,logPath:o,...c===void 0?{}:{retriable:c},...l===void 0?{}:{supportedOn:l},details:u}}const x=/^\S+ exited with code -?\d+$/;function ee(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=w(typeof n?.stderr==`string`?n.stderr:``);return r?x.test(t)?r:t.includes(r)?t:`${t}: ${r}`:t}const S=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i],C=/^(?:(?:adb|xcrun|simctl):\s*)?(?:error:\s*)?/i;function w(e){for(let t of e.split(`
|
|
2
|
+
`)){let e=t.trim();if(!e||S.some(t=>t.test(e)))continue;let n=e.replace(C,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function T(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function D(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const O={DEVICE_IN_USE:!0};function k(e){return p.includes(e)}function A(e){return k(e)?O[e]:void 0}function j(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 M(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function N(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}function P(e){return e.map((e,t)=>({...e,ref:`e${t+1}`}))}const F=/^~s(\d+)$/,I=`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 L(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=F.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function R(e){let t=L(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function z(e,t){return e.find(e=>e.ref===t)??null}function B(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 V(e){if(e)return{depth:e.snapshotDepth,interactiveOnly:e.snapshotInteractiveOnly,raw:e.snapshotRaw,scope:e.snapshotScope,customActions:e.snapshotCustomActions}}function H(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const U=[`summary`,`headers`,`body`,`all`],W=[`digest`,`default`,`full`];function G(e){return e!==void 0&&e!=="default"}function K(e){return{parse(t){return e(t,`$`)}}}function q(e,t){throw Error(`${e}: ${t}`)}function J(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&q(t,`Expected an object`),e}function Y(e,t){return typeof e!=`string`&&q(t,`Expected a string`),e}function X(e,t){return Number.isInteger(e)||q(t,`Expected an integer`),e}function Z(e,t){return Array.isArray(e)||q(t,`Expected an array`),e}function Q(e,t,n){let r=e[t];return r===void 0?void 0:Y(r,`${n}.${t}`)}function te(e,t,n){let r=e[t];if(r!==void 0)return Z(r,`${n}.${t}`).map((e,r)=>Y(e,`${n}.${t}[${String(r)}]`))}function ne(e,t,n){let r=e[t];return r===void 0?void 0:X(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:J(r,`${n}.${t}`)}function re(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&q(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const ie=K((e,t)=>{let n=J(e,t);return{platform:re(n,`platform`,[`ios`,`android`],t),metroHost:Q(n,`metroHost`,t),metroPort:ne(n,`metroPort`,t),bundleUrl:Q(n,`bundleUrl`,t),launchUrl:Q(n,`launchUrl`,t)}});function ae(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&q(`${t}.id`,`Expected a string, number, or null`),n}const oe=K((e,t)=>{let n=J(e,t);return{jsonrpc:Q(n,`jsonrpc`,t),id:ae(n,t),method:Q(n,`method`,t),params:n.params}}),se=K((e,t)=>{let n=J(e,t);return{token:Q(n,`token`,t),session:Q(n,`session`,t),command:Q(n,`command`,t),positionals:te(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{b as C,a as D,m as E,y as S,g as T,h as _,G as a,f as b,P as c,z as d,M as f,N as g,L as h,ie as i,B as l,V as m,W as n,oe as o,R as p,se as r,I as s,U as t,H as u,_ as v,A as w,v as x,j as y};
|
package/dist/src/sdk-device.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return e===`apple`||e===`ios`||e===`macos`}function p(e){return e.appleOs===`macos`||e.platform===`macos`}function m(e){return f(e.platform)&&!p(e)}function h(e){return e.platform===`android`||e.platform===`harmonyos`||f(e.platform)&&!p(e)}function g(e){return f(e.platform)?p(e)?`macos`:`ios`:e.platform}function _(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function v(e){return f(e.platform)&&e.target===`tv`}function y(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:v(e)?`tvos`:`ios`}function b(e){return c.includes(e)}function x(e){return l.includes(e)}function S(e){return s.includes(e)}function C(e,t){return t?t===`apple`?f(e.platform):t===`ios`?f(e.platform)&&!p(e):t===`macos`?f(e.platform)&&p(e):e.platform===t:!0}function w(e,t){return t?T(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function T(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function E(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function D(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return e===`apple`||e===`ios`||e===`macos`}function p(e){return e.appleOs===`macos`||e.platform===`macos`}function m(e){return f(e.platform)&&!p(e)}function h(e){return e.platform===`android`||e.platform===`harmonyos`||f(e.platform)&&!p(e)}function g(e){return f(e.platform)?p(e)?`macos`:`ios`:e.platform}function _(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function v(e){return f(e.platform)&&e.target===`tv`}function y(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:v(e)?`tvos`:`ios`}function b(e){return c.includes(e)}function x(e){return l.includes(e)}function S(e){return s.includes(e)}function C(e,t){return t?t===`apple`?f(e.platform):t===`ios`?f(e.platform)&&!p(e):t===`macos`?f(e.platform)&&p(e):e.platform===t:!0}function w(e,t){return t?T(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function T(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function E(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function D(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>H(e,t)).map(({device:e})=>e)}function O(e){return!e||e===`apple`||e===`ios`}async function k(e,t,n={}){let r=e.filter(e=>I(e,t));return A(r,t)||N(r,t.deviceName)||(G(r)&&(r=D(r)),P(r,t,n))}function A(e,t){if(t.udid)return j(e,t.udid);if(t.serial)return M(e,t)}function j(t,n){let r=t.find(e=>e.id===n&&f(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n}`);return r}function M(t,n){let r=t.find(e=>e.id===n.serial&&R(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,z(n));return r}function N(t,n){if(!n)return;let r=V(n),i=t.find(e=>V(e.name)===r);if(!i)throw new e(`DEVICE_NOT_FOUND`,`No device named ${n}`);return i}function P(e,t,n){let r=e[0];if(r!==void 0&&e.length===1)return r;e.length===0&&B(t,n);let i=F(e);return i||B(t,n),i}function F(e){let t=e.filter(e=>e.kind!==`device`),n=t.length>0?t:e;if(G(n))return n[0];let r=n.filter(e=>e.booted),i=r[0];return i&&r.length===1?i:r[0]??n[0]}function I(e,t,n={}){return C(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||L(e,t))}function L(e,t){return!(t.udid&&!(e.id===t.udid&&f(e.platform))||t.serial&&!(e.id===t.serial&&R(e.platform))||t.deviceName&&V(e.name)!==V(t.deviceName))}function R(e){return e===`android`||e===`harmonyos`||e===`vega`}function z(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:e.platform===`harmonyos`?`No HarmonyOS device with serial ${e.serial}`:`No Android, HarmonyOS device, or Vega VVD with serial ${e.serial}`}function B(t,n){let r=n.simulatorSetPath;throw r&&O(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function V(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function H(e,t){return U(e.device)-U(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function U(e){return e.kind===`simulator`?W(e,0,1,2,3):e.kind===`device`&&f(e.platform)&&!p(e)?W(e,10,11,12,13):14}function W(e,t,n,r,i){return{mobile:K(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function G(e){return e.length>0&&e.every(e=>f(e.platform))}function K(e){return/\bipad\b/i.test(e)}export{n as C,a as D,i as E,D as S,t as T,g as _,_ as a,k as b,m as c,b as d,x as f,C as g,I as h,l as i,p as l,v as m,c as n,S as o,R as p,u as r,f as s,d as t,h as u,w as v,r as w,y as x,E as y};
|
package/dist/src/sdk-finders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pn as e}from"./sdk-batch-runner.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
|
package/dist/src/sdk-io.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import n from"node:path";import{promises as r}from"node:fs";import i from"node:os";var a=e({createLocalArtifactAdapter:()=>o});function o(e={}){let a=e.cwd??process.cwd(),o=e.tempDir??i.tmpdir(),c=e.rootDir?s(e.rootDir,a):void 0;return{resolveInput:async e=>{if(e.kind===`uploadedArtifact`)throw new t(`UNSUPPORTED_OPERATION`,`Uploaded artifact inputs require a custom artifact adapter`);return{path:s(e.path,a,c)}},reserveOutput:async(e,t)=>{let i,l=t.visibility??`client-visible`,u=e?.kind===`path`?s(e.path,a,c):n.join(i=await r.mkdtemp(n.join(o,`agent-device-${t.field}-`)),`${t.field}${t.ext}`);return await r.mkdir(n.dirname(u),{recursive:!0}),{path:u,visibility:l,...i?{cleanup:async()=>{await r.rm(i,{recursive:!0,force:!0})}}:{},publish:async()=>e?.kind===`downloadableArtifact`?{kind:`localPath`,field:t.field,artifactType:t.artifactType,path:u,fileName:e.fileName??n.basename(e.clientPath??u)}:void 0}},createTempFile:async e=>{let t=await r.mkdtemp(n.join(o,`${e.prefix}-`));return{path:n.join(t,`file${e.ext}`),visibility:`internal`,cleanup:async()=>{await r.rm(t,{recursive:!0,force:!0})}}}}}function s(e,r,i){let a=n.isAbsolute(e)?e:n.resolve(r,e);if(i&&!c(a,i))throw new t(`INVALID_ARGS`,`Local path is outside the artifact adapter root`,{path:a,rootDir:i});return a}function c(e,t){let r=n.relative(t,e);return r===``||!r.startsWith(`..`)&&!n.isAbsolute(r)}export{a as n,o as t};
|
|
@@ -508,6 +508,24 @@ type FindCommandResponseData = {
|
|
|
508
508
|
cost?: ResponseCost;
|
|
509
509
|
};
|
|
510
510
|
//#endregion
|
|
511
|
+
//#region packages/selectors/src/internal/parse.d.ts
|
|
512
|
+
type SelectorKey = 'id' | 'role' | 'text' | 'label' | 'value' | 'appname' | 'windowtitle' | 'visible' | 'hidden' | 'editable' | 'selected' | 'focused' | 'enabled' | 'hittable';
|
|
513
|
+
type SelectorTerm = {
|
|
514
|
+
key: SelectorKey;
|
|
515
|
+
value: string | boolean;
|
|
516
|
+
};
|
|
517
|
+
type Selector = {
|
|
518
|
+
raw: string;
|
|
519
|
+
terms: SelectorTerm[];
|
|
520
|
+
};
|
|
521
|
+
type SelectorChain = {
|
|
522
|
+
raw: string;
|
|
523
|
+
selectors: Selector[];
|
|
524
|
+
};
|
|
525
|
+
declare function parseSelectorChain(expression: string): SelectorChain;
|
|
526
|
+
declare function tryParseSelectorChain(expression: string): SelectorChain | null;
|
|
527
|
+
declare function isSelectorToken(token: string): boolean;
|
|
528
|
+
//#endregion
|
|
511
529
|
//#region packages/selectors/src/internal/public-resolution-types.d.ts
|
|
512
530
|
/** One per-alternative diagnostic returned by selector resolution. */
|
|
513
531
|
type SelectorDiagnostics = {
|
|
@@ -539,24 +557,6 @@ type SelectorResolutionOptions = SelectorMatchOptions & {
|
|
|
539
557
|
disambiguateAmbiguous?: boolean;
|
|
540
558
|
};
|
|
541
559
|
//#endregion
|
|
542
|
-
//#region packages/selectors/src/internal/parse.d.ts
|
|
543
|
-
type SelectorKey = 'id' | 'role' | 'text' | 'label' | 'value' | 'appname' | 'windowtitle' | 'visible' | 'hidden' | 'editable' | 'selected' | 'focused' | 'enabled' | 'hittable';
|
|
544
|
-
type SelectorTerm = {
|
|
545
|
-
key: SelectorKey;
|
|
546
|
-
value: string | boolean;
|
|
547
|
-
};
|
|
548
|
-
type Selector = {
|
|
549
|
-
raw: string;
|
|
550
|
-
terms: SelectorTerm[];
|
|
551
|
-
};
|
|
552
|
-
type SelectorChain = {
|
|
553
|
-
raw: string;
|
|
554
|
-
selectors: Selector[];
|
|
555
|
-
};
|
|
556
|
-
declare function parseSelectorChain(expression: string): SelectorChain;
|
|
557
|
-
declare function tryParseSelectorChain(expression: string): SelectorChain | null;
|
|
558
|
-
declare function isSelectorToken(token: string): boolean;
|
|
559
|
-
//#endregion
|
|
560
560
|
//#region packages/selectors/src/internal/resolve.d.ts
|
|
561
561
|
/**
|
|
562
562
|
* The parser-side twin of the façade's `SelectorResolution`: identical except
|
|
@@ -574,7 +574,11 @@ type AstSelectorResolution = {
|
|
|
574
574
|
disambiguation?: SelectorDisambiguationDisclosure;
|
|
575
575
|
};
|
|
576
576
|
declare function resolveSelectorChain(nodes: SnapshotState['nodes'], chain: SelectorChain, options: SelectorResolutionOptions): AstSelectorResolution | null;
|
|
577
|
-
/**
|
|
577
|
+
/**
|
|
578
|
+
* A first-match lookup used by existence checks. No façade twin: the root
|
|
579
|
+
* façade resolves through the policy interface only, so this shape reaches
|
|
580
|
+
* consumers via the published `./ast` surface alone (#1630).
|
|
581
|
+
*/
|
|
578
582
|
type AstSelectorChainMatch = {
|
|
579
583
|
selectorIndex: number;
|
|
580
584
|
selector: Selector;
|
|
@@ -598,4 +602,4 @@ declare function formatSelectorFailure(chain: SelectorChain | string, diagnostic
|
|
|
598
602
|
unique?: boolean;
|
|
599
603
|
}): string;
|
|
600
604
|
//#endregion
|
|
601
|
-
export { SessionSurface as C, BackMode as D, ClickButton as E, SnapshotDiagnosticsSummary as S, DeviceRotation as T, Interactor as _, resolveSelectorChain as a, FindLocator as b,
|
|
605
|
+
export { SessionSurface as C, BackMode as D, ClickButton as E, SnapshotDiagnosticsSummary as S, DeviceRotation as T, Interactor as _, resolveSelectorChain as a, FindLocator as b, isSelectorToken as c, ClickCommandResponseData as d, FillCommandResponseData as f, SettleObservation as g, PressCommandResponseData as h, findSelectorChainMatch as i, parseSelectorChain as l, LongPressCommandResponseData as m, isNodeEditable as n, SelectorDiagnostics as o, FindCommandResponseData as p, isNodeVisible as r, SelectorChain as s, formatSelectorFailure as t, tryParseSelectorChain as u, RunnerContext as v, TvRemoteButton as w, ScreenshotResultData as x, AndroidSnapshotBackendMetadata as y };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{an as e}from"./sdk-batch-runner.js";function t(t,n,r){return e(typeof t==`string`?t:t.raw,n,r)}export{t};
|
package/dist/src/sdk.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime.js";import t from"node:path";import{promises as n}from"node:fs";import r from"node:os";var i=e({ensureAndroidSdkPathConfigured:()=>l,resolveAndroidSdkRoots:()=>s});const a=[`emulator`,`platform-tools`,t.join(`cmdline-tools`,`latest`,`bin`),t.join(`cmdline-tools`,`tools`,`bin`)];function o(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function s(e=process.env){let n=e.ANDROID_SDK_ROOT?.trim(),i=e.ANDROID_HOME?.trim(),a=e.HOME?.trim()||r.homedir(),s=a?t.join(a,`Android`,`Sdk`):``;return o([n??``,i??``,s])}async function c(e){try{return await n.access(e,n.constants.X_OK),!0}catch{return!1}}async function l(e=process.env){let n=[],r;for(let i of s(e)){let e=[];for(let n of a){let r=t.join(i,n);await c(r)&&e.push(r)}e.length!==0&&(r||=i,n.push(...e))}if(r&&(e.ANDROID_SDK_ROOT=e.ANDROID_SDK_ROOT?.trim()||r,e.ANDROID_HOME=e.ANDROID_HOME?.trim()||r),n.length===0)return;let i=(e.PATH??``).split(t.delimiter).map(e=>e.trim()).filter(e=>e.length>0);e.PATH=o([...n,...i]).join(t.delimiter)}export{i as n,s as t};
|