agent-device 0.21.37 → 0.21.38
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.37.apk → agent-device-android-ime-helper-0.21.38.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.38.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.37.manifest.json → agent-device-android-ime-helper-0.21.38.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.apk → agent-device-android-snapshot-helper-0.21.38.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.38.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.manifest.json → agent-device-android-snapshot-helper-0.21.38.manifest.json} +7 -7
- package/apple/fold-helper/Fold.m +8 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerKeyboardReturnKey.swift +53 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +42 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +26 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +42 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +123 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +570 -53
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +41 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +17 -1
- package/dist/src/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/absence-observation.js +1 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +1 -1
- package/dist/src/adb-failure.js +2 -2
- 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/ai-sdk.d.ts +1 -1
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-contract.js +1 -1
- package/dist/src/alert-tree-driver.js +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/android2.js +1 -1
- package/dist/src/app-backend.js +1 -1
- 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 +1 -1
- package/dist/src/app-lifecycle.js +4 -4
- package/dist/src/app-lifecycle2.js +2 -2
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-runtime2.js +2 -2
- package/dist/src/app-log-session-resource.js +1 -1
- package/dist/src/app-resolution.js +1 -1
- package/dist/src/app-state-read.js +1 -1
- package/dist/src/app-state-runtime.d.ts +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/args.js +1 -1
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/artifact-tracking.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/automation-helper-artifact.js +1 -1
- package/dist/src/automation-helper.js +1 -1
- package/dist/src/await-with-signal.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/boot-diagnostics.js +1 -1
- package/dist/src/bridge-source.js +1 -1
- package/dist/src/browser-launch.js +1 -1
- package/dist/src/browserstack-device-features.js +1 -1
- package/dist/src/browserstack.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/capture-disclosure.js +1 -1
- package/dist/src/capture-lifecycle.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +19 -16
- package/dist/src/cli-output.js +11 -11
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +2 -2
- 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 +1 -1
- package/dist/src/client-port.d.ts +246 -208
- package/dist/src/clipboard-shell-response.js +1 -1
- package/dist/src/cloud-artifacts.d.ts +7 -2
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/command-schema.js +6 -4
- package/dist/src/command-tools.js +3 -3
- package/dist/src/command.js +1 -1
- package/dist/src/composed-inventory-gateways.js +1 -1
- package/dist/src/composite-resource-admission.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/connection-lease-transaction.js +1 -1
- package/dist/src/connection-metro-runtime.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection-verification.js +1 -1
- package/dist/src/connection.js +3 -3
- package/dist/src/context.js +1 -1
- package/dist/src/contract.d.ts +2 -1
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-attach.js +1 -1
- package/dist/src/daemon-client-dispatch-disclosure.js +1 -1
- package/dist/src/daemon-client-ensure.js +1 -1
- package/dist/src/daemon-client-ensuring.js +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-liveness-probe.js +1 -1
- package/dist/src/daemon-client-remote-health-cache.js +1 -0
- package/dist/src/daemon-client-remote-health-recovery.js +1 -0
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-command-registry.js +1 -1
- package/dist/src/daemon-composition.js +1 -1
- package/dist/src/daemon-diagnostics-scope.js +1 -1
- package/dist/src/daemon-http.js +1 -1
- package/dist/src/daemon-launch-spec.js +1 -1
- package/dist/src/daemon-lifecycle-errors.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +3 -3
- package/dist/src/daemon-registration.js +1 -1
- package/dist/src/daemon-resolution.js +1 -1
- package/dist/src/daemon-startup-diagnostics.js +1 -1
- package/dist/src/daemon-stop.js +1 -1
- package/dist/src/daemon.js +1 -1
- package/dist/src/debug-symbols-facade.js +3 -3
- package/dist/src/device-claim-admission.js +1 -0
- package/dist/src/device-claim-reconciliation.js +1 -0
- package/dist/src/device-claim-recovery.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-claims.js +1 -1
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-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/device3.js +3 -3
- package/dist/src/devicectl.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/discovery.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -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 -1
- package/dist/src/durable-capture.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/ended-lease.js +1 -1
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.js +2 -2
- package/dist/src/errors.js +1 -1
- package/dist/src/explicit-session-resolution.js +1 -1
- package/dist/src/expo-dev-client-launch.js +1 -1
- package/dist/src/failure-output.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/flag-registry.js +1 -1
- package/dist/src/focus-runtime.js +1 -1
- package/dist/src/fold-helper.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-types.d.ts +1 -1
- package/dist/src/gesture-plan.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper-artifacts.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/host2.js +1 -1
- package/dist/src/host3.js +1 -1
- package/dist/src/host4.js +1 -1
- package/dist/src/host5.js +1 -1
- package/dist/src/host6.js +1 -1
- package/dist/src/human-control-contract.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/ime-rebind.js +1 -1
- package/dist/src/ime-settings-record.js +1 -1
- package/dist/src/ime-state.js +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-artifact-facade.js +1 -1
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-error.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.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/interactor3.js +1 -1
- package/dist/src/interactor4.js +1 -1
- package/dist/src/interactor5.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/companion-tunnel.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-child.js +1 -1
- package/dist/src/inventory.js +1 -1
- 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-node-interpretation.js +1 -1
- package/dist/src/ios-simulator-accessibility.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/launch-services-registration.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-registry-scope.js +1 -1
- package/dist/src/lease-release2.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/leased-recording-retention.js +1 -1
- package/dist/src/legacy.js +1 -1
- package/dist/src/limrun-download-file.js +1 -1
- package/dist/src/limrun-ios-files.js +1 -1
- package/dist/src/limrun-ios-runner.js +2 -2
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/local-simulator-apps.js +1 -1
- package/dist/src/local-simulator-files.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/mechanics.js +12 -12
- package/dist/src/merge-flags.js +1 -1
- package/dist/src/metro-reload-endpoints.js +1 -1
- package/dist/src/metro-session-hints.js +1 -1
- package/dist/src/metro.d.ts +1 -1
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/network-traffic.js +1 -1
- package/dist/src/node-http.js +1 -1
- package/dist/src/node-touch-point.js +1 -1
- package/dist/src/observation.js +1 -1
- package/dist/src/open-script.js +1 -1
- package/dist/src/open-target-device-resolution.js +1 -1
- package/dist/src/orientation.js +1 -1
- package/dist/src/parameterized-recorded-fill.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 +2 -2
- package/dist/src/perf.js +1 -1
- package/dist/src/physical-device-control.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-apple-application-tools.js +1 -1
- package/dist/src/platform-runtime-claim-recovery.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +3 -3
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime-shutdown-error.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/plist.js +1 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/png-crop-bytes.js +1 -1
- package/dist/src/png-resize.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/post-gesture-stability.js +1 -1
- package/dist/src/process-executable-path.js +1 -0
- package/dist/src/process-exit.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +2 -2
- package/dist/src/provider-limrun-credentials.js +1 -1
- package/dist/src/provider-plugin.d.ts +1 -1
- package/dist/src/provider-profile-fields.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/provider.js +1 -1
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-devtools-connection.js +1 -1
- package/dist/src/react-devtools-inspect-command.js +1 -1
- package/dist/src/react-native-overlay2.js +2 -2
- package/dist/src/react-native.js +1 -1
- package/dist/src/react-profile-command.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-gestures.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 +1 -1
- package/dist/src/remote-config-core.js +1 -1
- package/dist/src/remote-config-flags.js +1 -1
- package/dist/src/remote-connection-state.js +1 -1
- package/dist/src/replay-backend-host.js +1 -1
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay-maestro-backend.js +2 -2
- package/dist/src/replay.d.ts +1 -1
- package/dist/src/replay2.js +1 -1
- package/dist/src/reporting.js +1 -1
- package/dist/src/request-dispatch-disclosure.js +1 -1
- package/dist/src/request-ended-leases.js +1 -1
- package/dist/src/request-providers.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/request.js +1 -1
- package/dist/src/result-serialization.js +2 -2
- package/dist/src/retry.js +1 -1
- package/dist/src/run-script-execution.js +6 -8
- package/dist/src/run-script-http.js +1 -1
- package/dist/src/runner-cache-metadata.js +1 -1
- package/dist/src/runner-cache-retention.js +1 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-contract.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-device-set.js +1 -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-io.js +1 -1
- package/dist/src/runner-launched-session.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runner-lifecycle.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-panel.js +1 -1
- package/dist/src/runner-retention.js +1 -1
- package/dist/src/runner-runtime.js +1 -1
- package/dist/src/runner-selector-query.js +1 -1
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-startup-transport.js +1 -1
- package/dist/src/runner-toolchain-identity.js +1 -1
- package/dist/src/runtime-admission.js +1 -1
- package/dist/src/runtime-deployment.js +1 -1
- package/dist/src/runtime-factory.js +1 -1
- package/dist/src/runtime-session.js +1 -1
- package/dist/src/runtime-transport-hints.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime10.js +1 -1
- package/dist/src/runtime11.js +1 -1
- package/dist/src/runtime12.js +1 -1
- package/dist/src/runtime13.js +2 -2
- package/dist/src/runtime2.js +2 -2
- package/dist/src/runtime4.js +3 -3
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +2 -2
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -0
- 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-stop-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-size.js +1 -1
- package/dist/src/screenshot-image.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot-runtime2.js +1 -1
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot2.js +1 -1
- package/dist/src/screenshot4.js +1 -1
- package/dist/src/script-source.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.d.ts +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 +26 -2
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.js +5 -5
- package/dist/src/sdk-remote-config.d.ts +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +9 -6
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server-shutdown.js +1 -1
- package/dist/src/server-startup.js +2 -2
- package/dist/src/server.js +4 -4
- package/dist/src/session-allocation.js +1 -1
- package/dist/src/session-artifact-paths.js +1 -1
- package/dist/src/session-capture-binding.js +1 -1
- package/dist/src/session-device-resolution.js +1 -1
- package/dist/src/session-event-action.js +1 -1
- package/dist/src/session-open.js +1 -1
- package/dist/src/session-repair-tombstone.js +1 -1
- package/dist/src/session-replay-vars.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-runtime.js +1 -1
- package/dist/src/session-script-destination.js +1 -0
- package/dist/src/session-selector.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session-teardown.js +1 -1
- package/dist/src/session-tenant-scope.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/settings-bluetooth.js +1 -1
- package/dist/src/settings-global-toggle.js +1 -1
- package/dist/src/settings.js +1 -1
- package/dist/src/settings2.js +1 -1
- package/dist/src/settle-observation-capture.js +1 -1
- package/dist/src/simctl-execution.js +1 -1
- package/dist/src/simctl-facade.js +1 -1
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-app-budget.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-facade.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-baseline.js +1 -1
- package/dist/src/snapshot-chrome.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-diagnostics.js +1 -1
- package/dist/src/snapshot-helper-install.js +3 -3
- package/dist/src/snapshot-helper-session.js +1 -1
- package/dist/src/snapshot-lines.js +1 -1
- package/dist/src/snapshot-node-lookup.js +1 -1
- package/dist/src/snapshot-occlusion.js +1 -1
- package/dist/src/snapshot-private-evidence.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime-capture-input.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +2 -2
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/source-channel.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src10.js +1 -1
- package/dist/src/src11.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +5 -5
- package/dist/src/src4.js +2 -2
- package/dist/src/src5.js +1 -1
- package/dist/src/src6.js +1 -1
- package/dist/src/src8.js +1 -1
- package/dist/src/store-legacy.js +1 -1
- package/dist/src/store.js +1 -1
- package/dist/src/string-enum.js +1 -1
- package/dist/src/surface-snapshot.js +1 -1
- package/dist/src/surface-snapshot2.js +1 -1
- package/dist/src/sync-cache.js +1 -1
- package/dist/src/system-surface-foreground.js +2 -2
- package/dist/src/takeover.js +1 -1
- package/dist/src/tap-keyboard-occlusion.js +1 -1
- package/dist/src/target-evidence-tree.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/telephony-runtime.js +1 -1
- package/dist/src/tool-provider-facade.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 +1 -1
- 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/tree.js +1 -1
- package/dist/src/tv-remote-runtime.js +1 -1
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/unsupported-interactor.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/validation.js +1 -1
- package/dist/src/vars.js +1 -1
- package/dist/src/vega-executable.js +1 -1
- package/dist/src/verified-file.js +1 -1
- package/dist/src/video.js +2 -2
- package/dist/src/viewport.js +1 -1
- package/dist/src/web.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.37.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.37.apk.sha256 +0 -1
- package/dist/src/capture-output-ownership.js +0 -1
package/dist/src/merge-flags.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_t as e,yt as t}from"./sdk-io.js";import{i as n}from"./catalog.js";import{E as r}from"./src3.js";import{n as i}from"./flag-registry.js";import{n as a}from"./command-schema.js";const o=new Set([`config`,`remoteConfig`,`help`,`version`,`batchSteps`,`githubActionsArtifact`,`textStdin`]),s=new Set([`appsFilter`,`iosSimulatorDeviceSet`,`textStdin`,`osVersion`,`imageTag`,`deviceMode`,`deviceBaseline`,`physical`]),c=m(),l=new Map(c.map(e=>[e.key,e]));function u(e){return l.get(e)}function d(e){return c.filter(t=>t.configurable&&t.supportsCommand(e))}function f(e,t){return u(e)?.supportsCommand(t)??!1}function p(e,n,r,i){return t(_(e),n,r,i)}function m(){let t=new Map;for(let e of i()){let n=t.get(e.key);n?n.push(e):t.set(e.key,[e])}let c=new Map;for(let e of r)c.set(e,new Set([`*`]));for(let e of n()){let t=a(e);for(let n of[...t.allowedFlags??[],...t.supportedFlags??[]]){let t=c.get(n);t&&t.has(`*`)||(t?t.add(e):c.set(n,new Set([e])))}}return[...t.entries()].map(([t,n])=>({key:t,flagDefinitions:n,configurable:!o.has(t),env:{names:s.has(t)?[]:[e(t)]},supportsCommand(e){let n=c.get(t);return n?n.has(`*`)?!0:e?n.has(e):!1:!1}})).sort((e,t)=>h(e.key,t.key))}function h(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?e<t?-1:+(e>t):n<r?-1:1}function g(e){let t=e.flagDefinitions[0];if(!t)throw Error(`Missing flag definition for option ${e.key}`);return t}function _(e){let t=e.flagDefinitions.find(e=>e.setValue===void 0);if(t)return t;let n=g(e);if(n.type===`enum`){let t=n.enumValues??e.flagDefinitions.map(e=>e.setValue).filter(e=>e!==void 0);return{...n,setValue:void 0,enumValues:t}}return n}function v(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}export{p as a,f as i,d as n,u as r,v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{r as t,t as n}from"./runtime-transport-hints.js";const r=8081,i=`.expo/.virtual-metro-entry.bundle`;function a(t,n){if(t==null||t===``)return n;let r=/^\d+$/.test(String(t).trim())?Number(String(t).trim()):NaN;if(!Number.isInteger(r)||r<1||r>65535)throw new e(`INVALID_ARGS`,`Invalid Metro port: ${String(t)}. Use 1-65535.`);return r}function o(i){let o=t(i.bundleUrl),s=o??i.runtime?.bundleUrl,c=n({bundleUrl:s,metroHost:t(i.metroHost)??(o?void 0:t(i.runtime?.metroHost))??(s?void 0:`localhost`),metroPort:i.metroPort===void 0?o?void 0:i.runtime?.metroPort??(s?void 0:r):a(i.metroPort,r)});if(!c)throw new e(`INVALID_ARGS`,`Unable to resolve Metro host and port for reload.`);return c}function s(e){let t=o(e),n=t.pathname.replace(/\/+$/,``),r=new URL(t);r.pathname=`${n}/reload`;let i=new URL(t);return i.protocol=t.protocol===`https:`?`wss:`:`ws:`,i.pathname=`${n}/message`,{reloadUrl:r.toString(),messageSocketUrl:i.toString()}}export{o as i,a as n,s as r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{h as t}from"./daemon-resolution.js";import{r as n}from"./session-paths.js";import{i as r}from"./metro-reload-endpoints.js";import i from"node:fs";import a from"node:path";var o=e({clearMetroSessionHints:()=>d,clearMetroSessionHintsQuietly:()=>v,readMetroSessionHints:()=>u,readMetroSessionRuntime:()=>m,recordOpenedMetroSession:()=>_,recordPreparedMetroSession:()=>g,resolveSessionMetroServerUrl:()=>f,writeMetroSessionHints:()=>l});function s(e){let{host:n}=e;return{stateDir:t(e.stateDir??n.env.AGENT_DEVICE_STATE_DIR,{env:n.env,cwd:n.cwd}).baseDir,session:e.session}}function c(e,t){return a.join(e,`metro-sessions`,`${n(t)}.json`)}function l(e){let t=c(e.stateDir,e.session);i.mkdirSync(a.dirname(t),{recursive:!0}),i.writeFileSync(t,`${JSON.stringify(e.hints,null,2)}\n`,`utf8`)}function u(e){let t=c(e.stateDir,e.session),n;try{n=i.readFileSync(t,`utf8`)}catch{return}let a;try{a=JSON.parse(n)}catch{return}if(!a||typeof a!=`object`||Array.isArray(a))return;let o=a;try{let e={metroHost:typeof o.metroHost==`string`?o.metroHost:void 0,metroPort:typeof o.metroPort==`number`?o.metroPort:void 0,bundleUrl:typeof o.bundleUrl==`string`?o.bundleUrl:void 0};if(typeof o.controlBaseUrl!=`string`&&Object.values(e).every(e=>e===void 0))return;let t=typeof o.controlBaseUrl==`string`?new URL(o.controlBaseUrl):r({runtime:e});return t.protocol===`http:`||t.protocol===`https:`?{controlBaseUrl:t.toString(),...Array.isArray(o.deviceBaseUrls)?{deviceBaseUrls:o.deviceBaseUrls.filter(e=>typeof e==`string`)}:{}}:void 0}catch{return}}function d(e){i.rmSync(c(e.stateDir,e.session),{force:!0})}function f(e,t={}){let n=t.bundleUrl!==void 0||t.metroHost!==void 0&&t.metroPort!==void 0;return r({...t,runtime:(n?void 0:p(e))??t.runtime})}function p(e){try{let t=u(e);return t?{bundleUrl:t.controlBaseUrl}:void 0}catch{return}}function m(e){let t;try{t=s(e)}catch{return}return p(t)}function h(e){let{metroHost:t,metroPort:n,bundleUrl:i}=e??{};return t===void 0&&n===void 0&&i===void 0?void 0:r({runtime:e}).toString()}function g(e,t){try{let n=s(e),r=new Set;for(let e of[t.iosRuntime,t.androidRuntime])try{let t=h(e);t&&r.add(t)}catch{}l({...n,hints:{controlBaseUrl:new URL(`.`,t.statusUrl).toString(),deviceBaseUrls:[...r]}})}catch{}}function _(e,t){try{let n=s(e),r=h(t.runtime);if(r){let e=t.explicitRuntime?void 0:u(n);if(e&&(t.sessionReused||e.deviceBaseUrls?.includes(r)))return;l({...n,hints:{controlBaseUrl:r}})}else t.sessionReused||d(n)}catch{}}function v(e){try{d(s(e))}catch{}}export{f as n,o as t};
|
package/dist/src/metro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { O as HostEnvironment, y as SessionRuntimeHints } from "./sdk-contracts.js";
|
|
2
2
|
import { f as PrepareMetroRuntimeResult, m as MetroBridgeScope, p as ReloadMetroResult, s as MetroPrepareKind } from "./sdk-remote-config.js";
|
|
3
3
|
//#region packages/react-native/src/metro/metro-types.d.ts
|
|
4
4
|
/** Re-export of {@link SessionRuntimeHints} under the Metro-specific alias used by public API consumers. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ei as e,gi as t,ni as n,si as r,ti as i}from"./sdk-batch.js";import{t as a}from"./scroll-indicator.js";function o(e){if(e.length===0)return{nodes:e,hiddenCount:0,summaryLines:[]};let{visibility:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}=c(e),a=n.size===0?e:e.filter(e=>n.has(e.index));return{nodes:a.map(e=>m(e,i.directionsByContainer)),hiddenCount:n.size===0?0:e.length-a.length,summaryLines:h(r.filter(e=>!i.coveredNodeIndexes.has(e.index)&&v(e)),t)}}function s(e){if(e.length===0)return new Map;let{hintedContainers:t}=c(e);return p(t.directionsByContainer)}function c(t){let n=e(t),r=n.nodeByIndex,i=new Set,a=[];for(let e of t){if(n.isVisibleInEffectiveViewport(e)){b(e,i,r);continue}a.push(e)}return{visibility:n,visibleNodeIndexes:i,offscreenNodes:a,hintedContainers:f(t,a,i,r)}}function l(e,t){return e.hittable&&n(e.rect,t)}function u(e,r){if(!e.rect)return null;let i=r.resolveEffectiveViewport(e);if(i&&!t(e.rect,i)){let t=d(e.rect,i);if(t)return t}let a=r.resolveViewport(e.rect);if(a&&!n(e.rect,a)){let t=d(e.rect,a);if(t)return t}return null}function d(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=[{direction:`down`,amount:r-(t.y+t.height)},{direction:`up`,amount:t.y-r},{direction:`right`,amount:n-(t.x+t.width)},{direction:`left`,amount:t.x-n}],a=null;for(let e of i)e.amount>0&&(!a||e.amount>a.amount)&&(a=e);return a?.direction??null}function f(e,t,n,r){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=x(e,n,r);if(!t?.rect)continue;let s=_(e.rect,t.rect);if(!s)continue;let c=i.get(t.index)??new Set;c.add(s),i.set(t.index,c);let l=a.get(t.index)??new Set;l.add(s),a.set(t.index,l),o.add(e.index)}return S(e,n,r,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}function p(e){let t=new Map;for(let[n,r]of e){let e={};r.has(`above`)&&(e.hiddenContentAbove=!0),r.has(`below`)&&(e.hiddenContentBelow=!0),(e.hiddenContentAbove||e.hiddenContentBelow)&&t.set(n,e)}return t}function m(e,t){let n=t.get(e.index);if(!n||n.size===0)return e;let r=e.hiddenContentAbove===!0||n.has(`above`)?!0:void 0,i=e.hiddenContentBelow===!0||n.has(`below`)?!0:void 0;return{...e,hiddenContentAbove:r,hiddenContentBelow:i}}function h(e,t){let n=new Map;for(let r of e){let e=g(r,t);if(!e)continue;let i=n.get(e)??[];i.push(r),n.set(e,i)}return[`above`,`below`].flatMap(e=>{let t=n.get(e);if(!t||t.length===0)return[];let r=y(t).slice(0,3).map(e=>`"${e}"`),i=t.length===1?`interactive item`:`interactive items`,a=r.length>0?`: ${r.join(`, `)}`:``;return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}function g(e,t){if(!e.rect)return null;let n=t.resolveEffectiveViewport(e);return n?_(e.rect,n):null}function _(e,t){return e.y+e.height<=t.y?`above`:e.y>=t.y+t.height?`below`:null}function v(e){if(e.hittable===!0)return!0;let t=(e.type??``).toLowerCase();return t.includes(`button`)||t.includes(`link`)||t.includes(`textfield`)||t.includes(`edittext`)||t.includes(`searchfield`)||t.includes(`checkbox`)||t.includes(`radio`)||t.includes(`switch`)||t.includes(`menuitem`)||!!r(e)}function y(e){let t=new Set,n=[];for(let i of e){let e=r(i);!e||t.has(e)||(t.add(e),n.push(e))}return n}function b(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),t.add(r.index),r=typeof r.parentIndex==`number`?n.get(r.parentIndex):void 0}function x(e,t,n){return i(e,n,e=>t.has(e.index))}function S(e,t,n,r,i){for(let a of e){let e=C(a);if(!e||e.size===0)continue;let o=x(a,t,n);if(!o)continue;let s=r.get(o.index)??new Set,c=i.get(o.index);for(let t of e)c&&c.size>0&&!c.has(t)||s.add(t);r.set(o.index,s)}}function C(e){let t=a(e.label,e.value);if(!t)return null;let n=new Set;return t.above&&n.add(`above`),t.below&&n.add(`below`),n.size>0?n:null}export{l as i,u as n,s as r,o as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{n as t,t as n}from"./durable-resource.js";import{n as r}from"./async-lifecycle.js";function i(e,t){if(e.resourceKind!==t.resourceKind)return{status:`unreattachable`,reason:`descriptor-invalid`,message:`Durable resource kind ${e.resourceKind} does not match ${t.resourceKind}`};if(e.descriptor.version!==t.version)return{status:`unreattachable`,reason:`descriptor-version-unsupported`,message:`Unsupported ${t.resourceKind} descriptor version: ${e.descriptor.version}`,version:e.descriptor.version};try{let n=t.decode(e.descriptor.body);return n.status===`decoded`?n:{status:`unreattachable`,reason:`descriptor-invalid`,message:n.message}}catch(e){return{status:`unreattachable`,reason:`descriptor-invalid`,message:e instanceof Error?e.message:`Descriptor codec rejected the body`}}}function a(e,t){return Object.freeze({pendingHandle:new r(e),envelope:t})}function o(e){return Object.freeze({appLogReattach:async({envelope:t})=>{let n=i(t,e.codec);return n.status===`unreattachable`?n:await e.reattach(n.descriptor,s(t))},appLogCleanup:async({envelope:t})=>{let n=i(t,e.codec);return n.status===`decoded`?await e.cleanup(n.descriptor,s(t)):{status:`cleanup-pending`,reason:`manual-recovery-required`,message:n.message}}})}function s(e){return Object.freeze({sessionId:e.sessionId,fence:e.fence})}function c(e){if(typeof e!=`object`||!e||Array.isArray(e))return{status:`invalid`,message:`App-log process marker must be an object`};let t=e;return!Number.isInteger(t.pid)||Number(t.pid)<=0?{status:`invalid`,message:`App-log process marker pid must be a positive integer`}:typeof t.startTime!=`string`||t.startTime.trim().length===0?{status:`invalid`,message:`App-log process marker startTime must be a non-empty string`}:typeof t.command!=`string`||t.command.trim().length===0?{status:`invalid`,message:`App-log process marker command must be a non-empty string`}:{status:`decoded`,marker:Object.freeze({pid:Number(t.pid),startTime:t.startTime,command:t.command})}}function l(e){let t;return Object.freeze({inspect:()=>e.inspect(),finish:()=>t??=e.finish(),...n(()=>e.forceCleanup(),d)})}function u(e){return l({inspect:e.inspect,finish:e.finish,forceCleanup:async()=>{let t=await e.finish();return t.status===`completed`?{status:`cleaned`}:{status:`cleanup-pending`,reason:t.reason,message:t.message}}})}function d(n,r){if(!t(n))throw new e(`COMMAND_FAILED`,n.message??`Durable resource cleanup could not be confirmed`,{reason:n.reason,retriable:n.reason!==`ownership-fence-lost`,hint:n.reason===`ownership-fence-lost`?`Use the current resource owner or recovery record before retrying cleanup.`:`Keep the recovery record and retry cleanup through the exact runtime owner.`},r)}function f(e,t,n){let r=e.artifacts.resolveSession(t);return n.outputPath===r.outputPath&&(n.pidPath===void 0||n.pidPath===r.pidPath)}function p(t,n){if(!f(t,n.sessionId,n))throw new e(`INVALID_ARGS`,`App-log paths do not match the owning session`)}function m(e){for(let t of[/\bstatus(?:Code)?["'=: ]+([1-5]\d{2})\b/i,/\bresponse(?:\s+code)?["'=: ]+([1-5]\d{2})\b/i,/\bHTTP\/[0-9.]+\s+([1-5]\d{2})\b/i]){let n=t.exec(e);if(!n)continue;let r=Number.parseInt(n[1]??``,10);if(Number.isInteger(r))return r}return null}function h(e){return/\b\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z)?\b/.exec(e)?.[0]??/\b\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+\b/.exec(e)?.[0]}function g(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`);if(t<0||n<=t)return null;try{let r=JSON.parse(e.slice(t,n+1));return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch{return null}}function _(e,t){for(let n of t){let t=e?.[n];if(typeof t==`string`&&t.trim())return t.trim()}}function ee(e,t){for(let n of t){let t=e?.[n];if(typeof t==`number`&&Number.isInteger(t))return t;if(typeof t==`string`&&/^\d{3}$/.test(t.trim()))return Number.parseInt(t,10)}return null}function te(e,t){let n=t?.headers??t?.requestHeaders??t?.responseHeaders;return n===void 0?/\bheaders?["'=: ]+(\{.*\})/i.exec(e)?.[1]?.trim():y(n)}function v(e,t,n){for(let r of n){if(t?.[r]!==void 0)return y(t[r]);let n=r.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),i=RegExp(`\\b${n}["'=: ]+(.+)$`,`i`).exec(e);if(i?.[1])return i[1].trim()}}function y(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function b(e,t,n){let r=C(t,n,5),i=e.packetId??r.map(x).find(e=>typeof e==`string`&&e.length>0);i&&(e.packetId=i);let a=i?C(t,n,12).filter(e=>x(e)===i):r;e.timestamp??=a.map(h).find(e=>typeof e==`string`&&e.length>0),e.status??=a.map(m).find(e=>typeof e==`number`)??void 0,e.durationMs??=a.map(S).find(e=>typeof e==`number`)??void 0}function x(e){return/\bpacket id (\d+)\b/i.exec(e)?.[1]??null}function S(e){let t=/\b(?:duration|elapsed request\/response time, ms)[:= ]+(\d+)\b/i.exec(e);return t?Number.parseInt(t[1]??``,10):null}function C(e,t,n){return e.slice(Math.max(0,t-n),Math.min(e.length,t+n+1)).map(e=>e.trim()).filter(Boolean)}const w=RegExp(`\\b(${[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`HEAD`,`OPTIONS`].join(`|`)})\\b\\s+https?:\\/\\/`,`i`),T=/https?:\/\/[^\s"'<>\])]+/i,E=/\[C(\d+)\b[^\]]*?\burl:\s*([^\s,\]]+)/,D=/\bsummary for task (?:success|failure)\s*\{([^}]*)\}/,ne=/\bTask\s+<([0-9A-Fa-f-]+)>\.<(\d+)>/,O=/(?:^|\s)(\S+)\[(\d+):[0-9a-f]+\]/,re=/\burl:\s*(https?:\/\/[^\s,\]]+)/i;function k(e,t,n=e.dump.limits.maxEntries){let r=e.dump.entries.slice(0,n),i=new Set(r.map(U));for(let e of t.dump.entries){if(r.length>=n)break;let t=U(e);i.has(t)||(i.add(t),r.push(e))}let a=new Set([...e.dump.entries,...t.dump.entries].map(e=>e.packetId).filter(e=>e!==void 0)),o=[...new Set([...e.unnamedRequestIds,...t.unnamedRequestIds])].filter(e=>!a.has(e));return Object.freeze({dump:Object.freeze({...e.dump,matchedLines:r.length,entries:Object.freeze(r),unnamedRequests:o.length}),unnamedRequestIds:Object.freeze(o)})}function A(e,t){let n=G(t.maxEntries,25,1,200),r=t.include??`summary`,i=G(t.maxPayloadChars,2048,64,16384),a=G(t.maxScanLines,4e3,100,2e4),o=M(t.lineNumberOffset);if(!t.exists)return Object.freeze({dump:Object.freeze({path:t.path,exists:!1,scannedLines:0,matchedLines:0,entries:Object.freeze([]),unnamedRequests:0,include:r,limits:Object.freeze({maxEntries:n,maxPayloadChars:i,maxScanLines:a})}),unnamedRequestIds:Object.freeze([])});let s=e.split(`
|
|
2
2
|
`),c=Math.max(0,s.length-a),l=s.slice(c),u=[],d=j(t.backend)?K(l):void 0,f=d?Y(l,d):[];for(let e=l.length-1;e>=0&&u.length<n;--e){if(!l[e]?.trim())continue;let n=N(l,e,o+c+e+1,t.backend,r,i,d);n&&u.push(n)}return Object.freeze({dump:Object.freeze({path:t.path,exists:!0,scannedLines:l.length,matchedLines:u.length,entries:Object.freeze(u),unnamedRequests:f.length,include:r,limits:Object.freeze({maxEntries:n,maxPayloadChars:i,maxScanLines:a})}),unnamedRequestIds:Object.freeze(f)})}function j(e){return e===`ios-simulator`||e===`ios-device`||e===`macos`}function M(e){if(e===void 0)return 0;if(!Number.isInteger(e)||e<0)throw TypeError(`Network line number offset must be a non-negative integer`);return e}function N(e,t,n,r,i,a,o){let s=e[t]?.trim();if(!s)return null;let c=g(s),l=P(s,c)??(o?J(s,o,t):null);if(!l)return null;let u=z(s,n,l,a);return r===`android`&&b(u,e,t),B(u,s,c,i,a),u}function P(e,t){let n=F(e,t),r=I(e,t);if(!r)return null;let i=L(e,t);return R(e,n.explicit,i)?{method:n.value,url:r,status:i}:null}function F(e,t){let n=_(t,[`method`,`httpMethod`]),r=/\bmethod["'=: ]+([A-Z]+)\b/i.exec(e)?.[1],i=w.exec(e)?.[1],a=n??r??i;return{value:a?.toUpperCase(),explicit:!!a}}function I(e,t){return _(t,[`url`,`requestUrl`])||(re.exec(e)?.[1]??T.exec(e)?.[0])}function L(e,t){return ee(t,[`status`,`statusCode`,`responseCode`])??m(e)??void 0}function R(e,t,n){return t||n!==void 0||/\bURL["'=: ]+https?:\/\//i.test(e)||/\bheaders?["'=: ]+/i.test(e)||/\b(?:requestBody|responseBody|payload|request|response)["'=: ]+/i.test(e)}function z(e,t,n,r){return{...n,timestamp:h(e),packetId:n.packetId??x(e)??void 0,durationMs:n.durationMs??S(e)??void 0,raw:W(e,r),line:t}}function B(e,t,n,r,i){if(V(r)){let r=te(t,n);r&&(e.headers=W(r,i))}if(H(r)){let r=v(t,n,[`requestBody`,`body`,`payload`,`request`]),a=v(t,n,[`responseBody`,`response`]);r&&(e.requestBody=W(r,i)),a&&(e.responseBody=W(a,i))}}function V(e){return e===`headers`||e===`all`}function H(e){return e===`body`||e===`all`}function U(e){return`${e.timestamp??``}|${e.method??``}|${e.url}|${e.status??``}|${e.raw}`}function W(e,t){return e.length<=t?e:`${e.slice(0,t)}...<truncated>`}function G(e,t,n,r){return e===void 0||!Number.isInteger(e)?t:Math.max(n,Math.min(r,e))}function K(e){let t=new Map;for(let[n,r]of e.entries()){let e=E.exec(r);if(!e)continue;let i=q(r,e[1]),a=i===void 0?void 0:ae(e[2]);if(!a||i===void 0)continue;let o=t.get(i);o?o.push({lineIndex:n,origin:a}):t.set(i,[{lineIndex:n,origin:a}])}return t}function q(e,t){let n=O.exec(e);if(n)return`${n[1]}[${n[2]}]#${t}`}function J(e,t,n){let r=D.exec(e);if(!r)return null;let i=Q(r[1]);if(i.get(`reused`)!==`1`)return null;let a=i.get(`connection`),o=a===void 0?void 0:q(e,a),s=o===void 0?void 0:Z(t,o,n);return s?{url:s,status:oe(i.get(`response_status`)),durationMs:$(i.get(`transaction_duration_ms`)),pathUnavailable:!0,packetId:X(e)}:null}function Y(e,t){let n=new Set;for(let[r,i]of e.entries()){let e=ie(i,t,r);e!==void 0&&n.add(e)}return[...n]}function ie(e,t,n){if(!e.includes(`summary for task`))return;let r=D.exec(e);if(!r)return;let i=Q(r[1]);if(i.get(`reused`)!==`1`)return;let a=i.get(`connection`),o=a===void 0?void 0:q(e,a);if(!(o!==void 0&&Z(t,o,n)))return X(e)}function X(e){let t=ne.exec(e);if(!t)return;let n=O.exec(e);return`${n?`${n[1]}[${n[2]}]`:``}#${t[1]}.${t[2]}`}function Z(e,t,n){let r=e.get(t);if(!r)return;let i;for(let e of r){if(e.lineIndex>n)break;i=e.origin}return i}function Q(e){let t=new Map;for(let n of e.split(`,`)){let e=n.indexOf(`=`);e!==-1&&t.set(n.slice(0,e).trim(),n.slice(e+1).trim())}return t}function ae(e){try{return new URL(e).origin}catch{return}}function oe(e){let t=$(e);return t!==void 0&&t>0?t:void 0}function $(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}export{u as a,c,p as i,i as l,A as n,o,f as r,a as s,k as t};
|
package/dist/src/node-http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as e}from"./daemon-http.js";import{Readable as t}from"node:stream";import{pipeline as n}from"node:stream/promises";import{TLSSocket as r}from"node:tls";async function i(e,r,i){if(r.method===`TRACE`){a(i,404);return}let c=o(r);if(!c){a(i,400);return}let l=await e.handle(s(c,r,i));i.statusCode=l.status;for(let[e,t]of l.headers)i.setHeader(e,t);if(!l.body){i.end();return}await n(t.fromWeb(l.body),i)}function a(e,t){e.statusCode=t,e.end()}function o(t){return e(t.url,t.rawHeaders,t.socket instanceof r)}function s(e,n,r){let i=n.method??`GET`,a=i!==`GET`&&i!==`HEAD`;return new Request(e,{method:i,headers:c(n),signal:l(n,r),...a?{body:t.toWeb(n),duplex:`half`}:{}})}function c(e){let t=new Headers;for(let[n,r]of Object.entries(e.headers))if(r!==void 0)for(let e of Array.isArray(r)?r:[r])t.append(n,e);return t}function l(e,t){let n=new AbortController,r=()=>{t.writableFinished||n.signal.aborted||n.abort(Error(`Proxy client disconnected before the response ended`))};return e.on(`aborted`,r),t.on(`close`,r),t.closed&&r(),n.signal}export{i as serveProxyRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Vi as e,ci as t,ei as n,pi as r}from"./sdk-batch.js";import{D as i,_ as a,ft as o,ht as s}from"./sdk-contracts.js";import{t as c}from"./interaction-error.js";import{a as l,n as u,o as d,s as f}from"./rect-center.js";import{d as p}from"./selector-pipeline-policy.js";import{i as m,t as h}from"./tap-keyboard-occlusion.js";function g(e){switch(e){case`click`:case`press`:case`tap`:return`be tapped`;case`fill`:return`be filled`;case`focus`:return`be focused`;case`longPress`:return`be long-pressed`;case`hover`:return`be hovered`;case`scroll`:return`be scrolled`;case`swipe`:return`be swiped`;case`pinch`:return`be pinched`;case`pan`:return`be panned`;case`drag`:return`be dragged`;case`fling`:return`be flung`;case`rotate`:return`be rotated`;case`transform`:return`be transformed`}}function _(e){let t=e.node.rect;if(!t||!e.tapPoint)return;let r=m({nodes:e.nodes,viewport:n(e.nodes).resolveViewport(t),point:e.tapPoint,node:e.node,...e.keyboard?{keyboard:e.keyboard}:{}});if(r.kind===`occluded`)throw b({label:e.label,action:e.action,ref:e.node.ref,targetRect:t,surface:r.surface})}function v(e){let t=m({nodes:e.nodes,viewport:e.viewport,point:e.point,...e.keyboard?{keyboard:e.keyboard}:{}});if(t.kind===`occluded`)return y(e.point,t.surface)}function y(e,t){return`(${e.x}, ${e.y}) is behind the visible keyboard, so this tap lands on the keyboard rather than anything under it (${h.reason}; keyboard frame ${Math.round(t.frame.y)}..${Math.round(t.frame.y+t.frame.height)}). `+h.hint}function b(e){return i(new a(`COMMAND_FAILED`,`${e.label} is behind the visible keyboard and cannot ${g(e.action)} safely`,{...h,ref:`@${e.ref}`,rect:e.targetRect,keyboardFrame:e.surface.frame}),`no`)}function x(e,t,n={}){let i=l(t.rect);if(!i||!S(i))return{kind:`invalid`};let a=f(t),o=a?r(i,a):i;if(!o||!S(o))return{kind:`invalid`};let c=d(o);if(!Number.isFinite(c.x)||!Number.isFinite(c.y))return{kind:`invalid`};let u=C(e,t,i);if(u.length===0)return{kind:`resolved`,point:c,strategy:`center`};let p=(n.parentOwnedBounds??[]).reduce((e,t)=>e?r(e,t):void 0,o),m=p?T(i,p,c,u):null;return m?{kind:`resolved`,point:m,strategy:`parent-owned`}:{kind:`blocked`,competitorRefs:s(u),competitorCount:u.length}}function S(e){return e.width>0&&e.height>0}function C(e,t,n){let i=new Map(e.map(e=>[e.index,e]));return e.filter(e=>e.index!==t.index).filter(e=>w(e,t,i)).filter(p).flatMap(e=>{let t=l(e.rect);if(!t||u(t,n))return[];let i=r(t,n);return i?[{ref:e.ref,index:e.index,rect:i}]:[]}).sort((e,t)=>e.index-t.index)}function w(e,t,n){let r=new Set,i=e;for(;typeof i.parentIndex==`number`&&!r.has(i.index);){if(r.add(i.index),i.parentIndex===t.index)return!0;let e=n.get(i.parentIndex);if(!e)return!1;i=e}return!1}function T(e,t,n,r){let i=A(e),a=O(t.x,t.width,n.x,r.flatMap(({rect:e})=>[e.x,e.x+e.width]),i),o=O(t.y,t.height,n.y,r.flatMap(({rect:e})=>[e.y,e.y+e.height]),i);return a.flatMap(a=>o.flatMap(o=>{let s={x:Math.round(a),y:Math.round(o)};if(s.x<t.x||s.x>=t.x+t.width||s.y<t.y||s.y>=t.y+t.height)return[];let c=E(s,e,n,r,i);return c?[c]:[]})).sort(D)[0]?.point??null}function E(e,t,n,r,i){let a=k(e,t,r);return a.parentEdge<i||a.competitor<12?null:{point:e,distanceSquared:(e.x-n.x)**2+(e.y-n.y)**2,clearance:Math.min(a.parentEdge,a.competitor)}}function D(e,t){return e.distanceSquared-t.distanceSquared||t.clearance-e.clearance||e.point.y-t.point.y||e.point.x-t.point.x}function O(e,t,n,r,i){let a=e+i,o=Math.min(e+t-i,Math.ceil(e+t)-1);if(a>o)return[];let s=[...new Set([e,e+t,...r])].sort((e,t)=>e-t),c=new Set([n,a,o]);for(let e of r)c.add(e-12),c.add(e+12);for(let e=1;e<s.length;e+=1)c.add((s[e-1]+s[e])/2);return[...c].filter(e=>e>=a&&e<=o).sort((e,t)=>e-t)}function k(e,t,n){let r=Math.min(e.x-t.x,t.x+t.width-e.x,e.y-t.y,t.y+t.height-e.y),i=1/0;for(let{rect:t}of n){let n=e.x<t.x?t.x-e.x:Math.max(0,e.x-(t.x+t.width)),r=e.y<t.y?t.y-e.y:Math.max(0,e.y-(t.y+t.height));i=Math.min(i,Math.max(n,r))}return{parentEdge:r,competitor:i}}function A(e){let t=Math.min(e.width,e.height);return Math.max(0,Math.min(12,Math.floor(t/2)-1))}function j(e){let{located:t,resolved:n,nodes:r,platform:i}=e,a=M(t,n,r).find(e=>I(e)&&L(e,i));if(a)return a.enabled===!1?{kind:`disabled-field`,node:a}:{kind:`target`,node:a};let o=P(n,r,i),s=o.filter(e=>e.enabled!==!1);return s.length>1?{kind:`several-fields`,fields:s}:s[0]?{kind:`target`,node:s[0]}:o[0]?{kind:`disabled-field`,node:o[0]}:{kind:`target`,node:n}}function M(e,t,n){let r=new Map(n.map(e=>[e.index,e]));if(!w(e,t,r))return[e,t];let i=[e],a=N(e,r);for(;a&&a.index!==t.index;)i.push(a),a=N(a,r);return[...i,t]}function N(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function P(e,t,r){let i=new Map(t.map(e=>[e.index,e])),a=n([...t]),o=t.filter(t=>I(t)&&L(t,r)&&w(t,e,i)&&F(t)&&a.isVisibleOnScreen(t));return o.filter(e=>!o.some(t=>w(e,t,i)))}function F(e){let t=l(e.rect);return t!==null&&t.width>0&&t.height>0}function I(e){return e.ref!==void 0}function L(e,n){return e.editable??(e.password===!0||!!e.type?.trim()&&t(e.type??``,n))}function R(t,n){return n.filter(n=>n.parentIndex===t.parentIndex&&n.index<t.index&&F(n)&&e(n)&&!z(n)).at(-1)??null}function z(e){let t=`${e.type??``} ${e.role??``} ${e.subrole??``}`.toLowerCase();return/scroll\s?(bar|indicator)/.test(t)}function B(e,t,n){if(F(e))return{};let r=R(e,t);if(!r)return{};let i=n?`run scroll <direction> --until ${n} to bring it on screen, then retry with the same selector.`:`scroll toward it, then retry with a selector (e.g. text=/id=) rather than an @ref — the scroll expires the ref frame, so re-run snapshot -i before reusing any @ref.`;return{...r.ref?{scrollContainerRef:r.ref}:{},hint:`The target reports no frame, so nothing confirms it is on screen, and the frame names no direction. It may be scrolled out of a scrollable container: ${i}`}}function V(e,t,r){let o=n(t),s=x(t,e,{parentOwnedBounds:[o.resolveEffectiveViewport(e),e.rect?o.resolveViewport(e.rect):null].filter(e=>e!==null)});if(s.kind===`resolved`)return s.point;throw s.kind===`invalid`?i(new a(`COMMAND_FAILED`,r.invalidMessage,{reason:c.targetBoundsInvalid,...H(r.blockedTargetDetails),...B(e,t,r.shellQuotedSelector)}),`no`):i(new a(`COMMAND_FAILED`,`${r.blockedTargetLabel} has no parent-owned touch point outside its interactive descendants`,{reason:`covered_by_interactive_descendants`,...r.blockedTargetDetails,competitorRefs:s.competitorRefs.slice(0,5).map(e=>`@${e}`),competitorCount:s.competitorCount,hint:`Tap the specific interactive child you intend, or use a more specific selector. Every safely tappable region of the parent belongs to one of its child controls.`}),`no`)}function H(e){return`ref`in e?{ref:o(e.ref)??e.ref}:e}export{g as a,v as i,V as n,_ as r,j as t};
|
package/dist/src/observation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{H as t,Q as n}from"./sdk-io.js";import"./command.js";import{n as r}from"./device-shell.js";import"./retry.js";import{c as i,n as a,t as o}from"./app-parsers.js";const s=[[`dumpsys`,`window`,`windows`],[`dumpsys`,`window`]],c=[[`dumpsys`,`activity`,`activities`],[`dumpsys`,`activity`]],l=RegExp(`(?:${a.map(x).join(`|`)})(.*)$`,`gm`),u=new Set([`com.android.permissioncontroller`,`com.google.android.permissioncontroller`,`com.android.packageinstaller`,`com.google.android.packageinstaller`]),d=new Map;function f(t){return Object.freeze({readAppState:async e=>await m(t,e),readBlockingDialog:async e=>await h(t,e),async readAppFocus(e,n,r={}){let{runAndroidAutomationHelper:i}=await import(`./automation-helper.js`),a=await i(e,{action:`focus`});if(a?.focusedPackage===n&&a.windowType===`1`)return!0;let o=p(t,e);return r.requireNoBlockingDialog&&(await h(t,e,o)).status===`dialog`?!1:(await m(t,e,o)).package===n},readSnapshotNodes:async e=>await t.readSnapshotNodes(e),async tap(e,n,i){return await t.runAdb(e,r(`adb`,`shell`,[`input`,`tap`,String(Math.round(n)),String(Math.round(i))]),{allowFailure:!0})},openApp:async(e,n)=>await t.openApp(e,n),async readScreenSize(n){let i=(await t.runAdb(n,r(`adb`,`shell`,[`wm`,`size`]))).stdout.match(/Physical size:\s*(\d+)x(\d+)/);if(!i)throw new e(`COMMAND_FAILED`,`Unable to read screen size`);return{width:Number(i[1]),height:Number(i[2])}},async isPermissionPackage(e){return u.has(e)}})}function p(e,i){let a=new Map,o;return s=>{let c=s.join(` `),l=a.get(c);if(l)return l;o??=t.fromTimeoutMs(1e4);let u=o.remainingMs();if(u<=0)return Promise.resolve(``);let d=e.runAdb(i,r(`adb`,`shell`,s),{allowFailure:!0,timeoutMs:u}).then(e=>(_(i,c,e.stdout),e.stdout),e=>{if(!n(e))throw e;return``});return a.set(c,d),d}}async function m(e,t,n=p(e,t)){for(let e of g(t,`foreground`)){let t=y(await n(e));if(t)return t}return{}}async function h(e,t,n=p(e,t)){let{runAndroidAutomationHelper:r}=await import(`./automation-helper.js`),a=await r(t,{action:`focus`});if(a?.windowType===`1`&&a.focusedPackage&&a.focusedPackage!==`android`)return{status:`clear`};for(let e of g(t,`blockingDialog`)){let t=i(await n(e));if(t.focus)return{status:`dialog`,focus:t.focus};if(t.focusObserved)return{status:`clear`}}return{status:`unknown`}}function g(e,t){let n=t===`foreground`?[s,c]:[s],r=d.get(e.id);return n.flatMap(e=>{if(!r)return e;let n=e=>r.get(`${t} ${e.join(` `)}`)===!1,i=e.filter(e=>!n(e));return i.length===0||i.length===e.length?e:[...i,...e.filter(n)]})}function _(e,t,n){if(!n)return;let r=d.get(e.id)??new Map;v(r,`foreground ${t}`,b(a).test(n)),v(r,`blockingDialog ${t}`,b([o]).test(n)),d.set(e.id,r)}function v(e,t,n){e.get(t)!==!0&&e.set(t,n)}function y(e){for(let t of e.matchAll(l)){let e=t[1]?.match(/\b([A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)+)\/([A-Za-z0-9_.$]+)/);if(e?.[1]&&e[2])return{package:e[1],activity:e[2]}}return null}function b(e){return new RegExp(e.map(x).join(`|`))}function x(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}export{f as createAndroidObservationAdapter};
|
package/dist/src/open-script.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,_t as t}from"./sdk-contracts.js";import{l as n}from"./screenshot.js";import"./capture.js";const r={ios:!0,android:!0,harmonyos:!0};function i(e){return typeof e==`string`&&Object.hasOwn(r,e)}function a(e){return e.startsWith(`@`)?t(e)?.base??e:e}const o=/^-?\d+(\.\d+)?$/,s=/^[^\s"'\\][^\s"\\]*$/,c=new Map([[`--count`,`count`],[`--interval-ms`,`intervalMs`],[`--hold-ms`,`holdMs`],[`--jitter-px`,`jitterPx`]]),l=new Map([[`--count`,`count`],[`--pause-ms`,`pauseMs`]]),u=new Map([[`--pointer-count`,`pointerCount`],[`--hold-ms`,`holdMs`],[`--count`,`count`],[`--pause-ms`,`pauseMs`]]),d=new Map([[`--delay-ms`,`delayMs`]]),f={scroll:new Map([[`--until`,{key:`until`,kind:`string`}],[`--max-passes`,{key:`maxPasses`,kind:`int`}]]),wait:new Map([[`--raw`,{key:`snapshotRaw`,kind:`boolean`}],[`--depth`,{key:`snapshotDepth`,kind:`int`}],[`--scope`,{key:`snapshotScope`,kind:`string`}]])};Object.keys(f);function p(e,t){let n=[],r={},i=f[e];for(let e=0;e<t.length;e+=1){let a=t[e],o=i.get(a),s=t[e+1];if(o===void 0||o.kind!==`boolean`&&s===void 0){n.push(a);continue}if(o.kind===`boolean`){Object.assign(r,{[o.key]:!0});continue}if(o.kind===`int`){let e=I(s);if(e===null){n.push(a);continue}Object.assign(r,{[o.key]:e})}else Object.assign(r,{[o.key]:s});e+=1}return{positionals:n,flags:r}}function m(e){return e===`click`||e===`press`}function h(e){return m(e)||e===`longpress`||e===`hover`}function g(e){return e===`type`||e===`fill`}function _(e){return b(e,x)}function v(e){return JSON.stringify(e)}function y(e){return b(e,S)}function b(e,t){return t(e)?e:v(e)}function x(e){return S(e)&&e.startsWith(`@`)||o.test(e)}function S(e){return s.test(e)}const C=new Set([`fill`,`type`]);function w(e){if(!C.has(e.command)){let t=(e.positionals??[]).map(e=>_(e));return[e.command,...t].join(` `)}let t=T(e).map(e=>_(e)).join(` `);return[e.command,t,`<text>`].filter(e=>e.length>0).join(` `)}function T(e){if(e.command===`type`)return[];let t=e.positionals??[],n=t[0];return n===void 0?[]:n.startsWith(`@`)?[n]:t.length>=3&&o.test(n)&&o.test(t[1]??``)?[n,t[1]]:[n]}function E(e,t){let n=t.flags??{};if(m(t.command)){typeof n.count==`number`&&e.push(`--count`,String(n.count)),typeof n.intervalMs==`number`&&e.push(`--interval-ms`,String(n.intervalMs)),typeof n.holdMs==`number`&&e.push(`--hold-ms`,String(n.holdMs)),typeof n.jitterPx==`number`&&e.push(`--jitter-px`,String(n.jitterPx)),n.doubleTap===!0&&e.push(`--double-tap`);let t=n.clickButton;t&&t!==`primary`&&e.push(`--button`,t);return}if(t.command===`swipe`){typeof n.count==`number`&&e.push(`--count`,String(n.count)),typeof n.pauseMs==`number`&&e.push(`--pause-ms`,String(n.pauseMs)),(n.pattern===`one-way`||n.pattern===`ping-pong`)&&e.push(`--pattern`,n.pattern);return}if(t.command===`gesture`){typeof n.pointerCount==`number`&&e.push(`--pointer-count`,String(n.pointerCount)),typeof n.holdMs==`number`&&e.push(`--hold-ms`,String(n.holdMs)),typeof n.count==`number`&&e.push(`--count`,String(n.count)),typeof n.pauseMs==`number`&&e.push(`--pause-ms`,String(n.pauseMs));return}g(t.command)&&typeof n.delayMs==`number`&&e.push(`--delay-ms`,String(n.delayMs))}function D(e,t){t&&(i(t.platform)&&e.push(`--platform`,t.platform),typeof t.metroHost==`string`&&t.metroHost.length>0&&e.push(`--metro-host`,y(t.metroHost)),typeof t.metroPort==`number`&&e.push(`--metro-port`,String(t.metroPort)),typeof t.bundleUrl==`string`&&t.bundleUrl.length>0&&e.push(`--bundle-url`,y(t.bundleUrl)),typeof t.launchUrl==`string`&&t.launchUrl.length>0&&e.push(`--launch-url`,y(t.launchUrl)))}function O(e,t){let[n,...r]=t.positionals??[];n&&e.push(y(n));for(let t of r)e.push(_(t));typeof t.flags?.fps==`number`&&e.push(`--fps`,String(t.flags.fps)),(typeof t.flags?.quality==`number`||typeof t.flags?.quality==`string`)&&e.push(`--quality`,String(t.flags.quality)),t.flags?.hideTouches&&e.push(`--hide-touches`)}function k(e,t){t.flags?.snapshotInteractiveOnly&&e.push(`-i`),typeof t.flags?.snapshotDepth==`number`&&e.push(`-d`,String(t.flags.snapshotDepth)),t.flags?.snapshotScope&&e.push(`-s`,_(t.flags.snapshotScope)),t.flags?.snapshotRaw&&e.push(`--raw`)}function A(e,t){for(let n of t.positionals??[])e.push(_(n));let r=t.flags?.screenshotCropOn;typeof r==`string`&&r.length>0&&e.push(`--crop-on`,y(r)),n(e,t.flags)}function j(e,t,n={}){let r=t.positionals??[],i=n.includeAllPositionals?r:r.slice(0,1);for(let t of i)e.push(y(t));D(e,t.flags)}function M(e,t){for(let n of t.positionals??[])e.push(_(t.command===`wait`?a(n):n));t.command===`fold`&&t.flags?.keyframes!==void 0&&e.push(`--keyframes`,_(t.flags.keyframes)),t.command===`scroll`&&typeof t.flags?.until==`string`&&e.push(`--until`,_(t.flags.until)),t.command===`scroll`&&typeof t.flags?.maxPasses==`number`&&e.push(`--max-passes`,String(t.flags.maxPasses)),t.command===`wait`&&N(e,t.flags),E(e,t)}function N(e,t){t&&(t.snapshotRaw===!0&&e.push(`--raw`),typeof t.snapshotDepth==`number`&&e.push(`--depth`,String(t.snapshotDepth)),typeof t.snapshotScope==`string`&&e.push(`--scope`,_(t.snapshotScope)))}function P(e,t){let n=[],r={},i=m(e)?c:e===`swipe`?l:e===`gesture`?u:g(e)?d:void 0;for(let a=0;a<t.length;a+=1){let o=t[a];if(m(e)&&o===`--double-tap`){r.doubleTap=!0;continue}let s=t[a+1];if(e===`fold`&&o===`--keyframes`&&s!==void 0){r.keyframes=s,a+=1;continue}if(m(e)&&o===`--button`&&s!==void 0){let e=s;(e===`primary`||e===`secondary`||e===`middle`)&&(r.clickButton=e),a+=1;continue}let c=i?.get(o);if(c&&s!==void 0){let e=I(s);if(e!==null){r[c]=e,a+=1;continue}}if(e===`swipe`&&o===`--pattern`&&s!==void 0){let e=s;(e===`one-way`||e===`ping-pong`)&&(r.pattern=e),a+=1;continue}n.push(o)}return{positionals:n,flags:r}}function F(e){let t=[],n={};for(let r=0;r<e.length;r+=1){let a=e[r],o=e[r+1];if(a===`--platform`&&o!==void 0){let e=o;i(e)&&(n.platform=e),r+=1;continue}if(a===`--metro-host`&&o!==void 0){n.metroHost=o,r+=1;continue}if(a===`--metro-port`&&o!==void 0){let e=I(o);e!==null&&(n.metroPort=e),r+=1;continue}if(a===`--bundle-url`&&o!==void 0){n.bundleUrl=o,r+=1;continue}if(a===`--launch-url`&&o!==void 0){n.launchUrl=o,r+=1;continue}t.push(a)}return{positionals:t,flags:n}}function I(e){if(!e)return null;let t=Number(e);return!Number.isFinite(t)||t<0?null:Math.floor(t)}function L(e){let t;for(let n of e){if(n.command===`runtime`&&typeof n.flags.platform==`string`){t=n.flags.platform;continue}if(n.command===`open`)return n.runtime?.platform??t}return t}function R(e,t){for(let n of t.positionals??[])e.push(_(n));t.flags?.relaunch&&e.push(`--relaunch`),t.flags?.surface!==void 0&&e.push(`--surface`,t.flags.surface),t.flags?.testIme===!0?e.push(`--test-ime`):t.flags?.testIme===!1&&e.push(`--no-test-ime`),D(e,t.runtime)}function z(e){let t=[],n={};for(let r=0;r<e.length;r+=1){let i=e[r];if(i===`--surface`){n.surface=H(e[r+1]),r+=1;continue}if(i===`--relaunch`){n.relaunch=!0;continue}if(i===`--test-ime`){n.testIme=!0;continue}if(i===`--no-test-ime`){n.testIme=!1;continue}t.push(i)}let r=F(t);return{positionals:r.positionals,flags:n,runtime:U(r.flags)?r.flags:void 0}}const B={app:!0,"frontmost-app":!0,desktop:!0,menubar:!0};function V(e){return Object.hasOwn(B,e)}function H(t){let n=t?.trim().toLowerCase();if(n!==void 0&&V(n))return n;throw new e(`INVALID_ARGS`,`Invalid surface: ${t}. Use ${Object.keys(B).join(`|`)}.`)}function U(e){return!!(e.platform||e.metroHost||e.metroPort!==void 0||e.bundleUrl||e.launchUrl)}export{P as _,O as a,E as c,_ as d,v as f,F as g,p as h,M as i,k as l,h as m,z as n,j as o,m as p,L as r,A as s,R as t,w as u,a as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{d as t}from"./daemon-command-registry.js";import{n}from"./open-target2.js";var r=e({resolveOpenTargetDeviceOptions:()=>i});function i(e,r){return n(e.positionals?.[0],r,e.flags?.surface,e.flags?.device?t(`open`):`running-only`)}export{i as n,r as t};
|
package/dist/src/orientation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{St as t}from"./sdk-io.js";import"./diagnostics.js";import{t as n}from"./ttl-memo.js";import"./config.js";import{d as r}from"./simctl.js";import{a as i,i as a,o}from"./display-inventory.js";import{n as s}from"./fold-helper.js";import{t as c}from"./runtime6.js";const l=new Map,u=n({ttlMs:5e3});let d=0;const f=new Map;function p(e,t,n){l.set(e.id,t.multiScreen),u.delete(e.id),f.set(e.id,Math.max(n,f.get(e.id)??0))}async function m(e,t){if(!c(e).setFoldPose.available)return!1;let n=l.get(e.id);if(n!==void 0)return n;let r=++d,i=await o(e,{signal:t});return!i.unresolved&&(p(e,i,r),i.multiScreen)}async function h(e,t){if(!c(e).setFoldPose.available)return{kind:`single-panel`};let n=l.get(e.id);if(n===!1||n===void 0&&u.get(e.id))return{kind:`single-panel`};let r=++d,i=await o(e,t);if(i.unresolved){if(n)return{kind:`unreadable`};let i=(f.get(e.id)??0)>r;return t.timeoutMs>=5e3&&!t.signal?.aborted&&!i&&u.set(e.id,!0),{kind:`single-panel`}}return p(e,i,r),i.multiScreen?{kind:`multi-panel`,inventory:i}:{kind:`single-panel`}}const g={outer:{portrait:`portrait`,"landscape-left":`landscape-left`,"landscape-right":`landscape-right`},inner:{portrait:`landscape-left`,"landscape-left":`portrait-upside-down`,"landscape-right":`portrait`}};async function _(n,i,a={}){let{signal:o}=a;if(i===`portrait-upside-down`)throw new e(`UNSUPPORTED_OPERATION`,`${n.name} cannot rotate to ${i}`,{deviceId:n.id,requestedOrientation:i,reason:`unsupported-foldable-orientation`,hint:`A foldable simulator accepts portrait, landscape-left, and landscape-right as rotation targets.`});let c=s(n),l,u;for(let e=1;e<=6;e+=1){if(o?.throwIfAborted(),u=await y(n,c,{signal:o}),u?.rotation===i)return{orientation:i};if(u&&u.panel.displayId!==l){let a=(u.panel.primary?g.outer:g.inner)[i];await c.rotate(a,o),l=u.panel.displayId,t({level:`info`,phase:`apple_foldable_orientation_dispatched`,data:{deviceId:n.id,orientation:a,requestedOrientation:i,scopedSet:!!r(n).simulatorSetPath,attempt:e,observedOrientation:u.rotation,litDisplay:u.panel.name}})}await b()}if(u=await y(n,c,{signal:o,requireTable:!0}),u?.rotation===i)return{orientation:i};throw v(n,i,u)}function v(t,n,r){return new e(`COMMAND_FAILED`,`${t.name} did not confirm rotation to ${n}: ${r?`the lit panel shows ${r.rotation}`:`the last panel table read named no single lit panel`}`,{deviceId:t.id,requestedOrientation:n,...r?{observedOrientation:r.rotation,rawPanelOrientation:r.panel.currentOrientation}:{},reason:`orientation-unverified`,hint:`The lit panel did not show the requested orientation, or the simulator never reported a single lit panel; the app in front may not support that orientation. Take a screenshot to see the screen, then retry.`})}async function y(t,n,r){let s=await o(t,{signal:r.signal,source:`guest`,foldHelper:n});if(s.unresolved&&r.requireTable)throw new e(`COMMAND_FAILED`,`The guest panel table could not be read`,{deviceId:t.id,reason:`orientation-panel-table-unavailable`,hint:`The fold helper could not provide a usable display table. Check the apple_display_inventory_unresolved diagnostic for the helper or display-table failure, then retry.`});let c=a(s);if(!c)return;let l=i(c.currentOrientation);return l===void 0?void 0:{panel:c,rotation:l}}async function b(){await new Promise(e=>{setTimeout(e,600)})}export{h as n,_ as r,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{Fn as t}from"./sdk-batch.js";import{t as n}from"./script.js";import{t as r}from"./session-paths.js";const i=/^\$\{([A-Z_][A-Z0-9_]*)\}$/;function a(t){if(t!==t.trim()||!n.test(t))throw new e(`INVALID_ARGS`,`Invalid --record-as variable "${t}": use uppercase letters, digits, and underscores (for example PASSWORD).`);if(t.startsWith(`AD_`))throw new e(`INVALID_ARGS`,`Invalid --record-as variable "${t}": the AD_* namespace is reserved for built-in replay variables.`);return t}function o(e){return typeof e?.recordAs==`string`||e?.textStdin===!0}function s(e){return typeof e?.recordAs==`string`?c(e.recordAs):`[REDACTED]`}function c(e){return`\${${e}}`}function ee(e){let t=i.exec(e);if(!(!t?.[1]||t[1].startsWith(`AD_`)))return t[1]}function te(e){let t=e.result?.text;if(typeof t==`string`)return t;let n=e.positionals??[];return n.length===0?``:n[0]?.startsWith(`@`)?n.length>=3?n.slice(2).join(` `):n.slice(1).join(` `):n.length>=3&&!Number.isNaN(Number(n[0]))&&!Number.isNaN(Number(n[1]))?n.slice(2).join(` `):n.slice(1).join(` `)}const l={kind:`none`};function u(e,t){if(t.path===void 0){let n=e??{kind:`default`,force:!1};return t.force?{...n,force:!0}:n}let n=e?.force===!0&&(e.kind==="default"||e.path===t.path);return{kind:`explicit`,path:t.path,force:t.force||n}}function ne(e){return e.kind===`repair`?{...e,status:`armed`}:e}function d(e){return e.kind===`none`?void 0:e.target}function f(e){return e.kind===`repair`&&(e.status===`complete`||e.status===`close-succeeded`)}function p(e){return e.kind===`authoring`&&e.status===`aborted`}function m(e){return e.kind===`authoring`?e.status===`armed`:e.kind===`repair`}function re(e){return e.kind===`repair`?e.status===`committed`:e.kind===`authoring`&&e.status===`published`}function h(e){return{kind:`authoring`,status:`armed`,target:u(void 0,e)}}function ie(e){return e.kind!==`authoring`||e.status!==`armed`?e:{...e,status:`aborted`}}function g(e,t){return e.kind===`authoring`?{kind:`authoring`,status:`published`,target:{kind:`explicit`,path:t,force:e.target.force}}:e}function _(e,t){let n=e.kind===`repair`?e:void 0,r=n?.sourcePath??t.sourcePath;return{kind:`repair`,status:n?.status??`armed`,target:u(n?.target,t.requested),boundary:n?.boundary??t.boundary,...r===void 0?{}:{sourcePath:r},...n?.closeReceipt===void 0?{}:{closeReceipt:n.closeReceipt}}}function ae(e){return e.kind!==`repair`||e.status!==`armed`?e:{...e,status:`complete`}}function oe(e,t){return e.kind===`repair`?{...e,status:e.status===`complete`?`close-succeeded`:e.status,closeReceipt:t}:e}function se(e){if(e.kind!==`repair`)return e;let{closeReceipt:t,...n}=e;return{...n,status:`committed`}}function ce(e){if(e.kind!==`repair`)return e;let{closeReceipt:t,...n}=e;return{...n,status:`aborted`}}function le(e){return e.kind===`repair`?e.boundary:void 0}function ue(e){return e.kind===`repair`?e.sourcePath:void 0}function de(e){return e.kind===`repair`&&e.status!==`committed`}function fe(e){let t=d(e);return t?.kind===`explicit`?t.path:void 0}function v(e){return d(e)?.force===!0}function y(e){return e?.scriptPublication??l}function b(e){let t=y(e);return t.kind===`authoring`&&t.status===`armed`}function x(e,t,n){e.scriptPublication=h({path:t.path===void 0?void 0:r(t.path,n),force:t.force===!0})}function S(e){e.scriptPublication=ie(y(e))}function C(e){return m(y(e))}function w(e,t,n){if(!t.saveScript||p(y(e)))return;let i={path:typeof t.saveScript==`string`?r(t.saveScript,n):void 0,force:t.force===!0},a=y(e);if(a.kind===`repair`){e.scriptPublication=_(a,{requested:i,boundary:a.boundary,sourcePath:a.sourcePath});return}if(a.kind===`authoring`){e.scriptPublication={...a,target:u(a.target,i)};return}e.scriptPublication=h(i)}function T(e,t,n){let i=y(e);i.kind===`authoring`&&(e.scriptPublication={...i,target:u(i.target,{path:t.explicitPath===void 0?void 0:r(t.explicitPath,n),force:t.liveForce===!0})})}function E(e,t){e.scriptPublication=g(y(e),t)}function D(e,t){let n=y(e);n.kind===`authoring`&&(e.scriptPublication=g(n,t))}function O(e,t){return t===!0||v(y(e))}function k(e){return re(y(e))}const A=new Set(`action.after.backend.before.cost.delayMs.evidence.gesture.hint.kind.maestroFallbackReason.maestroNonHittableCoordinateFallbackAllowed.maestroNonHittableCoordinateFallbackUsed.message.platform.ref.referenceHeight.referenceWidth.refLabel.requested.resolution.selector.selectorChain.settle.target.targetHittable.targetKind.text.verification.warning.x.y`.split(`.`)),j=new Set([`action`,`backend`,`gesture`,`kind`,`platform`,`ref`,`selector`,`targetKind`,`verification`]),M=new Set([`cost`,`evidence`,`resolution`,`settle`,`target`]),N=new Map([[`cost`,new Set([`nodeCount`,`runnerRoundTrips`,`wallClockMs`])],[`evidence`,new Set([`changedFromBefore`,`digest`,`foregroundApp`,`interactiveNodeCount`,`nodeCount`])],[`resolution`,new Set([`alternatives`,`kind`,`matchCount`,`phase`,`source`,`tiebreak`,`winnerDiagnostic`])],[`resolution.alternatives`,new Set([`diagnosticRef`,`label`,`role`])],[`resolution.winnerDiagnostic`,new Set([`diagnosticRef`,`label`,`role`])],[`settle`,new Set([`captures`,`diff`,`hint`,`quietMs`,`refs`,`refsGeneration`,`settled`,`tail`,`tailTruncated`,`timeoutMs`,`waitedMs`])],[`settle.diff`,new Set([`lines`,`summary`,`truncated`])],[`settle.diff.lines`,new Set([`kind`,`ref`,`text`])],[`settle.diff.summary`,new Set([`additions`,`removals`,`unchanged`])],[`settle.refs`,new Set([`ref`])],[`settle.tail`,new Set([`label`,`ref`,`role`])],[`target`,new Set([`className`,`packageName`,`rect`,`resourceId`])],[`target.rect`,new Set([`height`,`width`,`x`,`y`])]]),P=new Set([`evidence.digest`,`evidence.foregroundApp`,`resolution.alternatives.diagnosticRef`,`resolution.alternatives.role`,`resolution.kind`,`resolution.phase`,`resolution.source`,`resolution.tiebreak`,`resolution.winnerDiagnostic.diagnosticRef`,`resolution.winnerDiagnostic.role`,`settle.diff.lines.kind`,`settle.diff.lines.ref`,`settle.refs.ref`,`settle.tail.ref`,`settle.tail.role`,`target.className`]);function F(e,t,n){if(!e)return e;let r=ge(e.selectorChain),i=e=>V(e,t);return{...H(e,e=>W(e,t,n),i),...typeof e.text==`string`?{text:n}:{},...r?{selectorChain:r.filter(e=>!i(e))}:{}}}function I(e,t){let n=new Set;if(!e)return{payload:e,insertedPlaceholders:n};let r=q(t);return{payload:H(e,(e,t)=>J(e,r,t===`value`?n:void 0),e=>z(e,t)),insertedPlaceholders:n}}function L(e,t){if(!e)return e;let n=q(t);return{...e,...e.label===void 0?{}:{label:J(e.label,n)},ancestry:e.ancestry.map(e=>({...e,...e.label===void 0?{}:{label:J(e.label,n)}})),...e.scrollRegion?{scrollRegion:{...e.scrollRegion,...e.scrollRegion.label===void 0?{}:{label:J(e.scrollRegion.label,n)}}}:{}}}function pe(e,t){return!!(e.label!==void 0&&R(e.label,t)||e.ancestry.some(e=>e.label&&R(e.label,t))||e.scrollRegion?.label&&R(e.scrollRegion.label,t))}function R(e,t){for(let n of t.keys())if(e.includes(n))return!0;return!1}function z(e,t){for(let n of t.keys())if(V(e,n))return!0;return!1}function B(e,t,n){return!e||!t?e:{...e,...e.label===t?{label:n}:{},ancestry:e.ancestry.map(e=>({...e,...e.label===t?{label:n}:{}})),...e.scrollRegion?{scrollRegion:{...e.scrollRegion,...e.scrollRegion.label===t?{label:n}:{}}}:{}}}function V(e,n){return t(e,n)}function H(e,t,n){return Object.fromEntries(Object.entries(e).map(([e,r])=>[A.has(e)?e:t(e,`key`),me(r,e,t,n)]))}function me(e,t,n,r){return typeof e==`string`&&j.has(t)?e:t===`selectorChain`&&Y(e)?he(e,r):U(e,n,r,M.has(t)?t:void 0)}function U(e,t,n,r){if(typeof e==`string`)return r&&P.has(r)?e:t(e,`value`);if(Array.isArray(e))return e.map(e=>U(e,t,n,r));if(!e||typeof e!=`object`)return e;let i=r?N.get(r):void 0;return Object.fromEntries(Object.entries(e).map(([e,a])=>{let o=i?.has(e)===!0;return[o?e:t(e,`key`),U(a,t,n,o?`${r}.${e}`:void 0)]}))}function he(e,t){return e.filter(e=>!t(e))}function W(e,t,n){if(!t)return e;let r=n?e.split(n):[e];return r.every(e=>!e.includes(t))?G(e,t,n):t.trim()?G(r.map(e=>e.replaceAll(t,n)).join(n),t,n):n}function G(e,t,n){let r=[];if(n)for(let t=e.indexOf(n);t!==-1;t=e.indexOf(n,t+n.length))r.push(t);let i=0;for(let a=e.indexOf(t);a!==-1;a=e.indexOf(t,a+1)){for(;i<r.length&&r[i]+n.length<a+t.length;)i+=1;if(i===r.length||r[i]>a)return n}return e}const K=/\$\{[A-Z_][A-Z0-9_]*\}/y;function q(e){return[...e].sort(([e],[t])=>t.length-e.length)}function J(e,t,n){if(!e||t.length===0)return e;let r=``,i=0;scan:for(;i<e.length;){for(let[a,o]of t)if(e.startsWith(a,i)){r+=o,n?.add(o),i+=a.length;continue scan}if(e[i]===`$`){K.lastIndex=i;let t=K.exec(e);if(t){r+=t[0],i+=t[0].length;continue}}r+=e[i],i+=1}return r}function Y(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function ge(e){return Y(e)?e:void 0}const _e=[`requested`,`before`,`after`],ve=[`expected`,`actual`],ye=[`targetInput`,`actualInput`];function X(e,t){if(!e)return e;let n=e.verification===`unconfirmed`?Q(e,_e,t):{};return{...e,...n,...$(e.settle)?{settle:be(e.settle,t)}:{}}}function be(e,t){let{diff:n,tail:r}=e;return{...e,...$(n)&&Array.isArray(n.lines)?{diff:{...n,lines:n.lines.map(e=>Z(e,`text`,t))}}:{},...Array.isArray(r)?{tail:r.map(e=>Z(e,`label`,t))}:{}}}function Z(e,t,n){return $(e)?{...e,...Q(e,[t],n)}:e}function xe(e,t){if(!$(e)||typeof e.failureReason!=`string`)return e;let n=Object.fromEntries(ye.flatMap(n=>{let r=e[n];return $(r)?[[n,{...r,...Q(r,[`text`],t)}]]:[]}));return{...e,...Q(e,ve,t),...n}}function Q(e,t,n){return Object.fromEntries(t.filter(t=>typeof e[t]==`string`).map(e=>[e,n]))}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{ue as A,ne as C,ae as D,de as E,ee as F,c as I,s as L,fe as M,te as N,oe as O,o as P,a as R,se as S,f as T,D as _,L as a,ce as b,pe as c,x as d,O as f,E as g,k as h,W as i,v as j,le as k,S as l,C as m,B as n,xe as o,b as p,I as r,X as s,F as t,w as u,T as v,m as w,_ as x,l as y};
|
|
1
|
+
import{Rn as e}from"./sdk-batch.js";import{_ as t}from"./sdk-contracts.js";import{n}from"./success-text.js";import{t as r}from"./script.js";import{t as i}from"./session-paths.js";import a from"node:path";const o=/^\$\{([A-Z_][A-Z0-9_]*)\}$/;function s(e){if(e!==e.trim()||!r.test(e))throw new t(`INVALID_ARGS`,`Invalid --record-as variable "${e}": use uppercase letters, digits, and underscores (for example PASSWORD).`);if(e.startsWith(`AD_`))throw new t(`INVALID_ARGS`,`Invalid --record-as variable "${e}": the AD_* namespace is reserved for built-in replay variables.`);return e}function c(e){return typeof e?.recordAs==`string`||e?.textStdin===!0}function l(e){return typeof e?.recordAs==`string`?u(e.recordAs):`[REDACTED]`}function u(e){return`\${${e}}`}function ee(e){let t=o.exec(e);if(!(!t?.[1]||t[1].startsWith(`AD_`)))return t[1]}function te(e){let t=e.result?.text;if(typeof t==`string`)return t;let n=e.positionals??[];return n.length===0?``:n[0]?.startsWith(`@`)?n.length>=3?n.slice(2).join(` `):n.slice(1).join(` `):n.length>=3&&!Number.isNaN(Number(n[0]))&&!Number.isNaN(Number(n[1]))?n.slice(2).join(` `):n.slice(1).join(` `)}const d=Symbol(`captureOutputOwnership`);function ne(e,t,n){return{...e,[d]:{ownership:t,tenantId:n}}}function re(e){return e[d]?.ownership}function ie(e){return e[d]?.tenantId}const f=Symbol(`daemonDeliveredArtifact`);function ae(e,t){let n=e;return n[f]={tenantId:t},n}function oe(e){return e?.[f]}const p={kind:`none`};function m(e,t){if(t.path===void 0){let n=e??{kind:`default`,force:!1};return t.force?{...n,force:!0}:n}let n=e?.force===!0&&(e.kind==="default"||e.path===t.path);return{kind:`explicit`,path:t.path,force:t.force||n}}function se(e){return e.kind===`repair`?{...e,status:`armed`}:e}function h(e){return e.kind===`none`?void 0:e.target}function ce(e){return e.kind===`repair`&&(e.status===`complete`||e.status===`close-succeeded`)}function g(e){return e.kind===`authoring`&&e.status===`aborted`}function _(e){return e.kind===`authoring`?e.status===`armed`:e.kind===`repair`}function le(e){return e.kind===`repair`?e.status===`committed`:e.kind===`authoring`&&e.status===`published`}function v(e,t){return{kind:`authoring`,status:`armed`,target:m(void 0,e),...t?{remoteDelivery:t}:{}}}function y(e){return e.kind!==`authoring`||e.status!==`armed`?e:{...e,status:`aborted`}}function b(e,t){return e.kind===`authoring`?{...e,status:`published`,target:{kind:`explicit`,path:t,force:e.target.force}}:e}function x(e,t){let n=e.kind===`repair`?e:void 0,r=n?.sourcePath??t.sourcePath;return{kind:`repair`,status:n?.status??`armed`,target:m(n?.target,t.requested),boundary:n?.boundary??t.boundary,...r===void 0?{}:{sourcePath:r},...n?.closeReceipt===void 0?{}:{closeReceipt:n.closeReceipt}}}function ue(e){return e.kind!==`repair`||e.status!==`armed`?e:{...e,status:`complete`}}function de(e,t){return e.kind===`repair`?{...e,status:e.status===`complete`?`close-succeeded`:e.status,closeReceipt:t}:e}function fe(e){if(e.kind!==`repair`)return e;let{closeReceipt:t,...n}=e;return{...n,status:`committed`}}function pe(e){if(e.kind!==`repair`)return e;let{closeReceipt:t,...n}=e;return{...n,status:`aborted`}}function me(e){return e.kind===`repair`?e.boundary:void 0}function he(e){return e.kind===`repair`?e.sourcePath:void 0}function ge(e){return e.kind===`repair`&&e.status!==`committed`}function S(e){let t=h(e);return t?.kind===`explicit`?t.path:void 0}function C(e){return h(e)?.force===!0}function w(e){return e?.scriptPublication??p}function T(e){let t=w(e);return t.kind===`authoring`&&t.status===`armed`}function E(e,t,n,r){e.scriptPublication=v({path:t.path===void 0?void 0:i(t.path,n),force:t.force===!0},r?{...r,revision:0}:void 0)}function D(e){let t=e?.scriptPublicationId;if(!(typeof t!=`string`||!/^[A-Za-z0-9-]{16,64}$/.test(t)))return{publicationId:t,tenantId:e?.tenantId}}function O(e){e.scriptPublication=y(w(e))}function k(e){return _(w(e))}function A(e,t,n){if(!t.saveScript||g(w(e)))return;let r={path:typeof t.saveScript==`string`?i(t.saveScript,n):void 0,force:t.force===!0},a=w(e);if(a.kind===`repair`){e.scriptPublication=x(a,{requested:r,boundary:a.boundary,sourcePath:a.sourcePath});return}if(a.kind===`authoring`){e.scriptPublication={...a,target:m(a.target,r)};return}e.scriptPublication=v(r)}function j(e,t,n){let r=w(e);r.kind===`authoring`&&(e.scriptPublication={...r,target:m(r.target,{path:t.explicitPath===void 0?void 0:i(t.explicitPath,n),force:t.liveForce===!0})})}function M(e){return T(e)&&N(e)!==void 0}function N(e){let t=w(e);return t.kind===`authoring`?t.remoteDelivery:void 0}function P(e,t){e.scriptPublication=b(w(e),t)}function F(e,t){let n=w(e);n.kind===`authoring`&&(e.scriptPublication=b(n,t))}function I(e,t){return t===!0||C(w(e))}function L(e){return le(w(e))}function R(e){let t=e.scriptPublication;if(t?.kind!==`authoring`||!t.remoteDelivery)return;let n={...t.remoteDelivery,revision:t.remoteDelivery.revision+1};return e.scriptPublication={...t,remoteDelivery:n},n}function z(e,t,r){if(!e.ok)return e;let{publicationId:i}=t,o=e.data??{};if(`failure`in r){let e={reason:`script_delivery_failed`,publicationId:i,...r.failure};return{ok:!0,data:{...o,scriptDeliveryFailure:e,warnings:[...n(o),`${e.message} ${e.hint}`]}}}let s=ae({field:`savedScript`,artifactType:`session-script`,path:r.path,fileName:a.basename(r.path),scriptPublicationId:i,scriptRevision:t.revision},t.tenantId),c=Array.isArray(o.artifacts)?o.artifacts:[];return{ok:!0,data:{...o,artifacts:[...c,s]}}}function _e(e,t){let n=e.lookup(t)?.session,r=n&&N(n)?n.actions.length:0;return n=>{if(!n.ok)return n;let i=e.lookup(t),a=N(i?.session);if(!i||!a||i.session.actions.length===r)return n;let o=e.writeRemoteScriptVersion(i);return o.written?z(n,R(i.session)??a,{path:o.path}):o.error?z(n,a,{failure:{message:`The action succeeded, but the daemon could not write the remote recording.`,hint:`The --save-script file keeps the previous version. The next recorded action or close delivers the full recording again.`}}):n}}function B(e,t){let n=e.scriptPublication;if(n?.kind!==`authoring`||!n.remoteDelivery)return;let r=n.remoteDelivery;if(t)return{delivery:r,version:{failure:{message:`The session was closed, but the daemon could not write its final script.`,hint:`The --save-script file keeps the version from the last recorded action.`}}};let i=n.status===`published`?S(n):void 0;return i?{delivery:R(e)??r,version:{path:i}}:{delivery:r}}function ve(e,t){if(!t||!e.ok)return e;let n={ok:!0,data:{...e.data,scriptPublicationId:t.delivery.publicationId}};return t.version?z(n,t.delivery,t.version):n}const ye=new Set(`action.after.backend.before.cost.delayMs.evidence.gesture.hint.kind.maestroFallbackReason.maestroNonHittableCoordinateFallbackAllowed.maestroNonHittableCoordinateFallbackUsed.message.platform.ref.referenceHeight.referenceWidth.refLabel.requested.resolution.selector.selectorChain.settle.target.targetHittable.targetKind.text.verification.warning.x.y`.split(`.`)),be=new Set([`action`,`backend`,`gesture`,`kind`,`platform`,`ref`,`selector`,`targetKind`,`verification`]),xe=new Set([`cost`,`evidence`,`resolution`,`settle`,`target`]),Se=new Map([[`cost`,new Set([`nodeCount`,`runnerRoundTrips`,`wallClockMs`])],[`evidence`,new Set([`changedFromBefore`,`digest`,`foregroundApp`,`interactiveNodeCount`,`nodeCount`])],[`resolution`,new Set([`alternatives`,`kind`,`matchCount`,`phase`,`source`,`tiebreak`,`winnerDiagnostic`])],[`resolution.alternatives`,new Set([`diagnosticRef`,`label`,`role`])],[`resolution.winnerDiagnostic`,new Set([`diagnosticRef`,`label`,`role`])],[`settle`,new Set([`captures`,`diff`,`hint`,`quietMs`,`refs`,`refsGeneration`,`settled`,`tail`,`tailTruncated`,`timeoutMs`,`waitedMs`])],[`settle.diff`,new Set([`lines`,`summary`,`truncated`])],[`settle.diff.lines`,new Set([`kind`,`ref`,`text`])],[`settle.diff.summary`,new Set([`additions`,`removals`,`unchanged`])],[`settle.refs`,new Set([`ref`])],[`settle.tail`,new Set([`label`,`ref`,`role`])],[`target`,new Set([`className`,`packageName`,`rect`,`resourceId`])],[`target.rect`,new Set([`height`,`width`,`x`,`y`])]]),Ce=new Set([`evidence.digest`,`evidence.foregroundApp`,`resolution.alternatives.diagnosticRef`,`resolution.alternatives.role`,`resolution.kind`,`resolution.phase`,`resolution.source`,`resolution.tiebreak`,`resolution.winnerDiagnostic.diagnosticRef`,`resolution.winnerDiagnostic.role`,`settle.diff.lines.kind`,`settle.diff.lines.ref`,`settle.refs.ref`,`settle.tail.ref`,`settle.tail.role`,`target.className`]);function we(e,t,n){if(!e)return e;let r=Me(e.selectorChain),i=e=>H(e,t);return{...U(e,e=>G(e,t,n),i),...typeof e.text==`string`?{text:n}:{},...r?{selectorChain:r.filter(e=>!i(e))}:{}}}function Te(e,t){let n=new Set;if(!e)return{payload:e,insertedPlaceholders:n};let r=J(t);return{payload:U(e,(e,t)=>Y(e,r,t===`value`?n:void 0),e=>Oe(e,t)),insertedPlaceholders:n}}function Ee(e,t){if(!e)return e;let n=J(t);return{...e,...e.label===void 0?{}:{label:Y(e.label,n)},ancestry:e.ancestry.map(e=>({...e,...e.label===void 0?{}:{label:Y(e.label,n)}})),...e.scrollRegion?{scrollRegion:{...e.scrollRegion,...e.scrollRegion.label===void 0?{}:{label:Y(e.scrollRegion.label,n)}}}:{}}}function De(e,t){return!!(e.label!==void 0&&V(e.label,t)||e.ancestry.some(e=>e.label&&V(e.label,t))||e.scrollRegion?.label&&V(e.scrollRegion.label,t))}function V(e,t){for(let n of t.keys())if(e.includes(n))return!0;return!1}function Oe(e,t){for(let n of t.keys())if(H(e,n))return!0;return!1}function ke(e,t,n){return!e||!t?e:{...e,...e.label===t?{label:n}:{},ancestry:e.ancestry.map(e=>({...e,...e.label===t?{label:n}:{}})),...e.scrollRegion?{scrollRegion:{...e.scrollRegion,...e.scrollRegion.label===t?{label:n}:{}}}:{}}}function H(t,n){return e(t,n)}function U(e,t,n){return Object.fromEntries(Object.entries(e).map(([e,r])=>[ye.has(e)?e:t(e,`key`),Ae(r,e,t,n)]))}function Ae(e,t,n,r){return typeof e==`string`&&be.has(t)?e:t===`selectorChain`&&X(e)?je(e,r):W(e,n,r,xe.has(t)?t:void 0)}function W(e,t,n,r){if(typeof e==`string`)return r&&Ce.has(r)?e:t(e,`value`);if(Array.isArray(e))return e.map(e=>W(e,t,n,r));if(!e||typeof e!=`object`)return e;let i=r?Se.get(r):void 0;return Object.fromEntries(Object.entries(e).map(([e,a])=>{let o=i?.has(e)===!0;return[o?e:t(e,`key`),W(a,t,n,o?`${r}.${e}`:void 0)]}))}function je(e,t){return e.filter(e=>!t(e))}function G(e,t,n){if(!t)return e;let r=n?e.split(n):[e];return r.every(e=>!e.includes(t))?K(e,t,n):t.trim()?K(r.map(e=>e.replaceAll(t,n)).join(n),t,n):n}function K(e,t,n){let r=[];if(n)for(let t=e.indexOf(n);t!==-1;t=e.indexOf(n,t+n.length))r.push(t);let i=0;for(let a=e.indexOf(t);a!==-1;a=e.indexOf(t,a+1)){for(;i<r.length&&r[i]+n.length<a+t.length;)i+=1;if(i===r.length||r[i]>a)return n}return e}const q=/\$\{[A-Z_][A-Z0-9_]*\}/y;function J(e){return[...e].sort(([e],[t])=>t.length-e.length)}function Y(e,t,n){if(!e||t.length===0)return e;let r=``,i=0;scan:for(;i<e.length;){for(let[a,o]of t)if(e.startsWith(a,i)){r+=o,n?.add(o),i+=a.length;continue scan}if(e[i]===`$`){q.lastIndex=i;let t=q.exec(e);if(t){r+=t[0],i+=t[0].length;continue}}r+=e[i],i+=1}return r}function X(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Me(e){return X(e)?e:void 0}const Ne=[`requested`,`before`,`after`],Pe=[`expected`,`actual`],Fe=[`targetInput`,`actualInput`];function Ie(e,t){if(!e)return e;let n=e.verification===`unconfirmed`?Q(e,Ne,t):{};return{...e,...n,...$(e.settle)?{settle:Le(e.settle,t)}:{}}}function Le(e,t){let{diff:n,tail:r}=e;return{...e,...$(n)&&Array.isArray(n.lines)?{diff:{...n,lines:n.lines.map(e=>Z(e,`text`,t))}}:{},...Array.isArray(r)?{tail:r.map(e=>Z(e,`label`,t))}:{}}}function Z(e,t,n){return $(e)?{...e,...Q(e,[t],n)}:e}function Re(e,t){if(!$(e)||typeof e.failureReason!=`string`)return e;let n=Object.fromEntries(Fe.flatMap(n=>{let r=e[n];return $(r)?[[n,{...r,...Q(r,[`text`],t)}]]:[]}));return{...e,...Q(e,Pe,t),...n}}function Q(e,t,n){return Object.fromEntries(t.filter(t=>typeof e[t]==`string`).map(e=>[e,n]))}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{_ as A,ie as B,_e as C,x as D,pe as E,me as F,ee as G,ne as H,he as I,s as J,u as K,C as L,ge as M,ue as N,fe as O,de as P,S as R,D as S,p as T,te as U,oe as V,c as W,P as _,Ee as a,ve as b,De as c,E as d,I as f,L as g,k as h,G as i,ce as j,se as k,O as l,T as m,ke as n,Re as o,M as p,l as q,Te as r,Ie as s,we as t,A as u,F as v,j as w,N as x,B as y,re as z};
|
package/dist/src/perf-facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{J as t,Z as n,tt as r}from"./sdk-io.js";import{L as i,T as a,w as o,y as s}from"./sdk-device.js";import{Ar as c}from"./sdk-batch.js";import"./command.js";import{t as l}from"./parser.js";import{n as u,t as d}from"./numeric.js";import{O as ee,T as te,_ as ne,b as re,h as f,i as ie,o as p,u as m,w as h}from"./host-file.js";import{o as ae,s as g}from"./tool-provider.js";import{o as oe,t as se}from"./devicectl.js";import{n as ce}from"./simctl.js";import _ from"node:path";import{fileURLToPath as v}from"node:url";function y(e,t){for(let n of e){if(t(n))return n;let e=y(n.children,t);if(e)return e}}function b(e,t){let n=[];for(let r of e)t(r)&&n.push(r),n.push(...b(r.children,t));return n}function le(e,t){return e.children.find(e=>e.name===t)?.text??null}function x(e,t){let n=y(e,e=>e.name===`schema`&&e.attributes.name===t);return n?n.children.filter(e=>e.name===`col`).map(e=>le(e,`mnemonic`)??``):[]}function S(e){if(!e||e.children.some(e=>e.name===`sentinel`)||!e.text)return null;let t=Number(e.text);return Number.isFinite(t)?t:null}function C(e,t){return e?e.attributes.ref?t.get(e.attributes.ref)?.numberValue??null:S(e):null}function w(e,t){for(let n of e)w(n.children,t),n.attributes.id&&t.set(n.attributes.id,{numberValue:S(n),process:E(n)})}function T(e,t){return e?e.attributes.ref?t.get(e.attributes.ref)?.process??null:E(e):null}function E(e){if(!e||e.children.some(e=>e.name===`sentinel`))return null;let t=S(y(e.children,e=>e.name===`pid`)),n=(e.attributes.fmt??``).trim().replace(/\s+\(\d+\)$/,``).trim();return t===null&&n.length===0?null:{pid:t??void 0,name:n.length>0?n:void 0}}function ue(e){return new Map(b(e,e=>!!e.attributes.id).flatMap(e=>{let t=e.attributes.id;return t?[[t,e]]:[]}))}function D(e,t){if(e)return e.attributes.ref?t.get(e.attributes.ref):e}const O=new Set([`backtrace`,`tagged-backtrace`]);function k(e,t=10){let n=l(e),r=ue(n),i=new Map,a=0,o=0;for(let e of b(n,e=>e.name===`row`)){let t=A(e,r),n=de(e,r);if(t===void 0||!n)continue;let s=n.attributes.name?.trim()||`<unknown>`,c=fe(n,r),l=`${c??``}\u0000${s}`,u=i.get(l);i.set(l,{symbol:s,binary:c,weightNs:(u?.weightNs??0)+t}),a+=1,o+=t}let s=Math.max(0,Math.floor(t)),c=[...i.values()].sort((e,t)=>t.weightNs-e.weightNs||e.symbol.localeCompare(t.symbol)).slice(0,s).map(({symbol:e,binary:t,weightNs:n})=>({symbol:e,binary:t,selfSampleMs:j(n),selfSamplePercent:o>0?u(n/o*100):0}));return{sampleCount:a,totalSampleWeightMs:j(o),topFunctions:c}}function A(e,t){let n=D(e.children.find(e=>e.name===`weight`),t);if(!n?.text)return;let r=Number(n.text);return Number.isFinite(r)&&r>0?r:void 0}function de(e,t){return D(D(e.children.find(e=>O.has(e.name)),t)?.children.find(e=>e.name===`frame`),t)}function fe(e,t){return D(e.children.find(e=>e.name===`binary`),t)?.attributes.name?.trim()||void 0}function j(e){return Math.round(e/1e6*1e3)/1e3}async function pe(e){let t=await _e(e.device,e.appBundleId);await p(_.dirname(e.outPath));let n=P({device:e.device,template:e.template,target:t.pids,outPath:e.outPath}),a=new Date().toISOString(),o=await F(n,e.outPath,{device:e.device,appBundleId:e.appBundleId,failureMessage:`Failed to start Apple xctrace ${e.mode} capture for ${e.appBundleId}`},async()=>{let e=r(`xcrun`,n,{allowFailure:!0}),t=await ye(e.wait);return t?{failure:t}:{recorded:e}});return{kind:`xctrace`,mode:e.mode,template:e.template,outPath:e.outPath,appBundleId:e.appBundleId,deviceId:e.device.id,platform:i(e.device),targetPids:t.pids,targetProcesses:t.processNames,startedAt:a,child:o.child,wait:o.wait}}async function me(e,t=e.outPath){t!==e.outPath&&await p(_.dirname(t));let r=n(await L(e,{failOnForcedKill:!0}),`Failed to stop Apple xctrace ${e.mode} capture`,t=>({tracePath:e.outPath,captureCleanedUp:!0,hint:B(t.stdout,t.stderr)}));return t!==e.outPath&&await te(e.outPath,t).catch(async()=>{await ie(e.outPath,t),await h(e.outPath)}),await z(t,{message:`xctrace produced no trace data`,hint:`Keep the Apple device unlocked and connected, keep the app active, then retry perf.`,appBundleId:e.appBundleId,deviceId:e.deviceId,stdout:r.stdout,stderr:r.stderr}),{kind:`xctrace`,mode:e.mode,template:e.template,outPath:t,appBundleId:e.appBundleId,deviceId:e.deviceId,platform:e.platform,targetPids:e.targetPids,targetProcesses:e.targetProcesses,startedAt:e.startedAt,endedAt:new Date().toISOString()}}async function he(e){return await L(e,{failOnForcedKill:!1})}async function ge(t){let n=await f(`agent-device-xctrace-report-`),r=_.join(n,`trace-toc.xml`),i=_.join(n,`time-profile.xml`);try{let n=await N({tracePath:t.tracePath,outPath:r,query:`toc`,failureMessage:`Failed to export Apple xctrace report metadata`,failureDetails:{tracePath:t.tracePath}}),a=await N({tracePath:t.tracePath,outPath:i,query:{schema:`time-profile`},failureMessage:`Failed to export Apple xctrace Time Profiler samples`,failureDetails:{tracePath:t.tracePath}}),o=be({...t,tocXml:n,timeProfileXml:a});if(o.summary.sampleCount===0)throw new e(`COMMAND_FAILED`,`Apple xctrace CPU report contained no samples`,{tracePath:t.tracePath,tableSchemas:o.summary.tableSchemas,hint:`Keep the app active while recording, then retry. Open the raw trace in Instruments if it still contains no Time Profiler samples.`});return await p(_.dirname(t.outPath)),await ee(t.outPath,`${JSON.stringify(o,null,2)}\n`),o}finally{await h(n).catch(()=>{})}}async function M(e){let t=P({device:e.device,template:e.template,target:e.target,timeLimit:e.timeLimit,outPath:e.tracePath}),{result:n,...r}=await F(t,e.tracePath,e,async()=>{let e=new Date().toISOString(),n=await g(t,{allowFailure:!0,timeoutMs:6e4});return n.exitCode===0?{recorded:{result:n,startedAt:e,endedAt:new Date().toISOString(),capturedAtMs:Date.now()}}:{failure:n}});return e.requireTraceData&&await z(e.tracePath,{message:`${e.failureMessage}: xctrace produced no trace data`,hint:`Keep the iOS device unlocked and connected by cable, keep the app active, then retry perf.`,appBundleId:e.appBundleId,deviceId:e.device.id,stdout:n.stdout,stderr:n.stderr}),r}async function N(e){let t=[`xctrace`,`export`,`--input`,e.tracePath,...e.query===`toc`?[`--toc`]:[`--xpath`,`/trace-toc/run/data/table[@schema="${e.query.schema}"]`],`--output`,e.outPath];return n(await g(t,{allowFailure:!0,timeoutMs:15e3}),e.failureMessage,n=>({cmd:`xcrun`,args:t,...e.failureDetails,hint:B(n.stdout,n.stderr)})),await re(e.outPath)}async function _e(t,n){if(!s(t.platform))throw new e(`UNSUPPORTED_OPERATION`,`Apple xctrace perf is not supported on Android.`,{platform:t.platform,hint:`Android native profiling belongs to the Android perf rollout and is not implemented under Apple xctrace.`});let{readAppleProcessSamples:r,resolveAppleExecutable:i,resolveIosDevicePerfTarget:a}=await import(`./perf-target.js`);if(o(t)&&t.kind===`device`){let e=await a(t,n);return{pids:e.map(e=>e.pid),processNames:c(e.map(e=>_.basename(v(e.executable))))}}let l=await i(t,n),u=await r(t,l);if(u.length===0)throw new e(`COMMAND_FAILED`,`No running process found for ${n}`,{appBundleId:n,deviceId:t.id,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf.`});return{pids:u.map(e=>e.pid),processNames:[l.executableName]}}function P(e){return[`xctrace`,`record`,`--template`,e.template,...o(e.device)?[`--device`,e.device.id]:[],...e.target===`all-processes`?[`--all-processes`]:e.target.flatMap(e=>[`--attach`,String(e)]),...e.timeLimit?[`--time-limit`,e.timeLimit]:[],`--output`,e.outPath,`--quiet`,`--no-prompt`]}async function F(n,r,i,a){for(let o=1;;o+=1){await ve(r,o);let s=await a();if(`recorded`in s)return s.recorded;if(o<3&&I(s.failure))continue;let{failure:c}=s;throw new e(`COMMAND_FAILED`,i.failureMessage,t(c,{cmd:`xcrun`,args:n,appBundleId:i.appBundleId,deviceId:i.device.id,hint:B(c.stdout,c.stderr)}))}}function I(e){let t=`${e.stdout}\n${e.stderr}`.toLowerCase();return t.includes(`_lockkperf`)||t.includes(`could not lock kperf`)||t.includes(`likely another session just started`)}async function ve(e,t){t<=1||(await h(e).catch(()=>{}),await new Promise(e=>setTimeout(e,1500)))}async function ye(e){return await Promise.race([e,new Promise(e=>setTimeout(e,500))])}async function L(t,n){t.child.kill(`SIGINT`);let r=await R(t.wait,45e3);if(r)return r;t.child.kill(`SIGKILL`);let i=await R(t.wait,5e3);if(i&&!n.failOnForcedKill)return i;throw i?new e(`COMMAND_FAILED`,`Timed out waiting for Apple xctrace capture to stop`,{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr,tracePath:t.outPath,captureCleanedUp:!0,forcedKill:!0,hint:`xctrace did not finish after SIGINT, so it was force-killed. Retry the perf command after confirming no other xctrace session is active.`}):new e(`COMMAND_FAILED`,`Timed out waiting for Apple xctrace capture to stop after SIGKILL`,{tracePath:t.outPath,captureCleanedUp:!1,forcedKill:!0,hint:`xctrace did not exit after SIGKILL. Inspect running xctrace processes before retrying.`})}async function R(e,t){return await Promise.race([e,new Promise(e=>setTimeout(e,t))])}async function z(t,n){let r=await m(t).catch(()=>null);if(!(r?.isDirectory()===!0?(await ne(t).catch(()=>[])).length>0:(r?.size??0)>0))throw new e(`COMMAND_FAILED`,n.message,{tracePath:t,appBundleId:n.appBundleId,deviceId:n.deviceId,stdout:n.stdout,stderr:n.stderr,hint:n.hint})}function be(e){let t=l(e.tocXml),n=b(t,e=>e.name===`run`),r=c(b(t,e=>e.name===`table`).map(e=>e.attributes.schema).filter(e=>typeof e==`string`&&e.length>0)).sort(),i=k(e.timeProfileXml);return{kind:`xctrace`,mode:`cpu-profile`,template:e.template,tracePath:e.tracePath,reportPath:e.outPath,appBundleId:e.appBundleId,generatedAt:new Date().toISOString(),summary:{runCount:n.length,tableSchemas:r,...i}}}function B(e,t){let n=oe(e,t);if(n)return n;let r=`${e}\n${t}`.toLowerCase();return r.includes(`no device matched`)||r.includes(`failed to find device`)?se:r.includes(`timed out`)?`Keep the iOS device unlocked and connected by cable, keep the app active, then retry perf.`:`Ensure the iOS device is unlocked, trusted, visible to xctrace, and the target app stays active while perf samples it.`}const V=`xctrace-animation-hitches`;function xe(e){let t=Se(e.frameLifetimesXml),n=Ce(e.displayInfoXml),r=we(e.hitchesXml).filter(t=>De(t,e.processIds,e.processNames)),i=r.length,a=Math.max(0,Math.round(Date.parse(e.windowEndedAt)-Date.parse(e.windowStartedAt))),o=H(r,Date.parse(e.windowStartedAt));return{droppedFramePercent:t>0?u(i/t*100):0,droppedFrameCount:i,totalFrameCount:t,sampleWindowMs:a,windowStartedAt:e.windowStartedAt,windowEndedAt:e.windowEndedAt,measuredAt:e.measuredAt,method:V,matchedProcesses:c(r.map(e=>e.processName).filter(e=>typeof e==`string`&&e.length>0)),frameDeadlineMs:n===void 0?void 0:d(1e3/n),refreshRateHz:n,worstWindows:o.length>0?o:void 0}}function Se(e){return ke(e,`hitches-frame-lifetimes`).length}function Ce(e){if(!e)return;let{rows:t,schema:n}=U(e,`device-display-info`),r=n.indexOf(`max-refresh-rate`);if(r<0)return;let i=new Map;for(let e of t){w(e.children,i);let t=C(e.children[r],i);if(t!==null&&t>0)return t}}function we(e){let t=l(e),n=Te(t);if(!n)return[];let r=new Map;return b(t,e=>e.name===`row`).map(e=>Ee(e,n,r)).filter(e=>!!e)}function Te(e){let t=x(e,`hitches`),n={start:t.indexOf(`start`),duration:t.indexOf(`duration`),process:t.indexOf(`process`),isSystem:t.indexOf(`is-system`)};return Object.values(n).every(e=>e>=0)?n:null}function Ee(e,t,n){if(w(e.children,n),Ae(e.children[t.isSystem],n)===!0)return null;let r=C(e.children[t.start],n),i=C(e.children[t.duration],n);if(r===null||i===null)return null;let a=T(e.children[t.process],n);return{startNs:r,durationNs:i,pid:a?.pid,processName:a?.name}}function De(e,t,n){return e.pid!==void 0&&t.includes(e.pid)?!0:e.processName?n.includes(e.processName):!1}function H(e,t){if(e.length===0)return[];let n=[...e].sort((e,t)=>e.startNs-t.startNs),r=[],i=[];for(let e of n){let t=i.at(-1);if(!t||e.startNs-(t.startNs+t.durationNs)<=5e8){i.push(e);continue}r.push(i),i=[e]}return i.length>0&&r.push(i),r.map(e=>Oe(e,t)).sort((e,t)=>t.missedDeadlineFrameCount-e.missedDeadlineFrameCount||t.worstFrameMs-e.worstFrameMs).slice(0,3).sort((e,t)=>e.startOffsetMs-t.startOffsetMs)}function Oe(e,t){let n=Math.min(...e.map(e=>e.startNs)),r=Math.max(...e.map(e=>e.startNs+e.durationNs)),i=Math.max(0,Math.round(n/1e6)),a=Math.max(i,Math.round(r/1e6));return{startOffsetMs:i,endOffsetMs:a,startAt:new Date(t+i).toISOString(),endAt:new Date(t+a).toISOString(),missedDeadlineFrameCount:e.length,worstFrameMs:d(Math.max(...e.map(e=>e.durationNs))/1e6)}}function ke(e,t){return U(e,t).rows}function U(e,t){let n=l(e),r=x(n,t);return{rows:r.length===0?[]:b(n,e=>e.name===`row`),schema:r}}function Ae(e,t){let n=C(e,t);return n===null?null:n!==0}const W=`ps-process-snapshot`,G=`xctrace-activity-monitor`,K=`leaks-output-graph`,q=12e4;async function je(t,n){if(o(t)&&t.kind===`device`)return await Ve(t,n);let{readAppleProcessSamples:r,resolveAppleExecutable:i}=await import(`./perf-target.js`),a=await i(t,n),s=await r(t,a);if(s.length===0)throw new e(`COMMAND_FAILED`,`No running process found for ${n}`,{appBundleId:n,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf.`});let c=new Date().toISOString();return $({residentMemoryKb:s.reduce((e,t)=>e+t.rssKb,0),measuredAt:c,matchedProcesses:[a.executableName],memoryMethod:W})}async function Me(n,r,i){let a=Y(n);if(!a.memgraph)return{available:!1,kind:`memgraph`,reason:a.reason,hint:a.hint,support:a};let o=await Ge(n,r,a);if(o.available===!1)return o;let{process:s}=o;await p(_.dirname(i));let c=await Fe(i),l;try{l=await Ne(n,i,s.pid)}catch(e){throw await J(i,c),Pe(n,r,s,i,e)}if(l.exitCode!==0)throw await J(i,c),new e(`COMMAND_FAILED`,`Failed to capture Apple memgraph for ${r}`,t(l,{kind:`memgraph`,appBundleId:r,pid:s.pid,processName:_.basename(Z(s.command)),path:i,hint:Q(n,l.stdout,l.stderr)}));let u=await m(i).catch(()=>null);if(!u?.isFile()||u.size<=0)throw await J(i,c),new e(`COMMAND_FAILED`,`Apple memgraph artifact is missing or empty`,{kind:`memgraph`,appBundleId:r,pid:s.pid,path:i,hint:`Retry with a writable --out path. If the file is still empty, check free disk space at path.`});return{available:!0,kind:`memgraph`,path:i,sizeBytes:u.size,measuredAt:new Date().toISOString(),method:K,appBundleId:r,pid:s.pid,processName:_.basename(Z(s.command)),support:a}}async function Ne(e,t,n){return a(e)?await ae(`leaks`,[`--outputGraph=${t}`,String(n)],{allowFailure:!0,timeoutMs:q}):await g(ce(e,[`spawn`,e.id,`leaks`,`--outputGraph=${t}`,String(n)]),{allowFailure:!0,timeoutMs:q})}function Pe(t,n,r,i,a){if(a instanceof e){let o=a.details??{};return new e(a.code,`Failed to capture Apple memgraph for ${n}`,{...o,kind:`memgraph`,appBundleId:n,pid:r.pid,processName:_.basename(Z(r.command)),path:i,hint:Q(t,typeof o.stdout==`string`?o.stdout:``,typeof o.stderr==`string`&&o.stderr.length>0?o.stderr:a.message)},a)}return new e(`COMMAND_FAILED`,`Failed to capture Apple memgraph for ${n}`,{kind:`memgraph`,appBundleId:n,pid:r.pid,processName:_.basename(Z(r.command)),path:i,hint:`Retry perf memory snapshot. If it still fails, the Cause line names the leaks failure.`},a)}async function Fe(e){return await m(e).then(e=>e.isFile()).catch(()=>!1)}async function J(e,t){t||await h(e).catch(()=>{})}async function Ie(t,n){if(!o(t)||t.kind!==`device`)throw new e(`COMMAND_FAILED`,`Apple frame-health sampling is currently available only on connected iOS devices.`,{metric:`fps`,platform:i(t),deviceKind:t.kind});let{resolveIosDevicePerfTarget:r}=await import(`./perf-target.js`),a=await r(t,n),s=await ze(t,n,a);return xe({hitchesXml:s.hitchesXml,frameLifetimesXml:s.frameLifetimesXml,displayInfoXml:s.displayInfoXml,processIds:a.map(e=>e.pid),processNames:c(a.map(e=>_.basename(v(e.executable)))),windowStartedAt:s.windowStartedAt,windowEndedAt:s.windowEndedAt,measuredAt:s.windowEndedAt})}function Le(e){return o(e)&&e.kind===`device`?{method:V,description:`Rendered-frame hitch health from xctrace Animation Hitches on connected iOS devices. Dropped frames are counted from native hitch rows for the attached app process, with total frames from the same trace frame-lifetime table.`,unit:`percent`,primaryField:`droppedFramePercent`,window:`short 2s xctrace Animation Hitches record of the active app process`,resetsAfterRead:!1}:{method:V,description:`Unavailable on iOS simulators and macOS because local Apple tooling does not expose reliable app frame hitches for these targets.`,unit:`percent`,primaryField:`droppedFramePercent`}}function Re(e){if(o(e)&&e.kind===`device`)return{method:G,description:`Resident memory snapshot from a short xctrace Activity Monitor sample on the connected iOS device.`,unit:`kB`};let t=a(e)?`host ps for the running macOS app executable resolved from the bundle ID.`:`xcrun simctl spawn ps, with host ps fallback, for the running iOS simulator app executable resolved from the bundle ID.`;return{method:W,description:`Resident memory snapshot from ${t}`,unit:`kB`}}function Y(e){return o(e)&&e.kind===`device`?{platform:i(e),deviceKind:e.kind,memgraph:!1,method:K,reason:`Physical iOS device memgraph capture is not exposed through reliable local agent-device tooling.`,hint:`Use perf memory sample for a compact resident-memory reading, or reproduce on an iOS simulator/macOS target for memgraph capture.`}:o(e)&&e.kind===`simulator`?{platform:i(e),deviceKind:e.kind,memgraph:!0,method:K,reason:`iOS simulator processes are host-visible through simctl spawn leaks.`,hint:`Keep the simulator app running in the foreground while the memgraph is captured.`}:a(e)?{platform:i(e),deviceKind:e.kind,memgraph:!0,method:K,reason:`macOS app processes are host-visible to leaks --outputGraph.`,hint:`Grant Terminal/agent process permissions if macOS denies process inspection.`}:{platform:i(e),deviceKind:e.kind,memgraph:!1,method:K,reason:`Apple memgraph capture is available only for iOS simulator and macOS app sessions.`,hint:`Use perf memory sample on supported app sessions, or rerun against iOS simulator/macOS for memgraph capture.`}}async function ze(e,t,n){let r=await f(`agent-device-ios-frame-perf-`),i=_.join(r,`animation-hitches.trace`);try{let a=await M({device:e,appBundleId:t,tracePath:i,template:`Animation Hitches`,timeLimit:`2s`,target:n.map(e=>e.pid),requireTraceData:!0,failureMessage:`Failed to record iOS frame-health sample for ${t}`}),o={device:e,appBundleId:t,tracePath:i,tempDir:r};return{windowStartedAt:a.startedAt,windowEndedAt:a.endedAt,hitchesXml:await X(o,`hitches`),frameLifetimesXml:await X(o,`hitches-frame-lifetimes`),displayInfoXml:await X(o,`device-display-info`).catch(()=>void 0)}}finally{await h(r).catch(()=>{})}}async function X(e,t){return await N({tracePath:e.tracePath,outPath:_.join(e.tempDir,`${t}.xml`),query:{schema:t},failureMessage:`Failed to export iOS device ${t} data`,failureDetails:{appBundleId:e.appBundleId,deviceId:e.device.id}})}async function Be(t){let n=l(t),r=x(n,`activity-monitor-process-live`);if(r.length===0)throw new e(`COMMAND_FAILED`,`Failed to parse xctrace activity-monitor-process-live schema`);let i=r.indexOf(`pid`),a=r.indexOf(`process`),o=r.indexOf(`memory-real`);if(i<0||a<0||o<0)throw new e(`COMMAND_FAILED`,`xctrace activity-monitor-process-live export is missing expected columns`);let s=b(n,e=>e.name===`row`),c=[],u=new Map;for(let e of s){let t=e.children;if(t.length===0)continue;w(t,u);let n=C(t[i],u),r=T(t[a],u)?.name;n===null||!Number.isFinite(n)||!r||c.push({pid:n,processName:r,residentMemoryBytes:C(t[o],u)})}return c}async function Ve(t,n){let{resolveIosDevicePerfTarget:r}=await import(`./perf-target.js`),i=await r(t,n),a=await He(t,n),o=Ue(await Be(a.xml),i,n,t);if(o.residentMemoryBytes===null)throw new e(`COMMAND_FAILED`,`Incomplete Activity Monitor sample for ${n}`,{appBundleId:n,deviceId:t.id,hint:`Keep the app running in the foreground while perf samples the device, then retry.`});return $({residentMemoryKb:o.residentMemoryBytes/1024,measuredAt:new Date(a.capturedAtMs).toISOString(),matchedProcesses:o.matchedProcesses,memoryMethod:G})}async function He(e,t){let n=await f(`agent-device-ios-perf-`),r=_.join(n,`sample.trace`);try{return{capturedAtMs:(await M({device:e,appBundleId:t,tracePath:r,template:`Activity Monitor`,timeLimit:`1s`,target:`all-processes`,failureMessage:`Failed to record iOS device Activity Monitor sample for ${t}`})).capturedAtMs,xml:await X({device:e,appBundleId:t,tracePath:r,tempDir:n},`activity-monitor-process-live`)}}finally{await h(n).catch(()=>{})}}function Ue(t,n,r,i){let a=new Set(n.map(e=>e.pid)),o=new Set(n.map(e=>_.basename(v(e.executable)))),s=t.filter(e=>a.has(e.pid)||o.has(e.processName));if(s.length===0)throw new e(`COMMAND_FAILED`,`No Activity Monitor sample found for ${r}`,{appBundleId:r,deviceId:i.id,hint:`Keep the app running in the foreground while perf samples the device, then retry.`});let l=new Map;for(let e of s){let t=l.get(e.pid);if(!t){l.set(e.pid,e);continue}l.set(e.pid,{pid:e.pid,processName:e.processName||t.processName,residentMemoryBytes:qe(t.residentMemoryBytes,e.residentMemoryBytes)})}let u=[...l.values()],d=u.map(e=>e.residentMemoryBytes).filter(e=>e!==null);return{residentMemoryBytes:d.length>0?d.reduce((e,t)=>e+t,0):null,matchedProcesses:c(u.map(e=>e.processName))}}function Z(e){let[t=``]=e.trim().split(/\s+/,1);return t}async function We(t,n,r){let{readAppleProcessSamples:i}=await import(`./perf-target.js`),a=(await i(t,r)).sort((e,t)=>t.rssKb-e.rssKb)[0];if(a)return a;throw new e(`COMMAND_FAILED`,`No running process found for ${n}`,{kind:`memgraph`,appBundleId:n,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf memory snapshot.`})}async function Ge(e,t,n){try{let{resolveAppleExecutable:n}=await import(`./perf-target.js`);return{available:!0,process:await We(e,t,await n(e,t))}}catch(t){if(Ke(e,t))return{available:!1,kind:`memgraph`,reason:`iOS simulator memgraph capture needs process tools inside simctl spawn, but this simulator runtime did not provide ps.`,hint:`Use perf memory sample when available, or retry memgraph on a simulator runtime that includes process tools such as ps and leaks.`,support:{...n,memgraph:!1}};throw t}}function Ke(t,n){if(!o(t)||t.kind!==`simulator`||!(n instanceof e))return!1;let r=n.details??{},i=Array.isArray(r.args)?r.args.join(` `):``,a=typeof r.stderr==`string`?r.stderr:``,s=`${n.message}\n${a}`.toLowerCase();return i.includes(`simctl spawn`)&&i.includes(` ps `)&&s.includes(`no such file`)}function Q(e,t,n){let r=`${t}\n${n}`.toLowerCase();return r.includes(`timed out`)||r.includes(`timeout`)?`Apple memgraph capture can take longer than metric sampling. Keep the app running and retry; if it times out again, collect a smaller reproduction before capturing leaks --outputGraph.`:r.includes(`not found`)||r.includes(`no such file`)?`Install Xcode command line tools and ensure leaks is available, then retry.`:r.includes(`permission`)||r.includes(`denied`)||r.includes(`not authorized`)?a(e)?`Grant the agent terminal process permission to inspect this macOS app, then retry.`:`Keep the simulator booted and app running; if inspection is denied, retry with a debug simulator build.`:`Keep the app process running and retry perf memory snapshot. If it still fails, read the leaks output in error.details.stdout and error.details.stderr (--json).`}function $(e){return{residentMemoryKb:Math.round(e.residentMemoryKb),measuredAt:e.measuredAt,method:e.memoryMethod,matchedProcesses:e.matchedProcesses}}function qe(e,t){return e===null?t:t===null?e:Math.max(e,t)}export{Le as buildAppleFrameSamplingMetadata,Re as buildAppleMemorySamplingMetadata,Y as buildAppleMemorySnapshotSupport,Me as captureAppleMemorySnapshot,he as cleanupAppleXctracePerfCapture,I as isRetryableIosDeviceTraceRecordFailure,B as resolveIosDevicePerfHint,Ie as sampleAppleFramePerf,je as sampleAppleMemoryPerf,pe as startAppleXctracePerfCapture,me as stopAppleXctracePerfCapture,ge as writeAppleXctracePerfReport};
|
|
1
|
+
import{Nr as e}from"./sdk-batch.js";import{_ as t}from"./sdk-contracts.js";import{Z as n,et as r,it as i}from"./sdk-io.js";import{R as a,T as o,w as s,y as c}from"./sdk-device.js";import"./command.js";import{t as l}from"./parser.js";import{n as u,t as d}from"./numeric.js";import{E as ee,T as f,_ as te,b as ne,h as p,i as re,k as ie,o as m,u as h}from"./host-file.js";import{c as g,s as ae}from"./tool-provider.js";import{o as oe,t as se}from"./devicectl.js";import{r as ce}from"./simctl.js";import _ from"node:path";import{fileURLToPath as v}from"node:url";function y(e,t){for(let n of e){if(t(n))return n;let e=y(n.children,t);if(e)return e}}function b(e,t){let n=[];for(let r of e)t(r)&&n.push(r),n.push(...b(r.children,t));return n}function le(e,t){return e.children.find(e=>e.name===t)?.text??null}function x(e,t){let n=y(e,e=>e.name===`schema`&&e.attributes.name===t);return n?n.children.filter(e=>e.name===`col`).map(e=>le(e,`mnemonic`)??``):[]}function S(e){if(!e||e.children.some(e=>e.name===`sentinel`)||!e.text)return null;let t=Number(e.text);return Number.isFinite(t)?t:null}function C(e,t){return e?e.attributes.ref?t.get(e.attributes.ref)?.numberValue??null:S(e):null}function w(e,t){for(let n of e)w(n.children,t),n.attributes.id&&t.set(n.attributes.id,{numberValue:S(n),process:E(n)})}function T(e,t){return e?e.attributes.ref?t.get(e.attributes.ref)?.process??null:E(e):null}function E(e){if(!e||e.children.some(e=>e.name===`sentinel`))return null;let t=S(y(e.children,e=>e.name===`pid`)),n=(e.attributes.fmt??``).trim().replace(/\s+\(\d+\)$/,``).trim();return t===null&&n.length===0?null:{pid:t??void 0,name:n.length>0?n:void 0}}function ue(e){return new Map(b(e,e=>!!e.attributes.id).flatMap(e=>{let t=e.attributes.id;return t?[[t,e]]:[]}))}function D(e,t){if(e)return e.attributes.ref?t.get(e.attributes.ref):e}const O=new Set([`backtrace`,`tagged-backtrace`]);function k(e,t=10){let n=l(e),r=ue(n),i=new Map,a=0,o=0;for(let e of b(n,e=>e.name===`row`)){let t=A(e,r),n=de(e,r);if(t===void 0||!n)continue;let s=n.attributes.name?.trim()||`<unknown>`,c=fe(n,r),l=`${c??``}\u0000${s}`,u=i.get(l);i.set(l,{symbol:s,binary:c,weightNs:(u?.weightNs??0)+t}),a+=1,o+=t}let s=Math.max(0,Math.floor(t)),c=[...i.values()].sort((e,t)=>t.weightNs-e.weightNs||e.symbol.localeCompare(t.symbol)).slice(0,s).map(({symbol:e,binary:t,weightNs:n})=>({symbol:e,binary:t,selfSampleMs:j(n),selfSamplePercent:o>0?u(n/o*100):0}));return{sampleCount:a,totalSampleWeightMs:j(o),topFunctions:c}}function A(e,t){let n=D(e.children.find(e=>e.name===`weight`),t);if(!n?.text)return;let r=Number(n.text);return Number.isFinite(r)&&r>0?r:void 0}function de(e,t){return D(D(e.children.find(e=>O.has(e.name)),t)?.children.find(e=>e.name===`frame`),t)}function fe(e,t){return D(e.children.find(e=>e.name===`binary`),t)?.attributes.name?.trim()||void 0}function j(e){return Math.round(e/1e6*1e3)/1e3}async function pe(e){let t=await _e(e.device,e.appBundleId);await m(_.dirname(e.outPath));let n=P({device:e.device,template:e.template,target:t.pids,outPath:e.outPath}),r=new Date().toISOString(),o=await F(n,e.outPath,{device:e.device,appBundleId:e.appBundleId,failureMessage:`Failed to start Apple xctrace ${e.mode} capture for ${e.appBundleId}`},async()=>{let e=i(`xcrun`,n,{allowFailure:!0}),t=await ye(e.wait);return t?{failure:t}:{recorded:e}});return{kind:`xctrace`,mode:e.mode,template:e.template,outPath:e.outPath,appBundleId:e.appBundleId,deviceId:e.device.id,platform:a(e.device),targetPids:t.pids,targetProcesses:t.processNames,startedAt:r,child:o.child,wait:o.wait}}async function me(e,t=e.outPath){t!==e.outPath&&await m(_.dirname(t));let n=r(await L(e,{failOnForcedKill:!0}),`Failed to stop Apple xctrace ${e.mode} capture`,t=>({tracePath:e.outPath,captureCleanedUp:!0,hint:B(t.stdout,t.stderr)}));return t!==e.outPath&&await ee(e.outPath,t).catch(async()=>{await re(e.outPath,t),await f(e.outPath)}),await z(t,{message:`xctrace produced no trace data`,hint:`Keep the Apple device unlocked and connected, keep the app active, then retry perf.`,appBundleId:e.appBundleId,deviceId:e.deviceId,stdout:n.stdout,stderr:n.stderr}),{kind:`xctrace`,mode:e.mode,template:e.template,outPath:t,appBundleId:e.appBundleId,deviceId:e.deviceId,platform:e.platform,targetPids:e.targetPids,targetProcesses:e.targetProcesses,startedAt:e.startedAt,endedAt:new Date().toISOString()}}async function he(e){return await L(e,{failOnForcedKill:!1})}async function ge(e){let n=await p(`agent-device-xctrace-report-`),r=_.join(n,`trace-toc.xml`),i=_.join(n,`time-profile.xml`);try{let n=await N({tracePath:e.tracePath,outPath:r,query:`toc`,failureMessage:`Failed to export Apple xctrace report metadata`,failureDetails:{tracePath:e.tracePath}}),a=await N({tracePath:e.tracePath,outPath:i,query:{schema:`time-profile`},failureMessage:`Failed to export Apple xctrace Time Profiler samples`,failureDetails:{tracePath:e.tracePath}}),o=be({...e,tocXml:n,timeProfileXml:a});if(o.summary.sampleCount===0)throw new t(`COMMAND_FAILED`,`Apple xctrace CPU report contained no samples`,{tracePath:e.tracePath,tableSchemas:o.summary.tableSchemas,hint:`Keep the app active while recording, then retry. Open the raw trace in Instruments if it still contains no Time Profiler samples.`});return await m(_.dirname(e.outPath)),await ie(e.outPath,`${JSON.stringify(o,null,2)}\n`),o}finally{await f(n).catch(()=>{})}}async function M(e){let t=P({device:e.device,template:e.template,target:e.target,timeLimit:e.timeLimit,outPath:e.tracePath}),{result:n,...r}=await F(t,e.tracePath,e,async()=>{let e=new Date().toISOString(),n=await g(t,{allowFailure:!0,timeoutMs:6e4});return n.exitCode===0?{recorded:{result:n,startedAt:e,endedAt:new Date().toISOString(),capturedAtMs:Date.now()}}:{failure:n}});return e.requireTraceData&&await z(e.tracePath,{message:`${e.failureMessage}: xctrace produced no trace data`,hint:`Keep the iOS device unlocked and connected by cable, keep the app active, then retry perf.`,appBundleId:e.appBundleId,deviceId:e.device.id,stdout:n.stdout,stderr:n.stderr}),r}async function N(e){let t=[`xctrace`,`export`,`--input`,e.tracePath,...e.query===`toc`?[`--toc`]:[`--xpath`,`/trace-toc/run/data/table[@schema="${e.query.schema}"]`],`--output`,e.outPath];return r(await g(t,{allowFailure:!0,timeoutMs:15e3}),e.failureMessage,n=>({cmd:`xcrun`,args:t,...e.failureDetails,hint:B(n.stdout,n.stderr)})),await ne(e.outPath)}async function _e(n,r){if(!c(n.platform))throw new t(`UNSUPPORTED_OPERATION`,`Apple xctrace perf is not supported on Android.`,{platform:n.platform,hint:`Android native profiling belongs to the Android perf rollout and is not implemented under Apple xctrace.`});let{readAppleProcessSamples:i,resolveAppleExecutable:a,resolveIosDevicePerfTarget:o}=await import(`./perf-target.js`);if(s(n)&&n.kind===`device`){let t=await o(n,r);return{pids:t.map(e=>e.pid),processNames:e(t.map(e=>_.basename(v(e.executable))))}}let l=await a(n,r),u=await i(n,l);if(u.length===0)throw new t(`COMMAND_FAILED`,`No running process found for ${r}`,{appBundleId:r,deviceId:n.id,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf.`});return{pids:u.map(e=>e.pid),processNames:[l.executableName]}}function P(e){return[`xctrace`,`record`,`--template`,e.template,...s(e.device)?[`--device`,e.device.id]:[],...e.target===`all-processes`?[`--all-processes`]:e.target.flatMap(e=>[`--attach`,String(e)]),...e.timeLimit?[`--time-limit`,e.timeLimit]:[],`--output`,e.outPath,`--quiet`,`--no-prompt`]}async function F(e,r,i,a){for(let o=1;;o+=1){await ve(r,o);let s=await a();if(`recorded`in s)return s.recorded;if(o<3&&I(s.failure))continue;let{failure:c}=s;throw new t(`COMMAND_FAILED`,i.failureMessage,n(c,{cmd:`xcrun`,args:e,appBundleId:i.appBundleId,deviceId:i.device.id,hint:B(c.stdout,c.stderr)}))}}function I(e){let t=`${e.stdout}\n${e.stderr}`.toLowerCase();return t.includes(`_lockkperf`)||t.includes(`could not lock kperf`)||t.includes(`likely another session just started`)}async function ve(e,t){t<=1||(await f(e).catch(()=>{}),await new Promise(e=>setTimeout(e,1500)))}async function ye(e){return await Promise.race([e,new Promise(e=>setTimeout(e,500))])}async function L(e,n){e.child.kill(`SIGINT`);let r=await R(e.wait,45e3);if(r)return r;e.child.kill(`SIGKILL`);let i=await R(e.wait,5e3);if(i&&!n.failOnForcedKill)return i;throw i?new t(`COMMAND_FAILED`,`Timed out waiting for Apple xctrace capture to stop`,{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr,tracePath:e.outPath,captureCleanedUp:!0,forcedKill:!0,hint:`xctrace did not finish after SIGINT, so it was force-killed. Retry the perf command after confirming no other xctrace session is active.`}):new t(`COMMAND_FAILED`,`Timed out waiting for Apple xctrace capture to stop after SIGKILL`,{tracePath:e.outPath,captureCleanedUp:!1,forcedKill:!0,hint:`xctrace did not exit after SIGKILL. Inspect running xctrace processes before retrying.`})}async function R(e,t){return await Promise.race([e,new Promise(e=>setTimeout(e,t))])}async function z(e,n){let r=await h(e).catch(()=>null);if(!(r?.isDirectory()===!0?(await te(e).catch(()=>[])).length>0:(r?.size??0)>0))throw new t(`COMMAND_FAILED`,n.message,{tracePath:e,appBundleId:n.appBundleId,deviceId:n.deviceId,stdout:n.stdout,stderr:n.stderr,hint:n.hint})}function be(t){let n=l(t.tocXml),r=b(n,e=>e.name===`run`),i=e(b(n,e=>e.name===`table`).map(e=>e.attributes.schema).filter(e=>typeof e==`string`&&e.length>0)).sort(),a=k(t.timeProfileXml);return{kind:`xctrace`,mode:`cpu-profile`,template:t.template,tracePath:t.tracePath,reportPath:t.outPath,appBundleId:t.appBundleId,generatedAt:new Date().toISOString(),summary:{runCount:r.length,tableSchemas:i,...a}}}function B(e,t){let n=oe(e,t);if(n)return n;let r=`${e}\n${t}`.toLowerCase();return r.includes(`no device matched`)||r.includes(`failed to find device`)?se:r.includes(`timed out`)?`Keep the iOS device unlocked and connected by cable, keep the app active, then retry perf.`:`Ensure the iOS device is unlocked, trusted, visible to xctrace, and the target app stays active while perf samples it.`}const V=`xctrace-animation-hitches`;function xe(t){let n=Se(t.frameLifetimesXml),r=Ce(t.displayInfoXml),i=we(t.hitchesXml).filter(e=>De(e,t.processIds,t.processNames)),a=i.length,o=Math.max(0,Math.round(Date.parse(t.windowEndedAt)-Date.parse(t.windowStartedAt))),s=H(i,Date.parse(t.windowStartedAt));return{droppedFramePercent:n>0?u(a/n*100):0,droppedFrameCount:a,totalFrameCount:n,sampleWindowMs:o,windowStartedAt:t.windowStartedAt,windowEndedAt:t.windowEndedAt,measuredAt:t.measuredAt,method:V,matchedProcesses:e(i.map(e=>e.processName).filter(e=>typeof e==`string`&&e.length>0)),frameDeadlineMs:r===void 0?void 0:d(1e3/r),refreshRateHz:r,worstWindows:s.length>0?s:void 0}}function Se(e){return ke(e,`hitches-frame-lifetimes`).length}function Ce(e){if(!e)return;let{rows:t,schema:n}=U(e,`device-display-info`),r=n.indexOf(`max-refresh-rate`);if(r<0)return;let i=new Map;for(let e of t){w(e.children,i);let t=C(e.children[r],i);if(t!==null&&t>0)return t}}function we(e){let t=l(e),n=Te(t);if(!n)return[];let r=new Map;return b(t,e=>e.name===`row`).map(e=>Ee(e,n,r)).filter(e=>!!e)}function Te(e){let t=x(e,`hitches`),n={start:t.indexOf(`start`),duration:t.indexOf(`duration`),process:t.indexOf(`process`),isSystem:t.indexOf(`is-system`)};return Object.values(n).every(e=>e>=0)?n:null}function Ee(e,t,n){if(w(e.children,n),Ae(e.children[t.isSystem],n)===!0)return null;let r=C(e.children[t.start],n),i=C(e.children[t.duration],n);if(r===null||i===null)return null;let a=T(e.children[t.process],n);return{startNs:r,durationNs:i,pid:a?.pid,processName:a?.name}}function De(e,t,n){return e.pid!==void 0&&t.includes(e.pid)?!0:e.processName?n.includes(e.processName):!1}function H(e,t){if(e.length===0)return[];let n=[...e].sort((e,t)=>e.startNs-t.startNs),r=[],i=[];for(let e of n){let t=i.at(-1);if(!t||e.startNs-(t.startNs+t.durationNs)<=5e8){i.push(e);continue}r.push(i),i=[e]}return i.length>0&&r.push(i),r.map(e=>Oe(e,t)).sort((e,t)=>t.missedDeadlineFrameCount-e.missedDeadlineFrameCount||t.worstFrameMs-e.worstFrameMs).slice(0,3).sort((e,t)=>e.startOffsetMs-t.startOffsetMs)}function Oe(e,t){let n=Math.min(...e.map(e=>e.startNs)),r=Math.max(...e.map(e=>e.startNs+e.durationNs)),i=Math.max(0,Math.round(n/1e6)),a=Math.max(i,Math.round(r/1e6));return{startOffsetMs:i,endOffsetMs:a,startAt:new Date(t+i).toISOString(),endAt:new Date(t+a).toISOString(),missedDeadlineFrameCount:e.length,worstFrameMs:d(Math.max(...e.map(e=>e.durationNs))/1e6)}}function ke(e,t){return U(e,t).rows}function U(e,t){let n=l(e),r=x(n,t);return{rows:r.length===0?[]:b(n,e=>e.name===`row`),schema:r}}function Ae(e,t){let n=C(e,t);return n===null?null:n!==0}const W=`ps-process-snapshot`,G=`xctrace-activity-monitor`,K=`leaks-output-graph`,q=12e4;async function je(e,n){if(s(e)&&e.kind===`device`)return await Ve(e,n);let{readAppleProcessSamples:r,resolveAppleExecutable:i}=await import(`./perf-target.js`),a=await i(e,n),o=await r(e,a);if(o.length===0)throw new t(`COMMAND_FAILED`,`No running process found for ${n}`,{appBundleId:n,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf.`});let c=new Date().toISOString();return $({residentMemoryKb:o.reduce((e,t)=>e+t.rssKb,0),measuredAt:c,matchedProcesses:[a.executableName],memoryMethod:W})}async function Me(e,r,i){let a=Y(e);if(!a.memgraph)return{available:!1,kind:`memgraph`,reason:a.reason,hint:a.hint,support:a};let o=await Ge(e,r,a);if(o.available===!1)return o;let{process:s}=o;await m(_.dirname(i));let c=await Fe(i),l;try{l=await Ne(e,i,s.pid)}catch(t){throw await J(i,c),Pe(e,r,s,i,t)}if(l.exitCode!==0)throw await J(i,c),new t(`COMMAND_FAILED`,`Failed to capture Apple memgraph for ${r}`,n(l,{kind:`memgraph`,appBundleId:r,pid:s.pid,processName:_.basename(Z(s.command)),path:i,hint:Q(e,l.stdout,l.stderr)}));let u=await h(i).catch(()=>null);if(!u?.isFile()||u.size<=0)throw await J(i,c),new t(`COMMAND_FAILED`,`Apple memgraph artifact is missing or empty`,{kind:`memgraph`,appBundleId:r,pid:s.pid,path:i,hint:`Retry with a writable --out path. If the file is still empty, check free disk space at path.`});return{available:!0,kind:`memgraph`,path:i,sizeBytes:u.size,measuredAt:new Date().toISOString(),method:K,appBundleId:r,pid:s.pid,processName:_.basename(Z(s.command)),support:a}}async function Ne(e,t,n){return o(e)?await ae(`leaks`,[`--outputGraph=${t}`,String(n)],{allowFailure:!0,timeoutMs:q}):await g(ce(e,[`spawn`,e.id,`leaks`,`--outputGraph=${t}`,String(n)]),{allowFailure:!0,timeoutMs:q})}function Pe(e,n,r,i,a){if(a instanceof t){let o=a.details??{};return new t(a.code,`Failed to capture Apple memgraph for ${n}`,{...o,kind:`memgraph`,appBundleId:n,pid:r.pid,processName:_.basename(Z(r.command)),path:i,hint:Q(e,typeof o.stdout==`string`?o.stdout:``,typeof o.stderr==`string`&&o.stderr.length>0?o.stderr:a.message)},a)}return new t(`COMMAND_FAILED`,`Failed to capture Apple memgraph for ${n}`,{kind:`memgraph`,appBundleId:n,pid:r.pid,processName:_.basename(Z(r.command)),path:i,hint:`Retry perf memory snapshot. If it still fails, the Cause line names the leaks failure.`},a)}async function Fe(e){return await h(e).then(e=>e.isFile()).catch(()=>!1)}async function J(e,t){t||await f(e).catch(()=>{})}async function Ie(n,r){if(!s(n)||n.kind!==`device`)throw new t(`COMMAND_FAILED`,`Apple frame-health sampling is currently available only on connected iOS devices.`,{metric:`fps`,platform:a(n),deviceKind:n.kind});let{resolveIosDevicePerfTarget:i}=await import(`./perf-target.js`),o=await i(n,r),c=await ze(n,r,o);return xe({hitchesXml:c.hitchesXml,frameLifetimesXml:c.frameLifetimesXml,displayInfoXml:c.displayInfoXml,processIds:o.map(e=>e.pid),processNames:e(o.map(e=>_.basename(v(e.executable)))),windowStartedAt:c.windowStartedAt,windowEndedAt:c.windowEndedAt,measuredAt:c.windowEndedAt})}function Le(e){return s(e)&&e.kind===`device`?{method:V,description:`Rendered-frame hitch health from xctrace Animation Hitches on connected iOS devices. Dropped frames are counted from native hitch rows for the attached app process, with total frames from the same trace frame-lifetime table.`,unit:`percent`,primaryField:`droppedFramePercent`,window:`short 2s xctrace Animation Hitches record of the active app process`,resetsAfterRead:!1}:{method:V,description:`Unavailable on iOS simulators and macOS because local Apple tooling does not expose reliable app frame hitches for these targets.`,unit:`percent`,primaryField:`droppedFramePercent`}}function Re(e){if(s(e)&&e.kind===`device`)return{method:G,description:`Resident memory snapshot from a short xctrace Activity Monitor sample on the connected iOS device.`,unit:`kB`};let t=o(e)?`host ps for the running macOS app executable resolved from the bundle ID.`:`xcrun simctl spawn ps, with host ps fallback, for the running iOS simulator app executable resolved from the bundle ID.`;return{method:W,description:`Resident memory snapshot from ${t}`,unit:`kB`}}function Y(e){return s(e)&&e.kind===`device`?{platform:a(e),deviceKind:e.kind,memgraph:!1,method:K,reason:`Physical iOS device memgraph capture is not exposed through reliable local agent-device tooling.`,hint:`Use perf memory sample for a compact resident-memory reading, or reproduce on an iOS simulator/macOS target for memgraph capture.`}:s(e)&&e.kind===`simulator`?{platform:a(e),deviceKind:e.kind,memgraph:!0,method:K,reason:`iOS simulator processes are host-visible through simctl spawn leaks.`,hint:`Keep the simulator app running in the foreground while the memgraph is captured.`}:o(e)?{platform:a(e),deviceKind:e.kind,memgraph:!0,method:K,reason:`macOS app processes are host-visible to leaks --outputGraph.`,hint:`Grant Terminal/agent process permissions if macOS denies process inspection.`}:{platform:a(e),deviceKind:e.kind,memgraph:!1,method:K,reason:`Apple memgraph capture is available only for iOS simulator and macOS app sessions.`,hint:`Use perf memory sample on supported app sessions, or rerun against iOS simulator/macOS for memgraph capture.`}}async function ze(e,t,n){let r=await p(`agent-device-ios-frame-perf-`),i=_.join(r,`animation-hitches.trace`);try{let a=await M({device:e,appBundleId:t,tracePath:i,template:`Animation Hitches`,timeLimit:`2s`,target:n.map(e=>e.pid),requireTraceData:!0,failureMessage:`Failed to record iOS frame-health sample for ${t}`}),o={device:e,appBundleId:t,tracePath:i,tempDir:r};return{windowStartedAt:a.startedAt,windowEndedAt:a.endedAt,hitchesXml:await X(o,`hitches`),frameLifetimesXml:await X(o,`hitches-frame-lifetimes`),displayInfoXml:await X(o,`device-display-info`).catch(()=>void 0)}}finally{await f(r).catch(()=>{})}}async function X(e,t){return await N({tracePath:e.tracePath,outPath:_.join(e.tempDir,`${t}.xml`),query:{schema:t},failureMessage:`Failed to export iOS device ${t} data`,failureDetails:{appBundleId:e.appBundleId,deviceId:e.device.id}})}async function Be(e){let n=l(e),r=x(n,`activity-monitor-process-live`);if(r.length===0)throw new t(`COMMAND_FAILED`,`Failed to parse xctrace activity-monitor-process-live schema`);let i=r.indexOf(`pid`),a=r.indexOf(`process`),o=r.indexOf(`memory-real`);if(i<0||a<0||o<0)throw new t(`COMMAND_FAILED`,`xctrace activity-monitor-process-live export is missing expected columns`);let s=b(n,e=>e.name===`row`),c=[],u=new Map;for(let e of s){let t=e.children;if(t.length===0)continue;w(t,u);let n=C(t[i],u),r=T(t[a],u)?.name;n===null||!Number.isFinite(n)||!r||c.push({pid:n,processName:r,residentMemoryBytes:C(t[o],u)})}return c}async function Ve(e,n){let{resolveIosDevicePerfTarget:r}=await import(`./perf-target.js`),i=await r(e,n),a=await He(e,n),o=Ue(await Be(a.xml),i,n,e);if(o.residentMemoryBytes===null)throw new t(`COMMAND_FAILED`,`Incomplete Activity Monitor sample for ${n}`,{appBundleId:n,deviceId:e.id,hint:`Keep the app running in the foreground while perf samples the device, then retry.`});return $({residentMemoryKb:o.residentMemoryBytes/1024,measuredAt:new Date(a.capturedAtMs).toISOString(),matchedProcesses:o.matchedProcesses,memoryMethod:G})}async function He(e,t){let n=await p(`agent-device-ios-perf-`),r=_.join(n,`sample.trace`);try{return{capturedAtMs:(await M({device:e,appBundleId:t,tracePath:r,template:`Activity Monitor`,timeLimit:`1s`,target:`all-processes`,failureMessage:`Failed to record iOS device Activity Monitor sample for ${t}`})).capturedAtMs,xml:await X({device:e,appBundleId:t,tracePath:r,tempDir:n},`activity-monitor-process-live`)}}finally{await f(n).catch(()=>{})}}function Ue(n,r,i,a){let o=new Set(r.map(e=>e.pid)),s=new Set(r.map(e=>_.basename(v(e.executable)))),c=n.filter(e=>o.has(e.pid)||s.has(e.processName));if(c.length===0)throw new t(`COMMAND_FAILED`,`No Activity Monitor sample found for ${i}`,{appBundleId:i,deviceId:a.id,hint:`Keep the app running in the foreground while perf samples the device, then retry.`});let l=new Map;for(let e of c){let t=l.get(e.pid);if(!t){l.set(e.pid,e);continue}l.set(e.pid,{pid:e.pid,processName:e.processName||t.processName,residentMemoryBytes:qe(t.residentMemoryBytes,e.residentMemoryBytes)})}let u=[...l.values()],d=u.map(e=>e.residentMemoryBytes).filter(e=>e!==null);return{residentMemoryBytes:d.length>0?d.reduce((e,t)=>e+t,0):null,matchedProcesses:e(u.map(e=>e.processName))}}function Z(e){let[t=``]=e.trim().split(/\s+/,1);return t}async function We(e,n,r){let{readAppleProcessSamples:i}=await import(`./perf-target.js`),a=(await i(e,r)).sort((e,t)=>t.rssKb-e.rssKb)[0];if(a)return a;throw new t(`COMMAND_FAILED`,`No running process found for ${n}`,{kind:`memgraph`,appBundleId:n,hint:`Run open <app> for this session again to ensure the Apple app is active, then retry perf memory snapshot.`})}async function Ge(e,t,n){try{let{resolveAppleExecutable:n}=await import(`./perf-target.js`);return{available:!0,process:await We(e,t,await n(e,t))}}catch(t){if(Ke(e,t))return{available:!1,kind:`memgraph`,reason:`iOS simulator memgraph capture needs process tools inside simctl spawn, but this simulator runtime did not provide ps.`,hint:`Use perf memory sample when available, or retry memgraph on a simulator runtime that includes process tools such as ps and leaks.`,support:{...n,memgraph:!1}};throw t}}function Ke(e,n){if(!s(e)||e.kind!==`simulator`||!(n instanceof t))return!1;let r=n.details??{},i=Array.isArray(r.args)?r.args.join(` `):``,a=typeof r.stderr==`string`?r.stderr:``,o=`${n.message}\n${a}`.toLowerCase();return i.includes(`simctl spawn`)&&i.includes(` ps `)&&o.includes(`no such file`)}function Q(e,t,n){let r=`${t}\n${n}`.toLowerCase();return r.includes(`timed out`)||r.includes(`timeout`)?`Apple memgraph capture can take longer than metric sampling. Keep the app running and retry; if it times out again, collect a smaller reproduction before capturing leaks --outputGraph.`:r.includes(`not found`)||r.includes(`no such file`)?`Install Xcode command line tools and ensure leaks is available, then retry.`:r.includes(`permission`)||r.includes(`denied`)||r.includes(`not authorized`)?o(e)?`Grant the agent terminal process permission to inspect this macOS app, then retry.`:`Keep the simulator booted and app running; if inspection is denied, retry with a debug simulator build.`:`Keep the app process running and retry perf memory snapshot. If it still fails, read the leaks output in error.details.stdout and error.details.stderr (--json).`}function $(e){return{residentMemoryKb:Math.round(e.residentMemoryKb),measuredAt:e.measuredAt,method:e.memoryMethod,matchedProcesses:e.matchedProcesses}}function qe(e,t){return e===null?t:t===null?e:Math.max(e,t)}export{Le as buildAppleFrameSamplingMetadata,Re as buildAppleMemorySamplingMetadata,Y as buildAppleMemorySnapshotSupport,Me as captureAppleMemorySnapshot,he as cleanupAppleXctracePerfCapture,I as isRetryableIosDeviceTraceRecordFailure,B as resolveIosDevicePerfHint,Ie as sampleAppleFramePerf,je as sampleAppleMemoryPerf,pe as startAppleXctracePerfCapture,me as stopAppleXctracePerfCapture,ge as writeAppleXctracePerfReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,z as t}from"./sdk-contracts.js";async function n(e){try{return{available:!0,...await e}}catch(e){let n=t(e);return{available:!1,reason:n.message,error:n}}}function r(e,t){return{available:!1,reason:`No ${e} app ${t} is associated with this session. Run open <app> first.`}}function i(e,t,n,r){return{artifact:{available:!1,kind:t,reason:`${e} perf memory snapshot does not support ${t}.`,hint:r,support:n},support:n}}function a(){return new e(`INVALID_ARGS`,`perf memory snapshot requires an active app session`,{hint:`Run open <app> first so perf memory snapshot can resolve the app process.`})}function o(t){return Object.freeze({perfNativeCaptureStart:t.start,perfNativeCaptureReattach:t.reattach,perfNativeCaptureCleanup:t.cleanup,perfProfileReport:async n=>{if(n.kind!==t.expectedProfileKind)throw new e(`INVALID_ARGS`,`${t.platform} native perf requires --kind ${t.expectedProfileKind}, not ${n.kind}`);return await t.writeProfileReport(n)}})}export{i as a,n as i,r as n,a as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$t as e,Qt as t,Zt as n,nn as r,tn as i}from"./sdk-batch.js";import{_ as a}from"./sdk-contracts.js";import{m as o}from"./observability.js";function s(a){if(a.area===`frames`)return Object.freeze({kind:`frames`,request:a,use:n});if(a.area===`memory`)return a.action===`snapshot`?Object.freeze({kind:`memory-snapshot`,request:a,use:e}):Object.freeze({kind:`memory-sample`,request:a,use:t});if(a.area===`trace`)return a.action===`start`?Object.freeze({kind:`capture-start`,request:a,use:i}):Object.freeze({kind:`capture-stop`,request:a});switch(a.action){case`start`:return Object.freeze({kind:`capture-start`,request:a,use:i});case`stop`:return Object.freeze({kind:`capture-stop`,request:a});case`report`:return Object.freeze({kind:`profile-report`,request:a,use:r})}}function c(e){let t=e.positionals??[],n=t[0]?.toLowerCase();if(n===`frames`){let r=t[1]?.toLowerCase();if(r!==void 0&&r!==`sample`||t.length>2||e.kind!==void 0)throw new a(`INVALID_ARGS`,`perf action must be frames, memory sample|snapshot, cpu profile start|stop|report, or trace start|stop`);return Object.freeze({area:n,action:`sample`})}if(n===`memory`)return l(t,e);if(n===`cpu`)return u(t,e.outPath);if(n===`trace`)return d(t,e.outPath);throw new a(`INVALID_ARGS`,`perf requires frames, memory, cpu, or trace`)}function l(e,t){let n=(e[1]??`sample`).toLowerCase();if(n!==`sample`&&n!==`snapshot`)throw new a(`INVALID_ARGS`,`perf memory requires sample or snapshot`);if(t.kind!==void 0&&n!==`snapshot`)throw new a(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(n===`sample`&&e.length>2)throw new a(`INVALID_ARGS`,`perf memory sample does not accept additional positionals`);if(n===`snapshot`&&e.length>3)throw new a(`INVALID_ARGS`,`perf memory snapshot accepts at most one positional kind`);let r=t.kind??e[2];if(r!==void 0&&!o(r))throw new a(`INVALID_ARGS`,`perf memory snapshot --kind must be android-hprof or memgraph`);return Object.freeze({area:`memory`,action:n,...r===void 0?{}:{kind:r},...t.outPath===void 0?{}:{outPath:t.outPath}})}function u(e,t){if(e[1]?.toLowerCase()!==`profile`)throw new a(`INVALID_ARGS`,`perf cpu requires profile`);let n=e[2]?.toLowerCase();if(n!==`start`&&n!==`stop`&&n!==`report`)throw new a(`INVALID_ARGS`,`perf cpu profile action must be start, stop, or report`);let r=e[3]?.toLowerCase();if(r!==`xctrace`&&r!==`simpleperf`)throw new a(`INVALID_ARGS`,`perf cpu profile requires --kind xctrace or simpleperf`);let i=t??e[5];return Object.freeze({area:`cpu`,subject:`profile`,action:n,kind:r,...e[4]?{template:e[4]}:{},...i?{outPath:i}:{},...e[6]?{tracePath:e[6]}:{}})}function d(e,t){let n=e[1]?.toLowerCase();if(n!==`start`&&n!==`stop`)throw new a(`INVALID_ARGS`,`perf trace action must be start or stop`);let r=e[2]?.toLowerCase();if(r!==`xctrace`&&r!==`perfetto`)throw new a(`INVALID_ARGS`,`perf trace requires --kind xctrace or perfetto`);let i=t??e[4];return Object.freeze({area:`trace`,action:n,kind:r,...e[3]?{template:e[3]}:{},...i?{outPath:i}:{}})}export{s as n,c as t};
|
package/dist/src/perf-target.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`).map(e=>e.trim()).find(e=>e.endsWith(`.app`));if(!
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{M as t}from"./sdk-batch-runner.js";import{et as n}from"./sdk-io.js";import{T as r}from"./sdk-device.js";import"./command.js";import{c as i,s as a}from"./tool-provider.js";import{t as o}from"./physical-device-control.js";import{r as s}from"./simctl.js";import{r as c}from"./plist.js";import l from"node:path";import{fileURLToPath as u}from"node:url";const d=15e3;function f(e){let n=[];for(let r of t(e)){let e=r.match(/^(\d+)\s+([0-9]+(?:\.[0-9]+)?)\s+(\d+)\s+(.+)$/);if(!e)continue;let[t,i,a,o]=e.slice(1);if(t===void 0||i===void 0||a===void 0||o===void 0)continue;let s=Number(t),c=Number(i),l=Number(a),u=o.trim();!Number.isFinite(s)||!Number.isFinite(c)||!Number.isFinite(l)||n.push({pid:s,cpuPercent:c,rssKb:l,command:u})}return n}async function p(t,n){let i=r(t)?await h(n):await g(t,n),a=r(t)?l.join(i,`Contents`,`Info.plist`):l.join(i,`Info.plist`),o=await c(a,`CFBundleExecutable`);if(!o)throw new e(`COMMAND_FAILED`,`Failed to resolve executable for ${n}`,{appBundleId:n,appPath:i});return{executableName:o,executablePath:r(t)?l.join(i,`Contents`,`MacOS`,o):l.join(i,o)}}async function m(t,n){let{appBundleUrl:r,processes:i}=await o(t).resolveAppProcesses(t,n),a=u(r);if(i.length===0)throw new e(`COMMAND_FAILED`,`No running process found for ${n}`,{appBundleId:n,deviceId:t.id,appBundlePath:a,hint:`Run open <app> for this session again to ensure the iOS app is active, then retry perf.`});return i}async function h(t){let r=`kMDItemCFBundleIdentifier == "${t.replaceAll(`"`,String.raw`\"`)}"`,i=n(await a(`mdfind`,[r],{allowFailure:!0,timeoutMs:d}),`Failed to resolve macOS app bundle for ${t}`,{appBundleId:t}).stdout.split(`
|
|
2
|
+
`).map(e=>e.trim()).find(e=>e.endsWith(`.app`));if(!i)throw new e(`APP_NOT_INSTALLED`,`No macOS app found for ${t}`,{appBundleId:t});return i}async function g(t,r){let a=s(t,[`get_app_container`,t.id,r,`app`]),o=n(await i(a,{allowFailure:!0,timeoutMs:d}),`Failed to resolve iOS simulator app container for ${r}`,{appBundleId:r,hint:`Ensure the iOS simulator app is installed and booted, then retry perf.`}).stdout.trim();if(o.length===0)throw new e(`APP_NOT_INSTALLED`,`No iOS simulator app container found for ${r}`,{appBundleId:r});return o}async function _(e,t){let n=r(e)?await a(`ps`,[`-axo`,`pid=,%cpu=,rss=,command=`],{timeoutMs:d}):await v(s(e,[`spawn`,e.id,`ps`,`-axo`,`pid=,%cpu=,rss=,command=`])),{matchesAppleExecutableProcess:i}=await import(`./perf-process-identity.js`);return f(n.stdout).filter(e=>i(e.command,t))}async function v(e){let t=await i(e,{allowFailure:!0,timeoutMs:d});return t.exitCode===0?t:await a(`ps`,[`-axo`,`pid=,%cpu=,rss=,command=`],{timeoutMs:d})}export{_ as readAppleProcessSamples,p as resolveAppleExecutable,m as resolveIosDevicePerfTarget};
|
package/dist/src/perf.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{r as t}from"./hdc.js";function n(e){let t=e.trim().split(/\s+/)[0];if(!t||!/^\d+$/.test(t))return;let n=Number.parseInt(t,10);return n>0?n:void 0}function r(e){let t=o(e,`VmRSS`);if(t===void 0)return;let n=o(e,`VmHWM`);return{totalRssKb:t,...n===void 0?{}:{peakRssKb:n}}}async function i(n,i){let o=await a(n,i),s=r((await t(n,[`cat`,`/proc/${o}/status`],{timeoutMs:15e3})).stdout);if(!s)throw new e(`COMMAND_FAILED`,`Could not read resident memory for ${i}`,{hint:`Verify the app is still running, then retry perf memory sample.`,details:{bundleName:i,pid:o}});return{...s,measuredAt:new Date().toISOString(),method:`hdc-shell-proc-status`,pid:o}}async function a(r,i){let a=await t(r,[`pidof`,i],{allowFailure:!0,timeoutMs:15e3}),o=a.exitCode===0?n(a.stdout):void 0;if(o!==void 0)return o;throw new e(`COMMAND_FAILED`,`Could not find a running process for ${i}`,{hint:`Open the app in this session, then retry perf memory sample.`,details:{bundleName:i}})}function o(e,t){let n=e.match(RegExp(`^${t}:\\s+(\\d+)\\s+kB$`,`m`));if(!n?.[1])return;let r=Number.parseInt(n[1],10);return Number.isFinite(r)?r:void 0}export{i as sampleHarmonyMemoryPerf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e}from"./sdk-contracts.js";import{J as t,yt as n,z as r}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import"./retry.js";import{D as i}from"./host-file.js";import{d as a}from"./config.js";import{s as o}from"./tool-provider.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h}from"./devicectl.js";import{n as g,r as ee,t as _}from"./physical-device-constants.js";async function v(e,t){return await l(e,t)}async function y(e,t){await u(e,t)}async function b(e,t){return await s(e,t)}function x(e){return e.includes(`not installed`)||e.includes(`not found`)||e.includes(`no such file`)}const S=1e4;async function C(e,t,n={}){let r=[`device`,`process`,`launch`,`--device`,e.id];n.payloadUrl&&r.push(`--payload-url`,n.payloadUrl),r.push(t),n.launchArgs&&n.launchArgs.length>0&&r.push(`--`,...n.launchArgs),await m(r,{action:`launch iOS app`,deviceId:e.id})}async function w(n,r){try{let i=await A(n.id,g,_,r);if(i.status===`unreadable`)throw new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{kind:`probe_inconclusive`,deviceId:n.id,stdout:i.result.stdout,stderr:i.result.stderr,hint:`CoreDevice returned success but readiness JSON output was missing or invalid. Retry; if it persists restart Xcode and the iOS device.`});if(i.status===`reported`){let t=i.details.tunnelState?.toLowerCase();if(t===`connecting`)throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,{kind:`not_ready`,deviceId:n.id,tunnelState:t,hint:`Device tunnel is still connecting. Keep the device unlocked and connected by cable until it is fully available in Xcode Devices, then retry.`});if(!ee(t))throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,{kind:`not_ready`,deviceId:n.id,tunnelState:t,hint:`CoreDevice cannot reach the device. Connect it by cable or to the same network as this Mac, unlock it, and wait until Xcode Devices lists it as available, then retry.`});return}throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,t(i.result,{kind:`not_ready`,deviceId:n.id,tunnelState:i.details.tunnelState,hint:W(i.result.stdout,i.result.stderr)}))}catch(e){throw T(n.id,e)}}function T(t,n){return!(n instanceof e)||n.code!==`COMMAND_FAILED`?D(t,n):(typeof n.details?.kind==`string`?n.details.kind:``)===`not_ready`?n:E(t,n)}function E(t,n){let r=n.details??{},i=String(r.stdout??``),a=String(r.stderr??``),o=Number(r.timeoutMs??15e3),s=`CoreDevice did not respond within ${o}ms. Keep the device unlocked and trusted, then retry; if it persists restart Xcode and the iOS device.`;return new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{deviceId:t,cause:n.message,timeoutMs:o,stdout:i,stderr:a,hint:i||a?W(i,a):s},n)}function D(t,n){return new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{deviceId:t,hint:`Reconnect the device, keep it unlocked, and retry.`},n instanceof Error?n:void 0)}async function O(e,t){return(await k(e,t??S))?.tunnelIp??null}async function k(e,t,n){if(!(t>0))return null;let r=Math.max(1,Math.min(S,t));try{let t=await A(e.id,r,0,n);return t.status!==`reported`||t.details.outcome&&t.details.outcome!==`success`?null:t.details}catch{return null}}async function A(e,t,n=0,r){let i=Math.max(5,Math.ceil(t/1e3)),a=await c({jsonPrefix:`agent-device-coredevice-info`,args:[`devicectl`,`device`,`info`,`details`,`--device`,e,`--timeout`,String(i)],signal:r,timeoutMs:t+n});return a.ok?{status:`reported`,details:P(a.payload)}:a.reason===`unreadable-json`?{status:`unreadable`,result:a.result}:{status:`failed`,result:a.result,details:P(a.payload)}}function j(e){let t=e,n=N(t.device);return{connectionProperties:M(N(t.connectionProperties),N(n?.connectionProperties)),deviceProperties:M(N(t.deviceProperties),N(n?.deviceProperties))}}function M(e,t){if(!e)return t;if(!t)return e;let n={...t};for(let[t,r]of Object.entries(e))r!==void 0&&(n[t]=r);return n}function N(e){return e&&typeof e==`object`?e:void 0}function P(e){let t=N(e?.result);if(!t)return{};let{connectionProperties:n,deviceProperties:r}=j(t);return{...F(`outcome`,I(e?.info?.outcome)),...F(`tunnelState`,I(n?.tunnelState)),...F(`tunnelIp`,I(n?.tunnelIPAddress)),...F(`developerModeStatus`,I(r?.developerModeStatus)),...F(`developerDiskImageServicesAvailable`,L(r?.ddiServicesAvailable)),...F(`bootState`,I(r?.bootState))}}function F(e,t){return t===void 0?{}:{[e]:t}}function I(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function L(e){return typeof e==`boolean`?e:void 0}const R={developerModeOff:p,developerDiskImageUnavailable:d};function z(e){return e.tunnelState===`connected`&&e.bootState===`booted`}function B(e){return`The device reported its developer disk image as unavailable while it was not observable (tunnelState=${e.tunnelState??`unknown`}, bootState=${e.bootState??`unknown`}). Unlock it, keep it connected by cable until \`xcrun devicectl device info details\` reports tunnelState=connected and bootState=booted, then retry.`}async function V(e,t=1e4,n){let r=await k(e,t,n);if(!r)return{available:!1,reason:`device_readiness_unreadable`,hint:"Read the device state directly with `xcrun devicectl device info details --device <id> --json-output -`, keeping the device unlocked and connected by cable, then retry."};let i=H(r.developerModeStatus),a=U(r.developerDiskImageServicesAvailable);return a===`unavailable`&&i!==`disabled`&&!z(r)?{available:!1,reason:`device_readiness_unreadable`,hint:B(r)}:{available:!0,developerMode:i,developerDiskImage:a,remedies:R}}function H(e){let t=e?.toLowerCase();return t===`enabled`?`enabled`:t===`disabled`?`disabled`:`unknown`}function U(e){return e===!0?`available`:e===!1?`unavailable`:`unknown`}function W(e,t){return f(e,t)||(`${e}\n${t}`.toLowerCase().includes(`timed out waiting for all destinations`)?`Xcode destination did not become available in time. Keep device unlocked and retry.`:h)}async function G(t,n,i,s,c=a){let l=r.fromTimeoutMs(c),{resolveRunnerContainerBundleIds:u}=await import(`./src8.js`).then(e=>e.u),d={exitCode:1,stdout:``,stderr:``};for(let e of u(s))if(d=await o([`devicectl`,`device`,`copy`,`from`,`--device`,t.id,`--source`,n,`--destination`,i,`--domain-type`,`appDataContainer`,`--domain-identifier`,e],{allowFailure:!0,timeoutMs:te(l,c)}),d.exitCode===0)return;let f=d.stderr.trim()||d.stdout.trim()||`devicectl exited with code ${d.exitCode}`;throw new e(`COMMAND_FAILED`,`Failed to copy runner file from iOS device: ${f}`)}function te(t,n){let r=t.remainingMs();if(r>0)return r;throw new e(`COMMAND_FAILED`,`iOS runner file copy timed out after ${n}ms`,{timeoutMs:n,step:`runner file copy`})}function K(t){if(!(t instanceof e))return{reason:t instanceof Error?t.message:String(t)};let n=t.details??{},r=Array.isArray(n.args)?n.args.filter(e=>typeof e==`string`).join(` `):void 0;return{errorCode:t.code,reason:t.message,timeoutMs:typeof n.timeoutMs==`number`?n.timeoutMs:void 0,exitCode:typeof n.exitCode==`number`?n.exitCode:void 0,stderr:typeof n.stderr==`string`&&n.stderr.trim()?n.stderr:void 0,stdout:typeof n.stdout==`string`&&n.stdout.trim()?n.stdout:void 0,commandArgs:r}}function q(e){let t=e.details??{},n=typeof t.stdout==`string`?t.stdout:``,r=typeof t.stderr==`string`?t.stderr:``,i=Array.isArray(t.args)?t.args.filter(e=>typeof e==`string`).join(` `):``;return`${e.message}\n${n}\n${r}\n${i}`.toLowerCase()}async function J(e,t,n){if(!n.preferRunner)try{return await m([`device`,`capture`,`screenshot`,`--device`,e.id,`--destination`,t],{action:`capture iOS screenshot`,deviceId:e.id}),{iosPhysicalCaptureBackend:`coredevice`}}catch(t){if(!re(t))throw t;ne(e,t)}let r=await X(e,n,!1);return await Z(r,t)||await G(e,Q(r),t,n.env),{iosPhysicalCaptureBackend:`xctest`}}async function Y(t,n,r){if(await Z(await X(t,r,!0),n))return{iosPhysicalCaptureBackend:`xctest`};throw new e(`COMMAND_FAILED`,`Failed to capture iOS screenshot: XCTest runner returned no inline image`,{deviceId:t.id,backend:`xctest`})}async function X(e,t,n){return await t.runRunnerCommand(e,{command:`screenshot`,appBundleId:t.appBundleId,fullscreen:t.fullscreen,inlineScreenshot:n},t.runnerOptions??{})}async function Z(e,t){let n=e.imageBase64;return typeof n!=`string`||n.length===0?!1:(await i(t,Buffer.from(n,`base64`)),!0)}function Q(t){let n=t.message;if(typeof n==`string`&&n.length>0)return n;throw new e(`COMMAND_FAILED`,`Failed to capture iOS screenshot: runner returned no file path`)}function ne(e,t){n({level:`warn`,phase:`ios_screenshot_fallback`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,from:`devicectl_screenshot`,to:`runner`,...K(t)}})}function re(t){if(!(t instanceof e)||t.code!==`COMMAND_FAILED`)return!1;let n=q(t);return n.includes(`unknown option '--device'`)||n.includes(`unknown subcommand`)&&n.includes(`screenshot`)||n.includes(`unrecognized subcommand`)&&n.includes(`screenshot`)}const ie={coredevice:{backend:`coredevice`,ensureReady:w,listApps:v,launchApp:C,terminateApp:async(e,t)=>await y(e,t),resolveAppProcesses:b,captureScreenshot:J,copyRunnerFile:G,resolveTunnel:async(e,t)=>({tunnelIp:await O(e,t)}),readDeviceReadiness:V},xctest:{backend:`xctest`,ensureReady:ue,listApps:oe,launchApp:de,terminateApp:fe,resolveAppProcesses:$,captureScreenshot:Y,copyRunnerFile:le,resolveTunnel:se,readDeviceReadiness:ce}};function ae(e){return ie[e.iosPhysicalDeviceBackend===`xctest`?`xctest`:`coredevice`]}async function oe(t){throw new e(`UNSUPPORTED_OPERATION`,`App inventory is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`,hint:`Use an installed app bundle ID when opening the device.`})}async function $(t){throw new e(`UNSUPPORTED_OPERATION`,`Process lookup is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`,hint:`Use a CoreDevice-backed iOS device for performance sampling.`})}async function se(t){throw new e(`UNSUPPORTED_OPERATION`,`XCTest-backed physical iOS devices have no CoreDevice tunnel.`,{deviceId:t.id,backend:`xctest`,hint:`Connect the device by cable so it is reachable through usbmux.`})}async function ce(e){return{available:!1,reason:`device_readiness_unreadable`,hint:`This device is driven through XCTest (device ${e.id}), which does not report Developer Mode or developer disk image state. Check the device's own Settings if development tooling fails to start on it.`}}async function le(t,n,r,i){throw new e(`UNSUPPORTED_OPERATION`,`Runner file copy is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`})}async function ue(n,r){let i=[`xcdevice`,`wait`,`--both`,`--timeout=${Math.max(1,Math.ceil(g/1e3))}`,n.id],a=await o(i,{allowFailure:!0,signal:r,timeoutMs:g+_});if(a.exitCode!==0)throw new e(`COMMAND_FAILED`,`iOS device is not ready for XCTest automation`,t(a,{cmd:`xcrun`,args:i,deviceId:n.id,backend:`xctest`,hint:"Keep the device unlocked, trusted, connected, and visible in `xcrun xcdevice list`, then retry."}))}async function de(t,n,r){if(r.payloadUrl||r.launchArgs&&r.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`XCTest-backed physical iOS devices do not support deep links or launch arguments during open.`,{deviceId:t.id,backend:`xctest`,hint:`Open the installed app by bundle ID without a URL or --launch-args.`});await r.runRunnerCommand(t,{command:`activate`,appBundleId:n},r.runnerOptions??{})}async function fe(e,t,n){await n.runRunnerCommand(e,{command:`terminate`,appBundleId:t},n.runnerOptions??{})}export{x as i,q as n,K as r,ae as t};
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{H as t,St as n,Z as r}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import"./retry.js";import{O as i}from"./host-file.js";import{d as a}from"./config.js";import{c as o}from"./tool-provider.js";import{a as s,c,i as l,l as u,n as d,o as f,r as p,s as m,t as h}from"./devicectl.js";import{n as g,r as _,t as v}from"./physical-device-constants.js";async function y(e,t){return await l(e,t)}async function b(e,t){await u(e,t)}async function x(e,t){return await s(e,t)}function S(e){return e.includes(`not installed`)||e.includes(`not found`)||e.includes(`no such file`)}const C=1e4;async function w(e,t,n={}){let r=[`device`,`process`,`launch`,`--device`,e.id];n.payloadUrl&&r.push(`--payload-url`,n.payloadUrl),r.push(t),n.launchArgs&&n.launchArgs.length>0&&r.push(`--`,...n.launchArgs),await m(r,{action:`launch iOS app`,deviceId:e.id})}async function ee(t,n){try{let i=await k(t.id,g,v,n);if(i.status===`unreadable`)throw new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{kind:`probe_inconclusive`,deviceId:t.id,stdout:i.result.stdout,stderr:i.result.stderr,hint:`CoreDevice returned success but readiness JSON output was missing or invalid. Retry; if it persists restart Xcode and the iOS device.`});if(i.status===`reported`){let n=i.details.tunnelState?.toLowerCase();if(n===`connecting`)throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,{kind:`not_ready`,deviceId:t.id,tunnelState:n,hint:`Device tunnel is still connecting. Keep the device unlocked and connected by cable until it is fully available in Xcode Devices, then retry.`});if(!_(n))throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,{kind:`not_ready`,deviceId:t.id,tunnelState:n,hint:`CoreDevice cannot reach the device. Connect it by cable or to the same network as this Mac, unlock it, and wait until Xcode Devices lists it as available, then retry.`});return}throw new e(`COMMAND_FAILED`,`iOS device is not ready for automation`,r(i.result,{kind:`not_ready`,deviceId:t.id,tunnelState:i.details.tunnelState,hint:U(i.result.stdout,i.result.stderr)}))}catch(e){throw T(t.id,e)}}function T(t,n){return!(n instanceof e)||n.code!==`COMMAND_FAILED`?D(t,n):(typeof n.details?.kind==`string`?n.details.kind:``)===`not_ready`?n:E(t,n)}function E(t,n){let r=n.details??{},i=String(r.stdout??``),a=String(r.stderr??``),o=Number(r.timeoutMs??15e3),s=`CoreDevice did not respond within ${o}ms. Keep the device unlocked and trusted, then retry; if it persists restart Xcode and the iOS device.`;return new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{deviceId:t,cause:n.message,timeoutMs:o,stdout:i,stderr:a,hint:i||a?U(i,a):s},n)}function D(t,n){return new e(`COMMAND_FAILED`,`iOS device readiness probe failed`,{deviceId:t,hint:`Reconnect the device, keep it unlocked, and retry.`},n instanceof Error?n:void 0)}async function te(e,t){return(await O(e,t??C))?.tunnelIp??null}async function O(e,t,n){if(!(t>0))return null;let r=Math.max(1,Math.min(C,t));try{let t=await k(e.id,r,0,n);return t.status!==`reported`||t.details.outcome&&t.details.outcome!==`success`?null:t.details}catch{return null}}async function k(e,t,n=0,r){let i=Math.max(5,Math.ceil(t/1e3)),a=await c({jsonPrefix:`agent-device-coredevice-info`,args:[`devicectl`,`device`,`info`,`details`,`--device`,e,`--timeout`,String(i)],signal:r,timeoutMs:t+n});return a.ok?{status:`reported`,details:N(a.payload)}:a.reason===`unreadable-json`?{status:`unreadable`,result:a.result}:{status:`failed`,result:a.result,details:N(a.payload)}}function A(e){let t=e,n=M(t.device);return{connectionProperties:j(M(t.connectionProperties),M(n?.connectionProperties)),deviceProperties:j(M(t.deviceProperties),M(n?.deviceProperties))}}function j(e,t){if(!e)return t;if(!t)return e;let n={...t};for(let[t,r]of Object.entries(e))r!==void 0&&(n[t]=r);return n}function M(e){return e&&typeof e==`object`?e:void 0}function N(e){let t=M(e?.result);if(!t)return{};let{connectionProperties:n,deviceProperties:r}=A(t);return{...P(`outcome`,F(e?.info?.outcome)),...P(`tunnelState`,F(n?.tunnelState)),...P(`tunnelIp`,F(n?.tunnelIPAddress)),...P(`developerModeStatus`,F(r?.developerModeStatus)),...P(`developerDiskImageServicesAvailable`,I(r?.ddiServicesAvailable)),...P(`bootState`,F(r?.bootState))}}function P(e,t){return t===void 0?{}:{[e]:t}}function F(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function I(e){return typeof e==`boolean`?e:void 0}const L={developerModeOff:p,developerDiskImageUnavailable:d};function R(e){return e.tunnelState===`connected`&&e.bootState===`booted`}function z(e){return`The device reported its developer disk image as unavailable while it was not observable (tunnelState=${e.tunnelState??`unknown`}, bootState=${e.bootState??`unknown`}). Unlock it, keep it connected by cable until \`xcrun devicectl device info details\` reports tunnelState=connected and bootState=booted, then retry.`}async function B(e,t=1e4,n){let r=await O(e,t,n);if(!r)return{available:!1,reason:`device_readiness_unreadable`,hint:"Read the device state directly with `xcrun devicectl device info details --device <id> --json-output -`, keeping the device unlocked and connected by cable, then retry."};let i=V(r.developerModeStatus),a=H(r.developerDiskImageServicesAvailable);return a===`unavailable`&&i!==`disabled`&&!R(r)?{available:!1,reason:`device_readiness_unreadable`,hint:z(r)}:{available:!0,developerMode:i,developerDiskImage:a,remedies:L}}function V(e){let t=e?.toLowerCase();return t===`enabled`?`enabled`:t===`disabled`?`disabled`:`unknown`}function H(e){return e===!0?`available`:e===!1?`unavailable`:`unknown`}function U(e,t){return f(e,t)||(`${e}\n${t}`.toLowerCase().includes(`timed out waiting for all destinations`)?`Xcode destination did not become available in time. Keep device unlocked and retry.`:h)}async function W(n,r,i,s,c=a){let l=t.fromTimeoutMs(c),{resolveRunnerContainerBundleIds:u}=await import(`./src8.js`).then(e=>e.u),d={exitCode:1,stdout:``,stderr:``};for(let e of u(s))if(d=await o([`devicectl`,`device`,`copy`,`from`,`--device`,n.id,`--source`,r,`--destination`,i,`--domain-type`,`appDataContainer`,`--domain-identifier`,e],{allowFailure:!0,timeoutMs:G(l,c)}),d.exitCode===0)return;let f=d.stderr.trim()||d.stdout.trim()||`devicectl exited with code ${d.exitCode}`;throw new e(`COMMAND_FAILED`,`Failed to copy runner file from iOS device: ${f}`)}function G(t,n){let r=t.remainingMs();if(r>0)return r;throw new e(`COMMAND_FAILED`,`iOS runner file copy timed out after ${n}ms`,{timeoutMs:n,step:`runner file copy`})}function K(t){if(!(t instanceof e))return{reason:t instanceof Error?t.message:String(t)};let n=t.details??{},r=Array.isArray(n.args)?n.args.filter(e=>typeof e==`string`).join(` `):void 0;return{errorCode:t.code,reason:t.message,timeoutMs:typeof n.timeoutMs==`number`?n.timeoutMs:void 0,exitCode:typeof n.exitCode==`number`?n.exitCode:void 0,stderr:typeof n.stderr==`string`&&n.stderr.trim()?n.stderr:void 0,stdout:typeof n.stdout==`string`&&n.stdout.trim()?n.stdout:void 0,commandArgs:r}}function q(e){let t=e.details??{},n=typeof t.stdout==`string`?t.stdout:``,r=typeof t.stderr==`string`?t.stderr:``,i=Array.isArray(t.args)?t.args.filter(e=>typeof e==`string`).join(` `):``;return`${e.message}\n${n}\n${r}\n${i}`.toLowerCase()}async function J(e,t,n){if(!n.preferRunner)try{return await m([`device`,`capture`,`screenshot`,`--device`,e.id,`--destination`,t],{action:`capture iOS screenshot`,deviceId:e.id}),{iosPhysicalCaptureBackend:`coredevice`}}catch(t){if(!re(t))throw t;ne(e,t)}let r=await X(e,n,!1);return await Z(r,t)||await W(e,Q(r),t,n.env),{iosPhysicalCaptureBackend:`xctest`}}async function Y(t,n,r){if(await Z(await X(t,r,!0),n))return{iosPhysicalCaptureBackend:`xctest`};throw new e(`COMMAND_FAILED`,`Failed to capture iOS screenshot: XCTest runner returned no inline image`,{deviceId:t.id,backend:`xctest`})}async function X(e,t,n){return await t.runRunnerCommand(e,{command:`screenshot`,appBundleId:t.appBundleId,fullscreen:t.fullscreen,inlineScreenshot:n},t.runnerOptions??{})}async function Z(e,t){let n=e.imageBase64;return typeof n!=`string`||n.length===0?!1:(await i(t,Buffer.from(n,`base64`)),!0)}function Q(t){let n=t.message;if(typeof n==`string`&&n.length>0)return n;throw new e(`COMMAND_FAILED`,`Failed to capture iOS screenshot: runner returned no file path`)}function ne(e,t){n({level:`warn`,phase:`ios_screenshot_fallback`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,from:`devicectl_screenshot`,to:`runner`,...K(t)}})}function re(t){if(!(t instanceof e)||t.code!==`COMMAND_FAILED`)return!1;let n=q(t);return n.includes(`unknown option '--device'`)||n.includes(`unknown subcommand`)&&n.includes(`screenshot`)||n.includes(`unrecognized subcommand`)&&n.includes(`screenshot`)}const ie={coredevice:{backend:`coredevice`,ensureReady:ee,listApps:y,launchApp:w,terminateApp:async(e,t)=>await b(e,t),resolveAppProcesses:x,captureScreenshot:J,copyRunnerFile:W,resolveTunnel:async(e,t)=>({tunnelIp:await te(e,t)}),readDeviceReadiness:B},xctest:{backend:`xctest`,ensureReady:ue,listApps:oe,launchApp:de,terminateApp:fe,resolveAppProcesses:$,captureScreenshot:Y,copyRunnerFile:le,resolveTunnel:se,readDeviceReadiness:ce}};function ae(e){return ie[e.iosPhysicalDeviceBackend===`xctest`?`xctest`:`coredevice`]}async function oe(t){throw new e(`UNSUPPORTED_OPERATION`,`App inventory is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`,hint:`Use an installed app bundle ID when opening the device.`})}async function $(t){throw new e(`UNSUPPORTED_OPERATION`,`Process lookup is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`,hint:`Use a CoreDevice-backed iOS device for performance sampling.`})}async function se(t){throw new e(`UNSUPPORTED_OPERATION`,`XCTest-backed physical iOS devices have no CoreDevice tunnel.`,{deviceId:t.id,backend:`xctest`,hint:`Connect the device by cable so it is reachable through usbmux.`})}async function ce(e){return{available:!1,reason:`device_readiness_unreadable`,hint:`This device is driven through XCTest (device ${e.id}), which does not report Developer Mode or developer disk image state. Check the device's own Settings if development tooling fails to start on it.`}}async function le(t,n,r,i){throw new e(`UNSUPPORTED_OPERATION`,`Runner file copy is unavailable on this XCTest-backed physical iOS device.`,{deviceId:t.id,backend:`xctest`})}async function ue(t,n){let i=[`xcdevice`,`wait`,`--both`,`--timeout=${Math.max(1,Math.ceil(g/1e3))}`,t.id],a=await o(i,{allowFailure:!0,signal:n,timeoutMs:g+v});if(a.exitCode!==0)throw new e(`COMMAND_FAILED`,`iOS device is not ready for XCTest automation`,r(a,{cmd:`xcrun`,args:i,deviceId:t.id,backend:`xctest`,hint:"Keep the device unlocked, trusted, connected, and visible in `xcrun xcdevice list`, then retry."}))}async function de(t,n,r){if(r.payloadUrl||r.launchArgs&&r.launchArgs.length>0)throw new e(`UNSUPPORTED_OPERATION`,`XCTest-backed physical iOS devices do not support deep links or launch arguments during open.`,{deviceId:t.id,backend:`xctest`,hint:`Open the installed app by bundle ID without a URL or --launch-args.`});await r.runRunnerCommand(t,{command:`activate`,appBundleId:n},r.runnerOptions??{})}async function fe(e,t,n){await n.runRunnerCommand(e,{command:`terminate`,appBundleId:t},n.runnerOptions??{})}export{K as n,S as r,ae as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{J as t,St as n,X as r,Z as i,dt as a,it as o,pt as s,rt as c}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import{m as l}from"./adb-executor.js";import{t as u}from"./device-shell.js";import{c as d}from"./adb-transport.js";import"./mechanics.js";import{createHash as f,randomUUID as p}from"node:crypto";import{constants as m}from"node:fs";import h from"node:os";import g from"node:path";import{access as _,mkdir as v,mkdtemp as y,open as b,readFile as x,readdir as S,rename as C,rm as w,stat as T,writeFile as E}from"node:fs/promises";var D=e({});function O(e){u(e,`adb`)}l({get environment(){return r().env},files:{access:async e=>await _(e),ensureDirectory:async e=>{await v(e,{recursive:!0})},isExecutable:async e=>{try{return await _(e,m.X_OK),!0}catch{return!1}},makeTempDirectory:async e=>await y(g.join(h.tmpdir(),e)),readBytes:async e=>await x(e),readDirectory:async e=>await S(e),readText:async e=>await x(e,`utf8`),remove:async(e,t)=>await w(e,t),stat:async e=>{let t=await T(e);return{isFile:t.isFile(),size:t.size}},sha256:e=>f(`sha256`).update(e).digest(`hex`),writeAtomicText:async(e,t,n=384)=>{let r=g.dirname(e),i=g.join(r,`.${g.basename(e)}.${p()}.tmp`),a,o=!1;try{a=await b(i,`wx`,n),await a.writeFile(t,`utf8`),await a.sync(),await a.close(),a=void 0,await C(i,e),o=!0;let s;try{s=await b(r,`r`),await s.sync()}catch{}finally{s&&await s.close().catch(()=>{})}}finally{a&&await a.close().catch(()=>{}),o||await w(i,{force:!0}).catch(()=>{})}},writeBytes:async(e,t)=>await E(e,t)},execAdb:async(e,t)=>{O(e.command);let n=d(e,t,r().env);return await c(`adb`,n.args,{...n.options,detached:process.platform!==`win32`})},spawnAdb:(e,t)=>{O(e.command);let n=d(e,t,r().env),i=o(`adb`,n.args,{...n.options,allowFailure:!0,captureOutput:!1});return i.wait.catch(()=>{}),i.child},withAdbCommandExecutorOverride:a,withoutAdbCommandExecutorOverride:s,coerceAdbResult:t,execFailureDetails:i,emitDiagnostic:n,imeRecoveryMarkers:{write:async(e,t)=>{let{writeAndroidTestImeRecoveryMarker:n}=await import(`./mechanics.js`).then(e=>e.r);return await n(e,t)},clear:async(e,t)=>{let{clearAndroidTestImeRecoveryMarker:n}=await import(`./mechanics.js`).then(e=>e.r);await n(e,t)},read:async e=>{let{readAndroidTestImeRecoveryMarkers:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)}},resolveHelperArtifact:async e=>{let{resolveAndroidHelperArtifact:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)},ensureHelperInstalled:async(e,t)=>{let{makeEnsureAndroidHelperInstalled:n}=await import(`./mechanics.js`).then(e=>e.r);return await n(e)(t)}});export{D as t};
|