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,242 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CoreGraphics
|
|
3
|
+
|
|
4
|
+
public enum SnapshotVisibilityFold {
|
|
5
|
+
public enum Policy {
|
|
6
|
+
case cursorProjected
|
|
7
|
+
case plainViewport
|
|
8
|
+
|
|
9
|
+
public static var platformDefault: Self {
|
|
10
|
+
#if os(iOS)
|
|
11
|
+
return .cursorProjected
|
|
12
|
+
#else
|
|
13
|
+
return .plainViewport
|
|
14
|
+
#endif
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static let scrollContainerTypeNames: Set<String> = ["CollectionView", "ScrollView", "Table"]
|
|
19
|
+
|
|
20
|
+
enum Geometry {
|
|
21
|
+
case geometryless
|
|
22
|
+
case framed(intersectsClip: Bool)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum DescendantVisibility {
|
|
26
|
+
case independent
|
|
27
|
+
case owned
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct ProjectionCursor {
|
|
31
|
+
static let root = ProjectionCursor(ancestorProjectedOut: false)
|
|
32
|
+
|
|
33
|
+
private let ancestorProjectedOut: Bool
|
|
34
|
+
|
|
35
|
+
var isProjectedOut: Bool { ancestorProjectedOut }
|
|
36
|
+
|
|
37
|
+
func project(
|
|
38
|
+
geometry: Geometry,
|
|
39
|
+
descendantVisibility: DescendantVisibility
|
|
40
|
+
) -> ProjectionDecision {
|
|
41
|
+
let nodeProjectedOut: Bool
|
|
42
|
+
switch geometry {
|
|
43
|
+
case .geometryless:
|
|
44
|
+
nodeProjectedOut = false
|
|
45
|
+
case .framed(let intersectsClip):
|
|
46
|
+
nodeProjectedOut = !intersectsClip
|
|
47
|
+
}
|
|
48
|
+
let presentationVisible = !ancestorProjectedOut && !nodeProjectedOut
|
|
49
|
+
let descendantsProjectedOut = ancestorProjectedOut
|
|
50
|
+
|| (nodeProjectedOut && descendantVisibility == .owned)
|
|
51
|
+
return ProjectionDecision(
|
|
52
|
+
presentationVisible: presentationVisible,
|
|
53
|
+
descendants: ProjectionCursor(ancestorProjectedOut: descendantsProjectedOut)
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
struct ProjectionDecision {
|
|
59
|
+
let presentationVisible: Bool
|
|
60
|
+
let descendants: ProjectionCursor
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
struct ProjectionTransition {
|
|
64
|
+
let decision: ProjectionDecision
|
|
65
|
+
let hiddenContentFrame: CGRect?
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public struct TraversalState {
|
|
69
|
+
fileprivate let cursor: ProjectionCursor
|
|
70
|
+
fileprivate let ancestorClip: CGRect?
|
|
71
|
+
|
|
72
|
+
fileprivate init(cursor: ProjectionCursor, ancestorClip: CGRect?) {
|
|
73
|
+
self.cursor = cursor
|
|
74
|
+
self.ancestorClip = ancestorClip
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public static let root = TraversalState(cursor: .root, ancestorClip: nil)
|
|
78
|
+
|
|
79
|
+
public var descendantsMayBeVisible: Bool {
|
|
80
|
+
!cursor.isProjectedOut
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public struct TraversalDecision {
|
|
85
|
+
public let isIncluded: Bool
|
|
86
|
+
public let descendantsMayBeVisible: Bool
|
|
87
|
+
public let descendants: TraversalState
|
|
88
|
+
fileprivate let effectiveFrame: CGRect
|
|
89
|
+
fileprivate let hiddenContentFrame: CGRect?
|
|
90
|
+
fileprivate let establishesScrollAnchor: Bool
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private struct BranchState {
|
|
94
|
+
let traversal: TraversalState
|
|
95
|
+
let anchor: (index: Int, rect: CGRect)?
|
|
96
|
+
let keptIndex: Int?
|
|
97
|
+
let keptDepth: Int
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public static func traversalDecision(
|
|
101
|
+
for node: RawAXNode,
|
|
102
|
+
parent: TraversalState,
|
|
103
|
+
viewport: CGRect,
|
|
104
|
+
interactiveOnly: Bool,
|
|
105
|
+
hasChildren: Bool,
|
|
106
|
+
policy: Policy
|
|
107
|
+
) -> TraversalDecision {
|
|
108
|
+
let ancestorClip = policy == .cursorProjected ? parent.ancestorClip : nil
|
|
109
|
+
let rect = node.rect.cgRect
|
|
110
|
+
let effectiveFrame = SnapshotGeometry.effectiveFrame(
|
|
111
|
+
reportedFrame: rect,
|
|
112
|
+
viewport: viewport,
|
|
113
|
+
ancestorClip: ancestorClip
|
|
114
|
+
)
|
|
115
|
+
let intersects = !effectiveFrame.isNull && !effectiveFrame.isEmpty
|
|
116
|
+
let transition = projectionTransition(
|
|
117
|
+
frame: rect,
|
|
118
|
+
intersectsClip: intersects,
|
|
119
|
+
typeName: node.type,
|
|
120
|
+
hasChildren: hasChildren,
|
|
121
|
+
cursor: parent.cursor,
|
|
122
|
+
policy: policy
|
|
123
|
+
)
|
|
124
|
+
let negligibleDecoration = policy == .cursorProjected
|
|
125
|
+
&& node.parentIndex != nil
|
|
126
|
+
&& !node.hasSemanticContent
|
|
127
|
+
&& (rect.isEmpty || rect.width <= negligibleDecorationTolerance || rect.height <= negligibleDecorationTolerance)
|
|
128
|
+
let visible = transition.decision.presentationVisible && !negligibleDecoration
|
|
129
|
+
let isIncluded = shouldInclude(
|
|
130
|
+
node,
|
|
131
|
+
visible: visible,
|
|
132
|
+
interactiveOnly: interactiveOnly,
|
|
133
|
+
policy: policy
|
|
134
|
+
)
|
|
135
|
+
let establishesScrollAnchor = policy == .cursorProjected
|
|
136
|
+
&& isIncluded
|
|
137
|
+
&& intersects
|
|
138
|
+
&& hasChildren
|
|
139
|
+
&& scrollContainerTypeNames.contains(node.type)
|
|
140
|
+
let descendants = TraversalState(
|
|
141
|
+
cursor: transition.decision.descendants,
|
|
142
|
+
ancestorClip: establishesScrollAnchor ? effectiveFrame : ancestorClip
|
|
143
|
+
)
|
|
144
|
+
return TraversalDecision(
|
|
145
|
+
isIncluded: isIncluded,
|
|
146
|
+
descendantsMayBeVisible: !transition.decision.descendants.isProjectedOut,
|
|
147
|
+
descendants: descendants,
|
|
148
|
+
effectiveFrame: effectiveFrame,
|
|
149
|
+
hiddenContentFrame: transition.hiddenContentFrame,
|
|
150
|
+
establishesScrollAnchor: establishesScrollAnchor
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public static func fold(
|
|
155
|
+
_ nodes: [RawAXNode],
|
|
156
|
+
viewport: CGRect,
|
|
157
|
+
interactiveOnly: Bool,
|
|
158
|
+
policy: Policy
|
|
159
|
+
) -> [SnapshotPresentationNode] {
|
|
160
|
+
var hasChildren = [Bool](repeating: false, count: nodes.count)
|
|
161
|
+
for node in nodes {
|
|
162
|
+
if let parentIndex = node.parentIndex, parentIndex >= 0, parentIndex < nodes.count {
|
|
163
|
+
hasChildren[parentIndex] = true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var states = [BranchState?](repeating: nil, count: nodes.count)
|
|
168
|
+
var kept: [SnapshotPresentationNode] = []
|
|
169
|
+
var hints: [Int: (above: Bool, below: Bool)] = [:]
|
|
170
|
+
|
|
171
|
+
for (offset, node) in nodes.enumerated() {
|
|
172
|
+
let parentState = node.parentIndex.flatMap { states[$0] }
|
|
173
|
+
let parentTraversal = parentState?.traversal ?? .root
|
|
174
|
+
let parentAnchor = policy == .cursorProjected ? parentState?.anchor : nil
|
|
175
|
+
let rect = node.rect.cgRect
|
|
176
|
+
let decision = traversalDecision(
|
|
177
|
+
for: node,
|
|
178
|
+
parent: parentTraversal,
|
|
179
|
+
viewport: viewport,
|
|
180
|
+
interactiveOnly: interactiveOnly,
|
|
181
|
+
hasChildren: hasChildren[offset],
|
|
182
|
+
policy: policy
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
if let hiddenFrame = decision.hiddenContentFrame, let parentAnchor {
|
|
186
|
+
rememberHiddenContentHint(for: hiddenFrame, relativeTo: parentAnchor, hints: &hints)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var keptIndex = parentState?.keptIndex
|
|
190
|
+
var keptDepth = parentState?.keptDepth ?? -1
|
|
191
|
+
if decision.isIncluded {
|
|
192
|
+
let outIndex = kept.count
|
|
193
|
+
let outDepth = keptDepth + 1
|
|
194
|
+
kept.append(
|
|
195
|
+
SnapshotPresentationNode(
|
|
196
|
+
raw: RawAXNode(
|
|
197
|
+
index: outIndex,
|
|
198
|
+
type: node.type,
|
|
199
|
+
label: node.label,
|
|
200
|
+
identifier: node.identifier,
|
|
201
|
+
value: node.value,
|
|
202
|
+
rect: node.rect,
|
|
203
|
+
enabled: node.enabled,
|
|
204
|
+
focused: node.focused,
|
|
205
|
+
selected: node.selected,
|
|
206
|
+
hittable: node.parentIndex != nil && node.hittable
|
|
207
|
+
&& SnapshotGeometry.isGeometricallyActionable(
|
|
208
|
+
enabled: node.enabled,
|
|
209
|
+
frame: decision.effectiveFrame,
|
|
210
|
+
viewport: viewport
|
|
211
|
+
),
|
|
212
|
+
depth: outDepth,
|
|
213
|
+
parentIndex: keptIndex,
|
|
214
|
+
hiddenContentAbove: node.hiddenContentAbove,
|
|
215
|
+
hiddenContentBelow: node.hiddenContentBelow,
|
|
216
|
+
actions: node.actions
|
|
217
|
+
),
|
|
218
|
+
effectiveRect: SnapshotGeometry.snapshotRect(
|
|
219
|
+
from: decision.effectiveFrame,
|
|
220
|
+
reportedFrame: rect
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
keptIndex = outIndex
|
|
225
|
+
keptDepth = outDepth
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var anchor = parentAnchor
|
|
229
|
+
if decision.establishesScrollAnchor, let keptIndex {
|
|
230
|
+
anchor = (index: keptIndex, rect: decision.effectiveFrame)
|
|
231
|
+
}
|
|
232
|
+
states[offset] = BranchState(
|
|
233
|
+
traversal: decision.descendants,
|
|
234
|
+
anchor: anchor,
|
|
235
|
+
keptIndex: keptIndex,
|
|
236
|
+
keptDepth: keptDepth
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
return applyHiddenContentHints(hints, to: kept)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import CoreGraphics
|
|
2
|
+
|
|
3
|
+
extension SnapshotVisibilityFold {
|
|
4
|
+
static let negligibleDecorationTolerance = 1.0
|
|
5
|
+
static let visibilityExemptCarrierTypes: Set<String> = ["Application", "Window"]
|
|
6
|
+
|
|
7
|
+
static func projectionTransition(
|
|
8
|
+
frame: CGRect,
|
|
9
|
+
intersectsClip: Bool,
|
|
10
|
+
typeName: String,
|
|
11
|
+
hasChildren: Bool,
|
|
12
|
+
cursor: ProjectionCursor,
|
|
13
|
+
policy: Policy
|
|
14
|
+
) -> ProjectionTransition {
|
|
15
|
+
if policy == .plainViewport {
|
|
16
|
+
return ProjectionTransition(
|
|
17
|
+
decision: ProjectionDecision(
|
|
18
|
+
presentationVisible: intersectsClip,
|
|
19
|
+
descendants: .root
|
|
20
|
+
),
|
|
21
|
+
hiddenContentFrame: !intersectsClip ? frame : nil
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let hasFrame = !frame.isNull && !frame.isEmpty
|
|
26
|
+
let geometry: Geometry = hasFrame ? .framed(intersectsClip: intersectsClip) : .geometryless
|
|
27
|
+
let ownsDescendants = hasChildren
|
|
28
|
+
&& (typeName == "Cell" || scrollContainerTypeNames.contains(typeName))
|
|
29
|
+
return ProjectionTransition(
|
|
30
|
+
decision: cursor.project(
|
|
31
|
+
geometry: geometry,
|
|
32
|
+
descendantVisibility: ownsDescendants ? .owned : .independent
|
|
33
|
+
),
|
|
34
|
+
hiddenContentFrame: !cursor.isProjectedOut && hasFrame && !intersectsClip ? frame : nil
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static func shouldInclude(
|
|
39
|
+
_ node: RawAXNode,
|
|
40
|
+
visible: Bool,
|
|
41
|
+
interactiveOnly: Bool,
|
|
42
|
+
policy: Policy
|
|
43
|
+
) -> Bool {
|
|
44
|
+
if node.parentIndex == nil { return true }
|
|
45
|
+
if policy == .plainViewport && interactiveOnly && !visible && node.type != "Application" {
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
return visibilityExemptCarrierTypes.contains(node.type) || visible
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static func rememberHiddenContentHint(
|
|
52
|
+
for frame: CGRect,
|
|
53
|
+
relativeTo scrollAnchor: (index: Int, rect: CGRect),
|
|
54
|
+
hints: inout [Int: (above: Bool, below: Bool)]
|
|
55
|
+
) {
|
|
56
|
+
var hint = hints[scrollAnchor.index] ?? (above: false, below: false)
|
|
57
|
+
if frame.maxY <= scrollAnchor.rect.minY {
|
|
58
|
+
hint.above = true
|
|
59
|
+
} else if frame.minY >= scrollAnchor.rect.maxY {
|
|
60
|
+
hint.below = true
|
|
61
|
+
} else {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
hints[scrollAnchor.index] = hint
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static func applyHiddenContentHints(
|
|
68
|
+
_ hints: [Int: (above: Bool, below: Bool)],
|
|
69
|
+
to nodes: [SnapshotPresentationNode]
|
|
70
|
+
) -> [SnapshotPresentationNode] {
|
|
71
|
+
if hints.isEmpty { return nodes }
|
|
72
|
+
return nodes.map { presentationNode in
|
|
73
|
+
let node = presentationNode.raw
|
|
74
|
+
guard let hint = hints[node.index] else { return presentationNode }
|
|
75
|
+
return SnapshotPresentationNode(
|
|
76
|
+
raw: RawAXNode(
|
|
77
|
+
index: node.index,
|
|
78
|
+
type: node.type,
|
|
79
|
+
label: node.label,
|
|
80
|
+
identifier: node.identifier,
|
|
81
|
+
value: node.value,
|
|
82
|
+
rect: node.rect,
|
|
83
|
+
enabled: node.enabled,
|
|
84
|
+
focused: node.focused,
|
|
85
|
+
selected: node.selected,
|
|
86
|
+
hittable: node.hittable,
|
|
87
|
+
depth: node.depth,
|
|
88
|
+
parentIndex: node.parentIndex,
|
|
89
|
+
hiddenContentAbove: node.hiddenContentAbove == true || hint.above ? true : nil,
|
|
90
|
+
hiddenContentBelow: node.hiddenContentBelow == true || hint.below ? true : nil,
|
|
91
|
+
actions: node.actions
|
|
92
|
+
),
|
|
93
|
+
effectiveRect: presentationNode.effectiveRect
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,y as t}from"./sdk-contracts.js";import{Rr as n}from"./sdk-batch.js";import{c as r,r as i}from"./diagnostics.js";import{S as a,b as o,f as s}from"./owner-identity.js";import{c,s as l}from"./exec.js";import{t as u}from"./file.js";import"./diagnostics2.js";import"./command.js";import{n as d}from"./retry.js";import{n as f}from"./version.js";import"./process.js";import{C as p,D as m,c as ee,f as te,h as ne,n as h,o as g,w as _,y as re}from"./host-file.js";import{t as ie}from"./snapshot-process.js";import v from"node:path";import{createHash as y,randomUUID as b}from"node:crypto";import ae from"node:net";import{Buffer as x}from"node:buffer";const S={unsupported:`UNSUPPORTED_OPERATION`,"malformed-tree":`COMMAND_FAILED`,"stale-target":`COMMAND_FAILED`,timeout:`COMMAND_FAILED`,cancelled:`COMMAND_FAILED`,"process-crash":`COMMAND_FAILED`,"transport-failure":`COMMAND_FAILED`};var C=class extends t{failureKind;failureCode;constructor(e,t,n=`iOS Simulator snapshot source ${e}: ${t}`,r={},i){super(S[e],n,{...r,bridgeFailure:e,bridgeFailureCode:t,...e===`cancelled`?{reason:`request_canceled`}:{}},i),this.name=`SnapshotSourceError`,this.failureKind=e,this.failureCode=t}};function w(e,t,n={},r){return new C(e,t,void 0,n,r)}function T(n){return n instanceof C?n:e(n)?w(`cancelled`,`abort-signal`,{},n):n instanceof t&&typeof n.details?.timeoutMs==`number`?w(`timeout`,`host-operation-timeout`,{timeoutMs:n.details.timeoutMs},n):w(`transport-failure`,`unexpected-host-error`,{error:n instanceof Error?n.message:String(n)},n)}function oe(e,t){if(t?.aborted)throw w(`cancelled`,`abort-signal`);return{clock:d.fromTimeoutMs(e),signal:t}}function E(e,t){if(e.signal?.aborted)throw w(`cancelled`,`abort-signal`);let n=e.clock.remainingMs();if(n<=0)throw w(`timeout`,t);return Math.max(1,Math.floor(n))}async function D(e,t,n){let r=Math.min(t,E(e,n));await new Promise((t,n)=>{let i=!1,a=setTimeout(()=>s(t),r),o=()=>{s(()=>n(w(`cancelled`,`abort-signal`)))},s=t=>{i||(i=!0,clearTimeout(a),e.signal?.removeEventListener(`abort`,o),t())};e.signal?.addEventListener(`abort`,o,{once:!0}),e.signal?.aborted&&o()})}const O=[`SnapshotBridge.m`,`SnapshotBridgeRuntime.m`,`SnapshotBridgeRuntime.h`],se=[`SnapshotBridge.m`,`SnapshotBridgeRuntime.m`];async function ce(e,t,n){let r=y(`sha256`);for(let i of O){let a=v.join(t,i);if(E(n,`native-source-fingerprint-deadline`),!e.exists(a))throw w(`unsupported`,`native-source-missing`,{filePath:a});r.update(i),r.update(`\0`),r.update(await e.readBinary(a)),r.update(`\0`)}return r.digest(`hex`)}async function le(e,t,n){let r=await k(e,`xcodebuild`,[`-version`],n),i=await k(e,`sw_vers`,[`-productVersion`],n),a=await k(e,`sw_vers`,[`-buildVersion`],n),o=await k(e,`uname`,[`-m`],n),s=await k(e,`xcrun`,[`--sdk`,`iphonesimulator`,`--show-sdk-version`],n),c=t.trim();if(!c)throw w(`unsupported`,`simulator-runtime-missing`);if(o!==`arm64`&&o!==`x86_64`)throw w(`unsupported`,`simulator-architecture-unsupported`,{architecture:o});return{xcode:r,macosProductVersion:i,macosBuild:a,architecture:o,simulatorSdk:s,simulatorRuntime:c}}async function k(e,t,n,r){let i=await e.run(t,n,{allowFailure:!0,signal:r.signal,timeoutMs:Math.min(1e4,E(r,`toolchain-probe-deadline`))});if(i.exitCode!==0)throw w(`unsupported`,`toolchain-probe-failed`,{command:t,exitCode:i.exitCode,stderr:i.stderr.slice(0,1024)});let a=(i.stdout||i.stderr).trim();if(!a)throw w(`unsupported`,`toolchain-probe-empty`,{command:t});return a}const A=`agent-device-simulator-ax-v1.5.3`;Object.freeze([`verb`,`requestId`,`pid`,`generation`,`snapshotTree`,`automationMode`,`maxDepth`,`maxNodes`,`maxDurationMs`,`maxResponseBytes`]),Object.freeze([`protocolVersion`,`sourceVersion`,`requestId`,`generation`,`ok`,`pid`,`tree`,`truncated`,`automationEnabled`,`error_kind`,`error_code`,`error`]),Object.freeze([`XC_kAXXCAttributeElementType`,`XC_kAXXCAttributeElementBaseType`,`XC_kAXXCAttributeLabel`,`XC_kAXXCAttributeValue`,`XC_kAXXCAttributeIdentifier`,`XC_kAXXCAttributeFrame`,`XC_kAXXCAttributeAutomationType`,`XC_kAXXCAttributeChildren`]);function ue(e,t){let n;try{n=x.from(JSON.stringify(e),`utf8`)}catch(e){throw w(`malformed-tree`,`request-not-json`,{},e)}let r=n.length+4;if(r>t.maxRequestBytes)throw w(`transport-failure`,`request-limit-exceeded`,{frameBytes:r,maxRequestBytes:t.maxRequestBytes});let i=x.alloc(4);return i.writeUInt32BE(n.length,0),x.concat([i,n])}var de=class{header=x.alloc(4);headerBytes=0;chunks=[];payloadBytes=0;expectedBodyBytes;frame;maxFrameBytes;constructor(e){if(!Number.isSafeInteger(e)||e<=0)throw w(`malformed-tree`,`frame-limit-invalid`,{maxFrameBytes:e});this.maxFrameBytes=e}push(e){if(this.frame)return this.acceptTrailingChunk(e);let t=this.readHeader(e);if(t&&(this.appendPayload(e,t.offset,t.bodyBytes),this.payloadBytes===t.bodyBytes))return this.frame=x.concat(this.chunks,t.bodyBytes),this.frame}acceptTrailingChunk(e){if(e.length>0)throw w(`malformed-tree`,`multiple-frames`,{trailingBytes:e.length});return this.frame}readHeader(e){if(this.headerBytes===4)return{offset:0,bodyBytes:this.expectedBodyBytes};let t=Math.min(4-this.headerBytes,e.length);if(e.copy(this.header,this.headerBytes,0,t),this.headerBytes+=t,this.headerBytes<4)return;let n=this.header.readUInt32BE(0);if(n===0||n>this.maxFrameBytes)throw w(`malformed-tree`,`frame-limit-exceeded`,{bodyBytes:n,maxFrameBytes:this.maxFrameBytes});return this.expectedBodyBytes=n,{offset:t,bodyBytes:n}}appendPayload(e,t,n){let r=n-this.payloadBytes,i=e.length-t;if(i>r)throw w(`malformed-tree`,`multiple-frames`,{trailingBytes:i-r});i!==0&&(this.chunks.push(e.subarray(t)),this.payloadBytes+=i)}finish(){if(this.frame)return this.frame;throw w(`transport-failure`,`bridge-frame-incomplete`,{headerBytes:this.headerBytes,payloadBytes:this.payloadBytes,expectedBodyBytes:this.expectedBodyBytes})}};function fe(e){let t;try{t=JSON.parse(e.toString(`utf8`))}catch(e){throw w(`malformed-tree`,`response-not-json`,{},e)}if(!j(t))throw w(`malformed-tree`,`response-not-object`);return t}function pe(e){return Object.freeze({verb:`describe`,requestId:e.requestId,pid:e.pid,generation:e.generation,snapshotTree:!0,automationMode:!0,maxDepth:e.maxDepth,maxNodes:e.maxNodes,maxDurationMs:e.maxDurationMs,maxResponseBytes:e.maxResponseBytes})}function me(e,t){if(e.protocolVersion!==1)throw w(`transport-failure`,`protocol-version-mismatch`,{expected:1,observed:e.protocolVersion});if(e.sourceVersion!==`agent-device-simulator-ax-v1.5.3`)throw w(`transport-failure`,`source-version-mismatch`,{expected:A,observed:e.sourceVersion});if(e.requestId!==t)throw w(`transport-failure`,`request-id-mismatch`,{expected:t,observed:e.requestId})}function he(e,t){if(typeof e.pid!=`number`||e.pid!==t.pid)throw w(`stale-target`,`bridge-pid-mismatch`,{expectedPid:t.pid,observedPid:e.pid});if(e.generation!==t.generation)throw w(`stale-target`,`bridge-generation-mismatch`,{expectedGeneration:t.generation,observedGeneration:e.generation})}function ge(e){let t=e.error_kind,n=typeof e.error_code==`string`?e.error_code:`guest-error`,r=typeof e.error==`string`?e.error:void 0,i=r?{guestMessage:r.slice(0,1024)}:{};throw w(t===`unsupported`?`unsupported`:t===`malformed_tree`?`malformed-tree`:t===`application_not_responding`?`timeout`:t===`application_unavailable`?`transport-failure`:t===`bad_request`?`malformed-tree`:`transport-failure`,n,i)}function j(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const M=`snapshot-bridge`,N=`manifest.json`;async function P(e){let t=e.deadline,n=e.sourceRoot??F(e.host),r=await ce(e.host,n,t),i=await le(e.host,e.runtime,t),a=_e({schemaVersion:1,protocolVersion:1,sourceVersion:A,sourceHash:r,toolchain:i}),o=e.cacheRoot??v.join(e.host.homeDirectory(),`.agent-device`,`snapshot-source`),s=v.join(o,a),c=await e.host.acquireLock(v.join(o,`${a}.lock`),{deadline:t});try{let c=await I(e.host,s,{sourceHash:r,cacheKey:a,toolchain:i},t);if(c)return c;E(t,`native-build-deadline`),e.host.exists(s)&&await e.host.remove(s),E(t,`native-build-deadline`),await e.host.ensureDirectory(o);let l=v.join(o,`.${a}.${e.host.processId()}.tmp`);E(t,`native-build-deadline`),await e.host.remove(l);try{E(t,`native-build-deadline`),await e.host.ensureDirectory(l);let o=v.join(l,M),c=await e.host.run(`xcrun`,[`--sdk`,`iphonesimulator`,`clang`,`-arch`,i.architecture,`-mios-simulator-version-min=15.0`,`-fobjc-arc`,`-Werror`,`-Wall`,`-Wextra`,`-framework`,`Foundation`,`-framework`,`CoreGraphics`,...se.map(e=>v.join(n,e)),`-o`,o],{signal:t.signal,timeoutMs:Math.min(12e4,E(t,`native-build-deadline`)),allowFailure:!0});if(c.exitCode!==0||!e.host.exists(o))throw w(`unsupported`,`native-build-failed`,{exitCode:c.exitCode,stderr:c.stderr.slice(0,4096)});E(t,`native-build-deadline`),await e.host.chmod(o,493);let u=await L(e.host,o,t),d={schemaVersion:1,protocolVersion:1,sourceVersion:A,sourceHash:r,cacheKey:a,toolchain:i,binarySha256:u};return await e.host.writeText(v.join(l,N),`${JSON.stringify(d,null,2)}\n`),E(t,`native-build-deadline`),await e.host.rename(l,s),{path:v.join(s,M),sourceHash:r,cacheKey:a,protocolVersion:1,sourceVersion:A}}catch(t){throw await e.host.remove(l),t}}finally{await c()}}function F(e){let t=e.projectRoot(),n=v.join(t,`apple`,`snapshot-bridge`);if(O.every(t=>e.exists(v.join(n,t))))return n;let r=v.join(t,`dist`,`apple`,`snapshot-bridge`);if(O.every(t=>e.exists(v.join(r,t))))return r;throw w(`unsupported`,`native-source-missing`,{projectRoot:t})}async function I(e,t,n,r){let i=v.join(t,M);if(!(!e.exists(i)||!e.exists(v.join(t,N))))try{let a=JSON.parse(await e.readText(v.join(t,N)));return a.schemaVersion!==1||a.protocolVersion!==1||a.sourceVersion!==`agent-device-simulator-ax-v1.5.3`||a.sourceHash!==n.sourceHash||a.cacheKey!==n.cacheKey||JSON.stringify(a.toolchain)!==JSON.stringify(n.toolchain)||typeof a.binarySha256!=`string`||await L(e,i,r)!==a.binarySha256?void 0:{path:i,sourceHash:n.sourceHash,cacheKey:n.cacheKey,protocolVersion:1,sourceVersion:A}}catch(e){if(e instanceof C&&(e.failureKind===`cancelled`||e.failureKind===`timeout`))throw e;return}}async function L(e,t,n){return E(n,`native-cache-hash-deadline`),y(`sha256`).update(await e.readBinary(t)).digest(`hex`)}function _e(e){return y(`sha256`).update(JSON.stringify(e)).digest(`hex`).slice(0,32)}const R=65536;function ve(){return{projectRoot:f,homeDirectory:te,run:async(e,t,n)=>await l(e,t,n),start:ye,connect:be,readText:re,readBinary:ne,writeText:m,ensureDirectory:g,chmod:h,exists:ee,rename:_,remove:p,acquireLock:xe,emitDiagnostic:i,withDiagnosticTimer:r,processId:s,readTargetProcessStartTime:ie}}function ye(e,t,n,r={}){if(r.signal?.aborted)throw w(`cancelled`,`abort-signal`);let i=c(`xcrun`,[`simctl`,`spawn`,e,t,`serve`,n,`--idle-timeout`,`60`,`--exit-on-disconnect`,`false`],{allowFailure:!0,captureOutput:!1,detached:!0}),o=i.child.pid??0;if(o<=0)throw w(`transport-failure`,`bridge-process-pid-missing`);let s=``;return i.child.stderr?.setEncoding(`utf8`),i.child.stderr?.on(`data`,e=>{s=Se(s,String(e))}),{pid:o,wait:i.wait,isAlive:()=>i.child.exitCode===null&&i.child.signalCode===null,signal:e=>{a(o,e)||i.child.kill(e)},readLog:()=>s}}async function be(e,t){if(t.signal?.aborted)throw w(`cancelled`,`abort-signal`);let n=Math.max(1,Math.floor(t.timeoutMs));return await new Promise((r,i)=>{let a=ae.createConnection({path:e}),o=!1,s=!1,c=setTimeout(()=>{p(w(`timeout`,`bridge-connect-timeout`)),a.destroy()},n),l=()=>{p(w(`cancelled`,`abort-signal`)),a.destroy()},u=()=>{o=!0,clearTimeout(c),t.signal?.removeEventListener(`abort`,l),a.off(`error`,d),a.off(`close`,f),a.setTimeout(0),r(a)},d=e=>{p(e),a.destroy()},f=()=>{o||p(w(`transport-failure`,`bridge-closed-before-connect`))},p=e=>{s||o||(s=!0,clearTimeout(c),t.signal?.removeEventListener(`abort`,l),a.off(`connect`,u),a.off(`error`,d),a.off(`close`,f),i(e))};a.once(`connect`,u),a.once(`error`,d),a.once(`close`,f),t.signal?.addEventListener(`abort`,l,{once:!0}),t.signal?.aborted&&l()})}async function xe(e,t){let n=s(),r=t.deadline,i=u({lockDirPath:e,owner:{pid:n,startTime:o(n),acquiredAtMs:Date.now()},timeoutMs:E(r,`cache-lock-deadline`),pollMs:100,ownerGraceMs:5e3,description:`iOS Simulator snapshot bridge cache`}),a=r.signal;if(!a)return await i;let c=!1,l,d=new Promise((e,t)=>{l=()=>{c=!0,t(w(`cancelled`,`abort-signal`))},a.addEventListener(`abort`,l,{once:!0}),a.aborted&&l()});try{return await Promise.race([i,d])}catch(e){throw c&&i.then(e=>e(),()=>void 0),r.clock.isExpired()&&!(e instanceof C&&e.failureKind===`cancelled`)?w(`timeout`,`cache-lock-deadline`):e}finally{a.removeEventListener(`abort`,l)}}function Se(e,t){let n=e+t;return n.length<=R?n:n.slice(n.length-R)}function Ce(e,t,n){let r=y(`sha256`).update(t).digest(`hex`).slice(0,12),i=y(`sha256`).update(n).digest(`hex`).slice(0,12);return v.join(`/tmp`,`agent-device-ax-${r}-${e.processId()}-${i}`,`snapshot.sock`)}const z=new WeakSet;async function B(e,t){let n;try{n=(await t.wait).exitCode}catch{n=void 0}return z.has(t)||(z.add(t),e.emitDiagnostic({level:`error`,phase:`ios.snapshot-source.bridge-process-exit`,data:{pid:t.pid,...n===void 0?{}:{exitCode:n},stderr:we(t.readLog())}})),w(`process-crash`,`bridge-exited`,{pid:t.pid,...n===void 0?{}:{exitCode:n}})}function we(e){let t=x.from(e);return t.length<=65536?e:t.subarray(-65536).toString(`utf8`)}async function Te(e){let t=new de(e.limits.maxResponseBytes-4),n=E(e.deadline,`bridge-request-deadline`);return await new Promise((r,i)=>{let a=!1,o=!1,s=setTimeout(()=>{p(w(`timeout`,`bridge-request-deadline`,{dispatched:o})),e.socket.destroy()},n),c=()=>{p(w(`cancelled`,`abort-signal`,{dispatched:o})),e.socket.destroy()},l=n=>{try{if(!Buffer.isBuffer(n))throw w(`transport-failure`,`bridge-data-invalid`);let r=t.push(n);if(r){let t=fe(r);if(me(t,e.requestId),he(t,{pid:e.expectedPid,generation:e.expectedGeneration}),t.ok!==!0&&ge(t),typeof t.truncated!=`boolean`)throw w(`malformed-tree`,`truncated-invalid`);f(t);return}}catch(t){p(t),e.socket.destroy()}},u=e=>p(T(e)),d=()=>{a||(e.process.isAlive()?p(w(`transport-failure`,`bridge-connection-closed`)):B(e.host,e.process).then(p))};e.process.wait.then(()=>{a||B(e.host,e.process).then(p)},e=>{a||p(T(e))});let f=e=>m(()=>r(e)),p=e=>m(()=>i(e)),m=t=>{a||(a=!0,clearTimeout(s),e.deadline.signal?.removeEventListener(`abort`,c),e.socket.off(`data`,l),e.socket.off(`error`,u),e.socket.off(`close`,d),t())};e.socket.on(`data`,l),e.socket.on(`error`,u),e.socket.on(`close`,d),e.deadline.signal?.addEventListener(`abort`,c,{once:!0});try{if(e.deadline.signal?.aborted)throw w(`cancelled`,`abort-signal`);o=!0,e.socket.write(e.frame)}catch(t){p(T(t)),e.socket.destroy()}})}var Ee=class{sessions=new Map;requestQueues=new Map;ownerId=b();closed=!1;host;constructor(e){this.host=e}async request(e){if(this.closed)throw w(`unsupported`,`source-closed`);return await this.withSimulatorLock(e.target.udid,e.deadline,()=>this.requestInSimulator(e))}async requestInSimulator(e){if(this.closed)throw w(`unsupported`,`source-closed`);let t=e.deadline;E(t,`bridge-request-deadline`);let n=this.sessions.get(e.target.udid),r=await this.ensureSession(e,t);try{let n=await this.readTargetStartTime(e.target,t),i=await this.exchange(r,e,t);return await this.assertTargetStillCurrent(e.target,n,t),i}catch(e){throw await this.handleRequestFailure(e,r,n)}}async handleRequestFailure(e,t,n){let r=T(e);return Oe(r,t,n)?await this.removeSession(t,!0):r.failureKind===`process-crash`?await this.removeSession(t,!1):r.failureKind===`transport-failure`&&(t.socket?.destroy(),t.socket=void 0),r}async withSimulatorLock(e,t,n){let r=this.requestQueues.get(e)??Promise.resolve(),i,a=new Promise(e=>{i=e}),o=r.then(()=>a);this.requestQueues.set(e,o);try{return await De(r,t),await n()}finally{i(),this.requestQueues.get(e)===o&&this.requestQueues.delete(e)}}async close(){if(this.closed)return;this.closed=!0;let e=[...this.sessions.values()];this.sessions.clear(),await Promise.all(e.map(async e=>await this.dispose(e,!0)))}async ensureSession(e,t){let n=e.target.udid,r=this.sessions.get(n);if(r&&r.bridgePath===e.bridge.path&&r.process.isAlive())return(!r.socket||r.socket.destroyed)&&(r.socket=await this.connectUntilReady(r,t)),r;r&&await this.removeSession(r,!0);let i=Ce(this.host,e.target.udid,this.ownerId);await this.host.ensureDirectory(v.dirname(i)),await this.host.remove(i);let a=this.host.start(e.target.udid,e.bridge.path,i,{signal:t.signal}),o={udid:e.target.udid,bridgePath:e.bridge.path,socketPath:i,process:a};this.sessions.set(n,o);try{return o.socket=await this.connectUntilReady(o,t),o}catch(e){throw await this.removeSession(o,!0),T(e)}}async connectUntilReady(e,t){let n;for(;;){let r=E(t,`bridge-connect-deadline`);if(!e.process.isAlive())throw await B(this.host,e.process);try{return await this.host.connect(e.socketPath,{signal:t.signal,timeoutMs:Math.min(250,r)})}catch(e){if(n=e,e instanceof C&&e.failureKind===`cancelled`)throw e;let r=Math.min(20,E(t,`bridge-connect-deadline`));try{await D(t,r,`bridge-connect-deadline`)}catch(e){throw T(e)}}if(n instanceof C&&n.failureKind===`timeout`)throw n}}async exchange(e,t,n){(!e.socket||e.socket.destroyed)&&(e.socket=await this.connectUntilReady(e,n));let r=b(),i=ue(pe({requestId:r,pid:t.target.pid,generation:t.target.generation,maxDepth:Math.min(t.limits.maxTraversalDepth,t.maxDepth),maxNodes:t.limits.maxNodes,maxDurationMs:E(n,`bridge-request-deadline`),maxResponseBytes:t.limits.maxResponseBytes}),t.limits);return await Te({process:e.process,socket:e.socket,frame:i,requestId:r,deadline:n,limits:t.limits,expectedPid:t.target.pid,expectedGeneration:t.target.generation,host:this.host})}async readTargetStartTime(e,t){let n=await this.host.readTargetProcessStartTime(e.pid,{signal:t.signal,timeoutMs:E(t,`target-identity-deadline`)});if(!n)throw w(`stale-target`,`target-process-unavailable`,{pid:e.pid,generation:e.generation});if(e.processStartTime!==void 0&&e.processStartTime!==n)throw w(`stale-target`,`target-process-changed`,{pid:e.pid,generation:e.generation,expectedStartTime:e.processStartTime,observedStartTime:n});return n}async assertTargetStillCurrent(e,t,n){let r=await this.host.readTargetProcessStartTime(e.pid,{signal:n.signal,timeoutMs:E(n,`target-identity-deadline`)});if(r!==t)throw w(`stale-target`,`target-process-changed`,{pid:e.pid,generation:e.generation,expectedStartTime:t,observedStartTime:r})}async removeSession(e,t){this.sessions.get(e.udid)===e&&this.sessions.delete(e.udid),await this.dispose(e,t)}async dispose(e,t){e.socket?.destroy(),e.socket=void 0,t&&e.process.isAlive()&&(e.process.signal(`SIGTERM`),await V(e.process,500),e.process.isAlive()&&(e.process.signal(`SIGKILL`),await V(e.process,500))),await this.host.remove(e.socketPath)}};async function De(e,t){let n=E(t,`bridge-request-deadline`);await Promise.race([e,D(t,n,`bridge-request-deadline`).then(()=>{throw w(`timeout`,`bridge-request-deadline`)})])}function Oe(e,t,n){return(e.failureKind===`cancelled`||e.failureKind===`timeout`)&&(e.details?.dispatched===!0||n!==t)}async function V(e,t){await Promise.race([e.wait.catch(()=>void 0),new Promise(e=>setTimeout(e,t))])}const H=16777216,U=12e4,W=1e4,ke=Object.freeze({maxRequestBytes:65536,maxResponseBytes:4194304,maxNodes:1500,maxTraversalDepth:64,maxDurationMs:5e3});function Ae(e){let n={...ke,...e??{}};for(let[e,r]of Object.entries(n))if(!Number.isSafeInteger(r)||r<=0)throw new t(`INVALID_ARGS`,`Snapshot source limit ${e} must be a positive integer`,{name:e,value:r});if(n.maxRequestBytes>n.maxResponseBytes)throw new t(`INVALID_ARGS`,`Snapshot source request bytes cannot exceed response bytes`,{maxRequestBytes:n.maxRequestBytes,maxResponseBytes:n.maxResponseBytes});if(n.maxRequestBytes>H||n.maxResponseBytes>H)throw new t(`INVALID_ARGS`,`Snapshot source frame limits exceed the bridge bound`,{maxRequestBytes:n.maxRequestBytes,maxResponseBytes:n.maxResponseBytes,maximumFrameBytes:H});if(n.maxNodes>W||n.maxTraversalDepth>128)throw new t(`INVALID_ARGS`,`Snapshot source tree limits exceed the bridge bound`,{maxNodes:n.maxNodes,maxTraversalDepth:n.maxTraversalDepth,maximumNodes:W,maximumDepth:128});if(n.maxDurationMs>U)throw new t(`INVALID_ARGS`,`Snapshot source duration exceeds the bridge bound`,{maxDurationMs:n.maxDurationMs,maximumDurationMs:U});if(n.maxRequestBytes<=4||n.maxResponseBytes<=4)throw new t(`INVALID_ARGS`,`Snapshot source frame limits must leave room for a body`,{maxRequestBytes:n.maxRequestBytes,maxResponseBytes:n.maxResponseBytes});return Object.freeze(n)}const G=Object.freeze({elementType:`XC_kAXXCAttributeElementType`,elementBaseType:`XC_kAXXCAttributeElementBaseType`,label:`XC_kAXXCAttributeLabel`,value:`XC_kAXXCAttributeValue`,identifier:`XC_kAXXCAttributeIdentifier`,frame:`XC_kAXXCAttributeFrame`,automationType:`XC_kAXXCAttributeAutomationType`,children:`XC_kAXXCAttributeChildren`}),K=`Other.Other.Application.Group.Window.Sheet.Drawer.Alert.Dialog.Button.RadioButton.RadioGroup.CheckBox.DisclosureTriangle.PopUpButton.ComboBox.MenuButton.ToolbarButton.Popover.Keyboard.Key.NavigationBar.TabBar.TabGroup.Toolbar.StatusBar.Table.TableRow.TableColumn.Outline.OutlineRow.Browser.CollectionView.Slider.PageIndicator.ProgressIndicator.ActivityIndicator.SegmentedControl.Picker.PickerWheel.Switch.Toggle.Link.Image.Icon.SearchField.ScrollView.ScrollBar.StaticText.TextField.SecureTextField.DatePicker.TextView.Menu.MenuItem.MenuBar.MenuBarItem.Map.WebView.IncrementArrow.DecrementArrow.Timeline.RatingIndicator.ValueIndicator.SplitGroup.Splitter.RelevanceIndicator.ColorWell.HelpTag.Matte.DockItem.Ruler.RulerMarker.Grid.LevelIndicator.Cell.LayoutArea.LayoutItem.Handle.Stepper.Tab.TouchBar.StatusItem`.split(`.`),q={UIApplication:`Application`,UIWindow:`Window`},je=new Set(Object.values(G));function Me(e,t,n){let r=Array.isArray(e)?e:[e];if(r.length===0||r.some(e=>!j(e)))throw w(`malformed-tree`,`guest-tree-root-invalid`);let i=[],a=0;for(let e of r)o(e,void 0,0);if(i.length>n.maxNodes)throw w(`malformed-tree`,`node-limit-exceeded`,{nodeCount:i.length,maxNodes:n.maxNodes});if(a>n.maxTraversalDepth)throw w(`malformed-tree`,`traversal-depth-exceeded`,{maxTraversalDepth:a,maxAllowedDepth:n.maxTraversalDepth});if(typeof t.truncated!=`boolean`)throw w(`malformed-tree`,`truncated-invalid`);return{nodes:i,maxTraversalDepth:a,viewport:Fe(i.find(e=>e.type===`Application`||e.type===`Window`))};function o(e,t,r){if(i.length>=n.maxNodes)throw w(`malformed-tree`,`node-limit-exceeded`,{maxNodes:n.maxNodes});for(let t of Object.keys(e))if(!je.has(t))throw w(`malformed-tree`,`node-contains-unknown-field`,{key:t});let s=e[G.children];if(!Array.isArray(s))throw w(`malformed-tree`,`children-invalid`);let c=i.length,l=Ne(e,c,t,r);i.push(l),a=Math.max(a,r);for(let e of s){if(!j(e))throw w(`malformed-tree`,`child-invalid`);o(e,c,r+1)}}}function Ne(e,t,n,r){let i=Y(e[G.elementType]),a=Y(e[G.elementBaseType]),o=Ie(e[G.automationType]),s=Pe(e[G.frame]);return{index:t,...n===void 0?{}:{parentIndex:n},...J(i,o)?{type:J(i,o)}:{},...i?{role:i}:{},...a&&a!==i?{subrole:a}:{},...Y(e[G.label])?{label:Y(e[G.label])}:{},...X(e[G.value])?{value:X(e[G.value])}:{},...Y(e[G.identifier])?{identifier:Y(e[G.identifier])}:{},...s?{rect:s}:{},depth:r}}function J(e,t){if(e!==void 0&&q[e])return q[e];if(e!==void 0&&K.includes(e))return e;if(t!==void 0)return K[t]??`Other`}function Pe(e){if(e===void 0)return;if(!j(e))throw w(`malformed-tree`,`frame-invalid`);let t=[`X`,`Y`,`Width`,`Height`].map(t=>e[t]);if(!t.every(e=>typeof e==`number`&&Number.isFinite(e)))throw w(`malformed-tree`,`frame-invalid`);let[n,r,i,a]=t;if(i<0||a<0)throw w(`malformed-tree`,`frame-invalid`);return{x:n,y:r,width:i,height:a}}function Fe(e){return!e||e.type!==`Application`&&e.type!==`Window`?{kind:`missing`,reason:`not-provided`}:n(e.rect)?{kind:`reported`,rect:e.rect}:{kind:`missing`,reason:e.rect?`invalid`:`not-provided`}}function Y(e){return typeof e==`string`&&e.length>0?e:void 0}function X(e){if(typeof e==`string`)return e.length>0?e:void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e!=null)throw w(`malformed-tree`,`scalar-invalid`)}function Ie(e){if(e!=null){if(!Number.isSafeInteger(e))throw w(`malformed-tree`,`automation-type-invalid`);return e}}const Z=`simulator-ax-bridge`;function Le(e={}){let t=e.host??ve(),n=new Ee(t),r=new Map,i=!1,a=async n=>{if(i)throw w(`unsupported`,`source-closed`);let a=r.get(n.runtime);if(a)return a;let o=await t.withDiagnosticTimer(`ios.snapshot-source.prepare`,async()=>await P({host:t,runtime:n.runtime,limits:n.limits,deadline:n.deadline,sourceRoot:e.sourceRoot,cacheRoot:e.cacheRoot}),{producer:Z});return r.set(n.runtime,o),o};return{acquire:async r=>{try{if(i)throw w(`unsupported`,`source-closed`);Re(r);let o=Ae({...e.limits,...r.limits}),s=oe(o.maxDurationMs,r.signal),c=Q(r.hint,o.maxTraversalDepth);return await t.withDiagnosticTimer(`ios.snapshot-source.acquire`,async()=>{let e=await a({runtime:r.target.runtime,limits:o,deadline:s}),t=await n.request({target:r.target,bridge:e,limits:o,maxDepth:c,deadline:s});return E(s,`snapshot-decode-deadline`),{stage:`acquired`,acquisition:ze(r.hint,r.target,t,o,c)}},{producer:Z})}catch(e){let t=T(e);return{stage:`failed`,failure:{kind:t.failureKind,code:t.failureCode,...t.details?{details:t.details}:{}}}}},close:async()=>{i||(i=!0,await n.close())}}}function Re(e){if(!e.target.udid.trim()||!e.target.runtime.trim()||!e.target.generation.trim()||!Number.isSafeInteger(e.target.pid)||e.target.pid<=0)throw new t(`INVALID_ARGS`,`Simulator snapshot source target identity is incomplete`);let n=e.hint;if(n.projection!==`raw`&&n.projection!==`regular`||![`full`,`surface-observation`].includes(n.acquisitionIntent)||typeof n.interactiveOnly!=`boolean`||typeof n.customActions!=`boolean`||!$(n.rawTraversalDepth)||!$(n.regularPresentedDepth))throw new t(`INVALID_ARGS`,`Simulator snapshot source capture hint is invalid`)}function Q(e,n){let r=e.rawTraversalDepth??n;if(r>n)throw new t(`INVALID_ARGS`,`Simulator snapshot source depth exceeds its bound`,{requested:r,maximum:n});return r}function $(e){return e===null||Number.isSafeInteger(e)&&e>=0}function ze(e,t,n,r,i){if(n.automationEnabled!==!0)throw w(`unsupported`,`automation-mode-unavailable`);let a=n.tree,o=n.truncated;if(typeof o!=`boolean`)throw w(`malformed-tree`,`truncated-invalid`);let s=Me(a,{truncated:o},r),c=n.generation;if(typeof c!=`string`||!c)throw w(`malformed-tree`,`generation-invalid`);let l=Object.freeze(s.nodes.map(e=>Object.freeze({...e,pid:t.pid}))),u=Be(e,o,s,r,i,l.length),d=Object.freeze({...t.targetId?{targetId:t.targetId}:{},generation:c}),f={producer:Z,nodes:l,truncated:o,viewport:s.viewport,lineage:d,residue:u};return e.acquisitionIntent===`full`?{...f,intent:`full`,hint:{...e,acquisitionIntent:`full`}}:{...f,intent:`surface-observation`,hint:{...e,acquisitionIntent:`surface-observation`}}}function Be(e,t,n,r,i,a){return Object.freeze([{kind:`unavailable-fact`,fact:`hittability`},...e.interactiveOnly?[{kind:`unavailable-fact`,fact:`interactive-query`}]:[],...t?[Ve(n.maxTraversalDepth,a,r,i)]:[],...n.viewport.kind===`missing`?[{kind:`missing-viewport`,reason:n.viewport.reason}]:[]])}function Ve(e,t,n,r){return t>=n.maxNodes?{kind:`truncated`,dimension:`nodes`,limit:n.maxNodes}:e>=r?{kind:`truncated`,dimension:`depth`,limit:r}:{kind:`truncated`,dimension:`payload`,limit:n.maxResponseBytes}}export{Le as createSimulatorSnapshotSource};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{a as t,r as n}from"./adb-host.js";import{n as r,s as i}from"./adb-failure.js";import a from"node:path";import{AsyncLocalStorage as o}from"node:async_hooks";const s=new WeakSet;function c(e){return l(typeof e==`function`?{exec:e}:e)}function l(e){if(s.has(e))return e;let t={...e,exec:i(u(e.exec)),...e.pull?{pull:i(u(e.pull))}:{},...e.install?{install:i(u(e.install))}:{},...e.installBundle?{installBundle:i(e.installBundle)}:{}};return s.add(t),t}function u(e){return async(...t)=>n().coerceAdbResult(await e(...t))}const d=new WeakSet;function f(t){let n=c(t);if(n.reverse&&d.has(n.reverse))return n.reverse;let r=n.reverse??p(n.exec),i=new Map,a={async ensure(t,n){let a=i.get(t.local);if(a&&a.ownerId!==t.ownerId)throw new e(`COMMAND_FAILED`,`Android port reverse ${t.local} is already owned by ${a.ownerId??`another session`}`,{current:a,requested:t});a?.remote!==t.remote&&(await r.ensure(t,n),i.set(t.local,{...t}))},async remove(e,t){if(!i.has(e)){await r.remove(e,t);return}await r.remove(e,t),i.delete(e)},async removeAllOwned(e,t){let n=[...i.values()].filter(t=>t.ownerId===e).map(e=>e.local);if(n.length===0){await r.removeAllOwned(e,t);return}for(let e of n)await r.remove(e,t),i.delete(e)},async list(e){return r.list?await r.list(e):[...i.values()]}};return d.add(a),a}function p(e){let t=new Map;return{async ensure(n,r){if(await e([`reverse`,n.local,n.remote],{allowFailure:!1,signal:r?.signal,timeoutMs:r?.timeoutMs}),n.ownerId){let e=t.get(n.ownerId)??new Set;e.add(n.local),t.set(n.ownerId,e)}},async remove(n,i){let a=await e([`reverse`,`--remove`,n],{allowFailure:!0,signal:i?.signal,timeoutMs:i?.timeoutMs});if(a.exitCode!==0&&!h(a.stdout,a.stderr))throw r(`Failed to remove Android port reverse ${n}`,a,{local:n});for(let e of t.values())e.delete(n)},async removeAllOwned(e,n){let r=[...t.get(e)??[]];for(let e of r)await this.remove(e,n);t.delete(e)},async list(n){let r=await e([`reverse`,`--list`],{allowFailure:!0,signal:n?.signal,timeoutMs:n?.timeoutMs});return r.exitCode===0?m(r.stdout,t):[]}}}function m(e,t){let n=new Map;for(let[e,r]of t)for(let t of r)n.set(t,e);return e.split(`
|
|
2
|
+
`).map(e=>e.trim().split(/\s+/)).filter(e=>e.length>=3).map(([,e,t])=>{let r=e;return{local:r,remote:t,ownerId:n.get(r)}})}function h(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`listener`)&&n.includes(`not found`)}function g(e){let{replace:t,allowTestPackages:n,allowDowngrade:r,grantPermissions:i,...a}=e??{},o=[];return t&&o.push(`-r`),n&&o.push(`-t`),r&&o.push(`-d`),i&&o.push(`-g`),{installArgs:o,execOptions:a}}const _=new o;function v(e,t={}){return y(e.id,t.serverPort)}function y(e,t){return i(async(r,i)=>{let a=N(e,t);return await n().execSerialAdb(e,r,a===void 0?i:{...i,serverPort:a})})}function b(e,t){return(r,i)=>{let a=N(e,t);return n().spawnSerialAdb(e,r,a===void 0?i:{...i,serverPort:a})}}function x(e,t={}){let n=v(e,t);return{exec:n,spawn:b(e.id,t.serverPort),reverse:p(n),pull:async(e,t,r)=>await n([`pull`,e,t],r),install:async(e,t)=>{let{installArgs:r,execOptions:i}=g(t);return await n([`install`,...r,e],i)}}}function S(e,t){let n=j(e);return t||(n?.serial===e.id?n.provider.exec:v(e))}function C(e,t){let n=j(e);return t?c(t):n?.serial===e.id?c(n.provider):x(e)}function w(e){let t=j(e);return t?.serial===e.id?{mode:`transport-composed`,...t.provider.spawn?{spawn:t.provider.spawn}:{}}:{mode:`local`}}function T(e){let t=j(e);return t?.serial===e.id?t.provider.text:void 0}function E(e){let t=j(e);return t?.serial===e.id&&t.provider.touch?t.provider:void 0}function D(e,t){if(t)return c(t);if(e)return C(e);let n=_.getStore();if(n)return c(n.provider)}async function O(e,r,i){if(!e)return await i();let a={provider:c(e),serial:r.serial,...r.serverPort===void 0?{}:{serverPort:r.serverPort}},o=k(a),s=async()=>await _.run(a,async()=>await n().withAdbCommandExecutorOverride(o,i));return r.serverPort===void 0?await s():await t(A(a),s)}function k(e){return(t,r,i)=>{if(!P(t)||e.serverPort===void 0&&t!==`adb`)return;let a=F(r);if(M(e,a),!(a&&a!==e.serial)){if(a===e.serial){let t=L(r,e.serial);return t?n().withoutAdbCommandExecutorOverride(async()=>await e.provider.exec(t,i)):void 0}if(e.serverPort!==void 0)return n().withoutAdbCommandExecutorOverride(async()=>await n().execHostAdb([`-s`,e.serial,...r],{...i,allowFailure:!0,serverPort:e.serverPort}))}}}function A(e){return async(t,r)=>{let i=F(t);M(e,i);let a=n();return await a.withoutAdbCommandExecutorOverride(async()=>await a.execHostAdb(i===void 0?[`-s`,e.serial,...t]:t,{...r,allowFailure:!0,serverPort:e.serverPort}))}}function j(e){let t=_.getStore();return M(t,e.id),t}function M(t,n){if(t?.serverPort!==void 0&&n!==void 0&&n!==t.serial)throw new e(`COMMAND_FAILED`,`Managed ADB transport cannot address another device.`,{reason:`managed-device-transport-mismatch`})}function N(t,n){let r=_.getStore();if(M(r,t),r?.serverPort===void 0)return n;if(n!==void 0&&n!==r.serverPort)throw new e(`COMMAND_FAILED`,`Managed ADB transport cannot select another server.`,{reason:`managed-device-transport-mismatch`});return r.serverPort}function P(e){return a.basename(e).replace(/\.(?:com|exe|bat|cmd)$/i,``)===`adb`}function F(e){let t=I(e);return t===void 0?void 0:e[t+1]}function I(e){let t=0;for(;t<e.length;){let n=e[t];if(n===`-s`)return t;if(n===`-P`||n===`-H`||n===`-L`){t+=2;continue}if(n===`-a`||n===`-d`||n===`-e`){t+=1;continue}return}}function L(e,t){let n=I(e);if(n!==void 0&&e[n+1]===t)return[...e.slice(0,n),...e.slice(n+2)]}async function R(t,r,i){let{device:a,provider:o,...s}=i??{},c=D(a,o),l=c?.pull,u=n();if(l)return await u.withoutAdbCommandExecutorOverride(async()=>await l(t,r,s));let d=c?.exec;if(!d)throw new e(`COMMAND_FAILED`,`Android adb pull requires an adb provider`);return await u.withoutAdbCommandExecutorOverride(async()=>await d([`pull`,t,r],s))}async function z(t,r){let{device:i,provider:a,...o}=r??{},s=D(i,a),c=s?.install,l=n();if(c)return await l.withoutAdbCommandExecutorOverride(async()=>await c(t,o));let u=s?.exec;if(!u)throw new e(`COMMAND_FAILED`,`Android adb install requires an adb provider`);let{installArgs:d,execOptions:f}=g(o);return await l.withoutAdbCommandExecutorOverride(async()=>await u([`install`,...d,t],f))}export{S as a,E as c,f as d,x as i,w as l,R as n,C as o,v as r,T as s,z as t,O as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{y as t}from"./sdk-contracts.js";var n=e({androidAdbResultError:()=>c,androidDiscoveryCommandError:()=>u,attachAdbFailureHint:()=>o,attachAndroidDiscoveryTimeout:()=>d,classifyAndroidAdbFailure:()=>a,withAdbFailureHints:()=>l});const r=[[/device unauthorized|device still authorizing/,{reason:`device_unauthorized`,hint:`USB debugging is not authorized — accept the authorization prompt on the device screen (re-plug the cable if none appears), then retry.`}],[/device offline/,{reason:`device_offline`,hint:`The device is connected but offline — wait for it to finish booting or run adb reconnect, then retry.`,retriable:!0}],[/more than one (?:device\/emulator|device and emulator)/,{reason:`multiple_devices`,hint:`Multiple Android devices are connected — pass --serial <serial> (see adb devices) to select one.`}],[/no devices\/emulators found|no devices found/,{reason:`no_devices`,hint:`No Android devices detected — boot an emulator or connect a device and verify it appears in adb devices.`}],[/device (?:'[^']*' )?not found/,{reason:`device_not_found`,hint:`The device disconnected or is restarting — verify it is listed in adb devices, then retry.`,retriable:!0}],[/adb server version \(\d+\) doesn't match this client/,{reason:`server_version_mismatch`,hint:`Multiple adb installs conflict — adb restarts its server automatically, so retry; align PATH to a single adb to stop recurrences.`,retriable:!0}],[/transport error|connection reset|broken pipe|protocol fault/,{reason:`connection_dropped`,hint:`The adb connection dropped — retry; if it persists, run adb kill-server and reconnect the device.`,retriable:!0}],[/install_failed_insufficient_storage/,{reason:`install_insufficient_storage`,hint:`The device is out of storage — free up space or uninstall unused apps, then retry the install.`},!0],[/install_failed_update_incompatible/,{reason:`install_update_incompatible`,hint:`The installed app has an incompatible signature — uninstall the existing app first, then retry the install.`},!0],[/install_failed_version_downgrade/,{reason:`install_version_downgrade`,hint:`The APK is older than the installed app — uninstall the app first (or install with downgrade allowed), then retry.`},!0],[/install_failed_\w+|install_parse_failed_\w+/,{reason:`install_failed`,hint:`The Android package installer rejected the APK — see the INSTALL_FAILED code in the error output for the exact cause.`},!0]],i=Object.freeze({reason:`timeout`,hint:`adb timed out — the adb server may be wedged. Run adb kill-server && adb start-server, check adb devices, then retry.`});function a(e,t=``){let n=e.toLowerCase(),i=t.toLowerCase();for(let[e,t,a]of r)if(e.test(n)||a&&e.test(i))return t}function o(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return e;let n=s(e);return n&&(e.details={...e.details,adbFailure:n.reason,...typeof e.details?.hint==`string`?{}:{hint:n.hint},...n.retriable!==void 0&&e.details?.retriable===void 0?{retriable:n.retriable}:{}}),e}function s(e){return typeof e.details?.timeoutMs==`number`?i:a(typeof e.details?.stderr==`string`?e.details.stderr:``,typeof e.details?.stdout==`string`?e.details.stdout:``)}function c(e,n,r){let i=n.exitCode===0?{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,...r}:{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,processExitError:!0,...r};return o(new t(`COMMAND_FAILED`,e,i))}function l(e){return async(...t)=>{try{return await e(...t)}catch(e){throw o(e)}}}function u(e,n,r){let i=a(n.stderr,n.stdout);return new t(`COMMAND_FAILED`,e,{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,processExitError:!0,hint:i?.hint??r,...i?{adbFailure:i.reason}:{},...i?.retriable===void 0?{}:{retriable:i.retriable}})}function d(e){return!(e instanceof t)||e.code!==`COMMAND_FAILED`||typeof e.details?.timeoutMs!=`number`||(e.details={...e.details,adbFailure:i.reason,...typeof e.details.hint==`string`?{}:{hint:i.hint}}),e}export{d as a,o as i,c as n,a as o,u as r,l as s,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AsyncLocalStorage as e}from"node:async_hooks";let t;const n=new e;function r(e){t=e}function i(){if(!t)throw Error(`Android adb host port is not bound; import the platform composition wiring (src/platform-runtime-android-adb-host.ts) before using the adb/IME cluster.`);return t}async function a(e,t){let r=i(),a=n.getStore(),o=r.coerceAdbResult(a?await a(e,t):await r.execHostAdb(e,{...t,allowFailure:!0}));if(!t?.allowFailure&&o.exitCode!==0){let{androidAdbResultError:t}=await import(`./adb-failure.js`).then(e=>e.t);throw t(`adb ${e.join(` `)} exited with code ${o.exitCode}`,o)}return o}async function o(e,t){return await n.run(e,t)}function s(e){i().emitDiagnostic(e)}export{o as a,a as i,s as n,i as r,r as t};
|
package/dist/src/adb.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import"./retry.js";import{a as t}from"./adb-executor.js";var n=e({isAndroidShellCommandUnsupported:()=>i,runAndroidAdb:()=>r});async function r(e,n,r){return await t(e)(n,r)}function i(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`no shell command implementation`)||n.includes(`unknown command`)}export{i as n,r,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{nr as t}from"./sdk-batch.js";import{r as n}from"./diagnostics.js";import{c as r}from"./owner-identity.js";import"./diagnostics2.js";import{n as i}from"./process.js";import{_ as a,d as o}from"./host-file.js";import"./agent-browser-process-record.js";import s from"node:path";var c=e({DEFAULT_AGENT_BROWSER_IDLE_TIMEOUT_MS:()=>l,cleanupManagedAgentBrowserOrphans:()=>f,cleanupManagedAgentBrowserOrphansForProviderStartup:()=>p,resolveAgentBrowserIdleTimeoutMs:()=>d});const l=3e5,u=new Map;function d(e){return m(e.AGENT_BROWSER_IDLE_TIMEOUT_MS)??m(e.AGENT_DEVICE_WEB_IDLE_TIMEOUT_MS)??3e5}async function f(e,a,o={}){let s=t((o.openWebSessionNames??[]).filter(e=>e.length>0));if(s.length>0)return h(`open-web-session`,{openWebSessionNames:s});let c=d(r()),l=_(e);if(l!==void 0&&Date.now()-l<c)return h(`recent-browser-activity`,{idleTimeoutMs:c,latestActivityMs:l});let u=o.ownedProcessRecords;if(!u)return g();let f=await i(u,{openWebSessionNames:s,purposes:[`managed-web-browser`],termTimeoutMs:1500,killTimeoutMs:1e3}),p=[...f.terminatedPids];return f.inspected>0&&n({level:`warn`,phase:`web_agent_browser_orphan_cleanup`,data:{reason:a,count:f.inspected,pids:[...f.inspectedPids],signalPids:p,ownershipLostPids:[...f.ownershipLostPids],stateDir:e.stateDir,installDir:e.installDir}}),{count:f.inspected,pids:[...f.inspectedPids],processes:[],signalPids:p}}async function p(e,t={}){let n=Date.now(),r=s.resolve(e.stateDir),i=u.get(r);if(!(i!==void 0&&n-i<3e4))return u.set(r,n),await f(e,`provider-startup`,t)}function m(e){if(e===void 0||e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isInteger(t)&&t>0?t:void 0}function h(e,t){return{count:0,pids:[],processes:[],signalPids:[],skipped:{reason:e,...t}}}function g(){return{count:0,pids:[],processes:[],signalPids:[]}}function _(e){let t=v(e.socketDir).map(e=>y(e)).filter(e=>e!==void 0);return t.length>0?Math.max(...t):void 0}function v(e){try{return a(e).map(t=>s.join(e,t))}catch{return[]}}function y(e){try{return o(e).mtimeMs}catch{return}}export{p as n,d as r,c as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{nr as t}from"./sdk-batch.js";import{b as n,f as r,g as i,o as a,y as o}from"./owner-identity.js";import{h as s}from"./exec.js";import"./command.js";import"./process.js";import c from"node:path";import l from"node:crypto";var u=e({agentBrowserChromeLaunchMarker:()=>d,appendAgentDeviceChromeArgs:()=>f,inspectManagedAgentBrowserProcesses:()=>_,matchAgentBrowserChromeProcess:()=>p,recordManagedAgentBrowserProcesses:()=>v,summarizeAgentBrowserProcesses:()=>m,summarizeManagedAgentBrowserProcesses:()=>g});function d(e){let t=l.createHash(`sha256`);return t.update(c.resolve(e.stateDir)),t.update(`\0`),t.update(c.resolve(e.installDir)),`--agent-device-managed-web=${t.digest(`hex`).slice(0,16)}`}function f(e,t){let n=d(t),r=e?.trim();return r?x(r).includes(n)?r:`${r},${n}`:n}function p(e,t){if(!(e.pid===r()||!S(e.command))){if(e.command.includes(d(t)))return{process:e,reason:`launch-marker`};if(w(t).some(t=>T(e,t)))return{process:e,reason:`managed-browser-home`}}}function m(e,t){return b(e,e=>p(e,t))}function h(e,t){return p(e,t)??C(e,t)}function g(e,t){return b(e,e=>h(e,t))}async function _(e){return m(await y(),e)}async function v(e,t){let r=await y(),i=g(r,e),s=a(i.pids,r),c={count:s.length,pids:s.map(({pid:e})=>e),processes:s.map(t=>({process:t,reason:h(t,e)?.reason??`descendant`}))},l=c.processes.flatMap(({process:e})=>{let t=n(e.pid),r=o(e.pid);return t&&r?[{pid:e.pid,startTime:t,command:r,purpose:`managed-web-browser`}]:[]});return l.length>0&&t.replace({kind:`daemon`},l),c}async function y(){return await s(async()=>await i({timeoutMs:1500}))}function b(e,t){let n=e.flatMap(e=>{let n=t(e);return n?[n]:[]});return{count:n.length,pids:n.map(e=>e.process.pid),processes:n}}function x(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)}function S(e){return/\b(?:Google Chrome for Testing|Chrome for Testing|Chromium|chrome|chrome\.exe|chromium|chromium-browser|headless_shell)\b/i.test(e)}function C(e,t){if(e.pid===r()||S(e.command))return;let n=E(e.command),i=E(c.resolve(t.installDir));return n.includes(`${i}/`)?{process:e,reason:`agent-browser-daemon`}:void 0}function w(e){return t([c.join(e.homeDir,`.agent-browser`,`browsers`),c.join(e.runtimeHomeDir,`.agent-browser`,`browsers`)])}function T(e,t){let n=E(e.command),r=`${E(c.resolve(t)).replace(/\/+$/,``)}/`;return n.includes(r)}function E(e){return e.replaceAll(`\\`,`/`)}export{v as i,f as n,_ as r,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{D as t}from"./sdk-batch-runner.js";import{r as n}from"./diagnostics.js";import{d as r}from"./owner-identity.js";import{n as i}from"./exec.js";import{t as a}from"./timeouts.js";import"./diagnostics2.js";import"./command.js";import"./retry.js";import"./process.js";import{n as o}from"./audio-probe-result.js";import{i as s}from"./agent-browser-process-record.js";import{n as c}from"./agent-browser-lifecycle.js";import{i as l,n as u,r as d}from"./agent-browser-tool.js";function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e,t){return f(e)?e[t]:void 0}function m(e,t){let n=p(e,t);return typeof n==`string`?n:void 0}function ee(e,t){let n=p(e,t);return typeof n==`boolean`?n:void 0}function h(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}const te=[_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N];function ne(e){let t=te.map(e=>`${e.toString()};`).join(``),n=ie(e.action),r=g(e.durationMs),i=g(e.bucketMs);return`(()=>{${t}return ${N.name}({action:${n},durationMs:${r},bucketMs:${i}})})()`}function re(e){let t=o(ae(e),{source:`media-elements`,backend:`agent-browser`,durationMs:0,elapsedMs:0,bucketMs:1e3,activeFallback:!1,mediaElementCount:0,sourceCount:0});return{...t,source:`media-elements`,mediaElementCount:t.mediaElementCount??0}}function ie(e){switch(e){case`start`:return`'start'`;case`stop`:return`'stop'`;default:return`'status'`}}function g(e){return e===void 0||!Number.isFinite(e)?`undefined`:String(Math.trunc(e))}function _(e){return!Number.isFinite(e)||e<=0?-90:Math.max(-90,Math.min(0,Math.round(20*Math.log10(e))))}function v(e,t){e.notes.includes(t)||e.notes.push(t)}function y(){return Array.from(document.querySelectorAll(`audio,video`))}function b(e,t){if(!e||e.state===`stopped`)return e;clearInterval(e.timer),clearTimeout(e.timeout),e.timer=void 0,e.timeout=void 0,e.state=`stopped`,e.active=!1,e.reason=t,e.stoppedAt=Date.now();for(let t of e.analysers)try{t.analyser.disconnect(),t.source.disconnect(),t.audible&&t.source.connect(e.context.destination)}catch{}if(e.resumeOnGesture){for(let t of[`click`,`pointerdown`,`keydown`])window.removeEventListener(t,e.resumeOnGesture,!0);e.resumeOnGesture=void 0}return e}function x(e){let t=window.AudioContext||window.webkitAudioContext;if(!t)return;let n=window[e];if(n&&n.state!==`closed`)return n;let r=new t;return window[e]=r,r}function S(e,t,n){if(!(!t.currentSrc&&!t.src&&t.readyState===0))try{window[n]||(window[n]=new WeakMap);let r=window[n].get(t);return r||(r=e.context.createMediaElementSource(t),window[n].set(t,r)),r.disconnect(),{source:r,audible:!0}}catch{return}}function C(e,t){if(!(!t||typeof t.getAudioTracks!=`function`)&&t.getAudioTracks().length!==0)return{source:e.context.createMediaStreamSource(t),audible:!1}}function w(e,t){if(typeof t.captureStream==`function`)return C(e,t.captureStream())}function T(e,t){let n=e.context.createAnalyser();n.fftSize=2048,t.source.connect(n),n.connect(t.audible?e.context.destination:e.sink),e.analysers.push({...t,analyser:n,buffer:new Float32Array(n.fftSize)})}function E(e,t){let n=y();e.mediaElementCount=n.length;for(let r of n){if(e.seen.has(r))continue;let n=C(e,r.srcObject)??w(e,r)??S(e,r,t);if(!n){v(e,`Some media elements do not expose capturable audio to Web Audio.`);continue}e.seen.add(r),T(e,n)}e.sourceCount=e.analysers.length,e.sourceCount===0&&v(e,`No capturable page media audio sources were found yet.`)}function D(e){let t=0,n=0,r=0;for(let i of e.analysers){i.analyser.getFloatTimeDomainData(i.buffer);for(let e of i.buffer)t+=e*e,n+=1,r=Math.max(r,Math.abs(e))}return{rms:n>0?Math.sqrt(t/n):0,peak:r}}function O(e){let t=Math.ceil(e.durationMs/e.bucketMs)+2;e.rmsDbfs.length>t&&e.rmsDbfs.splice(0,e.rmsDbfs.length-t),e.peakDbfs.length>t&&e.peakDbfs.splice(0,e.peakDbfs.length-t)}function k(e,t){if(!e||e.state!==`running`)return;E(e,t);let n=D(e),r=_(n.rms),i=_(n.peak);e.rmsDbfs.push(r),e.peakDbfs.push(i),e.heard=e.heard||r>-90||i>-90,O(e),Date.now()-e.startedAt>=e.durationMs&&b(e,`duration`)}function A(e,t){return{audio:`probe`,state:`stopped`,active:!1,heard:!1,source:`media-elements`,backend:`agent-browser`,durationMs:Number(e.durationMs)||1e4,elapsedMs:0,bucketMs:Number(e.bucketMs)||1e3,sampleCount:0,mediaElementCount:y().length,sourceCount:0,rmsDbfs:[],peakDbfs:[],notes:t}}function j(e,t,n,r){return e?{audio:`probe`,state:e.state,active:e.state===`running`,heard:e.heard,source:`media-elements`,backend:`agent-browser`,durationMs:e.durationMs,elapsedMs:Math.max(0,Math.min((e.stoppedAt||Date.now())-e.startedAt,e.durationMs)),bucketMs:e.bucketMs,sampleCount:e.rmsDbfs.length,mediaElementCount:y().length,sourceCount:e.sourceCount,rmsDbfs:e.rmsDbfs.slice(),peakDbfs:e.peakDbfs.slice(),startedAt:new Date(e.startedAt).toISOString(),stoppedAt:e.stoppedAt?new Date(e.stoppedAt).toISOString():void 0,reason:e.reason,notes:[n,r,...e.notes]}:A(t,[n,r])}function M(e,t,n,r,i,a,o){t&&b(t,`restarted`);let s=x(r);if(!s)return A(e,[`Web Audio API is not available in this browser context.`]);let c=s.createGain();c.gain.value=0,c.connect(s.destination);let l={state:`running`,active:!0,context:s,sink:c,seen:new WeakSet,analysers:[],mediaElementCount:0,sourceCount:0,durationMs:Math.max(100,Number(e.durationMs)||1e4),bucketMs:Math.max(100,Number(e.bucketMs)||1e3),startedAt:Date.now(),stoppedAt:void 0,reason:void 0,heard:!1,rmsDbfs:[],peakDbfs:[],notes:[]};try{s.resume()}catch{v(l,`AudioContext could not be resumed by the probe.`)}l.resumeOnGesture=()=>{try{s.resume()}catch{v(l,`AudioContext could not be resumed from a user gesture.`)}};for(let e of[`click`,`pointerdown`,`keydown`])window.addEventListener(e,l.resumeOnGesture,{capture:!0,once:!0});return E(l,i),l.timer=setInterval(()=>k(l,i),l.bucketMs),l.timeout=setTimeout(()=>b(l,`duration`),l.durationMs),window[n]=l,j(l,e,a,o)}function N(e){let t=`__agentDeviceAudioProbe`,n=`__agentDeviceAudioProbeSources`,r=`Audio probe samples HTML media elements exposed to Web Audio; it is not whole-tab or system audio capture.`,i=`URL-backed media elements may be routed through the probe AudioContext while they are observed.`,a=window[t];return a&&a.state===`running`&&Date.now()-a.startedAt>=a.durationMs&&(k(a,n),b(a,`duration`)),e.action===`start`?M(e,a,t,`__agentDeviceAudioProbeContext`,n,r,i):e.action===`stop`?(a&&k(a,n),b(a,`manual`),j(a,e,r,i)):(a&&k(a,n),j(a,e,r,i))}function ae(e){return f(e)?f(e.result)?e.result:e:{}}function oe(e,t={}){let n=se(e),r=de(t.limit),i=t.include===`headers`||t.include===`all`,a=n.slice(-r).reverse().map(e=>le(e,i)),o=t.include===`body`||t.include===`all`?[`agent-browser network requests does not expose request or response bodies.`]:void 0;return{entries:a,backend:`agent-browser`,redacted:!1,...o?{notes:o}:{}}}function se(e){let t=f(e)&&Array.isArray(e.requests)?e.requests:e;return Array.isArray(t)?t.filter(ce).map(e=>({headers:P(e.headers),method:m(e,`method`),mimeType:m(e,`mimeType`),requestId:m(e,`requestId`),resourceType:m(e,`resourceType`),responseHeaders:P(e.responseHeaders),status:h(e,`status`),timestamp:ue(e.timestamp),url:m(e,`url`)})):[]}function ce(e){return f(e)}function le(e,n){let r=e.timestamp===void 0?void 0:F(e.timestamp),i=t({requestId:e.requestId,resourceType:e.resourceType,mimeType:e.mimeType});return t({timestamp:r,method:e.method,url:e.url,status:e.status,requestHeaders:n?e.headers:void 0,responseHeaders:n?e.responseHeaders:void 0,metadata:Object.keys(i).length>0?i:void 0})}function P(e){if(!f(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function ue(e){if(typeof e==`number`||typeof e==`string`)return e}function F(e){if(typeof e==`string`){let t=Number(e);return Number.isFinite(t)?F(t):e}let t=e>1e10?e:e*1e3,n=new Date(t);return Number.isNaN(n.getTime())?String(e):n.toISOString()}function de(e){return typeof e!=`number`||!Number.isInteger(e)?25:Math.max(1,Math.min(e,200))}async function fe(e,t){let n=me(m(e,`snapshot`)??``,L(p(e,`refs`)));return t&&await pe(n,t),{nodes:n.map((e,t)=>({...e.node,index:t,ref:e.ref})),truncated:ee(e,`truncated`)}}async function pe(e,t){for(let n=0;n<e.length;n+=8){let r=e.slice(n,n+8),i=await Promise.all(r.map(e=>t(e.ref)));for(let[e,t]of i.entries())t&&(r[e].node.rect=t)}}function me(e,t){let n=new Map(t.map(e=>[e.ref,e])),r=[],i=new Set,a=new Map;for(let t of e.split(/\r?\n/)){let e=_e(t);if(!e)continue;i.add(e);let o=n.get(e)?.data,s=R(t),c=he(t,o,s),l=ge(a,s);l!==void 0&&(c.parentIndex=l),r.push({ref:e,node:{...c,index:r.length}}),a.set(s,r.length-1)}for(let e of t)i.has(e.ref)||r.push({ref:e.ref,node:{...I(e.data),index:r.length}});return r}function he(e,t,n){let r=ve(e)??V(t,[`role`,`type`]);return{index:0,type:r,role:r,label:ye(e)??V(t,[`label`,`name`,`text`]),value:xe(e)??V(t,[`value`]),depth:n,enabled:H(t,[`enabled`])??(!be(e)&&void 0),focused:H(t,[`focused`])}}function I(e){let t=V(e,[`role`,`type`]);return{index:0,type:t,role:t,label:V(e,[`label`,`name`,`text`]),value:V(e,[`value`]),enabled:H(e,[`enabled`]),focused:H(e,[`focused`])}}function L(e){return Array.isArray(e)?e.flatMap(e=>{let t=f(e)?e:void 0,n=B(V(t,[`ref`,`id`])??String(e));return n?[{ref:n,data:t}]:[]}):f(e)?Object.entries(e).flatMap(([e,t])=>{let n=B(e);return n?[{ref:n,data:f(t)?t:void 0}]:[]}):[]}function R(e){let t=e.match(/^\s*/)?.[0].length??0;return Math.floor(t/2)}function ge(e,t){for(let n=t-1;n>=0;--n){let t=e.get(n);if(t!==void 0)return t}}function _e(e){return B(z(e)?.match(/\bref\s*=\s*['"]?(@?e\d+)['"]?/i)?.[1]??e.match(/@?(e\d+)\b/i)?.[1])}function z(e){return e.replaceAll(/"(?:[^"\\]|\\.)*"/g,`""`).replaceAll(/'(?:[^'\\]|\\.)*'/g,`''`).match(/\[([^\]]*\bref\s*=\s*['"]?@?e\d+[^\]]*)\]\s*(?=:|$)/i)?.[1]}function B(e){let t=e?.trim().replace(/^@/,``);return t&&/^e\d+$/i.test(t)?t.toLowerCase():null}function ve(e){return e.replaceAll(/\[[^\]]*ref[^\]]*\]/gi,``).replaceAll(/@?e\d+\b/gi,``).replaceAll(/^[\s|├└─>*-]+/g,``).trim().match(/^([A-Za-z][\w-]*)\b/)?.[1]}function ye(e){return e.match(/"([^"]+)"/)?.[1]??e.match(/'([^']+)'/)?.[1]}function be(e){return/\bdisabled\b/i.test(z(e)??``)}function xe(e){return Se(e)??e.match(/\bvalue=(?:"([^"]*)"|'([^']*)'|([^\s\]]+))/i)?.slice(1).find(U)??e.match(/\bvalue:\s*(?:"([^"]*)"|'([^']*)'|([^\s\]]+))/i)?.slice(1).find(U)}function Se(e){return e.match(/\]\s*:\s*(.+)$/)?.[1]?.trim()||void 0}function V(e,t){if(e)for(let n of t){let t=e[n];if(typeof t==`string`&&t.length>0)return t}}function H(e,t){if(e)for(let n of t){let t=e[n];if(typeof t==`boolean`)return t}}function U(e){return typeof e==`string`}const W=`agent-browser`,G="Run `agent-device web setup` to install the managed web backend.";function Ce(e={}){let t=e.session?.trim(),n=async(n,r)=>await Ne(n,{session:t,options:e,signal:r});return{async open(e){await n([`open`,e])},async close(){await n([`close`])},async startRecording(e){await n([`record`,`start`,e])},async stopRecording(){await n([`record`,`stop`])},async snapshot(e){return await ke(t=>n(t,e?.signal),e)},async screenshot(e,t){await n([`screenshot`,...t?.fullscreen?[`--full`]:[],e])},async setViewport(e,t){await n([`set`,`viewport`,String(e),String(t)])},async click(e,t){await K(n,e,t)},async hover(e,t){await q(n,e,t)},async hoverRef(e){await n([`hover`,Z(e)])},async clickRef(e){await n([`click`,Z(e)])},async fill(e,t,r){if(await K(n,e,t),await n([`press`,Ve()]),r.length===0){await n([`press`,`Backspace`]);return}await n([`keyboard`,`type`,r])},async fillRef(e,t){await n([`fill`,Z(e),t])},async typeText(e){await n([`keyboard`,`type`,e])},async scroll(e,t){return await we(n,e,t),t?.durationMs===void 0?{}:{durationMs:t.durationMs}},async dumpNetwork(e){return oe(await n([`network`,`requests`]),e)},async probeAudio(e){return re(await n([`eval`,ne(e)]))}}}async function we(e,t,n){let r=Te(n);for(let n of r)await e(Oe(t,n.distance)),n.delayAfterMs>0&&await a(n.delayAfterMs)}function Te(e){let t=e?.pixels??e?.amount,n=e?.durationMs;if(n===void 0||n<=0)return[{distance:t,delayAfterMs:0}];let r=Math.max(1,Math.min(20,Math.ceil(n/50))),i=n/Math.max(1,r-1);return Ee(e,r).map((e,t)=>({distance:e,delayAfterMs:t<r-1?i:0}))}function Ee(e,t){let n=e?.pixels??e?.amount??300;return e?.amount!==void 0&&e.pixels===void 0?Array.from({length:t},()=>n/t):De(Math.round(n),t)}function De(e,t){let n=Math.floor(e/t),r=e-n*t;return Array.from({length:t},(e,t)=>t<r?n+1:n)}function Oe(e,t){return[`scroll`,e,...t===void 0?[]:[String(t)]]}async function K(e,t,n){await q(e,t,n),await e([`mouse`,`down`]),await e([`mouse`,`up`])}async function q(e,t,n){await e([`mouse`,`move`,String(Math.round(t)),String(Math.round(n))])}async function ke(e,t){return await fe(await e(Ae(t)),t?.includeRects?async t=>await je(e,t):void 0)}function Ae(e){return[`snapshot`,...e?.interactiveOnly?[`--interactive`]:[],...e?.raw?[]:[`--compact`],...typeof e?.depth==`number`?[`--depth`,String(e.depth)]:[],...e?.scope?[`--selector`,e.scope]:[]]}async function je(e,t){try{return He(await e([`get`,`box`,Z(t)]))}catch(e){if(Me(e))return;throw e}}function Me(e){let t=e instanceof Error?e.message:String(e);return!/\bstale\b/i.test(t)&&/\bbox\b|not visible|not found|no element/i.test(t)}async function Ne(e,t){let{session:n,options:r,signal:i}=t,a=[...e,`--json`,...n?[`--session`,n]:[]];return await Pe(a,r,e=>Le(Re(e.stdout,e.stderr,a,e.exitCode),e,a),i)}async function Pe(e,t,n,r){let i=``,a=``,o=0,s=!1,c=!1,d=u({stateDir:t.stateDir});try{await Ie(t);let n=await l(e,{stateDir:t.stateDir,allowFailure:!0,timeoutMs:3e4,signal:r});i=n.stdout,a=n.stderr,o=n.exitCode,s=!0}catch(n){throw await J({cliArgs:e,commandCompleted:s,exitCode:o,semanticSuccess:c,options:t,status:d}),Y(n,e)}try{let e=n({stdout:i,stderr:a,exitCode:o});return c=!0,e}finally{await J({cliArgs:e,commandCompleted:s,exitCode:o,semanticSuccess:c,options:t,status:d})}}async function J(e){let t=e.options.ownedProcessRecords;if(!(!t||!e.status.installed))try{let n=e.options.openWebSessionNames?.()??[],r=e.options.session?.trim();Fe(e,n.filter(e=>e!==r).length)?t.clear({kind:`daemon`}):await s(e.status,t)}catch(e){n({level:`warn`,phase:`web_agent_browser_process_record_failed`,data:{error:e instanceof Error?e.message:String(e)}})}}function Fe(e,t){return e.commandCompleted&&e.semanticSuccess&&e.cliArgs[0]===`close`&&e.exitCode===0&&t===0}async function Ie(e){if(!e.openWebSessionNames)return;let t=u({stateDir:e.stateDir});if(t.installed)try{await c(t,{openWebSessionNames:e.openWebSessionNames(),...e.ownedProcessRecords===void 0?{}:{ownedProcessRecords:e.ownedProcessRecords}})}catch(e){n({level:`warn`,phase:`web_agent_browser_provider_orphan_cleanup_failed`,data:{error:e instanceof Error?e.message:String(e)}})}}function Le(t,n,r){if(!f(t))return t;if((t.success??t.ok)===!1)throw new e(Be(t.code),ze(t),{cmd:W,args:r,hint:m(t,`hint`)??G,agentBrowserError:t.error});if(n.exitCode!==0)throw new e(`COMMAND_FAILED`,`agent-browser command failed`,i(n,{cmd:W,args:r,stdout:n.stdout.slice(0,500),stderr:n.stderr.slice(0,500),hint:m(t,`hint`)??G}));return Object.hasOwn(t,`data`)?t.data:t}function Re(t,n,r,i){try{return JSON.parse(t)}catch(a){let o=i!==0;throw new e(`COMMAND_FAILED`,o?`agent-browser command failed`:`agent-browser returned invalid JSON`,{cmd:W,args:r,...o?{exitCode:i}:{},stdout:t.slice(0,500),stderr:n.slice(0,500),hint:G},a instanceof Error?a:void 0)}}function Y(t,n){let r=d(t);return r.code===`TOOL_MISSING`?new e(`TOOL_MISSING`,r.message,{...r.details??{},cmd:W,args:n,hint:X(r)},r):r.code===`COMMAND_FAILED`?new e(`COMMAND_FAILED`,r.message,{...r.details??{},cmd:W,args:n,hint:X(r)},r):r}function X(e){return typeof e.details?.hint==`string`?e.details.hint:G}function ze(e){let t=e.error;if(typeof t==`string`&&t.trim())return t.trim();if(f(t)){let e=m(t,`message`)??m(t,`error`);if(e)return e}return m(e,`message`)??`agent-browser command failed`}function Be(e){return typeof e==`string`&&e.length>0?e:`COMMAND_FAILED`}function Z(e){return e.startsWith(`@`)?e:`@${e}`}function Ve(){return r()===`darwin`?`Meta+a`:`Control+a`}function He(e){let t=f(e)&&f(e.box)?e.box:e;if(f(t))return Ue(t)??We(t)}function Ue(e){return Q(h(e,`x`),h(e,`y`),h(e,`width`),h(e,`height`))}function We(e){let t=h(e,`left`),n=h(e,`top`),r=h(e,`right`),i=h(e,`bottom`);return Q(t,n,$(r,t),$(i,n))}function Q(e,t,n,r){if(e!==void 0&&t!==void 0&&n!==void 0&&r!==void 0)return{x:e,y:t,width:n,height:r}}function $(e,t){return e===void 0||t===void 0?void 0:e-t}export{Ce as createAgentBrowserWebProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{b as t,y as n}from"./sdk-contracts.js";import{b as r,c as i,d as a,f as o,l as s,s as c,u as l}from"./owner-identity.js";import{s as u}from"./exec.js";import{t as d}from"./file.js";import"./command.js";import"./process.js";import{O as f,S as p,a as m,b as h,c as g,d as _,l as v,p as y,s as b,v as x}from"./host-file.js";import{n as S}from"./agent-browser-process-record.js";import{r as C}from"./agent-browser-lifecycle.js";import w from"node:path";import T from"node:crypto";async function E(e){b(e.packageRoot);let t=ee([`install`,`--prefix`,e.packageRoot,`--no-global`,`--no-audit`,`--no-fund`,`--no-save`,e.packageSpec]);await u(t.command,t.args,{env:i(),timeoutMs:e.timeoutMs})}function D(e){f(w.join(e.installDir,`manifest.json`),JSON.stringify({package:e.packageName,version:e.version,node:l(),installedAt:new Date().toISOString()},null,2))}function ee(e){if(a()!==`win32`)return{command:`npm`,args:e};let t=O(i());if(!t)throw new n(`TOOL_MISSING`,`npm not found in PATH`,{nodeExecPath:s(),hint:"Install Node.js with npm, or add npm to PATH, and run `agent-device web setup` again."});return{command:s(),args:[t,...e]}}function O(e){let t=e.npm_execpath?.trim();if(t){let e=w.resolve(t);if(w.basename(e)===`npm-cli.js`&&k(e))return e}let n=w.join(w.dirname(s()),`node_modules`,`npm`,`bin`,`npm-cli.js`);return k(n)?n:void 0}function k(e){try{return _(e).isFile()}catch{return!1}}var A=e({doctorManagedAgentBrowser:()=>L,getManagedAgentBrowserStatus:()=>R,mapManagedAgentBrowserError:()=>$,runManagedAgentBrowser:()=>F,setupManagedAgentBrowser:()=>I});const j=`0.27.1`,M=`agent-browser`,N=3e5,P=6e4;async function F(e,t){let n=R({stateDir:t.stateDir});if(!n.installed)throw q(n);return await z(n,e,t)}async function I(e){let t=R(e);Y(t.nodeMajor);let n=o(),i=await d({lockDirPath:w.join(t.installDir,`..`,`.agent-browser-install.lock`),owner:{pid:n,startTime:r(n),acquiredAtMs:Date.now()},timeoutMs:N,description:`managed agent-browser setup`});try{let t=R(e);if(t.installed)return t;b(t.installDir),await E({packageRoot:w.join(t.installDir,`package`),packageSpec:`${M}@${j}`,timeoutMs:N});let n=R(e);if(!n.entryScript)throw J(n);return await z(n,[`install`],{timeoutMs:N}),await z(n,[`doctor`,`--offline`,`--quick`],{timeoutMs:P}),D({installDir:n.installDir,packageName:M,version:j}),R(e)}finally{await i()}}async function L(e){let t=R(e);if(!t.installed)throw q(t);return{status:t,...await z(t,[`doctor`,`--offline`,`--quick`],{timeoutMs:P,allowFailure:!0})}}function R(e){let t=e.stateDir??i().AGENT_DEVICE_STATE_DIR??te(),n=w.join(t,`tools`,`agent-browser`,j),r=G(n),a=K(n),o=U(r),s=w.join(n,`home`),c=X(n),u=Z(n),d=o!==void 0&&H(n),f=Number.parseInt(l().replace(/^v/,``).split(`.`)[0]??`0`,10);return{version:j,stateDir:t,installDir:n,packageDir:r,binaryPath:a,entryScript:o,homeDir:s,runtimeHomeDir:c,socketDir:u,installed:d,nodeMajor:f,nodeSupported:f>=24}}async function z(e,t,n){if(!e.entryScript)throw q(e);return await u(s(),[e.entryScript,...t],{allowFailure:n.allowFailure,env:B(e,i()),timeoutMs:n.timeoutMs,signal:n.signal})}function B(e,t){return b(e.homeDir),V(e),b(e.socketDir),{...t,HOME:e.runtimeHomeDir,AGENT_BROWSER_SOCKET_DIR:e.socketDir,AGENT_BROWSER_IDLE_TIMEOUT_MS:String(C(t)),AGENT_BROWSER_ARGS:S(t.AGENT_BROWSER_ARGS,e)}}function V(e){if(e.runtimeHomeDir!==e.homeDir){b(w.dirname(e.runtimeHomeDir));try{let t=v(e.runtimeHomeDir);if(t.isSymbolicLink()&&x(e.runtimeHomeDir)===e.homeDir||t.isDirectory())return;t.isSymbolicLink()&&p(e.runtimeHomeDir)}catch(e){if(!Q(e))throw e}try{m(e.homeDir,e.runtimeHomeDir)}catch{b(e.runtimeHomeDir)}}}function H(e){return g(w.join(e,`manifest.json`))}function U(e){let t;try{let n=JSON.parse(h(w.join(e,`package.json`)));t=typeof n==`object`&&n?n.bin:void 0}catch{return}let n=typeof t==`string`?t:typeof t==`object`&&t?t[M]:void 0;if(typeof n!=`string`)return;let r=w.resolve(e,n);return W(r)?r:void 0}function W(e){try{return _(e).isFile()}catch{return!1}}function G(e){return w.join(e,`package`,`node_modules`,M)}function K(e){let t=a()===`win32`?`${M}.cmd`:M;return w.join(e,`package`,`node_modules`,`.bin`,t)}function q(e){return new n(`TOOL_MISSING`,`Managed web browser backend is not installed.`,{version:j,installDir:e.installDir,hint:e.nodeSupported===!1?`Web automation requires Node 24+; current Node is ${l()}.`:"Run `agent-device web setup` to install the managed web backend."})}function J(e){return new n(`TOOL_MISSING`,`Managed web backend install produced no runnable entry.`,{version:j,installDir:e.installDir,packageDir:e.packageDir,hint:`Remove ${e.installDir} and run \`agent-device web setup\` again.`})}function Y(e){if(!(e>=24))throw new n(`UNSUPPORTED_OPERATION`,`Web automation requires Node 24 or newer.`,{currentNode:l(),requiredNodeMajor:24,hint:`Run agent-device with Node 24+ for web setup and web automation.`})}function X(e){if(a()===`win32`)return w.join(e,`home`);let t=T.createHash(`sha1`).update(e).digest(`hex`).slice(0,12);return w.join(y(),`agent-device-web`,t)}function Z(e){let t=T.createHash(`sha1`).update(e).digest(`hex`).slice(0,12);return w.join(y(),`adw`,t)}function Q(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}function te(){return w.join(i().HOME??c(),`.agent-device`)}function $(e){let r=t(e);return r.code===`TOOL_MISSING`?new n(r.code,r.message,{...r.details??{},hint:typeof r.details?.hint==`string`?r.details.hint:"Run `agent-device web setup` to install the managed web backend."}):r}export{F as i,R as n,$ as r,A as t};
|