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/daemon.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{h as t}from"./daemon-resolution.js";import{o as n}from"./src4.js";import{c as r}from"./device-shell.js";import{o as i,r as a,s as o,u as s}from"./daemon-registration.js";import{i as c}from"./plugin-inventory.js";import{n as l}from"./daemon-stop.js";import{n as u}from"./shared.js";function d(e){return Object.freeze({cleanup:async t=>{let{setAppleRunnerHostEnvironment:n}=await import(`./runner-owner-facade.js`);n(e);let{cleanupRunnerLeasesForOwner:r}=await import(`./runner-operations-facade.js`).then(e=>e.t);await r(t)}})}const f=async({positionals:r,flags:a,host:l})=>{let f=d(l),m=r[0];if(m!==`stop`&&m!==`status`||r.length!==1)throw new e(`INVALID_ARGS`,`daemon accepts only: stop, status`);let _=t(a.stateDir,{cwd:l.cwd,env:l.env});if(m===`status`){let e=i(_),t={...e,plugins:c(e.plugins)};return await u(a,t,()=>g(t)),!0}let v=o(_.infoPath);if(a.clean===!0&&v.ownership!==`absent`&&v.ownership!==`detached`)throw p(_,v);let y=await n(v,{paths:_,host:l}),b=s(v),x=a.clean===!0&&b!==null&&y.stopped;x&&await f.cleanup({pid:b.pid,startTime:b.processStartTime});let S={...y,clean:x};return await u(a,S,()=>h(S,_.baseDir)),!0};function p(t,n){return new e(`COMMAND_FAILED`,`This daemon record does not prove the process is a daemon of its own, so its retained-runner cleanup cannot be run from here.`,{reason:`daemon-clean-not-detached`,stateDir:t.baseDir,ownership:n.ownership,hint:m(t,n)})}function m(e,t){return t.ownership===`unreadable`?`Nothing was signaled. Check what owns that process, then repair the record: stop it by its own means and remove ${r(`${e.baseDir}/daemon.json`)} so a daemon can register again.`:l(t.ownership===`embedded`?`embedded-owner`:`owner-unproven`,t.identity?.pid).hint}function h(e,t){return[e.stopped?`Daemon stopped (${e.mode}).`:`No running daemon for ${t}. A daemon may run under another --state-dir; inspect claims with agent-device device status.`,e.clean?`Retained runner cleanup completed.`:null,...e.warnings].filter(e=>!!e).join(`
|
|
2
2
|
`)}function g(e){return a(e)?`The daemon record for ${e.stateDir} is ${e.state===`invalid`?`not a valid record`:`unreadable`}, so whether a daemon runs there is unknown.`:e.state===`stopped`?`No running daemon for ${e.stateDir}.`:[`Daemon running (${[`pid ${e.pid}`,e.ownership===`embedded`?`host-owned`:e.ownership===`unknown`?`owner-not-recognized`:null,e.version,e.transport].filter(Boolean).join(`, `)}) for ${e.stateDir}.`,...e.plugins.length===0?[`No providers registered.`]:[`Providers:`,...e.plugins.map(e=>{let t=e.package?`${e.package}${e.version?`@${e.version}`:``}`:e.source,n=e.state===`active`?`active`:`failed: ${e.error?.message??`unknown`}`;return` ${e.provider??`(unknown provider)`} [${e.source}] ${t} - ${n}`})]].join(`
|
|
3
3
|
`)}export{f as daemonCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{y as t}from"./sdk-batch-runner.js";import{et as n,rt as r}from"./sdk-io.js";import"./command.js";import{_ as i,b as a,k as o,o as s,u as c}from"./host-file.js";import l from"node:path";const u=/^[0-9a-fA-F-]{32,36}$/;function d(e){if(!(!e||!u.test(e)))return e.replaceAll(`-`,``).toUpperCase()}function f(e,t){return`${e.uuid}:${p(t)}`}function p(e){return`0x${e.toString(16)}`}function m(e){return typeof e==`string`&&e.length>0?e:void 0}function h(...e){for(let t of e){let e=m(t);if(e)return e}}function g(e){let t=e.filter(e=>!!e);return t.length>0?t.join(` `):void 0}function _(e){try{let n=JSON.parse(e);return t(n)?n:null}catch{return null}}function v(e){if(typeof e==`number`&&Number.isSafeInteger(e))return e;if(typeof e==`string`){let t=e.startsWith(`0x`)?Number.parseInt(e,16):Number(e);return Number.isSafeInteger(t)?t:void 0}}function y(e,t,n){if(!Object.hasOwn(e,t))return;let r=v(e[t]);if(r!==void 0)return r;S(n,t)}function b(e,t,n){if(!Object.hasOwn(e,t))return;let r=x(e[t]);if(r!==void 0)return r;S(n,t)}function x(e){if(typeof e==`bigint`)return e;if(typeof e==`number`&&Number.isSafeInteger(e)||typeof e==`string`&&/^(?:0x[0-9a-fA-F]+|\d+)$/.test(e))return BigInt(e)}function S(t,n){throw new e(`INVALID_ARGS`,`Invalid ${t} numeric field: ${n}`,{hint:`Crash artifact numeric fields must be integer numbers or integer numeric strings.`})}function C(e){return e.length===1?e[0]:void 0}function w(e){return[...new Set(e)]}function ee(e){let t=e.match(/^(.*) \+ (\d+)$/);return t?{symbol:t[1],location:Number(t[2])}:{symbol:e}}const te=/^(?:arm64e?|arm64_32|x86_64|armv7[sk]?|i386)$/;function ne(e){return re(e)??O(e)}function re(e){let t=ie(e);if(!t)return null;let n=(Array.isArray(t.payload.usedImages)?t.payload.usedImages:[]).flatMap((e,t)=>D(e,t));if(n.length===0)return null;let r=ae(Array.isArray(t.payload.threads)?t.payload.threads:[],n);return{format:`ips`,images:n,addresses:r.map(({frame:e,...t})=>t),document:t,frameMatches:r,write:e=>T(t,r,e)}}function ie(e){let t=_(e);if(t)return{payload:t};let n=e.indexOf(`
|
|
2
2
|
`);if(n===-1)return null;let r=e.slice(0,n),i=_(e.slice(n+1));return i?{header:r,payload:i}:null}function ae(e,t){let n=new Map(t.map(e=>[e.index,e]));return e.flatMap((e,t)=>oe(e).flatMap((e,r)=>se(e,n,t,r)))}function oe(e){return!t(e)||!Array.isArray(e.frames)?[]:e.frames.filter(t)}function se(e,t,n,r){let i=y(e,`imageIndex`,`IPS frame`),a=b(e,`imageOffset`,`IPS frame`);if(i===void 0||a===void 0)return[];let o=t.get(i);return o?[{frame:e,frameIndex:r,threadIndex:n,image:o,address:o.base+a}]:[]}function T(e,t,n){for(let e of t){let t=n.get(f(e.image,e.address))?.text;t&&E(e.frame,t)}e.payload.agentDeviceSymbolication={tool:`agent-device debug symbols`,symbolicatedFrames:[...n.values()].filter(e=>e.text).length};let r=`${JSON.stringify(e.payload,null,2)}\n`;return e.header?`${e.header}\n${r}`:r}function E(e,t){let n=ee(t);e.symbol=n.symbol,n.location!==void 0&&(e.symbolLocation=n.location)}function D(e,n){if(!t(e))return[];let r=d(m(e.uuid)),i=b(e,`base`,`IPS usedImages`);if(!r||i===void 0)return[];let a=m(e.path);return[{index:n,name:m(e.name)??(a?l.basename(a):`image-${n}`),uuid:r,arch:m(e.arch),base:i,path:a}]}function O(e){let t=e.split(`
|
|
3
3
|
`),n=k(t);if(n.length===0)return null;let r=M(t,n);return{format:`text`,images:n,addresses:r,lines:t,frameMatches:r,write(e){let n=new Map(r.map(e=>[e.lineIndex,e]));return t.map((t,r)=>{let i=n.get(r);if(!i)return t;let a=e.get(f(i.image,i.address))?.text;return!a||t.includes(a)?t:`${t} // ${a}`}).join(`
|
|
4
|
-
`)}}}function k(e){let t=[],n=e.findIndex(e=>/^Binary Images:/i.test(e.trim()));if(n===-1)return t;for(let r of e.slice(n+1)){let e=A(r);e&&t.push(e)}return t}function A(e){let t=e.match(/^\s*(0x[0-9a-fA-F]+)\s*-\s*(0x[0-9a-fA-F]+)\s+\+?(.+?)\s+<([0-9a-fA-F-]{32,36})>\s+(.+)$/);if(!t)return null;let n=d(t[4]);if(!n)return null;let r=j(t[3].trim(),t[5].trim());return{name:r.name,arch:r.arch,uuid:n,base:BigInt(t[1]),end:BigInt(t[2]),path:t[5].trim()}}function j(e,t){let n=e.split(/\s+/),r=n.at(-1);if(r&&te.test(r))return{name:n.slice(0,-1).join(` `).trim(),arch:r};let i=l.basename(t);return{name:e.startsWith(i)?i:e}}function M(e,t){let n=[],r;for(let[i,a]of e.entries()){let e=a.match(/^Thread\s+(\d+)\s+Crashed:/);e?r=Number(e[1]):(a.trim().length===0||/^Thread\s+\d+/.test(a))&&(r=void 0);let o=N(a,t),s=a.match(/^\s*(\d+)/);o&&s&&n.push({...o,frameIndex:Number(s[1]),lineIndex:i,threadIndex:r})}return n}function N(e,t){let n=e.match(/^\s*\d+\s+(.+?)\s+(0x[0-9a-fA-F]+)\b/);if(!n)return null;let r=n[1].trim(),i=BigInt(n[2]),a=P(t,r,i);return a?{image:a,address:i}:null}function P(e,t,n){let r=e.filter(e=>e.name===t);return r.find(e=>F(e,n))??C(r)}function F(e,t){return e.end!==void 0&&e.base<=t&&t<=e.end}const I=1e4;async function L(e){return e.dsym&&e.searchPath?[K(e.cwd,e.dsym),...await R(K(e.cwd,e.searchPath))]:e.dsym?[K(e.cwd,e.dsym)]:e.searchPath?await R(K(e.cwd,e.searchPath)):[]}async function R(t){let n=[],r=0;async function
|
|
5
|
-
`).flatMap(t=>{let n=t.match(/^UUID:\s+([0-9a-fA-F-]{32,36})\s+\(([^)]+)\)\s+(.+)$/),r=d(n?.[1]);return n&&r?[{dsymPath:e,uuid:r,arch:n[2],binaryPath:n[3].trim()}]:[]})}function G(t,n,r){let i=new Map;for(let e of t){let t=n.find(t=>t.uuid===e.uuid&&(e.arch===void 0||t.arch===void 0||t.arch===e.arch));t&&i.set(e.uuid,{image:e,dsym:t})}if(i.size>0)return i;let a=w(t.map(e=>e.uuid)),o=w(n.map(e=>e.uuid));throw new e(`COMMAND_FAILED`,r?`dSYM UUID does not match any Apple image in the crash artifact.`:`No matching dSYM UUID found under search path.`,{artifactUuidCount:a.length,artifactUuidSample:a.slice(0,5),dsymUuidCount:o.length,dsymUuidSample:o.slice(0,5),hint:`Use dwarfdump --uuid <App.dSYM> and compare it with the crash Binary Images or usedImages UUID, then pass the matching dSYM/search path.`})}function K(e,t){return l.resolve(e,t)}function ce(e,t){return e.format===`ips`?le(e.document,e.frameMatches,t):Se(e.lines,e.frameMatches,t)}function le(e,t,n){let r=ve(e.payload),i={format:`ips`,...ue(e),crashedThread:r,topFrames:xe(t,r,n),findings:[]};return{...i,findings:Y(i)}}function ue(e){let t=e.payload,n=_e(e.header);return{appName:de(t,n),bundleId:fe(t,n),version:pe(t,n),incident:me(t,n),timestamp:he(t,n),exceptionType:ge(t.exception),exceptionCodes:ye(t.exception),terminationReason:be(t.termination)}}function de(e,t){return h(e.procName,t?.app_name,t?.name)}function fe(e,n){return h((t(e.bundleInfo)?e.bundleInfo:void 0)?.CFBundleIdentifier,n?.bundleID)}function pe(e,n){return h((t(e.bundleInfo)?e.bundleInfo:void 0)?.CFBundleShortVersionString,n?.app_version)}function me(e,t){return h(e.incident,t?.incident_id)}function he(e,t){return h(e.captureTime,t?.timestamp)}function ge(e){return t(e)?m(e.type):void 0}function _e(e){return e?_(e):null}function ve(e){let n=v(e.faultingThread);if(n!==void 0)return n;let r=(Array.isArray(e.threads)?e.threads:[]).findIndex(e=>t(e)&&e.triggered===!0);return r===-1?void 0:r}function ye(e){return t(e)?h(e.codes,e.rawCodes):void 0}function be(e){if(t(e))return g([m(e.namespace),m(e.code),m(e.reason)])}function xe(e,t,n){return e.filter(e=>t===void 0||e.threadIndex===t).slice(0,5).map(e=>J(e.frameIndex,e.image,e.address,n))}function Se(e,t,n){let r=we(e),i={format:`text`,appName:Ce(e),bundleId:q(e,`Identifier`),version:q(e,`Version`),incident:q(e,`Incident Identifier`),timestamp:q(e,`Date/Time`),exceptionType:q(e,`Exception Type`),exceptionCodes:q(e,`Exception Codes`),terminationReason:q(e,`Termination Reason`),crashedThread:r,topFrames:Te(t,r,n),findings:[]};return{...i,findings:Y(i)}}function Ce(e){return q(e,`Process`)?.replace(/\s+\[\d+\]$/,``)}function q(e,t){let n=`${t}:`,r=e.find(e=>e.trimStart().startsWith(n));return r&&r.slice(r.indexOf(`:`)+1).trim()||void 0}function we(e){let t=q(e,`Triggered by Thread`),n=t?Number.parseInt(t,10):NaN;if(Number.isSafeInteger(n))return n;for(let t of e){let e=t.match(/^Thread\s+(\d+)\s+Crashed:/);if(e)return Number(e[1])}}function Te(e,t,n){return t===void 0?[]:e.filter(e=>e.threadIndex===t).slice(0,5).map(e=>J(e.frameIndex,e.image,e.address,n))}function J(e,t,n,r){return{index:e,image:t.name,address:p(n),symbol:r.get(f(t,n))?.text}}function Y(e){return[Ee(e),e.exceptionType?`Exception: ${e.exceptionType}`:void 0,e.terminationReason?`Termination: ${e.terminationReason}`:void 0].filter(e=>!!e).slice(0,3)}function Ee(e){let t=e.topFrames.find(e=>e.symbol);return t?`Start with ${t.symbol} in ${t.image}; it is the first symbolicated frame captured on the crashed thread.`:e.topFrames.length>0?`No symbolicated frame was found on the crashed thread; verify matching dSYMs for the top images.`:void 0}async function De(e,t,n){let r=new Map;for(let i of Oe(e,t).values())for(let e of await ke(n,i))r.set(f(e.image,e.address),e);return r}function Oe(e,t){let n=new Map;for(let r of e){let e=t.get(r.image.uuid);if(!e)continue;let i=`${r.image.uuid}:${e.dsym.binaryPath}`,a=n.get(i)??{...e,addresses:[]};a.addresses.push(r.address),n.set(i,a)}return n}async function ke(e,t){let i=w(t.addresses.map(p)),a=n(await r(e,Ae(t,i),{timeoutMs:3e4,allowFailure:!0}),`atos failed while symbolicating crash frames.`,{hint:`Verify the crash artifact and dSYM were produced from the same build and architecture.`});return X(t.image,i,a.stdout)}function Ae(e,t){return[`-arch`,e.image.arch??e.dsym.arch??`arm64`,`-o`,e.dsym.binaryPath,`-l`,p(e.image.base),...t]}function X(e,t,n){let r=je(n);return t.map((t,n)=>{let i=r[n]?.trim();return{image:e,address:BigInt(t),text:Me(i,t)?i:void 0}})}function je(e){let t=e.split(/\r?\n/);return t.at(-1)===``&&t.pop(),t}function Me(e,t){if(!e)return!1;let n=e.trim().toLowerCase();return!n||n===`??`||n===t.toLowerCase()?!1:!n.startsWith(`0x`)}async function Ne(){return{dwarfdump:await Z(`dwarfdump`),atos:await Z(`atos`)}}async function Z(t){try{let e=await r(`xcrun`,[`--find`,t],{timeoutMs:5e3,allowFailure:!0}),n=e.stdout.trim();if(e.exitCode===0&&n.length>0)return n}catch{}throw new e(`TOOL_MISSING`,`Apple symbolication tool not found: ${t}`,{hint:`Install Xcode Command Line Tools and verify xcrun --find dwarfdump and xcrun --find atos succeed.`})}const Q=67108864;async function Pe(t){if(t.action!==void 0&&t.action!==`symbols`)throw new e(`INVALID_ARGS`,`debug supports only the symbols workflow.`,{hint:`Use debug symbols --artifact <crash.ips|crash.log> --dsym <App.dSYM> or --search-path <dir> --out <path>.`});let n=t.cwd,r=$(n,t.artifact),
|
|
4
|
+
`)}}}function k(e){let t=[],n=e.findIndex(e=>/^Binary Images:/i.test(e.trim()));if(n===-1)return t;for(let r of e.slice(n+1)){let e=A(r);e&&t.push(e)}return t}function A(e){let t=e.match(/^\s*(0x[0-9a-fA-F]+)\s*-\s*(0x[0-9a-fA-F]+)\s+\+?(.+?)\s+<([0-9a-fA-F-]{32,36})>\s+(.+)$/);if(!t)return null;let n=d(t[4]);if(!n)return null;let r=j(t[3].trim(),t[5].trim());return{name:r.name,arch:r.arch,uuid:n,base:BigInt(t[1]),end:BigInt(t[2]),path:t[5].trim()}}function j(e,t){let n=e.split(/\s+/),r=n.at(-1);if(r&&te.test(r))return{name:n.slice(0,-1).join(` `).trim(),arch:r};let i=l.basename(t);return{name:e.startsWith(i)?i:e}}function M(e,t){let n=[],r;for(let[i,a]of e.entries()){let e=a.match(/^Thread\s+(\d+)\s+Crashed:/);e?r=Number(e[1]):(a.trim().length===0||/^Thread\s+\d+/.test(a))&&(r=void 0);let o=N(a,t),s=a.match(/^\s*(\d+)/);o&&s&&n.push({...o,frameIndex:Number(s[1]),lineIndex:i,threadIndex:r})}return n}function N(e,t){let n=e.match(/^\s*\d+\s+(.+?)\s+(0x[0-9a-fA-F]+)\b/);if(!n)return null;let r=n[1].trim(),i=BigInt(n[2]),a=P(t,r,i);return a?{image:a,address:i}:null}function P(e,t,n){let r=e.filter(e=>e.name===t);return r.find(e=>F(e,n))??C(r)}function F(e,t){return e.end!==void 0&&e.base<=t&&t<=e.end}const I=1e4;async function L(e){return e.dsym&&e.searchPath?[K(e.cwd,e.dsym),...await R(K(e.cwd,e.searchPath))]:e.dsym?[K(e.cwd,e.dsym)]:e.searchPath?await R(K(e.cwd,e.searchPath)):[]}async function R(t){let n=[],r=0;async function a(o){if(n.length>=200)return;if(r+=1,r>I)throw new e(`COMMAND_FAILED`,`debug symbols search-path scan exceeded bounds.`,{searchPath:t,maxEntries:I,hint:`Pass --dsym <App.dSYM> directly or narrow --search-path to the build products directory.`});if(!(await z(o,t)).isDirectory()){o===t&&B(t);return}if(o.endsWith(`.dSYM`)){n.push(o);return}let s=await i(o,{withFileTypes:!0});for(let e of s)e.isDirectory()&&await a(l.join(o,e.name))}return await a(t),n}async function z(t,n){try{return await c(t)}catch{throw new e(`INVALID_ARGS`,`debug symbols search path does not exist: ${n}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}}function B(t){throw new e(`INVALID_ARGS`,`debug symbols search path is not a directory: ${t}`,{hint:`Pass an existing build products directory to --search-path, or pass --dsym <App.dSYM> directly.`})}async function V(t,n){let r=(await Promise.all(w(t).map(e=>H(e,n)))).flat();if(r.length===0)throw new e(`COMMAND_FAILED`,`No UUIDs found in dSYM bundle.`,{hint:`Verify the path points to a built .dSYM bundle with DWARF contents.`});return r}async function H(e,t){return await U(e),W(e,n(await r(t,[`--uuid`,e],{timeoutMs:15e3,allowFailure:!0}),`Failed to inspect dSYM UUIDs: ${e}`,{hint:`Verify the dSYM bundle is valid and readable.`}).stdout)}async function U(t){if(!((await c(t).catch(()=>null))?.isDirectory()&&t.endsWith(`.dSYM`)))throw new e(`INVALID_ARGS`,`Not a .dSYM bundle: ${t}`,{hint:`Pass the .dSYM bundle path, not the DWARF executable inside it.`})}function W(e,t){return t.split(`
|
|
5
|
+
`).flatMap(t=>{let n=t.match(/^UUID:\s+([0-9a-fA-F-]{32,36})\s+\(([^)]+)\)\s+(.+)$/),r=d(n?.[1]);return n&&r?[{dsymPath:e,uuid:r,arch:n[2],binaryPath:n[3].trim()}]:[]})}function G(t,n,r){let i=new Map;for(let e of t){let t=n.find(t=>t.uuid===e.uuid&&(e.arch===void 0||t.arch===void 0||t.arch===e.arch));t&&i.set(e.uuid,{image:e,dsym:t})}if(i.size>0)return i;let a=w(t.map(e=>e.uuid)),o=w(n.map(e=>e.uuid));throw new e(`COMMAND_FAILED`,r?`dSYM UUID does not match any Apple image in the crash artifact.`:`No matching dSYM UUID found under search path.`,{artifactUuidCount:a.length,artifactUuidSample:a.slice(0,5),dsymUuidCount:o.length,dsymUuidSample:o.slice(0,5),hint:`Use dwarfdump --uuid <App.dSYM> and compare it with the crash Binary Images or usedImages UUID, then pass the matching dSYM/search path.`})}function K(e,t){return l.resolve(e,t)}function ce(e,t){return e.format===`ips`?le(e.document,e.frameMatches,t):Se(e.lines,e.frameMatches,t)}function le(e,t,n){let r=ve(e.payload),i={format:`ips`,...ue(e),crashedThread:r,topFrames:xe(t,r,n),findings:[]};return{...i,findings:Y(i)}}function ue(e){let t=e.payload,n=_e(e.header);return{appName:de(t,n),bundleId:fe(t,n),version:pe(t,n),incident:me(t,n),timestamp:he(t,n),exceptionType:ge(t.exception),exceptionCodes:ye(t.exception),terminationReason:be(t.termination)}}function de(e,t){return h(e.procName,t?.app_name,t?.name)}function fe(e,n){return h((t(e.bundleInfo)?e.bundleInfo:void 0)?.CFBundleIdentifier,n?.bundleID)}function pe(e,n){return h((t(e.bundleInfo)?e.bundleInfo:void 0)?.CFBundleShortVersionString,n?.app_version)}function me(e,t){return h(e.incident,t?.incident_id)}function he(e,t){return h(e.captureTime,t?.timestamp)}function ge(e){return t(e)?m(e.type):void 0}function _e(e){return e?_(e):null}function ve(e){let n=v(e.faultingThread);if(n!==void 0)return n;let r=(Array.isArray(e.threads)?e.threads:[]).findIndex(e=>t(e)&&e.triggered===!0);return r===-1?void 0:r}function ye(e){return t(e)?h(e.codes,e.rawCodes):void 0}function be(e){if(t(e))return g([m(e.namespace),m(e.code),m(e.reason)])}function xe(e,t,n){return e.filter(e=>t===void 0||e.threadIndex===t).slice(0,5).map(e=>J(e.frameIndex,e.image,e.address,n))}function Se(e,t,n){let r=we(e),i={format:`text`,appName:Ce(e),bundleId:q(e,`Identifier`),version:q(e,`Version`),incident:q(e,`Incident Identifier`),timestamp:q(e,`Date/Time`),exceptionType:q(e,`Exception Type`),exceptionCodes:q(e,`Exception Codes`),terminationReason:q(e,`Termination Reason`),crashedThread:r,topFrames:Te(t,r,n),findings:[]};return{...i,findings:Y(i)}}function Ce(e){return q(e,`Process`)?.replace(/\s+\[\d+\]$/,``)}function q(e,t){let n=`${t}:`,r=e.find(e=>e.trimStart().startsWith(n));return r&&r.slice(r.indexOf(`:`)+1).trim()||void 0}function we(e){let t=q(e,`Triggered by Thread`),n=t?Number.parseInt(t,10):NaN;if(Number.isSafeInteger(n))return n;for(let t of e){let e=t.match(/^Thread\s+(\d+)\s+Crashed:/);if(e)return Number(e[1])}}function Te(e,t,n){return t===void 0?[]:e.filter(e=>e.threadIndex===t).slice(0,5).map(e=>J(e.frameIndex,e.image,e.address,n))}function J(e,t,n,r){return{index:e,image:t.name,address:p(n),symbol:r.get(f(t,n))?.text}}function Y(e){return[Ee(e),e.exceptionType?`Exception: ${e.exceptionType}`:void 0,e.terminationReason?`Termination: ${e.terminationReason}`:void 0].filter(e=>!!e).slice(0,3)}function Ee(e){let t=e.topFrames.find(e=>e.symbol);return t?`Start with ${t.symbol} in ${t.image}; it is the first symbolicated frame captured on the crashed thread.`:e.topFrames.length>0?`No symbolicated frame was found on the crashed thread; verify matching dSYMs for the top images.`:void 0}async function De(e,t,n){let r=new Map;for(let i of Oe(e,t).values())for(let e of await ke(n,i))r.set(f(e.image,e.address),e);return r}function Oe(e,t){let n=new Map;for(let r of e){let e=t.get(r.image.uuid);if(!e)continue;let i=`${r.image.uuid}:${e.dsym.binaryPath}`,a=n.get(i)??{...e,addresses:[]};a.addresses.push(r.address),n.set(i,a)}return n}async function ke(e,t){let i=w(t.addresses.map(p)),a=n(await r(e,Ae(t,i),{timeoutMs:3e4,allowFailure:!0}),`atos failed while symbolicating crash frames.`,{hint:`Verify the crash artifact and dSYM were produced from the same build and architecture.`});return X(t.image,i,a.stdout)}function Ae(e,t){return[`-arch`,e.image.arch??e.dsym.arch??`arm64`,`-o`,e.dsym.binaryPath,`-l`,p(e.image.base),...t]}function X(e,t,n){let r=je(n);return t.map((t,n)=>{let i=r[n]?.trim();return{image:e,address:BigInt(t),text:Me(i,t)?i:void 0}})}function je(e){let t=e.split(/\r?\n/);return t.at(-1)===``&&t.pop(),t}function Me(e,t){if(!e)return!1;let n=e.trim().toLowerCase();return!n||n===`??`||n===t.toLowerCase()?!1:!n.startsWith(`0x`)}async function Ne(){return{dwarfdump:await Z(`dwarfdump`),atos:await Z(`atos`)}}async function Z(t){try{let e=await r(`xcrun`,[`--find`,t],{timeoutMs:5e3,allowFailure:!0}),n=e.stdout.trim();if(e.exitCode===0&&n.length>0)return n}catch{}throw new e(`TOOL_MISSING`,`Apple symbolication tool not found: ${t}`,{hint:`Install Xcode Command Line Tools and verify xcrun --find dwarfdump and xcrun --find atos succeed.`})}const Q=67108864;async function Pe(t){if(t.action!==void 0&&t.action!==`symbols`)throw new e(`INVALID_ARGS`,`debug supports only the symbols workflow.`,{hint:`Use debug symbols --artifact <crash.ips|crash.log> --dsym <App.dSYM> or --search-path <dir> --out <path>.`});let n=t.cwd,r=$(n,t.artifact),i=$(n,t.out??Re(r)),a=ne(await Ie(r,`crash artifact`));a||Fe();let c=await L({cwd:n,dsym:t.dsym,searchPath:t.searchPath});if(c.length===0)throw new e(`INVALID_ARGS`,`debug symbols requires --dsym or --search-path.`,{hint:`Pass a matching .dSYM bundle directly, or pass --search-path <dir> so agent-device can match crash image UUIDs to local dSYMs.`});let u=await Ne(),d=await V(c,u.dwarfdump),f=G(a.images,d,!!t.dsym),p=await De(a.addresses,f,u.atos),m=a.write(p);await s(l.dirname(i)),await o(i,m);let h=[...f.values()].map(({image:e,dsym:t})=>({name:e.name,uuid:e.uuid,arch:e.arch??t.arch,dsymPath:t.dsymPath,binaryPath:t.binaryPath})),g=[...p.values()].filter(e=>e.text).length,_=a.images.length-h.length,v=_>0?[`${_} Apple image${_===1?``:`s`} had no matching dSYM and were left unchanged.`]:void 0;return{kind:`debugSymbols`,platform:`apple`,artifactPath:r,outPath:i,crash:ce(a,p),matchedImages:h,symbolicatedFrames:g,skippedImages:_,warnings:v,message:`Symbolicated ${g} frame${g===1?``:`s`} -> ${i}`}}function Fe(){throw new e(`UNSUPPORTED_OPERATION`,`debug symbols currently supports Apple crash artifacts with Binary Images or IPS usedImages.`,{hint:`For Android Java/R8 crashes, use retrace with mapping.txt. For Android native crashes, use ndk-stack or addr2line with unstripped .so symbols. Capture the crash with logs, then symbolicate externally until Android support is added.`})}async function Ie(t,n){await Le(t,n);try{return await a(t)}catch(r){let i=r instanceof Error?r.message:String(r);throw new e(`INVALID_ARGS`,`Failed to read ${n}: ${t}`,{message:i})}}async function Le(t,n){try{let r=await c(t);if(r.size<=Q)return;throw new e(`INVALID_ARGS`,`${n} is too large: ${t}`,{actualBytes:r.size,maxBytes:Q,hint:`Pass a bounded Apple .ips/.crash artifact. For very large logs, first narrow the log to the crash report, or use logs grep/tail for lead-up context.`})}catch(r){if(r instanceof e)throw r;let i=r instanceof Error?r.message:String(r);throw new e(`INVALID_ARGS`,`Failed to read ${n}: ${t}`,{message:i})}}function $(e,t){return l.resolve(e,t)}function Re(e){let t=l.extname(e);return`${t?e.slice(0,-t.length):e}-symbolicated${t||`.log`}`}export{Pe as symbolicateCrashArtifact};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./device-claim-reconciliation.js";import{o as t}from"./device-claims.js";import n from"node:path";async function r(n){let{inspectRecovery:r=e,...i}=n,a=[];for(let e of await t(i)){if(e.status===`conflict`)return{status:`refused`,conflict:e.conflict};if(e.status!==`reconcile`)continue;let t=r(e.claim);if(t?.status===`retained`)return{status:`refused`,conflict:e.conflict,retainedBy:t.reason};a.push({claim:e.claim,...t?{recovery:t}:{}})}return{status:`admitted`,reclaimed:a}}async function i(e){return await r({device:e.device,command:`open`,session:`device-status`,workspace:n.sep,stateDir:``,env:e.env,coveredClaimIsOwnedByRequest:()=>!1})}export{r as inspectDeviceClaimAdmission,i as inspectNewSessionAdmission};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,L as t,Tn as n,en as r}from"./sdk-batch.js";import{St as i}from"./sdk-io.js";import"./diagnostics.js";import{Z as a}from"./sdk-device.js";import"./perf-runtime-plan.js";import{h as o}from"./daemon-resolution.js";import{a as s}from"./session-artifact-paths.js";import"./durable-capture-resource.js";import{t as c}from"./app-log-durable-resource.js";import{n as l,r as u}from"./screen-recording-resource-recovery.js";import{a as d,r as f}from"./perf-capture-session-resource.js";import{i as p}from"./screen-recording-session-resource.js";const m=e({required:[`appLogReattach`,`appLogCleanup`]});function h(e){return c.recoverAll({sessionsDir:e.sessionsDir,..._(e)})}function g(e){return c.recoverOne({sessionsDir:e.sessionsDir,..._(e)},e.resourcePath)}function _(e){return{scope:e.scope,acquisitionDeadlineMs:e.acquisitionDeadlineMs,onDiagnostic:e.onDiagnostic,acquireControl:async(t,n)=>await v(e.gateway,t,n)}}async function v(e,t,r){return await u({gateway:e,envelope:t,scope:r,create:e=>{let t=n(e,m);return Object.freeze({reattach:async e=>await t.operations.appLogReattach({envelope:e}),cleanup:async e=>await t.operations.appLogCleanup({envelope:e}),[Symbol.asyncDispose]:async()=>await e[Symbol.asyncDispose]()})}})}function y(e){return d.recoverOne({sessionsDir:e.sessionsDir,scope:e.scope,acquisitionDeadlineMs:e.acquisitionDeadlineMs,onDiagnostic:e.onDiagnostic,acquireControl:async(t,n)=>await b(e.gateway,t,n)},e.resourcePath)}async function b(e,r,i){return await u({gateway:e,envelope:r,scope:i,create:e=>x({runtime:n(e,t),dispose:async()=>await e[Symbol.asyncDispose]()})})}function x(e){return Object.freeze({reattach:async t=>await e.runtime.operations.audioProbeReattach({envelope:t}),cleanup:async t=>await e.runtime.operations.audioProbeCleanup({envelope:t}),[Symbol.asyncDispose]:e.dispose})}function S(e){return f.recoverOne({sessionsDir:e.sessionsDir,scope:e.scope,acquisitionDeadlineMs:e.acquisitionDeadlineMs,onDiagnostic:e.onDiagnostic,acquireControl:async(t,n)=>await C(e.gateway,t,n)},e.resourcePath)}async function C(e,t,i){return await u({gateway:e,envelope:t,scope:i,create:e=>w({runtime:n(e,r),dispose:async()=>await e[Symbol.asyncDispose]()})})}function w(e){return Object.freeze({reattach:async t=>await e.runtime.operations.perfNativeCaptureReattach({envelope:t}),cleanup:async t=>await e.runtime.operations.perfNativeCaptureCleanup({envelope:t}),[Symbol.asyncDispose]:e.dispose})}function T(e){return async(t,n)=>{let r=n??E(t);if(r.status===`retained`)return r;try{let n=o(t.stateDir).sessionsDir,i=s(n,t.session);for(let{resourceKind:a,resourcePath:o}of r.ownedResources){let r=D[a],s=O(r,t,i);if(s.status===`retained`)return s;if(s.status!==`missing`&&await r.recover(e,n,o)===`retained`)return{status:`retained`,reason:`${r.resourceKind}-cleanup-pending`}}let a=E(t);if(a.status===`retained`)return a;let c=new Set(r.ownedResources.map(({resourcePath:e})=>e)),l=a.ownedResources.find(({resourceKind:e,resourcePath:t})=>!c.has(t)||a.recoveryKinds.includes(e));return l?{status:`retained`,reason:`${l.resourceKind}-cleanup-pending`}:{status:`reconciled`}}catch(e){return i({level:`warn`,phase:`device_claim_orphan_reconciliation_failed`,data:{deviceKey:t.deviceKey,ownerSession:t.session,error:e instanceof Error?e.message:String(e)}}),{status:`retained`,reason:`durable-resource-reconciliation-failed`}}}}function E(e){try{let t=o(e.stateDir).sessionsDir,n=s(t,e.session),r=[],i=[];for(let t of Object.values(D)){let a=O(t,e,n);if(a.status===`retained`)return a;a.status===`owned`&&(i.push({resourceKind:t.resourceKind,resourcePath:a.resourcePath}),a.requiresRecovery&&r.push(t.resourceKind))}return{status:`inspectable`,recoveryKinds:r,ownedResources:i}}catch(t){return i({level:`warn`,phase:`device_claim_orphan_reconciliation_failed`,data:{deviceKey:e.deviceKey,ownerSession:e.session,error:t instanceof Error?t.message:String(t)}}),{status:`retained`,reason:`durable-resource-reconciliation-failed`}}}const D={"app-log":{resourceKind:`app-log`,store:c.store,recover:async(e,t,n)=>await g({sessionsDir:t,resourcePath:n,gateway:e.gateway,scope:e.scope})},"screen-recording":{resourceKind:`screen-recording`,store:p.store,recover:async(e,t,n)=>await l({sessionsDir:t,resourcePath:n,gateway:e.gateway,scope:e.scope})},"audio-probe":{resourceKind:`audio-probe`,store:d.store,recover:async(e,t,n)=>await y({sessionsDir:t,resourcePath:n,gateway:e.gateway,scope:e.scope})},"perf-capture":{resourceKind:`perf-capture`,store:f.store,recover:async(e,t,n)=>await S({sessionsDir:t,resourcePath:n,gateway:e.gateway,scope:e.scope})}};function O(e,t,n){let r=e.store.resolvePath(n),i=e.store.read(r);return i.status===`missing`?{status:`missing`}:i.status===`unreattachable`?{status:`retained`,reason:`${e.resourceKind}-${i.reason}`}:i.envelope.sessionId!==t.session||!a(i.envelope.device,t.device)?{status:`retained`,reason:`${e.resourceKind}-owner-mismatch`}:{status:`owned`,resourcePath:r,requiresRecovery:i.envelope.lifecycle===`open`}}export{E as n,h as r,T as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{z as e}from"./sdk-contracts.js";import{Et as t,St as n,a as r}from"./sdk-io.js";import"./diagnostics.js";import{h as i}from"./daemon-resolution.js";import{a,i as o,r as s}from"./session-artifact-paths.js";import{t as c}from"./device-claim-reconciliation.js";function l(n){let r=n.composeRecovery??(e=>u(e,n.scope,n.composeGateway));return async i=>{let a=await n.beforeGateway?.(i);if(a?.status===`retained`)return a;let o=r(i.stateDir),s;try{s={status:`fulfilled`,result:await o.reconcile(i,a)}}catch(e){s={status:`rejected`,error:e}}try{await o.dispose()}catch(r){let a;try{a={error:t(e(r))}}catch{a={reason:`diagnostic-data-unserializable`}}try{n.scope.diagnostics.emit({level:`error`,phase:`device_claim_recovery_dispose_failed`,data:{deviceKey:i.deviceKey,ownerSession:i.session,...s.status===`fulfilled`&&s.result.status===`retained`?{retainedReason:s.result.reason}:{},...a}})}catch{}if(s.status===`fulfilled`&&s.result.status===`reconciled`)throw r}if(s.status===`rejected`)throw s.error;return s.result}}function u(e,t,n){let l=i(e),u=n({sessionsDir:l.sessionsDir,ownedProcesses:r({stateDir:l.baseDir,sessionsDir:l.sessionsDir,resolveSessionDir:e=>a(l.sessionsDir,e)}),resolveSessionArtifacts:e=>({outputPath:s(l.sessionsDir,e),pidPath:o(l.sessionsDir,e)})});return{reconcile:c({gateway:u,scope:t}),dispose:async()=>{await u.shutdown()}}}const d=new AbortController().signal;function f(){return Object.freeze({signal:d,diagnostics:Object.freeze({emit:e=>n(e)}),progress:Object.freeze({report:()=>{}})})}async function p(e){return(await import(`./device-claim-admission.js`)).inspectDeviceClaimAdmission(e)}async function m(e){return(await import(`./device-claim-admission.js`)).inspectNewSessionAdmission(e)}export{l as i,m as n,f as r,p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e,Z as t,q as n,s as r}from"./sdk-contracts.js";import{h as i}from"./sdk-batch-runner.js";import{W as a,yt as o,z as s}from"./sdk-io.js";import"./diagnostics.js";import{C as c,L as l,_ as u,c as ee,y as d}from"./sdk-device.js";import{b as f,c as te,y as p}from"./lease-scope.js";import{o as m}from"./sdk-batch.js";import{r as h}from"./flag-registry.js";import{b as g,y as _}from"./daemon-http.js";import{c as v}from"./device-shell.js";import"./retry.js";import{r as y}from"./daemon-policy-file.js";import{f as b,i as ne,p as re}from"./device-claims.js";import{h as ie,n as ae}from"./request.js";import{a as x,i as S,t as oe}from"./lease-context.js";import{a as se}from"./session-tenant-scope.js";import{a as ce,h as le,o as C,s as w}from"./daemon-command-registry.js";import{m as T}from"./session-runtime.js";import{a as E,o as D}from"./session-selector.js";import{t as O}from"./session-routing.js";function k(e,t){if(A(e,t.command,t.flags??{}),t.command===`batch`)for(let n of t.flags?.batchSteps??[])A(e,m(n.command),{...n.input,...n.flags})}function A(e,t,n){if(R(e,t),t===`close`&&n.shutdown===!0&&F(e,`device-shutdown`),e.deviceIds)for(let t of[n.udid,n.serial]){let n=typeof t==`string`?t.trim():``;if(!(!n||j(e.deviceIds,n)))throw z(e,`device`,`Device ${n} is outside this daemon's policy.`,{deviceId:n})}}function j(e,t){let n=ee(t);return e.has(n)||e.has(u(n))}function M(e,t){return!e.deviceIds||j(e.deviceIds,t.id)}function N(e,t){return!e.deviceIds||M(e,t)?!0:[...e.deviceIds].some(e=>c(t.id,e))}function P(e,t){if(!M(e,t))throw z(e,`device`,`Device ${t.id} is outside this daemon's policy.`,{deviceId:t.id})}function F(e,t){if(e.deniedCapabilities.has(t))throw z(e,`capability`,`This daemon's policy denies ${t}.`,{capability:t})}function I(e,t){let n=e.requiredLeaseBackend;if(!(!n||t?.backend===n))throw z(e,`lease`,`This daemon's policy requires a ${n} lease.`,{leaseBackend:n})}function L(e,n){if(!n.deviceIds)return e;let r=e=>e.filter(e=>N(n,e)),i=Object.freeze({discover:async(t,n)=>r(await e.localOnly.discover(t,n))}),a=async(t,n)=>{let a=await e.providerFirst.discoverWithSource(t,n),o=r(a.devices);return o.length>0||a.source===`local`?{...a,devices:o}:{devices:await i.discover(t,n),source:`local`}},o=Object.freeze({discover:async(e,t)=>(await a(e,t)).devices,discoverWithSource:a}),s=e.resolveAppDevice,c=s?async(e,r)=>{if(M(n,e))return await s(e,r);try{let t=await s(e,r);return t&&M(n,t)?t:void 0}catch(e){if(t(e))throw e;return}}:void 0;return Object.freeze({...e,localOnly:i,providerFirst:o,resolveAppDevice:c})}function R(e,t){let n=e.commands;if(!n)return;let r=y(t);if(r===void 0)return;let i=n.names.has(r);if(!(n.mode===`allow`?i:!i))throw z(e,`command`,`This daemon's policy denies the ${r} command.`,{command:r})}function z(t,n,r,i){return new e(`UNAUTHORIZED`,r,{...i,reason:`DAEMON_POLICY_DENIED`,rule:n,policyDigest:t.digest,retriable:!1,hint:`The daemon operator's policy denies this request; retrying will not help. Use an allowed command and device, or ask the operator to change the policy.`})}function B(e){return(e??``).trim().toLowerCase()===`tenant`?`tenant`:`none`}function V(t){let n=B(t.meta?.sessionIsolation??t.flags?.sessionIsolation),r=t.meta?.tenantId??t.flags?.tenant,i=g(r);if(r&&!i)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(n!==`tenant`)return t;if(!i)throw new e(`INVALID_ARGS`,`session isolation mode tenant requires --tenant (or meta.tenantId).`);let a=t.session||`default`;return _(i,a)?{...t,meta:{...t.meta,tenantId:i,sessionIsolation:n}}:{...t,session:se(i,a),meta:{...t.meta,tenantId:i,sessionIsolation:n}}}function H(t,n,r,i){if(W(t,n,r,i.daemonPolicy))return;let a=S(t);K(t,a);let o=r?.lease;if(i.daemonPolicy?.requiredLeaseBackend){let e=x(t,r).leaseId?U(t,n,r,i.env):void 0;return I(i.daemonPolicy,e),e}if(!(r===void 0&&!a.leaseId&&ue(t,i.providerAppCatalog))){if(t.command===`human_control`&&!o&&!a.leaseId)throw new e(`UNSUPPORTED_OPERATION`,`Takeover requires an active remote device lease. Local takeover is not supported.`);if(!(t.command!==`human_control`&&!o&&t.meta?.sessionIsolation!==`tenant`&&(!a.leaseId||!a.tenantId&&!a.runId)))return U(t,n,r,i.env)}}function U(e,t,n,r){fe(S(e),n?.lease);let i=x(e,n);t.assertLeaseAdmission(p(i));let a=t.heartbeatLease(p(i));return T(a,e,n,r),C(e)&&t.assertHumanControlAdmission(a),a}function W(e,t,n,r){return w(e.command)?ce(e.command)?!0:!G(e,t,n,r):!1}function G(e,t,n,r){if(r?.requiredLeaseBackend)return!0;let i=x(e,n);return i.leaseBackend===`macos-app`||i.leaseId!==void 0&&t.inspectLeaseBackend(i.leaseId)===`macos-app`}function ue(e,t){let n=le(e);return n?.kind===`unconditional`||n?.kind===`provider-app-catalog`&&t?.supports(n.provider)===!0}function de(e){w(e.command)||K(e,S(e))}function K(t,n){if(t.command!==`open`)return;let r=te(n);if(r.length!==0)throw new e(`INVALID_ARGS`,`Proxy open requires leaseId, tenantId, runId, clientId, and deviceKey lease metadata.`,{missing:r})}function fe(e,t){t&&(q(`leaseId`,e.leaseId,t.leaseId),q(`tenantId`,e.tenantId,t.tenantId),q(`runId`,e.runId,t.runId),q(`leaseProvider`,e.leaseProvider,t.leaseProvider),q(`clientId`,e.clientId,t.clientId),q(`deviceKey`,e.deviceKey,t.deviceKey))}function q(t,n,r){if(!(!n||!r||n===r))throw new e(`UNAUTHORIZED`,`Lease does not match session owner (${t})`,{reason:`LEASE_SESSION_MISMATCH`,field:t})}async function pe(e,t){if(!t.leaseProvider||!e)return!1;try{return await e(t),o({level:`info`,phase:`provider_lease_expired_released`,data:{leaseId:t.leaseId,provider:t.leaseProvider}}),!0}catch(e){return o({level:`error`,phase:`provider_lease_expiry_release_failed`,data:{leaseId:t.leaseId,provider:t.leaseProvider,error:e instanceof Error?e.message:String(e)}}),!1}}async function me(e){let t=e.sessionStore.lookup(e.sessionName),n=t?.session.lease;return!t||!n||!e.leaseRegistry.consumeExpiredLease(n.leaseId,()=>e.assertTeardownAllowed?.(t))?!1:(await J(t,e.sessionStore,e.teardownSession,`LEASE_EXPIRED`,e.env),!0)}async function J(e,t,r,i,a){let s=e.session,c=s.lease?.leaseId;o({level:`info`,phase:`leased_session_ended`,data:{reason:i,leaseId:c,session:s.name,deviceKey:s.lease?.deviceKey}}),await r(e).catch(e=>{o({level:`debug`,phase:`leased_session_end_cleanup_failed`,data:{reason:i,leaseId:c,session:s.name,error:n(e)}})}),await ne(s.deviceClaim,a).catch(e=>{o({level:`warn`,phase:`leased_session_end_device_claim_clear_failed`,data:{session:s.name,deviceKey:s.deviceClaim?.deviceKey,error:n(e)}})}),t.finalizeRepairTeardown(e),t.retire(e)}function he(e){let{sessionName:t,sessionStore:n,leaseRegistry:r}=e,i=n.lookup(t),a=i?.session,o=H(e.req,r,a,{env:e.env,providerAppCatalog:e.providerAppCatalog,daemonPolicy:e.daemonPolicy});if(!o)return e.req;let s={...e.req,internal:{...e.req.internal,admittedLease:o}};return i&&a?.lease&&n.update(i,e=>({lease:{...e.lease,leaseBackend:o.backend,expiresAt:o.expiresAt}})),s}function ge(e){return oe(e.req,e.req.internal?.admittedLease)??e.existingLease}function Y(e){let t=e.lease;return f({leaseId:t.leaseId,tenantId:t.tenantId,runId:t.runId,leaseBackend:t.leaseBackend,leaseProvider:t.leaseProvider,deviceKey:t.deviceKey,clientId:t.clientId})}function X(e,t,n=!1){return e?.retainOnClose&&!n?`retained`:e&&t?.release?`provider-release`:`local-release`}function _e(e){return e.session.lease?X(e.leaseRegistry.inspectLeaseForClose(Y(e.session)),void 0)===`retained`:!1}function ve(e){return e.session.lease?X(e.leaseRegistry.inspectLeaseForClose(Y(e.session)),e.leaseLifecycleProvider,e.shutdownRequested)===`provider-release`:!1}async function ye(e){let t=e.session.lease;if(!t)return{};let n=Y(e.session),r=e.leaseRegistry.getLease(n),i=X(r,e.leaseLifecycleProvider);if(i===`retained`)return o({level:`info`,phase:`session_lease_released`,data:{session:e.session.name,leaseId:t.leaseId,released:!1,retained:!0}}),{};let{releaseLease:a}=await import(`./lease-release.js`).then(e=>e.t),s=await a(e.leaseRegistry,i===`provider-release`?e.leaseLifecycleProvider:void 0,r,n),c=s.provider;return o({level:`info`,phase:`session_lease_released`,data:{session:e.session.name,leaseId:t.leaseId,released:s.registryReleased}}),{endedLeaseId:t.leaseId,...c?{providerData:c}:{}}}function be(t){let n=t.flags??{};if(n.waitMs===void 0)return;let[r]=h(`waitMs`);if(!r)throw new e(`INTERNAL_ERROR`,`The waitMs option has no flag declaration whose bounds the daemon can enforce.`);return i(n,`waitMs`,{min:r.min,max:r.max})}function xe(e){let t=e.internal?.openDeviceWait?.waitedMs;return t===void 0?{}:{waitedMs:t}}function Se(e){return{...xe(e),offersDeviceWait:e.command===`open`&&typeof e.flags?.waitMs!=`number`}}function Z(e){let{req:t,budgetMs:n,sessionName:r,sessionStore:i,deviceId:a}=e;if(t.command===`open`&&n!==void 0&&!(a===void 0||i.get(r)))return we({req:t,sessionName:r,sessionStore:i,deviceId:a,budgetMs:n})}function Q(e,t,n){let r=e.findByDevice(t);if(!(!r||r.address===n))return r}function Ce(e){let{req:t,device:n,sessionStore:r,sessionName:i}=e,a=i?Q(r,n.id,i):r.findByDevice(n.id);if(!a)return;let o=Se(t);return O(t,a.session)?D(a,n,o):E(a,n,o)}function we(e){let{req:t,sessionName:n,sessionStore:r,deviceId:i,budgetMs:o}=e,c=s.fromTimeoutMs(o),l=()=>Q(r,i,n),u=async()=>{for(;;){let e=l();if(!e||c.isExpired())return;ae({type:`command`,status:`progress`,message:`Waiting for ${e.session.device.name}: held by session "${e.address}" (${Math.round(c.elapsedMs())}ms of the ${Math.round(o)}ms wait budget used)`}),await a(Math.min(250,c.remainingMs())),ie(t.meta?.requestId)}};return{waitForDeviceOutsideLocks:u,runWhenDeviceIsUnheld:async e=>{let{acquireLocks:n,task:r}=e;for(;;){let e=await n(async()=>{if(l()){if(!c.isExpired())return{ran:!1};Te(t,c.elapsedMs())}return{ran:!0,outcome:await r()}});if(e.ran)return e.outcome;await u()}}}}function Te(e,t){if(t<=0)return;let n=e.internal??={};n.openDeviceWait={waitedMs:t}}function Ee(e,t,n=`status`){let r=t.claim,i=l(r?{platform:r.device.family,appleOs:r.device.appleOs}:e),a=d(e.platform)?`--udid`:`--serial`;return[`agent-device device ${n}`,`--platform ${v(i)}`,`${a} ${v(r?.device.id??e.id)}`,...n===`release`||re(t.classification)?[`--stale`]:[]].join(` `)}function $(t,n){let r=n.claim,i=Ee(t,n,b(n.classification)?`release`:`status`),a=l(r?{platform:r.device.family,appleOs:r.device.appleOs}:t);return new e(`DEVICE_IN_USE`,r?`${a} device ${r.device.id} is owned by session "${r.session}" in workspace "${r.workspace}".`:`${t.name} has an ownership claim that could not be verified.`,{reason:ke(n.classification),classification:n.classification,deviceKey:n.deviceKey,...r?{owner:{session:r.session,workspace:r.workspace,stateDir:r.stateDir}}:{},recovery:{command:i},hint:b(n.classification)?`The recorded owner can no longer release this device; settle its resources and release the claim with: ${i}`:`Inspect the owner with: ${i}`,retriable:!1,dispatched:`no`})}function De(e,t){return Oe($(e,t))}function Oe(e){let{hint:t,retriable:n,...i}=e.details??{};return r(e.code,e.message,i,{hint:t,retriable:n})}function ke(e){switch(e){case`live`:return`DEVICE_CLAIM_LIVE_OWNER`;case`owner-process-dead`:case`owner-daemon-superseded`:return`DEVICE_CLAIM_RECOVERY_PENDING`;case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return`DEVICE_CLAIM_OWNER_UNCERTAIN`}}function Ae(e){switch(e.kind){case`local-family`:return`ordinary`;case`provider-runtime`:return`none`}}export{V as _,Ce as a,F as b,me as c,ve as d,pe as f,G as g,de as h,Z as i,J as l,ge as m,De as n,be as o,ye as p,$ as r,he as s,Ae as t,_e as u,P as v,L as x,k as y};
|
|
1
|
+
import{o as e}from"./sdk-batch.js";import{A as t,P as n,_ as r,s as i}from"./sdk-contracts.js";import{h as a}from"./sdk-batch-runner.js";import{H as o,St as s,q as c}from"./sdk-io.js";import"./diagnostics.js";import{C as l,R as u,_ as d,c as f,y as p}from"./sdk-device.js";import{b as ee,c as te,y as m}from"./lease-scope.js";import{r as h}from"./flag-registry.js";import{S as g,y as _}from"./daemon-http.js";import{c as v}from"./device-shell.js";import"./retry.js";import{r as y}from"./daemon-policy-file.js";import{f as b,i as ne,m as re}from"./device-claims.js";import{g as ie,n as ae}from"./request.js";import{a as x,i as S,t as oe}from"./lease-context.js";import{a as se}from"./session-tenant-scope.js";import{a as ce,g as le,o as C,s as w}from"./daemon-command-registry.js";import{m as T}from"./session-runtime.js";import{a as E,o as D}from"./session-selector.js";import{t as O}from"./session-routing.js";function k(t,n){if(A(t,n.command,n.flags??{}),n.command===`batch`)for(let r of n.flags?.batchSteps??[])A(t,e(r.command),{...r.input,...r.flags})}function A(e,t,n){if(R(e,t),t===`close`&&n.shutdown===!0&&F(e,`device-shutdown`),e.deviceIds)for(let t of[n.udid,n.serial]){let n=typeof t==`string`?t.trim():``;if(!(!n||j(e.deviceIds,n)))throw z(e,`device`,`Device ${n} is outside this daemon's policy.`,{deviceId:n})}}function j(e,t){let n=f(t);return e.has(n)||e.has(d(n))}function M(e,t){return!e.deviceIds||j(e.deviceIds,t.id)}function N(e,t){return!e.deviceIds||M(e,t)?!0:[...e.deviceIds].some(e=>l(t.id,e))}function P(e,t){if(!M(e,t))throw z(e,`device`,`Device ${t.id} is outside this daemon's policy.`,{deviceId:t.id})}function F(e,t){if(e.deniedCapabilities.has(t))throw z(e,`capability`,`This daemon's policy denies ${t}.`,{capability:t})}function I(e,t){let n=e.requiredLeaseBackend;if(!(!n||t?.backend===n))throw z(e,`lease`,`This daemon's policy requires a ${n} lease.`,{leaseBackend:n})}function L(e,t){if(!t.deviceIds)return e;let r=e=>e.filter(e=>N(t,e)),i=Object.freeze({discover:async(t,n)=>r(await e.localOnly.discover(t,n))}),a=async(t,n)=>{let a=await e.providerFirst.discoverWithSource(t,n),o=r(a.devices);return o.length>0||a.source===`local`?{...a,devices:o}:{devices:await i.discover(t,n),source:`local`}},o=Object.freeze({discover:async(e,t)=>(await a(e,t)).devices,discoverWithSource:a}),s=e.resolveAppDevice,c=s?async(e,r)=>{if(M(t,e))return await s(e,r);try{let n=await s(e,r);return n&&M(t,n)?n:void 0}catch(e){if(n(e))throw e;return}}:void 0;return Object.freeze({...e,localOnly:i,providerFirst:o,resolveAppDevice:c})}function R(e,t){let n=e.commands;if(!n)return;let r=y(t);if(r===void 0)return;let i=n.names.has(r);if(!(n.mode===`allow`?i:!i))throw z(e,`command`,`This daemon's policy denies the ${r} command.`,{command:r})}function z(e,t,n,i){return new r(`UNAUTHORIZED`,n,{...i,reason:`DAEMON_POLICY_DENIED`,rule:t,policyDigest:e.digest,retriable:!1,hint:`The daemon operator's policy denies this request; retrying will not help. Use an allowed command and device, or ask the operator to change the policy.`})}function B(e){return(e??``).trim().toLowerCase()===`tenant`?`tenant`:`none`}function V(e){let t=B(e.meta?.sessionIsolation??e.flags?.sessionIsolation),n=e.meta?.tenantId??e.flags?.tenant,i=g(n);if(n&&!i)throw new r(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(t!==`tenant`)return e;if(!i)throw new r(`INVALID_ARGS`,`session isolation mode tenant requires --tenant (or meta.tenantId).`);let a=e.session||`default`;return _(i,a)?{...e,meta:{...e.meta,tenantId:i,sessionIsolation:t}}:{...e,session:se(i,a),meta:{...e.meta,tenantId:i,sessionIsolation:t}}}function H(e,t,n,i){if(W(e,t,n,i.daemonPolicy))return;let a=S(e);K(e,a);let o=n?.lease;if(i.daemonPolicy?.requiredLeaseBackend){let r=x(e,n).leaseId?U(e,t,n,i.env):void 0;return I(i.daemonPolicy,r),r}if(!(n===void 0&&!a.leaseId&&ue(e,i.providerAppCatalog))){if(e.command===`human_control`&&!o&&!a.leaseId)throw new r(`UNSUPPORTED_OPERATION`,`Takeover requires an active remote device lease. Local takeover is not supported.`);if(!(e.command!==`human_control`&&!o&&e.meta?.sessionIsolation!==`tenant`&&(!a.leaseId||!a.tenantId&&!a.runId)))return U(e,t,n,i.env)}}function U(e,t,n,r){fe(S(e),n?.lease);let i=x(e,n);t.assertLeaseAdmission(m(i));let a=t.heartbeatLease(m(i));return T(a,e,n,r),C(e)&&t.assertHumanControlAdmission(a),a}function W(e,t,n,r){return w(e.command)?ce(e.command)?!0:!G(e,t,n,r):!1}function G(e,t,n,r){if(r?.requiredLeaseBackend)return!0;let i=x(e,n);return i.leaseBackend===`macos-app`||i.leaseId!==void 0&&t.inspectLeaseBackend(i.leaseId)===`macos-app`}function ue(e,t){let n=le(e);return n?.kind===`unconditional`||n?.kind===`provider-app-catalog`&&t?.supports(n.provider)===!0}function de(e){w(e.command)||K(e,S(e))}function K(e,t){if(e.command!==`open`)return;let n=te(t);if(n.length!==0)throw new r(`INVALID_ARGS`,`Proxy open requires leaseId, tenantId, runId, clientId, and deviceKey lease metadata.`,{missing:n})}function fe(e,t){t&&(q(`leaseId`,e.leaseId,t.leaseId),q(`tenantId`,e.tenantId,t.tenantId),q(`runId`,e.runId,t.runId),q(`leaseProvider`,e.leaseProvider,t.leaseProvider),q(`clientId`,e.clientId,t.clientId),q(`deviceKey`,e.deviceKey,t.deviceKey))}function q(e,t,n){if(!(!t||!n||t===n))throw new r(`UNAUTHORIZED`,`Lease does not match session owner (${e})`,{reason:`LEASE_SESSION_MISMATCH`,field:e})}async function pe(e,t){if(!t.leaseProvider||!e)return!1;try{return await e(t),s({level:`info`,phase:`provider_lease_expired_released`,data:{leaseId:t.leaseId,provider:t.leaseProvider}}),!0}catch(e){return s({level:`error`,phase:`provider_lease_expiry_release_failed`,data:{leaseId:t.leaseId,provider:t.leaseProvider,error:e instanceof Error?e.message:String(e)}}),!1}}async function me(e){let t=e.sessionStore.lookup(e.sessionName),n=t?.session.lease;return!t||!n||!e.leaseRegistry.consumeExpiredLease(n.leaseId,()=>e.assertTeardownAllowed?.(t))?!1:(await J(t,e.sessionStore,e.teardownSession,`LEASE_EXPIRED`,e.env),!0)}async function J(e,n,r,i,a){let o=e.session,c=o.lease?.leaseId;s({level:`info`,phase:`leased_session_ended`,data:{reason:i,leaseId:c,session:o.name,deviceKey:o.lease?.deviceKey}}),await r(e).catch(e=>{s({level:`debug`,phase:`leased_session_end_cleanup_failed`,data:{reason:i,leaseId:c,session:o.name,error:t(e)}})}),await ne(o.deviceClaim,a).catch(e=>{s({level:`warn`,phase:`leased_session_end_device_claim_clear_failed`,data:{session:o.name,deviceKey:o.deviceClaim?.deviceKey,error:t(e)}})}),n.finalizeRepairTeardown(e),n.retire(e)}function he(e){let{sessionName:t,sessionStore:n,leaseRegistry:r}=e,i=n.lookup(t),a=i?.session,o=H(e.req,r,a,{env:e.env,providerAppCatalog:e.providerAppCatalog,daemonPolicy:e.daemonPolicy});if(!o)return e.req;let s={...e.req,internal:{...e.req.internal,admittedLease:o}};return i&&a?.lease&&n.update(i,e=>({lease:{...e.lease,leaseBackend:o.backend,expiresAt:o.expiresAt}})),s}function ge(e){return oe(e.req,e.req.internal?.admittedLease)??e.existingLease}function Y(e){let t=e.lease;return ee({leaseId:t.leaseId,tenantId:t.tenantId,runId:t.runId,leaseBackend:t.leaseBackend,leaseProvider:t.leaseProvider,deviceKey:t.deviceKey,clientId:t.clientId})}function X(e,t,n=!1){return e?.retainOnClose&&!n?`retained`:e&&t?.release?`provider-release`:`local-release`}function _e(e){return e.session.lease?X(e.leaseRegistry.inspectLeaseForClose(Y(e.session)),void 0)===`retained`:!1}function ve(e){return e.session.lease?X(e.leaseRegistry.inspectLeaseForClose(Y(e.session)),e.leaseLifecycleProvider,e.shutdownRequested)===`provider-release`:!1}async function ye(e){let t=e.session.lease;if(!t)return{};let n=Y(e.session),r=e.leaseRegistry.getLease(n),i=X(r,e.leaseLifecycleProvider);if(i===`retained`)return s({level:`info`,phase:`session_lease_released`,data:{session:e.session.name,leaseId:t.leaseId,released:!1,retained:!0}}),{};let{releaseLease:a}=await import(`./lease-release.js`).then(e=>e.t),o=await a(e.leaseRegistry,i===`provider-release`?e.leaseLifecycleProvider:void 0,r,n),c=o.provider;return s({level:`info`,phase:`session_lease_released`,data:{session:e.session.name,leaseId:t.leaseId,released:o.registryReleased}}),{endedLeaseId:t.leaseId,...c?{providerData:c}:{}}}function be(e){let t=e.flags??{};if(t.waitMs===void 0)return;let[n]=h(`waitMs`);if(!n)throw new r(`INTERNAL_ERROR`,`The waitMs option has no flag declaration whose bounds the daemon can enforce.`);return a(t,`waitMs`,{min:n.min,max:n.max})}function xe(e){let t=e.internal?.openDeviceWait?.waitedMs;return t===void 0?{}:{waitedMs:t}}function Se(e){return{...xe(e),offersDeviceWait:e.command===`open`&&typeof e.flags?.waitMs!=`number`}}function Z(e){let{req:t,budgetMs:n,sessionName:r,sessionStore:i,deviceId:a}=e;if(t.command===`open`&&n!==void 0&&!(a===void 0||i.get(r)))return we({req:t,sessionName:r,sessionStore:i,deviceId:a,budgetMs:n})}function Q(e,t,n){let r=e.findByDevice(t);if(!(!r||r.address===n))return r}function Ce(e){let{req:t,device:n,sessionStore:r,sessionName:i}=e,a=i?Q(r,n.id,i):r.findByDevice(n.id);if(!a)return;let o=Se(t);return O(t,a.session)?D(a,n,o):E(a,n,o)}function we(e){let{req:t,sessionName:n,sessionStore:r,deviceId:i,budgetMs:a}=e,s=o.fromTimeoutMs(a),l=()=>Q(r,i,n),u=async()=>{for(;;){let e=l();if(!e||s.isExpired())return;ae({type:`command`,status:`progress`,message:`Waiting for ${e.session.device.name}: held by session "${e.address}" (${Math.round(s.elapsedMs())}ms of the ${Math.round(a)}ms wait budget used)`}),await c(Math.min(250,s.remainingMs())),ie(t.meta?.requestId)}};return{waitForDeviceOutsideLocks:u,runWhenDeviceIsUnheld:async e=>{let{acquireLocks:n,task:r}=e;for(;;){let e=await n(async()=>{if(l()){if(!s.isExpired())return{ran:!1};Te(t,s.elapsedMs())}return{ran:!0,outcome:await r()}});if(e.ran)return e.outcome;await u()}}}}function Te(e,t){if(t<=0)return;let n=e.internal??={};n.openDeviceWait={waitedMs:t}}function Ee(e,t,n=`status`){let r=t.claim,i=u(r?{platform:r.device.family,appleOs:r.device.appleOs}:e),a=p(e.platform)?`--udid`:`--serial`;return[`agent-device device ${n}`,`--platform ${v(i)}`,`${a} ${v(r?.device.id??e.id)}`,...n===`release`||re(t.classification)?[`--stale`]:[]].join(` `)}function $(e,t){let n=t.claim,i=Ee(e,t,b(t.classification)?`release`:`status`),a=u(n?{platform:n.device.family,appleOs:n.device.appleOs}:e);return new r(`DEVICE_IN_USE`,n?`${a} device ${n.device.id} is owned by session "${n.session}" in workspace "${n.workspace}".`:`${e.name} has an ownership claim that could not be verified.`,{reason:ke(t.classification),classification:t.classification,deviceKey:t.deviceKey,...n?{owner:{session:n.session,workspace:n.workspace,stateDir:n.stateDir}}:{},recovery:{command:i},hint:b(t.classification)?`The recorded owner can no longer release this device; settle its resources and release the claim with: ${i}`:`Inspect the owner with: ${i}`,retriable:!1,dispatched:`no`})}function De(e,t){return Oe($(e,t))}function Oe(e){let{hint:t,retriable:n,...r}=e.details??{};return i(e.code,e.message,r,{hint:t,retriable:n})}function ke(e){switch(e){case`live`:return`DEVICE_CLAIM_LIVE_OWNER`;case`owner-process-dead`:case`owner-daemon-superseded`:return`DEVICE_CLAIM_RECOVERY_PENDING`;case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return`DEVICE_CLAIM_OWNER_UNCERTAIN`}}function Ae(e){switch(e.kind){case`local-family`:return`ordinary`;case`provider-runtime`:return`none`}}export{V as _,Ce as a,F as b,me as c,ve as d,pe as f,G as g,de as h,Z as i,J as l,ge as m,De as n,be as o,ye as p,$ as r,he as s,Ae as t,_e as u,P as v,L as x,k as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e}from"./sdk-batch-runner.js";import{A as t,c as n,d as r,f as i,k as a,pt as o,yt as s}from"./sdk-io.js";import"./diagnostics.js";import{B as c,C as l,P as u,_ as d,k as ee,l as te,p as ne,q as re,s as f,u as ie,y as ae}from"./sdk-device.js";import{c as p,n as oe,o as se}from"./file.js";import{n as ce}from"./daemon-registration.js";import le from"node:crypto";import m from"node:fs";import h from"node:path";function g(e){return ue(`family`in e?e.family:e.platform,e.appleOs,e.id)}function ue(e,t,n){return`local:${e}:${t??`none`}:${n}`}function _(e,t){let n=le.createHash(`sha256`).update(e).digest(`hex`);return h.join(p(t),`${n}.json`)}const de=[`open-session`,`transient-command`,`unstated`];function v(e){return{deviceKey:e.deviceKey,ownerToken:e.ownerToken,ownerPid:e.ownerPid,ownerStartTime:e.ownerStartTime}}function fe(t){return e(t)?t.schemaVersion===3?pe(t):t.schemaVersion===2?y(t,`unstated`):t.schemaVersion===1?he(t):null:null}function pe(e){let{claimOwnerKind:t,transientCommand:n}=e;if(!me(t))return null;if(t===`transient-command`){if(!S(n))return null;let r=y(e,t);return r?{...r,transientCommand:n}:null}return n===void 0?y(e,t):null}function me(e){return typeof e==`string`&&de.includes(e)}function y(t,n){if(!e(t.device)||!S(t.device.name))return null;let r=te(t.device);return r?b(t,r,t.device.name,n):null}function he(t){if(!e(t.device))return null;let n=t.device,r=n.name;if(!S(r)||!ee(n.platform))return null;let i=ie(n.platform),a=te({id:n.id,family:i.platform,kind:n.kind,target:n.target,...n.appleOs===void 0?i.platform===`apple`?{appleOs:n.platform===`macos`?`macos`:`ios`}:{}:{appleOs:n.appleOs},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend}});return a?b(t,a,r,`unstated`):null}function b(e,t,n,r){let i=_e(e),a=ve(e),o=ye(e);return!i||!a||!o||i.deviceKey!==g(t)?null:{schemaVersion:3,...i,device:{...t,name:n},...a,...o,claimOwnerKind:r}}function x(e){return`${ge}${e}`}const ge=`transient:`;function _e(e){let t=C(e.deviceKey),n=C(e.session),r=C(e.workspace),i=C(e.stateDir);return!t||!n||!r||!i?null:{deviceKey:t,session:n,workspace:r,stateDir:i}}function ve(e){let{ownerPid:t,ownerStartTime:n}=e,r=C(e.ownerToken);return!be(t)||!r||n!==null&&!S(n)?null:{ownerPid:t,ownerStartTime:n,ownerToken:r}}function ye(e){let{createdAtMs:t,updatedAtMs:n,abandonedAtMs:r}=e;return!w(t)||!w(n)||r!==void 0&&!w(r)?null:{createdAtMs:t,updatedAtMs:n,...w(r)?{abandonedAtMs:r}:{}}}function S(e){return typeof e==`string`&&e.length>0}function C(e){return S(e)?e:null}function be(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function w(e){return typeof e==`number`&&Number.isFinite(e)}function xe(e,t){let n=E(e,t);return`claims`in n?n.claims:O(n.parsed,a(D(n.parsed)))}async function T(e,n){let r=E(e,n);return`claims`in r?r.claims:O(r.parsed,await t(D(r.parsed)))}function E(e,t){let n=p(t),r=Se(n);return`claims`in r?r:{parsed:r.entries.filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>j(h.join(n,e.name))).filter(e=>e!==null).filter(t=>Ce(t.claim,e))}}function D(e){return e.flatMap(e=>e.claim?[e.claim.ownerPid]:[])}function O(e,t){return e.map(e=>e.claim?Oe(e,t.get(e.claim.ownerPid)??null):e)}function Se(e){try{return{entries:m.readdirSync(e,{withFileTypes:!0})}}catch(t){let n=t.code;return n===`ENOENT`||n===`ENOTDIR`?{claims:[]}:{claims:[{fileName:h.basename(e),classification:`unknown`,error:String(t)}]}}}function Ce(e,t){return!e||[we(e,t.udid??t.serial),Te(e,t.device),Ee(e,t.platform)].every(Boolean)}function we(e,t){return!t||ne(e.device.id,t)}function Te(e,t){return!t||e.device.name===t||e.device.id===t}function Ee(e,t){return u({platform:e.device.family,appleOs:e.device.appleOs},t)}async function k(e){return await A(j(e))}async function A(e){return e?.claim?Oe(e,(await t([e.claim.ownerPid])).get(e.claim.ownerPid)??null):e}function j(e){let t=h.basename(e);try{return De(t,m.readFileSync(e,`utf8`))}catch(e){let n=e.code;return n===`ENOENT`||n===`ENOTDIR`?null:{fileName:t,classification:`unknown`,error:String(e)}}}function De(e,t){try{let n=fe(JSON.parse(t));return n?{fileName:e,deviceKey:n.deviceKey,claim:n,classification:`unknown`}:{fileName:e,classification:`inconsistent`}}catch(t){return{fileName:e,classification:`inconsistent`,error:String(t)}}}function Oe(e,t){let r=e.claim;if(!r)return e;let i={pid:r.ownerPid,startTime:r.ownerStartTime},a=n({owner:i,stateDir:r.stateDir},t),o=a===`live`&&ce({...i,stateDir:r.stateDir});return{...e,classification:o?`owner-daemon-superseded`:a}}function ke(e){switch(e){case`owner-process-dead`:case`owner-process-reused`:case`owner-state-dir-gone`:case`owner-daemon-superseded`:return!0;case`live`:case`unknown`:case`inconsistent`:return!1}}function M(e){switch(e){case`owner-process-dead`:case`owner-daemon-superseded`:return!0;case`live`:case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return!1}}async function Ae(e){let t=await e.observeDeviceBoot?.observeBootTimeMs(e.device);if(t?.observed!==!0||t.bootedAtMs<=e.claim.updatedAtMs)return;let{session:n,workspace:r,stateDir:i}=e.claim;return{session:n,workspace:r,stateDir:i,bootedAtMs:t.bootedAtMs}}function je(e){s({level:`info`,phase:`device_claim_reboot_released`,data:{deviceKey:e.deviceKey,ownerSession:e.claim.session,ownerStateDir:e.claim.stateDir,ownerWorkspace:e.claim.workspace,claimUpdatedAtMs:e.claim.updatedAtMs,deviceBootedAtMs:e.bootedAtMs}})}function N(e,t){let n=_(e.deviceKey,t);m.mkdirSync(h.dirname(n),{recursive:!0,mode:448}),o({destination:n,contents:`${JSON.stringify(e)}\n`,mode:384})}async function P(e,t,n){let r=i();return await se({acquire:()=>oe({lockDirPath:`${_(e,t)}.lock`,owner:{pid:r.pid,startTime:r.startTime,acquiredAtMs:Date.now()},timeoutMs:3e4,description:`device claim for ${e}`}),task:n})}async function F(e){let t=await I(e);return t.status===`available`?(t.superseded&&Le(e.deviceKey,t.superseded),{status:`available`}):t.status===`held`?{status:`held`,ownership:Me(t.claim,e.env)}:t.status===`conflict`?(V(e.deviceKey,t.conflict),t):await Ne(t,e)}async function I(e){let t=await k(_(e.deviceKey,e.env));if(!t)return{status:`available`};if(t.claim&&B(t.claim,e.stateDir,e.owner))return{status:`available`,superseded:t.claim};if(t.claim&&Fe(t.claim,e,e.owner))return{status:`held`,claim:t.claim};if(!t.claim)return{status:`conflict`,conflict:t};let n=await Pe({classification:t.classification,claim:t.claim,device:e.device,observeDeviceBoot:e.observeDeviceBoot});return n.settles?{status:`reconcile`,claim:t.claim,conflict:t,tookOver:n.tookOver}:{status:`conflict`,conflict:t}}function Me(e,t){if(e.updatedAtMs>=Date.now())return v(e);let n={...e,updatedAtMs:Date.now()};return N(n,t),v(n)}async function Ne(e,t){let n=await L(e.claim,t.reconcileOrphanedDeviceClaim,t.env);return n.status===`retained`?(V(t.deviceKey,e.conflict,n.reason),{status:`conflict`,conflict:e.conflict}):e.tookOver?(je({deviceKey:t.deviceKey,claim:e.claim,bootedAtMs:e.tookOver.bootedAtMs}),{status:`available`,tookOver:e.tookOver}):{status:`available`}}async function Pe(e){if(M(e.classification))return{settles:!0};let t=await Ae(e);return t?{settles:!0,tookOver:t}:{settles:!1}}async function L(e,t,n){let r=await t(e);if(r.status===`retained`)return r;try{m.unlinkSync(_(e.deviceKey,n))}catch(e){if(e.code!==`ENOENT`)throw e}return{status:`reconciled`}}function R(e,t,n){return e.stateDir===t&&r({pid:e.ownerPid,startTime:e.ownerStartTime},n)}function z(e){return e.abandonedAtMs!==void 0}function B(e,t,n){return z(e)&&R(e,t,n)}function Fe(e,t,n){return e.claimOwnerKind!==t.claimOwnerKind||t.claimOwnerKind===`transient-command`&&e.transientCommand!==t.transientCommand?!1:e.session===t.session&&e.workspace===t.workspace&&R(e,t.stateDir,n)}function V(e,t,n){s({level:`warn`,phase:`device_claim_conflict`,data:{deviceKey:e,classification:t.classification,...Ie(t),...n?{reconciliationReason:n}:{}}})}function Ie(e){return{ownerSession:e.claim?.session,ownerStateDir:e.claim?.stateDir}}function Le(e,t){s({level:`info`,phase:`device_claim_abandoned_superseded`,data:{deviceKey:e,abandonedSession:t.session,abandonedAtMs:t.abandonedAtMs}})}async function H(e,t,n){let r=await k(_(t,e.env)),i=r&&J(r,{...e,coveredBySession:e.session},n);if(i===`covered`&&r?.claim)return{status:`held`,claim:r.claim};if(i===`conflict`&&r)return{status:`conflict`,conflict:r}}async function U(e,t,n,r,i=!0){let a=e.command!==`open`;if(a&&i){let t=await H(e,n,r);if(t)return t}return await I({...e,session:a?x(e.command):e.session,claimOwnerKind:a?`transient-command`:`open-session`,...a?{transientCommand:e.command,observeDeviceBoot:void 0}:{},device:t,deviceKey:n,owner:r})}async function Re(e,t,n){let r=[];for(let i of await T({},e.env)){if(!i.claim){r.push({status:`conflict`,conflict:i});continue}if(!G(t,i.claim))continue;let a=await k(_(i.claim.deviceKey,e.env));a&&r.push(X(a,e.stateDir,n))}return r}function W(e){let t=d(e.id);return t===e.id?void 0:t}function G(e,t){return t.device.family===e.family&&t.device.appleOs===e.appleOs&&l(e.id,t.device.id)}async function ze(e){let t=Q(e.device),n=g(t),r=i(),a=W(e.device);if(e.command!==`open`&&a===void 0&&f(e.device)){let t=await H(e,n,r);if(t)return[t]}let o=[];if(a!==void 0){let t={...e.device,id:a,hostApp:void 0},n=g(Q(t)),i=await U(e,t,n,r,!1);if(i.status===`held`){let t=await k(_(n,e.env));t&&o.push({status:`conflict`,conflict:t})}else o.push(i)}else f(e.device)&&o.push(...await Re(e,t,r));return o.push(await U(e,e.device,n,r)),o}async function Be(e){let t=Q(e.device),n=g(t);return await K({...e,claimOwnerKind:`open-session`},n,async()=>await Y({...e,deviceKey:n,identity:t}))}async function K(e,t,n){let r=W(e.device);if(r===void 0)return await P(t,e.env,n);let a={...e.device,id:r,hostApp:void 0},o=g(Q(a));return await P(o,e.env,async()=>{let r=await F({...e,device:a,deviceKey:o,owner:i()});if(r.status===`conflict`)return r;if(r.status===`held`){let t=await k(_(o,e.env));if(t)return{status:`conflict`,conflict:t}}let s=await P(t,e.env,n);if(s.status!==`acquired`)return s;q(o,e.env);let c=s.tookOver??(r.status===`available`?r.tookOver:void 0);return c?{...s,tookOver:c}:s})}function q(e,t){try{m.unlinkSync(_(e,t))}catch(e){if(e.code!==`ENOENT`)throw e}}async function Ve(e){let t=Q(e.device),n=g(t),r=x(e.command);return await K({...e,session:r,claimOwnerKind:`transient-command`,transientCommand:e.command},n,async()=>{let a=await k(_(n,e.env)),o=a&&J(a,e,i());return o===`covered`?{status:`covered-by-owned-claim`}:o===`conflict`?{status:`conflict`,conflict:a}:await Y({device:e.device,deviceKey:n,identity:t,session:r,transientCommand:e.command,workspace:e.workspace,stateDir:e.stateDir,env:e.env,reconcileOrphanedDeviceClaim:e.reconcileOrphanedDeviceClaim})})}function J(e,t,n){let r=e.claim;if(!(!r||z(r)||!R(r,t.stateDir,n)))return r.claimOwnerKind===`open-session`?r.session===t.coveredBySession&&t.coveredClaimIsOwnedByRequest(r)?`covered`:void 0:`conflict`}async function Y(e){let{deviceKey:t,identity:n}=e,r=i(),a=e.transientCommand===void 0?`open-session`:`transient-command`,o=[];if(W(e.device)===void 0&&f(e.device)){let t=await He(n,e);if(t.conflict)return{status:`conflict`,conflict:t.conflict};o=t.abandoned}let s=await F({...e,owner:r,claimOwnerKind:a});if(s.status===`conflict`)return s;if(s.status===`held`)return await Z(o,e.env),{status:`acquired`,ownership:s.ownership};let c=Date.now(),l={schemaVersion:3,deviceKey:t,device:{...n,name:e.device.name},session:e.session,workspace:e.workspace,stateDir:e.stateDir,ownerPid:r.pid,ownerStartTime:r.startTime,ownerToken:le.randomUUID(),createdAtMs:c,updatedAtMs:c,claimOwnerKind:a,...e.transientCommand===void 0?{}:{transientCommand:e.transientCommand}};return N(l,e.env),await Z(o,e.env),{status:`acquired`,ownership:v(l),...s.tookOver?{tookOver:s.tookOver}:{}}}async function He(e,t){let n=[];for(let r of await T({},t.env)){let a=r.claim;if(!a)return{conflict:r,abandoned:[]};if(!G(e,a))continue;let o=await P(a.deviceKey,t.env,async()=>{let e=await k(_(a.deviceKey,t.env));if(!e)return;let r=X(e,t.stateDir,i());if(r.status===`available`){r.superseded&&n.push(r.superseded.deviceKey);return}return r.status===`conflict`?r.conflict:(await L(r.claim,t.reconcileOrphanedDeviceClaim,t.env)).status===`retained`?e:void 0});if(o)return{conflict:o,abandoned:[]}}return{abandoned:n}}function X(e,t,n){return e.claim?B(e.claim,t,n)?{status:`available`,superseded:e.claim}:M(e.classification)?{status:`reconcile`,claim:e.claim,conflict:e}:{status:`conflict`,conflict:e}:{status:`conflict`,conflict:e}}async function Z(e,t){for(let n of e)await P(n,t,async()=>q(n,t))}function Ue(e,t){let n=g(Q(e)),a=j(_(n,t))?.claim;return a!==void 0&&a.deviceKey===n&&!z(a)&&r({pid:a.ownerPid,startTime:a.ownerStartTime},i())}function Q(e){return re({...e,...ae(e.platform)?{appleOs:c(e)}:{}})}async function We(e){let t=[];for(let n of await T(e.selectors,e.env))t.push(await Ge(n,e.reconcile,e.env));return t}async function Ge(e,t,n){let r=e.claim,i={fileName:e.fileName,classification:e.classification,...e.deviceKey?{deviceKey:e.deviceKey}:{},...r?{device:r.device,session:r.session,workspace:r.workspace,stateDir:r.stateDir}:{}};if(!r||!M(e.classification))return{...i,status:`refused`,reason:qe(e.classification)};if(_(r.deviceKey,n)!==h.join(p(n),e.fileName))return{...i,status:`refused`,reason:`claim-file-name-mismatch`};let{deviceKey:a,ownerToken:o}=r;return await P(a,n,async()=>{let e=await k(_(a,n));if(!e?.claim||e.claim.ownerToken!==o||!M(e.classification))return{...i,status:`changed`,reason:`claim-changed-during-release`};let c=await L(e.claim,t,n);return c.status===`retained`?{...i,status:`retained`,reason:c.reason}:(s({level:`info`,phase:`device_claim_stale_released`,data:{deviceKey:a,ownerSession:r.session,ownerStateDir:r.stateDir}}),{...i,status:`released`})})}const Ke=Object.freeze({live:`live-owner`,"owner-process-reused":`owner-pid-reused`,"owner-state-dir-gone":`owner-process-still-running`,unknown:`owner-liveness-unknown`,inconsistent:`claim-record-inconsistent`,"owner-process-dead":`claim-record-unreadable`,"owner-daemon-superseded":`claim-record-unreadable`});function qe(e){return Ke[e]}async function Je(e,t){return e?await $(e,t,(e,t)=>{try{m.unlinkSync(t)}catch(e){if(e.code!==`ENOENT`)throw e;return`absent`}return`deleted`},e=>e?e.claim?`ownership-changed`:`unattributable`:`absent`):`absent`}async function Ye(e,t){return e?await $(e,t,e=>{let n=Date.now();return N({...e,abandonedAtMs:n,updatedAtMs:n},t),`abandoned`},e=>e?`ownership-changed`:`absent`):`absent`}async function Xe(e,t){return e?await $(e,t,e=>(N({...e,updatedAtMs:Date.now()},t),{status:`renewed`}),e=>({status:`lost`,conflict:e})):{status:`lost`,conflict:void 0}}async function $(e,t,n,r){return await P(e.deviceKey,t,async()=>{let i=_(e.deviceKey,t),a=j(i);if(!a)return r(void 0);let o=a.claim;return o&&Ze(o,e)?n(o,i):r(await A(a)??void 0)})}function Ze(e,t){return e.ownerToken===t.ownerToken&&r({pid:e.ownerPid,startTime:e.ownerStartTime},{pid:t.ownerPid,startTime:t.ownerStartTime})}async function Qe(e,t,n){let r=p(n),i=0,a=0,o=0,s=0;for(let c of await T({},n)){let l=h.join(r,c.fileName);if(!c.claim||!$e(c.classification,c.claim.stateDir,t))continue;i+=1;let{deviceKey:u,ownerToken:d}=c.claim;if(_(u,n)!==l){o+=1;continue}await P(u,n,async()=>{let r=await k(l);if(!r?.claim||!$e(r.classification,r.claim.stateDir,t)||r.claim.ownerToken!==d){s+=1;return}if((await L(r.claim,e,n)).status===`retained`){o+=1;return}a+=1})}return{examined:i,reconciled:a,retained:o,changed:s}}function $e(e,t,n){return M(e)?e!==`owner-daemon-superseded`||h.resolve(t)===h.resolve(n):!1}export{Q as a,Ue as c,Xe as d,M as f,g,T as h,Je as i,Qe as l,xe as m,Be as n,ze as o,ke as p,Ve as r,G as s,Ye as t,We as u};
|
|
1
|
+
import{y as e}from"./sdk-batch-runner.js";import{M as t,St as n,f as r,gt as i,j as a,l as o,p as s}from"./sdk-io.js";import"./diagnostics.js";import{C as c,J as l,P as u,V as d,_ as ee,k as te,l as f,p as ne,s as p,u as re,y as ie}from"./sdk-device.js";import{c as m,n as ae,o as oe}from"./file.js";import{n as se}from"./daemon-registration.js";import h from"node:crypto";import g from"node:fs";import _ from"node:path";function v(e){return ce(`family`in e?e.family:e.platform,e.appleOs,e.id)}function ce(e,t,n){return`local:${e}:${t??`none`}:${n}`}function y(e,t){let n=h.createHash(`sha256`).update(e).digest(`hex`);return _.join(m(t),`${n}.json`)}const le=[`open-session`,`transient-command`,`unstated`];function b(e){return{deviceKey:e.deviceKey,ownerToken:e.ownerToken,ownerPid:e.ownerPid,ownerStartTime:e.ownerStartTime}}function ue(t){return e(t)?t.schemaVersion===3?de(t):t.schemaVersion===2?x(t,`unstated`):t.schemaVersion===1?pe(t):null:null}function de(e){let{claimOwnerKind:t,transientCommand:n}=e;if(!fe(t))return null;if(t===`transient-command`){if(!w(n))return null;let r=x(e,t);return r?{...r,transientCommand:n}:null}return n===void 0?x(e,t):null}function fe(e){return typeof e==`string`&&le.includes(e)}function x(t,n){if(!e(t.device)||!w(t.device.name))return null;let r=f(t.device);return r?S(t,r,t.device.name,n):null}function pe(t){if(!e(t.device))return null;let n=t.device,r=n.name;if(!w(r)||!te(n.platform))return null;let i=re(n.platform),a=f({id:n.id,family:i.platform,kind:n.kind,target:n.target,...n.appleOs===void 0?i.platform===`apple`?{appleOs:n.platform===`macos`?`macos`:`ios`}:{}:{appleOs:n.appleOs},...n.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:n.iosPhysicalDeviceBackend}});return a?S(t,a,r,`unstated`):null}function S(e,t,n,r){let i=he(e),a=ge(e),o=_e(e);return!i||!a||!o||i.deviceKey!==v(t)?null:{schemaVersion:3,...i,device:{...t,name:n},...a,...o,claimOwnerKind:r}}function C(e){return`${me}${e}`}const me=`transient:`;function he(e){let t=T(e.deviceKey),n=T(e.session),r=T(e.workspace),i=T(e.stateDir);return!t||!n||!r||!i?null:{deviceKey:t,session:n,workspace:r,stateDir:i}}function ge(e){let{ownerPid:t,ownerStartTime:n}=e,r=T(e.ownerToken);return!ve(t)||!r||n!==null&&!w(n)?null:{ownerPid:t,ownerStartTime:n,ownerToken:r}}function _e(e){let{createdAtMs:t,updatedAtMs:n,abandonedAtMs:r}=e;return!E(t)||!E(n)||r!==void 0&&!E(r)?null:{createdAtMs:t,updatedAtMs:n,...E(r)?{abandonedAtMs:r}:{}}}function w(e){return typeof e==`string`&&e.length>0}function T(e){return w(e)?e:null}function ve(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function E(e){return typeof e==`number`&&Number.isFinite(e)}function ye(e,t){let n=O(e,t);return`claims`in n?n.claims:A(n.parsed,a(k(n.parsed)))}async function D(e,n){let r=O(e,n);return`claims`in r?r.claims:A(r.parsed,await t(k(r.parsed)))}function O(e,t){let n=m(t),r=be(n);return`claims`in r?r:{parsed:r.entries.filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>N(_.join(n,e.name))).filter(e=>e!==null).filter(t=>xe(t.claim,e))}}function k(e){return e.flatMap(e=>e.claim?[e.claim.ownerPid]:[])}function A(e,t){return e.map(e=>e.claim?P(e,t.get(e.claim.ownerPid)??null):e)}function be(e){try{return{entries:g.readdirSync(e,{withFileTypes:!0})}}catch(t){let n=t.code;return n===`ENOENT`||n===`ENOTDIR`?{claims:[]}:{claims:[{fileName:_.basename(e),classification:`unknown`,error:String(t)}]}}}function xe(e,t){return!e||[Se(e,t.udid??t.serial),Ce(e,t.device),we(e,t.platform)].every(Boolean)}function Se(e,t){return!t||ne(e.device.id,t)}function Ce(e,t){return!t||e.device.name===t||e.device.id===t}function we(e,t){return u({platform:e.device.family,appleOs:e.device.appleOs},t)}async function j(e){return await M(N(e))}async function M(e){return e?.claim?P(e,(await t([e.claim.ownerPid])).get(e.claim.ownerPid)??null):e}function N(e){let t=_.basename(e);try{return Te(t,g.readFileSync(e,`utf8`))}catch(e){let n=e.code;return n===`ENOENT`||n===`ENOTDIR`?null:{fileName:t,classification:`unknown`,error:String(e)}}}function Te(e,t){try{let n=ue(JSON.parse(t));return n?{fileName:e,deviceKey:n.deviceKey,claim:n,classification:`unknown`}:{fileName:e,classification:`inconsistent`}}catch(t){return{fileName:e,classification:`inconsistent`,error:String(t)}}}function P(e,t){let n=e.claim;if(!n)return e;let r={pid:n.ownerPid,startTime:n.ownerStartTime},i=o({owner:r,stateDir:n.stateDir},t),a=i===`live`&&se({...r,stateDir:n.stateDir});return{...e,classification:a?`owner-daemon-superseded`:i}}function Ee(e){switch(e){case`owner-process-dead`:case`owner-process-reused`:case`owner-state-dir-gone`:case`owner-daemon-superseded`:return!0;case`live`:case`unknown`:case`inconsistent`:return!1}}const De=Object.freeze({live:`live-owner`,"owner-process-reused":`owner-pid-reused`,"owner-state-dir-gone":`owner-process-still-running`,unknown:`owner-liveness-unknown`,inconsistent:`claim-record-inconsistent`,"owner-process-dead":`claim-record-unreadable`,"owner-daemon-superseded":`claim-record-unreadable`});function F(e){return De[e]}function I(e){switch(e){case`owner-process-dead`:case`owner-daemon-superseded`:return!0;case`live`:case`owner-process-reused`:case`owner-state-dir-gone`:case`unknown`:case`inconsistent`:return!1}}async function Oe(e){let t=await e.observeDeviceBoot?.observeBootTimeMs(e.device);if(t?.observed!==!0||t.bootedAtMs<=e.claim.updatedAtMs)return;let{session:n,workspace:r,stateDir:i}=e.claim;return{session:n,workspace:r,stateDir:i,bootedAtMs:t.bootedAtMs}}function ke(e){n({level:`info`,phase:`device_claim_reboot_released`,data:{deviceKey:e.deviceKey,ownerSession:e.claim.session,ownerStateDir:e.claim.stateDir,ownerWorkspace:e.claim.workspace,claimUpdatedAtMs:e.claim.updatedAtMs,deviceBootedAtMs:e.bootedAtMs}})}function L(e,t){let n=y(e.deviceKey,t);g.mkdirSync(_.dirname(n),{recursive:!0,mode:448}),i({destination:n,contents:`${JSON.stringify(e)}\n`,mode:384})}async function R(e,t,n){let r=s();return await oe({acquire:()=>ae({lockDirPath:`${y(e,t)}.lock`,owner:{pid:r.pid,startTime:r.startTime,acquiredAtMs:Date.now()},timeoutMs:3e4,description:`device claim for ${e}`}),task:n})}async function z(e){let t=await B(e);return t.status===`available`?(t.superseded&&Fe(e.deviceKey,t.superseded),{status:`available`}):t.status===`held`?{status:`held`,ownership:Ae(t.claim,e.env)}:t.status===`conflict`?(G(e.deviceKey,t.conflict),t):await je(t,e)}async function B(e){let t=await j(y(e.deviceKey,e.env));if(!t)return{status:`available`};if(t.claim&&W(t.claim,e.stateDir,e.owner))return{status:`available`,superseded:t.claim};if(t.claim&&Ne(t.claim,e,e.owner))return{status:`held`,claim:t.claim};if(!t.claim)return{status:`conflict`,conflict:t};let n=await Me({classification:t.classification,claim:t.claim,device:e.device,observeDeviceBoot:e.observeDeviceBoot});return n.settles?{status:`reconcile`,claim:t.claim,conflict:t,tookOver:n.tookOver}:{status:`conflict`,conflict:t}}function Ae(e,t){if(e.updatedAtMs>=Date.now())return b(e);let n={...e,updatedAtMs:Date.now()};return L(n,t),b(n)}async function je(e,t){let n=await V(e.claim,t.reconcileOrphanedDeviceClaim,t.env);return n.status===`retained`?(G(t.deviceKey,e.conflict,n.reason),{status:`conflict`,conflict:e.conflict}):e.tookOver?(ke({deviceKey:t.deviceKey,claim:e.claim,bootedAtMs:e.tookOver.bootedAtMs}),{status:`available`,tookOver:e.tookOver}):{status:`available`}}async function Me(e){if(I(e.classification))return{settles:!0};let t=await Oe(e);return t?{settles:!0,tookOver:t}:{settles:!1}}async function V(e,t,n){let r=await t(e);if(r.status===`retained`)return r;try{g.unlinkSync(y(e.deviceKey,n))}catch(e){if(e.code!==`ENOENT`)throw e}return{status:`reconciled`}}function H(e,t,n){return e.stateDir===t&&r({pid:e.ownerPid,startTime:e.ownerStartTime},n)}function U(e){return e.abandonedAtMs!==void 0}function W(e,t,n){return U(e)&&H(e,t,n)}function Ne(e,t,n){return e.claimOwnerKind!==t.claimOwnerKind||t.claimOwnerKind===`transient-command`&&e.transientCommand!==t.transientCommand?!1:e.session===t.session&&e.workspace===t.workspace&&H(e,t.stateDir,n)}function G(e,t,r){n({level:`warn`,phase:`device_claim_conflict`,data:{deviceKey:e,classification:t.classification,...Pe(t),...r?{reconciliationReason:r}:{}}})}function Pe(e){return{ownerSession:e.claim?.session,ownerStateDir:e.claim?.stateDir}}function Fe(e,t){n({level:`info`,phase:`device_claim_abandoned_superseded`,data:{deviceKey:e,abandonedSession:t.session,abandonedAtMs:t.abandonedAtMs}})}async function K(e,t,n){let r=await j(y(t,e.env)),i=r&&Ve(r,{...e,coveredBySession:e.session},n);if(i===`covered`&&r?.claim)return{status:`held`,claim:r.claim};if(i===`conflict`&&r)return{status:`conflict`,conflict:r}}async function q(e,t,n,r,i=!0){let a=e.command!==`open`;if(a&&i){let t=await K(e,n,r);if(t)return t}return await B({...e,session:a?C(e.command):e.session,claimOwnerKind:a?`transient-command`:`open-session`,...a?{transientCommand:e.command,observeDeviceBoot:void 0}:{},device:t,deviceKey:n,owner:r})}async function Ie(e,t,n){let r=[];for(let i of await D({},e.env)){if(!i.claim){r.push({status:`conflict`,conflict:i});continue}if(!Y(t,i.claim))continue;let a=await j(y(i.claim.deviceKey,e.env));a&&r.push(Z(a,e.stateDir,n))}return r}function J(e){let t=ee(e.id);return t===e.id?void 0:t}function Y(e,t){return t.device.family===e.family&&t.device.appleOs===e.appleOs&&c(e.id,t.device.id)}async function Le(e){let t=Q(e.device),n=v(t),r=s(),i=J(e.device);if(e.command!==`open`&&i===void 0&&p(e.device)){let t=await K(e,n,r);if(t)return[t]}let a=[];if(i!==void 0){let t={...e.device,id:i,hostApp:void 0},n=v(Q(t)),o=await q(e,t,n,r,!1);if(o.status===`held`){let t=await j(y(n,e.env));t&&a.push({status:`conflict`,conflict:t})}else a.push(o)}else p(e.device)&&a.push(...await Ie(e,t,r));return a.push(await q(e,e.device,n,r)),a}async function Re(e){let t=Q(e.device),n=v(t);return await X({...e,claimOwnerKind:`open-session`},n,async()=>await He({...e,deviceKey:n,identity:t}))}async function X(e,t,n){let r=J(e.device);if(r===void 0)return await R(t,e.env,n);let i={...e.device,id:r,hostApp:void 0},a=v(Q(i));return await R(a,e.env,async()=>{let r=await z({...e,device:i,deviceKey:a,owner:s()});if(r.status===`conflict`)return r;if(r.status===`held`){let t=await j(y(a,e.env));if(t)return{status:`conflict`,conflict:t}}let o=await R(t,e.env,n);if(o.status!==`acquired`)return o;ze(a,e.env);let c=o.tookOver??(r.status===`available`?r.tookOver:void 0);return c?{...o,tookOver:c}:o})}function ze(e,t){try{g.unlinkSync(y(e,t))}catch(e){if(e.code!==`ENOENT`)throw e}}async function Be(e){let t=Q(e.device),n=v(t),r=C(e.command);return await X({...e,session:r,claimOwnerKind:`transient-command`,transientCommand:e.command},n,async()=>{let i=await j(y(n,e.env)),a=i&&Ve(i,e,s());return a===`covered`?{status:`covered-by-owned-claim`}:a===`conflict`?{status:`conflict`,conflict:i}:await He({device:e.device,deviceKey:n,identity:t,session:r,transientCommand:e.command,workspace:e.workspace,stateDir:e.stateDir,env:e.env,reconcileOrphanedDeviceClaim:e.reconcileOrphanedDeviceClaim})})}function Ve(e,t,n){let r=e.claim;if(!(!r||U(r)||!H(r,t.stateDir,n)))return r.claimOwnerKind===`open-session`?r.session===t.coveredBySession&&t.coveredClaimIsOwnedByRequest(r)?`covered`:void 0:`conflict`}async function He(e){let{deviceKey:t,identity:n}=e,r=s(),i=e.transientCommand===void 0?`open-session`:`transient-command`,a=[];if(J(e.device)===void 0&&p(e.device)){let t=await Ue(n,e);if(t.conflict)return{status:`conflict`,conflict:t.conflict};a=t.abandoned}let o=await z({...e,owner:r,claimOwnerKind:i});if(o.status===`conflict`)return o;if(o.status===`held`)return await We(a,e.env),{status:`acquired`,ownership:o.ownership};let c=Date.now(),l={schemaVersion:3,deviceKey:t,device:{...n,name:e.device.name},session:e.session,workspace:e.workspace,stateDir:e.stateDir,ownerPid:r.pid,ownerStartTime:r.startTime,ownerToken:h.randomUUID(),createdAtMs:c,updatedAtMs:c,claimOwnerKind:i,...e.transientCommand===void 0?{}:{transientCommand:e.transientCommand}};return L(l,e.env),await We(a,e.env),{status:`acquired`,ownership:b(l),...o.tookOver?{tookOver:o.tookOver}:{}}}async function Ue(e,t){let n=[];for(let r of await D({},t.env)){let i=r.claim;if(!i)return{conflict:r,abandoned:[]};if(!Y(e,i))continue;let a=await R(i.deviceKey,t.env,async()=>{let e=await j(y(i.deviceKey,t.env));if(!e)return;let r=Z(e,t.stateDir,s());if(r.status===`available`){r.superseded&&n.push(r.superseded.deviceKey);return}return r.status===`conflict`?r.conflict:(await V(r.claim,t.reconcileOrphanedDeviceClaim,t.env)).status===`retained`?e:void 0});if(a)return{conflict:a,abandoned:[]}}return{abandoned:n}}function Z(e,t,n){return e.claim?W(e.claim,t,n)?{status:`available`,superseded:e.claim}:I(e.classification)?{status:`reconcile`,claim:e.claim,conflict:e}:{status:`conflict`,conflict:e}:{status:`conflict`,conflict:e}}async function We(e,t){for(let n of e)await R(n,t,async()=>ze(n,t))}function Ge(e,t){let n=v(Q(e)),i=N(y(n,t))?.claim;return i!==void 0&&i.deviceKey===n&&!U(i)&&r({pid:i.ownerPid,startTime:i.ownerStartTime},s())}function Q(e){return l({...e,...ie(e.platform)?{appleOs:d(e)}:{}})}async function Ke(e){let t=[];for(let n of await D(e.selectors,e.env))t.push(await qe(n,e.reconcile,e.env));return t}async function qe(e,t,r){let i=e.claim,a={fileName:e.fileName,classification:e.classification,...e.deviceKey?{deviceKey:e.deviceKey}:{},...i?{device:i.device,session:i.session,workspace:i.workspace,stateDir:i.stateDir}:{}};if(!i||!I(e.classification))return{...a,status:`refused`,reason:F(e.classification)};if(y(i.deviceKey,r)!==_.join(m(r),e.fileName))return{...a,status:`refused`,reason:`claim-file-name-mismatch`};let{deviceKey:o,ownerToken:s}=i;return await R(o,r,async()=>{let e=await j(y(o,r));if(!e?.claim||e.claim.ownerToken!==s||!I(e.classification))return{...a,status:`changed`,reason:`claim-changed-during-release`};let c=await V(e.claim,t,r);return c.status===`retained`?{...a,status:`retained`,reason:c.reason}:(n({level:`info`,phase:`device_claim_stale_released`,data:{deviceKey:o,ownerSession:i.session,ownerStateDir:i.stateDir}}),{...a,status:`released`})})}async function Je(e,t){return e?await $(e,t,(e,t)=>{try{g.unlinkSync(t)}catch(e){if(e.code!==`ENOENT`)throw e;return`absent`}return`deleted`},e=>e?e.claim?`ownership-changed`:`unattributable`:`absent`):`absent`}async function Ye(e,t){return e?await $(e,t,e=>{let n=Date.now();return L({...e,abandonedAtMs:n,updatedAtMs:n},t),`abandoned`},e=>e?`ownership-changed`:`absent`):`absent`}async function Xe(e,t){return e?await $(e,t,e=>(L({...e,updatedAtMs:Date.now()},t),{status:`renewed`}),e=>({status:`lost`,conflict:e})):{status:`lost`,conflict:void 0}}async function $(e,t,n,r){return await R(e.deviceKey,t,async()=>{let i=y(e.deviceKey,t),a=N(i);if(!a)return r(void 0);let o=a.claim;return o&&Ze(o,e)?n(o,i):r(await M(a)??void 0)})}function Ze(e,t){return e.ownerToken===t.ownerToken&&r({pid:e.ownerPid,startTime:e.ownerStartTime},{pid:t.ownerPid,startTime:t.ownerStartTime})}async function Qe(e,t,n){let r=m(n),i=0,a=0,o=0,s=0;for(let c of await D({},n)){let l=_.join(r,c.fileName);if(!c.claim||!$e(c.classification,c.claim.stateDir,t))continue;i+=1;let{deviceKey:u,ownerToken:d}=c.claim;if(y(u,n)!==l){o+=1;continue}await R(u,n,async()=>{let r=await j(l);if(!r?.claim||!$e(r.classification,r.claim.stateDir,t)||r.claim.ownerToken!==d){s+=1;return}if((await V(r.claim,e,n)).status===`retained`){o+=1;return}a+=1})}return{examined:i,reconciled:a,retained:o,changed:s}}function $e(e,t,n){return I(e)?e!==`owner-daemon-superseded`||_.resolve(t)===_.resolve(n):!1}export{v as _,Q as a,Ge as c,Xe as d,I as f,D as g,ye as h,Je as i,Qe as l,Ee as m,Re as n,Le as o,F as p,Be as r,Y as s,Ye as t,Ke as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as Rect } from "./sdk-contracts.js";
|
|
2
2
|
import { a as PointerTrajectorySample, i as PointerTrajectory, o as SinglePointerGesturePlan, r as MultiTouchGesturePlan } from "./gesture-plan-types.js";
|
|
3
3
|
import { Readable, Stream, Writable } from "node:stream";
|
|
4
4
|
//#region packages/platform-android/src/helper-artifacts.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{P as t,
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{P as t,_ as n}from"./sdk-contracts.js";import{AsyncLocalStorage as r}from"node:async_hooks";var i=e({listDeviceInventory:()=>u,listLocalDeviceInventory:()=>f,readAppDeviceResolver:()=>l,readDeviceInventory:()=>d,readInstalledAppProbe:()=>c,shouldPropagateDeviceInventoryProbeError:()=>h,withDeviceInventoryContext:()=>s});const a=`device_inventory_context_unavailable`,o=new r;async function s(e,t){return await o.run(e,t)}function c(){return o.getStore()?.findInstalledApp}function l(){return o.getStore()?.resolveAppDevice}async function u(e){return await p(`providerFirst`,e)}async function d(e){let t=m(),n=await t.providerFirst.discoverWithSource(e,t.requestScope);return{devices:n.devices.map(e=>({...e})),source:n.source}}async function f(e){return await p(`localOnly`,e)}async function p(e,t){let n=m();return(await n[e].discover(t,n.requestScope)).map(e=>({...e}))}function m(){let e=o.getStore();if(!e)throw new n(`COMMAND_FAILED`,`Device inventory gateway is unavailable outside request execution`,{reason:a});return e}function h(e){return t(e)||e instanceof n&&e.code===`COMMAND_FAILED`&&e.details?.reason===a?!0:e instanceof Error&&e.name===`AbortError`}export{d as a,l as i,u as n,h as o,f as r,s,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{_ as t}from"./sdk-contracts.js";import{A as n,B as r,F as i,I as a,L as o,M as s,N as c,m as l,w as u,y as d}from"./sdk-device.js";var f=e({assertDeviceHonorsPin:()=>O,assertRequestHonorsDevicePin:()=>T,effectiveDevicePinSelector:()=>w,markSelectionBootOccurred:()=>h,resolveExistingSessionDeviceSelection:()=>m,resolveInventoryDeviceSelection:()=>p});async function p(e){let{devices:t,selector:n,source:a}=e,o=l(n);if(a===`provider`&&!o)return v(t,n);if(a===`local`&&!o){let r=await y(t,n,e.appleSimulatorAppTarget);if(r)return r}let s=t.filter(e=>c(e,n,{includeExplicitSelectors:o})),u=e.boot&&a===`local`&&!o?i(s):void 0;if(u&&e.boot?.pick===`newest`)return{device:u,reason:`newest-bootable-local`,source:a,candidateCount:s.length,bootOccurred:!1};try{return g(await r([...t],n),s,{explicitSelector:o,source:a})}catch(e){throw b(e,s,u?`To boot one of these shut-down devices, pass --pick newest (pick: "newest" from Node or MCP).`:void 0)}}function m(e){return{device:e,reason:`existing-session`,source:`session`,candidateCount:1,bootOccurred:!1}}function h(e){if(!e||e.source!==`local`)return e;let{device:t}=e;return t.booted!==!0&&(t.kind===`simulator`||t.kind===`emulator`)?{...e,bootOccurred:!0}:e}function g(e,t,n){return{device:e,reason:n.explicitSelector?`explicit-selector`:n.source===`provider`?`single-provider-device`:_(e,t),source:n.source,candidateCount:t.length,bootOccurred:!1}}function _(e,t){return e.booted===!0&&t.filter(e=>e.booted===!0).length===1?`single-booted-local`:!e.booted&&t.length===1?`single-bootable-local`:`preferred-local`}async function v(e,n){let i=e.filter(e=>c(e,n)),a=i[0];if(a!==void 0&&i.length===1)return g(a,i,{explicitSelector:!1,source:`provider`});try{await r([...e],n)}catch(e){throw b(e,i)}throw new t(`AMBIGUOUS_MATCH`,`Multiple provider devices match this request.`,{...x(i),matches:i.length,dispatched:`no`,hint:`Select the leased provider device explicitly with --device, --udid, or --serial.`,retrySelectors:S(i)})}async function y(e,n,r){let i=r?.trim();if(!i)return;let{readInstalledAppProbe:a}=await import(`./device-inventory-context.js`).then(e=>e.t),o=a();if(!o)return;let s=e.filter(e=>c(e,n)&&u(e)&&e.kind===`simulator`&&e.booted===!0);if(s.length<2)return;let l=(await Promise.all(s.map(async e=>await o(e,i)?e:void 0))).filter(e=>e!==void 0),d=l[0];if(d!==void 0&&l.length===1)return{device:d,reason:`single-app-installed-local`,source:`local`,candidateCount:1,bootOccurred:!1};throw l.length===0?new t(`APP_NOT_INSTALLED`,`No booted iOS simulator has ${i} installed`,{appTarget:i,...x(s),hint:`Install the app on a booted simulator, or pass --udid to select the intended device explicitly.`,retrySelectors:S(s)}):new t(`AMBIGUOUS_MATCH`,`Multiple booted iOS simulators have ${i} installed`,{appTarget:i,...x(l),dispatched:`no`,hint:`Pass --udid to select the intended simulator explicitly.`,retrySelectors:S(l)})}function b(e,n,r){if(!(e instanceof t)||e.code!==`AMBIGUOUS_MATCH`)return e;let i=o([...n]);return new t(e.code,e.message,{...e.details??{},...x(i),retrySelectors:S(i),...r?{hint:[e.details?.hint,r].filter(Boolean).join(` `)}:{}},e)}function x(e){return{devices:e.slice(0,10).map(e=>({id:e.id,name:e.name}))}}function S(e){return e.slice(0,10).flatMap(e=>[{flag:n(e.platform)?`--serial`:`--udid`,value:e.id},{flag:`--device`,value:e.name}])}function C(e){return`${e.kind===`project`?`project `:``}config file ${e.path}`}function w(e,t){let n=t.platform;return{platform:n&&n!==`apple`?n:e.selector.platform??n,device:t.device??e.selector.device,udid:t.udid??e.selector.udid,serial:t.serial??e.selector.serial}}function T(e,t){let n=[],r=(t,r)=>{let i=r===void 0?{}:{step:r};for(let r of Object.keys(e.selector)){let a=e.selector[r];if(a!==void 0)for(let e of[`platform`,`device`,`udid`,`serial`]){let o=t?.[e];typeof o==`string`&&E(r,a,e,o)&&n.push({key:e,pinned:a,requested:o,...e===r?{}:{pinnedKey:r},...i})}}};r(t.flags),t.flags?.batchSteps?.forEach((e,t)=>r(e.flags,t+1)),n.length&&k(e,n)}function E(e,t,n,r){return e===n?n===`device`?!s({name:t},r):n===`platform`?a(r,t):r!==t:e===`platform`?!D(n,t):n===`platform`?!D(e,r):e===`udid`&&n===`serial`||e===`serial`&&n===`udid`}function D(e,t){return e===`udid`?d(t):e!==`serial`||n(t)}function O(e,t,n={}){let r=e=>c(t,{...e,deviceName:e.device},{includeExplicitSelectors:!0});r(e.selector)&&r(n)||k(e,[],{id:t.id,name:t.name})}function k(e,n,r){let i=n[0],a=i?.step===void 0?``:`Batch step ${i.step}: `,o=i?`${i.key} ${JSON.stringify(i.requested)}`:`Device selection ${JSON.stringify(r?.name)} (${r?.id})`,s=C(e.source);throw new t(`INVALID_ARGS`,`${a}${o} conflicts with the device pin from ${s}.`,{reason:`device_pin_conflict`,pin:{...e.selector},pinSource:s,conflicts:n,...r?{device:r}:{},hint:`Use a device matching ${JSON.stringify(e.selector)}, or edit or remove devicePin in ${e.source.path}.`})}export{h as n,m as r,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{n as t}from"./app-inventory.js";import"./device.js";import{t as n}from"./ios-client.js";import{o as r,r as i}from"./android.js";import{t as a}from"./request-cancellation.js";import o from"node:fs";import s from"node:path";import{setTimeout as c}from"node:timers/promises";async function l(e,t){let r=await n({apiUrl:e.apiUrl,token:e.token,logLevel:`warn`});try{let n=await t.ios.createRunner({...e,client:r});return{...e,platform:`ios`,client:r,runner:n,dependencies:t}}catch(e){throw r.disconnect(),e}}async function u(e,t,n,r,i){r?.throwIfAborted();let{LimrunSyncCache:s}=await import(`./sync-cache.js`),c=e.syncCache??=new s,l=((await o.promises.stat(t)).isDirectory()?await e.dependencies.ios.readBundleAppName(t):void 0)??h(t),u=(await f(e,async()=>{r?.throwIfAborted();let o=await a(i,c.run(t,`ios`,r=>e.client.syncApp(t,{basisCacheDir:r,install:!0,watch:!1,launchMode:n?.relaunch?`RelaunchIfRunning`:`None`}),r));return r?.throwIfAborted(),o.installedBundleId},n,r,i)).appId;return{...u?{bundleId:u,launchTarget:u}:{},...l?{appName:l}:{}}}async function d(e,t,n,r,i){return await f(e,async()=>(await a(i,e.client.installApp(t,{launchMode:n?.relaunch?`RelaunchIfRunning`:void 0}),r)).bundleId,n,r,i)}async function f(t,n,i,o,s){o?.throwIfAborted();let l=await a(s,t.client.listApps(),o).catch(e=>{if(o?.aborted)throw e}),u=r(await n()),d=r(i?.appIdentifierHint),f=[];for(let e of g){e>0&&await c(e,void 0,{signal:o}),f=await a(s,t.client.listApps(),o);let n=_({resultBundleId:u,requestedBundleId:d,beforeInstallApps:l,afterInstallApps:f});if(n)return{appId:n}}throw new e(`COMMAND_FAILED`,`Limrun iOS app installation could not be verified.`,{resultBundleId:u,requestedBundleId:d,installedUserApps:f.filter(y).map(e=>e.bundleId).sort()})}function p(e,t){let n={...t,get appBundleId(){return t?.appBundleId??e.appBundleId}},r=e.runner.createInteractor(n),i=new m(e,r,n);return{...r,open:i.open.bind(i),openDevice:i.openDevice.bind(i),close:i.close.bind(i),setSetting:i.setSetting.bind(i)}}var m=class{session;signal;context;shared;constructor(e,t,n){this.session=e,this.shared=t,this.context=n,this.signal=n.signal}async open(e,t){let n=t?.appBundleId??(await this.session.runner.applicationTools.resolveOpenTarget(this.session.device,{target:e,currentAppBundleId:this.context.appBundleId,surface:`app`})).appBundleId;await this.shared.open(e,{...t,appBundleId:n}),this.session.appBundleId=n}async openDevice(){}async close(e){let{appBundleId:t}=await this.session.runner.applicationTools.resolveOpenTarget(this.session.device,{target:e,surface:`app`});await this.shared.close(t??e),t!==void 0&&this.session.appBundleId===t&&(await this.session.runner.resetTarget(this.signal),this.session.appBundleId=void 0)}async setSetting(t,n,r,i){if(t.toLowerCase()===`reset-keychain`)throw new e(`UNSUPPORTED_OPERATION`,`Limrun does not expose keychain reset.`);return await this.shared.setSetting(t,n,r,i)}};function h(e){return s.basename(e).replace(/\.(?:app|ipa|apk|aab|zip)$/i,``)||void 0}const g=[0,250];function _(e){let t=new Set(e.afterInstallApps.map(e=>e.bundleId));return(e.resultBundleId&&t.has(e.resultBundleId)?e.resultBundleId:void 0)??(e.requestedBundleId&&t.has(e.requestedBundleId)?e.requestedBundleId:void 0)??v(e.beforeInstallApps,e.afterInstallApps)}function v(e,t){if(!e)return;let n=new Set(e.map(e=>e.bundleId)),r=t.filter(e=>y(e)&&!n.has(e.bundleId));return r.length===1?r[0]?.bundleId:void 0}function y(e){return!e.bundleId.startsWith(`com.apple.`)&&!e.installType.toLowerCase().includes(`system`)}function b(e){return e.platform===`android`?x(e):S(e)}function x(e){let n=e.adbProvider.exec;return{platform:`android`,device:e.device,interactor:i(e),adb:e.adbProvider,listApps:async r=>await e.dependencies.android.listApps(n,t(r)),getForegroundApp:async t=>await e.dependencies.android.getForegroundApp(e.device,n,t),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},getKeyboardState:async()=>await e.dependencies.android.getKeyboardState(n),dismissKeyboard:async()=>await e.dependencies.android.dismissKeyboard(n),readLogs:async t=>await e.dependencies.android.readLogs(n,t),...C(e.client,e.token,e.dependencies.host),installRemoteApp:async t=>{await e.client.sendAsset(t)}}}function S(e){return{platform:`ios`,device:e.device,interactor:p(e),viewport:{width:e.client.deviceInfo.screenWidth,height:e.client.deviceInfo.screenHeight},listApps:async n=>(await e.client.listApps()).filter(e=>t(n)===`all`||y(e)).map(e=>({id:e.bundleId,name:e.name,installType:e.installType})).sort((e,t)=>e.id.localeCompare(t.id)),pressKey:async(t,n)=>{await e.client.pressKey(t,n)},readLogs:async(t,n)=>await e.client.appLogTail(t,n),...C(e.client,e.token,e.dependencies.host),installRemoteApp:async(t,n)=>await d(e,t,n),runSimctl:t=>e.client.simctl(t)}}function C(e,t,n){return{startRecording:async t=>{await e.startRecordingSession(t)},stopRecording:async t=>({downloadUrl:await e.stopRecordingSession(t)}),downloadRecording:async e=>{await n.downloadFile({url:e.downloadUrl,headers:{Authorization:`Bearer ${t}`},destinationPath:e.outPath,timeoutMs:6e4})}}}export{u as i,p as n,l as r,b as t};
|
package/dist/src/device-shell.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";const t=/^[A-Za-z0-9_@%+=:,./-]+$/;function n(e){return`'${e.replaceAll(`'`,String.raw`'\''`)}'`}function r(e){return t.test(e)?e:n(e)}function i(e){return Object.freeze({script:e})}const a=new WeakMap,o=/[\\$"`]/g;function s(e){return e.replaceAll(o,e=>`\\${e}`)}function c(t,n){if(typeof t==`number`)return String(t);if(typeof t==`string`){if(n===`hdc`){if(t===``)throw new e(`INVALID_ARGS`,`hdc drops an empty element instead of carrying it, so the device command would lose an operand.`,{reason:`hdc-empty-word-unsupported`,hint:`Pass a value the transport can carry, or use a device action that needs no operand.`});return s(t)}return r(t)}if(n===`hdc`)throw new e(`INVALID_ARGS`,`hdc wraps every element in double quotes, so a shell fragment would reach the device as literal text instead of a script.`,{reason:`hdc-shell-fragment-unsupported`});return t.script}function l(e,t,n,r=[]){let i=Object.freeze([...r,t,...n.map(t=>c(t,e))]);return a.set(i,r.length),i}function u(e,t,n){if(n===0)return e;let r=a.get(e),i=[...e.slice(0,t),...e.slice(t+n)];if(r===void 0||t+n>r)return i;let o=r-n,s=Object.freeze(i);return a.set(s,o),s}function d(e,t){let n=a.get(t),r=Object.freeze([...e,...t]);return n!==void 0&&a.set(r,e.length+n),r}function f(t,n){if(!(!t.includes(`shell`)&&!t.includes(`exec-out`))&&!a.has(t))throw new e(`INVALID_ARGS`,`${n}: device-shell argv must be built with deviceShellArgv (got ${JSON.stringify(t)}).`,{reason:`unguarded-device-shell-argv`})}function p(e){let t=e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1).replace(/\.(?:com|exe|bat|cmd)$/i,``);return t===`adb`||t===`hdc`?t:void 0}export{u as a,r as c,d as i,l as n,i as o,p as r,n as s,f as t};
|
package/dist/src/device.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{A as n,P as r,T as i,a,w as o,y as ee}from"./sdk-device.js";const s=[`android`,`harmonyos`,`apple`,`vega`,`linux`];function c(e){let{booted:t,kind:n,...r}=e;return r}const l={platform:`web`,id:`agent-browser-chrome`,name:`Agent Browser Chrome`,kind:`device`,target:`desktop`,booted:!0};function u(e){let t=f();for(let n of e){let e=p(n);t[e].available+=1,n.booted===!0&&(t[e].booted+=1)}return t}function d(e,t){return e.filter(e=>r(e,t.platform)&&(t.target===void 0||(e.target??`mobile`)===t.target)&&(t.kind===void 0||e.kind===t.kind)&&(t.booted===void 0||e.booted===t.booted))}function f(){return{android:{available:0,booted:0},harmonyos:{available:0,booted:0},apple:{available:0,booted:0},vega:{available:0,booted:0},linux:{available:0,booted:0},web:{available:0,booted:0}}}function p(e){return o(e)||i(e)?`apple`:e.platform}const m=new Set([`DEVICE_CLAIM_LIVE_OWNER`,`DEVICE_CLAIM_RECOVERY_PENDING`,`DEVICE_CLAIM_OWNER_UNCERTAIN`]);function h(e){return m.has(e)}function g(e){return new t(`DEVICE_NOT_FOUND`,`The provider connection has no allocated instance.`,{reason:`provider_instance_unallocated`,hint:`Run boot or open to allocate an instance. SDK callers allocate one with leases.allocate and pass its leaseId.`,leaseProvider:e})}const _=[`platform`,`device`,`udid`,`serial`];function v(e,t){(!x(e)||Object.keys(e).length===0)&&b(`devicePin in ${t} must be a non-empty selector object.`,t);let r={};for(let[n,i]of Object.entries(e))(!_.includes(n)||typeof i!=`string`||!i.trim()||n===`platform`&&!a.includes(i))&&b(`Invalid devicePin.${n} in ${t}.`,t),Object.assign(r,{[n]:i});return(r.udid&&r.serial||r.platform&&(r.udid&&!ee(r.platform)||r.serial&&!n(r.platform)))&&b(`devicePin in ${t} contains incompatible selectors.`,t),r}function y(e){if(e===void 0)return;let t=`daemon request metadata`;(!x(e)||Object.keys(e).some(e=>e!==`selector`&&e!==`source`)||!x(e.source))&&b(`devicePin must contain selector and source objects.`,t);let{kind:n,path:r}=e.source;(n!==`user`&&n!==`project`&&n!==`explicit`||typeof r!=`string`||!r.trim()||Object.keys(e.source).some(e=>e!==`kind`&&e!==`path`))&&b(`devicePin.source must contain a config kind and non-empty path.`,t);let i=`${n===`project`?`project `:``}config file ${r}`;return{selector:v(e.selector,i),source:{kind:n,path:r}}}function b(e,n){throw new t(`INVALID_ARGS`,e,{reason:`invalid_device_pin`,pinSource:n})}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const S=`native-panel`,C=[`portrait`,`portrait-upside-down`,`landscape-left`,`landscape-right`],w={portrait:0,"landscape-left":1,"portrait-upside-down":2,"landscape-right":3};function T(e){return C.find(t=>w[t]===e)}function E(e){return typeof e==`string`&&C.includes(e)}function D(e){return w[e]*90}function O(e){return w[e]%2==0?`PORTRAIT`:`LANDSCAPE`}function k(e){if(e===void 0)throw new t(`INVALID_ARGS`,`orientation requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.`);switch(e?.trim().toLowerCase()){case`portrait`:return`portrait`;case`portrait-upside-down`:case`upside-down`:return`portrait-upside-down`;case`landscape-left`:case`left`:return`landscape-left`;case`landscape-right`:case`right`:return`landscape-right`;default:throw new t(`INVALID_ARGS`,`Invalid rotation: ${e}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}const A=[...C,`auto`];function j(e){return e?.trim().toLowerCase()===`auto`?`auto`:k(e)}const M=[`volume-up`,`volume-down`,`power`,`mute`,`sleep`,`wake`,`media-play-pause`,`media-next`,`media-previous`,`media-rewind`,`media-fast-forward`],N=`<${M.join(`|`)}>`,P={volumeUp:`volume-up`,volumeDown:`volume-down`,power:`power`,mute:`mute`,sleep:`sleep`,wake:`wake`,mediaPlayPause:`media-play-pause`,mediaNext:`media-next`,mediaPrevious:`media-previous`,mediaRewind:`media-rewind`,mediaFastForward:`media-fast-forward`},F=new Map(Object.entries(P).map(([e,t])=>[t,e]));function I(e){let n=e?.toLowerCase(),r=n===void 0?void 0:F.get(n);if(r)return r;throw new t(`INVALID_ARGS`,`hardware-button button must be one of: ${M.join(`, `)}.`)}function L(e){if(e.length!==1)throw new t(`INVALID_ARGS`,`hardware-button requires exactly one button: ${M.join(`, `)}.`);return I(e[0])}const R=[`closed`,`half-open`,`open`],z=`closed|half-open|open`;function B(e){if(Number.isFinite(e))return e<=V?`closed`:e>=te?`open`:`half-open`}const V=1,te=179;function H(e){if(e===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose argument. Use ${z}.`);switch(e.trim().toLowerCase()){case`closed`:case`close`:case`fold`:case`folded`:return`closed`;case`half-open`:case`half`:case`half-unfolded`:case`partially-open`:case`book`:return`half-open`;case`open`:case`unfold`:case`unfolded`:case`fully-open`:case`flat`:return`open`;default:throw new t(`INVALID_ARGS`,`Invalid fold pose: ${e}. Use ${z}.`)}}const U=6e4;function W(e){if(e.keyframes===void 0){if(e.pose===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose or keyframes`);if(typeof e.pose!=`string`)throw new t(`INVALID_ARGS`,`fold pose must be a string`);return{pose:H(e.pose)}}if(e.pose!==void 0)throw new t(`INVALID_ARGS`,`fold accepts either pose or keyframes`);return{keyframes:G(e.keyframes)}}function G(e){if(!Array.isArray(e)||e.length<2||e.length>64)throw new t(`INVALID_ARGS`,`fold requires 2–64 keyframes`);let n=e.map(q);if(n[0].atMs!==0||n.some((e,t)=>t>0&&e.atMs<=n[t-1].atMs))throw new t(`INVALID_ARGS`,`Fold keyframes must start at 0ms and increase strictly`);return n}function K(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=t}function q(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t(`INVALID_ARGS`,`Each fold keyframe requires atMs and angle`);let{atMs:n,angle:r}=e;if(Object.keys(e).some(e=>e!==`atMs`&&e!==`angle`))throw new t(`INVALID_ARGS`,`Fold keyframes only accept atMs and angle`);if(!K(n,6e4)||!Number.isSafeInteger(n))throw new t(`INVALID_ARGS`,`Fold keyframe times must be integers from 0 to ${U}ms`);if(!K(r,180))throw new t(`INVALID_ARGS`,`Fold keyframe angles must be finite numbers from 0 to 180`);return{atMs:n,angle:r}}function J(e){let n;try{n=JSON.parse(e)}catch{throw new t(`INVALID_ARGS`,`--keyframes requires a JSON array of {atMs, angle} objects`)}return G(n)}const Y=[`call`,`accept`,`cancel`],X=[...Y,`sms`],Z=`telephony call|accept|cancel <number> | telephony sms <number> <text>`,Q=/^\+?\d{1,15}$/,ne=/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/;function re(e){if(e===void 0)throw new t(`INVALID_ARGS`,`telephony requires an action. Use ${Z}.`);let n=typeof e==`string`?e.trim().toLowerCase():void 0,r=X.find(e=>e===n);if(!r)throw new t(`INVALID_ARGS`,`Invalid telephony action: ${String(e)}. Use ${X.join(`, `)}.`);return r}function $(e){let n=re(e.action),r=oe(e.number,n);if(n!==`sms`){if(e.text!==void 0)throw new t(`INVALID_ARGS`,`telephony ${n} takes only a phone number.`);return{action:n,number:r}}return{action:n,number:r,text:se(e.text)}}function ie(e){let[t,n,...r]=e;return $({action:t,number:n,text:r.length>0?r.join(` `):void 0})}function ae(e){return e.action===`sms`?[e.action,e.number,e.text]:[e.action,e.number]}function oe(e,n){if(typeof e!=`string`||e.trim()===``)throw new t(`INVALID_ARGS`,`telephony ${n} requires a phone number.`);let r=e.trim();if(!Q.test(r))throw new t(`INVALID_ARGS`,`Invalid phone number: ${r}.`,{hint:`Use digits with an optional leading +, for example 5551234 or +15551234567.`});return r}function se(e){if(typeof e!=`string`||e===``)throw new t(`INVALID_ARGS`,`telephony sms requires message text.`);let n=e.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`);if(ne.test(n))throw new t(`INVALID_ARGS`,`telephony sms text must not contain control characters.`,{hint:`Line breaks (LF or CRLF) are allowed; tabs, lone carriage returns, and other control characters are not.`});return n}var ce=e({FOLD_POSE_USAGE:()=>z,FOLD_SCREEN_COORDINATE_SPACE:()=>S,HARDWARE_BUTTON_NAME_LABELS:()=>P,MAX_FOLD_DURATION_MS:()=>U,MAX_FOLD_KEYFRAMES:()=>64,TELEPHONY_USAGE:()=>Z});export{u as A,W as C,j as D,L as E,g as F,y as I,h as M,v as N,s as O,c as P,E as S,H as T,A as _,$ as a,D as b,C as c,z as d,S as f,U as g,N as h,Z as i,d as j,l as k,w as l,P as m,X as n,ie as o,M as p,Y as r,ae as s,ce as t,R as u,T as v,J as w,B as x,O as y};
|
package/dist/src/device3.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}function
|
|
3
|
-
`)}function
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{R as t}from"./sdk-device.js";import{c as n}from"./device-shell.js";import{n as r}from"./device-claim-recovery.js";import{f as i,h as a,m as o,p as s}from"./device-claims.js";import{n as c}from"./shared.js";const l=async({positionals:t,flags:n,host:r})=>{if(t.length!==1||t[0]!==`status`&&t[0]!==`release`)throw new e(`INVALID_ARGS`,`device accepts only: status, release`);if(t[0]===`release`)return await f(n,r);let s=a({platform:n.platform,device:n.device,udid:n.udid,serial:n.serial},r.env),l=s.filter(e=>o(e.classification)),d=(n.stale?l:s.filter(e=>!o(e.classification))).map(v),p=n.json?await u(s,r.env):[],m={claims:d,...n.stale?{}:{hiddenStaleClaims:l.length},devices:p};return await c(n,m,()=>b(d,{staleOnly:n.stale===!0,hiddenStaleClaims:l.length,staleCommand:T(n,`status`),releasableClaims:l.filter(e=>i(e.classification)).length,releaseCommand:T(n,`release`)})),!0};async function u(e,t){let n=[],i=new Set;for(let a of e){let e=a.deviceKey,o=a.claim?.device;if(!e||!o||i.has(e))continue;i.add(e);let{family:s,...c}=o,{blockedBy:l,holder:u}=d(await r({device:{...c,platform:s},env:t}));n.push({deviceKey:e,device:y(o),acquirable:l===void 0,...l?{blockedBy:l}:{},...u?{owner:{session:u.session,workspace:u.workspace,stateDir:u.stateDir}}:{}})}return n}function d(e){if(e.status===`refused`)return{blockedBy:e.retainedBy??s(e.conflict.classification),holder:e.conflict.claim};for(let{claim:t,recovery:n}of e.reclaimed){let e=n?.status===`inspectable`?n.recoveryKinds[0]:void 0;if(e)return{blockedBy:`${e}-cleanup-pending`,holder:t}}return{holder:e.reclaimed[0]?.claim}}async function f(t,n){if(t.stale!==!0)throw new e(`INVALID_ARGS`,`device release only releases provably stale claims; pass --stale to confirm.`,{hint:`A live owner is released by closing its session from its own workspace, or by stopping its daemon: agent-device daemon stop --state-dir <owner state dir>.`});let{runStaleDeviceClaimRelease:r}=await import(`./platform-runtime-claim-recovery.js`),i=await r({platform:t.platform,device:t.device,udid:t.udid,serial:t.serial},n),a={released:i.filter(e=>e.status===`released`).map(p),retained:i.filter(e=>e.status===`retained`).map(p),refused:i.filter(e=>e.status===`refused`).map(p),changed:i.filter(e=>e.status===`changed`).map(p)};return await c(t,a,()=>m(i)),!0}function p(e){let{device:t,...n}=e;return{...n,...t?{device:y(t)}:{}}}function m(e){return e.length===0?`No local device claims matched.`:e.map(h).join(`
|
|
2
|
+
`)}function h(e){let n=e.device?`${t({platform:e.device.family,appleOs:e.device.appleOs})} ${e.device.name}`:e.deviceKey??e.fileName,r=g(e);switch(e.status){case`released`:return`released ${n}${r}`;case`retained`:return`retained ${n}${r} — resources not settled (${e.reason}); the claim stays until they are.`;case`refused`:return`refused ${n}${r} — ${e.reason} (${e.classification}); ${_(e)}`;case`changed`:return`changed ${n} — the claim changed while releasing; re-run device status.`}}function g(e){return e.session?` session=${e.session} workspace=${e.workspace}`:``}function _(e){return e.classification===`live`||e.classification===`owner-state-dir-gone`?e.stateDir?`close the owning session from its workspace, or stop its daemon: agent-device daemon stop --state-dir ${n(e.stateDir)}`:`close the owning session from its workspace first.`:`only provably dead owners are released; nothing was changed.`}function v(e){let t=e.claim;return{...e.deviceKey?{deviceKey:e.deviceKey}:{},...t?{}:{fileName:e.fileName},classification:e.classification,...t?{device:y(t.device)}:{},...e.claim?{owner:{session:e.claim.session,workspace:e.claim.workspace,stateDir:e.claim.stateDir,pid:e.claim.ownerPid,startTime:e.claim.ownerStartTime}}:{},...e.error?{error:e.error}:{}}}function y(e){let{family:n,...r}=e;return{...r,platform:t({platform:n,appleOs:e.appleOs})}}function b(e,t){let n=e.map(S);if(n.length===0){if(t.staleOnly)return`No stale local device claims found.`;if(t.hiddenStaleClaims===0)return`No local device claims found.`}return[...n.length===0?[`No live local device claims found.`]:n,...x(t)].join(`
|
|
3
|
+
`)}function x(e){if(e.staleOnly)return e.releasableClaims>0?[`Release provably dead owners with: ${e.releaseCommand}`]:[];if(e.hiddenStaleClaims===0)return[];let t=e.hiddenStaleClaims===1?`claim`:`claims`;return[`${e.hiddenStaleClaims} stale ${t} hidden; inspect with: ${e.staleCommand}`]}function S(e){return`${C(e)}: ${e.classification}${w(e.owner)}`}function C(e){let t=e.device;return t?`${t.platform??`unknown`} ${t.name??t.id??`claim`}`:String(e.deviceKey??e.fileName??`claim`)}function w(e){if(!e||typeof e!=`object`)return``;let t=e;return` session=${t.session} workspace=${t.workspace}`}function T(e,t){let r=[e.platform?`--platform ${n(e.platform)}`:null,e.device?`--device ${n(e.device)}`:null,e.udid?`--udid ${n(e.udid)}`:null,e.serial?`--serial ${n(e.serial)}`:null].filter(e=>!!e);return[`agent-device device ${t}`,...r,`--stale`].join(` `)}export{l as deviceCommand};
|
package/dist/src/devicectl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{S as t,Z as n}from"./sdk-io.js";import"./command.js";import{D as r,b as i,m as a}from"./host-file.js";import"./config.js";import{c as o,u as s}from"./tool-provider.js";import c from"node:path";async function l(t,r,i={}){let a=[`devicectl`,...t],s=await o(a,{allowFailure:!0,signal:i.signal,timeoutMs:i.timeoutMs??2e4});if(s.exitCode===0)return;let{stdout:c,stderr:l}=s;if(!i.tolerateOutput?.(c,l))throw new e(`COMMAND_FAILED`,`Failed to ${r.action}`,n(s,{cmd:`xcrun`,args:a,stdout:c,stderr:l,deviceId:r.deviceId,hint:O(c,l)??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}async function u(e,t){return C(x(await g(e,{jsonPrefix:`agent-device-ios-apps`,args:[`devicectl`,`device`,`info`,`apps`,`--device`,e.id,`--include-all-apps`],failureMessage:`Failed to list iOS apps`,parseFailureMessage:`Failed to parse iOS apps list`})),t)}async function d(t){let n=await g(t,{jsonPrefix:`agent-device-ios-processes`,args:[`devicectl`,`device`,`info`,`processes`,`--device`,t.id],failureMessage:`Failed to list iOS processes`,parseFailureMessage:`Failed to parse iOS process list`,fallbackHint:T});if(!y(n))throw new e(`COMMAND_FAILED`,`Unsupported iOS process list response`,{deviceId:t.id,hint:T});return S(n)}async function f(e,t){let{appBundleUrl:n,processes:r}=await p(e,t),i=r.sort((e,t)=>v(e,n)-v(t,n))[0];i&&await g(e,{jsonPrefix:`agent-device-ios-process-terminate`,args:[`devicectl`,`device`,`process`,`terminate`,`--device`,e.id,`--pid`,String(i.pid),`--kill`],failureMessage:`Failed to terminate iOS app`,parseFailureMessage:`Failed to parse iOS process termination response`,tolerateFailurePayload:b})}async function p(t,n){let r=(await u(t,`all`)).find(e=>e.bundleId===n);if(!r)throw new e(`APP_NOT_INSTALLED`,`No iOS device app found for ${n}`,{appBundleId:n,deviceId:t.id});if(!r.url)throw new e(`COMMAND_FAILED`,`Missing app bundle URL for ${n}`,{appBundleId:n,deviceId:t.id,hint:`Installed-app metadata from devicectl did not include the bundle URL required to match running processes. Use an Xcode/CoreDevice toolchain that reports app URLs.`});let i=r.url.replace(/\/+$/,``);return{appBundleUrl:i,processes:(await d(t)).filter(e=>e.executable.startsWith(`${i}/`))}}async function m(e){let n=c.join(a(),`${e.jsonPrefix}-${t()}-${Date.now()}-${Math.random().toString(36).slice(2)}.json`),i=[...e.args,`--json-output`,n];try{let t=await o(i,{allowFailure:!0,signal:e.signal,timeoutMs:e.timeoutMs??2e4});if(t.exitCode!==0){let r=await _(n).catch(()=>void 0);return r!==void 0&&e.tolerateFailurePayload?.(r)?{ok:!0,payload:r}:{ok:!1,reason:`command-failed`,args:i,result:t,payload:r}}return await h(n,i,t)}finally{await r(n).catch(()=>{})}}async function h(t,n,r){try{return{ok:!0,payload:await _(t)}}catch(t){if(t instanceof e)throw t;return{ok:!1,reason:`unreadable-json`,args:n,result:r,cause:String(t)}}}async function g(t,r){let i=await m(r);if(i.ok)return i.payload;if(i.reason===`command-failed`){let{stdout:a,stderr:o}=i.result;throw new e(`COMMAND_FAILED`,r.failureMessage,n(i.result,{cmd:`xcrun`,args:i.args,stdout:a,stderr:o,deviceId:t.id,hint:O(a,o)??r.fallbackHint??`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`}))}throw new e(`COMMAND_FAILED`,r.parseFailureMessage,{deviceId:t.id,cause:i.cause})}async function _(e){return JSON.parse(await i(e))}function v(e,t){return e.executable.slice(t.length+1).split(`/`).length}function y(e){return Array.isArray(e?.result?.runningProcesses)}function b(e){let t=e?.error?.userInfo?.NSUnderlyingError?.error;return t?.domain===`NSPOSIXErrorDomain`&&t.code===3}function x(e){let t=e?.result?.apps;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.bundleIdentifier==`string`?e.bundleIdentifier.trim():``;if(!t)continue;let r=typeof e.name==`string`&&e.name.trim().length>0?e.name.trim():t,i=typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():void 0;n.push({bundleId:t,name:r,url:i})}return n}function S(e){let t=e?.result?.runningProcesses;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=typeof e.executable==`string`?e.executable.trim():``,r=typeof e.processIdentifier==`number`&&Number.isFinite(e.processIdentifier)?e.processIdentifier:NaN;!t||!Number.isFinite(r)||n.push({executable:t,pid:r})}return n}function C(e,t){return s(e,t)}const w=`Ensure the iOS device is unlocked, trusted, and available in Xcode > Devices, then retry.`,T=`This Xcode/CoreDevice toolchain must support 'devicectl device info processes' with JSON runningProcesses so agent-device can resolve app process IDs. Inspect diagnostics for the exact devicectl API failure.`,E=`Enable Developer Mode on the iOS device (Settings > Privacy & Security > Developer Mode), restart it when prompted, unlock it, then retry.`,D=`Let Xcode finish preparing this device: keep it unlocked and connected by cable, open Xcode > Settings > Platforms (or Window > Devices and Simulators), wait for device support to install, then retry.`;function O(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`device is busy`)&&n.includes(`connecting`)?`iOS device is still connecting. Keep it unlocked and connected by cable until it is fully available in Xcode Devices, then retry.`:n.includes(`coredeviceservice`)&&n.includes(`timed out`)?`CoreDevice service timed out. Reconnect the device and retry; if it persists restart Xcode and the iOS device.`:n.includes(`developer mode is disabled`)?E:n.includes(`developer disk image`)?D:n.includes(`must be paired`)?`Pair the iOS device with this Mac: connect it by cable, unlock it, accept the Trust prompt, and enter the device passcode, then retry.`:null}export{p as a,m as c,u as i,f as l,D as n,O as o,E as r,l as s,w as t};
|
package/dist/src/diagnostics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{St as t}from"./sdk-io.js";var n=e({DIAGNOSTIC_STDERR_PREFIX:()=>DIAGNOSTIC_STDERR_PREFIX,emitDiagnostic:()=>t});export{n as t};
|
package/dist/src/discovery.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{y as t}from"./sdk-batch-runner.js";import{a as n,i as r}from"./manifest.js";import i from"node:fs";import a from"node:path";const o=/^[a-z][a-z0-9-]*$/;function s(e){return typeof e==`string`&&o.test(e)}const c=`./agent-device`;function l(e){let t=u(e),i=f(t.exports,c);if(i.status===`resolved`)return{kind:`v2`,file:n(e,i.target)};if(i.status===`blocked`)throw y(e,c);if(t.agentDevicePlugin!==void 0)return{kind:`v1`,manifest:r(e)};let o=f(t.exports,`.`);if(o.status===`blocked`)throw y(e,`.`);let s=o.status===`resolved`?o.target:(t.exports===void 0||t.exports===null)&&typeof t.main==`string`?`./${a.posix.normalize(t.main)}`:void 0;if(s===void 0)throw b(e,c);return{kind:`v2`,file:n(e,s)}}function u(n){try{let e=JSON.parse(i.readFileSync(a.join(n,`package.json`),`utf8`));if(t(e))return e}catch(t){throw new e(`INVALID_ARGS`,`Cannot read plugin manifest: ${n}`,{reason:`plugin_load_failed`},t)}throw new e(`INVALID_ARGS`,`Cannot read plugin manifest: ${n}`,{reason:`plugin_load_failed`})}const d=new Set([`node`,`import`,`module-sync`,`node-addons`,`default`]);function f(e,t){if(e==null)return{status:`absent`};if(!m(e))return t===`.`?p(g(e,void 0)):{status:`absent`};if(Object.hasOwn(e,t)&&!t.includes(`*`))return p(g(e[t],void 0));let n=h(Object.keys(e),t);return n?p(g(e[n.key],n.captured)):{status:`absent`}}function p(e){return typeof e==`string`?{status:`resolved`,target:e}:{status:`blocked`}}function m(e){return t(e)&&Object.keys(e).some(e=>e.startsWith(`.`))}function h(e,t){let n;for(let r of e){let e=r.indexOf(`*`);if(e===-1||e!==r.lastIndexOf(`*`))continue;let i=r.slice(0,e),a=r.slice(e+1);t.startsWith(i)&&t!==i&&t.length>=r.length&&t.endsWith(a)&&(!n||i.length>n.base.length||i.length===n.base.length&&r.length>n.key.length)&&(n={key:r,base:i,trailer:a})}return n?{key:n.key,captured:t.slice(n.base.length,t.length-n.trailer.length)}:void 0}function g(e,n){if(typeof e==`string`)return _(e,n);if(e===null)return null;if(Array.isArray(e))return v(e.map(e=>()=>g(e,n)));if(t(e))return v(Object.entries(e).filter(([e])=>d.has(e)).map(([,e])=>()=>g(e,n)))}function _(e,t){if(e.startsWith(`./`))return t===void 0?e:e.replaceAll(`*`,t)}function v(e){for(let t of e){let e=t();if(e!==void 0)return e}}function y(t,n){return new e(`INVALID_ARGS`,`Package exports ${n} without an import target`,{reason:`incompatible_plugin`,directory:t,hint:`Ask the plugin author for a release whose ${n} export has an import condition.`})}function b(t,n){return new e(`INVALID_ARGS`,`Package does not export a provider plugin`,{reason:`incompatible_plugin`,directory:t,hint:`Install a plugin release that exports ${n}.`})}export{l as discoverPluginEntry,s as isProviderId,u as readPackageJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{Ot as n}from"./sdk-io.js";import"./diagnostics.js";import{H as r,m as i,q as a,y as o}from"./sdk-device.js";import{n as s}from"./device-isolation.js";import{a as c,i as l,o as u,r as d}from"./device-inventory-context.js";import{AsyncLocalStorage as f}from"node:async_hooks";var p=e({buildDeviceInventoryRequestFromFlags:()=>C,resolveTargetDevice:()=>v,resolveTargetDeviceSelection:()=>y,withResolveTargetDeviceCacheScope:()=>w});async function m(e){let{resolveInventoryDeviceSelection:t}=await import(`./device-selection-resolver.js`).then(e=>e.t);return await t(e)}const h=new f;function g(e,n){return!i(n)&&e instanceof t&&e.code===`DEVICE_NOT_FOUND`}function _(e,t){return!i(e)&&(!e.platform||e.platform===`apple`||e.platform===`ios`)&&e.target!==`desktop`&&(!t||t.kind===`device`)}async function v(e,t){return(await y(e,t)).device}async function y(e,t){let r={...C(e,t.env),androidAvdSelection:t.androidAvdSelection??`running-only`},{iosSimulatorSetPath:i,...a}=r,s=D(r,t),l={platform:r.platform,target:e.target,...r.udid?{udid:r.udid}:{},...i?{iosSimulatorSetPath:i}:{},cacheHit:!1};return await n(`resolve_target_device`,async()=>{let e=T(s);if(e)return l.cacheHit=!0,await b(e,t);let n=await c(r),u=[...n.devices];if(o(a.platform)&&n.source===`local`){let e=await x(u,a,{simulatorSetPath:i,appleSimulatorAppTarget:t.appleSimulatorAppTarget,boot:t.boot});return await b(E(s,e),t)}let d=await m({devices:u,selector:a,source:n.source,boot:t.boot});return await b(E(s,d),t)},l)}async function b(e,t){if(t.webSession!==void 0&&e.source===`local`&&e.device.platform===`web`)return{...e,device:a(e.device,t.webSession)};let n=t.appDeviceTarget,r=n?l():void 0;if(!n||!r||e.source!==`local`)return e;let i=await r(e.device,n);return i?{...e,device:i}:e}async function x(e,n,r){let i;try{i=await m({devices:e,selector:n,source:`local`,appleSimulatorAppTarget:r.appleSimulatorAppTarget,boot:r.boot})}catch(e){if(!g(e,n))throw e}let a=await S(n,r,i?.device);if(a)return a;if(i)return i;throw new t(`DEVICE_NOT_FOUND`,`No devices found`,{selector:n})}async function S(e,t,n){if(_(e,n))try{return await m({devices:await d({platform:e.platform??`ios`,target:e.target,iosSimulatorSetPath:t.simulatorSetPath,kind:`simulator`}),selector:e,source:`local`,boot:t.boot})}catch(e){if(u(e))throw e;return}}function C(e,n){let i=e.platform;if(e.target&&!i)throw new t(`INVALID_ARGS`,`Device target selector requires --platform. Use --platform ios|macos|android|vega|linux|apple with --target mobile|tv|desktop.`);let a=r({requestedSetPath:e.iosSimulatorDeviceSet,platform:i,target:e.target,env:n}),o=s(e.androidDeviceAllowlist,n);return{platform:i,target:e.target,deviceName:e.device,udid:e.udid,serial:e.serial,leaseId:e.leaseId,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId,iosSimulatorSetPath:a,androidSerialAllowlist:o?Array.from(o).sort():void 0}}async function w(e){return h.getStore()?await e():await h.run(new Map,e)}function T(e){let t=h.getStore()?.get(e);if(t)return{...t,device:{...t.device}}}function E(e,t){return h.getStore()?.set(e,{...t,device:{...t.device}}),t}function D(e,t){let{env:n,appleSimulatorAppTarget:r,appDeviceTarget:i,webSession:a,...o}=t;return JSON.stringify({request:e,options:o})}export{w as a,y as i,p as n,v as r,C as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{Q as n,St as r}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import{l as i}from"./config.js";import{c as a}from"./devicectl.js";import{d as o}from"./simctl.js";var s=e({appleLitPanel:()=>j,appleSimulatorDisplayArgvFragment:()=>L,buildInventory:()=>D,establishedLitPanel:()=>A,panelContentRotation:()=>F,parseCoreDeviceDisplays:()=>v,queryAppleDisplayInventory:()=>u,readPanelPower:()=>T,resolveAppleCaptureDisplay:()=>M,resolveAppleCaptureTarget:()=>N});const c=new Set([`activeOn`,`inactiveOn`,`activeDimmed`]),l=new Set([`off`]);async function u(e,t){let n=t.source===`guest`||o(e).simulatorSetPath?await f(e,t):await d(e,t);return n.ok?m(e,n.payload):(g(e,n.reason,n.detail),_())}async function d(e,t){try{let n=await a({jsonPrefix:`agent-device-apple-displays`,args:[`devicectl`,`device`,`info`,`displays`,`--device`,e.id],timeoutMs:t.timeoutMs??5e3,signal:t.signal});return n.ok?{ok:!0,payload:n.payload}:{ok:!1,reason:n.reason,detail:n.result.stderr.trim()}}catch(e){return p(e,n(e)?`probe-timed-out`:`probe-failed`)}}async function f(e,t){let r=AbortSignal.timeout(i),a=t.signal?AbortSignal.any([t.signal,r]):r;try{let{createFoldHelper:n}=await import(`./fold-helper.js`).then(e=>e.r);return{ok:!0,payload:await(t.foldHelper??n(e)).readPanelPayload({signal:a,timeoutMs:t.timeoutMs??5e3})}}catch(e){return t.signal?.throwIfAborted(),p(e,n(e)||r.aborted?`probe-timed-out`:`guest-panels-failed`)}}function p(e,t){return{ok:!1,reason:t,detail:e instanceof Error?e.message:String(e)}}function m(e,t){let n=v(t),r=h(t);return n.filter(e=>e.integrated).length===r&&n.length>0?D(n):r>=2?{displays:n.filter(e=>e.integrated),multiScreen:!0,ambiguous:!0,unresolved:!1}:(g(e,n.length===0?`empty-display-list`:`incomplete-panel-table`,``),_())}function h(e){let t=e?.result?.displays;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&E(e.type)).length:0}function g(e,t,n){r({level:`warn`,phase:`apple_display_inventory_unresolved`,data:{platform:e.platform,deviceId:e.id,reason:t,...n?{detail:n}:{},...t===`command-failed`||t===`unreadable-json`?{hint:`This Xcode/CoreDevice toolchain does not report 'devicectl device info displays'. Update Xcode to a version that ships the display-information feature before targeting multi-display Apple devices.`}:{}}})}function _(){return{displays:[],multiScreen:!1,ambiguous:!1,unresolved:!0}}function v(e){let t=e?.result?.displays;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=y(e);t&&n.push(t)}return n}function y(e){let t=b(e);if(t)return{...t,power:T(e.backlightState,e.active),primary:e.primary===!0,currentOrientation:typeof e.currentOrientation==`string`?e.currentOrientation:`unknown`,integrated:E(e.type)}}function b(e){let t=x(e.name),n=C(e.displayId),r=w(e.pointScale),i=S(e.nativeSize);if(!(!t||n===void 0||r===void 0||!i))return{name:t,displayId:n,pointScale:r,widthPx:i.widthPx,heightPx:i.heightPx}}function x(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function S(e){if(!Array.isArray(e))return;let t=w(e[0]),n=w(e[1]);if(t!==void 0&&n!==void 0)return{widthPx:t,heightPx:n}}function C(e){return typeof e==`number`&&Number.isInteger(e)?e:void 0}function w(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function T(e,t){return typeof e==`string`?c.has(e)?`lit`:l.has(e)?`dark`:`unknown`:t===!0?`lit`:t===!1?`dark`:`unknown`}function E(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`integrated`)}function D(e){let t=e.filter(e=>e.integrated);if(t.length<2)return{displays:e,multiScreen:!1,ambiguous:!1,unresolved:!1};k(t);let n=t.filter(e=>e.power===`lit`),i=t.find(e=>e.primary),a=n.length===1,o=a?n[0]:i,s=!a||i===void 0;return s&&r({level:`warn`,phase:`apple_display_capture_ambiguous`,data:{reason:i===void 0?`no-primary-panel`:`lit-panel-count`,litPanelCount:n.length,...o?{capturedDisplay:o.name,hint:`Panel power did not identify exactly one lit panel, so the capture names the primary panel without claiming to know which panel the device is showing. Read the device pose from the app under test with UIHinge.status.`}:{hint:O}}}),{displays:t,multiScreen:!0,...o?{activeDisplay:o}:{},ambiguous:s,unresolved:!1}}const O=`The panel table named no primary panel and panel power did not identify exactly one lit panel. Retry after one panel reports a lit backlightState; agent-device help foldable names the panel table source for each device set.`;function k(e){let t=e.find(e=>e.primary);if(!t)return;let n=e=>e.widthPx*e.heightPx,i=e.filter(e=>e!==t).reduce((e,t)=>n(t)>n(e)?t:e);n(t)<n(i)||r({level:`warn`,phase:`apple_display_primary_geometry_conflict`,data:{primaryDisplay:t.name,largestDisplay:i.name,hint:"The panel table reported the primary panel as at least as large as the other panel. Its `primary` flag still selects the capture fallback; verify the device type capabilities."}})}function A(e){if(!e.multiScreen||e.unresolved||!e.activeDisplay||e.displays.some(e=>e.power===`unknown`))return;let t=e.displays.filter(e=>e.power===`lit`);if(t.length===1&&t[0]===e.activeDisplay)return t[0]}function j(e){let t=A(e);if(!(!t||t.displayId<=0))return{displayId:t.displayId,widthPt:t.widthPx/t.pointScale,heightPt:t.heightPx/t.pointScale}}async function M(e,t={}){return(await N(e,t)).display}async function N(e,n={}){let r=await u(e,n);if(r.unresolved)return{};if(r.multiScreen){if(r.activeDisplay)return{display:r.activeDisplay};throw new t(`COMMAND_FAILED`,`The panel table did not identify which panel of ${e.name} to capture`,{deviceId:e.id,reason:`capture-panel-unidentified`,litPanelCount:r.displays.filter(e=>e.power===`lit`).length,hint:O})}let i=r.displays.find(e=>e.integrated),a=i?I(i):void 0;return a?{displayRotation:a}:{}}const P=new Map([[`rot0`,`portrait`],[`rot90`,`landscape-right`],[`rot180`,`portrait-upside-down`],[`rot270`,`landscape-left`]]);function F(e){return P.get(e)}function I(e){return F(e.currentOrientation)}function L(e){return e?[`--display=${e.name}`]:[]}export{F as a,A as i,L as n,u as o,s as r,N as s,j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{x as e}from"./sdk-io.js";import{w as t}from"./sdk-device.js";import{n}from"./toolchain-probe.js";import{a as r}from"./src8.js";import{v as i}from"./runner-disposal.js";import"./runner-client.js";async function a(){let e=await n(`xcodebuild`,[`-version`]);return e?s({selectedPath:await n(`xcode-select`,[`-p`]),versionLine:e}):u()}async function o(n,a){if(!(!t(n)||n.kind!==`simulator`)&&!(e()!==`darwin`||a.isProviderDevice(n)))return a.emitProgress(`Checking iOS runner build cache (${n.name})...`),await i(n)?{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner artifact cached; first open skips the runner build`}:(r(n,{}),a.emitProgress(`Warming iOS runner build cache in the background (${n.name})...`),{id:`ios-runner-cache`,status:`pass`,summary:`iOS runner build started in the background; the first open gets faster once it completes`,hint:"Run `agent-device prepare ios-runner` to wait for a fully warmed runner instead."})}function s(e){return{id:`toolchain`,status:c(e),summary:l(e),evidence:{selectedPath:e.selectedPath??null,xcodeVersion:e.versionLine??null}}}function c(e){return e.versionLine?`pass`:`info`}function l(e){return e.versionLine?e.selectedPath?`Apple toolchain: ${e.versionLine}; xcode-select ${e.selectedPath}.`:`Apple toolchain: ${e.versionLine}; xcode-select path unavailable.`:`Apple toolchain: xcodebuild version check failed.`}function u(){return{id:`toolchain`,status:`info`,summary:`Apple toolchain: xcodebuild version check failed.`,hint:`Install/select Xcode and complete first launch/license setup if xcodebuild reports it.`,command:`xcodebuild -version`}}export{o as appleRunnerWarmupCheck,a as appleToolchainCheck};
|
package/dist/src/doctor2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{i as t,t as n}from"./toolchain-probe.js";import{i as r,n as i,r as a,t as o}from"./tool-provider3.js";async function s(e,s){let l=a()?r():i(o(s));if(!await l.isAvailable())return{id:`toolchain`,status:`info`,summary:`Vega toolchain: Vega CLI not found.`,hint:`Install Vega Developer Tools or ensure ~/vega/bin/vega is executable.`,command:`vega --version`};let u=await l.version({allowFailure:!0,timeoutMs:n}),f=await c(e),p=t(u.stdout),m=f.devices.some(e=>e.platform===`vega`&&e.kind===`emulator`&&e.target===`tv`&&e.booted===!0);return{id:`toolchain`,status:u.exitCode===0?`pass`:`info`,summary:p?`Vega toolchain: ${p}; ${m?`VVD running`:`no running VVD`}.`:`Vega toolchain: CLI found but version check failed.`,hint:m?void 0:`Start the Vega Virtual Device and retry doctor.`,evidence:{vegaVersion:p??null,deviceList:d(f)}}}async function c(e){try{return{devices:await e.listLocalDeviceInventory({platform:`vega`,target:`tv`}),listedSerials:[]}}catch(t){if(e.shouldPropagateInventoryProbeError(t))throw t;return{devices:[],listedSerials:l(t)}}}function l(t){if(!(t instanceof e)||t.code!==`DEVICE_NOT_FOUND`)return[];let n=t.details?.listedSerials;return u(n)?n:[]}function u(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function d(e){return(e.devices.length>0?e.devices.map(e=>e.id):e.listedSerials).join(`, `)||null}export{s as vegaToolchainCheck};
|