agent-device 0.21.19 → 0.21.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.19.apk → agent-device-android-ime-helper-0.21.21.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.21.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.19.manifest.json → agent-device-android-ime-helper-0.21.21.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.21.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.21.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.19.manifest.json → agent-device-android-snapshot-helper-0.21.21.manifest.json} +6 -6
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AppWindowScreenshot.swift +73 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/BackgroundInteraction.swift +557 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/GhostCursor.swift +141 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/SnapshotTraversal.swift +107 -3
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +136 -22
- package/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/BackgroundInteractionTests.swift +88 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +133 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +36 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +28 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -14
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +14 -16
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +67 -14
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedCommitDeadline.swift +6 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +7 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +21 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +121 -17
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +179 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryConfirmation.swift +119 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +8 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryReadiness.swift +23 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +59 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +112 -23
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +25 -12
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +6 -1
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +43 -13
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +20 -5
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +2 -15
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +10 -25
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -18
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +2 -2
- package/dist/src/adb-failure.js +1 -1
- package/dist/src/adb-transport.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/alert.js +1 -0
- package/dist/src/android-adb.d.ts +12 -0
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/app-backend.js +1 -0
- package/dist/src/app-catalog.js +1 -1
- package/dist/src/app-deployment-resolution.js +1 -1
- package/dist/src/app-inventory.js +1 -1
- package/dist/src/app-launch.js +2 -2
- package/dist/src/app-lifecycle.js +2 -2
- package/dist/src/app-lifecycle2.js +1 -1
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-log-session-resource.js +1 -0
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/archive.js +2 -2
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/back-mode.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/boot-diagnostics.js +1 -1
- package/dist/src/browser-launch.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/capabilities.js +1 -1
- package/dist/src/capture.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +317 -323
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +4 -4
- package/dist/src/click-button.js +1 -1
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-options.js +3 -0
- package/dist/src/client-types.d.ts +101 -6
- package/dist/src/clipboard-shell-response.js +1 -1
- package/dist/src/{scroll-command.d.ts → cloud-artifacts.d.ts} +249 -240
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/code-signature.js +1 -1
- package/dist/src/command-schema.js +3 -3
- package/dist/src/command-tools.js +2 -2
- package/dist/src/command.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +5 -5
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-artifacts.js +1 -0
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-liveness-probe.js +1 -0
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-http.js +1 -0
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +1 -0
- package/dist/src/daemon-registration.js +1 -1
- package/dist/src/daemon-resolution.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -1
- package/dist/src/daemon.js +2 -2
- package/dist/src/debug-symbols-facade.js +3 -3
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-readiness-runtime.js +1 -1
- package/dist/src/device-release.js +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device-shell.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -3
- package/dist/src/device3.js +3 -0
- package/dist/src/devicectl.js +1 -1
- package/dist/src/diagnostics.js +3 -3
- package/dist/src/dispatch-resolve.js +4 -1
- package/dist/src/display-inventory.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/doctor2.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -0
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host-file.js +1 -1
- package/dist/src/host.js +1 -1
- package/dist/src/human-control-contract.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +2 -2
- package/dist/src/install-artifact-facade.js +1 -1
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/install-source.d.ts +5 -0
- package/dist/src/install-source2.js +1 -1
- package/dist/src/instance-client.js +1 -0
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-binding.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +1 -2
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-http-child.js +1 -1
- package/dist/src/inventory.js +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/ios-client.js +4 -30
- package/dist/src/ios-settings.js +1 -0
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -0
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-registry-scope.js +1 -0
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/legacy-xctest-device-set.js +1 -1
- package/dist/src/limrun-download-file.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +78 -44
- package/dist/src/limrun.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/load.js +1 -0
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/macos-facade.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +16 -16
- package/dist/src/observation.js +1 -1
- package/dist/src/observe-until.js +1 -1
- package/dist/src/overlay.js +2 -2
- package/dist/src/owner-identity.js +3 -3
- package/dist/src/path-resolution.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-operation-builder.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.js +1 -1
- package/dist/src/perf.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-android-adb-host.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +2 -2
- package/dist/src/platform-runtime-runtime-hints.js +2 -2
- package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-output-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plugins.d.ts +9 -0
- package/dist/src/plugins.js +1 -0
- package/dist/src/plugins2.js +2 -0
- package/dist/src/png-crop-bytes.js +1 -1
- package/dist/src/png-size.js +1 -1
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/png.js +1 -1
- package/dist/src/prepare-kind.js +1 -1
- package/dist/src/process.js +1 -1
- package/dist/src/project-runtime.js +1 -1
- package/dist/src/provider-credential-fingerprint.js +1 -0
- package/dist/src/provider-device-admission.js +1 -1
- package/dist/src/provider-device-runtimes.js +1 -0
- package/dist/src/provider-limrun-credentials.js +1 -0
- package/dist/src/provider-profile-fields.js +1 -0
- package/dist/src/provider-session-ownership.js +2 -2
- package/dist/src/provider-webdriver.js +2 -1
- package/dist/src/providers.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/quality-warnings.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/rect-center.js +1 -1
- package/dist/src/register-builtins.js +1 -1
- package/dist/src/registry.js +52 -36
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay.js +2 -2
- package/dist/src/reporting.js +5 -5
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-cancel.js +1 -1
- package/dist/src/request-cancellation.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/retry.js +1 -1
- package/dist/src/runner-artifact-manifest.js +1 -1
- package/dist/src/runner-cache-metadata.js +3 -3
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +2 -2
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-session-types.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-admission.js +1 -1
- package/dist/src/runtime-transport-hints.js +1 -1
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +2 -2
- package/dist/src/runtime2.js +3 -3
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +5 -5
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -1
- package/dist/src/screen-recording-completion.js +1 -1
- package/dist/src/screen-recording-options.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-image.js +1 -1
- package/dist/src/screenshot-result.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot3.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-command.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +47 -2
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-io.js +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +37 -8
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +2 -2
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-allocation.js +1 -1
- package/dist/src/session-artifact-paths.js +1 -1
- package/dist/src/session-repair-tombstone.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-stream.js +27 -0
- package/dist/src/session.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/settings.js +1 -1
- package/dist/src/settings2.js +1 -1
- package/dist/src/simctl-settings-facade.js +1 -0
- package/dist/src/simctl-settings.js +1 -0
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-diagnostics.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +2 -2
- package/dist/src/store.js +1 -0
- package/dist/src/string-enum.js +1 -1
- package/dist/src/surface-snapshot.js +1 -1
- package/dist/src/takeover.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/telemetry.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider.js +3 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -1
- package/dist/src/toolchain-probe.js +2 -2
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/transport.js +2 -2
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/vars.js +1 -1
- package/dist/src/verified-file.js +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/video.js +1 -1
- package/dist/src/viewport.js +1 -1
- package/dist/src/web.js +1 -1
- package/dist/src/web2.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/package.json +5 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.19.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.19.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.19.apk.sha256 +0 -1
- package/dist/src/api.js +0 -3
- package/dist/src/daemon-process.js +0 -1
- package/dist/src/multitouch-support.js +0 -1
- package/dist/src/parameterized-recorded-fill.js +0 -1
- package/dist/src/runner-startup-transport.js +0 -1
- package/dist/src/runner-xctestrun.js +0 -1
- package/dist/src/session-store.js +0 -4
|
@@ -2,7 +2,19 @@ import { b as DeviceInfo } from "./sdk-contracts.js";
|
|
|
2
2
|
import { s as AppsFilter } from "./gesture-plan-types.js";
|
|
3
3
|
import { a as readAndroidClipboardWithAdb, c as AndroidAdbExecutor, d as AndroidAdbProvider, f as AndroidPortReverseEndpoint, i as getAndroidKeyboardStatusWithAdb, l as AndroidAdbExecutorOptions, m as AppStateRuntimeResult, n as AndroidKeyboardState, o as writeAndroidClipboardWithAdb, p as AndroidPortReverseProvider, r as dismissAndroidKeyboardWithAdb, t as AndroidKeyboardDismissResult, u as AndroidAdbExecutorResult } from "./device-input-state.js";
|
|
4
4
|
//#region packages/platform-android/src/adb-port-reverse.d.ts
|
|
5
|
+
type AndroidExecPortReverseOptions = Readonly<{
|
|
6
|
+
/**
|
|
7
|
+
* Refuses to replace any existing device mapping, including one this provider created
|
|
8
|
+
* (`adb reverse --no-rebind`), for a device that other adb clients also drive. When
|
|
9
|
+
* `adb reverse --list` shows the endpoint after a refusal, the provider throws `COMMAND_FAILED`
|
|
10
|
+
* with `details.reason: 'android_port_reverse_rebind_refused'`; otherwise it throws the adb
|
|
11
|
+
* failure.
|
|
12
|
+
*/
|
|
13
|
+
noRebind?: boolean;
|
|
14
|
+
}>;
|
|
5
15
|
declare function createAndroidPortReverseManager(provider: AndroidAdbProvider | AndroidAdbExecutor): AndroidPortReverseProvider;
|
|
16
|
+
/** Options reach only the exec-backed provider the manager builds over a bare executor. */
|
|
17
|
+
declare function createAndroidPortReverseManager(adb: AndroidAdbExecutor, options: AndroidExecPortReverseOptions): AndroidPortReverseProvider;
|
|
6
18
|
//#endregion
|
|
7
19
|
//#region packages/kernel/src/device-shell.d.ts
|
|
8
20
|
declare const shellFragmentBrand: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as e}from"./sdk-contracts.js";import{Lr as t,jr as n,qr as r}from"./sdk-batch.js";import{n as i,t as a}from"./rect-center.js";const o=new WeakMap;function s(e,t){return o.set(e,{...o.get(e),...t}),e}function c(e,t){return s(e,{clickability:t})}function l(e){return e?o.get(e)?.clickability:void 0}function u(e,t){let n=l(e);return n?c(t,n):t}function d(e,t){return s(e,{occlusionContext:t})}function f(e){return e?o.get(e)?.occlusionContext:void 0}const p=[`tabbar`,`toolbar`,`navigationbar`,`bottomnavigation`,`bottomnavigationview`,`sheet`,`dialog`,`alert`,`popover`,`menu`],m=[`tabbar`,`toolbar`,`navigationbar`],h=[`button`,`link`,`menuitem`,`tabitem`,`textfield`,`searchfield`,`edittext`,`checkbox`,`radio`,`switch`,`cell`];function g(e){let t=new Map,n=new Map;for(let r of e){if(t.set(r.index,r),typeof r.parentIndex!=`number`)continue;let e=n.get(r.parentIndex);e?e.push(r):n.set(r.parentIndex,[r])}return{byIndex:t,childrenByParent:n}}function _(e,t={}){if(e.length<2)return e;let n=g(e),r={nodes:e,byIndex:n.byIndex,neighbourhood:n,overlayPositions:e.flatMap((e,r)=>D(e,n,t)?[r]:[]),coverCache:new Map},i=[];for(let[n,a]of e.entries())E(a)&&x(r,n,a,t)&&i.push(n);return y(e,i)}function v(e,t){let n=[];for(let[r,i]of e.entries())E(i)&&t(i)&&n.push(r);return y(e,n)}function y(e,t){if(t.length===0)return e;let n=[...e];for(let r of t){let t=e[r];n[r]={...t,hittable:!1,interactionBlocked:`covered`,presentationHints:z(t.presentationHints)}}return n}function b(e){return e.interactionBlocked!==void 0}function x(t,n,r,i){let a=t.coverCache.get(n);if(a!==void 0)return a;t.coverCache.set(n,null);let o=R(r.rect);if(!o)return C(t,n,null);let s=e(o),c=i.isAdditionalOverlayNode?.(r)===!0;for(let e of t.overlayPositions){if(!S(t,e,n,c,i))continue;let a=t.nodes[e];if(w(t,e,r,o,s,i))return C(t,n,a)}return C(t,n,null)}function S(e,t,n,r,i){let a=e.nodes[t];return a?t>n?!0:t===n||r?!1:i.isAdditionalOverlayNode?.(a)===!0:!1}function C(e,t,n){return e.coverCache.set(t,n),n}function w(e,t,n,i,a,o){if(!e.nodes[t])return!1;let s=T(e,t,n,i,o);return!!(s&&r(s,a.x,a.y))}function T(e,t,n,r,i){let o=e.nodes[t];if(!o||!D(o,e.neighbourhood,i)||I(n,o,e.byIndex))return null;let s=R(o.rect);return!s||a(r,s)||x(e,t,o,i)?null:s}function E(e){return R(e.rect)?e.hittable===!0||N(e)?!0:!!(e.label?.trim()||e.value?.trim()||e.identifier?.trim()):!1}function D(e,t,r){return!R(e.rect)||n(e)||k(e,t.byIndex)||O(e,t)?!1:P(e,p)||A(e,t.byIndex,r)}function O(e,t){if(!P(e,m)||typeof e.parentIndex!=`number`)return!1;let n=R(e.rect);return n?(t.childrenByParent.get(e.parentIndex)??[]).some(t=>t.index!==e.index&&a(n,t.rect)):!1}function k(e,t){if(!P(e,m))return!1;let r=R(e.rect);if(!r)return!1;let i=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,o=new Set;for(;i&&!o.has(i.index);){if(n(i)){let e=R(i.rect);return!!(e&&a(r,e))}o.add(i.index),i=typeof i.parentIndex==`number`?t.get(i.parentIndex):void 0}return!1}function A(e,t,n){return n.isAdditionalOverlayNode?.(e)===!0&&!j(e,t,n)}function j(e,t,n){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(M(r,n))return!0;i.add(r.index),r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return!1}function M(e,t){return t.isAdditionalOverlayNode?.(e)===!0&&R(e.rect)!==null&&!n(e)}function N(e){return P(e,h)}function P(e,t){let n=F(e);return t.some(e=>n.includes(e))}function F(e){return[e.type,e.role,e.subrole].map(e=>t(e??``)).join(` `)}function I(e,t,n){return L(e,t,n)||L(t,e,n)}function L(e,t,n){let r=typeof t.parentIndex==`number`?n.get(t.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(r.index===e.index)return!0;i.add(r.index),r=typeof r.parentIndex==`number`?n.get(r.parentIndex):void 0}return!1}function R(e){let t=i(e);return t&&t.width>0&&t.height>0?t:null}function z(e){return Array.from(new Set([...e??[],`covered`]))}const B=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function V(e){let t=X(e.packageName),n=(e.resourceId??``).toLowerCase(),r=X(e.activeInputMethodPackage);if(t&&r&&t===r)return{inputMethodOwned:!0,source:`active-input-method`};if(r&&n.startsWith(`${r}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(t&&B.has(t))return{inputMethodOwned:!0,source:`known-ime-package`};for(let e of B)if(n.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function H(e,t,n){return V({packageName:e,resourceId:t,activeInputMethodPackage:n}).inputMethodOwned}function U(e){return V(e).inputMethodOwned}function W(e){return U({packageName:e.bundleId,resourceId:e.identifier})}function G(e){let t=X(e);return!!(t&&B.has(t))}function K(e){let t=(e??``).toLowerCase();for(let e of B)if(t.startsWith(`${e}:id/`))return!0;return!1}function q(e,t,n){return!e&&!t?`unknown`:H(e,t,n)?`ime`:`app`}function J(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=Y(e.match(t)?.[1]);if(n)return n}}function Y(e){let t=(e??``).trim();if(t)return X((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function X(e){return(e??``).trim().toLowerCase()||void 0}export{K as a,v as c,d,u as f,G as i,b as l,f as m,W as n,J as o,l as p,U as r,_ as s,q as t,c as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{O as t,d as n}from"./sdk-device.js";import{a as r}from"./session.js";import{b as i}from"./owner-identity.js";import"./process.js";import{n as a}from"./gesture-admission.js";const o={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android and the iOS simulator only.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android and the iOS simulator only.`};function s(r,i){if(!n(r.platform))throw c(i,r.platform);let s=t(r);if(s!==`ios`&&s!==`ipados`||r.kind!==`simulator`)throw s===`ios`||s===`ipados`?new e(`UNSUPPORTED_OPERATION`,`gesture ${i} is not supported on physical iOS devices`,{hint:`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`}):c(i,a[s],o[s])}function c(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function l(){return r(i)}export{o as n,s as r,l as t};
|
package/dist/src/app-catalog.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";const t=1e3;function n(t){if(t)throw new e(`UNAUTHORIZED`,`Limrun uploaded apps are unavailable on the public daemon HTTP surface.`)}async function r(e,n,r){r?.throwIfAborted();let i=await e.assets.list({limit:t},{signal:r});r?.throwIfAborted();let a=[];for(let e of i){let t=o(e,n);t&&a.push(t)}return a.sort((e,t)=>e.name.localeCompare(t.name))}async function i(n,r,i,a){a?.throwIfAborted();let s=await n.assets.list({limit:t,nameFilter:i},{signal:a});a?.throwIfAborted();let c=s.filter(e=>e.name===i).map(e=>o(e,r)).filter(e=>e!==void 0);if(c.length<=1)return c[0];throw new e(`COMMAND_FAILED`,`Limrun returned multiple uploaded apps named ${i}.`,{app:i,platform:r,assetIds:c.map(e=>e.id)})}function a(e,t){let n=l(e.replace(/\.(?:tar\.gz|tgz|tar|zip|ipa|apk)$/i,``).replace(/\.app$/i,``));if(n.length<5)return;let r=t.map(e=>({app:e,keys:c(e)})).filter(({keys:e})=>e.includes(n));return r.length===1?r[0]?.app.id:void 0}function o(e,t){if(e.md5&&s(e)===t)return{id:e.id,name:e.name}}function s(e){if(e.os===`android`||e.os===`ios`)return e.os;let t=e.name.toLowerCase();if(t.endsWith(`.apk`))return`android`;if(t.endsWith(`.ipa`)||t.endsWith(`.zip`)||t.endsWith(`.tar`)||t.endsWith(`.tar.gz`)||t.endsWith(`.tgz`))return`ios`}function c(e){let t=e.id.split(/[.:/]/).at(-1);return[e.id,t,e.name].filter(e=>typeof e==`string`).map(l)}function l(e){return e.toLowerCase().replaceAll(/[^a-z0-9]+/g,``)}export{n as assertLimrunUploadedAppAccess,r as listLimrunAppAssets,a as resolveInstalledAppIdForAsset,i as resolveLimrunAppAsset};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{o as t}from"./adb.js";import{t as n}from"./app-resolution-cache.js";const r=/\.(?:apk|aab)$/i,i=/^[A-Za-z_][\w]*(\.[A-Za-z_][\w]*)+$/;function a(e){let t=e.trim();return t.length===0?`other`:r.test(t)?t.includes(`/`)||t.includes(`\\`)||t.startsWith(`.`)||t.startsWith(`~`)||!o(t)?`binary`:`package`:o(t)?`package`:`other`}function o(e){return i.test(e)}function s(e){return`Android runtime hints require an installed package name, not "${e}". Install or reinstall the app first, then relaunch by package.`}const c={settings:{type:`intent`,value:`android.settings.SETTINGS`}},l=`Run agent-device apps --platform android to discover the installed package name, then retry open with that exact package.`,u=n();function d(e){return{platform:`android`,deviceId:e.id,variant:e.target??``}}async function f(e,t){return await u.invalidateWhile(d(e),t)}async function p(n,r){let i=r.trim();if(a(i)===`package`)return{type:`package`,value:i};let o=c[i.toLowerCase()];if(o)return o;let s=d(n),f=u.get(s,i);if(f)return f;let p=(await t(n,[`pm`,`list`,`packages`])).stdout.split(`
|
|
2
2
|
`).map(e=>e.replace(`package:`,``).trim()).filter(Boolean).filter(e=>e.toLowerCase().includes(i.toLowerCase())),m=p[0];if(m!==void 0&&p.length===1)return u.set(s,i,{type:`package`,value:m});throw p.length>1?new e(`INVALID_ARGS`,`Multiple packages matched "${r}"`,{matches:p,hint:`Run agent-device apps --platform android to see the exact installed package names before retrying open.`}):new e(`APP_NOT_INSTALLED`,`No package found matching "${r}"`,{hint:l})}function m(e){let t=new Set([`com`,`android`,`google`,`app`,`apps`,`service`,`services`,`mobile`,`client`]),n=e.split(`.`).flatMap(e=>e.split(/[_-]+/)).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0),r=n.at(-1)??e;for(let e=n.length-1;e>=0;--e){let i=n[e];if(i&&!t.has(i)){r=i;break}}return r.split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}export{a,f as i,m as n,s as o,p as r,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";function t(e){return e??`user-installed`}function n(t){if(t===void 0)throw new e(`INVALID_ARGS`,`appsFilter must be resolved before executing the apps command`);return t}export{t as n,n as t};
|
package/dist/src/app-launch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)||e.endsWith(`\r`)?`${e}${t}`:`${e}\n${t}`}async function
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{a as t,i as n,o as r}from"./sdk-batch-runner.js";import{r as i}from"./diagnostics.js";import"./diagnostics2.js";import{m as a,p as o}from"./sdk-device.js";import{n as s,t as c}from"./launch-console.js";import"./observability.js";import{i as l,r as u}from"./exec.js";import"./command.js";import{i as d,n as f}from"./retry.js";import{D as p,o as m}from"./host-file.js";import{d as h,g,n as _}from"./config.js";import{a as v,o as y}from"./tool-provider.js";import{t as b}from"./physical-device-control.js";import{n as x}from"./simctl.js";import{c as S}from"./runner-client.js";import{t as C}from"./simulator.js";import{a as w,l as T,u as E}from"./app-resolution.js";import D from"node:path";function O(t){if(!(t instanceof e)||t.code!==`COMMAND_FAILED`)return!1;let n=t.details??{};if(n.exitCode!==4)return!1;let r=String(n.stderr??``).toLowerCase();return r.includes(`fbsopenapplicationserviceerrordomain`)&&r.includes(`the request to open`)}async function k(e,t){let n=await y(x(e,[`get_app_container`,e.id,t]),{allowFailure:!0});if(n.exitCode!==0)return{installed:!1};let r=n.stdout.trim();if(!r)return{installed:!1};let i=await v(`plutil`,[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,`${r}/Info.plist`],{allowFailure:!0});if(i.exitCode!==0||!i.stdout.trim())return{installed:!0};let a=`${r}/${i.stdout.trim()}`,o=await v(`otool`,[`-l`,a],{allowFailure:!0});if(o.exitCode!==0)return{installed:!0};let s=o.stdout.toLowerCase();return{installed:!0,simulatorCompatible:s.includes(`iossimulator`)||s.includes(`platform 7`)}}function A(e){return e.installed?e.simulatorCompatible===!1?`ARCH_MISMATCH`:`PERSISTENT_LAUNCH_FAIL`:`APP_NOT_INSTALLED`}function j(e){switch(e){case`ARCH_MISMATCH`:return`The app binary was not built for the simulator platform. Rebuild with a simulator destination or use a physical device.`;case`APP_NOT_INSTALLED`:return`The app bundle is not installed on this simulator. Run install before open.`;case`PERSISTENT_LAUNCH_FAIL`:return`The simulator repeatedly refused to launch the app. Inspect crash logs in Console.app or ~/Library/Logs/DiagnosticReports/ and consider reinstalling the app.`;default:return`The simulator failed to launch the app. Retry with --debug and inspect diagnostics log for details.`}}const M=25e3;async function N(i,l,u){let d=u?.launchConsole?.trim(),f=u?.launchArgs;if(d&&(!o(i)||i.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,s);if(a(i)){if(f&&f.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on macOS; launch arguments are currently iOS-only.`);await E(i,l,u);return}let p=u?.url?.trim();if(p){if(d)throw new e(`INVALID_ARGS`,c);if(!n(p))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(i.kind===`simulator`){let e=!!f||t(p);if(u?.terminateRunningApp||e){let t=u?.appBundleId??await w(i,l);e?await z(i,t,{...f?{launchArgs:f}:{},...u?.terminateRunningApp?{terminateRunningApp:!0}:{}}):await R(i,t)}await P(i,p,void 0,u?.runnerOptions);return}let a=u?.appBundleId??await w(i,l),o=r(a,p);if(!o)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,o,{payloadUrl:p,launchArgs:f,runnerOptions:u?.runnerOptions});return}let m=l.trim();if(n(m)){if(d)throw new e(`INVALID_ARGS`,c);if(i.kind===`simulator`){await P(i,m,f,u?.runnerOptions);return}let t=r(u?.appBundleId,m);if(!t)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,t,{payloadUrl:m,launchArgs:f,runnerOptions:u?.runnerOptions});return}let h=u?.appBundleId??await w(i,l);if(i.kind===`simulator`){await z(i,h,{...d?{launchConsole:d}:{},...f?{launchArgs:f}:{},...u?.terminateRunningApp?{terminateRunningApp:!0}:{}});return}await W(i,h,{launchArgs:f,runnerOptions:u?.runnerOptions})}async function P(t,n,r,i){if(r&&r.length>0)throw new e(`INVALID_ARGS`,`--launch-args is not supported with iOS simulator URL opens (simctl openurl ignores launch args). Launch the app first with --launch-args, then issue the URL open in a separate call.`);await C(t);let a=x(t,[`openurl`,t.id,n]);try{await y(a,{timeoutMs:h,...i?.signal?{signal:i.signal}:{}})}catch(n){throw l(n)?new e(`COMMAND_FAILED`,`xcrun simctl openurl did not answer within ${h}ms.`,{...n.details,reason:`ios-simulator-openurl-timeout`,timeoutMs:h,deviceId:t.id,hint:`The Simulator may still have received the URL; CoreSimulator is slow to answer. Retry the open, or answer any "Open in" prompt with alert accept.`}):n}}async function F(e){a(e)||e.kind===`simulator`&&await C(e)}async function I(e,t,n){if(a(e)){await T(e,t);return}let r=await w(e,t);if(e.kind===`simulator`){await R(e,r);return}await L(r),await b(e).terminateApp(e,r,{runnerOptions:n,runRunnerCommand:S})}async function L(t){let{iosSystemSurfaceHost:n,iosSystemSurfaceOpenRefusal:r}=await import(`./ios-system-surface.js`).then(e=>e.a);if(n(t))throw new e(`UNSUPPORTED_OPERATION`,r(t),{reason:`system-surface-host-not-openable`,appBundleId:t})}async function R(t,n){await L(n),await C(t);let r=x(t,[`terminate`,t.id,n]),i=await y(r,{allowFailure:!0,timeoutMs:g});if(i.exitCode!==0&&!i.stderr.toLowerCase().includes(`found nothing to terminate`))throw new e(`COMMAND_FAILED`,`xcrun exited with code ${i.exitCode}`,u(i,{cmd:`xcrun`,args:r}))}async function z(t,n,r){await L(n),await C(t);let i=0,a=f.fromTimeoutMs(_);try{await d(async({deadline:i})=>{if(i?.isExpired())throw new e(`COMMAND_FAILED`,`App launch deadline exceeded`,{timeoutMs:_});let a=x(t,B(t.id,n,r)),o=r?.launchConsole?await V(a,r.launchConsole):await y(a,{allowFailure:!0});if(o.exitCode!==0)throw new e(`COMMAND_FAILED`,`xcrun exited with code ${o.exitCode}`,u(o,{cmd:`xcrun`,args:a}))},{maxAttempts:10,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry(e){return O(e)?(i+=1,i<3):!1}},{deadline:a})}catch(e){if(O(e)){let r=e,i=A(await k(t,n));r.details={...r.details,hint:j(i)}}throw e}}function B(e,t,n){let r=[`launch`];return n?.launchConsole&&r.push(`--console-pty`),n?.terminateRunningApp&&r.push(`--terminate-running-process`),r.push(e,t),n?.launchArgs&&n.launchArgs.length>0&&r.push(...n.launchArgs),r}async function V(t,n){await m(D.dirname(n));try{let e=await y(t,{allowFailure:!0,timeoutMs:M});return await H(n,e.stdout,e.stderr),e}catch(t){let r=(t instanceof e?t:void 0)?.details;if(r?.timeoutMs===M){let e=typeof r.stdout==`string`?r.stdout:``,t=typeof r.stderr==`string`?r.stderr:``;return await H(n,e,t),i({level:`warn`,phase:`ios_simulator_launch_console_capture_timeout`,data:{timeoutMs:M,logPath:n,stdoutBytes:Buffer.byteLength(e),stderrBytes:Buffer.byteLength(t)}}),{stdout:e,stderr:t,exitCode:0}}throw t}}async function H(e,t,n){await p(e,U(t,n))}function U(e,t){return!e||!t||e.endsWith(`
|
|
2
|
+
`)||e.endsWith(`\r`)?`${e}${t}`:`${e}\n${t}`}async function W(e,t,n){await L(t),await b(e).launchApp(e,t,{...n,runRunnerCommand:S})}export{N as n,F as r,I as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{N as t,P as n}from"./sdk-contracts.js";import{i as r}from"./sdk-batch-runner.js";import{h as i,u as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./command.js";import{n as s}from"./device-shell.js";import{i as c,n as l}from"./retry.js";import{_ as u,g as d,o as f,p}from"./adb-executor.js";import{i as m,o as h}from"./adb-transport.js";import{n as g}from"./adb-failure.js";import{o as _}from"./adb.js";import{n as v,t as ee}from"./boot-diagnostics.js";import{n as y,r as b,t as te}from"./app-deployment-resolution.js";import{a as ne,i as re}from"./app-parsers.js";import{n as ie}from"./window-state.js";import x from"node:path";const ae=[`emulator`,`platform-tools`,x.join(`cmdline-tools`,`latest`,`bin`),x.join(`cmdline-tools`,`tools`,`bin`)];function S(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function C(e=d().environment){let t=e.ANDROID_SDK_ROOT?.trim(),n=e.ANDROID_HOME?.trim(),r=e.HOME?.trim(),i=r?x.join(r,`Android`,`Sdk`):``;return S([t??``,n??``,i])}async function w(e=d().environment,t=d().files){let n=[],r;for(let i of C(e)){let e=[];for(let n of ae){let r=x.join(i,n);await t.isExecutable(r)&&e.push(r)}e.length!==0&&(r||=i,n.push(...e))}if(r&&(e.ANDROID_SDK_ROOT=e.ANDROID_SDK_ROOT?.trim()||r,e.ANDROID_HOME=e.ANDROID_HOME?.trim()||r),n.length===0)return;let i=(e.PATH??``).split(x.delimiter).map(e=>e.trim()).filter(e=>e.length>0);e.PATH=S([...n,...i]).join(x.delimiter)}const T=1e4;async function oe(e,n){await w();let r=e.avdName.trim();if(!r)throw new t(`INVALID_ARGS`,`Android emulator boot requires a non-empty AVD name.`);let o=e.timeoutMs??12e4;if(!await i(`adb`))throw new t(`TOOL_MISSING`,`adb not found in PATH`);if(!await i(`emulator`))throw new t(`TOOL_MISSING`,`emulator not found in PATH`);let s=await E(n,e.serial),c=D(s,r,e.serial);if(!c)throw new t(`DEVICE_NOT_FOUND`,`No Android emulator AVD named ${e.avdName}`,{requestedAvdName:r,availableAvds:s.map(e=>e.name),hint:"Run `emulator -list-avds` and pass an existing AVD name to --device."});let l=c.name,u=Date.now(),d=O(c)?c:void 0;if(!d){let t=[`-avd`,l];e.headless&&t.push(`-no-window`,`-no-audio`),a(`emulator`,t)}let f=d??await se({dependencies:n,avdName:l,serial:e.serial,timeoutMs:o}),p=Date.now()-u;return await j(f.id,Math.max(1e3,o-p)),{...(await E(n,e.serial)).find(e=>e.id===f.id)??f,name:l,booted:!0}}async function E(e,t){return await e.discoverLocal({platform:`android`,kind:`emulator`,...t?{serial:t}:{},...e.androidSerialAllowlist?{androidSerialAllowlist:[...e.androidSerialAllowlist]}:{}})}function D(e,t,n){let r=A(t);return e.find(e=>e.platform===`android`&&e.kind===`emulator`&&A(e.name)===r&&(!n||!O(e)||e.id===n))}function O(e){return k(e.id)}function k(e){return e.startsWith(`emulator-`)}function A(e){return e.toLowerCase().replaceAll(`_`,` `).replaceAll(/\s+/g,` `).trim()}async function se(e){let n=Date.now(),r=Math.min(1e3,Math.max(50,Math.floor(e.timeoutMs/20)));for(;Date.now()-n<e.timeoutMs;){try{let t=D(await E(e.dependencies,e.serial),e.avdName,e.serial);if(t&&O(t))return t}catch{}await o(r)}throw new t(`COMMAND_FAILED`,`Android emulator did not appear in time`,{avdName:e.avdName,serial:e.serial,timeoutMs:e.timeoutMs,hint:`Check emulator logs and verify the AVD can start from command line.`})}async function ce(e,t=T,n){return await u(m(h(e),s(`adb`,`shell`,[`getprop`,`sys.boot_completed`])),{allowFailure:!0,signal:n,timeoutMs:t})}async function j(e,n=6e4,r){let i=l.fromTimeoutMs(n),a=Math.min(1e3,Math.max(50,Math.floor(n/20))),o=Math.max(1,Math.ceil(n/a)),s,u=!1;try{await c(async({deadline:a})=>{if(a?.isExpired())throw u=!0,new t(`COMMAND_FAILED`,`Android boot deadline exceeded`,{serial:e,timeoutMs:n,elapsedMs:i.elapsedMs(),message:`timeout`});let o=Math.max(1e3,a?.remainingMs()??n),c=await ce(e,Math.min(o,T),r);if(s=c,c.stdout.trim()!==`1`)throw new t(`COMMAND_FAILED`,`Android device is still booting`,{serial:e,stdout:c.stdout,stderr:c.stderr,exitCode:c.exitCode})},{maxAttempts:o,baseDelayMs:a,maxDelayMs:a,jitter:0,shouldRetry:e=>{let t=v({error:e,stdout:s?.stdout,stderr:s?.stderr,context:{platform:`android`,phase:`boot`}});return t!==`ADB_TRANSPORT_UNAVAILABLE`&&t!==`ANDROID_BOOT_TIMEOUT`}},{deadline:i,phase:`boot`,signal:r,classifyReason:e=>v({error:e,stdout:s?.stdout,stderr:s?.stderr,context:{platform:`android`,phase:`boot`}})})}catch(t){le({error:t,serial:e,timeoutMs:n,deadline:i,lastBootResult:s,timedOut:u})}}function le(e){let t=n(e.error),r=ue(e,t);throw fe(t,r,e.timedOut,de(e,r))}function ue(e,t){let n=v({error:e.error,stdout:e.lastBootResult?.stdout,stderr:e.lastBootResult?.stderr,context:{platform:`android`,phase:`boot`}});return n===`BOOT_COMMAND_FAILED`&&t.message===`Android device is still booting`?`ANDROID_BOOT_TIMEOUT`:n}function de(e,t){return{serial:e.serial,timeoutMs:e.timeoutMs,elapsedMs:e.deadline.elapsedMs(),reason:t,hint:ee(t),stdout:e.lastBootResult?.stdout,stderr:e.lastBootResult?.stderr,exitCode:e.lastBootResult?.exitCode,...n(e.error).details??{}}}function fe(e,n,r,i){return r||n===`ANDROID_BOOT_TIMEOUT`?new t(`COMMAND_FAILED`,`Android device did not finish booting in time`,i):e.code===`TOOL_MISSING`?new t(`TOOL_MISSING`,e.message,i):n===`ADB_TRANSPORT_UNAVAILABLE`?new t(`COMMAND_FAILED`,e.message,i):new t(e.code,e.message,i,e.cause)}var pe=e({closeAndroidApp:()=>Z,isAmStartError:()=>J,listAndroidApps:()=>I,openAndroidApp:()=>U,openAndroidDevice:()=>X,parseAndroidLaunchComponent:()=>Y});const M=`android.intent.category.LAUNCHER`,N=`android.intent.category.LEANBACK_LAUNCHER`,P=`android.intent.category.DEFAULT`,F=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);async function I(e,t){let n=await L(e);return(t===`user-installed`?(await B(e)).filter(e=>n.has(e)):Array.from(n)).sort((e,t)=>e.localeCompare(t)).map(e=>({package:e,name:y(e)}))}async function L(e){let t=new Set;for(let n of z(e,{includeFallbackWhenUnknown:!0})){let r=await _(e,[`cmd`,`package`,`query-activities`,`--brief`,`-a`,`android.intent.action.MAIN`,`-c`,n],{allowFailure:!0});if(r.exitCode===0&&r.stdout.trim().length!==0)for(let e of re(r.stdout))t.add(e)}return t}function R(e){return z(e)[0]??M}function z(e,t={}){return e.target===`tv`?[N]:e.target===`mobile`?[M]:t.includeFallbackWhenUnknown?[M,N]:[M]}async function B(e){let t=await _(e,[`pm`,`list`,`packages`,`-3`]);return ne(t.stdout)}function me(e){let t;try{t=new URL(e)}catch{return null}let n=t.hostname.toLowerCase();if(!F.has(n)||!t.port)return null;let r=Number(t.port);return Number.isInteger(r)?`tcp:${r}`:null}async function V(e,n){let r=me(n);if(!r)return;let i=p(f(e));try{await i.ensure({local:r,remote:r})}catch(e){let n={localPort:r.replace(`tcp:`,``),operation:`adb reverse ${r} ${r}`};throw e instanceof t&&Object.assign(n,{hint:e.details?.hint,diagnosticId:e.details?.diagnosticId,logPath:e.details?.logPath}),new t(`COMMAND_FAILED`,`Failed to ensure Android port reverse ${r} before opening localhost URL`,n,e)}}function H(e){return e.launchArgs??[]}async function U(e,t,n){e.booted||await j(e.id);let i=xe(n),a=i.activity,o=t.trim();if(r(o)){await he(e,o,i);return}if(i.url!==void 0){await ge(e,t,i);return}let s=await b(e,t),c=R(e);if(s.type===`intent`){await _e(e,s.value,i);return}if(a){await ve(e,s.value,a,c,i);return}await ye(e,s.value,c,i)}async function he(e,n,r){if(r.activity)throw new t(`INVALID_ARGS`,`Activity override is not supported when opening a deep link URL`);await V(e,n),await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.VIEW`,`-d`,n,...Se(r.appBundleId),...H(r)])}async function ge(e,n,i){if(i.activity)throw new t(`INVALID_ARGS`,`Activity override is not supported when opening an app-bound deep link URL`);let a=i.url?.trim()??``;if(!r(a))throw new t(`INVALID_ARGS`,`Android app-bound open requires a valid URL target`);await V(e,a);let o=await be(e,n,`app-bound open`);await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.VIEW`,`-d`,a,`-p`,o,...H(i)])}async function _e(e,n,r){if(r.activity)throw new t(`INVALID_ARGS`,`Activity override requires a package name, not an intent`);await _(e,[`am`,`start`,`-W`,`-a`,n,...H(r)])}async function ve(e,t,n,r,i){let a=n.includes(`/`)?n:`${t}/${n.startsWith(`.`)?n:`.${n}`}`;try{await _(e,W(a,r,i))}catch(n){throw await Ce(e,t,n),n}}async function ye(e,t,n,r){let i=await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.MAIN`,`-c`,P,`-c`,n,`-p`,t,...H(r)],{allowFailure:!0});if(i.exitCode===0&&!J(i.stdout,i.stderr))return;let a=await we(e,t);if(!a)throw await K(e,t)?g(`Failed to launch ${t}`,i):G(t);await _(e,W(a,n,r))}function W(e,t,n){return[`am`,`start`,`-W`,`-a`,`android.intent.action.MAIN`,`-c`,P,`-c`,t,`-n`,e,...H(n)]}async function be(e,n,r){let i=await b(e,n);if(i.type===`intent`)throw new t(`INVALID_ARGS`,`Android ${r} requires a package name, not an intent`);return i.value}function xe(e){return typeof e==`string`?{activity:e}:e??{}}function Se(e){let t=e?.trim();return t?[`-p`,t]:[]}function G(e){return new t(`APP_NOT_INSTALLED`,`No package found matching "${e}"`,{package:e,hint:te})}async function K(e,t){let n=await _(e,[`pm`,`path`,t],{allowFailure:!0}),r=`${n.stdout}\n${n.stderr}`;return n.exitCode===0&&/\bpackage:/i.test(r)?!0:(q(r),!1)}async function Ce(e,n,r){if(q(r instanceof t?`${String(r.details?.stdout??``)}\n${String(r.details?.stderr??``)}`:``)||!await K(e,n))throw G(n)}function q(e){return/\bunknown package\b/i.test(e)||/\bpackage .* (?:was|is) not found\b/i.test(e)||/\bpackage .* does not exist\b/i.test(e)||/\bcould not find package\b/i.test(e)}async function we(e,t){let n=Array.from(new Set(z(e,{includeFallbackWhenUnknown:!0})));for(let r of n){let n=await _(e,[`cmd`,`package`,`resolve-activity`,`--brief`,`-a`,`android.intent.action.MAIN`,`-c`,r,t],{allowFailure:!0});if(n.exitCode!==0)continue;let i=Y(n.stdout);if(i)return i}return null}function J(e,t){return`${e}\n${t}`.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{F as t,P as n}from"./sdk-contracts.js";import{i as r}from"./sdk-batch-runner.js";import{d as i,g as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./command.js";import{i as s,n as c}from"./retry.js";import{_ as l,g as u,o as d,p as f}from"./adb-executor.js";import{n as p}from"./device-shell.js";import{i as m,o as h}from"./adb-transport.js";import{n as g}from"./adb-failure.js";import{o as _}from"./adb.js";import{n as v,t as ee}from"./boot-diagnostics.js";import{n as y,r as b,t as te}from"./app-deployment-resolution.js";import{a as ne,i as re}from"./app-parsers.js";import{n as ie}from"./window-state.js";import x from"node:path";const ae=[`emulator`,`platform-tools`,x.join(`cmdline-tools`,`latest`,`bin`),x.join(`cmdline-tools`,`tools`,`bin`)];function S(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function C(e=u().environment,t){let n=e.ANDROID_SDK_ROOT?.trim(),r=e.ANDROID_HOME?.trim(),i=e.HOME?.trim(),a=t===`darwin`&&i?x.join(i,`Library`,`Android`,`sdk`):``,o=i?x.join(i,`Android`,`Sdk`):``;return S([n??``,r??``,a,o])}async function w(e=u().environment,t=u().files){let n=[],r,{hostPlatform:i}=await import(`./process.js`).then(e=>e.t);for(let a of C(e,i())){let e=[];for(let n of ae){let r=x.join(a,n);await t.isExecutable(r)&&e.push(r)}e.length!==0&&(r||=a,n.push(...e))}if(r&&(e.ANDROID_SDK_ROOT=e.ANDROID_SDK_ROOT?.trim()||r,e.ANDROID_HOME=e.ANDROID_HOME?.trim()||r),n.length===0)return;let a=(e.PATH??``).split(x.delimiter).map(e=>e.trim()).filter(e=>e.length>0);e.PATH=S([...n,...a]).join(x.delimiter)}const T=1e4;async function oe(e,t){await w();let r=e.avdName.trim();if(!r)throw new n(`INVALID_ARGS`,`Android emulator boot requires a non-empty AVD name.`);let o=e.timeoutMs??12e4;if(!await a(`adb`))throw new n(`TOOL_MISSING`,`adb not found in PATH`);if(!await a(`emulator`))throw new n(`TOOL_MISSING`,`emulator not found in PATH`);let s=await E(t,e.serial),c=D(s,r,e.serial);if(!c)throw new n(`DEVICE_NOT_FOUND`,`No Android emulator AVD named ${e.avdName}`,{requestedAvdName:r,availableAvds:s.map(e=>e.name),hint:"Run `emulator -list-avds` and pass an existing AVD name to --device."});let l=c.name,u=Date.now(),d=O(c)?c:void 0;if(!d){let t=[`-avd`,l];e.headless&&t.push(`-no-window`,`-no-audio`),i(`emulator`,t)}let f=d??await se({dependencies:t,avdName:l,serial:e.serial,timeoutMs:o}),p=Date.now()-u;return await j(f.id,Math.max(1e3,o-p)),{...(await E(t,e.serial)).find(e=>e.id===f.id)??f,name:l,booted:!0}}async function E(e,t){return await e.discoverLocal({platform:`android`,kind:`emulator`,...t?{serial:t}:{},...e.androidSerialAllowlist?{androidSerialAllowlist:[...e.androidSerialAllowlist]}:{}})}function D(e,t,n){let r=A(t);return e.find(e=>e.platform===`android`&&e.kind===`emulator`&&A(e.name)===r&&(!n||!O(e)||e.id===n))}function O(e){return k(e.id)}function k(e){return e.startsWith(`emulator-`)}function A(e){return e.toLowerCase().replaceAll(`_`,` `).replaceAll(/\s+/g,` `).trim()}async function se(e){let t=Date.now(),r=Math.min(1e3,Math.max(50,Math.floor(e.timeoutMs/20)));for(;Date.now()-t<e.timeoutMs;){try{let t=D(await E(e.dependencies,e.serial),e.avdName,e.serial);if(t&&O(t))return t}catch{}await o(r)}throw new n(`COMMAND_FAILED`,`Android emulator did not appear in time`,{avdName:e.avdName,serial:e.serial,timeoutMs:e.timeoutMs,hint:`Check emulator logs and verify the AVD can start from command line.`})}async function ce(e,t=T,n){return await l(m(h(e),p(`adb`,`shell`,[`getprop`,`sys.boot_completed`])),{allowFailure:!0,signal:n,timeoutMs:t})}async function j(e,t=6e4,r){let i=c.fromTimeoutMs(t),a=Math.min(1e3,Math.max(50,Math.floor(t/20))),o=Math.max(1,Math.ceil(t/a)),l,u=!1;try{await s(async({deadline:a})=>{if(a?.isExpired())throw u=!0,new n(`COMMAND_FAILED`,`Android boot deadline exceeded`,{serial:e,timeoutMs:t,elapsedMs:i.elapsedMs(),message:`timeout`});let o=Math.max(1e3,a?.remainingMs()??t),s=await ce(e,Math.min(o,T),r);if(l=s,s.stdout.trim()!==`1`)throw new n(`COMMAND_FAILED`,`Android device is still booting`,{serial:e,stdout:s.stdout,stderr:s.stderr,exitCode:s.exitCode})},{maxAttempts:o,baseDelayMs:a,maxDelayMs:a,jitter:0,shouldRetry:e=>{let t=v({error:e,stdout:l?.stdout,stderr:l?.stderr,context:{platform:`android`,phase:`boot`}});return t!==`ADB_TRANSPORT_UNAVAILABLE`&&t!==`ANDROID_BOOT_TIMEOUT`}},{deadline:i,phase:`boot`,signal:r,classifyReason:e=>v({error:e,stdout:l?.stdout,stderr:l?.stderr,context:{platform:`android`,phase:`boot`}})})}catch(n){le({error:n,serial:e,timeoutMs:t,deadline:i,lastBootResult:l,timedOut:u})}}function le(e){let n=t(e.error),r=ue(e,n);throw fe(n,r,e.timedOut,de(e,r))}function ue(e,t){let n=v({error:e.error,stdout:e.lastBootResult?.stdout,stderr:e.lastBootResult?.stderr,context:{platform:`android`,phase:`boot`}});return n===`BOOT_COMMAND_FAILED`&&t.message===`Android device is still booting`?`ANDROID_BOOT_TIMEOUT`:n}function de(e,n){return{serial:e.serial,timeoutMs:e.timeoutMs,elapsedMs:e.deadline.elapsedMs(),reason:n,hint:ee(n),stdout:e.lastBootResult?.stdout,stderr:e.lastBootResult?.stderr,exitCode:e.lastBootResult?.exitCode,...t(e.error).details??{}}}function fe(e,t,r,i){return r||t===`ANDROID_BOOT_TIMEOUT`?new n(`COMMAND_FAILED`,`Android device did not finish booting in time`,i):e.code===`TOOL_MISSING`?new n(`TOOL_MISSING`,e.message,i):t===`ADB_TRANSPORT_UNAVAILABLE`?new n(`COMMAND_FAILED`,e.message,i):new n(e.code,e.message,i,e.cause)}var pe=e({closeAndroidApp:()=>Z,isAmStartError:()=>J,listAndroidApps:()=>I,openAndroidApp:()=>U,openAndroidDevice:()=>X,parseAndroidLaunchComponent:()=>Y});const M=`android.intent.category.LAUNCHER`,N=`android.intent.category.LEANBACK_LAUNCHER`,P=`android.intent.category.DEFAULT`,F=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);async function I(e,t){let n=await L(e);return(t===`user-installed`?(await B(e)).filter(e=>n.has(e)):Array.from(n)).sort((e,t)=>e.localeCompare(t)).map(e=>({package:e,name:y(e)}))}async function L(e){let t=new Set;for(let n of z(e,{includeFallbackWhenUnknown:!0})){let r=await _(e,[`cmd`,`package`,`query-activities`,`--brief`,`-a`,`android.intent.action.MAIN`,`-c`,n],{allowFailure:!0});if(r.exitCode===0&&r.stdout.trim().length!==0)for(let e of re(r.stdout))t.add(e)}return t}function R(e){return z(e)[0]??M}function z(e,t={}){return e.target===`tv`?[N]:e.target===`mobile`?[M]:t.includeFallbackWhenUnknown?[M,N]:[M]}async function B(e){let t=await _(e,[`pm`,`list`,`packages`,`-3`]);return ne(t.stdout)}function me(e){let t;try{t=new URL(e)}catch{return null}let n=t.hostname.toLowerCase();if(!F.has(n)||!t.port)return null;let r=Number(t.port);return Number.isInteger(r)?`tcp:${r}`:null}async function V(e,t){let r=me(t);if(!r)return;let i=f(d(e));try{await i.ensure({local:r,remote:r,ownerId:`localhost-url`})}catch(e){let t={localPort:r.replace(`tcp:`,``),operation:`adb reverse ${r} ${r}`};throw e instanceof n&&Object.assign(t,{reason:e.details?.reason,hint:e.details?.hint,diagnosticId:e.details?.diagnosticId,logPath:e.details?.logPath}),new n(`COMMAND_FAILED`,`Failed to ensure Android port reverse ${r} before opening localhost URL`,t,e)}}function H(e){return e.launchArgs??[]}async function U(e,t,n){e.booted||await j(e.id);let i=xe(n),a=i.activity,o=t.trim();if(r(o)){await he(e,o,i);return}if(i.url!==void 0){await ge(e,t,i);return}let s=await b(e,t),c=R(e);if(s.type===`intent`){await _e(e,s.value,i);return}if(a){await ve(e,s.value,a,c,i);return}await ye(e,s.value,c,i)}async function he(e,t,r){if(r.activity)throw new n(`INVALID_ARGS`,`Activity override is not supported when opening a deep link URL`);await V(e,t),await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.VIEW`,`-d`,t,...Se(r.appBundleId),...H(r)])}async function ge(e,t,i){if(i.activity)throw new n(`INVALID_ARGS`,`Activity override is not supported when opening an app-bound deep link URL`);let a=i.url?.trim()??``;if(!r(a))throw new n(`INVALID_ARGS`,`Android app-bound open requires a valid URL target`);await V(e,a);let o=await be(e,t,`app-bound open`);await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.VIEW`,`-d`,a,`-p`,o,...H(i)])}async function _e(e,t,r){if(r.activity)throw new n(`INVALID_ARGS`,`Activity override requires a package name, not an intent`);await _(e,[`am`,`start`,`-W`,`-a`,t,...H(r)])}async function ve(e,t,n,r,i){let a=n.includes(`/`)?n:`${t}/${n.startsWith(`.`)?n:`.${n}`}`;try{await _(e,W(a,r,i))}catch(n){throw await Ce(e,t,n),n}}async function ye(e,t,n,r){let i=await _(e,[`am`,`start`,`-W`,`-a`,`android.intent.action.MAIN`,`-c`,P,`-c`,n,`-p`,t,...H(r)],{allowFailure:!0});if(i.exitCode===0&&!J(i.stdout,i.stderr))return;let a=await we(e,t);if(!a)throw await K(e,t)?g(`Failed to launch ${t}`,i):G(t);await _(e,W(a,n,r))}function W(e,t,n){return[`am`,`start`,`-W`,`-a`,`android.intent.action.MAIN`,`-c`,P,`-c`,t,`-n`,e,...H(n)]}async function be(e,t,r){let i=await b(e,t);if(i.type===`intent`)throw new n(`INVALID_ARGS`,`Android ${r} requires a package name, not an intent`);return i.value}function xe(e){return typeof e==`string`?{activity:e}:e??{}}function Se(e){let t=e?.trim();return t?[`-p`,t]:[]}function G(e){return new n(`APP_NOT_INSTALLED`,`No package found matching "${e}"`,{package:e,hint:te})}async function K(e,t){let n=await _(e,[`pm`,`path`,t],{allowFailure:!0}),r=`${n.stdout}\n${n.stderr}`;return n.exitCode===0&&/\bpackage:/i.test(r)?!0:(q(r),!1)}async function Ce(e,t,r){if(q(r instanceof n?`${String(r.details?.stdout??``)}\n${String(r.details?.stderr??``)}`:``)||!await K(e,t))throw G(t)}function q(e){return/\bunknown package\b/i.test(e)||/\bpackage .* (?:was|is) not found\b/i.test(e)||/\bpackage .* does not exist\b/i.test(e)||/\bcould not find package\b/i.test(e)}async function we(e,t){let n=Array.from(new Set(z(e,{includeFallbackWhenUnknown:!0})));for(let r of n){let n=await _(e,[`cmd`,`package`,`resolve-activity`,`--brief`,`-a`,`android.intent.action.MAIN`,`-c`,r,t],{allowFailure:!0});if(n.exitCode!==0)continue;let i=Y(n.stdout);if(i)return i}return null}function J(e,t){return`${e}\n${t}`.split(`
|
|
2
2
|
`).some(e=>{let t=e.toLowerCase();return t.startsWith(`error:`)&&(t.includes(`activity not started`)||t.includes(`unable to resolve intent`))})}function Y(e){let t=e.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n===void 0||!n.includes(`/`))continue;let r=n.split(/\s+/)[0];if(r!==void 0)return r}return null}async function X(e){e.booted||await j(e.id)}async function Z(e,
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n===void 0||!n.includes(`/`))continue;let r=n.split(/\s+/)[0];if(r!==void 0)return r}return null}async function X(e){e.booted||await j(e.id)}async function Z(e,t){if(t.trim().toLowerCase()===`settings`){await _(e,[`am`,`force-stop`,`com.android.settings`]),await Q(e,`com.android.settings`);return}let r=await b(e,t);if(r.type===`intent`)throw new n(`INVALID_ARGS`,`Close requires a package name, not an intent`);await _(e,[`am`,`force-stop`,r.value]),await Q(e,r.value)}async function Q(e,t){await Te(e,t),await De(e,t)}async function Te(e,t){let n=Date.now()+2e3;for(;Date.now()<n;){if((await Ee(e))?.package!==t)return;await o(50)}}async function Ee(e){let t=await ie(e);return t.package?t:null}async function De(e,t){let n=Date.now()+2e3;for(;Date.now()<n;){if(!await $(e,t)&&(await o(150),!await $(e,t)))return;await o(50)}}async function $(e,t){return((await _(e,[`pidof`,t],{allowFailure:!0})).stdout??``).trim().length>0}export{X as a,j as c,U as i,w as l,Z as n,Y as o,J as r,oe as s,pe as t,C as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import"./command.js";import{runHarmonyShell as t}from"./hdc.js";import{invalidateHarmonyGestureViewport as n}from"./snapshot2.js";function r(e){return e.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(e=>/^([a-zA-Z0-9_]+\.)+[a-zA-Z0-9_]+$/.test(e))}function i(e){let t=o(e);if(!t)return;let n=t.hapModuleInfos?.find(e=>e.mainElementName);if(n?.mainElementName)return{ability:n.mainElementName,module:n.moduleName}}function a(e){let t=o(e),n=t?.applicationInfo?.isSystemApp??t?.appInfo?.isSystemApp;return typeof n==`boolean`?n:void 0}function o(e){let t=e.indexOf(`{`);if(t!==-1)try{return JSON.parse(e.slice(t))}catch{return}}async function s(n,i,a={}){if(i===`all`)return c(r((await t(n,[`bm`,`dump`,`-a`],{timeoutMs:15e3,signal:a.signal})).stdout));let o=new AbortController,s=setTimeout(()=>o.abort(),6e4),d=u(a.signal,o.signal);try{return c(await l(n,r((await t(n,[`bm`,`dump`,`-a`],{timeoutMs:15e3,signal:d})).stdout),d))}catch(t){throw o.signal.aborted?new e(`COMMAND_FAILED`,`Timed out while classifying HarmonyOS application inventory`,{hint:`Use apps --all to list bundles without per-bundle classification, then retry after the device is responsive.`}):t}finally{clearTimeout(s)}}function c(e){return e.map(e=>({package:e,name:e.split(`.`).at(-1)??e}))}async function l(n,r,i){let o=Array(r.length),s=new AbortController,c=u(i,s.signal),l=0,d,f=Math.min(4,r.length),p=Array.from({length:f},async()=>{try{for(;;){c?.throwIfAborted();let i=l++;if(i>=r.length)return;let s=r[i];if(!s)return;let u=a((await t(n,[`bm`,`dump`,`-n`,s],{timeoutMs:15e3,signal:c})).stdout);if(u===void 0)throw new e(`COMMAND_FAILED`,`Could not determine whether ${s} is a system application`,{hint:`Use apps --all to list all bundles when Bundle Manager does not expose applicationInfo.isSystemApp.`});o[i]=u}}catch(e){throw!c?.aborted&&d===void 0&&(d=e),s.abort(),e}}),m=await Promise.allSettled(p);if(d!==void 0)throw d;let h=m.find(e=>e.status===`rejected`);if(h)throw h.reason;return r.filter((e,t)=>!o[t])}function u(...e){let t=e.filter(e=>!!e);if(t.length!==0)return t.length===1?t[0]:AbortSignal.any(t)}async function d(r,a,o){let s=o?.activity?{ability:o.activity}:i((await t(r,[`bm`,`dump`,`-n`,a],{signal:o?.signal,timeoutMs:15e3})).stdout);if(!s)throw new e(`COMMAND_FAILED`,`Could not determine a launchable ability for ${a}`,{hint:`Pass --activity with the HarmonyOS ability name, or check that the bundle is installed.`});let c=[`aa`,`start`,`-a`,s.ability,`-b`,a];s.module&&c.push(`-m`,s.module);let l=await t(r,c,{signal:o?.signal});if(!l.stdout.includes(`start ability successfully`))throw new e(`COMMAND_FAILED`,`Failed to start ${a}`,{details:{output:l.stdout.trim()}});n(r)}async function f(e,r){await t(e,[`aa`,`force-stop`,r]),n(e)}export{f as closeHarmonyApp,s as listHarmonyApps,d as openHarmonyApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{n as t,t as n}from"./verified-file.js";import"./file.js";import r from"node:fs";import i from"node:path";function a(e,t=process.env){let n=i.dirname(e);r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),s(e),o(e,{maxBytes:l(t.AGENT_DEVICE_APP_LOG_MAX_BYTES,5242880),maxRotatedFiles:l(t.AGENT_DEVICE_APP_LOG_MAX_FILES,1)})}function o(e,t){let n=c(e);if(!(!n||n.size<t.maxBytes))for(let n=t.maxRotatedFiles;n>=1;--n){let t=n===1?e:`${e}.${n-1}`,i=`${e}.${n}`;c(t)&&(c(i)&&r.unlinkSync(i),r.renameSync(t,i))}}function s(e){c(e)}function c(r){let i=t(r);if(i?.isSymbolicLink())throw new e(`COMMAND_FAILED`,`App-log file must not be a symbolic link: ${r}`,{hint:n});return i}function l(e,t){let n=Number.parseInt(e??``,10);return Number.isInteger(n)&&n>0?n:t}export{a as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./
|
|
1
|
+
import{r as e}from"./device2.js";import{r as t}from"./client-options.js";import{A as n}from"./session-stream.js";import{t as r}from"./ios-client.js";import{t as i}from"./instance-client.js";import{t as a}from"./async-lifecycle.js";async function o(e){if(e.signal?.throwIfAborted(),e.descriptor.ownership===`attached`)return await s(e.instances??{},e.descriptor,e.dependencies);let r=t(e.limrun,`Reconnecting app logs`);try{return e.descriptor.platform===`ios`?await l({...e,limrun:r}):await d({...e,limrun:r})}catch(e){if(e instanceof n)return{status:`missing`};throw e}}async function s(e,t,n){return t.platform===`ios`?c(e.ios,t)?await u(e.ios,t):{status:`ownership-lost`}:c(e.android,t)?await f(e.android,t,n):{status:`ownership-lost`}}function c(t,n){return t!==void 0&&e(t.apiUrl)===n.instanceId}async function l(e){let t=await p(async()=>await e.limrun.iosInstances.get(e.descriptor.instanceId,{timeout:5e3,maxRetries:0,signal:e.signal}),e.descriptor);return t.status===`active`?await u({apiUrl:t.apiUrl,token:t.instance.status.token},e.descriptor):t}async function u(e,t){let n=await r({apiUrl:e.apiUrl,token:e.token,logLevel:`warn`});return{status:`opened`,reader:{platform:`ios`,leaseId:t.leaseId,instanceId:t.instanceId,ownership:t.ownership,readLogs:async(e,t)=>await n.appLogTail(e,t),[Symbol.asyncDispose]:async()=>n.disconnect()}}}async function d(e){let t=await p(async()=>await e.limrun.androidInstances.get(e.descriptor.instanceId,{timeout:5e3,maxRetries:0,signal:e.signal}),e.descriptor);if(t.status!==`active`)return t;let{instance:n}=t;return n.status.adbWebSocketUrl?await f({apiUrl:t.apiUrl,adbUrl:n.status.adbWebSocketUrl,token:n.status.token},e.descriptor,e.dependencies):{status:`missing`}}async function f(e,t,n){let r=await i({apiUrl:e.apiUrl,adbUrl:e.adbUrl,token:e.token,logLevel:`warn`}),o=new a,s=!1;o.defer(async()=>{s||r.disconnect()});try{let e=await r.startAdbTunnel();o.defer(async()=>{s||e.close()});let i=`${e.address.address}:${e.address.port}`,a=async(e,t)=>await n.host.runAdb(n.android.deviceAdbInvocation(i,e),t),c={platform:`android`,leaseId:t.leaseId,instanceId:t.instanceId,ownership:t.ownership,readLogs:async(e,t)=>await n.android.readLogs(a,t),[Symbol.asyncDispose]:async()=>{await n.host.runAdb(n.android.hostAdbInvocation([`disconnect`,i]),{allowFailure:!0,timeoutMs:1e4}).catch(()=>void 0);let t=(await Promise.allSettled([Promise.resolve().then(()=>e.close()),Promise.resolve().then(()=>r.disconnect())])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Limrun Android app-log reader cleanup failed`)}};return s=!0,{status:`opened`,reader:c}}finally{await o[Symbol.asyncDispose]()}}async function p(e,t){let n=await e();return m(n.metadata.labels,t)?n.status.state===`terminated`||!n.status.apiUrl?{status:`missing`}:{status:`active`,instance:n,apiUrl:n.status.apiUrl}:{status:`ownership-lost`}}function m(e,t){return e?.provider===`limrun`&&e.leaseId===t.leaseId}export{o as reconnectLimrunAppLogReader};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)?r:`${r}\n`),a=`active`}catch{if(o)return;a=`recovering`}await e.host.clock.sleep(1e3)}})(),l;return Te({inspect:()=>({backend:r,state:a,startedAt:i}),finish:async()=>l??=(async()=>(o=!0,await c,(await
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{p as t}from"./sdk-device.js";import{$t as n,tn as r}from"./sdk-batch.js";import{a as i,o as a}from"./device2.js";import{n as o,r as s}from"./request-cancellation.js";import{n as c,t as l}from"./application-lifecycle-runtime.js";import{A as u,B as d,C as f,D as ee,F as te,G as p,I as m,J as h,M as ne,N as re,R as ie,U as ae,V as g,d as _,h as v,k as oe,n as se,o as ce,q as le,s as ue,v as de,w as y,x as b,z as fe}from"./alert-runtime.js";import{n as pe}from"./audio-probe-runtime.js";import{n as me}from"./perf-runtime.js";import{i as he,n as ge}from"./touch-runtime.js";import{r as _e}from"./platform-runtime-unavailable.js";import{a as ve,n as ye}from"./durable-resource.js";import{t as be}from"./async-lifecycle.js";import{a as x,d as xe,f as Se,n as Ce,o as we,u as Te}from"./src7.js";import{i as Ee,t as De}from"./gesture-admission.js";import{n as Oe}from"./interactor-operation-catalog.js";import{t as S}from"./app-log-runtime.js";import{r as ke,t as Ae}from"./application-lifecycle-interaction.js";import{n as je,r as Me,t as Ne}from"./screen-recording-transport.js";import{setTimeout as Pe}from"node:timers/promises";const C=Object.freeze({available:!0}),Fe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose portable gesture execution yet.`}),Ie=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Le=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),Re=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:De}),ze=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:Ee});function w(e,t){if(!t.available)return m({unsupported:t});if(e.platform!==`android`)return m({unsupported:Fe});let n=e.target===`tv`;return m({unsupported:Ie,plan:C,directionalFling:C,multiTouch:n?Re:C,targetAuthoredDrag:n?ze:C,viewport:C})}const Be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose home yet.`}),Ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose tv remote control.`}),He=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`tv-remote is supported only on Android TV targets.`}),Ue=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose keyboard actions.`}),We=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose clipboard access yet.`}),Ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions cannot read settings back.`}),Ke=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose app switcher yet.`}),T=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No Limrun session exposes this system button.`});function E(e,n){let r=n??C,i=Object.freeze({available:!1,reason:`unsupported-provider-mode`});return Object.freeze({...fe({focus:r}),...u({type:r}),...he({unsupported:i,tap:r,longPress:r,hover:n??i,fill:r,tapElementSelector:n??(t(e)?r:i)}),...w(e,r),...re({scroll:r})})}function qe(e){let{device:t,signal:n}=e,r=n=>e.getInteractor(t,n);return Object.freeze({...ae({device:t,signal:n,resolveInteractor:r,presentIosAcquisition:e.presentIosAcquisition}),...ie({device:t,signal:n,resolveInteractor:r}),...oe({device:t,signal:n,resolveInteractor:r}),...ge({device:t,signal:n,resolveInteractor:r,facts:E(t),pause:async e=>await Pe(e,void 0,{signal:n})}),...le({device:t,signal:n,resolveInteractor:r}),...te({device:t,signal:n,facts:w(t,C),resolveInteractor:r}),...ne({device:t,signal:n,resolveInteractor:r})})}function D(e,t){return t?Object.freeze({...y({back:t}),...f({orientation:t}),...b({tvRemote:t})}):e.platform===`android`?Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:e.target===`tv`?C:He})}):Object.freeze({...y({back:C}),...f({orientation:C}),...b({tvRemote:Ve})})}function O(e,t){return t?Object.freeze({...v({unsupported:t})}):e.platform===`android`?Object.freeze({...v({unsupported:Le,read:C,write:C})}):Object.freeze({...v({unsupported:We})})}const Je=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS direct sessions do not expose alert inspection yet.`});function k(e,t){let n=t??(e.platform===`android`?C:Je);return Object.freeze({...se({read:n,wait:n,accept:n,dismiss:n})})}function A(e,t){return t?_({unsupported:t}):e.platform===`android`?_({unsupported:T,home:C,appSwitcher:C}):_({unsupported:T,home:Be,appSwitcher:Ke})}const j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold runs a HID helper through simctl spawn inside a foldable iPhone simulator on the daemon host; a Limrun session has no such simulator.`});function M(){return Object.freeze({setFoldPose:j})}function N(e,t){return Object.freeze({...ue({triggerAppEvent:t??C})})}function P(e,t){let n=t??C,r=t??(e.platform===`android`?C:Ge);return Object.freeze({...ce({setSetting:n,readSetting:r})})}function F(e,t){let n=t??Ue,r=t===void 0&&e.platform===`android`;return Object.freeze({...de(r?{unsupported:n,status:C,dismiss:C,enter:C}:{unsupported:n})})}const I=Object.freeze({resourceKind:S,version:1,encode:e=>({...e}),decode:e=>{let t=Xe(e.ownership);return!t||e.transport!==`limrun-log-poller`||e.platform!==`ios`&&e.platform!==`android`||!L(e.leaseId)||!L(e.instanceId)||!L(e.appBundleId)||!L(e.outputPath)?{status:`invalid`,message:`Invalid Limrun app-log descriptor`}:{status:`decoded`,descriptor:Object.freeze({transport:`limrun-log-poller`,platform:e.platform,leaseId:e.leaseId,instanceId:e.instanceId,ownership:t,appBundleId:e.appBundleId,outputPath:e.outputPath})}}});function Ye(e){if(e.device.platform===`apple`&&!e.device.appleOs)throw TypeError(`Limrun Apple app-log persistence requires an explicit appleOs identity`);return ye({resourceKind:S,sessionId:e.sessionId,device:{id:e.device.id,family:e.device.platform,...e.device.appleOs===void 0?{}:{appleOs:e.device.appleOs},kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}},owner:e.owner,fence:e.fence,lifecycle:`open`,descriptor:ve(I,e.descriptor)})}function Xe(e){return e===void 0?`created`:e===`created`||e===`attached`?e:void 0}function L(e){return typeof e==`string`&&e.trim().length>0}async function R(e){let t=new be,n=!1;t.defer(async()=>{n||await e.reader[Symbol.asyncDispose]()});try{let r=await e.host.outputs.readTail(e.outputPath,262144),i=await e.host.outputs.openAppend(e.outputPath);t.defer(async()=>{n||await i[Symbol.asyncDispose]()});let a=Ze(e,i,nt(r));return n=!0,a}finally{await t[Symbol.asyncDispose]()}}function Ze(e,t,n){let r=it(e.reader),i=e.host.clock.now(),a=`active`,o=!1,s=n,c=(async()=>{for(;!o;){try{let n=await Qe(e);if(n.status===`timeout`){a=`failed`;return}if(o)return;let r=$e(s,n.text);s=n.text,r&&await t.write(r.endsWith(`
|
|
2
|
+
`)?r:`${r}\n`),a=`active`}catch{if(o)return;a=`recovering`}await e.host.clock.sleep(1e3)}})(),l;return Te({inspect:()=>({backend:r,state:a,startedAt:i}),finish:async()=>l??=(async()=>(o=!0,await c,(await rt([e.reader,t])).length>0?(a=`failed`,{status:`cleanup-pending`,reason:`transport-failed`,message:`Limrun app-log cleanup did not settle every owned resource`}):(a=`ended`,{status:`completed`,result:{backend:r,outputPath:e.outputPath,completedAt:e.host.clock.now()}})))()})}async function Qe(e){let t=new AbortController,n=o(e.reader.readLogs(e.appBundleId,1e3),t.signal,`App-log provider read aborted`).then(e=>({status:`read`,text:e}));try{let r=await Promise.race([n,e.host.clock.sleep(5e3,t.signal).then(()=>({status:`timeout`}))]);return r.status===`timeout`&&(t.abort(),await n.catch(()=>void 0)),r}finally{t.abort()}}function $e(e,t){if(!e||!t)return t;let n=et(t),r=Math.min(e.length,t.length),i=e.slice(e.length-r);return t.slice(tt(i,t,n))}function et(e){let t=new Uint32Array(e.length),n=0;for(let r=1;r<e.length;r+=1){for(;n>0&&e[r]!==e[n];)n=t[n-1];e[r]===e[n]&&(n+=1),t[r]=n}return t}function tt(e,t,n){let r=0;for(let i=0;i<e.length;i+=1){for(;r>0&&e[i]!==t[r];)r=n[r-1];e[i]===t[r]&&(r+=1),r===t.length&&i<e.length-1&&(r=n[r-1])}return r}function nt(e){return e.split(`
|
|
3
3
|
`).filter(e=>!e.startsWith(`[agent-device][mark]`)).join(`
|
|
4
|
-
`)}async function nt(e){return(await Promise.allSettled(e.map(async e=>await e[Symbol.asyncDispose]()))).flatMap(e=>e.status===`rejected`?[e.reason]:[])}function rt(e){return e.platform===`ios`?`ios-simulator`:`android`}function it(e){let t=Ae({owner:`Limrun`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,configureProviderPortReverse:async t=>await e.configurePortReverse(t),binding:ke({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})}),n=e.resolveAppReference;return n?Object.freeze({...t,resolveOpenTarget:async e=>await t.resolveOpenTarget(at(e,n)),openApplication:async e=>await t.openApplication(ot(e,n)),closeApplication:async e=>await t.closeApplication(st(e,n))}):t}function at(e,t){return e.target===void 0?e:{...e,target:t(e.target)}}function ot(e,t){return{...e,target:B(e.target,t),positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function st(e,t){return{...e,positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function z(e,t){let n=e[0];return n===void 0?e:[t(n),...e.slice(1)]}function B(e,t){return e===void 0?void 0:t(e)}function ct(e){let t=s(e.id);return!t||e.target!==`mobile`?!1:t.platform===`ios`?e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&e.iosPhysicalDeviceBackend===void 0:e.platform===`android`&&e.appleOs===void 0&&e.kind===`emulator`&&e.iosPhysicalDeviceBackend===void 0}const lt=Object.freeze({available:!0}),V=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The Limrun provider session is no longer active for this device.`}),ut=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for Limrun provider-owned devices.`});function H(e,t){let n=ft(e,t);return Object.freeze({deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:U(e,t)?ut:V})}function dt(e,t,n,r){let i=e.deployApp,a=e.deployMaterializedApp;return!H(e,t).deployApp.available||!i||!a?Object.freeze({}):Object.freeze({deployApp:async e=>W(await i(t,e,n,r)),materializeAppSource:async r=>await pt(e.host,t,r,n),deployMaterializedApp:async e=>W(await a(t,e,n,r))})}function ft(e,t){return ct(t)&&U(e,t)&&e.deployApp&&e.deployMaterializedApp?lt:V}function U(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function pt(e,t,n,r){return await(t.platform===`apple`?e.appleDeployment:e.androidDeployment).prepareArtifact(n,{signal:r})}function W(t){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The Limrun provider session is no longer active.`);return t}const mt=Object.freeze({medium:5,high:8});function ht(e){return Object.freeze({screenRecordingStart:async t=>await gt(e,t),screenRecordingReattach:async()=>Me(`Limrun recordings cannot be reattached after daemon restart.`),screenRecordingCleanup:async()=>je(`Limrun recordings cannot be cleaned after daemon restart; the instance disposes them when it terminates.`)})}async function gt(t,n){let r=t.getDeviceSession(t.device);if(!r)throw new e(`UNSUPPORTED_OPERATION`,`Limrun recording requires a live provider session for this device.`,{deviceId:t.device.id});return await Ne({host:t.host,device:t.device,owner:t.owner,input:n,signal:t.signal,transport:{backend:`limrun-recorder`,targetLabel:`Limrun recording`,start:async()=>{await r.startRecording({quality:mt[n.exportQuality??`medium`]})},stop:async()=>(await r.stopRecording()).downloadUrl,collect:async(e,t)=>{await r.downloadRecording({downloadUrl:e,outPath:t})}},support:{scopes:[`app`,`device`,`system`],fps:!1,exportQuality:!0,hideTouches:!1},unsupported:e=>`Limrun recordings do not support ${e.join(`, `)}`})}const G=Object.freeze({available:!0}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Custom snapshot actions are available only for Limrun iOS simulator sessions.`}),_t=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose viewport resizing.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun-owned devices read element text from the captured tree only.`}),vt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),J=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Limrun requires a matching live provider session for this device.`}),yt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for Limrun-owned devices.`}),bt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.`}),xt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun open requires a Limrun-owned iOS simulator or Android emulator.`}),St=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun close requires a Limrun-owned iOS simulator or Android emulator.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ct=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun port reverse requires an active Android Limrun session.`}),wt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose the audio probe.`});function Tt(e){return{...e,isSessionActive:e.hasLiveSession}}function X(e,t){let n=Et(e,t),r=Dt(e,t),i=Ot(e,t);return l({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:yt,configureProviderPortReverse:i})}function Et(e,t){return a(e)?t?G:J:xt}function Dt(e,t){return a(e)?t?G:J:St}function Ot(e,t){return t?e.platform===`android`?G:Ct:J}function Z(e,n){let r=H(Tt(e),n),i=n.platform===`android`,a=t(n)&&n.kind===`simulator`?G:K;return Object.freeze({device:{family:n.platform,...n.appleOs===void 0?{}:{appleOs:n.appleOs},kind:n.kind,...n.target===void 0?{}:{target:n.target},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend},providerMode:`provider-runtime`},operations:{appLogInspect:G,appLogDoctor:G,appLogStart:G,appLogReattach:G,appLogCleanup:G,...r,appState:i?G:bt,networkDump:G,screenRecordingStart:G,screenRecordingReattach:G,screenRecordingCleanup:G,...p({capture:G,customActions:a,withoutActiveApp:G}),...h({capture:G}),...g({findText:K}),...d({setViewport:_t}),...E(n),...ee({readTextAtPoint:q}),...D(n),...F(n),...O(n),...A(n),...M(),...N(n),...P(n),...k(n),...pe({capture:wt,query:wt}),...me({frames:q,memorySample:q,memorySnapshot:q,nativeCapture:q,profileReport:q}),ensureReady:G,bootTarget:G,bootTargetHeadless:vt,listApps:G,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`Limrun owns the target lifecycle for provider-owned devices.`},...X(n,!0)}})}function kt(e,t){let n=Z(e,t);return Object.freeze({device:n.device,operations:{...n.operations,appLogInspect:J,appLogDoctor:J,appLogStart:J,appLogReattach:G,appLogCleanup:G,appState:J,networkDump:J,screenRecordingStart:J,screenRecordingReattach:J,screenRecordingCleanup:J,...p({capture:J,customActions:J,withoutActiveApp:J}),...h({capture:J}),...g({findText:J}),...d({setViewport:J}),...E(t,J),...D(t,J),...F(t,J),...O(t,J),...A(t,J),...M(),...N(t,J),...P(t,J),...k(t,J),ensureReady:J,bootTarget:J,bootTargetHeadless:J,listApps:J,deployApp:J,materializeAppSource:J,deployMaterializedApp:J,sendPushNotification:J,shutdownTarget:J,...X(t,!1)}})}function At(t){let i=n(`limrun`,t.runtimeInstance),o=e=>a(e)&&t.ownsDevice(e),s=e=>o(e)&&t.hasLiveSession(e);return Object.freeze({owner:i,ownsDevice:o,inspectFacts:async e=>s(e)?Z(t,e):_e(e,i,{appLog:J,appState:J,appDeployment:J,network:J,screenshot:J,viewport:J,focus:J,gesture:J,scroll:J,typeText:J,touch:J,elementText:J,back:J,orientation:J,tvRemote:J,keyboard:J,clipboard:J,systemButton:J,fold:j,triggerAppEvent:J,settings:J,readAlert:J,awaitAlert:J,acceptAlert:J,dismissAlert:J,audioProbeCapture:J,audioProbeQuery:J,perf:J,readiness:J,shutdown:J,lifecycle:X(e,!1)}),bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,i))throw new e(`UNSUPPORTED_OPERATION`,`Limrun app-log owner identity does not match`);if(!a(n.device))throw new e(`UNSUPPORTED_PLATFORM`,`Limrun app logs require an iOS simulator or Android emulator device identity`);let o=s(n.device);if(n.intent.kind!==`exact-owner`&&!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun provider session is no longer live for the selected device`,{reason:`provider-session-unavailable`});return jt(t,i,n.device,n.scope.signal,!o)},shutdown:async()=>void 0})}function jt(t,n,r,i,a){let s=a?kt(t,r):Z(t,r),l=o(),u=xe({codec:I,reattach:async(e,n)=>{if(!$(e,r)||!x(t.host,n.sessionId,e))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Limrun app-log descriptor does not match the bound device or owning session`};let a=await t.reconnect(e,i);return a.status===`missing`?{status:`missing`}:a.status===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`active`,handle:await R({host:t.host,reader:a.reader,appBundleId:e.appBundleId,outputPath:e.outputPath})}},cleanup:async(e,n)=>$(e,r)&&x(t.host,n.sessionId,e)?{status:`cleaned`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Limrun app-log descriptor does not match the bound device or owning session`}}),d={appLogInspect:async()=>({backend:Q(r)}),appLogDoctor:async()=>({backend:Q(r),checks:{limrunSessionAvailable:await Mt(t,r,i)},notes:[]}),appLogStart:async a=>{we(t.host,a),i.throwIfAborted();let o=await t.openCurrent(r);if(!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun app logs require an active instance`);let s={transport:`limrun-log-poller`,platform:o.platform,leaseId:o.leaseId,instanceId:o.instanceId,appBundleId:a.appBundleId,outputPath:a.outputPath},c=!1;try{i.throwIfAborted();let e=Ye({sessionId:a.sessionId,device:r,owner:n,fence:a.fence,descriptor:s});c=!0;let l=await R({host:t.host,reader:o,appBundleId:a.appBundleId,outputPath:a.outputPath});return Se(l,e)}catch(e){throw c||await o[Symbol.asyncDispose](),e}},...u,networkDump:async e=>{let n=await t.host.appLogs.readRecent(e.sessionId,e.maxScanLines),i=Q(r),{dump:a}=Ce(n.text,{...e,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i}),o=a.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[];return Object.freeze({source:`app-log`,backend:i,dump:a,notes:o})},ensureReady:async()=>({...r,booted:!0}),bootTarget:async()=>({...r,booted:!0}),listApps:async e=>await t.listApps(e.device,e.filter,i),...r.platform===`android`?{appState:async()=>await t.getAppState(r,i)}:{},...c(it({device:r,signal:i,getInteractor:t.getInteractor,resolveAppReference:e=>t.resolveAppReference?.(r,e)??e,configurePortReverse:t.configurePortReverse}),s.operations),...qe({device:r,signal:i,getInteractor:t.getInteractor,presentIosAcquisition:t.host.snapshot.presentIosAcquisition}),...Oe({device:r,signal:i,resolveInteractor:e=>t.getInteractor(r,e),facts:s.operations}),...dt(Tt(t),r,i,l),...ht({host:t.host,device:r,owner:n,signal:i,getDeviceSession:t.getDeviceSession})};return Object.freeze({device:r,owner:n,facts:s,operations:Object.freeze(a?{appLogReattach:u.appLogReattach,appLogCleanup:u.appLogCleanup}:d),[Symbol.asyncDispose]:async()=>await l[Symbol.asyncDispose]()})}async function Mt(e,t,n){n.throwIfAborted();let r=await e.openCurrent(t);if(!r)return!1;try{n.throwIfAborted()}finally{await r[Symbol.asyncDispose]()}return!0}function Q(e){return e.platform===`apple`?`ios-simulator`:`android`}function $(e,t){if(!a(t))return!1;let n=s(t.id);return n!==void 0&&n.leaseId===e.leaseId&&n.platform===e.platform&&(t.platform===`apple`?e.platform===`ios`:e.platform===`android`)}export{At as createLimrunPlatformRuntimeOwner};
|
|
4
|
+
`)}async function rt(e){return(await Promise.allSettled(e.map(async e=>await e[Symbol.asyncDispose]()))).flatMap(e=>e.status===`rejected`?[e.reason]:[])}function it(e){return e.platform===`ios`?`ios-simulator`:`android`}function at(e){let t=Ae({owner:`Limrun`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,configureProviderPortReverse:async t=>await e.configurePortReverse(t),binding:ke({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})}),n=e.resolveAppReference;return n?Object.freeze({...t,resolveOpenTarget:async e=>await t.resolveOpenTarget(ot(e,n)),openApplication:async e=>await t.openApplication(st(e,n)),closeApplication:async e=>await t.closeApplication(ct(e,n))}):t}function ot(e,t){return e.target===void 0?e:{...e,target:t(e.target)}}function st(e,t){return{...e,target:B(e.target,t),positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function ct(e,t){return{...e,positionals:z(e.positionals,t),appBundleId:B(e.appBundleId,t)}}function z(e,t){let n=e[0];return n===void 0?e:[t(n),...e.slice(1)]}function B(e,t){return e===void 0?void 0:t(e)}function lt(e){let t=a(e.id);return!t||e.target!==`mobile`?!1:t.platform===`ios`?e.platform===`apple`&&e.appleOs===`ios`&&e.kind===`simulator`&&e.iosPhysicalDeviceBackend===void 0:e.platform===`android`&&e.appleOs===void 0&&e.kind===`emulator`&&e.iosPhysicalDeviceBackend===void 0}const ut=Object.freeze({available:!0}),V=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The Limrun provider session is no longer active for this device.`}),dt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for Limrun provider-owned devices.`});function H(e,t){let n=pt(e,t);return Object.freeze({deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:U(e,t)?dt:V})}function ft(e,t,n,r){let i=e.deployApp,a=e.deployMaterializedApp;return!H(e,t).deployApp.available||!i||!a?Object.freeze({}):Object.freeze({deployApp:async e=>W(await i(t,e,n,r)),materializeAppSource:async r=>await mt(e.host,t,r,n),deployMaterializedApp:async e=>W(await a(t,e,n,r))})}function pt(e,t){return lt(t)&&U(e,t)&&e.deployApp&&e.deployMaterializedApp?ut:V}function U(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function mt(e,t,n,r){return await(t.platform===`apple`?e.appleDeployment:e.androidDeployment).prepareArtifact(n,{signal:r})}function W(t){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The Limrun provider session is no longer active.`);return t}const ht=Object.freeze({medium:5,high:8});function gt(e){return Object.freeze({screenRecordingStart:async t=>await _t(e,t),screenRecordingReattach:async()=>Me(`Limrun recordings cannot be reattached after daemon restart.`),screenRecordingCleanup:async()=>je(`Limrun recordings cannot be cleaned after daemon restart; the instance disposes them when it terminates.`)})}async function _t(t,n){let r=t.getDeviceSession(t.device);if(!r)throw new e(`UNSUPPORTED_OPERATION`,`Limrun recording requires a live provider session for this device.`,{deviceId:t.device.id});return await Ne({host:t.host,device:t.device,owner:t.owner,input:n,signal:t.signal,transport:{backend:`limrun-recorder`,targetLabel:`Limrun recording`,start:async()=>{await r.startRecording({quality:ht[n.exportQuality??`medium`]})},stop:async()=>(await r.stopRecording()).downloadUrl,collect:async(e,t)=>{await r.downloadRecording({downloadUrl:e,outPath:t})}},support:{scopes:[`app`,`device`,`system`],fps:!1,exportQuality:!0,hideTouches:!1},unsupported:e=>`Limrun recordings do not support ${e.join(`, `)}`})}const G=Object.freeze({available:!0}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Custom snapshot actions are available only for Limrun iOS simulator sessions.`}),vt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose viewport resizing.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun-owned devices read element text from the captured tree only.`}),yt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),J=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`Limrun requires a matching live provider session for this device.`}),bt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for Limrun-owned devices.`}),xt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun iOS appstate is session-owned; no sessionless provider foreground probe is exposed.`}),St=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun open requires a Limrun-owned iOS simulator or Android emulator.`}),Ct=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun close requires a Limrun-owned iOS simulator or Android emulator.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),wt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun port reverse requires an active Android Limrun session.`}),Tt=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Limrun does not expose the audio probe.`});function Et(e){return{...e,isSessionActive:e.hasLiveSession}}function X(e,t){let n=Dt(e,t),r=Ot(e,t),i=kt(e,t);return l({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:bt,configureProviderPortReverse:i})}function Dt(e,t){return i(e)?t?G:J:St}function Ot(e,t){return i(e)?t?G:J:Ct}function kt(e,t){return t?e.platform===`android`?G:wt:J}function Z(e,n){let r=H(Et(e),n),i=n.platform===`android`,a=t(n)&&n.kind===`simulator`?G:K;return Object.freeze({device:{family:n.platform,...n.appleOs===void 0?{}:{appleOs:n.appleOs},kind:n.kind,...n.target===void 0?{}:{target:n.target},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend},providerMode:`provider-runtime`},operations:{appLogInspect:G,appLogDoctor:G,appLogStart:G,appLogReattach:G,appLogCleanup:G,...r,appState:i?G:xt,networkDump:G,screenRecordingStart:G,screenRecordingReattach:G,screenRecordingCleanup:G,...p({capture:G,customActions:a,withoutActiveApp:G}),...h({capture:G}),...g({findText:K}),...d({setViewport:vt}),...E(n),...ee({readTextAtPoint:q}),...D(n),...F(n),...O(n),...A(n),...M(),...N(n),...P(n),...k(n),...pe({capture:Tt,query:Tt}),...me({frames:q,memorySample:q,memorySnapshot:q,nativeCapture:q,profileReport:q}),ensureReady:G,bootTarget:G,bootTargetHeadless:yt,listApps:G,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`Limrun owns the target lifecycle for provider-owned devices.`},...X(n,!0)}})}function At(e,t){let n=Z(e,t);return Object.freeze({device:n.device,operations:{...n.operations,appLogInspect:J,appLogDoctor:J,appLogStart:J,appLogReattach:G,appLogCleanup:G,appState:J,networkDump:J,screenRecordingStart:J,screenRecordingReattach:J,screenRecordingCleanup:J,...p({capture:J,customActions:J,withoutActiveApp:J}),...h({capture:J}),...g({findText:J}),...d({setViewport:J}),...E(t,J),...D(t,J),...F(t,J),...O(t,J),...A(t,J),...M(),...N(t,J),...P(t,J),...k(t,J),ensureReady:J,bootTarget:J,bootTargetHeadless:J,listApps:J,deployApp:J,materializeAppSource:J,deployMaterializedApp:J,sendPushNotification:J,shutdownTarget:J,...X(t,!1)}})}function jt(t){let a=n(`limrun`,t.runtimeInstance),o=e=>i(e)&&t.ownsDevice(e),s=e=>o(e)&&t.hasLiveSession(e);return Object.freeze({owner:a,ownsDevice:o,inspectFacts:async e=>s(e)?Z(t,e):_e(e,a,{appLog:J,appState:J,appDeployment:J,network:J,screenshot:J,viewport:J,focus:J,gesture:J,scroll:J,typeText:J,touch:J,elementText:J,back:J,orientation:J,tvRemote:J,keyboard:J,clipboard:J,systemButton:J,fold:j,triggerAppEvent:J,settings:J,readAlert:J,awaitAlert:J,acceptAlert:J,dismissAlert:J,audioProbeCapture:J,audioProbeQuery:J,perf:J,readiness:J,shutdown:J,lifecycle:X(e,!1)}),bind:async n=>{if(n.intent.kind===`exact-owner`&&!r(n.intent.owner,a))throw new e(`UNSUPPORTED_OPERATION`,`Limrun app-log owner identity does not match`);if(!i(n.device))throw new e(`UNSUPPORTED_PLATFORM`,`Limrun app logs require an iOS simulator or Android emulator device identity`);let o=s(n.device);if(n.intent.kind!==`exact-owner`&&!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun provider session is no longer live for the selected device`,{reason:`provider-session-unavailable`});return Mt(t,a,n.device,n.scope.signal,!o)},shutdown:async()=>void 0})}function Mt(t,n,r,i,a){let o=a?At(t,r):Z(t,r),l=s(),u=xe({codec:I,reattach:async(e,n)=>{if(!$(e,r)||!x(t.host,n.sessionId,e))return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Limrun app-log descriptor does not match the bound device or owning session`};let a=await t.reconnect(e,i);return a.status===`missing`?{status:`missing`}:a.status===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`active`,handle:await R({host:t.host,reader:a.reader,appBundleId:e.appBundleId,outputPath:e.outputPath})}},cleanup:async(e,n)=>$(e,r)&&x(t.host,n.sessionId,e)?{status:`cleaned`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`,message:`Limrun app-log descriptor does not match the bound device or owning session`}}),d={appLogInspect:async()=>({backend:Q(r)}),appLogDoctor:async()=>({backend:Q(r),checks:{limrunSessionAvailable:await Nt(t,r,i)},notes:[]}),appLogStart:async a=>{we(t.host,a),i.throwIfAborted();let o=await t.openCurrent(r);if(!o)throw new e(`UNSUPPORTED_OPERATION`,`Limrun app logs require an active instance`);let s={transport:`limrun-log-poller`,platform:o.platform,leaseId:o.leaseId,instanceId:o.instanceId,ownership:o.ownership,appBundleId:a.appBundleId,outputPath:a.outputPath},c=!1;try{i.throwIfAborted();let e=Ye({sessionId:a.sessionId,device:r,owner:n,fence:a.fence,descriptor:s});c=!0;let l=await R({host:t.host,reader:o,appBundleId:a.appBundleId,outputPath:a.outputPath});return Se(l,e)}catch(e){throw c||await o[Symbol.asyncDispose](),e}},...u,networkDump:async e=>{let n=await t.host.appLogs.readRecent(e.sessionId,e.maxScanLines),i=Q(r),{dump:a}=Ce(n.text,{...e,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i}),o=a.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[];return Object.freeze({source:`app-log`,backend:i,dump:a,notes:o})},ensureReady:async()=>({...r,booted:!0}),bootTarget:async()=>({...r,booted:!0}),listApps:async e=>await t.listApps(e.device,e.filter,i),...r.platform===`android`?{appState:async()=>await t.getAppState(r,i)}:{},...c(at({device:r,signal:i,getInteractor:t.getInteractor,resolveAppReference:e=>t.resolveAppReference?.(r,e)??e,configurePortReverse:t.configurePortReverse}),o.operations),...qe({device:r,signal:i,getInteractor:t.getInteractor,presentIosAcquisition:t.host.snapshot.presentIosAcquisition}),...Oe({device:r,signal:i,resolveInteractor:e=>t.getInteractor(r,e),facts:o.operations}),...ft(Et(t),r,i,l),...gt({host:t.host,device:r,owner:n,signal:i,getDeviceSession:t.getDeviceSession})};return Object.freeze({device:r,owner:n,facts:o,operations:Object.freeze(a?{appLogReattach:u.appLogReattach,appLogCleanup:u.appLogCleanup}:d),[Symbol.asyncDispose]:async()=>await l[Symbol.asyncDispose]()})}async function Nt(e,t,n){n.throwIfAborted();let r=await e.openCurrent(t);if(!r)return!1;try{n.throwIfAborted()}finally{await r[Symbol.asyncDispose]()}return!0}function Q(e){return e.platform===`apple`?`ios-simulator`:`android`}function $(e,t){if(!i(t))return!1;let n=a(t.id);return n!==void 0&&n.leaseId===e.leaseId&&n.platform===e.platform&&(t.platform===`apple`?e.platform===`ios`:e.platform===`android`)}export{jt as createLimrunPlatformRuntimeOwner};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{J as t,P as n}from"./sdk-contracts.js";import{a as r,i,r as a}from"./verified-file.js";import"./file.js";import{a as o,n as s,t as c}from"./durable-capture-resource.js";import{t as l}from"./app-log-files.js";import u from"node:fs";import d from"node:path";const f=s({resourceKind:`app-log`,fileName:`app-log.resource.json`,displayName:`App-log`});function p(e){let t=i(e);if(t===void 0)return{exists:!1,sizeBytes:0};try{let e=u.fstatSync(t);return{exists:!0,sizeBytes:e.size,modifiedAt:e.mtime.toISOString()}}finally{u.closeSync(t)}}function m(e,t){l(e);let n=`[agent-device][mark][${new Date().toISOString()}] ${t.trim()||`marker`}\n`,r=a(e);try{u.writeFileSync(r,n,`utf8`)}finally{u.closeSync(r)}}function h(e){let t=d.dirname(e),n=d.basename(e);u.existsSync(t)||u.mkdirSync(t,{recursive:!0});let i=r(e);try{u.fsyncSync(i)}finally{u.closeSync(i)}let a=0;for(let e of u.readdirSync(t)){if(!e.startsWith(`${n}.`))continue;let r=e.slice(n.length+1);if(/^\d+$/.test(r))try{u.unlinkSync(d.join(t,e)),a+=1}catch{}}return{path:e,cleared:!0,removedRotatedFiles:a}}var g=e({adoptStartedSessionAppLog:()=>y,appLogDurableResource:()=>_,bindSessionAppLog:()=>C,clearStoppedSessionAppLog:()=>w,finishSessionAppLog:()=>b,forceCleanupSessionAppLog:()=>x,inspectSessionAppLog:()=>v,recordSessionAppLogFailure:()=>S});const _=c({resourceKind:`app-log`,displayName:`app-log`,store:f,completionMetadata:e=>({backend:e.backend,outputPath:e.outputPath,completedAt:e.completedAt}),failedFinishPolicy:`dispose-on-failed-finish`,messages:{noActive:`no app log stream active`,cleanupPendingHint:`Keep app-log.resource.json and retry cleanup through its exact runtime owner.`}});function v(e){if(e.appLog){let t=e.appLog.handle.inspect();return{active:t.state===`active`||t.state===`recovering`,...t}}return e.appLogFailure?{active:!1,state:`failed`,backend:e.appLogFailure.backend,failureCode:e.appLogFailure.code,failureMessage:e.appLogFailure.message,hint:e.appLogFailure.hint}:{active:!1,state:`inactive`}}function y(e){return _.adoptStarted({...e,binding:C(e.sessionStore,e.ref)})}function b(e){return _.finishLive({binding:C(e.sessionStore,e.ref),intent:e.intent})}function x(e){return _.forceCleanupLive({binding:C(e.sessionStore,e.ref)})}function S(e){let n=t(e.error),r=e.sessionStore.resolveCurrent(e.ref);return!r||r.appLog||e.sessionStore.update(e.ref,{appLog:void 0,appLogFailure:{backend:e.backend,code:n.code,message:n.message,hint:n.hint}}),n}function C(e,t){return o(e,t,{read:e=>e.appLog,write:n=>{e.update(t,{appLog:n,appLogFailure:void 0})}})}function w(e){if(e.sessionStore.requireCurrent(e.ref).appLog)throw new n(`INVALID_ARGS`,`logs clear requires logs to be stopped first; run logs stop`);let t=h(e.sessionStore.resolveAppLogPath(e.ref.address));return e.sessionStore.update(e.ref,{appLogFailure:void 0}),t}export{w as a,S as c,f as d,C as i,m as l,_ as n,b as o,g as r,v as s,y as t,p as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
2
|
-
`)){let t=
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{K as t,P as n}from"./sdk-contracts.js";import{i as r}from"./sdk-batch-runner.js";import{m as i,p as a}from"./sdk-device.js";import{_ as o}from"./settings.js";import{i as s}from"./exec.js";import"./command.js";import{t as c}from"./ttl-memo.js";import{n as l}from"./retry.js";import{t as u}from"./app-resolution-cache.js";import{u as ee}from"./host-file.js";import{a as d,i as f,l as p}from"./tool-provider.js";import{t as m}from"./physical-device-control.js";import{a as h}from"./simctl.js";import{r as g}from"./helper.js";import _ from"node:path";import{fileURLToPath as te}from"node:url";import{setTimeout as v}from"node:timers/promises";const y={settings:`com.apple.systempreferences`},b=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,x={platform:`macos`,deviceId:`host`,variant:`all`},S=u();function C(e){return b.test(e)}async function w(e){let t=e.trim(),r=y[t.toLowerCase()];if(r)return r;if(C(t))return t;let i=S.get(x,t);if(i)return i;let a=(await j(`all`)).filter(e=>e.name.toLowerCase()===t.toLowerCase()),o=a[0];if(o!==void 0&&a.length===1)return S.set(x,t,o.bundleId);throw a.length>1?new n(`INVALID_ARGS`,`Multiple apps matched "${e}"`,{matches:a}):new n(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}async function T(e,t,i){let a=i?.url?.trim();if(a){if(!r(a))throw new n(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);let e=i?.appBundleId??await w(t);await M().openBundle(e,a);return}let o=t.trim();if(r(o)){await M().openTarget(o);return}let s=i?.appBundleId??await w(o);await M().openBundle(s)}async function E(e,t){let r=await w(t),i=await g(r);if(i.running){if(!i.terminated&&!i.forceTerminated)throw new n(`COMMAND_FAILED`,`Failed to close macOS app ${t}`,{bundleId:r,running:i.running,terminated:i.terminated,forceTerminated:i.forceTerminated});for(let e=1;e<20;e+=1)if(await v(100),!(await g(r)).running)return;throw new n(`COMMAND_FAILED`,`Timed out waiting for macOS app ${t} to close`,{reason:`MACOS_APP_TERMINATION_TIMEOUT`,bundleId:r,attempts:20})}}async function D(){return await M().readClipboard()}async function O(e){await M().writeClipboard(e)}async function k(){return await M().readDarkMode()}async function A(e){let t=o(e),n=t===`toggle`?!await k():t===`dark`;await M().setDarkMode(n)}async function j(e){return await M().listApps(e)}function M(){let e=f().macosHost;if(!e)throw new n(`UNSUPPORTED_OPERATION`,`macOS host provider is not available`);return e}function N(e){return new n(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}var P=e({buildAppNotInstalledError:()=>N,detectSoleRunningIosSimulatorApp:()=>W,findIosSimulatorInstalledApp:()=>B,invalidateIosAppResolutionCache:()=>R,listIosApps:()=>Y,resolveIosApp:()=>z,resolveIosAppAlias:()=>V,resolveIosSimulatorDeepLinkBundleId:()=>K});const F={settings:`com.apple.Preferences`},I=u();function L(e){return{platform:`ios`,deviceId:e.id,variant:e.kind}}async function R(e,t){return await I.invalidateWhile(L(e),t)}async function z(e,t){if(i(e))return await w(t);let r=t.trim();if(r.includes(`.`))return r;let a=V(r);if(a!==r)return a;let o=L(e),s=I.get(o,r);if(s)return s;let c=(e.kind===`simulator`?await X(e):await m(e).listApps(e,`all`)).filter(e=>e.name.toLowerCase()===r.toLowerCase()),l=c[0];if(l!==void 0&&c.length===1)return I.set(o,r,l.bundleId);throw c.length>1?new n(`INVALID_ARGS`,`Multiple apps matched "${t}"`,{matches:c}):N(t)}async function B(e,t){if(!a(e)||e.kind!==`simulator`||e.booted!==!0)return;let n=V(t.trim());if(!n)return;let r=await X(e);if(n.includes(`.`))return r.find(e=>e.bundleId===n)?.bundleId;let i=r.filter(e=>e.name.toLowerCase()===n.toLowerCase());return i.length===1?i[0]?.bundleId:void 0}function V(e){let t=e.trim();return F[t.toLowerCase()]??e}const H=3e3,U=/UIKitApplication:([^[\s]+)\[/;async function W(e){if(!(!a(e)||e.kind!==`simulator`||e.booted!==!0))try{let[t,n]=await Promise.all([G(e),X(e,{timeoutMs:H})]);if(t.length===0)return;let r=new Map(n.map(e=>[e.bundleId,e])),i=new Map;for(let e of t){let t=r.get(e);t&&i.set(t.bundleId,t)}return i.size===1?[...i.values()][0]:void 0}catch{return}}async function G(e){let t=await h(e,[`spawn`,e.id,`launchctl`,`list`],{allowFailure:!0,timeoutMs:H});if(t.exitCode!==0)return[];let n=[];for(let e of t.stdout.split(`
|
|
2
|
+
`)){let t=U.exec(e);t?.[1]&&n.push(t[1])}return n}async function K(e,t,n={}){if(!a(e)||e.kind!==`simulator`)return;let r=J(t);if(!r)return;let i=q(n),o=await Z(e,i()),s=[];for(let e of o)e.bundleId.startsWith(`com.callstack.agentdevice.runner`)||e.path&&(await ae(_.join(e.path,`Info.plist`),i())).has(r)&&s.push(e);let c=s.filter(e=>e.applicationType===`User`);if(c.length===1)return c[0]?.bundleId;if(!(c.length>1))return s.length===1?s[0]?.bundleId:void 0}function q({timeoutMs:e,signal:t}){let n=t?{signal:t}:{};if(e===void 0)return()=>n;let r=l.fromTimeoutMs(e);return()=>({timeoutMs:Math.max(1,r.remainingMs()),...n})}function J(e){return/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(e.trim())?.[1]?.toLowerCase()}async function Y(e,t){if(i(e))return await j(t);if(e.kind===`simulator`){let n=await X(e);return p(n,t)}return await m(e).listApps(e,t)}async function X(e,t){return(await Z(e,t)).map(e=>({bundleId:e.bundleId,name:e.name}))}async function Z(e,t){let n=q(t??{}),r=(await h(e,[`listapps`,e.id],{allowFailure:!0,...n()})).stdout.trim();if(!r.startsWith(`{`))return[];let i=ne(r)??await re(r,n());return i?Object.entries(i).map(([e,t])=>{let n=ie(t);return{bundleId:e,name:t.CFBundleDisplayName??t.CFBundleName??e,...n?{path:n}:{},...t.ApplicationType?{applicationType:t.ApplicationType}:{}}}):[]}function ne(e){try{return JSON.parse(e)}catch{return null}}async function re(e,n){try{let t=await d(`plutil`,[`-convert`,`json`,`-o`,`-`,`-`],{allowFailure:!0,stdin:e,...n});return t.exitCode!==0||!t.stdout.trim().startsWith(`{`)?null:JSON.parse(t.stdout)}catch(e){if(s(e)||t(e))throw e;return null}}function ie(e){if(e.Path)return e.Path;if(e.Bundle)try{return te(e.Bundle)}catch{return}}const Q=c({ttlMs:18e5,scheduleExpiry:!0});async function ae(e,t){let n;try{n=`${e}:${(await ee(e)).mtimeMs}`}catch{n=void 0}if(n===void 0)return await $(e,t)??new Set;let r=Q.get(n);if(r)return r;let i=await $(e,t);return i&&Q.set(n,i),i??new Set}async function $(e,t){let n=await d(`plutil`,[`-convert`,`json`,`-o`,`-`,e],{allowFailure:!0,...t});if(n.exitCode===0)try{let e=JSON.parse(n.stdout),t=new Set;for(let n of e.CFBundleURLTypes??[])if(Array.isArray(n.CFBundleURLSchemes))for(let e of n.CFBundleURLSchemes)typeof e==`string`&&e.trim()&&t.add(e.trim().toLowerCase());return t}catch{return}}export{z as a,N as c,D as d,A as f,R as i,E as l,W as n,V as o,O as p,B as r,K as s,P as t,T as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{O as t,T as n,d as r,m as i}from"./sdk-device.js";import{E as a}from"./host.js";const o=3e4,s={iOS:{sdkName:{simulator:`iphonesimulator`,device:`iphoneos`},derivedBaseName:{simulator:`ios-simulator`,device:`ios-device`},xctestrunHints:{simulator:{preferred:[`iphonesimulator`],disallowed:[`iphoneos`,`appletvos`,`appletvsimulator`,`macos`]},device:{preferred:[`iphoneos`],disallowed:[`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]}}},tvOS:{sdkName:{simulator:`appletvsimulator`,device:`appletvos`},derivedBaseName:{simulator:`tvos-simulator`,device:`tvos-device`},xctestrunHints:{simulator:{preferred:[`appletvsimulator`],disallowed:[`appletvos`,`iphoneos`,`iphonesimulator`,`macos`]},device:{preferred:[`appletvos`],disallowed:[`appletvsimulator`,`iphoneos`,`iphonesimulator`,`macos`]}}},macOS:{sdkName:{simulator:`macosx`,device:`macosx`},derivedBaseName:{simulator:`macos`,device:`macos`},xctestrunHints:{simulator:{preferred:[`macos`],disallowed:[`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`]},device:{preferred:[`macos`],disallowed:[`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`]}}},visionOS:{sdkName:{simulator:`xrsimulator`,device:`xros`},derivedBaseName:{simulator:`visionos-simulator`,device:`visionos-device`},xctestrunHints:{simulator:{preferred:[`xrsimulator`],disallowed:[`xros`,`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]},device:{preferred:[`xros`],disallowed:[`xrsimulator`,`iphoneos`,`iphonesimulator`,`appletvos`,`appletvsimulator`,`macos`]}}}},c=[`ios`,`macos`,`tvos`,`visionos`];function l(e){return c.includes(e)}const u={ios:`mobile`,macos:`desktop`,tvos:`tv`,visionos:`mobile`},d={ios:`ios`,macos:`macos`,tvos:`tvos`,visionos:`visionos`};function f(e,t){return{platform:`apple`,id:`runner-script-${e}`,name:`Apple runner build script (${e})`,kind:e===`macos`?`device`:p(t),target:u[e],appleOs:d[e]}}function p(t){let n=m(t);if(n===void 0)throw new e(`INVALID_ARGS`,`The Apple runner build destination must name its platform`,{destination:t,hint:`Pass a destination with a platform= token, e.g. generic/platform=iOS Simulator for a simulator or generic/platform=iOS for a physical device.`});return n.toLowerCase().endsWith(`simulator`)?`simulator`:`device`}function m(e){for(let t of e.split(`,`)){let e=t.indexOf(`=`);if(!(e<0)&&t.slice(0,e).trim().toLowerCase().replace(/^generic\//,``)===`platform`)return t.slice(e+1).trim()||void 0}}function h(t){if(!r(t.platform))throw new e(`UNSUPPORTED_PLATFORM`,`Unsupported platform for Apple runner: ${t.platform}`);return i(t)?`macOS`:n(t.target,t.appleOs)}function g(e){if(!r(e.platform))return{handoff:!1,reason:`non_apple_target`};if(e.kind===`simulator`)return{handoff:!0,lane:`simulator`};if(i(e))return{handoff:!1,reason:`macos_host`};let n=t(e);return n!==`ios`&&n!==`ipados`?{handoff:!1,reason:`physical_non_ios_os`}:e.iosPhysicalDeviceBackend===`xctest`?{handoff:!1,reason:`xctest_backend`}:{handoff:!0,lane:`physical_coredevice`}}function _(e,t){return s[e].sdkName[C(t)]}function v(e){return s[h(e)].derivedBaseName[C(e.kind)]}function y(e){return s[h(e)].xctestrunHints[C(e.kind)]}function b(e){let t=h(e);return t===`macOS`?`platform=macOS,arch=${w()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`platform=${t},id=${e.id}`}function x(e){let t=h(e);return t===`macOS`?`platform=macOS,arch=${w()}`:e.kind===`simulator`?`platform=${t} Simulator,id=${e.id}`:`generic/platform=${t}`}function S(e){let t=h(e);return t===`macOS`?`platform=macOS,arch=${w()}`:e.kind===`simulator`?`generic/platform=${t} Simulator`:`generic/platform=${t}`}function C(e){return e===`simulator`?`simulator`:`device`}function w(){return a()===`arm64`?`arm64`:`x86_64`}export{v as a,h as c,y as d,S as i,f as l,l as n,b as o,x as r,g as s,o as t,_ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{i as t}from"./sdk-batch-runner.js";import{p as n}from"./sdk-device.js";import{n as r,t as i}from"./launch-console.js";function a(e,t,n){return{requestId:e.requestId,signal:n,appBundleId:t,verbose:e.verbose,logPath:e.logPath,traceLogPath:e.traceLogPath,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext}}function o(t){let{device:n,signal:r,ownership:i}=t;return Object.freeze({device:n,signal:r,resolveInteractor:async(o,s)=>{let c=a(o,s,r);if(i===`local`)return await t.resolveLocalInteractor(n,c);let l=i.resolveInteractor(c);if(l)return l;throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned application lifecycle operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:n.id})}})}function s(e){return o({device:e.device,signal:e.signal,resolveLocalInteractor:e.resolveInteractor,ownership:`local`})}function c(e){return o({device:e.device,signal:e.signal,ownership:{kind:`provider`,resolveInteractor:e.resolveInteractor}})}async function l(e){let{device:t,positionals:n,execution:r}=e;u(n);let i=n[0],a=n[1];if(!i){await d(e);return}if(f(t,r),a!==void 0){await p(e,i,a);return}await m(e,i)}function u(t){if(t.length>2)throw new e(`INVALID_ARGS`,`open accepts at most two arguments: <app|url> [url]`)}async function d(t){if(t.execution.launchConsole)throw new e(`INVALID_ARGS`,`--launch-console requires an app target`);if(t.execution.launchArgs&&t.execution.launchArgs.length>0)throw new e(`INVALID_ARGS`,`--launch-args requires an app target`);await t.interactor.openDevice()}function f(t,i){if(i.launchConsole&&(!n(t)||t.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,r);if(t.platform===`linux`&&i.launchArgs&&i.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on Linux.`)}async function p(n,r,a){if(t(r))throw new e(`INVALID_ARGS`,`open <app> <url> requires an app target as the first argument`);if(!t(a))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(n.execution.launchConsole)throw new e(`INVALID_ARGS`,i);await n.interactor.open(r,{activity:n.execution.activity,appBundleId:n.appBundleId,launchArgs:n.execution.launchArgs?[...n.execution.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp,url:a})}async function m(n,r){let{execution:a,interactor:o}=n;if(a.launchConsole&&t(r))throw new e(`INVALID_ARGS`,i);if(a.clearAppState){if(t(r))throw new e(`INVALID_ARGS`,`Clearing app state requires an app target, not a deep link.`);await o.setSetting(`clear-app-state`,`clear`,r)}await o.open(r,{activity:a.activity,appBundleId:n.appBundleId,launchConsole:a.launchConsole,launchArgs:a.launchArgs?[...a.launchArgs]:void 0,terminateRunningApp:n.terminateRunningApp})}function h(t){let{binding:n}=t,r=async()=>{throw new e(`UNSUPPORTED_OPERATION`,`This lifecycle operation is unavailable for ${t.owner}.`)};return Object.freeze({resolveOpenTarget:async e=>v(t.openTargetIdentity,e),prepareApplicationOpen:async()=>void 0,openApplication:async e=>await g(t,e),applyRuntimeHints:r,clearRuntimeHints:r,closeApplication:async e=>{await y({device:n.device,interactor:await n.resolveInteractor(e.execution,e.appBundleId),positionals:e.positionals})},finalizeApplicationClose:async()=>({}),prepareAppleRunner:r,configureProviderPortReverse:t.configureProviderPortReverse??r})}async function g(e,t){let{binding:n}=e,r=await n.resolveInteractor(t.execution,t.appBundleId);e.closeBeforeRelaunch&&t.relaunch&&t.target!==void 0&&await y({device:n.device,interactor:r,positionals:[t.appBundleId??t.target]}),await l({device:n.device,interactor:r,positionals:t.positionals,appBundleId:t.appBundleId,execution:t.execution});let i=_(t);return i&&await l({device:n.device,interactor:r,positionals:[i],appBundleId:t.appBundleId,execution:{...t.execution,clearAppState:void 0,launchConsole:void 0,launchArgs:void 0}}),{appBundleId:t.appBundleId,timing:{}}}function _(e){let n=e.runtimeLaunchUrl?.trim(),r=e.positionals.length===1?e.positionals[0]?.trim():void 0;if(!(!n||!r||t(r)))return n}function v(e,n){let r=n.target;if(e===`app-name`)return Object.freeze(r===void 0?{}:{appName:r});let i=r?.trim(),a=i&&i.includes(`.`)&&!t(i)?i:n.currentAppBundleId;return Object.freeze({...a===void 0?{}:{appBundleId:a},...r===void 0?{}:{appName:r}})}async function y(e){let{device:t,interactor:n,positionals:r}=e,i=r[0];if(!i){t.platform===`web`&&await n.close(``);return}await n.close(i)}export{y as a,_ as i,s as n,l as o,c as r,h as t};
|