agent-device 0.21.22 → 0.21.24
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 +6 -6
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.22.apk → agent-device-android-ime-helper-0.21.24.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.24.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.22.manifest.json → agent-device-android-ime-helper-0.21.24.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.24.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.24.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.22.manifest.json → agent-device-android-snapshot-helper-0.21.24.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +12 -6
- package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/RectResponseTests.swift +21 -0
- package/apple/snapshot-bridge/README.md +9 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +56 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +14 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +29 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +34 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +19 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +3 -3
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +3 -2
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/app-backend.js +1 -1
- package/dist/src/app-inventory.d.ts +4 -0
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state-runtime.d.ts +15 -0
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/aws-device-farm-connection.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/browserstack-connection.js +1 -0
- package/dist/src/browserstack-device-features.js +1 -0
- package/dist/src/browserstack.js +1 -0
- package/dist/src/cache.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +35 -19
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +3 -4
- package/dist/src/client-companion-tunnel.js +1 -0
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-options.js +3 -3
- package/dist/src/client-types.d.ts +7 -5
- package/dist/src/cloud-artifacts.d.ts +9 -2
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-tools.js +2 -2
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection-verification.js +1 -0
- package/dist/src/connection.js +5 -5
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-http.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-input-state.d.ts +2 -15
- package/dist/src/device-readiness-runtime.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +3 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/device3.js +1 -1
- package/dist/src/dispatch-resolve.js +3 -3
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/format.js +2 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +2 -5
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/human-control.js +1 -1
- package/dist/src/ime-rebind.js +1 -0
- package/dist/src/ime-settings-record.js +1 -0
- package/dist/src/ime-state.js +1 -0
- package/dist/src/index.d.ts +3 -3
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/instance-client.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-client.js +4 -4
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun.d.ts +4 -555
- package/dist/src/load.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/log-stream.js +33 -0
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/manifest.js +1 -0
- package/dist/src/mechanics.js +16 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/node-http.js +1 -0
- package/dist/src/observation.js +1 -2
- package/dist/src/overlay.js +3 -3
- package/dist/src/owner-identity.js +3 -3
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plugin.js +1 -0
- package/dist/src/plugins/webdriver.d.ts +111 -0
- package/dist/src/plugins/webdriver.js +1 -0
- package/dist/src/plugins.d.ts +2 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/process-exit.js +1 -1
- package/dist/src/process.js +1 -1
- package/dist/src/provider-credential-fingerprint.js +1 -1
- package/dist/src/provider-device-admission.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +556 -0
- package/dist/src/provider-policy.js +1 -0
- package/dist/src/provider-profile-fields.js +1 -1
- package/dist/src/provider-webdriver.js +1 -2
- package/dist/src/providers.js +1 -1
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-devtools.js +2 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/registry.js +24 -24
- package/dist/src/remote-bridge.js +1 -0
- package/dist/src/remote-config-core.js +1 -0
- package/dist/src/remote-config.js +1 -1
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/remote-connection-state.js +1 -0
- package/dist/src/replay.js +2 -2
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/retry.js +1 -1
- package/dist/src/retry2.js +1 -0
- package/dist/src/runner-artifact-manifest.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -3
- package/dist/src/runner-cache-retention.js +1 -0
- package/dist/src/runner-cache-trim.js +1 -0
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-device-set.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +1 -1
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-lease.js +1 -0
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-session-types.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-toolchain-probe.js +2 -0
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-deployment.js +1 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +1 -2
- package/dist/src/runtime11.js +2 -0
- package/dist/src/runtime2.js +2 -5
- package/dist/src/runtime3.js +5 -1
- package/dist/src/runtime4.js +1 -5
- package/dist/src/runtime5.js +5 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-overlay-draw.js +1 -1
- package/dist/src/screenshot3.js +2 -2
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +25 -33
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +4 -0
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-private-evidence.js +1 -0
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +1 -1
- package/dist/src/src4.js +1 -1
- package/dist/src/src5.js +1 -1
- package/dist/src/src6.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +20 -20
- package/dist/src/store.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +1 -1
- package/package.json +24 -16
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.22.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.22.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.22.apk.sha256 +0 -1
- package/dist/src/capabilities.js +0 -1
- package/dist/src/compatibility-policy.js +0 -1
- package/dist/src/daemon-artifacts.js +0 -1
- package/dist/src/device-claim-rule.js +0 -1
- package/dist/src/human-control-contract.js +0 -1
- package/dist/src/prepare-kind.js +0 -1
- package/dist/src/provider-device-runtimes.js +0 -1
- package/dist/src/screen-recording-admission-ledger.js +0 -1
- package/dist/src/screenshot-runtime.js +0 -1
- package/dist/src/session-routing.js +0 -1
- package/dist/src/session-runtime-admission.js +0 -1
- package/dist/src/session-stream.js +0 -27
- package/dist/src/timeouts.js +0 -1
- package/dist/src/touch-reference-frame.js +0 -1
- package/dist/src/vars.js +0 -2
- package/dist/src/viewport.js +0 -1
package/dist/src/sdk-batch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{P as e,S as t,b as n}from"./sdk-contracts.js";import{
|
|
2
|
-
`],[`r`,`\r`],[`t`,` `]]);function v(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=ze(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Le(e))}}function y(e){try{return v(e)}catch{return null}}function b(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return _.has(e)}return _.has(t.toLowerCase())}function Ie(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||_.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=S(i).trim();return a?{key:r,value:a}:null}function x(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!b(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&y(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function Le(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Be(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Re)}}function Re(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(!je.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!_.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(je.has(i)){let t=We(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:S(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===`'`)&&!Ge(t,a)){i=Ve(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 Be(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ge(t,e)){i=Ve(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 Ve(e,t){return e?e===t?null:e:t}function S(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?He(t.slice(1,-1)):t}function He(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=Ue(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 Ue(e){return Fe.get(e)??null}function We(e){let t=S(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ge(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function C(e){return o.includes(e)}const Ke=`is requires predicate: ${o.join(`|`)}`;function qe(e){let t=e.toLowerCase();return C(t)?{ok:!0,predicate:t}:a(Ke,Je)}const Je=`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 Ye(e){if(C((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(C(n)&&y(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function Xe(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=m(n),s=Oe(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):Qe(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break;default:return Ze(t)}let ee=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:ee}}function Ze(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function Qe(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(l(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=$e(e,t,n);return r?l(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function $e(e,t,n){return t.findAncestor(e,e=>De(e,n)?e:null)}function et(e){let t=Ye(e),n=t[0]??``;return{predicate:n,split:x(t.slice(1),{preferTrailingValue:n===`text`})}}const tt=`is requires a selector expression`,nt=`is text requires expected text value`;function rt(e){let{predicate:t,split:n}=et([...e]),r=qe(t);if(!r.ok)return r;if(!n)return a(tt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?a(nt):r.predicate!==`text`&&n.rest.length>0?a(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function it(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:a(`get only supports text or attrs`)}function at(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}:a(`get requires @ref or selector expression`)}function ot(e){return e?{ok:!0,text:e}:a(`wait requires text`)}function st(e){return Array.from(new Set(e))}function ct(e){return JSON.stringify(lt(e))}function lt(e){if(Array.isArray(e))return e.map(lt);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,lt(t[e])]))}function ut(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t+=1;for(;n>t&&e[n-1]===`-`;)--n;return e.slice(t,n)}const dt=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,ft=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,pt=4096;function mt(e){return e.normalize(`NFC`)}function ht(e){if(e===void 0)return;let t=mt(e);return t.length>0?t:void 0}function gt(e){return mt(e)}function _t(e){if(e===void 0)return;let t=mt(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function w(e){return Buffer.byteLength(e,`utf8`)}function T(e,t){if(w(e)<=t)return e;let n=e.length;for(;n>0&&w(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 vt(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(yt),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=bt(e.scrollRegion)),e.rect&&(t.rect=xt(e.rect)),t.verification=e.verification,t}function yt(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function bt(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 xt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function St(e){return JSON.stringify(vt(e))}function Ct(e){return`# agent-device:target-v1 ${St(e)}`}function wt(e){return JSON.stringify({source:vt(e.source),destination:vt(e.destination)})}function Tt(e){return`# agent-device:targets-v1 ${wt(e)}`}function Et(e){let t=e.trim(),n=ft.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Dt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Dt(t){if(w(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:kt(JSON.stringify(r.source)),destination:kt(JSON.stringify(r.destination))}}function Ot(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=dt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:kt((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function kt(t){if(w(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${pt}-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=At(r.role,`role`),a=jt(r.id,`id`),o=Mt(r.label,`label`),s=Pt(r.ancestry),c=It(r.sibling,`sibling`,0),l=It(r.viewportOrder,`viewportOrder`,0),u=Lt(r.scrollRegion),d=Rt(r.rect),ee=zt(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:ee}}function At(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 Nt(gt(t),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=ht(t);return r===void 0?void 0:Nt(r,n)}function Mt(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=_t(t);return r===void 0?void 0:Nt(r,n)}function Nt(t,n){if(w(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Pt(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)=>Ft(e,t))}function Ft(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=At(r.role,`ancestry[${n}].role`),a=Mt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function It(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 Lt(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=At(n.role,`scrollRegion.role`),i=jt(n.id,`id`),a=Mt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function Rt(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:E(n.x,`rect.x`),y:E(n.y,`rect.y`),width:E(n.width,`rect.width`),height:E(n.height,`rect.height`)}}function E(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function zt(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function Bt(e){let t=gt(p(e.type??``)),n=ht(e.identifier),r=_t(e.label);return{...n===void 0?{}:{id:T(n,256)},role:T(t,256),...r===void 0?{}:{label:T(r,256)}}}function Vt(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Ht(e,t){let n=0;for(let r of e)Bt(r).id===t&&(n+=1);return n}function Ut(e,t){if(e.id===void 0||Ht(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Wt(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 Gt(e,t){return{documentOrder:e.index,sibling:Wt(t,e)}}function Kt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function qt(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Jt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Yt(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 Xt(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 Zt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Qt(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function $t(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Qt(r,e))return[`ancestry[${n}]: recorded=${Zt(r)} observed=${Zt(e)}`]}return[]}function en(e,t,n={}){let r=[],i=p(e.type??``),a=tn(e,n.nodes),o=O(e.label),s=O(e.value),c=O(m(e)),l=n.action===`fill`;a&&r.push(`id=${D(a)}`),i&&o&&r.push(l?`role=${D(i)} label=${D(o)} editable=true`:`role=${D(i)} label=${D(o)}`),o&&r.push(l?`label=${D(o)} editable=true`:`label=${D(o)}`),s&&r.push(l?`value=${D(s)} editable=true`:`value=${D(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${D(c)} editable=true`:`text=${D(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${D(i)} editable=true`);let u=st(r);return u.length===0&&i&&u.push(l?`role=${D(i)} editable=true`:`role=${D(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function tn(e,t){let n=O(e.identifier);if(!n||!t)return n;let r=Bt(e).id;return r===void 0?n:Ht(t,r)>1?null:n}function D(e){return JSON.stringify(e)}function O(e){return e&&e.trim()||null}const nn=[`any`,`text`,`label`,`value`,`role`,`id`],rn=[`text`,`label`,`value`,`role`,`id`];function an(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function on(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function sn(e,t,n,r={}){let i=A(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=cn(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 cn(e,t,n){switch(t){case`role`:return ln(e,n);case`label`:return k(e.label,n);case`value`:return k(e.value,n);case`id`:return k(e.identifier,n);default:return Math.max(k(e.label,n),k(e.value,n),k(e.identifier,n))}}function k(e,t){let n=A(e??``);return n?n===t?2:+!!n.includes(t):0}function ln(e,t){let n=ke(e);return n.some(e=>A(e)===t)?2:+!!n.some(e=>un(e).includes(t))}function un(e){let t=e.lastIndexOf(`.`);return t===-1?e:e.slice(t+1)}function A(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}const dn=`find requires a value`,fn=`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 pn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=gn([...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:dn}}const mn=[`exists`,`list`,`click`,`focus`];function hn(e){return mn.includes(e)}function gn(t){let n=`any`,r=0;rn.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=an(a[0]);if(hn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:_n(a[1])};if(o===`wait`){let e=yn(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:fn})}function _n(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 vn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:y(t)?t:null}function yn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function bn(e,t,n){return t.terms.every(t=>xn(e,t,n))}function xn(e,t,n){switch(t.key){case`id`:return j(e.identifier,String(t.value));case`role`:return Sn(e,String(t.value));case`label`:return j(e.label,String(t.value));case`value`:return j(e.value,String(t.value));case`text`:return j(m(e),String(t.value));case`appname`:return j(e.appName,String(t.value));case`windowtitle`:return j(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return Oe(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function j(e,t){return A(e??``)===A(t)}function Sn(e,t){let n=A(t);return ke(e).some(e=>A(e)===n)}function Cn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[],o=null;for(let[s,c]of t.selectors.entries()){let t=An(e,c,n.platform,r);if(a.push({selector:c.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(o??={selector:c,selectorIndex:s,matchedNodes:t.candidates},i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.disambiguated,selector:c,selectorIndex:s,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}}return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.firstNode,selector:c,selectorIndex:s,matches:t.count,diagnostics:a}}}}return{resolution:null,matchedNodes:o?.matchedNodes??[],firstMatch:o}}function wn(e,t,n){return Cn(e,t,n).resolution}function Tn(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:bn(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function En(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Pn(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 Dn=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function On(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 kn(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 An(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=be(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||bn(l,t,n)&&(i+=1,a??=l,o.push(l),jn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:Mn(o,s.best,c),candidates:o}}function jn(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=Fn(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function Mn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Nn(i,r,n).result>0)&&(r=i);return r?Nn(t,r,n).criterion:null}function Nn(e,t,n){let r=n(e);return r===n(t)?Fn(e,t):{result:r?1:-1,criterion:`visible`}}function Pn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||bn(a,t,n)&&(i+=1);return i}function Fn(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=In(e),a=In(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function In(e){return e.rect?e.rect.width*e.rect.height:1/0}const Ln={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1},cropTarget:{ambiguity:`fail-closed`,requireRect:!0}};function Rn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function zn(e,t){let n=e===`is`?et([...t]).split:x([...t]);return n?y(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Bn(e){return{platform:e.platform,...Rn({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function Vn(e,t,n){let r=y(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=Cn(t,r,Bn(n));return i?{kind:`resolved`,winner:i.node,matchedNodes:a,matchCount:a.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}:{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function Hn(e,t,n={}){return en(e,t,n)}function Un(e,t,n){let r=y(e);if(!r)return;let i=wn(t,r,Bn(n));if(i)return{node:i.node,basis:Gn(i.selector)}}function Wn(e){if(!e)return;let t=y(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Gn(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 Kn(e,t){let n=y(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?qn(n.selectors,r,i):Jn(n.selectors[0],r,new Set(t.booleanKeys),i)}function qn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Yn(r.key,t,n)&&typeof r.value==`string`?r.value:void 0}),i=r[0];return i!==void 0&&r.every(e=>e===i)?i:null}function Jn(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Yn(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Xn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Yn(e,t,n){return t.has(e)||n[e]!==void 0}function Xn(e,t,n){return t.has(e.key)&&typeof e.value===n}function Zn(e){let t=y(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function Qn(e,t){if(!t)return!1;let n=y(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function $n(e,t){return y(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function er(e){return v(e).selectors.map(e=>e.raw)}function tr(e){return y(e)!==null}function nr(e){v(e)}function M(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const rr=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function ir(e){let t=e[0];if(t===void 0)return null;let n=M(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=M(e.at(-1));return t===`text`?ar(e,r):t===`stable`?or(e):t===`absent`?sr(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:lr(e,r)}function ar(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function or(e){let t=e.slice(1),n=t.length>1?M(t[1]):null;return{kind:`stable`,quietMs:t.length>0?M(t[0]):null,timeoutMs:n}}function sr(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=x(n);return n.length>0&&r?.rest.length===0&&tr(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:cr(n)}}function cr(e){let t=e.join(` `);return t.length>0?`wait absent requires one valid selector; received "${t}". Use wait absent '<selector>' [timeoutMs].`:`wait absent requires <selector> [timeoutMs].`}function lr(e,t){let n=t===null?e.slice():e.slice(0,-1),r=x(n);return r&&r.rest.length===0&&tr(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:ur(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function ur(e,t){for(let t of e){let n=Ie(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:dr(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:fr(t,e)}:e.some(e=>b(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:pr(e)}:null}function dr(e,t){let n=t.join(` `),r=Pe(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${Me.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function fr(e,t){let n=t.join(` `);return`Selector ${e.selectorExpression} is followed by unexpected extra arguments: "${e.rest.join(` `)}". Selector values with spaces need quotes, e.g. label="Sign in". Use wait '<selector>' [timeoutMs], or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function pr(e){let t=e.join(` `),n=e.filter(e=>!b(e)),r=e.filter(e=>b(e));if(n.length>0){let e=n[0],i=rr.has(e.toLowerCase())?` "${e}" describes a condition, not a selector key. Use the selector form: `+(e.toLowerCase()===`gone`||e.toLowerCase()===`disappears`?`wait absent '${r.join(` `)}' [timeoutMs] to wait for zero matches.`:`wait '${r.join(` `)}' [timeoutMs] to wait for it to appear.`):` "${e}" is not a recognized selector key (${Me.join(`, `)}).`;return`"${t}" mixes plain word "${e}" with selector-shaped "${r.join(` `)}", so it is neither a valid selector nor safe as literal text.${i} Use wait '<selector>' [timeoutMs] for a selector, or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}return`"${t}" looks like a selector key but is not a valid selector expression. Use wait '<selector>' [timeoutMs], e.g. wait '${e[0]}="value"' [timeoutMs], or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}function mr(e){let t=ir(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const hr=3e4,gr=24e4,_r=3e5,N={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},vr={budget:{source:`none`},envelopeMs:255e3,onTimeout:`reset-daemon`};function yr(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return(xr(n,t.positionals??[])??Sr(n,t.flags)??n.envelopeMs)+br(e,t.flags)}function br(e,t){if(e.targetReadiness!==`budgeted`)return 0;let n=t?.readinessTimeoutMs;return typeof n!=`number`||!Number.isInteger(n)||n<=0?0:Math.min(n,2e3)}function xr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:Tr(e,n)}function Sr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?wr(e,e.budget,t):e.budget.envelope===`margin`?Cr(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function Cr(e,t){let n=typeof t?.timeoutMs==`number`?Tr(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?Er({...e,envelopeMs:n},t.waitMs):n}function wr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?Er(e,r):e.envelopeMs}function Tr(e,t){return Math.max(e.envelopeMs,t+hr)}function Er(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+hr)}const Dr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function Or(e){if(e!==void 0)return Dr[e]}function P(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function kr(e){if(!r(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function Ar(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 jr(e){let t=e.trim();if(t.length===0)throw TypeError(`Managed local runtime owner requires a non-empty allocator instance identity`);return Object.freeze({kind:`managed-local`,instance:t})}function Mr(e){switch(e.kind){case`local-family`:return`local:${e.family}`;case`managed-local`:return`managed:${JSON.stringify([e.instance])}`;case`provider-runtime`:return`provider:${JSON.stringify([e.provider,e.instance])}`}}function Nr(e,t){return Mr(e)===Mr(t)}function Pr(e,t){return e.available?t():{}}function Fr(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!Lr(e.requestGeneration))throw TypeError(`Managed binding fence requires non-empty requester and identity incarnation ids and a non-negative integer request generation`);return Object.freeze({token:JSON.stringify([e.requesterId,e.identityIncarnationId]),generation:e.requestGeneration})}function Ir(e){let t=Rr(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!Lr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return Fr(i).token===e.token?i:null}function Lr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function Rr(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function zr(e,t){let n={},r={};for(let i of t.required){let t=Br(e.facts.operations,i);if(n[i]=t,!t.available)throw Gr(i,t);r[i]=Ur(e.operations,i)}for(let i of t.preferred){let t=Br(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Ur(e.operations,i))}for(let i of t.conditional??[]){let t=Br(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Ur(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function Br(e,t){let n=e[t];if(!Vr(n))throw P(`Runtime owner omitted the ${t} fact`);let r=Hr(n);if(r)return r;throw P(`Runtime owner returned an invalid ${t} fact`)}function Vr(e){return typeof e==`object`&&!!e&&`available`in e}function Hr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Wr(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 Ur(e,t){let n=e[t];if(typeof n!=`function`)throw P(`Runtime owner advertised ${t} without an implementation`);return n}function Wr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-device-scope`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function Gr(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function Kr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function qr(){return e=>{let t=Jr(e.required,`required`),n=Jr(e.preferred??[],`preferred`),r=Jr(e.conditional??[],`conditional`),i=[[`required`,t],[`preferred`,n],[`conditional`,r]];for(let e=0;e<i.length;e+=1){let t=i[e];if(t)for(let n of i.slice(e+1)){let e=n[1].find(e=>t[1].includes(e));if(e!==void 0)throw TypeError(`Runtime operation cannot be both ${t[0]} and ${n[0]}: ${e}`)}}return Object.freeze(r.length===0?{required:t,preferred:n}:{required:t,preferred:n,conditional:r})}}function Jr(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 I=qr(),Yr=I({required:[`bootTarget`]}),Xr=I({required:[`bootTargetHeadless`]}),Zr=I({required:[`ensureReady`,`listApps`]}),Qr=I({required:[`captureSnapshot`]}),$r=I({required:[`setViewport`]}),ei=I({required:[`focusPoint`]}),ti=I({required:[`typeText`]}),ni=I({required:[`back`]}),ri=I({required:[`home`]}),ii=I({required:[`setOrientation`]}),ai=I({required:[`setFoldPose`]}),oi=I({required:[`tvRemote`]}),si=I({required:[`keyboardStatus`]}),ci=I({required:[`keyboardDismiss`]}),li=I({required:[`keyboardEnter`]}),ui=I({required:[`appSwitcher`]}),di=I({required:[`actionButton`]}),fi=I({required:[`triggerAppEvent`]}),pi=I({required:[`setSetting`]}),mi=I({required:[`readSetting`]}),hi=I({required:[`readAlert`]}),gi=I({required:[`awaitAlert`]}),_i=I({required:[`acceptAlert`]}),vi=I({required:[`dismissAlert`]}),yi=I({required:[`readClipboard`]}),bi=I({required:[`writeClipboard`]}),xi=I({required:[`perfFrames`]}),Si=I({required:[`perfMemorySample`]}),Ci=I({required:[`perfMemorySnapshot`]}),wi=I({required:[`perfNativeCaptureStart`]}),Ti=I({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),Ei=I({required:[`perfProfileReport`]}),Di=Object.freeze([xi,Si,Ci,wi,Ti,Ei]),L=I({required:[`tapPoint`]}),Oi=I({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),ki=I({required:[`longPressPoint`]}),Ai=I({required:[`captureSnapshot`,`longPressPoint`]}),ji=I({required:[`hoverPoint`]}),Mi=I({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),Ni=I({required:[`fillPoint`]}),Pi=I({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),Fi=Object.freeze([L,Oi]),Ii=Fi,Li=Object.freeze([ki,Ai]),Ri=Object.freeze([ji,Mi]),zi=Object.freeze([Ni,Pi]);function Bi(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:Oi}:{kind:`tap-point`,use:L};case`fill`:return t?{kind:`captured-fill`,use:Pi}:{kind:`fill-point`,use:Ni};case`longpress`:return t?{kind:`captured-long-press`,use:Ai}:{kind:`long-press-point`,use:ki};case`hover`:return t?{kind:`captured-hover`,use:Mi}:{kind:`hover-point`,use:ji}}}const Vi=I({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Hi=I({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ui=I({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Wi=I({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),Gi=I({required:[`gestureViewport`]}),Ki=I({required:[`scrollDirection`],conditional:[`captureSnapshot`]}),qi=I({required:[`scrollDirection`,`captureSnapshot`]}),Ji=Object.freeze({plan:Vi,"directional-fling":Hi,"multi-touch":Ui,"target-authored-drag":Wi}),Yi=Object.freeze([Vi,Hi,Ui,Wi]),Xi=Object.freeze([Vi]),Zi=Object.freeze([Ki,qi]);function Qi(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function $i(e){return e.intent===`drag`?`target-authored-drag`:Qi(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function ea(e){let t=$i(e);switch(t){case`plan`:return R(t);case`directional-fling`:return R(t);case`multi-touch`:return R(t);case`target-authored-drag`:return R(t)}}function R(e){let t=Ji[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function ta(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Ki}):Object.freeze({kind:`edge`,edge:e.edge,use:qi}):Object.freeze({kind:`until`,until:e.until,use:qi})}const na=I({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),ra=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),ia=I({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),aa=I({required:[`captureSnapshot`]}),oa=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),sa=I({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),ca=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),la=I({required:[`captureSnapshot`],conditional:[`findText`]}),ua=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),da=Object.freeze([aa,oa]),fa=Object.freeze([sa,ca]),pa=I({required:[`captureSnapshot`,`focusPoint`]}),ma=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),ha=I({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),ga=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),_a=Object.freeze([sa,ca,aa,oa,pa,ma,ha,ga]),va=Object.freeze([la,ua]),ya=Object.freeze([Qr,na,ra,ia]),z=Object.freeze({"capture-only":da,"element-text":fa,"wait-observation":va,"find-focus":Object.freeze([pa,ma]),"find-type":Object.freeze([ha,ga])});function ba(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function xa(e){switch(e.intent){case`capture-only`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`element-text`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`wait-observation`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`find-focus`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`find-type`:return B(e.hasActiveApp,e.intent,z[e.intent])}}function B(e,t,n){return Object.freeze(e?{kind:`selector-active-app`,intent:t,operation:`captureSnapshot`,use:n[0]}:{kind:`selector-without-active-app`,intent:t,operation:`captureSnapshotWithoutActiveApp`,use:n[1]})}function Sa(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:na}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:ia}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:Qr}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:ra})}const Ca=I({required:[`captureScreenshot`]}),wa=I({required:[`captureScreenshot`,`captureSnapshot`]}),Ta=Object.freeze([Ca,wa]);function Ea(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:wa}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:wa}):Object.freeze({kind:`capture`,use:Ca})}const Da=Object.freeze([Yr,Xr]),Oa=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Yr}),ka=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Xr});function Aa(e){return e.headless?ka:Oa}const ja=I({required:[`ensureReady`,`appState`]}),Ma=Object.freeze([ja]),Na=I({required:[`shutdownTarget`]}),Pa=Object.freeze([yi,bi]),Fa=Object.freeze([pi,mi]),Ia=[`text-size`],La=Object.freeze({kind:`write`,use:pi});function Ra(e){let t=za(e?.[0]);return e?.length!==1||t===void 0?La:Ia.includes(t)?Object.freeze({kind:`read`,setting:t,use:mi}):La}function za(e){let t=e?.trim().toLowerCase();return Ia.find(e=>e===t)}const Ba=Object.freeze([hi,gi,_i,vi]),Va=Object.freeze([si,ci,li]),Ha=I({required:[`deployApp`]}),Ua=I({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),Wa=I({required:[`ensureReady`,`sendPushNotification`]}),Ga=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Ka=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),qa=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Ja=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Ya(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Ja}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Ka}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:qa}):Object.freeze({kind:`open`,use:Ga})}const Xa=Object.freeze([Ga,Ka,qa,Ja]),Za=I({required:[`closeApplication`,`finalizeApplicationClose`]}),Qa=I({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),$a=Object.freeze([Za,Qa]),eo=I({required:[`finalizeApplicationClose`]}),to=I({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),no=I({required:[`prepareAppleRunner`]}),ro=I({required:[`clearRuntimeHints`]}),io=I({required:[`configureProviderPortReverse`]}),ao=Object.freeze([ro,io]),V=I({required:[`appLogInspect`]}),oo=I({required:[`appLogInspect`,`appLogDoctor`]}),so=I({required:[`appLogInspect`,`appLogStart`]}),co=I({required:[],preferred:[`appLogInspect`]}),lo=Object.freeze([V,oo,so]);function uo(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:V});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:so});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:V});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:oo});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:V});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:so}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:V});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const fo=I({required:[`audioProbeStart`]}),po=I({required:[`audioProbeReattach`,`audioProbeCleanup`]}),mo=I({required:[`audioProbeQuery`]}),ho=Object.freeze([fo,po,mo]);function go(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:mo});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:fo});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const _o=[`probe`],vo=[`start`,`status`,`stop`];function yo(t){let n=(t?.[0]??`probe`).toLowerCase();if(!_o.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!vo.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${vo.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:bo(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:bo(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function bo(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,n.message);return r}const xo=I({required:[`networkDump`]}),So=I({required:[],preferred:[`networkDump`]}),Co=[`dump`,`log`],wo=[`summary`,`headers`,`body`,`all`];function To(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!Eo(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!Do(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:xo})}function Eo(e){return Co.some(t=>t===e)}function Do(e){return wo.some(t=>t===e)}function Oo(e){let t=new Map;for(let n of e){if(!r(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,ko(n))}let n=i.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let a=Object.freeze([...i]),o=Object.freeze(a.map(e=>Ao(t,e)));return Object.freeze({families:a,modules:o,get:e=>Ao(t,e)})}function ko(e){return Object.freeze({...e})}function Ao(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const jo=Object.freeze({kind:`device-inventory`});function Mo(e){if(typeof e!=`object`||!e)throw zo();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&H(n,[`kind`]))&&!(t.kind===`host`&&H(n,[`kind`]))&&!(t.kind===`inventory`&&H(n,[`kind`,`use`])&&Po(t.use))&&!(t.kind===`device-runtime`&&H(n,[`kind`,`use`])&&Fo(t.use))&&!(t.kind===`device-runtime`&&(H(n,[`kind`,`uses`])||H(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&No(t.uses)))throw zo()}function No(e){if(!Array.isArray(e)||e.length===0||!e.every(Fo))return!1;let t=e.map(Kr);return new Set(t).size===t.length}function Po(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&H(Object.keys(t).sort(),[`kind`])}function Fo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[Lo(t.required),Lo(t.preferred),Lo(t.conditional??[])];if(!Io(n))return!1;let r=n.flat();return new Set(r).size===r.length&&H(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function Io(e){return e.every(e=>e!==null&&Ro(e))}function Lo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Ro(e){return new Set(e).size===e.length}function H(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function zo(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const Bo=I({required:[`screenRecordingStart`]}),Vo=I({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Ho=I({required:[]}),Uo=I({required:[],preferred:[`screenRecordingStart`]}),Wo=Object.freeze([Bo,Vo]);function Go(t){switch((t.action??``).toLowerCase()){case`start`:if(!Ko(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:Bo});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Ho}):Object.freeze({kind:`stop-recovery`,use:Vo});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function Ko(e){return e===`app`||e===`device`||e===`system`}function qo(e){if(Mo(e),e.kind!==`device-runtime`||!(`uses`in e))throw Jo();let t=e.uses.map(Kr),n=Wo.map(Kr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw Jo()}function Jo(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Yo(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, host, inventory, or device-runtime); there is no registry-entry default`);return Mo(t),t}const U={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},W={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Xo=()=>!0,Zo=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Qo=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),$o=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,es=e=>{let t=e.flags?.leaseProvider;return e.flags?.leaseId===void 0&&typeof t==`string`&&(e.flags?.platform===`android`||e.flags?.platform===`ios`)?{kind:`provider-app-catalog`,provider:t}:void 0},ts=new Set([`status`,`get`]),ns=e=>fs(e,ts,`status`),rs=new Set([`get`,`wait`]),is=e=>fs(e,rs,`get`),as=e=>G(e,ts,`status`),os=e=>G(e,rs,`get`),ss=e=>{try{return on(gn(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},cs=e=>G(e,new Set([`read`]),``),ls=e=>Ra(e.positionals).kind===`read`,us=e=>ls(e)?`observes-app`:`mutates-app`,ds=e=>ls(e)?`preserve`:`may-invalidate`;function fs(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function G(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const K={kind:`none`},ps={kind:`host`},q={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0},J={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...N,onTimeout:`preserve-daemon`},ms={...N,envelopeMs:18e4},hs={...N,onTimeout:`preserve-daemon`},gs={...hs,envelopeMs:33e4},_s={...N,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},vs={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}}},ys={fields:{delayMs:{defaultValue:0}}};function X(e,t){return Or(e)===void 0?t:_s}function Z(e){let t=Or(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const bs={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ha},timeoutPolicy:ms,batchable:!0},xs=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>Sa({customActions:t,hasActiveApp:e}).use)},Ss=e=>{let t=ws(e);if(t===void 0||!Cs(t))return _a;let n=ba(t);return[!0,!1].map(e=>xa({hasActiveApp:e,intent:n}).use)};function Cs(e){return on(e)||e===`focus`||e===`type`}function ws(e){if(e.positionals===void 0)return;let t=pn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const Ts=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:Xo},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U},timeoutPolicy:gs,batchable:!1,platformExecution:K},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U,appLease:`allowed`},timeoutPolicy:hs,batchable:!1,platformExecution:K},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U,appLease:`allowed`},timeoutPolicy:hs,batchable:!1,platformExecution:K},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session_save_script`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...W},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`inventory`,use:jo}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...W},timeoutPolicy:N,batchable:!0,platformExecution:K},{name:`doctor`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:Xo,...W},timeoutPolicy:N,batchable:!0,platformExecution:ps},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:es},platformExecution:{kind:`device-runtime`,uses:[Zr]},timeoutPolicy:N,batchable:!0},{name:`boot`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:Da},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0},{name:`shutdown`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:Na},timeoutPolicy:N,batchable:!0},{name:`appstate`,deviceClaimPolicy:`observe`,catalog:{group:`public`,key:`appState`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:Ma},timeoutPolicy:N,batchable:!0},{name:`perf`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Di}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:lo},timeoutPolicy:N,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`network`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:xo},timeoutPolicy:N,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ho}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Qo,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`}},batchable:!1,platformExecution:K},{name:`test`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Qo},timeoutPolicy:{...N,envelopeMs:`unbounded`},batchable:!0,platformExecution:K},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...ao,Gi]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:cs,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Pa}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:as,daemon:{route:`session`,refFrameEffect:ns,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Va}},{name:`install`,...bs},{name:`reinstall`,...bs},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`,servesPublicCommand:`install-from-source`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ua},timeoutPolicy:ms,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`push`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Wa},timeoutPolicy:N,batchable:!0},{name:`trigger-app-event`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`triggerAppEvent`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[fi]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Xo,saveScriptFlagOwner:!0,appLease:`allowed`},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Xa}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:27e4,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:no}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,appLease:`allowed`},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`close`,deviceClaimPolicy:`release-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0,sessionlessLeaseAdmissionExemption:$o,appLease:`allowed`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:$a}},{name:`snapshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ya,selectUses:xs}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ya,selectUses:xs}},{name:`wait`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:mr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:va}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:os,daemon:{route:`snapshot`,refFrameEffect:is},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ba}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:us,daemon:{route:`snapshot`,refFrameEffect:ds},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fa}},{name:`react-native`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`reactNative`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[L]}},{name:`record`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:Zo},platformExecution:{kind:`device-runtime`,uses:Wo},timeoutPolicy:Y,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:K},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:ss,daemon:{route:`find`,refFrameEffect:`may-invalidate`,appLease:`allowed`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:_a,selectUses:Ss}},{name:`click`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0,appLease:`allowed`},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),targetReadiness:`budgeted`,responseDataTransform:vs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Fi}},{name:`fill`,...J,daemon:{...J.daemon,appLease:`allowed`},frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:ys,batchable:!0,platformExecution:{kind:`device-runtime`,uses:zi}},{name:`longpress`,...J,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{..._s,envelopeMs:21e4},postActionObservation:Z(`longpress`),targetReadiness:`budgeted`,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Li}},{name:`hover`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`},timeoutPolicy:X(`hover`,Y),postActionObservation:Z(`hover`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ri}},{name:`press`,...J,daemon:{...J.daemon,appLease:`allowed`},frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),targetReadiness:`budgeted`,responseDataTransform:vs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ii}},{name:`type`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0,appLease:`allowed`},timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ti]}},{name:`get`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:fa}},{name:`is`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:da}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...q,timeoutPolicy:X(`back`,N),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[ni]}},{name:`gesture`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Yi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[ri]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[oi]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[ii]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...q,timeoutPolicy:vr,platformExecution:{kind:`device-runtime`,uses:[ai]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...q,daemon:{...q.daemon,appLease:`allowed`},timeoutPolicy:X(`scroll`,N),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:Zi}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Xi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...q,daemon:{...q.daemon,appLease:`allowed`},platformExecution:{kind:`device-runtime`,uses:[ei]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ta}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[$r]}},{name:`app-switcher`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`appSwitcher`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ui]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[di]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Ua},timeoutPolicy:N,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:ps},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`plugins`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:jo}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:ps}],Es=new Set([`public`,`local-cli`]),Ds=new Set(Ts.filter(e=>Es.has(Fs(e))).map(e=>e.name)),Q=Ts.map(e=>{let t=Yo(e);return e.name===`record`&&qo(t),{...e,mcpExposed:Ns(e),platformExecution:t}});function Os(e){return Q.filter(t=>Fs(t)===e).map(e=>[Is(e),e.name])}function ks(){return Q.filter(e=>Ps(e)).map(e=>e.name).sort()}function As(e){let t=Q.find(t=>t.name===e)?.platformExecution;if(t?.kind===`device-runtime`)return(`uses`in t?t.uses:[t.use]).map(e=>e.required)}function js(){return Q.filter(e=>e.catalog.group===`public`&&e.platformExecution.kind===`device-runtime`).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function Ms(e){return Ds.has(e)}function Ns(e){return e.mcpExposed??Ds.has(e.name)}function Ps(e){return e.mcpExposed&&Ms(e.name)}function Fs(e){return e.catalog.group}function Is(e){return e.catalog.key??e.name}const Ls=new Map(Array.from($.values(),e=>[e.name,e.targetReadiness?{...e.timeoutPolicy,targetReadiness:e.targetReadiness}:e.timeoutPolicy])),Rs=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),zs=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Bs(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Vs(e){return Bs(e)!==void 0}function Hs(e){return e!==void 0&&$.get(e)?.targetReadiness===`budgeted`}function Us(e){return Bs(e)===`settle-and-verify`}function Ws(e){return e===void 0?N:Ls.get(e)??N}function Gs(e){return e===void 0?`require-owner`:Rs.get(e)??`require-owner`}function Ks(e){if(e!==void 0)return zs.get(e)}function qs(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Js(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Ys(e){return $.get(e)?.targetIdentityVerification}function Xs(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Zs(){return[...new Set(Array.from(zs.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const Qs={apps:{appsFilter:`user-installed`}};function $s(e,t){if(!e||!Ms(e))return!1;let n=Qs[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function ec(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function tc(e){return e.filter(e=>e.batchable).map(e=>e.name)}const nc=tc(Q),rc=new Set([`batch`,`replay`]),ic=[`command`,`positionals`,`input`,`flags`,`runtime`],ac=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`,`testIme`],oc=`Session, daemon, connection, and host tooling commands are excluded from batch — they own lifecycle a batch cannot carry — and batch and replay never nest. Run an excluded command on its own; every other device command is available as a step.`,sc=new Set(nc);function cc(e){return sc.has(e)}function lc(e){return typeof e==`string`?e.trim().toLowerCase():``}function uc(e){let t=lc(e);return cc(t)?t:void 0}function dc(t,n,r=oc){let i=uc(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function fc(t,n){if(rc.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{di as $,Tt as $n,ne as $r,Ar as $t,Oo as A,nn as An,De as Ar,Ci as At,Qa as B,O as Bn,me as Br,Sa as Bt,qs as C,Dn as Cn,x as Cr,ci as Ct,Go as D,wn as Dn,be as Dr,ii as Dt,Ys as E,Tn as En,g as Er,ki as Et,go as F,on as Fn,_e as Fr,ea as Ft,Ja as G,Vt as Gn,ce as Gr,L as Gt,eo as H,Ut as Hn,ue as Hr,mi as Ht,co as I,an as In,ve as Ir,Ea as It,no as J,Bt as Jn,ie as Jr,$r as Jt,Ka as K,Yt as Kn,se as Kr,oi as Kt,uo as L,gn as Ln,p as Lr,ta as Lt,To as M,fn as Mn,Ce as Mr,wi as Mt,po as N,pn as Nn,m as Nr,Ei as Nt,Uo as O,Cn as On,Ee as Or,xi as Ot,yo as P,sn as Pn,ge as Pr,Aa as Pt,Wa as Q,pt as Qn,ee as Qr,zr as Qt,ro as R,vn as Rn,pe as Rr,xa as Rt,Xs as S,Rn as Sn,v as Sr,ji as St,Ws as T,kn as Tn,Oe as Tr,si as Tt,to as U,$t as Un,le as Ur,pi as Ut,io as V,qt as Vn,de as Vr,Bi as Vt,Ga as W,Xt as Wn,fe as Wr,Na as Wt,Ha as X,Wt as Xn,ae as Xr,kr as Xt,Ya as Y,Gt as Yn,l as Yr,Ir as Yt,Ua as Z,Kt as Zn,f as Zr,jr as Zt,Os as _,Wn as _n,Ye as _r,ba as _t,fc as a,gr as an,w as ar,ja as at,Gs as b,Un as bn,Pe as br,Gi as bt,uc as c,M as cn,st as cr,ni as ct,Hs as d,er as dn,at as dr,Ai as dt,te as ei,Mr as en,Ct as er,_i as et,Q as f,Zn as fn,it as fr,Oi as ft,Zs as g,Hn as gn,Xe as gr,Ni as gt,Us as h,nr as hn,qe as hr,I as ht,nc as i,_r as in,T as ir,fi as it,So as j,dn as jn,xe as jr,Ti as jt,Vo as k,On as kn,Te as kr,Si as kt,ec as l,tr as ln,nt as lr,Pi as lt,Vs as m,Qn as mn,ot as mr,bi as mt,ic as n,o as ni,Pr as nn,Ot as nr,hi as nt,lc as o,yr as on,ct as or,ui as ot,As as p,$n as pn,rt as pr,yi as pt,qa as q,Jt as qn,re as qr,ti as qt,ac as r,P as rn,St as rr,gi as rt,dc as s,ir as sn,ut as sr,Zr as st,oc as t,d as ti,Nr as tn,Et as tr,vi as tt,$s as u,Kn as un,tt as ur,Mi as ut,ks as v,zn as vn,Me as vr,ei as vt,Ks as w,En as wn,y as wr,li as wt,Js as x,Ln as xn,b as xr,ri as xt,js as y,Vn as yn,Ie as yr,ai as yt,Za as z,en as zn,he as zr,Ra as zt};
|
|
1
|
+
import{P as e,S as t,b as n}from"./sdk-contracts.js";import{r,v as i}from"./sdk-device.js";function a(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}const o=[`visible`,`hidden`,`exists`,`absent`,`editable`,`selected`,`focused`,`text`],s={x:-Number.MAX_VALUE/2,y:-Number.MAX_VALUE/2,width:Number.MAX_VALUE,height:Number.MAX_VALUE};function c(e){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function l(e){if(!e)return!1;let{x:t,y:n,width:r,height:i}=e;return![t,n,r,i].every(Number.isFinite)||!Number.isFinite(t+r)||!Number.isFinite(n+i)||r<=0||i<=0?!1:!c(e)}function u(e,t){return e>=s.width||t>=s.height}function d(e){if(l(e)&&!u(e.width,e.height))return{width:e.width,height:e.height}}function ee(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{x:t,y:n,width:r,height:i}=e;if(typeof r==`number`&&typeof i==`number`&&(t===void 0||typeof t==`number`)&&(n===void 0||typeof n==`number`))return d({x:t??0,y:n??0,width:r,height:i})}function te(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 ne(e){return e.width*e.height}function re(e){let t=e[0];if(t===void 0)throw Error(`unionRects requires at least one rect`);let n=t.x,r=t.y,i=t.x+t.width,a=t.y+t.height;for(let t of e.slice(1))n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x+t.width),a=Math.max(a,t.y+t.height);return{x:n,y:r,width:i-n,height:a-r}}function ie(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function ae(e,t,n){if(!e||!l(t))return!1;let r=t.x+t.width/2,i=t.y+t.height/2;return r>=n.x&&r<n.x+n.width&&i>=n.y&&i<n.y+n.height}function f(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function oe(e,t){return se(e.x,e.x+e.width,t.x,t.x+t.width)&&se(e.y,e.y+e.height,t.y,t.y+t.height)}function se(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function ce(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function le(e){return ce(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function ue(e){return e?.trim().toLowerCase()||null}function de(e,t){let n=ue(t);return n?[e.label,e.value,e.identifier].some(e=>(e??``).toLowerCase().includes(n)):!1}function fe(e,t,n=()=>!0){if(!ue(t))return null;for(let[r,i]of e.entries()){if(!de(i,t))continue;let a=i.depth??0,o=r+1;for(;o<e.length&&(e[o]?.depth??0)>a;)o+=1;let s={start:r,end:o};if(n(s))return s}return null}function pe(e,t=0){let n=new Map;for(let[t,r]of e.entries())n.set(r.index,t);return e.map((e,r)=>({...e,index:r,depth:Math.max(0,(e.depth??0)-t),parentIndex:typeof e.parentIndex==`number`?n.get(e.parentIndex):void 0}))}function me(e){return new Map(e.map(e=>[e.index,e]))}function he(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 ge(e,t,n){return he(e,t,me(e),e=>n(e)?e:null)}function p(e){let t=e.trim().replaceAll(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function _e(e,t){let n=p(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 ve(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function ye(e){if(typeof e!=`string`)return!1;let t=e.trim();return t?!/^(true|false)$/i.test(t):!1}function m(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}const be=Symbol(`SnapshotVisibility`);function xe(e,t={}){let n,r,i=()=>(n||(n=me(e),t.onNodeMapBuilt?.()),n),a=()=>(r||(r=Ce(e),t.onViewportRectsCollected?.()),r),o=n=>h(e,n,a(),t.onContainingRectFallback),s=n=>{let r=De(n,i(),e=>!!e.rect)?.rect;if(r)return r;let o=a();return o.length===0?null:h(e,n.rect??{x:0,y:0,width:0,height:0},o,t.onContainingRectFallback)},c=e=>{if(!e.rect)return!0;let t=s(e);return!t||oe(e.rect,t)},l=e=>e.rect?c(e)?Ee(e.rect,o(e.rect)):!1:!0;return{[be]:!0,get nodeByIndex(){return i()},get viewportRects(){return a()},findAncestor(t,n){return he(e,t,i(),n)},isVisibleInEffectiveViewport:c,isVisibleOnScreen:l,resolveEffectiveViewport:s,resolveViewport:o}}function Se(e){let t=[e.type,e.role,e.subrole].map(e=>p(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function Ce(e){return e.flatMap(e=>Se(e)&&l(e.rect)?[e.rect]:[])}function we(e,t,n){return h(e,t,n??Ce(e))}function h(e,t,r,i){let a=n(t),o=e=>ie(e,a.x,a.y);return(f(r.filter(o))??f(r))||(i?.(),f(e.flatMap(e=>Te(e.rect)&&o(e.rect)?[e.rect]:[])))}function Te(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function Ee(e,t){return!t||t.width<=0||t.height<=0||ie(t,e.x+e.width/2,e.y+e.height/2)}function De(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)&&le(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function Oe(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=p(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&&l(e.rect):e.hittable===!0||l(e.rect)}function g(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function ke(e,t){return _e(e.type??``,t)&&e.enabled!==!1}function Ae(e){let n=e.kind??t(e.type??`Element`),r=p(e.type??``);return r&&r!==n?[n,r]:[n]}const je=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),Me=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),_=new Set([...je,...Me]),Ne=[..._],Pe=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 Fe(e){return Pe.has(e.trim().toLowerCase())}const Ie=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
|
|
2
|
+
`],[`r`,`\r`],[`t`,` `]]);function v(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Be(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Re(e))}}function y(e){try{return v(e)}catch{return null}}function b(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return _.has(e)}return _.has(t.toLowerCase())}function Le(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||_.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=S(i).trim();return a?{key:r,value:a}:null}function x(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!b(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&y(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function Re(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Ve(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(ze)}}function ze(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(!Me.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!_.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(Me.has(i)){let t=Ge(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:S(a)}}function Be(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Ke(t,a)){i=He(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 Ve(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Ke(t,e)){i=He(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 He(e,t){return e?e===t?null:e:t}function S(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?Ue(t.slice(1,-1)):t}function Ue(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=We(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 We(e){return Ie.get(e)??null}function Ge(e){let t=S(e).toLowerCase();return t===`true`||t!==`false`&&null}function Ke(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function C(e){return o.includes(e)}const qe=`is requires predicate: ${o.join(`|`)}`;function Je(e){let t=e.toLowerCase();return C(t)?{ok:!0,predicate:t}:a(qe,Ye)}const Ye=`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 Xe(e){if(C((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(C(n)&&y(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function Ze(e){let{predicate:t,node:n,visibility:r,expectedText:i,platform:a}=e,o=m(n),s=ke(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?g(n):$e(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break;default:return Qe(t)}let ee=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:ee}}function Qe(e){throw Error(`Unhandled is predicate: ${String(e)}`)}function $e(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(l(e.rect))return t.isVisibleInEffectiveViewport(e);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=et(e,t,n);return r?l(r.rect)?t.isVisibleInEffectiveViewport(r):n!==`android`&&r.hittable===!0:!1}function et(e,t,n){return t.findAncestor(e,e=>Oe(e,n)?e:null)}function tt(e){let t=Xe(e),n=t[0]??``;return{predicate:n,split:x(t.slice(1),{preferTrailingValue:n===`text`})}}const nt=`is requires a selector expression`,rt=`is text requires expected text value`;function it(e){let{predicate:t,split:n}=tt([...e]),r=Je(t);if(!r.ok)return r;if(!n)return a(nt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?a(rt):r.predicate!==`text`&&n.rest.length>0?a(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function at(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:a(`get only supports text or attrs`)}function ot(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}:a(`get requires @ref or selector expression`)}function st(e){return e?{ok:!0,text:e}:a(`wait requires text`)}function ct(e){return Array.from(new Set(e))}function lt(e){return JSON.stringify(ut(e))}function ut(e){if(Array.isArray(e))return e.map(ut);if(!e||typeof e!=`object`)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,ut(t[e])]))}function dt(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t+=1;for(;n>t&&e[n-1]===`-`;)--n;return e.slice(t,n)}const ft=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,pt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,mt=4096;function ht(e){return e.normalize(`NFC`)}function gt(e){if(e===void 0)return;let t=ht(e);return t.length>0?t:void 0}function _t(e){return ht(e)}function vt(e){if(e===void 0)return;let t=ht(e).trim().replaceAll(/\s+/g,` `);return t.length>0?t:void 0}function w(e){return Buffer.byteLength(e,`utf8`)}function T(e,t){if(w(e)<=t)return e;let n=e.length;for(;n>0&&w(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 yt(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(bt),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=xt(e.scrollRegion)),e.rect&&(t.rect=St(e.rect)),t.verification=e.verification,t}function bt(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function xt(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 St(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function Ct(e){return JSON.stringify(yt(e))}function wt(e){return`# agent-device:target-v1 ${Ct(e)}`}function Tt(e){return JSON.stringify({source:yt(e.source),destination:yt(e.destination)})}function Et(e){return`# agent-device:targets-v1 ${Tt(e)}`}function Dt(e){let t=e.trim(),n=pt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:Ot((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function Ot(t){if(w(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:At(JSON.stringify(r.source)),destination:At(JSON.stringify(r.destination))}}function kt(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=ft.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:At((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function At(t){if(w(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${mt}-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=jt(r.role,`role`),a=Mt(r.id,`id`),o=Nt(r.label,`label`),s=Ft(r.ancestry),c=Lt(r.sibling,`sibling`,0),l=Lt(r.viewportOrder,`viewportOrder`,0),u=Rt(r.scrollRegion),d=zt(r.rect),ee=Bt(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:ee}}function jt(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 Pt(_t(t),n)}function Mt(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=gt(t);return r===void 0?void 0:Pt(r,n)}function Nt(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=vt(t);return r===void 0?void 0:Pt(r,n)}function Pt(t,n){if(w(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function Ft(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)=>It(e,t))}function It(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=jt(r.role,`ancestry[${n}].role`),a=Nt(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function Lt(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 Rt(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=jt(n.role,`scrollRegion.role`),i=Mt(n.id,`id`),a=Nt(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function zt(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:E(n.x,`rect.x`),y:E(n.y,`rect.y`),width:E(n.width,`rect.width`),height:E(n.height,`rect.height`)}}function E(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function Bt(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function Vt(e){let t=_t(p(e.type??``)),n=gt(e.identifier),r=vt(e.label);return{...n===void 0?{}:{id:T(n,256)},role:T(t,256),...r===void 0?{}:{label:T(r,256)}}}function Ht(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Ut(e,t){let n=0;for(let r of e)Vt(r).id===t&&(n+=1);return n}function Wt(e,t){if(e.id===void 0||Ut(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Gt(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 Kt(e,t){return{documentOrder:e.index,sibling:Gt(t,e)}}function qt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Jt(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Yt(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function Xt(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function Zt(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Qt(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function $t(e,t){return!t||t.role!==e.role||e.label!==void 0&&t.label!==e.label}function en(e,t){for(let[n,r]of e.entries()){let e=t[n];if($t(r,e))return[`ancestry[${n}]: recorded=${Qt(r)} observed=${Qt(e)}`]}return[]}function tn(e,t,n={}){let r=[],i=p(e.type??``),a=nn(e,n.nodes),o=O(e.label),s=O(e.value),c=O(m(e)),l=n.action===`fill`;a&&r.push(`id=${D(a)}`),i&&o&&r.push(l?`role=${D(i)} label=${D(o)} editable=true`:`role=${D(i)} label=${D(o)}`),o&&r.push(l?`label=${D(o)} editable=true`:`label=${D(o)}`),s&&r.push(l?`value=${D(s)} editable=true`:`value=${D(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${D(c)} editable=true`:`text=${D(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${D(i)} editable=true`);let u=ct(r);return u.length===0&&i&&u.push(l?`role=${D(i)} editable=true`:`role=${D(i)}`),u.length===0&&g(e)&&u.push(`visible=true`),u}function nn(e,t){let n=O(e.identifier);if(!n||!t)return n;let r=Vt(e).id;return r===void 0?n:Ut(t,r)>1?null:n}function D(e){return JSON.stringify(e)}function O(e){return e&&e.trim()||null}const rn=[`any`,`text`,`label`,`value`,`role`,`id`],an=[`text`,`label`,`value`,`role`,`id`];function on(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function sn(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function cn(e,t,n,r={}){let i=A(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=ln(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 ln(e,t,n){switch(t){case`role`:return un(e,n);case`label`:return k(e.label,n);case`value`:return k(e.value,n);case`id`:return k(e.identifier,n);default:return Math.max(k(e.label,n),k(e.value,n),k(e.identifier,n))}}function k(e,t){let n=A(e??``);return n?n===t?2:+!!n.includes(t):0}function un(e,t){let n=Ae(e);return n.some(e=>A(e)===t)?2:+!!n.some(e=>dn(e).includes(t))}function dn(e){let t=e.lastIndexOf(`.`);return t===-1?e:e.slice(t+1)}function A(e){return e.trim().toLowerCase().replaceAll(/\s+/g,` `)}const fn=`find requires a value`,pn=`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 mn(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=_n([...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:fn}}const hn=[`exists`,`list`,`click`,`focus`];function gn(e){return hn.includes(e)}function _n(t){let n=`any`,r=0;an.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=on(a[0]);if(gn(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:vn(a[1])};if(o===`wait`){let e=bn(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`){let e=a.slice(1);return{locator:n,query:i,action:o,value:e.length===0?void 0:e.join(` `)}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:pn})}function vn(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 yn(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:y(t)?t:null}function bn(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function xn(e,t,n){return t.terms.every(t=>Sn(e,t,n))}function Sn(e,t,n){switch(t.key){case`id`:return j(e.identifier,String(t.value));case`role`:return Cn(e,String(t.value));case`label`:return j(e.label,String(t.value));case`value`:return j(e.value,String(t.value));case`text`:return j(m(e),String(t.value));case`appname`:return j(e.appName,String(t.value));case`windowtitle`:return j(e.windowTitle,String(t.value));case`visible`:return g(e)===!!t.value;case`hidden`:return!g(e)==!!t.value;case`editable`:return ke(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function j(e,t){return A(e??``)===A(t)}function Cn(e,t){let n=A(t);return Ae(e).some(e=>A(e)===n)}function wn(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[],o=null;for(let[s,c]of t.selectors.entries()){let t=jn(e,c,n.platform,r);if(a.push({selector:c.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(o??={selector:c,selectorIndex:s,matchedNodes:t.candidates},i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.disambiguated,selector:c,selectorIndex:s,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}}return{matchedNodes:t.candidates,firstMatch:o,resolution:{node:t.firstNode,selector:c,selectorIndex:s,matches:t.count,diagnostics:a}}}}return{resolution:null,matchedNodes:o?.matchedNodes??[],firstMatch:o}}function Tn(e,t,n){return wn(e,t,n).resolution}function En(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:xn(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function Dn(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Fn(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 On=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function kn(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 An(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 jn(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c=xe(e).isVisibleOnScreen;for(let l of e)r&&!l.rect||xn(l,t,n)&&(i+=1,a??=l,o.push(l),Mn(s,l,c));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:Nn(o,s.best,c),candidates:o}}function Mn(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=In(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function Nn(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Pn(i,r,n).result>0)&&(r=i);return r?Pn(t,r,n).criterion:null}function Pn(e,t,n){let r=n(e);return r===n(t)?In(e,t):{result:r?1:-1,criterion:`visible`}}function Fn(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||xn(a,t,n)&&(i+=1);return i}function In(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Ln(e),a=Ln(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Ln(e){return e.rect?e.rect.width*e.rect.height:1/0}const Rn={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0},readList:{ambiguity:`reject-candidates`,requireRect:!1},cropTarget:{ambiguity:`fail-closed`,requireRect:!0}};function zn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Bn(e,t){let n=e===`is`?tt([...t]).split:x([...t]);return n?y(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Vn(e){return{platform:e.platform,...zn({ambiguity:e.allowDisambiguation?`disambiguate`:`fail-closed`,requireRect:e.requireRect})}}function Hn(e,t,n){let r=y(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let{resolution:i,matchedNodes:a}=wn(t,r,Vn(n));return i?{kind:`resolved`,winner:i.node,matchedNodes:a,matchCount:a.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}:{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function Un(e,t,n={}){return tn(e,t,n)}function Wn(e,t,n){let r=y(e);if(!r)return;let i=Tn(t,r,Vn(n));if(i)return{node:i.node,basis:Kn(i.selector)}}function Gn(e){if(!e)return;let t=y(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Kn(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 qn(e,t){let n=y(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys),i=t.textAliases??{};return n.selectors.length>1?Jn(n.selectors,r,i):Yn(n.selectors[0],r,new Set(t.booleanKeys),i)}function Jn(e,t,n){let r=e.map(e=>{let r=e.terms.length===1?e.terms[0]:void 0;return r&&Xn(r.key,t,n)&&typeof r.value==`string`?r.value:void 0}),i=r[0];return i!==void 0&&r.every(e=>e===i)?i:null}function Yn(e,t,n,r){if(!e)return null;let i={},a=0;for(let o of e.terms){if(Xn(o.key,t,r)&&typeof o.value==`string`)a+=1;else if(!Zn(o,n,`boolean`))return null;i[r[o.key]??o.key]=o.value}return a<=1&&Object.keys(i).length>0?i:null}function Xn(e,t,n){return t.has(e)||n[e]!==void 0}function Zn(e,t,n){return t.has(e.key)&&typeof e.value===n}function Qn(e){let t=y(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function $n(e,t){if(!t)return!1;let n=y(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function er(e,t){return y(e)?.selectors.some(e=>e.terms.some(e=>e.key===t))??!1}function tr(e){return v(e).selectors.map(e=>e.raw)}function nr(e){return y(e)!==null}function rr(e){v(e)}function M(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const ir=new Set([`exists`,`present`,`appears`,`gone`,`disappears`]);function ar(e){let t=e[0];if(t===void 0)return null;let n=M(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=M(e.at(-1));return t===`text`?or(e,r):t===`stable`?sr(e):t===`absent`?cr(e,r):t.startsWith(`@`)?{kind:`ref`,rawRef:t,timeoutMs:r}:ur(e,r)}function or(e,t){return{kind:`text`,text:(t===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:t}}function sr(e){let t=e.slice(1),n=t.length>1?M(t[1]):null;return{kind:`stable`,quietMs:t.length>0?M(t[0]):null,timeoutMs:n}}function cr(e,t){let n=t===null?e.slice(1):e.slice(1,-1),r=x(n);return n.length>0&&r?.rest.length===0&&nr(r.selectorExpression)?{kind:`absent`,selectorExpression:r.selectorExpression,timeoutMs:t}:{kind:`invalid`,reason:`absent-selector-required`,message:lr(n)}}function lr(e){let t=e.join(` `);return t.length>0?`wait absent requires one valid selector; received "${t}". Use wait absent '<selector>' [timeoutMs].`:`wait absent requires <selector> [timeoutMs].`}function ur(e,t){let n=t===null?e.slice():e.slice(0,-1),r=x(n);return r&&r.rest.length===0&&nr(r.selectorExpression)?{kind:`selector`,selectorExpression:r.selectorExpression,timeoutMs:t}:dr(n,r)||{kind:`text`,text:(t===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:t}}function dr(e,t){for(let t of e){let n=Le(t);if(n)return{kind:`invalid`,reason:`unknown-selector-key`,message:fr(n,e)}}return t&&t.rest.length>0?{kind:`invalid`,reason:`selector-shaped-text`,message:pr(t,e)}:e.some(e=>b(e))?{kind:`invalid`,reason:`selector-shaped-text`,message:mr(e)}:null}function fr(e,t){let n=t.join(` `),r=Fe(e.key)?`role=${e.key} label="${e.value}"`:`label="${e.value}"`;return`Unknown selector key "${e.key}" in "${n}". Supported: ${Ne.join(`, `)}. Use wait '${r}' [timeoutMs] to wait for the selector, or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function pr(e,t){let n=t.join(` `);return`Selector ${e.selectorExpression} is followed by unexpected extra arguments: "${e.rest.join(` `)}". Selector values with spaces need quotes, e.g. label="Sign in". Use wait '<selector>' [timeoutMs], or wait text '${n}' [timeoutMs] to wait for the literal text "${n}".`}function mr(e){let t=e.join(` `),n=e.filter(e=>!b(e)),r=e.filter(e=>b(e));if(n.length>0){let e=n[0],i=ir.has(e.toLowerCase())?` "${e}" describes a condition, not a selector key. Use the selector form: `+(e.toLowerCase()===`gone`||e.toLowerCase()===`disappears`?`wait absent '${r.join(` `)}' [timeoutMs] to wait for zero matches.`:`wait '${r.join(` `)}' [timeoutMs] to wait for it to appear.`):` "${e}" is not a recognized selector key (${Ne.join(`, `)}).`;return`"${t}" mixes plain word "${e}" with selector-shaped "${r.join(` `)}", so it is neither a valid selector nor safe as literal text.${i} Use wait '<selector>' [timeoutMs] for a selector, or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}return`"${t}" looks like a selector key but is not a valid selector expression. Use wait '<selector>' [timeoutMs], e.g. wait '${e[0]}="value"' [timeoutMs], or wait text '${t}' [timeoutMs] to wait for the literal text "${t}".`}function hr(e){let t=ar(e);return t?t.kind===`sleep`?t.durationMs:t.kind===`invalid`?null:t.timeoutMs:null}const gr=3e4,_r=24e4,vr=3e5,N={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},yr={budget:{source:`none`},envelopeMs:255e3,onTimeout:`reset-daemon`};function br(e,t){if(e.envelopeMs===`unbounded`)return;let n={...e,envelopeMs:e.envelopeMs};return(Sr(n,t.positionals??[])??Cr(n,t.flags)??n.envelopeMs)+xr(e,t.flags)}function xr(e,t){if(e.targetReadiness!==`budgeted`)return 0;let n=t?.readinessTimeoutMs;return typeof n!=`number`||!Number.isInteger(n)||n<=0?0:Math.min(n,2e3)}function Sr(e,t){if(e.budget.source!==`positional-parser`)return;let n=e.budget.parser(t);return n===null?void 0:Er(e,n)}function Cr(e,t){if(e.budget.source===`flag`)return e.budget.envelope===`widen`?Tr(e,e.budget,t):e.budget.envelope===`margin`?wr(e,t):typeof t?.timeoutMs==`number`?t.timeoutMs:e.envelopeMs}function wr(e,t){let n=typeof t?.timeoutMs==`number`?Er(e,t.timeoutMs):e.envelopeMs;return typeof t?.waitMs==`number`?Dr({...e,envelopeMs:n},t.waitMs):n}function Tr(e,t,n){if(n?.settle!==!0)return e.envelopeMs;let r=typeof n.timeoutMs==`number`?n.timeoutMs:t.defaultBudgetMs;return typeof r==`number`?Dr(e,r):e.envelopeMs}function Er(e,t){return Math.max(e.envelopeMs,t+gr)}function Dr(e,t){return Math.max(e.envelopeMs,e.envelopeMs+t+gr)}const Or={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,hover:`settle`,scroll:`settle`,back:`settle`};function kr(e){if(e!==void 0)return Or[e]}function P(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function Ar(e){if(!i(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function jr(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 Mr(e){let t=e.trim();if(t.length===0)throw TypeError(`Managed local runtime owner requires a non-empty allocator instance identity`);return Object.freeze({kind:`managed-local`,instance:t})}function Nr(e){switch(e.kind){case`local-family`:return`local:${e.family}`;case`managed-local`:return`managed:${JSON.stringify([e.instance])}`;case`provider-runtime`:return`provider:${JSON.stringify([e.provider,e.instance])}`}}function Pr(e,t){return Nr(e)===Nr(t)}function Fr(e,t){return Object.freeze(t===void 0?{available:!1,reason:e}:{available:!1,reason:e,hint:t})}function Ir(e,t){return e.available?t():{}}function Lr(e){if(!F(e.requesterId)||!F(e.identityIncarnationId)||!zr(e.requestGeneration))throw TypeError(`Managed binding fence requires non-empty requester and identity incarnation ids and a non-negative integer request generation`);return Object.freeze({token:JSON.stringify([e.requesterId,e.identityIncarnationId]),generation:e.requestGeneration})}function Rr(e){let t=Br(e.token);if(!t||t.length!==2)return null;let[n,r]=t;if(!F(n)||!F(r)||!zr(e.generation))return null;let i=Object.freeze({requesterId:n,requestGeneration:e.generation,identityIncarnationId:r});return Lr(i).token===e.token?i:null}function zr(e){return Number.isInteger(e)&&e>=0}function F(e){return typeof e==`string`&&e.trim().length>0}function Br(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Vr(e,t){let n={},r={};for(let i of t.required){let t=Hr(e.facts.operations,i);if(n[i]=t,!t.available)throw qr(i,t);r[i]=Gr(e.operations,i)}for(let i of t.preferred){let t=Hr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Gr(e.operations,i))}for(let i of t.conditional??[]){let t=Hr(e.facts.operations,i);n[i]=t,t.available&&(r[i]=Gr(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function Hr(e,t){let n=e[t];if(!Ur(n))throw P(`Runtime owner omitted the ${t} fact`);let r=Wr(n);if(r)return r;throw P(`Runtime owner returned an invalid ${t} fact`)}function Ur(e){return typeof e==`object`&&!!e&&`available`in e}function Wr(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&Kr(e.reason)&&(e.hint===void 0||typeof e.hint==`string`))return Fr(e.reason,e.hint)}function Gr(e,t){let n=e[t];if(typeof n!=`function`)throw P(`Runtime owner advertised ${t} without an implementation`);return n}function Kr(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-device-scope`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function qr(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function Jr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort(),conditional:[...e.conditional??[]].sort()})}function Yr(){return e=>{let t=Xr(e.required,`required`),n=Xr(e.preferred??[],`preferred`),r=Xr(e.conditional??[],`conditional`),i=[[`required`,t],[`preferred`,n],[`conditional`,r]];for(let e=0;e<i.length;e+=1){let t=i[e];if(t)for(let n of i.slice(e+1)){let e=n[1].find(e=>t[1].includes(e));if(e!==void 0)throw TypeError(`Runtime operation cannot be both ${t[0]} and ${n[0]}: ${e}`)}}return Object.freeze(r.length===0?{required:t,preferred:n}:{required:t,preferred:n,conditional:r})}}function Xr(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 I=Yr(),Zr=I({required:[`bootTarget`]}),Qr=I({required:[`bootTargetHeadless`]}),$r=I({required:[`ensureReady`,`listApps`]}),ei=I({required:[`captureSnapshot`]}),ti=I({required:[`setViewport`]}),ni=I({required:[`focusPoint`]}),ri=I({required:[`typeText`]}),ii=I({required:[`back`]}),ai=I({required:[`home`]}),oi=I({required:[`setOrientation`]}),si=I({required:[`setFoldPose`]}),ci=I({required:[`tvRemote`]}),li=I({required:[`keyboardStatus`]}),ui=I({required:[`keyboardDismiss`]}),di=I({required:[`keyboardEnter`]}),fi=I({required:[`appSwitcher`]}),pi=I({required:[`actionButton`]}),mi=I({required:[`triggerAppEvent`]}),hi=I({required:[`setSetting`]}),gi=I({required:[`readSetting`]}),_i=I({required:[`readAlert`]}),vi=I({required:[`awaitAlert`]}),yi=I({required:[`acceptAlert`]}),bi=I({required:[`dismissAlert`]}),xi=I({required:[`readClipboard`]}),Si=I({required:[`writeClipboard`]}),Ci=I({required:[`perfFrames`]}),wi=I({required:[`perfMemorySample`]}),Ti=I({required:[`perfMemorySnapshot`]}),Ei=I({required:[`perfNativeCaptureStart`]}),Di=I({required:[`perfNativeCaptureReattach`,`perfNativeCaptureCleanup`]}),Oi=I({required:[`perfProfileReport`]}),ki=Object.freeze([Ci,wi,Ti,Ei,Di,Oi]),L=I({required:[`tapPoint`]}),Ai=I({required:[`captureSnapshot`,`tapPoint`],preferred:[`tapRef`],conditional:[`tapElementSelector`]}),ji=I({required:[`longPressPoint`]}),Mi=I({required:[`captureSnapshot`,`longPressPoint`]}),Ni=I({required:[`hoverPoint`]}),Pi=I({required:[`captureSnapshot`,`hoverPoint`],preferred:[`hoverRef`]}),Fi=I({required:[`fillPoint`]}),Ii=I({required:[`captureSnapshot`,`fillPoint`],preferred:[`fillRef`]}),Li=Object.freeze([L,Ai]),Ri=Li,zi=Object.freeze([ji,Mi]),Bi=Object.freeze([Ni,Pi]),Vi=Object.freeze([Fi,Ii]);function Hi(e,t){switch(e){case`click`:case`press`:return t?{kind:`captured-tap`,use:Ai}:{kind:`tap-point`,use:L};case`fill`:return t?{kind:`captured-fill`,use:Ii}:{kind:`fill-point`,use:Fi};case`longpress`:return t?{kind:`captured-long-press`,use:Mi}:{kind:`long-press-point`,use:ji};case`hover`:return t?{kind:`captured-hover`,use:Pi}:{kind:`hover-point`,use:Ni}}}const Ui=I({required:[`performGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Wi=I({required:[`performDirectionalFlingPlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Gi=I({required:[`performMultiTouchGesturePlan`,`captureSnapshot`],preferred:[`gestureViewport`]}),Ki=I({required:[`performTargetAuthoredDrag`,`captureSnapshot`],preferred:[`gestureViewport`]}),qi=I({required:[`gestureViewport`]}),Ji=I({required:[`scrollDirection`],conditional:[`captureSnapshot`]}),Yi=I({required:[`scrollDirection`,`captureSnapshot`]}),Xi=Object.freeze({plan:Ui,"directional-fling":Wi,"multi-touch":Gi,"target-authored-drag":Ki}),Zi=Object.freeze([Ui,Wi,Gi,Ki]),Qi=Object.freeze([Ui]),$i=Object.freeze([Ji,Yi]);function ea(e){return e.intent===`pan`?(`pointerCount`in e?e.pointerCount:1)===2:e.intent===`pinch`||e.intent===`rotate`||e.intent===`transform`}function ta(e){return e.intent===`drag`?`target-authored-drag`:ea(e)?`multi-touch`:e.intent===`fling`&&`direction`in e?`directional-fling`:`plan`}function na(e){let t=ta(e);switch(t){case`plan`:return R(t);case`directional-fling`:return R(t);case`multi-touch`:return R(t);case`target-authored-drag`:return R(t)}}function R(e){let t=Xi[e];return Object.freeze({tier:e,operation:t.required[0],use:t})}function ra(e){return e.until===void 0?e.edge===void 0?Object.freeze({kind:`direction`,use:Ji}):Object.freeze({kind:`edge`,edge:e.edge,use:Yi}):Object.freeze({kind:`until`,until:e.until,use:Yi})}const ia=I({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`]}),aa=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),oa=I({required:[`captureSnapshot`,`captureSnapshotWithCustomActions`,`captureSnapshotWithoutActiveApp`]}),sa=I({required:[`captureSnapshot`]}),ca=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`]}),la=I({required:[`captureSnapshot`],preferred:[`readTextAtPoint`]}),ua=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],preferred:[`readTextAtPoint`]}),da=I({required:[`captureSnapshot`],conditional:[`findText`]}),fa=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`],conditional:[`findText`]}),pa=Object.freeze([sa,ca]),ma=Object.freeze([la,ua]),ha=I({required:[`captureSnapshot`,`focusPoint`]}),ga=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`]}),_a=I({required:[`captureSnapshot`,`focusPoint`,`typeText`]}),va=I({required:[`captureSnapshot`,`captureSnapshotWithoutActiveApp`,`focusPoint`,`typeText`]}),ya=Object.freeze([la,ua,sa,ca,ha,ga,_a,va]),ba=Object.freeze([da,fa]),xa=Object.freeze([ei,ia,aa,oa]),z=Object.freeze({"capture-only":pa,"element-text":ma,"wait-observation":ba,"find-focus":Object.freeze([ha,ga]),"find-type":Object.freeze([_a,va])});function Sa(e){return e===`focus`?`find-focus`:e===`type`?`find-type`:`capture-only`}function Ca(e){switch(e.intent){case`capture-only`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`element-text`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`wait-observation`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`find-focus`:return B(e.hasActiveApp,e.intent,z[e.intent]);case`find-type`:return B(e.hasActiveApp,e.intent,z[e.intent])}}function B(e,t,n){return Object.freeze(e?{kind:`selector-active-app`,intent:t,operation:`captureSnapshot`,use:n[0]}:{kind:`selector-without-active-app`,intent:t,operation:`captureSnapshotWithoutActiveApp`,use:n[1]})}function wa(e){return e.customActions?e.hasActiveApp?Object.freeze({kind:`custom-actions-active-app`,operation:`captureSnapshotWithCustomActions`,use:ia}):Object.freeze({kind:`custom-actions-without-active-app`,operation:`captureSnapshotWithCustomActions`,use:oa}):e.hasActiveApp?Object.freeze({kind:`active-app`,operation:`captureSnapshot`,use:ei}):Object.freeze({kind:`without-active-app`,operation:`captureSnapshotWithoutActiveApp`,use:aa})}const Ta=I({required:[`captureScreenshot`]}),Ea=I({required:[`captureScreenshot`,`captureSnapshot`]}),Da=Object.freeze([Ta,Ea]);function Oa(e){return e.cropOn?Object.freeze({kind:`capture-with-crop-on`,use:Ea}):e.overlayRefs?Object.freeze({kind:`capture-with-overlay-refs`,use:Ea}):Object.freeze({kind:`capture`,use:Ta})}const ka=Object.freeze([Zr,Qr]),Aa=Object.freeze({kind:`boot-target`,operation:`bootTarget`,use:Zr}),ja=Object.freeze({kind:`boot-target-headless`,operation:`bootTargetHeadless`,use:Qr});function Ma(e){return e.headless?ja:Aa}const Na=I({required:[`ensureReady`,`appState`]}),Pa=Object.freeze([Na]),Fa=I({required:[`shutdownTarget`]}),Ia=Object.freeze([xi,Si]),La=Object.freeze([hi,gi]),Ra=[`text-size`],za=Object.freeze({kind:`write`,use:hi});function Ba(e){let t=Va(e?.[0]);return e?.length!==1||t===void 0?za:Ra.includes(t)?Object.freeze({kind:`read`,setting:t,use:gi}):za}function Va(e){let t=e?.trim().toLowerCase();return Ra.find(e=>e===t)}const Ha=Object.freeze([_i,vi,yi,bi]),Ua=Object.freeze([li,ui,di]),Wa=I({required:[`deployApp`]}),Ga=I({required:[`ensureReady`,`materializeAppSource`,`deployMaterializedApp`]}),Ka=I({required:[`ensureReady`,`sendPushNotification`]}),qa=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`]}),Ja=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`]}),Ya=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`clearRuntimeHints`]}),Xa=I({required:[`resolveOpenTarget`,`prepareApplicationOpen`,`openApplication`,`applyRuntimeHints`,`clearRuntimeHints`]});function Za(e){return e.applyRuntimeHints&&e.clearRemovedRuntimeHints?Object.freeze({kind:`open-apply-and-clear-runtime-hints`,use:Xa}):e.applyRuntimeHints?Object.freeze({kind:`open-apply-runtime-hints`,use:Ja}):e.clearRemovedRuntimeHints?Object.freeze({kind:`open-clear-runtime-hints`,use:Ya}):Object.freeze({kind:`open`,use:qa})}const Qa=Object.freeze([qa,Ja,Ya,Xa]),$a=I({required:[`closeApplication`,`finalizeApplicationClose`]}),eo=I({required:[`closeApplication`,`finalizeApplicationClose`,`clearRuntimeHints`]}),to=Object.freeze([$a,eo]),no=I({required:[`finalizeApplicationClose`]}),ro=I({required:[`finalizeApplicationClose`,`clearRuntimeHints`]}),io=I({required:[`prepareAppleRunner`]}),ao=I({required:[`clearRuntimeHints`]}),oo=I({required:[`configureProviderPortReverse`]}),so=Object.freeze([ao,oo]),V=I({required:[`appLogInspect`]}),co=I({required:[`appLogInspect`,`appLogDoctor`]}),lo=I({required:[`appLogInspect`,`appLogStart`]}),uo=I({required:[],preferred:[`appLogInspect`]}),fo=Object.freeze([V,co,lo]);function po(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:V});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:lo});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:V});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:co});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:V});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:lo}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:V});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}const mo=I({required:[`audioProbeStart`]}),ho=I({required:[`audioProbeReattach`,`audioProbeCleanup`]}),go=I({required:[`audioProbeQuery`]}),_o=Object.freeze([mo,ho,go]);function vo(e){if(e.mode===`query`)return Object.freeze({kind:`query`,action:e.probeAction,use:go});switch(e.probeAction){case`start`:return Object.freeze({kind:`capture-start`,use:mo});case`status`:return Object.freeze({kind:`capture-status`});case`stop`:return Object.freeze({kind:`capture-stop`})}}const yo=[`probe`],bo=[`start`,`status`,`stop`];function xo(t){let n=(t?.[0]??`probe`).toLowerCase();if(!yo.includes(n))throw new e(`INVALID_ARGS`,`audio requires probe`);let r=(t?.[1]??`status`).toLowerCase();if(!bo.includes(r))throw new e(`INVALID_ARGS`,`audio probe requires ${bo.join(`, `)}`);if(r!==`start`&&t&&t.length>2)throw new e(`INVALID_ARGS`,`audio probe duration and bucket are only supported with audio probe start`);return Object.freeze({probeAction:r,durationMs:So(t?.[2],{defaultValue:1e4,min:100,max:12e4,message:`audio probe duration must be an integer in range 100..120000 ms`}),bucketMs:So(t?.[3],{defaultValue:1e3,min:100,max:1e4,message:`audio probe bucket must be an integer in range 100..10000 ms`})})}function So(t,n){if(t===void 0)return n.defaultValue;let r=Number.parseInt(t,10);if(!Number.isInteger(r)||String(r)!==t||r<n.min||r>n.max)throw new e(`INVALID_ARGS`,n.message);return r}const Co=I({required:[`networkDump`]}),wo=I({required:[],preferred:[`networkDump`]}),To=[`dump`,`log`],Eo=[`summary`,`headers`,`body`,`all`];function Do(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!Oo(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!ko(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:Co})}function Oo(e){return To.some(t=>t===e)}function ko(e){return Eo.some(t=>t===e)}function Ao(e){let t=new Map;for(let n of e){if(!i(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,jo(n))}let n=r.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let a=Object.freeze([...r]),o=Object.freeze(a.map(e=>Mo(t,e)));return Object.freeze({families:a,modules:o,get:e=>Mo(t,e)})}function jo(e){return Object.freeze({...e})}function Mo(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const No=Object.freeze({kind:`device-inventory`});function Po(e){if(typeof e!=`object`||!e)throw Vo();let t=e,n=Object.keys(t).sort();if(!(t.kind===`none`&&H(n,[`kind`]))&&!(t.kind===`host`&&H(n,[`kind`]))&&!(t.kind===`inventory`&&H(n,[`kind`,`use`])&&Io(t.use))&&!(t.kind===`device-runtime`&&H(n,[`kind`,`use`])&&Lo(t.use))&&!(t.kind===`device-runtime`&&(H(n,[`kind`,`uses`])||H(n,[`kind`,`selectUses`,`uses`])&&typeof t.selectUses==`function`)&&Fo(t.uses)))throw Vo()}function Fo(e){if(!Array.isArray(e)||e.length===0||!e.every(Lo))return!1;let t=e.map(Jr);return new Set(t).size===t.length}function Io(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&H(Object.keys(t).sort(),[`kind`])}function Lo(e){if(typeof e!=`object`||!e)return!1;let t=e,n=[zo(t.required),zo(t.preferred),zo(t.conditional??[])];if(!Ro(n))return!1;let r=n.flat();return new Set(r).size===r.length&&H(Object.keys(t).sort(),t.conditional===void 0?[`preferred`,`required`]:[`conditional`,`preferred`,`required`])}function Ro(e){return e.every(e=>e!==null&&Bo(e))}function zo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Bo(e){return new Set(e).size===e.length}function H(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Vo(){return TypeError(`Command platform execution must declare exactly one of none, host, inventory, or device-runtime`)}const Ho=I({required:[`screenRecordingStart`]}),Uo=I({required:[`screenRecordingReattach`,`screenRecordingCleanup`]}),Wo=I({required:[]}),Go=I({required:[],preferred:[`screenRecordingStart`]}),Ko=Object.freeze([Ho,Uo]);function qo(t){switch((t.action??``).toLowerCase()){case`start`:if(!Jo(t.scope??`app`))throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`);return Object.freeze({kind:`start`,use:Ho});case`stop`:return t.hasLiveHandle===!0?Object.freeze({kind:`stop-live`,use:Wo}):Object.freeze({kind:`stop-recovery`,use:Uo});default:throw new e(`INVALID_ARGS`,`record requires start or stop`)}}function Jo(e){return e===`app`||e===`device`||e===`system`}function Yo(e){if(Po(e),e.kind!==`device-runtime`||!(`uses`in e))throw Xo();let t=e.uses.map(Jr),n=Ko.map(Jr),r=new Set(t),i=new Set(n);if(t.length!==n.length||r.size!==t.length||[...r].some(e=>!i.has(e)))throw Xo()}function Xo(){return TypeError(`Record runtime execution must declare exactly the uses selected by its two runtime-bearing plans`)}function Zo(e){let t=e.platformExecution;if(t===void 0)throw TypeError(`Command descriptor "${e.name}" must declare platformExecution (none, host, inventory, or device-runtime); there is no registry-entry default`);return Po(t),t}const U={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},W={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},G=()=>!0,Qo=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,$o=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),es=e=>(e.positionals?.length??0)===0?{kind:`unconditional`}:void 0,ts=e=>{let t=e.flags?.leaseProvider;return e.flags?.leaseId===void 0&&typeof t==`string`&&(e.flags?.platform===`android`||e.flags?.platform===`ios`)?{kind:`provider-app-catalog`,provider:t}:void 0},ns=new Set([`status`,`get`]),rs=e=>ps(e,ns,`status`),is=new Set([`get`,`wait`]),as=e=>ps(e,is,`get`),os=e=>ms(e,ns,`status`),ss=e=>ms(e,is,`get`),cs=e=>{try{return sn(_n(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}},ls=e=>ms(e,new Set([`read`]),``),us=e=>Ba(e.positionals).kind===`read`,ds=e=>us(e)?`observes-app`:`mutates-app`,fs=e=>us(e)?`preserve`:`may-invalidate`;function ps(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function ms(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const K={kind:`none`},hs={kind:`host`},q={recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0},J={targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,deviceClaimPolicy:`require-owner`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0}},Y={...N,onTimeout:`preserve-daemon`},gs={...N,envelopeMs:18e4},_s={...N,onTimeout:`preserve-daemon`},vs={..._s,envelopeMs:33e4},ys={...N,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},bs={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}}},xs={fields:{delayMs:{defaultValue:0}}};function X(e,t){return kr(e)===void 0?t:ys}function Z(e){let t=kr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const Ss={deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Wa},timeoutPolicy:gs,batchable:!0},Cs=e=>{let t=e.flags?.snapshotCustomActions===!0||e.input?.customActions===!0;return[!0,!1].map(e=>wa({customActions:t,hasActiveApp:e}).use)},ws=e=>{let t=Es(e);if(t===void 0||!Ts(t))return ya;let n=Sa(t);return[!0,!1].map(e=>Ca({hasActiveApp:e,intent:n}).use)};function Ts(e){return sn(e)||e===`focus`||e===`type`}function Es(e){if(e.positionals===void 0)return;let t=mn(e.positionals,e.flags);return t.ok?t.parsed.action:void 0}const Ds=[{name:`human_control`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`humanControl`},recordsSessionAction:!1,daemon:{route:`humanControl`,refFrameEffect:`preserve`,selectorValidationExempt:!0,skipSessionlessProviderDevice:G},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`lease_allocate`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U},timeoutPolicy:vs,batchable:!1,platformExecution:K},{name:`lease_heartbeat`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U,appLease:`allowed`},timeoutPolicy:_s,batchable:!1,platformExecution:K},{name:`lease_release`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U,appLease:`allowed`},timeoutPolicy:_s,batchable:!1,platformExecution:K},{name:`artifacts`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...U},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session_list`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session_save_script`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`devices`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...W},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`inventory`,use:No}},{name:`capabilities`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...W},timeoutPolicy:N,batchable:!0,platformExecution:K},{name:`doctor`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:G,...W},timeoutPolicy:N,batchable:!0,platformExecution:hs},{name:`apps`,deviceClaimPolicy:`observe`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,sessionlessLeaseAdmissionExemption:ts},platformExecution:{kind:`device-runtime`,uses:[$r]},timeoutPolicy:N,batchable:!0},{name:`boot`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:ka},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0},{name:`shutdown`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,use:Fa},timeoutPolicy:N,batchable:!0},{name:`appstate`,deviceClaimPolicy:`observe`,catalog:{group:`public`,key:`appState`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},platformExecution:{kind:`device-runtime`,uses:Pa},timeoutPolicy:N,batchable:!0},{name:`perf`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ki}},{name:`logs`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:fo},timeoutPolicy:N,batchable:!0},{name:`events`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`network`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:Co},timeoutPolicy:N,batchable:!0},{name:`audio`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:_o}},{name:`replay`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:$o,saveScriptFlagOwner:!0},timeoutPolicy:{...N,budget:{source:`flag`}},batchable:!1,platformExecution:K},{name:`test`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:$o},timeoutPolicy:{...N,envelopeMs:`unbounded`},batchable:!0,platformExecution:K},{name:`runtime`,deviceClaimPolicy:`require-owner`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[...so,qi]}},{name:`clipboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:ls,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ia}},{name:`keyboard`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:os,daemon:{route:`session`,refFrameEffect:rs,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ua}},{name:`install`,...Ss},{name:`reinstall`,...Ss},{name:`install_source`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`internal`,key:`installSource`,servesPublicCommand:`install-from-source`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ga},timeoutPolicy:gs,batchable:!1},{name:`release_materialized_paths`,deviceClaimPolicy:`none`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...W},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`push`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},platformExecution:{kind:`device-runtime`,use:Ka},timeoutPolicy:N,batchable:!0},{name:`trigger-app-event`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`triggerAppEvent`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[mi]}},{name:`open`,deviceClaimPolicy:`acquire-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:G,saveScriptFlagOwner:!0,appLease:`allowed`},timeoutPolicy:{...N,budget:{source:`flag`,envelope:`margin`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:Qa}},{name:`prepare`,deviceClaimPolicy:`transient-exclusive`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`,envelope:`margin`},envelopeMs:27e4,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1,platformExecution:{kind:`device-runtime`,use:io}},{name:`batch`,deviceClaimPolicy:`none`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,appLease:`allowed`},timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`close`,deviceClaimPolicy:`release-session`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0,sessionlessLeaseAdmissionExemption:es,appLease:`allowed`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:to}},{name:`snapshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:xa,selectUses:Cs}},{name:`diff`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:xa,selectUses:Cs}},{name:`wait`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:hr}},batchable:!0,platformExecution:{kind:`device-runtime`,uses:ba}},{name:`alert`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:ss,daemon:{route:`snapshot`,refFrameEffect:as},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ha}},{name:`settings`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:ds,daemon:{route:`snapshot`,refFrameEffect:fs},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:La}},{name:`react-native`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`reactNative`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[L]}},{name:`record`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:Qo},platformExecution:{kind:`device-runtime`,uses:Ko},timeoutPolicy:Y,batchable:!0},{name:`trace`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:N,batchable:!0,platformExecution:K},{name:`find`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:cs,daemon:{route:`find`,refFrameEffect:`may-invalidate`,appLease:`allowed`},timeoutPolicy:Y,batchable:!0,platformExecution:{kind:`device-runtime`,uses:ya,selectUses:ws}},{name:`click`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0,appLease:`allowed`},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),targetReadiness:`budgeted`,responseDataTransform:bs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Li}},{name:`fill`,...J,daemon:{...J.daemon,appLease:`allowed`},frameworkTier:`core`,timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:xs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Vi}},{name:`longpress`,...J,catalog:{group:`public`,key:`longPress`},frameworkTier:`extended`,timeoutPolicy:{...ys,envelopeMs:21e4},postActionObservation:Z(`longpress`),targetReadiness:`budgeted`,batchable:!0,platformExecution:{kind:`device-runtime`,uses:zi}},{name:`hover`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`},timeoutPolicy:X(`hover`,Y),postActionObservation:Z(`hover`),batchable:!0,platformExecution:{kind:`device-runtime`,uses:Bi}},{name:`press`,...J,daemon:{...J.daemon,appLease:`allowed`},frameworkTier:`core`,timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),targetReadiness:`budgeted`,responseDataTransform:bs,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Ri}},{name:`type`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0,appLease:`allowed`},timeoutPolicy:X(`type`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:[ri]}},{name:`get`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:X(`get`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:ma}},{name:`is`,deviceClaimPolicy:`require-owner`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:X(`is`,Y),batchable:!0,platformExecution:{kind:`device-runtime`,uses:pa}},{name:`back`,catalog:{group:`public`},frameworkTier:`core`,...q,timeoutPolicy:X(`back`,N),postActionObservation:Z(`back`),platformExecution:{kind:`device-runtime`,uses:[ii]}},{name:`gesture`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Zi}},{name:`home`,catalog:{group:`public`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[ai]}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[ci]}},{name:`orientation`,catalog:{group:`public`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[oi]}},{name:`fold`,catalog:{group:`public`},frameworkTier:`extended`,...q,timeoutPolicy:yr,platformExecution:{kind:`device-runtime`,uses:[si]}},{name:`scroll`,catalog:{group:`public`},frameworkTier:`core`,...q,daemon:{...q.daemon,appLease:`allowed`},timeoutPolicy:X(`scroll`,N),postActionObservation:Z(`scroll`),platformExecution:{kind:`device-runtime`,uses:$i}},{name:`swipe`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Qi}},{name:`focus`,catalog:{group:`public`},frameworkTier:`extended`,...q,daemon:{...q.daemon,appLease:`allowed`},platformExecution:{kind:`device-runtime`,uses:[ni]}},{name:`screenshot`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`core`,recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`,appLease:`allowed`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:Da}},{name:`viewport`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!1,platformExecution:{kind:`device-runtime`,uses:[ti]}},{name:`app-switcher`,deviceClaimPolicy:`require-owner`,catalog:{group:`public`,key:`appSwitcher`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},timeoutPolicy:N,batchable:!0,platformExecution:{kind:`device-runtime`,uses:[fi]}},{name:`action-button`,catalog:{group:`public`,key:`actionButton`},frameworkTier:`extended`,...q,platformExecution:{kind:`device-runtime`,uses:[pi]}},{name:`install-from-source`,deviceClaimPolicy:`none`,catalog:{group:`public`,key:`installFromSource`},frameworkTier:`extended`,recordsSessionAction:!0,recordingEffect:`mutates-app`,platformExecution:{kind:`device-runtime`,use:Ga},timeoutPolicy:N,batchable:!0},{name:`debug`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`daemon`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:hs},{name:`device`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`metro`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`session`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,platformExecution:K},{name:`cdp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`auth`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`plugins`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`connection`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`disconnect`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`mcp`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`proxy`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`takeover`,deviceClaimPolicy:`observe`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:{kind:`inventory`,use:No}},{name:`react-devtools`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:K},{name:`web`,deviceClaimPolicy:`none`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:N,batchable:!1,mcpExposed:!1,platformExecution:hs}],Os=new Set([`public`,`local-cli`]),ks=new Set(Ds.filter(e=>Os.has(Ls(e))).map(e=>e.name)),Q=Ds.map(e=>{let t=Zo(e);return e.name===`record`&&Yo(t),{...e,mcpExposed:Fs(e),platformExecution:t}});function As(e){return Q.filter(t=>Ls(t)===e).map(e=>[Rs(e),e.name])}function js(){return Q.filter(e=>Is(e)).map(e=>e.name).sort()}function Ms(e){let t=Q.find(t=>t.name===e)?.platformExecution;if(t?.kind===`device-runtime`)return(`uses`in t?t.uses:[t.use]).map(e=>e.required)}function Ns(){return Q.filter(e=>e.catalog.group===`public`&&e.platformExecution.kind===`device-runtime`).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function Ps(e){return ks.has(e)}function Fs(e){return e.mcpExposed??ks.has(e.name)}function Is(e){return e.mcpExposed&&Ps(e.name)}function Ls(e){return e.catalog.group}function Rs(e){return e.catalog.key??e.name}const zs=new Map(Array.from($.values(),e=>[e.name,e.targetReadiness?{...e.timeoutPolicy,targetReadiness:e.targetReadiness}:e.timeoutPolicy])),Bs=new Map(Q.map(e=>[e.name,e.deviceClaimPolicy])),Vs=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function Hs(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Us(e){return Hs(e)!==void 0}function Ws(e){return e!==void 0&&$.get(e)?.targetReadiness===`budgeted`}function Gs(e){return Hs(e)===`settle-and-verify`}function Ks(e){return e===void 0?N:zs.get(e)??N}function qs(e){return e===void 0?`require-owner`:Bs.get(e)??`require-owner`}function Js(e){if(e!==void 0)return Vs.get(e)}function Ys(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Xs(e){if(e!==void 0)return $.get(e)?.frameworkTier}function Zs(e){return $.get(e)?.targetIdentityVerification}function Qs(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function $s(){return[...new Set(Array.from(Vs.values()).flatMap(e=>Object.keys(e.fields)))].sort()}const ec={apps:{appsFilter:`user-installed`}};function tc(e,t){if(!e||!Ps(e))return!1;let n=ec[e];if(!n)return!1;let r=!1;for(let e of Object.keys(n))t[e]===void 0&&(t[e]=n[e],r=!0);return r}function nc(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function rc(e){return e.filter(e=>e.batchable).map(e=>e.name)}const ic=rc(Q),ac=new Set([`batch`,`replay`]),oc=[`command`,`positionals`,`input`,`flags`,`runtime`],sc=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`,`testIme`],cc=`Session, daemon, connection, and host tooling commands are excluded from batch — they own lifecycle a batch cannot carry — and batch and replay never nest. Run an excluded command on its own; every other device command is available as a step.`,lc=new Set(ic);function uc(e){return lc.has(e)}function dc(e){return typeof e==`string`?e.trim().toLowerCase():``}function fc(e){let t=dc(e);return uc(t)?t:void 0}function pc(t,n,r=cc){let i=fc(t);if(i!==void 0)return i;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`,{hint:r})}function mc(t,n){if(ac.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{pi as $,mt as $n,ee as $r,jr as $t,Ao as A,kn as An,Ee as Ar,Ti as At,eo as B,tn as Bn,ge as Br,wa as Bt,Ys as C,zn as Cn,v as Cr,ui as Ct,qo as D,En as Dn,g as Dr,oi as Dt,Zs as E,An as En,ke as Er,ji as Et,vo as F,cn as Fn,_e as Fr,na as Ft,Xa as G,Zt as Gn,pe as Gr,L as Gt,no as H,Jt as Hn,fe as Hr,gi as Ht,uo as I,sn as In,ve as Ir,Oa as It,io as J,Yt as Jn,ie as Jr,ti as Jt,Ja as K,Ht as Kn,le as Kr,ci as Kt,po as L,on as Ln,ye as Lr,ra as Lt,Do as M,fn as Mn,Se as Mr,Ei as Mt,ho as N,pn as Nn,we as Nr,Oi as Nt,Go as O,Tn as On,xe as Or,Ci as Ot,xo as P,mn as Pn,m as Pr,Ma as Pt,Ka as Q,qt as Qn,f as Qr,Vr as Qt,ao as R,_n as Rn,p as Rr,Ca as Rt,Qs as S,Rn as Sn,b as Sr,Ni as St,Ks as T,Dn as Tn,y as Tr,li as Tt,ro as U,Wt as Un,de as Ur,hi as Ut,oo as V,O as Vn,he as Vr,Hi as Vt,qa as W,en as Wn,ue as Wr,Fa as Wt,Wa as X,Kt as Xn,l as Xr,Ar as Xt,Za as Y,Vt as Yn,ae as Yr,Rr as Yt,Ga as Z,Gt as Zn,oe as Zr,Mr as Zt,As as _,Un as _n,Ze as _r,Sa as _t,mc as a,vr as an,T as ar,Na as at,qs as b,Hn as bn,Le as br,qi as bt,fc as c,ar as cn,dt as cr,ii as ct,Ws as d,qn as dn,nt as dr,Mi as dt,ne as ei,Nr as en,Et as er,yi as et,Q as f,tr as fn,ot as fr,Ai as ft,$s as g,rr as gn,Je as gr,Fi as gt,Gs as h,$n as hn,st as hr,I as ht,ic as i,o as ii,P as in,Ct as ir,mi as it,wo as j,rn as jn,Oe as jr,Di as jt,Uo as k,wn as kn,De as kr,wi as kt,nc as l,M as ln,ct as lr,Ii as lt,Us as m,er as mn,it as mr,Si as mt,oc as n,d as ni,Fr as nn,Dt as nr,_i as nt,dc as o,_r as on,w as or,fi as ot,Ms as p,Qn as pn,at as pr,xi as pt,Ya as q,Xt as qn,ce as qr,ri as qt,sc as r,re as ri,Ir as rn,kt as rr,vi as rt,pc as s,br as sn,lt as sr,$r as st,cc as t,te as ti,Pr as tn,wt as tr,bi as tt,tc as u,nr as un,rt as ur,Pi as ut,js as v,Gn as vn,Xe as vr,ni as vt,Js as w,On as wn,x as wr,di as wt,Xs as x,Wn as xn,Fe as xr,ai as xt,Ns as y,Bn as yn,Ne as yr,si as yt,$a as z,yn as zn,me as zr,Ba as zt};
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
declare const KNOWN_APP_ERROR_CODES: readonly ['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'];
|
|
11
11
|
type KnownAppErrorCode = (typeof KNOWN_APP_ERROR_CODES)[number];
|
|
12
12
|
type AppErrorCode = KnownAppErrorCode | (string & {});
|
|
13
|
+
declare class AppError extends Error {
|
|
14
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
15
|
+
code: AppErrorCode;
|
|
16
|
+
details?: AppErrorDetails;
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
constructor(code: AppErrorCode, message: string, details?: AppErrorDetails, cause?: unknown);
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
21
|
* Locator for one request's diagnostics record on the daemon host, in the
|
|
15
22
|
* daemon's own vocabulary rather than as a filesystem path: `logPath` names
|
|
@@ -102,33 +109,7 @@ type NormalizedError = {
|
|
|
102
109
|
* error representation because clients immediately rehydrate this wire shape
|
|
103
110
|
* into `AppError` before rendering or handling it.
|
|
104
111
|
*/
|
|
105
|
-
type DaemonError =
|
|
106
|
-
code: string;
|
|
107
|
-
message: string;
|
|
108
|
-
cause?: ErrorCause;
|
|
109
|
-
hint?: string;
|
|
110
|
-
diagnosticId?: string;
|
|
111
|
-
/** Path on the DAEMON host. Meaningful to a local caller only (#1801). */
|
|
112
|
-
logPath?: string;
|
|
113
|
-
/** Why no readable path is named; set by the client, never by the daemon. */
|
|
114
|
-
logPathUnavailable?: string;
|
|
115
|
-
/**
|
|
116
|
-
* Additive locator (#1801) for the request diagnostics record `logPath`
|
|
117
|
-
* names, so a remote caller can fetch it over the daemon API instead of
|
|
118
|
-
* being handed a path on a filesystem it cannot read.
|
|
119
|
-
*/
|
|
120
|
-
diagnosticsRecord?: DiagnosticsRecordRef;
|
|
121
|
-
details?: ErrorWireDetails;
|
|
122
|
-
/** Additive retry and platform-support signals; absent when not derivable. */
|
|
123
|
-
retriable?: boolean;
|
|
124
|
-
supportedOn?: string;
|
|
125
|
-
};
|
|
126
|
-
declare class AppError extends Error {
|
|
127
|
-
code: AppErrorCode;
|
|
128
|
-
details?: AppErrorDetails;
|
|
129
|
-
cause?: unknown;
|
|
130
|
-
constructor(code: AppErrorCode, message: string, details?: AppErrorDetails, cause?: unknown);
|
|
131
|
-
}
|
|
112
|
+
type DaemonError = NormalizedError;
|
|
132
113
|
declare function isAgentDeviceError(err: unknown): err is AppError;
|
|
133
114
|
type NormalizeErrorContext = {
|
|
134
115
|
diagnosticId?: string;
|
|
@@ -206,7 +187,15 @@ type Point = {
|
|
|
206
187
|
x: number;
|
|
207
188
|
y: number;
|
|
208
189
|
};
|
|
190
|
+
type IosSnapshotObservation = {
|
|
191
|
+
mode: 'observe-only';
|
|
192
|
+
activationPerformed: false;
|
|
193
|
+
/** XCTest's report, not proof of foreground ownership (#2696). */
|
|
194
|
+
appState: 'runningForeground';
|
|
195
|
+
appStateSource: 'xcuiapplication-state';
|
|
196
|
+
};
|
|
209
197
|
type SnapshotOptions = {
|
|
198
|
+
observeOnly?: boolean;
|
|
210
199
|
interactiveOnly?: boolean;
|
|
211
200
|
depth?: number;
|
|
212
201
|
scope?: string;
|
|
@@ -231,6 +220,7 @@ declare const SNAPSHOT_OPTION_FLAGS: {
|
|
|
231
220
|
readonly depth: 'snapshotDepth';
|
|
232
221
|
readonly scope: 'snapshotScope';
|
|
233
222
|
readonly raw: 'snapshotRaw';
|
|
223
|
+
readonly observeOnly: 'snapshotObserveOnly';
|
|
234
224
|
readonly customActions: 'snapshotCustomActions';
|
|
235
225
|
readonly forceFull: 'snapshotForceFull';
|
|
236
226
|
readonly includeHiddenContentHints: 'snapshotIncludeHiddenContentHints';
|
|
@@ -238,6 +228,7 @@ declare const SNAPSHOT_OPTION_FLAGS: {
|
|
|
238
228
|
};
|
|
239
229
|
type SnapshotOptionKey = keyof typeof SNAPSHOT_OPTION_FLAGS;
|
|
240
230
|
type SnapshotOptionValues = {
|
|
231
|
+
observeOnly: boolean;
|
|
241
232
|
interactiveOnly: boolean;
|
|
242
233
|
depth: number;
|
|
243
234
|
scope: string;
|
|
@@ -254,7 +245,7 @@ type SnapshotOptionFields<TKeys extends SnapshotOptionKey = SnapshotOptionKey> =
|
|
|
254
245
|
* resolved against the session before capture, so seams that resolve it spread
|
|
255
246
|
* this projection and then override that one key.
|
|
256
247
|
*/
|
|
257
|
-
declare const SNAPSHOT_COMMAND_OPTION_KEYS: readonly ['interactiveOnly', 'depth', 'scope', 'raw', 'customActions', 'forceFull'];
|
|
248
|
+
declare const SNAPSHOT_COMMAND_OPTION_KEYS: readonly ['observeOnly', 'interactiveOnly', 'depth', 'scope', 'raw', 'customActions', 'forceFull'];
|
|
258
249
|
/**
|
|
259
250
|
* The snapshot capture options a `snapshot`/`diff` request is stated in, in
|
|
260
251
|
* every vocabulary that names them: the public SDK type, the internal request
|
|
@@ -339,7 +330,8 @@ type RawSnapshotNode = {
|
|
|
339
330
|
* A keyboard is its own system surface, so it never reaches the tree as a covering sibling of app
|
|
340
331
|
* content, and a consumer that wants to refuse a tap behind it has to learn where it is from
|
|
341
332
|
* somewhere (#2589). A producer that can measure the band directly — the Apple runner, from its
|
|
342
|
-
* `app.keyboards` query
|
|
333
|
+
* `app.keyboards` query, and the Android helper, from the input method window in the window list it
|
|
334
|
+
* captures — publishes one fact per capture and says nothing else about it. A consumer therefore gets three
|
|
343
335
|
* answers and no fourth: a band in the same space as every node rect, a proven absence, or a
|
|
344
336
|
* producer that could not look.
|
|
345
337
|
*
|
|
@@ -529,9 +521,9 @@ type SnapshotState = {
|
|
|
529
521
|
*/
|
|
530
522
|
iosSystemSurfaceBundleId?: string;
|
|
531
523
|
/**
|
|
532
|
-
* iOS: the keyboard band this capture's producer measured, when it measured one. The
|
|
533
|
-
* keyboard guard prefers this over the band it would otherwise derive from `nodes`,
|
|
534
|
-
* producer that can query the keyboard directly answers in the
|
|
524
|
+
* iOS and Android: the keyboard band this capture's producer measured, when it measured one. The
|
|
525
|
+
* tap-path keyboard guard prefers this over the band it would otherwise derive from `nodes`,
|
|
526
|
+
* because a producer that can query the keyboard directly answers in the tree's own space and
|
|
535
527
|
* needs no geometry to be plausible (#2660). Absent means the guard measures the tree as before.
|
|
536
528
|
*/
|
|
537
529
|
keyboard?: SnapshotKeyboardBandFact;
|
|
@@ -735,4 +727,4 @@ type JsonRpcRequestEnvelope<TParams = unknown> = {
|
|
|
735
727
|
params?: TParams;
|
|
736
728
|
};
|
|
737
729
|
//#endregion
|
|
738
|
-
export {
|
|
730
|
+
export { normalizeAgentDeviceError as $, RawSnapshotNode as A, SnapshotUnchanged as B, Platform as C, IosSnapshotObservation as D, AppleApplicationState as E, SnapshotNode as F, AppErrorCode as G, SnapshotVisibility as H, SnapshotOptions as I, ErrorCause as J, AppErrorDetails as K, SnapshotProvenance as L, ScreenshotOverlayRef as M, SnapshotCommandOptionFields as N, IosTargetActivation as O, SnapshotKeyboardBandFact as P, isAgentDeviceError as Q, SnapshotQualityVerdict as R, DeviceTarget as S, PublicPlatform as T, centerOfRect as U, SnapshotViewportSize as V, AppError as W, NormalizedError as X, KnownAppErrorCode as Y, defaultHintForCode as Z, SessionIsolationMode as _, DaemonRequest as a, DeviceInfo as b, DaemonServerMode as c, JsonRpcRequestEnvelope as d, normalizeError as et, LeaseBackend as f, ResponseLevel as g, ResponseCost as h, DaemonLockPolicy as i, Rect as j, Point as k, DaemonTransportPreference as l, NetworkIncludeMode as m, DaemonArtifactType as n, DaemonResponse as o, LocalInstallSource as p, DaemonError as q, DaemonInstallSource as r, DaemonResponseData as s, DaemonArtifact as t, JsonRpcId as u, SessionRuntimeHints as v, PlatformSelector as w, DeviceKind as x, AppleOS as y, SnapshotState as z };
|