agent-device 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.0.apk → agent-device-android-ime-helper-0.21.2.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.2.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.0.manifest.json → agent-device-android-ime-helper-0.21.2.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.2.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.2.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.0.manifest.json → agent-device-android-snapshot-helper-0.21.2.manifest.json} +6 -6
- package/apple/snapshot-bridge/README.md +58 -1
- package/apple/snapshot-bridge/SnapshotBridge.m +6 -0
- package/apple/snapshot-bridge/SnapshotBridgeCapture.h +25 -0
- package/apple/snapshot-bridge/SnapshotBridgeCapture.m +138 -0
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +1 -0
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +32 -3
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +20 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +413 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +15 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSystemSurfaceHostPolicy.swift +72 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +63 -14
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +668 -82
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +48 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+BlockingSystemModalResolution.swift +39 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +1078 -211
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +290 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +10 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +250 -74
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +101 -42
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -13
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +55 -43
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +71 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +144 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +13 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +216 -17
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +206 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +289 -42
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +92 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +617 -122
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +79 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +71 -71
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +92 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +67 -67
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +4 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +17 -17
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +30 -30
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +31 -31
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputCandidatePolicy.swift +28 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +101 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +19 -19
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +55 -17
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +26 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +126 -75
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +8 -12
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +9 -9
- package/dist/src/absence-observation-errors.js +1 -0
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +1 -1
- package/dist/src/adb-failure.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-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.d.ts +1 -1
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/app-catalog.js +1 -1
- package/dist/src/app-deployment-resolution.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-inventory-contract.js +1 -1
- package/dist/src/app-inventory.js +1 -1
- package/dist/src/app-launch.js +2 -2
- package/dist/src/app-lifecycle.js +3 -3
- package/dist/src/app-lifecycle2.js +1 -1
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +1 -1
- package/dist/src/apple-runner-platform.js +1 -0
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/back-mode.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/boot-diagnostics.js +1 -1
- package/dist/src/browser-launch.js +1 -0
- package/dist/src/capture.js +1 -1
- package/dist/src/catalog.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +30 -26
- package/dist/src/cli.js +4 -4
- package/dist/src/click-button.js +1 -1
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +28 -13
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/code-signature.js +1 -1
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +3 -3
- package/dist/src/command-tools.js +2 -2
- package/dist/src/command.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +3 -3
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-process.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -1
- package/dist/src/daemon.js +1 -1
- package/dist/src/debug-symbols-facade.js +1 -1
- package/dist/src/device-boot.js +1 -0
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -1
- package/dist/src/doctor2.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/engine-eval-script.js +1 -0
- package/dist/src/error.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 +1 -2
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/gesture-plan.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/human-control-contract.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +2 -2
- package/dist/src/install-artifact-facade.js +1 -1
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/install-source2.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/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/internal/png-worker.d.ts +3 -0
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-http-child.js +1 -1
- package/dist/src/inventory.js +2 -2
- package/dist/src/inventory2.js +1 -1
- package/dist/src/inventory3.js +1 -1
- package/dist/src/inventory5.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-planning.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/ios-system-surface.js +1 -0
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +16 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/mp4-atoms.js +1 -0
- package/dist/src/multitouch-support.js +1 -1
- package/dist/src/observation.js +1 -1
- package/dist/src/open-target-resolution.js +1 -0
- package/dist/src/owner-identity.js +3 -3
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +2 -2
- package/dist/src/perf-process-identity.js +1 -0
- package/dist/src/perf-runtime-operation-builder.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf.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-android-adb-host.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +2 -2
- package/dist/src/platform-runtime-runtime-hints.js +2 -2
- package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.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/png-crop-bytes.js +1 -0
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/png.js +1 -0
- package/dist/src/prepare-kind.js +1 -1
- package/dist/src/process.js +1 -1
- package/dist/src/provider-device-runtime.js +1 -1
- package/dist/src/provider-session-ownership.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/quality-warnings.js +1 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/rect-center.js +1 -1
- package/dist/src/register-builtins.js +1 -1
- package/dist/src/registry.js +36 -36
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay.js +2 -2
- package/dist/src/reporting.js +9 -8
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-cancel.js +1 -1
- package/dist/src/request-cancellation.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/retry.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-presentation.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-transport-hints.js +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime10.js +1 -0
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +5 -4
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-live-handle.js +1 -1
- package/dist/src/screen-recording-options.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot3.js +3 -3
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-command.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +69 -26
- 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-io.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +80 -16
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/server.js +3 -3
- package/dist/src/session-allocation.js +1 -1
- package/dist/src/session-observation.js +1 -0
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/settings.js +1 -1
- package/dist/src/simulator-boot.js +3 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-quality-backend-capabilities.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +2 -2
- package/dist/src/src8.js +2 -2
- package/dist/src/string-enum.js +1 -1
- package/dist/src/takeover.js +1 -1
- package/dist/src/telemetry.js +1 -1
- package/dist/src/tool-provider.js +2 -2
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -1
- package/dist/src/toolchain-probe.js +1 -1
- package/dist/src/touch-reference-frame.js +1 -0
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/transport.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/vars.js +2 -0
- package/dist/src/verified-file.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/video.js +2 -2
- package/dist/src/viewport.js +1 -0
- package/dist/src/web.js +1 -1
- package/dist/src/web2.js +1 -1
- package/dist/src/webdriver-ios-snapshot.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/dist/src/window-state.js +1 -0
- package/package.json +4 -2
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.0.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.0.apk.sha256 +0 -1
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -93
- package/dist/src/platform-runtime-apple-resources.js +0 -1
- package/dist/src/runner-selector-query.js +0 -1
- package/dist/src/snapshot-quality-verdict.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";const t=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,n=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,r=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,i=/https?:\/\/[^\s"'<>]+/gi;function a(e){return s(e,new WeakSet)}function o(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.message==`string`&&t.message.length!==0)return a({message:t.message,...typeof t.code==`string`&&t.code.length>0?{code:t.code}:{}})}function s(e,n,r){if(e==null)return e;if(typeof e==`string`)return c(e,r);if(typeof e!=`object`)return e;if(n.has(e))return`[Circular]`;if(n.add(e),Array.isArray(e))return e.map(e=>s(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=s(a,n,r)}return i}function c(e,i){let a=e.trim();if(!a)return l(e);if(i&&t.test(i))return`[REDACTED]`;let o=u(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>f({key:t,separator:n,rawValue:r,offset:i,input:a})||d(r)?e:`${t}${n}[REDACTED]`),l(o)}function l(e){return e.length<=400?e:`${e.slice(0,386)}...<truncated>`}function u(e){return e.replace(i,e=>p(e)??e)}function d(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function f(e){if(e.key.toLowerCase()!==`token`||!e.separator.includes(`:`))return!1;try{return new URL(e.rawValue).pathname.replace(/\/+$/,``)===`/api-keys`&&/(?:^|\b)(?:service\/)?api\s+$/i.test(e.input.slice(0,e.offset))}catch{return!1}}function p(e){try{let t=new URL(e);return t.search&&=`?REDACTED`,(t.username||t.password)&&(t.username=`REDACTED`,t.password=`REDACTED`),t.toString()}catch{return null}}var m=e({AppError:()=>b,KNOWN_APP_ERROR_CODES:()=>h,asAppError:()=>D,createRequestCanceledError:()=>w,defaultHintForCode:()=>F,errorMessage:()=>E,isAgentDeviceError:()=>O,isRequestCanceledError:()=>T,normalizeAgentDeviceError:()=>k,normalizeError:()=>A,readDiagnosticsRecordRef:()=>N,readElementMatchCandidateRefs:()=>v,readErrorCandidateViews:()=>_,retriableForErrorCode:()=>P,throwDaemonError:()=>x,toAppErrorCode:()=>g});const h=[`INVALID_ARGS`,`DEVICE_NOT_FOUND`,`DEVICE_IN_USE`,`TOOL_MISSING`,`APP_NOT_INSTALLED`,`UNSUPPORTED_PLATFORM`,`UNSUPPORTED_OPERATION`,`NOT_IMPLEMENTED`,`COMMAND_FAILED`,`SESSION_NOT_FOUND`,`UNAUTHORIZED`,`AMBIGUOUS_MATCH`,`REPLAY_DIVERGENCE`,`REPAIR_SESSION_EXPIRED`,`REPAIR_COMMIT_FAILED`,`UNKNOWN`];function g(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}function _(e){let t=y(e?.candidates),n=[];if(t.length>0){let r=typeof e?.matches==`number`?e.matches:t.length,i=typeof e?.refsGeneration==`number`?e.refsGeneration:void 0;n.push({kind:`element-match`,candidates:t,matches:r,...i===void 0?{}:{refsGeneration:i}})}let r=ee(e?.devices);return r.length>0&&n.push({kind:`device`,devices:r}),n}function v(e){return y(e?.candidates).flatMap(e=>{let t=/^@(e\d+)(?:~s\d+)?(?:\s|$)/.exec(e);return t?.[1]?[t[1]]:[]})}function y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ee(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}var b=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function x(e){throw new b(g(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,logPathUnavailable:e.logPathUnavailable,diagnosticsRecord:e.diagnosticsRecord,retriable:e.retriable,supportedOn:e.supportedOn},e.cause)}const S=`request_canceled`,C=`request canceled`;function w(e,t){return new b(`COMMAND_FAILED`,C,{hint:`The request was canceled intentionally (explicit cancel or client disconnect) — no retry is needed unless the cancellation was unintended.`,...e,reason:S},t)}function T(e){return!(e instanceof b)||e.code!==`COMMAND_FAILED`?!1:e.details?.reason===S||e.message===C}function E(e){return e instanceof Error?e.message:String(e)}function D(e,t=`UNKNOWN`){return e instanceof b?e:e instanceof Error?new b(t,e.message,void 0,e):new b(t,`Unknown error`,{err:e})}function O(e){return e instanceof b}function k(e,t={}){return A(e,t)}function A(e,t={}){let n=D(e),r=n.details?a(n.details):void 0,i=M(r,`diagnosticId`)??t.diagnosticId,s=M(r,`logPath`)??t.logPath,c=M(r,`logPathUnavailable`),l=N(r?.diagnosticsRecord)??t.diagnosticsRecord,u=M(r,`hint`)??F(n.code),d=ae(r,`retriable`)??P(n.code),f=M(r,`supportedOn`),p=oe(r),m=ne(n.code,n.message,r),h=o(n.cause);return{code:n.code,message:m,...h===void 0?{}:{cause:h},hint:u,diagnosticId:i,logPath:s,...c===void 0?{}:{logPathUnavailable:c},...l===void 0?{}:{diagnosticsRecord:l},...d===void 0?{}:{retriable:d},...f===void 0?{}:{supportedOn:f},details:p}}const te=/^\S+ exited with code -?\d+$/;function ne(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=
|
|
2
|
-
`)){let e=t.trim();if(!e||re.some(t=>t.test(e)))continue;let n=e.replace(
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";const t=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,n=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,r=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,i=/https?:\/\/[^\s"'<>]+/gi;function a(e){return s(e,new WeakSet)}function o(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.message==`string`&&t.message.length!==0)return a({message:t.message,...typeof t.code==`string`&&t.code.length>0?{code:t.code}:{}})}function s(e,n,r){if(e==null)return e;if(typeof e==`string`)return c(e,r);if(typeof e!=`object`)return e;if(n.has(e))return`[Circular]`;if(n.add(e),Array.isArray(e))return e.map(e=>s(e,n));let i={};for(let[r,a]of Object.entries(e)){if(t.test(r)){i[r]=`[REDACTED]`;continue}i[r]=s(a,n,r)}return i}function c(e,i){let a=e.trim();if(!a)return l(e);if(i&&t.test(i))return`[REDACTED]`;let o=u(a);return o=o.replace(n,`[REDACTED]`),o=o.replace(r,(e,t,n,r,i,a)=>f({key:t,separator:n,rawValue:r,offset:i,input:a})||d(r)?e:`${t}${n}[REDACTED]`),l(o)}function l(e){return e.length<=400?e:`${e.slice(0,386)}...<truncated>`}function u(e){return e.replace(i,e=>p(e)??e)}function d(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function f(e){if(e.key.toLowerCase()!==`token`||!e.separator.includes(`:`))return!1;try{return new URL(e.rawValue).pathname.replace(/\/+$/,``)===`/api-keys`&&/(?:^|\b)(?:service\/)?api\s+$/i.test(e.input.slice(0,e.offset))}catch{return!1}}function p(e){try{let t=new URL(e);return t.search&&=`?REDACTED`,(t.username||t.password)&&(t.username=`REDACTED`,t.password=`REDACTED`),t.toString()}catch{return null}}var m=e({AppError:()=>b,KNOWN_APP_ERROR_CODES:()=>h,asAppError:()=>D,createRequestCanceledError:()=>w,defaultHintForCode:()=>F,errorMessage:()=>E,isAgentDeviceError:()=>O,isRequestCanceledError:()=>T,normalizeAgentDeviceError:()=>k,normalizeError:()=>A,readDiagnosticsRecordRef:()=>N,readElementMatchCandidateRefs:()=>v,readErrorCandidateViews:()=>_,retriableForErrorCode:()=>P,throwDaemonError:()=>x,toAppErrorCode:()=>g});const h=[`INVALID_ARGS`,`DEVICE_NOT_FOUND`,`DEVICE_IN_USE`,`TOOL_MISSING`,`APP_NOT_INSTALLED`,`UNSUPPORTED_PLATFORM`,`UNSUPPORTED_OPERATION`,`NOT_IMPLEMENTED`,`COMMAND_FAILED`,`SESSION_NOT_FOUND`,`UNAUTHORIZED`,`AMBIGUOUS_MATCH`,`REPLAY_DIVERGENCE`,`REPAIR_SESSION_EXPIRED`,`REPAIR_COMMIT_FAILED`,`UNKNOWN`];function g(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}function _(e){let t=y(e?.candidates),n=[];if(t.length>0){let r=typeof e?.matches==`number`?e.matches:t.length,i=typeof e?.refsGeneration==`number`?e.refsGeneration:void 0;n.push({kind:`element-match`,candidates:t,matches:r,...i===void 0?{}:{refsGeneration:i}})}let r=ee(e?.devices);return r.length>0&&n.push({kind:`device`,devices:r}),n}function v(e){return y(e?.candidates).flatMap(e=>{let t=/^@(e\d+)(?:~s\d+)?(?:\s|$)/.exec(e);return t?.[1]?[t[1]]:[]})}function y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ee(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.name==`string`):[]}var b=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function x(e){throw new b(g(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,logPathUnavailable:e.logPathUnavailable,diagnosticsRecord:e.diagnosticsRecord,retriable:e.retriable,supportedOn:e.supportedOn},e.cause)}const S=`request_canceled`,C=`request canceled`;function w(e,t){return new b(`COMMAND_FAILED`,C,{hint:`The request was canceled intentionally (explicit cancel or client disconnect) — no retry is needed unless the cancellation was unintended.`,...e,reason:S},t)}function T(e){return!(e instanceof b)||e.code!==`COMMAND_FAILED`?!1:e.details?.reason===S||e.message===C}function E(e){return e instanceof Error?e.message:String(e)}function D(e,t=`UNKNOWN`){return e instanceof b?e:e instanceof Error?new b(t,e.message,void 0,e):new b(t,`Unknown error`,{err:e})}function O(e){return e instanceof b}function k(e,t={}){return A(e,t)}function A(e,t={}){let n=D(e),r=n.details?a(n.details):void 0,i=M(r,`diagnosticId`)??t.diagnosticId,s=M(r,`logPath`)??t.logPath,c=M(r,`logPathUnavailable`),l=N(r?.diagnosticsRecord)??t.diagnosticsRecord,u=M(r,`hint`)??F(n.code),d=ae(r,`retriable`)??P(n.code),f=M(r,`supportedOn`),p=oe(r),m=ne(n.code,n.message,r),h=o(n.cause);return{code:n.code,message:m,...h===void 0?{}:{cause:h},hint:u,diagnosticId:i,logPath:s,...c===void 0?{}:{logPathUnavailable:c},...l===void 0?{}:{diagnosticsRecord:l},...d===void 0?{}:{retriable:d},...f===void 0?{}:{supportedOn:f},details:p}}const te=/^\S+ exited with code -?\d+$/;function ne(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=j(typeof n?.stderr==`string`?n.stderr:``);return r?te.test(t)?r:t.includes(r)?t:`${t}: ${r}`:t}const re=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i],ie=/^(?:(?:adb|xcrun|simctl):\s*)?(?:error:\s*)?/i;function j(e){for(let t of e.split(`
|
|
2
|
+
`)){let e=t.trim();if(!e||re.some(t=>t.test(e)))continue;let n=e.replace(ie,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function M(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function N(e){if(!e||typeof e!=`object`)return;let{session:t,requestId:n}=e;if(typeof t==`string`&&typeof n==`string`&&t.length!==0&&n.length!==0)return{session:t,requestId:n}}function ae(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function oe(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.logPathUnavailable,delete t.diagnosticsRecord,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const se={DEVICE_IN_USE:!0};function ce(e){return h.includes(e)}function P(e){return ce(e)?se[e]:void 0}function F(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}const I={interactiveOnly:`snapshotInteractiveOnly`,depth:`snapshotDepth`,scope:`snapshotScope`,raw:`snapshotRaw`,customActions:`snapshotCustomActions`,forceFull:`snapshotForceFull`,includeHiddenContentHints:`snapshotIncludeHiddenContentHints`,preferredBackend:`snapshotPreferredBackend`},le=[`interactiveOnly`,`depth`,`scope`,`raw`,`customActions`,`forceFull`],L=[`interactiveOnly`,`preferredBackend`,`depth`,`scope`,`raw`,`customActions`,`includeHiddenContentHints`],R=[`depth`,`interactiveOnly`,`raw`,`scope`,`customActions`];function z(e,t){return Object.fromEntries(t.map(t=>[t,e?.[I[t]]]))}function B(e,t){return Object.fromEntries(t.flatMap(t=>{let n=e?.[t];return n===void 0?[]:[[I[t],n]]}))}function V(e){if(e===void 0||e.backend===void 0)return{};switch(e.backend){case`xctest`:return{backend:e.backend,producer:e.producer};case`android`:return{backend:e.backend,producer:e.producer};case`harmonyos-arkui`:return{backend:e.backend,producer:e.producer};case`macos-helper`:return{backend:e.backend,producer:e.producer};case`linux-atspi`:return{backend:e.backend,producer:e.producer};case`web`:return{backend:e.backend,producer:e.producer}}}function H(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function U(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}function W(e){return e.map((e,t)=>({...e,ref:e.ref??`e${t+1}`}))}const ue=/^~s(\d+)$/,de=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function G(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=ue.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function fe(e){let t=G(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function pe(e,t){return e.find(e=>e.ref===t)??null}function me(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function he(e){if(e)return z(e,R)}function ge(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const K=[`ios`,`android`,`harmonyos`];function _e(e){return K.some(t=>t===e)}const ve=[`summary`,`headers`,`body`,`all`],ye=[`digest`,`default`,`full`];function be(e){return e!==void 0&&e!=="default"}function q(e){return{parse(t){return e(t,`$`)}}}function J(e,t){throw Error(`${e}: ${t}`)}function Y(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&J(t,`Expected an object`),e}function X(e,t){return typeof e!=`string`&&J(t,`Expected a string`),e}function xe(e,t){return Number.isInteger(e)||J(t,`Expected an integer`),e}function Se(e,t){return Array.isArray(e)||J(t,`Expected an array`),e}function Z(e,t,n){let r=e[t];return r===void 0?void 0:X(r,`${n}.${t}`)}function Q(e,t,n){let r=e[t];if(r!==void 0)return Se(r,`${n}.${t}`).map((e,r)=>X(e,`${n}.${t}[${String(r)}]`))}function Ce(e,t,n){let r=e[t];return r===void 0?void 0:xe(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:Y(r,`${n}.${t}`)}function we(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&J(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const Te=q((e,t)=>{let n=Y(e,t);return{platform:we(n,`platform`,K,t),metroHost:Z(n,`metroHost`,t),metroPort:Ce(n,`metroPort`,t),bundleUrl:Z(n,`bundleUrl`,t),launchUrl:Z(n,`launchUrl`,t)}});function Ee(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&J(`${t}.id`,`Expected a string, number, or null`),n}const De=q((e,t)=>{let n=Y(e,t);return{jsonrpc:Z(n,`jsonrpc`,t),id:Ee(n,t),method:Z(n,`method`,t),params:n.params}}),Oe=q((e,t)=>{let n=Y(e,t);return{token:Z(n,`token`,t),session:Z(n,`session`,t),command:Z(n,`command`,t),positionals:Q(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{T as A,o as B,b as C,E as D,F as E,_ as F,P as I,x as L,A as M,N,m as O,v as P,g as R,U as S,w as T,B as _,be as a,V as b,de as c,W as d,me as f,fe as g,H as h,Te as i,k as j,O as k,L as l,pe as m,ye as n,_e as o,ge as p,Oe as r,De as s,ve as t,le as u,z as v,D as w,G as x,he as y,a as z};
|
package/dist/src/sdk-device.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return[e.deviceName,e.udid,e.serial].some(e=>typeof e==`string`&&e.trim().length>0)}function p(e){return e===`apple`||e===`ios`||e===`macos`}function m(e){return e.appleOs===`macos`||e.platform===`macos`}function h(e){return p(e.platform)&&!m(e)}function g(e){return e.platform===`android`||e.platform===`harmonyos`||p(e.platform)&&!m(e)}function _(e){return p(e.platform)?m(e)?`macos`:`ios`:e.platform}function v(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function y(e){return p(e.platform)&&e.target===`tv`}function b(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:y(e)?`tvos`:`ios`}function x(e){return c.includes(e)}function S(e){return l.includes(e)}function C(e){return s.includes(e)}function w(e,t){return t?t===`apple`?p(e.platform):t===`ios`?p(e.platform)&&!m(e):t===`macos`?p(e.platform)&&m(e):e.platform===t:!0}function T(e,t){return t?E(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function E(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function D(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&n!==`macos`&&r!==`desktop`)return t}function O(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>Y(e,t)).map(({device:e})=>e)}function k(e){return!e||e===`apple`||e===`ios`}async function A(e,t,n={}){let r=e.filter(e=>U(e,t));return j(r,t)||F(r,t.deviceName)||(Q(r)&&(r=O(r)),ee(r,t,n))}function j(e,t){if(M(t),t.udid)return N(e,t.udid);if(t.serial)return P(e,t)}function M(t){let n=t.platform;if(n){if(t.udid&&G(n))throw new e(`INVALID_ARGS`,`--udid selects Apple devices, but this request selected --platform ${n}.`,{hint:`Use --serial ${t.udid} for ${n} devices.`});if(t.serial&&p(n))throw new e(`INVALID_ARGS`,`--serial selects Android and HarmonyOS devices, but this request selected --platform ${n}.`,{hint:`Use --udid ${t.serial} for Apple devices.`})}}function N(t,n){let r=t.find(e=>e.id===n&&p(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n}`);return r}function P(t,n){let r=t.find(e=>e.id===n.serial&&G(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,K(n));return r}function F(t,n){if(!n)return;let r=J(n),i=t.find(e=>J(e.name)===r);if(!i){let r=I(t,n);throw new e(`DEVICE_NOT_FOUND`,`No device named ${n}`,r===void 0?void 0:{hint:r})}return i}function I(e,t){let n=e.find(e=>e.id===t);if(!n)return;let r=L(n.platform);if(r)return`${t} is the id of ${JSON.stringify(n.name)}, not its name. Did you mean ${r} ${t}?`}function L(e){if(p(e))return`--udid`;if(G(e))return`--serial`}function ee(e,t,n){let r=e[0];if(r!==void 0&&e.length===1)return r;e.length===0&&q(t,n);let i=B(e);i.length>1&&R(i);let a=i[0];return a||q(t,n),a}function R(t){let n=t.slice(0,10);throw new e(`AMBIGUOUS_MATCH`,`${t.length} devices match this request equally; select one explicitly.`,{devices:n.map(e=>({id:e.id,name:e.name})),matches:t.length,hint:z(n)})}function z(e){let t=e[0];return`Select the intended device explicitly, for example ${t&&G(t.platform)?`--serial ${t.id}`:`--udid ${t?.id??`<id>`}`} or --device ${JSON.stringify(t?.name??`<name>`)}. Run agent-device devices to list them.`}function B(e){let t=Q(e)?H(e):V(e),n=t.filter(e=>e.booted);return n.length>0?n:t}function V(e){let t=e.filter(e=>e.kind!==`device`);return t.length>0?t:e}function H(e){let t=Math.min(...e.map(e=>X(e)));return e.filter(e=>X(e)===t)}function U(e,t,n={}){return w(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||W(e,t))}function W(e,t){return!(t.udid&&!(e.id===t.udid&&p(e.platform))||t.serial&&!(e.id===t.serial&&G(e.platform))||t.deviceName&&J(e.name)!==J(t.deviceName))}function G(e){return e===`android`||e===`harmonyos`||e===`vega`}function K(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:e.platform===`harmonyos`?`No HarmonyOS device with serial ${e.serial}`:`No Android, HarmonyOS device, or Vega VVD with serial ${e.serial}`}function q(t,n){let r=n.simulatorSetPath;throw r&&k(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function J(e){return e.toLowerCase().replaceAll(`_`,` `).replaceAll(/\s+/g,` `).trim()}function Y(e,t){return X(e.device)-X(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function X(e){return e.kind===`simulator`?Z(e,0,1,2,3):e.kind===`device`&&p(e.platform)&&!m(e)?Z(e,10,11,12,13):14}function Z(e,t,n,r,i){return{mobile:$(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function Q(e){return e.length>0&&e.every(e=>p(e.platform))}function $(e){return/\bipad\b/i.test(e)}export{O as C,i as D,t as E,a as O,b as S,r as T,w as _,v as a,D as b,p as c,g as d,x as f,U as g,y as h,l as i,h as l,G as m,c as n,f as o,S as p,u as r,C as s,d as t,m as u,_ as v,n as w,A as x,T as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as SnapshotNode } from "./sdk-contracts.js";
|
|
2
2
|
//#region packages/selectors/src/internal/find.d.ts
|
|
3
3
|
declare const FIND_LOCATORS: readonly ['any', 'text', 'label', 'value', 'role', 'id'];
|
|
4
4
|
type FindLocator = (typeof FIND_LOCATORS)[number];
|
package/dist/src/sdk-finders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{kn as e}from"./sdk-batch.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
|
package/dist/src/sdk-io.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{C as t}from"./sdk-contracts.js";import n from"node:path";import{promises as r}from"node:fs";import i from"node:os";var a=e({createLocalArtifactAdapter:()=>o});function o(e={}){let a=e.cwd??process.cwd(),o=e.tempDir??i.tmpdir(),c=e.rootDir?s(e.rootDir,a):void 0;return{resolveInput:async e=>{if(e.kind===`uploadedArtifact`)throw new t(`UNSUPPORTED_OPERATION`,`Uploaded artifact inputs require a custom artifact adapter`);return{path:s(e.path,a,c)}},reserveOutput:async(e,t)=>{let i,l=t.visibility??`client-visible`,u=e?.kind===`path`?s(e.path,a,c):n.join(i=await r.mkdtemp(n.join(o,`agent-device-${t.field}-`)),`${t.field}${t.ext}`);return await r.mkdir(n.dirname(u),{recursive:!0}),{path:u,visibility:l,...i?{cleanup:async()=>{await r.rm(i,{recursive:!0,force:!0})}}:{},publish:async()=>e?.kind===`downloadableArtifact`?{kind:`localPath`,field:t.field,artifactType:t.artifactType,path:u,fileName:e.fileName??n.basename(e.clientPath??u)}:void 0}},createTempFile:async e=>{let t=await r.mkdtemp(n.join(o,`${e.prefix}-`));return{path:n.join(t,`file${e.ext}`),visibility:`internal`,cleanup:async()=>{await r.rm(t,{recursive:!0,force:!0})}}}}}function s(e,r,i){let a=n.isAbsolute(e)?e:n.resolve(r,e);if(i&&!c(a,i))throw new t(`INVALID_ARGS`,`Local path is outside the artifact adapter root`,{path:a,rootDir:i});return a}function c(e,t){let r=n.relative(t,e);return r===``||!r.startsWith(`..`)&&!n.isAbsolute(r)}export{a as n,o as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as DeviceTarget, _ as SessionIsolationMode, c as DaemonServerMode, f as LeaseBackend, l as DaemonTransportPreference, v as SessionRuntimeHints, w as PlatformSelector } from "./sdk-contracts.js";
|
|
2
2
|
//#region packages/contracts/src/companion-tunnel-scope.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The identity a companion tunnel is scoped to.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e}from"./sdk-contracts.js";import{r as t}from"./sdk-device.js";const n=[`portrait`,`landscape`],r=new Set([`1`,`true`,`yes`,`on`]),i=new Set([`0`,`false`,`no`,`off`]);function a(e){return`AGENT_DEVICE_${e.replaceAll(/([A-Z])/g,`_$1`).replaceAll(/[^A-Za-z0-9_]/g,`_`).toUpperCase()}`}function o(t,n,r,i){if(t.multiple)return(Array.isArray(n)?n:[n]).map(e=>o({...t,multiple:!1},e,r,i));if(t.type===`boolean`)return s(n,r,i);if(t.type===`booleanOrString`){if(typeof n==`boolean`)return n;if(typeof n==`string`&&c(n)!==void 0)return c(n);if(typeof n==`string`&&n.trim().length>0)return n;throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected boolean or non-empty string.`)}if(t.type===`string`){if(typeof n==`string`&&n.trim().length>0)return n;throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected non-empty string.`)}if(t.type===`enum`){if(t.setValue!==void 0)return l(t,n,r,i);if(typeof n!=`string`||!t.enumValues?.includes(n))throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected one of: ${t.enumValues?.join(`, `)}.`);return n}let a=typeof n==`number`?n:typeof n==`string`?Number(n):NaN;if(!Number.isFinite(a)||t.type===`int`&&!Number.isInteger(a))throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected ${t.type===`int`?`integer`:`number`}.`);if(typeof t.min==`number`&&a<t.min)throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Must be >= ${t.min}.`);if(typeof t.max==`number`&&a>t.max)throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Must be <= ${t.max}.`);return a}function s(t,n,r){if(typeof t==`boolean`)return t;if(typeof t==`string`){let e=c(t);if(e!==void 0)return e}throw new e(`INVALID_ARGS`,`Invalid value for "${r}" in ${n}. Expected boolean.`)}function c(e){let t=e.trim().toLowerCase();if(r.has(t))return!0;if(i.has(t))return!1}function l(t,n,r,i){let a=t.setValue;if(n===a)return a;if(typeof n==`string`){let e=n.trim();if(e===``||e===`true`||e===`1`)return a;if(e===`false`||e===`0`)return}if(n===!0)return a;if(n!==!1)throw new e(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected boolean-like value for enum flag.`)}const u=[{key:`stateDir`,type:`string`,path:!0},{key:`daemonBaseUrl`,type:`string`},{key:`daemonAuthToken`,type:`string`},{key:`daemonTransport`,type:`enum`,enumValues:[`auto`,`socket`,`http`]},{key:`daemonServerMode`,type:`enum`,enumValues:[`socket`,`http`,`dual`]},{key:`tenant`,type:`string`},{key:`sessionIsolation`,type:`enum`,enumValues:[`none`,`tenant`]},{key:`runId`,type:`string`},{key:`leaseId`,type:`string`},{key:`leaseBackend`,type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`,`harmonyos-instance`]},{key:`platform`,type:`enum`,enumValues:t},{key:`target`,type:`enum`,enumValues:[`mobile`,`tv`,`desktop`]},{key:`device`,type:`string`},{key:`udid`,type:`string`},{key:`serial`,type:`string`},{key:`iosSimulatorDeviceSet`,type:`string`,path:!0,env:!1},{key:`androidDeviceAllowlist`,type:`string`},{key:`session`,type:`string`},{key:`providerApp`,type:`string`},{key:`providerOsVersion`,type:`string`},{key:`providerProject`,type:`string`},{key:`providerBuild`,type:`string`},{key:`providerSessionName`,type:`string`},{key:`providerDeviceOrientation`,type:`enum`,enumValues:n},{key:`providerGeoLocation`,type:`string`},{key:`providerTimezone`,type:`string`},{key:`providerLanguage`,type:`string`},{key:`providerLocale`,type:`string`},{key:`providerNetworkProfile`,type:`string`},{key:`providerCustomNetwork`,type:`string`},{key:`providerNoResignApp`,type:`boolean`},{key:`awsProjectArn`,type:`string`},{key:`awsDeviceArn`,type:`string`},{key:`awsAppArn`,type:`string`},{key:`awsRegion`,type:`string`},{key:`awsInteractionMode`,type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`]},{key:`metroProjectRoot`,type:`string`,path:!0},{key:`metroKind`,type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`]},{key:`metroPublicBaseUrl`,type:`string`},{key:`metroProxyBaseUrl`,type:`string`},{key:`metroBearerToken`,type:`string`},{key:`metroPreparePort`,type:`int`,min:1,max:65535},{key:`metroListenHost`,type:`string`},{key:`metroStatusHost`,type:`string`},{key:`metroStartupTimeoutMs`,type:`int`,min:1},{key:`metroProbeTimeoutMs`,type:`int`,min:1},{key:`metroRuntimeFile`,type:`string`,path:!0},{key:`metroNoReuseExisting`,type:`boolean`},{key:`metroNoInstallDeps`,type:`boolean`},{key:`launchUrl`,type:`string`}],d=[{key:`leaseProvider`,type:`string`,env:!1},{key:`deviceKey`,type:`string`,env:!1},{key:`clientId`,type:`string`,env:!1}],f=[...u,...d],p=new Map(f.map(e=>[e.key,e]));function m(e){return p.get(e)}function h(e){return m(e)?.env===!1?[]:[a(e)]}export{a,n as c,m as i,f as n,c as o,h as r,o as s,u as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as Platform, D as RawSnapshotNode, E as Point, F as SnapshotState, M as SnapshotOptions$1, N as SnapshotProvenance, O as Rect, P as SnapshotQualityVerdict, T as PublicPlatform, h as ResponseCost, j as SnapshotNode, k as ScreenshotOverlayRef } from "./sdk-contracts.js";
|
|
2
2
|
//#region packages/contracts/src/session-surface.d.ts
|
|
3
3
|
declare const SESSION_SURFACES: readonly ['app', 'frontmost-app', 'desktop', 'menubar'];
|
|
4
4
|
type SessionSurface = (typeof SESSION_SURFACES)[number];
|
|
@@ -198,6 +198,34 @@ declare const TV_REMOTE_BUTTON_DEFINITIONS: {
|
|
|
198
198
|
declare const TV_REMOTE_BUTTONS: (keyof typeof TV_REMOTE_BUTTON_DEFINITIONS)[];
|
|
199
199
|
type TvRemoteButton = (typeof TV_REMOTE_BUTTONS)[number];
|
|
200
200
|
//#endregion
|
|
201
|
+
//#region packages/contracts/src/ios-system-surface.d.ts
|
|
202
|
+
/**
|
|
203
|
+
* iOS out-of-process system surfaces that agent-device observes and drives IN PLACE, never by
|
|
204
|
+
* activation.
|
|
205
|
+
*
|
|
206
|
+
* `com.apple.SafariViewService` hosts `ASWebAuthenticationSession` and `SFSafariViewController`
|
|
207
|
+
* out of the app's process. It is presented over a still-foreground app, and any
|
|
208
|
+
* `XCUIApplication.activate()` or `simctl launch` on it cancels the authentication session and
|
|
209
|
+
* blacks the view (issue #2438). So the runner reads and drives it without activation, and the
|
|
210
|
+
* `open` path refuses to launch it. The set is deliberately closed and tiny; add a host only with
|
|
211
|
+
* live evidence that it presents out of process and dies on activation.
|
|
212
|
+
*
|
|
213
|
+
* The canonical membership lives in `contracts/fixtures/ios-system-surface-hosts.json`; this module
|
|
214
|
+
* and the Swift `SystemSurfaceHostRegistry` both mirror it, each guarded by a parity test.
|
|
215
|
+
*/
|
|
216
|
+
/** Why a system surface is served in place; carried at snapshot-response level as provenance. */
|
|
217
|
+
type IosSystemSurfaceKind = 'web-auth';
|
|
218
|
+
/**
|
|
219
|
+
* Whole-snapshot provenance: the capture describes a system surface presented over the session app,
|
|
220
|
+
* not the app itself. Carried at response level (it applies to the entire snapshot) and folded into
|
|
221
|
+
* iOS snapshot lineage so `--verify`/`--settle` never compare an app baseline against a sheet
|
|
222
|
+
* capture. Mirrors the Android system-chrome/system-surface provenance model.
|
|
223
|
+
*/
|
|
224
|
+
type IosSystemSurfaceProvenance = Readonly<{
|
|
225
|
+
bundleId: string;
|
|
226
|
+
kind: IosSystemSurfaceKind;
|
|
227
|
+
}>;
|
|
228
|
+
//#endregion
|
|
201
229
|
//#region packages/contracts/src/interaction.d.ts
|
|
202
230
|
/** The decisive criterion separating a resolveSelectorChain winner from its strongest runner-up (ADR 0012). */
|
|
203
231
|
type DisambiguationTiebreak = 'visible' | 'deepest' | 'smallest-area' | 'structural-equivalence';
|
|
@@ -244,6 +272,22 @@ type ResolutionDisclosure = {
|
|
|
244
272
|
source: 'direct-ios';
|
|
245
273
|
kind: 'not-observed';
|
|
246
274
|
};
|
|
275
|
+
/**
|
|
276
|
+
* A post-action capture that describes a DIFFERENT surface than the pre-action baseline (#2438): an
|
|
277
|
+
* in-place iOS system surface (a web sign-in sheet, hosted out of the app's process) was presented
|
|
278
|
+
* over the app, or left it. `from`/`to` name the two surfaces — a host bundle id, or `app` for
|
|
279
|
+
* ordinary app content.
|
|
280
|
+
*
|
|
281
|
+
* Its presence IS the refusal of a same-surface claim: the two captures are not one presentation,
|
|
282
|
+
* so `--verify` reports `changedFromBefore` from this transition instead of from a digest
|
|
283
|
+
* comparison across it, and `--settle` attaches no settled diff (and therefore no refs) across it.
|
|
284
|
+
*/
|
|
285
|
+
type PostActionSurfaceChange = {
|
|
286
|
+
from: string;
|
|
287
|
+
to: string;
|
|
288
|
+
/** The one agent-facing sentence for this transition (`@agent-device/contracts/ios-system-surface`). */
|
|
289
|
+
disclosure: string;
|
|
290
|
+
};
|
|
247
291
|
/**
|
|
248
292
|
* Opt-in (`--verify`) cheap post-condition evidence for mutating interaction
|
|
249
293
|
* commands (#1047). `digest`/`nodeCount`/`interactiveNodeCount` describe a single
|
|
@@ -252,6 +296,10 @@ type ResolutionDisclosure = {
|
|
|
252
296
|
* held, so no extra device round trip is spent beyond the one verify capture.
|
|
253
297
|
* `changedFromBefore: false` is evidence, not failure — the command still
|
|
254
298
|
* succeeded.
|
|
299
|
+
*
|
|
300
|
+
* When `surfaceChange` is present the two captures describe different surfaces, so the digest
|
|
301
|
+
* comparison is not made at all: `changedFromBefore` then reports that transition, which replaced
|
|
302
|
+
* the whole observed surface.
|
|
255
303
|
*/
|
|
256
304
|
type InteractionEvidence = {
|
|
257
305
|
foregroundApp?: string;
|
|
@@ -259,6 +307,7 @@ type InteractionEvidence = {
|
|
|
259
307
|
interactiveNodeCount: number;
|
|
260
308
|
digest: string;
|
|
261
309
|
changedFromBefore: boolean;
|
|
310
|
+
surfaceChange?: PostActionSurfaceChange;
|
|
262
311
|
};
|
|
263
312
|
type SettleDiffLine = {
|
|
264
313
|
kind: 'added' | 'removed';
|
|
@@ -302,7 +351,17 @@ type SettleObservation = {
|
|
|
302
351
|
refs?: Array<{
|
|
303
352
|
ref: string;
|
|
304
353
|
}>;
|
|
305
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Present when the settled capture describes a different surface than the pre-action baseline
|
|
356
|
+
* (#2438). The settled tree then replaced the whole surface rather than changing within one, so
|
|
357
|
+
* `diff` is omitted: its lines (and their refs) would present a surface replacement as an
|
|
358
|
+
* in-surface change. `hint` says what to do instead.
|
|
359
|
+
*/
|
|
360
|
+
surfaceChange?: PostActionSurfaceChange;
|
|
361
|
+
/**
|
|
362
|
+
* Present only for `settled: true` observations that stored the settled tree, and never across a
|
|
363
|
+
* `surfaceChange` — a diff describes change WITHIN one surface.
|
|
364
|
+
*/
|
|
306
365
|
diff?: {
|
|
307
366
|
summary: {
|
|
308
367
|
additions: number;
|
|
@@ -464,13 +523,26 @@ type ScrollCommandResult = {
|
|
|
464
523
|
direction: ScrollDirection;
|
|
465
524
|
/** Set for `top`/`bottom` requests: the extreme being scrolled to. */
|
|
466
525
|
edge?: 'top' | 'bottom';
|
|
467
|
-
/**
|
|
526
|
+
/** Set for `--until` requests: the selector the passes stopped on. */
|
|
527
|
+
until?: string;
|
|
528
|
+
/** Edge and until scrolls only: how many scroll-and-check passes ran. */
|
|
468
529
|
passes?: number;
|
|
469
530
|
amount?: number;
|
|
470
531
|
pixels?: number;
|
|
471
532
|
durationMs?: number;
|
|
472
533
|
message?: string;
|
|
473
534
|
settle?: SettleObservation;
|
|
535
|
+
/**
|
|
536
|
+
* Set only when an on-screen keyboard made the owner clip the swipe into the band above it
|
|
537
|
+
* (#2500). Absent means the swipe was not clipped, which is not the same claim as `false`: a
|
|
538
|
+
* platform that never runs the clip has nothing to report. The platform leaf's `referenceHeight`
|
|
539
|
+
* names the shortened axis the reported `pixels` were planned against, and `keyboardMinY` names
|
|
540
|
+
* where the keyboard began. A surface the owner refused to swipe at all fails instead, under the
|
|
541
|
+
* `scroll_keyboard_occludes_surface` reason.
|
|
542
|
+
*/
|
|
543
|
+
keyboardAvoided?: true;
|
|
544
|
+
/** The keyboard's edge in the same unit as the gesture coordinates, when the swipe was clipped. */
|
|
545
|
+
keyboardMinY?: number;
|
|
474
546
|
};
|
|
475
547
|
//#endregion
|
|
476
548
|
//#region packages/contracts/src/settings.d.ts
|
|
@@ -528,7 +600,6 @@ type IosViewportEvidence = Readonly<{
|
|
|
528
600
|
reason: 'not-provided' | 'not-supported' | 'invalid';
|
|
529
601
|
}>;
|
|
530
602
|
type IosProviderPrunedField = 'nodes' | 'depth' | 'scope' | 'interactive-only';
|
|
531
|
-
type IosTruncationDimension = 'nodes' | 'depth' | 'payload';
|
|
532
603
|
type IosAcquisitionResidue = Readonly<{
|
|
533
604
|
kind: 'provider-pruned';
|
|
534
605
|
fields: readonly IosProviderPrunedField[];
|
|
@@ -537,8 +608,6 @@ type IosAcquisitionResidue = Readonly<{
|
|
|
537
608
|
reason: 'not-provided' | 'not-supported' | 'invalid';
|
|
538
609
|
}> | Readonly<{
|
|
539
610
|
kind: 'truncated';
|
|
540
|
-
dimension: IosTruncationDimension;
|
|
541
|
-
limit?: number;
|
|
542
611
|
}> | Readonly<{
|
|
543
612
|
kind: 'stale-generation';
|
|
544
613
|
expected?: IosSnapshotGeneration;
|
|
@@ -724,6 +793,11 @@ type KeyboardEnterResult = Readonly<{
|
|
|
724
793
|
type SnapshotResult = Omit<BackendSnapshotResult, 'backend' | 'nodes'> & {
|
|
725
794
|
nodes?: RawSnapshotNode[];
|
|
726
795
|
comparisonIdentity?: IosSnapshotComparisonIdentity;
|
|
796
|
+
/**
|
|
797
|
+
* Set when the capture describes an in-place iOS system surface (a web sign-in sheet) presented
|
|
798
|
+
* over the session app rather than the app itself (#2438).
|
|
799
|
+
*/
|
|
800
|
+
systemSurface?: IosSystemSurfaceProvenance;
|
|
727
801
|
} & SnapshotProvenance;
|
|
728
802
|
type SnapshotRuntimeAcquiredResult = Readonly<{
|
|
729
803
|
stage: 'acquired';
|
|
@@ -798,16 +872,6 @@ type Interactor = {
|
|
|
798
872
|
}): Promise<{
|
|
799
873
|
found: boolean;
|
|
800
874
|
}>;
|
|
801
|
-
/** Native one-sided observation for a simple selector; false defers to canonical capture. */
|
|
802
|
-
findSelector?(selector: Readonly<{
|
|
803
|
-
key: ElementSelectorKey;
|
|
804
|
-
value: string;
|
|
805
|
-
}>, options?: {
|
|
806
|
-
appBundleId?: string;
|
|
807
|
-
signal?: AbortSignal;
|
|
808
|
-
}): Promise<{
|
|
809
|
-
found: boolean;
|
|
810
|
-
}>;
|
|
811
875
|
gestureViewport?(): Promise<Rect>;
|
|
812
876
|
back(mode?: BackMode): Promise<void>;
|
|
813
877
|
home(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bn as e}from"./sdk-batch.js";function t(t,n,r){return e(typeof t==`string`?t:t.raw,n,r)}export{t};
|
package/dist/src/selection.js
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,b as t,c as n,h as r,u as i,y as a}from"./sdk-contracts.js";import{l as o,v as s}from"./sdk-device.js";import{Dn as c,Pt as l,ar as u,kn as d,or as f,sr as p}from"./sdk-batch.js";import{s as m}from"./session-store.js";import{i as ee,s as te}from"./session-target-evidence.js";import{f as ne}from"./parameterized-recorded-fill.js";import{b as re,t as ie}from"./runtime.js";import{a as h,f as g,p as _,s as v,t as y}from"./app-inventory-contract.js";import{r as ae}from"./diagnostics.js";import"./diagnostics2.js";import{i as oe}from"./rect-center.js";import{a as b}from"./android-system-chrome.js";import{r as se}from"./request-cancel.js";import"./request.js";import{r as ce}from"./provider-device-runtime.js";import{n as le}from"./dispatch-resolve.js";import{a as ue,i as x}from"./request-runtime-binding.js";import{_ as de,b as fe,f as S,i as C,n as pe,o as me,p as he,r as ge,s as _e,x as w}from"./session-snapshot.js";import{t as T}from"./snapshot-quality-verdict.js";import{t as E}from"./backend-snapshot-options.js";import{t as D}from"./snapshot-runtime-binding.js";function O(t){let r=e(t);return r?{ok:!0,ref:r.base,generation:r.generation}:{ok:!1,response:x(`INVALID_ARGS`,`Invalid ref "${t}" — malformed generation suffix.`,{hint:n})}}function k(e,t){if(t===`exists`)return{found:!0};if(t===`wait`)return{found:!0,waitedMs:e.waitedMs};if(t===`list`)return{action:`list`,matches:Array.isArray(e.matches)?e.matches.length:0};let n=typeof e.ref==`string`?e.ref:void 0;return t===`get_attrs`?{ref:n,action:`get attrs`}:{ref:n,action:`get text`,text:typeof e.text==`string`?e.text:``}}function A(e){return e.kind===`found`?{found:!0,...typeof e.waitedMs==`number`?{waitedMs:e.waitedMs}:{}}:e.kind===`list`?{matches:e.matches.map(e=>({ref:e.ref,node:b(e.node)}))}:{ref:e.ref,...e.kind===`text`?{text:e.text}:{},node:b(e.node)}}function j(e,t){let n=Array.isArray(e.selectorChain)?e.selectorChain:void 0,r=ye(e),i=r?.kind===`ref`?L(r.ref):void 0,a=r?.kind===`selector`?r.selector:void 0,o={...i?{ref:i}:{},...a?{selector:a}:{},...n?{selectorChain:n}:{}};if(t===`attrs`)return o;let s=typeof e.text==`string`?e.text:``;return{...o,text:s,refLabel:ve(s)}}function M(e){let{target:t}=e;return{...t.kind===`ref`?{ref:L(t.ref)}:{},...t.kind===`selector`?{selector:t.selector}:{},...typeof e.text==`string`?{text:e.text}:{},node:b(e.node)}}function N(e){let{node:t,preActionNodes:n,...r}=e;return r}function P(e){return{waitedMs:e.waitedMs,...typeof e.text==`string`?{text:e.text}:{},...typeof e.selector==`string`?{selector:e.selector}:{},...typeof e.captures==`number`?{captures:e.captures}:{},...typeof e.nodeCount==`number`?{nodeCount:e.nodeCount}:{},...typeof e.hint==`string`?{hint:e.hint}:{}}}function F(e){let{selectorChain:t,...n}=e;return n}function I(e,t,n,r,i,a){let o=e.get(t);if(!o)return;let s=ne(o)&&i?ee(i,{mode:a}):void 0;e.recordAction(o,{command:n.command,positionals:n.positionals??[],flags:n.flags??{},result:r,interactiveObservation:m(n),...s?{targetEvidence:s,targetEvidenceMode:a??`action`}:{}})}function ve(e){let t=e.trim();if(!(!t||t.length>80||/[\r\n]/.test(t)))return t}function ye(e){let t=e.target;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`ref`&&typeof n.ref==`string`)return{kind:`ref`,ref:n.ref};if(n.kind===`selector`&&typeof n.selector==`string`)return{kind:`selector`,selector:n.selector}}function L(e){return e.startsWith(`@`)?e.slice(1):e}async function R(e){let t=await D({...e,plan:l({hasActiveApp:e.session?.appBundleId!==void 0,intent:be(e.command)}),...e.session?{}:{readiness:{}}});return t.ok?{ok:!0,operations:{capture:t.capture,...t.readTextAtPoint?{readText:t.readTextAtPoint}:{},...t.findText?{findText:t.findText}:{},...t.findSelector?{findSelector:t.findSelector}:{}}}:t}function be(e){switch(e){case`is`:return`capture-only`;case`find`:case`get`:return`element-text`;case`wait`:return`wait-observation`}}const xe=[[`snapshotDepth`,`--depth`],[`snapshotScope`,`--scope`],[`snapshotRaw`,`--raw`]];function z(e,t){let n=xe.filter(([e])=>t?.[e]!==void 0).map(([,e])=>e);return n.length===0?null:x(`INVALID_ARGS`,`${e} @ref does not support ${n.join(`, `)}.`)}async function B(e,t){if(e.device.platform!==`android`||!e.appBundleId||e.lease?.leaseProvider||ce(e.device))return null;if(!t)throw new a(`INTERNAL_ERROR`,`Android observation was not supplied by root runtime composition`);let n=await t.readAppState(e.device),r=n.package?.trim();if(!r||r===e.appBundleId)return null;let i=await t.isPermissionPackage(r);return!we(r)&&!i?null:{expectedPackage:e.appBundleId,foregroundPackage:r,activity:n.activity,hint:Ce(i),...i?{permissionDialog:!0}:{}}}function Se(e){return e.permissionDialog?`Android permission dialog is blocking ${e.expectedPackage}`:`${e.foregroundPackage} is foreground instead of ${e.expectedPackage}`}function Ce(e){return e?`Use "alert get" to inspect it, then "alert accept" or "alert dismiss" to respond.`:`Use screenshot as visual truth, then take a fresh snapshot -i before retrying.`}function we(e){return e===`com.android.settings`||e===`com.android.systemui`||e.includes(`launcher`)}function V(e,t){let n=re(t);if(!n)return e;if(e.ok){let t=H(e.data?.warning,n);return{...e,data:{...e.data,warning:t}}}let r=e.error.details??{};return{...e,error:{...e.error,details:{...r,hint:H(r.hint,n)}}}}function H(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}async function Te(e){let{device:t,node:n,flags:r,appBundleId:i,traceOutPath:a,surface:s,contextFromFlags:c}=e,l=g(n),u=e.readTextAtPoint;if(!u)return l;let d=oe(n.rect);if(!d||o(t)&&l&&!_(n.type??``))return l;let f=c(r,i,a),p=await u({point:d,options:{appBundleId:i,surface:s},execution:he(f)});return p.status===`read`?p.text:(ae({level:`warn`,phase:`interaction_read_fallback`,data:{reason:Ee(p.reason),nodeRef:n.ref,surface:s,platform:t.platform}}),l)}function Ee(e){switch(e){case`no-text-at-point`:return`no_text_at_point`;default:return e}}function U(e){let{session:t,sessionStore:n,sessionName:r}=e,i=0,a,o,s=t=>(e.consumedSnapshot&&(e.consumedSnapshot.state=t.snapshot),t);return{capture:async c=>{let l=Date.now(),u=Pe(c,e.req.flags?.out),d=Ae({timestamp:l,lastSnapshotAt:i,lastSnapshotResult:a,lastSnapshotCacheKey:o,session:t,request:c,cacheKey:u});if(d)return s(d);let f=je({session:t,timestamp:l,request:c});if(f)return i=f.createdAt,a={snapshot:f},o=u,s(a);let p=await De({params:e,request:c});c.signal?.throwIfAborted();let m={snapshot:p};return Ie({session:t,sessionStore:n,sessionName:r,snapshot:p}),i=l,a=m,o=u,s(m)}}}async function De(e){let{params:t,request:n}=e,r=await W(t,n,n.snapshotScope);return n.recovery?.legacyIosSparse&&v(r)?await Oe({runtimeParams:t,request:n,policy:n.recovery.legacyIosSparse}):n.recovery?.sparseVerdictQueryScope?.shouldScope&&T(r.snapshotQuality)?await ke({runtimeParams:t,request:n,policy:n.recovery.sparseVerdictQueryScope,snapshot:r}):r}async function Oe(e){let{runtimeParams:t,request:n,policy:r}=e;try{return await W(t,n,void 0,!1)}catch(e){if(!r.shouldScope)throw e;return await W(t,n,r.query,!1)}}async function ke(e){let{runtimeParams:t,request:n,policy:r,snapshot:i}=e;try{return await W(t,n,r.query,!1)}catch{return i}}async function W(e,t,n,r=t.flags?.snapshotInteractiveOnly){let i={...t.flags,snapshotInteractiveOnly:r},a=e.capture;return(await _e({device:e.device,session:e.session,flags:i,outPath:t.outPath??e.req.flags?.out,logPath:e.logPath??``,snapshotScope:n,includeRects:t.includeRects,signal:t.signal,captureData:async()=>await a(S({flags:i,logPath:e.logPath??``,meta:e.req.meta,session:e.session,snapshotScope:n,includeRects:t.includeRects,signal:t.signal}))})).snapshot}function Ae(e){let{timestamp:t,lastSnapshotAt:n,lastSnapshotResult:r,lastSnapshotCacheKey:i,session:a,request:o,cacheKey:s}=e;if(o.cache?.forceFresh!==!0&&r&&i===s&&!(t-n>=750)&&!w(a)&&!G(a,o))return r}function je(e){let{session:t,timestamp:n,request:r}=e,i=t?.snapshot;if(i&&Me(t,r)&&Ne(i,n)&&i.presentationKey===K(r))return i}function Me(e,t){return!(t.cache?.forceFresh===!0||t.cache?.useSessionSnapshot!==!0||w(e)||G(e,t))}function Ne(e,t){return t-e.createdAt<750}function G(e,t){return t.cache?.bypassForPostGestureStabilization===!0&&de(e)}function K(e){return i(r(Fe(e)))}function Pe(e,t){return JSON.stringify({presentationKey:K(e),includeRects:e.includeRects===!0,outPath:e.outPath??t??null})}function Fe(e){return e.snapshotScope===void 0?e.flags:{...e.flags,snapshotScope:e.snapshotScope}}function Ie(e){let{session:t,sessionStore:n,sessionName:r,snapshot:i}=e;!t||T(i.snapshotQuality)||(C(t,i),n.set(r,t))}function q(e){return ie({backend:Re(e),...te(`selector commands`,{plural:!0}),sessions:me({sessionName:e.sessionName,getSession:()=>e.session,recordOptions:{includeSnapshot:!0},setRecord:t=>{!e.session||!t.snapshot||(C(e.session,t.snapshot),e.sessionStore.set(e.sessionName,e.session))}}),signal:e.signal??se(e.req.meta?.requestId)})}async function Le(e,t){e.consumedSnapshot??={};let n=e.sessionStore.get(e.sessionName);return!n&&t?{ok:!1,response:ue()}:{ok:!0,session:n,device:n?.device??await le(e.req.flags??{})}}async function J(e,t){let n=await Le(e,t.requireSession);if(!n.ok)return n;let r=await R({command:t.command,device:n.device,session:n.session,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return r.ok?{ok:!0,runtime:q({...e,session:n.session,device:n.device,bound:r.operations})}:{ok:!1,response:r.response}}function Re(e){let{req:t,session:n,device:r,logPath:i,sessionName:a,sessionStore:o}=e,c=e.contextFromFlags??((e,t,n)=>fe(i??``,e,t,n)),l=e.bound?.readText,u=e.bound?.findText,d=S({flags:t.flags,logPath:i??``,meta:t.meta,session:n,snapshotScope:void 0}).execution,f=e.bound,p=f===void 0?void 0:U({device:r,session:n,sessionStore:o,sessionName:a,req:t,consumedSnapshot:e.consumedSnapshot,logPath:i,capture:f.capture});return{platform:s(r),captureSnapshot:p&&(async(e,n)=>{let i={...t.flags,...E(n)},a=n?.includeRects===!0,o=n?.scope??t.flags?.snapshotScope,s=t.command===`wait`||t.command===`find`||ze(t)||a&&r.platform===`web`;return await p.capture({flags:i,signal:e.signal,snapshotScope:o,includeRects:a,cache:{forceFresh:s,useSessionSnapshot:!0,bypassForPostGestureStabilization:!0}})}),readText:async(e,i)=>({text:await Te({readTextAtPoint:l,device:r,node:i,flags:t.flags,appBundleId:n?.appBundleId,traceOutPath:n?.trace?.outPath,surface:n?.surface,contextFromFlags:c})}),...u?{findText:async(e,t)=>({found:(await u({text:t,options:{appBundleId:n?.appBundleId,surface:n?.surface},execution:d,...e.signal?{signal:e.signal}:{}})).found})}:{}}}function ze(e){if(e.command!==`is`)return!1;let t=p(e.positionals??[]);return t.ok&&t.predicate===`absent`}async function Be(e){let{req:t}=e;if(t.command!==`find`)return null;let n=t.positionals??[],r=c(n,t.flags);if(!r.ok)return x(r.code,r.message);let i=r.parsed,a=i.action;if(!d(a))return null;let o=await J(e,{requireSession:!1,command:`find`});return o.ok?V(await Q(async()=>{let n=await o.runtime.selectors.find({session:e.sessionName,requestId:t.meta?.requestId,locator:i.locator,query:i.query,action:a,timeoutMs:i.timeoutMs});I(e.sessionStore,e.sessionName,t,k(n,a));let r=A(n),s=typeof r.ref==`string`?[r.ref]:Array.isArray(r.matches)?r.matches.map(e=>e.ref).filter(e=>typeof e==`string`):[];if(s.length>0){let t=e.sessionStore.get(e.sessionName);if(t&&(pe(t,s),e.sessionStore.set(e.sessionName,t),t.snapshotGeneration!==void 0))return{...r,refsGeneration:t.snapshotGeneration}}return r}),Y(e)):o.response}function Y(e){return e.consumedSnapshot?.state??e.sessionStore.get(e.sessionName)?.snapshot}async function X(e){let{req:t}=e;if(t.command!==`get`)return null;let n=f(t.positionals?.[0]);if(!n.ok)return x(n.code,n.message);let r=n.format,i=He(t);if(!i.ok)return i.response;if(i.target.kind===`ref`){let e=z(`get`,t.flags);if(e)return e}let a=t.internal?.replayTargetGuard,o=await J(e,{requireSession:!0,command:`get`});if(!o.ok)return o.response;let s=o.runtime,c=i.target.kind===`ref`?ge({session:e.sessionStore.get(e.sessionName),ref:i.target.ref,mintedGeneration:i.refGeneration}):void 0;return V(await Q(async()=>{let n=await s.selectors.get({session:e.sessionName,requestId:t.meta?.requestId,property:r,target:i.target,expectedResolvedTarget:a});I(e.sessionStore,e.sessionName,t,j(n,r),{node:n.node,preActionNodes:n.preActionNodes});let o=M(n);return c?{...o,warning:c}:o}),Y(e))}async function Ve(e){let{req:t}=e;if(t.command!==`is`)return null;let n=p(t.positionals??[]);if(!n.ok)return x(n.code,n.message,n.hint?{hint:n.hint}:void 0);let{predicate:r,selectorExpression:i,expectedText:a}=n;if(r===`absent`){let e=h({depth:t.flags?.snapshotDepth,scope:t.flags?.snapshotScope});if(e){let t=y(e);return x(t.code,t.message,t.details)}}let o=t.internal?.replayTargetGuard,s=await J(e,{requireSession:!0,command:`is`});return s.ok?V(await $(e,await Q(async()=>{let n=await s.runtime.selectors.is({session:e.sessionName,requestId:t.meta?.requestId,predicate:r,selector:i,expectedText:a,expectedResolvedTarget:o}),c=Z(n),l=N(n);return I(e.sessionStore,e.sessionName,t,l,c),F(l)}),`is ${r}`),Y(e)):s.response}function Z(e){let t=e.node,n=e.preActionNodes;if(!(!t||typeof t!=`object`||!Array.isArray(n)))return{node:t,preActionNodes:n}}function He(e){let t=e.positionals?.[1]??``;if(t.startsWith(`@`)){let n=O(t);return n.ok?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:e.positionals.length>2?e.positionals.slice(2).join(` `).trim():``},refGeneration:n.generation}:{ok:!1,response:n.response}}let n=u(e.positionals?.slice(1)??[]);return n.ok?{ok:!0,target:{kind:`selector`,selector:`selector`in n?n.selector:``}}:{ok:!1,response:x(n.code,n.message)}}async function Q(e){try{return{ok:!0,data:await e()}}catch(e){let n=t(e);return x(n.code,n.message,n.details)}}async function $(e,t,n){if(t.ok)return t;let r=e.sessionStore.get(e.sessionName);if(!r)return t;let i;try{if(!e.androidObservation)return t;i=await B(r,e.androidObservation)}catch{return t}return i?x(t.error.code,`${n} failed because ${Se(i)}.`,{...t.error.details??{},...i,blockedBy:`android_foreground_surface`,originalMessage:t.error.message}):t}export{P as _,$ as a,q as c,B as d,z as f,F as g,N as h,Ve as i,U as l,I as m,Be as n,Z as o,R as p,X as r,Q as s,Y as t,V as u,O as v};
|
|
1
|
+
import{C as e,c as t,f as n,w as r,x as i,y as a}from"./sdk-contracts.js";import{l as o,v as s}from"./sdk-device.js";import{An as c,Ft as l,On as u,cr as d,or as f,sr as p}from"./sdk-batch.js";import{s as m}from"./session-store.js";import{i as ee,s as h}from"./session-target-evidence.js";import{f as g}from"./parameterized-recorded-fill.js";import{n as te}from"./runtime.js";import{a as ne,m as re,p as ie,s as ae,t as oe}from"./absence-observation-errors.js";import{r as se}from"./diagnostics.js";import"./diagnostics2.js";import{i as ce}from"./rect-center.js";import{a as _}from"./android-system-chrome.js";import{r as le}from"./request-cancel.js";import"./request.js";import{a as v,i as y,s as b}from"./request-runtime-binding.js";import{n as ue}from"./dispatch-resolve.js";import{C as de,b as fe,f as pe,i as x,m as me,n as he,o as ge,p as S,r as _e,s as ve,w as C}from"./session-snapshot.js";import{p as w}from"./quality-warnings.js";import{t as T}from"./ios-system-surface.js";import{t as E}from"./backend-snapshot-options.js";import{t as D}from"./snapshot-runtime-binding.js";function O(e){let n=i(e);return n?{ok:!0,ref:n.base,generation:n.generation}:{ok:!1,response:y(`INVALID_ARGS`,`Invalid ref "${e}" — malformed generation suffix.`,{hint:t})}}function k(e,t){if(t===`exists`)return{found:!0};if(t===`wait`)return{found:!0,waitedMs:e.waitedMs};if(t===`list`)return{action:`list`,matches:Array.isArray(e.matches)?e.matches.length:0};let n=typeof e.ref==`string`?e.ref:void 0;return t===`get_attrs`?{ref:n,action:`get attrs`}:{ref:n,action:`get text`,text:typeof e.text==`string`?e.text:``}}function A(e){return e.kind===`found`?{found:!0,...typeof e.waitedMs==`number`?{waitedMs:e.waitedMs}:{}}:e.kind===`list`?{matches:e.matches.map(e=>({ref:e.ref,node:_(e.node)}))}:{ref:e.ref,...e.kind===`text`?{text:e.text}:{},node:_(e.node)}}function j(e,t){let n=Array.isArray(e.selectorChain)?e.selectorChain:void 0,r=be(e),i=r?.kind===`ref`?L(r.ref):void 0,a=r?.kind===`selector`?r.selector:void 0,o={...i?{ref:i}:{},...a?{selector:a}:{},...n?{selectorChain:n}:{}};if(t===`attrs`)return o;let s=typeof e.text==`string`?e.text:``;return{...o,text:s,refLabel:ye(s)}}function M(e){let{target:t}=e;return{...t.kind===`ref`?{ref:L(t.ref)}:{},...t.kind===`selector`?{selector:t.selector}:{},...typeof e.text==`string`?{text:e.text}:{},node:_(e.node)}}function N(e){let{node:t,preActionNodes:n,...r}=e;return r}function P(e){return{waitedMs:e.waitedMs,...typeof e.text==`string`?{text:e.text}:{},...typeof e.selector==`string`?{selector:e.selector}:{},...typeof e.captures==`number`?{captures:e.captures}:{},...typeof e.nodeCount==`number`?{nodeCount:e.nodeCount}:{},...typeof e.hint==`string`?{hint:e.hint}:{}}}function F(e){let{selectorChain:t,...n}=e;return n}function I(e,t,n,r,i,a){let o=e.get(t);if(!o)return;let s=g(o)&&i?ee(i,{mode:a}):void 0;e.recordAction(o,{command:n.command,positionals:n.positionals??[],flags:n.flags??{},result:r,interactiveObservation:m(n),...s?{targetEvidence:s,targetEvidenceMode:a??`action`}:{}})}function ye(e){let t=e.trim();if(!(!t||t.length>80||/[\r\n]/.test(t)))return t}function be(e){let t=e.target;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`ref`&&typeof n.ref==`string`)return{kind:`ref`,ref:n.ref};if(n.kind===`selector`&&typeof n.selector==`string`)return{kind:`selector`,selector:n.selector}}function L(e){return e.startsWith(`@`)?e.slice(1):e}async function R(e){let t=await D({...e,plan:l({hasActiveApp:e.session?.appBundleId!==void 0,intent:xe(e.command)}),...e.session?{}:{readiness:{}}});return t.ok?{ok:!0,operations:{capture:t.capture,...t.readTextAtPoint?{readText:t.readTextAtPoint}:{},...t.findText?{findText:t.findText}:{}}}:t}function xe(e){switch(e){case`is`:return`capture-only`;case`find`:case`get`:return`element-text`;case`wait`:return`wait-observation`}}const Se=[[`snapshotDepth`,`--depth`],[`snapshotScope`,`--scope`],[`snapshotRaw`,`--raw`]];function z(e,t){let n=Se.filter(([e])=>t?.[e]!==void 0).map(([,e])=>e);return n.length===0?null:y(`INVALID_ARGS`,`${e} @ref does not support ${n.join(`, `)}.`)}async function B(t,n){if(t.device.platform!==`android`||!t.appBundleId||t.lease?.leaseProvider||b(t.device))return null;if(!n)throw new e(`INTERNAL_ERROR`,`Android observation was not supplied by root runtime composition`);let r=await n.readAppState(t.device),i=r.package?.trim();if(!i||i===t.appBundleId)return null;let a=await n.isPermissionPackage(i);return!we(i)&&!a?null:{expectedPackage:t.appBundleId,foregroundPackage:i,activity:r.activity,hint:Ce(a),...a?{permissionDialog:!0}:{}}}function V(e){return e.permissionDialog?`Android permission dialog is blocking ${e.expectedPackage}`:`${e.foregroundPackage} is foreground instead of ${e.expectedPackage}`}function Ce(e){return e?`Use "alert get" to inspect it, then "alert accept" or "alert dismiss" to respond.`:`Use screenshot as visual truth, then take a fresh snapshot -i before retrying.`}function we(e){return e===`com.android.settings`||e===`com.android.systemui`||e.includes(`launcher`)}function H(e,t){let n=t?.iosSystemSurfaceBundleId?T:te(t);if(!n)return e;if(e.ok){let t=U(e.data?.warning,n);return{...e,data:{...e.data,warning:t}}}let r=e.error.details??{};return{...e,error:{...e.error,details:{...r,hint:U(r.hint,n)}}}}function U(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}async function Te(e){let{device:t,node:n,flags:r,appBundleId:i,traceOutPath:a,surface:s,contextFromFlags:c}=e,l=ie(n),u=e.readTextAtPoint;if(!u)return l;let d=ce(n.rect);if(!d||o(t)&&l&&!re(n.type??``))return l;let f=c(r,i,a),p=await u({point:d,options:{appBundleId:i,surface:s},execution:me(f)});return p.status===`read`?p.text:(se({level:`warn`,phase:`interaction_read_fallback`,data:{reason:Ee(p.reason),nodeRef:n.ref,surface:s,platform:t.platform}}),l)}function Ee(e){switch(e){case`no-text-at-point`:return`no_text_at_point`;default:return e}}function W(e){let{session:t,sessionStore:n,sessionName:r}=e,i=0,a,o,s=t=>(e.consumedSnapshot&&(e.consumedSnapshot.state=t.snapshot),t);return{capture:async c=>{let l=Date.now(),u=Pe(c,e.req.flags?.out),d=Ae({timestamp:l,lastSnapshotAt:i,lastSnapshotResult:a,lastSnapshotCacheKey:o,session:t,request:c,cacheKey:u});if(d)return s(d);let f=je({session:t,timestamp:l,request:c});if(f)return i=f.createdAt,a={snapshot:f},o=u,s(a);let p=await De({params:e,request:c});c.signal?.throwIfAborted();let m={snapshot:p};return Ie({session:t,sessionStore:n,sessionName:r,snapshot:p}),i=l,a=m,o=u,s(m)}}}async function De(e){let{params:t,request:n}=e,r=await G(t,n,n.snapshotScope);return n.recovery?.legacyIosSparse&&ae(r)?await Oe({runtimeParams:t,request:n,policy:n.recovery.legacyIosSparse}):n.recovery?.sparseVerdictQueryScope?.shouldScope&&w(r.snapshotQuality)?await ke({runtimeParams:t,request:n,policy:n.recovery.sparseVerdictQueryScope,snapshot:r}):r}async function Oe(e){let{runtimeParams:t,request:n,policy:r}=e;try{return await G(t,n,void 0,!1)}catch(e){if(!r.shouldScope)throw e;return await G(t,n,r.query,!1)}}async function ke(e){let{runtimeParams:t,request:n,policy:r,snapshot:i}=e;try{return await G(t,n,r.query,!1)}catch{return i}}async function G(e,t,n,r=t.flags?.snapshotInteractiveOnly){let i={...t.flags,snapshotInteractiveOnly:r},a=e.capture;return(await ve({device:e.device,session:e.session,flags:i,outPath:t.outPath??e.req.flags?.out,logPath:e.logPath??``,snapshotScope:n,includeRects:t.includeRects,signal:t.signal,captureData:async()=>await a(S({flags:i,logPath:e.logPath??``,meta:e.req.meta,session:e.session,snapshotScope:n,includeRects:t.includeRects,signal:t.signal}))})).snapshot}function Ae(e){let{timestamp:t,lastSnapshotAt:n,lastSnapshotResult:r,lastSnapshotCacheKey:i,session:a,request:o,cacheKey:s}=e;if(o.cache?.forceFresh!==!0&&r&&i===s&&!(t-n>=750)&&!C(a)&&!K(a,o))return r}function je(e){let{session:t,timestamp:n,request:r}=e,i=t?.snapshot;if(i&&Me(t,r)&&Ne(i,n)&&i.presentationKey===q(r))return i}function Me(e,t){return!(t.cache?.forceFresh===!0||t.cache?.useSessionSnapshot!==!0||C(e)||K(e,t))}function Ne(e,t){return t-e.createdAt<750}function K(e,t){return t.cache?.bypassForPostGestureStabilization===!0&&fe(e)}function q(e){return n(a(Fe(e)))}function Pe(e,t){return JSON.stringify({presentationKey:q(e),includeRects:e.includeRects===!0,outPath:e.outPath??t??null})}function Fe(e){return e.snapshotScope===void 0?e.flags:{...e.flags,snapshotScope:e.snapshotScope}}function Ie(e){let{session:t,sessionStore:n,sessionName:r,snapshot:i}=e;!t||w(i.snapshotQuality)||(x(t,i),n.set(r,t))}function J(e){return pe({backend:Re(e),...h(`selector commands`,{plural:!0}),sessions:ge({sessionName:e.sessionName,getSession:()=>e.session,recordOptions:{includeSnapshot:!0},setRecord:t=>{!e.session||!t.snapshot||(x(e.session,t.snapshot),e.sessionStore.set(e.sessionName,e.session))}}),signal:e.signal??le(e.req.meta?.requestId)})}async function Le(e,t){e.consumedSnapshot??={};let n=e.sessionStore.get(e.sessionName);return!n&&t?{ok:!1,response:v()}:{ok:!0,session:n,device:n?.device??await ue(e.req.flags??{})}}async function Y(e,t){let n=await Le(e,t.requireSession);if(!n.ok)return n;let r=await R({command:t.command,device:n.device,session:n.session,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return r.ok?{ok:!0,runtime:J({...e,session:n.session,device:n.device,bound:r.operations})}:{ok:!1,response:r.response}}function Re(e){let{req:t,session:n,device:r,logPath:i,sessionName:a,sessionStore:o}=e,c=e.contextFromFlags??((e,t,n)=>de(i??``,e,t,n)),l=e.bound?.readText,u=e.bound?.findText,d=S({flags:t.flags,logPath:i??``,meta:t.meta,session:n,snapshotScope:void 0}).execution,f=e.bound,p=f===void 0?void 0:W({device:r,session:n,sessionStore:o,sessionName:a,req:t,consumedSnapshot:e.consumedSnapshot,logPath:i,capture:f.capture});return{platform:s(r),captureSnapshot:p&&(async(e,n)=>{let i={...t.flags,...E(n)},a=n?.includeRects===!0,o=n?.scope??t.flags?.snapshotScope,s=t.command===`wait`||t.command===`find`||ze(t)||a&&r.platform===`web`;return await p.capture({flags:i,signal:e.signal,snapshotScope:o,includeRects:a,cache:{forceFresh:s,useSessionSnapshot:!0,bypassForPostGestureStabilization:!0}})}),readText:async(e,i)=>({text:await Te({readTextAtPoint:l,device:r,node:i,flags:t.flags,appBundleId:n?.appBundleId,traceOutPath:n?.trace?.outPath,surface:n?.surface,contextFromFlags:c})}),...u?{findText:async(e,t)=>({found:(await u({text:t,options:{appBundleId:n?.appBundleId,surface:n?.surface},execution:d,...e.signal?{signal:e.signal}:{}})).found})}:{}}}function ze(e){if(e.command!==`is`)return!1;let t=d(e.positionals??[]);return t.ok&&t.predicate===`absent`}async function Be(e){let{req:t}=e;if(t.command!==`find`)return null;let n=t.positionals??[],r=u(n,t.flags);if(!r.ok)return y(r.code,r.message);let i=r.parsed,a=i.action;if(!c(a))return null;let o=await Y(e,{requireSession:!1,command:`find`});return o.ok?H(await Q(async()=>{let n=await o.runtime.selectors.find({session:e.sessionName,requestId:t.meta?.requestId,locator:i.locator,query:i.query,action:a,timeoutMs:i.timeoutMs});I(e.sessionStore,e.sessionName,t,k(n,a));let r=A(n),s=typeof r.ref==`string`?[r.ref]:Array.isArray(r.matches)?r.matches.map(e=>e.ref).filter(e=>typeof e==`string`):[];if(s.length>0){let t=e.sessionStore.get(e.sessionName);if(t&&(he(t,s),e.sessionStore.set(e.sessionName,t),t.snapshotGeneration!==void 0))return{...r,refsGeneration:t.snapshotGeneration}}return r}),X(e)):o.response}function X(e){return e.consumedSnapshot?.state??e.sessionStore.get(e.sessionName)?.snapshot}async function Ve(e){let{req:t}=e;if(t.command!==`get`)return null;let n=p(t.positionals?.[0]);if(!n.ok)return y(n.code,n.message);let r=n.format,i=Ue(t);if(!i.ok)return i.response;if(i.target.kind===`ref`){let e=z(`get`,t.flags);if(e)return e}let a=t.internal?.replayTargetGuard,o=await Y(e,{requireSession:!0,command:`get`});if(!o.ok)return o.response;let s=o.runtime,c=i.target.kind===`ref`?_e({session:e.sessionStore.get(e.sessionName),ref:i.target.ref,mintedGeneration:i.refGeneration}):void 0;return H(await Q(async()=>{let n=await s.selectors.get({session:e.sessionName,requestId:t.meta?.requestId,property:r,target:i.target,expectedResolvedTarget:a});I(e.sessionStore,e.sessionName,t,j(n,r),{node:n.node,preActionNodes:n.preActionNodes});let o=M(n);return c?{...o,warning:c}:o}),X(e))}async function He(e){let{req:t}=e;if(t.command!==`is`)return null;let n=d(t.positionals??[]);if(!n.ok)return y(n.code,n.message,n.hint?{hint:n.hint}:void 0);let{predicate:r,selectorExpression:i,expectedText:a}=n;if(r===`absent`){let e=ne({depth:t.flags?.snapshotDepth,scope:t.flags?.snapshotScope});if(e){let t=oe(e);return y(t.code,t.message,t.details)}}let o=t.internal?.replayTargetGuard,s=await Y(e,{requireSession:!0,command:`is`});return s.ok?H(await $(e,await Q(async()=>{let n=await s.runtime.selectors.is({session:e.sessionName,requestId:t.meta?.requestId,predicate:r,selector:i,expectedText:a,expectedResolvedTarget:o}),c=Z(n),l=N(n);return I(e.sessionStore,e.sessionName,t,l,c),F(l)}),`is ${r}`),X(e)):s.response}function Z(e){let t=e.node,n=e.preActionNodes;if(!(!t||typeof t!=`object`||!Array.isArray(n)))return{node:t,preActionNodes:n}}function Ue(e){let t=e.positionals?.[1]??``;if(t.startsWith(`@`)){let n=O(t);return n.ok?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:e.positionals.length>2?e.positionals.slice(2).join(` `).trim():``},refGeneration:n.generation}:{ok:!1,response:n.response}}let n=f(e.positionals?.slice(1)??[]);return n.ok?{ok:!0,target:{kind:`selector`,selector:`selector`in n?n.selector:``}}:{ok:!1,response:y(n.code,n.message)}}async function Q(e){try{return{ok:!0,data:await e()}}catch(e){let t=r(e);return y(t.code,t.message,t.details)}}async function $(e,t,n){if(t.ok)return t;let r=e.sessionStore.get(e.sessionName);if(!r)return t;let i;try{if(!e.androidObservation)return t;i=await B(r,e.androidObservation)}catch{return t}return i?y(t.error.code,`${n} failed because ${V(i)}.`,{...t.error.details??{},...i,blockedBy:`android_foreground_surface`,originalMessage:t.error.message}):t}export{O as _,$ as a,J as c,B as d,z as f,P as g,N as h,He as i,W as l,I as m,Be as n,Z as o,R as p,Ve as r,Q as s,X as t,H as u};
|
package/dist/src/selectors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Sn as e,_r as t,br as n,gr as r,xr as i,yn as a,yr as o}from"./sdk-batch.js";import{t as s}from"./sdk-selectors.js";export{a as findSelectorChainMatch,s as formatSelectorFailure,n as isNodeEditable,i as isNodeVisible,r as isSelectorToken,t as parseSelectorChain,e as resolveSelectorChain,o as tryParseSelectorChain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dr as e,Hr as t,Rr as n,Vr as r,jr as i,zr as a}from"./sdk-batch.js";import{n as o,t as s}from"./scroll-indicator.js";import{a as c,i as l,o as ee,r as u}from"./react-native-overlay.js";import{t as d}from"./rect-center.js";import{a as f,c as te,d as p,f as m,g as ne,h,i as g,l as re,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as ie}from"./tree.js";function ae(e,t){let n=g(t.sourceNodesByIndex.values());for(let r of e)oe(r,t.sourceNodesByIndex,n)&&b(t.replacements,r,{type:`Cell`})}function oe(e,t,n){return!(i(e.type??``)!==`other`||e.enabled===!1||!e.rect||!le(e.label)||!f(e,t,ce)||!se(e)||re(e.rect,n))}function se(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ce(e){let t=i(e.type??``);return t===`scrollview`||t===`scrollarea`}function le(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function ue(e,t){let n=new Set;for(let r of e)de(t.replacements.get(r.index)??r)&&fe(r,t.sourceNodesByIndex,t,n);pe(e,t,n)}function de(e){let t=e.label?.trim();return!!(t&&o(t))}function fe(e,t,n,r){let i=!p(e.type)||n.isSuppressed(e),a=s(e.label?.trim()??``,e.value),o=a?y(e,t,{includeSelf:!0}):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&j(n,o,e,a)&&r.add(o.index)}function pe(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=k(o.rect,a),c=me(o,a,s),l=w(e,c,o);T(t,i,o,a,s,c,l),r.set(i.index,E(i,o,a,s,l,n))}}function me(e,t,r){return!!(t&&n(e.rect)&&!n(r))}function w(e,t,n){return!!(e?.projectedOut||t&&O(n))}function T(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!A(n.rect,i)&&b(e.replacements,t,{rect:i})}function E(e,t,n,r,i,a){return{projectedOut:i,...D(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function D(e,t,r,i,a){return!!(n(i)&&(a.has(e.index)||r!==void 0&&p(t.type)))}function O(e){return e.type?.trim().toLowerCase()===`cell`||p(e.type)}function k(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function A(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function j(e,t,n,r){let i=N((e.replacements.get(t.index)??t).rect,n.rect);return ne(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:M(e.hiddenContentAbove,r.above),hiddenContentBelow:M(e.hiddenContentBelow,r.below)})),!!i}function M(e,t){return e===!0||t?!0:void 0}function N(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function P(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],a=r?.label?.trim();r&&a&&i(r.type??``)===`other`&&t(r,a,n)}}function F(e,t){P(e,(n,r,i)=>{if(!c(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&ee(e.label?.trim()??``));if(!a?.rect)return;let o=L(n.rect,a.rect);if(!o)return;let s=I(e,i,o);b(t,n,{rect:s}),S(e,i,e=>{c(e.label?.trim()??``)&&b(t,e,{rect:s})})})}function I(e,n,i){let a=i;return S(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!c(n)||t(i,e.rect)&&r(e.rect)<r(a)&&(a=e.rect)}),a}function L(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&d(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&d(t,a))return{...e,x:r,width:n-r}}function R(e,t){P(e,(n,r,i)=>{u(n)&&l(n,z(e,i))&&t.suppressNode(n,z(e,i))})}function z(e,t){let n=[];return S(e,t,e=>{n.push(e)}),n}function he(e,t){let n=g(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!ge(i,r)||(t.suppressNode(i,[]),_e(i,t,r),S(e,n,e=>{t.suppressNode(e,[])}))}}function ge(e,t){return!e.rect||i(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function _e(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function ve(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(!r)continue;if(ye(r)){B(e,n,r,t);continue}if(!be(r))continue;let a=x(e,n,e=>i(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(r,[a]),xe(r,a,t),B(e,n,a,t))}}function ye(e){return i(e.type??``)===`searchfield`&&e.label===`Search`}function be(e){let t=i(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function B(e,t,n,r){S(e,t,e=>{e.index!==n.index&&Se(e)&&r.suppressNode(e,[n])})}function xe(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Se(e){let t=i(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Ce(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||we(e,n,r,i,t)}}function we(e,t,n,r,a){let o=i(n.type??``);if(o===`statictext`||o===`link`){V(e,t,r,n,a);return}if(o!==`other`)return;let s=Te(e,t,r);if(s){a.suppressNode(n,[s]);return}V(e,t,r,n,a)}function Te(e,t,n){return x(e,t,e=>{let t=i(e.type??``);return(t===`link`||t===`searchfield`||p(e.type))&&e.label?.trim()===n})}function V(e,t,n,r,i){S(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ie(e,n)&&i.suppressNode(e,[r])})}function Ee(e,t){P(e,(n,r,i)=>{let a=x(e,i,e=>m(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||De(n,e)));a&&t.suppressNode(n,[a])})}function De(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let n=i(t.type??``);return Oe(e,n)||n===`textfield`||ke(e,n,t)}function Oe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function ke(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ae(e,t){let n=C(e);for(let r of e)i(r.type??``)===`other`&&(r.hittable===!0||r.label?.trim()||r.value?.trim()||r.identifier?.trim()&&t.suppressNode(r,je(r,n)))}function je(e,t){let n=[],r=new Set([e.index]),i=[...t.get(e.index)??[]];for(;i.length>0;){let e=i.pop();if(!e||r.has(e.index))continue;r.add(e.index),n.push(e);let a=t.get(e.index);a&&i.push(...a)}return n}function Me(e,t){he(e,t),Ae(e,t),ue(e,t),ve(e,t),Ee(e,t),F(e,t.replacements),R(e,t),Ce(e,t)}function Ne(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Pe(e,n,r,t):void 0;!r?.rect||!i||Le(e,n,r,i,t)}}function Pe(e,t,n,r){let a=n.label?.trim();if(i(n.type??``)!==`cell`||a&&!Fe(a,n.identifier)&&!o(a))return a;let s=v(e,t).find(Ie),c=s?.label?.trim();return!s||!c?a:(b(r.replacements,n,{label:c}),r.suppressNode(s,[n]),c)}function Fe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ie(e){if(!e.label?.trim())return!1;let t=i(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function Le(e,t,n,r,a){let o=i(n.type??``);if(o===`button`){H(v(e,t),r,a,n);return}if(o!==`cell`)return;let s=v(e,t);Re(s,n,r,a)||ze(s,n,r,a)}function Re(e,t,n,r){let i=e.find(e=>Ve(e,t,n));if(!i)return!1;let a=e.find(e=>U(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&b(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),Be(e,t,n,i,r),!0}function ze(e,t,n,r){let i=e.find(e=>U(e,t,n));if(!i){e.some(te)&&H(e,n,r,t);return}!t.identifier&&i.identifier&&b(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),H(e.filter(e=>e.index!==i.index),n,r,t)}function Be(e,t,n,r,i){for(let a of e)a.index!==r.index&&(U(a,t,n)||W(a,t)||He(a,r)||h(a,n))&&i.suppressNode(a,[r])}function H(e,t,n,r){for(let i of e)(h(i,t)||r&&W(i,r))&&n.suppressNode(i,r?[r]:[])}function U(e,t,n){if(i(e.type??``)!==`button`)return!1;let r=t.identifier?.trim(),a=e.identifier?.trim();return r&&a&&r===a?!0:e.label?.trim()===n&&d(e.rect,t.rect)}function W(e,t){return i(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function Ve(e,t,n){if(i(e.type??``)!==`switch`)return!1;let r=t.identifier?.trim(),a=e.identifier?.trim();return r&&a&&r===a?!0:e.label?.trim()===n}function He(e,t){if(i(e.type??``)!==`switch`||e.index===t.index)return!1;let n=e.label?.trim();return n===t.value?.trim()||n===`0`||n===`1`}const G=1.15;function Ue(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[i,o]of e.entries()){let s=We(e,r,t,o,n);if(!s)continue;q(e,i,n);let c=J(s.shelfRect,2);for(let t of s.intermediateSiblings){if($e(t)||!t.rect||!a(t.rect,c))continue;let i=r.get(t.index);i!==void 0&&q(e,i,n)}}}function We(e,t,n,r,i){let a=Ge(r,n,i.sourceNodesByIndex);if(!a)return;let o=Je(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function Ge(e,t,n){let r=Ye(e,K(t,e.index));if(!r)return;let i=qe(e,n);if(!i||!i.rect)return;let a=K(t,i.index),o=a.findIndex(t=>t.index===e.index);if(Ke(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function K(e,t){return e.get(t)??[]}function Ke(e,t,n,r){if(t<1)return!1;let i=Xe(e,t,n);return i?!r.childActionsPresented||!Ze(i,r.actionButtons):!1}function qe(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function Je(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&Qe(e,t.get(n.index),n,i))}function Ye(e,n){if(!p(e.type)||!e.rect)return;let r=e.rect,a=n.filter(e=>i(e.type??``)===`button`&&e.rect);if(a.length===0&&e.hiddenContentBelow===!0)return{rect:r,childActionsPresented:!1,actionButtons:a};if(a.length<3)return;let o=a.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:r,childActionsPresented:a.some(e=>t(r,e.rect)),actionButtons:a}}function Xe(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!m(t))&&t.rect.x+t.rect.width/2<n.rect.x&&et(t.rect,J(n.rect,2)))return t}}function Ze(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*G||e.rect.height>r*G}function Qe(e,t,n,r){return t!==void 0&&i(n.type??``)===`other`&&d(n.rect,r.rect)&&!!x(e,t,m)}function q(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of v(e,t))n.suppressNode(r,[])}}function $e(e){let t=i(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function J(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function et(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function tt(e,t){let n=C(e);Ue(e,n,t),nt(e,n,t)}function nt(e,t,n){for(let r of e){if(i(r.type??``)!==`navigationbar`||!r.rect)continue;let e=t.get(r.index)??[],a=e.flatMap(t=>rt(t,e,r.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];b(n.replacements,o,{type:`Button`,label:l,enabled:!0,rect:st([c.rect,o.rect,s.rect])}),n.semanticRepresentativeIndexes.add(o.index),n.suppressNode(s,[o]),n.suppressNode(c,[o])}}function rt(t,n,r){let i=e(t);if(!it(t,i))return[];let a=X(n,e=>at(e,i)),o=X(n,Y);return a?.rect&&o?.rect&&ot(o.rect,t.rect,a.rect,r)?[{field:t,title:a,image:o,label:i}]:[]}function it(e,t){return i(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function at(e,t){return i(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Y(e){return i(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function X(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function ot(e,n,r,i){let a=n.x-(e.x+e.width),o=r.x-(n.x+n.width);return t(i,e)&&t(i,n)&&t(i,r)&&a>=0&&a<=12&&o>=0&&o<=12&&Z(e,n)&&Z(n,r)}function Z(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function st(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function ct(e,t){let n=C(e);for(let r of e){if(i(r.type??``)===`element(58)`){b(t.replacements,r,{type:`WebView`});continue}let e=lt(r,t.sourceNodesByIndex,n);if(e?.kind===`suppress`){t.suppressNode(r,[]);continue}e&&(b(t.replacements,r,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(r.index))}}function lt(e,t,n){if(i(e.type??``)!==`other`)return null;let r=f(e,t,ft),a=e.label?.trim();return!r||!a?null:dt(e,r,a)?{kind:`suppress`}:ut(e,a,n)?{kind:`semantic`,type:Q(e.value)?`Heading`:`StaticText`}:null}function ut(e,t,n){let r=n.get(e.index);if(r?.length!==1)return!1;let a=r[0];return i(a.type??``)===`statictext`&&a.label?.trim()===t&&!n.has(a.index)}function dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!Q(e.value)}function ft(e){let t=i(e.type??``);return t===`webview`||t===`element(58)`}function Q(e){return/^[1-6]$/.test(e?.trim()??``)}const pt=[ct,tt,ae,Ne,Me];function mt(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of pt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=_(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,$(e.index,l,n)]))}}function $(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of $(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}export{mt as t};
|
|
1
|
+
import{Br as e,Hr as t,Mr as n,Or as r,Ur as i,zr as a}from"./sdk-batch.js";import{n as o,t as s}from"./scroll-indicator.js";import{a as c,i as l,o as ee,r as u}from"./react-native-overlay.js";import{t as d}from"./rect-center.js";import{a as f,c as te,d as p,f as m,g as ne,h,i as g,l as re,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as ie}from"./tree.js";function ae(e,t){let n=g(t.sourceNodesByIndex.values());for(let r of e)oe(r,t.sourceNodesByIndex,n)&&b(t.replacements,r,{type:`Cell`})}function oe(e,t,r){return!(n(e.type??``)!==`other`||e.enabled===!1||!e.rect||!le(e.label)||!f(e,t,ce)||!se(e)||re(e.rect,r))}function se(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ce(e){let t=n(e.type??``);return t===`scrollview`||t===`scrollarea`}function le(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function ue(e,t){let n=new Set;for(let r of e)de(t.replacements.get(r.index)??r)&&fe(r,t.sourceNodesByIndex,t,n);pe(e,t,n)}function de(e){let t=e.label?.trim();return!!(t&&o(t))}function fe(e,t,n,r){let i=!p(e.type)||n.isSuppressed(e),a=s(e.label?.trim()??``,e.value),o=a?y(e,t,{includeSelf:!0}):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&j(n,o,e,a)&&r.add(o.index)}function pe(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=k(o.rect,a),c=me(o,a,s),l=w(e,c,o);T(t,i,o,a,s,c,l),r.set(i.index,E(i,o,a,s,l,n))}}function me(e,t,n){return!!(t&&a(e.rect)&&!a(n))}function w(e,t,n){return!!(e?.projectedOut||t&&O(n))}function T(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!A(n.rect,i)&&b(e.replacements,t,{rect:i})}function E(e,t,n,r,i,a){return{projectedOut:i,...D(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function D(e,t,n,r,i){return!!(a(r)&&(i.has(e.index)||n!==void 0&&p(t.type)))}function O(e){return e.type?.trim().toLowerCase()===`cell`||p(e.type)}function k(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function A(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function j(e,t,n,r){let i=N((e.replacements.get(t.index)??t).rect,n.rect);return ne(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:M(e.hiddenContentAbove,r.above),hiddenContentBelow:M(e.hiddenContentBelow,r.below)})),!!i}function M(e,t){return e===!0||t?!0:void 0}function N(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function P(e,t){for(let r=0;r<e.length;r+=1){let i=e[r],a=i?.label?.trim();i&&a&&n(i.type??``)===`other`&&t(i,a,r)}}function F(e,t){P(e,(n,r,i)=>{if(!c(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&ee(e.label?.trim()??``));if(!a?.rect)return;let o=L(n.rect,a.rect);if(!o)return;let s=I(e,i,o);b(t,n,{rect:s}),S(e,i,e=>{c(e.label?.trim()??``)&&b(t,e,{rect:s})})})}function I(e,n,r){let a=r;return S(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!c(n)||i(r,e.rect)&&t(e.rect)<t(a)&&(a=e.rect)}),a}function L(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&d(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&d(t,a))return{...e,x:r,width:n-r}}function R(e,t){P(e,(n,r,i)=>{u(n)&&l(n,z(e,i))&&t.suppressNode(n,z(e,i))})}function z(e,t){let n=[];return S(e,t,e=>{n.push(e)}),n}function he(e,t){let n=g(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!ge(i,r)||(t.suppressNode(i,[]),_e(i,t,r),S(e,n,e=>{t.suppressNode(e,[])}))}}function ge(e,t){return!e.rect||n(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function _e(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function ve(e,t){for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)continue;if(ye(i)){B(e,r,i,t);continue}if(!be(i))continue;let a=x(e,r,e=>n(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(i,[a]),xe(i,a,t),B(e,r,a,t))}}function ye(e){return n(e.type??``)===`searchfield`&&e.label===`Search`}function be(e){let t=n(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function B(e,t,n,r){S(e,t,e=>{e.index!==n.index&&Se(e)&&r.suppressNode(e,[n])})}function xe(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Se(e){let t=n(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Ce(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||we(e,n,r,i,t)}}function we(e,t,r,i,a){let o=n(r.type??``);if(o===`statictext`||o===`link`){V(e,t,i,r,a);return}if(o!==`other`)return;let s=Te(e,t,i);if(s){a.suppressNode(r,[s]);return}V(e,t,i,r,a)}function Te(e,t,r){return x(e,t,e=>{let t=n(e.type??``);return(t===`link`||t===`searchfield`||p(e.type))&&e.label?.trim()===r})}function V(e,t,n,r,i){S(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ie(e,n)&&i.suppressNode(e,[r])})}function Ee(e,t){P(e,(n,r,i)=>{let a=x(e,i,e=>m(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||De(n,e)));a&&t.suppressNode(n,[a])})}function De(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let r=n(t.type??``);return Oe(e,r)||r===`textfield`||ke(e,r,t)}function Oe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function ke(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ae(e,t){let r=C(e);for(let i of e)n(i.type??``)===`other`&&(i.hittable===!0||i.label?.trim()||i.value?.trim()||i.identifier?.trim()&&t.suppressNode(i,je(i,r)))}function je(e,t){let n=[],r=new Set([e.index]),i=[...t.get(e.index)??[]];for(;i.length>0;){let e=i.pop();if(!e||r.has(e.index))continue;r.add(e.index),n.push(e);let a=t.get(e.index);a&&i.push(...a)}return n}function Me(e,t){he(e,t),Ae(e,t),ue(e,t),ve(e,t),Ee(e,t),F(e,t.replacements),R(e,t),Ce(e,t)}function Ne(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Pe(e,n,r,t):void 0;!r?.rect||!i||Le(e,n,r,i,t)}}function Pe(e,t,r,i){let a=r.label?.trim();if(n(r.type??``)!==`cell`||a&&!Fe(a,r.identifier)&&!o(a))return a;let s=v(e,t).find(Ie),c=s?.label?.trim();return!s||!c?a:(b(i.replacements,r,{label:c}),i.suppressNode(s,[r]),c)}function Fe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ie(e){if(!e.label?.trim())return!1;let t=n(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function Le(e,t,r,i,a){let o=n(r.type??``);if(o===`button`){H(v(e,t),i,a,r);return}if(o!==`cell`)return;let s=v(e,t);Re(s,r,i,a)||ze(s,r,i,a)}function Re(e,t,n,r){let i=e.find(e=>Ve(e,t,n));if(!i)return!1;let a=e.find(e=>U(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&b(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),Be(e,t,n,i,r),!0}function ze(e,t,n,r){let i=e.find(e=>U(e,t,n));if(!i){e.some(te)&&H(e,n,r,t);return}!t.identifier&&i.identifier&&b(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),H(e.filter(e=>e.index!==i.index),n,r,t)}function Be(e,t,n,r,i){for(let a of e)a.index!==r.index&&(U(a,t,n)||W(a,t)||He(a,r)||h(a,n))&&i.suppressNode(a,[r])}function H(e,t,n,r){for(let i of e)(h(i,t)||r&&W(i,r))&&n.suppressNode(i,r?[r]:[])}function U(e,t,r){if(n(e.type??``)!==`button`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r&&d(e.rect,t.rect)}function W(e,t){return n(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function Ve(e,t,r){if(n(e.type??``)!==`switch`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r}function He(e,t){if(n(e.type??``)!==`switch`||e.index===t.index)return!1;let r=e.label?.trim();return r===t.value?.trim()||r===`0`||r===`1`}const G=1.15;function Ue(t,n,r){let i=new Map(t.map((e,t)=>[e.index,t]));for(let[a,o]of t.entries()){let s=We(t,i,n,o,r);if(!s)continue;q(t,a,r);let c=J(s.shelfRect,2);for(let n of s.intermediateSiblings){if($e(n)||!n.rect||!e(n.rect,c))continue;let a=i.get(n.index);a!==void 0&&q(t,a,r)}}}function We(e,t,n,r,i){let a=Ge(r,n,i.sourceNodesByIndex);if(!a)return;let o=Je(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function Ge(e,t,n){let r=Ye(e,K(t,e.index));if(!r)return;let i=qe(e,n);if(!i||!i.rect)return;let a=K(t,i.index),o=a.findIndex(t=>t.index===e.index);if(Ke(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function K(e,t){return e.get(t)??[]}function Ke(e,t,n,r){if(t<1)return!1;let i=Xe(e,t,n);return i?!r.childActionsPresented||!Ze(i,r.actionButtons):!1}function qe(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function Je(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&Qe(e,t.get(n.index),n,i))}function Ye(e,t){if(!p(e.type)||!e.rect)return;let r=e.rect,a=t.filter(e=>n(e.type??``)===`button`&&e.rect);if(a.length===0&&e.hiddenContentBelow===!0)return{rect:r,childActionsPresented:!1,actionButtons:a};if(a.length<3)return;let o=a.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:r,childActionsPresented:a.some(e=>i(r,e.rect)),actionButtons:a}}function Xe(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!m(t))&&t.rect.x+t.rect.width/2<n.rect.x&&et(t.rect,J(n.rect,2)))return t}}function Ze(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*G||e.rect.height>r*G}function Qe(e,t,r,i){return t!==void 0&&n(r.type??``)===`other`&&d(r.rect,i.rect)&&!!x(e,t,m)}function q(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of v(e,t))n.suppressNode(r,[])}}function $e(e){let t=n(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function J(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function et(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function tt(e,t){let n=C(e);Ue(e,n,t),nt(e,n,t)}function nt(e,t,r){for(let i of e){if(n(i.type??``)!==`navigationbar`||!i.rect)continue;let e=t.get(i.index)??[],a=e.flatMap(t=>rt(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];b(r.replacements,o,{type:`Button`,label:l,enabled:!0,rect:st([c.rect,o.rect,s.rect])}),r.semanticRepresentativeIndexes.add(o.index),r.suppressNode(s,[o]),r.suppressNode(c,[o])}}function rt(e,t,n){let i=r(e);if(!it(e,i))return[];let a=X(t,e=>at(e,i)),o=X(t,Y);return a?.rect&&o?.rect&&ot(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:i}]:[]}function it(e,t){return n(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function at(e,t){return n(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Y(e){return n(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function X(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function ot(e,t,n,r){let a=t.x-(e.x+e.width),o=n.x-(t.x+t.width);return i(r,e)&&i(r,t)&&i(r,n)&&a>=0&&a<=12&&o>=0&&o<=12&&Z(e,t)&&Z(t,n)}function Z(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function st(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function ct(e,t){let r=C(e);for(let i of e){if(n(i.type??``)===`element(58)`){b(t.replacements,i,{type:`WebView`});continue}let e=lt(i,t.sourceNodesByIndex,r);if(e?.kind===`suppress`){t.suppressNode(i,[]);continue}e&&(b(t.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(i.index))}}function lt(e,t,r){if(n(e.type??``)!==`other`)return null;let i=f(e,t,ft),a=e.label?.trim();return!i||!a?null:dt(e,i,a)?{kind:`suppress`}:ut(e,a,r)?{kind:`semantic`,type:Q(e.value)?`Heading`:`StaticText`}:null}function ut(e,t,r){let i=r.get(e.index);if(i?.length!==1)return!1;let a=i[0];return n(a.type??``)===`statictext`&&a.label?.trim()===t&&!r.has(a.index)}function dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!Q(e.value)}function ft(e){let t=n(e.type??``);return t===`webview`||t===`element(58)`}function Q(e){return/^[1-6]$/.test(e?.trim()??``)}const pt=[ct,tt,ae,Ne,Me];function mt(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of pt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=_(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,$(e.index,l,n)]))}}function $(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of $(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}export{mt as t};
|
package/dist/src/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,s as t}from"./sdk-contracts.js";import{_ as n}from"./sdk-batch.js";import{i as r}from"./catalog.js";import{r as i}from"./version.js";import{a,i as ee,r as o,t as te}from"./command-tools.js";import{i as s,r as c,t as l}from"./cli-help.js";const u=`agent-device drives iOS, Android, tvOS, Android TV, macOS, Linux, and web apps. Tools mirror CLI commands of the same name; CLI flags are camelCase properties (--settle -> settle: true).
|
|
2
2
|
|
|
3
3
|
Start: known app -> call open {app, foreground: true} at once; do not probe with devices, apps, appstate, snapshot, or screenshot first. open returns the initial interactive snapshot with @refs. Unknown app id: devices, then apps, then open the discovered id; never invent ids. Existing session: continue from its state, do not reopen.
|
|
4
4
|
|
|
5
|
-
Loop: press/click/fill/longpress/hover/scroll/back with settle: true; the response is the settled UI diff, continue from it. snapshot {interactiveOnly: true} only when the diff lacks the next target or did not settle. Verify with wait {kind: "text", text}, wait {selector}, wait {absent: selector}, is, get, or find; a bare screenshot is not verification. End with close.
|
|
5
|
+
Loop: press/click/fill/longpress/hover/scroll/back with settle: true; the response is the settled UI diff, continue from it. To reach an off-screen target, scroll {direction, until: "<selector>"} scrolls until it is on screen in one call, and direction "bottom" runs to the end of the content; repeated bare scrolls are the slow way to find something. snapshot {interactiveOnly: true} only when the diff lacks the next target or did not settle. Verify with wait {kind: "text", text}, wait {selector}, wait {absent: selector}, is, get, or find; a bare screenshot is not verification. End with close.
|
|
6
6
|
|
|
7
7
|
Targets: copy refs byte-for-byte (@e12, @e12~s4; keep @ and any ~sN). Refs go stale after mutations. Prefer refs, then id/label/role selectors; coordinates last. On a sparse/AX-unavailable warning its refs and selectors are invalid: screenshot, read the image, press {x, y}, then snapshot the changed screen.
|
|
8
8
|
|
|
9
|
-
Errors carry hints; follow them instead of re-planning. Call help only for specialized work (gestures, scripting, TV, macOS, web, remote, debugging) or an unclear command shape, never at startup.`;function d(){let e=new Set(n());return r().filter(t=>!e.has(t))}const f={name:`help`,description:`Usage guides. No topic: the full workflow card. topic = one of ${c().join(`, `)} for that guide, or a tool name for its complete flag reference. For specialized work or an unclear command shape only; not a startup step, not needed after an error that carries a hint.`,inputSchema:{type:`object`,properties:{topic:{type:`string`,description:`Guide topic or tool name; omit for the card.`}},additionalProperties:!1}},p=`CLI syntax over MCP: \`agent-device <command> <positionals> --flag\` = tool <command>; positionals are named properties (target, text, direction), flags camelCase (--settle -> settle: true, -i -> interactiveOnly: true). Terminal-only (no MCP tool; run in a shell): ${d().join(`, `)}.\n\n`;function ne(e){let t=e.topic;if(t!==void 0&&typeof t!=`string`)return m(`Expected topic to be a string.`,!0);let n=t?s(t):l();return n===null?m(`Unknown help topic: ${t}. ${f.description}`,!0):m(p+n)}function m(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}const h=`2026-07-28`,g=[h],_=[`2025-11-25`,`2025-06-18`],v=[...g,..._],y=`server/discover`,b=new Set([`initialize`,`ping`]),x=`io.modelcontextprotocol/protocolVersion`,S=`io.modelcontextprotocol/clientCapabilities`,C=`io.modelcontextprotocol/clientInfo`,w=36e5;var T=class extends Error{requested;constructor(e){super(`Unsupported MCP protocol version: ${e}. Supported: ${v.join(`, `)}.`),this.requested=e}get data(){return{supported:v,requested:this.requested}}};function E(
|
|
9
|
+
Errors carry hints; follow them instead of re-planning. Call help only for specialized work (gestures, scripting, TV, macOS, web, remote, debugging) or an unclear command shape, never at startup.`;function d(){let e=new Set(n());return r().filter(t=>!e.has(t))}const f={name:`help`,description:`Usage guides. No topic: the full workflow card. topic = one of ${c().join(`, `)} for that guide, or a tool name for its complete flag reference. For specialized work or an unclear command shape only; not a startup step, not needed after an error that carries a hint.`,inputSchema:{type:`object`,properties:{topic:{type:`string`,description:`Guide topic or tool name; omit for the card.`}},additionalProperties:!1}},p=`CLI syntax over MCP: \`agent-device <command> <positionals> --flag\` = tool <command>; positionals are named properties (target, text, direction), flags camelCase (--settle -> settle: true, -i -> interactiveOnly: true). Terminal-only (no MCP tool; run in a shell): ${d().join(`, `)}.\n\n`;function ne(e){let t=e.topic;if(t!==void 0&&typeof t!=`string`)return m(`Expected topic to be a string.`,!0);let n=t?s(t):l();return n===null?m(`Unknown help topic: ${t}. ${f.description}`,!0):m(p+n)}function m(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}const h=`2026-07-28`,g=[h],_=[`2025-11-25`,`2025-06-18`],v=[...g,..._],y=`server/discover`,b=new Set([`initialize`,`ping`]),x=`io.modelcontextprotocol/protocolVersion`,S=`io.modelcontextprotocol/clientCapabilities`,C=`io.modelcontextprotocol/clientInfo`,w=36e5;var T=class extends Error{requested;constructor(e){super(`Unsupported MCP protocol version: ${e}. Supported: ${v.join(`, `)}.`),this.requested=e}get data(){return{supported:v,requested:this.requested}}};function E(t,n){let r=I(I(n)._meta),i=L(r,x);if(i===void 0){if(t===y)throw new e(`INVALID_ARGS`,`Expected _meta["${x}"] on ${y}.`);return`legacy`}if(!v.includes(i))throw new T(i);if(!A(r[S]))throw new e(`INVALID_ARGS`,`Expected _meta["${S}"] to be an object.`);let a=r[C];if(a!==void 0&&!j(a))throw new e(`INVALID_ARGS`,`Expected _meta["${C}"] to be a valid Implementation.`);if(!g.includes(i)){if(t===y)throw new T(i);return`legacy`}return`modern`}function D(e){let t=L(I(e),`protocolVersion`);return t!==void 0&&_.includes(t)?t:`2025-11-25`}function O(e,t){return t===`modern`&&b.has(e)}function k(){return{name:`agent-device`,version:i()}}function re(e,t){return t===`legacy`||typeof e!=`object`||!e?e:{resultType:`complete`,...e,_meta:{...e._meta,"io.modelcontextprotocol/serverInfo":k()}}}function ie(e,t){return e===`modern`?{ttlMs:t,cacheScope:`public`}:void 0}function A(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function j(e){return!A(e)||!P(e.name)||!P(e.version)?!1:N(e.title,P)&&N(e.description,P)&&N(e.websiteUrl,P)&&N(e.icons,e=>Array.isArray(e)&&e.every(M))}function M(e){return!A(e)||!P(e.src)?!1:N(e.mimeType,P)&&N(e.sizes,F)&&N(e.theme,e=>e===`light`||e===`dark`)}function N(e,t){return e===void 0||t(e)}function P(e){return typeof e==`string`}function F(e){return Array.isArray(e)&&e.every(P)}function I(e){return A(e)?e:{}}function L(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}async function R(e){if(e.jsonrpc!==`2.0`||typeof e.method!=`string`)return U(e.id??null,-32600,`Invalid JSON-RPC request.`);if(e.id===void 0)return null;try{let t=E(e.method,e.params),n=await z(e.method,e.params,t);return H(e.id,re(n,t))}catch(t){return t instanceof T?U(e.id,-32022,t.message,t.data):t instanceof q?U(e.id,-32601,t.message):U(e.id,-32602,t instanceof Error?t.message:String(t))}}async function z(e,t,n){if(O(e,n))throw new q(`${e} was removed in MCP ${h}.`);switch(e){case`server/discover`:return{supportedVersions:v,capabilities:{tools:{}},instructions:u,ttlMs:w,cacheScope:`public`};case`initialize`:return{protocolVersion:D(t),capabilities:{tools:{}},serverInfo:k(),instructions:u};case`ping`:return{};case`tools/list`:return{tools:[...o(),f],...ie(n,w)};case`tools/call`:return await B(t);default:throw new q(`Unsupported MCP method: ${e}`)}}async function B(e){let t=W(e),n=K(t,`name`);try{return n===`help`?ne(G(t.arguments)):await te.execute(n,G(t.arguments))}catch(e){return V(ee(a(e)),!0)}}function V(e,t=!1){return{isError:t,content:[{type:`text`,text:e}]}}function H(e,t){return{jsonrpc:`2.0`,id:e,result:t}}function U(e,t,n,r){return{jsonrpc:`2.0`,id:e,error:{code:t,message:n,...r?{data:r}:{}}}}function W(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`Expected object parameters.`);return t}function G(e){return e===void 0?{}:W(e)}function K(t,n){let r=t[n];if(typeof r!=`string`||r.length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r}var q=class extends Error{};async function J(){let e=Y(),t=new ce(t=>{e.push(t)});process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{try{t.push(e)}catch(e){$({jsonrpc:`2.0`,id:null,error:{code:-32700,message:e instanceof Error?e.message:String(e)}})}}),await new Promise(e=>{process.stdin.on(`end`,e),process.stdin.on(`close`,e),process.stdin.resume()}),await e.idle()}function Y(e={}){let t=e.handlePayload??X,n=e.write??$,r=Promise.resolve();return{push:e=>{let i=se(e);r=r.then(async()=>{let r=await t(e);r&&n(r)}).catch(e=>{n({jsonrpc:`2.0`,id:i,error:{code:-32603,message:e instanceof Error?e.message:String(e)}})})},idle:async()=>{await r}}}function X(e){return Array.isArray(e)?ae(e):Z(e)}async function ae(e){let t=[];for(let n of e)t.push(...le(await Z(n)));return t.length>0?t:null}async function Z(e){let n;try{n=t.parse(e)}catch{return oe(Q(e))}return R(n)}function oe(e){return{jsonrpc:`2.0`,id:e,error:{code:-32600,message:`Invalid JSON-RPC request.`}}}function se(e){return Array.isArray(e)?e.length===1?Q(e[0]):null:Q(e)}function Q(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.id;if(typeof t==`string`||typeof t==`number`||t===null)return t}return null}var ce=class{buffer=``;sink;constructor(e){this.sink=e}push(e){for(this.buffer+=e;;){let e=this.tryReadLineMessage();if(e!==void 0){this.emit(e);continue}break}}tryReadLineMessage(){let e=this.buffer.indexOf(`
|
|
10
10
|
`);if(e===-1)return;let t=this.buffer.slice(0,e).trim();return this.buffer=this.buffer.slice(e+1),t.length>0?t:void 0}emit(e){this.sink(JSON.parse(e))}};function le(e){return e?[e]:[]}function $(e){process.stdout.write(`${JSON.stringify(e)}\n`)}export{Y as createMcpPayloadQueue,X as handleMcpPayload,J as runAgentDeviceMcpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e}from"./sdk-contracts.js";import{a as t}from"./request-cancellation.js";import{c as n,r,t as i}from"./device-session.js";import{assertLimrunUploadedAppAccess as a,resolveInstalledAppIdForAsset as o,resolveLimrunAppAsset as s}from"./app-catalog.js";async function c(e,t,n){let r=n?.initialApp,i=typeof r==`string`?r.trim():``;if(i)return a(n?.publicNetworkOnly),await s(e,t,i,n?.signal)}async function l(t,n){let r=await i(t).listApps(`user-installed`),a=o(n.name,r);if(a)return a;throw new e(`COMMAND_FAILED`,`Limrun installed ${n.name}, but its application identifier could not be resolved unambiguously.`,{asset:n.name,installedApps:r.map(e=>e.id)})}async function u(n){let i=await n.limrun.iosInstances.create({wait:!0,metadata:n.metadata,spec:{...n.region?{region:n.region}:{},...n.app?{initialAssets:[{kind:`App`,source:`AssetID`,assetId:n.app.id,launchMode:`RelaunchIfRunning`}]}:{}}});try{if(!i.status.apiUrl)throw new e(`COMMAND_FAILED`,`Limrun iOS instance did not expose apiUrl`);return await r({lease:n.lease,instanceId:i.metadata.id,device:t(`ios`,n.lease,i.metadata.id),apiUrl:i.status.apiUrl,token:i.status.token},n.dependencies)}catch(e){throw await n.limrun.iosInstances.delete(i.metadata.id).catch(()=>{}),e}}async function d(r){let i=await r.limrun.androidInstances.create({wait:!0,metadata:r.metadata,spec:{...r.region?{region:r.region}:{},...r.app?{initialAssets:[{kind:`App`,source:`AssetIDs`,assetIds:[r.app.id]}]}:{}}});try{if(!i.status.apiUrl||!i.status.adbWebSocketUrl)throw new e(`COMMAND_FAILED`,`Limrun Android instance did not expose API and ADB websocket endpoints`);return await n({lease:r.lease,instanceId:i.metadata.id,device:t(`android`,r.lease,i.metadata.id),apiUrl:i.status.apiUrl,token:i.status.token,adbUrl:i.status.adbWebSocketUrl},r.dependencies)}catch(e){throw await r.limrun.androidInstances.delete(i.metadata.id).catch(()=>{}),e}}export{d as allocateLimrunAndroidSession,u as allocateLimrunIosSession,l as resolvePreinstalledAppId,c as resolveRequestedLimrunAppAsset};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return Object.freeze({async observeRunnerSession(e){let{getRunnerSessionSnapshot:t}=await import(`./runner-client.js`).then(e=>e.h),n=await t(e);return n?{alive:n.alive,sessionId:n.sessionId}:void 0},async resolveSoleForegroundApp(t={}){try{let n=await e.listLocalDevices({platform:`ios`,iosSimulatorSetPath:t.simulatorSetPath,kind:`simulator`,booted:!0});if(n.length!==1)return;let[r]=n;if(!r)return;let{detectSoleRunningIosSimulatorApp:i}=await import(`./app-resolution.js`).then(e=>e.t),a=await i(r);return a?{device:r,app:{bundleId:a.bundleId}}:void 0}catch(t){if(e.shouldPropagateProbeError(t))throw t;return}}})}export{e as createAppleSessionObservation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e}from"./sdk-contracts.js";import"./session-store.js";import t from"node:path";import n from"node:fs";import r from"node:crypto";const i=`default`;function a(e,t){let n=e.session||i;if(d(e))return n;let r=c(e);return r.kind===`cwd`?f(r.id,n):n}function o(e){return e.session||i}function s(e){let t=c(e);return t.kind===`cwd`?t:void 0}function c(t){if(t.meta?.sessionIsolation===`tenant`||t.flags?.sessionIsolation===`tenant`){let n=t.meta?.tenantId;if(!n)throw new e(`INTERNAL_ERROR`,`Tenant-scoped request reached session routing without an admitted tenant id`);return{kind:`tenant`,id:n}}if(d(t)||(t.session||i)!==i)return{kind:`named-local`};let n=m(t.meta?.cwd);return n?{kind:`cwd`,id:p(n)}:{kind:`global-default`}}function l(e,t){let n=e.sessionScope;return n?t.kind===`tenant`?n.kind===`tenant`&&n.id===t.id:n.kind===`tenant`?!1:t.kind!==`cwd`||n.kind===`named-local`||n.kind===`cwd`&&n.id===t.id:!1}function u(e,t){let n=s(e);return!n||t.sessionScope?.kind!==`cwd`?!1:t.sessionScope.id!==n.id}function d(e){if(e.meta?.sessionExplicit===!0)return!0;let t=e.flags?.session;return typeof t==`string`&&t.trim().length>0}function f(e,t){return`cwd:${e}:${t}`}function p(e){return r.createHash(`sha256`).update(e).digest(`hex`).slice(0,16)}function m(e){if(!e||e.trim().length===0)return;let t=h(e);return g(t)??t}function h(e){let r=t.resolve(e);try{return n.realpathSync.native(r)}catch{return r}}function g(e){let r=e;for(;;){if(n.existsSync(t.join(r,`.git`)))return r;let e=t.dirname(r);if(e===r)return;r=e}}export{c as a,o as i,u as n,l as o,a as r,d as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e}from"./sdk-contracts.js";import{i as t}from"./request-runtime-binding.js";function n(e,n){if(!n.available)return t(`UNSUPPORTED_OPERATION`,`${e} is not supported on this device`,{reason:n.reason},n.hint?{hint:n.hint}:void 0)}function r(t){if(t)return t;throw new e(`COMMAND_FAILED`,`Device runtime facts inspection is unavailable.`)}const i=new WeakMap;let a;(class e{static{a=(t,n)=>{let r=new e;return i.set(r,{device:Object.freeze({...t}),plan:n}),Object.freeze(r),r}}#e;constructor(){this.#e=void 0}get admitted(){return this.#e,!0}});function o(t){let n=i.get(t);if(n===void 0)throw new e(`COMMAND_FAILED`,`Runtime plan admission is not one minted by admitRuntimePlan; refusing to bind.`);return n}async function s(e){let t=await r(e.inspectFacts)(e.device);for(let n of e.plan.use.required){let e=t.operations[n];if(!e.available)return{admitted:!1,operation:n,fact:e}}return a(e.device,e.plan)}function c(t){if(t)return t;throw new e(`COMMAND_FAILED`,`Device runtime binding is unavailable.`)}export{o as a,n as i,c as n,r,s as t};
|