agent-device 0.20.10 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.10.apk → agent-device-android-ime-helper-0.21.0.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.0.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.10.manifest.json → agent-device-android-ime-helper-0.21.0.manifest.json} +4 -4
- 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 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.10.manifest.json → agent-device-android-snapshot-helper-0.21.0.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +35 -33
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +6 -1
- package/apple/snapshot-bridge/LICENSE.idb +23 -0
- package/apple/snapshot-bridge/README.md +49 -0
- package/apple/snapshot-bridge/SnapshotBridge.m +280 -0
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.h +33 -0
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +382 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +58 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +19 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAlertVerification.swift +36 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerStringNormalization.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +12 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +100 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +2 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +16 -8
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +21 -88
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +124 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +106 -103
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +6 -14
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +63 -91
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +13 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +72 -155
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXElementTypes.swift +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +74 -78
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +17 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +42 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +185 -461
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotBackendCapabilities.swift +98 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +224 -164
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationInvariant.swift +19 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +110 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +206 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +147 -25
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +24 -307
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +206 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +158 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +49 -16
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +2 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +4 -19
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +16 -20
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +111 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +42 -81
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +35 -82
- package/dist/apple/snapshot-presentation/Package.swift +21 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +56 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +259 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +153 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationFailure.swift +27 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +91 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +161 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotScopePolicy.swift +53 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +242 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +97 -0
- package/dist/src/adapter.js +1 -0
- package/dist/src/adb-executor.js +2 -0
- package/dist/src/adb-failure.js +1 -0
- package/dist/src/adb-host.js +1 -0
- package/dist/src/adb.js +1 -0
- package/dist/src/agent-browser-lifecycle.js +1 -0
- package/dist/src/agent-browser-process-record.js +1 -0
- package/dist/src/agent-browser-provider.js +1 -0
- 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 +2 -2
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-contract.js +1 -0
- package/dist/src/alert-runtime.js +1 -0
- package/dist/src/android-adb.d.ts +27 -19
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-input-ownership.js +1 -0
- package/dist/src/android-system-chrome.js +1 -0
- package/dist/src/android.js +1 -1
- package/dist/src/api.js +11 -0
- package/dist/src/app-catalog.js +1 -0
- package/dist/src/app-deployment-resolution.js +2 -0
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-inventory-contract.js +1 -0
- package/dist/src/app-inventory.js +1 -0
- package/dist/src/app-launch.js +2 -0
- package/dist/src/app-lifecycle-facade.js +1 -0
- package/dist/src/app-lifecycle.js +3 -6
- package/dist/src/app-lifecycle2.js +2 -2
- package/dist/src/app-lifecycle3.js +1 -0
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime.js +1 -4
- package/dist/src/app-log-runtime2.js +4 -0
- package/dist/src/app-parsers.js +4 -0
- package/dist/src/app-resolution-cache.js +1 -0
- package/dist/src/app-resolution-facade.js +1 -0
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state.js +1 -2
- package/dist/src/application-lifecycle-interaction.js +1 -0
- package/dist/src/application-lifecycle-runtime.js +1 -0
- package/dist/src/apps-simctl.js +1 -0
- package/dist/src/archive.js +4 -0
- package/dist/src/artifact-download.js +1 -0
- package/dist/src/artifacts.d.ts +6 -2
- package/dist/src/artifacts.js +1 -1
- package/dist/src/async-lifecycle.js +1 -0
- package/dist/src/audio-probe-result.js +1 -0
- package/dist/src/audio-probe-runtime.js +1 -0
- package/dist/src/audio-probe-support.js +1 -0
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/back-mode.js +1 -0
- package/dist/src/{url.js → base-url.js} +1 -1
- package/dist/src/boot-diagnostics.js +2 -2
- package/dist/src/byte-limit-stream.js +1 -1
- package/dist/src/capabilities.js +1 -0
- package/dist/src/capture.js +1 -0
- package/dist/src/catalog.js +1 -0
- package/dist/src/cli-command-aliases.js +1 -0
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +69 -50
- package/dist/src/cli-output.js +1 -1
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +4 -6
- package/dist/src/click-button.js +1 -0
- package/dist/src/client-metro-companion.js +1 -0
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +255 -231
- package/dist/src/clipboard.js +1 -0
- package/dist/src/code-signature-cache.js +1 -0
- package/dist/src/code-signature.js +1 -0
- package/dist/src/color.js +1 -0
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +3 -3
- package/dist/src/command-surface.js +1 -1
- package/dist/src/command-tools.js +2 -2
- package/dist/src/command.js +1 -0
- package/dist/src/compatibility-policy.js +1 -0
- package/dist/src/config.js +1 -1
- package/dist/src/config2.js +1 -0
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +5 -5
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -0
- package/dist/src/daemon-process.js +1 -0
- package/dist/src/daemon-registration.js +1 -0
- package/dist/src/daemon-shutdown-report.js +1 -1
- package/dist/src/daemon.js +2 -2
- package/dist/src/debug-symbols-facade.js +5 -0
- package/dist/src/deploy-result-target.js +1 -0
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +1 -0
- package/dist/src/device-input-state.d.ts +190 -3
- package/dist/src/device-inventory-context.js +1 -0
- package/dist/src/device-isolation.js +1 -0
- package/dist/src/device-release.js +1 -0
- package/dist/src/device-rotation.js +1 -0
- package/dist/src/device-selection-resolver.js +1 -0
- package/dist/src/device-session.js +1 -0
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +3 -2
- package/dist/src/diagnostics.js +3 -0
- package/dist/src/diagnostics2.js +1 -0
- package/dist/src/dispatch-resolve.js +1 -0
- package/dist/src/doctor-facade.js +1 -0
- package/dist/src/doctor-output.js +1 -0
- package/dist/src/doctor.js +1 -0
- package/dist/src/doctor2.js +1 -0
- package/dist/src/doctor3.js +1 -0
- package/dist/src/durable-resource.js +1 -0
- package/dist/src/entities.js +1 -1
- package/dist/src/error.js +2 -0
- package/dist/src/exec.js +1 -0
- package/dist/src/file.js +1 -0
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/format.js +2 -0
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/gesture-admission.js +1 -0
- package/dist/src/gesture-plan-types.js +1 -0
- package/dist/src/gesture-plan.js +1 -0
- package/dist/src/gesture-runtime.js +1 -0
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host-file.js +1 -0
- package/dist/src/human-control-contract.js +1 -0
- package/dist/src/human-control.js +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -4
- package/dist/src/input-actions2.js +2 -1
- package/dist/src/install-artifact-facade.js +1 -0
- package/dist/src/install-source-network-transport.js +1 -0
- package/dist/src/install-source.d.ts +3 -10
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-positionals.js +1 -0
- package/dist/src/interaction-ref-policy.js +1 -0
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-catalog.js +1 -0
- package/dist/src/interactor-types.js +1 -0
- package/dist/src/interactor.js +6 -2
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.d.ts +1 -1
- package/dist/src/internal/bin.js +1 -2
- package/dist/src/internal/companion-tunnel.d.ts +1 -1
- package/dist/src/internal/companion-tunnel.js +1 -1
- package/dist/src/internal/daemon.d.ts +1 -1
- package/dist/src/internal/daemon.js +2 -4
- package/dist/src/internal/png-worker.d.ts +4 -4
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-http-child.d.ts +4 -0
- package/dist/src/internal/run-script-http-child.js +1 -0
- package/dist/src/internal/update-check-entry.d.ts +1 -1
- package/dist/src/inventory.js +4 -4
- package/dist/src/inventory2.js +1 -1
- package/dist/src/inventory3.js +1 -1
- package/dist/src/inventory5.js +1 -1
- package/dist/src/inventory6.js +1 -1
- package/dist/src/ios-client.js +16 -0
- package/dist/src/ios-snapshot-acquisition.js +1 -0
- package/dist/src/ios-snapshot-adapter.js +1 -0
- package/dist/src/ios-snapshot-planning.js +1 -0
- package/dist/src/ios-snapshot-runtime.js +1 -0
- package/dist/src/json.js +1 -0
- package/dist/src/keyboard-actions.js +1 -0
- package/dist/src/launch-console.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-scope.js +1 -0
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +1610 -7
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -0
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/logcat.js +1 -1
- package/dist/src/macos-facade.js +1 -0
- package/dist/src/managed-device-scope.js +1 -0
- package/dist/src/mechanics.js +19 -0
- package/dist/src/metro.d.ts +4 -2
- package/dist/src/metro.js +1 -1
- package/dist/src/metro2.js +1 -1
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/multitouch-support.js +1 -0
- package/dist/src/numeric.js +1 -0
- package/dist/src/observability.js +1 -1
- package/dist/src/observation.js +2 -0
- package/dist/src/output-path.js +1 -1
- package/dist/src/owner-identity.js +3 -1
- package/dist/src/parameterized-recorded-fill.js +1 -0
- package/dist/src/parser.js +1 -1
- package/dist/src/perf-facade.js +2 -0
- package/dist/src/perf-runtime-operation-builder.js +1 -0
- package/dist/src/perf-runtime-plan.js +1 -0
- package/dist/src/perf-runtime.js +1 -0
- package/dist/src/perf.js +1 -4
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/physical-device-facade.js +1 -0
- package/dist/src/platform-request-scope.js +1 -0
- package/dist/src/platform-runtime-android-adb-host.js +1 -0
- package/dist/src/platform-runtime-android-mechanics.js +1 -0
- package/dist/src/platform-runtime-app-log-android-transport.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-apple-resources.js +1 -0
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -0
- package/dist/src/platform-runtime-network-web-transport.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +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-apple-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -0
- package/dist/src/platform-runtime-screen-recording-web-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -0
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plist.js +1 -1
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/prepare-kind.js +1 -0
- package/dist/src/process-exit.js +1 -1
- package/dist/src/process.js +1 -0
- package/dist/src/provider-device-runtime.js +1 -0
- package/dist/src/provider-session-ownership.js +2 -0
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/provider.js +1 -1
- package/dist/src/providers.js +1 -0
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-native-overlay.js +1 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/rect-center.js +1 -0
- package/dist/src/register-builtins.js +1 -0
- package/dist/src/registry.js +39 -28
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay-divergence.js +2 -0
- package/dist/src/replay.js +2 -2
- package/dist/src/reporting.js +8 -8
- package/dist/src/request-admission.js +1 -0
- package/dist/src/request-cancel.js +1 -0
- package/dist/src/request-cancellation.js +1 -0
- package/dist/src/request-progress-protocol.js +1 -0
- package/dist/src/request-providers.js +1 -0
- package/dist/src/request-runtime-binding.js +1 -0
- package/dist/src/request.js +1 -0
- package/dist/src/result-serialization.js +1 -0
- package/dist/src/retry.js +1 -0
- package/dist/src/rolldown-runtime.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -0
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -0
- package/dist/src/runner-owner-facade.js +1 -0
- package/dist/src/runner-owner-state.js +1 -0
- package/dist/src/runner-presentation.js +1 -0
- package/dist/src/runner-selector-query.js +1 -0
- package/dist/src/runner.js +1 -0
- package/dist/src/{runtime-transport.js → runtime-transport-hints.js} +1 -1
- package/dist/src/runtime.js +3 -3
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +4 -3
- 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/scoped-provider.js +1 -1
- package/dist/src/screen-recording-completion.js +1 -0
- package/dist/src/screen-recording-live-handle.js +1 -0
- package/dist/src/screen-recording-options.js +1 -0
- package/dist/src/screen-recording-resource-recovery.js +1 -0
- package/dist/src/screen-recording-runtime.js +1 -0
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-result.js +1 -6
- package/dist/src/screenshot-runtime.js +1 -0
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot2.js +1 -0
- package/dist/src/screenshot3.js +5 -0
- package/dist/src/script.js +1 -0
- package/dist/src/scroll-command.js +1 -0
- package/dist/src/scroll-gesture.js +1 -0
- package/dist/src/scroll-indicator.js +1 -0
- package/dist/src/sdk-batch-runner.d.ts +23 -6
- package/dist/src/sdk-batch-runner.js +2 -3
- package/dist/src/sdk-batch.js +2 -0
- package/dist/src/sdk-contracts.d.ts +127 -41
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.js +1 -1
- package/dist/src/sdk-remote-config.d.ts +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +472 -144
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/semantic-index.js +1 -0
- package/dist/src/server.js +4 -4
- package/dist/src/session-allocation.js +1 -0
- package/dist/src/session-artifact-paths.js +1 -0
- package/dist/src/session-paths.js +1 -0
- package/dist/src/session-repair-tombstone.js +1 -0
- package/dist/src/session-routing.js +1 -0
- package/dist/src/session-runtime-admission.js +1 -0
- package/dist/src/session-snapshot.js +1 -0
- package/dist/src/session-store.js +4 -0
- package/dist/src/session-target-evidence.js +1 -1
- package/dist/src/session2.js +5 -27
- package/dist/src/settings.js +1 -0
- package/dist/src/shared.js +2 -2
- package/dist/src/simctl-facade.js +1 -0
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-facade.js +1 -0
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -0
- package/dist/src/snapshot-desktop-projection.js +1 -0
- package/dist/src/snapshot-diagnostics.js +1 -0
- package/dist/src/snapshot-process.js +1 -0
- package/dist/src/snapshot-quality-backend-capabilities.js +1 -0
- package/dist/src/snapshot-quality-verdict.js +1 -0
- package/dist/src/snapshot-runtime-binding.js +1 -0
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-scope.js +1 -1
- package/dist/src/snapshot-state.js +1 -0
- package/dist/src/snapshot.js +1 -8
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -1
- package/dist/src/snapshot4.js +1 -0
- package/dist/src/src.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +1 -2
- package/dist/src/src4.js +1 -1
- package/dist/src/src5.js +1 -0
- package/dist/src/src6.js +1 -0
- package/dist/src/src7.js +2 -0
- package/dist/src/src8.js +115 -0
- package/dist/src/startup-recovery-fence.js +1 -0
- package/dist/src/status-markers.js +1 -0
- package/dist/src/string-enum.js +1 -1
- package/dist/src/success-text.js +1 -0
- package/dist/src/surface-snapshot.js +1 -0
- package/dist/src/surface-snapshot2.js +1 -0
- package/dist/src/takeover.js +5 -0
- package/dist/src/tool-provider-facade.js +1 -0
- package/dist/src/tool-provider.js +4 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -1
- package/dist/src/toolchain-probe.js +2 -0
- package/dist/src/touch-runtime.js +1 -0
- package/dist/src/transport.js +3 -0
- package/dist/src/tree.js +1 -0
- package/dist/src/ttl-memo.js +1 -0
- package/dist/src/tv-remote.js +1 -0
- package/dist/src/type-text-runtime.js +1 -0
- package/dist/src/undici.js +99 -0
- package/dist/src/update-check.js +1 -1
- 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/web.js +2 -1
- package/dist/src/web2.js +1 -0
- package/dist/src/webdriver-ios-snapshot.js +1 -0
- package/dist/src/webdriver-source.js +1 -0
- package/linux/atspi-dump.py +54 -9
- package/package.json +56 -34
- package/server.json +9 -3
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.10.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.10.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.10.apk.sha256 +0 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +0 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -168
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+LifecycleCacheTests.swift +0 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+RecordingTests.swift +0 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +0 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentation.swift +0 -183
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationTests.swift +0 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTraversalIdentityTests.swift +0 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryPolicyTests.swift +0 -4
- package/dist/src/appearance.js +0 -1
- package/dist/src/apps.js +0 -5
- package/dist/src/audio-probe.js +0 -1
- package/dist/src/cli-grammar.js +0 -1
- package/dist/src/command-catalog.js +0 -1
- package/dist/src/debug-symbols.js +0 -5
- package/dist/src/device-input-state.js +0 -2
- package/dist/src/device-ready.js +0 -1
- package/dist/src/dispatch.js +0 -1
- package/dist/src/handler-utils.js +0 -1
- package/dist/src/helper-package-install.js +0 -1
- package/dist/src/host-process.js +0 -3
- package/dist/src/ime-lifecycle.js +0 -2
- package/dist/src/ime-recovery-marker.js +0 -1
- package/dist/src/input-actions3.js +0 -1
- package/dist/src/install-artifact.js +0 -1
- package/dist/src/install-artifact2.js +0 -1
- package/dist/src/interaction-common.js +0 -1
- package/dist/src/interaction-runtime.js +0 -1
- package/dist/src/interaction-snapshot.js +0 -1
- package/dist/src/manifest.js +0 -1
- package/dist/src/method-scope.js +0 -1
- package/dist/src/png-resize.js +0 -1
- package/dist/src/process-lock.js +0 -1
- package/dist/src/runner-lease.js +0 -1
- package/dist/src/runner-sequence.js +0 -1
- package/dist/src/script-source-bundle.js +0 -16
- package/dist/src/sdk-android-adb.d.ts +0 -245
- package/dist/src/sdk-android-adb.js +0 -4
- package/dist/src/sdk.js +0 -1
- package/dist/src/setting-state.js +0 -1
- package/dist/src/shell-quote.js +0 -1
- package/dist/src/snapshot-session.js +0 -1
- package/dist/src/timing-safe-equal.js +0 -1
- package/dist/src/unsupported-interactor.js +0 -1
- package/dist/src/verdict.js +0 -1
- /package/dist/src/{recording-telemetry.js → telemetry.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as e,s as t}from"./sdk-device.js";import{Gt as n,Wt as r,qt as i}from"./sdk-batch.js";const a=4096;function o(e){return c(e,{seen:new WeakSet,nodes:0},0)}function s(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,p(t)])))}function c(e,t,n){if(!d(e)||n>32||t.seen.has(e))return!1;t.seen.add(e),t.nodes+=1;let r=t.nodes<=a&&Object.values(e).every(e=>l(e,t,n+1));return t.seen.delete(e),r}function l(e,t,n){return f(e)?!0:n>32?!1:Array.isArray(e)?u(e,t,n):c(e,t,n)}function u(e,t,n){if(t.seen.has(e))return!1;t.seen.add(e),t.nodes+=1;let r=t.nodes<=a&&e.every(e=>l(e,t,n+1));return t.seen.delete(e),r}function d(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function f(e){return e===null?!0:typeof e==`number`?Number.isFinite(e):typeof e==`string`||typeof e==`boolean`}function p(e){return Array.isArray(e)?Object.freeze(e.map(p)):typeof e==`object`&&e?s(e):e}function m(e){if(!P(e))return _(`Durable resource envelope must be an object`);let t=e.envelopeVersion;if(!N(t))return _(`Durable resource envelopeVersion must be a non-negative integer`);if(t!==1)return{status:`unreattachable`,reason:`descriptor-version-unsupported`,message:`Unsupported durable resource envelope version: ${t}`,version:t};if(!M(e.resourceKind))return _(`Durable resource resourceKind must be a non-empty string`);if(!M(e.sessionId))return _(`Durable resource sessionId must be a non-empty string`);let n=y(e.device);if(!n)return _(`Durable resource device identity is invalid`);let r=v(e.owner);if(!r)return _(`Durable resource owner reference is invalid`);if(r.kind===`local-family`&&r.family!==n.family)return _(`Durable resource local owner does not match the device family`);let i=D(e.fence);if(!i)return _(`Durable resource ownership fence is invalid`);if(!k(e.lifecycle))return _(`Durable resource lifecycle state is invalid`);let a=O(e.descriptor);return a?e.metadata!==void 0&&!o(e.metadata)?_(`Durable resource metadata must be a JSON object`):{status:`decoded`,envelope:Object.freeze({envelopeVersion:1,resourceKind:e.resourceKind,sessionId:e.sessionId,device:n,owner:r,fence:i,lifecycle:e.lifecycle,descriptor:a,...e.metadata===void 0?{}:{metadata:s(e.metadata)}})}:_(`Durable resource descriptor is invalid`)}function h(e,t){return Object.freeze({version:e.version,body:s(e.encode(t))})}function g(e){let t=m({envelopeVersion:1,...e});if(t.status!==`decoded`)throw TypeError(t.message);return t.envelope}function _(e){return{status:`unreattachable`,reason:`descriptor-invalid`,message:e}}function v(t){return P(t)?t.kind===`local-family`&&e(t.family)?r(t.family):t.kind===`managed-local`&&M(t.instance)?n(t.instance):t.kind===`provider-runtime`&&M(t.provider)&&M(t.instance)?i(t.provider,t.instance):null:null}function y(e){if(!P(e))return null;let t=x(e.id),n=S(e.family),r=C(e.kind),i=w(e.target);return!t||!n||!r||i===null||!T(e,n,r)?null:b(e,t,n,r,i)}function b(e,t,n,r,i){return Object.freeze({id:t,family:n,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:r,...i===void 0?{}:{target:i},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function x(e){return M(e)?e:null}function S(t){return e(t)?t:null}function C(e){return A(e)?e:null}function w(e){if(e!==void 0)return j(e)?e:null}function T(e,n,r){if(n===`apple`){if(!t(e.appleOs))return!1}else if(e.appleOs!==void 0||e.iosPhysicalDeviceBackend!==void 0)return!1;return E(e.iosPhysicalDeviceBackend,r)}function E(e,t){return e===void 0?!0:t===`device`?e===`coredevice`||e===`xctest`:!1}function D(e){return!P(e)||!M(e.token)||!N(e.generation)?null:Object.freeze({token:e.token,generation:e.generation})}function O(e){return!P(e)||!N(e.version)||!o(e.body)?null:Object.freeze({version:e.version,body:s(e.body)})}function k(e){return e===`open`||e===`completed`}function A(e){return e===`simulator`||e===`emulator`||e===`device`}function j(e){return e===`mobile`||e===`tv`||e===`desktop`}function M(e){return typeof e==`string`&&e.trim().length>0}function N(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0}function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F(e){return e.status===`cleaned`||e.status===`already-missing`}export{h as a,m as i,g as n,y as r,F as t};
|
package/dist/src/entities.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return e.
|
|
1
|
+
function e(e){return e.replaceAll(/&(#(?:x|X)[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g,(e,t)=>{switch(t){case`amp`:return`&`;case`lt`:return`<`;case`gt`:return`>`;case`quot`:return`"`;case`apos`:return`'`;default:return n(e,t)}})}function t(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function n(e,t){let n=t.slice(0,2).toLowerCase()===`#x`?Number.parseInt(t.slice(2),16):Number(t.slice(1));if(!Number.isInteger(n)||n<0||n>1114111)return e;try{return String.fromCodePoint(n)}catch{return e}}export{t as n,e as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{O as e,j as t,y as n}from"./sdk-contracts.js";import{r}from"./replay-divergence.js";function i(i,o={}){let s=i instanceof n?e(i):i;if(process.stderr.write(`Error (${s.code}): ${s.message}\n`),s.cause){let e=s.cause.code?`${s.cause.code} `:``;process.stderr.write(`Cause: ${e}${s.cause.message}\n`)}s.hint&&process.stderr.write(`Hint: ${s.hint}\n`);let c=a(t(s.details));c.length>0&&process.stderr.write(`${c.join(`
|
|
2
|
+
`)}\n`),s.diagnosticId&&process.stderr.write(`Diagnostic ID: ${s.diagnosticId}\n`),s.logPath&&process.stderr.write(`Diagnostics Log: ${s.logPath}\n`),s.logPathUnavailable&&process.stderr.write(`Remote Diagnostics: unavailable (${s.logPathUnavailable})\n`);let l=r(s.details);l&&process.stderr.write(`${l}\n`),o.showDetails&&s.details&&process.stderr.write(`${JSON.stringify(s.details,null,2)}\n`)}function a(e){return e.flatMap(e=>{if(e.kind===`element-match`){let t=e.matches-e.candidates.length;return[`Candidates:`,...e.candidates.map(t=>` ${o(t,e.refsGeneration)}`),...t>0?[` +${t} more`]:[]]}return[`Devices:`,...e.devices.map(e=>` ${e.id} ${e.name}`)]})}function o(e,t){return t===void 0?e:e.replace(/^@(e\d+)(?=\s|$)/,`@$1~s${t}`)}export{i as printHumanError};
|
package/dist/src/exec.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{x as e,y as t}from"./sdk-contracts.js";import{o as n}from"./sdk-remote-config.js";import{a as r,r as i,s as a}from"./diagnostics.js";import o from"node:path";import{constants as s}from"node:fs";import{AsyncLocalStorage as c}from"node:async_hooks";import{access as l,stat as u}from"node:fs/promises";import{spawn as d,spawnSync as f}from"node:child_process";import{Readable as p}from"node:stream";import{pipeline as m}from"node:stream/promises";const h=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,g=[`.com`,`.exe`,`.bat`,`.cmd`],_=new c;async function v(e,t){return e?await _.run(e,t):await t()}async function y(e){return await _.run(void 0,e)}async function b(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}async function x(e,t,n={}){let r=_.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}function S(e){let t=typeof e.stdout==`string`?e.stdout:String(e.stdout??``),n=typeof e.stderr==`string`?e.stderr:String(e.stderr??``),r=typeof e.exitCode==`number`?e.exitCode:1;return t===e.stdout&&n===e.stderr&&r===e.exitCode?e:{...e,stdout:t,stderr:n,exitCode:r}}function C(e,t,n={}){let r=P(e),i=j();return new Promise((a,o)=>{let s=d(r,t,{cwd:n.cwd,env:n.env,stdio:[`pipe`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});n.onSpawn?.(s);let c=``,l=n.binaryStdout?[]:void 0,u=``,f=!1,p=Z(n.timeoutMs),m=p?setTimeout(()=>{f=!0,$(s,n.detached)},p):null,h=Q(s,n);n.binaryStdout||s.stdout.setEncoding(`utf8`),s.stderr.setEncoding(`utf8`),te(s,n.stdin).catch(i=>{h.didAbort||f||ne(i)||(o(ee(r,e,t,i)),$(s,n.detached))}),s.stdout.on(`data`,e=>{if(n.binaryStdout){l?.push(Buffer.isBuffer(e)?e:Buffer.from(e));return}let t=String(e);c+=t,n.onStdoutChunk?.(t)}),s.stderr.on(`data`,e=>{let t=String(e);u+=t,n.onStderrChunk?.(t)}),s.on(`error`,n=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t),o(U(h,r,e,t,n))}),s.on(`close`,s=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t);let d=s??1;if(!h.didAbort&&f&&p){o(z(r,e,t,p,d,c,u));return}let g=W(h,r,e,t,d,n.allowFailure,c,u);if(g){o(g);return}a({stdout:c,stderr:u,exitCode:d,stdoutBuffer:l?Buffer.concat(l):void 0})})})}async function w(e){let t=K(e);if(!t)return!1;if(o.isAbsolute(t))return Y(t);let n=process.env.PATH;if(!n)return!1;let r=q();for(let e of n.split(o.delimiter)){let n=e.trim();if(n){for(let e of J(t,r))if(await Y(o.join(n,e)))return!0}}return!1}async function T(e,n){let r=G(e,n,`executable`);if(r){if(!await Y(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-executable file: ${r}`,{envName:n,path:r});return r}}async function E(e,n){let r=G(e,n,`file`);if(r){if(!await X(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-file path: ${r}`,{envName:n,path:r});return r}}function D(e,n,r={}){let i=P(e),a=f(i,n,{cwd:r.cwd,env:r.env,stdio:[`pipe`,`pipe`,`pipe`],encoding:r.binaryStdout?void 0:`utf8`,input:r.stdin,timeout:Z(r.timeoutMs),windowsHide:!0,shell:!1,...r.maxBuffer===void 0?{}:{maxBuffer:r.maxBuffer}});if(a.error){let o=a.error.code;throw o===`ETIMEDOUT`?new t(`COMMAND_FAILED`,`${i} timed out after ${Z(r.timeoutMs)}ms`,{cmd:e,args:n,timeoutMs:Z(r.timeoutMs)},a.error):o===`ENOENT`?I(i,e,a.error):L(i,e,n,a.error)}let o=r.binaryStdout?Buffer.isBuffer(a.stdout)?a.stdout:Buffer.from(a.stdout??``):void 0,s=r.binaryStdout?``:typeof a.stdout==`string`?a.stdout:(a.stdout??``).toString(),c=typeof a.stderr==`string`?a.stderr:(a.stderr??``).toString(),l=a.status??1;if(l!==0&&!r.allowFailure)throw B(i,e,n,l,s,c);return{stdout:s,stderr:c,exitCode:l,stdoutBuffer:o}}function O(e,t,n={}){return k(e,t,n).pid}function k(e,t,n={}){let r=P(e),i=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??`ignore`,detached:!0,windowsHide:!0,shell:!1}),a=i.pid??0,o=new Promise(e=>{i.once(`error`,t=>{e({pid:a,error:t.message})}),i.once(`exit`,(t,n)=>{e({pid:a,...typeof t==`number`?{exitCode:t}:{},...n?{signal:n}:{}})})});return i.unref(),{pid:a,exited:o}}function A(e,t,n={}){let r=P(e),i=j(),a=d(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??[`ignore`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});i.emitBackgroundSpawn(e,t);let o=``,s=``,c=n.captureOutput??!0,l=Q(a,n);return c&&(a.stdout?.setEncoding(`utf8`),a.stderr?.setEncoding(`utf8`),a.stdout?.on(`data`,e=>{o+=e}),a.stderr?.on(`data`,e=>{s+=e})),{child:a,wait:new Promise((c,u)=>{a.on(`error`,n=>{l.dispose(),i.emitBackgroundCompletion(e,t,`error`),u(U(l,r,e,t,n))}),a.on(`close`,a=>{l.dispose(),i.emitBackgroundCompletion(e,t,`exit`);let d=a??1,f=W(l,r,e,t,d,n.allowFailure,o,s);if(f){u(f);return}c({stdout:o,stderr:s,exitCode:d})})})}}function j(){let e=r(),t=e.debug===!0,i=n(process.env.AGENT_DEVICE_EXEC_TRACE??``)===!0;if(!t&&!i)return M();i&&e.flushOnSuccess!==!0&&a({flushOnSuccess:!0});let o=Date.now(),s=!1;return{emitForegroundCompletion:(e,t)=>{s||(s=!0,N({cmd:e,args:t,startedAtMs:o}))},emitBackgroundSpawn:(e,t)=>{N({cmd:e,args:t,data:{event:`spawn`}})},emitBackgroundCompletion:(e,t,n)=>{s||(s=!0,N({cmd:e,args:t,startedAtMs:o,data:{event:n}}))}}}function M(){return{emitForegroundCompletion:()=>{},emitBackgroundSpawn:()=>{},emitBackgroundCompletion:()=>{}}}function N(e){let t=e.args.slice(0,6);i({level:`debug`,phase:`exec_command`,durationMs:e.startedAtMs===void 0?void 0:Math.max(0,Date.now()-e.startedAtMs),data:{command:e.cmd,argsPrefix:t,...e.args.length>t.length?{omittedArgCount:e.args.length-t.length}:{},...e.data??{}}})}function P(e){let n=K(e);if(!n)throw new t(`INVALID_ARGS`,`Invalid executable command: ${JSON.stringify(e)}`,{cmd:e,hint:`Use a bare command name from PATH or an absolute executable path.`});return n}function F(e,t,n,r){return r.code===`ENOENT`?I(e,t,r):L(e,t,n,r)}function I(e,n,r){return new t(`TOOL_MISSING`,`${e} not found in PATH`,{cmd:n},r)}function L(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to run ${e}`,{cmd:n,args:r},i)}function ee(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to write stdin for ${e}`,{cmd:n,args:r},i instanceof Error?i:void 0)}function R(t,n,r){return e({cmd:n,args:r,executable:t})}function z(e,n,r,i,a,o,s){return new t(`COMMAND_FAILED`,`${e} timed out after ${i}ms`,{cmd:n,args:r,stdout:o,stderr:s,exitCode:a,timeoutMs:i})}function B(e,n,r,i,a,o){return new t(`COMMAND_FAILED`,`${e} exited with code ${i}`,H({stdout:a,stderr:o,exitCode:i},{cmd:n,args:r}))}function V(e,n,r){if(e.exitCode===0)return e;throw new t(`COMMAND_FAILED`,n,H(e,typeof r==`function`?r(e):r))}function H(e,t){return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,processExitError:!0,...t}}function U(e,t,n,r,i){return e.didAbort?R(t,n,r):F(t,n,r,i)}function W(e,t,n,r,i,a,o,s){return e.didAbort?R(t,n,r):i!==0&&!a?B(t,n,r,i,o,s):null}function G(e,n,r){let i=e?.trim();if(i){if(!o.isAbsolute(i)||i.includes(`\0`))throw new t(`INVALID_ARGS`,`${n} must be an absolute ${r} path, not ${JSON.stringify(e)}`,{envName:n,path:e});return i}}function K(e){let t=e.trim();return!t||t.includes(`\0`)?null:o.isAbsolute(t)?t:t.includes(`/`)||t.includes(`\\`)?null:h.test(t)?t:null}function q(){if(process.platform!==`win32`)return[``];let e=process.env.PATHEXT;if(!e)return g;let t=e.split(`;`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);return t.length>0?t:g}function J(e,t){if(process.platform!==`win32`)return[e];let n=e.toLowerCase();return t.some(e=>n.endsWith(e))?[e]:t.map(t=>`${e}${t}`)}async function Y(e){try{return await X(e)?(await l(e,process.platform===`win32`?s.F_OK:s.X_OK),!0):!1}catch{return!1}}async function X(e){try{return(await u(e)).isFile()}catch{return!1}}function Z(e){if(!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t}function Q(e,t){let n=!1,r=()=>{n=!0,$(e,t.detached)};return t.signal?.aborted?r():t.signal?.addEventListener(`abort`,r,{once:!0}),{get didAbort(){return n},dispose:()=>{t.signal?.removeEventListener(`abort`,r)}}}function $(e,t){if(t&&e.pid&&process.platform!==`win32`)try{process.kill(-e.pid,`SIGKILL`);return}catch{}e.kill(`SIGKILL`)}async function te(e,t){if(e.stdin){if(t===void 0){e.stdin?.end();return}await m(p.from([t]),e.stdin)}}function ne(e){return e instanceof Error&&`code`in e&&e.code===`EPIPE`}export{T as a,A as c,x as d,D as f,y as h,V as i,O as l,v as m,H as n,E as o,w as p,Y as r,b as s,S as t,k as u};
|
package/dist/src/file.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{D as t,t as n}from"./owner-identity.js";import{t as r}from"./timeouts.js";import i from"node:path";import a from"node:fs";async function o(t){let{lockDirPath:n,owner:o}=t,l=i.join(n,`owner.json`),d=Date.now()+(t.timeoutMs??3e4),f=t.pollMs??100,p=t.ownerGraceMs??5e3,m=t.description??`process lock`;for(a.mkdirSync(i.dirname(n),{recursive:!0});Date.now()<d;)try{a.mkdirSync(n),s(l,o);let e=!1;return async()=>{e||(e=!0,a.rmSync(n,{recursive:!0,force:!0}))}}catch(e){let t=e;if(t.code!==`EEXIST`)throw t;if(c(n,l,p))continue;await r(f)}throw new e(`COMMAND_FAILED`,`Timed out waiting for ${m}`,{lockDirPath:n,...u(n,l)})}function s(e,n){t({destination:e,contents:JSON.stringify(n)})}function c(e,t,n){let r=null;try{r=a.statSync(e)}catch{return!0}let i=l(t);return i?!d(i)&&(a.rmSync(e,{recursive:!0,force:!0}),!0):Date.now()-r.mtimeMs<n?!1:(a.rmSync(e,{recursive:!0,force:!0}),!0)}function l(e){try{return JSON.parse(a.readFileSync(e,`utf8`))}catch{return null}}function u(e,t){let r=Date.now(),i=l(t),o;try{o=Math.max(0,Math.round(r-a.statSync(e).mtimeMs))}catch{}return{...o===void 0?{}:{lockAgeMs:o},...i?{ownerPid:i.pid,ownerStartTime:i.startTime,ownerAgeMs:Math.max(0,Math.round(r-i.acquiredAtMs)),ownerLiveness:n({owner:i})}:{}}}function d(e){let t=n({owner:e});return t!==`owner-process-dead`&&t!==`owner-process-reused`}export{o as t};
|
package/dist/src/find.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e}from"./sdk-contracts.js";import{Dn as t,Mn as n,On as r,Pt as i,kn as a,mt as o}from"./sdk-batch.js";import{c as s}from"./session-store.js";import{f as c,g as l,h as u,m as d,y as f}from"./runtime.js";import{n as p,t as m}from"./success-text.js";import{d as h}from"./app-inventory-contract.js";import{a as g,i as _}from"./request-runtime-binding.js";import{C as v,b as y,y as b}from"./session-snapshot.js";import{t as x}from"./snapshot-quality-verdict.js";import{t as S}from"./internal/daemon.js";import{t as C}from"./snapshot-runtime-binding.js";import{l as w,n as T,u as E}from"./selector-runtime.js";import{t as D}from"./type-text-runtime.js";function O(t,n){let r=n[0]?.rect;if(!r)return t;let i=t.filter(t=>{if(!t.rect)return!1;let n=e(t.rect);return n.x>=r.x&&n.x<=r.x+r.width&&n.y>=r.y&&n.y<=r.y+r.height}),a=i.length>0?i:t;return a.length<2?a:k(a,n,u(n))}function k(e,t,n){return e.map((e,r)=>({node:e,index:r,score:A(e,t,n)})).sort((e,t)=>t.score===e.score?M(e.node)-M(t.node)||e.index-t.index:t.score-e.score).map(e=>e.node)}function A(e,t,n){let r=n(e);if(r.reason===`covered`)return 0;let i=j(r,t[0]);return i>0?i:e.hittable&&e.rect&&!l(e,t[0])?3:+!!e.rect}function j(e,t){return e.node.rect?e.reason===`semantic-target`||e.reason===`same-rect-descendant`?4:e.reason===`hittable-ancestor`&&!l(e.node,t)?2:0:0}function M(e){return e.rect?e.rect.width*e.rect.height:1/0}function N(e,t,n){let r={matches:e.length,candidates:e.slice(0,5).map(e=>h(e,0,!1))};return _(`AMBIGUOUS_MATCH`,`find matched ${e.length} elements for ${t} "${n}". Use a more specific locator or selector.`,{locator:t,query:n,...r})}function P(e){if(e.ambiguity!==`reject-candidates`)throw Error(`find's resolution policy must reject candidates, got "${e.ambiguity}"`)}function F(e){let{nodes:t,locator:n,query:i,selectorExpression:a,flags:o,platform:s}=e,u=f.findAct,d=t.filter(e=>!l(e,t[0])),p=u.resolution,m;if(m=a?c(u,d,a,{platform:s}).list?.matchedNodes??[]:r(d,n,i,{requireRect:p.requireRect}).matches,m=O(m,t),m.length>1){P(p);let e=I(m,o);if(!e)return{ok:!1,response:N(m,n,i)};m=e}let h=m[0]??null;return h?{ok:!0,node:h}:{ok:!1,response:_(`COMMAND_FAILED`,`find did not match any element`)}}function I(e,t){return t?.findFirst?[e[0]]:t?.findLast?[e.at(-1)]:null}function L(e){let{device:t,session:n,req:r,logPath:i,locator:a,query:o,sessionStore:s,sessionName:c}=e,l=w({device:t,session:n,sessionStore:s,sessionName:c,req:r,logPath:i,capture:e.capture});return async()=>{let{snapshot:e}=await l.capture({flags:{...r.flags,snapshotInteractiveOnly:!0},recovery:{legacyIosSparse:{query:o,shouldScope:z(a)},sparseVerdictQueryScope:{query:o,shouldScope:z(a)}}});return{nodes:e.nodes,snapshotQuality:e.snapshotQuality,systemSurfaceOnly:e.systemSurfaceOnly}}}function R(e){return _(`COMMAND_FAILED`,`find could not read the current accessibility tree`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth, navigate with coordinates if needed, then retry find after reaching a readable screen.`})}function z(e){return e!==`role`}async function B(e){let{req:r,sessionName:s,logPath:c,sessionStore:l,invoke:u}=e,p=r.command;if(p!==`find`)return null;let m=r.positionals??[],h=t(m,r.flags);if(!h.ok)return _(h.code,h.message);let{locator:v,query:y,action:b,value:S}=h.parsed;if(r.flags?.record&&!a(b))return _(`INVALID_ARGS`,`find ${b} is a mutating action and is always recorded; --record only applies to a read-only find (exists, wait, list, get text, get attrs).`);let w=await T({req:r,sessionName:s,logPath:c,sessionStore:l,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(w)return w;let D=l.get(s);if(!D)return g();let O=D.device,k=await C({command:`find`,device:O,session:D,plan:i({hasActiveApp:D.appBundleId!==void 0,intent:o(b)}),inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(!k.ok)return k.response;let A=n(v,y),j=L({device:O,session:D,req:r,logPath:c,locator:v,query:y,sessionStore:l,sessionName:s,capture:k.capture}),M={req:r,sessionName:s,logPath:c,sessionStore:l,invoke:u,session:D,device:O,command:p,locator:v,query:y,publicFlags:X(r.flags),boundFocusPoint:k.focusPoint,boundTypeText:k.typeText},N=await j();if(x(N.snapshotQuality))return R(N.snapshotQuality);let{nodes:P}=N,I=F({nodes:P,locator:v,query:y,selectorExpression:A,flags:r.flags,platform:O.platform});if(!I.ok)return E(I.response,N);let z=I.node,B=await d(f.findAct,P,z),H=B.node,U=await V(M,{node:z,resolvedNode:H,ref:`@${H.ref}`,nodes:P,actionFlags:{...r.flags??{},noRecord:!0},...B.kind===`occluded`?{occludedNode:B.node}:{}},b,S);return U&&E(U,N)}async function V(e,t,n,r){let i={click:()=>U(e,t),fill:()=>W(e,t,r),focus:()=>G(e,t),type:()=>K(e,t,r)}[n];return i?await i():null}function H(e){return{ref:e.ref,node:e.resolvedNode,nodes:e.nodes}}async function U(t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:c,command:l,locator:u,query:d,publicFlags:f}=t,h=await c({token:r.token,session:i,command:`click`,positionals:[n.ref],flags:n.actionFlags,internal:{findResolvedTarget:H(n)}});if(!h.ok)return h;let g=n.resolvedNode.rect?e(n.resolvedNode.rect):n.node.rect?e(n.node.rect):null,_={ref:n.ref,locator:u,query:d};g&&(_.x=g.x,_.y=g.y);let v=m(h.data)??`Tapped ${n.ref}${g?` (${g.x}, ${g.y})`:``}`;return Object.assign(_,p(v)),s(a,o,r,l,{ref:n.ref,action:`click`,locator:u,query:d},{flags:f}),{ok:!0,data:_}}async function W(e,t,n){let{req:r,sessionName:i,sessionStore:a,session:o,invoke:c,command:l,publicFlags:u}=e;if(n===void 0)return _(`INVALID_ARGS`,`find fill requires text (use "" to clear the field)`);let d=await c({token:r.token,session:i,command:`fill`,positionals:[t.ref,n],flags:t.actionFlags,internal:{findResolvedTarget:H(t)}});return d.ok&&s(a,o,r,l,{ref:t.ref,action:`fill`},{flags:u}),d}async function G(e,t){let n=await q(e,t);return n.ok&&Y(e,t,`focus`),n}async function K(e,t,n){let{req:r,logPath:i,session:a}=e;if(!n)return _(`INVALID_ARGS`,`find type requires text`);let o=await q(e,t);if(!o.ok)return o;v(a);let s=e.boundTypeText;if(!s)return _(`COMMAND_FAILED`,`find type was admitted without a text-entry operation`);let c=await D({operations:{typeText:s}},[n],y(i,r.flags,a.appBundleId,a.trace?.outPath));return Y(e,t,`type`),{ok:!0,data:c??{ref:t.ref}}}async function q(t,n){let{req:r,logPath:i,session:a}=t,o=J(n,`be focused`);if(o)return o;let s=n.resolvedNode.rect?e(n.resolvedNode.rect):null;if(!s)return _(`COMMAND_FAILED`,`matched element has no bounds`);v(a);let c=t.boundFocusPoint;return c?{ok:!0,data:await S({operations:{focusPoint:c}},s,y(i,r.flags,a.appBundleId,a.trace?.outPath))??{ref:n.ref}}:_(`COMMAND_FAILED`,`find focus was admitted without a focus operation`)}function J(e,t){let n=e.occludedNode;return n?_(`COMMAND_FAILED`,`Matched element ${e.ref} is covered by another visible element and cannot ${t} safely`,{ref:`@${n.ref}`,interactionBlocked:n.interactionBlocked,hint:`Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.`}):null}function Y(e,t,n){let{req:r,sessionStore:i,session:a,command:o,publicFlags:c}=e;s(i,a,r,o,{ref:t.ref,action:n},{flags:c})}function X(e){return{...b(e)??{}}}export{B as handleFindCommands};
|
package/dist/src/finders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jn as e}from"./sdk-batch.js";import{t}from"./sdk-finders.js";export{t as findBestMatchesByLocator,e as parseFindArgs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{t}from"./script.js";import n from"node:path";function r(e){return e.startsWith(`AD_`)}function i(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function a(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let n=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of n)if(e)for(let[n,a]of Object.entries(e)){if(r(n))throw i(n);t[n]=a}return{values:t,expandedBuiltinNames:new Set}}function o(e){let n={};for(let[i,a]of Object.entries(e)){if(typeof a!=`string`||!i.startsWith(`AD_VAR_`))continue;let e=i.slice(7);e.length!==0&&t.test(e)&&(r(e)||(n[e]=a))}return n}function s(n){let a={};for(let o of n){let n=o.indexOf(`=`);if(n<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${o}": expected KEY=VALUE.`);let s=o.slice(0,n);if(!t.test(s))throw new e(`INVALID_ARGS`,`Invalid -e key "${s}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(r(s))throw i(s);a[s]=o.slice(n+1)}return a}function c(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function l(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return process.env}function u(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e===`_`}function d(e){return u(e)||e>=`0`&&e<=`9`||e===`.`}function f(e){return e===`
|
|
2
|
+
`||e===`\r`||e===`\u2028`||e===`\u2029`}function p(e,t){let n=t+2;if(n>=e.length||!u(e[n]))return null;for(n+=1;n<e.length&&d(e[n]);)n+=1;let r=e.slice(t+2,n);if(e[n]===`}`)return{key:r,fallback:void 0,end:n+1};if(e[n]!==`:`||e[n+1]!==`-`)return null;n+=2;let i=``;for(;n<e.length;){let t=e[n];if(t===`}`)return{key:r,fallback:i,end:n+1};if(t===`\\`){let t=e[n+1];if(t===void 0)return{abortEnd:e.length};if(f(t))return{abortEnd:n+2};i+=t,n+=2;continue}i+=t,n+=1}return{abortEnd:e.length}}function m(t,n,i){let a=``,o=0;for(;o<t.length;){let s=t[o];if(s===`\\`&&t.startsWith("${",o+1)){a+="${",o+=3;continue}if(s===`$`&&t[o+1]===`{`){let s=p(t,o);if(s!==null&&`abortEnd`in s){a+=t.slice(o,s.abortEnd),o=s.abortEnd;continue}if(s!==null){let{key:t,fallback:c}=s;if(Object.prototype.hasOwnProperty.call(n.values,t))r(t)&&(n.expandedBuiltinNames??=new Set).add(t),a+=String(n.values[t]);else if(c!==void 0)a+=c;else throw new e(`INVALID_ARGS`,`Unresolved variable \${${t}} at ${i.file}:${i.line}.`);o=s.end;continue}}a+=s,o+=1}return a}function h(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>m(e,t,n)),flags:g(e.flags,t,n)??{},runtime:g(e.runtime,t,n)}}function g(e,t,n){return e&&_(e,t,n)}function _(e,t,n){return typeof e==`string`?m(e,t,n):Array.isArray(e)?e.map(e=>_(e,t,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,_(r,t,n)])):e}function v(e){return Object.entries(e.values).filter(([t,n])=>n.length>0&&(!r(t)||e.expandedBuiltinNames?.has(t))).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value.length-e.value.length)}function y(e){let t=n.extname(e).toLowerCase();return t===`.yaml`||t===`.yml`}function b(e,t){return`Maestro YAML requires explicit --maestro routing: ${e} ${t} --maestro`}function x(e,t){return t===`maestro`&&y(e)?`maestro`:`ad`}export{v as a,c,a as i,l,b as n,o,x as r,s,y as t,h as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{f as e}from"./sdk-batch.js";import{t}from"./session-snapshot.js";import{i as n,r}from"./interaction-ref-policy.js";import{captureSnapshotForSession as i,createInteractionRuntime as a}from"./interaction.js";function o(t){if(!e(t.command))return{};let i=n(t.command,t.flags);if(i)return{response:i};let a=r(t.flags);if(!a)return{};let o=t.session.snapshot?.nodes??[];return{observe:async()=>await s(t,a,o)}}async function s(e,n,r){let i=c(e);if(!i)return;let a=await i.interactions.settleObservation({...n,baselineNodes:r,session:e.sessionName,requestId:e.req.meta?.requestId}),o=t(e.session,a);return o===void 0?a:{...a,refsGeneration:o}}function c(e){try{return a({req:e.req,sessionName:e.sessionName,logPath:e.logPath,sessionStore:e.sessionStore,contextFromFlags:e.contextFromFlags,captureSnapshotForSession:i})}catch{return}}export{o as planGenericSettleObservation};
|
package/dist/src/generic.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{a as e}from"./sdk-contracts.js";import{t}from"./success-text.js";import{t as n}from"./shared.js";import{n as r}from"./cli-runner.js";async function i({command:t,positionals:i,flags:s,client:c,debug:l,replayTestReporterRuntime:u,commandProgress:d}){let{result:f,cliOutput:p}=await r({client:c,command:t,positionals:i,flags:s,commandProgress:d});if(e(s.responseLevel))return await n(s,f,()=>JSON.stringify(f,null,2)),!0;if(p)await o(s,p);else{let e=await a(t,s,f,{debug:l,replayTestReporterRuntime:u});e!==0&&process.exit(e)}return!0}async function a(e,r,i,a={}){return e===`test`?import(`./reporting.js`).then(({renderReplayTestResponse:e})=>e({suite:i,debug:a.debug,verbose:r.verbose,json:r.json,reporter:r.reporter,reportJunit:r.reportJunit,reporterRuntime:a.replayTestReporterRuntime})):(await n(r,i,()=>t(i)),0)}async function o(e,t){!e.json&&t.stderr&&process.stderr.write(t.stderr),await n(e,e.json?t.jsonData??t.data:t.data,()=>t.text)}export{i as runGenericClientBackedCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,c as t}from"./sdk-device.js";const n={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},r=`Target-authored drag requires an adapter that preserves source hold, timed movement, and destination hold; it is supported on Android touch devices and iOS/iPadOS.`,i=`Android TV has no touch input — this gesture is supported on Android phones, tablets, and the iOS simulator only.`,a=`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`;function o(e,t){return(t===`multi-touch`?s(e):t===`directional-fling`&&e.platform===`linux`?`Linux`:void 0)??e.appleOs??e.platform}function s(r){if(r.platform===`android`)return r.target===`tv`?`Android TV`:void 0;if(!t(r.platform))return;let i=e(r);if(i===`ios`||i===`ipados`)return`physical iOS devices`;if(i===`macos`||i===`tvos`||i===`visionos`)return n[i]}function c(e,t,n){return`gesture ${n} is not supported on ${o(e,t)}`}export{c as a,r as i,n,a as r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=1e4;export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{d as t,u as n}from"./scroll-gesture.js";import{t as r}from"./gesture-plan-types.js";const i={pinchAxisDegrees:-90,samplingProfile:`default`},a={ios:i,macos:i,android:{pinchAxisDegrees:0,samplingProfile:`android`},harmonyos:i,vega:i,linux:i,web:i};function o(e,t,n){let r=b(t),i=N(n);switch(e.intent){case`fling`:return u(e,r);case`pan`:return d(e,r,i);case`pinch`:return p({intent:`pinch`,origin:e.origin??k(r),delta:{x:0,y:0},scale:D(e.scale,`gesture pinch scale`),rotationDegrees:0,durationMs:300},r,i);case`rotate`:{let t=E(e.degrees,`gesture rotate degrees`);return p({intent:`rotate`,origin:e.origin??k(r),delta:{x:0,y:0},scale:1,rotationDegrees:t,durationMs:w(t)},r,i)}case`transform`:{let t=E(e.degrees,`gesture transform degrees`);return p({intent:`transform`,origin:e.origin,delta:e.delta,scale:D(e.scale,`gesture transform scale`),rotationDegrees:t,durationMs:x(e.durationMs,w(t),`gesture transform durationMs`)},r,i)}}}function s(e){let[{samples:t}]=e.pointers,n=t[0],r=t.at(-1);return{start:n.point,end:r.point}}function c(t,n){let i=b(n),a=S(t.sourceHoldMs,800,`gesture drag sourceHoldMs`),o=x(t.moveMs,500,`gesture drag moveMs`),s=C(t.destinationHoldMs,0,`gesture drag destinationHoldMs`);if(a+o+s>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${r}`);return l(f(`pan`,t.from,t.to,o,i,`timed-pan`),a,s)}function l(e,t,n){let r=e.pointers[0],[i,a]=r.samples,o=t+e.durationMs+n,s=[{offsetMs:0,point:i.point},{...i,offsetMs:i.offsetMs+t},{...a,offsetMs:a.offsetMs+t},...n>0?[{offsetMs:o,point:a.point}]:[]];return{...e,durationMs:o,pointers:[{...r,samples:s}]}}function u(e,n){if(`preset`in e){let{from:t,to:r}=M(e.preset,n);return f(`fling`,t,r,100,n,`endpoint-hold`)}if(`from`in e)return f(`fling`,e.from,e.to,100,n,`endpoint-hold`);let r=T(e.origin,`gesture fling origin`),i=O(e.distance??180,`gesture fling distance`);return f(`fling`,r,A(r,t(e.direction,i)),100,n,`endpoint-hold`)}function d(t,n,r){let i=x(t.durationMs,500,`gesture pan durationMs`);if((t.pointerCount??1)===1){let e=T(t.origin,`gesture pan origin`);return f(`pan`,e,A(e,T(t.delta,`gesture pan delta`)),i,n,t.executionProfile??`timed-pan`)}if(t.pointerCount!==2)throw new e(`INVALID_ARGS`,`gesture pan pointerCount must be 1 or 2`);return p({intent:`pan`,origin:t.origin,delta:t.delta,scale:1,rotationDegrees:0,durationMs:i},n,r)}function f(e,t,n,r,i,a){let o=T(t,`gesture ${e} start`),s=T(n,`gesture ${e} end`),c=[{offsetMs:0,point:o},{offsetMs:r,point:s}];return v(c,i,{intent:e,pointerId:0}),{topology:`single`,intent:e,executionProfile:a,durationMs:r,viewport:i,pointers:[{pointerId:0,samples:c}]}}function p(e,t,n){let r=T(e.origin,`gesture ${e.intent} origin`),i=A(r,T(e.delta,`gesture ${e.intent} delta`)),a=Math.min(t.width,t.height)*g(e.intent),o=e.scale>1?a/e.scale:a,s=o*e.scale;if(Math.min(o,s)<48)throw y({intent:e.intent,viewport:t,initialSpan:o,finalSpan:s,minimumReliableSpan:48});let c=o/2,l=_(e.durationMs,n.samplingProfile),u=(a,o)=>{let s=l.map(t=>({offsetMs:t,point:m({...e,start:r,end:i,initialRadius:c,offsetMs:t,side:o,profile:n})}));return v(s,t,{intent:e.intent,pointerId:a}),{pointerId:a,samples:s}};return{topology:`two`,intent:e.intent,durationMs:e.durationMs,viewport:t,pointers:[u(0,1),u(1,-1)]}}function m(e){let t=e.offsetMs/e.durationMs,n=j(e.start,e.end,t),r=e.initialRadius*(1+(e.scale-1)*t),i=P(h(e.intent,e.profile)+e.rotationDegrees*t);return{x:n.x+Math.cos(i)*r*e.side,y:n.y+Math.sin(i)*r*e.side}}function h(e,t){return e===`pinch`?t.pinchAxisDegrees:-90}function g(e){return e===`pinch`?.4:.25}function _(t,n){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`gesture sample duration must be a positive finite number`);let r=t/16,i=Math.max(3,n===`android`?Math.round(r):Math.floor(r));return Array.from({length:i+1},(e,n)=>Math.round(t*n/i))}function v(t,n,r){let i=n.x+n.width-1,a=n.y+n.height-1;for(let o of t){let{x:t,y:s}=o.point;if(!Number.isFinite(t)||!Number.isFinite(s))throw new e(`INVALID_ARGS`,`Gesture motion produces non-finite pointer coordinates`,{...r,reason:`GESTURE_TRAJECTORY_NON_FINITE`,hint:`Reduce the requested rotation, translation, or scale.`});if(t<n.x+1||t>i||s<n.y+1||s>a)throw y({...r,viewport:n,sample:o})}}function y(t){return new e(`INVALID_ARGS`,`Gesture trajectory does not fit inside the viewport`,{...t,reason:`GESTURE_TRAJECTORY_OUT_OF_BOUNDS`,hint:`Move the gesture away from the edge or reduce its translation, scale, or rotation.`})}function b(t){let n={x:E(t.x,`gesture viewport x`),y:E(t.y,`gesture viewport y`),width:E(t.width,`gesture viewport width`),height:E(t.height,`gesture viewport height`)};if(n.width<=0||n.height<=0)throw new e(`INVALID_ARGS`,`gesture viewport width and height must be positive`);return n}function x(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<16||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 16 and ${r}`);return a}function S(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<1||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 1 and ${r}`);return a}function C(t,n,i){let a=t??n;if(!Number.isInteger(a)||a<0||a>1e4)throw new e(`INVALID_ARGS`,`${i} must be an integer between 0 and ${r}`);return a}function w(e){let t=Math.ceil(Math.abs(e)/3)*16;return Math.min(Math.max(300,t),2400)}function T(e,t){return{x:E(e.x,`${t} x`),y:E(e.y,`${t} y`)}}function E(t,n){if(!Number.isFinite(t))throw new e(`INVALID_ARGS`,`${n} must be a finite number`);return t}function D(t,n){let r=E(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be greater than 0`);return r}function O(t,n){let r=E(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be a positive number`);return r}function k(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function A(e,t){return{x:e.x+t.x,y:e.y+t.y}}function j(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function M(e,t){let r=n(e,{referenceWidth:t.width,referenceHeight:t.height});return{from:{x:t.x+r.x1,y:t.y+r.y1},to:{x:t.x+r.x2,y:t.y+r.y2}}}function N(e){return e===void 0?i:a[e]}function P(e){return e*Math.PI/180}export{s as a,_ as i,o as n,j as r,c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as e,y as t}from"./sdk-contracts.js";import{gt as n,jt as r}from"./sdk-batch.js";import{h as i,m as a,p as o}from"./session-snapshot.js";import{a as s}from"./gesture-admission.js";async function c(e){let t=await i({command:`runtime gesture-viewport`,device:e.device,use:n,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return t.type===`response`?{ok:!1,response:t.response}:{ok:!0,read:d(t.runtime).gestureViewport}}async function l(n){let i=r(n.input),o=await a({command:`gesture`,device:n.device,required:i.use.required,inspectFacts:n.inspectFacts,bindDevice:n.bindDevice,unavailableResponse:r=>({ok:!1,error:e(new t(`UNSUPPORTED_OPERATION`,s(n.device,i.tier,n.input.intent),{gesture:n.input.intent,...r.hint===void 0?{}:{hint:r.hint}}))})});return o.type===`response`?{ok:!1,response:o.response}:{ok:!0,gestures:await u(o.bind,n.device,i)}}async function u(e,t,n){switch(n.tier){case`plan`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performGesturePlan(f(e,t)),...d(r)}}case`directional-fling`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performDirectionalFlingPlan(f(e,t)),...d(r)}}case`multi-touch`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performMultiTouchGesturePlan(f(e,t)),...d(r)}}case`target-authored-drag`:{let r=await e(t,n.use);return{performPlan:async(e,t)=>await r.operations.performTargetAuthoredDrag(f(e,t)),...d(r)}}}}function d(e){let{gestureViewport:t}=e.operations,n=e.operations.captureSnapshot?{operations:{captureSnapshot:e.operations.captureSnapshot}}:void 0,r=t?{operations:{gestureViewport:t}}:void 0;return Object.freeze({...n?{captureSnapshot:async e=>await n.operations.captureSnapshot(e)}:{},...r?{gestureViewport:async e=>await r.operations.gestureViewport(p(e))}:{}})}function f(e,t){return{plan:e,...t.appBundleId===void 0?{}:{options:{appBundleId:t.appBundleId}},execution:o(t)}}function p(e){return{...e.appBundleId===void 0?{}:{options:{appBundleId:e.appBundleId}},execution:o(e)}}export{c as n,l as t};
|
package/dist/src/harmonyos.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{c as t}from"./diagnostics.js";import"./diagnostics2.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,x as v,y}from"./src3.js";function b(b,x){let S=t=>async()=>{throw new e(`UNSUPPORTED_OPERATION`,`${t} is not supported on HarmonyOS`)};return{open:(e,t)=>l(b,e,{activity:t?.activity}),openDevice:()=>m(b),close:e=>p(b,e),tap:(e,t)=>a(b,e,t),doubleTap:(e,t)=>r(b,e,t),longPress:(e,t,n)=>i(b,e,t,n),focus:(e,t)=>a(b,e,t),type:(e,t)=>v(b,e,t),fill:(e,t,n,r)=>d(b,e,t,n,r),scroll:(e,t)=>s(b,e,t),performGesture:e=>g(b,e),gestureViewport:()=>f(b),screenshot:e=>c(b,e),snapshot:async e=>({...await t(`snapshot_capture`,async()=>await y(b,e),{backend:`harmonyos-arkui`}),backend:`harmonyos-arkui`,producer:`harmonyos-uitest`}),back:()=>u(b),home:()=>m(b),setOrientation:e=>n(b,e),appSwitcher:()=>h(b),tvRemote:S(`tv-remote`),keyboardDismiss:async()=>(await o(b,`Back`),{kind:`acknowledged`}),keyboardEnter:async()=>(await o(b,`Enter`),{kind:`harmonyos-acknowledged`}),readClipboard:S(`clipboard`),writeClipboard:S(`clipboard`),setSetting:(e,t,n)=>_(b,e,t,n),readAlert:S(`alert`),awaitAlert:S(`alert`),acceptAlert:S(`alert`),dismissAlert:S(`alert`)}}export{b as createHarmonyInteractor};
|
package/dist/src/hdc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e}from"./owner-identity.js";import{r as t,s as n}from"./exec.js";import"./command.js";import"./process.js";import r from"node:path";async function i(e,t,r){return await n(`hdc`,[`-t`,e.id,...t],{timeoutMs:15e3,...r})}async function a(n=e()){let i=[n.HDC_SDK_PATH,n.DEVECO_SDK_HOME?r.join(n.DEVECO_SDK_HOME,`default`,`openharmony`,`toolchains`):void 0,n.HARMONYOS_COMMAND_LINE_TOOLS?r.join(n.HARMONYOS_COMMAND_LINE_TOOLS,`sdk`,`default`,`openharmony`,`toolchains`):void 0].filter(e=>!!e?.trim()),a=[];for(let e of i)await t(r.join(e,`hdc`))&&a.push(e);if(a.length===0)return;let o=(n.PATH??``).split(r.delimiter).filter(Boolean);n.PATH=[...new Set([...a,...o])].join(r.delimiter)}export{a as ensureHarmonyToolchainPathConfigured,i as runHarmonyHdc};
|
package/dist/src/helper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),await
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{y as t}from"./sdk-contracts.js";import{T as n,_ as r,d as i}from"./owner-identity.js";import{a,c as o}from"./exec.js";import"./command.js";import"./process.js";import{D as s,c,f as l,g as u,h as d,n as f,o as p,r as m,t as h,w as g,y as _}from"./host-file.js";import{a as v,i as y,n as b}from"./tool-provider.js";import x from"node:path";import{createHash as S}from"node:crypto";import{fileURLToPath as C}from"node:url";var w=e({quitMacOsApp:()=>W,resolveFrontmostMacOsApp:()=>U,resolveMacOsHelperPackageRootFrom:()=>M,runMacOsAlertAction:()=>K,runMacOsPermissionAction:()=>G,runMacOsPressAction:()=>Y,runMacOsReadTextAction:()=>J,runMacOsScreenshotAction:()=>X,runMacOsSnapshotAction:()=>q,startMacOsAudioProbeProcess:()=>V});const T=`agent-device-macos-helper`,E=`AGENT_DEVICE_MACOS_HELPER_BIN`,D=x.join(l(),`.agent-device`,`macos-helper`,`current`),O=x.join(D,`manifest.json`),k=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;function A(e){let n=e.trim();if(!k.test(n))throw new t(`INVALID_ARGS`,`macOS bundle id must use reverse-DNS form like com.example.App`,{bundleId:e});return n}function j(e,t){t.bundleId&&e.push(`--bundle-id`,A(t.bundleId)),t.surface&&e.push(`--surface`,t.surface)}function M(e){let n=x.dirname(e);for(;;){let e=x.join(n,`apple`,`macos-helper`);if(c(x.join(e,`Package.swift`)))return e;let t=x.dirname(n);if(t===n)break;n=t}throw new t(`COMMAND_FAILED`,`Unable to locate macOS helper package root`,{modulePath:e})}function N(){return M(C(import.meta.url))}function P(){return x.join(N(),`.build`,`release`,T)}function F(){return x.join(D,T)}async function I(e){let t=await u(e,{withFileTypes:!0});return(await Promise.all(t.map(async t=>{let n=x.join(e,t.name);return t.isDirectory()?t.name===`.build`?[]:await I(n):!t.isFile()||!t.name.endsWith(`.swift`)&&t.name!==`Package.swift`?[]:[n]}))).flat().sort()}async function L(e){let t=await I(e),n=S(`sha256`);for(let r of t)n.update(x.relative(e,r)),n.update(`\0`),n.update(await d(r)),n.update(`\0`);let r=await v(`swift`,[`--version`],{allowFailure:!0,cwd:e,timeoutMs:1e4});return n.update(`swift-version`),n.update(`\0`),n.update(r.stdout||r.stderr||`exit:${r.exitCode}`),n.update(`\0`),n.digest(`hex`)}async function R(){try{let e=JSON.parse(await _(O));return typeof e.fingerprint==`string`?e.fingerprint:null}catch{return null}}async function z(){let e=await a(r(E),E);if(e)return e;let t=N(),i=await L(t),o=F();try{if(await R()===i)return await h(o),o}catch{}let c=P();n(`agent-device: building macOS helper (first run or helper update)
|
|
2
|
+
`),await v(`swift`,[`build`,`-c`,`release`,`--package-path`,t],{cwd:t,timeoutMs:12e4}),await p(D);let l=`${o}.tmp`;return await m(c,l),await g(l,o),await f(o,493),await s(O,`${JSON.stringify({fingerprint:i},null,2)}\n`),o}async function B(){let e=r(E)?.trim();if(e){let t=await a(e,E);if(t)return t}if(b())return T;if(i()!==`darwin`)throw new t(`UNSUPPORTED_PLATFORM`,`macOS helper is only available on macOS`);return await z()}async function V(e){let t=await B();return o(t,[`audio-probe`,`--duration-ms`,String(e.durationMs),`--bucket-ms`,String(e.bucketMs),`--out`,e.statusPath],{allowFailure:!0,captureOutput:!0})}async function H(e,n={}){let r={allowFailure:!0,timeoutMs:3e4,signal:n.signal},i=y().macosHelper,a=i?T:await B(),o=i?await i.run(e,r):await v(a,e,r),s=o.stdout.trim(),c=null;if(s)try{c=JSON.parse(s)}catch{c=null}if(o.exitCode===0&&c?.ok)return c.data;let l=c&&!c.ok?c.error?.message??`macOS helper exited with code ${o.exitCode}`:s||o.stderr.trim()||`macOS helper exited with code ${o.exitCode}`;throw new t(`COMMAND_FAILED`,l,{helperPath:a,args:e,stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,...c&&!c.ok?c.error?.details:{}})}async function U(){return await H([`app`,`frontmost`])}async function W(e){return await H([`app`,`quit`,`--bundle-id`,A(e)])}async function G(e,t){return await H([`permission`,e,t])}async function K(e,t={}){let n=[`alert`,e];return j(n,t),await H(n)}async function q(e,t={}){let n=[`snapshot`,`--surface`,e];return j(n,t),await H(n,{signal:t.signal})}async function J(e,t,n={}){let r=[`read`,`--x`,String(e),`--y`,String(t)];return j(r,n),await H(r)}async function Y(e,t,n={}){let r=[`press`,`--x`,String(e),`--y`,String(t)];return j(r,n),await H(r)}async function X(e,t={}){let n=[`screenshot`,`--out`,e];return j(n,t),t.fullscreen&&n.push(`--fullscreen`),await H(n)}export{G as a,K as i,W as n,X as o,U as r,V as s,w as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:path";import t from"node:fs";import n from"node:os";import r from"node:fs/promises";function i(){return n.homedir()}function a(){return n.tmpdir()}async function o(t){return await r.mkdtemp(e.join(a(),t))}async function s(e){await r.mkdir(e,{recursive:!0})}async function c(e,t={}){return await r.readFile(e,{encoding:`utf8`,signal:t.signal})}async function l(e,t={}){return await r.readFile(e,{signal:t.signal})}async function u(e,t={}){return t.withFileTypes===!0?await r.readdir(e,{withFileTypes:!0}):await r.readdir(e)}async function d(e){return await r.stat(e)}async function f(e,t){await r.writeFile(e,t,`utf8`)}async function p(e,t){await r.writeFile(e,t)}async function m(e){await r.rm(e,{recursive:!0,force:!0})}async function h(e){await r.unlink(e)}async function g(e,t){await r.copyFile(e,t)}async function _(e,t){await r.cp(e,t,{recursive:!0})}async function v(e,t){await r.rename(e,t)}async function y(e,t){await r.chmod(e,t)}async function b(e){await r.access(e)}async function x(e){await m(e)}function S(e){t.mkdirSync(e,{recursive:!0})}function C(e){return t.readFileSync(e,`utf8`)}function w(e,n){t.writeFileSync(e,n,`utf8`)}function T(e){return t.existsSync(e)}function E(e){return t.statSync(e)}function D(e){return t.lstatSync(e)}function O(e){return t.readlinkSync(e)}function k(e){t.unlinkSync(e)}function A(e,n){t.symlinkSync(e,n,`dir`)}function j(e){return t.readdirSync(e)}export{m as C,f as D,p as E,w as O,k as S,h as T,j as _,A as a,C as b,T as c,E as d,i as f,u as g,l as h,_ as i,D as l,o as m,y as n,s as o,a as p,g as r,S as s,b as t,d as u,O as v,v as w,x,c as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{t}from"./config.js";import n from"node:crypto";const r=`default`;function i(t){let n=Number.isInteger(t.defaultLeaseTtlMs)?Math.max(1,Number(t.defaultLeaseTtlMs)):6e4,r=Number.isInteger(t.minLeaseTtlMs)?Math.max(1,Number(t.minLeaseTtlMs)):5e3,i=Number.isInteger(t.maxLeaseTtlMs)?Math.max(r,Number(t.maxLeaseTtlMs)):6e5;return t=>{if(!Number.isInteger(t))return n;let a=Number(t);if(a<r||a>i)throw new e(`INVALID_ARGS`,`Lease ttlMs must be between ${r} and ${i}.`);return a}}function a(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}function o(e){if(!e)return;let t=e.trim();if(t&&/^[a-f0-9]{16,128}$/i.test(t))return t.toLowerCase()}function s(t){let n=o(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid lease id.`);return n}function c(t){let n=(t??``).trim().toLowerCase();if(!n||n===`ios-simulator`)return`ios-simulator`;if(n===`ios-instance`||n===`android-instance`||n===`harmonyos-instance`)return n;throw new e(`INVALID_ARGS`,`Unsupported lease backend: ${t??``}`)}function l(t){if(t===void 0)return;let n=t.trim();if(!n||n.length>256||!/^[\u0020-\u007E]+$/.test(n))throw new e(`INVALID_ARGS`,`Invalid device key. Use 1-256 printable characters.`);return n}function u(e){return f(e,`client id`,128)}function d(e){return f(e,`lease provider`,64)}function f(t,n,r){if(t===void 0)return;let i=t.trim();if(!i||i.length>r||!/^[a-zA-Z0-9._-]+$/.test(i))throw new e(`INVALID_ARGS`,`Invalid ${n}. Use 1-${String(r)} chars: letters, numbers, dot, underscore, hyphen.`);return i}function p(n){let r=t(n);if(!r)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return r}function m(t){let n=a(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function h(e){return{backend:c(e.leaseBackend),leaseProvider:d(e.leaseProvider),deviceKey:l(e.deviceKey),clientId:u(e.clientId),tenantId:p(e.tenantId),runId:m(e.runId),ttlMs:e.ttlMs}}function g(e){return!!(e.leaseProvider??e.deviceKey??e.clientId)}function _(e,t){return!t.tenantId||!t.runId?!1:[[e.leaseProvider,t.leaseProvider],[e.deviceKey,t.deviceKey],[e.clientId,t.clientId]].every(([e,t])=>!e||!!t)}function v(t,n){let r=b(n);if(r.tenantId&&t.tenantId!==r.tenantId||r.runId&&t.runId!==r.runId||r.leaseBackend&&t.backend!==r.leaseBackend||r.leaseProvider&&t.leaseProvider!==r.leaseProvider||r.deviceKey&&t.deviceKey!==r.deviceKey||r.clientId&&t.clientId!==r.clientId)throw new e(`UNAUTHORIZED`,`Lease does not match tenant/run scope`,{reason:`LEASE_SCOPE_MISMATCH`})}function y(n){let r=c(n.leaseBackend),i=t(n.tenantId);if(!i)throw new e(`INVALID_ARGS`,`tenant isolation requires tenant id.`);let s=a(n.runId);if(!s)throw new e(`INVALID_ARGS`,`tenant isolation requires run id.`);let l=o(n.leaseId);if(!l)throw new e(`INVALID_ARGS`,`tenant isolation requires lease id.`);return{...n,tenantId:i,runId:s,leaseId:l,leaseBackend:r}}function b(n){let r=t(n.tenantId),i=a(n.runId);if(n.tenantId&&!r)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(n.runId&&!i)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return{tenantId:r,runId:i,leaseBackend:n.leaseBackend?c(n.leaseBackend):void 0,leaseProvider:d(n.leaseProvider),deviceKey:l(n.deviceKey),clientId:u(n.clientId)}}function x(t,n){if(g(t)&&!_(t,n))throw new e(`UNAUTHORIZED`,`Lease owner scope is required`,{reason:`LEASE_SCOPE_REQUIRED`})}function S(e){if(e.deviceKey)return JSON.stringify([e.backend,e.leaseProvider??r,e.deviceKey])}function C(e){return JSON.stringify([e.tenantId,e.runId,e.backend,e.leaseProvider??r,e.deviceKey??`*`])}function w(e,t,r){return{leaseId:n.randomBytes(16).toString(`hex`),tenantId:e.tenantId,runId:e.runId,backend:e.backend,...e.leaseProvider?{leaseProvider:e.leaseProvider}:{},...e.deviceKey?{deviceKey:e.deviceKey}:{},...e.clientId?{clientId:e.clientId}:{},createdAt:r,heartbeatAt:r,expiresAt:r+t}}function T(t){return new e(`DEVICE_IN_USE`,`Device is already leased`,{reason:`DEVICE_LEASE_BUSY`,deviceKey:t.deviceKey,backend:t.backend,leaseProvider:t.leaseProvider,expiresAt:t.expiresAt,hint:`Retry after the lease expires or close the owning session.`})}const E=`/admin/human-control/holds`;function D(t){let n=k(t,`Human-control request body`),r=n.reason;if(r!==void 0&&(typeof r!=`string`||r.trim().length>512))throw new e(`INVALID_ARGS`,`Human-control reason must be at most 512 characters.`);let i=n.ttlMs;if(i!==void 0&&(typeof i!=`number`||!Number.isInteger(i)||i<1e3||i>864e5))throw new e(`INVALID_ARGS`,`Human-control ttlMs must be between 1000 and 86400000.`);return{...n.scope===void 0?{}:{scope:O(n.scope)},...typeof r==`string`&&r.trim()?{reason:r.trim()}:{},...typeof i==`number`?{ttlMs:i}:{}}}function O(t){let n=k(t,`Host human-control scope`);if(typeof n.backend!=`string`||!n.backend.trim()||typeof n.deviceKey!=`string`)throw new e(`INVALID_ARGS`,`Host human control requires scope.backend and scope.deviceKey.`);if(n.leaseProvider!==void 0&&typeof n.leaseProvider!=`string`)throw new e(`INVALID_ARGS`,`scope.leaseProvider must be a string.`);let r=d(n.leaseProvider);return{backend:c(n.backend),deviceKey:l(n.deviceKey),...r?{leaseProvider:r}:{}}}function k(t,n){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`${n} must be an object.`);return t}function A(t){let n=typeof t==`string`?t.trim():``;if(!/^[a-zA-Z0-9._-]{1,128}$/.test(n))throw new e(`INVALID_ARGS`,`Invalid human-control hold id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function j(e){return{...e,scope:{...e.scope}}}function M(t){return new e(`DEVICE_IN_USE`,`A human is interacting with this simulator or device; agent interactions are temporarily disabled.`,{reason:`human_control_active`,blockedBy:`human_control`,holdId:t.id,deviceKey:t.scope.deviceKey,pausedAt:new Date(t.createdAt).toISOString(),...t.expiresAt===void 0?{}:{expiresAt:new Date(t.expiresAt).toISOString()},...t.reason?{humanReason:t.reason}:{},hint:`Wait until the human-control hold is released before retrying.`})}export{D as a,w as c,S as d,C as f,s as g,o as h,A as i,i as l,y as m,j as n,x as o,h as p,M as r,v as s,E as t,T as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{r as t}from"./request-cancel.js";import"./request.js";import{a as n}from"./human-control-contract.js";async function r(n){let{req:r,registry:s}=n,c=r.internal?.admittedLease;if(!c)throw new e(`UNAUTHORIZED`,`Human control requires an admitted remote lease.`);let l={kind:`lease`,leaseId:c.leaseId},u=r.positionals??[],[d,f=``,p=``]=u;switch(d){case`list`:return a(u,1),{ok:!0,data:{holds:s.listHumanControlHolds(l)}};case`put`:return a(u,3),{ok:!0,data:{hold:await s.putHumanControlHold(l,f,i(p),t(r.meta?.requestId)),state:`active`}};case`remove`:{a(u,2);let e=s.removeHumanControlHold(l,f);return{ok:!0,data:{released:!!e,...e?{hold:e}:{}}}}default:throw o()}}function i(t){let r;try{r=JSON.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Human-control payload must be valid JSON.`,void 0,t)}return n(r)}function a(e,t){if(e.length!==t)throw o()}function o(){return new e(`INVALID_ARGS`,`human_control requires list, put <id> <payload>, or remove <id>.`)}export{r as handleHumanControlCommand};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as centerOfRect, H as isAgentDeviceError, R as AppError, U as normalizeAgentDeviceError } from "./sdk-contracts.js";
|
|
2
2
|
import { n as AgentDeviceClientConfig, r as AgentDeviceDaemonTransport, t as AgentDeviceClient } from "./client-types.js";
|
|
3
3
|
import { p as createLocalArtifactAdapter } from "./sdk-io.js";
|
|
4
4
|
//#region src/agent-device-client.d.ts
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{D as e,T as t,d as n,y as r}from"./sdk-contracts.js";import{n as i}from"./agent-device-client.js";import{t as a}from"./sdk-io.js";export{r as AppError,n as centerOfRect,i as createAgentDeviceClient,a as createLocalArtifactAdapter,t as isAgentDeviceError,e as normalizeAgentDeviceError};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{Wt as n}from"./sdk-batch-runner.js";import{_ as r,a as i,v as a,y as o,z as s}from"./interaction.js";import{n as c}from"./device.js";import{A as l,F as u,c as d,f,l as ee,o as p,s as m}from"./sdk-android-adb.js";import{n as te}from"./shell-quote.js";import{t as h}from"./timeouts.js";import{g}from"./app-lifecycle.js";import{r as _}from"./device-input-state.js";import{c as v,d as ne,f as re,h as ie,l as ae,m as oe,o as se,p as ce,t as y}from"./snapshot.js";import{a as le,d as b,r as ue}from"./helper-package-install.js";import{a as de,c as x,r as S,s as C}from"./ime-lifecycle.js";function fe(e,t){if(!t)return{expected:e,actual:null,failureReason:`text_mismatch`,targetInput:null,actualInput:null};let n=he(t),r={failureReason:t.reason??`text_mismatch`,targetInput:T(t.targetInput),actualInput:T(t.actualInput)};return n?{...r,expectedLength:Array.from(e).length,actual:null,masked:!0,actualLength:Array.from(t.actual??``).length}:{...r,expected:e,actual:t.actual}}function w(e){return e?e.password?!0:pe(e.text):!1}function pe(e){return e?Array.from(e).every(me):!1}function T(e){if(!e)return null;let t=w(e);return{...e,text:t?null:e.text,...t?{textRedacted:!0}:{}}}function me(e){return e===`•`||e===`*`||e===`●`}function he(e){return e.masked===!0||w(e.targetInput)||w(e.actualInput)}async function E(e,t,n,r){let i=[0,150,350],a=null,o=null,s=await j(e);for(let c of i){c>0&&await h(c);let i=await Ce(e,t,n,r,s);if(a=i,i.reason===`ime_capture`)return i;o=i.ok?i:null}return o??a??{ok:!1,actual:null,reason:`text_mismatch`,targetInput:null,actualInput:null}}async function ge(e,t,n){return be(await y(e),t,n)}async function _e(e,t,n){let r=await j(e);return k(await y(e),t,n,r).targetInput}async function ve(e,t,n){try{return await _e(e,t,n)}catch(e){return l({level:`warn`,phase:`android_fill_pre_action_target_capture_failed`,data:{error:e instanceof Error?e.message:String(e)}}),null}}function D(e,n,r){if(r?.ok)return;let i=r?O(e,n,r):null;if(i)return i;throw new t(`COMMAND_FAILED`,xe(r),Se(e,r))}function O(e,t,n){let r=n.targetInput,i=n.actualInput;if(n.reason===`ime_capture`||!t||!r||!i||w(t)||w(r)||w(i)||!N(t,r)||!N(t,i)||t.text===n.actual)return null;let a=Fe(t);return l({level:`warn`,phase:`android_fill_verification_unconfirmed`,data:{target:a}}),{verification:`unconfirmed`,requested:e,before:t.text,after:n.actual,target:a}}function ye(e,t,n,r,i={}){let a=k(e,t,n,i);return we(a)?{ok:!1,actual:a.actualInput?.text??null,reason:`ime_capture`,targetInput:a.targetInput,actualInput:a.actualInput}:Te(a,r)??Ee(a,r)}function be(e,t,n){return k(e,t,n).targetInput?.text??null}function xe(e){return e?.reason===`ime_capture`?`Android fill input was captured by the active keyboard instead of the app field`:e?.reason===`masked_unverified`?`Android fill verification could not confirm masked text value`:`Android fill verification failed`}function Se(e,t){let n=fe(e,t);return t?.reason===`ime_capture`&&(n.hint=`The focused input belongs to the Android keyboard/IME, not the app field. Disable handwriting/stylus input or switch to a standard IME, then retry fill.`),n}async function Ce(e,t,n,r,i){return ye(await y(e),t,n,r,i)}function k(e,t,n,r={}){let i={focusedEdit:null,editAtPoint:null,anyAtPoint:null};for(let a of ie(e)){let e=ke(a,r);e&&Ae(i,e,t,n)}return Me(i)}function we(e){let{targetInput:t,actualInput:n}=e;return!t||!n||n===t?!1:n.inputMethodOwned&&!t.inputMethodOwned}function Te(e,t){let n=e.actualInput;if(!n||!Pe(n))return null;let r=n.text??null,i=Array.from(r??``).length,a=Array.from(t).length,o=r!==null&&i>0&&a>0&&i===a;return{ok:o,actual:r,reason:o?void 0:`masked_unverified`,masked:!0,targetInput:e.targetInput,actualInput:n}}function Ee(e,t){let n=e.actualInput?.text??null;return{ok:De(n,t),actual:n,reason:`text_mismatch`,targetInput:e.targetInput,actualInput:e.actualInput}}function De(e,t){if(e===t)return!0;let n=A(e),r=A(t);return!n||!r?!1:!!(n===r||Oe(n,r))}function A(e){return(e??``).replace(/\s+/g,` `).trim()}function Oe(e,t){if(e.length!==t.length||e.length===0||e.slice(1)!==t.slice(1))return!1;let n=e[0],r=t[0];return!n||!r?!1:r.toLowerCase()===r&&n===r.toUpperCase()}function ke(e,t){if(!e.rect)return null;let r=e.text??``,i=Math.max(1,e.rect.width*e.rect.height);return{text:r||null,className:e.className,resourceId:e.resourceId,packageName:e.packageName,rect:e.rect,focused:e.focused??!1,password:e.password===!0,inputMethodOwned:n({packageName:e.packageName,resourceId:e.resourceId,activeInputMethodPackage:t.activeInputMethodPackage}),area:i,editText:Ne(e.className??``)}}async function j(e){try{return{activeInputMethodPackage:(await _(e)).inputMethodPackage}}catch(e){return l({level:`warn`,phase:`android_fill_verification_input_method_probe_failed`,data:{error:e instanceof Error?e.message:String(e)}}),{}}}function Ae(e,t,n,r){let i=je(t.rect,n,r);if(i&&t.editText&&(e.editAtPoint=M(e.editAtPoint,t)),t.focused&&t.editText){e.focusedEdit=M(e.focusedEdit,t);return}i&&t.text&&(e.anyAtPoint=M(e.anyAtPoint,t))}function je(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function M(e,t){return e&&e.area<t.area?e:t}function Me(e){let t=e.editAtPoint??e.anyAtPoint;return{targetInput:t,actualInput:(e.focusedEdit?.text?e.focusedEdit:null)??t}}function Ne(e){let t=e.toLowerCase();return t.includes(`edittext`)||t.includes(`textfield`)}function Pe(e){return w(e)}function N(e,t){return e.resourceId||t.resourceId?e.resourceId===t.resourceId&&e.packageName===t.packageName:e.className===t.className&&e.packageName===t.packageName&&e.rect.x===t.rect.x&&e.rect.y===t.rect.y&&e.rect.width===t.rect.width&&e.rect.height===t.rect.height}function Fe(e){return{resourceId:e.resourceId,className:e.className,packageName:e.packageName,rect:e.rect}}function P(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)throw new t(`COMMAND_FAILED`,`Android helper returned an invalid gesture viewport`);return e}const F=45e3,I=`ANDROID_TOUCH_HELPER_NO_FINAL_RESULT`,L=`ANDROID_TOUCH_HELPER_REPORTED_FAILURE`;async function Ie(e,t){let n=await z(e),r=ze(t),i=Math.max(45e3,r.durationMs+15e3),a=Buffer.from(JSON.stringify({protocol:`android-touch-plan-v1`,...r})).toString(`base64`),o=await u(`android_touch_helper_gesture`,async()=>{let e=await v({deviceKey:n.deviceKey,action:`gesture`,helper:R(n.artifact),payloadBase64:a,timeoutMs:i});return e?{...V(e),helperTransport:`persistent-session`}:{...await B({adb:n.adb,runner:n.artifact.manifest.instrumentationRunner,extraArgs:[`-e`,`mode`,`gesture`,`-e`,`payloadBase64`,a],timeoutMs:i,readResult:V}),helperTransport:`instrumentation`}},{packageName:n.artifact.manifest.packageName,version:n.artifact.manifest.version});return{backend:`android-helper`,helperVersion:n.artifact.manifest.version,installReason:n.install.reason,...o}}async function Le(e){let t=await z(e);try{let e=await v({deviceKey:t.deviceKey,action:`viewport`,helper:R(t.artifact),timeoutMs:F});if(e)return H(e)}catch(e){await ae(t.deviceKey),l({level:`warn`,phase:`android_touch_helper_viewport_session_fallback`,data:{reason:e instanceof Error?e.message:String(e)}})}return await B({adb:t.adb,runner:t.artifact.manifest.instrumentationRunner,extraArgs:[`-e`,`mode`,`viewport`],timeoutMs:F,readResult:H})}function R(e){return{packageName:e.manifest.packageName,runner:e.manifest.instrumentationRunner,helperVersion:e.manifest.version,helperVersionCode:e.manifest.versionCode,sha256:e.manifest.sha256}}async function z(e){let t=m(e),n=t.snapshotHelperArtifact??await Re(),r=ne(e);await re({deviceKey:r,adb:t.exec});let i=await u(`android_touch_helper_install`,async()=>await se({adb:t.exec,adbProvider:t,artifact:n,deviceKey:r,timeoutMs:3e4}),{packageName:n.manifest.packageName,versionCode:n.manifest.versionCode});return l({phase:`android_touch_helper_install_decision`,data:i}),i.installed&&await ae(r),{adb:t.exec,artifact:n,install:i,deviceKey:r}}async function Re(){return await ue({helperDirName:`snapshot-helper`,manifestFileName:e=>`agent-device-android-snapshot-helper-${e}.manifest.json`,parseManifest:e=>{let t=ce(e);return{...t,assetName:t.assetName??`agent-device-android-snapshot-helper-${t.version}.apk`}},unavailableMessage:`Android touch gestures require the bundled Android automation helper artifact, but it was not found or could not be read`})}function ze(e){return{kind:e.topology===`single`?`swipe`:`transform`,durationMs:e.durationMs,pointers:e.pointers.map(Be)}}function Be(e){return{pointerId:e.pointerId,samples:e.samples.map(({offsetMs:e,point:t})=>({offsetMs:e,x:t.x,y:t.y}))}}async function B(e){let n=await e.adb([`shell`,`am`,`instrument`,`-w`,...e.extraArgs,e.runner],{allowFailure:!0,timeoutMs:e.timeoutMs}),r;try{r=Ve(`${n.stdout}\n${n.stderr}`)}catch(e){if(e instanceof t){if(e.code===L)throw new t(`COMMAND_FAILED`,e.message,e.details,e);if(e.code!==I)throw e}throw new t(`COMMAND_FAILED`,n.exitCode===0?`Android automation helper output could not be parsed`:`Android automation helper failed before returning parseable output`,f(n),e)}if(n.exitCode!==0)throw new t(`COMMAND_FAILED`,`Android automation helper failed`,f(n,{helper:r}));return e.readResult(r)}function Ve(e){let n=le(e).results.find(e=>e.agentDeviceProtocol===oe);if(!n)throw new t(I,`Android automation helper did not return a final result`);if(n.ok!==`true`)throw new t(L,n.message&&n.message!==`null`?n.message:n.errorType||`Android automation helper returned an error`,{errorType:n.errorType,helper:n});return n}function V(e){return{helperKind:e.kind,helperApiVersion:e.helperApiVersion,injectedEvents:b(e.injectedEvents),elapsedMs:b(e.elapsedMs)}}function H(e){let n=b(e.x),r=b(e.y),i=b(e.width),a=b(e.height);if(n===void 0||r===void 0||i===void 0||a===void 0)throw new t(`COMMAND_FAILED`,`Android helper returned an invalid gesture viewport`);return P({x:n,y:r,width:i,height:a})}function He(e){if(e.topology===`two`||e.intent===`longPress`)return e;let[{pointerId:t,samples:n}]=e.pointers,r=[...new Set([...o(e.durationMs,`android`),...n.map(({offsetMs:e})=>e)])].sort((e,t)=>e-t),i=0,s=r.map(e=>{for(;i<n.length-2&&e>n[i+1].offsetMs;)i+=1;let t=n[i],r=n[i+1],o=r.offsetMs-t.offsetMs;return{offsetMs:e,point:e===r.offsetMs||o===0?r.point:a(t.point,r.point,(e-t.offsetMs)/o)}}),c=[s[0],s[1],s[2],...s.slice(3)];return{...e,pointers:[{pointerId:t,samples:c}]}}async function U(e,t){let n=He(t),r=ee(e);if(r){let e=n.intent===`longPress`?{...n,viewport:P(await r.gestureViewport())}:n;return{backend:`provider-native-touch`,...await r.touch(e)??{}}}return await Ie(e,n)}async function W(e){let t=ee(e);return t?P(await t.gestureViewport()):await Le(e)}var Ue=e({appSwitcherAndroid:()=>Ke,backAndroid:()=>q,fillAndroid:()=>Ye,focusAndroid:()=>Y,getAndroidScreenSize:()=>X,homeAndroid:()=>J,longPressAndroid:()=>qe,pressAndroid:()=>G,pressAndroidEnter:()=>We,pressAndroidTvRemote:()=>K,readAndroidTextAtPoint:()=>ge,scrollAndroid:()=>Qe,setAndroidOrientation:()=>Ge,typeAndroid:()=>Je});async function G(e,t,n){await g(e,[`shell`,`input`,`tap`,String(t),String(n)])}async function K(e,t,n){let r=i(t);await g(e,[`shell`,`input`,...n&&n>0?[`keyevent`,`--longpress`]:[`keyevent`],r])}async function q(e){await g(e,[`shell`,`input`,`keyevent`,`4`])}async function J(e){await g(e,[`shell`,`input`,`keyevent`,`3`])}async function We(e){await g(e,[`shell`,`input`,`keyevent`,`ENTER`])}async function Ge(e,t){let n=$e(t);await g(e,[`shell`,`settings`,`put`,`system`,`accelerometer_rotation`,`0`]),await g(e,[`shell`,`settings`,`put`,`system`,`user_rotation`,n])}async function Ke(e){await g(e,[`shell`,`input`,`keyevent`,`187`])}async function qe(e,t,n,r=800){let i={x:t,y:n};return await U(e,{topology:`single`,intent:`longPress`,durationMs:r,pointers:[{pointerId:0,samples:[{offsetMs:0,point:i},{offsetMs:r,point:i}]}]})}async function Je(e,t,n=0){let r=d(e);if(r){await r({action:`type`,text:t,delayMs:n}),$(`type`,`provider-native`,t);return}if(S(e)){await Xe(e,t,n);return}if(rt(t),await et(e,`type`),n>0&&Array.from(t).length>1){await Z(e,{action:`type`,text:t,chunkSize:1,delayMs:n});return}await Z(e,{action:`type`,text:t,chunkSize:tt,delayMs:0})}async function Y(e,t,n){await G(e,t,n)}async function Ye(e,t,n,r,i=0){let a=await ve(e,t,n),o=d(e);if(o)return await o({action:`fill`,target:{x:t,y:n},text:r,delayMs:i}),$(`fill`,`provider-native`,r),D(r,a,await E(e,t,n,r));if(S(e))return D(r,a,await Ze(e,t,n,r,a));rt(r);let s=Array.from(r).length,c=[{clearPadding:12,minClear:8,maxClear:48,chunkSize:i>0?1:tt,inputDelayMs:i},{clearPadding:24,minClear:16,maxClear:96,chunkSize:i>0?1:4,inputDelayMs:i>0?i:15}],l=null;for(let i of c){await Y(e,t,n),await et(e,`fill`),await ct(e,lt(s+i.clearPadding,i.minClear,i.maxClear)),await Z(e,{action:`fill`,text:r,chunkSize:i.chunkSize,delayMs:i.inputDelayMs});let o=await E(e,t,n,r);if(l=o,o.ok)return;if(o.reason===`ime_capture`)return D(r,a,o);let c=O(r,a,o);if(c)return c}return D(r,a,l)}async function Xe(e,t,n){let r=p(e),i=(await C(m(e))).manifest.packageName,a=t.split(`
|
|
2
|
-
`);for(let[t,o]of a.entries()){let s=n>0?Q(o,1):[o];for(let[e,o]of s.entries())o&&await x(r,i,o),n>0&&(e+1<s.length||t+1<a.length)&&await h(n);t+1<a.length&&await g(e,[`shell`,`input`,`keyevent`,`ENTER`])}$(`type`,`test-ime`,t)}async function Ze(e,t,n,r,i){let a=p(e),o=(await C(m(e))).manifest.packageName,s=null;for(let c=0;c<2;c+=1){await Y(e,t,n),await de(a,o),r&&await x(a,o,r);let c=await E(e,t,n,r);if(s=c,c.ok||O(r,i,c))break}return $(`fill`,`test-ime`,r),s}async function Qe(e,t,n){let i=await W(e),a=s({direction:t,amount:n?.amount,pixels:n?.pixels,referenceWidth:i.width,referenceHeight:i.height}),o={...a,referenceWidth:i.x+i.width,referenceHeight:i.y+i.height,x1:i.x+a.x1,y1:i.y+a.y1,x2:i.x+a.x2,y2:i.y+a.y2},c=Math.max(n?.durationMs??300,16),l=await U(e,r({intent:`pan`,origin:{x:o.x1,y:o.y1},delta:{x:o.x2-o.x1,y:o.y2-o.y1},durationMs:c},i,`android`));return{...o,...n?.durationMs===void 0?{}:{durationMs:c},...l}}function $e(e){let n=c[e];if(n===void 0)throw new t(`INVALID_ARGS`,`Unsupported Android rotation: ${e}`);return String(n)}async function et(e,n){let r;try{r=await _(e)}catch(e){l({level:`warn`,phase:`android_input_ownership_probe_failed`,data:{action:n,error:e instanceof Error?e.message:String(e)}});return}if(r.inputOwner===`ime`)throw new t(`COMMAND_FAILED`,`KEYBOARD_OVERLAY_BLOCKING: Android text input is blocked because the focused input belongs to the active keyboard/IME.`,{failureReason:`ime_capture`,action:n,inputOwner:r.inputOwner,inputType:r.inputType,type:r.type,inputMethodPackage:r.inputMethodPackage,focusedPackage:r.focusedPackage,focusedResourceId:r.focusedResourceId,nextAction:`Focused input appears to be owned by the keyboard/IME; dismiss or change the IME before retrying text entry.`})}async function X(e){let n=(await g(e,[`shell`,`wm`,`size`])).stdout.match(/Physical size:\s*(\d+)x(\d+)/);if(!n)throw new t(`COMMAND_FAILED`,`Unable to read screen size`);return{width:Number(n[1]),height:Number(n[2])}}const tt=8;async function Z(e,t){let n=t.text.split(`
|
|
3
|
-
`);for(let[r,i]of n.entries()){let a=Q(i,t.chunkSize);for(let[i,o]of a.entries())await nt(e,o),t.delayMs>0&&(i+1<a.length||r+1<n.length)&&await h(t.delayMs);r+1<n.length&&await g(e,[`shell`,`input`,`keyevent`,`ENTER`])}$(t.action,`adb-shell`,t.text)}async function nt(e,t){if(t)try{await g(e,[`shell`,`input`,`text`,te(at(t))])}catch(e){throw ot(e)?st(t,e):e}}function rt(e){if(!it(e))throw st(e)}function it(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&t!==`
|
|
4
|
-
`&&(e<32||e>126))return!1}return!0}function at(e){return e.replace(/ /g,`%s`)}function ot(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=e.details?.stderr,r=(typeof n==`string`?n:``).toLowerCase();return!!(r.includes(`exception occurred while executing 'text'`)||r.includes(`nullpointerexception`)&&r.includes(`inputshellcommand.sendtext`))}function st(e,n){return new t(`COMMAND_FAILED`,"Android text input requires provider-native text injection or the bundled test IME helper for non-ASCII/control characters; the adb-shell fallback supports ASCII text only. On emulators the test IME activates automatically; on real devices pass `open --test-ime` to enable it (see `agent-device doctor` for the current IME state).",{backend:`adb-shell`,textLength:Array.from(e).length,textPreview:e.slice(0,32)},n instanceof Error?n:void 0)}function Q(e,t){let n=Math.max(1,Math.floor(t)),r=[],i=Array.from(e);for(let e=0;e<i.length;e+=n)r.push(i.slice(e,e+n).join(``));return r.length>0?r:[``]}function $(e,t,n){l({phase:`android_text_injection`,data:{action:e,backend:t,textLength:Array.from(n).length}})}async function ct(e,t){let n=Math.max(0,t);await g(e,[`shell`,`input`,`keyevent`,`KEYCODE_MOVE_END`],{allowFailure:!0});for(let t=0;t<n;t+=24){let r=Math.min(24,n-t);await g(e,[`shell`,`input`,`keyevent`,...Array(r).fill(`KEYCODE_DEL`)],{allowFailure:!0})}}function lt(e,t,n){return Math.max(t,Math.min(n,e))}export{X as a,qe as c,Qe as d,Ge as f,W as h,Y as i,G as l,U as m,q as n,J as o,Je as p,Ye as r,Ue as s,Ke as t,K as u};
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{l as t}from"./scroll-gesture.js";import{t as n}from"./timeouts.js";import"./retry.js";import{runHarmonyHdc as r}from"./hdc.js";import{invalidateHarmonyGestureViewport as i,readHarmonyGestureViewport as a}from"./snapshot2.js";async function o(e,t,n){await r(e,[`shell`,`uitest`,`uiInput`,`click`,String(t),String(n)])}async function s(e,t,n){await r(e,[`shell`,`uitest`,`uiInput`,`doubleClick`,String(t),String(n)])}async function c(e,t,n,i=800){await r(e,[`shell`,`uitest`,`uiInput`,`longClick`,String(t),String(n)])}async function l(e,t,i=0){await r(e,[`shell`,`uitest`,`uiInput`,`text`,t]),i>0&&await n(i)}async function u(e,t,i,a,o=0){await r(e,[`shell`,`uitest`,`uiInput`,`inputText`,String(t),String(i),a]),o>0&&await n(o)}async function d(e,n,i){let o=await a(e),s=t({direction:n,amount:i?.amount,pixels:i?.pixels,referenceWidth:o.width,referenceHeight:o.height});return await r(e,[`shell`,`uitest`,`uiInput`,`swipe`,String(s.x1),String(s.y1),String(s.x2),String(s.y2),String(i?.durationMs??300)]),s}async function f(t,n){if(n.topology!==`single`)throw new e(`UNSUPPORTED_OPERATION`,`HarmonyOS HDC does not support multi-touch gestures`);let i=n.pointers[0].samples,a=i[0],o=i.at(-1);if(!a||!o)throw new e(`COMMAND_FAILED`,`HarmonyOS gesture plan has no pointer endpoints`);let s=Math.hypot(o.point.x-a.point.x,o.point.y-a.point.y),c=Math.max(200,Math.min(4e4,Math.round(s/n.durationMs*1e3))),l=n.intent===`fling`?`fling`:`swipe`;return await r(t,[`shell`,`uitest`,`uiInput`,l,String(Math.round(a.point.x)),String(Math.round(a.point.y)),String(Math.round(o.point.x)),String(Math.round(o.point.y)),String(c)]),{backend:`harmonyos-hdc-uiinput`,command:l,velocity:c,viewport:n.viewport}}async function p(e){await r(e,[`shell`,`uitest`,`uiInput`,`keyEvent`,`Back`]),i(e)}async function m(e){await r(e,[`shell`,`uitest`,`uiInput`,`keyEvent`,`Home`]),i(e)}async function h(e){await r(e,[`shell`,`uitest`,`uiInput`,`keyEvent`,`Recent`]),i(e)}async function g(e,t){if(t===`Back`){await p(e);return}await r(e,[`shell`,`uitest`,`uiInput`,`keyEvent`,t])}async function _(t,n){throw new e(`UNSUPPORTED_OPERATION`,`HarmonyOS orientation control is not available through the public HDC API.`)}export{h as appSwitcherHarmony,p as backHarmony,s as doubleClickHarmony,u as fillHarmony,m as homeHarmony,c as longPressHarmony,f as performHarmonyGesture,o as pressHarmony,g as pressHarmonyKeyboardKey,d as scrollHarmony,_ as setHarmonyOrientation,l as typeHarmony};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{c as t}from"./owner-identity.js";import{t as n}from"./timeouts.js";import"./retry.js";import"./process.js";import{t as r}from"./tool-provider2.js";function i(){let e=t();return e.WAYLAND_DISPLAY||e.XDG_SESSION_TYPE===`wayland`?`wayland`:`x11`}let a=null;async function o(){let t=r();if(a?.provider===t)return a;let n=i();if(n===`wayland`){if(await t.whichCommand(`ydotool`))return a={tool:`ydotool`,display:n,provider:t},a;throw new e(`TOOL_MISSING`,`ydotool is required for input synthesis on Wayland (xdotool does not work on Wayland). Install it via your package manager.`)}if(await t.whichCommand(`xdotool`))return a={tool:`xdotool`,display:n,provider:t},a;throw new e(`TOOL_MISSING`,`xdotool is required for input synthesis on X11. Install it via your package manager.`)}const s=1e4;async function c(...e){await r().runCommand(`xdotool`,e,{allowFailure:!1,timeoutMs:s})}async function l(...e){await r().runCommand(`ydotool`,e,{allowFailure:!1,timeoutMs:s})}function u(){return r().input}async function d(e,t){let{tool:n}=await o();if(n===`xdotool`){if(await f(e,t))return;await c(`mousemove`,`--sync`,String(e),String(t))}else await l(`mousemove`,`--absolute`,`-x`,String(e),`-y`,String(t))}async function f(e,t){try{let n=await r().runCommand(`xdotool`,[`getmouselocation`,`--shell`],{allowFailure:!0,timeoutMs:s}),i=new Map(n.stdout.split(`
|
|
2
|
+
`).map(e=>e.trim().split(`=`)).filter(e=>e.length===2).map(([e,t])=>[e,Number(t)]));return i.get(`X`)===Math.round(e)&&i.get(`Y`)===Math.round(t)}catch{return!1}}async function p(e,t){let n=u();if(n){await n.key(e,t);return}let{tool:r}=await o();r===`xdotool`?await c(`key`,`--clearmodifiers`,e):await l(`key`,...t)}async function m(e,t,n,r){await d(e,t);let{tool:i}=await o();i===`xdotool`?await c(`click`,n):await l(`click`,r)}async function h(e,t,n,r,i){let a=u();if(a){await a.click(e,t,n);return}await m(e,t,r,i)}async function g(e,t){await h(e,t,`primary`,`1`,`0xC0`)}async function _(e,t){await h(e,t,`secondary`,`3`,`0xC1`)}async function v(e,t){await h(e,t,`middle`,`2`,`0xC2`)}async function y(e,t){let n=u();if(n){await n.doubleClick(e,t);return}let{tool:r}=await o();await d(e,t),r===`xdotool`?await c(`click`,`--repeat`,`2`,`1`):(await l(`click`,`0xC0`),await l(`click`,`0xC0`))}async function b(e,t,r=800){let i=u();if(i){await i.longPress(e,t,r);return}let{tool:a}=await o();await d(e,t),a===`xdotool`?(await c(`mousedown`,`1`),await n(r),await c(`mouseup`,`1`)):(await l(`click`,`--down`,`0xC0`),await n(r),await l(`click`,`--up`,`0xC0`))}async function x(e,t){await g(e,t)}async function S(e,t,r,i,a=300){let s=u();if(s){await s.drag(e,t,r,i,a);return}let{tool:f}=await o();await d(e,t),f===`xdotool`?(await c(`mousedown`,`1`),await c(`mousemove`,`--sync`,String(r),String(i)),await n(a),await c(`mouseup`,`1`)):(await l(`click`,`--down`,`0xC0`),await l(`mousemove`,`--absolute`,`-x`,String(r),`-y`,String(i)),await n(a),await l(`click`,`--up`,`0xC0`))}async function C(e,t){let n=u();if(n)return await n.scroll(e,t),T(t);let{tool:r}=await o(),i=5;if(t?.pixels==null?t?.amount!=null&&(i=Math.max(1,Math.round(5*(t.amount/.6)))):i=r===`xdotool`?Math.max(1,Math.round(t.pixels/15)):Math.max(1,Math.round(t.pixels/40)),r===`xdotool`){let n=e===`up`?`4`:e===`down`?`5`:e===`left`?`6`:`7`;await w(i,t?.durationMs,async e=>{await c(`click`,`--repeat`,String(e),n)})}else e===`up`||e===`down`?await w(i,t?.durationMs,async t=>{await l(`mousemove`,`--wheel`,`-y`,String(e===`up`?-t:t))}):await w(i,t?.durationMs,async t=>{await l(`mousemove`,`--wheel`,`-x`,String(e===`left`?-t:t))});return T(t)}async function w(e,t,r){if(t===void 0||t<=0||e<=1){await r(e);return}let i=t/Math.max(1,e-1);for(let t=0;t<e;t+=1)await r(1),t<e-1&&await n(i)}function T(e){return e?.durationMs===void 0?{}:{durationMs:e.durationMs}}async function E(e,t=0){let n=u();if(n){await n.typeText(e,{delayMs:t});return}let{tool:r}=await o();if(r===`xdotool`){let n=[`type`];t>0&&n.push(`--delay`,String(t)),n.push(`--clearmodifiers`,`--`,e),await c(...n)}else await l(`type`,`--`,e)}async function D(e,t,r,i=0){if(await g(e,t),await n(100),await p(`ctrl+a`,[`29:1`,`30:1`,`30:0`,`29:0`]),await n(50),r.length===0){await p(`BackSpace`,[`14:1`,`14:0`]);return}await E(r,i)}export{y as doubleClickLinux,D as fillLinux,x as focusLinux,b as longPressLinux,v as middleClickLinux,g as pressLinux,_ as rightClickLinux,C as scrollLinux,p as sendKey,S as swipeLinux,E as typeLinux};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{r as t}from"./archive.js";import{a as n,c as r,n as i,o as a,r as o,s}from"./install-source2.js";import{C as c,g as l,m as u}from"./host-file.js";import{t as d}from"./plist.js";import f from"node:path";async function p(e,t){let n=f.join(e,`Info.plist`),[r,i,a]=await Promise.all([d(n,`CFBundleIdentifier`,t),d(n,`CFBundleDisplayName`,t),d(n,`CFBundleName`,t)]);return{bundleId:r,appName:i??a}}async function m(e,t){return await r(async()=>await h(e,t))}async function h(t,n){if(t.kind===`url`&&!i(t.url))throw new e(`INVALID_ARGS`,`iOS install_from_source URL sources are only supported for trusted artifact services such as GitHub Actions and EAS. Use a path source for other hosts.`);let r=await o({source:t,isInstallablePath:(e,t)=>t.isDirectory()&&e.toLowerCase().endsWith(`.app`)||t.isFile()&&e.toLowerCase().endsWith(`.ipa`),installableLabel:`iOS installable (.app or .ipa)`,allowArchiveExtraction:t.kind!==`url`||i(t.url),signal:n?.signal}),a;try{a=await g(r.installablePath,n);let e=a,t=await p(e.installPath,n?.signal);return{archivePath:r.archivePath??(r.installablePath.toLowerCase().endsWith(`.ipa`)?r.installablePath:void 0),installablePath:e.installPath,bundleId:t.bundleId,appName:t.appName,cleanup:async()=>{await e.cleanup(),await r.cleanup()}}}catch(e){try{await a?.cleanup()}finally{await r.cleanup()}throw e}}async function g(e,t){return e.toLowerCase().endsWith(`.ipa`)?await _(e,t):{installPath:e,cleanup:async()=>{}}}async function _(r,i){let o=await u(`agent-device-ios-ipa-`),d=async()=>{await c(o)};try{let c=f.join(o,`extracted`),u=a()+1,p=n();await t({archivePath:r,outputRoot:c,type:`zip`,budget:p,depth:u,signal:i?.signal}),s(u);let m=f.join(c,`Payload`),h=(await l(m,{withFileTypes:!0}).catch(()=>{throw new e(`INVALID_ARGS`,`Invalid IPA: missing Payload directory`)})).filter(e=>e.isDirectory()&&e.name.toLowerCase().endsWith(`.app`)).map(e=>({installPath:f.join(m,e.name),bundleName:e.name.replace(/\.app$/i,``)})),g=h[0];if(g!==void 0&&h.length===1)return{installPath:g.installPath,cleanup:d};if(h.length===0)throw new e(`INVALID_ARGS`,`Invalid IPA: expected at least one .app under Payload, found 0`);await v(h,i?.signal);let _=i?.appIdentifierHint?.trim();if(_){let t=y(h,_);if(t)return{installPath:t.installPath,cleanup:d};throw new e(`INVALID_ARGS`,`Invalid IPA: found ${h.length} .app bundles under Payload and none matched "${_}". Available bundles: ${h.map(b).join(`, `)}`)}throw new e(`INVALID_ARGS`,`Invalid IPA: found ${h.length} .app bundles under Payload. Pass an app identifier or bundle name matching one of: ${h.map(b).join(`, `)}`)}catch(e){throw await d(),e}}async function v(e,t){await Promise.all(e.map(async e=>{if(e.bundleId&&e.appName)return;let n=await p(e.installPath,t);e.bundleId=e.bundleId??n.bundleId,e.appName=e.appName??n.appName}))}function y(t,n){let r=n.toLowerCase(),i=t.filter(e=>e.bundleName.toLowerCase()===r);if(i.length===1)return i[0];if(i.length>1)throw new e(`INVALID_ARGS`,`Invalid IPA: multiple app bundles matched "${n}" by name. Use a bundle id hint instead.`);if(n.includes(`.`)){let e=t.filter(e=>e.bundleId?.toLowerCase()===r);if(e.length===1)return e[0]}}function b(e){let t=e.bundleId??e.appName;return t?`${e.bundleName}.app (${t})`:`${e.bundleName}.app`}export{m as prepareIosInstallArtifact,p as readIosBundleInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,t}from"./rolldown-runtime.js";import{E as n,x as r,y as i}from"./sdk-contracts.js";import{t as a}from"./undici.js";import o from"node:net";import s from"node:dns/promises";var c=e(t(((e,t)=>{(function(e){let n=`(0?\\d+|0x[a-f0-9]+)`,r={fourOctet:RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,`i`),threeOctet:RegExp(`^${n}\\.${n}\\.${n}$`,`i`),twoOctet:RegExp(`^${n}\\.${n}$`,`i`),longValue:RegExp(`^${n}$`,`i`)},i=RegExp(`^0[0-7]+$`,`i`),a=RegExp(`^0x[a-f0-9]+$`,`i`),o=`%[0-9a-z]{1,}`,s=`(?:[0-9a-f]+::?)+`,c={zoneIndex:RegExp(o,`i`),native:RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,`i`),deprecatedTransitional:RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,`i`),transitional:RegExp(`^((?:${s})|(?:::)(?:${s})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,`i`)};function l(e,t){if(e.indexOf(`::`)!==e.lastIndexOf(`::`))return null;let n=0,r=-1,i=(e.match(c.zoneIndex)||[])[0],a,o;for(i&&(i=i.substring(1),e=e.replace(/%.+$/,``));(r=e.indexOf(`:`,r+1))>=0;)n++;if(e.substr(0,2)===`::`&&n--,e.substr(-2,2)===`::`&&n--,n>=t)return null;for(o=t-n,a=`:`;o--;)a+=`0:`;return e=e.replace(`::`,a),e[0]===`:`&&(e=e.slice(1)),e[e.length-1]===`:`&&(e=e.slice(0,-1)),t=(function(){let t=e.split(`:`),n=[];for(let e=0;e<t.length;e++)n.push(t[e].length>4?NaN:parseInt(t[e],16));return n})(),{parts:t,zoneId:i}}function u(e,t,n,r){if(e.length!==t.length)throw Error(`ipaddr: cannot match CIDR for objects with different lengths`);let i=0,a;for(;r>0;){if(a=n-r,a<0&&(a=0),e[i]>>a!==t[i]>>a)return!1;r-=n,i+=1}return!0}function d(e){if(a.test(e))return parseInt(e,16);if(e[0]===`0`&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length<t;)e=`0${e}`;return e}let p={};p.IPv4=(function(){function e(e){if(e.length!==4)throw Error(`ipaddr: ipv4 octet count should be 4`);let t,n;for(t=0;t<e.length;t++)if(n=e[t],!(0<=n&&n<=255))throw Error(`ipaddr: ipv4 octet should fit in 8 bits`);this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]],as112:[[new e([192,175,48,0]),24],[new e([192,31,196,0]),24]],amt:[[new e([192,52,193,0]),24]]},e.prototype.kind=function(){return`ipv4`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv4`)throw Error(`ipaddr: cannot match ipv4 address with non-ipv4 one`);return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},r,i,a;for(r=3;r>=0;--r)if(i=this.octets[r],i in n){if(a=n[i],t&&a!==0)return null;a!==8&&(t=!0),e+=a}else return null;return 32-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(`.`)},e})(),p.IPv4.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<4;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.isIPv4=function(e){return this.parser(e)!==null},p.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch{return!1}},p.IPv4.isValidCIDR=function(e){try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(e){return!!(p.IPv4.isValid(e)&&e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.isValidCIDRFourPartDecimal=function(e){let t=e.match(/^(.+)\/(\d+)$/);return!p.IPv4.isValidCIDR(e)||!t?!1:p.IPv4.isValidFourPartDecimal(t[1])},p.IPv4.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<4;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv4 CIDR format`,{cause:e})}},p.IPv4.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv4 Address`);return new this(t)},p.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){let e=parseInt(t[2]);if(e>=0&&e<=32){let n=[this.parse(t[1]),e];return Object.defineProperty(n,"toString",{value:function(){return this.join(`/`)}}),n}}throw Error(`ipaddr: string is not formatted like an IPv4 CIDR range`)},p.IPv4.parser=function(e){let t,n,i;if(t=e.match(r.fourOctet))return(function(){let e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)n=e[t],r.push(d(n));return r})();if(t=e.match(r.longValue)){if(i=d(t[1]),i>4294967295||i<0)throw Error(`ipaddr: address outside defined range`);return(function(){let e=[],t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e})().reverse()}return(t=e.match(r.twoOctet))?(function(){let e=t.slice(1,4),n=[];if(i=d(e[1]),i>16777215||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(i>>16&255),n.push(i>>8&255),n.push(i&255),n})():(t=e.match(r.threeOctet))?(function(){let e=t.slice(1,5),n=[];if(i=d(e[2]),i>65535||i<0)throw Error(`ipaddr: address outside defined range`);return n.push(d(e[0])),n.push(d(e[1])),n.push(i>>8&255),n.push(i&255),n})():null},p.IPv4.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>32)throw Error(`ipaddr: invalid IPv4 prefix length`);let t=[0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<4&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.IPv6=(function(){function e(e,t){let n,r;if(e.length===16)for(this.parts=[],n=0;n<=14;n+=2)this.parts.push(e[n]<<8|e[n+1]);else if(e.length===8)this.parts=e;else throw Error(`ipaddr: ipv6 part count should be 8 or 16`);for(n=0;n<this.parts.length;n++)if(r=this.parts[n],!(0<=r&&r<=65535))throw Error(`ipaddr: ipv6 part should fit in 16 bits`);t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new e([65216,0,0,0,0,0,0,0]),10],discard:[new e([256,0,0,0,0,0,0,0]),64],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new e([100,65435,0,0,0,0,0,0]),96],[new e([100,65435,1,0,0,0,0,0]),48]],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[[new e([8193,4,274,0,0,0,0,0]),48],[new e([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new e([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new e([24320,0,0,0,0,0,0,0]),16],reserved:[[new e([8193,0,0,0,0,0,0,0]),23],[new e([8193,3512,0,0,0,0,0,0]),32],[new e([16383,0,0,0,0,0,0,0]),20]]},e.prototype.isIPv4MappedAddress=function(){return this.range()===`ipv4Mapped`},e.prototype.kind=function(){return`ipv6`},e.prototype.match=function(e,t){let n;if(t===void 0&&(n=e,e=n[0],t=n[1]),e.kind()!==`ipv6`)throw Error(`ipaddr: cannot match ipv6 address with non-ipv6 one`);return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1,n={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r,i;for(let a=7;a>=0;--a)if(r=this.parts[a],r in n){if(i=n[r],t&&i!==0)return null;i!==16&&(t=!0),e+=i}else return null;return 128-e},e.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e,t=[],n=this.parts;for(let r=0;r<n.length;r++)e=n[r],t.push(e>>8),t.push(e&255);return t},e.prototype.toFixedLengthString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(f(this.parts[t].toString(16),4));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error(`ipaddr: trying to convert a generic ipv6 address to ipv4`);let e=this.parts.slice(-2),t=e[0],n=e[1];return new p.IPv4([t>>8,t&255,n>>8,n&255])},e.prototype.toNormalizedString=function(){let e=(function(){let e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}).call(this).join(`:`),t=``;return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){let e=/((^|:)(0(:|$)){2,})/g,t=``;this.zoneId&&(t=`%${this.zoneId}`);let n=this.toNormalizedString(),r=n.slice(0,n.length-t.length),i=0,a=-1,o=-1,s;for(;s=e.exec(r);){let e=(s[0].match(/0/g)||[]).length;e>o&&(o=e,i=s.index,a=s[0].length)}return a<0?r+t:`${r.substring(0,i)}::${r.substring(i+a)}${t}`},e.prototype.toString=function(){return this.toRFC5952String()},e})(),p.IPv6.broadcastAddressFromCIDR=function(e){try{let t=this.parseCIDR(e),n=t[0].toByteArray(),r=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],a=0;for(;a<16;)i.push(parseInt(n[a],10)|parseInt(r[a],10)^255),a++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.isIPv6=function(e){return this.parser(e)!==null},p.IPv6.isValid=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{let t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch{return!1}},p.IPv6.isValidCIDR=function(e){if(typeof e==`string`&&e.indexOf(`:`)===-1)return!1;try{return this.parseCIDR(e),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(e){let t,n,r,i,a;try{for(t=this.parseCIDR(e),r=t[0].toByteArray(),a=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],n=0;n<16;)i.push(parseInt(r[n],10)&parseInt(a[n],10)),n++;return new this(i)}catch(e){throw Error(`ipaddr: the address does not have IPv6 CIDR format`,{cause:e})}},p.IPv6.parse=function(e){let t=this.parser(e);if(t===null)throw Error(`ipaddr: string is not formatted like an IPv6 Address`);return new this(t.parts,t.zoneId)},p.IPv6.parseCIDR=function(e){let t,n,r;if((n=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(n[2]),t>=0&&t<=128))return r=[this.parse(n[1]),t],Object.defineProperty(r,"toString",{value:function(){return this.join(`/`)}}),r;throw Error(`ipaddr: string is not formatted like an IPv6 CIDR range`)},p.IPv6.parser=function(e){let t,n,r,i,a,o;if(r=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${r[1]}`);if(c.native.test(e))return l(e,8);if((r=e.match(c.transitional))&&(o=r[6]||``,t=r[1],r[1].endsWith(`::`)||(t=t.slice(0,-1)),t=l(t+o,6),t&&t.parts)){for(a=[parseInt(r[2]),parseInt(r[3]),parseInt(r[4]),parseInt(r[5])],n=0;n<a.length;n++)if(i=a[n],!(0<=i&&i<=255))return null;return t.parts.push(a[0]<<8|a[1]),t.parts.push(a[2]<<8|a[3]),{parts:t.parts,zoneId:t.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(e){if(e=parseInt(e),Number.isNaN(e)||e<0||e>128)throw Error(`ipaddr: invalid IPv6 prefix length`);let t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0,r=Math.floor(e/8);for(;n<r;)t[n]=255,n++;return r<16&&(t[r]=2**(e%8)-1<<8-e%8),new this(t)},p.fromByteArray=function(e){let t=e.length;if(t===4)return new p.IPv4(e);if(t===16)return new p.IPv6(e);throw Error(`ipaddr: the binary input is neither an IPv6 nor IPv4 address`)},p.isValid=function(e){return p.IPv6.isValid(e)||p.IPv4.isValid(e)},p.isValidCIDR=function(e){return p.IPv6.isValidCIDR(e)||p.IPv4.isValidCIDR(e)},p.parse=function(e){if(p.IPv6.isValid(e))return p.IPv6.parse(e);if(p.IPv4.isValid(e))return p.IPv4.parse(e);throw Error(`ipaddr: the address has neither IPv6 nor IPv4 format`)},p.parseCIDR=function(e){try{return p.IPv6.parseCIDR(e)}catch{try{return p.IPv4.parseCIDR(e)}catch(e){throw Error(`ipaddr: the address has neither IPv6 nor IPv4 CIDR format`,{cause:e})}}},p.process=function(e){let t=this.parse(e);return t.kind()===`ipv6`&&t.isIPv4MappedAddress()?t.toIPv4Address():t},p.subnetMatch=function(e,t,n){let r,i,a,o;for(i in n??=`unicast`,t)if(Object.prototype.hasOwnProperty.call(t,i)){for(a=t[i],a[0]&&!(a[0]instanceof Array)&&(a=[a]),r=0;r<a.length;r++)if(o=a[r],e.kind()===o[0].kind()&&e.match.apply(e,o))return i}return n},t!==void 0&&t.exports?t.exports=p:e.ipaddr=p})(e)}))(),1);async function l(e,t){if(e.protocol!==`http:`&&e.protocol!==`https:`)throw new i(`INVALID_ARGS`,`Unsupported source URL protocol: ${e.protocol}`);if(e.username||e.password)throw new i(`INVALID_ARGS`,`Source URL credentials are not allowed`);d(t);let r=h(e.hostname);p(r)&&_(e.hostname);let a=o.isIP(r);if(a)return{address:r,family:a};let s;try{s=await u(r,t)}catch(e){throw n(e)?e:new i(`INVALID_ARGS`,`Source URL host could not be resolved: ${r}`,{hint:`Use a public artifact URL.`},e)}if(s.length===0)throw new i(`INVALID_ARGS`,`Source URL host could not be resolved: ${r}`,{hint:`Use a public artifact URL.`});s.some(e=>m(e.address))&&_(r);let c=s[0];return{address:c.address,family:c.family}}async function u(e,t){let n=s.lookup(e,{all:!0,verbatim:!0});return t?await new Promise((e,r)=>{let i=()=>r(f(t.reason));t.addEventListener(`abort`,i,{once:!0}),n.then(e,r).finally(()=>t.removeEventListener(`abort`,i))}):await n}function d(e){if(e?.aborted)throw f(e.reason)}function f(e){return r(void 0,e)}function p(e){let t;try{t=h(e)}catch{return!0}return!t||t===`localhost`||t.endsWith(`.localhost`)?!0:o.isIP(t)!==0&&m(t)}function m(e){try{return c.default.process(g(e)).range()!==`unicast`}catch{return!0}}function h(e){let t=g(e).toLowerCase().replace(/\.$/,``);if(!t||t.includes(`%`))throw new i(`INVALID_ARGS`,`Source URL host is not allowed`,{hint:`Use a public artifact URL.`});return t}function g(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}function _(e){throw new i(`INVALID_ARGS`,`Source URL host is not allowed because it resolves to a non-public address: ${e}`,{hint:`Use a public artifact URL.`})}var v=a();async function y(e){let t=b(e.url),n=t?C(t,e.url):S(e.approvedAddress,e.family),r=t?w(e.url,e.approvedAddress,e.family):e.url;try{let i={dispatcher:n,headers:t?{...e.headers,host:e.url.host}:e.headers,maxRedirections:0,method:`GET`,signal:e.signal},a=await(0,v.request)(r,i);return{statusCode:a.statusCode,headers:a.headers,body:a.body,close:async()=>await D(n)}}catch(e){throw await D(n),e}}function b(e,t=process.env){if(x(e,t.no_proxy??t.NO_PROXY))return;let n=t.http_proxy??t.HTTP_PROXY;return e.protocol===`http:`?n||void 0:(t.https_proxy??t.HTTPS_PROXY)||n||void 0}function x(e,t){if(!t)return!1;let n=E(e.hostname).toLowerCase(),r=e.port||(e.protocol===`https:`?`443`:`80`);return t.split(/[\s,]+/).filter(Boolean).some(e=>{if(e===`*`)return!0;let t=T(e);if(t.port&&t.port!==r)return!1;let i=t.hostname.replace(/^\*?\./,``).toLowerCase();return n===i||n.endsWith(`.${i}`)})}function S(e,t){return new v.Agent({connect:{lookup:(n,r,i)=>i(null,e,t)}})}function C(e,t){let n=o.isIP(E(t.hostname))!==0;return new v.ProxyAgent({uri:e,proxyTunnel:!0,requestTls:t.protocol===`https:`&&!n?{servername:E(t.hostname)}:void 0})}function w(e,t,n){let r=new URL(e);return r.hostname=n===6?`[${E(t)}]`:t,r}function T(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t<0?{hostname:e}:{hostname:e.slice(1,t),port:e[t+1]===`:`?e.slice(t+2):void 0}}let t=e.lastIndexOf(`:`);return t>-1&&e.indexOf(`:`)===t?{hostname:e.slice(0,t),port:e.slice(t+1)}:{hostname:e}}function E(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}async function D(e){await e.close()}export{b as n,l as r,y as t};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
kind: 'url';
|
|
4
|
-
url: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
} | {
|
|
7
|
-
kind: 'path';
|
|
8
|
-
path: string;
|
|
9
|
-
};
|
|
1
|
+
import { p as LocalInstallSource } from "./sdk-contracts.js";
|
|
2
|
+
//#region packages/provision-kit/src/install-source.d.ts
|
|
10
3
|
/**
|
|
11
4
|
* @public Archive extensions accepted by install-source resolution.
|
|
12
5
|
*/
|
|
@@ -14,4 +7,4 @@ declare const ARCHIVE_EXTENSIONS: readonly [".zip", ".tar", ".tar.gz", ".tgz"];
|
|
|
14
7
|
declare function validateDownloadSourceUrl(parsedUrl: URL): Promise<void>;
|
|
15
8
|
declare function isTrustedInstallSourceUrl(sourceUrl: string | URL): boolean;
|
|
16
9
|
//#endregion
|
|
17
|
-
export { ARCHIVE_EXTENSIONS, type MaterializeInstallSource, isTrustedInstallSourceUrl, validateDownloadSourceUrl };
|
|
10
|
+
export { ARCHIVE_EXTENSIONS, type LocalInstallSource as MaterializeInstallSource, isTrustedInstallSourceUrl, validateDownloadSourceUrl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,w as t,y as n}from"./sdk-contracts.js";import{t as r}from"./path-resolution.js";import{a as i,i as a,n as o,r as s,t as c}from"./byte-limit-stream.js";import l from"node:path";import{createWriteStream as u,promises as d}from"node:fs";import f from"node:os";import{AsyncLocalStorage as p}from"node:async_hooks";import{pipeline as m}from"node:stream/promises";import h from"node:net";import g from"node:dns/promises";import _ from"ipaddr.js";import{Agent as v,ProxyAgent as ee,request as te}from"undici";async function y(t,n){let r=await d.stat(t).catch(()=>null);if(!r)throw new e(`INVALID_ARGS`,`App source not found: ${t}`);if(n.isInstallablePath(t,r))return{archivePath:n.archivePath,installablePath:t};if(r.isFile()&&w(t))return C(t,n,!1),await b(t,n);if(r.isDirectory()){let r=await S(t,n.isInstallablePath);if(r.length===1)return{archivePath:n.archivePath,installablePath:r[0]};if(r.length>1)throw new e(`INVALID_ARGS`,`Found multiple ${n.installableLabel} candidates under ${t}: ${r.join(`, `)}`,{matches:r});let i=await S(t,(e,t)=>!!(t.isFile()&&w(e)));if(i.length===1)return C(i[0],n,!0),await b(i[0],n);if(i.length>1)throw new e(`INVALID_ARGS`,`Found multiple nested archives under ${t}; expected one ${n.installableLabel} source`,{matches:i})}throw new e(`INVALID_ARGS`,`Expected ${n.installableLabel} source, but got ${t}`)}async function b(e,t){let n=await x(e,t.budget,t.archiveDepth+1);return t.onArchiveAccepted?.(t.archiveDepth+1),t.registerCleanup(n.cleanup),await y(n.outputPath,{...t,archivePath:t.archivePath??e,archiveDepth:t.archiveDepth+1})}async function x(t,n,r){let i=o(t);if(!i)throw new e(`INVALID_ARGS`,`Unsupported archive: ${t}`);let a=await d.mkdtemp(l.join(f.tmpdir(),`agent-device-archive-`)),c=l.join(a,`extracted`);try{return await s({archivePath:t,outputRoot:c,type:i,budget:n,depth:r}),{outputPath:c,cleanup:async()=>await d.rm(a,{recursive:!0,force:!0})}}catch(e){throw await d.rm(a,{recursive:!0,force:!0}),e}}async function S(e,t){let n=[],r=[{path:e,depth:0}];for(;r.length>0;){let e=r.shift();if(!e)continue;let i=await d.readdir(e.path,{withFileTypes:!0});i.sort((e,t)=>e.name.localeCompare(t.name));for(let a of i){if(a.name===`__MACOSX`||a.name.startsWith(`._`))continue;let i=l.join(e.path,a.name);t(i,a)?n.push(i):a.isDirectory()&&e.depth<5&&r.push({path:i,depth:e.depth+1})}}return[...new Set(n)]}function C(t,n,r){if(!n.allowArchiveExtraction)throw new e(`INVALID_ARGS`,r?`URL sources must point directly to a ${n.installableLabel}; nested archives are not allowed`:`URL sources must point directly to a ${n.installableLabel}; archive extraction is not allowed`,{path:t})}function w(e){return o(e)!==void 0}const T=new p;async function E(e){return await T.run({budget:new a,depth:0},e)}function D(){return T.getStore()?.budget}function ne(){return T.getStore()?.depth??0}function O(e){let t=T.getStore();t&&(t.depth=Math.max(t.depth,e))}async function k(n,r){if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new e(`INVALID_ARGS`,`Unsupported source URL protocol: ${n.protocol}`);if(n.username||n.password)throw new e(`INVALID_ARGS`,`Source URL credentials are not allowed`);j(r);let i=F(n.hostname);N(i)&&L(n.hostname);let a=h.isIP(i);if(a)return{address:i,family:a};let o;try{o=await A(i,r)}catch(n){throw t(n)?n:new e(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`},n)}if(o.length===0)throw new e(`INVALID_ARGS`,`Source URL host could not be resolved: ${i}`,{hint:`Use a public artifact URL.`});o.some(e=>P(e.address))&&L(i);let s=o[0];return{address:s.address,family:s.family}}async function A(e,t){let n=g.lookup(e,{all:!0,verbatim:!0});return t?await new Promise((e,r)=>{let i=()=>r(M(t.reason));t.addEventListener(`abort`,i,{once:!0}),n.then(e,r).finally(()=>t.removeEventListener(`abort`,i))}):await n}function j(e){if(e?.aborted)throw M(e.reason)}function M(e){return n(void 0,e)}function N(e){let t;try{t=F(e)}catch{return!0}return!t||t===`localhost`||t.endsWith(`.localhost`)?!0:h.isIP(t)!==0&&P(t)}function P(e){try{return _.process(I(e)).range()!==`unicast`}catch{return!0}}function F(t){let n=I(t).toLowerCase().replace(/\.$/,``);if(!n||n.includes(`%`))throw new e(`INVALID_ARGS`,`Source URL host is not allowed`,{hint:`Use a public artifact URL.`});return n}function I(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}function L(t){throw new e(`INVALID_ARGS`,`Source URL host is not allowed because it resolves to a non-public address: ${t}`,{hint:`Use a public artifact URL.`})}async function R(e){let t=z(e.url),n=t?H(t,e.url):V(e.approvedAddress,e.family),r=t?U(e.url,e.approvedAddress,e.family):e.url;try{let i=await te(r,{dispatcher:n,headers:t?{...e.headers,host:e.url.host}:e.headers,maxRedirections:0,method:`GET`,signal:e.signal});return{statusCode:i.statusCode,headers:i.headers,body:i.body,close:async()=>await K(n)}}catch(e){throw await K(n),e}}function z(e,t=process.env){if(B(e,t.no_proxy??t.NO_PROXY))return;let n=t.http_proxy??t.HTTP_PROXY;return e.protocol===`http:`?n||void 0:(t.https_proxy??t.HTTPS_PROXY)||n||void 0}function B(e,t){if(!t)return!1;let n=G(e.hostname).toLowerCase(),r=e.port||(e.protocol===`https:`?`443`:`80`);return t.split(/[\s,]+/).filter(Boolean).some(e=>{if(e===`*`)return!0;let t=W(e);if(t.port&&t.port!==r)return!1;let i=t.hostname.replace(/^\*?\./,``).toLowerCase();return n===i||n.endsWith(`.${i}`)})}function V(e,t){return new v({connect:{lookup:(n,r,i)=>i(null,e,t)}})}function H(e,t){let n=h.isIP(G(t.hostname))!==0;return new ee({uri:e,proxyTunnel:!0,requestTls:t.protocol===`https:`&&!n?{servername:G(t.hostname)}:void 0})}function U(e,t,n){let r=new URL(e);return r.hostname=n===6?`[${G(t)}]`:t,r}function W(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t<0?{hostname:e}:{hostname:e.slice(1,t),port:e[t+1]===`:`?e.slice(t+2):void 0}}let t=e.lastIndexOf(`:`);return t>-1&&e.indexOf(`:`)===t?{hostname:e.slice(0,t),port:e.slice(t+1)}:{hostname:e}}function G(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e}async function K(e){await e.close()}const q=new Set([301,302,303,307,308]),J=new Set([`accept-encoding`,`connection`,`content-length`,`host`,`keep-alive`,`proxy-connection`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]);async function re(e){let t=ue(e.url),n=se(e.headers);for(let r=0;;r+=1){let i=await Y(t,n,e.signal);try{let a=X(i,t,r);if(a){a.origin!==t.origin&&(n=ce(n)),t=a;continue}return ie(i),await ae(e.tempDir,t,i)}finally{await i.close()}}}async function Y(t,n,r){let i=await k(t,r);try{return await R({url:t,approvedAddress:i.address,family:i.family,headers:{...n,"accept-encoding":`identity`},signal:r})}catch(t){throw t instanceof e?t:new e(`COMMAND_FAILED`,`App source network request failed`,void 0,t)}}function X(t,n,r){if(!q.has(t.statusCode))return;t.body.resume?.();let i=Z(t.headers,`location`);if(!i||r>=5)throw new e(`COMMAND_FAILED`,`App source redirect limit was exceeded`,{status:t.statusCode});let a=new URL(i,n);if(n.protocol===`https:`&&a.protocol!==`https:`)throw new e(`COMMAND_FAILED`,`App source redirect downgraded HTTPS`);return a}function ie(t){if(!(t.statusCode>=200&&t.statusCode<300))throw new e(`COMMAND_FAILED`,`Failed to download app source: ${t.statusCode}`,{status:t.statusCode})}async function ae(t,n,r){let a=Z(r.headers,`content-encoding`);if(a&&a.toLowerCase()!==`identity`)throw new e(`COMMAND_FAILED`,`App source response used unsupported content encoding`);oe(Z(r.headers,`content-length`));let o=l.join(t,le(r,n)),s=c({maxBytes:i,createLimitError:()=>new e(`COMMAND_FAILED`,`App source exceeds maximum size of ${i} bytes`,{reason:`ARTIFACT_BYTE_LIMIT`})});try{return await m(r.body,s,u(o,{flags:`wx`})),o}catch(e){throw await d.rm(o,{force:!0}).catch(()=>{}),e}}function oe(t){if(t===null)return;if(!/^\d+$/.test(t))throw new e(`COMMAND_FAILED`,`App source response had invalid content-length`);let n=Number(t);if(!Number.isSafeInteger(n)||n>2147483648)throw new e(`COMMAND_FAILED`,`App source response exceeded the byte limit`,{reason:`ARTIFACT_BYTE_LIMIT`})}function se(e){let t=new Set(Object.entries(e??{}).filter(([e])=>e.toLowerCase()===`connection`).flatMap(([,e])=>e.split(`,`).map(e=>e.trim().toLowerCase())));return Object.fromEntries(Object.entries(e??{}).filter(([e])=>{let n=e.toLowerCase();return!J.has(n)&&!t.has(n)}))}function ce(e){return Object.fromEntries(Object.entries(e).filter(([e])=>[`accept`,`user-agent`].includes(e.toLowerCase())))}function le(e,t){let n=(Z(e.headers,`content-disposition`)?.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i))?.[1]?.trim()||l.basename(t.pathname)||`downloaded-artifact.bin`;return l.basename(n)}function Z(e,t){let n=e[t];return Array.isArray(n)?n[0]??null:n??null}function ue(t){let n;try{n=new URL(t)}catch{throw new e(`INVALID_ARGS`,`Invalid source URL`)}if(n.username||n.password)throw new e(`INVALID_ARGS`,`Source URL credentials are not allowed`);return n}const de=Object.freeze([`.zip`,`.tar`,`.tar.gz`,`.tgz`]);async function fe(e){let t=[];try{let n=await me(e.source,{signal:e.signal,downloadTimeoutMs:e.downloadTimeoutMs});t.push(n.cleanup);let r=await y(n.localPath,{archivePath:void 0,isInstallablePath:e.isInstallablePath,installableLabel:e.installableLabel,allowArchiveExtraction:e.allowArchiveExtraction!==!1,registerCleanup:e=>{t.push(e)},budget:D()??new a,archiveDepth:0,onArchiveAccepted:O});return{archivePath:r.archivePath,installablePath:r.installablePath,cleanup:async()=>{await $(t)}}}catch(e){throw await $(t),e}}function pe(e){return r(e)}async function me(e,t){if(e.kind===`path`)return{localPath:pe(e.path),cleanup:async()=>{}};let n=await d.mkdtemp(l.join(f.tmpdir(),`agent-device-source-`));try{return{localPath:await Q(n,e.url,e.headers,t),cleanup:async()=>{await d.rm(n,{recursive:!0,force:!0})}}}catch(e){throw await d.rm(n,{recursive:!0,force:!0}),e}}async function Q(e,t,r,i){let a=i?.signal;if(a?.aborted)throw n();let o=i?.downloadTimeoutMs??12e4,s=AbortSignal.timeout(o),c=a?AbortSignal.any([a,s]):s;try{return await re({tempDir:e,url:t,headers:r,signal:c})}catch(e){throw he(e,a,s,o)}}function he(t,r,i,a){return r?.aborted?n(void 0,t):i.aborted?new e(`COMMAND_FAILED`,`App source download timed out after ${a}ms`,{timeoutMs:a},t):t}async function ge(e){await k(e)}function _e(e){let t=e instanceof URL?e:new URL(e),n=t.hostname.toLowerCase();if(!n)return!1;let r=t.pathname;return ve(n,r)||ye(n,r)}function ve(e,t){return e===`api.github.com`?/^\/repos\/[^/]+\/[^/]+\/actions\/artifacts\/\d+\/zip$/i.test(t):e===`github.com`?/^\/[^/]+\/[^/]+\/(?:actions\/runs\/\d+\/artifacts\/\d+|suites\/\d+\/artifacts\/\d+)$/i.test(t):!1}function ye(e,t){return e!==`expo.dev`&&!e.endsWith(`.expo.dev`)?!1:/^\/(?:artifacts\/eas\/|accounts\/[^/]+\/projects\/[^/]+\/builds\/)/i.test(t)}async function $(e){for(let t of[...e].reverse())await t()}export{D as a,E as c,ge as i,_e as n,ne as o,fe as r,O as s,de as t};
|
|
1
|
+
import{x as e,y as t}from"./sdk-contracts.js";import{t as n}from"./path-resolution.js";import"./file.js";import{a as r,i,n as a,r as o}from"./archive.js";import{t as s}from"./byte-limit-stream.js";import{r as c,t as l}from"./install-source-network-transport.js";import u from"node:path";import{createWriteStream as d,promises as f}from"node:fs";import{AsyncLocalStorage as p}from"node:async_hooks";import m from"node:os";import{pipeline as h}from"node:stream/promises";async function g(e,n){let r=await f.stat(e).catch(()=>null);if(!r)throw new t(`INVALID_ARGS`,`App source not found: ${e}`);if(n.isInstallablePath(e,r))return{archivePath:n.archivePath,installablePath:e};if(r.isFile()&&x(e))return b(e,n,!1),await _(e,n);if(r.isDirectory()){let r=await y(e,n.isInstallablePath);if(r.length===1)return{archivePath:n.archivePath,installablePath:r[0]};if(r.length>1)throw new t(`INVALID_ARGS`,`Found multiple ${n.installableLabel} candidates under ${e}: ${r.join(`, `)}`,{matches:r});let i=await y(e,(e,t)=>!!(t.isFile()&&x(e)));if(i.length===1)return b(i[0],n,!0),await _(i[0],n);if(i.length>1)throw new t(`INVALID_ARGS`,`Found multiple nested archives under ${e}; expected one ${n.installableLabel} source`,{matches:i})}throw new t(`INVALID_ARGS`,`Expected ${n.installableLabel} source, but got ${e}`)}async function _(e,t){let n=await v(e,t.budget,t.archiveDepth+1);return t.onArchiveAccepted?.(t.archiveDepth+1),t.registerCleanup(n.cleanup),await g(n.outputPath,{...t,archivePath:t.archivePath??e,archiveDepth:t.archiveDepth+1})}async function v(e,n,r){let i=a(e);if(!i)throw new t(`INVALID_ARGS`,`Unsupported archive: ${e}`);let s=await f.mkdtemp(u.join(m.tmpdir(),`agent-device-archive-`)),c=u.join(s,`extracted`);try{return await o({archivePath:e,outputRoot:c,type:i,budget:n,depth:r}),{outputPath:c,cleanup:async()=>await f.rm(s,{recursive:!0,force:!0})}}catch(e){throw await f.rm(s,{recursive:!0,force:!0}),e}}async function y(e,t){let n=[],r=[{path:e,depth:0}];for(;r.length>0;){let e=r.shift();if(!e)continue;let i=await f.readdir(e.path,{withFileTypes:!0});i.sort((e,t)=>e.name.localeCompare(t.name));for(let a of i){if(a.name===`__MACOSX`||a.name.startsWith(`._`))continue;let i=u.join(e.path,a.name);t(i,a)?n.push(i):a.isDirectory()&&e.depth<5&&r.push({path:i,depth:e.depth+1})}}return[...new Set(n)]}function b(e,n,r){if(n.allowArchiveExtraction)return;let i=r?`URL sources must point directly to a ${n.installableLabel}; nested archives are not allowed`:`URL sources must point directly to a ${n.installableLabel}; archive extraction is not allowed`;throw new t(`INVALID_ARGS`,i,{path:e})}function x(e){return a(e)!==void 0}const S=new p;async function C(e){return await S.run({budget:new i,depth:0},e)}function w(){return S.getStore()?.budget}function T(){return S.getStore()?.depth??0}function E(e){let t=S.getStore();t&&(t.depth=Math.max(t.depth,e))}const D=new Set([301,302,303,307,308]),O=new Set([`accept-encoding`,`connection`,`content-length`,`host`,`keep-alive`,`proxy-connection`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`]);async function k(e){let t=z(e.url),n=F(e.headers);for(let r=0;;r+=1){let i=await A(t,n,e.signal);try{let a=j(i,t,r);if(a){a.origin!==t.origin&&(n=I(n)),t=a;continue}return M(i),await N(e.tempDir,t,i)}finally{await i.close()}}}async function A(e,n,r){let i=await c(e,r);try{return await l({url:e,approvedAddress:i.address,family:i.family,headers:{...n,"accept-encoding":`identity`},signal:r})}catch(e){throw e instanceof t?e:new t(`COMMAND_FAILED`,`The daemon failed to fetch the app source`,void 0,e)}}function j(e,n,r){if(!D.has(e.statusCode))return;e.body.resume?.();let i=R(e.headers,`location`);if(!i||r>=5)throw new t(`COMMAND_FAILED`,`App source redirect limit was exceeded`,{status:e.statusCode});let a=new URL(i,n);if(n.protocol===`https:`&&a.protocol!==`https:`)throw new t(`COMMAND_FAILED`,`App source redirect downgraded HTTPS`);return a}function M(e){if(!(e.statusCode>=200&&e.statusCode<300))throw new t(`COMMAND_FAILED`,`Failed to download app source: ${e.statusCode}`,{status:e.statusCode})}async function N(e,n,i){let a=R(i.headers,`content-encoding`);if(a&&a.toLowerCase()!==`identity`)throw new t(`COMMAND_FAILED`,`App source response used unsupported content encoding`);P(R(i.headers,`content-length`));let o=u.join(e,L(i,n)),c=s({maxBytes:r,createLimitError:()=>new t(`COMMAND_FAILED`,`App source exceeds maximum size of ${r} bytes`,{reason:`ARTIFACT_BYTE_LIMIT`})});try{return await h(i.body,c,d(o,{flags:`wx`})),o}catch(e){throw await f.rm(o,{force:!0}).catch(()=>{}),e}}function P(e){if(e===null)return;if(!/^\d+$/.test(e))throw new t(`COMMAND_FAILED`,`App source response had invalid content-length`);let n=Number(e);if(!Number.isSafeInteger(n)||n>2147483648)throw new t(`COMMAND_FAILED`,`App source response exceeded the byte limit`,{reason:`ARTIFACT_BYTE_LIMIT`})}function F(e){let t=new Set(Object.entries(e??{}).filter(([e])=>e.toLowerCase()===`connection`).flatMap(([,e])=>e.split(`,`).map(e=>e.trim().toLowerCase())));return Object.fromEntries(Object.entries(e??{}).filter(([e])=>{let n=e.toLowerCase();return!O.has(n)&&!t.has(n)}))}function I(e){return Object.fromEntries(Object.entries(e).filter(([e])=>[`accept`,`user-agent`].includes(e.toLowerCase())))}function L(e,t){let n=(R(e.headers,`content-disposition`)?.match(/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i))?.[1]?.trim()||u.basename(t.pathname)||`downloaded-artifact.bin`;return u.basename(n)}function R(e,t){let n=e[t];return Array.isArray(n)?n[0]??null:n??null}function z(e){let n;try{n=new URL(e)}catch{throw new t(`INVALID_ARGS`,`Invalid source URL`)}if(n.username||n.password)throw new t(`INVALID_ARGS`,`Source URL credentials are not allowed`);return n}const B=Object.freeze([`.zip`,`.tar`,`.tar.gz`,`.tgz`]);async function V(e){let t=[];try{let n=await U(e.source,{signal:e.signal,downloadTimeoutMs:e.downloadTimeoutMs});t.push(n.cleanup);let r=await g(n.localPath,{archivePath:void 0,isInstallablePath:e.isInstallablePath,installableLabel:e.installableLabel,allowArchiveExtraction:e.allowArchiveExtraction!==!1,registerCleanup:e=>{t.push(e)},budget:w()??new i,archiveDepth:0,onArchiveAccepted:E});return{archivePath:r.archivePath,installablePath:r.installablePath,cleanup:async()=>{await X(t)}}}catch(e){throw await X(t),e}}function H(e){return n(e)}async function U(e,t){if(e.kind===`path`)return{localPath:H(e.path),cleanup:async()=>{}};let n=await f.mkdtemp(u.join(m.tmpdir(),`agent-device-source-`));try{return{localPath:await W(n,e.url,e.headers,t),cleanup:async()=>{await f.rm(n,{recursive:!0,force:!0})}}}catch(e){throw await f.rm(n,{recursive:!0,force:!0}),e}}async function W(t,n,r,i){let a=i?.signal;if(a?.aborted)throw e();let o=i?.downloadTimeoutMs??12e4,s=AbortSignal.timeout(o),c=a?AbortSignal.any([a,s]):s;try{return await k({tempDir:t,url:n,headers:r,signal:c})}catch(e){throw G(e,a,s,o)}}function G(n,r,i,a){return r?.aborted?e(void 0,n):i.aborted?new t(`COMMAND_FAILED`,`App source download timed out after ${a}ms`,{timeoutMs:a},n):n}async function K(e){await c(e)}function q(e){let t=e instanceof URL?e:new URL(e),n=t.hostname.toLowerCase();if(!n)return!1;let r=t.pathname;return J(n,r)||Y(n,r)}function J(e,t){return e===`api.github.com`?/^\/repos\/[^/]+\/[^/]+\/actions\/artifacts\/\d+\/zip$/i.test(t):e===`github.com`&&/^\/[^/]+\/[^/]+\/(?:actions\/runs\/\d+\/artifacts\/\d+|suites\/\d+\/artifacts\/\d+)$/i.test(t)}function Y(e,t){return e!==`expo.dev`&&!e.endsWith(`.expo.dev`)?!1:/^\/(?:artifacts\/eas\/|accounts\/[^/]+\/projects\/[^/]+\/builds\/)/i.test(t)}async function X(e){for(let t of[...e].reverse())await t()}export{w as a,C as c,K as i,q as n,T as o,V as r,E as s,B as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{_r as t,fr as n,hr as r,mr as i,pr as a}from"./sdk-batch.js";function o(e){return e?.startsWith(`@`)?e.slice(1):e}const s=/^e\d+$/;function c(n){if(n[0]?.startsWith(`@`)){let e=_(n.slice(1));return{ref:n[0],...e===void 0?{}:{label:e}}}if(s.test(n[0]??``))throw new e(`INVALID_ARGS`,`Did you mean "@${n[0]}"? Snapshot refs need the @ prefix.`);let r=t(n);if(r){if(r.rest.length>0)throw new e(`INVALID_ARGS`,m(n,r));return{selector:r.selectorExpression}}return u(n)}function l(n){let r=n[0];if(r?.startsWith(`@`)){let e=n.slice(1),t=e.length===0?void 0:e.join(` `);return{kind:`ref`,target:{ref:r},text:t}}if(s.test(r??``))throw new e(`INVALID_ARGS`,`Did you mean "@${r}"? Snapshot refs need the @ prefix.`);let i=t(n,{preferTrailingValue:!0});if(i)return{kind:`selector`,target:{selector:i.selectorExpression},text:i.rest.length===0?void 0:i.rest.join(` `)};let a=n.slice(2);return{kind:`point`,target:u(n.slice(0,2)),text:a.length===0?void 0:a.join(` `)}}function u(t){let n=t[0]??``,r=a(n);if(r){let i=d(n)?r.value:[r.value,...t.slice(1)].join(` `).trim();throw new e(`INVALID_ARGS`,f({key:r.key,value:i}))}let i=Number(t[0]),o=Number(t[1]);if(Number.isFinite(i)&&Number.isFinite(o))return{x:i,y:o};throw new e(`INVALID_ARGS`,p(t))}function d(e){let t=e.slice(e.indexOf(`=`)+1).trim();if(t.length<2)return!1;let n=t[0];return(n===`"`||n===`'`)&&t.endsWith(n)}function f(e){let{key:t,value:r}=e;return`Unknown selector key "${t}". Supported: ${n.join(`, `)}. ${i(t)?`Did you mean role=${t} label=${g(r)}?`:`Did you mean label=${g(r)}?`}`}function p(e){let t=e.filter(e=>e!==void 0).join(` `);if(!t.trim())return`Missing target. Pass an @ref from snapshot, a selector like text="Sign in", or "x y" coordinates.`;let n=`Target "${t}" is not a @ref, selector, or "x y" point.`;return e.some(e=>r(e??``))?`${n} Selector values with spaces need quotes, e.g. text="Sign in".`:`${n} To match by visible text, use text=${g(t)} (or label=/id=/role=), or pass an @ref from snapshot.`}function m(e,t){return`${`Selector ${t.selectorExpression} is followed by unexpected extra arguments: "${t.rest.join(` `)}".`} Selector values with spaces need quotes, e.g. ${h(e,t)??`text="Sign in"`}.`}function h(e,t){let n=e.length-t.rest.length,r=e[n-1];if(r===void 0)return;let i=r.indexOf(`=`);if(i<=0)return;let a=[r.slice(i+1),...t.rest].join(` `),o=`${r.slice(0,i+1)}${g(a)}`;return[...e.slice(0,n-1),o].join(` `)}function g(e){return`"${e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}"`}function _(e){return e.join(` `).trim()||void 0}export{c as n,o as r,l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,y as t}from"./sdk-contracts.js";import{l as n,v as r}from"./sdk-device.js";import{on as i}from"./sdk-batch.js";import{i as a,s as o}from"./session-target-evidence.js";import{M as s,f as c,o as l,t as u}from"./parameterized-recorded-fill.js";import{t as d}from"./runtime.js";import{i as f}from"./mobile-snapshot-semantics.js";import{r as p}from"./request-cancel.js";import"./request.js";import{r as m}from"./provider-device-runtime.js";import{r as h}from"./request-runtime-binding.js";import{C as g,_,i as v,o as y,v as b,y as x}from"./session-snapshot.js";import{n as S}from"./platform-runtime-apple-resources.js";import{n as C}from"./internal/daemon.js";function w(e){let{req:t,logPath:n,traceLogPath:r}=e;return{verbose:t.flags?.verbose,logPath:n,traceLogPath:r,requestId:t.meta?.requestId,iosXctestrunFile:t.flags?.iosXctestrunFile,iosXctestDerivedDataPath:t.flags?.iosXctestDerivedDataPath,iosXctestEnvDir:t.flags?.iosXctestEnvDir}}function T(e,t){return!(!e||!n(e.device)||m(e.device)||t.skipPendingPostGestureStabilization&&_(e))}function E(e){let{session:t,selectorExpression:n}=e;return T(t,{skipPendingPostGestureStabilization:!0})?i(n):null}function D(e){let t=e.identifier?.trim();if(t)return{key:`id`,value:t};let n=e.label?.trim();return n?{key:`label`,value:n}:null}async function O(e,t,n){let r=await S(e.device,t,e.appBundleId,n),i=r.found===!0,a=k(r);return{found:i,...typeof r.text==`string`?{text:r.text}:{},...a?{node:a}:{}}}function k(e){let t=e.nodes;if(!Array.isArray(t))return;let n=t[0];if(!(!n||typeof n!=`object`))return n}function A(t,n={}){let r=e(t);if(r.code===`ELEMENT_NOT_FOUND`)return n.delegateSemanticFailures===!0||n.allowElementNotFound===!0;if(r.code===`AMBIGUOUS_MATCH`)return n.delegateSemanticFailures===!0;if(r.code===`ELEMENT_OFFSCREEN`)return n.delegateSemanticFailures!==!1;if(r.code!==`COMMAND_FAILED`)return!1;let i=r.message.toLowerCase();return i.includes(`fetch failed`)||i.includes(`timed out`)||i.includes(`timeout`)||i.includes(`runner did not accept connection`)||i.includes(`invalid runner response`)}async function j(e){let{session:t,node:n,rootViewport:r,requestOptions:i}=e,a=D(n);if(!a)return null;let o;try{o=await O(t,a,i)}catch{return null}if(!o.found||!o.node?.rect)return null;let s={rect:o.node.rect,hittable:o.node.hittable===!0};return f(s,r)?s.rect:null}function M(e){let{operations:t,command:n,positionals:r,actionCommand:i=n,retryPositionals:o,flags:s,result:c,responseData:l,recordedTarget:u,recordedTargets:d,scheduleInteractionOutcomeRetry:f=!0,actionStartedAt:p,actionFinishedAt:m,androidFreshnessBaseline:h}=e,g=x(s),[_,v]=P({command:n,positionals:r,flags:g,result:c,responseData:l}),y=t.isSessionRecording()&&u?a(u):void 0,b=t.isSessionRecording()&&d?N(d):void 0;return t.recordAction({command:n,positionals:r,flags:g??{},result:_,...y?{targetEvidence:y}:{},...b?{targetEvidences:b}:{}}),t.markDeferredOutcome({command:n,action:i,positionals:o??r,flags:s,scheduleOutcomeRetry:f,androidFreshnessBaseline:h}),t.recordGestureVisualization(i,r,_,g??{},p,m),{ok:!0,data:v}}function N(e){let t=a(e.source),n=a(e.destination);return t&&n?{source:t,destination:n}:void 0}function P(e){if(e.command!==`fill`||typeof e.flags?.recordAs!=`string`)return[e.result,e.responseData];let t=l({ts:0,command:`fill`,positionals:e.positionals,flags:e.flags,result:e.result}),n=s(e.flags.recordAs);return[u(e.result,t,n),u(e.responseData,t,n)]}function F(e){let n=e.sessionStore.get(e.sessionName);if(!n)throw new t(`SESSION_NOT_FOUND`,h);return L({requestId:e.req.meta?.requestId,flags:e.req.flags,session:n,contextFromFlags:e.contextFromFlags,captureSnapshot:async(t,r)=>await e.captureSnapshotForSession(n,t,e.sessionStore,e.contextFromFlags,r),runtimeSessions:y({sessionName:e.sessionName,getSession:()=>n,recordOptions:{includeSnapshot:!0,omitRefFrameSnapshot:e.req.internal?.findResolvedTarget!==void 0},setRecord:t=>{t.snapshot&&(v(n,t.snapshot),e.sessionStore.set(e.sessionName,n))}}),expireRefFrame:()=>g(n),confirmOffscreenTargetVisible:T(n,{skipPendingPostGestureStabilization:!1})?async(t,r)=>await j({session:n,node:t,rootViewport:r,requestOptions:w({req:e.req,logPath:e.logPath,traceLogPath:n.trace?.outPath})}):void 0,pairedGestureViewport:e.pairedGestureViewport,touchExecutor:e.touchExecutor,gestures:e.gestures})}function I(e){let{session:t,sessionStore:n,...r}=e;return M({...r,operations:{recordAction:n.recordAction.bind(n,t),markDeferredOutcome:e=>b({session:t,...e}),isSessionRecording:c.bind(null,t),recordGestureVisualization:C.bind(null,t)}})}function L(e){return d({backend:R(e),...o(`interaction commands`,{plural:!0}),sessions:e.runtimeSessions,signal:p(e.requestId)})}function R(e){let{flags:t,session:n}=e;return{platform:r(n.device),captureSnapshot:async(n,r)=>({snapshot:await e.captureSnapshot(t,{interactiveOnly:r?.interactiveOnly===!0,preferredBackend:r?.preferredBackend,includeRects:r?.includeRects===!0,signal:n.signal,boundCapture:e.touchExecutor?.captureSnapshot??e.gestures?.captureSnapshot})}),...z(e,()=>e.contextFromFlags(t,n.appBundleId,n.trace?.outPath)),...e.confirmOffscreenTargetVisible?{confirmOffscreenTargetVisible:async(t,n,r)=>await e.confirmOffscreenTargetVisible(n,r)}:{},...B(e.touchExecutor,e.expireRefFrame,t)}}function z(e,t){let n=e.gestures,r=e.pairedGestureViewport;return n?{resolveGestureViewport:async()=>r??await n.gestureViewport?.(t()),performGesture:async(r,i)=>(e.expireRefFrame(),V(await n.performPlan(i,t())))}:r?{resolveGestureViewport:async()=>r}:{}}function B(e,t,n){if(!e)return{};let{tapPoint:r,tapRef:i,fillPoint:a,fillRef:o,longPressPoint:s,hoverPoint:c,hoverRef:l}=e,u=async e=>(t(),V(await e()));return{tap:r?(e,t)=>u(()=>r(t,n)):void 0,tapTarget:i?(e,t)=>u(()=>i(t.ref)):void 0,fill:a?(e,t,n,r)=>u(()=>a(t,n,r)):void 0,fillTarget:o?(e,t,n,r)=>u(()=>o(t.ref,n,r)):void 0,longPress:s?(e,t,n)=>u(()=>s(t,n?.durationMs)):void 0,hover:c?(e,t)=>u(()=>c(t)):void 0,hoverTarget:l?(e,t)=>u(()=>l(t.ref)):void 0}}function V(e){return e&&typeof e==`object`?e:void 0}function H(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}function U(e,t){if(!t||t.settle===!0)return null;let n=[];return t.settleQuietMs!==void 0&&n.push(`--settle-quiet`),n.length===0?null:H(`INVALID_ARGS`,`${e}: ${n.join(`, `)} require${n.length===1?`s`:``} --settle.`)}function W(e){if(e?.settle===!0)return{...e.settleQuietMs===void 0?{}:{quietMs:e.settleQuietMs},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}}function G(e){try{return K(e),null}catch(e){if(e instanceof t)return H(e.code,e.message,e.details);throw e}}function K(e){let n=e.ref.startsWith(`@`)?e.ref.slice(1):e.ref,{admission:r,scope:i,currentGeneration:a}=e.frame;if(r.admitted)return;let o=r.reason===`plain_ref_requires_complete_frame`&&i!==`all`&&i.has(n)&&a!==void 0?`@${n}~s${a}`:void 0;throw new t(`COMMAND_FAILED`,J(r.reason,e.ref),{reason:r.reason,ref:e.ref,currentGeneration:a,scope:i===`all`?`all`:Array.from(i),...e.mintedGeneration===void 0?{}:{mintedGeneration:e.mintedGeneration},...o?{suggestedRef:o}:{},hint:o?`Retry with the exact emitted ref ${o}.`:e.staleRefsWarning??q})}const q=`Capture a fresh interactive snapshot (snapshot -i) or use a stable selector, then retry.`;function J(e,t){switch(e){case`ref_frame_expired`:return`Ref ${t} belongs to an expired ref frame — a device action since the snapshot invalidated it`;case`ref_generation_mismatch`:return`Ref ${t} was minted from a superseded snapshot generation`;case`plain_ref_requires_complete_frame`:return`Ref ${t} needs a complete snapshot — the current frame only authorizes its emitted refs`;case`ref_not_issued`:return`Ref ${t} was not issued by the current ref frame`}}export{F as a,T as c,U as i,E as l,G as n,I as o,W as r,A as s,K as t};
|
package/dist/src/interaction.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{Kn as t,_r as n}from"./sdk-batch-runner.js";import{t as r}from"./string-enum.js";const i=1e4,a=2e3,o=[`get`,`accept`,`dismiss`,`wait`],s=[`in-app`,`system`],c=[`primary`,`secondary`,`middle`];function l(e){return e?.clickButton??`primary`}function u(t){return t.button===`primary`?null:t.commandLabel===`click`?t.platform!==`macos`&&t.platform!==`linux`?new e(`UNSUPPORTED_OPERATION`,`click --button ${t.button} is supported only on macOS and Linux`):t.platform===`macos`&&t.button===`middle`?new e(`UNSUPPORTED_OPERATION`,`click --button middle is not supported by the macOS runner yet`):typeof t.count==`number`||typeof t.intervalMs==`number`||typeof t.holdMs==`number`||typeof t.jitterPx==`number`||t.doubleTap===!0?new e(`INVALID_ARGS`,`click --button ${t.button} does not support repeat or gesture modifier flags`):null:new e(`INVALID_ARGS`,`--button is supported only for click`)}function d(e){return e===`primary`?{}:{button:e}}const ee=[`up`,`down`,`left`,`right`,`top`,`bottom`],f=[`up`,`down`,`left`,`right`],p=[`left`,`right`,`left-edge`,`right-edge`],te=[`one-way`,`ping-pong`],ne=1e4,re=6e4,ie=r(f,{message:e=>`Unknown direction: ${e}`});function ae(e){let t=e.direction,n=t===`up`||t===`down`?e.referenceHeight:e.referenceWidth,r=v(e.amount),i=e.pixels===void 0?Math.round(n*r):fe(e.pixels),a=Math.max(1,Math.round(n*.1)),o=Math.max(1,n-a*2),s=Math.max(1,Math.min(i,o)),c=Math.round(s/2),l=Math.round(e.referenceWidth/2),u=Math.round(e.referenceHeight/2),d=(n,r,i,a)=>({direction:t,x1:n,y1:r,x2:i,y2:a,referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:s});switch(t){case`up`:return d(l,u-c,l,u+c);case`down`:return d(l,u+c,l,u-c);case`left`:return d(l-c,u,l+c,u);case`right`:return d(l+c,u,l-c,u)}}function oe(e){v(e.amount),e.pixels!==void 0&&fe(e.pixels)}function se(e,t){if(e===`left`||e===`right`){let n=m(e,t);return{preset:e,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,referenceWidth:n.referenceWidth,referenceHeight:n.referenceHeight}}let[n,r]=e===`left-edge`?[99,15]:[1,85],i=g(h(t,n,50),t,8),a=g(h(t,r,50),t,8);return{preset:e,x1:i.x,y1:i.y,x2:a.x,y2:a.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function ce(e,t){switch(e){case`up`:return{x:0,y:-t};case`down`:return{x:0,y:t};case`left`:return{x:-t,y:0};case`right`:return{x:t,y:0}}}function m(e,t){let n=e===`left`||e===`up`,r=n?85:15,i=n?15:85,a=e===`up`||e===`down`,o=g(h(t,a?50:r,a?r:50),t,8),s=g(h(t,a?50:i,a?i:50),t,8);return{direction:e,x1:o.x,y1:o.y,x2:s.x,y2:s.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function le(e){let t=de(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function h(e,t,n){let r=Math.trunc(e.referenceWidth*t/100),i=Math.trunc(e.referenceHeight*n/100);return{x:Number.isFinite(r)?r:0,y:Number.isFinite(i)?i:0}}function g(e,t,n){return{x:y(e.x,n,t.referenceWidth),y:y(e.y,n,t.referenceHeight)}}function ue(e){return ie.parse(e)}function de(e){let t=e.filter(e=>n(e)&&_(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let r=e.map(e=>e.rect).filter(_);if(r.length===0)return;let i=Math.max(...r.map(e=>e.x+e.width)),a=Math.max(...r.map(e=>e.y+e.height));if(!(i<=0||a<=0))return{x:0,y:0,width:i,height:a}}function _(e){return!!e&&e.width>0&&e.height>0}function v(t){if(t===void 0)return .6;if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`scroll amount must be a positive number`);return t}function fe(t){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`scroll pixels must be a positive integer`);return Math.max(1,Math.round(t))}function y(e,t,n){let r=Math.round(t);if(!Number.isFinite(r))return 0;let i=Math.max(r,Math.round(n-t));return!Number.isFinite(i)||!Number.isFinite(e)?r:Math.min(i,Math.max(r,Math.round(e)))}const b=1e4,x=[`pan`,`fling`,`swipe`,`pinch`,`rotate`,`transform`,`drag`];function S(n){let r=C(n),i=O(r,`kind`,x);if(i===`pan`)return{kind:i,origin:w(r,`origin`),delta:w(r,`delta`),pointerCount:t(r,`pointerCount`,{min:1,max:2}),durationMs:me(r)};if(i===`drag`)return pe(r);if(r.pointerCount!==void 0)throw new e(`INVALID_ARGS`,`pointerCount is supported only for gesture pan`);if(i===`fling`){if(r.durationMs!==void 0)throw new e(`INVALID_ARGS`,`gesture fling does not accept durationMs; use gesture pan for timed movement`);return{kind:i,direction:O(r,`direction`,f),origin:w(r,`origin`),distance:t(r,`distance`,{min:0})}}if(i===`swipe`){if(r.durationMs!==void 0)throw new e(`INVALID_ARGS`,`gesture swipe does not accept durationMs; use gesture pan for timed movement`);return{kind:i,preset:O(r,`preset`,p)}}if(i===`pinch`)return{kind:i,scale:E(r,`scale`),origin:T(r,`origin`)};if(i===`rotate`){if(r.velocity!==void 0)throw new e(`INVALID_ARGS`,`gesture rotate does not accept velocity; rotation pacing derives from degrees`);return{kind:i,degrees:E(r,`degrees`),origin:T(r,`origin`)}}return{kind:i,origin:w(r,`origin`),delta:w(r,`delta`),scale:E(r,`scale`),degrees:E(r,`degrees`),durationMs:me(r)}}function pe(n){let r=t(n,`sourceHoldMs`,{min:1,max:1e4}),i=t(n,`moveMs`,{min:16,max:1e4}),a=t(n,`destinationHoldMs`,{min:0,max:1e4});if((r??800)+(i??500)+(a??0)>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${b}`);return{kind:`drag`,source:D(n,`source`),destination:D(n,`destination`),sourceHoldMs:r,moveMs:i,destinationHoldMs:a}}function me(n){let r=t(n,`durationMs`);if(r!==void 0){if(r<16||r>1e4)throw new e(`INVALID_ARGS`,`Expected durationMs to be an integer between 16 and ${b}.`);return r}}function C(t){if(!t||typeof t!=`object`||Array.isArray(t))throw new e(`INVALID_ARGS`,`gesture requires structured object input`);return t}function w(e,t){let n=C(e[t]);return{x:E(n,`x`),y:E(n,`y`)}}function T(e,t){return e[t]===void 0?void 0:w(e,t)}function E(t,n){let r=t[n];if(typeof r!=`number`||!Number.isFinite(r))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);return r}function D(t,n){let r=t[n];if(typeof r!=`string`||r.trim().length===0)throw new e(`INVALID_ARGS`,`Expected ${n} to be a non-empty string.`);return r.trim()}function O(t,n,r){let i=t[n];if(typeof i!=`string`||!r.includes(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be one of: ${r.join(`, `)}.`);return i}const k={swipe:{max:4,usage:`swipe accepts 4 arguments: x1 y1 x2 y2`,retired:{positional:`durationMs`,migrate:he}},"gesture pan":{max:5,usage:`gesture pan accepts at most 5 arguments: x y dx dy [durationMs]`},"gesture fling":{max:4,usage:`gesture fling accepts at most 4 arguments: direction x y [distance]`,retired:{positional:`durationMs`,migrate:(e,t)=>`use "${t}", or gesture pan for timed movement.`}},"gesture swipe":{max:1,usage:`gesture swipe accepts 1 argument: preset`,retired:{positional:`durationMs`,migrate:(e,t)=>`use "${t}", or gesture pan for timed movement.`}},"gesture pinch":{max:3,usage:`gesture pinch accepts at most 3 arguments: scale [x] [y]`},"gesture rotate":{max:3,usage:`gesture rotate accepts at most 3 arguments: degrees [x] [y]`,retired:{positional:`velocity`,migrate:(e,t)=>`use "${t}"; rotation pacing derives from degrees.`}},"gesture transform":{max:7,usage:`gesture transform accepts at most 7 arguments: x y dx dy scale degrees [durationMs]`},"gesture drag":{max:5,usage:`gesture drag accepts at most 5 arguments: source destination [sourceHoldMs] [moveMs] [destinationHoldMs]`}};function he(e,t){let[n,r,i,a,o]=e,s=A(n,i),c=A(r,a);return s===void 0||c===void 0?`use "gesture pan x1 y1 dx dy durationMs" for the same timed drag, or "${t}" for a default-duration swipe.`:`use "gesture pan ${n} ${r} ${s} ${c} ${o}" for the same timed drag, or "${t}" for a default-duration swipe.`}function A(e,t){let n=Number(t)-Number(e);return Number.isFinite(n)?n:void 0}function j(e,t){let n=k[e];if(t.length<=n.max)return;let r=n.retired;if(!r||t.length!==n.max+1||!ge(t[n.max]))return{usage:n.usage};let i=`${e} ${t.slice(0,n.max).join(` `)}`;return{usage:n.usage,migration:`The trailing ${r.positional} positional was removed: ${r.migrate(t,i)}`}}function ge(e){return e===void 0||e.trim().length===0?!1:e.startsWith("${")||Number.isFinite(Number(e))}function _e(t){if(!(!t||typeof t!=`object`||Array.isArray(t))&&t.durationMs!==void 0)throw new e(`INVALID_ARGS`,`swipe does not accept durationMs; use gesture pan for timed movement`)}function ve(e,t){let n=t?`${e.usage} (${t})`:e.usage;return e.migration?`${n}. ${e.migration}`:`${n}.`}function M(t,n){let r=j(t,n);if(r)throw new e(`INVALID_ARGS`,ve(r))}function ye(e,t,n){let r=be(e,t);return r?ve(r,n):void 0}function be(e,t){if(e===`swipe`)return j(`swipe`,t);if(e!==`gesture`)return;let n=`gesture ${t[0]}`;if(Object.hasOwn(k,n))return j(n,t.slice(1))}function N(e){return{origin:{x:Number(e[0]),y:Number(e[1])},delta:{x:Number(e[2]),y:Number(e[3])}}}function P(e,t){let n=e[0],r=e.slice(1);switch(n){case`pan`:{M(`gesture pan`,r);let{origin:e,delta:i}=N(r);return S({kind:n,origin:e,delta:i,pointerCount:t,durationMs:F(r[4])})}case`fling`:return M(`gesture fling`,r),S({kind:n,direction:r[0],origin:{x:Number(r[1]),y:Number(r[2])},distance:F(r[3])});case`swipe`:return M(`gesture swipe`,r),S({kind:n,preset:r[0]});case`pinch`:return M(`gesture pinch`,r),S({kind:n,scale:Number(r[0]),origin:I(r[1],r[2])});case`rotate`:return M(`gesture rotate`,r),S({kind:n,degrees:Number(r[0]),origin:I(r[1],r[2])});case`transform`:{M(`gesture transform`,r);let{origin:e,delta:t}=N(r);return S({kind:n,origin:e,delta:t,scale:Number(r[4]),degrees:Number(r[5]),durationMs:F(r[6])})}case`drag`:return M(`gesture drag`,r),S({kind:n,source:r[0],destination:r[1],sourceHoldMs:F(r[2]),moveMs:F(r[3]),destinationHoldMs:F(r[4])});default:return S({kind:n})}}function xe(e){if(e[0]!==`drag`)return;let t=P(e);return t.kind===`drag`?t:void 0}function Se(e){switch(e.kind){case`pan`:return L([e.kind,e.origin.x,e.origin.y,e.delta.x,e.delta.y,e.durationMs]);case`fling`:return L([e.kind,e.direction,e.origin.x,e.origin.y,e.distance]);case`swipe`:return[e.kind,e.preset];case`pinch`:return L([e.kind,e.scale,e.origin?.x,e.origin?.y]);case`rotate`:return e.origin?L([e.kind,e.degrees,e.origin.x,e.origin.y]):[e.kind,String(e.degrees)];case`transform`:return L([e.kind,e.origin.x,e.origin.y,e.delta.x,e.delta.y,e.scale,e.degrees,e.durationMs]);case`drag`:return[e.kind,e.source,e.destination,String(e.sourceHoldMs??800),String(e.moveMs??500),String(e.destinationHoldMs??0)]}}function Ce(e,t={}){return M(`swipe`,e),{from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},...t.count===void 0?{}:{count:t.count},...t.pauseMs===void 0?{}:{pauseMs:t.pauseMs},...t.pattern===void 0?{}:{pattern:t.pattern}}}function we(t){switch(t.kind){case`pan`:return{gesture:{intent:`pan`,origin:t.origin,delta:t.delta,pointerCount:t.pointerCount,durationMs:t.durationMs}};case`fling`:return{gesture:{intent:`fling`,direction:t.direction,origin:t.origin,distance:t.distance}};case`swipe`:return{gesture:{intent:`fling`,preset:t.preset}};case`pinch`:return{gesture:{intent:`pinch`,origin:t.origin,scale:t.scale}};case`rotate`:return{gesture:{intent:`rotate`,origin:t.origin,degrees:t.degrees}};case`transform`:return{gesture:{intent:`transform`,origin:t.origin,delta:t.delta,scale:t.scale,degrees:t.degrees,durationMs:t.durationMs}};case`drag`:throw new e(`INVALID_ARGS`,`gesture drag targets must be resolved before coordinate normalization`)}}function Te(e){return e.kind===`drag`?{intent:`drag`,source:e.source,destination:e.destination,sourceHoldMs:e.sourceHoldMs,moveMs:e.moveMs,destinationHoldMs:e.destinationHoldMs}:we(e).gesture}function Ee(e){return{gesture:{intent:`fling`,from:e.from,to:e.to}}}function F(e){return e===void 0?void 0:Number(e)}function I(t,n){if(t===void 0!=(n===void 0))throw new e(`INVALID_ARGS`,`gesture origin requires both x and y coordinates`);return t===void 0?void 0:{x:Number(t),y:Number(n)}}function L(e){return e.filter(e=>e!==void 0).map(String)}const R={pinchAxisDegrees:-90,samplingProfile:`default`},De={ios:R,macos:R,android:{pinchAxisDegrees:0,samplingProfile:`android`},harmonyos:R,vega:R,linux:R,web:R};function Oe(e,t,n){let r=W(t),i=He(n);switch(e.intent){case`fling`:return Me(e,r);case`pan`:return Ne(e,r,i);case`pinch`:return B({intent:`pinch`,origin:e.origin??X(r),delta:{x:0,y:0},scale:Y(e.scale,`gesture pinch scale`),rotationDegrees:0,durationMs:300},r,i);case`rotate`:{let t=J(e.degrees,`gesture rotate degrees`);return B({intent:`rotate`,origin:e.origin??X(r),delta:{x:0,y:0},scale:1,rotationDegrees:t,durationMs:K(t)},r,i)}case`transform`:{let t=J(e.degrees,`gesture transform degrees`);return B({intent:`transform`,origin:e.origin,delta:e.delta,scale:Y(e.scale,`gesture transform scale`),rotationDegrees:t,durationMs:G(e.durationMs,K(t),`gesture transform durationMs`)},r,i)}}}function ke(e){let[{samples:t}]=e.pointers,n=t[0],r=t.at(-1);return{start:n.point,end:r.point}}function Ae(t,n){let r=W(n),i=Le(t.sourceHoldMs,800,`gesture drag sourceHoldMs`),a=G(t.moveMs,500,`gesture drag moveMs`),o=Re(t.destinationHoldMs,0,`gesture drag destinationHoldMs`);if(i+a+o>1e4)throw new e(`INVALID_ARGS`,`gesture drag total duration must be at most ${b}`);return je(z(`pan`,t.from,t.to,a,r,`timed-pan`),i,o)}function je(e,t,n){let r=e.pointers[0],[i,a]=r.samples,o=t+e.durationMs+n,s=[{offsetMs:0,point:i.point},{...i,offsetMs:i.offsetMs+t},{...a,offsetMs:a.offsetMs+t},...n>0?[{offsetMs:o,point:a.point}]:[]];return{...e,durationMs:o,pointers:[{...r,samples:s}]}}function Me(e,t){if(`preset`in e){let{from:n,to:r}=Ve(e.preset,t);return z(`fling`,n,r,100,t,`endpoint-hold`)}if(`from`in e)return z(`fling`,e.from,e.to,100,t,`endpoint-hold`);let n=q(e.origin,`gesture fling origin`),r=ze(e.distance??180,`gesture fling distance`);return z(`fling`,n,Z(n,ce(e.direction,r)),100,t,`endpoint-hold`)}function Ne(t,n,r){let i=G(t.durationMs,500,`gesture pan durationMs`);if((t.pointerCount??1)===1){let e=q(t.origin,`gesture pan origin`);return z(`pan`,e,Z(e,q(t.delta,`gesture pan delta`)),i,n,t.executionProfile??`timed-pan`)}if(t.pointerCount!==2)throw new e(`INVALID_ARGS`,`gesture pan pointerCount must be 1 or 2`);return B({intent:`pan`,origin:t.origin,delta:t.delta,scale:1,rotationDegrees:0,durationMs:i},n,r)}function z(e,t,n,r,i,a){let o=q(t,`gesture ${e} start`),s=q(n,`gesture ${e} end`),c=[{offsetMs:0,point:o},{offsetMs:r,point:s}];return H(c,i,{intent:e,pointerId:0}),{topology:`single`,intent:e,executionProfile:a,durationMs:r,viewport:i,pointers:[{pointerId:0,samples:c}]}}function B(e,t,n){let r=q(e.origin,`gesture ${e.intent} origin`),i=Z(r,q(e.delta,`gesture ${e.intent} delta`)),a=Math.min(t.width,t.height)*Ie(e.intent),o=e.scale>1?a/e.scale:a,s=o*e.scale;if(Math.min(o,s)<48)throw U({intent:e.intent,viewport:t,initialSpan:o,finalSpan:s,minimumReliableSpan:48});let c=o/2,l=V(e.durationMs,n.samplingProfile),u=(a,o)=>{let s=l.map(t=>({offsetMs:t,point:Pe({...e,start:r,end:i,initialRadius:c,offsetMs:t,side:o,profile:n})}));return H(s,t,{intent:e.intent,pointerId:a}),{pointerId:a,samples:s}};return{topology:`two`,intent:e.intent,durationMs:e.durationMs,viewport:t,pointers:[u(0,1),u(1,-1)]}}function Pe(e){let t=e.offsetMs/e.durationMs,n=Be(e.start,e.end,t),r=e.initialRadius*(1+(e.scale-1)*t),i=Ue(Fe(e.intent,e.profile)+e.rotationDegrees*t);return{x:n.x+Math.cos(i)*r*e.side,y:n.y+Math.sin(i)*r*e.side}}function Fe(e,t){return e===`pinch`?t.pinchAxisDegrees:-90}function Ie(e){return e===`pinch`?.4:.25}function V(t,n){if(!Number.isFinite(t)||t<=0)throw new e(`INVALID_ARGS`,`gesture sample duration must be a positive finite number`);let r=t/16,i=Math.max(3,n===`android`?Math.round(r):Math.floor(r));return Array.from({length:i+1},(e,n)=>Math.round(t*n/i))}function H(t,n,r){let i=n.x+n.width-1,a=n.y+n.height-1;for(let o of t){let{x:t,y:s}=o.point;if(!Number.isFinite(t)||!Number.isFinite(s))throw new e(`INVALID_ARGS`,`Gesture motion produces non-finite pointer coordinates`,{...r,reason:`GESTURE_TRAJECTORY_NON_FINITE`,hint:`Reduce the requested rotation, translation, or scale.`});if(t<n.x+1||t>i||s<n.y+1||s>a)throw U({...r,viewport:n,sample:o})}}function U(t){return new e(`INVALID_ARGS`,`Gesture trajectory does not fit inside the viewport`,{...t,reason:`GESTURE_TRAJECTORY_OUT_OF_BOUNDS`,hint:`Move the gesture away from the edge or reduce its translation, scale, or rotation.`})}function W(t){let n={x:J(t.x,`gesture viewport x`),y:J(t.y,`gesture viewport y`),width:J(t.width,`gesture viewport width`),height:J(t.height,`gesture viewport height`)};if(n.width<=0||n.height<=0)throw new e(`INVALID_ARGS`,`gesture viewport width and height must be positive`);return n}function G(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<16||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 16 and ${b}`);return i}function Le(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<1||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 1 and ${b}`);return i}function Re(t,n,r){let i=t??n;if(!Number.isInteger(i)||i<0||i>1e4)throw new e(`INVALID_ARGS`,`${r} must be an integer between 0 and ${b}`);return i}function K(e){let t=Math.ceil(Math.abs(e)/3)*16;return Math.min(Math.max(300,t),2400)}function q(e,t){return{x:J(e.x,`${t} x`),y:J(e.y,`${t} y`)}}function J(t,n){if(!Number.isFinite(t))throw new e(`INVALID_ARGS`,`${n} must be a finite number`);return t}function Y(t,n){let r=J(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be greater than 0`);return r}function ze(t,n){let r=J(t,n);if(r<=0)throw new e(`INVALID_ARGS`,`${n} must be a positive number`);return r}function X(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Z(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Be(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ve(e,t){let n=se(e,{referenceWidth:t.width,referenceHeight:t.height});return{from:{x:t.x+n.x1,y:t.y+n.y1},to:{x:t.x+n.x2,y:t.y+n.y2}}}function He(e){return e===void 0?R:De[e]}function Ue(e){return e*Math.PI/180}const We={occlusion:{kind:`runtime`,via:`src/core/selector-pipeline.ts#runNodePipelineStages`},parentOwnedTouchPoint:{kind:`runtime`,via:`src/core/interaction-touch-point.ts#resolveInteractionTouchPoint`},offscreen:{kind:`runtime`,via:`src/commands/interaction/runtime/resolution.ts#throwIfOffscreenInteractionTarget`},nonHittable:{kind:`runtime`,via:`src/core/selector-pipeline.ts#runNodePipelineStages`},responseConstruction:{kind:`runtime`,via:`src/daemon/handlers/interaction-touch-response.ts#buildInteractionResponseData`},responseIdentity:{kind:`runtime`,via:`src/daemon/handlers/interaction-touch-targets.ts#interactionResultExtra`},verifyEvidence:{kind:`runtime`,via:`src/commands/interaction/runtime/interactions.ts#pressCommand`,appliesTo:[`press`,`click`,`fill`]},settleObservation:{kind:`runtime`,via:`src/commands/interaction/runtime/settle.ts#settleAfterInteraction`}};({...We}),{...We};const Ge=`tapped via non-hittable coordinate fallback`,Ke=[`xctest-element`,`synthesized-first-responder`,`synthesized-first-responder-replacement`,`xctest-application-fallback`],qe=[`focused-element`,`keyboard-shown`],Je=1e4;function Ye(t,n=`scroll accepts either a relative amount or --pixels, not both`){if(t.amount!==void 0&&t.pixels!==void 0)throw new e(`INVALID_ARGS`,n)}function Xe(t,n={}){if(t===void 0)return;let r=n.field??`scroll durationMs`,i=n.max??1e4,a=n.invalidMessage??`${r} must be a non-negative integer`;if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new e(`INVALID_ARGS`,a);if(t>i)throw new e(`INVALID_ARGS`,`${r} must be a non-negative integer at most ${i}`);return t}function Ze(e){return typeof e?.durationMs==`number`?e.durationMs:void 0}const Qe={android:`longpress`,apple:`exact`,vega:`exact`},Q={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`}},$=Object.keys(Q),$e=`<${$.join(`|`)}>`;function et(t){let n=t?.toLowerCase();if(tt(n))return n;let r=n?ot.get(n):void 0;if(r)return r;throw new e(`INVALID_ARGS`,`tv-remote button must be one of: ${$.join(`, `)}.`)}function tt(e){return typeof e==`string`&&$.includes(e)}function nt(e){return Q[e].appleRemoteButton}function rt(e){return Q[e].androidKeyevent}function it(e){return Q[e].vegaKey}function at(e){return Qe[e]}const ot=new Map($.flatMap(e=>Q[e].aliases.map(t=>[t,e]))),st={captureStalled:`wait_capture_stalled`,deadlineExceeded:`wait_deadline_exceeded`,targetAbsent:`wait_target_absent`,stableTimeout:`wait_stable_timeout`,landmarkIdentityMismatch:`wait_landmark_identity_mismatch`};export{S as A,le as B,xe as C,Ee as D,Te as E,p as F,l as G,c as H,re as I,a as J,s as K,oe as L,ee as M,te as N,Ce as O,ne as P,m as R,ye as S,Se as T,d as U,ue as V,u as W,i as Y,Oe as _,rt as a,ke as b,at as c,Ze as d,Xe as f,Ae as g,Ke as h,et as i,f as j,x as k,Je as l,Ge as m,$ as n,nt as o,qe as p,o as q,$e as r,it as s,st as t,Ye as u,Be as v,P as w,_e as x,V as y,ae as z};
|
|
1
|
+
import{f as e,i as t,s as n}from"./session-snapshot.js";import{t as r}from"./snapshot-quality-verdict.js";import{t as i}from"./backend-snapshot-options.js";import{a,i as o,n as s,o as c,r as l}from"./interaction-ref-policy.js";async function u(e){let{session:t,flags:n,contextFromFlags:a,options:o}=e,s={...n??{},...i(o)},c=a(s,t.appBundleId,t.trace?.outPath),l=await e.capture({flags:s,options:o,context:c});return r(l.snapshotQuality)||e.publishSnapshot(l),l}const d=async(r,i,a,o,s)=>await u({session:r,flags:i,contextFromFlags:o,options:s,capture:async({flags:t,options:i,context:a})=>{let{snapshot:o}=await n({device:r.device,session:r,flags:t,outPath:t.out,logPath:a.logPath??``,includeRects:i.includeRects,androidFreshnessMode:i.androidFreshnessMode,signal:i.signal,...i.boundCapture?{captureData:async()=>await i.boundCapture(e({flags:t,session:r,snapshotScope:t.snapshotScope,includeRects:i.includeRects,signal:i.signal,context:a}))}:{}});return o},publishSnapshot:e=>{t(r,e),a.set(r.name,r)}});function f(e){return a({...e,captureSnapshotForSession:e.captureSnapshotForSession??d})}async function p(e){return(await import(`./find.js`)).handleFindCommands(e)}async function m(e){return await(await import(`./interaction2.js`)).handleInteractionCommands({...e,captureSnapshotForSession:e.captureSnapshotForSession??d})}export{d as captureSnapshotForSession,f as createInteractionRuntime,c as finalizeTouchInteraction,p as handleFindCommands,m as handleInteractionCommands,l as readSettleRequest,s as refMutationAdmissionResponse,o as settleFlagGuardResponse};
|